mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 15:13:16 +00:00
O_o make_ephemerial seems to work
This commit is contained in:
parent
62f32a4863
commit
067d02c0ad
2 changed files with 17 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
|
arch::asm,
|
||||||
cell::{LazyCell, RefCell},
|
cell::{LazyCell, RefCell},
|
||||||
ffi::{c_int, c_void},
|
ffi::{c_int, c_void},
|
||||||
mem,
|
mem,
|
||||||
|
@ -39,7 +40,7 @@ struct GrabbedGlobals {
|
||||||
// These 3 actually point to a pointer.
|
// These 3 actually point to a pointer.
|
||||||
game_global: *mut usize,
|
game_global: *mut usize,
|
||||||
world_state_entity: *mut usize,
|
world_state_entity: *mut usize,
|
||||||
entity_manager: *mut EntityManager,
|
entity_manager: *const *mut EntityManager,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GrabbedFns {
|
struct GrabbedFns {
|
||||||
|
@ -186,13 +187,22 @@ unsafe fn grab_addrs(lua: *mut lua_State) {
|
||||||
unsafe extern "C" fn make_ephemereal(lua: *mut lua_State) -> c_int {
|
unsafe extern "C" fn make_ephemereal(lua: *mut lua_State) -> c_int {
|
||||||
unsafe {
|
unsafe {
|
||||||
let entity_id = LUA.lua_tointeger(lua, 1) as u32;
|
let entity_id = LUA.lua_tointeger(lua, 1) as u32;
|
||||||
println!("Making {} ephemerial", entity_id);
|
|
||||||
STATE.with(|state| {
|
STATE.with(|state| {
|
||||||
let state = state.borrow();
|
let state = state.borrow();
|
||||||
let entity = dbg!((state.fns.as_ref().unwrap().get_entity)(
|
let entity_manager = state.globals.as_ref().unwrap().entity_manager.read();
|
||||||
state.globals.as_ref().unwrap().entity_manager,
|
let mut entity: *mut Entity;
|
||||||
entity_id,
|
asm!(
|
||||||
));
|
"mov ecx, {entity_manager}",
|
||||||
|
"push {entity_id:e}",
|
||||||
|
"call {get_entity}",
|
||||||
|
entity_manager = in(reg) entity_manager,
|
||||||
|
get_entity = in(reg) state.fns.as_ref().unwrap().get_entity,
|
||||||
|
entity_id = in(reg) entity_id,
|
||||||
|
clobber_abi("C"),
|
||||||
|
out("ecx") _,
|
||||||
|
out("eax") entity,
|
||||||
|
);
|
||||||
|
// let entity = (state.fns.as_ref().unwrap().get_entity)(entity_manager, entity_id);
|
||||||
entity.cast::<c_void>().offset(0x8).cast::<u32>().write(0);
|
entity.cast::<c_void>().offset(0x8).cast::<u32>().write(0);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
local ffi = require("ffi")
|
local ffi = require("ffi")
|
||||||
local world_ffi = require("noitapatcher.nsew.world_ffi")
|
local world_ffi = require("noitapatcher.nsew.world_ffi")
|
||||||
|
|
||||||
np.CrossCallAdd("make_ephemerial", ewext.make_ephemerial)
|
-- np.CrossCallAdd("make_ephemerial", ewext.make_ephemerial)
|
||||||
|
|
||||||
local initial_world_state_entity = nil
|
local initial_world_state_entity = nil
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue