From 9a30776f2d4f508bb93c78b652de801afaa01e6f Mon Sep 17 00:00:00 2001 From: Dregu Date: Fri, 8 Jan 2021 08:24:30 +0200 Subject: [PATCH] added some kind of entity deleting --- crates/injected/cxx/ui.cpp | 23 +++++++++++++++++++++-- crates/injected/src/models.rs | 5 +++++ crates/injected/src/ui.rs | 5 ++--- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/crates/injected/cxx/ui.cpp b/crates/injected/cxx/ui.cpp index 2806bf048..7d515d4cf 100644 --- a/crates/injected/cxx/ui.cpp +++ b/crates/injected/cxx/ui.cpp @@ -64,7 +64,9 @@ std::map keys{ { "mouse_boom", 0x504 }, { "mouse_big_boom", 0x604 }, { "mouse_nuke", 0x704 }, - { "mouse_clone", 0x405 }, + { "mouse_clone", 0x505 }, + { "mouse_destroy", 0x405 }, + { "mouse_destroy_unsafe", 0x605 }, //{ "", 0x }, }; @@ -988,7 +990,7 @@ void render_clickhandler() unsigned int mask = 0b01111111; if(held("mouse_grab_unsafe")) { - mask = 2147483647; + mask = 0xffffffff; } g_held_entity = get_entity_at(g_x, g_y, true, 2, mask); g_flags = get_entity_flags(g_held_entity); @@ -1078,6 +1080,23 @@ void render_clickhandler() spawn_entity(631, g_x-0.15, g_y-0.2, true, g_vx, g_vy, snap_to_grid); g_x = 0; g_y = 0; g_vx = 0; g_vy = 0; } + else if(released("mouse_destroy") || released("mouse_destroy_unsafe")) + { + ImVec2 pos = ImGui::GetMousePos(); + set_pos(pos); + unsigned int mask = 0b01111111; + if(released("mouse_destroy_unsafe")) + { + mask = 0xffffffff; + } + g_held_entity = get_entity_at(g_x, g_y, true, 2, mask); + if(g_held_entity > 0) + { + // lets just sweep this under the rug for now :D + move_entity(g_held_entity, 0, -1000, false, 0, 0, true); + } + g_x = 0; g_y = 0; g_vx = 0; g_vy = 0; g_held_entity = 0; + } int buttons = 0; for(int i = 0; i < ImGuiMouseButton_COUNT; i++) { if(ImGui::IsMouseDown(i)) diff --git a/crates/injected/src/models.rs b/crates/injected/src/models.rs index af40e92c0..8f71ac164 100644 --- a/crates/injected/src/models.rs +++ b/crates/injected/src/models.rs @@ -263,6 +263,10 @@ impl State { pub fn zoom(&self, level: f32) { log::debug!("Zoom level: {:?}", level); let memory = Memory::get(); + // This technically sets camp zoom but not interactively :( + //let mut addr_zoom = find_inst(memory.exe(), &hex!("C7 80 E8 04 08 00"), memory.after_bundle); + //write_mem_prot(memory.at_exe(addr_zoom + 6), &level.to_le_bytes(), true); + //addr_zoom = memory.after_bundle; let mut addr_zoom = memory.after_bundle; let mut real_addr; for i in 0..3 { @@ -392,6 +396,7 @@ impl Entity { pub fn unique_id(&self) -> u32 { read_u32(self.pointer + 0x38) } + pub fn flags(&self) -> u32 { read_u32(self.pointer + 0x30) } diff --git a/crates/injected/src/ui.rs b/crates/injected/src/ui.rs index 6ec3ebb91..f02e884d3 100644 --- a/crates/injected/src/ui.rs +++ b/crates/injected/src/ui.rs @@ -155,13 +155,12 @@ pub unsafe fn get_entity_at(mut x: f32, mut y: f32, s: bool, r: f32, mask: u32) let distance = ((x-ix).powi(2) + (y-iy).powi(2)).sqrt(); if mask & flags > 0 && distance < r { log::debug!( - "Item: {}, type: {:x}, position: {:?}, distance: {}, {:x?}, {:#x?}", + "Item: {}, type: {:x}, position: {:?}, distance: {}, {:x?}", item.unique_id(), item._type().search_flags, item.position_self(), distance, - item.ptr(), - item._type() + item.ptr() ); found.push((item.unique_id(), distance)); }