summaryrefslogtreecommitdiff
path: root/engine/battle/ai/items.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle/ai/items.asm')
-rw-r--r--engine/battle/ai/items.asm108
1 files changed, 54 insertions, 54 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