From 21df8c279b36507b9215441af7f0cda1a8e11305 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 9 Sep 2022 08:59:53 -0400 Subject: [PATCH] Added SPECIES_FLAG_CANNOT_BE_TRADED - Also corrected Cylarex's forms not having the legendary flag --- include/constants/pokemon.h | 1 + include/constants/trade.h | 11 ++++++----- include/strings.h | 2 +- src/data/party_menu.h | 4 ++-- src/data/pokemon/base_stats.h | 10 ++++++---- src/party_menu.c | 5 ++++- src/strings.c | 1 + src/trade.c | 24 ++++++++++++++++++++---- 8 files changed, 41 insertions(+), 17 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 60bca5a838..55f13caf96 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -352,6 +352,7 @@ #define SPECIES_FLAG_GENDER_DIFFERENCE (1 << 6) #define SPECIES_FLAG_ALL_PERFECT_IVS (1 << 7) #define SPECIES_FLAG_SHINY_LOCKED (1 << 8) +#define SPECIES_FLAG_CANNOT_BE_TRADED (1 << 9) #define LEGENDARY_PERFECT_IV_COUNT 3 diff --git a/include/constants/trade.h b/include/constants/trade.h index fa42e6b43f..e8afc2a77f 100644 --- a/include/constants/trade.h +++ b/include/constants/trade.h @@ -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 diff --git a/include/strings.h b/include/strings.h index 25a96eef08..d71daf4160 100644 --- a/include/strings.h +++ b/include/strings.h @@ -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[]; @@ -2154,7 +2155,6 @@ extern const u8 gText_Switch2[]; extern const u8 gText_Item[]; extern const u8 gText_NotPkmnOtherTrainerWants[]; extern const u8 gText_ThatIsntAnEgg[]; -extern const u8 gText_PkmnCantBeTradedNow[]; extern const u8 gText_OtherTrainersPkmnCantBeTraded[]; extern const u8 gText_EggCantBeTradedNow[]; extern const u8 gText_OtherTrainerCantAcceptPkmn[]; diff --git a/src/data/party_menu.h b/src/data/party_menu.h index 9411ec3bb7..8d871c2022 100644 --- a/src/data/party_menu.h +++ b/src/data/party_menu.h @@ -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, diff --git a/src/data/pokemon/base_stats.h b/src/data/pokemon/base_stats.h index bb85f2840f..2a3798dcb6 100644 --- a/src/data/pokemon/base_stats.h +++ b/src/data/pokemon/base_stats.h @@ -25974,7 +25974,7 @@ const struct BaseStats gBaseStats[] = .abilities = {ABILITY_TURBOBLAZE, ABILITY_NONE}, .bodyColor = BODY_COLOR_GRAY, .noFlip = TRUE, - .flags = SPECIES_FLAG_LEGENDARY, + .flags = SPECIES_FLAG_LEGENDARY | SPECIES_FLAG_CANNOT_BE_TRADED, }, [SPECIES_KYUREM_BLACK] = @@ -25999,7 +25999,7 @@ const struct BaseStats gBaseStats[] = .abilities = {ABILITY_TERAVOLT, ABILITY_NONE}, .bodyColor = BODY_COLOR_GRAY, .noFlip = TRUE, - .flags = SPECIES_FLAG_LEGENDARY, + .flags = SPECIES_FLAG_LEGENDARY | SPECIES_FLAG_CANNOT_BE_TRADED, }, [SPECIES_KELDEO_RESOLUTE] = @@ -26489,7 +26489,7 @@ const struct BaseStats gBaseStats[] = .abilities = {ABILITY_PRISM_ARMOR, ABILITY_NONE}, .bodyColor = BODY_COLOR_YELLOW, .noFlip = TRUE, - .flags = SPECIES_FLAG_LEGENDARY, + .flags = SPECIES_FLAG_LEGENDARY | SPECIES_FLAG_CANNOT_BE_TRADED, }, [SPECIES_NECROZMA_DAWN_WINGS] = @@ -26514,7 +26514,7 @@ const struct BaseStats gBaseStats[] = .abilities = {ABILITY_PRISM_ARMOR, ABILITY_NONE}, .bodyColor = BODY_COLOR_BLUE, .noFlip = TRUE, - .flags = SPECIES_FLAG_LEGENDARY, + .flags = SPECIES_FLAG_LEGENDARY | SPECIES_FLAG_CANNOT_BE_TRADED, }, [SPECIES_NECROZMA_ULTRA] = @@ -26738,6 +26738,7 @@ const struct BaseStats gBaseStats[] = .abilities = {ABILITY_AS_ONE_ICE_RIDER, ABILITY_NONE}, .bodyColor = BODY_COLOR_WHITE, .noFlip = FALSE, + .flags = SPECIES_FLAG_LEGENDARY | SPECIES_FLAG_CANNOT_BE_TRADED, }, [SPECIES_CALYREX_SHADOW_RIDER] = @@ -26762,6 +26763,7 @@ const struct BaseStats gBaseStats[] = .abilities = {ABILITY_AS_ONE_SHADOW_RIDER, ABILITY_NONE}, .bodyColor = BODY_COLOR_BLACK, .noFlip = FALSE, + .flags = SPECIES_FLAG_LEGENDARY | SPECIES_FLAG_CANNOT_BE_TRADED, }, #endif }; diff --git a/src/party_menu.c b/src/party_menu.c index 00224f6bd6..3fe52231af 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -3587,9 +3587,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; diff --git a/src/strings.c b/src/strings.c index d199b92d4b..b951c8ff5e 100644 --- a/src/strings.c +++ b/src/strings.c @@ -478,6 +478,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."); diff --git a/src/trade.c b/src/trade.c index abf35f26a4..8ff31bfd0c 100644 --- a/src/trade.c +++ b/src/trade.c @@ -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