summaryrefslogtreecommitdiff
path: root/engine/battle/effect_commands.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle/effect_commands.asm')
-rw-r--r--engine/battle/effect_commands.asm58
1 files changed, 30 insertions, 28 deletions
diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm
index 3e6d928d2..91c021a72 100644
--- a/engine/battle/effect_commands.asm
+++ b/engine/battle/effect_commands.asm
@@ -2,7 +2,7 @@ DoPlayerTurn:
call SetPlayerTurn
ld a, [wBattlePlayerAction]
- and a
+ and a ; BATTLEPLAYERACTION_USEMOVE?
ret nz
jr DoTurn
@@ -1210,7 +1210,9 @@ BattleCommand_Critical:
ld [wCriticalHit], a
ret
-INCLUDE "data/battle/critical_hits.asm"
+INCLUDE "data/moves/critical_hit_moves.asm"
+
+INCLUDE "data/battle/critical_hit_chances.asm"
INCLUDE "engine/battle/move_effects/triple_kick.asm"
@@ -1246,7 +1248,7 @@ BattleCommand_Stab:
.go
ld a, BATTLE_VARS_MOVE_TYPE
call GetBattleVarAddr
- ld [wTypeMatchup], a
+ ld [wCurType], a
push hl
push de
@@ -1262,7 +1264,7 @@ BattleCommand_Stab:
pop bc
pop de
- ld a, [wTypeMatchup]
+ ld a, [wCurType]
cp b
jr z, .stab
cp c
@@ -2361,10 +2363,12 @@ BattleCommand_SuperEffectiveText:
.print
jp StdBattleTextBox
-BattleCommand_CheckDestinyBond:
-; checkdestinybond
+BattleCommand_CheckFaint:
+; checkfaint
-; Faint the user if it fainted an opponent using Destiny Bond.
+; Faint the opponent if its HP reached zero
+; and faint the user along with it if it used Destiny Bond.
+; Ends the move effect if the opponent faints.
ld hl, wEnemyMonHP
ld a, [hBattleTurn]
@@ -2592,7 +2596,7 @@ PlayerAttackDamage:
.physicalcrit
ld hl, wBattleMonAttack
- call GetDamageStatsCritical
+ call CheckDamageStatsCritical
jr c, .thickclub
ld hl, wEnemyDefense
@@ -2616,7 +2620,7 @@ PlayerAttackDamage:
.specialcrit
ld hl, wBattleMonSpclAtk
- call GetDamageStatsCritical
+ call CheckDamageStatsCritical
jr c, .lightball
ld hl, wEnemySpDef
@@ -2677,7 +2681,7 @@ TruncateHL_BC:
.finish
ld a, [wLinkMode]
- cp 3
+ cp LINK_COLOSSEUM
jr z, .done
; If we go back to the loop point,
; it's the same as doing this exact
@@ -2690,20 +2694,16 @@ TruncateHL_BC:
ld b, l
ret
-GetDamageStatsCritical:
-; Return carry if non-critical.
+CheckDamageStatsCritical:
+; Return carry if boosted stats should be used in damage calculations.
+; Unboosted stats should be used if the attack is a critical hit,
+; and the stage of the opponent's defense is higher than the user's attack.
ld a, [wCriticalHit]
and a
scf
ret z
- ; fallthrough
-
-GetDamageStats:
-; Return the attacker's offensive stat and the defender's defensive
-; stat based on whether the attacking type is physical or special.
-
push hl
push bc
ld a, [hBattleTurn]
@@ -2838,7 +2838,7 @@ EnemyAttackDamage:
.physicalcrit
ld hl, wEnemyMonAttack
- call GetDamageStatsCritical
+ call CheckDamageStatsCritical
jr c, .thickclub
ld hl, wPlayerDefense
@@ -2862,7 +2862,7 @@ EnemyAttackDamage:
.specialcrit
ld hl, wEnemyMonSpclAtk
- call GetDamageStatsCritical
+ call CheckDamageStatsCritical
jr c, .lightball
ld hl, wPlayerSpDef
ld a, [hli]
@@ -3581,7 +3581,7 @@ UpdateMoveData:
ld a, BATTLE_VARS_MOVE
call GetBattleVar
- ld [wCurMove], a
+ ld [wCurSpecies], a
ld [wNamedObjectIndexBuffer], a
dec a
@@ -4183,13 +4183,13 @@ BattleCommand_EvasionUp2:
BattleCommand_StatUp:
; statup
- call CheckIfStatCanBeRaised
+ call RaiseStat
ld a, [wFailedMessage]
and a
ret nz
- jp StatUpAnimation
+ jp MinimizeDropSub
-CheckIfStatCanBeRaised:
+RaiseStat:
ld a, b
ld [wLoweredStat], a
ld hl, wPlayerStatLevels
@@ -4285,7 +4285,9 @@ CheckIfStatCanBeRaised:
ld [wFailedMessage], a
ret
-StatUpAnimation:
+MinimizeDropSub:
+; Lower the substitute if we're minimizing
+
ld bc, wPlayerMinimized
ld hl, DropPlayerSub
ld a, [hBattleTurn]
@@ -6152,7 +6154,7 @@ BattleCommand_Heal:
push de
push bc
ld c, 2
- call StringCmp
+ call CompareBytes
pop bc
pop de
pop hl
@@ -6571,7 +6573,7 @@ BattleCommand_TimeBasedHealContinue:
; Don't bother healing if HP is already full.
push bc
- call StringCmp
+ call CompareBytes
pop bc
jr z, .Full
@@ -6682,7 +6684,7 @@ INCLUDE "engine/battle/move_effects/future_sight.asm"
INCLUDE "engine/battle/move_effects/thunder.asm"
CheckHiddenOpponent:
-; BUG: This routine should account for Lock-On and Mind Reader.
+; BUG: This routine is completely redundant and introduces a bug, since BattleCommand_CheckHit does these checks properly.
ld a, BATTLE_VARS_SUBSTATUS3_OPP
call GetBattleVar
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND