diff --git a/data/data_8107224.s b/data/data_8107224.s index 5322d8304..e57e09fb4 100644 --- a/data/data_8107224.s +++ b/data/data_8107224.s @@ -12,26 +12,5 @@ .string "pksdir0\0" .string "pksdir0\0" .string "pksdir0\0" @ -@ ??? Jirachi -.string "pksdir0\0" - -.global gUnknown_81074FC -gUnknown_81074FC: @ 81074FC -.byte 0x4e, 0x4f, 0x50, 0x51, 0x4a, 0x49, 0x3e, 0x38 - -@ ??? -.string "pksdir0\0" @ lugia -@ ??? -.string "pksdir0\0" @kyorge -@ ??? -.string "pksdir0\0" @ deoxys -@ ??? -.string "pksdir0\0" @celebi -@ ??? -.string "pksdir0\0" @unk -@ ??? -.string "pksdir0\0" @ medicham -@ ??? -.string "pksdir0\0" @ smeargle .align 2,0 diff --git a/ld_script.txt b/ld_script.txt index 53ca5656a..b1094c24f 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -289,6 +289,14 @@ SECTIONS { src/dungeon_cutscene_articuno.o(.text); src/dungeon_cutscene_empty_summit.o(.text); src/dungeon_cutscenes.o(.text); + src/dungeon_cutscene_jirachi.o(.text); + src/dungeon_cutscene_lugia.o(.text); + src/dungeon_cutscene_kyogre.o(.text); + src/dungeon_cutscene_deoxys.o(.text); + src/dungeon_cutscene_celebi.o(.text); + src/dungeon_cutscene_medicham.o(.text); + src/dungeon_cutscene_smeargle.o(.text); + src/dungeon_cutscene_no_one_here.o(.text); src/dungeon_portrait_placement.o(.text); src/pokemon.o(.text); src/pokemon_3.o(.text); @@ -636,6 +644,14 @@ SECTIONS { src/dungeon_cutscene_articuno.o(.rodata); src/dungeon_cutscene_empty_summit.o(.rodata); data/data_8107224.o(.rodata); + src/dungeon_cutscene_jirachi.o(.rodata); + src/dungeon_cutscene_lugia.o(.rodata); + src/dungeon_cutscene_kyogre.o(.rodata); + src/dungeon_cutscene_deoxys.o(.rodata); + src/dungeon_cutscene_celebi.o(.rodata); + src/dungeon_cutscene_medicham.o(.rodata); + src/dungeon_cutscene_smeargle.o(.rodata); + src/dungeon_cutscene_no_one_here.o(.rodata); src/dungeon_portrait_placement.o(.rodata); src/pokemon.o(.rodata); data/data_81076E4.o(.rodata); diff --git a/src/dungeon_cutscene_articuno.c b/src/dungeon_cutscene_articuno.c index 397c2b230..1eb6e448d 100644 --- a/src/dungeon_cutscene_articuno.c +++ b/src/dungeon_cutscene_articuno.c @@ -47,7 +47,6 @@ extern void sub_8049B8C(void); extern void ShowWholeRevealedDungeonMap(void); extern void sub_8086A54(Entity *); extern void ResetMonEntityData(EntityInfo *, u32); -extern void sub_808BBA8(Entity * ); extern void sub_8041888(u32); extern u32 sub_80861F8(u32, Entity *, u32); extern u8 sub_80860A8(u32); diff --git a/src/dungeon_cutscene_celebi.c b/src/dungeon_cutscene_celebi.c new file mode 100644 index 000000000..a2af85d90 --- /dev/null +++ b/src/dungeon_cutscene_celebi.c @@ -0,0 +1,274 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "code_803E46C.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void sub_808C8E0(Entity *entity); +static void sub_808C9B0(Entity *param_1); + +void sub_808C5C0(void) +{ + Entity * leaderEntity; + Entity * celebiEntity; + + u32 XPos; + s32 YPos; + + leaderEntity = xxx_call_GetLeader(); + celebiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_CELEBI); + DungeonStartNewBGM(MUS_FRIEND_AREA_HEALING_FOREST); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + SetFacingDirection(celebiEntity, DIRECTION_SOUTH); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); + XPos = GetCameraXPos(); + YPos = GetCameraYPos(); + sub_803F878(XPos,YPos - 0x1000); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_CELEBI); +} + +void nullsub_100(u8 r0, u8 r1, u8 r3) +{ +} + +void CelebiJoinDialogue(void) +{ + Entity *leaderEntity; + s32 state; + s32 menuChoice; + Entity *celebiEntity; + + leaderEntity = xxx_call_GetLeader(); + celebiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_CELEBI); + if ((HasRecruitedMon(MONSTER_CELEBI)) || (!sub_806FD18(celebiEntity))) + { + sub_8068FE0(celebiEntity,0x21c,0); + SpriteLookAroundEffect(leaderEntity); + sub_803E708(10,0x46); + // ......... + DisplayDungeonDialogue(&gCelebiJoinDialogue_10); + } + else + { + SpriteLookAroundEffect(leaderEntity); + sub_803E708(10,0x46); + SpriteShockEffect(leaderEntity); + sub_803E708(10,0x46); + // Oh? There's someone there. + DisplayDungeonDialogue(&gCelebiJoinDialogue_1); + sub_803E708(10,0x46); + sub_8086598(); + sub_8086598(); + sub_8086598(); + sub_8086598(); + // The Time-Traveling Pokemon {POKEMON_2} (Celebi)! + DisplayDungeonDialogue(&gCelebiJoinDialogue_2); + PlaySoundEffect(0x1c7); + sub_806CDD4(celebiEntity,10,DIRECTION_SOUTH); + sub_803E708(0x14,0x46); + sub_806CE68(celebiEntity, DIRECTION_SOUTH); + sub_803E708(4,0x46); + PlaySoundEffect(0x1c7); + sub_806CDD4(celebiEntity,10,DIRECTION_SOUTH); + DisplayDungeonDialogue(&gCelebiJoinDialogue_3); + sub_803E708(10,0x46); + state = 0; + + do + { + switch(state) + { + case 0: + do + { + menuChoice = DisplayDungeonMenuMessage(0,gPtrPurityForestAllowCelebiToJoinText, gPurityForestAllowCelebiToJoinPrompt,0x701); + } while (menuChoice < 1); + + sub_803E708(10,0x46); + + if (menuChoice == 1) + { + DungeonStopBGM(); + PlaySoundEffect(0xcc); + while (IsFanfareSEPlaying_2(0xcc) != 0) { + DungeonRunFrameActions(0x46); + } + DungeonStartNewBGM(MUS_FRIEND_AREA_HEALING_FOREST); + PlaySoundEffect(0x1c7); + sub_80861D4(celebiEntity,0xd,DIRECTION_SOUTH); + sub_803E708(0x37,0x46); + PlaySoundEffect(0x1d5); + sub_803E708(0x1a,0x46); + PlaySoundEffect(0x1d5); + sub_803E708(0x1c,0x46); + DisplayDungeonDialogue(&gCelebiJoinDialogue_4); + sub_803E708(10,0x46); + sub_806FDF4(leaderEntity,celebiEntity,&celebiEntity); + DungeonStartNewBGM(MUS_FRIEND_AREA_HEALING_FOREST); + DisplayDungeonDialogue(&gCelebiJoinDialogue_5); + sub_803E708(10,0x46); + PlaySoundEffect(0x1c7); + sub_80861D4(celebiEntity,0xd,DIRECTION_SOUTH); + sub_803E708(0x37,0x46); + PlaySoundEffect(0x1d5); + sub_803E708(0x1a,0x46); + PlaySoundEffect(0x1d5); + sub_803E708(0x1b,0x46); + DisplayDungeonDialogue(&gCelebiJoinDialogue_6); + sub_803E708(10,0x46); + state = 2; + } + else + { + state = 1; + } + break; + case 1: + do + { + menuChoice = DisplayDungeonMenuMessage(0,gPtrPurityForestRefuseCelebiConfirmText, gPurityForestRefuseCelebiConfirmPrompt,0x701); + } while (menuChoice < 1); + if (menuChoice == 1) + { + state = 0; + } + else + { + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gCelebiJoinDialogue_7); + sub_80861F8(0x3e,celebiEntity,1); + sub_803E708(0x18,0x46); + sub_80861F8(0x3e,celebiEntity,1); + sub_803E708(0xe,0x46); + DisplayDungeonDialogue(&gCelebiJoinDialogue_8); + sub_803E708(10,0x46); + sub_808C8E0(celebiEntity); + DisplayDungeonDialogue(&gCelebiJoinDialogue_9); + sub_803E708(10,0x46); + state = 2; + } + break; + } + } while (state != 2); + } + DungeonFadeOutBGM(0x1e); + sub_803E708(0x1e,0x46); + gDungeon->unk2 = 1; +} + +static void sub_808C8E0(Entity *entity) +{ + s32 iVar1; + + PlaySoundEffect(0x1a5); + sub_806CDD4(entity, 0, DIRECTION_SOUTH); + for(iVar1 = 0; iVar1 < 16; iVar1++){ + GetEntInfo(entity)->unk174 = IntToF248_2(iVar1); + DungeonRunFrameActions(0x46); + } + for(iVar1 = 16; iVar1 < 200; iVar1 += 4){ + GetEntInfo(entity)->unk174 = IntToF248_2(iVar1); + DungeonRunFrameActions(0x46); + } + sub_8086A3C(entity); +} + +void sub_808C938(void) +{ + sub_80855E4(sub_808C9B0); +} + +void sub_808C948(Entity *entity, u8 param_2) +{ + bool8 flag; + s32 index; + Entity *pokeEntity; + + if (param_2 == 0x37) { + flag = FALSE; + for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++){ + pokeEntity = gDungeon->wildPokemon[index]; + if ((pokeEntity != entity) && (EntityIsValid(pokeEntity))) { + flag = TRUE; + break; + } + } + if (!flag) { + gDungeon->unk2 = 1; + } + } +} + +void sub_808C998(void) +{ + // Defeat the opposing team to win + // Be careful, your opponents are tough + DisplayDungeonDialogue(&gUnknown_8106720); + sub_803E708(0xA, 0x46); +} + +static void sub_808C9B0(Entity *param_1) +{ + GetEntInfo(param_1)->action.direction = DIRECTION_NORTH; + sub_806CE68(param_1, DIRECTION_NORTH); +} diff --git a/src/dungeon_cutscene_deoxys.c b/src/dungeon_cutscene_deoxys.c new file mode 100644 index 000000000..2cf857982 --- /dev/null +++ b/src/dungeon_cutscene_deoxys.c @@ -0,0 +1,175 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "code_803E46C.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern s32 gDungeonBrightness; + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void DeoxysScreenFlash(void); +static void sub_808C550(void); +static void sub_808C590(Entity *r0); +static void SetupDeoxysFacingDirection(Entity *deoxysEntity); +static void SetupDeoxysFightHP(Entity *deoxysEntity); + +void sub_808C3A0(void) +{ + Entity * leaderEntity; + + leaderEntity = xxx_call_GetLeader(); + DungeonStopBGM(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + if (HasRecruitedMon(MONSTER_DEOXYS_NORMAL)) { + sub_808563C(sub_808C590); + } + else { + gDungeon->unk7 = 1; + sub_808563C(SetupDeoxysFacingDirection); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_DEOXYS_NORMAL); +} + +void sub_808C414(u8 param_1,u8 param_2,u8 param_3) +{ + if ((param_2 == 0x35) && (param_1 == 0x1D)) { + gDungeon->unk2 = 1; + DungeonStartNewBGM(MUS_RAYQUAZAS_DOMAIN); + } +} + +void DeoxysPreFightDialogue(void) +{ + Entity * leaderEntity; + + leaderEntity = xxx_call_GetLeader(); + sub_8086448(); + if (HasRecruitedMon(MONSTER_DEOXYS_NORMAL)) { + // There appears to be no one here. + // It's impossible to go any further + sub_80866C4(&gDeoxysPreFightDialogue_5); + } + else { + DisplayDungeonDialogue(&gDeoxysPreFightDialogue_1); + DungeonFadeInNewBGM(MUS_RAYQUAZAS_DOMAIN, 0x3c); + sub_808C550(); + DisplayDungeonDialogue(&gDeoxysPreFightDialogue_2); + DeoxysScreenFlash(); + DisplayDungeonDialogue(&gDeoxysPreFightDialogue_3); + DeoxysScreenFlash(); + DisplayDungeonDialogue(&gDeoxysPreFightDialogue_4); + sub_803E708(10,0x46); + sub_808563C(SetupDeoxysFightHP); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void DeoxysScreenFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x2c1); + for(iVar1 = 250; iVar1 > 149; iVar1 -= 10){ + SetDungeonBGColorRGB(iVar1,0,0,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10){ + SetDungeonBGColorRGB(iVar1,iVar1,0,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10){ + SetDungeonBGColorRGB(iVar1,0,0,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + sub_8085EB0(); +} + +static void sub_808C550(void) +{ + gDungeonBrightness = 0x1f; + SetDungeonBGColorRGB(0,0,0,1,1); + BgColorCallNullsub4(); + DungeonRunFrameActions(0x46); + gDungeon->unk7 = 0; + DeoxysScreenFlash(); +} + +static void sub_808C590(Entity *r0) +{ + sub_8068FE0(r0, 0x21C, 0); +} + +static void SetupDeoxysFacingDirection(Entity *deoxysEntity) +{ + SetFacingDirection(deoxysEntity, DIRECTION_SOUTH); +} + +static void SetupDeoxysFightHP(Entity *deoxysEntity) +{ + SetupBossFightHP(deoxysEntity, 950, MUS_BATTLE_WITH_RAYQUAZA); +} + diff --git a/src/dungeon_cutscene_jirachi.c b/src/dungeon_cutscene_jirachi.c new file mode 100644 index 000000000..5c2b6abfa --- /dev/null +++ b/src/dungeon_cutscene_jirachi.c @@ -0,0 +1,567 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "code_803E46C.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern s32 gDungeonBrightness; + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void sub_808B50C(void); +static void JirachiWish(void); +static void JirachiWishGrantFlash(void); +static void sub_808BB3C(DungeonPos *pos1); +static void sub_808BBA8(Entity *jirachiEntity); +static void JirachiDropInEffect(Entity *jirachiEntity); +static void JirachiSpinEffect(Entity * jirachiEntity); +static void JirachiWishGrantDialogue(Entity *jirachiEntity); +static void CreateJirachiWishWarpTile(void); +static void EnableJirachiWishWarpTile(void); +static u8 JirachiFriendAreaSearch(void); + +void sub_808B2F4(void) +{ + Entity * leaderEntity; + Entity * jirachiEntity; + + leaderEntity = xxx_call_GetLeader(); + jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); + DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); + CreateJirachiWishWarpTile(); + sub_8049ED4(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + SetFacingDirection(jirachiEntity, DIRECTION_SOUTH); + sub_8086A3C(jirachiEntity); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); +} + +void sub_808B35C(void) +{ + Entity * leaderEntity; + Entity * jirachiEntity; + + leaderEntity = xxx_call_GetLeader(); + jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); + DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + if (HasRecruitedMon(MONSTER_JIRACHI)) { + sub_8068FE0(jirachiEntity,0x21c,0); + } + else { + SetFacingDirection(jirachiEntity, DIRECTION_SOUTH); + sub_8086A3C(jirachiEntity); + CreateJirachiWishWarpTile(); + sub_8049ED4(); + + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); +} + +void sub_808B3E4(u8 param_1, u8 param_2, u8 param_3) +{ + u8 uVar1; + if ((param_2 == 0x31 || param_2 == 0x32) && (param_1 == 0x1A)) { + sub_8097FA8(0x1E); + if(param_3 != 0) + { + gDungeon->unk2 = 1; + } + else { + uVar1 = gDungeon->unk1356C; + if(sub_80860A8(0x36) != 0) + { + JirachiWish(); + } + else + { + sub_808B50C(); + } + gDungeon->unk1356C = uVar1; + ShowWholeRevealedDungeonMap(); + } + } +} + +void JirachiPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * jirachiEntity; + + leaderEntity = xxx_call_GetLeader(); + jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); + sub_8086448(); + sub_803E708(0x40,70); + DisplayDungeonDialogue(&gJirachiPreFightDialogue_1); + sub_803E708(10,70); + SpriteLookAroundEffect(leaderEntity); + sub_803E708(10,70); + DisplayDungeonDialogue(&gJirachiPreFightDialogue_2); + sub_80861F8(0x37,jirachiEntity,1); + sub_80855E4(SpriteShockEffect); + sub_803E708(0x3c,70); + JirachiDropInEffect(jirachiEntity); + sub_803E708(0x5a,70); + DisplayDungeonDialogue(&gJirachiPreFightDialogue_3); + sub_803E708(10,70); + DisplayDungeonDialogue(&gJirachiPreFightDialogue_4); + sub_803E708(10,70); + SetupBossFightHP(jirachiEntity,0x15e,MUS_BATTLE_WITH_RAYQUAZA); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +static void sub_808B50C(void) +{ + Entity * jirachiEntity; + + jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); + sub_80855E4(sub_808BBA8); + sub_808BBA8(jirachiEntity); + sub_8041888(0); + GetEntInfo(jirachiEntity)->unk15C = 1; + GetEntInfo(jirachiEntity)->unk15E = 0; + sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH); + DungeonFadeOutBGM(0x1e); + sub_803E708(0x1e,70); + // Fwaaaahhhh + DisplayDungeonDialogue(&gUnknown_810554C); + DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); + // I think I had a dream, and I was fighting in it + // Did I imagine it? + // I'm sleepy so I'm going back to sleep. + DisplayDungeonDialogue(&gUnknown_8105558); + sub_803E708(10,70); + JirachiSpinEffect(jirachiEntity); + DisplayDungeonDialogue(&gUnknown_81055F4); + sub_803E708(10,70); + gDungeon->unk2 = 1; +} + +static const u8 sJirachiItems[] = {ITEM_PROTEIN, ITEM_CALCIUM, ITEM_IRON, ITEM_ZINC, ITEM_JOY_SEED, ITEM_GINSENG, ITEM_LIFE_SEED, ITEM_SITRUS_BERRY}; + +static void JirachiWish(void) +{ + Entity *jirachiEntity; + DungeonPos *LeaderPos; + Entity *leaderEntity; + s32 wishChoice; + + jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); + sub_80855E4(sub_808BBA8); + sub_808BBA8(jirachiEntity); + sub_8041888(0); + GetEntInfo(jirachiEntity)->unk15C = 1; + GetEntInfo(jirachiEntity)->unk15E = 0; + sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH); + sub_80855E4(sub_80861A8); + gDungeon->unk1356C = 1; + DungeonFadeOutBGM(0x1e); + sub_803E708(0x1e,0x46); + DisplayDungeonDialogue(&gUnknown_8105668); + sub_803E708(10,0x46); + PlaySoundEffect(0x1a7); + sub_803E708(0x96,0x46); + SpriteShockEffect(jirachiEntity); + DisplayDungeonDialogue(&gUnknown_8105674); + DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); + sub_803E708(10,0x46); + sub_80856E0(jirachiEntity, DIRECTION_SOUTH); + PlaySoundEffect(0x16a); + DisplayDungeonDialogue(&gUnknown_81056B8); + sub_803E708(10,0x46); + SpriteLookAroundEffect(jirachiEntity); + DisplayDungeonDialogue(&gUnknown_81056DC); + sub_803E708(10,0x46); + while( 1 ) { + while (1) { + wishChoice = DisplayDungeonMenuMessage(NULL,gUnknown_8105798,gUnknown_810579C,0x705); + if (wishChoice >= 1) break; + } + sub_803E708(10,0x46); + if (wishChoice == 1) { + s32 counter, index; + DungeonPos pos; + Item moneyItems [9]; + // Lots of Money + DisplayDungeonDialogue(&gUnknown_810581C); + sub_803E708(10,0x46); + JirachiWishGrantDialogue(jirachiEntity); + + for(counter = 0; counter < 6; counter++) + { + for(index = 0; index < 9; index++) + { + CreateItemWithStickyChance(&moneyItems[index], ITEM_POKE, 0); + } + pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); + pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); + if ((GetTileMut(pos.x, pos.y)->terrainType & 3) != 0) { + PlaySoundEffect(0x14c); + sub_808BB3C(&pos); + sub_8046860(jirachiEntity,&pos,moneyItems,9); + } + } + GetEntInfo(jirachiEntity)->unk15D = 0; + } + if (wishChoice == 2) { + s32 counter, index; + DungeonPos pos; + Item items [9]; + // Lots of Items + DisplayDungeonDialogue(&gUnknown_8105974); + sub_803E708(10,0x46); + JirachiWishGrantDialogue(jirachiEntity); + + for(counter = 0; counter < 6; counter++) + { + for(index = 0; index < 9; index++) + { + CreateItemWithStickyChance(&items[index], GetRandomFloorItem(0),0); + } + pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); + pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); + + if ((GetTileMut(pos.x, pos.y)->terrainType & 3) != 0) { + PlaySoundEffect(400); + sub_808BB3C(&pos); + sub_8046860(jirachiEntity,&pos,items,9); + } + } + GetEntInfo(jirachiEntity)->unk15D = 0; + } + + if (wishChoice == 3) + { + // A Friend Area + s32 friendArea = JirachiFriendAreaSearch(); + if (friendArea == NUM_FRIEND_AREAS) + { + // You want a friend area? But you already have many friend areas... + DisplayDungeonDialogue(&gUnknown_8105A08); + sub_803E708(10,0x46); + continue; + } + else + { + // You want a friend area? As you wish.. + DisplayDungeonDialogue(&gUnknown_8105AD4); + sub_803E708(10,0x46); + JirachiWishGrantDialogue(jirachiEntity); + GetEntInfo(jirachiEntity)->unk15D = 0; + DisplayDungeonDialogue(&gUnknown_8105B20); + UnlockFriendArea(friendArea); + PlaySoundEffect(0xd4); + leaderEntity = GetLeader(); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],leaderEntity,0); + WriteFriendAreaName(gFormatBuffer_Items[0],friendArea,FALSE); + // Obtained the friend area! + DisplayDungeonDialogue(&gUnknown_8105B68); + } + } + if (wishChoice == 4) { + s32 counter, index; + DungeonPos pos; + Item strengthItems [9]; + // More Strength.. + DisplayDungeonDialogue(&gUnknown_8105BA8); + sub_803E708(10,0x46); + JirachiWishGrantDialogue(jirachiEntity); + + for(counter = 0; counter < 5; counter++) + { + + for(index = 0; index < 4; index++) + { + CreateItemWithStickyChance(&strengthItems[index],sJirachiItems[DungeonRandInt(ARRAY_COUNT(sJirachiItems))],0); + } + + pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); + pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); + + if ((GetTileMut(pos.x, pos.y)->terrainType & 3) != 0) { + PlaySoundEffect(400); + sub_808BB3C(&pos); + sub_8046860(jirachiEntity,&pos,strengthItems,4); + } + } + GetEntInfo(jirachiEntity)->unk15D = 0; + DisplayDungeonDialogue(&gUnknown_8105BF4); + sub_803E708(10,0x46); + } + if (wishChoice == 5) { + s32 direction; + // Something Good... + DisplayDungeonDialogue(&gUnknown_8105D2C); + sub_803E708(10,0x46); + JirachiWishGrantDialogue(jirachiEntity); + GetEntInfo(jirachiEntity)->unk15D = 0; + DisplayDungeonDialogue(&gUnknown_8105D80); + sub_803E708(10,0x46); + LeaderPos = &GetLeader()->pos; + direction = GetDirectionTowardsPosition(&jirachiEntity->pos,LeaderPos); + SetFacingDirection(jirachiEntity,direction); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gUnknown_8105D9C); + sub_803E708(10,0x46); + gDungeon->unk644.unk30 = 1; + } + break; + } + + DisplayDungeonDialogue(&gUnknown_81058E0); + JirachiSpinEffect(jirachiEntity); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gUnknown_810593C); + sub_803E708(10,0x46); + EnableJirachiWishWarpTile(); +} + +void JirachiReFightDialogue(void) +{ + if(HasRecruitedMon(MONSTER_JIRACHI)) + { + sub_8086448(); + sub_80866C4(&gJirachiReFightDialogue_1); + } + else + { + JirachiPreFightDialogue(); + } +} + +static void JirachiWishGrantFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x2c1); + gDungeonBrightness = 0x1f; + + for(iVar1 = 0xFA; iVar1 > 0x95; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + + for(iVar1 = 0xFA; iVar1 > 0xC7; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + + for(iVar1 = 0xFA; iVar1 >= 0; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + sub_8085EB0(); +} + +static void sub_808BB3C(DungeonPos *pos1) +{ + s32 x, y; + DungeonPos newPos; + + x = X_POS_TO_PIXELPOS(pos1->x); + newPos.x = x / 256; + + y = Y_POS_TO_PIXELPOS(pos1->y); + newPos.y = y / 256; + + sub_8085EC8(100,0,0,&newPos,0); +} + +static void sub_808BBA8(Entity *jirachiEntity) +{ + ResetMonEntityData(GetEntInfo(jirachiEntity),0); +} + +static void JirachiDropInEffect(Entity *jirachiEntity) +{ + s24_8 iVar1; + s24_8 iVar2; + + sub_80861F8(0x1b,jirachiEntity,0); + sub_8086A54(jirachiEntity); + sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH); + iVar1 = IntToF248(160); + iVar2 = IntToF248(2); + PlaySoundEffect(0x1f8); + while (1) { + iVar1.raw = iVar1.raw - iVar2.raw; // FRAGILE! Subtraction and assignment below must use .raw + if (F248LessThanInt(iVar1, 24)) { + iVar2.raw = IntToF248_2(1).raw; + } + if (F248LessThanInt(iVar1, 0)) break; + GetEntInfo(jirachiEntity)->unk174 = iVar1; + DungeonRunFrameActions(0x46); + } + GetEntInfo(jirachiEntity)->unk174 = IntToF248_2(0); +} + +static void JirachiSpinEffect(Entity * jirachiEntity) +{ + s32 uVar1; + + PlaySoundEffect(0x298); + for(uVar1 = 0; uVar1 < 25; uVar1++){ + SetFacingDirection(jirachiEntity, uVar1 & DIRECTION_MASK); + sub_803E708(3,0x46); + } + GetEntInfo(jirachiEntity)->unk15E = 1; + PlaySoundEffect(0x27f); + sub_80861F8(99,jirachiEntity,1); +} + +static void JirachiWishGrantDialogue(Entity *jirachiEntity) +{ + u32 uVar2; + + GetEntInfo(jirachiEntity)->unk15D = 1; + // Nnnnnnnnnn! + DisplayDungeonDialogue(&gUnknown_81058A8); + PlaySoundEffect(0x375); + sub_80861F8(0x67,jirachiEntity,1); + PlaySoundEffect(0x2a8); + uVar2 = sub_80861F8(0x68,jirachiEntity,0); + // Taaaaaaaah! + DisplayDungeonDialogue(&gUnknown_81058C4); + if (sub_800E9A8(uVar2)) { + sub_800DC14(uVar2); + } + sub_803E708(10,0x46); + JirachiWishGrantFlash(); +} + +// Warp Tile is created but not enabled until the Wish is done with EnableJirachiWishWarpTile +static void CreateJirachiWishWarpTile(void) +{ + Tile *tile; + + tile = GetTileMut(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); + tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); + tile->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL; + tile->terrainType &= ~TERRAIN_TYPE_STAIRS; + sub_8049884(); + sub_8049B8C(); + sub_8049ED4(); + ShowWholeRevealedDungeonMap(); +} + +static void EnableJirachiWishWarpTile(void) +{ + Tile *tile; + + tile = GetTileMut(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); + tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); + tile->terrainType |= TERRAIN_TYPE_NORMAL; + tile->terrainType &= ~TERRAIN_TYPE_IMPASSABLE_WALL; + tile->terrainType |= TERRAIN_TYPE_STAIRS; + tile->unk8 = 1; + sub_8049884(); + sub_8049B8C(); + sub_8049ED4(); + ShowWholeRevealedDungeonMap(); +} + +static u8 JirachiFriendAreaSearch(void) +{ + u8 unlockCondition; + s32 friendAreaCounter; + s32 numUnlockableAreas; + u8 friendAreas[NUM_FRIEND_AREAS]; + u32 friendAreaIndex; + + // Build a copy of friend area list and keep track of + // how many are only Story Unlockable + numUnlockableAreas = 0; + for(friendAreaCounter = 1; friendAreaCounter < NUM_FRIEND_AREAS; friendAreaCounter++){ + unlockCondition = GetFriendAreaUnlockCondition(friendAreaCounter); + if (!(unlockCondition == UNLOCK_LEGENDARY_REQUEST)){ + if (!(unlockCondition == UNLOCK_WONDER_MAIL)){ + if(!gFriendAreas[friendAreaCounter]) { + friendAreas[numUnlockableAreas] = friendAreaCounter; + numUnlockableAreas++; + } + } + } + } + + if (numUnlockableAreas == 0) { + return NUM_FRIEND_AREAS; + } + else { + // Randomly pick 1 + friendAreaIndex = DungeonRandInt(numUnlockableAreas); + return friendAreas[friendAreaIndex]; + } +} + + diff --git a/src/dungeon_cutscene_kyogre.c b/src/dungeon_cutscene_kyogre.c new file mode 100644 index 000000000..13523eb14 --- /dev/null +++ b/src/dungeon_cutscene_kyogre.c @@ -0,0 +1,191 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "code_803E46C.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern s32 gDungeonBrightness; + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void nullsub_99(void); +static void KyogreScreenFlash(void); +static void sub_808C360(void); + +void sub_808C10C(void) +{ + Entity * leaderEntity; + Entity * kyogreEntity; + + u32 XPos; + s32 YPos; + + leaderEntity = xxx_call_GetLeader(); + kyogreEntity = GetEntityFromMonsterBehavior(BEHAVIOR_KYOGRE); + DungeonStopBGM(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + if (HasRecruitedMon(MONSTER_KYOGRE)) { + sub_8068FE0(kyogreEntity,0x21c,0); + } + else { + gDungeon->unk7 = 1; + SetFacingDirection(kyogreEntity, DIRECTION_SOUTH); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); + XPos = GetCameraXPos(); + YPos = GetCameraYPos(); + sub_803F878(XPos,YPos + -0x1000); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_KYOGRE); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_GROUDON); +} + +void sub_808C1A4(u8 param_1,u8 param_2,u8 param_3) +{ + if ((param_2 == 0x34) && (param_1 == 0x1C)) { + gDungeon->unk2 = 1; + DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); + } +} + +void KyogrePreFightDialogue(void) +{ + Entity *leaderEntity; + Entity *KyogreEntity; + + leaderEntity = xxx_call_GetLeader(); + KyogreEntity = GetEntityFromMonsterBehavior(BEHAVIOR_KYOGRE); + DungeonStopBGM(); + if (HasRecruitedMon(MONSTER_KYOGRE)) { + DungeonFadeInNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE,0x3c); + SpriteLookAroundEffect(leaderEntity); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gKyogrePreFightDialogue_8); + sub_803E708(10,0x46); + gDungeon->unk2 = 1; + } + else { + DisplayDungeonDialogue(&gKyogrePreFightDialogue_1); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gKyogrePreFightDialogue_2); + sub_803E708(10,0x46); + nullsub_99(); + sub_803E708(10,0x46); + // Gwwwwwooooooooh + DisplayDungeonDialogue(&gKyogrePreFightDialogue_3); + sub_803E708(10,0x46); + DungeonFadeInNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE,0x3c); + sub_808C360(); + // My duels against {POKEMON_3} (Groudon) left us both exhausted + DisplayDungeonDialogue(&gKyogrePreFightDialogue_4); + KyogreScreenFlash(); + // I am {POKEMON_2} (Kyogre)! + // The lord of the sea! + DisplayDungeonDialogue(&gKyogrePreFightDialogue_5); + KyogreScreenFlash(); + // Witness the destructive force of my waves! + DisplayDungeonDialogue(&gKyogrePreFightDialogue_6); + KyogreScreenFlash(); + // Marvel at my awesome + // power! + DisplayDungeonDialogue(&gKyogrePreFightDialogue_7); + sub_803E708(10,0x46); + SetupBossFightHP(KyogreEntity,600,MUS_BOSS_BATTLE); + DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void nullsub_99(void) +{ +} + +static void KyogreScreenFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x1f8); + for(iVar1 = 250; iVar1 > 149; iVar1 -= 10){ + SetDungeonBGColorRGB(0,0,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10){ + SetDungeonBGColorRGB(0,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10){ + SetDungeonBGColorRGB(0,0,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + sub_8085EB0(); +} + +static void sub_808C360(void) +{ + gDungeonBrightness = 0x1f; + SetDungeonBGColorRGB(0,0,0,1,1); + BgColorCallNullsub4(); + DungeonRunFrameActions(0x46); + gDungeon->unk7 = 0; + KyogreScreenFlash(); +} diff --git a/src/dungeon_cutscene_lugia.c b/src/dungeon_cutscene_lugia.c new file mode 100644 index 000000000..c92a26c73 --- /dev/null +++ b/src/dungeon_cutscene_lugia.c @@ -0,0 +1,207 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "code_803E46C.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern s32 gDungeonBrightness; + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void LugiaScreenFlash(void); +static void LugiaScreenFlash2(void); +static void sub_808C0CC(void); + +void sub_808BDEC(void) +{ + Entity * leaderEntity; + Entity * lugiaEntity; + + leaderEntity = xxx_call_GetLeader(); + lugiaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LUGIA); + DungeonStopBGM(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + if (HasRecruitedMon(MONSTER_LUGIA)) { + DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); + sub_8068FE0(lugiaEntity,0x21c,0); + } + else { + gDungeon->unk7 = 1; + SetFacingDirection(lugiaEntity, DIRECTION_SOUTH); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_LUGIA); +} + +void sub_808BE70(u8 param_1,u8 param_2,u8 param_3) +{ + if ((param_2 == 0x33) && (param_1 == 0x1B)) { + gDungeon->unk2 = 1; + } +} + +void LugiaPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * lugiaEntity; + + leaderEntity = xxx_call_GetLeader(); + lugiaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LUGIA); + if (HasRecruitedMon(MONSTER_LUGIA)) { + sub_8086448(); + sub_80866C4(&gLugiaPreFightDialogue_8); + } + else { + DungeonStopBGM(); + sub_8086448(); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_1); + DungeonFadeInNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE,0x3c); + sub_808C0CC(); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_2); + LugiaScreenFlash(); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_3); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_4); + PlaySoundEffect(0x1f8); + sub_80861D4(lugiaEntity,0xd,DIRECTION_SOUTH); + sub_803E708(0x2b,0x46); + sub_80861B8(lugiaEntity,0,DIRECTION_SOUTH); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_5); + LugiaScreenFlash(); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_6); + LugiaScreenFlash2(); + SetDungeonBGColorRGB(-250,-250,-250,1,0); + DungeonStopBGM(); + sub_80861D4(lugiaEntity,7,DIRECTION_SOUTH); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_7); + LugiaScreenFlash(); + SetupBossFightHP(lugiaEntity,800,MUS_BATTLE_WITH_RAYQUAZA); + DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void LugiaScreenFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x1f6); + for(iVar1 = 250; iVar1 > 149; iVar1 -= 10){ + SetDungeonBGColorRGB(0,0,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10){ + SetDungeonBGColorRGB(0,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10){ + SetDungeonBGColorRGB(0,0,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + sub_8085EB0(); +} + +static void LugiaScreenFlash2(void) +{ + s32 iVar1; + + PlaySoundEffect(0x1f6); + + for(iVar1 = 0; iVar1 < 200; iVar1 += 100){ + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); + DungeonRunFrameActions(0x46); + } + + for(iVar1 = 200; iVar1 >= 0; iVar1 -= 100){ + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); + DungeonRunFrameActions(0x46); + } + + sub_803E708(4,0x46); + + for(iVar1 = 0; iVar1 < 200; iVar1 += 100){ + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); + DungeonRunFrameActions(0x46); + } + + for(iVar1 = 200; iVar1 >= 0; iVar1 -= 100){ + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); + DungeonRunFrameActions(0x46); + } + + sub_803E708(10,0x46); + sub_8085EB0(); +} + +static void sub_808C0CC(void) +{ + gDungeonBrightness = 0x1f; + SetDungeonBGColorRGB(0,0,0,1,1); + BgColorCallNullsub4(); + DungeonRunFrameActions(0x46); + gDungeon->unk7 = 0; + LugiaScreenFlash(); +} + diff --git a/src/dungeon_cutscene_meanies.c b/src/dungeon_cutscene_meanies.c index 9cd71e15a..e9b2a9a65 100644 --- a/src/dungeon_cutscene_meanies.c +++ b/src/dungeon_cutscene_meanies.c @@ -47,7 +47,6 @@ extern void sub_8049B8C(void); extern void ShowWholeRevealedDungeonMap(void); extern void sub_8086A54(Entity *); extern void ResetMonEntityData(EntityInfo *, u32); -extern void sub_808BBA8(Entity * ); extern void sub_8041888(u32); extern u32 sub_80861F8(u32, Entity *, u32); extern u8 sub_80860A8(u32); diff --git a/src/dungeon_cutscene_medicham.c b/src/dungeon_cutscene_medicham.c new file mode 100644 index 000000000..d3e1067f1 --- /dev/null +++ b/src/dungeon_cutscene_medicham.c @@ -0,0 +1,148 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "code_803E46C.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +void sub_808C9C4(void) +{ + Entity *leaderEntity; + Entity *medichamEntity; + + leaderEntity = xxx_call_GetLeader(); + medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + SetFacingDirection(medichamEntity, DIRECTION_SOUTH); + sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_MEDICHAM); +} + +void MedichamRescueDialogue(void) +{ + Entity *medichamEntity; + s32 counter; + + medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); + SpriteLookAroundEffect(medichamEntity); + sub_803E708(0xA, 0x46); + // Oh my I can't seem to find a way out... + DisplayDungeonDialogue(&gMedichamRescueDialogue_1); + sub_803E708(0xA, 0x46); + sub_80869E4(medichamEntity, 4, 2, DIRECTION_NORTH); + sub_803E708(0xA, 0x46); + // What am I to do...? + DisplayDungeonDialogue(&gMedichamRescueDialogue_2); + sub_803E708(0xA, 0x46); + sub_8086448(); + sub_8086598(); + sub_803E708(0x20, 0x46); + SpriteShockEffect(medichamEntity); + sub_803E708(0x20, 0x46); + sub_80869E4(medichamEntity, 4, 2, DIRECTION_SOUTH); + DisplayDungeonDialogue(&gMedichamRescueDialogue_3); + sub_803E708(0xA, 0x46); + PlaySoundEffect(0x1c7); + sub_806CDD4(medichamEntity, 0xA, DIRECTION_SOUTH); + sub_803E708(0x14, 0x46); + sub_806CE68(medichamEntity, DIRECTION_SOUTH); + sub_803E708(0x4, 0x46); + PlaySoundEffect(0x1c7); + sub_806CDD4(medichamEntity, 0xA, DIRECTION_SOUTH); + sub_803E708(0x14, 0x46); + // Yes Yes + // I am so lucky + // + // There appears to be no one here + DisplayDungeonDialogue(&gMedichamRescueDialogue_4); + sub_803E708(0xA, 0x46); + sub_806CDD4(medichamEntity, 0, DIRECTION_SOUTH); + for(counter = 0x17; counter >= 0; counter--) + { + IncreaseEntityPixelPos(medichamEntity, 0, 0x100); + DungeonRunFrameActions(0x46); + } + sub_806CE68(medichamEntity, DIRECTION_SOUTH); + sub_803E708(0x20, 0x46); + sub_8042B0C(medichamEntity); + sub_8068FE0(medichamEntity, 0x21C, 0); + gDungeon->unk4 = 1; + gDungeon->unk11 = 4; +} + +void sub_808CB5C(void) +{ + Entity *leaderEntity; + Entity *medichamEntity; + + leaderEntity = xxx_call_GetLeader(); + medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_8068FE0(medichamEntity, 0x21C, 0); + sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_MEDICHAM); +} + diff --git a/src/dungeon_cutscene_moltres.c b/src/dungeon_cutscene_moltres.c index cc7ba121c..0a97051b2 100644 --- a/src/dungeon_cutscene_moltres.c +++ b/src/dungeon_cutscene_moltres.c @@ -47,7 +47,6 @@ extern void sub_8049B8C(void); extern void ShowWholeRevealedDungeonMap(void); extern void sub_8086A54(Entity *); extern void ResetMonEntityData(EntityInfo *, u32); -extern void sub_808BBA8(Entity * ); extern void sub_8041888(u32); extern u32 sub_80861F8(u32, Entity *, u32); extern u8 sub_80860A8(u32); diff --git a/src/dungeon_cutscene_no_one_here.c b/src/dungeon_cutscene_no_one_here.c new file mode 100644 index 000000000..693c6cd95 --- /dev/null +++ b/src/dungeon_cutscene_no_one_here.c @@ -0,0 +1,13 @@ +#include "global.h" +#include "globaldata.h" +#include "code_80869E4.h" +#include "dungeon_boss_dialogue.h" + +void sub_808CD9C(void) +{ + sub_8086448(); + // There appears to be no one here. + // It's impossible to go any further + sub_80866C4(&gUnknown_810697C); +} + diff --git a/src/dungeon_cutscene_placeholder.c b/src/dungeon_cutscene_placeholder.c index 7e38f30f0..4a6719c28 100644 --- a/src/dungeon_cutscene_placeholder.c +++ b/src/dungeon_cutscene_placeholder.c @@ -47,7 +47,6 @@ extern void sub_8049B8C(void); extern void ShowWholeRevealedDungeonMap(void); extern void sub_8086A54(Entity *); extern void ResetMonEntityData(EntityInfo *, u32); -extern void sub_808BBA8(Entity * ); extern void sub_8041888(u32); extern u32 sub_80861F8(u32, Entity *, u32); extern u8 sub_80860A8(u32); diff --git a/src/dungeon_cutscene_skarmory.c b/src/dungeon_cutscene_skarmory.c index 402ffa3c6..8dd071b92 100644 --- a/src/dungeon_cutscene_skarmory.c +++ b/src/dungeon_cutscene_skarmory.c @@ -47,7 +47,6 @@ extern void sub_8049B8C(void); extern void ShowWholeRevealedDungeonMap(void); extern void sub_8086A54(Entity *); extern void ResetMonEntityData(EntityInfo *, u32); -extern void sub_808BBA8(Entity * ); extern void sub_8041888(u32); extern u32 sub_80861F8(u32, Entity *, u32); extern u8 sub_80860A8(u32); diff --git a/src/dungeon_cutscene_smeargle.c b/src/dungeon_cutscene_smeargle.c new file mode 100644 index 000000000..014ec5a25 --- /dev/null +++ b/src/dungeon_cutscene_smeargle.c @@ -0,0 +1,154 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "code_803E46C.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +void DummyFightDialogue(void) +{ +} + +void sub_808CBB0(void) +{ + Entity *leaderEntity; + Entity *smeargleEntity; + + leaderEntity = xxx_call_GetLeader(); + smeargleEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SMEARGLE); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + SetFacingDirection(smeargleEntity, DIRECTION_SOUTH); + sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SMEARGLE); +} + +void SmeargleRescueDialogue(void) +{ + Entity *smeargleEntity; + s32 counter; + + smeargleEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SMEARGLE); + SpriteLookAroundEffect(smeargleEntity); + sub_803E708(0xA, 0x46); + // Ohhh... + // I've lost my bearings + DisplayDungeonDialogue(&gSmeargleRescueDialogue_1); + sub_803E708(0xA, 0x46); + sub_80869E4(smeargleEntity, 4, 2, DIRECTION_NORTH); + sub_803E708(0xA, 0x46); + // I can't get out... + // I'm hungry... + // I'm in trouble + DisplayDungeonDialogue(&gSmeargleRescueDialogue_2); + sub_803E708(0xA, 0x46); + sub_8086448(); + sub_8086598(); + sub_803E708(0x20, 0x46); + SpriteShockEffect(smeargleEntity); + sub_803E708(0x20, 0x46); + sub_80869E4(smeargleEntity, 4, 2, DIRECTION_SOUTH); + // Oh! You are? + DisplayDungeonDialogue(&gSmeargleRescueDialogue_3); + sub_803E708(0xA, 0x46); + PlaySoundEffect(0x1c7); + sub_806CDD4(smeargleEntity, 0xA, DIRECTION_SOUTH); + sub_803E708(0x14, 0x46); + sub_806CE68(smeargleEntity, DIRECTION_SOUTH); + sub_803E708(0x4, 0x46); + PlaySoundEffect(0x1c7); + sub_806CDD4(smeargleEntity, 0xA, DIRECTION_SOUTH); + sub_803E708(0x14, 0x46); + // Did you maybe come to rescue me? + // Am I glad to see you + DisplayDungeonDialogue(&gSmeargleRescueDialogue_4); + sub_803E708(0xA, 0x46); + sub_806CDD4(smeargleEntity, 0, DIRECTION_SOUTH); + for(counter = 0x17; counter >= 0; counter--) + { + IncreaseEntityPixelPos(smeargleEntity, 0, 0x100); + DungeonRunFrameActions(0x46); + } + sub_806CE68(smeargleEntity, DIRECTION_SOUTH); + sub_803E708(0x20, 0x46); + sub_8042B0C(smeargleEntity); + sub_8068FE0(smeargleEntity, 0x21C, 0); + gDungeon->unk4 = 1; + gDungeon->unk11 = 4; +} + +void sub_808CD44(void) +{ + Entity *leaderEntity; + Entity *smeargleEntity; + + leaderEntity = xxx_call_GetLeader(); + smeargleEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SMEARGLE); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + sub_8068FE0(smeargleEntity, 540, 0); + sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SMEARGLE); +} diff --git a/src/dungeon_cutscene_zapdos.c b/src/dungeon_cutscene_zapdos.c index 3c047184d..3b0ea56ea 100644 --- a/src/dungeon_cutscene_zapdos.c +++ b/src/dungeon_cutscene_zapdos.c @@ -47,7 +47,6 @@ extern void sub_8049B8C(void); extern void ShowWholeRevealedDungeonMap(void); extern void sub_8086A54(Entity *); extern void ResetMonEntityData(EntityInfo *, u32); -extern void sub_808BBA8(Entity * ); extern void sub_8041888(u32); extern u32 sub_80861F8(u32, Entity *, u32); extern u8 sub_80860A8(u32); diff --git a/src/dungeon_cutscenes.c b/src/dungeon_cutscenes.c index c5e5d383d..c036b779e 100644 --- a/src/dungeon_cutscenes.c +++ b/src/dungeon_cutscenes.c @@ -38,7 +38,7 @@ extern u32 gDungeonBrightness; extern const struct MenuItem gUnknown_810579C[]; extern const u64 gUnknown_8107544[]; extern const u8 *const gUnknown_8105798; -extern const u8 gUnknown_81074FC[]; + @@ -55,7 +55,6 @@ extern void sub_8049B8C(void); extern void ShowWholeRevealedDungeonMap(void); extern void sub_8086A54(Entity *); extern void ResetMonEntityData(EntityInfo *, u32); -extern void sub_808BBA8(Entity * ); extern void sub_8041888(u32); extern u32 sub_80861F8(u32, Entity *, u32); extern u8 sub_80860A8(u32); @@ -2272,1238 +2271,10 @@ void SetupRegisteelFightHP(Entity *r0) SetupBossFightHP(r0, 450, MUS_BOSS_BATTLE); } -void sub_808B2F4(void) -{ - Entity * leaderEntity; - Entity * jirachiEntity; - leaderEntity = xxx_call_GetLeader(); - jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); - DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); - CreateJirachiWishWarpTile(); - sub_8049ED4(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - SetFacingDirection(jirachiEntity, DIRECTION_SOUTH); - sub_8086A3C(jirachiEntity); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); -} -void sub_808B35C(void) -{ - Entity * leaderEntity; - Entity * jirachiEntity; - leaderEntity = xxx_call_GetLeader(); - jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); - DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - if (HasRecruitedMon(MONSTER_JIRACHI)) { - sub_8068FE0(jirachiEntity,0x21c,0); - } - else { - SetFacingDirection(jirachiEntity, DIRECTION_SOUTH); - sub_8086A3C(jirachiEntity); - CreateJirachiWishWarpTile(); - sub_8049ED4(); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); -} -void sub_808B3E4(u8 param_1, u8 param_2, u8 param_3) -{ - u8 uVar1; - if ((param_2 == 0x31 || param_2 == 0x32) && (param_1 == 0x1A)) { - sub_8097FA8(0x1E); - if(param_3 != 0) - { - gDungeon->unk2 = 1; - } - else { - uVar1 = gDungeon->unk1356C; - if(sub_80860A8(0x36) != 0) - { - JirachiWish(); - } - else - { - sub_808B50C(); - } - gDungeon->unk1356C = uVar1; - ShowWholeRevealedDungeonMap(); - } - } -} - -void JirachiPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * jirachiEntity; - - leaderEntity = xxx_call_GetLeader(); - jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); - sub_8086448(); - sub_803E708(0x40,70); - DisplayDungeonDialogue(&gJirachiPreFightDialogue_1); - sub_803E708(10,70); - SpriteLookAroundEffect(leaderEntity); - sub_803E708(10,70); - DisplayDungeonDialogue(&gJirachiPreFightDialogue_2); - sub_80861F8(0x37,jirachiEntity,1); - sub_80855E4(SpriteShockEffect); - sub_803E708(0x3c,70); - JirachiDropInEffect(jirachiEntity); - sub_803E708(0x5a,70); - DisplayDungeonDialogue(&gJirachiPreFightDialogue_3); - sub_803E708(10,70); - DisplayDungeonDialogue(&gJirachiPreFightDialogue_4); - sub_803E708(10,70); - SetupBossFightHP(jirachiEntity,0x15e,MUS_BATTLE_WITH_RAYQUAZA); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void sub_808B50C(void) -{ - Entity * jirachiEntity; - - jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); - sub_80855E4(sub_808BBA8); - sub_808BBA8(jirachiEntity); - sub_8041888(0); - GetEntInfo(jirachiEntity)->unk15C = 1; - GetEntInfo(jirachiEntity)->unk15E = 0; - sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH); - DungeonFadeOutBGM(0x1e); - sub_803E708(0x1e,70); - // Fwaaaahhhh - DisplayDungeonDialogue(&gUnknown_810554C); - DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); - // I think I had a dream, and I was fighting in it - // Did I imagine it? - // I'm sleepy so I'm going back to sleep. - DisplayDungeonDialogue(&gUnknown_8105558); - sub_803E708(10,70); - JirachiSpinEffect(jirachiEntity); - DisplayDungeonDialogue(&gUnknown_81055F4); - sub_803E708(10,70); - gDungeon->unk2 = 1; -} - -void JirachiWish(void) -{ - Entity *jirachiEntity; - DungeonPos *LeaderPos; - Entity *leaderEntity; - s32 wishChoice; - - jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); - sub_80855E4(sub_808BBA8); - sub_808BBA8(jirachiEntity); - sub_8041888(0); - GetEntInfo(jirachiEntity)->unk15C = 1; - GetEntInfo(jirachiEntity)->unk15E = 0; - sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH); - sub_80855E4(sub_80861A8); - gDungeon->unk1356C = 1; - DungeonFadeOutBGM(0x1e); - sub_803E708(0x1e,0x46); - DisplayDungeonDialogue(&gUnknown_8105668); - sub_803E708(10,0x46); - PlaySoundEffect(0x1a7); - sub_803E708(0x96,0x46); - SpriteShockEffect(jirachiEntity); - DisplayDungeonDialogue(&gUnknown_8105674); - DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); - sub_803E708(10,0x46); - sub_80856E0(jirachiEntity, DIRECTION_SOUTH); - PlaySoundEffect(0x16a); - DisplayDungeonDialogue(&gUnknown_81056B8); - sub_803E708(10,0x46); - SpriteLookAroundEffect(jirachiEntity); - DisplayDungeonDialogue(&gUnknown_81056DC); - sub_803E708(10,0x46); - while( 1 ) { - while (1) { - wishChoice = DisplayDungeonMenuMessage(NULL,gUnknown_8105798,gUnknown_810579C,0x705); - if (wishChoice >= 1) break; - } - sub_803E708(10,0x46); - if (wishChoice == 1) { - s32 counter, index; - DungeonPos pos; - Item moneyItems [9]; - // Lots of Money - DisplayDungeonDialogue(&gUnknown_810581C); - sub_803E708(10,0x46); - JirachiWishGrantDialogue(jirachiEntity); - - for(counter = 0; counter < 6; counter++) - { - for(index = 0; index < 9; index++) - { - CreateItemWithStickyChance(&moneyItems[index], ITEM_POKE, 0); - } - pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); - pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); - if ((GetTileMut(pos.x, pos.y)->terrainType & 3) != 0) { - PlaySoundEffect(0x14c); - sub_808BB3C(&pos); - sub_8046860(jirachiEntity,&pos,moneyItems,9); - } - } - GetEntInfo(jirachiEntity)->unk15D = 0; - } - if (wishChoice == 2) { - s32 counter, index; - DungeonPos pos; - Item items [9]; - // Lots of Items - DisplayDungeonDialogue(&gUnknown_8105974); - sub_803E708(10,0x46); - JirachiWishGrantDialogue(jirachiEntity); - - for(counter = 0; counter < 6; counter++) - { - for(index = 0; index < 9; index++) - { - CreateItemWithStickyChance(&items[index], GetRandomFloorItem(0),0); - } - pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); - pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); - - if ((GetTileMut(pos.x, pos.y)->terrainType & 3) != 0) { - PlaySoundEffect(400); - sub_808BB3C(&pos); - sub_8046860(jirachiEntity,&pos,items,9); - } - } - GetEntInfo(jirachiEntity)->unk15D = 0; - } - - if (wishChoice == 3) - { - // A Friend Area - s32 friendArea = JirachiFriendAreaSearch(); - if (friendArea == NUM_FRIEND_AREAS) - { - // You want a friend area? But you already have many friend areas... - DisplayDungeonDialogue(&gUnknown_8105A08); - sub_803E708(10,0x46); - continue; - } - else - { - // You want a friend area? As you wish.. - DisplayDungeonDialogue(&gUnknown_8105AD4); - sub_803E708(10,0x46); - JirachiWishGrantDialogue(jirachiEntity); - GetEntInfo(jirachiEntity)->unk15D = 0; - DisplayDungeonDialogue(&gUnknown_8105B20); - UnlockFriendArea(friendArea); - PlaySoundEffect(0xd4); - leaderEntity = GetLeader(); - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],leaderEntity,0); - WriteFriendAreaName(gFormatBuffer_Items[0],friendArea,FALSE); - // Obtained the friend area! - DisplayDungeonDialogue(&gUnknown_8105B68); - } - } - if (wishChoice == 4) { - s32 counter, index; - DungeonPos pos; - Item strengthItems [9]; - // More Strength.. - DisplayDungeonDialogue(&gUnknown_8105BA8); - sub_803E708(10,0x46); - JirachiWishGrantDialogue(jirachiEntity); - - for(counter = 0; counter < 5; counter++) - { - - for(index = 0; index < 4; index++) - { - CreateItemWithStickyChance(&strengthItems[index],gUnknown_81074FC[DungeonRandInt(8)],0); - } - - pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); - pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); - - if ((GetTileMut(pos.x, pos.y)->terrainType & 3) != 0) { - PlaySoundEffect(400); - sub_808BB3C(&pos); - sub_8046860(jirachiEntity,&pos,strengthItems,4); - } - } - GetEntInfo(jirachiEntity)->unk15D = 0; - DisplayDungeonDialogue(&gUnknown_8105BF4); - sub_803E708(10,0x46); - } - if (wishChoice == 5) { - s32 direction; - // Something Good... - DisplayDungeonDialogue(&gUnknown_8105D2C); - sub_803E708(10,0x46); - JirachiWishGrantDialogue(jirachiEntity); - GetEntInfo(jirachiEntity)->unk15D = 0; - DisplayDungeonDialogue(&gUnknown_8105D80); - sub_803E708(10,0x46); - LeaderPos = &GetLeader()->pos; - direction = GetDirectionTowardsPosition(&jirachiEntity->pos,LeaderPos); - SetFacingDirection(jirachiEntity,direction); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gUnknown_8105D9C); - sub_803E708(10,0x46); - gDungeon->unk644.unk30 = 1; - } - break; - } - - DisplayDungeonDialogue(&gUnknown_81058E0); - JirachiSpinEffect(jirachiEntity); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gUnknown_810593C); - sub_803E708(10,0x46); - EnableJirachiWishWarpTile(); -} - -void JirachiReFightDialogue(void) -{ - if(HasRecruitedMon(MONSTER_JIRACHI)) - { - sub_8086448(); - sub_80866C4(&gJirachiReFightDialogue_1); - } - else - { - JirachiPreFightDialogue(); - } -} - -void JirachiWishGrantFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x2c1); - gDungeonBrightness = 0x1f; - - for(iVar1 = 0xFA; iVar1 > 0x95; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - - for(iVar1 = 0xFA; iVar1 > 0xC7; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - - for(iVar1 = 0xFA; iVar1 >= 0; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - sub_8085EB0(); -} - -void sub_808BB3C(DungeonPos *pos1) -{ - s32 x, y; - DungeonPos newPos; - - x = X_POS_TO_PIXELPOS(pos1->x); - newPos.x = x / 256; - - y = Y_POS_TO_PIXELPOS(pos1->y); - newPos.y = y / 256; - - sub_8085EC8(100,0,0,&newPos,0); -} - -void sub_808BBA8(Entity *jirachiEntity) -{ - ResetMonEntityData(GetEntInfo(jirachiEntity),0); -} - -void JirachiDropInEffect(Entity *jirachiEntity) -{ - s24_8 iVar1; - s24_8 iVar2; - - sub_80861F8(0x1b,jirachiEntity,0); - sub_8086A54(jirachiEntity); - sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH); - iVar1 = IntToF248(160); - iVar2 = IntToF248(2); - PlaySoundEffect(0x1f8); - while (1) { - iVar1.raw = iVar1.raw - iVar2.raw; // FRAGILE! Subtraction and assignment below must use .raw - if (F248LessThanInt(iVar1, 24)) { - iVar2.raw = IntToF248_2(1).raw; - } - if (F248LessThanInt(iVar1, 0)) break; - GetEntInfo(jirachiEntity)->unk174 = iVar1; - DungeonRunFrameActions(0x46); - } - GetEntInfo(jirachiEntity)->unk174 = IntToF248_2(0); -} - -void JirachiSpinEffect(Entity * jirachiEntity) -{ - s32 uVar1; - - PlaySoundEffect(0x298); - for(uVar1 = 0; uVar1 < 25; uVar1++){ - SetFacingDirection(jirachiEntity, uVar1 & DIRECTION_MASK); - sub_803E708(3,0x46); - } - GetEntInfo(jirachiEntity)->unk15E = 1; - PlaySoundEffect(0x27f); - sub_80861F8(99,jirachiEntity,1); -} - -void JirachiWishGrantDialogue(Entity *jirachiEntity) -{ - u32 uVar2; - - GetEntInfo(jirachiEntity)->unk15D = 1; - // Nnnnnnnnnn! - DisplayDungeonDialogue(&gUnknown_81058A8); - PlaySoundEffect(0x375); - sub_80861F8(0x67,jirachiEntity,1); - PlaySoundEffect(0x2a8); - uVar2 = sub_80861F8(0x68,jirachiEntity,0); - // Taaaaaaaah! - DisplayDungeonDialogue(&gUnknown_81058C4); - if (sub_800E9A8(uVar2)) { - sub_800DC14(uVar2); - } - sub_803E708(10,0x46); - JirachiWishGrantFlash(); -} - -// Warp Tile is created but not enabled until the Wish is done with EnableJirachiWishWarpTile -void CreateJirachiWishWarpTile(void) -{ - Tile *tile; - - tile = GetTileMut(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); - tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); - tile->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL; - tile->terrainType &= ~TERRAIN_TYPE_STAIRS; - sub_8049884(); - sub_8049B8C(); - sub_8049ED4(); - ShowWholeRevealedDungeonMap(); -} - -void EnableJirachiWishWarpTile(void) -{ - Tile *tile; - - tile = GetTileMut(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); - tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); - tile->terrainType |= TERRAIN_TYPE_NORMAL; - tile->terrainType &= ~TERRAIN_TYPE_IMPASSABLE_WALL; - tile->terrainType |= TERRAIN_TYPE_STAIRS; - tile->unk8 = 1; - sub_8049884(); - sub_8049B8C(); - sub_8049ED4(); - ShowWholeRevealedDungeonMap(); -} - -u8 JirachiFriendAreaSearch(void) -{ - u8 unlockCondition; - s32 friendAreaCounter; - s32 numUnlockableAreas; - u8 friendAreas[NUM_FRIEND_AREAS]; - u32 friendAreaIndex; - - // Build a copy of friend area list and keep track of - // how many are only Story Unlockable - numUnlockableAreas = 0; - for(friendAreaCounter = 1; friendAreaCounter < NUM_FRIEND_AREAS; friendAreaCounter++){ - unlockCondition = GetFriendAreaUnlockCondition(friendAreaCounter); - if (!(unlockCondition == UNLOCK_LEGENDARY_REQUEST)){ - if (!(unlockCondition == UNLOCK_WONDER_MAIL)){ - if(!gFriendAreas[friendAreaCounter]) { - friendAreas[numUnlockableAreas] = friendAreaCounter; - numUnlockableAreas++; - } - } - } - } - - if (numUnlockableAreas == 0) { - return NUM_FRIEND_AREAS; - } - else { - // Randomly pick 1 - friendAreaIndex = DungeonRandInt(numUnlockableAreas); - return friendAreas[friendAreaIndex]; - } -} - -void sub_808BDEC(void) -{ - Entity * leaderEntity; - Entity * lugiaEntity; - - leaderEntity = xxx_call_GetLeader(); - lugiaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LUGIA); - DungeonStopBGM(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - if (HasRecruitedMon(MONSTER_LUGIA)) { - DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); - sub_8068FE0(lugiaEntity,0x21c,0); - } - else { - gDungeon->unk7 = 1; - SetFacingDirection(lugiaEntity, DIRECTION_SOUTH); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_LUGIA); -} - -void sub_808BE70(u8 param_1,u8 param_2,u8 param_3) -{ - if ((param_2 == 0x33) && (param_1 == 0x1B)) { - gDungeon->unk2 = 1; - } -} - - -void LugiaPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * lugiaEntity; - - leaderEntity = xxx_call_GetLeader(); - lugiaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LUGIA); - if (HasRecruitedMon(MONSTER_LUGIA)) { - sub_8086448(); - sub_80866C4(&gLugiaPreFightDialogue_8); - } - else { - DungeonStopBGM(); - sub_8086448(); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_1); - DungeonFadeInNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE,0x3c); - sub_808C0CC(); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_2); - LugiaScreenFlash(); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_3); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_4); - PlaySoundEffect(0x1f8); - sub_80861D4(lugiaEntity,0xd,DIRECTION_SOUTH); - sub_803E708(0x2b,0x46); - sub_80861B8(lugiaEntity,0,DIRECTION_SOUTH); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_5); - LugiaScreenFlash(); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_6); - LugiaScreenFlash2(); - SetDungeonBGColorRGB(0xffffff06,0xffffff06,0xffffff06,1,0); - DungeonStopBGM(); - sub_80861D4(lugiaEntity,7,DIRECTION_SOUTH); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_7); - LugiaScreenFlash(); - SetupBossFightHP(lugiaEntity,800,MUS_BATTLE_WITH_RAYQUAZA); - DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void LugiaScreenFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x1f6); - for(iVar1 = 250; iVar1 > 149; iVar1 -= 10){ - SetDungeonBGColorRGB(0,0,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10){ - SetDungeonBGColorRGB(0,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10){ - SetDungeonBGColorRGB(0,0,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - sub_8085EB0(); -} - -void LugiaScreenFlash2(void) -{ - s32 iVar1; - - PlaySoundEffect(0x1f6); - - for(iVar1 = 0; iVar1 < 200; iVar1 += 100){ - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); - DungeonRunFrameActions(0x46); - } - - for(iVar1 = 200; iVar1 >= 0; iVar1 -= 100){ - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); - DungeonRunFrameActions(0x46); - } - - sub_803E708(4,0x46); - - for(iVar1 = 0; iVar1 < 200; iVar1 += 100){ - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); - DungeonRunFrameActions(0x46); - } - - for(iVar1 = 200; iVar1 >= 0; iVar1 -= 100){ - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); - DungeonRunFrameActions(0x46); - } - - sub_803E708(10,0x46); - sub_8085EB0(); -} - -void sub_808C0CC(void) -{ - gDungeonBrightness = 0x1f; - SetDungeonBGColorRGB(0,0,0,1,1); - BgColorCallNullsub4(); - DungeonRunFrameActions(0x46); - gDungeon->unk7 = 0; - LugiaScreenFlash(); -} - -void sub_808C10C(void) -{ - Entity * leaderEntity; - Entity * kyogreEntity; - - u32 XPos; - s32 YPos; - - leaderEntity = xxx_call_GetLeader(); - kyogreEntity = GetEntityFromMonsterBehavior(BEHAVIOR_KYOGRE); - DungeonStopBGM(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - if (HasRecruitedMon(MONSTER_KYOGRE)) { - sub_8068FE0(kyogreEntity,0x21c,0); - } - else { - gDungeon->unk7 = 1; - SetFacingDirection(kyogreEntity, DIRECTION_SOUTH); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); - XPos = GetCameraXPos(); - YPos = GetCameraYPos(); - sub_803F878(XPos,YPos + -0x1000); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_KYOGRE); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_GROUDON); -} - -void sub_808C1A4(u8 param_1,u8 param_2,u8 param_3) -{ - if ((param_2 == 0x34) && (param_1 == 0x1C)) { - gDungeon->unk2 = 1; - DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); - } -} - -void KyogrePreFightDialogue(void) -{ - Entity *leaderEntity; - Entity *KyogreEntity; - - leaderEntity = xxx_call_GetLeader(); - KyogreEntity = GetEntityFromMonsterBehavior(BEHAVIOR_KYOGRE); - DungeonStopBGM(); - if (HasRecruitedMon(MONSTER_KYOGRE)) { - DungeonFadeInNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE,0x3c); - SpriteLookAroundEffect(leaderEntity); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gKyogrePreFightDialogue_8); - sub_803E708(10,0x46); - gDungeon->unk2 = 1; - } - else { - DisplayDungeonDialogue(&gKyogrePreFightDialogue_1); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gKyogrePreFightDialogue_2); - sub_803E708(10,0x46); - nullsub_99(); - sub_803E708(10,0x46); - // Gwwwwwooooooooh - DisplayDungeonDialogue(&gKyogrePreFightDialogue_3); - sub_803E708(10,0x46); - DungeonFadeInNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE,0x3c); - sub_808C360(); - // My duels against {POKEMON_3} (Groudon) left us both exhausted - DisplayDungeonDialogue(&gKyogrePreFightDialogue_4); - KyogreScreenFlash(); - // I am {POKEMON_2} (Kyogre)! - // The lord of the sea! - DisplayDungeonDialogue(&gKyogrePreFightDialogue_5); - KyogreScreenFlash(); - // Witness the destructive force of my waves! - DisplayDungeonDialogue(&gKyogrePreFightDialogue_6); - KyogreScreenFlash(); - // Marvel at my awesome - // power! - DisplayDungeonDialogue(&gKyogrePreFightDialogue_7); - sub_803E708(10,0x46); - SetupBossFightHP(KyogreEntity,600,MUS_BOSS_BATTLE); - DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void nullsub_99(void) -{ -} - -void KyogreScreenFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x1f8); - for(iVar1 = 250; iVar1 > 149; iVar1 -= 10){ - SetDungeonBGColorRGB(0,0,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10){ - SetDungeonBGColorRGB(0,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10){ - SetDungeonBGColorRGB(0,0,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - sub_8085EB0(); -} - -void sub_808C360(void) -{ - gDungeonBrightness = 0x1f; - SetDungeonBGColorRGB(0,0,0,1,1); - BgColorCallNullsub4(); - DungeonRunFrameActions(0x46); - gDungeon->unk7 = 0; - KyogreScreenFlash(); -} - -void sub_808C3A0(void) -{ - Entity * leaderEntity; - - leaderEntity = xxx_call_GetLeader(); - DungeonStopBGM(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - if (HasRecruitedMon(MONSTER_DEOXYS_NORMAL)) { - sub_808563C(sub_808C590); - } - else { - gDungeon->unk7 = 1; - sub_808563C(SetupDeoxysFacingDirection); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_DEOXYS_NORMAL); -} - -void sub_808C414(u8 param_1,u8 param_2,u8 param_3) -{ - if ((param_2 == 0x35) && (param_1 == 0x1D)) { - gDungeon->unk2 = 1; - DungeonStartNewBGM(MUS_RAYQUAZAS_DOMAIN); - } -} - -void DeoxysPreFightDialogue(void) -{ - Entity * leaderEntity; - - leaderEntity = xxx_call_GetLeader(); - sub_8086448(); - if (HasRecruitedMon(MONSTER_DEOXYS_NORMAL)) { - // There appears to be no one here. - // It's impossible to go any further - sub_80866C4(&gDeoxysPreFightDialogue_5); - } - else { - DisplayDungeonDialogue(&gDeoxysPreFightDialogue_1); - DungeonFadeInNewBGM(MUS_RAYQUAZAS_DOMAIN, 0x3c); - sub_808C550(); - DisplayDungeonDialogue(&gDeoxysPreFightDialogue_2); - DeoxysScreenFlash(); - DisplayDungeonDialogue(&gDeoxysPreFightDialogue_3); - DeoxysScreenFlash(); - DisplayDungeonDialogue(&gDeoxysPreFightDialogue_4); - sub_803E708(10,0x46); - sub_808563C(SetupDeoxysFightHP); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void DeoxysScreenFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x2c1); - for(iVar1 = 250; iVar1 > 149; iVar1 -= 10){ - SetDungeonBGColorRGB(iVar1,0,0,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10){ - SetDungeonBGColorRGB(iVar1,iVar1,0,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10){ - SetDungeonBGColorRGB(iVar1,0,0,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - sub_8085EB0(); -} - -void sub_808C550(void) -{ - gDungeonBrightness = 0x1f; - SetDungeonBGColorRGB(0,0,0,1,1); - BgColorCallNullsub4(); - DungeonRunFrameActions(0x46); - gDungeon->unk7 = 0; - DeoxysScreenFlash(); -} - -void sub_808C590(Entity *r0) -{ - sub_8068FE0(r0, 0x21C, 0); -} - -void SetupDeoxysFacingDirection(Entity *deoxysEntity) -{ - SetFacingDirection(deoxysEntity, DIRECTION_SOUTH); -} - -void SetupDeoxysFightHP(Entity *deoxysEntity) -{ - SetupBossFightHP(deoxysEntity, 950, MUS_BATTLE_WITH_RAYQUAZA); -} - -void sub_808C5C0(void) -{ - Entity * leaderEntity; - Entity * celebiEntity; - - u32 XPos; - s32 YPos; - - leaderEntity = xxx_call_GetLeader(); - celebiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_CELEBI); - DungeonStartNewBGM(MUS_FRIEND_AREA_HEALING_FOREST); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - SetFacingDirection(celebiEntity, DIRECTION_SOUTH); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); - XPos = GetCameraXPos(); - YPos = GetCameraYPos(); - sub_803F878(XPos,YPos - 0x1000); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_CELEBI); -} - -void nullsub_100(u8 r0, u8 r1, u8 r3) -{ -} - -void CelebiJoinDialogue(void) -{ - Entity *leaderEntity; - s32 state; - s32 menuChoice; - Entity *celebiEntity; - - leaderEntity = xxx_call_GetLeader(); - celebiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_CELEBI); - if ((HasRecruitedMon(MONSTER_CELEBI)) || (!sub_806FD18(celebiEntity))) - { - sub_8068FE0(celebiEntity,0x21c,0); - SpriteLookAroundEffect(leaderEntity); - sub_803E708(10,0x46); - // ......... - DisplayDungeonDialogue(&gCelebiJoinDialogue_10); - } - else - { - SpriteLookAroundEffect(leaderEntity); - sub_803E708(10,0x46); - SpriteShockEffect(leaderEntity); - sub_803E708(10,0x46); - // Oh? There's someone there. - DisplayDungeonDialogue(&gCelebiJoinDialogue_1); - sub_803E708(10,0x46); - sub_8086598(); - sub_8086598(); - sub_8086598(); - sub_8086598(); - // The Time-Traveling Pokemon {POKEMON_2} (Celebi)! - DisplayDungeonDialogue(&gCelebiJoinDialogue_2); - PlaySoundEffect(0x1c7); - sub_806CDD4(celebiEntity,10,DIRECTION_SOUTH); - sub_803E708(0x14,0x46); - sub_806CE68(celebiEntity, DIRECTION_SOUTH); - sub_803E708(4,0x46); - PlaySoundEffect(0x1c7); - sub_806CDD4(celebiEntity,10,DIRECTION_SOUTH); - DisplayDungeonDialogue(&gCelebiJoinDialogue_3); - sub_803E708(10,0x46); - state = 0; - - do - { - switch(state) - { - case 0: - do - { - menuChoice = DisplayDungeonMenuMessage(0,gPtrPurityForestAllowCelebiToJoinText, gPurityForestAllowCelebiToJoinPrompt,0x701); - } while (menuChoice < 1); - - sub_803E708(10,0x46); - - if (menuChoice == 1) - { - DungeonStopBGM(); - PlaySoundEffect(0xcc); - while (IsFanfareSEPlaying_2(0xcc) != 0) { - DungeonRunFrameActions(0x46); - } - DungeonStartNewBGM(MUS_FRIEND_AREA_HEALING_FOREST); - PlaySoundEffect(0x1c7); - sub_80861D4(celebiEntity,0xd,DIRECTION_SOUTH); - sub_803E708(0x37,0x46); - PlaySoundEffect(0x1d5); - sub_803E708(0x1a,0x46); - PlaySoundEffect(0x1d5); - sub_803E708(0x1c,0x46); - DisplayDungeonDialogue(&gCelebiJoinDialogue_4); - sub_803E708(10,0x46); - sub_806FDF4(leaderEntity,celebiEntity,&celebiEntity); - DungeonStartNewBGM(MUS_FRIEND_AREA_HEALING_FOREST); - DisplayDungeonDialogue(&gCelebiJoinDialogue_5); - sub_803E708(10,0x46); - PlaySoundEffect(0x1c7); - sub_80861D4(celebiEntity,0xd,DIRECTION_SOUTH); - sub_803E708(0x37,0x46); - PlaySoundEffect(0x1d5); - sub_803E708(0x1a,0x46); - PlaySoundEffect(0x1d5); - sub_803E708(0x1b,0x46); - DisplayDungeonDialogue(&gCelebiJoinDialogue_6); - sub_803E708(10,0x46); - state = 2; - } - else - { - state = 1; - } - break; - case 1: - do - { - menuChoice = DisplayDungeonMenuMessage(0,gPtrPurityForestRefuseCelebiConfirmText, gPurityForestRefuseCelebiConfirmPrompt,0x701); - } while (menuChoice < 1); - if (menuChoice == 1) - { - state = 0; - } - else - { - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gCelebiJoinDialogue_7); - sub_80861F8(0x3e,celebiEntity,1); - sub_803E708(0x18,0x46); - sub_80861F8(0x3e,celebiEntity,1); - sub_803E708(0xe,0x46); - DisplayDungeonDialogue(&gCelebiJoinDialogue_8); - sub_803E708(10,0x46); - sub_808C8E0(celebiEntity); - DisplayDungeonDialogue(&gCelebiJoinDialogue_9); - sub_803E708(10,0x46); - state = 2; - } - break; - } - } while (state != 2); - } - DungeonFadeOutBGM(0x1e); - sub_803E708(0x1e,0x46); - gDungeon->unk2 = 1; -} - -void sub_808C8E0(Entity *entity) -{ - s32 iVar1; - - PlaySoundEffect(0x1a5); - sub_806CDD4(entity, 0, DIRECTION_SOUTH); - for(iVar1 = 0; iVar1 < 16; iVar1++){ - GetEntInfo(entity)->unk174 = IntToF248_2(iVar1); - DungeonRunFrameActions(0x46); - } - for(iVar1 = 16; iVar1 < 200; iVar1 += 4){ - GetEntInfo(entity)->unk174 = IntToF248_2(iVar1); - DungeonRunFrameActions(0x46); - } - sub_8086A3C(entity); -} - -void sub_808C938(void) -{ - sub_80855E4(sub_808C9B0); -} - -void sub_808C948(Entity *entity, u8 param_2) -{ - bool8 flag; - s32 index; - Entity *pokeEntity; - - if (param_2 == 0x37) { - flag = FALSE; - for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++){ - pokeEntity = gDungeon->wildPokemon[index]; - if ((pokeEntity != entity) && (EntityIsValid(pokeEntity))) { - flag = TRUE; - break; - } - } - if (!flag) { - gDungeon->unk2 = 1; - } - } -} - -void sub_808C998(void) -{ - // Defeat the opposing team to win - // Be careful, your opponents are tough - DisplayDungeonDialogue(&gUnknown_8106720); - sub_803E708(0xA, 0x46); -} - -void sub_808C9B0(Entity *param_1) -{ - GetEntInfo(param_1)->action.direction = DIRECTION_NORTH; - sub_806CE68(param_1, DIRECTION_NORTH); -} - -void sub_808C9C4(void) -{ - Entity *leaderEntity; - Entity *medichamEntity; - - leaderEntity = xxx_call_GetLeader(); - medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - SetFacingDirection(medichamEntity, DIRECTION_SOUTH); - sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_MEDICHAM); -} - -void MedichamRescueDialogue(void) -{ - Entity *medichamEntity; - s32 counter; - - medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); - SpriteLookAroundEffect(medichamEntity); - sub_803E708(0xA, 0x46); - // Oh my I can't seem to find a way out... - DisplayDungeonDialogue(&gMedichamRescueDialogue_1); - sub_803E708(0xA, 0x46); - sub_80869E4(medichamEntity, 4, 2, DIRECTION_NORTH); - sub_803E708(0xA, 0x46); - // What am I to do...? - DisplayDungeonDialogue(&gMedichamRescueDialogue_2); - sub_803E708(0xA, 0x46); - sub_8086448(); - sub_8086598(); - sub_803E708(0x20, 0x46); - SpriteShockEffect(medichamEntity); - sub_803E708(0x20, 0x46); - sub_80869E4(medichamEntity, 4, 2, DIRECTION_SOUTH); - DisplayDungeonDialogue(&gMedichamRescueDialogue_3); - sub_803E708(0xA, 0x46); - PlaySoundEffect(0x1c7); - sub_806CDD4(medichamEntity, 0xA, DIRECTION_SOUTH); - sub_803E708(0x14, 0x46); - sub_806CE68(medichamEntity, DIRECTION_SOUTH); - sub_803E708(0x4, 0x46); - PlaySoundEffect(0x1c7); - sub_806CDD4(medichamEntity, 0xA, DIRECTION_SOUTH); - sub_803E708(0x14, 0x46); - // Yes Yes - // I am so lucky - // - // There appears to be no one here - DisplayDungeonDialogue(&gMedichamRescueDialogue_4); - sub_803E708(0xA, 0x46); - sub_806CDD4(medichamEntity, 0, DIRECTION_SOUTH); - for(counter = 0x17; counter >= 0; counter--) - { - IncreaseEntityPixelPos(medichamEntity, 0, 0x100); - DungeonRunFrameActions(0x46); - } - sub_806CE68(medichamEntity, DIRECTION_SOUTH); - sub_803E708(0x20, 0x46); - sub_8042B0C(medichamEntity); - sub_8068FE0(medichamEntity, 0x21C, 0); - gDungeon->unk4 = 1; - gDungeon->unk11 = 4; -} - -void sub_808CB5C(void) -{ - Entity *leaderEntity; - Entity *medichamEntity; - - leaderEntity = xxx_call_GetLeader(); - medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_8068FE0(medichamEntity, 0x21C, 0); - sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_MEDICHAM); -} - -void DummyFightDialogue(void) -{ -} - -void sub_808CBB0(void) -{ - Entity *leaderEntity; - Entity *smeargleEntity; - - leaderEntity = xxx_call_GetLeader(); - smeargleEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SMEARGLE); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - SetFacingDirection(smeargleEntity, DIRECTION_SOUTH); - sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SMEARGLE); -} - -void SmeargleRescueDialogue(void) -{ - Entity *smeargleEntity; - s32 counter; - - smeargleEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SMEARGLE); - SpriteLookAroundEffect(smeargleEntity); - sub_803E708(0xA, 0x46); - // Ohhh... - // I've lost my bearings - DisplayDungeonDialogue(&gSmeargleRescueDialogue_1); - sub_803E708(0xA, 0x46); - sub_80869E4(smeargleEntity, 4, 2, DIRECTION_NORTH); - sub_803E708(0xA, 0x46); - // I can't get out... - // I'm hungry... - // I'm in trouble - DisplayDungeonDialogue(&gSmeargleRescueDialogue_2); - sub_803E708(0xA, 0x46); - sub_8086448(); - sub_8086598(); - sub_803E708(0x20, 0x46); - SpriteShockEffect(smeargleEntity); - sub_803E708(0x20, 0x46); - sub_80869E4(smeargleEntity, 4, 2, DIRECTION_SOUTH); - // Oh! You are? - DisplayDungeonDialogue(&gSmeargleRescueDialogue_3); - sub_803E708(0xA, 0x46); - PlaySoundEffect(0x1c7); - sub_806CDD4(smeargleEntity, 0xA, DIRECTION_SOUTH); - sub_803E708(0x14, 0x46); - sub_806CE68(smeargleEntity, DIRECTION_SOUTH); - sub_803E708(0x4, 0x46); - PlaySoundEffect(0x1c7); - sub_806CDD4(smeargleEntity, 0xA, DIRECTION_SOUTH); - sub_803E708(0x14, 0x46); - // Did you maybe come to rescue me? - // Am I glad to see you - DisplayDungeonDialogue(&gSmeargleRescueDialogue_4); - sub_803E708(0xA, 0x46); - sub_806CDD4(smeargleEntity, 0, DIRECTION_SOUTH); - for(counter = 0x17; counter >= 0; counter--) - { - IncreaseEntityPixelPos(smeargleEntity, 0, 0x100); - DungeonRunFrameActions(0x46); - } - sub_806CE68(smeargleEntity, DIRECTION_SOUTH); - sub_803E708(0x20, 0x46); - sub_8042B0C(smeargleEntity); - sub_8068FE0(smeargleEntity, 0x21C, 0); - gDungeon->unk4 = 1; - gDungeon->unk11 = 4; - -} - -void sub_808CD44(void) -{ - Entity *leaderEntity; - Entity *smeargleEntity; - - leaderEntity = xxx_call_GetLeader(); - smeargleEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SMEARGLE); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - sub_8068FE0(smeargleEntity, 540, 0); - sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SMEARGLE); -} - -void sub_808CD9C(void) -{ - sub_8086448(); - // There appears to be no one here. - // It's impossible to go any further - sub_80866C4(&gUnknown_810697C); -} diff --git a/src/dungeon_portrait_placement.c b/src/dungeon_portrait_placement.c index d2013e8bc..60f3a184e 100644 --- a/src/dungeon_portrait_placement.c +++ b/src/dungeon_portrait_placement.c @@ -4,7 +4,7 @@ // Note: this file is not part of overlay5. It's most likely arm9.bin, but I couldn't locate the address -static const struct PortraitPlacementInfo gUnknown_8107544[] = { +static const struct PortraitPlacementInfo sDungeonPortraitsInfo[] = { [0] = {{2, 8}, FALSE}, [1] = {{12, 5}, FALSE}, [2] = {{2, 8}, FALSE}, @@ -30,5 +30,5 @@ static const struct PortraitPlacementInfo gUnknown_8107544[] = { const struct PortraitPlacementInfo *GetPortraitPlacementInfo(u8 id) { - return &gUnknown_8107544[id]; + return &sDungeonPortraitsInfo[id]; }