From 263e0577adae97559df5c5bbe860ed761c64a66e Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Tue, 30 Apr 2024 00:35:17 -0300 Subject: [PATCH] Change PlayerBot so that it accepts a player number Make PlayerExiting consistent with PlayerFinished --- extras/acs/srb2defs.acs | 10 ++++++++ extras/acs/srb2special.acs | 4 +-- src/acs/call-funcs.cpp | 50 ++++++++++++++++++++++---------------- 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/extras/acs/srb2defs.acs b/extras/acs/srb2defs.acs index cd7608413..8e1fee865 100644 --- a/extras/acs/srb2defs.acs +++ b/extras/acs/srb2defs.acs @@ -212,6 +212,16 @@ #define SHIELD_FORCEHP 0xFF +// Emeralds + +#define EMERALD1 (1 << 0) +#define EMERALD2 (1 << 1) +#define EMERALD3 (1 << 2) +#define EMERALD4 (1 << 3) +#define EMERALD5 (1 << 4) +#define EMERALD6 (1 << 5) +#define EMERALD7 (1 << 6) + // Teams #define NO_TEAM 0 diff --git a/extras/acs/srb2special.acs b/extras/acs/srb2special.acs index 79b5c2baa..efc376877 100644 --- a/extras/acs/srb2special.acs +++ b/extras/acs/srb2special.acs @@ -33,8 +33,8 @@ special -303:SkinUnlocked(1), -304:PlayerSkin(0), -305:PlayerEmeralds(0), - -306:PlayerBot(0), - -307:PlayerExiting(0), + -306:PlayerBot(1), + -307:PlayerExiting(1), -308:PlayerLap(0), -309:RingSlingerMode(0), -310:TeamGame(0), diff --git a/src/acs/call-funcs.cpp b/src/acs/call-funcs.cpp index 8005bae51..86cde7ce0 100644 --- a/src/acs/call-funcs.cpp +++ b/src/acs/call-funcs.cpp @@ -1686,24 +1686,28 @@ bool CallFunc_PlayerSkin(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM:: /*-------------------------------------------------- bool CallFunc_PlayerBot(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) - Returns the activating player's bot status. + Returns the given player's bot status. --------------------------------------------------*/ bool CallFunc_PlayerBot(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) { - auto info = &static_cast(thread)->info; - - (void)argV; (void)argC; - if ((info != NULL) - && (info->mo != NULL && P_MobjWasRemoved(info->mo) == false) - && (info->mo->player != NULL)) + INT32 playernum = argV[0]; + + bool isBot = false; + + if (playernum < 0 || playernum >= MAXPLAYERS) { - thread->dataStk.push(info->mo->player->bot); - return false; + CONS_Alert(CONS_WARNING, "PlayerBot player %d out of range (expected 0 - %d).\n", playernum, MAXPLAYERS-1); + } + else + { + if (players[playernum].bot != BOT_NONE) + isBot = true; } - thread->dataStk.push(false); + thread->dataStk.push(isBot); + return false; } @@ -1714,20 +1718,24 @@ bool CallFunc_PlayerBot(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::W --------------------------------------------------*/ bool CallFunc_PlayerExiting(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) { - auto info = &static_cast(thread)->info; - - (void)argV; (void)argC; - if ((info != NULL) - && (info->mo != NULL && P_MobjWasRemoved(info->mo) == false) - && (info->mo->player != NULL)) + INT32 playernum = argV[0]; + + bool exiting = false; + + if (playernum < 0 || playernum >= MAXPLAYERS) { - thread->dataStk.push((info->mo->player->exiting != 0)); - return false; + CONS_Alert(CONS_WARNING, "PlayerExiting player %d out of range (expected 0 - %d).\n", playernum, MAXPLAYERS-1); + } + else + { + if (players[playernum].exiting != 0) + exiting = true; } - thread->dataStk.push(false); + thread->dataStk.push(exiting); + return false; } @@ -5255,7 +5263,7 @@ bool CallFunc_PlayerIsIt(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM:: /*-------------------------------------------------- bool CallFunc_PlayerFinished(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) - Checks if the activator finished the level. + Checks if the given player finished the level. --------------------------------------------------*/ bool CallFunc_PlayerFinished(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) { @@ -5283,7 +5291,7 @@ bool CallFunc_PlayerFinished(ACSVM::Thread *thread, const ACSVM::Word *argV, ACS /*-------------------------------------------------- bool CallFunc_SpawnProjectile(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) - Spawns a projectile. Yeah... + Spawns a projectile. --------------------------------------------------*/ bool CallFunc_SpawnProjectile(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) {