diff options
author | Remy Oukaour <remy.oukaour@gmail.com> | 2017-12-26 17:47:05 -0500 |
---|---|---|
committer | Remy Oukaour <remy.oukaour@gmail.com> | 2017-12-26 17:47:05 -0500 |
commit | b5417fafec7dd37cb4be391f3bd3d4541a2a381e (patch) | |
tree | a4e7d08afb2e862186a138e82c8ef4785d82786d /engine/battle/hidden_power.asm | |
parent | 2f98c2032fd47ada3484bfc37d590992f286d3d4 (diff) |
Split battle/ into data/ and engine/ components
Diffstat (limited to 'engine/battle/hidden_power.asm')
-rw-r--r-- | engine/battle/hidden_power.asm | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/engine/battle/hidden_power.asm b/engine/battle/hidden_power.asm new file mode 100644 index 000000000..c75a67ab3 --- /dev/null +++ b/engine/battle/hidden_power.asm @@ -0,0 +1,111 @@ +HiddenPowerDamage: ; fbced +; Override Hidden Power's type and power based on the user's DVs. + + ld hl, BattleMonDVs + ld a, [hBattleTurn] + and a + jr z, .got_dvs + ld hl, EnemyMonDVs +.got_dvs + + +; Power: + +; Take the top bit from each stat + + ; Attack + ld a, [hl] + swap a + and 8 + + ; Defense + ld b, a + ld a, [hli] + and 8 + srl a + or b + + ; Speed + ld b, a + ld a, [hl] + swap a + and 8 + srl a + srl a + or b + + ; Special + ld b, a + ld a, [hl] + and 8 + srl a + srl a + srl a + or b + +; Multiply by 5 + ld b, a + add a + add a + add b + +; Add Special & 3 + ld b, a + ld a, [hld] + and 3 + add b + +; Divide by 2 and add 30 + 1 + srl a + add 30 + inc a + + ld d, a + + +; Type: + + ; Def & 3 + ld a, [hl] + and 3 + ld b, a + + ; + (Atk & 3) << 2 + ld a, [hl] + and 3 << 4 + swap a + add a + add a + or b + +; Skip Normal + inc a + +; Skip Bird + cp BIRD + jr c, .done + inc a + +; Skip unused types + cp UNUSED_TYPES + jr c, .done + add SPECIAL - UNUSED_TYPES + +.done + +; Overwrite the current move type. + push af + ld a, BATTLE_VARS_MOVE_TYPE + call GetBattleVarAddr + pop af + ld [hl], a + +; Get the rest of the damage formula variables +; based on the new type, but keep base power. + ld a, d + push af + farcall BattleCommand_DamageStats ; damagestats + pop af + ld d, a + ret +; fbd54 |