Valentine Nemesis
An endearing rival is your best ally.

It's hacking time.

We now understand that PUSHes can be made before CALLing a function in order to tell the function what to do. We can change the PUSHes that come before a CALL in order to change how the function behaves.

Today we're also going to learn how to use OllyDbg's useful search feature.

If you look inside the Assembly Compendium, you'll find that the code for the Nemesis bullet begins at address 408230. Open up a copy of Cave Story with OllyDbg, and use Ctrl+G to get to address 408230.

Now that you're at address 408230, press Ctrl+F to search for assembly instructions. Type in CALL 46EFD0.

Search for CALL

You should be able to use the search feature to find 4 of these CALLs, one after another.

Found CALLs

Now, remember what CALL 46EFD0 is used for. It's the create NPC function. Right before each CALL, we see some PUSH 4 instructions. 4 is the identification number of the NPC, and the function located at 46EFD0 will create that NPC on the map.

NPC 4 is the smoke entity, which is why Nemesis bullets tend to make a lot of smoke. We can actually change which entity the Nemesis spawns by modifying the last PUSH right before the CALL 46EFD0 instructions.

Go ahead and change each of the four PUSH 4 instructions to PUSH 57. Don't forget to save your changes to the executable.

Valentine Hack

57 in hex = 87 in decimal. NPC 87 is a heart: the thing that heals you. So now, you can fire the Nemesis and it will actually produce hearts!
Here's the result:

Nemesis with Hearts

Changing Weapon Sounds
We can use a similar technique to the Nemesis heart hack in order to change the sound that a weapon makes when you fire it.

Go to address 41E7B0 using Ctrl+G. This address is the beginning of the weapon code for the Missile Launcher and the Super Missile Launcher.
The instruction CALL 420640 is used to play a sound effect. Go search for CALL 420640 starting at address 41E7B0.

Inside the Missile Launcher weapon code, you should be able to find 3 instances of CALL 420640. The third one is the one you want. At address 41EFB4, change that PUSH 20 to a PUSH 74. 20 (hex) = 32 (dec) and 74 (hex) = 116 (dec). Now, upon firing, the Missile Launcher (and Super Missile Launcher) will use sound effect 116 instead of sound effect 32.

Sound 116 is a fancy sound effect that I can't fully describe in words. Do the hack and fire the Missile Launcher to hear it.

Navigation
Previous Lesson: Calling Functions
Next Lesson: Structure of Functions
Table of Contents