mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 11:44:17 +01:00
Condense battle AI scripts, minor clean up
This commit is contained in:
parent
8f43d1ebeb
commit
64d06f4c8f
File diff suppressed because it is too large
Load Diff
@ -29,24 +29,24 @@
|
||||
#define AI_WEATHER_HAIL 3
|
||||
|
||||
// get_how_powerful_move_is
|
||||
#define MOVE_POWER_DISCOURAGED 0
|
||||
#define MOVE_POWER_OTHER 0
|
||||
#define MOVE_NOT_MOST_POWERFUL 1
|
||||
#define MOVE_MOST_POWERFUL 2
|
||||
|
||||
// script's table id to bit
|
||||
#define AI_SCRIPT_CHECK_BAD_MOVE (1 << 0)
|
||||
#define AI_SCRIPT_TRY_TO_FAINT (1 << 1)
|
||||
#define AI_SCRIPT_CHECK_VIABILITY (1 << 2)
|
||||
#define AI_SCRIPT_SETUP_FIRST_TURN (1 << 3)
|
||||
#define AI_SCRIPT_RISKY (1 << 4)
|
||||
#define AI_SCRIPT_PREFER_STRONGEST_MOVE (1 << 5)
|
||||
#define AI_SCRIPT_PREFER_BATON_PASS (1 << 6)
|
||||
#define AI_SCRIPT_DOUBLE_BATTLE (1 << 7)
|
||||
#define AI_SCRIPT_HP_AWARE (1 << 8)
|
||||
#define AI_SCRIPT_UNKNOWN (1 << 9)
|
||||
#define AI_SCRIPT_CHECK_BAD_MOVE (1 << 0)
|
||||
#define AI_SCRIPT_TRY_TO_FAINT (1 << 1)
|
||||
#define AI_SCRIPT_CHECK_VIABILITY (1 << 2)
|
||||
#define AI_SCRIPT_SETUP_FIRST_TURN (1 << 3)
|
||||
#define AI_SCRIPT_RISKY (1 << 4)
|
||||
#define AI_SCRIPT_PREFER_POWER_EXTREMES (1 << 5)
|
||||
#define AI_SCRIPT_PREFER_BATON_PASS (1 << 6)
|
||||
#define AI_SCRIPT_DOUBLE_BATTLE (1 << 7)
|
||||
#define AI_SCRIPT_HP_AWARE (1 << 8)
|
||||
#define AI_SCRIPT_TRY_SUNNY_DAY_START (1 << 9)
|
||||
// 10 - 28 are not used
|
||||
#define AI_SCRIPT_ROAMING (1 << 29)
|
||||
#define AI_SCRIPT_SAFARI (1 << 30)
|
||||
#define AI_SCRIPT_FIRST_BATTLE (1 << 31)
|
||||
#define AI_SCRIPT_ROAMING (1 << 29)
|
||||
#define AI_SCRIPT_SAFARI (1 << 30)
|
||||
#define AI_SCRIPT_FIRST_BATTLE (1 << 31)
|
||||
|
||||
#endif // GUARD_CONSTANTS_BATTLE_AI_H
|
||||
|
@ -263,7 +263,10 @@ static const BattleAICmdFunc sBattleAICmdTable[] =
|
||||
Cmd_if_holds_item, // 0x62
|
||||
};
|
||||
|
||||
static const u16 sDiscouragedPowerfulMoveEffects[] =
|
||||
// For the purposes of determing the most powerful move in a moveset, these
|
||||
// moves are treated the same as having a power of 0 or 1
|
||||
#define IGNORED_MOVES_END 0xFFFF
|
||||
static const u16 sIgnoredPowerfulMoveEffects[] =
|
||||
{
|
||||
EFFECT_EXPLOSION,
|
||||
EFFECT_DREAM_EATER,
|
||||
@ -277,7 +280,7 @@ static const u16 sDiscouragedPowerfulMoveEffects[] =
|
||||
EFFECT_SUPERPOWER,
|
||||
EFFECT_ERUPTION,
|
||||
EFFECT_OVERHEAT,
|
||||
0xFFFF
|
||||
IGNORED_MOVES_END
|
||||
};
|
||||
|
||||
// code
|
||||
@ -1177,14 +1180,14 @@ static void Cmd_get_how_powerful_move_is(void)
|
||||
s32 i, checkedMove;
|
||||
s32 moveDmgs[MAX_MON_MOVES];
|
||||
|
||||
for (i = 0; sDiscouragedPowerfulMoveEffects[i] != 0xFFFF; i++)
|
||||
for (i = 0; sIgnoredPowerfulMoveEffects[i] != IGNORED_MOVES_END; i++)
|
||||
{
|
||||
if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect == sDiscouragedPowerfulMoveEffects[i])
|
||||
if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect == sIgnoredPowerfulMoveEffects[i])
|
||||
break;
|
||||
}
|
||||
|
||||
if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power > 1
|
||||
&& sDiscouragedPowerfulMoveEffects[i] == 0xFFFF)
|
||||
&& sIgnoredPowerfulMoveEffects[i] == IGNORED_MOVES_END)
|
||||
{
|
||||
gDynamicBasePower = 0;
|
||||
*(&gBattleStruct->dynamicMoveType) = 0;
|
||||
@ -1192,16 +1195,18 @@ static void Cmd_get_how_powerful_move_is(void)
|
||||
gMoveResultFlags = 0;
|
||||
gCritMultiplier = 1;
|
||||
|
||||
// Considered move has power and is not in sIgnoredPowerfulMoveEffects
|
||||
// Check all other moves and calculate their power
|
||||
for (checkedMove = 0; checkedMove < MAX_MON_MOVES; checkedMove++)
|
||||
{
|
||||
for (i = 0; sDiscouragedPowerfulMoveEffects[i] != 0xFFFF; i++)
|
||||
for (i = 0; sIgnoredPowerfulMoveEffects[i] != IGNORED_MOVES_END; i++)
|
||||
{
|
||||
if (gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].effect == sDiscouragedPowerfulMoveEffects[i])
|
||||
if (gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].effect == sIgnoredPowerfulMoveEffects[i])
|
||||
break;
|
||||
}
|
||||
|
||||
if (gBattleMons[sBattler_AI].moves[checkedMove] != MOVE_NONE
|
||||
&& sDiscouragedPowerfulMoveEffects[i] == 0xFFFF
|
||||
&& sIgnoredPowerfulMoveEffects[i] == IGNORED_MOVES_END
|
||||
&& gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].power > 1)
|
||||
{
|
||||
gCurrentMove = gBattleMons[sBattler_AI].moves[checkedMove];
|
||||
@ -1217,6 +1222,7 @@ static void Cmd_get_how_powerful_move_is(void)
|
||||
}
|
||||
}
|
||||
|
||||
// Is the considered move the most powerful move available?
|
||||
for (checkedMove = 0; checkedMove < MAX_MON_MOVES; checkedMove++)
|
||||
{
|
||||
if (moveDmgs[checkedMove] > moveDmgs[AI_THINKING_STRUCT->movesetIndex])
|
||||
@ -1224,13 +1230,14 @@ static void Cmd_get_how_powerful_move_is(void)
|
||||
}
|
||||
|
||||
if (checkedMove == MAX_MON_MOVES)
|
||||
AI_THINKING_STRUCT->funcResult = MOVE_MOST_POWERFUL; // Is the most powerful.
|
||||
AI_THINKING_STRUCT->funcResult = MOVE_MOST_POWERFUL;
|
||||
else
|
||||
AI_THINKING_STRUCT->funcResult = MOVE_NOT_MOST_POWERFUL; // Not the most powerful.
|
||||
AI_THINKING_STRUCT->funcResult = MOVE_NOT_MOST_POWERFUL;
|
||||
}
|
||||
else
|
||||
{
|
||||
AI_THINKING_STRUCT->funcResult = MOVE_POWER_DISCOURAGED; // Highly discouraged in terms of power.
|
||||
// Move has a power of 0/1, or is in the group sIgnoredPowerfulMoveEffects
|
||||
AI_THINKING_STRUCT->funcResult = MOVE_POWER_OTHER;
|
||||
}
|
||||
|
||||
gAIScriptPtr++;
|
||||
|
Loading…
Reference in New Issue
Block a user