- 22
- Posts
- 261
- Days
- Seen May 16, 2024
Hi All,
This is my first post looking for debug help, so I apologize if I do this incorrectly.
I want to have a custom event trigger in May's Room during the night hours (Jirachi appears, player gets to catch it, etc.). I've written a special function
1. The special call is not finishing before the code continues to execute, causing an error (thus why any script, whether inside the CheckIfNight script or the PlayJirachiEvent script, causes blackscreen).
OR
2. There is something funky going on with me goto_if_set call on line 20.
I am now leaning towards the former, but I'm not sure what could be causing the issue. If someone could please take a look and help out, that would be huge! Thank you all very much. For the script file, I've only included the sections that I've edited (other than movement and text) but if you'd like to see the whole file, please let me know and I'll share it. Thanks so much again!
This is my first post looking for debug help, so I apologize if I do this incorrectly.
I want to have a custom event trigger in May's Room during the night hours (Jirachi appears, player gets to catch it, etc.). I've written a special function
IsNight
that checks if the gLocalTime.hours is < 7 || >= 20. Gratefully, this works no problem! It sets a flag FLAG_IS_NIGHT
to true, which I am using to trigger the event. The idea is that if the player has the national dex (FLAG_SYS_NATIONAL_DEX), has not yet caught Jirachi (FLAG_CAUGHT_JIRACHI), it is night (FLAG_IS_NIGHT), and finally if the player is not female (checkplayergender, will be doing the same thing in Brendan's Room for female characters), then the event will trigger. I've included below the time_events.c which has the function in it (again, working so I don't think that's the problem) as well as the script file for May's Room. I think the issue is on line 20, where I am calling goto_if_set FLAG_IS_NIGHT, LittlerootTown_MaysHouse_2F_EventScript_PlayJirachiEvent
. When I remove this line, FLAG_IS_NIGHT is set to true, as it should be by the special call on the line above. Including this line however causes the game to blackscreen. The music still plays but nothing loads in. I have tried using a different flag (FLAG_SYS_NATIONAL_DEX) for testing and the same thing occurs. I have also tried pointing it to a different event script, same thing occurs. I edited the PlayJirachiEvent
event script to something very simply (playmoncry) and the same thing occurs. Lastly, I have tried adding in a simple msgbox that occurs after the special IsNight
is called, and that doesn't seem to work. I have made sure to include def_special IsNight
in the specials.inc file. So my thoughts are either of these 2 things:1. The special call is not finishing before the code continues to execute, causing an error (thus why any script, whether inside the CheckIfNight script or the PlayJirachiEvent script, causes blackscreen).
OR
2. There is something funky going on with me goto_if_set call on line 20.
I am now leaning towards the former, but I'm not sure what could be causing the issue. If someone could please take a look and help out, that would be huge! Thank you all very much. For the script file, I've only included the sections that I've edited (other than movement and text) but if you'd like to see the whole file, please let me know and I'll share it. Thanks so much again!
Spoiler: time_events.h
#ifndef GUARD_TIME_EVENTS_H
#define GUARD_TIME_EVENTS_H
void UpdateMirageRnd(u16);
u8 IsMirageIslandPresent(void);
void IsNight(void);
void UpdateBirchState(u16);
#endif // GUARD_TIME_EVENTS_H
Spoiler: time_events.c
void IsNight(void)
{
// day is 7am to 8pm
// night is 8pm to 7am
RtcCalcLocalTime();
if (gLocalTime.hours < 7 || gLocalTime.hours >= 20)
FlagSet(FLAG_IS_NIGHT);
else
FlagClear(FLAG_IS_NIGHT);
}
Spoiler: May's House 2F script.inc
LittlerootTown_MaysHouse_2F_MapScripts::
map_script MAP_SCRIPT_ON_TRANSITION, LittlerootTown_MaysHouse_2F_OnTransition
map_script MAP_SCRIPT_ON_WARP_INTO_MAP_TABLE, LittlerootTown_MaysHouse_2F_OnWarp
.byte 0
LittlerootTown_MaysHouse_2F_OnTransition:
call_if_lt VAR_LITTLEROOT_RIVAL_STATE, 2, LittlerootTown_MaysHouse_2F_EventScript_CheckSetReadyToMeetMay
call_if_ge VAR_LITTLEROOT_RIVAL_STATE, 3, LittlerootTown_MaysHouse_2F_EventScript_CheckShouldUpdateMayPos
call_if_eq VAR_LITTLEROOT_INTRO_STATE, 4, PlayersHouse_2F_EventScript_BlockStairsUntilClockIsSet
call SecretBase_EventScript_SetDecorationFlags
setvar VAR_SECRET_BASE_INITIALIZED, 0
setflag FLAG_HIDE_JIRACHI
goto_if_set FLAG_SYS_NATIONAL_DEX, LittlerootTown_MaysHouse_2F_EventScript_CheckIfNight
end
LittlerootTown_MaysHouse_2F_EventScript_CheckIfNight::
special IsNight
lockall
msgbox RivalsHouse_2F_Text_QuickComeSee, MSGBOX_DEFAULT
releaseall
end
LittlerootTown_MaysHouse_2F_EventScript_PlayJirachiEvent::
goto_if_set FLAG_CAUGHT_JIRACHI, LittlerootTown_MaysHouse_2F_EventScript_Ret
checkplayergender
goto_if_eq VAR_RESULT, FEMALE, LittlerootTown_MaysHouse_2F_EventScript_Ret
clearflag FLAG_HIDE_JIRACHI
clearflag FLAG_HIDE_LITTLEROOT_TOWN_MAYS_HOUSE_RIVAL_BEDROOM
setobjectxyperm LOCALID_RIVAL, 7, 5
playse SE_PIN
applymovement LOCALID_RIVAL, Common_Movement_ExclamationMark
msgbox RivalsHouse_2F_Text_QuickComeSee, MSGBOX_DEFAULT
applymovement OBJ_EVENT_ID_PLAYER, LittlerootTown_MaysHouse_2F_Movement_PlayerMoveJirachi
waitmovement 0
msgbox RivalsHouse_2F_Text_MadeAWish, MSGBOX_DEFAULT
applymovement LOCALID_RIVAL, LittlerootTown_MaysHouse_2F_Movement_TurnRival
waitmovement 0
applymovement LOCALID_RIVAL, Common_Movement_FacePlayer
waitmovement 0
msgbox RivalsHouse_2F_Text_Woah, MSGBOX_DEFAULT
applymovement 17, LittlerootTown_MaysHouse_2F_Movement_JirachiMovement
waitmovement 0
applymovement 17, Common_Movement_FacePlayer
waitmovement 0
call LittlerootTown_MaysHouse_2F_EventScript_JirachiFight
msgbox RivalsHouse_2F_Text_WhatIWishedFor, MSGBOX_DEFAULT
msgbox RivalsHouse_2F_Text_TimeForBed, MSGBOX_DEFAULT
fadescreen FADE_TO_BLACK
setflag FLAG_HIDE_LITTLEROOT_TOWN_MAYS_HOUSE_RIVAL_BEDROOM
fadescreen FADE_FROM_BLACK
return
LittlerootTown_MaysHouse_2F_EventScript_JirachiFight::
lockall
playmoncry SPECIES_JIRACHI, CRY_MODE_ENCOUNTER
waitmoncry
setwildbattle SPECIES_JIRACHI, 75, ITEM_LAVA_COOKIE
special BattleSetup_StartLegendaryBattle
waitstate
specialvar VAR_RESULT, GetBattleOutcome
goto_if_eq VAR_RESULT, B_OUTCOME_CAUGHT, LittlerootTown_MaysHouse_2F_EventScript_PostJirachiBattle
goto_if_eq VAR_RESULT, B_OUTCOME_WON, LittlerootTown_MaysHouse_2F_EventScript_PostJirachiBattle
releaseall
return
LittlerootTown_MaysHouse_2F_EventScript_PostJirachiBattle::
fadescreen FADE_TO_BLACK
removeobject 17
fadescreen FADE_FROM_BLACK
setflag FLAG_CAUGHT_JIRACHI
setflag FLAG_HIDE_JIRACHI
return