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 "duke3d.h"
# include "osd.h"
// PRIMITIVE
2007-01-30 09:03:51 +00:00
static int haltsoundhack ;
2008-11-20 14:06:36 +00:00
// this function activates a sector's MUSICANDSFX sprite
int A_CallSound ( int sn , int whatsprite )
2006-04-13 20:47:06 +00:00
{
2006-12-20 03:27:25 +00:00
int i ;
2006-11-13 23:12:47 +00:00
if ( haltsoundhack )
2006-04-13 20:47:06 +00:00
{
haltsoundhack = 0 ;
return - 1 ;
}
i = headspritesect [ sn ] ;
2006-11-13 23:12:47 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( PN = = MUSICANDSFX & & SLT < 1000 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( whatsprite = = - 1 ) whatsprite = i ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( T1 = = 0 )
2006-04-13 20:47:06 +00:00
{
2007-09-11 05:26:38 +00:00
if ( ( g_sounds [ SLT ] . m & 16 ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( SLT )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
A_PlaySound ( SLT , whatsprite ) ;
2007-10-24 06:48:13 +00:00
if ( SHT & & SLT ! = SHT & & SHT < MAXSOUNDS )
2008-11-20 14:06:36 +00:00
A_StopSound ( SHT , T6 ) ;
2006-07-13 23:13:06 +00:00
T6 = whatsprite ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
if ( ( sector [ SECT ] . lotag & 0xff ) ! = 22 )
2006-04-13 20:47:06 +00:00
T1 = 1 ;
}
}
2007-10-24 06:48:13 +00:00
else if ( SHT < MAXSOUNDS )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( SHT ) A_PlaySound ( SHT , whatsprite ) ;
2007-09-11 05:26:38 +00:00
if ( ( g_sounds [ SLT ] . m & 1 ) | | ( SHT & & SHT ! = SLT ) )
2008-11-20 14:06:36 +00:00
A_StopSound ( SLT , T6 ) ;
2006-07-13 23:13:06 +00:00
T6 = whatsprite ;
2006-04-13 20:47:06 +00:00
T1 = 0 ;
}
return SLT ;
}
i = nextspritesect [ i ] ;
}
return - 1 ;
}
2006-12-20 03:27:25 +00:00
int check_activator_motion ( int lotag )
2006-04-13 20:47:06 +00:00
{
2006-12-20 03:27:25 +00:00
int i , j ;
2006-04-13 20:47:06 +00:00
spritetype * s ;
2008-11-20 14:06:36 +00:00
i = headspritestat [ STAT_ACTIVATOR ] ;
2006-11-14 21:35:50 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( sprite [ i ] . lotag = = lotag )
2006-04-13 20:47:06 +00:00
{
s = & sprite [ i ] ;
2008-11-20 14:06:36 +00:00
for ( j = g_animateCount - 1 ; j > = 0 ; j - - )
2006-11-14 21:35:50 +00:00
if ( s - > sectnum = = animatesect [ j ] )
return ( 1 ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
j = headspritestat [ STAT_EFFECTOR ] ;
2006-11-14 21:35:50 +00:00
while ( j > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( s - > sectnum = = sprite [ j ] . sectnum )
switch ( sprite [ j ] . lotag )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 11 :
case 30 :
2008-11-20 14:06:36 +00:00
if ( ActorExtra [ j ] . temp_data [ 4 ] )
2006-11-16 03:02:42 +00:00
return ( 1 ) ;
break ;
case 20 :
case 31 :
case 32 :
case 18 :
2008-11-20 14:06:36 +00:00
if ( ActorExtra [ j ] . temp_data [ 0 ] )
2006-11-16 03:02:42 +00:00
return ( 1 ) ;
break ;
2006-04-13 20:47:06 +00:00
}
j = nextspritestat [ j ] ;
}
}
i = nextspritestat [ i ] ;
}
2006-11-14 21:35:50 +00:00
return ( 0 ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
int CheckDoorTile ( int dapic )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ dapic ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case DOORTILE1__STATIC :
case DOORTILE2__STATIC :
case DOORTILE3__STATIC :
case DOORTILE4__STATIC :
case DOORTILE5__STATIC :
case DOORTILE6__STATIC :
case DOORTILE7__STATIC :
case DOORTILE8__STATIC :
case DOORTILE9__STATIC :
case DOORTILE10__STATIC :
case DOORTILE11__STATIC :
case DOORTILE12__STATIC :
case DOORTILE14__STATIC :
case DOORTILE15__STATIC :
case DOORTILE16__STATIC :
case DOORTILE17__STATIC :
case DOORTILE18__STATIC :
case DOORTILE19__STATIC :
case DOORTILE20__STATIC :
case DOORTILE21__STATIC :
case DOORTILE22__STATIC :
case DOORTILE23__STATIC :
return 1 ;
2006-04-13 20:47:06 +00:00
}
return 0 ;
}
2006-12-20 03:27:25 +00:00
int isanunderoperator ( int lotag )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
switch ( lotag & 0xff )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 15 :
case 16 :
case 17 :
case 18 :
case 19 :
case 22 :
case 26 :
return 1 ;
2006-04-13 20:47:06 +00:00
}
return 0 ;
}
2006-12-20 03:27:25 +00:00
int isanearoperator ( int lotag )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
switch ( lotag & 0xff )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 9 :
case 15 :
case 16 :
case 17 :
case 18 :
case 19 :
case 20 :
case 21 :
case 22 :
case 23 :
case 25 :
case 26 :
case 29 : //Toothed door
return 1 ;
2006-04-13 20:47:06 +00:00
}
return 0 ;
}
2008-11-20 14:06:36 +00:00
inline int CheckPlayerInSector ( int sect )
2006-04-13 20:47:06 +00:00
{
2008-02-06 11:48:48 +00:00
int i = connecthead ;
for ( ; i > = 0 ; i = connectpoint2 [ i ] )
2007-08-27 06:46:31 +00:00
if ( sprite [ g_player [ i ] . ps - > i ] . sectnum = = sect ) return i ;
2006-04-13 20:47:06 +00:00
return - 1 ;
}
2008-08-09 12:29:23 +00:00
int ldist ( spritetype * s1 , spritetype * s2 )
2006-04-13 20:47:06 +00:00
{
2008-08-09 12:29:23 +00:00
int x = klabs ( s1 - > x - s2 - > x ) ;
int y = klabs ( s1 - > y - s2 - > y ) ;
if ( x < y ) swaplong ( & x , & y ) ;
{
int t = y + ( y > > 1 ) ;
return ( x - ( x > > 5 ) - ( x > > 7 ) + ( t > > 2 ) + ( t > > 6 ) ) ;
}
2006-04-13 20:47:06 +00:00
}
2008-08-09 12:29:23 +00:00
int dist ( spritetype * s1 , spritetype * s2 )
2006-04-13 20:47:06 +00:00
{
2008-08-09 12:29:23 +00:00
int x = klabs ( s1 - > x - s2 - > x ) ;
int y = klabs ( s1 - > y - s2 - > y ) ;
int z = klabs ( ( s1 - > z - s2 - > z ) > > 4 ) ;
if ( x < y ) swaplong ( & x , & y ) ;
if ( x < z ) swaplong ( & x , & z ) ;
{
int t = y + z ;
return ( x - ( x > > 4 ) + ( t > > 2 ) + ( t > > 3 ) ) ;
}
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
int A_FindPlayer ( spritetype * s , int * d )
2006-04-13 20:47:06 +00:00
{
2008-02-06 11:42:34 +00:00
int j , closest_player = 0 ;
int x , closest = 0x7fffffff ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( ud . multimode < 2 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
* d = klabs ( g_player [ myconnectindex ] . ps - > oposx - s - > x ) + klabs ( g_player [ myconnectindex ] . ps - > oposy - s - > y ) + ( ( klabs ( g_player [ myconnectindex ] . ps - > oposz - s - > z + ( 28 < < 8 ) ) ) > > 4 ) ;
2006-04-13 20:47:06 +00:00
return myconnectindex ;
}
2008-11-20 14:06:36 +00:00
TRAVERSE_CONNECT ( j )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
x = klabs ( g_player [ j ] . ps - > oposx - s - > x ) + klabs ( g_player [ j ] . ps - > oposy - s - > y ) + ( ( klabs ( g_player [ j ] . ps - > oposz - s - > z + ( 28 < < 8 ) ) ) > > 4 ) ;
if ( x < closest & & sprite [ g_player [ j ] . ps - > i ] . extra > 0 )
2006-04-13 20:47:06 +00:00
{
closest_player = j ;
closest = x ;
}
}
* d = closest ;
return closest_player ;
}
2008-11-20 14:06:36 +00:00
int P_FindOtherPlayer ( int p , int * d )
2006-04-13 20:47:06 +00:00
{
2008-02-06 11:42:34 +00:00
int j , closest_player = p ;
int x , closest = 0x7fffffff ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
TRAVERSE_CONNECT ( j )
if ( p ! = j & & sprite [ g_player [ j ] . ps - > i ] . extra > 0 )
{
x = klabs ( g_player [ j ] . ps - > oposx - g_player [ p ] . ps - > posx ) + klabs ( g_player [ j ] . ps - > oposy - g_player [ p ] . ps - > posy ) + ( klabs ( g_player [ j ] . ps - > oposz - g_player [ p ] . ps - > posz ) > > 4 ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( x < closest )
{
closest_player = j ;
closest = x ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
}
2006-04-13 20:47:06 +00:00
* d = closest ;
return closest_player ;
}
2008-11-20 14:06:36 +00:00
void G_DoSectorAnimations ( void )
2006-04-13 20:47:06 +00:00
{
2007-12-12 17:42:14 +00:00
int i , j , a , p , v , dasect ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
for ( i = g_animateCount - 1 ; i > = 0 ; i - - )
2006-04-13 20:47:06 +00:00
{
a = * animateptr [ i ] ;
v = animatevel [ i ] * TICSPERFRAME ;
dasect = animatesect [ i ] ;
if ( a = = animategoal [ i ] )
{
2008-11-20 14:06:36 +00:00
G_StopInterpolation ( animateptr [ i ] ) ;
2006-04-13 20:47:06 +00:00
2008-09-28 11:00:59 +00:00
// This fixes a bug where wall or floor sprites contained in
// elevator sectors (ST 16-19) would jitter vertically after the
// elevator had stopped.
2008-09-26 09:48:35 +00:00
if ( animateptr [ i ] = = & sector [ animatesect [ i ] ] . floorz )
for ( j = headspritesect [ dasect ] ; j > = 0 ; j = nextspritesect [ j ] )
if ( sprite [ j ] . statnum ! = 3 )
2008-11-20 14:06:36 +00:00
ActorExtra [ j ] . bposz = sprite [ j ] . z ;
2008-09-26 09:48:35 +00:00
2008-11-20 14:06:36 +00:00
g_animateCount - - ;
animateptr [ i ] = animateptr [ g_animateCount ] ;
animategoal [ i ] = animategoal [ g_animateCount ] ;
animatevel [ i ] = animatevel [ g_animateCount ] ;
animatesect [ i ] = animatesect [ g_animateCount ] ;
2006-11-14 21:35:50 +00:00
if ( sector [ animatesect [ i ] ] . lotag = = 18 | | sector [ animatesect [ i ] ] . lotag = = 19 )
2006-11-13 23:12:47 +00:00
if ( animateptr [ i ] = = & sector [ animatesect [ i ] ] . ceilingz )
2006-04-13 20:47:06 +00:00
continue ;
2006-11-14 21:35:50 +00:00
if ( ( sector [ dasect ] . lotag & 0xff ) ! = 22 )
2008-11-20 14:06:36 +00:00
A_CallSound ( dasect , - 1 ) ;
2006-04-13 20:47:06 +00:00
continue ;
}
2006-11-15 01:16:55 +00:00
if ( v > 0 )
{
a = min ( a + v , animategoal [ i ] ) ;
}
else
{
a = max ( a + v , animategoal [ i ] ) ;
}
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( animateptr [ i ] = = & sector [ animatesect [ i ] ] . floorz )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
TRAVERSE_CONNECT ( p )
if ( g_player [ p ] . ps - > cursectnum = = dasect )
if ( ( sector [ dasect ] . floorz - g_player [ p ] . ps - > posz ) < ( 64 < < 8 ) )
if ( sprite [ g_player [ p ] . ps - > i ] . owner > = 0 )
{
g_player [ p ] . ps - > posz + = v ;
g_player [ p ] . ps - > poszv = 0 ;
if ( p = = myconnectindex )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
myz + = v ;
myzvel = 0 ;
myzbak [ ( ( movefifoplc - 1 ) & ( MOVEFIFOSIZ - 1 ) ) ] = g_player [ p ] . ps - > posz ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
for ( j = headspritesect [ dasect ] ; j > = 0 ; j = nextspritesect [ j ] )
2006-04-13 20:47:06 +00:00
if ( sprite [ j ] . statnum ! = 3 )
{
2008-11-20 14:06:36 +00:00
ActorExtra [ j ] . bposz = sprite [ j ] . z ;
2006-04-13 20:47:06 +00:00
sprite [ j ] . z + = v ;
2008-11-20 14:06:36 +00:00
ActorExtra [ j ] . floorz = sector [ dasect ] . floorz + v ;
2006-04-13 20:47:06 +00:00
}
}
* animateptr [ i ] = a ;
}
}
2008-11-20 14:06:36 +00:00
int GetAnimationGoal ( int * animptr )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
int i = g_animateCount - 1 , j = - 1 ;
2006-04-13 20:47:06 +00:00
2008-02-06 11:42:34 +00:00
for ( ; i > = 0 ; i - - )
2007-12-12 17:42:14 +00:00
if ( animptr = = ( int * ) animateptr [ i ] )
2006-04-13 20:47:06 +00:00
{
j = i ;
break ;
}
return ( j ) ;
}
2008-11-20 14:06:36 +00:00
int SetAnimation ( int animsect , int * animptr , int thegoal , int thevel )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
int i = 0 , j = g_animateCount ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( g_animateCount > = MAXANIMATES - 1 )
2006-04-13 20:47:06 +00:00
return ( - 1 ) ;
2008-11-20 14:06:36 +00:00
for ( ; i < g_animateCount ; i + + )
2006-04-13 20:47:06 +00:00
if ( animptr = = animateptr [ i ] )
{
j = i ;
break ;
}
animatesect [ j ] = animsect ;
animateptr [ j ] = animptr ;
animategoal [ j ] = thegoal ;
if ( thegoal > = * animptr )
animatevel [ j ] = thevel ;
else
animatevel [ j ] = - thevel ;
2008-11-20 14:06:36 +00:00
if ( j = = g_animateCount ) g_animateCount + + ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
G_SetInterpolation ( animptr ) ;
2006-04-13 20:47:06 +00:00
return ( j ) ;
}
2008-11-20 14:06:36 +00:00
void G_AnimateCamSprite ( void )
2006-04-13 20:47:06 +00:00
{
2008-02-06 11:42:34 +00:00
int i = camsprite ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( camsprite < = 0 ) return ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( T1 > = 11 )
2006-04-13 20:47:06 +00:00
{
T1 = 0 ;
2007-08-27 06:46:31 +00:00
if ( g_player [ screenpeek ] . ps - > newowner > = 0 )
OW = g_player [ screenpeek ] . ps - > newowner ;
else if ( OW > = 0 & & dist ( & sprite [ g_player [ screenpeek ] . ps - > i ] , & sprite [ i ] ) < 2048 )
2006-04-13 20:47:06 +00:00
{
if ( waloff [ TILE_VIEWSCR ] = = 0 )
allocatepermanenttile ( TILE_VIEWSCR , tilesizx [ PN ] , tilesizy [ PN ] ) ;
else walock [ TILE_VIEWSCR ] = 255 ;
xyzmirror ( OW , /*PN*/ TILE_VIEWSCR ) ;
}
}
else T1 + + ;
}
2008-11-20 14:06:36 +00:00
void G_AnimateWalls ( void )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
int i , j , p = g_numAnimWalls - 1 , t ;
2006-04-13 20:47:06 +00:00
2008-08-24 04:35:35 +00:00
for ( ; p > = 0 ; p - - )
2008-11-20 14:06:36 +00:00
// for(p=g_numAnimWalls-1;p>=0;p--)
2006-04-13 20:47:06 +00:00
{
i = animwall [ p ] . wallnum ;
j = wall [ i ] . picnum ;
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ j ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case SCREENBREAK1__STATIC :
case SCREENBREAK2__STATIC :
case SCREENBREAK3__STATIC :
case SCREENBREAK4__STATIC :
case SCREENBREAK5__STATIC :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case SCREENBREAK9__STATIC :
case SCREENBREAK10__STATIC :
case SCREENBREAK11__STATIC :
case SCREENBREAK12__STATIC :
case SCREENBREAK13__STATIC :
case SCREENBREAK14__STATIC :
case SCREENBREAK15__STATIC :
case SCREENBREAK16__STATIC :
case SCREENBREAK17__STATIC :
case SCREENBREAK18__STATIC :
case SCREENBREAK19__STATIC :
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( ( krand ( ) & 255 ) < 16 )
2006-11-16 03:02:42 +00:00
{
animwall [ p ] . tag = wall [ i ] . picnum ;
wall [ i ] . picnum = SCREENBREAK6 ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case SCREENBREAK6__STATIC :
case SCREENBREAK7__STATIC :
case SCREENBREAK8__STATIC :
if ( animwall [ p ] . tag > = 0 & & wall [ i ] . extra ! = FEMPIC2 & & wall [ i ] . extra ! = FEMPIC3 )
wall [ i ] . picnum = animwall [ p ] . tag ;
else
{
wall [ i ] . picnum + + ;
if ( wall [ i ] . picnum = = ( SCREENBREAK6 + 3 ) )
wall [ i ] . picnum = SCREENBREAK6 ;
}
continue ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
if ( wall [ i ] . cstat & 16 )
2006-04-13 20:47:06 +00:00
if ( ( wall [ i ] . overpicnum > = W_FORCEFIELD ) & & ( wall [ i ] . overpicnum < = W_FORCEFIELD + 2 ) )
{
t = animwall [ p ] . tag ;
2006-11-13 23:12:47 +00:00
if ( wall [ i ] . cstat & 254 )
2006-04-13 20:47:06 +00:00
{
wall [ i ] . xpanning - = t > > 10 ; // sintable[(t+512)&2047]>>12;
wall [ i ] . ypanning - = t > > 10 ; // sintable[t&2047]>>12;
2006-11-13 23:12:47 +00:00
if ( wall [ i ] . extra = = 1 )
2006-04-13 20:47:06 +00:00
{
wall [ i ] . extra = 0 ;
animwall [ p ] . tag = 0 ;
}
else
animwall [ p ] . tag + = 128 ;
2006-11-14 21:35:50 +00:00
if ( animwall [ p ] . tag < ( 128 < < 4 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( animwall [ p ] . tag & 128 )
2006-04-13 20:47:06 +00:00
wall [ i ] . overpicnum = W_FORCEFIELD ;
else wall [ i ] . overpicnum = W_FORCEFIELD + 1 ;
}
else
{
2008-11-20 14:06:36 +00:00
if ( ( krand ( ) & 255 ) < 32 )
animwall [ p ] . tag = 128 < < ( krand ( ) & 3 ) ;
2006-04-13 20:47:06 +00:00
else wall [ i ] . overpicnum = W_FORCEFIELD + 1 ;
}
}
}
}
}
2008-11-20 14:06:36 +00:00
int G_ActivateWarpElevators ( int s , int d ) //Parm = sectoreffectornum
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
int i = headspritestat [ STAT_EFFECTOR ] , sn = sprite [ s ] . sectnum ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( SLT = = 17 )
if ( SHT = = sprite [ s ] . hitag )
2008-11-20 14:06:36 +00:00
if ( ( klabs ( sector [ sn ] . floorz - ActorExtra [ s ] . temp_data [ 2 ] ) > SP ) | |
2006-11-14 21:35:50 +00:00
( sector [ SECT ] . hitag = = ( sector [ sn ] . hitag - d ) ) )
2006-04-13 20:47:06 +00:00
break ;
i = nextspritestat [ i ] ;
}
2006-11-13 23:12:47 +00:00
if ( i = = - 1 )
2006-04-13 20:47:06 +00:00
{
d = 0 ;
return 1 ; // No find
}
else
{
2006-11-13 23:12:47 +00:00
if ( d = = 0 )
2008-11-20 14:06:36 +00:00
A_PlaySound ( ELEVATOR_OFF , s ) ;
else A_PlaySound ( ELEVATOR_ON , s ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
i = headspritestat [ STAT_EFFECTOR ] ;
2006-11-13 23:12:47 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( SLT = = 17 )
if ( SHT = = sprite [ s ] . hitag )
2006-04-13 20:47:06 +00:00
{
T1 = d ;
T2 = d ; //Make all check warp
}
i = nextspritestat [ i ] ;
}
return 0 ;
}
2008-11-20 14:06:36 +00:00
void G_OperateSectors ( int sn , int ii )
2006-04-13 20:47:06 +00:00
{
2007-12-12 17:42:14 +00:00
int j = 0 , l , q , startwall , endwall ;
2006-12-23 02:38:47 +00:00
int i ;
sectortype * sptr = & sector [ sn ] ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
switch ( sptr - > lotag & ( 0xffff - 49152 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 30 :
j = sector [ sn ] . hitag ;
2008-11-20 14:06:36 +00:00
if ( ActorExtra [ j ] . tempang = = 0 | |
ActorExtra [ j ] . tempang = = 256 )
A_CallSound ( sn , ii ) ;
2006-11-16 03:02:42 +00:00
if ( sprite [ j ] . extra = = 1 )
sprite [ j ] . extra = 3 ;
else sprite [ j ] . extra = 1 ;
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 31 :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
j = sector [ sn ] . hitag ;
2008-11-20 14:06:36 +00:00
if ( ActorExtra [ j ] . temp_data [ 4 ] = = 0 )
ActorExtra [ j ] . temp_data [ 4 ] = 1 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
A_CallSound ( sn , ii ) ;
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 26 : //The split doors
2008-11-20 14:06:36 +00:00
i = GetAnimationGoal ( & sptr - > ceilingz ) ;
2006-11-16 03:02:42 +00:00
if ( i = = - 1 ) //if the door has stopped
2006-11-15 01:16:55 +00:00
{
2006-11-16 03:02:42 +00:00
haltsoundhack = 1 ;
sptr - > lotag & = 0xff00 ;
sptr - > lotag | = 22 ;
2008-11-20 14:06:36 +00:00
G_OperateSectors ( sn , ii ) ;
2006-11-16 03:02:42 +00:00
sptr - > lotag & = 0xff00 ;
sptr - > lotag | = 9 ;
2008-11-20 14:06:36 +00:00
G_OperateSectors ( sn , ii ) ;
2006-11-16 03:02:42 +00:00
sptr - > lotag & = 0xff00 ;
sptr - > lotag | = 26 ;
}
return ;
case 9 :
{
2007-12-12 17:42:14 +00:00
int dax , day , dax2 , day2 , sp ;
int wallfind [ 2 ] ;
2006-11-16 03:02:42 +00:00
startwall = sptr - > wallptr ;
endwall = startwall + sptr - > wallnum - 1 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sp = sptr - > extra > > 4 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
//first find center point by averaging all points
dax = 0L , day = 0L ;
for ( i = startwall ; i < = endwall ; i + + )
{
dax + = wall [ i ] . x ;
day + = wall [ i ] . y ;
}
dax / = ( endwall - startwall + 1 ) ;
day / = ( endwall - startwall + 1 ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
//find any points with either same x or same y coordinate
// as center (dax, day) - should be 2 points found.
wallfind [ 0 ] = - 1 ;
wallfind [ 1 ] = - 1 ;
for ( i = startwall ; i < = endwall ; i + + )
if ( ( wall [ i ] . x = = dax ) | | ( wall [ i ] . y = = day ) )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( wallfind [ 0 ] = = - 1 )
wallfind [ 0 ] = i ;
else wallfind [ 1 ] = i ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
for ( j = 0 ; j < 2 ; j + + )
{
if ( ( wall [ wallfind [ j ] ] . x = = dax ) & & ( wall [ wallfind [ j ] ] . y = = day ) )
{
//find what direction door should open by averaging the
// 2 neighboring points of wallfind[0] & wallfind[1].
i = wallfind [ j ] - 1 ;
if ( i < startwall ) i = endwall ;
dax2 = ( ( wall [ i ] . x + wall [ wall [ wallfind [ j ] ] . point2 ] . x ) > > 1 ) - wall [ wallfind [ j ] ] . x ;
day2 = ( ( wall [ i ] . y + wall [ wall [ wallfind [ j ] ] . point2 ] . y ) > > 1 ) - wall [ wallfind [ j ] ] . y ;
if ( dax2 ! = 0 )
2006-11-13 23:12:47 +00:00
{
2006-11-16 03:02:42 +00:00
dax2 = wall [ wall [ wall [ wallfind [ j ] ] . point2 ] . point2 ] . x ;
dax2 - = wall [ wall [ wallfind [ j ] ] . point2 ] . x ;
2008-11-20 14:06:36 +00:00
SetAnimation ( sn , & wall [ wallfind [ j ] ] . x , wall [ wallfind [ j ] ] . x + dax2 , sp ) ;
SetAnimation ( sn , & wall [ i ] . x , wall [ i ] . x + dax2 , sp ) ;
SetAnimation ( sn , & wall [ wall [ wallfind [ j ] ] . point2 ] . x , wall [ wall [ wallfind [ j ] ] . point2 ] . x + dax2 , sp ) ;
A_CallSound ( sn , ii ) ;
2006-11-13 23:12:47 +00:00
}
2006-11-16 03:02:42 +00:00
else if ( day2 ! = 0 )
{
day2 = wall [ wall [ wall [ wallfind [ j ] ] . point2 ] . point2 ] . y ;
day2 - = wall [ wall [ wallfind [ j ] ] . point2 ] . y ;
2008-11-20 14:06:36 +00:00
SetAnimation ( sn , & wall [ wallfind [ j ] ] . y , wall [ wallfind [ j ] ] . y + day2 , sp ) ;
SetAnimation ( sn , & wall [ i ] . y , wall [ i ] . y + day2 , sp ) ;
SetAnimation ( sn , & wall [ wall [ wallfind [ j ] ] . point2 ] . y , wall [ wall [ wallfind [ j ] ] . point2 ] . y + day2 , sp ) ;
A_CallSound ( sn , ii ) ;
2006-11-16 03:02:42 +00:00
}
}
else
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
i = wallfind [ j ] - 1 ;
if ( i < startwall ) i = endwall ;
dax2 = ( ( wall [ i ] . x + wall [ wall [ wallfind [ j ] ] . point2 ] . x ) > > 1 ) - wall [ wallfind [ j ] ] . x ;
day2 = ( ( wall [ i ] . y + wall [ wall [ wallfind [ j ] ] . point2 ] . y ) > > 1 ) - wall [ wallfind [ j ] ] . y ;
if ( dax2 ! = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
SetAnimation ( sn , & wall [ wallfind [ j ] ] . x , dax , sp ) ;
SetAnimation ( sn , & wall [ i ] . x , dax + dax2 , sp ) ;
SetAnimation ( sn , & wall [ wall [ wallfind [ j ] ] . point2 ] . x , dax + dax2 , sp ) ;
A_CallSound ( sn , ii ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
else if ( day2 ! = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
SetAnimation ( sn , & wall [ wallfind [ j ] ] . y , day , sp ) ;
SetAnimation ( sn , & wall [ i ] . y , day + day2 , sp ) ;
SetAnimation ( sn , & wall [ wall [ wallfind [ j ] ] . point2 ] . y , day + day2 , sp ) ;
A_CallSound ( sn , ii ) ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
}
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 15 : //Warping elevators
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sprite [ ii ] . picnum ! = APLAYER ) return ;
// if(ps[sprite[ii].yvel].select_dir == 1) return;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
i = headspritesect [ sn ] ;
while ( i > = 0 )
{
if ( PN = = SECTOREFFECTOR & & SLT = = 17 ) break ;
i = nextspritesect [ i ] ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sprite [ ii ] . sectnum = = sn )
{
2008-11-20 14:06:36 +00:00
if ( G_ActivateWarpElevators ( i , - 1 ) )
G_ActivateWarpElevators ( i , 1 ) ;
else if ( G_ActivateWarpElevators ( i , 1 ) )
G_ActivateWarpElevators ( i , - 1 ) ;
2006-11-15 01:16:55 +00:00
return ;
2006-11-16 03:02:42 +00:00
}
else
{
if ( sptr - > floorz > SZ )
2008-11-20 14:06:36 +00:00
G_ActivateWarpElevators ( i , - 1 ) ;
2006-11-16 03:02:42 +00:00
else
2008-11-20 14:06:36 +00:00
G_ActivateWarpElevators ( i , 1 ) ;
2006-11-16 03:02:42 +00:00
}
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 16 :
case 17 :
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
i = GetAnimationGoal ( & sptr - > floorz ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( i = = - 1 )
{
i = nextsectorneighborz ( sn , sptr - > floorz , 1 , 1 ) ;
2006-11-14 21:35:50 +00:00
if ( i = = - 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
i = nextsectorneighborz ( sn , sptr - > floorz , 1 , - 1 ) ;
if ( i = = - 1 ) return ;
j = sector [ i ] . floorz ;
2008-11-20 14:06:36 +00:00
SetAnimation ( sn , & sptr - > floorz , j , sptr - > extra ) ;
2006-11-16 03:02:42 +00:00
}
else
{
j = sector [ i ] . floorz ;
2008-11-20 14:06:36 +00:00
SetAnimation ( sn , & sptr - > floorz , j , sptr - > extra ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
A_CallSound ( sn , ii ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 18 :
case 19 :
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
i = GetAnimationGoal ( & sptr - > floorz ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( i = = - 1 )
{
i = nextsectorneighborz ( sn , sptr - > floorz , 1 , - 1 ) ;
if ( i = = - 1 ) i = nextsectorneighborz ( sn , sptr - > floorz , 1 , 1 ) ;
if ( i = = - 1 ) return ;
j = sector [ i ] . floorz ;
q = sptr - > extra ;
l = sptr - > ceilingz - sptr - > floorz ;
2008-11-20 14:06:36 +00:00
SetAnimation ( sn , & sptr - > floorz , j , q ) ;
SetAnimation ( sn , & sptr - > ceilingz , j + l , q ) ;
A_CallSound ( sn , ii ) ;
2006-11-16 03:02:42 +00:00
}
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 29 :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sptr - > lotag & 0x8000 )
j = sector [ nextsectorneighborz ( sn , sptr - > ceilingz , 1 , 1 ) ] . floorz ;
else
j = sector [ nextsectorneighborz ( sn , sptr - > ceilingz , - 1 , - 1 ) ] . ceilingz ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
i = headspritestat [ STAT_EFFECTOR ] ; //Effectors
2006-11-16 03:02:42 +00:00
while ( i > = 0 )
{
if ( ( SLT = = 22 ) & &
( SHT = = sptr - > hitag ) )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
sector [ SECT ] . extra = - sector [ SECT ] . extra ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
T1 = sn ;
T2 = 1 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
i = nextspritestat [ i ] ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sptr - > lotag ^ = 0x8000 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
SetAnimation ( sn , & sptr - > ceilingz , j , sptr - > extra ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
A_CallSound ( sn , ii ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 20 :
2006-04-13 20:47:06 +00:00
REDODOOR :
2006-11-16 03:02:42 +00:00
if ( sptr - > lotag & 0x8000 )
{
i = headspritesect [ sn ] ;
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( sprite [ i ] . statnum = = 3 & & SLT = = 9 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
j = SZ ;
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
i = nextspritesect [ i ] ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
if ( i = = - 1 )
j = sptr - > floorz ;
}
else
{
j = nextsectorneighborz ( sn , sptr - > ceilingz , - 1 , - 1 ) ;
if ( j > = 0 ) j = sector [ j ] . ceilingz ;
2006-04-13 20:47:06 +00:00
else
{
2006-11-16 03:02:42 +00:00
sptr - > lotag | = 32768 ;
goto REDODOOR ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sptr - > lotag ^ = 0x8000 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
SetAnimation ( sn , & sptr - > ceilingz , j , sptr - > extra ) ;
A_CallSound ( sn , ii ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 21 :
2008-11-20 14:06:36 +00:00
i = GetAnimationGoal ( & sptr - > floorz ) ;
2006-11-16 03:02:42 +00:00
if ( i > = 0 )
{
if ( animategoal [ sn ] = = sptr - > ceilingz )
animategoal [ i ] = sector [ nextsectorneighborz ( sn , sptr - > ceilingz , 1 , 1 ) ] . floorz ;
else animategoal [ i ] = sptr - > ceilingz ;
j = animategoal [ i ] ;
}
else
{
if ( sptr - > ceilingz = = sptr - > floorz )
j = sector [ nextsectorneighborz ( sn , sptr - > ceilingz , 1 , 1 ) ] . floorz ;
else j = sptr - > ceilingz ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sptr - > lotag ^ = 0x8000 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( SetAnimation ( sn , & sptr - > floorz , j , sptr - > extra ) > = 0 )
A_CallSound ( sn , ii ) ;
2006-11-16 03:02:42 +00:00
}
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 22 :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
// REDODOOR22:
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( ( sptr - > lotag & 0x8000 ) )
{
q = ( sptr - > ceilingz + sptr - > floorz ) > > 1 ;
2008-11-20 14:06:36 +00:00
j = SetAnimation ( sn , & sptr - > floorz , q , sptr - > extra ) ;
j = SetAnimation ( sn , & sptr - > ceilingz , q , sptr - > extra ) ;
2006-11-16 03:02:42 +00:00
}
else
{
q = sector [ nextsectorneighborz ( sn , sptr - > floorz , 1 , 1 ) ] . floorz ;
2008-11-20 14:06:36 +00:00
j = SetAnimation ( sn , & sptr - > floorz , q , sptr - > extra ) ;
2006-11-16 03:02:42 +00:00
q = sector [ nextsectorneighborz ( sn , sptr - > ceilingz , - 1 , - 1 ) ] . ceilingz ;
2008-11-20 14:06:36 +00:00
j = SetAnimation ( sn , & sptr - > ceilingz , q , sptr - > extra ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sptr - > lotag ^ = 0x8000 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
A_CallSound ( sn , ii ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 23 : //Swingdoor
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
j = - 1 ;
q = 0 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
i = headspritestat [ STAT_EFFECTOR ] ;
2006-11-16 03:02:42 +00:00
while ( i > = 0 )
{
if ( SLT = = 11 & & SECT = = sn & & ! T5 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
j = i ;
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
i = nextspritestat [ i ] ;
}
if ( i < 0 )
{
OSD_Printf ( " WARNING: SE23 i<0! \n " ) ;
return ;
} // JBF
l = sector [ SECT ] . lotag & 0x8000 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j > = 0 )
{
2008-11-20 14:06:36 +00:00
i = headspritestat [ STAT_EFFECTOR ] ;
2006-11-16 03:02:42 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( l = = ( sector [ SECT ] . lotag & 0x8000 ) & & SLT = = 11 & & sprite [ j ] . hitag = = SHT & & ! T5 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( sector [ SECT ] . lotag & 0x8000 ) sector [ SECT ] . lotag & = 0x7fff ;
else sector [ SECT ] . lotag | = 0x8000 ;
T5 = 1 ;
T4 = - T4 ;
if ( q = = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
A_CallSound ( sn , i ) ;
2006-11-16 03:02:42 +00:00
q = 1 ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-16 03:02:42 +00:00
i = nextspritestat [ i ] ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 25 : //Subway type sliding doors
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
j = headspritestat [ STAT_EFFECTOR ] ;
2006-11-16 03:02:42 +00:00
while ( j > = 0 ) //Find the sprite
{
if ( ( sprite [ j ] . lotag ) = = 15 & & sprite [ j ] . sectnum = = sn )
break ; //Found the sectoreffector.
j = nextspritestat [ j ] ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j < 0 )
return ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
i = headspritestat [ STAT_EFFECTOR ] ;
2006-11-16 03:02:42 +00:00
while ( i > = 0 )
{
if ( SHT = = sprite [ j ] . hitag )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( SLT = = 15 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
sector [ SECT ] . lotag ^ = 0x8000 ; // Toggle the open or close
SA + = 1024 ;
2008-11-20 14:06:36 +00:00
if ( T5 ) A_CallSound ( SECT , i ) ;
A_CallSound ( SECT , i ) ;
2006-11-16 03:02:42 +00:00
if ( sector [ SECT ] . lotag & 0x8000 ) T5 = 1 ;
else T5 = 2 ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-16 03:02:42 +00:00
i = nextspritestat [ i ] ;
}
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 27 : //Extended bridge
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
j = headspritestat [ STAT_EFFECTOR ] ;
2006-11-16 03:02:42 +00:00
while ( j > = 0 )
{
if ( ( sprite [ j ] . lotag & 0xff ) = = 20 & & sprite [ j ] . sectnum = = sn ) //Bridge
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
sector [ sn ] . lotag ^ = 0x8000 ;
if ( sector [ sn ] . lotag & 0x8000 ) //OPENING
2008-11-20 14:06:36 +00:00
ActorExtra [ j ] . temp_data [ 0 ] = 1 ;
else ActorExtra [ j ] . temp_data [ 0 ] = 2 ;
A_CallSound ( sn , ii ) ;
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
j = nextspritestat [ j ] ;
}
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 28 :
//activate the rest of them
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
j = headspritesect [ sn ] ;
while ( j > = 0 )
{
if ( sprite [ j ] . statnum = = 3 & & ( sprite [ j ] . lotag & 0xff ) = = 21 )
break ; //Found it
j = nextspritesect [ j ] ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
j = sprite [ j ] . hitag ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
l = headspritestat [ STAT_EFFECTOR ] ;
2006-11-16 03:02:42 +00:00
while ( l > = 0 )
{
2008-11-20 14:06:36 +00:00
if ( ( sprite [ l ] . lotag & 0xff ) = = 21 & & ! ActorExtra [ l ] . temp_data [ 0 ] & &
2006-11-16 03:02:42 +00:00
( sprite [ l ] . hitag ) = = j )
2008-11-20 14:06:36 +00:00
ActorExtra [ l ] . temp_data [ 0 ] = 1 ;
2006-11-16 03:02:42 +00:00
l = nextspritestat [ l ] ;
}
2008-11-20 14:06:36 +00:00
A_CallSound ( sn , ii ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
void G_OperateRespawns ( int low )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
int j , nexti , i = headspritestat [ STAT_FX ] ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
nexti = nextspritestat [ i ] ;
if ( ( SLT = = low ) & & ( PN = = RESPAWN ) )
{
2008-11-20 14:06:36 +00:00
if ( A_CheckEnemyTile ( SHT ) & & ud . monsters_off ) break ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
j = A_Spawn ( i , TRANSPORTERSTAR ) ;
2006-04-13 20:47:06 +00:00
sprite [ j ] . z - = ( 32 < < 8 ) ;
sprite [ i ] . extra = 66 - 12 ; // Just a way to killit
}
i = nexti ;
}
}
2008-11-20 14:06:36 +00:00
void G_OperateActivators ( int low , int snum )
2006-04-13 20:47:06 +00:00
{
2006-12-20 03:27:25 +00:00
int i , j , k ;
short * p ;
2006-04-13 20:47:06 +00:00
walltype * wal ;
2008-11-20 14:06:36 +00:00
for ( i = g_numCyclers - 1 ; i > = 0 ; i - - )
2006-04-13 20:47:06 +00:00
{
p = & cyclers [ i ] [ 0 ] ;
2006-11-13 23:12:47 +00:00
if ( p [ 4 ] = = low )
2006-04-13 20:47:06 +00:00
{
p [ 5 ] = ! p [ 5 ] ;
sector [ p [ 0 ] ] . floorshade = sector [ p [ 0 ] ] . ceilingshade = p [ 3 ] ;
wal = & wall [ sector [ p [ 0 ] ] . wallptr ] ;
2006-11-13 23:12:47 +00:00
for ( j = sector [ p [ 0 ] ] . wallnum ; j > 0 ; j - - , wal + + )
2006-04-13 20:47:06 +00:00
wal - > shade = p [ 3 ] ;
}
}
2008-11-20 14:06:36 +00:00
i = headspritestat [ STAT_ACTIVATOR ] ;
2006-04-13 20:47:06 +00:00
k = - 1 ;
2006-11-13 23:12:47 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sprite [ i ] . lotag = = low )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( sprite [ i ] . picnum = = ACTIVATORLOCKED )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sector [ SECT ] . lotag & 16384 )
2006-04-13 20:47:06 +00:00
sector [ SECT ] . lotag & = 65535 - 16384 ;
else
sector [ SECT ] . lotag | = 16384 ;
2007-08-31 06:18:56 +00:00
if ( snum > = 0 & & snum < ud . multimode )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( sector [ SECT ] . lotag & 16384 )
2008-11-20 14:06:36 +00:00
P_DoQuote ( 4 , g_player [ snum ] . ps ) ;
else P_DoQuote ( 8 , g_player [ snum ] . ps ) ;
2006-04-13 20:47:06 +00:00
}
}
else
{
2006-11-13 23:12:47 +00:00
switch ( SHT )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
break ;
case 1 :
if ( sector [ SECT ] . floorz ! = sector [ SECT ] . ceilingz )
{
i = nextspritestat [ i ] ;
continue ;
}
break ;
case 2 :
if ( sector [ SECT ] . floorz = = sector [ SECT ] . ceilingz )
{
i = nextspritestat [ i ] ;
continue ;
}
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
if ( sector [ sprite [ i ] . sectnum ] . lotag < 3 )
2006-04-13 20:47:06 +00:00
{
j = headspritesect [ sprite [ i ] . sectnum ] ;
2006-11-13 23:12:47 +00:00
while ( j > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( sprite [ j ] . statnum = = 3 ) switch ( sprite [ j ] . lotag )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 36 :
case 31 :
case 32 :
case 18 :
2008-11-20 14:06:36 +00:00
ActorExtra [ j ] . temp_data [ 0 ] = 1 - ActorExtra [ j ] . temp_data [ 0 ] ;
A_CallSound ( SECT , j ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
j = nextspritesect [ j ] ;
}
}
2006-11-14 21:35:50 +00:00
if ( k = = - 1 & & ( sector [ SECT ] . lotag & 0xff ) = = 22 )
2008-11-20 14:06:36 +00:00
k = A_CallSound ( SECT , i ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
G_OperateSectors ( SECT , i ) ;
2006-04-13 20:47:06 +00:00
}
}
i = nextspritestat [ i ] ;
}
2008-11-20 14:06:36 +00:00
G_OperateRespawns ( low ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
void G_OperateMasterSwitches ( int low )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
int i = headspritestat [ STAT_STANDABLE ] ;
2006-11-13 23:12:47 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( PN = = MASTERSWITCH & & SLT = = low & & SP = = 0 )
2006-04-13 20:47:06 +00:00
SP = 1 ;
i = nextspritestat [ i ] ;
}
}
2008-11-20 14:06:36 +00:00
void G_OperateForceFields ( int s , int low )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
int i , p = g_numAnimWalls ;
2006-04-13 20:47:06 +00:00
2008-02-06 11:42:34 +00:00
for ( ; p > = 0 ; p - - )
2006-04-13 20:47:06 +00:00
{
i = animwall [ p ] . wallnum ;
2006-11-13 23:12:47 +00:00
if ( low = = wall [ i ] . lotag | | low = = - 1 )
2006-11-15 01:16:55 +00:00
if ( ( ( wall [ i ] . overpicnum > = W_FORCEFIELD ) & & ( wall [ i ] . overpicnum < = W_FORCEFIELD + 2 ) ) | | ( wall [ i ] . overpicnum = = BIGFORCE ) )
{
2006-04-13 20:47:06 +00:00
animwall [ p ] . tag = 0 ;
2006-11-14 21:35:50 +00:00
if ( wall [ i ] . cstat )
2006-04-13 20:47:06 +00:00
{
wall [ i ] . cstat = 0 ;
2006-11-14 21:35:50 +00:00
if ( s > = 0 & & sprite [ s ] . picnum = = SECTOREFFECTOR & &
2006-04-13 20:47:06 +00:00
sprite [ s ] . lotag = = 30 )
wall [ i ] . lotag = 0 ;
}
else
wall [ i ] . cstat = 85 ;
}
}
}
2008-11-20 14:06:36 +00:00
int P_ActivateSwitch ( int snum , int w , int switchtype )
2006-04-13 20:47:06 +00:00
{
2006-12-23 02:38:47 +00:00
int switchpal , switchpicnum ;
2008-02-06 11:42:34 +00:00
int i , x , lotag , hitag , picnum , correctdips = 1 , numdips = 0 ;
2007-12-12 17:42:14 +00:00
int sx , sy ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( w < 0 ) return 0 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( switchtype = = 1 ) // A wall sprite
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
lotag = sprite [ w ] . lotag ;
if ( lotag = = 0 ) return 0 ;
2006-04-13 20:47:06 +00:00
hitag = sprite [ w ] . hitag ;
sx = sprite [ w ] . x ;
sy = sprite [ w ] . y ;
picnum = sprite [ w ] . picnum ;
switchpal = sprite [ w ] . pal ;
}
else
{
2006-11-15 01:16:55 +00:00
lotag = wall [ w ] . lotag ;
if ( lotag = = 0 ) return 0 ;
2006-04-13 20:47:06 +00:00
hitag = wall [ w ] . hitag ;
sx = wall [ w ] . x ;
sy = wall [ w ] . y ;
picnum = wall [ w ] . picnum ;
switchpal = wall [ w ] . pal ;
}
2008-11-20 14:06:36 +00:00
// initprintf("P_ActivateSwitch called picnum=%i switchtype=%i\n",picnum,switchtype);
2006-04-13 20:47:06 +00:00
switchpicnum = picnum ;
2006-11-14 21:35:50 +00:00
if ( ( picnum = = DIPSWITCH + 1 )
2006-04-13 20:47:06 +00:00
| | ( picnum = = TECHSWITCH + 1 )
| | ( picnum = = ALIENSWITCH + 1 )
| | ( picnum = = DIPSWITCH2 + 1 )
| | ( picnum = = DIPSWITCH3 + 1 )
| | ( picnum = = PULLSWITCH + 1 )
| | ( picnum = = HANDSWITCH + 1 )
| | ( picnum = = SLOTDOOR + 1 )
| | ( picnum = = LIGHTSWITCH + 1 )
| | ( picnum = = SPACELIGHTSWITCH + 1 )
| | ( picnum = = SPACEDOORSWITCH + 1 )
| | ( picnum = = FRANKENSTINESWITCH + 1 )
| | ( picnum = = LIGHTSWITCH2 + 1 )
| | ( picnum = = POWERSWITCH1 + 1 )
| | ( picnum = = LOCKSWITCH1 + 1 )
| | ( picnum = = POWERSWITCH2 + 1 )
| | ( picnum = = LIGHTSWITCH + 1 )
2006-11-15 01:16:55 +00:00
)
{
2006-04-13 20:47:06 +00:00
switchpicnum - - ;
}
2006-11-15 01:16:55 +00:00
if ( ( picnum > MULTISWITCH ) & & ( picnum < = MULTISWITCH + 3 ) )
{
2006-04-13 20:47:06 +00:00
switchpicnum = MULTISWITCH ;
}
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ switchpicnum ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case DIPSWITCH__STATIC :
// case DIPSWITCH+1:
case TECHSWITCH__STATIC :
// case TECHSWITCH+1:
case ALIENSWITCH__STATIC :
// case ALIENSWITCH+1:
break ;
case ACCESSSWITCH__STATIC :
case ACCESSSWITCH2__STATIC :
2007-08-27 06:46:31 +00:00
if ( g_player [ snum ] . ps - > access_incs = = 0 )
2006-11-16 03:02:42 +00:00
{
if ( switchpal = = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( ( g_player [ snum ] . ps - > got_access & 1 ) )
g_player [ snum ] . ps - > access_incs = 1 ;
2008-11-20 14:06:36 +00:00
else P_DoQuote ( 70 , g_player [ snum ] . ps ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
else if ( switchpal = = 21 )
{
2007-08-27 06:46:31 +00:00
if ( g_player [ snum ] . ps - > got_access & 2 )
g_player [ snum ] . ps - > access_incs = 1 ;
2008-11-20 14:06:36 +00:00
else P_DoQuote ( 71 , g_player [ snum ] . ps ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
else if ( switchpal = = 23 )
{
2007-08-27 06:46:31 +00:00
if ( g_player [ snum ] . ps - > got_access & 4 )
g_player [ snum ] . ps - > access_incs = 1 ;
2008-11-20 14:06:36 +00:00
else P_DoQuote ( 72 , g_player [ snum ] . ps ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2007-08-27 06:46:31 +00:00
if ( g_player [ snum ] . ps - > access_incs = = 1 )
2006-11-16 03:02:42 +00:00
{
if ( switchtype = = 0 )
2007-08-27 06:46:31 +00:00
g_player [ snum ] . ps - > access_wallnum = w ;
2006-11-16 03:02:42 +00:00
else
2007-08-27 06:46:31 +00:00
g_player [ snum ] . ps - > access_spritenum = w ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
return 0 ;
}
case DIPSWITCH2__STATIC :
//case DIPSWITCH2+1:
case DIPSWITCH3__STATIC :
//case DIPSWITCH3+1:
case MULTISWITCH__STATIC :
//case MULTISWITCH+1:
//case MULTISWITCH+2:
//case MULTISWITCH+3:
case PULLSWITCH__STATIC :
//case PULLSWITCH+1:
case HANDSWITCH__STATIC :
//case HANDSWITCH+1:
case SLOTDOOR__STATIC :
//case SLOTDOOR+1:
case LIGHTSWITCH__STATIC :
//case LIGHTSWITCH+1:
case SPACELIGHTSWITCH__STATIC :
//case SPACELIGHTSWITCH+1:
case SPACEDOORSWITCH__STATIC :
//case SPACEDOORSWITCH+1:
case FRANKENSTINESWITCH__STATIC :
//case FRANKENSTINESWITCH+1:
case LIGHTSWITCH2__STATIC :
//case LIGHTSWITCH2+1:
case POWERSWITCH1__STATIC :
//case POWERSWITCH1+1:
case LOCKSWITCH1__STATIC :
//case LOCKSWITCH1+1:
case POWERSWITCH2__STATIC :
//case POWERSWITCH2+1:
if ( check_activator_motion ( lotag ) ) return 0 ;
break ;
default :
2008-11-20 14:06:36 +00:00
if ( CheckDoorTile ( picnum ) = = 0 ) return 0 ;
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
i = headspritestat [ STAT_DEFAULT ] ;
2006-11-13 23:12:47 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-15 01:16:55 +00:00
if ( lotag = = SLT )
{
2006-04-13 20:47:06 +00:00
int switchpicnum = PN ; // put it in a variable so later switches don't trigger on the result of changes
2006-11-15 01:16:55 +00:00
if ( ( switchpicnum > = MULTISWITCH ) & & ( switchpicnum < = MULTISWITCH + 3 ) )
{
2006-04-13 20:47:06 +00:00
sprite [ i ] . picnum + + ;
2006-11-14 21:35:50 +00:00
if ( sprite [ i ] . picnum > ( MULTISWITCH + 3 ) )
2006-04-13 20:47:06 +00:00
sprite [ i ] . picnum = MULTISWITCH ;
}
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ switchpicnum ] )
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 DIPSWITCH__STATIC :
case TECHSWITCH__STATIC :
case ALIENSWITCH__STATIC :
if ( switchtype = = 1 & & w = = i ) PN + + ;
else if ( SHT = = 0 ) correctdips + + ;
numdips + + ;
break ;
case ACCESSSWITCH__STATIC :
case ACCESSSWITCH2__STATIC :
case SLOTDOOR__STATIC :
case LIGHTSWITCH__STATIC :
case SPACELIGHTSWITCH__STATIC :
case SPACEDOORSWITCH__STATIC :
case FRANKENSTINESWITCH__STATIC :
case LIGHTSWITCH2__STATIC :
case POWERSWITCH1__STATIC :
case LOCKSWITCH1__STATIC :
case POWERSWITCH2__STATIC :
case HANDSWITCH__STATIC :
case PULLSWITCH__STATIC :
case DIPSWITCH2__STATIC :
case DIPSWITCH3__STATIC :
sprite [ i ] . picnum + + ;
break ;
default :
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ switchpicnum - 1 ] )
2006-11-16 03:02:42 +00:00
{
2006-11-15 01:16:55 +00:00
case TECHSWITCH__STATIC :
2006-11-16 03:02:42 +00:00
case DIPSWITCH__STATIC :
2006-04-13 20:47:06 +00:00
case ALIENSWITCH__STATIC :
2006-11-16 03:02:42 +00:00
if ( switchtype = = 1 & & w = = i ) PN - - ;
else if ( SHT = = 1 ) correctdips + + ;
2006-04-13 20:47:06 +00:00
numdips + + ;
break ;
2006-11-16 03:02:42 +00:00
case PULLSWITCH__STATIC :
case HANDSWITCH__STATIC :
case LIGHTSWITCH2__STATIC :
case POWERSWITCH1__STATIC :
case LOCKSWITCH1__STATIC :
case POWERSWITCH2__STATIC :
2006-04-13 20:47:06 +00:00
case SLOTDOOR__STATIC :
case LIGHTSWITCH__STATIC :
case SPACELIGHTSWITCH__STATIC :
case SPACEDOORSWITCH__STATIC :
case FRANKENSTINESWITCH__STATIC :
case DIPSWITCH2__STATIC :
case DIPSWITCH3__STATIC :
2006-11-16 03:02:42 +00:00
sprite [ i ] . picnum - - ;
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
}
}
i = nextspritestat [ i ] ;
}
2008-08-24 09:29:03 +00:00
for ( i = numwalls - 1 ; i > = 0 ; i - - )
2006-04-13 20:47:06 +00:00
{
x = i ;
2006-11-15 01:16:55 +00:00
if ( lotag = = wall [ x ] . lotag )
{
if ( ( wall [ x ] . picnum > = MULTISWITCH ) & & ( wall [ x ] . picnum < = MULTISWITCH + 3 ) )
{
2006-04-13 20:47:06 +00:00
wall [ x ] . picnum + + ;
2006-11-14 21:35:50 +00:00
if ( wall [ x ] . picnum > ( MULTISWITCH + 3 ) )
2006-04-13 20:47:06 +00:00
wall [ x ] . picnum = MULTISWITCH ;
}
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ wall [ x ] . picnum ] )
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 DIPSWITCH__STATIC :
case TECHSWITCH__STATIC :
case ALIENSWITCH__STATIC :
if ( switchtype = = 0 & & i = = w ) wall [ x ] . picnum + + ;
else if ( wall [ x ] . hitag = = 0 ) correctdips + + ;
numdips + + ;
break ;
case ACCESSSWITCH__STATIC :
case ACCESSSWITCH2__STATIC :
case SLOTDOOR__STATIC :
case LIGHTSWITCH__STATIC :
case SPACELIGHTSWITCH__STATIC :
case SPACEDOORSWITCH__STATIC :
case FRANKENSTINESWITCH__STATIC :
case LIGHTSWITCH2__STATIC :
case POWERSWITCH1__STATIC :
case LOCKSWITCH1__STATIC :
case POWERSWITCH2__STATIC :
case HANDSWITCH__STATIC :
case PULLSWITCH__STATIC :
case DIPSWITCH2__STATIC :
case DIPSWITCH3__STATIC :
wall [ x ] . picnum + + ;
break ;
default :
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ wall [ x ] . picnum - 1 ] )
2006-11-16 03:02:42 +00:00
{
2006-11-15 01:16:55 +00:00
case TECHSWITCH__STATIC :
2006-11-16 03:02:42 +00:00
case DIPSWITCH__STATIC :
2006-04-13 20:47:06 +00:00
case ALIENSWITCH__STATIC :
2006-11-16 03:02:42 +00:00
if ( switchtype = = 0 & & i = = w ) wall [ x ] . picnum - - ;
else if ( wall [ x ] . hitag = = 1 ) correctdips + + ;
2006-04-13 20:47:06 +00:00
numdips + + ;
break ;
2006-11-16 03:02:42 +00:00
case PULLSWITCH__STATIC :
case HANDSWITCH__STATIC :
case LIGHTSWITCH2__STATIC :
case POWERSWITCH1__STATIC :
case LOCKSWITCH1__STATIC :
case POWERSWITCH2__STATIC :
2006-04-13 20:47:06 +00:00
case SLOTDOOR__STATIC :
case LIGHTSWITCH__STATIC :
case SPACELIGHTSWITCH__STATIC :
case SPACEDOORSWITCH__STATIC :
case FRANKENSTINESWITCH__STATIC :
case DIPSWITCH2__STATIC :
case DIPSWITCH3__STATIC :
2006-11-16 03:02:42 +00:00
wall [ x ] . picnum - - ;
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-13 23:12:47 +00:00
if ( lotag = = ( short ) 65535 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ myconnectindex ] . ps - > gm = MODE_EOL ;
2006-11-13 23:12:47 +00:00
if ( ud . from_bonus )
2006-04-13 20:47:06 +00:00
{
ud . level_number = ud . from_bonus ;
ud . m_level_number = ud . level_number ;
ud . from_bonus = 0 ;
}
else
{
ud . level_number + + ;
2006-12-17 03:21:55 +00:00
if ( ud . level_number > MAXLEVELS - 1 )
2006-04-13 20:47:06 +00:00
ud . level_number = 0 ;
ud . m_level_number = ud . level_number ;
}
return 1 ;
}
switchpicnum = picnum ;
2006-11-14 21:35:50 +00:00
if ( ( picnum = = DIPSWITCH + 1 )
2006-04-13 20:47:06 +00:00
| | ( picnum = = TECHSWITCH + 1 )
| | ( picnum = = ALIENSWITCH + 1 )
| | ( picnum = = DIPSWITCH2 + 1 )
| | ( picnum = = DIPSWITCH3 + 1 )
| | ( picnum = = PULLSWITCH + 1 )
| | ( picnum = = HANDSWITCH + 1 )
| | ( picnum = = SLOTDOOR + 1 )
| | ( picnum = = LIGHTSWITCH + 1 )
| | ( picnum = = SPACELIGHTSWITCH + 1 )
| | ( picnum = = SPACEDOORSWITCH + 1 )
| | ( picnum = = FRANKENSTINESWITCH + 1 )
| | ( picnum = = LIGHTSWITCH2 + 1 )
| | ( picnum = = POWERSWITCH1 + 1 )
| | ( picnum = = LOCKSWITCH1 + 1 )
| | ( picnum = = POWERSWITCH2 + 1 )
| | ( picnum = = LIGHTSWITCH + 1 )
2006-11-15 01:16:55 +00:00
)
{
2006-04-13 20:47:06 +00:00
switchpicnum - - ;
}
2006-11-15 01:16:55 +00:00
if ( ( picnum > MULTISWITCH ) & & ( picnum < = MULTISWITCH + 3 ) )
{
2006-04-13 20:47:06 +00:00
switchpicnum = MULTISWITCH ;
}
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ switchpicnum ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
default :
2008-11-20 14:06:36 +00:00
if ( CheckDoorTile ( picnum ) = = 0 ) break ;
2006-11-16 03:02:42 +00:00
case DIPSWITCH__STATIC :
//case DIPSWITCH+1:
case TECHSWITCH__STATIC :
//case TECHSWITCH+1:
case ALIENSWITCH__STATIC :
//case ALIENSWITCH+1:
if ( picnum = = DIPSWITCH | | picnum = = DIPSWITCH + 1 | |
picnum = = ALIENSWITCH | | picnum = = ALIENSWITCH + 1 | |
picnum = = TECHSWITCH | | picnum = = TECHSWITCH + 1 )
{
if ( picnum = = ALIENSWITCH | | picnum = = ALIENSWITCH + 1 )
{
if ( switchtype = = 1 )
2008-11-20 14:06:36 +00:00
S_PlaySoundXYZ ( ALIEN_SWITCH1 , w , sx , sy , g_player [ snum ] . ps - > posz ) ;
else S_PlaySoundXYZ ( ALIEN_SWITCH1 , g_player [ snum ] . ps - > i , sx , sy , g_player [ snum ] . ps - > posz ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
else
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( switchtype = = 1 )
2008-11-20 14:06:36 +00:00
S_PlaySoundXYZ ( SWITCH_ON , w , sx , sy , g_player [ snum ] . ps - > posz ) ;
else S_PlaySoundXYZ ( SWITCH_ON , g_player [ snum ] . ps - > i , sx , sy , g_player [ snum ] . ps - > posz ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
if ( numdips ! = correctdips ) break ;
2008-11-20 14:06:36 +00:00
S_PlaySoundXYZ ( END_OF_LEVEL_WARN , g_player [ snum ] . ps - > i , sx , sy , g_player [ snum ] . ps - > posz ) ;
2006-11-16 03:02:42 +00:00
}
case DIPSWITCH2__STATIC :
//case DIPSWITCH2+1:
case DIPSWITCH3__STATIC :
//case DIPSWITCH3+1:
case MULTISWITCH__STATIC :
//case MULTISWITCH+1:
//case MULTISWITCH+2:
//case MULTISWITCH+3:
case ACCESSSWITCH__STATIC :
case ACCESSSWITCH2__STATIC :
case SLOTDOOR__STATIC :
//case SLOTDOOR+1:
case LIGHTSWITCH__STATIC :
//case LIGHTSWITCH+1:
case SPACELIGHTSWITCH__STATIC :
//case SPACELIGHTSWITCH+1:
case SPACEDOORSWITCH__STATIC :
//case SPACEDOORSWITCH+1:
case FRANKENSTINESWITCH__STATIC :
//case FRANKENSTINESWITCH+1:
case LIGHTSWITCH2__STATIC :
//case LIGHTSWITCH2+1:
case POWERSWITCH1__STATIC :
//case POWERSWITCH1+1:
case LOCKSWITCH1__STATIC :
//case LOCKSWITCH1+1:
case POWERSWITCH2__STATIC :
//case POWERSWITCH2+1:
case HANDSWITCH__STATIC :
//case HANDSWITCH+1:
case PULLSWITCH__STATIC :
//case PULLSWITCH+1:
if ( picnum = = MULTISWITCH | | picnum = = ( MULTISWITCH + 1 ) | |
picnum = = ( MULTISWITCH + 2 ) | | picnum = = ( MULTISWITCH + 3 ) )
lotag + = picnum - MULTISWITCH ;
2008-11-20 14:06:36 +00:00
x = headspritestat [ STAT_EFFECTOR ] ;
2006-11-16 03:02:42 +00:00
while ( x > = 0 )
{
if ( ( ( sprite [ x ] . hitag ) = = lotag ) )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
switch ( sprite [ x ] . lotag )
{
case 12 :
sector [ sprite [ x ] . sectnum ] . floorpal = 0 ;
2008-11-20 14:06:36 +00:00
ActorExtra [ x ] . temp_data [ 0 ] + + ;
if ( ActorExtra [ x ] . temp_data [ 0 ] = = 2 )
ActorExtra [ x ] . temp_data [ 0 ] + + ;
2006-11-16 03:02:42 +00:00
break ;
case 24 :
case 34 :
case 25 :
2008-11-20 14:06:36 +00:00
ActorExtra [ x ] . temp_data [ 4 ] = ! ActorExtra [ x ] . temp_data [ 4 ] ;
if ( ActorExtra [ x ] . temp_data [ 4 ] )
P_DoQuote ( 15 , g_player [ snum ] . ps ) ;
else P_DoQuote ( 2 , g_player [ snum ] . ps ) ;
2006-11-16 03:02:42 +00:00
break ;
case 21 :
2008-11-20 14:06:36 +00:00
P_DoQuote ( 2 , g_player [ screenpeek ] . ps ) ;
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
x = nextspritestat [ x ] ;
}
2008-11-20 14:06:36 +00:00
G_OperateActivators ( lotag , snum ) ;
G_OperateForceFields ( g_player [ snum ] . ps - > i , lotag ) ;
G_OperateMasterSwitches ( lotag ) ;
2006-11-16 03:02:42 +00:00
if ( picnum = = DIPSWITCH | | picnum = = DIPSWITCH + 1 | |
picnum = = ALIENSWITCH | | picnum = = ALIENSWITCH + 1 | |
picnum = = TECHSWITCH | | picnum = = TECHSWITCH + 1 ) return 1 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( hitag = = 0 & & CheckDoorTile ( picnum ) = = 0 )
2006-11-16 03:02:42 +00:00
{
if ( switchtype = = 1 )
2008-11-20 14:06:36 +00:00
S_PlaySoundXYZ ( SWITCH_ON , w , sx , sy , g_player [ snum ] . ps - > posz ) ;
else S_PlaySoundXYZ ( SWITCH_ON , g_player [ snum ] . ps - > i , sx , sy , g_player [ snum ] . ps - > posz ) ;
2006-11-16 03:02:42 +00:00
}
else if ( hitag ! = 0 )
{
2007-09-11 05:26:38 +00:00
if ( switchtype = = 1 & & ( g_sounds [ hitag ] . m & 4 ) = = 0 )
2008-11-20 14:06:36 +00:00
S_PlaySoundXYZ ( hitag , w , sx , sy , g_player [ snum ] . ps - > posz ) ;
else A_PlaySound ( hitag , g_player [ snum ] . ps - > i ) ;
2006-11-16 03:02:42 +00:00
}
return 1 ;
2006-04-13 20:47:06 +00:00
}
return 0 ;
}
2007-02-28 09:12:41 +00:00
void activatebysector ( int sect , int j )
2006-04-13 20:47:06 +00:00
{
2006-12-20 03:27:25 +00:00
int i = headspritesect [ sect ] ;
int didit = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( PN = = ACTIVATOR )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
G_OperateActivators ( SLT , - 1 ) ;
2006-04-13 20:47:06 +00:00
didit = 1 ;
// return;
}
i = nextspritesect [ i ] ;
}
2006-11-13 23:12:47 +00:00
if ( didit = = 0 )
2008-11-20 14:06:36 +00:00
G_OperateSectors ( sect , j ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
static void BreakWall ( int newpn , int spr , int dawallnum )
2006-04-13 20:47:06 +00:00
{
wall [ dawallnum ] . picnum = newpn ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( VENT_BUST , spr ) ;
A_PlaySound ( GLASS_HEAVYBREAK , spr ) ;
A_SpawnWallGlass ( spr , dawallnum , 10 ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
void A_DamageWall ( int spr , int dawallnum , int x , int y , int z , int atwith )
2006-04-13 20:47:06 +00:00
{
2007-02-28 09:12:41 +00:00
short sn = - 1 ;
int j , i , darkestwall ;
2008-02-06 11:42:34 +00:00
walltype * wal = & wall [ dawallnum ] ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( wal - > overpicnum = = MIRROR & & wal - > pal ! = 4 & & A_CheckSpriteTileFlags ( atwith , SPRITE_PROJECTILE ) & & ( ActorExtra [ spr ] . projectile . workslike & PROJECTILE_RPG ) )
2006-04-13 20:47:06 +00:00
{
2008-10-11 09:20:04 +00:00
if ( wal - > nextwall = = - 1 | | wall [ wal - > nextwall ] . pal ! = 4 )
{
2008-11-20 14:06:36 +00:00
A_SpawnWallGlass ( spr , dawallnum , 70 ) ;
2008-10-11 09:20:04 +00:00
wal - > cstat & = ~ 16 ;
wal - > overpicnum = MIRRORBROKE ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( GLASS_HEAVYBREAK , spr ) ;
2008-10-11 09:20:04 +00:00
return ;
}
2006-04-13 20:47:06 +00:00
}
2008-10-11 09:20:04 +00:00
if ( wal - > overpicnum = = MIRROR & & wal - > pal ! = 4 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ atwith ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case HEAVYHBOMB__STATIC :
case RADIUSEXPLOSION__STATIC :
case RPG__STATIC :
case HYDRENT__STATIC :
case SEENINE__STATIC :
case OOZFILTER__STATIC :
case EXPLODINGBARREL__STATIC :
2008-10-13 01:16:40 +00:00
if ( wal - > nextwall = = - 1 | | wall [ wal - > nextwall ] . pal ! = 4 )
{
2008-11-20 14:06:36 +00:00
A_SpawnWallGlass ( spr , dawallnum , 70 ) ;
2008-10-13 01:16:40 +00:00
wal - > cstat & = ~ 16 ;
wal - > overpicnum = MIRRORBROKE ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( GLASS_HEAVYBREAK , spr ) ;
2008-10-13 01:16:40 +00:00
return ;
}
2006-04-13 20:47:06 +00:00
}
}
2006-11-14 21:35:50 +00:00
if ( ( ( wal - > cstat & 16 ) | | wal - > overpicnum = = BIGFORCE ) & & wal - > nextsector > = 0 )
if ( sector [ wal - > nextsector ] . floorz > z )
if ( sector [ wal - > nextsector ] . floorz - sector [ wal - > nextsector ] . ceilingz )
2006-04-13 20:47:06 +00:00
{
int switchpicnum = wal - > overpicnum ;
if ( ( switchpicnum > W_FORCEFIELD ) & & ( switchpicnum < = W_FORCEFIELD + 2 ) )
switchpicnum = W_FORCEFIELD ;
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ switchpicnum ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case W_FORCEFIELD__STATIC :
//case W_FORCEFIELD+1:
//case W_FORCEFIELD+2:
wal - > extra = 1 ; // tell the forces to animate
case BIGFORCE__STATIC :
2006-12-02 06:00:49 +00:00
updatesector ( x , y , & sn ) ;
2006-11-16 03:02:42 +00:00
if ( sn < 0 ) return ;
if ( atwith = = - 1 )
2008-11-20 14:06:36 +00:00
i = A_InsertSprite ( sn , x , y , z , FORCERIPPLE , - 127 , 8 , 8 , 0 , 0 , 0 , spr , 5 ) ;
2006-11-16 03:02:42 +00:00
else
{
if ( atwith = = CHAINGUN )
2008-11-20 14:06:36 +00:00
i = A_InsertSprite ( sn , x , y , z , FORCERIPPLE , - 127 , 16 + sprite [ spr ] . xrepeat , 16 + sprite [ spr ] . yrepeat , 0 , 0 , 0 , spr , 5 ) ;
else i = A_InsertSprite ( sn , x , y , z , FORCERIPPLE , - 127 , 32 , 32 , 0 , 0 , 0 , spr , 5 ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
CS | = 18 + 128 ;
SA = getangle ( wal - > x - wall [ wal - > point2 ] . x ,
wal - > y - wall [ wal - > point2 ] . y ) - 512 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
A_PlaySound ( SOMETHINGHITFORCE , i ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case FANSPRITE__STATIC :
wal - > overpicnum = FANSPRITEBROKE ;
wal - > cstat & = 65535 - 65 ;
if ( wal - > nextwall > = 0 )
{
wall [ wal - > nextwall ] . overpicnum = FANSPRITEBROKE ;
wall [ wal - > nextwall ] . cstat & = 65535 - 65 ;
}
2008-11-20 14:06:36 +00:00
A_PlaySound ( VENT_BUST , spr ) ;
A_PlaySound ( GLASS_BREAKING , spr ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case GLASS__STATIC :
2006-12-02 06:00:49 +00:00
updatesector ( x , y , & sn ) ;
2006-11-16 03:02:42 +00:00
if ( sn < 0 ) return ;
wal - > overpicnum = GLASS2 ;
2008-11-20 14:06:36 +00:00
A_SpawnWallGlass ( spr , dawallnum , 10 ) ;
2006-11-16 03:02:42 +00:00
wal - > cstat = 0 ;
if ( wal - > nextwall > = 0 )
wall [ wal - > nextwall ] . cstat = 0 ;
2008-11-20 14:06:36 +00:00
i = A_InsertSprite ( sn , x , y , z , SECTOREFFECTOR , 0 , 0 , 0 , g_player [ 0 ] . ps - > ang , 0 , 0 , spr , 3 ) ;
2006-11-16 03:02:42 +00:00
SLT = 128 ;
T2 = 5 ;
T3 = dawallnum ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( GLASS_BREAKING , i ) ;
2006-11-16 03:02:42 +00:00
return ;
case STAINGLASS1__STATIC :
2006-12-02 06:00:49 +00:00
updatesector ( x , y , & sn ) ;
2006-11-16 03:02:42 +00:00
if ( sn < 0 ) return ;
2008-11-20 14:06:36 +00:00
A_SpawnRandomGlass ( spr , dawallnum , 80 ) ;
2006-11-16 03:02:42 +00:00
wal - > cstat = 0 ;
if ( wal - > nextwall > = 0 )
wall [ wal - > nextwall ] . cstat = 0 ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( VENT_BUST , spr ) ;
A_PlaySound ( GLASS_BREAKING , spr ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ wal - > picnum ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case COLAMACHINE__STATIC :
case VENDMACHINE__STATIC :
2008-11-20 14:06:36 +00:00
BreakWall ( wal - > picnum + 2 , spr , dawallnum ) ;
A_PlaySound ( VENT_BUST , spr ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case OJ__STATIC :
case FEMPIC2__STATIC :
case FEMPIC3__STATIC :
case SCREENBREAK6__STATIC :
case SCREENBREAK7__STATIC :
case SCREENBREAK8__STATIC :
case SCREENBREAK1__STATIC :
case SCREENBREAK2__STATIC :
case SCREENBREAK3__STATIC :
case SCREENBREAK4__STATIC :
case SCREENBREAK5__STATIC :
case SCREENBREAK9__STATIC :
case SCREENBREAK10__STATIC :
case SCREENBREAK11__STATIC :
case SCREENBREAK12__STATIC :
case SCREENBREAK13__STATIC :
case SCREENBREAK14__STATIC :
case SCREENBREAK15__STATIC :
case SCREENBREAK16__STATIC :
case SCREENBREAK17__STATIC :
case SCREENBREAK18__STATIC :
case SCREENBREAK19__STATIC :
case BORNTOBEWILDSCREEN__STATIC :
2008-11-20 14:06:36 +00:00
A_SpawnWallGlass ( spr , dawallnum , 30 ) ;
wal - > picnum = W_SCREENBREAK + ( krand ( ) % 3 ) ;
A_PlaySound ( GLASS_HEAVYBREAK , spr ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case W_TECHWALL5__STATIC :
case W_TECHWALL6__STATIC :
case W_TECHWALL7__STATIC :
case W_TECHWALL8__STATIC :
case W_TECHWALL9__STATIC :
2008-11-20 14:06:36 +00:00
BreakWall ( wal - > picnum + 1 , spr , dawallnum ) ;
2006-11-16 03:02:42 +00:00
return ;
case W_MILKSHELF__STATIC :
2008-11-20 14:06:36 +00:00
BreakWall ( W_MILKSHELFBROKE , spr , dawallnum ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case W_TECHWALL10__STATIC :
2008-11-20 14:06:36 +00:00
BreakWall ( W_HITTECHWALL10 , spr , dawallnum ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case W_TECHWALL1__STATIC :
case W_TECHWALL11__STATIC :
case W_TECHWALL12__STATIC :
case W_TECHWALL13__STATIC :
case W_TECHWALL14__STATIC :
2008-11-20 14:06:36 +00:00
BreakWall ( W_HITTECHWALL1 , spr , dawallnum ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case W_TECHWALL15__STATIC :
2008-11-20 14:06:36 +00:00
BreakWall ( W_HITTECHWALL15 , spr , dawallnum ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case W_TECHWALL16__STATIC :
2008-11-20 14:06:36 +00:00
BreakWall ( W_HITTECHWALL16 , spr , dawallnum ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case W_TECHWALL2__STATIC :
2008-11-20 14:06:36 +00:00
BreakWall ( W_HITTECHWALL2 , spr , dawallnum ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case W_TECHWALL3__STATIC :
2008-11-20 14:06:36 +00:00
BreakWall ( W_HITTECHWALL3 , spr , dawallnum ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
case W_TECHWALL4__STATIC :
2008-11-20 14:06:36 +00:00
BreakWall ( W_HITTECHWALL4 , spr , dawallnum ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
case ATM__STATIC :
wal - > picnum = ATMBROKE ;
2008-11-20 14:06:36 +00:00
A_SpawnMultiple ( spr , MONEY , 1 + ( krand ( ) & 7 ) ) ;
A_PlaySound ( GLASS_HEAVYBREAK , spr ) ;
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 WALLLIGHT1__STATIC :
case WALLLIGHT2__STATIC :
case WALLLIGHT3__STATIC :
case WALLLIGHT4__STATIC :
case TECHLIGHT2__STATIC :
case TECHLIGHT4__STATIC :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( rnd ( 128 ) )
2008-11-20 14:06:36 +00:00
A_PlaySound ( GLASS_HEAVYBREAK , spr ) ;
else A_PlaySound ( GLASS_BREAKING , spr ) ;
A_SpawnWallGlass ( spr , dawallnum , 30 ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( wal - > picnum = = WALLLIGHT1 )
wal - > picnum = WALLLIGHTBUST1 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( wal - > picnum = = WALLLIGHT2 )
wal - > picnum = WALLLIGHTBUST2 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( wal - > picnum = = WALLLIGHT3 )
wal - > picnum = WALLLIGHTBUST3 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( wal - > picnum = = WALLLIGHT4 )
wal - > picnum = WALLLIGHTBUST4 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( wal - > picnum = = TECHLIGHT2 )
wal - > picnum = TECHLIGHTBUST2 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( wal - > picnum = = TECHLIGHT4 )
wal - > picnum = TECHLIGHTBUST4 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( ! wal - > lotag ) return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sn = wal - > nextsector ;
if ( sn < 0 ) return ;
darkestwall = 0 ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
wal = & wall [ sector [ sn ] . wallptr ] ;
for ( i = sector [ sn ] . wallnum ; i > 0 ; i - - , wal + + )
if ( wal - > shade > darkestwall )
darkestwall = wal - > shade ;
2006-11-15 01:16:55 +00:00
2008-11-20 14:06:36 +00:00
j = krand ( ) & 1 ;
i = headspritestat [ STAT_EFFECTOR ] ;
2006-11-16 03:02:42 +00:00
while ( i > = 0 )
{
if ( SHT = = wall [ dawallnum ] . lotag & & SLT = = 3 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
T3 = j ;
T4 = darkestwall ;
T5 = 1 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
i = nextspritestat [ i ] ;
}
break ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
void P_CheckTouchDamage ( DukePlayer_t * p , int j )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( ( j & 49152 ) = = 49152 )
2006-04-13 20:47:06 +00:00
{
j & = ( MAXSPRITES - 1 ) ;
2006-11-15 01:16:55 +00:00
if ( sprite [ j ] . picnum = = CACTUS )
{
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( p - > hurt_delay < 8 )
2006-04-13 20:47:06 +00:00
{
sprite [ p - > i ] . extra - = 5 ;
p - > hurt_delay = 16 ;
p - > pals_time = 32 ;
p - > pals [ 0 ] = 32 ;
p - > pals [ 1 ] = 0 ;
p - > pals [ 2 ] = 0 ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( DUKE_LONGTERM_PAIN , p - > i ) ;
2006-04-13 20:47:06 +00:00
}
}
return ;
}
2006-11-14 21:35:50 +00:00
if ( ( j & 49152 ) ! = 32768 ) return ;
2006-04-13 20:47:06 +00:00
j & = ( MAXWALLS - 1 ) ;
2006-11-14 21:35:50 +00:00
if ( p - > hurt_delay > 0 ) p - > hurt_delay - - ;
2006-11-15 01:16:55 +00:00
else if ( wall [ j ] . cstat & 85 )
{
2006-04-13 20:47:06 +00:00
int switchpicnum = wall [ j ] . overpicnum ;
if ( ( switchpicnum > W_FORCEFIELD ) & & ( switchpicnum < = W_FORCEFIELD + 2 ) )
switchpicnum = W_FORCEFIELD ;
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ switchpicnum ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case W_FORCEFIELD__STATIC :
// case W_FORCEFIELD+1:
// case W_FORCEFIELD+2:
sprite [ p - > i ] . extra - = 5 ;
p - > hurt_delay = 16 ;
p - > pals_time = 32 ;
p - > pals [ 0 ] = 32 ;
p - > pals [ 1 ] = 0 ;
p - > pals [ 2 ] = 0 ;
p - > posxv = - ( sintable [ ( p - > ang + 512 ) & 2047 ] < < 8 ) ;
p - > posyv = - ( sintable [ ( p - > ang ) & 2047 ] < < 8 ) ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( DUKE_LONGTERM_PAIN , p - > i ) ;
2006-11-16 03:02:42 +00:00
2008-11-20 14:06:36 +00:00
A_DamageWall ( p - > i , j ,
2006-11-16 03:02:42 +00:00
p - > posx + ( sintable [ ( p - > ang + 512 ) & 2047 ] > > 9 ) ,
p - > posy + ( sintable [ p - > ang & 2047 ] > > 9 ) ,
p - > posz , - 1 ) ;
2006-11-15 01:16:55 +00:00
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 BIGFORCE__STATIC :
p - > hurt_delay = 26 ;
2008-11-20 14:06:36 +00:00
A_DamageWall ( p - > i , j ,
2006-11-16 03:02:42 +00:00
p - > posx + ( sintable [ ( p - > ang + 512 ) & 2047 ] > > 9 ) ,
p - > posy + ( sintable [ p - > ang & 2047 ] > > 9 ) ,
p - > posz , - 1 ) ;
break ;
2006-04-13 20:47:06 +00:00
}
}
}
2008-11-20 14:06:36 +00:00
int Sect_DamageCeiling ( int sn )
2006-04-13 20:47:06 +00:00
{
2006-12-23 02:38:47 +00:00
int i , j ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ sector [ sn ] . ceilingpicnum ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case WALLLIGHT1__STATIC :
case WALLLIGHT2__STATIC :
case WALLLIGHT3__STATIC :
case WALLLIGHT4__STATIC :
case TECHLIGHT2__STATIC :
case TECHLIGHT4__STATIC :
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
A_SpawnCeilingGlass ( g_player [ myconnectindex ] . ps - > i , sn , 10 ) ;
A_PlaySound ( GLASS_BREAKING , g_player [ screenpeek ] . ps - > i ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sector [ sn ] . ceilingpicnum = = WALLLIGHT1 )
sector [ sn ] . ceilingpicnum = WALLLIGHTBUST1 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sector [ sn ] . ceilingpicnum = = WALLLIGHT2 )
sector [ sn ] . ceilingpicnum = WALLLIGHTBUST2 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sector [ sn ] . ceilingpicnum = = WALLLIGHT3 )
sector [ sn ] . ceilingpicnum = WALLLIGHTBUST3 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sector [ sn ] . ceilingpicnum = = WALLLIGHT4 )
sector [ sn ] . ceilingpicnum = WALLLIGHTBUST4 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sector [ sn ] . ceilingpicnum = = TECHLIGHT2 )
sector [ sn ] . ceilingpicnum = TECHLIGHTBUST2 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sector [ sn ] . ceilingpicnum = = TECHLIGHT4 )
sector [ sn ] . ceilingpicnum = TECHLIGHTBUST4 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( ! sector [ sn ] . hitag )
{
i = headspritesect [ sn ] ;
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( PN = = SECTOREFFECTOR & & SLT = = 12 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
j = headspritestat [ STAT_EFFECTOR ] ;
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 ] . hitag = = SHT )
2008-11-20 14:06:36 +00:00
ActorExtra [ j ] . temp_data [ 3 ] = 1 ;
2006-11-16 03:02:42 +00:00
j = nextspritestat [ j ] ;
2006-04-13 20:47:06 +00:00
}
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
i = nextspritesect [ i ] ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
i = headspritestat [ STAT_EFFECTOR ] ;
j = krand ( ) & 1 ;
2006-11-16 03:02:42 +00:00
while ( i > = 0 )
{
if ( SHT = = ( sector [ sn ] . hitag ) & & SLT = = 3 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
T3 = j ;
T5 = 1 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
i = nextspritestat [ i ] ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
return 1 ;
2006-04-13 20:47:06 +00:00
}
return 0 ;
}
2008-11-20 14:06:36 +00:00
// hard coded props... :(
void A_DamageObject ( int i , int sn )
2006-04-13 20:47:06 +00:00
{
2007-02-28 09:12:41 +00:00
short j ;
int k , p , rpg = 0 ;
2006-04-13 20:47:06 +00:00
spritetype * s ;
2008-02-06 11:42:34 +00:00
int switchpicnum = PN ;
2006-04-13 20:47:06 +00:00
i & = ( MAXSPRITES - 1 ) ;
2008-11-20 14:06:36 +00:00
if ( A_CheckSpriteFlags ( sn , SPRITE_PROJECTILE ) )
if ( ActorExtra [ sn ] . projectile . workslike & PROJECTILE_RPG )
2006-04-13 20:47:06 +00:00
rpg = 1 ;
switchpicnum = PN ;
2006-11-15 01:16:55 +00:00
if ( ( PN > WATERFOUNTAIN ) & & ( PN < WATERFOUNTAIN + 3 ) )
{
2006-04-13 20:47:06 +00:00
switchpicnum = WATERFOUNTAIN ;
}
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ PN ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case OCEANSPRITE1__STATIC :
case OCEANSPRITE2__STATIC :
case OCEANSPRITE3__STATIC :
case OCEANSPRITE4__STATIC :
case OCEANSPRITE5__STATIC :
2008-11-20 14:06:36 +00:00
A_Spawn ( i , SMALLSMOKE ) ;
2006-11-16 03:02:42 +00:00
deletesprite ( i ) ;
break ;
case QUEBALL__STATIC :
case STRIPEBALL__STATIC :
if ( sprite [ sn ] . picnum = = QUEBALL | | sprite [ sn ] . picnum = = STRIPEBALL )
{
sprite [ sn ] . xvel = ( sprite [ i ] . xvel > > 1 ) + ( sprite [ i ] . xvel > > 2 ) ;
sprite [ sn ] . ang - = ( SA < < 1 ) + 1024 ;
SA = getangle ( SX - sprite [ sn ] . x , SY - sprite [ sn ] . y ) - 512 ;
2008-11-20 14:06:36 +00:00
if ( S_CheckSoundPlaying ( i , POOLBALLHIT ) < 2 )
A_PlaySound ( POOLBALLHIT , i ) ;
2006-11-16 03:02:42 +00:00
}
else
{
2008-11-20 14:06:36 +00:00
if ( krand ( ) & 3 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
sprite [ i ] . xvel = 164 ;
sprite [ i ] . ang = sprite [ sn ] . ang ;
2006-04-13 20:47:06 +00:00
}
else
{
2008-11-20 14:06:36 +00:00
A_SpawnWallGlass ( i , - 1 , 3 ) ;
2006-11-16 03:02:42 +00:00
deletesprite ( i ) ;
2006-11-13 23:12:47 +00:00
}
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
break ;
case TREE1__STATIC :
case TREE2__STATIC :
case TIRE__STATIC :
case CONE__STATIC :
case BOX__STATIC :
{
if ( rpg = = 1 )
if ( T1 = = 0 )
{
CS & = ~ 257 ;
T1 = 1 ;
2008-11-20 14:06:36 +00:00
A_Spawn ( i , BURNING ) ;
2006-11-16 03:02:42 +00:00
}
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ sprite [ sn ] . picnum ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case RADIUSEXPLOSION__STATIC :
case RPG__STATIC :
case FIRELASER__STATIC :
case HYDRENT__STATIC :
case HEAVYHBOMB__STATIC :
if ( T1 = = 0 )
{
CS & = ~ 257 ;
T1 = 1 ;
2008-11-20 14:06:36 +00:00
A_Spawn ( i , BURNING ) ;
2006-04-13 20:47:06 +00:00
}
break ;
}
2006-11-16 03:02:42 +00:00
break ;
}
case CACTUS__STATIC :
{
if ( rpg = = 1 )
2008-08-24 09:29:03 +00:00
for ( k = 64 ; k > 0 ; k - - )
2006-11-13 23:12:47 +00:00
{
2008-11-20 14:06:36 +00:00
j = A_InsertSprite ( SECT , SX , SY , SZ - ( krand ( ) % ( 48 < < 8 ) ) , SCRAP3 + ( krand ( ) & 3 ) , - 8 , 48 , 48 , krand ( ) & 2047 , ( krand ( ) & 63 ) + 64 , - ( krand ( ) & 4095 ) - ( sprite [ i ] . zvel > > 2 ) , i , 5 ) ;
2006-11-16 03:02:42 +00:00
sprite [ j ] . pal = 8 ;
2006-11-13 23:12:47 +00:00
}
2006-11-16 03:02:42 +00:00
// case CACTUSBROKE:
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ sprite [ sn ] . picnum ] )
2006-11-16 03:02:42 +00:00
{
case RADIUSEXPLOSION__STATIC :
case RPG__STATIC :
case FIRELASER__STATIC :
case HYDRENT__STATIC :
case HEAVYHBOMB__STATIC :
2008-08-24 09:29:03 +00:00
for ( k = 64 ; k > 0 ; k - - )
2006-11-13 23:12:47 +00:00
{
2008-11-20 14:06:36 +00:00
j = A_InsertSprite ( SECT , SX , SY , SZ - ( krand ( ) % ( 48 < < 8 ) ) , SCRAP3 + ( krand ( ) & 3 ) , - 8 , 48 , 48 , krand ( ) & 2047 , ( krand ( ) & 63 ) + 64 , - ( krand ( ) & 4095 ) - ( sprite [ i ] . zvel > > 2 ) , i , 5 ) ;
2006-11-16 03:02:42 +00:00
sprite [ j ] . pal = 8 ;
2006-04-13 20:47:06 +00:00
}
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
if ( PN = = CACTUS )
PN = CACTUSBROKE ;
2006-11-15 01:16:55 +00:00
CS & = ~ 257 ;
2006-11-16 03:02:42 +00:00
// else deletesprite(i);
2006-11-15 01:16:55 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
break ;
}
case HANGLIGHT__STATIC :
case GENERICPOLE2__STATIC :
2008-08-24 09:29:03 +00:00
for ( k = 6 ; k > 0 ; k - - )
2008-11-20 14:06:36 +00:00
A_InsertSprite ( SECT , SX , SY , SZ - ( 8 < < 8 ) , SCRAP1 + ( krand ( ) & 15 ) , - 8 , 48 , 48 , krand ( ) & 2047 , ( krand ( ) & 63 ) + 64 , - ( krand ( ) & 4095 ) - ( sprite [ i ] . zvel > > 2 ) , i , 5 ) ;
A_PlaySound ( GLASS_HEAVYBREAK , i ) ;
2006-11-16 03:02:42 +00:00
deletesprite ( i ) ;
break ;
case FANSPRITE__STATIC :
PN = FANSPRITEBROKE ;
CS & = ( 65535 - 257 ) ;
if ( sector [ SECT ] . floorpicnum = = FANSHADOW )
sector [ SECT ] . floorpicnum = FANSHADOWBROKE ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( GLASS_HEAVYBREAK , i ) ;
2006-11-16 03:02:42 +00:00
s = & sprite [ i ] ;
2008-08-24 09:29:03 +00:00
for ( j = 16 ; j > 0 ; j - - ) RANDOMSCRAP ;
2006-11-16 03:02:42 +00:00
break ;
case WATERFOUNTAIN__STATIC :
// case WATERFOUNTAIN+1:
// case WATERFOUNTAIN+2:
// case __STATIC:
PN = WATERFOUNTAINBROKE ;
2008-11-20 14:06:36 +00:00
A_Spawn ( i , TOILETWATER ) ;
2006-11-16 03:02:42 +00:00
break ;
case SATELITE__STATIC :
case FUELPOD__STATIC :
case SOLARPANNEL__STATIC :
case ANTENNA__STATIC :
if ( sprite [ sn ] . extra ! = * actorscrptr [ SHOTSPARK1 ] )
{
2008-08-24 09:29:03 +00:00
for ( j = 15 ; j > 0 ; j - - )
2008-11-20 14:06:36 +00:00
A_InsertSprite ( SECT , SX , SY , sector [ SECT ] . floorz - ( 12 < < 8 ) - ( j < < 9 ) , SCRAP1 + ( krand ( ) & 15 ) , - 8 , 64 , 64 ,
krand ( ) & 2047 , ( krand ( ) & 127 ) + 64 , - ( krand ( ) & 511 ) - 256 , i , 5 ) ;
A_Spawn ( i , EXPLOSION2 ) ;
2006-11-16 03:02:42 +00:00
deletesprite ( i ) ;
}
break ;
case BOTTLE1__STATIC :
case BOTTLE2__STATIC :
case BOTTLE3__STATIC :
case BOTTLE4__STATIC :
case BOTTLE5__STATIC :
case BOTTLE6__STATIC :
case BOTTLE8__STATIC :
case BOTTLE10__STATIC :
case BOTTLE11__STATIC :
case BOTTLE12__STATIC :
case BOTTLE13__STATIC :
case BOTTLE14__STATIC :
case BOTTLE15__STATIC :
case BOTTLE16__STATIC :
case BOTTLE17__STATIC :
case BOTTLE18__STATIC :
case BOTTLE19__STATIC :
case WATERFOUNTAINBROKE__STATIC :
case DOMELITE__STATIC :
case SUSHIPLATE1__STATIC :
case SUSHIPLATE2__STATIC :
case SUSHIPLATE3__STATIC :
case SUSHIPLATE4__STATIC :
case SUSHIPLATE5__STATIC :
case WAITTOBESEATED__STATIC :
case VASE__STATIC :
case STATUEFLASH__STATIC :
case STATUE__STATIC :
if ( PN = = BOTTLE10 )
2008-11-20 14:06:36 +00:00
A_SpawnMultiple ( i , MONEY , 4 + ( krand ( ) & 3 ) ) ;
2006-11-16 03:02:42 +00:00
else if ( PN = = STATUE | | PN = = STATUEFLASH )
{
2008-11-20 14:06:36 +00:00
A_SpawnRandomGlass ( i , - 1 , 40 ) ;
A_PlaySound ( GLASS_HEAVYBREAK , i ) ;
2006-11-16 03:02:42 +00:00
}
else if ( PN = = VASE )
2008-11-20 14:06:36 +00:00
A_SpawnWallGlass ( i , - 1 , 40 ) ;
2006-11-16 03:02:42 +00:00
2008-11-20 14:06:36 +00:00
A_PlaySound ( GLASS_BREAKING , i ) ;
SA = krand ( ) & 2047 ;
A_SpawnWallGlass ( i , - 1 , 8 ) ;
2006-11-16 03:02:42 +00:00
deletesprite ( i ) ;
break ;
case FETUS__STATIC :
PN = FETUSBROKE ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( GLASS_BREAKING , i ) ;
A_SpawnWallGlass ( i , - 1 , 10 ) ;
2006-11-16 03:02:42 +00:00
break ;
case FETUSBROKE__STATIC :
2008-08-24 09:29:03 +00:00
for ( j = 48 ; j > 0 ; j - - )
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
A_Shoot ( i , BLOODSPLAT1 ) ;
2006-11-16 03:02:42 +00:00
SA + = 333 ;
}
2008-11-20 14:06:36 +00:00
A_PlaySound ( GLASS_HEAVYBREAK , i ) ;
A_PlaySound ( SQUISHED , i ) ;
2006-11-16 03:02:42 +00:00
case BOTTLE7__STATIC :
2008-11-20 14:06:36 +00:00
A_PlaySound ( GLASS_BREAKING , i ) ;
A_SpawnWallGlass ( i , - 1 , 10 ) ;
2006-11-16 03:02:42 +00:00
deletesprite ( i ) ;
break ;
case HYDROPLANT__STATIC :
PN = BROKEHYDROPLANT ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( GLASS_BREAKING , i ) ;
A_SpawnWallGlass ( i , - 1 , 10 ) ;
2006-11-16 03:02:42 +00:00
break ;
case FORCESPHERE__STATIC :
sprite [ i ] . xrepeat = 0 ;
2008-11-20 14:06:36 +00:00
ActorExtra [ OW ] . temp_data [ 0 ] = 32 ;
ActorExtra [ OW ] . temp_data [ 1 ] = ! ActorExtra [ OW ] . temp_data [ 1 ] ;
ActorExtra [ OW ] . temp_data [ 2 ] + + ;
A_Spawn ( i , EXPLOSION2 ) ;
2006-11-16 03:02:42 +00:00
break ;
case BROKEHYDROPLANT__STATIC :
if ( CS & 1 )
{
2008-11-20 14:06:36 +00:00
A_PlaySound ( GLASS_BREAKING , i ) ;
2006-11-16 03:02:42 +00:00
SZ + = 16 < < 8 ;
CS = 0 ;
2008-11-20 14:06:36 +00:00
A_SpawnWallGlass ( i , - 1 , 5 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
case TOILET__STATIC :
PN = TOILETBROKE ;
2008-11-20 14:06:36 +00:00
CS | = ( krand ( ) & 1 ) < < 2 ;
2006-11-16 03:02:42 +00:00
CS & = ~ 257 ;
2008-11-20 14:06:36 +00:00
A_Spawn ( i , TOILETWATER ) ;
A_PlaySound ( GLASS_BREAKING , i ) ;
2006-11-16 03:02:42 +00:00
break ;
case STALL__STATIC :
PN = STALLBROKE ;
2008-11-20 14:06:36 +00:00
CS | = ( krand ( ) & 1 ) < < 2 ;
2006-11-16 03:02:42 +00:00
CS & = ~ 257 ;
2008-11-20 14:06:36 +00:00
A_Spawn ( i , TOILETWATER ) ;
A_PlaySound ( GLASS_HEAVYBREAK , i ) ;
2006-11-16 03:02:42 +00:00
break ;
case HYDRENT__STATIC :
PN = BROKEFIREHYDRENT ;
2008-11-20 14:06:36 +00:00
A_Spawn ( i , TOILETWATER ) ;
2006-11-16 03:02:42 +00:00
// for(k=0;k<5;k++)
// {
2008-11-20 14:06:36 +00:00
// j = A_InsertSprite(SECT,SX,SY,SZ-(krand()%(48<<8)),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(sprite[i].zvel>>2),i,5);
2006-11-16 03:02:42 +00:00
// sprite[j].pal = 2;
// }
2008-11-20 14:06:36 +00:00
A_PlaySound ( GLASS_HEAVYBREAK , i ) ;
2006-11-16 03:02:42 +00:00
break ;
case GRATE1__STATIC :
PN = BGRATE1 ;
CS & = ( 65535 - 256 - 1 ) ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( VENT_BUST , i ) ;
2006-11-16 03:02:42 +00:00
break ;
case CIRCLEPANNEL__STATIC :
PN = CIRCLEPANNELBROKE ;
CS & = ( 65535 - 256 - 1 ) ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( VENT_BUST , i ) ;
2006-11-16 03:02:42 +00:00
break ;
case PANNEL1__STATIC :
case PANNEL2__STATIC :
PN = BPANNEL1 ;
CS & = ( 65535 - 256 - 1 ) ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( VENT_BUST , i ) ;
2006-11-16 03:02:42 +00:00
break ;
case PANNEL3__STATIC :
PN = BPANNEL3 ;
CS & = ( 65535 - 256 - 1 ) ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( VENT_BUST , i ) ;
2006-11-16 03:02:42 +00:00
break ;
case PIPE1__STATIC :
case PIPE2__STATIC :
case PIPE3__STATIC :
case PIPE4__STATIC :
case PIPE5__STATIC :
case PIPE6__STATIC :
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ PN ] )
2006-11-16 03:02:42 +00:00
{
2006-11-13 23:12:47 +00:00
case PIPE1__STATIC :
2006-11-16 03:02:42 +00:00
PN = PIPE1B ;
break ;
2006-11-13 23:12:47 +00:00
case PIPE2__STATIC :
2006-11-16 03:02:42 +00:00
PN = PIPE2B ;
break ;
2006-11-13 23:12:47 +00:00
case PIPE3__STATIC :
2006-11-16 03:02:42 +00:00
PN = PIPE3B ;
break ;
2006-11-13 23:12:47 +00:00
case PIPE4__STATIC :
2006-11-16 03:02:42 +00:00
PN = PIPE4B ;
2006-11-15 01:16:55 +00:00
break ;
2006-11-16 03:02:42 +00:00
case PIPE5__STATIC :
PN = PIPE5B ;
2006-11-15 01:16:55 +00:00
break ;
2006-11-16 03:02:42 +00:00
case PIPE6__STATIC :
PN = PIPE6B ;
2006-11-15 01:16:55 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2008-11-20 14:06:36 +00:00
j = A_Spawn ( i , STEAM ) ;
2006-11-16 03:02:42 +00:00
sprite [ j ] . z = sector [ SECT ] . floorz - ( 32 < < 8 ) ;
break ;
case MONK__STATIC :
case LUKE__STATIC :
case INDY__STATIC :
case JURYGUY__STATIC :
2008-11-20 14:06:36 +00:00
A_PlaySound ( SLT , i ) ;
A_Spawn ( i , SHT ) ;
2006-11-16 03:02:42 +00:00
case SPACEMARINE__STATIC :
sprite [ i ] . extra - = sprite [ sn ] . extra ;
if ( sprite [ i ] . extra > 0 ) break ;
2008-11-20 14:06:36 +00:00
SA = krand ( ) & 2047 ;
A_Shoot ( i , BLOODSPLAT1 ) ;
SA = krand ( ) & 2047 ;
A_Shoot ( i , BLOODSPLAT2 ) ;
SA = krand ( ) & 2047 ;
A_Shoot ( i , BLOODSPLAT3 ) ;
SA = krand ( ) & 2047 ;
A_Shoot ( i , BLOODSPLAT4 ) ;
SA = krand ( ) & 2047 ;
A_Shoot ( i , BLOODSPLAT1 ) ;
SA = krand ( ) & 2047 ;
A_Shoot ( i , BLOODSPLAT2 ) ;
SA = krand ( ) & 2047 ;
A_Shoot ( i , BLOODSPLAT3 ) ;
SA = krand ( ) & 2047 ;
A_Shoot ( i , BLOODSPLAT4 ) ;
A_DoGuts ( i , JIBS1 , 1 ) ;
A_DoGuts ( i , JIBS2 , 2 ) ;
A_DoGuts ( i , JIBS3 , 3 ) ;
A_DoGuts ( i , JIBS4 , 4 ) ;
A_DoGuts ( i , JIBS5 , 1 ) ;
A_DoGuts ( i , JIBS3 , 6 ) ;
S_PlaySound ( SQUISHED ) ;
2006-11-16 03:02:42 +00:00
deletesprite ( i ) ;
break ;
case CHAIR1__STATIC :
case CHAIR2__STATIC :
PN = BROKENCHAIR ;
CS = 0 ;
break ;
case CHAIR3__STATIC :
case MOVIECAMERA__STATIC :
case SCALE__STATIC :
case VACUUM__STATIC :
case CAMERALIGHT__STATIC :
case IVUNIT__STATIC :
case POT1__STATIC :
case POT2__STATIC :
case POT3__STATIC :
case TRIPODCAMERA__STATIC :
2008-11-20 14:06:36 +00:00
A_PlaySound ( GLASS_HEAVYBREAK , i ) ;
2006-11-16 03:02:42 +00:00
s = & sprite [ i ] ;
2008-08-24 09:29:03 +00:00
for ( j = 16 ; j > 0 ; j - - ) RANDOMSCRAP ;
2006-11-16 03:02:42 +00:00
deletesprite ( i ) ;
break ;
case PLAYERONWATER__STATIC :
i = OW ;
default :
if ( ( sprite [ i ] . cstat & 16 ) & & SHT = = 0 & & SLT = = 0 & & sprite [ i ] . statnum = = 0 )
2006-04-13 20:47:06 +00:00
break ;
2006-11-16 03:02:42 +00:00
if ( ( sprite [ sn ] . picnum = = FREEZEBLAST | | sprite [ sn ] . owner ! = i ) & & sprite [ i ] . statnum ! = 4 )
{
2008-11-20 14:06:36 +00:00
if ( A_CheckEnemySprite ( & sprite [ i ] ) = = 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( sprite [ sn ] . picnum = = RPG ) sprite [ sn ] . extra < < = 1 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( ( PN ! = DRONE ) & & ( PN ! = ROTATEGUN ) & & ( PN ! = COMMANDER ) & & ( PN < GREENSLIME | | PN > GREENSLIME + 7 ) )
if ( sprite [ sn ] . picnum ! = FREEZEBLAST )
2008-11-20 14:06:36 +00:00
if ( ActorType [ PN ] = = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
j = A_Spawn ( sn , JIBS6 ) ;
2006-11-16 03:02:42 +00:00
if ( sprite [ sn ] . pal = = 6 )
sprite [ j ] . pal = 6 ;
sprite [ j ] . z + = ( 4 < < 8 ) ;
sprite [ j ] . xvel = 16 ;
sprite [ j ] . xrepeat = sprite [ j ] . yrepeat = 24 ;
2008-11-20 14:06:36 +00:00
sprite [ j ] . ang + = 32 - ( krand ( ) & 63 ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
j = sprite [ sn ] . owner ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j > = 0 & & sprite [ j ] . picnum = = APLAYER & & PN ! = ROTATEGUN & & PN ! = DRONE )
2007-08-27 06:46:31 +00:00
if ( g_player [ sprite [ j ] . yvel ] . ps - > curr_weapon = = SHOTGUN_WEAPON )
2006-11-15 01:16:55 +00:00
{
2008-11-20 14:06:36 +00:00
A_Shoot ( i , BLOODSPLAT3 ) ;
A_Shoot ( i , BLOODSPLAT1 ) ;
A_Shoot ( i , BLOODSPLAT2 ) ;
A_Shoot ( i , BLOODSPLAT4 ) ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( PN ! = TANK & & PN ! = BOSS1 & & PN ! = BOSS4 & & PN ! = BOSS2 & & PN ! = BOSS3 & & PN ! = RECON & & PN ! = ROTATEGUN )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( ( sprite [ i ] . cstat & 48 ) = = 0 )
SA = ( sprite [ sn ] . ang + 1024 ) & 2047 ;
sprite [ i ] . xvel = - ( sprite [ sn ] . extra < < 2 ) ;
j = SECT ;
pushmove ( & SX , & SY , & SZ , & j , 128L , ( 4L < < 8 ) , ( 4L < < 8 ) , CLIPMASK0 ) ;
if ( j ! = SECT & & j > = 0 & & j < MAXSECTORS )
changespritesect ( i , j ) ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sprite [ i ] . statnum = = 2 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
changespritestat ( i , 1 ) ;
2008-11-20 14:06:36 +00:00
ActorExtra [ i ] . timetosleep = SLEEPTIME ;
2006-11-16 03:02:42 +00:00
}
if ( ( RX < 24 | | PN = = SHARK ) & & sprite [ sn ] . picnum = = SHRINKSPARK ) return ;
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( sprite [ i ] . statnum ! = 2 )
{
2008-11-20 14:06:36 +00:00
if ( sprite [ sn ] . picnum = = FREEZEBLAST & & ( ( PN = = APLAYER & & sprite [ i ] . pal = = 1 ) | | ( g_freezerSelfDamage = = 0 & & sprite [ sn ] . owner = = i ) ) )
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
ActorExtra [ i ] . picnum = sprite [ sn ] . picnum ;
ActorExtra [ i ] . extra + = sprite [ sn ] . extra ;
ActorExtra [ i ] . ang = sprite [ sn ] . ang ;
ActorExtra [ i ] . owner = sprite [ sn ] . owner ;
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 ( sprite [ i ] . statnum = = 10 )
{
p = sprite [ i ] . yvel ;
2007-08-27 06:46:31 +00:00
if ( g_player [ p ] . ps - > newowner > = 0 )
2006-11-16 03:02:42 +00:00
{
2007-08-27 06:46:31 +00:00
g_player [ p ] . ps - > newowner = - 1 ;
g_player [ p ] . ps - > posx = g_player [ p ] . ps - > oposx ;
g_player [ p ] . ps - > posy = g_player [ p ] . ps - > oposy ;
g_player [ p ] . ps - > posz = g_player [ p ] . ps - > oposz ;
g_player [ p ] . ps - > ang = g_player [ p ] . ps - > oang ;
2006-11-16 03:02:42 +00:00
2007-08-27 06:46:31 +00:00
updatesector ( g_player [ p ] . ps - > posx , g_player [ p ] . ps - > posy , & g_player [ p ] . ps - > cursectnum ) ;
2008-11-20 14:06:36 +00:00
P_UpdateScreenPal ( g_player [ 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 )
{
if ( sprite [ j ] . picnum = = CAMERA1 ) sprite [ j ] . yvel = 0 ;
j = nextspritestat [ j ] ;
}
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( RX < 24 & & sprite [ sn ] . picnum = = SHRINKSPARK )
return ;
2008-11-20 14:06:36 +00:00
if ( sprite [ ActorExtra [ i ] . owner ] . picnum ! = APLAYER )
2006-11-16 03:02:42 +00:00
if ( ud . player_skill > = 3 )
sprite [ sn ] . extra + = ( sprite [ sn ] . extra > > 1 ) ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
}
}
void allignwarpelevators ( void )
{
2008-11-20 14:06:36 +00:00
int j , i = headspritestat [ STAT_EFFECTOR ] ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( SLT = = 17 & & SS > 16 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
j = headspritestat [ STAT_EFFECTOR ] ;
2006-11-13 23:12:47 +00:00
while ( j > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( ( sprite [ j ] . lotag ) = = 17 & & i ! = j & &
( SHT ) = = ( sprite [ j ] . hitag ) )
2006-04-13 20:47:06 +00:00
{
sector [ sprite [ j ] . sectnum ] . floorz =
sector [ SECT ] . floorz ;
sector [ sprite [ j ] . sectnum ] . ceilingz =
sector [ SECT ] . ceilingz ;
}
j = nextspritestat [ j ] ;
}
}
i = nextspritestat [ i ] ;
}
}
2008-11-20 14:06:36 +00:00
void G_HandleSharedKeys ( int snum )
2006-04-13 20:47:06 +00:00
{
2006-12-21 09:33:26 +00:00
int i , k , dainv ;
2007-12-12 17:42:14 +00:00
unsigned int sb_snum = g_player [ snum ] . sync - > bits , j ;
2008-11-20 14:06:36 +00:00
DukePlayer_t * p = g_player [ snum ] . ps ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( p - > cheat_phase = = 1 ) return ;
2006-04-13 20:47:06 +00:00
// 1<<0 = jump
// 1<<1 = crouch
// 1<<2 = fire
// 1<<3 = aim up
// 1<<4 = aim down
// 1<<5 = run
// 1<<6 = look left
// 1<<7 = look right
// 15<<8 = !weapon selection (bits 8-11)
// 1<<12 = !steroids
// 1<<13 = look up
// 1<<14 = look down
// 1<<15 = !nightvis
// 1<<16 = !medkit
// 1<<17 = (multiflag==1) ? changes meaning of bits 18 and 19
// 1<<18 = centre view
// 1<<19 = !holster weapon
// 1<<20 = !inventory left
// 1<<21 = !pause
// 1<<22 = !quick kick
// 1<<23 = aim mode
// 1<<24 = !holoduke
// 1<<25 = !jetpack
2008-11-20 14:06:36 +00:00
// 1<<26 = g_gameQuit
2006-04-13 20:47:06 +00:00
// 1<<27 = !inventory right
// 1<<28 = !turn around
// 1<<29 = !open
// 1<<30 = !inventory
// 1<<31 = !escape
i = p - > aim_mode ;
2008-11-20 14:06:36 +00:00
p - > aim_mode = ( sb_snum > > SK_AIMMODE ) & 1 ;
2006-11-13 23:12:47 +00:00
if ( p - > aim_mode < i )
2006-04-13 20:47:06 +00:00
p - > return_to_center = 9 ;
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( sb_snum , SK_QUICK_KICK ) & & p - > quick_kick = = 0 )
2006-11-14 21:35:50 +00:00
if ( p - > curr_weapon ! = KNEE_WEAPON | | p - > kickback_pic = = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , 0 , g_player [ snum ] . ps - > i , snum ) ;
X_OnEvent ( EVENT_QUICKKICK , g_player [ snum ] . ps - > i , snum , - 1 ) ;
if ( Gv_GetVar ( g_iReturnVarID , g_player [ snum ] . ps - > i , snum ) = = 0 )
2006-04-13 20:47:06 +00:00
{
p - > quick_kick = 14 ;
2008-09-15 02:47:02 +00:00
if ( p - > fta = = 0 | | p - > ftq = = 80 )
2008-11-20 14:06:36 +00:00
P_DoQuote ( 80 , p ) ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
// j = sb_snum & ((15<<8)|(1<<12)|(1<<15)|(1<<16)|(1<<22)|(1<<19)|(1<<20)|(1<<21)|(1<<24)|(1<<25)|(1<<27)|(1<<28)|(1<<29)|(1<<30)|(1<<31));
j = sb_snum & ( ( 15 < < 8 ) | BIT ( SK_STEROIDS ) | BIT ( SK_NIGHTVISION ) | BIT ( SK_MEDKIT ) | BIT ( SK_QUICK_KICK ) | \
BIT ( SK_HOLSTER ) | BIT ( SK_INV_LEFT ) | BIT ( SK_PAUSE ) | BIT ( SK_HOLODUKE ) | BIT ( SK_JETPACK ) | BIT ( SK_INV_RIGHT ) | \
BIT ( SK_TURNAROUND ) | BIT ( SK_OPEN ) | BIT ( SK_INVENTORY ) | BIT ( SK_ESCAPE ) ) ;
2006-04-13 20:47:06 +00:00
sb_snum = j & ~ p - > interface_toggle_flag ;
p - > interface_toggle_flag | = sb_snum | ( ( sb_snum & 0xf00 ) ? 0xf00 : 0 ) ;
p - > interface_toggle_flag & = j | ( ( j & 0xf00 ) ? 0xf00 : 0 ) ;
2008-11-20 14:06:36 +00:00
if ( sb_snum & & TEST_SYNC_KEY ( sb_snum , SK_MULTIFLAG ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( sb_snum , SK_PAUSE ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
KB_ClearKeyDown ( sc_Pause ) ;
2006-11-13 23:12:47 +00:00
if ( ud . pause_on )
2006-04-19 05:48:44 +00:00
ud . pause_on = 0 ;
else ud . pause_on = 1 + SHIFTS_IS_PRESSED ;
2006-11-13 23:12:47 +00:00
if ( ud . pause_on )
2006-04-13 20:47:06 +00:00
{
MUSIC_Pause ( ) ;
FX_StopAllSounds ( ) ;
2008-11-20 14:06:36 +00:00
S_ClearSoundLocks ( ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2007-08-27 00:20:15 +00:00
if ( ud . config . MusicToggle ) MUSIC_Continue ( ) ;
2006-04-13 20:47:06 +00:00
pub = NUMPAGES ;
pus = NUMPAGES ;
}
}
2006-11-13 23:12:47 +00:00
if ( ud . pause_on ) return ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( sprite [ p - > i ] . extra < = 0 ) return ; // if dead...
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( sb_snum , SK_INVENTORY ) & & p - > newowner = = - 1 ) // inventory button generates event for selected item
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , 0 , g_player [ snum ] . ps - > i , snum ) ;
X_OnEvent ( EVENT_INVENTORY , g_player [ snum ] . ps - > i , snum , - 1 ) ;
if ( Gv_GetVar ( g_iReturnVarID , g_player [ snum ] . ps - > i , snum ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
switch ( p - > inven_icon )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 4 :
2008-11-20 14:06:36 +00:00
sb_snum | = BIT ( SK_JETPACK ) ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
2008-11-20 14:06:36 +00:00
sb_snum | = BIT ( SK_HOLODUKE ) ;
2006-11-16 03:02:42 +00:00
break ;
case 5 :
2008-11-20 14:06:36 +00:00
sb_snum | = BIT ( SK_NIGHTVISION ) ;
2006-11-16 03:02:42 +00:00
break ;
case 1 :
2008-11-20 14:06:36 +00:00
sb_snum | = BIT ( SK_MEDKIT ) ;
2006-11-16 03:02:42 +00:00
break ;
case 2 :
2008-11-20 14:06:36 +00:00
sb_snum | = BIT ( SK_STEROIDS ) ;
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
if ( TEST_SYNC_KEY ( sb_snum , SK_NIGHTVISION ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , 0 , g_player [ snum ] . ps - > i , snum ) ;
X_OnEvent ( EVENT_USENIGHTVISION , g_player [ snum ] . ps - > i , snum , - 1 ) ;
if ( Gv_GetVar ( g_iReturnVarID , g_player [ snum ] . ps - > i , snum ) = = 0
2006-04-13 20:47:06 +00:00
& & p - > heat_amount > 0 )
{
p - > heat_on = ! p - > heat_on ;
2008-11-20 14:06:36 +00:00
P_UpdateScreenPal ( p ) ;
2006-04-13 20:47:06 +00:00
p - > inven_icon = 5 ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( NITEVISION_ONOFF , p - > i ) ;
P_DoQuote ( 106 + ( ! p - > heat_on ) , p ) ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( sb_snum , SK_STEROIDS ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , 0 , g_player [ snum ] . ps - > i , snum ) ;
X_OnEvent ( EVENT_USESTEROIDS , g_player [ snum ] . ps - > i , snum , - 1 ) ;
if ( Gv_GetVar ( g_iReturnVarID , g_player [ snum ] . ps - > i , snum ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( p - > steroids_amount = = 400 )
2006-04-13 20:47:06 +00:00
{
p - > steroids_amount - - ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( DUKE_TAKEPILLS , p - > i ) ;
P_DoQuote ( 12 , p ) ;
2006-04-13 20:47:06 +00:00
}
2008-08-23 00:42:16 +00:00
if ( p - > steroids_amount > 0 )
p - > inven_icon = 2 ;
2006-04-13 20:47:06 +00:00
}
return ; // is there significance to returning?
}
2006-11-13 23:12:47 +00:00
if ( p - > refresh_inventory )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
sb_snum | = BIT ( SK_INV_LEFT ) ; // emulate move left...
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
if ( p - > newowner = = - 1 )
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( sb_snum , SK_INV_LEFT | SK_INV_RIGHT ) )
2006-04-13 20:47:06 +00:00
{
p - > invdisptime = 26 * 2 ;
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( sb_snum , SK_INV_RIGHT ) ) k = 1 ;
2006-04-13 20:47:06 +00:00
else k = 0 ;
2006-11-13 23:12:47 +00:00
if ( p - > refresh_inventory ) p - > refresh_inventory = 0 ;
2006-04-13 20:47:06 +00:00
dainv = p - > inven_icon ;
i = 0 ;
CHECKINV1 :
2006-11-13 23:12:47 +00:00
if ( i < 9 )
2006-04-13 20:47:06 +00:00
{
i + + ;
2006-11-13 23:12:47 +00:00
switch ( dainv )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 4 :
if ( p - > jetpack_amount > 0 & & i > 1 )
break ;
if ( k ) dainv = 5 ;
else dainv = 3 ;
goto CHECKINV1 ;
case 6 :
if ( p - > scuba_amount > 0 & & i > 1 )
break ;
if ( k ) dainv = 7 ;
else dainv = 5 ;
goto CHECKINV1 ;
case 2 :
if ( p - > steroids_amount > 0 & & i > 1 )
break ;
if ( k ) dainv = 3 ;
else dainv = 1 ;
goto CHECKINV1 ;
case 3 :
if ( p - > holoduke_amount > 0 & & i > 1 )
break ;
if ( k ) dainv = 4 ;
else dainv = 2 ;
goto CHECKINV1 ;
case 0 :
case 1 :
if ( p - > firstaid_amount > 0 & & i > 1 )
break ;
if ( k ) dainv = 2 ;
else dainv = 7 ;
goto CHECKINV1 ;
case 5 :
if ( p - > heat_amount > 0 & & i > 1 )
break ;
if ( k ) dainv = 6 ;
else dainv = 4 ;
goto CHECKINV1 ;
case 7 :
if ( p - > boot_amount > 0 & & i > 1 )
break ;
if ( k ) dainv = 1 ;
else dainv = 6 ;
goto CHECKINV1 ;
2006-04-13 20:47:06 +00:00
}
}
else dainv = 0 ;
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( sb_snum , SK_INV_LEFT ) ) // Inventory_Left
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , dainv , g_player [ snum ] . ps - > i , snum ) ;
X_OnEvent ( EVENT_INVENTORYLEFT , g_player [ snum ] . ps - > i , snum , - 1 ) ;
dainv = Gv_GetVar ( g_iReturnVarID , g_player [ snum ] . ps - > i , snum ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( sb_snum , SK_INV_RIGHT ) ) // Inventory_Right
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , dainv , g_player [ snum ] . ps - > i , snum ) ;
X_OnEvent ( EVENT_INVENTORYRIGHT , g_player [ snum ] . ps - > i , snum , - 1 ) ;
dainv = Gv_GetVar ( g_iReturnVarID , g_player [ snum ] . ps - > i , snum ) ;
2006-04-13 20:47:06 +00:00
}
p - > inven_icon = dainv ;
2006-11-13 23:12:47 +00:00
switch ( dainv )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 1 :
2008-11-20 14:06:36 +00:00
P_DoQuote ( 3 , p ) ;
2006-11-16 03:02:42 +00:00
break ;
case 2 :
2008-11-20 14:06:36 +00:00
P_DoQuote ( 90 , p ) ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
2008-11-20 14:06:36 +00:00
P_DoQuote ( 91 , p ) ;
2006-11-16 03:02:42 +00:00
break ;
case 4 :
2008-11-20 14:06:36 +00:00
P_DoQuote ( 88 , p ) ;
2006-11-16 03:02:42 +00:00
break ;
case 5 :
2008-11-20 14:06:36 +00:00
P_DoQuote ( 101 , p ) ;
2006-11-16 03:02:42 +00:00
break ;
case 6 :
2008-11-20 14:06:36 +00:00
P_DoQuote ( 89 , p ) ;
2006-11-16 03:02:42 +00:00
break ;
case 7 :
2008-11-20 14:06:36 +00:00
P_DoQuote ( 6 , p ) ;
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
j = ( ( sb_snum & ( 15 < < SK_WEAPON_BITS ) ) > > SK_WEAPON_BITS ) - 1 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , j , p - > i , snum ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
switch ( j )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case 0 :
2008-11-20 14:06:36 +00:00
X_OnEvent ( EVENT_WEAPKEY1 , p - > i , snum , - 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 1 :
2008-11-20 14:06:36 +00:00
X_OnEvent ( EVENT_WEAPKEY2 , p - > i , snum , - 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 2 :
2008-11-20 14:06:36 +00:00
X_OnEvent ( EVENT_WEAPKEY3 , p - > i , snum , - 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 3 :
2008-11-20 14:06:36 +00:00
X_OnEvent ( EVENT_WEAPKEY4 , p - > i , snum , - 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 4 :
2008-11-20 14:06:36 +00:00
X_OnEvent ( EVENT_WEAPKEY5 , p - > i , snum , - 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 5 :
2008-11-20 14:06:36 +00:00
X_OnEvent ( EVENT_WEAPKEY6 , p - > i , snum , - 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 6 :
2008-11-20 14:06:36 +00:00
X_OnEvent ( EVENT_WEAPKEY7 , p - > i , snum , - 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 7 :
2008-11-20 14:06:36 +00:00
X_OnEvent ( EVENT_WEAPKEY8 , p - > i , snum , - 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 8 :
2008-11-20 14:06:36 +00:00
X_OnEvent ( EVENT_WEAPKEY9 , p - > i , snum , - 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 9 :
2008-11-20 14:06:36 +00:00
X_OnEvent ( EVENT_WEAPKEY10 , p - > i , snum , - 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 10 :
2008-11-20 14:06:36 +00:00
X_OnEvent ( EVENT_PREVIOUSWEAPON , p - > i , snum , - 1 ) ;
2006-11-16 03:02:42 +00:00
break ;
case 11 :
2008-11-20 14:06:36 +00:00
X_OnEvent ( EVENT_NEXTWEAPON , p - > i , snum , - 1 ) ;
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
if ( ( unsigned int ) Gv_GetVar ( g_iReturnVarID , p - > i , snum ) ! = j )
j = ( unsigned int ) Gv_GetVar ( g_iReturnVarID , p - > i , snum ) ;
2006-10-10 23:04:38 +00:00
2006-04-13 20:47:06 +00:00
if ( p - > reloading = = 1 )
j = - 1 ;
2006-11-14 21:35:50 +00:00
else if ( j > 0 & & p - > kickback_pic = = 1 & & p - > weapon_pos = = 1 )
2006-04-13 20:47:06 +00:00
{
p - > wantweaponfire = j ;
p - > kickback_pic = 0 ;
}
2006-11-14 21:35:50 +00:00
if ( p - > last_pissed_time < = ( 26 * 218 ) & & p - > show_empty_weapon = = 0 & & p - > kickback_pic = = 0 & & p - > quick_kick = = 0 & & sprite [ p - > i ] . xrepeat > 32 & & p - > access_incs = = 0 & & p - > knee_incs = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-04-19 08:00:09 +00:00
// if( ( p->weapon_pos == 0 || ( p->holster_weapon && p->weapon_pos == -9 ) ))
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( j = = 10 | | j = = 11 )
2006-04-13 20:47:06 +00:00
{
k = p - > curr_weapon ;
2006-11-14 21:35:50 +00:00
j = ( j = = 10 ? - 1 : 1 ) ; // JBF: prev (-1) or next (1) weapon choice
2006-04-13 20:47:06 +00:00
i = 0 ;
2006-11-14 21:35:50 +00:00
while ( ( k > = 0 & & k < 10 ) | | ( PLUTOPAK & & k = = GROW_WEAPON & & ( p - > subweapon & ( 1 < < GROW_WEAPON ) ) ) ) // JBF 20040116: so we don't select grower with v1.3d
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( k = = GROW_WEAPON ) // JBF: this is handling next/previous with the grower selected
2006-04-13 20:47:06 +00:00
{
2007-12-12 17:42:14 +00:00
if ( j = = ( unsigned int ) - 1 )
2006-04-13 20:47:06 +00:00
k = 5 ;
else k = 7 ;
}
else
{
k + = j ;
if ( PLUTOPAK ) // JBF 20040116: so we don't select grower with v1.3d
2006-11-14 21:35:50 +00:00
if ( k = = SHRINKER_WEAPON & & ( p - > subweapon & ( 1 < < GROW_WEAPON ) ) ) // JBF: activates grower
2006-04-13 20:47:06 +00:00
k = GROW_WEAPON ; // if enabled
}
2006-11-13 23:12:47 +00:00
if ( k = = - 1 ) k = 9 ;
else if ( k = = 10 ) k = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( p - > gotweapon [ k ] & & p - > ammo_amount [ k ] > 0 )
2006-04-13 20:47:06 +00:00
{
if ( PLUTOPAK ) // JBF 20040116: so we don't select grower with v1.3d
2006-11-14 21:35:50 +00:00
if ( k = = SHRINKER_WEAPON & & ( p - > subweapon & ( 1 < < GROW_WEAPON ) ) )
2006-04-13 20:47:06 +00:00
k = GROW_WEAPON ;
j = k ;
break ;
}
else // JBF: grower with no ammo, but shrinker with ammo, switch to shrink
2006-11-13 23:12:47 +00:00
if ( PLUTOPAK & & k = = GROW_WEAPON & & p - > ammo_amount [ GROW_WEAPON ] = = 0 & & p - > gotweapon [ SHRINKER_WEAPON ] & & p - > ammo_amount [ SHRINKER_WEAPON ] > 0 ) // JBF 20040116: added PLUTOPAK so we don't select grower with v1.3d
2006-04-13 20:47:06 +00:00
{
j = SHRINKER_WEAPON ;
p - > subweapon & = ~ ( 1 < < GROW_WEAPON ) ;
break ;
}
else // JBF: shrinker with no ammo, but grower with ammo, switch to grow
2006-11-13 23:12:47 +00:00
if ( PLUTOPAK & & k = = SHRINKER_WEAPON & & p - > ammo_amount [ SHRINKER_WEAPON ] = = 0 & & p - > gotweapon [ SHRINKER_WEAPON ] & & p - > ammo_amount [ GROW_WEAPON ] > 0 ) // JBF 20040116: added PLUTOPAK so we don't select grower with v1.3d
2006-04-13 20:47:06 +00:00
{
j = GROW_WEAPON ;
p - > subweapon | = ( 1 < < GROW_WEAPON ) ;
break ;
}
i + + ; // absolutely no weapons, so use foot
2006-11-13 23:12:47 +00:00
if ( i = = 10 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
P_AddWeapon ( p , KNEE_WEAPON ) ;
2006-04-13 20:47:06 +00:00
break ;
}
}
}
k = - 1 ;
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iWeaponVarID , j , p - > i , snum ) ;
Gv_SetVar ( g_iReturnVarID , 0 , p - > i , snum ) ;
X_OnEvent ( EVENT_SELECTWEAPON , p - > i , snum , - 1 ) ;
if ( Gv_GetVar ( g_iReturnVarID , p - > i , snum ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( j = = HANDBOMB_WEAPON & & p - > ammo_amount [ HANDBOMB_WEAPON ] = = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
k = headspritestat [ STAT_ACTOR ] ;
2006-11-13 23:12:47 +00:00
while ( k > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( sprite [ k ] . picnum = = HEAVYHBOMB & & sprite [ k ] . owner = = p - > i )
2006-04-13 20:47:06 +00:00
{
p - > gotweapon [ HANDBOMB_WEAPON ] = 1 ;
j = HANDREMOTE_WEAPON ;
break ;
}
k = nextspritestat [ k ] ;
}
}
2006-11-13 23:12:47 +00:00
if ( j = = SHRINKER_WEAPON & & PLUTOPAK ) // JBF 20040116: so we don't select the grower with v1.3d
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( screenpeek = = snum ) pus = NUMPAGES ;
2006-04-13 20:47:06 +00:00
2006-11-14 21:35:50 +00:00
if ( p - > curr_weapon ! = GROW_WEAPON & & p - > curr_weapon ! = SHRINKER_WEAPON )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( p - > ammo_amount [ GROW_WEAPON ] > 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( ( p - > subweapon & ( 1 < < GROW_WEAPON ) ) = = ( 1 < < GROW_WEAPON ) )
2006-04-13 20:47:06 +00:00
j = GROW_WEAPON ;
2006-11-13 23:12:47 +00:00
else if ( p - > ammo_amount [ SHRINKER_WEAPON ] = = 0 )
2006-04-13 20:47:06 +00:00
{
j = GROW_WEAPON ;
p - > subweapon | = ( 1 < < GROW_WEAPON ) ;
}
}
2006-11-14 21:35:50 +00:00
else if ( p - > ammo_amount [ SHRINKER_WEAPON ] > 0 )
2006-04-13 20:47:06 +00:00
p - > subweapon & = ~ ( 1 < < GROW_WEAPON ) ;
}
2006-11-14 21:35:50 +00:00
else if ( p - > curr_weapon = = SHRINKER_WEAPON )
2006-04-13 20:47:06 +00:00
{
p - > subweapon | = ( 1 < < GROW_WEAPON ) ;
j = GROW_WEAPON ;
}
else
p - > subweapon & = ~ ( 1 < < GROW_WEAPON ) ;
}
2006-11-13 23:12:47 +00:00
if ( p - > holster_weapon )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
sb_snum | = BIT ( SK_HOLSTER ) ;
2006-04-13 20:47:06 +00:00
p - > weapon_pos = - 9 ;
}
2007-12-12 17:42:14 +00:00
else if ( ( int ) j > = 0 & & p - > gotweapon [ j ] & & ( unsigned int ) p - > curr_weapon ! = j )
2006-11-13 23:12:47 +00:00
switch ( j )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case KNEE_WEAPON :
2008-11-20 14:06:36 +00:00
P_AddWeapon ( p , KNEE_WEAPON ) ;
2006-11-16 03:02:42 +00:00
break ;
case PISTOL_WEAPON :
if ( p - > ammo_amount [ PISTOL_WEAPON ] = = 0 )
if ( p - > show_empty_weapon = = 0 )
2006-11-15 01:16:55 +00:00
{
p - > last_full_weapon = p - > curr_weapon ;
p - > show_empty_weapon = 32 ;
}
2008-11-20 14:06:36 +00:00
P_AddWeapon ( p , PISTOL_WEAPON ) ;
2006-11-16 03:02:42 +00:00
break ;
case SHOTGUN_WEAPON :
if ( p - > ammo_amount [ SHOTGUN_WEAPON ] = = 0 & & p - > show_empty_weapon = = 0 )
{
p - > last_full_weapon = p - > curr_weapon ;
p - > show_empty_weapon = 32 ;
}
2008-11-20 14:06:36 +00:00
P_AddWeapon ( p , SHOTGUN_WEAPON ) ;
2006-11-16 03:02:42 +00:00
break ;
case CHAINGUN_WEAPON :
if ( p - > ammo_amount [ CHAINGUN_WEAPON ] = = 0 & & p - > show_empty_weapon = = 0 )
{
p - > last_full_weapon = p - > curr_weapon ;
p - > show_empty_weapon = 32 ;
}
2008-11-20 14:06:36 +00:00
P_AddWeapon ( p , CHAINGUN_WEAPON ) ;
2006-11-16 03:02:42 +00:00
break ;
case RPG_WEAPON :
if ( p - > ammo_amount [ RPG_WEAPON ] = = 0 )
if ( p - > show_empty_weapon = = 0 )
2006-11-15 01:16:55 +00:00
{
p - > last_full_weapon = p - > curr_weapon ;
p - > show_empty_weapon = 32 ;
}
2008-11-20 14:06:36 +00:00
P_AddWeapon ( p , RPG_WEAPON ) ;
2006-11-16 03:02:42 +00:00
break ;
case DEVISTATOR_WEAPON :
if ( p - > ammo_amount [ DEVISTATOR_WEAPON ] = = 0 & & p - > show_empty_weapon = = 0 )
{
p - > last_full_weapon = p - > curr_weapon ;
p - > show_empty_weapon = 32 ;
}
2008-11-20 14:06:36 +00:00
P_AddWeapon ( p , DEVISTATOR_WEAPON ) ;
2006-11-16 03:02:42 +00:00
break ;
case FREEZE_WEAPON :
if ( p - > ammo_amount [ FREEZE_WEAPON ] = = 0 & & p - > show_empty_weapon = = 0 )
{
p - > last_full_weapon = p - > curr_weapon ;
p - > show_empty_weapon = 32 ;
}
2008-11-20 14:06:36 +00:00
P_AddWeapon ( p , FREEZE_WEAPON ) ;
2006-11-16 03:02:42 +00:00
break ;
case GROW_WEAPON :
case SHRINKER_WEAPON :
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( p - > ammo_amount [ j ] = = 0 & & p - > show_empty_weapon = = 0 )
{
p - > show_empty_weapon = 32 ;
p - > last_full_weapon = p - > curr_weapon ;
}
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
P_AddWeapon ( p , j ) ;
2006-11-16 03:02:42 +00:00
break ;
case HANDREMOTE_WEAPON :
if ( k > = 0 ) // Found in list of [1]'s
{
p - > curr_weapon = HANDREMOTE_WEAPON ;
p - > last_weapon = - 1 ;
p - > weapon_pos = 10 ;
}
break ;
case HANDBOMB_WEAPON :
if ( p - > ammo_amount [ HANDBOMB_WEAPON ] > 0 & & p - > gotweapon [ HANDBOMB_WEAPON ] )
2008-11-20 14:06:36 +00:00
P_AddWeapon ( p , HANDBOMB_WEAPON ) ;
2006-11-16 03:02:42 +00:00
break ;
case TRIPBOMB_WEAPON :
if ( p - > ammo_amount [ TRIPBOMB_WEAPON ] > 0 & & p - > gotweapon [ TRIPBOMB_WEAPON ] )
2008-11-20 14:06:36 +00:00
P_AddWeapon ( p , TRIPBOMB_WEAPON ) ;
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
if ( TEST_SYNC_KEY ( sb_snum , SK_HOLSTER ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( p - > curr_weapon > KNEE_WEAPON )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( p - > holster_weapon = = 0 & & p - > weapon_pos = = 0 )
2006-04-13 20:47:06 +00:00
{
p - > holster_weapon = 1 ;
p - > weapon_pos = - 1 ;
2008-11-20 14:06:36 +00:00
P_DoQuote ( 73 , p ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
else if ( p - > holster_weapon = = 1 & & p - > weapon_pos = = - 9 )
2006-04-13 20:47:06 +00:00
{
p - > holster_weapon = 0 ;
p - > weapon_pos = 10 ;
2008-11-20 14:06:36 +00:00
P_DoQuote ( 74 , p ) ;
2006-04-13 20:47:06 +00:00
}
}
}
}
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( sb_snum , SK_HOLODUKE ) & & p - > newowner = = - 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( p - > holoduke_on = = - 1 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , 0 , g_player [ snum ] . ps - > i , snum ) ;
X_OnEvent ( EVENT_HOLODUKEON , g_player [ snum ] . ps - > i , snum , - 1 ) ;
if ( Gv_GetVar ( g_iReturnVarID , g_player [ snum ] . ps - > i , snum ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( p - > holoduke_amount > 0 )
2006-04-13 20:47:06 +00:00
{
p - > inven_icon = 3 ;
2008-07-29 09:57:09 +00:00
if ( p - > cursectnum > - 1 )
{
p - > holoduke_on = i =
2008-11-20 14:06:36 +00:00
A_InsertSprite ( p - > cursectnum ,
p - > posx ,
p - > posy ,
p - > posz + ( 30 < < 8 ) , APLAYER , - 64 , 0 , 0 , p - > ang , 0 , 0 , - 1 , 10 ) ;
2008-07-29 09:57:09 +00:00
T4 = T5 = 0 ;
SP = snum ;
sprite [ i ] . extra = 0 ;
2008-11-20 14:06:36 +00:00
P_DoQuote ( 47 , p ) ;
A_PlaySound ( TELEPORTER , p - > holoduke_on ) ;
2008-07-29 09:57:09 +00:00
}
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
else P_DoQuote ( 49 , p ) ;
2006-04-13 20:47:06 +00:00
}
}
else
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , 0 , g_player [ snum ] . ps - > i , snum ) ;
X_OnEvent ( EVENT_HOLODUKEOFF , g_player [ snum ] . ps - > i , snum , - 1 ) ;
if ( Gv_GetVar ( g_iReturnVarID , g_player [ snum ] . ps - > i , snum ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
A_PlaySound ( TELEPORTER , p - > holoduke_on ) ;
2006-04-13 20:47:06 +00:00
p - > holoduke_on = - 1 ;
2008-11-20 14:06:36 +00:00
P_DoQuote ( 48 , p ) ;
2006-04-13 20:47:06 +00:00
}
}
}
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( sb_snum , SK_MEDKIT ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , 0 , g_player [ snum ] . ps - > i , snum ) ;
X_OnEvent ( EVENT_USEMEDKIT , g_player [ snum ] . ps - > i , snum , - 1 ) ;
if ( Gv_GetVar ( g_iReturnVarID , g_player [ snum ] . ps - > i , snum ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 23:11:49 +00:00
if ( p - > firstaid_amount > 0 & & sprite [ p - > i ] . extra < p - > max_player_health )
2006-04-13 20:47:06 +00:00
{
2007-08-27 23:11:49 +00:00
j = p - > max_player_health - sprite [ p - > i ] . extra ;
2006-04-13 20:47:06 +00:00
2007-12-12 17:42:14 +00:00
if ( ( unsigned int ) p - > firstaid_amount > j )
2006-04-13 20:47:06 +00:00
{
p - > firstaid_amount - = j ;
2007-08-27 23:11:49 +00:00
sprite [ p - > i ] . extra = p - > max_player_health ;
2006-04-13 20:47:06 +00:00
p - > inven_icon = 1 ;
}
else
{
sprite [ p - > i ] . extra + = p - > firstaid_amount ;
p - > firstaid_amount = 0 ;
2008-11-20 14:06:36 +00:00
P_SelectNextInventoryItem ( p ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
A_PlaySound ( DUKE_USEMEDKIT , p - > i ) ;
2006-04-13 20:47:06 +00:00
}
}
}
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( sb_snum , SK_JETPACK ) & & p - > newowner = = - 1 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , 0 , g_player [ snum ] . ps - > i , snum ) ;
X_OnEvent ( EVENT_USEJETPACK , g_player [ snum ] . ps - > i , snum , - 1 ) ;
if ( Gv_GetVar ( g_iReturnVarID , g_player [ snum ] . ps - > i , snum ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( p - > jetpack_amount > 0 )
2006-04-13 20:47:06 +00:00
{
p - > jetpack_on = ! p - > jetpack_on ;
2006-11-13 23:12:47 +00:00
if ( p - > jetpack_on )
2006-04-13 20:47:06 +00:00
{
p - > inven_icon = 4 ;
2006-11-13 23:12:47 +00:00
if ( p - > scream_voice > FX_Ok )
2006-04-13 20:47:06 +00:00
{
FX_StopSound ( p - > scream_voice ) ;
2008-11-20 14:06:36 +00:00
S_TestSoundCallback ( DUKE_SCREAM ) ;
2006-04-13 20:47:06 +00:00
p - > scream_voice = FX_Ok ;
}
2008-11-20 14:06:36 +00:00
A_PlaySound ( DUKE_JETPACK_ON , p - > i ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
P_DoQuote ( 52 , p ) ;
2006-04-13 20:47:06 +00:00
}
else
{
p - > hard_landing = 0 ;
p - > poszv = 0 ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( DUKE_JETPACK_OFF , p - > i ) ;
A_StopSound ( DUKE_JETPACK_IDLE , p - > i ) ;
A_StopSound ( DUKE_JETPACK_ON , p - > i ) ;
P_DoQuote ( 53 , p ) ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
else P_DoQuote ( 50 , p ) ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( sb_snum , SK_TURNAROUND ) & & p - > one_eighty_count = = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , 0 , p - > i , snum ) ;
X_OnEvent ( EVENT_TURNAROUND , p - > i , snum , - 1 ) ;
if ( Gv_GetVar ( g_iReturnVarID , p - > i , snum ) = = 0 )
2006-04-13 20:47:06 +00:00
{
p - > one_eighty_count = - 1024 ;
}
}
}
}
2008-11-20 14:06:36 +00:00
int A_CheckHitSprite ( int i , short * hitsp )
2006-12-10 06:49:01 +00:00
{
2007-12-12 17:42:14 +00:00
int sx , sy , sz , zoff ;
2006-12-10 06:49:01 +00:00
short sect , hw ;
2008-11-20 14:06:36 +00:00
if ( A_CheckEnemySprite ( & sprite [ i ] ) )
2006-12-10 06:49:01 +00:00
zoff = ( 42 < < 8 ) ;
else if ( PN = = APLAYER ) zoff = ( 39 < < 8 ) ;
else zoff = 0 ;
hitscan ( SX , SY , SZ - zoff , SECT ,
sintable [ ( SA + 512 ) & 2047 ] ,
sintable [ SA & 2047 ] ,
0 , & sect , & hw , hitsp , & sx , & sy , & sz , CLIPMASK1 ) ;
2008-11-20 14:06:36 +00:00
if ( hw > = 0 & & ( wall [ hw ] . cstat & 16 ) & & A_CheckEnemySprite ( & sprite [ i ] ) )
2006-12-10 06:49:01 +00:00
return ( ( 1 < < 30 ) ) ;
return ( FindDistance2D ( sx - SX , sy - SY ) ) ;
}
2008-11-20 14:06:36 +00:00
static int hitawall ( DukePlayer_t * p , short * hitw )
2006-12-10 06:49:01 +00:00
{
2007-12-12 17:42:14 +00:00
int sx , sy , sz ;
2006-12-10 06:49:01 +00:00
short sect , hs ;
hitscan ( p - > posx , p - > posy , p - > posz , p - > cursectnum ,
sintable [ ( p - > ang + 512 ) & 2047 ] ,
sintable [ p - > ang & 2047 ] ,
0 , & sect , hitw , & hs , & sx , & sy , & sz , CLIPMASK0 ) ;
return ( FindDistance2D ( sx - p - > posx , sy - p - > posy ) ) ;
}
2006-12-20 03:27:25 +00:00
void checksectors ( int snum )
2006-04-13 20:47:06 +00:00
{
2007-12-12 17:42:14 +00:00
int i = - 1 , oldz ;
2008-11-20 14:06:36 +00:00
DukePlayer_t * p = g_player [ snum ] . ps ;
2006-04-13 20:47:06 +00:00
short j , hitscanwall ;
2008-07-29 07:14:54 +00:00
if ( p - > cursectnum > - 1 )
2008-07-30 02:51:32 +00:00
switch ( sector [ p - > cursectnum ] . lotag )
2006-11-16 03:02:42 +00:00
{
2008-07-30 02:51:32 +00:00
case 32767 :
2006-11-15 01:16:55 +00:00
sector [ p - > cursectnum ] . lotag = 0 ;
2008-11-20 14:06:36 +00:00
P_DoQuote ( 9 , p ) ;
2008-07-30 02:51:32 +00:00
p - > secret_rooms + + ;
return ;
case - 1 :
2008-11-20 14:06:36 +00:00
TRAVERSE_CONNECT ( i )
g_player [ i ] . ps - > gm = MODE_EOL ;
2008-07-30 02:51:32 +00:00
sector [ p - > cursectnum ] . lotag = 0 ;
if ( ud . from_bonus )
{
ud . level_number = ud . from_bonus ;
ud . m_level_number = ud . level_number ;
ud . from_bonus = 0 ;
}
else
{
ud . level_number + + ;
if ( ud . level_number > MAXLEVELS - 1 )
ud . level_number = 0 ;
ud . m_level_number = ud . level_number ;
}
return ;
case - 2 :
sector [ p - > cursectnum ] . lotag = 0 ;
p - > timebeforeexit = 26 * 8 ;
p - > customexitsound = sector [ p - > cursectnum ] . hitag ;
return ;
default :
if ( sector [ p - > cursectnum ] . lotag > = 10000 & & sector [ p - > cursectnum ] . lotag < 16383 )
{
2008-11-20 14:06:36 +00:00
if ( snum = = screenpeek | | ( GametypeFlags [ ud . coop ] & GAMETYPE_COOPSOUND ) )
A_PlaySound ( sector [ p - > cursectnum ] . lotag - 10000 , p - > i ) ;
2008-07-30 02:51:32 +00:00
sector [ p - > cursectnum ] . lotag = 0 ;
}
break ;
2006-04-13 20:47:06 +00:00
2008-07-30 02:51:32 +00:00
}
2006-04-13 20:47:06 +00:00
//After this point the the player effects the map with space
2006-11-13 23:12:47 +00:00
if ( p - > gm & MODE_TYPE | | sprite [ p - > i ] . extra < = 0 ) return ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( g_player [ snum ] . sync - > bits , SK_OPEN ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
Gv_SetVar ( g_iReturnVarID , 0 , p - > i , snum ) ;
X_OnEvent ( EVENT_USE , p - > i , snum , - 1 ) ;
if ( Gv_GetVar ( g_iReturnVarID , p - > i , snum ) ! = 0 )
g_player [ snum ] . sync - > bits & = ~ BIT ( SK_OPEN ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
if ( ud . cashman & & TEST_SYNC_KEY ( g_player [ snum ] . sync - > bits , SK_OPEN ) )
A_SpawnMultiple ( p - > i , MONEY , 2 ) ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( p - > newowner > = 0 )
2006-04-13 20:47:06 +00:00
{
2007-08-27 06:46:31 +00:00
if ( klabs ( g_player [ snum ] . sync - > svel ) > 768 | | klabs ( g_player [ snum ] . sync - > fvel ) > 768 )
2006-04-13 20:47:06 +00:00
{
i = - 1 ;
goto CLEARCAMERAS ;
}
}
2008-11-20 14:06:36 +00:00
if ( ! TEST_SYNC_KEY ( g_player [ snum ] . sync - > bits , SK_OPEN ) & & ! TEST_SYNC_KEY ( g_player [ snum ] . sync - > bits , SK_ESCAPE ) )
2006-04-13 20:47:06 +00:00
p - > toggle_key_flag = 0 ;
2006-11-13 23:12:47 +00:00
else if ( ! p - > toggle_key_flag )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( g_player [ snum ] . sync - > bits , SK_ESCAPE ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( p - > newowner > = 0 )
2006-04-13 20:47:06 +00:00
{
i = - 1 ;
goto CLEARCAMERAS ;
}
return ;
}
neartagsprite = - 1 ;
p - > toggle_key_flag = 1 ;
hitscanwall = - 1 ;
i = hitawall ( p , & hitscanwall ) ;
2006-11-13 23:12:47 +00:00
if ( i < 1280 & & hitscanwall > = 0 & & wall [ hitscanwall ] . overpicnum = = MIRROR )
2008-11-20 14:06:36 +00:00
if ( wall [ hitscanwall ] . lotag > 0 & & ! A_CheckSoundPlaying ( p - > i , wall [ hitscanwall ] . lotag ) & & snum = = screenpeek )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
A_PlaySound ( wall [ hitscanwall ] . lotag , p - > i ) ;
2006-04-13 20:47:06 +00:00
return ;
}
2006-11-14 21:35:50 +00:00
if ( hitscanwall > = 0 & & ( wall [ hitscanwall ] . cstat & 16 ) )
2006-11-13 23:12:47 +00:00
switch ( wall [ hitscanwall ] . overpicnum )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
default :
if ( wall [ hitscanwall ] . lotag )
return ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
if ( p - > newowner > = 0 )
2006-04-13 20:47:06 +00:00
neartag ( p - > oposx , p - > oposy , p - > oposz , sprite [ p - > i ] . sectnum , p - > oang , & neartagsector , & neartagwall , & neartagsprite , & neartaghitdist , 1280L , 1 ) ;
else
{
neartag ( p - > posx , p - > posy , p - > posz , sprite [ p - > i ] . sectnum , p - > oang , & neartagsector , & neartagwall , & neartagsprite , & neartaghitdist , 1280L , 1 ) ;
2006-11-13 23:12:47 +00:00
if ( neartagsprite = = - 1 & & neartagwall = = - 1 & & neartagsector = = - 1 )
2006-04-13 20:47:06 +00:00
neartag ( p - > posx , p - > posy , p - > posz + ( 8 < < 8 ) , sprite [ p - > i ] . sectnum , p - > oang , & neartagsector , & neartagwall , & neartagsprite , & neartaghitdist , 1280L , 1 ) ;
2006-11-13 23:12:47 +00:00
if ( neartagsprite = = - 1 & & neartagwall = = - 1 & & neartagsector = = - 1 )
2006-04-13 20:47:06 +00:00
neartag ( p - > posx , p - > posy , p - > posz + ( 16 < < 8 ) , sprite [ p - > i ] . sectnum , p - > oang , & neartagsector , & neartagwall , & neartagsprite , & neartaghitdist , 1280L , 1 ) ;
2006-11-13 23:12:47 +00:00
if ( neartagsprite = = - 1 & & neartagwall = = - 1 & & neartagsector = = - 1 )
2006-04-13 20:47:06 +00:00
{
neartag ( p - > posx , p - > posy , p - > posz + ( 16 < < 8 ) , sprite [ p - > i ] . sectnum , p - > oang , & neartagsector , & neartagwall , & neartagsprite , & neartaghitdist , 1280L , 3 ) ;
2006-11-13 23:12:47 +00:00
if ( neartagsprite > = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ sprite [ neartagsprite ] . picnum ] )
2006-04-13 20:47:06 +00:00
{
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 :
case TOUGHGAL__STATIC :
return ;
2006-04-13 20:47:06 +00:00
}
}
neartagsprite = - 1 ;
neartagwall = - 1 ;
neartagsector = - 1 ;
}
}
2006-11-14 21:35:50 +00:00
if ( p - > newowner = = - 1 & & neartagsprite = = - 1 & & neartagsector = = - 1 & & neartagwall = = - 1 )
if ( isanunderoperator ( sector [ sprite [ p - > i ] . sectnum ] . lotag ) )
2006-04-13 20:47:06 +00:00
neartagsector = sprite [ p - > i ] . sectnum ;
2006-11-14 21:35:50 +00:00
if ( neartagsector > = 0 & & ( sector [ neartagsector ] . lotag & 16384 ) )
2006-04-13 20:47:06 +00:00
return ;
2006-11-14 21:35:50 +00:00
if ( neartagsprite = = - 1 & & neartagwall = = - 1 )
if ( sector [ p - > cursectnum ] . lotag = = 2 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
oldz = A_CheckHitSprite ( p - > i , & neartagsprite ) ;
2006-11-13 23:12:47 +00:00
if ( oldz > 1280 ) neartagsprite = - 1 ;
2006-04-13 20:47:06 +00:00
}
2006-11-13 23:12:47 +00:00
if ( neartagsprite > = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( P_ActivateSwitch ( snum , neartagsprite , 1 ) ) return ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
switch ( DynamicTileMap [ sprite [ neartagsprite ] . picnum ] )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case TOILET__STATIC :
case STALL__STATIC :
if ( p - > last_pissed_time = = 0 )
{
2008-11-20 14:06:36 +00:00
if ( ud . lockout = = 0 ) A_PlaySound ( DUKE_URINATE , p - > i ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
p - > last_pissed_time = 26 * 220 ;
p - > transporter_hold = 29 * 2 ;
if ( p - > holster_weapon = = 0 )
{
p - > holster_weapon = 1 ;
p - > weapon_pos = - 1 ;
2006-04-13 20:47:06 +00:00
}
2007-08-27 23:11:49 +00:00
if ( sprite [ p - > i ] . extra < = ( p - > max_player_health - ( p - > max_player_health / 10 ) ) )
2006-11-16 03:02:42 +00:00
{
2007-08-27 23:11:49 +00:00
sprite [ p - > i ] . extra + = p - > max_player_health / 10 ;
2006-11-16 03:02:42 +00:00
p - > last_extra = sprite [ p - > i ] . extra ;
}
2007-08-27 23:11:49 +00:00
else if ( sprite [ p - > i ] . extra < p - > max_player_health )
sprite [ p - > i ] . extra = p - > max_player_health ;
2006-11-16 03:02:42 +00:00
}
2008-11-20 14:06:36 +00:00
else if ( ! A_CheckSoundPlaying ( neartagsprite , FLUSH_TOILET ) )
A_PlaySound ( FLUSH_TOILET , neartagsprite ) ;
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case NUKEBUTTON__STATIC :
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
hitawall ( p , & j ) ;
if ( j > = 0 & & wall [ j ] . overpicnum = = 0 )
2008-11-20 14:06:36 +00:00
if ( ActorExtra [ neartagsprite ] . temp_data [ 0 ] = = 0 )
2006-11-16 03:02:42 +00:00
{
if ( ud . noexits & & ud . multimode > 1 )
2006-11-15 01:16:55 +00:00
{
2008-11-20 14:06:36 +00:00
ActorExtra [ p - > i ] . picnum = NUKEBUTTON ;
ActorExtra [ p - > i ] . extra = 250 ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
else
2006-11-15 01:16:55 +00:00
{
2008-11-20 14:06:36 +00:00
ActorExtra [ neartagsprite ] . temp_data [ 0 ] = 1 ;
2006-11-16 03:02:42 +00:00
sprite [ neartagsprite ] . owner = p - > i ;
p - > buttonpalette = sprite [ neartagsprite ] . pal ;
if ( p - > buttonpalette )
ud . secretlevel = sprite [ neartagsprite ] . lotag ;
else ud . secretlevel = 0 ;
2006-11-15 01:16:55 +00:00
}
}
2006-11-16 03:02:42 +00:00
return ;
case WATERFOUNTAIN__STATIC :
2008-11-20 14:06:36 +00:00
if ( ActorExtra [ neartagsprite ] . temp_data [ 0 ] ! = 1 )
2006-11-13 23:12:47 +00:00
{
2008-11-20 14:06:36 +00:00
ActorExtra [ neartagsprite ] . temp_data [ 0 ] = 1 ;
2006-11-16 03:02:42 +00:00
sprite [ neartagsprite ] . owner = p - > i ;
2006-11-15 01:16:55 +00:00
2007-08-27 23:11:49 +00:00
if ( sprite [ p - > i ] . extra < p - > max_player_health )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
sprite [ p - > i ] . extra + + ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( DUKE_DRINKING , p - > i ) ;
2006-11-16 03:02:42 +00:00
}
}
return ;
case PLUG__STATIC :
2008-11-20 14:06:36 +00:00
A_PlaySound ( SHORT_CIRCUIT , p - > i ) ;
sprite [ p - > i ] . extra - = 2 + ( krand ( ) & 3 ) ;
2006-11-16 03:02:42 +00:00
p - > pals [ 0 ] = 48 ;
p - > pals [ 1 ] = 48 ;
p - > pals [ 2 ] = 64 ;
p - > pals_time = 32 ;
break ;
case VIEWSCREEN__STATIC :
case VIEWSCREEN2__STATIC :
{
2008-11-20 14:06:36 +00:00
i = headspritestat [ STAT_ACTOR ] ;
2006-11-16 03:02:42 +00:00
while ( i > = 0 )
{
if ( PN = = CAMERA1 & & SP = = 0 & & sprite [ neartagsprite ] . hitag = = SLT )
{
SP = 1 ; //Using this camera
2008-11-20 14:06:36 +00:00
A_PlaySound ( MONITOR_ACTIVE , neartagsprite ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sprite [ neartagsprite ] . owner = i ;
sprite [ neartagsprite ] . yvel = 1 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
j = p - > cursectnum ;
p - > cursectnum = SECT ;
2008-11-20 14:06:36 +00:00
P_UpdateScreenPal ( p ) ;
2006-11-16 03:02:42 +00:00
p - > cursectnum = j ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
// parallaxtype = 2;
p - > newowner = i ;
return ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
i = nextspritestat [ i ] ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
CLEARCAMERAS :
2006-11-16 03:02:42 +00:00
if ( i < 0 )
{
p - > posx = p - > oposx ;
p - > posy = p - > oposy ;
p - > posz = p - > oposz ;
p - > ang = p - > oang ;
p - > newowner = - 1 ;
2006-04-13 20:47:06 +00:00
2006-12-02 06:00:49 +00:00
updatesector ( p - > posx , p - > posy , & p - > cursectnum ) ;
2008-11-20 14:06:36 +00:00
P_UpdateScreenPal ( p ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
i = headspritestat [ STAT_ACTOR ] ;
2006-11-16 03:02:42 +00:00
while ( i > = 0 )
{
if ( PN = = CAMERA1 ) SP = 0 ;
i = nextspritestat [ i ] ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
else if ( p - > newowner > = 0 )
p - > newowner = - 1 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( KB_KeyPressed ( sc_Escape ) )
KB_ClearKeyDown ( sc_Escape ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
}
2008-11-20 14:06:36 +00:00
if ( TEST_SYNC_KEY ( g_player [ snum ] . sync - > bits , SK_OPEN ) = = 0 ) return ;
2006-11-15 01:16:55 +00:00
else if ( p - > newowner > = 0 )
{
i = - 1 ;
goto CLEARCAMERAS ;
}
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( neartagwall = = - 1 & & neartagsector = = - 1 & & neartagsprite = = - 1 )
2008-11-20 14:06:36 +00:00
if ( klabs ( A_GetHitscanRange ( p - > i ) ) < 512 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( ( krand ( ) & 255 ) < 16 )
A_PlaySound ( DUKE_SEARCH2 , p - > i ) ;
else A_PlaySound ( DUKE_SEARCH , p - > i ) ;
2006-04-13 20:47:06 +00:00
return ;
}
2006-11-14 21:35:50 +00:00
if ( neartagwall > = 0 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( wall [ neartagwall ] . lotag > 0 & & CheckDoorTile ( wall [ neartagwall ] . picnum ) )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( hitscanwall = = neartagwall | | hitscanwall = = - 1 )
2008-11-20 14:06:36 +00:00
P_ActivateSwitch ( snum , neartagwall , 0 ) ;
2006-04-13 20:47:06 +00:00
return ;
}
2006-11-13 23:12:47 +00:00
else if ( p - > newowner > = 0 )
2006-04-13 20:47:06 +00:00
{
i = - 1 ;
goto CLEARCAMERAS ;
}
}
2006-11-14 21:35:50 +00:00
if ( neartagsector > = 0 & & ( sector [ neartagsector ] . lotag & 16384 ) = = 0 & & isanearoperator ( sector [ neartagsector ] . lotag ) )
2006-04-13 20:47:06 +00:00
{
i = headspritesect [ neartagsector ] ;
2006-11-13 23:12:47 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( PN = = ACTIVATOR | | PN = = MASTERSWITCH )
2006-04-13 20:47:06 +00:00
return ;
i = nextspritesect [ i ] ;
}
2008-11-20 14:06:36 +00:00
G_OperateSectors ( neartagsector , p - > i ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-14 21:35:50 +00:00
else if ( ( sector [ sprite [ p - > i ] . sectnum ] . lotag & 16384 ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( isanunderoperator ( sector [ sprite [ p - > i ] . sectnum ] . lotag ) )
2006-04-13 20:47:06 +00:00
{
i = headspritesect [ sprite [ p - > i ] . sectnum ] ;
2006-11-13 23:12:47 +00:00
while ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
if ( PN = = ACTIVATOR | | PN = = MASTERSWITCH ) return ;
2006-04-13 20:47:06 +00:00
i = nextspritesect [ i ] ;
}
2008-11-20 14:06:36 +00:00
G_OperateSectors ( sprite [ p - > i ] . sectnum , p - > i ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
else P_ActivateSwitch ( snum , neartagwall , 0 ) ;
2006-04-13 20:47:06 +00:00
}
}
}