• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
March 29, 2024, 06:17:09 am

News:

Don't be hasty to start your own mod; all our FFT modding projects are greatly understaffed! Find out how you can help in the Recruitment section or our Discord!


Help me figure out why this formula isn't working.

Started by Emmy, April 17, 2016, 03:30:14 pm

Emmy

So, I'm trying to write a formula that deals caster's MP in damage to the target, and effective MP cost = damage dealt; accepting status effect (19%) and element.  Can't figure out why this doesn't work. :(



As you can see, the damage is displaying properly.



But it's not dealing the MP damage to self. :(

FFTOrgasm version (writing over formula 0E):


  <Patch name="Formula 0E = Mana Bomb">
    <Description>TEST</Description>
    <Location file="BATTLE_BIN" offset="121f90">
1980043C
982D848C
1980033C
942D638C
E8FFBD27
19008310
1000BFAF
2C006294
1980043C
902D848C
00000000
040082A4
80000234
250082A0
00000000
B41B060C
00000000
FE1B060C
00000000
1980023C
902D428C
00000000
00004290
00000000
06004010
C721060C
00000000
03004014
00000000
AD1F060C
00000000
2C006194
1980043C
8C2D848C
01000334
000083A0
040081A4
20000334
1980023C
8C2D428C
00000000
250043A0
1000BF8F
1800BD27
0800E003
00000000
    </Location>
  </Patch>


ASM of this:


[0x00000000] lui r4,0x8019
[0x00000004] lw r4,0x2d98(r4)
[0x00000008] lui r3,0x8019
[0x0000000c] lw r3,0x2d94(r3)
[0x00000010] addiu r29,r29,0xffe8
[0x00000014] beq r4,r3,0x0000007c
[0x00000018] sw r31,0x0010(r29)
[0x0000001c] lhu r2,0x002c(r3)
[0x00000020] lui r4,0x8019
[0x00000024] lw r4,0x2d90(r4)
[0x00000028] nop
[0x0000002c] sh r2,0x0004(r4)
[0x00000030] ori r2,r0,0x0080
[0x00000034] sb r2,0x0025(r4)
[0x00000038] nop
[0x0000003c] jal 0x00186ed0
[0x00000040] nop
[0x00000044] jal 0x00186ff8
[0x00000048] nop
[0x0000004c] lui r2,0x8019
[0x00000050] lw r2,0x2d90(r2)
[0x00000054] nop
[0x00000058] lbu r2,0x0000(r2)
[0x0000005c] nop
[0x00000060] beq r2,r0,0x0000007c
[0x00000064] jal 0x 0018871c
[0x00000068] nop
[0x0000006c] bne r2,r0,0x0000007c
[0x00000070] nop
[0x00000074] jal 0x 00187eb4
[0x00000078] nop
[0x0000007c] lhu r1,0x002c(r3)
[0x00000080] lui r4,0x8019
[0x00000084] lw r4,0x2d8c(r4)
[0x00000088] ori r3,r0,0x0001
[0x0000008c] sb r3,0x0000(r4)
[0x00000090] sh r1,0x0004(r4)
[0x00000094] ori r3,r0,0x0020
[0x00000098] lui r2,0x8019
[0x0000009c] lw r2,0x2d8c(r2)
[0x000000a0] nop
[0x000000a4] sb r3,0x0025(r2)
[0x000000a8] lw r31,0x0010(r29)
[0x000000ac] addiu r29,r29,0x 0018
[0x000000b0] jr r31
[0x000000b4] nop
  • Modding version: PSX

Glain

So, I happened to give this a look.  Aside from some redundancy (you don't need to re-load the return action 0x80192d8c twice at the end of the routine, for example), there are 2 issues that I see:

1. [0x7c] lhu r1, 0x2c(r3)

This line is loading an unpredictable value into r1 because we no longer know what's in r3, as there have been several subroutine calls between this line and where r3 was set above. You'll need to re-load the attacking unit's pointer into r3 before running this line.

2. [0x90] sh r1, 4(r4)

This is setting the [HP Damage] of the return action equal to the value of r1. You'll want to set the [MP Damage], which is offset 8, not 4, thus: sh r1, 8(r4).

Essentially, as it is now, you've told the game that the action's display type (0x25) is MP Damage but then told it to deal HP Damage instead. Typically that will cause the action to deal HP Damage without actually displaying it (though it will show the 0 MP Damage). I suspect if you fixed the first issue without fixing the second that the attacking unit would just keel over after using that ability as it would stealth deal 569 damage to itself.
  • Modding version: Other/Unknown

Emmy

Yay! I got something to work. :)  Thanks! :)

Only downside is it doesn't actually cap the MP damage done to self, but does cap the hp done to the target.  Mini screenshot series:



This dragon has 1019 MP. 



Formula works! (no more purple 0 taunting me)



This unit got killed by something else on the screen before i could screenshot it again, but it has 0 mp left instead of the expected 20 mp.

As for the redundancy, well, kinda don't know what I'm doing anyway so not surprised. :(

New working code:


  <Patch name="Formula 0E = Mana Bomb">
    <Description>TEST</Description>
    <Location file="BATTLE_BIN" offset="121f90">
1980043C
982D848C
1980033C
942D638C
E8FFBD27
1A008310
1000BFAF
2C006294
1980043C
902D848C
00000000
040082A4
80000234
250082A0
00000000
B41B060C
00000000
FE1B060C
00000000
1980023C
902D428C
00000000
00004290
00000000
07004010
00000000
C721060C
00000000
03004014
00000000
AD1F060C
00000000
1980033C
942D638C
00000000
2C006194
1980043C
8C2D848C
01000334
000083A0
080081A4
20000334
1980023C
8C2D428C
00000000
250043A0
1000BF8F
1800BD27
0800E003
00000000
    </Location>
  </Patch>
  • Modding version: PSX

Pride


1980043C
982D848C
1980033C
942D638C
E8FFBD27
1A008310
1000BFAF
2C006294
1980043C
902D848C
00000000
040082A4
80000234
250082A0
00000000
B41B060C
00000000
FE1B060C
00000000
1980023C
902D428C
00000000
00004290
00000000
07004010
00000000
C721060C
00000000
03004014
00000000
AD1F060C
00000000
1980033C
942D638C
01000234
2C006194
1980043C
8C2D848C
00000000
000082A0
E7030334
2B106100
02004010
00000000
21086000
080081A4
20000334
250083A0
1000BF8F
1800BD27
0800E003
00000000


Or it should work.
  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?

Emmy

Your version did not work. :(  It didn't spend any mp.
  • Modding version: PSX

Pride

Doesn't look wrong but slightly changed code. Attempt 2.
  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?