Merge pull request #2293 from AsparagusEduardo/RHH/pr/pokemonFlags

4 new species flags
This commit is contained in:
ghoulslash 2022-10-07 10:55:43 -04:00 committed by GitHub
commit 441586f23f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 334 additions and 250 deletions

View file

@ -340,13 +340,17 @@
#define NUM_HIDDEN_ABILITY_SLOTS 1
// Species Flags
#define FLAG_LEGENDARY (1 << 0)
#define FLAG_MYTHICAL (1 << 1)
#define FLAG_ULTRA_BEAST (1 << 2)
#define FLAG_ALOLAN_FORM (1 << 3)
#define FLAG_GALARIAN_FORM (1 << 4)
#define FLAG_HISUIAN_FORM (1 << 5)
#define FLAG_GENDER_DIFFERENCE (1 << 6)
#define SPECIES_FLAG_LEGENDARY (1 << 0)
#define SPECIES_FLAG_MYTHICAL (1 << 1)
#define SPECIES_FLAG_MEGA_EVOLUTION (1 << 2)
#define SPECIES_FLAG_ULTRA_BEAST (1 << 3)
#define SPECIES_FLAG_ALOLAN_FORM (1 << 4)
#define SPECIES_FLAG_GALARIAN_FORM (1 << 5)
#define SPECIES_FLAG_HISUIAN_FORM (1 << 6)
#define SPECIES_FLAG_GENDER_DIFFERENCE (1 << 7)
#define SPECIES_FLAG_ALL_PERFECT_IVS (1 << 8)
#define SPECIES_FLAG_SHINY_LOCKED (1 << 9)
#define SPECIES_FLAG_CANNOT_BE_TRADED (1 << 10)
#define LEGENDARY_PERFECT_IV_COUNT 3

View file

@ -99,8 +99,8 @@
#define UR_TRADE_MSG_NONE 0
#define UR_TRADE_MSG_NOT_MON_PARTNER_WANTS 1
#define UR_TRADE_MSG_NOT_EGG 2
#define UR_TRADE_MSG_MON_CANT_BE_TRADED_1 3
#define UR_TRADE_MSG_MON_CANT_BE_TRADED_2 4
#define UR_TRADE_MSG_MON_CANT_BE_TRADED_NOW 3
#define UR_TRADE_MSG_MON_CANT_BE_TRADED 4
#define UR_TRADE_MSG_PARTNERS_MON_CANT_BE_TRADED 5
#define UR_TRADE_MSG_EGG_CANT_BE_TRADED 6
#define UR_TRADE_MSG_PARTNER_CANT_ACCEPT_MON 7
@ -108,9 +108,10 @@
#define UR_TRADE_MSG_CANT_TRADE_WITH_PARTNER_2 9
// Return values for CanRegisterMonForTradingBoard
#define CAN_REGISTER_MON 0
#define CANT_REGISTER_MON 1
#define CANT_REGISTER_EGG 2
#define CAN_REGISTER_MON 0
#define CANT_REGISTER_MON_NOW 1
#define CANT_REGISTER_MON 2
#define CANT_REGISTER_EGG 3
#endif //GUARD_CONSTANTS_TRADE_H

View file

@ -324,7 +324,7 @@ struct BaseStats
u8 safariZoneFleeRate;
u8 bodyColor : 7;
u8 noFlip : 1;
u8 flags;
u16 flags;
};
#include "constants/battle_config.h"

View file

@ -464,6 +464,7 @@ extern const u8 gText_MailMessageWillBeLost[];
extern const u8 gText_MailTakenFromPkmn[];
extern const u8 gText_NoMoreThanVar1Pkmn[];
extern const u8 gText_PkmnCantBeTradedNow[];
extern const u8 gText_PkmnCantBeTraded[];
extern const u8 gText_EggCantBeTradedNow[];
extern const u8 gText_OnlyPkmnForBattle[];
extern const u8 gJPText_AreYouSureYouWantToSpinTradeMon[];

View file

@ -13912,7 +13912,7 @@ static void Cmd_handleballthrow(void)
else
catchRate = gBaseStats[gBattleMons[gBattlerTarget].species].catchRate;
if (gBaseStats[gBattleMons[gBattlerTarget].species].flags & FLAG_ULTRA_BEAST)
if (gBaseStats[gBattleMons[gBattlerTarget].species].flags & SPECIES_FLAG_ULTRA_BEAST)
{
if (gLastUsedItem == ITEM_BEAST_BALL)
ballMultiplier = 500;

View file

@ -789,8 +789,8 @@ static const u8 *const sUnionRoomTradeMessages[] =
{
[UR_TRADE_MSG_NOT_MON_PARTNER_WANTS - 1] = gText_NotPkmnOtherTrainerWants,
[UR_TRADE_MSG_NOT_EGG - 1] = gText_ThatIsntAnEgg,
[UR_TRADE_MSG_MON_CANT_BE_TRADED_1 - 1] = gText_PkmnCantBeTradedNow,
[UR_TRADE_MSG_MON_CANT_BE_TRADED_2 - 1] = gText_PkmnCantBeTradedNow,
[UR_TRADE_MSG_MON_CANT_BE_TRADED_NOW - 1] = gText_PkmnCantBeTradedNow,
[UR_TRADE_MSG_MON_CANT_BE_TRADED - 1] = gText_PkmnCantBeTraded,
[UR_TRADE_MSG_PARTNERS_MON_CANT_BE_TRADED - 1] = gText_OtherTrainersPkmnCantBeTraded,
[UR_TRADE_MSG_EGG_CANT_BE_TRADED -1] = gText_EggCantBeTradedNow,
[UR_TRADE_MSG_PARTNER_CANT_ACCEPT_MON - 1] = gText_OtherTrainerCantAcceptPkmn,

File diff suppressed because it is too large Load diff

View file

@ -3586,9 +3586,12 @@ static void CursorCb_Register(u8 taskId)
switch (CanRegisterMonForTradingBoard(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), species2, species, isEventLegal))
{
case CANT_REGISTER_MON:
case CANT_REGISTER_MON_NOW:
StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow);
break;
case CANT_REGISTER_MON:
StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTraded);
break;
case CANT_REGISTER_EGG:
StringExpandPlaceholders(gStringVar4, gText_EggCantBeTradedNow);
break;

View file

@ -3303,14 +3303,23 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV,
}
else // Player is the OT
{
u32 shinyValue;
value = gSaveBlock2Ptr->playerTrainerId[0]
| (gSaveBlock2Ptr->playerTrainerId[1] << 8)
| (gSaveBlock2Ptr->playerTrainerId[2] << 16)
| (gSaveBlock2Ptr->playerTrainerId[3] << 24);
if (CheckBagHasItem(ITEM_SHINY_CHARM, 1))
if (gBaseStats[species].flags & SPECIES_FLAG_SHINY_LOCKED)
{
do
{
// Choose random personalities until one that results in a non-shiny Pokémon
personality = Random32();
shinyValue = HIHALF(value) ^ LOHALF(value) ^ HIHALF(personality) ^ LOHALF(personality);
} while (shinyValue < SHINY_ODDS);
}
else if (CheckBagHasItem(ITEM_SHINY_CHARM, 1))
{
u32 shinyValue;
u32 rolls = 0;
do
{
@ -3372,8 +3381,18 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV,
iv = (value & (MAX_IV_MASK << 10)) >> 10;
SetBoxMonData(boxMon, MON_DATA_SPDEF_IV, &iv);
if (gBaseStats[species].flags & SPECIES_FLAG_ALL_PERFECT_IVS)
{
iv = MAX_PER_STAT_IVS;
SetBoxMonData(boxMon, MON_DATA_HP_IV, &iv);
SetBoxMonData(boxMon, MON_DATA_ATK_IV, &iv);
SetBoxMonData(boxMon, MON_DATA_DEF_IV, &iv);
SetBoxMonData(boxMon, MON_DATA_SPEED_IV, &iv);
SetBoxMonData(boxMon, MON_DATA_SPATK_IV, &iv);
SetBoxMonData(boxMon, MON_DATA_SPDEF_IV, &iv);
}
#if P_LEGENDARY_PERFECT_IVS >= GEN_6
if (gBaseStats[species].flags & (FLAG_LEGENDARY | FLAG_MYTHICAL | FLAG_ULTRA_BEAST))
else if (gBaseStats[species].flags & (SPECIES_FLAG_LEGENDARY | SPECIES_FLAG_MYTHICAL | SPECIES_FLAG_ULTRA_BEAST))
{
iv = MAX_PER_STAT_IVS;
// Initialize a list of IV indices.
@ -3393,29 +3412,28 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV,
{
switch (selectedIvs[i])
{
case STAT_HP:
SetBoxMonData(boxMon, MON_DATA_HP_IV, &iv);
break;
case STAT_ATK:
SetBoxMonData(boxMon, MON_DATA_ATK_IV, &iv);
break;
case STAT_DEF:
SetBoxMonData(boxMon, MON_DATA_DEF_IV, &iv);
break;
case STAT_SPEED:
SetBoxMonData(boxMon, MON_DATA_SPEED_IV, &iv);
break;
case STAT_SPATK:
SetBoxMonData(boxMon, MON_DATA_SPATK_IV, &iv);
break;
case STAT_SPDEF:
SetBoxMonData(boxMon, MON_DATA_SPDEF_IV, &iv);
break;
case STAT_HP:
SetBoxMonData(boxMon, MON_DATA_HP_IV, &iv);
break;
case STAT_ATK:
SetBoxMonData(boxMon, MON_DATA_ATK_IV, &iv);
break;
case STAT_DEF:
SetBoxMonData(boxMon, MON_DATA_DEF_IV, &iv);
break;
case STAT_SPEED:
SetBoxMonData(boxMon, MON_DATA_SPEED_IV, &iv);
break;
case STAT_SPATK:
SetBoxMonData(boxMon, MON_DATA_SPATK_IV, &iv);
break;
case STAT_SPDEF:
SetBoxMonData(boxMon, MON_DATA_SPDEF_IV, &iv);
break;
}
}
}
#endif
}
if (gBaseStats[species].abilities[1])
@ -8427,7 +8445,7 @@ void TrySpecialOverworldEvo(void)
bool32 ShouldShowFemaleDifferences(u16 species, u32 personality)
{
return (gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE;
return (gBaseStats[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE;
}
void TryToSetBattleFormChangeMoves(struct Pokemon *mon)

View file

@ -417,21 +417,21 @@ static void PrintInstructionsOnWindow(struct PokemonDebugMenu *data)
FillWindowPixelBuffer(WIN_INSTRUCTIONS, 0x11);
if (data->currentSubmenu == 0)
{
if (gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE)
if (gBaseStats[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE)
AddTextPrinterParameterized(WIN_INSTRUCTIONS, fontId, textInstructionsGender, x, 0, 0, NULL);
else
AddTextPrinterParameterized(WIN_INSTRUCTIONS, fontId, textInstructions, x, 0, 0, NULL);
}
else if (data->currentSubmenu == 1)
{
if (gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE)
if (gBaseStats[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE)
AddTextPrinterParameterized(WIN_INSTRUCTIONS, fontId, textInstructionsSubmenuOneGender, x, 0, 0, NULL);
else
AddTextPrinterParameterized(WIN_INSTRUCTIONS, fontId, textInstructionsSubmenuOne, x, 0, 0, NULL);
}
else if (data->currentSubmenu == 2)
{
if (gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE)
if (gBaseStats[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE)
AddTextPrinterParameterized(WIN_INSTRUCTIONS, fontId, textInstructionsSubmenuTwoGender, x, 0, 0, NULL);
else
AddTextPrinterParameterized(WIN_INSTRUCTIONS, fontId, textInstructionsSubmenuTwo, x, 0, 0, NULL);
@ -485,7 +485,7 @@ static void PrintDigitChars(struct PokemonDebugMenu *data)
text[i++] = CHAR_SPACE;
text[i++] = CHAR_HYPHEN;
if (gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE)
if (gBaseStats[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE)
{
if (data->isFemale)
text[i++] = CHAR_FEMALE;
@ -688,14 +688,14 @@ static const struct CompressedSpritePalette *GetMonSpritePalStructCustom(u16 spe
{
if (isShiny)
{
if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && isFemale)
if ((gBaseStats[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE) && isFemale)
return &gMonShinyPaletteTableFemale[species];
else
return &gMonShinyPaletteTable[species];
}
else
{
if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && isFemale)
if ((gBaseStats[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE) && isFemale)
return &gMonPaletteTableFemale[species];
else
return &gMonPaletteTable[species];
@ -714,14 +714,14 @@ static void BattleLoadOpponentMonSpriteGfxCustom(u16 species, bool8 isFemale, bo
if (isShiny)
{
if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && isFemale)
if ((gBaseStats[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE) && isFemale)
lzPaletteData = gMonShinyPaletteTableFemale[species].data;
else
lzPaletteData = gMonShinyPaletteTable[species].data;
}
else
{
if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && isFemale)
if ((gBaseStats[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE) && isFemale)
lzPaletteData = gMonPaletteTableFemale[species].data;
else
lzPaletteData = gMonPaletteTable[species].data;
@ -1493,7 +1493,7 @@ static void Handle_Input_Debug_Pokemon(u8 taskId)
ReloadPokemonSprites(data);
ApplyOffsetSpriteValues(data);
}
if (JOY_NEW(SELECT_BUTTON) && (gBaseStats[data->currentmonId].flags & FLAG_GENDER_DIFFERENCE))
if (JOY_NEW(SELECT_BUTTON) && (gBaseStats[data->currentmonId].flags & SPECIES_FLAG_GENDER_DIFFERENCE))
{
data->isFemale = !data->isFemale;
PrintDigitChars(data);

View file

@ -479,6 +479,7 @@ const u8 gText_PauseUntilPress[] = _("{PAUSE_UNTIL_PRESS}");
const u8 gJPText_AreYouSureYouWantToSpinTradeMon[] = _("{STR_VAR_1}を ぐるぐるこうかんに\nだして よろしいですか?");
ALIGNED(4) const u8 gText_OnlyPkmnForBattle[] = _("That's your only\nPOKéMON for battle.");
ALIGNED(4) const u8 gText_PkmnCantBeTradedNow[] = _("That POKéMON can't be traded\nnow.");
ALIGNED(4) const u8 gText_PkmnCantBeTraded[] = _("That POKéMON can't be traded.");
ALIGNED(4) const u8 gText_EggCantBeTradedNow[] = _("An EGG can't be traded now.");
ALIGNED(4) const u8 gText_OtherTrainersPkmnCantBeTraded[] = _("The other TRAINER's POKéMON\ncan't be traded now.");
ALIGNED(4) const u8 gText_OtherTrainerCantAcceptPkmn[] = _("The other TRAINER can't accept\nthat POKéMON now.");

View file

@ -1504,6 +1504,10 @@ static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 player
return PARTNER_MON_INVALID;
}
// Can't trade specific species
if (gBaseStats[partnerSpecies].flags & SPECIES_FLAG_CANNOT_BE_TRADED)
return PARTNER_MON_INVALID;
// Partner cant trade Egg or non-Hoenn mon if player doesn't have National Dex
if (!IsNationalPokedexEnabled())
{
@ -2360,6 +2364,10 @@ static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int
return CANT_TRADE_INVALID_MON;
}
// Can't trade specific species
if (gBaseStats[species[monIdx]].flags & SPECIES_FLAG_CANNOT_BE_TRADED)
return CANT_TRADE_INVALID_MON;
// Make Eggs not count for numMonsLeft
for (i = 0; i < partyCount; i++)
{
@ -2450,7 +2458,11 @@ int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct Rf
// Cannot trade illegitimate Deoxys/Mew
if (IsDeoxysOrMewUntradable(playerSpecies, isEventLegal))
return UR_TRADE_MSG_MON_CANT_BE_TRADED_2;
return UR_TRADE_MSG_MON_CANT_BE_TRADED;
// Can't trade specific species
if (gBaseStats[playerSpecies].flags & SPECIES_FLAG_CANNOT_BE_TRADED)
return UR_TRADE_MSG_MON_CANT_BE_TRADED;
if (partnerSpecies == SPECIES_EGG)
{
@ -2469,7 +2481,7 @@ int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct Rf
// If the player is trading an Egg then the partner must also be trading an Egg
// Odd that this wasn't checked earlier, as by this point we know either the partner doesn't have an Egg or that both do.
if (playerSpecies2 == SPECIES_EGG && playerSpecies2 != partnerSpecies)
return UR_TRADE_MSG_MON_CANT_BE_TRADED_1;
return UR_TRADE_MSG_MON_CANT_BE_TRADED_NOW;
// If the player doesn't have the National Dex then Eggs and non-Hoenn Pokémon can't be traded
if (!playerHasNationalDex)
@ -2478,7 +2490,7 @@ int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct Rf
return UR_TRADE_MSG_EGG_CANT_BE_TRADED;
if (!IsSpeciesInHoennDex(playerSpecies2))
return UR_TRADE_MSG_MON_CANT_BE_TRADED_2;
return UR_TRADE_MSG_MON_CANT_BE_TRADED_NOW;
if (!IsSpeciesInHoennDex(partnerSpecies))
return UR_TRADE_MSG_PARTNERS_MON_CANT_BE_TRADED;
@ -2497,6 +2509,10 @@ int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 sp
bool8 hasNationalDex = player.hasNationalDex;
if (IsDeoxysOrMewUntradable(species, isEventLegal))
return CANT_REGISTER_MON_NOW;
// Can't trade specific species
if (gBaseStats[species].flags & SPECIES_FLAG_CANNOT_BE_TRADED)
return CANT_REGISTER_MON;
if (hasNationalDex)
@ -2509,7 +2525,7 @@ int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 sp
if (IsSpeciesInHoennDex(species2))
return CAN_REGISTER_MON;
return CANT_REGISTER_MON;
return CANT_REGISTER_MON_NOW;
}
// Spin Trade wasnt fully implemented, but this checks if a mon would be valid to Spin Trade