summaryrefslogtreecommitdiff
path: root/battle
diff options
context:
space:
mode:
Diffstat (limited to 'battle')
-rw-r--r--battle/ai/items.asm4
-rwxr-xr-xbattle/ai/redundant.asm2
-rw-r--r--battle/ai/scoring.asm22
-rwxr-xr-xbattle/ai/switch.asm8
-rw-r--r--battle/anim_commands.asm2
-rw-r--r--battle/bg_effects.asm10
-rw-r--r--battle/core.asm10
-rw-r--r--battle/effect_commands.asm10
-rwxr-xr-xbattle/objects/functions.asm4
9 files changed, 39 insertions, 33 deletions
diff --git a/battle/ai/items.asm b/battle/ai/items.asm
index 4405ae756..325c7b555 100644
--- a/battle/ai/items.asm
+++ b/battle/ai/items.asm
@@ -211,7 +211,7 @@ AI_TryItem: ; 38105
ld a, [hli]
ld h, [hl]
ld l, a
- jp [hl]
+ jp hl
.callback
pop de
pop hl
@@ -238,7 +238,7 @@ AI_TryItem: ; 38105
res SUBSTATUS_RAGE, [hl]
xor a
- ld [LastPlayerCounterMove], a
+ ld [LastEnemyCounterMove], a
scf
ret
diff --git a/battle/ai/redundant.asm b/battle/ai/redundant.asm
index da71d0ece..e3dda8c4b 100755
--- a/battle/ai/redundant.asm
+++ b/battle/ai/redundant.asm
@@ -11,7 +11,7 @@ AI_Redundant: ; 2c41a
ld a, [hli]
ld h, [hl]
ld l, a
- jp [hl]
+ jp hl
.Moves: ; 2c42c
dbw EFFECT_DREAM_EATER, .DreamEater
diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm
index 3091697e5..733322f82 100644
--- a/battle/ai/scoring.asm
+++ b/battle/ai/scoring.asm
@@ -756,7 +756,7 @@ AI_Smart_AlwaysHit: ; 38947
AI_Smart_MirrorMove: ; 3895b
; If the player did not use any move last turn...
- ld a, [LastEnemyCounterMove]
+ ld a, [LastPlayerCounterMove]
and a
jr nz, .asm_38968
@@ -1353,7 +1353,7 @@ AI_Smart_Rage: ; 38b7f
AI_Smart_Mimic: ; 38ba8
- ld a, [LastEnemyCounterMove]
+ ld a, [LastPlayerCounterMove]
and a
jr z, .asm_38be9
@@ -1361,7 +1361,7 @@ AI_Smart_Mimic: ; 38ba8
jr nc, .asm_38bef
push hl
- ld a, [LastEnemyCounterMove]
+ ld a, [LastPlayerCounterMove]
call AIGetEnemyMove
ld a, $1
@@ -1380,7 +1380,7 @@ AI_Smart_Mimic: ; 38ba8
dec [hl]
.asm_38bd4
- ld a, [LastEnemyCounterMove]
+ ld a, [LastPlayerCounterMove]
push hl
ld hl, UsefulMoves
ld de, 1
@@ -1438,7 +1438,7 @@ AI_Smart_Counter: ; 38bf1
cp $3
jr nc, .asm_38c30
- ld a, [LastEnemyCounterMove]
+ ld a, [LastPlayerCounterMove]
and a
jr z, .asm_38c38
@@ -1499,7 +1499,7 @@ AI_Smart_Encore: ; 38c3b
.asm_38c68
push hl
- ld a, [LastEnemyCounterMove]
+ ld a, [LastPlayerCounterMove]
ld hl, .EncoreMoves
ld de, 1
call IsInArray
@@ -1615,7 +1615,7 @@ AI_Smart_DefrostOpponent: ; 38ccb
AI_Smart_Spite: ; 38cd5
- ld a, [LastEnemyCounterMove]
+ ld a, [LastPlayerCounterMove]
and a
jr nz, .asm_38ce7
@@ -1837,7 +1837,7 @@ AI_Smart_Disable: ; 38dd1
jr nc, .asm_38df3
push hl
- ld a, [LastEnemyCounterMove]
+ ld a, [LastPlayerCounterMove]
ld hl, UsefulMoves
ld de, 1
call IsInArray
@@ -2367,7 +2367,7 @@ AI_Smart_Magnitude:
AI_Smart_Earthquake: ; 39044
; Greatly encourage this move if the player is underground and the enemy is faster.
- ld a, [LastEnemyCounterMove]
+ ld a, [LastPlayerCounterMove]
cp DIG
ret nz
@@ -2741,7 +2741,7 @@ AI_Smart_MirrorCoat: ; 3918b
cp $3
jr nc, .asm_391ca
- ld a, [LastEnemyCounterMove]
+ ld a, [LastPlayerCounterMove]
and a
jr z, .asm_391d2
@@ -2775,7 +2775,7 @@ AI_Smart_Twister:
AI_Smart_Gust: ; 391d5
; Greatly encourage this move if the player is flying and the enemy is faster.
- ld a, [LastEnemyCounterMove]
+ ld a, [LastPlayerCounterMove]
cp FLY
ret nz
diff --git a/battle/ai/switch.asm b/battle/ai/switch.asm
index cb1fe3660..c2f83fa1f 100755
--- a/battle/ai/switch.asm
+++ b/battle/ai/switch.asm
@@ -229,7 +229,7 @@ CheckAbleToSwitch: ; 34941
cp 11
ret nc
- ld a, [LastEnemyCounterMove]
+ ld a, [LastPlayerCounterMove]
and a
jr z, .no_last_counter_move
@@ -378,8 +378,8 @@ FindEnemyMonsImmuneToLastCounterMove: ; 34a2a
ld [CurSpecies], a
call GetBaseData
- ; the enemy's last move is damaging...
- ld a, [LastEnemyCounterMove]
+ ; the player's last move is damaging...
+ ld a, [LastPlayerCounterMove]
dec a
ld hl, Moves + MOVE_POWER
call GetMoveAttr
@@ -568,7 +568,7 @@ FindEnemyMonsThatResistPlayer: ; 34b20
push hl
ld [CurSpecies], a
call GetBaseData
- ld a, [LastEnemyCounterMove]
+ ld a, [LastPlayerCounterMove]
and a
jr z, .skip_move
diff --git a/battle/anim_commands.asm b/battle/anim_commands.asm
index 957b2a066..958dcfe40 100644
--- a/battle/anim_commands.asm
+++ b/battle/anim_commands.asm
@@ -347,7 +347,7 @@ RunBattleAnimCommand: ; cc25f
ld a, [hli]
ld h, [hl]
ld l, a
- jp [hl]
+ jp hl
; cc2a4
diff --git a/battle/bg_effects.asm b/battle/bg_effects.asm
index b7f415770..22807f77d 100644
--- a/battle/bg_effects.asm
+++ b/battle/bg_effects.asm
@@ -75,7 +75,7 @@ DoBattleBGEffectFunction: ; c804a (32:404a)
ld a, [hli]
ld h, [hl]
ld l, a
- jp [hl]
+ jp hl
BattleBGEffects: ; c805a (32:405a)
dw BattleBGEffect_End
@@ -161,7 +161,7 @@ BattleBGEffects_AnonJumptable: ; c80d7 (32:40d7)
ld a, [hli]
ld h, [hl]
ld l, a
- jp [hl]
+ jp hl
BattleBGEffects_IncrementJumptable: ; c80e5 (32:40e5)
ld hl, BG_EFFECT_STRUCT_JT_INDEX
@@ -2059,7 +2059,7 @@ BattleBGEffect_1c: ; c8b00 (32:4b00)
.cgb
ld de, .Jumptable
call BatttleBGEffects_GetNamedJumptablePointer
- jp [hl]
+ jp hl
.Jumptable:
dw .cgb_zero
@@ -2421,7 +2421,7 @@ BGEffect_RapidCyclePals: ; c8d77 (32:4d77)
ld de, .Jumptable_DMG
call BatttleBGEffects_GetNamedJumptablePointer
pop de
- jp [hl]
+ jp hl
.Jumptable_DMG:
dw .zero_dmg
@@ -2484,7 +2484,7 @@ BGEffect_RapidCyclePals: ; c8d77 (32:4d77)
ld de, .Jumptable_CGB
call BatttleBGEffects_GetNamedJumptablePointer
pop de
- jp [hl]
+ jp hl
.Jumptable_CGB: ; c8ddd (32:4ddd)
dw .zero_cgb
diff --git a/battle/core.asm b/battle/core.asm
index dec315ab8..cb709e08d 100644
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -3366,8 +3366,8 @@ CheckWhetherSwitchmonIsPredetermined: ; 3d533
ResetEnemyBattleVars: ; 3d557
; and draw empty TextBox
xor a
- ld [LastEnemyCounterMove], a
ld [LastPlayerCounterMove], a
+ ld [LastEnemyCounterMove], a
ld [LastEnemyMove], a
ld [CurEnemyMove], a
dec a
@@ -3766,8 +3766,8 @@ Function_SetEnemyPkmnAndSendOutAnimation: ; 3d7c7
NewEnemyMonStatus: ; 3d834
xor a
- ld [LastEnemyCounterMove], a
ld [LastPlayerCounterMove], a
+ ld [LastEnemyCounterMove], a
ld [LastEnemyMove], a
ld hl, EnemySubStatus1
rept 4
@@ -4217,8 +4217,8 @@ SendOutPlayerMon: ; 3db5f
ld [CurMoveNum], a
ld [TypeModifier], a
ld [wPlayerMoveStruct + MOVE_ANIM], a
- ld [LastEnemyCounterMove], a
ld [LastPlayerCounterMove], a
+ ld [LastEnemyCounterMove], a
ld [LastPlayerMove], a
call CheckAmuletCoin
call FinishBattleAnim
@@ -4258,8 +4258,8 @@ SendOutPlayerMon: ; 3db5f
NewBattleMonStatus: ; 3dbde
xor a
- ld [LastEnemyCounterMove], a
ld [LastPlayerCounterMove], a
+ ld [LastEnemyCounterMove], a
ld [LastPlayerMove], a
ld hl, PlayerSubStatus1
rept 4
@@ -4331,7 +4331,7 @@ SpikesDamage: ; 3dc23
jp WaitBGMap
.hl
- jp [hl]
+ jp hl
; 3dc5b
PursuitSwitch: ; 3dc5b
diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm
index a74dea632..221570d76 100644
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -113,7 +113,7 @@ DoMove: ; 3402c
jr .ReadMoveEffectCommand
.DoMoveEffectCommand:
- jp [hl]
+ jp hl
; 34084
@@ -971,7 +971,7 @@ BattleCommand_CheckObedience: ; 343db
.EndDisobedience:
xor a
ld [LastPlayerMove], a
- ld [LastEnemyCounterMove], a
+ ld [LastPlayerCounterMove], a
; Break Encore too.
ld hl, PlayerSubStatus5
@@ -1542,6 +1542,12 @@ BattleCheckTypeMatchup: ; 347c8
jr z, CheckTypeMatchup
ld hl, BattleMonType1
CheckTypeMatchup: ; 347d3
+; There is an incorrect assumption about this function made in the AI related code: when
+; the AI calls CheckTypeMatchup (not BattleCheckTypeMatchup), it assumes that placing the
+; offensive type in a will make this function do the right thing. Since a is overwritten,
+; this assumption is incorrect. A simple fix would be to load the move type for the
+; current move into a in BattleCheckTypeMatchup, before falling through, which is
+; consistent with how the rest of the code assumes this code works like.
push hl
push de
push bc
diff --git a/battle/objects/functions.asm b/battle/objects/functions.asm
index 4ed9b67b7..debfcf04d 100755
--- a/battle/objects/functions.asm
+++ b/battle/objects/functions.asm
@@ -9,7 +9,7 @@ DoBattleAnimFrame: ; ccfbe
ld a, [hli]
ld h, [hl]
ld l, a
- jp [hl]
+ jp hl
; ccfce
.Jumptable:
@@ -4085,7 +4085,7 @@ BattleAnim_AnonJumptable: ; ce71e (33:671e)
ld a, [hli]
ld h, [hl]
ld l, a
- jp [hl]
+ jp hl
BattleAnim_IncAnonJumptableIndex: ; ce72c (33:672c)
ld hl, BATTLEANIMSTRUCT_ANON_JT_INDEX