# HG changeset patch # User Adam Kaminski # Date 1608920520 18000 # Fri Dec 25 13:22:00 2020 -0500 # Node ID 32e97212fdfe8569f641f4c352fe8b3a22eec115 # Parent ba6b7372e802b99b41df5e70b9ce9063ca9e473e Added a new SBARINFO command: IfSpying [not] that executes a sub block if the local player is (not) spying on another player. diff -r ba6b7372e802 -r 32e97212fdfe docs/zandronum-history.txt --- a/docs/zandronum-history.txt Fri Dec 25 09:41:37 2020 -0500 +++ b/docs/zandronum-history.txt Fri Dec 25 13:22:00 2020 -0500 @@ -28,7 +28,7 @@ + - Added a new scoreboard icon that displays if a player is lagging to the server. [Kaminsky] + - Added ACS functions: SetPlayerScore(int player, int type, int value) and GetPlayerScore(int player, int type) to get or set the player's score. The type can be either frags, points, wins, deaths, kills, or the item and secret counts. [Kaminsky] + - Added an ACS special to check whether the game is in demo or not [DoomJoshuaBoy/geNia] -+ - Added a new SBARINFO command: IfSpectator [not] [dead] that executes a sub block if the local player is (not) a (dead) spectator. [Kaminsky] ++ - Added new SBARINFO commands: IfSpectator [not] [dead] and IfSpying [not] that execute a sub block if the local player is (not) a (dead) spectator, or (not) spying on another player respectively. [Kaminsky] - - Fixed: Bots tries to jump to reach item when sv_nojump is true. [sleep] - - Fixed: ACS function SetSkyScrollSpeed didn't work online. [Edward-san] - - Fixed: color codes in callvote reasons weren't terminated properly. [Dusk] diff -r ba6b7372e802 -r 32e97212fdfe src/g_shared/sbarinfo_commands.cpp --- a/src/g_shared/sbarinfo_commands.cpp Fri Dec 25 09:41:37 2020 -0500 +++ b/src/g_shared/sbarinfo_commands.cpp Fri Dec 25 13:22:00 2020 -0500 @@ -3684,6 +3684,38 @@ //////////////////////////////////////////////////////////////////////////////// +class CommandIfSpying : public SBarInfoCommandFlowControl +{ + public: + CommandIfSpying(SBarInfo *script) : SBarInfoCommandFlowControl(script), + negate(false) + { + } + + void Parse(FScanner &sc, bool fullScreenOffsets) + { + if (sc.CheckToken(TK_Identifier)) + { + if (sc.Compare("not")) + negate = true; + else + sc.ScriptError("Expected 'not', but got '%s' instead.", sc.String); + } + + SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets); + } + + void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) + { + SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); + SetTruth((statusBar->CPlayer != &players[consoleplayer]) ^ negate, block, statusBar); + } + protected: + bool negate; +}; + +//////////////////////////////////////////////////////////////////////////////// + static const char *SBarInfoCommandNames[] = { "drawimage", "drawnumber", "drawswitchableimage", @@ -3695,8 +3727,8 @@ "hasweaponpiece", "inventorybarnotvisible", "weaponammo", "ininventory", "alpha", - // [AK] Zandronum-exclusive "IfSpectator" command. - "ifspectator", + // [AK] Zandronum-exclusive commands. + "ifspectator", "ifspying", NULL }; @@ -3711,8 +3743,8 @@ SBARINFO_HASWEAPONPIECE, SBARINFO_INVENTORYBARNOTVISIBLE, SBARINFO_WEAPONAMMO, SBARINFO_ININVENTORY, SBARINFO_ALPHA, - // [AK] Zandronum-exclusive "IfSpectator" command. - SBARINFO_IFSPECTATOR, + // [AK] Zandronum-exclusive commands. + SBARINFO_IFSPECTATOR, SBARINFO_IFSPYING, }; SBarInfoCommand *SBarInfoCommandFlowControl::NextCommand(FScanner &sc) @@ -3746,8 +3778,9 @@ case SBARINFO_ININVENTORY: return new CommandInInventory(script); case SBARINFO_ALPHA: return new CommandAlpha(script); - // [AK] Zandronum-exclusive "IfSpectator" command. + // [AK] Zandronum-exclusive commands. case SBARINFO_IFSPECTATOR: return new CommandIfSpectator(script); + case SBARINFO_IFSPYING: return new CommandIfSpying(script); } sc.ScriptError("Unknown command '%s'.\n", sc.String);