2014-01-05 04:49:35 -08:00
|
|
|
HiddenPowerDamage: ; fbced
|
|
|
|
; Override Hidden Power's type and power based on the user's DVs.
|
2013-08-09 14:42:04 -07:00
|
|
|
|
|
|
|
ld hl, BattleMonDVs
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-01-05 04:49:35 -08:00
|
|
|
jr z, .got_dvs
|
2013-08-09 14:42:04 -07:00
|
|
|
ld hl, EnemyMonDVs
|
2014-01-05 04:49:35 -08:00
|
|
|
.got_dvs
|
2013-08-09 14:42:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
; Power:
|
|
|
|
|
2014-01-05 04:49:35 -08:00
|
|
|
; Take the top bit from each stat
|
2013-08-09 14:42:04 -07:00
|
|
|
|
2014-01-05 04:49:35 -08:00
|
|
|
; Attack
|
2013-08-09 14:42:04 -07:00
|
|
|
ld a, [hl]
|
|
|
|
swap a
|
|
|
|
and 8
|
2014-01-05 04:49:35 -08:00
|
|
|
|
|
|
|
; Defense
|
2013-08-09 14:42:04 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [hli]
|
|
|
|
and 8
|
|
|
|
srl a
|
|
|
|
or b
|
2014-01-05 04:49:35 -08:00
|
|
|
|
|
|
|
; Speed
|
2013-08-09 14:42:04 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
swap a
|
|
|
|
and 8
|
|
|
|
srl a
|
|
|
|
srl a
|
|
|
|
or b
|
2014-01-05 04:49:35 -08:00
|
|
|
|
|
|
|
; Special
|
2013-08-09 14:42:04 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
and 8
|
|
|
|
srl a
|
|
|
|
srl a
|
|
|
|
srl a
|
|
|
|
or b
|
|
|
|
|
2014-01-05 04:49:35 -08:00
|
|
|
; Multiply by 5
|
|
|
|
ld b, a
|
2013-08-09 14:42:04 -07:00
|
|
|
add a
|
|
|
|
add a
|
|
|
|
add b
|
|
|
|
|
2014-01-05 04:49:35 -08:00
|
|
|
; Add Special & 3
|
|
|
|
ld b, a
|
2013-08-09 14:42:04 -07:00
|
|
|
ld a, [hld]
|
|
|
|
and 3
|
|
|
|
add b
|
|
|
|
|
2014-01-05 04:49:35 -08:00
|
|
|
; Divide by 2 and add 30 + 1
|
2013-08-09 14:42:04 -07:00
|
|
|
srl a
|
|
|
|
add 30
|
|
|
|
inc a
|
2014-01-05 04:49:35 -08:00
|
|
|
|
2013-08-09 14:42:04 -07:00
|
|
|
ld d, a
|
|
|
|
|
|
|
|
|
|
|
|
; Type:
|
|
|
|
|
2014-01-05 04:49:35 -08:00
|
|
|
; Def & 3
|
2013-08-09 14:42:04 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and 3
|
|
|
|
ld b, a
|
|
|
|
|
2014-01-05 04:49:35 -08:00
|
|
|
; + (Atk & 3) << 2
|
2013-08-09 14:42:04 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and 3 << 4
|
|
|
|
swap a
|
|
|
|
add a
|
|
|
|
add a
|
|
|
|
or b
|
|
|
|
|
|
|
|
; Skip Normal
|
|
|
|
inc a
|
|
|
|
|
2014-01-05 04:49:35 -08:00
|
|
|
; Skip Bird
|
|
|
|
cp BIRD
|
|
|
|
jr c, .done
|
2013-08-09 14:42:04 -07:00
|
|
|
inc a
|
|
|
|
|
2014-01-05 05:24:27 -08:00
|
|
|
; Skip unused types
|
|
|
|
cp UNUSED_TYPES
|
2014-01-05 04:49:35 -08:00
|
|
|
jr c, .done
|
2014-01-05 05:24:27 -08:00
|
|
|
add SPECIAL - UNUSED_TYPES
|
2013-08-09 14:42:04 -07:00
|
|
|
|
2014-01-05 04:49:35 -08:00
|
|
|
.done
|
2013-08-09 14:42:04 -07:00
|
|
|
|
2014-01-05 04:49:35 -08:00
|
|
|
; Overwrite the current move type.
|
2013-08-09 14:42:04 -07:00
|
|
|
push af
|
|
|
|
ld a, BATTLE_VARS_MOVE_TYPE
|
2013-10-11 00:04:21 -07:00
|
|
|
call _GetBattleVar
|
2013-08-09 14:42:04 -07:00
|
|
|
pop af
|
|
|
|
ld [hl], a
|
|
|
|
|
2014-01-05 04:49:35 -08:00
|
|
|
; Get the rest of the damage formula variables
|
|
|
|
; based on the new type, but keep base power.
|
2013-08-09 14:42:04 -07:00
|
|
|
ld a, d
|
|
|
|
push af
|
2014-01-05 04:49:35 -08:00
|
|
|
callba BattleCommand06 ; damagestats
|
2013-08-09 14:42:04 -07:00
|
|
|
pop af
|
|
|
|
ld d, a
|
|
|
|
ret
|
|
|
|
; fbd54
|
|
|
|
|