mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 11:44:17 +01:00
Merge pull request #1640 from GriffinRichards/doc-egg-hatch
Improve egg hatch documentation
This commit is contained in:
commit
ce227aa055
Before Width: | Height: | Size: 469 B After Width: | Height: | Size: 469 B |
Before Width: | Height: | Size: 189 B After Width: | Height: | Size: 189 B |
472
src/egg_hatch.c
472
src/egg_hatch.c
@ -37,16 +37,24 @@
|
|||||||
#include "battle.h" // to get rid of later
|
#include "battle.h" // to get rid of later
|
||||||
#include "constants/rgb.h"
|
#include "constants/rgb.h"
|
||||||
|
|
||||||
|
#define GFXTAG_EGG 12345
|
||||||
|
#define GFXTAG_EGG_SHARD 23456
|
||||||
|
|
||||||
|
#define PALTAG_EGG 54321
|
||||||
|
|
||||||
|
#define EGG_X (DISPLAY_WIDTH / 2)
|
||||||
|
#define EGG_Y (DISPLAY_HEIGHT / 2 - 5)
|
||||||
|
|
||||||
struct EggHatchData
|
struct EggHatchData
|
||||||
{
|
{
|
||||||
u8 eggSpriteID;
|
u8 eggSpriteId;
|
||||||
u8 pokeSpriteID;
|
u8 monSpriteId;
|
||||||
u8 CB2_state;
|
u8 state;
|
||||||
u8 CB2_PalCounter;
|
u8 delayTimer;
|
||||||
u8 eggPartyID;
|
u8 eggPartyId;
|
||||||
u8 unused_5;
|
u8 unused_5;
|
||||||
u8 unused_6;
|
u8 unused_6;
|
||||||
u8 eggShardVelocityID;
|
u8 eggShardVelocityId;
|
||||||
u8 windowId;
|
u8 windowId;
|
||||||
u8 unused_9;
|
u8 unused_9;
|
||||||
u8 unused_A;
|
u8 unused_A;
|
||||||
@ -58,29 +66,27 @@ extern const u32 gTradePlatform_Tilemap[];
|
|||||||
extern const u8 gText_HatchedFromEgg[];
|
extern const u8 gText_HatchedFromEgg[];
|
||||||
extern const u8 gText_NicknameHatchPrompt[];
|
extern const u8 gText_NicknameHatchPrompt[];
|
||||||
|
|
||||||
static void Task_EggHatch(u8 taskID);
|
static void Task_EggHatch(u8);
|
||||||
static void CB2_EggHatch_0(void);
|
static void CB2_LoadEggHatch(void);
|
||||||
static void CB2_EggHatch_1(void);
|
static void CB2_EggHatch(void);
|
||||||
static void SpriteCB_Egg_0(struct Sprite* sprite);
|
static void SpriteCB_Egg_Shake1(struct Sprite*);
|
||||||
static void SpriteCB_Egg_1(struct Sprite* sprite);
|
static void SpriteCB_Egg_Shake2(struct Sprite*);
|
||||||
static void SpriteCB_Egg_2(struct Sprite* sprite);
|
static void SpriteCB_Egg_Shake3(struct Sprite*);
|
||||||
static void SpriteCB_Egg_3(struct Sprite* sprite);
|
static void SpriteCB_Egg_WaitHatch(struct Sprite*);
|
||||||
static void SpriteCB_Egg_4(struct Sprite* sprite);
|
static void SpriteCB_Egg_Hatch(struct Sprite*);
|
||||||
static void SpriteCB_Egg_5(struct Sprite* sprite);
|
static void SpriteCB_Egg_Reveal(struct Sprite*);
|
||||||
static void SpriteCB_EggShard(struct Sprite* sprite);
|
static void SpriteCB_EggShard(struct Sprite*);
|
||||||
static void EggHatchPrintMessage(u8 windowId, u8* string, u8 x, u8 y, u8 speed);
|
static void EggHatchPrintMessage(u8, u8*, u8, u8, u8);
|
||||||
static void CreateRandomEggShardSprite(void);
|
static void CreateRandomEggShardSprite(void);
|
||||||
static void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8 spriteAnimIndex);
|
static void CreateEggShardSprite(u8, u8, s16, s16, s16, u8);
|
||||||
|
|
||||||
// IWRAM bss
|
|
||||||
static struct EggHatchData *sEggHatchData;
|
static struct EggHatchData *sEggHatchData;
|
||||||
|
|
||||||
// rom data
|
|
||||||
static const u16 sEggPalette[] = INCBIN_U16("graphics/pokemon/egg/normal.gbapal");
|
static const u16 sEggPalette[] = INCBIN_U16("graphics/pokemon/egg/normal.gbapal");
|
||||||
static const u8 sEggHatchTiles[] = INCBIN_U8("graphics/misc/egg_hatch.4bpp");
|
static const u8 sEggHatchTiles[] = INCBIN_U8("graphics/pokemon/egg/hatch.4bpp");
|
||||||
static const u8 sEggShardTiles[] = INCBIN_U8("graphics/misc/egg_shard.4bpp");
|
static const u8 sEggShardTiles[] = INCBIN_U8("graphics/pokemon/egg/shard.4bpp");
|
||||||
|
|
||||||
static const struct OamData sOamData_EggHatch =
|
static const struct OamData sOamData_Egg =
|
||||||
{
|
{
|
||||||
.y = 0,
|
.y = 0,
|
||||||
.affineMode = ST_OAM_AFFINE_OFF,
|
.affineMode = ST_OAM_AFFINE_OFF,
|
||||||
@ -97,64 +103,71 @@ static const struct OamData sOamData_EggHatch =
|
|||||||
.affineParam = 0,
|
.affineParam = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const union AnimCmd sSpriteAnim_EggHatch0[] =
|
static const union AnimCmd sSpriteAnim_Egg_Normal[] =
|
||||||
{
|
{
|
||||||
ANIMCMD_FRAME(0, 5),
|
ANIMCMD_FRAME(0, 5),
|
||||||
ANIMCMD_END
|
ANIMCMD_END
|
||||||
};
|
};
|
||||||
|
|
||||||
static const union AnimCmd sSpriteAnim_EggHatch1[] =
|
static const union AnimCmd sSpriteAnim_Egg_Cracked1[] =
|
||||||
{
|
{
|
||||||
ANIMCMD_FRAME(16, 5),
|
ANIMCMD_FRAME(16, 5),
|
||||||
ANIMCMD_END
|
ANIMCMD_END
|
||||||
};
|
};
|
||||||
|
|
||||||
static const union AnimCmd sSpriteAnim_EggHatch2[] =
|
static const union AnimCmd sSpriteAnim_Egg_Cracked2[] =
|
||||||
{
|
{
|
||||||
ANIMCMD_FRAME(32, 5),
|
ANIMCMD_FRAME(32, 5),
|
||||||
ANIMCMD_END
|
ANIMCMD_END
|
||||||
};
|
};
|
||||||
|
|
||||||
static const union AnimCmd sSpriteAnim_EggHatch3[] =
|
static const union AnimCmd sSpriteAnim_Egg_Cracked3[] =
|
||||||
{
|
{
|
||||||
ANIMCMD_FRAME(48, 5),
|
ANIMCMD_FRAME(48, 5),
|
||||||
ANIMCMD_END
|
ANIMCMD_END
|
||||||
};
|
};
|
||||||
|
|
||||||
static const union AnimCmd *const sSpriteAnimTable_EggHatch[] =
|
enum {
|
||||||
|
EGG_ANIM_NORMAL,
|
||||||
|
EGG_ANIM_CRACKED_1,
|
||||||
|
EGG_ANIM_CRACKED_2,
|
||||||
|
EGG_ANIM_CRACKED_3,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const union AnimCmd *const sSpriteAnimTable_Egg[] =
|
||||||
{
|
{
|
||||||
sSpriteAnim_EggHatch0,
|
[EGG_ANIM_NORMAL] = sSpriteAnim_Egg_Normal,
|
||||||
sSpriteAnim_EggHatch1,
|
[EGG_ANIM_CRACKED_1] = sSpriteAnim_Egg_Cracked1,
|
||||||
sSpriteAnim_EggHatch2,
|
[EGG_ANIM_CRACKED_2] = sSpriteAnim_Egg_Cracked2,
|
||||||
sSpriteAnim_EggHatch3,
|
[EGG_ANIM_CRACKED_3] = sSpriteAnim_Egg_Cracked3,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct SpriteSheet sEggHatch_Sheet =
|
static const struct SpriteSheet sEggHatch_Sheet =
|
||||||
{
|
{
|
||||||
.data = sEggHatchTiles,
|
.data = sEggHatchTiles,
|
||||||
.size = 2048,
|
.size = 0x800,
|
||||||
.tag = 12345,
|
.tag = GFXTAG_EGG,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct SpriteSheet sEggShards_Sheet =
|
static const struct SpriteSheet sEggShards_Sheet =
|
||||||
{
|
{
|
||||||
.data = sEggShardTiles,
|
.data = sEggShardTiles,
|
||||||
.size = 128,
|
.size = 0x80,
|
||||||
.tag = 23456,
|
.tag = GFXTAG_EGG_SHARD,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct SpritePalette sEgg_SpritePalette =
|
static const struct SpritePalette sEgg_SpritePalette =
|
||||||
{
|
{
|
||||||
.data = sEggPalette,
|
.data = sEggPalette,
|
||||||
.tag = 54321
|
.tag = PALTAG_EGG
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct SpriteTemplate sSpriteTemplate_EggHatch =
|
static const struct SpriteTemplate sSpriteTemplate_Egg =
|
||||||
{
|
{
|
||||||
.tileTag = 12345,
|
.tileTag = GFXTAG_EGG,
|
||||||
.paletteTag = 54321,
|
.paletteTag = PALTAG_EGG,
|
||||||
.oam = &sOamData_EggHatch,
|
.oam = &sOamData_Egg,
|
||||||
.anims = sSpriteAnimTable_EggHatch,
|
.anims = sSpriteAnimTable_Egg,
|
||||||
.images = NULL,
|
.images = NULL,
|
||||||
.affineAnims = gDummySpriteAffineAnimTable,
|
.affineAnims = gDummySpriteAffineAnimTable,
|
||||||
.callback = SpriteCallbackDummy
|
.callback = SpriteCallbackDummy
|
||||||
@ -211,8 +224,8 @@ static const union AnimCmd *const sSpriteAnimTable_EggShard[] =
|
|||||||
|
|
||||||
static const struct SpriteTemplate sSpriteTemplate_EggShard =
|
static const struct SpriteTemplate sSpriteTemplate_EggShard =
|
||||||
{
|
{
|
||||||
.tileTag = 23456,
|
.tileTag = GFXTAG_EGG_SHARD,
|
||||||
.paletteTag = 54321,
|
.paletteTag = PALTAG_EGG,
|
||||||
.oam = &sOamData_EggShard,
|
.oam = &sOamData_EggShard,
|
||||||
.anims = sSpriteAnimTable_EggShard,
|
.anims = sSpriteAnimTable_EggShard,
|
||||||
.images = NULL,
|
.images = NULL,
|
||||||
@ -220,7 +233,7 @@ static const struct SpriteTemplate sSpriteTemplate_EggShard =
|
|||||||
.callback = SpriteCB_EggShard
|
.callback = SpriteCB_EggShard
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct BgTemplate sBgTemplates_EggHatch[2] =
|
static const struct BgTemplate sBgTemplates_EggHatch[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
.bg = 0,
|
.bg = 0,
|
||||||
@ -243,7 +256,7 @@ static const struct BgTemplate sBgTemplates_EggHatch[2] =
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct WindowTemplate sWinTemplates_EggHatch[2] =
|
static const struct WindowTemplate sWinTemplates_EggHatch[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
.bg = 0,
|
.bg = 0,
|
||||||
@ -270,9 +283,14 @@ static const struct WindowTemplate sYesNoWinTemplate =
|
|||||||
|
|
||||||
static const s16 sEggShardVelocities[][2] =
|
static const s16 sEggShardVelocities[][2] =
|
||||||
{
|
{
|
||||||
|
// First shake
|
||||||
{Q_8_8(-1.5), Q_8_8(-3.75)},
|
{Q_8_8(-1.5), Q_8_8(-3.75)},
|
||||||
|
|
||||||
|
// Third shake
|
||||||
{Q_8_8(-5), Q_8_8(-3)},
|
{Q_8_8(-5), Q_8_8(-3)},
|
||||||
{Q_8_8(3.5), Q_8_8(-3)},
|
{Q_8_8(3.5), Q_8_8(-3)},
|
||||||
|
|
||||||
|
// Hatching
|
||||||
{Q_8_8(-4), Q_8_8(-3.75)},
|
{Q_8_8(-4), Q_8_8(-3.75)},
|
||||||
{Q_8_8(2), Q_8_8(-1.5)},
|
{Q_8_8(2), Q_8_8(-1.5)},
|
||||||
{Q_8_8(-0.5), Q_8_8(-6.75)},
|
{Q_8_8(-0.5), Q_8_8(-6.75)},
|
||||||
@ -291,8 +309,6 @@ static const s16 sEggShardVelocities[][2] =
|
|||||||
{Q_8_8(2.5), Q_8_8(-7.5)},
|
{Q_8_8(2.5), Q_8_8(-7.5)},
|
||||||
};
|
};
|
||||||
|
|
||||||
// code
|
|
||||||
|
|
||||||
static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
|
static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
|
||||||
{
|
{
|
||||||
u16 species;
|
u16 species;
|
||||||
@ -301,21 +317,17 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
|
|||||||
u16 moves[MAX_MON_MOVES];
|
u16 moves[MAX_MON_MOVES];
|
||||||
u32 ivs[NUM_STATS];
|
u32 ivs[NUM_STATS];
|
||||||
|
|
||||||
|
|
||||||
species = GetMonData(egg, MON_DATA_SPECIES);
|
species = GetMonData(egg, MON_DATA_SPECIES);
|
||||||
|
|
||||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||||
{
|
|
||||||
moves[i] = GetMonData(egg, MON_DATA_MOVE1 + i);
|
moves[i] = GetMonData(egg, MON_DATA_MOVE1 + i);
|
||||||
}
|
|
||||||
|
|
||||||
personality = GetMonData(egg, MON_DATA_PERSONALITY);
|
personality = GetMonData(egg, MON_DATA_PERSONALITY);
|
||||||
|
|
||||||
for (i = 0; i < NUM_STATS; i++)
|
for (i = 0; i < NUM_STATS; i++)
|
||||||
{
|
|
||||||
ivs[i] = GetMonData(egg, MON_DATA_HP_IV + i);
|
ivs[i] = GetMonData(egg, MON_DATA_HP_IV + i);
|
||||||
}
|
|
||||||
|
|
||||||
|
// The language is initially read from the Egg but is later overwritten below
|
||||||
language = GetMonData(egg, MON_DATA_LANGUAGE);
|
language = GetMonData(egg, MON_DATA_LANGUAGE);
|
||||||
gameMet = GetMonData(egg, MON_DATA_MET_GAME);
|
gameMet = GetMonData(egg, MON_DATA_MET_GAME);
|
||||||
markings = GetMonData(egg, MON_DATA_MARKINGS);
|
markings = GetMonData(egg, MON_DATA_MARKINGS);
|
||||||
@ -325,14 +337,10 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
|
|||||||
CreateMon(temp, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, TRUE, personality, OT_ID_PLAYER_ID, 0);
|
CreateMon(temp, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, TRUE, personality, OT_ID_PLAYER_ID, 0);
|
||||||
|
|
||||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||||
{
|
|
||||||
SetMonData(temp, MON_DATA_MOVE1 + i, &moves[i]);
|
SetMonData(temp, MON_DATA_MOVE1 + i, &moves[i]);
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < NUM_STATS; i++)
|
for (i = 0; i < NUM_STATS; i++)
|
||||||
{
|
|
||||||
SetMonData(temp, MON_DATA_HP_IV + i, &ivs[i]);
|
SetMonData(temp, MON_DATA_HP_IV + i, &ivs[i]);
|
||||||
}
|
|
||||||
|
|
||||||
language = GAME_LANGUAGE;
|
language = GAME_LANGUAGE;
|
||||||
SetMonData(temp, MON_DATA_LANGUAGE, &language);
|
SetMonData(temp, MON_DATA_LANGUAGE, &language);
|
||||||
@ -350,34 +358,35 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
|
|||||||
static void AddHatchedMonToParty(u8 id)
|
static void AddHatchedMonToParty(u8 id)
|
||||||
{
|
{
|
||||||
u8 isEgg = 0x46; // ?
|
u8 isEgg = 0x46; // ?
|
||||||
u16 pokeNum;
|
u16 species;
|
||||||
u8 name[12];
|
u8 name[POKEMON_NAME_LENGTH + 1];
|
||||||
u16 ball;
|
u16 ball;
|
||||||
u16 caughtLvl;
|
u16 metLevel;
|
||||||
u8 mapNameID;
|
u8 metLocation;
|
||||||
struct Pokemon* mon = &gPlayerParty[id];
|
struct Pokemon* mon = &gPlayerParty[id];
|
||||||
|
|
||||||
CreateHatchedMon(mon, &gEnemyParty[0]);
|
CreateHatchedMon(mon, &gEnemyParty[0]);
|
||||||
SetMonData(mon, MON_DATA_IS_EGG, &isEgg);
|
SetMonData(mon, MON_DATA_IS_EGG, &isEgg);
|
||||||
|
|
||||||
pokeNum = GetMonData(mon, MON_DATA_SPECIES);
|
species = GetMonData(mon, MON_DATA_SPECIES);
|
||||||
GetSpeciesName(name, pokeNum);
|
GetSpeciesName(name, species);
|
||||||
SetMonData(mon, MON_DATA_NICKNAME, name);
|
SetMonData(mon, MON_DATA_NICKNAME, name);
|
||||||
|
|
||||||
pokeNum = SpeciesToNationalPokedexNum(pokeNum);
|
species = SpeciesToNationalPokedexNum(species);
|
||||||
GetSetPokedexFlag(pokeNum, FLAG_SET_SEEN);
|
GetSetPokedexFlag(species, FLAG_SET_SEEN);
|
||||||
GetSetPokedexFlag(pokeNum, FLAG_SET_CAUGHT);
|
GetSetPokedexFlag(species, FLAG_SET_CAUGHT);
|
||||||
|
|
||||||
GetMonNickname2(mon, gStringVar1);
|
GetMonNickname2(mon, gStringVar1);
|
||||||
|
|
||||||
ball = ITEM_POKE_BALL;
|
ball = ITEM_POKE_BALL;
|
||||||
SetMonData(mon, MON_DATA_POKEBALL, &ball);
|
SetMonData(mon, MON_DATA_POKEBALL, &ball);
|
||||||
|
|
||||||
caughtLvl = 0;
|
// A met level of 0 is interpreted on the summary screen as "hatched at"
|
||||||
SetMonData(mon, MON_DATA_MET_LEVEL, &caughtLvl);
|
metLevel = 0;
|
||||||
|
SetMonData(mon, MON_DATA_MET_LEVEL, &metLevel);
|
||||||
|
|
||||||
mapNameID = GetCurrentRegionMapSectionId();
|
metLocation = GetCurrentRegionMapSectionId();
|
||||||
SetMonData(mon, MON_DATA_MET_LOCATION, &mapNameID);
|
SetMonData(mon, MON_DATA_MET_LOCATION, &metLocation);
|
||||||
|
|
||||||
MonRestorePP(mon);
|
MonRestorePP(mon);
|
||||||
CalculateMonStats(mon);
|
CalculateMonStats(mon);
|
||||||
@ -411,26 +420,27 @@ bool8 CheckDaycareMonReceivedMail(void)
|
|||||||
return _CheckDaycareMonReceivedMail(&gSaveBlock1Ptr->daycare, gSpecialVar_0x8004);
|
return _CheckDaycareMonReceivedMail(&gSaveBlock1Ptr->daycare, gSpecialVar_0x8004);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 EggHatchCreateMonSprite(u8 useAlt, u8 switchID, u8 pokeID, u16* speciesLoc)
|
static u8 EggHatchCreateMonSprite(u8 useAlt, u8 state, u8 partyId, u16* speciesLoc)
|
||||||
{
|
{
|
||||||
u8 position = 0;
|
u8 position = 0;
|
||||||
u8 spriteID = 0;
|
u8 spriteId = 0;
|
||||||
struct Pokemon* mon = NULL;
|
struct Pokemon* mon = NULL;
|
||||||
|
|
||||||
if (useAlt == FALSE)
|
if (useAlt == FALSE)
|
||||||
{
|
{
|
||||||
mon = &gPlayerParty[pokeID];
|
mon = &gPlayerParty[partyId];
|
||||||
position = B_POSITION_OPPONENT_LEFT;
|
position = B_POSITION_OPPONENT_LEFT;
|
||||||
}
|
}
|
||||||
if (useAlt == TRUE)
|
if (useAlt == TRUE)
|
||||||
{
|
{
|
||||||
// Alternate sprite allocation position. Never reached.
|
// Alternate sprite allocation position. Never reached.
|
||||||
mon = &gPlayerParty[pokeID];
|
mon = &gPlayerParty[partyId];
|
||||||
position = B_POSITION_OPPONENT_RIGHT;
|
position = B_POSITION_OPPONENT_RIGHT;
|
||||||
}
|
}
|
||||||
switch (switchID)
|
switch (state)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
// Load mon sprite gfx
|
||||||
{
|
{
|
||||||
u16 species = GetMonData(mon, MON_DATA_SPECIES);
|
u16 species = GetMonData(mon, MON_DATA_SPECIES);
|
||||||
u32 pid = GetMonData(mon, MON_DATA_PERSONALITY);
|
u32 pid = GetMonData(mon, MON_DATA_PERSONALITY);
|
||||||
@ -442,13 +452,14 @@ static u8 EggHatchCreateMonSprite(u8 useAlt, u8 switchID, u8 pokeID, u16* specie
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
// Create mon sprite
|
||||||
SetMultiuseSpriteTemplateToPokemon(GetMonSpritePalStruct(mon)->tag, position);
|
SetMultiuseSpriteTemplateToPokemon(GetMonSpritePalStruct(mon)->tag, position);
|
||||||
spriteID = CreateSprite(&gMultiuseSpriteTemplate, 120, 75, 6);
|
spriteId = CreateSprite(&gMultiuseSpriteTemplate, EGG_X, EGG_Y, 6);
|
||||||
gSprites[spriteID].invisible = TRUE;
|
gSprites[spriteId].invisible = TRUE;
|
||||||
gSprites[spriteID].callback = SpriteCallbackDummy;
|
gSprites[spriteId].callback = SpriteCallbackDummy;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return spriteID;
|
return spriteId;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void VBlankCB_EggHatch(void)
|
static void VBlankCB_EggHatch(void)
|
||||||
@ -465,28 +476,28 @@ void EggHatch(void)
|
|||||||
FadeScreen(FADE_TO_BLACK, 0);
|
FadeScreen(FADE_TO_BLACK, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Task_EggHatch(u8 taskID)
|
static void Task_EggHatch(u8 taskId)
|
||||||
{
|
{
|
||||||
if (!gPaletteFade.active)
|
if (!gPaletteFade.active)
|
||||||
{
|
{
|
||||||
CleanupOverworldWindowsAndTilemaps();
|
CleanupOverworldWindowsAndTilemaps();
|
||||||
SetMainCallback2(CB2_EggHatch_0);
|
SetMainCallback2(CB2_LoadEggHatch);
|
||||||
gFieldCallback = FieldCB_ContinueScriptHandleMusic;
|
gFieldCallback = FieldCB_ContinueScriptHandleMusic;
|
||||||
DestroyTask(taskID);
|
DestroyTask(taskId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CB2_EggHatch_0(void)
|
static void CB2_LoadEggHatch(void)
|
||||||
{
|
{
|
||||||
switch (gMain.state)
|
switch (gMain.state)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
||||||
|
|
||||||
sEggHatchData = Alloc(sizeof(struct EggHatchData));
|
sEggHatchData = Alloc(sizeof(*sEggHatchData));
|
||||||
AllocateMonSpritesGfx();
|
AllocateMonSpritesGfx();
|
||||||
sEggHatchData->eggPartyID = gSpecialVar_0x8004;
|
sEggHatchData->eggPartyId = gSpecialVar_0x8004;
|
||||||
sEggHatchData->eggShardVelocityID = 0;
|
sEggHatchData->eggShardVelocityId = 0;
|
||||||
|
|
||||||
SetVBlankCallback(VBlankCB_EggHatch);
|
SetVBlankCallback(VBlankCB_EggHatch);
|
||||||
gSpecialVar_0x8005 = GetCurrentMapMusic();
|
gSpecialVar_0x8005 = GetCurrentMapMusic();
|
||||||
@ -532,15 +543,15 @@ static void CB2_EggHatch_0(void)
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
CopyBgTilemapBufferToVram(0);
|
CopyBgTilemapBufferToVram(0);
|
||||||
AddHatchedMonToParty(sEggHatchData->eggPartyID);
|
AddHatchedMonToParty(sEggHatchData->eggPartyId);
|
||||||
gMain.state++;
|
gMain.state++;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
EggHatchCreateMonSprite(FALSE, 0, sEggHatchData->eggPartyID, &sEggHatchData->species);
|
EggHatchCreateMonSprite(FALSE, 0, sEggHatchData->eggPartyId, &sEggHatchData->species);
|
||||||
gMain.state++;
|
gMain.state++;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
sEggHatchData->pokeSpriteID = EggHatchCreateMonSprite(FALSE, 1, sEggHatchData->eggPartyID, &sEggHatchData->species);
|
sEggHatchData->monSpriteId = EggHatchCreateMonSprite(FALSE, 1, sEggHatchData->eggPartyId, &sEggHatchData->species);
|
||||||
gMain.state++;
|
gMain.state++;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
@ -552,8 +563,8 @@ static void CB2_EggHatch_0(void)
|
|||||||
gMain.state++;
|
gMain.state++;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
SetMainCallback2(CB2_EggHatch_1);
|
SetMainCallback2(CB2_EggHatch);
|
||||||
sEggHatchData->CB2_state = 0;
|
sEggHatchData->state = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
RunTasks();
|
RunTasks();
|
||||||
@ -571,121 +582,127 @@ static void EggHatchSetMonNickname(void)
|
|||||||
SetMainCallback2(CB2_ReturnToField);
|
SetMainCallback2(CB2_ReturnToField);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Task_EggHatchPlayBGM(u8 taskID)
|
#define tTimer data[0]
|
||||||
|
|
||||||
|
static void Task_EggHatchPlayBGM(u8 taskId)
|
||||||
{
|
{
|
||||||
if (gTasks[taskID].data[0] == 0)
|
if (gTasks[taskId].tTimer == 0)
|
||||||
{
|
{
|
||||||
StopMapMusic();
|
StopMapMusic();
|
||||||
PlayRainStoppingSoundEffect();
|
PlayRainStoppingSoundEffect();
|
||||||
}
|
}
|
||||||
if (gTasks[taskID].data[0] == 1)
|
|
||||||
|
if (gTasks[taskId].tTimer == 1)
|
||||||
PlayBGM(MUS_EVOLUTION_INTRO);
|
PlayBGM(MUS_EVOLUTION_INTRO);
|
||||||
if (gTasks[taskID].data[0] > 60)
|
|
||||||
|
if (gTasks[taskId].tTimer > 60)
|
||||||
{
|
{
|
||||||
PlayBGM(MUS_EVOLUTION);
|
PlayBGM(MUS_EVOLUTION);
|
||||||
DestroyTask(taskID);
|
DestroyTask(taskId);
|
||||||
// UB: task is destroyed, yet the value is incremented
|
|
||||||
#ifdef UBFIX
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
gTasks[taskID].data[0]++;
|
gTasks[taskId].tTimer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CB2_EggHatch_1(void)
|
static void CB2_EggHatch(void)
|
||||||
{
|
{
|
||||||
u16 species;
|
u16 species;
|
||||||
u8 gender;
|
u8 gender;
|
||||||
u32 personality;
|
u32 personality;
|
||||||
|
|
||||||
switch (sEggHatchData->CB2_state)
|
switch (sEggHatchData->state)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0x10, 0, RGB_BLACK);
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
|
||||||
sEggHatchData->eggSpriteID = CreateSprite(&sSpriteTemplate_EggHatch, 120, 75, 5);
|
sEggHatchData->eggSpriteId = CreateSprite(&sSpriteTemplate_Egg, EGG_X, EGG_Y, 5);
|
||||||
ShowBg(0);
|
ShowBg(0);
|
||||||
ShowBg(1);
|
ShowBg(1);
|
||||||
sEggHatchData->CB2_state++;
|
sEggHatchData->state++;
|
||||||
CreateTask(Task_EggHatchPlayBGM, 5);
|
CreateTask(Task_EggHatchPlayBGM, 5);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (!gPaletteFade.active)
|
if (!gPaletteFade.active)
|
||||||
{
|
{
|
||||||
FillWindowPixelBuffer(sEggHatchData->windowId, PIXEL_FILL(0));
|
FillWindowPixelBuffer(sEggHatchData->windowId, PIXEL_FILL(0));
|
||||||
sEggHatchData->CB2_PalCounter = 0;
|
sEggHatchData->delayTimer = 0;
|
||||||
sEggHatchData->CB2_state++;
|
sEggHatchData->state++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (++sEggHatchData->CB2_PalCounter > 30)
|
if (++sEggHatchData->delayTimer > 30)
|
||||||
{
|
{
|
||||||
sEggHatchData->CB2_state++;
|
// Start hatching animation
|
||||||
gSprites[sEggHatchData->eggSpriteID].callback = SpriteCB_Egg_0;
|
sEggHatchData->state++;
|
||||||
|
gSprites[sEggHatchData->eggSpriteId].callback = SpriteCB_Egg_Shake1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (gSprites[sEggHatchData->eggSpriteID].callback == SpriteCallbackDummy)
|
// Wait for hatching animation to finish
|
||||||
|
if (gSprites[sEggHatchData->eggSpriteId].callback == SpriteCallbackDummy)
|
||||||
{
|
{
|
||||||
species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyID], MON_DATA_SPECIES);
|
species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyId], MON_DATA_SPECIES);
|
||||||
DoMonFrontSpriteAnimation(&gSprites[sEggHatchData->pokeSpriteID], species, FALSE, 1);
|
DoMonFrontSpriteAnimation(&gSprites[sEggHatchData->monSpriteId], species, FALSE, 1);
|
||||||
sEggHatchData->CB2_state++;
|
sEggHatchData->state++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (gSprites[sEggHatchData->pokeSpriteID].callback == SpriteCallbackDummy)
|
// Wait for Pokémon's front sprite animation
|
||||||
{
|
if (gSprites[sEggHatchData->monSpriteId].callback == SpriteCallbackDummy)
|
||||||
sEggHatchData->CB2_state++;
|
sEggHatchData->state++;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
GetMonNickname2(&gPlayerParty[sEggHatchData->eggPartyID], gStringVar1);
|
// "{mon} hatched from egg" message/fanfare
|
||||||
|
GetMonNickname2(&gPlayerParty[sEggHatchData->eggPartyId], gStringVar1);
|
||||||
StringExpandPlaceholders(gStringVar4, gText_HatchedFromEgg);
|
StringExpandPlaceholders(gStringVar4, gText_HatchedFromEgg);
|
||||||
EggHatchPrintMessage(sEggHatchData->windowId, gStringVar4, 0, 3, TEXT_SKIP_DRAW);
|
EggHatchPrintMessage(sEggHatchData->windowId, gStringVar4, 0, 3, TEXT_SKIP_DRAW);
|
||||||
PlayFanfare(MUS_EVOLVED);
|
PlayFanfare(MUS_EVOLVED);
|
||||||
sEggHatchData->CB2_state++;
|
sEggHatchData->state++;
|
||||||
PutWindowTilemap(sEggHatchData->windowId);
|
PutWindowTilemap(sEggHatchData->windowId);
|
||||||
CopyWindowToVram(sEggHatchData->windowId, COPYWIN_FULL);
|
CopyWindowToVram(sEggHatchData->windowId, COPYWIN_FULL);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
if (IsFanfareTaskInactive())
|
if (IsFanfareTaskInactive())
|
||||||
sEggHatchData->CB2_state++;
|
sEggHatchData->state++;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7: // Twice?
|
||||||
if (IsFanfareTaskInactive())
|
if (IsFanfareTaskInactive())
|
||||||
sEggHatchData->CB2_state++;
|
sEggHatchData->state++;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
GetMonNickname2(&gPlayerParty[sEggHatchData->eggPartyID], gStringVar1);
|
// Ready the nickname prompt
|
||||||
|
GetMonNickname2(&gPlayerParty[sEggHatchData->eggPartyId], gStringVar1);
|
||||||
StringExpandPlaceholders(gStringVar4, gText_NicknameHatchPrompt);
|
StringExpandPlaceholders(gStringVar4, gText_NicknameHatchPrompt);
|
||||||
EggHatchPrintMessage(sEggHatchData->windowId, gStringVar4, 0, 2, 1);
|
EggHatchPrintMessage(sEggHatchData->windowId, gStringVar4, 0, 2, 1);
|
||||||
sEggHatchData->CB2_state++;
|
sEggHatchData->state++;
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
|
// Print the nickname prompt
|
||||||
if (!IsTextPrinterActive(sEggHatchData->windowId))
|
if (!IsTextPrinterActive(sEggHatchData->windowId))
|
||||||
{
|
{
|
||||||
LoadUserWindowBorderGfx(sEggHatchData->windowId, 0x140, 0xE0);
|
LoadUserWindowBorderGfx(sEggHatchData->windowId, 0x140, 0xE0);
|
||||||
CreateYesNoMenu(&sYesNoWinTemplate, 0x140, 0xE, 0);
|
CreateYesNoMenu(&sYesNoWinTemplate, 0x140, 0xE, 0);
|
||||||
sEggHatchData->CB2_state++;
|
sEggHatchData->state++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
|
// Handle the nickname prompt input
|
||||||
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0: // Yes
|
||||||
GetMonNickname2(&gPlayerParty[sEggHatchData->eggPartyID], gStringVar3);
|
GetMonNickname2(&gPlayerParty[sEggHatchData->eggPartyId], gStringVar3);
|
||||||
species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyID], MON_DATA_SPECIES);
|
species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyId], MON_DATA_SPECIES);
|
||||||
gender = GetMonGender(&gPlayerParty[sEggHatchData->eggPartyID]);
|
gender = GetMonGender(&gPlayerParty[sEggHatchData->eggPartyId]);
|
||||||
personality = GetMonData(&gPlayerParty[sEggHatchData->eggPartyID], MON_DATA_PERSONALITY, 0);
|
personality = GetMonData(&gPlayerParty[sEggHatchData->eggPartyId], MON_DATA_PERSONALITY, 0);
|
||||||
DoNamingScreen(NAMING_SCREEN_NICKNAME, gStringVar3, species, gender, personality, EggHatchSetMonNickname);
|
DoNamingScreen(NAMING_SCREEN_NICKNAME, gStringVar3, species, gender, personality, EggHatchSetMonNickname);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: // No
|
||||||
case -1:
|
case MENU_B_PRESSED:
|
||||||
sEggHatchData->CB2_state++;
|
sEggHatchData->state++;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
||||||
sEggHatchData->CB2_state++;
|
sEggHatchData->state++;
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
if (!gPaletteFade.active)
|
if (!gPaletteFade.active)
|
||||||
@ -707,136 +724,170 @@ static void CB2_EggHatch_1(void)
|
|||||||
UpdatePaletteFade();
|
UpdatePaletteFade();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SpriteCB_Egg_0(struct Sprite* sprite)
|
#define sTimer data[0]
|
||||||
|
#define sSinIdx data[1]
|
||||||
|
#define sDelayTimer data[2]
|
||||||
|
|
||||||
|
static void SpriteCB_Egg_Shake1(struct Sprite* sprite)
|
||||||
{
|
{
|
||||||
if (++sprite->data[0] > 20)
|
if (++sprite->sTimer > 20)
|
||||||
{
|
{
|
||||||
sprite->callback = SpriteCB_Egg_1;
|
sprite->callback = SpriteCB_Egg_Shake2;
|
||||||
sprite->data[0] = 0;
|
sprite->sTimer = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprite->data[1] = (sprite->data[1] + 20) & 0xFF;
|
// Shake egg
|
||||||
sprite->x2 = Sin(sprite->data[1], 1);
|
sprite->sSinIdx = (sprite->sSinIdx + 20) & 0xFF;
|
||||||
if (sprite->data[0] == 15)
|
sprite->x2 = Sin(sprite->sSinIdx, 1);
|
||||||
|
if (sprite->sTimer == 15)
|
||||||
{
|
{
|
||||||
|
// First egg crack
|
||||||
PlaySE(SE_BALL);
|
PlaySE(SE_BALL);
|
||||||
StartSpriteAnim(sprite, 1);
|
StartSpriteAnim(sprite, EGG_ANIM_CRACKED_1);
|
||||||
CreateRandomEggShardSprite();
|
CreateRandomEggShardSprite();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SpriteCB_Egg_1(struct Sprite* sprite)
|
static void SpriteCB_Egg_Shake2(struct Sprite* sprite)
|
||||||
{
|
{
|
||||||
if (++sprite->data[2] > 30)
|
if (++sprite->sDelayTimer > 30)
|
||||||
{
|
{
|
||||||
if (++sprite->data[0] > 20)
|
if (++sprite->sTimer > 20)
|
||||||
{
|
{
|
||||||
sprite->callback = SpriteCB_Egg_2;
|
sprite->callback = SpriteCB_Egg_Shake3;
|
||||||
sprite->data[0] = 0;
|
sprite->sTimer = 0;
|
||||||
sprite->data[2] = 0;
|
sprite->sDelayTimer = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprite->data[1] = (sprite->data[1] + 20) & 0xFF;
|
// Shake egg
|
||||||
sprite->x2 = Sin(sprite->data[1], 2);
|
sprite->sSinIdx = (sprite->sSinIdx + 20) & 0xFF;
|
||||||
if (sprite->data[0] == 15)
|
sprite->x2 = Sin(sprite->sSinIdx, 2);
|
||||||
|
if (sprite->sTimer == 15)
|
||||||
{
|
{
|
||||||
|
// Second egg crack
|
||||||
PlaySE(SE_BALL);
|
PlaySE(SE_BALL);
|
||||||
StartSpriteAnim(sprite, 2);
|
StartSpriteAnim(sprite, EGG_ANIM_CRACKED_2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SpriteCB_Egg_2(struct Sprite* sprite)
|
static void SpriteCB_Egg_Shake3(struct Sprite* sprite)
|
||||||
{
|
{
|
||||||
if (++sprite->data[2] > 30)
|
if (++sprite->sDelayTimer > 30)
|
||||||
{
|
{
|
||||||
if (++sprite->data[0] > 38)
|
if (++sprite->sTimer > 38)
|
||||||
{
|
{
|
||||||
u16 species;
|
u16 species;
|
||||||
|
sprite->callback = SpriteCB_Egg_WaitHatch;
|
||||||
sprite->callback = SpriteCB_Egg_3;
|
sprite->sTimer = 0;
|
||||||
sprite->data[0] = 0;
|
species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyId], MON_DATA_SPECIES);
|
||||||
species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyID], MON_DATA_SPECIES);
|
gSprites[sEggHatchData->monSpriteId].x2 = 0;
|
||||||
gSprites[sEggHatchData->pokeSpriteID].x2 = 0;
|
gSprites[sEggHatchData->monSpriteId].y2 = 0;
|
||||||
gSprites[sEggHatchData->pokeSpriteID].y2 = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprite->data[1] = (sprite->data[1] + 20) & 0xFF;
|
// Shake egg
|
||||||
sprite->x2 = Sin(sprite->data[1], 2);
|
sprite->sSinIdx = (sprite->sSinIdx + 20) & 0xFF;
|
||||||
if (sprite->data[0] == 15)
|
sprite->x2 = Sin(sprite->sSinIdx, 2);
|
||||||
|
if (sprite->sTimer == 15)
|
||||||
{
|
{
|
||||||
|
// Third egg crack
|
||||||
|
// This ineffectually sets the animation to the frame it's already using.
|
||||||
|
// They likely meant to use the 3rd and final cracked frame of the egg, which goes unused as a result.
|
||||||
PlaySE(SE_BALL);
|
PlaySE(SE_BALL);
|
||||||
StartSpriteAnim(sprite, 2);
|
#ifdef BUGFIX
|
||||||
|
StartSpriteAnim(sprite, EGG_ANIM_CRACKED_3);
|
||||||
|
#else
|
||||||
|
StartSpriteAnim(sprite, EGG_ANIM_CRACKED_2);
|
||||||
|
#endif
|
||||||
CreateRandomEggShardSprite();
|
CreateRandomEggShardSprite();
|
||||||
CreateRandomEggShardSprite();
|
CreateRandomEggShardSprite();
|
||||||
}
|
}
|
||||||
if (sprite->data[0] == 30)
|
if (sprite->sTimer == 30)
|
||||||
PlaySE(SE_BALL);
|
PlaySE(SE_BALL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SpriteCB_Egg_3(struct Sprite* sprite)
|
static void SpriteCB_Egg_WaitHatch(struct Sprite* sprite)
|
||||||
{
|
{
|
||||||
if (++sprite->data[0] > 50)
|
if (++sprite->sTimer > 50)
|
||||||
{
|
{
|
||||||
sprite->callback = SpriteCB_Egg_4;
|
sprite->callback = SpriteCB_Egg_Hatch;
|
||||||
sprite->data[0] = 0;
|
sprite->sTimer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SpriteCB_Egg_4(struct Sprite* sprite)
|
static void SpriteCB_Egg_Hatch(struct Sprite* sprite)
|
||||||
{
|
{
|
||||||
s16 i;
|
s16 i;
|
||||||
if (sprite->data[0] == 0)
|
|
||||||
BeginNormalPaletteFade(PALETTES_ALL, -1, 0, 0x10, RGB_WHITEALPHA);
|
// Fade to white to hide transition from egg to Pokémon
|
||||||
if (sprite->data[0] < 4u)
|
if (sprite->sTimer == 0)
|
||||||
|
BeginNormalPaletteFade(PALETTES_ALL, -1, 0, 16, RGB_WHITEALPHA);
|
||||||
|
|
||||||
|
// Create a shower of 16 egg shards in 4 groups of 4
|
||||||
|
if ((u32)sprite->sTimer < 4)
|
||||||
{
|
{
|
||||||
for (i = 0; i <= 3; i++)
|
for (i = 0; i < 4; i++)
|
||||||
CreateRandomEggShardSprite();
|
CreateRandomEggShardSprite();
|
||||||
}
|
}
|
||||||
sprite->data[0]++;
|
|
||||||
|
sprite->sTimer++;
|
||||||
|
|
||||||
if (!gPaletteFade.active)
|
if (!gPaletteFade.active)
|
||||||
{
|
{
|
||||||
|
// Screen is hidden by the fade to white, hide egg
|
||||||
PlaySE(SE_EGG_HATCH);
|
PlaySE(SE_EGG_HATCH);
|
||||||
sprite->invisible = TRUE;
|
sprite->invisible = TRUE;
|
||||||
sprite->callback = SpriteCB_Egg_5;
|
sprite->callback = SpriteCB_Egg_Reveal;
|
||||||
sprite->data[0] = 0;
|
sprite->sTimer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SpriteCB_Egg_5(struct Sprite* sprite)
|
static void SpriteCB_Egg_Reveal(struct Sprite* sprite)
|
||||||
{
|
{
|
||||||
if (sprite->data[0] == 0)
|
if (sprite->sTimer == 0)
|
||||||
{
|
{
|
||||||
gSprites[sEggHatchData->pokeSpriteID].invisible = FALSE;
|
// Reveal hatched Pokémon
|
||||||
StartSpriteAffineAnim(&gSprites[sEggHatchData->pokeSpriteID], BATTLER_AFFINE_EMERGE);
|
gSprites[sEggHatchData->monSpriteId].invisible = FALSE;
|
||||||
|
StartSpriteAffineAnim(&gSprites[sEggHatchData->monSpriteId], BATTLER_AFFINE_EMERGE);
|
||||||
}
|
}
|
||||||
if (sprite->data[0] == 8)
|
|
||||||
BeginNormalPaletteFade(PALETTES_ALL, -1, 0x10, 0, RGB_WHITEALPHA);
|
// Fade back from white for reveal
|
||||||
if (sprite->data[0] <= 9)
|
if (sprite->sTimer == 8)
|
||||||
gSprites[sEggHatchData->pokeSpriteID].y -= 1;
|
BeginNormalPaletteFade(PALETTES_ALL, -1, 16, 0, RGB_WHITEALPHA);
|
||||||
if (sprite->data[0] > 40)
|
|
||||||
sprite->callback = SpriteCallbackDummy;
|
if (sprite->sTimer <= 9)
|
||||||
sprite->data[0]++;
|
gSprites[sEggHatchData->monSpriteId].y--;
|
||||||
|
|
||||||
|
if (sprite->sTimer > 40)
|
||||||
|
sprite->callback = SpriteCallbackDummy; // Finished
|
||||||
|
|
||||||
|
sprite->sTimer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define sVelocX data[1]
|
||||||
|
#define sVelocY data[2]
|
||||||
|
#define sAccelY data[3]
|
||||||
|
#define sDeltaX data[4]
|
||||||
|
#define sDeltaY data[5]
|
||||||
|
|
||||||
static void SpriteCB_EggShard(struct Sprite* sprite)
|
static void SpriteCB_EggShard(struct Sprite* sprite)
|
||||||
{
|
{
|
||||||
sprite->data[4] += sprite->data[1];
|
sprite->sDeltaX += sprite->sVelocX;
|
||||||
sprite->data[5] += sprite->data[2];
|
sprite->sDeltaY += sprite->sVelocY;
|
||||||
|
|
||||||
sprite->x2 = sprite->data[4] / 256;
|
sprite->x2 = sprite->sDeltaX / 256;
|
||||||
sprite->y2 = sprite->data[5] / 256;
|
sprite->y2 = sprite->sDeltaY / 256;
|
||||||
|
|
||||||
sprite->data[2] += sprite->data[3];
|
sprite->sVelocY += sprite->sAccelY;
|
||||||
|
|
||||||
if (sprite->y + sprite->y2 > sprite->y + 20 && sprite->data[2] > 0)
|
if (sprite->y + sprite->y2 > sprite->y + 20 && sprite->sVelocY > 0)
|
||||||
DestroySprite(sprite);
|
DestroySprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -844,20 +895,23 @@ static void CreateRandomEggShardSprite(void)
|
|||||||
{
|
{
|
||||||
u16 spriteAnimIndex;
|
u16 spriteAnimIndex;
|
||||||
|
|
||||||
s16 velocity1 = sEggShardVelocities[sEggHatchData->eggShardVelocityID][0];
|
s16 velocityX = sEggShardVelocities[sEggHatchData->eggShardVelocityId][0];
|
||||||
s16 velocity2 = sEggShardVelocities[sEggHatchData->eggShardVelocityID][1];
|
s16 velocityY = sEggShardVelocities[sEggHatchData->eggShardVelocityId][1];
|
||||||
sEggHatchData->eggShardVelocityID++;
|
sEggHatchData->eggShardVelocityId++;
|
||||||
spriteAnimIndex = Random() % 4;
|
|
||||||
CreateEggShardSprite(120, 60, velocity1, velocity2, 100, spriteAnimIndex);
|
// Randomly choose one of the 4 shard images
|
||||||
|
spriteAnimIndex = Random() % ARRAY_COUNT(sSpriteAnimTable_EggShard);
|
||||||
|
|
||||||
|
CreateEggShardSprite(EGG_X, EGG_Y - 15, velocityX, velocityY, 100, spriteAnimIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8 spriteAnimIndex)
|
static void CreateEggShardSprite(u8 x, u8 y, s16 velocityX, s16 velocityY, s16 acceleration, u8 spriteAnimIndex)
|
||||||
{
|
{
|
||||||
u8 spriteID = CreateSprite(&sSpriteTemplate_EggShard, x, y, 4);
|
u8 spriteId = CreateSprite(&sSpriteTemplate_EggShard, x, y, 4);
|
||||||
gSprites[spriteID].data[1] = data1;
|
gSprites[spriteId].sVelocX = velocityX;
|
||||||
gSprites[spriteID].data[2] = data2;
|
gSprites[spriteId].sVelocY = velocityY;
|
||||||
gSprites[spriteID].data[3] = data3;
|
gSprites[spriteId].sAccelY = acceleration;
|
||||||
StartSpriteAnim(&gSprites[spriteID], spriteAnimIndex);
|
StartSpriteAnim(&gSprites[spriteId], spriteAnimIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EggHatchPrintMessage(u8 windowId, u8* string, u8 x, u8 y, u8 speed)
|
static void EggHatchPrintMessage(u8 windowId, u8* string, u8 x, u8 y, u8 speed)
|
||||||
|
Loading…
Reference in New Issue
Block a user