diff options
Diffstat (limited to 'engine/battle/ai')
-rw-r--r-- | engine/battle/ai/items.asm | 9 | ||||
-rw-r--r-- | engine/battle/ai/move.asm | 3 | ||||
-rw-r--r-- | engine/battle/ai/scoring.asm | 115 | ||||
-rw-r--r-- | engine/battle/ai/switch.asm | 9 |
4 files changed, 2 insertions, 134 deletions
diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm index 14817f414..29bc23b20 100644 --- a/engine/battle/ai/items.asm +++ b/engine/battle/ai/items.asm @@ -145,13 +145,11 @@ SwitchSometimes: ld [wEnemySwitchMonIndex], a jp AI_TrySwitch - CheckSubstatusCantRun: ld a, [wEnemySubStatus5] bit SUBSTATUS_CANT_RUN, a ret - AI_TryItem: ; items are not allowed in the BattleTower ld a, [wInBattleTowerBattle] @@ -238,7 +236,6 @@ AI_TryItem: scf ret - .IsHighestLevel: ld a, [wOTPartyCount] ld d, a @@ -270,7 +267,6 @@ AI_TryItem: scf ret - AI_Items: dbw FULL_RESTORE, .FullRestore dbw MAX_POTION, .MaxPotion @@ -520,7 +516,6 @@ AI_Items: and a ret - AIUpdateHUD: call UpdateEnemyMonInParty farcall UpdateEnemyHUD @@ -538,7 +533,6 @@ AIUsedItemSound: pop de ret - EnemyUsedFullHeal: call AIUsedItemSound call AI_HealStatus @@ -642,7 +636,6 @@ EnemyPotionFinish: predef AnimateHPBar jp AIUpdateHUD - AI_TrySwitch: ; Determine whether the AI can switch based on how many Pokemon are still alive. ; If it can switch, it will. @@ -805,7 +798,6 @@ EnemyUsedXSpecial: ld b, SP_ATTACK ld a, X_SPECIAL - ; Parameter ; a = ITEM_CONSTANT ; b = BATTLE_CONSTANT (ATTACK, DEFENSE, SPEED, SP_ATTACK, SP_DEFENSE, ACCURACY, EVASION) @@ -817,7 +809,6 @@ EnemyUsedXItem: farcall CheckIfStatCanBeRaised jp AIUpdateHUD - ; Parameter ; a = ITEM_CONSTANT PrintText_UsedItemOn_AND_AIUpdateHUD: diff --git a/engine/battle/ai/move.asm b/engine/battle/ai/move.asm index 488ea76ca..df0053141 100644 --- a/engine/battle/ai/move.asm +++ b/engine/battle/ai/move.asm @@ -15,7 +15,6 @@ AIChooseMove: farcall CheckEnemyLockedIn ret nz - ; The default score is 20. Unusable moves are given a score of 80. ld a, 20 ld hl, wBuffer1 @@ -61,7 +60,6 @@ AIChooseMove: ld [hl], 80 jr .CheckMovePP - ; Apply AI scoring layers depending on the trainer class. .ApplyLayers: ld hl, TrainerClassAttributes + TRNATTR_AI_MOVE_WEIGHTS @@ -199,7 +197,6 @@ AIChooseMove: ld [wCurEnemyMoveNum], a ret - AIScoringPointers: ; entries correspond to AI_* constants dw AI_Basic diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm index 128e9841b..6928a3a83 100644 --- a/engine/battle/ai/scoring.asm +++ b/engine/battle/ai/scoring.asm @@ -65,7 +65,6 @@ AI_Basic: INCLUDE "data/battle/ai/status_only_effects.asm" - AI_Setup: ; Use stat-modifying moves on turn 1. @@ -141,7 +140,6 @@ AI_Setup: jr .checkmove - AI_Types: ; Dismiss any move that the player is immune to. ; Encourage super-effective moves. @@ -232,7 +230,6 @@ AI_Types: jr .checkmove - AI_Offensive: ; Greatly discourage non-damaging moves. @@ -260,7 +257,6 @@ AI_Offensive: jr .checkmove - AI_Smart: ; Context-specific scoring. @@ -392,7 +388,6 @@ AI_Smart: dbw EFFECT_FLY, AI_Smart_Fly db -1 ; end - AI_Smart_Sleep: ; Greatly encourage sleep inducing moves if the enemy has either Dream Eater or Nightmare. ; 50% chance to greatly encourage sleep inducing moves otherwise. @@ -412,7 +407,6 @@ AI_Smart_Sleep: dec [hl] ret - AI_Smart_LeechHit: push hl ld a, 1 @@ -447,7 +441,6 @@ AI_Smart_LeechHit: inc [hl] ret - AI_Smart_LockOn: ld a, [wPlayerSubStatus5] bit SUBSTATUS_LOCK_ON, a @@ -552,7 +545,6 @@ AI_Smart_LockOn: pop hl jp AIDiscourageMove - AI_Smart_Selfdestruct: ; Selfdestruct, Explosion @@ -589,7 +581,6 @@ AI_Smart_Selfdestruct: inc [hl] ret - AI_Smart_DreamEater: ; 90% chance to greatly encourage this move. ; The AI_Basic layer will make sure that @@ -602,9 +593,7 @@ AI_Smart_DreamEater: dec [hl] ret - AI_Smart_EvasionUp: - ; Dismiss this move if enemy's evasion can't raise anymore. ld a, [wEnemyEvaLevel] cp $d @@ -688,7 +677,6 @@ AI_Smart_EvasionUp: bit SUBSTATUS_ROLLOUT, a jr nz, .asm_388ef - .asm_38936 inc [hl] ret @@ -714,7 +702,6 @@ AI_Smart_EvasionUp: dec [hl] ret - AI_Smart_AlwaysHit: ; 80% chance to greatly encourage this move if either... @@ -736,9 +723,7 @@ AI_Smart_AlwaysHit: dec [hl] ret - AI_Smart_MirrorMove: - ; If the player did not use any move last turn... ld a, [wLastPlayerCounterMove] and a @@ -779,9 +764,7 @@ AI_Smart_MirrorMove: dec [hl] ret - AI_Smart_AccuracyDown: - ; If player's HP is full... call AICheckPlayerMaxHP jr nc, .asm_389a0 @@ -885,9 +868,7 @@ AI_Smart_AccuracyDown: dec [hl] ret - AI_Smart_ResetStats: - ; 85% chance to encourage this move if any of enemy's stat levels is lower than -2. push hl ld hl, wEnemyAtkLevel @@ -927,7 +908,6 @@ AI_Smart_ResetStats: inc [hl] ret - AI_Smart_Bide: ; 90% chance to discourage this move unless enemy's HP is full. @@ -939,7 +919,6 @@ AI_Smart_Bide: inc [hl] ret - AI_Smart_ForceSwitch: ; Whirlwind, Roar. @@ -956,7 +935,6 @@ AI_Smart_ForceSwitch: inc [hl] ret - AI_Smart_Heal: AI_Smart_MorningSun: AI_Smart_Synthesis: @@ -980,7 +958,6 @@ AI_Smart_Moonlight: dec [hl] ret - AI_Smart_Toxic: AI_Smart_LeechSeed: ; Discourage this move if player's HP is below 50%. @@ -990,7 +967,6 @@ AI_Smart_LeechSeed: inc [hl] ret - AI_Smart_LightScreen: AI_Smart_Reflect: ; Over 90% chance to discourage this move unless enemy's HP is full. @@ -1003,7 +979,6 @@ AI_Smart_Reflect: inc [hl] ret - AI_Smart_Ohko: ; Dismiss this move if player's level is higher than enemy's level. ; Else, discourage this move is player's HP is below 50%. @@ -1018,7 +993,6 @@ AI_Smart_Ohko: inc [hl] ret - AI_Smart_TrapTarget: ; Bind, Wrap, Fire Spin, Clamp @@ -1058,7 +1032,6 @@ AI_Smart_TrapTarget: dec [hl] ret - AI_Smart_RazorWind: AI_Smart_Unused2B: ld a, [wEnemySubStatus1] @@ -1112,9 +1085,7 @@ AI_Smart_Unused2B: ld [hl], a ret - AI_Smart_Confuse: - ; 90% chance to discourage this move if player's HP is between 25% and 50%. call AICheckPlayerHalfHP ret c @@ -1130,9 +1101,7 @@ AI_Smart_Confuse: inc [hl] ret - AI_Smart_SpDefenseUp2: - ; Discourage this move if enemy's HP is lower than 50%. call AICheckEnemyHalfHP jr nc, .asm_38b10 @@ -1165,7 +1134,6 @@ AI_Smart_SpDefenseUp2: inc [hl] ret - AI_Smart_Fly: ; Fly, Dig @@ -1184,7 +1152,6 @@ AI_Smart_Fly: dec [hl] ret - AI_Smart_SuperFang: ; Discourage this move if player's HP is below 25%. @@ -1193,9 +1160,7 @@ AI_Smart_SuperFang: inc [hl] ret - AI_Smart_Paralyze: - ; 50% chance to discourage this move if player's HP is below 25%. call AICheckPlayerQuarterHP jr nc, .asm_38b3a @@ -1218,7 +1183,6 @@ AI_Smart_Paralyze: inc [hl] ret - AI_Smart_SpeedDownHit: ; Icy Wind @@ -1244,7 +1208,6 @@ AI_Smart_SpeedDownHit: dec [hl] ret - AI_Smart_Substitute: ; Dismiss this move if enemy's HP is below 50%. @@ -1252,7 +1215,6 @@ AI_Smart_Substitute: ret c jp AIDiscourageMove - AI_Smart_HyperBeam: call AICheckEnemyHalfHP jr c, .asm_38b72 @@ -1276,7 +1238,6 @@ AI_Smart_HyperBeam: inc [hl] ret - AI_Smart_Rage: ld a, [wEnemySubStatus4] bit SUBSTATUS_RAGE, a @@ -1315,7 +1276,6 @@ AI_Smart_Rage: inc [hl] ret - AI_Smart_Mimic: ld a, [wLastPlayerCounterMove] and a @@ -1365,7 +1325,6 @@ AI_Smart_Mimic: inc [hl] ret - AI_Smart_Counter: push hl ld hl, wPlayerUsedMoves @@ -1415,7 +1374,6 @@ AI_Smart_Counter: cp SPECIAL jr nc, .asm_38c38 - .asm_38c30 call Random cp 39 percent + 1 @@ -1430,7 +1388,6 @@ AI_Smart_Counter: inc [hl] ret - AI_Smart_Encore: call AICompareSpeed jr nc, .asm_38c81 @@ -1484,7 +1441,6 @@ AI_Smart_Encore: INCLUDE "data/battle/ai/encore_moves.asm" - AI_Smart_PainSplit: ; Discourage this move if [enemy's current HP * 2 > player's current HP]. @@ -1505,7 +1461,6 @@ AI_Smart_PainSplit: inc [hl] ret - AI_Smart_Snore: AI_Smart_SleepTalk: ; Greatly encourage this move if enemy is fast asleep. @@ -1527,7 +1482,6 @@ AI_Smart_SleepTalk: inc [hl] ret - AI_Smart_DefrostOpponent: ; Greatly encourage this move if enemy is frozen. ; No move has EFFECT_DEFROST_OPPONENT, so this layer is unused. @@ -1540,7 +1494,6 @@ AI_Smart_DefrostOpponent: dec [hl] ret - AI_Smart_Spite: ld a, [wLastPlayerCounterMove] and a @@ -1597,11 +1550,9 @@ AI_Smart_Spite: dec [hl] ret - Function_0x38d16 jp AIDiscourageMove - AI_Smart_DestinyBond: AI_Smart_Reversal: AI_Smart_SkullBash: @@ -1612,7 +1563,6 @@ AI_Smart_SkullBash: inc [hl] ret - AI_Smart_HealBell: ; Dismiss this move if none of the opponent's Pokemon is statused. ; Encourage this move if the enemy is statused. @@ -1670,7 +1620,6 @@ AI_Smart_HealBell: jp AIDiscourageMove - AI_Smart_PriorityHit: call AICompareSpeed ret c @@ -1702,7 +1651,6 @@ AI_Smart_PriorityHit: dec [hl] ret - AI_Smart_Thief: ; Don't use Thief unless it's the only move available. @@ -1711,7 +1659,6 @@ AI_Smart_Thief: ld [hl], a ret - AI_Smart_Conversion2: ld a, [wLastPlayerMove] and a @@ -1751,7 +1698,6 @@ AI_Smart_Conversion2: inc [hl] ret - AI_Smart_Disable: call AICompareSpeed jr nc, .asm_38df3 @@ -1783,7 +1729,6 @@ AI_Smart_Disable: inc [hl] ret - AI_Smart_MeanLook: call AICheckEnemyHalfHP jr nc, .asm_38e24 @@ -1825,7 +1770,6 @@ AI_Smart_MeanLook: dec [hl] ret - AICheckLastPlayerMon: ld a, [wPartyCount] ld b, a @@ -1851,7 +1795,6 @@ AICheckLastPlayerMon: ret - AI_Smart_Nightmare: ; 50% chance to encourage this move. ; The AI_Basic layer will make sure that @@ -1862,7 +1805,6 @@ AI_Smart_Nightmare: dec [hl] ret - AI_Smart_FlameWheel: ; Use this move if the enemy is frozen. @@ -1874,7 +1816,6 @@ rept 5 endr ret - AI_Smart_Curse: ld a, [wEnemyMonType1] cp GHOST @@ -1932,14 +1873,12 @@ AI_Smart_Curse: jr .asm_38eb7 - .asm_38eb0 push hl call AICheckLastPlayerMon pop hl jr z, .asm_38ecb - .asm_38eb7 call AICheckEnemyQuarterHP jp nc, .asm_38e90 @@ -1962,7 +1901,6 @@ AI_Smart_Curse: dec [hl] ret - AI_Smart_Protect: ld a, [wEnemyProtectCount] and a @@ -2014,7 +1952,6 @@ AI_Smart_Protect: inc [hl] ret - AI_Smart_Foresight: ld a, [wEnemyAccLevel] cp $5 @@ -2044,7 +1981,6 @@ AI_Smart_Foresight: dec [hl] ret - AI_Smart_PerishSong: push hl callfar FindAliveEnemyMons @@ -2081,9 +2017,7 @@ AI_Smart_PerishSong: ld [hl], a ret - AI_Smart_Sandstorm: - ; Greatly discourage this move if the player is immune to Sandstorm damage. ld a, [wBattleMonType1] push hl @@ -2125,7 +2059,6 @@ AI_Smart_Sandstorm: db STEEL db -1 ; end - AI_Smart_Endure: ld a, [wEnemyProtectCount] and a @@ -2168,7 +2101,6 @@ AI_Smart_Endure: inc [hl] ret - AI_Smart_FuryCutter: ; Encourage this move based on Fury Cutter's count. @@ -2192,7 +2124,6 @@ AI_Smart_FuryCutter: ; fallthrough - AI_Smart_Rollout: ; Rollout, Fury Cutter @@ -2235,7 +2166,6 @@ AI_Smart_Rollout: inc [hl] ret - AI_Smart_Swagger: AI_Smart_Attract: ; 80% chance to encourage this move during the first turn of player's Pokemon. @@ -2257,7 +2187,6 @@ AI_Smart_Attract: dec [hl] ret - AI_Smart_Safeguard: ; 80% chance to discourage this move if player's HP is below 50%. @@ -2268,10 +2197,8 @@ AI_Smart_Safeguard: inc [hl] ret - AI_Smart_Magnitude: AI_Smart_Earthquake: - ; Greatly encourage this move if the player is underground and the enemy is faster. ld a, [wLastPlayerCounterMove] cp DIG @@ -2300,7 +2227,6 @@ AI_Smart_Earthquake: dec [hl] ret - AI_Smart_BatonPass: ; Discourage this move if the player hasn't shown super-effective moves against the enemy. ; Consider player's type(s) if its moves are unknown. @@ -2314,7 +2240,6 @@ AI_Smart_BatonPass: inc [hl] ret - AI_Smart_Pursuit: ; 50% chance to greatly encourage this move if player's HP is below 25%. ; 80% chance to discourage this move otherwise. @@ -2333,7 +2258,6 @@ AI_Smart_Pursuit: dec [hl] ret - AI_Smart_RapidSpin: ; 80% chance to greatly encourage this move if the enemy is ; trapped (Bind effect), seeded, or scattered with spikes. @@ -2358,7 +2282,6 @@ AI_Smart_RapidSpin: dec [hl] ret - AI_Smart_HiddenPower: push hl ld a, 1 @@ -2397,9 +2320,7 @@ AI_Smart_HiddenPower: inc [hl] ret - AI_Smart_RainDance: - ; Greatly discourage this move if it would favour the player type-wise. ; Particularly, if the player is a Water-type. ld a, [wBattleMonType1] @@ -2420,9 +2341,7 @@ AI_Smart_RainDance: INCLUDE "data/battle/ai/rain_dance_moves.asm" - AI_Smart_SunnyDay: - ; Greatly discourage this move if it would favour the player type-wise. ; Particularly, if the player is a Fire-type. ld a, [wBattleMonType1] @@ -2442,7 +2361,6 @@ AI_Smart_SunnyDay: ; fallthrough - AI_Smart_WeatherMove: ; Rain Dance, Sunny Day @@ -2492,10 +2410,8 @@ AIGoodWeatherType: dec [hl] ret - INCLUDE "data/battle/ai/sunny_day_moves.asm" - AI_Smart_BellyDrum: ; 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. @@ -2518,7 +2434,6 @@ AI_Smart_BellyDrum: ld [hl], a ret - AI_Smart_PsychUp: push hl ld hl, wEnemyAtkLevel @@ -2576,7 +2491,6 @@ AI_Smart_PsychUp: inc [hl] ret - AI_Smart_MirrorCoat: push hl ld hl, wPlayerUsedMoves @@ -2626,7 +2540,6 @@ AI_Smart_MirrorCoat: cp SPECIAL jr c, .asm_391d2 - .asm_391ca call Random cp 100 @@ -2640,10 +2553,8 @@ AI_Smart_MirrorCoat: inc [hl] ret - AI_Smart_Twister: AI_Smart_Gust: - ; Greatly encourage this move if the player is flying and the enemy is faster. ld a, [wLastPlayerCounterMove] cp FLY @@ -2671,7 +2582,6 @@ AI_Smart_Gust: dec [hl] ret - AI_Smart_FutureSight: ; Greatly encourage this move if the player is ; flying or underground, and slower than the enemy. @@ -2687,7 +2597,6 @@ AI_Smart_FutureSight: dec [hl] ret - AI_Smart_Stomp: ; 80% chance to encourage this move if the player has used Minimize. @@ -2701,7 +2610,6 @@ AI_Smart_Stomp: dec [hl] ret - AI_Smart_Solarbeam: ; 80% chance to encourage this move when it's sunny. ; 90% chance to discourage this move when it's raining. @@ -2729,7 +2637,6 @@ AI_Smart_Solarbeam: dec [hl] ret - AI_Smart_Thunder: ; 90% chance to discourage this move when it's sunny. @@ -2744,7 +2651,6 @@ AI_Smart_Thunder: inc [hl] ret - AICompareSpeed: ; Return carry if enemy is faster than player. @@ -2760,7 +2666,6 @@ AICompareSpeed: pop bc ret - AICheckPlayerMaxHP: push hl push de @@ -2769,7 +2674,6 @@ AICheckPlayerMaxHP: ld hl, wBattleMonMaxHP jr AICheckMaxHP - AICheckEnemyMaxHP: push hl push de @@ -2778,7 +2682,6 @@ AICheckEnemyMaxHP: ld hl, wEnemyMonMaxHP ; fallthrough - AICheckMaxHP: ; Return carry if hp at de matches max hp at hl. @@ -2805,7 +2708,6 @@ AICheckMaxHP: and a ret - AICheckPlayerHalfHP: push hl ld hl, wBattleMonHP @@ -2823,7 +2725,6 @@ AICheckPlayerHalfHP: pop hl ret - AICheckEnemyHalfHP: push hl push de @@ -2845,7 +2746,6 @@ AICheckEnemyHalfHP: pop hl ret - AICheckEnemyQuarterHP: push hl push de @@ -2869,7 +2769,6 @@ AICheckEnemyQuarterHP: pop hl ret - AICheckPlayerQuarterHP: push hl ld hl, wBattleMonHP @@ -2889,7 +2788,6 @@ AICheckPlayerQuarterHP: pop hl ret - AIHasMoveEffect: ; Return carry if the enemy has move b. @@ -2921,7 +2819,6 @@ AIHasMoveEffect: scf ret - AIHasMoveInArray: ; Return carry if the enemy has a move in array hl. @@ -2955,10 +2852,8 @@ AIHasMoveInArray: pop hl ret - INCLUDE "data/battle/ai/useful_moves.asm" - AI_Opportunist: ; Discourage stall moves when the enemy's HP is low. @@ -3009,7 +2904,6 @@ AI_Opportunist: INCLUDE "data/battle/ai/stall_moves.asm" - AI_Aggressive: ; Use whatever does the most damage. @@ -3117,7 +3011,6 @@ AI_Aggressive: INCLUDE "data/battle/ai/reckless_moves.asm" - AIDamageCalc: ld a, 1 ld [hBattleTurn], a @@ -3137,7 +3030,6 @@ AIDamageCalc: INCLUDE "data/battle/ai/constant_damage_effects.asm" - AI_Cautious: ; 90% chance to discourage moves with residual effects after the first turn. @@ -3180,7 +3072,6 @@ AI_Cautious: INCLUDE "data/battle/ai/residual_moves.asm" - AI_Status: ; Dismiss status moves that don't affect the player. @@ -3243,7 +3134,6 @@ AI_Status: jr .checkmove - AI_Risky: ; Use any move that will KO the target. ; Risky moves will often be an exception (see below). @@ -3313,18 +3203,15 @@ endr INCLUDE "data/battle/ai/risky_effects.asm" - AI_None: ret - AIDiscourageMove: ld a, [hl] add 10 ld [hl], a ret - AIGetEnemyMove: ; Load attributes of move a into ram @@ -3345,13 +3232,11 @@ AIGetEnemyMove: pop hl ret - AI_80_20: call Random cp 20 percent - 1 ret - AI_50_50: call Random cp 50 percent + 1 diff --git a/engine/battle/ai/switch.asm b/engine/battle/ai/switch.asm index b975776c2..b9bd2ea60 100644 --- a/engine/battle/ai/switch.asm +++ b/engine/battle/ai/switch.asm @@ -96,7 +96,6 @@ CheckPlayerMoveTypeMatchups: pop hl ret - .CheckEnemyMoveMatchups: ld de, wEnemyMonMoves ld b, NUM_MOVES + 1 @@ -290,7 +289,6 @@ CheckAbleToSwitch: ld [wEnemySwitchMonParam], a ret - FindAliveEnemyMons: ld a, [wOTPartyCount] cp 2 @@ -341,7 +339,6 @@ FindAliveEnemyMons: and a ret - FindEnemyMonsImmuneToLastCounterMove: ld hl, wOTPartyMon1 ld a, [wOTPartyCount] @@ -408,7 +405,6 @@ FindEnemyMonsImmuneToLastCounterMove: srl c jr .loop - FindAliveEnemyMonsWithASuperEffectiveMove: push bc ld a, [wOTPartyCount] @@ -439,8 +435,9 @@ FindAliveEnemyMonsWithASuperEffectiveMove: and c ld c, a -FindEnemyMonsWithASuperEffectiveMove: + ; fallthrough +FindEnemyMonsWithASuperEffectiveMove: ld a, -1 ld [wEnemyAISwitchScore], a ld hl, wOTPartyMon1Moves @@ -546,7 +543,6 @@ FindEnemyMonsWithASuperEffectiveMove: pop bc ret - FindEnemyMonsThatResistPlayer: push bc ld hl, wOTPartySpecies @@ -607,7 +603,6 @@ FindEnemyMonsThatResistPlayer: ld c, a ret - FindEnemyMonsWithAtLeastQuarterMaxHP: push bc ld de, wOTPartySpecies |