summaryrefslogtreecommitdiff
path: root/engine/battle/ai
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle/ai')
-rw-r--r--engine/battle/ai/items.asm108
-rwxr-xr-xengine/battle/ai/move.asm38
-rwxr-xr-xengine/battle/ai/redundant.asm52
-rw-r--r--engine/battle/ai/scoring.asm388
-rwxr-xr-xengine/battle/ai/switch.asm66
5 files changed, 326 insertions, 326 deletions
diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm
index d0867fb33..4d1eea2e8 100644
--- a/engine/battle/ai/items.asm
+++ b/engine/battle/ai/items.asm
@@ -12,7 +12,7 @@ AI_SwitchOrTryItem: ; 38000
farcall CheckEnemyLockedIn
ret nz
- ld a, [PlayerSubStatus5]
+ ld a, [wPlayerSubStatus5]
bit SUBSTATUS_CANT_RUN, a
jr nz, DontSwitch
@@ -21,11 +21,11 @@ AI_SwitchOrTryItem: ; 38000
jr nz, DontSwitch
ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH
- ld a, [InBattleTowerBattle] ; Load always the first TrainerClass for BattleTower-Trainers
+ ld a, [wInBattleTowerBattle] ; always load the first trainer class in wTrainerClass for BattleTower-Trainers
and a
jr nz, .ok
- ld a, [TrainerClass]
+ ld a, [wTrainerClass]
dec a
ld bc, NUM_TRAINER_ATTRIBUTES
call AddNTimes
@@ -151,7 +151,7 @@ SwitchSometimes: ; 380c1
CheckSubstatusCantRun: ; 380ff
- ld a, [EnemySubStatus5]
+ ld a, [wEnemySubStatus5]
bit SUBSTATUS_CANT_RUN, a
ret
; 38105
@@ -159,7 +159,7 @@ CheckSubstatusCantRun: ; 380ff
AI_TryItem: ; 38105
; items are not allowed in the BattleTower
- ld a, [InBattleTowerBattle]
+ ld a, [wInBattleTowerBattle]
and a
ret nz
@@ -172,7 +172,7 @@ AI_TryItem: ; 38105
call .IsHighestLevel
ret nc
- ld a, [TrainerClass]
+ ld a, [wTrainerClass]
dec a
ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH
ld bc, NUM_TRAINER_ATTRIBUTES
@@ -226,29 +226,29 @@ AI_TryItem: ; 38105
inc a
ld [wEnemyGoesFirst], a
- ld hl, EnemySubStatus3
+ ld hl, wEnemySubStatus3
res SUBSTATUS_BIDE, [hl]
xor a
- ld [EnemyFuryCutterCount], a
- ld [EnemyProtectCount], a
+ ld [wEnemyFuryCutterCount], a
+ ld [wEnemyProtectCount], a
ld [wEnemyRageCounter], a
- ld hl, EnemySubStatus4
+ ld hl, wEnemySubStatus4
res SUBSTATUS_RAGE, [hl]
xor a
- ld [LastEnemyCounterMove], a
+ ld [wLastEnemyCounterMove], a
scf
ret
.IsHighestLevel: ; 38170
- ld a, [OTPartyCount]
+ ld a, [wOTPartyCount]
ld d, a
ld e, 0
- ld hl, OTPartyMon1Level
+ ld hl, wOTPartyMon1Level
ld bc, PARTYMON_STRUCT_LENGTH
.next
ld a, [hl]
@@ -260,8 +260,8 @@ AI_TryItem: ; 38105
dec d
jr nz, .next
- ld a, [CurOTMon]
- ld hl, OTPartyMon1Level
+ ld a, [wCurOTMon]
+ ld hl, wOTPartyMon1Level
call AddNTimes
ld a, [hl]
cp e
@@ -302,7 +302,7 @@ AI_Items: ; 39196
; 381ca
.Status: ; 381ca (e:41ca)
- ld a, [EnemyMonStatus]
+ ld a, [wEnemyMonStatus]
and a
jp z, .DontUse
@@ -318,17 +318,17 @@ AI_Items: ; 39196
jp .DontUse
.StatusCheckContext:
- ld a, [EnemySubStatus5]
+ ld a, [wEnemySubStatus5]
bit SUBSTATUS_TOXIC, a
jr z, .FailToxicCheck
- ld a, [EnemyToxicCount]
+ ld a, [wEnemyToxicCount]
cp 4
jr c, .FailToxicCheck
call Random
cp 1 + 50 percent
jp c, .Use
.FailToxicCheck:
- ld a, [EnemyMonStatus]
+ ld a, [wEnemyMonStatus]
and 1 << FRZ | SLP
jp z, .DontUse
jp .Use
@@ -419,8 +419,8 @@ AI_Items: ; 39196
callfar AICheckEnemyMaxHP
jr c, .dont_use
push bc
- ld de, EnemyMonMaxHP + 1
- ld hl, EnemyMonHP + 1
+ ld de, wEnemyMonMaxHP + 1
+ ld hl, wEnemyMonHP + 1
ld a, [de]
sub [hl]
jr z, .check_40_percent
@@ -509,7 +509,7 @@ AI_Items: ; 39196
; 3834d
.XItem: ; 3834d (e:434d)
- ld a, [EnemyTurnsTaken]
+ ld a, [wEnemyTurnsTaken]
and a
jr nz, .notfirstturnout
ld a, [bc]
@@ -571,37 +571,37 @@ EnemyUsedFullHeal: ; 383a3 (e:43a3)
EnemyUsedMaxPotion: ; 383ae (e:43ae)
ld a, MAX_POTION
- ld [CurEnemyItem], a
+ ld [wCurEnemyItem], a
jr FullRestoreContinue
EnemyUsedFullRestore: ; 383b5 (e:43b5)
call AI_HealStatus
ld a, FULL_RESTORE
- ld [CurEnemyItem], a
- ld hl, EnemySubStatus3
+ ld [wCurEnemyItem], a
+ ld hl, wEnemySubStatus3
res SUBSTATUS_CONFUSED, [hl]
xor a
- ld [EnemyConfuseCount], a
+ ld [wEnemyConfuseCount], a
FullRestoreContinue: ; 383c6
ld de, wCurHPAnimOldHP
- ld hl, EnemyMonHP + 1
+ ld hl, wEnemyMonHP + 1
ld a, [hld]
ld [de], a
inc de
ld a, [hl]
ld [de], a
inc de
- ld hl, EnemyMonMaxHP + 1
+ ld hl, wEnemyMonMaxHP + 1
ld a, [hld]
ld [de], a
inc de
ld [wCurHPAnimMaxHP], a
- ld [EnemyMonHP + 1], a
+ ld [wEnemyMonHP + 1], a
ld a, [hl]
ld [de], a
ld [wCurHPAnimMaxHP + 1], a
- ld [EnemyMonHP], a
+ ld [wEnemyMonHP], a
jr EnemyPotionFinish
; 383e8 (e:43e8)
@@ -620,8 +620,8 @@ EnemyUsedHyperPotion: ; 383f4 (e:43f4)
ld b, 200
EnemyPotionContinue: ; 383f8
- ld [CurEnemyItem], a
- ld hl, EnemyMonHP + 1
+ ld [wCurEnemyItem], a
+ ld hl, wEnemyMonHP + 1
ld a, [hl]
ld [wCurHPAnimOldHP], a
add b
@@ -638,7 +638,7 @@ EnemyPotionContinue: ; 383f8
inc hl
ld a, [hld]
ld b, a
- ld de, EnemyMonMaxHP + 1
+ ld de, wEnemyMonMaxHP + 1
ld a, [de]
dec de
ld [wCurHPAnimMaxHP], a
@@ -671,9 +671,9 @@ EnemyPotionFinish: ; 38436
AI_TrySwitch: ; 3844b
; Determine whether the AI can switch based on how many Pokemon are still alive.
; If it can switch, it will.
- ld a, [OTPartyCount]
+ ld a, [wOTPartyCount]
ld c, a
- ld hl, OTPartyMon1HP
+ ld hl, wOTPartyMon1HP
ld d, 0
.SwitchLoop:
ld a, [hli]
@@ -701,20 +701,20 @@ AI_Switch: ; 3846c
ld a, $1
ld [wEnemyIsSwitching], a
ld [wEnemyGoesFirst], a
- ld hl, EnemySubStatus4
+ ld hl, wEnemySubStatus4
res SUBSTATUS_RAGE, [hl]
xor a
ld [hBattleTurn], a
callfar PursuitSwitch
push af
- ld a, [CurOTMon]
- ld hl, OTPartyMon1Status
+ ld a, [wCurOTMon]
+ ld hl, wOTPartyMon1Status
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
- ld hl, EnemyMonStatus
+ ld hl, wEnemyMonStatus
ld bc, MON_MAXHP - MON_STATUS
call CopyBytes
pop af
@@ -728,7 +728,7 @@ AI_Switch: ; 3846c
ld [wBattleHasJustStarted], a
callfar NewEnemyMonStatus
callfar ResetEnemyStatLevels
- ld hl, PlayerSubStatus1
+ ld hl, wPlayerSubStatus1
res SUBSTATUS_IN_LOVE, [hl]
farcall EnemySwitch
farcall ResetBattleParticipants
@@ -754,25 +754,25 @@ Function384d5: ; This appears to be unused
; 384e0
AI_HealStatus: ; 384e0
- ld a, [CurOTMon]
- ld hl, OTPartyMon1Status
+ ld a, [wCurOTMon]
+ ld hl, wOTPartyMon1Status
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
xor a
ld [hl], a
- ld [EnemyMonStatus], a
+ ld [wEnemyMonStatus], a
; Bug: this should reset SUBSTATUS_NIGHTMARE too
; Uncomment the lines below to fix
- ; ld hl, EnemySubStatus1
+ ; ld hl, wEnemySubStatus1
; res SUBSTATUS_NIGHTMARE, [hl]
- ld hl, EnemySubStatus5
+ ld hl, wEnemySubStatus5
res SUBSTATUS_TOXIC, [hl]
ret
; 384f7
EnemyUsedXAccuracy: ; 384f7
call AIUsedItemSound
- ld hl, EnemySubStatus4
+ ld hl, wEnemySubStatus4
set SUBSTATUS_X_ACCURACY, [hl]
ld a, X_ACCURACY
jp PrintText_UsedItemOn_AND_AIUpdateHUD
@@ -780,7 +780,7 @@ EnemyUsedXAccuracy: ; 384f7
EnemyUsedGuardSpec: ; 38504
call AIUsedItemSound
- ld hl, EnemySubStatus4
+ ld hl, wEnemySubStatus4
set SUBSTATUS_MIST, [hl]
ld a, GUARD_SPEC
jp PrintText_UsedItemOn_AND_AIUpdateHUD
@@ -788,7 +788,7 @@ EnemyUsedGuardSpec: ; 38504
EnemyUsedDireHit: ; 38511
call AIUsedItemSound
- ld hl, EnemySubStatus4
+ ld hl, wEnemySubStatus4
set SUBSTATUS_FOCUS_ENERGY, [hl]
ld a, DIRE_HIT
jp PrintText_UsedItemOn_AND_AIUpdateHUD
@@ -796,7 +796,7 @@ EnemyUsedDireHit: ; 38511
Function3851e: ; This appears to be unused
ld [hDivisor], a
- ld hl, EnemyMonMaxHP
+ ld hl, wEnemyMonMaxHP
ld a, [hli]
ld [hDividend], a
ld a, [hl]
@@ -807,7 +807,7 @@ Function3851e: ; This appears to be unused
ld c, a
ld a, [hQuotient + 1]
ld b, a
- ld hl, EnemyMonHP + 1
+ ld hl, wEnemyMonHP + 1
ld a, [hld]
ld e, a
ld a, [hl]
@@ -847,7 +847,7 @@ EnemyUsedXSpecial: ; 38553
; a = ITEM_CONSTANT
; b = BATTLE_CONSTANT (ATTACK, DEFENSE, SPEED, SP_ATTACK, SP_DEFENSE, ACCURACY, EVASION)
EnemyUsedXItem:
- ld [CurEnemyItem], a
+ ld [wCurEnemyItem], a
push bc
call PrintText_UsedItemOn
pop bc
@@ -859,16 +859,16 @@ EnemyUsedXItem:
; Parameter
; a = ITEM_CONSTANT
PrintText_UsedItemOn_AND_AIUpdateHUD: ; 38568
- ld [CurEnemyItem], a
+ ld [wCurEnemyItem], a
call PrintText_UsedItemOn
jp AIUpdateHUD
; 38571
PrintText_UsedItemOn: ; 38571
- ld a, [CurEnemyItem]
+ ld a, [wCurEnemyItem]
ld [wd265], a
call GetItemName
- ld hl, StringBuffer1
+ ld hl, wStringBuffer1
ld de, wMonOrItemNameBuffer
ld bc, ITEM_NAME_LENGTH
call CopyBytes
diff --git a/engine/battle/ai/move.asm b/engine/battle/ai/move.asm
index cee2037e3..dd4357fe2 100755
--- a/engine/battle/ai/move.asm
+++ b/engine/battle/ai/move.asm
@@ -1,5 +1,5 @@
AIChooseMove: ; 440ce
-; Score each move in EnemyMonMoves starting from Buffer1. Lower is better.
+; Score each move in wEnemyMonMoves starting from wBuffer1. Lower is better.
; Pick the move with the lowest score.
; Wildmons attack at random.
@@ -18,18 +18,18 @@ AIChooseMove: ; 440ce
; The default score is 20. Unusable moves are given a score of 80.
ld a, 20
- ld hl, Buffer1
+ ld hl, wBuffer1
ld [hli], a
ld [hli], a
ld [hli], a
ld [hl], a
; Don't pick disabled moves.
- ld a, [EnemyDisabledMove]
+ ld a, [wEnemyDisabledMove]
and a
jr z, .CheckPP
- ld hl, EnemyMonMoves
+ ld hl, wEnemyMonMoves
ld c, 0
.CheckDisabledMove:
cp [hl]
@@ -38,20 +38,20 @@ AIChooseMove: ; 440ce
inc hl
jr .CheckDisabledMove
.ScoreDisabledMove:
- ld hl, Buffer1
+ ld hl, wBuffer1
ld b, 0
add hl, bc
ld [hl], 80
; Don't pick moves with 0 PP.
.CheckPP:
- ld hl, Buffer1 - 1
- ld de, EnemyMonPP
+ ld hl, wBuffer1 - 1
+ ld de, wEnemyMonPP
ld b, 0
.CheckMovePP:
inc b
ld a, b
- cp EnemyMonMovesEnd - EnemyMonMoves + 1
+ cp wEnemyMonMovesEnd - wEnemyMonMoves + 1
jr z, .ApplyLayers
inc hl
ld a, [de]
@@ -66,13 +66,13 @@ AIChooseMove: ; 440ce
.ApplyLayers:
ld hl, TrainerClassAttributes + TRNATTR_AI_MOVE_WEIGHTS
- ; If we have a battle in BattleTower just load the Attributes of the first TrainerClass (Falkner)
+ ; If we have a battle in BattleTower just load the Attributes of the first trainer class in wTrainerClass (Falkner)
; so we have always the same AI, regardless of the loaded class of trainer
- ld a, [InBattleTowerBattle]
+ ld a, [wInBattleTowerBattle]
bit 0, a
jr nz, .battle_tower_skip
- ld a, [TrainerClass]
+ ld a, [wTrainerClass]
dec a
ld bc, 7 ; Trainer2AI - Trainer1AI
call AddNTimes
@@ -119,9 +119,9 @@ AIChooseMove: ; 440ce
; Decrement the scores of all moves one by one until one reaches 0.
.DecrementScores:
- ld hl, Buffer1
- ld de, EnemyMonMoves
- ld c, EnemyMonMovesEnd - EnemyMonMoves
+ ld hl, wBuffer1
+ ld de, wEnemyMonMoves
+ ld c, wEnemyMonMovesEnd - wEnemyMonMoves
.DecrementNextScore:
; If the enemy has no moves, this will infinite.
@@ -154,8 +154,8 @@ AIChooseMove: ; 440ce
cp NUM_MOVES + 1
jr nz, .move_loop
- ld hl, Buffer1
- ld de, EnemyMonMoves
+ ld hl, wBuffer1
+ ld de, wEnemyMonMoves
ld c, NUM_MOVES
; Give a score of 0 to a blank move
@@ -184,7 +184,7 @@ AIChooseMove: ; 440ce
; Randomly choose one of the moves with a score of 1
.ChooseMove:
- ld hl, Buffer1
+ ld hl, wBuffer1
call Random
maskbits NUM_MOVES
ld c, a
@@ -194,9 +194,9 @@ AIChooseMove: ; 440ce
and a
jr z, .ChooseMove
- ld [CurEnemyMove], a
+ ld [wCurEnemyMove], a
ld a, c
- ld [CurEnemyMoveNum], a
+ ld [wCurEnemyMoveNum], a
ret
; 441af
diff --git a/engine/battle/ai/redundant.asm b/engine/battle/ai/redundant.asm
index 2e8f7c6df..d09b4da73 100755
--- a/engine/battle/ai/redundant.asm
+++ b/engine/battle/ai/redundant.asm
@@ -47,95 +47,95 @@ AI_Redundant: ; 2c41a
db -1
.LightScreen: ; 2c487
- ld a, [EnemyScreens]
+ ld a, [wEnemyScreens]
bit SCREENS_LIGHT_SCREEN, a
ret
.Mist: ; 2c48d
- ld a, [EnemySubStatus4]
+ ld a, [wEnemySubStatus4]
bit SUBSTATUS_MIST, a
ret
.FocusEnergy: ; 2c493
- ld a, [EnemySubStatus4]
+ ld a, [wEnemySubStatus4]
bit SUBSTATUS_FOCUS_ENERGY, a
ret
.Confuse: ; 2c499
- ld a, [PlayerSubStatus3]
+ ld a, [wPlayerSubStatus3]
bit SUBSTATUS_CONFUSED, a
ret nz
- ld a, [PlayerScreens]
+ ld a, [wPlayerScreens]
bit SCREENS_SAFEGUARD, a
ret
.Transform: ; 2c4a5
- ld a, [EnemySubStatus5]
+ ld a, [wEnemySubStatus5]
bit SUBSTATUS_TRANSFORMED, a
ret
.Reflect: ; 2c4ab
- ld a, [EnemyScreens]
+ ld a, [wEnemyScreens]
bit SCREENS_REFLECT, a
ret
.Substitute: ; 2c4b1
- ld a, [EnemySubStatus4]
+ ld a, [wEnemySubStatus4]
bit SUBSTATUS_SUBSTITUTE, a
ret
.LeechSeed: ; 2c4b7
- ld a, [PlayerSubStatus4]
+ ld a, [wPlayerSubStatus4]
bit SUBSTATUS_LEECH_SEED, a
ret
.Disable: ; 2c4bd
- ld a, [PlayerDisableCount]
+ ld a, [wPlayerDisableCount]
and a
ret
.Encore: ; 2c4c2
- ld a, [PlayerSubStatus5]
+ ld a, [wPlayerSubStatus5]
bit SUBSTATUS_ENCORED, a
ret
.Snore:
.SleepTalk: ; 2c4c8
- ld a, [EnemyMonStatus]
+ ld a, [wEnemyMonStatus]
and SLP
jr z, .Redundant
jr .NotRedundant
.MeanLook: ; 2c4d1
- ld a, [EnemySubStatus5]
+ ld a, [wEnemySubStatus5]
bit SUBSTATUS_CANT_RUN, a
ret
.Nightmare: ; 2c4d7
- ld a, [BattleMonStatus]
+ ld a, [wBattleMonStatus]
and a
jr z, .Redundant
- ld a, [PlayerSubStatus1]
+ ld a, [wPlayerSubStatus1]
bit SUBSTATUS_NIGHTMARE, a
ret
.Spikes: ; 2c4e3
- ld a, [PlayerScreens]
+ ld a, [wPlayerScreens]
bit SCREENS_SPIKES, a
ret
.Foresight: ; 2c4e9
- ld a, [PlayerSubStatus1]
+ ld a, [wPlayerSubStatus1]
bit SUBSTATUS_IDENTIFIED, a
ret
.PerishSong: ; 2c4ef
- ld a, [PlayerSubStatus1]
+ ld a, [wPlayerSubStatus1]
bit SUBSTATUS_PERISH, a
ret
.Sandstorm: ; 2c4f5
- ld a, [Weather]
+ ld a, [wBattleWeather]
cp WEATHER_SANDSTORM
jr z, .Redundant
jr .NotRedundant
@@ -143,40 +143,40 @@ AI_Redundant: ; 2c41a
.Attract: ; 2c4fe
farcall CheckOppositeGender
jr c, .Redundant
- ld a, [PlayerSubStatus1]
+ ld a, [wPlayerSubStatus1]
bit SUBSTATUS_IN_LOVE, a
ret
.Safeguard: ; 2c50c
- ld a, [EnemyScreens]
+ ld a, [wEnemyScreens]
bit SCREENS_SAFEGUARD, a
ret
.RainDance: ; 2c512
- ld a, [Weather]
+ ld a, [wBattleWeather]
cp WEATHER_RAIN
jr z, .Redundant
jr .NotRedundant
.SunnyDay: ; 2c51b
- ld a, [Weather]
+ ld a, [wBattleWeather]
cp WEATHER_SUN
jr z, .Redundant
jr .NotRedundant
.DreamEater: ; 2c524
- ld a, [BattleMonStatus]
+ ld a, [wBattleMonStatus]
and SLP
jr z, .Redundant
jr .NotRedundant
.Swagger: ; 2c52d
- ld a, [PlayerSubStatus3]
+ ld a, [wPlayerSubStatus3]
bit SUBSTATUS_CONFUSED, a
ret
.FutureSight: ; 2c533
- ld a, [EnemyScreens]
+ ld a, [wEnemyScreens]
bit 5, a
ret
diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm
index 902910b86..7af2db8ad 100644
--- a/engine/battle/ai/scoring.asm
+++ b/engine/battle/ai/scoring.asm
@@ -5,9 +5,9 @@ AI_Basic: ; 38591
; -Using status-only moves if the player can't be statused
; -Using moves that fail if they've already been used
- ld hl, Buffer1 - 1
- ld de, EnemyMonMoves
- ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
+ ld hl, wBuffer1 - 1
+ ld de, wEnemyMonMoves
+ ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
.checkmove
dec b
ret z
@@ -49,12 +49,12 @@ AI_Basic: ; 38591
pop hl
jr nc, .checkmove
- ld a, [BattleMonStatus]
+ ld a, [wBattleMonStatus]
and a
jr nz, .discourage
; Dismiss Safeguard if it's already active.
- ld a, [PlayerScreens]
+ ld a, [wPlayerScreens]
bit SCREENS_SAFEGUARD, a
jr z, .checkmove
@@ -74,9 +74,9 @@ AI_Setup: ; 385e0
; 50% chance to greatly encourage stat-down moves during the first turn of player's Pokemon.
; Almost 90% chance to greatly discourage stat-modifying moves otherwise.
- ld hl, Buffer1 - 1
- ld de, EnemyMonMoves
- ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
+ ld hl, wBuffer1 - 1
+ ld de, wEnemyMonMoves
+ ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
.checkmove
dec b
ret z
@@ -114,14 +114,14 @@ AI_Setup: ; 385e0
jr .checkmove
.statup
- ld a, [EnemyTurnsTaken]
+ ld a, [wEnemyTurnsTaken]
and a
jr nz, .discourage
jr .encourage
.statdown
- ld a, [PlayerTurnsTaken]
+ ld a, [wPlayerTurnsTaken]
and a
jr nz, .discourage
@@ -150,9 +150,9 @@ AI_Types: ; 38635
; Discourage not very effective moves unless
; all damaging moves are of the same type.
- ld hl, Buffer1 - 1
- ld de, EnemyMonMoves
- ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
+ ld hl, wBuffer1 - 1
+ ld de, wEnemyMonMoves
+ ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
.checkmove
dec b
ret z
@@ -197,8 +197,8 @@ AI_Types: ; 38635
push bc
ld a, [wEnemyMoveStruct + MOVE_TYPE]
ld d, a
- ld hl, EnemyMonMoves
- ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
+ ld hl, wEnemyMonMoves
+ ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
ld c, 0
.checkmove2
dec b
@@ -239,9 +239,9 @@ AI_Types: ; 38635
AI_Offensive: ; 386a2
; Greatly discourage non-damaging moves.
- ld hl, Buffer1 - 1
- ld de, EnemyMonMoves
- ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
+ ld hl, wBuffer1 - 1
+ ld de, wEnemyMonMoves
+ ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
.checkmove
dec b
ret z
@@ -268,9 +268,9 @@ AI_Offensive: ; 386a2
AI_Smart: ; 386be
; Context-specific scoring.
- ld hl, Buffer1
- ld de, EnemyMonMoves
- ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
+ ld hl, wBuffer1
+ ld de, wEnemyMonMoves
+ ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
.checkmove
dec b
ret z
@@ -456,7 +456,7 @@ AI_Smart_LeechHit: ; 387f7
AI_Smart_LockOn: ; 3881d
- ld a, [PlayerSubStatus5]
+ ld a, [wPlayerSubStatus5]
bit SUBSTATUS_LOCK_ON, a
jr nz, .asm_38882
@@ -471,20 +471,20 @@ AI_Smart_LockOn: ; 3881d
jr nc, .asm_38877
.asm_38834
- ld a, [PlayerEvaLevel]
+ ld a, [wPlayerEvaLevel]
cp $a
jr nc, .asm_3887a
cp $8
jr nc, .asm_38875
- ld a, [EnemyAccLevel]
+ ld a, [wEnemyAccLevel]
cp $5
jr c, .asm_3887a
cp $7
jr c, .asm_38875
- ld hl, EnemyMonMoves
- ld c, EnemyMonMovesEnd - EnemyMonMoves + 1
+ ld hl, wEnemyMonMoves
+ ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
.asm_3884f
dec c
jr z, .asm_38877
@@ -531,9 +531,9 @@ AI_Smart_LockOn: ; 3881d
.asm_38882
push hl
- ld hl, Buffer1 - 1
- ld de, EnemyMonMoves
- ld c, EnemyMonMovesEnd - EnemyMonMoves + 1
+ ld hl, wBuffer1 - 1
+ ld de, wEnemyMonMoves
+ ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
.asm_3888b
inc hl
@@ -616,7 +616,7 @@ AI_Smart_DreamEater: ; 388ca
AI_Smart_EvasionUp: ; 388d4
; Dismiss this move if enemy's evasion can't raise anymore.
- ld a, [EnemyEvaLevel]
+ ld a, [wEnemyEvaLevel]
cp $d
jp nc, AIDiscourageMove
@@ -625,7 +625,7 @@ AI_Smart_EvasionUp: ; 388d4
jr nc, .asm_388f2
; ...greatly encourage this move if player is badly poisoned.
- ld a, [PlayerSubStatus5]
+ ld a, [wPlayerSubStatus5]
bit SUBSTATUS_TOXIC, a
jr nz, .asm_388ef
@@ -674,27 +674,27 @@ AI_Smart_EvasionUp: ; 388d4
; 100% chance to end up here if enemy's HP is below 25%.
; In other words, we only end up here if the move has not been encouraged or dismissed.
.asm_38911
- ld a, [PlayerSubStatus5]
+ ld a, [wPlayerSubStatus5]
bit SUBSTATUS_TOXIC, a
jr nz, .asm_38938
- ld a, [PlayerSubStatus4]
+ ld a, [wPlayerSubStatus4]
bit SUBSTATUS_LEECH_SEED, a
jr nz, .asm_38941
; Discourage this move if enemy's evasion level is higher than player's accuracy level.
- ld a, [EnemyEvaLevel]
+ ld a, [wEnemyEvaLevel]
ld b, a
- ld a, [PlayerAccLevel]
+ ld a, [wPlayerAccLevel]
cp b
jr c, .asm_38936
; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout.
- ld a, [PlayerFuryCutterCount]
+ ld a, [wPlayerFuryCutterCount]
and a
jr nz, .asm_388ef
- ld a, [PlayerSubStatus1]
+ ld a, [wPlayerSubStatus1]
bit SUBSTATUS_ROLLOUT, a
jr nz, .asm_388ef
@@ -730,12 +730,12 @@ AI_Smart_AlwaysHit: ; 38947
; 80% chance to greatly encourage this move if either...
; ...enemy's accuracy level has been lowered three or more stages
- ld a, [EnemyAccLevel]
+ ld a, [wEnemyAccLevel]
cp $5
jr c, .asm_38954
; ...or player's evasion level has been raised three or more stages.
- ld a, [PlayerEvaLevel]
+ ld a, [wPlayerEvaLevel]
cp $a
ret c
@@ -752,7 +752,7 @@ AI_Smart_AlwaysHit: ; 38947
AI_Smart_MirrorMove: ; 3895b
; If the player did not use any move last turn...
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
and a
jr nz, .asm_38968
@@ -804,7 +804,7 @@ AI_Smart_AccuracyDown: ; 38985
jr nc, .asm_389a0
; ...greatly encourage this move if player is badly poisoned.
- ld a, [PlayerSubStatus5]
+ ld a, [wPlayerSubStatus5]
bit SUBSTATUS_TOXIC, a
jr nz, .asm_3899d
@@ -849,27 +849,27 @@ AI_Smart_AccuracyDown: ; 38985
; We only end up here if the move has not been already encouraged.
.asm_389bf
- ld a, [PlayerSubStatus5]
+ ld a, [wPlayerSubStatus5]
bit SUBSTATUS_TOXIC, a
jr nz, .asm_389e6
- ld a, [PlayerSubStatus4]
+ ld a, [wPlayerSubStatus4]
bit SUBSTATUS_LEECH_SEED, a
jr nz, .asm_389ef
; Discourage this move if enemy's evasion level is higher than player's accuracy level.
- ld a, [EnemyEvaLevel]
+ ld a, [wEnemyEvaLevel]
ld b, a
- ld a, [PlayerAccLevel]
+ ld a, [wPlayerAccLevel]
cp b
jr c, .asm_389e4
; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout.
- ld a, [PlayerFuryCutterCount]
+ ld a, [wPlayerFuryCutterCount]
and a
jr nz, .asm_3899d
- ld a, [PlayerSubStatus1]
+ ld a, [wPlayerSubStatus1]
bit SUBSTATUS_ROLLOUT, a
jr nz, .asm_3899d
@@ -904,7 +904,7 @@ AI_Smart_ResetStats: ; 389f5
; 85% chance to encourage this move if any of enemy's stat levels is lower than -2.
push hl
- ld hl, EnemyAtkLevel
+ ld hl, wEnemyAtkLevel
ld c, $8
.asm_389fb
dec c
@@ -916,7 +916,7 @@ AI_Smart_ResetStats: ; 389f5
; 85% chance to encourage this move if any of player's stat levels is higher than +2.
.asm_38a05
- ld hl, PlayerAtkLevel
+ ld hl, wPlayerAtkLevel
ld c, $8
.asm_38a0a
dec c
@@ -1028,9 +1028,9 @@ AI_Smart_Ohko: ; 38a60
; Dismiss this move if player's level is higher than enemy's level.
; Else, discourage this move is player's HP is below 50%.
- ld a, [BattleMonLevel]
+ ld a, [wBattleMonLevel]
ld b, a
- ld a, [EnemyMonLevel]
+ ld a, [wEnemyMonLevel]
cp b
jp c, AIDiscourageMove
call AICheckPlayerHalfHP
@@ -1050,16 +1050,16 @@ AI_Smart_TrapTarget: ; 38a71
; 50% chance to greatly encourage this move if player is either
; badly poisoned, in love, identified, stuck in Rollout, or has a Nightmare.
- ld a, [PlayerSubStatus5]
+ ld a, [wPlayerSubStatus5]
bit SUBSTATUS_TOXIC, a
jr nz, .asm_38a91
- ld a, [PlayerSubStatus1]
+ ld a, [wPlayerSubStatus1]
and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE
jr nz, .asm_38a91
; Else, 50% chance to greatly encourage this move if it's the player's Pokemon first turn.
- ld a, [PlayerTurnsTaken]
+ ld a, [wPlayerTurnsTaken]
and a
jr z, .asm_38a91
@@ -1083,17 +1083,17 @@ AI_Smart_TrapTarget: ; 38a71
AI_Smart_RazorWind:
AI_Smart_Unused2B: ; 38a9c
- ld a, [EnemySubStatus1]
+ ld a, [wEnemySubStatus1]
bit SUBSTATUS_PERISH, a
jr z, .asm_38aaa
- ld a, [EnemyPerishCount]
+ ld a, [wEnemyPerishCount]
cp 3
jr c, .asm_38ad3
.asm_38aaa
push hl
- ld hl, PlayerUsedMoves
+ ld hl, wPlayerUsedMoves
ld c, 4
.asm_38ab0
@@ -1111,7 +1111,7 @@ AI_Smart_Unused2B: ; 38a9c
.asm_38ac1
pop hl
- ld a, [EnemySubStatus3]
+ ld a, [wEnemySubStatus3]
bit SUBSTATUS_CONFUSED, a
jr nz, .asm_38acd
@@ -1162,7 +1162,7 @@ AI_Smart_SpDefenseUp2: ; 38aed
jr nc, .asm_38b10
; Discourage this move if enemy's special defense level is higher than +3.
- ld a, [EnemySDefLevel]
+ ld a, [wEnemySDefLevel]
cp $b
jr nc, .asm_38b10
@@ -1171,10 +1171,10 @@ AI_Smart_SpDefenseUp2: ; 38aed
cp $9
ret nc
- ld a, [BattleMonType1]
+ ld a, [wBattleMonType1]
cp SPECIAL
jr nc, .asm_38b09
- ld a, [BattleMonType2]
+ ld a, [wBattleMonType2]
cp SPECIAL
ret c
@@ -1197,7 +1197,7 @@ AI_Smart_Fly: ; 38b12
; Greatly encourage this move if the player is
; flying or underground, and slower than the enemy.
- ld a, [PlayerSubStatus3]
+ ld a, [wPlayerSubStatus3]
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
ret z
@@ -1260,7 +1260,7 @@ AI_Smart_SpeedDownHit: ; 38b40
ret nz
call AICheckEnemyQuarterHP
ret nc
- ld a, [PlayerTurnsTaken]
+ ld a, [wPlayerTurnsTaken]
and a
ret nz
call AICompareSpeed
@@ -1309,7 +1309,7 @@ AI_Smart_HyperBeam: ; 38b63
AI_Smart_Rage: ; 38b7f
- ld a, [EnemySubStatus4]
+ ld a, [wEnemySubStatus4]
bit SUBSTATUS_RAGE, a
jr z, .asm_38b9b
@@ -1349,7 +1349,7 @@ AI_Smart_Rage: ; 38b7f
AI_Smart_Mimic: ; 38ba8
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
and a
jr z, .asm_38be9
@@ -1357,7 +1357,7 @@ AI_Smart_Mimic: ; 38ba8
jr nc, .asm_38bef
push hl
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
call AIGetEnemyMove
ld a, $1
@@ -1376,7 +1376,7 @@ AI_Smart_Mimic: ; 38ba8
dec [hl]
.asm_38bd4
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
push hl
ld hl, UsefulMoves
ld de, 1
@@ -1401,7 +1401,7 @@ AI_Smart_Mimic: ; 38ba8
AI_Smart_Counter: ; 38bf1
push hl
- ld hl, PlayerUsedMoves
+ ld hl, wPlayerUsedMoves
ld c, 4
ld b, 0
@@ -1434,7 +1434,7 @@ AI_Smart_Counter: ; 38bf1
cp $3
jr nc, .asm_38c30
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
and a
jr z, .asm_38c38
@@ -1469,7 +1469,7 @@ AI_Smart_Encore: ; 38c3b
call AICompareSpeed
jr nc, .asm_38c81
- ld a, [LastPlayerMove]
+ ld a, [wLastPlayerMove]
and a
jp z, AIDiscourageMove
@@ -1481,7 +1481,7 @@ AI_Smart_Encore: ; 38c3b
push hl
ld a, [wEnemyMoveStruct + MOVE_TYPE]
- ld hl, EnemyMonType1
+ ld hl, wEnemyMonType1
predef CheckTypeMatchup
pop hl
@@ -1495,7 +1495,7 @@ AI_Smart_Encore: ; 38c3b
.asm_38c68
push hl
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
ld hl, EncoreMoves
ld de, 1
call IsInArray
@@ -1523,13 +1523,13 @@ AI_Smart_PainSplit: ; 38ca4
; Discourage this move if [enemy's current HP * 2 > player's current HP].
push hl
- ld hl, EnemyMonHP
+ ld hl, wEnemyMonHP
ld b, [hl]
inc hl
ld c, [hl]
sla c
rl b
- ld hl, BattleMonHP + 1
+ ld hl, wBattleMonHP + 1
ld a, [hld]
cp c
ld a, [hl]
@@ -1546,7 +1546,7 @@ AI_Smart_SleepTalk: ; 38cba
; Greatly encourage this move if enemy is fast asleep.
; Greatly discourage this move otherwise.
- ld a, [EnemyMonStatus]
+ ld a, [wEnemyMonStatus]
and $7
cp $1
jr z, .asm_38cc7
@@ -1568,7 +1568,7 @@ AI_Smart_DefrostOpponent: ; 38ccb
; Greatly encourage this move if enemy is frozen.
; No move has EFFECT_DEFROST_OPPONENT, so this layer is unused.
- ld a, [EnemyMonStatus]
+ ld a, [wEnemyMonStatus]
and $20
ret z
dec [hl]
@@ -1579,7 +1579,7 @@ AI_Smart_DefrostOpponent: ; 38ccb
AI_Smart_Spite: ; 38cd5
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
and a
jr nz, .asm_38ce7
@@ -1595,8 +1595,8 @@ AI_Smart_Spite: ; 38cd5
push hl
ld b, a
ld c, 4
- ld hl, BattleMonMoves
- ld de, BattleMonPP
+ ld hl, wBattleMonMoves
+ ld de, wBattleMonPP
.asm_38cf1
ld a, [hli]
@@ -1659,10 +1659,10 @@ AI_Smart_HealBell: ; 38d1f
; 50% chance to greatly encourage this move if the enemy is fast asleep or frozen.
push hl
- ld a, [OTPartyCount]
+ ld a, [wOTPartyCount]
ld b, a
ld c, 0
- ld hl, OTPartyMon1HP
+ ld hl, wOTPartyMon1HP
ld de, PARTYMON_STRUCT_LENGTH
.loop
@@ -1690,7 +1690,7 @@ AI_Smart_HealBell: ; 38d1f
and a
jr z, .no_status
- ld a, [EnemyMonStatus]
+ ld a, [wEnemyMonStatus]
and a
jr z, .ok
dec [hl]
@@ -1704,7 +1704,7 @@ AI_Smart_HealBell: ; 38d1f
ret
.no_status
- ld a, [EnemyMonStatus]
+ ld a, [wEnemyMonStatus]
and a
ret nz
jp AIDiscourageMove
@@ -1717,7 +1717,7 @@ AI_Smart_PriorityHit: ; 38d5a
ret c
; Dismiss this move if the player is flying or underground.
- ld a, [PlayerSubStatus3]
+ ld a, [wPlayerSubStatus3]
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
jp nz, AIDiscourageMove
@@ -1729,13 +1729,13 @@ AI_Smart_PriorityHit: ; 38d5a
callfar BattleCommand_DamageCalc
callfar BattleCommand_Stab
pop hl
- ld a, [CurDamage + 1]
+ ld a, [wCurDamage + 1]
ld c, a
- ld a, [CurDamage]
+ ld a, [wCurDamage]
ld b, a
- ld a, [BattleMonHP + 1]
+ ld a, [wBattleMonHP + 1]
cp c
- ld a, [BattleMonHP]
+ ld a, [wBattleMonHP]
sbc b
ret nc
dec [hl]
@@ -1756,7 +1756,7 @@ AI_Smart_Thief: ; 38d93
AI_Smart_Conversion2: ; 38d98
- ld a, [LastPlayerMove]
+ ld a, [wLastPlayerMove]
and a
jr nz, .asm_38dc9
@@ -1801,7 +1801,7 @@ AI_Smart_Disable: ; 38dd1
jr nc, .asm_38df3
push hl
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
ld hl, UsefulMoves
ld de, 1
call IsInArray
@@ -1839,14 +1839,14 @@ AI_Smart_MeanLook: ; 38dfb
jp z, AIDiscourageMove
; 80% chance to greatly encourage this move if the enemy is badly poisoned (buggy).
-; Should check PlayerSubStatus5 instead.
- ld a, [EnemySubStatus5]
+; Should check wPlayerSubStatus5 instead.
+ ld a, [wEnemySubStatus5]
bit SUBSTATUS_TOXIC, a
jr nz, .asm_38e26
; 80% chance to greatly encourage this move if the player is either
; in love, identified, stuck in Rollout, or has a Nightmare.
- ld a, [PlayerSubStatus1]
+ ld a, [wPlayerSubStatus1]
and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE
jr nz, .asm_38e26
@@ -1873,14 +1873,14 @@ AI_Smart_MeanLook: ; 38dfb
AICheckLastPlayerMon: ; 38e2e
- ld a, [PartyCount]
+ ld a, [wPartyCount]
ld b, a
ld c, 0
- ld hl, PartyMon1HP
+ ld hl, wPartyMon1HP
ld de, PARTYMON_STRUCT_LENGTH
.loop
- ld a, [CurBattleMon]
+ ld a, [wCurBattleMon]
cp c
jr z, .asm_38e44
@@ -1914,7 +1914,7 @@ AI_Smart_Nightmare: ; 38e4a
AI_Smart_FlameWheel: ; 38e50
; Use this move if the enemy is frozen.
- ld a, [EnemyMonStatus]
+ ld a, [wEnemyMonStatus]
bit FRZ, a
ret z
rept 5
@@ -1925,28 +1925,28 @@ endr
AI_Smart_Curse: ; 38e5c
- ld a, [EnemyMonType1]
+ ld a, [wEnemyMonType1]
cp GHOST
jr z, .ghostcurse
- ld a, [EnemyMonType2]
+ ld a, [wEnemyMonType2]
cp GHOST
jr z, .ghostcurse
call AICheckEnemyHalfHP
jr nc, .asm_38e93
- ld a, [EnemyAtkLevel]
+ ld a, [wEnemyAtkLevel]
cp $b
jr nc, .asm_38e93
cp $9
ret nc
- ld a, [BattleMonType1]
+ ld a, [wBattleMonType1]
cp GHOST
jr z, .asm_38e92
cp SPECIAL
ret nc
- ld a, [BattleMonType2]
+ ld a, [wBattleMonType2]
cp SPECIAL
ret nc
call AI_80_20
@@ -1965,7 +1965,7 @@ AI_Smart_Curse: ; 38e5c
ret
.ghostcurse
- ld a, [PlayerSubStatus1]
+ ld a, [wPlayerSubStatus1]
bit SUBSTATUS_CURSE, a
jp nz, AIDiscourageMove
@@ -1999,7 +1999,7 @@ AI_Smart_Curse: ; 38e5c
call AICheckEnemyMaxHP
ret nc
- ld a, [PlayerTurnsTaken]
+ ld a, [wPlayerTurnsTaken]
and a
ret nz
@@ -2014,36 +2014,36 @@ AI_Smart_Curse: ; 38e5c
AI_Smart_Protect: ; 38ed2
- ld a, [EnemyProtectCount]
+ ld a, [wEnemyProtectCount]
and a
jr nz, .asm_38f13
- ld a, [PlayerSubStatus5]
+ ld a, [wPlayerSubStatus5]
bit SUBSTATUS_LOCK_ON, a
jr nz, .asm_38f14
- ld a, [PlayerFuryCutterCount]
+ ld a, [wPlayerFuryCutterCount]
cp 3
jr nc, .asm_38f0d
- ld a, [PlayerSubStatus3]
+ ld a, [wPlayerSubStatus3]
bit SUBSTATUS_CHARGED, a
jr nz, .asm_38f0d
- ld a, [PlayerSubStatus5]
+ ld a, [wPlayerSubStatus5]
bit SUBSTATUS_TOXIC, a
jr nz, .asm_38f0d
- ld a, [PlayerSubStatus4]
+ ld a, [wPlayerSubStatus4]
bit SUBSTATUS_LEECH_SEED, a
jr nz, .asm_38f0d
- ld a, [PlayerSubStatus1]
+ ld a, [wPlayerSubStatus1]
bit SUBSTATUS_CURSE, a
jr nz, .asm_38f0d
bit SUBSTATUS_ROLLOUT, a
jr z, .asm_38f14
- ld a, [PlayerRolloutCount]
+ ld a, [wPlayerRolloutCount]
cp 3
jr c, .asm_38f14
@@ -2067,17 +2067,17 @@ AI_Smart_Protect: ; 38ed2
AI_Smart_Foresight: ; 38f1d
- ld a, [EnemyAccLevel]
+ ld a, [wEnemyAccLevel]
cp $5
jr c, .asm_38f41
- ld a, [PlayerEvaLevel]
+ ld a, [wPlayerEvaLevel]
cp $a
jr nc, .asm_38f41
- ld a, [BattleMonType1]
+ ld a, [wBattleMonType1]
cp GHOST
jr z, .asm_38f41
- ld a, [BattleMonType2]
+ ld a, [wBattleMonType2]
cp GHOST
jr z, .asm_38f41
@@ -2103,7 +2103,7 @@ AI_Smart_PerishSong: ; 38f4a
pop hl
jr c, .no
- ld a, [PlayerSubStatus5]
+ ld a, [wPlayerSubStatus5]
bit SUBSTATUS_CANT_RUN, a
jr nz, .yes
@@ -2138,7 +2138,7 @@ AI_Smart_PerishSong: ; 38f4a
AI_Smart_Sandstorm: ; 38f7a
; Greatly discourage this move if the player is immune to Sandstorm damage.
- ld a, [BattleMonType1]
+ ld a, [wBattleMonType1]
push hl
ld hl, .SandstormImmuneTypes
ld de, 1
@@ -2146,7 +2146,7 @@ AI_Smart_Sandstorm: ; 38f7a
pop hl
jr c, .asm_38fa5
- ld a, [BattleMonType2]
+ ld a, [wBattleMonType2]
push hl
ld hl, .SandstormImmuneTypes
ld de, 1
@@ -2181,7 +2181,7 @@ AI_Smart_Sandstorm: ; 38f7a
AI_Smart_Endure: ; 38fac
- ld a, [EnemyProtectCount]
+ ld a, [wEnemyProtectCount]
and a
jr nz, .asm_38fd8
@@ -2204,7 +2204,7 @@ AI_Smart_Endure: ; 38fac
ret
.asm_38fcb
- ld a, [EnemySubStatus5]
+ ld a, [wEnemySubStatus5]
bit SUBSTATUS_LOCK_ON, a
ret z
@@ -2227,7 +2227,7 @@ AI_Smart_Endure: ; 38fac
AI_Smart_FuryCutter: ; 38fdb
; Encourage this move based on Fury Cutter's count.
- ld a, [EnemyFuryCutterCount]
+ ld a, [wEnemyFuryCutterCount]
and a
jr z, .end
dec [hl]
@@ -2253,15 +2253,15 @@ AI_Smart_Rollout: ; 38fef
; Rollout, Fury Cutter
; 80% chance to discourage this move if the enemy is in love, confused, or paralyzed.
- ld a, [EnemySubStatus1]
+ ld a, [wEnemySubStatus1]
bit SUBSTATUS_IN_LOVE, a
jr nz, .asm_39020
- ld a, [EnemySubStatus3]
+ ld a, [wEnemySubStatus3]
bit SUBSTATUS_CONFUSED, a
jr nz, .asm_39020
- ld a, [EnemyMonStatus]
+ ld a, [wEnemyMonStatus]
bit PAR, a
jr nz, .asm_39020
@@ -2270,10 +2270,10 @@ AI_Smart_Rollout: ; 38fef
call AICheckEnemyQuarterHP
jr nc, .asm_39020
- ld a, [EnemyAccLevel]
+ ld a, [wEnemyAccLevel]
cp 7
jr c, .asm_39020
- ld a, [PlayerEvaLevel]
+ ld a, [wPlayerEvaLevel]
cp 8
jr nc, .asm_39020
@@ -2298,7 +2298,7 @@ AI_Smart_Attract: ; 39026
; 80% chance to encourage this move during the first turn of player's Pokemon.
; 80% chance to discourage this move otherwise.
- ld a, [PlayerTurnsTaken]
+ ld a, [wPlayerTurnsTaken]
and a
jr z, .first_turn
@@ -2332,11 +2332,11 @@ AI_Smart_Magnitude:
AI_Smart_Earthquake: ; 39044
; Greatly encourage this move if the player is underground and the enemy is faster.
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
cp DIG
ret nz
- ld a, [PlayerSubStatus3]
+ ld a, [wPlayerSubStatus3]
bit SUBSTATUS_UNDERGROUND, a
jr z, .could_dig
@@ -2404,11 +2404,11 @@ AI_Smart_RapidSpin: ; 39084
and a
jr nz, .asm_39097
- ld a, [EnemySubStatus4]
+ ld a, [wEnemySubStatus4]
bit SUBSTATUS_LEECH_SEED, a
jr nz, .asm_39097
- ld a, [EnemyScreens]
+ ld a, [wEnemyScreens]
bit SCREENS_SPIKES, a
ret z
@@ -2466,13 +2466,13 @@ AI_Smart_RainDance: ; 390cb
; Greatly discourage this move if it would favour the player type-wise.
; Particularly, if the player is a Water-type.
- ld a, [BattleMonType1]
+ ld a, [wBattleMonType1]
cp WATER
jr z, AIBadWeatherType
cp FIRE
jr z, AIGoodWeatherType
- ld a, [BattleMonType2]
+ ld a, [wBattleMonType2]
cp WATER
jr z, AIBadWeatherType
cp FIRE
@@ -2490,13 +2490,13 @@ AI_Smart_SunnyDay: ; 390f3
; Greatly discourage this move if it would favour the player type-wise.
; Particularly, if the player is a Fire-type.
- ld a, [BattleMonType1]
+ ld a, [wBattleMonType1]
cp FIRE
jr z, AIBadWeatherType
cp WATER
jr z, AIGoodWeatherType
- ld a, [BattleMonType2]
+ ld a, [wBattleMonType2]
cp FIRE
jr z, AIBadWeatherType
cp WATER
@@ -2546,12 +2546,12 @@ AIGoodWeatherType: ; 39122
; ...as long as one of the following conditions meet:
; It's the first turn of the player's Pokemon.
- ld a, [PlayerTurnsTaken]
+ ld a, [wPlayerTurnsTaken]
and a
jr z, .good
; Or it's the first turn of the enemy's Pokemon.
- ld a, [EnemyTurnsTaken]
+ ld a, [wEnemyTurnsTaken]
and a
ret nz
@@ -2569,7 +2569,7 @@ AI_Smart_BellyDrum: ; 3913d
; Dismiss this move if enemy's attack is higher than +2 or if enemy's HP is below 50%.
; Else, discourage this move if enemy's HP is not full.
- ld a, [EnemyAtkLevel]
+ ld a, [wEnemyAtkLevel]
cp $a
jr nc, .asm_3914d
@@ -2591,7 +2591,7 @@ AI_Smart_BellyDrum: ; 3913d
AI_Smart_PsychUp: ; 39152
push hl
- ld hl, EnemyAtkLevel
+ ld hl, wEnemyAtkLevel
ld b, $8
ld c, 100
@@ -2607,7 +2607,7 @@ AI_Smart_PsychUp: ; 39152
; Calculate the sum of all player's stat level modifiers. Add 100 first to prevent underflow.
; Put the result in d. d will range between 58 and 142.
- ld hl, PlayerAtkLevel
+ ld hl, wPlayerAtkLevel
ld b, $8
ld d, 100
@@ -2626,12 +2626,12 @@ AI_Smart_PsychUp: ; 39152
jr nc, .asm_39188
; Else, 80% chance to encourage this move unless player's accuracy level is lower than -1...
- ld a, [PlayerAccLevel]
+ ld a, [wPlayerAccLevel]
cp $6
ret c
; ...or enemy's evasion level is higher than +0.
- ld a, [EnemyEvaLevel]
+ ld a, [wEnemyEvaLevel]
cp $8
ret nc
@@ -2650,7 +2650,7 @@ AI_Smart_PsychUp: ; 39152
AI_Smart_MirrorCoat: ; 3918b
push hl
- ld hl, PlayerUsedMoves
+ ld hl, wPlayerUsedMoves
ld c, $4
ld b, $0
@@ -2683,7 +2683,7 @@ AI_Smart_MirrorCoat: ; 3918b
cp $3
jr nc, .asm_391ca
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
and a
jr z, .asm_391d2
@@ -2717,11 +2717,11 @@ AI_Smart_Twister:
AI_Smart_Gust: ; 391d5
; Greatly encourage this move if the player is flying and the enemy is faster.
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
cp FLY
ret nz
- ld a, [PlayerSubStatus3]
+ ld a, [wPlayerSubStatus3]
bit SUBSTATUS_FLYING, a
jr z, .couldFly
@@ -2752,7 +2752,7 @@ AI_Smart_FutureSight: ; 391f3
call AICompareSpeed
ret nc
- ld a, [PlayerSubStatus3]
+ ld a, [wPlayerSubStatus3]
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
ret z
@@ -2781,7 +2781,7 @@ AI_Smart_Solarbeam: ; 3920b
; 80% chance to encourage this move when it's sunny.
; 90% chance to discourage this move when it's raining.
- ld a, [Weather]
+ ld a, [wBattleWeather]
cp WEATHER_SUN
jr z, .asm_3921e
@@ -2809,7 +2809,7 @@ AI_Smart_Solarbeam: ; 3920b
AI_Smart_Thunder: ; 39225
; 90% chance to discourage this move when it's sunny.
- ld a, [Weather]
+ ld a, [wBattleWeather]
cp WEATHER_SUN
ret nz
@@ -2826,13 +2826,13 @@ AICompareSpeed: ; 39233
; Return carry if enemy is faster than player.
push bc
- ld a, [EnemyMonSpeed + 1]
+ ld a, [wEnemyMonSpeed + 1]
ld b, a
- ld a, [BattleMonSpeed + 1]
+ ld a, [wBattleMonSpeed + 1]
cp b
- ld a, [EnemyMonSpeed]
+ ld a, [wEnemyMonSpeed]
ld b, a
- ld a, [BattleMonSpeed]
+ ld a, [wBattleMonSpeed]
sbc b
pop bc
ret
@@ -2843,8 +2843,8 @@ AICheckPlayerMaxHP: ; 39246
push hl
push de
push bc
- ld de, BattleMonHP
- ld hl, BattleMonMaxHP
+ ld de, wBattleMonHP
+ ld hl, wBattleMonMaxHP
jr AICheckMaxHP
; 39251
@@ -2853,8 +2853,8 @@ AICheckEnemyMaxHP: ; 39251
push hl
push de
push bc
- ld de, EnemyMonHP
- ld hl, EnemyMonMaxHP
+ ld de, wEnemyMonHP
+ ld hl, wEnemyMonMaxHP
; fallthrough
; 3925a
@@ -2889,7 +2889,7 @@ AICheckMaxHP: ; 3925a
AICheckPlayerHalfHP: ; 3926e
push hl
- ld hl, BattleMonHP
+ ld hl, wBattleMonHP
ld b, [hl]
inc hl
ld c, [hl]
@@ -2910,7 +2910,7 @@ AICheckEnemyHalfHP: ; 39281
push hl
push de
push bc
- ld hl, EnemyMonHP
+ ld hl, wEnemyMonHP
ld b, [hl]
inc hl
ld c, [hl]
@@ -2933,7 +2933,7 @@ AICheckEnemyQuarterHP: ; 39298
push hl
push de
push bc
- ld hl, EnemyMonHP
+ ld hl, wEnemyMonHP
ld b, [hl]
inc hl
ld c, [hl]
@@ -2956,7 +2956,7 @@ AICheckEnemyQuarterHP: ; 39298
AICheckPlayerQuarterHP: ; 392b3
push hl
- ld hl, BattleMonHP
+ ld hl, wBattleMonHP
ld b, [hl]
inc hl
ld c, [hl]
@@ -2979,8 +2979,8 @@ AIHasMoveEffect: ; 392ca
; Return carry if the enemy has move b.
push hl
- ld hl, EnemyMonMoves
- ld c, EnemyMonMovesEnd - EnemyMonMoves
+ ld hl, wEnemyMonMoves
+ ld c, wEnemyMonMovesEnd - wEnemyMonMoves
.checkmove
ld a, [hli]
@@ -3021,8 +3021,8 @@ AIHasMoveInArray: ; 392e6
jr z, .done
ld b, a
- ld c, EnemyMonMovesEnd - EnemyMonMoves + 1
- ld de, EnemyMonMoves
+ ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
+ ld de, wEnemyMonMoves
.check
dec c
@@ -3062,9 +3062,9 @@ AI_Opportunist: ; 39315
ret c
.asm_39322
- ld hl, Buffer1 - 1
- ld de, EnemyMonMoves
- ld c, EnemyMonMovesEnd - EnemyMonMoves + 1
+ ld hl, wBuffer1 - 1
+ ld de, wEnemyMonMoves
+ ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
.checkmove
inc hl
dec c
@@ -3105,13 +3105,13 @@ AI_Aggressive: ; 39369
; no move will be discouraged
; Figure out which attack does the most damage and put it in c.
- ld hl, EnemyMonMoves
+ ld hl, wEnemyMonMoves
ld bc, 0
ld de, 0
.checkmove
inc b
ld a, b
- cp EnemyMonMovesEnd - EnemyMonMoves + 1
+ cp wEnemyMonMovesEnd - wEnemyMonMoves + 1
jr z, .gotstrongestmove
ld a, [hli]
@@ -3131,15 +3131,15 @@ AI_Aggressive: ; 39369
pop hl
; Update current move if damage is highest so far
- ld a, [CurDamage + 1]
+ ld a, [wCurDamage + 1]
cp e
- ld a, [CurDamage]
+ ld a, [wCurDamage]
sbc d
jr c, .checkmove
- ld a, [CurDamage + 1]
+ ld a, [wCurDamage + 1]
ld e, a
- ld a, [CurDamage]
+ ld a, [wCurDamage]
ld d, a
ld c, b
jr .checkmove
@@ -3157,13 +3157,13 @@ AI_Aggressive: ; 39369
jr z, .done
; Discourage moves that do less damage unless they're reckless too.
- ld hl, Buffer1 - 1
- ld de, EnemyMonMoves
+ ld hl, wBuffer1 - 1
+ ld de, wEnemyMonMoves
ld b, 0
.checkmove2
inc b
ld a, b
- cp EnemyMonMovesEnd - EnemyMonMoves + 1
+ cp wEnemyMonMovesEnd - wEnemyMonMoves + 1
jr z, .done
; Ignore this move if it is the highest damaging one.
@@ -3228,13 +3228,13 @@ INCLUDE "data/battle/ai/constant_damage_effects.asm"
AI_Cautious: ; 39418
; 90% chance to discourage moves with residual effects after the first turn.
- ld a, [EnemyTurnsTaken]
+ ld a, [wEnemyTurnsTaken]
and a
ret z
- ld hl, Buffer1 - 1
- ld de, EnemyMonMoves
- ld c, EnemyMonMovesEnd - EnemyMonMoves + 1
+ ld hl, wBuffer1 - 1
+ ld de, wEnemyMonMoves
+ ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
.asm_39425
inc hl
dec c
@@ -3271,9 +3271,9 @@ INCLUDE "data/battle/ai/residual_moves.asm"
AI_Status: ; 39453
; Dismiss status moves that don't affect the player.
- ld hl, Buffer1 - 1
- ld de, EnemyMonMoves
- ld b, EnemyMonMovesEnd - EnemyMonMoves + 1
+ ld hl, wBuffer1 - 1
+ ld de, wEnemyMonMoves
+ ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1
.checkmove
dec b
ret z
@@ -3303,10 +3303,10 @@ AI_Status: ; 39453
jr .typeimmunity
.poisonimmunity
- ld a, [BattleMonType1]
+ ld a, [wBattleMonType1]
cp POISON
jr z, .immune
- ld a, [BattleMonType2]
+ ld a, [wBattleMonType2]
cp POISON
jr z, .immune
@@ -3336,9 +3336,9 @@ AI_Risky: ; 394a9
; Use any move that will KO the target.
; Risky moves will often be an exception (see below).
- ld hl, Buffer1 - 1
- ld de, EnemyMonMoves
- ld c, EnemyMonMovesEnd - EnemyMonMoves + 1
+ ld hl, wBuffer1 - 1
+ ld de, wEnemyMonMoves
+ ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1
.checkmove
inc hl
dec c
@@ -3376,13 +3376,13 @@ AI_Risky: ; 394a9
.checkko
call AIDamageCalc
- ld a, [CurDamage + 1]
+ ld a, [wCurDamage + 1]
ld e, a
- ld a, [CurDamage]
+ ld a, [wCurDamage]
ld d, a
- ld a, [BattleMonHP + 1]
+ ld a, [wBattleMonHP + 1]
cp e
- ld a, [BattleMonHP]
+ ld a, [wBattleMonHP]
sbc d
jr nc, .nextmove
diff --git a/engine/battle/ai/switch.asm b/engine/battle/ai/switch.asm
index c2f83fa1f..d397c8d32 100755
--- a/engine/battle/ai/switch.asm
+++ b/engine/battle/ai/switch.asm
@@ -7,7 +7,7 @@ CheckPlayerMoveTypeMatchups: ; 3484e
push bc
ld a, 10
ld [wEnemyAISwitchScore], a
- ld hl, PlayerUsedMoves
+ ld hl, wPlayerUsedMoves
ld a, [hl]
and a
jr z, .unknown_moves
@@ -27,7 +27,7 @@ CheckPlayerMoveTypeMatchups: ; 3484e
inc hl
call GetMoveByte
- ld hl, EnemyMonType
+ ld hl, wEnemyMonType
call CheckTypeMatchup
ld a, [wTypeMatchup]
cp 10 + 1 ; 1.0 + 0.1
@@ -70,16 +70,16 @@ CheckPlayerMoveTypeMatchups: ; 3484e
jr .done
.unknown_moves
- ld a, [BattleMonType1]
+ ld a, [wBattleMonType1]
ld b, a
- ld hl, EnemyMonType1
+ ld hl, wEnemyMonType1
call CheckTypeMatchup
ld a, [wTypeMatchup]
cp 10 + 1 ; 1.0 + 0.1
jr c, .ok
call .DecreaseScore
.ok
- ld a, [BattleMonType2]
+ ld a, [wBattleMonType2]
cp b
jr z, .ok2
call CheckTypeMatchup
@@ -99,7 +99,7 @@ CheckPlayerMoveTypeMatchups: ; 3484e
.CheckEnemyMoveMatchups: ; 348de
- ld de, EnemyMonMoves
+ ld de, wEnemyMonMoves
ld b, NUM_MOVES + 1
ld c, 0
@@ -122,7 +122,7 @@ CheckPlayerMoveTypeMatchups: ; 3484e
inc hl
call GetMoveByte
- ld hl, BattleMonType1
+ ld hl, wBattleMonType1
call CheckTypeMatchup
ld a, [wTypeMatchup]
@@ -183,11 +183,11 @@ CheckAbleToSwitch: ; 34941
call FindAliveEnemyMons
ret c
- ld a, [EnemySubStatus1]
+ ld a, [wEnemySubStatus1]
bit SUBSTATUS_PERISH, a
jr z, .no_perish
- ld a, [EnemyPerishCount]
+ ld a, [wEnemyPerishCount]
cp 1
jr nz, .no_perish
@@ -229,7 +229,7 @@ CheckAbleToSwitch: ; 34941
cp 11
ret nc
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
and a
jr z, .no_last_counter_move
@@ -296,7 +296,7 @@ CheckAbleToSwitch: ; 34941
FindAliveEnemyMons: ; 349f4
- ld a, [OTPartyCount]
+ ld a, [wOTPartyCount]
cp 2
jr c, .only_one
@@ -304,10 +304,10 @@ FindAliveEnemyMons: ; 349f4
ld e, 0
ld b, 1 << (PARTY_LENGTH - 1)
ld c, 0
- ld hl, OTPartyMon1HP
+ ld hl, wOTPartyMon1HP
.loop
- ld a, [CurOTMon]
+ ld a, [wCurOTMon]
cp e
jr z, .next
@@ -348,8 +348,8 @@ FindAliveEnemyMons: ; 349f4
FindEnemyMonsImmuneToLastCounterMove: ; 34a2a
- ld hl, OTPartyMon1
- ld a, [OTPartyCount]
+ ld hl, wOTPartyMon1
+ ld a, [wOTPartyCount]
ld b, a
ld c, 1 << (PARTY_LENGTH - 1)
ld d, 0
@@ -357,7 +357,7 @@ FindEnemyMonsImmuneToLastCounterMove: ; 34a2a
ld [wEnemyAISwitchScore], a
.loop
- ld a, [CurOTMon]
+ ld a, [wCurOTMon]
cp d
push hl
jr z, .next
@@ -375,11 +375,11 @@ FindEnemyMonsImmuneToLastCounterMove: ; 34a2a
jr z, .next
ld a, [hl]
- ld [CurSpecies], a
+ ld [wCurSpecies], a
call GetBaseData
; the player's last move is damaging...
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
dec a
ld hl, Moves + MOVE_POWER
call GetMoveAttr
@@ -389,7 +389,7 @@ FindEnemyMonsImmuneToLastCounterMove: ; 34a2a
; and the Pokemon is immune to it...
inc hl
call GetMoveByte
- ld hl, BaseType
+ ld hl, wBaseType
call CheckTypeMatchup
ld a, [wTypeMatchup]
and a
@@ -417,9 +417,9 @@ FindEnemyMonsImmuneToLastCounterMove: ; 34a2a
FindAliveEnemyMonsWithASuperEffectiveMove: ; 34a85
push bc
- ld a, [OTPartyCount]
+ ld a, [wOTPartyCount]
ld e, a
- ld hl, OTPartyMon1HP
+ ld hl, wOTPartyMon1HP
ld b, 1 << (PARTY_LENGTH - 1)
ld c, 0
.loop
@@ -434,7 +434,7 @@ FindAliveEnemyMonsWithASuperEffectiveMove: ; 34a85
.next
srl b
push bc
- ld bc, PartyMon2HP - (PartyMon1HP + 1)
+ ld bc, wPartyMon2HP - (wPartyMon1HP + 1)
add hl, bc
pop bc
dec e
@@ -449,7 +449,7 @@ FindEnemyMonsWithASuperEffectiveMove: ; 34aa7
ld a, -1
ld [wEnemyAISwitchScore], a
- ld hl, OTPartyMon1Moves
+ ld hl, wOTPartyMon1Moves
ld b, 1 << (PARTY_LENGTH - 1)
ld d, 0
ld e, 0
@@ -480,7 +480,7 @@ FindEnemyMonsWithASuperEffectiveMove: ; 34aa7
; check type matchups
inc hl
call GetMoveByte
- ld hl, BattleMonType1
+ ld hl, wBattleMonType1
call CheckTypeMatchup
; if immune or not very effective: continue
@@ -556,7 +556,7 @@ FindEnemyMonsWithASuperEffectiveMove: ; 34aa7
FindEnemyMonsThatResistPlayer: ; 34b20
push bc
- ld hl, OTPartySpecies
+ ld hl, wOTPartySpecies
ld b, 1 << (PARTY_LENGTH - 1)
ld c, 0
@@ -566,9 +566,9 @@ FindEnemyMonsThatResistPlayer: ; 34b20
jr z, .done
push hl
- ld [CurSpecies], a
+ ld [wCurSpecies], a
call GetBaseData
- ld a, [LastPlayerCounterMove]
+ ld a, [wLastPlayerCounterMove]
and a
jr z, .skip_move
@@ -583,16 +583,16 @@ FindEnemyMonsThatResistPlayer: ; 34b20
jr .check_type
.skip_move
- ld a, [BattleMonType1]
- ld hl, BaseType
+ ld a, [wBattleMonType1]
+ ld hl, wBaseType
call CheckTypeMatchup
ld a, [wTypeMatchup]
cp 10 + 1
jr nc, .dont_choose_mon
- ld a, [BattleMonType2]
+ ld a, [wBattleMonType2]
.check_type
- ld hl, BaseType
+ ld hl, wBaseType
call CheckTypeMatchup
ld a, [wTypeMatchup]
cp 10 + 1
@@ -618,10 +618,10 @@ FindEnemyMonsThatResistPlayer: ; 34b20
FindEnemyMonsWithAtLeastQuarterMaxHP: ; 34b77
push bc
- ld de, OTPartySpecies
+ ld de, wOTPartySpecies
ld b, 1 << (PARTY_LENGTH - 1)
ld c, 0
- ld hl, OTPartyMon1HP
+ ld hl, wOTPartyMon1HP
.loop
ld a, [de]