diff options
author | libjet <libj3t@gmail.com> | 2020-06-06 02:28:53 +0100 |
---|---|---|
committer | libjet <libj3t@gmail.com> | 2020-06-06 02:28:53 +0100 |
commit | 864e9c068da895bcd547152a7fc04b8fdc9b2540 (patch) | |
tree | d9acedf55dfee9971721aa9cf2cd06523cdd02d8 | |
parent | 5ea5b0d9019b3de45129d347eaf2a1f565839a8d (diff) |
Add engine/battle/hidden_power.asm
-rwxr-xr-x | engine/battle/hidden_power.asm | 108 | ||||
-rw-r--r-- | main.asm | 4 |
2 files changed, 109 insertions, 3 deletions
diff --git a/engine/battle/hidden_power.asm b/engine/battle/hidden_power.asm new file mode 100755 index 00000000..f7abd71f --- /dev/null +++ b/engine/battle/hidden_power.asm @@ -0,0 +1,108 @@ +HiddenPowerDamage: +; Override Hidden Power's type and power based on the user's DVs. + + ld hl, wBattleMonDVs + ldh a, [hBattleTurn] + and a + jr z, .got_dvs + ld hl, wEnemyMonDVs +.got_dvs + +; Power: + +; Take the top bit from each stat + + ; Attack + ld a, [hl] + swap a + and %1000 + + ; Defense + ld b, a + ld a, [hli] + and %1000 + srl a + or b + + ; Speed + ld b, a + ld a, [hl] + swap a + and %1000 + srl a + srl a + or b + + ; Special + ld b, a + ld a, [hl] + and %1000 + 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 %0011 + 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 %0011 + ld b, a + + ; + (Atk & 3) << 2 + ld a, [hl] + and %0011 << 4 + swap a + sla a + sla 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 @@ -381,9 +381,7 @@ INCLUDE "engine/pokedex/new_pokedex_entry.asm" INCLUDE "engine/link/time_capsule_2.asm" INCLUDE "engine/pokedex/unown_dex.asm" INCLUDE "engine/events/magikarp.asm" - -HiddenPowerDamage:: - dr $fbdf1, $fbe5a +INCLUDE "engine/battle/hidden_power.asm" _DisappearUser:: dr $fbe5a, $fbe6f |