mirror of
https://github.com/risingPhil/libpokemegb.git
synced 2026-09-12 02:47:28 -05:00
Add a function to unlock the Egg Ticket for Japanese Pokémon Crystal
This commit is contained in:
@@ -12,6 +12,7 @@ typedef struct Gen2DistributionPokemon Gen2DistributionPokemon;
|
||||
|
||||
// source: https://bulbapedia.bulbagarden.net/wiki/List_of_items_by_index_number_(Generation_II)
|
||||
#define CRYSTAL_ITEM_ID_GS_BALL 0x73
|
||||
#define CRYSTAL_ITEM_ID_EGG_TICKET 0x81
|
||||
|
||||
// Based on https://github.com/kwsch/PKHeX/blob/master/PKHeX.Core/Resources/text/script/gen2/flags_c_en.txt
|
||||
// Look at this file to see more events
|
||||
@@ -19,6 +20,7 @@ typedef struct Gen2DistributionPokemon Gen2DistributionPokemon;
|
||||
#define CRYSTAL_EVENTFLAG_KURT_READY_TO_RETURN_GSBALL 191
|
||||
#define CRYSTAL_EVENTFLAG_GSBALL_USABLE_IN_ILEX_FOREST_SHRINE 192
|
||||
#define CRYSTAL_EVENTFLAG_RECEIVED_GSBALL 832
|
||||
#define CRYSTAL_EVENTFLAG_EGG_TICKET 830
|
||||
#define CRYSTAL_GS_BALL_ENABLE_VALUE 0xB
|
||||
|
||||
enum class Gen2GameType
|
||||
|
||||
@@ -215,6 +215,11 @@ public:
|
||||
*/
|
||||
void unlockGsBallEvent();
|
||||
|
||||
/**
|
||||
* @brief This function unlocks the Egg Ticket in Japanese Pokémon Crystal saves.
|
||||
*/
|
||||
void unlockEggTicketEvent();
|
||||
|
||||
/**
|
||||
* @brief Retrieves the value of the given event flag
|
||||
* Hint: You can find the number and meaning of various event flags here:
|
||||
|
||||
@@ -876,6 +876,20 @@ void Gen2GameReader::unlockGsBallEvent()
|
||||
saveManager_.writeByte(CRYSTAL_GS_BALL_ENABLE_VALUE);
|
||||
}
|
||||
|
||||
void Gen2GameReader::unlockEggTicketEvent()
|
||||
{
|
||||
if(!isGameCrystal() || getGameLanguage() != Gen2LocalizationLanguage::JAPANESE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// let's remove the Egg Ticket from the players' inventory first (if it exists)
|
||||
Gen2ItemList itemList = getItemList(Gen2ItemListType::GEN2_ITEMLISTTYPE_KEYITEMPOCKET);
|
||||
itemList.remove(CRYSTAL_ITEM_ID_EGG_TICKET);
|
||||
|
||||
setEventFlag(CRYSTAL_EVENTFLAG_EGG_TICKET, true);
|
||||
}
|
||||
|
||||
bool Gen2GameReader::getEventFlag(uint16_t flagNumber)
|
||||
{
|
||||
const uint32_t saveOffset = gen2_getSRAMOffsets(gameType_, localization_).eventFlags;
|
||||
|
||||
Reference in New Issue
Block a user