• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
March 28, 2024, 03:55:30 pm

News:

Use of ePSXe before 2.0 is highly discouraged. Mednafen, RetroArch, and Duckstation are recommended for playing/testing, pSX is recommended for debugging.


ASM Request: Stat Down Skills Accept Element

Started by Eternal248, January 22, 2012, 06:10:32 pm

Eternal

  • Modding version: PSX & WotL
"You, no less human than we? Ha! Now there's a beastly thought. You've been less than we from the moment your baseborn father fell upon your mother in whatever gutter saw you sired! You've been chattel since you came into the world drenched in common blood!"
  • Discord username: eternal248#1817

Glain

So it turns out the patch was only giving the correct element to the action for the first target it hit. Then it was zeroing out the ability element (too early). I've got a new patch to correct that! I'm not sure this one overwrites everything the other one did, so best use on an ISO that doesn't have the old patch applied.


  <Patch name="All formulas apply elemental">
    <Description>All formulas apply elemental</Description>
    <Location file="BATTLE_BIN" offset="1249F0">
      FE1B0608
    </Location>
    <Location file="BATTLE_BIN" offset="11FFE0">
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="121794">
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="121E2C">
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="122D20">
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="12361C">
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="F5C78">
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="11DF1C">
      1980083C
      902D098D
      8C2D0A8D
      04002B95
      00000000
      43580B00
      04002BA5
      06004BA5
      00000000
      00000000
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="11DF64">
      1980083C
      902D098D
      8C2D0A8D
      10002395
      04002485
      00086334
      40200400
      100023A5
      040024A5
      060044A5
    </Location>
    <Location file="BATTLE_BIN" offset="120010">
      4C73050C
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="F5D30">
      1980083C
      F4380991
      F3380E91
      004A0900
      25482E01
      F7381091
      04390C91
      D6380D91
      04200A34
      24582A01
      05006A11
      00000000
      0300A011
      00000000
      5D730508
      00000000
      25800C02
      80730508
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="11DEB8">
      1980033C
      902D638C
      6873050C
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="F5DA0">
      1980083C
      902D0E8D
      8C2D098D
      40000F34
      80000A34
      0400CD95
      06002B95
      0400C0A5
      2500CFA1
      0600CDA5
      060020A5
      25002AA5
      0800E003
      04002BA5
    </Location>
    <Location file="BATTLE_BIN" offset="F5E00">
      1980083C
      942D0E8D
      902D098D
      7100CE91
      04002A95
      2470D001
      0700C011
      8C2D0C8D
      80680A00
      2168AA01
      0200AD21
      83680D00
      04002DA5
      06008DA5
      0800E003
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="12002C">
      1980033C
      902D638C
      00000000
      04006284
      00000000
      40100200
      040062A4
      22006290
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="120060">
      00000000
      25008890
      00000000
      08000835
      250088A0
    </Location>
    <Location file="BATTLE_BIN" offset="120124">
      501C0608
    </Location>
    <Location file="BATTLE_BIN" offset="11EFA4">
      0800E003
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="11EFFC">
      0800E003
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="CEE4">
      98730508
    </Location>
    <Location file="BATTLE_BIN" offset="F5E60">
      043900A1
      0800E003
      F73800A1
    </Location>
  </Patch>
  • Modding version: Other/Unknown

Austin

Alright, I'm back again from my most recent hiatus and trying this out again. It's still giving me the same problems as before, if you make the knight stat break skills elemental and hit something that cancels that element and has a reaction ability that targets itself it will always miss.

So I'm testing this by making squires cancel dark then hitting them with dark element break skills. The skill will miss like it's supposed to, but if the squire has any reaction ability like a/ma save, dragon spirit, etc. and it activates afterwards it'll always miss.

Also I tried using a dark element life drain on them and it had a wonky effect. If the attack succeeded (even though it always shows 0%) then the person that casted it got healed for the hp they would have gotten from the drain even though it would still miss on the squire. Basically it would work like normal except it didn't take any hp from the squire since it "missed".

Thanks again for trying to get this working, maybe it'll get there eventually.
  • Modding version: PSX

Glain

Good catch with the dark element life drain. Can't believe I didn't notice that earlier... (my test battle is Gate of Lionel... dark element life drain... now where have I seen that before? :<) I think I have a fix for that!

...As for nullified attacks having the reactions miss. I couldn't reproduce that, not exactly. The stat breaks are interesting though. I can't get MA Save to fire after a nullified stat break... ...even in vanilla. But in that case, it doesn't miss... it just doesn't fire at all whatsoever. I'm not really sure what's going on there, but I don't think this patch introduces that problem.

It's working for me with Sunken State though. I can't reproduce the problem. We're probably testing on two different platforms. Are you using an emulator? If so, do you have a savestate where it happens?

Anyway, here's the latest (should fix the drain problem)


  <Patch name="All formulas apply elemental">
    <Description>All formulas apply elemental</Description>
    <Location file="BATTLE_BIN" offset="1249F0">
      FE1B0608
    </Location>
    <Location file="BATTLE_BIN" offset="11FFE0">
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="121794">
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="121E2C">
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="122D20">
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="12361C">
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="F5C78">
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="11DF1C">
      1980083C
      902D098D
      8C2D0A8D
      04002B95
      00000000
      43580B00
      04002BA5
      06004BA5
      00000000
      00000000
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="11DF64">
      1980083C
      902D098D
      8C2D0A8D
      10002395
      04002485
      00086334
      40200400
      100023A5
      040024A5
      060044A5
    </Location>
    <Location file="BATTLE_BIN" offset="120010">
      4C73050C
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="F5D30">
      1980083C
      F4380991
      F3380E91
      004A0900
      25482E01
      F7381091
      04390C91
      D6380D91
      04200A34
      24582A01
      05006A11
      00000000
      0300A011
      00000000
      5D730508
      00000000
      25800C02
      80730508
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="11DEB8">
      1980033C
      902D638C
      6873050C
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="F5DA0">
      1980083C
      902D0E8D
      8C2D098D
      40000F34
      80000A34
      0400CD95
      06002B95
      0400C0A5
      2500CFA1
      0600CDA5
      060020A5
      25002AA5
      0800E003
      04002BA5
    </Location>
    <Location file="BATTLE_BIN" offset="F5E00">
      1980083C
      942D0E8D
      902D098D
      7100CE91
      04002A95
      2470D001
      0700C011
      8C2D0C8D
      80680A00
      2168AA01
      0200AD21
      83680D00
      04002DA5
      06008DA5
      0800E003
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="12002C">
      1980033C
      902D638C
      00000000
      04006284
      00000000
      40100200
      040062A4
      22006290
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="120060">
      00000000
      25008890
      00000000
      08000835
      250088A0
    </Location>
    <Location file="BATTLE_BIN" offset="120124">
      501C0608
    </Location>
    <Location file="BATTLE_BIN" offset="11EFA4">
      0800E003
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="11EFFC">
      0800E003
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="CEE4">
      98730508
    </Location>
    <Location file="BATTLE_BIN" offset="F5E60">
      1980083C
      043900A1
      0800E003
      F73800A1
    </Location>
    <Location file="BATTLE_BIN" offset="F65C0">
      F4FFBD27
      0400BFAF
      9013060C
      00000000
      1980083C
      902D098D
      8C2D0A8D
      0800A9AF
      902D0AAD
      9013060C
      00000000
      0800A98F
      1980083C
      902D09AD
      0400BF8F
      0C00BD27
      0800E003
      00000000
    </Location>
    <Location file="BATTLE_BIN" offset="1200C8">
      7075050C
    </Location>
    <Location file="BATTLE_BIN" offset="11DEF8">
      7075050C
    </Location>
  </Patch>
  • Modding version: Other/Unknown

Austin

Alright, I just tried this one out and for whatever reason it looks like everything's working right. After using this patch I could only get certain abilities to go off like you too, brave up, caution, and dragon spirit I think all activated and worked like they were supposed to. I couldn't get regenerator to go off though despite it being one of the ones that did when I tried it before.

Either way if it's working there's no point worrying about it lol, it may have been something on my end that was messing it up. I am playing on the psxfin emulator if you still wanted to know though. Thanks for the help dude.  :P
  • Modding version: PSX


FFMaster

Will probably break them.

Multiple formula rewrites are bad unless you know exactly what is happening.
  • Modding version: Other/Unknown
☢ CAUTION CAUTION ☢ CAUTION CAUTION ☢

Glain

Well, the majority of what this hack does is just call the elemental routine after the formula code has already been called. It doesn't actually edit the formulas themselves except to null out (nop) any other calls to the elemental routine (0x186ff8) and its inner routine (0x184e98).

If a formula hack calls those routines explicitly, it would be a problem because the element would be applied twice. If formulas have been rewritten so that those calls aren't in the same place that they normally would be, that would be bad.

I don't think I've seen another hack that edits the end of the formula calling routine in the same way this one does, so I don't imagine there would be code overlap issues anywhere else.

It depends on what the other hacks do, I suppose, to really know whether they'd work in tandem, but it's probably worth a shot...
  • Modding version: Other/Unknown

RavenOfRazgriz

So as long as those hacks don't edit the end of the formula calling routine and have their usually elemental callings nopped out, it should be fine?

I'm not really editing any existing formula, just adding new ones such as your MA*WP+Y and ride's White Wind and Damage=Y.  A couple are being actively edited but with that in mind I think things should be workable.

Thanks, Glain.

RavenOfRazgriz

Important question #2 regarding this hack: If I use this hack, then make a skill like Cure 2 Holy element, then have a character that Absorbs Holy, what will happen, Glain?  Will the healing be reversed into damage sortof like an Undead Reverse or will nothing happen?

Glain

July 23, 2012, 02:42:05 pm #70 Last Edit: July 24, 2012, 09:42:37 pm by Glain
It looks like the absorb code for this hack is basically:

Healing = Damage
Damage = 0

If draining HP, then additionally:

Returned damage = returned healing
Returned healing = 0

The problem is that for heals, damage = 0, so with absorb, healing = 0.

Eyeballing the address, I think that's in kanji space, and I usually leave a bit of space between routines, so I think I can expand it to skip setting the healing = damage if the damage is 0.  You can try overwriting the F5DA0 segment in the patch with this and give it a go:


      1980083C
      902D0E8D
      8C2D098D
      40000F34
      80000A34
      0400CD95
      06002B95
      2500CFA1
      0200A011
      0400C0A5
      0600CDA5
      060020A5
      25002AA5
      0800E003
      04002BA5


This modification was brought to you in accordance with Absolutely Zero Testing™.
  • Modding version: Other/Unknown

Glain

This version should work without having to remove (nop out) any other calls.  The idea was to place an immediate return statement at the start of the elemental and inner elemental routines, to make them do nothing, and shift the real routines one line down, making up the space somewhere in the process (removing a nop, reusing a register).


Since the routines were only moved one line down, an immediate return at the old function location still means that the first statement of the real function is executed, since it's in the branch delay slot of the return statement, but in both routines, that statement is harmless to a calling function (changes a temp register).


Patch and source are one and the same!  Formatting looks messed up here but should be right if you copy/paste into a file.


  <Patch name="All formulas apply elemental">
    <Description>All formulas apply elemental</Description>
    <Location file="BATTLE_BIN" offset="1249F0" mode="ASM">
      j       0x186ffc              # Call Apply Elemental routine (at new location) at the end of formula code
    </Location>
    <Location file="BATTLE_BIN" offset="11FFF8" mode="ASM">
      jr      ra                    # Return immediately from original routine
      lui     t0,0x8019             # Shift routine down one space
      lw      v0,0x2d98(t0)
      addiu   sp,sp,-0x18
      sw      ra,0x14(sp)
      sw      s0,0x10(sp)
      lbu     v0,0x5a(v0)
      lbu     s0,0x38f7(t0)         # Regain space through repeated use of t0 = 0x8019
    </Location>
    <Location file="BATTLE_BIN" offset="1200E0" mode="ASM">
      jal     0x184e9c              # Call inner elemental routine at new location
    </Location>
    <Location file="BATTLE_BIN" offset="11DE98" mode="ASM">
      jr      ra                    # Return immediately from original routine
      lui     t0,0x8019             # Shift routine down one space
      lw      v0,0x2d98(t0)
      addiu   sp,sp,-0x18
      sw      ra,0x10(sp)
      lbu     v0,0x6d(v0)
      move    a1,a0
      and     v0,v0,a1
      beq     v0,zero,0x184ed8
      lw      v1,0x2d90(t0)         # Regain space by eating a nop and reusing t0
      jal     0x15cda0              # Jump to new absorb section
      nop
    </Location>
    <Location file="BATTLE_BIN" offset="11DF1C" mode="ASM">
      lui     t0,0x8019             # Elemental Half section
      lw      t1,0x2d90(t0)
      lw      t2,0x2d8c(t0)
      lhu     t3,4(t1)
      nop
      sra     t3,t3,1               # Halve damage
      sh      t3,4(t1)              # Store as damage
      sh      t3,6(t2)              # Store as returned healing (drain)
      nop
      nop
      nop
    </Location>
    <Location file="BATTLE_BIN" offset="11DF64" mode="ASM">
      lui     t0,0x8019             # Elemental Weak section
      lw      t1,0x2d90(t0)
      lw      t2,0x2d8c(t0)
      lhu     v1,0x10(t1)
      lh      a0,0x04(t1)
      ori     v1,v1,0x0800
      sll     a0,a0,1               # Double damage
      sh      v1,0x10(t1)
      sh      a0,0x04(t1)           # Store as damage
      sh      a0,0x06(t2)           # Store as returned healing (drain)
    </Location>
    <Location file="BATTLE_BIN" offset="120010" mode="ASM">
      jal     0x15cd30              # Call new routine
      nop
    </Location>
    <Location file="BATTLE_BIN" offset="F5D30" mode="ASM">
      lui     t0,0x8019             # Element determination section
      lbu     t1,0x38f4(t0)
      lbu     t6,0x38f3(t0)
      sll     t1,t1,8
      or      t1,t1,t6
      lbu     s0,0x38f7(t0)
      lbu     t4,0x3904(t0)         # Weapon element
      lbu     t5,0x38d6(t0)         # Ability element
      ori     t2,zero,0x2004       
      and     t3,t1,t2              # Check if "Weapon Strike" and flag under "Hit Allies" checked
      beq     t3,t2,CMB             # If so, jump to combine element section
      nop
     
      beq     t5,zero,CMB           # If this ability is Attack (ID 0), then jump to combine element section
      nop
     
      j       PCB                   # Otherwise, jump past the combine section
      nop
     
CMB:  or      s0,s0,t4              # Combine section; combine the weapon and ability element

PCB:  j       0x15ce00              # Past combine section; go to next section
      nop
    </Location>
    <Location file="BATTLE_BIN" offset="F5DA0" mode="ASM">
      lui     t0,0x8019             # Elemental Absorb section
      lw      t6,0x2d90(t0)
      lw      t1,0x2d8c(t0)
      li      t7,0x40
      li      t2,0x80
      lhu     t5,0x04(t6)
      lhu     t3,0x06(t1)
      sb      t7,0x25(t6)           # Action type = HP Healing
      beq     t5,zero,PDO
      sh      zero,0x04(t6)         # HP Damage = 0
      sh      t5,0x06(t6)           # HP Healing = old HP Damage
PDO:  sh      zero,0x06(t1)         # Returned HP Healing = 0 (Reverse drain)
      sh      t2,0x25(t1)           # Returned action type = HP Damage (Reverse drain)
      jr      ra
      sh      t3,0x04(t1)           # Returned HP Damage = Old Returned HP Healing (Reverse drain)
    </Location>
    <Location file="BATTLE_BIN" offset="F5E00" mode="ASM">
      lui     t0,0x8019             # Elemental Strengthen section
      lw      t6,0x2d94(t0)
      lw      t1,0x2d90(t0)
      lbu     t6,0x0071(t6)
      lhu     t2,0x0004(t1)
      and     t6,t6,s0
      beq     t6,zero,END           # Skip if element not strengthened
      lw      t4,0x2d8c(t0)
     
      sll     t5,t2,2
      addu    t5,t5,t2
      addi    t5,t5,2
      sra     t5,t5,2               # Damage = Damage * 5 / 4 (Rounded)
      sh      t5,0x04(t1)           # Save as HP Damage
      sh      t5,0x06(t4)           # Save as returned HP Healing (Drain)
END:  jr      ra
      nop
    </Location>
    <Location file="BATTLE_BIN" offset="12002C" mode="ASM">
      lw      v1,0x80192d90         # Oil section (Target hit by fire attack)
      nop
      lhu     v0,0x04(v1)
      nop
      sll     v0,v0,1               # Double HP damage
      sh      v0,0x04(v1)           # Save as HP damage
      lbu     v0,0x22(v1)
      nop
    </Location>
    <Location file="BATTLE_BIN" offset="120060" mode="ASM">
      nop                           # Oil - don't overwrite action type
      lbu     t0,0x25(a0)           # Load Action type
      nop
      ori     t0,t0,0x08            # Add status change
      sb      t0,0x25(a0)           # Save as action type
    </Location>
    <Location file="BATTLE_BIN" offset="120124" mode="ASM">
      j       0x187140              # Jump over normal absorption block
    </Location>
    <Location file="BATTLE_BIN" offset="11EFA4" mode="ASM">
      jr      ra                    # Blank out routine (Weapon element strengthen)
      nop
    </Location>
    <Location file="BATTLE_BIN" offset="11EFFC" mode="ASM">
      jr      ra                    # Blank out routine (Ability element strengthen)
      nop
    </Location>
    <Location file="BATTLE_BIN" offset="CEE4" mode="ASM">
      j       0x15ce60              # Jump to new section
    </Location>
    <Location file="BATTLE_BIN" offset="F5E60" mode="ASM">
      lui     t0,0x8019
      sb      zero,0x3904(t0)       # Zero out weapon element
      jr      ra
      sb      zero,0x38f7(t0)       # Zero out ability element
    </Location>
    <Location file="BATTLE_BIN" offset="1200C8" mode="ASM">
      jal     0x15d5c0              # Call routine to null action and drain action
    </Location>
    <Location file="BATTLE_BIN" offset="11DEF8" mode="ASM">
      jal     0x15d5c0              # Call routine to null action and drain action
    </Location>
    <Location file="BATTLE_BIN" offset="F65C0" mode="ASM">
      addiu   sp,sp,-12
      sw      ra,4(sp)

      jal     0x184e40              # Nullify current action
      nop

      lui     t0,0x8019
      lw      t1,0x2d90(t0)
      lw      t2,0x2d8c(t0)
      sw      t1,8(sp)              # Save action to stack
      sw      t2,0x2d90(t0)         # Save drain action as current action

      jal     0x184e40              # Nullify current action (drain action)
      nop

      lw      t1,8(sp)              # Load action from stack
      lui     t0,0x8019
      sw      t1,0x2d90(t0)         # Save current action back

      lw      ra,4(sp)
      addiu   sp,sp,12
      jr      ra
      nop
    </Location>
  </Patch>
  • Modding version: Other/Unknown


Glain

Yeah, I put the modification described in the last post in there, so healing should be preserved regardless of absorb.

And yep, all the other things should be in there too.
  • Modding version: Other/Unknown

RavenOfRazgriz

Weeeee.  Sounds good.

Now do it again for the Status routine.  :U

But really, it's good to have a much more user-friendly version of this ASM.  How hard would customizing which elements are affected by Oil be?  I don't personally need it but I know it's a nice bit of customization a lot of people would appreciate.