summaryrefslogtreecommitdiff
path: root/engine/battle/moveEffects
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle/moveEffects')
-rw-r--r--engine/battle/moveEffects/conversion_effect.asm17
-rw-r--r--engine/battle/moveEffects/drain_hp_effect.asm24
-rw-r--r--engine/battle/moveEffects/focus_energy_effect.asm16
-rw-r--r--engine/battle/moveEffects/haze_effect.asm43
-rw-r--r--engine/battle/moveEffects/heal_effect.asm58
-rw-r--r--engine/battle/moveEffects/leech_seed_effect.asm39
-rw-r--r--engine/battle/moveEffects/mist_effect.asm22
-rw-r--r--engine/battle/moveEffects/one_hit_ko_effect.asm20
-rw-r--r--engine/battle/moveEffects/paralyze_effect.asm22
-rw-r--r--engine/battle/moveEffects/pay_day_effect.asm14
-rw-r--r--engine/battle/moveEffects/recoil_effect.asm44
-rw-r--r--engine/battle/moveEffects/reflect_light_screen_effect.asm26
-rw-r--r--engine/battle/moveEffects/substitute_effect.asm64
-rw-r--r--engine/battle/moveEffects/transform_effect.asm86
14 files changed, 256 insertions, 239 deletions
diff --git a/engine/battle/moveEffects/conversion_effect.asm b/engine/battle/moveEffects/conversion_effect.asm
index 511df2fd..9c347876 100644
--- a/engine/battle/moveEffects/conversion_effect.asm
+++ b/engine/battle/moveEffects/conversion_effect.asm
@@ -1,18 +1,19 @@
-ConversionEffect_: ; 139a3 (4:79a3)
+ConversionEffect_:
ld hl, wEnemyMonType1
ld de, wBattleMonType1
ld a, [H_WHOSETURN]
and a
- ld a, [W_ENEMYBATTSTATUS1]
- jr z, .asm_139b8
+ ld a, [wEnemyBattleStatus1]
+ jr z, .conversionEffect
push hl
ld h, d
ld l, e
pop de
- ld a, [W_PLAYERBATTSTATUS1]
-.asm_139b8
+ ld a, [wPlayerBattleStatus1]
+.conversionEffect
bit Invulnerable, a ; is mon immune to typical attacks (dig/fly)
jr nz, PrintButItFailedText
+; copy target's types to user
ld a, [hli]
ld [de], a
inc de
@@ -23,12 +24,12 @@ ConversionEffect_: ; 139a3 (4:79a3)
ld hl, ConvertedTypeText
jp PrintText
-ConvertedTypeText: ; 139cd (4:79cd)
+ConvertedTypeText:
TX_FAR _ConvertedTypeText
db "@"
-PrintButItFailedText: ; 139d2 (4:79d2)
+PrintButItFailedText:
ld hl, PrintButItFailedText_
-CallBankF: ; 139d5 (4:79d5)
+CallBankF:
ld b, BANK(PrintButItFailedText_)
jp Bankswitch
diff --git a/engine/battle/moveEffects/drain_hp_effect.asm b/engine/battle/moveEffects/drain_hp_effect.asm
index 517d53d1..e5f4681a 100644
--- a/engine/battle/moveEffects/drain_hp_effect.asm
+++ b/engine/battle/moveEffects/drain_hp_effect.asm
@@ -1,5 +1,5 @@
-DrainHPEffect_: ; 783f (1:783f)
- ld hl, W_DAMAGE
+DrainHPEffect_:
+ ld hl, wDamage
ld a, [hl]
srl a ; divide damage by 2
ld [hli], a
@@ -17,8 +17,8 @@ DrainHPEffect_: ; 783f (1:783f)
ld a, [H_WHOSETURN]
and a
jp z, .addDamageToAttackerHP
- ld hl, wEnemyMonHP
- ld de, wEnemyMonMaxHP
+ ld hl, wEnemyMonHP
+ ld de, wEnemyMonMaxHP
.addDamageToAttackerHP
ld bc, wHPBarOldHP+1
; copy current HP to wHPBarOldHP
@@ -36,12 +36,12 @@ DrainHPEffect_: ; 783f (1:783f)
dec bc
ld [bc], a
; add damage to attacker's HP and copy new HP to wHPBarNewHP
- ld a, [W_DAMAGE + 1]
+ ld a, [wDamage + 1]
ld b, [hl]
add b
ld [hld], a
ld [wHPBarNewHP], a
- ld a, [W_DAMAGE]
+ ld a, [wDamage]
ld b, [hl]
adc b
ld [hli], a
@@ -71,10 +71,10 @@ DrainHPEffect_: ; 783f (1:783f)
.next
ld a, [H_WHOSETURN]
and a
- hlCoord 10, 9
+ coord hl, 10, 9
ld a, $1
jr z, .next2
- hlCoord 2, 2
+ coord hl, 2, 2
xor a
.next2
ld [wHPBarType], a
@@ -85,9 +85,9 @@ DrainHPEffect_: ; 783f (1:783f)
ld hl, SuckedHealthText
ld a, [H_WHOSETURN]
and a
- ld a, [W_PLAYERMOVEEFFECT]
+ ld a, [wPlayerMoveEffect]
jr z, .next3
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
.next3
cp DREAM_EATER_EFFECT
jr nz, .printText
@@ -95,10 +95,10 @@ DrainHPEffect_: ; 783f (1:783f)
.printText
jp PrintText
-SuckedHealthText: ; 78dc (1:78dc)
+SuckedHealthText:
TX_FAR _SuckedHealthText
db "@"
-DreamWasEatenText: ; 78e1 (1:78e1)
+DreamWasEatenText:
TX_FAR _DreamWasEatenText
db "@"
diff --git a/engine/battle/moveEffects/focus_energy_effect.asm b/engine/battle/moveEffects/focus_energy_effect.asm
index f01e61cc..69301d8e 100644
--- a/engine/battle/moveEffects/focus_energy_effect.asm
+++ b/engine/battle/moveEffects/focus_energy_effect.asm
@@ -1,9 +1,9 @@
-FocusEnergyEffect_: ; 27f86 (9:7f86)
- ld hl, W_PLAYERBATTSTATUS2
+FocusEnergyEffect_:
+ ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
and a
jr z, .notEnemy
- ld hl, W_ENEMYBATTSTATUS2
+ ld hl, wEnemyBattleStatus2
.notEnemy
bit GettingPumped, [hl] ; is mon already using focus energy?
jr nz, .alreadyUsing
@@ -12,13 +12,11 @@ FocusEnergyEffect_: ; 27f86 (9:7f86)
ld hl, GettingPumpedText
jp PrintText
.alreadyUsing
- ld c, $32
+ ld c, 50
call DelayFrames
- ld hl, PrintButItFailedText_
- ld b, BANK(PrintButItFailedText_)
- jp Bankswitch
+ jpab PrintButItFailedText_
-GettingPumpedText: ; 27fb3 (9:7fb3)
- db $0a
+GettingPumpedText:
+ TX_DELAY
TX_FAR _GettingPumpedText
db "@"
diff --git a/engine/battle/moveEffects/haze_effect.asm b/engine/battle/moveEffects/haze_effect.asm
index 2343e784..06907bcc 100644
--- a/engine/battle/moveEffects/haze_effect.asm
+++ b/engine/battle/moveEffects/haze_effect.asm
@@ -1,59 +1,64 @@
-HazeEffect_: ; 139da (4:79da)
+HazeEffect_:
ld a, $7
+; store 7 on every stat mod
ld hl, wPlayerMonAttackMod
call ResetStatMods
ld hl, wEnemyMonAttackMod
call ResetStatMods
+; copy unmodified stats to battle stats
ld hl, wPlayerMonUnmodifiedAttack
ld de, wBattleMonAttack
call ResetStats
ld hl, wEnemyMonUnmodifiedAttack
ld de, wEnemyMonAttack
call ResetStats
+; cure non-volatile status, but only for the target
ld hl, wEnemyMonStatus
ld de, wEnemySelectedMove
ld a, [H_WHOSETURN]
and a
- jr z, .asm_13a09
+ jr z, .cureStatuses
ld hl, wBattleMonStatus
- dec de
+ dec de ; wPlayerSelectedMove
-.asm_13a09
+.cureStatuses
ld a, [hl]
ld [hl], $0
- and $27
- jr z, .asm_13a13
+ and SLP | (1 << FRZ)
+ jr z, .cureVolatileStatuses
+; prevent the Pokemon from executing a move if it was asleep or frozen
ld a, $ff
ld [de], a
-.asm_13a13
+.cureVolatileStatuses
xor a
- ld [W_PLAYERDISABLEDMOVE], a
- ld [W_ENEMYDISABLEDMOVE], a
- ld hl, wccee
+ ld [wPlayerDisabledMove], a
+ ld [wEnemyDisabledMove], a
+ ld hl, wPlayerDisabledMoveNumber
ld [hli], a
ld [hl], a
- ld hl, W_PLAYERBATTSTATUS1
- call CureStatuses
- ld hl, W_ENEMYBATTSTATUS1
- call CureStatuses
+ ld hl, wPlayerBattleStatus1
+ call CureVolatileStatuses
+ ld hl, wEnemyBattleStatus1
+ call CureVolatileStatuses
ld hl, PlayCurrentMoveAnimation
call CallBankF
ld hl, StatusChangesEliminatedText
jp PrintText
-CureStatuses: ; 13a37 (4:7a37)
+CureVolatileStatuses:
res Confused, [hl]
inc hl ; BATTSTATUS2
ld a, [hl]
- and (1 << UsingRage) | (1 << NeedsToRecharge) | (1 << HasSubstituteUp) | (1 << 3) ; clear all but these from BATTSTATUS2
+ ; clear UsingXAccuracy, ProtectedByMist, GettingPumped, and Seeded statuses
+ and $ff ^((1 << UsingXAccuracy) | (1 << ProtectedByMist) | (1 << GettingPumped) | (1 << Seeded))
ld [hli], a ; BATTSTATUS3
ld a, [hl]
and %11110000 | (1 << Transformed) ; clear Bad Poison, Reflect and Light Screen statuses
ld [hl], a
ret
-ResetStatMods: ; 13a43 (4:7a43)
+ResetStatMods:
ld b, $8
.loop
ld [hli], a
@@ -61,7 +66,7 @@ ResetStatMods: ; 13a43 (4:7a43)
jr nz, .loop
ret
-ResetStats: ; 13a4a (4:7a4a)
+ResetStats:
ld b, $8
.loop
ld a, [hli]
@@ -71,6 +76,6 @@ ResetStats: ; 13a4a (4:7a4a)
jr nz, .loop
ret
-StatusChangesEliminatedText: ; 13a53 (4:7a53)
+StatusChangesEliminatedText:
TX_FAR _StatusChangesEliminatedText
db "@"
diff --git a/engine/battle/moveEffects/heal_effect.asm b/engine/battle/moveEffects/heal_effect.asm
index 22d482e7..b7d8283f 100644
--- a/engine/battle/moveEffects/heal_effect.asm
+++ b/engine/battle/moveEffects/heal_effect.asm
@@ -1,25 +1,26 @@
-HealEffect_: ; 3b9ec (e:79ec)
+HealEffect_:
ld a, [H_WHOSETURN]
and a
ld de, wBattleMonHP
ld hl, wBattleMonMaxHP
- ld a, [W_PLAYERMOVENUM]
- jr z, .asm_3ba03
+ ld a, [wPlayerMoveNum]
+ jr z, .healEffect
ld de, wEnemyMonHP
ld hl, wEnemyMonMaxHP
- ld a, [W_ENEMYMOVENUM]
-.asm_3ba03
+ ld a, [wEnemyMoveNum]
+.healEffect
ld b, a
ld a, [de]
- cp [hl]
+ cp [hl] ; most significant bytes comparison is ignored
+ ; causes the move to miss if max HP is 255 or 511 points higher than the current HP
inc de
inc hl
ld a, [de]
sbc [hl]
- jp z, .failed
+ jp z, .failed ; no effect if user's HP is already at its maximum
ld a, b
cp REST
- jr nz, .asm_3ba37
+ jr nz, .healHP
push hl
push de
push af
@@ -28,31 +29,33 @@ HealEffect_: ; 3b9ec (e:79ec)
ld hl, wBattleMonStatus
ld a, [H_WHOSETURN]
and a
- jr z, .asm_3ba25
+ jr z, .restEffect
ld hl, wEnemyMonStatus
-.asm_3ba25
+.restEffect
ld a, [hl]
and a
- ld [hl], 2 ; Number of turns from Rest
- ld hl, StartedSleepingEffect
- jr z, .asm_3ba31
- ld hl, FellAsleepBecameHealthyText
-.asm_3ba31
+ ld [hl], 2 ; clear status and set number of turns asleep to 2
+ ld hl, StartedSleepingEffect ; if mon didn't have an status
+ jr z, .printRestText
+ ld hl, FellAsleepBecameHealthyText ; if mon had an status
+.printRestText
call PrintText
pop af
pop de
pop hl
-.asm_3ba37
+.healHP
ld a, [hld]
ld [wHPBarMaxHP], a
ld c, a
ld a, [hl]
ld [wHPBarMaxHP+1], a
ld b, a
- jr z, .asm_3ba47
+ jr z, .gotHPAmountToHeal
+; Recover and Softboiled only heal for half the mon's max HP
srl b
rr c
-.asm_3ba47
+.gotHPAmountToHeal
+; update HP
ld a, [de]
ld [wHPBarOldHP], a
add c
@@ -72,7 +75,8 @@ HealEffect_: ; 3b9ec (e:79ec)
dec hl
ld a, [de]
sbc [hl]
- jr c, .asm_3ba6f
+ jr c, .playAnim
+; copy max HP to current HP if an overflow ocurred
ld a, [hli]
ld [de], a
ld [wHPBarNewHP+1], a
@@ -80,17 +84,17 @@ HealEffect_: ; 3b9ec (e:79ec)
ld a, [hl]
ld [de], a
ld [wHPBarNewHP], a
-.asm_3ba6f
+.playAnim
ld hl, PlayCurrentMoveAnimation
call BankswitchEtoF
ld a, [H_WHOSETURN]
and a
- hlCoord 10, 9
+ coord hl, 10, 9
ld a, $1
- jr z, .asm_3ba83
- hlCoord 2, 2
+ jr z, .updateHPBar
+ coord hl, 2, 2
xor a
-.asm_3ba83
+.updateHPBar
ld [wHPBarType], a
predef UpdateHPBar2
ld hl, DrawHUDsAndHPBars
@@ -103,14 +107,14 @@ HealEffect_: ; 3b9ec (e:79ec)
ld hl, PrintButItFailedText_
jp BankswitchEtoF
-StartedSleepingEffect: ; 3baa2 (e:7aa2)
+StartedSleepingEffect:
TX_FAR _StartedSleepingEffect
db "@"
-FellAsleepBecameHealthyText: ; 3baa7 (e:7aa7)
+FellAsleepBecameHealthyText:
TX_FAR _FellAsleepBecameHealthyText
db "@"
-RegainedHealthText: ; 3baac (e:7aac)
+RegainedHealthText:
TX_FAR _RegainedHealthText
db "@"
diff --git a/engine/battle/moveEffects/leech_seed_effect.asm b/engine/battle/moveEffects/leech_seed_effect.asm
index a257d143..0f3a2666 100644
--- a/engine/battle/moveEffects/leech_seed_effect.asm
+++ b/engine/battle/moveEffects/leech_seed_effect.asm
@@ -1,39 +1,40 @@
-LeechSeedEffect_: ; 2bea9 (a:7ea9)
+LeechSeedEffect_:
callab MoveHitTest
- ld a, [W_MOVEMISSED] ; W_MOVEMISSED
+ ld a, [wMoveMissed]
and a
- jr nz, .asm_2bee7
- ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2
- ld de, wEnemyMonType1 ; wcfea (aliases: wEnemyMonType)
- ld a, [H_WHOSETURN] ; $fff3
+ jr nz, .moveMissed
+ ld hl, wEnemyBattleStatus2
+ ld de, wEnemyMonType1
+ ld a, [H_WHOSETURN]
and a
- jr z, .asm_2bec8
- ld hl, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2
- ld de, wBattleMonType1 ; wd019 (aliases: wBattleMonType)
-.asm_2bec8
+ jr z, .leechSeedEffect
+ ld hl, wPlayerBattleStatus2
+ ld de, wBattleMonType1
+.leechSeedEffect
+; miss if the target is grass-type or already seeded
ld a, [de]
cp GRASS
- jr z, .asm_2bee7
+ jr z, .moveMissed
inc de
ld a, [de]
cp GRASS
- jr z, .asm_2bee7
+ jr z, .moveMissed
bit Seeded, [hl]
- jr nz, .asm_2bee7
+ jr nz, .moveMissed
set Seeded, [hl]
callab PlayCurrentMoveAnimation
- ld hl, WasSeededText ; $7ef2
+ ld hl, WasSeededText
jp PrintText
-.asm_2bee7
- ld c, $32
+.moveMissed
+ ld c, 50
call DelayFrames
- ld hl, EvadedAttackText ; $7ef7
+ ld hl, EvadedAttackText
jp PrintText
-WasSeededText: ; 2bef2 (a:7ef2)
+WasSeededText:
TX_FAR _WasSeededText
db "@"
-EvadedAttackText: ; 2bef7 (a:7ef7)
+EvadedAttackText:
TX_FAR _EvadedAttackText
db "@"
diff --git a/engine/battle/moveEffects/mist_effect.asm b/engine/battle/moveEffects/mist_effect.asm
index adee1dfd..b92777de 100644
--- a/engine/battle/moveEffects/mist_effect.asm
+++ b/engine/battle/moveEffects/mist_effect.asm
@@ -1,21 +1,19 @@
-MistEffect_: ; 33f2b (c:7f2b)
- ld hl, W_PLAYERBATTSTATUS2
- ld a, [$fff3]
+MistEffect_:
+ ld hl, wPlayerBattleStatus2
+ ld a, [H_WHOSETURN]
and a
- jr z, .asm_33f36
- ld hl, W_ENEMYBATTSTATUS2
-.asm_33f36
+ jr z, .mistEffect
+ ld hl, wEnemyBattleStatus2
+.mistEffect
bit ProtectedByMist, [hl] ; is mon protected by mist?
- jr nz, .asm_33f4a
+ jr nz, .mistAlreadyInUse
set ProtectedByMist, [hl] ; mon is now protected by mist
callab PlayCurrentMoveAnimation
ld hl, ShroudedInMistText
jp PrintText
-.asm_33f4a
- ld hl, PrintButItFailedText_
- ld b, BANK(PrintButItFailedText_)
- jp Bankswitch
+.mistAlreadyInUse
+ jpab PrintButItFailedText_
-ShroudedInMistText: ; 33f52 (c:7f52)
+ShroudedInMistText:
TX_FAR _ShroudedInMistText
db "@"
diff --git a/engine/battle/moveEffects/one_hit_ko_effect.asm b/engine/battle/moveEffects/one_hit_ko_effect.asm
index 84418e33..827e2197 100644
--- a/engine/battle/moveEffects/one_hit_ko_effect.asm
+++ b/engine/battle/moveEffects/one_hit_ko_effect.asm
@@ -1,5 +1,5 @@
-OneHitKOEffect_: ; 33f57 (c:7f57)
- ld hl, W_DAMAGE
+OneHitKOEffect_:
+ ld hl, wDamage
xor a
ld [hli], a
ld [hl], a ; set the damage output to zero
@@ -7,12 +7,13 @@ OneHitKOEffect_: ; 33f57 (c:7f57)
ld [wCriticalHitOrOHKO], a
ld hl, wBattleMonSpeed + 1
ld de, wEnemyMonSpeed + 1
- ld a, [H_WHOSETURN] ; $fff3
+ ld a, [H_WHOSETURN]
and a
- jr z, .asm_33f72
+ jr z, .compareSpeed
ld hl, wEnemyMonSpeed + 1
ld de, wBattleMonSpeed + 1
-.asm_33f72
+.compareSpeed
+; set damage to 65535 and OHKO flag is the user's current speed is higher than the target's
ld a, [de]
dec de
ld b, a
@@ -22,15 +23,16 @@ OneHitKOEffect_: ; 33f57 (c:7f57)
ld b, a
ld a, [hl]
sbc b
- jr c, .asm_33f8a
- ld hl, W_DAMAGE
+ jr c, .userIsSlower
+ ld hl, wDamage
ld a, $ff
ld [hli], a
ld [hl], a
ld a, $2
ld [wCriticalHitOrOHKO], a
ret
-.asm_33f8a
+.userIsSlower
+; keep damage at 0 and set move missed flag if target's current speed is higher instead
ld a, $1
- ld [W_MOVEMISSED], a
+ ld [wMoveMissed], a
ret
diff --git a/engine/battle/moveEffects/paralyze_effect.asm b/engine/battle/moveEffects/paralyze_effect.asm
index 69acbb01..95979ae6 100644
--- a/engine/battle/moveEffects/paralyze_effect.asm
+++ b/engine/battle/moveEffects/paralyze_effect.asm
@@ -1,11 +1,11 @@
-ParalyzeEffect_: ; 52601 (14:6601)
+ParalyzeEffect_:
ld hl, wEnemyMonStatus
- ld de, W_PLAYERMOVETYPE
+ ld de, wPlayerMoveType
ld a, [H_WHOSETURN]
and a
jp z, .next
- ld hl, wBattleMonStatus
- ld de, W_ENEMYMOVETYPE
+ ld hl, wBattleMonStatus
+ ld de, wEnemyMoveType
.next
ld a, [hl]
and a ; does the target already have a status ailment?
@@ -28,7 +28,7 @@ ParalyzeEffect_: ; 52601 (14:6601)
push hl
callab MoveHitTest
pop hl
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
and a
jr nz, .didntAffect
set PAR, [hl]
@@ -36,18 +36,12 @@ ParalyzeEffect_: ; 52601 (14:6601)
ld c, 30
call DelayFrames
callab PlayCurrentMoveAnimation
- ld hl, PrintMayNotAttackText
- ld b, BANK(PrintMayNotAttackText)
- jp Bankswitch
+ jpab PrintMayNotAttackText
.didntAffect
ld c, 50
call DelayFrames
- ld hl, PrintDidntAffectText
- ld b, BANK(PrintDidntAffectText)
- jp Bankswitch
+ jpab PrintDidntAffectText
.doesntAffect
ld c, 50
call DelayFrames
- ld hl, PrintDoesntAffectText
- ld b, BANK(PrintDoesntAffectText)
- jp Bankswitch
+ jpab PrintDoesntAffectText
diff --git a/engine/battle/moveEffects/pay_day_effect.asm b/engine/battle/moveEffects/pay_day_effect.asm
index 75a005ed..e5daf014 100644
--- a/engine/battle/moveEffects/pay_day_effect.asm
+++ b/engine/battle/moveEffects/pay_day_effect.asm
@@ -1,20 +1,22 @@
-PayDayEffect_ ; 2feb8 (b:7eb8)
+PayDayEffect_:
xor a
ld hl, wcd6d
ld [hli], a
ld a, [H_WHOSETURN]
and a
ld a, [wBattleMonLevel]
- jr z, .asm_2fec8
+ jr z, .payDayEffect
ld a, [wEnemyMonLevel]
-.asm_2fec8
+.payDayEffect
+; level * 2
add a
ld [H_DIVIDEND + 3], a
xor a
ld [H_DIVIDEND], a
ld [H_DIVIDEND + 1], a
ld [H_DIVIDEND + 2], a
- ld a, $64
+; convert to BCD
+ ld a, 100
ld [H_DIVISOR], a
ld b, $4
call Divide
@@ -22,7 +24,7 @@ PayDayEffect_ ; 2feb8 (b:7eb8)
ld [hli], a
ld a, [H_REMAINDER]
ld [H_DIVIDEND + 3], a
- ld a, $a
+ ld a, 10
ld [H_DIVISOR], a
ld b, $4
call Divide
@@ -38,6 +40,6 @@ PayDayEffect_ ; 2feb8 (b:7eb8)
ld hl, CoinsScatteredText
jp PrintText
-CoinsScatteredText: ; 2ff04 (b:7f04)
+CoinsScatteredText:
TX_FAR _CoinsScatteredText
db "@"
diff --git a/engine/battle/moveEffects/recoil_effect.asm b/engine/battle/moveEffects/recoil_effect.asm
index 0460b208..7fc90c44 100644
--- a/engine/battle/moveEffects/recoil_effect.asm
+++ b/engine/battle/moveEffects/recoil_effect.asm
@@ -1,36 +1,37 @@
-RecoilEffect_: ; 1392c (4:792c)
+RecoilEffect_:
ld a, [H_WHOSETURN]
and a
- ld a, [W_PLAYERMOVENUM]
+ ld a, [wPlayerMoveNum]
ld hl, wBattleMonMaxHP
- jr z, .asm_1393d
- ld a, [W_ENEMYMOVENUM]
+ jr z, .recoilEffect
+ ld a, [wEnemyMoveNum]
ld hl, wEnemyMonMaxHP
-.asm_1393d
+.recoilEffect
ld d, a
- ld a, [W_DAMAGE]
+ ld a, [wDamage]
ld b, a
- ld a, [W_DAMAGE + 1]
+ ld a, [wDamage + 1]
ld c, a
srl b
rr c
ld a, d
- cp STRUGGLE
- jr z, .asm_13953
+ cp STRUGGLE ; struggle deals 50% recoil damage
+ jr z, .gotRecoilDamage
srl b
rr c
-.asm_13953
+.gotRecoilDamage
ld a, b
or c
- jr nz, .asm_13958
- inc c
-.asm_13958
+ jr nz, .updateHP
+ inc c ; minimum recoil damage is 1
+.updateHP
+; substract HP from user due to the recoil damage
ld a, [hli]
ld [wHPBarMaxHP+1], a
ld a, [hl]
ld [wHPBarMaxHP], a
push bc
- ld bc, $fff2
+ ld bc, wBattleMonHP - wBattleMonMaxHP
add hl, bc
pop bc
ld a, [hl]
@@ -43,26 +44,27 @@ RecoilEffect_: ; 1392c (4:792c)
sbc b
ld [hl], a
ld [wHPBarNewHP+1], a
- jr nc, .asm_13982
+ jr nc, .getHPBarCoords
+; if recoil damage is higher than the Pokemon's HP, set its HP to 0
xor a
ld [hli], a
ld [hl], a
ld hl, wHPBarNewHP
ld [hli], a
ld [hl], a
-.asm_13982
- hlCoord 10, 9
+.getHPBarCoords
+ coord hl, 10, 9
ld a, [H_WHOSETURN]
and a
ld a, $1
- jr z, .asm_13990
- hlCoord 2, 2
+ jr z, .updateHPBar
+ coord hl, 2, 2
xor a
-.asm_13990
+.updateHPBar
ld [wHPBarType], a
predef UpdateHPBar2
ld hl, HitWithRecoilText
jp PrintText
-HitWithRecoilText: ; 1399e (4:799e)
+HitWithRecoilText:
TX_FAR _HitWithRecoilText
db "@"
diff --git a/engine/battle/moveEffects/reflect_light_screen_effect.asm b/engine/battle/moveEffects/reflect_light_screen_effect.asm
index 39a2c154..b45fbe20 100644
--- a/engine/battle/moveEffects/reflect_light_screen_effect.asm
+++ b/engine/battle/moveEffects/reflect_light_screen_effect.asm
@@ -1,12 +1,12 @@
-ReflectLightScreenEffect_: ; 3bb97 (e:7b97)
- ld hl, W_PLAYERBATTSTATUS3
- ld de, W_PLAYERMOVEEFFECT
+ReflectLightScreenEffect_:
+ ld hl, wPlayerBattleStatus3
+ ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN]
and a
- jr z, .asm_3bba8
- ld hl, W_ENEMYBATTSTATUS3
- ld de, W_ENEMYMOVEEFFECT
-.asm_3bba8
+ jr z, .reflectLightScreenEffect
+ ld hl, wEnemyBattleStatus3
+ ld de, wEnemyMoveEffect
+.reflectLightScreenEffect
ld a, [de]
cp LIGHT_SCREEN_EFFECT
jr nz, .reflect
@@ -14,32 +14,32 @@ ReflectLightScreenEffect_: ; 3bb97 (e:7b97)
jr nz, .moveFailed
set HasLightScreenUp, [hl] ; mon is now protected by light screen
ld hl, LightScreenProtectedText
- jr .asm_3bbc1
+ jr .playAnim
.reflect
bit HasReflectUp, [hl] ; is mon already protected by reflect?
jr nz, .moveFailed
set HasReflectUp, [hl] ; mon is now protected by reflect
ld hl, ReflectGainedArmorText
-.asm_3bbc1
+.playAnim
push hl
ld hl, PlayCurrentMoveAnimation
call BankswitchEtoF
pop hl
jp PrintText
.moveFailed
- ld c, $32
+ ld c, 50
call DelayFrames
ld hl, PrintButItFailedText_
jp BankswitchEtoF
-LightScreenProtectedText: ; 3bbd7 (e:7bd7)
+LightScreenProtectedText:
TX_FAR _LightScreenProtectedText
db "@"
-ReflectGainedArmorText: ; 3bbdc (e:7bdc)
+ReflectGainedArmorText:
TX_FAR _ReflectGainedArmorText
db "@"
-BankswitchEtoF: ; 3bbe1 (e:7be1)
+BankswitchEtoF:
ld b, BANK(BattleCore)
jp Bankswitch
diff --git a/engine/battle/moveEffects/substitute_effect.asm b/engine/battle/moveEffects/substitute_effect.asm
index e88def4a..03314ebf 100644
--- a/engine/battle/moveEffects/substitute_effect.asm
+++ b/engine/battle/moveEffects/substitute_effect.asm
@@ -1,61 +1,61 @@
-SubstituteEffect_: ; 17dad (5:7dad)
+SubstituteEffect_:
ld c, 50
call DelayFrames
ld hl, wBattleMonMaxHP
ld de, wPlayerSubstituteHP
- ld bc, W_PLAYERBATTSTATUS2
+ ld bc, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
and a
jr z, .notEnemy
ld hl, wEnemyMonMaxHP
ld de, wEnemySubstituteHP
- ld bc, W_ENEMYBATTSTATUS2
+ ld bc, wEnemyBattleStatus2
.notEnemy
- ld a, [bc] ;load flags
- bit HasSubstituteUp, a ;user already has substitute?
- jr nz, .alreadyHasSubstitute ;skip this code if so
- ;user doesn't have a substitute [yet]
+ ld a, [bc]
+ bit HasSubstituteUp, a ; user already has substitute?
+ jr nz, .alreadyHasSubstitute
+; quarter health to remove from user
+; assumes max HP is 1023 or lower
push bc
- ld a, [hli] ;load max hp
+ ld a, [hli]
ld b, [hl]
- srl a ;max hp / 4, [quarter health to remove from user]
- rr b
srl a
rr b
+ srl a
+ rr b ; max hp / 4
push de
ld de, wBattleMonHP - wBattleMonMaxHP
- add hl, de ; point hl to current HP
+ add hl, de ; point hl to current HP low byte
pop de
ld a, b
- ld [de], a ;save copy of HP to subtract in ccd7/ccd8 [how much HP substitute has]
- ld a, [hld] ;load current hp
- sub b ;subtract [max hp / 4]
- ld d, a ;save low byte result in D
+ ld [de], a ; save copy of HP to subtract in ccd7/ccd8 [how much HP substitute has]
+ ld a, [hld]
+; subtract [max hp / 4] to current HP
+ sub b
+ ld d, a
ld a, [hl]
- sbc a, 0 ;borrow from high byte if needed
+ sbc 0
pop bc
- jr c, .notEnoughHP ;underflow means user would be left with negative health
- ;bug: note since it only brances on carry, it will possibly leave user with 0HP
+ jr c, .notEnoughHP ; underflow means user would be left with negative health
+ ; bug: since it only brances on carry, it will possibly leave user with 0 HP
.userHasZeroOrMoreHP
- ldi [hl], a ;store high byte HP
- ld [hl], d ;store low byte HP
+ ldi [hl], a ; save resulting HP after substraction into current HP
+ ld [hl], d
ld h, b
ld l, c
- set HasSubstituteUp, [hl] ;set bit 4 of flags, user now has substitute
- ld a, [W_OPTIONS] ;load options
- bit 7, a ;battle animation is enabled?
- ld hl, PlayCurrentMoveAnimation ;animation enabled: 0F:7BA8
+ set HasSubstituteUp, [hl]
+ ld a, [wOptions]
+ bit 7, a ; battle animation is enabled?
+ ld hl, PlayCurrentMoveAnimation
ld b, BANK(PlayCurrentMoveAnimation)
jr z, .animationEnabled
- ld hl, AnimationSubstitute ;animation disabled: 1E:56E0
+ ld hl, AnimationSubstitute
ld b, BANK(AnimationSubstitute)
.animationEnabled
- call Bankswitch ;jump to routine depending on animation setting
+ call Bankswitch ; jump to routine depending on animation setting
ld hl, SubstituteText
call PrintText
- ld hl, DrawHUDsAndHPBars
- ld b, BANK(DrawHUDsAndHPBars)
- jp Bankswitch
+ jpab DrawHUDsAndHPBars
.alreadyHasSubstitute
ld hl, HasSubstituteText
jr .printText
@@ -64,14 +64,14 @@ SubstituteEffect_: ; 17dad (5:7dad)
.printText
jp PrintText
-SubstituteText: ; 17e1d (5:7e1d)
+SubstituteText:
TX_FAR _SubstituteText
db "@"
-HasSubstituteText: ; 17e22 (5:7e22)
+HasSubstituteText:
TX_FAR _HasSubstituteText
db "@"
-TooWeakSubstituteText: ; 17e27 (5:7e27)
+TooWeakSubstituteText:
TX_FAR _TooWeakSubstituteText
db "@"
diff --git a/engine/battle/moveEffects/transform_effect.asm b/engine/battle/moveEffects/transform_effect.asm
index 6e25712a..45f8c910 100644
--- a/engine/battle/moveEffects/transform_effect.asm
+++ b/engine/battle/moveEffects/transform_effect.asm
@@ -1,55 +1,59 @@
-TransformEffect_: ; 3bab1 (e:7ab1)
+TransformEffect_:
ld hl, wBattleMonSpecies
ld de, wEnemyMonSpecies
- ld bc, W_ENEMYBATTSTATUS3
- ld a, [W_ENEMYBATTSTATUS1]
+ ld bc, wEnemyBattleStatus3
+ ld a, [wEnemyBattleStatus1]
ld a, [H_WHOSETURN]
and a
- jr nz, .asm_3bad1
+ jr nz, .hitTest
ld hl, wEnemyMonSpecies
ld de, wBattleMonSpecies
- ld bc, W_PLAYERBATTSTATUS3
+ ld bc, wPlayerBattleStatus3
ld [wPlayerMoveListIndex], a
- ld a, [W_PLAYERBATTSTATUS1]
-.asm_3bad1
+ ld a, [wPlayerBattleStatus1]
+.hitTest
bit Invulnerable, a ; is mon invulnerable to typical attacks? (fly/dig)
jp nz, .failed
push hl
push de
push bc
- ld hl, W_PLAYERBATTSTATUS2
+ ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
and a
- jr z, .asm_3bae4
- ld hl, W_ENEMYBATTSTATUS2
-.asm_3bae4
+ jr z, .transformEffect
+ ld hl, wEnemyBattleStatus2
+.transformEffect
+; animation(s) played are different if target has Substitute up
bit HasSubstituteUp, [hl]
push af
- ld hl, Func_79747
- ld b, BANK(Func_79747)
+ ld hl, HideSubstituteShowMonAnim
+ ld b, BANK(HideSubstituteShowMonAnim)
call nz, Bankswitch
- ld a, [W_OPTIONS]
+ ld a, [wOptions]
add a
ld hl, PlayCurrentMoveAnimation
ld b, BANK(PlayCurrentMoveAnimation)
- jr nc, .asm_3baff
+ jr nc, .gotAnimToPlay
ld hl, AnimationTransformMon
ld b, BANK(AnimationTransformMon)
-.asm_3baff
+.gotAnimToPlay
call Bankswitch
- ld hl, Func_79771
- ld b, BANK(Func_79771)
+ ld hl, ReshowSubstituteAnim
+ ld b, BANK(ReshowSubstituteAnim)
pop af
call nz, Bankswitch
pop bc
ld a, [bc]
- set Transformed, a
+ set Transformed, a ; mon is now Transformed
ld [bc], a
pop de
pop hl
push hl
+; transform user into opposing Pokemon
+; species
ld a, [hl]
ld [de], a
+; type 1, type 2, catch rate, and moves
ld bc, $5
add hl, bc
inc de
@@ -62,20 +66,23 @@ TransformEffect_: ; 3bab1 (e:7ab1)
call CopyData
ld a, [H_WHOSETURN]
and a
- jr z, .asm_3bb32
+ jr z, .next
+; save enemy mon DVs at wTransformedEnemyMonOriginalDVs
ld a, [de]
- ld [wcceb], a
+ ld [wTransformedEnemyMonOriginalDVs], a
inc de
ld a, [de]
- ld [wccec], a
+ ld [wTransformedEnemyMonOriginalDVs + 1], a
dec de
-.asm_3bb32
+.next
+; DVs
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
+; Attack, Defense, Speed, and Special stats
inc hl
inc hl
inc hl
@@ -84,48 +91,51 @@ TransformEffect_: ; 3bab1 (e:7ab1)
inc de
ld bc, $8
call CopyData
- ld bc, $ffef
- add hl, bc
- ld b, $4
-.asm_3bb4a
+ ld bc, wBattleMonMoves - wBattleMonPP
+ add hl, bc ; ld hl, wBattleMonMoves
+ ld b, NUM_MOVES
+.copyPPLoop
+; 5 PP for all moves
ld a, [hli]
and a
- jr z, .asm_3bb57
+ jr z, .lessThanFourMoves
ld a, $5
ld [de], a
inc de
dec b
- jr nz, .asm_3bb4a
- jr .asm_3bb5d
-.asm_3bb57
+ jr nz, .copyPPLoop
+ jr .copyStats
+.lessThanFourMoves
+; 0 PP for blank moves
xor a
ld [de], a
inc de
dec b
- jr nz, .asm_3bb57
-.asm_3bb5d
+ jr nz, .lessThanFourMoves
+.copyStats
+; original (unmodified) stats and stat mods
pop hl
ld a, [hl]
ld [wd11e], a
call GetMonName
ld hl, wEnemyMonUnmodifiedAttack
ld de, wPlayerMonUnmodifiedAttack
- call .copyBasedOnTurn
+ call .copyBasedOnTurn ; original (unmodified) stats
ld hl, wEnemyMonStatMods
ld de, wPlayerMonStatMods
- call .copyBasedOnTurn
+ call .copyBasedOnTurn ; stat mods
ld hl, TransformedText
jp PrintText
.copyBasedOnTurn
ld a, [H_WHOSETURN]
and a
- jr z, .asm_3bb86
+ jr z, .gotStatsOrModsToCopy
push hl
ld h, d
ld l, e
pop de
-.asm_3bb86
+.gotStatsOrModsToCopy
ld bc, $8
jp CopyData
@@ -133,6 +143,6 @@ TransformEffect_: ; 3bab1 (e:7ab1)
ld hl, PrintButItFailedText_
jp BankswitchEtoF
-TransformedText: ; 3bb92 (e:7b92)
+TransformedText:
TX_FAR _TransformedText
db "@"