Apply Status and Check Undead

From Final Fantasy Hacktics Wiki
Revision as of 12:15, 16 April 2022 by Orkney (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#   ROUTINE: APPLY STATUS AND CHECK UNDEAD
#       Applies status to the current action.  Returns 1 if the status was applied, or if the target is undead.  
#       Otherwise, nullifies the action and returns 0.
#       Returns:
#           r2 =    1, if status successfully applied, or target is undead
#                   0, otherwise

8018acdc: 27bdffe8 addiu r29,r29,-0x0018
8018ace0: afbf0010 sw r31,0x0010(r29)
8018ace4: 0c061fad jal 0x80187eb4               #   Apply status (to action) - (Preserve hit status, evade type, hit %)
8018ace8: 00000000 nop
8018acec: 3c028019 lui r2,0x8019
8018acf0: 8c422d90 lw r2,0x2d90(r2)             #   Action
8018acf4: 00000000 nop
8018acf8: 90420025 lbu r2,0x0025(r2)            #   Action.DisplayType
8018acfc: 00000000 nop
8018ad00: 30420008 andi r2,r2,0x0008            
8018ad04: 14400010 bne r2,r0,0x8018ad48         #   if ((Action.DisplayType & TYPE_STATUS) != 0) return 1;      // If status was applied, return 1 (success)
8018ad08: 34020001 ori r2,r0,0x0001
8018ad0c: 3c028019 lui r2,0x8019
8018ad10: 8c422d98 lw r2,0x2d98(r2)             #   Target
8018ad14: 00000000 nop
8018ad18: 90420058 lbu r2,0x0058(r2)            #   Target.CurrentStatus1
8018ad1c: 00000000 nop
8018ad20: 30420010 andi r2,r2,0x0010            
8018ad24: 14400008 bne r2,r0,0x8018ad48         #   if (Target.CurrentStatus1 & STATUS_UNDEAD) return 1;        // If target is undead, return 1 (success)
8018ad28: 34020001 ori r2,r0,0x0001
8018ad2c: 0c061390 jal 0x80184e40               #   Nullify Action ();
8018ad30: 00000000 nop
8018ad34: 00001021 addu r2,r0,r0                
8018ad38: 3c048019 lui r4,0x8019
8018ad3c: 8c842d90 lw r4,0x2d90(r4)             #   Action
8018ad40: 34030007 ori r3,r0,0x0007
8018ad44: a0830002 sb r3,0x0002(r4)             #   Action.EvadeType = 7
8018ad48: 8fbf0010 lw r31,0x0010(r29)           #   return 0;
8018ad4c: 27bd0018 addiu r29,r29,0x0018
8018ad50: 03e00008 jr r31
8018ad54: 00000000 nop

Alternative notes

No Parameters 

Returns r2 = 0x00 if Attack is forced to miss
        r2 = 0x01 if Status infliction is OK or Target is undead

Nullify Target Current Action if Status is not inflicted and Target is not Undead
----------------------------------------------------------------------------------------------
8018acdc: 27bdffe8 addiu r29,r29,-0x0018    |
8018ace0: afbf0010 sw r31,0x0010(r29)       |
8018ace4: 0c061fad jal 0x80187eb4           |-->Apply status (to action) - (Preserve hit status, evade type, hit %) Update Target Current Action status infliction/Removal - Enables TCA Attack type 0x08 flag
8018ace8: 00000000 nop                      |
8018acec: 3c028019 lui r2,0x8019            |
8018acf0: 8c422d90 lw r2,0x2d90(r2)         |r2 = Target Current Action (TCA) data pointer
8018acf4: 00000000 nop                      |
8018acf8: 90420025 lbu r2,0x0025(r2)        |r2 = TCA Attack type
8018acfc: 00000000 nop                      |
8018ad00: 30420008 andi r2,r2,0x0008        |r2 = 0x08 if Attack type has [Status change] enabled
8018ad04: 14400010 bne r2,r0,0x8018ad48     #If Status infliction/removal has failed /If Status Infliction/Removal occurs, branch to END with r2 = 0x01
8018ad08: 34020001 ori r2,r0,0x0001         |r2 = 0x01
8018ad0c: 3c028019 lui r2,0x8019                |
8018ad10: 8c422d98 lw r2,0x2d98(r2)             |r2 = Target data pointer
8018ad14: 00000000 nop                          |
8018ad18: 90420058 lbu r2,0x0058(r2)            |r2 = Target Current Status (1st set)
8018ad1c: 00000000 nop                          |
8018ad20: 30420010 andi r2,r2,0x0010            |r2 = 0x10 if Target is undead
8018ad24: 14400008 bne r2,r0,0x8018ad48         #If Target is not undead /If Target is undead branch to END (r2 = 0x01)
8018ad28: 34020001 ori r2,r0,0x0001             |r2 = 0x01
8018ad2c: 0c061390 jal 0x80184e40                   |-->Nullify Action Clear TCA HP damage, Hit%, Special flags, Attack Type and Hit Flag / Clear Proc and knockback flags
8018ad30: 00000000 nop                              |
8018ad34: 00001021 addu r2,r0,r0                    |r2 = 0x00
8018ad38: 3c048019 lui r4,0x8019                    |
8018ad3c: 8c842d90 lw r4,0x2d90(r4)                 |r2 = TCA data pointer
8018ad40: 34030007 ori r3,r0,0x0007                 |r3 = 0x07
8018ad44: a0830002 sb r3,0x0002(r4)                 |Set TCA Evade type to 0x07 (Forced to miss)
8018ad48: 8fbf0010 lw r31,0x0010(r29)       END
8018ad4c: 27bd0018 addiu r29,r29,0x0018     
8018ad50: 03e00008 jr r31                   
8018ad54: 00000000 nop

Return locations

Battle.bin
00188f68: Formula 0d : Heal (Y)% Hit F(MA+X)%
0018905c: Formula 0e : Dmg (Y)% Hit F(MA+X)% 100% Status Hide Status
00189f5c: Formula 35 : Heal (Y)% Hit (PA+X)%
0018a2fc: Formula 4b : Heal (Rdm(1..9)) 100% Status