2006-04-13 20:47:06 +00:00
//-------------------------------------------------------------------------
/*
2016-02-07 02:38:03 +00:00
Copyright ( C ) 2016 EDuke32 developers and contributors
2006-04-13 20:47:06 +00:00
2010-05-25 10:56:00 +00:00
This file is part of EDuke32 .
2006-04-13 20:47:06 +00:00
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
2014-07-20 08:55:56 +00:00
Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2006-04-13 20:47:06 +00:00
*/
//-------------------------------------------------------------------------
2010-05-25 10:56:00 +00:00
2019-09-21 18:59:54 +00:00
# include "ns.h" // Must come before everything else!
2016-01-08 01:33:35 +00:00
# define actors_c_
2020-03-29 08:41:12 +00:00
# ifndef EDUKE32_STANDALONE
# include <map>
# endif
2006-04-13 20:47:06 +00:00
# include "duke3d.h"
2019-12-16 07:19:57 +00:00
# include "sounds.h"
2020-05-25 15:11:32 +00:00
# include "v_text.h"
# include "printf.h"
2006-04-13 20:47:06 +00:00
2019-09-21 20:53:00 +00:00
BEGIN_DUKE_NS
2010-01-24 23:33:17 +00:00
# if KRANDDEBUG
# define ACTOR_STATIC
# else
# define ACTOR_STATIC static
# endif
2019-09-17 03:20:16 +00:00
uint8_t g_radiusDmgStatnums [ ( MAXSTATUS + 7 ) > > 3 ] ;
2016-08-27 01:41:33 +00:00
# define DELETE_SPRITE_AND_CONTINUE(KX) do { A_DeleteSprite(KX); goto next_sprite; } while (0)
2006-04-13 20:47:06 +00:00
2013-04-15 10:48:05 +00:00
int32_t otherp ;
2016-08-27 01:42:01 +00:00
int G_SetInterpolation ( int32_t * const posptr )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:42:01 +00:00
if ( g_interpolationCnt > = MAXINTERPOLATIONS )
2013-02-16 18:53:00 +00:00
return 1 ;
2016-08-27 01:42:01 +00:00
for ( bssize_t i = 0 ; i < g_interpolationCnt ; + + i )
2013-02-16 18:53:00 +00:00
if ( curipos [ i ] = = posptr )
return 0 ;
2016-08-27 01:42:01 +00:00
curipos [ g_interpolationCnt ] = posptr ;
oldipos [ g_interpolationCnt ] = * posptr ;
g_interpolationCnt + + ;
2013-02-16 18:53:00 +00:00
return 0 ;
2006-04-13 20:47:06 +00:00
}
2018-10-16 06:08:50 +00:00
void G_StopInterpolation ( const int32_t * const posptr )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:42:01 +00:00
for ( bssize_t i = 0 ; i < g_interpolationCnt ; + + i )
2006-04-13 20:47:06 +00:00
if ( curipos [ i ] = = posptr )
{
2016-08-27 01:42:01 +00:00
g_interpolationCnt - - ;
oldipos [ i ] = oldipos [ g_interpolationCnt ] ;
bakipos [ i ] = bakipos [ g_interpolationCnt ] ;
curipos [ i ] = curipos [ g_interpolationCnt ] ;
2006-04-13 20:47:06 +00:00
}
}
2016-08-27 01:42:01 +00:00
void G_DoInterpolations ( int smoothRatio )
2006-04-13 20:47:06 +00:00
{
2009-10-15 16:02:55 +00:00
if ( g_interpolationLock + + )
return ;
2018-10-07 05:23:53 +00:00
int32_t ndelta = 0 ;
2015-03-24 00:40:05 +00:00
2016-08-27 01:42:01 +00:00
for ( bssize_t i = 0 , j = 0 ; i < g_interpolationCnt ; + + i )
2006-04-13 20:47:06 +00:00
{
2018-10-07 05:23:53 +00:00
int32_t const odelta = ndelta ;
2015-03-24 00:40:05 +00:00
bakipos [ i ] = * curipos [ i ] ;
ndelta = ( * curipos [ i ] ) - oldipos [ i ] ;
if ( odelta ! = ndelta )
2016-08-27 01:42:01 +00:00
j = mulscale16 ( ndelta , smoothRatio ) ;
2015-03-24 00:40:05 +00:00
* curipos [ i ] = oldipos [ i ] + j ;
2006-04-13 20:47:06 +00:00
}
}
2012-08-02 10:52:13 +00:00
void G_ClearCameraView ( DukePlayer_t * ps )
{
ps - > newowner = - 1 ;
2015-03-24 00:40:05 +00:00
ps - > pos = ps - > opos ;
2018-03-07 04:21:18 +00:00
ps - > q16ang = ps - > oq16ang ;
2012-08-02 10:52:13 +00:00
updatesector ( ps - > pos . x , ps - > pos . y , & ps - > cursectnum ) ;
P_UpdateScreenPal ( ps ) ;
2016-08-27 01:41:21 +00:00
for ( bssize_t SPRITES_OF ( STAT_ACTOR , k ) )
2012-08-02 10:52:13 +00:00
if ( sprite [ k ] . picnum = = CAMERA1 )
sprite [ k ] . yvel = 0 ;
}
2019-09-08 01:01:09 +00:00
void A_RadiusDamageObject_Internal ( int const spriteNum , int const otherSprite , int const blastRadius , int spriteDist ,
int const zOffset , int const dmg1 , int dmg2 , int dmg3 , int dmg4 )
2013-12-20 18:31:26 +00:00
{
2019-04-18 17:25:24 +00:00
auto const pSprite = ( uspriteptr_t ) & sprite [ spriteNum ] ;
2019-09-08 01:01:09 +00:00
auto const pOther = & sprite [ otherSprite ] ;
2018-04-02 22:00:33 +00:00
2020-03-29 08:41:12 +00:00
# ifndef EDUKE32_STANDALONE
if ( WORLDTOUR & & pSprite - > picnum = = FLAMETHROWERFLAME )
{
2020-05-30 11:01:06 +00:00
// enemies in WT don't damage other enemies of the same type with FLAMETHROWERFLAME
if ( sprite [ pSprite - > owner ] . picnum = = pOther - > picnum & & pOther - > picnum ! = APLAYER )
2020-03-29 08:41:12 +00:00
return ;
}
# endif
2020-03-29 08:41:03 +00:00
2019-09-08 01:01:09 +00:00
// DEFAULT, ZOMBIEACTOR, MISC
2020-03-29 08:41:03 +00:00
if ( pOther - > statnum = = STAT_DEFAULT | | pOther - > statnum = = STAT_ZOMBIEACTOR | | pOther - > statnum = = STAT_MISC
# ifndef EDUKE32_STANDALONE
| | ( ! FURY & & AFLAMABLE ( pOther - > picnum ) )
# endif
)
2019-09-08 01:01:09 +00:00
{
2018-04-02 22:00:33 +00:00
# ifndef EDUKE32_STANDALONE
2019-09-08 01:01:09 +00:00
if ( pSprite - > picnum ! = SHRINKSPARK | | ( pOther - > cstat & 257 ) )
2018-04-02 22:00:33 +00:00
# endif
2019-09-08 01:01:09 +00:00
{
if ( A_CheckEnemySprite ( pOther ) & & ! cansee ( pOther - > x , pOther - > y , pOther - > z + zOffset , pOther - > sectnum , pSprite - > x , pSprite - > y , pSprite - > z + zOffset , pSprite - > sectnum ) )
return ;
2006-04-13 20:47:06 +00:00
2019-09-08 13:51:12 +00:00
# ifndef EDUKE32_STANDALONE
if ( ! FURY )
A_DamageObject_Duke3D ( otherSprite , spriteNum ) ;
else
# endif
A_DamageObject_Generic ( otherSprite , spriteNum ) ;
2019-09-08 01:01:09 +00:00
}
}
else if ( pOther - > extra > = 0 & & ( uspriteptr_t ) pOther ! = pSprite & & ( ( pOther - > cstat & 257 ) | |
# ifndef EDUKE32_STANDALONE
pOther - > picnum = = TRIPBOMB | | pOther - > picnum = = QUEBALL | | pOther - > picnum = = STRIPEBALL | | pOther - > picnum = = DUKELYINGDEAD | |
# endif
A_CheckEnemySprite ( pOther ) ) )
2006-04-13 20:47:06 +00:00
{
2019-09-08 01:01:09 +00:00
# ifndef EDUKE32_STANDALONE
if ( ( pSprite - > picnum = = SHRINKSPARK & & pOther - > picnum ! = SHARK & & ( otherSprite = = pSprite - > owner | | pOther - > xrepeat < 24 ) )
| | ( pSprite - > picnum = = MORTER & & otherSprite = = pSprite - > owner ) )
return ;
# endif
if ( spriteDist > = blastRadius | | ! cansee ( pOther - > x , pOther - > y , pOther - > z - ZOFFSET3 , pOther - > sectnum ,
pSprite - > x , pSprite - > y , pSprite - > z - ZOFFSET4 , pSprite - > sectnum ) )
return ;
2013-04-15 10:48:09 +00:00
2019-09-08 01:01:09 +00:00
if ( A_CheckSpriteFlags ( otherSprite , SFLAG_DAMAGEEVENT ) )
if ( VM_OnEventWithReturn ( EVENT_DAMAGESPRITE , spriteNum , - 1 , otherSprite ) < 0 )
return ;
2006-04-13 20:47:06 +00:00
2019-09-08 01:01:09 +00:00
auto & dmgActor = actor [ otherSprite ] ;
dmgActor . ang = getangle ( pOther - > x - pSprite - > x , pOther - > y - pSprite - > y ) ;
if ( ( pOther - > extra > 0 & & ( ( A_CheckSpriteFlags ( spriteNum , SFLAG_PROJECTILE ) & & SpriteProjectile [ spriteNum ] . workslike & PROJECTILE_RADIUS_PICNUM )
# ifndef EDUKE32_STANDALONE
| | pSprite - > picnum = = RPG
# endif
) )
# ifndef EDUKE32_STANDALONE
| | ( pSprite - > picnum = = SHRINKSPARK )
# endif
)
dmgActor . picnum = pSprite - > picnum ;
2020-03-29 08:41:12 +00:00
# ifndef EDUKE32_STANDALONE
else if ( WORLDTOUR & & ( pSprite - > picnum = = FLAMETHROWERFLAME | | pSprite - > picnum = = LAVAPOOL
| | ( pSprite - > picnum = = FIREBALL & & sprite [ pSprite - > owner ] . picnum = = APLAYER ) ) )
dmgActor . picnum = FLAMETHROWERFLAME ;
# endif
2020-03-29 08:41:03 +00:00
else
dmgActor . picnum = RADIUSEXPLOSION ;
2019-09-08 01:01:09 +00:00
# ifndef EDUKE32_STANDALONE
2020-03-29 08:41:12 +00:00
if ( pSprite - > picnum ! = SHRINKSPARK & & ( ! WORLDTOUR | | pSprite - > picnum ! = LAVAPOOL ) )
2019-09-08 01:01:09 +00:00
# endif
2006-04-13 20:47:06 +00:00
{
2019-09-08 01:01:09 +00:00
// this is really weird
int const k = blastRadius / 3 ;
2020-01-03 10:21:48 +00:00
int dmgBase = 0 , dmgFuzz = 1 ;
2006-04-13 20:47:06 +00:00
2019-09-08 01:01:09 +00:00
if ( spriteDist < k )
2019-09-08 01:01:33 +00:00
dmgBase = dmg3 , dmgFuzz = dmg4 ;
2019-09-08 01:01:09 +00:00
else if ( spriteDist < k * 2 )
2019-09-08 01:01:33 +00:00
dmgBase = dmg2 , dmgFuzz = dmg3 ;
2019-09-08 01:01:09 +00:00
else if ( spriteDist < blastRadius )
2019-09-08 01:01:33 +00:00
dmgBase = dmg1 , dmgFuzz = dmg2 ;
if ( dmgBase = = dmgFuzz )
+ + dmgFuzz ;
dmgActor . extra = dmgBase + ( krand ( ) % ( dmgFuzz - dmgBase ) ) ;
2013-04-15 10:48:09 +00:00
2019-09-08 01:01:09 +00:00
if ( ! A_CheckSpriteFlags ( otherSprite , SFLAG_NODAMAGEPUSH ) )
2018-04-02 22:00:33 +00:00
{
2019-09-08 01:01:09 +00:00
if ( pOther - > xvel < 0 ) pOther - > xvel = 0 ;
pOther - > xvel + = ( pSprite - > extra < < 2 ) ;
}
2013-04-15 10:48:09 +00:00
2019-09-08 01:01:09 +00:00
if ( A_CheckSpriteFlags ( otherSprite , SFLAG_DAMAGEEVENT ) )
VM_OnEventWithReturn ( EVENT_POSTDAMAGESPRITE , spriteNum , - 1 , otherSprite ) ;
2013-04-15 10:48:09 +00:00
2019-09-08 01:01:09 +00:00
# ifndef EDUKE32_STANDALONE
if ( ! FURY )
{
switch ( DYNAMICTILEMAP ( pOther - > picnum ) )
2018-04-02 22:00:33 +00:00
{
2019-09-08 01:01:09 +00:00
case PODFEM1__STATIC :
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 STATUE__STATIC :
case STATUEFLASH__STATIC :
case SPACEMARINE__STATIC :
case QUEBALL__STATIC :
case STRIPEBALL__STATIC :
2019-09-08 13:51:12 +00:00
A_DamageObject_Duke3D ( otherSprite , spriteNum ) ;
2019-09-08 01:01:09 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
}
2019-09-08 01:01:09 +00:00
# endif
}
# ifndef EDUKE32_STANDALONE
else if ( ! FURY & & pSprite - > extra = = 0 ) dmgActor . extra = 0 ;
# endif
2018-04-02 22:00:33 +00:00
2019-09-08 01:01:09 +00:00
if ( pOther - > picnum ! = RADIUSEXPLOSION & &
pSprite - > owner > = 0 & & sprite [ pSprite - > owner ] . statnum < MAXSTATUS )
{
if ( pOther - > picnum = = APLAYER )
{
auto pPlayer = g_player [ P_GetP ( pOther ) ] . ps ;
2018-04-02 22:00:33 +00:00
2019-09-08 01:01:09 +00:00
if ( pPlayer - > newowner > = 0 )
G_ClearCameraView ( pPlayer ) ;
}
2018-04-02 22:00:33 +00:00
2019-09-08 01:01:09 +00:00
dmgActor . owner = pSprite - > owner ;
2006-04-13 20:47:06 +00:00
}
}
2019-09-08 01:01:09 +00:00
}
2006-04-13 20:47:06 +00:00
2020-01-29 11:37:12 +00:00
# define MAXDAMAGESECTORS 128
2006-04-13 20:47:06 +00:00
2019-09-08 01:01:09 +00:00
void A_RadiusDamage ( int const spriteNum , int const blastRadius , int const dmg1 , int const dmg2 , int const dmg3 , int const dmg4 )
{
// Allow checking for radius damage in EVENT_DAMAGE(SPRITE/WALL/FLOOR/CEILING) events.
decltype ( ud . returnvar ) const parms = { blastRadius , dmg1 , dmg2 , dmg3 , dmg4 } ;
Bmemcpy ( ud . returnvar , parms , sizeof ( parms ) ) ;
2006-04-13 20:47:06 +00:00
2019-09-08 01:01:09 +00:00
auto const pSprite = ( uspriteptr_t ) & sprite [ spriteNum ] ;
2018-04-02 22:00:33 +00:00
2020-05-30 08:34:23 +00:00
int16_t numSectors , sectorList [ MAXDAMAGESECTORS ] ;
uint8_t * const sectorMap = ( uint8_t * ) Balloca ( ( numsectors + 7 ) > > 3 ) ;
bfirst_search_init ( sectorList , sectorMap , & numSectors , numsectors , pSprite - > sectnum ) ;
2006-04-13 20:47:06 +00:00
2018-04-02 22:00:33 +00:00
# ifndef EDUKE32_STANDALONE
2020-05-30 08:34:23 +00:00
// rockets from the Devastator skip propagating damage to other sectors
2019-09-08 01:01:37 +00:00
if ( ! FURY & & ( pSprite - > picnum = = RPG & & pSprite - > xrepeat < 11 ) )
2020-05-30 08:34:23 +00:00
goto wallsfinished ;
2018-04-02 22:00:33 +00:00
# endif
2020-05-30 08:34:23 +00:00
uint8_t * wallTouched ;
wallTouched = ( uint8_t * ) Balloca ( ( numwalls + 7 ) > > 3 ) ;
Bmemset ( wallTouched , 0 , ( numwalls + 7 ) > > 3 ) ;
uint8_t * wallCanSee ;
wallCanSee = ( uint8_t * ) Balloca ( ( numwalls + 7 ) > > 3 ) ;
Bmemset ( wallCanSee , 0 , ( numwalls + 7 ) > > 3 ) ;
2019-09-08 01:01:09 +00:00
for ( int sectorCount = 0 ; sectorCount < numSectors ; + + sectorCount )
{
2020-01-29 11:37:12 +00:00
int const sectorNum = sectorList [ sectorCount ] ;
2019-09-08 01:01:33 +00:00
auto const & listSector = sector [ sectorNum ] ;
2018-04-02 22:00:33 +00:00
2020-05-30 08:34:23 +00:00
vec2_t closest = { } ;
int32_t distance = INT32_MAX ;
2006-04-13 20:47:06 +00:00
2019-09-08 01:01:33 +00:00
int const startWall = listSector . wallptr ;
int const endWall = listSector . wallnum + startWall ;
2006-04-13 20:47:06 +00:00
2019-09-08 01:01:09 +00:00
int w = startWall ;
2019-09-08 01:01:33 +00:00
for ( auto pWall = ( uwallptr_t ) & wall [ startWall ] ; w < endWall ; + + w , + + pWall )
2019-09-08 01:01:09 +00:00
{
2020-05-30 08:34:23 +00:00
vec2_t p = pSprite - > pos . vec2 ;
int32_t walldist = blastRadius - 1 ;
if ( bitmap_test ( wallTouched , w ) = = 0 )
walldist = getwalldist ( p , w , & p ) ;
if ( walldist < blastRadius )
{
if ( walldist < distance )
{
distance = walldist ;
closest = p ;
}
2012-08-02 10:52:13 +00:00
2020-01-29 11:37:12 +00:00
int16_t aSector = sectorNum ;
vec3_t vect = { ( ( ( pWall - > x + wall [ pWall - > point2 ] . x ) > > 1 ) + pSprite - > x ) > > 1 ,
( ( ( pWall - > y + wall [ pWall - > point2 ] . y ) > > 1 ) + pSprite - > y ) > > 1 , pSprite - > z } ;
2018-04-02 22:00:33 +00:00
2020-01-29 11:37:12 +00:00
updatesector ( vect . x , vect . y , & aSector ) ;
if ( aSector = = - 1 )
2019-09-08 01:01:09 +00:00
{
2020-05-30 08:34:23 +00:00
vect . vec2 = p ;
2020-01-29 11:37:12 +00:00
aSector = sectorNum ;
}
2019-09-08 01:01:33 +00:00
2020-05-30 08:34:23 +00:00
bitmap_set ( wallTouched , w ) ;
if ( pWall - > nextwall ! = - 1 )
bitmap_set ( wallTouched , pWall - > nextwall ) ;
if ( bitmap_test ( wallCanSee , w ) = = 1 | | cansee ( vect . x , vect . y , vect . z , aSector , pSprite - > x , pSprite - > y , pSprite - > z , pSprite - > sectnum ) )
{
bitmap_set ( wallCanSee , w ) ;
if ( pWall - > nextwall ! = - 1 )
bitmap_set ( wallCanSee , pWall - > nextwall ) ;
A_DamageWall_Internal ( spriteNum , w , { p . x , p . y , pSprite - > z } , pSprite - > picnum ) ;
}
2019-09-17 03:20:00 +00:00
2020-01-29 11:37:12 +00:00
int const nextSector = pWall - > nextsector ;
2019-09-08 13:51:16 +00:00
2020-01-29 11:37:12 +00:00
if ( nextSector > = 0 )
bfirst_search_try ( sectorList , sectorMap , & numSectors , nextSector ) ;
if ( numSectors = = MAXDAMAGESECTORS )
{
2020-04-11 21:45:45 +00:00
Printf ( " Sprite %d tried to damage more than %d sectors! \n " , spriteNum , MAXDAMAGESECTORS ) ;
2020-05-30 08:34:23 +00:00
goto wallsfinished ;
2006-04-13 20:47:06 +00:00
}
2019-09-08 01:01:09 +00:00
}
}
2020-05-30 08:34:23 +00:00
if ( distance > = blastRadius )
continue ;
int32_t floorZ , ceilZ ;
getzsofslope ( sectorNum , closest . x , closest . y , & ceilZ , & floorZ ) ;
if ( ( ( ceilZ - pSprite - > z ) > > 8 ) < blastRadius )
Sect_DamageCeiling_Internal ( spriteNum , sectorNum ) ;
if ( ( ( pSprite - > z - floorZ ) > > 8 ) < blastRadius )
Sect_DamageFloor_Internal ( spriteNum , sectorNum ) ;
}
wallsfinished :
2019-09-08 01:01:09 +00:00
int const randomZOffset = - ZOFFSET2 + ( krand ( ) & ( ZOFFSET5 - 1 ) ) ;
for ( int sectorCount = 0 ; sectorCount < numSectors ; + + sectorCount )
{
int damageSprite = headspritesect [ sectorList [ sectorCount ] ] ;
while ( damageSprite > = 0 )
{
int const nextSprite = nextspritesect [ damageSprite ] ;
2019-09-08 01:01:33 +00:00
auto pDamage = & sprite [ damageSprite ] ;
2019-09-08 01:01:09 +00:00
2019-09-17 03:20:16 +00:00
if ( bitmap_test ( g_radiusDmgStatnums , pDamage - > statnum ) )
2019-09-08 01:01:09 +00:00
{
2020-05-30 08:34:23 +00:00
int spriteDist = dist ( pSprite , pDamage ) ;
if ( pDamage - > picnum = = APLAYER )
spriteDist = FindDistance3D ( pSprite - > x - pDamage - > x , pSprite - > y - pDamage - > y , pSprite - > z - ( pDamage - > z - PHEIGHT ) ) ;
2019-09-08 01:01:09 +00:00
if ( spriteDist < blastRadius )
A_RadiusDamageObject_Internal ( spriteNum , damageSprite , blastRadius , spriteDist , randomZOffset , dmg1 , dmg2 , dmg3 , dmg4 ) ;
}
damageSprite = nextSprite ;
2006-04-13 20:47:06 +00:00
}
}
}
2013-04-15 10:48:05 +00:00
// Maybe do a projectile transport via an SE7.
// <spritenum>: the projectile
// <i>: the SE7
// <fromunderp>: below->above change?
2019-04-18 17:25:24 +00:00
static int32_t Proj_MaybeDoTransport ( int32_t spriteNum , uspriteptr_t const pSEffector , int32_t fromunderp , int32_t daz )
2013-04-15 10:48:05 +00:00
{
2019-08-27 13:39:54 +00:00
if ( ( ( int32_t ) totalclock & UINT8_MAX ) = = actor [ spriteNum ] . lasttransport )
2015-03-24 00:40:05 +00:00
return 0 ;
2019-04-18 17:25:24 +00:00
auto const pSprite = & sprite [ spriteNum ] ;
auto const otherse = ( uspriteptr_t ) & sprite [ pSEffector - > owner ] ;
2019-08-27 13:39:54 +00:00
actor [ spriteNum ] . lasttransport = ( ( int32_t ) totalclock & UINT8_MAX ) ;
2013-04-15 10:48:05 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > x + = ( otherse - > x - pSEffector - > x ) ;
pSprite - > y + = ( otherse - > y - pSEffector - > y ) ;
2013-04-15 10:48:05 +00:00
2016-08-27 01:40:35 +00:00
// above->below
pSprite - > z = ( ! fromunderp ) ? sector [ otherse - > sectnum ] . ceilingz - daz + sector [ pSEffector - > sectnum ] . floorz
: sector [ otherse - > sectnum ] . floorz - daz + sector [ pSEffector - > sectnum ] . ceilingz ;
// below->above
2013-04-15 10:48:05 +00:00
2019-06-25 11:28:25 +00:00
actor [ spriteNum ] . bpos = sprite [ spriteNum ] . pos ;
2016-08-27 01:40:35 +00:00
changespritesect ( spriteNum , otherse - > sectnum ) ;
2013-04-15 10:48:18 +00:00
2015-03-24 00:40:05 +00:00
return 1 ;
2013-04-15 10:48:05 +00:00
}
// Check whether sprite <s> is on/in a non-SE7 water sector.
// <othersectptr>: if not NULL, the sector on the other side.
2019-04-18 17:25:24 +00:00
int A_CheckNoSE7Water ( uspriteptr_t const pSprite , int sectNum , int sectLotag , int32_t * pOther )
2013-04-15 10:48:05 +00:00
{
2016-08-27 01:40:35 +00:00
if ( sectLotag = = ST_1_ABOVE_WATER | | sectLotag = = ST_2_UNDERWATER )
2013-04-15 10:48:05 +00:00
{
2016-08-27 01:40:35 +00:00
int const otherSect =
yax_getneighborsect ( pSprite - > x , pSprite - > y , sectNum , sectLotag = = ST_1_ABOVE_WATER ? YAX_FLOOR : YAX_CEILING ) ;
int const otherLotag = ( sectLotag = = ST_1_ABOVE_WATER ) ? ST_2_UNDERWATER : ST_1_ABOVE_WATER ;
2013-04-15 10:48:05 +00:00
// If submerging, the lower sector MUST have lotag 2.
// If emerging, the upper sector MUST have lotag 1.
// This way, the x/y coordinates where above/below water
// changes can happen are the same.
2016-08-27 01:40:35 +00:00
if ( otherSect > = 0 & & sector [ otherSect ] . lotag = = otherLotag )
2013-04-15 10:48:05 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pOther )
* pOther = otherSect ;
2013-04-15 10:48:05 +00:00
return 1 ;
}
}
return 0 ;
}
// Check whether to do a z position update of sprite <spritenum>.
// Returns:
// 0 if no.
// 1 if yes, but stayed inside [actor[].ceilingz+1, actor[].floorz].
2013-04-15 10:48:20 +00:00
// <0 if yes, but passed a TROR no-SE7 water boundary. -returnvalue-1 is the
// other-side sector number.
2019-07-16 07:00:24 +00:00
static int32_t A_CheckNeedZUpdate ( int32_t spriteNum , int32_t zChange , int32_t * pZcoord ,
int32_t * ceilhit , int32_t * florhit )
2013-04-15 10:48:05 +00:00
{
2016-08-27 01:40:35 +00:00
if ( zChange = = 0 )
return 0 ;
2013-04-15 10:48:05 +00:00
2019-04-18 17:25:24 +00:00
auto const pSprite = ( uspriteptr_t ) & sprite [ spriteNum ] ;
int const newZ = pSprite - > z + ( zChange > > 1 ) ;
2013-04-15 10:48:05 +00:00
2016-08-27 01:40:35 +00:00
* pZcoord = newZ ;
2013-04-15 10:48:05 +00:00
2019-05-19 03:55:40 +00:00
int const clipDist = A_GetClipdist ( spriteNum , - 1 ) ;
2019-07-16 07:00:24 +00:00
VM_GetZRange ( spriteNum , ceilhit , florhit , pSprite - > statnum = = STAT_PROJECTILE ? clipDist < < 3 : clipDist ) ;
2019-03-19 17:10:17 +00:00
2016-08-27 01:40:35 +00:00
if ( newZ > actor [ spriteNum ] . ceilingz & & newZ < = actor [ spriteNum ] . floorz )
2013-04-15 10:48:05 +00:00
return 1 ;
# ifdef YAX_ENABLE
2016-08-27 01:40:35 +00:00
int const sectNum = pSprite - > sectnum ;
int const sectLotag = sector [ sectNum ] . lotag ;
int32_t otherSect ;
2013-04-15 10:48:05 +00:00
2016-06-21 00:34:07 +00:00
// Non-SE7 water.
// PROJECTILE_CHSECT
2016-08-27 01:40:35 +00:00
if ( ( zChange < 0 & & sectLotag = = ST_2_UNDERWATER ) | | ( zChange > 0 & & sectLotag = = ST_1_ABOVE_WATER ) )
{
if ( A_CheckNoSE7Water ( pSprite , sprite [ spriteNum ] . sectnum , sectLotag , & otherSect ) )
2016-06-21 00:34:07 +00:00
{
2016-08-27 01:40:35 +00:00
A_Spawn ( spriteNum , WATERSPLASH2 ) ;
2016-06-21 00:34:07 +00:00
// NOTE: Don't tweak its z position afterwards like with
// SE7-induced projectile teleportation. It doesn't look good
// with TROR water.
2013-04-15 10:48:20 +00:00
2016-08-27 01:40:35 +00:00
actor [ spriteNum ] . flags | = SFLAG_DIDNOSE7WATER ;
return - otherSect - 1 ;
2016-06-21 00:34:07 +00:00
}
2016-08-27 01:40:35 +00:00
}
2013-04-15 10:48:05 +00:00
# endif
2019-07-16 07:00:24 +00:00
return 2 ;
2013-04-15 10:48:05 +00:00
}
2019-03-19 17:10:17 +00:00
int A_GetClipdist ( int spriteNum , int clipDist )
2006-04-13 20:47:06 +00:00
{
2019-03-19 17:08:27 +00:00
if ( clipDist < 0 )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pSprite = & sprite [ spriteNum ] ;
2019-09-17 03:20:20 +00:00
int const isEnemy = A_CheckEnemySprite ( pSprite ) ;
2019-03-19 17:10:17 +00:00
2019-03-19 17:08:27 +00:00
if ( A_CheckSpriteFlags ( spriteNum , SFLAG_REALCLIPDIST ) )
clipDist = pSprite - > clipdist < < 2 ;
2019-08-09 09:28:22 +00:00
else if ( ( pSprite - > cstat & 48 ) = = 16 )
clipDist = 0 ;
2019-03-19 17:08:27 +00:00
else if ( isEnemy )
{
if ( pSprite - > xrepeat > 60 )
clipDist = 1024 ;
2019-03-19 17:08:16 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
else if ( ! FURY & & pSprite - > picnum = = LIZMAN )
2019-03-19 17:08:27 +00:00
clipDist = 292 ;
2019-03-19 17:08:16 +00:00
# endif
2019-03-19 17:08:27 +00:00
else if ( A_CheckSpriteFlags ( spriteNum , SFLAG_BADGUY ) )
clipDist = pSprite - > clipdist < < 2 ;
else
clipDist = 192 ;
}
2015-02-08 18:48:31 +00:00
else
2019-03-19 17:08:27 +00:00
{
if ( pSprite - > statnum = = STAT_PROJECTILE & & ( SpriteProjectile [ spriteNum ] . workslike & PROJECTILE_REALCLIPDIST ) = = 0 )
2019-03-19 17:10:17 +00:00
clipDist = 16 ;
2019-03-19 17:08:27 +00:00
else
clipDist = pSprite - > clipdist < < 2 ;
}
2015-02-08 18:48:31 +00:00
}
2019-03-19 17:10:17 +00:00
return clipDist ;
}
int32_t A_MoveSpriteClipdist ( int32_t spriteNum , vec3_t const * const change , uint32_t clipType , int32_t clipDist )
{
2019-09-17 03:20:20 +00:00
auto const pSprite = & sprite [ spriteNum ] ;
int const isEnemy = A_CheckEnemySprite ( pSprite ) ;
vec2_t const oldPos = pSprite - > pos . vec2 ;
2019-03-19 17:10:17 +00:00
// check to make sure the netcode didn't leave a deleted sprite in the sprite lists.
Bassert ( pSprite - > sectnum < MAXSECTORS ) ;
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY & & ( pSprite - > statnum = = STAT_MISC | | ( isEnemy & & pSprite - > xrepeat < 4 ) ) )
2019-03-19 17:10:17 +00:00
{
pSprite - > x + = change - > x ;
pSprite - > y + = change - > y ;
pSprite - > z + = change - > z ;
if ( isEnemy )
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2019-03-19 17:10:17 +00:00
return 0 ;
}
# endif
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2019-03-19 17:10:17 +00:00
2020-01-29 11:36:24 +00:00
if ( ! ( change - > x | change - > y | change - > z ) )
return 0 ;
2019-03-19 17:10:17 +00:00
clipDist = A_GetClipdist ( spriteNum , clipDist ) ;
2016-08-27 01:40:35 +00:00
int16_t newSectnum = pSprite - > sectnum ;
2018-04-05 04:39:23 +00:00
# ifndef EDUKE32_STANDALONE
2018-04-04 21:06:07 +00:00
int const oldSectnum = newSectnum ;
2018-04-05 04:39:23 +00:00
# endif
2015-02-20 22:10:26 +00:00
2015-02-08 18:48:31 +00:00
// Handle horizontal movement first.
2019-03-19 17:08:27 +00:00
int returnValue ;
2019-03-30 19:36:10 +00:00
int32_t diffZ ;
2019-09-17 03:21:10 +00:00
spriteheightofs ( spriteNum , & diffZ , 1 ) ;
2019-03-19 17:08:27 +00:00
2019-09-17 03:21:10 +00:00
if ( pSprite - > statnum = = STAT_PROJECTILE )
returnValue = clipmovex ( & pSprite - > pos , & newSectnum , change - > x < < 13 , change - > y < < 13 , clipDist , diffZ > > 3 , diffZ > > 3 , clipType , 1 ) ;
else
2019-03-19 17:08:27 +00:00
{
2019-09-17 03:21:10 +00:00
pSprite - > z - = diffZ > > 1 ;
returnValue = clipmove ( & pSprite - > pos , & newSectnum , change - > x < < 13 , change - > y < < 13 , clipDist , ZOFFSET6 , ZOFFSET6 , clipType ) ;
pSprite - > z + = diffZ > > 1 ;
2019-03-19 17:08:27 +00:00
}
2012-10-14 20:41:25 +00:00
2018-12-08 00:40:39 +00:00
// Testing: For some reason the assert below this was tripping for clients
EDUKE32_UNUSED int16_t dbg_ClipMoveSectnum = newSectnum ;
2016-08-27 01:40:35 +00:00
if ( isEnemy )
2012-10-14 20:41:25 +00:00
{
2015-02-08 18:48:31 +00:00
// Handle potential stayput condition (map-provided or hard-coded).
2019-03-19 17:08:27 +00:00
if ( newSectnum < 0 | | ( ( actor [ spriteNum ] . stayput > = 0 & & actor [ spriteNum ] . stayput ! = newSectnum )
2019-09-17 03:20:27 +00:00
| | ( ( g_tile [ pSprite - > picnum ] . flags & SFLAG_NOWATERSECTOR ) & & sector [ newSectnum ] . lotag = = ST_1_ABOVE_WATER )
2018-04-02 22:00:44 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
| | ( ! FURY & & pSprite - > picnum = = BOSS2 & & pSprite - > pal = = 0 & & sector [ newSectnum ] . lotag ! = ST_3 )
| | ( ! FURY & & ( pSprite - > picnum = = BOSS1 | | pSprite - > picnum = = BOSS2 ) & & sector [ newSectnum ] . lotag = = ST_1_ABOVE_WATER )
| | ( ! FURY & & sector [ oldSectnum ] . lotag ! = ST_1_ABOVE_WATER & & sector [ newSectnum ] . lotag = = ST_1_ABOVE_WATER
2018-04-02 22:00:44 +00:00
& & ( pSprite - > picnum = = LIZMAN | | ( pSprite - > picnum = = LIZTROOP & & pSprite - > zvel = = 0 ) ) )
# endif
) )
2006-04-13 20:47:06 +00:00
{
2019-08-07 22:43:48 +00:00
pSprite - > pos . vec2 = oldPos ;
2015-02-08 18:48:31 +00:00
// NOTE: in Duke3D, LIZMAN on water takes on random angle here.
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2012-10-14 20:41:25 +00:00
2016-08-27 01:40:35 +00:00
if ( newSectnum < 0 )
newSectnum = 0 ;
2012-10-14 20:41:25 +00:00
2016-08-27 01:40:35 +00:00
return 16384 + newSectnum ;
2006-04-13 20:47:06 +00:00
}
2009-01-14 10:40:30 +00:00
2016-08-27 01:40:35 +00:00
if ( ( returnValue & 49152 ) > = 32768 & & actor [ spriteNum ] . cgg = = 0 )
pSprite - > ang + = 768 ;
2009-08-28 23:08:00 +00:00
}
2006-04-13 20:47:06 +00:00
2018-12-08 00:40:39 +00:00
EDUKE32_UNUSED int16_t dbg_newSectnum2 = newSectnum ;
2016-08-27 01:40:35 +00:00
if ( newSectnum = = - 1 )
2009-08-28 23:08:00 +00:00
{
2016-08-27 01:40:35 +00:00
newSectnum = pSprite - > sectnum ;
2020-04-11 21:45:45 +00:00
// Printf("%s:%d wtf\n",__FILE__,__LINE__);
2009-08-28 23:08:00 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( newSectnum ! = pSprite - > sectnum )
2009-08-28 23:08:00 +00:00
{
2016-08-27 01:40:35 +00:00
changespritesect ( spriteNum , newSectnum ) ;
2012-10-24 13:21:02 +00:00
// A_GetZLimits(spritenum);
2009-01-13 12:23:18 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
Bassert ( newSectnum = = pSprite - > sectnum ) ;
2012-10-14 20:41:25 +00:00
2019-09-17 03:21:10 +00:00
int newZ = pSprite - > z ;
2019-07-16 07:00:24 +00:00
int32_t ceilhit , florhit ;
int const doZUpdate = change - > z ? A_CheckNeedZUpdate ( spriteNum , change - > z , & newZ , & ceilhit , & florhit ) : 0 ;
2009-08-28 23:08:00 +00:00
2013-04-15 10:48:05 +00:00
// Update sprite's z positions and (for TROR) maybe the sector number.
2019-07-16 07:00:24 +00:00
if ( doZUpdate = = 2 )
2019-07-16 08:38:21 +00:00
{
if ( returnValue = = 0 )
returnValue = change - > z < 0 ? ceilhit : florhit ;
}
2019-07-16 07:00:24 +00:00
else if ( doZUpdate )
2011-05-07 18:23:34 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > z = newZ ;
2011-05-07 18:23:34 +00:00
# ifdef YAX_ENABLE
2016-08-27 01:40:35 +00:00
if ( doZUpdate < 0 )
2013-04-15 10:48:05 +00:00
{
// If we passed a TROR no-SE7 water boundary, signal to the outside
// that the ceiling/floor was not hit. However, this is not enough:
// later, code checks for (retval&49152)!=49152
// [i.e. not "was ceiling or floor hit", but "was no sprite hit"]
// and calls G_WeaponHitCeilingOrFloor() then, so we need to set
2014-02-22 19:38:52 +00:00
// actor[].flags |= SFLAG_DIDNOSE7WATER in A_CheckNeedZUpdate()
2013-04-15 10:48:05 +00:00
// previously.
// XXX: Why is this contrived data flow necessary? (If at all.)
2016-08-27 01:40:35 +00:00
changespritesect ( spriteNum , - doZUpdate - 1 ) ;
2013-04-15 10:48:20 +00:00
return 0 ;
}
2016-08-27 01:40:35 +00:00
if ( yax_getbunch ( newSectnum , ( change - > z > 0 ) ) > = 0
& & ( SECTORFLD ( newSectnum , stat , ( change - > z > 0 ) ) & yax_waltosecmask ( clipType ) ) = = 0 )
2013-04-15 10:48:20 +00:00
{
2019-06-25 11:28:25 +00:00
setspritez ( spriteNum , & pSprite - > pos ) ;
2013-04-15 10:48:05 +00:00
}
2011-05-07 18:23:34 +00:00
# endif
}
2016-08-27 01:40:35 +00:00
else if ( change - > z ! = 0 & & returnValue = = 0 )
returnValue = 16384 + newSectnum ;
2009-07-04 09:28:21 +00:00
2016-08-27 01:40:35 +00:00
if ( returnValue = = 16384 + newSectnum )
{
if ( pSprite - > statnum = = STAT_PROJECTILE )
2009-07-04 09:28:21 +00:00
{
2013-04-15 10:48:18 +00:00
// Projectile sector changes due to transport SEs (SE7_PROJECTILE).
// PROJECTILE_CHSECT
2016-08-27 01:41:21 +00:00
for ( bssize_t SPRITES_OF ( STAT_TRANSPORT , otherSpriteNum ) )
2016-08-27 01:40:35 +00:00
{
if ( sprite [ otherSpriteNum ] . sectnum = = newSectnum )
2009-07-04 09:28:21 +00:00
{
2016-08-27 01:40:35 +00:00
int const sectLotag = sector [ newSectnum ] . lotag ;
2013-04-15 10:48:18 +00:00
2016-08-27 01:40:35 +00:00
if ( sectLotag = = ST_1_ABOVE_WATER & & newZ > = actor [ spriteNum ] . floorz )
2019-04-18 17:25:24 +00:00
if ( Proj_MaybeDoTransport ( spriteNum , ( uspriteptr_t ) & sprite [ otherSpriteNum ] , 0 , newZ ) )
2016-08-27 01:40:35 +00:00
return 0 ;
2013-04-15 10:48:05 +00:00
2016-08-27 01:40:35 +00:00
if ( sectLotag = = ST_2_UNDERWATER & & newZ < = actor [ spriteNum ] . ceilingz )
2019-04-18 17:25:24 +00:00
if ( Proj_MaybeDoTransport ( spriteNum , ( uspriteptr_t ) & sprite [ otherSpriteNum ] , 1 , newZ ) )
2016-08-27 01:40:35 +00:00
return 0 ;
2009-07-04 09:28:21 +00:00
}
2016-08-27 01:40:35 +00:00
}
2009-07-04 09:28:21 +00:00
}
2016-08-27 01:40:35 +00:00
}
2009-01-14 10:40:30 +00:00
2016-08-27 01:40:35 +00:00
return returnValue ;
2006-04-13 20:47:06 +00:00
}
2009-01-09 09:29:17 +00:00
int32_t block_deletesprite = 0 ;
2008-11-16 00:48:02 +00:00
2011-09-06 17:45:21 +00:00
# ifdef POLYMER
2012-10-05 20:48:10 +00:00
static void A_DeleteLight ( int32_t s )
2011-09-06 17:45:21 +00:00
{
2011-12-09 19:11:31 +00:00
if ( actor [ s ] . lightId > = 0 )
polymer_deletelight ( actor [ s ] . lightId ) ;
2011-09-06 17:45:21 +00:00
actor [ s ] . lightId = - 1 ;
actor [ s ] . lightptr = NULL ;
}
void G_Polymer_UnInit ( void )
{
int32_t i ;
for ( i = 0 ; i < MAXSPRITES ; i + + )
2012-10-05 20:48:10 +00:00
A_DeleteLight ( i ) ;
2011-09-06 17:45:21 +00:00
}
# endif
2012-03-11 17:38:13 +00:00
// deletesprite() game wrapper
2016-08-27 01:40:35 +00:00
void A_DeleteSprite ( int spriteNum )
2007-12-20 19:14:38 +00:00
{
2014-10-29 17:05:46 +00:00
if ( EDUKE32_PREDICT_FALSE ( block_deletesprite ) )
2008-11-16 00:48:02 +00:00
{
2020-05-25 15:11:32 +00:00
Printf ( TEXTCOLOR_RED " A_DeleteSprite(): tried to remove sprite %d in EVENT_EGS \n " , spriteNum ) ;
2008-11-16 00:48:02 +00:00
return ;
}
2009-06-05 20:09:13 +00:00
2014-10-25 03:36:34 +00:00
if ( VM_HaveEvent ( EVENT_KILLIT ) )
2008-02-06 11:42:34 +00:00
{
2016-08-27 01:40:35 +00:00
int32_t playerDist ;
int playerNum = A_FindPlayer ( & sprite [ spriteNum ] , & playerDist ) ;
2009-01-02 01:03:41 +00:00
2019-05-19 03:53:25 +00:00
if ( VM_ExecuteEvent ( EVENT_KILLIT , spriteNum , playerNum , playerDist ) )
2008-02-06 11:42:34 +00:00
return ;
}
2009-06-05 20:09:13 +00:00
# ifdef POLYMER
2018-04-12 21:03:12 +00:00
if ( actor [ spriteNum ] . lightptr ! = NULL & & videoGetRenderMode ( ) = = REND_POLYMER )
2016-08-27 01:40:35 +00:00
A_DeleteLight ( spriteNum ) ;
2009-06-05 20:09:13 +00:00
# endif
2014-11-22 12:29:25 +00:00
// AMBIENT_SFX_PLAYING
2016-08-27 01:40:35 +00:00
if ( sprite [ spriteNum ] . picnum = = MUSICANDSFX & & actor [ spriteNum ] . t_data [ 0 ] = = 1 )
S_StopEnvSound ( sprite [ spriteNum ] . lotag , spriteNum ) ;
2013-05-28 19:52:51 +00:00
2018-12-08 00:40:39 +00:00
# ifdef NETCODE_DISABLE
2016-08-27 01:40:35 +00:00
deletesprite ( spriteNum ) ;
2018-12-08 00:40:39 +00:00
# else
Net_DeleteSprite ( spriteNum ) ;
# endif
2009-08-28 23:08:00 +00:00
}
2007-12-20 19:14:38 +00:00
2016-08-27 01:42:01 +00:00
void A_AddToDeleteQueue ( int spriteNum )
2006-04-13 20:47:06 +00:00
{
2018-12-08 00:40:39 +00:00
if ( g_netClient | | ( g_deleteQueueSize = = 0 ) ) // [75] Clients should not use SpriteDeletionQueue[] and just set the sprites invisible immediately in A_DeleteSprite
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
A_DeleteSprite ( spriteNum ) ;
2008-02-06 21:02:11 +00:00
return ;
2006-04-13 20:47:06 +00:00
}
2007-03-11 00:47:32 +00:00
2019-04-18 17:25:30 +00:00
auto & deleteSpriteNum = SpriteDeletionQueue [ g_spriteDeleteQueuePos ] ;
2018-12-15 01:39:03 +00:00
2019-04-18 17:25:30 +00:00
if ( deleteSpriteNum > = 0 & & actor [ deleteSpriteNum ] . flags & SFLAG_QUEUEDFORDELETE )
A_DeleteSprite ( deleteSpriteNum ) ;
deleteSpriteNum = spriteNum ;
actor [ spriteNum ] . flags | = SFLAG_QUEUEDFORDELETE ;
2016-08-27 01:40:35 +00:00
g_spriteDeleteQueuePos = ( g_spriteDeleteQueuePos + 1 ) % g_deleteQueueSize ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:42:01 +00:00
void A_SpawnMultiple ( int spriteNum , int tileNum , int spawnCnt )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pSprite = & sprite [ spriteNum ] ;
2007-03-11 00:47:32 +00:00
2016-08-27 01:40:35 +00:00
for ( ; spawnCnt > 0 ; spawnCnt - - )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
int const j = A_InsertSprite ( pSprite - > sectnum , pSprite - > x , pSprite - > y , pSprite - > z - ( krand ( ) % ( 47 < < 8 ) ) , tileNum , - 32 , 8 ,
8 , krand ( ) & 2047 , 0 , 0 , spriteNum , 5 ) ;
2008-11-20 14:06:36 +00:00
A_Spawn ( - 1 , j ) ;
sprite [ j ] . cstat = krand ( ) & 12 ;
2006-04-13 20:47:06 +00:00
}
}
2018-06-09 20:36:31 +00:00
# ifndef EDUKE32_STANDALONE
2016-08-27 01:42:01 +00:00
void A_DoGuts ( int spriteNum , int tileNum , int spawnCnt )
2006-04-13 20:47:06 +00:00
{
2019-04-18 17:25:24 +00:00
auto const pSprite = ( uspriteptr_t ) & sprite [ spriteNum ] ;
vec2_t repeat = { 32 , 32 } ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
if ( A_CheckEnemySprite ( pSprite ) & & pSprite - > xrepeat < 16 )
repeat . x = repeat . y = 8 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
int gutZ = pSprite - > z - ZOFFSET3 ;
int floorz = getflorzofslope ( pSprite - > sectnum , pSprite - > x , pSprite - > y ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( gutZ > ( floorz - ZOFFSET3 ) )
gutZ = floorz - ZOFFSET3 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum = = COMMANDER )
gutZ - = ( 24 < < 8 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:21 +00:00
for ( bssize_t j = spawnCnt ; j > 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
int const i = A_InsertSprite ( pSprite - > sectnum , pSprite - > x + ( krand ( ) & 255 ) - 128 ,
pSprite - > y + ( krand ( ) & 255 ) - 128 , gutZ - ( krand ( ) & 8191 ) , tileNum , - 32 , repeat . x ,
repeat . y , krand ( ) & 2047 , 48 + ( krand ( ) & 31 ) , - 512 - ( krand ( ) & 2047 ) , spriteNum , 5 ) ;
if ( PN ( i ) = = JIBS2 )
2006-04-13 20:47:06 +00:00
{
sprite [ i ] . xrepeat > > = 2 ;
sprite [ i ] . yrepeat > > = 2 ;
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
sprite [ i ] . pal = pSprite - > pal ;
2006-04-13 20:47:06 +00:00
}
}
2016-08-27 01:42:01 +00:00
void A_DoGutsDir ( int spriteNum , int tileNum , int spawnCnt )
2006-04-13 20:47:06 +00:00
{
2019-04-18 17:25:24 +00:00
auto const s = ( uspriteptr_t ) & sprite [ spriteNum ] ;
vec2_t repeat = { 32 , 32 } ;
2007-03-11 00:47:32 +00:00
2008-11-20 14:06:36 +00:00
if ( A_CheckEnemySprite ( s ) & & s - > xrepeat < 16 )
2016-08-27 01:40:35 +00:00
repeat . x = repeat . y = 8 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
int gutZ = s - > z - ZOFFSET3 ;
int floorZ = getflorzofslope ( s - > sectnum , s - > x , s - > y ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( gutZ > ( floorZ - ZOFFSET3 ) )
gutZ = floorZ - ZOFFSET3 ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
if ( s - > picnum = = COMMANDER )
2016-08-27 01:40:35 +00:00
gutZ - = ( 24 < < 8 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:21 +00:00
for ( bssize_t j = spawnCnt ; j > 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
int const i = A_InsertSprite ( s - > sectnum , s - > x , s - > y , gutZ , tileNum , - 32 , repeat . x , repeat . y , krand ( ) & 2047 ,
256 + ( krand ( ) & 127 ) , - 512 - ( krand ( ) & 2047 ) , spriteNum , 5 ) ;
2008-08-07 10:48:21 +00:00
sprite [ i ] . pal = s - > pal ;
2006-04-13 20:47:06 +00:00
}
}
2018-06-09 20:36:31 +00:00
# endif
2006-04-13 20:47:06 +00:00
2020-05-17 18:51:20 +00:00
static int32_t G_ToggleWallInterpolation ( int32_t wallNum , int32_t setInterpolation )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( setInterpolation )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
return G_SetInterpolation ( & wall [ wallNum ] . x ) | | G_SetInterpolation ( & wall [ wallNum ] . y ) ;
2013-02-16 18:53:00 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
G_StopInterpolation ( & wall [ wallNum ] . x ) ;
G_StopInterpolation ( & wall [ wallNum ] . y ) ;
2013-02-16 18:53:00 +00:00
return 0 ;
2006-04-13 20:47:06 +00:00
}
}
2016-08-27 01:40:35 +00:00
void Sect_ToggleInterpolation ( int sectNum , int setInterpolation )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:21 +00:00
for ( bssize_t j = sector [ sectNum ] . wallptr , endwall = sector [ sectNum ] . wallptr + sector [ sectNum ] . wallnum ; j < endwall ; j + + )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
G_ToggleWallInterpolation ( j , setInterpolation ) ;
int const nextWall = wall [ j ] . nextwall ;
2013-02-16 18:53:00 +00:00
2016-08-27 01:40:35 +00:00
if ( nextWall > = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
G_ToggleWallInterpolation ( nextWall , setInterpolation ) ;
G_ToggleWallInterpolation ( wall [ nextWall ] . point2 , setInterpolation ) ;
2006-04-13 20:47:06 +00:00
}
}
}
2016-08-27 01:40:35 +00:00
static int32_t move_rotfixed_sprite ( int32_t spriteNum , int32_t pivotSpriteNum , int32_t pivotAngle )
2011-06-22 19:12:47 +00:00
{
2016-08-27 01:40:35 +00:00
if ( ( ROTFIXSPR_STATNUMP ( sprite [ spriteNum ] . statnum ) | |
( ( sprite [ spriteNum ] . statnum = = STAT_ACTOR | | sprite [ spriteNum ] . statnum = = STAT_ZOMBIEACTOR ) & &
A_CheckSpriteFlags ( spriteNum , SFLAG_ROTFIXED ) ) ) & &
actor [ spriteNum ] . t_data [ 7 ] = = ( ROTFIXSPR_MAGIC | pivotSpriteNum ) )
2011-06-22 19:12:47 +00:00
{
2019-08-07 22:43:48 +00:00
rotatepoint ( zerovec , * ( vec2_t * ) & actor [ spriteNum ] . t_data [ 8 ] , pivotAngle & 2047 , & sprite [ spriteNum ] . pos . vec2 ) ;
2016-08-27 01:40:35 +00:00
sprite [ spriteNum ] . x + = sprite [ pivotSpriteNum ] . x ;
sprite [ spriteNum ] . y + = sprite [ pivotSpriteNum ] . y ;
2011-06-22 19:12:47 +00:00
return 0 ;
}
return 1 ;
}
2016-08-27 01:40:35 +00:00
void A_MoveSector ( int spriteNum )
2006-04-13 20:47:06 +00:00
{
2014-11-22 12:29:25 +00:00
// T1,T2 and T3 are used for all the sector moving stuff!!!
2016-01-21 19:35:22 +00:00
2019-07-08 00:41:25 +00:00
int32_t playerDist ;
auto const pSprite = & sprite [ spriteNum ] ;
int const playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
int const rotateAngle = VM_OnEvent ( EVENT_MOVESECTOR , spriteNum , playerNum , playerDist , T3 ( spriteNum ) ) ;
int originIdx = T2 ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > x + = ( pSprite - > xvel * ( sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) ) > > 14 ;
pSprite - > y + = ( pSprite - > xvel * ( sintable [ pSprite - > ang & 2047 ] ) ) > > 14 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
int const endWall = sector [ pSprite - > sectnum ] . wallptr + sector [ pSprite - > sectnum ] . wallnum ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:21 +00:00
for ( bssize_t wallNum = sector [ pSprite - > sectnum ] . wallptr ; wallNum < endWall ; wallNum + + )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
vec2_t const origin = g_origins [ originIdx ] ;
vec2_t result ;
rotatepoint ( zerovec , origin , rotateAngle & 2047 , & result ) ;
dragpoint ( wallNum , pSprite - > x + result . x , pSprite - > y + result . y , 0 ) ;
2007-03-01 00:50:59 +00:00
2016-08-27 01:40:35 +00:00
originIdx + + ;
2006-04-13 20:47:06 +00:00
}
}
2013-06-30 20:38:48 +00:00
// NOTE: T5 is AC_ACTION_ID
2020-05-17 17:29:34 +00:00
# define LIGHTRAD_PICOFS(i) (T5(i) ? *(apScript + T5(i)) + (*(apScript + T5(i) + 2)) * AC_CURFRAME(actor[i].t_data) : 0)
2011-12-21 18:40:47 +00:00
2009-06-06 22:30:53 +00:00
// this is the same crap as in game.c's tspr manipulation. puke.
2013-06-30 20:38:48 +00:00
// XXX: may access tilesizy out-of-bounds by bad user code.
2016-08-27 01:41:46 +00:00
# define LIGHTRAD(spriteNum, s) (s->yrepeat * tilesiz[s->picnum + LIGHTRAD_PICOFS(spriteNum)].y)
# define LIGHTRAD2(spriteNum, s) ((s->yrepeat + ((rand() % s->yrepeat)>>2)) * tilesiz[s->picnum + LIGHTRAD_PICOFS(spriteNum)].y)
2009-06-06 22:30:53 +00:00
2016-08-27 01:42:01 +00:00
void G_AddGameLight ( int lightRadius , int spriteNum , int zOffset , int lightRange , int lightColor , int lightPrio )
2009-06-06 10:20:00 +00:00
{
# ifdef POLYMER
2019-07-08 00:41:25 +00:00
auto const s = & sprite [ spriteNum ] ;
2009-06-08 00:31:53 +00:00
2018-04-12 21:03:12 +00:00
if ( videoGetRenderMode ( ) ! = REND_POLYMER | | pr_lighting ! = 1 )
2009-06-07 12:57:46 +00:00
return ;
2016-08-27 01:42:01 +00:00
if ( actor [ spriteNum ] . lightptr = = NULL )
2009-06-06 10:20:00 +00:00
{
2014-11-22 12:29:25 +00:00
# pragma pack(push, 1)
2009-06-06 10:20:00 +00:00
_prlight mylight ;
2009-07-12 01:55:34 +00:00
# pragma pack(pop)
2011-07-22 13:32:01 +00:00
Bmemset ( & mylight , 0 , sizeof ( mylight ) ) ;
2009-06-06 10:20:00 +00:00
mylight . sector = s - > sectnum ;
mylight . x = s - > x ;
mylight . y = s - > y ;
2016-08-27 01:42:01 +00:00
mylight . z = s - > z - zOffset ;
mylight . color [ 0 ] = lightColor & 255 ;
mylight . color [ 1 ] = ( lightColor > > 8 ) & 255 ;
mylight . color [ 2 ] = ( lightColor > > 16 ) & 255 ;
mylight . radius = lightRadius ;
actor [ spriteNum ] . lightmaxrange = mylight . range = lightRange ;
mylight . priority = lightPrio ;
2009-10-03 21:14:42 +00:00
mylight . tilenum = 0 ;
2009-06-06 10:20:00 +00:00
2012-10-21 04:52:43 +00:00
mylight . publicflags . emitshadow = 1 ;
mylight . publicflags . negative = 0 ;
2016-08-27 01:42:01 +00:00
actor [ spriteNum ] . lightId = polymer_addlight ( & mylight ) ;
if ( actor [ spriteNum ] . lightId > = 0 )
actor [ spriteNum ] . lightptr = & prlights [ actor [ spriteNum ] . lightId ] ;
2009-06-06 10:20:00 +00:00
return ;
}
2016-08-27 01:42:01 +00:00
s - > z - = zOffset ;
2009-06-09 06:19:58 +00:00
2016-08-27 01:42:01 +00:00
if ( lightRange < actor [ spriteNum ] . lightmaxrange > > 1 )
actor [ spriteNum ] . lightmaxrange = 0 ;
2009-06-13 21:06:45 +00:00
2016-08-27 01:42:01 +00:00
if ( lightRange > actor [ spriteNum ] . lightmaxrange | | lightPrio ! = actor [ spriteNum ] . lightptr - > priority | |
Bmemcmp ( & sprite [ spriteNum ] , actor [ spriteNum ] . lightptr , sizeof ( int32_t ) * 3 ) )
2009-06-06 10:20:00 +00:00
{
2016-08-27 01:42:01 +00:00
if ( lightRange > actor [ spriteNum ] . lightmaxrange )
actor [ spriteNum ] . lightmaxrange = lightRange ;
2009-06-07 03:13:55 +00:00
2016-08-27 01:42:01 +00:00
Bmemcpy ( actor [ spriteNum ] . lightptr , & sprite [ spriteNum ] , sizeof ( int32_t ) * 3 ) ;
actor [ spriteNum ] . lightptr - > sector = s - > sectnum ;
actor [ spriteNum ] . lightptr - > flags . invalidate = 1 ;
2009-06-06 10:20:00 +00:00
}
2009-06-06 22:30:53 +00:00
2016-08-27 01:42:01 +00:00
actor [ spriteNum ] . lightptr - > priority = lightPrio ;
actor [ spriteNum ] . lightptr - > range = lightRange ;
actor [ spriteNum ] . lightptr - > color [ 0 ] = lightColor & 255 ;
actor [ spriteNum ] . lightptr - > color [ 1 ] = ( lightColor > > 8 ) & 255 ;
actor [ spriteNum ] . lightptr - > color [ 2 ] = ( lightColor > > 16 ) & 255 ;
2009-06-06 22:30:53 +00:00
2016-08-27 01:42:01 +00:00
s - > z + = zOffset ;
2009-06-06 10:20:00 +00:00
# else
2016-08-27 01:42:01 +00:00
UNREFERENCED_PARAMETER ( lightRadius ) ;
UNREFERENCED_PARAMETER ( spriteNum ) ;
UNREFERENCED_PARAMETER ( zOffset ) ;
UNREFERENCED_PARAMETER ( lightRange ) ;
UNREFERENCED_PARAMETER ( lightColor ) ;
UNREFERENCED_PARAMETER ( lightPrio ) ;
2009-06-06 10:20:00 +00:00
# endif
}
2017-06-23 09:16:21 +00:00
ACTOR_STATIC void A_MaybeAwakenBadGuys ( int const spriteNum )
2016-08-27 01:40:46 +00:00
{
if ( sprite [ spriteNum ] . sectnum = = MAXSECTORS )
return ;
if ( A_CheckSpriteFlags ( spriteNum , SFLAG_WAKEUPBADGUYS ) )
{
2019-04-18 17:25:24 +00:00
auto const pSprite = ( uspriteptr_t ) & sprite [ spriteNum ] ;
2016-08-27 01:40:46 +00:00
2016-08-27 01:41:21 +00:00
for ( bssize_t nextSprite , SPRITES_OF_STAT_SAFE ( STAT_ZOMBIEACTOR , spriteNum , nextSprite ) )
2016-08-27 01:40:46 +00:00
{
if ( A_CheckEnemySprite ( & sprite [ spriteNum ] ) )
{
if ( sprite [ spriteNum ] . sectnum = = pSprite - > sectnum
| | sprite [ spriteNum ] . sectnum = = nextsectorneighborz ( pSprite - > sectnum , sector [ pSprite - > sectnum ] . floorz , 1 , 1 )
| | cansee ( pSprite - > x , pSprite - > y , pSprite - > z - PHEIGHT , pSprite - > sectnum , sprite [ spriteNum ] . x , sprite [ spriteNum ] . y ,
sprite [ spriteNum ] . z - PHEIGHT , sprite [ spriteNum ] . sectnum ) )
{
2018-06-05 21:59:52 +00:00
actor [ spriteNum ] . timetosleep = SLEEPTIME ;
2016-08-27 01:40:46 +00:00
A_PlayAlertSound ( spriteNum ) ;
changespritestat ( spriteNum , STAT_ACTOR ) ;
if ( A_CheckSpriteFlags ( spriteNum , SFLAG_WAKEUPBADGUYS ) )
A_MaybeAwakenBadGuys ( spriteNum ) ;
}
}
}
}
}
2008-11-20 14:06:36 +00:00
// sleeping monsters, etc
2010-01-24 23:33:17 +00:00
ACTOR_STATIC void G_MoveZombieActors ( void )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
int spriteNum = headspritestat [ STAT_ZOMBIEACTOR ] , canSeePlayer ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
while ( spriteNum > = 0 )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
int const nextSprite = nextspritestat [ spriteNum ] ;
int32_t playerDist ;
auto const pSprite = & sprite [ spriteNum ] ;
int const playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
auto const pPlayer = g_player [ playerNum ] . ps ;
2006-04-13 20:47:06 +00:00
2016-11-14 23:47:06 +00:00
if ( sprite [ pPlayer - > i ] . extra > 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( playerDist < 30000 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
actor [ spriteNum ] . timetosleep + + ;
if ( actor [ spriteNum ] . timetosleep > = ( playerDist > > 8 ) )
2006-04-13 20:47:06 +00:00
{
2016-11-14 23:47:06 +00:00
if ( pPlayer - > newowner = = - 1 & & A_CheckEnemySprite ( pSprite ) )
2006-04-13 20:47:06 +00:00
{
2016-11-14 23:47:06 +00:00
vec3_t const p = { pPlayer - > pos . x + 64 - ( krand ( ) & 127 ) ,
pPlayer - > pos . y + 64 - ( krand ( ) & 127 ) ,
pPlayer - > pos . z - ( krand ( ) % ZOFFSET5 ) } ;
2016-08-27 01:40:46 +00:00
2016-11-14 23:47:06 +00:00
int16_t pSectnum = pPlayer - > cursectnum ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
updatesector ( p . x , p . y , & pSectnum ) ;
if ( pSectnum = = - 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
spriteNum = nextSprite ;
2006-04-13 20:47:06 +00:00
continue ;
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:46 +00:00
vec3_t const s = { pSprite - > x + 64 - ( krand ( ) & 127 ) ,
pSprite - > y + 64 - ( krand ( ) & 127 ) ,
pSprite - > z - ( krand ( ) % ( 52 < < 8 ) ) } ;
2016-08-27 01:40:35 +00:00
int16_t sectNum = pSprite - > sectnum ;
2016-08-27 01:40:46 +00:00
updatesector ( s . x , s . y , & sectNum ) ;
2016-08-27 01:40:35 +00:00
if ( sectNum = = - 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
spriteNum = nextSprite ;
2006-04-13 20:47:06 +00:00
continue ;
}
2013-04-15 10:48:09 +00:00
2017-06-23 09:16:21 +00:00
canSeePlayer = cansee ( s . x , s . y , s . z , sectNum , p . x , p . y , p . z , pSectnum ) ;
2006-04-13 20:47:06 +00:00
}
else
2017-06-23 09:16:21 +00:00
canSeePlayer = cansee ( pSprite - > x , pSprite - > y , pSprite - > z - ( ( krand ( ) & 31 ) < < 8 ) , pSprite - > sectnum , pPlayer - > opos . x ,
2016-11-14 23:47:06 +00:00
pPlayer - > opos . y , pPlayer - > opos . z - ( ( krand ( ) & 31 ) < < 8 ) , pPlayer - > cursectnum ) ;
2006-04-13 20:47:06 +00:00
2017-06-23 09:16:21 +00:00
if ( canSeePlayer )
2012-05-14 18:12:27 +00:00
{
2016-08-27 01:40:35 +00:00
switch ( DYNAMICTILEMAP ( pSprite - > picnum ) )
2006-04-13 20:47:06 +00:00
{
2018-04-02 22:00:44 +00:00
# ifndef EDUKE32_STANDALONE
2016-08-27 01:41:46 +00:00
case RUBBERCAN__STATIC :
case EXPLODINGBARREL__STATIC :
case WOODENHORSE__STATIC :
case HORSEONSIDE__STATIC :
case CANWITHSOMETHING__STATIC :
case CANWITHSOMETHING2__STATIC :
case CANWITHSOMETHING3__STATIC :
case CANWITHSOMETHING4__STATIC :
case FIREBARREL__STATIC :
case FIREVASE__STATIC :
case NUKEBARREL__STATIC :
case NUKEBARRELDENTED__STATIC :
case NUKEBARRELLEAKED__STATIC :
case TRIPBOMB__STATIC :
2020-01-29 11:37:16 +00:00
if ( ! FURY )
{
pSprite - > shade = ( ( sector [ pSprite - > sectnum ] . ceilingstat & 1 ) & & A_CheckSpriteFlags ( spriteNum , SFLAG_NOSHADE ) = = 0 )
? sector [ pSprite - > sectnum ] . ceilingshade
: sector [ pSprite - > sectnum ] . floorshade ;
actor [ spriteNum ] . timetosleep = 0 ;
changespritestat ( spriteNum , STAT_STANDABLE ) ;
2020-03-29 08:41:03 +00:00
break ;
2020-01-29 11:37:16 +00:00
}
2020-03-29 08:41:03 +00:00
fallthrough__ ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:41:46 +00:00
case RECON__STATIC :
2020-03-29 08:41:03 +00:00
if ( ! FURY & & pSprite - > picnum = = RECON )
2020-01-29 11:37:16 +00:00
CS ( spriteNum ) | = 257 ;
2018-04-02 22:00:44 +00:00
fallthrough__ ;
# endif
2016-08-27 01:41:46 +00:00
default :
if ( A_CheckSpriteFlags ( spriteNum , SFLAG_USEACTIVATOR ) & & sector [ sprite [ spriteNum ] . sectnum ] . lotag & 16384 )
break ;
2016-08-27 01:40:46 +00:00
2016-08-27 01:41:46 +00:00
actor [ spriteNum ] . timetosleep = 0 ;
A_PlayAlertSound ( spriteNum ) ;
changespritestat ( spriteNum , STAT_ACTOR ) ;
2016-08-27 01:40:46 +00:00
2016-08-27 01:41:46 +00:00
if ( A_CheckSpriteFlags ( spriteNum , SFLAG_WAKEUPBADGUYS ) )
A_MaybeAwakenBadGuys ( spriteNum ) ;
2016-08-27 01:40:46 +00:00
2016-08-27 01:41:46 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2012-05-14 18:12:27 +00:00
}
2016-08-27 01:41:46 +00:00
else
actor [ spriteNum ] . timetosleep = 0 ;
2006-04-13 20:47:06 +00:00
}
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
if ( A_CheckEnemySprite ( pSprite ) & & A_CheckSpriteFlags ( spriteNum , SFLAG_NOSHADE ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:46 +00:00
pSprite - > shade = ( sector [ pSprite - > sectnum ] . ceilingstat & 1 )
? sector [ pSprite - > sectnum ] . ceilingshade
: sector [ pSprite - > sectnum ] . floorshade ;
2006-04-13 20:47:06 +00:00
}
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
spriteNum = nextSprite ;
2006-04-13 20:47:06 +00:00
}
}
2012-09-02 14:30:32 +00:00
// stupid name, but it's what the function does.
2017-06-23 09:16:21 +00:00
static FORCE_INLINE int G_FindExplosionInSector ( int const sectNum )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:21 +00:00
for ( bssize_t SPRITES_OF ( STAT_MISC , i ) )
2017-06-23 09:16:21 +00:00
if ( PN ( i ) = = EXPLOSION2 & & sectNum = = SECT ( i ) )
2006-04-13 20:47:06 +00:00
return i ;
2013-04-15 10:48:09 +00:00
2006-04-13 20:47:06 +00:00
return - 1 ;
}
2017-02-25 08:15:53 +00:00
static FORCE_INLINE void P_Nudge ( int playerNum , int spriteNum , int shiftLeft )
2012-08-10 19:11:49 +00:00
{
2016-08-27 01:40:35 +00:00
g_player [ playerNum ] . ps - > vel . x + = actor [ spriteNum ] . extra * ( sintable [ ( actor [ spriteNum ] . ang + 512 ) & 2047 ] ) < < shiftLeft ;
g_player [ playerNum ] . ps - > vel . y + = actor [ spriteNum ] . extra * ( sintable [ actor [ spriteNum ] . ang & 2047 ] ) < < shiftLeft ;
2012-08-10 19:11:49 +00:00
}
2017-06-23 09:16:21 +00:00
int A_IncurDamage ( int const spriteNum )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pSprite = & sprite [ spriteNum ] ;
auto const pActor = & actor [ spriteNum ] ;
2006-04-13 20:47:06 +00:00
2013-03-29 15:59:23 +00:00
// dmg->picnum check: safety, since it might have been set to <0 from CON.
2016-08-27 01:40:35 +00:00
if ( pActor - > extra < 0 | | pSprite - > extra < 0 | | pActor - > picnum < 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pActor - > extra = - 1 ;
2012-10-05 20:48:10 +00:00
return - 1 ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum = = APLAYER )
2012-10-05 20:48:10 +00:00
{
2016-08-27 01:40:35 +00:00
if ( ud . god & & pActor - > picnum ! = SHRINKSPARK )
2014-11-22 12:29:25 +00:00
return - 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:46 +00:00
int const playerNum = P_GetP ( pSprite ) ;
2016-08-27 01:40:35 +00:00
2018-01-15 17:46:21 +00:00
if ( pActor - > owner > = 0 & & ( sprite [ pActor - > owner ] . picnum = = APLAYER ) )
{
if (
( ud . ffire = = 0 ) & &
( spriteNum ! = pActor - > owner ) & & // Not damaging self.
( ( g_gametypeFlags [ ud . coop ] & GAMETYPE_PLAYERSFRIENDLY ) | |
( ( g_gametypeFlags [ ud . coop ] & GAMETYPE_TDM ) & & g_player [ playerNum ] . ps - > team = = g_player [ P_Get ( pActor - > owner ) ] . ps - > team ) )
)
{
// Nullify damage and cancel.
pActor - > owner = - 1 ;
pActor - > extra = - 1 ;
return - 1 ;
}
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > extra - = pActor - > extra ;
2006-08-18 23:52:26 +00:00
2016-08-27 01:40:35 +00:00
if ( pActor - > owner > = 0 & & pSprite - > extra < = 0 & & pActor - > picnum ! = FREEZEBLAST )
2012-10-05 20:48:10 +00:00
{
2016-08-27 01:41:46 +00:00
int const damageOwner = pActor - > owner ;
pSprite - > extra = 0 ;
2013-12-28 17:04:27 +00:00
2016-08-27 01:40:35 +00:00
g_player [ playerNum ] . ps - > wackedbyactor = damageOwner ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( sprite [ damageOwner ] . picnum = = APLAYER & & playerNum ! = P_Get ( damageOwner ) )
g_player [ playerNum ] . ps - > frag_ps = P_Get ( damageOwner ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pActor - > owner = g_player [ playerNum ] . ps - > i ;
2012-10-05 20:48:10 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
switch ( DYNAMICTILEMAP ( pActor - > picnum ) )
2012-10-05 20:48:10 +00:00
{
2014-11-22 12:29:25 +00:00
case RADIUSEXPLOSION__STATIC :
2018-04-02 22:00:44 +00:00
case SEENINE__STATIC :
# ifndef EDUKE32_STANDALONE
2014-11-22 12:29:25 +00:00
case RPG__STATIC :
case HYDRENT__STATIC :
case HEAVYHBOMB__STATIC :
case OOZFILTER__STATIC :
case EXPLODINGBARREL__STATIC :
2018-04-02 22:00:44 +00:00
# endif
2016-08-27 01:40:35 +00:00
P_Nudge ( playerNum , spriteNum , 2 ) ;
2014-11-22 12:29:25 +00:00
break ;
default :
2016-08-27 01:40:35 +00:00
P_Nudge ( playerNum , spriteNum , ( A_CheckSpriteFlags ( pActor - > owner , SFLAG_PROJECTILE ) & &
( SpriteProjectile [ pActor - > owner ] . workslike & PROJECTILE_RPG ) )
? 2
: 1 ) ;
2014-11-22 12:29:25 +00:00
break ;
2012-10-05 20:48:10 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pActor - > extra = - 1 ;
return pActor - > picnum ;
2012-10-05 20:48:10 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pActor - > extra = = 0 & & pActor - > picnum = = SHRINKSPARK & & pSprite - > xrepeat < 24 )
2014-11-22 12:29:25 +00:00
return - 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > extra - = pActor - > extra ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum ! = RECON & & pSprite - > owner > = 0 & & sprite [ pSprite - > owner ] . statnum < MAXSTATUS )
pSprite - > owner = pActor - > owner ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pActor - > extra = - 1 ;
2014-11-22 12:29:25 +00:00
2016-08-27 01:40:35 +00:00
return pActor - > picnum ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
void A_MoveCyclers ( void )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:42:01 +00:00
for ( bssize_t i = g_cyclerCnt - 1 ; i > = 0 ; i - - )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:42:01 +00:00
int16_t * const pCycler = g_cyclers [ i ] ;
2016-08-27 01:41:46 +00:00
int const sectNum = pCycler [ 0 ] ;
int spriteShade = pCycler [ 2 ] ;
int const floorShade = pCycler [ 3 ] ;
int sectorShade = clamp ( floorShade + ( sintable [ pCycler [ 1 ] & 2047 ] > > 10 ) , spriteShade , floorShade ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pCycler [ 1 ] + = sector [ sectNum ] . extra ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
if ( pCycler [ 5 ] ) // angle 1536...
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
walltype * pWall = & wall [ sector [ sectNum ] . wallptr ] ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:21 +00:00
for ( bssize_t wallsLeft = sector [ sectNum ] . wallnum ; wallsLeft > 0 ; wallsLeft - - , pWall + + )
2012-10-05 20:48:10 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pWall - > hitag ! = 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:46 +00:00
pWall - > shade = sectorShade ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( ( pWall - > cstat & 2 ) & & pWall - > nextwall > = 0 )
2016-08-27 01:41:46 +00:00
wall [ pWall - > nextwall ] . shade = sectorShade ;
2006-04-13 20:47:06 +00:00
}
2012-10-05 20:48:10 +00:00
}
2016-08-27 01:41:46 +00:00
sector [ sectNum ] . floorshade = sector [ sectNum ] . ceilingshade = sectorShade ;
2006-04-13 20:47:06 +00:00
}
}
}
2008-11-20 14:06:36 +00:00
void A_MoveDummyPlayers ( void )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
int spriteNum = headspritestat [ STAT_DUMMYPLAYER ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
while ( spriteNum > = 0 )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
int const playerNum = P_Get ( OW ( spriteNum ) ) ;
auto const pPlayer = g_player [ playerNum ] . ps ;
int const nextSprite = nextspritestat [ spriteNum ] ;
int const playerSectnum = pPlayer - > cursectnum ;
2012-02-14 23:13:38 +00:00
2016-08-27 01:40:35 +00:00
if ( pPlayer - > on_crane > = 0 | | ( playerSectnum > = 0 & & sector [ playerSectnum ] . lotag ! = ST_1_ABOVE_WATER ) | | sprite [ pPlayer - > i ] . extra < = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pPlayer - > dummyplayersprite = - 1 ;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
if ( pPlayer - > on_ground & & pPlayer - > on_warping_sector = = 1 & & playerSectnum > = 0 & & sector [ playerSectnum ] . lotag = = ST_1_ABOVE_WATER )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
CS ( spriteNum ) = 257 ;
SZ ( spriteNum ) = sector [ SECT ( spriteNum ) ] . ceilingz + ( 27 < < 8 ) ;
2018-03-07 04:21:18 +00:00
SA ( spriteNum ) = fix16_to_int ( pPlayer - > q16ang ) ;
2016-08-27 01:40:35 +00:00
if ( T1 ( spriteNum ) = = 8 )
T1 ( spriteNum ) = 0 ;
else T1 ( spriteNum ) + + ;
2006-04-13 20:47:06 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
if ( sector [ SECT ( spriteNum ) ] . lotag ! = ST_2_UNDERWATER ) SZ ( spriteNum ) = sector [ SECT ( spriteNum ) ] . floorz ;
CS ( spriteNum ) = 32768 ;
2006-04-13 20:47:06 +00:00
}
}
2016-08-27 01:40:35 +00:00
SX ( spriteNum ) + = ( pPlayer - > pos . x - pPlayer - > opos . x ) ;
SY ( spriteNum ) + = ( pPlayer - > pos . y - pPlayer - > opos . y ) ;
2019-08-13 14:44:00 +00:00
setsprite ( spriteNum , & sprite [ spriteNum ] . pos ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
next_sprite :
spriteNum = nextSprite ;
2006-04-13 20:47:06 +00:00
}
}
2012-10-14 20:41:17 +00:00
2018-12-15 01:36:15 +00:00
static int P_Submerge ( int , DukePlayer_t * , int , int ) ;
static int P_Emerge ( int , DukePlayer_t * , int , int ) ;
2017-01-01 13:23:29 +00:00
static void P_FinishWaterChange ( int , DukePlayer_t * , int , int , int ) ;
2012-10-14 20:41:17 +00:00
2010-01-24 23:33:17 +00:00
ACTOR_STATIC void G_MovePlayers ( void )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
int spriteNum = headspritestat [ STAT_PLAYER ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
while ( spriteNum > = 0 )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
int const nextSprite = nextspritestat [ spriteNum ] ;
auto const pSprite = & sprite [ spriteNum ] ;
auto const pPlayer = g_player [ P_GetP ( pSprite ) ] . ps ;
2012-08-10 19:11:56 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > owner > = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pPlayer - > newowner > = 0 ) //Looking thru the camera
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > x = pPlayer - > opos . x ;
pSprite - > y = pPlayer - > opos . y ;
pSprite - > z = pPlayer - > opos . z + PHEIGHT ;
actor [ spriteNum ] . bpos . z = pSprite - > z ;
2018-06-21 04:12:04 +00:00
pSprite - > ang = fix16_to_int ( pPlayer - > oq16ang ) ;
2016-08-27 01:40:35 +00:00
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2017-06-23 09:16:21 +00:00
int32_t otherPlayerDist ;
2012-10-14 20:41:17 +00:00
# ifdef YAX_ENABLE
// TROR water submerge/emerge
2016-08-27 01:40:35 +00:00
int const playerSectnum = pSprite - > sectnum ;
int const sectorLotag = sector [ playerSectnum ] . lotag ;
int32_t otherSector ;
2012-10-14 20:41:17 +00:00
2019-04-18 17:25:24 +00:00
if ( A_CheckNoSE7Water ( ( uspriteptr_t ) pSprite , playerSectnum , sectorLotag , & otherSector ) )
2012-10-14 20:41:17 +00:00
{
2013-04-15 10:48:05 +00:00
// NOTE: Compare with G_MoveTransports().
2016-08-27 01:40:35 +00:00
pPlayer - > on_warping_sector = 1 ;
2012-10-14 20:41:17 +00:00
2018-01-28 04:30:50 +00:00
if ( ( sectorLotag = = ST_1_ABOVE_WATER ?
2018-12-15 01:36:15 +00:00
P_Submerge ( P_GetP ( pSprite ) , pPlayer , playerSectnum , otherSector ) :
P_Emerge ( P_GetP ( pSprite ) , pPlayer , playerSectnum , otherSector ) ) = = 1 )
2016-08-27 01:40:35 +00:00
P_FinishWaterChange ( spriteNum , pPlayer , sectorLotag , - 1 , otherSector ) ;
2012-10-14 20:41:17 +00:00
}
# endif
2012-08-19 12:54:30 +00:00
if ( g_netServer | | ud . multimode > 1 )
2017-06-23 09:16:21 +00:00
otherp = P_FindOtherPlayer ( P_GetP ( pSprite ) , & otherPlayerDist ) ;
2006-04-13 20:47:06 +00:00
else
{
2016-08-27 01:40:35 +00:00
otherp = P_GetP ( pSprite ) ;
2017-06-23 09:16:21 +00:00
otherPlayerDist = 0 ;
2006-04-13 20:47:06 +00:00
}
2020-04-05 06:40:38 +00:00
if ( G_TileHasActor ( sprite [ spriteNum ] . picnum ) )
2017-06-23 09:16:21 +00:00
A_Execute ( spriteNum , P_GetP ( pSprite ) , otherPlayerDist ) ;
2006-04-13 20:47:06 +00:00
2020-05-13 09:13:27 +00:00
pPlayer - > q16angvel = G_GetQ16AngleDelta ( pPlayer - > oq16ang , pPlayer - > q16ang ) ;
2020-02-06 22:00:44 +00:00
pPlayer - > oq16ang = pPlayer - > q16ang ;
pPlayer - > oq16horiz = pPlayer - > q16horiz ;
pPlayer - > oq16horizoff = pPlayer - > q16horizoff ;
2012-08-19 12:54:30 +00:00
if ( g_netServer | | ud . multimode > 1 )
2016-08-27 01:40:35 +00:00
{
2007-08-27 06:46:31 +00:00
if ( sprite [ g_player [ otherp ] . ps - > i ] . extra > 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > yrepeat > 32 & & sprite [ g_player [ otherp ] . ps - > i ] . yrepeat < 32 )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
if ( otherPlayerDist < 1400 & & pPlayer - > knee_incs = = 0 )
2006-04-13 20:47:06 +00:00
{
2018-12-08 00:40:39 +00:00
// Don't stomp teammates.
if (
( ( g_gametypeFlags [ ud . coop ] & GAMETYPE_TDM ) & & pPlayer - > team ! = g_player [ otherp ] . ps - > team ) | |
( ! ( g_gametypeFlags [ ud . coop ] & GAMETYPE_PLAYERSFRIENDLY ) & & ! ( g_gametypeFlags [ ud . coop ] & GAMETYPE_TDM ) )
)
2018-01-15 17:46:25 +00:00
{
pPlayer - > knee_incs = 1 ;
pPlayer - > weapon_pos = - 1 ;
pPlayer - > actorsqu = g_player [ otherp ] . ps - > i ;
}
2006-04-13 20:47:06 +00:00
}
}
}
2016-08-27 01:40:35 +00:00
}
2012-10-05 20:48:10 +00:00
2006-11-13 23:12:47 +00:00
if ( ud . god )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > extra = pPlayer - > max_player_health ;
pSprite - > cstat = 257 ;
2015-11-25 12:08:31 +00:00
if ( ! WW2GI )
2016-08-27 01:40:35 +00:00
pPlayer - > inv_amount [ GET_JETPACK ] = 1599 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pSprite - > extra > 0 )
2006-04-13 20:47:06 +00:00
{
2019-08-16 04:58:51 +00:00
# ifndef EDUKE32_STANDALONE
if ( ! FURY )
{
actor [ spriteNum ] . owner = spriteNum ;
2006-04-13 20:47:06 +00:00
2019-08-16 04:58:51 +00:00
if ( ud . god = = 0 )
if ( G_CheckForSpaceCeiling ( pSprite - > sectnum ) | | G_CheckForSpaceFloor ( pSprite - > sectnum ) )
{
2020-05-25 15:11:32 +00:00
Printf ( TEXTCOLOR_RED " %s: player killed by space sector! \n " , EDUKE32_FUNCTION ) ;
2019-08-16 04:58:51 +00:00
P_QuickKill ( pPlayer ) ;
}
}
# endif
2006-04-13 20:47:06 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
pPlayer - > pos . x = pSprite - > x ;
pPlayer - > pos . y = pSprite - > y ;
pPlayer - > pos . z = pSprite - > z - ( 20 < < 8 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pPlayer - > newowner = - 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pPlayer - > wackedbyactor > = 0 & & sprite [ pPlayer - > wackedbyactor ] . statnum < MAXSTATUS )
2006-04-13 20:47:06 +00:00
{
2020-04-07 17:00:51 +00:00
pPlayer - > q16ang + = fix16_from_int ( G_GetAngleDelta ( fix16_to_int ( pPlayer - > q16ang ) ,
2018-03-07 04:21:18 +00:00
getangle ( sprite [ pPlayer - > wackedbyactor ] . x - pPlayer - > pos . x ,
sprite [ pPlayer - > wackedbyactor ] . y - pPlayer - > pos . y ) )
> > 1 ) ;
pPlayer - > q16ang & = 0x7FFFFFF ;
2006-04-13 20:47:06 +00:00
}
}
2012-10-05 20:48:10 +00:00
2018-03-07 04:21:18 +00:00
pSprite - > ang = fix16_to_int ( pPlayer - > q16ang ) ;
2006-04-13 20:47:06 +00:00
}
}
else
{
2016-08-27 01:40:35 +00:00
if ( pPlayer - > holoduke_on = = - 1 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2019-08-07 22:43:48 +00:00
actor [ spriteNum ] . bpos = pSprite - > pos ;
2016-08-27 01:40:35 +00:00
pSprite - > cstat = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xrepeat < 42 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xrepeat + = 4 ;
pSprite - > cstat | = 2 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else pSprite - > xrepeat = 42 ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > yrepeat < 36 )
pSprite - > yrepeat + = 4 ;
2006-04-13 20:47:06 +00:00
else
{
2016-08-27 01:40:35 +00:00
pSprite - > yrepeat = 36 ;
if ( sector [ pSprite - > sectnum ] . lotag ! = ST_2_UNDERWATER )
A_Fall ( spriteNum ) ;
if ( pSprite - > zvel = = 0 & & sector [ pSprite - > sectnum ] . lotag = = ST_1_ABOVE_WATER )
2016-08-27 01:40:56 +00:00
pSprite - > z + = ZOFFSET5 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pSprite - > extra < 8 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xvel = 128 ;
2018-03-07 04:21:18 +00:00
pSprite - > ang = fix16_to_int ( pPlayer - > q16ang ) ;
2016-08-27 01:40:35 +00:00
pSprite - > extra + + ;
A_SetSprite ( spriteNum , CLIPMASK0 ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2018-03-07 04:21:18 +00:00
pSprite - > ang = 2047 - fix16_to_int ( pPlayer - > q16ang ) ;
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2006-04-13 20:47:06 +00:00
}
}
2016-08-27 01:40:35 +00:00
pSprite - > shade =
logapproach ( pSprite - > shade , ( sector [ pSprite - > sectnum ] . ceilingstat & 1 ) ? sector [ pSprite - > sectnum ] . ceilingshade
: sector [ pSprite - > sectnum ] . floorshade ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
next_sprite :
spriteNum = nextSprite ;
2006-04-13 20:47:06 +00:00
}
}
2010-01-24 23:33:17 +00:00
ACTOR_STATIC void G_MoveFX ( void )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
int spriteNum = headspritestat [ STAT_FX ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
while ( spriteNum > = 0 )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pSprite = & sprite [ spriteNum ] ;
int const nextSprite = nextspritestat [ spriteNum ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
switch ( DYNAMICTILEMAP ( pSprite - > picnum ) )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case RESPAWN__STATIC :
2016-08-27 01:40:35 +00:00
if ( pSprite - > extra = = 66 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
/*int32_t j =*/ A_Spawn ( spriteNum , SHT ( spriteNum ) ) ;
2006-11-16 03:02:42 +00:00
// sprite[j].pal = sprite[i].pal;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pSprite - > extra > ( 66 - 13 ) )
sprite [ spriteNum ] . extra + + ;
2006-11-16 03:02:42 +00:00
break ;
case MUSICANDSFX__STATIC :
2012-08-13 18:25:53 +00:00
{
2019-07-08 00:41:25 +00:00
int32_t const spriteHitag = ( uint16_t ) pSprite - > hitag ;
auto const pPlayer = g_player [ screenpeek ] . ps ;
2006-04-13 20:47:06 +00:00
2019-11-02 20:21:48 +00:00
if ( T2 ( spriteNum ) ! = ( int ) SoundEnabled ( ) )
2006-11-16 03:02:42 +00:00
{
2013-05-28 19:52:51 +00:00
// If sound playback was toggled, restart.
2019-11-02 20:21:48 +00:00
T2 ( spriteNum ) = SoundEnabled ( ) ;
2016-08-27 01:40:35 +00:00
T1 ( spriteNum ) = 0 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > lotag > = 1000 & & pSprite - > lotag < 2000 )
2006-11-16 03:02:42 +00:00
{
2018-02-11 05:04:03 +00:00
int32_t playerDist = ldist ( & sprite [ pPlayer - > i ] , pSprite ) ;
2012-08-13 18:25:53 +00:00
2014-01-12 14:04:51 +00:00
# ifdef SPLITSCREEN_MOD_HACKS
2012-08-22 22:51:38 +00:00
if ( g_fakeMultiMode = = 2 )
2012-08-13 18:25:53 +00:00
{
// HACK for splitscreen mod
2016-08-27 01:40:35 +00:00
int32_t otherdist = ldist ( & sprite [ g_player [ 1 ] . ps - > i ] , pSprite ) ;
2017-06-23 09:16:21 +00:00
playerDist = min ( playerDist , otherdist ) ;
2012-08-13 18:25:53 +00:00
}
2014-01-12 14:04:51 +00:00
# endif
2012-08-13 18:25:53 +00:00
2017-06-23 09:16:21 +00:00
if ( playerDist < spriteHitag & & T1 ( spriteNum ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
FX_SetReverb ( pSprite - > lotag - 1000 ) ;
T1 ( spriteNum ) = 1 ;
2006-04-13 20:47:06 +00:00
}
2017-06-23 09:16:21 +00:00
else if ( playerDist > = spriteHitag & & T1 ( spriteNum ) = = 1 )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
FX_SetReverb ( 0 ) ;
2016-08-27 01:40:35 +00:00
T1 ( spriteNum ) = 0 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pSprite - > lotag < 999 & & ( unsigned ) sector [ pSprite - > sectnum ] . lotag < 9 & & // ST_9_SLIDING_ST_DOOR
2019-10-22 00:01:05 +00:00
snd_ambience & & sector [ SECT ( spriteNum ) ] . floorz ! = sector [ SECT ( spriteNum ) ] . ceilingz )
2006-11-16 03:02:42 +00:00
{
2019-12-15 12:34:00 +00:00
auto flags = S_GetUserFlags ( pSprite - > lotag ) ;
if ( flags & SF_MSFX )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
int playerDist = dist ( & sprite [ pPlayer - > i ] , pSprite ) ;
2012-08-13 18:25:53 +00:00
2014-01-12 14:04:51 +00:00
# ifdef SPLITSCREEN_MOD_HACKS
2012-08-22 22:51:38 +00:00
if ( g_fakeMultiMode = = 2 )
2012-08-13 18:25:53 +00:00
{
// HACK for splitscreen mod
2016-08-27 01:40:35 +00:00
int32_t otherdist = dist ( & sprite [ g_player [ 1 ] . ps - > i ] , pSprite ) ;
playerDist = min ( playerDist , otherdist ) ;
2012-08-13 18:25:53 +00:00
}
2014-01-12 14:04:51 +00:00
# endif
2012-08-13 18:25:53 +00:00
2019-12-15 12:34:00 +00:00
if ( playerDist < spriteHitag & & T1 ( spriteNum ) = = 0 ) // && FX_VoiceAvailable(g_sounds[pSprite->lotag].pr-1))
2006-11-15 01:16:55 +00:00
{
2013-05-28 19:52:51 +00:00
// Start playing an ambience sound.
2019-12-15 12:34:00 +00:00
#if 0 // let the sound system handle this internally.
2016-08-27 01:40:35 +00:00
char om = g_sounds [ pSprite - > lotag ] . m ;
2019-10-22 00:01:05 +00:00
if ( g_numEnvSoundsPlaying = = snd_numvoices )
2006-11-15 01:16:55 +00:00
{
2012-08-13 18:25:59 +00:00
int32_t j ;
for ( SPRITES_OF ( STAT_FX , j ) )
2016-08-27 01:40:35 +00:00
if ( j ! = spriteNum & & S_IsAmbientSFX ( j ) & & actor [ j ] . t_data [ 0 ] = = 1 & &
dist ( & sprite [ j ] , & sprite [ pPlayer - > i ] ) > playerDist )
2006-11-15 01:16:55 +00:00
{
2008-11-20 14:06:36 +00:00
S_StopEnvSound ( sprite [ j ] . lotag , j ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-11-15 01:16:55 +00:00
}
2012-08-13 18:25:59 +00:00
if ( j = = - 1 )
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-11-15 01:16:55 +00:00
}
2019-12-15 12:34:00 +00:00
# endif
2019-12-16 23:29:38 +00:00
A_PlaySound ( pSprite - > lotag , spriteNum , CHAN_AUTO , CHANF_LOOP ) ;
2016-08-27 01:40:35 +00:00
T1 ( spriteNum ) = 1 ; // AMBIENT_SFX_PLAYING
2006-11-15 01:16:55 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( playerDist > = spriteHitag & & T1 ( spriteNum ) = = 1 )
2006-11-15 01:16:55 +00:00
{
2013-05-28 19:52:51 +00:00
// Stop playing ambience sound because we're out of its range.
2014-02-22 19:38:53 +00:00
// T1 will be reset in sounds.c: CLEAR_SOUND_T0
2010-02-23 18:13:46 +00:00
// T1 = 0;
2016-08-27 01:40:35 +00:00
S_StopEnvSound ( pSprite - > lotag , spriteNum ) ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
}
2012-08-13 18:25:59 +00:00
2019-12-15 12:34:00 +00:00
if ( ( flags & ( SF_GLOBAL | SF_DTAG ) ) = = SF_GLOBAL )
2006-11-16 03:02:42 +00:00
{
2012-08-13 18:25:59 +00:00
// Randomly playing global sounds (flyby of planes, screams, ...)
2016-08-27 01:40:35 +00:00
if ( T5 ( spriteNum ) > 0 )
T5 ( spriteNum ) - - ;
2008-11-20 14:06:36 +00:00
else
2012-08-10 19:11:56 +00:00
{
2017-06-23 09:16:21 +00:00
for ( int TRAVERSE_CONNECT ( playerNum ) )
if ( playerNum = = myconnectindex & & g_player [ playerNum ] . ps - > cursectnum = = pSprite - > sectnum )
2012-02-21 19:33:33 +00:00
{
2016-08-27 01:40:35 +00:00
S_PlaySound ( pSprite - > lotag + ( unsigned ) g_globalRandom % ( pSprite - > hitag + 1 ) ) ;
T5 ( spriteNum ) = GAMETICSPERSEC * 40 + g_globalRandom % ( GAMETICSPERSEC * 40 ) ;
2012-02-21 19:33:33 +00:00
}
2012-08-10 19:11:56 +00:00
}
2006-11-16 03:02:42 +00:00
}
}
break ;
2006-04-13 20:47:06 +00:00
}
2012-08-13 18:25:53 +00:00
}
2016-08-27 01:40:35 +00:00
next_sprite :
spriteNum = nextSprite ;
2006-04-13 20:47:06 +00:00
}
}
2010-01-24 23:33:17 +00:00
ACTOR_STATIC void G_MoveFallers ( void )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
int spriteNum = headspritestat [ STAT_FALLER ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
while ( spriteNum > = 0 )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
int const nextSprite = nextspritestat [ spriteNum ] ;
auto const pSprite = & sprite [ spriteNum ] ;
int const sectNum = pSprite - > sectnum ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( T1 ( spriteNum ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
const int16_t oextra = pSprite - > extra ;
2016-08-27 01:40:35 +00:00
int j ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > z - = ZOFFSET2 ;
T2 ( spriteNum ) = pSprite - > ang ;
2017-06-23 09:16:21 +00:00
2016-08-27 01:40:35 +00:00
if ( ( j = A_IncurDamage ( spriteNum ) ) > = 0 )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
if ( j = = FIREEXT | | j = = RPG | | j = = RADIUSEXPLOSION | | j = = SEENINE | | j = = OOZFILTER )
2007-08-25 01:05:00 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > extra < = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
T1 ( spriteNum ) = 1 ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:41:21 +00:00
for ( bssize_t SPRITES_OF ( STAT_FALLER , j ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( sprite [ j ] . hitag = = SHT ( spriteNum ) )
2006-04-13 20:47:06 +00:00
{
2010-05-02 23:27:30 +00:00
actor [ j ] . t_data [ 0 ] = 1 ;
2006-04-13 20:47:06 +00:00
sprite [ j ] . cstat & = ( 65535 - 64 ) ;
2006-11-13 23:12:47 +00:00
if ( sprite [ j ] . picnum = = CEILINGSTEAM | | sprite [ j ] . picnum = = STEAM )
2006-04-13 20:47:06 +00:00
sprite [ j ] . cstat | = 32768 ;
}
}
}
}
else
{
2016-08-27 01:40:35 +00:00
actor [ spriteNum ] . extra = 0 ;
pSprite - > extra = oextra ;
2006-04-13 20:47:06 +00:00
}
}
2016-08-27 01:40:35 +00:00
pSprite - > ang = T2 ( spriteNum ) ;
pSprite - > z + = ZOFFSET2 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( T1 ( spriteNum ) = = 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( ( int16_t ) pSprite - > lotag > 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > lotag - = 3 ;
if ( ( int16_t ) pSprite - > lotag < = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xvel = ( 32 + ( krand ( ) & 63 ) ) ;
pSprite - > zvel = - ( 1024 + ( krand ( ) & 1023 ) ) ;
2006-04-13 20:47:06 +00:00
}
}
else
{
2017-06-23 09:16:21 +00:00
int32_t spriteGravity = g_spriteGravity ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel > 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xvel - = 8 ;
A_SetSprite ( spriteNum , CLIPMASK0 ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
if ( EDUKE32_PREDICT_FALSE ( G_CheckForSpaceFloor ( pSprite - > sectnum ) ) )
2017-06-23 09:16:21 +00:00
spriteGravity = 0 ;
else if ( EDUKE32_PREDICT_FALSE ( G_CheckForSpaceCeiling ( pSprite - > sectnum ) ) )
spriteGravity = g_spriteGravity / 6 ;
2006-04-13 20:47:06 +00:00
2020-02-11 09:21:44 +00:00
if ( pSprite - > z < ( sector [ sectNum ] . floorz - ACTOR_FLOOR_OFFSET ) )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
pSprite - > zvel + = spriteGravity ;
2020-02-11 09:21:44 +00:00
if ( pSprite - > zvel > ACTOR_MAXFALLINGZVEL )
pSprite - > zvel = ACTOR_MAXFALLINGZVEL ;
2016-08-27 01:40:35 +00:00
pSprite - > z + = pSprite - > zvel ;
2006-04-13 20:47:06 +00:00
}
2017-06-23 09:16:21 +00:00
2016-08-27 01:40:35 +00:00
if ( ( sector [ sectNum ] . floorz - pSprite - > z ) < ZOFFSET2 )
2006-04-13 20:47:06 +00:00
{
2018-06-09 20:36:31 +00:00
# ifndef EDUKE32_STANDALONE
2019-05-19 03:56:13 +00:00
for ( int x = 0 , x_end = 1 + ( krand ( ) & 7 ) ; x < x_end ; + + x )
2017-06-23 09:16:21 +00:00
RANDOMSCRAP ( pSprite , spriteNum ) ;
2018-06-09 20:36:31 +00:00
# endif
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
}
}
2016-08-27 01:40:35 +00:00
next_sprite :
spriteNum = nextSprite ;
2006-04-13 20:47:06 +00:00
}
}
2010-01-24 23:33:17 +00:00
ACTOR_STATIC void G_MoveStandables ( void )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
int spriteNum = headspritestat [ STAT_STANDABLE ] , j , switchPic ;
2012-03-11 17:37:50 +00:00
2016-08-27 01:40:35 +00:00
while ( spriteNum > = 0 )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
int const nextSprite = nextspritestat [ spriteNum ] ;
auto const pData = & actor [ spriteNum ] . t_data [ 0 ] ;
auto const pSprite = & sprite [ spriteNum ] ;
int const sectNum = pSprite - > sectnum ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( sectNum < 0 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2013-04-15 10:48:18 +00:00
// Rotation-fixed sprites in rotating sectors already have bpos* updated.
2016-08-27 01:40:35 +00:00
if ( ( pData [ 7 ] & ( 0xffff0000 ) ) ! = ROTFIXSPR_MAGIC )
2019-08-07 22:43:48 +00:00
actor [ spriteNum ] . bpos = pSprite - > pos ;
2006-04-13 20:47:06 +00:00
2018-04-02 22:00:44 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY & & PN ( spriteNum ) > = CRANE & & PN ( spriteNum ) < = CRANE + 3 )
2006-04-13 20:47:06 +00:00
{
2013-04-15 10:48:09 +00:00
int32_t nextj ;
2006-04-13 20:47:06 +00:00
//t[0] = state
//t[1] = checking sector number
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel ) A_GetZLimits ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 0 ) //Waiting to check the sector
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
for ( SPRITES_OF_SECT_SAFE ( pData [ 1 ] , j , nextj ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
switch ( sprite [ j ] . statnum )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
case STAT_ACTOR :
case STAT_ZOMBIEACTOR :
case STAT_STANDABLE :
case STAT_PLAYER :
{
vec3_t vect = { g_origins [ pData [ 4 ] + 1 ] . x , g_origins [ pData [ 4 ] + 1 ] . y , sprite [ j ] . z } ;
2009-01-13 12:23:18 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > ang = getangle ( vect . x - pSprite - > x , vect . y - pSprite - > y ) ;
setsprite ( j , & vect ) ;
pData [ 0 ] + + ;
goto next_sprite ;
}
2006-04-13 20:47:06 +00:00
}
}
}
2016-08-27 01:40:35 +00:00
else if ( pData [ 0 ] = = 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel < 184 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > picnum = CRANE + 1 ;
pSprite - > xvel + = 8 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
A_SetSprite ( spriteNum , CLIPMASK0 ) ;
if ( sectNum = = pData [ 1 ] )
pData [ 0 ] + + ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pData [ 0 ] = = 2 | | pData [ 0 ] = = 7 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > z + = ( 1024 + 512 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 2 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( sector [ sectNum ] . floorz - pSprite - > z < ( 64 < < 8 ) )
if ( pSprite - > picnum > CRANE ) pSprite - > picnum - - ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( sector [ sectNum ] . floorz - pSprite - > z < 4096 + 1024 )
pData [ 0 ] + + ;
2006-04-13 20:47:06 +00:00
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 7 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( sector [ sectNum ] . floorz - pSprite - > z < ( 64 < < 8 ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum > CRANE ) pSprite - > picnum - - ;
2006-04-13 20:47:06 +00:00
else
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > owner = = - 2 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
int32_t p = A_FindPlayer ( pSprite , NULL ) ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( DUKE_GRUNT , g_player [ p ] . ps - > i ) ;
2016-08-27 01:40:35 +00:00
if ( g_player [ p ] . ps - > on_crane = = spriteNum )
2007-08-27 06:46:31 +00:00
g_player [ p ] . ps - > on_crane = - 1 ;
2006-04-13 20:47:06 +00:00
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
pData [ 0 ] + + ;
pSprite - > owner = - 1 ;
2006-04-13 20:47:06 +00:00
}
}
}
}
2016-08-27 01:40:35 +00:00
else if ( pData [ 0 ] = = 3 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > picnum + + ;
if ( pSprite - > picnum = = CRANE + 2 )
2006-04-13 20:47:06 +00:00
{
2020-01-29 11:37:20 +00:00
int32_t p = G_GetPlayerInSector ( pData [ 1 ] ) ;
2013-04-15 10:48:09 +00:00
2007-08-27 06:46:31 +00:00
if ( p > = 0 & & g_player [ p ] . ps - > on_ground )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > owner = - 2 ;
g_player [ p ] . ps - > on_crane = spriteNum ;
2008-11-20 14:06:36 +00:00
A_PlaySound ( DUKE_GRUNT , g_player [ p ] . ps - > i ) ;
2018-03-07 04:21:18 +00:00
g_player [ p ] . ps - > q16ang = fix16_from_int ( pSprite - > ang + 1024 ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
for ( SPRITES_OF_SECT ( pData [ 1 ] , j ) )
2006-04-13 20:47:06 +00:00
{
2006-11-14 21:35:50 +00:00
switch ( sprite [ j ] . statnum )
2006-04-13 20:47:06 +00:00
{
2009-08-06 10:12:13 +00:00
case STAT_ACTOR :
case STAT_STANDABLE :
2016-08-27 01:40:35 +00:00
pSprite - > owner = j ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
}
}
2016-08-27 01:40:35 +00:00
pData [ 0 ] + + ; //Grabbed the sprite
pData [ 2 ] = 0 ;
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
}
2016-08-27 01:40:35 +00:00
else if ( pData [ 0 ] = = 4 ) //Delay before going up
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 2 ] + + ;
if ( pData [ 2 ] > 10 )
pData [ 0 ] + + ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pData [ 0 ] = = 5 | | pData [ 0 ] = = 8 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 8 & & pSprite - > picnum < ( CRANE + 2 ) )
if ( ( sector [ sectNum ] . floorz - pSprite - > z ) > 8192 )
pSprite - > picnum + + ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > z < g_origins [ pData [ 4 ] + 2 ] . x )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] + + ;
pSprite - > xvel = 0 ;
2006-04-13 20:47:06 +00:00
}
else
2016-08-27 01:40:35 +00:00
pSprite - > z - = ( 1024 + 512 ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pData [ 0 ] = = 6 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel < 192 )
pSprite - > xvel + = 8 ;
pSprite - > ang = getangle ( g_origins [ pData [ 4 ] ] . x - pSprite - > x , g_origins [ pData [ 4 ] ] . y - pSprite - > y ) ;
A_SetSprite ( spriteNum , CLIPMASK0 ) ;
if ( ( ( pSprite - > x - g_origins [ pData [ 4 ] ] . x ) * ( pSprite - > x - g_origins [ pData [ 4 ] ] . x ) + ( pSprite - > y - g_origins [ pData [ 4 ] ] . y ) * ( pSprite - > y - g_origins [ pData [ 4 ] ] . y ) ) < ( 128 * 128 ) )
pData [ 0 ] + + ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pData [ 0 ] = = 9 )
pData [ 0 ] = 0 ;
2006-04-13 20:47:06 +00:00
2009-01-13 12:23:18 +00:00
{
vec3_t vect ;
2016-08-27 01:40:35 +00:00
Bmemcpy ( & vect , pSprite , sizeof ( vec3_t ) ) ;
2009-01-13 12:23:18 +00:00
vect . z - = ( 34 < < 8 ) ;
2016-08-27 01:40:35 +00:00
setsprite ( g_origins [ pData [ 4 ] + 2 ] . y , & vect ) ;
2009-01-13 12:23:18 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > owner ! = - 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
int32_t p = A_FindPlayer ( pSprite , NULL ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( A_IncurDamage ( spriteNum ) > = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > owner = = - 2 )
if ( g_player [ p ] . ps - > on_crane = = spriteNum )
2007-08-27 06:46:31 +00:00
g_player [ p ] . ps - > on_crane = - 1 ;
2016-08-27 01:40:35 +00:00
pSprite - > owner = - 1 ;
pSprite - > picnum = CRANE ;
goto next_sprite ;
2007-08-25 01:05:00 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > owner > = 0 )
2007-08-25 01:05:00 +00:00
{
2019-06-25 11:28:25 +00:00
setsprite ( pSprite - > owner , & pSprite - > pos ) ;
2006-04-13 20:47:06 +00:00
2019-08-07 22:43:48 +00:00
actor [ pSprite - > owner ] . bpos = pSprite - > pos ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > zvel = 0 ;
2007-08-25 01:05:00 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pSprite - > owner = = - 2 )
2007-08-25 01:05:00 +00:00
{
2019-07-08 00:41:25 +00:00
auto const ps = g_player [ p ] . ps ;
2009-01-13 12:23:18 +00:00
2018-03-07 04:21:18 +00:00
ps - > opos . x = ps - > pos . x = pSprite - > x - ( sintable [ ( fix16_to_int ( ps - > q16ang ) + 512 ) & 2047 ] > > 6 ) ;
ps - > opos . y = ps - > pos . y = pSprite - > y - ( sintable [ fix16_to_int ( ps - > q16ang ) & 2047 ] > > 6 ) ;
2016-08-27 01:40:35 +00:00
ps - > opos . z = ps - > pos . z = pSprite - > z + ( 2 < < 8 ) ;
2012-08-10 19:11:53 +00:00
2019-08-13 14:44:00 +00:00
setsprite ( ps - > i , & ps - > pos ) ;
2012-08-10 19:11:53 +00:00
ps - > cursectnum = sprite [ ps - > i ] . sectnum ;
2007-08-25 01:05:00 +00:00
}
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2020-01-29 11:37:16 +00:00
else if ( ! FURY & & PN ( spriteNum ) > = WATERFOUNTAIN & & PN ( spriteNum ) < = WATERFOUNTAIN + 3 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] > 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] < 20 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] + + ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > picnum + + ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum = = ( WATERFOUNTAIN + 3 ) )
pSprite - > picnum = WATERFOUNTAIN + 1 ;
2006-04-13 20:47:06 +00:00
}
else
{
2018-04-02 22:00:44 +00:00
int32_t playerDist ;
2017-06-23 09:16:21 +00:00
A_FindPlayer ( pSprite , & playerDist ) ;
2006-04-13 20:47:06 +00:00
2017-06-23 09:16:21 +00:00
if ( playerDist > 512 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = 0 ;
pSprite - > picnum = WATERFOUNTAIN ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else pData [ 0 ] = 1 ;
2006-04-13 20:47:06 +00:00
}
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2020-01-29 11:37:16 +00:00
else if ( ! FURY & & AFLAMABLE ( pSprite - > picnum ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( T1 ( spriteNum ) = = 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( ( + + T2 ( spriteNum ) & 3 ) > 0 ) goto next_sprite ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum = = TIRE & & T2 ( spriteNum ) = = 32 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > cstat = 0 ;
j = A_Spawn ( spriteNum , BLOODPOOL ) ;
2006-04-13 20:47:06 +00:00
sprite [ j ] . shade = 127 ;
}
else
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > shade < 64 ) pSprite - > shade + + ;
2016-08-27 01:41:33 +00:00
else DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
j = pSprite - > xrepeat - ( krand ( ) & 7 ) ;
2006-11-13 23:12:47 +00:00
if ( j < 10 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > xrepeat = j ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
j = pSprite - > yrepeat - ( krand ( ) & 7 ) ;
2006-11-15 01:16:55 +00:00
if ( j < 4 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2012-04-13 10:46:04 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > yrepeat = j ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum = = BOX )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
A_Fall ( spriteNum ) ;
actor [ spriteNum ] . ceilingz = sector [ pSprite - > sectnum ] . ceilingz ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2020-01-29 11:37:16 +00:00
else if ( ! FURY & & pSprite - > picnum = = TRIPBOMB )
2006-04-13 20:47:06 +00:00
{
2014-01-12 14:54:34 +00:00
// TIMER_CONTROL
2016-08-27 01:40:35 +00:00
if ( actor [ spriteNum ] . t_data [ 6 ] = = 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( actor [ spriteNum ] . t_data [ 7 ] > = 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
actor [ spriteNum ] . t_data [ 7 ] - - ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
if ( actor [ spriteNum ] . t_data [ 7 ] < = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
T3 ( spriteNum ) = 16 ;
actor [ spriteNum ] . t_data [ 6 ] = 3 ;
A_PlaySound ( LASERTRIP_ARMING , spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
// we're on a timer....
}
2016-08-27 01:40:35 +00:00
if ( T3 ( spriteNum ) > 0 & & actor [ spriteNum ] . t_data [ 6 ] = = 3 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
T3 ( spriteNum ) - - ;
2010-05-02 23:27:30 +00:00
2016-08-27 01:40:35 +00:00
if ( T3 ( spriteNum ) = = 8 )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
for ( j = 0 ; j < 5 ; j + + )
RANDOMSCRAP ( pSprite , spriteNum ) ;
int const dmg = pSprite - > extra ;
A_RadiusDamage ( spriteNum , g_tripbombRadius , dmg > > 2 , dmg > > 1 , dmg - ( dmg > > 2 ) , dmg ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
j = A_Spawn ( spriteNum , EXPLOSION2 ) ;
2010-07-03 08:53:57 +00:00
A_PlaySound ( LASERTRIP_EXPLODE , j ) ;
2016-08-27 01:40:35 +00:00
sprite [ j ] . ang = pSprite - > ang ;
2006-04-13 20:47:06 +00:00
sprite [ j ] . xvel = 348 ;
2008-11-20 14:06:36 +00:00
A_SetSprite ( j , CLIPMASK0 ) ;
2006-04-13 20:47:06 +00:00
2013-04-15 10:48:09 +00:00
for ( SPRITES_OF ( STAT_MISC , j ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( sprite [ j ] . picnum = = LASERLINE & & pSprite - > hitag = = sprite [ j ] . hitag )
2006-04-13 20:47:06 +00:00
sprite [ j ] . xrepeat = sprite [ j ] . yrepeat = 0 ;
}
2012-04-13 10:46:04 +00:00
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
else
{
2017-06-23 09:16:21 +00:00
int const oldExtra = pSprite - > extra ;
int const oldAng = pSprite - > ang ;
2016-08-27 01:40:35 +00:00
pSprite - > extra = 1 ;
if ( A_IncurDamage ( spriteNum ) > = 0 )
2013-04-15 10:48:09 +00:00
{
2016-08-27 01:40:35 +00:00
actor [ spriteNum ] . t_data [ 6 ] = 3 ;
T3 ( spriteNum ) = 16 ;
2013-04-15 10:48:09 +00:00
}
2017-06-23 09:16:21 +00:00
pSprite - > extra = oldExtra ;
pSprite - > ang = oldAng ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
switch ( T1 ( spriteNum ) )
2006-04-13 20:47:06 +00:00
{
2010-05-02 23:27:30 +00:00
default :
2017-06-23 09:16:21 +00:00
{
int32_t playerDist ;
A_FindPlayer ( pSprite , & playerDist ) ;
if ( playerDist > 768 | | T1 ( spriteNum ) > 16 ) T1 ( spriteNum ) + + ;
2010-05-02 23:27:30 +00:00
break ;
2017-06-23 09:16:21 +00:00
}
2010-05-02 23:27:30 +00:00
case 32 :
2013-04-15 10:48:13 +00:00
{
2017-06-23 09:16:21 +00:00
int16_t hitSprite ;
int const oldAng = pSprite - > ang ;
2013-04-15 10:48:13 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > ang = T6 ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
T4 ( spriteNum ) = pSprite - > x ;
T5 ( spriteNum ) = pSprite - > y ;
2010-05-02 23:27:30 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > x + = sintable [ ( T6 ( spriteNum ) + 512 ) & 2047 ] > > 9 ;
pSprite - > y + = sintable [ ( T6 ( spriteNum ) ) & 2047 ] > > 9 ;
pSprite - > z - = ( 3 < < 8 ) ;
2010-05-02 23:27:30 +00:00
2020-03-12 00:58:07 +00:00
int16_t const oldSectNum = pSprite - > sectnum ;
int16_t curSectNum = pSprite - > sectnum ;
updatesectorneighbor ( pSprite - > x , pSprite - > y , & curSectNum , 1024 , 2048 ) ;
changespritesect ( spriteNum , curSectNum ) ;
2006-04-13 20:47:06 +00:00
2020-03-12 01:05:37 +00:00
int32_t hitDist = A_CheckHitSprite ( spriteNum , & hitSprite ) ;
2006-04-13 20:47:06 +00:00
2017-06-23 09:16:21 +00:00
actor [ spriteNum ] . lastv . x = hitDist ;
pSprite - > ang = oldAng ;
2006-04-13 20:47:06 +00:00
2020-03-12 00:58:07 +00:00
// we're on a trip wire
2016-08-27 01:40:35 +00:00
if ( actor [ spriteNum ] . t_data [ 6 ] ! = 1 )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
while ( hitDist > 0 )
2006-04-13 20:47:06 +00:00
{
2020-03-12 00:58:07 +00:00
j = A_Spawn ( spriteNum , LASERLINE ) ;
2016-08-27 01:40:35 +00:00
sprite [ j ] . hitag = pSprite - > hitag ;
2010-05-02 23:27:30 +00:00
actor [ j ] . t_data [ 1 ] = sprite [ j ] . z ;
2006-04-13 20:47:06 +00:00
2017-06-23 09:16:21 +00:00
if ( hitDist < 1024 )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
sprite [ j ] . xrepeat = hitDist > > 5 ;
2006-04-13 20:47:06 +00:00
break ;
}
2017-06-23 09:16:21 +00:00
hitDist - = 1024 ;
2011-10-10 00:07:00 +00:00
2020-03-12 00:58:07 +00:00
pSprite - > x + = sintable [ ( T6 ( spriteNum ) + 512 ) & 2047 ] > > 4 ;
pSprite - > y + = sintable [ ( T6 ( spriteNum ) ) & 2047 ] > > 4 ;
updatesectorneighbor ( pSprite - > x , pSprite - > y , & curSectNum , 1024 , 2048 ) ;
if ( curSectNum = = - 1 )
2011-10-10 00:07:00 +00:00
break ;
2020-03-12 00:58:07 +00:00
changespritesect ( spriteNum , curSectNum ) ;
// this is a hack to work around the LASERLINE sprite's art tile offset
changespritesect ( j , curSectNum ) ;
2006-04-13 20:47:06 +00:00
}
}
2010-05-02 23:27:30 +00:00
2016-08-27 01:40:35 +00:00
T1 ( spriteNum ) + + ;
2010-05-02 23:27:30 +00:00
2020-03-12 00:58:07 +00:00
pSprite - > pos . vec2 = { T4 ( spriteNum ) , T5 ( spriteNum ) } ;
2016-08-27 01:40:35 +00:00
pSprite - > z + = ( 3 < < 8 ) ;
2010-05-02 23:27:30 +00:00
2020-03-12 00:58:07 +00:00
changespritesect ( spriteNum , oldSectNum ) ;
2016-08-27 01:40:35 +00:00
T4 ( spriteNum ) = T3 ( spriteNum ) = 0 ;
2010-05-02 23:27:30 +00:00
2017-06-23 09:16:21 +00:00
if ( hitSprite > = 0 & & actor [ spriteNum ] . t_data [ 6 ] ! = 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
actor [ spriteNum ] . t_data [ 6 ] = 3 ;
T3 ( spriteNum ) = 13 ;
A_PlaySound ( LASERTRIP_ARMING , spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2010-05-02 23:27:30 +00:00
break ;
2013-04-15 10:48:13 +00:00
}
2006-04-13 20:47:06 +00:00
2010-05-02 23:27:30 +00:00
case 33 :
2017-06-23 09:16:21 +00:00
{
2016-08-27 01:40:35 +00:00
T2 ( spriteNum ) + + ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
T4 ( spriteNum ) = pSprite - > x ;
T5 ( spriteNum ) = pSprite - > y ;
2010-05-02 23:27:30 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > x + = sintable [ ( T6 ( spriteNum ) + 512 ) & 2047 ] > > 9 ;
pSprite - > y + = sintable [ ( T6 ( spriteNum ) ) & 2047 ] > > 9 ;
pSprite - > z - = ( 3 < < 8 ) ;
2010-05-02 23:27:30 +00:00
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2006-04-13 20:47:06 +00:00
2020-03-12 01:05:37 +00:00
int32_t const hitDist = A_CheckHitSprite ( spriteNum , NULL ) ;
2006-04-13 20:47:06 +00:00
2020-03-12 00:58:07 +00:00
pSprite - > pos . vec2 = { T4 ( spriteNum ) , T5 ( spriteNum ) } ;
2016-08-27 01:40:35 +00:00
pSprite - > z + = ( 3 < < 8 ) ;
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2006-04-13 20:47:06 +00:00
2017-06-23 09:16:21 +00:00
// if( Actor[i].lastvx != x && lTripBombControl & TRIPBOMB_TRIPWIRE)
if ( actor [ spriteNum ] . lastv . x ! = hitDist & & actor [ spriteNum ] . t_data [ 6 ] ! = 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
actor [ spriteNum ] . t_data [ 6 ] = 3 ;
T3 ( spriteNum ) = 13 ;
2017-06-23 09:16:21 +00:00
A_PlaySound ( LASERTRIP_ARMING , spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2010-05-02 23:27:30 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2017-06-23 09:16:21 +00:00
}
2010-05-02 23:27:30 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2020-01-29 11:37:16 +00:00
else if ( ! FURY & & pSprite - > picnum > = CRACK1 & & pSprite - > picnum < = CRACK4 )
2006-04-13 20:47:06 +00:00
{
2018-03-06 10:25:17 +00:00
if ( pSprite - > hitag )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = pSprite - > cstat ;
pData [ 1 ] = pSprite - > ang ;
2013-04-15 10:48:15 +00:00
2016-08-27 01:40:35 +00:00
int const dmgTile = A_IncurDamage ( spriteNum ) ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:40:35 +00:00
if ( dmgTile < 0 )
2013-05-10 12:31:33 +00:00
goto crack_default ;
2013-04-15 10:48:15 +00:00
2016-08-27 01:40:35 +00:00
switch ( DYNAMICTILEMAP ( dmgTile ) )
2013-05-10 12:31:33 +00:00
{
2016-08-27 01:40:35 +00:00
case FIREEXT__STATIC :
case RPG__STATIC :
case RADIUSEXPLOSION__STATIC :
case SEENINE__STATIC :
case OOZFILTER__STATIC :
for ( SPRITES_OF ( STAT_STANDABLE , j ) )
{
if ( pSprite - > hitag = = sprite [ j ] . hitag & &
( sprite [ j ] . picnum = = OOZFILTER | | sprite [ j ] . picnum = = SEENINE ) )
if ( sprite [ j ] . shade ! = - 32 )
sprite [ j ] . shade = - 32 ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
goto DETONATE ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:40:35 +00:00
crack_default :
default :
pSprite - > cstat = pData [ 0 ] ;
pSprite - > ang = pData [ 1 ] ;
pSprite - > extra = 0 ;
2013-04-15 10:48:15 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2013-05-10 12:31:33 +00:00
}
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2020-01-29 11:37:16 +00:00
else if ( ! FURY & & pSprite - > picnum = = FIREEXT )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( A_IncurDamage ( spriteNum ) < 0 )
goto next_sprite ;
2006-04-13 20:47:06 +00:00
2019-05-19 03:56:13 +00:00
for ( int k = 0 ; k < 16 ; k + + )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
j = A_InsertSprite ( SECT ( spriteNum ) , SX ( spriteNum ) , SY ( spriteNum ) , SZ ( spriteNum ) - ( krand ( ) % ( 48 < < 8 ) ) ,
SCRAP3 + ( krand ( ) & 3 ) , - 8 , 48 , 48 , krand ( ) & 2047 , ( krand ( ) & 63 ) + 64 ,
- ( krand ( ) & 4095 ) - ( sprite [ spriteNum ] . zvel > > 2 ) , spriteNum , 5 ) ;
2006-04-13 20:47:06 +00:00
sprite [ j ] . pal = 2 ;
}
2016-08-27 01:40:35 +00:00
j = A_Spawn ( spriteNum , EXPLOSION2 ) ;
2010-07-03 08:53:57 +00:00
A_PlaySound ( PIPEBOMB_EXPLODE , j ) ;
A_PlaySound ( GLASS_HEAVYBREAK , j ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( ( int16_t ) pSprite - > hitag > 0 )
2006-04-13 20:47:06 +00:00
{
2013-04-15 10:48:09 +00:00
for ( SPRITES_OF ( STAT_STANDABLE , j ) )
2006-04-13 20:47:06 +00:00
{
2013-04-15 10:48:09 +00:00
// XXX: This block seems to be CODEDUP'd a lot of times.
2016-08-27 01:40:35 +00:00
if ( pSprite - > hitag = = sprite [ j ] . hitag & & ( sprite [ j ] . picnum = = OOZFILTER | | sprite [ j ] . picnum = = SEENINE ) )
2006-11-13 23:12:47 +00:00
if ( sprite [ j ] . shade ! = - 32 )
2006-04-13 20:47:06 +00:00
sprite [ j ] . shade = - 32 ;
}
2017-06-23 09:16:21 +00:00
int const dmg = pSprite - > extra ;
A_RadiusDamage ( spriteNum , g_pipebombRadius , dmg > > 2 , dmg - ( dmg > > 1 ) , dmg - ( dmg > > 2 ) , dmg ) ;
2016-08-27 01:40:35 +00:00
j = A_Spawn ( spriteNum , EXPLOSION2 ) ;
2010-07-03 08:53:57 +00:00
A_PlaySound ( PIPEBOMB_EXPLODE , j ) ;
2006-04-13 20:47:06 +00:00
goto DETONATE ;
}
else
{
2016-08-27 01:42:01 +00:00
A_RadiusDamage ( spriteNum , g_seenineRadius , 10 , 15 , 20 , 25 ) ;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2018-04-02 22:00:44 +00:00
else
# endif
if ( pSprite - > picnum = = OOZFILTER | | pSprite - > picnum = = SEENINE | | pSprite - > picnum = = SEENINEDEAD | | pSprite - > picnum = = SEENINEDEAD + 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > shade ! = - 32 & & pSprite - > shade ! = - 33 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > xrepeat )
j = ( A_IncurDamage ( spriteNum ) > = 0 ) ;
2006-04-13 20:47:06 +00:00
else
j = 0 ;
2016-08-27 01:40:35 +00:00
if ( j | | pSprite - > shade = = - 31 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( j ) pSprite - > lotag = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pData [ 3 ] = 1 ;
2006-04-13 20:47:06 +00:00
2013-04-15 10:48:09 +00:00
for ( SPRITES_OF ( STAT_STANDABLE , j ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > hitag = = sprite [ j ] . hitag & & ( sprite [ j ] . picnum = = SEENINE | | sprite [ j ] . picnum = = OOZFILTER ) )
2006-04-13 20:47:06 +00:00
sprite [ j ] . shade = - 32 ;
}
}
}
else
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > shade = = - 32 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( ( int16_t ) pSprite - > lotag > 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > lotag - = 3 ;
if ( ( int16_t ) pSprite - > lotag < = 0 )
2018-01-15 23:13:50 +00:00
pSprite - > lotag = - 99 ;
2006-04-13 20:47:06 +00:00
}
else
2016-08-27 01:40:35 +00:00
pSprite - > shade = - 33 ;
2006-04-13 20:47:06 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > xrepeat > 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
T3 ( spriteNum ) + + ;
if ( T3 ( spriteNum ) = = 3 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum = = OOZFILTER )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
T3 ( spriteNum ) = 0 ;
2006-04-13 20:47:06 +00:00
goto DETONATE ;
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum ! = ( SEENINEDEAD + 1 ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
T3 ( spriteNum ) = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum = = SEENINEDEAD )
pSprite - > picnum + + ;
else if ( pSprite - > picnum = = SEENINE )
pSprite - > picnum = SEENINEDEAD ;
2006-04-13 20:47:06 +00:00
}
else goto DETONATE ;
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
DETONATE :
2008-11-20 14:06:36 +00:00
g_earthquakeTime = 16 ;
2006-04-13 20:47:06 +00:00
2013-04-15 10:48:09 +00:00
for ( SPRITES_OF ( STAT_EFFECTOR , j ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > hitag = = sprite [ j ] . hitag )
2006-04-13 20:47:06 +00:00
{
2012-09-08 22:18:44 +00:00
if ( sprite [ j ] . lotag = = SE_13_EXPLOSIVE )
2006-04-13 20:47:06 +00:00
{
2010-05-02 23:27:30 +00:00
if ( actor [ j ] . t_data [ 2 ] = = 0 )
actor [ j ] . t_data [ 2 ] = 1 ;
2006-04-13 20:47:06 +00:00
}
2012-09-08 22:18:44 +00:00
else if ( sprite [ j ] . lotag = = SE_8_UP_OPEN_DOOR_LIGHTS )
2010-05-02 23:27:30 +00:00
actor [ j ] . t_data [ 4 ] = 1 ;
2012-09-08 22:18:44 +00:00
else if ( sprite [ j ] . lotag = = SE_18_INCREMENTAL_SECTOR_RISE_FALL )
2006-04-13 20:47:06 +00:00
{
2010-05-02 23:27:30 +00:00
if ( actor [ j ] . t_data [ 0 ] = = 0 )
actor [ j ] . t_data [ 0 ] = 1 ;
2006-04-13 20:47:06 +00:00
}
2012-08-26 22:16:08 +00:00
else if ( sprite [ j ] . lotag = = SE_21_DROP_FLOOR )
2010-05-02 23:27:30 +00:00
actor [ j ] . t_data [ 0 ] = 1 ;
2006-04-13 20:47:06 +00:00
}
}
2016-08-27 01:40:56 +00:00
pSprite - > z - = ZOFFSET5 ;
2006-04-13 20:47:06 +00:00
2018-06-09 20:36:31 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY & & pSprite - > xrepeat )
2019-05-19 03:56:13 +00:00
for ( int x = 0 ; x < 8 ; x + + )
2017-06-23 09:16:21 +00:00
RANDOMSCRAP ( pSprite , spriteNum ) ;
2018-06-09 20:36:31 +00:00
# endif
2010-07-03 08:53:57 +00:00
2016-08-27 01:40:35 +00:00
if ( ( pData [ 3 ] = = 1 & & pSprite - > xrepeat ) | | ( int16_t ) pSprite - > lotag = = - 99 )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
int const newSprite = A_Spawn ( spriteNum , EXPLOSION2 ) ;
int const dmg = pSprite - > extra ;
A_RadiusDamage ( spriteNum , g_seenineRadius , dmg > > 2 , dmg - ( dmg > > 1 ) , dmg - ( dmg > > 2 ) , dmg ) ;
A_PlaySound ( PIPEBOMB_EXPLODE , newSprite ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pSprite - > picnum = = MASTERSWITCH )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > yvel = = 1 )
2006-04-13 20:47:06 +00:00
{
2017-06-23 09:16:21 +00:00
if ( ( int16_t ) - - pSprite - > hitag < = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
G_OperateSectors ( sectNum , spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
for ( SPRITES_OF_SECT ( sectNum , j ) )
2006-04-13 20:47:06 +00:00
{
2009-08-06 10:12:13 +00:00
if ( sprite [ j ] . statnum = = STAT_EFFECTOR )
2006-04-13 20:47:06 +00:00
{
2006-11-13 23:12:47 +00:00
switch ( sprite [ j ] . lotag )
2006-04-13 20:47:06 +00:00
{
2012-09-08 22:18:44 +00:00
case SE_2_EARTHQUAKE :
2012-08-26 22:16:08 +00:00
case SE_21_DROP_FLOOR :
case SE_31_FLOOR_RISE_FALL :
case SE_32_CEILING_RISE_FALL :
case SE_36_PROJ_SHOOTER :
2010-05-02 23:27:30 +00:00
actor [ j ] . t_data [ 0 ] = 1 ;
2006-11-16 03:02:42 +00:00
break ;
2012-09-08 22:18:44 +00:00
case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT :
2010-05-02 23:27:30 +00:00
actor [ j ] . t_data [ 4 ] = 1 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
}
2009-08-06 10:12:13 +00:00
else if ( sprite [ j ] . statnum = = STAT_STANDABLE )
2006-04-13 20:47:06 +00:00
{
2012-01-28 14:38:23 +00:00
switch ( DYNAMICTILEMAP ( sprite [ j ] . picnum ) )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case SEENINE__STATIC :
case OOZFILTER__STATIC :
sprite [ j ] . shade = - 31 ;
break ;
2006-04-13 20:47:06 +00:00
}
}
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
switchPic = pSprite - > picnum ;
2006-04-13 20:47:06 +00:00
2018-04-02 22:00:44 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY )
{
if ( switchPic > SIDEBOLT1 & & switchPic < = SIDEBOLT1 + 3 )
switchPic = SIDEBOLT1 ;
else if ( switchPic > BOLT1 & & switchPic < = BOLT1 + 3 )
switchPic = BOLT1 ;
}
2018-04-02 22:00:44 +00:00
# endif
2016-08-27 01:40:35 +00:00
switch ( DYNAMICTILEMAP ( switchPic ) )
2006-11-16 03:02:42 +00:00
{
2018-04-02 22:00:44 +00:00
case TOUCHPLATE__STATIC :
if ( pData [ 1 ] = = 1 & & ( int16_t ) pSprite - > hitag > = 0 ) // Move the sector floor
{
int const floorZ = sector [ sectNum ] . floorz ;
if ( pData [ 3 ] = = 1 )
{
if ( floorZ > = pData [ 2 ] )
{
sector [ sectNum ] . floorz = floorZ ;
pData [ 1 ] = 0 ;
}
else
{
sector [ sectNum ] . floorz + = sector [ sectNum ] . extra ;
2020-01-29 11:37:20 +00:00
int const playerNum = G_GetPlayerInSector ( sectNum ) ;
2018-04-02 22:00:44 +00:00
if ( playerNum > = 0 )
g_player [ playerNum ] . ps - > pos . z + = sector [ sectNum ] . extra ;
}
}
else
{
if ( floorZ < = pSprite - > z )
{
sector [ sectNum ] . floorz = pSprite - > z ;
pData [ 1 ] = 0 ;
}
else
{
int32_t p ;
sector [ sectNum ] . floorz - = sector [ sectNum ] . extra ;
2020-01-29 11:37:20 +00:00
p = G_GetPlayerInSector ( sectNum ) ;
2018-04-02 22:00:44 +00:00
if ( p > = 0 )
g_player [ p ] . ps - > pos . z - = sector [ sectNum ] . extra ;
}
}
goto next_sprite ;
}
if ( pData [ 5 ] = = 1 )
goto next_sprite ;
{
2020-01-29 11:37:20 +00:00
int32_t p = G_GetPlayerInSector ( sectNum ) ;
2018-04-02 22:00:44 +00:00
if ( p > = 0 & & ( g_player [ p ] . ps - > on_ground | | pSprite - > ang = = 512 ) )
{
if ( pData [ 0 ] = = 0 & & ! G_CheckActivatorMotion ( pSprite - > lotag ) )
{
pData [ 0 ] = 1 ;
pData [ 1 ] = 1 ;
pData [ 3 ] = ! pData [ 3 ] ;
G_OperateMasterSwitches ( pSprite - > lotag ) ;
G_OperateActivators ( pSprite - > lotag , p ) ;
if ( ( int16_t ) pSprite - > hitag > 0 )
{
pSprite - > hitag - - ;
if ( pSprite - > hitag = = 0 )
pData [ 5 ] = 1 ;
}
}
}
else
pData [ 0 ] = 0 ;
}
if ( pData [ 1 ] = = 1 )
{
for ( SPRITES_OF ( STAT_STANDABLE , j ) )
{
if ( j ! = spriteNum & & sprite [ j ] . picnum = = TOUCHPLATE & & sprite [ j ] . lotag = = pSprite - > lotag )
{
actor [ j ] . t_data [ 1 ] = 1 ;
actor [ j ] . t_data [ 3 ] = pData [ 3 ] ;
}
}
}
goto next_sprite ;
2016-08-27 01:40:35 +00:00
case VIEWSCREEN__STATIC :
case VIEWSCREEN2__STATIC :
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xrepeat = = 0 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
{
2019-07-08 00:41:25 +00:00
int32_t playerDist ;
int const p = A_FindPlayer ( pSprite , & playerDist ) ;
auto const ps = g_player [ p ] . ps ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( dist ( & sprite [ ps - > i ] , pSprite ) < VIEWSCREEN_ACTIVE_DISTANCE )
{
#if 0
if ( sprite [ i ] . yvel = = 1 ) // VIEWSCREEN_YVEL
g_curViewscreen = i ;
# endif
}
else if ( g_curViewscreen = = spriteNum /*&& T1 == 1*/ )
{
g_curViewscreen = - 1 ;
sprite [ spriteNum ] . yvel = 0 ; // VIEWSCREEN_YVEL
T1 ( spriteNum ) = 0 ;
}
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2020-01-29 11:37:16 +00:00
}
2018-04-02 22:00:44 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY )
switch ( DYNAMICTILEMAP ( switchPic ) )
{
2016-08-27 01:40:35 +00:00
case TRASH__STATIC :
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel = = 0 )
pSprite - > xvel = 1 ;
if ( A_SetSprite ( spriteNum , CLIPMASK0 ) )
{
A_Fall ( spriteNum ) ;
if ( krand ( ) & 1 )
pSprite - > zvel - = 256 ;
if ( ( pSprite - > xvel ) < 48 )
pSprite - > xvel + = ( krand ( ) & 3 ) ;
}
else
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2016-08-27 01:40:35 +00:00
break ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
case SIDEBOLT1__STATIC :
2018-01-28 04:30:53 +00:00
// case SIDEBOLT1+1:
// case SIDEBOLT1+2:
// case SIDEBOLT1+3:
{
int32_t playerDist ;
A_FindPlayer ( pSprite , & playerDist ) ;
if ( playerDist > 20480 )
goto next_sprite ;
CLEAR_THE_BOLT2 :
if ( pData [ 2 ] )
{
pData [ 2 ] - - ;
goto next_sprite ;
}
if ( ( pSprite - > xrepeat | pSprite - > yrepeat ) = = 0 )
{
pSprite - > xrepeat = pData [ 0 ] ;
pSprite - > yrepeat = pData [ 1 ] ;
}
if ( ( krand ( ) & 8 ) = = 0 )
{
pData [ 0 ] = pSprite - > xrepeat ;
pData [ 1 ] = pSprite - > yrepeat ;
pData [ 2 ] = g_globalRandom & 4 ;
pSprite - > xrepeat = pSprite - > yrepeat = 0 ;
goto CLEAR_THE_BOLT2 ;
}
pSprite - > picnum + + ;
#if 0
// NOTE: Um, this 'l' was assigned to last at the beginning of this function.
// SIDEBOLT1 never gets translucent as a consequence, unlike BOLT1.
if ( randomRepeat & 1 )
pSprite - > cstat ^ = 2 ;
# endif
if ( ( krand ( ) & 1 ) & & sector [ sectNum ] . floorpicnum = = HURTRAIL )
A_PlaySound ( SHORT_CIRCUIT , spriteNum ) ;
if ( pSprite - > picnum = = SIDEBOLT1 + 4 )
pSprite - > picnum = SIDEBOLT1 ;
goto next_sprite ;
}
2016-08-27 01:40:35 +00:00
case BOLT1__STATIC :
2018-01-28 04:30:53 +00:00
// case BOLT1+1:
// case BOLT1+2:
// case BOLT1+3:
2017-06-23 09:16:21 +00:00
{
int32_t playerDist ;
A_FindPlayer ( pSprite , & playerDist ) ;
if ( playerDist > 20480 )
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 3 ] = = 0 )
pData [ 3 ] = sector [ sectNum ] . floorshade ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
CLEAR_THE_BOLT :
if ( pData [ 2 ] )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 2 ] - - ;
2018-01-28 04:30:53 +00:00
sector [ sectNum ] . floorshade = 20 ;
sector [ sectNum ] . ceilingshade = 20 ;
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
if ( ( pSprite - > xrepeat | pSprite - > yrepeat ) = = 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xrepeat = pData [ 0 ] ;
pSprite - > yrepeat = pData [ 1 ] ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( ( krand ( ) & 8 ) = = 0 )
{
pData [ 0 ] = pSprite - > xrepeat ;
pData [ 1 ] = pSprite - > yrepeat ;
pData [ 2 ] = g_globalRandom & 4 ;
pSprite - > xrepeat = pSprite - > yrepeat = 0 ;
goto CLEAR_THE_BOLT ;
}
pSprite - > picnum + + ;
2006-04-13 20:47:06 +00:00
2017-06-23 09:16:21 +00:00
int const randomRepeat = g_globalRandom & 7 ;
pSprite - > xrepeat = randomRepeat + 8 ;
2006-04-13 20:47:06 +00:00
2017-06-23 09:16:21 +00:00
if ( randomRepeat & 1 )
2016-08-27 01:40:35 +00:00
pSprite - > cstat ^ = 2 ;
2006-04-13 20:47:06 +00:00
2018-01-28 04:30:53 +00:00
if ( pSprite - > picnum = = ( BOLT1 + 1 )
2017-06-23 09:16:21 +00:00
& & ( krand ( ) & 7 ) = = 0 & & sector [ sectNum ] . floorpicnum = = HURTRAIL )
2016-08-27 01:40:35 +00:00
A_PlaySound ( SHORT_CIRCUIT , spriteNum ) ;
2006-04-13 20:47:06 +00:00
2018-01-28 04:30:53 +00:00
if ( pSprite - > picnum = = BOLT1 + 4 )
pSprite - > picnum = BOLT1 ;
2017-06-23 09:16:21 +00:00
2018-01-28 04:30:53 +00:00
if ( pSprite - > picnum & 1 )
{
sector [ sectNum ] . floorshade = 0 ;
sector [ sectNum ] . ceilingshade = 0 ;
}
else
{
sector [ sectNum ] . floorshade = 20 ;
sector [ sectNum ] . ceilingshade = 20 ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2017-06-23 09:16:21 +00:00
}
2016-08-27 01:40:35 +00:00
case WATERDRIP__STATIC :
if ( pData [ 1 ] )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( - - pData [ 1 ] = = 0 )
pSprite - > cstat & = 32767 ;
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
A_Fall ( spriteNum ) ;
A_SetSprite ( spriteNum , CLIPMASK0 ) ;
if ( pSprite - > xvel > 0 )
pSprite - > xvel - = 2 ;
if ( pSprite - > zvel = = 0 )
{
pSprite - > cstat | = 32768 ;
if ( pSprite - > pal ! = 2 & & pSprite - > hitag = = 0 )
A_PlaySound ( SOMETHING_DRIPPING , spriteNum ) ;
if ( sprite [ pSprite - > owner ] . picnum ! = WATERDRIP )
{
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2016-08-27 01:40:35 +00:00
}
else
{
actor [ spriteNum ] . bpos . z = pSprite - > z = pData [ 0 ] ;
pData [ 1 ] = 48 + ( krand ( ) & 31 ) ;
}
}
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
case DOORSHOCK__STATIC :
2017-06-23 09:16:21 +00:00
pSprite - > yrepeat = ( klabs ( sector [ sectNum ] . ceilingz - sector [ sectNum ] . floorz ) > > 9 ) + 4 ;
2016-08-27 01:40:35 +00:00
pSprite - > xrepeat = 16 ;
pSprite - > z = sector [ sectNum ] . floorz ;
goto next_sprite ;
case CANWITHSOMETHING__STATIC :
case CANWITHSOMETHING2__STATIC :
case CANWITHSOMETHING3__STATIC :
case CANWITHSOMETHING4__STATIC :
A_Fall ( spriteNum ) ;
if ( A_IncurDamage ( spriteNum ) > = 0 )
{
A_PlaySound ( VENT_BUST , spriteNum ) ;
2010-05-02 23:27:30 +00:00
2016-08-27 01:40:35 +00:00
for ( j = 9 ; j > = 0 ; j - - ) RANDOMSCRAP ( pSprite , spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > lotag )
A_Spawn ( spriteNum , pSprite - > lotag ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2016-08-27 01:40:35 +00:00
}
goto next_sprite ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
case FLOORFLAME__STATIC :
case FIREBARREL__STATIC :
case FIREVASE__STATIC :
case EXPLODINGBARREL__STATIC :
case WOODENHORSE__STATIC :
case HORSEONSIDE__STATIC :
case NUKEBARREL__STATIC :
case NUKEBARRELDENTED__STATIC :
case NUKEBARRELLEAKED__STATIC :
case TOILETWATER__STATIC :
case RUBBERCAN__STATIC :
case STEAM__STATIC :
case CEILINGSTEAM__STATIC :
case WATERBUBBLEMAKER__STATIC :
2020-04-05 06:40:38 +00:00
if ( ! G_TileHasActor ( sprite [ spriteNum ] . picnum ) )
2016-08-27 01:40:35 +00:00
goto next_sprite ;
{
2017-06-23 09:16:21 +00:00
int32_t playerDist ;
int const playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
A_Execute ( spriteNum , playerNum , playerDist ) ;
2016-08-27 01:40:35 +00:00
}
goto next_sprite ;
2012-08-10 19:11:56 +00:00
}
2020-01-29 11:37:16 +00:00
# endif
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
next_sprite :
spriteNum = nextSprite ;
2006-04-13 20:47:06 +00:00
}
}
2017-06-23 09:16:21 +00:00
ACTOR_STATIC void A_DoProjectileBounce ( int const spriteNum )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pSprite = & sprite [ spriteNum ] ;
2016-08-27 01:40:35 +00:00
int32_t const hitSectnum = pSprite - > sectnum ;
int const firstWall = sector [ hitSectnum ] . wallptr ;
int const secondWall = wall [ firstWall ] . point2 ;
int const wallAngle = getangle ( wall [ secondWall ] . x - wall [ firstWall ] . x , wall [ secondWall ] . y - wall [ firstWall ] . y ) ;
vec3_t vect = { mulscale10 ( pSprite - > xvel , sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) ,
mulscale10 ( pSprite - > xvel , sintable [ pSprite - > ang & 2047 ] ) , pSprite - > zvel } ;
2006-04-13 20:47:06 +00:00
2017-06-23 09:16:21 +00:00
int k = ( pSprite - > z < ( actor [ spriteNum ] . floorz + actor [ spriteNum ] . ceilingz ) > > 1 ) ? sector [ hitSectnum ] . ceilingheinum
2016-08-27 01:40:35 +00:00
: sector [ hitSectnum ] . floorheinum ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
vec3_t const da = { mulscale14 ( k , sintable [ ( wallAngle ) & 2047 ] ) ,
mulscale14 ( k , sintable [ ( wallAngle + 1536 ) & 2047 ] ) , 4096 } ;
2016-06-21 00:34:07 +00:00
2016-08-27 01:40:35 +00:00
k = vect . x * da . x + vect . y * da . y + vect . z * da . z ;
int l = da . x * da . x + da . y * da . y + da . z * da . z ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( ( klabs ( k ) > > 14 ) < l )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
k = divscale17 ( k , l ) ;
vect . x - = mulscale16 ( da . x , k ) ;
vect . y - = mulscale16 ( da . y , k ) ;
vect . z - = mulscale16 ( da . z , k ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
pSprite - > zvel = vect . z ;
pSprite - > xvel = ksqrt ( dmulscale8 ( vect . x , vect . x , vect . y , vect . y ) ) ;
pSprite - > ang = getangle ( vect . x , vect . y ) ;
2006-04-13 20:47:06 +00:00
}
2016-06-21 00:34:07 +00:00
ACTOR_STATIC void P_HandleBeingSpitOn ( DukePlayer_t * const ps )
2012-02-09 22:42:51 +00:00
{
2018-03-07 04:21:18 +00:00
ps - > q16horiz + = F16 ( 32 ) ;
2012-02-09 22:42:51 +00:00
ps - > return_to_center = 8 ;
2016-06-21 00:34:07 +00:00
if ( ps - > loogcnt )
return ;
2012-02-09 22:42:51 +00:00
2016-06-21 00:34:07 +00:00
if ( ! A_CheckSoundPlaying ( ps - > i , DUKE_LONGTERM_PAIN ) )
A_PlaySound ( DUKE_LONGTERM_PAIN , ps - > i ) ;
2012-02-09 22:42:51 +00:00
2016-06-21 00:34:07 +00:00
int j = 3 + ( krand ( ) & 3 ) ;
ps - > numloogs = j ;
ps - > loogcnt = 24 * 4 ;
2016-08-27 01:41:21 +00:00
for ( bssize_t x = 0 ; x < j ; x + + )
2016-06-21 00:34:07 +00:00
{
ps - > loogiex [ x ] = krand ( ) % xdim ;
ps - > loogiey [ x ] = krand ( ) % ydim ;
2012-02-09 22:42:51 +00:00
}
}
2016-08-27 01:41:33 +00:00
static void A_DoProjectileEffects ( int spriteNum , const vec3_t * davect , int radiusDamage )
2012-07-01 22:11:22 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pProj = & SpriteProjectile [ spriteNum ] ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:40:35 +00:00
if ( pProj - > spawns > = 0 )
2012-07-01 22:11:22 +00:00
{
2017-06-23 09:16:21 +00:00
int const newSpr = A_Spawn ( spriteNum , pProj - > spawns ) ;
2012-07-01 22:11:22 +00:00
if ( davect )
2017-06-23 09:16:21 +00:00
Bmemcpy ( & sprite [ newSpr ] , davect , sizeof ( vec3_t ) ) ;
2012-07-01 22:11:22 +00:00
2016-08-27 01:40:35 +00:00
if ( pProj - > sxrepeat > 4 )
2017-06-23 09:16:21 +00:00
sprite [ newSpr ] . xrepeat = pProj - > sxrepeat ;
2016-08-27 01:40:35 +00:00
if ( pProj - > syrepeat > 4 )
2017-06-23 09:16:21 +00:00
sprite [ newSpr ] . yrepeat = pProj - > syrepeat ;
2012-07-01 22:11:22 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pProj - > isound > = 0 )
A_PlaySound ( pProj - > isound , spriteNum ) ;
2012-07-01 22:11:22 +00:00
2016-08-27 01:40:35 +00:00
if ( ! radiusDamage )
2016-06-21 00:34:07 +00:00
return ;
2019-07-08 00:41:25 +00:00
auto const pSprite = & sprite [ spriteNum ] ;
2016-08-27 01:40:35 +00:00
pSprite - > extra = Proj_GetDamage ( pProj ) ;
2017-06-23 09:16:21 +00:00
int const dmg = pSprite - > extra ;
A_RadiusDamage ( spriteNum , pProj - > hitradius , dmg > > 2 , dmg > > 1 , dmg - ( dmg > > 2 ) , dmg ) ;
2012-07-01 22:11:22 +00:00
}
2017-01-01 13:23:29 +00:00
static void G_WeaponHitCeilingOrFloor ( int32_t i , spritetype * s , int * j )
2012-10-14 20:41:30 +00:00
{
2014-02-22 19:38:52 +00:00
if ( actor [ i ] . flags & SFLAG_DIDNOSE7WATER )
2013-04-15 10:48:18 +00:00
{
2014-02-22 19:38:52 +00:00
actor [ i ] . flags & = ~ SFLAG_DIDNOSE7WATER ;
2013-04-15 10:48:05 +00:00
return ;
2013-04-15 10:48:18 +00:00
}
2013-04-15 10:48:05 +00:00
2012-10-14 20:41:30 +00:00
if ( s - > z < actor [ i ] . ceilingz )
{
* j = 16384 | s - > sectnum ;
s - > zvel = - 1 ;
}
2016-08-27 01:40:06 +00:00
else if ( s - > z > actor [ i ] . floorz + ZOFFSET2 * ( sector [ s - > sectnum ] . lotag = = ST_1_ABOVE_WATER ) )
2012-10-14 20:41:30 +00:00
{
* j = 16384 | s - > sectnum ;
if ( sector [ s - > sectnum ] . lotag ! = ST_1_ABOVE_WATER )
s - > zvel = 1 ;
}
}
2016-06-21 00:34:07 +00:00
static void Proj_BounceOffWall ( spritetype * s , int j )
2013-02-07 21:00:55 +00:00
{
2016-06-21 00:34:07 +00:00
int k = getangle (
2013-02-07 21:00:55 +00:00
wall [ wall [ j ] . point2 ] . x - wall [ j ] . x ,
wall [ wall [ j ] . point2 ] . y - wall [ j ] . y ) ;
s - > ang = ( ( k < < 1 ) - s - > ang ) & 2047 ;
}
2013-12-20 18:31:26 +00:00
# define PROJ_DECAYVELOCITY(s) s->xvel >>= 1, s->zvel >>= 1
// Maybe damage a ceiling or floor as the consequence of projectile impact.
// Returns 1 if sprite <s> should be killed.
// NOTE: Compare with Proj_MaybeDamageCF2() in sector.c
2018-03-17 03:26:10 +00:00
static int Proj_MaybeDamageCF ( int spriteNum )
2013-12-20 18:31:26 +00:00
{
2019-04-18 17:25:24 +00:00
auto const s = ( uspriteptr_t ) & sprite [ spriteNum ] ;
2018-03-17 03:26:10 +00:00
2013-12-20 18:31:26 +00:00
if ( s - > zvel < 0 )
{
if ( ( sector [ s - > sectnum ] . ceilingstat & 1 ) & & sector [ s - > sectnum ] . ceilingpal = = 0 )
return 1 ;
2018-03-17 03:26:10 +00:00
Sect_DamageCeiling ( spriteNum , s - > sectnum ) ;
2013-12-20 18:31:29 +00:00
}
else if ( s - > zvel > 0 )
{
if ( ( sector [ s - > sectnum ] . floorstat & 1 ) & & sector [ s - > sectnum ] . floorpal = = 0 )
{
// Keep original Duke3D behavior: pass projectiles through
// parallaxed ceilings, but NOT through such floors.
return 0 ;
}
2018-03-17 03:26:10 +00:00
Sect_DamageFloor ( spriteNum , s - > sectnum ) ;
2013-12-20 18:31:26 +00:00
}
return 0 ;
}
2013-08-06 23:53:34 +00:00
2017-06-23 09:16:21 +00:00
ACTOR_STATIC void Proj_MoveCustom ( int const spriteNum )
2006-04-13 20:47:06 +00:00
{
2019-03-19 17:10:17 +00:00
int projectileMoved = SpriteProjectile [ spriteNum ] . workslike & PROJECTILE_MOVED ;
2016-08-27 01:40:35 +00:00
SpriteProjectile [ spriteNum ] . workslike | = PROJECTILE_MOVED ;
2019-07-08 00:41:25 +00:00
auto const pProj = & SpriteProjectile [ spriteNum ] ;
auto const pSprite = & sprite [ spriteNum ] ;
vec3_t davect ;
int otherSprite = 0 ;
2016-08-27 01:40:35 +00:00
switch ( pProj - > workslike & PROJECTILE_TYPE_MASK )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
case PROJECTILE_HITSCAN :
2013-08-06 23:53:34 +00:00
{
2020-04-05 06:40:38 +00:00
if ( ! G_TileHasActor ( sprite [ spriteNum ] . picnum ) )
2016-08-27 01:41:33 +00:00
return ;
int32_t playerDist ;
int const playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
A_Execute ( spriteNum , playerNum , playerDist ) ;
return ;
2013-08-06 23:53:34 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
case PROJECTILE_KNEE :
case PROJECTILE_BLOOD : A_DeleteSprite ( spriteNum ) ; return ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
default :
case PROJECTILE_RPG :
{
2019-06-25 11:28:25 +00:00
davect = pSprite - > pos ;
2016-08-27 01:42:01 +00:00
VM_UpdateAnim ( spriteNum , & actor [ spriteNum ] . t_data [ 0 ] ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > flashcolor )
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , 2048 , pProj - > flashcolor ,
PR_LIGHT_PRIO_LOW_GAME ) ;
2016-04-13 04:04:13 +00:00
2016-08-27 01:41:33 +00:00
if ( ( pProj - > workslike & ( PROJECTILE_BOUNCESOFFWALLS | PROJECTILE_EXPLODEONTIMER ) ) = = PROJECTILE_BOUNCESOFFWALLS
& & pSprite - > yvel < 1 )
{
A_DoProjectileEffects ( spriteNum , & davect , 1 ) ;
A_DeleteSprite ( spriteNum ) ;
return ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > workslike & PROJECTILE_COOLEXPLOSION1 & & + + pSprite - > shade > = 40 )
{
A_DeleteSprite ( spriteNum ) ;
return ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
pSprite - > zvel - = pProj - > drop ;
2006-04-13 20:47:06 +00:00
2020-02-11 09:21:44 +00:00
if ( pProj - > workslike & PROJECTILE_SPIT & & pSprite - > zvel < ACTOR_MAXFALLINGZVEL )
2016-08-27 01:41:33 +00:00
pSprite - > zvel + = g_spriteGravity - 112 ;
2006-04-13 20:47:06 +00:00
2019-05-19 03:55:40 +00:00
A_GetZLimits ( spriteNum ) ;
2016-08-27 01:41:33 +00:00
if ( pProj - > trail > = 0 )
2013-08-06 23:53:34 +00:00
{
2016-08-27 01:41:33 +00:00
for ( bssize_t cnt = 0 ; cnt < = pProj - > tnum ; cnt + + )
{
otherSprite = A_Spawn ( spriteNum , pProj - > trail ) ;
2009-02-19 09:39:19 +00:00
2016-08-27 01:41:33 +00:00
sprite [ otherSprite ] . z + = ( pProj - > toffset < < 8 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > txrepeat > = 0 )
sprite [ otherSprite ] . xrepeat = pProj - > txrepeat ;
2006-12-18 04:18:46 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > tyrepeat > = 0 )
sprite [ otherSprite ] . yrepeat = pProj - > tyrepeat ;
}
2013-08-06 23:53:34 +00:00
}
2006-12-18 04:18:46 +00:00
2016-08-27 01:41:33 +00:00
int projMoveCnt = pProj - > movecnt ;
int projVel = pSprite - > xvel ;
int projZvel = pSprite - > zvel ;
2006-12-18 04:18:46 +00:00
2016-08-27 01:40:35 +00:00
if ( sector [ pSprite - > sectnum ] . lotag = = ST_2_UNDERWATER )
2013-08-06 23:53:34 +00:00
{
2016-08-27 01:40:35 +00:00
projVel > > = 1 ;
projZvel > > = 1 ;
2013-08-06 23:53:34 +00:00
}
2012-10-05 20:48:10 +00:00
2013-08-06 23:53:34 +00:00
do
{
2019-03-19 17:10:17 +00:00
vec3_t tmpvect = { ( projVel * ( sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) ) > > 14 > > ( int ) ! projectileMoved ,
( projVel * ( sintable [ pSprite - > ang & 2047 ] ) ) > > 14 > > ( int ) ! projectileMoved , projZvel > > ( int ) ! projectileMoved } ;
2016-08-27 01:40:35 +00:00
Bmemcpy ( & davect , pSprite , sizeof ( vec3_t ) ) ;
2019-03-19 17:10:17 +00:00
projectileMoved + + ;
otherSprite = A_MoveSprite ( spriteNum , & tmpvect , ( A_CheckSpriteFlags ( spriteNum , SFLAG_NOCLIP ) ? 0 : CLIPMASK1 ) ) ;
2016-08-27 01:42:01 +00:00
}
while ( ! otherSprite & & - - projMoveCnt > 0 ) ;
2015-12-28 02:04:41 +00:00
2016-08-27 01:41:33 +00:00
if ( ! ( pProj - > workslike & PROJECTILE_BOUNCESOFFWALLS ) & & // NOT_BOUNCESOFFWALLS_YVEL
( unsigned ) pSprite - > yvel < MAXSPRITES
& & sprite [ pSprite - > yvel ] . sectnum ! = MAXSECTORS )
if ( FindDistance2D ( pSprite - > x - sprite [ pSprite - > yvel ] . x , pSprite - > y - sprite [ pSprite - > yvel ] . y ) < 256 )
otherSprite = 49152 | pSprite - > yvel ;
2006-12-18 04:18:46 +00:00
2016-08-27 01:41:33 +00:00
actor [ spriteNum ] . movflag = otherSprite ;
2012-10-11 03:25:10 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > sectnum < 0 )
2013-08-06 23:53:34 +00:00
{
2016-08-27 01:40:35 +00:00
A_DeleteSprite ( spriteNum ) ;
2013-08-06 23:53:34 +00:00
return ;
}
2009-01-13 04:40:56 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > workslike & PROJECTILE_TIMED & & pProj - > range > 0 )
2013-08-06 23:53:34 +00:00
{
2016-08-27 01:41:33 +00:00
if ( + + actor [ spriteNum ] . t_data [ 8 ] > pProj - > range )
{
if ( pProj - > workslike & PROJECTILE_EXPLODEONTIMER )
A_DoProjectileEffects ( spriteNum , & davect , 1 ) ;
A_DeleteSprite ( spriteNum ) ;
return ;
}
2013-08-06 23:53:34 +00:00
}
2008-08-26 04:00:42 +00:00
2016-08-27 01:41:33 +00:00
if ( ( otherSprite & 49152 ) ! = 49152 & & ! ( pProj - > workslike & PROJECTILE_BOUNCESOFFWALLS ) )
G_WeaponHitCeilingOrFloor ( spriteNum , pSprite , & otherSprite ) ;
if ( pProj - > workslike & PROJECTILE_WATERBUBBLES & & sector [ pSprite - > sectnum ] . lotag = = ST_2_UNDERWATER & & rnd ( 140 ) )
A_Spawn ( spriteNum , WATERBUBBLE ) ;
if ( otherSprite ! = 0 )
2013-08-06 23:53:34 +00:00
{
2016-08-27 01:41:33 +00:00
if ( pProj - > workslike & PROJECTILE_COOLEXPLOSION1 )
{
pSprite - > xvel = 0 ;
pSprite - > zvel = 0 ;
}
2006-12-18 04:18:46 +00:00
2016-08-27 01:41:33 +00:00
switch ( otherSprite & 49152 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
case 49152 :
otherSprite & = ( MAXSPRITES - 1 ) ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > workslike & PROJECTILE_BOUNCESOFFSPRITES )
{
pSprite - > yvel - - ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
int const projAngle = getangle ( sprite [ otherSprite ] . x - pSprite - > x , sprite [ otherSprite ] . y - pSprite - > y )
2018-10-07 05:23:53 +00:00
+ ( ( sprite [ otherSprite ] . cstat & 16 ) ? 0 : 512 ) ;
2016-08-27 01:41:33 +00:00
pSprite - > ang = ( ( projAngle < < 1 ) - pSprite - > ang ) & 2047 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > bsound > = 0 )
A_PlaySound ( pProj - > bsound , spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > workslike & PROJECTILE_LOSESVELOCITY )
PROJ_DECAYVELOCITY ( pSprite ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( ! ( pProj - > workslike & PROJECTILE_FORCEIMPACT ) )
return ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
A_DamageObject ( otherSprite , spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( sprite [ otherSprite ] . picnum = = APLAYER )
{
int playerNum = P_Get ( otherSprite ) ;
2006-04-13 20:47:06 +00:00
2018-09-01 19:36:20 +00:00
# ifndef EDUKE32_STANDALONE
2019-08-16 12:05:21 +00:00
if ( ! FURY )
A_PlaySound ( PISTOL_BODYHIT , otherSprite ) ;
2018-09-01 19:36:20 +00:00
# endif
2016-08-27 01:41:33 +00:00
if ( pProj - > workslike & PROJECTILE_SPIT )
P_HandleBeingSpitOn ( g_player [ playerNum ] . ps ) ;
}
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > workslike & PROJECTILE_RPG_IMPACT )
{
actor [ otherSprite ] . owner = pSprite - > owner ;
actor [ otherSprite ] . picnum = pSprite - > picnum ;
2018-09-01 19:36:15 +00:00
if ( pProj - > workslike & PROJECTILE_RPG_IMPACT_DAMAGE )
actor [ otherSprite ] . extra + = pProj - > extra ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
A_DoProjectileEffects ( spriteNum , & davect , 0 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( ! ( pProj - > workslike & PROJECTILE_FORCEIMPACT ) )
{
A_DeleteSprite ( spriteNum ) ;
return ;
}
}
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > workslike & PROJECTILE_FORCEIMPACT )
return ;
break ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
case 32768 :
otherSprite & = ( MAXWALLS - 1 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > workslike & PROJECTILE_BOUNCESOFFMIRRORS
& & ( wall [ otherSprite ] . overpicnum = = MIRROR | | wall [ otherSprite ] . picnum = = MIRROR ) )
{
Proj_BounceOffWall ( pSprite , otherSprite ) ;
pSprite - > owner = spriteNum ;
2019-08-16 12:05:21 +00:00
# ifndef EDUKE32_STANDALONE
if ( ! FURY )
A_Spawn ( spriteNum , TRANSPORTERSTAR ) ;
# endif
2016-08-27 01:41:33 +00:00
return ;
}
else
{
setsprite ( spriteNum , & davect ) ;
2019-09-08 01:01:13 +00:00
A_DamageWall ( spriteNum , otherSprite , pSprite - > pos , pSprite - > picnum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > workslike & PROJECTILE_BOUNCESOFFWALLS )
{
if ( wall [ otherSprite ] . overpicnum ! = MIRROR & & wall [ otherSprite ] . picnum ! = MIRROR )
pSprite - > yvel - - ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
Proj_BounceOffWall ( pSprite , otherSprite ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > bsound > = 0 )
A_PlaySound ( pProj - > bsound , spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > workslike & PROJECTILE_LOSESVELOCITY )
PROJ_DECAYVELOCITY ( pSprite ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
return ;
}
}
break ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
case 16384 :
setsprite ( spriteNum , & davect ) ;
2006-04-13 20:47:06 +00:00
2018-03-17 03:26:10 +00:00
if ( Proj_MaybeDamageCF ( spriteNum ) )
2016-08-27 01:41:33 +00:00
{
A_DeleteSprite ( spriteNum ) ;
return ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > workslike & PROJECTILE_BOUNCESOFFWALLS )
{
A_DoProjectileBounce ( spriteNum ) ;
A_SetSprite ( spriteNum , CLIPMASK1 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
pSprite - > yvel - - ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > bsound > = 0 )
A_PlaySound ( pProj - > bsound , spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pProj - > workslike & PROJECTILE_LOSESVELOCITY )
PROJ_DECAYVELOCITY ( pSprite ) ;
return ;
}
break ;
2013-08-06 23:53:34 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
A_DoProjectileEffects ( spriteNum , & davect , 1 ) ;
A_DeleteSprite ( spriteNum ) ;
return ;
}
2013-08-06 23:53:34 +00:00
return ;
}
}
}
2006-04-13 20:47:06 +00:00
2020-03-29 08:41:12 +00:00
# ifndef EDUKE32_STANDALONE
struct SpriteTracerData
{
int32_t x , y , z ;
int32_t xVel , yVel , zVel ;
SpriteTracerData ( ) : x ( 0 ) , y ( 0 ) , z ( 0 ) , xVel ( 0 ) , yVel ( 0 ) , zVel ( 0 ) { }
} ;
std : : map < int , SpriteTracerData > tracerData ;
# endif
2013-08-06 23:53:34 +00:00
ACTOR_STATIC void G_MoveWeapons ( void )
{
2016-08-27 01:41:33 +00:00
int spriteNum = headspritestat [ STAT_PROJECTILE ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
while ( spriteNum > = 0 )
2013-08-06 23:53:34 +00:00
{
2019-07-08 00:41:25 +00:00
int const nextSprite = nextspritestat [ spriteNum ] ;
auto const pSprite = & sprite [ spriteNum ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > sectnum < 0 )
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2019-06-25 11:28:25 +00:00
actor [ spriteNum ] . bpos = pSprite - > pos ;
2012-10-05 20:48:10 +00:00
2013-08-06 23:53:34 +00:00
/* Custom projectiles */
2016-08-27 01:41:33 +00:00
if ( A_CheckSpriteFlags ( spriteNum , SFLAG_PROJECTILE ) )
2013-08-06 23:53:34 +00:00
{
2016-08-27 01:41:33 +00:00
Proj_MoveCustom ( spriteNum ) ;
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2012-10-05 20:48:10 +00:00
// hard coded projectiles
2016-08-27 01:41:33 +00:00
switch ( DYNAMICTILEMAP ( pSprite - > picnum ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
case SHOTSPARK1__STATIC :
2012-10-05 20:48:10 +00:00
{
2020-04-05 06:40:38 +00:00
if ( ! G_TileHasActor ( sprite [ spriteNum ] . picnum ) )
2016-08-27 01:41:33 +00:00
goto next_sprite ;
int32_t playerDist ;
int const playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
A_Execute ( spriteNum , playerNum , playerDist ) ;
goto next_sprite ;
2012-10-05 20:48:10 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
case RADIUSEXPLOSION__STATIC :
case KNEE__STATIC : DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2020-01-29 11:37:16 +00:00
}
2018-04-02 22:00:44 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY )
switch ( DYNAMICTILEMAP ( pSprite - > picnum ) )
{
2016-08-27 01:41:33 +00:00
case FREEZEBLAST__STATIC :
if ( pSprite - > yvel < 1 | | pSprite - > extra < 2 | | ( pSprite - > xvel | pSprite - > zvel ) = = 0 )
{
int const newSprite = A_Spawn ( spriteNum , TRANSPORTERSTAR ) ;
sprite [ newSprite ] . pal = 1 ;
sprite [ newSprite ] . xrepeat = 32 ;
sprite [ newSprite ] . yrepeat = 32 ;
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
}
2017-07-18 20:53:41 +00:00
fallthrough__ ;
2020-03-29 08:41:12 +00:00
case FIREBALL__STATIC :
if ( ! WORLDTOUR & & pSprite - > picnum = = FIREBALL )
break ;
fallthrough__ ;
2016-08-27 01:41:33 +00:00
case SHRINKSPARK__STATIC :
case RPG__STATIC :
case FIRELASER__STATIC :
case SPIT__STATIC :
case COOLEXPLOSION1__STATIC :
2012-10-05 20:48:10 +00:00
{
2019-03-19 17:08:27 +00:00
int const projectileMoved = SpriteProjectile [ spriteNum ] . workslike & PROJECTILE_MOVED ;
SpriteProjectile [ spriteNum ] . workslike | = PROJECTILE_MOVED ;
2016-08-27 01:41:33 +00:00
if ( pSprite - > picnum = = COOLEXPLOSION1 )
2018-12-15 01:39:25 +00:00
if ( ! S_CheckSoundPlaying ( WIERDSHOT_FLY ) )
2016-08-27 01:41:33 +00:00
A_PlaySound ( WIERDSHOT_FLY , spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
int spriteXvel = pSprite - > xvel ;
int spriteZvel = pSprite - > zvel ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > picnum = = RPG & & sector [ pSprite - > sectnum ] . lotag = = ST_2_UNDERWATER )
{
spriteXvel > > = 1 ;
spriteZvel > > = 1 ;
}
2006-04-13 20:47:06 +00:00
2019-06-25 11:28:25 +00:00
vec3_t davect = pSprite - > pos ;
2006-04-13 20:47:06 +00:00
2019-05-19 03:55:40 +00:00
A_GetZLimits ( spriteNum ) ;
2020-03-29 08:41:12 +00:00
int const fireball = ( WORLDTOUR & & pSprite - > picnum = = FIREBALL & & sprite [ pSprite - > owner ] . picnum ! = FIREBALL ) ;
2016-08-27 01:41:33 +00:00
if ( pSprite - > picnum = = RPG & & actor [ spriteNum ] . picnum ! = BOSS2 & & pSprite - > xrepeat > = 10
& & sector [ pSprite - > sectnum ] . lotag ! = ST_2_UNDERWATER
& & g_scriptVersion > = 13 )
{
int const newSprite = A_Spawn ( spriteNum , SMALLSMOKE ) ;
sprite [ newSprite ] . z + = ( 1 < < 8 ) ;
}
2020-03-29 08:41:12 +00:00
if ( pSprite - > picnum = = FIREBALL )
{
if ( sector [ pSprite - > sectnum ] . lotag = = ST_2_UNDERWATER ) { DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ; }
if ( fireball )
{
if ( actor [ spriteNum ] . t_data [ 0 ] > = 1 & & actor [ spriteNum ] . t_data [ 0 ] < 6 )
{
float t = 1.f - 0.2 * actor [ spriteNum ] . t_data [ 0 ] ;
int j = A_Spawn ( spriteNum , FIREBALL ) ;
spritetype * sj = & sprite [ j ] ;
sj - > xvel = pSprite - > xvel ;
sj - > yvel = pSprite - > yvel ;
sj - > zvel = pSprite - > zvel ;
if ( actor [ spriteNum ] . t_data [ 0 ] > 1 )
{
SpriteTracerData t = tracerData [ actor [ spriteNum ] . t_data [ 1 ] ] ;
sj - > x = t . x ;
sj - > y = t . y ;
sj - > z = t . z ;
sj - > xvel = t . xVel ;
sj - > yvel = t . yVel ;
sj - > zvel = t . zVel ;
}
sj - > xrepeat = sj - > yrepeat = t * pSprite - > xrepeat ;
sj - > cstat = pSprite - > cstat ;
sj - > extra = 0 ;
actor [ spriteNum ] . t_data [ 1 ] = j ;
SpriteTracerData tt ;
tt . x = sj - > x ;
tt . y = sj - > y ;
tt . z = sj - > z ;
tt . xVel = sj - > xvel ;
tt . yVel = sj - > yvel ;
tt . zVel = sj - > zvel ;
tracerData [ actor [ spriteNum ] . t_data [ 1 ] ] = tt ;
changespritestat ( j , 4 ) ;
}
actor [ spriteNum ] . t_data [ 0 ] + + ;
}
if ( pSprite - > zvel < 15000 )
pSprite - > zvel + = 200 ;
}
2009-01-13 04:40:56 +00:00
2019-03-19 17:10:17 +00:00
vec3_t const tmpvect = { ( spriteXvel * ( sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) ) > > 14 > > ( int ) ! projectileMoved ,
( spriteXvel * ( sintable [ pSprite - > ang & 2047 ] ) ) > > 14 > > ( int ) ! projectileMoved , spriteZvel > > ( int ) ! projectileMoved } ;
2006-04-13 20:47:06 +00:00
2019-03-19 17:10:17 +00:00
int moveSprite = A_MoveSprite ( spriteNum , & tmpvect , ( A_CheckSpriteFlags ( spriteNum , SFLAG_NOCLIP ) ? 0 : CLIPMASK1 ) ) ;
2008-08-26 04:00:42 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > picnum = = RPG & & ( unsigned ) pSprite - > yvel < MAXSPRITES ) // RPG_YVEL
if ( FindDistance2D ( pSprite - > x - sprite [ pSprite - > yvel ] . x , pSprite - > y - sprite [ pSprite - > yvel ] . y ) < 256 )
moveSprite = 49152 | pSprite - > yvel ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:41:33 +00:00
actor [ spriteNum ] . movflag = moveSprite ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > sectnum < 0 )
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2012-10-14 20:41:28 +00:00
2016-08-27 01:41:33 +00:00
if ( ( moveSprite & 49152 ) ! = 49152 & & pSprite - > picnum ! = FREEZEBLAST )
G_WeaponHitCeilingOrFloor ( spriteNum , pSprite , & moveSprite ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > picnum = = FIRELASER )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
for ( bssize_t k = - 3 ; k < 2 ; k + + )
{
int const newSprite
= A_InsertSprite ( pSprite - > sectnum , pSprite - > x + ( ( k * sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) > > 9 ) ,
pSprite - > y + ( ( k * sintable [ pSprite - > ang & 2047 ] ) > > 9 ) ,
pSprite - > z + ( ( k * ksgn ( pSprite - > zvel ) ) * klabs ( pSprite - > zvel / 24 ) ) , FIRELASER , - 40 + ( k < < 2 ) ,
pSprite - > xrepeat , pSprite - > yrepeat , 0 , 0 , 0 , pSprite - > owner , 5 ) ;
sprite [ newSprite ] . cstat = 128 ;
sprite [ newSprite ] . pal = pSprite - > pal ;
}
2012-10-14 20:41:28 +00:00
}
2016-08-27 01:41:33 +00:00
else if ( pSprite - > picnum = = SPIT )
2020-02-11 09:21:44 +00:00
if ( pSprite - > zvel < ACTOR_MAXFALLINGZVEL )
2016-08-27 01:41:33 +00:00
pSprite - > zvel + = g_spriteGravity - 112 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( moveSprite ! = 0 )
2012-10-14 20:41:28 +00:00
{
2016-08-27 01:41:33 +00:00
if ( pSprite - > picnum = = COOLEXPLOSION1 )
{
if ( ( moveSprite & 49152 ) = = 49152 & & sprite [ moveSprite & ( MAXSPRITES - 1 ) ] . picnum ! = APLAYER )
goto COOLEXPLOSION ;
pSprite - > xvel = 0 ;
pSprite - > zvel = 0 ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
switch ( moveSprite & 49152 )
{
case 49152 :
moveSprite & = ( MAXSPRITES - 1 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > picnum = = FREEZEBLAST & & sprite [ moveSprite ] . pal = = 1 )
if ( A_CheckEnemySprite ( & sprite [ moveSprite ] ) | | sprite [ moveSprite ] . picnum = = APLAYER )
{
int const newSprite = A_Spawn ( spriteNum , TRANSPORTERSTAR ) ;
sprite [ newSprite ] . pal = 1 ;
sprite [ newSprite ] . xrepeat = 32 ;
sprite [ newSprite ] . yrepeat = 32 ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
}
2006-04-13 20:47:06 +00:00
2020-03-29 08:41:12 +00:00
if ( ! WORLDTOUR | | pSprite - > picnum ! = FIREBALL | | fireball )
A_DamageObject ( moveSprite , spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( sprite [ moveSprite ] . picnum = = APLAYER )
{
int const playerNum = P_Get ( moveSprite ) ;
A_PlaySound ( PISTOL_BODYHIT , moveSprite ) ;
2013-08-06 23:53:34 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > picnum = = SPIT )
P_HandleBeingSpitOn ( g_player [ playerNum ] . ps ) ;
}
break ;
2012-10-14 20:41:28 +00:00
2016-08-27 01:41:33 +00:00
case 32768 :
moveSprite & = ( MAXWALLS - 1 ) ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > picnum ! = RPG & & pSprite - > picnum ! = FREEZEBLAST & & pSprite - > picnum ! = SPIT
2020-03-29 08:41:12 +00:00
& & ( ! WORLDTOUR | | pSprite - > picnum ! = FIREBALL )
2016-08-27 01:41:33 +00:00
& & ( wall [ moveSprite ] . overpicnum = = MIRROR | | wall [ moveSprite ] . picnum = = MIRROR ) )
2012-10-14 20:41:28 +00:00
{
2016-08-27 01:41:33 +00:00
Proj_BounceOffWall ( pSprite , moveSprite ) ;
pSprite - > owner = spriteNum ;
A_Spawn ( spriteNum , TRANSPORTERSTAR ) ;
goto next_sprite ;
2012-10-14 20:41:28 +00:00
}
2016-08-27 01:41:33 +00:00
else
{
setsprite ( spriteNum , & davect ) ;
2019-09-08 01:01:13 +00:00
A_DamageWall ( spriteNum , moveSprite , pSprite - > pos , pSprite - > picnum ) ;
2012-10-14 20:41:28 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > picnum = = FREEZEBLAST )
{
if ( wall [ moveSprite ] . overpicnum ! = MIRROR & & wall [ moveSprite ] . picnum ! = MIRROR )
{
pSprite - > extra > > = 1 ;
pSprite - > yvel - - ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
Proj_BounceOffWall ( pSprite , moveSprite ) ;
goto next_sprite ;
}
}
break ;
2013-08-06 23:53:34 +00:00
2016-08-27 01:41:33 +00:00
case 16384 :
setsprite ( spriteNum , & davect ) ;
2013-08-06 23:53:34 +00:00
2018-03-17 03:26:10 +00:00
if ( Proj_MaybeDamageCF ( spriteNum ) )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2013-08-06 23:53:34 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > picnum = = FREEZEBLAST )
{
A_DoProjectileBounce ( spriteNum ) ;
A_SetSprite ( spriteNum , CLIPMASK1 ) ;
2013-08-06 23:53:34 +00:00
2016-08-27 01:41:33 +00:00
pSprite - > extra > > = 1 ;
pSprite - > yvel - - ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > xrepeat > 8 )
{
pSprite - > xrepeat - = 2 ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > yrepeat > 8 )
pSprite - > yrepeat - = 2 ;
}
2006-12-17 21:20:35 +00:00
2016-08-27 01:41:33 +00:00
goto next_sprite ;
}
2020-03-29 08:41:12 +00:00
if ( pSprite - > zvel > = 0 & & fireball )
{
int lp = A_Spawn ( spriteNum , LAVAPOOL ) ;
sprite [ lp ] . owner = sprite [ spriteNum ] . owner ;
sprite [ lp ] . yvel = sprite [ spriteNum ] . yvel ;
actor [ lp ] . owner = sprite [ spriteNum ] . owner ;
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
}
2016-08-27 01:41:33 +00:00
break ;
default : break ;
2013-08-06 23:53:34 +00:00
}
2016-08-27 01:41:33 +00:00
switch ( DYNAMICTILEMAP ( pSprite - > picnum ) )
2013-08-06 23:53:34 +00:00
{
2016-08-27 01:41:33 +00:00
case SPIT__STATIC :
case COOLEXPLOSION1__STATIC :
case FREEZEBLAST__STATIC :
2020-03-29 08:41:03 +00:00
case FIRELASER__STATIC :
break ;
2016-08-27 01:41:33 +00:00
case RPG__STATIC :
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
int const newSprite = A_Spawn ( spriteNum , EXPLOSION2 ) ;
A_PlaySound ( RPG_EXPLODE , newSprite ) ;
Bmemcpy ( & sprite [ newSprite ] , & davect , sizeof ( vec3_t ) ) ;
2013-08-06 23:53:34 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > xrepeat < 10 )
{
sprite [ newSprite ] . xrepeat = 6 ;
sprite [ newSprite ] . yrepeat = 6 ;
}
else if ( ( moveSprite & 49152 ) = = 16384 )
{
if ( pSprite - > zvel > 0 )
A_Spawn ( spriteNum , EXPLOSION2BOT ) ;
else
{
sprite [ newSprite ] . cstat | = 8 ;
sprite [ newSprite ] . z + = ( 48 < < 8 ) ;
}
}
2013-08-06 23:53:34 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > xrepeat > = 10 )
{
int const x = pSprite - > extra ;
2016-08-27 01:42:01 +00:00
A_RadiusDamage ( spriteNum , g_rpgRadius , x > > 2 , x > > 1 , x - ( x > > 2 ) , x ) ;
2016-08-27 01:41:33 +00:00
}
else
{
int const x = pSprite - > extra + ( g_globalRandom & 3 ) ;
2016-08-27 01:42:01 +00:00
A_RadiusDamage ( spriteNum , ( g_rpgRadius > > 1 ) , x > > 2 , x > > 1 , x - ( x > > 2 ) , x ) ;
2016-08-27 01:41:33 +00:00
}
break ;
}
2013-08-06 23:53:34 +00:00
2016-08-27 01:41:33 +00:00
case SHRINKSPARK__STATIC :
A_Spawn ( spriteNum , SHRINKEREXPLOSION ) ;
A_PlaySound ( SHRINKER_HIT , spriteNum ) ;
2016-08-27 01:42:01 +00:00
A_RadiusDamage ( spriteNum , g_shrinkerRadius , 0 , 0 , 0 , 0 ) ;
2016-08-27 01:41:33 +00:00
break ;
2020-03-29 08:41:12 +00:00
case FIREBALL__STATIC :
if ( WORLDTOUR )
break ;
fallthrough__ ;
2016-08-27 01:41:33 +00:00
default :
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
int const newSprite = A_Spawn ( spriteNum , EXPLOSION2 ) ;
sprite [ newSprite ] . xrepeat = sprite [ newSprite ] . yrepeat = pSprite - > xrepeat > > 1 ;
if ( ( moveSprite & 49152 ) = = 16384 )
{
if ( pSprite - > zvel < 0 )
{
sprite [ newSprite ] . cstat | = 8 ;
sprite [ newSprite ] . z + = ( 72 < < 8 ) ;
}
}
break ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
}
2012-04-13 10:46:04 +00:00
2020-03-29 08:41:12 +00:00
if ( fireball )
{
int ex = A_Spawn ( spriteNum , EXPLOSION2 ) ;
sprite [ ex ] . xrepeat = sprite [ ex ] . yrepeat = pSprite - > xrepeat > > 1 ;
}
2016-08-27 01:41:33 +00:00
if ( pSprite - > picnum ! = COOLEXPLOSION1 )
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > picnum = = COOLEXPLOSION1 )
{
COOLEXPLOSION :
pSprite - > shade + + ;
if ( pSprite - > shade > = 40 )
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
}
else if ( pSprite - > picnum = = RPG & & sector [ pSprite - > sectnum ] . lotag = = ST_2_UNDERWATER & & pSprite - > xrepeat > = 10 & & rnd ( 140 ) )
A_Spawn ( spriteNum , WATERBUBBLE ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
}
2020-01-29 11:37:16 +00:00
# endif
2016-08-27 01:41:33 +00:00
next_sprite :
spriteNum = nextSprite ;
2006-04-13 20:47:06 +00:00
}
}
2012-10-14 20:41:17 +00:00
2018-12-15 01:36:15 +00:00
static int P_Submerge ( int const playerNum , DukePlayer_t * const pPlayer , int const sectNum , int const otherSect )
2012-10-14 20:41:17 +00:00
{
2016-08-27 01:41:33 +00:00
if ( pPlayer - > on_ground & & pPlayer - > pos . z > = sector [ sectNum ] . floorz
2019-07-08 00:41:17 +00:00
& & ( TEST_SYNC_KEY ( g_player [ playerNum ] . input - > bits , SK_CROUCH ) | | pPlayer - > vel . z > 2048 ) )
2016-08-27 01:41:33 +00:00
// if( onfloorz && sectlotag == 1 && ps->pos.z > (sector[sect].floorz-(6<<8)) )
2012-10-14 20:41:17 +00:00
{
2016-08-27 01:41:33 +00:00
if ( screenpeek = = playerNum )
2012-10-14 20:41:17 +00:00
{
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
}
2018-09-01 19:36:20 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY & & sprite [ pPlayer - > i ] . extra > 0 )
2018-12-15 01:36:15 +00:00
A_PlaySound ( DUKE_UNDERWATER , pPlayer - > i ) ;
2018-09-01 19:36:20 +00:00
# endif
2012-10-14 20:41:17 +00:00
2016-08-27 01:41:33 +00:00
pPlayer - > opos . z = pPlayer - > pos . z = sector [ otherSect ] . ceilingz ;
2012-10-14 20:41:17 +00:00
2019-07-08 00:41:17 +00:00
if ( TEST_SYNC_KEY ( g_player [ playerNum ] . input - > bits , SK_CROUCH ) )
2016-08-27 01:41:33 +00:00
pPlayer - > vel . z + = 512 ;
2012-10-14 20:41:17 +00:00
return 1 ;
}
return 0 ;
}
2018-12-15 01:36:15 +00:00
static int P_Emerge ( int const playerNum , DukePlayer_t * const pPlayer , int const sectNum , int const otherSect )
2012-10-14 20:41:17 +00:00
{
// r1449-:
2019-07-26 23:11:20 +00:00
if ( pPlayer - > pos . z < ( sector [ sectNum ] . ceilingz + 1080 ) & & pPlayer - > vel . z < = 0 )
2012-10-14 20:41:17 +00:00
// r1450+, breaks submergible slime in bobsp2:
// if (onfloorz && sectlotag == 2 && ps->pos.z <= sector[sect].ceilingz /*&& ps->vel.z == 0*/)
{
// if( sprite[j].extra <= 0) break;
2016-08-27 01:41:33 +00:00
if ( screenpeek = = playerNum )
2012-10-14 20:41:17 +00:00
{
FX_StopAllSounds ( ) ;
S_ClearSoundLocks ( ) ;
}
2018-09-01 19:36:20 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY )
A_PlaySound ( DUKE_GASP , pPlayer - > i ) ;
2018-09-01 19:36:20 +00:00
# endif
2012-10-14 20:41:17 +00:00
2016-08-27 01:41:33 +00:00
pPlayer - > opos . z = pPlayer - > pos . z = sector [ otherSect ] . floorz ;
pPlayer - > vel . z = 0 ;
2012-10-14 20:41:17 +00:00
// ps->vel.z += 1024;
2016-08-27 01:41:33 +00:00
pPlayer - > jumping_toggle = 1 ;
pPlayer - > jumping_counter = 0 ;
2012-10-14 20:41:17 +00:00
return 1 ;
}
return 0 ;
}
2017-06-23 09:16:21 +00:00
static void P_FinishWaterChange ( int const playerNum , DukePlayer_t * const pPlayer , int const sectLotag , int const spriteOwner , int const newSector )
2012-10-14 20:41:17 +00:00
{
2016-08-27 01:41:33 +00:00
pPlayer - > bobpos . x = pPlayer - > opos . x = pPlayer - > pos . x ;
pPlayer - > bobpos . y = pPlayer - > opos . y = pPlayer - > pos . y ;
2012-10-14 20:41:17 +00:00
2016-08-27 01:41:33 +00:00
if ( spriteOwner < 0 | | sprite [ spriteOwner ] . owner ! = spriteOwner )
pPlayer - > transporter_hold = - 2 ;
2012-10-14 20:41:17 +00:00
2016-08-27 01:41:33 +00:00
pPlayer - > cursectnum = newSector ;
changespritesect ( playerNum , newSector ) ;
2012-10-14 20:41:17 +00:00
2016-08-27 01:41:33 +00:00
vec3_t vect = pPlayer - > pos ;
2016-06-21 00:34:07 +00:00
vect . z + = PHEIGHT ;
2016-08-27 01:41:33 +00:00
setsprite ( pPlayer - > i , & vect ) ;
2012-10-14 20:41:17 +00:00
2016-08-27 01:41:33 +00:00
P_UpdateScreenPal ( pPlayer ) ;
2012-10-14 20:41:17 +00:00
if ( ( krand ( ) & 255 ) < 32 )
2016-08-27 01:41:33 +00:00
A_Spawn ( playerNum , WATERSPLASH2 ) ;
2012-10-14 20:41:17 +00:00
2016-08-27 01:41:33 +00:00
if ( sectLotag = = ST_1_ABOVE_WATER )
{
2016-08-27 01:41:21 +00:00
for ( bssize_t l = 0 ; l < 9 ; l + + )
2016-08-27 01:41:33 +00:00
sprite [ A_Spawn ( pPlayer - > i , WATERBUBBLE ) ] . z + = krand ( ) & 16383 ;
}
2012-10-14 20:41:17 +00:00
}
2013-04-29 19:24:12 +00:00
// Check prevention of teleportation *when alive*. For example, commanders and
// octabrains would be transported by SE7 (both water and normal) only if dead.
2017-06-23 09:16:21 +00:00
static int A_CheckNonTeleporting ( int const spriteNum )
2012-10-14 20:41:23 +00:00
{
2016-08-27 01:41:33 +00:00
int const tileNum = sprite [ spriteNum ] . picnum ;
return ! ! ( A_CheckSpriteFlags ( spriteNum , SFLAG_NOTELEPORT ) | | tileNum = = SHARK | | tileNum = = COMMANDER | | tileNum = = OCTABRAIN
| | ( tileNum > = GREENSLIME & & tileNum < = GREENSLIME + 7 ) ) ;
2012-10-14 20:41:23 +00:00
}
2010-01-24 23:33:17 +00:00
ACTOR_STATIC void G_MoveTransports ( void )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
int spriteNum = headspritestat [ STAT_TRANSPORT ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
while ( spriteNum > = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
int const nextSprite = nextspritestat [ spriteNum ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( OW ( spriteNum ) = = spriteNum )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
spriteNum = nextSprite ;
2006-04-13 20:47:06 +00:00
continue ;
}
2016-08-27 01:41:33 +00:00
int const sectNum = SECT ( spriteNum ) ;
int const sectLotag = sector [ sectNum ] . lotag ;
int const onFloor = T5 ( spriteNum ) ; // ONFLOORZ
if ( T1 ( spriteNum ) > 0 )
T1 ( spriteNum ) - - ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
int sectSprite = headspritesect [ sectNum ] ;
while ( sectSprite > = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
int const nextSectSprite = nextspritesect [ sectSprite ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
switch ( sprite [ sectSprite ] . statnum )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
case STAT_PLAYER :
if ( sprite [ sectSprite ] . owner ! = - 1 )
{
2019-07-08 00:41:25 +00:00
int const playerNum = P_Get ( sectSprite ) ;
auto const pPlayer = g_player [ playerNum ] . ps ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
pPlayer - > on_warping_sector = 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pPlayer - > transporter_hold = = 0 & & pPlayer - > jumping_counter = = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
if ( pPlayer - > on_ground & & sectLotag = = 0 & & onFloor & & pPlayer - > jetpack_on = = 0 )
2006-04-13 20:47:06 +00:00
{
2018-07-21 00:18:03 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY & & sprite [ spriteNum ] . pal = = 0 )
2016-08-27 01:41:33 +00:00
{
A_Spawn ( spriteNum , TRANSPORTERBEAM ) ;
A_PlaySound ( TELEPORTER , spriteNum ) ;
}
2018-07-21 00:18:03 +00:00
# endif
2016-08-27 01:41:33 +00:00
for ( int TRAVERSE_CONNECT ( otherPlayer ) )
2012-02-21 19:33:33 +00:00
{
2016-08-27 01:41:33 +00:00
if ( g_player [ otherPlayer ] . ps - > cursectnum = = sprite [ OW ( spriteNum ) ] . sectnum )
{
g_player [ otherPlayer ] . ps - > frag_ps = playerNum ;
sprite [ g_player [ otherPlayer ] . ps - > i ] . extra = 0 ;
}
2012-02-21 19:33:33 +00:00
}
2006-04-13 20:47:06 +00:00
2018-03-07 04:21:18 +00:00
pPlayer - > q16ang = fix16_from_int ( sprite [ OW ( spriteNum ) ] . ang ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( sprite [ OW ( spriteNum ) ] . owner ! = OW ( spriteNum ) )
{
T1 ( spriteNum ) = 13 ;
actor [ OW ( spriteNum ) ] . t_data [ 0 ] = 13 ;
pPlayer - > transporter_hold = 13 ;
}
2006-04-13 20:47:06 +00:00
2019-06-25 11:28:25 +00:00
pPlayer - > pos = sprite [ OW ( spriteNum ) ] . pos ;
2016-08-27 01:41:33 +00:00
pPlayer - > pos . z - = PHEIGHT ;
pPlayer - > opos = pPlayer - > pos ;
2019-08-07 22:43:48 +00:00
pPlayer - > bobpos = pPlayer - > pos . vec2 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
changespritesect ( sectSprite , sprite [ OW ( spriteNum ) ] . sectnum ) ;
pPlayer - > cursectnum = sprite [ sectSprite ] . sectnum ;
2006-04-13 20:47:06 +00:00
2018-07-21 00:18:03 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY & & sprite [ spriteNum ] . pal = = 0 )
2016-08-27 01:41:33 +00:00
{
int const newSprite = A_Spawn ( OW ( spriteNum ) , TRANSPORTERBEAM ) ;
A_PlaySound ( TELEPORTER , newSprite ) ;
}
2018-07-21 00:18:03 +00:00
# endif
2016-08-27 01:41:33 +00:00
break ;
}
2016-08-27 01:41:46 +00:00
2016-08-27 01:41:33 +00:00
if ( onFloor = = 0 & & klabs ( SZ ( spriteNum ) - pPlayer - > pos . z ) < 6144 )
2019-07-08 00:41:17 +00:00
if ( ! pPlayer - > jetpack_on | | TEST_SYNC_KEY ( g_player [ playerNum ] . input - > bits , SK_JUMP )
2019-09-17 03:20:11 +00:00
| | TEST_SYNC_KEY ( g_player [ playerNum ] . input - > bits , SK_CROUCH ) )
2016-08-27 01:41:33 +00:00
{
2016-08-27 01:41:46 +00:00
pPlayer - > pos . x + = sprite [ OW ( spriteNum ) ] . x - SX ( spriteNum ) ;
pPlayer - > pos . y + = sprite [ OW ( spriteNum ) ] . y - SY ( spriteNum ) ;
2019-07-08 00:41:17 +00:00
pPlayer - > pos . z = ( pPlayer - > jetpack_on & & ( TEST_SYNC_KEY ( g_player [ playerNum ] . input - > bits , SK_JUMP )
2016-08-27 01:41:46 +00:00
| | pPlayer - > jetpack_on < 11 ) )
? sprite [ OW ( spriteNum ) ] . z - 6144
: sprite [ OW ( spriteNum ) ] . z + 6144 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
actor [ pPlayer - > i ] . bpos = pPlayer - > pos ;
2016-08-27 01:41:46 +00:00
pPlayer - > opos = pPlayer - > pos ;
2019-08-07 22:43:48 +00:00
pPlayer - > bobpos = pPlayer - > pos . vec2 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
changespritesect ( sectSprite , sprite [ OW ( spriteNum ) ] . sectnum ) ;
pPlayer - > cursectnum = sprite [ OW ( spriteNum ) ] . sectnum ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
int doWater = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( onFloor )
{
if ( sectLotag = = ST_1_ABOVE_WATER )
2018-12-15 01:36:15 +00:00
doWater = P_Submerge ( playerNum , pPlayer , sectNum , sprite [ OW ( spriteNum ) ] . sectnum ) ;
2016-08-27 01:41:33 +00:00
else if ( sectLotag = = ST_2_UNDERWATER )
2018-12-15 01:36:15 +00:00
doWater = P_Emerge ( playerNum , pPlayer , sectNum , sprite [ OW ( spriteNum ) ] . sectnum ) ;
2006-04-13 20:47:06 +00:00
2018-11-18 18:13:19 +00:00
if ( doWater = = 1 )
{
pPlayer - > pos . x + = sprite [ OW ( spriteNum ) ] . x - SX ( spriteNum ) ;
pPlayer - > pos . y + = sprite [ OW ( spriteNum ) ] . y - SY ( spriteNum ) ;
2016-08-27 01:41:33 +00:00
2018-11-18 18:13:19 +00:00
P_FinishWaterChange ( sectSprite , pPlayer , sectLotag , OW ( spriteNum ) , sprite [ OW ( spriteNum ) ] . sectnum ) ;
}
2016-08-27 01:41:33 +00:00
}
}
2016-08-27 01:41:46 +00:00
else if ( ! ( sectLotag = = ST_1_ABOVE_WATER & & pPlayer - > on_ground = = 1 ) )
break ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:41:33 +00:00
break ;
2006-04-13 20:47:06 +00:00
2012-10-14 20:41:23 +00:00
2016-08-27 01:41:33 +00:00
////////// Non-player teleportation //////////
2012-10-14 20:41:23 +00:00
2016-08-27 01:41:33 +00:00
case STAT_PROJECTILE :
2013-04-15 10:48:18 +00:00
// SE7_PROJECTILE, PROJECTILE_CHSECT.
2011-08-16 19:17:45 +00:00
// comment out to make RPGs pass through water: (r1450 breaks this)
2016-08-27 01:41:33 +00:00
// if (sectlotag != 0) goto JBOLT;
case STAT_ACTOR :
if ( sprite [ sectSprite ] . extra > 0 & & A_CheckNonTeleporting ( sectSprite ) )
goto JBOLT ;
2017-07-18 20:53:41 +00:00
fallthrough__ ;
2016-08-27 01:41:33 +00:00
case STAT_MISC :
case STAT_FALLER :
case STAT_DUMMYPLAYER :
2006-11-16 03:02:42 +00:00
{
2019-08-27 13:39:54 +00:00
if ( ( ( int32_t ) totalclock & UINT8_MAX ) ! = actor [ sectSprite ] . lasttransport )
2012-10-14 20:41:23 +00:00
{
2016-08-27 01:41:33 +00:00
int const zvel = sprite [ sectSprite ] . zvel ;
int const absZvel = klabs ( zvel ) ;
int doWarp = 0 ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:41:33 +00:00
if ( absZvel ! = 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
if ( sectLotag = = ST_2_UNDERWATER & & sprite [ sectSprite ] . z < ( sector [ sectNum ] . ceilingz + absZvel ) & & zvel < 0 )
doWarp = 1 ;
if ( sectLotag = = ST_1_ABOVE_WATER & & sprite [ sectSprite ] . z > ( sector [ sectNum ] . floorz - absZvel ) & & zvel > 0 )
doWarp = 1 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( sectLotag = = 0 & & ( onFloor | | klabs ( sprite [ sectSprite ] . z - SZ ( spriteNum ) ) < 4096 ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
if ( sprite [ OW ( spriteNum ) ] . owner ! = OW ( spriteNum ) & & onFloor & & T1 ( spriteNum ) > 0
& & sprite [ sectSprite ] . statnum ! = STAT_MISC )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
T1 ( spriteNum ) + + ;
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:41:33 +00:00
doWarp = 1 ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( doWarp )
{
if ( A_CheckSpriteFlags ( sectSprite , SFLAG_DECAL ) )
goto JBOLT ;
2020-01-29 11:37:16 +00:00
# ifndef EDUKE32_STANDALONE
if ( ! FURY )
2016-08-27 01:41:33 +00:00
switch ( DYNAMICTILEMAP ( sprite [ sectSprite ] . picnum ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
case TRANSPORTERSTAR__STATIC :
case TRANSPORTERBEAM__STATIC :
case TRIPBOMB__STATIC :
case BULLETHOLE__STATIC :
case WATERSPLASH2__STATIC :
case BURNING__STATIC :
case BURNING2__STATIC :
case FIRE__STATIC :
case FIRE2__STATIC :
case TOILETWATER__STATIC :
case LASERLINE__STATIC : goto JBOLT ;
2020-01-29 11:37:16 +00:00
}
2018-04-02 22:00:44 +00:00
# endif
2020-01-29 11:37:16 +00:00
switch ( DYNAMICTILEMAP ( sprite [ sectSprite ] . picnum ) )
{
2016-08-27 01:41:33 +00:00
case PLAYERONWATER__STATIC :
if ( sectLotag = = ST_2_UNDERWATER )
{
sprite [ sectSprite ] . cstat & = 32768 ;
break ;
}
2018-04-02 22:00:44 +00:00
fallthrough__ ;
2016-08-27 01:41:33 +00:00
default :
if ( sprite [ sectSprite ] . statnum = = STAT_MISC & & ! ( sectLotag = = ST_1_ABOVE_WATER | | sectLotag = = ST_2_UNDERWATER ) )
break ;
2018-04-02 22:00:44 +00:00
fallthrough__ ;
2016-08-27 01:41:33 +00:00
case WATERBUBBLE__STATIC :
// if( rnd(192) && sprite[j].picnum == WATERBUBBLE)
// break;
if ( sectLotag > 0 )
{
// Water SE7 teleportation.
int const osect = sprite [ OW ( spriteNum ) ] . sectnum ;
2012-10-14 20:41:23 +00:00
2016-08-27 01:41:33 +00:00
Bassert ( sectLotag = = ST_1_ABOVE_WATER | | sectLotag = = ST_2_UNDERWATER ) ;
2018-07-21 00:18:03 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY )
2016-08-27 01:41:33 +00:00
{
2020-01-29 11:37:16 +00:00
int const newSprite = A_Spawn ( sectSprite , WATERSPLASH2 ) ;
if ( sectLotag = = ST_1_ABOVE_WATER & & sprite [ sectSprite ] . statnum = = STAT_PROJECTILE )
{
sprite [ newSprite ] . xvel = sprite [ sectSprite ] . xvel > > 1 ;
sprite [ newSprite ] . ang = sprite [ sectSprite ] . ang ;
A_SetSprite ( newSprite , CLIPMASK0 ) ;
}
2016-08-27 01:41:33 +00:00
}
2018-07-21 00:18:03 +00:00
# endif
2019-08-27 13:39:54 +00:00
actor [ sectSprite ] . lasttransport = ( ( int32_t ) totalclock & UINT8_MAX ) ;
2012-10-14 20:41:23 +00:00
2016-08-27 01:41:33 +00:00
sprite [ sectSprite ] . x + = sprite [ OW ( spriteNum ) ] . x - SX ( spriteNum ) ;
sprite [ sectSprite ] . y + = sprite [ OW ( spriteNum ) ] . y - SY ( spriteNum ) ;
sprite [ sectSprite ] . z = ( sectLotag = = ST_1_ABOVE_WATER ) ? sector [ osect ] . ceilingz : sector [ osect ] . floorz ;
2012-10-14 20:41:23 +00:00
2019-06-25 11:28:25 +00:00
actor [ sectSprite ] . bpos = sprite [ sectSprite ] . pos ;
2013-04-15 10:48:18 +00:00
2016-08-27 01:41:33 +00:00
changespritesect ( sectSprite , sprite [ OW ( spriteNum ) ] . sectnum ) ;
}
else if ( Bassert ( sectLotag = = 0 ) , 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
// Non-water SE7 teleportation.
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( onFloor )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
if ( sprite [ sectSprite ] . statnum = = STAT_PROJECTILE
2020-01-29 11:37:20 +00:00
| | ( G_GetPlayerInSector ( sectNum ) = = - 1
& & G_GetPlayerInSector ( sprite [ OW ( spriteNum ) ] . sectnum ) = = - 1 ) )
2016-08-27 01:41:33 +00:00
{
sprite [ sectSprite ] . x + = ( sprite [ OW ( spriteNum ) ] . x - SX ( spriteNum ) ) ;
sprite [ sectSprite ] . y + = ( sprite [ OW ( spriteNum ) ] . y - SY ( spriteNum ) ) ;
sprite [ sectSprite ] . z - = SZ ( spriteNum ) - sector [ sprite [ OW ( spriteNum ) ] . sectnum ] . floorz ;
2016-08-27 01:41:46 +00:00
sprite [ sectSprite ] . ang = sprite [ OW ( spriteNum ) ] . ang ;
2019-06-25 11:28:25 +00:00
actor [ sectSprite ] . bpos = sprite [ sectSprite ] . pos ;
2018-07-21 00:18:03 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY & & sprite [ spriteNum ] . pal = = 0 )
2016-08-27 01:41:33 +00:00
{
int newSprite = A_Spawn ( spriteNum , TRANSPORTERBEAM ) ;
A_PlaySound ( TELEPORTER , newSprite ) ;
newSprite = A_Spawn ( OW ( spriteNum ) , TRANSPORTERBEAM ) ;
A_PlaySound ( TELEPORTER , newSprite ) ;
}
2018-07-21 00:18:03 +00:00
# endif
2016-08-27 01:41:33 +00:00
if ( sprite [ OW ( spriteNum ) ] . owner ! = OW ( spriteNum ) )
{
T1 ( spriteNum ) = 13 ;
actor [ OW ( spriteNum ) ] . t_data [ 0 ] = 13 ;
}
changespritesect ( sectSprite , sprite [ OW ( spriteNum ) ] . sectnum ) ;
}
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:41:33 +00:00
else
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
sprite [ sectSprite ] . x + = ( sprite [ OW ( spriteNum ) ] . x - SX ( spriteNum ) ) ;
sprite [ sectSprite ] . y + = ( sprite [ OW ( spriteNum ) ] . y - SY ( spriteNum ) ) ;
sprite [ sectSprite ] . z = sprite [ OW ( spriteNum ) ] . z + 4096 ;
2006-11-16 03:02:42 +00:00
2019-06-25 11:28:25 +00:00
actor [ sectSprite ] . bpos = sprite [ sectSprite ] . pos ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
changespritesect ( sectSprite , sprite [ OW ( spriteNum ) ] . sectnum ) ;
}
}
2006-11-16 03:02:42 +00:00
2016-08-27 01:41:33 +00:00
break ;
} // switch (DYNAMICTILEMAP(sprite[j].picnum))
} // if (doWarp)
} // if (totalclock > actor[j].lasttransport)
2012-10-14 20:41:23 +00:00
2016-08-27 01:41:33 +00:00
break ;
} // five cases
2012-10-14 20:41:23 +00:00
2012-10-14 20:41:17 +00:00
} // switch (sprite[j].statnum)
2016-08-27 01:41:33 +00:00
JBOLT :
sectSprite = nextSectSprite ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:41:33 +00:00
next_sprite :
spriteNum = nextSprite ;
2006-04-13 20:47:06 +00:00
}
}
2017-06-23 09:16:21 +00:00
static int A_FindLocator ( int const tag , int const sectNum )
2006-12-10 06:49:01 +00:00
{
2016-08-27 01:41:33 +00:00
for ( bssize_t SPRITES_OF ( STAT_LOCATOR , spriteNum ) )
2006-12-10 06:49:01 +00:00
{
2016-08-27 01:41:33 +00:00
if ( ( sectNum = = - 1 | | sectNum = = SECT ( spriteNum ) ) & & tag = = SLT ( spriteNum ) )
return spriteNum ;
2006-12-10 06:49:01 +00:00
}
2013-04-15 10:48:09 +00:00
2006-12-10 06:49:01 +00:00
return - 1 ;
}
2019-06-25 18:35:24 +00:00
static int A_FindLocatorWithHiLoTags ( int const hitag , int const tag , int const sectNum )
{
for ( bssize_t SPRITES_OF ( STAT_LOCATOR , spriteNum ) )
{
if ( ( sectNum = = - 1 | | sectNum = = SECT ( spriteNum ) ) & & tag = = SLT ( spriteNum ) & & hitag = = SHT ( spriteNum ) )
return spriteNum ;
}
return - 1 ;
}
2010-01-24 23:33:17 +00:00
ACTOR_STATIC void G_MoveActors ( void )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
int spriteNum = headspritestat [ STAT_ACTOR ] ;
2007-03-01 00:50:59 +00:00
2016-08-27 01:40:35 +00:00
while ( spriteNum > = 0 )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
int const nextSprite = nextspritestat [ spriteNum ] ;
auto const pSprite = & sprite [ spriteNum ] ;
int const sectNum = pSprite - > sectnum ;
auto const pData = actor [ spriteNum ] . t_data ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
int switchPic ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xrepeat = = 0 | | sectNum < 0 | | sectNum > = MAXSECTORS )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2019-08-07 22:43:48 +00:00
actor [ spriteNum ] . bpos = pSprite - > pos ;
2009-08-28 23:08:00 +00:00
2016-08-27 01:40:35 +00:00
switchPic = pSprite - > picnum ;
2012-05-14 18:12:27 +00:00
2020-01-29 11:37:16 +00:00
# ifndef EDUKE32_STANDALONE
if ( ! FURY & & pSprite - > picnum > GREENSLIME & & pSprite - > picnum < = GREENSLIME + 7 )
2016-08-27 01:40:35 +00:00
switchPic = GREENSLIME ;
2020-01-29 11:37:16 +00:00
# endif
2012-05-14 18:12:27 +00:00
2016-08-27 01:40:35 +00:00
switch ( DYNAMICTILEMAP ( switchPic ) )
2006-04-13 20:47:06 +00:00
{
2018-04-02 22:00:44 +00:00
case OOZ__STATIC :
case OOZ2__STATIC :
{
A_GetZLimits ( spriteNum ) ;
int const yrepeat = clamp ( ( actor [ spriteNum ] . floorz - actor [ spriteNum ] . ceilingz ) > > 9 , 8 , 255 ) ;
int const xrepeat = clamp ( 25 - ( yrepeat > > 1 ) , 8 , 48 ) ;
pSprite - > yrepeat = yrepeat ;
pSprite - > xrepeat = xrepeat ;
pSprite - > z = actor [ spriteNum ] . floorz ;
goto next_sprite ;
}
2020-01-29 11:37:16 +00:00
case CAMERA1__STATIC :
if ( pData [ 0 ] = = 0 )
{
pData [ 1 ] + = 8 ;
if ( g_damageCameras )
{
if ( A_IncurDamage ( spriteNum ) > = 0 )
{
pData [ 0 ] = 1 ; // static
pSprite - > cstat = 32768 ;
2018-04-02 22:00:44 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY )
{
for ( bssize_t x = 0 ; x < 5 ; x + + )
RANDOMSCRAP ( pSprite , spriteNum ) ;
}
# endif
goto next_sprite ;
}
}
if ( pSprite - > hitag > 0 )
{
if ( pData [ 1 ] < pSprite - > hitag ) pSprite - > ang + = 8 ;
else if ( pData [ 1 ] < pSprite - > hitag * 3 ) pSprite - > ang - = 8 ;
else if ( pData [ 1 ] < ( pSprite - > hitag < < 2 ) ) pSprite - > ang + = 8 ;
else
{
pData [ 1 ] = 8 ;
pSprite - > ang + = 16 ;
}
}
}
goto next_sprite ;
}
# ifndef EDUKE32_STANDALONE
switch ( DYNAMICTILEMAP ( switchPic ) )
{
2020-03-29 08:41:12 +00:00
case FLAMETHROWERFLAME__STATIC :
{
if ( ! WORLDTOUR )
goto next_sprite ;
2020-04-05 06:40:38 +00:00
if ( G_TileHasActor ( sprite [ spriteNum ] . picnum ) )
2020-03-29 08:41:12 +00:00
{
int32_t playerDist ;
int const playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
A_Execute ( spriteNum , playerNum , playerDist ) ;
}
actor [ spriteNum ] . t_data [ 0 ] + + ;
if ( sector [ pSprite - > sectnum ] . lotag = = ST_2_UNDERWATER )
{
int const newSprite = A_Spawn ( spriteNum , EXPLOSION2 ) ;
sprite [ newSprite ] . shade = 127 ;
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
}
int spriteXvel = pSprite - > xvel ;
int spriteZvel = pSprite - > zvel ;
vec3_t davect = pSprite - > pos ;
A_GetZLimits ( spriteNum ) ;
if ( pSprite - > xrepeat < 80 )
{
pSprite - > xrepeat + = actor [ spriteNum ] . t_data [ 0 ] / 6 ;
pSprite - > yrepeat + = actor [ spriteNum ] . t_data [ 0 ] / 6 ;
}
pSprite - > clipdist + = actor [ spriteNum ] . t_data [ 0 ] / 6 ;
if ( actor [ spriteNum ] . t_data [ 0 ] < 2 )
actor [ spriteNum ] . t_data [ 3 ] = krand ( ) % 10 ;
if ( actor [ spriteNum ] . t_data [ 0 ] > 30 )
{
int const newSprite = A_Spawn ( spriteNum , EXPLOSION2 ) ;
sprite [ newSprite ] . shade = 127 ;
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
}
vec3_t const tmpvect = { ( spriteXvel * ( sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) ) > > 14 ,
( spriteXvel * ( sintable [ pSprite - > ang & 2047 ] ) ) > > 14 , spriteZvel } ;
int moveSprite = A_MoveSprite ( spriteNum , & tmpvect , CLIPMASK1 ) ;
actor [ spriteNum ] . movflag = moveSprite ;
if ( pSprite - > sectnum < 0 )
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
if ( ( moveSprite & 49152 ) ! = 49152 & & pSprite - > picnum ! = FREEZEBLAST )
G_WeaponHitCeilingOrFloor ( spriteNum , pSprite , & moveSprite ) ;
if ( moveSprite ! = 0 )
{
switch ( moveSprite & 49152 )
{
case 49152 :
moveSprite & = ( MAXSPRITES - 1 ) ;
A_DamageObject ( moveSprite , spriteNum ) ;
if ( sprite [ moveSprite ] . picnum = = APLAYER )
{
A_PlaySound ( PISTOL_BODYHIT , moveSprite ) ;
}
break ;
case 32768 :
moveSprite & = ( MAXWALLS - 1 ) ;
setsprite ( spriteNum , & davect ) ;
A_DamageWall ( spriteNum , moveSprite , pSprite - > pos , pSprite - > picnum ) ;
break ;
case 16384 :
setsprite ( spriteNum , & davect ) ;
if ( pSprite - > zvel < 0 )
Sect_DamageCeiling ( spriteNum , pSprite - > sectnum ) ;
else if ( pSprite - > zvel > 0 )
Sect_DamageFloor ( spriteNum , pSprite - > sectnum ) ;
break ;
default : break ;
}
}
if ( pSprite - > xrepeat > = 10 )
{
int const x = pSprite - > extra ;
A_RadiusDamage ( spriteNum , g_rpgRadius , x > > 2 , x > > 1 , x - ( x > > 2 ) , x ) ;
}
else
{
int const x = pSprite - > extra + ( g_globalRandom & 3 ) ;
A_RadiusDamage ( spriteNum , ( g_rpgRadius > > 1 ) , x > > 2 , x > > 1 , x - ( x > > 2 ) , x ) ;
}
goto next_sprite ;
}
2006-11-16 03:02:42 +00:00
case DUCK__STATIC :
case TARGET__STATIC :
2016-08-27 01:40:35 +00:00
if ( pSprite - > cstat & 32 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] + + ;
if ( pData [ 0 ] > 60 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = 0 ;
pSprite - > cstat = 128 + 257 + 16 ;
pSprite - > extra = 1 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
if ( A_IncurDamage ( spriteNum ) > = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
int doEffects = 1 ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > cstat = 32 + 128 ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:41:33 +00:00
for ( bssize_t SPRITES_OF ( STAT_ACTOR , actorNum ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
if ( ( sprite [ actorNum ] . lotag = = pSprite - > lotag & & sprite [ actorNum ] . picnum = = pSprite - > picnum )
& & ( ( sprite [ actorNum ] . hitag ! = 0 ) ^ ( ( sprite [ actorNum ] . cstat & 32 ) ! = 0 ) ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
doEffects = 0 ;
break ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:41:33 +00:00
if ( doEffects = = 1 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
G_OperateActivators ( pSprite - > lotag , - 1 ) ;
G_OperateForceFields ( spriteNum , pSprite - > lotag ) ;
2016-08-27 01:40:35 +00:00
G_OperateMasterSwitches ( pSprite - > lotag ) ;
2006-11-16 03:02:42 +00:00
}
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case RESPAWNMARKERRED__STATIC :
case RESPAWNMARKERYELLOW__STATIC :
case RESPAWNMARKERGREEN__STATIC :
2016-08-27 01:40:35 +00:00
if ( + + T1 ( spriteNum ) > g_itemRespawnTime )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2010-05-02 23:27:30 +00:00
2016-08-27 01:40:35 +00:00
if ( T1 ( spriteNum ) > = ( g_itemRespawnTime > > 1 ) & & T1 ( spriteNum ) < ( ( g_itemRespawnTime > > 1 ) + ( g_itemRespawnTime > > 2 ) ) )
PN ( spriteNum ) = RESPAWNMARKERYELLOW ;
else if ( T1 ( spriteNum ) > ( ( g_itemRespawnTime > > 1 ) + ( g_itemRespawnTime > > 2 ) ) )
PN ( spriteNum ) = RESPAWNMARKERGREEN ;
2010-05-02 23:27:30 +00:00
2016-08-27 01:40:35 +00:00
A_Fall ( spriteNum ) ;
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 HELECOPT__STATIC :
case DUKECAR__STATIC :
2016-08-27 01:40:35 +00:00
pSprite - > z + = pSprite - > zvel ;
pData [ 0 ] + + ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pData [ 0 ] = = 4 )
A_PlaySound ( WAR_AMBIENCE2 , spriteNum ) ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] > ( GAMETICSPERSEC * 8 ) )
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
g_earthquakeTime = 16 ;
2016-08-27 01:41:33 +00:00
S_PlaySound ( RPG_EXPLODE ) ;
for ( bssize_t j = 0 ; j < 32 ; j + + )
RANDOMSCRAP ( pSprite , spriteNum ) ;
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( ( pData [ 0 ] & 3 ) = = 0 )
A_Spawn ( spriteNum , EXPLOSION2 ) ;
2016-08-27 01:41:33 +00:00
2016-08-27 01:40:35 +00:00
A_SetSprite ( spriteNum , CLIPMASK0 ) ;
2006-11-16 03:02:42 +00:00
break ;
2012-04-13 10:46:04 +00:00
2006-11-16 03:02:42 +00:00
case RAT__STATIC :
2016-08-27 01:40:35 +00:00
A_Fall ( spriteNum ) ;
if ( A_SetSprite ( spriteNum , CLIPMASK0 ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( ( krand ( ) & 255 ) < 3 ) A_PlaySound ( RATTY , spriteNum ) ;
pSprite - > ang + = ( krand ( ) & 31 ) - 15 + ( sintable [ ( pData [ 0 ] < < 8 ) & 2047 ] > > 11 ) ;
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
T1 ( spriteNum ) + + ;
if ( T1 ( spriteNum ) > 1 )
2007-08-25 01:05:00 +00:00
{
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else pSprite - > ang = ( krand ( ) & 2047 ) ;
2007-08-25 01:05:00 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel < 128 )
pSprite - > xvel + = 2 ;
pSprite - > ang + = ( krand ( ) & 3 ) - 6 ;
2006-11-16 03:02:42 +00:00
break ;
2012-04-13 10:46:04 +00:00
2006-11-16 03:02:42 +00:00
case QUEBALL__STATIC :
case STRIPEBALL__STATIC :
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
for ( bssize_t SPRITES_OF ( STAT_DEFAULT , hitObject ) )
if ( sprite [ hitObject ] . picnum = = POCKET & & ldist ( & sprite [ hitObject ] , pSprite ) < 52 )
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2019-06-25 11:28:25 +00:00
int hitObject = clipmove ( & pSprite - > pos , & pSprite - > sectnum ,
2016-08-27 01:41:33 +00:00
( ( ( pSprite - > xvel * ( sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) ) > > 14 ) * TICSPERFRAME ) < < 11 ,
( ( ( pSprite - > xvel * ( sintable [ pSprite - > ang & 2047 ] ) ) > > 14 ) * TICSPERFRAME ) < < 11 , 24L , ZOFFSET6 ,
ZOFFSET6 , CLIPMASK1 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( hitObject & 49152 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
if ( ( hitObject & 49152 ) = = 32768 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
hitObject & = ( MAXWALLS - 1 ) ;
Proj_BounceOffWall ( pSprite , hitObject ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:41:33 +00:00
else if ( ( hitObject & 49152 ) = = 49152 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
hitObject & = ( MAXSPRITES - 1 ) ;
A_DamageObject ( spriteNum , hitObject ) ;
2006-04-13 20:47:06 +00:00
}
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:41:33 +00:00
if ( - - pSprite - > xvel < 0 )
pSprite - > xvel = 0 ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum = = STRIPEBALL )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > cstat = 257 ;
pSprite - > cstat | = ( 4 & pSprite - > xvel ) | ( 8 & pSprite - > xvel ) ;
2006-11-16 03:02:42 +00:00
}
}
else
{
2019-07-08 00:41:25 +00:00
int32_t playerDist ;
int const playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
auto const pPlayer = g_player [ playerNum ] . ps ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
// I'm 50/50 on this being either a typo or a stupid hack
if ( playerDist < 1596 )
2006-11-16 03:02:42 +00:00
{
2018-03-07 04:21:18 +00:00
int const angDiff = G_GetAngleDelta ( fix16_to_int ( pPlayer - > q16ang ) , getangle ( pSprite - > x - pPlayer - > pos . x , pSprite - > y - pPlayer - > pos . y ) ) ;
2013-04-15 10:48:09 +00:00
2019-07-08 00:41:17 +00:00
if ( angDiff > - 64 & & angDiff < 64 & & TEST_SYNC_KEY ( g_player [ playerNum ] . input - > bits , SK_OPEN )
2016-08-27 01:41:33 +00:00
& & pPlayer - > toggle_key_flag = = 1 )
{
int ballSprite ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:41:33 +00:00
for ( SPRITES_OF ( STAT_ACTOR , ballSprite ) )
{
if ( sprite [ ballSprite ] . picnum = = QUEBALL | | sprite [ ballSprite ] . picnum = = STRIPEBALL )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
int const angDiff2 = G_GetAngleDelta (
2018-03-07 04:21:18 +00:00
fix16_to_int ( pPlayer - > q16ang ) , getangle ( sprite [ ballSprite ] . x - pPlayer - > pos . x , sprite [ ballSprite ] . y - pPlayer - > pos . y ) ) ;
2016-08-27 01:41:33 +00:00
if ( angDiff2 > - 64 & & angDiff2 < 64 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
int32_t ballDist ;
A_FindPlayer ( & sprite [ ballSprite ] , & ballDist ) ;
if ( playerDist > ballDist )
break ;
2006-11-16 03:02:42 +00:00
}
}
2016-08-27 01:41:33 +00:00
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:41:33 +00:00
if ( ballSprite = = - 1 )
{
pSprite - > xvel = ( pSprite - > pal = = 12 ) ? 164 : 140 ;
2018-03-07 04:21:18 +00:00
pSprite - > ang = fix16_to_int ( pPlayer - > q16ang ) ;
2016-08-27 01:41:33 +00:00
pPlayer - > toggle_key_flag = 2 ;
2013-04-15 10:48:09 +00:00
}
2016-08-27 01:41:33 +00:00
}
2006-04-13 20:47:06 +00:00
}
2012-08-10 19:11:56 +00:00
2016-08-27 01:41:33 +00:00
if ( playerDist < 512 & & pSprite - > sectnum = = pPlayer - > cursectnum )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
pSprite - > ang = getangle ( pSprite - > x - pPlayer - > pos . x , pSprite - > y - pPlayer - > pos . y ) ;
2016-08-27 01:40:35 +00:00
pSprite - > xvel = 48 ;
2006-11-16 03:02:42 +00:00
}
}
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
2012-04-13 10:46:04 +00:00
case FORCESPHERE__STATIC :
2016-08-27 01:40:35 +00:00
if ( pSprite - > yvel = = 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > yvel = 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
for ( bssize_t l = 512 ; l < ( 2048 - 512 ) ; l + = 128 )
{
for ( bssize_t j = 0 ; j < 2048 ; j + = 128 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
int const newSprite = A_Spawn ( spriteNum , FORCESPHERE ) ;
sprite [ newSprite ] . cstat = 257 + 128 ;
sprite [ newSprite ] . clipdist = 64 ;
sprite [ newSprite ] . ang = j ;
sprite [ newSprite ] . zvel = sintable [ l & 2047 ] > > 5 ;
sprite [ newSprite ] . xvel = sintable [ ( l + 512 ) & 2047 ] > > 9 ;
sprite [ newSprite ] . owner = spriteNum ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:41:33 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 3 ] > 0 )
2006-11-16 03:02:42 +00:00
{
2020-02-11 09:21:44 +00:00
if ( pSprite - > zvel < ACTOR_MAXFALLINGZVEL )
2016-08-27 01:40:35 +00:00
pSprite - > zvel + = 192 ;
2016-08-27 01:41:33 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > z + = pSprite - > zvel ;
2016-08-27 01:41:33 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > z > sector [ sectNum ] . floorz )
pSprite - > z = sector [ sectNum ] . floorz ;
2016-08-27 01:41:33 +00:00
if ( - - pData [ 3 ] = = 0 )
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pData [ 2 ] > 10 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
for ( bssize_t SPRITES_OF ( STAT_MISC , miscSprite ) )
{
if ( sprite [ miscSprite ] . owner = = spriteNum & & sprite [ miscSprite ] . picnum = = FORCESPHERE )
actor [ miscSprite ] . t_data [ 1 ] = 1 + ( krand ( ) & 63 ) ;
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
pData [ 3 ] = 64 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case RECON__STATIC :
2012-08-10 19:11:56 +00:00
{
2016-08-27 01:41:33 +00:00
int playerNum ;
DukePlayer_t * pPlayer ;
2012-08-10 19:11:56 +00:00
2016-08-27 01:40:35 +00:00
A_GetZLimits ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
pSprite - > shade + = ( sector [ pSprite - > sectnum ] . ceilingstat & 1 ) ? ( sector [ pSprite - > sectnum ] . ceilingshade - pSprite - > shade ) > > 1
: ( sector [ pSprite - > sectnum ] . floorshade - pSprite - > shade ) > > 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > z < sector [ sectNum ] . ceilingz + ZOFFSET5 )
pSprite - > z = sector [ sectNum ] . ceilingz + ZOFFSET5 ;
2006-04-13 20:47:06 +00:00
2012-08-06 20:00:31 +00:00
#if 0 //def POLYMER
gamelights [ gamelightcount & ( PR_MAXLIGHTS - 1 ) ] . sector = s - > sectnum ;
gamelights [ gamelightcount & ( PR_MAXLIGHTS - 1 ) ] . x = s - > x ;
gamelights [ gamelightcount & ( PR_MAXLIGHTS - 1 ) ] . y = s - > y ;
gamelights [ gamelightcount & ( PR_MAXLIGHTS - 1 ) ] . z = s - > z + 10248 ;
gamelights [ gamelightcount & ( PR_MAXLIGHTS - 1 ) ] . range = 8192 ;
gamelights [ gamelightcount & ( PR_MAXLIGHTS - 1 ) ] . angle = s - > ang ;
gamelights [ gamelightcount & ( PR_MAXLIGHTS - 1 ) ] . horiz = 100 ;
gamelights [ gamelightcount & ( PR_MAXLIGHTS - 1 ) ] . radius = 256 ;
gamelights [ gamelightcount & ( PR_MAXLIGHTS - 1 ) ] . faderadius = 200 ;
gamelights [ gamelightcount & ( PR_MAXLIGHTS - 1 ) ] . color [ 0 ] = 255 ;
gamelights [ gamelightcount & ( PR_MAXLIGHTS - 1 ) ] . color [ 1 ] = 255 ;
gamelights [ gamelightcount & ( PR_MAXLIGHTS - 1 ) ] . color [ 2 ] = 255 ;
gamelights [ gamelightcount & ( PR_MAXLIGHTS - 1 ) ] . priority = PR_LIGHT_PRIO_MAX_GAME ;
if ( gamelightcount < PR_MAXLIGHTS )
gamelightcount + + ;
# endif
2009-04-12 13:02:36 +00:00
2010-05-02 23:27:30 +00:00
if ( ! g_netServer & & ud . multimode < 2 )
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
if ( g_noEnemies = = 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > cstat = 32768 ;
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( g_noEnemies = = 2 ) pSprite - > cstat = 257 ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
if ( A_IncurDamage ( spriteNum ) > = 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > extra < 0 & & pData [ 0 ] ! = - 1 )
2007-08-25 01:05:00 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = - 1 ;
pSprite - > extra = 0 ;
2006-11-16 03:02:42 +00:00
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
A_PlaySound ( RECO_PAIN , spriteNum ) ;
RANDOMSCRAP ( pSprite , spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = - 1 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > z + = 1024 ;
pData [ 2 ] + + ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
if ( ( pData [ 2 ] & 3 ) = = 0 )
A_Spawn ( spriteNum , EXPLOSION2 ) ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
A_GetZLimits ( spriteNum ) ;
pSprite - > ang + = 96 ;
pSprite - > xvel = 128 ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:41:33 +00:00
if ( ! A_SetSprite ( spriteNum , CLIPMASK0 ) | | pSprite - > z > actor [ spriteNum ] . floorz )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:41:33 +00:00
for ( bssize_t l = 0 ; l < 16 ; l + + )
2016-08-27 01:40:35 +00:00
RANDOMSCRAP ( pSprite , spriteNum ) ;
2016-08-27 01:41:33 +00:00
int const newSprite = A_Spawn ( spriteNum , EXPLOSION2 ) ;
A_PlaySound ( LASERTRIP_EXPLODE , newSprite ) ;
A_Spawn ( spriteNum , PIGCOP ) ;
2017-07-05 05:37:58 +00:00
P_AddKills ( g_player [ myconnectindex ] . ps , 1 ) ;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:41:33 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > z > actor [ spriteNum ] . floorz - ( 48 < < 8 ) )
pSprite - > z = actor [ spriteNum ] . floorz - ( 48 < < 8 ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:41:33 +00:00
int32_t playerDist ;
playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
pPlayer = g_player [ playerNum ] . ps ;
2012-08-10 19:11:56 +00:00
2016-08-27 01:41:33 +00:00
int const spriteOwner = pSprite - > owner ;
2006-11-16 03:02:42 +00:00
// 3 = findplayerz, 4 = shoot
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] > = 4 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
if ( ( + + pData [ 2 ] & 15 ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
int const saveAng = pSprite - > ang ;
pSprite - > ang = actor [ spriteNum ] . tempang ;
A_PlaySound ( RECO_ATTACK , spriteNum ) ;
A_Shoot ( spriteNum , FIRELASER ) ;
pSprite - > ang = saveAng ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:41:33 +00:00
if ( pData [ 2 ] > ( GAMETICSPERSEC * 3 )
| | ! cansee ( pSprite - > x , pSprite - > y , pSprite - > z - ZOFFSET2 , pSprite - > sectnum , pPlayer - > pos . x , pPlayer - > pos . y ,
pPlayer - > pos . z , pPlayer - > cursectnum ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = 0 ;
pData [ 2 ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:41:33 +00:00
else actor [ spriteNum ] . tempang + = G_GetAngleDelta ( actor [ spriteNum ] . tempang ,
getangle ( pPlayer - > pos . x - pSprite - > x ,
pPlayer - > pos . y - pSprite - > y ) ) / 3 ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pData [ 0 ] = = 2 | | pData [ 0 ] = = 3 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:46 +00:00
pData [ 3 ] = 0 ;
pSprite - > xvel = ( pSprite - > xvel > 0 ) ? pSprite - > xvel - 16 : 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 2 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
int const zDiff = pPlayer - > pos . z - pSprite - > z ;
if ( klabs ( zDiff ) < ( 48 < < 8 ) )
pData [ 0 ] = 3 ;
else
pSprite - > z + = ksgn ( pPlayer - > pos . z - pSprite - > z ) < < 10 ;
2006-11-16 03:02:42 +00:00
}
else
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 2 ] + + ;
2016-08-27 01:41:33 +00:00
if ( pData [ 2 ] > ( GAMETICSPERSEC * 3 ) | |
! cansee ( pSprite - > x , pSprite - > y , pSprite - > z - ZOFFSET2 , pSprite - > sectnum , pPlayer - > pos . x , pPlayer - > pos . y , pPlayer - > pos . z , pPlayer - > cursectnum ) )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = 1 ;
pData [ 2 ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( ( pData [ 2 ] & 15 ) = = 0 )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
A_PlaySound ( RECO_ATTACK , spriteNum ) ;
A_Shoot ( spriteNum , FIRELASER ) ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:41:33 +00:00
pSprite - > ang + = G_GetAngleDelta ( pSprite - > ang , getangle ( pPlayer - > pos . x - pSprite - > x , pPlayer - > pos . y - pSprite - > y ) ) > > 2 ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] ! = 2 & & pData [ 0 ] ! = 3 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
int newAngle ;
int locatorDist = ldist ( & sprite [ spriteOwner ] , pSprite ) ;
if ( locatorDist < = 1524 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
newAngle = pSprite - > ang ;
2016-08-27 01:40:35 +00:00
pSprite - > xvel > > = 1 ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:41:33 +00:00
else newAngle = getangle ( sprite [ spriteOwner ] . x - pSprite - > x , sprite [ spriteOwner ] . y - pSprite - > y ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 1 | | pData [ 0 ] = = 4 ) // Found a locator and going with it
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
locatorDist = dist ( & sprite [ spriteOwner ] , pSprite ) ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:41:33 +00:00
if ( locatorDist < = 1524 )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:41:33 +00:00
pData [ 0 ] = ( pData [ 0 ] = = 1 ) ? 0 : 5 ;
2006-11-15 01:16:55 +00:00
}
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
// Control speed here
2018-10-07 05:23:53 +00:00
if ( pSprite - > xvel < 256 ) pSprite - > xvel + = 32 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] < 2 ) pData [ 2 ] + + ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( playerDist < 6144 & & pData [ 0 ] < 2 & & pData [ 2 ] > ( GAMETICSPERSEC * 4 ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = 2 + ( krand ( ) & 2 ) ;
pData [ 2 ] = 0 ;
actor [ spriteNum ] . tempang = pSprite - > ang ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
int locatorSprite = pSprite - > owner ;
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 0 | | pData [ 0 ] = = 5 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
pData [ 0 ] = ( pData [ 0 ] = = 0 ) ? 1 : 4 ;
pSprite - > owner = A_FindLocator ( pSprite - > hitag , - 1 ) ;
locatorSprite = pSprite - > owner ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:41:33 +00:00
if ( locatorSprite = = - 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
locatorSprite = actor [ spriteNum ] . t_data [ 5 ] ;
pSprite - > hitag = locatorSprite ;
pSprite - > owner = A_FindLocator ( locatorSprite , - 1 ) ;
locatorSprite = pSprite - > owner ;
if ( locatorSprite = = - 1 )
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else pSprite - > hitag + + ;
2006-11-15 01:16:55 +00:00
}
2012-08-06 20:00:31 +00:00
// RECON_T4
2016-08-27 01:41:33 +00:00
pData [ 3 ] = G_GetAngleDelta ( pSprite - > ang , newAngle ) ;
2016-08-27 01:40:35 +00:00
pSprite - > ang + = pData [ 3 ] > > 3 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > z < sprite [ locatorSprite ] . z - 512 )
2016-08-27 01:40:35 +00:00
pSprite - > z + = 512 ;
2016-08-27 01:41:33 +00:00
else if ( pSprite - > z > sprite [ locatorSprite ] . z + 512 )
2016-08-27 01:40:35 +00:00
pSprite - > z - = 512 ;
2016-08-27 01:41:33 +00:00
else
pSprite - > z = sprite [ locatorSprite ] . z ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( ! A_CheckSoundPlaying ( spriteNum , RECO_ROAM ) )
A_PlaySound ( RECO_ROAM , spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
A_SetSprite ( spriteNum , CLIPMASK0 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2012-08-10 19:11:56 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case GREENSLIME__STATIC :
2012-08-10 19:11:56 +00:00
{
2006-11-16 03:02:42 +00:00
// #ifndef VOLUMEONE
2012-08-07 13:08:57 +00:00
if ( ! g_netServer & & ud . multimode < 2 )
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
if ( g_noEnemies = = 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > cstat = 32768 ;
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( g_noEnemies = = 2 ) pSprite - > cstat = 257 ;
2006-11-16 03:02:42 +00:00
}
// #endif
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pData [ 1 ] + = 128 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( sector [ sectNum ] . floorstat & 1 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
int32_t playerDist ;
int const playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
2019-07-08 00:41:25 +00:00
auto const pPlayer = g_player [ playerNum ] . ps ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( playerDist > 20480 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
if ( + + actor [ spriteNum ] . timetosleep > SLEEPTIME )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
actor [ spriteNum ] . timetosleep = 0 ;
changespritestat ( spriteNum , STAT_ZOMBIEACTOR ) ;
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = - 5 ) // FROZEN
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 3 ] + + ;
if ( pData [ 3 ] > 280 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > pal = 0 ;
pData [ 0 ] = 0 ;
goto next_sprite ;
2006-11-15 01:16:55 +00:00
}
2016-08-27 01:40:35 +00:00
A_Fall ( spriteNum ) ;
pSprite - > cstat = 257 ;
pSprite - > picnum = GREENSLIME + 2 ;
pSprite - > extra = 1 ;
pSprite - > pal = 1 ;
2016-08-27 01:41:33 +00:00
int const damageTile = A_IncurDamage ( spriteNum ) ;
if ( damageTile > = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
if ( damageTile = = FREEZEBLAST )
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2017-07-05 05:37:58 +00:00
P_AddKills ( pPlayer , 1 ) ;
2016-11-15 21:55:25 +00:00
2016-08-27 01:41:33 +00:00
for ( bssize_t j = 16 ; j > = 0 ; - - j )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:41:33 +00:00
int32_t newSprite = A_InsertSprite ( SECT ( spriteNum ) , SX ( spriteNum ) , SY ( spriteNum ) , SZ ( spriteNum ) ,
GLASSPIECES + ( j % 3 ) , - 32 , 36 , 36 , krand ( ) & 2047 , 32 + ( krand ( ) & 63 ) ,
1024 - ( krand ( ) & 1023 ) , spriteNum , 5 ) ;
sprite [ newSprite ] . pal = 1 ;
2007-08-25 01:05:00 +00:00
}
2016-08-27 01:41:33 +00:00
2016-08-27 01:40:35 +00:00
A_PlaySound ( GLASS_BREAKING , spriteNum ) ;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:41:33 +00:00
else if ( playerDist < 1024 & & pPlayer - > quick_kick = = 0 )
2006-11-16 03:02:42 +00:00
{
2018-03-07 04:21:18 +00:00
int const angDiff = G_GetAngleDelta ( fix16_to_int ( pPlayer - > q16ang ) , getangle ( SX ( spriteNum ) - pPlayer - > pos . x ,
2016-08-27 01:41:33 +00:00
SY ( spriteNum ) - pPlayer - > pos . y ) ) ;
if ( angDiff > - 128 & & angDiff < 128 )
2016-08-27 01:40:35 +00:00
pPlayer - > quick_kick = 14 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
pSprite - > cstat = ( playerDist < 1596 ) ? 0 : 257 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = - 4 ) //On the player
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( sprite [ pPlayer - > i ] . extra < 1 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = 0 ;
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2006-04-13 20:47:06 +00:00
2018-03-07 04:21:18 +00:00
pSprite - > ang = fix16_to_int ( pPlayer - > q16ang ) ;
2006-04-13 20:47:06 +00:00
2019-07-08 00:41:17 +00:00
if ( ( TEST_SYNC_KEY ( g_player [ playerNum ] . input - > bits , SK_FIRE ) | | ( pPlayer - > quick_kick > 0 ) ) & & sprite [ pPlayer - > i ] . extra > 0 )
2016-08-27 01:40:35 +00:00
if ( pPlayer - > quick_kick > 0 | |
( PWEAPON ( playerNum , pPlayer - > curr_weapon , WorksLike ) ! = HANDREMOTE_WEAPON & & PWEAPON ( playerNum , pPlayer - > curr_weapon , WorksLike ) ! = HANDBOMB_WEAPON & &
PWEAPON ( playerNum , pPlayer - > curr_weapon , WorksLike ) ! = TRIPBOMB_WEAPON & & pPlayer - > ammo_amount [ pPlayer - > curr_weapon ] > = 0 ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
for ( bssize_t x = 0 ; x < 8 ; + + x )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:41:33 +00:00
int const j
= A_InsertSprite ( sectNum , pSprite - > x , pSprite - > y , pSprite - > z - ZOFFSET3 , SCRAP3 + ( krand ( ) & 3 ) , - 8 , 48 , 48 ,
krand ( ) & 2047 , ( krand ( ) & 63 ) + 64 , - ( krand ( ) & 4095 ) - ( pSprite - > zvel > > 2 ) , spriteNum , 5 ) ;
2006-11-16 03:02:42 +00:00
sprite [ j ] . pal = 6 ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
A_PlaySound ( SLIM_DYING , spriteNum ) ;
A_PlaySound ( SQUISHED , spriteNum ) ;
2016-08-27 01:41:33 +00:00
2008-11-20 14:06:36 +00:00
if ( ( krand ( ) & 255 ) < 32 )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:41:33 +00:00
int const j = A_Spawn ( spriteNum , BLOODPOOL ) ;
2006-11-16 03:02:42 +00:00
sprite [ j ] . pal = 0 ;
2006-11-15 01:16:55 +00:00
}
2016-08-27 01:41:33 +00:00
2017-07-05 05:37:58 +00:00
P_AddKills ( pPlayer , 1 ) ;
2016-08-27 01:40:35 +00:00
pData [ 0 ] = - 3 ;
2016-08-27 01:41:33 +00:00
2016-08-27 01:40:35 +00:00
if ( pPlayer - > somethingonplayer = = spriteNum )
pPlayer - > somethingonplayer = - 1 ;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2018-03-07 04:21:18 +00:00
pSprite - > z = pPlayer - > pos . z + pPlayer - > pyoff - pData [ 2 ] + ZOFFSET3 + ( fix16_to_int ( F16 ( 100 ) - pPlayer - > q16horiz ) < < 4 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 2 ] > 512 )
pData [ 2 ] - = 128 ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 2 ] < 348 )
pData [ 2 ] + = 128 ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( pPlayer - > newowner > = 0 )
G_ClearCameraView ( pPlayer ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 3 ] > 0 )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
static const char slimeFrames [ ] = { 5 , 5 , 6 , 6 , 7 , 7 , 6 , 5 } ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > picnum = GREENSLIME + slimeFrames [ pData [ 3 ] ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 3 ] = = 5 )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
sprite [ pPlayer - > i ] . extra + = - ( 5 + ( krand ( ) & 3 ) ) ;
A_PlaySound ( SLIM_ATTACK , spriteNum ) ;
2006-11-15 01:16:55 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pData [ 3 ] < 7 )
pData [ 3 ] + + ;
else
pData [ 3 ] = 0 ;
2006-11-16 03:02:42 +00:00
}
else
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > picnum = GREENSLIME + 5 ;
2006-11-16 03:02:42 +00:00
if ( rnd ( 32 ) )
2016-08-27 01:40:35 +00:00
pData [ 3 ] = 1 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > xrepeat = 20 + ( sintable [ pData [ 1 ] & 2047 ] > > 13 ) ;
pSprite - > yrepeat = 15 + ( sintable [ pData [ 1 ] & 2047 ] > > 13 ) ;
2018-03-07 04:21:18 +00:00
pSprite - > x = pPlayer - > pos . x + ( sintable [ ( fix16_to_int ( pPlayer - > q16ang ) + 512 ) & 2047 ] > > 7 ) ;
pSprite - > y = pPlayer - > pos . y + ( sintable [ fix16_to_int ( pPlayer - > q16ang ) & 2047 ] > > 7 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
else if ( pSprite - > xvel < 64 & & playerDist < 768 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pPlayer - > somethingonplayer = = - 1 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pPlayer - > somethingonplayer = spriteNum ;
if ( pData [ 0 ] = = 3 | | pData [ 0 ] = = 2 ) // Falling downward
pData [ 2 ] = ( 12 < < 8 ) ;
else
pData [ 2 ] = - ( 13 < < 8 ) ; // Climbing up player
pData [ 0 ] = - 4 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
int const damageTile = A_IncurDamage ( spriteNum ) ;
if ( damageTile > = 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
A_PlaySound ( SLIM_DYING , spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pPlayer - > somethingonplayer = = spriteNum )
pPlayer - > somethingonplayer = - 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( damageTile = = FREEZEBLAST )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
A_PlaySound ( SOMETHINGFROZE , spriteNum ) ;
pData [ 0 ] = - 5 ;
pData [ 3 ] = 0 ;
goto next_sprite ;
2007-08-25 01:05:00 +00:00
}
2006-11-15 01:16:55 +00:00
2017-07-05 05:37:58 +00:00
P_AddKills ( pPlayer , 1 ) ;
2016-11-15 21:55:25 +00:00
2008-11-20 14:06:36 +00:00
if ( ( krand ( ) & 255 ) < 32 )
2007-08-25 01:05:00 +00:00
{
2016-08-27 01:41:33 +00:00
int const j = A_Spawn ( spriteNum , BLOODPOOL ) ;
2006-11-16 03:02:42 +00:00
sprite [ j ] . pal = 0 ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
for ( bssize_t x = 0 ; x < 8 ; x + + )
2007-08-25 01:05:00 +00:00
{
2016-08-27 01:41:33 +00:00
int const j = A_InsertSprite ( sectNum , pSprite - > x , pSprite - > y , pSprite - > z - ZOFFSET3 , SCRAP3 + ( krand ( ) & 3 ) , - 8 ,
48 , 48 , krand ( ) & 2047 , ( krand ( ) & 63 ) + 64 , - ( krand ( ) & 4095 ) - ( pSprite - > zvel > > 2 ) ,
spriteNum , 5 ) ;
2006-11-16 03:02:42 +00:00
sprite [ j ] . pal = 6 ;
}
2016-08-27 01:40:35 +00:00
pData [ 0 ] = - 3 ;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
// All weap
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = - 1 ) //Shrinking down
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
A_Fall ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > cstat & = 65535 - 8 ;
pSprite - > picnum = GREENSLIME + 4 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
// if(s->yrepeat > 62)
2008-11-20 14:06:36 +00:00
// A_DoGuts(s,JIBS6,5,myconnectindex);
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xrepeat > 32 ) pSprite - > xrepeat - = krand ( ) & 7 ;
if ( pSprite - > yrepeat > 16 ) pSprite - > yrepeat - = krand ( ) & 7 ;
2006-11-16 03:02:42 +00:00
else
{
2016-08-27 01:40:35 +00:00
pSprite - > xrepeat = 40 ;
pSprite - > yrepeat = 16 ;
pData [ 5 ] = - 1 ;
pData [ 0 ] = 0 ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pData [ 0 ] ! = - 2 ) A_GetZLimits ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = - 2 ) //On top of somebody
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
A_Fall ( spriteNum ) ;
sprite [ pData [ 5 ] ] . xvel = 0 ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:41:33 +00:00
int const ang = sprite [ pData [ 5 ] ] . ang ;
pSprite - > x = sprite [ pData [ 5 ] ] . x + ( sintable [ ( ang + 512 ) & 2047 ] > > 11 ) ;
pSprite - > y = sprite [ pData [ 5 ] ] . y + ( sintable [ ang & 2047 ] > > 11 ) ;
pSprite - > z = sprite [ pData [ 5 ] ] . z ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:41:33 +00:00
pSprite - > picnum = GREENSLIME + 2 + ( g_globalRandom & 1 ) ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:41:33 +00:00
if ( pSprite - > yrepeat < 64 )
pSprite - > yrepeat + = 2 ;
2006-11-16 03:02:42 +00:00
else
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
if ( pSprite - > xrepeat < 32 )
pSprite - > xrepeat + = 4 ;
2006-11-16 03:02:42 +00:00
else
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
pData [ 0 ] = - 1 ;
playerDist = ldist ( pSprite , & sprite [ pData [ 5 ] ] ) ;
if ( playerDist < 768 )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
sprite [ pData [ 5 ] ] . xrepeat = 0 ;
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
// JBF 20041129: a slimer eating another enemy really ought
// to decrease the maximum kill count by one.
2020-03-01 07:35:05 +00:00
if ( sprite [ pData [ 5 ] ] . extra > 0 & & g_player [ myconnectindex ] . ps - > max_actors_killed > 0 )
2012-04-13 10:46:04 +00:00
g_player [ myconnectindex ] . ps - > max_actors_killed - - ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
}
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
//Check randomly to see of there is an actor near
if ( rnd ( 32 ) )
{
2016-08-27 01:41:33 +00:00
for ( bssize_t SPRITES_OF_SECT ( sectNum , j ) )
2006-04-13 20:47:06 +00:00
{
2016-02-02 00:21:17 +00:00
if ( A_CheckSpriteFlags ( j , SFLAG_GREENSLIMEFOOD ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( ldist ( pSprite , & sprite [ j ] ) < 768 & & ( klabs ( pSprite - > z - sprite [ j ] . z ) < 8192 ) ) // Gulp them
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 5 ] = j ;
pData [ 0 ] = - 2 ;
pData [ 1 ] = 0 ;
goto next_sprite ;
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
//Moving on the ground or ceiling
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 0 | | pData [ 0 ] = = 2 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > picnum = GREENSLIME ;
2006-11-16 03:02:42 +00:00
2008-11-20 14:06:36 +00:00
if ( ( krand ( ) & 511 ) = = 0 )
2016-08-27 01:40:35 +00:00
A_PlaySound ( SLIM_ROAM , spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 2 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > zvel = 0 ;
pSprite - > cstat & = ( 65535 - 8 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( ( sector [ sectNum ] . ceilingstat & 1 ) | | ( actor [ spriteNum ] . ceilingz + 6144 ) < pSprite - > z )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > z + = 2048 ;
pData [ 0 ] = 3 ;
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
else
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > cstat | = 8 ;
A_Fall ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
if ( everyothertime & 1 ) A_SetSprite ( spriteNum , CLIPMASK0 ) ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel > 96 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xvel - = 2 ;
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
else
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xvel = 64 - ( sintable [ ( pData [ 1 ] + 512 ) & 2047 ] > > 9 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > ang + = G_GetAngleDelta ( pSprite - > ang ,
getangle ( pPlayer - > pos . x - pSprite - > x , pPlayer - > pos . y - pSprite - > y ) ) > > 3 ;
2006-11-16 03:02:42 +00:00
// TJR
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > xrepeat = 36 + ( sintable [ ( pData [ 1 ] + 512 ) & 2047 ] > > 11 ) ;
pSprite - > yrepeat = 16 + ( sintable [ pData [ 1 ] & 2047 ] > > 13 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( rnd ( 4 ) & & ( sector [ sectNum ] . ceilingstat & 1 ) = = 0 & &
klabs ( actor [ spriteNum ] . floorz - actor [ spriteNum ] . ceilingz )
2006-11-16 03:02:42 +00:00
< ( 192 < < 8 ) )
{
2016-08-27 01:40:35 +00:00
pSprite - > zvel = 0 ;
pData [ 0 ] + + ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 1 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > picnum = GREENSLIME ;
if ( pSprite - > yrepeat < 40 ) pSprite - > yrepeat + = 8 ;
if ( pSprite - > xrepeat > 8 ) pSprite - > xrepeat - = 4 ;
if ( pSprite - > zvel > - ( 2048 + 1024 ) )
pSprite - > zvel - = 348 ;
pSprite - > z + = pSprite - > zvel ;
if ( pSprite - > z < actor [ spriteNum ] . ceilingz + 4096 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > z = actor [ spriteNum ] . ceilingz + 4096 ;
pSprite - > xvel = 0 ;
pData [ 0 ] = 2 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 3 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > picnum = GREENSLIME + 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
A_Fall ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > z > actor [ spriteNum ] . floorz - ZOFFSET3 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > yrepeat - = 4 ;
pSprite - > xrepeat + = 2 ;
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
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > yrepeat < ( 40 - 4 ) ) pSprite - > yrepeat + = 8 ;
if ( pSprite - > xrepeat > 8 ) pSprite - > xrepeat - = 4 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > z > actor [ spriteNum ] . floorz - 2048 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > z = actor [ spriteNum ] . floorz - 2048 ;
pData [ 0 ] = 0 ;
pSprite - > xvel = 0 ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2012-08-10 19:11:56 +00:00
}
2006-04-13 20:47:06 +00:00
2015-08-02 08:50:31 +00:00
case BOUNCEMINE__STATIC :
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel ! = 0 )
2006-11-16 03:02:42 +00:00
case MORTER__STATIC :
2015-08-08 07:04:11 +00:00
{
2016-08-27 01:41:33 +00:00
int const j = A_Spawn ( spriteNum , ( PLUTOPAK ? FRAMEEFFECT1 : FRAMEEFFECT1_13 ) ) ;
2010-05-02 23:27:30 +00:00
actor [ j ] . t_data [ 0 ] = 3 ;
2015-08-08 07:04:11 +00:00
}
2018-09-04 05:57:41 +00:00
fallthrough__ ;
2006-11-16 03:02:42 +00:00
case HEAVYHBOMB__STATIC :
2012-08-10 19:11:56 +00:00
{
2016-08-27 01:41:33 +00:00
int playerNum ;
2016-08-27 01:40:35 +00:00
DukePlayer_t * pPlayer ;
2016-08-27 01:41:33 +00:00
int detonatePlayer ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( ( pSprite - > cstat & 32768 ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( - - pData [ 2 ] < = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
A_PlaySound ( TELEPORTER , spriteNum ) ;
A_Spawn ( spriteNum , TRANSPORTERSTAR ) ;
2016-08-27 01:40:35 +00:00
pSprite - > cstat = 257 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
int32_t playerDist ;
playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
pPlayer = g_player [ playerNum ] . ps ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:41:33 +00:00
if ( playerDist < 1220 )
2016-08-27 01:40:35 +00:00
pSprite - > cstat & = ~ 257 ;
else
pSprite - > cstat | = 257 ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 3 ] = = 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( A_IncurDamage ( spriteNum ) > = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
pData [ 3 ] = 1 ;
pData [ 2 ] = 0 ;
detonatePlayer = 0 ;
pSprite - > xvel = 0 ;
2006-04-13 20:47:06 +00:00
goto DETONATEB ;
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum ! = BOUNCEMINE )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
A_Fall ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2020-02-11 09:21:44 +00:00
if ( ( sector [ sectNum ] . lotag ! = ST_1_ABOVE_WATER | | actor [ spriteNum ] . floorz ! = sector [ sectNum ] . floorz ) & & pSprite - > z > = actor [ spriteNum ] . floorz - ( ACTOR_FLOOR_OFFSET ) & & pSprite - > yvel < 3 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > yvel > 0 | | ( pSprite - > yvel = = 0 & & actor [ spriteNum ] . floorz = = sector [ sectNum ] . floorz ) )
A_PlaySound ( PIPEBOMB_BOUNCE , spriteNum ) ;
pSprite - > zvel = - ( ( 4 - pSprite - > yvel ) < < 8 ) ;
if ( sector [ pSprite - > sectnum ] . lotag = = ST_2_UNDERWATER )
pSprite - > zvel > > = 2 ;
pSprite - > yvel + + ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pSprite - > z < actor [ spriteNum ] . ceilingz ) // && sector[sect].lotag != ST_2_UNDERWATER )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > z = actor [ spriteNum ] . ceilingz + ( 3 < < 8 ) ;
pSprite - > zvel = 0 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
// can't initialize this because of the goto above
2016-08-27 01:40:35 +00:00
vec3_t tmpvect ;
tmpvect . x = ( pSprite - > xvel * ( sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) ) > > 14 ;
tmpvect . y = ( pSprite - > xvel * ( sintable [ pSprite - > ang & 2047 ] ) ) > > 14 ;
tmpvect . z = pSprite - > zvel ;
2009-01-13 04:40:56 +00:00
2016-08-27 01:41:33 +00:00
int moveSprite ;
moveSprite = A_MoveSprite ( spriteNum , & tmpvect , CLIPMASK0 ) ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:41:33 +00:00
actor [ spriteNum ] . movflag = moveSprite ;
2008-08-26 04:00:42 +00:00
2016-08-27 01:40:35 +00:00
if ( sector [ SECT ( spriteNum ) ] . lotag = = ST_1_ABOVE_WATER & & pSprite - > zvel = = 0 & & actor [ spriteNum ] . floorz = = sector [ sectNum ] . floorz )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:56 +00:00
pSprite - > z + = ZOFFSET5 ;
2016-08-27 01:40:35 +00:00
if ( pData [ 5 ] = = 0 )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 5 ] = 1 ;
A_Spawn ( spriteNum , WATERSPLASH2 ) ;
2006-11-16 03:02:42 +00:00
}
}
2016-08-27 01:40:35 +00:00
else pData [ 5 ] = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( pData [ 3 ] = = 0 & & ( pSprite - > picnum = = BOUNCEMINE | | pSprite - > picnum = = MORTER ) & & ( moveSprite | | playerDist < 844 ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 3 ] = 1 ;
pData [ 2 ] = 0 ;
2016-08-27 01:41:33 +00:00
detonatePlayer = 0 ;
2016-08-27 01:40:35 +00:00
pSprite - > xvel = 0 ;
2006-11-16 03:02:42 +00:00
goto DETONATEB ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( sprite [ pSprite - > owner ] . picnum = = APLAYER )
2016-08-27 01:41:33 +00:00
detonatePlayer = P_Get ( pSprite - > owner ) ;
else detonatePlayer = - 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel > 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xvel - = 5 ;
if ( sector [ sectNum ] . lotag = = ST_2_UNDERWATER )
pSprite - > xvel - = 10 ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel < 0 )
pSprite - > xvel = 0 ;
if ( pSprite - > xvel & 8 ) pSprite - > cstat ^ = 4 ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:41:33 +00:00
if ( ( moveSprite & 49152 ) = = 32768 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
moveSprite & = ( MAXWALLS - 1 ) ;
2019-09-08 01:01:13 +00:00
A_DamageWall ( spriteNum , moveSprite , pSprite - > pos , pSprite - > picnum ) ;
2016-08-27 01:41:33 +00:00
Proj_BounceOffWall ( pSprite , moveSprite ) ;
2016-08-27 01:40:35 +00:00
pSprite - > xvel > > = 1 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
DETONATEB :
2013-01-20 21:16:58 +00:00
// Pipebomb control set to timer? (see player.c)
2014-01-12 14:54:34 +00:00
// TIMER_CONTROL
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum = = HEAVYHBOMB & & pData [ 6 ] = = 1 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 7 ] > = 1 )
pData [ 7 ] - - ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 7 ] < = 0 )
pData [ 6 ] = 3 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( ( detonatePlayer > = 0 & & g_player [ detonatePlayer ] . ps - > hbomb_on = = 0 & & pData [ 6 ] = = 2 ) | | pData [ 3 ] = = 1 )
2016-08-27 01:40:35 +00:00
pData [ 6 ] = 3 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 6 ] = = 3 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 2 ] + + ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 2 ] = = 2 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
int const x = pSprite - > extra ;
int radius = 0 ;
2010-07-03 08:53:57 +00:00
2016-08-27 01:40:35 +00:00
switch ( DYNAMICTILEMAP ( pSprite - > picnum ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:42:01 +00:00
case HEAVYHBOMB__STATIC : radius = g_pipebombRadius ; break ;
case MORTER__STATIC : radius = g_morterRadius ; break ;
case BOUNCEMINE__STATIC : radius = g_bouncemineRadius ; break ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:41:33 +00:00
A_RadiusDamage ( spriteNum , radius , x > > 2 , x > > 1 , x - ( x > > 2 ) , x ) ;
int const j = A_Spawn ( spriteNum , EXPLOSION2 ) ;
A_PlaySound ( PIPEBOMB_EXPLODE , j ) ;
2016-08-27 01:40:35 +00:00
if ( pSprite - > zvel = = 0 )
A_Spawn ( spriteNum , EXPLOSION2BOT ) ;
2016-08-27 01:41:33 +00:00
for ( bssize_t x = 0 ; x < 8 ; + + x )
2016-08-27 01:40:35 +00:00
RANDOMSCRAP ( pSprite , spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > yrepeat )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > yrepeat = 0 ;
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 2 ] > 20 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > owner ! = spriteNum | | ud . respawn_items = = 0 )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
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
{
2016-08-27 01:40:35 +00:00
pData [ 2 ] = g_itemRespawnTime ;
A_Spawn ( spriteNum , RESPAWNMARKERRED ) ;
pSprite - > cstat = 32768 ;
pSprite - > yrepeat = 9 ;
goto next_sprite ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
}
2016-08-27 01:41:33 +00:00
else if ( pSprite - > picnum = = HEAVYHBOMB & & playerDist < 788 & & pData [ 0 ] > 7 & & pSprite - > xvel = = 0 )
{
if ( cansee ( pSprite - > x , pSprite - > y , pSprite - > z - ZOFFSET3 , pSprite - > sectnum ,
pPlayer - > pos . x , pPlayer - > pos . y , pPlayer - > pos . z , pPlayer - > cursectnum ) )
{
2016-08-27 01:40:35 +00:00
if ( pPlayer - > ammo_amount [ HANDBOMB_WEAPON ] < pPlayer - > max_ammo_amount [ HANDBOMB_WEAPON ] )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:42:01 +00:00
if ( ( g_gametypeFlags [ ud . coop ] & GAMETYPE_WEAPSTAY ) & & pSprite - > owner = = spriteNum )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
for ( bssize_t j = 0 ; j < pPlayer - > weapreccnt ; j + + )
{
2016-08-27 01:40:35 +00:00
if ( pPlayer - > weaprecs [ j ] = = pSprite - > picnum )
goto next_sprite ;
2016-08-27 01:41:33 +00:00
}
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( pPlayer - > weapreccnt < MAX_WEAPONS )
pPlayer - > weaprecs [ pPlayer - > weapreccnt + + ] = pSprite - > picnum ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:41:33 +00:00
P_AddAmmo ( pPlayer , HANDBOMB_WEAPON , 1 ) ;
A_PlaySound ( DUKE_GET , pPlayer - > i ) ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( ( pPlayer - > gotweapon & ( 1 < < HANDBOMB_WEAPON ) ) = = 0 | | pSprite - > owner = = pPlayer - > i )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
int doSwitch = ( ( pPlayer - > weaponswitch & 1 ) | |
2016-08-27 01:41:33 +00:00
PWEAPON ( playerNum , pPlayer - > curr_weapon , WorksLike ) = = HANDREMOTE_WEAPON ) ;
2016-08-27 01:40:35 +00:00
P_AddWeapon ( pPlayer , HANDBOMB_WEAPON , doSwitch ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
if ( sprite [ pSprite - > owner ] . picnum ! = APLAYER )
P_PalFrom ( pPlayer , 32 , 0 , 32 , 0 ) ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > owner ! = spriteNum | | ud . respawn_items = = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:42:01 +00:00
if ( pSprite - > owner = = spriteNum & & ( g_gametypeFlags [ ud . coop ] & GAMETYPE_WEAPSTAY ) )
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
pData [ 2 ] = g_itemRespawnTime ;
A_Spawn ( spriteNum , RESPAWNMARKERRED ) ;
pSprite - > cstat = 32768 ;
2006-04-13 20:47:06 +00:00
}
}
2016-08-27 01:41:33 +00:00
}
}
if ( pData [ 0 ] < 8 )
pData [ 0 ] + + ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2012-08-10 19:11:56 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case REACTORBURNT__STATIC :
case REACTOR2BURNT__STATIC :
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case REACTOR__STATIC :
case REACTOR2__STATIC :
2012-08-10 19:11:56 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 4 ] = = 1 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
for ( bssize_t SPRITES_OF_SECT ( sectNum , j ) )
2006-04-13 20:47:06 +00:00
{
2012-01-28 14:38:23 +00:00
switch ( DYNAMICTILEMAP ( sprite [ j ] . picnum ) )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
case SECTOREFFECTOR__STATIC :
if ( sprite [ j ] . lotag = = 1 )
2006-04-13 20:47:06 +00:00
{
2018-01-28 04:30:38 +00:00
sprite [ j ] . lotag = 65535u ;
sprite [ j ] . hitag = 65535u ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
break ;
case REACTOR__STATIC :
sprite [ j ] . picnum = REACTORBURNT ;
break ;
case REACTOR2__STATIC :
sprite [ j ] . picnum = REACTOR2BURNT ;
break ;
case REACTORSPARK__STATIC :
case REACTOR2SPARK__STATIC :
2012-11-18 19:01:34 +00:00
sprite [ j ] . cstat = 32768 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2006-11-15 01:16:55 +00:00
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 1 ] > = 20 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 4 ] = 1 ;
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2019-07-08 00:41:25 +00:00
int32_t playerDist ;
int playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
auto const pPlayer = g_player [ playerNum ] . ps ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:33 +00:00
if ( + + pData [ 2 ] = = 4 )
pData [ 2 ] = 0 ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:41:33 +00:00
if ( playerDist < 4096 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
if ( ( krand ( ) & 255 ) < 16 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
if ( ! A_CheckSoundPlaying ( pPlayer - > i , DUKE_LONGTERM_PAIN ) )
A_PlaySound ( DUKE_LONGTERM_PAIN , pPlayer - > i ) ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:41:33 +00:00
A_PlaySound ( SHORT_CIRCUIT , spriteNum ) ;
sprite [ pPlayer - > i ] . extra - - ;
P_PalFrom ( pPlayer , 32 , 32 , 0 , 0 ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:41:33 +00:00
2016-08-27 01:40:35 +00:00
pData [ 0 ] + = 128 ;
2016-08-27 01:41:33 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 3 ] = = 0 )
pData [ 3 ] = 1 ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else pData [ 3 ] = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 1 ] )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 1 ] + + ;
2016-08-27 01:41:33 +00:00
pData [ 4 ] = pSprite - > z ;
pSprite - > z = sector [ sectNum ] . floorz - ( krand ( ) % ( sector [ sectNum ] . floorz - sector [ sectNum ] . ceilingz ) ) ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
switch ( pData [ 1 ] )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
case 3 :
// Turn on all of those flashing sectoreffector.
A_RadiusDamage ( spriteNum , 4096 , g_impactDamage < < 2 , g_impactDamage < < 2 , g_impactDamage < < 2 , g_impactDamage < < 2 ) ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:41:33 +00:00
for ( bssize_t SPRITES_OF ( STAT_STANDABLE , j ) )
{
if ( sprite [ j ] . picnum = = MASTERSWITCH & & sprite [ j ] . hitag = = pSprite - > hitag & & sprite [ j ] . yvel = = 0 )
sprite [ j ] . yvel = 1 ;
}
break ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:41:33 +00:00
case 4 :
case 7 :
case 10 :
case 15 :
for ( bssize_t SPRITES_OF_SECT ( sectNum , j ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
if ( j ! = spriteNum )
{
A_DeleteSprite ( j ) ;
break ;
}
2006-11-16 03:02:42 +00:00
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:41:33 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:41:33 +00:00
for ( bssize_t x = 0 ; x < 16 ; x + + )
2016-08-27 01:40:35 +00:00
RANDOMSCRAP ( pSprite , spriteNum ) ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > z = pData [ 4 ] ;
2016-08-27 01:41:33 +00:00
pData [ 4 ] = 0 ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:41:33 +00:00
else if ( A_IncurDamage ( spriteNum ) > = 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
for ( bssize_t x = 0 ; x < 32 ; x + + )
RANDOMSCRAP ( pSprite , spriteNum ) ;
if ( pSprite - > extra < 0 )
pData [ 1 ] = 1 ;
2007-08-25 01:05:00 +00:00
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2012-08-10 19:11:56 +00:00
}
2006-04-13 20:47:06 +00:00
}
2020-01-29 11:37:16 +00:00
# endif // EDUKE32_STANDALONE
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( ! g_netServer & & ud . multimode < 2 & & A_CheckEnemySprite ( pSprite ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( g_noEnemies = = 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > cstat = 32768 ;
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
else if ( g_noEnemies = = 2 )
2006-12-17 21:20:35 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > cstat = 0 ;
if ( pSprite - > extra )
pSprite - > cstat = 257 ;
2006-12-17 21:20:35 +00:00
}
2006-04-13 20:47:06 +00:00
}
2008-08-09 22:02:57 +00:00
2020-04-05 06:40:38 +00:00
if ( G_TileHasActor ( sprite [ spriteNum ] . picnum ) )
2012-08-10 19:11:56 +00:00
{
2016-08-27 01:41:33 +00:00
int32_t playerDist ;
2018-11-18 18:07:51 +00:00
int const playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
2016-08-27 01:41:33 +00:00
A_Execute ( spriteNum , playerNum , playerDist ) ;
2012-08-10 19:11:56 +00:00
}
2016-08-27 01:40:35 +00:00
next_sprite :
2016-08-27 01:40:46 +00:00
A_MaybeAwakenBadGuys ( spriteNum ) ;
2016-08-27 01:40:35 +00:00
spriteNum = nextSprite ;
2006-04-13 20:47:06 +00:00
}
}
2010-01-24 23:33:17 +00:00
ACTOR_STATIC void G_MoveMisc ( void ) // STATNUM 5
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
int spriteNum = headspritestat [ STAT_MISC ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
while ( spriteNum > = 0 )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
int const nextSprite = nextspritestat [ spriteNum ] ;
int32_t playerDist ;
auto const pData = actor [ spriteNum ] . t_data ;
auto const pSprite = & sprite [ spriteNum ] ;
int sectNum = pSprite - > sectnum ; // XXX: not const
int switchPic ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( sectNum < 0 | | pSprite - > xrepeat = = 0 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2013-04-15 10:48:09 +00:00
2019-08-07 22:43:48 +00:00
actor [ spriteNum ] . bpos = pSprite - > pos ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
switchPic = pSprite - > picnum ;
2018-04-02 22:00:44 +00:00
# ifndef EDUKE32_STANDALONE
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum > NUKEBUTTON & & pSprite - > picnum < = NUKEBUTTON + 3 )
switchPic = NUKEBUTTON ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum > GLASSPIECES & & pSprite - > picnum < = GLASSPIECES + 2 )
switchPic = GLASSPIECES ;
2009-08-28 23:08:00 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum = = INNERJAW + 1 )
switchPic - - ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:40:35 +00:00
if ( ( pSprite - > picnum = = MONEY + 1 ) | | ( pSprite - > picnum = = MAIL + 1 ) | | ( pSprite - > picnum = = PAPER + 1 ) )
actor [ spriteNum ] . floorz = pSprite - > z = getflorzofslope ( pSprite - > sectnum , pSprite - > x , pSprite - > y ) ;
2018-04-02 22:00:44 +00:00
else
# endif
2020-01-29 11:37:16 +00:00
{
2018-04-02 22:00:44 +00:00
switch ( DYNAMICTILEMAP ( switchPic ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:46 +00:00
case APLAYER__STATIC : pSprite - > cstat = 32768 ; goto next_sprite ;
2018-04-02 22:00:44 +00:00
case FRAMEEFFECT1_13__STATIC :
if ( PLUTOPAK ) goto next_sprite ; // JBF: ideally this should never happen...
fallthrough__ ;
case FRAMEEFFECT1__STATIC :
if ( pSprite - > owner > = 0 )
{
pData [ 0 ] + + ;
if ( pData [ 0 ] > 7 )
{
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
}
else if ( pData [ 0 ] > 4 )
pSprite - > cstat | = 512 + 2 ;
else if ( pData [ 0 ] > 2 )
pSprite - > cstat | = 2 ;
pSprite - > xoffset = sprite [ pSprite - > owner ] . xoffset ;
pSprite - > yoffset = sprite [ pSprite - > owner ] . yoffset ;
}
goto next_sprite ;
2020-03-29 08:41:12 +00:00
# ifndef EDUKE32_STANDALONE
case ONFIRESMOKE__STATIC :
case ONFIRE__STATIC :
case BURNEDCORPSE__STATIC :
case LAVAPOOLBUBBLE__STATIC :
case WHISPYSMOKE__STATIC :
case LAVAPOOL__STATIC :
if ( ! WORLDTOUR )
goto next_sprite ;
fallthrough__ ;
# endif
2019-06-25 11:27:47 +00:00
case EXPLOSION2__STATIC :
case EXPLOSION2BOT__STATIC :
case FORCERIPPLE__STATIC :
case TRANSPORTERSTAR__STATIC :
case TRANSPORTERBEAM__STATIC :
case SMALLSMOKE__STATIC :
# ifndef EDUKE32_STANDALONE
case WATERBUBBLE__STATIC :
2018-04-02 22:00:44 +00:00
case BURNING__STATIC :
case BURNING2__STATIC :
case FECES__STATIC :
case SHRINKEREXPLOSION__STATIC :
case BLOOD__STATIC :
case LASERSITE__STATIC :
2019-06-25 11:27:47 +00:00
# endif
2018-04-02 22:00:44 +00:00
{
2020-04-05 06:40:38 +00:00
if ( ! G_TileHasActor ( sprite [ spriteNum ] . picnum ) )
2018-04-02 22:00:44 +00:00
goto next_sprite ;
int const playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
A_Execute ( spriteNum , playerNum , playerDist ) ;
goto next_sprite ;
}
2020-01-29 11:37:16 +00:00
}
2018-04-02 22:00:44 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY )
switch ( DYNAMICTILEMAP ( switchPic ) )
{
2016-08-27 01:40:46 +00:00
case NEON1__STATIC :
case NEON2__STATIC :
case NEON3__STATIC :
case NEON4__STATIC :
case NEON5__STATIC :
case NEON6__STATIC :
pSprite - > shade = ( ( tabledivide32_noinline ( g_globalRandom , pSprite - > lotag + 1 ) & 31 ) > 4 ) ? - 127 : 127 ;
goto next_sprite ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:46 +00:00
case BLOODSPLAT1__STATIC :
case BLOODSPLAT2__STATIC :
case BLOODSPLAT3__STATIC :
case BLOODSPLAT4__STATIC :
if ( pData [ 0 ] = = 3 * GAMETICSPERSEC )
goto next_sprite ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:46 +00:00
actor [ spriteNum ] . bpos . z - = pSprite - > z ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:46 +00:00
if ( ( + + pData [ 0 ] % 9 ) = = 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:46 +00:00
pSprite - > yrepeat + + ;
pSprite - > z + = ( tilesiz [ pSprite - > picnum ] . y * pSprite - > yrepeat ) > > 2 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:46 +00:00
else
pSprite - > z + = 16 + ( krand ( ) & 15 ) ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:46 +00:00
actor [ spriteNum ] . bpos . z + = pSprite - > z ;
goto next_sprite ;
case NUKEBUTTON__STATIC :
// case NUKEBUTTON+1:
// case NUKEBUTTON+2:
// case NUKEBUTTON+3:
if ( pData [ 0 ] )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] + + ;
2016-08-27 01:40:46 +00:00
if ( pData [ 0 ] = = 8 )
pSprite - > picnum = NUKEBUTTON + 1 ;
else if ( pData [ 0 ] = = 16 )
{
pSprite - > picnum = NUKEBUTTON + 2 ;
g_player [ P_Get ( pSprite - > owner ) ] . ps - > fist_incs = 1 ;
}
if ( g_player [ P_Get ( pSprite - > owner ) ] . ps - > fist_incs = = GAMETICSPERSEC )
pSprite - > picnum = NUKEBUTTON + 3 ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:46 +00:00
goto next_sprite ;
case FORCESPHERE__STATIC :
2009-02-19 16:47:54 +00:00
{
2016-08-27 01:42:01 +00:00
int forceRepeat = pSprite - > xrepeat ;
2016-08-27 01:40:46 +00:00
if ( pData [ 1 ] > 0 )
{
pData [ 1 ] - - ;
if ( pData [ 1 ] = = 0 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2016-08-27 01:40:46 +00:00
}
if ( actor [ pSprite - > owner ] . t_data [ 1 ] = = 0 )
{
if ( pData [ 0 ] < 64 )
{
pData [ 0 ] + + ;
2016-08-27 01:42:01 +00:00
forceRepeat + = 3 ;
2016-08-27 01:40:46 +00:00
}
}
else if ( pData [ 0 ] > 64 )
{
pData [ 0 ] - - ;
2016-08-27 01:42:01 +00:00
forceRepeat - = 3 ;
2016-08-27 01:40:46 +00:00
}
2006-04-13 20:47:06 +00:00
2019-06-25 11:28:25 +00:00
pSprite - > pos = sprite [ pSprite - > owner ] . pos ;
pSprite - > ang + = actor [ pSprite - > owner ] . t_data [ 0 ] ;
2006-04-13 20:47:06 +00:00
2019-06-25 11:28:25 +00:00
forceRepeat = clamp2 ( forceRepeat , 1 , 64 ) ;
pSprite - > xrepeat = forceRepeat ;
pSprite - > yrepeat = forceRepeat ;
pSprite - > shade = ( forceRepeat > > 1 ) - 48 ;
2006-04-13 20:47:06 +00:00
2019-05-19 03:56:13 +00:00
for ( int j = pData [ 0 ] ; j > 0 ; j - - )
2016-08-27 01:42:01 +00:00
A_SetSprite ( spriteNum , CLIPMASK0 ) ;
2016-08-27 01:40:46 +00:00
goto next_sprite ;
2018-04-02 22:00:44 +00:00
}
2006-11-16 03:02:42 +00:00
2012-08-06 20:00:31 +00:00
case WATERSPLASH2__STATIC :
2016-08-27 01:40:35 +00:00
pData [ 0 ] + + ;
if ( pData [ 0 ] = = 1 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( sector [ sectNum ] . lotag ! = ST_1_ABOVE_WATER & & sector [ sectNum ] . lotag ! = ST_2_UNDERWATER )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2012-08-06 20:00:31 +00:00
/*
else
{
l = getflorzofslope ( sect , s - > x , s - > y ) - s - > z ;
2016-08-27 01:40:06 +00:00
if ( l > ZOFFSET2 ) KILLIT ( i ) ;
2012-08-06 20:00:31 +00:00
}
else
*/
2018-12-15 01:39:25 +00:00
if ( ! S_CheckSoundPlaying ( ITEM_SPLASH ) )
2016-08-27 01:40:35 +00:00
A_PlaySound ( ITEM_SPLASH , spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 3 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = 0 ;
pData [ 1 ] + + ; // WATERSPLASH_T2
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pData [ 1 ] = = 5 )
A_DeleteSprite ( spriteNum ) ;
goto next_sprite ;
2006-11-16 03:02:42 +00:00
case INNERJAW__STATIC :
2012-08-10 19:11:56 +00:00
{
2006-11-16 03:02:42 +00:00
// case INNERJAW+1:
2016-08-27 01:40:35 +00:00
int32_t playerDist , playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( playerDist < 512 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
P_PalFrom ( g_player [ playerNum ] . ps , 32 , 32 , 0 , 0 ) ;
sprite [ g_player [ playerNum ] . ps - > i ] . extra - = 4 ;
2006-11-16 03:02:42 +00:00
}
2012-08-10 19:11:56 +00:00
}
2017-07-18 20:53:41 +00:00
fallthrough__ ;
2006-11-16 03:02:42 +00:00
case FIRELASER__STATIC :
2016-08-27 01:40:35 +00:00
if ( pSprite - > extra ! = 5 )
pSprite - > extra = 5 ;
2016-08-27 01:41:33 +00:00
else DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
break ;
case TONGUE__STATIC :
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case MONEY__STATIC :
case MAIL__STATIC :
case PAPER__STATIC :
2016-08-27 01:42:01 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xvel = ( krand ( ) & 7 ) + ( sintable [ T1 ( spriteNum ) & 2047 ] > > 9 ) ;
T1 ( spriteNum ) + = ( krand ( ) & 63 ) ;
2019-03-19 17:09:36 +00:00
if ( ( T1 ( spriteNum ) & 2047 ) > 512 & & ( T1 ( spriteNum ) & 2047 ) < 1536 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( sector [ sectNum ] . lotag = = ST_2_UNDERWATER )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > zvel < 64 )
pSprite - > zvel + = ( g_spriteGravity > > 5 ) + ( krand ( ) & 7 ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pSprite - > zvel < 144 )
pSprite - > zvel + = ( g_spriteGravity > > 5 ) + ( krand ( ) & 7 ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
A_SetSprite ( spriteNum , CLIPMASK0 ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( ( krand ( ) & 3 ) = = 0 )
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > sectnum = = - 1 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
int const floorZ = getflorzofslope ( pSprite - > sectnum , pSprite - > x , pSprite - > y ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
if ( pSprite - > z > floorZ )
{
pSprite - > z = floorZ ;
2016-08-27 01:40:35 +00:00
A_AddToDeleteQueue ( spriteNum ) ;
2016-08-27 01:42:01 +00:00
PN ( spriteNum ) + + ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:21 +00:00
for ( bssize_t SPRITES_OF ( STAT_MISC , j ) )
2016-08-27 01:40:35 +00:00
{
if ( sprite [ j ] . picnum = = BLOODPOOL & & ldist ( pSprite , & sprite [ j ] ) < 348 )
{
pSprite - > pal = 2 ;
break ;
}
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2016-08-27 01:42:01 +00:00
}
2006-11-15 01:16:55 +00:00
2006-11-16 03:02:42 +00:00
case JIBS1__STATIC :
case JIBS2__STATIC :
case JIBS3__STATIC :
case JIBS4__STATIC :
case JIBS5__STATIC :
case JIBS6__STATIC :
case HEADJIB1__STATIC :
case ARMJIB1__STATIC :
case LEGJIB1__STATIC :
case LIZMANHEAD1__STATIC :
case LIZMANARM1__STATIC :
case LIZMANLEG1__STATIC :
case DUKETORSO__STATIC :
case DUKEGUN__STATIC :
case DUKELEG__STATIC :
2016-08-27 01:42:01 +00:00
{
pSprite - > xvel = ( pSprite - > xvel > 0 ) ? pSprite - > xvel - 1 : 0 ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( + + pData [ 5 ] = = ( 30 * 10 ) )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > zvel > 1024 & & pSprite - > zvel < 1280 )
2006-11-16 03:02:42 +00:00
{
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2016-08-27 01:40:35 +00:00
sectNum = pSprite - > sectnum ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:42:01 +00:00
int32_t floorZ , ceilZ ;
getzsofslope ( sectNum , pSprite - > x , pSprite - > y , & ceilZ , & floorZ ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
if ( ceilZ = = floorZ | | sectNum < 0 | | sectNum > = MAXSECTORS )
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
if ( pSprite - > z < floorZ - ( 2 < < 8 ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 1 ] < 2 ) pData [ 1 ] + + ;
else if ( sector [ sectNum ] . lotag ! = ST_2_UNDERWATER )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 1 ] = 0 ;
2016-08-27 01:42:01 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum = = DUKELEG | | pSprite - > picnum = = DUKETORSO | | pSprite - > picnum = = DUKEGUN )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
pData [ 0 ] = ( pData [ 0 ] > 6 ) ? 0 : pData [ 0 ] + 1 ;
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:42:01 +00:00
pData [ 0 ] = ( pData [ 0 ] > 2 ) ? 0 : pData [ 0 ] + 1 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
}
2020-02-11 09:21:44 +00:00
if ( pSprite - > zvel < ACTOR_MAXFALLINGZVEL )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( sector [ sectNum ] . lotag = = ST_2_UNDERWATER )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > zvel < 1024 )
pSprite - > zvel + = 48 ;
else pSprite - > zvel = 1024 ;
2006-11-15 01:16:55 +00:00
}
2016-08-27 01:40:35 +00:00
else pSprite - > zvel + = g_spriteGravity - 50 ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > x + = ( pSprite - > xvel * sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) > > 14 ;
pSprite - > y + = ( pSprite - > xvel * sintable [ pSprite - > ang & 2047 ] ) > > 14 ;
pSprite - > z + = pSprite - > zvel ;
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
if ( pData [ 2 ] = = 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > sectnum = = - 1 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2012-04-13 10:46:04 +00:00
2016-08-27 01:40:35 +00:00
if ( ( sector [ pSprite - > sectnum ] . floorstat & 2 ) )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2012-04-13 10:46:04 +00:00
2016-08-27 01:40:35 +00:00
pData [ 2 ] + + ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:42:01 +00:00
floorZ = getflorzofslope ( pSprite - > sectnum , pSprite - > x , pSprite - > y ) ;
pSprite - > z = floorZ - ( 2 < < 8 ) ;
2016-08-27 01:40:35 +00:00
pSprite - > xvel = 0 ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum = = JIBS6 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 1 ] + + ;
2016-08-27 01:42:01 +00:00
2016-08-27 01:40:35 +00:00
if ( ( pData [ 1 ] & 3 ) = = 0 & & pData [ 0 ] < 7 )
pData [ 0 ] + + ;
2016-08-27 01:42:01 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 1 ] > 20 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
pSprite - > picnum = JIBS6 ;
pData [ 0 ] = 0 ;
pData [ 1 ] = 0 ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2016-08-27 01:42:01 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case BLOODPOOL__STATIC :
case PUKE__STATIC :
2012-08-10 19:11:56 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = 1 ;
if ( sector [ sectNum ] . floorstat & 2 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else A_AddToDeleteQueue ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
A_Fall ( spriteNum ) ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:42:01 +00:00
int32_t playerDist ;
int const playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
2019-07-08 00:41:25 +00:00
pSprite - > z = actor [ spriteNum ] . floorz - 1 ;
auto const pPlayer = g_player [ playerNum ] . ps ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 2 ] < 32 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 2 ] + + ;
2016-08-27 01:42:01 +00:00
2016-08-27 01:40:35 +00:00
if ( actor [ spriteNum ] . picnum = = TIRE )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > xrepeat < 64 & & pSprite - > yrepeat < 64 )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xrepeat + = krand ( ) & 3 ;
pSprite - > yrepeat + = krand ( ) & 3 ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > xrepeat < 32 & & pSprite - > yrepeat < 32 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xrepeat + = krand ( ) & 3 ;
pSprite - > yrepeat + = krand ( ) & 3 ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( playerDist < 844 & & pSprite - > xrepeat > 6 & & pSprite - > yrepeat > 6 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > pal = = 0 & & pSprite - > picnum ! = PUKE & & ( krand ( ) & 255 ) < 16 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pPlayer - > inv_amount [ GET_BOOTS ] > 0 )
pPlayer - > inv_amount [ GET_BOOTS ] - - ;
2006-11-16 03:02:42 +00:00
else
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( ! A_CheckSoundPlaying ( pPlayer - > i , DUKE_LONGTERM_PAIN ) )
A_PlaySound ( DUKE_LONGTERM_PAIN , pPlayer - > i ) ;
2016-08-27 01:42:01 +00:00
2016-08-27 01:40:35 +00:00
sprite [ pPlayer - > i ] . extra - - ;
2012-05-05 22:24:50 +00:00
2016-08-27 01:40:35 +00:00
P_PalFrom ( pPlayer , 32 , 16 , 0 , 0 ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 1 ] = = 1 ) goto next_sprite ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pData [ 1 ] = 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pPlayer - > footprintcount = ( actor [ spriteNum ] . picnum = = TIRE ) ? 10 : 3 ;
pPlayer - > footprintpal = pSprite - > pal ;
pPlayer - > footprintshade = pSprite - > shade ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 2 ] = = 32 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xrepeat - = 6 ;
pSprite - > yrepeat - = 6 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else pData [ 1 ] = 0 ;
goto next_sprite ;
2012-08-10 19:11:56 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case SHELL__STATIC :
case SHOTGUNSHELL__STATIC :
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
A_SetSprite ( spriteNum , CLIPMASK0 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( sectNum < 0 | | ( sector [ sectNum ] . floorz + 256 ) < pSprite - > z )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( sector [ sectNum ] . lotag = = ST_2_UNDERWATER )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 1 ] + + ;
if ( pData [ 1 ] > 8 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 1 ] = 0 ;
pData [ 0 ] + + ;
pData [ 0 ] & = 3 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pSprite - > zvel < 128 ) pSprite - > zvel + = ( g_spriteGravity / 13 ) ; // 8
else pSprite - > zvel - = 64 ;
if ( pSprite - > xvel > 0 )
pSprite - > xvel - = 4 ;
else pSprite - > xvel = 0 ;
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
pData [ 1 ] + + ;
if ( pData [ 1 ] > 3 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 1 ] = 0 ;
pData [ 0 ] + + ;
pData [ 0 ] & = 3 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pSprite - > zvel < 512 ) pSprite - > zvel + = ( g_spriteGravity / 3 ) ; // 52;
if ( pSprite - > xvel > 0 )
pSprite - > xvel - - ;
2006-11-16 03:02:42 +00:00
// else KILLIT(i);
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case GLASSPIECES__STATIC :
// case GLASSPIECES+1:
// case GLASSPIECES+2:
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
A_Fall ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > zvel > 4096 ) pSprite - > zvel = 4096 ;
if ( sectNum < 0 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2020-02-11 09:21:44 +00:00
if ( pSprite - > z = = actor [ spriteNum ] . floorz - ( ACTOR_FLOOR_OFFSET ) & & pData [ 0 ] < 3 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > zvel = - ( ( 3 - pData [ 0 ] ) < < 8 ) - ( krand ( ) & 511 ) ;
if ( sector [ sectNum ] . lotag = = ST_2_UNDERWATER )
pSprite - > zvel > > = 1 ;
pSprite - > xrepeat > > = 1 ;
pSprite - > yrepeat > > = 1 ;
2006-11-16 03:02:42 +00:00
if ( rnd ( 96 ) )
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2016-08-27 01:40:35 +00:00
pData [ 0 ] + + ; //Number of bounces
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pData [ 0 ] = = 3 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel > 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xvel - = 2 ;
pSprite - > cstat = ( ( pSprite - > xvel & 3 ) < < 2 ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else pSprite - > xvel = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
A_SetSprite ( spriteNum , CLIPMASK0 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2020-03-29 08:41:12 +00:00
case FIREFLYFLYINGEFFECT__STATIC :
2020-04-05 06:40:38 +00:00
if ( WORLDTOUR & & G_TileHasActor ( sprite [ spriteNum ] . picnum ) )
2020-03-29 08:41:12 +00:00
{
int playerDist ;
int const playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
A_Execute ( spriteNum , playerNum , playerDist ) ;
spritetype * pPlayer = & sprite [ g_player [ playerNum ] . ps - > i ] ;
spritetype * pOwner = & sprite [ pSprite - > owner ] ;
if ( pOwner - > picnum ! = FIREFLY ) DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
if ( pOwner - > xrepeat < 24 & & pOwner - > pal ! = 1 )
pSprite - > cstat & = ~ 32768 ;
else
pSprite - > cstat | = 32768 ;
float dx = pOwner - > x - pPlayer - > x ;
float dy = pOwner - > y - pPlayer - > y ;
float dn = sqrt ( dx * dx + dy * dy ) ;
if ( dn > 0.f )
{
dx / = dn ;
dy / = dn ;
}
pSprite - > x = pOwner - > x - int ( dx * - 10.f ) ;
pSprite - > y = pOwner - > y - int ( dy * - 10.f ) ;
pSprite - > z = pOwner - > z + 0x800 ;
if ( pOwner - > extra < = 0 ) DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
}
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2020-01-29 11:37:16 +00:00
# endif
}
2006-04-13 20:47:06 +00:00
2018-04-02 22:00:44 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY & & PN ( spriteNum ) > = SCRAP6 & & PN ( spriteNum ) < = SCRAP5 + 3 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel > 0 )
pSprite - > xvel - - ;
else pSprite - > xvel = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > zvel > 1024 & & pSprite - > zvel < 1280 )
2006-04-13 20:47:06 +00:00
{
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2016-08-27 01:40:35 +00:00
sectNum = pSprite - > sectnum ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pSprite - > z < sector [ sectNum ] . floorz - ( 2 < < 8 ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 1 ] < 1 ) pData [ 1 ] + + ;
2006-04-13 20:47:06 +00:00
else
{
2016-08-27 01:40:35 +00:00
pData [ 1 ] = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
if ( pSprite - > picnum < SCRAP6 + 8 )
pData [ 0 ] = ( pData [ 0 ] > 6 ) ? 0 : pData [ 0 ] + 1 ;
2006-04-13 20:47:06 +00:00
else
2016-08-27 01:42:01 +00:00
pData [ 0 ] = ( pData [ 0 ] > 2 ) ? 0 : pData [ 0 ] + 1 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:42:01 +00:00
if ( pSprite - > zvel < 4096 )
pSprite - > zvel + = g_spriteGravity - 50 ;
2016-08-27 01:40:35 +00:00
pSprite - > x + = ( pSprite - > xvel * sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) > > 14 ;
pSprite - > y + = ( pSprite - > xvel * sintable [ pSprite - > ang & 2047 ] ) > > 14 ;
pSprite - > z + = pSprite - > zvel ;
2006-04-13 20:47:06 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > picnum = = SCRAP1 & & pSprite - > yvel > 0 & & pSprite - > yvel < MAXUSERTILES )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
int32_t j = A_Spawn ( spriteNum , pSprite - > yvel ) ;
2013-04-15 10:48:09 +00:00
2019-06-25 11:28:25 +00:00
setsprite ( j , & pSprite - > pos ) ;
2008-11-20 14:06:36 +00:00
A_GetZLimits ( j ) ;
2006-04-13 20:47:06 +00:00
sprite [ j ] . hitag = sprite [ j ] . lotag = 0 ;
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-04-13 20:47:06 +00:00
}
2018-04-02 22:00:44 +00:00
# endif
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
next_sprite :
spriteNum = nextSprite ;
2006-04-13 20:47:06 +00:00
}
}
2012-04-13 10:45:33 +00:00
// i: SE spritenum
2016-08-27 01:42:01 +00:00
static void HandleSE31 ( int spriteNum , int setFloorZ , int spriteZ , int SEdir , int zDifference )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pSprite = & sprite [ spriteNum ] ;
auto const pSector = & sector [ sprite [ spriteNum ] . sectnum ] ;
auto const pData = actor [ spriteNum ] . t_data ;
2012-03-11 17:37:50 +00:00
2016-08-27 01:42:01 +00:00
if ( klabs ( pSector - > floorz - spriteZ ) < SP ( spriteNum ) )
2012-04-13 10:45:33 +00:00
{
2016-08-27 01:42:01 +00:00
if ( setFloorZ )
pSector - > floorz = spriteZ ;
pData [ 2 ] = SEdir ;
pData [ 0 ] = 0 ;
pData [ 3 ] = pSprite - > hitag ;
2013-04-15 10:48:09 +00:00
2017-05-19 02:28:40 +00:00
for ( bssize_t SPRITES_OF_SECT ( pSprite - > sectnum , j ) )
{
if ( sprite [ j ] . zvel = = 0 & & sprite [ j ] . statnum ! = STAT_EFFECTOR & & sprite [ j ] . statnum ! = STAT_PROJECTILE )
{
actor [ j ] . bpos . z = sprite [ j ] . z ;
actor [ j ] . floorz = pSector - > floorz ;
}
}
2016-08-27 01:42:01 +00:00
A_CallSound ( pSprite - > sectnum , spriteNum ) ;
2012-04-13 10:45:33 +00:00
}
else
{
2016-08-27 01:42:01 +00:00
int const zChange = ksgn ( zDifference ) * SP ( spriteNum ) ;
2012-04-13 10:45:33 +00:00
2016-08-27 01:42:01 +00:00
pSector - > floorz + = zChange ;
2012-04-13 10:45:33 +00:00
2016-08-27 01:42:01 +00:00
for ( bssize_t SPRITES_OF_SECT ( pSprite - > sectnum , j ) )
2012-04-13 10:45:33 +00:00
{
if ( sprite [ j ] . picnum = = APLAYER & & sprite [ j ] . owner > = 0 )
2016-08-27 01:42:01 +00:00
{
int const playerNum = P_Get ( j ) ;
if ( g_player [ playerNum ] . ps - > on_ground = = 1 )
g_player [ playerNum ] . ps - > pos . z + = zChange ;
}
2013-04-01 18:35:44 +00:00
2012-04-13 10:45:33 +00:00
if ( sprite [ j ] . zvel = = 0 & & sprite [ j ] . statnum ! = STAT_EFFECTOR & & sprite [ j ] . statnum ! = STAT_PROJECTILE )
{
2017-05-19 02:28:40 +00:00
actor [ j ] . bpos . z = sprite [ j ] . z ;
sprite [ j ] . z + = zChange ;
2016-08-27 01:42:01 +00:00
actor [ j ] . floorz = pSector - > floorz ;
2012-04-13 10:45:33 +00:00
}
}
}
}
// s: SE sprite
2017-06-24 06:31:26 +00:00
static void MaybeTrainKillPlayer ( const spritetype * pSprite , int const setOPos )
2012-04-13 10:45:33 +00:00
{
2016-08-27 01:42:01 +00:00
for ( bssize_t TRAVERSE_CONNECT ( playerNum ) )
2012-08-10 19:11:56 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pPlayer = g_player [ playerNum ] . ps ;
2012-08-10 19:11:56 +00:00
2016-08-27 01:42:01 +00:00
if ( sprite [ pPlayer - > i ] . extra > 0 )
2012-04-13 10:45:33 +00:00
{
2016-08-27 01:42:01 +00:00
int16_t playerSectnum = pPlayer - > cursectnum ;
updatesector ( pPlayer - > pos . x , pPlayer - > pos . y , & playerSectnum ) ;
2012-04-13 10:45:33 +00:00
2017-06-24 06:31:26 +00:00
if ( pPlayer - > cursectnum ! = pSprite - > sectnum & & ( playerSectnum = = - 1 | | playerSectnum = = pSprite - > sectnum ) )
2012-04-13 10:45:33 +00:00
{
2019-08-07 22:43:48 +00:00
pPlayer - > pos . vec2 = pSprite - > pos . vec2 ;
2012-03-11 17:37:50 +00:00
2016-08-27 01:42:01 +00:00
if ( setOPos )
2019-08-07 22:43:48 +00:00
pPlayer - > opos . vec2 = pPlayer - > pos . vec2 ;
2012-04-13 10:45:33 +00:00
2016-08-27 01:42:01 +00:00
pPlayer - > cursectnum = pSprite - > sectnum ;
2012-04-13 10:45:33 +00:00
2016-08-27 01:42:01 +00:00
setsprite ( pPlayer - > i , ( vec3_t const * ) pSprite ) ;
P_QuickKill ( pPlayer ) ;
2012-04-13 10:45:33 +00:00
}
}
2012-08-10 19:11:56 +00:00
}
2012-04-13 10:45:33 +00:00
}
// i: SE spritenum
2017-06-24 06:31:26 +00:00
static void MaybeTrainKillEnemies ( int const spriteNum )
2012-04-13 10:45:33 +00:00
{
2016-08-27 01:42:01 +00:00
int findSprite = headspritesect [ sprite [ OW ( spriteNum ) ] . sectnum ] ;
2012-04-13 10:45:33 +00:00
2017-06-24 06:31:26 +00:00
do
2012-04-13 10:45:33 +00:00
{
2016-08-27 01:42:01 +00:00
int const nextSprite = nextspritesect [ findSprite ] ;
2012-04-13 10:45:33 +00:00
2016-08-27 01:42:01 +00:00
if ( sprite [ findSprite ] . extra > = 0 & & sprite [ findSprite ] . statnum = = STAT_ACTOR & & A_CheckEnemySprite ( & sprite [ findSprite ] ) )
2012-04-13 10:45:33 +00:00
{
2016-08-27 01:42:01 +00:00
int16_t sectNum = sprite [ findSprite ] . sectnum ;
updatesector ( sprite [ findSprite ] . x , sprite [ findSprite ] . y , & sectNum ) ;
2012-04-13 10:45:33 +00:00
2017-06-24 06:31:26 +00:00
if ( sectNum = = sprite [ spriteNum ] . sectnum | | sectNum = = - 1 )
2012-04-13 10:45:33 +00:00
{
2017-06-23 03:58:13 +00:00
actor [ findSprite ] . picnum = RADIUSEXPLOSION ;
2017-06-24 06:31:26 +00:00
actor [ findSprite ] . extra = g_impactDamage < < 10 ;
actor [ findSprite ] . owner = spriteNum ;
2012-04-13 10:45:33 +00:00
}
}
2016-08-27 01:42:01 +00:00
findSprite = nextSprite ;
2012-04-13 10:45:33 +00:00
}
2017-06-24 06:31:26 +00:00
while ( findSprite > = 0 ) ;
2012-04-13 10:45:33 +00:00
}
ACTOR_STATIC void G_MoveEffectors ( void ) //STATNUM 3
{
2016-08-27 01:42:01 +00:00
int32_t q = 0 , j , k , l , m , x ;
int spriteNum = headspritestat [ STAT_EFFECTOR ] ;
2006-04-13 20:47:06 +00:00
2019-06-25 11:27:47 +00:00
# ifndef EDUKE32_STANDALONE
2019-07-19 01:49:29 +00:00
if ( ! FURY )
2018-02-12 02:32:43 +00:00
{
2018-06-09 20:36:47 +00:00
for ( native_t TRAVERSE_CONNECT ( playerNum ) )
{
vec2_t & fric = g_player [ playerNum ] . ps - > fric ;
fric . x = fric . y = 0 ;
}
2018-02-12 02:32:43 +00:00
}
2019-06-25 11:27:47 +00:00
# endif
2016-08-27 01:40:35 +00:00
while ( spriteNum > = 0 )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
int const nextSprite = nextspritestat [ spriteNum ] ;
auto const pSprite = & sprite [ spriteNum ] ;
int32_t playerDist ;
int playerNum = A_FindPlayer ( pSprite , & playerDist ) ;
auto const pPlayer = g_player [ playerNum ] . ps ;
2016-01-21 19:35:25 +00:00
2019-05-19 03:53:25 +00:00
if ( VM_OnEvent ( EVENT_MOVEEFFECTORS , spriteNum , playerNum , playerDist , 0 ) )
2016-01-21 19:35:25 +00:00
{
2016-08-27 01:40:35 +00:00
spriteNum = nextSprite ;
2016-01-21 19:35:25 +00:00
continue ;
}
2016-08-27 01:42:01 +00:00
sectortype * const pSector = & sector [ pSprite - > sectnum ] ;
2017-06-24 21:16:43 +00:00
int const spriteLotag = pSprite - > lotag ;
int const spriteHitag = pSprite - > hitag ;
2016-08-27 01:42:01 +00:00
int32_t * const pData = & actor [ spriteNum ] . t_data [ 0 ] ;
2006-04-13 20:47:06 +00:00
2017-06-24 21:16:43 +00:00
switch ( spriteLotag )
2006-04-13 20:47:06 +00:00
{
2013-06-22 11:31:13 +00:00
case SE_0_ROTATING_SECTOR :
2006-11-16 03:02:42 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t zchange = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
j = pSprite - > owner ;
2006-04-13 20:47:06 +00:00
2018-01-15 23:13:50 +00:00
if ( ( uint16_t ) sprite [ j ] . lotag = = UINT16_MAX )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
q = pSector - > extra > > 3 ;
2006-11-16 03:02:42 +00:00
l = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSector - > lotag = = ST_30_ROTATE_RISE_BRIDGE )
2006-11-16 03:02:42 +00:00
{
q > > = 2 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( sprite [ spriteNum ] . extra = = 1 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( actor [ spriteNum ] . tempang < 256 )
2006-11-13 23:12:47 +00:00
{
2016-08-27 01:40:35 +00:00
actor [ spriteNum ] . tempang + = 4 ;
if ( actor [ spriteNum ] . tempang > = 256 )
A_CallSound ( pSprite - > sectnum , spriteNum ) ;
if ( pSprite - > clipdist ) l = 1 ;
2006-11-16 03:02:42 +00:00
else l = - 1 ;
}
2016-08-27 01:40:35 +00:00
else actor [ spriteNum ] . tempang = 256 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSector - > floorz > pSprite - > z ) //z's are touching
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > floorz - = 512 ;
2006-11-16 03:02:42 +00:00
zchange = - 512 ;
2016-08-27 01:40:35 +00:00
if ( pSector - > floorz < pSprite - > z )
pSector - > floorz = pSprite - > z ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pSector - > floorz < pSprite - > z ) //z's are touching
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > floorz + = 512 ;
2006-11-16 03:02:42 +00:00
zchange = 512 ;
2016-08-27 01:40:35 +00:00
if ( pSector - > floorz > pSprite - > z )
pSector - > floorz = pSprite - > z ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( sprite [ spriteNum ] . extra = = 3 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( actor [ spriteNum ] . tempang > 0 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
actor [ spriteNum ] . tempang - = 4 ;
if ( actor [ spriteNum ] . tempang < = 0 )
A_CallSound ( pSprite - > sectnum , spriteNum ) ;
if ( pSprite - > clipdist ) l = - 1 ;
2006-11-16 03:02:42 +00:00
else l = 1 ;
}
2016-08-27 01:40:35 +00:00
else actor [ spriteNum ] . tempang = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSector - > floorz > T4 ( spriteNum ) ) //z's are touching
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > floorz - = 512 ;
2006-11-16 03:02:42 +00:00
zchange = - 512 ;
2016-08-27 01:40:35 +00:00
if ( pSector - > floorz < T4 ( spriteNum ) )
pSector - > floorz = T4 ( spriteNum ) ;
2006-11-13 23:12:47 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pSector - > floorz < T4 ( spriteNum ) ) //z's are touching
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > floorz + = 512 ;
2006-11-16 03:02:42 +00:00
zchange = 512 ;
2016-08-27 01:40:35 +00:00
if ( pSector - > floorz > T4 ( spriteNum ) )
pSector - > floorz = T4 ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
else
{
2010-05-02 23:27:30 +00:00
if ( actor [ j ] . t_data [ 0 ] = = 0 ) break ;
2016-08-27 01:41:33 +00:00
if ( actor [ j ] . t_data [ 0 ] = = 2 ) DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2017-06-24 21:17:26 +00:00
l = ( sprite [ j ] . ang > 1024 ) ? - 1 : 1 ;
2016-08-27 01:40:35 +00:00
if ( pData [ 3 ] = = 0 )
pData [ 3 ] = ldist ( pSprite , & sprite [ j ] ) ;
pSprite - > xvel = pData [ 3 ] ;
pSprite - > x = sprite [ j ] . x ;
pSprite - > y = sprite [ j ] . y ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
pSprite - > ang + = ( l * q ) ;
pData [ 2 ] + = ( l * q ) ;
2012-05-25 18:39:22 +00:00
2016-08-27 01:40:35 +00:00
if ( l & & ( pSector - > floorstat & 64 ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
for ( TRAVERSE_CONNECT ( playerNum ) )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pPlayer = g_player [ playerNum ] . ps ;
2012-08-10 19:11:56 +00:00
2016-08-27 01:40:35 +00:00
if ( pPlayer - > cursectnum = = pSprite - > sectnum & & pPlayer - > on_ground = = 1 )
2006-04-13 20:47:06 +00:00
{
2018-03-07 04:21:18 +00:00
pPlayer - > q16ang + = fix16_from_int ( l * q ) ;
pPlayer - > q16ang & = 0x7FFFFFF ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pPlayer - > pos . z + = zchange ;
2006-04-13 20:47:06 +00:00
2015-05-26 00:47:54 +00:00
vec2_t r ;
2019-08-07 22:43:48 +00:00
rotatepoint ( sprite [ j ] . pos . vec2 , pPlayer - > pos . vec2 , ( q * l ) , & r ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pPlayer - > bobpos . x + = r . x - pPlayer - > pos . x ;
pPlayer - > bobpos . y + = r . y - pPlayer - > pos . y ;
2006-04-13 20:47:06 +00:00
2019-08-07 22:43:48 +00:00
pPlayer - > pos . vec2 = r ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( sprite [ pPlayer - > i ] . extra < = 0 )
2019-08-07 22:43:48 +00:00
sprite [ pPlayer - > i ] . pos . vec2 = r ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:41:21 +00:00
for ( bssize_t SPRITES_OF_SECT ( pSprite - > sectnum , p ) )
2006-11-16 03:02:42 +00:00
{
2013-04-15 10:48:09 +00:00
// KEEPINSYNC1
if ( sprite [ p ] . statnum ! = STAT_EFFECTOR & & sprite [ p ] . statnum ! = STAT_PROJECTILE )
2006-11-16 03:02:42 +00:00
if ( sprite [ p ] . picnum ! = LASERLINE )
{
if ( sprite [ p ] . picnum = = APLAYER & & sprite [ p ] . owner > = 0 )
continue ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sprite [ p ] . ang + = ( l * q ) ;
sprite [ p ] . ang & = 2047 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sprite [ p ] . z + = zchange ;
2006-04-13 20:47:06 +00:00
2011-06-22 19:12:47 +00:00
// interpolation fix
2019-08-07 22:43:48 +00:00
actor [ p ] . bpos . vec2 = sprite [ p ] . pos . vec2 ;
2011-06-22 19:12:47 +00:00
2016-08-27 01:40:35 +00:00
if ( move_rotfixed_sprite ( p , j , pData [ 2 ] ) )
2019-08-07 22:43:48 +00:00
rotatepoint ( sprite [ j ] . pos . vec2 , sprite [ p ] . pos . vec2 , ( q * l ) , & sprite [ p ] . pos . vec2 ) ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( l = = 0 & & ( pSector - > floorstat & 64 ) )
2011-06-24 11:16:12 +00:00
{
// fix for jittering of sprites in halted rotating sectors
2016-08-27 01:41:21 +00:00
for ( bssize_t SPRITES_OF_SECT ( pSprite - > sectnum , p ) )
2011-06-24 11:16:12 +00:00
{
2013-04-15 10:48:09 +00:00
// KEEPINSYNC1
if ( sprite [ p ] . statnum ! = STAT_EFFECTOR & & sprite [ p ] . statnum ! = STAT_PROJECTILE )
2011-06-24 11:16:12 +00:00
if ( sprite [ p ] . picnum ! = LASERLINE )
{
if ( sprite [ p ] . picnum = = APLAYER & & sprite [ p ] . owner > = 0 )
continue ;
2019-08-07 22:43:48 +00:00
actor [ p ] . bpos . vec2 = sprite [ p ] . pos . vec2 ;
2011-06-24 11:16:12 +00:00
}
}
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
A_MoveSector ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2013-04-15 10:48:09 +00:00
2013-06-22 11:31:13 +00:00
case SE_1_PIVOT : //Nothing for now used as the pivot
2016-08-27 01:40:35 +00:00
if ( pSprite - > owner = = - 1 ) //Init
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > owner = spriteNum ;
2006-04-13 20:47:06 +00:00
2013-04-15 10:48:09 +00:00
for ( SPRITES_OF ( STAT_EFFECTOR , j ) )
2006-04-13 20:47:06 +00:00
{
2017-06-24 21:16:43 +00:00
if ( sprite [ j ] . lotag = = SE_19_EXPLOSION_LOWERS_CEILING & & sprite [ j ] . hitag = = spriteHitag )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = 0 ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-16 03:02:42 +00:00
}
break ;
2013-04-15 10:48:09 +00:00
2017-06-09 06:41:17 +00:00
case SE_6_SUBWAY :
2016-08-27 01:40:35 +00:00
k = pSector - > extra ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 4 ] > 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 4 ] - - ;
if ( pData [ 4 ] > = ( k - ( k > > 3 ) ) )
pSprite - > xvel - = ( k > > 5 ) ;
if ( pData [ 4 ] > ( ( k > > 1 ) - 1 ) & & pData [ 4 ] < ( k - ( k > > 3 ) ) )
pSprite - > xvel = 0 ;
if ( pData [ 4 ] < ( k > > 1 ) )
pSprite - > xvel + = ( k > > 5 ) ;
if ( pData [ 4 ] < ( ( k > > 1 ) - ( k > > 3 ) ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 4 ] = 0 ;
pSprite - > xvel = k ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else pSprite - > xvel = k ;
2006-04-13 20:47:06 +00:00
2013-04-15 10:48:09 +00:00
for ( SPRITES_OF ( STAT_EFFECTOR , j ) )
2006-11-16 03:02:42 +00:00
{
2017-06-24 21:16:43 +00:00
if ( sprite [ j ] . lotag = = SE_14_SUBWAY_CAR & & spriteHitag = = sprite [ j ] . hitag & & actor [ j ] . t_data [ 0 ] = = pData [ 0 ] )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
sprite [ j ] . xvel = pSprite - > xvel ;
2006-11-16 03:02:42 +00:00
// if( t[4] == 1 )
2006-04-13 20:47:06 +00:00
{
2010-05-02 23:27:30 +00:00
if ( actor [ j ] . t_data [ 5 ] = = 0 )
2016-08-27 01:40:35 +00:00
actor [ j ] . t_data [ 5 ] = dist ( & sprite [ j ] , pSprite ) ;
x = ksgn ( dist ( & sprite [ j ] , pSprite ) - actor [ j ] . t_data [ 5 ] ) ;
2006-11-16 03:02:42 +00:00
if ( sprite [ j ] . extra )
x = - x ;
2016-08-27 01:40:35 +00:00
pSprite - > xvel + = x ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
actor [ j ] . t_data [ 4 ] = pData [ 4 ] ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2013-04-15 10:48:09 +00:00
x = 0 ; // XXX: This assignment is dead?
2017-07-18 20:53:41 +00:00
fallthrough__ ;
2006-04-13 20:47:06 +00:00
2012-09-08 22:18:44 +00:00
case SE_14_SUBWAY_CAR :
2016-08-27 01:40:35 +00:00
if ( pSprite - > owner = = - 1 )
pSprite - > owner = A_FindLocator ( ( int16_t ) pData [ 3 ] , ( int16_t ) pData [ 0 ] ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > owner = = - 1 )
2006-11-16 03:02:42 +00:00
{
2011-05-12 23:31:13 +00:00
// debugging subway cars (mapping-wise) is freakin annoying
// let's at least have a helpful message...
Bsprintf ( tempbuf , " Could not find any locators in sector %d "
2016-08-27 01:40:35 +00:00
" for SE# 6 or 14 with hitag %d. \n " , ( int ) pData [ 0 ] , ( int ) pData [ 3 ] ) ;
2008-11-20 14:06:36 +00:00
G_GameExit ( tempbuf ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
j = ldist ( & sprite [ pSprite - > owner ] , pSprite ) ;
2006-11-16 03:02:42 +00:00
if ( j < 1024L )
{
2017-06-24 21:16:43 +00:00
if ( spriteLotag = = SE_6_SUBWAY )
2016-08-27 01:40:35 +00:00
if ( sprite [ pSprite - > owner ] . hitag & 1 )
pData [ 4 ] = pSector - > extra ; //Slow it down
pData [ 3 ] + + ;
pSprite - > owner = A_FindLocator ( pData [ 3 ] , pData [ 0 ] ) ;
if ( pSprite - > owner = = - 1 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 3 ] = 0 ;
pSprite - > owner = A_FindLocator ( 0 , pData [ 0 ] ) ;
2006-11-16 03:02:42 +00:00
}
}
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel )
2006-11-16 03:02:42 +00:00
{
2011-06-26 21:59:42 +00:00
# ifdef YAX_ENABLE
int32_t firstrun = 1 ;
# endif
2016-08-27 01:40:35 +00:00
x = getangle ( sprite [ pSprite - > owner ] . x - pSprite - > x , sprite [ pSprite - > owner ] . y - pSprite - > y ) ;
q = G_GetAngleDelta ( pSprite - > ang , x ) > > 3 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pData [ 2 ] + = q ;
pSprite - > ang + = q ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel = = pSector - > extra )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( ( pSector - > floorstat & 1 ) = = 0 & & ( pSector - > ceilingstat & 1 ) = = 0 )
2006-11-16 03:02:42 +00:00
{
2018-12-15 01:39:25 +00:00
if ( ! S_CheckSoundPlaying ( actor [ spriteNum ] . lastv . x ) )
2017-06-23 03:59:19 +00:00
A_PlaySound ( actor [ spriteNum ] . lastv . x , spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( ud . monsters_off = = 0 & & pSector - > floorpal = = 0 & & ( pSector - > floorstat & 1 ) & & rnd ( 8 ) )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:42:01 +00:00
if ( playerDist < 20480 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
j = pSprite - > ang ;
2016-08-27 01:42:01 +00:00
pSprite - > ang = getangle ( pSprite - > x - g_player [ playerNum ] . ps - > pos . x , pSprite - > y - g_player [ playerNum ] . ps - > pos . y ) ;
2016-08-27 01:40:35 +00:00
A_Shoot ( spriteNum , RPG ) ;
pSprite - > ang = j ;
2006-11-16 03:02:42 +00:00
}
}
}
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel < = 64 & & ( pSector - > floorstat & 1 ) = = 0 & & ( pSector - > ceilingstat & 1 ) = = 0 )
2017-06-23 03:59:19 +00:00
S_StopEnvSound ( actor [ spriteNum ] . lastv . x , spriteNum ) ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( ( pSector - > floorz - pSector - > ceilingz ) < ( 108 < < 8 ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( ud . noclip = = 0 & & pSprite - > xvel > = 192 )
MaybeTrainKillPlayer ( pSprite , 0 ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
m = ( pSprite - > xvel * sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) > > 14 ;
x = ( pSprite - > xvel * sintable [ pSprite - > ang & 2047 ] ) > > 14 ;
2006-04-13 20:47:06 +00:00
2020-04-30 05:11:46 +00:00
if ( sector [ pSprite - > sectnum ] . lotag ! = ST_2_UNDERWATER )
2010-01-23 22:12:02 +00:00
{
2020-05-17 23:55:21 +00:00
// Move player spawns with sector.
for ( int spawnNum = 0 ; spawnNum < g_playerSpawnCnt ; spawnNum + + )
2010-01-23 22:12:02 +00:00
{
2020-05-17 23:55:21 +00:00
if ( g_playerSpawnPoints [ spawnNum ] . sect = = pSprite - > sectnum )
2011-06-26 21:59:42 +00:00
{
2020-05-17 23:55:21 +00:00
g_playerSpawnPoints [ spawnNum ] . pos . x + = m ;
g_playerSpawnPoints [ spawnNum ] . pos . y + = x ;
2011-06-26 21:59:42 +00:00
}
2020-05-17 23:55:21 +00:00
}
2006-11-15 01:16:55 +00:00
2020-05-17 23:55:21 +00:00
for ( TRAVERSE_CONNECT ( playerNum ) )
{
2020-04-30 05:11:46 +00:00
auto const pPlayer = g_player [ playerNum ] . ps ;
// might happen when squished into void space
if ( pPlayer - > cursectnum < 0 )
break ;
2019-10-20 17:55:35 +00:00
if ( pSprite - > sectnum = = pPlayer - > cursectnum
2011-06-26 21:59:42 +00:00
# ifdef YAX_ENABLE
2020-04-30 05:11:46 +00:00
| | ( pData [ 9 ] > = 0 & & pData [ 9 ] = = pPlayer - > cursectnum )
2011-06-26 21:59:42 +00:00
# endif
2020-04-30 05:11:46 +00:00
)
2011-06-26 21:59:42 +00:00
{
2019-08-07 22:43:48 +00:00
rotatepoint ( pSprite - > pos . vec2 , pPlayer - > pos . vec2 , q , & pPlayer - > pos . vec2 ) ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:42:01 +00:00
pPlayer - > pos . x + = m ;
pPlayer - > pos . y + = x ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:42:01 +00:00
pPlayer - > bobpos . x + = m ;
pPlayer - > bobpos . y + = x ;
2006-11-15 01:16:55 +00:00
2018-03-07 04:21:18 +00:00
pPlayer - > q16ang + = fix16_from_int ( q ) ;
pPlayer - > q16ang & = 0x7FFFFFF ;
2011-06-26 21:59:42 +00:00
2016-08-27 01:42:01 +00:00
if ( sprite [ pPlayer - > i ] . extra < = 0 )
2020-04-30 05:11:46 +00:00
sprite [ pPlayer - > i ] . pos . vec2 = pPlayer - > pos . vec2 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2011-06-26 21:59:42 +00:00
2020-04-30 05:11:46 +00:00
// NOTE: special loop handling
j = headspritesect [ pSprite - > sectnum ] ;
while ( j > = 0 )
2006-04-13 20:47:06 +00:00
{
2020-04-30 05:16:01 +00:00
if ( ( sprite [ j ] . picnum ! = SECTOREFFECTOR | | ( sprite [ j ] . lotag = = SE_49_POINT_LIGHT | | sprite [ j ] . lotag = = SE_50_SPOT_LIGHT ) )
2020-04-30 05:11:46 +00:00
& & sprite [ j ] . picnum ! = LOCATORS )
{
if ( move_rotfixed_sprite ( j , pSprite - sprite , pData [ 2 ] ) )
rotatepoint ( pSprite - > pos . vec2 , sprite [ j ] . pos . vec2 , q , & sprite [ j ] . pos . vec2 ) ;
2006-04-13 20:47:06 +00:00
2020-04-30 05:11:46 +00:00
sprite [ j ] . x + = m ;
sprite [ j ] . y + = x ;
2006-04-13 20:47:06 +00:00
2020-04-30 05:11:46 +00:00
sprite [ j ] . ang + = q ;
}
j = nextspritesect [ j ] ;
2011-06-26 21:59:42 +00:00
# ifdef YAX_ENABLE
2020-04-30 05:11:46 +00:00
if ( j < 0 )
2011-06-26 21:59:42 +00:00
{
2020-04-30 05:11:46 +00:00
if ( pData [ 9 ] > = 0 & & firstrun )
{
firstrun = 0 ;
j = headspritesect [ pData [ 9 ] ] ;
}
2011-06-26 21:59:42 +00:00
}
# endif
2020-04-30 05:11:46 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
A_MoveSector ( spriteNum ) ;
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( ( pSector - > floorz - pSector - > ceilingz ) < ( 108 < < 8 ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( ud . noclip = = 0 & & pSprite - > xvel > = 192 )
MaybeTrainKillPlayer ( pSprite , 1 ) ;
2006-04-13 20:47:06 +00:00
2017-06-23 03:58:13 +00:00
MaybeTrainKillEnemies ( spriteNum ) ;
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
break ;
2012-08-26 22:16:08 +00:00
case SE_30_TWO_WAY_TRAIN :
2016-08-27 01:40:35 +00:00
if ( pSprite - > owner = = - 1 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 3 ] = ! pData [ 3 ] ;
pSprite - > owner = A_FindLocator ( pData [ 3 ] , pData [ 0 ] ) ;
2006-11-16 03:02:42 +00:00
}
else
{
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 4 ] = = 1 ) // Starting to go
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( ldist ( & sprite [ pSprite - > owner ] , pSprite ) < ( 2048 - 128 ) )
pData [ 4 ] = 2 ;
2006-11-16 03:02:42 +00:00
else
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel = = 0 )
G_OperateActivators ( pSprite - > hitag + ( ! pData [ 3 ] ) , - 1 ) ;
if ( pSprite - > xvel < 256 )
pSprite - > xvel + = 16 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pData [ 4 ] = = 2 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
l = FindDistance2D ( sprite [ pSprite - > owner ] . x - pSprite - > x , sprite [ pSprite - > owner ] . y - pSprite - > y ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( l < = 128 )
2016-08-27 01:40:35 +00:00
pSprite - > xvel = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel > 0 )
pSprite - > xvel - = 16 ;
2006-11-16 03:02:42 +00:00
else
{
2016-08-27 01:40:35 +00:00
pSprite - > xvel = 0 ;
G_OperateActivators ( pSprite - > hitag + ( int16_t ) pData [ 3 ] , - 1 ) ;
pSprite - > owner = - 1 ;
pSprite - > ang + = 1024 ;
pData [ 4 ] = 0 ;
G_OperateForceFields ( spriteNum , pSprite - > hitag ) ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
for ( SPRITES_OF_SECT ( pSprite - > sectnum , j ) )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( sprite [ j ] . picnum ! = SECTOREFFECTOR & & sprite [ j ] . picnum ! = LOCATORS )
2019-08-07 22:43:48 +00:00
actor [ j ] . bpos . vec2 = sprite [ j ] . pos . vec2 ;
2006-11-15 01:16:55 +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
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
l = ( pSprite - > xvel * sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) > > 14 ;
x = ( pSprite - > xvel * sintable [ pSprite - > ang & 2047 ] ) > > 14 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( ( pSector - > floorz - pSector - > ceilingz ) < ( 108 < < 8 ) )
2012-03-11 17:38:50 +00:00
if ( ud . noclip = = 0 )
2016-08-27 01:40:35 +00:00
MaybeTrainKillPlayer ( pSprite , 0 ) ;
2006-04-13 20:47:06 +00:00
2020-05-17 23:55:21 +00:00
// Move player spawns with sector.
for ( int spawnNum = 0 ; spawnNum < g_playerSpawnCnt ; spawnNum + + )
{
if ( g_playerSpawnPoints [ spawnNum ] . sect = = pSprite - > sectnum )
{
g_playerSpawnPoints [ spawnNum ] . pos . x + = l ;
g_playerSpawnPoints [ spawnNum ] . pos . y + = x ;
}
}
2017-06-24 21:17:26 +00:00
for ( int TRAVERSE_CONNECT ( playerNum ) )
2006-11-16 03:02:42 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pPlayer = g_player [ playerNum ] . ps ;
2012-08-10 19:11:56 +00:00
2019-10-20 17:55:35 +00:00
if ( pPlayer - > cursectnum = = pSprite - > sectnum )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:46 +00:00
pPlayer - > pos . x + = l ;
pPlayer - > pos . y + = x ;
2006-11-15 01:16:55 +00:00
2010-01-16 23:08:17 +00:00
if ( g_netServer | | numplayers > 1 )
2019-10-20 17:55:24 +00:00
pPlayer - > opos . vec2 = pPlayer - > pos . vec2 ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:41:46 +00:00
pPlayer - > bobpos . x + = l ;
pPlayer - > bobpos . y + = x ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
for ( SPRITES_OF_SECT ( pSprite - > sectnum , j ) )
2006-11-16 03:02:42 +00:00
{
2013-04-15 10:48:09 +00:00
// TODO: replace some checks for SE 49/50 with statnum LIGHT instead?
2012-10-05 20:48:10 +00:00
if ( ( sprite [ j ] . picnum ! = SECTOREFFECTOR | | sprite [ j ] . lotag = = SE_49_POINT_LIGHT | | sprite [ j ] . lotag = = SE_50_SPOT_LIGHT )
2012-04-28 21:56:23 +00:00
& & sprite [ j ] . picnum ! = LOCATORS )
2006-04-13 20:47:06 +00:00
{
2010-01-16 23:08:17 +00:00
if ( numplayers < 2 & & ! g_netServer )
2019-08-07 22:43:48 +00:00
actor [ j ] . bpos . vec2 = sprite [ j ] . pos . vec2 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
sprite [ j ] . x + = l ;
sprite [ j ] . y + = x ;
2006-04-13 20:47:06 +00:00
2010-01-16 23:08:17 +00:00
if ( g_netServer | | numplayers > 1 )
2019-08-07 22:43:48 +00:00
actor [ j ] . bpos . vec2 = sprite [ j ] . pos . vec2 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
A_MoveSector ( spriteNum ) ;
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSector - > floorz - pSector - > ceilingz < ( 108 < < 8 ) )
2006-11-16 03:02:42 +00:00
{
2012-03-11 17:38:50 +00:00
if ( ud . noclip = = 0 )
2016-08-27 01:40:35 +00:00
MaybeTrainKillPlayer ( pSprite , 1 ) ;
2006-04-13 20:47:06 +00:00
2017-06-23 03:58:13 +00:00
MaybeTrainKillEnemies ( spriteNum ) ;
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
break ;
2006-04-13 20:47:06 +00:00
2013-06-22 11:31:13 +00:00
case SE_2_EARTHQUAKE : //Quakes
2016-08-27 01:40:35 +00:00
if ( pData [ 4 ] > 0 & & pData [ 0 ] = = 0 )
2006-11-16 03:02:42 +00:00
{
2017-06-24 21:16:43 +00:00
if ( pData [ 4 ] < spriteHitag )
2016-08-27 01:40:35 +00:00
pData [ 4 ] + + ;
else pData [ 0 ] = 1 ;
2006-11-16 03:02:42 +00:00
}
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] > 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] + + ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > xvel = 3 ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] > 96 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = - 1 ; //Stop the quake
pData [ 4 ] = - 1 ;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
if ( ( pData [ 0 ] & 31 ) = = 8 )
2006-11-15 01:16:55 +00:00
{
2008-11-20 14:06:36 +00:00
g_earthquakeTime = 48 ;
A_PlaySound ( EARTHQUAKE , g_player [ screenpeek ] . ps - > i ) ;
2006-11-15 01:16:55 +00:00
}
2016-08-27 01:42:01 +00:00
pSector - > floorheinum = ( klabs ( pSector - > floorheinum - pData [ 5 ] ) < 8 )
? pData [ 5 ]
: pSector - > floorheinum + ( ksgn ( pData [ 5 ] - pSector - > floorheinum ) < < 4 ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
vec2_t const vect = { ( pSprite - > xvel * sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) > > 14 ,
( pSprite - > xvel * sintable [ pSprite - > ang & 2047 ] ) > > 14 } ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
for ( TRAVERSE_CONNECT ( playerNum ) )
2012-08-10 19:11:56 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pPlayer = g_player [ playerNum ] . ps ;
2012-08-10 19:11:56 +00:00
2016-08-27 01:42:01 +00:00
if ( pPlayer - > cursectnum = = pSprite - > sectnum & & pPlayer - > on_ground )
2012-02-21 19:33:33 +00:00
{
2016-08-27 01:42:01 +00:00
pPlayer - > pos . x + = vect . x ;
pPlayer - > pos . y + = vect . y ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:42:01 +00:00
pPlayer - > bobpos . x + = vect . x ;
pPlayer - > bobpos . y + = vect . y ;
2012-02-21 19:33:33 +00:00
}
2012-08-10 19:11:56 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
for ( bssize_t nextSprite , SPRITES_OF_SECT_SAFE ( pSprite - > sectnum , sectSprite , nextSprite ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
if ( sprite [ sectSprite ] . picnum ! = SECTOREFFECTOR )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
sprite [ sectSprite ] . x + = vect . x ;
sprite [ sectSprite ] . y + = vect . y ;
2019-08-13 14:44:00 +00:00
setsprite ( sectSprite , & sprite [ sectSprite ] . pos ) ;
2006-04-13 20:47:06 +00:00
}
2006-11-15 01:16:55 +00:00
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
A_MoveSector ( spriteNum ) ;
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
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
//Flashing sector lights after reactor EXPLOSION2
2006-04-13 20:47:06 +00:00
2013-06-22 11:31:13 +00:00
case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT :
2012-08-10 19:11:56 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 4 ] = = 0 ) break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
// if(t[5] > 0) { t[5]--; break; }
2006-04-13 20:47:06 +00:00
2017-06-24 21:16:43 +00:00
if ( ( tabledivide32_noinline ( g_globalRandom , spriteHitag + 1 ) & 31 ) < 4 & & ! pData [ 2 ] )
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
// t[5] = 4+(g_globalRandom&7);
2016-08-27 01:42:01 +00:00
pSector - > ceilingpal = pSprite - > owner > > 8 ;
pSector - > floorpal = pSprite - > owner & 0xff ;
pData [ 0 ] = pSprite - > shade + ( g_globalRandom & 15 ) ;
2006-11-16 03:02:42 +00:00
}
else
{
2008-11-20 14:06:36 +00:00
// t[5] = 4+(g_globalRandom&3);
2016-08-27 01:40:35 +00:00
pSector - > ceilingpal = pSprite - > pal ;
2016-08-27 01:42:01 +00:00
pSector - > floorpal = pSprite - > pal ;
pData [ 0 ] = pData [ 3 ] ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSector - > ceilingshade = pData [ 0 ] ;
2016-08-27 01:42:01 +00:00
pSector - > floorshade = pData [ 0 ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
walltype * pWall = & wall [ pSector - > wallptr ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
for ( x = pSector - > wallnum ; x > 0 ; x - - , pWall + + )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pWall - > hitag ! = 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pWall - > shade = pData [ 0 ] ;
2016-08-27 01:42:01 +00:00
if ( ( pWall - > cstat & 2 ) & & pWall - > nextwall > = 0 )
2016-08-27 01:40:35 +00:00
wall [ pWall - > nextwall ] . shade = pWall - > shade ;
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
break ;
2012-08-10 19:11:56 +00:00
}
2006-04-13 20:47:06 +00:00
2013-06-22 11:31:13 +00:00
case SE_4_RANDOM_LIGHTS :
2015-04-18 21:59:17 +00:00
{
// See A_Spawn():
// s->owner: original ((ceilingpal<<8) | floorpal)
// t[2]: original floor shade
// t[3]: max wall shade
2016-08-27 01:42:01 +00:00
int lightFlag ;
2006-04-13 20:47:06 +00:00
2017-06-24 21:16:43 +00:00
if ( ( tabledivide32_noinline ( g_globalRandom , spriteHitag + 1 ) & 31 ) < 4 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
pData [ 1 ] = pSprite - > shade + ( g_globalRandom & 15 ) ; // Got really bright
pData [ 0 ] = pSprite - > shade + ( g_globalRandom & 15 ) ;
pSector - > ceilingpal = pSprite - > owner > > 8 ;
pSector - > floorpal = pSprite - > owner & 0xff ;
lightFlag = 1 ;
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
pData [ 1 ] = pData [ 2 ] ;
pData [ 0 ] = pData [ 3 ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSector - > ceilingpal = pSprite - > pal ;
2016-08-27 01:42:01 +00:00
pSector - > floorpal = pSprite - > pal ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
lightFlag = 0 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSector - > floorshade = pData [ 1 ] ;
pSector - > ceilingshade = pData [ 1 ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
walltype * pWall = & wall [ pSector - > wallptr ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
for ( x = pSector - > wallnum ; x > 0 ; x - - , pWall + + )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
if ( lightFlag ) pWall - > pal = ( pSprite - > owner & 0xff ) ;
2016-08-27 01:40:35 +00:00
else pWall - > pal = pSprite - > pal ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
if ( pWall - > hitag ! = 1 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pWall - > shade = pData [ 0 ] ;
if ( ( pWall - > cstat & 2 ) & & pWall - > nextwall > = 0 )
wall [ pWall - > nextwall ] . shade = pWall - > shade ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
for ( bssize_t SPRITES_OF_SECT ( SECT ( spriteNum ) , sectSprite ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
if ( sprite [ sectSprite ] . cstat & 16 & & A_CheckSpriteFlags ( sectSprite , SFLAG_NOSHADE ) = = 0 )
sprite [ sectSprite ] . shade = ( pSector - > ceilingstat & 1 ) ? pSector - > ceilingshade : pSector - > floorshade ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 4 ] )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2015-04-18 21:59:17 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
//BOSS
2013-06-22 11:31:13 +00:00
case SE_5 :
2012-08-10 19:11:56 +00:00
{
2016-08-27 01:42:01 +00:00
if ( playerDist < 8192 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
int const saveAng = pSprite - > ang ;
pSprite - > ang = getangle ( pSprite - > x - pPlayer - > pos . x , pSprite - > y - pPlayer - > pos . y ) ;
A_Shoot ( spriteNum , FIRELASER ) ;
pSprite - > ang = saveAng ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > owner = = - 1 ) //Start search
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
pData [ 4 ] = 0 ;
int closestLocatorDist = INT32_MAX ;
int closestLocator = pSprite - > owner ;
//Find the shortest dist
do
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
pSprite - > owner = A_FindLocator ( ( int16_t ) pData [ 4 ] , - 1 ) ; // t[0] hold sectnum
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
if ( pSprite - > owner = = - 1 )
break ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
int const locatorDist = ldist ( & sprite [ pPlayer - > i ] , & sprite [ pSprite - > owner ] ) ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:42:01 +00:00
if ( closestLocatorDist > locatorDist )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
closestLocator = pSprite - > owner ;
closestLocatorDist = locatorDist ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
pData [ 4 ] + + ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:42:01 +00:00
while ( 1 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
pSprite - > owner = closestLocator ;
pSprite - > zvel = ksgn ( sprite [ closestLocator ] . z - pSprite - > z ) < < 4 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( ldist ( & sprite [ pSprite - > owner ] , pSprite ) < 1024 )
2006-11-16 03:02:42 +00:00
{
2018-10-10 19:15:38 +00:00
pSprite - > owner = - 1 ;
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else pSprite - > xvel = 256 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
int const angInc = G_GetAngleDelta ( pSprite - > ang , getangle ( sprite [ pSprite - > owner ] . x - pSprite - > x ,
sprite [ pSprite - > owner ] . y - pSprite - > y ) ) > > 3 ;
pSprite - > ang + = angInc ;
2006-11-16 03:02:42 +00:00
if ( rnd ( 32 ) )
{
2016-08-27 01:42:01 +00:00
pData [ 2 ] + = angInc ;
2016-08-27 01:40:35 +00:00
pSector - > ceilingshade = 127 ;
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:42:01 +00:00
pData [ 2 ] + = G_GetAngleDelta ( pData [ 2 ] + 512 , getangle ( pPlayer - > pos . x - pSprite - > x , pPlayer - > pos . y - pSprite - > y ) ) > > 2 ;
2016-08-27 01:40:35 +00:00
pSector - > ceilingshade = 0 ;
2006-11-16 03:02:42 +00:00
}
2011-02-25 21:50:19 +00:00
2016-08-27 01:40:35 +00:00
if ( A_IncurDamage ( spriteNum ) > = 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( + + pData [ 3 ] = = 5 )
2007-08-25 01:05:00 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > zvel + = 1024 ;
2011-02-25 21:50:19 +00:00
P_DoQuote ( QUOTE_WASTED , g_player [ myconnectindex ] . ps ) ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:42:01 +00:00
pSprite - > z + = pSprite - > zvel ;
pSector - > ceilingz + = pSprite - > zvel ;
2016-08-27 01:40:35 +00:00
sector [ pData [ 0 ] ] . ceilingz + = pSprite - > zvel ;
2016-08-27 01:42:01 +00:00
2016-08-27 01:40:35 +00:00
A_MoveSector ( spriteNum ) ;
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2006-11-16 03:02:42 +00:00
break ;
2012-08-10 19:11:56 +00:00
}
2006-04-13 20:47:06 +00:00
2012-09-08 22:18:44 +00:00
case SE_8_UP_OPEN_DOOR_LIGHTS :
case SE_9_DOWN_OPEN_DOOR_LIGHTS :
2016-08-27 01:42:01 +00:00
{
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
// work only if its moving
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
int animGoal = - 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( actor [ spriteNum ] . t_data [ 4 ] )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
if ( + + actor [ spriteNum ] . t_data [ 4 ] > 8 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2016-08-27 01:42:01 +00:00
animGoal = 1 ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:42:01 +00:00
else animGoal = GetAnimationGoal ( & pSector - > ceilingz ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
if ( animGoal > = 0 )
2006-11-16 03:02:42 +00:00
{
2018-01-28 04:30:42 +00:00
int shadeInc = ( ( pSector - > lotag & 0x8000u ) | | actor [ spriteNum ] . t_data [ 4 ] ) ? - pData [ 3 ] : pData [ 3 ] ;
2006-04-13 20:47:06 +00:00
2017-06-24 21:16:43 +00:00
if ( spriteLotag = = SE_9_DOWN_OPEN_DOOR_LIGHTS )
2016-08-27 01:42:01 +00:00
shadeInc = - shadeInc ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
for ( bssize_t SPRITES_OF ( STAT_EFFECTOR , sectorEffector ) )
2006-11-16 03:02:42 +00:00
{
2017-06-24 21:16:43 +00:00
if ( sprite [ sectorEffector ] . lotag = = spriteLotag & & sprite [ sectorEffector ] . hitag = = spriteHitag )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:42:01 +00:00
int const sectNum = sprite [ sectorEffector ] . sectnum ;
int const spriteShade = sprite [ sectorEffector ] . shade ;
2014-05-30 19:39:06 +00:00
2016-08-27 01:42:01 +00:00
walltype * pWall = & wall [ sector [ sectNum ] . wallptr ] ;
2006-04-13 20:47:06 +00:00
2019-05-19 03:56:13 +00:00
for ( int l = sector [ sectNum ] . wallnum ; l > 0 ; l - - , pWall + + )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
if ( pWall - > hitag = = 1 )
continue ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
pWall - > shade + = shadeInc ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
if ( pWall - > shade < spriteShade )
pWall - > shade = spriteShade ;
else if ( pWall - > shade > actor [ sectorEffector ] . t_data [ 2 ] )
pWall - > shade = actor [ sectorEffector ] . t_data [ 2 ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
if ( pWall - > nextwall > = 0 & & wall [ pWall - > nextwall ] . hitag ! = 1 )
wall [ pWall - > nextwall ] . shade = pWall - > shade ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
sector [ sectNum ] . floorshade + = shadeInc ;
sector [ sectNum ] . ceilingshade + = shadeInc ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
if ( sector [ sectNum ] . floorshade < spriteShade )
sector [ sectNum ] . floorshade = spriteShade ;
else if ( sector [ sectNum ] . floorshade > actor [ sectorEffector ] . t_data [ 0 ] )
sector [ sectNum ] . floorshade = actor [ sectorEffector ] . t_data [ 0 ] ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
if ( sector [ sectNum ] . ceilingshade < spriteShade )
sector [ sectNum ] . ceilingshade = spriteShade ;
else if ( sector [ sectNum ] . ceilingshade > actor [ sectorEffector ] . t_data [ 1 ] )
sector [ sectNum ] . ceilingshade = actor [ sectorEffector ] . t_data [ 1 ] ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-16 03:02:42 +00:00
}
break ;
2016-08-27 01:42:01 +00:00
}
2006-04-13 20:47:06 +00:00
2012-09-08 22:18:44 +00:00
case SE_10_DOOR_AUTO_CLOSE :
// XXX: 32791, what the hell?
2018-01-28 04:30:42 +00:00
if ( ( pSector - > lotag & 0xff ) = = ST_27_STRETCH_BRIDGE | | ( pSector - > floorz > pSector - > ceilingz & & ( pSector - > lotag & 0xff ) ! = ST_23_SWINGING_DOOR ) | | pSector - > lotag = = ( int16_t ) 32791u )
2006-11-16 03:02:42 +00:00
{
j = 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( ( pSector - > lotag & 0xff ) ! = ST_27_STRETCH_BRIDGE )
2016-08-27 01:42:01 +00:00
for ( bssize_t TRAVERSE_CONNECT ( playerNum ) )
if ( pSector - > lotag ! = ST_30_ROTATE_RISE_BRIDGE & & pSector - > lotag ! = ST_31_TWO_WAY_TRAIN & & pSector - > lotag ! = 0
2019-10-20 17:55:35 +00:00
& & pSprite - > sectnum = = pPlayer - > cursectnum )
2016-08-27 01:42:01 +00:00
j = 0 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
if ( j = = 1 )
2006-11-15 01:16:55 +00:00
{
2017-06-24 21:16:43 +00:00
if ( pData [ 0 ] > spriteHitag )
2016-08-27 01:40:35 +00:00
switch ( sector [ pSprite - > sectnum ] . lotag )
2006-11-16 03:02:42 +00:00
{
2012-08-26 22:16:08 +00:00
case ST_20_CEILING_DOOR :
case ST_21_FLOOR_DOOR :
case ST_22_SPLITTING_DOOR :
case ST_26_SPLITTING_ST_DOOR :
2016-08-27 01:40:35 +00:00
if ( GetAnimationGoal ( & sector [ pSprite - > sectnum ] . ceilingz ) > = 0 )
2006-11-16 03:02:42 +00:00
break ;
2017-07-18 20:53:41 +00:00
fallthrough__ ;
2006-11-16 03:02:42 +00:00
default :
2016-08-27 01:40:35 +00:00
G_ActivateBySector ( pSprite - > sectnum , spriteNum ) ;
pData [ 0 ] = 0 ;
2006-11-16 03:02:42 +00:00
break ;
}
2016-08-27 01:40:35 +00:00
else pData [ 0 ] + + ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else pData [ 0 ] = 0 ;
2006-11-16 03:02:42 +00:00
break ;
2013-04-15 10:48:09 +00:00
2012-09-08 22:18:44 +00:00
case SE_11_SWINGING_DOOR : //Swingdoor
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 5 ] > 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 5 ] - - ;
2006-11-16 03:02:42 +00:00
break ;
}
2016-08-27 01:40:35 +00:00
if ( pData [ 4 ] )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
int const endWall = pSector - > wallptr + pSector - > wallnum ;
2007-03-01 00:50:59 +00:00
2016-08-27 01:42:01 +00:00
for ( j = pSector - > wallptr ; j < endWall ; j + + )
2006-11-16 03:02:42 +00:00
{
2013-04-15 10:48:09 +00:00
for ( SPRITES_OF ( STAT_ACTOR , k ) )
2006-04-13 20:47:06 +00:00
{
2019-04-05 17:45:22 +00:00
if ( sprite [ k ] . extra > 0 & &
( pSprite - > sectnum = = sprite [ k ] . sectnum | |
sectoradjacent ( pSprite - > sectnum , sprite [ k ] . sectnum ) ) & &
A_CheckEnemySprite ( & sprite [ k ] ) & &
2019-08-07 22:43:48 +00:00
clipinsidebox ( & sprite [ k ] . pos . vec2 , j , 256 ) = = 1 )
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-11-16 03:02:42 +00:00
}
2018-05-22 10:01:17 +00:00
}
2006-04-13 20:47:06 +00:00
2018-05-22 10:01:17 +00:00
l = ( SP ( spriteNum ) > > 3 ) * pData [ 3 ] ;
pData [ 2 ] + = l ;
pData [ 4 ] + = l ;
A_MoveSector ( spriteNum ) ;
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2018-05-22 10:01:17 +00:00
for ( j = pSector - > wallptr ; j < endWall ; j + + )
{
2013-04-15 10:48:09 +00:00
for ( SPRITES_OF ( STAT_PLAYER , k ) )
2006-11-16 03:02:42 +00:00
{
2019-08-07 22:43:48 +00:00
if ( sprite [ k ] . owner > = 0 & & clipinsidebox ( & sprite [ k ] . pos . vec2 , j , pPlayer - > clipdist ) )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:42:01 +00:00
pData [ 5 ] = 8 ; // Delay
2018-05-22 10:01:17 +00:00
pData [ 2 ] - = l ;
pData [ 4 ] - = l ;
A_MoveSector ( spriteNum ) ;
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2016-08-27 01:40:35 +00:00
goto next_sprite ;
2006-11-15 01:16:55 +00:00
}
}
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pData [ 4 ] < = - 511 | | pData [ 4 ] > = 512 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 4 ] = 0 ;
pData [ 2 ] & = 0xffffff00 ;
A_MoveSector ( spriteNum ) ;
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2006-11-16 03:02:42 +00:00
break ;
}
}
break ;
2013-04-15 10:48:09 +00:00
2012-09-08 22:18:44 +00:00
case SE_12_LIGHT_SWITCH :
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 3 | | pData [ 3 ] = = 1 ) //Lights going off
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
pSector - > floorpal = 0 ;
2016-08-27 01:40:35 +00:00
pSector - > ceilingpal = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
walltype * pWall = & wall [ pSector - > wallptr ] ;
2016-08-27 01:42:01 +00:00
2016-08-27 01:40:35 +00:00
for ( j = pSector - > wallnum ; j > 0 ; j - - , pWall + + )
2016-08-27 01:42:01 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pWall - > hitag ! = 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pWall - > shade = pData [ 1 ] ;
2016-08-27 01:42:01 +00:00
pWall - > pal = 0 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:42:01 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
pSector - > floorshade = pData [ 1 ] ;
2016-08-27 01:40:35 +00:00
pSector - > ceilingshade = pData [ 2 ] ;
2016-08-27 01:42:01 +00:00
pData [ 0 ] = 0 ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
for ( SPRITES_OF_SECT ( SECT ( spriteNum ) , j ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
if ( ( sprite [ j ] . cstat & 16 ) & & ( A_CheckSpriteFlags ( j , SFLAG_NOSHADE ) = = 0 ) )
sprite [ j ] . shade = ( pSector - > ceilingstat & 1 ) ? pSector - > ceilingshade : pSector - > floorshade ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pData [ 3 ] = = 1 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:42:01 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 1 ) //Lights flickering on
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSector - > floorshade > pSprite - > shade )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
pSector - > floorpal = pSprite - > pal ;
2016-08-27 01:40:35 +00:00
pSector - > ceilingpal = pSprite - > pal ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
pSector - > floorshade - = 2 ;
2016-08-27 01:40:35 +00:00
pSector - > ceilingshade - = 2 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
walltype * pWall = & wall [ pSector - > wallptr ] ;
2016-08-27 01:42:01 +00:00
for ( j = pSector - > wallnum ; j > 0 ; j - - , pWall + + )
{
2016-08-27 01:40:35 +00:00
if ( pWall - > hitag ! = 1 )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
pWall - > pal = pSprite - > pal ;
pWall - > shade - = 2 ;
2006-11-15 01:16:55 +00:00
}
2016-08-27 01:42:01 +00:00
}
2006-11-15 01:16:55 +00:00
}
2016-08-27 01:40:35 +00:00
else pData [ 0 ] = 2 ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
for ( SPRITES_OF_SECT ( SECT ( spriteNum ) , j ) )
2006-11-15 01:16:55 +00:00
{
2018-10-10 19:15:38 +00:00
if ( ( sprite [ j ] . cstat & 16 ) & & ( A_CheckSpriteFlags ( j , SFLAG_NOSHADE ) = = 0 ) )
sprite [ j ] . shade = ( pSector - > ceilingstat & 1 ) ? pSector - > ceilingshade : pSector - > floorshade ;
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
2012-09-08 22:18:44 +00:00
case SE_13_EXPLOSIVE :
2016-08-27 01:40:35 +00:00
if ( pData [ 2 ] )
2006-11-16 03:02:42 +00:00
{
2011-06-26 21:59:42 +00:00
// t[0]: ceiling z
// t[1]: floor z
// s->owner: 1 if affect ceiling, 0 if affect floor
// t[3]: 1 if ceiling was parallaxed at premap, 0 else
2016-08-27 01:40:35 +00:00
j = ( SP ( spriteNum ) < < 5 ) | 1 ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > ang = = 512 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > owner )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:42:01 +00:00
pSector - > ceilingz = ( klabs ( pData [ 0 ] - pSector - > ceilingz ) > = j )
? pSector - > ceilingz + ksgn ( pData [ 0 ] - pSector - > ceilingz ) * j
: pData [ 0 ] ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
else
{
2016-08-27 01:42:01 +00:00
pSector - > floorz = ( klabs ( pData [ 1 ] - pSector - > floorz ) > = j )
? pSector - > floorz + ksgn ( pData [ 1 ] - pSector - > floorz ) * j
: pData [ 1 ] ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:42:01 +00:00
pSector - > floorz = ( klabs ( pData [ 1 ] - pSector - > floorz ) > = j )
? pSector - > floorz + ksgn ( pData [ 1 ] - pSector - > floorz ) * j
: pData [ 1 ] ;
pSector - > ceilingz = ( klabs ( pData [ 0 ] - pSector - > ceilingz ) > = j )
? pSector - > ceilingz + ksgn ( pData [ 0 ] - pSector - > ceilingz ) * j
: pData [ 0 ] ;
2006-11-16 03:02:42 +00:00
}
2011-06-26 21:59:42 +00:00
# ifdef YAX_ENABLE
2016-08-27 01:40:35 +00:00
if ( pSprite - > ang = = 512 )
2011-06-26 21:59:42 +00:00
{
2016-08-27 01:40:35 +00:00
int16_t cf = ! pSprite - > owner , bn = yax_getbunch ( pSector - sector , cf ) ;
int32_t jj , daz = SECTORFLD ( pSector - sector , z , cf ) ;
2006-04-13 20:47:06 +00:00
2011-06-26 21:59:42 +00:00
if ( bn > = 0 )
{
for ( SECTORS_OF_BUNCH ( bn , cf , jj ) )
{
SECTORFLD ( jj , z , cf ) = daz ;
SECTORFLD ( jj , stat , cf ) & = ~ ( 128 + 256 + 512 + 2048 ) ;
}
for ( SECTORS_OF_BUNCH ( bn , ! cf , jj ) )
{
SECTORFLD ( jj , z , ! cf ) = daz ;
SECTORFLD ( jj , stat , ! cf ) & = ~ ( 128 + 256 + 512 + 2048 ) ;
}
}
}
# endif
2016-08-27 01:40:35 +00:00
if ( pData [ 3 ] = = 1 )
2006-11-16 03:02:42 +00:00
{
//Change the shades
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pData [ 3 ] + + ;
pSector - > ceilingstat ^ = 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > ang = = 512 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
walltype * pWall = & wall [ pSector - > wallptr ] ;
2016-08-27 01:42:01 +00:00
for ( j = pSector - > wallnum ; j > 0 ; j - - , pWall + + )
2016-08-27 01:40:35 +00:00
pWall - > shade = pSprite - > shade ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
pSector - > floorshade = pSprite - > shade ;
2006-11-15 01:16:55 +00:00
2018-11-18 18:07:38 +00:00
if ( g_player [ 0 ] . ps - > parallax_sectnum > = 0 )
2006-11-16 03:02:42 +00:00
{
2018-11-18 18:07:38 +00:00
pSector - > ceilingpicnum = sector [ g_player [ 0 ] . ps - > parallax_sectnum ] . ceilingpicnum ;
pSector - > ceilingshade = sector [ g_player [ 0 ] . ps - > parallax_sectnum ] . ceilingshade ;
2006-04-13 20:47:06 +00:00
}
}
}
2016-08-27 01:42:01 +00:00
2020-03-12 00:58:28 +00:00
for ( int SPRITES_OF_SECT ( pSprite - > sectnum , p ) )
if ( sprite [ p ] . statnum > = STAT_DEFAULT & & sprite [ p ] . statnum < = STAT_ZOMBIEACTOR )
A_GetZLimits ( p ) ;
2016-08-27 01:42:01 +00:00
if ( + + pData [ 2 ] > 256 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2018-06-09 20:36:31 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( ! FURY & & pData [ 2 ] = = 4 & & pSprite - > ang ! = 512 )
2016-08-27 01:40:35 +00:00
for ( x = 0 ; x < 7 ; x + + ) RANDOMSCRAP ( pSprite , spriteNum ) ;
2018-06-09 20:36:31 +00:00
# endif
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
2012-09-08 22:18:44 +00:00
case SE_15_SLIDING_DOOR :
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 4 ] )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > xvel = 16 ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 4 ] = = 1 ) //Opening
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 3 ] > = ( SP ( spriteNum ) > > 3 ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 4 ] = 0 ; //Turn off the sliders
A_CallSound ( pSprite - > sectnum , spriteNum ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
pData [ 3 ] + + ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pData [ 4 ] = = 2 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 3 ] < 1 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 4 ] = 0 ;
A_CallSound ( pSprite - > sectnum , spriteNum ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
pData [ 3 ] - - ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
A_MoveSector ( spriteNum ) ;
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2012-08-26 22:16:08 +00:00
case SE_16_REACTOR : //Reactor
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pData [ 2 ] + = 32 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
if ( pSector - > floorz < pSector - > ceilingz )
pSprite - > shade = 0 ;
2016-08-27 01:40:35 +00:00
else if ( pSector - > ceilingz < pData [ 3 ] )
2006-11-16 03:02:42 +00:00
{
//The following code check to see if
//there is any other sprites in the sector.
//If there isn't, then kill this sectoreffector
//itself.....
2016-08-27 01:40:35 +00:00
for ( SPRITES_OF_SECT ( pSprite - > sectnum , j ) )
2006-11-16 03:02:42 +00:00
{
if ( sprite [ j ] . picnum = = REACTOR | | sprite [ j ] . picnum = = REACTOR2 )
break ;
}
2013-04-15 10:48:09 +00:00
2006-11-16 03:02:42 +00:00
if ( j = = - 1 )
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > shade = 1 ;
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
pSector - > ceilingz = ( pSprite - > shade )
? pSector - > ceilingz + 1024
: pSector - > ceilingz - 512 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
A_MoveSector ( spriteNum ) ;
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
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
2012-08-26 22:16:08 +00:00
case SE_17_WARP_ELEVATOR :
2012-08-10 19:11:56 +00:00
{
2016-08-27 01:40:35 +00:00
q = pData [ 0 ] * ( SP ( spriteNum ) < < 2 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
pSector - > ceilingz + = q ;
pSector - > floorz + = q ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
for ( SPRITES_OF_SECT ( pSprite - > sectnum , j ) )
2006-11-16 03:02:42 +00:00
{
2009-08-06 10:12:13 +00:00
if ( sprite [ j ] . statnum = = STAT_PLAYER & & sprite [ j ] . owner > = 0 )
2006-04-13 20:47:06 +00:00
{
2019-07-08 00:41:25 +00:00
int const warpPlayer = P_Get ( j ) ;
auto const pPlayer = g_player [ warpPlayer ] . ps ;
2012-08-10 19:11:56 +00:00
2010-01-16 23:08:17 +00:00
if ( numplayers < 2 & & ! g_netServer )
2016-08-27 01:42:01 +00:00
pPlayer - > opos . z = pPlayer - > pos . z ;
2015-10-20 07:15:21 +00:00
2016-08-27 01:42:01 +00:00
pPlayer - > pos . z + = q ;
pPlayer - > truefz + = q ;
pPlayer - > truecz + = q ;
2015-10-20 07:15:21 +00:00
2010-01-16 23:08:17 +00:00
if ( g_netServer | | numplayers > 1 )
2016-08-27 01:42:01 +00:00
pPlayer - > opos . z = pPlayer - > pos . z ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:42:01 +00:00
2009-08-06 10:12:13 +00:00
if ( sprite [ j ] . statnum ! = STAT_EFFECTOR )
2006-11-16 03:02:42 +00:00
{
2012-12-23 14:00:08 +00:00
actor [ j ] . bpos . z = sprite [ j ] . z ;
2006-11-16 03:02:42 +00:00
sprite [ j ] . z + = q ;
}
2016-08-27 01:42:01 +00:00
actor [ j ] . floorz = pSector - > floorz ;
2016-08-27 01:40:35 +00:00
actor [ j ] . ceilingz = pSector - > ceilingz ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] ) //If in motion
2009-07-12 01:55:34 +00:00
{
2016-08-27 01:40:35 +00:00
if ( klabs ( pSector - > floorz - pData [ 2 ] ) < = SP ( spriteNum ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
G_ActivateWarpElevators ( spriteNum , 0 ) ;
2009-07-12 01:55:34 +00:00
break ;
}
2012-08-28 21:42:49 +00:00
// If we still see the opening, we can't yet teleport.
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = - 1 )
2009-07-12 01:55:34 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSector - > floorz > pData [ 3 ] )
2006-11-16 03:02:42 +00:00
break ;
2009-07-12 01:55:34 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( pSector - > ceilingz < pData [ 4 ] ) break ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 1 ] = = 0 ) break ;
pData [ 1 ] = 0 ;
2006-04-13 20:47:06 +00:00
2013-04-15 10:48:09 +00:00
for ( SPRITES_OF ( STAT_EFFECTOR , j ) )
2009-07-12 01:55:34 +00:00
{
2016-08-27 01:40:35 +00:00
if ( spriteNum ! = j & & sprite [ j ] . lotag = = SE_17_WARP_ELEVATOR )
if ( pSector - > hitag - pData [ 0 ] = = sector [ sprite [ j ] . sectnum ] . hitag
2017-06-24 21:16:43 +00:00
& & spriteHitag = = sprite [ j ] . hitag )
2009-07-12 01:55:34 +00:00
break ;
}
2006-11-15 01:16:55 +00:00
2009-07-12 01:55:34 +00:00
if ( j = = - 1 ) break ;
2006-04-13 20:47:06 +00:00
2018-10-07 05:23:53 +00:00
int32_t nextk ;
2016-08-27 01:40:35 +00:00
for ( SPRITES_OF_SECT_SAFE ( pSprite - > sectnum , k , nextk ) )
2009-07-12 01:55:34 +00:00
{
2009-08-06 10:12:13 +00:00
if ( sprite [ k ] . statnum = = STAT_PLAYER & & sprite [ k ] . owner > = 0 )
2006-11-16 03:02:42 +00:00
{
2019-07-08 00:41:25 +00:00
int const warpPlayer = P_Get ( k ) ;
auto const pPlayer = g_player [ warpPlayer ] . ps ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
pPlayer - > pos . x + = sprite [ j ] . x - pSprite - > x ;
pPlayer - > pos . y + = sprite [ j ] . y - pSprite - > y ;
pPlayer - > opos . z - = pPlayer - > pos . z ;
pPlayer - > pos . z = sector [ sprite [ j ] . sectnum ] . floorz - ( pSector - > floorz - pPlayer - > pos . z ) ;
pPlayer - > opos . z + = pPlayer - > pos . z ;
2006-04-13 20:47:06 +00:00
2019-06-25 11:28:25 +00:00
actor [ k ] . floorz = sector [ sprite [ j ] . sectnum ] . floorz ;
actor [ k ] . ceilingz = sector [ sprite [ j ] . sectnum ] . ceilingz ;
2019-08-07 22:43:48 +00:00
pPlayer - > opos . vec2 = pPlayer - > pos . vec2 ;
pPlayer - > bobpos = pPlayer - > pos . vec2 ;
2019-06-25 11:28:25 +00:00
pPlayer - > truefz = actor [ k ] . floorz ;
pPlayer - > truecz = actor [ k ] . ceilingz ;
pPlayer - > bobcounter = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
changespritesect ( k , sprite [ j ] . sectnum ) ;
pPlayer - > cursectnum = sprite [ j ] . sectnum ;
2009-07-12 01:55:34 +00:00
}
2009-08-06 10:12:13 +00:00
else if ( sprite [ k ] . statnum ! = STAT_EFFECTOR )
2009-07-12 01:55:34 +00:00
{
2016-08-27 01:40:35 +00:00
sprite [ k ] . x + = sprite [ j ] . x - pSprite - > x ;
sprite [ k ] . y + = sprite [ j ] . y - pSprite - > y ;
2006-11-15 01:16:55 +00:00
2019-08-07 22:43:48 +00:00
actor [ k ] . bpos . vec2 = sprite [ k ] . pos . vec2 ;
2015-10-20 07:15:21 +00:00
actor [ k ] . bpos . z - = sprite [ k ] . z ;
2016-08-27 01:42:01 +00:00
sprite [ k ] . z = sector [ sprite [ j ] . sectnum ] . floorz - ( pSector - > floorz - sprite [ k ] . z ) ;
2015-10-20 07:15:21 +00:00
actor [ k ] . bpos . z + = sprite [ k ] . z ;
2006-04-13 20:47:06 +00:00
2009-07-12 01:55:34 +00:00
changespritesect ( k , sprite [ j ] . sectnum ) ;
2019-08-13 14:44:00 +00:00
setsprite ( k , & sprite [ k ] . pos ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
actor [ k ] . floorz = sector [ sprite [ j ] . sectnum ] . floorz ;
2010-05-02 23:27:30 +00:00
actor [ k ] . ceilingz = sector [ sprite [ j ] . sectnum ] . ceilingz ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2009-07-12 01:55:34 +00:00
}
2006-11-16 03:02:42 +00:00
break ;
2012-08-10 19:11:56 +00:00
}
2006-04-13 20:47:06 +00:00
2012-09-08 22:18:44 +00:00
case SE_18_INCREMENTAL_SECTOR_RISE_FALL :
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > pal )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > ang = = 512 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > ceilingz - = pSector - > extra ;
if ( pSector - > ceilingz < = pData [ 1 ] )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > ceilingz = pData [ 1 ] ;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
}
else
{
2016-08-27 01:40:35 +00:00
pSector - > floorz + = pSector - > extra ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:42:01 +00:00
for ( bssize_t SPRITES_OF_SECT ( pSprite - > sectnum , sectSprite ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:42:01 +00:00
if ( sprite [ sectSprite ] . picnum = = APLAYER & & sprite [ sectSprite ] . owner > = 0 & & g_player [ P_Get ( sectSprite ) ] . ps - > on_ground = = 1 )
g_player [ P_Get ( sectSprite ) ] . ps - > pos . z + = pSector - > extra ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:42:01 +00:00
if ( sprite [ sectSprite ] . zvel = = 0 & & sprite [ sectSprite ] . statnum ! = STAT_EFFECTOR & & sprite [ sectSprite ] . statnum ! = STAT_PROJECTILE )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:42:01 +00:00
actor [ sectSprite ] . bpos . z = sprite [ sectSprite ] . z + = pSector - > extra ;
actor [ sectSprite ] . floorz = pSector - > floorz ;
2006-04-13 20:47:06 +00:00
}
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
if ( pSector - > floorz > = pData [ 1 ] )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > floorz = pData [ 1 ] ;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
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
{
2016-08-27 01:40:35 +00:00
if ( pSprite - > ang = = 512 )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > ceilingz + = pSector - > extra ;
if ( pSector - > ceilingz > = pSprite - > z )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > ceilingz = pSprite - > z ;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2006-11-15 01:16:55 +00:00
}
else
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > floorz - = pSector - > extra ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:42:01 +00:00
for ( bssize_t SPRITES_OF_SECT ( pSprite - > sectnum , sectSprite ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:42:01 +00:00
if ( sprite [ sectSprite ] . picnum = = APLAYER & & sprite [ sectSprite ] . owner > = 0 & & g_player [ P_Get ( sectSprite ) ] . ps - > on_ground = = 1 )
g_player [ P_Get ( sectSprite ) ] . ps - > pos . z - = pSector - > extra ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:42:01 +00:00
if ( sprite [ sectSprite ] . zvel = = 0 & & sprite [ sectSprite ] . statnum ! = STAT_EFFECTOR & & sprite [ sectSprite ] . statnum ! = STAT_PROJECTILE )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:42:01 +00:00
actor [ sectSprite ] . bpos . z = sprite [ sectSprite ] . z - = pSector - > extra ;
actor [ sectSprite ] . floorz = pSector - > floorz ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:40:35 +00:00
if ( pSector - > floorz < = pSprite - > z )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > floorz = pSprite - > z ;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
}
}
2016-08-27 01:42:01 +00:00
if ( + + pData [ 2 ] > = pSprite - > hitag )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 2 ] = 0 ;
pData [ 0 ] = 0 ;
2006-11-16 03:02:42 +00:00
}
}
break ;
2006-04-13 20:47:06 +00:00
2012-09-08 22:18:44 +00:00
case SE_19_EXPLOSION_LOWERS_CEILING : //Battlestar galactia shields
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 1 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] + + ;
x = pSector - > wallptr ;
q = x + pSector - > wallnum ;
2016-08-27 01:42:01 +00:00
2009-02-19 16:47:54 +00:00
for ( j = x ; j < q ; j + + )
2016-08-27 01:42:01 +00:00
{
2006-11-16 03:02:42 +00:00
if ( wall [ j ] . overpicnum = = BIGFORCE )
{
wall [ j ] . cstat & = ( 128 + 32 + 8 + 4 + 2 ) ;
wall [ j ] . overpicnum = 0 ;
2016-08-27 01:42:01 +00:00
2006-11-16 03:02:42 +00:00
if ( wall [ j ] . nextwall > = 0 )
{
wall [ wall [ j ] . nextwall ] . overpicnum = 0 ;
wall [ wall [ j ] . nextwall ] . cstat & = ( 128 + 32 + 8 + 4 + 2 ) ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:42:01 +00:00
}
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pSector - > ceilingz < pSector - > floorz )
pSector - > ceilingz + = SP ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
else
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > ceilingz = pSector - > floorz ;
2006-04-13 20:47:06 +00:00
2013-04-15 10:48:09 +00:00
for ( SPRITES_OF ( STAT_EFFECTOR , j ) )
2006-04-13 20:47:06 +00:00
{
2017-06-24 21:16:43 +00:00
if ( sprite [ j ] . lotag = = SE_0_ROTATING_SECTOR & & sprite [ j ] . hitag = = spriteHitag )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:42:01 +00:00
sectortype * const pSector = & sector [ sprite [ j ] . sectnum ] ;
int const ownerSector = sprite [ sprite [ j ] . owner ] . sectnum ;
2013-04-15 10:48:09 +00:00
2016-08-27 01:42:01 +00:00
pSector - > ceilingpal = sector [ ownerSector ] . floorpal ;
pSector - > floorpal = pSector - > ceilingpal ;
pSector - > ceilingshade = sector [ ownerSector ] . floorshade ;
pSector - > floorshade = pSector - > ceilingshade ;
2006-11-16 03:02:42 +00:00
2010-05-02 23:27:30 +00:00
actor [ sprite [ j ] . owner ] . t_data [ 0 ] = 2 ;
2006-11-15 01:16:55 +00:00
}
2006-04-13 20:47:06 +00:00
}
2012-04-13 10:45:49 +00:00
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
}
else //Not hit yet
{
2016-08-27 01:40:35 +00:00
if ( G_FindExplosionInSector ( pSprite - > sectnum ) > = 0 )
2006-11-16 03:02:42 +00:00
{
2013-04-15 10:48:09 +00:00
P_DoQuote ( QUOTE_UNLOCKED , g_player [ myconnectindex ] . ps ) ;
2006-04-13 20:47:06 +00:00
2013-04-15 10:48:09 +00:00
for ( SPRITES_OF ( STAT_EFFECTOR , l ) )
2007-08-25 01:05:00 +00:00
{
2016-08-27 01:42:01 +00:00
switch ( sprite [ l ] . lotag & 0x7fff )
2006-11-15 01:16:55 +00:00
{
2012-09-08 22:18:44 +00:00
case SE_0_ROTATING_SECTOR :
2017-06-24 21:16:43 +00:00
if ( sprite [ l ] . hitag = = spriteHitag )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
int const spriteOwner = sprite [ l ] . owner ;
int const sectNum = sprite [ l ] . sectnum ;
sector [ sectNum ] . ceilingshade = sprite [ spriteOwner ] . shade ;
sector [ sectNum ] . floorshade = sector [ sectNum ] . ceilingshade ;
sector [ sectNum ] . ceilingpal = sprite [ spriteOwner ] . pal ;
sector [ sectNum ] . floorpal = sector [ sectNum ] . ceilingpal ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2012-09-08 22:18:44 +00:00
case SE_1_PIVOT :
case SE_12_LIGHT_SWITCH :
2013-04-15 10:48:09 +00:00
// case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
2012-09-08 22:18:44 +00:00
case SE_19_EXPLOSION_LOWERS_CEILING :
2017-06-24 21:16:43 +00:00
if ( spriteHitag = = sprite [ l ] . hitag )
2010-05-02 23:27:30 +00:00
if ( actor [ l ] . t_data [ 0 ] = = 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
actor [ l ] . t_data [ 0 ] = 1 ; // Shut them all on
sprite [ l ] . owner = spriteNum ;
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
}
}
}
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
2012-09-08 22:18:44 +00:00
case SE_20_STRETCH_BRIDGE : //Extend-o-bridge
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 0 ) break ;
2016-08-27 01:42:01 +00:00
pSprite - > xvel = ( pData [ 0 ] = = 1 ) ? 8 : - 8 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > xvel ) //Moving
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
vec2_t const vect = { ( pSprite - > xvel * sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) > > 14 ,
( pSprite - > xvel * sintable [ pSprite - > ang & 2047 ] ) > > 14 } ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
pData [ 3 ] + = pSprite - > xvel ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:42:01 +00:00
pSprite - > x + = vect . x ;
pSprite - > y + = vect . y ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
if ( pData [ 3 ] < = 0 | | ( pData [ 3 ] > > 6 ) > = ( SP ( spriteNum ) > > 6 ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:42:01 +00:00
pSprite - > x - = vect . x ;
pSprite - > y - = vect . y ;
2016-08-27 01:40:35 +00:00
pData [ 0 ] = 0 ;
2016-08-27 01:42:01 +00:00
A_CallSound ( pSprite - > sectnum , spriteNum ) ;
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:42:01 +00:00
for ( bssize_t nextSprite , SPRITES_OF_SECT_SAFE ( pSprite - > sectnum , sectSprite , nextSprite ) )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:42:01 +00:00
if ( sprite [ sectSprite ] . statnum ! = STAT_EFFECTOR & & sprite [ sectSprite ] . zvel = = 0 )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:42:01 +00:00
sprite [ sectSprite ] . x + = vect . x ;
sprite [ sectSprite ] . y + = vect . y ;
2019-08-13 14:44:00 +00:00
setsprite ( sectSprite , & sprite [ sectSprite ] . pos ) ;
2016-08-27 01:42:01 +00:00
if ( sector [ sprite [ sectSprite ] . sectnum ] . floorstat & 2 & & sprite [ sectSprite ] . statnum = = STAT_ZOMBIEACTOR )
A_Fall ( sectSprite ) ;
2006-11-15 01:16:55 +00:00
}
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
dragpoint ( ( int16_t ) pData [ 1 ] , wall [ pData [ 1 ] ] . x + vect . x , wall [ pData [ 1 ] ] . y + vect . y , 0 ) ;
dragpoint ( ( int16_t ) pData [ 2 ] , wall [ pData [ 2 ] ] . x + vect . x , wall [ pData [ 2 ] ] . y + vect . y , 0 ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
for ( bssize_t TRAVERSE_CONNECT ( playerNum ) )
2012-08-10 19:11:56 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pPlayer = g_player [ playerNum ] . ps ;
2012-08-10 19:11:56 +00:00
2016-08-27 01:42:01 +00:00
if ( pPlayer - > cursectnum = = pSprite - > sectnum & & pPlayer - > on_ground )
2012-02-21 19:33:33 +00:00
{
2016-08-27 01:42:01 +00:00
pPlayer - > pos . x + = vect . x ;
pPlayer - > pos . y + = vect . y ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
pPlayer - > opos . x = pPlayer - > pos . x ;
pPlayer - > opos . y = pPlayer - > pos . y ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
pPlayer - > pos . z + = PHEIGHT ;
2019-08-13 14:44:00 +00:00
setsprite ( pPlayer - > i , & pPlayer - > pos ) ;
2016-08-27 01:42:01 +00:00
pPlayer - > pos . z - = PHEIGHT ;
2012-02-21 19:33:33 +00:00
}
2012-08-10 19:11:56 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
pSector - > floorxpanning - = vect . x > > 3 ;
pSector - > floorypanning - = vect . y > > 3 ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:42:01 +00:00
pSector - > ceilingxpanning - = vect . x > > 3 ;
pSector - > ceilingypanning - = vect . y > > 3 ;
2006-11-16 03:02:42 +00:00
}
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
2012-08-26 22:16:08 +00:00
case SE_21_DROP_FLOOR : // Cascading effect
2011-12-21 18:40:47 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 0 ) break ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
int32_t * zptr = ( pSprite - > ang = = 1536 ) ? & pSector - > ceilingz : & pSector - > floorz ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 1 ) //Decide if the s->sectnum should go up or down
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > zvel = ksgn ( pSprite - > z - * zptr ) * ( SP ( spriteNum ) < < 4 ) ;
pData [ 0 ] + + ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
if ( pSector - > extra = = 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
* zptr + = pSprite - > zvel ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
if ( klabs ( * zptr - pSprite - > z ) < 1024 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
* zptr = pSprite - > z ;
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ; //All done // SE_21_KILLIT, see sector.c
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else pSector - > extra - - ;
2006-11-16 03:02:42 +00:00
break ;
2011-12-21 18:40:47 +00:00
}
2006-04-13 20:47:06 +00:00
2012-09-08 22:18:44 +00:00
case SE_22_TEETH_DOOR :
2016-08-27 01:40:35 +00:00
if ( pData [ 1 ] )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( GetAnimationGoal ( & sector [ pData [ 0 ] ] . ceilingz ) > = 0 )
pSector - > ceilingz + = pSector - > extra * 9 ;
else pData [ 1 ] = 0 ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2012-08-26 22:16:08 +00:00
case SE_24_CONVEYOR :
2012-09-08 22:18:44 +00:00
case SE_34 :
2012-08-10 19:11:56 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 4 ] )
2012-04-13 10:46:04 +00:00
break ;
2006-11-15 01:16:55 +00:00
2016-08-27 01:42:01 +00:00
vec2_t const vect = { ( SP ( spriteNum ) * sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) > > 18 ,
( SP ( spriteNum ) * sintable [ pSprite - > ang & 2047 ] ) > > 18 } ;
2006-11-16 03:02:42 +00:00
k = 0 ;
2016-08-27 01:42:01 +00:00
for ( bssize_t nextSprite , SPRITES_OF_SECT_SAFE ( pSprite - > sectnum , sectSprite , nextSprite ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
if ( sprite [ sectSprite ] . zvel < 0 )
continue ;
switch ( sprite [ sectSprite ] . statnum )
{
2009-08-06 10:12:13 +00:00
case STAT_MISC :
2016-08-27 01:42:01 +00:00
switch ( DYNAMICTILEMAP ( sprite [ sectSprite ] . picnum ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
case BLOODPOOL__STATIC :
case PUKE__STATIC :
case FOOTPRINTS__STATIC :
case FOOTPRINTS2__STATIC :
case FOOTPRINTS3__STATIC :
case FOOTPRINTS4__STATIC :
case BULLETHOLE__STATIC :
case BLOODSPLAT1__STATIC :
case BLOODSPLAT2__STATIC :
case BLOODSPLAT3__STATIC :
case BLOODSPLAT4__STATIC : sprite [ sectSprite ] . xrepeat = sprite [ sectSprite ] . yrepeat = 0 ; continue ;
case LASERLINE__STATIC : continue ;
2006-11-16 03:02:42 +00:00
}
2018-09-04 05:57:41 +00:00
fallthrough__ ;
2009-08-06 10:12:13 +00:00
case STAT_STANDABLE :
2016-08-27 01:42:01 +00:00
if ( sprite [ sectSprite ] . picnum = = TRIPBOMB )
2013-04-15 10:48:09 +00:00
break ;
2018-09-04 05:57:41 +00:00
fallthrough__ ;
2009-08-06 10:12:13 +00:00
case STAT_ACTOR :
case STAT_DEFAULT :
2016-08-27 01:42:01 +00:00
if ( sprite [ sectSprite ] . picnum = = BOLT1
| | sprite [ sectSprite ] . picnum = = BOLT1 + 1
| | sprite [ sectSprite ] . picnum = = BOLT1 + 2
| | sprite [ sectSprite ] . picnum = = BOLT1 + 3
| | sprite [ sectSprite ] . picnum = = SIDEBOLT1
| | sprite [ sectSprite ] . picnum = = SIDEBOLT1 + 1
| | sprite [ sectSprite ] . picnum = = SIDEBOLT1 + 2
| | sprite [ sectSprite ] . picnum = = SIDEBOLT1 + 3
| | A_CheckSwitchTile ( sectSprite ) )
2006-11-16 03:02:42 +00:00
break ;
2016-08-27 01:42:01 +00:00
if ( ! ( sprite [ sectSprite ] . picnum > = CRANE & & sprite [ sectSprite ] . picnum < = CRANE + 3 ) )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:42:01 +00:00
if ( sprite [ sectSprite ] . z > actor [ sectSprite ] . floorz - ZOFFSET2 )
2006-11-16 03:02:42 +00:00
{
2019-08-07 22:43:48 +00:00
actor [ sectSprite ] . bpos . vec2 = sprite [ sectSprite ] . pos . vec2 ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:42:01 +00:00
sprite [ sectSprite ] . x + = vect . x > > 2 ;
sprite [ sectSprite ] . y + = vect . y > > 2 ;
2006-11-16 03:02:42 +00:00
2019-08-13 14:44:00 +00:00
setsprite ( sectSprite , & sprite [ sectSprite ] . pos ) ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:42:01 +00:00
if ( sector [ sprite [ sectSprite ] . sectnum ] . floorstat & 2 )
if ( sprite [ sectSprite ] . statnum = = STAT_ZOMBIEACTOR )
A_Fall ( sectSprite ) ;
2006-11-16 03:02:42 +00:00
}
2006-11-15 01:16:55 +00:00
}
break ;
2016-08-27 01:42:01 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:42:01 +00:00
for ( bssize_t TRAVERSE_CONNECT ( playerNum ) )
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pPlayer = g_player [ playerNum ] . ps ;
2015-07-25 19:42:54 +00:00
2016-08-27 01:42:01 +00:00
if ( pPlayer - > cursectnum = = pSprite - > sectnum & & pPlayer - > on_ground )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:42:01 +00:00
if ( klabs ( pPlayer - > pos . z - pPlayer - > truefz ) < PHEIGHT + ( 9 < < 8 ) )
2014-11-22 12:28:12 +00:00
{
2016-08-27 01:42:01 +00:00
pPlayer - > fric . x + = vect . x < < 3 ;
pPlayer - > fric . y + = vect . y < < 3 ;
2014-11-22 12:28:12 +00:00
}
2006-11-16 03:02:42 +00:00
}
2014-11-22 12:28:12 +00:00
}
2016-08-27 01:40:35 +00:00
pSector - > floorxpanning + = SP ( spriteNum ) > > 7 ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2012-08-10 19:11:56 +00:00
}
2006-04-13 20:47:06 +00:00
2013-06-22 11:31:13 +00:00
case SE_35 :
2016-08-27 01:40:35 +00:00
if ( pSector - > ceilingz > pSprite - > z )
2016-08-27 01:42:01 +00:00
{
2009-02-19 16:47:54 +00:00
for ( j = 0 ; j < 8 ; j + + )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > ang + = krand ( ) & 511 ;
2016-08-27 01:42:01 +00:00
k = A_Spawn ( spriteNum , SMALLSMOKE ) ;
2008-11-20 14:06:36 +00:00
sprite [ k ] . xvel = 96 + ( krand ( ) & 127 ) ;
2016-08-27 01:42:01 +00:00
A_SetSprite ( k , CLIPMASK0 ) ;
2019-08-13 14:44:00 +00:00
setsprite ( k , & sprite [ k ] . pos ) ;
2006-11-16 03:02:42 +00:00
if ( rnd ( 16 ) )
2016-08-27 01:42:01 +00:00
A_Spawn ( spriteNum , EXPLOSION2 ) ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
2016-08-27 01:42:01 +00:00
}
2016-08-27 01:40:35 +00:00
switch ( pData [ 0 ] )
2006-11-16 03:02:42 +00:00
{
case 0 :
2016-08-27 01:40:35 +00:00
pSector - > ceilingz + = pSprite - > yvel ;
if ( pSector - > ceilingz > pSector - > floorz )
pSector - > floorz = pSector - > ceilingz ;
2016-08-27 01:40:56 +00:00
if ( pSector - > ceilingz > pSprite - > z + ZOFFSET5 )
2016-08-27 01:40:35 +00:00
pData [ 0 ] + + ;
2006-11-16 03:02:42 +00:00
break ;
case 1 :
2016-08-27 01:40:35 +00:00
pSector - > ceilingz - = ( pSprite - > yvel < < 2 ) ;
if ( pSector - > ceilingz < pData [ 4 ] )
2006-11-15 01:16:55 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > ceilingz = pData [ 4 ] ;
pData [ 0 ] = 0 ;
2006-11-15 01:16:55 +00:00
}
break ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2012-08-26 22:16:08 +00:00
case SE_25_PISTON : //PISTONS
2016-08-27 01:40:35 +00:00
if ( pData [ 4 ] = = 0 ) break ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSector - > floorz < = pSector - > ceilingz )
pSprite - > shade = 0 ;
else if ( pSector - > ceilingz < = pData [ 3 ] )
pSprite - > shade = 1 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pSprite - > shade )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > ceilingz + = SP ( spriteNum ) < < 4 ;
if ( pSector - > ceilingz > pSector - > floorz )
pSector - > ceilingz = pSector - > floorz ;
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
pSector - > ceilingz - = SP ( spriteNum ) < < 4 ;
if ( pSector - > ceilingz < pData [ 3 ] )
pSector - > ceilingz = pData [ 3 ] ;
2006-11-16 03:02:42 +00:00
}
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
2012-08-26 22:16:08 +00:00
case SE_26 :
2012-08-10 19:11:56 +00:00
{
2013-04-15 10:48:09 +00:00
int32_t p , nextj ;
2012-08-10 19:11:56 +00:00
2016-12-26 06:03:00 +00:00
pSprite - > xvel = pSector - > extra ! = 0 ? pSector - > extra : 32 ;
2016-08-27 01:40:35 +00:00
l = ( pSprite - > xvel * sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) > > 14 ;
x = ( pSprite - > xvel * sintable [ pSprite - > ang & 2047 ] ) > > 14 ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
pSprite - > shade + + ;
if ( pSprite - > shade > 7 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pSprite - > x = pData [ 3 ] ;
pSprite - > y = pData [ 4 ] ;
pSector - > floorz - = ( ( pSprite - > zvel * pSprite - > shade ) - pSprite - > zvel ) ;
pSprite - > shade = 0 ;
2006-11-16 03:02:42 +00:00
}
else
2016-08-27 01:40:35 +00:00
pSector - > floorz + = pSprite - > zvel ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
for ( SPRITES_OF_SECT_SAFE ( pSprite - > sectnum , j , nextj ) )
2006-11-16 03:02:42 +00:00
{
2018-06-09 20:36:24 +00:00
if ( sprite [ j ] . statnum ! = STAT_EFFECTOR & & sprite [ j ] . statnum ! = STAT_PLAYER & & sprite [ j ] . statnum ! = STAT_PROJECTILE )
2006-11-15 01:16:55 +00:00
{
2019-08-07 22:43:48 +00:00
actor [ j ] . bpos . vec2 = sprite [ j ] . pos . vec2 ;
2006-11-16 03:02:42 +00:00
sprite [ j ] . x + = l ;
sprite [ j ] . y + = x ;
2016-08-27 01:40:35 +00:00
sprite [ j ] . z + = pSprite - > zvel ;
2018-06-09 20:36:24 +00:00
2019-08-13 14:44:00 +00:00
setsprite ( j , & sprite [ j ] . pos ) ;
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
}
2006-04-13 20:47:06 +00:00
2012-02-21 19:33:33 +00:00
for ( TRAVERSE_CONNECT ( p ) )
2014-11-22 12:28:12 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pPlayer = g_player [ p ] . ps ;
2015-07-25 19:42:54 +00:00
2019-10-20 17:55:35 +00:00
if ( pSprite - > sectnum = = pPlayer - > cursectnum & & pPlayer - > on_ground )
2014-11-22 12:28:12 +00:00
{
2018-06-09 20:36:24 +00:00
pPlayer - > pos . x + = l ;
pPlayer - > pos . y + = x ;
pPlayer - > pos . z + = pSprite - > zvel ;
updatesector ( pPlayer - > pos . x , pPlayer - > pos . y , & pPlayer - > cursectnum ) ;
changespritesect ( pPlayer - > i , pPlayer - > cursectnum ) ;
pPlayer - > bobpos . x + = l ;
pPlayer - > bobpos . y + = x ;
if ( g_netServer | | numplayers > 1 )
2019-10-20 17:55:24 +00:00
pPlayer - > opos . vec2 = pPlayer - > pos . vec2 ;
2018-06-09 20:36:24 +00:00
if ( sprite [ pPlayer - > i ] . extra < = 0 )
2019-10-20 17:55:24 +00:00
sprite [ pPlayer - > i ] . pos . vec2 = pPlayer - > pos . vec2 ;
2014-11-22 12:28:12 +00:00
}
}
2018-06-09 20:36:24 +00:00
2016-08-27 01:40:35 +00:00
A_MoveSector ( spriteNum ) ;
2019-06-25 11:28:25 +00:00
setsprite ( spriteNum , & pSprite - > pos ) ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
break ;
2012-08-10 19:11:56 +00:00
}
2006-04-13 20:47:06 +00:00
2012-08-26 22:16:08 +00:00
case SE_27_DEMO_CAM :
2012-08-10 19:11:56 +00:00
{
2019-10-21 23:00:22 +00:00
if ( pSprite - > extra < 1 & & ( ud . recstat = = 0 | | ! cl_democams ) ) break ;
2006-11-15 01:16:55 +00:00
2019-06-25 18:34:49 +00:00
if ( klabs ( pSprite - > extra ) = = 2 )
2006-11-16 03:02:42 +00:00
{
2019-06-25 18:34:45 +00:00
actor [ spriteNum ] . tempang = pSprite - > ang ;
if ( ud . camerasprite ! = spriteNum )
2006-04-13 20:47:06 +00:00
{
2019-06-25 18:34:45 +00:00
//level the camera out by default (yvel stores the up/down angle)
pSprite - > yvel = 100 ;
2016-08-27 01:40:35 +00:00
ud . camerasprite = spriteNum ;
2006-11-16 03:02:42 +00:00
}
2019-06-25 18:34:45 +00:00
findCameraDestination :
if ( pSprite - > owner = = spriteNum )
2006-11-16 03:02:42 +00:00
{
2019-06-25 18:35:24 +00:00
pSprite - > owner = A_FindLocatorWithHiLoTags ( pSprite - > hitag , pData [ 0 ] , - 1 ) ;
2019-06-25 18:34:45 +00:00
//reset our elapsed time since reaching a locator
pData [ 1 ] = 0 ;
//store our starting point
pData [ 2 ] = pSprite - > x ;
pData [ 3 ] = pSprite - > y ;
pData [ 4 ] = pSprite - > z ;
pData [ 5 ] = pSprite - > ang ;
pData [ 6 ] = pSprite - > yvel ;
if ( pSprite - > owner ! = - 1 )
{
spritetype * const destLocator = & sprite [ pSprite - > owner ] ;
2019-06-25 18:35:24 +00:00
int32_t subjectLocatorIndex = A_FindLocatorWithHiLoTags ( pSprite - > hitag , destLocator - > owner , - 1 ) ;
pData [ 7 ] = G_GetAngleDelta ( pData [ 5 ] , destLocator - > ang ) ;
//level the camera out by default (pData[8] stores our destination up/down angle)
pData [ 8 ] = 100 ;
if ( subjectLocatorIndex ! = - 1 )
2006-04-13 20:47:06 +00:00
{
2019-06-25 18:34:45 +00:00
spritetype * const subjectLocator = & sprite [ subjectLocatorIndex ] ;
const vec3_t cameraDirection = { subjectLocator - > x - destLocator - > x ,
subjectLocator - > y - destLocator - > y ,
subjectLocator - > z - destLocator - > z } ;
pData [ 7 ] = G_GetAngleDelta ( pData [ 5 ] , getangle ( cameraDirection . x ,
cameraDirection . y ) ) ;
pData [ 8 ] = ( ( ( int32_t ) getangle ( - ksqrt ( cameraDirection . x * cameraDirection . x + cameraDirection . y * cameraDirection . y ) , cameraDirection . z ) * ( 400.f / 1024.f ) ) ) - 300 ;
2006-11-16 03:02:42 +00:00
}
}
2019-06-25 18:34:45 +00:00
}
if ( pSprite - > owner = = - 1 )
{
break ;
}
2019-06-25 18:35:24 +00:00
spritetype * const destLocator = & sprite [ pSprite - > owner ] ;
2019-06-25 18:34:45 +00:00
if ( pData [ 1 ] = = destLocator - > extra )
{
pSprite - > owner = spriteNum ;
2019-06-25 18:35:24 +00:00
+ + pData [ 0 ] ;
2019-06-25 18:34:45 +00:00
goto findCameraDestination ;
}
//smoothstep to the new location and camera direction over the duration (in ticks) stored in the destLocator's extra value
const vec3_t heading = { destLocator - > x - pData [ 2 ] ,
destLocator - > y - pData [ 3 ] ,
destLocator - > z - pData [ 4 ] } ;
float interpolation = ( pData [ 1 ] / ( float ) destLocator - > extra ) ;
interpolation = interpolation * interpolation * ( 3 - 2 * interpolation ) ;
pSprite - > x = pData [ 2 ] + interpolation * heading . x ;
pSprite - > y = pData [ 3 ] + interpolation * heading . y ;
pSprite - > z = pData [ 4 ] + interpolation * heading . z ;
pSprite - > ang = pData [ 5 ] + interpolation * pData [ 7 ] ;
pSprite - > yvel = ( pData [ 6 ] + ( ( int32_t ) interpolation * pData [ 8 ] ) + 100 ) % 400 - 100 ;
2019-06-25 18:35:24 +00:00
2019-06-25 18:34:45 +00:00
//increment elapsed time
+ + pData [ 1 ] ;
}
else
{
actor [ spriteNum ] . tempang = pSprite - > ang ;
2019-07-08 00:41:25 +00:00
int const p = A_FindPlayer ( pSprite , & x ) ;
auto const ps = g_player [ p ] . ps ;
2019-06-25 18:34:45 +00:00
if ( sprite [ ps - > i ] . extra > 0 & & myconnectindex = = screenpeek )
{
if ( pData [ 0 ] < 0 )
2006-11-16 03:02:42 +00:00
{
2019-06-25 18:34:45 +00:00
ud . camerasprite = spriteNum ;
pData [ 0 ] + + ;
}
else if ( ud . recstat = = 2 & & ps - > newowner = = - 1 )
{
if ( cansee ( pSprite - > x , pSprite - > y , pSprite - > z , SECT ( spriteNum ) , ps - > pos . x , ps - > pos . y , ps - > pos . z , ps - > cursectnum ) )
{
if ( x < ( int32_t ) ( ( unsigned ) spriteHitag ) )
{
ud . camerasprite = spriteNum ;
pData [ 0 ] = 999 ;
pSprite - > ang + = G_GetAngleDelta ( pSprite - > ang , getangle ( ps - > pos . x - pSprite - > x , ps - > pos . y - pSprite - > y ) ) > > 3 ;
SP ( spriteNum ) = 100 + ( ( pSprite - > z - ps - > pos . z ) / 257 ) ;
2006-11-16 03:02:42 +00:00
2019-06-25 18:34:45 +00:00
}
else if ( pData [ 0 ] = = 999 )
{
if ( ud . camerasprite = = spriteNum )
pData [ 0 ] = 0 ;
else pData [ 0 ] = - 10 ;
ud . camerasprite = spriteNum ;
}
}
else
2006-11-16 03:02:42 +00:00
{
2019-06-25 18:34:45 +00:00
pSprite - > ang = getangle ( ps - > pos . x - pSprite - > x , ps - > pos . y - pSprite - > y ) ;
if ( pData [ 0 ] = = 999 )
{
if ( ud . camerasprite = = spriteNum )
pData [ 0 ] = 0 ;
else pData [ 0 ] = - 20 ;
ud . camerasprite = spriteNum ;
}
2006-04-13 20:47:06 +00:00
}
}
}
2006-11-16 03:02:42 +00:00
}
break ;
2012-08-10 19:11:56 +00:00
}
2012-04-13 10:46:04 +00:00
2012-08-26 22:16:08 +00:00
case SE_28_LIGHTNING :
2012-08-10 19:11:56 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 5 ] > 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 5 ] - - ;
2006-04-13 20:47:06 +00:00
break ;
2006-11-16 03:02:42 +00:00
}
2006-11-15 01:16:55 +00:00
2016-08-27 01:40:35 +00:00
if ( T1 ( spriteNum ) = = 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
A_FindPlayer ( pSprite , & x ) ;
2006-11-16 03:02:42 +00:00
if ( x > 15500 )
break ;
2016-08-27 01:40:35 +00:00
T1 ( spriteNum ) = 1 ;
T2 ( spriteNum ) = 64 + ( krand ( ) & 511 ) ;
T3 ( spriteNum ) = 0 ;
2006-11-16 03:02:42 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
T3 ( spriteNum ) + + ;
if ( T3 ( spriteNum ) > T2 ( spriteNum ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
T1 ( spriteNum ) = 0 ;
2007-08-27 06:46:31 +00:00
g_player [ screenpeek ] . ps - > visibility = ud . const_visibility ;
2006-11-16 03:02:42 +00:00
break ;
2006-11-15 01:16:55 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( T3 ( spriteNum ) = = ( T2 ( spriteNum ) > > 1 ) )
A_PlaySound ( THUNDER , spriteNum ) ;
else if ( T3 ( spriteNum ) = = ( T2 ( spriteNum ) > > 3 ) )
A_PlaySound ( LIGHTNING_SLAP , spriteNum ) ;
else if ( T3 ( spriteNum ) = = ( T2 ( spriteNum ) > > 2 ) )
2006-11-15 01:16:55 +00:00
{
2012-05-29 20:01:48 +00:00
for ( SPRITES_OF ( STAT_DEFAULT , j ) )
2016-08-27 01:40:35 +00:00
if ( sprite [ j ] . picnum = = NATURALLIGHTNING & & sprite [ j ] . hitag = = pSprite - > hitag )
2006-11-16 03:02:42 +00:00
sprite [ j ] . cstat | = 32768 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else if ( T3 ( spriteNum ) > ( T2 ( spriteNum ) > > 3 ) & & T3 ( spriteNum ) < ( T2 ( spriteNum ) > > 2 ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( cansee ( pSprite - > x , pSprite - > y , pSprite - > z , pSprite - > sectnum , g_player [ screenpeek ] . ps - > pos . x , g_player [ screenpeek ] . ps - > pos . y , g_player [ screenpeek ] . ps - > pos . z , g_player [ screenpeek ] . ps - > cursectnum ) )
2006-11-16 03:02:42 +00:00
j = 1 ;
else j = 0 ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( rnd ( 192 ) & & ( T3 ( spriteNum ) & 1 ) )
2006-04-13 20:47:06 +00:00
{
2006-11-16 03:02:42 +00:00
if ( j )
2007-08-27 06:46:31 +00:00
g_player [ screenpeek ] . ps - > visibility = 0 ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
else if ( j )
2007-08-27 06:46:31 +00:00
g_player [ screenpeek ] . ps - > visibility = ud . const_visibility ;
2006-04-13 20:47:06 +00:00
2013-04-15 10:48:09 +00:00
for ( SPRITES_OF ( STAT_DEFAULT , j ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( sprite [ j ] . picnum = = NATURALLIGHTNING & & sprite [ j ] . hitag = = pSprite - > hitag )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( rnd ( 32 ) & & ( T3 ( spriteNum ) & 1 ) )
2006-04-13 20:47:06 +00:00
{
2012-08-10 19:11:56 +00:00
int32_t p ;
DukePlayer_t * ps ;
2006-11-16 03:02:42 +00:00
sprite [ j ] . cstat & = 32767 ;
2008-11-20 14:06:36 +00:00
A_Spawn ( j , SMALLSMOKE ) ;
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
p = A_FindPlayer ( pSprite , NULL ) ;
2012-08-10 19:11:56 +00:00
ps = g_player [ p ] . ps ;
x = ldist ( & sprite [ ps - > i ] , & sprite [ j ] ) ;
2006-11-16 03:02:42 +00:00
if ( x < 768 )
2006-04-13 20:47:06 +00:00
{
2012-08-10 19:11:56 +00:00
if ( ! A_CheckSoundPlaying ( ps - > i , DUKE_LONGTERM_PAIN ) )
A_PlaySound ( DUKE_LONGTERM_PAIN , ps - > i ) ;
A_PlaySound ( SHORT_CIRCUIT , ps - > i ) ;
sprite [ ps - > i ] . extra - = 8 + ( krand ( ) & 7 ) ;
2012-05-05 22:24:50 +00:00
2012-08-10 19:11:56 +00:00
P_PalFrom ( ps , 32 , 16 , 0 , 0 ) ;
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
else sprite [ j ] . cstat | = 32768 ;
2006-04-13 20:47:06 +00:00
}
}
2006-11-16 03:02:42 +00:00
}
}
break ;
2012-08-10 19:11:56 +00:00
}
2012-04-13 10:46:04 +00:00
2012-08-26 22:16:08 +00:00
case SE_29_WAVES :
2016-08-27 01:40:35 +00:00
pSprite - > hitag + = 64 ;
l = mulscale12 ( ( int32_t ) pSprite - > yvel , sintable [ pSprite - > hitag & 2047 ] ) ;
pSector - > floorz = pSprite - > z + l ;
2006-11-16 03:02:42 +00:00
break ;
2012-04-13 10:46:04 +00:00
2012-08-26 22:16:08 +00:00
case SE_31_FLOOR_RISE_FALL : // True Drop Floor
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 1 )
2006-11-16 03:02:42 +00:00
{
// Choose dir
2016-08-27 01:40:35 +00:00
if ( pData [ 3 ] > 0 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 3 ] - - ;
2006-11-16 03:02:42 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 2 ] = = 1 ) // Retract
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( SA ( spriteNum ) ! = 1536 )
HandleSE31 ( spriteNum , 1 , pSprite - > z , 0 , pSprite - > z - pSector - > floorz ) ;
2006-04-13 20:47:06 +00:00
else
2016-08-27 01:40:35 +00:00
HandleSE31 ( spriteNum , 1 , pData [ 1 ] , 0 , pData [ 1 ] - pSector - > floorz ) ;
2011-06-29 19:57:05 +00:00
2016-08-27 01:40:35 +00:00
Yax_SetBunchZs ( pSector - sector , YAX_FLOOR , pSector - > floorz ) ;
2011-06-29 19:57:05 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
if ( ( pSprite - > ang & 2047 ) = = 1536 )
HandleSE31 ( spriteNum , 0 , pSprite - > z , 1 , pSprite - > z - pSector - > floorz ) ;
2006-11-16 03:02:42 +00:00
else
2016-08-27 01:40:35 +00:00
HandleSE31 ( spriteNum , 0 , pData [ 1 ] , 1 , pData [ 1 ] - pSprite - > z ) ;
2011-06-29 19:57:05 +00:00
2016-08-27 01:40:35 +00:00
Yax_SetBunchZs ( pSector - sector , YAX_FLOOR , pSector - > floorz ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2012-08-26 22:16:08 +00:00
case SE_32_CEILING_RISE_FALL : // True Drop Ceiling
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 1 )
2006-11-16 03:02:42 +00:00
{
// Choose dir
2006-04-13 20:47:06 +00:00
2016-08-27 01:40:35 +00:00
if ( pData [ 2 ] = = 1 ) // Retract
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( SA ( spriteNum ) ! = 1536 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( klabs ( pSector - > ceilingz - pSprite - > z ) < ( SP ( spriteNum ) < < 1 ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > ceilingz = pSprite - > z ;
A_CallSound ( pSprite - > sectnum , spriteNum ) ;
pData [ 2 ] = 0 ;
pData [ 0 ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else pSector - > ceilingz + = ksgn ( pSprite - > z - pSector - > ceilingz ) * SP ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2016-08-27 01:40:35 +00:00
if ( klabs ( pSector - > ceilingz - pData [ 1 ] ) < ( SP ( spriteNum ) < < 1 ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pSector - > ceilingz = pData [ 1 ] ;
A_CallSound ( pSprite - > sectnum , spriteNum ) ;
pData [ 2 ] = 0 ;
pData [ 0 ] = 0 ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else pSector - > ceilingz + = ksgn ( pData [ 1 ] - pSector - > ceilingz ) * SP ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2011-06-29 19:57:05 +00:00
2016-08-27 01:40:35 +00:00
Yax_SetBunchZs ( pSector - sector , YAX_CEILING , pSector - > ceilingz ) ;
2011-06-29 19:57:05 +00:00
2006-11-16 03:02:42 +00:00
break ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
if ( ( pSprite - > ang & 2047 ) = = 1536 )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
if ( klabs ( pSector - > ceilingz - pSprite - > z ) < ( SP ( spriteNum ) < < 1 ) )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = 0 ;
pData [ 2 ] = ! pData [ 2 ] ;
A_CallSound ( pSprite - > sectnum , spriteNum ) ;
pSector - > ceilingz = pSprite - > z ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else pSector - > ceilingz + = ksgn ( pSprite - > z - pSector - > ceilingz ) * SP ( spriteNum ) ;
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
{
2016-08-27 01:40:35 +00:00
if ( klabs ( pSector - > ceilingz - pData [ 1 ] ) < ( SP ( spriteNum ) < < 1 ) )
2006-04-13 20:47:06 +00:00
{
2016-08-27 01:40:35 +00:00
pData [ 0 ] = 0 ;
pData [ 2 ] = ! pData [ 2 ] ;
A_CallSound ( pSprite - > sectnum , spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2016-08-27 01:40:35 +00:00
else pSector - > ceilingz - = ksgn ( pSprite - > z - pData [ 1 ] ) * SP ( spriteNum ) ;
2006-04-13 20:47:06 +00:00
}
2011-06-29 19:57:05 +00:00
2016-08-27 01:40:35 +00:00
Yax_SetBunchZs ( pSector - sector , YAX_CEILING , pSector - > ceilingz ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2018-06-09 20:36:31 +00:00
# ifndef EDUKE32_STANDALONE
2012-08-26 22:16:08 +00:00
case SE_33_QUAKE_DEBRIS :
2020-01-29 11:37:16 +00:00
if ( ! FURY & & g_earthquakeTime > 0 & & ( krand ( ) & 7 ) = = 0 )
2016-08-27 01:40:35 +00:00
RANDOMSCRAP ( pSprite , spriteNum ) ;
2006-11-16 03:02:42 +00:00
break ;
2018-06-09 20:36:31 +00:00
# endif
2012-08-26 22:16:08 +00:00
case SE_36_PROJ_SHOOTER :
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] = = 1 )
A_Shoot ( spriteNum , pSector - > extra ) ;
else if ( pData [ 0 ] = = GAMETICSPERSEC * 5 )
pData [ 0 ] = 0 ;
pData [ 0 ] + + ;
2006-11-16 03:02:42 +00:00
}
break ;
2006-04-13 20:47:06 +00:00
2006-11-16 03:02:42 +00:00
case 128 : //SE to control glass breakage
{
2016-08-27 01:40:35 +00:00
walltype * pWall = & wall [ pData [ 2 ] ] ;
2020-05-18 04:35:33 +00:00
pWall - > cstat & = ( 255 - 32 ) ;
pWall - > cstat | = 16 ;
2016-08-27 01:40:35 +00:00
if ( pWall - > nextwall > = 0 )
{
2020-05-18 04:35:33 +00:00
wall [ pWall - > nextwall ] . cstat & = ( 255 - 32 ) ;
wall [ pWall - > nextwall ] . cstat | = 16 ;
2016-08-27 01:40:35 +00:00
}
2020-05-22 21:04:21 +00:00
pWall - > overpicnum + + ;
if ( pWall - > nextwall > = 0 )
wall [ pWall - > nextwall ] . overpicnum + + ;
if ( pData [ 0 ] < pData [ 1 ] ) pData [ 0 ] + + ;
else
{
pWall - > cstat & = ( 128 + 32 + 8 + 4 + 2 ) ;
if ( pWall - > nextwall > = 0 )
wall [ pWall - > nextwall ] . cstat & = ( 128 + 32 + 8 + 4 + 2 ) ;
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
}
2006-11-16 03:02:42 +00:00
}
break ;
2013-06-22 11:31:13 +00:00
case SE_130 :
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] > 80 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else pData [ 0 ] + + ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
x = pSector - > floorz - pSector - > ceilingz ;
2006-11-16 03:02:42 +00:00
if ( rnd ( 64 ) )
{
2016-08-27 01:40:35 +00:00
k = A_Spawn ( spriteNum , EXPLOSION2 ) ;
2008-11-20 14:06:36 +00:00
sprite [ k ] . xrepeat = sprite [ k ] . yrepeat = 2 + ( krand ( ) & 7 ) ;
2016-08-27 01:40:35 +00:00
sprite [ k ] . z = pSector - > floorz - ( krand ( ) % x ) ;
2008-11-20 14:06:36 +00:00
sprite [ k ] . ang + = 256 - ( krand ( ) % 511 ) ;
sprite [ k ] . xvel = krand ( ) & 127 ;
A_SetSprite ( k , CLIPMASK0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2013-04-15 10:48:09 +00:00
2013-06-22 11:31:13 +00:00
case SE_131 :
2016-08-27 01:40:35 +00:00
if ( pData [ 0 ] > 40 )
2006-11-16 03:02:42 +00:00
{
2016-08-27 01:41:33 +00:00
DELETE_SPRITE_AND_CONTINUE ( spriteNum ) ;
2006-11-16 03:02:42 +00:00
}
2016-08-27 01:40:35 +00:00
else pData [ 0 ] + + ;
2006-11-16 03:02:42 +00:00
2016-08-27 01:40:35 +00:00
x = pSector - > floorz - pSector - > ceilingz ;
2006-11-16 03:02:42 +00:00
if ( rnd ( 32 ) )
{
2016-08-27 01:40:35 +00:00
k = A_Spawn ( spriteNum , EXPLOSION2 ) ;
2008-11-20 14:06:36 +00:00
sprite [ k ] . xrepeat = sprite [ k ] . yrepeat = 2 + ( krand ( ) & 3 ) ;
2016-08-27 01:40:35 +00:00
sprite [ k ] . z = pSector - > floorz - ( krand ( ) % x ) ;
2008-11-20 14:06:36 +00:00
sprite [ k ] . ang + = 256 - ( krand ( ) % 511 ) ;
sprite [ k ] . xvel = krand ( ) & 127 ;
A_SetSprite ( k , CLIPMASK0 ) ;
2006-11-16 03:02:42 +00:00
}
break ;
2013-04-15 10:48:09 +00:00
2012-10-05 20:48:10 +00:00
case SE_49_POINT_LIGHT :
case SE_50_SPOT_LIGHT :
2016-08-27 01:40:35 +00:00
changespritestat ( spriteNum , STAT_LIGHT ) ;
2012-05-14 18:12:27 +00:00
break ;
2012-05-06 21:01:52 +00:00
}
2016-08-27 01:40:35 +00:00
next_sprite :
spriteNum = nextSprite ;
2012-05-06 21:01:52 +00:00
}
//Sloped sin-wave floors!
2016-08-27 01:40:35 +00:00
for ( SPRITES_OF ( STAT_EFFECTOR , spriteNum ) )
2012-05-06 21:01:52 +00:00
{
2019-07-08 00:41:25 +00:00
auto const s = & sprite [ spriteNum ] ;
2012-05-06 21:01:52 +00:00
2013-04-15 10:48:09 +00:00
if ( s - > lotag = = SE_29_WAVES )
{
2019-04-18 17:25:24 +00:00
auto const sc = ( usectorptr_t ) & sector [ s - > sectnum ] ;
2013-04-15 10:48:09 +00:00
if ( sc - > wallnum = = 4 )
{
2019-07-08 00:41:25 +00:00
auto const pWall = & wall [ sc - > wallptr + 2 ] ;
2016-08-27 01:40:35 +00:00
if ( pWall - > nextsector > = 0 )
alignflorslope ( s - > sectnum , pWall - > x , pWall - > y , sector [ pWall - > nextsector ] . floorz ) ;
2013-04-15 10:48:09 +00:00
}
}
2012-05-06 21:01:52 +00:00
}
}
2012-10-05 20:48:10 +00:00
static void G_DoEffectorLights ( void ) // STATNUM 14
2012-05-06 21:01:52 +00:00
{
2019-11-23 22:05:24 +00:00
# ifdef POLYMER
int32_t i ;
2012-04-13 10:46:04 +00:00
2013-04-15 10:48:09 +00:00
for ( SPRITES_OF ( STAT_LIGHT , i ) )
2012-05-06 21:01:52 +00:00
{
2019-11-23 22:05:24 +00:00
switch ( sprite [ i ] . lotag )
2012-05-06 21:01:52 +00:00
{
2012-10-05 20:48:10 +00:00
case SE_49_POINT_LIGHT :
2009-04-24 06:04:13 +00:00
{
2018-04-12 21:03:12 +00:00
if ( ! A_CheckSpriteFlags ( i , SFLAG_NOLIGHT ) & & videoGetRenderMode ( ) = = REND_POLYMER & &
2014-02-22 19:38:52 +00:00
! ( A_CheckSpriteFlags ( i , SFLAG_USEACTIVATOR ) & & sector [ sprite [ i ] . sectnum ] . lotag & 16384 ) )
2009-04-24 06:04:13 +00:00
{
2010-05-02 23:27:30 +00:00
if ( actor [ i ] . lightptr = = NULL )
2009-06-06 10:20:00 +00:00
{
2009-07-12 01:55:34 +00:00
# pragma pack(push,1)
2009-06-08 00:31:53 +00:00
_prlight mylight ;
2009-07-12 01:55:34 +00:00
# pragma pack(pop)
2016-08-27 01:40:35 +00:00
mylight . sector = SECT ( i ) ;
2009-07-12 01:55:34 +00:00
Bmemcpy ( & mylight , & sprite [ i ] , sizeof ( int32_t ) * 3 ) ;
2016-08-27 01:40:35 +00:00
mylight . range = SHT ( i ) ;
2009-07-12 01:55:34 +00:00
mylight . color [ 0 ] = sprite [ i ] . xvel ;
mylight . color [ 1 ] = sprite [ i ] . yvel ;
mylight . color [ 2 ] = sprite [ i ] . zvel ;
2009-06-08 00:31:53 +00:00
mylight . radius = 0 ;
2016-08-27 01:40:35 +00:00
mylight . angle = SA ( i ) ;
mylight . horiz = SH ( i ) ;
2009-06-08 00:31:53 +00:00
mylight . minshade = sprite [ i ] . xoffset ;
mylight . maxshade = sprite [ i ] . yoffset ;
2009-10-03 21:14:42 +00:00
mylight . tilenum = 0 ;
2012-10-21 03:41:13 +00:00
mylight . publicflags . emitshadow = 0 ;
2016-08-27 01:40:35 +00:00
mylight . publicflags . negative = ! ! ( CS ( i ) & 128 ) ;
2009-06-06 10:20:00 +00:00
2016-08-27 01:40:35 +00:00
if ( CS ( i ) & 2 )
2009-06-08 00:31:53 +00:00
{
2016-08-27 01:40:35 +00:00
if ( CS ( i ) & 512 )
2009-06-08 00:31:53 +00:00
mylight . priority = PR_LIGHT_PRIO_LOW ;
else
mylight . priority = PR_LIGHT_PRIO_HIGH ;
}
else
mylight . priority = PR_LIGHT_PRIO_MAX ;
2009-04-28 05:31:32 +00:00
2010-05-02 23:27:30 +00:00
actor [ i ] . lightId = polymer_addlight ( & mylight ) ;
if ( actor [ i ] . lightId > = 0 )
actor [ i ] . lightptr = & prlights [ actor [ i ] . lightId ] ;
2009-06-08 00:31:53 +00:00
break ;
}
2010-05-02 23:27:30 +00:00
if ( Bmemcmp ( & sprite [ i ] , actor [ i ] . lightptr , sizeof ( int32_t ) * 3 ) )
2009-06-08 00:31:53 +00:00
{
2010-05-02 23:27:30 +00:00
Bmemcpy ( actor [ i ] . lightptr , & sprite [ i ] , sizeof ( int32_t ) * 3 ) ;
actor [ i ] . lightptr - > sector = sprite [ i ] . sectnum ;
actor [ i ] . lightptr - > flags . invalidate = 1 ;
2009-06-08 00:31:53 +00:00
}
2016-08-27 01:40:35 +00:00
if ( SHT ( i ) ! = actor [ i ] . lightptr - > range )
2009-07-13 22:30:13 +00:00
{
2016-08-27 01:40:35 +00:00
actor [ i ] . lightptr - > range = SHT ( i ) ;
2010-05-02 23:27:30 +00:00
actor [ i ] . lightptr - > flags . invalidate = 1 ;
2009-07-13 22:30:13 +00:00
}
2010-05-02 23:27:30 +00:00
if ( ( sprite [ i ] . xvel ! = actor [ i ] . lightptr - > color [ 0 ] ) | |
( sprite [ i ] . yvel ! = actor [ i ] . lightptr - > color [ 1 ] ) | |
( sprite [ i ] . zvel ! = actor [ i ] . lightptr - > color [ 2 ] ) )
2009-07-13 22:30:13 +00:00
{
2010-05-02 23:27:30 +00:00
actor [ i ] . lightptr - > color [ 0 ] = sprite [ i ] . xvel ;
actor [ i ] . lightptr - > color [ 1 ] = sprite [ i ] . yvel ;
actor [ i ] . lightptr - > color [ 2 ] = sprite [ i ] . zvel ;
2009-07-13 22:30:13 +00:00
}
2016-08-27 01:40:35 +00:00
if ( ( int ) ! ! ( CS ( i ) & 128 ) ! = actor [ i ] . lightptr - > publicflags . negative ) {
actor [ i ] . lightptr - > publicflags . negative = ! ! ( CS ( i ) & 128 ) ;
2012-10-21 04:52:43 +00:00
}
2009-06-06 10:20:00 +00:00
}
2009-04-24 06:04:13 +00:00
break ;
}
2012-10-05 20:48:10 +00:00
case SE_50_SPOT_LIGHT :
2009-04-24 06:04:13 +00:00
{
2018-04-12 21:03:12 +00:00
if ( ! A_CheckSpriteFlags ( i , SFLAG_NOLIGHT ) & & videoGetRenderMode ( ) = = REND_POLYMER & &
2014-02-22 19:38:52 +00:00
! ( A_CheckSpriteFlags ( i , SFLAG_USEACTIVATOR ) & & sector [ sprite [ i ] . sectnum ] . lotag & 16384 ) )
2009-04-24 06:04:13 +00:00
{
2010-05-02 23:27:30 +00:00
if ( actor [ i ] . lightptr = = NULL )
2009-06-06 10:20:00 +00:00
{
2009-07-12 01:55:34 +00:00
# pragma pack(push,1)
2009-06-08 00:31:53 +00:00
_prlight mylight ;
2009-07-12 01:55:34 +00:00
# pragma pack(pop)
2009-06-06 10:20:00 +00:00
2016-08-27 01:40:35 +00:00
mylight . sector = SECT ( i ) ;
2009-07-12 01:55:34 +00:00
Bmemcpy ( & mylight , & sprite [ i ] , sizeof ( int32_t ) * 3 ) ;
2016-08-27 01:40:35 +00:00
mylight . range = SHT ( i ) ;
2009-07-12 01:55:34 +00:00
mylight . color [ 0 ] = sprite [ i ] . xvel ;
mylight . color [ 1 ] = sprite [ i ] . yvel ;
mylight . color [ 2 ] = sprite [ i ] . zvel ;
2016-08-27 01:40:35 +00:00
mylight . radius = ( 256 - ( SS ( i ) + 128 ) ) < < 1 ;
2009-07-12 01:55:34 +00:00
mylight . faderadius = ( int16_t ) ( mylight . radius * 0.75f ) ;
2016-08-27 01:40:35 +00:00
mylight . angle = SA ( i ) ;
mylight . horiz = SH ( i ) ;
2009-06-08 00:31:53 +00:00
mylight . minshade = sprite [ i ] . xoffset ;
mylight . maxshade = sprite [ i ] . yoffset ;
2010-07-22 20:29:09 +00:00
mylight . tilenum = actor [ i ] . picnum ;
2016-08-27 01:40:35 +00:00
mylight . publicflags . emitshadow = ! ( CS ( i ) & 64 ) ;
mylight . publicflags . negative = ! ! ( CS ( i ) & 128 ) ;
2009-06-06 10:20:00 +00:00
2016-08-27 01:40:35 +00:00
if ( CS ( i ) & 2 )
2009-06-08 00:31:53 +00:00
{
2016-08-27 01:40:35 +00:00
if ( CS ( i ) & 512 )
2009-06-08 00:31:53 +00:00
mylight . priority = PR_LIGHT_PRIO_LOW ;
else
mylight . priority = PR_LIGHT_PRIO_HIGH ;
}
else
mylight . priority = PR_LIGHT_PRIO_MAX ;
2009-04-28 05:31:32 +00:00
2010-05-02 23:27:30 +00:00
actor [ i ] . lightId = polymer_addlight ( & mylight ) ;
if ( actor [ i ] . lightId > = 0 )
2012-02-08 11:01:03 +00:00
{
2010-05-02 23:27:30 +00:00
actor [ i ] . lightptr = & prlights [ actor [ i ] . lightId ] ;
2011-10-02 07:09:04 +00:00
2012-02-08 11:01:03 +00:00
// Hack in case polymer_addlight tweaked the horiz value
2016-08-27 01:40:35 +00:00
if ( actor [ i ] . lightptr - > horiz ! = SH ( i ) )
SH ( i ) = actor [ i ] . lightptr - > horiz ;
2012-02-08 11:01:03 +00:00
}
2009-06-08 00:31:53 +00:00
break ;
}
2010-05-02 23:27:30 +00:00
if ( Bmemcmp ( & sprite [ i ] , actor [ i ] . lightptr , sizeof ( int32_t ) * 3 ) )
2009-06-08 00:31:53 +00:00
{
2010-05-02 23:27:30 +00:00
Bmemcpy ( actor [ i ] . lightptr , & sprite [ i ] , sizeof ( int32_t ) * 3 ) ;
actor [ i ] . lightptr - > sector = sprite [ i ] . sectnum ;
actor [ i ] . lightptr - > flags . invalidate = 1 ;
2009-06-08 00:31:53 +00:00
}
2016-08-27 01:40:35 +00:00
if ( SHT ( i ) ! = actor [ i ] . lightptr - > range )
2009-07-13 22:30:13 +00:00
{
2016-08-27 01:40:35 +00:00
actor [ i ] . lightptr - > range = SHT ( i ) ;
2010-05-02 23:27:30 +00:00
actor [ i ] . lightptr - > flags . invalidate = 1 ;
2009-07-13 22:30:13 +00:00
}
2010-05-02 23:27:30 +00:00
if ( ( sprite [ i ] . xvel ! = actor [ i ] . lightptr - > color [ 0 ] ) | |
( sprite [ i ] . yvel ! = actor [ i ] . lightptr - > color [ 1 ] ) | |
( sprite [ i ] . zvel ! = actor [ i ] . lightptr - > color [ 2 ] ) )
2009-07-13 22:30:13 +00:00
{
2010-05-02 23:27:30 +00:00
actor [ i ] . lightptr - > color [ 0 ] = sprite [ i ] . xvel ;
actor [ i ] . lightptr - > color [ 1 ] = sprite [ i ] . yvel ;
actor [ i ] . lightptr - > color [ 2 ] = sprite [ i ] . zvel ;
2009-07-13 22:30:13 +00:00
}
2016-08-27 01:40:35 +00:00
if ( ( ( 256 - ( SS ( i ) + 128 ) ) < < 1 ) ! = actor [ i ] . lightptr - > radius )
2009-07-13 22:30:13 +00:00
{
2016-08-27 01:40:35 +00:00
actor [ i ] . lightptr - > radius = ( 256 - ( SS ( i ) + 128 ) ) < < 1 ;
2010-05-02 23:27:30 +00:00
actor [ i ] . lightptr - > faderadius = ( int16_t ) ( actor [ i ] . lightptr - > radius * 0.75f ) ;
actor [ i ] . lightptr - > flags . invalidate = 1 ;
2009-07-13 22:30:13 +00:00
}
2016-08-27 01:40:35 +00:00
if ( SA ( i ) ! = actor [ i ] . lightptr - > angle )
2009-07-13 22:30:13 +00:00
{
2016-08-27 01:40:35 +00:00
actor [ i ] . lightptr - > angle = SA ( i ) ;
2010-05-02 23:27:30 +00:00
actor [ i ] . lightptr - > flags . invalidate = 1 ;
2009-07-13 22:30:13 +00:00
}
2016-08-27 01:40:35 +00:00
if ( SH ( i ) ! = actor [ i ] . lightptr - > horiz )
2009-07-13 22:30:13 +00:00
{
2016-08-27 01:40:35 +00:00
actor [ i ] . lightptr - > horiz = SH ( i ) ;
2010-05-02 23:27:30 +00:00
actor [ i ] . lightptr - > flags . invalidate = 1 ;
2009-07-13 22:30:13 +00:00
}
2016-08-27 01:40:35 +00:00
if ( ( int ) ! ( CS ( i ) & 64 ) ! = actor [ i ] . lightptr - > publicflags . emitshadow ) {
actor [ i ] . lightptr - > publicflags . emitshadow = ! ( CS ( i ) & 64 ) ;
2012-10-21 03:41:13 +00:00
}
2016-08-27 01:40:35 +00:00
if ( ( int ) ! ! ( CS ( i ) & 128 ) ! = actor [ i ] . lightptr - > publicflags . negative ) {
actor [ i ] . lightptr - > publicflags . negative = ! ! ( CS ( i ) & 128 ) ;
2012-10-21 04:52:43 +00:00
}
2010-05-02 23:27:30 +00:00
actor [ i ] . lightptr - > tilenum = actor [ i ] . picnum ;
2009-04-29 19:43:51 +00:00
}
2009-04-28 05:31:32 +00:00
2009-04-24 06:04:13 +00:00
break ;
}
2006-04-13 20:47:06 +00:00
}
}
2019-11-23 22:05:24 +00:00
# endif // POLYMER
2006-04-13 20:47:06 +00:00
}
2012-10-05 20:48:10 +00:00
# ifdef POLYMER
2016-08-27 01:41:46 +00:00
static void A_DoLight ( int spriteNum )
2012-10-05 20:48:10 +00:00
{
2019-07-08 00:41:25 +00:00
auto const pSprite = & sprite [ spriteNum ] ;
2016-08-27 01:41:46 +00:00
int savedFires = 0 ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
if ( ( ( sector [ pSprite - > sectnum ] . floorz - sector [ pSprite - > sectnum ] . ceilingz ) < 16 ) | | pSprite - > z > sector [ pSprite - > sectnum ] . floorz | | pSprite - > z > actor [ spriteNum ] . floorz | |
( pSprite - > picnum ! = SECTOREFFECTOR & & ( ( pSprite - > cstat & 32768 ) | | pSprite - > yrepeat < 4 ) ) | |
A_CheckSpriteFlags ( spriteNum , SFLAG_NOLIGHT ) | | ( A_CheckSpriteFlags ( spriteNum , SFLAG_USEACTIVATOR ) & & sector [ pSprite - > sectnum ] . lotag & 16384 ) )
2012-10-05 20:48:10 +00:00
{
2016-08-27 01:41:46 +00:00
if ( actor [ spriteNum ] . lightptr ! = NULL )
A_DeleteLight ( spriteNum ) ;
2012-10-05 20:48:10 +00:00
}
else
{
2016-08-27 01:41:46 +00:00
if ( actor [ spriteNum ] . lightptr ! = NULL & & actor [ spriteNum ] . lightcount )
2012-10-05 20:48:10 +00:00
{
2016-08-27 01:41:46 +00:00
if ( ! ( - - actor [ spriteNum ] . lightcount ) )
A_DeleteLight ( spriteNum ) ;
2012-10-05 20:48:10 +00:00
}
2015-10-23 23:00:21 +00:00
if ( pr_lighting ! = 1 )
return ;
2019-05-19 03:55:36 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( FURY )
return ;
2019-05-19 03:56:13 +00:00
for ( int ii = 0 ; ii < 2 ; ii + + )
2012-10-05 20:48:10 +00:00
{
2016-08-27 01:41:46 +00:00
if ( pSprite - > picnum < = 0 ) // oob safety
2012-10-05 20:48:10 +00:00
break ;
2016-08-27 01:41:46 +00:00
switch ( DYNAMICTILEMAP ( pSprite - > picnum - 1 + ii ) )
2012-10-05 20:48:10 +00:00
{
case DIPSWITCH__STATIC :
case DIPSWITCH2__STATIC :
case DIPSWITCH3__STATIC :
case PULLSWITCH__STATIC :
case SLOTDOOR__STATIC :
case LIGHTSWITCH__STATIC :
case SPACELIGHTSWITCH__STATIC :
case SPACEDOORSWITCH__STATIC :
case FRANKENSTINESWITCH__STATIC :
case POWERSWITCH1__STATIC :
case LOCKSWITCH1__STATIC :
case POWERSWITCH2__STATIC :
case TECHSWITCH__STATIC :
case ACCESSSWITCH__STATIC :
case ACCESSSWITCH2__STATIC :
{
2016-08-27 01:41:46 +00:00
if ( ( pSprite - > cstat & 32768 ) | | A_CheckSpriteFlags ( spriteNum , SFLAG_NOLIGHT ) )
2012-10-05 20:48:10 +00:00
{
2016-08-27 01:41:46 +00:00
if ( actor [ spriteNum ] . lightptr ! = NULL )
A_DeleteLight ( spriteNum ) ;
2012-10-05 20:48:10 +00:00
break ;
}
2016-08-27 01:41:46 +00:00
vec2_t const d = { sintable [ ( pSprite - > ang + 512 ) & 2047 ] > > 7 , sintable [ ( pSprite - > ang ) & 2047 ] > > 7 } ;
2015-12-23 04:05:31 +00:00
2016-08-27 01:41:46 +00:00
pSprite - > x + = d . x ;
pSprite - > y + = d . y ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
int16_t sectnum = pSprite - > sectnum ;
updatesector ( pSprite - > x , pSprite - > y , & sectnum ) ;
2015-10-23 23:00:13 +00:00
2016-08-27 01:41:46 +00:00
if ( ( unsigned ) sectnum > = MAXSECTORS | | pSprite - > z > sector [ sectnum ] . floorz | | pSprite - > z < sector [ sectnum ] . ceilingz )
2015-12-23 04:05:31 +00:00
goto POOP ;
2015-10-23 23:00:13 +00:00
2016-08-27 01:41:46 +00:00
G_AddGameLight ( 0 , spriteNum , ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 , 512 - ii * 128 ,
2016-04-13 04:04:13 +00:00
ii = = 0 ? ( 172 + ( 200 < < 8 ) + ( 104 < < 16 ) ) : 216 + ( 52 < < 8 ) + ( 20 < < 16 ) , PR_LIGHT_PRIO_LOW ) ;
2012-10-05 20:48:10 +00:00
2015-12-23 04:05:31 +00:00
POOP :
2016-08-27 01:41:46 +00:00
pSprite - > x - = d . x ;
pSprite - > y - = d . y ;
2015-12-23 04:05:31 +00:00
}
2012-10-05 20:48:10 +00:00
break ;
}
}
2016-08-27 01:41:46 +00:00
switch ( DYNAMICTILEMAP ( pSprite - > picnum ) )
2012-10-05 20:48:10 +00:00
{
case ATOMICHEALTH__STATIC :
2016-08-27 01:41:46 +00:00
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , LIGHTRAD2 ( spriteNum , pSprite ) , 128 + ( 128 < < 8 ) + ( 255 < < 16 ) , PR_LIGHT_PRIO_HIGH_GAME ) ;
2012-10-05 20:48:10 +00:00
break ;
case FIRE__STATIC :
case FIRE2__STATIC :
case BURNING__STATIC :
case BURNING2__STATIC :
{
uint32_t color ;
int32_t jj ;
static int32_t savedfires [ 32 ] [ 4 ] ; // sectnum x y z
/*
if ( Actor [ i ] . floorz - Actor [ i ] . ceilingz < 128 ) break ;
if ( s - > z > Actor [ i ] . floorz + 2048 ) break ;
*/
2016-08-27 01:41:46 +00:00
switch ( pSprite - > pal )
2012-10-05 20:48:10 +00:00
{
case 1 : color = 128 + ( 128 < < 8 ) + ( 255 < < 16 ) ; break ;
case 2 : color = 255 + ( 48 < < 8 ) + ( 48 < < 16 ) ; break ;
case 8 : color = 48 + ( 255 < < 8 ) + ( 48 < < 16 ) ; break ;
2015-12-23 04:05:31 +00:00
default : color = 240 + ( 160 < < 8 ) + ( 80 < < 16 ) ; break ;
2012-10-05 20:48:10 +00:00
}
2016-08-27 01:41:46 +00:00
for ( jj = savedFires - 1 ; jj > = 0 ; jj - - )
if ( savedfires [ jj ] [ 0 ] = = pSprite - > sectnum & & savedfires [ jj ] [ 1 ] = = ( pSprite - > x > > 3 ) & &
savedfires [ jj ] [ 2 ] = = ( pSprite - > y > > 3 ) & & savedfires [ jj ] [ 3 ] = = ( pSprite - > z > > 7 ) )
2012-10-05 20:48:10 +00:00
break ;
2016-08-27 01:41:46 +00:00
if ( jj = = - 1 & & savedFires < 32 )
2012-10-05 20:48:10 +00:00
{
2016-08-27 01:41:46 +00:00
jj = savedFires ;
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , LIGHTRAD2 ( spriteNum , pSprite ) , color , PR_LIGHT_PRIO_HIGH_GAME ) ;
savedfires [ jj ] [ 0 ] = pSprite - > sectnum ;
savedfires [ jj ] [ 1 ] = pSprite - > x > > 3 ;
savedfires [ jj ] [ 2 ] = pSprite - > y > > 3 ;
savedfires [ jj ] [ 3 ] = pSprite - > z > > 7 ;
savedFires + + ;
2012-10-05 20:48:10 +00:00
}
}
break ;
case OOZFILTER__STATIC :
2016-08-27 01:41:46 +00:00
if ( pSprite - > xrepeat > 4 )
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , 4096 , 176 + ( 252 < < 8 ) + ( 120 < < 16 ) , PR_LIGHT_PRIO_HIGH_GAME ) ;
2012-10-05 20:48:10 +00:00
break ;
case FLOORFLAME__STATIC :
case FIREBARREL__STATIC :
case FIREVASE__STATIC :
2016-08-27 01:41:46 +00:00
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 2 ) , LIGHTRAD2 ( spriteNum , pSprite ) > > 1 , 255 + ( 95 < < 8 ) , PR_LIGHT_PRIO_HIGH_GAME ) ;
2012-10-05 20:48:10 +00:00
break ;
case EXPLOSION2__STATIC :
2016-08-27 01:41:46 +00:00
if ( ! actor [ spriteNum ] . lightcount )
2012-10-05 20:48:10 +00:00
{
2013-04-15 10:48:09 +00:00
// XXX: This block gets CODEDUP'd too much.
2016-08-27 01:41:46 +00:00
int32_t x = ( ( sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) > > 6 ) ;
int32_t y = ( ( sintable [ ( pSprite - > ang ) & 2047 ] ) > > 6 ) ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
pSprite - > x - = x ;
pSprite - > y - = y ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , LIGHTRAD ( spriteNum , pSprite ) , 240 + ( 160 < < 8 ) + ( 80 < < 16 ) ,
pSprite - > yrepeat > 32 ? PR_LIGHT_PRIO_HIGH_GAME : PR_LIGHT_PRIO_LOW_GAME ) ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
pSprite - > x + = x ;
pSprite - > y + = y ;
2012-10-05 20:48:10 +00:00
}
break ;
case FORCERIPPLE__STATIC :
case TRANSPORTERBEAM__STATIC :
2016-08-27 01:41:46 +00:00
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , LIGHTRAD ( spriteNum , pSprite ) , 80 + ( 80 < < 8 ) + ( 255 < < 16 ) , PR_LIGHT_PRIO_LOW_GAME ) ;
2012-10-05 20:48:10 +00:00
break ;
case GROWSPARK__STATIC :
{
2016-08-27 01:41:46 +00:00
int32_t x = ( ( sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) > > 6 ) ;
int32_t y = ( ( sintable [ ( pSprite - > ang ) & 2047 ] ) > > 6 ) ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
pSprite - > x - = x ;
pSprite - > y - = y ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , 1024 , 216 + ( 52 < < 8 ) + ( 20 < < 16 ) , PR_LIGHT_PRIO_HIGH_GAME ) ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
pSprite - > x + = x ;
pSprite - > y + = y ;
2012-10-05 20:48:10 +00:00
}
break ;
case SHRINKEREXPLOSION__STATIC :
{
2016-08-27 01:41:46 +00:00
int32_t x = ( ( sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) > > 6 ) ;
int32_t y = ( ( sintable [ ( pSprite - > ang ) & 2047 ] ) > > 6 ) ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
pSprite - > x - = x ;
pSprite - > y - = y ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , 2048 , 176 + ( 252 < < 8 ) + ( 120 < < 16 ) , PR_LIGHT_PRIO_HIGH_GAME ) ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
pSprite - > x + = x ;
pSprite - > y + = y ;
2012-10-05 20:48:10 +00:00
}
break ;
case FREEZEBLAST__STATIC :
2016-08-27 01:41:46 +00:00
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , LIGHTRAD ( spriteNum , pSprite ) < < 2 , 72 + ( 88 < < 8 ) + ( 140 < < 16 ) , PR_LIGHT_PRIO_HIGH_GAME ) ;
2012-10-05 20:48:10 +00:00
break ;
case COOLEXPLOSION1__STATIC :
2016-08-27 01:41:46 +00:00
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , LIGHTRAD ( spriteNum , pSprite ) < < 2 , 128 + ( 0 < < 8 ) + ( 255 < < 16 ) , PR_LIGHT_PRIO_HIGH_GAME ) ;
2012-10-05 20:48:10 +00:00
break ;
case SHRINKSPARK__STATIC :
2016-08-27 01:41:46 +00:00
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , LIGHTRAD ( spriteNum , pSprite ) , 176 + ( 252 < < 8 ) + ( 120 < < 16 ) , PR_LIGHT_PRIO_HIGH_GAME ) ;
2012-10-05 20:48:10 +00:00
break ;
case FIRELASER__STATIC :
2016-08-27 01:41:46 +00:00
if ( pSprite - > statnum = = STAT_PROJECTILE )
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , 64 * pSprite - > yrepeat , 255 + ( 95 < < 8 ) , PR_LIGHT_PRIO_LOW_GAME ) ;
2012-10-05 20:48:10 +00:00
break ;
case RPG__STATIC :
2016-08-27 01:41:46 +00:00
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , 128 * pSprite - > yrepeat , 255 + ( 95 < < 8 ) , PR_LIGHT_PRIO_LOW_GAME ) ;
2012-10-05 20:48:10 +00:00
break ;
case SHOTSPARK1__STATIC :
2016-08-27 01:41:46 +00:00
if ( actor [ spriteNum ] . t_data [ 2 ] = = 0 ) // check for first frame of action
2012-10-05 20:48:10 +00:00
{
2016-08-27 01:41:46 +00:00
int32_t x = ( ( sintable [ ( pSprite - > ang + 512 ) & 2047 ] ) > > 7 ) ;
int32_t y = ( ( sintable [ ( pSprite - > ang ) & 2047 ] ) > > 7 ) ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
pSprite - > x - = x ;
pSprite - > y - = y ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
G_AddGameLight ( 0 , spriteNum , ( ( pSprite - > yrepeat * tilesiz [ pSprite - > picnum ] . y ) < < 1 ) , 8 * pSprite - > yrepeat , 240 + ( 160 < < 8 ) + ( 80 < < 16 ) , PR_LIGHT_PRIO_LOW_GAME ) ;
actor [ spriteNum ] . lightcount = 1 ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
pSprite - > x + = x ;
pSprite - > y + = y ;
2012-10-05 20:48:10 +00:00
}
break ;
}
2019-05-19 03:55:36 +00:00
# endif
2012-10-05 20:48:10 +00:00
}
}
# endif // POLYMER
2016-08-27 01:42:01 +00:00
void A_PlayAlertSound ( int spriteNum )
2008-11-20 14:06:36 +00:00
{
2016-08-27 01:42:01 +00:00
if ( sprite [ spriteNum ] . extra > 0 )
{
2017-12-10 03:24:47 +00:00
if ( ( VM_OnEventWithReturn ( EVENT_RECOGSOUND , spriteNum , screenpeek , 0 ) ) ! = 0 )
2017-11-29 07:29:40 +00:00
return ;
2018-04-04 20:48:15 +00:00
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( FURY )
return ;
2016-08-27 01:42:01 +00:00
switch ( DYNAMICTILEMAP ( PN ( spriteNum ) ) )
2008-11-20 14:06:36 +00:00
{
2016-08-27 01:42:01 +00:00
case LIZTROOPONTOILET__STATIC :
case LIZTROOPJUSTSIT__STATIC :
case LIZTROOPSHOOT__STATIC :
case LIZTROOPJETPACK__STATIC :
case LIZTROOPDUCKING__STATIC :
case LIZTROOPRUNNING__STATIC :
case LIZTROOP__STATIC : A_PlaySound ( PRED_RECOG , spriteNum ) ; break ;
case LIZMAN__STATIC :
case LIZMANSPITTING__STATIC :
case LIZMANFEEDING__STATIC :
case LIZMANJUMP__STATIC : A_PlaySound ( CAPT_RECOG , spriteNum ) ; break ;
case PIGCOP__STATIC :
case PIGCOPDIVE__STATIC : A_PlaySound ( PIG_RECOG , spriteNum ) ; break ;
case RECON__STATIC : A_PlaySound ( RECO_RECOG , spriteNum ) ; break ;
case DRONE__STATIC : A_PlaySound ( DRON_RECOG , spriteNum ) ; break ;
case COMMANDER__STATIC :
case COMMANDERSTAYPUT__STATIC : A_PlaySound ( COMM_RECOG , spriteNum ) ; break ;
case ORGANTIC__STATIC : A_PlaySound ( TURR_RECOG , spriteNum ) ; break ;
case OCTABRAIN__STATIC :
case OCTABRAINSTAYPUT__STATIC : A_PlaySound ( OCTA_RECOG , spriteNum ) ; break ;
case BOSS1__STATIC :
case BOSS1STAYPUT__STATIC : S_PlaySound ( BOS1_RECOG ) ; break ;
case BOSS2__STATIC : S_PlaySound ( ( sprite [ spriteNum ] . pal ! = 0 ) ? BOS2_RECOG : WHIPYOURASS ) ; break ;
case BOSS3__STATIC : S_PlaySound ( ( sprite [ spriteNum ] . pal ! = 0 ) ? BOS3_RECOG : RIPHEADNECK ) ; break ;
case BOSS4__STATIC :
case BOSS4STAYPUT__STATIC : S_PlaySound ( ( sprite [ spriteNum ] . pal ! = 0 ) ? BOS4_RECOG : BOSS4_FIRSTSEE ) ; break ;
case GREENSLIME__STATIC : A_PlaySound ( SLIM_RECOG , spriteNum ) ; break ;
2008-11-20 14:06:36 +00:00
}
2018-04-04 20:48:15 +00:00
# endif
2016-08-27 01:42:01 +00:00
}
2008-11-20 14:06:36 +00:00
}
2016-08-27 01:42:01 +00:00
int A_CheckSwitchTile ( int spriteNum )
2008-11-20 14:06:36 +00:00
{
2019-05-19 03:55:36 +00:00
UNREFERENCED_PARAMETER ( spriteNum ) ;
# ifndef EDUKE32_STANDALONE
2020-01-29 11:37:16 +00:00
if ( FURY )
return 0 ;
2016-06-21 00:34:07 +00:00
// picnum 0 would oob in the switch below,
2016-11-14 23:47:11 +00:00
if ( PN ( spriteNum ) < = 0 )
return 0 ;
2016-06-21 00:34:07 +00:00
// MULTISWITCH has 4 states so deal with it separately,
2013-04-15 10:48:09 +00:00
// ACCESSSWITCH and ACCESSSWITCH2 are only active in one state so deal with
// them separately.
2016-06-21 00:34:07 +00:00
2016-11-14 23:47:11 +00:00
if ( ( PN ( spriteNum ) > = MULTISWITCH & & PN ( spriteNum ) < = MULTISWITCH + 3 ) | | ( PN ( spriteNum ) = = ACCESSSWITCH | | PN ( spriteNum ) = = ACCESSSWITCH2 ) )
2014-02-22 19:38:47 +00:00
return 1 ;
2013-04-15 10:48:09 +00:00
// Loop to catch both states of switches.
2016-08-27 01:41:21 +00:00
for ( bssize_t j = 1 ; j > = 0 ; j - - )
2008-11-20 14:06:36 +00:00
{
2016-08-27 01:42:01 +00:00
switch ( DYNAMICTILEMAP ( PN ( spriteNum ) - j ) )
2008-11-20 14:06:36 +00:00
{
case HANDPRINTSWITCH__STATIC :
case ALIENSWITCH__STATIC :
case MULTISWITCH__STATIC :
case PULLSWITCH__STATIC :
case HANDSWITCH__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 DIPSWITCH__STATIC :
case DIPSWITCH2__STATIC :
case TECHSWITCH__STATIC :
case DIPSWITCH3__STATIC :
return 1 ;
}
}
2019-05-19 03:55:36 +00:00
# endif
2008-11-20 14:06:36 +00:00
return 0 ;
}
2016-04-13 04:04:13 +00:00
void G_RefreshLights ( void )
2015-10-23 23:00:21 +00:00
{
# ifdef POLYMER
2018-04-12 21:03:12 +00:00
if ( Numsprites & & videoGetRenderMode ( ) = = REND_POLYMER )
2015-10-23 23:00:21 +00:00
{
2016-08-27 01:41:46 +00:00
int statNum = 0 ;
2015-10-23 23:00:21 +00:00
do
{
2016-08-27 01:41:46 +00:00
int spriteNum = headspritestat [ statNum + + ] ;
2015-10-23 23:00:21 +00:00
2016-08-27 01:41:46 +00:00
while ( spriteNum > = 0 )
2015-10-23 23:00:21 +00:00
{
2016-08-27 01:41:46 +00:00
A_DoLight ( spriteNum ) ;
spriteNum = nextspritestat [ spriteNum ] ;
2015-10-23 23:00:21 +00:00
}
2016-08-27 01:41:46 +00:00
}
while ( statNum < MAXSTATUS ) ;
2015-10-23 23:00:21 +00:00
}
# endif
}
2020-03-12 00:58:32 +00:00
static void G_RecordOldSpritePos ( void )
{
int statNum = 0 ;
do
{
int spriteNum = headspritestat [ statNum + + ] ;
while ( spriteNum > = 0 )
{
int const nextSprite = nextspritestat [ spriteNum ] ;
actor [ spriteNum ] . bpos = sprite [ spriteNum ] . pos ;
spriteNum = nextSprite ;
}
}
while ( statNum < MAXSTATUS ) ;
}
2017-12-01 01:49:00 +00:00
static void G_DoEventGame ( int const nEventID )
2006-12-10 03:15:56 +00:00
{
2017-03-20 20:29:57 +00:00
if ( VM_HaveEvent ( nEventID ) )
2012-08-27 03:49:55 +00:00
{
2016-08-27 01:41:46 +00:00
int statNum = 0 ;
2012-10-05 20:48:10 +00:00
2014-10-25 03:36:34 +00:00
do
2012-08-27 03:49:55 +00:00
{
2016-08-27 01:41:46 +00:00
int spriteNum = headspritestat [ statNum + + ] ;
2012-08-27 03:49:55 +00:00
2016-08-27 01:41:46 +00:00
while ( spriteNum > = 0 )
2012-08-27 03:49:55 +00:00
{
2016-08-27 01:41:46 +00:00
int const nextSprite = nextspritestat [ spriteNum ] ;
2012-10-05 20:48:10 +00:00
2016-08-27 01:41:46 +00:00
if ( A_CheckSpriteFlags ( spriteNum , SFLAG_NOEVENTCODE ) )
2014-10-25 03:36:34 +00:00
{
2016-08-27 01:41:46 +00:00
spriteNum = nextSprite ;
2014-10-25 03:36:34 +00:00
continue ;
}
2013-04-15 10:48:09 +00:00
2016-08-27 01:41:46 +00:00
int32_t playerDist ;
int const playerNum = A_FindPlayer ( & sprite [ spriteNum ] , & playerDist ) ;
2019-05-19 03:53:25 +00:00
VM_ExecuteEvent ( nEventID , spriteNum , playerNum , playerDist ) ;
2014-10-25 03:36:34 +00:00
2016-08-27 01:41:46 +00:00
spriteNum = nextSprite ;
2014-10-25 03:36:34 +00:00
}
2016-08-27 01:41:46 +00:00
}
while ( statNum < MAXSTATUS ) ;
2012-08-27 03:49:55 +00:00
}
2017-03-20 20:29:57 +00:00
}
void G_MoveWorld ( void )
{
2018-03-08 00:29:41 +00:00
extern double g_moveActorsTime , g_moveWorldTime ;
2018-04-12 21:02:51 +00:00
const double worldTime = timerGetHiTicks ( ) ;
2017-03-20 20:29:57 +00:00
2019-06-25 11:30:17 +00:00
VM_OnEvent ( EVENT_PREWORLD ) ;
2017-03-20 20:29:57 +00:00
G_DoEventGame ( EVENT_PREGAME ) ;
2012-08-27 03:49:55 +00:00
2020-03-12 00:58:32 +00:00
G_RecordOldSpritePos ( ) ;
2008-11-20 14:06:36 +00:00
G_MoveZombieActors ( ) ; //ST 2
G_MoveWeapons ( ) ; //ST 4
G_MoveTransports ( ) ; //ST 9
2006-12-10 03:15:56 +00:00
2008-11-20 14:06:36 +00:00
G_MovePlayers ( ) ; //ST 10
G_MoveFallers ( ) ; //ST 12
G_MoveMisc ( ) ; //ST 5
2006-12-10 03:15:56 +00:00
2018-04-12 21:02:51 +00:00
const double actorsTime = timerGetHiTicks ( ) ;
2013-07-13 21:04:47 +00:00
2016-06-21 00:34:07 +00:00
G_MoveActors ( ) ; //ST 1
2013-07-13 21:04:47 +00:00
2018-04-12 21:02:51 +00:00
g_moveActorsTime = ( 1 - 0.033 ) * g_moveActorsTime + 0.033 * ( timerGetHiTicks ( ) - actorsTime ) ;
2012-05-06 21:01:52 +00:00
// XXX: Has to be before effectors, in particular movers?
// TODO: lights in moving sectors ought to be interpolated
2012-10-05 20:48:10 +00:00
G_DoEffectorLights ( ) ;
2008-11-20 14:06:36 +00:00
G_MoveEffectors ( ) ; //ST 3
G_MoveStandables ( ) ; //ST 6
2006-12-10 03:15:56 +00:00
2012-10-05 20:48:10 +00:00
2019-06-25 11:30:17 +00:00
VM_OnEvent ( EVENT_WORLD ) ;
2015-03-27 12:29:05 +00:00
2017-03-20 20:29:57 +00:00
G_DoEventGame ( EVENT_GAME ) ;
2012-10-05 20:48:10 +00:00
2016-04-13 04:04:13 +00:00
G_RefreshLights ( ) ;
2008-11-20 14:06:36 +00:00
G_DoSectorAnimations ( ) ;
G_MoveFX ( ) ; //ST 11
2018-03-08 00:29:41 +00:00
2018-04-12 21:02:51 +00:00
g_moveWorldTime = ( 1 - 0.033 ) * g_moveWorldTime + 0.033 * ( timerGetHiTicks ( ) - worldTime ) ;
2006-12-10 03:15:56 +00:00
}
2019-09-21 20:53:00 +00:00
END_DUKE_NS