From 24166fd2c5846a63c2fabd774830dbd6a8339096 Mon Sep 17 00:00:00 2001 From: Dregu Date: Tue, 5 Jan 2021 07:21:43 +0200 Subject: [PATCH] fix oops with default tp keys overlapping walking --- README.md | 10 ++++--- crates/injected/cxx/ui.cpp | 59 +++++++++++++++++++++++++++++--------- crates/injected/src/ui.rs | 33 +++++++++++++++++++++ 3 files changed, 84 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 912cb9f4d..b30a62525 100644 --- a/README.md +++ b/README.md @@ -14,17 +14,19 @@ You are strongly discouraged from using any modding tools in your actual online ## Features Current features and their *default* keyboard shortcuts: - **F1**: Search and spawn entities where you're standing - + **Enter**: Spawn entity + + **Enter**: Spawn entity (when tool is active) + **Ctrl+Arrows**: Move spawn coordinates around you - + **Ctrl+Enter**: Teleport to coordinates - + **Shift+Arrows**: Teleport to direction + + **Ctrl+Shift+Arrows**: Teleport to direction + + **Ctrl+Shift+Space**: Teleport to coordinates + **Mouse left**: Spawn entity at mouse cursor + **Mouse right**: Teleport to mouse cursor + Enter multiple numeric IDs like `526 560 570` to spawn them all at once. Useful for making a kit you can just paste in. - **F2**: Spawn doors to many places - + **Enter**: Spawn warp door + + **Enter**: Spawn warp door (when tool is active) + **Shift+Enter**: Spawn back layer door + + **Ctrl+Shift+Enter**: Spawn warp door - **F3**: Camera controls + + **Enter**: Set zoom (when tool is active) + **Ctrl+,**: Zoom in + **Ctrl+.**: Zoom out + **Ctrl+Numbers**: Set zoom level diff --git a/crates/injected/cxx/ui.cpp b/crates/injected/cxx/ui.cpp index 07e3927c6..2516892e6 100644 --- a/crates/injected/cxx/ui.cpp +++ b/crates/injected/cxx/ui.cpp @@ -30,10 +30,10 @@ std::map keys{ { "tool_door", 0x71 }, { "tool_camera", 0x72 }, { "tool_options", 0x78 }, - { "spawn_entity", 0x120 }, + { "tool_debug", 0x344 }, + { "spawn_entity", 0x10d }, { "spawn_layer_door", 0x20d }, - { "spawn_warp_door", 0x220 }, - { "teleport", 0x10d }, + { "spawn_warp_door", 0x30d }, { "hide_ui", 0x7a }, { "zoom_in", 0x1bc }, { "zoom_out", 0x1be }, @@ -41,14 +41,15 @@ std::map keys{ { "zoom_3x", 0x133 }, { "zoom_4x", 0x134 }, { "zoom_5x", 0x135 }, - { "teleport_left", 0x225 }, - { "teleport_up", 0x226 }, - { "teleport_right", 0x227 }, - { "teleport_down", 0x228 }, + { "teleport", 0x320 }, + { "teleport_left", 0x325 }, + { "teleport_up", 0x326 }, + { "teleport_right", 0x327 }, + { "teleport_down", 0x328 }, { "coordinate_left", 0x125 }, { "coordinate_up", 0x126 }, { "coordinate_right", 0x127 }, - { "coordinate_down", 0x128 } + { "coordinate_down", 0x128 }, //{ "", 0x }, }; @@ -95,6 +96,7 @@ bool hidegui = false; bool clickevents = false; bool file_written = false; bool god = false; +bool hidedebug = true; const char* themes[] = { "1: Dwelling", "2: Jungle", "2: Volcana", "3: Olmec", "4: Tide Pool", "4: Temple", "5: Ice Caves", "6: Neo Babylon", "7: Sunken City", "8: Cosmic Ocean", "4: City of Gold", "4: Duat", "4: Abzu", "6: Tiamat", "7: Eggplant World", "7: Hundun" }; @@ -363,19 +365,19 @@ bool process_keys( } else if (pressed("teleport_left", wParam)) { - teleport(-1, 0, false); + teleport(-3, 0, false); } else if (pressed("teleport_right", wParam)) { - teleport(1, 0, false); + teleport(3, 0, false); } else if (pressed("teleport_up", wParam)) { - teleport(0, 1, false); + teleport(0, 3, false); } else if (pressed("teleport_down", wParam)) { - teleport(0, -1, false); + teleport(0, -3, false); } else if (pressed("spawn_layer_door", wParam)) { @@ -449,6 +451,9 @@ bool process_keys( { set_zoom(); } + else if(pressed("tool_debug", wParam)) { + hidedebug = !hidedebug; + } else { return false; @@ -701,12 +706,26 @@ void render_options() { ImGui::Checkbox("##clickevents", &clickevents); ImGui::SameLine(); - ImGui::Text("Enable click to spawn/teleport"); + ImGui::Text("Mouse controls"); if(ImGui::Checkbox("##Godmode", &god)) { godmode(god); } ImGui::SameLine(); - ImGui::Text("Enable god mode"); + ImGui::Text("God mode"); +} + +void render_debug() +{ + ImGui::Text("You're not supposed to be here!"); + if(ImGui::Button("List items")) + { + list_items(); + } + ImGui::SameLine(); + if(ImGui::Button("Player status")) + { + player_status(); + } } void create_render_target() @@ -802,6 +821,7 @@ HRESULT __stdcall hkPresent(IDXGISwapChain *pSwapChain, UINT SyncInterval, UINT windows["tool_door"] = "Door to anywhere ("+key_string(keys["tool_door"])+")"; windows["tool_camera"] = "Camera ("+key_string(keys["tool_camera"])+")"; windows["tool_options"] = "Options ("+key_string(keys["tool_options"])+")"; + windows["tool_debug"] = "Debug ("+key_string(keys["tool_debug"])+")"; windows["entities"] = "##Entities"; } @@ -854,6 +874,17 @@ HRESULT __stdcall hkPresent(IDXGISwapChain *pSwapChain, UINT SyncInterval, UINT ImGui::End(); } + if(!hidedebug) + { + ImGui::SetNextWindowSize({400, ImGui::GetIO().DisplaySize.y-100}, ImGuiCond_FirstUseEver); + ImGui::SetNextWindowPos({ImGui::GetIO().DisplaySize.x-400, 100}, ImGuiCond_FirstUseEver); + ImGui::Begin(windows["tool_debug"].c_str()); + ImGui::PushItemWidth(-1); + render_debug(); + ImGui::PopItemWidth(); + ImGui::End(); + } + ImGui::Render(); if(!file_written) diff --git a/crates/injected/src/ui.rs b/crates/injected/src/ui.rs index 4000eafbc..6646c5dda 100644 --- a/crates/injected/src/ui.rs +++ b/crates/injected/src/ui.rs @@ -1,5 +1,6 @@ use crate::{db::ffi::EntityItem, models::State}; + #[cxx::bridge] pub mod ffi { extern "Rust" { @@ -9,6 +10,8 @@ pub mod ffi { unsafe fn teleport(x: f32, y: f32, s: bool); unsafe fn godmode(g: bool); unsafe fn zoom(level: f32); + unsafe fn list_items(); + unsafe fn player_status(); } unsafe extern "C++" { include!("cxx/ui.hpp"); @@ -114,3 +117,33 @@ pub unsafe fn godmode(g: bool) { pub unsafe fn zoom(level: f32) { State::new().zoom(level); } + +pub unsafe fn list_items() { + let state = State::new(); + match state.items().player(0) { + Some(player) => { + for item in state.layer(player.layer()).items() { + log::debug!( + "Item: {} {:x}, position: {:?}", + item.unique_id(), + item._type().search_flags, + item.position_self() + ); + } + } + None => {} + } +} + +pub unsafe fn player_status() { + let state = State::new(); + match state.items().player(0) { + Some(player) => { + let status = player.status(); + log::debug!("Player status: {:?}", [status.rope(), status.bomb()]); + status.set_rope(99); + status.set_bomb(99); + } + None => {} + } +}