diff options
Diffstat (limited to 'battle/ai')
-rw-r--r-- | battle/ai/items.asm | 48 | ||||
-rwxr-xr-x | battle/ai/move.asm | 2 | ||||
-rwxr-xr-x | battle/ai/redundant.asm | 4 | ||||
-rw-r--r-- | battle/ai/scoring.asm | 51 |
4 files changed, 56 insertions, 49 deletions
diff --git a/battle/ai/items.asm b/battle/ai/items.asm index 325c7b555..09595077a 100644 --- a/battle/ai/items.asm +++ b/battle/ai/items.asm @@ -9,7 +9,7 @@ AI_SwitchOrTryItem: ; 38000 and a ret nz - callba CheckEnemyLockedIn + farcall CheckEnemyLockedIn ret nz ld a, [PlayerSubStatus5] @@ -27,7 +27,7 @@ AI_SwitchOrTryItem: ; 38000 ld a, [TrainerClass] dec a - ld bc, 7 + ld bc, NUM_TRAINER_ATTRIBUTES call AddNTimes .ok bit SWITCH_OFTEN_F, [hl] @@ -44,7 +44,7 @@ DontSwitch: ; 38041 ; 38045 SwitchOften: ; 38045 - callab CheckAbleToSwitch + callfar CheckAbleToSwitch ld a, [wEnemySwitchMonParam] and $f0 jp z, DontSwitch @@ -80,7 +80,7 @@ SwitchOften: ; 38045 ; 38083 SwitchRarely: ; 38083 - callab CheckAbleToSwitch + callfar CheckAbleToSwitch ld a, [wEnemySwitchMonParam] and $f0 jp z, DontSwitch @@ -115,7 +115,7 @@ SwitchRarely: ; 38083 ; 380c1 SwitchSometimes: ; 380c1 - callab CheckAbleToSwitch + callfar CheckAbleToSwitch ld a, [wEnemySwitchMonParam] and $f0 jp z, DontSwitch @@ -174,8 +174,8 @@ AI_TryItem: ; 38105 ld a, [TrainerClass] dec a - ld hl, TrainerClassAttributes + 5 - ld bc, 7 + ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH + ld bc, NUM_TRAINER_ATTRIBUTES call AddNTimes ld b, h ld c, l @@ -358,12 +358,12 @@ AI_Items: ; 39196 ld a, [bc] bit CONTEXT_USE_F, a jr nz, .CheckHalfOrQuarterHP - callab AICheckEnemyHalfHP + callfar AICheckEnemyHalfHP jp c, .DontUse ld a, [bc] bit UNKNOWN_USE_F, a jp nz, .CheckQuarterHP - callab AICheckEnemyQuarterHP + callfar AICheckEnemyQuarterHP jp nc, .UseHealItem call Random cp 1 + 50 percent @@ -371,7 +371,7 @@ AI_Items: ; 39196 jp .DontUse .CheckQuarterHP: ; 38254 (e:4254) - callab AICheckEnemyQuarterHP + callfar AICheckEnemyQuarterHP jp c, .DontUse call Random cp -1 + 20 percent @@ -379,9 +379,9 @@ AI_Items: ; 39196 jr .UseHealItem .CheckHalfOrQuarterHP: ; 38267 (e:4267) - callab AICheckEnemyHalfHP + callfar AICheckEnemyHalfHP jp c, .DontUse - callab AICheckEnemyQuarterHP + callfar AICheckEnemyQuarterHP jp nc, .UseHealItem call Random cp -1 + 20 percent @@ -416,7 +416,7 @@ AI_Items: ; 39196 ; 382ae .asm_382ae ; This appears to be unused - callab AICheckEnemyMaxHP + callfar AICheckEnemyMaxHP jr c, .dont_use push bc ld de, EnemyMonMaxHP + 1 @@ -433,7 +433,7 @@ AI_Items: ; 39196 ld a, c cp b jp c, .check_50_percent - callab AICheckEnemyQuarterHP + callfar AICheckEnemyQuarterHP jr c, .check_40_percent .check_50_percent @@ -545,7 +545,7 @@ AI_Items: ; 39196 AIUpdateHUD: ; 38387 call UpdateEnemyMonInParty - callba UpdateEnemyHUD + farcall UpdateEnemyHUD ld a, $1 ld [hBGMapMode], a ld hl, wEnemyItemState @@ -705,7 +705,7 @@ AI_Switch: ; 3846c res SUBSTATUS_RAGE, [hl] xor a ld [hBattleTurn], a - callab PursuitSwitch + callfar PursuitSwitch push af ld a, [CurOTMon] @@ -726,12 +726,12 @@ AI_Switch: ; 3846c .skiptext ld a, 1 ld [wBattleHasJustStarted], a - callab NewEnemyMonStatus - callab ResetEnemyStatLevels + callfar NewEnemyMonStatus + callfar ResetEnemyStatLevels ld hl, PlayerSubStatus1 res SUBSTATUS_IN_LOVE, [hl] - callba EnemySwitch - callba ResetBattleParticipants + farcall EnemySwitch + farcall ResetBattleParticipants xor a ld [wBattleHasJustStarted], a ld a, [wLinkMode] @@ -749,7 +749,7 @@ TextJump_EnemyWithdrew: ; 384d0 Function384d5: ; This appears to be unused call AIUsedItemSound call AI_HealStatus - ld a, X_SPEED + ld a, FULL_HEAL_RED ; X_SPEED jp PrintText_UsedItemOn_AND_AIUpdateHUD ; 384e0 @@ -761,6 +761,10 @@ AI_HealStatus: ; 384e0 xor a ld [hl], a ld [EnemyMonStatus], a + ; Bug: this should reset SUBSTATUS_NIGHTMARE too + ; Uncomment the lines below to fix + ; ld hl, EnemySubStatus1 + ; res SUBSTATUS_NIGHTMARE, [hl] ld hl, EnemySubStatus5 res SUBSTATUS_TOXIC, [hl] ret @@ -847,7 +851,7 @@ EnemyUsedXItem: push bc call PrintText_UsedItemOn pop bc - callba CheckIfStatCanBeRaised + farcall CheckIfStatCanBeRaised jp AIUpdateHUD ; 38568 diff --git a/battle/ai/move.asm b/battle/ai/move.asm index 6e5aca358..11586c0da 100755 --- a/battle/ai/move.asm +++ b/battle/ai/move.asm @@ -12,7 +12,7 @@ AIChooseMove: ; 440ce ret nz ; No use picking a move if there's no choice. - callba CheckEnemyLockedIn + farcall CheckEnemyLockedIn ret nz diff --git a/battle/ai/redundant.asm b/battle/ai/redundant.asm index e3dda8c4b..2e8f7c6df 100755 --- a/battle/ai/redundant.asm +++ b/battle/ai/redundant.asm @@ -141,7 +141,7 @@ AI_Redundant: ; 2c41a jr .NotRedundant .Attract: ; 2c4fe - callba CheckOppositeGender + farcall CheckOppositeGender jr c, .Redundant ld a, [PlayerSubStatus1] bit SUBSTATUS_IN_LOVE, a @@ -184,7 +184,7 @@ AI_Redundant: ; 2c41a .MorningSun: .Synthesis: .Moonlight: ; 2c539 - callba AICheckEnemyMaxHP + farcall AICheckEnemyMaxHP jr nc, .NotRedundant .Teleport: diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm index b52f37311..6391e3b29 100644 --- a/battle/ai/scoring.asm +++ b/battle/ai/scoring.asm @@ -1,3 +1,5 @@ +AIScoring: ; 38591 + AI_Basic: ; 38591 ; Don't do anything redundant: ; -Using status-only moves if the player can't be statused @@ -27,7 +29,7 @@ AI_Basic: ; 38591 push hl push de push bc - callba AI_Redundant + farcall AI_Redundant pop bc pop de pop hl @@ -174,7 +176,7 @@ AI_Types: ; 38635 push de ld a, 1 ld [hBattleTurn], a - callab BattleCheckTypeMatchup + callfar BattleCheckTypeMatchup pop de pop bc pop hl @@ -427,7 +429,7 @@ AI_Smart_LeechHit: ; 387f7 push hl ld a, 1 ld [hBattleTurn], a - callab BattleCheckTypeMatchup + callfar BattleCheckTypeMatchup pop hl ; 60% chance to discourage this move if not very effective. @@ -508,7 +510,7 @@ AI_Smart_LockOn: ; 3881d push hl push bc - callba BattleCheckTypeMatchup + farcall BattleCheckTypeMatchup ld a, [wd265] cp $a pop bc @@ -570,7 +572,7 @@ AI_Smart_Selfdestruct: ; 388a6 ; Unless this is the enemy's last Pokemon... push hl - callba FindAliveEnemyMons + farcall FindAliveEnemyMons pop hl jr nc, .asm_388b7 @@ -968,7 +970,7 @@ AI_Smart_ForceSwitch: ; 38a2a ; Consider player's type(s) if its moves are unknown. push hl - callab CheckPlayerMoveTypeMatchups + callfar CheckPlayerMoveTypeMatchups ld a, [wEnemyAISwitchScore] cp 10 ; neutral pop hl @@ -1366,7 +1368,7 @@ AI_Smart_Mimic: ; 38ba8 ld a, $1 ld [hBattleTurn], a - callab BattleCheckTypeMatchup + callfar BattleCheckTypeMatchup ld a, [wd265] cp $a @@ -1761,9 +1763,9 @@ AI_Smart_PriorityHit: ; 38d5a ld a, $1 ld [hBattleTurn], a push hl - callab EnemyAttackDamage - callab BattleCommand_DamageCalc - callab BattleCommand_Stab + callfar EnemyAttackDamage + callfar BattleCommand_DamageCalc + callfar BattleCommand_Stab pop hl ld a, [CurDamage + 1] ld c, a @@ -1809,7 +1811,7 @@ AI_Smart_Conversion2: ; 38d98 xor a ld [hBattleTurn], a - callab BattleCheckTypeMatchup + callfar BattleCheckTypeMatchup ld a, [wd265] cp $a @@ -1874,7 +1876,8 @@ AI_Smart_MeanLook: ; 38dfb pop hl jp z, AIDiscourageMove -; 80% chance to greatly encourage this move if the enemy is badly poisoned (weird). +; 80% chance to greatly encourage this move if the enemy is badly poisoned (buggy). +; Should check PlayerSubStatus5 instead. ld a, [EnemySubStatus5] bit SUBSTATUS_TOXIC, a jr nz, .asm_38e26 @@ -1887,7 +1890,7 @@ AI_Smart_MeanLook: ; 38dfb ; Otherwise, discourage this move unless the player only has not very effective moves against the enemy. push hl - callab CheckPlayerMoveTypeMatchups + callfar CheckPlayerMoveTypeMatchups ld a, [wEnemyAISwitchScore] cp $b ; not very effective pop hl @@ -2005,7 +2008,7 @@ AI_Smart_Curse: ; 38e5c jp nz, AIDiscourageMove push hl - callba FindAliveEnemyMons + farcall FindAliveEnemyMons pop hl jr nc, .asm_38eb0 @@ -2134,7 +2137,7 @@ AI_Smart_Foresight: ; 38f1d AI_Smart_PerishSong: ; 38f4a push hl - callab FindAliveEnemyMons + callfar FindAliveEnemyMons pop hl jr c, .no @@ -2143,7 +2146,7 @@ AI_Smart_PerishSong: ; 38f4a jr nz, .yes push hl - callab CheckPlayerMoveTypeMatchups + callfar CheckPlayerMoveTypeMatchups ld a, [wEnemyAISwitchScore] cp 10 ; 1.0 pop hl @@ -2401,7 +2404,7 @@ AI_Smart_BatonPass: ; 39062 ; Consider player's type(s) if its moves are unknown. push hl - callab CheckPlayerMoveTypeMatchups + callfar CheckPlayerMoveTypeMatchups ld a, [wEnemyAISwitchScore] cp 10 ; neutral pop hl @@ -2463,8 +2466,8 @@ AI_Smart_HiddenPower: ; 3909e ld [hBattleTurn], a ; Calculate Hidden Power's type and base power based on enemy's DVs. - callab HiddenPowerDamage - callab BattleCheckTypeMatchup + callfar HiddenPowerDamage + callfar BattleCheckTypeMatchup pop hl ; Discourage Hidden Power if not very effective. @@ -3333,13 +3336,13 @@ AIDamageCalc: ; 393e7 ld hl, .ConstantDamageEffects call IsInArray jr nc, .asm_39400 - callab BattleCommand_ConstantDamage + callfar BattleCommand_ConstantDamage ret .asm_39400 - callab EnemyAttackDamage - callab BattleCommand_DamageCalc - callab BattleCommand_Stab + callfar EnemyAttackDamage + callfar BattleCommand_DamageCalc + callfar BattleCommand_Stab ret .ConstantDamageEffects: @@ -3456,7 +3459,7 @@ AI_Status: ; 39453 push de ld a, 1 ld [hBattleTurn], a - callab BattleCheckTypeMatchup + callfar BattleCheckTypeMatchup pop de pop bc pop hl |