Labeling of AI item and wild encounter functions

This commit is contained in:
PikalaxALT 2015-10-07 21:27:32 -04:00
parent edf42a54d5
commit 96b0e448c4
10 changed files with 124 additions and 123 deletions

View File

@ -297,7 +297,7 @@ AI_Items: ; 39196
.FullHeal: ; 381be
call .Status
jp c, .DontUse
call Function383a3
call EnemyUsedFullHeal
jp .Use
; 381ca
@ -308,7 +308,7 @@ AI_Items: ; 39196
ld a, [bc]
bit CONTEXT_USE_F, a
jr nz, .asm_381e7
jr nz, .StatusCheckContext
ld a, [bc]
bit ALWAYS_USE_F, a
jp nz, .Use
@ -317,17 +317,17 @@ AI_Items: ; 39196
jp c, .Use
jp .DontUse
.asm_381e7
.StatusCheckContext
ld a, [EnemySubStatus5]
bit SUBSTATUS_TOXIC, a
jr z, .asm_381fd
jr z, .FailToxicCheck
ld a, [EnemyToxicCount]
cp 4
jr c, .asm_381fd
jr c, .FailToxicCheck
call Random
cp $80
jp c, .Use
.asm_381fd
.FailToxicCheck
ld a, [EnemyMonStatus]
and 1 << FRZ | SLP
jp z, .DontUse
@ -336,58 +336,58 @@ AI_Items: ; 39196
.FullRestore: ; 38208
call .HealItem
jp nc, .asm_3821a
jp nc, .UseFullRestore
ld a, [bc]
bit CONTEXT_USE_F, a
jp z, .DontUse
call .Status
jp c, .DontUse
.asm_3821a
call Function383b5
.UseFullRestore
call EnemyUsedFullRestore
jp .Use
; 38220
.MaxPotion: ; 38220
call .HealItem
jp c, .DontUse
call Function383ae
call EnemyUsedMaxPotion
jp .Use
.HealItem: ; 3822c (e:422c)
ld a, [bc]
bit CONTEXT_USE_F, a
jr nz, .asm_38267
jr nz, .CheckHalfOrQuarterHP
callab AICheckEnemyHalfHP
jp c, .DontUse
ld a, [bc]
bit UNKNOWN_USE_F, a
jp nz, .asm_38254
jp nz, .CheckQuarterHP
callab AICheckEnemyQuarterHP
jp nc, .asm_38281
jp nc, .UseHealItem
call Random
cp $80
jp c, .asm_38281
jp c, .UseHealItem
jp .DontUse
.asm_38254: ; 38254 (e:4254)
.CheckQuarterHP: ; 38254 (e:4254)
callab AICheckEnemyQuarterHP
jp c, .DontUse
call Random
cp 50
cp $32
jp c, .DontUse
jr .asm_38281
jr .UseHealItem
.asm_38267: ; 38267 (e:4267)
.CheckHalfOrQuarterHP: ; 38267 (e:4267)
callab AICheckEnemyHalfHP
jp c, .DontUse
callab AICheckEnemyQuarterHP
jp nc, .asm_38281
jp nc, .UseHealItem
call Random
cp 50
cp $32
jp nc, .DontUse
.asm_38281: ; 38281 (e:4281)
.UseHealItem: ; 38281 (e:4281)
jp .Use
; 38284
@ -395,7 +395,7 @@ AI_Items: ; 39196
call .HealItem
jp c, .DontUse
ld b, 200
call Function383f4
call EnemyUsedHyperPotion
jp .Use
; 38292 (e:4292)
@ -403,7 +403,7 @@ AI_Items: ; 39196
call .HealItem
jp c, .DontUse
ld b, 50
call Function383ee
call EnemyUsedSuperPotion
jp .Use
; 382a0
@ -411,11 +411,11 @@ AI_Items: ; 39196
call .HealItem
jp c, .DontUse
ld b, 20
call Function383e8
call EnemyUsedPotion
jp .Use
; 382ae
.asm_382ae: ; 382ae
.asm_382ae: ; This appears to be unused
callab AICheckEnemyMaxHP
jr c, .asm_382e4
push bc
@ -454,7 +454,7 @@ AI_Items: ; 39196
bit UNKNOWN_USE_F, a
jp z, .DontUse
call Random
cp 100
cp $64
jp c, .Use
jp .DontUse
; 382f9
@ -462,56 +462,56 @@ AI_Items: ; 39196
.XAccuracy: ; 382f9
call .XItem
jp c, .DontUse
call Function384f7
call EnemyUsedXAccuracy
jp .Use
; 38305
.GuardSpec: ; 38305
call .XItem
jp c, .DontUse
call Function38504
call EnemyUsedGuardSpec
jp .Use
; 38311
.DireHit: ; 38311
call .XItem
jp c, .DontUse
call Function38511
call EnemyUsedDireHit
jp .Use
; 3831d (e:431d)
.XAttack: ; 3831d
call .XItem
jp c, .DontUse
call Function38541
call EnemyUsedXAttack
jp .Use
; 38329
.XDefend: ; 38329
call .XItem
jp c, .DontUse
call Function38547
call EnemyUsedXDefend
jp .Use
; 38335
.XSpeed: ; 38335
call .XItem
jp c, .DontUse
call Function3854d
call EnemyUsedXSpeed
jp .Use
; 38341
.XSpecial: ; 38341
call .XItem
jp c, .DontUse
call Function38553
call EnemyUsedXSpecial
jp .Use
; 3834d
.XItem: ; 3834d (e:434d)
ld a, [EnemyTurnsTaken]
and a
jr nz, .asm_38372
jr nz, .notfirstturnout
ld a, [bc]
bit ALWAYS_USE_F, a
jp nz, .Use
@ -525,12 +525,12 @@ AI_Items: ; 39196
cp $80
jp c, .DontUse
jp .Use
.asm_38372
.notfirstturnout
ld a, [bc]
bit ALWAYS_USE_F, a
jp z, .DontUse
call Random
cp 50
cp $32
jp nc, .DontUse
jp .Use
@ -563,18 +563,18 @@ AIUsedItemSound: ; 3839a
; 383a3
Function383a3: ; 383a3 (e:43a3)
EnemyUsedFullHeal: ; 383a3 (e:43a3)
call AIUsedItemSound
call AI_HealStatus
ld a, FULL_HEAL
jp PrintText_UsedItemOn_AND_AIUpdateHUD
Function383ae: ; 383ae (e:43ae)
EnemyUsedMaxPotion: ; 383ae (e:43ae)
ld a, MAX_POTION
ld [wd1f1], a
jr asm_383c6
jr FullRestoreContinue
Function383b5: ; 383b5 (e:43b5)
EnemyUsedFullRestore: ; 383b5 (e:43b5)
call AI_HealStatus
ld a, FULL_RESTORE
ld [wd1f1], a
@ -583,7 +583,7 @@ Function383b5: ; 383b5 (e:43b5)
xor a
ld [EnemyConfuseCount], a
asm_383c6: ; 383c6
FullRestoreContinue: ; 383c6
ld de, wd1ec
ld hl, EnemyMonHP + 1
ld a, [hld]
@ -602,24 +602,24 @@ asm_383c6: ; 383c6
ld [de], a
ld [Buffer2], a
ld [EnemyMonHP], a
jr Function38436
jr EnemyPotionFinish
; 383e8 (e:43e8)
Function383e8: ; 383e8
EnemyUsedPotion: ; 383e8
ld a, POTION
ld b, 20
jr Function383f8
jr EnemyPotionContinue
Function383ee: ; 383ee
EnemyUsedSuperPotion: ; 383ee
ld a, SUPER_POTION
ld b, 50
jr Function383f8
jr EnemyPotionContinue
Function383f4: ; 383f4 (e:43f4)
EnemyUsedHyperPotion: ; 383f4 (e:43f4)
ld a, HYPER_POTION
ld b, 200
Function383f8: ; 383f8
EnemyPotionContinue: ; 383f8
ld [wd1f1], a
ld hl, EnemyMonHP + 1
ld a, [hl]
@ -630,11 +630,11 @@ Function383f8: ; 383f8
ld a, [hl]
ld [wd1ec + 1], a
ld [wd1ee + 1], a
jr nc, .asm_38415
jr nc, .ok
inc a
ld [hl], a
ld [wd1ee + 1], a
.asm_38415
.ok
inc hl
ld a, [hld]
ld b, a
@ -648,7 +648,7 @@ Function383f8: ; 383f8
ld a, [de]
ld [Buffer2], a
sbc b
jr nc, .asm_38436
jr nc, EnemyPotionFinish
inc de
ld a, [de]
dec de
@ -657,9 +657,8 @@ Function383f8: ; 383f8
ld a, [de]
ld [hl], a
ld [wd1ef], a
.asm_38436
Function38436: ; 38436
EnemyPotionFinish: ; 38436
call PrintText_UsedItemOn
hlcoord 2, 2
xor a
@ -670,24 +669,26 @@ Function38436: ; 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 c, a
ld hl, OTPartyMon1HP
ld d, 0
.asm_38454
.SwitchLoop
ld a, [hli]
ld b, a
ld a, [hld]
or b
jr z, .asm_3845b
jr z, .fainted
inc d
.asm_3845b
.fainted
push bc
ld bc, PartyMon2 - PartyMon1
add hl, bc
pop bc
dec c
jr nz, .asm_38454
jr nz, .SwitchLoop
ld a, d
cp 2
@ -716,10 +717,10 @@ AI_Switch: ; 3846c
ld bc, $0004
call CopyBytes
pop af
jr c, .asm_384a3
jr c, .skiptext
ld hl, TextJump_EnemyWithdrew
call PrintText
.asm_384a3
.skiptext
ld a, $1
ld [wd264], a
callab NewEnemyMonStatus
@ -742,10 +743,10 @@ TextJump_EnemyWithdrew: ; 384d0
db "@"
; 384d5
Function384d5: ; 384d5
Function384d5: ; This appears to be unused
call AIUsedItemSound
call AI_HealStatus
ld a, FULL_HEAL_RED
ld a, X_SPEED
jp PrintText_UsedItemOn_AND_AIUpdateHUD
; 384e0
@ -762,7 +763,7 @@ AI_HealStatus: ; 384e0
ret
; 384f7
Function384f7: ; 384f7
EnemyUsedXAccuracy: ; 384f7
call AIUsedItemSound
ld hl, EnemySubStatus4
set SUBSTATUS_X_ACCURACY, [hl]
@ -770,7 +771,7 @@ Function384f7: ; 384f7
jp PrintText_UsedItemOn_AND_AIUpdateHUD
; 38504
Function38504: ; 38504
EnemyUsedGuardSpec: ; 38504
call AIUsedItemSound
ld hl, EnemySubStatus4
set SUBSTATUS_MIST, [hl]
@ -778,7 +779,7 @@ Function38504: ; 38504
jp PrintText_UsedItemOn_AND_AIUpdateHUD
; 38511
Function38511: ; 38511
EnemyUsedDireHit: ; 38511
call AIUsedItemSound
ld hl, EnemySubStatus4
set SUBSTATUS_FOCUS_ENERGY, [hl]
@ -786,14 +787,14 @@ Function38511: ; 38511
jp PrintText_UsedItemOn_AND_AIUpdateHUD
; 3851e
Function3851e: ; 3851e
Function3851e: ; This appears to be unused
ld [hDivisor], a
ld hl, EnemyMonMaxHP
ld a, [hli]
ld [hDividend], a
ld a, [hl]
ld [hDividend + 1], a
ld b, $2
ld b, 2
call Divide
ld a, [hQuotient + 2]
ld c, a
@ -812,25 +813,25 @@ Function3851e: ; 3851e
ret
; 38541
Function38541: ; 38541
EnemyUsedXAttack: ; 38541
ld b, ATTACK
ld a, X_ATTACK
jr Function38557
jr EnemyUsedXItem
; 38547
Function38547: ; 38547
EnemyUsedXDefend: ; 38547
ld b, DEFENSE
ld a, X_DEFEND
jr Function38557
jr EnemyUsedXItem
; 3854d
Function3854d: ; 3854d
EnemyUsedXSpeed: ; 3854d
ld b, SPEED
ld a, X_SPEED
jr Function38557
jr EnemyUsedXItem
; 38553
Function38553: ; 38553
EnemyUsedXSpecial: ; 38553
ld b, SP_ATTACK
ld a, X_SPECIAL
@ -838,12 +839,12 @@ Function38553: ; 38553
; Parameter
; a = ITEM_CONSTANT
; b = BATTLE_CONSTANT (ATTACK, DEFENSE, SPEED, SP_ATTACK, SP_DEFENSE, ACCURACY, EVASION)
Function38557:
EnemyUsedXItem:
ld [wd1f1], a
push bc
call PrintText_UsedItemOn
pop bc
callba Function361ef
callba CheckIfStatCanBeRaised
jp AIUpdateHUD
; 38568

View File

@ -4821,7 +4821,7 @@ DrawPlayerHUD: ; 3df58
; HP bar
hlcoord 10, 9
ld b, 1
xor a
xor a ; PARTYMON
ld [MonType], a
predef DrawPlayerHP
@ -4903,7 +4903,7 @@ PrintPlayerHUD: ; 3dfbf
pop hl
dec hl
ld a, $3
ld a, BREEDMON
ld [MonType], a
callab GetGender
ld a, " "
@ -4981,7 +4981,7 @@ DrawEnemyHUD: ; 3e043
ld a, [hl]
ld [de], a
ld a, $3
ld a, BREEDMON
ld [MonType], a
callab GetGender
ld a, " "
@ -5358,7 +5358,7 @@ Function3e308: ; 3e308
call EnableLCD
call ClearSprites
call LowVolume
xor a
xor a ; PARTYMON
ld [MonType], a
callba Function4dc7b
call MaxVolume
@ -7535,7 +7535,7 @@ endr
ld [hld], a
.asm_3ef74
xor a
xor a ; PARTYMON
ld [MonType], a
predef Function5084a
callab Function50e1b
@ -7647,7 +7647,7 @@ endr
call Function309d
.asm_3f057
xor a
xor a ; PARTYMON
ld [MonType], a
predef Function5084a
hlcoord 9, 0
@ -7661,7 +7661,7 @@ endr
call DelayFrames
call Functiona80
call Function30b4
xor a
xor a ; PARTYMON
ld [MonType], a
ld a, [CurSpecies]
ld [wd265], a
@ -7802,7 +7802,7 @@ Function3f136: ; 3f136
push af
xor a
ld [DefaultFlypoint], a
xor a
xor a ; PARTYMON
ld [MonType], a
predef Function5084a
ld a, [TempMonLevel]

View File

@ -1036,13 +1036,13 @@ BattleCommand04: ; 34555
ld a, [hBattleTurn]
and a
jr z, .asm_34570
jr z, .proceed
ld hl, EnemyMonPP
ld de, EnemySubStatus3
ld bc, EnemyTurnsTaken
.asm_34570
.proceed
; If we've gotten this far, this counts as a turn.
ld a, [bc]
@ -6100,7 +6100,7 @@ BattleCommand7d: ; 361e0
jr BattleCommand1c
BattleCommand1c: ; 361e4
; statup
call Function361ef
call CheckIfStatCanBeRaised
ld a, [FailedMessage]
and a
ret nz
@ -6108,7 +6108,7 @@ BattleCommand1c: ; 361e4
; 361ef
Function361ef: ; 361ef
CheckIfStatCanBeRaised: ; 361ef
ld a, b
ld [LoweredStat], a
ld hl, PlayerStatLevels

View File

@ -133,7 +133,7 @@ EnterMap: ; 9673e
xor a
ld [wd453], a
ld [wd454], a
call Function968d1
call SetUpFiveStepWildEncounterCooldown
callba RunMapSetupScript
call ClearAllScriptFlags3
@ -382,9 +382,9 @@ CheckTileEvent: ; 96874
call CheckBit4_ScriptFlags3
jr z, .ok
call RockSmashEncounter
call RandomEncounter
ret c
jr .ok
jr .ok ; pointless
.ok
xor a
@ -419,8 +419,8 @@ CheckTileEvent: ; 96874
; 968c7
Function968c7:: ; 968c7
ld hl, wd452
CheckWildEncounterCooldown:: ; 968c7
ld hl, wWildEncounterCooldown
ld a, [hl]
and a
ret z
@ -430,9 +430,9 @@ Function968c7:: ; 968c7
ret
; 968d1
Function968d1: ; 968d1
SetUpFiveStepWildEncounterCooldown: ; 968d1
ld a, 5
ld [wd452], a
ld [wWildEncounterCooldown], a
ret
; 968d7
@ -441,11 +441,11 @@ Function968d7: ; 968d7
; 968d8
Function968d8: ; 968d8
ld a, [wd452]
ld a, [wWildEncounterCooldown]
cp 2
ret nc
ld a, 2
ld [wd452], a
ld [wWildEncounterCooldown], a
ret
; 968e4

View File

@ -95,10 +95,10 @@ CheckFacingTileEvent:: ; 97c5f
; 97cc0
RockSmashEncounter:: ; 97cc0
; Rock Smash encounter
RandomEncounter:: ; 97cc0
; Random encounter
call Function968c7
call CheckWildEncounterCooldown
jr c, .nope
call CanUseSweetScent
jr nc, .nope
@ -120,8 +120,8 @@ RockSmashEncounter:: ; 97cc0
ret
.ok
ld a, BANK(RockSmashBattleScript)
ld hl, RockSmashBattleScript
ld a, BANK(WildBattleScript)
ld hl, WildBattleScript
jr .done
.ok_bug_contest
@ -135,7 +135,7 @@ RockSmashEncounter:: ; 97cc0
ret
; 97cf9
RockSmashBattleScript: ; 97cf9
WildBattleScript: ; 97cf9
battlecheck
startbattle
returnafterbattle

View File

@ -2656,7 +2656,7 @@ Script_giveegg: ; 0x97968
; level (DecimalParam)
; if no room in the party, return 0 in ScriptVar; else, return 2
xor a
xor a ; PARTYMON
ld [ScriptVar], a
ld [MonType], a
call GetScriptByte

View File

@ -26,7 +26,7 @@ NameRater: ; fb6ed
ld hl, NameRaterWhichNameText
call PrintText
; Load the new nickname into StringBuffer2
xor a
xor a ; PARTYMON
ld [MonType], a
ld a, [CurPartySpecies]
ld [wd265], a

View File

@ -558,7 +558,7 @@ endr
cp PARTY_LENGTH
jr z, .asm_eb3c
xor a
xor a ; PARTYMON
ld [MonType], a
call ClearSprites
@ -600,7 +600,7 @@ endr
ld d, h
ld e, l
push de
xor a
xor a ; PARTYMON
ld [MonType], a
ld b, 0
callba Function116c1
@ -980,7 +980,7 @@ LoveBallMultiplier:
push bc
ld a, [TempBattleMonSpecies]
ld [CurPartySpecies], a
xor a
xor a ; PARTYMON
ld [MonType], a
ld a, [CurBattleMon]
ld [CurPartyMon], a
@ -1425,7 +1425,7 @@ RareCandy: ; ef14
ld a, $f8
call Functionf24a
xor a
xor a ; PARTYMON
ld [MonType], a
predef Function5084a
@ -1440,7 +1440,7 @@ RareCandy: ; ef14
call Functiona80
xor a
xor a ; PARTYMON
ld [MonType], a
ld a, [CurPartySpecies]
ld [wd265], a
@ -2340,7 +2340,7 @@ endr
ld [hBattleTurn], a
ld [AttackMissed], a
ld [EffectFailed], a
callba Function361ef
callba CheckIfStatCanBeRaised
call WaitSFX
callba BattleCommand8c
@ -2703,7 +2703,7 @@ Functionf6e0: ; f6e0
; f6e8
Functionf6e8: ; f6e8
xor a
xor a ; PARTYMON
ld [MonType], a
call Functionf8ec
ld hl, PartyMon1PP
@ -3188,7 +3188,7 @@ Functionf8b9: ; f8b9
ld a, PartyMon1Moves - PartyMon1
call GetPartyParamLocation
pop de
xor a
xor a ; PARTYMON
ld [wcfa9], a
ld [MonType], a
ld c, NUM_MOVES
@ -3229,27 +3229,27 @@ Functionf8ec: ; f8ec
ld hl, PartyMon1Moves
ld bc, PartyMon2 - PartyMon1
jr z, .asm_f91a
jr z, .asm_f91a ; PARTYMON
ld hl, OTPartyMon1Moves
dec a
jr z, .asm_f91a
jr z, .asm_f91a ; OTPARTYMON
ld hl, TempMonMoves
dec a
jr z, .asm_f915
jr z, .asm_f915 ; BOXMON
ld hl, TempMonMoves
ld hl, TempMonMoves ; Wasted cycles
dec a
jr z, .asm_f915
jr z, .asm_f915 ; BREEDMON
ld hl, BattleMonMoves
ld hl, BattleMonMoves ; WILDMON
.asm_f915
.asm_f915 ; BOXMON, BREEDMON, WILDMON
call Functionf969
jr .asm_f91d
.asm_f91a
.asm_f91a ; PARTYMON, OTPARTYMON
call Functionf963
.asm_f91d

View File

@ -7920,7 +7920,7 @@ TryAddMonToParty: ; d88c
ld de, PartyCount
ld a, [MonType]
and $f
jr z, .getpartylocation
jr z, .getpartylocation ; PARTYMON
ld de, OTPartyCount
.getpartylocation
@ -9468,7 +9468,7 @@ endr
GivePoke:: ; e277
push de
push bc
xor a
xor a ; PARTYMON
ld [MonType], a
call TryAddMonToParty
jr nc, .failed

View File

@ -1914,7 +1914,7 @@ wd44e:: ds 1
wd44f:: ds 1
wd450:: ds 1
wd451:: ds 1
wd452:: ds 1
wWildEncounterCooldown:: ds 1
wd453:: ds 1
wd454:: ds 1
ds 4