Sync script.c
This commit is contained in:
@@ -285,7 +285,7 @@
|
||||
.endm
|
||||
|
||||
@ Blocks script execution until a command or C code manually unblocks it. Generally used with specific
|
||||
@ commands and specials. Calling EnableBothScriptContexts for instance will allow execution to continue.
|
||||
@ commands and specials. Calling ScriptContext_Enable for instance will allow execution to continue.
|
||||
.macro waitstate
|
||||
.byte 0x27
|
||||
.endm
|
||||
|
||||
+12
-17
@@ -28,26 +28,21 @@ u8 SetupBytecodeScript(struct ScriptContext *ctx, const u8 *ptr);
|
||||
void SetupNativeScript(struct ScriptContext *ctx, bool8 (*ptr)(void));
|
||||
void StopScript(struct ScriptContext *ctx);
|
||||
bool8 RunScriptCommand(struct ScriptContext *ctx);
|
||||
u8 ScriptPush(struct ScriptContext *ctx, const u8 *ptr);
|
||||
const u8 *ScriptPop(struct ScriptContext *ctx);
|
||||
void ScriptJump(struct ScriptContext *ctx, const u8 *ptr);
|
||||
void ScriptCall(struct ScriptContext *ctx, const u8 *ptr);
|
||||
void ScriptReturn(struct ScriptContext *ctx);
|
||||
u16 ScriptReadHalfword(struct ScriptContext *ctx);
|
||||
u32 ScriptReadWord(struct ScriptContext *ctx);
|
||||
void ScriptContext2_Enable(void);
|
||||
void ScriptContext2_Disable(void);
|
||||
bool8 ScriptContext2_IsEnabled(void);
|
||||
void ScriptContext1_Init(void);
|
||||
bool8 ScriptContext1_IsScriptSetUp(void);
|
||||
bool8 ScriptContext2_RunScript(void);
|
||||
void ScriptContext1_SetupScript(const u8 *ptr);
|
||||
void ScriptContext1_Stop(void);
|
||||
void EnableBothScriptContexts(void);
|
||||
void ScriptContext2_RunNewScript(const u8 *ptr);
|
||||
u8 *mapheader_get_tagged_pointer(u8 tag);
|
||||
void mapheader_run_script_by_tag(u8 tag);
|
||||
u8 *mapheader_get_first_match_from_tagged_ptr_list(u8 tag);
|
||||
void LockPlayerFieldControls(void);
|
||||
void UnlockPlayerFieldControls(void);
|
||||
bool8 ArePlayerFieldControlsLocked(void);
|
||||
void ScriptContext_Init(void);
|
||||
bool8 ScriptContext_IsEnabled(void);
|
||||
bool8 ScriptContext_RunScript(void);
|
||||
void ScriptContext_SetupScript(const u8 *ptr);
|
||||
void ScriptContext_Stop(void);
|
||||
void ScriptContext_Enable(void);
|
||||
void RunScriptImmediately(const u8 *ptr);
|
||||
void RunOnLoadMapScript(void);
|
||||
void RunOnTransitionMapScript(void);
|
||||
void RunOnResumeMapScript(void);
|
||||
@@ -60,7 +55,7 @@ void ClearRamScript(void);
|
||||
bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId);
|
||||
const u8 *GetRamScript(u8 objectId, const u8 *script);
|
||||
bool32 ValidateRamScript(void);
|
||||
void MEventSetRamScript(u8 * script, u16 scriptSize);
|
||||
void InitRamScript_NoObjectEvent(u8 * script, u16 scriptSize);
|
||||
u8 * GetSavedRamScriptIfValid(void);
|
||||
void RegisterQuestLogInput(u8 var);
|
||||
void ClearMsgBoxCancelableState(void);
|
||||
@@ -77,7 +72,7 @@ bool8 CanWalkAwayToCancelMsgBox(void);
|
||||
void SetWalkingIntoSignVars(void);
|
||||
bool8 IsMsgBoxWalkawayDisabled(void);
|
||||
|
||||
extern const u8 *gRAMScriptPtr;
|
||||
extern const u8 *gRamScriptRetAddr;
|
||||
extern u8 gWalkAwayFromSignInhibitTimer;
|
||||
|
||||
#endif // GUARD_SCRIPT_H
|
||||
|
||||
+16
-16
@@ -236,7 +236,7 @@ void StartWildBattle(void)
|
||||
|
||||
static void DoStandardWildBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
StopPlayerAvatar();
|
||||
gMain.savedCallback = CB2_EndWildBattle;
|
||||
@@ -248,7 +248,7 @@ static void DoStandardWildBattle(void)
|
||||
|
||||
void StartRoamerBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
StopPlayerAvatar();
|
||||
gMain.savedCallback = CB2_EndWildBattle;
|
||||
@@ -260,7 +260,7 @@ void StartRoamerBattle(void)
|
||||
|
||||
static void DoSafariBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
StopPlayerAvatar();
|
||||
gMain.savedCallback = CB2_EndSafariBattle;
|
||||
@@ -270,7 +270,7 @@ static void DoSafariBattle(void)
|
||||
|
||||
static void DoGhostBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
StopPlayerAvatar();
|
||||
gMain.savedCallback = CB2_EndWildBattle;
|
||||
@@ -291,7 +291,7 @@ static void DoTrainerBattle(void)
|
||||
void StartOldManTutorialBattle(void)
|
||||
{
|
||||
CreateMaleMon(&gEnemyParty[0], SPECIES_WEEDLE, 5);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_ReturnToFieldContinueScriptPlayMapMusic;
|
||||
gBattleTypeFlags = BATTLE_TYPE_OLD_MAN_TUTORIAL;
|
||||
CreateBattleStartTask(B_TRANSITION_SLICED_SCREEN, 0);
|
||||
@@ -299,7 +299,7 @@ void StartOldManTutorialBattle(void)
|
||||
|
||||
void StartScriptedWildBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_EndScriptedWildBattle;
|
||||
gBattleTypeFlags = BATTLE_TYPE_WILD_SCRIPTED;
|
||||
CreateBattleStartTask(GetWildBattleTransition(), 0);
|
||||
@@ -309,7 +309,7 @@ void StartScriptedWildBattle(void)
|
||||
|
||||
void StartMarowakBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_EndMarowakBattle;
|
||||
if (CheckBagHasItem(ITEM_SILPH_SCOPE, 1))
|
||||
{
|
||||
@@ -328,7 +328,7 @@ void StartMarowakBattle(void)
|
||||
|
||||
void StartSouthernIslandBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_EndScriptedWildBattle;
|
||||
gBattleTypeFlags = BATTLE_TYPE_LEGENDARY;
|
||||
CreateBattleStartTask(GetWildBattleTransition(), 0);
|
||||
@@ -340,7 +340,7 @@ void StartLegendaryBattle(void)
|
||||
{
|
||||
u16 species;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_EndScriptedWildBattle;
|
||||
gBattleTypeFlags = BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_LEGENDARY_FRLG;
|
||||
species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES);
|
||||
@@ -369,7 +369,7 @@ void StartLegendaryBattle(void)
|
||||
|
||||
void StartGroudonKyogreBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_EndScriptedWildBattle;
|
||||
gBattleTypeFlags = BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_KYOGRE_GROUDON;
|
||||
if (gGameVersion == VERSION_FIRE_RED)
|
||||
@@ -382,7 +382,7 @@ void StartGroudonKyogreBattle(void)
|
||||
|
||||
void StartRegiBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_EndScriptedWildBattle;
|
||||
gBattleTypeFlags = BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_REGI;
|
||||
CreateBattleStartTask(B_TRANSITION_BLUR, MUS_RS_VS_TRAINER);
|
||||
@@ -400,7 +400,7 @@ static void sub_807FAF8(void)
|
||||
// not used
|
||||
static void sub_807FB08(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
StopPlayerAvatar();
|
||||
gMain.savedCallback = sub_807FAF8;
|
||||
@@ -823,8 +823,8 @@ void ConfigureAndSetUpOneTrainerBattle(u8 trainerEventObjId, const u8 *trainerSc
|
||||
gSelectedObjectEvent = trainerEventObjId;
|
||||
gSpecialVar_LastTalked = gObjectEvents[trainerEventObjId].localId;
|
||||
BattleSetup_ConfigureTrainerBattle(trainerScript + 1);
|
||||
ScriptContext1_SetupScript(EventScript_DoTrainerBattleFromApproach);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(EventScript_DoTrainerBattleFromApproach);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
bool32 GetTrainerFlagFromScriptPointer(const u8 *data)
|
||||
@@ -889,7 +889,7 @@ void StartTrainerBattle(void)
|
||||
gBattleTypeFlags |= BATTLE_TYPE_FIRST_BATTLE;
|
||||
gMain.savedCallback = CB2_EndTrainerBattle;
|
||||
DoTrainerBattle();
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
}
|
||||
|
||||
static void CB2_EndTrainerBattle(void)
|
||||
@@ -964,7 +964,7 @@ void StartRematchBattle(void)
|
||||
gBattleTypeFlags = BATTLE_TYPE_TRAINER;
|
||||
gMain.savedCallback = CB2_EndRematchBattle;
|
||||
DoTrainerBattle();
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
}
|
||||
|
||||
void ShowTrainerIntroSpeech(void)
|
||||
|
||||
+3
-3
@@ -3178,8 +3178,8 @@ static void Task_ShowBerryCrushRankings(u8 taskId)
|
||||
ClearWindowTilemap(tWindowId);
|
||||
RemoveWindow(tWindowId);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Enable();
|
||||
UnlockPlayerFieldControls();
|
||||
tState = 0;
|
||||
return;
|
||||
}
|
||||
@@ -3190,7 +3190,7 @@ void ShowBerryCrushRankings(void)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
taskId = CreateTask(Task_ShowBerryCrushRankings, 0);
|
||||
gTasks[taskId].tPressingSpeeds(0) = gSaveBlock2Ptr->berryCrush.pressingSpeeds[0];
|
||||
gTasks[taskId].tPressingSpeeds(1) = gSaveBlock2Ptr->berryCrush.pressingSpeeds[1];
|
||||
|
||||
+11
-11
@@ -405,7 +405,7 @@ static void Task_Linkup_6a(u8 taskId)
|
||||
if (gLinkType == LINKTYPE_BERRY_BLENDER_SETUP)
|
||||
*UnusedVarNeededToMatch += 0;
|
||||
DestroyLinkPlayerCountDisplayWindow(gTasks[taskId].data[5]);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
else
|
||||
@@ -421,7 +421,7 @@ static void Task_Linkup_7(u8 taskId)
|
||||
if (!gReceivedRemoteLinkPlayers)
|
||||
{
|
||||
DestroyLinkPlayerCountDisplayWindow(gTasks[taskId].data[5]);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
RemoveWindow(gTasks[taskId].data[5]);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
@@ -432,7 +432,7 @@ static void Task_Linkup_Canceled(u8 taskId)
|
||||
gSpecialVar_Result = 5;
|
||||
DestroyLinkPlayerCountDisplayWindow(gTasks[taskId].data[5]);
|
||||
HideFieldMessageBox();
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ static void Task_Linkup_ErroredOut(u8 taskId)
|
||||
gSpecialVar_Result = 6;
|
||||
DestroyLinkPlayerCountDisplayWindow(gTasks[taskId].data[5]);
|
||||
HideFieldMessageBox();
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
@@ -807,7 +807,7 @@ static void Task_EnterCableClubSeat(u8 taskId)
|
||||
SetLinkWaitingForScript();
|
||||
sub_80F771C(TRUE);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -816,7 +816,7 @@ static void CreateEnterCableClubSeatTaskWithFollowupFunc(TaskFunc followUpFunc)
|
||||
{
|
||||
u8 taskId = CreateTask(Task_EnterCableClubSeat, 80);
|
||||
SetTaskFuncWithFollowupFunc(taskId, Task_EnterCableClubSeat, followUpFunc);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
}
|
||||
|
||||
static void Task_StartWiredCableClubTrade(u8 taskId)
|
||||
@@ -825,7 +825,7 @@ static void Task_StartWiredCableClubTrade(u8 taskId)
|
||||
switch (task->data[0])
|
||||
{
|
||||
case 0:
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FadeScreen(FADE_TO_BLACK, 0);
|
||||
ClearLinkCallback_2();
|
||||
task->data[0]++;
|
||||
@@ -857,7 +857,7 @@ static void Task_StartWirelessCableClubTrade(u8 taskId)
|
||||
switch (data[0])
|
||||
{
|
||||
case 0:
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FadeScreen(FADE_TO_BLACK, 0);
|
||||
ClearLinkRfuCallback();
|
||||
data[0]++;
|
||||
@@ -899,7 +899,7 @@ static void CreateTask_StartWiredCableClubTrade(void)
|
||||
void StartWiredCableClubTrade(void)
|
||||
{
|
||||
CreateTask_StartWiredCableClubTrade();
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
}
|
||||
|
||||
void EnterColosseumPlayerSpot(void)
|
||||
@@ -914,7 +914,7 @@ void EnterColosseumPlayerSpot(void)
|
||||
static void Debug_CreateTaskEnterCableClubSeat(void)
|
||||
{
|
||||
CreateTask(Task_EnterCableClubSeat, 80);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
}
|
||||
|
||||
void Script_ShowLinkTrainerCard(void)
|
||||
@@ -952,7 +952,7 @@ static void sub_8081AE4(u8 taskId)
|
||||
{
|
||||
if (!gReceivedRemoteLinkPlayers)
|
||||
{
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1515,7 +1515,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId)
|
||||
ClearStdWindowAndFrame(gTasks[taskId].tWindowId, TRUE);
|
||||
RemoveWindow(gTasks[taskId].tWindowId);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
else if (gMain.newKeys & B_BUTTON)
|
||||
{
|
||||
@@ -1524,7 +1524,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId)
|
||||
ClearStdWindowAndFrame(gTasks[taskId].tWindowId, TRUE);
|
||||
RemoveWindow(gTasks[taskId].tWindowId);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1756,7 +1756,7 @@ static void VBlankCB_EggHatch(void)
|
||||
|
||||
void EggHatch(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
CreateTask(Task_EggHatch, 10);
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, 0);
|
||||
HelpSystem_Disable();
|
||||
|
||||
@@ -2984,7 +2984,7 @@ static void Task_ShowDodrioBerryPickingRecords(u8 taskId)
|
||||
{
|
||||
RemoveWindow(tWindowId);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1690,7 +1690,7 @@ void MakeObjectTemplateFromObjectEventGraphicsInfo(u16 graphicsId, void (*callba
|
||||
|
||||
do
|
||||
{
|
||||
if (ScriptContext1_IsScriptSetUp() != TRUE && sub_8112CAC() == TRUE)
|
||||
if (ScriptContext_IsEnabled() != TRUE && sub_8112CAC() == TRUE)
|
||||
spriteTemplate->callback = sub_811246C;
|
||||
else
|
||||
spriteTemplate->callback = callback;
|
||||
|
||||
+17
-17
@@ -97,7 +97,7 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
|
||||
u8 tileTransitionState = gPlayerAvatar.tileTransitionState;
|
||||
bool8 forcedMove = MetatileBehavior_IsForcedMovementTile(GetPlayerCurMetatileBehavior());
|
||||
|
||||
if (!ScriptContext1_IsScriptSetUp() && IsQuestLogInputDpad() == TRUE)
|
||||
if (!ScriptContext_IsEnabled() && IsQuestLogInputDpad() == TRUE)
|
||||
{
|
||||
QuestLogOverrideJoyVars(input, &newKeys, &heldKeys);
|
||||
}
|
||||
@@ -300,7 +300,7 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
|
||||
|
||||
void FieldInput_HandleCancelSignpost(struct FieldInput * input)
|
||||
{
|
||||
if (ScriptContext1_IsScriptSetUp() == TRUE)
|
||||
if (ScriptContext_IsEnabled() == TRUE)
|
||||
{
|
||||
if (gWalkAwayFromSignInhibitTimer != 0)
|
||||
gWalkAwayFromSignInhibitTimer--;
|
||||
@@ -318,13 +318,13 @@ void FieldInput_HandleCancelSignpost(struct FieldInput * input)
|
||||
RegisterQuestLogInput(QL_INPUT_LEFT);
|
||||
else if (input->dpadDirection == DIR_EAST)
|
||||
RegisterQuestLogInput(QL_INPUT_RIGHT);
|
||||
ScriptContext1_SetupScript(EventScript_CancelMessageBox);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(EventScript_CancelMessageBox);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
else if (input->pressedStartButton)
|
||||
{
|
||||
ScriptContext1_SetupScript(EventScript_CancelMessageBox);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(EventScript_CancelMessageBox);
|
||||
LockPlayerFieldControls();
|
||||
if (!FuncIsActiveTask(Task_QuestLogPlayback_OpenStartMenu))
|
||||
CreateTask(Task_QuestLogPlayback_OpenStartMenu, 8);
|
||||
}
|
||||
@@ -334,7 +334,7 @@ void FieldInput_HandleCancelSignpost(struct FieldInput * input)
|
||||
|
||||
static void Task_QuestLogPlayback_OpenStartMenu(u8 taskId)
|
||||
{
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
if (!ArePlayerFieldControlsLocked())
|
||||
{
|
||||
PlaySE(SE_WIN_OPEN);
|
||||
ShowStartMenu();
|
||||
@@ -379,7 +379,7 @@ static bool8 TryStartInteractionScript(struct MapPosition *position, u16 metatil
|
||||
&& script != EventScript_PC)
|
||||
PlaySE(SE_SELECT);
|
||||
|
||||
ScriptContext1_SetupScript(script);
|
||||
ScriptContext_SetupScript(script);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -636,7 +636,7 @@ static bool8 TryStartCoordEventScript(struct MapPosition *position)
|
||||
|
||||
if (script == NULL)
|
||||
return FALSE;
|
||||
ScriptContext1_SetupScript(script);
|
||||
ScriptContext_SetupScript(script);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -659,18 +659,18 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior)
|
||||
{
|
||||
if (UpdateVsSeekerStepCounter() == TRUE)
|
||||
{
|
||||
ScriptContext1_SetupScript(EventScript_VsSeekerChargingDone);
|
||||
ScriptContext_SetupScript(EventScript_VsSeekerChargingDone);
|
||||
return TRUE;
|
||||
}
|
||||
else if (UpdatePoisonStepCounter() == TRUE)
|
||||
{
|
||||
ScriptContext1_SetupScript(EventScript_FieldPoison);
|
||||
ScriptContext_SetupScript(EventScript_FieldPoison);
|
||||
return TRUE;
|
||||
}
|
||||
else if (ShouldEggHatch())
|
||||
{
|
||||
IncrementGameStat(GAME_STAT_HATCHED_EGGS);
|
||||
ScriptContext1_SetupScript(EventScript_EggHatch);
|
||||
ScriptContext_SetupScript(EventScript_EggHatch);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -807,7 +807,7 @@ static u8 GetFacingSignpostType(u16 metatileBehavior, u8 playerDirection)
|
||||
static void SetUpWalkIntoSignScript(const u8 *script, u8 playerDirection)
|
||||
{
|
||||
gSpecialVar_Facing = playerDirection;
|
||||
ScriptContext1_SetupScript(script);
|
||||
ScriptContext_SetupScript(script);
|
||||
SetWalkingIntoSignVars();
|
||||
MsgSetSignPost();
|
||||
}
|
||||
@@ -889,7 +889,7 @@ static bool8 TryStartWarpEventScript(struct MapPosition *position, u16 metatileB
|
||||
if (MetatileBehavior_IsFallWarp(metatileBehavior) == TRUE)
|
||||
{
|
||||
ResetInitialPlayerAvatarState();
|
||||
ScriptContext1_SetupScript(EventScript_1C1361);
|
||||
ScriptContext_SetupScript(EventScript_1C1361);
|
||||
return TRUE;
|
||||
}
|
||||
DoWarp();
|
||||
@@ -1033,7 +1033,7 @@ static const u8 *TryRunCoordEventScript(struct CoordEvent *coordEvent)
|
||||
}
|
||||
if (coordEvent->trigger == 0)
|
||||
{
|
||||
ScriptContext2_RunNewScript(coordEvent->script);
|
||||
RunScriptImmediately(coordEvent->script);
|
||||
return NULL;
|
||||
}
|
||||
if (VarGet(coordEvent->trigger) == (u8)coordEvent->index)
|
||||
@@ -1086,8 +1086,8 @@ void HandleBoulderActivateVictoryRoadSwitch(u16 x, u16 y)
|
||||
if (events[i].x + 7 == x && events[i].y + 7 == y)
|
||||
{
|
||||
QuestLog_CutRecording();
|
||||
ScriptContext1_SetupScript(events[i].script);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(events[i].script);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+22
-22
@@ -1071,7 +1071,7 @@ static void FieldCallback_UseFly(void)
|
||||
{
|
||||
FadeInFromBlack();
|
||||
CreateTask(Task_UseFly, 0);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gFieldCallback = NULL;
|
||||
}
|
||||
@@ -1108,7 +1108,7 @@ static void FieldCallback_FlyIntoMap(void)
|
||||
gObjectEvents[gPlayerAvatar.objectEventId].invisible = TRUE;
|
||||
if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
|
||||
ObjectEventTurn(&gObjectEvents[gPlayerAvatar.objectEventId], DIR_WEST);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gFieldCallback = NULL;
|
||||
}
|
||||
@@ -1126,7 +1126,7 @@ static void Task_FlyIntoMap(u8 taskId)
|
||||
}
|
||||
if (!FieldEffectActiveListContains(FLDEFF_FLY_IN))
|
||||
{
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnfreezeObjectEvents();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
@@ -1156,7 +1156,7 @@ void FieldCB_FallWarpExit(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
WarpFadeInScreen();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
CreateTask(Task_FallWarpFieldEffect, 0);
|
||||
gFieldCallback = NULL;
|
||||
@@ -1274,7 +1274,7 @@ static bool8 FallWarpEffect_7(struct Task *task)
|
||||
{
|
||||
s16 x, y;
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
CameraObjectReset1();
|
||||
UnfreezeObjectEvents();
|
||||
InstallCameraPanAheadCallback();
|
||||
@@ -1459,7 +1459,7 @@ static void FieldCB_EscalatorWarpIn(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
WarpFadeInScreen();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
CreateTask(Task_EscalatorWarpInFieldEffect, 0);
|
||||
gFieldCallback = NULL;
|
||||
@@ -1576,7 +1576,7 @@ static bool8 EscalatorWarpInEffect_7(struct Task *task)
|
||||
if (ObjectEventClearHeldMovementIfFinished(objectEvent))
|
||||
{
|
||||
CameraObjectReset1();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnfreezeObjectEvents();
|
||||
ObjectEventSetHeldMovement(objectEvent, GetWalkNormalMovementAction(DIR_EAST));
|
||||
DestroyTask(FindTaskIdByFunc(Task_EscalatorWarpInFieldEffect));
|
||||
@@ -1617,7 +1617,7 @@ static void Task_UseWaterfall(u8 taskId)
|
||||
|
||||
static bool8 waterfall_0_setup(struct Task *task, struct ObjectEvent * playerObj)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
task->data[0]++;
|
||||
return FALSE;
|
||||
@@ -1625,7 +1625,7 @@ static bool8 waterfall_0_setup(struct Task *task, struct ObjectEvent * playerObj
|
||||
|
||||
static bool8 waterfall_1_do_anim_probably(struct Task *task, struct ObjectEvent * playerObj)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
if (!ObjectEventIsMovementOverridden(playerObj))
|
||||
{
|
||||
ObjectEventClearHeldMovementIfFinished(playerObj);
|
||||
@@ -1660,7 +1660,7 @@ static bool8 waterfall_4_wait_player_move_probably(struct Task *task, struct Obj
|
||||
task->data[0] = 3;
|
||||
return TRUE;
|
||||
}
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
DestroyTask(FindTaskIdByFunc(Task_UseWaterfall));
|
||||
FieldEffectActiveListRemove(FLDEFF_USE_WATERFALL);
|
||||
@@ -1702,7 +1702,7 @@ static bool8 DiveFieldEffect_Init(struct Task *task)
|
||||
|
||||
static bool8 DiveFieldEffect_ShowMon(struct Task *task)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gFieldEffectArguments[0] = task->data[15];
|
||||
FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT);
|
||||
task->data[0]++;
|
||||
@@ -1869,7 +1869,7 @@ static void FieldCB_LavaridgeGymB1FWarpExit(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
WarpFadeInScreen();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gFieldCallback = NULL;
|
||||
CreateTask(Task_LavaridgeGymB1FWarpExit, 0);
|
||||
}
|
||||
@@ -1922,7 +1922,7 @@ static bool8 LavaridgeGymB1FWarpExitEffect_4(struct Task *task, struct ObjectEve
|
||||
if (ObjectEventClearHeldMovementIfFinished(objectEvent))
|
||||
{
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnfreezeObjectEvents();
|
||||
DestroyTask(FindTaskIdByFunc(Task_LavaridgeGymB1FWarpExit));
|
||||
}
|
||||
@@ -2084,7 +2084,7 @@ static void (*const sEscapeRopeWarpOutEffectFuncs[])(struct Task *task) =
|
||||
|
||||
void StartEscapeRopeFieldEffect(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
CreateTask(Task_EscapeRopeWarpOut, 80);
|
||||
}
|
||||
@@ -2270,7 +2270,7 @@ static void FieldCallback_EscapeRopeExit(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
WarpFadeInScreen();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gFieldCallback = NULL;
|
||||
gObjectEvents[gPlayerAvatar.objectEventId].invisible = TRUE;
|
||||
@@ -2311,7 +2311,7 @@ static void EscapeRopeWarpInEffect_Spin(struct Task *task)
|
||||
{
|
||||
playerObj->invisible = FALSE;
|
||||
playerObj->fixedPriority = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnfreezeObjectEvents();
|
||||
DestroyTask(FindTaskIdByFunc(Task_EscapeRopeWarpIn));
|
||||
}
|
||||
@@ -2360,7 +2360,7 @@ static void Task_DoTeleportFieldEffect(u8 taskId)
|
||||
|
||||
static void TeleportFieldEffectTask1(struct Task *task)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
CameraObjectReset2();
|
||||
task->data[15] = GetPlayerFacingDirection();
|
||||
@@ -2447,7 +2447,7 @@ static void FieldCallback_TeleportIn(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
WarpFadeInScreen();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gFieldCallback = NULL;
|
||||
gObjectEvents[gPlayerAvatar.objectEventId].invisible = TRUE;
|
||||
@@ -2528,7 +2528,7 @@ static void TeleportInFieldEffectTask3(struct Task *task)
|
||||
task->data[1] = 8;
|
||||
if ((++task->data[2]) > 4 && task->data[14] == objectEvent->facingDirection)
|
||||
{
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
CameraObjectReset1();
|
||||
UnfreezeObjectEvents();
|
||||
DestroyTask(FindTaskIdByFunc(Task_DoTeleportInFieldEffect));
|
||||
@@ -2997,7 +2997,7 @@ static void Task_FldEffUseSurf(u8 taskId)
|
||||
|
||||
static void UseSurfEffect_1(struct Task *task)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_SURFING);
|
||||
@@ -3058,7 +3058,7 @@ static void UseSurfEffect_5(struct Task *task)
|
||||
ObjectEventSetHeldMovement(objectEvent, GetFaceDirectionMovementAction(objectEvent->movementDirection));
|
||||
SetSurfBlob_BobState(objectEvent->fieldEffectSpriteId, BOB_PLAYER_AND_MON);
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
FieldEffectActiveListRemove(FLDEFF_USE_SURF);
|
||||
DestroyTask(FindTaskIdByFunc(Task_FldEffUseSurf));
|
||||
SetHelpContext(HELPCONTEXT_SURFING);
|
||||
@@ -3093,7 +3093,7 @@ static void Task_FldEffUseVsSeeker(u8 taskId)
|
||||
|
||||
static void UseVsSeekerEffect_1(struct Task *task)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
task->data[0]++;
|
||||
|
||||
+37
-37
@@ -137,7 +137,7 @@ static void Task_ContinueScriptUnionRoom(u8 taskId)
|
||||
|
||||
void FieldCB_ContinueScriptUnionRoom(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
FadeInFromBlack();
|
||||
CreateTask(Task_ContinueScriptUnionRoom, 10);
|
||||
@@ -148,13 +148,13 @@ static void Task_ContinueScript(u8 taskId)
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
void FieldCB_ContinueScriptHandleMusic(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
FadeInFromBlack();
|
||||
CreateTask(Task_ContinueScript, 10);
|
||||
@@ -162,7 +162,7 @@ void FieldCB_ContinueScriptHandleMusic(void)
|
||||
|
||||
void FieldCB_ContinueScript(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FadeInFromBlack();
|
||||
CreateTask(Task_ContinueScript, 10);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ static void Task_ReturnToFieldCableLink(u8 taskId)
|
||||
case 2:
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
@@ -195,7 +195,7 @@ static void Task_ReturnToFieldCableLink(u8 taskId)
|
||||
|
||||
void FieldCB_ReturnToFieldCableLink(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
palette_bg_faded_fill_black();
|
||||
CreateTask(Task_ReturnToFieldCableLink, 10);
|
||||
@@ -221,7 +221,7 @@ static void Task_ReturnToFieldRecordMixing(u8 taskId)
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
StartSendingKeysToLink();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
@@ -230,7 +230,7 @@ static void Task_ReturnToFieldRecordMixing(u8 taskId)
|
||||
|
||||
void FieldCB_ReturnToFieldWirelessLink(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
palette_bg_faded_fill_black();
|
||||
CreateTask(Task_ReturnToFieldRecordMixing, 10);
|
||||
@@ -290,7 +290,7 @@ void FieldCB_DefaultWarpExit(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
SetUpWarpExitTask(FALSE);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
void FieldCB_WarpExitFadeFromBlack(void)
|
||||
@@ -298,7 +298,7 @@ void FieldCB_WarpExitFadeFromBlack(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
SetUpWarpExitTask(TRUE);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void FieldCB_TeleportWarpIn(void)
|
||||
@@ -308,7 +308,7 @@ static void FieldCB_TeleportWarpIn(void)
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
PlaySE(SE_WARP_OUT);
|
||||
CreateTask(Task_TeleportWarpIn, 10);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void Task_ExitDoor(u8 taskId)
|
||||
@@ -393,7 +393,7 @@ static void Task_ExitDoor(u8 taskId)
|
||||
break;
|
||||
case 4:
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
@@ -429,7 +429,7 @@ static void Task_ExitNonAnimDoor(u8 taskId)
|
||||
break;
|
||||
case 3:
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
@@ -441,14 +441,14 @@ static void Task_ExitNonDoor(u8 taskId)
|
||||
{
|
||||
case 0:
|
||||
FreezeObjectEvents();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gTasks[taskId].data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished())
|
||||
{
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
@@ -461,7 +461,7 @@ static void Task_TeleportWarpIn(u8 taskId)
|
||||
{
|
||||
case 0:
|
||||
FreezeObjectEvents();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
StartTeleportInPlayerAnim();
|
||||
gTasks[taskId].data[0]++;
|
||||
break;
|
||||
@@ -469,7 +469,7 @@ static void Task_TeleportWarpIn(u8 taskId)
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() && WaitTeleportInPlayerAnim() != TRUE)
|
||||
{
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
@@ -489,7 +489,7 @@ void FadeTransition_FadeInOnReturnToStartMenu(void)
|
||||
{
|
||||
FadeInFromBlack();
|
||||
CreateTask(Task_WaitFadeAndCreateStartMenuTask, 80);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
bool8 FieldCB_ReturnToFieldOpenStartMenu(void)
|
||||
@@ -502,7 +502,7 @@ static void Task_SafariZoneRanOutOfBalls(u8 taskId)
|
||||
{
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
}
|
||||
@@ -510,7 +510,7 @@ static void Task_SafariZoneRanOutOfBalls(u8 taskId)
|
||||
|
||||
void FieldCB_SafariZoneRanOutOfBalls(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
FadeInFromBlack();
|
||||
CreateTask(Task_SafariZoneRanOutOfBalls, 10);
|
||||
@@ -531,7 +531,7 @@ bool32 FieldFadeTransitionBackgroundEffectIsFinished(void)
|
||||
|
||||
void DoWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
TryFadeOutOldMapMusic();
|
||||
WarpFadeOutScreen();
|
||||
PlayRainStoppingSoundEffect();
|
||||
@@ -542,7 +542,7 @@ void DoWarp(void)
|
||||
|
||||
void DoDiveWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
TryFadeOutOldMapMusic();
|
||||
WarpFadeOutScreen();
|
||||
PlayRainStoppingSoundEffect();
|
||||
@@ -560,21 +560,21 @@ void DoStairWarp(u16 metatileBehavior, u16 delay)
|
||||
|
||||
void DoDoorWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gFieldCallback = FieldCB_DefaultWarpExit;
|
||||
CreateTask(Task_DoorWarp, 10);
|
||||
}
|
||||
|
||||
void DoTeleport2Warp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
CreateTask(Task_Teleport2Warp, 10);
|
||||
gFieldCallback = FieldCB_TeleportWarpIn;
|
||||
}
|
||||
|
||||
void DoUnionRoomWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gFieldCallback = FieldCB_DefaultWarpExit;
|
||||
CreateTask(Task_TeleportWarp, 10);
|
||||
}
|
||||
@@ -587,25 +587,25 @@ void DoFallWarp(void)
|
||||
|
||||
void DoEscalatorWarp(u8 metatileBehavior)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
StartEscalatorWarp(metatileBehavior, 10);
|
||||
}
|
||||
|
||||
void DoLavaridgeGymB1FWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
StartLavaridgeGymB1FWarp(10);
|
||||
}
|
||||
|
||||
void DoLavaridgeGym1FWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
StartLavaridgeGym1FWarp(10);
|
||||
}
|
||||
|
||||
void DoTeleportWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
TryFadeOutOldMapMusic();
|
||||
CreateTask(Task_TeleportWarp, 10);
|
||||
gFieldCallback = FieldCB_TeleportWarpIn;
|
||||
@@ -613,7 +613,7 @@ void DoTeleportWarp(void)
|
||||
|
||||
static void DoPortholeWarp(void) // Unused
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
WarpFadeOutScreen();
|
||||
CreateTask(Task_Teleport2Warp, 10);
|
||||
gFieldCallback = nullsub_60;
|
||||
@@ -625,7 +625,7 @@ static void Task_CableClubWarp(u8 taskId)
|
||||
switch (task->data[0])
|
||||
{
|
||||
case 0:
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
@@ -642,7 +642,7 @@ static void Task_CableClubWarp(u8 taskId)
|
||||
|
||||
void DoCableClubWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
TryFadeOutOldMapMusic();
|
||||
WarpFadeOutScreen();
|
||||
PlaySE(SE_EXIT);
|
||||
@@ -691,7 +691,7 @@ static void Task_Teleport2Warp(u8 taskId)
|
||||
{
|
||||
case 0:
|
||||
FreezeObjectEvents();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
@@ -713,7 +713,7 @@ static void Task_TeleportWarp(u8 taskId)
|
||||
{
|
||||
case 0:
|
||||
FreezeObjectEvents();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
PlaySE(SE_WARP_IN);
|
||||
StartTeleportWarpOutPlayerAnim();
|
||||
task->data[0]++;
|
||||
@@ -796,7 +796,7 @@ static void Task_StairWarp(u8 taskId)
|
||||
switch (data[0])
|
||||
{
|
||||
case 0:
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
CameraObjectReset2();
|
||||
data[0]++;
|
||||
@@ -898,14 +898,14 @@ static void Task_ExitStairs(u8 taskId)
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
CameraObjectReset1();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
WarpFadeInScreen();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
ExitStairsMovement(&data[1], &data[2], &data[3], &data[4], &data[5]);
|
||||
data[0]++;
|
||||
break;
|
||||
|
||||
+10
-10
@@ -1417,7 +1417,7 @@ static void Task_BumpBoulder(u8 taskId)
|
||||
|
||||
static bool8 DoBoulderInit(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
task->data[0]++;
|
||||
return FALSE;
|
||||
@@ -1453,7 +1453,7 @@ static bool8 DoBoulderFinish(struct Task *task, struct ObjectEvent *playerObject
|
||||
HandleBoulderFallThroughHole(strengthObject);
|
||||
HandleBoulderActivateVictoryRoadSwitch(strengthObject->currentCoords.x, strengthObject->currentCoords.y);
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(FindTaskIdByFunc(Task_BumpBoulder));
|
||||
}
|
||||
return FALSE;
|
||||
@@ -1518,7 +1518,7 @@ static bool8 PlayerAvatar_SecretBaseMatSpinStep0(struct Task *task, struct Objec
|
||||
task->data[0]++;
|
||||
task->data[1] = objectEvent->movementDirection;
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
PlaySE(SE_WARP_IN);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1564,7 +1564,7 @@ static bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task *task, struct Objec
|
||||
if (ObjectEventClearHeldMovementIfFinished(objectEvent))
|
||||
{
|
||||
QL_TryRecordPlayerStepWithDuration0(objectEvent, GetWalkSlowerMovementAction(GetOppositeDirection(task->data[1])));
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
DestroyTask(FindTaskIdByFunc(PlayerAvatar_DoSecretBaseMatSpin));
|
||||
}
|
||||
@@ -1575,7 +1575,7 @@ static void CreateStopSurfingTask(u8 direction)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
Overworld_ClearSavedMusic();
|
||||
Overworld_ChangeMusicToDefault();
|
||||
@@ -1591,7 +1591,7 @@ void CreateStopSurfingTask_NoMusicChange(u8 direction)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_SURFING;
|
||||
gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_ON_FOOT;
|
||||
@@ -1633,7 +1633,7 @@ static void Task_WaitStopSurfing(u8 taskId)
|
||||
ObjectEventSetGraphicsId(playerObjEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_GFX_NORMAL));
|
||||
QL_TryRecordPlayerStepWithDuration0(playerObjEvent, GetFaceDirectionMovementAction(playerObjEvent->facingDirection));
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnfreezeObjectEvents();
|
||||
DestroySprite(&gSprites[playerObjEvent->fieldEffectSpriteId]);
|
||||
DestroyTask(taskId);
|
||||
@@ -1696,7 +1696,7 @@ static void Task_Fishing(u8 taskId)
|
||||
|
||||
static bool8 Fishing1(struct Task *task)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
task->tStep++;
|
||||
return FALSE;
|
||||
@@ -1880,7 +1880,7 @@ static bool8 Fishing11(struct Task *task)
|
||||
if (task->tFrameCounter != 0)
|
||||
{
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
FishingWildEncounter(task->tFishingRod);
|
||||
DestroyTask(FindTaskIdByFunc(Task_Fishing));
|
||||
}
|
||||
@@ -1940,7 +1940,7 @@ static bool8 Fishing16(struct Task *task)
|
||||
if (!IsTextPrinterActive(0))
|
||||
{
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnfreezeObjectEvents();
|
||||
ClearDialogWindowAndFrame(0, TRUE);
|
||||
DestroyTask(FindTaskIdByFunc(Task_Fishing));
|
||||
|
||||
+2
-2
@@ -77,7 +77,7 @@ static void Task_TryFieldPoisonWhiteOut(u8 taskId)
|
||||
gSpecialVar_Result = TRUE;
|
||||
else
|
||||
gSpecialVar_Result = FALSE;
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ static void Task_TryFieldPoisonWhiteOut(u8 taskId)
|
||||
void TryFieldPoisonWhiteOut(void)
|
||||
{
|
||||
CreateTask(Task_TryFieldPoisonWhiteOut, 80);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
}
|
||||
|
||||
s32 DoPoisonFieldEffect(void)
|
||||
|
||||
@@ -154,7 +154,7 @@ static void sub_807EF7C(u8 taskId)
|
||||
{
|
||||
if (!FuncIsActiveTask(UpdateFlashLevelEffect))
|
||||
{
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ void AnimateFlash(u8 flashLevel)
|
||||
value = TRUE;
|
||||
sub_807EFC8(120, 80, sFlashLevelPixelRadii[curFlashLevel], sFlashLevelPixelRadii[flashLevel], value, 2);
|
||||
sub_807EFA4();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
void WriteFlashScanlineEffectBuffer(u8 flashLevel)
|
||||
@@ -221,7 +221,7 @@ static void Task_EnableScriptAfterMusicFade(u8 taskId)
|
||||
if (BGMusicStopped() == TRUE)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,14 +435,14 @@ static void Task_RushInjuredPokemonToCenter(u8 taskId)
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
ScriptContext1_SetupScript(EventScript_AfterWhiteOutHeal);
|
||||
ScriptContext_SetupScript(EventScript_AfterWhiteOutHeal);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
ScriptContext1_SetupScript(EventScript_AfterWhiteOutMomHeal);
|
||||
ScriptContext_SetupScript(EventScript_AfterWhiteOutMomHeal);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -452,7 +452,7 @@ void FieldCB_RushInjuredPokemonToCenter(void)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
palette_bg_faded_fill_black();
|
||||
taskId = CreateTask(Task_RushInjuredPokemonToCenter, 10);
|
||||
gTasks[taskId].data[0] = 0;
|
||||
|
||||
+12
-12
@@ -91,7 +91,7 @@ void ShowDiploma(void)
|
||||
{
|
||||
QuestLog_CutRecording();
|
||||
SetMainCallback2(CB2_ShowDiploma);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
void ForcePlayerOntoBike(void)
|
||||
@@ -497,7 +497,7 @@ static void Task_ShakeScreen(u8 taskId)
|
||||
static void Task_EndScreenShake(u8 taskId)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
#undef tYtrans
|
||||
@@ -1083,7 +1083,7 @@ static void Task_ElevatorShake(u8 taskId)
|
||||
{
|
||||
PlaySE(SE_DING_DONG);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
InstallCameraPanAheadCallback();
|
||||
}
|
||||
}
|
||||
@@ -1336,7 +1336,7 @@ static void Task_CreateScriptListMenu(u8 taskId)
|
||||
s32 mwidth;
|
||||
struct Task *task = &gTasks[taskId];
|
||||
u8 windowId;
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
if (gSpecialVar_0x8004 == LISTMENU_SILPHCO_FLOORS)
|
||||
sListMenuLastScrollPosition = sElevatorScroll;
|
||||
else
|
||||
@@ -1432,7 +1432,7 @@ static void Task_ListMenuHandleInput(u8 taskId)
|
||||
{
|
||||
Task_ListMenuRemoveScrollIndicatorArrowPair(taskId);
|
||||
task->func = Task_SuspendListMenu;
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1450,7 +1450,7 @@ static void Task_DestroyListMenu(u8 taskId)
|
||||
CopyWindowToVram(task->data[13], COPYWIN_GFX);
|
||||
RemoveWindow(task->data[13]);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
static void Task_SuspendListMenu(u8 taskId)
|
||||
@@ -1470,14 +1470,14 @@ void ReturnToListMenu(void)
|
||||
{
|
||||
u8 taskId = FindTaskIdByFunc(Task_SuspendListMenu);
|
||||
if (taskId == 0xFF)
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
else
|
||||
gTasks[taskId].data[6]++;
|
||||
}
|
||||
|
||||
static void Task_RedrawScrollArrowsAndWaitInput(u8 taskId)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Task_CreateMenuRemoveScrollIndicatorArrowPair(taskId);
|
||||
gTasks[taskId].func = Task_ListMenuHandleInput;
|
||||
}
|
||||
@@ -2317,7 +2317,7 @@ void CutMoveOpenDottedHoleDoor(void)
|
||||
DrawWholeMapView();
|
||||
PlaySE(SE_BANG);
|
||||
FlagSet(FLAG_USED_CUT_ON_RUIN_VALLEY_BRAILLE);
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static const u16 sDeoxysObjectPals[][16] = {
|
||||
@@ -2373,7 +2373,7 @@ static void Task_DoDeoxysTriangleInteraction(u8 taskId)
|
||||
if (FlagGet(FLAG_SYS_DEOXYS_AWAKENED) == TRUE)
|
||||
{
|
||||
gSpecialVar_Result = 3;
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
else
|
||||
@@ -2392,7 +2392,7 @@ static void Task_DoDeoxysTriangleInteraction(u8 taskId)
|
||||
{
|
||||
FlagSet(FLAG_SYS_DEOXYS_AWAKENED);
|
||||
gSpecialVar_Result = 2;
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
else
|
||||
@@ -2434,7 +2434,7 @@ static void Task_WaitDeoxysFieldEffect(u8 taskId)
|
||||
{
|
||||
if (!FieldEffectActiveListContains(FLDEFF_MOVE_DEOXYS_ROCK))
|
||||
{
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ static void Task_RunTimeBasedEvents(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
if (!ArePlayerFieldControlsLocked())
|
||||
{
|
||||
if (!QL_IS_PLAYBACK_STATE)
|
||||
{
|
||||
|
||||
@@ -315,7 +315,7 @@ static void UpdateDroughtBlend(u8 taskId)
|
||||
task->tState++;
|
||||
break;
|
||||
case 4:
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
|
||||
+3
-3
@@ -177,7 +177,7 @@ bool8 FldEff_UseCutOnGrass(void)
|
||||
static void FieldCallback_CutTree(void)
|
||||
{
|
||||
gFieldEffectArguments[0] = GetCursorSelectionMonId();
|
||||
ScriptContext1_SetupScript(EventScript_FldEffCut);
|
||||
ScriptContext_SetupScript(EventScript_FldEffCut);
|
||||
}
|
||||
|
||||
bool8 FldEff_UseCutOnTree(void)
|
||||
@@ -284,12 +284,12 @@ static void SpriteCallback_CutGrass_Cleanup(struct Sprite *sprite)
|
||||
FieldEffectStop(&gSprites[sCutGrassSpriteArrayPtr[0]], FLDEFF_CUT_GRASS);
|
||||
Free(sCutGrassSpriteArrayPtr);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void FieldMoveCallback_CutTree(void)
|
||||
{
|
||||
PlaySE(SE_M_CUT);
|
||||
FieldEffectActiveListRemove(FLDEFF_USE_CUT_ON_TREE);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
+1
-1
@@ -185,7 +185,7 @@ static void FldEff_UseFlash(void)
|
||||
{
|
||||
PlaySE(SE_M_REFLECT);
|
||||
FlagSet(FLAG_SYS_FLASH_ACTIVE);
|
||||
ScriptContext1_SetupScript(EventScript_FldEffFlash);
|
||||
ScriptContext_SetupScript(EventScript_FldEffFlash);
|
||||
}
|
||||
|
||||
// Map transition animatics
|
||||
|
||||
@@ -46,7 +46,7 @@ static void Task_FieldEffectShowMon_Init(u8 taskId)
|
||||
{
|
||||
u8 mapObjId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
mapObjId = gPlayerAvatar.objectEventId;
|
||||
if (!ObjectEventIsMovementOverridden(&gObjectEvents[mapObjId])
|
||||
@@ -117,7 +117,7 @@ bool8 SetUpFieldMove_RockSmash(void)
|
||||
static void sub_80C9A10(void)
|
||||
{
|
||||
gFieldEffectArguments[0] = GetCursorSelectionMonId();
|
||||
ScriptContext1_SetupScript(EventScript_FldEffRockSmash);
|
||||
ScriptContext_SetupScript(EventScript_FldEffRockSmash);
|
||||
}
|
||||
|
||||
bool8 FldEff_UseRockSmash(void)
|
||||
@@ -133,5 +133,5 @@ static void sub_80C9A60(void)
|
||||
{
|
||||
PlaySE(SE_M_ROCK_THROW);
|
||||
FieldEffectActiveListRemove(FLDEFF_USE_ROCK_SMASH);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ bool8 SetUpFieldMove_Strength(void)
|
||||
static void FieldCB_UseStrength(void)
|
||||
{
|
||||
gFieldEffectArguments[0] = GetCursorSelectionMonId();
|
||||
ScriptContext1_SetupScript(EventScript_FldEffStrength);
|
||||
ScriptContext_SetupScript(EventScript_FldEffStrength);
|
||||
}
|
||||
|
||||
bool8 FldEff_UseStrength(void)
|
||||
@@ -42,5 +42,5 @@ bool8 FldEff_UseStrength(void)
|
||||
static void ShowMonCB_UseStrength(void)
|
||||
{
|
||||
FieldEffectActiveListRemove(FLDEFF_USE_STRENGTH);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ static void FailSweetScentEncounter(u8 taskId)
|
||||
CpuFastCopy(sPlttBufferBak, gPlttBufferUnfaded, PLTT_SIZE);
|
||||
WeatherProcessingIdle();
|
||||
Free(sPlttBufferBak);
|
||||
ScriptContext1_SetupScript(EventScript_FailSweetScent);
|
||||
ScriptContext_SetupScript(EventScript_FailSweetScent);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ static void Task_WaitFadeAndSetCallback(u8 taskId)
|
||||
void HallOfFamePCBeginFade(void)
|
||||
{
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
CreateTask(Task_WaitFadeAndSetCallback, 0);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ void ReturnFromHallOfFamePC(void)
|
||||
|
||||
static void ReshowPCMenuAfterHallOfFamePC(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
CreatePCMenu();
|
||||
ScriptMenu_DisplayPCStartupPrompt();
|
||||
|
||||
+2
-2
@@ -2033,7 +2033,7 @@ bool8 UseRegisteredKeyItemOnField(void)
|
||||
{
|
||||
if (CheckBagHasItem(gSaveBlock1Ptr->registeredItem, 1) == TRUE)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
HandleEnforcedLookDirectionOnPlayerStopMoving();
|
||||
StopPlayerAvatar();
|
||||
@@ -2044,7 +2044,7 @@ bool8 UseRegisteredKeyItemOnField(void)
|
||||
}
|
||||
gSaveBlock1Ptr->registeredItem = ITEM_NONE;
|
||||
}
|
||||
ScriptContext1_SetupScript(EventScript_BagItemCanBeRegistered);
|
||||
ScriptContext_SetupScript(EventScript_BagItemCanBeRegistered);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -197,7 +197,7 @@ static void Task_ItemUse_CloseMessageBoxAndReturnToField(u8 taskId)
|
||||
ClearDialogWindowAndFrame(0, 1);
|
||||
DestroyTask(taskId);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
}
|
||||
|
||||
u8 CheckIfItemIsTMHMOrEvolutionStone(u16 itemId)
|
||||
@@ -218,7 +218,7 @@ static void sub_80A1184(void)
|
||||
static bool8 sub_80A1194(void)
|
||||
{
|
||||
FreezeObjectEvents();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FadeInFromBlack();
|
||||
CreateTask(sub_80A11C0, 10);
|
||||
gExitStairsMovementDisabled = FALSE;
|
||||
@@ -230,7 +230,7 @@ static void sub_80A11C0(u8 taskId)
|
||||
if (IsWeatherNotFadingIn() == TRUE)
|
||||
{
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
@@ -278,7 +278,7 @@ static void ItemUseOnFieldCB_Bicycle(u8 taskId)
|
||||
PlaySE(SE_BIKE_BELL);
|
||||
GetOnOffBike(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -151,7 +151,7 @@ static void Task_NoResponse_CleanUp(u8 taskId)
|
||||
{
|
||||
ClearDialogWindowAndFrame(0, TRUE);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ static void Task_ItemfinderResponseCleanUp(u8 taskId)
|
||||
DestroyArrowAndStarTiles();
|
||||
ClearDialogWindowAndFrame(0, TRUE);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
@@ -500,8 +500,8 @@ static void Task_ItemfinderUnderfootDigUpItem(u8 taskId)
|
||||
{
|
||||
DestroyArrowAndStarTiles();
|
||||
DestroyTask(taskId);
|
||||
ScriptContext1_SetupScript(EventScript_ItemfinderDigUpUnderfootItem);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(EventScript_ItemfinderDigUpUnderfootItem);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
#undef tStartSpriteId
|
||||
|
||||
+1
-1
@@ -366,7 +366,7 @@ static void VBlankCB_MoveRelearner(void)
|
||||
|
||||
void DisplayMoveTutorMenu(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
CreateTask(Task_InitMoveRelearnerMenu, 10);
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ void MapPreview_StartForestTransition(u8 mapsec)
|
||||
SetGpuRegBits(REG_OFFSET_WININ, WININ_WIN0_CLR | WININ_WIN1_CLR);
|
||||
SetGpuRegBits(REG_OFFSET_WINOUT, WINOUT_WIN01_CLR);
|
||||
gTasks[taskId].data[11] = MapPreview_CreateMapNameWindow(mapsec);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
u16 MapPreview_CreateMapNameWindow(u8 mapsec)
|
||||
|
||||
+1
-1
@@ -215,7 +215,7 @@ static u32 client_mainseq_4(struct mevent_client * svr)
|
||||
MEvent_ReceiveDistributionMon(svr->recvBuffer);
|
||||
break;
|
||||
case 17:
|
||||
MEventSetRamScript(svr->recvBuffer, 1000);
|
||||
InitRamScript_NoObjectEvent(svr->recvBuffer, 1000);
|
||||
break;
|
||||
case 18:
|
||||
memcpy(&gSaveBlock2Ptr->battleTower.ereaderTrainer, svr->recvBuffer, sizeof(struct BattleTowerEReaderTrainer));
|
||||
|
||||
@@ -145,7 +145,7 @@ bool8 MEScrCmd_setmsg(struct ScriptContext *ctx)
|
||||
bool8 MEScrCmd_runscript(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 *script = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
ScriptContext2_RunNewScript(script);
|
||||
RunScriptImmediately(script);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ void NewGameInitData(void)
|
||||
InitMEventData();
|
||||
SetAllRenewableItemFlags();
|
||||
WarpToPlayersRoom();
|
||||
ScriptContext2_RunNewScript(EventScript_ResetAllMapFlags);
|
||||
RunScriptImmediately(EventScript_ResetAllMapFlags);
|
||||
StringCopy(gSaveBlock1Ptr->rivalName, rivalName);
|
||||
ResetTrainerTowerResults();
|
||||
}
|
||||
|
||||
+40
-40
@@ -242,7 +242,7 @@ static const u16 sWhiteOutMoneyLossBadgeFlagIDs[] = {
|
||||
|
||||
static void DoWhiteOut(void)
|
||||
{
|
||||
ScriptContext2_RunNewScript(EventScript_ResetEliteFourEnd);
|
||||
RunScriptImmediately(EventScript_ResetEliteFourEnd);
|
||||
RemoveMoney(&gSaveBlock1Ptr->money, ComputeWhiteOutMoneyLoss());
|
||||
HealPlayerParty();
|
||||
Overworld_ResetStateAfterWhitingOut();
|
||||
@@ -1393,13 +1393,13 @@ static void DoCB1_Overworld(u16 newKeys, u16 heldKeys)
|
||||
FieldClearPlayerInput(&fieldInput);
|
||||
FieldGetPlayerInput(&fieldInput, newKeys, heldKeys);
|
||||
FieldInput_HandleCancelSignpost(&fieldInput);
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
if (!ArePlayerFieldControlsLocked())
|
||||
{
|
||||
if (ProcessPlayerFieldInput(&fieldInput) == TRUE)
|
||||
{
|
||||
if (gQuestLogPlaybackState == 2)
|
||||
sub_81127F8(&gInputToStoreInQuestLogMaybe);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
DismissMapNamePopup();
|
||||
}
|
||||
else
|
||||
@@ -1420,11 +1420,11 @@ static void DoCB1_Overworld_QuestLogPlayback(void)
|
||||
FieldClearPlayerInput(&fieldInput);
|
||||
fieldInput = gQuestLogFieldInput;
|
||||
FieldInput_HandleCancelSignpost(&fieldInput);
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
if (!ArePlayerFieldControlsLocked())
|
||||
{
|
||||
if (ProcessPlayerFieldInput(&fieldInput) == TRUE)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
DismissMapNamePopup();
|
||||
}
|
||||
else
|
||||
@@ -1452,7 +1452,7 @@ void CB1_Overworld(void)
|
||||
|
||||
static void OverworldBasic(void)
|
||||
{
|
||||
ScriptContext2_RunScript();
|
||||
ScriptContext_RunScript();
|
||||
RunTasks();
|
||||
AnimateSprites();
|
||||
CameraUpdate();
|
||||
@@ -1518,8 +1518,8 @@ void CB2_NewGame(void)
|
||||
NewGameInitData();
|
||||
ResetInitialPlayerAvatarState();
|
||||
PlayTimeCounter_Start();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
gFieldCallback = FieldCB_WarpExitFadeFromBlack;
|
||||
gFieldCallback2 = NULL;
|
||||
DoMapLoadLoop(&gMain.state);
|
||||
@@ -1539,8 +1539,8 @@ void CB2_WhiteOut(void)
|
||||
ResetSafariZoneFlag_();
|
||||
DoWhiteOut();
|
||||
SetInitialPlayerAvatarStateWithDirection(DIR_NORTH);
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
gFieldCallback = FieldCB_RushInjuredPokemonToCenter;
|
||||
val = 0;
|
||||
DoMapLoadLoop(&val);
|
||||
@@ -1554,8 +1554,8 @@ void CB2_WhiteOut(void)
|
||||
void CB2_LoadMap(void)
|
||||
{
|
||||
FieldClearVBlankHBlankCallbacks();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
SetMainCallback1(NULL);
|
||||
SetMainCallback2(CB2_DoChangeMap);
|
||||
gMain.savedCallback = CB2_LoadMap2;
|
||||
@@ -1634,8 +1634,8 @@ void CB2_ReturnToFieldFromMultiplayer(void)
|
||||
else
|
||||
gFieldCallback = FieldCB_ReturnToFieldCableLink;
|
||||
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
CB2_ReturnToField();
|
||||
}
|
||||
|
||||
@@ -1685,8 +1685,8 @@ void CB2_ContinueSavedGame(void)
|
||||
Overworld_ResetStateOnContinue();
|
||||
InitMapFromSavedGame();
|
||||
PlayTimeCounter_Start();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
gFieldCallback2 = NULL;
|
||||
gExitStairsMovementDisabled = TRUE;
|
||||
if (UseContinueGameWarp() == TRUE)
|
||||
@@ -1760,8 +1760,8 @@ static bool32 LoadMapInStepsLink(u8 *state)
|
||||
{
|
||||
case 0:
|
||||
InitOverworldBgs();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
@@ -2197,8 +2197,8 @@ void CB2_SetUpOverworldForQLPlaybackWithWarpExit(void)
|
||||
{
|
||||
FieldClearVBlankHBlankCallbacks();
|
||||
gGlobalFieldTintMode = QL_TINT_GRAYSCALE;
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
SetMainCallback1(NULL);
|
||||
SetMainCallback2(CB2_DoChangeMap);
|
||||
gMain.savedCallback = CB2_LoadMapForQLPlayback;
|
||||
@@ -2209,8 +2209,8 @@ void CB2_SetUpOverworldForQLPlayback(void)
|
||||
FieldClearVBlankHBlankCallbacks();
|
||||
gGlobalFieldTintMode = QL_TINT_GRAYSCALE;
|
||||
LoadSaveblockMapHeader();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
SetMainCallback1(NULL);
|
||||
SetMainCallback2(CB2_LoadMapForQLPlayback);
|
||||
}
|
||||
@@ -2317,7 +2317,7 @@ void CB2_EnterFieldFromQuestLog(void)
|
||||
Overworld_ResetStateOnContinue();
|
||||
InitMapFromSavedGame();
|
||||
PlayTimeCounter_Start();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext_Init();
|
||||
gExitStairsMovementDisabled = TRUE;
|
||||
if (UseContinueGameWarp() == TRUE)
|
||||
{
|
||||
@@ -2388,8 +2388,8 @@ static bool32 SetUpScrollSceneForCredits(u8 *state, u8 unused)
|
||||
sCreditsOverworld_CmdLength = sCreditsOverworld_Script[sCreditsOverworld_CmdIndex].unk_4;
|
||||
WarpIntoMap();
|
||||
gPaletteFade.bufferTransferDisabled = TRUE;
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
SetMainCallback1(NULL);
|
||||
gFieldCallback2 = FieldCB2_Credits_WaitFade;
|
||||
gMain.state = 0;
|
||||
@@ -2845,7 +2845,7 @@ static void ResetPlayerHeldKeys(u16 *keys)
|
||||
|
||||
static u16 KeyInterCB_SelfIdle(u32 key)
|
||||
{
|
||||
if (ScriptContext2_IsEnabled() == TRUE)
|
||||
if (ArePlayerFieldControlsLocked() == TRUE)
|
||||
return LINK_KEY_CODE_EMPTY;
|
||||
if (GetLinkRecvQueueLength() > 4)
|
||||
return LINK_KEY_CODE_HANDLE_RECV_QUEUE;
|
||||
@@ -2865,7 +2865,7 @@ static u16 KeyInterCB_Idle(u32 key)
|
||||
static u16 KeyInterCB_DeferToEventScript(u32 key)
|
||||
{
|
||||
u16 retVal;
|
||||
if (ScriptContext2_IsEnabled() == TRUE)
|
||||
if (ArePlayerFieldControlsLocked() == TRUE)
|
||||
{
|
||||
retVal = LINK_KEY_CODE_EMPTY;
|
||||
}
|
||||
@@ -2888,7 +2888,7 @@ static u16 KeyInterCB_DeferToRecvQueue(u32 key)
|
||||
else
|
||||
{
|
||||
retVal = LINK_KEY_CODE_IDLE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
SetKeyInterceptCallback(KeyInterCB_Idle);
|
||||
}
|
||||
return retVal;
|
||||
@@ -2905,7 +2905,7 @@ static u16 KeyInterCB_DeferToSendQueue(u32 key)
|
||||
else
|
||||
{
|
||||
retVal = LINK_KEY_CODE_IDLE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
SetKeyInterceptCallback(KeyInterCB_Idle);
|
||||
}
|
||||
return retVal;
|
||||
@@ -2958,7 +2958,7 @@ static u16 KeyInterCB_WaitForPlayersToExit(u32 keyOrPlayerId)
|
||||
CheckRfuKeepAliveTimer();
|
||||
if (AreAllPlayersInLinkState(PLAYER_LINK_STATE_EXITING_ROOM) == TRUE)
|
||||
{
|
||||
ScriptContext1_SetupScript(CableClub_EventScript_DoLinkRoomExit);
|
||||
ScriptContext_SetupScript(CableClub_EventScript_DoLinkRoomExit);
|
||||
SetKeyInterceptCallback(KeyInterCB_SendNothing);
|
||||
}
|
||||
return LINK_KEY_CODE_EMPTY;
|
||||
@@ -3136,41 +3136,41 @@ static u16 GetDirectionForEventScript(const u8 *script)
|
||||
|
||||
static void InitLinkPlayerQueueScript(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void InitLinkRoomStartMenuScript(void)
|
||||
{
|
||||
PlaySE(SE_WIN_OPEN);
|
||||
ShowStartMenu();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void RunInteractLocalPlayerScript(const u8 *script)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ScriptContext1_SetupScript(script);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(script);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void CreateConfirmLeaveTradeRoomPrompt(void)
|
||||
{
|
||||
PlaySE(SE_WIN_OPEN);
|
||||
ScriptContext1_SetupScript(TradeCenter_ConfirmLeaveRoom);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(TradeCenter_ConfirmLeaveRoom);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void InitMenuBasedScript(const u8 *script)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ScriptContext1_SetupScript(script);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(script);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void RunTerminateLinkScript(void)
|
||||
{
|
||||
ScriptContext1_SetupScript(TradeCenter_TerminateLink);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(TradeCenter_TerminateLink);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
bool32 Overworld_LinkRecvQueueLengthMoreThan2(void)
|
||||
|
||||
+2
-2
@@ -6368,7 +6368,7 @@ static void Task_PartyMenuWaitForFade(u8 taskId)
|
||||
if (IsWeatherNotFadingIn())
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
ScriptContext2_Disable();
|
||||
EnableBothScriptContexts();
|
||||
UnlockPlayerFieldControls();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ void ChoosePartyMon(void)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
taskId = CreateTask(sub_80BF97C, 10);
|
||||
gTasks[taskId].data[0] = PARTY_MENU_TYPE_CHOOSE_MON;
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
|
||||
@@ -25,7 +25,7 @@ void SelectMoveTutorMon(void)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
taskId = CreateTask(sub_80BF97C, 10);
|
||||
gTasks[taskId].data[0] = PARTY_MENU_TYPE_MOVE_RELEARNER;
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
|
||||
|
||||
+2
-2
@@ -257,9 +257,9 @@ static void Task_PlayerPcMailbox(u8 taskId)
|
||||
static void Task_PlayerPcTurnOff(u8 taskId)
|
||||
{
|
||||
if (gPlayerPcMenuManager.notInRoom == FALSE)
|
||||
ScriptContext1_SetupScript(EventScript_PalletTown_PlayersHouse_2F_ShutDownPC);
|
||||
ScriptContext_SetupScript(EventScript_PalletTown_PlayersHouse_2F_ShutDownPC);
|
||||
else
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -4535,7 +4535,7 @@ static void Task_ShowPokemonJumpRecords(u8 taskId)
|
||||
{
|
||||
RemoveWindow(tWindowId);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -300,8 +300,8 @@ static void Task_PCMainMenu(u8 taskId)
|
||||
case OPTION_EXIT:
|
||||
ClearStdWindowAndFrame(0, TRUE);
|
||||
ClearStdWindowAndFrame(task->tWindowId, TRUE);
|
||||
ScriptContext2_Disable();
|
||||
EnableBothScriptContexts();
|
||||
UnlockPlayerFieldControls();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
default:
|
||||
@@ -374,7 +374,7 @@ void ShowPokemonStorageSystemPC(void)
|
||||
u8 taskId = CreateTask(Task_PCMainMenu, 80);
|
||||
gTasks[taskId].tState = 0;
|
||||
gTasks[taskId].tSelectedOption = 0;
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void FieldTask_ReturnToPcMenu(void)
|
||||
|
||||
+10
-10
@@ -256,7 +256,7 @@ static void QLogCB_Playback(void)
|
||||
else
|
||||
{
|
||||
sQuestLogCurrentScene.sceneEndMode = 2;
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
QuestLog_BeginFadeAtEndOfScene(0);
|
||||
}
|
||||
}
|
||||
@@ -791,7 +791,7 @@ static void QuestLog_AdvancePlayhead(void)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
if (++sCurrentSceneNum < QUEST_LOG_SCENE_COUNT && gSaveBlock1Ptr->questLog[sCurrentSceneNum].startType != 0)
|
||||
{
|
||||
sNumScenes--;
|
||||
@@ -1051,7 +1051,7 @@ static void QuestLog_WaitFadeAndCancelPlayback(void)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
for (sCurrentSceneNum = sCurrentSceneNum; sCurrentSceneNum < QUEST_LOG_SCENE_COUNT; sCurrentSceneNum++)
|
||||
{
|
||||
if (gSaveBlock1Ptr->questLog[sCurrentSceneNum].startType == 0)
|
||||
@@ -1087,12 +1087,12 @@ static void Task_FinalScene_WaitFade(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
if (ScriptContext2_IsEnabled() != TRUE)
|
||||
if (ArePlayerFieldControlsLocked() != TRUE)
|
||||
{
|
||||
FreezeObjectEvents();
|
||||
HandleEnforcedLookDirectionOnPlayerStopMoving();
|
||||
StopPlayerAvatar();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
task->func = Task_QuestLogScene_SavedGame;
|
||||
}
|
||||
}
|
||||
@@ -1113,7 +1113,7 @@ static void Task_QuestLogScene_SavedGame(u8 taskId)
|
||||
task->data[1] = 0;
|
||||
task->func = Task_WaitAtEndOfQuestLog;
|
||||
FreezeObjectEvents();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1179,7 +1179,7 @@ static void Task_EndQuestLog(u8 taskId)
|
||||
Free(sPalettesBackup);
|
||||
sQuestLogCurrentScene = (struct UnkStruct_203AE94){};
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
gTextFlags.autoScroll = FALSE;
|
||||
gGlobalFieldTintMode = QL_TINT_NONE;
|
||||
DisableWildEncounters(FALSE);
|
||||
@@ -1417,7 +1417,7 @@ void sub_81127F8(struct FieldInput * a0)
|
||||
sCurQuestLogEntry[sQuestLogCursor].mapGroup = r2 >> 16;
|
||||
sCurQuestLogEntry[sQuestLogCursor].animId = r2 >> 24; // always 0
|
||||
sQuestLogCursor++;
|
||||
if (ScriptContext2_IsEnabled())
|
||||
if (ArePlayerFieldControlsLocked())
|
||||
sNextStepDelay = TRUE;
|
||||
else
|
||||
sNextStepDelay = FALSE;
|
||||
@@ -1590,7 +1590,7 @@ void sub_8112B3C(void)
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (ScriptContext2_IsEnabled() != TRUE)
|
||||
if (ArePlayerFieldControlsLocked() != TRUE)
|
||||
{
|
||||
sNextStepDelay++;
|
||||
if (sQuestLogCursor >= sNumEventsInLogEntry)
|
||||
@@ -1627,7 +1627,7 @@ u8 sub_8112CAC(void)
|
||||
|
||||
static bool8 RecordHeadAtEndOfEntryOrScriptContext2Enabled(void)
|
||||
{
|
||||
if (sQuestLogCursor >= sNumEventsInLogEntry || ScriptContext2_IsEnabled() == TRUE)
|
||||
if (sQuestLogCursor >= sNumEventsInLogEntry || ArePlayerFieldControlsLocked() == TRUE)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ static void QL_GfxTransition_Fish(void)
|
||||
if (gQuestLogPlaybackState == 1 || gQuestLogPlaybackState == 3)
|
||||
{
|
||||
u8 taskId;
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
taskId = CreateTask(Task_QLFishMovement, 0xFF);
|
||||
gTasks[taskId].data[0] = 0;
|
||||
@@ -129,7 +129,7 @@ static void Task_QLFishMovement(u8 taskId)
|
||||
ObjectEventTurn(objectEvent, objectEvent->movementDirection);
|
||||
sprite->x2 = 0;
|
||||
sprite->y2 = 0;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
@@ -166,7 +166,7 @@ static void Task_QLVSSeekerMovement(u8 taskId)
|
||||
if (!FieldEffectActiveListContains(FLDEFF_USE_VS_SEEKER))
|
||||
{
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ static bool32 TryReleaseUnionRoomPlayerObjectEvent(u32 playerIdx)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
if (!ArePlayerFieldControlsLocked())
|
||||
{
|
||||
UnfreezeObjectEvent(object);
|
||||
}
|
||||
|
||||
+5
-5
@@ -46,7 +46,7 @@ bool8 SafariZoneTakeStep(void)
|
||||
gSafariZoneStepCounter--;
|
||||
if (gSafariZoneStepCounter == 0)
|
||||
{
|
||||
ScriptContext1_SetupScript(SafariZone_EventScript_TimesUp);
|
||||
ScriptContext_SetupScript(SafariZone_EventScript_TimesUp);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -54,7 +54,7 @@ bool8 SafariZoneTakeStep(void)
|
||||
|
||||
void SafariZoneRetirePrompt(void)
|
||||
{
|
||||
ScriptContext1_SetupScript(SafariZone_EventScript_RetirePrompt);
|
||||
ScriptContext_SetupScript(SafariZone_EventScript_RetirePrompt);
|
||||
}
|
||||
|
||||
void CB2_EndSafariBattle(void)
|
||||
@@ -65,15 +65,15 @@ void CB2_EndSafariBattle(void)
|
||||
}
|
||||
else if (gBattleOutcome == B_OUTCOME_NO_SAFARI_BALLS)
|
||||
{
|
||||
ScriptContext2_RunNewScript(SafariZone_EventScript_OutOfBallsMidBattle);
|
||||
RunScriptImmediately(SafariZone_EventScript_OutOfBallsMidBattle);
|
||||
WarpIntoMap();
|
||||
gFieldCallback = FieldCB_SafariZoneRanOutOfBalls;
|
||||
SetMainCallback2(CB2_LoadMap);
|
||||
}
|
||||
else if (gBattleOutcome == B_OUTCOME_CAUGHT)
|
||||
{
|
||||
ScriptContext1_SetupScript(SafariZone_EventScript_OutOfBalls);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_SetupScript(SafariZone_EventScript_OutOfBalls);
|
||||
ScriptContext_Stop();
|
||||
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
|
||||
}
|
||||
}
|
||||
|
||||
+20
-20
@@ -125,7 +125,7 @@ bool8 ScrCmd_callnative(struct ScriptContext * ctx)
|
||||
|
||||
bool8 ScrCmd_waitstate(struct ScriptContext * ctx)
|
||||
{
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ bool8 ScrCmd_callstd_if(struct ScriptContext * ctx)
|
||||
|
||||
bool8 ScrCmd_returnram(struct ScriptContext * ctx)
|
||||
{
|
||||
ScriptJump(ctx, gRAMScriptPtr);
|
||||
ScriptJump(ctx, gRamScriptRetAddr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ bool8 ScrCmd_trywondercardscript(struct ScriptContext * ctx)
|
||||
const u8 * script = GetSavedRamScriptIfValid();
|
||||
if (script != NULL)
|
||||
{
|
||||
gRAMScriptPtr = ctx->scriptPtr;
|
||||
gRamScriptRetAddr = ctx->scriptPtr;
|
||||
ScriptJump(ctx, script);
|
||||
}
|
||||
return FALSE;
|
||||
@@ -604,7 +604,7 @@ bool8 ScrCmd_setworldmapflag(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_animateflash(struct ScriptContext * ctx)
|
||||
{
|
||||
AnimateFlash(ScriptReadByte(ctx));
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1414,7 +1414,7 @@ bool8 ScrCmd_yesnobox(struct ScriptContext * ctx)
|
||||
|
||||
if (ScriptMenu_YesNo(left, top) == TRUE)
|
||||
{
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@@ -1432,7 +1432,7 @@ bool8 ScrCmd_multichoice(struct ScriptContext * ctx)
|
||||
|
||||
if (ScriptMenu_Multichoice(left, top, multichoiceId, ignoreBPress) == TRUE)
|
||||
{
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@@ -1451,7 +1451,7 @@ bool8 ScrCmd_multichoicedefault(struct ScriptContext * ctx)
|
||||
|
||||
if (ScriptMenu_MultichoiceWithDefault(left, top, multichoiceId, ignoreBPress, defaultChoice) == TRUE)
|
||||
{
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@@ -1481,7 +1481,7 @@ bool8 ScrCmd_multichoicegrid(struct ScriptContext * ctx)
|
||||
|
||||
if (ScriptMenu_MultichoiceGrid(left, top, multichoiceId, ignoreBPress, numColumns) == TRUE)
|
||||
{
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@@ -1510,7 +1510,7 @@ bool8 ScrCmd_drawboxtext(struct ScriptContext * ctx)
|
||||
|
||||
/*if (Multichoice(left, top, multichoiceId, ignoreBPress) == TRUE)
|
||||
{
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}*/
|
||||
return FALSE;
|
||||
@@ -1548,7 +1548,7 @@ bool8 ScrCmd_showcontestpainting(struct ScriptContext * ctx)
|
||||
SetContestWinnerForPainting(contestWinnerId);
|
||||
|
||||
ShowContestPainting();
|
||||
ScriptContext1_Stop()
|
||||
ScriptContext_Stop()
|
||||
return TRUE;
|
||||
*/
|
||||
return FALSE;
|
||||
@@ -1932,7 +1932,7 @@ bool8 ScrCmd_setwildbattle(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_dowildbattle(struct ScriptContext * ctx)
|
||||
{
|
||||
StartScriptedWildBattle();
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1941,7 +1941,7 @@ bool8 ScrCmd_pokemart(struct ScriptContext * ctx)
|
||||
const void *ptr = (void *)ScriptReadWord(ctx);
|
||||
|
||||
CreatePokemartMenu(ptr);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1950,7 +1950,7 @@ bool8 ScrCmd_pokemartdecoration(struct ScriptContext * ctx)
|
||||
const void *ptr = (void *)ScriptReadWord(ctx);
|
||||
|
||||
CreateDecorationShop1Menu(ptr);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1960,7 +1960,7 @@ bool8 ScrCmd_pokemartdecoration2(struct ScriptContext * ctx)
|
||||
const void *ptr = (void *)ScriptReadWord(ctx);
|
||||
|
||||
CreateDecorationShop2Menu(ptr);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1969,7 +1969,7 @@ bool8 ScrCmd_playslotmachine(struct ScriptContext * ctx)
|
||||
u8 slotMachineIndex = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
PlaySlotMachine(slotMachineIndex, CB2_ReturnToFieldContinueScriptPlayMapMusic);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1997,7 +1997,7 @@ bool8 ScrCmd_getpokenewsactive(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_choosecontestmon(struct ScriptContext * ctx)
|
||||
{
|
||||
// ChooseContestMon();
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2005,7 +2005,7 @@ bool8 ScrCmd_choosecontestmon(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_startcontest(struct ScriptContext * ctx)
|
||||
{
|
||||
// StartContest();
|
||||
// ScriptContext1_Stop();
|
||||
// ScriptContext_Stop();
|
||||
// return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
@@ -2013,7 +2013,7 @@ bool8 ScrCmd_startcontest(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_showcontestresults(struct ScriptContext * ctx)
|
||||
{
|
||||
// ShowContestResults();
|
||||
// ScriptContext1_Stop();
|
||||
// ScriptContext_Stop();
|
||||
// return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
@@ -2021,7 +2021,7 @@ bool8 ScrCmd_showcontestresults(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_contestlinktransfer(struct ScriptContext * ctx)
|
||||
{
|
||||
// ContestLinkTransfer(gSpecialVar_ContestCategory);
|
||||
// ScriptContext1_Stop();
|
||||
// ScriptContext_Stop();
|
||||
// return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
@@ -2176,7 +2176,7 @@ bool8 ScrCmd_addelevmenuitem(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_showelevmenu(struct ScriptContext * ctx)
|
||||
{
|
||||
/*ScriptShowElevatorMenu();
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;*/
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+109
-81
@@ -3,32 +3,35 @@
|
||||
#include "event_data.h"
|
||||
#include "quest_log.h"
|
||||
#include "constants/maps.h"
|
||||
|
||||
#define RAM_SCRIPT_MAGIC 51
|
||||
#define SCRIPT_STACK_SIZE 20
|
||||
|
||||
#include "constants/map_scripts.h"
|
||||
|
||||
extern void ResetContextNpcTextColor(void); // field_specials
|
||||
extern u16 CalcCRC16WithTable(u8 *data, int length); // util
|
||||
extern bool32 ValidateReceivedWonderCard(void); // mevent
|
||||
|
||||
enum
|
||||
{
|
||||
#define RAM_SCRIPT_MAGIC 51
|
||||
|
||||
enum {
|
||||
SCRIPT_MODE_STOPPED,
|
||||
SCRIPT_MODE_BYTECODE,
|
||||
SCRIPT_MODE_NATIVE,
|
||||
};
|
||||
|
||||
EWRAM_DATA u8 gWalkAwayFromSignInhibitTimer = 0;
|
||||
EWRAM_DATA const u8 *gRAMScriptPtr = NULL;
|
||||
enum {
|
||||
CONTEXT_RUNNING,
|
||||
CONTEXT_WAITING,
|
||||
CONTEXT_SHUTDOWN,
|
||||
};
|
||||
|
||||
// iwram bss
|
||||
static u8 sScriptContext1Status;
|
||||
EWRAM_DATA u8 gWalkAwayFromSignInhibitTimer = 0;
|
||||
EWRAM_DATA const u8 *gRamScriptRetAddr = NULL;
|
||||
|
||||
static u8 sGlobalScriptContextStatus;
|
||||
static u32 sUnusedVariable1;
|
||||
static struct ScriptContext sScriptContext1;
|
||||
static struct ScriptContext sGlobalScriptContext;
|
||||
static u32 sUnusedVariable2;
|
||||
static struct ScriptContext sScriptContext2;
|
||||
static bool8 sScriptContext2Enabled;
|
||||
static struct ScriptContext sImmediateScriptContext;
|
||||
static bool8 sLockFieldControls;
|
||||
static u8 sMsgBoxWalkawayDisabled;
|
||||
static u8 sMsgBoxIsCancelable;
|
||||
static u8 sQuestLogInput;
|
||||
@@ -50,10 +53,10 @@ void InitScriptContext(struct ScriptContext *ctx, void *cmdTable, void *cmdTable
|
||||
ctx->cmdTable = cmdTable;
|
||||
ctx->cmdTableEnd = cmdTableEnd;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
for (i = 0; i < (int)ARRAY_COUNT(ctx->data); i++)
|
||||
ctx->data[i] = 0;
|
||||
|
||||
for (i = 0; i < SCRIPT_STACK_SIZE; i++)
|
||||
for (i = 0; i < (int)ARRAY_COUNT(ctx->stack); i++)
|
||||
ctx->stack[i] = 0;
|
||||
}
|
||||
|
||||
@@ -90,6 +93,8 @@ bool8 RunScriptCommand(struct ScriptContext *ctx)
|
||||
case SCRIPT_MODE_STOPPED:
|
||||
return FALSE;
|
||||
case SCRIPT_MODE_NATIVE:
|
||||
// Try to call a function in C
|
||||
// Continue to bytecode if no function or it returns TRUE
|
||||
if (ctx->nativePtr)
|
||||
{
|
||||
if (ctx->nativePtr() == TRUE)
|
||||
@@ -97,6 +102,7 @@ bool8 RunScriptCommand(struct ScriptContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
ctx->mode = SCRIPT_MODE_BYTECODE;
|
||||
// fallthrough
|
||||
case SCRIPT_MODE_BYTECODE:
|
||||
while (1)
|
||||
{
|
||||
@@ -133,9 +139,9 @@ bool8 RunScriptCommand(struct ScriptContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
u8 ScriptPush(struct ScriptContext *ctx, const u8 *ptr)
|
||||
static u8 ScriptPush(struct ScriptContext *ctx, const u8 *ptr)
|
||||
{
|
||||
if (ctx->stackDepth + 1 >= SCRIPT_STACK_SIZE)
|
||||
if (ctx->stackDepth + 1 >= (int)ARRAY_COUNT(ctx->stack))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -147,7 +153,7 @@ u8 ScriptPush(struct ScriptContext *ctx, const u8 *ptr)
|
||||
}
|
||||
}
|
||||
|
||||
const u8 *ScriptPop(struct ScriptContext *ctx)
|
||||
static const u8 *ScriptPop(struct ScriptContext *ctx)
|
||||
{
|
||||
if (ctx->stackDepth == 0)
|
||||
return NULL;
|
||||
@@ -188,19 +194,19 @@ u32 ScriptReadWord(struct ScriptContext *ctx)
|
||||
return (((((value3 << 8) + value2) << 8) + value1) << 8) + value0;
|
||||
}
|
||||
|
||||
void ScriptContext2_Enable(void)
|
||||
void LockPlayerFieldControls(void)
|
||||
{
|
||||
sScriptContext2Enabled = TRUE;
|
||||
sLockFieldControls = TRUE;
|
||||
}
|
||||
|
||||
void ScriptContext2_Disable(void)
|
||||
void UnlockPlayerFieldControls(void)
|
||||
{
|
||||
sScriptContext2Enabled = FALSE;
|
||||
sLockFieldControls = FALSE;
|
||||
}
|
||||
|
||||
bool8 ScriptContext2_IsEnabled(void)
|
||||
bool8 ArePlayerFieldControlsLocked(void)
|
||||
{
|
||||
return sScriptContext2Enabled;
|
||||
return sLockFieldControls;
|
||||
}
|
||||
|
||||
void SetQuestLogInputIsDpadFlag(void)
|
||||
@@ -294,70 +300,86 @@ void ResetFacingNpcOrSignPostVars(void)
|
||||
MsgSetNotSignPost();
|
||||
}
|
||||
|
||||
bool8 ScriptContext1_IsScriptSetUp(void)
|
||||
// The ScriptContext_* functions work with the primary script context,
|
||||
// which yields control back to native code should the script make a wait call.
|
||||
|
||||
// Checks if the global script context is able to be run right now.
|
||||
bool8 ScriptContext_IsEnabled(void)
|
||||
{
|
||||
if (sScriptContext1Status == 0)
|
||||
if (sGlobalScriptContextStatus == CONTEXT_RUNNING)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void ScriptContext1_Init(void)
|
||||
// Re-initializes the global script context to zero.
|
||||
void ScriptContext_Init(void)
|
||||
{
|
||||
InitScriptContext(&sScriptContext1, gScriptCmdTable, gScriptCmdTableEnd);
|
||||
sScriptContext1Status = 2;
|
||||
InitScriptContext(&sGlobalScriptContext, gScriptCmdTable, gScriptCmdTableEnd);
|
||||
sGlobalScriptContextStatus = CONTEXT_SHUTDOWN;
|
||||
}
|
||||
|
||||
bool8 ScriptContext2_RunScript(void)
|
||||
// Runs the script until the script makes a wait* call, then returns true if
|
||||
// there's more script to run, or false if the script has hit the end.
|
||||
// This function also returns false if the context is finished
|
||||
// or waiting (after a call to _Stop)
|
||||
bool8 ScriptContext_RunScript(void)
|
||||
{
|
||||
if (sScriptContext1Status == 2)
|
||||
return 0;
|
||||
if (sGlobalScriptContextStatus == CONTEXT_SHUTDOWN)
|
||||
return FALSE;
|
||||
|
||||
if (sScriptContext1Status == 1)
|
||||
return 0;
|
||||
if (sGlobalScriptContextStatus == CONTEXT_WAITING)
|
||||
return FALSE;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
|
||||
if (!RunScriptCommand(&sScriptContext1))
|
||||
if (!RunScriptCommand(&sGlobalScriptContext))
|
||||
{
|
||||
sScriptContext1Status = 2;
|
||||
ScriptContext2_Disable();
|
||||
return 0;
|
||||
sGlobalScriptContextStatus = CONTEXT_SHUTDOWN;
|
||||
UnlockPlayerFieldControls();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void ScriptContext1_SetupScript(const u8 *ptr)
|
||||
// Sets up a new script in the global context and enables the context
|
||||
void ScriptContext_SetupScript(const u8 *ptr)
|
||||
{
|
||||
ClearMsgBoxCancelableState();
|
||||
EnableMsgBoxWalkaway();
|
||||
ClearQuestLogInputIsDpadFlag();
|
||||
InitScriptContext(&sScriptContext1, gScriptCmdTable, gScriptCmdTableEnd);
|
||||
SetupBytecodeScript(&sScriptContext1, ptr);
|
||||
ScriptContext2_Enable();
|
||||
sScriptContext1Status = 0;
|
||||
|
||||
InitScriptContext(&sGlobalScriptContext, gScriptCmdTable, gScriptCmdTableEnd);
|
||||
SetupBytecodeScript(&sGlobalScriptContext, ptr);
|
||||
LockPlayerFieldControls();
|
||||
sGlobalScriptContextStatus = CONTEXT_RUNNING;
|
||||
}
|
||||
|
||||
void ScriptContext1_Stop(void)
|
||||
// Puts the script into waiting mode; usually called from a wait* script command.
|
||||
void ScriptContext_Stop(void)
|
||||
{
|
||||
sScriptContext1Status = 1;
|
||||
sGlobalScriptContextStatus = CONTEXT_WAITING;
|
||||
}
|
||||
|
||||
void EnableBothScriptContexts(void)
|
||||
// Puts the script into running mode.
|
||||
void ScriptContext_Enable(void)
|
||||
{
|
||||
sScriptContext1Status = 0;
|
||||
ScriptContext2_Enable();
|
||||
sGlobalScriptContextStatus = CONTEXT_RUNNING;
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
void ScriptContext2_RunNewScript(const u8 *ptr)
|
||||
// Sets up and runs a script in its own context immediately. The script will be
|
||||
// finished when this function returns. Used mainly by all of the map header
|
||||
// scripts (except the frame table scripts).
|
||||
void RunScriptImmediately(const u8 *ptr)
|
||||
{
|
||||
InitScriptContext(&sScriptContext2, &gScriptCmdTable, &gScriptCmdTableEnd);
|
||||
SetupBytecodeScript(&sScriptContext2, ptr);
|
||||
while (RunScriptCommand(&sScriptContext2) == TRUE);
|
||||
InitScriptContext(&sImmediateScriptContext, &gScriptCmdTable, &gScriptCmdTableEnd);
|
||||
SetupBytecodeScript(&sImmediateScriptContext, ptr);
|
||||
while (RunScriptCommand(&sImmediateScriptContext) == TRUE);
|
||||
}
|
||||
|
||||
u8 *mapheader_get_tagged_pointer(u8 tag)
|
||||
static u8 *MapHeaderGetScriptTable(u8 tag)
|
||||
{
|
||||
const u8 *mapScripts = gMapHeader.mapScripts;
|
||||
|
||||
@@ -377,16 +399,16 @@ u8 *mapheader_get_tagged_pointer(u8 tag)
|
||||
}
|
||||
}
|
||||
|
||||
void mapheader_run_script_by_tag(u8 tag)
|
||||
static void MapHeaderRunScriptType(u8 tag)
|
||||
{
|
||||
u8 *ptr = mapheader_get_tagged_pointer(tag);
|
||||
u8 *ptr = MapHeaderGetScriptTable(tag);
|
||||
if (ptr != NULL)
|
||||
ScriptContext2_RunNewScript(ptr);
|
||||
RunScriptImmediately(ptr);
|
||||
}
|
||||
|
||||
u8 *mapheader_get_first_match_from_tagged_ptr_list(u8 tag)
|
||||
static u8 *MapHeaderCheckScriptTable(u8 tag)
|
||||
{
|
||||
u8 *ptr = mapheader_get_tagged_pointer(tag);
|
||||
u8 *ptr = MapHeaderGetScriptTable(tag);
|
||||
|
||||
if (ptr == NULL)
|
||||
return NULL;
|
||||
@@ -395,64 +417,70 @@ u8 *mapheader_get_first_match_from_tagged_ptr_list(u8 tag)
|
||||
{
|
||||
u16 varIndex1;
|
||||
u16 varIndex2;
|
||||
varIndex1 = ptr[0] | (ptr[1] << 8);
|
||||
|
||||
// Read first var (or .2byte terminal value)
|
||||
varIndex1 = T1_READ_16(ptr);
|
||||
if (!varIndex1)
|
||||
return NULL;
|
||||
return NULL; // Reached end of table
|
||||
ptr += 2;
|
||||
varIndex2 = ptr[0] | (ptr[1] << 8);
|
||||
|
||||
// Read second var
|
||||
varIndex2 = T1_READ_16(ptr);
|
||||
ptr += 2;
|
||||
|
||||
// Run map script if vars are equal
|
||||
if (VarGet(varIndex1) == VarGet(varIndex2))
|
||||
return (u8 *)(ptr[0] + (ptr[1] << 8) + (ptr[2] << 16) + (ptr[3] << 24));
|
||||
return T2_READ_PTR(ptr);
|
||||
ptr += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void RunOnLoadMapScript(void)
|
||||
{
|
||||
mapheader_run_script_by_tag(1);
|
||||
MapHeaderRunScriptType(MAP_SCRIPT_ON_LOAD);
|
||||
}
|
||||
|
||||
void RunOnTransitionMapScript(void)
|
||||
{
|
||||
mapheader_run_script_by_tag(3);
|
||||
MapHeaderRunScriptType(MAP_SCRIPT_ON_TRANSITION);
|
||||
}
|
||||
|
||||
void RunOnResumeMapScript(void)
|
||||
{
|
||||
mapheader_run_script_by_tag(5);
|
||||
MapHeaderRunScriptType(MAP_SCRIPT_ON_RESUME);
|
||||
}
|
||||
|
||||
void RunOnReturnToFieldMapScript(void)
|
||||
{
|
||||
mapheader_run_script_by_tag(7);
|
||||
MapHeaderRunScriptType(MAP_SCRIPT_ON_RETURN_TO_FIELD);
|
||||
}
|
||||
|
||||
void RunOnDiveWarpMapScript(void)
|
||||
{
|
||||
mapheader_run_script_by_tag(6);
|
||||
MapHeaderRunScriptType(MAP_SCRIPT_ON_DIVE_WARP);
|
||||
}
|
||||
|
||||
bool8 TryRunOnFrameMapScript(void)
|
||||
{
|
||||
u8 *ptr;
|
||||
|
||||
if(gQuestLogState == QL_STATE_PLAYBACK_LAST)
|
||||
return 0;
|
||||
if (gQuestLogState == QL_STATE_PLAYBACK_LAST)
|
||||
return FALSE;
|
||||
|
||||
ptr = mapheader_get_first_match_from_tagged_ptr_list(2);
|
||||
ptr = MapHeaderCheckScriptTable(MAP_SCRIPT_ON_FRAME_TABLE);
|
||||
|
||||
if (!ptr)
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
ScriptContext1_SetupScript(ptr);
|
||||
return 1;
|
||||
ScriptContext_SetupScript(ptr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TryRunOnWarpIntoMapScript(void)
|
||||
{
|
||||
u8 *ptr = mapheader_get_first_match_from_tagged_ptr_list(4);
|
||||
u8 *ptr = MapHeaderCheckScriptTable(MAP_SCRIPT_ON_WARP_INTO_MAP_TABLE);
|
||||
if (ptr)
|
||||
ScriptContext2_RunNewScript(ptr);
|
||||
RunScriptImmediately(ptr);
|
||||
}
|
||||
|
||||
u32 CalculateRamScriptChecksum(void)
|
||||
@@ -486,7 +514,7 @@ bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objec
|
||||
const u8 *GetRamScript(u8 objectId, const u8 *script)
|
||||
{
|
||||
struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data;
|
||||
gRAMScriptPtr = NULL;
|
||||
gRamScriptRetAddr = NULL;
|
||||
if (scriptData->magic != RAM_SCRIPT_MAGIC)
|
||||
return script;
|
||||
if (scriptData->mapGroup != gSaveBlock1Ptr->location.mapGroup)
|
||||
@@ -502,7 +530,7 @@ const u8 *GetRamScript(u8 objectId, const u8 *script)
|
||||
}
|
||||
else
|
||||
{
|
||||
gRAMScriptPtr = script;
|
||||
gRamScriptRetAddr = script;
|
||||
return scriptData->script;
|
||||
}
|
||||
}
|
||||
@@ -547,9 +575,9 @@ u8 *GetSavedRamScriptIfValid(void)
|
||||
}
|
||||
}
|
||||
|
||||
void MEventSetRamScript(u8 *script, u16 scriptSize)
|
||||
void InitRamScript_NoObjectEvent(u8 *script, u16 scriptSize)
|
||||
{
|
||||
if (scriptSize > sizeof(gSaveBlock1Ptr->ramScript.data.script))
|
||||
scriptSize = sizeof(gSaveBlock1Ptr->ramScript.data.script);
|
||||
InitRamScript(script, scriptSize, 0xFF, 0xFF, 0xFF);
|
||||
InitRamScript(script, scriptSize, MAP_GROUP(UNDEFINED), MAP_NUM(UNDEFINED), 0xFF);
|
||||
}
|
||||
|
||||
+4
-4
@@ -816,7 +816,7 @@ static void Task_MultichoiceMenu_HandleInput(u8 taskId)
|
||||
}
|
||||
DestroyScriptMenuWindow(data[6]);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -885,7 +885,7 @@ static void Task_YesNoMenu_HandleInput(u8 taskId)
|
||||
break;
|
||||
}
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -936,7 +936,7 @@ static void Hask_MultichoiceGridMenu_HandleInput(u8 taskId)
|
||||
}
|
||||
DestroyScriptMenuWindow(data[6]);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
bool8 CreatePCMenu(void)
|
||||
@@ -1172,7 +1172,7 @@ void QLPlaybackCB_DestroyScriptMenuMonPicSprites(void)
|
||||
{
|
||||
u8 taskId;
|
||||
s16 *data;
|
||||
ScriptContext1_SetupScript(EventScript_ReleaseEnd);
|
||||
ScriptContext_SetupScript(EventScript_ReleaseEnd);
|
||||
taskId = FindTaskIdByFunc(Task_ScriptShowMonPic);
|
||||
if (taskId != 0xFF)
|
||||
{
|
||||
|
||||
+3
-3
@@ -1129,7 +1129,7 @@ void CreatePokemartMenu(const u16 *itemsForSale)
|
||||
{
|
||||
SetShopItemsForSale(itemsForSale);
|
||||
CreateShopMenu(MART_TYPE_REGULAR);
|
||||
SetShopMenuCallback(EnableBothScriptContexts);
|
||||
SetShopMenuCallback(ScriptContext_Enable);
|
||||
DebugFunc_PrintShopMenuHistoryBeforeClearMaybe();
|
||||
memset(&gShopMenuHistory, 0, sizeof(gShopMenuHistory));
|
||||
gShopMenuHistory[0].unk8 = gMapHeader.regionMapSectionId;
|
||||
@@ -1140,13 +1140,13 @@ void CreateDecorationShop1Menu(const u16 *itemsForSale)
|
||||
{
|
||||
SetShopItemsForSale(itemsForSale);
|
||||
CreateShopMenu(MART_TYPE_DECOR);
|
||||
SetShopMenuCallback(EnableBothScriptContexts);
|
||||
SetShopMenuCallback(ScriptContext_Enable);
|
||||
}
|
||||
|
||||
void CreateDecorationShop2Menu(const u16 *itemsForSale)
|
||||
{
|
||||
SetShopItemsForSale(itemsForSale);
|
||||
CreateShopMenu(MART_TYPE_DECOR2);
|
||||
SetShopMenuCallback(EnableBothScriptContexts);
|
||||
SetShopMenuCallback(ScriptContext_Enable);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ static void Task_SSAnneFinish(u8 taskId)
|
||||
FreeSpriteTilesByTag(SPRITE_TAG_WAKE);
|
||||
FreeSpriteTilesByTag(SPRITE_TAG_SMOKE);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -394,7 +394,7 @@ void ShowStartMenu(void)
|
||||
StopPlayerAvatar();
|
||||
}
|
||||
OpenStartMenuWithFollowupFunc(Task_StartMenuHandleInput);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static bool8 StartCB_HandleInput(void)
|
||||
@@ -575,7 +575,7 @@ static bool8 StartCB_Save2(void)
|
||||
case SAVECB_RETURN_OKAY:
|
||||
ClearDialogWindowAndFrameToTransparent(0, TRUE);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
RestoreHelpContext();
|
||||
return TRUE;
|
||||
case SAVECB_RETURN_CANCEL:
|
||||
@@ -587,7 +587,7 @@ static bool8 StartCB_Save2(void)
|
||||
case SAVECB_RETURN_ERROR:
|
||||
ClearDialogWindowAndFrameToTransparent(0, TRUE);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
RestoreHelpContext();
|
||||
return TRUE;
|
||||
}
|
||||
@@ -641,7 +641,7 @@ static void task50_save_game(u8 taskId)
|
||||
break;
|
||||
}
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
RestoreHelpContext();
|
||||
}
|
||||
|
||||
@@ -995,7 +995,7 @@ static void CloseStartMenu(void)
|
||||
ClearStdWindowAndFrame(GetStartMenuWindowId(), TRUE);
|
||||
RemoveStartMenuWindow();
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
}
|
||||
|
||||
void AppendToList(u8 *list, u8 *cursor, u8 newEntry)
|
||||
|
||||
+1
-1
@@ -2728,7 +2728,7 @@ static void LinkTrade_TearDownAssets(void)
|
||||
|
||||
void DoInGameTradeScene(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
CreateTask(Task_WaitFadeAndStartInGameTradeAnim, 10);
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
||||
HelpSystem_Disable();
|
||||
|
||||
+1
-1
@@ -550,7 +550,7 @@ void EndTrainerApproach(void)
|
||||
static void Task_DestroyTrainerApproachTask(u8 taskId)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
// Trainer See Excl Mark Field Effect
|
||||
|
||||
+9
-9
@@ -1019,12 +1019,12 @@ static void Task_TryBecomeLinkLeader(u8 taskId)
|
||||
data->state++;
|
||||
break;
|
||||
case 24:
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
gSpecialVar_Result = 5;
|
||||
break;
|
||||
case 22:
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
gSpecialVar_Result = 8;
|
||||
break;
|
||||
@@ -2003,7 +2003,7 @@ static void Task_StartActivity(u8 taskId)
|
||||
|
||||
DestroyTask(taskId);
|
||||
gSpecialVar_Result = 1;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void Task_RunScriptAndFadeToActivity(u8 taskId)
|
||||
@@ -2015,11 +2015,11 @@ static void Task_RunScriptAndFadeToActivity(u8 taskId)
|
||||
{
|
||||
case 0:
|
||||
gSpecialVar_Result = 1;
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (!ScriptContext1_IsScriptSetUp())
|
||||
if (!ScriptContext_IsEnabled())
|
||||
{
|
||||
FadeScreen(FADE_TO_BLACK, 0);
|
||||
data[0]++;
|
||||
@@ -2776,7 +2776,7 @@ static void Task_RunUnionRoom(u8 taskId)
|
||||
gSpecialVar_Result = 0;
|
||||
}
|
||||
}
|
||||
else if (ScriptContext2_IsEnabled() != TRUE)
|
||||
else if (ArePlayerFieldControlsLocked() != TRUE)
|
||||
{
|
||||
if (JOY_NEW(A_BUTTON))
|
||||
{
|
||||
@@ -3977,7 +3977,7 @@ static void JoinGroup_BlankBg0AndEnableScriptContexts(void)
|
||||
{
|
||||
FillBgTilemapBufferRect(0, 0, 0, 0, 32, 32, 0);
|
||||
CopyBgTilemapBufferToVram(0);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
static void UR_AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 colorIdx)
|
||||
@@ -4644,7 +4644,7 @@ static u32 GetPartyPositionOfRegisteredMon(struct UnionRoomTrade * trade, u8 mul
|
||||
static void HandleCancelTrade(bool32 unlockObjs)
|
||||
{
|
||||
UR_BlankBg0();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnionRoom_UnlockPlayerAndChatPartner();
|
||||
sPlayerCurrActivity = 0;
|
||||
if (unlockObjs)
|
||||
@@ -4656,7 +4656,7 @@ static void HandleCancelTrade(bool32 unlockObjs)
|
||||
|
||||
static void UR_EnableScriptContext2AndFreezeObjectEvents(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjects_WaitForPlayer();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -624,7 +624,7 @@ static void Task_ResetObjectsRematchWantedState(u8 taskId)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
StopPlayerAvatar();
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -837,7 +837,7 @@ static void Task_VsSeeker_3(u8 taskId)
|
||||
StartAllRespondantIdleMovements();
|
||||
ClearDialogWindowAndFrame(0, TRUE);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
Free(sVsSeeker);
|
||||
|
||||
@@ -593,7 +593,7 @@ bool8 UpdateRepelCounter(void)
|
||||
VarSet(VAR_REPEL_STEP_COUNT, steps);
|
||||
if (steps == 0)
|
||||
{
|
||||
ScriptContext1_SetupScript(EventScript_RepelWoreOff);
|
||||
ScriptContext_SetupScript(EventScript_RepelWoreOff);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user