Users browsing this thread: 1 Guest(s)
Changing physical damage calculations?

#1
Posts: 32
Threads: 4
Thanks Received: 0
Thanks Given: 0
Joined: Mar 2012
Reputation: 0
Status
None
Hello,

I have been working on a Final Fantasy VI hack for quite some time, and have in the past six months began working with hex coding, changing certain ways the game works and various texts that can not be editted using FF6usME. I've used Cygnus and the C2 bank dis-assembly. One thing I am interested in doing is changing the way physical attack damage is dealt. However, I get the feeling that this is no simple matter, the way it was to increase the damage dealt by GP Rain, or to change the sprite that the Moogle Suit changes you to! There are two aspects of the game's coding I want to focus on. Firstly, I want the effectiveness of battle power (both abilities and regular attacks) to be amplified...allowing for a greater range of damage from smaller attack power. Also, I want to increase the role that player Stamina plays in the defense against physical attacks.

Any help, even if it is ultimately discouraging, is appreciated.
  Find
Quote  

#2
Posts: 3,966
Threads: 279
Thanks Received: 234
Thanks Given: 56
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
(04-10-2012, 07:14 PM)Marketa Lazarova Wrote: One thing I am interested in doing is changing the way physical attack damage is dealt. However, I get the feeling that this is no simple matter, the way it was to increase the damage dealt by GP Rain, or to change the sprite that the Moogle Suit changes you to! There are two aspects of the game's coding I want to focus on. Firstly, I want the effectiveness of battle power (both abilities and regular attacks) to be amplified...allowing for a greater range of damage from smaller attack power. Also, I want to increase the role that player Stamina plays in the defense against physical attacks.

First of all, Bank C2 is where everything you want to change should be. With a quick search for "damage" I found the Damage modification routine. There are other special routines concerning damage like for relics such as Atlas armlet. C2 is well commented thanks to some devoted people. As for GP rain and the role that stamina plays, the routines should be in C2 as well. Maybe try with a search with those words...

I can't tell you which bytes exactly to change and where because it's not an area that I focused on so far. It also depends of what you want exactly but all this require some ASM knowledge. I could have a closer look to all this tonight, but maybe you could try first to understand the routines with the comments, the code and a instruction list.

Code:
Damage modification (Randomness, Row, Self Damage, and more)

C2/0C9E: 08           PHP
C2/0C9F: C2 20        REP #$20
C2/0CA1: AD B0 11     LDA $11B0   (Maximum Damage)
C2/0CA4: 85 F0        STA $F0
C2/0CA6: E2 20        SEP #$20    (Set 8-bit Accumulator)
C2/0CA8: AD 14 34     LDA $3414
C2/0CAB: D0 03        BNE $0CB0
C2/0CAD: 4C 3B 0D     JMP $0D3B   (Exit if $3414 = 0)
C2/0CB0: 20 5A 4B     JSR $4B5A   (Random number 0 to 255)
C2/0CB3: 09 E0        ORA #$E0    (Set bits 7,6,5; bits 0,1,2,3,4 are random)
C2/0CB5: 85 E8        STA $E8     (Random number [224..255])
C2/0CB7: 20 3D 0D     JSR $0D3D   (Damage randomness)
C2/0CBA: 18           CLC
C2/0CBB: AD A3 11     LDA $11A3
C2/0CBE: 30 04        BMI $0CC4   (Branch if Concern MP)
C2/0CC0: AD A2 11     LDA $11A2
C2/0CC3: 4A           LSR
C2/0CC4: AD A2 11     LDA $11A2
C2/0CC7: 89 20        BIT #$20
C2/0CC9: D0 57        BNE $0D22   (Branch if ignores defense)
C2/0CCB: 08           PHP
C2/0CCC: B9 B9 3B     LDA $3BB9,Y (Magic Defense)
C2/0CCF: 90 03        BCC $0CD4   (Branch if concern MP or Magical damage)
C2/0CD1: B9 B8 3B     LDA $3BB8,Y (Defense)
C2/0CD4: 1A           INC
C2/0CD5: F0 10        BEQ $0CE7   (If = 255)
C2/0CD7: EB           XBA
C2/0CD8: AD 82 3A     LDA $3A82
C2/0CDB: 2D 83 3A     AND $3A83
C2/0CDE: 30 03        BMI $0CE3   (If Blocked by Golem or Dog, defense = 192)
C2/0CE0: A9 C1        LDA #$C1
C2/0CE2: EB           XBA
C2/0CE3: EB           XBA
C2/0CE4: 3A           DEC
C2/0CE5: 49 FF        EOR #$FF
C2/0CE7: 85 E8        STA $E8     (= 255 - Defense)
C2/0CE9: 20 3D 0D     JSR $0D3D   (Multiply damage by (255 - Defense) / 256 ,
                                   then add 1)
C2/0CEC: A3 01        LDA $01,S
C2/0CEE: 4A           LSR
C2/0CEF: B9 F8 3E     LDA $3EF8,Y (Status byte 3)
C2/0CF2: B0 01        BCS $0CF5   (Branch if physical attack)
C2/0CF4: 0A           ASL
C2/0CF5: 0A           ASL
C2/0CF6: 10 07        BPL $0CFF   (Branch if no safe / shell)
C2/0CF8: A9 AA        LDA #$AA
C2/0CFA: 85 E8        STA $E8
C2/0CFC: 20 3D 0D     JSR $0D3D   (Multiply damage by 170 / 256 , then add 1)
C2/0CFF: 28           PLP
C2/0D00: 90 15        BCC $0D17   (Skip row check if magical attack)
C2/0D02: B9 A1 3A     LDA $3AA1,Y
C2/0D05: 89 02        BIT #$02
C2/0D07: F0 04        BEQ $0D0D   (Branch if not defending)
C2/0D09: 46 F1        LSR $F1
C2/0D0B: 66 F0        ROR $F0     (Cut damage in half)
C2/0D0D: 89 20        BIT #$20    (Check row)
C2/0D0F: F0 11        BEQ $0D22   (Branch if target in front row)
C2/0D11: 46 F1        LSR $F1
C2/0D13: 66 F0        ROR $F0     (Cut damage in half)
C2/0D15: 80 0B        BRA $0D22   (Skip morph if physical attack)
C2/0D17: B9 F9 3E     LDA $3EF9,Y
C2/0D1A: 89 08        BIT #$08
C2/0D1C: F0 04        BEQ $0D22   (Branch if not morph)
C2/0D1E: 46 F1        LSR $F1
C2/0D20: 66 F0        ROR $F0     (Cut damage in half)
C2/0D22: C2 20        REP #$20    (Set 16-bit Accumulator)
C2/0D24: AD A4 11     LDA $11A4
C2/0D27: 4A           LSR
C2/0D28: B0 0A        BCS $0D34   (Branch if heal, heal skips self damage theory)
C2/0D2A: C0 08        CPY #$08
C2/0D2C: B0 06        BCS $0D34   (Branch if target is a monster)
C2/0D2E: E0 08        CPX #$08
C2/0D30: B0 02        BCS $0D34   (Branch if attacker is monster)
C2/0D32: 46 F0        LSR $F0     (Cut damage in half if party attacks party)
C2/0D34: A5 F0        LDA $F0    
C2/0D36: 20 0B 37     JSR $370B   (Increment damage using $BC)
C2/0D39: 85 F0        STA $F0
C2/0D3B: 28           PLP
C2/0D3C: 60           RTS

Edit: As for the moogle suit sprite, there is a thread about this with another thread linked in it about the same thing: https://www.ff6hacking.com/forums/showth...p?tid=1545
  Find
Quote  

#3
Posts: 127
Threads: 8
Thanks Received: 21
Thanks Given: 12
Joined: Jan 2012
Reputation: 13
Status
None
GP Rain

GP Rain has nicely commented routines in NovaliaSpirit's disassembly.

I believe this line is the multiplier for GP Rain:
Code:
C2/3FE9: A2 02        LDX #$02

02 could be changed to 03 or 04 for some big incremental steps of GP Rain.

The current formula is "gold to consume * x" where x is 2 as shown above.

Moogle Suit

The moogle suit is applied in "Initialize in-battle character properties from equipment properties." as the routine is described by Novalia Spirit.

Code:
C2/287E: A9 0A        LDA #$0A

This line will load the pointer index to what sprite to use for the Moogle Suit. So 0A is Mog, 00 would be Terra, 01 would be Locke and so forth in the character sprite pointer indexes.

Unfortunately I did not notice where the palette is set for the Moogle Suit.
  Find
Quote  

#4
Posts: 3,966
Threads: 279
Thanks Received: 234
Thanks Given: 56
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
Nice finding m06!

m06 Wrote:02 could be changed to 03 or 04 for some big incremental steps of GP Rain.

The current formula is "gold to consume * x" where x is 2 as shown above.

It could also be multiply by any other value but it would require extra code, with everything that comes with that (moving code...). If you want to keep this simple, what m06 said is the best solution.

m06 Wrote:Unfortunately I did not notice where the palette is set for the Moogle Suit.

If you change the value you posted, the good palette will be loaded. I don't know either where it's being done.
  Find
Quote  

#5
Posts: 32
Threads: 4
Thanks Received: 0
Thanks Given: 0
Joined: Mar 2012
Reputation: 0
Status
None
Hello,

I apologize for being aloof! I had already figured out the (relatively simple) way to manipulate the Moogle Suit and GP Rain to the desired effects, which is why I mentioned them as being easy to do.
  Find
Quote  

#6
Posts: 3,966
Threads: 279
Thanks Received: 234
Thanks Given: 56
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
(04-11-2012, 04:24 PM)Marketa Lazarova Wrote: I apologize for being aloof! I had already figured out the (relatively simple) way to manipulate the Moogle Suit and GP Rain to the desired effects, which is why I mentioned them as being easy to do.

Sorry I think I don't know how to read...

Well from what I see there is multiples ways to modify damages and here's an example. Here's how damage dealt by a character is calculated:

Code:
Step 1a. Vigor2 = Vigor * 2
         If Vigor >= 128 then Vigor2 = 255 instead

Step 1b. Attack = Battle Power + Vigor2
Step 1c. If equipped with Gauntlet, Attack = Attack + Battle Power * 3 / 4
Step 1d. Damage = Battle Power + ((Level * Level * Attack) / 256) * 3 / 2
Step 1e. If character is equipped with an Offering:
Damage = Damage / 2

Step 1f. If the attack is a standard fight attack and the character is
equipped with a Genji Glove, but only one or zero weapons:

Damage = ceil(Damage * 3 / 4)

Now I found this portion of code here, which I think concern the * 3/2 in step 1d:

Code:
C2/2BE9: 8D B0 11     STA $11B0   (Maximum Damage)
C2/2BEC: E0 08        CPX #$08    (If Player then multiply $11B0 by 3/2)
C2/2BEE: B0 2F        BCS $2C1F   (And add Battle Power)
C2/2BF0: AD A6 11     LDA $11A6   (Battle Power)
C2/2BF3: 29 FF 00     AND #$00FF
C2/2BF5: 0A           ASL
C2/2BF7: 6D B0 11     ADC $11B0   (Maximum Damage)
C2/2BFA: 4A           LSR
C2/2BFB: 18           CLC
C2/2BFC: 6D B0 11     ADC $11B0   (Maximum Damage)
C2/2BFF: 8D B0 11     STA $11B0   (Maximum Damage)

If you remove the LSR here at C2/2BFA and change it with a NOP (instruction EA), you remove a division by 2. You would end up with * 4/2 instead of * 3/2. You could also swtich it to a ASL, which would multiply by 2 instead of dividing. I dunno what the final output would be as for game balance, but I'm discovering the damages algorithms as I'm answering this thread. As I said , there is a lot of possibilities and it all depends of your level of ASM understanding.
  Find
Quote  

#7
Posts: 32
Threads: 4
Thanks Received: 0
Thanks Given: 0
Joined: Mar 2012
Reputation: 0
Status
None
Wow, thank you, Madsuir. I believe this may be exactly what I'm looking for. I'm going to give this a shot soon enough, and try to see what works best.

On an unrelated note, I've also been considering replacing the Soul Sabre effect with an effect similar to that of the Tempest's effect, only using a different spell in Tempest's place. The idea is to have another weapon randomly cast Magnitude8, while keeping the Tempest and its ability to cast Wind Slash. The Soul Sabre effect, as per the disassembly, has 16 bytes of data, while the Tempest ability has 14 bytes, and I am wondering if this is possible without doing a whole lot of rearranging.

Code:
Special Effect 6 - Soul Sabre

C2/3F6E: A9 80        LDA #$80    
C2/3F70: 0C A3 11     TSB $11A3   (Sets attack to Concern MP)
C2/3F73: A9 08        LDA #$08    (Special Effect 5 - Drainer jumps here)
C2/3F75: 0C A2 11     TSB $11A2   (Sets attack to heal undead)
C2/3F78: A9 02        LDA #$02
C2/3F7A: 0C A4 11     TSB $11A4   (Sets attack to redirection)
C2/3F7D: 60           RTS

Code:
(Wind Slash - Tempest)

C2/3F9F: 20 5A 4B     JSR $4B5A   (Random Number Function: 0 to 255)
C2/3FA2: C9 80        CMP #$80
C2/3FA4: B0 10        BCS $3FB6   (50% chance exit function)
C2/3FA6: 9C A6 11     STZ $11A6   (Clear Battle Power)
C2/3FA9: A9 65        LDA #$65    (Wind Slash spell number)
C2/3FAB: 80 03        BRA $3FB0
  Find
Quote  

#8
Posts: 3,966
Threads: 279
Thanks Received: 234
Thanks Given: 56
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
(04-17-2012, 08:08 AM)Marketa Lazarova Wrote: On an unrelated note, I've also been considering replacing the Soul Sabre effect with an effect similar to that of the Tempest's effect, only using a different spell in Tempest's place. The idea is to have another weapon randomly cast Magnitude8, while keeping the Tempest and its ability to cast Wind Slash. The Soul Sabre effect, as per the disassembly, has 16 bytes of data, while the Tempest ability has 14 bytes, and I am wondering if this is possible without doing a whole lot of rearranging.

I wasn't able to fit it in the Soul saber code. You need 0x18 bytes for this code. Maybe there is a way to optimize it but this is what I came up with with my level of ASM programming. This could would give the soul saber the same properties as the tempest except it could cast Magnitude8 25% (12.5% total) of the times and Wind Slash 75% (37.5% total) of the time. You still have 50% chances to cast a spell, if not it's a regular hit:

Code:
C2/0000: 20 5A 4B     JSR $4B5A   (Random Number Function: 0 to 255)  
C2/0003: C9 80        CMP #$80    (compare to 128)
C2/0005: B0 ??        BCS $3FB6   (50% chance exit function)
C2/0007: 20 5A 4B     JSR $4B5A   (Random Number Function: 0 to 255)  
C2/000A: C9 80        CMP #$40    (compare to 64)
C2/000C: B0 04        BCS $0012   (25% chance branch)
C2/000E: A9 65        LDA #$65    (Wind Slash spell number 75% chances)
C2/0010: 80 02        BRA $0014   (branch to clear battle power)
C2/0012: A9 BC        LDA #$BC    (Magnitude8 spell number 25% chances)
C2/0014: 9C A6 11     STZ $11A6   (clear battle power)
C2/0017: 80 ??        BRA $3FB0   (branch to store the spell number)

You could maybe put some of this code where there is empty space in C2. In this case, the last BRA might need to be replaced by a JMP, depending where the code is.
  Find
Quote  

#9
Posts: 32
Threads: 4
Thanks Received: 0
Thanks Given: 0
Joined: Mar 2012
Reputation: 0
Status
None
The idea is grand: I custom-made a new earth-elemental spell, called Megathrust. I could have the weapon in question cast Magnitude8 75% of the time the effect is activated, and 25% of the time, the stronger Megathrust. All I would have to do is replace the spells in the code?

There is a large block of unused space starting at 6469 (6669 for me, since I'm using a headered ROM), and I believe its the only amount of space in C2 bank that would be sufficient for the above code. I believe I've figured out how to re-adjust pointers (if I started the new code at C2:6669, then the Soul Sabre effect's new pointer should be 69 64, replacing 6E 3F, correct?). I think I'm a lot greener at this than I thought, so I guess the big question I have must seem ridiculously basic: what should the two "??" bytes you listed be?
  Find
Quote  

#10
Posts: 290
Threads: 3
Thanks Received: 40
Thanks Given: 1
Joined: Apr 2012
Reputation: 9
Status
None
Quote:The idea is grand: I custom-made a new earth-elemental spell, called Megathrust. I could have the weapon in question cast Magnitude8 75% of the time the effect is activated, and 25% of the time, the stronger Megathrust. All I would have to do is replace the spells in the code?

That's right, just replace the spell IDs as desired.

Quote:There is a large block of unused space starting at 6469 (6669 for me, since I'm using a headered ROM), and I believe its the only amount of space in C2 bank that would be sufficient for the above code.

There are three blocks of free space in C2, any of which would be sufficient for this sort of thing. C2/6469 is the earliest; the other two are at C2/A65A and C2/FAA4.

Those addresses are for unheadered ROMs, so adjust as necessary.

Quote:I believe I've figured out how to re-adjust pointers (if I started the new code at C2:6669, then the Soul Sabre effect's new pointer should be 69 64, replacing 6E 3F, correct?).

That's right.

There are two things you could do here. You can adjust the pointer directly, or leave it as it is and overwrite the existing Soul Sabre code, jumping to C2/6469 when you run out of space. One method isn't any more efficient than the other, but you do save roughly 13 bytes of free space. Not a big deal in the long run.

Quote:I think I'm a lot greener at this than I thought, so I guess the big question I have must seem ridiculously basic: what should the two "??" bytes you listed be?

The operands for the various branch instructions are relative to the current location rather than absolute (like JMP/JSR/JSL). Branching will pass over a certain number of bytes instead of going directly to an address; those bytes being bypassed are what the ?? above represent. The assembler should fill in those values itself.

These single-byte operands are also why you can only branch 127 bytes forward or 128 bytes backward.


GET A SILK BAG FROM THE GRAVEYARD DUCK TO LIVE LONGER.

Brave New World
  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite