Users browsing this thread: 1 Guest(s)
Changing and Replacing Combat Functions via Special Effects

#4
Posts: 61
Threads: 18
Thanks Received: 1
Thanks Given: 47
Joined: May 2014
Status
None
Thanks I'll try and figure out how to use that.  This thread isn't just about debugging my formulas by the way---it's to find ways that actually work, so if anyone else has successfully changed things up in a similar way, please feel free to join in.

Alright that debug tool worked like a charm once I figured out how to use it.  You have to add a breakpoint then check the "Execute" and "read"function and type in your 6 digit hex address.  When the address is called or used then it stops and you have to push the "step into" button to go step-by-step through the code that is executing and compare what should happen.  Then you can use the same program to change the hex code of the ROM on the fly and reload.

What the debugging tool also means, is that you can track the entire combat function using the same technique.  There's probably some button that can just write the code to a file but that wasn't explained by the self-titled "l337" pre-pubescent boy who was explaining this to me on Youtube.

Also I've found a nice explanation of the special effects combat function when foolishly trying to remove a patch by Assassin, the capture weapon fix "Recapture the Glory":

Quote:Also, the game only has a few basic damage formulae: one used by physical spells (and by
weapons, as Battle is physical), another used by magical spells, one for spells/items that
affect a fraction of the target's HP or MP, and one for items that just do a constant amount
of healing/damage.

What if you want to do a unconventional type of damage, like based on how many steps your
party has taken?

What if you want to use special criteria for how often an attack hits, like with Ragnarok's
Metamorph or Relm's Control?

What if you want to change statuses at random rather than a spell always trying to
inflict/remove/toggle the same ones?

What if you want to do greater damage to human targets?

For Square, the answer to all those above questions was the same: you make a special effect.

There are dozens of unique behaviors Square felt like throwing into the game, so it would
hardly be economical to designate a "Yes / No" bit for each one as done with more common
properties like elementals.  Instead, they set aside a single "special effect" byte in the
spell data and the item data (the latter also includes weapons, equipment, relics, tools,
etc).  When you perform an attack, this ROM byte is copied into the RAM data for the current
attack.  The byte's value determines which special effect function(s) is/are called.

Up to two functions can be assigned to a given effect #: one routine is called just once per
strike (where a "strike" can have single or multiple targets); the other is called once for
each separate target.  The former type of routine doesn't care about target properties,
while the latter does.  Spells/items without a special effect just put zero in the byte,
which results in harmless empty functions being called.

.....

As mentioned in the last three paragraphs, there is just one special effect byte.  That's
plenty sufficient in all but one known case: using the Capture command in conjunction
with a weapon that has a special effect of its own (see Section 0 for the many examples).

First, the weapon's special effect byte is copied into the RAM attack data.  But before
its special effect function can be called, the Capture command overwrites that byte with
A4h.  Thus, you'll get the thievery aspect, but lose any snazzy properties the weapon may
have.  To handle this combination correctly, two bytes would have been needed.

____________________________________________________________________________________________

3. WHAT MY PATCH DOES
____________________________________________________________________________________________

As Kirstie Alley and Marv Albert will tell you, one byte isn't always enough.  This patch
introduces a second byte to allow for multiple special effects if -- and only if -- the
Capture command is involved.  Here's a very rough summary of the relevant happenings in a
given strike ("NC" means no change from original game):

- Zero the new special effect variable ($2F3D).

- The weapon data is loaded into the attack data, which includes copying the weapon special
  effect into the normal special effect variable ($11A9).  Weapons without a special effect
  just set the variable to zero.  NC

- If the command is Capture, A4h (Steal) is put into a new special effect byte ($2F3D.
  Previously, the game had put it into $11A9).

- [...]

- The once-per-strike special effect routine is called as normal (i.e. using $11A9's value.
  If it's zero, a harmless empty function is called).  NC

- For each target of a strike (there should only be one target with Fight and Capture, as
  multiple Offering or Genji Glove hits are considered separate strikes):

  - [...]

  - The once-per-target special effect routine is called as normal (i.e. using $11A9's
    value.  If it's zero, a harmless empty function is called).  NC

  - If Variable $11A9 =/= Variable $2F3D, call the once-per-target special effect function
    again, this time using $2F3D's value so as to attempt a steal.  (If $2F3D is zero, a
    harmless empty function is called.)

    We skip the call if $11A9 equals $2F3D, because that means either:

     - Both special effects are A4h (Steal).  We have the Capture command in conjunction
       with a capture attempted by Thief Knife; there's no reason to call the Steal function
       twice, and doing so would likely screw things up.

     OR

     - Both special effects are 0 (Nothing), in which case calling a second empty function
       is harmless, but a waste of CPU cycles.


As mentioned above, no modification was needed for the once-per-strike special effect call,
because Steal only has a once-per-target function defined.  Also note that the
once-per-target special effect call in the Super Ball/Launcher/Reflected spells routine
isn't changed, as there's no way to combine Capture with those without extensive hacking.

The problem with my formula was that my storage bytes were in the middle of the code and being interpreted as ASM instructions, derailing the train from there. Now the damage is off for a reason I haven't figured out yet. It should be doing around 4801 dmg with 2063 HP and 651 MP, but ends up around 1100.
  Find
Quote  



Messages In This Thread
RE: Changing and Replacing Combat Functions via Special Effects - by ReturnerScum - 02-27-2016, 02:53 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite