Skip to content

Commit

Permalink
fix oops with default tp keys overlapping walking
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Jan 5, 2021
1 parent ab4cb0a commit 24166fd
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 18 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
59 changes: 45 additions & 14 deletions crates/injected/cxx/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,26 @@ std::map<std::string, int> 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 },
{ "zoom_default", 0x132 },
{ "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 },
};

Expand Down Expand Up @@ -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" };

Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -449,6 +451,9 @@ bool process_keys(
{
set_zoom();
}
else if(pressed("tool_debug", wParam)) {
hidedebug = !hidedebug;
}
else
{
return false;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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";
}

Expand Down Expand Up @@ -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)
Expand Down
33 changes: 33 additions & 0 deletions crates/injected/src/ui.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{db::ffi::EntityItem, models::State};


#[cxx::bridge]
pub mod ffi {
extern "Rust" {
Expand All @@ -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");
Expand Down Expand Up @@ -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 => {}
}
}

0 comments on commit 24166fd

Please sign in to comment.