2017-09-18 18:36:05 +02:00
|
|
|
#include "global.h"
|
|
|
|
#include "pokemon.h"
|
2017-11-14 23:25:07 +01:00
|
|
|
#include "egg_hatch.h"
|
2017-09-18 18:36:05 +02:00
|
|
|
#include "pokedex.h"
|
2017-12-05 18:55:48 +01:00
|
|
|
#include "constants/items.h"
|
2017-09-18 18:36:05 +02:00
|
|
|
#include "script.h"
|
|
|
|
#include "decompress.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "event_data.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "songs.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "text_window.h"
|
|
|
|
#include "string_util.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "trig.h"
|
2017-12-05 19:27:33 +01:00
|
|
|
#include "random.h"
|
2017-09-18 18:36:05 +02:00
|
|
|
#include "malloc.h"
|
|
|
|
#include "dma3.h"
|
|
|
|
#include "gpu_regs.h"
|
|
|
|
#include "bg.h"
|
|
|
|
#include "m4a.h"
|
|
|
|
#include "window.h"
|
2017-12-05 18:55:48 +01:00
|
|
|
#include "constants/abilities.h"
|
2017-11-14 21:43:23 +01:00
|
|
|
#include "daycare.h"
|
2017-09-18 18:36:05 +02:00
|
|
|
#include "battle.h" // to get rid of later
|
|
|
|
|
|
|
|
struct EggHatchData
|
|
|
|
{
|
|
|
|
u8 eggSpriteID;
|
|
|
|
u8 pokeSpriteID;
|
|
|
|
u8 CB2_state;
|
|
|
|
u8 CB2_PalCounter;
|
|
|
|
u8 eggPartyID;
|
2017-09-18 23:48:47 +02:00
|
|
|
u8 unused_5;
|
|
|
|
u8 unused_6;
|
2017-09-18 18:36:05 +02:00
|
|
|
u8 eggShardVelocityID;
|
2017-09-18 23:48:47 +02:00
|
|
|
u8 windowId;
|
|
|
|
u8 unused_9;
|
|
|
|
u8 unused_A;
|
2017-09-18 18:36:05 +02:00
|
|
|
u16 species;
|
2017-09-18 23:48:47 +02:00
|
|
|
struct TextColor textColor;
|
2017-09-18 18:36:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct SpriteTemplate gUnknown_0202499C;
|
|
|
|
extern void (*gFieldCallback)(void);
|
|
|
|
|
|
|
|
extern const struct CompressedSpriteSheet gMonFrontPicTable[];
|
|
|
|
extern const u8 gUnknown_08C00000[];
|
|
|
|
extern const u8 gUnknown_08C00524[];
|
|
|
|
extern const u8 gUnknown_08C004E0[];
|
|
|
|
extern const u16 gUnknown_08DD7300[]; // palette, gameboy advance
|
|
|
|
extern const u32 gUnknown_08DD7360[]; // tileset gameboy advance
|
|
|
|
extern const u32 gUnknown_08331F60[]; // tilemap gameboy circle
|
2017-09-21 10:50:15 +02:00
|
|
|
extern const u8 gText_HatchedFromEgg[];
|
|
|
|
extern const u8 gText_NickHatchPrompt[];
|
2017-09-18 18:36:05 +02:00
|
|
|
|
|
|
|
extern u8 sav1_map_get_name(void);
|
2017-09-18 23:48:47 +02:00
|
|
|
extern s8 sub_8198C58(void);
|
2017-10-13 17:09:36 +02:00
|
|
|
extern void TVShowConvertInternationalString(u8* str1, u8* str2, u8);
|
2017-09-18 18:36:05 +02:00
|
|
|
extern void sub_806A068(u16, u8);
|
|
|
|
extern void fade_screen(u8, u8);
|
|
|
|
extern void overworld_free_bg_tilemaps(void);
|
|
|
|
extern void sub_80AF168(void);
|
2017-10-01 01:12:42 +02:00
|
|
|
extern void AllocateMonSpritesGfx(void);
|
2017-10-01 18:54:01 +02:00
|
|
|
extern void FreeMonSpritesGfx(void);
|
2017-09-18 18:36:05 +02:00
|
|
|
extern void remove_some_task(void);
|
|
|
|
extern void reset_temp_tile_data_buffers(void);
|
2017-09-18 23:48:47 +02:00
|
|
|
extern void c2_exit_to_overworld_2_switch(void);
|
|
|
|
extern void play_some_sound(void);
|
2017-09-18 18:36:05 +02:00
|
|
|
extern void copy_decompressed_tile_data_to_vram_autofree(u8 bg_id, const void* src, u16 size, u16 offset, u8 mode);
|
2017-09-19 14:27:46 +02:00
|
|
|
extern void CreateYesNoMenu(const struct WindowTemplate*, u16, u8, u8);
|
2017-09-18 23:48:47 +02:00
|
|
|
extern void DoNamingScreen(u8, const u8*, u16, u8, u32, MainCallback);
|
2017-09-19 14:27:46 +02:00
|
|
|
extern u16 sub_80D22D0(void);
|
2017-11-11 14:45:08 +01:00
|
|
|
extern u8 CountPartyAliveNonEggMonsExcept(u8);
|
2017-09-18 23:48:47 +02:00
|
|
|
|
|
|
|
static void Task_EggHatch(u8 taskID);
|
|
|
|
static void CB2_EggHatch_0(void);
|
|
|
|
static void CB2_EggHatch_1(void);
|
|
|
|
static void SpriteCB_Egg_0(struct Sprite* sprite);
|
|
|
|
static void SpriteCB_Egg_1(struct Sprite* sprite);
|
|
|
|
static void SpriteCB_Egg_2(struct Sprite* sprite);
|
|
|
|
static void SpriteCB_Egg_3(struct Sprite* sprite);
|
|
|
|
static void SpriteCB_Egg_4(struct Sprite* sprite);
|
|
|
|
static void SpriteCB_Egg_5(struct Sprite* sprite);
|
|
|
|
static void SpriteCB_EggShard(struct Sprite* sprite);
|
|
|
|
static void EggHatchPrintMessage(u8 windowId, u8* string, u8 x, u8 y, u8 speed);
|
|
|
|
static void CreateRandomEggShardSprite(void);
|
|
|
|
static void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8 spriteAnimIndex);
|
2017-09-18 18:36:05 +02:00
|
|
|
|
2017-09-19 14:27:46 +02:00
|
|
|
// IWRAM bss
|
|
|
|
static IWRAM_DATA struct EggHatchData* sEggHatchData;
|
|
|
|
|
|
|
|
// rom data
|
|
|
|
static const u16 sEggPalette[] = INCBIN_U16("graphics/pokemon/palettes/egg_palette.gbapal");
|
|
|
|
static const u8 sEggHatchTiles[] = INCBIN_U8("graphics/misc/egg_hatch.4bpp");
|
|
|
|
static const u8 sEggShardTiles[] = INCBIN_U8("graphics/misc/egg_shard.4bpp");
|
|
|
|
|
|
|
|
static const struct OamData sOamData_EggHatch =
|
|
|
|
{
|
|
|
|
.y = 0,
|
|
|
|
.affineMode = 0,
|
|
|
|
.objMode = 0,
|
|
|
|
.mosaic = 0,
|
|
|
|
.bpp = 0,
|
|
|
|
.shape = 0,
|
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
|
|
|
.size = 2,
|
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_EggHatch0[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_EggHatch1[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(16, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_EggHatch2[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(32, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_EggHatch3[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(48, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd *const sSpriteAnimTable_EggHatch[] =
|
|
|
|
{
|
|
|
|
sSpriteAnim_EggHatch0,
|
|
|
|
sSpriteAnim_EggHatch1,
|
|
|
|
sSpriteAnim_EggHatch2,
|
|
|
|
sSpriteAnim_EggHatch3,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpriteSheet sEggHatch_Sheet =
|
|
|
|
{
|
|
|
|
.data = sEggHatchTiles,
|
|
|
|
.size = 2048,
|
|
|
|
.tag = 12345,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpriteSheet sEggShards_Sheet =
|
|
|
|
{
|
|
|
|
.data = sEggShardTiles,
|
|
|
|
.size = 128,
|
|
|
|
.tag = 23456,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpritePalette sEgg_SpritePalette =
|
|
|
|
{
|
|
|
|
.data = sEggPalette,
|
|
|
|
.tag = 54321
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_EggHatch =
|
|
|
|
{
|
|
|
|
.tileTag = 12345,
|
|
|
|
.paletteTag = 54321,
|
|
|
|
.oam = &sOamData_EggHatch,
|
|
|
|
.anims = sSpriteAnimTable_EggHatch,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct OamData sOamData_EggShard =
|
|
|
|
{
|
|
|
|
.y = 0,
|
|
|
|
.affineMode = 0,
|
|
|
|
.objMode = 0,
|
|
|
|
.mosaic = 0,
|
|
|
|
.bpp = 0,
|
|
|
|
.shape = 0,
|
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
|
|
|
.size = 0,
|
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 2,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_EggShard0[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_EggShard1[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(1, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_EggShard2[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(2, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_EggShard3[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(3, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd *const sSpriteAnimTable_EggShard[] =
|
|
|
|
{
|
|
|
|
sSpriteAnim_EggShard0,
|
|
|
|
sSpriteAnim_EggShard1,
|
|
|
|
sSpriteAnim_EggShard2,
|
|
|
|
sSpriteAnim_EggShard3,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_EggShard =
|
|
|
|
{
|
|
|
|
.tileTag = 23456,
|
|
|
|
.paletteTag = 54321,
|
|
|
|
.oam = &sOamData_EggShard,
|
|
|
|
.anims = sSpriteAnimTable_EggShard,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCB_EggShard
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct BgTemplate sBgTemplates_EggHatch[2] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 2,
|
|
|
|
.mapBaseIndex = 24,
|
|
|
|
.screenSize = 3,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 8,
|
|
|
|
.screenSize = 1,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 2,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct WindowTemplate sWinTemplates_EggHatch[2] =
|
|
|
|
{
|
|
|
|
{0, 2, 0xF, 0x1A, 4, 0, 0x40},
|
|
|
|
DUMMY_WIN_TEMPLATE
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct WindowTemplate sYesNoWinTemplate =
|
|
|
|
{
|
|
|
|
0, 0x15, 9, 5, 4, 0xF, 0x1A8
|
|
|
|
};
|
|
|
|
|
|
|
|
static const s16 sEggShardVelocities[][2] =
|
|
|
|
{
|
|
|
|
{Q_8_8(-1.5), Q_8_8(-3.75)},
|
|
|
|
{Q_8_8(-5), Q_8_8(-3)},
|
|
|
|
{Q_8_8(3.5), Q_8_8(-3)},
|
|
|
|
{Q_8_8(-4), Q_8_8(-3.75)},
|
|
|
|
{Q_8_8(2), Q_8_8(-1.5)},
|
|
|
|
{Q_8_8(-0.5), Q_8_8(-6.75)},
|
|
|
|
{Q_8_8(5), Q_8_8(-2.25)},
|
|
|
|
{Q_8_8(-1.5), Q_8_8(-3.75)},
|
|
|
|
{Q_8_8(4.5), Q_8_8(-1.5)},
|
|
|
|
{Q_8_8(-1), Q_8_8(-6.75)},
|
|
|
|
{Q_8_8(4), Q_8_8(-2.25)},
|
|
|
|
{Q_8_8(-3.5), Q_8_8(-3.75)},
|
|
|
|
{Q_8_8(1), Q_8_8(-1.5)},
|
|
|
|
{Q_8_8(-3.515625), Q_8_8(-6.75)},
|
|
|
|
{Q_8_8(4.5), Q_8_8(-2.25)},
|
|
|
|
{Q_8_8(-0.5), Q_8_8(-7.5)},
|
|
|
|
{Q_8_8(1), Q_8_8(-4.5)},
|
|
|
|
{Q_8_8(-2.5), Q_8_8(-2.25)},
|
|
|
|
{Q_8_8(2.5), Q_8_8(-7.5)},
|
|
|
|
};
|
|
|
|
|
|
|
|
// code
|
|
|
|
|
2017-09-18 18:36:05 +02:00
|
|
|
static void CreatedHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
|
|
|
|
{
|
|
|
|
u16 species;
|
|
|
|
u32 personality, pokerus;
|
|
|
|
u8 i, friendship, language, gameMet, markings, obedience;
|
|
|
|
u16 moves[4];
|
|
|
|
u32 ivs[6];
|
|
|
|
|
|
|
|
|
|
|
|
species = GetMonData(egg, MON_DATA_SPECIES);
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
moves[i] = GetMonData(egg, MON_DATA_MOVE1 + i);
|
|
|
|
}
|
|
|
|
|
|
|
|
personality = GetMonData(egg, MON_DATA_PERSONALITY);
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
{
|
|
|
|
ivs[i] = GetMonData(egg, MON_DATA_HP_IV + i);
|
|
|
|
}
|
|
|
|
|
|
|
|
language = GetMonData(egg, MON_DATA_LANGUAGE);
|
|
|
|
gameMet = GetMonData(egg, MON_DATA_MET_GAME);
|
|
|
|
markings = GetMonData(egg, MON_DATA_MARKINGS);
|
|
|
|
pokerus = GetMonData(egg, MON_DATA_POKERUS);
|
|
|
|
obedience = GetMonData(egg, MON_DATA_OBEDIENCE);
|
|
|
|
|
2017-11-14 21:43:23 +01:00
|
|
|
CreateMon(temp, species, EGG_HATCH_LEVEL, 32, TRUE, personality, 0, 0);
|
2017-09-18 18:36:05 +02:00
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
SetMonData(temp, MON_DATA_MOVE1 + i, &moves[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
{
|
|
|
|
SetMonData(temp, MON_DATA_HP_IV + i, &ivs[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
language = GAME_LANGUAGE;
|
|
|
|
SetMonData(temp, MON_DATA_LANGUAGE, &language);
|
|
|
|
SetMonData(temp, MON_DATA_MET_GAME, &gameMet);
|
|
|
|
SetMonData(temp, MON_DATA_MARKINGS, &markings);
|
|
|
|
|
|
|
|
friendship = 120;
|
|
|
|
SetMonData(temp, MON_DATA_FRIENDSHIP, &friendship);
|
|
|
|
SetMonData(temp, MON_DATA_POKERUS, &pokerus);
|
|
|
|
SetMonData(temp, MON_DATA_OBEDIENCE, &obedience);
|
|
|
|
|
|
|
|
*egg = *temp;
|
|
|
|
}
|
|
|
|
|
2017-09-18 23:48:47 +02:00
|
|
|
static void AddHatchedMonToParty(u8 id)
|
2017-09-18 18:36:05 +02:00
|
|
|
{
|
|
|
|
u8 isEgg = 0x46; // ?
|
|
|
|
u16 pokeNum;
|
|
|
|
u8 name[12];
|
|
|
|
u16 ball;
|
|
|
|
u16 caughtLvl;
|
|
|
|
u8 mapNameID;
|
|
|
|
struct Pokemon* mon = &gPlayerParty[id];
|
|
|
|
|
|
|
|
CreatedHatchedMon(mon, &gEnemyParty[0]);
|
|
|
|
SetMonData(mon, MON_DATA_IS_EGG, &isEgg);
|
|
|
|
|
|
|
|
pokeNum = GetMonData(mon, MON_DATA_SPECIES);
|
|
|
|
GetSpeciesName(name, pokeNum);
|
|
|
|
SetMonData(mon, MON_DATA_NICKNAME, name);
|
|
|
|
|
|
|
|
pokeNum = SpeciesToNationalPokedexNum(pokeNum);
|
|
|
|
GetSetPokedexFlag(pokeNum, FLAG_SET_SEEN);
|
|
|
|
GetSetPokedexFlag(pokeNum, FLAG_SET_CAUGHT);
|
|
|
|
|
|
|
|
GetMonNick(mon, gStringVar1);
|
|
|
|
|
|
|
|
ball = ITEM_POKE_BALL;
|
|
|
|
SetMonData(mon, MON_DATA_POKEBALL, &ball);
|
|
|
|
|
|
|
|
caughtLvl = 0;
|
|
|
|
SetMonData(mon, MON_DATA_MET_LEVEL, &caughtLvl);
|
|
|
|
|
|
|
|
mapNameID = sav1_map_get_name();
|
|
|
|
SetMonData(mon, MON_DATA_MET_LOCATION, &mapNameID);
|
|
|
|
|
|
|
|
MonRestorePP(mon);
|
|
|
|
CalculateMonStats(mon);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScriptHatchMon(void)
|
|
|
|
{
|
|
|
|
AddHatchedMonToParty(gSpecialVar_0x8004);
|
|
|
|
}
|
|
|
|
|
2017-11-14 21:43:23 +01:00
|
|
|
static bool8 sub_807158C(struct DayCare *daycare, u8 daycareId)
|
2017-09-18 18:36:05 +02:00
|
|
|
{
|
|
|
|
u8 nick[0x20];
|
2017-11-14 21:43:23 +01:00
|
|
|
struct DaycareMon *daycareMon = &daycare->mons[daycareId];
|
2017-09-18 18:36:05 +02:00
|
|
|
|
|
|
|
GetBoxMonNick(&daycareMon->mon, nick);
|
2017-11-14 21:43:23 +01:00
|
|
|
if (daycareMon->misc.mail.itemId != 0
|
|
|
|
&& (StringCompareWithoutExtCtrlCodes(nick, daycareMon->misc.monName) != 0
|
|
|
|
|| StringCompareWithoutExtCtrlCodes(gSaveBlock2Ptr->playerName, daycareMon->misc.OT_name) != 0))
|
2017-09-18 18:36:05 +02:00
|
|
|
{
|
|
|
|
StringCopy(gStringVar1, nick);
|
2017-11-14 21:43:23 +01:00
|
|
|
TVShowConvertInternationalString(gStringVar2, daycareMon->misc.OT_name, daycareMon->misc.gameLanguage);
|
|
|
|
TVShowConvertInternationalString(gStringVar3, daycareMon->misc.monName, daycareMon->misc.monLanguage);
|
2017-09-18 18:36:05 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool8 sub_8071614(void)
|
|
|
|
{
|
|
|
|
return sub_807158C(&gSaveBlock1Ptr->daycare, gSpecialVar_0x8004);
|
|
|
|
}
|
|
|
|
|
2017-09-18 23:48:47 +02:00
|
|
|
static u8 EggHatchCreateMonSprite(u8 a0, u8 switchID, u8 pokeID, u16* speciesLoc)
|
2017-09-18 18:36:05 +02:00
|
|
|
{
|
|
|
|
u8 r5 = 0;
|
|
|
|
u8 spriteID = 0;
|
|
|
|
struct Pokemon* mon = NULL;
|
|
|
|
|
|
|
|
if (a0 == 0)
|
|
|
|
{
|
|
|
|
mon = &gPlayerParty[pokeID];
|
|
|
|
r5 = 1;
|
|
|
|
}
|
|
|
|
if (a0 == 1)
|
|
|
|
{
|
|
|
|
mon = &gPlayerParty[pokeID];
|
|
|
|
r5 = 3;
|
|
|
|
}
|
|
|
|
switch (switchID)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
u16 species = GetMonData(mon, MON_DATA_SPECIES);
|
|
|
|
u32 pid = GetMonData(mon, MON_DATA_PERSONALITY);
|
|
|
|
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species],
|
2017-10-01 01:12:42 +02:00
|
|
|
gMonSpritesGfxPtr->sprites[(a0 * 2) + 1],
|
2017-09-18 18:36:05 +02:00
|
|
|
species, pid);
|
|
|
|
LoadCompressedObjectPalette(sub_806E794(mon));
|
|
|
|
*speciesLoc = species;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
sub_806A068(sub_806E794(mon)->tag, r5);
|
|
|
|
spriteID = CreateSprite(&gUnknown_0202499C, 120, 75, 6);
|
|
|
|
gSprites[spriteID].invisible = 1;
|
|
|
|
gSprites[spriteID].callback = SpriteCallbackDummy;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return spriteID;
|
|
|
|
}
|
|
|
|
|
2017-09-18 23:48:47 +02:00
|
|
|
static void VBlankCB_EggHatch(void)
|
2017-09-18 18:36:05 +02:00
|
|
|
{
|
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
|
|
|
TransferPlttBuffer();
|
|
|
|
}
|
|
|
|
|
2017-10-14 20:26:25 +02:00
|
|
|
void EggHatch(void)
|
2017-09-18 18:36:05 +02:00
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
CreateTask(Task_EggHatch, 10);
|
|
|
|
fade_screen(1, 0);
|
|
|
|
}
|
|
|
|
|
2017-09-18 23:48:47 +02:00
|
|
|
static void Task_EggHatch(u8 taskID)
|
2017-09-18 18:36:05 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
overworld_free_bg_tilemaps();
|
|
|
|
SetMainCallback2(CB2_EggHatch_0);
|
|
|
|
gFieldCallback = sub_80AF168;
|
|
|
|
DestroyTask(taskID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-18 23:48:47 +02:00
|
|
|
static void CB2_EggHatch_0(void)
|
2017-09-18 18:36:05 +02:00
|
|
|
{
|
|
|
|
switch (gMain.state)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
|
|
|
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData = Alloc(sizeof(struct EggHatchData));
|
2017-10-01 01:12:42 +02:00
|
|
|
AllocateMonSpritesGfx();
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData->eggPartyID = gSpecialVar_0x8004;
|
|
|
|
sEggHatchData->eggShardVelocityID = 0;
|
2017-09-18 18:36:05 +02:00
|
|
|
|
|
|
|
SetVBlankCallback(VBlankCB_EggHatch);
|
|
|
|
gSpecialVar_0x8005 = GetCurrentMapMusic();
|
|
|
|
|
|
|
|
reset_temp_tile_data_buffers();
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
2017-09-19 14:27:46 +02:00
|
|
|
InitBgsFromTemplates(0, sBgTemplates_EggHatch, ARRAY_COUNT(sBgTemplates_EggHatch));
|
2017-09-18 18:36:05 +02:00
|
|
|
|
|
|
|
ChangeBgX(1, 0, 0);
|
|
|
|
ChangeBgY(1, 0, 0);
|
|
|
|
ChangeBgX(0, 0, 0);
|
|
|
|
ChangeBgY(0, 0, 0);
|
|
|
|
|
|
|
|
SetBgAttribute(1, BG_CTRL_ATTR_MOSAIC, 2);
|
|
|
|
SetBgTilemapBuffer(1, Alloc(0x1000));
|
|
|
|
SetBgTilemapBuffer(0, Alloc(0x2000));
|
|
|
|
|
|
|
|
DeactivateAllTextPrinters();
|
|
|
|
ResetPaletteFade();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
ResetSpriteData();
|
|
|
|
ResetTasks();
|
|
|
|
remove_some_task();
|
|
|
|
m4aSoundVSyncOn();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 1:
|
2017-09-19 14:27:46 +02:00
|
|
|
InitWindows(sWinTemplates_EggHatch);
|
|
|
|
sEggHatchData->windowId = 0;
|
2017-09-18 18:36:05 +02:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
copy_decompressed_tile_data_to_vram_autofree(0, gUnknown_08C00000, 0, 0, 0);
|
|
|
|
CopyToBgTilemapBuffer(0, gUnknown_08C00524, 0, 0);
|
|
|
|
LoadCompressedPalette(gUnknown_08C004E0, 0, 0x20);
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 3:
|
2017-09-19 14:27:46 +02:00
|
|
|
LoadSpriteSheet(&sEggHatch_Sheet);
|
|
|
|
LoadSpriteSheet(&sEggShards_Sheet);
|
|
|
|
LoadSpritePalette(&sEgg_SpritePalette);
|
2017-09-18 18:36:05 +02:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
2017-09-19 14:27:46 +02:00
|
|
|
AddHatchedMonToParty(sEggHatchData->eggPartyID);
|
2017-09-18 18:36:05 +02:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 5:
|
2017-09-19 14:27:46 +02:00
|
|
|
EggHatchCreateMonSprite(0, 0, sEggHatchData->eggPartyID, &sEggHatchData->species);
|
2017-09-18 18:36:05 +02:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 6:
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData->pokeSpriteID = EggHatchCreateMonSprite(0, 1, sEggHatchData->eggPartyID, &sEggHatchData->species);
|
2017-09-18 18:36:05 +02:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
|
|
|
LoadPalette(gUnknown_08DD7300, 0x10, 0xA0);
|
|
|
|
LoadBgTiles(1, gUnknown_08DD7360, 0x1420, 0);
|
|
|
|
CopyToBgTilemapBuffer(1, gUnknown_08331F60, 0x1000, 0);
|
|
|
|
CopyBgTilemapBufferToVram(1);
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
SetMainCallback2(CB2_EggHatch_1);
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData->CB2_state = 0;
|
2017-09-18 18:36:05 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
RunTasks();
|
|
|
|
RunTextPrinters();
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
UpdatePaletteFade();
|
|
|
|
}
|
2017-09-18 23:48:47 +02:00
|
|
|
|
|
|
|
static void EggHatchSetMonNickname(void)
|
|
|
|
{
|
|
|
|
SetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, gStringVar3);
|
2017-10-01 18:54:01 +02:00
|
|
|
FreeMonSpritesGfx();
|
2017-09-19 14:27:46 +02:00
|
|
|
Free(sEggHatchData);
|
2017-09-18 23:48:47 +02:00
|
|
|
SetMainCallback2(c2_exit_to_overworld_2_switch);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Task_EggHatchPlayBGM(u8 taskID)
|
|
|
|
{
|
|
|
|
if (gTasks[taskID].data[0] == 0)
|
|
|
|
{
|
|
|
|
StopMapMusic();
|
|
|
|
play_some_sound();
|
|
|
|
}
|
|
|
|
if (gTasks[taskID].data[0] == 1)
|
|
|
|
PlayBGM(376);
|
|
|
|
if (gTasks[taskID].data[0] > 60)
|
|
|
|
{
|
|
|
|
PlayBGM(377);
|
|
|
|
DestroyTask(taskID);
|
|
|
|
// UB: task is destroyed, yet the value is incremented
|
|
|
|
}
|
|
|
|
gTasks[taskID].data[0]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CB2_EggHatch_1(void)
|
|
|
|
{
|
|
|
|
u16 species;
|
|
|
|
u8 gender;
|
|
|
|
u32 personality;
|
|
|
|
|
2017-09-19 14:27:46 +02:00
|
|
|
switch (sEggHatchData->CB2_state)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
BeginNormalPaletteFade(-1, 0, 0x10, 0, 0);
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData->eggSpriteID = CreateSprite(&sSpriteTemplate_EggHatch, 120, 75, 5);
|
2017-09-18 23:48:47 +02:00
|
|
|
ShowBg(0);
|
|
|
|
ShowBg(1);
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData->CB2_state++;
|
2017-09-18 23:48:47 +02:00
|
|
|
CreateTask(Task_EggHatchPlayBGM, 5);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2017-09-19 14:27:46 +02:00
|
|
|
FillWindowPixelBuffer(sEggHatchData->windowId, 0);
|
|
|
|
sEggHatchData->CB2_PalCounter = 0;
|
|
|
|
sEggHatchData->CB2_state++;
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2017-09-19 14:27:46 +02:00
|
|
|
if (++sEggHatchData->CB2_PalCounter > 30)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData->CB2_state++;
|
|
|
|
gSprites[sEggHatchData->eggSpriteID].callback = SpriteCB_Egg_0;
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2017-09-19 14:27:46 +02:00
|
|
|
if (gSprites[sEggHatchData->eggSpriteID].callback == SpriteCallbackDummy)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
2017-09-19 14:27:46 +02:00
|
|
|
species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyID], MON_DATA_SPECIES);
|
|
|
|
DoMonFrontSpriteAnimation(&gSprites[sEggHatchData->pokeSpriteID], species, FALSE, 1);
|
|
|
|
sEggHatchData->CB2_state++;
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
2017-09-19 14:27:46 +02:00
|
|
|
if (gSprites[sEggHatchData->pokeSpriteID].callback == SpriteCallbackDummy)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData->CB2_state++;
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
2017-09-19 14:27:46 +02:00
|
|
|
GetMonNick(&gPlayerParty[sEggHatchData->eggPartyID], gStringVar1);
|
2017-09-21 10:50:15 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_HatchedFromEgg);
|
2017-09-19 14:27:46 +02:00
|
|
|
EggHatchPrintMessage(sEggHatchData->windowId, gStringVar4, 0, 3, 0xFF);
|
2017-09-18 23:48:47 +02:00
|
|
|
PlayFanfare(371);
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData->CB2_state++;
|
|
|
|
PutWindowTilemap(sEggHatchData->windowId);
|
|
|
|
CopyWindowToVram(sEggHatchData->windowId, 3);
|
2017-09-18 23:48:47 +02:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
if (IsFanfareTaskInactive())
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData->CB2_state++;
|
2017-09-18 23:48:47 +02:00
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
if (IsFanfareTaskInactive())
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData->CB2_state++;
|
2017-09-18 23:48:47 +02:00
|
|
|
break;
|
|
|
|
case 8:
|
2017-09-19 14:27:46 +02:00
|
|
|
GetMonNick(&gPlayerParty[sEggHatchData->eggPartyID], gStringVar1);
|
2017-09-21 10:50:15 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_NickHatchPrompt);
|
2017-09-19 14:27:46 +02:00
|
|
|
EggHatchPrintMessage(sEggHatchData->windowId, gStringVar4, 0, 2, 1);
|
|
|
|
sEggHatchData->CB2_state++;
|
2017-09-18 23:48:47 +02:00
|
|
|
break;
|
|
|
|
case 9:
|
2017-09-19 14:27:46 +02:00
|
|
|
if (!IsTextPrinterActive(sEggHatchData->windowId))
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
2017-09-19 14:27:46 +02:00
|
|
|
sub_809882C(sEggHatchData->windowId, 0x140, 0xE0);
|
|
|
|
CreateYesNoMenu(&sYesNoWinTemplate, 0x140, 0xE, 0);
|
|
|
|
sEggHatchData->CB2_state++;
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
switch (sub_8198C58())
|
|
|
|
{
|
|
|
|
case 0:
|
2017-09-19 14:27:46 +02:00
|
|
|
GetMonNick(&gPlayerParty[sEggHatchData->eggPartyID], gStringVar3);
|
|
|
|
species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyID], MON_DATA_SPECIES);
|
|
|
|
gender = GetMonGender(&gPlayerParty[sEggHatchData->eggPartyID]);
|
|
|
|
personality = GetMonData(&gPlayerParty[sEggHatchData->eggPartyID], MON_DATA_PERSONALITY, 0);
|
2017-09-18 23:48:47 +02:00
|
|
|
DoNamingScreen(3, gStringVar3, species, gender, personality, EggHatchSetMonNickname);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case -1:
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData->CB2_state++;
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData->CB2_state++;
|
2017-09-18 23:48:47 +02:00
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2017-10-01 18:54:01 +02:00
|
|
|
FreeMonSpritesGfx();
|
2017-09-19 14:27:46 +02:00
|
|
|
RemoveWindow(sEggHatchData->windowId);
|
2017-09-18 23:48:47 +02:00
|
|
|
UnsetBgTilemapBuffer(0);
|
|
|
|
UnsetBgTilemapBuffer(1);
|
2017-09-19 14:27:46 +02:00
|
|
|
Free(sEggHatchData);
|
2017-09-18 23:48:47 +02:00
|
|
|
SetMainCallback2(c2_exit_to_overworld_2_switch);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
RunTasks();
|
|
|
|
RunTextPrinters();
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
UpdatePaletteFade();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SpriteCB_Egg_0(struct Sprite* sprite)
|
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
if (++sprite->data[0] > 20)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
|
|
|
sprite->callback = SpriteCB_Egg_1;
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[0] = 0;
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[1] = (sprite->data[1] + 20) & 0xFF;
|
|
|
|
sprite->pos2.x = Sin(sprite->data[1], 1);
|
|
|
|
if (sprite->data[0] == 15)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_BOWA);
|
|
|
|
StartSpriteAnim(sprite, 1);
|
|
|
|
CreateRandomEggShardSprite();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SpriteCB_Egg_1(struct Sprite* sprite)
|
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
if (++sprite->data[2] > 30)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
if (++sprite->data[0] > 20)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
|
|
|
sprite->callback = SpriteCB_Egg_2;
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[0] = 0;
|
|
|
|
sprite->data[2] = 0;
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[1] = (sprite->data[1] + 20) & 0xFF;
|
|
|
|
sprite->pos2.x = Sin(sprite->data[1], 2);
|
|
|
|
if (sprite->data[0] == 15)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_BOWA);
|
|
|
|
StartSpriteAnim(sprite, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SpriteCB_Egg_2(struct Sprite* sprite)
|
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
if (++sprite->data[2] > 30)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
if (++sprite->data[0] > 38)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
|
|
|
u16 species;
|
|
|
|
|
|
|
|
sprite->callback = SpriteCB_Egg_3;
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[0] = 0;
|
2017-09-19 14:27:46 +02:00
|
|
|
species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyID], MON_DATA_SPECIES);
|
|
|
|
gSprites[sEggHatchData->pokeSpriteID].pos2.x = 0;
|
|
|
|
gSprites[sEggHatchData->pokeSpriteID].pos2.y = 0;
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[1] = (sprite->data[1] + 20) & 0xFF;
|
|
|
|
sprite->pos2.x = Sin(sprite->data[1], 2);
|
|
|
|
if (sprite->data[0] == 15)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_BOWA);
|
|
|
|
StartSpriteAnim(sprite, 2);
|
|
|
|
CreateRandomEggShardSprite();
|
|
|
|
CreateRandomEggShardSprite();
|
|
|
|
}
|
2017-12-02 21:44:50 +01:00
|
|
|
if (sprite->data[0] == 30)
|
2017-09-18 23:48:47 +02:00
|
|
|
PlaySE(SE_BOWA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SpriteCB_Egg_3(struct Sprite* sprite)
|
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
if (++sprite->data[0] > 50)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
|
|
|
sprite->callback = SpriteCB_Egg_4;
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[0] = 0;
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SpriteCB_Egg_4(struct Sprite* sprite)
|
|
|
|
{
|
|
|
|
s16 i;
|
2017-12-02 21:44:50 +01:00
|
|
|
if (sprite->data[0] == 0)
|
2017-09-18 23:48:47 +02:00
|
|
|
BeginNormalPaletteFade(-1, -1, 0, 0x10, 0xFFFF);
|
2017-12-02 21:44:50 +01:00
|
|
|
if (sprite->data[0] < 4u)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
|
|
|
for (i = 0; i <= 3; i++)
|
|
|
|
CreateRandomEggShardSprite();
|
|
|
|
}
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[0]++;
|
2017-09-18 23:48:47 +02:00
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
PlaySE(SE_TAMAGO);
|
|
|
|
sprite->invisible = 1;
|
|
|
|
sprite->callback = SpriteCB_Egg_5;
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[0] = 0;
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SpriteCB_Egg_5(struct Sprite* sprite)
|
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
if (sprite->data[0] == 0)
|
2017-09-18 23:48:47 +02:00
|
|
|
{
|
2017-09-19 14:27:46 +02:00
|
|
|
gSprites[sEggHatchData->pokeSpriteID].invisible = 0;
|
|
|
|
StartSpriteAffineAnim(&gSprites[sEggHatchData->pokeSpriteID], 1);
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|
2017-12-02 21:44:50 +01:00
|
|
|
if (sprite->data[0] == 8)
|
2017-09-18 23:48:47 +02:00
|
|
|
BeginNormalPaletteFade(-1, -1, 0x10, 0, 0xFFFF);
|
2017-12-02 21:44:50 +01:00
|
|
|
if (sprite->data[0] <= 9)
|
2017-09-19 14:27:46 +02:00
|
|
|
gSprites[sEggHatchData->pokeSpriteID].pos1.y -= 1;
|
2017-12-02 21:44:50 +01:00
|
|
|
if (sprite->data[0] > 40)
|
2017-09-18 23:48:47 +02:00
|
|
|
sprite->callback = SpriteCallbackDummy;
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[0]++;
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void SpriteCB_EggShard(struct Sprite* sprite)
|
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[4] += sprite->data[1];
|
|
|
|
sprite->data[5] += sprite->data[2];
|
2017-09-18 23:48:47 +02:00
|
|
|
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->pos2.x = sprite->data[4] / 256;
|
|
|
|
sprite->pos2.y = sprite->data[5] / 256;
|
2017-09-18 23:48:47 +02:00
|
|
|
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[2] += sprite->data[3];
|
2017-09-18 23:48:47 +02:00
|
|
|
|
2017-12-02 21:44:50 +01:00
|
|
|
if (sprite->pos1.y + sprite->pos2.y > sprite->pos1.y + 20 && sprite->data[2] > 0)
|
2017-09-18 23:48:47 +02:00
|
|
|
DestroySprite(sprite);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CreateRandomEggShardSprite(void)
|
|
|
|
{
|
|
|
|
u16 spriteAnimIndex;
|
|
|
|
|
2017-09-19 14:27:46 +02:00
|
|
|
s16 velocity1 = sEggShardVelocities[sEggHatchData->eggShardVelocityID][0];
|
|
|
|
s16 velocity2 = sEggShardVelocities[sEggHatchData->eggShardVelocityID][1];
|
|
|
|
sEggHatchData->eggShardVelocityID++;
|
2017-09-18 23:48:47 +02:00
|
|
|
spriteAnimIndex = Random() % 4;
|
|
|
|
CreateEggShardSprite(120, 60, velocity1, velocity2, 100, spriteAnimIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8 spriteAnimIndex)
|
|
|
|
{
|
2017-09-19 14:27:46 +02:00
|
|
|
u8 spriteID = CreateSprite(&sSpriteTemplate_EggShard, x, y, 4);
|
2017-12-02 21:44:50 +01:00
|
|
|
gSprites[spriteID].data[1] = data1;
|
|
|
|
gSprites[spriteID].data[2] = data2;
|
|
|
|
gSprites[spriteID].data[3] = data3;
|
2017-09-18 23:48:47 +02:00
|
|
|
StartSpriteAnim(&gSprites[spriteID], spriteAnimIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void EggHatchPrintMessage(u8 windowId, u8* string, u8 x, u8 y, u8 speed)
|
|
|
|
{
|
|
|
|
FillWindowPixelBuffer(windowId, 0xFF);
|
2017-09-19 14:27:46 +02:00
|
|
|
sEggHatchData->textColor.fgColor = 0;
|
|
|
|
sEggHatchData->textColor.bgColor = 5;
|
|
|
|
sEggHatchData->textColor.shadowColor = 6;
|
|
|
|
AddTextPrinterParametrized2(windowId, 1, x, y, 0, 0, &sEggHatchData->textColor, speed, string);
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetEggStepsToSubtract(void)
|
|
|
|
{
|
|
|
|
u8 count, i;
|
|
|
|
for (count = CalculatePlayerPartyCount(), i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (!GetMonData(&gPlayerParty[i], MON_DATA_SANITY_BIT3))
|
|
|
|
{
|
|
|
|
u8 ability = GetMonAbility(&gPlayerParty[i]);
|
|
|
|
if (ability == ABILITY_MAGMA_ARMOR || ability == ABILITY_FLAME_BODY)
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
u16 sub_80722E0(void)
|
|
|
|
{
|
|
|
|
u16 value = sub_80D22D0();
|
2017-11-11 14:45:08 +01:00
|
|
|
value += CountPartyAliveNonEggMonsExcept(6);
|
2017-09-19 14:27:46 +02:00
|
|
|
return value;
|
2017-09-18 23:48:47 +02:00
|
|
|
}
|