Mar 20, 2017 at 10:05 PM
Join Date: Nov 23, 2015
Location: Somewhere within a world far away from reality...
Posts: 381
Age: 24
Pronouns: he/him
Alright soHey, so Discord servers crashed right as I was about to ask my question so I guess I gotta retype here:
I don't really know what I'm doing because I'm not at all used to OllyDbg / ASM logic
Say I wanted to have a duplicate of an entity, so that I could point the graphics elsewhere and make a minor edit of it while still having the original.
I copied the binary/hex in its entirety from the entity I wanted duplicated, and pasted it over a boss entity with more room that I have no intention of using. I NOP'd the rest of the code even though from my logic the RTN should end that loop and never execute it. I didn't expect this to work but it mostly does.
After saving as a new executable, editing NPC.tbl to point to the original graphic sheet, and adding in the new entity to my test map, it seems to work for about 20 seconds after it spawned in.
Going through it in Olly shows that it crashes at 42B53E, which isn't even entity code I believe, with "Access violation when writing to 7E4D1DED".
For kicks I NOP'd this entire function and it started to work for an additional 30 seconds, acting completely like the original NPC, before crashing again elsewhere with a similar error (the address was different).
Something I missed when trying a technique like this for entity duplication? Do I need to be more specific with which entities I'm using?
Instead of copying the actual AI, if it's the graphics you want to change, go to an entity you're replacing and do this:
PUSH EBP
MOV EBP, ESP
MOV EDI, DWORD [EBP+8]
PUSH EDI
CALL (AI of the entity you want to copy)
#Then set your sprites. The pointer should hopefully (Unless you've modified the other entity as well) still be in EDI.
The reason your code crashed was because it didn't have the proper pointer, and crashed trying to access an invalid instruction. It could also have been a CALL going to an invalid address due to being binary copied. This could happen 20 ~ 30 seconds after it is initialised if the entity has a timer.
This technique also allows you to do nifty things like copying a boss AI into a much smaller space, as well as make entities move/attack twice as fast by CALLing their AI twice a frame.
Last edited: