Faith Calculation

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
No Parameters - Returns Nothing

Modify Target Curent Action HP damage : Damage * [Target Faith]/100 * [Attacker Faith]/100
- If A Unit has Faith, his faith value is forced to 100
- If A unit has Innocent, his faith value is forced to 0x00 (resulting in no damage)
-------------------------------------------------------------------------------------------------
00187150: 3c028019 lui r2,0x8019            |
00187154: 8c422d94 lw r2,0x2d94(r2)         |r2 = Attacker's Data pointer
00187158: 00000000 nop                      |
0018715c: 9042005c lbu r2,0x005c(r2)        |r2 = Attacker's 5th set of current Status
00187160: 00000000 nop                      |
00187164: 30420080 andi r2,r2,0x0080        |r2 = 0x80 if Attacker has faith
00187168: 10400003 beq r2,r0,0x00187178     #If Attacker has Faith
0018716c: 34020064 ori r2,r0,0x0064             |r2 = 0x64 (100)
00187170: 3c018019 lui r1,0x8019                |
00187174: a02238d3 sb r2,0x38d3(r1)             |Forces Current Ability Attacker Faith to 100      0x801938d3 / 801938d3
00187178: 3c028019 lui r2,0x8019            |
0018717c: 8c422d94 lw r2,0x2d94(r2)         |r2 =  Attacker's Data pointer
00187180: 00000000 nop                      |
00187184: 9042005c lbu r2,0x005c(r2)        |r2 = Attacker's 5th set of current Status
00187188: 00000000 nop                      |
0018718c: 30420040 andi r2,r2,0x0040        |r2 = 0x40 if Attacker has innocent
00187190: 10400003 beq r2,r0,0x001871a0     #If Attacker has innocent
00187194: 00000000 nop                          |
00187198: 3c018019 lui r1,0x8019                |
0018719c: a02038d3 sb r0,0x38d3(r1)             |Forces Current Ability Attacker Faith to 0x00      0x801938d3 / 801938d3
001871a0: 3c028019 lui r2,0x8019            |
001871a4: 8c422d98 lw r2,0x2d98(r2)         |r2 = Target data pointer
001871a8: 00000000 nop                      |
001871ac: 9042005c lbu r2,0x005c(r2)        |r2 = Target's 5th set of current status
001871b0: 00000000 nop                      |
001871b4: 30420080 andi r2,r2,0x0080        |r2 = 0x80 if Target has Faith
001871b8: 10400003 beq r2,r0,0x001871c8     #If Target has Faith
001871bc: 34020064 ori r2,r0,0x0064             |r2 = 0x64 (100)
001871c0: 3c018019 lui r1,0x8019                |
001871c4: a02238d2 sb r2,0x38d2(r1)             |Forces Current Ability Target Faith to 100      0x801938d2 / 801938d2
001871c8: 3c028019 lui r2,0x8019            |
001871cc: 8c422d98 lw r2,0x2d98(r2)         |r2 = Target data pointer
001871d0: 00000000 nop                      |
001871d4: 9042005c lbu r2,0x005c(r2)        |r2 = Target's 5th set of current status
001871d8: 00000000 nop                      |
001871dc: 30420040 andi r2,r2,0x0040        |r2 = 0x40 if Target has Innoncent
001871e0: 10400003 beq r2,r0,0x001871f0     #If Target has innocent
001871e4: 00000000 nop                          |
001871e8: 3c018019 lui r1,0x8019                |
001871ec: a02038d2 sb r0,0x38d2(r1)             |Forces Current Ability Target Faith to 0x00      0x801938d2 / 801938d2
001871f0: 3c048019 lui r4,0x8019            |
001871f4: 8c842d90 lw r4,0x2d90(r4)         |r4 = Target Current Action (TCA) data pointer
001871f8: 3c028019 lui r2,0x8019            |
001871fc: 904238d2 lbu r2,0x38d2(r2)        |r2 = Target Faith (Current ability data)      0x801938d2 / 801938d2
00187200: 84830004 lh r3,0x0004(r4)         |r3 = TCA HP damage amount
00187204: 00000000 nop                      |
00187208: 00620018 mult r3,r2               |HP Damage * Target's Faith
0018720c: 00001812 mflo r3                  |r3 = HP Damage * Target's Faith
00187210: 3c028019 lui r2,0x8019            |
00187214: 904238d3 lbu r2,0x38d3(r2)        |r2 = Attacker's Faith (Current ability data)
00187218: 00000000 nop                      |
0018721c: 00620018 mult r3,r2               |HP Damage * Target's Faith * Attacker's Faith
00187220: 00001812 mflo r3                  |r3 = HP Damage * Target's Faith * Attacker's Faith
00187224: 3c0268db lui r2,0x68db            |
00187228: 34428bad ori r2,r2,0x8bad         |r2 = 0x68db8bad ( 0,4096 * 2^32 )
0018722c: 00620018 mult r3,r2               |HP Damage * Target's Faith * Attacker's Faith * 0,4096 * 2^32
00187230: 00031fc3 sra r3,r3,0x1f           |r3 = highest bit of r3 (for rounding purpose : 0x00 or 0x01)
00187234: 00001010 mfhi r2                  |r2 = HP Damage * Target's Faith * Attacker's Faith * 4096 / 10000
00187238: 00021303 sra r2,r2,0x0c           |r2 = HP Damage * Target's Faith/100 * Attacker's Faith/100 (r2/4096)
0018723c: 00431023 subu r2,r2,r3            |Eventually rounding down the result
00187240: 03e00008 jr r31                   |
00187244: a4820004 sh r2,0x0004(r4)         |Store new TCA HP Damage

Returns locations

Battle.bin
00188828: MA + X
001889f4: Calculate_Accuracy_for_Magical_Spells
00188a54: Calculate_Accuracy_for_Magical
00188c84: Formula 04 : Magic Gun
00188dcc: Formula 08 : Dmg F(MA*Y)
00188f20: Formula 0c : Heal F(MA*Y)
00189030: Formula 0e : Dmg (Y)% Hit F(MA+X)% 100% Status Hide Status
001892ec: Formula 1a : Hit F(MA+Y)% // -PA/MA/SP (X)