Skip to content

Commit

Permalink
Revert "Smarter SwitchAI Mon Choices | HasBadOdds Switch Check (rh-hi…
Browse files Browse the repository at this point in the history
…deout#3253)"

This reverts commit 472f8ad.
  • Loading branch information
Kasenn committed Dec 29, 2023
1 parent 3bb2616 commit d6c3076
Show file tree
Hide file tree
Showing 13 changed files with 235 additions and 1,101 deletions.
8 changes: 0 additions & 8 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,6 @@ struct AIPartyData // Opposing battlers - party mons.
u8 count[NUM_BATTLE_SIDES];
};

struct SwitchinCandidate
{
struct BattlePokemon battleMon;
bool8 hypotheticalStatus;
};

// Ai Data used when deciding which move to use, computed only once before each turn's start.
struct AiLogicData
{
Expand All @@ -305,8 +299,6 @@ struct AiLogicData
bool8 shouldSwitchMon; // Because all available moves have no/little effect. Each bit per battler.
u8 monToSwitchId[MAX_BATTLERS_COUNT]; // ID of the mon to switch.
bool8 weatherHasEffect; // The same as WEATHER_HAS_EFFECT. Stored here, so it's called only once.
u8 mostSuitableMonId; // Stores result of GetMostSuitableMonToSwitchInto, which decides which generic mon the AI would switch into if they decide to switch. This can be overruled by specific mons found in ShouldSwitch; the final resulting mon is stored in AI_monToSwitchIntoId.
struct SwitchinCandidate switchinCandidate; // Struct used for deciding which mon to switch to in battle_ai_switch_items.c
};

struct AI_ThinkingStruct
Expand Down
2 changes: 1 addition & 1 deletion include/battle_ai_switch_items.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

void GetAIPartyIndexes(u32 battlerId, s32 *firstId, s32 *lastId);
void AI_TrySwitchOrUseItem(u32 battler);
u8 GetMostSuitableMonToSwitchInto(u32 battler, bool32 switchAfterMonKOd);
u8 GetMostSuitableMonToSwitchInto(u32 battler);
bool32 ShouldSwitch(u32 battler);

#endif // GUARD_BATTLE_AI_SWITCH_ITEMS_H
3 changes: 1 addition & 2 deletions include/battle_ai_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ bool32 ShouldUseWishAromatherapy(u32 battlerAtk, u32 battlerDef, u32 move);
// party logic
struct BattlePokemon *AllocSaveBattleMons(void);
void FreeRestoreBattleMons(struct BattlePokemon *savedBattleMons);
s32 AI_CalcPartyMonBestMoveDamage(u32 battlerAtk, u32 battlerDef, struct Pokemon *attackerMon, struct Pokemon *targetMon);
s32 CountUsablePartyMons(u32 battlerId);
bool32 IsPartyFullyHealedExceptBattler(u32 battler);
bool32 PartyHasMoveSplit(u32 battlerId, u32 split);
Expand All @@ -187,6 +188,4 @@ void IncreaseSleepScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score);
void IncreaseConfusionScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score);
void IncreaseFrostbiteScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score);

s32 AI_CalcPartyMonDamage(u32 move, u32 battlerAtk, u32 battlerDef, struct BattlePokemon switchinCandidate, bool8 isPartyMonAttacker);

#endif //GUARD_BATTLE_AI_UTIL_H
1 change: 0 additions & 1 deletion include/constants/battle_ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#define AI_FLAG_SMART_SWITCHING (1 << 15) // AI includes a lot more switching checks
#define AI_FLAG_ACE_POKEMON (1 << 16) // AI has an Ace Pokemon. The last Pokemon in the party will not be used until it's the last one remaining.
#define AI_FLAG_OMNISCIENT (1 << 17) // AI has full knowledge of player moves, abilities, hold items
#define AI_FLAG_SMART_MON_CHOICES (1 << 18) // AI will make smarter decisions when choosing which mon to send out mid-battle and after a KO, which are separate decisions. Pairs very well with AI_FLAG_SMART_SWITCHING.

#define AI_FLAG_COUNT 18

Expand Down
14 changes: 0 additions & 14 deletions include/constants/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -607,20 +607,6 @@
#define ITEM_UTILITY_UMBRELLA 513

// Berries
#if B_CONFUSE_BERRIES_HEAL >= GEN_8
#define CONFUSE_BERRY_HEAL_FRACTION 3
#elif B_CONFUSE_BERRIES_HEAL == GEN_7
#define CONFUSE_BERRY_HEAL_FRACTION 2
#else
#define CONFUSE_BERRY_HEAL_FRACTION 8
#endif

#if B_CONFUSE_BERRIES_HEAL >= GEN_7
#define CONFUSE_BERRY_HP_FRACTION 4
#else
#define CONFUSE_BERRY_HP_FRACTION 2
#endif

#define ITEM_CHERI_BERRY 514
#define ITEM_CHESTO_BERRY 515
#define ITEM_PECHA_BERRY 516
Expand Down
2 changes: 1 addition & 1 deletion src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ void SetAiLogicDataForTurn(struct AiLogicData *aiData)

static bool32 AI_SwitchMonIfSuitable(u32 battler)
{
u32 monToSwitchId = AI_DATA->mostSuitableMonId;
u32 monToSwitchId = GetMostSuitableMonToSwitchInto(battler);
if (monToSwitchId != PARTY_SIZE)
{
AI_DATA->shouldSwitchMon |= gBitTable[battler];
Expand Down
Loading

0 comments on commit d6c3076

Please sign in to comment.