Users browsing this thread: 1 Guest(s)
Question: Changing a Battle Command to a single spell

#1
Posts: 7
Threads: 4
Thanks Received: 1
Thanks Given: 9
Joined: May 2019
Reputation: 0
Status
None
Hello everyone! 

   I'm still new to FF3 (SNES) romhacking, so I'm not sure if this is incredibly simple or incredibly complex. Really, I'm mostly trying to understand basic concepts. In an attempt to learn small bits of hacking, I've been diving into the Hex Code as much as I can. I've done some event hacking, and now I'm moving on to actual data. I'm trying to set small goals for myself for the time being so here is my current goal:

I'd like to change Sabin's Battle command list from Fight, Blitz, Magic, Item; to Fight, Blitz, Charm, Item.

My original idea was to set Sabin's third ability from Magic to Mimic (a command I don't intend to use) and change where the Mimic data points to result in a different effect. I figure I can do this by either pointing at the "Muddle" spell, or the enemy spell "Charm" (Entice) which is used by Chadarnook. Logically, if that's how pointers work in this instance, this would give me the option to use any spell there: Fight, Blitz, Fire2, Item. Etc. 

Is this how pointers work? Am I completely off-base? Is there a simpler way to do this? My thanks in advance for helping me understand this simple concept.
  Find
Quote  

#2
Posts: 33
Threads: 4
Thanks Received: 53
Thanks Given: 1
Joined: Apr 2018
Reputation: 2
Status
Shell
The easiest way is probably to sacrifice Banon's Health command (which just casts Cure 2) or Leo's Shock command (which just casts Mega Hit). Just give them a different spell index and you're done.

If you want to replace mimic, you basically need to copy the code for one of those commands, change the spell index, then make mimic call that (either by copying it over the mimic code or copying it into free space and changing a pointer)
  Find
Quote  
[-] The following 1 user says Thank You to Subtraction for this post:
  • Morendo (12-10-2019)

#3
Posts: 7
Threads: 4
Thanks Received: 1
Thanks Given: 9
Joined: May 2019
Reputation: 0
Status
None
(12-10-2019, 03:12 AM)Subtraction Wrote: The easiest way is probably to sacrifice Banon's Health command (which just casts Cure 2) or Leo's Shock command (which just casts Mega Hit). Just give them a different spell index and you're done.

If you want to replace mimic, you basically need to copy the code for one of those commands, change the spell index, then make mimic call that (either by copying it over the mimic code or copying it into free space and changing a pointer)

Wonderful advice! I've taken it, and now I'm attempting to sacrifice Banon's Health command. Here's what I'm looking at:

I used FFusME to change the name of Health to Charm as desired. OK
I used FFusME to change the attributes of the ability to only single target an enemy, etc as desire. OK
I dug into the C2 code and found this:
Code:
Health

C2/171E: A9 2E        LDA #$2E       (Cure 2)
C2/1720: 85 B6        STA $B6        (Set spell/animation)
C2/1722: A9 05        LDA #$05
C2/1724: 80 3F        BRA $1765
I changed C2/171F to CE so now instead of Cure 2, the ability performs the "Charm" spell index just like Chadarnook.
I ran the test and sure enough everything works perfectly, except it still has the Cure2/Health animation. It looks like I'm using Health, but the result is Charm.

Changing the animation has proven to be a toughie though. I could easily swap the Health animation for the Charm animation in FF3usME, but since Health is also Cure2 this will also affect how Cure2 is animated and I don't want that. I figure there's probably a pointer somewhere that I can change which would fix it. I just need to point the Health ability animation to the Charm animation instead. I even found where these animations are located in the battle animation scripts!
Code:
; [ Animation Script $0153: Cure 2, Dried Meat, Pearl Wind, Health (sprite) ]

D0/3F35: 00 20                    speed 1, align to center of character/monster
D0/3F37: D1 01                    invalidate character/monster sprite priority
D0/3F39: EB                       jump based on thread ($3F42, $3F49, $3F52, $3F5E)
D0/3F42: C9 00                    play default sound effect
D0/3F44: 83 6B                    move forward 12
D0/3F46: FA 58 3F                 jump to $3F58
D0/3F49: 89 03                    loop start (3 times)
D0/3F4B: 1F                       [---]
D0/3F4C: 8A                       loop end
D0/3F4D: 83 CB                    move up 12
D0/3F4F: FA 58 3F                 jump to $3F58
D0/3F52: 89 07                    loop start (7 times)
D0/3F54: 1F                       [---]
D0/3F55: 8A                       loop end
D0/3F56: 83 8B                    move back 12
D0/3F58: 84 03                    set animation speed to 4
D0/3F5A: 8B 0D                    animated loop start (13 times, increment frame offset each time)
D0/3F5C: 00                       [$00]
D0/3F5D: 8C                       animated loop end
D0/3F5E: FF                       end of script
Code:
; [ Animation Script $01E6: Charm (sprite) ]

D0/2692: 00 20                    speed 1, align to center of character/monster
D0/2694: D1 01                    invalidate character/monster sprite priority
D0/2696: 85                       move to attacker position
D0/2697: 95                       calculate vector from attacker to target
D0/2698: EB                       jump based on thread ($26A1, $26AC, $26B5, $26BE)
D0/26A1: C9 00                    play default sound effect
D0/26A3: 80 5D                    command $80/$5D
D0/26A5: 00                       [$00]
D0/26A6: 92 02 05                 move along vector at speed 2, branch to $26A3
D0/26A9: 80 5D                    command $80/$5D
D0/26AB: FF                       end of script

D0/26AC: 80 5D                    command $80/$5D
D0/26AE: 01                       [$01]
D0/26AF: 92 02 05                 move along vector at speed 2, branch to $26AC
D0/26B2: 80 5D                    command $80/$5D
D0/26B4: FF                       end of script

For the life of me, I can't find the pointer though! I think it might be buried somewhere in D1EAD8-D1EFFF perhaps? The ROM map labels them as "Pointers to Battle Animation Scripts (+$D00000)", which appears to be exactly what I need, but I can't find any kind of disassembly for that section of code. 

Am I on the right track? Am I looking in the wrong spot? Anyone who has insight on this would be my hero. I feel like I've made a lot of progress as a newbie, and I'm hoping I'm getting the hang of it.
  Find
Quote  

#4
Posts: 45
Threads: 0
Thanks Received: 14
Thanks Given: 227
Joined: Feb 2015
Reputation: 0
Status
None
I believe the answer to your question can be found in this thread here. https://www.ff6hacking.com/forums/thread-3474.html
  Find
Quote  

#5
Posts: 33
Threads: 4
Thanks Received: 53
Thanks Given: 1
Joined: Apr 2018
Reputation: 2
Status
Shell
(12-11-2019, 01:55 AM)Morendo Wrote: I changed C2/171F to CE so now instead of Cure 2, the ability performs the "Charm" spell index just like Chadarnook.
I ran the test and sure enough everything works perfectly, except it still has the Cure2/Health animation. It looks like I'm using Health, but the result is Charm.

Changing the animation has proven to be a toughie though. I could easily swap the Health animation for the Charm animation in FF3usME, but since Health is also Cure2 this will also affect how Cure2 is animated and I don't want that. I figure there's probably a pointer somewhere that I can change which would fix it. I just need to point the Health ability animation to the Charm animation instead.

Oh, yeah. I forgot about that.

You can change the animation in FF3usME without affecting Cure 2, though.
Health uses the animation in Bttl > Animations 1 > 46: Bannon's Health, which is the same as Cure 2 but with a different palette. (Notice that the value for "Idx 0" is the index of the animation script you found.)
Just copy the values for the Charm spell animation into that.
  Find
Quote  

#6
Posts: 7
Threads: 4
Thanks Received: 1
Thanks Given: 9
Joined: May 2019
Reputation: 0
Status
None
(12-10-2019, 03:12 AM)Subtraction Wrote: If you want to replace mimic, you basically need to copy the code for one of those commands, change the spell index, then make mimic call that (either by copying it over the mimic code or copying it into free space and changing a pointer)

A little update on this.

I successfully was able to complete the initial task by means of altering the "Health" command. 
As a point of continuing my learning in romhacking, I also attempted to follow this direction with a new ability using the other method listed (quoted here).

I thought I could try replacing another command (this time GP Rain) to a spell (this time Empowerer). I used FF3usME to change the battle commands (which worked well), but attempting to copy the code for Empowerer and paste it over the code for GP Rain did not change the command. It simply caused the character to enter their battle stance, but with no action. The ATB meter then reset as if an action had occurred. Am I missing something? 

Again I find myself curious if maybe it would be simpler to find the pointer that points TO the GP Rain command and change it to instead point at the Empowerer spell. I have no idea if that would help, but it seems a logical next step to try. Those Command pointers (if they even exist) are buried somewhere in the code in a place I can't seem to find though.

Does anyone have any suggestions? My ultimate goal is to create several Battle Commands that are just spells without needing to enter a Magic command window. One character might have "Fight, Blitz, Muddle, Item", while another might have "Fight, Lore, Cure2, Item", and another might have "Fight, Steal, Haste, Item", etc. Doing so would require more commands than simply altering "Health" and "Shock" would allow. Thank you in advance for any help given!
  Find
Quote  

#7
Posts: 108
Threads: 13
Thanks Received: 43
Thanks Given: 57
Joined: Dec 2018
Reputation: 4
Status
Moog
You're going to run into a hard limit with the commands you can add: the game treats commands after 'Possess' differently (well, technically you can replace Magitek but then you have to rework that rider status), and trying to get it to allow them from a battle menu call will be an uphill battle.

However... something could be coded to allow a single command to perform different spells based on the caster who uses it.  You would make this command (say, "SPECIAL") set the spell based on the actor ID of the character who calls it.  Granted, this would break the ability to mimic the command or set it on a Gogo-esque character, but from what you described as your goal that might not be a problem.


Health and Shock have hardcoded animations based on their command IDs (GP Rain does too).  To get around that, you can change the command ID to #02 (MAGIC) in your block of code (by storing it in $b5) before executing a hit.  However, this will make monsters that counter the magic command counter your special command as well.

Here's the locations of the command pointers, taken from Assassin's C2 Disassembly.
Code:
Code pointers for commands; special commands start at C2/1A03

C2/19C7: C8 15     (Fight)
C2/19C9: 97 18     (Item)
C2/19CB: 41 17     (Magic)
C2/19CD: 36 19     (Morph)
C2/19CF: 27 19     (Revert)
C2/19D1: 91 15     (Steal)   (05)
C2/19D3: 10 16     (Capture)
C2/19D5: 47 18     (Swdtech)
C2/19D7: 8D 18     (Throw)
C2/19D9: 85 18     (Tools)
C2/19DB: 9D 15     (Blitz)   (0A)
C2/19DD: 5B 19     (Runic)
C2/19DF: 5F 17     (Lore)
C2/19E1: 1F 15     (Sketch)
C2/19E3: 76 19     (Control)
C2/19E5: 26 17     (Slot)
C2/19E7: 60 15     (Rage)    (10)
C2/19E9: 9D 19     (Leap)
C2/19EB: 1E 15     (Mimic)
C2/19ED: 7D 17     (Dance)
C2/19EF: 4C 19     (Row)
C2/19F1: 6A 19     (Def.)    (15)
C2/19F3: F6 17     (Jump)
C2/19F5: 41 17     (X-Magic)
C2/19F7: 07 19     (GP Rain)
C2/19F9: 63 17     (Summon)
C2/19FB: 1E 17     (Health)  (1A)
C2/19FD: 1A 17     (Shock)
C2/19FF: E5 17     (Possess)
C2/1A01: 5F 17     (Magitek)
C2/1A03: B2 19     (1E) (Enemy Roulette)
C2/1A05: 1E 15     (1F) (Jumps to RTS)
C2/1A07: 72 50     (20) (#$F2 Command script)
C2/1A09: D1 50     (21) (#$F3 Command script)
C2/1A0B: 0B 50     (22) (Poison, Regen, and Seizure/Phantasm damage or healing)
C2/1A0D: 57 4F     (23) (#$F7 Command script)
C2/1A0F: 97 4F     (24) (#$F5 Command script)
C2/1A11: CD 50     (25)
C2/1A13: 5F 4F     (26) (Doom cast when Condemned countdown reaches 0; Safe, Shell, or
                        Reflect* cast when character enters Near Fatal (* no items
                        actually do this, but it's supported); or revival due to Life 3.)
C2/1A15: DD 50     (27) (Display Scan info)
C2/1A17: 1E 15     (28) (Jumps to RTS)
C2/1A19: 61 51     (29) (Remove Stop, Reflect, Freeze, or Sleep when time is up)
C2/1A1B: DE 20     (2A) (Run)
C2/1A1D: 2D 64     (2B) (#$FA Command script)
C2/1A1F: A8 51     (2C)
C2/1A21: B2 51     (2D) (Drain from being seized)
C2/1A23: FA 1D     (2E) (#$F8 Command script)
C2/1A25: 1A 1E     (2F) (#$F9 Command script)
C2/1A27: 5E 1E     (30) (#$FB Command script)
C2/1A29: 1E 15     (31) (Jumps to RTS)
C2/1A2B: 1E 15     (32) (Jumps to RTS)
C2/1A2D: 1E 15     (33) (Jumps to RTS)

As for making GP Rain into another 'cast spell' command like health, you're going to have to apply hex like the following with a hex editor like HxD.
Code:
Spell [Was GP Rain]
C2/1907: A9 59        LDA #$59       (Spell d89 [h59], Empowerer)
c2/1909: 85 B6        STA $B6        (Set spell/animation)
c2/190b: A9 02        LDA #$02
c2/190d: 85 B6        STA $B6        (Set command to Magic)
c2/190f: A9 05        LDA #$05
c2/1911: 4C 65 17     JMP $1765      (Go to the end of the Slot command)
c2/1914: EA EA        NOP
This changes the spell being called by the command, tells the game to treat the command like magic, and then executes one hit.  If you want the command to skip MP depletion, you can change the LDA #$02 to LDA #$0F, Slot.  If you want it to keep a custom animation (default, throwing coins), then change c2/190b and c2/190d to 80 02 EA EA.

NOTE: This will take its targeting from the command, not the spell you select. So, if you set the command to target all in FF3USME it will, even though Empowerer is single-target. Getting the command to target based on spell targeting is a little more complicated; it draws some design from actions like Rage. I've got notes on it, but not on hand at the moment... we can discuss it later if the need arises.
  Find
Quote  
[-] The following 1 user says Thank You to C-Dude for this post:
  • Morendo (12-21-2019)



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite