ref: 4e9102f2497041873debda18a5f3d055840ad7b9
parent: ea01721284572181dd34e09bc04f5a363e800b9c
author: yenatch <[email protected]>
date: Sun Jan 5 02:49:35 EST 2014
recomment hidden power calculation
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -10077,7 +10077,7 @@
ld a, [AttackMissed]
and a
ret nz
- callba GetHiddenPower
+ callba HiddenPowerDamage
ret
; 37bf4
--- a/battle/hidden_power.asm
+++ b/battle/hidden_power.asm
@@ -1,30 +1,32 @@
-GetHiddenPower: ; fbced
-; Override Hidden Power's type and power based on the actor's DVs.
+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, .GotDVs
+ jr z, .got_dvs
ld hl, EnemyMonDVs
-.GotDVs
+.got_dvs
; Power:
-; Take the top bit from...
+; Take the top bit from each stat
-; Atk
+ ; Attack
ld a, [hl]
swap a
and 8
+
+ ; Defense
ld b, a
-; Def
ld a, [hli]
and 8
srl a
or b
+
+ ; Speed
ld b, a
-; Spd
ld a, [hl]
swap a
and 8
@@ -31,8 +33,9 @@
srl a
srl a
or b
+
+ ; Special
ld b, a
-; Spc
ld a, [hl]
and 8
srl a
@@ -39,37 +42,35 @@
srl a
srl a
or b
- ld b, a
-; * 5
+; Multiply by 5
+ ld b, a
add a
add a
add b
- ld b, a
-; + (Spc & 3)
+; Add Special & 3
+ ld b, a
ld a, [hld]
and 3
add b
-; / 2
+; Divide by 2 and add 30 + 1
srl a
-
-; + 30
add 30
-; + 1
inc a
+
ld d, a
; Type:
-; Def & 3
+ ; Def & 3
ld a, [hl]
and 3
ld b, a
-; + (Atk & 3) << 2
+ ; + (Atk & 3) << 2
ld a, [hl]
and 3 << 4
swap a
@@ -80,18 +81,19 @@
; Skip Normal
inc a
-; Skip type 6 (unused)
- cp 6
- jr c, .GotType
+; Skip Bird
+ cp BIRD
+ jr c, .done
inc a
; Skip unused types between Steel and Fire
cp STEEL + 1
- jr c, .GotType
+ jr c, .done
add FIRE - (STEEL + 1)
+.done
-.GotType
+; Overwrite the current move type.
push af
ld a, BATTLE_VARS_MOVE_TYPE
call _GetBattleVar
@@ -98,9 +100,11 @@
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
- callba BattleCommand06
+ callba BattleCommand06 ; damagestats
pop af
ld d, a
ret