Converts some defines to enums (#6592)

This commit is contained in:
Bassoonian 2025-04-13 13:39:20 +02:00 committed by GitHub
parent 6a881f918a
commit d62205f2fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 87 additions and 70 deletions

View File

@ -16,31 +16,35 @@ typedef s32 (*AiScoreFunc)(u32, u32, u32, s32);
#define AI_IS_SLOWER -1
// for stat increasing / decreasing scores
#define STAT_CHANGE_ATK 0
#define STAT_CHANGE_DEF 1
#define STAT_CHANGE_SPEED 2
#define STAT_CHANGE_SPATK 3
#define STAT_CHANGE_SPDEF 4
#define STAT_CHANGE_ATK_2 5
#define STAT_CHANGE_DEF_2 6
#define STAT_CHANGE_SPEED_2 7
#define STAT_CHANGE_SPATK_2 8
#define STAT_CHANGE_SPDEF_2 9
#define STAT_CHANGE_ACC 10
#define STAT_CHANGE_EVASION 11
enum StatChange
{
STAT_CHANGE_ATK,
STAT_CHANGE_DEF,
STAT_CHANGE_SPEED,
STAT_CHANGE_SPATK,
STAT_CHANGE_SPDEF,
STAT_CHANGE_ATK_2,
STAT_CHANGE_DEF_2,
STAT_CHANGE_SPEED_2,
STAT_CHANGE_SPATK_2,
STAT_CHANGE_SPDEF_2,
STAT_CHANGE_ACC,
STAT_CHANGE_EVASION
};
#define BEST_DAMAGE_MOVE 1 // Move with the most amount of hits with the best accuracy/effect
#define POWERFUL_STATUS_MOVE 10 // Moves with this score will be chosen over a move that faints target
#define NO_DAMAGE_OR_FAILS -20 // Move fails or does no damage
// Scores given in AI_CalcMoveEffectScore and AI_CalcHoldEffectMoveScore
#define NO_INCREASE 0
#define WEAK_EFFECT 1
#define DECENT_EFFECT 2
#define GOOD_EFFECT 3
#define BEST_EFFECT 4
enum AIScore
{
NO_INCREASE,
WEAK_EFFECT,
DECENT_EFFECT,
GOOD_EFFECT,
BEST_EFFECT
};
// AI_TryToFaint
#define FAST_KILL 6 // AI is faster and faints target

View File

@ -1,6 +1,8 @@
#ifndef GUARD_BATTLE_AI_UTIL_H
#define GUARD_BATTLE_AI_UTIL_H
#include "battle_ai_main.h"
#define FOE(battler) ((BATTLE_OPPOSITE(battler)) & BIT_SIDE)
// Roll boundaries used by AI when scoring. Doesn't affect actual damage dealt.
@ -218,8 +220,8 @@ bool32 PartyHasMoveCategory(u32 battlerId, u32 category);
bool32 SideHasMoveCategory(u32 battlerId, u32 category);
// score increases
u32 IncreaseStatUpScore(u32 battlerAtk, u32 battlerDef, u32 statId);
u32 IncreaseStatUpScoreContrary(u32 battlerAtk, u32 battlerDef, u32 statId);
u32 IncreaseStatUpScore(u32 battlerAtk, u32 battlerDef, enum StatChange statId);
u32 IncreaseStatUpScoreContrary(u32 battlerAtk, u32 battlerDef, enum StatChange statId);
void IncreasePoisonScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score);
void IncreaseBurnScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score);
void IncreaseParalyzeScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score);

View File

@ -4,11 +4,14 @@
#include "config/dexnav.h"
// GUI Info
#define ROW_WATER 0
#define ROW_LAND_TOP 1
#define ROW_LAND_BOT 2
#define ROW_HIDDEN 3
#define ROWS_COUNT 4
enum RowGUIInfo
{
ROW_WATER,
ROW_LAND_TOP,
ROW_LAND_BOT,
ROW_HIDDEN,
ROWS_COUNT
};
#define ROW_WATER_ICON_X 30
#define ROW_WATER_ICON_Y 35
@ -20,9 +23,12 @@
#define ROW_HIDDEN_ICON_X 52
#define ROW_HIDDEN_ICON_Y 138
#define ENCOUNTER_TYPE_LAND 0
#define ENCOUNTER_TYPE_WATER 1
#define ENCOUNTER_TYPE_HIDDEN 2 // Get from species
enum EncounterType
{
ENCOUNTER_TYPE_LAND,
ENCOUNTER_TYPE_WATER,
ENCOUNTER_TYPE_HIDDEN // Get from species
};
#define COL_WATER_COUNT 5
#define COL_LAND_COUNT 6

View File

@ -1,7 +1,8 @@
#ifndef GUARD_FOLLOWER_HELPER_H
#define GUARD_FOLLOWER_HELPER_H
enum {
enum FollowerEmotion
{
FOLLOWER_EMOTION_HAPPY = 0,
FOLLOWER_EMOTION_NEUTRAL, // Also called "No emotion"
FOLLOWER_EMOTION_SAD,
@ -50,17 +51,20 @@ struct FollowerMsgInfoExtended
}; // size = 8 + 4 + 5*4 = 32, 0x20
// Follower message conditions
#define MSG_COND_NONE 0
#define MSG_COND_SPECIES 1
#define MSG_COND_TYPE 2
#define MSG_COND_STATUS 3
#define MSG_COND_MAPSEC 4
#define MSG_COND_MAP 5
#define MSG_COND_ON_MB 6
#define MSG_COND_WEATHER 7
#define MSG_COND_MUSIC 8
#define MSG_COND_TIME_OF_DAY 9
#define MSG_COND_NEAR_MB 10
enum MessageCondition
{
MSG_COND_NONE,
MSG_COND_SPECIES,
MSG_COND_TYPE,
MSG_COND_STATUS,
MSG_COND_MAPSEC,
MSG_COND_MAP,
MSG_COND_ON_MB,
MSG_COND_WEATHER,
MSG_COND_MUSIC,
MSG_COND_TIME_OF_DAY,
MSG_COND_NEAR_MB
};
#define MATCH_U24(type, value) {type, {.raw = value}}
#define MATCH_U16(type, value1, value2) {type, {.split = {.hw = value1, .b = value2}}}
@ -82,7 +86,8 @@ struct FollowerMsgInfoExtended
// Matches metatile behavior within a '+' shape of size `distance`
#define MATCH_NEAR_MB(mb, distance) MATCH_U8(MSG_COND_NEAR_MB, mb, distance, 0)
enum {
enum ConditionalMessage
{
COND_MSG_CELEBI,
COND_MSG_FIRE,
COND_MSG_EVER_GRANDE,

View File

@ -4601,7 +4601,7 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
// Consider move effects that target self
if (additionalEffect->self)
{
u32 StageStatId;
enum StatChange StageStatId;
if (aiData->abilities[battlerAtk] != ABILITY_CONTRARY)
{

View File

@ -3990,9 +3990,9 @@ bool32 IsRecycleEncouragedItem(u32 item)
return FALSE;
}
static u32 IncreaseStatUpScoreInternal(u32 battlerAtk, u32 battlerDef, u32 statId, bool32 considerContrary)
static enum AIScore IncreaseStatUpScoreInternal(u32 battlerAtk, u32 battlerDef, enum StatChange statId, bool32 considerContrary)
{
u32 tempScore = NO_INCREASE;
enum AIScore tempScore = NO_INCREASE;
u32 noOfHitsToFaint = NoOfHitsForTargetToFaintAI(battlerDef, battlerAtk);
u32 aiIsFaster = AI_IsFaster(battlerAtk, battlerDef, TRUE);
u32 shouldSetUp = ((noOfHitsToFaint >= 2 && aiIsFaster) || (noOfHitsToFaint >= 3 && !aiIsFaster) || noOfHitsToFaint == UNKNOWN_NO_OF_HITS);
@ -4123,12 +4123,12 @@ static u32 IncreaseStatUpScoreInternal(u32 battlerAtk, u32 battlerDef, u32 statI
return tempScore;
}
u32 IncreaseStatUpScore(u32 battlerAtk, u32 battlerDef, u32 statId)
u32 IncreaseStatUpScore(u32 battlerAtk, u32 battlerDef, enum StatChange statId)
{
return IncreaseStatUpScoreInternal(battlerAtk, battlerDef, statId, TRUE);
}
u32 IncreaseStatUpScoreContrary(u32 battlerAtk, u32 battlerDef, u32 statId)
u32 IncreaseStatUpScoreContrary(u32 battlerAtk, u32 battlerDef, enum StatChange statId)
{
return IncreaseStatUpScoreInternal(battlerAtk, battlerDef, statId, FALSE);
}

View File

@ -143,16 +143,16 @@ static void Task_DexNavWaitFadeIn(u8 taskId);
static void Task_DexNavMain(u8 taskId);
static void PrintCurrentSpeciesInfo(void);
// SEARCH
static bool8 TryStartHiddenMonFieldEffect(u8 environment, u8 xSize, u8 ySize, bool8 smallScan);
static void DexNavGenerateMoveset(u16 species, u8 searchLevel, u8 encounterLevel, u16* moveDst);
static bool8 TryStartHiddenMonFieldEffect(enum EncounterType environment, u8 xSize, u8 ySize, bool8 smallScan);
static void DexNavGenerateMoveset(u16 species, u8 searchLevel, u8 encounterLevel, u16 *moveDst);
static u16 DexNavGenerateHeldItem(u16 species, u8 searchLevel);
static u8 DexNavGetAbilityNum(u16 species, u8 searchLevel);
static u8 DexNavGeneratePotential(u8 searchLevel);
static u8 DexNavTryGenerateMonLevel(u16 species, u8 environment);
static u8 GetEncounterLevelFromMapData(u16 species, u8 environment);
static void CreateDexNavWildMon(u16 species, u8 potential, u8 level, u8 abilityNum, u16 item, u16* moves);
static u8 DexNavTryGenerateMonLevel(u16 species, enum EncounterType environment);
static u8 GetEncounterLevelFromMapData(u16 species, enum EncounterType environment);
static void CreateDexNavWildMon(u16 species, u8 potential, u8 level, u8 abilityNum, u16 item, u16 *moves);
static u8 GetPlayerDistance(s16 x, s16 y);
static u8 DexNavPickTile(u8 environment, u8 xSize, u8 ySize, bool8 smallScan);
static u8 DexNavPickTile(enum EncounterType environment, u8 xSize, u8 ySize, bool8 smallScan);
static void DexNavProximityUpdate(void);
static void DexNavDrawIcons(void);
static void DexNavUpdateSearchWindow(u8 proximity, u8 searchLevel);
@ -603,7 +603,7 @@ static void DexNavProximityUpdate(void)
}
//Pick a specific tile based on environment
static bool8 DexNavPickTile(u8 environment, u8 areaX, u8 areaY, bool8 smallScan)
static bool8 DexNavPickTile(enum EncounterType environment, u8 areaX, u8 areaY, bool8 smallScan)
{
// area of map to cover starting from camera position {-7, -7}
s16 topX = gSaveBlock1Ptr->pos.x - SCANSTART_X + (smallScan * 5);
@ -724,7 +724,7 @@ static bool8 DexNavPickTile(u8 environment, u8 areaX, u8 areaY, bool8 smallScan)
}
static bool8 TryStartHiddenMonFieldEffect(u8 environment, u8 xSize, u8 ySize, bool8 smallScan)
static bool8 TryStartHiddenMonFieldEffect(enum EncounterType environment, u8 xSize, u8 ySize, bool8 smallScan)
{
u8 currMapType = GetCurrentMapType();
u8 fldEffId = 0;
@ -790,7 +790,7 @@ static bool8 TryStartHiddenMonFieldEffect(u8 environment, u8 xSize, u8 ySize, bo
return FALSE;
}
static void DrawDexNavSearchHeldItem(u8* dst)
static void DrawDexNavSearchHeldItem(u8 *dst)
{
*dst = CreateSprite(&sHeldItemTemplate, SPECIES_ICON_X + 6, GetSearchWindowY() + 18, 0);
if (*dst != MAX_SPRITES)
@ -912,7 +912,7 @@ static void Task_InitDexNavSearch(u8 taskId)
task->func = Task_SetUpDexNavSearch;
}
static void DexNavDrawPotentialStars(u8 potential, u8* dst)
static void DexNavDrawPotentialStars(u8 potential, u8 *dst)
{
u8 spriteId;
u32 i;
@ -1213,9 +1213,9 @@ static void DexNavUpdateSearchWindow(u8 proximity, u8 searchLevel)
//////////////////////////////
//// DEXNAV MON GENERATOR ////
//////////////////////////////
static void CreateDexNavWildMon(u16 species, u8 potential, u8 level, u8 abilityNum, u16 item, u16* moves)
static void CreateDexNavWildMon(u16 species, u8 potential, u8 level, u8 abilityNum, u16 item, u16 *moves)
{
struct Pokemon* mon = &gEnemyParty[0];
struct Pokemon *mon = &gEnemyParty[0];
u8 iv[3] = {NUM_STATS};
u8 i;
u8 perfectIv = 31;
@ -1253,7 +1253,7 @@ static void CreateDexNavWildMon(u16 species, u8 potential, u8 level, u8 abilityN
// gets a random level of the species based on map data.
//if it was a hidden encounter, updates the environment it is to be found from the wildheader encounterRate
static u8 DexNavTryGenerateMonLevel(u16 species, u8 environment)
static u8 DexNavTryGenerateMonLevel(u16 species, enum EncounterType environment)
{
u8 levelBase = GetEncounterLevelFromMapData(species, environment);
u8 levelBonus = gSaveBlock3Ptr->dexNavChain / 5;
@ -1270,7 +1270,7 @@ static u8 DexNavTryGenerateMonLevel(u16 species, u8 environment)
return levelBase + levelBonus;
}
static void DexNavGenerateMoveset(u16 species, u8 searchLevel, u8 encounterLevel, u16* moveDst)
static void DexNavGenerateMoveset(u16 species, u8 searchLevel, u8 encounterLevel, u16 *moveDst)
{
bool8 genMove = FALSE;
u16 randVal = Random() % 100;
@ -1514,7 +1514,7 @@ static u8 DexNavGeneratePotential(u8 searchLevel)
return 0; // No potential
}
static u8 GetEncounterLevelFromMapData(u16 species, u8 environment)
static u8 GetEncounterLevelFromMapData(u16 species, enum EncounterType environment)
{
u32 headerId = GetCurrentMapWildMonHeaderId();
enum TimeOfDay timeOfDay;
@ -1738,7 +1738,7 @@ static bool8 CapturedAllLandMons(u32 headerId)
int count = 0;
enum TimeOfDay timeOfDay = GetTimeOfDayForEncounters(headerId, WILD_AREA_LAND);
const struct WildPokemonInfo* landMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].landMonsInfo;
const struct WildPokemonInfo *landMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].landMonsInfo;
if (landMonsInfo != NULL)
{
@ -1773,7 +1773,7 @@ static bool8 CapturedAllWaterMons(u32 headerId)
u8 count = 0;
enum TimeOfDay timeOfDay = GetTimeOfDayForEncounters(headerId, WILD_AREA_WATER);
const struct WildPokemonInfo* waterMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].waterMonsInfo;
const struct WildPokemonInfo *waterMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].waterMonsInfo;
if (waterMonsInfo != NULL)
{
@ -1806,7 +1806,7 @@ static bool8 CapturedAllHiddenMons(u32 headerId)
u8 count = 0;
enum TimeOfDay timeOfDay = GetTimeOfDayForEncounters(headerId, WILD_AREA_HIDDEN);
const struct WildPokemonInfo* hiddenMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].hiddenMonsInfo;
const struct WildPokemonInfo *hiddenMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].hiddenMonsInfo;
if (hiddenMonsInfo != NULL)
{
@ -1954,11 +1954,11 @@ static void DexNavLoadEncounterData(void)
enum TimeOfDay timeOfDay;
timeOfDay = GetTimeOfDayForEncounters(headerId, WILD_AREA_LAND);
const struct WildPokemonInfo* landMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].landMonsInfo;
const struct WildPokemonInfo *landMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].landMonsInfo;
timeOfDay = GetTimeOfDayForEncounters(headerId, WILD_AREA_WATER);
const struct WildPokemonInfo* waterMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].waterMonsInfo;
const struct WildPokemonInfo *waterMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].waterMonsInfo;
timeOfDay = GetTimeOfDayForEncounters(headerId, WILD_AREA_HIDDEN);
const struct WildPokemonInfo* hiddenMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].hiddenMonsInfo;
const struct WildPokemonInfo *hiddenMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].hiddenMonsInfo;
// nop struct data
memset(sDexNavUiDataPtr->landSpecies, 0, sizeof(sDexNavUiDataPtr->landSpecies));
@ -2531,11 +2531,11 @@ bool8 TryFindHiddenPokemon(void)
u32 headerId = GetCurrentMapWildMonHeaderId();
u8 index;
u16 species;
u8 environment;
enum EncounterType environment;
u8 taskId;
enum TimeOfDay timeOfDay = GetTimeOfDayForEncounters(headerId, WILD_AREA_HIDDEN);
const struct WildPokemonInfo* hiddenMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].hiddenMonsInfo;
const struct WildPokemonInfo *hiddenMonsInfo = gWildMonHeaders[headerId].encounterTypes[timeOfDay].hiddenMonsInfo;
bool8 isHiddenMon = FALSE;
// while you can still technically find hidden pokemon if there are not hidden-only pokemon on a map,