2006-04-13 20:47:06 +00:00
//-------------------------------------------------------------------------
/*
2007-02-08 04:19:39 +00:00
Copyright ( C ) 1996 , 2003 - 3 D Realms Entertainment
Copyright ( C ) 2000 , 2003 - Matt Saettler ( EDuke Enhancements )
Copyright ( C ) 2004 , 2007 - EDuke32 developers
2006-04-13 20:47:06 +00:00
This file is part of EDuke32
EDuke32 is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation .
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 .
*/
//-------------------------------------------------------------------------
# include <time.h>
# include "duke3d.h"
# include "gamedef.h"
# include "scriplib.h"
2008-08-11 10:38:46 +00:00
# include "osdcmds.h"
2006-04-13 20:47:06 +00:00
# include "osd.h"
2008-11-20 14:06:36 +00:00
void G_RestoreMapState ( mapstate_t * save ) ;
void G_SaveMapState ( mapstate_t * save ) ;
2008-07-16 09:27:08 +00:00
2007-02-08 04:19:39 +00:00
int g_i , g_p ;
2008-02-18 08:10:54 +00:00
static int g_x ;
static intptr_t * g_t ;
2008-09-03 04:20:46 +00:00
spritetype * g_sp ;
2008-11-20 14:06:36 +00:00
static int g_killitFlag ;
int g_errorLineNum ;
2008-08-11 23:33:53 +00:00
int g_tw ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
static int X_DoExecute ( void ) ;
2008-02-16 22:18:48 +00:00
2008-11-20 14:06:36 +00:00
void X_ScriptInfo ( void )
2008-08-25 20:25:49 +00:00
{
if ( script )
{
intptr_t * p ;
for ( p = insptr - 20 ; p < insptr + 20 ; p + + )
{
if ( * p > > 12 & & ( * p & 0xFFF ) < CON_END )
initprintf ( " \n %5d: %5d %s " , p - script , * p > > 12 , keyw [ * p & 0xFFF ] ) ;
else
initprintf ( " %d " , * p ) ;
2008-08-28 05:57:46 +00:00
}
2008-08-25 20:25:49 +00:00
initprintf ( " current actor: %d (%d) \n " , g_i , g_sp - > picnum ) ;
2008-11-20 14:06:36 +00:00
initprintf ( " g_errorLineNum: %d, g_tw: %d \n " , g_errorLineNum , g_tw ) ;
2008-08-25 20:25:49 +00:00
}
}
2008-11-20 14:06:36 +00:00
void X_OnEvent ( int iEventID , int iActor , int iPlayer , int lDist )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( ( iEventID < 0 | | iEventID > = MAXGAMEEVENTS ) & & g_scriptSanityChecks )
2006-12-21 09:33:26 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid event ID " , g_errorLineNum , keyw [ g_tw ] ) ;
2006-12-21 09:33:26 +00:00
return ;
}
2006-04-13 20:47:06 +00:00
2006-12-23 02:38:47 +00:00
if ( apScriptGameEvent [ iEventID ] = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-12-23 02:38:47 +00:00
//Bsprintf(g_szBuf,"No event found for %d",iEventID);
//AddLog(g_szBuf);
2006-04-13 20:47:06 +00:00
return ;
}
{
2008-11-20 14:06:36 +00:00
int og_i = g_i , og_p = g_p , okillit_flag = g_killitFlag ;
2008-06-10 19:27:39 +00:00
int og_x = g_x ; // *og_t=g_t;
intptr_t * oinsptr = insptr , * og_t = g_t ;
2006-12-21 09:33:26 +00:00
spritetype * og_sp = g_sp ;
2007-02-08 04:19:39 +00:00
2006-12-21 09:33:26 +00:00
g_i = iActor ; // current sprite ID
g_p = iPlayer ; // current player ID
g_x = lDist ; // ?
g_sp = & sprite [ g_i ] ;
2008-11-20 14:06:36 +00:00
g_t = & ActorExtra [ g_i ] . temp_data [ 0 ] ;
2006-12-21 09:33:26 +00:00
insptr = ( apScriptGameEvent [ iEventID ] ) ;
//Bsprintf(g_szBuf,"Executing event for %d at %lX",iEventID, insptr);
2006-04-13 20:47:06 +00:00
//AddLog(g_szBuf);
2008-11-20 14:06:36 +00:00
g_killitFlag = 0 ;
2006-04-13 20:47:06 +00:00
2008-12-01 10:44:18 +00:00
while ( ! X_DoExecute ( ) ) ;
2006-11-13 23:12:47 +00:00
2008-11-20 14:06:36 +00:00
if ( g_killitFlag = = 1 )
2006-11-13 23:12:47 +00:00
{
2006-12-21 09:33:26 +00:00
// if player was set to squish, first stop that...
if ( g_p > = 0 )
{
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > actorsqu = = g_i )
g_player [ g_p ] . ps - > actorsqu = - 1 ;
2006-12-21 09:33:26 +00:00
}
deletesprite ( g_i ) ;
2006-11-13 23:12:47 +00:00
}
2006-04-13 20:47:06 +00:00
2006-12-21 09:33:26 +00:00
// restore old values...
g_i = og_i ;
g_p = og_p ;
g_x = og_x ;
g_sp = og_sp ;
g_t = og_t ;
2008-11-20 14:06:36 +00:00
g_killitFlag = okillit_flag ;
2006-12-21 09:33:26 +00:00
insptr = oinsptr ;
2006-04-13 20:47:06 +00:00
2006-12-21 09:33:26 +00:00
//AddLog("End of Execution");
}
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
static int A_CheckSquished ( int i , int p )
2006-12-10 03:15:56 +00:00
{
2006-12-21 09:33:26 +00:00
sectortype * sc = & sector [ SECT ] ;
2008-09-03 04:20:46 +00:00
int squishme = 0 ;
2006-12-10 03:15:56 +00:00
if ( PN = = APLAYER & & ud . clipping )
return 0 ;
if ( sc - > lotag ! = 23 )
{
2006-12-23 02:38:47 +00:00
squishme = ( sc - > floorz - sc - > ceilingz < ( 12 < < 8 ) ) ; // && (sc->lotag&32768) == 0;
2006-12-18 08:37:12 +00:00
2006-12-10 03:15:56 +00:00
if ( sprite [ i ] . pal = = 1 )
2006-12-23 02:38:47 +00:00
squishme = ( sc - > floorz - sc - > ceilingz < ( 32 < < 8 ) & & ( sc - > lotag & 32768 ) = = 0 ) ;
2006-12-10 03:15:56 +00:00
}
if ( squishme )
{
2008-11-20 14:06:36 +00:00
P_DoQuote ( 10 , g_player [ p ] . ps ) ;
2006-12-10 03:15:56 +00:00
2008-11-20 14:06:36 +00:00
if ( A_CheckEnemySprite ( & sprite [ i ] ) ) sprite [ i ] . xvel = 0 ;
2006-12-10 03:15:56 +00:00
if ( sprite [ i ] . pal = = 1 )
{
2008-11-20 14:06:36 +00:00
ActorExtra [ i ] . picnum = SHOTSPARK1 ;
ActorExtra [ i ] . extra = 1 ;
2006-12-10 03:15:56 +00:00
return 0 ;
}
return 1 ;
}
return 0 ;
}
2008-11-20 14:06:36 +00:00
static void P_ForceAngle ( DukePlayer_t * p )
2006-12-10 06:49:01 +00:00
{
2008-11-20 14:06:36 +00:00
int n = 128 - ( krand ( ) & 255 ) ;
2006-12-10 06:49:01 +00:00
p - > horiz + = 64 ;
p - > return_to_center = 9 ;
p - > look_ang = n > > 1 ;
p - > rotscrnang = n > > 1 ;
}
2008-11-20 14:06:36 +00:00
static char A_Dodge ( spritetype * s )
2006-04-13 20:47:06 +00:00
{
2007-12-12 17:42:14 +00:00
int bx , by , bxvect , byvect , d , i ;
int mx = s - > x , my = s - > y ;
int mxvect = sintable [ ( s - > ang + 512 ) & 2047 ] ;
int myvect = sintable [ s - > ang & 2047 ] ;
2006-04-13 20:47:06 +00:00
2008-12-01 10:44:18 +00:00
if ( A_CheckEnemySprite ( s ) & & s - > extra < = 0 ) // hack
return 0 ;
2008-11-20 14:06:36 +00:00
for ( i = headspritestat [ STAT_PROJECTILE ] ; i > = 0 ; i = nextspritestat [ i ] ) //weapons list
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( OW = = i | | SECT ! = s - > sectnum )
2006-04-13 20:47:06 +00:00
continue ;
bx = SX - mx ;
by = SY - my ;
2006-11-15 01:16:55 +00:00
bxvect = sintable [ ( SA + 512 ) & 2047 ] ;
byvect = sintable [ SA & 2047 ] ;
2006-04-13 20:47:06 +00:00
if ( mxvect * bx + myvect * by > = 0 )
if ( bxvect * bx + byvect * by < 0 )
{
d = bxvect * by - byvect * bx ;
if ( klabs ( d ) < 65536 * 64 )
{
2008-11-20 14:06:36 +00:00
s - > ang - = 512 + ( krand ( ) & 1024 ) ;
2006-04-13 20:47:06 +00:00
return 1 ;
}
}
}
return 0 ;
}
2008-11-20 14:06:36 +00:00
int A_GetFurthestAngle ( int iActor , int angs )
2006-04-13 20:47:06 +00:00
{
2006-12-20 03:27:25 +00:00
spritetype * s = & sprite [ iActor ] ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( s - > picnum ! = APLAYER & & ( ActorExtra [ iActor ] . temp_data [ 0 ] & 63 ) > 2 )
2008-09-03 04:20:46 +00:00
return ( s - > ang + 1024 ) ;
2006-04-13 20:47:06 +00:00
{
2008-09-03 04:20:46 +00:00
int furthest_angle = 0 ;
short hitsect , hitwall , hitspr ;
int hx , hy , hz , d ;
int greatestd = - ( 1 < < 30 ) ;
int angincs = 2048 / angs , j ;
2006-04-13 20:47:06 +00:00
2008-09-03 04:20:46 +00:00
for ( j = s - > ang ; j < ( 2048 + s - > ang ) ; j + = angincs )
2006-04-13 20:47:06 +00:00
{
2008-09-03 04:20:46 +00:00
hitscan ( s - > x , s - > y , s - > z - ( 8 < < 8 ) , s - > sectnum ,
sintable [ ( j + 512 ) & 2047 ] ,
sintable [ j & 2047 ] , 0 ,
& hitsect , & hitwall , & hitspr , & hx , & hy , & hz , CLIPMASK1 ) ;
d = klabs ( hx - s - > x ) + klabs ( hy - s - > y ) ;
if ( d > greatestd )
{
greatestd = d ;
furthest_angle = j ;
}
2006-04-13 20:47:06 +00:00
}
2008-09-03 04:20:46 +00:00
return ( furthest_angle & 2047 ) ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
int A_FurthestVisiblePoint ( int iActor , spritetype * ts , int * dax , int * day )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( ( ActorExtra [ iActor ] . temp_data [ 0 ] & 63 ) ) return - 1 ;
2006-04-13 20:47:06 +00:00
{
2008-09-03 04:20:46 +00:00
short hitsect , hitwall , hitspr , angincs ;
int hx , hy , hz , d , da ; //, d, cd, ca,tempx,tempy,cx,cy;
int j ;
spritetype * s = & sprite [ iActor ] ;
2006-04-13 20:47:06 +00:00
2008-09-03 04:20:46 +00:00
if ( ud . multimode < 2 & & ud . player_skill < 3 )
angincs = 2048 / 2 ;
2008-11-20 14:06:36 +00:00
else angincs = 2048 / ( 1 + ( krand ( ) & 1 ) ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
for ( j = ts - > ang ; j < ( 2048 + ts - > ang ) ; j + = ( angincs - ( krand ( ) & 511 ) ) )
2008-09-03 04:20:46 +00:00
{
hitscan ( ts - > x , ts - > y , ts - > z - ( 16 < < 8 ) , ts - > sectnum ,
sintable [ ( j + 512 ) & 2047 ] ,
2008-11-20 14:06:36 +00:00
sintable [ j & 2047 ] , 16384 - ( krand ( ) & 32767 ) ,
2008-09-03 04:20:46 +00:00
& hitsect , & hitwall , & hitspr , & hx , & hy , & hz , CLIPMASK1 ) ;
d = klabs ( hx - ts - > x ) + klabs ( hy - ts - > y ) ;
da = klabs ( hx - s - > x ) + klabs ( hy - s - > y ) ;
if ( d < da & & hitsect > - 1 )
if ( cansee ( hx , hy , hz , hitsect , s - > x , s - > y , s - > z - ( 16 < < 8 ) , s - > sectnum ) )
{
* dax = hx ;
* day = hy ;
return hitsect ;
}
}
return - 1 ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
void A_GetZLimits ( int iActor )
2006-04-13 20:47:06 +00:00
{
2006-12-20 03:27:25 +00:00
spritetype * s = & sprite [ iActor ] ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( s - > statnum = = 10 | | s - > statnum = = 6 | | s - > statnum = = 2 | | s - > statnum = = 1 | | s - > statnum = = 4 )
2006-04-13 20:47:06 +00:00
{
2007-12-12 17:42:14 +00:00
int hz , lz , zr = 127L ;
2006-12-18 08:37:12 +00:00
2006-11-13 23:12:47 +00:00
if ( s - > statnum = = 4 )
2006-04-13 20:47:06 +00:00
zr = 4L ;
2008-11-20 14:06:36 +00:00
getzrange ( s - > x , s - > y , s - > z - ( FOURSLEIGHT ) , s - > sectnum , & ActorExtra [ iActor ] . ceilingz , & hz , & ActorExtra [ iActor ] . floorz , & lz , zr , CLIPMASK0 ) ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( ( lz & 49152 ) = = 49152 & & ( sprite [ lz & ( MAXSPRITES - 1 ) ] . cstat & 48 ) = = 0 )
2006-04-13 20:47:06 +00:00
{
lz & = ( MAXSPRITES - 1 ) ;
2008-11-20 14:06:36 +00:00
if ( A_CheckEnemySprite ( & sprite [ lz ] ) & & sprite [ lz ] . pal ! = 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( s - > statnum ! = 4 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
ActorExtra [ iActor ] . dispicnum = - 4 ; // No shadows on actors
2006-04-13 20:47:06 +00:00
s - > xvel = - 256 ;
2008-11-20 14:06:36 +00:00
A_SetSprite ( iActor , CLIPMASK0 ) ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
else if ( sprite [ lz ] . picnum = = APLAYER & & A_CheckEnemySprite ( s ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
ActorExtra [ iActor ] . dispicnum = - 4 ; // No shadows on actors
2006-04-13 20:47:06 +00:00
s - > xvel = - 256 ;
2008-11-20 14:06:36 +00:00
A_SetSprite ( iActor , CLIPMASK0 ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
else if ( s - > statnum = = 4 & & sprite [ lz ] . picnum = = APLAYER )
if ( s - > owner = = lz )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
ActorExtra [ iActor ] . ceilingz = sector [ s - > sectnum ] . ceilingz ;
ActorExtra [ iActor ] . floorz = sector [ s - > sectnum ] . floorz ;
2006-04-13 20:47:06 +00:00
}
}
}
else
{
2008-11-20 14:06:36 +00:00
ActorExtra [ iActor ] . ceilingz = sector [ s - > sectnum ] . ceilingz ;
ActorExtra [ iActor ] . floorz = sector [ s - > sectnum ] . floorz ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
void A_Fall ( int iActor )
2006-04-13 20:47:06 +00:00
{
2006-12-20 03:27:25 +00:00
spritetype * s = & sprite [ iActor ] ;
2008-11-24 09:22:07 +00:00
int hz , lz , c = g_spriteGravity ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( G_CheckForSpaceFloor ( s - > sectnum ) )
2006-04-13 20:47:06 +00:00
c = 0 ;
else
{
2008-11-20 14:06:36 +00:00
if ( G_CheckForSpaceCeiling ( s - > sectnum ) | | sector [ s - > sectnum ] . lotag = = 2 )
2008-11-24 09:22:07 +00:00
c = g_spriteGravity / 6 ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
if ( ( s - > statnum = = 1 | | s - > statnum = = 10 | | s - > statnum = = 2 | | s - > statnum = = 6 ) )
2008-11-20 14:06:36 +00:00
getzrange ( s - > x , s - > y , s - > z - ( FOURSLEIGHT ) , s - > sectnum , & ActorExtra [ iActor ] . ceilingz , & hz , & ActorExtra [ iActor ] . floorz , & lz , 127L , CLIPMASK0 ) ;
2006-04-13 20:47:06 +00:00
else
{
2008-11-20 14:06:36 +00:00
ActorExtra [ iActor ] . ceilingz = sector [ s - > sectnum ] . ceilingz ;
ActorExtra [ iActor ] . floorz = sector [ s - > sectnum ] . floorz ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
if ( s - > z < ActorExtra [ iActor ] . floorz - ( FOURSLEIGHT ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( sector [ s - > sectnum ] . lotag = = 2 & & s - > zvel > 3122 )
2006-04-13 20:47:06 +00:00
s - > zvel = 3144 ;
2006-11-13 23:12:47 +00:00
if ( s - > zvel < 6144 )
2006-04-13 20:47:06 +00:00
s - > zvel + = c ;
else s - > zvel = 6144 ;
s - > z + = s - > zvel ;
}
2008-11-20 14:06:36 +00:00
if ( s - > z > = ActorExtra [ iActor ] . floorz - ( FOURSLEIGHT ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
s - > z = ActorExtra [ iActor ] . floorz - FOURSLEIGHT ;
2006-04-13 20:47:06 +00:00
s - > zvel = 0 ;
}
}
2008-11-20 14:06:36 +00:00
int G_GetAngleDelta ( int a , int na )
2006-04-13 20:47:06 +00:00
{
a & = 2047 ;
na & = 2047 ;
2006-11-13 23:12:47 +00:00
if ( klabs ( a - na ) < 1024 )
2007-03-11 00:20:32 +00:00
{
2008-11-20 14:06:36 +00:00
// OSD_Printf("G_GetAngleDelta() returning %d\n",na-a);
2006-04-13 20:47:06 +00:00
return ( na - a ) ;
2007-03-11 00:47:32 +00:00
}
2006-04-13 20:47:06 +00:00
2006-12-18 08:37:12 +00:00
if ( na > 1024 ) na - = 2048 ;
if ( a > 1024 ) a - = 2048 ;
na - = 2048 ;
a - = 2048 ;
2008-11-20 14:06:36 +00:00
// OSD_Printf("G_GetAngleDelta() returning %d\n",na-a);
2006-12-18 08:37:12 +00:00
return ( na - a ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
static void X_AlterAng ( int a )
2006-04-13 20:47:06 +00:00
{
2008-02-17 05:08:18 +00:00
intptr_t * moveptr = ( intptr_t * ) g_t [ 1 ] ;
2008-09-03 04:20:46 +00:00
int ticselapsed = ( g_t [ 0 ] ) & 31 ;
2006-04-13 20:47:06 +00:00
g_sp - > xvel + = ( * moveptr - g_sp - > xvel ) / 5 ;
2006-11-13 23:12:47 +00:00
if ( g_sp - > zvel < 648 ) g_sp - > zvel + = ( ( * ( moveptr + 1 ) < < 4 ) - g_sp - > zvel ) / 5 ;
2006-04-13 20:47:06 +00:00
2008-12-01 10:44:18 +00:00
if ( A_CheckEnemySprite ( g_sp ) & & g_sp - > extra < = 0 ) // hack
return ;
2006-11-13 23:12:47 +00:00
if ( a & seekplayer )
2006-04-13 20:47:06 +00:00
{
2008-09-03 04:20:46 +00:00
int aang = g_sp - > ang , angdif , goalang ;
int j = g_player [ g_p ] . ps - > holoduke_on ;
2006-04-13 20:47:06 +00:00
// NOTE: looks like 'owner' is set to target sprite ID...
2006-11-14 21:35:50 +00:00
if ( j > = 0 & & cansee ( sprite [ j ] . x , sprite [ j ] . y , sprite [ j ] . z , sprite [ j ] . sectnum , g_sp - > x , g_sp - > y , g_sp - > z , g_sp - > sectnum ) )
2006-04-13 20:47:06 +00:00
g_sp - > owner = j ;
2007-08-27 06:46:31 +00:00
else g_sp - > owner = g_player [ g_p ] . ps - > i ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( sprite [ g_sp - > owner ] . picnum = = APLAYER )
2008-11-20 14:06:36 +00:00
goalang = getangle ( ActorExtra [ g_i ] . lastvx - g_sp - > x , ActorExtra [ g_i ] . lastvy - g_sp - > y ) ;
2006-04-13 20:47:06 +00:00
else
goalang = getangle ( sprite [ g_sp - > owner ] . x - g_sp - > x , sprite [ g_sp - > owner ] . y - g_sp - > y ) ;
2006-11-13 23:12:47 +00:00
if ( g_sp - > xvel & & g_sp - > picnum ! = DRONE )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
angdif = G_GetAngleDelta ( aang , goalang ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( ticselapsed < 2 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( klabs ( angdif ) < 256 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
j = 128 - ( krand ( ) & 256 ) ;
2006-04-13 20:47:06 +00:00
g_sp - > ang + = j ;
2008-11-20 14:06:36 +00:00
if ( A_GetHitscanRange ( g_i ) < 844 )
2006-04-13 20:47:06 +00:00
g_sp - > ang - = j ;
}
}
2006-11-13 23:12:47 +00:00
else if ( ticselapsed > 18 & & ticselapsed < 26 ) // choose
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( klabs ( angdif > > 2 ) < 128 ) g_sp - > ang = goalang ;
2006-04-13 20:47:06 +00:00
else g_sp - > ang + = angdif > > 2 ;
}
}
else g_sp - > ang = goalang ;
}
2006-11-13 23:12:47 +00:00
if ( ticselapsed < 1 )
2006-04-13 20:47:06 +00:00
{
2008-09-03 04:20:46 +00:00
int j = 2 ;
2006-11-13 23:12:47 +00:00
if ( a & furthestdir )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
g_sp - > ang = A_GetFurthestAngle ( g_i , j ) ;
2007-08-27 06:46:31 +00:00
g_sp - > owner = g_player [ g_p ] . ps - > i ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
if ( a & fleeenemy )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
g_sp - > ang = A_GetFurthestAngle ( g_i , j ) ; // += angdif; // = G_GetAngleDelta(aang,goalang)>>1;
2006-04-13 20:47:06 +00:00
}
}
}
2008-11-20 14:06:36 +00:00
static void X_Move ( void )
2006-04-13 20:47:06 +00:00
{
2008-06-11 09:25:58 +00:00
int l ;
2008-06-10 19:27:39 +00:00
intptr_t * moveptr ;
2006-12-23 02:38:47 +00:00
int a = g_sp - > hitag , goalang , angdif ;
2007-12-12 17:42:14 +00:00
int daxvel ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( a = = - 1 ) a = 0 ;
2006-04-13 20:47:06 +00:00
g_t [ 0 ] + + ;
2008-12-01 10:44:18 +00:00
if ( g_t [ 1 ] = = 0 | | a = = 0 | | ( A_CheckEnemySprite ( g_sp ) & & g_sp - > extra < = 0 ) )
{
if ( ( A_CheckEnemySprite ( g_sp ) & & g_sp - > extra < = 0 ) | | ( ActorExtra [ g_i ] . bposx ! = g_sp - > x ) | | ( ActorExtra [ g_i ] . bposy ! = g_sp - > y ) )
{
ActorExtra [ g_i ] . bposx = g_sp - > x ;
ActorExtra [ g_i ] . bposy = g_sp - > y ;
setsprite ( g_i , g_sp - > x , g_sp - > y , g_sp - > z ) ;
}
return ;
}
2006-11-13 23:12:47 +00:00
if ( a & face_player )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > newowner > = 0 )
goalang = getangle ( g_player [ g_p ] . ps - > oposx - g_sp - > x , g_player [ g_p ] . ps - > oposy - g_sp - > y ) ;
else goalang = getangle ( g_player [ g_p ] . ps - > posx - g_sp - > x , g_player [ g_p ] . ps - > posy - g_sp - > y ) ;
2008-11-20 14:06:36 +00:00
angdif = G_GetAngleDelta ( g_sp - > ang , goalang ) > > 2 ;
2007-03-08 21:07:10 +00:00
if ( ( angdif > - 8 & & angdif < 0 ) | | ( angdif < 8 & & angdif > 0 ) )
angdif * = 2 ;
2006-04-13 20:47:06 +00:00
g_sp - > ang + = angdif ;
}
2006-11-13 23:12:47 +00:00
if ( a & spin )
2006-11-14 21:35:50 +00:00
g_sp - > ang + = sintable [ ( ( g_t [ 0 ] < < 3 ) & 2047 ) ] > > 6 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( a & face_player_slow )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > newowner > = 0 )
goalang = getangle ( g_player [ g_p ] . ps - > oposx - g_sp - > x , g_player [ g_p ] . ps - > oposy - g_sp - > y ) ;
else goalang = getangle ( g_player [ g_p ] . ps - > posx - g_sp - > x , g_player [ g_p ] . ps - > posy - g_sp - > y ) ;
2008-11-20 14:06:36 +00:00
angdif = G_GetAngleDelta ( g_sp - > ang , goalang ) > > 4 ;
2007-03-08 21:07:10 +00:00
if ( ( angdif > - 8 & & angdif < 0 ) | | ( angdif < 8 & & angdif > 0 ) )
angdif * = 2 ;
2006-04-13 20:47:06 +00:00
g_sp - > ang + = angdif ;
}
2006-11-13 23:12:47 +00:00
if ( ( a & jumptoplayer ) = = jumptoplayer )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( g_t [ 0 ] < 16 )
2006-04-13 20:47:06 +00:00
g_sp - > zvel - = ( sintable [ ( 512 + ( g_t [ 0 ] < < 4 ) ) & 2047 ] > > 5 ) ;
}
2006-11-13 23:12:47 +00:00
if ( a & face_player_smart )
2006-04-13 20:47:06 +00:00
{
2007-12-12 17:42:14 +00:00
int newx = g_player [ g_p ] . ps - > posx + ( g_player [ g_p ] . ps - > posxv / 768 ) ;
int newy = g_player [ g_p ] . ps - > posy + ( g_player [ g_p ] . ps - > posyv / 768 ) ;
2007-03-11 00:47:32 +00:00
2006-04-13 20:47:06 +00:00
goalang = getangle ( newx - g_sp - > x , newy - g_sp - > y ) ;
2008-11-20 14:06:36 +00:00
angdif = G_GetAngleDelta ( g_sp - > ang , goalang ) > > 2 ;
2007-03-08 21:07:10 +00:00
if ( ( angdif > - 8 & & angdif < 0 ) | | ( angdif < 8 & & angdif > 0 ) )
angdif * = 2 ;
2006-04-13 20:47:06 +00:00
g_sp - > ang + = angdif ;
}
2008-02-17 05:08:18 +00:00
moveptr = ( intptr_t * ) g_t [ 1 ] ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( a & geth ) g_sp - > xvel + = ( * moveptr - g_sp - > xvel ) > > 1 ;
if ( a & getv ) g_sp - > zvel + = ( ( * ( moveptr + 1 ) < < 4 ) - g_sp - > zvel ) > > 1 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( a & dodgebullet )
2008-11-20 14:06:36 +00:00
A_Dodge ( g_sp ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( g_sp - > picnum ! = APLAYER )
2008-11-20 14:06:36 +00:00
X_AlterAng ( a ) ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( g_sp - > xvel > - 6 & & g_sp - > xvel < 6 ) g_sp - > xvel = 0 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
a = A_CheckEnemySprite ( g_sp ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( g_sp - > xvel | | g_sp - > zvel )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( a & & g_sp - > picnum ! = ROTATEGUN )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( ( g_sp - > picnum = = DRONE | | g_sp - > picnum = = COMMANDER ) & & g_sp - > extra > 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( g_sp - > picnum = = COMMANDER )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . floorz = l = getflorzofslope ( g_sp - > sectnum , g_sp - > x , g_sp - > y ) ;
2006-11-14 21:35:50 +00:00
if ( g_sp - > z > ( l - ( 8 < < 8 ) ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( g_sp - > z > ( l - ( 8 < < 8 ) ) ) g_sp - > z = l - ( 8 < < 8 ) ;
2006-04-13 20:47:06 +00:00
g_sp - > zvel = 0 ;
}
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . ceilingz = l = getceilzofslope ( g_sp - > sectnum , g_sp - > x , g_sp - > y ) ;
2006-11-14 21:35:50 +00:00
if ( ( g_sp - > z - l ) < ( 80 < < 8 ) )
2006-04-13 20:47:06 +00:00
{
g_sp - > z = l + ( 80 < < 8 ) ;
g_sp - > zvel = 0 ;
}
}
else
{
2006-11-14 21:35:50 +00:00
if ( g_sp - > zvel > 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . floorz = l = getflorzofslope ( g_sp - > sectnum , g_sp - > x , g_sp - > y ) ;
2006-11-14 21:35:50 +00:00
if ( g_sp - > z > ( l - ( 30 < < 8 ) ) )
2006-04-13 20:47:06 +00:00
g_sp - > z = l - ( 30 < < 8 ) ;
}
else
{
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . ceilingz = l = getceilzofslope ( g_sp - > sectnum , g_sp - > x , g_sp - > y ) ;
2006-11-14 21:35:50 +00:00
if ( ( g_sp - > z - l ) < ( 50 < < 8 ) )
2006-04-13 20:47:06 +00:00
{
g_sp - > z = l + ( 50 < < 8 ) ;
g_sp - > zvel = 0 ;
}
}
}
}
2006-11-13 23:12:47 +00:00
else if ( g_sp - > picnum ! = ORGANTIC )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( g_sp - > zvel > 0 & & ActorExtra [ g_i ] . floorz < g_sp - > z )
g_sp - > z = ActorExtra [ g_i ] . floorz ;
2006-11-14 21:35:50 +00:00
if ( g_sp - > zvel < 0 )
2006-04-13 20:47:06 +00:00
{
l = getceilzofslope ( g_sp - > sectnum , g_sp - > x , g_sp - > y ) ;
2006-11-14 21:35:50 +00:00
if ( ( g_sp - > z - l ) < ( 66 < < 8 ) )
2006-04-13 20:47:06 +00:00
{
g_sp - > z = l + ( 66 < < 8 ) ;
g_sp - > zvel > > = 1 ;
}
}
}
}
2006-11-13 23:12:47 +00:00
else if ( g_sp - > picnum = = APLAYER )
2008-11-20 14:06:36 +00:00
if ( ( g_sp - > z - ActorExtra [ g_i ] . ceilingz ) < ( 32 < < 8 ) )
g_sp - > z = ActorExtra [ g_i ] . ceilingz + ( 32 < < 8 ) ;
2006-04-13 20:47:06 +00:00
daxvel = g_sp - > xvel ;
angdif = g_sp - > ang ;
2006-11-14 21:35:50 +00:00
if ( a & & g_sp - > picnum ! = ROTATEGUN )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( g_x < 960 & & g_sp - > xrepeat > 16 )
2006-04-13 20:47:06 +00:00
{
daxvel = - ( 1024 - g_x ) ;
2007-08-27 06:46:31 +00:00
angdif = getangle ( g_player [ g_p ] . ps - > posx - g_sp - > x , g_player [ g_p ] . ps - > posy - g_sp - > y ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( g_x < 512 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > posxv = 0 ;
g_player [ g_p ] . ps - > posyv = 0 ;
2006-04-13 20:47:06 +00:00
}
else
{
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > posxv = mulscale ( g_player [ g_p ] . ps - > posxv , g_player [ g_p ] . ps - > runspeed - 0x2000 , 16 ) ;
g_player [ g_p ] . ps - > posyv = mulscale ( g_player [ g_p ] . ps - > posyv , g_player [ g_p ] . ps - > runspeed - 0x2000 , 16 ) ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-13 23:12:47 +00:00
else if ( g_sp - > picnum ! = DRONE & & g_sp - > picnum ! = SHARK & & g_sp - > picnum ! = COMMANDER )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( ActorExtra [ g_i ] . bposz ! = g_sp - > z | | ( ud . multimode < 2 & & ud . player_skill < 2 ) )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( ( g_t [ 0 ] & 1 ) | | g_player [ g_p ] . ps - > actorsqu = = g_i ) return ;
2006-04-13 20:47:06 +00:00
else daxvel < < = 1 ;
}
else
{
2007-08-27 06:46:31 +00:00
if ( ( g_t [ 0 ] & 3 ) | | g_player [ g_p ] . ps - > actorsqu = = g_i ) return ;
2006-04-13 20:47:06 +00:00
else daxvel < < = 2 ;
}
}
}
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . movflag = A_MoveSprite ( g_i ,
( daxvel * ( sintable [ ( angdif + 512 ) & 2047 ] ) ) > > 14 ,
( daxvel * ( sintable [ angdif & 2047 ] ) ) > > 14 , g_sp - > zvel , CLIPMASK0 ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
if ( a )
2006-04-13 20:47:06 +00:00
{
if ( sector [ g_sp - > sectnum ] . ceilingstat & 1 )
g_sp - > shade + = ( sector [ g_sp - > sectnum ] . ceilingshade - g_sp - > shade ) > > 1 ;
else g_sp - > shade + = ( sector [ g_sp - > sectnum ] . floorshade - g_sp - > shade ) > > 1 ;
2006-11-14 21:35:50 +00:00
if ( sector [ g_sp - > sectnum ] . floorpicnum = = MIRROR )
2006-04-13 20:47:06 +00:00
deletesprite ( g_i ) ;
}
}
2008-11-20 14:06:36 +00:00
static inline void X_DoConditional ( int condition )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( condition )
2006-04-13 20:47:06 +00:00
{
// skip 'else' pointer.. and...
insptr + = 2 ;
2008-11-20 14:06:36 +00:00
X_DoExecute ( ) ;
2008-02-14 08:35:30 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2008-02-17 05:08:18 +00:00
insptr = ( intptr_t * ) * ( insptr + 1 ) ;
2008-07-19 19:06:21 +00:00
if ( ( ( * insptr ) & 0xFFF ) = = CON_ELSE )
2006-04-13 20:47:06 +00:00
{
2008-02-14 08:35:30 +00:00
// else...
// skip 'else' and...
insptr + = 2 ;
2008-11-20 14:06:36 +00:00
X_DoExecute ( ) ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
static int X_DoExecute ( void )
2006-04-13 20:47:06 +00:00
{
2008-08-11 23:33:53 +00:00
int j , l , s , tw = * insptr ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( g_killitFlag ) return 1 ;
2006-04-13 20:47:06 +00:00
// Bsprintf(g_szBuf,"Parsing: %d",*insptr);
// AddLog(g_szBuf);
2008-11-20 14:06:36 +00:00
g_errorLineNum = tw > > 12 ;
2008-08-16 07:53:29 +00:00
g_tw = tw & = 0xFFF ;
2008-07-19 19:06:21 +00:00
2006-11-13 23:12:47 +00:00
switch ( tw )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case CON_REDEFINEQUOTE :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-12-18 21:29:55 +00:00
{
2007-02-08 04:19:39 +00:00
int q = * insptr + + , i = * insptr + + ;
2008-11-20 14:06:36 +00:00
if ( ( ScriptQuotes [ q ] = = NULL | | ScriptQuoteRedefinitions [ i ] = = NULL ) & & g_scriptSanityChecks )
2007-02-08 04:19:39 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " %s %d null quote \n " , g_errorLineNum , keyw [ g_tw ] , q , i ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Bstrcpy ( ScriptQuotes [ q ] , ScriptQuoteRedefinitions [ i ] ) ;
2006-12-18 21:29:55 +00:00
break ;
}
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_GETTHISPROJECTILE :
case CON_SETTHISPROJECTILE :
2007-02-08 04:19:39 +00:00
insptr + + ;
{
// syntax [gs]etplayer[<var>].x <VAR>
// <varid> <xxxid> <varid>
int lVar1 = * insptr + + , lLabelID = * insptr + + , lVar2 = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_AccessActiveProjectile ( tw = = CON_SETTHISPROJECTILE , lVar1 , lLabelID , lVar2 ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFRND :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( rnd ( * insptr ) ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFCANSHOOTTARGET :
if ( g_x > 1024 )
{
2006-12-18 08:37:12 +00:00
short temphit , sclip = 768 , angdif = 16 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( A_CheckEnemySprite ( g_sp ) & & g_sp - > xrepeat > 56 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
sclip = 3084 ;
angdif = 48 ;
}
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
j = A_CheckHitSprite ( g_i , & temphit ) ;
2006-11-16 03:02:42 +00:00
if ( j = = ( 1 < < 30 ) )
{
2008-11-20 14:06:36 +00:00
X_DoConditional ( 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
}
if ( j > sclip )
{
if ( temphit > = 0 & & sprite [ temphit ] . picnum = = g_sp - > picnum )
j = 0 ;
2006-04-13 20:47:06 +00:00
else
{
2006-11-16 03:02:42 +00:00
g_sp - > ang + = angdif ;
2008-11-20 14:06:36 +00:00
j = A_CheckHitSprite ( g_i , & temphit ) ;
2006-11-16 03:02:42 +00:00
g_sp - > ang - = angdif ;
if ( j > sclip )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( temphit > = 0 & & sprite [ temphit ] . picnum = = g_sp - > picnum )
j = 0 ;
else
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
g_sp - > ang - = angdif ;
2008-11-20 14:06:36 +00:00
j = A_CheckHitSprite ( g_i , & temphit ) ;
2006-11-16 03:02:42 +00:00
g_sp - > ang + = angdif ;
if ( j > 768 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( temphit > = 0 & & sprite [ temphit ] . picnum = = g_sp - > picnum )
j = 0 ;
else j = 1 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
else j = 0 ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-16 03:02:42 +00:00
else j = 0 ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-16 03:02:42 +00:00
else j = 0 ;
}
else j = 1 ;
2006-04-18 03:11:38 +00:00
2008-11-20 14:06:36 +00:00
X_DoConditional ( j ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFCANSEETARGET :
2008-11-20 14:06:36 +00:00
j = cansee ( g_sp - > x , g_sp - > y , g_sp - > z - ( ( krand ( ) & 41 ) < < 8 ) , g_sp - > sectnum , g_player [ g_p ] . ps - > posx , g_player [ g_p ] . ps - > posy , g_player [ g_p ] . ps - > posz /*-((krand()&41)<<8)*/ , sprite [ g_player [ g_p ] . ps - > i ] . sectnum ) ;
X_DoConditional ( j ) ;
if ( j ) ActorExtra [ g_i ] . timetosleep = SLEEPTIME ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFACTORNOTSTAYPUT :
2008-11-20 14:06:36 +00:00
X_DoConditional ( ActorExtra [ g_i ] . actorstayput = = - 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case CON_IFCANSEE :
{
spritetype * s ;
2006-11-13 23:12:47 +00:00
2006-11-16 03:02:42 +00:00
// select sprite for monster to target
// if holoduke is on, let them target holoduke first.
//
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > holoduke_on > = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
s = & sprite [ g_player [ g_p ] . ps - > holoduke_on ] ;
2008-11-20 14:06:36 +00:00
j = cansee ( g_sp - > x , g_sp - > y , g_sp - > z - ( krand ( ) & ( ( 32 < < 8 ) - 1 ) ) , g_sp - > sectnum ,
2006-11-16 03:02:42 +00:00
s - > x , s - > y , s - > z , s - > sectnum ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
// they can't see player's holoduke
// check for player...
2007-08-27 06:46:31 +00:00
s = & sprite [ g_player [ g_p ] . ps - > i ] ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
2007-08-27 06:46:31 +00:00
else s = & sprite [ g_player [ g_p ] . ps - > i ] ; // holoduke not on. look for player
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
// can they see player, (or player's holoduke)
2008-11-20 14:06:36 +00:00
j = cansee ( g_sp - > x , g_sp - > y , g_sp - > z - ( krand ( ) & ( ( 47 < < 8 ) ) ) , g_sp - > sectnum ,
2006-11-16 03:02:42 +00:00
s - > x , s - > y , s - > z - ( 24 < < 8 ) , s - > sectnum ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j = = 0 )
{
// they can't see it.
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
// Huh?. This does nothing....
// (the result is always j==0....)
2008-12-10 11:36:53 +00:00
// if ((klabs(ActorExtra[g_i].lastvx-g_sp->x)+klabs(ActorExtra[g_i].lastvy-g_sp->y)) <
// (klabs(ActorExtra[g_i].lastvx-s->x)+klabs(ActorExtra[g_i].lastvy-s->y)))
// j = 0;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
// um yeah, this if() will always fire....
2008-12-10 11:36:53 +00:00
// if (j == 0)
2006-11-16 03:02:42 +00:00
{
// search around for target player
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
// also modifies 'target' x&y if found..
2006-04-13 20:47:06 +00:00
2008-12-10 11:36:53 +00:00
j = 1 ;
if ( A_FurthestVisiblePoint ( g_i , s , & ActorExtra [ g_i ] . lastvx , & ActorExtra [ g_i ] . lastvy ) = = - 1 )
j = 0 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
else
{
// else, they did see it.
// save where we were looking...
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . lastvx = s - > x ;
ActorExtra [ g_i ] . lastvy = s - > y ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
2008-12-10 11:36:53 +00:00
if ( j & & ( g_sp - > statnum = = 1 | | g_sp - > statnum = = 6 ) )
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . timetosleep = SLEEPTIME ;
2006-04-18 03:11:38 +00:00
2008-12-10 11:36:53 +00:00
X_DoConditional ( j ) ;
2006-11-16 03:02:42 +00:00
break ;
}
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFHITWEAPON :
2008-11-20 14:06:36 +00:00
X_DoConditional ( A_IncurDamage ( g_i ) > = 0 ) ;
2006-04-13 20:47:06 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFSQUISHED :
2008-12-10 11:36:53 +00:00
X_DoConditional ( A_CheckSquished ( g_i , g_p ) ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFDEAD :
2008-12-10 11:36:53 +00:00
// j = g_sp->extra;
// if (g_sp->picnum == APLAYER)
// j--;
X_DoConditional ( g_sp - > extra < = 0 ) ;
2007-02-08 04:19:39 +00:00
break ;
2006-11-16 03:02:42 +00:00
case CON_AI :
insptr + + ;
2008-04-25 10:22:22 +00:00
//Following changed to use pointersizes
2006-11-16 03:02:42 +00:00
g_t [ 5 ] = * insptr + + ; // Ai
2008-02-17 05:08:18 +00:00
g_t [ 4 ] = * ( intptr_t * ) ( g_t [ 5 ] ) ; // Action
2008-11-25 13:06:36 +00:00
if ( g_t [ 5 ] ) g_t [ 1 ] = * ( ( ( intptr_t * ) g_t [ 5 ] ) + 1 ) ; // move
2008-04-24 09:53:16 +00:00
g_sp - > hitag = * ( ( ( intptr_t * ) g_t [ 5 ] ) + 2 ) ; // move flags
2006-11-16 03:02:42 +00:00
g_t [ 0 ] = g_t [ 2 ] = g_t [ 3 ] = 0 ; // count, actioncount... g_t[3] = ???
2008-12-01 10:44:18 +00:00
if ( A_CheckEnemySprite ( g_sp ) & & g_sp - > extra < = 0 ) // hack
break ;
2006-11-16 03:02:42 +00:00
if ( g_sp - > hitag & random_angle )
2008-11-20 14:06:36 +00:00
g_sp - > ang = krand ( ) & 2047 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_ACTION :
insptr + + ;
g_t [ 2 ] = 0 ;
g_t [ 3 ] = 0 ;
g_t [ 4 ] = * insptr + + ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFPDISTL :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( g_x < * insptr ) ;
if ( g_x > MAXSLEEPDIST & & ActorExtra [ g_i ] . timetosleep = = 0 )
ActorExtra [ g_i ] . timetosleep = SLEEPTIME ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFPDISTG :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( g_x > * insptr ) ;
if ( g_x > MAXSLEEPDIST & & ActorExtra [ g_i ] . timetosleep = = 0 )
ActorExtra [ g_i ] . timetosleep = SLEEPTIME ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_ELSE :
2008-02-17 05:08:18 +00:00
insptr = ( intptr_t * ) * ( insptr + 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_ADDSTRENGTH :
insptr + + ;
g_sp - > extra + = * insptr + + ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_STRENGTH :
insptr + + ;
g_sp - > extra = * insptr + + ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFGOTWEAPONCE :
insptr + + ;
2008-11-20 14:06:36 +00:00
if ( ( GametypeFlags [ ud . coop ] & GAMETYPE_WEAPSTAY ) & & ud . multimode > 1 )
2006-11-16 03:02:42 +00:00
{
if ( * insptr = = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
for ( j = 0 ; j < g_player [ g_p ] . ps - > weapreccnt ; j + + )
if ( g_player [ g_p ] . ps - > weaprecs [ j ] = = g_sp - > picnum )
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2008-11-20 14:06:36 +00:00
X_DoConditional ( j < g_player [ g_p ] . ps - > weapreccnt & & g_sp - > owner = = g_i ) ;
2006-11-15 01:16:55 +00:00
}
2007-08-27 06:46:31 +00:00
else if ( g_player [ g_p ] . ps - > weapreccnt < 16 )
2006-11-16 03:02:42 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > weaprecs [ g_player [ g_p ] . ps - > weapreccnt + + ] = g_sp - > picnum ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( g_sp - > owner = = g_i ) ;
2006-11-16 03:02:42 +00:00
}
2008-11-20 14:06:36 +00:00
else X_DoConditional ( 0 ) ;
2006-11-16 03:02:42 +00:00
}
2008-11-20 14:06:36 +00:00
else X_DoConditional ( 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_GETLASTPAL :
insptr + + ;
if ( g_sp - > picnum = = APLAYER )
2007-08-27 06:46:31 +00:00
g_sp - > pal = g_player [ g_sp - > yvel ] . ps - > palookup ;
2008-12-02 10:44:39 +00:00
else
{
if ( g_sp - > pal = = 1 & & g_sp - > extra = = 0 ) // hack for frozen
g_sp - > extra + + ;
g_sp - > pal = ActorExtra [ g_i ] . tempang ;
}
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . tempang = 0 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_TOSSWEAPON :
insptr + + ;
2008-11-20 14:06:36 +00:00
P_DropWeapon ( g_player [ g_sp - > yvel ] . ps ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_NULLOP :
insptr + + ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_MIKESND :
insptr + + ;
2008-11-20 14:06:36 +00:00
if ( ( g_sp - > yvel < 0 | | g_sp - > yvel > = MAXSOUNDS ) & & g_scriptSanityChecks )
2008-08-09 10:43:27 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sound %d \n " , g_errorLineNum , keyw [ g_tw ] , g_sp - > yvel ) ;
2008-08-09 10:43:27 +00:00
insptr + + ;
break ;
}
2008-11-20 14:06:36 +00:00
if ( ! A_CheckSoundPlaying ( g_i , g_sp - > yvel ) )
A_PlaySound ( g_sp - > yvel , g_i ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_PKICK :
insptr + + ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
if ( ud . multimode > 1 & & g_sp - > picnum = = APLAYER )
{
2007-08-27 06:46:31 +00:00
if ( g_player [ otherp ] . ps - > quick_kick = = 0 )
g_player [ otherp ] . ps - > quick_kick = 14 ;
2006-11-16 03:02:42 +00:00
}
2007-08-27 06:46:31 +00:00
else if ( g_sp - > picnum ! = APLAYER & & g_player [ g_p ] . ps - > quick_kick = = 0 )
g_player [ g_p ] . ps - > quick_kick = 14 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_SIZETO :
insptr + + ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
j = ( * insptr + + - g_sp - > xrepeat ) < < 1 ;
g_sp - > xrepeat + = ksgn ( j ) ;
2006-04-18 21:18:30 +00:00
2008-11-20 14:06:36 +00:00
if ( ( g_sp - > picnum = = APLAYER & & g_sp - > yrepeat < 36 ) | | * insptr < g_sp - > yrepeat | | ( ( g_sp - > yrepeat * ( tilesizy [ g_sp - > picnum ] + 8 ) ) < < 2 ) < ( ActorExtra [ g_i ] . floorz - ActorExtra [ g_i ] . ceilingz ) )
2006-11-16 03:02:42 +00:00
{
j = ( ( * insptr ) - g_sp - > yrepeat ) < < 1 ;
if ( klabs ( j ) ) g_sp - > yrepeat + = ksgn ( j ) ;
}
insptr + + ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_SIZEAT :
insptr + + ;
g_sp - > xrepeat = ( char ) * insptr + + ;
g_sp - > yrepeat = ( char ) * insptr + + ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_SHOOT :
insptr + + ;
2008-11-20 14:06:36 +00:00
A_Shoot ( g_i , ( short ) * insptr + + ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_SOUNDONCE :
insptr + + ;
2008-11-20 14:06:36 +00:00
if ( ( * insptr < 0 | | * insptr > = MAXSOUNDS ) & & g_scriptSanityChecks )
2008-08-23 15:37:30 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sound %d \n " , g_errorLineNum , keyw [ g_tw ] , * insptr ) ;
2008-08-23 15:37:30 +00:00
insptr + + ; break ;
}
2008-11-20 14:06:36 +00:00
if ( ! A_CheckSoundPlaying ( g_i , * insptr ) )
A_PlaySound ( ( short ) * insptr , g_i ) ;
2006-11-16 03:02:42 +00:00
insptr + + ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFSOUND :
insptr + + ;
2008-11-20 14:06:36 +00:00
if ( ( * insptr < 0 | | * insptr > = MAXSOUNDS ) & & g_scriptSanityChecks )
2008-08-23 15:37:30 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sound %d \n " , g_errorLineNum , keyw [ g_tw ] , * insptr ) ;
2008-08-23 15:37:30 +00:00
insptr + + ; break ;
}
2008-11-20 14:06:36 +00:00
X_DoConditional ( A_CheckSoundPlaying ( g_i , * insptr ) ) ;
// X_DoConditional(SoundOwner[*insptr][0].i == g_i);
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_STOPSOUND :
insptr + + ;
2008-11-20 14:06:36 +00:00
if ( ( * insptr < 0 | | * insptr > = MAXSOUNDS ) & & g_scriptSanityChecks )
2008-08-23 15:37:30 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sound %d \n " , g_errorLineNum , keyw [ g_tw ] , * insptr ) ;
2008-08-23 15:37:30 +00:00
insptr + + ; break ;
}
2008-11-20 14:06:36 +00:00
if ( A_CheckSoundPlaying ( g_i , * insptr ) )
A_StopSound ( ( short ) * insptr , g_i ) ;
2006-11-16 03:02:42 +00:00
insptr + + ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_GLOBALSOUND :
insptr + + ;
2008-11-20 14:06:36 +00:00
if ( ( * insptr < 0 | | * insptr > = MAXSOUNDS ) & & g_scriptSanityChecks )
2008-08-23 15:37:30 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sound %d \n " , g_errorLineNum , keyw [ g_tw ] , * insptr ) ;
2008-08-23 15:37:30 +00:00
insptr + + ; break ;
}
2008-11-20 14:06:36 +00:00
if ( g_p = = screenpeek | | ( GametypeFlags [ ud . coop ] & GAMETYPE_COOPSOUND ) )
A_PlaySound ( ( short ) * insptr , g_player [ screenpeek ] . ps - > i ) ;
2006-11-16 03:02:42 +00:00
insptr + + ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_SOUND :
insptr + + ;
2008-11-20 14:06:36 +00:00
if ( ( * insptr < 0 | | * insptr > = MAXSOUNDS ) & & g_scriptSanityChecks )
2008-08-23 15:37:30 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sound %d \n " , g_errorLineNum , keyw [ g_tw ] , * insptr ) ;
2008-08-23 15:37:30 +00:00
insptr + + ; break ;
}
2008-11-20 14:06:36 +00:00
A_PlaySound ( ( short ) * insptr + + , g_i ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_TIP :
insptr + + ;
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > tipincs = 26 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_FALL :
insptr + + ;
2008-08-24 22:44:37 +00:00
g_sp - > xoffset = g_sp - > yoffset = 0 ;
2007-04-15 20:04:52 +00:00
2008-11-24 09:22:07 +00:00
j = g_spriteGravity ;
2007-04-15 20:04:52 +00:00
2008-11-20 14:06:36 +00:00
if ( G_CheckForSpaceCeiling ( g_sp - > sectnum ) | | sector [ g_sp - > sectnum ] . lotag = = 2 )
2008-11-24 09:22:07 +00:00
j = g_spriteGravity / 6 ;
2008-11-20 14:06:36 +00:00
else if ( G_CheckForSpaceFloor ( g_sp - > sectnum ) )
2007-04-15 20:04:52 +00:00
j = 0 ;
2008-11-20 14:06:36 +00:00
if ( ! ActorExtra [ g_i ] . cgg - - | | ( sector [ g_sp - > sectnum ] . floorstat & 2 ) )
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
A_GetZLimits ( g_i ) ;
ActorExtra [ g_i ] . cgg = 3 ;
2007-04-15 20:04:52 +00:00
}
2006-11-16 03:02:42 +00:00
2008-11-20 14:06:36 +00:00
if ( g_sp - > z < ( ActorExtra [ g_i ] . floorz - FOURSLEIGHT ) )
2007-04-15 20:04:52 +00:00
{
2008-08-24 22:44:37 +00:00
g_sp - > z + = g_sp - > zvel + = j ;
2006-04-13 20:47:06 +00:00
2007-04-15 20:04:52 +00:00
if ( g_sp - > zvel > 6144 ) g_sp - > zvel = 6144 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( g_sp - > z > ( ActorExtra [ g_i ] . floorz - FOURSLEIGHT ) )
g_sp - > z = ( ActorExtra [ g_i ] . floorz - FOURSLEIGHT ) ;
2008-08-24 19:09:17 +00:00
break ;
2007-04-15 20:04:52 +00:00
}
2008-11-20 14:06:36 +00:00
g_sp - > z = ActorExtra [ g_i ] . floorz - FOURSLEIGHT ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( A_CheckEnemySprite ( g_sp ) | | ( g_sp - > picnum = = APLAYER & & g_sp - > owner > = 0 ) )
2008-08-24 19:09:17 +00:00
{
if ( g_sp - > zvel > 3084 & & g_sp - > extra < = 1 )
2006-11-16 03:02:42 +00:00
{
2008-08-24 19:09:17 +00:00
if ( ! ( g_sp - > picnum = = APLAYER & & g_sp - > extra > 0 ) & & g_sp - > pal ! = 1 & & g_sp - > picnum ! = DRONE )
2007-04-15 20:04:52 +00:00
{
2008-11-20 14:06:36 +00:00
A_DoGuts ( g_i , JIBS6 , 15 ) ;
A_PlaySound ( SQUISHED , g_i ) ;
A_Spawn ( g_i , BLOODPOOL ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . picnum = SHOTSPARK1 ;
ActorExtra [ g_i ] . extra = 1 ;
2008-08-24 19:09:17 +00:00
g_sp - > zvel = 0 ;
2006-04-13 20:47:06 +00:00
}
2008-09-06 06:22:31 +00:00
else if ( g_sp - > zvel > 2048 & & sector [ g_sp - > sectnum ] . lotag ! = 1 )
2007-04-15 20:04:52 +00:00
{
2008-08-24 19:09:17 +00:00
j = g_sp - > sectnum ;
pushmove ( & g_sp - > x , & g_sp - > y , & g_sp - > z , ( short * ) & j , 128L , ( 4L < < 8 ) , ( 4L < < 8 ) , CLIPMASK0 ) ;
if ( j ! = g_sp - > sectnum & & j > = 0 & & j < MAXSECTORS )
changespritesect ( g_i , j ) ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( THUD , g_i ) ;
2007-04-15 20:04:52 +00:00
}
2008-08-24 19:09:17 +00:00
}
2008-11-20 14:06:36 +00:00
if ( g_sp - > z > ( ActorExtra [ g_i ] . floorz - FOURSLEIGHT ) )
2008-08-24 19:09:17 +00:00
{
2008-11-20 14:06:36 +00:00
A_GetZLimits ( g_i ) ;
if ( ActorExtra [ g_i ] . floorz ! = sector [ g_sp - > sectnum ] . floorz )
g_sp - > z = ( ActorExtra [ g_i ] . floorz - FOURSLEIGHT ) ;
2008-08-24 19:09:17 +00:00
break ;
}
else if ( sector [ g_sp - > sectnum ] . lotag = = 1 )
{
2008-09-01 07:15:16 +00:00
intptr_t * moveptr = ( intptr_t * ) g_t [ 1 ] ;
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ g_sp - > picnum ] )
2007-04-15 20:04:52 +00:00
{
2008-08-24 19:09:17 +00:00
default :
2008-09-01 07:15:16 +00:00
// fix for flying/jumping monsters getting stuck in water
2008-09-01 21:59:53 +00:00
if ( g_sp - > statnum ! = MAXSTATUS & & actorscrptr [ g_sp - > picnum ] & &
2008-11-25 13:06:36 +00:00
( g_sp - > hitag & jumptoplayer | |
2008-12-01 10:44:18 +00:00
( moveptr > = g_scriptPtr & & moveptr < = ( g_scriptPtr + g_scriptSize ) & & * ( moveptr + 1 ) ) )
)
2008-09-01 07:15:16 +00:00
{
// OSD_Printf("%d\n",*(moveptr+1));
break ;
}
// OSD_Printf("hitag: %d\n",g_sp->hitag);
2008-08-24 19:09:17 +00:00
g_sp - > z + = ( 24 < < 8 ) ;
case OCTABRAIN__STATIC :
case COMMANDER__STATIC :
case DRONE__STATIC :
break ;
2007-04-15 20:04:52 +00:00
}
2008-08-24 19:09:17 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2008-08-24 19:09:17 +00:00
g_sp - > zvel = 0 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_ENDA :
case CON_BREAK :
case CON_ENDS :
return 1 ;
case CON_RIGHTBRACE :
insptr + + ;
return 1 ;
case CON_ADDAMMO :
insptr + + ;
2008-11-20 14:06:36 +00:00
if ( ( * insptr < 0 | | * insptr > = MAX_WEAPONS ) & & g_scriptSanityChecks )
2008-08-23 15:37:30 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid weapon ID %d \n " , g_errorLineNum , keyw [ g_tw ] , * insptr ) ;
2008-08-23 15:37:30 +00:00
insptr + = 2 ; break ;
}
2007-08-27 23:11:49 +00:00
if ( g_player [ g_p ] . ps - > ammo_amount [ * insptr ] > = g_player [ g_p ] . ps - > max_ammo_amount [ * insptr ] )
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
g_killitFlag = 2 ;
2006-11-16 03:02:42 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
P_AddAmmo ( * insptr , g_player [ g_p ] . ps , * ( insptr + 1 ) ) ;
2008-08-24 19:09:17 +00:00
if ( g_player [ g_p ] . ps - > curr_weapon = = KNEE_WEAPON & & g_player [ g_p ] . ps - > gotweapon [ * insptr ] )
{
2008-11-20 14:06:36 +00:00
if ( ! ( g_player [ g_p ] . ps - > weaponswitch & 1 ) ) P_AddWeaponNoSwitch ( g_player [ g_p ] . ps , * insptr ) ;
else P_AddWeapon ( g_player [ g_p ] . ps , * insptr ) ;
2008-08-24 19:09:17 +00:00
}
2006-11-16 03:02:42 +00:00
insptr + = 2 ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_MONEY :
insptr + + ;
2008-11-20 14:06:36 +00:00
A_SpawnMultiple ( g_i , MONEY , * insptr + + ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_MAIL :
insptr + + ;
2008-11-20 14:06:36 +00:00
A_SpawnMultiple ( g_i , MAIL , * insptr + + ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_SLEEPTIME :
insptr + + ;
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . timetosleep = ( short ) * insptr + + ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_PAPER :
insptr + + ;
2008-11-20 14:06:36 +00:00
A_SpawnMultiple ( g_i , PAPER , * insptr + + ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_ADDKILLS :
insptr + + ;
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > actors_killed + = * insptr + + ;
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . actorstayput = - 1 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_LOTSOFGLASS :
insptr + + ;
2008-11-20 14:06:36 +00:00
A_SpawnGlass ( g_i , * insptr + + ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_KILLIT :
insptr + + ;
2008-11-20 14:06:36 +00:00
g_killitFlag = 1 ;
2006-11-16 03:02:42 +00:00
break ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
case CON_ADDWEAPON :
insptr + + ;
2008-11-20 14:06:36 +00:00
if ( ( * insptr < 0 | | * insptr > = MAX_WEAPONS ) & & g_scriptSanityChecks )
2008-08-23 15:37:30 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid weapon ID %d \n " , g_errorLineNum , keyw [ g_tw ] , * insptr ) ;
2008-08-23 15:37:30 +00:00
insptr + = 2 ; break ;
}
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > gotweapon [ * insptr ] = = 0 )
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
if ( ! ( g_player [ g_p ] . ps - > weaponswitch & 1 ) ) P_AddWeaponNoSwitch ( g_player [ g_p ] . ps , * insptr ) ;
else P_AddWeapon ( g_player [ g_p ] . ps , * insptr ) ;
2006-11-16 03:02:42 +00:00
}
2007-08-27 23:11:49 +00:00
else if ( g_player [ g_p ] . ps - > ammo_amount [ * insptr ] > = g_player [ g_p ] . ps - > max_ammo_amount [ * insptr ] )
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
g_killitFlag = 2 ;
2006-11-16 03:02:42 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
P_AddAmmo ( * insptr , g_player [ g_p ] . ps , * ( insptr + 1 ) ) ;
2008-08-24 19:09:17 +00:00
if ( g_player [ g_p ] . ps - > curr_weapon = = KNEE_WEAPON & & g_player [ g_p ] . ps - > gotweapon [ * insptr ] )
{
2008-11-20 14:06:36 +00:00
if ( ! ( g_player [ g_p ] . ps - > weaponswitch & 1 ) ) P_AddWeaponNoSwitch ( g_player [ g_p ] . ps , * insptr ) ;
else P_AddWeapon ( g_player [ g_p ] . ps , * insptr ) ;
2008-08-24 19:09:17 +00:00
}
2006-11-16 03:02:42 +00:00
insptr + = 2 ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_DEBUG :
insptr + + ;
2007-12-12 17:42:14 +00:00
initprintf ( " %d \n " , * insptr + + ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_ENDOFGAME :
insptr + + ;
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > timebeforeexit = * insptr + + ;
g_player [ g_p ] . ps - > customexitsound = - 1 ;
2006-11-16 03:02:42 +00:00
ud . eog = 1 ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_ADDPHEALTH :
insptr + + ;
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > newowner > = 0 )
2006-11-16 03:02:42 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > newowner = - 1 ;
g_player [ g_p ] . ps - > posx = g_player [ g_p ] . ps - > oposx ;
g_player [ g_p ] . ps - > posy = g_player [ g_p ] . ps - > oposy ;
g_player [ g_p ] . ps - > posz = g_player [ g_p ] . ps - > oposz ;
g_player [ g_p ] . ps - > ang = g_player [ g_p ] . ps - > oang ;
updatesector ( g_player [ g_p ] . ps - > posx , g_player [ g_p ] . ps - > posy , & g_player [ g_p ] . ps - > cursectnum ) ;
2008-11-20 14:06:36 +00:00
P_UpdateScreenPal ( g_player [ g_p ] . ps ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
j = headspritestat [ STAT_ACTOR ] ;
2006-11-16 03:02:42 +00:00
while ( j > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( sprite [ j ] . picnum = = CAMERA1 )
sprite [ j ] . yvel = 0 ;
j = nextspritestat [ j ] ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
j = sprite [ g_player [ g_p ] . ps - > i ] . extra ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( g_sp - > picnum ! = ATOMICHEALTH )
{
2007-08-27 23:11:49 +00:00
if ( j > g_player [ g_p ] . ps - > max_player_health & & * insptr > 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
insptr + + ;
break ;
2006-04-13 20:47:06 +00:00
}
else
{
2006-11-13 23:12:47 +00:00
if ( j > 0 )
2006-04-13 20:47:06 +00:00
j + = * insptr ;
2007-08-27 23:11:49 +00:00
if ( j > g_player [ g_p ] . ps - > max_player_health & & * insptr > 0 )
j = g_player [ g_p ] . ps - > max_player_health ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
else
{
if ( j > 0 )
j + = * insptr ;
2007-08-27 23:11:49 +00:00
if ( j > ( g_player [ g_p ] . ps - > max_player_health < < 1 ) )
j = ( g_player [ g_p ] . ps - > max_player_health < < 1 ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j < 0 ) j = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( ud . god = = 0 )
{
if ( * insptr > 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 23:11:49 +00:00
if ( ( j - * insptr ) < ( g_player [ g_p ] . ps - > max_player_health > > 2 ) & &
j > = ( g_player [ g_p ] . ps - > max_player_health > > 2 ) )
2008-11-20 14:06:36 +00:00
A_PlaySound ( DUKE_GOTHEALTHATLOW , g_player [ g_p ] . ps - > i ) ;
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > last_extra = j ;
2006-11-15 01:16:55 +00:00
}
2006-04-18 03:11:38 +00:00
2007-08-27 06:46:31 +00:00
sprite [ g_player [ g_p ] . ps - > i ] . extra = j ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
insptr + + ;
break ;
case CON_STATE :
{
2008-02-17 05:08:18 +00:00
intptr_t * tempscrptr = insptr + 2 ;
2006-04-18 03:11:38 +00:00
2008-02-17 05:08:18 +00:00
insptr = ( intptr_t * ) * ( insptr + 1 ) ;
2008-12-01 10:44:18 +00:00
while ( ! X_DoExecute ( ) ) ;
2006-11-16 03:02:42 +00:00
insptr = tempscrptr ;
}
break ;
case CON_LEFTBRACE :
insptr + + ;
2008-12-01 10:44:18 +00:00
while ( ! X_DoExecute ( ) ) ;
2006-04-13 20:47:06 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_MOVE :
insptr + + ;
g_t [ 0 ] = 0 ;
g_t [ 1 ] = * insptr + + ;
g_sp - > hitag = * insptr + + ;
2008-12-01 10:44:18 +00:00
if ( A_CheckEnemySprite ( g_sp ) & & g_sp - > extra < = 0 ) // hack
break ;
2006-11-16 03:02:42 +00:00
if ( g_sp - > hitag & random_angle )
2008-11-20 14:06:36 +00:00
g_sp - > ang = krand ( ) & 2047 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_ADDWEAPONVAR :
insptr + + ;
2008-11-20 14:06:36 +00:00
if ( g_player [ g_p ] . ps - > gotweapon [ Gv_GetVar ( * ( insptr ) , g_i , g_p ) ] = = 0 )
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
if ( ! ( g_player [ g_p ] . ps - > weaponswitch & 1 ) ) P_AddWeaponNoSwitch ( g_player [ g_p ] . ps , Gv_GetVar ( * ( insptr ) , g_i , g_p ) ) ;
else P_AddWeapon ( g_player [ g_p ] . ps , Gv_GetVar ( * ( insptr ) , g_i , g_p ) ) ;
2006-11-16 03:02:42 +00:00
}
2008-11-20 14:06:36 +00:00
else if ( g_player [ g_p ] . ps - > ammo_amount [ Gv_GetVar ( * ( insptr ) , g_i , g_p ) ] > = g_player [ g_p ] . ps - > max_ammo_amount [ Gv_GetVar ( * ( insptr ) , g_i , g_p ) ] )
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
g_killitFlag = 2 ;
2006-04-13 20:47:06 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2008-11-20 14:06:36 +00:00
P_AddAmmo ( Gv_GetVar ( * ( insptr ) , g_i , g_p ) , g_player [ g_p ] . ps , Gv_GetVar ( * ( insptr + 1 ) , g_i , g_p ) ) ;
if ( g_player [ g_p ] . ps - > curr_weapon = = KNEE_WEAPON & & g_player [ g_p ] . ps - > gotweapon [ Gv_GetVar ( * ( insptr ) , g_i , g_p ) ] )
2008-08-24 19:09:17 +00:00
{
2008-11-20 14:06:36 +00:00
if ( ! ( g_player [ g_p ] . ps - > weaponswitch & 1 ) ) P_AddWeaponNoSwitch ( g_player [ g_p ] . ps , Gv_GetVar ( * ( insptr ) , g_i , g_p ) ) ;
else P_AddWeapon ( g_player [ g_p ] . ps , Gv_GetVar ( * ( insptr ) , g_i , g_p ) ) ;
2008-08-24 19:09:17 +00:00
}
2006-11-16 03:02:42 +00:00
insptr + = 2 ;
break ;
case CON_ACTIVATEBYSECTOR :
case CON_OPERATESECTORS :
case CON_OPERATEACTIVATORS :
case CON_SETASPECT :
case CON_SSP :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
int var1 = Gv_GetVar ( * insptr + + , g_i , g_p ) , var2 ;
2007-02-08 04:19:39 +00:00
if ( tw = = CON_OPERATEACTIVATORS & & * insptr = = g_iThisActorID )
{
var2 = g_p ;
insptr + + ;
}
2008-11-20 14:06:36 +00:00
else var2 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
2007-02-08 04:19:39 +00:00
switch ( tw )
{
case CON_ACTIVATEBYSECTOR :
2008-11-20 14:06:36 +00:00
if ( ( var1 < 0 | | var1 > = numsectors ) & & g_scriptSanityChecks ) { OSD_Printf ( CON_ERROR " Invalid sector %d \n " , g_errorLineNum , keyw [ g_tw ] , var1 ) ; break ; }
2007-02-08 04:19:39 +00:00
activatebysector ( var1 , var2 ) ;
break ;
case CON_OPERATESECTORS :
2008-11-20 14:06:36 +00:00
if ( ( var1 < 0 | | var1 > = numsectors ) & & g_scriptSanityChecks ) { OSD_Printf ( CON_ERROR " Invalid sector %d \n " , g_errorLineNum , keyw [ g_tw ] , var1 ) ; break ; }
G_OperateSectors ( var1 , var2 ) ;
2007-02-08 04:19:39 +00:00
break ;
case CON_OPERATEACTIVATORS :
2008-11-20 14:06:36 +00:00
if ( ( var2 < 0 | | var2 > = ud . multimode ) & & g_scriptSanityChecks ) { OSD_Printf ( CON_ERROR " Invalid player %d \n " , g_errorLineNum , keyw [ g_tw ] , var2 ) ; break ; }
G_OperateActivators ( var1 , var2 ) ;
2007-02-08 04:19:39 +00:00
break ;
case CON_SETASPECT :
setaspect ( var1 , var2 ) ;
break ;
case CON_SSP :
2008-11-20 14:06:36 +00:00
if ( ( var1 < 0 | | var1 > = MAXSPRITES ) & & g_scriptSanityChecks ) { OSD_Printf ( CON_ERROR " Invalid sprite %d \n " , g_errorLineNum , keyw [ g_tw ] , var1 ) ; break ; }
A_SetSprite ( var1 , var2 ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-11-15 01:16:55 +00:00
break ;
}
2006-04-24 05:42:29 +00:00
2006-11-16 03:02:42 +00:00
case CON_CANSEESPR :
2007-02-08 04:19:39 +00:00
insptr + + ;
{
2008-11-20 14:06:36 +00:00
int lVar1 = Gv_GetVar ( * insptr + + , g_i , g_p ) , lVar2 = Gv_GetVar ( * insptr + + , g_i , g_p ) , res ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( ( lVar1 < 0 | | lVar1 > = MAXSPRITES | | lVar2 < 0 | | lVar2 > = MAXSPRITES ) & & g_scriptSanityChecks )
2008-08-11 10:17:18 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sprite %d \n " , g_errorLineNum , keyw [ g_tw ] , lVar1 < 0 | | lVar1 > = MAXSPRITES ? lVar1 : lVar2 ) ;
2008-08-11 10:17:18 +00:00
res = 0 ;
}
2008-07-25 01:09:39 +00:00
else res = cansee ( sprite [ lVar1 ] . x , sprite [ lVar1 ] . y , sprite [ lVar1 ] . z , sprite [ lVar1 ] . sectnum ,
sprite [ lVar2 ] . x , sprite [ lVar2 ] . y , sprite [ lVar2 ] . z , sprite [ lVar2 ] . sectnum ) ;
2008-07-23 20:09:22 +00:00
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr + + , res , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
case CON_OPERATERESPAWNS :
case CON_OPERATEMASTERSWITCHES :
case CON_CHECKACTIVATORMOTION :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
int var1 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
switch ( tw )
{
case CON_OPERATERESPAWNS :
2008-11-20 14:06:36 +00:00
G_OperateRespawns ( var1 ) ;
2007-02-08 04:19:39 +00:00
break ;
case CON_OPERATEMASTERSWITCHES :
2008-11-20 14:06:36 +00:00
G_OperateMasterSwitches ( var1 ) ;
2007-02-08 04:19:39 +00:00
break ;
case CON_CHECKACTIVATORMOTION :
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , check_activator_motion ( var1 ) , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-11-15 01:16:55 +00:00
break ;
}
2006-09-30 06:51:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_INSERTSPRITEQ :
insptr + + ;
2008-11-20 14:06:36 +00:00
A_AddToDeleteQueue ( g_i ) ;
2006-11-16 03:02:42 +00:00
break ;
case CON_QSTRLEN :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-12-18 21:29:55 +00:00
{
2007-02-08 04:19:39 +00:00
int i = * insptr + + ;
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
if ( ( ScriptQuotes [ j ] = = NULL ) & & g_scriptSanityChecks )
2007-02-08 04:19:39 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " null quote %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ;
Gv_SetVar ( i , - 1 , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( i , Bstrlen ( ScriptQuotes [ j ] ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
2007-08-19 00:15:30 +00:00
case CON_HEADSPRITESTAT :
case CON_PREVSPRITESTAT :
case CON_NEXTSPRITESTAT :
case CON_HEADSPRITESECT :
case CON_PREVSPRITESECT :
case CON_NEXTSPRITESECT :
insptr + + ;
{
int i = * insptr + + ;
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2007-08-19 00:15:30 +00:00
switch ( tw )
{
2007-08-25 01:05:00 +00:00
case CON_HEADSPRITESTAT :
2008-11-20 14:06:36 +00:00
if ( ( j < 0 | | j > MAXSTATUS ) & & g_scriptSanityChecks )
2008-08-11 10:38:46 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid status list %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ;
2008-08-11 10:38:46 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( i , headspritestat [ j ] , g_i , g_p ) ;
2007-08-25 01:05:00 +00:00
break ;
case CON_PREVSPRITESTAT :
2008-11-20 14:06:36 +00:00
if ( ( j < 0 | | j > = MAXSPRITES ) & & g_scriptSanityChecks )
2008-08-11 10:38:46 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid sprite ID %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ;
2008-08-11 10:38:46 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( i , prevspritestat [ j ] , g_i , g_p ) ;
2007-08-25 01:05:00 +00:00
break ;
case CON_NEXTSPRITESTAT :
2008-11-20 14:06:36 +00:00
if ( ( j < 0 | | j > = MAXSPRITES ) & & g_scriptSanityChecks )
2008-08-11 10:38:46 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid sprite ID %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ;
2008-08-11 10:38:46 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( i , nextspritestat [ j ] , g_i , g_p ) ;
2007-08-25 01:05:00 +00:00
break ;
case CON_HEADSPRITESECT :
2008-11-20 14:06:36 +00:00
if ( ( j < 0 | | j > numsectors ) & & g_scriptSanityChecks )
2008-08-11 10:38:46 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid sector %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ;
2008-08-11 10:38:46 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( i , headspritesect [ j ] , g_i , g_p ) ;
2007-08-25 01:05:00 +00:00
break ;
case CON_PREVSPRITESECT :
2008-11-20 14:06:36 +00:00
if ( ( j < 0 | | j > = MAXSPRITES ) & & g_scriptSanityChecks )
2008-08-11 10:38:46 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid sprite ID %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ;
2008-08-11 10:38:46 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( i , prevspritesect [ j ] , g_i , g_p ) ;
2007-08-25 01:05:00 +00:00
break ;
case CON_NEXTSPRITESECT :
2008-11-20 14:06:36 +00:00
if ( ( j < 0 | | j > = MAXSPRITES ) & & g_scriptSanityChecks )
2008-08-11 10:38:46 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid sprite ID %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ;
2008-08-11 10:38:46 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( i , nextspritesect [ j ] , g_i , g_p ) ;
2007-08-25 01:05:00 +00:00
break ;
2007-08-19 00:15:30 +00:00
}
break ;
}
2007-12-20 19:14:38 +00:00
case CON_GETKEYNAME :
insptr + + ;
{
2008-11-20 14:06:36 +00:00
int i = Gv_GetVar ( * insptr + + , g_i , g_p ) ,
f = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
j = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
if ( ( i < 0 | | i > = MAXQUOTES ) & & g_scriptSanityChecks )
OSD_Printf ( CON_ERROR " invalid quote ID %d \n " , g_errorLineNum , keyw [ g_tw ] , i ) ;
else if ( ( ScriptQuotes [ i ] = = NULL ) & & g_scriptSanityChecks )
OSD_Printf ( CON_ERROR " null quote %d \n " , g_errorLineNum , keyw [ g_tw ] , i ) ;
else if ( ( f < 0 | | f > = NUMGAMEFUNCTIONS ) & & g_scriptSanityChecks )
OSD_Printf ( CON_ERROR " invalid function %d \n " , g_errorLineNum , keyw [ g_tw ] , f ) ;
2008-08-11 10:17:18 +00:00
else
2007-12-20 19:14:38 +00:00
{
2008-02-18 08:10:54 +00:00
if ( j < 2 )
2008-08-11 10:17:18 +00:00
Bstrcpy ( tempbuf , KB_ScanCodeToString ( ud . config . KeyboardKeys [ f ] [ j ] ) ) ;
2008-02-18 08:10:54 +00:00
else
2008-08-11 10:17:18 +00:00
{
Bstrcpy ( tempbuf , KB_ScanCodeToString ( ud . config . KeyboardKeys [ f ] [ 0 ] ) ) ;
2007-12-20 19:14:38 +00:00
if ( ! * tempbuf )
2008-02-18 08:10:54 +00:00
Bstrcpy ( tempbuf , KB_ScanCodeToString ( ud . config . KeyboardKeys [ f ] [ 1 ] ) ) ;
2007-12-20 19:14:38 +00:00
}
}
2008-02-18 08:10:54 +00:00
if ( * tempbuf )
2008-11-20 14:06:36 +00:00
Bstrcpy ( ScriptQuotes [ i ] , tempbuf ) ;
2007-12-20 19:14:38 +00:00
break ;
}
case CON_QSUBSTR :
insptr + + ;
{
2008-02-18 08:10:54 +00:00
char * s1 , * s2 ;
int q1 , q2 , st , ln ;
2008-11-20 14:06:36 +00:00
q1 = Gv_GetVar ( * insptr + + , g_i , g_p ) ,
q2 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
st = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
ln = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2008-02-18 08:10:54 +00:00
2008-11-20 14:06:36 +00:00
if ( ( q1 < 0 | | q1 > = MAXQUOTES ) & & g_scriptSanityChecks ) OSD_Printf ( CON_ERROR " invalid quote ID %d \n " , g_errorLineNum , keyw [ g_tw ] , q1 ) ;
else if ( ( ScriptQuotes [ q1 ] = = NULL ) & & g_scriptSanityChecks ) OSD_Printf ( CON_ERROR " null quote %d \n " , g_errorLineNum , keyw [ g_tw ] , q1 ) ;
else if ( ( q2 < 0 | | q2 > = MAXQUOTES ) & & g_scriptSanityChecks ) OSD_Printf ( CON_ERROR " invalid quote ID %d \n " , g_errorLineNum , keyw [ g_tw ] , q2 ) ;
else if ( ( ScriptQuotes [ q2 ] = = NULL ) & & g_scriptSanityChecks ) OSD_Printf ( CON_ERROR " null quote %d \n " , g_errorLineNum , keyw [ g_tw ] , q2 ) ;
2008-08-10 10:53:55 +00:00
else
2007-12-20 19:14:38 +00:00
{
2008-11-20 14:06:36 +00:00
s1 = ScriptQuotes [ q1 ] ;
s2 = ScriptQuotes [ q2 ] ;
2007-12-20 19:14:38 +00:00
while ( * s2 & & st - - ) s2 + + ;
2008-08-10 13:13:24 +00:00
while ( ( * s1 = * s2 ) & & ln - - ) { s1 + + ; s2 + + ; }
* s1 = 0 ;
}
break ;
2007-12-20 19:14:38 +00:00
}
2008-08-09 10:43:27 +00:00
case CON_GETPNAME :
case CON_QSTRCAT :
case CON_QSTRCPY :
case CON_QGETSYSSTR :
case CON_CHANGESPRITESTAT :
case CON_CHANGESPRITESECT :
insptr + + ;
{
2008-11-20 14:06:36 +00:00
int i = Gv_GetVar ( * insptr + + , g_i , g_p ) , j ;
2007-02-08 04:19:39 +00:00
if ( tw = = CON_GETPNAME & & * insptr = = g_iThisActorID )
{
j = g_p ;
insptr + + ;
}
2008-11-20 14:06:36 +00:00
else j = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-05-13 01:07:06 +00:00
2007-02-08 04:19:39 +00:00
switch ( tw )
2006-11-16 03:02:42 +00:00
{
2007-02-08 04:19:39 +00:00
case CON_GETPNAME :
2008-11-20 14:06:36 +00:00
if ( ( ScriptQuotes [ i ] = = NULL ) & & g_scriptSanityChecks )
2007-02-08 04:19:39 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " null quote %d \n " , g_errorLineNum , keyw [ g_tw ] , i ) ;
2008-08-10 10:53:55 +00:00
break ;
2007-02-08 04:19:39 +00:00
}
2008-08-10 10:53:55 +00:00
if ( g_player [ j ] . user_name [ 0 ] )
2008-11-20 14:06:36 +00:00
Bstrcpy ( ScriptQuotes [ i ] , g_player [ j ] . user_name ) ;
else Bsprintf ( ScriptQuotes [ i ] , " %d " , j ) ;
2007-02-08 04:19:39 +00:00
break ;
2008-06-09 23:41:54 +00:00
case CON_QGETSYSSTR :
2008-11-20 14:06:36 +00:00
if ( ( ScriptQuotes [ i ] = = NULL ) & & g_scriptSanityChecks )
2008-08-10 10:53:55 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " null quote %d %d \n " , g_errorLineNum , keyw [ g_tw ] , i , j ) ;
2008-08-10 10:53:55 +00:00
break ;
}
switch ( j )
{
case STR_MAPNAME :
2008-11-20 14:06:36 +00:00
Bstrcpy ( ScriptQuotes [ i ] , MapInfo [ ud . volume_number * MAXLEVELS + ud . level_number ] . name ) ;
2008-08-10 10:53:55 +00:00
break ;
case STR_MAPFILENAME :
2008-11-20 14:06:36 +00:00
Bstrcpy ( ScriptQuotes [ i ] , MapInfo [ ud . volume_number * MAXLEVELS + ud . level_number ] . filename ) ;
2008-08-10 10:53:55 +00:00
break ;
case STR_PLAYERNAME :
2008-11-20 14:06:36 +00:00
Bstrcpy ( ScriptQuotes [ i ] , g_player [ g_p ] . user_name ) ;
2008-08-10 10:53:55 +00:00
break ;
case STR_VERSION :
2008-11-24 09:22:07 +00:00
Bsprintf ( tempbuf , HEAD2 " %s " , s_buildDate ) ;
2008-11-20 14:06:36 +00:00
Bstrcpy ( ScriptQuotes [ i ] , tempbuf ) ;
2008-08-10 10:53:55 +00:00
break ;
case STR_GAMETYPE :
2008-11-20 14:06:36 +00:00
Bstrcpy ( ScriptQuotes [ i ] , GametypeNames [ ud . coop ] ) ;
2008-08-10 10:53:55 +00:00
break ;
default :
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " unknown str ID %d %d \n " , g_errorLineNum , keyw [ g_tw ] , i , j ) ;
2008-08-10 10:53:55 +00:00
}
2008-06-09 23:41:54 +00:00
break ;
2007-02-08 04:19:39 +00:00
case CON_QSTRCAT :
2008-11-20 14:06:36 +00:00
if ( ( ScriptQuotes [ i ] = = NULL | | ScriptQuotes [ j ] = = NULL ) & & g_scriptSanityChecks )
2008-08-10 10:53:55 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " null quote %d \n " , g_errorLineNum , keyw [ g_tw ] , ScriptQuotes [ i ] ? j : i ) ;
2008-08-10 10:53:55 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Bstrncat ( ScriptQuotes [ i ] , ScriptQuotes [ j ] , ( MAXQUOTELEN - 1 ) - Bstrlen ( ScriptQuotes [ i ] ) ) ;
2007-02-08 04:19:39 +00:00
break ;
case CON_QSTRCPY :
2008-11-20 14:06:36 +00:00
if ( ( ScriptQuotes [ i ] = = NULL | | ScriptQuotes [ j ] = = NULL ) & & g_scriptSanityChecks )
2008-08-10 10:53:55 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " null quote %d \n " , g_errorLineNum , keyw [ g_tw ] , ScriptQuotes [ i ] ? j : i ) ;
2008-08-10 10:53:55 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Bstrcpy ( ScriptQuotes [ i ] , ScriptQuotes [ j ] ) ;
2007-02-08 04:19:39 +00:00
break ;
case CON_CHANGESPRITESTAT :
2008-11-20 14:06:36 +00:00
if ( ( i < 0 | | i > = MAXSPRITES ) & & g_scriptSanityChecks )
2008-09-01 08:31:48 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sprite: %d \n " , g_errorLineNum , keyw [ g_tw ] , i ) ;
2008-09-01 08:31:48 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
if ( ( j < 0 | | j > = MAXSTATUS ) & & g_scriptSanityChecks )
2008-09-01 08:31:48 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid statnum: %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ;
2008-09-01 08:31:48 +00:00
break ;
}
if ( sprite [ i ] . statnum = = j ) break ;
2008-09-01 21:59:53 +00:00
2008-09-30 17:27:23 +00:00
/* initialize actor data when changing to an actor statnum because there's usually
garbage left over from being handled as a hard coded object */
if ( j = = 1 | | j = = 2 )
2008-09-01 07:15:16 +00:00
{
2008-11-20 14:06:36 +00:00
ActorExtra [ i ] . lastvx = 0 ;
ActorExtra [ i ] . lastvy = 0 ;
ActorExtra [ i ] . timetosleep = 0 ;
ActorExtra [ i ] . cgg = 0 ;
ActorExtra [ i ] . movflag = 0 ;
ActorExtra [ i ] . tempang = 0 ;
ActorExtra [ i ] . dispicnum = 0 ;
2008-09-30 17:27:23 +00:00
T1 = T2 = T3 = T4 = T5 = T6 = T7 = T8 = T9 = 0 ;
2008-11-20 14:06:36 +00:00
ActorExtra [ i ] . flags = 0 ;
2008-09-30 17:27:23 +00:00
sprite [ i ] . hitag = 0 ;
// pointers
if ( actorscrptr [ sprite [ i ] . picnum ] )
{
T5 = * ( actorscrptr [ sprite [ i ] . picnum ] + 1 ) ;
T2 = * ( actorscrptr [ sprite [ i ] . picnum ] + 2 ) ;
sprite [ i ] . hitag = * ( actorscrptr [ sprite [ i ] . picnum ] + 3 ) ;
}
2008-09-01 07:15:16 +00:00
}
2007-02-08 04:19:39 +00:00
changespritestat ( i , j ) ;
break ;
case CON_CHANGESPRITESECT :
2008-11-20 14:06:36 +00:00
if ( ( i < 0 | | i > = MAXSPRITES ) & & g_scriptSanityChecks ) { OSD_Printf ( CON_ERROR " Invalid sprite %d \n " , g_errorLineNum , keyw [ g_tw ] , i ) ; break ; }
if ( ( j < 0 | | j > = numsectors ) & & g_scriptSanityChecks ) { OSD_Printf ( CON_ERROR " Invalid sector %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ; break ; }
2007-02-08 04:19:39 +00:00
changespritesect ( i , j ) ;
break ;
2006-11-16 03:02:42 +00:00
}
break ;
}
case CON_STARTLEVEL :
2007-02-08 04:19:39 +00:00
insptr + + ; // skip command
2006-12-21 09:33:26 +00:00
{
2007-02-08 04:19:39 +00:00
// from 'level' cheat in game.c (about line 6250)
2008-11-20 14:06:36 +00:00
int volnume = Gv_GetVar ( * insptr + + , g_i , g_p ) , levnume = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( ( volnume > MAXVOLUMES - 1 | | volnume < 0 ) & & g_scriptSanityChecks )
2007-02-08 04:19:39 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid volume (%d) \n " , g_errorLineNum , keyw [ g_tw ] , volnume ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( ( levnume > MAXLEVELS - 1 | | levnume < 0 ) & & g_scriptSanityChecks )
2007-02-08 04:19:39 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid level (%d) \n " , g_errorLineNum , keyw [ g_tw ] , levnume ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2007-02-08 04:19:39 +00:00
ud . m_volume_number = ud . volume_number = volnume ;
ud . m_level_number = ud . level_number = levnume ;
if ( numplayers > 1 & & myconnectindex = = connecthead )
2008-11-20 14:06:36 +00:00
Net_NewGame ( volnume , levnume ) ;
2007-02-08 04:19:39 +00:00
else
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm | = MODE_EOL ;
2008-08-19 11:05:21 +00:00
ud . display_bonus_screen = 0 ;
2007-02-08 04:19:39 +00:00
} // MODE_RESTART;
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_MYOSX :
case CON_MYOSPALX :
case CON_MYOS :
case CON_MYOSPAL :
insptr + + ;
{
2008-11-20 14:06:36 +00:00
int x = Gv_GetVar ( * insptr + + , g_i , g_p ) , y = Gv_GetVar ( * insptr + + , g_i , g_p ) , tilenum = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int shade = Gv_GetVar ( * insptr + + , g_i , g_p ) , orientation = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
switch ( tw )
{
case CON_MYOS :
2008-11-20 14:06:36 +00:00
G_DrawTile ( x , y , tilenum , shade , orientation ) ;
2006-12-18 08:37:12 +00:00
break ;
case CON_MYOSPAL :
{
2008-11-20 14:06:36 +00:00
int pal = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
G_DrawTilePal ( x , y , tilenum , shade , orientation , pal ) ;
2006-12-18 08:37:12 +00:00
break ;
}
case CON_MYOSX :
2008-11-20 14:06:36 +00:00
G_DrawTileSmall ( x , y , tilenum , shade , orientation ) ;
2006-12-18 08:37:12 +00:00
break ;
case CON_MYOSPALX :
{
2008-11-20 14:06:36 +00:00
int pal = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
G_DrawTilePalSmall ( x , y , tilenum , shade , orientation , pal ) ;
2006-12-18 08:37:12 +00:00
break ;
}
}
2006-04-13 20:47:06 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
case CON_SWITCH :
insptr + + ; // p-code
2006-04-13 20:47:06 +00:00
{
2006-12-18 08:37:12 +00:00
// 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
//AddLog("Processing Switch...");
2008-11-20 14:06:36 +00:00
int lValue = Gv_GetVar ( * insptr + + , g_i , g_p ) , lEnd = * insptr + + , lCases = * insptr + + ;
2008-02-17 05:08:18 +00:00
intptr_t * lpDefault = insptr + + , * lpCases = insptr , * lTempInsPtr ;
int bMatched = 0 , lCheckCase ;
2008-01-26 03:59:34 +00:00
int left , right ;
2006-12-18 08:37:12 +00:00
insptr + = lCases * 2 ;
lTempInsPtr = insptr ;
2007-12-12 17:42:14 +00:00
//Bsprintf(g_szBuf,"lEnd= %d *lpDefault=%d",lEnd,*lpDefault);
2006-04-13 20:47:06 +00:00
//AddLog(g_szBuf);
2007-12-12 17:42:14 +00:00
//Bsprintf(g_szBuf,"Checking %d cases for %d",lCases, lValue);
2006-12-18 08:37:12 +00:00
//AddLog(g_szBuf);
2008-01-26 03:59:34 +00:00
left = 0 ; right = lCases - 1 ;
while ( ! bMatched )
2006-04-13 20:47:06 +00:00
{
2007-12-12 17:42:14 +00:00
//Bsprintf(g_szBuf,"Checking #%d Value= %d",lCheckCase, lpCases[lCheckCase*2]);
2006-04-13 20:47:06 +00:00
//AddLog(g_szBuf);
2008-01-26 03:59:34 +00:00
lCheckCase = ( left + right ) / 2 ;
// initprintf("(%2d..%2d..%2d) [%2d..%2d..%2d]==%2d\n",left,lCheckCase,right,lpCases[left*2],lpCases[lCheckCase*2],lpCases[right*2],lValue);
2008-08-24 19:09:17 +00:00
if ( lpCases [ lCheckCase * 2 ] > lValue )
right = lCheckCase - 1 ;
else if ( lpCases [ lCheckCase * 2 ] < lValue )
left = lCheckCase + 1 ;
else if ( lpCases [ lCheckCase * 2 ] = = lValue )
{
//AddLog("Found Case Match");
//Bsprintf(g_szBuf,"insptr=%d. lCheckCase=%d, offset=%d, &script[0]=%d",
// (int)insptr,(int)lCheckCase,lpCases[lCheckCase*2+1],(int)&script[0]);
//AddLog(g_szBuf);
// fake a 2-d Array
insptr = ( intptr_t * ) ( lpCases [ lCheckCase * 2 + 1 ] + & script [ 0 ] ) ;
//Bsprintf(g_szBuf,"insptr=%d. ", (int)insptr);
//AddLog(g_szBuf);
2008-12-01 10:44:18 +00:00
while ( ! X_DoExecute ( ) ) ;
2008-08-24 19:09:17 +00:00
//AddLog("Done Executing Case");
bMatched = 1 ;
}
if ( right - left < 0 )
break ;
2006-11-16 03:02:42 +00:00
}
2006-12-18 08:37:12 +00:00
if ( ! bMatched )
2006-11-16 03:02:42 +00:00
{
2006-12-18 08:37:12 +00:00
if ( * lpDefault )
{
//AddLog("No Matching Case: Using Default");
2008-06-10 19:27:39 +00:00
insptr = ( intptr_t * ) ( * lpDefault + & script [ 0 ] ) ;
2008-12-01 10:44:18 +00:00
while ( ! X_DoExecute ( ) ) ;
2006-12-18 08:37:12 +00:00
}
else
{
//AddLog("No Matching Case: No Default to use");
}
2006-04-13 20:47:06 +00:00
}
2008-02-17 05:08:18 +00:00
insptr = ( intptr_t * ) ( lEnd + ( intptr_t ) & script [ 0 ] ) ;
2007-12-12 17:42:14 +00:00
//Bsprintf(g_szBuf,"insptr=%d. ", (int)insptr);
2006-12-18 08:37:12 +00:00
//AddLog(g_szBuf);
//AddLog("Done Processing Switch");
2006-11-13 23:12:47 +00:00
2006-12-18 08:37:12 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_ENDSWITCH :
case CON_ENDEVENT :
insptr + + ;
return 1 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_DISPLAYRAND :
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr + + , rand ( ) , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_DRAGPOINT :
insptr + + ;
2006-12-18 08:37:12 +00:00
{
2008-11-20 14:06:36 +00:00
int wallnum = Gv_GetVar ( * insptr + + , g_i , g_p ) , newx = Gv_GetVar ( * insptr + + , g_i , g_p ) , newy = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( ( wallnum < 0 | | wallnum > = numwalls ) & & g_scriptSanityChecks )
2008-08-24 19:09:17 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid wall %d \n " , g_errorLineNum , keyw [ g_tw ] , wallnum ) ;
2008-08-24 19:09:17 +00:00
break ;
}
2006-12-18 08:37:12 +00:00
dragpoint ( wallnum , newx , newy ) ;
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_DIST :
case CON_LDIST :
insptr + + ;
{
2008-11-20 14:06:36 +00:00
int distvar = * insptr + + , xvar = Gv_GetVar ( * insptr + + , g_i , g_p ) , yvar = Gv_GetVar ( * insptr + + , g_i , g_p ) , distx = 0 ;
2006-12-18 08:37:12 +00:00
2008-11-20 14:06:36 +00:00
if ( ( xvar < 0 | | yvar < 0 | | xvar > = MAXSPRITES | | yvar > = MAXSPRITES ) & & g_scriptSanityChecks )
2006-12-18 08:37:12 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid sprite \n " , g_errorLineNum , keyw [ g_tw ] ) ;
2008-08-10 13:07:07 +00:00
break ;
2007-12-12 17:42:14 +00:00
}
2008-08-10 13:07:07 +00:00
if ( tw = = CON_DIST ) distx = dist ( & sprite [ xvar ] , & sprite [ yvar ] ) ;
else distx = ldist ( & sprite [ xvar ] , & sprite [ yvar ] ) ;
2006-12-18 08:37:12 +00:00
2008-11-20 14:06:36 +00:00
Gv_SetVar ( distvar , distx , g_i , g_p ) ;
2006-04-13 20:47:06 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
case CON_GETINCANGLE :
case CON_GETANGLE :
insptr + + ;
2006-12-18 08:37:12 +00:00
{
2007-08-29 04:01:21 +00:00
int angvar = * insptr + + ;
2008-11-20 14:06:36 +00:00
int xvar = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int yvar = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
2006-12-18 08:37:12 +00:00
if ( tw = = CON_GETANGLE )
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( angvar , getangle ( xvar , yvar ) , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( angvar , G_GetAngleDelta ( xvar , yvar ) , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_MULSCALE :
insptr + + ;
2006-12-18 08:37:12 +00:00
{
2008-11-20 14:06:36 +00:00
int var1 = * insptr + + , var2 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int var3 = Gv_GetVar ( * insptr + + , g_i , g_p ) , var4 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
Gv_SetVar ( var1 , mulscale ( var2 , var3 , var4 ) , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_INITTIMER :
2007-02-08 04:19:39 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
if ( g_timerTicsPerSecond = = j )
2008-08-10 13:07:07 +00:00
break ;
uninittimer ( ) ;
inittimer ( j ) ;
2008-11-20 14:06:36 +00:00
g_timerTicsPerSecond = j ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_TIME :
insptr + = 2 ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_ESPAWNVAR :
case CON_EQSPAWNVAR :
case CON_QSPAWNVAR :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
int lIn = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
if ( ( g_sp - > sectnum < 0 | | g_sp - > sectnum > = numsectors ) & & g_scriptSanityChecks )
2008-08-10 13:07:07 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sector %d \n " , g_errorLineNum , keyw [ g_tw ] , g_sp - > sectnum ) ;
2008-08-10 13:07:07 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
j = A_Spawn ( g_i , lIn ) ;
2007-02-08 04:19:39 +00:00
switch ( tw )
{
case CON_EQSPAWNVAR :
if ( j ! = - 1 )
2008-11-20 14:06:36 +00:00
A_AddToDeleteQueue ( j ) ;
2007-02-08 04:19:39 +00:00
case CON_ESPAWNVAR :
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , j , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
break ;
case CON_QSPAWNVAR :
if ( j ! = - 1 )
2008-11-20 14:06:36 +00:00
A_AddToDeleteQueue ( j ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
case CON_ESPAWN :
case CON_EQSPAWN :
case CON_QSPAWN :
insptr + + ;
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
if ( ( g_sp - > sectnum < 0 | | g_sp - > sectnum > = numsectors ) & & g_scriptSanityChecks )
2008-08-10 13:07:07 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sector %d \n " , g_errorLineNum , keyw [ g_tw ] , g_sp - > sectnum ) ;
2008-08-10 13:07:07 +00:00
insptr + + ;
break ;
}
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
j = A_Spawn ( g_i , * insptr + + ) ;
2006-11-22 01:25:35 +00:00
2006-11-16 03:02:42 +00:00
switch ( tw )
{
2006-11-15 01:16:55 +00:00
case CON_EQSPAWN :
2006-12-19 20:31:40 +00:00
if ( j ! = - 1 )
2008-11-20 14:06:36 +00:00
A_AddToDeleteQueue ( j ) ;
2006-11-16 03:02:42 +00:00
case CON_ESPAWN :
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , j , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-11-13 23:12:47 +00:00
case CON_QSPAWN :
2006-12-19 20:31:40 +00:00
if ( j ! = - 1 )
2008-11-20 14:06:36 +00:00
A_AddToDeleteQueue ( j ) ;
2006-04-13 20:47:06 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_ESHOOT :
case CON_EZSHOOT :
case CON_ZSHOOT :
insptr + + ;
2007-02-08 04:19:39 +00:00
2006-11-16 03:02:42 +00:00
if ( tw = = CON_ZSHOOT | | tw = = CON_EZSHOOT )
2006-11-13 23:12:47 +00:00
{
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . temp_data [ 9 ] = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
if ( ActorExtra [ g_i ] . temp_data [ 9 ] = = 0 )
ActorExtra [ g_i ] . temp_data [ 9 ] = 1 ;
2006-04-13 20:47:06 +00:00
}
2008-08-10 13:07:07 +00:00
2008-11-20 14:06:36 +00:00
if ( ( g_sp - > sectnum < 0 | | g_sp - > sectnum > = numsectors ) & & g_scriptSanityChecks )
2006-11-15 01:16:55 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sector %d \n " , g_errorLineNum , keyw [ g_tw ] , g_sp - > sectnum ) ;
2008-08-10 13:07:07 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . temp_data [ 9 ] = 0 ;
2008-08-10 13:07:07 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2008-08-10 13:07:07 +00:00
2008-11-20 14:06:36 +00:00
j = A_Shoot ( g_i , * insptr + + ) ;
2008-08-10 13:07:07 +00:00
if ( tw = = CON_EZSHOOT | | tw = = CON_ESHOOT )
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , j , g_i , g_p ) ;
2006-11-22 01:25:35 +00:00
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . temp_data [ 9 ] = 0 ;
2006-11-16 03:02:42 +00:00
break ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
case CON_SHOOTVAR :
case CON_ESHOOTVAR :
case CON_EZSHOOTVAR :
case CON_ZSHOOTVAR :
{
2007-12-12 17:42:14 +00:00
int lReturn = - 1 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
insptr + + ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( tw = = CON_ZSHOOTVAR | | tw = = CON_EZSHOOTVAR )
2006-11-13 23:12:47 +00:00
{
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . temp_data [ 9 ] = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
if ( ActorExtra [ g_i ] . temp_data [ 9 ] = = 0 )
ActorExtra [ g_i ] . temp_data [ 9 ] = 1 ;
2006-11-13 23:12:47 +00:00
}
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2008-08-10 13:07:07 +00:00
2008-11-20 14:06:36 +00:00
if ( ( g_sp - > sectnum < 0 | | g_sp - > sectnum > = numsectors ) & & g_scriptSanityChecks )
2006-11-13 23:12:47 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sector %d \n " , g_errorLineNum , keyw [ g_tw ] , g_sp - > sectnum ) ;
ActorExtra [ g_i ] . temp_data [ 9 ] = 0 ;
2008-08-10 13:07:07 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2008-08-10 13:07:07 +00:00
2008-11-20 14:06:36 +00:00
lReturn = A_Shoot ( g_i , j ) ;
2008-08-10 13:07:07 +00:00
if ( tw = = CON_ESHOOTVAR | | tw = = CON_EZSHOOTVAR )
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , lReturn , g_i , g_p ) ;
ActorExtra [ g_i ] . temp_data [ 9 ] = 0 ;
2006-11-16 03:02:42 +00:00
break ;
}
2008-07-28 21:23:10 +00:00
2008-07-25 18:10:33 +00:00
case CON_CMENU :
insptr + + ;
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
ChangeToMenu ( j ) ;
2008-07-25 18:10:33 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_SOUNDVAR :
case CON_STOPSOUNDVAR :
case CON_SOUNDONCEVAR :
case CON_GLOBALSOUNDVAR :
2007-02-08 04:19:39 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
switch ( tw )
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
case CON_SOUNDONCEVAR :
2008-11-20 14:06:36 +00:00
if ( ( j < 0 | | j > = MAXSOUNDS ) & & g_scriptSanityChecks ) { OSD_Printf ( CON_ERROR " Invalid sound %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ; break ; }
if ( ! A_CheckSoundPlaying ( g_i , j ) )
A_PlaySound ( ( short ) j , g_i ) ;
2006-04-13 20:47:06 +00:00
break ;
2006-11-16 03:02:42 +00:00
case CON_GLOBALSOUNDVAR :
2008-11-20 14:06:36 +00:00
if ( ( j < 0 | | j > = MAXSOUNDS ) & & g_scriptSanityChecks ) { OSD_Printf ( CON_ERROR " Invalid sound %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ; break ; }
A_PlaySound ( ( short ) j , g_player [ screenpeek ] . ps - > i ) ;
2006-11-15 01:16:55 +00:00
break ;
2006-11-16 03:02:42 +00:00
case CON_STOPSOUNDVAR :
2008-11-20 14:06:36 +00:00
if ( ( j < 0 | | j > = MAXSOUNDS ) & & g_scriptSanityChecks ) { OSD_Printf ( CON_ERROR " Invalid sound %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ; break ; }
if ( A_CheckSoundPlaying ( g_i , j ) )
A_StopSound ( ( short ) j , g_i ) ;
2006-11-16 03:02:42 +00:00
break ;
case CON_SOUNDVAR :
2008-11-20 14:06:36 +00:00
if ( ( j < 0 | | j > = MAXSOUNDS ) & & g_scriptSanityChecks ) { OSD_Printf ( CON_ERROR " Invalid sound %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ; break ; }
A_PlaySound ( ( short ) j , g_i ) ;
2006-04-13 20:47:06 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_GUNIQHUDID :
insptr + + ;
2006-12-18 08:37:12 +00:00
{
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2008-08-09 10:43:27 +00:00
if ( j > = 0 & & j < MAXUNIQHUDID - 1 )
2006-12-18 21:29:55 +00:00
guniqhudid = j ;
2008-08-09 10:43:27 +00:00
else
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid ID %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
case CON_SAVEGAMEVAR :
case CON_READGAMEVAR :
{
int32 i = 0 ;
insptr + + ;
2008-06-29 10:40:37 +00:00
if ( ud . config . scripthandle < 0 )
{
insptr + + ;
break ;
}
2006-11-16 03:02:42 +00:00
switch ( tw )
{
case CON_SAVEGAMEVAR :
2008-11-20 14:06:36 +00:00
i = Gv_GetVar ( * insptr , g_i , g_p ) ;
2007-08-27 00:20:15 +00:00
SCRIPT_PutNumber ( ud . config . scripthandle , " Gamevars " , aGameVars [ * insptr + + ] . szLabel , i , false , false ) ;
2006-11-16 03:02:42 +00:00
break ;
case CON_READGAMEVAR :
2007-08-27 00:20:15 +00:00
SCRIPT_GetNumber ( ud . config . scripthandle , " Gamevars " , aGameVars [ * insptr ] . szLabel , & i ) ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr + + , i , g_i , g_p ) ;
2006-11-15 01:16:55 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
break ;
}
2006-11-15 01:16:55 +00:00
2007-02-08 04:19:39 +00:00
case CON_SHOWVIEW :
insptr + + ;
{
2008-11-20 14:06:36 +00:00
int x = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int y = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int z = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int a = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int horiz = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int sect = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int x1 = scale ( Gv_GetVar ( * insptr + + , g_i , g_p ) , xdim , 320 ) ;
int y1 = scale ( Gv_GetVar ( * insptr + + , g_i , g_p ) , ydim , 200 ) ;
int x2 = scale ( Gv_GetVar ( * insptr + + , g_i , g_p ) , xdim , 320 ) ;
int y2 = scale ( Gv_GetVar ( * insptr + + , g_i , g_p ) , ydim , 200 ) ;
2008-11-17 00:38:26 +00:00
int smoothratio = min ( max ( ( totalclock - ototalclock ) * ( 65536 / TICSPERFRAME ) , 0 ) , 65536 ) ;
2007-03-11 00:47:32 +00:00
2007-02-08 04:19:39 +00:00
if ( x1 > x2 ) swaplong ( & x1 , & x2 ) ;
if ( y1 > y2 ) swaplong ( & y1 , & y2 ) ;
2007-02-13 01:28:50 +00:00
2008-11-20 14:06:36 +00:00
if ( ( x1 < 0 | | y1 < 0 | | x2 > xdim - 1 | | y2 > ydim - 1 | | x2 - x1 < 2 | | y2 - y1 < 2 ) & & g_scriptSanityChecks )
2008-08-09 10:43:27 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " incorrect coordinates \n " , g_errorLineNum , keyw [ g_tw ] ) ;
2007-02-11 00:49:03 +00:00
break ;
2008-08-09 10:43:27 +00:00
}
2008-11-20 14:06:36 +00:00
if ( ( sect < 0 | | sect > = numsectors ) & & g_scriptSanityChecks )
2008-08-09 10:43:27 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sector %d \n " , g_errorLineNum , keyw [ g_tw ] , sect ) ;
2008-08-09 10:43:27 +00:00
break ;
}
2007-02-13 01:28:50 +00:00
2007-02-08 04:19:39 +00:00
# if defined(USE_OPENGL) && defined(POLYMOST)
j = glprojectionhacks ;
glprojectionhacks = 0 ;
2007-02-11 00:49:03 +00:00
# endif
2007-02-08 04:19:39 +00:00
setview ( x1 , y1 , x2 , y2 ) ;
2007-03-11 00:20:32 +00:00
#if 0
2007-08-27 06:46:31 +00:00
if ( ! ud . pause_on & & ( ( ud . show_help = = 0 & & ud . multimode < 2 & & ! ( g_player [ myconnectindex ] . ps - > gm & MODE_MENU ) ) | | ud . multimode > 1 | | ud . recstat = = 2 ) )
2007-03-11 00:20:32 +00:00
smoothratio = min ( max ( ( totalclock - ototalclock ) * ( 65536L / TICSPERFRAME ) , 0 ) , 65536 ) ;
# endif
2008-11-20 14:06:36 +00:00
G_DoInterpolations ( smoothratio ) ;
2007-03-11 00:47:32 +00:00
2007-03-13 18:37:46 +00:00
# define SE40
2007-03-11 00:20:32 +00:00
# ifdef SE40
se40code ( x , y , z , a , horiz , smoothratio ) ;
# endif
2008-07-12 23:44:07 +00:00
if ( ( ( gotpic [ MIRROR > > 3 ] & ( 1 < < ( MIRROR & 7 ) ) ) > 0 )
2008-08-10 13:07:07 +00:00
# if defined(POLYMER) && defined(USE_OPENGL)
2008-07-24 11:16:20 +00:00
& & ( getrendermode ( ) ! = 4 )
2008-07-12 23:44:07 +00:00
# endif
2008-07-16 09:27:08 +00:00
)
2007-03-11 00:20:32 +00:00
{
2007-12-12 17:42:14 +00:00
int j , i = 0 , k , dst = 0x7fffffff ;
2007-03-11 00:20:32 +00:00
2008-11-20 14:06:36 +00:00
for ( k = g_mirrorCount - 1 ; k > = 0 ; k - - )
2007-03-11 00:20:32 +00:00
{
2008-11-20 14:06:36 +00:00
j = klabs ( wall [ g_mirrorWall [ k ] ] . x - x ) ;
j + = klabs ( wall [ g_mirrorWall [ k ] ] . y - y ) ;
2007-03-11 00:20:32 +00:00
if ( j < dst ) dst = j , i = k ;
}
2008-11-20 14:06:36 +00:00
if ( wall [ g_mirrorWall [ i ] ] . overpicnum = = MIRROR )
2007-03-11 00:20:32 +00:00
{
2007-12-12 17:42:14 +00:00
int tposx , tposy ;
2007-03-11 00:20:32 +00:00
short tang ;
2007-03-11 00:47:32 +00:00
2008-11-20 14:06:36 +00:00
preparemirror ( x , y , z , a , horiz , g_mirrorWall [ i ] , g_mirrorSector [ i ] , & tposx , & tposy , & tang ) ;
2007-03-11 00:20:32 +00:00
j = visibility ;
visibility = ( j > > 1 ) + ( j > > 2 ) ;
2008-11-20 14:06:36 +00:00
drawrooms ( tposx , tposy , z , tang , horiz , g_mirrorSector [ i ] + MAXSECTORS ) ;
2007-03-11 00:20:32 +00:00
display_mirror = 1 ;
2008-11-20 14:06:36 +00:00
G_DoSpriteAnimations ( tposx , tposy , tang , smoothratio ) ;
2007-03-11 00:20:32 +00:00
display_mirror = 0 ;
drawmasks ( ) ;
completemirror ( ) ; //Reverse screen x-wise in this function
visibility = j ;
}
gotpic [ MIRROR > > 3 ] & = ~ ( 1 < < ( MIRROR & 7 ) ) ;
}
2008-05-10 01:29:37 +00:00
# ifdef POLYMER
2008-07-24 11:16:20 +00:00
if ( getrendermode ( ) = = 4 )
2008-11-20 14:06:36 +00:00
polymer_setanimatesprites ( G_DoSpriteAnimations , x , y , a , smoothratio ) ;
2008-05-10 01:29:37 +00:00
# endif
2007-02-08 04:19:39 +00:00
drawrooms ( x , y , z , a , horiz , sect ) ;
2007-03-11 00:20:32 +00:00
display_mirror = 2 ;
2008-11-20 14:06:36 +00:00
G_DoSpriteAnimations ( x , y , a , smoothratio ) ;
2007-03-11 00:20:32 +00:00
display_mirror = 0 ;
2007-02-08 04:19:39 +00:00
drawmasks ( ) ;
2008-11-20 14:06:36 +00:00
G_RestoreInterpolations ( ) ;
G_UpdateScreenArea ( ) ;
2007-02-08 04:19:39 +00:00
# if defined(USE_OPENGL) && defined(POLYMOST)
glprojectionhacks = j ;
2007-02-13 01:28:50 +00:00
# endif
2007-02-08 04:19:39 +00:00
break ;
}
2008-03-14 21:04:28 +00:00
case CON_ROTATESPRITE16 :
2006-11-16 03:02:42 +00:00
case CON_ROTATESPRITE :
insptr + + ;
2006-12-18 08:37:12 +00:00
{
2008-11-20 14:06:36 +00:00
int x = Gv_GetVar ( * insptr + + , g_i , g_p ) , y = Gv_GetVar ( * insptr + + , g_i , g_p ) , z = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int a = Gv_GetVar ( * insptr + + , g_i , g_p ) , tilenum = Gv_GetVar ( * insptr + + , g_i , g_p ) , shade = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int pal = Gv_GetVar ( * insptr + + , g_i , g_p ) , orientation = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int x1 = Gv_GetVar ( * insptr + + , g_i , g_p ) , y1 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int x2 = Gv_GetVar ( * insptr + + , g_i , g_p ) , y2 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
2008-08-11 09:31:49 +00:00
if ( tw = = CON_ROTATESPRITE & & ! ( orientation & 256 ) ) { x < < = 16 ; y < < = 16 ; }
2008-03-14 21:04:28 +00:00
rotatesprite ( x , y , z , a , tilenum , shade , pal , 2 | orientation , x1 , y1 , x2 , y2 ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
case CON_MINITEXT :
case CON_GAMETEXT :
2007-12-20 19:14:38 +00:00
case CON_GAMETEXTZ :
2006-11-16 03:02:42 +00:00
case CON_DIGITALNUMBER :
2007-12-20 19:14:38 +00:00
case CON_DIGITALNUMBERZ :
2006-12-18 08:37:12 +00:00
insptr + + ;
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
int tilenum = ( tw = = CON_GAMETEXT | | tw = = CON_GAMETEXTZ | | tw = = CON_DIGITALNUMBER | | tw = = CON_DIGITALNUMBERZ ) ? Gv_GetVar ( * insptr + + , g_i , g_p ) : 0 ;
int x = Gv_GetVar ( * insptr + + , g_i , g_p ) , y = Gv_GetVar ( * insptr + + , g_i , g_p ) , q = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int shade = Gv_GetVar ( * insptr + + , g_i , g_p ) , pal = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
2007-12-20 19:14:38 +00:00
if ( tw = = CON_GAMETEXT | | tw = = CON_GAMETEXTZ | | tw = = CON_DIGITALNUMBER | | tw = = CON_DIGITALNUMBERZ )
2006-12-18 08:37:12 +00:00
{
2008-11-20 14:06:36 +00:00
int orientation = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int x1 = Gv_GetVar ( * insptr + + , g_i , g_p ) , y1 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int x2 = Gv_GetVar ( * insptr + + , g_i , g_p ) , y2 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2007-12-28 20:04:58 +00:00
int z = 65536 ;
2006-12-18 08:37:12 +00:00
2007-12-20 19:14:38 +00:00
if ( tw = = CON_GAMETEXT | | tw = = CON_GAMETEXTZ )
2006-12-18 08:37:12 +00:00
{
2007-12-28 20:04:58 +00:00
int z = 65536 ;
2008-11-20 14:06:36 +00:00
if ( ( ScriptQuotes [ q ] = = NULL ) & & g_scriptSanityChecks )
2006-12-18 08:37:12 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " null quote %d \n " , g_errorLineNum , keyw [ g_tw ] , q ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
if ( tw = = CON_GAMETEXTZ ) z = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
gametext_z ( 0 , tilenum , x > > 1 , y , ScriptQuotes [ q ] , shade , pal , orientation , x1 , y1 , x2 , y2 , z ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
if ( tw = = CON_DIGITALNUMBERZ ) z = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
G_DrawTXDigiNumZ ( tilenum , x , y , q , shade , pal , orientation , x1 , y1 , x2 , y2 , z ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
if ( ( ScriptQuotes [ q ] = = NULL ) & & g_scriptSanityChecks )
2006-12-18 08:37:12 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " null quote %d \n " , g_errorLineNum , keyw [ g_tw ] , q ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
minitextshade ( x , y , ScriptQuotes [ q ] , shade , pal , 26 ) ;
2006-12-18 08:37:12 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
case CON_ANGOFF :
insptr + + ;
spriteext [ g_i ] . angoff = * insptr + + ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_GETZRANGE :
insptr + + ;
2006-12-18 08:37:12 +00:00
{
2008-11-20 14:06:36 +00:00
int x = Gv_GetVar ( * insptr + + , g_i , g_p ) , y = Gv_GetVar ( * insptr + + , g_i , g_p ) , z = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int sectnum = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
int ceilzvar = * insptr + + , ceilhitvar = * insptr + + , florzvar = * insptr + + , florhitvar = * insptr + + ;
2008-11-20 14:06:36 +00:00
int walldist = Gv_GetVar ( * insptr + + , g_i , g_p ) , clipmask = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2007-12-12 17:42:14 +00:00
int ceilz , ceilhit , florz , florhit ;
2006-12-18 08:37:12 +00:00
2008-11-20 14:06:36 +00:00
if ( ( sectnum < 0 | | sectnum > = numsectors ) & & g_scriptSanityChecks )
2008-08-09 10:43:27 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sector %d \n " , g_errorLineNum , keyw [ g_tw ] , sectnum ) ;
2008-08-09 10:43:27 +00:00
break ;
}
2006-12-18 08:37:12 +00:00
getzrange ( x , y , z , sectnum , & ceilz , & ceilhit , & florz , & florhit , walldist , clipmask ) ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( ceilzvar , ceilz , g_i , g_p ) ;
Gv_SetVar ( ceilhitvar , ceilhit , g_i , g_p ) ;
Gv_SetVar ( florzvar , florz , g_i , g_p ) ;
Gv_SetVar ( florhitvar , florhit , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2006-04-23 06:00:08 +00:00
2006-11-16 03:02:42 +00:00
case CON_HITSCAN :
2006-12-18 08:37:12 +00:00
insptr + + ;
{
2008-11-20 14:06:36 +00:00
int xs = Gv_GetVar ( * insptr + + , g_i , g_p ) , ys = Gv_GetVar ( * insptr + + , g_i , g_p ) , zs = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int sectnum = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int vx = Gv_GetVar ( * insptr + + , g_i , g_p ) , vy = Gv_GetVar ( * insptr + + , g_i , g_p ) , vz = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
int hitsectvar = * insptr + + , hitwallvar = * insptr + + , hitspritevar = * insptr + + ;
2008-11-20 14:06:36 +00:00
int hitxvar = * insptr + + , hityvar = * insptr + + , hitzvar = * insptr + + , cliptype = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
short hitsect , hitwall , hitsprite ;
2007-12-12 17:42:14 +00:00
int hitx , hity , hitz ;
2006-12-18 08:37:12 +00:00
2008-11-20 14:06:36 +00:00
if ( ( sectnum < 0 | | sectnum > = numsectors ) & & g_scriptSanityChecks )
2008-08-09 10:43:27 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sector %d \n " , g_errorLineNum , keyw [ g_tw ] , sectnum ) ;
2008-08-09 10:43:27 +00:00
break ;
}
2006-12-18 08:37:12 +00:00
hitscan ( xs , ys , zs , sectnum , vx , vy , vz , & hitsect , & hitwall , & hitsprite , & hitx , & hity , & hitz , cliptype ) ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( hitsectvar , hitsect , g_i , g_p ) ;
Gv_SetVar ( hitwallvar , hitwall , g_i , g_p ) ;
Gv_SetVar ( hitspritevar , hitsprite , g_i , g_p ) ;
Gv_SetVar ( hitxvar , hitx , g_i , g_p ) ;
Gv_SetVar ( hityvar , hity , g_i , g_p ) ;
Gv_SetVar ( hitzvar , hitz , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_CANSEE :
insptr + + ;
2006-12-18 08:37:12 +00:00
{
2008-11-20 14:06:36 +00:00
int x1 = Gv_GetVar ( * insptr + + , g_i , g_p ) , y1 = Gv_GetVar ( * insptr + + , g_i , g_p ) , z1 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int sect1 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int x2 = Gv_GetVar ( * insptr + + , g_i , g_p ) , y2 = Gv_GetVar ( * insptr + + , g_i , g_p ) , z2 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int sect2 = Gv_GetVar ( * insptr + + , g_i , g_p ) , rvar = * insptr + + ;
2008-07-25 01:09:39 +00:00
2008-11-20 14:06:36 +00:00
if ( ( sect1 < 0 | | sect1 > = numsectors | | sect2 < 0 | | sect2 > = numsectors ) & & g_scriptSanityChecks )
2008-07-25 01:09:39 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sector \n " , g_errorLineNum , keyw [ g_tw ] ) ;
Gv_SetVar ( rvar , 0 , g_i , g_p ) ;
2008-07-25 01:09:39 +00:00
}
2006-11-16 03:02:42 +00:00
2008-11-20 14:06:36 +00:00
Gv_SetVar ( rvar , cansee ( x1 , y1 , z1 , sect1 , x2 , y2 , z2 , sect2 ) , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
2006-12-18 08:37:12 +00:00
case CON_ROTATEPOINT :
2006-11-16 03:02:42 +00:00
insptr + + ;
2006-12-18 08:37:12 +00:00
{
2008-11-20 14:06:36 +00:00
int xpivot = Gv_GetVar ( * insptr + + , g_i , g_p ) , ypivot = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int x = Gv_GetVar ( * insptr + + , g_i , g_p ) , y = Gv_GetVar ( * insptr + + , g_i , g_p ) , daang = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
int x2var = * insptr + + , y2var = * insptr + + ;
2007-12-12 17:42:14 +00:00
int x2 , y2 ;
2006-12-18 08:37:12 +00:00
rotatepoint ( xpivot , ypivot , x , y , daang , & x2 , & y2 ) ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( x2var , x2 , g_i , g_p ) ;
Gv_SetVar ( y2var , y2 , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
case CON_NEARTAG :
2006-12-18 08:37:12 +00:00
insptr + + ;
{
2007-12-12 17:42:14 +00:00
// neartag(int x, int y, int z, short sectnum, short ang, //Starting position & angle
2006-12-18 08:37:12 +00:00
// short *neartagsector, //Returns near sector if sector[].tag != 0
// short *neartagwall, //Returns near wall if wall[].tag != 0
// short *neartagsprite, //Returns near sprite if sprite[].tag != 0
2007-12-12 17:42:14 +00:00
// int *neartaghitdist, //Returns actual distance to object (scale: 1024=largest grid size)
// int neartagrange, //Choose maximum distance to scan (scale: 1024=largest grid size)
2006-12-18 08:37:12 +00:00
// char tagsearch) //1-lotag only, 2-hitag only, 3-lotag&hitag
2008-11-20 14:06:36 +00:00
int x = Gv_GetVar ( * insptr + + , g_i , g_p ) , y = Gv_GetVar ( * insptr + + , g_i , g_p ) , z = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int sectnum = Gv_GetVar ( * insptr + + , g_i , g_p ) , ang = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
int neartagsectorvar = * insptr + + , neartagwallvar = * insptr + + , neartagspritevar = * insptr + + , neartaghitdistvar = * insptr + + ;
2008-11-20 14:06:36 +00:00
int neartagrange = Gv_GetVar ( * insptr + + , g_i , g_p ) , tagsearch = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
2008-11-20 14:06:36 +00:00
if ( ( sectnum < 0 | | sectnum > = numsectors ) & & g_scriptSanityChecks )
2008-08-09 10:43:27 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sector %d \n " , g_errorLineNum , keyw [ g_tw ] , sectnum ) ;
2008-08-09 10:43:27 +00:00
break ;
}
2006-12-18 08:37:12 +00:00
neartag ( x , y , z , sectnum , ang , & neartagsector , & neartagwall , & neartagsprite , & neartaghitdist , neartagrange , tagsearch ) ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( neartagsectorvar , neartagsector , g_i , g_p ) ;
Gv_SetVar ( neartagwallvar , neartagwall , g_i , g_p ) ;
Gv_SetVar ( neartagspritevar , neartagsprite , g_i , g_p ) ;
Gv_SetVar ( neartaghitdistvar , neartaghitdist , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2008-08-10 13:13:24 +00:00
case CON_GETTIMEDATE :
insptr + + ;
{
int v1 = * insptr + + , v2 = * insptr + + , v3 = * insptr + + , v4 = * insptr + + , v5 = * insptr + + , v6 = * insptr + + , v7 = * insptr + + , v8 = * insptr + + ;
time_t rawtime ;
struct tm * ti ;
time ( & rawtime ) ;
ti = localtime ( & rawtime ) ;
// initprintf("Time&date: %s\n",asctime (ti));
2008-11-20 14:06:36 +00:00
Gv_SetVar ( v1 , ti - > tm_sec , g_i , g_p ) ;
Gv_SetVar ( v2 , ti - > tm_min , g_i , g_p ) ;
Gv_SetVar ( v3 , ti - > tm_hour , g_i , g_p ) ;
Gv_SetVar ( v4 , ti - > tm_mday , g_i , g_p ) ;
Gv_SetVar ( v5 , ti - > tm_mon , g_i , g_p ) ;
Gv_SetVar ( v6 , ti - > tm_year + 1900 , g_i , g_p ) ;
Gv_SetVar ( v7 , ti - > tm_wday , g_i , g_p ) ;
Gv_SetVar ( v8 , ti - > tm_yday , g_i , g_p ) ;
2008-08-10 13:13:24 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
case CON_MOVESPRITE :
case CON_SETSPRITE :
insptr + + ;
{
2008-11-20 14:06:36 +00:00
int spritenum = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int x = Gv_GetVar ( * insptr + + , g_i , g_p ) , y = Gv_GetVar ( * insptr + + , g_i , g_p ) , z = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
if ( tw = = CON_SETSPRITE )
{
2008-11-20 14:06:36 +00:00
if ( ( spritenum < 0 | | spritenum > = MAXSPRITES ) & & g_scriptSanityChecks )
2008-08-09 11:19:27 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid sprite ID %d \n " , g_errorLineNum , keyw [ g_tw ] , spritenum ) ;
2008-08-09 11:19:27 +00:00
break ;
}
setsprite ( spritenum , x , y , z ) ;
2006-12-18 08:37:12 +00:00
break ;
}
{
2008-11-20 14:06:36 +00:00
int cliptype = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
2008-11-20 14:06:36 +00:00
if ( ( spritenum < 0 & & spritenum > = MAXSPRITES ) & & g_scriptSanityChecks )
2008-08-09 10:43:27 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid sprite ID %d \n " , g_errorLineNum , keyw [ g_tw ] , spritenum ) ;
2008-08-09 10:43:27 +00:00
insptr + + ;
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr + + , A_MoveSprite ( spritenum , x , y , z , cliptype ) , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
case CON_GETFLORZOFSLOPE :
case CON_GETCEILZOFSLOPE :
insptr + + ;
{
2008-11-20 14:06:36 +00:00
int sectnum = Gv_GetVar ( * insptr + + , g_i , g_p ) , x = Gv_GetVar ( * insptr + + , g_i , g_p ) , y = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
if ( ( sectnum < 0 | | sectnum > = numsectors ) & & g_scriptSanityChecks )
2008-07-25 01:09:39 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid sector %d \n " , g_errorLineNum , keyw [ g_tw ] , sectnum ) ;
2008-07-25 01:09:39 +00:00
insptr + + ;
break ;
}
2006-12-18 08:37:12 +00:00
if ( tw = = CON_GETFLORZOFSLOPE )
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr + + , getflorzofslope ( sectnum , x , y ) , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr + + , getceilzofslope ( sectnum , x , y ) , g_i , g_p ) ;
2006-04-13 20:47:06 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
case CON_UPDATESECTOR :
case CON_UPDATESECTORZ :
insptr + + ;
2006-12-18 08:37:12 +00:00
{
2008-11-20 14:06:36 +00:00
int x = Gv_GetVar ( * insptr + + , g_i , g_p ) , y = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int z = ( tw = = CON_UPDATESECTORZ ) ? Gv_GetVar ( * insptr + + , g_i , g_p ) : 0 ;
2006-12-18 08:37:12 +00:00
int var = * insptr + + ;
short w = sprite [ g_i ] . sectnum ;
2006-04-13 20:47:06 +00:00
2006-12-18 08:37:12 +00:00
if ( tw = = CON_UPDATESECTOR ) updatesector ( x , y , & w ) ;
2008-08-24 19:09:17 +00:00
else updatesectorz ( x , y , z , & w ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
Gv_SetVar ( var , w , g_i , g_p ) ;
2006-12-18 08:37:12 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_SPAWN :
insptr + + ;
if ( g_sp - > sectnum > = 0 & & g_sp - > sectnum < MAXSECTORS )
2008-11-20 14:06:36 +00:00
A_Spawn ( g_i , * insptr ) ;
2006-11-16 03:02:42 +00:00
insptr + + ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFWASWEAPON :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( ActorExtra [ g_i ] . picnum = = * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFAI :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( g_t [ 5 ] = = * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFACTION :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( g_t [ 4 ] = = * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFACTIONCOUNT :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( g_t [ 2 ] > = * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_RESETACTIONCOUNT :
insptr + + ;
g_t [ 2 ] = 0 ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_DEBRIS :
insptr + + ;
2007-02-08 04:19:39 +00:00
{
int dnum = * insptr + + ;
if ( g_sp - > sectnum > = 0 & & g_sp - > sectnum < MAXSECTORS )
for ( j = ( * insptr ) - 1 ; j > = 0 ; j - - )
{
if ( g_sp - > picnum = = BLIMP & & dnum = = SCRAP1 )
s = 0 ;
2008-11-20 14:06:36 +00:00
else s = ( krand ( ) % 3 ) ;
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
l = A_InsertSprite ( g_sp - > sectnum ,
g_sp - > x + ( krand ( ) & 255 ) - 128 , g_sp - > y + ( krand ( ) & 255 ) - 128 , g_sp - > z - ( 8 < < 8 ) - ( krand ( ) & 8191 ) ,
dnum + s , g_sp - > shade , 32 + ( krand ( ) & 15 ) , 32 + ( krand ( ) & 15 ) ,
krand ( ) & 2047 , ( krand ( ) & 127 ) + 32 ,
- ( krand ( ) & 2047 ) , g_i , 5 ) ;
2007-02-08 04:19:39 +00:00
if ( g_sp - > picnum = = BLIMP & & dnum = = SCRAP1 )
2008-11-20 14:06:36 +00:00
sprite [ l ] . yvel = BlimpSpawnSprites [ j % 14 ] ;
2007-02-08 04:19:39 +00:00
else sprite [ l ] . yvel = - 1 ;
sprite [ l ] . pal = g_sp - > pal ;
}
insptr + + ;
}
break ;
2006-11-16 03:02:42 +00:00
case CON_COUNT :
insptr + + ;
g_t [ 0 ] = ( short ) * insptr + + ;
2006-04-13 20:47:06 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_CSTATOR :
insptr + + ;
g_sp - > cstat | = ( short ) * insptr + + ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_CLIPDIST :
insptr + + ;
g_sp - > clipdist = ( short ) * insptr + + ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_CSTAT :
insptr + + ;
g_sp - > cstat = ( short ) * insptr + + ;
break ;
2008-09-15 02:47:02 +00:00
case CON_SAVENN :
2006-11-16 03:02:42 +00:00
case CON_SAVE :
2007-02-08 04:19:39 +00:00
insptr + + ;
{
time_t curtime ;
2006-11-16 03:02:42 +00:00
2008-11-20 14:06:36 +00:00
g_lastSaveSlot = * insptr + + ;
2006-12-19 20:31:40 +00:00
2008-11-20 14:06:36 +00:00
if ( ( g_movesPerPacket = = 4 & & connecthead ! = myconnectindex ) | | g_lastSaveSlot > 9 )
2007-02-08 04:19:39 +00:00
break ;
2008-11-20 14:06:36 +00:00
if ( ( tw = = CON_SAVE ) | | ! ( ud . savegame [ g_lastSaveSlot ] [ 0 ] ) )
2008-09-15 02:47:02 +00:00
{
curtime = time ( NULL ) ;
Bstrcpy ( tempbuf , asctime ( localtime ( & curtime ) ) ) ;
2008-11-20 14:06:36 +00:00
clearbuf ( ud . savegame [ g_lastSaveSlot ] , sizeof ( ud . savegame [ g_lastSaveSlot ] ) , 0 ) ;
Bsprintf ( ud . savegame [ g_lastSaveSlot ] , " Auto " ) ;
2008-02-14 08:35:30 +00:00
// for (j=0;j<13;j++)
2008-11-20 14:06:36 +00:00
// Bmemcpy(&ud.savegame[g_lastSaveSlot][j+4],&tempbuf[j+3],sizeof(tempbuf[j+3]));
// ud.savegame[g_lastSaveSlot][j+4] = '\0';
Bmemcpy ( & ud . savegame [ g_lastSaveSlot ] [ 4 ] , & tempbuf [ 3 ] , sizeof ( tempbuf [ 0 ] ) * 13 ) ;
ud . savegame [ g_lastSaveSlot ] [ 17 ] = ' \0 ' ;
2008-09-15 02:47:02 +00:00
}
2008-11-20 14:06:36 +00:00
OSD_Printf ( " Saving to slot %d \n " , g_lastSaveSlot ) ;
2006-11-13 23:12:47 +00:00
2007-02-08 04:19:39 +00:00
KB_FlushKeyboardQueue ( ) ;
2006-11-13 23:12:47 +00:00
2008-11-20 14:06:36 +00:00
g_screenCapture = 1 ;
G_DrawRooms ( myconnectindex , 65536 ) ;
g_screenCapture = 0 ;
2007-02-08 04:19:39 +00:00
if ( ud . multimode > 1 )
2008-11-20 14:06:36 +00:00
G_SavePlayer ( - 1 - ( g_lastSaveSlot ) ) ;
else G_SavePlayer ( g_lastSaveSlot ) ;
2006-04-18 02:01:48 +00:00
2007-02-08 04:19:39 +00:00
break ;
}
2006-04-18 03:11:38 +00:00
2007-01-05 22:30:35 +00:00
case CON_QUAKE :
insptr + + ;
2008-11-20 14:06:36 +00:00
g_earthquakeTime = ( char ) Gv_GetVar ( * insptr + + , g_i , g_p ) ;
A_PlaySound ( EARTHQUAKE , g_player [ screenpeek ] . ps - > i ) ;
2007-01-05 22:30:35 +00:00
break ;
2006-11-16 03:02:42 +00:00
case CON_IFMOVE :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( g_t [ 1 ] = = * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_RESETPLAYER :
{
insptr + + ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
//AddLog("resetplayer");
if ( ud . multimode < 2 )
{
2008-11-20 14:06:36 +00:00
if ( g_lastSaveSlot > = 0 & & ud . recstat ! = 2 )
2006-11-15 01:16:55 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > gm = MODE_MENU ;
2006-11-16 03:02:42 +00:00
KB_ClearKeyDown ( sc_Space ) ;
2008-11-20 14:06:36 +00:00
ChangeToMenu ( 15000 ) ;
2006-11-15 01:16:55 +00:00
}
2007-08-27 06:46:31 +00:00
else g_player [ g_p ] . ps - > gm = MODE_RESTART ;
2008-11-20 14:06:36 +00:00
g_killitFlag = 2 ;
2006-11-16 03:02:42 +00:00
}
else
{
2008-11-20 14:06:36 +00:00
P_RandomSpawnPoint ( g_p ) ;
g_sp - > x = ActorExtra [ g_i ] . bposx = g_player [ g_p ] . ps - > bobposx = g_player [ g_p ] . ps - > oposx = g_player [ g_p ] . ps - > posx ;
g_sp - > y = ActorExtra [ g_i ] . bposy = g_player [ g_p ] . ps - > bobposy = g_player [ g_p ] . ps - > oposy = g_player [ g_p ] . ps - > posy ;
g_sp - > z = ActorExtra [ g_i ] . bposy = g_player [ g_p ] . ps - > oposz = g_player [ g_p ] . ps - > posz ;
2007-08-27 06:46:31 +00:00
updatesector ( g_player [ g_p ] . ps - > posx , g_player [ g_p ] . ps - > posy , & g_player [ g_p ] . ps - > cursectnum ) ;
setsprite ( g_player [ g_p ] . ps - > i , g_player [ g_p ] . ps - > posx , g_player [ g_p ] . ps - > posy , g_player [ g_p ] . ps - > posz + PHEIGHT ) ;
2006-11-16 03:02:42 +00:00
g_sp - > cstat = 257 ;
g_sp - > shade = - 12 ;
g_sp - > clipdist = 64 ;
g_sp - > xrepeat = 42 ;
g_sp - > yrepeat = 36 ;
g_sp - > owner = g_i ;
g_sp - > xoffset = 0 ;
2007-08-27 06:46:31 +00:00
g_sp - > pal = g_player [ g_p ] . ps - > palookup ;
2007-08-27 23:11:49 +00:00
g_player [ g_p ] . ps - > last_extra = g_sp - > extra = g_player [ g_p ] . ps - > max_player_health ;
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > wantweaponfire = - 1 ;
g_player [ g_p ] . ps - > horiz = 100 ;
g_player [ g_p ] . ps - > on_crane = - 1 ;
g_player [ g_p ] . ps - > frag_ps = g_p ;
g_player [ g_p ] . ps - > horizoff = 0 ;
g_player [ g_p ] . ps - > opyoff = 0 ;
g_player [ g_p ] . ps - > wackedbyactor = - 1 ;
2008-11-20 14:06:36 +00:00
g_player [ g_p ] . ps - > shield_amount = g_startArmorAmount ;
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > dead_flag = 0 ;
g_player [ g_p ] . ps - > pals_time = 0 ;
g_player [ g_p ] . ps - > footprintcount = 0 ;
g_player [ g_p ] . ps - > weapreccnt = 0 ;
g_player [ g_p ] . ps - > fta = 0 ;
g_player [ g_p ] . ps - > ftq = 0 ;
g_player [ g_p ] . ps - > posxv = g_player [ g_p ] . ps - > posyv = 0 ;
g_player [ g_p ] . ps - > rotscrnang = 0 ;
2008-11-20 14:06:36 +00:00
g_player [ g_p ] . ps - > runspeed = g_playerFriction ;
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > falling_counter = 0 ;
2006-11-16 03:02:42 +00:00
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . extra = - 1 ;
ActorExtra [ g_i ] . owner = g_i ;
2006-11-16 03:02:42 +00:00
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . cgg = 0 ;
ActorExtra [ g_i ] . movflag = 0 ;
ActorExtra [ g_i ] . tempang = 0 ;
ActorExtra [ g_i ] . actorstayput = - 1 ;
ActorExtra [ g_i ] . dispicnum = 0 ;
ActorExtra [ g_i ] . owner = g_player [ g_p ] . ps - > i ;
2006-11-16 03:02:42 +00:00
2008-11-20 14:06:36 +00:00
P_ResetInventory ( g_p ) ;
P_ResetWeapons ( g_p ) ;
2006-11-16 03:02:42 +00:00
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > reloading = 0 ;
2006-11-16 03:02:42 +00:00
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > movement_lock = 0 ;
2006-11-16 03:02:42 +00:00
2008-11-20 14:06:36 +00:00
X_OnEvent ( EVENT_RESETPLAYER , g_player [ g_p ] . ps - > i , g_p , - 1 ) ;
g_cameraDistance = 0 ;
g_cameraClock = totalclock ;
2006-11-13 23:12:47 +00:00
}
2008-11-20 14:06:36 +00:00
P_UpdateScreenPal ( g_player [ g_p ] . ps ) ;
2006-11-16 03:02:42 +00:00
//AddLog("EOF: resetplayer");
}
break ;
case CON_IFONWATER :
2008-11-20 14:06:36 +00:00
X_DoConditional ( klabs ( g_sp - > z - sector [ g_sp - > sectnum ] . floorz ) < ( 32 < < 8 ) & & sector [ g_sp - > sectnum ] . lotag = = 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case CON_IFINWATER :
2008-11-20 14:06:36 +00:00
X_DoConditional ( sector [ g_sp - > sectnum ] . lotag = = 2 ) ;
2006-04-13 20:47:06 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFCOUNT :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( g_t [ 0 ] > = * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
case CON_IFACTOR :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( g_sp - > picnum = = * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
case CON_RESETCOUNT :
insptr + + ;
g_t [ 0 ] = 0 ;
break ;
case CON_ADDINVENTORY :
insptr + = 2 ;
switch ( * ( insptr - 1 ) )
{
case GET_STEROIDS :
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > steroids_amount = * insptr ;
g_player [ g_p ] . ps - > inven_icon = 2 ;
2006-04-13 20:47:06 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case GET_SHIELD :
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > shield_amount + = * insptr ; // 100;
2007-08-27 23:11:49 +00:00
if ( g_player [ g_p ] . ps - > shield_amount > g_player [ g_p ] . ps - > max_shield_amount )
g_player [ g_p ] . ps - > shield_amount = g_player [ g_p ] . ps - > max_shield_amount ;
2006-04-13 20:47:06 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case GET_SCUBA :
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > scuba_amount = * insptr ; // 1600;
g_player [ g_p ] . ps - > inven_icon = 6 ;
2006-04-13 20:47:06 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case GET_HOLODUKE :
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > holoduke_amount = * insptr ; // 1600;
g_player [ g_p ] . ps - > inven_icon = 3 ;
2006-04-13 20:47:06 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case GET_JETPACK :
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > jetpack_amount = * insptr ; // 1600;
g_player [ g_p ] . ps - > inven_icon = 4 ;
2006-04-13 20:47:06 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case GET_ACCESS :
switch ( g_sp - > pal )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > got_access | = 1 ;
2006-11-16 03:02:42 +00:00
break ;
case 21 :
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > got_access | = 2 ;
2006-11-16 03:02:42 +00:00
break ;
case 23 :
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > got_access | = 4 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case GET_HEATS :
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > heat_amount = * insptr ;
g_player [ g_p ] . ps - > inven_icon = 5 ;
2006-04-13 20:47:06 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case GET_FIRSTAID :
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > inven_icon = 1 ;
g_player [ g_p ] . ps - > firstaid_amount = * insptr ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case GET_BOOTS :
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > inven_icon = 7 ;
g_player [ g_p ] . ps - > boot_amount = * insptr ;
2006-11-16 03:02:42 +00:00
break ;
2008-07-25 01:09:39 +00:00
default :
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid inventory ID %d \n " , g_errorLineNum , keyw [ g_tw ] , * ( insptr - 1 ) ) ;
2008-07-25 01:09:39 +00:00
break ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
insptr + + ;
2006-04-13 20:47:06 +00:00
break ;
2006-04-18 03:11:38 +00:00
2008-02-16 22:18:48 +00:00
case CON_HITRADIUSVAR :
insptr + + ;
{
2008-11-20 14:06:36 +00:00
int v1 = Gv_GetVar ( * insptr + + , g_i , g_p ) , v2 = Gv_GetVar ( * insptr + + , g_i , g_p ) , v3 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int v4 = Gv_GetVar ( * insptr + + , g_i , g_p ) , v5 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
A_RadiusDamage ( g_i , v1 , v2 , v3 , v4 , v5 ) ;
2008-02-16 22:18:48 +00:00
}
break ;
2006-11-16 03:02:42 +00:00
case CON_HITRADIUS :
2008-11-20 14:06:36 +00:00
A_RadiusDamage ( g_i , * ( insptr + 1 ) , * ( insptr + 2 ) , * ( insptr + 3 ) , * ( insptr + 4 ) , * ( insptr + 5 ) ) ;
2006-11-16 03:02:42 +00:00
insptr + = 6 ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFP :
{
2008-02-16 22:18:48 +00:00
// insptr++;
2006-11-16 03:02:42 +00:00
2008-02-16 22:18:48 +00:00
l = * ( + + insptr ) ;
2006-11-16 03:02:42 +00:00
j = 0 ;
2007-08-27 06:46:31 +00:00
s = sprite [ g_player [ g_p ] . ps - > i ] . xvel ;
2006-11-16 03:02:42 +00:00
2008-11-20 14:06:36 +00:00
if ( ( l & 8 ) & & g_player [ g_p ] . ps - > on_ground & & TEST_SYNC_KEY ( g_player [ g_p ] . sync - > bits , SK_CROUCH ) )
2006-11-16 03:02:42 +00:00
j = 1 ;
2007-08-27 06:46:31 +00:00
else if ( ( l & 16 ) & & g_player [ g_p ] . ps - > jumping_counter = = 0 & & ! g_player [ g_p ] . ps - > on_ground & &
g_player [ g_p ] . ps - > poszv > 2048 )
2006-11-16 03:02:42 +00:00
j = 1 ;
2007-08-27 06:46:31 +00:00
else if ( ( l & 32 ) & & g_player [ g_p ] . ps - > jumping_counter > 348 )
2006-11-16 03:02:42 +00:00
j = 1 ;
else if ( ( l & 1 ) & & s > = 0 & & s < 8 )
j = 1 ;
2008-11-20 14:06:36 +00:00
else if ( ( l & 2 ) & & s > = 8 & & ! TEST_SYNC_KEY ( g_player [ g_p ] . sync - > bits , SK_RUN ) )
2006-11-16 03:02:42 +00:00
j = 1 ;
2008-11-20 14:06:36 +00:00
else if ( ( l & 4 ) & & s > = 8 & & TEST_SYNC_KEY ( g_player [ g_p ] . sync - > bits , SK_RUN ) )
2006-11-16 03:02:42 +00:00
j = 1 ;
2007-08-27 06:46:31 +00:00
else if ( ( l & 64 ) & & g_player [ g_p ] . ps - > posz < ( g_sp - > z - ( 48 < < 8 ) ) )
2006-11-16 03:02:42 +00:00
j = 1 ;
2008-11-20 14:06:36 +00:00
else if ( ( l & 128 ) & & s < = - 8 & & ! TEST_SYNC_KEY ( g_player [ g_p ] . sync - > bits , SK_RUN ) )
2006-11-16 03:02:42 +00:00
j = 1 ;
2008-11-20 14:06:36 +00:00
else if ( ( l & 256 ) & & s < = - 8 & & TEST_SYNC_KEY ( g_player [ g_p ] . sync - > bits , SK_RUN ) )
2006-11-16 03:02:42 +00:00
j = 1 ;
2007-08-27 06:46:31 +00:00
else if ( ( l & 512 ) & & ( g_player [ g_p ] . ps - > quick_kick > 0 | | ( g_player [ g_p ] . ps - > curr_weapon = = KNEE_WEAPON & & g_player [ g_p ] . ps - > kickback_pic > 0 ) ) )
2006-11-16 03:02:42 +00:00
j = 1 ;
2007-08-27 06:46:31 +00:00
else if ( ( l & 1024 ) & & sprite [ g_player [ g_p ] . ps - > i ] . xrepeat < 32 )
2006-11-16 03:02:42 +00:00
j = 1 ;
2007-08-27 06:46:31 +00:00
else if ( ( l & 2048 ) & & g_player [ g_p ] . ps - > jetpack_on )
2006-11-16 03:02:42 +00:00
j = 1 ;
2007-08-27 06:46:31 +00:00
else if ( ( l & 4096 ) & & g_player [ g_p ] . ps - > steroids_amount > 0 & & g_player [ g_p ] . ps - > steroids_amount < 400 )
2006-11-16 03:02:42 +00:00
j = 1 ;
2007-08-27 06:46:31 +00:00
else if ( ( l & 8192 ) & & g_player [ g_p ] . ps - > on_ground )
2006-11-16 03:02:42 +00:00
j = 1 ;
2007-08-27 06:46:31 +00:00
else if ( ( l & 16384 ) & & sprite [ g_player [ g_p ] . ps - > i ] . xrepeat > 32 & & sprite [ g_player [ g_p ] . ps - > i ] . extra > 0 & & g_player [ g_p ] . ps - > timebeforeexit = = 0 )
2006-11-16 03:02:42 +00:00
j = 1 ;
2007-08-27 06:46:31 +00:00
else if ( ( l & 32768 ) & & sprite [ g_player [ g_p ] . ps - > i ] . extra < = 0 )
2006-11-16 03:02:42 +00:00
j = 1 ;
else if ( ( l & 65536L ) )
{
if ( g_sp - > picnum = = APLAYER & & ud . multimode > 1 )
2008-11-20 14:06:36 +00:00
j = G_GetAngleDelta ( g_player [ otherp ] . ps - > ang , getangle ( g_player [ g_p ] . ps - > posx - g_player [ otherp ] . ps - > posx , g_player [ g_p ] . ps - > posy - g_player [ otherp ] . ps - > posy ) ) ;
2006-11-16 03:02:42 +00:00
else
2008-11-20 14:06:36 +00:00
j = G_GetAngleDelta ( g_player [ g_p ] . ps - > ang , getangle ( g_sp - > x - g_player [ g_p ] . ps - > posx , g_sp - > y - g_player [ g_p ] . ps - > posy ) ) ;
2006-11-16 03:02:42 +00:00
if ( j > - 128 & & j < 128 )
j = 1 ;
else
j = 0 ;
}
2008-11-20 14:06:36 +00:00
X_DoConditional ( ( intptr_t ) j ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFSTRENGTH :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( g_sp - > extra < = * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_GUTS :
insptr + = 2 ;
2008-11-20 14:06:36 +00:00
A_DoGuts ( g_i , * ( insptr - 1 ) , * insptr ) ;
2006-11-16 03:02:42 +00:00
insptr + + ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFSPAWNEDBY :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( ActorExtra [ g_i ] . picnum = = * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_WACKPLAYER :
insptr + + ;
2008-11-20 14:06:36 +00:00
P_ForceAngle ( g_player [ g_p ] . ps ) ;
2006-11-16 03:02:42 +00:00
return 0 ;
case CON_FLASH :
insptr + + ;
sprite [ g_i ] . shade = - 127 ;
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > visibility = - 127 ;
2006-11-16 03:02:42 +00:00
lastvisinc = totalclock + 32 ;
return 0 ;
2008-07-16 09:27:08 +00:00
case CON_SAVEMAPSTATE :
2008-11-20 14:06:36 +00:00
if ( MapInfo [ ud . volume_number * MAXLEVELS + ud . level_number ] . savedstate = = NULL )
MapInfo [ ud . volume_number * MAXLEVELS + ud . level_number ] . savedstate = Bcalloc ( 1 , sizeof ( mapstate_t ) ) ;
G_SaveMapState ( MapInfo [ ud . volume_number * MAXLEVELS + ud . level_number ] . savedstate ) ;
2008-07-16 09:27:08 +00:00
insptr + + ;
return 0 ;
case CON_LOADMAPSTATE :
2008-11-20 14:06:36 +00:00
if ( MapInfo [ ud . volume_number * MAXLEVELS + ud . level_number ] . savedstate )
G_RestoreMapState ( MapInfo [ ud . volume_number * MAXLEVELS + ud . level_number ] . savedstate ) ;
2008-07-16 09:27:08 +00:00
insptr + + ;
return 0 ;
case CON_CLEARMAPSTATE :
insptr + + ;
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
if ( ( j < 0 | | j > = MAXVOLUMES * MAXLEVELS ) & & g_scriptSanityChecks )
2008-08-09 07:41:09 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid map number: %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ;
2008-08-09 07:41:09 +00:00
return 0 ;
}
2008-11-20 14:06:36 +00:00
if ( MapInfo [ j ] . savedstate )
G_FreeMapState ( j ) ;
2008-07-16 09:27:08 +00:00
return 0 ;
2006-11-16 03:02:42 +00:00
case CON_STOPALLSOUNDS :
insptr + + ;
if ( screenpeek = = g_p )
FX_StopAllSounds ( ) ;
return 0 ;
case CON_IFGAPZL :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( ( ( ActorExtra [ g_i ] . floorz - ActorExtra [ g_i ] . ceilingz ) > > 8 ) < * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFHITSPACE :
2008-11-20 14:06:36 +00:00
X_DoConditional ( TEST_SYNC_KEY ( g_player [ g_p ] . sync - > bits , SK_OPEN ) ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFOUTSIDE :
2008-11-20 14:06:36 +00:00
X_DoConditional ( sector [ g_sp - > sectnum ] . ceilingstat & 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFMULTIPLAYER :
2008-11-20 14:06:36 +00:00
X_DoConditional ( ud . multimode > 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_OPERATE :
insptr + + ;
if ( sector [ g_sp - > sectnum ] . lotag = = 0 )
{
neartag ( g_sp - > x , g_sp - > y , g_sp - > z - ( 32 < < 8 ) , g_sp - > sectnum , g_sp - > ang , & neartagsector , & neartagwall , & neartagsprite , & neartaghitdist , 768L , 1 ) ;
if ( neartagsector > = 0 & & isanearoperator ( sector [ neartagsector ] . lotag ) )
if ( ( sector [ neartagsector ] . lotag & 0xff ) = = 23 | | sector [ neartagsector ] . floorz = = sector [ neartagsector ] . ceilingz )
if ( ( sector [ neartagsector ] . lotag & 16384 ) = = 0 )
if ( ( sector [ neartagsector ] . lotag & 32768 ) = = 0 )
{
j = headspritesect [ neartagsector ] ;
while ( j > = 0 )
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
if ( sprite [ j ] . picnum = = ACTIVATOR )
break ;
j = nextspritesect [ j ] ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
if ( j = = - 1 )
2008-11-20 14:06:36 +00:00
G_OperateSectors ( neartagsector , g_i ) ;
2006-11-16 03:02:42 +00:00
}
}
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFINSPACE :
2008-11-20 14:06:36 +00:00
X_DoConditional ( G_CheckForSpaceCeiling ( g_sp - > sectnum ) ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_SPRITEPAL :
insptr + + ;
if ( g_sp - > picnum ! = APLAYER )
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . tempang = g_sp - > pal ;
2006-11-16 03:02:42 +00:00
g_sp - > pal = * insptr + + ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_CACTOR :
insptr + + ;
g_sp - > picnum = * insptr + + ;
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFBULLETNEAR :
2008-11-20 14:06:36 +00:00
X_DoConditional ( A_Dodge ( g_sp ) = = 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFRESPAWN :
2008-11-20 14:06:36 +00:00
if ( A_CheckEnemySprite ( g_sp ) )
X_DoConditional ( ud . respawn_monsters ) ;
else if ( A_CheckInventorySprite ( g_sp ) )
X_DoConditional ( ud . respawn_inventory ) ;
2006-11-16 03:02:42 +00:00
else
2008-11-20 14:06:36 +00:00
X_DoConditional ( ud . respawn_items ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFFLOORDISTL :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( ( ActorExtra [ g_i ] . floorz - g_sp - > z ) < = ( ( * insptr ) < < 8 ) ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFCEILINGDISTL :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( ( g_sp - > z - ActorExtra [ g_i ] . ceilingz ) < = ( ( * insptr ) < < 8 ) ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
case CON_PALFROM :
insptr + + ;
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > pals_time = * insptr + + ;
2008-08-23 09:38:07 +00:00
for ( j = 2 ; j > = 0 ; j - - )
g_player [ g_p ] . ps - > pals [ 2 - j ] = * insptr + + ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_QSPRINTF :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-11-16 03:02:42 +00:00
{
2007-02-08 04:19:39 +00:00
int dq = * insptr + + , sq = * insptr + + ;
2008-11-20 14:06:36 +00:00
if ( ( ScriptQuotes [ sq ] = = NULL | | ScriptQuotes [ dq ] = = NULL ) & & g_scriptSanityChecks )
2008-08-09 12:42:02 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " null quote %d \n " , g_errorLineNum , keyw [ g_tw ] , ScriptQuotes [ sq ] ? dq : sq ) ;
2008-08-09 12:42:02 +00:00
insptr + = 4 ;
break ;
}
2007-02-08 04:19:39 +00:00
{
2008-11-20 14:06:36 +00:00
int var1 = Gv_GetVar ( * insptr + + , g_i , g_p ) , var2 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int var3 = Gv_GetVar ( * insptr + + , g_i , g_p ) , var4 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
Bstrcpy ( tempbuf , ScriptQuotes [ sq ] ) ;
Bsprintf ( ScriptQuotes [ dq ] , tempbuf , var1 , var2 , var3 , var4 ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_ADDLOG :
{
insptr + + ;
2008-08-25 20:25:49 +00:00
2008-11-20 14:06:36 +00:00
OSD_Printf ( OSDTEXT_GREEN " CONLOG: L=%d \n " , g_errorLineNum ) ;
2006-11-16 03:02:42 +00:00
break ;
}
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
case CON_ADDLOGVAR :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-11-16 03:02:42 +00:00
{
2007-02-08 04:19:39 +00:00
int m = 1 ;
char szBuf [ 256 ] ;
2008-08-09 07:41:09 +00:00
int lVarID = * insptr ;
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
if ( ( lVarID > = g_gameVarCount ) | | lVarID < 0 )
2007-02-08 04:19:39 +00:00
{
if ( * insptr = = MAXGAMEVARS ) // addlogvar for a constant? Har.
insptr + + ;
2008-11-20 14:06:36 +00:00
// else if (*insptr > g_gameVarCount && (*insptr < (MAXGAMEVARS<<1)+MAXGAMEVARS+1+MAXGAMEARRAYS))
2008-04-27 06:54:28 +00:00
else if ( * insptr & ( MAXGAMEVARS < < 2 ) )
2008-04-01 03:32:36 +00:00
{
int index ;
2008-04-27 06:54:28 +00:00
lVarID ^ = ( MAXGAMEVARS < < 2 ) ;
if ( lVarID & ( MAXGAMEVARS < < 1 ) )
{
2008-08-10 13:07:07 +00:00
m = - m ;
2008-04-27 06:54:28 +00:00
lVarID ^ = ( MAXGAMEVARS < < 1 ) ;
}
2008-04-01 03:32:36 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
index = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2008-04-27 06:54:28 +00:00
if ( ( index < aGameArrays [ lVarID ] . size ) & & ( index > = 0 ) )
2008-04-01 03:32:36 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( OSDTEXT_GREEN " %s: L=%d %s[%d] =%d \n " , g_errorLineNum , keyw [ g_tw ] ,
2008-08-10 13:13:24 +00:00
aGameArrays [ lVarID ] . szLabel , index , m * aGameArrays [ lVarID ] . plValues [ index ] ) ;
2008-04-01 03:32:36 +00:00
break ;
}
else
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid array index \n " , g_errorLineNum , keyw [ g_tw ] ) ;
2008-04-01 03:32:36 +00:00
break ;
}
}
2008-04-27 06:54:28 +00:00
else if ( * insptr & ( MAXGAMEVARS < < 1 ) )
{
2008-08-10 13:07:07 +00:00
m = - m ;
2008-04-27 06:54:28 +00:00
lVarID ^ = ( MAXGAMEVARS < < 1 ) ;
}
2007-02-08 04:19:39 +00:00
else
{
// invalid varID
insptr + + ;
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid variable \n " , g_errorLineNum , keyw [ g_tw ] ) ;
2007-02-08 04:19:39 +00:00
break ; // out of switch
}
}
2008-11-20 14:06:36 +00:00
Bsprintf ( szBuf , " CONLOGVAR: L=%d %s " , g_errorLineNum , aGameVars [ lVarID ] . szLabel ) ;
2007-02-08 04:19:39 +00:00
strcpy ( g_szBuf , szBuf ) ;
2008-11-20 14:06:36 +00:00
if ( aGameVars [ lVarID ] . dwFlags & GAMEVAR_READONLY )
2006-11-15 01:16:55 +00:00
{
2007-02-08 04:19:39 +00:00
Bsprintf ( szBuf , " (read-only) " ) ;
strcat ( g_szBuf , szBuf ) ;
}
2008-11-20 14:06:36 +00:00
if ( aGameVars [ lVarID ] . dwFlags & GAMEVAR_PERPLAYER )
2007-02-08 04:19:39 +00:00
{
Bsprintf ( szBuf , " (Per Player. Player=%d) " , g_p ) ;
}
2008-11-20 14:06:36 +00:00
else if ( aGameVars [ lVarID ] . dwFlags & GAMEVAR_PERACTOR )
2007-02-08 04:19:39 +00:00
{
Bsprintf ( szBuf , " (Per Actor. Actor=%d) " , g_i ) ;
2006-11-15 01:16:55 +00:00
}
2006-12-19 20:31:40 +00:00
else
{
2007-02-08 04:19:39 +00:00
Bsprintf ( szBuf , " (Global) " ) ;
2006-12-19 20:31:40 +00:00
}
2007-02-08 04:19:39 +00:00
Bstrcat ( g_szBuf , szBuf ) ;
2008-11-20 14:06:36 +00:00
Bsprintf ( szBuf , " =%d \n " , Gv_GetVar ( lVarID , g_i , g_p ) * m ) ;
2007-02-08 04:19:39 +00:00
Bstrcat ( g_szBuf , szBuf ) ;
2008-07-18 09:50:44 +00:00
OSD_Printf ( OSDTEXT_GREEN " %s " , g_szBuf ) ;
2007-02-08 04:19:39 +00:00
insptr + + ;
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
case CON_SETSECTOR :
case CON_GETSECTOR :
2007-02-08 04:19:39 +00:00
insptr + + ;
{
// syntax [gs]etsector[<var>].x <VAR>
// <varid> <xxxid> <varid>
int lVar1 = * insptr + + , lLabelID = * insptr + + , lVar2 = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_AccessSector ( tw = = CON_SETSECTOR , lVar1 , lLabelID , lVar2 ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_SQRT :
2007-02-08 04:19:39 +00:00
insptr + + ;
{
// syntax sqrt <invar> <outvar>
int lInVarID = * insptr + + , lOutVarID = * insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( lOutVarID , ksqrt ( Gv_GetVar ( lInVarID , g_i , g_p ) ) , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
case CON_FINDNEARACTOR :
case CON_FINDNEARSPRITE :
case CON_FINDNEARACTOR3D :
case CON_FINDNEARSPRITE3D :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-11-16 03:02:42 +00:00
{
2007-02-08 04:19:39 +00:00
// 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 = * insptr + + , lMaxDist = * insptr + + , lVarID = * insptr + + ;
2008-08-24 10:19:37 +00:00
int lFound = - 1 , j , k = MAXSTATUS - 1 ;
2007-02-08 04:19:39 +00:00
2008-08-24 10:19:37 +00:00
if ( tw = = CON_FINDNEARACTOR | | tw = = CON_FINDNEARACTOR3D )
k = 1 ;
2008-08-24 03:19:40 +00:00
do
2006-04-13 20:47:06 +00:00
{
2008-08-24 10:19:37 +00:00
j = headspritestat [ k ] ; // all sprites
if ( tw = = CON_FINDNEARSPRITE3D | | tw = = CON_FINDNEARACTOR3D )
2006-04-13 20:47:06 +00:00
{
2008-08-24 10:19:37 +00:00
while ( j > = 0 )
2006-04-13 20:47:06 +00:00
{
2008-08-24 10:19:37 +00:00
if ( sprite [ j ] . picnum = = lType & & j ! = g_i & & dist ( & sprite [ g_i ] , & sprite [ j ] ) < lMaxDist )
2007-02-08 04:19:39 +00:00
{
lFound = j ;
j = MAXSPRITES ;
break ;
}
2008-08-24 10:19:37 +00:00
j = nextspritestat [ j ] ;
2006-04-13 20:47:06 +00:00
}
2008-08-24 06:17:09 +00:00
}
2008-08-24 10:19:37 +00:00
else
{
while ( j > = 0 )
{
if ( sprite [ j ] . picnum = = lType & & j ! = g_i & & ldist ( & sprite [ g_i ] , & sprite [ j ] ) < lMaxDist )
{
lFound = j ;
j = MAXSPRITES ;
break ;
}
j = nextspritestat [ j ] ;
}
}
if ( j = = MAXSPRITES | | tw = = CON_FINDNEARACTOR | | tw = = CON_FINDNEARACTOR3D )
2007-02-08 04:19:39 +00:00
break ;
2008-08-24 06:17:09 +00:00
}
while ( k - - ) ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( lVarID , lFound , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
case CON_FINDNEARACTORVAR :
case CON_FINDNEARSPRITEVAR :
case CON_FINDNEARACTOR3DVAR :
case CON_FINDNEARSPRITE3DVAR :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-11-16 03:02:42 +00:00
{
2007-02-08 04:19:39 +00:00
// 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>
2008-11-20 14:06:36 +00:00
int lType = * insptr + + , lMaxDist = Gv_GetVar ( * insptr + + , g_i , g_p ) , lVarID = * insptr + + ;
2008-08-24 10:19:37 +00:00
int lFound = - 1 , j , k = MAXSTATUS - 1 ;
if ( tw = = CON_FINDNEARACTORVAR | | tw = = CON_FINDNEARACTOR3DVAR )
k = 1 ;
2007-02-08 04:19:39 +00:00
2008-08-24 03:19:40 +00:00
do
2006-04-13 20:47:06 +00:00
{
2008-08-24 10:19:37 +00:00
j = headspritestat [ k ] ; // all sprites
if ( tw = = CON_FINDNEARACTOR3DVAR | | tw = = CON_FINDNEARSPRITE3DVAR )
{
while ( j > = 0 )
{
if ( sprite [ j ] . picnum = = lType & & j ! = g_i & & dist ( & sprite [ g_i ] , & sprite [ j ] ) < lMaxDist )
{
lFound = j ;
j = MAXSPRITES ;
break ;
}
j = nextspritestat [ j ] ;
}
}
else
2006-04-13 20:47:06 +00:00
{
2008-08-24 10:19:37 +00:00
while ( j > = 0 )
2006-04-13 20:47:06 +00:00
{
2008-08-24 10:19:37 +00:00
if ( sprite [ j ] . picnum = = lType & & j ! = g_i & & ldist ( & sprite [ g_i ] , & sprite [ j ] ) < lMaxDist )
2007-02-08 04:19:39 +00:00
{
lFound = j ;
j = MAXSPRITES ;
break ;
}
2008-08-24 10:19:37 +00:00
j = nextspritestat [ j ] ;
2006-11-15 01:16:55 +00:00
}
2008-08-24 06:17:09 +00:00
}
2008-08-24 10:19:37 +00:00
if ( j = = MAXSPRITES | | tw = = CON_FINDNEARACTORVAR | | tw = = CON_FINDNEARACTOR3DVAR )
2007-02-08 04:19:39 +00:00
break ;
2008-08-24 06:17:09 +00:00
}
while ( k - - ) ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( lVarID , lFound , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
case CON_FINDNEARACTORZVAR :
case CON_FINDNEARSPRITEZVAR :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-11-16 03:02:42 +00:00
{
2007-02-08 04:19:39 +00:00
// 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>
2008-11-20 14:06:36 +00:00
int lType = * insptr + + , lMaxDist = Gv_GetVar ( * insptr + + , g_i , g_p ) , lMaxZDist = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2008-12-10 11:36:53 +00:00
int lVarID = * insptr + + , lFound = - 1 , lTemp , lTemp2 , j , k = MAXSTATUS - 1 ;
2008-08-24 03:19:40 +00:00
do
2006-04-13 20:47:06 +00:00
{
2007-02-08 04:19:39 +00:00
j = headspritestat [ tw = = CON_FINDNEARACTORZVAR ? 1 : k ] ; // all sprites
2008-08-24 03:19:40 +00:00
if ( j = = - 1 ) continue ;
do
2006-04-13 20:47:06 +00:00
{
2007-02-08 04:19:39 +00:00
if ( sprite [ j ] . picnum = = lType & & j ! = g_i )
2006-04-13 20:47:06 +00:00
{
2007-02-08 04:19:39 +00:00
lTemp = ldist ( & sprite [ g_i ] , & sprite [ j ] ) ;
if ( lTemp < lMaxDist )
2006-04-13 20:47:06 +00:00
{
2007-02-08 04:19:39 +00:00
lTemp2 = klabs ( sprite [ g_i ] . z - sprite [ j ] . z ) ;
if ( lTemp2 < lMaxZDist )
{
lFound = j ;
j = MAXSPRITES ;
break ;
}
2006-04-13 20:47:06 +00:00
}
}
2007-02-08 04:19:39 +00:00
j = nextspritestat [ j ] ;
2008-08-24 06:17:09 +00:00
}
while ( j > = 0 ) ;
2007-02-08 04:19:39 +00:00
if ( tw = = CON_FINDNEARACTORZVAR | | j = = MAXSPRITES )
break ;
2008-08-24 06:17:09 +00:00
}
while ( k - - ) ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( lVarID , lFound , g_i , g_p ) ;
2006-04-13 20:47:06 +00:00
2007-02-08 04:19:39 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_FINDNEARACTORZ :
case CON_FINDNEARSPRITEZ :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-11-16 03:02:42 +00:00
{
2007-02-08 04:19:39 +00:00
// 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 = * insptr + + , lMaxDist = * insptr + + , lMaxZDist = * insptr + + , lVarID = * insptr + + ;
2008-12-10 11:36:53 +00:00
int lTemp , lTemp2 , lFound = - 1 , j , k = MAXSTATUS - 1 ;
2008-08-24 03:19:40 +00:00
do
2006-04-13 20:47:06 +00:00
{
2007-02-08 04:19:39 +00:00
j = headspritestat [ tw = = CON_FINDNEARACTORZ ? 1 : k ] ; // all sprites
2008-08-24 03:19:40 +00:00
if ( j = = - 1 ) continue ;
do
2006-04-13 20:47:06 +00:00
{
2007-02-08 04:19:39 +00:00
if ( sprite [ j ] . picnum = = lType & & j ! = g_i )
2006-04-13 20:47:06 +00:00
{
2007-02-08 04:19:39 +00:00
lTemp = ldist ( & sprite [ g_i ] , & sprite [ j ] ) ;
if ( lTemp < lMaxDist )
2006-04-13 20:47:06 +00:00
{
2007-02-08 04:19:39 +00:00
lTemp2 = klabs ( sprite [ g_i ] . z - sprite [ j ] . z ) ;
if ( lTemp2 < lMaxZDist )
{
lFound = j ;
j = MAXSPRITES ;
break ;
}
2006-04-13 20:47:06 +00:00
}
}
2007-02-08 04:19:39 +00:00
j = nextspritestat [ j ] ;
2008-08-24 06:17:09 +00:00
}
while ( j > = 0 ) ;
2007-02-08 04:19:39 +00:00
if ( tw = = CON_FINDNEARACTORZ | | j = = MAXSPRITES )
break ;
2008-08-24 06:17:09 +00:00
}
while ( k - - ) ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( lVarID , lFound , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2006-05-22 07:11:30 +00:00
2006-11-16 03:02:42 +00:00
case CON_FINDPLAYER :
2007-02-08 04:19:39 +00:00
insptr + + ;
2008-12-10 11:36:53 +00:00
Gv_SetVar ( g_iReturnVarID , A_FindPlayer ( & sprite [ g_i ] , & j ) , g_i , g_p ) ;
Gv_SetVar ( * insptr + + , j , g_i , g_p ) ;
break ;
2006-05-22 07:11:30 +00:00
2008-12-10 11:36:53 +00:00
case CON_FINDOTHERPLAYER :
insptr + + ;
Gv_SetVar ( g_iReturnVarID , P_FindOtherPlayer ( g_p , & j ) , g_i , g_p ) ;
Gv_SetVar ( * insptr + + , j , g_i , g_p ) ;
break ;
2006-11-16 03:02:42 +00:00
case CON_SETPLAYER :
case CON_GETPLAYER :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-11-16 03:02:42 +00:00
{
2007-02-08 04:19:39 +00:00
// syntax [gs]etplayer[<var>].x <VAR>
// <varid> <xxxid> <varid>
2007-08-27 23:11:49 +00:00
int lVar1 = * insptr + + , lLabelID = * insptr + + , lParm2 = 0 , lVar2 ;
2007-02-08 04:19:39 +00:00
// HACK: need to have access to labels structure at run-time...
2008-11-20 14:06:36 +00:00
if ( PlayerLabels [ lLabelID ] . flags & LABEL_HASPARM2 )
lParm2 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
lVar2 = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_AccessPlayer ( tw = = CON_SETPLAYER , lVar1 , lLabelID , lVar2 , lParm2 ) ;
2006-04-13 20:47:06 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
case CON_SETINPUT :
case CON_GETINPUT :
2007-02-08 04:19:39 +00:00
insptr + + ;
{
// syntax [gs]etplayer[<var>].x <VAR>
// <varid> <xxxid> <varid>
int lVar1 = * insptr + + , lLabelID = * insptr + + , lVar2 = * insptr + + ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
X_AccessPlayerInput ( tw = = CON_SETINPUT , lVar1 , lLabelID , lVar2 ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_GETUSERDEF :
case CON_SETUSERDEF :
2007-02-08 04:19:39 +00:00
insptr + + ;
{
// syntax [gs]etuserdef.xxx <VAR>
// <xxxid> <varid>
int lLabelID = * insptr + + , lVar2 = * insptr + + ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
X_AccessUserdef ( tw = = CON_SETUSERDEF , lLabelID , lVar2 ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_GETPROJECTILE :
case CON_SETPROJECTILE :
2007-02-08 04:19:39 +00:00
insptr + + ;
{
// syntax [gs]etplayer[<var>].x <VAR>
// <varid> <xxxid> <varid>
2008-11-20 14:06:36 +00:00
int lVar1 = Gv_GetVar ( * insptr + + , g_i , g_p ) , lLabelID = * insptr + + , lVar2 = * insptr + + ;
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
X_AccessProjectile ( tw = = CON_SETPROJECTILE , lVar1 , lLabelID , lVar2 ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_SETWALL :
case CON_GETWALL :
2007-02-08 04:19:39 +00:00
insptr + + ;
{
// syntax [gs]etwall[<var>].x <VAR>
// <varid> <xxxid> <varid>
int lVar1 = * insptr + + , lLabelID = * insptr + + , lVar2 = * insptr + + ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
X_AccessWall ( tw = = CON_SETWALL , lVar1 , lLabelID , lVar2 ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_SETACTORVAR :
case CON_GETACTORVAR :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-11-16 03:02:42 +00:00
{
2007-02-08 04:19:39 +00:00
// syntax [gs]etactorvar[<var>].<varx> <VAR>
// gets the value of the per-actor variable varx into VAR
// <var> <varx> <VAR>
2008-11-20 14:06:36 +00:00
int lSprite = Gv_GetVar ( * insptr + + , g_i , g_p ) , lVar1 = * insptr + + ;
2008-06-04 07:38:11 +00:00
j = * insptr + + ;
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
if ( ( lSprite < 0 | | lSprite > = MAXSPRITES ) & & g_scriptSanityChecks )
2008-08-09 12:29:23 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid sprite ID %d \n " , g_errorLineNum , keyw [ g_tw ] , lSprite ) ;
2008-08-23 09:38:07 +00:00
if ( lVar1 = = MAXGAMEVARS ) insptr + + ;
if ( j = = MAXGAMEVARS ) insptr + + ;
2008-08-09 12:29:23 +00:00
break ;
}
2007-02-08 04:19:39 +00:00
if ( tw = = CON_SETACTORVAR )
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( lVar1 , Gv_GetVar ( j , g_i , g_p ) , lSprite , g_p ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , Gv_GetVar ( lVar1 , lSprite , g_p ) , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_SETPLAYERVAR :
case CON_GETPLAYERVAR :
2007-02-05 01:33:08 +00:00
insptr + + ;
2006-11-16 03:02:42 +00:00
{
2007-02-08 04:19:39 +00:00
int iPlayer ;
if ( * insptr ! = g_iThisActorID )
2008-11-20 14:06:36 +00:00
iPlayer = Gv_GetVar ( * insptr , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
else iPlayer = g_p ;
insptr + + ;
2007-02-05 01:33:08 +00:00
{
2007-02-08 04:19:39 +00:00
int lVar1 = * insptr + + , lVar2 = * insptr + + ;
2008-11-20 14:06:36 +00:00
if ( ( iPlayer < 0 | | iPlayer > = ud . multimode ) & & g_scriptSanityChecks )
2008-08-09 12:29:23 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid player ID %d \n " , g_errorLineNum , keyw [ g_tw ] , iPlayer ) ;
2008-08-09 12:29:23 +00:00
break ;
}
2007-02-08 04:19:39 +00:00
if ( tw = = CON_SETPLAYERVAR )
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( lVar1 , Gv_GetVar ( lVar2 , g_i , g_p ) , g_i , iPlayer ) ;
2007-02-08 04:19:39 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( lVar2 , Gv_GetVar ( lVar1 , g_i , iPlayer ) , g_i , g_p ) ;
2007-02-05 01:33:08 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_SETACTOR :
case CON_GETACTOR :
2007-02-08 04:19:39 +00:00
insptr + + ;
{
// syntax [gs]etactor[<var>].x <VAR>
// <varid> <xxxid> <varid>
2006-04-13 20:47:06 +00:00
2007-08-27 23:11:49 +00:00
int lVar1 = * insptr + + , lLabelID = * insptr + + , lParm2 = 0 , lVar2 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( ActorLabels [ lLabelID ] . flags & LABEL_HASPARM2 )
lParm2 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
lVar2 = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_AccessSprite ( tw = = CON_SETACTOR , lVar1 , lLabelID , lVar2 , lParm2 ) ;
2006-04-13 20:47:06 +00:00
break ;
}
2008-07-13 07:10:47 +00:00
case CON_SETTSPR :
case CON_GETTSPR :
insptr + + ;
{
// syntax [gs]etactor[<var>].x <VAR>
// <varid> <xxxid> <varid>
2008-07-13 08:35:36 +00:00
int lVar1 = * insptr + + , lLabelID = * insptr + + , lVar2 = * insptr + + ;
2008-07-13 07:10:47 +00:00
2008-11-20 14:06:36 +00:00
X_AccessTsprite ( tw = = CON_SETTSPR , lVar1 , lLabelID , lVar2 ) ;
2008-07-13 07:10:47 +00:00
break ;
}
2006-11-16 03:02:42 +00:00
case CON_GETANGLETOTARGET :
2007-02-08 04:19:39 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
// ActorExtra[g_i].lastvx and lastvy are last known location of target.
Gv_SetVar ( * insptr + + , getangle ( ActorExtra [ g_i ] . lastvx - g_sp - > x , ActorExtra [ g_i ] . lastvy - g_sp - > y ) , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_ANGOFFVAR :
insptr + + ;
2008-11-20 14:06:36 +00:00
spriteext [ g_i ] . angoff = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_LOCKPLAYER :
insptr + + ;
2008-11-20 14:06:36 +00:00
g_player [ g_p ] . ps - > transporter_hold = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_CHECKAVAILWEAPON :
case CON_CHECKAVAILINVEN :
2007-02-08 04:19:39 +00:00
insptr + + ;
2006-12-18 21:29:55 +00:00
j = g_p ;
2006-04-18 02:01:48 +00:00
2006-12-18 09:32:17 +00:00
if ( * insptr ! = g_iThisActorID )
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * insptr , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
2006-12-23 02:38:47 +00:00
insptr + + ;
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
if ( ( j < 0 | | j > = ud . multimode ) & & g_scriptSanityChecks )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid player ID %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ;
2008-08-09 10:16:18 +00:00
break ;
}
if ( tw = = CON_CHECKAVAILWEAPON )
2008-11-20 14:06:36 +00:00
P_CheckWeapon ( g_player [ j ] . ps ) ;
2008-12-01 10:44:18 +00:00
else P_SelectNextInvItem ( g_player [ j ] . ps ) ;
2008-07-25 01:09:39 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-11-13 23:12:47 +00:00
2006-11-16 03:02:42 +00:00
case CON_GETPLAYERANGLE :
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr + + , g_player [ g_p ] . ps - > ang , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-11-13 23:12:47 +00:00
2006-11-16 03:02:42 +00:00
case CON_SETPLAYERANGLE :
insptr + + ;
2008-11-20 14:06:36 +00:00
g_player [ g_p ] . ps - > ang = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > ang & = 2047 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_GETACTORANGLE :
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr + + , g_sp - > ang , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_SETACTORANGLE :
insptr + + ;
2008-11-20 14:06:36 +00:00
g_sp - > ang = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
g_sp - > ang & = 2047 ;
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_SETVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , * ( insptr + 1 ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2008-04-05 04:18:48 +00:00
2008-04-01 02:50:44 +00:00
case CON_SETARRAY :
2008-04-01 03:32:36 +00:00
insptr + + ;
j = * insptr + + ;
{
2008-11-20 14:06:36 +00:00
int index = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
int value = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2008-04-01 02:50:44 +00:00
2008-08-24 03:19:40 +00:00
// SetGameArrayID(j,index,value);
2008-11-20 14:06:36 +00:00
if ( j < 0 | | j > = g_gameArrayCount | | index > = aGameArrays [ j ] . size | | index < 0 )
2008-08-24 03:19:40 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( OSD_ERROR " Gv_SetVar(): tried to set invalid array ID (%d) or index out of bounds from sprite %d (%d), player %d \n " , j , g_i , sprite [ g_i ] . picnum , g_p ) ;
2008-08-24 03:19:40 +00:00
return 0 ;
}
aGameArrays [ j ] . plValues [ index ] = value ;
2008-04-01 03:32:36 +00:00
break ;
}
2008-09-15 02:47:02 +00:00
case CON_GETARRAYSIZE :
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr + + , aGameArrays [ j ] . size , g_i , g_p ) ;
2008-09-15 02:47:02 +00:00
break ;
2006-04-18 02:01:48 +00:00
2008-04-05 04:18:48 +00:00
case CON_RESIZEARRAY :
insptr + + ;
j = * insptr + + ;
{
2008-11-20 14:06:36 +00:00
int asize = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2008-04-05 04:18:48 +00:00
if ( asize > 0 )
{
2008-08-09 12:29:23 +00:00
OSD_Printf ( OSDTEXT_GREEN " CON_RESIZEARRAY: resizing array %s from %d to %d \n " , aGameArrays [ j ] . szLabel , aGameArrays [ j ] . size , asize ) ;
2008-04-05 04:18:48 +00:00
aGameArrays [ j ] . plValues = Brealloc ( aGameArrays [ j ] . plValues , sizeof ( int ) * asize ) ;
aGameArrays [ j ] . size = asize ;
}
break ;
}
2006-11-16 03:02:42 +00:00
case CON_RANDVAR :
2007-02-08 04:19:39 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , mulscale ( krand ( ) , * ( insptr + 1 ) + 1 , 16 ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_DISPLAYRANDVAR :
2007-02-08 04:19:39 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , mulscale ( rand ( ) , * ( insptr + 1 ) + 1 , 15 ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_MULVAR :
2007-02-08 04:19:39 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , Gv_GetVar ( * insptr , g_i , g_p ) * * ( insptr + 1 ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_DIVVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
if ( * ( insptr + 1 ) = = 0 )
2008-08-09 10:16:18 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Divide by zero. \n " , g_errorLineNum , keyw [ g_tw ] ) ;
2008-08-09 10:16:18 +00:00
insptr + = 2 ;
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , Gv_GetVar ( * insptr , g_i , g_p ) / * ( insptr + 1 ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_MODVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
if ( * ( insptr + 1 ) = = 0 )
2008-08-09 10:16:18 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Mod by zero. \n " , g_errorLineNum , keyw [ g_tw ] ) ;
2008-08-09 10:16:18 +00:00
insptr + = 2 ;
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , Gv_GetVar ( * insptr , g_i , g_p ) % * ( insptr + 1 ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_ANDVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , Gv_GetVar ( * insptr , g_i , g_p ) & * ( insptr + 1 ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_ORVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , Gv_GetVar ( * insptr , g_i , g_p ) | * ( insptr + 1 ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_XORVAR :
2007-02-08 04:19:39 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , Gv_GetVar ( * insptr , g_i , g_p ) ^ * ( insptr + 1 ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-12-19 20:31:40 +00:00
case CON_SETVARVAR :
insptr + + ;
2007-02-08 04:19:39 +00:00
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , Gv_GetVar ( * insptr + + , g_i , g_p ) , g_i , g_p ) ;
2006-12-19 20:31:40 +00:00
break ;
2006-11-16 03:02:42 +00:00
case CON_RANDVARVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , mulscale ( krand ( ) , Gv_GetVar ( * insptr + + , g_i , g_p ) + 1 , 16 ) , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_DISPLAYRANDVARVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , mulscale ( rand ( ) , Gv_GetVar ( * insptr + + , g_i , g_p ) + 1 , 15 ) , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_GMAXAMMO :
2006-12-18 21:29:55 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
if ( ( j < 0 | | j > = MAX_WEAPONS ) & & g_scriptSanityChecks )
2008-08-09 10:43:27 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid weapon ID %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ;
2008-08-09 10:43:27 +00:00
insptr + + ;
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr + + , g_player [ g_p ] . ps - > max_ammo_amount [ j ] , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_SMAXAMMO :
2006-12-18 21:29:55 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
if ( ( j < 0 | | j > = MAX_WEAPONS ) & & g_scriptSanityChecks )
2008-08-09 10:43:27 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Invalid weapon ID %d \n " , g_errorLineNum , keyw [ g_tw ] , j ) ;
2008-08-09 10:43:27 +00:00
insptr + + ;
break ;
}
2008-11-20 14:06:36 +00:00
g_player [ g_p ] . ps - > max_ammo_amount [ j ] = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_MULVARVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
2007-02-08 04:19:39 +00:00
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , Gv_GetVar ( j , g_i , g_p ) * Gv_GetVar ( * insptr + + , g_i , g_p ) , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_DIVVARVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
{
2008-11-20 14:06:36 +00:00
int l2 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
2006-12-18 21:29:55 +00:00
if ( l2 = = 0 )
2008-08-09 10:16:18 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Divide by zero. \n " , g_errorLineNum , keyw [ g_tw ] ) ;
2008-08-09 10:16:18 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , Gv_GetVar ( j , g_i , g_p ) / l2 , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
break ;
}
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_MODVARVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
2007-02-08 04:19:39 +00:00
j = * insptr + + ;
2006-12-18 21:29:55 +00:00
{
2008-11-20 14:06:36 +00:00
int l2 = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
2006-12-18 21:29:55 +00:00
if ( l2 = = 0 )
2008-08-09 10:16:18 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " Mod by zero. \n " , g_errorLineNum , keyw [ g_tw ] ) ;
2008-08-09 10:16:18 +00:00
break ;
}
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , Gv_GetVar ( j , g_i , g_p ) % l2 , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
break ;
}
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_ANDVARVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
2007-02-08 04:19:39 +00:00
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , Gv_GetVar ( j , g_i , g_p ) & Gv_GetVar ( * insptr + + , g_i , g_p ) , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_XORVARVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , Gv_GetVar ( j , g_i , g_p ) ^ Gv_GetVar ( * insptr + + , g_i , g_p ) , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_ORVARVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , Gv_GetVar ( j , g_i , g_p ) | Gv_GetVar ( * insptr + + , g_i , g_p ) , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_SUBVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , Gv_GetVar ( * insptr , g_i , g_p ) - * ( insptr + 1 ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_SUBVARVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , Gv_GetVar ( j , g_i , g_p ) - Gv_GetVar ( * insptr + + , g_i , g_p ) , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_ADDVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , Gv_GetVar ( * insptr , g_i , g_p ) + * ( insptr + 1 ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_SHIFTVARL :
2006-12-18 21:29:55 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , Gv_GetVar ( * insptr , g_i , g_p ) < < * ( insptr + 1 ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_SHIFTVARR :
2006-12-18 21:29:55 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , Gv_GetVar ( * insptr , g_i , g_p ) > > * ( insptr + 1 ) , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_SIN :
2006-12-18 21:29:55 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , sintable [ Gv_GetVar ( * ( insptr + 1 ) , g_i , g_p ) & 2047 ] , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_COS :
2006-12-18 21:29:55 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( * insptr , sintable [ ( Gv_GetVar ( * ( insptr + 1 ) , g_i , g_p ) + 512 ) & 2047 ] , g_i , g_p ) ;
2006-12-18 21:29:55 +00:00
insptr + = 2 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_ADDVARVAR :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , Gv_GetVar ( j , g_i , g_p ) + Gv_GetVar ( * insptr + + , g_i , g_p ) , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_SPGETLOTAG :
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iLoTagID , g_sp - > lotag , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_SPGETHITAG :
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iHiTagID , g_sp - > hitag , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_SECTGETLOTAG :
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iLoTagID , sector [ g_sp - > sectnum ] . lotag , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_SECTGETHITAG :
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iHiTagID , sector [ g_sp - > sectnum ] . hitag , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_GETTEXTUREFLOOR :
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iTextureID , sector [ g_sp - > sectnum ] . floorpicnum , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_STARTTRACK :
2008-05-10 01:29:37 +00:00
case CON_STARTTRACKVAR :
insptr + + ;
2008-11-20 14:06:36 +00:00
if ( tw = = CON_STARTTRACK ) g_musicIndex = ( ud . volume_number * MAXLEVELS ) + ( * ( insptr + + ) ) ;
else g_musicIndex = ( ud . volume_number * MAXLEVELS ) + ( Gv_GetVar ( * ( insptr + + ) , g_i , g_p ) ) ;
if ( MapInfo [ ( unsigned char ) g_musicIndex ] . musicfn = = NULL )
2008-08-09 12:29:23 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " null music for map %d \n " , g_errorLineNum , keyw [ g_tw ] , g_musicIndex ) ;
2008-08-09 12:29:23 +00:00
insptr + + ;
break ;
}
2008-11-20 14:06:36 +00:00
S_PlayMusic ( & MapInfo [ ( unsigned char ) g_musicIndex ] . musicfn [ 0 ] , g_musicIndex ) ;
2008-05-10 01:29:37 +00:00
break ;
2008-08-11 23:33:53 +00:00
case CON_ACTIVATECHEAT :
insptr + + ;
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * ( insptr + + ) , g_i , g_p ) ;
2008-08-11 23:33:53 +00:00
if ( numplayers ! = 1 | | ! ( g_player [ myconnectindex ] . ps - > gm & MODE_GAME ) )
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " not in a single-player game. \n " , g_errorLineNum , keyw [ g_tw ] ) ;
2008-08-11 23:33:53 +00:00
break ;
}
osdcmd_cheatsinfo_stat . cheatnum = j ;
2008-08-11 10:38:46 +00:00
break ;
2008-08-16 11:20:08 +00:00
case CON_SETGAMEPALETTE :
insptr + + ;
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * ( insptr + + ) , g_i , g_p ) ;
2008-08-19 11:05:21 +00:00
switch ( j )
{
default :
2008-11-21 12:14:05 +00:00
case 0 : P_SetGamePalette ( g_player [ g_p ] . ps , palette , 0 ) ; break ;
case 1 : P_SetGamePalette ( g_player [ g_p ] . ps , waterpal , 0 ) ; break ;
case 2 : P_SetGamePalette ( g_player [ g_p ] . ps , slimepal , 0 ) ; break ;
case 3 : P_SetGamePalette ( g_player [ g_p ] . ps , drealms , 0 ) ; break ;
case 4 : P_SetGamePalette ( g_player [ g_p ] . ps , titlepal , 0 ) ; break ;
case 5 : P_SetGamePalette ( g_player [ g_p ] . ps , endingpal , 0 ) ; break ;
case 6 : P_SetGamePalette ( g_player [ g_p ] . ps , animpal , 0 ) ; break ;
2008-08-16 11:20:08 +00:00
}
break ;
2006-11-16 03:02:42 +00:00
case CON_GETTEXTURECEILING :
insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iTextureID , sector [ g_sp - > sectnum ] . ceilingpicnum , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFVARVARAND :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) & Gv_GetVar ( * ( insptr ) , g_i , g_p ) ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2008-09-07 12:36:20 +00:00
case CON_IFVARVAROR :
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) | Gv_GetVar ( * ( insptr ) , g_i , g_p ) ) ;
2008-09-07 12:36:20 +00:00
break ;
case CON_IFVARVARXOR :
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) ^ Gv_GetVar ( * ( insptr ) , g_i , g_p ) ) ;
2008-09-07 12:36:20 +00:00
break ;
case CON_IFVARVAREITHER :
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) | | Gv_GetVar ( * ( insptr ) , g_i , g_p ) ) ;
2008-09-07 12:36:20 +00:00
break ;
2006-11-16 03:02:42 +00:00
case CON_IFVARVARN :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) ! = Gv_GetVar ( * ( insptr ) , g_i , g_p ) ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFVARVARE :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) = = Gv_GetVar ( * ( insptr ) , g_i , g_p ) ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFVARVARG :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) > Gv_GetVar ( * ( insptr ) , g_i , g_p ) ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFVARVARL :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) < Gv_GetVar ( * ( insptr ) , g_i , g_p ) ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFVARE :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) = = * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-11-13 23:12:47 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFVARN :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) ! = * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-11-13 23:12:47 +00:00
2006-11-16 03:02:42 +00:00
case CON_WHILEVARN :
{
2008-08-24 19:09:17 +00:00
intptr_t * savedinsptr = insptr + 2 ;
2006-11-16 03:02:42 +00:00
j = 1 ;
2008-08-24 19:09:17 +00:00
do
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
insptr = savedinsptr ;
2008-11-20 14:06:36 +00:00
if ( Gv_GetVar ( * ( insptr - 1 ) , g_i , g_p ) = = * insptr )
2008-07-16 09:27:08 +00:00
j = 0 ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( j ) ;
2006-11-15 01:16:55 +00:00
}
2008-08-24 19:09:17 +00:00
while ( j ) ;
2006-11-16 03:02:42 +00:00
break ;
}
2006-11-13 23:12:47 +00:00
2006-11-16 03:02:42 +00:00
case CON_WHILEVARVARN :
{
int i , k ;
2008-08-24 19:09:17 +00:00
intptr_t * savedinsptr = insptr + 2 ;
2006-11-16 03:02:42 +00:00
j = 1 ;
2008-08-24 19:09:17 +00:00
do
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
insptr = savedinsptr ;
2008-11-20 14:06:36 +00:00
i = Gv_GetVar ( * ( insptr - 1 ) , g_i , g_p ) ;
2007-02-08 04:19:39 +00:00
k = * ( insptr ) ;
2008-11-20 14:06:36 +00:00
if ( i = = Gv_GetVar ( k , g_i , g_p ) )
2008-07-16 09:27:08 +00:00
j = 0 ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( j ) ;
2006-04-13 20:47:06 +00:00
}
2008-08-24 19:09:17 +00:00
while ( j ) ;
2006-11-16 03:02:42 +00:00
break ;
}
2006-11-13 23:12:47 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFVARAND :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) & * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2008-09-07 12:36:20 +00:00
case CON_IFVAROR :
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) | * insptr ) ;
2008-09-07 12:36:20 +00:00
break ;
case CON_IFVARXOR :
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) ^ * insptr ) ;
2008-09-07 12:36:20 +00:00
break ;
case CON_IFVAREITHER :
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) | | * insptr ) ;
2008-09-07 12:36:20 +00:00
break ;
2006-11-16 03:02:42 +00:00
case CON_IFVARG :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) > * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 02:01:48 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFVARL :
2006-12-18 21:29:55 +00:00
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( Gv_GetVar ( j , g_i , g_p ) < * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFPHEALTHL :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( sprite [ g_player [ g_p ] . ps - > i ] . extra < * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFPINVENTORY :
{
insptr + + ;
j = 0 ;
switch ( * insptr + + )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case GET_STEROIDS :
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > steroids_amount ! = * insptr )
2006-11-16 03:02:42 +00:00
j = 1 ;
2006-11-13 23:12:47 +00:00
break ;
2006-11-16 03:02:42 +00:00
case GET_SHIELD :
2007-08-27 23:11:49 +00:00
if ( g_player [ g_p ] . ps - > shield_amount ! = g_player [ g_p ] . ps - > max_shield_amount )
2006-11-16 03:02:42 +00:00
j = 1 ;
2006-11-13 23:12:47 +00:00
break ;
2006-11-16 03:02:42 +00:00
case GET_SCUBA :
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > scuba_amount ! = * insptr ) j = 1 ;
2006-04-13 20:47:06 +00:00
break ;
2006-11-16 03:02:42 +00:00
case GET_HOLODUKE :
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > holoduke_amount ! = * insptr ) j = 1 ;
2006-11-15 01:16:55 +00:00
break ;
2006-11-16 03:02:42 +00:00
case GET_JETPACK :
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > jetpack_amount ! = * insptr ) j = 1 ;
2006-11-16 03:02:42 +00:00
break ;
case GET_ACCESS :
switch ( g_sp - > pal )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > got_access & 1 ) j = 1 ;
2006-11-16 03:02:42 +00:00
break ;
case 21 :
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > got_access & 2 ) j = 1 ;
2006-11-16 03:02:42 +00:00
break ;
case 23 :
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > got_access & 4 ) j = 1 ;
2006-11-16 03:02:42 +00:00
break ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
break ;
case GET_HEATS :
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > heat_amount ! = * insptr ) j = 1 ;
2006-11-16 03:02:42 +00:00
break ;
case GET_FIRSTAID :
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > firstaid_amount ! = * insptr ) j = 1 ;
2006-11-16 03:02:42 +00:00
break ;
case GET_BOOTS :
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > boot_amount ! = * insptr ) j = 1 ;
2006-11-15 01:16:55 +00:00
break ;
2008-08-09 10:43:27 +00:00
default :
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " invalid inventory ID: %d \n " , g_errorLineNum , keyw [ g_tw ] , * ( insptr - 1 ) ) ;
2006-11-15 01:16:55 +00:00
}
2008-11-20 14:06:36 +00:00
X_DoConditional ( j ) ;
2006-11-16 03:02:42 +00:00
break ;
}
case CON_PSTOMP :
insptr + + ;
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > knee_incs = = 0 & & sprite [ g_player [ g_p ] . ps - > i ] . xrepeat > = 40 )
if ( cansee ( g_sp - > x , g_sp - > y , g_sp - > z - ( 4 < < 8 ) , g_sp - > sectnum , g_player [ g_p ] . ps - > posx , g_player [ g_p ] . ps - > posy , g_player [ g_p ] . ps - > posz + ( 16 < < 8 ) , sprite [ g_player [ g_p ] . ps - > i ] . sectnum ) )
2006-11-16 03:02:42 +00:00
{
2008-08-16 07:53:29 +00:00
for ( j = ud . multimode - 1 ; j > = 0 ; j - - )
2006-04-29 02:23:07 +00:00
{
2007-08-27 06:46:31 +00:00
if ( g_player [ j ] . ps - > actorsqu = = g_i )
2006-11-16 03:02:42 +00:00
break ;
2006-04-29 02:23:07 +00:00
}
2008-08-16 07:53:29 +00:00
if ( j = = - 1 )
2006-11-16 03:02:42 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > knee_incs = 1 ;
if ( g_player [ g_p ] . ps - > weapon_pos = = 0 )
g_player [ g_p ] . ps - > weapon_pos = - 1 ;
g_player [ g_p ] . ps - > actorsqu = g_i ;
2006-11-16 03:02:42 +00:00
}
}
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFAWAYFROMWALL :
{
2006-12-18 09:32:17 +00:00
short s1 = g_sp - > sectnum ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
j = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
updatesector ( g_sp - > x + 108 , g_sp - > y + 108 , & s1 ) ;
if ( s1 = = g_sp - > sectnum )
{
updatesector ( g_sp - > x - 108 , g_sp - > y - 108 , & s1 ) ;
2006-11-14 21:35:50 +00:00
if ( s1 = = g_sp - > sectnum )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
updatesector ( g_sp - > x + 108 , g_sp - > y - 108 , & s1 ) ;
2006-11-14 21:35:50 +00:00
if ( s1 = = g_sp - > sectnum )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
updatesector ( g_sp - > x - 108 , g_sp - > y + 108 , & s1 ) ;
2006-11-14 21:35:50 +00:00
if ( s1 = = g_sp - > sectnum )
2006-11-16 03:02:42 +00:00
j = 1 ;
2006-04-13 20:47:06 +00:00
}
}
2006-04-24 00:49:44 +00:00
}
2008-11-20 14:06:36 +00:00
X_DoConditional ( j ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_QUOTE :
insptr + + ;
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
if ( ( ScriptQuotes [ * insptr ] = = NULL ) & & g_scriptSanityChecks )
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " null quote %d \n " , g_errorLineNum , keyw [ g_tw ] , * insptr ) ;
2006-04-24 00:49:44 +00:00
insptr + + ;
2006-12-23 02:38:47 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2008-07-16 09:27:08 +00:00
2008-11-20 14:06:36 +00:00
if ( ( g_p < 0 | | g_p > = MAXPLAYERS ) & & g_scriptSanityChecks )
2008-07-16 09:27:08 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " bad player for quote %d: (%d) \n " , g_errorLineNum , keyw [ g_tw ] , * insptr , g_p ) ;
2008-07-16 09:27:08 +00:00
insptr + + ;
break ;
}
2008-11-20 14:06:36 +00:00
P_DoQuote ( * ( insptr + + ) | MAXQUOTES , g_player [ g_p ] . ps ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_USERQUOTE :
insptr + + ;
{
2008-11-20 14:06:36 +00:00
int i = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2007-06-12 19:47:34 +00:00
2008-11-20 14:06:36 +00:00
if ( ( ScriptQuotes [ i ] = = NULL ) & & g_scriptSanityChecks )
2007-06-12 19:47:34 +00:00
{
2008-11-20 14:06:36 +00:00
OSD_Printf ( CON_ERROR " null quote %d \n " , g_errorLineNum , keyw [ g_tw ] , i ) ;
2007-06-12 19:47:34 +00:00
break ;
}
2008-11-20 14:06:36 +00:00
G_AddUserQuote ( ScriptQuotes [ i ] ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2007-08-25 01:05:00 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFINOUTERSPACE :
2008-11-20 14:06:36 +00:00
X_DoConditional ( G_CheckForSpaceFloor ( g_sp - > sectnum ) ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-18 03:11:38 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFNOTMOVING :
2008-11-20 14:06:36 +00:00
X_DoConditional ( ( ActorExtra [ g_i ] . movflag & 49152 ) > 16384 ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
case CON_RESPAWNHITAG :
insptr + + ;
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ g_sp - > picnum ] )
2006-11-16 03:02:42 +00:00
{
case FEM1__STATIC :
case FEM2__STATIC :
case FEM3__STATIC :
case FEM4__STATIC :
case FEM5__STATIC :
case FEM6__STATIC :
case FEM7__STATIC :
case FEM8__STATIC :
case FEM9__STATIC :
case FEM10__STATIC :
case PODFEM1__STATIC :
case NAKED1__STATIC :
case STATUE__STATIC :
2008-11-20 14:06:36 +00:00
if ( g_sp - > yvel ) G_OperateRespawns ( g_sp - > yvel ) ;
2006-04-13 20:47:06 +00:00
break ;
2006-11-16 03:02:42 +00:00
default :
2008-11-20 14:06:36 +00:00
if ( g_sp - > hitag > = 0 ) G_OperateRespawns ( g_sp - > hitag ) ;
2006-11-15 01:16:55 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFSPRITEPAL :
insptr + + ;
2008-11-20 14:06:36 +00:00
X_DoConditional ( g_sp - > pal = = * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFANGDIFFL :
insptr + + ;
2008-11-20 14:06:36 +00:00
j = klabs ( G_GetAngleDelta ( g_player [ g_p ] . ps - > ang , g_sp - > ang ) ) ;
X_DoConditional ( j < = * insptr ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_IFNOSOUNDS :
2008-08-23 09:38:07 +00:00
for ( j = MAXSOUNDS - 1 ; j > = 0 ; j - - )
2007-09-11 05:26:38 +00:00
if ( g_sounds [ j ] . SoundOwner [ 0 ] . i = = g_i )
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
X_DoConditional ( j < 0 ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case CON_SPRITEFLAGS :
insptr + + ;
2008-11-20 14:06:36 +00:00
ActorExtra [ g_i ] . flags = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-08-28 19:18:05 +00:00
2008-06-11 09:25:58 +00:00
case CON_GETTICKS :
insptr + + ;
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , getticks ( ) , g_i , g_p ) ;
2008-06-11 09:25:58 +00:00
break ;
2008-06-11 07:35:30 +00:00
2006-11-16 03:02:42 +00:00
case CON_GETCURRADDRESS :
insptr + + ;
2006-12-18 21:29:55 +00:00
j = * insptr + + ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( j , ( intptr_t ) ( insptr - script ) , g_i , g_p ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-08-28 19:18:05 +00:00
2006-11-16 03:02:42 +00:00
case CON_JUMP :
2006-12-18 21:29:55 +00:00
insptr + + ;
2008-11-20 14:06:36 +00:00
j = Gv_GetVar ( * insptr + + , g_i , g_p ) ;
2008-02-18 08:10:54 +00:00
insptr = ( intptr_t * ) ( j + script ) ;
2006-11-16 03:02:42 +00:00
break ;
default :
2008-08-28 05:57:46 +00:00
/* OSD_Printf("fatal error: default processing: previous five values: %d, %d, %d, %d, %d, "
" current opcode: %d, next five values: %d, %d, %d, %d, %d \n current actor: %d (%d) \n " ,
* ( insptr - 5 ) , * ( insptr - 4 ) , * ( insptr - 3 ) , * ( insptr - 2 ) , * ( insptr - 1 ) , * insptr , * ( insptr + 1 ) ,
* ( insptr + 2 ) , * ( insptr + 3 ) , * ( insptr + 4 ) , * ( insptr + 5 ) , g_i , g_sp - > picnum ) ;
2008-11-20 14:06:36 +00:00
OSD_Printf ( " g_errorLineNum: %d, g_tw: %d \n " , g_errorLineNum , g_tw ) ; */
X_ScriptInfo ( ) ;
2008-08-09 10:16:18 +00:00
2008-11-20 14:06:36 +00:00
G_GameExit ( " An error has occurred in the EDuke32 CON executor. \n \n "
" If you are an end user, please e-mail the file eduke32.log \n "
" along with links to any mods you're using to terminx@gmail.com. \n \n "
" If you are a mod developer, please attach all of your CON files \n "
" along with instructions on how to reproduce this error. \n \n "
" Thank you! " ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
return 0 ;
}
2008-11-20 14:06:36 +00:00
void A_LoadActor ( int iActor )
2006-04-13 20:47:06 +00:00
{
2006-12-20 03:27:25 +00:00
g_i = iActor ; // Sprite ID
g_p = - 1 ; // iPlayer; // Player ID
2006-12-10 01:52:35 +00:00
g_x = - 1 ; // lDist; // ??
2006-04-13 20:47:06 +00:00
g_sp = & sprite [ g_i ] ; // Pointer to sprite structure
2008-11-20 14:06:36 +00:00
g_t = & ActorExtra [ g_i ] . temp_data [ 0 ] ; // Sprite's 'extra' data
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( actorLoadEventScrptr [ g_sp - > picnum ] = = 0 ) return ;
2006-04-13 20:47:06 +00:00
insptr = actorLoadEventScrptr [ g_sp - > picnum ] ;
2008-11-20 14:06:36 +00:00
g_killitFlag = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( g_sp - > sectnum < 0 | | g_sp - > sectnum > = MAXSECTORS )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
// if(A_CheckEnemySprite(g_sp))
2007-08-27 06:46:31 +00:00
// g_player[g_p].ps->actors_killed++;
2006-04-13 20:47:06 +00:00
deletesprite ( g_i ) ;
return ;
}
2007-02-08 04:19:39 +00:00
2008-12-01 10:44:18 +00:00
while ( ! X_DoExecute ( ) ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( g_killitFlag = = 1 )
2006-04-13 20:47:06 +00:00
deletesprite ( g_i ) ;
}
2008-11-20 14:06:36 +00:00
void A_Execute ( int iActor , int iPlayer , int lDist )
2006-04-13 20:47:06 +00:00
{
2008-07-27 01:22:17 +00:00
int temp , temp2 ;
// if (actorscrptr[sprite[iActor].picnum] == 0) return;
2007-03-22 18:28:41 +00:00
2006-12-18 08:37:12 +00:00
g_i = iActor ; // Sprite ID
g_p = iPlayer ; // Player ID
g_x = lDist ; // ??
2006-04-13 20:47:06 +00:00
g_sp = & sprite [ g_i ] ; // Pointer to sprite structure
2008-11-20 14:06:36 +00:00
g_t = & ActorExtra [ g_i ] . temp_data [ 0 ] ; // Sprite's 'extra' data
2006-04-13 20:47:06 +00:00
insptr = 4 + ( actorscrptr [ g_sp - > picnum ] ) ;
2008-11-20 14:06:36 +00:00
g_killitFlag = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( g_sp - > sectnum < 0 | | g_sp - > sectnum > = MAXSECTORS )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( A_CheckEnemySprite ( g_sp ) )
2007-08-27 06:46:31 +00:00
g_player [ g_p ] . ps - > actors_killed + + ;
2006-04-13 20:47:06 +00:00
deletesprite ( g_i ) ;
return ;
}
2008-04-27 06:54:28 +00:00
/* Qbix: Changed variables to be aware of the sizeof *insptr
* ( wether it is int vs intptr_t ) , Although it is specificly cast to intptr_t *
* which might be corrected if the code is converted to use offsets */
if ( g_t [ 4 ] )
2006-04-13 20:47:06 +00:00
{
g_sp - > lotag + = TICSPERFRAME ;
2008-04-25 08:14:08 +00:00
if ( g_sp - > lotag > * ( intptr_t * ) ( g_t [ 4 ] + 4 * sizeof ( * insptr ) ) )
2006-04-13 20:47:06 +00:00
{
g_t [ 2 ] + + ;
g_sp - > lotag = 0 ;
2008-04-25 08:14:08 +00:00
g_t [ 3 ] + = * ( intptr_t * ) ( g_t [ 4 ] + 3 * sizeof ( * insptr ) ) ;
2006-04-13 20:47:06 +00:00
}
2008-04-25 08:14:08 +00:00
if ( klabs ( g_t [ 3 ] ) > = klabs ( * ( intptr_t * ) ( g_t [ 4 ] + sizeof ( * insptr ) ) * * ( intptr_t * ) ( g_t [ 4 ] + 3 * sizeof ( * insptr ) ) ) )
2006-04-13 20:47:06 +00:00
g_t [ 3 ] = 0 ;
}
2008-12-01 10:44:18 +00:00
while ( ! X_DoExecute ( ) ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( g_killitFlag = = 1 )
2006-04-13 20:47:06 +00:00
{
// if player was set to squish, first stop that...
2007-08-27 06:46:31 +00:00
if ( g_player [ g_p ] . ps - > actorsqu = = g_i )
g_player [ g_p ] . ps - > actorsqu = - 1 ;
2006-04-13 20:47:06 +00:00
deletesprite ( g_i ) ;
2008-08-24 19:09:17 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
X_Move ( ) ;
2008-08-24 19:09:17 +00:00
if ( ud . angleinterpolation )
{
temp = ( g_sp - > ang & 2047 ) - sprpos [ g_i ] . ang ;
sprpos [ g_i ] . oldang = sprpos [ g_i ] . ang ;
if ( temp )
2007-03-22 18:28:41 +00:00
{
2008-08-24 19:09:17 +00:00
temp2 = temp / klabs ( temp ) ;
if ( klabs ( temp ) > 1024 ) temp2 = - ( temp2 ) ;
sprpos [ g_i ] . angdir = temp2 ;
sprpos [ g_i ] . angdif = min ( ud . angleinterpolation , klabs ( temp ) ) ;
sprpos [ g_i ] . ang + = sprpos [ g_i ] . angdif * sprpos [ g_i ] . angdir ;
sprpos [ g_i ] . ang & = 2047 ;
2007-03-22 18:28:41 +00:00
}
2008-08-24 19:09:17 +00:00
}
2007-03-22 18:28:41 +00:00
2008-08-24 19:09:17 +00:00
if ( g_sp - > statnum = = 6 )
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ g_sp - > picnum ] )
2006-04-13 20:47:06 +00:00
{
2008-08-24 19:09:17 +00:00
case RUBBERCAN__STATIC :
case EXPLODINGBARREL__STATIC :
case WOODENHORSE__STATIC :
case HORSEONSIDE__STATIC :
case CANWITHSOMETHING__STATIC :
case FIREBARREL__STATIC :
case NUKEBARREL__STATIC :
case NUKEBARRELDENTED__STATIC :
case NUKEBARRELLEAKED__STATIC :
case TRIPBOMB__STATIC :
case EGG__STATIC :
2008-11-20 14:06:36 +00:00
if ( ActorExtra [ g_i ] . timetosleep > 1 )
ActorExtra [ g_i ] . timetosleep - - ;
else if ( ActorExtra [ g_i ] . timetosleep = = 1 )
2006-04-13 20:47:06 +00:00
changespritestat ( g_i , 2 ) ;
2008-08-24 19:09:17 +00:00
default :
return ;
2006-04-13 20:47:06 +00:00
}
2008-08-24 19:09:17 +00:00
if ( g_sp - > statnum ! = 1 )
return ;
2008-11-20 14:06:36 +00:00
if ( A_CheckEnemySprite ( g_sp ) )
2008-08-24 19:09:17 +00:00
{
if ( g_sp - > xrepeat > 60 ) return ;
if ( ud . respawn_monsters = = 1 & & g_sp - > extra < = 0 ) return ;
2006-04-13 20:47:06 +00:00
}
2008-08-24 19:09:17 +00:00
else if ( ud . respawn_items = = 1 & & ( g_sp - > cstat & 32768 ) ) return ;
2008-11-20 14:06:36 +00:00
if ( ActorExtra [ g_i ] . timetosleep > 1 )
ActorExtra [ g_i ] . timetosleep - - ;
else if ( ActorExtra [ g_i ] . timetosleep = = 1 )
2008-08-24 19:09:17 +00:00
changespritestat ( g_i , 2 ) ;
2006-04-13 20:47:06 +00:00
}
2008-07-16 09:27:08 +00:00
2008-11-20 14:06:36 +00:00
void G_SaveMapState ( mapstate_t * save )
2008-07-16 09:27:08 +00:00
{
if ( save ! = NULL )
{
int i ;
2008-07-16 21:21:18 +00:00
intptr_t j ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & save - > numwalls , & numwalls , sizeof ( numwalls ) ) ;
Bmemcpy ( & save - > wall [ 0 ] , & wall [ 0 ] , sizeof ( walltype ) * MAXWALLS ) ;
Bmemcpy ( & save - > numsectors , & numsectors , sizeof ( numsectors ) ) ;
Bmemcpy ( & save - > sector [ 0 ] , & sector [ 0 ] , sizeof ( sectortype ) * MAXSECTORS ) ;
Bmemcpy ( & save - > sprite [ 0 ] , & sprite [ 0 ] , sizeof ( spritetype ) * MAXSPRITES ) ;
Bmemcpy ( & save - > spriteext [ 0 ] , & spriteext [ 0 ] , sizeof ( spriteexttype ) * MAXSPRITES ) ;
Bmemcpy ( & save - > headspritesect [ 0 ] , & headspritesect [ 0 ] , sizeof ( headspritesect ) ) ;
Bmemcpy ( & save - > prevspritesect [ 0 ] , & prevspritesect [ 0 ] , sizeof ( prevspritesect ) ) ;
Bmemcpy ( & save - > nextspritesect [ 0 ] , & nextspritesect [ 0 ] , sizeof ( nextspritesect ) ) ;
2008-11-20 14:06:36 +00:00
Bmemcpy ( & save - > headspritestat [ STAT_DEFAULT ] , & headspritestat [ STAT_DEFAULT ] , sizeof ( headspritestat ) ) ;
Bmemcpy ( & save - > prevspritestat [ STAT_DEFAULT ] , & prevspritestat [ STAT_DEFAULT ] , sizeof ( prevspritestat ) ) ;
Bmemcpy ( & save - > nextspritestat [ STAT_DEFAULT ] , & nextspritestat [ STAT_DEFAULT ] , sizeof ( nextspritestat ) ) ;
2008-07-16 21:21:18 +00:00
2008-08-23 09:38:07 +00:00
for ( i = MAXSPRITES - 1 ; i > = 0 ; i - - )
2008-07-16 21:21:18 +00:00
{
save - > scriptptrs [ i ] = 0 ;
if ( actorscrptr [ PN ] = = 0 ) continue ;
j = ( intptr_t ) & script [ 0 ] ;
2008-11-20 14:06:36 +00:00
if ( T2 > = j & & T2 < ( intptr_t ) ( & script [ g_scriptSize ] ) )
2008-07-16 21:21:18 +00:00
{
save - > scriptptrs [ i ] | = 1 ;
T2 - = j ;
}
2008-11-20 14:06:36 +00:00
if ( T5 > = j & & T5 < ( intptr_t ) ( & script [ g_scriptSize ] ) )
2008-07-16 21:21:18 +00:00
{
save - > scriptptrs [ i ] | = 2 ;
T5 - = j ;
}
2008-11-20 14:06:36 +00:00
if ( T6 > = j & & T6 < ( intptr_t ) ( & script [ g_scriptSize ] ) )
2008-07-16 21:21:18 +00:00
{
save - > scriptptrs [ i ] | = 4 ;
T6 - = j ;
}
}
2008-11-20 14:06:36 +00:00
Bmemcpy ( & save - > ActorExtra [ 0 ] , & ActorExtra [ 0 ] , sizeof ( actordata_t ) * MAXSPRITES ) ;
2008-07-16 09:27:08 +00:00
2008-08-23 09:38:07 +00:00
for ( i = MAXSPRITES - 1 ; i > = 0 ; i - - )
2008-07-16 21:21:18 +00:00
{
if ( actorscrptr [ PN ] = = 0 ) continue ;
j = ( intptr_t ) & script [ 0 ] ;
if ( save - > scriptptrs [ i ] & 1 )
T2 + = j ;
if ( save - > scriptptrs [ i ] & 2 )
T5 + = j ;
if ( save - > scriptptrs [ i ] & 4 )
T6 + = j ;
}
2008-11-20 14:06:36 +00:00
Bmemcpy ( & save - > g_numCyclers , & g_numCyclers , sizeof ( g_numCyclers ) ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & save - > cyclers [ 0 ] [ 0 ] , & cyclers [ 0 ] [ 0 ] , sizeof ( cyclers ) ) ;
2008-11-20 14:06:36 +00:00
Bmemcpy ( & save - > g_playerSpawnPoints [ 0 ] , & g_playerSpawnPoints [ 0 ] , sizeof ( g_playerSpawnPoints ) ) ;
Bmemcpy ( & save - > g_numAnimWalls , & g_numAnimWalls , sizeof ( g_numAnimWalls ) ) ;
Bmemcpy ( & save - > SpriteDeletionQueue [ 0 ] , & SpriteDeletionQueue [ 0 ] , sizeof ( SpriteDeletionQueue ) ) ;
Bmemcpy ( & save - > g_spriteDeleteQueuePos , & g_spriteDeleteQueuePos , sizeof ( g_spriteDeleteQueuePos ) ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & save - > animwall [ 0 ] , & animwall [ 0 ] , sizeof ( animwall ) ) ;
Bmemcpy ( & save - > msx [ 0 ] , & msx [ 0 ] , sizeof ( msx ) ) ;
Bmemcpy ( & save - > msy [ 0 ] , & msy [ 0 ] , sizeof ( msy ) ) ;
2008-11-20 14:06:36 +00:00
Bmemcpy ( & save - > g_mirrorWall [ 0 ] , & g_mirrorWall [ 0 ] , sizeof ( g_mirrorWall ) ) ;
Bmemcpy ( & save - > g_mirrorSector [ 0 ] , & g_mirrorSector [ 0 ] , sizeof ( g_mirrorSector ) ) ;
Bmemcpy ( & save - > g_mirrorCount , & g_mirrorCount , sizeof ( g_mirrorCount ) ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & save - > show2dsector [ 0 ] , & show2dsector [ 0 ] , sizeof ( show2dsector ) ) ;
2008-11-20 14:06:36 +00:00
Bmemcpy ( & save - > g_numClouds , & g_numClouds , sizeof ( g_numClouds ) ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & save - > clouds [ 0 ] , & clouds [ 0 ] , sizeof ( clouds ) ) ;
Bmemcpy ( & save - > cloudx [ 0 ] , & cloudx [ 0 ] , sizeof ( cloudx ) ) ;
Bmemcpy ( & save - > cloudy [ 0 ] , & cloudy [ 0 ] , sizeof ( cloudy ) ) ;
Bmemcpy ( & save - > pskyoff [ 0 ] , & pskyoff [ 0 ] , sizeof ( pskyoff ) ) ;
Bmemcpy ( & save - > pskybits , & pskybits , sizeof ( pskybits ) ) ;
Bmemcpy ( & save - > animategoal [ 0 ] , & animategoal [ 0 ] , sizeof ( animategoal ) ) ;
Bmemcpy ( & save - > animatevel [ 0 ] , & animatevel [ 0 ] , sizeof ( animatevel ) ) ;
2008-11-20 14:06:36 +00:00
Bmemcpy ( & save - > g_animateCount , & g_animateCount , sizeof ( g_animateCount ) ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & save - > animatesect [ 0 ] , & animatesect [ 0 ] , sizeof ( animatesect ) ) ;
2008-11-20 14:06:36 +00:00
for ( i = g_animateCount - 1 ; i > = 0 ; i - - ) animateptr [ i ] = ( int * ) ( ( intptr_t ) animateptr [ i ] - ( intptr_t ) ( & sector [ 0 ] ) ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & save - > animateptr [ 0 ] , & animateptr [ 0 ] , sizeof ( animateptr ) ) ;
2008-11-20 14:06:36 +00:00
for ( i = g_animateCount - 1 ; i > = 0 ; i - - ) animateptr [ i ] = ( int * ) ( ( intptr_t ) animateptr [ i ] + ( intptr_t ) ( & sector [ 0 ] ) ) ;
Bmemcpy ( & save - > g_numPlayerSprites , & g_numPlayerSprites , sizeof ( g_numPlayerSprites ) ) ;
Bmemcpy ( & save - > g_earthquakeTime , & g_earthquakeTime , sizeof ( g_earthquakeTime ) ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & save - > lockclock , & lockclock , sizeof ( lockclock ) ) ;
Bmemcpy ( & save - > randomseed , & randomseed , sizeof ( randomseed ) ) ;
2008-11-20 14:06:36 +00:00
Bmemcpy ( & save - > g_globalRandom , & g_globalRandom , sizeof ( g_globalRandom ) ) ;
2008-07-18 02:46:24 +00:00
2008-11-20 14:06:36 +00:00
for ( i = g_gameVarCount - 1 ; i > = 0 ; i - - )
2008-07-18 02:46:24 +00:00
{
2008-11-20 14:06:36 +00:00
if ( aGameVars [ i ] . dwFlags & GAMEVAR_NORESET ) continue ;
if ( aGameVars [ i ] . dwFlags & GAMEVAR_PERPLAYER )
2008-07-18 02:46:24 +00:00
{
if ( ! save - > vars [ i ] )
save - > vars [ i ] = Bcalloc ( MAXPLAYERS , sizeof ( intptr_t ) ) ;
Bmemcpy ( & save - > vars [ i ] [ 0 ] , & aGameVars [ i ] . plValues [ 0 ] , sizeof ( intptr_t ) * MAXPLAYERS ) ;
}
2008-11-20 14:06:36 +00:00
else if ( aGameVars [ i ] . dwFlags & GAMEVAR_PERACTOR )
2008-07-18 02:46:24 +00:00
{
if ( ! save - > vars [ i ] )
save - > vars [ i ] = Bcalloc ( MAXSPRITES , sizeof ( intptr_t ) ) ;
Bmemcpy ( & save - > vars [ i ] [ 0 ] , & aGameVars [ i ] . plValues [ 0 ] , sizeof ( intptr_t ) * MAXSPRITES ) ;
}
else save - > vars [ i ] = ( intptr_t * ) aGameVars [ i ] . lValue ;
}
2008-07-16 09:27:08 +00:00
ototalclock = totalclock ;
}
}
2008-11-20 14:06:36 +00:00
extern void Gv_RefreshPointers ( void ) ;
2008-07-18 02:46:24 +00:00
2008-11-20 14:06:36 +00:00
void G_RestoreMapState ( mapstate_t * save )
2008-07-16 09:27:08 +00:00
{
if ( save ! = NULL )
{
int i , k , x ;
2008-07-16 21:21:18 +00:00
intptr_t j ;
2008-07-27 01:22:17 +00:00
char phealth [ MAXPLAYERS ] ;
2008-07-16 09:27:08 +00:00
2008-07-18 03:22:20 +00:00
for ( i = 0 ; i < ud . multimode ; i + + )
phealth [ i ] = sprite [ g_player [ i ] . ps - > i ] . extra ;
2008-07-16 09:27:08 +00:00
pub = NUMPAGES ;
pus = NUMPAGES ;
2008-11-20 14:06:36 +00:00
G_UpdateScreenArea ( ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & numwalls , & save - > numwalls , sizeof ( numwalls ) ) ;
Bmemcpy ( & wall [ 0 ] , & save - > wall [ 0 ] , sizeof ( walltype ) * MAXWALLS ) ;
Bmemcpy ( & numsectors , & save - > numsectors , sizeof ( numsectors ) ) ;
Bmemcpy ( & sector [ 0 ] , & save - > sector [ 0 ] , sizeof ( sectortype ) * MAXSECTORS ) ;
Bmemcpy ( & sprite [ 0 ] , & save - > sprite [ 0 ] , sizeof ( spritetype ) * MAXSPRITES ) ;
Bmemcpy ( & spriteext [ 0 ] , & save - > spriteext [ 0 ] , sizeof ( spriteexttype ) * MAXSPRITES ) ;
Bmemcpy ( & headspritesect [ 0 ] , & save - > headspritesect [ 0 ] , sizeof ( headspritesect ) ) ;
Bmemcpy ( & prevspritesect [ 0 ] , & save - > prevspritesect [ 0 ] , sizeof ( prevspritesect ) ) ;
Bmemcpy ( & nextspritesect [ 0 ] , & save - > nextspritesect [ 0 ] , sizeof ( nextspritesect ) ) ;
2008-11-20 14:06:36 +00:00
Bmemcpy ( & headspritestat [ STAT_DEFAULT ] , & save - > headspritestat [ STAT_DEFAULT ] , sizeof ( headspritestat ) ) ;
Bmemcpy ( & prevspritestat [ STAT_DEFAULT ] , & save - > prevspritestat [ STAT_DEFAULT ] , sizeof ( prevspritestat ) ) ;
Bmemcpy ( & nextspritestat [ STAT_DEFAULT ] , & save - > nextspritestat [ STAT_DEFAULT ] , sizeof ( nextspritestat ) ) ;
Bmemcpy ( & ActorExtra [ 0 ] , & save - > ActorExtra [ 0 ] , sizeof ( actordata_t ) * MAXSPRITES ) ;
2008-07-16 09:27:08 +00:00
2008-08-23 09:38:07 +00:00
for ( i = MAXSPRITES - 1 ; i > = 0 ; i - - )
2008-07-16 21:21:18 +00:00
{
j = ( intptr_t ) ( & script [ 0 ] ) ;
if ( save - > scriptptrs [ i ] & 1 ) T2 + = j ;
if ( save - > scriptptrs [ i ] & 2 ) T5 + = j ;
if ( save - > scriptptrs [ i ] & 4 ) T6 + = j ;
}
2008-11-20 14:06:36 +00:00
Bmemcpy ( & g_numCyclers , & save - > g_numCyclers , sizeof ( g_numCyclers ) ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & cyclers [ 0 ] [ 0 ] , & save - > cyclers [ 0 ] [ 0 ] , sizeof ( cyclers ) ) ;
2008-11-20 14:06:36 +00:00
Bmemcpy ( & g_playerSpawnPoints [ 0 ] , & save - > g_playerSpawnPoints [ 0 ] , sizeof ( g_playerSpawnPoints ) ) ;
Bmemcpy ( & g_numAnimWalls , & save - > g_numAnimWalls , sizeof ( g_numAnimWalls ) ) ;
Bmemcpy ( & SpriteDeletionQueue [ 0 ] , & save - > SpriteDeletionQueue [ 0 ] , sizeof ( SpriteDeletionQueue ) ) ;
Bmemcpy ( & g_spriteDeleteQueuePos , & save - > g_spriteDeleteQueuePos , sizeof ( g_spriteDeleteQueuePos ) ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & animwall [ 0 ] , & save - > animwall [ 0 ] , sizeof ( animwall ) ) ;
Bmemcpy ( & msx [ 0 ] , & save - > msx [ 0 ] , sizeof ( msx ) ) ;
Bmemcpy ( & msy [ 0 ] , & save - > msy [ 0 ] , sizeof ( msy ) ) ;
2008-11-20 14:06:36 +00:00
Bmemcpy ( & g_mirrorWall [ 0 ] , & save - > g_mirrorWall [ 0 ] , sizeof ( g_mirrorWall ) ) ;
Bmemcpy ( & g_mirrorSector [ 0 ] , & save - > g_mirrorSector [ 0 ] , sizeof ( g_mirrorSector ) ) ;
Bmemcpy ( & g_mirrorCount , & save - > g_mirrorCount , sizeof ( g_mirrorCount ) ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & show2dsector [ 0 ] , & save - > show2dsector [ 0 ] , sizeof ( show2dsector ) ) ;
2008-11-20 14:06:36 +00:00
Bmemcpy ( & g_numClouds , & save - > g_numClouds , sizeof ( g_numClouds ) ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & clouds [ 0 ] , & save - > clouds [ 0 ] , sizeof ( clouds ) ) ;
Bmemcpy ( & cloudx [ 0 ] , & save - > cloudx [ 0 ] , sizeof ( cloudx ) ) ;
Bmemcpy ( & cloudy [ 0 ] , & save - > cloudy [ 0 ] , sizeof ( cloudy ) ) ;
Bmemcpy ( & pskyoff [ 0 ] , & save - > pskyoff [ 0 ] , sizeof ( pskyoff ) ) ;
Bmemcpy ( & pskybits , & save - > pskybits , sizeof ( pskybits ) ) ;
Bmemcpy ( & animategoal [ 0 ] , & save - > animategoal [ 0 ] , sizeof ( animategoal ) ) ;
Bmemcpy ( & animatevel [ 0 ] , & save - > animatevel [ 0 ] , sizeof ( animatevel ) ) ;
2008-11-20 14:06:36 +00:00
Bmemcpy ( & g_animateCount , & save - > g_animateCount , sizeof ( g_animateCount ) ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & animatesect [ 0 ] , & save - > animatesect [ 0 ] , sizeof ( animatesect ) ) ;
Bmemcpy ( & animateptr [ 0 ] , & save - > animateptr [ 0 ] , sizeof ( animateptr ) ) ;
2008-11-20 14:06:36 +00:00
for ( i = g_animateCount - 1 ; i > = 0 ; i - - ) animateptr [ i ] = ( int * ) ( ( intptr_t ) animateptr [ i ] + ( intptr_t ) ( & sector [ 0 ] ) ) ;
Bmemcpy ( & g_numPlayerSprites , & save - > g_numPlayerSprites , sizeof ( g_numPlayerSprites ) ) ;
Bmemcpy ( & g_earthquakeTime , & save - > g_earthquakeTime , sizeof ( g_earthquakeTime ) ) ;
2008-07-16 09:27:08 +00:00
Bmemcpy ( & lockclock , & save - > lockclock , sizeof ( lockclock ) ) ;
Bmemcpy ( & randomseed , & save - > randomseed , sizeof ( randomseed ) ) ;
2008-11-20 14:06:36 +00:00
Bmemcpy ( & g_globalRandom , & save - > g_globalRandom , sizeof ( g_globalRandom ) ) ;
2008-07-16 09:27:08 +00:00
2008-11-20 14:06:36 +00:00
for ( i = g_gameVarCount - 1 ; i > = 0 ; i - - )
2008-07-18 02:46:24 +00:00
{
2008-11-20 14:06:36 +00:00
if ( aGameVars [ i ] . dwFlags & GAMEVAR_NORESET ) continue ;
if ( aGameVars [ i ] . dwFlags & GAMEVAR_PERPLAYER )
2008-07-18 02:46:24 +00:00
Bmemcpy ( & aGameVars [ i ] . plValues [ 0 ] , & save - > vars [ i ] [ 0 ] , sizeof ( intptr_t ) * MAXPLAYERS ) ;
2008-11-20 14:06:36 +00:00
else if ( aGameVars [ i ] . dwFlags & GAMEVAR_PERACTOR )
2008-07-18 02:46:24 +00:00
Bmemcpy ( & aGameVars [ i ] . plValues [ 0 ] , & save - > vars [ i ] [ 0 ] , sizeof ( intptr_t ) * MAXSPRITES ) ;
else aGameVars [ i ] . lValue = ( intptr_t ) save - > vars [ i ] ;
}
2008-11-20 14:06:36 +00:00
Gv_RefreshPointers ( ) ;
2008-07-18 02:46:24 +00:00
2008-07-18 03:22:20 +00:00
for ( i = 0 ; i < ud . multimode ; i + + )
sprite [ g_player [ i ] . ps - > i ] . extra = phealth [ i ] ;
2008-07-16 09:27:08 +00:00
if ( g_player [ myconnectindex ] . ps - > over_shoulder_on ! = 0 )
{
2008-11-20 14:06:36 +00:00
g_cameraDistance = 0 ;
g_cameraClock = 0 ;
2008-07-16 09:27:08 +00:00
g_player [ myconnectindex ] . ps - > over_shoulder_on = 1 ;
}
screenpeek = myconnectindex ;
if ( ud . lockout = = 0 )
{
2008-11-20 14:06:36 +00:00
for ( x = g_numAnimWalls - 1 ; x > = 0 ; x - - )
2008-07-16 09:27:08 +00:00
if ( wall [ animwall [ x ] . wallnum ] . extra > = 0 )
wall [ animwall [ x ] . wallnum ] . picnum = wall [ animwall [ x ] . wallnum ] . extra ;
}
else
{
2008-11-20 14:06:36 +00:00
for ( x = g_numAnimWalls - 1 ; x > = 0 ; x - - )
switch ( DynamicTileMap [ wall [ animwall [ x ] . wallnum ] . picnum ] )
2008-07-16 09:27:08 +00:00
{
case FEMPIC1__STATIC :
wall [ animwall [ x ] . wallnum ] . picnum = BLANKSCREEN ;
break ;
case FEMPIC2__STATIC :
case FEMPIC3__STATIC :
wall [ animwall [ x ] . wallnum ] . picnum = SCREENBREAK6 ;
break ;
}
}
2008-11-20 14:06:36 +00:00
g_numInterpolations = 0 ;
2008-07-16 09:27:08 +00:00
startofdynamicinterpolations = 0 ;
2008-11-20 14:06:36 +00:00
k = headspritestat [ STAT_EFFECTOR ] ;
2008-07-16 09:27:08 +00:00
while ( k > = 0 )
{
switch ( sprite [ k ] . lotag )
{
case 31 :
2008-11-20 14:06:36 +00:00
G_SetInterpolation ( & sector [ sprite [ k ] . sectnum ] . floorz ) ;
2008-07-16 09:27:08 +00:00
break ;
case 32 :
2008-11-20 14:06:36 +00:00
G_SetInterpolation ( & sector [ sprite [ k ] . sectnum ] . ceilingz ) ;
2008-07-16 09:27:08 +00:00
break ;
case 25 :
2008-11-20 14:06:36 +00:00
G_SetInterpolation ( & sector [ sprite [ k ] . sectnum ] . floorz ) ;
G_SetInterpolation ( & sector [ sprite [ k ] . sectnum ] . ceilingz ) ;
2008-07-16 09:27:08 +00:00
break ;
case 17 :
2008-11-20 14:06:36 +00:00
G_SetInterpolation ( & sector [ sprite [ k ] . sectnum ] . floorz ) ;
G_SetInterpolation ( & sector [ sprite [ k ] . sectnum ] . ceilingz ) ;
2008-07-16 09:27:08 +00:00
break ;
case 0 :
case 5 :
case 6 :
case 11 :
case 14 :
case 15 :
case 16 :
case 26 :
case 30 :
2008-11-20 14:06:36 +00:00
Sect_SetInterpolation ( k ) ;
2008-07-16 09:27:08 +00:00
break ;
}
k = nextspritestat [ k ] ;
}
2008-11-20 14:06:36 +00:00
for ( i = g_numInterpolations - 1 ; i > = 0 ; i - - ) bakipos [ i ] = * curipos [ i ] ;
for ( i = g_animateCount - 1 ; i > = 0 ; i - - )
G_SetInterpolation ( animateptr [ i ] ) ;
2008-07-16 09:27:08 +00:00
2008-11-20 14:06:36 +00:00
Net_ResetPrediction ( ) ;
2008-07-16 09:27:08 +00:00
2008-11-20 14:06:36 +00:00
waitforeverybody ( ) ;
2008-07-16 09:27:08 +00:00
flushpackets ( ) ;
clearfifo ( ) ;
2008-11-20 14:06:36 +00:00
G_ResetTimers ( ) ;
2008-07-16 09:27:08 +00:00
}
}