From e854ce53f53e5a046fffe68b0f81709917516198 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 13 Sep 2023 18:10:08 +0100 Subject: [PATCH] Add "GetGrabbedSprayCan" to ACS - If netgame or no Spray Can has been grabbed on this map, return 0 - If all Spray Cans have been grabbed in other maps, return "_Completed" - Otherwise, return the name for the Spray Can color attached to this map --- src/acs/call-funcs.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/acs/call-funcs.hpp | 1 + src/acs/environment.cpp | 1 + 3 files changed, 38 insertions(+) diff --git a/src/acs/call-funcs.cpp b/src/acs/call-funcs.cpp index 6594d4840..07b8cd957 100644 --- a/src/acs/call-funcs.cpp +++ b/src/acs/call-funcs.cpp @@ -1714,6 +1714,42 @@ bool CallFunc_GrandPrix(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::W return false; } +/*-------------------------------------------------- + bool CallFunc_GetGrabbedSprayCan(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) + + Returns the level's associated Spray Can, if grabbed. +--------------------------------------------------*/ +bool CallFunc_GetGrabbedSprayCan(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) +{ + Environment *env = &ACSEnv; + + (void)argV; + (void)argC; + + if (netgame == false // cans are per-player and completely unsyncable + && gamemap-1 < basenummapheaders) + { + // See also P_SprayCanInit + UINT16 can_id = mapheaderinfo[gamemap-1]->cache_spraycan; + + if (can_id < gamedata->numspraycans) + { + UINT16 col = gamedata->spraycans[can_id].col; + + thread->dataStk.push(~env->getString( skincolors[col].name )->idx); + return false; + } + + if (gamedata->gotspraycans >= gamedata->numspraycans) + { + thread->dataStk.push(~env->getString( "_Completed" )->idx); + return false; + } + } + + thread->dataStk.push(0); + return false; +} /*-------------------------------------------------- bool CallFunc_PodiumPosition(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) diff --git a/src/acs/call-funcs.hpp b/src/acs/call-funcs.hpp index 39bf5adf8..86af95f15 100644 --- a/src/acs/call-funcs.hpp +++ b/src/acs/call-funcs.hpp @@ -82,6 +82,7 @@ bool CallFunc_EncoreMode(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM:: bool CallFunc_BreakTheCapsules(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_TimeAttack(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_GrandPrix(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); +bool CallFunc_GetGrabbedSprayCan(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_PodiumPosition(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_PodiumFinish(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); diff --git a/src/acs/environment.cpp b/src/acs/environment.cpp index 9fba26211..289cfdb39 100644 --- a/src/acs/environment.cpp +++ b/src/acs/environment.cpp @@ -166,6 +166,7 @@ Environment::Environment() addFuncDataACS0( 311, addCallFunc(CallFunc_TimeAttack)); addFuncDataACS0( 312, addCallFunc(CallFunc_ThingCount)); addFuncDataACS0( 313, addCallFunc(CallFunc_GrandPrix)); + addFuncDataACS0( 314, addCallFunc(CallFunc_GetGrabbedSprayCan)); addFuncDataACS0( 500, addCallFunc(CallFunc_CameraWait)); addFuncDataACS0( 501, addCallFunc(CallFunc_PodiumPosition));