Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some define usage #181

Merged
merged 2 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/constants/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
#define MON_DATA_HOENN_WORLD_RIBBON 109
#define MON_DATA_FATEFUL_ENCOUNTER 110
#define MON_DATA_GENDER 111
#define MON_DATA_FORM 112
#define MON_DATA_FORM 112
#define MON_DATA_RESERVED_113 113 // HGSS
#define MON_DATA_RESERVED_114 114 // Plat
#define MON_DATA_HGSS_EGG_MET_LOCATION 115
Expand Down Expand Up @@ -330,7 +330,7 @@
#define MON_DATA_SEAL_COORDS 171
#define MON_DATA_SPECIES_EXISTS 172
#define MON_DATA_SANITY_IS_EGG 173
#define MON_DATA_SPECIES2 174
#define MON_DATA_SPECIES_OR_EGG 174 // If the Pokémon is in an Egg, return SPECIES_EGG.
#define MON_DATA_IVS_WORD 175
#define MON_DATA_UNK_176 176
#define MON_DATA_TYPE_1 177
Expand Down
47 changes: 34 additions & 13 deletions src/battle/battle_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -3165,7 +3165,9 @@ BOOL BtlCmd_TryWhirlwind(BattleSystem *bsys, BATTLECONTEXT *ctx) {

for (monIndex = index0; monIndex < indexEnd; monIndex++) {
mon = GetPartyMonByIndex(party, monIndex);
if (GetMonData(mon, MON_DATA_SPECIES, 0) && !GetMonData(mon, MON_DATA_IS_EGG, 0) && GetMonData(mon, MON_DATA_HP, 0)) {
if (GetMonData(mon, MON_DATA_SPECIES, 0) != SPECIES_NONE
&& !GetMonData(mon, MON_DATA_IS_EGG, 0)
&& GetMonData(mon, MON_DATA_HP, 0) != 0) {
cnt++;
}
}
Expand All @@ -3179,7 +3181,9 @@ BOOL BtlCmd_TryWhirlwind(BattleSystem *bsys, BATTLECONTEXT *ctx) {
monIndex += index0;
} while (monIndex == monIndexA || monIndex == monIndexB);
mon = GetPartyMonByIndex(party, monIndex);
} while (!GetMonData(mon, MON_DATA_SPECIES, 0) || GetMonData(mon, MON_DATA_IS_EGG, 0) == 1 || !GetMonData(mon, MON_DATA_HP, 0));
} while (GetMonData(mon, MON_DATA_SPECIES, 0) == SPECIES_NONE
|| GetMonData(mon, MON_DATA_IS_EGG, 0) == TRUE
|| GetMonData(mon, MON_DATA_HP, 0) == 0);
ctx->unk_21A0[ctx->battlerIdTarget] = monIndex;
} else {
BattleScriptIncrementPointer(ctx, adrs);
Expand Down Expand Up @@ -3735,8 +3739,11 @@ BOOL BtlCmd_BeatUpDamageCalc(BattleSystem *bsys, BATTLECONTEXT *ctx) {

while (TRUE) {
mon = BattleSystem_GetPartyMon(bsys, ctx->battlerIdAttacker, ctx->beatUpCount);
if (ctx->beatUpCount == ctx->selectedMonIndex[ctx->battlerIdAttacker] ||
(GetMonData(mon, MON_DATA_HP, 0) && GetMonData(mon, MON_DATA_SPECIES2, 0) && GetMonData(mon, MON_DATA_SPECIES2, 0) != 0x1ee && GetMonData(mon, MON_DATA_STATUS, 0) == 0)) {
if (ctx->beatUpCount == ctx->selectedMonIndex[ctx->battlerIdAttacker]
|| (GetMonData(mon, MON_DATA_HP, 0) != 0
&& GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0) != SPECIES_NONE
&& GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0) != SPECIES_EGG
&& GetMonData(mon, MON_DATA_STATUS, 0) == STATUS_NONE)) {
break;
}
ctx->beatUpCount++;
Expand Down Expand Up @@ -3771,8 +3778,11 @@ BOOL BtlCmd_BeatUpDamageCalc(BattleSystem *bsys, BATTLECONTEXT *ctx) {
if (ctx->beatUpCount < monCnt) {
while (TRUE) {
mon = BattleSystem_GetPartyMon(bsys, ctx->battlerIdAttacker, ctx->beatUpCount);
if (ctx->beatUpCount == ctx->selectedMonIndex[ctx->battlerIdAttacker] ||
(GetMonData(mon, MON_DATA_HP, 0) && GetMonData(mon, MON_DATA_SPECIES2, 0) && GetMonData(mon, MON_DATA_SPECIES2, 0) != 0x1ee && GetMonData(mon, MON_DATA_STATUS, 0) == 0)) {
if (ctx->beatUpCount == ctx->selectedMonIndex[ctx->battlerIdAttacker]
|| (GetMonData(mon, MON_DATA_HP, 0) != 0
&& GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0) != SPECIES_NONE
&& GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0) != SPECIES_EGG
&& GetMonData(mon, MON_DATA_STATUS, 0) == STATUS_NONE)) {
break;
}
ctx->beatUpCount++;
Expand Down Expand Up @@ -3879,7 +3889,8 @@ BOOL BtlCmd_TryAssist(BattleSystem *bsys, BATTLECONTEXT *ctx) {
for (i = 0; i < monCnt; i++) {
if (i != ctx->selectedMonIndex[ctx->battlerIdAttacker]) {
mon = BattleSystem_GetPartyMon(bsys, ctx->battlerIdAttacker, i);
if (GetMonData(mon, MON_DATA_SPECIES2, 0) && GetMonData(mon, MON_DATA_SPECIES2, 0) != SPECIES_EGG) {
if (GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0) != SPECIES_NONE
&& GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0) != SPECIES_EGG) {
for (j = 0; j < MAX_MON_MOVES; j++) {
move = GetMonData(mon, MON_DATA_MOVE1 + j, 0);
if (CheckMoveCallsOtherMove(move) == FALSE && CheckLegalMetronomeMove(bsys, ctx, ctx->battlerIdAttacker, move) == TRUE) {
Expand Down Expand Up @@ -4862,10 +4873,14 @@ BOOL BtlCmd_Pickup(BattleSystem *bsys, BATTLECONTEXT *ctx) {

for (i = 0; i < BattleSystem_GetPartySize(bsys, 0); i++) {
mon = BattleSystem_GetPartyMon(bsys, 0, i);
species = GetMonData(mon, MON_DATA_SPECIES2, 0);
species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0);
item = GetMonData(mon, MON_DATA_HELD_ITEM, 0);
ability = GetMonData(mon, MON_DATA_ABILITY, 0);
if (ability == ABILITY_PICKUP && species && species != SPECIES_EGG && !item && !(BattleSystem_Random(bsys)%10)) {
if (ability == ABILITY_PICKUP
&& species != SPECIES_NONE
&& species != SPECIES_EGG
&& item == ITEM_NONE
&& !(BattleSystem_Random(bsys) % 10)) {
rnd = BattleSystem_Random(bsys) % 100;
lvl = (GetMonData(mon, MON_DATA_LEVEL, 0) - 1) / 10;
if (lvl >= 10) {
Expand All @@ -4881,7 +4896,10 @@ BOOL BtlCmd_Pickup(BattleSystem *bsys, BATTLECONTEXT *ctx) {
}
}
}
if (ability == ABILITY_HONEY_GATHER && species && species != SPECIES_EGG && !item) {
if (ability == ABILITY_HONEY_GATHER
&& species != SPECIES_NONE
&& species != SPECIES_EGG
&& item == ITEM_NONE) {
j = 0;
k = 10;
lvl = GetMonData(mon, MON_DATA_LEVEL, 0);
Expand Down Expand Up @@ -5497,7 +5515,8 @@ BOOL BtlCmd_CheckWhiteout(BattleSystem *bsys, BATTLECONTEXT *ctx) {

for (i = 0; i < GetPartyCount(party1); i++) {
mon = GetPartyMonByIndex(party1, i);
if (GetMonData(mon, MON_DATA_SPECIES2, 0) != 0 && GetMonData(mon, MON_DATA_SPECIES2, 0) != SPECIES_EGG) {
if (GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0) != SPECIES_NONE
&& GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0) != SPECIES_EGG) {
partyHp += GetMonData(mon, MON_DATA_HP, 0);
}
}
Expand All @@ -5506,7 +5525,8 @@ BOOL BtlCmd_CheckWhiteout(BattleSystem *bsys, BATTLECONTEXT *ctx) {

} else for (i = 0; i < GetPartyCount(party2); i++) {
mon = GetPartyMonByIndex(party2, i);
if (GetMonData(mon, MON_DATA_SPECIES2, 0) != 0 && GetMonData(mon, MON_DATA_SPECIES2, 0) != SPECIES_EGG) {
if (GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0) != SPECIES_NONE
&& GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0) != SPECIES_EGG) {
partyHp += GetMonData(mon, MON_DATA_HP, 0);
}
}
Expand All @@ -5521,7 +5541,8 @@ BOOL BtlCmd_CheckWhiteout(BattleSystem *bsys, BATTLECONTEXT *ctx) {

for (i = 0; i < GetPartyCount(party); i++) {
mon = GetPartyMonByIndex(party, i);
if (GetMonData(mon, MON_DATA_SPECIES2, 0) != 0 && GetMonData(mon, MON_DATA_SPECIES2, 0) != SPECIES_EGG) {
if (GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0) != SPECIES_NONE
&& GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0) != SPECIES_EGG) {
partyHp += GetMonData(mon, MON_DATA_HP, 0);
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/battle/overlay_12_0224E4FC.c
Original file line number Diff line number Diff line change
Expand Up @@ -2985,7 +2985,11 @@ BOOL CanSwitchMon(BattleSystem *bsys, BATTLECONTEXT *ctx, int battlerId) {

for (i = start; i < partySize; i++) {
mon = GetPartyMonByIndex(party, i);
if (GetMonData(mon, MON_DATA_SPECIES, NULL) && !GetMonData(mon, MON_DATA_IS_EGG, NULL) && GetMonData(mon, MON_DATA_HP, NULL) && monIndex1 != i && monIndex2 != i) {
if (GetMonData(mon, MON_DATA_SPECIES, NULL) != SPECIES_NONE
&& !GetMonData(mon, MON_DATA_IS_EGG, NULL)
&& GetMonData(mon, MON_DATA_HP, NULL) != 0
&& monIndex1 != i
&& monIndex2 != i) {
cnt++;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/field/scrcmd_pokemon_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ BOOL ScrCmd_CreatePokeathlonFriendshipRoomStatues(ScriptContext *ctx) {

species = unkPtr->friendshipRoomStatues[i].species;

if (species != 0 && species <= SPECIES_ARCEUS) {
if (species != SPECIES_NONE && species <= SPECIES_ARCEUS) {
ov01_02201F98(fsys->mapObjectMan, (u8) i, species, unkPtr->friendshipRoomStatues[i].form, unkPtr->friendshipRoomStatues[i].gender, sFriendshipRoomStatuesPositions[i][0], sFriendshipRoomStatuesPositions[i][1], fsys->location->mapId);
}
}
Expand Down Expand Up @@ -1028,7 +1028,7 @@ BOOL ScrCmd_GiveTogepiEgg(ScriptContext *ctx) {
SetEggStats(mon, SPECIES_TOGEPI, 1, profile, 3, sub_02017FE4(MAPSECTYPE_GIFT, 0xd));

for (i = 0; i < MAX_MON_MOVES; i++) {
if (!GetMonData(mon, MON_DATA_MOVE1 + i, 0)) {
if (GetMonData(mon, MON_DATA_MOVE1 + i, 0) == MOVE_NONE) {
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/party.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ BOOL PartyHasMon(PARTY *party, u16 species) {
int i;

for (i = 0; i < party->core.curCount; i++) {
if (species == GetMonData(&party->core.mons[i], MON_DATA_SPECIES2, NULL)) {
if (species == GetMonData(&party->core.mons[i], MON_DATA_SPECIES_OR_EGG, NULL)) {
break;
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ static u32 GetBoxMonDataInternal(BoxPokemon *boxMon, int attr, void * dest) {
ret = blockB->isEgg;
}
break;
case MON_DATA_SPECIES2:
case MON_DATA_SPECIES_OR_EGG:
ret = blockA->species;
if (ret != SPECIES_NONE && (blockB->isEgg || boxMon->checksum_fail)) {
ret = SPECIES_EGG;
Expand Down Expand Up @@ -1698,7 +1698,7 @@ static void AddBoxMonDataInternal(BoxPokemon *boxMon, int attr, int value) {
case MON_DATA_SEAL_COORDS:
case MON_DATA_SPECIES_EXISTS:
case MON_DATA_SANITY_IS_EGG:
case MON_DATA_SPECIES2:
case MON_DATA_SPECIES_OR_EGG:
case MON_DATA_IVS_WORD:
case MON_DATA_UNK_176:
case MON_DATA_TYPE_1:
Expand Down Expand Up @@ -2041,7 +2041,7 @@ void MonApplyFriendshipMod(Pokemon *mon, u8 kind, u16 location) {
if (kind == FRIENDSHIP_EVENT_WALKING && (LCRandom() & 1))
return;

species = (u16)GetMonData(mon, MON_DATA_SPECIES2, NULL);
species = (u16)GetMonData(mon, MON_DATA_SPECIES_OR_EGG, NULL);
if (species == SPECIES_NONE || species == SPECIES_EGG)
return;

Expand Down Expand Up @@ -2157,7 +2157,7 @@ void sub_02070130(struct SomeDrawPokemonStruct *a0, BoxPokemon *boxMon, u8 which

void GetBoxmonSpriteCharAndPlttNarcIds(struct SomeDrawPokemonStruct *spC, BoxPokemon *boxMon, u8 whichFacing, BOOL sp14) {
BOOL decry = AcquireBoxMonLock(boxMon);
u16 species = GetBoxMonData(boxMon, MON_DATA_SPECIES2, NULL);
u16 species = GetBoxMonData(boxMon, MON_DATA_SPECIES_OR_EGG, NULL);
u8 gender = GetBoxMonGender(boxMon);
u8 shiny = BoxMonIsShiny(boxMon);
u32 pid = GetBoxMonData(boxMon, MON_DATA_PERSONALITY, NULL);
Expand Down Expand Up @@ -2474,7 +2474,7 @@ u8 sub_02070848(BoxPokemon *boxMon, u8 whichFacing) {
}

u8 sub_02070854(BoxPokemon *boxMon, u8 whichFacing, BOOL a2) {
u16 species = GetBoxMonData(boxMon, MON_DATA_SPECIES2, NULL);
u16 species = GetBoxMonData(boxMon, MON_DATA_SPECIES_OR_EGG, NULL);
u8 gender = GetBoxMonGender(boxMon);
u32 pid = GetBoxMonData(boxMon, MON_DATA_PERSONALITY, NULL);
u8 form;
Expand Down Expand Up @@ -3772,7 +3772,7 @@ BOOL GetBoxMonTMHMCompat(BoxPokemon *boxMon, u8 tmhm) {
u16 species;
u32 form;

species = GetBoxMonData(boxMon, MON_DATA_SPECIES2, NULL);
species = GetBoxMonData(boxMon, MON_DATA_SPECIES_OR_EGG, NULL);
form = GetBoxMonData(boxMon, MON_DATA_FORM, NULL);
return GetTMHMCompatBySpeciesAndForm(species, form, tmhm);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pokemon_icon_idx.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ u32 GetBattleMonIconNaixEx(u32 species, BOOL isEgg, u32 form) {
}

static u16 BoxMonGetForm(BoxPokemon *boxMon) {
switch (GetBoxMonData(boxMon, MON_DATA_SPECIES2, NULL)) {
switch (GetBoxMonData(boxMon, MON_DATA_SPECIES_OR_EGG, NULL)) {
case SPECIES_UNOWN:
return GetBoxMonUnownLetter(boxMon);
case SPECIES_DEOXYS:
Expand Down
4 changes: 2 additions & 2 deletions src/pokemon_mood.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ void ApplyMonMoodModifier(Pokemon *mon, int modifierId) {
u16 species;
s32 adjustedMood;

species = GetMonData(mon, MON_DATA_SPECIES2, NULL);
species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG, NULL);

if (species != 0 && species != SPECIES_EGG) {
if (species != SPECIES_NONE && species != SPECIES_EGG) {
mood = GetMonData(mon, MON_DATA_MOOD, NULL);

adjustedMood = mood + sMoodModifiers[modifierId];
Expand Down
2 changes: 1 addition & 1 deletion src/unk_02097F6C.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ void GetSwarmInfoFromRand(u32 rand, u16 *mapno, u16 *species) {
*species = encData.swarmSpecies[0];
break;
}
GF_ASSERT(*species != 0);
GF_ASSERT(*species != SPECIES_NONE);
*mapno = (*swarmMap)[0];
}