recomment hidden power calculation

This commit is contained in:
yenatch 2014-01-05 07:49:35 -05:00
parent ea01721284
commit 4e9102f249
2 changed files with 30 additions and 26 deletions

View File

@ -10077,7 +10077,7 @@ BattleCommand6d: ; 37be8
ld a, [AttackMissed] ld a, [AttackMissed]
and a and a
ret nz ret nz
callba GetHiddenPower callba HiddenPowerDamage
ret ret
; 37bf4 ; 37bf4

View File

@ -1,64 +1,65 @@
GetHiddenPower: ; fbced HiddenPowerDamage: ; fbced
; Override Hidden Power's type and power based on the actor's DVs. ; Override Hidden Power's type and power based on the user's DVs.
ld hl, BattleMonDVs ld hl, BattleMonDVs
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .GotDVs jr z, .got_dvs
ld hl, EnemyMonDVs ld hl, EnemyMonDVs
.GotDVs .got_dvs
; Power: ; Power:
; Take the top bit from... ; Take the top bit from each stat
; Atk ; Attack
ld a, [hl] ld a, [hl]
swap a swap a
and 8 and 8
; Defense
ld b, a ld b, a
; Def
ld a, [hli] ld a, [hli]
and 8 and 8
srl a srl a
or b or b
; Speed
ld b, a ld b, a
; Spd
ld a, [hl] ld a, [hl]
swap a swap a
and 8 and 8
srl a srl a
srl a srl a
or b or b
; Special
ld b, a ld b, a
; Spc
ld a, [hl] ld a, [hl]
and 8 and 8
srl a srl a
srl a srl a
srl a srl a
or b or b
ld b, a
; * 5 ; Multiply by 5
ld b, a
add a add a
add a add a
add b add b
ld b, a
; + (Spc & 3) ; Add Special & 3
ld b, a
ld a, [hld] ld a, [hld]
and 3 and 3
add b add b
; / 2 ; Divide by 2 and add 30 + 1
srl a srl a
; + 30
add 30 add 30
; + 1
inc a inc a
ld d, a ld d, a
@ -80,27 +81,30 @@ GetHiddenPower: ; fbced
; Skip Normal ; Skip Normal
inc a inc a
; Skip type 6 (unused) ; Skip Bird
cp 6 cp BIRD
jr c, .GotType jr c, .done
inc a inc a
; Skip unused types between Steel and Fire ; Skip unused types between Steel and Fire
cp STEEL + 1 cp STEEL + 1
jr c, .GotType jr c, .done
add FIRE - (STEEL + 1) add FIRE - (STEEL + 1)
.done
.GotType ; Overwrite the current move type.
push af push af
ld a, BATTLE_VARS_MOVE_TYPE ld a, BATTLE_VARS_MOVE_TYPE
call _GetBattleVar call _GetBattleVar
pop af pop af
ld [hl], a ld [hl], a
; Get the rest of the damage formula variables
; based on the new type, but keep base power.
ld a, d ld a, d
push af push af
callba BattleCommand06 callba BattleCommand06 ; damagestats
pop af pop af
ld d, a ld d, a
ret ret