2018-06-24 07:09:41 -07:00
|
|
|
HiddenPowerDamage:
|
2014-01-05 04:49:35 -08:00
|
|
|
; Override Hidden Power's type and power based on the user's DVs.
|
2013-08-09 14:42:04 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonDVs
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-08-09 14:42:04 -07:00
|
|
|
and a
|
2014-01-05 04:49:35 -08:00
|
|
|
jr z, .got_dvs
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonDVs
|
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
|
2018-01-09 14:20:47 -08:00
|
|
|
and %1000
|
2014-01-05 04:49:35 -08:00
|
|
|
|
|
|
|
; Defense
|
2013-08-09 14:42:04 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [hli]
|
2018-01-09 14:20:47 -08:00
|
|
|
and %1000
|
2013-08-09 14:42:04 -07:00
|
|
|
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
|
2018-01-09 14:20:47 -08:00
|
|
|
and %1000
|
2013-08-09 14:42:04 -07:00
|
|
|
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]
|
2018-01-09 14:20:47 -08:00
|
|
|
and %1000
|
2013-08-09 14:42:04 -07:00
|
|
|
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
|
2016-05-04 08:46:23 -07:00
|
|
|
add a
|
2013-08-09 14:42:04 -07:00
|
|
|
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]
|
2018-01-09 14:20:47 -08:00
|
|
|
and %0011
|
2013-08-09 14:42:04 -07:00
|
|
|
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]
|
2018-01-09 14:20:47 -08:00
|
|
|
and %0011
|
2013-08-09 14:42:04 -07:00
|
|
|
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]
|
2018-01-09 14:20:47 -08:00
|
|
|
and %0011 << 4
|
2013-08-09 14:42:04 -07:00
|
|
|
swap a
|
|
|
|
add a
|
2016-05-04 08:46:23 -07:00
|
|
|
add a
|
2013-08-09 14:42:04 -07:00
|
|
|
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
|
2021-04-26 09:00:16 -07:00
|
|
|
add UNUSED_TYPES_END - 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
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
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
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall BattleCommand_DamageStats ; damagestats
|
2013-08-09 14:42:04 -07:00
|
|
|
pop af
|
|
|
|
ld d, a
|
|
|
|
ret
|