Allow flags in trigger scripts (#4900)

This commit is contained in:
DizzyEggg 2024-07-26 23:46:33 +02:00 committed by GitHub
parent cc00446eb8
commit e82e3b4198
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -932,6 +932,16 @@ static s8 GetWarpEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 e
return WARP_ID_NONE;
}
static bool32 ShouldTriggerScriptRun(const struct CoordEvent *coordEvent)
{
u16 *varPtr = GetVarPointer(coordEvent->trigger);
// Treat non Vars as flags
if (varPtr == NULL)
return (FlagGet(coordEvent->trigger) == coordEvent->index);
else
return (*varPtr == coordEvent->index);
}
static const u8 *TryRunCoordEventScript(const struct CoordEvent *coordEvent)
{
if (coordEvent != NULL)
@ -946,7 +956,7 @@ static const u8 *TryRunCoordEventScript(const struct CoordEvent *coordEvent)
RunScriptImmediately(coordEvent->script);
return NULL;
}
if (VarGet(coordEvent->trigger) == (u8)coordEvent->index)
if (ShouldTriggerScriptRun(coordEvent))
return coordEvent->script;
}
return NULL;