diff --git a/src/acs/interface.cpp b/src/acs/interface.cpp index cbd6533c1..864c1fa3f 100644 --- a/src/acs/interface.cpp +++ b/src/acs/interface.cpp @@ -249,6 +249,61 @@ void ACS_RunLapScript(mobj_t *mo, line_t *line) map->scriptStartTypeForced(ACS_ST_LAP, scriptInfo); } +/*-------------------------------------------------- + void ACS_RunPositionScript(void) + + See header file for description. +--------------------------------------------------*/ +void ACS_RunPositionScript(void) +{ + Environment *env = &ACSEnv; + + ACSVM::GlobalScope *const global = env->getGlobalScope(0); + ACSVM::HubScope *const hub = global->getHubScope(0); + ACSVM::MapScope *const map = hub->getMapScope(0); + + map->scriptStartType(ACS_ST_POSITION, {}); +} + +/*-------------------------------------------------- + void ACS_RunOvertimeScript(void) + + See header file for description. +--------------------------------------------------*/ +void ACS_RunOvertimeScript(void) +{ + Environment *env = &ACSEnv; + + ACSVM::GlobalScope *const global = env->getGlobalScope(0); + ACSVM::HubScope *const hub = global->getHubScope(0); + ACSVM::MapScope *const map = hub->getMapScope(0); + + map->scriptStartType(ACS_ST_OVERTIME, {}); +} + +/*-------------------------------------------------- + void ACS_RunEmeraldScript(mobj_t *mo) + + See header file for description. +--------------------------------------------------*/ +void ACS_RunEmeraldScript(mobj_t *mo) +{ + Environment *env = &ACSEnv; + + ACSVM::GlobalScope *const global = env->getGlobalScope(0); + ACSVM::HubScope *const hub = global->getHubScope(0); + ACSVM::MapScope *const map = hub->getMapScope(0); + + ACSVM::MapScope::ScriptStartInfo scriptInfo; + ThreadInfo info; + + P_SetTarget(&info.mo, mo); + + scriptInfo.info = &info; + + map->scriptStartTypeForced(ACS_ST_EMERALD, scriptInfo); +} + /*-------------------------------------------------- void ACS_Tick(void) diff --git a/src/acs/interface.h b/src/acs/interface.h index 18a3010f1..7c535ac3d 100644 --- a/src/acs/interface.h +++ b/src/acs/interface.h @@ -59,6 +59,17 @@ void ACS_Shutdown(void); void ACS_LoadLevelScripts(size_t mapID); +/*-------------------------------------------------- + void ACS_RunLevelStartScripts(void); + + Runs the map's special scripts for opening + the level, and for all players to enter + the game. +--------------------------------------------------*/ + +void ACS_RunLevelStartScripts(void); + + /*-------------------------------------------------- void ACS_RunPlayerRespawnScript(player_t *player); @@ -107,17 +118,6 @@ void ACS_RunPlayerDeathScript(player_t *player); void ACS_RunPlayerEnterScript(player_t *player); -/*-------------------------------------------------- - void ACS_RunLevelStartScripts(void); - - Runs the map's special scripts for opening - the level, and for all players to enter - the game. ---------------------------------------------------*/ - -void ACS_RunLevelStartScripts(void); - - /*-------------------------------------------------- void ACS_RunLapScript(mobj_t *mo, line_t *line); @@ -135,6 +135,36 @@ void ACS_RunLevelStartScripts(void); void ACS_RunLapScript(mobj_t *mo, line_t *line); +/*-------------------------------------------------- + void ACS_RunPositionScript(void); + + Runs the map's special script for when the level + goes past the POSITION period. +--------------------------------------------------*/ + +void ACS_RunPositionScript(void); + + +/*-------------------------------------------------- + void ACS_RunOvertimeScript(void); + + Runs the map's special script for when the time + limit runs out and overtime begins. +--------------------------------------------------*/ + +void ACS_RunOvertimeScript(void); + + +/*-------------------------------------------------- + void ACS_RunEmeraldScript(mobj_t *mo); + + Runs the map's special script for when the + Special Stage Chaos Emerald is collected. +--------------------------------------------------*/ + +void ACS_RunEmeraldScript(mobj_t *mo); + + /*-------------------------------------------------- void ACS_Tick(void); diff --git a/src/acs/thread.hpp b/src/acs/thread.hpp index 7e528608a..eff31eb29 100644 --- a/src/acs/thread.hpp +++ b/src/acs/thread.hpp @@ -48,6 +48,9 @@ enum acs_scriptType_e ACS_ST_DEATH = 3, // DEATH: Runs when a player dies. ACS_ST_ENTER = 4, // ENTER: Runs when a player enters the game; both on start of the level, and when un-spectating. ACS_ST_LAP = 5, // LAP: Runs when a player's lap increases from crossing the finish line. + ACS_ST_POSITION = 6, // POSITION: Runs when the POSITION period ends. + ACS_ST_OVERTIME = 7, // OVERTIME: Runs when Overtime starts in timed game modes. + ACS_ST_EMERALD = 8, // EMERALD: Runs when the Chaos Emerald is collected in a Special Stage. }; // diff --git a/src/objects/ufo.c b/src/objects/ufo.c index a4c46d58c..253b1a5e8 100644 --- a/src/objects/ufo.c +++ b/src/objects/ufo.c @@ -24,6 +24,7 @@ #include "../k_waypoint.h" #include "../k_specialstage.h" #include "../r_skins.h" +#include "../acs/interface.h" #define UFO_BASE_SPEED (42 * FRACUNIT) // UFO's slowest speed. #define UFO_SPEEDUP (FRACUNIT >> 1) // Acceleration @@ -697,7 +698,7 @@ boolean Obj_SpecialUFODamage(mobj_t *ufo, mobj_t *inflictor, mobj_t *source, UIN ufo->flags = (ufo->flags & ~MF_SHOOTABLE) | (MF_SPECIAL|MF_PICKUPFROMBELOW); ufo->shadowscale = FRACUNIT/3; - P_LinedefExecute(LE_PINCHPHASE, ufo, NULL); + ACS_RunEmeraldScript(source); S_StopSound(ufo); S_StartSound(ufo, sfx_clawk2); diff --git a/src/p_tick.c b/src/p_tick.c index 22f9187be..4ed8fd83a 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -695,8 +695,20 @@ void P_Ticker(boolean run) P_PrecipitationEffects(); if (run) + { leveltime++; + if (starttime > introtime && leveltime == starttime) + { + ACS_RunPositionScript(); + } + + if (timelimitintics > 0 && leveltime == (timelimitintics + starttime + 1)) + { + ACS_RunOvertimeScript(); + } + } + timeinmap++; if (G_GametypeHasTeams())