2020-05-13 22:04:14 +00:00
//-------------------------------------------------------------------------
/*
Copyright ( C ) 1996 , 2003 - 3 D Realms Entertainment
Copyright ( C ) 2000 , 2003 - Matt Saettler ( EDuke Enhancements )
Copyright ( C ) 2020 - Christoph Oelckers
This file is part of Enhanced Duke Nukem 3 D version 1.5 - Atomic Edition
Duke Nukem 3 D is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation ; either version 2
of the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
Original Source : 1996 - Todd Replogle
Prepared for public release : 03 / 21 / 2003 - Charlie Wiederhold , 3 D Realms
EDuke enhancements integrated : 04 / 13 / 2003 - Matt Saettler
Note : EDuke source was in transition . Changes are in - progress in the
source as it is released .
*/
//-------------------------------------------------------------------------
# include "ns.h"
2020-05-14 07:07:07 +00:00
# include "concmd.h"
2020-06-23 20:01:58 +00:00
# include "duke3d.h"
2020-05-13 22:04:14 +00:00
# include "gamevar.h"
2020-07-07 15:56:20 +00:00
# include "mapinfo.h"
2020-09-03 21:10:28 +00:00
# include "gamestate.h"
2020-09-17 20:36:09 +00:00
# include "conlabel.h"
# include "automap.h"
2020-10-17 08:30:11 +00:00
# include "dukeactor.h"
2020-05-13 22:04:14 +00:00
BEGIN_DUKE_NS
2020-07-06 14:24:22 +00:00
// Player Actions - used by ifp instruction.
enum playeraction_t {
2021-11-09 23:05:42 +00:00
pstanding = 0x00000001 ,
pwalking = 0x00000002 ,
prunning = 0x00000004 ,
pducking = 0x00000008 ,
pfalling = 0x00000010 ,
pjumping = 0x00000020 ,
phigher = 0x00000040 ,
pwalkingback = 0x00000080 ,
prunningback = 0x00000100 ,
pkicking = 0x00000200 ,
pshrunk = 0x00000400 ,
pjetpack = 0x00000800 ,
ponsteroids = 0x00001000 ,
ponground = 0x00002000 ,
palive = 0x00004000 ,
pdead = 0x00008000 ,
pfacing = 0x00010000
2020-07-06 14:24:22 +00:00
} ;
2020-07-18 10:37:35 +00:00
struct ParseState
{
2023-07-22 08:24:20 +00:00
int killit_flag ;
2020-11-01 16:57:40 +00:00
int g_p ;
2020-07-18 10:37:35 +00:00
int g_x ;
2020-10-24 07:35:43 +00:00
DDukeActor * g_ac ;
2020-07-18 10:37:35 +00:00
int * insptr ;
2020-10-23 18:18:38 +00:00
Collision coll ;
2020-07-18 10:37:35 +00:00
int parse ( void ) ;
void parseifelse ( int condition ) ;
} ;
2022-09-12 20:58:52 +00:00
int furthestcanseepoint ( DDukeActor * i , DDukeActor * ts , DVector2 & pos ) ;
2020-05-14 21:25:53 +00:00
2021-12-05 16:36:57 +00:00
sectortype * toSect ( int index )
2020-05-13 22:04:14 +00:00
{
2021-12-05 16:36:57 +00:00
return validSectorIndex ( index ) ? & sector [ index ] : nullptr ;
}
int fromSect ( sectortype * sect )
{
2022-11-15 11:03:44 +00:00
return sect ? sectindex ( sect ) : - 1 ;
2021-12-05 16:36:57 +00:00
}
2020-09-17 20:36:09 +00:00
2021-12-05 16:36:57 +00:00
walltype * toWall ( int index )
{
return validWallIndex ( index ) ? & wall [ index ] : nullptr ;
}
int fromWall ( walltype * sect )
{
2022-11-15 11:03:44 +00:00
return sect ? wallindex ( sect ) : - 1 ;
2021-12-05 16:36:57 +00:00
}
static void DoUserDef ( bool bSet , int lVar1 , int lLabelID , int lVar2 , DDukeActor * sActor , int sPlayer , int lParm2 )
{
auto vValue = GetGameVarID ( lVar2 , sActor , sPlayer ) ;
auto lValue = vValue . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
// most settings have been removed because they are either pointless, no longer existent or simply too dangerous to access.
// Others have been made read-only.
switch ( lLabelID )
2020-05-13 22:04:14 +00:00
{
2020-09-17 20:36:09 +00:00
case USERDEFS_GOD : // redid this so that the script won't be able to disable user-set god mode.
if ( bSet ) ud . god = ( ud . god & ~ 2 ) | ( lValue ? 2 : 0 ) ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ! ! ud . god , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_CASHMAN :
if ( bSet ) ud . cashman = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . cashman , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_EOG :
if ( bSet ) ud . eog = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . eog , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_SHOWALLMAP :
if ( bSet ) gFullMap = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , gFullMap , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_SHOWWEAPONS :
2020-11-29 11:23:31 +00:00
// Read-only user state.
2021-03-31 09:07:36 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , cl_showweapon , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_CAMERASPRITE :
2021-12-05 16:36:57 +00:00
if ( bSet ) ud . cameraactor = vValue . safeActor ( ) ;
else SetGameVarID ( lVar2 , ud . cameraactor , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-14 10:52:59 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_LAST_CAMSPRITE :
2021-03-31 09:07:36 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , - 1 , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-14 07:07:07 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_LAST_LEVEL :
if ( bSet ) ud . last_level = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . last_level , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_SECRETLEVEL :
if ( bSet ) ud . secretlevel = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . secretlevel , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_CONST_VISIBILITY :
if ( bSet ) ud . const_visibility = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . const_visibility , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_SHADOWS :
if ( bSet ) ud . shadows = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . shadows , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case USERDEFS_M_COOP :
2021-03-31 09:07:36 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , ud . m_coop , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_COOP :
2021-03-31 09:07:36 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , ud . coop , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_RESPAWN_MONSTERS :
if ( bSet ) ud . respawn_monsters = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . respawn_monsters , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_RESPAWN_ITEMS :
if ( bSet ) ud . respawn_items = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . respawn_items , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_RESPAWN_INVENTORY :
if ( bSet ) ud . respawn_inventory = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . respawn_inventory , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_RECSTAT :
2021-03-31 09:07:36 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , ud . recstat , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_MONSTERS_OFF :
if ( bSet ) ud . monsters_off = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . monsters_off , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_BRIGHTNESS :
if ( bSet ) ud . brightness = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . brightness , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_M_RESPAWN_ITEMS :
if ( bSet ) ud . m_respawn_items = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . m_respawn_items , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_M_RESPAWN_MONSTERS :
if ( bSet ) ud . m_respawn_monsters = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . m_respawn_monsters , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_M_RESPAWN_INVENTORY :
if ( bSet ) ud . m_respawn_inventory = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . m_respawn_inventory , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_M_MONSTERS_OFF :
if ( bSet ) ud . m_monsters_off = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . m_monsters_off , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case USERDEFS_M_FFIRE :
if ( bSet ) ud . m_ffire = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . m_ffire , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case USERDEFS_FFIRE :
if ( bSet ) ud . ffire = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . ffire , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case USERDEFS_MULTIMODE :
2021-03-31 09:07:36 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , ud . multimode , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case USERDEFS_PLAYER_SKILL :
if ( bSet ) ud . player_skill = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . player_skill , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case USERDEFS_MARKER :
if ( bSet ) ud . marker = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , ud . marker , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
default :
// This will also catch all deleted cases.
// make sure that the return value is always defined.
2021-03-31 09:07:36 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , 0 , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
}
return ;
}
///////////////////////////////////////////
2020-10-23 17:07:33 +00:00
void DoPlayer ( bool bSet , int lVar1 , int lLabelID , int lVar2 , DDukeActor * sActor , int sPlayer , int lParm2 )
2020-09-17 20:36:09 +00:00
{
2021-12-05 16:36:57 +00:00
auto vValue = GetGameVarID ( lVar2 , sActor , sPlayer ) ;
auto lValue = vValue . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
int iPlayer ;
int lTemp ;
if ( lVar1 = = g_iThisActorID )
2020-05-14 07:07:07 +00:00
{
2020-09-17 20:36:09 +00:00
// if they've asked for 'this', then use 'this player'...
iPlayer = sPlayer ;
2020-05-14 07:07:07 +00:00
}
2020-09-17 20:36:09 +00:00
else
{
2021-12-05 16:36:57 +00:00
iPlayer = GetGameVarID ( lVar1 , sActor , sPlayer ) . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
}
if ( iPlayer < 0 | | iPlayer > = MAXPLAYERS )
return ;
2023-10-02 10:14:32 +00:00
const auto p = getPlayer ( iPlayer ) ;
const auto pact = p - > GetActor ( ) ;
2020-09-17 20:36:09 +00:00
switch ( lLabelID )
{
case PLAYER_ZOOM :
2021-03-31 09:07:36 +00:00
SetGameVarID ( lVar2 , 768 , sActor , sPlayer ) ; //return default for AM zoom.
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_EXITX :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > Exit . X = lValue * maptoworld ;
else SetGameVarID ( lVar2 , int ( p - > Exit . X / maptoworld ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_EXITY :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > Exit . Y = lValue * maptoworld ;
else SetGameVarID ( lVar2 , int ( p - > Exit . Y / maptoworld ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_LOOGIEX :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > loogie [ lParm2 ] . X = lValue ;
else SetGameVarID ( lVar2 , ( int ) p - > loogie [ lParm2 ] . X , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_LOOGIEY :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > loogie [ lParm2 ] . Y = lValue ;
else SetGameVarID ( lVar2 , ( int ) p - > loogie [ lParm2 ] . Y , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_NUMLOOGS :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > numloogs = lValue ;
else SetGameVarID ( lVar2 , p - > numloogs , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_LOOGCNT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > oloogcnt = p - > loogcnt = lValue ;
else SetGameVarID ( lVar2 , p - > loogcnt , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_POSX : // oh, my... :( Writing to these has been disabled until I know how to do it without the engine shitting all over itself.
2023-10-02 10:14:32 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , int ( pact - > spr . pos . X * ( 1 / maptoworld ) ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_POSY :
2023-10-02 10:14:32 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , int ( pact - > spr . pos . Y * ( 1 / maptoworld ) ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_POSZ :
2023-10-02 10:14:32 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , int ( pact - > getOffsetZ ( ) * ( 1 / zmaptoworld ) ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_HORIZ :
2021-03-31 08:48:38 +00:00
if ( bSet )
{
2023-10-02 10:14:32 +00:00
if ( p - > cmd . ucmd . actions & SB_CENTERVIEW )
2021-03-31 08:48:38 +00:00
{
2023-10-02 10:14:32 +00:00
p - > cmd . ucmd . actions & = ~ SB_CENTERVIEW ;
2021-03-31 08:48:38 +00:00
}
2023-10-02 10:14:32 +00:00
pact - > spr . Angles . Pitch = maphoriz ( - lValue ) ;
2021-03-31 08:48:38 +00:00
}
2023-10-02 10:14:32 +00:00
else SetGameVarID ( lVar2 , int ( pact - > spr . Angles . Pitch . Tan ( ) * - 128. ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_OHORIZ :
2023-10-02 10:14:32 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , int ( pact - > PrevAngles . Pitch . Tan ( ) * - 128. ) , sActor , sPlayer ) ;
2020-10-07 06:12:37 +00:00
break ;
case PLAYER_HORIZOFF :
2023-10-31 03:44:58 +00:00
if ( bSet ) p - > ViewAngles . Pitch = maphoriz ( - lValue ) ;
else SetGameVarID ( lVar2 , int ( p - > ViewAngles . Pitch . Tan ( ) * - 128. ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_OHORIZOFF :
2023-10-31 03:44:58 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , int ( p - > PrevViewAngles . Pitch . Tan ( ) * - 128. ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_INVDISPTIME :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > invdisptime = lValue ;
else SetGameVarID ( lVar2 , p - > invdisptime , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_BOBPOSX :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > bobpos . X = lValue * maptoworld ;
else SetGameVarID ( lVar2 , int ( p - > bobpos . X * ( 1 / maptoworld ) ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_BOBPOSY :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > bobpos . Y = lValue * maptoworld ;
else SetGameVarID ( lVar2 , int ( p - > bobpos . Y * ( 1 / maptoworld ) ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_OPOSX :
2023-10-02 10:14:32 +00:00
if ( bSet ) pact - > opos . X = lValue * maptoworld ;
else SetGameVarID ( lVar2 , int ( pact - > opos . X * ( 1 / maptoworld ) ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_OPOSY :
2023-10-02 10:14:32 +00:00
if ( bSet ) pact - > opos . Y = lValue * maptoworld ;
else SetGameVarID ( lVar2 , int ( pact - > opos . Y * ( 1 / maptoworld ) ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_OPOSZ :
2023-10-02 10:14:32 +00:00
if ( bSet ) pact - > opos . Z = ( lValue * zmaptoworld ) + gs . playerheight ;
else SetGameVarID ( lVar2 , int ( pact - > getPrevOffsetZ ( ) * ( 1 / zmaptoworld ) ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_PYOFF :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > pyoff = lValue * zmaptoworld ;
else SetGameVarID ( lVar2 , int ( p - > pyoff / zmaptoworld ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_OPYOFF :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > opyoff = lValue * zmaptoworld ;
else SetGameVarID ( lVar2 , int ( p - > opyoff / zmaptoworld ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_POSXV :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > vel . X = FixedToFloat < 18 > ( lValue ) ;
else SetGameVarID ( lVar2 , FloatToFixed < 18 > ( p - > vel . X ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_POSYV :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > vel . Y = FixedToFloat < 18 > ( lValue ) ;
else SetGameVarID ( lVar2 , FloatToFixed < 18 > ( p - > vel . Y ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_POSZV :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > vel . Z = lValue * zmaptoworld ;
else SetGameVarID ( lVar2 , int ( p - > vel . Z / zmaptoworld ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_LAST_PISSED_TIME :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > last_pissed_time = lValue ;
else SetGameVarID ( lVar2 , p - > last_pissed_time , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_TRUEFZ :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > truefz = lValue * zmaptoworld ;
else SetGameVarID ( lVar2 , int ( p - > truefz * ( 1 / zmaptoworld ) ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_TRUECZ :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > truecz = lValue * zmaptoworld ;
else SetGameVarID ( lVar2 , int ( p - > truecz * ( 1 / zmaptoworld ) ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-14 07:07:07 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_PLAYER_PAR :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > player_par = lValue ;
else SetGameVarID ( lVar2 , p - > player_par , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_VISIBILITY :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > visibility = lValue ;
else SetGameVarID ( lVar2 , p - > visibility , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_BOBCOUNTER :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > bobcounter = lValue ;
else SetGameVarID ( lVar2 , p - > bobcounter , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_WEAPON_SWAY :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > oweapon_sway = p - > weapon_sway = lValue ;
else SetGameVarID ( lVar2 , p - > weapon_sway , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_PALS_TIME :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > pals . a = lValue ;
else SetGameVarID ( lVar2 , p - > pals . a , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_RANDOMFLAMEX :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > randomflamex = lValue ;
else SetGameVarID ( lVar2 , p - > randomflamex , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_CRACK_TIME :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > crack_time = lValue ;
else SetGameVarID ( lVar2 , p - > crack_time , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_AIM_MODE : // game has no business enforcing this in any way.
2023-10-02 10:14:32 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , p - > aim_mode , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_ANG :
2023-10-02 10:14:32 +00:00
if ( bSet ) pact - > spr . Angles . Yaw = mapangle ( lValue ) ;
else SetGameVarID ( lVar2 , pact - > spr . Angles . Yaw . Buildang ( ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_OANG :
2023-10-02 10:14:32 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , pact - > PrevAngles . Yaw . Buildang ( ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_ANGVEL : // This no longer exists.
2021-03-31 09:07:36 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , 0 , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
2021-12-05 16:36:57 +00:00
case PLAYER_CURSECTNUM :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > cursector = toSect ( lValue ) ;
else SetGameVarID ( lVar2 , fromSect ( p - > cursector ) , sActor , sPlayer ) ;
2021-12-05 16:36:57 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_LOOK_ANG :
2023-10-31 03:44:58 +00:00
if ( bSet ) p - > ViewAngles . Yaw = mapangle ( lValue ) ;
else SetGameVarID ( lVar2 , p - > ViewAngles . Yaw . Buildang ( ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_LAST_EXTRA :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > last_extra = lValue ;
else SetGameVarID ( lVar2 , p - > last_extra , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_SUBWEAPON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > subweapon = lValue ;
else SetGameVarID ( lVar2 , p - > subweapon , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_AMMO_AMOUNT :
2021-12-05 16:36:57 +00:00
lTemp = GetGameVarID ( lParm2 , sActor , sPlayer ) . safeValue ( ) ;
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > ammo_amount [ lTemp ] = lValue ;
else SetGameVarID ( lVar2 , p - > ammo_amount [ lTemp ] , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_WACKEDBYACTOR :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > wackedbyactor = vValue . safeActor ( ) ;
else SetGameVarID ( lVar2 , p - > wackedbyactor , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_FRAG :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > frag = lValue ;
else SetGameVarID ( lVar2 , p - > frag , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_FRAGGEDSELF :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > fraggedself = lValue ;
else SetGameVarID ( lVar2 , p - > fraggedself , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_CURR_WEAPON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > curr_weapon = lValue ;
else SetGameVarID ( lVar2 , p - > curr_weapon , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_LAST_WEAPON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > last_weapon = lValue ;
else SetGameVarID ( lVar2 , p - > last_weapon , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_TIPINCS :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > otipincs = p - > tipincs = lValue ;
else SetGameVarID ( lVar2 , p - > tipincs , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_WANTWEAPONFIRE :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > wantweaponfire = lValue ;
else SetGameVarID ( lVar2 , p - > wantweaponfire , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_HOLODUKE_AMOUNT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > holoduke_amount = lValue ;
else SetGameVarID ( lVar2 , p - > holoduke_amount , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_NEWOWNER :
2023-10-05 02:10:47 +00:00
if ( bSet & & ( p - > newOwner = vValue . safeActor ( ) ) ) gameInput . ForceInputSync ( iPlayer ) ;
2023-10-02 10:14:32 +00:00
else SetGameVarID ( lVar2 , p - > newOwner , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_HURT_DELAY :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > hurt_delay = lValue ;
else SetGameVarID ( lVar2 , p - > hurt_delay , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_HBOMB_HOLD_DELAY :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > hbomb_hold_delay = lValue ;
else SetGameVarID ( lVar2 , p - > hbomb_hold_delay , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_JUMPING_COUNTER :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > jumping_counter = lValue ;
else SetGameVarID ( lVar2 , p - > jumping_counter , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_AIRLEFT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > airleft = lValue ;
else SetGameVarID ( lVar2 , p - > airleft , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-05-14 10:14:03 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_KNEE_INCS :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > oknee_incs = p - > knee_incs = lValue ;
else SetGameVarID ( lVar2 , p - > knee_incs , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-14 10:14:03 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_ACCESS_INCS :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > oaccess_incs = p - > access_incs = lValue ;
else SetGameVarID ( lVar2 , p - > access_incs , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-14 10:14:03 +00:00
2021-12-05 16:36:57 +00:00
case PLAYER_ACCESS_WALLNUM :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > access_wall = toWall ( lValue ) ;
else SetGameVarID ( lVar2 , fromWall ( p - > access_wall ) , sActor , sPlayer ) ;
2021-12-05 16:36:57 +00:00
break ;
case PLAYER_ACCESS_SPRITENUM :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > access_spritenum = vValue . safeActor ( ) ;
else SetGameVarID ( lVar2 , p - > access_spritenum , sActor , sPlayer ) ;
2021-12-05 16:36:57 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_KICKBACK_PIC :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > okickback_pic = p - > kickback_pic = lValue ;
else SetGameVarID ( lVar2 , p - > kickback_pic , sActor , sPlayer ) ;
2020-05-14 10:14:03 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_GOT_ACCESS :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > got_access = lValue ;
else SetGameVarID ( lVar2 , p - > got_access , sActor , sPlayer ) ;
2020-05-14 10:14:03 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_WEAPON_ANG :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > weapon_ang = lValue ;
else SetGameVarID ( lVar2 , p - > weapon_ang , sActor , sPlayer ) ;
2020-05-14 10:14:03 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_FIRSTAID_AMOUNT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > firstaid_amount = lValue ;
else SetGameVarID ( lVar2 , p - > firstaid_amount , sActor , sPlayer ) ;
2020-05-14 10:14:03 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_SOMETHINGONPLAYER :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > somethingonplayer = vValue . safeActor ( ) ;
else SetGameVarID ( lVar2 , ( p - > somethingonplayer ) , sActor , sPlayer ) ;
2020-05-14 10:14:03 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_ON_CRANE :
2023-10-05 02:10:47 +00:00
if ( bSet & & ( p - > on_crane = vValue . safeActor ( ) ) ) gameInput . ForceInputSync ( iPlayer ) ;
2023-10-02 10:14:32 +00:00
else SetGameVarID ( lVar2 , ( p - > on_crane ) , sActor , sPlayer ) ;
2021-12-05 16:36:57 +00:00
break ;
case PLAYER_I : // Read only, because this is very dangerous.
2023-10-02 10:14:32 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , pact , sActor , sPlayer ) ;
2021-12-05 16:36:57 +00:00
break ;
case PLAYER_ONE_PARALLAX_SECTNUM :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > one_parallax_sectnum = toSect ( lValue ) ;
else SetGameVarID ( lVar2 , fromSect ( p - > one_parallax_sectnum ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-14 10:14:03 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_OVER_SHOULDER_ON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > over_shoulder_on = lValue ;
else SetGameVarID ( lVar2 , p - > over_shoulder_on , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-14 10:14:03 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_RANDOM_CLUB_FRAME :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > orandom_club_frame = p - > random_club_frame = lValue ;
else SetGameVarID ( lVar2 , p - > random_club_frame , sActor , sPlayer ) ;
2020-05-14 10:14:03 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_FIST_INCS :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > ofist_incs = p - > fist_incs = lValue ;
else SetGameVarID ( lVar2 , p - > fist_incs , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-14 10:14:03 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_ONE_EIGHTY_COUNT :
2023-10-31 03:44:58 +00:00
if ( bSet ) p - > YawSpin = mapangle ( lValue ) ;
else SetGameVarID ( lVar2 , p - > YawSpin . Buildang ( ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_CHEAT_PHASE :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > cheat_phase = lValue ;
else SetGameVarID ( lVar2 , p - > cheat_phase , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_DUMMYPLAYERSPRITE :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > dummyplayersprite = vValue . safeActor ( ) ;
else SetGameVarID ( lVar2 , ( p - > dummyplayersprite ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_EXTRA_EXTRA8 :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > extra_extra8 = lValue ;
else SetGameVarID ( lVar2 , p - > extra_extra8 , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_QUICK_KICK :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > quick_kick = lValue ;
else SetGameVarID ( lVar2 , p - > quick_kick , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_HEAT_AMOUNT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > heat_amount = lValue ;
else SetGameVarID ( lVar2 , p - > heat_amount , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_ACTORSQU :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > actorsqu = vValue . safeActor ( ) ;
else SetGameVarID ( lVar2 , ( p - > actorsqu ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_TIMEBEFOREEXIT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > timebeforeexit = lValue ;
else SetGameVarID ( lVar2 , p - > timebeforeexit , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_CUSTOMEXITSOUND :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > customexitsound = lValue ;
else SetGameVarID ( lVar2 , p - > customexitsound , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_INTERFACE_TOGGLE_FLAG :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > interface_toggle_flag = lValue ;
else SetGameVarID ( lVar2 , p - > interface_toggle_flag , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_ROTSCRNANG :
2023-10-31 03:44:58 +00:00
if ( bSet ) p - > PrevViewAngles . Roll = p - > ViewAngles . Roll = - mapangle ( lValue ) ;
else SetGameVarID ( lVar2 , - p - > ViewAngles . Roll . Buildang ( ) , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_DEAD_FLAG :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > dead_flag = lValue ;
else SetGameVarID ( lVar2 , p - > dead_flag , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_SHOW_EMPTY_WEAPON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > show_empty_weapon = lValue ;
else SetGameVarID ( lVar2 , p - > show_empty_weapon , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_SCUBA_AMOUNT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > scuba_amount = lValue ;
else SetGameVarID ( lVar2 , p - > scuba_amount , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_JETPACK_AMOUNT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > jetpack_amount = lValue ;
else SetGameVarID ( lVar2 , p - > jetpack_amount , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_STEROIDS_AMOUNT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > steroids_amount = lValue ;
else SetGameVarID ( lVar2 , p - > steroids_amount , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_SHIELD_AMOUNT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > shield_amount = lValue ;
else SetGameVarID ( lVar2 , p - > shield_amount , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-14 07:07:07 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_HOLODUKE_ON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > holoduke_on = vValue . safeActor ( ) ;
else SetGameVarID ( lVar2 , ( p - > holoduke_on ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-14 07:07:07 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_PYCOUNT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > pycount = lValue ;
else SetGameVarID ( lVar2 , p - > pycount , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_WEAPON_POS :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > oweapon_pos = p - > weapon_pos = lValue ;
else SetGameVarID ( lVar2 , p - > weapon_pos , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_FRAG_PS :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > frag_ps = lValue ;
else SetGameVarID ( lVar2 , p - > frag_ps , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_TRANSPORTER_HOLD :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > transporter_hold = lValue ;
else SetGameVarID ( lVar2 , p - > transporter_hold , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_LAST_FULL_WEAPON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > last_full_weapon = lValue ;
else SetGameVarID ( lVar2 , p - > last_full_weapon , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_FOOTPRINTSHADE :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > footprintshade = lValue ;
else SetGameVarID ( lVar2 , p - > footprintshade , sActor , sPlayer ) ;
2020-05-14 17:23:36 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_BOOT_AMOUNT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > boot_amount = lValue ;
else SetGameVarID ( lVar2 , p - > boot_amount , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_GM :
2021-03-31 09:07:36 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , MODE_GAME , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-20 22:01:41 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_ON_WARPING_SECTOR :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > on_warping_sector = lValue ;
else SetGameVarID ( lVar2 , p - > on_warping_sector , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-20 22:01:41 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_FOOTPRINTCOUNT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > footprintcount = lValue ;
else SetGameVarID ( lVar2 , p - > footprintcount , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-20 22:01:41 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_HBOMB_ON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > hbomb_on = lValue ;
else SetGameVarID ( lVar2 , p - > hbomb_on , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-20 22:01:41 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_JUMPING_TOGGLE :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > jumping_toggle = lValue ;
else SetGameVarID ( lVar2 , p - > jumping_toggle , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-20 22:01:41 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_RAPID_FIRE_HOLD :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > rapid_fire_hold = lValue ;
else SetGameVarID ( lVar2 , p - > rapid_fire_hold , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-05-20 22:01:41 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_ON_GROUND :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > on_ground = lValue ;
else SetGameVarID ( lVar2 , p - > on_ground , sActor , sPlayer ) ;
2020-05-14 10:14:03 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_INVEN_ICON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > inven_icon = lValue ;
else SetGameVarID ( lVar2 , p - > inven_icon , sActor , sPlayer ) ;
2020-05-14 10:14:03 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_BUTTONPALETTE :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > buttonpalette = lValue ;
else SetGameVarID ( lVar2 , p - > buttonpalette , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_JETPACK_ON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > jetpack_on = lValue ;
else SetGameVarID ( lVar2 , p - > jetpack_on , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_SPRITEBRIDGE :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > spritebridge = lValue ;
else SetGameVarID ( lVar2 , p - > spritebridge , sActor , sPlayer ) ;
2020-05-14 10:14:03 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_LASTRANDOMSPOT :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > lastrandomspot = lValue ;
else SetGameVarID ( lVar2 , p - > lastrandomspot , sActor , sPlayer ) ;
2020-05-14 10:14:03 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_SCUBA_ON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > scuba_on = lValue ;
else SetGameVarID ( lVar2 , p - > scuba_on , sActor , sPlayer ) ;
2020-05-14 10:14:03 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_FOOTPRINTPAL :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > footprintpal = lValue ;
else SetGameVarID ( lVar2 , p - > footprintpal , sActor , sPlayer ) ;
2020-05-14 10:14:03 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_HEAT_ON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > heat_on = lValue ;
else SetGameVarID ( lVar2 , p - > heat_on , sActor , sPlayer ) ;
2020-05-14 10:14:03 +00:00
break ;
2020-05-14 17:23:36 +00:00
2020-09-17 20:36:09 +00:00
case PLAYER_HOLSTER_WEAPON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > holster_weapon = lValue ;
else SetGameVarID ( lVar2 , p - > holster_weapon , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_FALLING_COUNTER :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > falling_counter = lValue ;
else SetGameVarID ( lVar2 , p - > falling_counter , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_GOTWEAPON :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > gotweapon [ lParm2 ] = ! ! lValue ;
else SetGameVarID ( lVar2 , p - > gotweapon [ lParm2 ] , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_REFRESH_INVENTORY :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > refresh_inventory = lValue ;
else SetGameVarID ( lVar2 , p - > refresh_inventory , sActor , sPlayer ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case PLAYER_TOGGLE_KEY_FLAG :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > toggle_key_flag = lValue ;
else SetGameVarID ( lVar2 , p - > toggle_key_flag , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case PLAYER_KNUCKLE_INCS :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > knuckle_incs = lValue ;
else SetGameVarID ( lVar2 , p - > knuckle_incs , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case PLAYER_WALKING_SND_TOGGLE :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > walking_snd_toggle = lValue ;
else SetGameVarID ( lVar2 , p - > walking_snd_toggle , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case PLAYER_PALOOKUP :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > palookup = lValue ;
else SetGameVarID ( lVar2 , p - > palookup , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case PLAYER_HARD_LANDING :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > ohard_landing = p - > hard_landing = lValue ;
else SetGameVarID ( lVar2 , p - > hard_landing , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2020-10-10 05:59:00 +00:00
case PLAYER_RETURN_TO_CENTER :
2023-10-02 10:14:32 +00:00
if ( bSet ) p - > cmd . ucmd . actions | = SB_CENTERVIEW ;
else SetGameVarID ( lVar2 , p - > cmd . ucmd . actions & SB_CENTERVIEW ? int ( abs ( ( pact - > spr . Angles . Pitch * ( DAngle : : fromDeg ( 9. ) / GetMaxPitch ( ) ) ) . Degrees ( ) ) ) : 0 , sActor , sPlayer ) ;
2020-10-10 05:59:00 +00:00
break ;
2020-09-17 20:36:09 +00:00
default :
2021-03-31 09:07:36 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , 0 , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
}
return ;
}
////////////////////
2021-11-07 11:53:48 +00:00
void DoWall ( bool bSet , int lVar1 , int lLabelID , int lVar2 , DDukeActor * sActor , int sPlayer , int lParm2 )
2020-09-17 20:36:09 +00:00
{
2021-12-05 16:36:57 +00:00
auto lValue = GetGameVarID ( lVar2 , sActor , sPlayer ) . safeValue ( ) ;
auto vWall = GetGameVarID ( lVar1 , sActor , sPlayer ) ;
2021-12-21 09:51:41 +00:00
auto iWall = vWall . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
2021-12-21 08:54:21 +00:00
if ( iWall < 0 | | iWall > = ( int ) wall . Size ( ) | | vWall . isActor ( ) )
2020-09-17 20:36:09 +00:00
{
2021-03-31 09:07:36 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , 0 , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
return ;
}
2021-11-06 23:29:16 +00:00
auto wallp = & wall [ iWall ] ;
2020-09-17 20:36:09 +00:00
// All fields affecting map geometry have been made read-only!
switch ( lLabelID )
{
case WALL_X :
2022-10-12 17:00:29 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , int ( wallp - > pos . X / maptoworld ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_Y :
2022-10-12 17:00:29 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , int ( wallp - > pos . Y / maptoworld ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_POINT2 :
2021-11-06 23:29:16 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , wallp - > point2 , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_NEXTWALL :
2021-11-06 23:29:16 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , wallp - > nextwall , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_NEXTSECTOR :
2021-11-06 23:29:16 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , wallp - > nextsector , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_CSTAT :
2021-12-18 14:36:50 +00:00
if ( bSet ) wallp - > cstat = EWallFlags : : FromInt ( lValue ) ;
2021-11-06 23:29:16 +00:00
else SetGameVarID ( lVar2 , wallp - > cstat , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_PICNUM :
2022-12-06 13:14:10 +00:00
if ( bSet ) wallp - > setwalltexture ( tileGetTextureID ( lValue ) ) ;
2022-12-10 18:03:17 +00:00
else SetGameVarID ( lVar2 , legacyTileNum ( wallp - > walltexture ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_OVERPICNUM :
2022-12-06 13:14:10 +00:00
if ( bSet ) wallp - > setovertexture ( tileGetTextureID ( lValue ) ) ;
2022-12-10 18:03:17 +00:00
else SetGameVarID ( lVar2 , legacyTileNum ( wallp - > overtexture ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_SHADE :
2021-11-06 23:29:16 +00:00
if ( bSet ) wallp - > shade = lValue ;
else SetGameVarID ( lVar2 , wallp - > shade , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_PAL :
2021-11-06 23:29:16 +00:00
if ( bSet ) wallp - > pal = lValue ;
else SetGameVarID ( lVar2 , wallp - > pal , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_XREPEAT :
2022-10-07 22:02:10 +00:00
if ( bSet ) wallp - > xrepeat = lValue ;
else SetGameVarID ( lVar2 , wallp - > xrepeat , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_YREPEAT :
2022-10-07 22:02:10 +00:00
if ( bSet ) wallp - > yrepeat = lValue ;
else SetGameVarID ( lVar2 , wallp - > yrepeat , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_XPANNING :
2021-11-06 23:29:16 +00:00
if ( bSet ) wallp - > xpan_ = ( float ) ( lValue & 255 ) ;
else SetGameVarID ( lVar2 , wallp - > xpan ( ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_YPANNING :
2021-11-06 23:29:16 +00:00
if ( bSet ) wallp - > ypan_ = ( float ) ( lValue & 255 ) ;
else SetGameVarID ( lVar2 , wallp - > ypan ( ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_LOTAG :
2021-11-06 23:29:16 +00:00
if ( bSet ) wallp - > lotag = lValue ;
else SetGameVarID ( lVar2 , wallp - > lotag , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_HITAG :
2021-11-06 23:29:16 +00:00
if ( bSet ) wallp - > hitag = lValue ;
else SetGameVarID ( lVar2 , wallp - > hitag , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case WALL_EXTRA :
2021-11-06 23:29:16 +00:00
if ( bSet ) wallp - > extra = lValue ;
else SetGameVarID ( lVar2 , wallp - > extra , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
default :
break ;
}
return ;
}
2021-11-07 11:53:48 +00:00
void DoSector ( bool bSet , int lVar1 , int lLabelID , int lVar2 , DDukeActor * sActor , int sPlayer , int lParm2 )
2020-09-17 20:36:09 +00:00
{
int iSector ;
int lValue ;
2021-12-05 16:36:57 +00:00
bool no = false ;
2020-09-17 20:36:09 +00:00
if ( lVar1 = = g_iThisActorID )
{
// if they've asked for 'this', then use 'this'...
2021-12-30 15:39:43 +00:00
iSector = sActor - > sectno ( ) ;
2020-09-17 20:36:09 +00:00
}
else
{
2021-12-05 16:36:57 +00:00
auto vv = GetGameVarID ( lVar1 , sActor , sPlayer ) ;
no = vv . isActor ( ) ;
iSector = vv . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
}
2021-12-21 09:51:41 +00:00
if ( iSector < 0 | | iSector > = ( int ) sector . Size ( ) | | no )
2020-09-17 20:36:09 +00:00
{
2021-03-31 09:07:36 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , 0 , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
return ;
}
2021-12-05 16:36:57 +00:00
lValue = GetGameVarID ( lVar2 , sActor , sPlayer ) . safeValue ( ) ;
2021-11-06 22:05:25 +00:00
auto sectp = & sector [ iSector ] ;
2020-09-17 20:36:09 +00:00
// All fields affecting map geometry have been made read-only!
switch ( lLabelID )
{
case SECTOR_WALLPTR :
2022-11-15 14:44:33 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , wallindex ( sectp - > walls . Data ( ) ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_WALLNUM :
2022-11-15 13:59:28 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , sectp - > walls . Size ( ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_CEILINGZ :
2022-08-28 09:34:54 +00:00
if ( bSet ) sectp - > setceilingz ( lValue * zmaptoworld ) ;
else SetGameVarID ( lVar2 , ( int ) ( sectp - > ceilingz / zmaptoworld ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_FLOORZ :
2022-08-28 09:34:54 +00:00
if ( bSet ) sectp - > setfloorz ( lValue * zmaptoworld ) ;
else SetGameVarID ( lVar2 , ( int ) ( sectp - > floorz / zmaptoworld ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_CEILINGSTAT :
2021-12-18 13:08:57 +00:00
if ( bSet ) sectp - > ceilingstat = ESectorFlags : : FromInt ( lValue ) ;
2021-11-06 22:05:25 +00:00
else SetGameVarID ( lVar2 , sectp - > ceilingstat , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_FLOORSTAT :
2021-12-18 13:08:57 +00:00
if ( bSet ) sectp - > floorstat = ESectorFlags : : FromInt ( lValue ) ;
2021-11-06 22:05:25 +00:00
else SetGameVarID ( lVar2 , sectp - > floorstat , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_CEILINGPICNUM :
2022-12-06 10:47:56 +00:00
if ( bSet ) sectp - > setceilingtexture ( tileGetTextureID ( lValue ) ) ;
2022-12-09 09:48:47 +00:00
else SetGameVarID ( lVar2 , legacyTileNum ( sectp - > ceilingtexture ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_CEILINGSLOPE :
2021-12-17 22:33:16 +00:00
if ( bSet ) sectp - > setceilingslope ( lValue ) ;
2021-11-06 22:05:25 +00:00
else SetGameVarID ( lVar2 , sectp - > ceilingheinum , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_CEILINGSHADE :
2021-11-06 22:05:25 +00:00
if ( bSet ) sectp - > ceilingshade = lValue ;
else SetGameVarID ( lVar2 , sectp - > ceilingshade , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_CEILINGPAL :
2021-11-06 22:05:25 +00:00
if ( bSet ) sectp - > ceilingpal = lValue ;
else SetGameVarID ( lVar2 , sectp - > ceilingpal , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_CEILINGXPANNING :
2021-11-06 22:05:25 +00:00
if ( bSet ) sectp - > ceilingxpan_ = ( float ) ( lValue & 255 ) ;
else SetGameVarID ( lVar2 , sectp - > ceilingxpan ( ) , sActor , sPlayer ) ;
2020-11-25 19:52:06 +00:00
break ;
case SECTOR_CEILINGYPANNING :
2021-11-06 22:05:25 +00:00
if ( bSet ) sectp - > ceilingypan_ = ( float ) ( lValue & 255 ) ;
else SetGameVarID ( lVar2 , sectp - > ceilingypan ( ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_FLOORPICNUM :
2022-12-06 10:47:56 +00:00
if ( bSet ) sectp - > setfloortexture ( tileGetTextureID ( lValue ) ) ;
2022-12-09 09:48:47 +00:00
else SetGameVarID ( lVar2 , legacyTileNum ( sectp - > floortexture ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_FLOORSLOPE :
2021-12-17 22:33:16 +00:00
if ( bSet ) sectp - > setfloorslope ( lValue ) ;
2021-11-06 22:05:25 +00:00
else SetGameVarID ( lVar2 , sectp - > floorheinum , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_FLOORSHADE :
2021-11-06 22:05:25 +00:00
if ( bSet ) sectp - > floorshade = lValue ;
else SetGameVarID ( lVar2 , sectp - > floorshade , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_FLOORPAL :
2021-11-06 22:05:25 +00:00
if ( bSet ) sectp - > floorpal = lValue ;
else SetGameVarID ( lVar2 , sectp - > floorpal , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_FLOORXPANNING :
2021-11-06 22:05:25 +00:00
if ( bSet ) sectp - > floorxpan_ = ( float ) ( lValue & 255 ) ;
else SetGameVarID ( lVar2 , sectp - > floorxpan ( ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_FLOORYPANNING :
2021-11-06 22:05:25 +00:00
if ( bSet ) sectp - > floorypan_ = ( float ) ( lValue & 255 ) ;
else SetGameVarID ( lVar2 , sectp - > floorypan ( ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_VISIBILITY :
2021-11-06 22:05:25 +00:00
if ( bSet ) sectp - > visibility = lValue ;
else SetGameVarID ( lVar2 , sectp - > visibility , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_LOTAG :
2021-11-06 22:05:25 +00:00
if ( bSet ) sectp - > lotag = lValue ;
else SetGameVarID ( lVar2 , sectp - > lotag , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_HITAG :
2021-11-06 22:05:25 +00:00
if ( bSet ) sectp - > hitag = lValue ;
else SetGameVarID ( lVar2 , sectp - > hitag , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case SECTOR_EXTRA :
2021-11-06 22:05:25 +00:00
if ( bSet ) sectp - > extra = lValue ;
else SetGameVarID ( lVar2 , sectp - > extra , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
default :
break ;
}
return ;
}
2021-12-05 16:36:57 +00:00
2020-10-23 17:07:33 +00:00
void DoActor ( bool bSet , int lVar1 , int lLabelID , int lVar2 , DDukeActor * sActor , int sPlayer , int lParm2 )
2020-09-17 20:36:09 +00:00
{
2021-12-05 16:36:57 +00:00
auto vValue = GetGameVarID ( lVar2 , sActor , sPlayer ) ;
auto lValue = vValue . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
2020-10-23 17:07:33 +00:00
DDukeActor * act ;
2020-09-17 20:36:09 +00:00
if ( lVar1 = = g_iThisActorID )
{
// if they've asked for 'this', then use 'this'...
2020-10-23 17:07:33 +00:00
act = sActor ;
2020-09-17 20:36:09 +00:00
}
else
{
2021-12-05 16:36:57 +00:00
act = GetGameVarID ( lVar1 , sActor , sPlayer ) . safeActor ( ) ;
2020-09-17 20:36:09 +00:00
}
2021-12-05 16:36:57 +00:00
if ( ! act )
2020-09-17 20:36:09 +00:00
{
2021-03-31 09:07:36 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , 0 , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
return ;
}
switch ( lLabelID )
{
case ACTOR_X :
2022-10-12 17:00:29 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , int ( act - > spr . pos . X / maptoworld ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_Y :
2022-10-12 17:00:29 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , int ( act - > spr . pos . Y / maptoworld ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_Z :
2022-10-12 17:00:29 +00:00
if ( ! bSet ) SetGameVarID ( lVar2 , int ( act - > spr . pos . Z / zmaptoworld ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_CSTAT :
2021-12-21 19:29:46 +00:00
if ( bSet ) act - > spr . cstat = ESpriteFlags : : FromInt ( lValue ) ;
else SetGameVarID ( lVar2 , act - > spr . cstat , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_SHADE :
2021-12-21 19:29:46 +00:00
if ( bSet ) act - > spr . shade = lValue ;
else SetGameVarID ( lVar2 , act - > spr . shade , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_PAL :
2021-12-21 19:29:46 +00:00
if ( bSet ) act - > spr . pal = lValue ;
else SetGameVarID ( lVar2 , act - > spr . pal , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_CLIPDIST :
2022-10-04 17:22:46 +00:00
if ( bSet ) act - > clipdist = lValue * 0.25 ;
else SetGameVarID ( lVar2 , int ( act - > clipdist * 4 ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_DETAIL :
2020-10-24 05:25:25 +00:00
if ( bSet ) act - > spriteextra = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , act - > spriteextra , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_XREPEAT :
2022-10-07 21:46:28 +00:00
if ( bSet ) act - > spr . scale . X = ( lValue * REPEAT_SCALE ) ;
2022-10-07 21:33:37 +00:00
else SetGameVarID ( lVar2 , int ( act - > spr . scale . X * INV_REPEAT_SCALE ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_YREPEAT :
2022-10-07 21:46:28 +00:00
if ( bSet ) act - > spr . scale . Y = ( lValue * REPEAT_SCALE ) ;
2022-10-07 21:33:37 +00:00
else SetGameVarID ( lVar2 , int ( act - > spr . scale . Y * INV_REPEAT_SCALE ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_XOFFSET :
2021-12-21 19:29:46 +00:00
if ( bSet ) act - > spr . xoffset = lValue ;
else SetGameVarID ( lVar2 , act - > spr . xoffset , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_YOFFSET :
2021-12-21 19:29:46 +00:00
if ( bSet ) act - > spr . yoffset = lValue ;
else SetGameVarID ( lVar2 , act - > spr . yoffset , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2021-12-05 16:36:57 +00:00
case ACTOR_SECTNUM : // made read only because this is not safe.
if ( ! bSet ) /*changespritesect(iActor, lValue);
2021-12-30 15:39:43 +00:00
else */ SetGameVarID ( lVar2 , act - > sectno ( ) , sActor , sPlayer ) ;
2021-12-05 16:36:57 +00:00
break ;
case ACTOR_STATNUM :
if ( ! bSet ) /*changespritestat(iActor, lValue);
2021-12-21 19:29:46 +00:00
else */ SetGameVarID ( lVar2 , act - > spr . statnum , sActor , sPlayer ) ;
2021-12-05 16:36:57 +00:00
break ;
2020-09-17 20:36:09 +00:00
case ACTOR_ANG :
2022-11-25 12:13:50 +00:00
if ( bSet ) act - > spr . Angles . Yaw = DAngle : : fromBuild ( lValue ) ;
else SetGameVarID ( lVar2 , act - > spr . Angles . Yaw . Buildang ( ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_OWNER :
2021-12-05 16:36:57 +00:00
// there is no way to handle this well because we do not know whether this is an actor or not. Pity.
2022-05-23 22:30:41 +00:00
if ( bSet ) act - > spr . intowner = lValue ;
else SetGameVarID ( lVar2 , act - > spr . intowner , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_XVEL :
2022-09-13 16:24:02 +00:00
if ( bSet ) act - > vel . X = lValue * maptoworld ;
2022-10-12 17:00:29 +00:00
else SetGameVarID ( lVar2 , int ( act - > vel . X / maptoworld ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_YVEL :
2022-09-01 16:15:52 +00:00
if ( bSet ) act - > spr . yint = lValue ;
else SetGameVarID ( lVar2 , act - > spr . yint , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_ZVEL :
2022-09-13 16:24:02 +00:00
if ( bSet ) act - > vel . Z = lValue * zmaptoworld ;
2022-10-12 17:00:29 +00:00
else SetGameVarID ( lVar2 , int ( act - > vel . Z / zmaptoworld ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_LOTAG :
2021-12-21 19:29:46 +00:00
if ( bSet ) act - > spr . lotag = lValue ;
else SetGameVarID ( lVar2 , act - > spr . lotag , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HITAG :
2021-12-21 19:29:46 +00:00
if ( bSet ) act - > spr . hitag = lValue ;
else SetGameVarID ( lVar2 , act - > spr . hitag , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_EXTRA :
2021-12-21 19:29:46 +00:00
if ( bSet ) act - > spr . extra = lValue ;
else SetGameVarID ( lVar2 , act - > spr . extra , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTCGG :
2020-10-24 05:25:25 +00:00
if ( bSet ) act - > cgg = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , act - > cgg , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTANG :
2022-09-11 22:11:44 +00:00
if ( bSet ) act - > hitang = mapangle ( lValue ) ;
else SetGameVarID ( lVar2 , act - > hitang . Buildang ( ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTEXTRA :
2022-01-23 23:10:25 +00:00
if ( bSet ) act - > hitextra = lValue ;
else SetGameVarID ( lVar2 , act - > hitextra , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2021-12-05 16:36:57 +00:00
case ACTOR_HTOWNER :
if ( bSet ) act - > hitOwnerActor = vValue . safeActor ( ) ;
else SetGameVarID ( lVar2 , act - > hitOwnerActor , sActor , sPlayer ) ;
break ;
2020-09-17 20:36:09 +00:00
case ACTOR_HTMOVFLAG :
2020-10-24 05:25:25 +00:00
if ( bSet ) act - > movflag = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , act - > movflag , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTTEMPANG :
2022-09-14 21:30:10 +00:00
if ( bSet ) act - > tempval = lValue ;
else SetGameVarID ( lVar2 , act - > tempval , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
2021-12-05 16:36:57 +00:00
case ACTOR_HTACTORSTAYPUT :
if ( bSet ) act - > actorstayput = toSect ( lValue ) ;
else SetGameVarID ( lVar2 , fromSect ( act - > actorstayput ) , sActor , sPlayer ) ;
break ;
2020-09-17 20:36:09 +00:00
case ACTOR_HTTIMETOSLEEP :
2020-10-24 05:25:25 +00:00
if ( bSet ) act - > timetosleep = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , act - > timetosleep , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTFLOORZ :
2022-02-03 23:44:13 +00:00
if ( bSet ) act - > floorz = lValue * zmaptoworld ;
2022-10-12 17:00:29 +00:00
else SetGameVarID ( lVar2 , int ( act - > floorz * ( 1 / zmaptoworld ) ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTCEILINGZ :
2022-02-03 23:44:13 +00:00
if ( bSet ) act - > ceilingz = lValue * zmaptoworld ;
2022-10-12 17:00:29 +00:00
else SetGameVarID ( lVar2 , int ( act - > ceilingz * ( 1 / zmaptoworld ) ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTLASTVX :
2022-09-12 20:58:52 +00:00
if ( bSet ) act - > ovel . X = lValue * maptoworld ;
2022-10-12 17:00:29 +00:00
else SetGameVarID ( lVar2 , int ( act - > ovel . X / maptoworld ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTLASTVY :
2022-09-12 20:58:52 +00:00
if ( bSet ) act - > ovel . Y = lValue * maptoworld ;
2022-10-12 17:00:29 +00:00
else SetGameVarID ( lVar2 , int ( act - > ovel . Y / maptoworld ) , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTG_T0 :
2022-12-22 08:49:42 +00:00
if ( bSet ) act - > counter = lValue ;
else SetGameVarID ( lVar2 , act - > counter , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTG_T1 :
2020-10-24 05:25:25 +00:00
if ( bSet ) act - > temp_data [ 1 ] = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , act - > temp_data [ 1 ] , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTG_T2 :
2020-10-24 05:25:25 +00:00
if ( bSet ) act - > temp_data [ 2 ] = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , act - > temp_data [ 2 ] , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTG_T3 :
2020-10-24 05:25:25 +00:00
if ( bSet ) act - > temp_data [ 3 ] = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , act - > temp_data [ 3 ] , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTG_T4 :
2020-10-24 05:25:25 +00:00
if ( bSet ) act - > temp_data [ 4 ] = lValue ;
2021-03-31 09:07:36 +00:00
else SetGameVarID ( lVar2 , act - > temp_data [ 4 ] , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
case ACTOR_HTG_T5 :
2022-12-22 08:49:42 +00:00
if ( bSet ) act - > temp_data [ 0 ] = lValue ;
else SetGameVarID ( lVar2 , act - > temp_data [ 0 ] , sActor , sPlayer ) ;
2020-09-17 20:36:09 +00:00
break ;
default :
break ;
}
return ;
}
2022-12-01 09:19:37 +00:00
//---------------------------------------------------------------------------
//
// what a lousy hack job... :(
//
//---------------------------------------------------------------------------
2023-10-02 19:03:59 +00:00
int CheckWeapRec ( DDukePlayer * p , DDukeActor * g_ac , int testonly )
2022-12-01 09:19:37 +00:00
{
int j ;
for ( j = 0 ; j < p - > weapreccnt ; j + + )
2022-12-30 18:25:02 +00:00
if ( p - > weaprecs [ j ] = = g_ac - > GetClass ( ) )
2022-12-01 09:19:37 +00:00
break ;
if ( testonly )
{
return ( j < p - > weapreccnt & & g_ac - > GetOwner ( ) = = g_ac ) ;
}
else if ( p - > weapreccnt < 32 )
{
2022-12-30 18:25:02 +00:00
p - > weaprecs [ p - > weapreccnt + + ] = g_ac - > GetClass ( ) ;
2022-12-01 09:19:37 +00:00
return ( g_ac - > GetOwner ( ) = = g_ac ) ;
}
return false ;
}
2020-09-17 20:36:09 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void ParseState : : parseifelse ( int condition )
{
if ( condition )
{
// skip 'else' pointer.. and...
insptr + = 2 ;
parse ( ) ;
}
else
{
insptr = & ScriptCode [ * ( insptr + 1 ) ] ;
if ( * insptr = = 10 )
{
// else...
// skip 'else' and...
insptr + = 2 ;
parse ( ) ;
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-23 18:13:35 +00:00
static int ifcanshoottarget ( DDukeActor * actor , int g_p , int g_x )
2020-09-17 20:36:09 +00:00
{
if ( g_x > 1024 )
{
2022-09-13 22:11:16 +00:00
double sclip ;
2022-09-13 16:24:02 +00:00
DAngle angdif ;
2020-09-17 20:36:09 +00:00
2022-10-07 21:33:37 +00:00
if ( badguy ( actor ) & & actor - > spr . scale . X > 0.875 )
2020-09-17 20:36:09 +00:00
{
2022-09-13 22:11:16 +00:00
sclip = 3084 / 16. ;
2022-09-13 16:24:02 +00:00
angdif = DAngle22_5 * 3 / 8 ;
2020-09-17 20:36:09 +00:00
}
else
{
2022-09-13 22:11:16 +00:00
sclip = 48 ;
2022-09-13 16:24:02 +00:00
angdif = DAngle22_5 / 8 ;
2020-09-17 20:36:09 +00:00
}
2020-10-23 18:13:35 +00:00
DDukeActor * hit ;
2022-09-13 22:11:16 +00:00
double hs = hitasprite ( actor , & hit ) ;
if ( hs = = INT_MAX )
2020-09-17 20:36:09 +00:00
{
return 1 ;
}
2022-09-13 22:11:16 +00:00
if ( hs > sclip )
2020-09-17 20:36:09 +00:00
{
2022-12-30 18:30:53 +00:00
if ( hit ! = nullptr & & hit - > GetClass ( ) = = actor - > GetClass ( ) )
2022-09-13 22:11:16 +00:00
return 0 ;
2020-09-17 20:36:09 +00:00
else
{
2022-11-25 12:13:50 +00:00
actor - > spr . Angles . Yaw + = angdif ;
2022-09-13 22:11:16 +00:00
hs = hitasprite ( actor , & hit ) ;
2022-11-25 12:13:50 +00:00
actor - > spr . Angles . Yaw - = angdif ;
2022-09-13 22:11:16 +00:00
if ( hs > sclip )
2020-09-17 20:36:09 +00:00
{
2022-12-30 18:30:53 +00:00
if ( hit ! = nullptr & & hit - > GetClass ( ) = = actor - > GetClass ( ) )
2022-09-13 22:11:16 +00:00
return 0 ;
2020-09-17 20:36:09 +00:00
else
{
2022-11-25 12:13:50 +00:00
actor - > spr . Angles . Yaw + = angdif ;
2022-09-13 22:11:16 +00:00
hs = hitasprite ( actor , & hit ) ;
2022-11-25 12:13:50 +00:00
actor - > spr . Angles . Yaw - = angdif ;
2022-09-13 22:11:16 +00:00
if ( hs > 48 )
2020-09-17 20:36:09 +00:00
{
2022-12-30 18:30:53 +00:00
if ( hit ! = nullptr & & hit - > GetClass ( ) = = actor - > GetClass ( ) )
2022-09-13 22:11:16 +00:00
return 0 ;
return 1 ;
2020-09-17 20:36:09 +00:00
}
2022-09-13 22:11:16 +00:00
else return 0 ;
2020-09-17 20:36:09 +00:00
}
}
2022-09-13 22:11:16 +00:00
else return 0 ;
2020-09-17 20:36:09 +00:00
}
}
2022-09-13 22:11:16 +00:00
return 0 ;
2020-09-17 20:36:09 +00:00
}
2022-09-13 22:11:16 +00:00
return 1 ;
2020-09-17 20:36:09 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2023-10-02 19:03:59 +00:00
int ifcansee ( DDukeActor * actor , DDukePlayer * p )
2020-09-17 20:36:09 +00:00
{
int j ;
2020-10-23 18:14:50 +00:00
DDukeActor * tosee ;
2020-09-17 20:36:09 +00:00
// select sprite for monster to target
// if holoduke is on, let them target holoduke first.
//
2022-12-28 21:46:13 +00:00
if ( p - > holoduke_on ! = nullptr & & ! isRR ( ) )
2020-09-17 20:36:09 +00:00
{
2022-12-28 21:46:13 +00:00
tosee = p - > holoduke_on ;
2022-08-22 16:39:33 +00:00
j = cansee ( actor - > spr . pos . plusZ ( - zrand ( 32 ) ) , actor - > sector ( ) , tosee - > spr . pos , tosee - > sector ( ) ) ;
2020-09-17 20:36:09 +00:00
if ( j = = 0 )
{
// they can't see player's holoduke
2020-10-23 18:14:50 +00:00
// check for player..
2022-12-28 21:46:13 +00:00
tosee = p - > GetActor ( ) ;
2020-09-17 20:36:09 +00:00
}
}
2022-12-28 21:46:13 +00:00
else tosee = p - > GetActor ( ) ; // holoduke not on. look for player
2020-09-17 20:36:09 +00:00
// can they see player, (or player's holoduke)
2022-08-22 16:39:33 +00:00
j = cansee ( actor - > spr . pos . plusZ ( - zrand ( 48 ) ) , actor - > sector ( ) , tosee - > spr . pos . plusZ ( isRR ( ) ? - 28 : - 24 ) , tosee - > sector ( ) ) ;
2020-09-17 20:36:09 +00:00
if ( j = = 0 )
{
2020-10-23 18:14:50 +00:00
// search around for target player
// also modifies 'target' x&y if found.
2022-09-12 20:58:52 +00:00
j = furthestcanseepoint ( actor , tosee , actor - > ovel ) ;
2020-09-17 20:36:09 +00:00
}
else
{
// else, they did see it.
2020-10-23 18:14:50 +00:00
// save where we were looking..
2023-10-03 05:43:04 +00:00
actor - > ovel = tosee - > spr . pos . XY ( ) ;
2020-09-17 20:36:09 +00:00
}
2021-12-21 19:29:46 +00:00
if ( j = = 1 & & ( actor - > spr . statnum = = STAT_ACTOR | | actor - > spr . statnum = = STAT_STANDABLE ) )
2020-10-23 18:14:50 +00:00
actor - > timetosleep = SLEEPTIME ;
2020-09-17 20:36:09 +00:00
return j = = 1 ;
}
// int *it = 0x00589a04;
int ParseState : : parse ( void )
{
2023-11-08 05:18:00 +00:00
int j ;
2020-09-17 20:36:09 +00:00
2023-07-22 08:24:20 +00:00
if ( killit_flag ) return 1 ;
2020-09-17 20:36:09 +00:00
2023-10-03 00:29:28 +00:00
const auto p = getPlayer ( g_p ) ;
const auto pact = p - > GetActor ( ) ;
2020-09-17 20:36:09 +00:00
switch ( * insptr )
{
case concmd_ifrnd :
{
insptr + + ;
2022-12-14 17:26:40 +00:00
// HACK ALERT! The fire animation uses a broken ifrnd setup to delay its start because original CON has no variables
// But the chosen random value of 16/255 is too low and can cause delays of a second or more. (identical in Duke and RR.)
2022-12-29 08:56:14 +00:00
if ( g_ac - > IsKindOf ( RedneckFireClass ) & & g_ac - > curAction - > name = = NAME_None & & * insptr = = 16 )
2020-09-17 20:36:09 +00:00
{
parseifelse ( rnd ( 64 ) ) ;
break ;
}
parseifelse ( rnd ( * insptr ) ) ;
break ;
}
case concmd_ifcanshoottarget :
2020-10-23 18:13:35 +00:00
parseifelse ( ifcanshoottarget ( g_ac , g_p , g_x ) ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifcanseetarget :
2023-10-03 00:29:28 +00:00
j = cansee ( g_ac - > spr . pos . plusZ ( krand ( ) & 41 ) , g_ac - > sector ( ) , pact - > getPosWithOffsetZ ( ) , pact - > sector ( ) ) ;
2020-09-17 20:36:09 +00:00
parseifelse ( j ) ;
2020-10-23 18:16:03 +00:00
if ( j ) g_ac - > timetosleep = SLEEPTIME ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifnocover :
2023-10-03 00:29:28 +00:00
j = cansee ( g_ac - > spr . pos , g_ac - > sector ( ) , pact - > getPosWithOffsetZ ( ) , pact - > sector ( ) ) ;
2020-09-17 20:36:09 +00:00
parseifelse ( j ) ;
2020-10-23 18:16:03 +00:00
if ( j ) g_ac - > timetosleep = SLEEPTIME ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifactornotstayput :
2021-11-18 19:55:22 +00:00
parseifelse ( g_ac - > actorstayput = = nullptr ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifcansee :
2023-10-03 00:29:28 +00:00
parseifelse ( ifcansee ( g_ac , p ) ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifhitweapon :
2020-10-21 19:41:14 +00:00
parseifelse ( fi . ifhitbyweapon ( g_ac ) > = 0 ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifsquished :
2023-10-04 01:00:04 +00:00
parseifelse ( ifsquished ( g_ac , p ) = = 1 ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifdead :
{
2021-12-21 21:31:25 +00:00
j = g_ac - > spr . extra ;
2021-12-31 17:47:00 +00:00
if ( g_ac - > isPlayer ( ) )
2020-09-17 20:36:09 +00:00
j - - ;
parseifelse ( j < 0 ) ;
}
break ;
case concmd_ai :
2022-12-17 14:41:53 +00:00
{
2020-09-17 20:36:09 +00:00
insptr + + ;
2022-12-17 14:41:53 +00:00
auto ai = & ais [ * insptr ] ;
g_ac - > curAI = ai - > name ;
g_ac - > curAction = & actions [ ai - > action ] ;
g_ac - > curMove = & moves [ ai - > move ] ;
g_ac - > spr . hitag = ai - > moveflags ;
2022-12-17 14:55:01 +00:00
g_ac - > actioncounter = g_ac - > curframe = 0 ;
2022-12-22 08:49:42 +00:00
g_ac - > counter = 0 ;
2021-12-21 21:31:25 +00:00
if ( g_ac - > spr . hitag & random_angle )
2022-11-25 12:13:50 +00:00
g_ac - > spr . Angles . Yaw = randomAngle ( ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
2022-12-17 14:41:53 +00:00
}
2020-09-17 20:36:09 +00:00
case concmd_action :
insptr + + ;
2022-12-17 14:55:01 +00:00
g_ac - > actioncounter = g_ac - > curframe = 0 ;
2022-12-21 12:20:14 +00:00
g_ac - > curAction = & actions [ * insptr ] ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_ifpdistl :
insptr + + ;
parseifelse ( g_x < * insptr ) ;
2020-10-23 18:16:03 +00:00
if ( g_x > MAXSLEEPDIST & & g_ac - > timetosleep = = 0 )
g_ac - > timetosleep = SLEEPTIME ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifpdistg :
insptr + + ;
parseifelse ( g_x > * insptr ) ;
2020-10-23 18:16:03 +00:00
if ( g_x > MAXSLEEPDIST & & g_ac - > timetosleep = = 0 )
g_ac - > timetosleep = SLEEPTIME ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_else :
insptr = & ScriptCode [ * ( insptr + 1 ) ] ;
break ;
case concmd_addstrength :
insptr + + ;
2021-12-21 21:31:25 +00:00
g_ac - > spr . extra + = * insptr ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_strength :
insptr + + ;
2021-12-21 21:31:25 +00:00
g_ac - > spr . extra = * insptr ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_smacksprite :
switch ( krand ( ) & 1 )
{
case 0 :
2022-11-25 12:13:50 +00:00
g_ac - > spr . Angles . Yaw + = DAngle90 + randomAngle ( 90 ) ;
2020-09-17 20:36:09 +00:00
break ;
case 1 :
2022-11-25 12:13:50 +00:00
g_ac - > spr . Angles . Yaw - = DAngle90 + randomAngle ( 90 ) ;
2020-09-17 20:36:09 +00:00
break ;
}
insptr + + ;
break ;
case concmd_fakebubba :
insptr + + ;
2023-10-03 00:29:28 +00:00
fakebubbaspawn ( g_ac , p ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_rndmove :
2022-11-25 12:13:50 +00:00
g_ac - > spr . Angles . Yaw = randomAngle ( ) ;
2022-09-13 16:24:02 +00:00
g_ac - > vel . X = 25 / 16. ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_mamatrigger :
2023-10-03 00:29:28 +00:00
operateactivators ( 667 , p ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_mamaspawn :
2020-10-22 21:45:49 +00:00
mamaspawn ( g_ac ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_mamaquake :
2021-12-21 21:31:25 +00:00
if ( g_ac - > spr . pal = = 31 )
2022-11-30 16:15:44 +00:00
ud . earthquaketime = 4 ;
2021-12-21 21:31:25 +00:00
else if ( g_ac - > spr . pal = = 32 )
2022-11-30 16:15:44 +00:00
ud . earthquaketime = 6 ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_garybanjo :
2022-12-15 20:12:20 +00:00
garybanjo ( g_ac ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_motoloopsnd :
2020-10-23 18:16:57 +00:00
if ( ! S_CheckActorSoundPlaying ( g_ac , 411 ) )
S_PlayActorSound ( 411 , g_ac , CHAN_VOICE ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_ifgotweaponce :
insptr + + ;
if ( ud . coop > = 1 & & ud . multimode > 1 )
{
2023-10-03 00:29:28 +00:00
parseifelse ( CheckWeapRec ( p , g_ac , ! * insptr ) ) ;
2020-09-17 20:36:09 +00:00
}
else parseifelse ( 0 ) ;
break ;
case concmd_getlastpal :
insptr + + ;
2021-12-31 17:47:00 +00:00
if ( g_ac - > isPlayer ( ) )
2023-10-02 02:51:13 +00:00
g_ac - > spr . pal = getPlayer ( g_ac - > PlayerIndex ( ) ) - > palookup ;
2020-09-17 20:36:09 +00:00
else
{
2022-09-14 21:30:10 +00:00
g_ac - > spr . pal = ( uint8_t ) g_ac - > tempval ;
2020-09-17 20:36:09 +00:00
}
2022-09-14 21:30:10 +00:00
g_ac - > tempval = 0 ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_tossweapon :
insptr + + ;
2023-10-02 02:51:13 +00:00
fi . checkweapons ( getPlayer ( g_ac - > PlayerIndex ( ) ) ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_nullop :
insptr + + ;
break ;
case concmd_mikesnd :
insptr + + ;
2022-09-01 16:15:52 +00:00
if ( ! S_CheckActorSoundPlaying ( g_ac , g_ac - > spr . yint ) )
S_PlayActorSound ( g_ac - > spr . yint , g_ac , CHAN_VOICE ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_pkick :
insptr + + ;
2023-10-03 00:29:28 +00:00
playerkick ( p , g_ac ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_sizeto :
insptr + + ;
2022-12-15 20:12:20 +00:00
actorsizeto ( g_ac , * insptr * REPEAT_SCALE , * ( insptr + 1 ) * REPEAT_SCALE ) ;
insptr + = 2 ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_sizeat :
insptr + + ;
2022-10-07 21:46:28 +00:00
g_ac - > spr . scale . X = ( ( uint8_t ) * insptr * REPEAT_SCALE ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
2022-10-07 21:46:28 +00:00
g_ac - > spr . scale . Y = ( ( uint8_t ) * insptr * REPEAT_SCALE ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_shoot :
2022-12-22 11:36:16 +00:00
{
2020-09-17 20:36:09 +00:00
insptr + + ;
2022-12-22 11:36:16 +00:00
int type = * insptr ;
// hackery to separate RRRA's merged projectiles. We'd prefer not to keep this mess in the core implementation.
// Separating it here is easiest as long as the ZScript reimplementation explicitly takes care of these differences.
if ( isRRRA ( ) )
{
2022-12-29 08:56:14 +00:00
//if (g_ac->GetClass.TypeName == NAME_RedneckCheerleader && type == 3400) typecls = RedneckCheerBatonClass);
//if (g_ac->GetClass.TypeName == NAME_RedneckMama && type == 3390) typecls = RedneckRabbitBallClass);
//if (g_ac->GetClass.TypeName == NAME_RedneckMinion && type == 3390 && g_ac->spr.pal == 8) typecls = RedneckFrogBallClass);
//if (g_ac->GetClass.TypeName == NAME_RedneckMinion && type == 3390 && g_ac->spr.pal == 19)) typecls = RedneckShitBurnClass);
2022-12-22 11:36:16 +00:00
}
2022-12-29 09:56:10 +00:00
shoot ( g_ac , GetSpawnType ( * insptr ) ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
2022-12-22 11:36:16 +00:00
}
2020-09-17 20:36:09 +00:00
case concmd_ifsoundid :
insptr + + ;
2022-11-24 08:01:44 +00:00
parseifelse ( ( short ) * insptr = = ambienttags . SafeGet ( g_ac - > spr . detail , { } ) . lo ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifsounddist :
insptr + + ;
if ( * insptr = = 0 )
2022-11-24 08:01:44 +00:00
parseifelse ( ambienttags . SafeGet ( g_ac - > spr . detail , { } ) . hi > g_x ) ;
2020-09-17 20:36:09 +00:00
else if ( * insptr = = 1 )
2022-11-24 08:01:44 +00:00
parseifelse ( ambienttags . SafeGet ( g_ac - > spr . detail , { } ) . hi < g_x ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_soundtag :
insptr + + ;
2022-11-24 08:01:44 +00:00
S_PlayActorSound ( ambienttags . SafeGet ( g_ac - > spr . detail , { } ) . lo , g_ac ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_soundtagonce :
insptr + + ;
2022-11-24 08:01:44 +00:00
if ( ! S_CheckActorSoundPlaying ( g_ac , ambienttags . SafeGet ( g_ac - > spr . detail , { } ) . lo ) )
S_PlayActorSound ( ambienttags . SafeGet ( g_ac - > spr . detail , { } ) . lo , g_ac ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_soundonce :
insptr + + ;
2020-10-23 18:16:57 +00:00
if ( ! S_CheckSoundPlaying ( * insptr + + ) )
S_PlayActorSound ( * ( insptr - 1 ) , g_ac ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_stopsound :
insptr + + ;
2020-10-23 18:16:57 +00:00
if ( S_CheckSoundPlaying ( * insptr ) )
2021-03-31 09:07:36 +00:00
S_StopSound ( * insptr ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_globalsound :
insptr + + ;
if ( g_p = = screenpeek | | ud . coop = = 1 )
2023-10-02 02:51:13 +00:00
S_PlayActorSound ( * insptr , getPlayer ( screenpeek ) - > GetActor ( ) ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_smackbubba :
insptr + + ;
2021-12-21 21:31:25 +00:00
if ( ! isRRRA ( ) | | g_ac - > spr . pal ! = 105 )
2020-09-17 20:36:09 +00:00
{
setnextmap ( false ) ;
}
break ;
case concmd_mamaend :
insptr + + ;
2023-10-02 02:51:13 +00:00
getPlayer ( myconnectindex ) - > MamaEnd = 150 ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifactorhealthg :
insptr + + ;
2021-12-21 21:31:25 +00:00
parseifelse ( g_ac - > spr . extra > ( short ) * insptr ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifactorhealthl :
insptr + + ;
2021-12-21 21:31:25 +00:00
parseifelse ( g_ac - > spr . extra < ( short ) * insptr ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_sound :
insptr + + ;
2020-10-23 18:16:57 +00:00
S_PlayActorSound ( ( short ) * insptr , g_ac ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_tip :
insptr + + ;
2023-10-03 00:29:28 +00:00
p - > tipincs = 26 ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_iftipcow :
2022-12-31 16:58:14 +00:00
case concmd_ifhittruck : // both have the same code. Note that 'iftipcpw' ONLY works when used on the cow!
2020-10-23 18:16:57 +00:00
if ( g_ac - > spriteextra = = 1 ) //
2020-09-17 20:36:09 +00:00
{
j = 1 ;
2020-10-23 18:16:57 +00:00
g_ac - > spriteextra + + ;
2020-09-17 20:36:09 +00:00
}
else
j = 0 ;
parseifelse ( j > 0 ) ;
break ;
case concmd_tearitup :
insptr + + ;
2021-12-30 15:51:56 +00:00
tearitup ( g_ac - > sector ( ) ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_fall :
insptr + + ;
2021-12-21 21:31:25 +00:00
g_ac - > spr . xoffset = 0 ;
g_ac - > spr . yoffset = 0 ;
2022-12-30 13:28:59 +00:00
fall ( g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_enda :
case concmd_break :
case concmd_ends :
case concmd_endevent :
return 1 ;
case concmd_rightbrace :
insptr + + ;
return 1 ;
case concmd_addammo :
insptr + + ;
2023-10-03 00:29:28 +00:00
if ( ! playeraddammo ( p , * insptr , * ( insptr + 1 ) ) ) killit_flag = 2 ;
2020-09-17 20:36:09 +00:00
insptr + = 2 ;
break ;
case concmd_money :
insptr + + ;
2022-12-29 18:26:01 +00:00
lotsofstuff ( g_ac , * insptr , DukeMoneyClass ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_mail :
insptr + + ;
2022-12-29 18:26:01 +00:00
lotsofstuff ( g_ac , * insptr , DukeMailClass ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_sleeptime :
insptr + + ;
2020-10-23 18:16:57 +00:00
g_ac - > timetosleep = ( short ) * insptr ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_paper :
insptr + + ;
2022-12-29 18:26:01 +00:00
lotsofstuff ( g_ac , * insptr , DukePaperClass ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_addkills :
insptr + + ;
2023-10-03 00:29:28 +00:00
dokill ( p , g_ac , * insptr + + ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_lotsofglass :
insptr + + ;
2020-10-25 05:40:05 +00:00
spriteglass ( g_ac , * insptr ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_killit :
insptr + + ;
2023-07-22 08:24:20 +00:00
killit_flag = 1 ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_addweapon :
insptr + + ;
2023-10-03 00:29:28 +00:00
if ( ! playeraddweapon ( p , * insptr , * ( insptr + 1 ) ) ) killit_flag = 2 ;
2020-09-17 20:36:09 +00:00
insptr + = 2 ;
break ;
case concmd_debug :
insptr + + ;
Printf ( " %d \n " , * insptr ) ;
insptr + + ;
break ;
case concmd_endofgame :
insptr + + ;
2023-10-03 00:29:28 +00:00
p - > timebeforeexit = * insptr ;
p - > customexitsound = - 1 ;
2020-09-17 20:36:09 +00:00
ud . eog = true ;
insptr + + ;
break ;
case concmd_isdrunk : // todo: move out to player_r.
insptr + + ;
2023-10-03 00:29:28 +00:00
playerdrink ( p , * insptr + + ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_strafeleft :
insptr + + ;
2022-11-25 12:13:50 +00:00
movesprite_ex ( g_ac , DVector3 ( - g_ac - > spr . Angles . Yaw . Sin ( ) , g_ac - > spr . Angles . Yaw . Cos ( ) , g_ac - > vel . Z ) , CLIPMASK0 , coll ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_straferight :
insptr + + ;
2022-11-25 12:13:50 +00:00
movesprite_ex ( g_ac , DVector3 ( g_ac - > spr . Angles . Yaw . Sin ( ) , - g_ac - > spr . Angles . Yaw . Cos ( ) , g_ac - > vel . Z ) , CLIPMASK0 , coll ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_larrybird :
insptr + + ;
2023-10-03 00:29:28 +00:00
pact - > spr . pos . Z = pact - > sector ( ) - > ceilingz ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_destroyit :
insptr + + ;
2020-10-22 21:41:07 +00:00
destroyit ( g_ac ) ;
2020-09-17 20:36:09 +00:00
break ;
2022-12-15 14:18:46 +00:00
case concmd_iseat :
2020-09-17 20:36:09 +00:00
insptr + + ;
2023-10-03 00:29:28 +00:00
playereat ( p , * insptr + + , ! ! ( g_ac - > flags3 & SFLAG3_BIGHEALTH ) ) ;
2020-09-17 20:36:09 +00:00
break ;
2022-12-15 14:18:46 +00:00
case concmd_addphealth :
2020-09-17 20:36:09 +00:00
insptr + + ;
2023-10-03 00:29:28 +00:00
addphealth ( p , * insptr + + , ! ! ( g_ac - > flags3 & SFLAG3_BIGHEALTH ) ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_state :
{
auto tempscrptr = insptr + 2 ;
insptr = & ScriptCode [ * ( insptr + 1 ) ] ;
while ( 1 ) if ( parse ( ) ) break ;
insptr = tempscrptr ;
}
break ;
case concmd_leftbrace :
insptr + + ;
while ( 1 ) if ( parse ( ) ) break ;
break ;
case concmd_move :
2022-12-22 08:49:42 +00:00
g_ac - > counter = 0 ;
2020-09-17 20:36:09 +00:00
insptr + + ;
2022-12-21 12:32:00 +00:00
g_ac - > curMove = & moves [ * insptr ] ;
2020-09-17 20:36:09 +00:00
insptr + + ;
2021-12-21 21:31:25 +00:00
g_ac - > spr . hitag = * insptr ;
2020-09-17 20:36:09 +00:00
insptr + + ;
2021-12-21 21:31:25 +00:00
if ( g_ac - > spr . hitag & random_angle )
2022-11-25 12:13:50 +00:00
g_ac - > spr . Angles . Yaw = randomAngle ( ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_spawn :
insptr + + ;
2021-11-21 00:04:16 +00:00
if ( g_ac - > insector ( ) )
2022-12-31 18:56:41 +00:00
spawnsprite ( g_ac , * insptr ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_ifwasweapon :
case concmd_ifspawnedby : // these two are the same
insptr + + ;
2022-12-16 15:56:47 +00:00
parseifelse ( g_ac - > attackertype = = GetSpawnType ( * insptr ) ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifai :
insptr + + ;
2022-12-17 14:41:53 +00:00
parseifelse ( g_ac - > curAI = = ais [ * insptr ] . name ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifaction :
insptr + + ;
2022-12-21 12:20:14 +00:00
parseifelse ( ( g_ac - > curAction - actions . Data ( ) ) = = * insptr ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifactioncount :
insptr + + ;
2022-12-17 14:55:01 +00:00
parseifelse ( g_ac - > actioncounter > = * insptr ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_resetactioncount :
insptr + + ;
2022-12-17 14:55:01 +00:00
g_ac - > actioncounter = 0 ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_debris :
2022-11-14 22:55:46 +00:00
insptr + + ;
2023-01-01 12:05:42 +00:00
spawndebris ( g_ac , * insptr - ( isRR ( ) ? SCRAP_RR : SCRAP_DUKE ) , * ( insptr + 1 ) ) ; // must subtract the index of the first scrap tile.
2022-12-15 20:12:20 +00:00
insptr + = 2 ;
break ;
2020-09-17 20:36:09 +00:00
case concmd_count :
insptr + + ;
2022-12-22 08:49:42 +00:00
g_ac - > counter = ( short ) * insptr ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_cstator :
insptr + + ;
2021-12-21 21:31:25 +00:00
g_ac - > spr . cstat | = ESpriteFlags : : FromInt ( * insptr ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_clipdist :
insptr + + ;
2022-10-04 17:22:46 +00:00
g_ac - > clipdist = ( ( uint8_t ) * insptr ) * 0.25 ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_cstat :
insptr + + ;
2021-12-21 21:31:25 +00:00
g_ac - > spr . cstat = ESpriteFlags : : FromInt ( * insptr ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_ifmove :
insptr + + ;
2022-12-21 12:32:00 +00:00
parseifelse ( ( g_ac - > curMove - moves . Data ( ) ) = = * insptr ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_resetplayer :
insptr + + ;
2023-10-03 00:29:28 +00:00
playerreset ( p , g_ac ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifcoop :
parseifelse ( ud . coop | | numplayers > 2 ) ;
break ;
case concmd_ifonmud :
2022-12-09 09:48:47 +00:00
parseifelse ( abs ( g_ac - > spr . pos . Z - g_ac - > sector ( ) - > floorz ) < 32 & & ( tilesurface ( g_ac - > sector ( ) - > floortexture ) = = TSURF_MUDDY ) ! = 0 ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifonwater :
2022-08-28 09:34:54 +00:00
parseifelse ( abs ( g_ac - > spr . pos . Z - g_ac - > sector ( ) - > floorz ) < 32 & & g_ac - > sector ( ) - > lotag = = ST_1_ABOVE_WATER ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifmotofast :
2023-10-03 00:29:28 +00:00
parseifelse ( p - > MotoSpeed > 60 ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifonmoto :
2023-10-03 00:29:28 +00:00
parseifelse ( p - > OnMotorcycle = = 1 ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifonboat :
2023-10-03 00:29:28 +00:00
parseifelse ( p - > OnBoat = = 1 ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifsizedown :
2022-10-07 21:44:21 +00:00
g_ac - > spr . scale . X - = REPEAT_SCALE ;
g_ac - > spr . scale . Y - = REPEAT_SCALE ;
2022-10-07 21:33:37 +00:00
parseifelse ( g_ac - > spr . scale . X < = 5 * REPEAT_SCALE ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifwind :
parseifelse ( WindTime > 0 ) ;
break ;
case concmd_ifinwater :
2022-12-15 20:12:20 +00:00
parseifelse ( g_ac - > sector ( ) - > lotag = = ST_2_UNDERWATER ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifcount :
insptr + + ;
2022-12-22 08:49:42 +00:00
parseifelse ( g_ac - > counter > = * insptr ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifactor :
insptr + + ;
2022-12-30 18:30:53 +00:00
parseifelse ( g_ac - > GetClass ( ) = = GetSpawnType ( * insptr ) ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_resetcount :
insptr + + ;
2022-12-22 08:49:42 +00:00
g_ac - > counter = 0 ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_addinventory :
insptr + + ;
2023-10-03 00:29:28 +00:00
playeraddinventory ( p , g_ac , * insptr , * ( insptr + 1 ) ) ;
2022-12-15 20:12:20 +00:00
insptr + = 2 ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_hitradius :
2022-12-29 15:59:07 +00:00
hitradius ( g_ac , * ( insptr + 1 ) , * ( insptr + 2 ) , * ( insptr + 3 ) , * ( insptr + 4 ) , * ( insptr + 5 ) ) ;
2020-09-17 20:36:09 +00:00
insptr + = 6 ;
break ;
case concmd_ifp :
2023-11-08 05:18:00 +00:00
parseifelse ( checkp ( g_ac , p , * ( + + insptr ) ) ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifstrength :
insptr + + ;
2021-12-21 21:31:25 +00:00
parseifelse ( g_ac - > spr . extra < = * insptr ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_guts :
2022-11-22 22:21:45 +00:00
{
2020-09-17 20:36:09 +00:00
insptr + = 2 ;
2022-12-16 15:56:47 +00:00
auto clstype = GetSpawnType ( * ( insptr - 1 ) ) ;
if ( clstype ) spawnguts ( g_ac , clstype , * insptr ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
2022-11-22 22:21:45 +00:00
}
2020-09-17 20:36:09 +00:00
case concmd_slapplayer :
insptr + + ;
2023-10-03 00:29:28 +00:00
forceplayerangle ( p ) ;
p - > vel . XY ( ) - = pact - > spr . Angles . Yaw . ToVector ( ) * 8 ;
2020-09-17 20:36:09 +00:00
return 0 ;
case concmd_wackplayer :
insptr + + ;
2023-10-03 00:29:28 +00:00
wackplayer ( p ) ;
2020-09-17 20:36:09 +00:00
return 0 ;
case concmd_ifgapzl :
insptr + + ;
2022-02-03 23:55:12 +00:00
parseifelse ( int ( g_ac - > floorz - g_ac - > ceilingz ) < * insptr ) ; // Note: int cast here is needed to use the same truncation behavior as the old fixed point code.
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifhitspace :
2023-10-03 08:22:42 +00:00
parseifelse ( ! ! ( p - > cmd . ucmd . actions & SB_OPEN ) ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifoutside :
2021-12-30 15:51:56 +00:00
parseifelse ( g_ac - > sector ( ) - > ceilingstat & CSTAT_SECTOR_SKY ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifmultiplayer :
parseifelse ( ud . multimode > 1 ) ;
break ;
case concmd_operate :
insptr + + ;
2022-12-15 20:12:20 +00:00
actoroperate ( g_ac ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifinspace :
2022-11-25 16:43:13 +00:00
parseifelse ( ceilingspace ( g_ac - > sector ( ) ) ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_spritepal :
insptr + + ;
2021-12-31 17:47:00 +00:00
if ( ! g_ac - > isPlayer ( ) )
2022-09-14 21:30:10 +00:00
g_ac - > tempval = g_ac - > spr . pal ;
2021-12-21 21:31:25 +00:00
g_ac - > spr . pal = * insptr ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
2022-12-21 21:36:15 +00:00
case concmd_newpic :
2020-09-17 20:36:09 +00:00
case concmd_cactor :
2022-12-21 21:36:15 +00:00
{
2020-09-17 20:36:09 +00:00
insptr + + ;
2022-12-21 21:36:15 +00:00
auto info = spawnMap . CheckKey ( * insptr ) ;
if ( info ! = nullptr )
g_ac - > ChangeType ( info - > cls ) ;
2023-10-22 21:01:24 +00:00
else
g_ac - > ChangeType ( RUNTIME_CLASS ( DDukeActor ) ) ;
g_ac - > spr . setspritetexture ( tileGetTextureID ( * insptr ) ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
2022-12-21 21:36:15 +00:00
}
2020-09-17 20:36:09 +00:00
case concmd_ifbulletnear :
2020-10-21 23:12:16 +00:00
parseifelse ( dodge ( g_ac ) = = 1 ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifrespawn :
2020-10-23 18:19:44 +00:00
if ( badguy ( g_ac ) )
2020-09-17 20:36:09 +00:00
parseifelse ( ud . respawn_monsters ) ;
2021-12-21 21:31:25 +00:00
else if ( inventory ( g_ac ) )
2020-09-17 20:36:09 +00:00
parseifelse ( ud . respawn_inventory ) ;
else
parseifelse ( ud . respawn_items ) ;
break ;
case concmd_iffloordistl :
insptr + + ;
2022-02-03 23:55:12 +00:00
parseifelse ( g_ac - > floorz - g_ac - > spr . pos . Z < = * insptr ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifceilingdistl :
insptr + + ;
2022-02-03 23:55:12 +00:00
parseifelse ( g_ac - > spr . pos . Z - g_ac - > ceilingz < = * insptr ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_palfrom :
insptr + + ;
2023-10-03 00:29:28 +00:00
SetPlayerPal ( p , PalEntry ( insptr [ 0 ] , insptr [ 1 ] , insptr [ 2 ] , insptr [ 3 ] ) ) ;
2020-09-17 20:36:09 +00:00
insptr + = 4 ;
break ;
/* case 74:
insptr + + ;
2020-11-01 16:57:40 +00:00
getglobalz ( g_ac ) ;
2020-10-23 18:19:44 +00:00
parseifelse ( ( ( g_ac - > floorz - g_ac - > ceilingz ) > > 8 ) > = * insptr ) ;
2020-09-17 20:36:09 +00:00
break ;
*/
case concmd_addlog :
2021-12-24 09:53:27 +00:00
{ int instr ;
2020-09-17 20:36:09 +00:00
int lFile ;
insptr + + ;
lFile = * ( insptr + + ) ; // file
2021-12-24 09:53:27 +00:00
instr = * ( insptr + + ) ; // line
2020-09-17 20:36:09 +00:00
// this was only printing file name and line number as debug output.
break ;
}
case concmd_addlogvar :
2021-12-24 09:53:27 +00:00
{ int instr ;
2020-09-17 20:36:09 +00:00
int lFile ;
insptr + + ;
lFile = * ( insptr + + ) ; // file
2021-12-24 09:53:27 +00:00
instr = * ( insptr + + ) ; // l=Line number, *instpr=varID
2020-09-17 20:36:09 +00:00
if ( ( * insptr > = iGameVarCount )
| | * insptr < 0
)
{
// invalid varID
insptr + + ;
break ; // out of switch
}
DPrintf ( DMSG_NOTIFY , " ADDLOGVAR: " ) ;
2021-12-30 09:30:21 +00:00
2020-09-17 20:36:09 +00:00
if ( aGameVars [ * insptr ] . dwFlags & GAMEVAR_FLAG_READONLY )
{
DPrintf ( DMSG_NOTIFY , " (read-only) " ) ;
}
if ( aGameVars [ * insptr ] . dwFlags & GAMEVAR_FLAG_PERPLAYER )
{
DPrintf ( DMSG_NOTIFY , " (Per Player. Player=%d) " , g_p ) ;
}
else if ( aGameVars [ * insptr ] . dwFlags & GAMEVAR_FLAG_PERACTOR )
{
2020-10-25 05:40:05 +00:00
DPrintf ( DMSG_NOTIFY , " (Per Actor. Actor=%p) " , g_ac ) ;
2020-09-17 20:36:09 +00:00
}
else
{
DPrintf ( DMSG_NOTIFY , " (Global) " ) ;
}
2021-12-07 22:27:12 +00:00
DPrintf ( DMSG_NOTIFY , " =%d " , GetGameVarID ( * insptr , g_ac , g_p ) . safeValue ( ) ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
}
case concmd_setvar :
{ int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2020-11-01 17:23:09 +00:00
SetGameVarID ( i , * insptr , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
}
case concmd_setvarvar :
{ int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2020-11-01 17:23:09 +00:00
SetGameVarID ( i , GetGameVarID ( * insptr , g_ac , g_p ) , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
// aGameVars[i].lValue = aGameVars[*insptr].lValue;
insptr + + ;
break ;
}
case concmd_addvar :
{ int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
SetGameVarID ( i , GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) + * insptr , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
}
2021-12-30 09:30:21 +00:00
2020-09-17 20:36:09 +00:00
case concmd_addvarvar :
{ int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
SetGameVarID ( i , GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) + GetGameVarID ( * insptr , g_ac , g_p ) . safeValue ( ) , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
}
case concmd_ifvarvare :
{
int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
j = 0 ;
2021-12-05 16:36:57 +00:00
if ( GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) = = GetGameVarID ( * ( insptr ) , g_ac , g_p ) . safeValue ( ) )
2020-09-17 20:36:09 +00:00
{
j = 1 ;
}
parseifelse ( j ) ;
break ;
}
case concmd_ifvarvarg :
{
int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
j = 0 ;
2021-12-05 16:36:57 +00:00
if ( GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) > GetGameVarID ( * ( insptr ) , g_ac , g_p ) . safeValue ( ) )
2020-09-17 20:36:09 +00:00
{
j = 1 ;
}
parseifelse ( j ) ;
break ;
}
case concmd_ifvarvarl :
{
int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
j = 0 ;
2021-12-05 16:36:57 +00:00
if ( GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) < GetGameVarID ( * ( insptr ) , g_ac , g_p ) . safeValue ( ) )
2020-09-17 20:36:09 +00:00
{
j = 1 ;
}
parseifelse ( j ) ;
break ;
}
case concmd_ifvare :
{
int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
j = 0 ;
2021-12-05 16:36:57 +00:00
if ( GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) = = * insptr )
2020-09-17 20:36:09 +00:00
{
j = 1 ;
}
parseifelse ( j ) ;
break ;
}
case concmd_ifvarg :
{
int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
j = 0 ;
2021-12-05 16:36:57 +00:00
if ( GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) > * insptr )
2020-09-17 20:36:09 +00:00
{
j = 1 ;
}
parseifelse ( j ) ;
break ;
}
case concmd_ifvarl :
{
int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
j = 0 ;
2021-12-05 16:36:57 +00:00
if ( GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) < * insptr )
2020-09-17 20:36:09 +00:00
{
j = 1 ;
}
parseifelse ( j ) ;
break ;
}
case concmd_ifphealthl :
insptr + + ;
2023-10-03 00:29:28 +00:00
parseifelse ( pact - > spr . extra < * insptr ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifpinventory :
{
2022-12-15 20:12:20 +00:00
insptr + + ;
2023-10-03 00:29:28 +00:00
j = playercheckinventory ( p , g_ac , * insptr , * ( insptr + 1 ) ) ;
2022-12-15 20:12:20 +00:00
insptr + + ;
parseifelse ( j ) ;
break ;
2020-05-14 07:07:07 +00:00
}
2020-09-17 20:36:09 +00:00
case concmd_pstomp :
2020-05-14 07:07:07 +00:00
insptr + + ;
2023-10-03 00:29:28 +00:00
if ( p - > knee_incs = = 0 & & pact - > spr . scale . X > = ( isRR ( ) ? 0.140625 : 0.625 ) )
if ( cansee ( g_ac - > spr . pos . plusZ ( - 4 ) , g_ac - > sector ( ) , pact - > getPosWithOffsetZ ( ) . plusZ ( 16 ) , pact - > sector ( ) ) )
2020-09-17 20:36:09 +00:00
{
2023-10-03 00:29:28 +00:00
p - > knee_incs = 1 ;
if ( p - > weapon_pos = = 0 )
p - > weapon_pos = - 1 ;
p - > actorsqu = g_ac ;
2020-09-17 20:36:09 +00:00
}
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
case concmd_ifawayfromwall :
{
2021-12-30 15:51:56 +00:00
auto s1 = g_ac - > sector ( ) ;
2020-09-17 20:36:09 +00:00
2022-09-13 17:40:32 +00:00
j = isAwayFromWall ( g_ac , 6.75 ) ;
2020-09-17 20:36:09 +00:00
parseifelse ( j ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
}
case concmd_quote :
insptr + + ;
2023-10-03 00:29:28 +00:00
FTA ( * insptr , p ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
case concmd_ifinouterspace :
2022-11-25 16:43:13 +00:00
parseifelse ( floorspace ( g_ac - > sector ( ) ) ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifnotmoving :
2022-09-26 13:04:20 +00:00
parseifelse ( g_ac - > movflag > kHitSector ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_respawnhitag :
insptr + + ;
2022-11-30 13:29:34 +00:00
respawnhitag ( g_ac ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifspritepal :
insptr + + ;
2021-12-21 21:31:25 +00:00
parseifelse ( g_ac - > spr . pal = = * insptr ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifangdiffl :
2022-09-13 16:24:02 +00:00
{
2020-09-17 20:36:09 +00:00
insptr + + ;
2023-10-03 00:29:28 +00:00
auto ang = absangle ( pact - > spr . Angles . Yaw , g_ac - > spr . Angles . Yaw ) ;
2022-09-13 16:24:02 +00:00
parseifelse ( ang < = mapangle ( * insptr ) ) ;
2020-09-17 20:36:09 +00:00
break ;
2022-09-13 16:24:02 +00:00
}
2020-09-17 20:36:09 +00:00
case concmd_ifnosounds :
2020-10-25 05:40:05 +00:00
parseifelse ( ! S_CheckAnyActorSoundPlaying ( g_ac ) ) ;
2020-09-17 20:36:09 +00:00
break ;
case concmd_ifplaybackon : //Twentieth Anniversary World Tour
parseifelse ( false ) ;
break ;
case concmd_espawnvar :
2020-05-14 17:23:36 +00:00
{
2020-10-25 05:40:05 +00:00
DDukeActor * lReturn = nullptr ;
2020-09-17 20:36:09 +00:00
int lIn ;
insptr + + ;
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
lIn = * insptr + + ;
2021-12-05 16:36:57 +00:00
lIn = GetGameVarID ( lIn , g_ac , g_p ) . safeValue ( ) ;
2021-11-21 00:04:16 +00:00
if ( g_ac - > insector ( ) )
2022-12-30 20:45:31 +00:00
lReturn = spawn ( g_ac , GetSpawnType ( lIn ) ) ;
2020-05-14 07:07:07 +00:00
2021-12-05 16:36:57 +00:00
SetGameVarID ( g_iReturnVarID , ( lReturn ) , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_espawn :
{
2020-10-25 05:40:05 +00:00
DDukeActor * lReturn = nullptr ;
2020-09-17 20:36:09 +00:00
insptr + + ;
2021-11-21 00:04:16 +00:00
if ( g_ac - > insector ( ) )
2022-12-30 20:45:31 +00:00
lReturn = spawn ( g_ac , GetSpawnType ( * insptr ) ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
2021-12-05 16:36:57 +00:00
SetGameVarID ( g_iReturnVarID , ( lReturn ) , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_setsector :
case concmd_getsector :
{
// syntax [gs]etsector[<var>].x <VAR>
// <varid> <xxxid> <varid>
int lLabelID ;
int lVar1 , lVar2 ;
int lWhat ;
int lParm2 ;
lWhat = * ( insptr + + ) ;
lVar1 = * ( insptr + + ) ;
lLabelID = * ( insptr + + ) ;
2020-09-17 21:02:52 +00:00
lParm2 = * ( insptr + + ) ;
2020-09-17 20:36:09 +00:00
lVar2 = * ( insptr + + ) ;
2020-10-23 17:07:33 +00:00
DoSector ( lWhat = = concmd_setsector , lVar1 , lLabelID , lVar2 , g_ac , g_p , lParm2 ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_sqrt :
{
// syntax sqrt <invar> <outvar>
2020-05-14 07:07:07 +00:00
2020-09-17 20:36:09 +00:00
int lInVarID ;
int lOutVarID ;
int lIn ;
insptr + + ;
lInVarID = * ( insptr + + ) ;
lOutVarID = * ( insptr + + ) ;
2021-12-05 16:36:57 +00:00
lIn = GetGameVarID ( lInVarID , g_ac , g_p ) . safeValue ( ) ;
2020-10-23 18:22:08 +00:00
SetGameVarID ( lOutVarID , ksqrt ( lIn ) , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_findnearactor :
{
// syntax findnearactorvar <type> <maxdist> <getvar>
// gets the sprite ID of the nearest actor within max dist
// that is of <type> into <getvar>
// -1 for none found
// <type> <maxdist> <varid>
int lType ;
int lMaxDist ;
int lVarID ;
2022-09-13 21:29:41 +00:00
double lTemp ;
double lDist ;
2020-09-17 20:36:09 +00:00
insptr + + ;
lType = * ( insptr + + ) ;
lMaxDist = * ( insptr + + ) ;
lVarID = * ( insptr + + ) ;
2020-10-25 05:40:05 +00:00
DDukeActor * lFound = nullptr ;
2022-09-13 21:29:41 +00:00
lDist = 1000000 ; // big number
2020-09-17 20:36:09 +00:00
2020-10-23 18:22:08 +00:00
DukeStatIterator it ( STAT_ACTOR ) ;
2021-12-24 09:53:27 +00:00
while ( auto actj = it . Next ( ) )
2020-09-17 20:36:09 +00:00
{
2022-12-30 18:30:53 +00:00
if ( actj - > GetClass ( ) = = GetSpawnType ( lType ) )
2020-05-14 07:07:07 +00:00
{
2022-09-13 21:29:41 +00:00
lTemp = ( g_ac - > spr . pos . XY ( ) - actj - > spr . pos . XY ( ) ) . Length ( ) ;
2020-09-17 20:36:09 +00:00
if ( lTemp < lMaxDist )
{
if ( lTemp < lDist )
{
2021-12-24 09:53:27 +00:00
lFound = actj ;
2020-09-17 20:36:09 +00:00
}
}
2020-05-13 22:04:14 +00:00
}
2020-09-17 20:36:09 +00:00
}
2021-12-05 16:36:57 +00:00
SetGameVarID ( lVarID , ( lFound ) , g_ac , g_p ) ;
2020-05-14 07:07:07 +00:00
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_findnearactorvar :
{
// syntax findnearactorvar <type> <maxdistvar> <getvar>
// gets the sprite ID of the nearest actor within max dist
// that is of <type> into <getvar>
// -1 for none found
// <type> <maxdistvarid> <varid>
int lType ;
int lMaxDistVar ;
int lMaxDist ;
int lVarID ;
2022-09-13 21:29:41 +00:00
double lTemp ;
double lDist ;
2020-09-17 20:36:09 +00:00
insptr + + ;
lType = * ( insptr + + ) ;
lMaxDistVar = * ( insptr + + ) ;
lVarID = * ( insptr + + ) ;
2021-12-05 16:36:57 +00:00
lMaxDist = GetGameVarID ( lMaxDistVar , g_ac , g_p ) . safeValue ( ) ;
2021-11-14 12:33:35 +00:00
DDukeActor * lFound = nullptr ;
2022-09-13 21:29:41 +00:00
lDist = 1000000 ; // big number
2020-09-17 20:36:09 +00:00
2020-10-23 18:22:08 +00:00
DukeStatIterator it ( STAT_ACTOR ) ;
2021-12-24 09:53:27 +00:00
while ( auto actj = it . Next ( ) )
2020-09-17 20:36:09 +00:00
{
2022-12-30 18:30:53 +00:00
if ( actj - > GetClass ( ) = = GetSpawnType ( lType ) )
2020-09-17 20:36:09 +00:00
{
2022-09-13 21:29:41 +00:00
lTemp = ( g_ac - > spr . pos . XY ( ) - actj - > spr . pos . XY ( ) ) . Length ( ) ;
2020-09-17 20:36:09 +00:00
if ( lTemp < lMaxDist )
{
if ( lTemp < lDist )
{
2021-12-24 09:53:27 +00:00
lFound = actj ;
2020-09-17 20:36:09 +00:00
}
}
}
}
2021-12-05 16:36:57 +00:00
SetGameVarID ( lVarID , ( lFound ) , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_setplayer :
case concmd_getplayer :
{
// syntax [gs]etplayer[<var>].x <VAR>
// <varid> <xxxid> <varid>
int lLabelID ;
int lVar1 , lVar2 ;
int lWhat ;
int lParm2 ;
lWhat = * ( insptr + + ) ;
lVar1 = * ( insptr + + ) ;
lLabelID = * ( insptr + + ) ;
2020-09-17 21:02:52 +00:00
lParm2 = * ( insptr + + ) ;
2020-09-17 20:36:09 +00:00
lVar2 = * ( insptr + + ) ;
2020-10-23 17:07:33 +00:00
DoPlayer ( lWhat = = concmd_setplayer , lVar1 , lLabelID , lVar2 , g_ac , g_p , lParm2 ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_getuserdef :
case concmd_setuserdef :
{
// syntax [gs]etuserdef.xxx <VAR>
// <xxxid> <varid>
int lLabelID ;
int lVar1 , lVar2 ;
int lWhat ;
int lParm2 ;
lWhat = * ( insptr + + ) ;
lVar1 = - 1 ;
lLabelID = * ( insptr + + ) ;
2020-09-17 21:02:52 +00:00
lParm2 = * ( insptr + + ) ;
2020-09-17 20:36:09 +00:00
lVar2 = * ( insptr + + ) ;
2020-10-23 17:07:33 +00:00
DoUserDef ( lWhat = = concmd_setuserdef , lVar1 , lLabelID , lVar2 , g_ac , g_p , lParm2 ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_setwall :
case concmd_getwall :
{
// syntax [gs]etwall[<var>].x <VAR>
// <varid> <xxxid> <varid>
int lLabelID ;
int lVar1 , lVar2 ;
int lWhat ;
int lParm2 ;
lWhat = * ( insptr + + ) ;
lVar1 = * ( insptr + + ) ;
lLabelID = * ( insptr + + ) ;
2020-09-17 21:02:52 +00:00
lParm2 = * ( insptr + + ) ;
2020-09-17 20:36:09 +00:00
lVar2 = * ( insptr + + ) ;
2020-10-23 17:07:33 +00:00
DoWall ( lWhat = = concmd_setwall , lVar1 , lLabelID , lVar2 , g_ac , g_p , lParm2 ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_setactorvar :
{
// syntax [gs]etactorvar[<var>].<varx> <VAR>
// gets the value of the per-actor variable varx into VAR
// <var> <varx> <VAR>
int lVar1 , lVar2 , lVar3 ;
insptr + + ;
lVar1 = * ( insptr + + ) ;
lVar2 = * ( insptr + + ) ;
lVar3 = * ( insptr + + ) ;
2021-12-05 16:36:57 +00:00
auto lSprite = GetGameVarID ( lVar1 , g_ac , g_p ) ;
if ( lSprite . isActor ( ) )
2020-09-17 20:36:09 +00:00
{
2021-12-05 16:36:57 +00:00
auto lTemp = GetGameVarID ( lVar3 , g_ac , g_p ) ;
SetGameVarID ( lVar2 , lTemp , lSprite . actor ( ) , g_p ) ;
2020-09-17 20:36:09 +00:00
}
break ;
}
case concmd_getactorvar :
{
// syntax [gs]etactorvar[<var>].<varx> <VAR>
// gets the value of the per-actor variable varx into VAR
// <var> <varx> <VAR>
int lVar1 , lVar2 , lVar3 ;
insptr + + ;
lVar1 = * ( insptr + + ) ;
lVar2 = * ( insptr + + ) ;
lVar3 = * ( insptr + + ) ;
2020-05-14 07:07:07 +00:00
2021-12-05 16:36:57 +00:00
auto lSprite = GetGameVarID ( lVar1 , g_ac , g_p ) ;
if ( lSprite . isActor ( ) )
2020-09-17 20:36:09 +00:00
{
2021-12-05 16:36:57 +00:00
auto lTemp = GetGameVarID ( lVar2 , lSprite . actor ( ) , g_p ) ;
2020-10-23 18:22:08 +00:00
SetGameVarID ( lVar3 , lTemp , g_ac , g_p ) ;
2020-05-14 07:07:07 +00:00
}
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_setactor :
case concmd_getactor :
{
// syntax [gs]etactor[<var>].x <VAR>
// <varid> <xxxid> <varid>
int lLabelID ;
int lVar1 , lVar2 ;
int lWhat ;
int lParm2 ;
lWhat = * ( insptr + + ) ;
lVar1 = * ( insptr + + ) ;
lLabelID = * ( insptr + + ) ;
2020-09-17 21:02:52 +00:00
lParm2 = * ( insptr + + ) ;
2020-09-17 20:36:09 +00:00
lVar2 = * ( insptr + + ) ;
2020-10-23 17:07:33 +00:00
DoActor ( lWhat = = concmd_setactor , lVar1 , lLabelID , lVar2 , g_ac , g_p , lParm2 ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_getangletotarget :
{
insptr + + ;
2022-09-12 20:58:52 +00:00
int i = * ( insptr + + ) ; // ID of def
2020-09-17 20:36:09 +00:00
2020-10-23 18:22:08 +00:00
// g_ac->lastvx and lastvy are last known location of target.
2022-09-30 11:38:21 +00:00
int ang = ( g_ac - > ovel - g_ac - > spr . pos . XY ( ) ) . Angle ( ) . Buildang ( ) ;
2020-10-23 18:22:08 +00:00
SetGameVarID ( i , ang , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_lockplayer :
{
int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2023-10-03 00:29:28 +00:00
p - > transporter_hold = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_getplayerangle :
{
int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2023-10-03 00:29:28 +00:00
SetGameVarID ( i , pact - > spr . Angles . Yaw . Buildang ( ) , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_setplayerangle :
{
int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2023-10-03 00:29:28 +00:00
pact - > spr . Angles . Yaw = mapangle ( GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) & 2047 ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
}
case concmd_getactorangle :
{
int i ;
2020-05-14 07:07:07 +00:00
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
2022-11-25 12:13:50 +00:00
SetGameVarID ( i , g_ac - > spr . Angles . Yaw . Buildang ( ) , g_ac , g_p ) ;
2020-05-14 07:07:07 +00:00
break ;
2020-09-17 20:36:09 +00:00
}
case concmd_setactorangle :
{
int i ;
2020-05-14 17:23:36 +00:00
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
2022-11-25 12:13:50 +00:00
g_ac - > spr . Angles . Yaw = DAngle : : fromBuild ( GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) & 2047 ) ;
2020-05-14 17:23:36 +00:00
break ;
2020-09-17 20:36:09 +00:00
}
case concmd_randvar :
{
int i ;
2020-05-14 17:23:36 +00:00
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
2021-01-04 11:57:26 +00:00
SetGameVarID ( i , MulScale ( rand ( ) , * insptr , 15 ) , g_ac , g_p ) ;
2020-05-14 17:23:36 +00:00
insptr + + ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_mulvar :
{
int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
SetGameVarID ( i , GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) * ( * insptr ) , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
}
case concmd_divvar :
{
int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
if ( ( * insptr ) = = 0 )
2020-05-14 17:23:36 +00:00
{
2020-09-17 20:36:09 +00:00
I_Error ( " Divide by Zero in CON. " ) ;
2020-05-14 17:23:36 +00:00
}
2021-12-05 16:36:57 +00:00
SetGameVarID ( i , GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) / ( * insptr ) , g_ac , g_p ) ;
2020-05-14 17:23:36 +00:00
insptr + + ;
break ;
2020-09-17 20:36:09 +00:00
}
case concmd_modvar :
{
int i ;
2021-12-24 09:53:27 +00:00
int instr ;
2020-09-17 20:36:09 +00:00
int lResult ;
2020-05-14 17:23:36 +00:00
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
2021-12-24 09:53:27 +00:00
instr = ( * insptr ) ;
if ( instr = = 0 )
2020-05-14 17:23:36 +00:00
{
2020-09-17 20:36:09 +00:00
I_Error ( " Divide by Zero in CON " ) ;
2020-05-14 17:23:36 +00:00
}
2021-12-24 09:53:27 +00:00
lResult = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) % instr ;
2020-10-23 18:22:08 +00:00
SetGameVarID ( i , lResult , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
2020-05-14 17:23:36 +00:00
break ;
2020-09-17 20:36:09 +00:00
}
case concmd_andvar :
{
int i ;
2021-12-24 09:53:27 +00:00
int instr ;
2020-09-17 20:36:09 +00:00
int lResult ;
2020-05-14 17:23:36 +00:00
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
2021-12-24 09:53:27 +00:00
instr = ( * insptr ) ;
lResult = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) & instr ;
2020-10-23 18:22:08 +00:00
SetGameVarID ( i , lResult , g_ac , g_p ) ;
2020-05-14 17:23:36 +00:00
insptr + + ;
break ;
2020-09-17 20:36:09 +00:00
}
case concmd_xorvar :
{
int i ;
2021-12-24 09:53:27 +00:00
int instr ;
2020-09-17 20:36:09 +00:00
int lResult ;
2020-05-14 17:23:36 +00:00
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
2021-12-24 09:53:27 +00:00
instr = ( * insptr ) ;
lResult = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) ^ instr ;
2020-10-23 18:22:08 +00:00
SetGameVarID ( i , lResult , g_ac , g_p ) ;
2020-05-14 17:23:36 +00:00
insptr + + ;
break ;
2020-09-17 20:36:09 +00:00
}
case concmd_orvar :
{
int i ;
2021-12-24 09:53:27 +00:00
int instr ;
2020-09-17 20:36:09 +00:00
int lResult ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2021-12-24 09:53:27 +00:00
instr = ( * insptr ) ;
lResult = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) | instr ;
2020-10-23 18:22:55 +00:00
SetGameVarID ( i , lResult , g_ac , g_p ) ;
2020-05-14 17:23:36 +00:00
insptr + + ;
break ;
2020-09-17 20:36:09 +00:00
}
case concmd_randvarvar :
{
int i ;
int l1 , l2 ;
int lResult ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
l1 = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) ; // not used for this command
l2 = GetGameVarID ( * insptr , g_ac , g_p ) . safeValue ( ) ;
2021-01-04 11:57:26 +00:00
lResult = MulScale ( rand ( ) , l2 , 15 ) ;
2020-10-23 18:22:55 +00:00
SetGameVarID ( i , lResult , g_ac , g_p ) ;
2020-05-14 17:23:36 +00:00
insptr + + ;
break ;
2020-09-17 20:36:09 +00:00
}
case concmd_gmaxammo :
{
int i ;
int l1 , l2 ;
int lResult ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
l1 = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) ;
l2 = GetGameVarID ( * insptr , g_ac , g_p ) . safeValue ( ) ; // l2 not used in this one
2020-11-29 12:54:58 +00:00
lResult = gs . max_ammo_amount [ l1 ] ;
2020-10-23 18:22:55 +00:00
SetGameVarID ( * insptr , lResult , g_ac , g_p ) ;
2020-05-14 17:23:36 +00:00
insptr + + ;
break ;
2020-09-17 20:36:09 +00:00
}
case concmd_smaxammo :
{
int i ;
int l1 , l2 ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
l1 = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) ;
l2 = GetGameVarID ( * insptr , g_ac , g_p ) . safeValue ( ) ;
2020-11-29 12:54:58 +00:00
gs . max_ammo_amount [ l1 ] = l2 ;
2020-05-13 22:04:14 +00:00
2020-05-14 17:23:36 +00:00
insptr + + ;
break ;
2020-09-17 20:36:09 +00:00
}
case concmd_mulvarvar :
{
int i ;
int l1 , l2 ;
int lResult ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
l1 = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) ;
l2 = GetGameVarID ( * insptr , g_ac , g_p ) . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
lResult = l1 * l2 ;
2020-10-23 18:22:55 +00:00
SetGameVarID ( i , lResult , g_ac , g_p ) ;
2020-05-14 17:23:36 +00:00
insptr + + ;
break ;
}
2020-09-17 20:36:09 +00:00
case concmd_divvarvar :
{
int i ;
int l1 , l2 ;
int lResult ;
2020-05-14 17:23:36 +00:00
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
l1 = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) ;
l2 = GetGameVarID ( * insptr , g_ac , g_p ) . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
if ( l2 = = 0 )
2020-05-14 17:23:36 +00:00
{
2020-09-17 20:36:09 +00:00
I_Error ( " Divide by Zero in CON " ) ;
2020-05-13 22:04:14 +00:00
}
2020-09-17 20:36:09 +00:00
lResult = l1 / l2 ;
2020-10-23 18:22:55 +00:00
SetGameVarID ( i , lResult , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
}
case concmd_modvarvar :
{
int i ;
int l1 , l2 ;
int lResult ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
l1 = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) ;
l2 = GetGameVarID ( * insptr , g_ac , g_p ) . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
if ( l2 = = 0 )
2020-05-14 17:23:36 +00:00
{
2020-09-17 20:36:09 +00:00
I_Error ( " Mod by Zero in CON " ) ;
2020-05-14 17:23:36 +00:00
}
2020-09-17 20:36:09 +00:00
lResult = l1 % l2 ;
2020-10-23 18:22:55 +00:00
SetGameVarID ( i , lResult , g_ac , g_p ) ;
2020-05-14 17:23:36 +00:00
insptr + + ;
break ;
}
2020-09-17 20:36:09 +00:00
case concmd_andvarvar :
{
int i ;
int l1 , l2 ;
int lResult ;
2020-05-14 17:23:36 +00:00
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
l1 = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) ;
l2 = GetGameVarID ( * insptr , g_ac , g_p ) . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
lResult = l1 & l2 ;
2020-10-23 18:22:55 +00:00
SetGameVarID ( i , lResult , g_ac , g_p ) ;
2020-05-14 17:23:36 +00:00
insptr + + ;
break ;
}
2020-09-17 20:36:09 +00:00
case concmd_xorvarvar :
{
int i ;
int l1 , l2 ;
int lResult ;
2020-05-14 17:23:36 +00:00
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
l1 = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) ;
l2 = GetGameVarID ( * insptr , g_ac , g_p ) . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
lResult = l1 ^ l2 ;
2020-10-23 18:22:55 +00:00
SetGameVarID ( i , lResult , g_ac , g_p ) ;
2020-05-14 17:23:36 +00:00
insptr + + ;
break ;
}
2020-09-17 20:36:09 +00:00
case concmd_orvarvar :
{
int i ;
int l1 , l2 ;
int lResult ;
2020-05-14 17:23:36 +00:00
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
l1 = GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) ;
l2 = GetGameVarID ( * insptr , g_ac , g_p ) . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
lResult = l1 | l2 ;
2020-10-23 18:22:55 +00:00
SetGameVarID ( i , lResult , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
}
case concmd_subvar :
{
int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
SetGameVarID ( i , GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) - * insptr , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
}
case concmd_subvarvar :
{
int i ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2021-12-05 16:36:57 +00:00
SetGameVarID ( i , GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) - GetGameVarID ( * insptr , g_ac , g_p ) . safeValue ( ) , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
}
case concmd_sin :
{
int i ;
int lValue ;
insptr + + ;
i = * ( insptr + + ) ; // ID of def
2022-09-15 17:23:47 +00:00
lValue = int ( 16384 * BobVal ( GetGameVarID ( * insptr , g_ac , g_p ) . safeValue ( ) ) ) ;
2020-10-23 18:22:55 +00:00
SetGameVarID ( i , lValue , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
insptr + + ;
break ;
}
case concmd_spgetlotag :
{
insptr + + ;
2021-12-21 21:31:25 +00:00
SetGameVarID ( g_iLoTagID , g_ac - > spr . lotag , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_spgethitag :
{
insptr + + ;
2021-12-21 21:31:25 +00:00
SetGameVarID ( g_iHiTagID , g_ac - > spr . hitag , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_sectgetlotag :
{
insptr + + ;
2021-12-30 15:51:56 +00:00
SetGameVarID ( g_iLoTagID , g_ac - > sector ( ) - > lotag , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_sectgethitag :
{
insptr + + ;
2021-12-30 15:51:56 +00:00
SetGameVarID ( g_iHiTagID , g_ac - > sector ( ) - > hitag , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_gettexturefloor :
{
2020-05-14 17:23:36 +00:00
insptr + + ;
2022-12-09 09:48:47 +00:00
SetGameVarID ( g_iTextureID , legacyTileNum ( g_ac - > sector ( ) - > floortexture ) , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_startlevel :
{
// from 'level' cheat in game.c (about line 6250)
int volnume ;
int levnume ;
insptr + + ; // skip command
2021-12-05 16:36:57 +00:00
volnume = GetGameVarID ( * insptr + + , g_ac , g_p ) . safeValue ( ) ;
levnume = GetGameVarID ( * insptr + + , g_ac , g_p ) . safeValue ( ) ;
2021-05-02 08:35:43 +00:00
auto level = FindMapByIndex ( volnume , levnume ) ;
2020-09-17 20:36:09 +00:00
if ( level ! = nullptr )
2021-07-20 08:51:34 +00:00
ChangeLevel ( level , g_nextskill ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_myosx :
case concmd_myospalx :
case concmd_myos :
case concmd_myospal :
{
int x , y ;
int tilenum ;
int shade ;
int orientation ;
int pal ;
int tw = * insptr + + ;
2021-12-05 16:36:57 +00:00
x = GetGameVarID ( * insptr + + , g_ac , g_p ) . safeValue ( ) ;
y = GetGameVarID ( * insptr + + , g_ac , g_p ) . safeValue ( ) ;
tilenum = GetGameVarID ( * insptr + + , g_ac , g_p ) . safeValue ( ) ;
shade = GetGameVarID ( * insptr + + , g_ac , g_p ) . safeValue ( ) ;
orientation = GetGameVarID ( * insptr + + , g_ac , g_p ) . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
if ( tw = = concmd_myospal )
{
2021-12-05 16:36:57 +00:00
pal = GetGameVarID ( * insptr + + , g_ac , g_p ) . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
//myospal(x, y, tilenum, shade, orientation, pal);
}
else if ( tw = = concmd_myos )
{
//myos(x, y, tilenum, shade, orientation);
}
else if ( tw = = concmd_myosx )
{
//myos640(x, y, tilenum, shade, orientation);
}
else if ( tw = = concmd_myospalx )
{
2021-12-05 16:36:57 +00:00
pal = GetGameVarID ( * insptr + + , g_ac , g_p ) . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
//myospal640(x, y, tilenum, shade, orientation, pal);
}
2020-05-14 17:23:36 +00:00
break ;
}
2020-09-17 20:36:09 +00:00
case concmd_displayrand :
{
int i ;
2020-05-14 17:23:36 +00:00
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
2020-10-23 18:22:55 +00:00
SetGameVarID ( i , rand ( ) , g_ac , g_p ) ;
2020-05-14 17:23:36 +00:00
break ;
}
2020-09-17 20:36:09 +00:00
case concmd_switch :
2020-05-14 17:23:36 +00:00
{
2020-09-17 20:36:09 +00:00
int lVarID ;
int lValue ;
int * lpDefault ;
int * lpCases ;
int lCases ;
int lEnd ;
int lCheckCase ;
2021-11-07 11:53:48 +00:00
bool bMatched ;
2020-09-17 20:36:09 +00:00
int * lTempInsPtr ;
// command format:
// variable ID to check
// script offset to 'end'
// count of case statements
// script offset to default case (null if none)
// For each case: value, ptr to code
insptr + + ; // p-code
lVarID = * insptr + + ;
2021-12-05 16:36:57 +00:00
lValue = GetGameVarID ( lVarID , g_ac , g_p ) . safeValue ( ) ;
2020-09-17 20:36:09 +00:00
lEnd = * insptr + + ;
lCases = * insptr + + ;
lpDefault = insptr + + ;
lpCases = insptr ;
insptr + = lCases * 2 ;
2021-11-07 11:53:48 +00:00
bMatched = false ;
2020-09-17 20:36:09 +00:00
lTempInsPtr = insptr ;
for ( lCheckCase = 0 ; lCheckCase < lCases & & ! bMatched ; lCheckCase + + )
2020-05-13 22:04:14 +00:00
{
2020-09-17 20:36:09 +00:00
if ( lpCases [ lCheckCase * 2 ] = = lValue )
{
insptr = & ScriptCode [ lpCases [ lCheckCase * 2 + 1 ] ] ;
while ( 1 )
{
if ( parse ( ) )
break ;
}
2021-11-07 11:53:48 +00:00
bMatched = true ;
2020-09-17 20:36:09 +00:00
}
2020-05-13 22:04:14 +00:00
}
2020-09-17 20:36:09 +00:00
if ( ! bMatched )
{
if ( * lpDefault )
{
insptr = & ScriptCode [ * lpDefault ] ;
while ( 1 ) if ( parse ( ) ) break ;
}
else
{
//AddLog("No Matching Case: No Default to use");
}
}
insptr = & ScriptCode [ lEnd ] ;
2020-05-14 17:23:36 +00:00
break ;
}
2020-09-17 20:36:09 +00:00
case concmd_endswitch :
insptr + + ;
return 1 ;
break ;
case concmd_starttrack :
2020-05-14 17:23:36 +00:00
{
insptr + + ;
2020-09-17 20:36:09 +00:00
int music_select = * insptr + + ;
2021-05-02 08:35:43 +00:00
auto level = FindMapByIndex ( currentLevel - > cluster , music_select + 1 ) ; // this was 0-based in EDuke 2.0...
2020-09-17 20:36:09 +00:00
if ( level ) S_PlayLevelMusic ( level ) ;
2020-05-14 17:23:36 +00:00
break ;
}
2020-09-17 20:36:09 +00:00
case concmd_gettextureceiling :
{
insptr + + ;
2022-12-09 09:48:47 +00:00
SetGameVarID ( g_iTextureID , legacyTileNum ( g_ac - > sector ( ) - > ceilingtexture ) , g_ac , g_p ) ;
2020-09-17 20:36:09 +00:00
break ;
}
case concmd_ifvarvarand :
2020-05-14 17:23:36 +00:00
{
int i ;
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
j = 0 ;
2021-12-05 16:36:57 +00:00
if ( GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) & GetGameVarID ( * ( insptr ) , g_ac , g_p ) . safeValue ( ) )
2020-05-13 22:04:14 +00:00
{
2020-09-17 20:36:09 +00:00
j = 1 ;
2020-05-13 22:04:14 +00:00
}
2020-09-17 20:36:09 +00:00
parseifelse ( j ) ;
2020-05-14 17:23:36 +00:00
break ;
}
2020-09-17 20:36:09 +00:00
case concmd_ifvarvarn :
2020-05-14 17:23:36 +00:00
{
int i ;
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
j = 0 ;
2021-12-05 16:36:57 +00:00
if ( GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) ! = GetGameVarID ( * ( insptr ) , g_ac , g_p ) . safeValue ( ) )
2020-05-13 22:04:14 +00:00
{
2020-09-17 20:36:09 +00:00
j = 1 ;
2020-05-13 22:04:14 +00:00
}
2020-09-17 20:36:09 +00:00
parseifelse ( j ) ;
2020-05-14 17:23:36 +00:00
break ;
}
2020-09-17 20:36:09 +00:00
case concmd_ifvarn :
2020-05-14 17:23:36 +00:00
{
int i ;
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
j = 0 ;
2021-12-05 16:36:57 +00:00
if ( GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) ! = * insptr )
2020-05-13 22:04:14 +00:00
{
2020-09-17 20:36:09 +00:00
j = 1 ;
2020-05-13 22:04:14 +00:00
}
2020-09-17 20:36:09 +00:00
parseifelse ( j ) ;
2020-05-14 17:23:36 +00:00
break ;
}
2020-09-17 20:36:09 +00:00
case concmd_ifvarand :
2020-05-14 17:23:36 +00:00
{
int i ;
insptr + + ;
2020-09-17 20:36:09 +00:00
i = * ( insptr + + ) ; // ID of def
j = 0 ;
2021-12-05 16:36:57 +00:00
if ( GetGameVarID ( i , g_ac , g_p ) . safeValue ( ) & * insptr )
2020-05-13 22:04:14 +00:00
{
2020-09-17 20:36:09 +00:00
j = 1 ;
2020-05-13 22:04:14 +00:00
}
2020-09-17 20:36:09 +00:00
parseifelse ( j ) ;
2020-05-14 17:23:36 +00:00
break ;
}
2020-09-17 20:36:09 +00:00
default :
Printf ( TEXTCOLOR_RED " Unrecognized PCode of %d in parse. Killing current sprite. \n " , * insptr ) ;
Printf ( TEXTCOLOR_RED " Offset=%0X \n " , int ( insptr - ScriptCode . Data ( ) ) ) ;
2023-07-22 08:24:20 +00:00
killit_flag = 1 ;
2020-05-14 17:23:36 +00:00
break ;
2020-09-17 20:36:09 +00:00
}
return 0 ;
}
2020-05-13 22:04:14 +00:00
2020-09-17 20:36:09 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2023-04-30 06:46:51 +00:00
CVAR ( Bool , overridecon , false , 0 ) // This is for debugging the CON replacement code only.
2020-10-23 18:27:05 +00:00
void LoadActor ( DDukeActor * actor , int p , int x )
2020-09-17 20:36:09 +00:00
{
2021-11-07 11:53:48 +00:00
int done ;
2020-09-17 20:36:09 +00:00
ParseState s ;
s . g_p = p ; // Player ID
s . g_x = x ; // ??
2020-10-23 18:27:05 +00:00
s . g_ac = actor ;
2023-07-22 08:24:20 +00:00
s . killit_flag = 0 ;
2020-09-17 20:36:09 +00:00
2023-04-30 06:57:28 +00:00
if ( ( actor - > flags4 & SFLAG4_CONOVERRIDE ) & & overridecon ) return ;
2022-12-21 21:36:15 +00:00
auto coninf = actor - > conInfo ( ) ;
if ( coninf = = nullptr ) return ;
auto addr = coninf - > loadeventscriptptr ;
2020-09-17 20:36:09 +00:00
if ( addr = = 0 ) return ;
2021-11-21 00:04:16 +00:00
if ( ! actor - > insector ( ) )
2020-05-14 17:23:36 +00:00
{
2022-11-20 18:25:23 +00:00
actor - > Destroy ( ) ;
2020-09-17 20:36:09 +00:00
return ;
}
do
done = s . parse ( ) ;
while ( done = = 0 ) ;
2020-05-13 22:04:14 +00:00
2023-07-22 08:24:20 +00:00
if ( s . killit_flag = = 1 )
2020-09-17 20:36:09 +00:00
{
2022-11-20 18:25:23 +00:00
actor - > Destroy ( ) ;
2020-09-17 20:36:09 +00:00
}
2020-05-13 22:04:14 +00:00
}
2020-09-17 20:36:09 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2023-10-04 01:00:04 +00:00
bool execute ( DDukeActor * actor , DDukePlayer * const p , double pdist , int * killit_flag )
2020-05-13 22:04:14 +00:00
{
2023-07-22 08:24:20 +00:00
if ( killit_flag ) * killit_flag = 0 ;
2023-04-30 06:57:28 +00:00
if ( ( actor - > flags4 & SFLAG4_CONOVERRIDE ) & & overridecon ) return false ;
2022-12-21 21:36:15 +00:00
auto coninf = actor - > conInfo ( ) ;
if ( coninf = = nullptr )
return false ;
2020-05-15 06:04:30 +00:00
2020-07-18 10:37:35 +00:00
ParseState s ;
2023-10-04 01:00:04 +00:00
s . g_p = p - > pnum ; // Player ID
2022-12-30 11:38:36 +00:00
s . g_x = int ( pdist / maptoworld ) ; // ??
2020-10-23 18:28:29 +00:00
s . g_ac = actor ;
2023-07-22 08:24:20 +00:00
s . killit_flag = 0 ;
2022-12-30 18:30:53 +00:00
s . insptr = coninf ? & ScriptCode [ 4 + coninf - > scriptaddress ] : nullptr ;
2020-05-13 22:04:14 +00:00
2022-12-17 11:41:56 +00:00
int done ;
2020-05-13 22:04:14 +00:00
do
2020-07-18 10:37:35 +00:00
done = s . parse ( ) ;
2020-05-13 22:04:14 +00:00
while ( done = = 0 ) ;
2023-07-22 08:24:20 +00:00
if ( killit_flag ) * killit_flag = s . killit_flag ;
2020-05-13 22:04:14 +00:00
2022-12-03 16:09:40 +00:00
return true ;
2020-05-13 22:04:14 +00:00
}
2020-05-15 08:44:57 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-11-01 16:57:40 +00:00
void OnEvent ( int iEventID , int p , DDukeActor * actor , int x )
2020-05-15 08:44:57 +00:00
{
2021-11-07 11:53:48 +00:00
int done ;
2020-05-15 08:44:57 +00:00
if ( iEventID > = MAXGAMEEVENTS )
{
Printf ( " Invalid Event ID \n " ) ;
return ;
}
if ( apScriptGameEvent [ iEventID ] = = 0 )
{
return ;
}
2020-07-18 10:37:35 +00:00
ParseState s ;
s . g_p = p ; /// current player ID
s . g_x = x ; // ?
2020-11-01 16:57:40 +00:00
s . g_ac = actor ;
2020-05-15 08:44:57 +00:00
2020-07-18 10:37:35 +00:00
s . insptr = & ScriptCode [ apScriptGameEvent [ iEventID ] ] ;
2020-05-15 08:44:57 +00:00
2023-07-22 08:24:20 +00:00
s . killit_flag = 0 ;
2020-05-15 08:44:57 +00:00
do
2020-07-18 10:37:35 +00:00
done = s . parse ( ) ;
2020-05-15 08:44:57 +00:00
while ( done = = 0 ) ;
}
2020-05-13 22:04:14 +00:00
END_DUKE_NS