Skip to content

Commit

Permalink
added some kind of entity deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Jan 8, 2021
1 parent 6b83986 commit 9a30776
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
23 changes: 21 additions & 2 deletions crates/injected/cxx/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ std::map<std::string, int> 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 },
};

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand Down
5 changes: 5 additions & 0 deletions crates/injected/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions crates/injected/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 9a30776

Please sign in to comment.