2020-05-14 10:14:03 +00:00
//-------------------------------------------------------------------------
/*
Copyright ( C ) 1996 , 2003 - 3 D Realms Entertainment
Copyright ( C ) 2000 , 2003 - Matt Saettler ( EDuke Enhancements )
2020-06-28 07:03:31 +00:00
Copyright ( C ) 2020 - Christoph Oelckers
2020-05-14 10:14:03 +00:00
This file is part of Enhanced Duke Nukem 3 D version 1.5 - Atomic Edition
Duke Nukem 3 D is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation ; either version 2
of the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
Original Source : 1996 - Todd Replogle
Prepared for public release : 03 / 21 / 2003 - Charlie Wiederhold , 3 D Realms
EDuke enhancements integrated : 04 / 13 / 2003 - Matt Saettler
Note : EDuke source was in transition . Changes are in - progress in the
source as it is released .
*/
//-------------------------------------------------------------------------
# include "ns.h"
# include "global.h"
2020-05-16 21:55:21 +00:00
# include "gamevar.h"
2020-07-03 21:56:14 +00:00
# include "names_d.h"
2020-10-21 17:38:53 +00:00
# include "dukeactor.h"
2020-05-14 10:14:03 +00:00
BEGIN_DUKE_NS
2020-05-18 22:26:07 +00:00
void fireweapon_ww ( int snum ) ;
2020-08-30 22:33:41 +00:00
void operateweapon_ww ( int snum , ESyncBits actions , int psect ) ;
2020-05-18 22:26:07 +00:00
2020-05-16 21:55:21 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void incur_damage_d ( struct player_struct * p )
{
int damage = 0L , shield_damage = 0L ;
2020-10-23 19:40:49 +00:00
p - > GetActor ( ) - > s . extra - = p - > extra_extra8 > > 8 ;
2020-05-16 21:55:21 +00:00
2020-10-23 19:40:49 +00:00
damage = p - > GetActor ( ) - > s . extra - p - > last_extra ;
2020-05-16 21:55:21 +00:00
if ( damage < 0 )
{
p - > extra_extra8 = 0 ;
if ( p - > shield_amount > 0 )
{
shield_damage = damage * ( 20 + ( rand ( ) % 30 ) ) / 100 ;
damage - = shield_damage ;
p - > shield_amount + = shield_damage ;
if ( p - > shield_amount < 0 )
{
damage + = p - > shield_amount ;
p - > shield_amount = 0 ;
}
}
2020-10-23 19:40:49 +00:00
p - > GetActor ( ) - > s . extra = p - > last_extra + damage ;
2020-05-16 21:55:21 +00:00
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-23 18:16:47 +00:00
static void shootfireball ( DDukeActor * actor , int p , int sx , int sy , int sz , int sa )
2020-05-16 21:55:21 +00:00
{
2020-10-23 18:16:47 +00:00
auto s = & actor - > s ;
2020-10-20 22:17:09 +00:00
int vel , zvel ;
if ( s - > extra > = 0 )
s - > shade = - 96 ;
sz - = ( 4 < < 7 ) ;
2020-10-23 18:16:47 +00:00
if ( s - > picnum ! = BOSS5 )
2020-10-20 22:17:09 +00:00
vel = 840 ;
else {
vel = 968 ;
sz + = 6144 ;
}
if ( p < 0 )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
sa + = 16 - ( krand ( ) & 31 ) ;
int scratch ;
2020-11-02 22:10:19 +00:00
int j = findplayer ( actor , & scratch ) ;
2020-10-23 18:16:47 +00:00
zvel = ( ( ( ps [ j ] . oposz - sz + ( 3 < < 8 ) ) ) * vel ) / ldist ( ps [ j ] . GetActor ( ) , actor ) ;
2020-05-16 21:55:21 +00:00
}
else
{
2020-10-20 22:17:09 +00:00
zvel = - mulscale16 ( ps [ p ] . horizon . sum ( ) . asq16 ( ) , 98 ) ;
2020-11-15 11:07:03 +00:00
sx + = bcos ( sa + 348 ) / 448 ;
sy + = bsin ( sa + 348 ) / 448 ;
2020-10-20 22:17:09 +00:00
sz + = ( 3 < < 8 ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
int sizx = 18 ;
int sizy = 18 ;
if ( p > = 0 )
2020-09-17 21:02:52 +00:00
{
2020-10-20 22:17:09 +00:00
sizx = 7 ;
sizy = 7 ;
}
2020-10-23 18:16:47 +00:00
auto spawned = EGS ( s - > sectnum , sx , sy , sz , FIREBALL , - 127 , sizx , sizy , sa , vel , zvel , actor , ( short ) 4 ) ;
auto spr = & spawned - > s ;
2020-10-20 22:17:09 +00:00
spr - > extra + = ( krand ( ) & 7 ) ;
2020-10-23 18:16:47 +00:00
if ( s - > picnum = = BOSS5 | | p > = 0 )
2020-10-20 22:17:09 +00:00
{
spr - > xrepeat = 40 ;
spr - > yrepeat = 40 ;
2020-09-17 21:02:52 +00:00
}
2020-10-20 22:17:09 +00:00
spr - > yvel = p ;
spr - > cstat = 128 ;
spr - > clipdist = 4 ;
}
2020-09-17 21:02:52 +00:00
2020-10-20 22:17:09 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-09-17 21:02:52 +00:00
2020-10-23 18:16:47 +00:00
static void shootflamethrowerflame ( DDukeActor * actor , int p , int sx , int sy , int sz , int sa )
2020-10-20 22:17:09 +00:00
{
2020-10-23 18:16:47 +00:00
auto s = & actor - > s ;
2020-10-20 22:17:09 +00:00
int vel , zvel ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( s - > extra > = 0 )
s - > shade = - 96 ;
vel = 400 ;
2020-10-23 18:16:47 +00:00
DDukeActor * spawned = nullptr ;
2020-10-20 22:17:09 +00:00
if ( p < 0 )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
int x ;
2020-10-23 18:16:47 +00:00
int j = findplayer ( actor , & x ) ;
2020-10-20 22:17:09 +00:00
sa = getangle ( ps [ j ] . oposx - sx , ps [ j ] . oposy - sy ) ;
2020-05-16 21:55:21 +00:00
2020-10-23 18:16:47 +00:00
if ( s - > picnum = = BOSS5 )
2020-10-20 22:17:09 +00:00
{
vel = 528 ;
sz + = 6144 ;
}
2020-10-23 18:16:47 +00:00
else if ( s - > picnum = = BOSS3 )
2020-10-20 22:17:09 +00:00
sz - = 8192 ;
2020-05-16 21:55:21 +00:00
2020-10-23 18:16:47 +00:00
int l = ldist ( ps [ j ] . GetActor ( ) , actor ) ;
2020-10-20 22:17:09 +00:00
if ( l ! = 0 )
zvel = ( ( ps [ j ] . oposz - sz ) * vel ) / l ;
2020-10-23 18:16:47 +00:00
if ( badguy ( actor ) & & ( s - > hitag & face_player_smart ) ! = 0 )
2020-10-20 22:17:09 +00:00
sa = ( short ) ( s - > ang + ( krand ( ) & 31 ) - 16 ) ;
if ( sector [ s - > sectnum ] . lotag = = 2 & & ( krand ( ) % 5 ) = = 0 )
2020-10-23 18:16:47 +00:00
spawned = spawn ( actor , WATERBUBBLE ) ;
2020-05-16 21:55:21 +00:00
}
else
{
2020-10-20 22:17:09 +00:00
zvel = - mulscale16 ( ps [ p ] . horizon . sum ( ) . asq16 ( ) , 81 ) ;
2020-10-23 18:16:47 +00:00
if ( ps [ p ] . GetActor ( ) - > s . xvel ! = 0 )
2020-10-20 22:17:09 +00:00
vel = ( int ) ( ( ( ( 512 - ( 1024
- abs ( abs ( getangle ( sx - ps [ p ] . oposx , sy - ps [ p ] . oposy ) - sa ) - 1024 ) ) )
2020-10-23 18:16:47 +00:00
* 0.001953125f ) * ps [ p ] . GetActor ( ) - > s . xvel ) + 400 ) ;
2020-10-20 22:17:09 +00:00
if ( sector [ s - > sectnum ] . lotag = = 2 & & ( krand ( ) % 5 ) = = 0 )
2020-10-23 18:16:47 +00:00
spawned = spawn ( actor , WATERBUBBLE ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-23 18:16:47 +00:00
if ( spawned = = nullptr )
2020-10-20 22:17:09 +00:00
{
2020-10-23 18:16:47 +00:00
spawned = spawn ( actor , FLAMETHROWERFLAME ) ;
spawned - > s . xvel = ( short ) vel ;
spawned - > s . zvel = ( short ) zvel ;
2020-10-20 22:17:09 +00:00
}
2020-10-23 19:37:40 +00:00
2020-11-15 11:07:03 +00:00
spawned - > s . x = sx + bsin ( sa + 630 ) / 448 ;
spawned - > s . y = sy + bsin ( sa + 112 ) / 448 ;
2020-10-23 19:37:40 +00:00
spawned - > s . z = sz - 256 ;
spawned - > s . sectnum = s - > sectnum ;
spawned - > s . cstat = 0x80 ;
spawned - > s . ang = sa ;
spawned - > s . xrepeat = 2 ;
spawned - > s . yrepeat = 2 ;
spawned - > s . clipdist = 40 ;
spawned - > s . yvel = p ;
2020-10-23 18:16:47 +00:00
spawned - > SetOwner ( actor ) ;
2020-10-20 22:17:09 +00:00
if ( p = = - 1 )
{
2020-10-23 18:16:47 +00:00
if ( s - > picnum = = BOSS5 )
2020-05-16 21:55:21 +00:00
{
2020-11-15 11:07:03 +00:00
spawned - > s . x - = bsin ( sa ) / 56 ;
spawned - > s . y + = bcos ( sa ) / 56 ;
2020-10-23 19:37:40 +00:00
spawned - > s . xrepeat = 10 ;
spawned - > s . yrepeat = 10 ;
2020-10-20 22:17:09 +00:00
}
}
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-16 21:55:21 +00:00
2020-10-23 18:16:47 +00:00
static void shootknee ( DDukeActor * actor , int p , int sx , int sy , int sz , int sa )
2020-10-20 22:17:09 +00:00
{
2020-10-23 18:16:47 +00:00
auto s = & actor - > s ;
2020-10-20 22:17:09 +00:00
int sect = s - > sectnum ;
int zvel ;
2020-10-23 21:18:05 +00:00
short hitsect , hitwall ;
2020-10-20 22:17:09 +00:00
int hitx , hity , hitz ;
2020-10-23 21:18:05 +00:00
DDukeActor * hitsprt ;
2020-10-20 22:17:09 +00:00
if ( p > = 0 )
{
zvel = - ps [ p ] . horizon . sum ( ) . asq16 ( ) > > 11 ;
sz + = ( 6 < < 8 ) ;
sa + = 15 ;
}
else
{
int x ;
2020-11-02 22:10:19 +00:00
auto pactor = ps [ findplayer ( actor , & x ) ] . GetActor ( ) ;
2020-10-23 18:16:47 +00:00
zvel = ( ( pactor - > s . z - sz ) < < 8 ) / ( x + 1 ) ;
sa = getangle ( pactor - > s . x - sx , pactor - > s . y - sy ) ;
2020-10-20 22:17:09 +00:00
}
hitscan ( sx , sy , sz , sect ,
2020-11-15 11:07:03 +00:00
bcos ( sa ) ,
bsin ( sa ) , zvel < < 6 ,
2020-10-23 21:18:05 +00:00
& hitsect , & hitwall , & hitsprt , & hitx , & hity , & hitz , CLIPMASK1 ) ;
2020-10-20 22:17:09 +00:00
if ( hitsect < 0 ) return ;
if ( ( abs ( sx - hitx ) + abs ( sy - hity ) ) < 1024 )
{
2020-10-23 21:18:05 +00:00
if ( hitwall > = 0 | | hitsprt )
2020-10-20 22:17:09 +00:00
{
2020-10-23 18:16:47 +00:00
auto knee = EGS ( hitsect , hitx , hity , hitz , KNEE , - 15 , 0 , 0 , sa , 32 , 0 , actor , 4 ) ;
knee - > s . extra + = ( krand ( ) & 7 ) ;
2020-05-16 21:55:21 +00:00
if ( p > = 0 )
{
2020-10-23 18:16:47 +00:00
auto k = spawn ( knee , SMALLSMOKE ) ;
k - > s . z - = ( 8 < < 8 ) ;
S_PlayActorSound ( KICK_HIT , knee ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
if ( p > = 0 & & ps [ p ] . steroids_amount > 0 & & ps [ p ] . steroids_amount < 400 )
2020-10-23 18:16:47 +00:00
knee - > s . extra + = ( max_player_health > > 2 ) ;
2020-10-20 22:17:09 +00:00
2020-10-23 21:18:05 +00:00
if ( hitsprt & & hitsprt - > s . picnum ! = ACCESSSWITCH & & hitsprt - > s . picnum ! = ACCESSSWITCH2 )
2020-05-16 21:55:21 +00:00
{
2020-10-24 05:15:10 +00:00
fi . checkhitsprite ( hitsprt , knee ) ;
2020-10-26 06:30:34 +00:00
if ( p > = 0 ) fi . checkhitswitch ( p , - 1 , hitsprt ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
else if ( hitwall > = 0 )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
if ( wall [ hitwall ] . cstat & 2 )
if ( wall [ hitwall ] . nextsector > = 0 )
if ( hitz > = ( sector [ wall [ hitwall ] . nextsector ] . floorz ) )
hitwall = wall [ hitwall ] . nextwall ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( hitwall > = 0 & & wall [ hitwall ] . picnum ! = ACCESSSWITCH & & wall [ hitwall ] . picnum ! = ACCESSSWITCH2 )
2020-05-16 21:55:21 +00:00
{
2020-10-24 05:22:44 +00:00
fi . checkhitwall ( knee , hitwall , hitx , hity , hitz , KNEE ) ;
2020-10-26 06:30:34 +00:00
if ( p > = 0 ) fi . checkhitswitch ( p , hitwall , nullptr ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
}
}
else if ( p > = 0 & & zvel > 0 & & sector [ hitsect ] . lotag = = 1 )
{
2020-10-23 20:06:02 +00:00
auto splash = spawn ( ps [ p ] . GetActor ( ) , WATERSPLASH2 ) ;
splash - > s . x = hitx ;
splash - > s . y = hity ;
splash - > s . ang = ps [ p ] . angle . ang . asbuild ( ) ; // Total tweek
splash - > s . xvel = 32 ;
2020-10-23 18:16:47 +00:00
ssp ( actor , CLIPMASK0 ) ;
2020-10-23 20:06:02 +00:00
splash - > s . xvel = 0 ;
2020-10-20 22:17:09 +00:00
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-16 21:55:21 +00:00
2020-10-24 04:33:31 +00:00
static void shootweapon ( DDukeActor * actor , int p , int sx , int sy , int sz , int sa , int atwith )
2020-10-20 22:17:09 +00:00
{
2020-11-01 17:23:09 +00:00
auto s = & actor - > s ;
2020-10-20 22:17:09 +00:00
int sect = s - > sectnum ;
int zvel ;
2020-10-24 04:33:31 +00:00
short hitsect , hitwall ;
2020-10-20 22:17:09 +00:00
int hitx , hity , hitz ;
2020-10-23 21:18:05 +00:00
DDukeActor * hitact ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( s - > extra > = 0 ) s - > shade = - 96 ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( p > = 0 )
{
2020-11-01 17:23:09 +00:00
SetGameVarID ( g_iAimAngleVarID , AUTO_AIM_ANGLE , actor , p ) ;
2020-11-01 16:57:40 +00:00
OnEvent ( EVENT_GETAUTOAIMANGLE , p , ps [ p ] . GetActor ( ) , - 1 ) ;
2020-11-01 17:23:09 +00:00
int varval = GetGameVarID ( g_iAimAngleVarID , actor , p ) ;
2020-11-01 19:57:02 +00:00
DDukeActor * aimed = nullptr ;
2020-11-01 17:23:09 +00:00
if ( varval > 0 )
2020-10-20 22:17:09 +00:00
{
2020-11-01 19:57:02 +00:00
aimed = aim ( actor , varval ) ;
2020-10-20 22:17:09 +00:00
}
2020-11-01 19:57:02 +00:00
if ( aimed )
2020-10-20 22:17:09 +00:00
{
2020-11-20 07:18:26 +00:00
int dal = ( ( aimed - > s . xrepeat * tileHeight ( aimed - > s . picnum ) ) < < 1 ) + ( 5 < < 8 ) ;
2020-11-01 19:57:02 +00:00
switch ( aimed - > s . picnum )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
case GREENSLIME :
case GREENSLIME + 1 :
case GREENSLIME + 2 :
case GREENSLIME + 3 :
case GREENSLIME + 4 :
case GREENSLIME + 5 :
case GREENSLIME + 6 :
case GREENSLIME + 7 :
case ROTATEGUN :
dal - = ( 8 < < 8 ) ;
break ;
2020-05-16 21:55:21 +00:00
}
2020-11-01 19:57:02 +00:00
zvel = ( ( aimed - > s . z - sz - dal ) < < 8 ) / ldist ( ps [ p ] . GetActor ( ) , aimed ) ;
sa = getangle ( aimed - > s . x - sx , aimed - > s . y - sy ) ;
2020-10-20 22:17:09 +00:00
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( isWW2GI ( ) )
{
int angRange = 32 ;
int zRange = 256 ;
2020-11-01 17:23:09 +00:00
SetGameVarID ( g_iAngRangeVarID , 32 , actor , p ) ;
SetGameVarID ( g_iZRangeVarID , 256 , actor , p ) ;
2020-11-01 16:57:40 +00:00
OnEvent ( EVENT_GETSHOTRANGE , p , ps [ p ] . GetActor ( ) , - 1 ) ;
2020-11-01 17:23:09 +00:00
angRange = GetGameVarID ( g_iAngRangeVarID , actor , p ) ;
zRange = GetGameVarID ( g_iZRangeVarID , actor , p ) ;
2020-10-20 22:17:09 +00:00
sa + = ( angRange / 2 ) - ( krand ( ) & ( angRange - 1 ) ) ;
2020-11-01 19:57:02 +00:00
if ( aimed = = nullptr )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
// no target
zvel = - ps [ p ] . horizon . sum ( ) . asq16 ( ) > > 11 ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
zvel + = ( zRange / 2 ) - ( krand ( ) & ( zRange - 1 ) ) ;
}
2020-11-01 19:57:02 +00:00
else if ( aimed = = nullptr )
2020-10-20 22:17:09 +00:00
{
sa + = 16 - ( krand ( ) & 31 ) ;
zvel = - ps [ p ] . horizon . sum ( ) . asq16 ( ) > > 11 ;
zvel + = 128 - ( krand ( ) & 255 ) ;
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
sz - = ( 2 < < 8 ) ;
}
else
{
int x ;
2020-11-01 19:57:02 +00:00
int j = findplayer ( actor , & x ) ;
2020-10-20 22:17:09 +00:00
sz - = ( 4 < < 8 ) ;
2020-10-24 04:33:31 +00:00
zvel = ( ( ps [ j ] . posz - sz ) < < 8 ) / ( ldist ( ps [ j ] . GetActor ( ) , actor ) ) ;
2020-10-20 22:17:09 +00:00
if ( s - > picnum ! = BOSS1 )
{
zvel + = 128 - ( krand ( ) & 255 ) ;
sa + = 32 - ( krand ( ) & 63 ) ;
}
else
{
zvel + = 128 - ( krand ( ) & 255 ) ;
sa = getangle ( ps [ j ] . posx - sx , ps [ j ] . posy - sy ) + 64 - ( krand ( ) & 127 ) ;
}
}
s - > cstat & = ~ 257 ;
hitscan ( sx , sy , sz , sect ,
2020-11-15 11:07:03 +00:00
bcos ( sa ) ,
bsin ( sa ) ,
2020-10-23 21:18:05 +00:00
zvel < < 6 , & hitsect , & hitwall , & hitact , & hitx , & hity , & hitz , CLIPMASK1 ) ;
2020-10-20 22:17:09 +00:00
s - > cstat | = 257 ;
2020-10-23 20:06:02 +00:00
2020-10-20 22:17:09 +00:00
if ( hitsect < 0 ) return ;
if ( ( krand ( ) & 15 ) = = 0 & & sector [ hitsect ] . lotag = = 2 )
tracers ( hitx , hity , hitz , sx , sy , sz , 8 - ( ud . multimode > > 1 ) ) ;
2020-05-16 21:55:21 +00:00
2020-10-24 04:33:31 +00:00
DDukeActor * spark ;
2020-10-20 22:17:09 +00:00
if ( p > = 0 )
{
2020-10-24 04:33:31 +00:00
spark = EGS ( hitsect , hitx , hity , hitz , SHOTSPARK1 , - 15 , 10 , 10 , sa , 0 , 0 , actor , 4 ) ;
2020-10-23 20:06:02 +00:00
spark - > s . extra = ScriptCode [ actorinfo [ atwith ] . scriptaddress ] ;
spark - > s . extra + = ( krand ( ) % 6 ) ;
2020-10-20 22:17:09 +00:00
2020-10-23 21:18:05 +00:00
if ( hitwall = = - 1 & & hitact = = nullptr )
2020-10-20 22:17:09 +00:00
{
if ( zvel < 0 )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
if ( sector [ hitsect ] . ceilingstat & 1 )
2020-05-16 21:55:21 +00:00
{
2020-10-23 20:06:02 +00:00
spark - > s . xrepeat = 0 ;
spark - > s . yrepeat = 0 ;
2020-10-20 22:17:09 +00:00
return ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
else
fi . checkhitceiling ( hitsect ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-23 20:06:02 +00:00
spawn ( spark , SMALLSMOKE ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-23 21:18:05 +00:00
if ( hitact )
2020-05-16 21:55:21 +00:00
{
2020-10-24 05:15:10 +00:00
fi . checkhitsprite ( hitact , spark ) ;
2020-10-23 21:18:05 +00:00
if ( hitact - > s . picnum = = TILE_APLAYER & & ( ud . coop ! = 1 | | ud . ffire = = 1 ) )
2020-05-16 21:55:21 +00:00
{
2020-10-23 20:06:02 +00:00
auto jib = spawn ( spark , JIBS6 ) ;
spark - > s . xrepeat = spark - > s . yrepeat = 0 ;
jib - > s . z + = ( 4 < < 8 ) ;
jib - > s . xvel = 16 ;
jib - > s . xrepeat = jib - > s . yrepeat = 24 ;
jib - > s . ang + = 64 - ( krand ( ) & 127 ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-23 20:06:02 +00:00
else spawn ( spark , SMALLSMOKE ) ;
2020-10-20 22:17:09 +00:00
if ( p > = 0 & & (
2020-10-23 20:06:02 +00:00
hitact - > s . picnum = = DIPSWITCH | |
hitact - > s . picnum = = DIPSWITCH + 1 | |
hitact - > s . picnum = = DIPSWITCH2 | |
hitact - > s . picnum = = DIPSWITCH2 + 1 | |
hitact - > s . picnum = = DIPSWITCH3 | |
hitact - > s . picnum = = DIPSWITCH3 + 1 | |
hitact - > s . picnum = = HANDSWITCH | |
hitact - > s . picnum = = HANDSWITCH + 1 ) )
2020-05-16 21:55:21 +00:00
{
2020-10-26 06:30:34 +00:00
fi . checkhitswitch ( p , - 1 , hitact ) ;
2020-10-20 22:17:09 +00:00
return ;
2020-05-16 21:55:21 +00:00
}
}
2020-10-20 22:17:09 +00:00
else if ( hitwall > = 0 )
{
2020-10-23 20:06:02 +00:00
spawn ( spark , SMALLSMOKE ) ;
2020-10-20 22:17:09 +00:00
if ( fi . isadoorwall ( wall [ hitwall ] . picnum ) = = 1 )
goto SKIPBULLETHOLE ;
if ( p > = 0 & & (
wall [ hitwall ] . picnum = = DIPSWITCH | |
wall [ hitwall ] . picnum = = DIPSWITCH + 1 | |
wall [ hitwall ] . picnum = = DIPSWITCH2 | |
wall [ hitwall ] . picnum = = DIPSWITCH2 + 1 | |
wall [ hitwall ] . picnum = = DIPSWITCH3 | |
wall [ hitwall ] . picnum = = DIPSWITCH3 + 1 | |
wall [ hitwall ] . picnum = = HANDSWITCH | |
wall [ hitwall ] . picnum = = HANDSWITCH + 1 ) )
{
2020-10-26 06:30:34 +00:00
fi . checkhitswitch ( p , hitwall , nullptr ) ;
2020-10-20 22:17:09 +00:00
return ;
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( wall [ hitwall ] . hitag ! = 0 | | ( wall [ hitwall ] . nextwall > = 0 & & wall [ wall [ hitwall ] . nextwall ] . hitag ! = 0 ) )
goto SKIPBULLETHOLE ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( hitsect > = 0 & & sector [ hitsect ] . lotag = = 0 )
if ( wall [ hitwall ] . overpicnum ! = BIGFORCE )
if ( ( wall [ hitwall ] . nextsector > = 0 & & sector [ wall [ hitwall ] . nextsector ] . lotag = = 0 ) | |
2020-05-16 21:55:21 +00:00
( wall [ hitwall ] . nextsector = = - 1 & & sector [ hitsect ] . lotag = = 0 ) )
if ( ( wall [ hitwall ] . cstat & 16 ) = = 0 )
{
if ( wall [ hitwall ] . nextsector > = 0 )
{
2020-10-24 04:33:31 +00:00
DukeSectIterator it ( wall [ hitwall ] . nextsector ) ;
while ( auto l = it . Next ( ) )
2020-05-16 21:55:21 +00:00
{
2020-10-24 04:33:31 +00:00
if ( l - > s . statnum = = 3 & & l - > s . lotag = = 13 )
2020-10-20 22:17:09 +00:00
goto SKIPBULLETHOLE ;
2020-05-16 21:55:21 +00:00
}
}
2020-10-24 04:33:31 +00:00
DukeStatIterator it ( STAT_MISC ) ;
while ( auto l = it . Next ( ) )
2020-05-16 21:55:21 +00:00
{
2020-10-24 04:33:31 +00:00
if ( l - > s . picnum = = BULLETHOLE )
if ( dist ( l , spark ) < ( 12 + ( krand ( ) & 7 ) ) )
2020-10-20 22:17:09 +00:00
goto SKIPBULLETHOLE ;
2020-05-16 21:55:21 +00:00
}
2020-10-23 20:06:02 +00:00
auto hole = spawn ( spark , BULLETHOLE ) ;
hole - > s . xvel = - 1 ;
hole - > s . ang = getangle ( wall [ hitwall ] . x - wall [ wall [ hitwall ] . point2 ] . x ,
2020-10-20 22:17:09 +00:00
wall [ hitwall ] . y - wall [ wall [ hitwall ] . point2 ] . y ) + 512 ;
2020-10-23 20:06:02 +00:00
ssp ( hole , CLIPMASK0 ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
SKIPBULLETHOLE :
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( wall [ hitwall ] . cstat & 2 )
if ( wall [ hitwall ] . nextsector > = 0 )
if ( hitz > = ( sector [ wall [ hitwall ] . nextsector ] . floorz ) )
hitwall = wall [ hitwall ] . nextwall ;
2020-05-16 21:55:21 +00:00
2020-10-24 05:22:44 +00:00
fi . checkhitwall ( spark , hitwall , hitx , hity , hitz , SHOTSPARK1 ) ;
2020-10-20 22:17:09 +00:00
}
}
else
{
2020-10-24 04:33:31 +00:00
spark = EGS ( hitsect , hitx , hity , hitz , SHOTSPARK1 , - 15 , 24 , 24 , sa , 0 , 0 , actor , 4 ) ;
spark - > s . extra = ScriptCode [ actorinfo [ atwith ] . scriptaddress ] ;
2020-05-16 21:55:21 +00:00
2020-10-23 21:18:05 +00:00
if ( hitact )
2020-10-20 22:17:09 +00:00
{
2020-10-24 05:15:10 +00:00
fi . checkhitsprite ( hitact , spark ) ;
2020-10-23 21:18:05 +00:00
if ( hitact - > s . picnum ! = TILE_APLAYER )
2020-10-24 04:33:31 +00:00
spawn ( spark , SMALLSMOKE ) ;
else spark - > s . xrepeat = spark - > s . yrepeat = 0 ;
2020-10-20 22:17:09 +00:00
}
2020-10-20 23:03:38 +00:00
else if ( hitwall > = 0 )
2020-10-24 05:22:44 +00:00
fi . checkhitwall ( spark , hitwall , hitx , hity , hitz , SHOTSPARK1 ) ;
2020-10-20 22:17:09 +00:00
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( ( krand ( ) & 255 ) < 4 )
{
vec3_t v { hitx , hity , hitz } ;
2020-10-24 04:33:31 +00:00
S_PlaySound3D ( PISTOL_RICOCHET , spark , & v ) ;
2020-10-20 22:17:09 +00:00
}
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-16 21:55:21 +00:00
2020-10-24 04:40:41 +00:00
static void shootstuff ( DDukeActor * actor , int p , int sx , int sy , int sz , int sa , int atwith )
2020-10-20 22:17:09 +00:00
{
2020-11-01 19:57:02 +00:00
spritetype * const s = & actor - > s ;
2020-10-20 22:17:09 +00:00
int sect = s - > sectnum ;
int vel , zvel ;
2020-11-01 19:57:02 +00:00
short l , scount ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( s - > extra > = 0 ) s - > shade = - 96 ;
scount = 1 ;
if ( atwith = = SPIT ) vel = 292 ;
else
{
if ( atwith = = COOLEXPLOSION1 )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
if ( s - > picnum = = BOSS2 ) vel = 644 ;
else vel = 348 ;
sz - = ( 4 < < 7 ) ;
}
else
{
vel = 840 ;
sz - = ( 4 < < 7 ) ;
}
}
2020-09-17 20:36:09 +00:00
2020-10-20 22:17:09 +00:00
if ( p > = 0 )
{
2020-11-01 19:57:02 +00:00
auto aimed = aim ( actor , AUTO_AIM_ANGLE ) ;
2020-05-16 21:55:21 +00:00
2020-11-01 19:57:02 +00:00
if ( aimed )
2020-10-20 22:17:09 +00:00
{
2020-11-20 07:18:26 +00:00
int dal = ( ( aimed - > s . xrepeat * tileHeight ( aimed - > s . picnum ) ) < < 1 ) - ( 12 < < 8 ) ;
2020-11-01 19:57:02 +00:00
zvel = ( ( aimed - > s . z - sz - dal ) * vel ) / ldist ( ps [ p ] . GetActor ( ) , aimed ) ;
sa = getangle ( aimed - > s . x - sx , aimed - > s . y - sy ) ;
2020-05-16 21:55:21 +00:00
}
else
2020-10-20 22:17:09 +00:00
zvel = - mulscale16 ( ps [ p ] . horizon . sum ( ) . asq16 ( ) , 98 ) ;
}
else
{
int x ;
2020-11-01 19:57:02 +00:00
int j = findplayer ( actor , & x ) ;
2020-10-20 22:17:09 +00:00
// sa = getangle(ps[j].oposx-sx,ps[j].oposy-sy);
sa + = 16 - ( krand ( ) & 31 ) ;
2020-11-12 11:07:16 +00:00
zvel = ( ( ( ps [ j ] . oposz - sz + ( 3 < < 8 ) ) ) * vel ) / ldist ( ps [ j ] . GetActor ( ) , actor ) ;
2020-10-20 22:17:09 +00:00
}
int oldzvel = zvel ;
int sizx , sizy ;
if ( atwith = = SPIT ) { sizx = 18 ; sizy = 18 , sz - = ( 10 < < 8 ) ; }
else
{
if ( atwith = = FIRELASER )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
if ( p > = 0 )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
sizx = 34 ;
sizy = 34 ;
2020-05-16 21:55:21 +00:00
}
else
{
2020-10-20 22:17:09 +00:00
sizx = 18 ;
sizy = 18 ;
2020-05-16 21:55:21 +00:00
}
}
2020-10-20 22:17:09 +00:00
else
{
sizx = 18 ;
sizy = 18 ;
}
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( p > = 0 ) sizx = 7 , sizy = 7 ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
while ( scount > 0 )
{
2020-10-24 04:40:41 +00:00
auto spawned = EGS ( sect , sx , sy , sz , atwith , - 127 , sizx , sizy , sa , vel , zvel , actor , 4 ) ;
spawned - > s . extra + = ( krand ( ) & 7 ) ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( atwith = = COOLEXPLOSION1 )
2020-05-16 21:55:21 +00:00
{
2020-10-24 04:40:41 +00:00
spawned - > s . shade = 0 ;
2020-10-20 22:17:09 +00:00
if ( s - > picnum = = BOSS2 )
2020-05-16 21:55:21 +00:00
{
2020-10-24 04:40:41 +00:00
l = spawned - > s . xvel ;
spawned - > s . xvel = 1024 ;
ssp ( spawned , CLIPMASK0 ) ;
spawned - > s . xvel = l ;
spawned - > s . ang + = 128 - ( krand ( ) & 255 ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
}
2020-05-16 21:55:21 +00:00
2020-10-24 04:40:41 +00:00
spawned - > s . cstat = 128 ;
spawned - > s . clipdist = 4 ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
sa = s - > ang + 32 - ( krand ( ) & 63 ) ;
zvel = oldzvel + 512 - ( krand ( ) & 1023 ) ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
scount - - ;
}
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-16 21:55:21 +00:00
2020-10-24 04:40:41 +00:00
static void shootrpg ( DDukeActor * actor , int p , int sx , int sy , int sz , int sa , int atwith )
2020-10-20 22:17:09 +00:00
{
2020-11-01 19:57:02 +00:00
auto s = & actor - > s ;
2020-10-20 22:17:09 +00:00
int sect = s - > sectnum ;
int vel , zvel ;
2020-11-01 19:57:02 +00:00
short l , scount ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( s - > extra > = 0 ) s - > shade = - 96 ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
scount = 1 ;
vel = 644 ;
2020-05-16 21:55:21 +00:00
2020-11-01 19:57:02 +00:00
DDukeActor * aimed = nullptr ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( p > = 0 )
{
2020-11-01 19:57:02 +00:00
aimed = aim ( actor , 48 ) ;
if ( aimed )
2020-10-20 22:17:09 +00:00
{
2020-11-20 07:18:26 +00:00
int dal = ( ( aimed - > s . xrepeat * tileHeight ( aimed - > s . picnum ) ) < < 1 ) + ( 8 < < 8 ) ;
2020-11-01 19:57:02 +00:00
zvel = ( ( aimed - > s . z - sz - dal ) * vel ) / ldist ( ps [ p ] . GetActor ( ) , aimed ) ;
if ( aimed - > s . picnum ! = RECON )
sa = getangle ( aimed - > s . x - sx , aimed - > s . y - sy ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
else zvel = - mulscale16 ( ps [ p ] . horizon . sum ( ) . asq16 ( ) , 81 ) ;
if ( atwith = = RPG )
2020-10-24 04:40:41 +00:00
S_PlayActorSound ( RPG_SHOOT , actor ) ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
}
else
{
int x ;
2020-11-01 19:57:02 +00:00
int j = findplayer ( actor , & x ) ;
2020-10-20 22:17:09 +00:00
sa = getangle ( ps [ j ] . oposx - sx , ps [ j ] . oposy - sy ) ;
if ( s - > picnum = = BOSS3 )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
int zoffs = ( 32 < < 8 ) ;
if ( isWorldTour ( ) ) // Twentieth Anniversary World Tour
2020-10-24 04:40:41 +00:00
zoffs = ( int ) ( ( actor - > s . yrepeat / 80.0f ) * zoffs ) ;
2020-10-20 22:17:09 +00:00
sz - = zoffs ;
}
else if ( s - > picnum = = BOSS2 )
{
vel + = 128 ;
int zoffs = 24 < < 8 ;
if ( isWorldTour ( ) ) // Twentieth Anniversary World Tour
2020-10-24 04:40:41 +00:00
zoffs = ( int ) ( ( actor - > s . yrepeat / 80.0f ) * zoffs ) ;
2020-10-20 22:17:09 +00:00
sz + = zoffs ;
2020-05-16 21:55:21 +00:00
}
2020-10-24 04:40:41 +00:00
l = ldist ( ps [ j ] . GetActor ( ) , actor ) ;
2020-10-20 22:17:09 +00:00
zvel = ( ( ps [ j ] . oposz - sz ) * vel ) / l ;
2020-05-16 21:55:21 +00:00
2020-10-24 04:40:41 +00:00
if ( badguy ( actor ) & & ( s - > hitag & face_player_smart ) )
2020-10-20 22:17:09 +00:00
sa = s - > ang + ( krand ( ) & 31 ) - 16 ;
}
2020-11-01 19:57:02 +00:00
if ( p < 0 ) aimed = nullptr ;
2020-05-16 21:55:21 +00:00
2020-10-23 19:37:40 +00:00
auto spawned = EGS ( sect ,
2020-11-15 11:07:03 +00:00
sx + ( bcos ( sa + 348 ) / 448 ) ,
sy + ( bsin ( sa + 348 ) / 448 ) ,
2020-10-24 04:40:41 +00:00
sz - ( 1 < < 8 ) , atwith , 0 , 14 , 14 , sa , vel , zvel , actor , 4 ) ;
2020-10-20 22:17:09 +00:00
2020-10-23 19:37:40 +00:00
auto spj = & spawned - > s ;
2020-10-24 05:39:51 +00:00
spj - > extra + = ( krand ( ) & 7 ) ;
2020-10-20 22:17:09 +00:00
if ( atwith ! = FREEZEBLAST )
2020-11-01 19:57:02 +00:00
spawned - > temp_actor = aimed ;
2020-10-20 22:17:09 +00:00
else
{
2020-10-24 05:39:51 +00:00
spj - > yvel = numfreezebounces ;
spj - > xrepeat > > = 1 ;
spj - > yrepeat > > = 1 ;
spj - > zvel - = ( 2 < < 4 ) ;
2020-10-20 22:17:09 +00:00
}
if ( p = = - 1 )
{
if ( s - > picnum = = BOSS3 )
2020-05-16 21:55:21 +00:00
{
2020-11-15 11:07:03 +00:00
int xoffs = bsin ( sa , - 6 ) ;
int yoffs = - bcos ( sa , - 6 ) ;
2020-10-20 22:17:09 +00:00
int aoffs = 4 ;
if ( ( krand ( ) & 1 ) ! = 0 )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
xoffs = - xoffs ;
yoffs = - yoffs ;
aoffs = - 8 ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
if ( isWorldTour ( ) ) // Twentieth Anniversary World Tour
2020-05-16 21:55:21 +00:00
{
2020-10-24 04:40:41 +00:00
float siz = actor - > s . yrepeat / 80.0f ;
2020-10-20 22:17:09 +00:00
xoffs * = siz ;
yoffs * = siz ;
aoffs * = siz ;
2020-05-16 21:55:21 +00:00
}
2020-10-24 05:39:51 +00:00
spj - > x + = xoffs ;
spj - > y + = yoffs ;
spj - > ang + = aoffs ;
2020-05-16 21:55:21 +00:00
2020-10-24 05:39:51 +00:00
spj - > xrepeat = 42 ;
spj - > yrepeat = 42 ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
else if ( s - > picnum = = BOSS2 )
2020-05-16 21:55:21 +00:00
{
2020-11-15 11:07:03 +00:00
int xoffs = bsin ( sa ) / 56 ;
int yoffs = - bcos ( sa ) / 56 ;
2020-10-20 22:17:09 +00:00
int aoffs = 8 + ( krand ( ) & 255 ) - 128 ;
if ( isWorldTour ( ) ) { // Twentieth Anniversary World Tour
2020-10-24 04:40:41 +00:00
int siz = actor - > s . yrepeat ;
2020-10-20 22:17:09 +00:00
xoffs = Scale ( xoffs , siz , 80 ) ;
yoffs = Scale ( yoffs , siz , 80 ) ;
aoffs = Scale ( aoffs , siz , 80 ) ;
}
2020-05-16 21:55:21 +00:00
2020-10-24 05:39:51 +00:00
spj - > x - = xoffs ;
spj - > y - = yoffs ;
spj - > ang - = aoffs ;
2020-05-16 21:55:21 +00:00
2020-11-15 11:07:03 +00:00
spj - > x - = bsin ( sa ) / 56 ;
spj - > y + = bcos ( sa ) / 56 ;
2020-10-24 05:39:51 +00:00
spj - > ang - = 8 + ( krand ( ) & 255 ) - 128 ;
spj - > xrepeat = 24 ;
spj - > yrepeat = 24 ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
}
else if ( atwith ! = FREEZEBLAST )
2020-05-16 21:55:21 +00:00
{
2020-10-24 05:39:51 +00:00
spj - > xrepeat = 30 ;
spj - > yrepeat = 30 ;
spj - > extra > > = 2 ;
2020-10-20 22:17:09 +00:00
}
}
else if ( ( isWW2GI ( ) & & aplWeaponWorksLike [ ps [ p ] . curr_weapon ] [ p ] = = DEVISTATOR_WEAPON ) | | ( ! isWW2GI ( ) & & ps [ p ] . curr_weapon = = DEVISTATOR_WEAPON ) )
{
2020-10-24 05:39:51 +00:00
spj - > extra > > = 2 ;
spj - > ang + = 16 - ( krand ( ) & 31 ) ;
spj - > zvel + = 256 - ( krand ( ) & 511 ) ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( ps [ p ] . hbomb_hold_delay )
{
2020-11-15 11:07:03 +00:00
spj - > x - = bsin ( sa ) / 644 ;
spj - > y + = bcos ( sa ) / 644 ;
2020-10-20 22:17:09 +00:00
}
else
{
2020-11-15 11:07:03 +00:00
spj - > x + = bsin ( sa , - 8 ) ;
spj - > y - = bcos ( sa , - 8 ) ;
2020-10-20 22:17:09 +00:00
}
2020-10-24 05:39:51 +00:00
spj - > xrepeat > > = 1 ;
spj - > yrepeat > > = 1 ;
2020-10-20 22:17:09 +00:00
}
2020-05-16 21:55:21 +00:00
2020-10-24 05:39:51 +00:00
spj - > cstat = 128 ;
2020-10-20 22:17:09 +00:00
if ( atwith = = RPG )
2020-10-24 05:39:51 +00:00
spj - > clipdist = 4 ;
2020-10-20 22:17:09 +00:00
else
2020-10-24 05:39:51 +00:00
spj - > clipdist = 40 ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-16 21:55:21 +00:00
2020-10-24 04:46:34 +00:00
static void shootlaser ( DDukeActor * actor , int p , int sx , int sy , int sz , int sa )
2020-10-20 22:17:09 +00:00
{
2020-10-24 04:46:34 +00:00
spritetype * const s = & actor - > s ;
2020-10-20 22:17:09 +00:00
int sect = s - > sectnum ;
int zvel ;
2020-10-24 04:46:34 +00:00
short hitsect , hitwall , j ;
2020-10-20 22:17:09 +00:00
int hitx , hity , hitz ;
2020-10-23 21:18:05 +00:00
DDukeActor * hitsprt ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( p > = 0 )
zvel = - ps [ p ] . horizon . sum ( ) . asq16 ( ) > > 11 ;
else zvel = 0 ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
hitscan ( sx , sy , sz - ps [ p ] . pyoff , sect ,
2020-11-15 11:07:03 +00:00
bcos ( sa ) ,
bsin ( sa ) ,
2020-10-23 21:18:05 +00:00
zvel < < 6 , & hitsect , & hitwall , & hitsprt , & hitx , & hity , & hitz , CLIPMASK1 ) ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
j = 0 ;
2020-10-23 21:18:05 +00:00
if ( hitsprt ) return ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( hitwall > = 0 & & hitsect > = 0 )
if ( ( ( hitx - sx ) * ( hitx - sx ) + ( hity - sy ) * ( hity - sy ) ) < ( 290 * 290 ) )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
if ( wall [ hitwall ] . nextsector > = 0 )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
if ( sector [ wall [ hitwall ] . nextsector ] . lotag < = 2 & & sector [ hitsect ] . lotag < = 2 )
j = 1 ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
else if ( sector [ hitsect ] . lotag < = 2 )
j = 1 ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
if ( j = = 1 )
{
2020-10-24 04:46:34 +00:00
auto bomb = EGS ( hitsect , hitx , hity , hitz , TRIPBOMB , - 16 , 4 , 5 , sa , 0 , 0 , actor , 6 ) ;
2020-10-20 22:17:09 +00:00
if ( isWW2GI ( ) )
2020-05-16 21:55:21 +00:00
{
2020-11-01 17:23:09 +00:00
int lTripBombControl = GetGameVar ( " TRIPBOMB_CONTROL " , TRIPBOMB_TRIPWIRE , nullptr , - 1 ) ;
2020-10-20 22:17:09 +00:00
if ( lTripBombControl & TRIPBOMB_TIMER )
2020-05-16 21:55:21 +00:00
{
2020-11-01 17:23:09 +00:00
int lLifetime = GetGameVar ( " STICKYBOMB_LIFETIME " , NAM_GRENADE_LIFETIME , nullptr , p ) ;
int lLifetimeVar = GetGameVar ( " STICKYBOMB_LIFETIME_VAR " , NAM_GRENADE_LIFETIME_VAR , nullptr , p ) ;
2020-10-20 22:17:09 +00:00
// set timer. blows up when at zero....
2020-10-24 04:46:34 +00:00
bomb - > s . extra = lLifetime
2020-10-20 22:17:09 +00:00
+ mulscale ( krand ( ) , lLifetimeVar , 14 )
- lLifetimeVar ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
}
2020-05-16 21:55:21 +00:00
2020-11-03 06:14:39 +00:00
// this originally used the sprite index as tag to link the laser segments.
// This value is never used again to reference an actor by index. Decouple this for robustness.
ud . bomb_tag = ( ud . bomb_tag + 1 ) & 32767 ;
bomb - > s . hitag = ud . bomb_tag ;
2020-10-24 04:46:34 +00:00
S_PlayActorSound ( LASERTRIP_ONWALL , bomb ) ;
bomb - > s . xvel = - 20 ;
ssp ( bomb , CLIPMASK0 ) ;
bomb - > s . cstat = 16 ;
bomb - > temp_data [ 5 ] = bomb - > s . ang = getangle ( wall [ hitwall ] . x - wall [ wall [ hitwall ] . point2 ] . x , wall [ hitwall ] . y - wall [ wall [ hitwall ] . point2 ] . y ) - 512 ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( p > = 0 )
ps [ p ] . ammo_amount [ TRIPBOMB_WEAPON ] - - ;
}
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-16 21:55:21 +00:00
2020-10-24 04:46:34 +00:00
static void shootgrowspark ( DDukeActor * actor , int p , int sx , int sy , int sz , int sa )
2020-10-20 22:17:09 +00:00
{
2020-11-01 19:57:02 +00:00
auto s = & actor - > s ;
2020-10-20 22:17:09 +00:00
int sect = s - > sectnum ;
int zvel ;
2020-10-23 21:18:05 +00:00
short hitsect , hitwall , k ;
2020-10-20 22:17:09 +00:00
int hitx , hity , hitz ;
2020-10-23 21:18:05 +00:00
DDukeActor * hitsprt ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( p > = 0 )
{
2020-11-01 19:57:02 +00:00
auto aimed = aim ( actor , AUTO_AIM_ANGLE ) ;
if ( aimed )
2020-10-20 22:17:09 +00:00
{
2020-11-20 07:18:26 +00:00
int dal = ( ( aimed - > s . xrepeat * tileHeight ( aimed - > s . picnum ) ) < < 1 ) + ( 5 < < 8 ) ;
2020-11-01 19:57:02 +00:00
switch ( aimed - > s . picnum )
2020-10-20 22:17:09 +00:00
{
case GREENSLIME :
case GREENSLIME + 1 :
case GREENSLIME + 2 :
case GREENSLIME + 3 :
case GREENSLIME + 4 :
case GREENSLIME + 5 :
case GREENSLIME + 6 :
case GREENSLIME + 7 :
case ROTATEGUN :
dal - = ( 8 < < 8 ) ;
break ;
}
2020-11-01 19:57:02 +00:00
zvel = ( ( aimed - > s . z - sz - dal ) < < 8 ) / ( ldist ( ps [ p ] . GetActor ( ) , aimed ) ) ;
sa = getangle ( aimed - > s . x - sx , aimed - > s . y - sy ) ;
2020-10-20 22:17:09 +00:00
}
2020-05-16 21:55:21 +00:00
else
{
2020-10-20 22:17:09 +00:00
sa + = 16 - ( krand ( ) & 31 ) ;
zvel = - ps [ p ] . horizon . sum ( ) . asq16 ( ) > > 11 ;
zvel + = 128 - ( krand ( ) & 255 ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
sz - = ( 2 < < 8 ) ;
}
else
{
int x ;
2020-11-02 22:10:19 +00:00
int j = findplayer ( actor , & x ) ;
2020-10-20 22:17:09 +00:00
sz - = ( 4 < < 8 ) ;
2020-11-12 23:02:12 +00:00
zvel = ( ( ps [ j ] . posz - sz ) < < 8 ) / ( ldist ( ps [ j ] . GetActor ( ) , actor ) ) ;
2020-10-20 22:17:09 +00:00
zvel + = 128 - ( krand ( ) & 255 ) ;
sa + = 32 - ( krand ( ) & 63 ) ;
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
k = 0 ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
// RESHOOTGROW:
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
s - > cstat & = ~ 257 ;
2020-11-15 11:07:03 +00:00
hitscan ( sx , sy , sz , sect , bcos ( sa ) , bsin ( sa ) ,
2020-10-23 21:18:05 +00:00
zvel < < 6 , & hitsect , & hitwall , & hitsprt , & hitx , & hity , & hitz , CLIPMASK1 ) ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
s - > cstat | = 257 ;
2020-09-07 19:38:17 +00:00
2020-10-24 04:46:34 +00:00
auto spark = EGS ( sect , hitx , hity , hitz , GROWSPARK , - 16 , 28 , 28 , sa , 0 , 0 , actor , 1 ) ;
2020-05-16 21:55:21 +00:00
2020-10-24 04:46:34 +00:00
spark - > s . pal = 2 ;
spark - > s . cstat | = 130 ;
spark - > s . xrepeat = spark - > s . yrepeat = 1 ;
2020-05-16 21:55:21 +00:00
2020-10-23 21:18:05 +00:00
if ( hitwall = = - 1 & & hitsprt = = nullptr & & hitsect > = 0 )
2020-10-20 22:17:09 +00:00
{
if ( zvel < 0 & & ( sector [ hitsect ] . ceilingstat & 1 ) = = 0 )
fi . checkhitceiling ( hitsect ) ;
}
2020-10-24 05:15:10 +00:00
else if ( hitsprt ! = nullptr ) fi . checkhitsprite ( hitsprt , spark ) ;
2020-10-20 22:17:09 +00:00
else if ( hitwall > = 0 & & wall [ hitwall ] . picnum ! = ACCESSSWITCH & & wall [ hitwall ] . picnum ! = ACCESSSWITCH2 )
{
2020-10-24 05:22:44 +00:00
fi . checkhitwall ( spark , hitwall , hitx , hity , hitz , GROWSPARK ) ;
2020-10-20 22:17:09 +00:00
}
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-16 21:55:21 +00:00
2020-10-24 05:34:39 +00:00
void shoot_d ( DDukeActor * actor , int atwith )
2020-10-20 22:17:09 +00:00
{
2020-10-24 05:28:07 +00:00
spritetype * const s = & actor - > s ;
2020-10-23 18:16:47 +00:00
short sect , l , j ;
2020-10-20 22:17:09 +00:00
int sx , sy , sz , sa , p , vel , zvel , x , dal ;
if ( s - > picnum = = TILE_APLAYER )
{
p = s - > yvel ;
}
else
{
p = - 1 ;
}
2020-05-16 21:55:21 +00:00
2020-10-24 05:28:07 +00:00
SetGameVarID ( g_iAtWithVarID , atwith , actor , p ) ;
2020-11-01 17:23:09 +00:00
SetGameVarID ( g_iReturnVarID , 0 , actor , p ) ;
2020-11-01 16:57:40 +00:00
OnEvent ( EVENT_SHOOT , p , ps [ p ] . GetActor ( ) , - 1 ) ;
2020-11-01 17:23:09 +00:00
if ( GetGameVarID ( g_iReturnVarID , actor , p ) ! = 0 )
2020-10-20 22:17:09 +00:00
{
return ;
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
sect = s - > sectnum ;
zvel = 0 ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( s - > picnum = = TILE_APLAYER )
{
sx = ps [ p ] . posx ;
sy = ps [ p ] . posy ;
sz = ps [ p ] . posz + ps [ p ] . pyoff + ( 4 < < 8 ) ;
sa = ps [ p ] . angle . ang . asbuild ( ) ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
ps [ p ] . crack_time = CRACK_TIME ;
}
else
{
sa = s - > ang ;
sx = s - > x ;
sy = s - > y ;
2020-11-23 07:39:49 +00:00
sz = s - > z - ( s - > yrepeat * tileHeight ( s - > picnum ) < < 1 ) + ( 4 < < 8 ) ;
2020-10-20 22:17:09 +00:00
if ( s - > picnum ! = ROTATEGUN )
2020-05-16 21:55:21 +00:00
{
2020-10-20 22:17:09 +00:00
sz - = ( 7 < < 8 ) ;
if ( badguy ( s ) & & s - > picnum ! = COMMANDER )
2020-05-16 21:55:21 +00:00
{
2020-11-15 11:07:03 +00:00
sx - = bsin ( sa + 96 , - 7 ) ;
sy + = bcos ( sa + 96 , - 7 ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-20 22:17:09 +00:00
}
}
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
if ( isWorldTour ( ) )
{ // Twentieth Anniversary World Tour
switch ( atwith )
{
case FIREBALL :
2020-10-23 18:16:47 +00:00
shootfireball ( actor , p , sx , sy , sz , sa ) ;
2020-10-20 22:17:09 +00:00
return ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
case FLAMETHROWERFLAME :
2020-10-23 18:16:47 +00:00
shootflamethrowerflame ( actor , p , sx , sy , sz , sa ) ;
2020-10-20 22:17:09 +00:00
return ;
2020-05-16 21:55:21 +00:00
2020-10-20 22:17:09 +00:00
case FIREFLY : // BOSS5 shot
2020-10-23 18:16:47 +00:00
{
auto k = spawn ( actor , atwith ) ;
k - > s . sectnum = sect ;
k - > s . x = sx ;
k - > s . y = sy ;
k - > s . z = sz ;
k - > s . ang = sa ;
k - > s . xvel = 500 ;
k - > s . zvel = 0 ;
2020-10-20 22:17:09 +00:00
return ;
2020-05-16 21:55:21 +00:00
}
2020-10-23 18:16:47 +00:00
}
2020-10-20 22:17:09 +00:00
}
switch ( atwith )
{
case BLOODSPLAT1 :
case BLOODSPLAT2 :
case BLOODSPLAT3 :
case BLOODSPLAT4 :
2020-10-23 17:50:18 +00:00
shootbloodsplat ( actor , p , sx , sy , sz , sa , atwith , BIGFORCE , OOZFILTER , NEWBEAST ) ;
2020-10-20 22:17:09 +00:00
break ;
case KNEE :
2020-10-23 18:16:47 +00:00
shootknee ( actor , p , sx , sy , sz , sa ) ;
2020-10-20 22:17:09 +00:00
break ;
case SHOTSPARK1 :
case SHOTGUN :
case CHAINGUN :
2020-10-24 04:33:31 +00:00
shootweapon ( actor , p , sx , sy , sz , sa , atwith ) ;
2020-10-20 22:17:09 +00:00
return ;
case FIRELASER :
case SPIT :
case COOLEXPLOSION1 :
2020-10-24 04:40:41 +00:00
shootstuff ( actor , p , sx , sy , sz , sa , atwith ) ;
2020-10-20 22:17:09 +00:00
return ;
case FREEZEBLAST :
sz + = ( 3 < < 8 ) ;
case RPG :
2020-10-24 04:40:41 +00:00
shootrpg ( actor , p , sx , sy , sz , sa , atwith ) ;
2020-10-20 22:17:09 +00:00
break ;
case HANDHOLDINGLASER :
2020-10-24 04:46:34 +00:00
shootlaser ( actor , p , sx , sy , sz , sa ) ;
2020-05-16 21:55:21 +00:00
return ;
case BOUNCEMINE :
case MORTER :
2020-10-25 05:15:21 +00:00
{
2020-05-16 21:55:21 +00:00
if ( s - > extra > = 0 ) s - > shade = - 96 ;
2020-10-25 05:15:21 +00:00
auto j = ps [ findplayer ( actor , & x ) ] . GetActor ( ) ;
x = ldist ( j , actor ) ;
2020-05-16 21:55:21 +00:00
zvel = - x > > 1 ;
if ( zvel < - 4096 )
zvel = - 2048 ;
vel = x > > 4 ;
EGS ( sect ,
2020-11-15 11:07:03 +00:00
sx - bsin ( sa , - 8 ) ,
sy + bcos ( sa , - 8 ) ,
2020-10-24 05:34:39 +00:00
sz + ( 6 < < 8 ) , atwith , - 64 , 32 , 32 , sa , vel , zvel , actor , 1 ) ;
2020-05-16 21:55:21 +00:00
break ;
2020-10-25 05:15:21 +00:00
}
2020-05-16 21:55:21 +00:00
case GROWSPARK :
2020-10-24 04:46:34 +00:00
shootgrowspark ( actor , p , sx , sy , sz , sa ) ;
2020-05-16 21:55:21 +00:00
break ;
case SHRINKER :
2020-10-24 05:34:39 +00:00
{
2020-05-16 21:55:21 +00:00
if ( s - > extra > = 0 ) s - > shade = - 96 ;
if ( p > = 0 )
{
2020-10-24 05:34:39 +00:00
auto aimed = isNamWW2GI ( ) ? nullptr : aim ( actor , AUTO_AIM_ANGLE ) ;
2020-11-01 19:57:02 +00:00
if ( aimed )
2020-05-16 21:55:21 +00:00
{
2020-11-20 07:18:26 +00:00
dal = ( ( aimed - > s . xrepeat * tileHeight ( aimed - > s . picnum ) ) < < 1 ) ;
2020-11-01 19:57:02 +00:00
zvel = ( ( aimed - > s . z - sz - dal - ( 4 < < 8 ) ) * 768 ) / ( ldist ( ps [ p ] . GetActor ( ) , aimed ) ) ;
sa = getangle ( aimed - > s . x - sx , aimed - > s . y - sy ) ;
2020-05-16 21:55:21 +00:00
}
2020-10-07 06:12:37 +00:00
else zvel = - mulscale16 ( ps [ p ] . horizon . sum ( ) . asq16 ( ) , 98 ) ;
2020-05-16 21:55:21 +00:00
}
else if ( s - > statnum ! = 3 )
{
2020-11-01 19:57:02 +00:00
j = findplayer ( actor , & x ) ;
l = ldist ( ps [ j ] . GetActor ( ) , actor ) ;
2020-05-16 21:55:21 +00:00
zvel = ( ( ps [ j ] . oposz - sz ) * 512 ) / l ;
}
else zvel = 0 ;
2020-10-24 05:34:39 +00:00
auto j = EGS ( sect ,
2020-11-15 11:07:03 +00:00
sx - bsin ( sa , - 12 ) ,
sy + bcos ( sa , - 12 ) ,
2020-10-24 05:34:39 +00:00
sz + ( 2 < < 8 ) , SHRINKSPARK , - 16 , 28 , 28 , sa , 768 , zvel , actor , 4 ) ;
2020-05-16 21:55:21 +00:00
2020-10-24 05:34:39 +00:00
j - > s . cstat = 128 ;
j - > s . clipdist = 32 ;
2020-05-16 21:55:21 +00:00
return ;
}
2020-10-24 05:34:39 +00:00
}
2020-05-16 21:55:21 +00:00
return ;
}
2020-05-17 11:25:39 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-26 22:53:35 +00:00
void selectweapon_d ( int snum , int weap ) // playernum, weaponnum
2020-05-17 11:25:39 +00:00
{
2020-08-26 22:53:35 +00:00
int i , j , k ;
2020-05-17 11:25:39 +00:00
auto p = & ps [ snum ] ;
2020-10-23 19:40:49 +00:00
if ( p - > last_pissed_time < = ( 26 * 218 ) & & p - > show_empty_weapon = = 0 & & p - > kickback_pic = = 0 & & p - > quick_kick = = 0 & & p - > GetActor ( ) - > s . xrepeat > 32 & & p - > access_incs = = 0 & & p - > knee_incs = = 0 )
2020-05-17 11:25:39 +00:00
{
if ( ( p - > weapon_pos = = 0 | | ( p - > holster_weapon & & p - > weapon_pos = = - 9 ) ) )
{
2020-08-26 22:53:35 +00:00
if ( weap = = WeaponSel_Alt )
{
2020-08-29 11:27:58 +00:00
switch ( p - > curr_weapon )
{
case SHRINKER_WEAPON :
2020-10-11 09:39:51 +00:00
j = isPlutoPak ( ) ? GROW_WEAPON : p - > curr_weapon ;
2020-08-29 11:27:58 +00:00
break ;
case GROW_WEAPON :
j = SHRINKER_WEAPON ;
break ;
2020-08-29 12:30:45 +00:00
case FREEZE_WEAPON :
j = isWorldTour ( ) ? FLAMETHROWER_WEAPON : p - > curr_weapon ;
break ;
case FLAMETHROWER_WEAPON :
j = FREEZE_WEAPON ;
break ;
2020-08-29 11:27:58 +00:00
default :
j = p - > curr_weapon ;
break ;
}
2020-08-26 22:53:35 +00:00
}
else if ( weap = = WeaponSel_Next | | weap = = WeaponSel_Prev )
2020-05-17 11:25:39 +00:00
{
k = p - > curr_weapon ;
2020-08-26 22:53:35 +00:00
j = ( weap = = WeaponSel_Prev ? - 1 : 1 ) ; // JBF: prev (-1) or next (1) weapon choice
2020-05-17 11:25:39 +00:00
i = 0 ;
2020-10-11 09:39:51 +00:00
while ( ( k > = 0 & & k < 10 ) | | ( isPlutoPak ( ) & & k = = GROW_WEAPON & & ( p - > subweapon & ( 1 < < GROW_WEAPON ) ) ! = 0 )
2020-05-17 12:20:49 +00:00
| | ( isWorldTour ( ) & & k = = FLAMETHROWER_WEAPON & & ( p - > subweapon & ( 1 < < FLAMETHROWER_WEAPON ) ) ! = 0 ) )
2020-05-17 11:25:39 +00:00
{
2020-05-17 12:20:49 +00:00
if ( k = = FLAMETHROWER_WEAPON ) //Twentieth Anniversary World Tour
{
if ( j = = - 1 ) k = TRIPBOMB_WEAPON ;
else k = PISTOL_WEAPON ;
}
else if ( k = = GROW_WEAPON ) // JBF: this is handling next/previous with the grower selected
2020-05-17 11:25:39 +00:00
{
if ( j = = ( unsigned int ) - 1 )
k = 5 ;
else k = 7 ;
}
else
{
k + = j ;
2020-05-17 12:20:49 +00:00
// JBF 20040116: so we don't select grower with v1.3d
2020-10-11 09:39:51 +00:00
if ( isPlutoPak ( ) & & k = = SHRINKER_WEAPON & & ( p - > subweapon & ( 1 < < GROW_WEAPON ) ) ) // JBF: activates grower
2020-05-17 12:20:49 +00:00
k = GROW_WEAPON ; // if enabled
if ( isWorldTour ( ) & & k = = FREEZE_WEAPON & & ( p - > subweapon & ( 1 < < FLAMETHROWER_WEAPON ) ) ! = 0 )
k = FLAMETHROWER_WEAPON ;
2020-05-17 11:25:39 +00:00
}
if ( k = = - 1 ) k = 9 ;
else if ( k = = 10 ) k = 0 ;
if ( p - > gotweapon [ k ] & & p - > ammo_amount [ k ] > 0 )
{
2020-10-11 09:39:51 +00:00
if ( isPlutoPak ( ) ) // JBF 20040116: so we don't select grower with v1.3d
2020-05-17 11:25:39 +00:00
if ( k = = SHRINKER_WEAPON & & ( p - > subweapon & ( 1 < < GROW_WEAPON ) ) )
k = GROW_WEAPON ;
2020-05-17 12:20:49 +00:00
if ( isWorldTour ( ) & & k = = FREEZE_WEAPON & & ( p - > subweapon & ( 1 < < FLAMETHROWER_WEAPON ) ) ! = 0 )
k = FLAMETHROWER_WEAPON ;
2020-05-17 11:25:39 +00:00
j = k ;
break ;
}
2020-10-11 09:39:51 +00:00
else if ( isPlutoPak ( ) & & k = = GROW_WEAPON & & p - > ammo_amount [ GROW_WEAPON ] = = 0 & & p - > gotweapon [ SHRINKER_WEAPON ] & & p - > ammo_amount [ SHRINKER_WEAPON ] > 0 ) // JBF 20040116: added isPlutoPak() so we don't select grower with v1.3d
2020-05-17 12:20:49 +00:00
{
j = SHRINKER_WEAPON ;
p - > subweapon & = ~ ( 1 < < GROW_WEAPON ) ;
break ;
}
2020-10-11 09:39:51 +00:00
else if ( isPlutoPak ( ) & & k = = SHRINKER_WEAPON & & p - > ammo_amount [ SHRINKER_WEAPON ] = = 0 & & p - > gotweapon [ SHRINKER_WEAPON ] & & p - > ammo_amount [ GROW_WEAPON ] > 0 ) // JBF 20040116: added isPlutoPak() so we don't select grower with v1.3d
2020-05-17 12:20:49 +00:00
{
j = GROW_WEAPON ;
p - > subweapon | = ( 1 < < GROW_WEAPON ) ;
break ;
}
//Twentieth Anniversary World Tour
else if ( isWorldTour ( ) & & k = = FLAMETHROWER_WEAPON & & p - > ammo_amount [ FLAMETHROWER_WEAPON ] = = 0 & & p - > gotweapon [ FREEZE_WEAPON ] & & p - > ammo_amount [ FREEZE_WEAPON ] > 0 )
{
j = FREEZE_WEAPON ;
p - > subweapon & = ~ ( 1 < < FLAMETHROWER_WEAPON ) ;
break ;
}
else if ( isWorldTour ( ) & & k = = FREEZE_WEAPON & & p - > ammo_amount [ FREEZE_WEAPON ] = = 0 & & p - > gotweapon [ FLAMETHROWER_WEAPON ] & & p - > ammo_amount [ FLAMETHROWER_WEAPON ] > 0 )
{
j = FLAMETHROWER_WEAPON ;
p - > subweapon | = ( 1 < < FLAMETHROWER_WEAPON ) ;
break ;
}
2020-05-17 11:25:39 +00:00
i + + ; // absolutely no weapons, so use foot
if ( i = = 10 )
{
fi . addweapon ( p , KNEE_WEAPON ) ;
break ;
}
}
}
2020-08-26 22:53:35 +00:00
else j = weap - 1 ;
2020-05-17 11:25:39 +00:00
k = - 1 ;
if ( j = = HANDBOMB_WEAPON & & p - > ammo_amount [ HANDBOMB_WEAPON ] = = 0 )
{
2020-10-25 05:34:25 +00:00
DukeStatIterator it ( STAT_ACTOR ) ;
while ( auto act = it . Next ( ) )
2020-05-17 11:25:39 +00:00
{
2020-10-25 05:34:25 +00:00
if ( act - > s . picnum = = HEAVYHBOMB & & act - > GetOwner ( ) = = p - > GetActor ( ) )
2020-05-17 11:25:39 +00:00
{
p - > gotweapon . Set ( HANDBOMB_WEAPON ) ;
j = HANDREMOTE_WEAPON ;
break ;
}
}
}
2020-05-17 12:20:49 +00:00
//Twentieth Anniversary World Tour
if ( j = = FREEZE_WEAPON & & isWorldTour ( ) )
{
if ( p - > curr_weapon ! = FLAMETHROWER_WEAPON & & p - > curr_weapon ! = FREEZE_WEAPON )
{
if ( p - > ammo_amount [ FLAMETHROWER_WEAPON ] > 0 )
{
if ( ( p - > subweapon & ( 1 < < FLAMETHROWER_WEAPON ) ) = = ( 1 < < FLAMETHROWER_WEAPON ) )
j = FLAMETHROWER_WEAPON ;
else if ( p - > ammo_amount [ FREEZE_WEAPON ] = = 0 )
{
j = FLAMETHROWER_WEAPON ;
p - > subweapon | = ( 1 < < FLAMETHROWER_WEAPON ) ;
}
}
else if ( p - > ammo_amount [ FREEZE_WEAPON ] > 0 )
p - > subweapon & = ~ ( 1 < < FLAMETHROWER_WEAPON ) ;
}
else if ( p - > curr_weapon = = FREEZE_WEAPON )
{
p - > subweapon | = ( 1 < < FLAMETHROWER_WEAPON ) ;
j = FLAMETHROWER_WEAPON ;
}
else
p - > subweapon & = ~ ( 1 < < FLAMETHROWER_WEAPON ) ;
}
2020-10-11 09:39:51 +00:00
if ( j = = SHRINKER_WEAPON & & isPlutoPak ( ) ) // JBF 20040116: so we don't select the grower with v1.3d
2020-05-17 11:25:39 +00:00
{
if ( p - > curr_weapon ! = GROW_WEAPON & & p - > curr_weapon ! = SHRINKER_WEAPON )
{
if ( p - > ammo_amount [ GROW_WEAPON ] > 0 )
{
if ( ( p - > subweapon & ( 1 < < GROW_WEAPON ) ) = = ( 1 < < GROW_WEAPON ) )
j = GROW_WEAPON ;
else if ( p - > ammo_amount [ SHRINKER_WEAPON ] = = 0 )
{
j = GROW_WEAPON ;
p - > subweapon | = ( 1 < < GROW_WEAPON ) ;
}
}
else if ( p - > ammo_amount [ SHRINKER_WEAPON ] > 0 )
p - > subweapon & = ~ ( 1 < < GROW_WEAPON ) ;
}
else if ( p - > curr_weapon = = SHRINKER_WEAPON )
{
p - > subweapon | = ( 1 < < GROW_WEAPON ) ;
j = GROW_WEAPON ;
}
else
p - > subweapon & = ~ ( 1 < < GROW_WEAPON ) ;
}
if ( p - > holster_weapon )
{
2020-08-27 22:03:35 +00:00
PlayerSetInput ( snum , SB_HOLSTER ) ;
2020-09-16 11:01:09 +00:00
p - > oweapon_pos = p - > weapon_pos = - 9 ;
2020-05-17 11:25:39 +00:00
}
else if ( j > = MIN_WEAPON & & p - > gotweapon [ j ] & & ( unsigned int ) p - > curr_weapon ! = j ) switch ( j )
{
case KNEE_WEAPON :
fi . addweapon ( p , KNEE_WEAPON ) ;
break ;
case PISTOL_WEAPON :
case SHOTGUN_WEAPON :
case CHAINGUN_WEAPON :
case RPG_WEAPON :
case DEVISTATOR_WEAPON :
case FREEZE_WEAPON :
2020-05-17 12:20:49 +00:00
case FLAMETHROWER_WEAPON :
2020-05-17 11:25:39 +00:00
case GROW_WEAPON :
case SHRINKER_WEAPON :
if ( p - > ammo_amount [ j ] = = 0 & & p - > show_empty_weapon = = 0 )
{
p - > show_empty_weapon = 32 ;
p - > last_full_weapon = p - > curr_weapon ;
}
fi . addweapon ( p , j ) ;
break ;
case HANDREMOTE_WEAPON :
if ( k > = 0 ) // Found in list of [1]'s
{
p - > curr_weapon = HANDREMOTE_WEAPON ;
p - > last_weapon = - 1 ;
2020-09-16 11:01:09 +00:00
p - > oweapon_pos = p - > weapon_pos = 10 ;
2020-05-17 11:25:39 +00:00
}
break ;
case HANDBOMB_WEAPON :
if ( p - > ammo_amount [ HANDBOMB_WEAPON ] > 0 & & p - > gotweapon [ HANDBOMB_WEAPON ] )
fi . addweapon ( p , HANDBOMB_WEAPON ) ;
break ;
case TRIPBOMB_WEAPON :
if ( p - > ammo_amount [ TRIPBOMB_WEAPON ] > 0 & & p - > gotweapon [ TRIPBOMB_WEAPON ] )
fi . addweapon ( p , TRIPBOMB_WEAPON ) ;
break ;
}
}
}
}
2020-05-16 21:55:21 +00:00
2020-05-17 16:04:45 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int doincrements_d ( struct player_struct * p )
{
int snum ;
2020-11-02 19:24:07 +00:00
auto pact = p - > GetActor ( ) ;
snum = pact - > s . yvel ;
2020-05-17 16:04:45 +00:00
p - > player_par + + ;
if ( p - > invdisptime > 0 )
p - > invdisptime - - ;
if ( p - > tipincs > 0 ) p - > tipincs - - ;
if ( p - > last_pissed_time > 0 )
{
p - > last_pissed_time - - ;
if ( p - > last_pissed_time = = ( 26 * 219 ) )
{
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( FLUSH_TOILET , pact ) ;
2020-05-17 16:04:45 +00:00
if ( snum = = screenpeek | | ud . coop = = 1 )
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( DUKE_PISSRELIEF , pact ) ;
2020-05-17 16:04:45 +00:00
}
if ( p - > last_pissed_time = = ( 26 * 218 ) )
{
p - > holster_weapon = 0 ;
2020-09-16 11:01:09 +00:00
p - > oweapon_pos = p - > weapon_pos = 10 ;
2020-05-17 16:04:45 +00:00
}
}
if ( p - > crack_time > 0 )
{
p - > crack_time - - ;
if ( p - > crack_time = = 0 )
{
p - > knuckle_incs = 1 ;
2020-08-27 05:54:49 +00:00
p - > crack_time = CRACK_TIME ;
2020-05-17 16:04:45 +00:00
}
}
if ( p - > steroids_amount > 0 & & p - > steroids_amount < 400 )
{
p - > steroids_amount - - ;
if ( p - > steroids_amount = = 0 )
checkavailinven ( p ) ;
if ( ! ( p - > steroids_amount & 7 ) )
if ( snum = = screenpeek | | ud . coop = = 1 )
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( DUKE_HARTBEAT , pact ) ;
2020-05-17 16:04:45 +00:00
}
if ( p - > heat_on & & p - > heat_amount > 0 )
{
p - > heat_amount - - ;
if ( p - > heat_amount = = 0 )
{
p - > heat_on = 0 ;
checkavailinven ( p ) ;
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( NITEVISION_ONOFF , pact ) ;
2020-05-17 16:04:45 +00:00
}
}
2020-10-21 08:48:38 +00:00
if ( p - > holoduke_on ! = nullptr )
2020-05-17 16:04:45 +00:00
{
p - > holoduke_amount - - ;
if ( p - > holoduke_amount < = 0 )
{
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( TELEPORTER , pact ) ;
2020-10-21 08:48:38 +00:00
p - > holoduke_on = nullptr ;
2020-05-17 16:04:45 +00:00
checkavailinven ( p ) ;
}
}
if ( p - > jetpack_on & & p - > jetpack_amount > 0 )
{
p - > jetpack_amount - - ;
if ( p - > jetpack_amount < = 0 )
{
p - > jetpack_on = 0 ;
checkavailinven ( p ) ;
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( DUKE_JETPACK_OFF , pact ) ;
S_StopSound ( DUKE_JETPACK_IDLE , pact ) ;
S_StopSound ( DUKE_JETPACK_ON , pact ) ;
2020-05-17 16:04:45 +00:00
}
}
2020-10-23 19:40:49 +00:00
if ( p - > quick_kick > 0 & & p - > GetActor ( ) - > s . pal ! = 1 )
2020-05-17 16:04:45 +00:00
{
2020-07-26 08:18:55 +00:00
p - > last_quick_kick = p - > quick_kick + 1 ;
2020-05-17 16:04:45 +00:00
p - > quick_kick - - ;
if ( p - > quick_kick = = 8 )
2020-10-24 05:34:39 +00:00
fi . shoot ( p - > GetActor ( ) , KNEE ) ;
2020-05-17 16:04:45 +00:00
}
2020-07-26 08:18:55 +00:00
else if ( p - > last_quick_kick > 0 )
p - > last_quick_kick - - ;
2020-05-17 16:04:45 +00:00
2020-10-23 19:40:49 +00:00
if ( p - > access_incs & & p - > GetActor ( ) - > s . pal ! = 1 )
2020-05-17 16:04:45 +00:00
{
p - > access_incs + + ;
2020-10-23 19:40:49 +00:00
if ( p - > GetActor ( ) - > s . extra < = 0 )
2020-05-17 16:04:45 +00:00
p - > access_incs = 12 ;
if ( p - > access_incs = = 12 )
{
2020-10-25 05:34:25 +00:00
if ( p - > access_spritenum ! = nullptr )
2020-05-17 16:04:45 +00:00
{
2020-10-26 06:30:34 +00:00
fi . checkhitswitch ( snum , - 1 , p - > access_spritenum ) ;
2020-10-25 05:34:25 +00:00
switch ( p - > access_spritenum - > s . pal )
2020-05-17 16:04:45 +00:00
{
case 0 : p - > got_access & = ( 0xffff - 0x1 ) ; break ;
case 21 : p - > got_access & = ( 0xffff - 0x2 ) ; break ;
case 23 : p - > got_access & = ( 0xffff - 0x4 ) ; break ;
}
2020-10-25 05:34:25 +00:00
p - > access_spritenum = nullptr ;
2020-05-17 16:04:45 +00:00
}
else
{
2020-10-26 06:30:34 +00:00
fi . checkhitswitch ( snum , p - > access_wallnum , nullptr ) ;
2020-05-17 16:04:45 +00:00
switch ( wall [ p - > access_wallnum ] . pal )
{
case 0 : p - > got_access & = ( 0xffff - 0x1 ) ; break ;
case 21 : p - > got_access & = ( 0xffff - 0x2 ) ; break ;
case 23 : p - > got_access & = ( 0xffff - 0x4 ) ; break ;
}
}
}
if ( p - > access_incs > 20 )
{
p - > access_incs = 0 ;
2020-09-16 11:01:09 +00:00
p - > oweapon_pos = p - > weapon_pos = 10 ;
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-17 16:04:45 +00:00
}
}
if ( p - > scuba_on = = 0 & & sector [ p - > cursectnum ] . lotag = = 2 )
{
if ( p - > scuba_amount > 0 )
{
p - > scuba_on = 1 ;
p - > inven_icon = 6 ;
FTA ( 76 , p ) ;
}
else
{
if ( p - > airleft > 0 )
p - > airleft - - ;
else
{
p - > extra_extra8 + = 32 ;
if ( p - > last_extra < ( max_player_health > > 1 ) & & ( p - > last_extra & 3 ) = = 0 )
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( DUKE_LONGTERM_PAIN , pact ) ;
2020-05-17 16:04:45 +00:00
}
}
}
else if ( p - > scuba_amount > 0 & & p - > scuba_on )
{
p - > scuba_amount - - ;
if ( p - > scuba_amount = = 0 )
{
p - > scuba_on = 0 ;
checkavailinven ( p ) ;
}
}
if ( p - > knuckle_incs )
{
p - > knuckle_incs + + ;
if ( p - > knuckle_incs = = 10 & & ! isWW2GI ( ) )
{
2020-08-30 22:33:41 +00:00
if ( ud . levelclock > 1024 )
2020-05-17 16:04:45 +00:00
if ( snum = = screenpeek | | ud . coop = = 1 )
{
if ( rand ( ) & 1 )
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( DUKE_CRACK , pact ) ;
else S_PlayActorSound ( DUKE_CRACK2 , pact ) ;
2020-05-17 16:04:45 +00:00
}
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( DUKE_CRACK_FIRST , pact ) ;
2020-05-17 16:04:45 +00:00
}
2020-08-28 20:51:05 +00:00
else if ( p - > knuckle_incs = = 22 | | PlayerInput ( snum , SB_FIRE ) )
2020-05-17 16:04:45 +00:00
p - > knuckle_incs = 0 ;
return 1 ;
}
return 0 ;
}
2020-05-17 21:44:53 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void checkweapons_d ( struct player_struct * p )
{
static const short weapon_sprites [ MAX_WEAPONS ] = { KNEE , FIRSTGUNSPRITE , SHOTGUNSPRITE ,
CHAINGUNSPRITE , RPGSPRITE , HEAVYHBOMB , SHRINKERSPRITE , DEVISTATORSPRITE ,
TRIPBOMBSPRITE , FREEZESPRITE , HEAVYHBOMB , SHRINKERSPRITE } ;
int cw ;
if ( isWW2GI ( ) )
{
2020-10-23 19:40:49 +00:00
int snum = p - > GetActor ( ) - > s . yvel ;
2020-05-17 21:44:53 +00:00
cw = aplWeaponWorksLike [ p - > curr_weapon ] [ snum ] ;
}
else
cw = p - > curr_weapon ;
if ( cw < 1 | | cw > = MAX_WEAPONS ) return ;
if ( cw )
{
if ( krand ( ) & 1 )
2020-11-02 19:24:07 +00:00
spawn ( p - > GetActor ( ) , weapon_sprites [ cw ] ) ;
2020-05-17 21:44:53 +00:00
else switch ( cw )
{
case RPG_WEAPON :
case HANDBOMB_WEAPON :
2020-11-02 19:24:07 +00:00
spawn ( p - > GetActor ( ) , EXPLOSION2 ) ;
2020-05-17 21:44:53 +00:00
break ;
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-28 20:51:05 +00:00
static void operateJetpack ( int snum , ESyncBits actions , int psectlotag , int fz , int cz , int shrunk )
2020-05-17 21:44:53 +00:00
{
int j ;
auto p = & ps [ snum ] ;
2020-10-25 05:50:31 +00:00
auto pact = p - > GetActor ( ) ;
2020-05-17 21:44:53 +00:00
p - > on_ground = 0 ;
p - > jumping_counter = 0 ;
p - > hard_landing = 0 ;
p - > falling_counter = 0 ;
p - > pycount + = 32 ;
p - > pycount & = 2047 ;
2020-11-15 11:07:03 +00:00
p - > pyoff = bsin ( p - > pycount , - 7 ) ;
2020-05-17 21:44:53 +00:00
2020-10-25 05:50:31 +00:00
if ( p - > jetpack_on & & S_CheckActorSoundPlaying ( pact , DUKE_SCREAM ) )
2020-08-11 03:48:16 +00:00
{
2020-10-25 05:50:31 +00:00
S_StopSound ( DUKE_SCREAM , pact ) ;
2020-08-11 03:48:16 +00:00
}
2020-05-17 21:44:53 +00:00
if ( p - > jetpack_on < 11 )
{
p - > jetpack_on + + ;
p - > posz - = ( p - > jetpack_on < < 7 ) ; //Goin up
}
2020-10-25 05:50:31 +00:00
else if ( p - > jetpack_on = = 11 & & ! S_CheckActorSoundPlaying ( pact , DUKE_JETPACK_IDLE ) )
S_PlayActorSound ( DUKE_JETPACK_IDLE , pact ) ;
2020-05-17 21:44:53 +00:00
if ( shrunk ) j = 512 ;
else j = 2048 ;
2020-08-28 20:51:05 +00:00
if ( actions & SB_JUMP ) //A (soar high)
2020-05-17 21:44:53 +00:00
{
// jump
2020-11-01 17:23:09 +00:00
SetGameVarID ( g_iReturnVarID , 0 , p - > GetActor ( ) , snum ) ;
2020-11-01 16:57:40 +00:00
OnEvent ( EVENT_SOARUP , snum , p - > GetActor ( ) , - 1 ) ;
2020-11-01 17:23:09 +00:00
if ( GetGameVarID ( g_iReturnVarID , p - > GetActor ( ) , snum ) = = 0 )
2020-05-17 21:44:53 +00:00
{
p - > posz - = j ;
2020-08-27 05:54:49 +00:00
p - > crack_time = CRACK_TIME ;
2020-05-17 21:44:53 +00:00
}
}
2020-08-28 20:51:05 +00:00
if ( actions & SB_CROUCH ) //Z (soar low)
2020-05-17 21:44:53 +00:00
{
// crouch
2020-11-01 17:23:09 +00:00
SetGameVarID ( g_iReturnVarID , 0 , p - > GetActor ( ) , snum ) ;
2020-11-01 16:57:40 +00:00
OnEvent ( EVENT_SOARDOWN , snum , p - > GetActor ( ) , - 1 ) ;
2020-11-01 17:23:09 +00:00
if ( GetGameVarID ( g_iReturnVarID , p - > GetActor ( ) , snum ) = = 0 )
2020-05-17 21:44:53 +00:00
{
p - > posz + = j ;
2020-08-27 05:54:49 +00:00
p - > crack_time = CRACK_TIME ;
2020-05-17 21:44:53 +00:00
}
}
int k ;
if ( shrunk = = 0 & & ( psectlotag = = 0 | | psectlotag = = 2 ) ) k = 32 ;
else k = 16 ;
if ( psectlotag ! = 2 & & p - > scuba_on = = 1 )
p - > scuba_on = 0 ;
if ( p - > posz > ( fz - ( k < < 8 ) ) )
p - > posz + = ( ( fz - ( k < < 8 ) ) - p - > posz ) > > 1 ;
2020-10-25 05:50:31 +00:00
if ( p - > posz < ( pact - > ceilingz + ( 18 < < 8 ) ) )
p - > posz = pact - > ceilingz + ( 18 < < 8 ) ;
2020-05-17 21:44:53 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-28 20:51:05 +00:00
static void movement ( int snum , ESyncBits actions , int psect , int fz , int cz , int shrunk , int truefdist , int psectlotag )
2020-05-17 21:44:53 +00:00
{
int j ;
auto p = & ps [ snum ] ;
2020-10-25 05:50:31 +00:00
auto pact = p - > GetActor ( ) ;
2020-05-17 21:44:53 +00:00
if ( p - > airleft ! = 15 * 26 )
p - > airleft = 15 * 26 ; //Aprox twenty seconds.
if ( p - > scuba_on = = 1 )
p - > scuba_on = 0 ;
int i = 40 ;
2020-08-07 19:59:11 +00:00
if ( psectlotag = = ST_1_ABOVE_WATER & & p - > spritebridge = = 0 )
2020-05-17 21:44:53 +00:00
{
if ( shrunk = = 0 )
{
i = 34 ;
p - > pycount + = 32 ;
p - > pycount & = 2047 ;
2020-11-15 11:07:03 +00:00
p - > pyoff = bsin ( p - > pycount , - 6 ) ;
2020-05-17 21:44:53 +00:00
}
else i = 12 ;
if ( shrunk = = 0 & & truefdist < = PHEIGHT )
{
if ( p - > on_ground = = 1 )
{
2020-10-25 06:21:33 +00:00
if ( p - > dummyplayersprite = = nullptr )
p - > dummyplayersprite = spawn ( pact , PLAYERONWATER ) ;
2020-05-17 21:44:53 +00:00
p - > footprintcount = 6 ;
if ( sector [ p - > cursectnum ] . floorpicnum = = FLOORSLIME )
p - > footprintpal = 8 ;
else p - > footprintpal = 0 ;
p - > footprintshade = 0 ;
}
}
}
else
{
footprints ( snum ) ;
}
if ( p - > posz < ( fz - ( i < < 8 ) ) ) //falling
{
// not jumping or crouching
2020-08-28 20:51:05 +00:00
if ( ( actions & ( SB_JUMP | SB_CROUCH ) ) = = 0 & & p - > on_ground & & ( sector [ psect ] . floorstat & 2 ) & & p - > posz > = ( fz - ( i < < 8 ) - ( 16 < < 8 ) ) )
2020-05-17 21:44:53 +00:00
p - > posz = fz - ( i < < 8 ) ;
else
{
p - > on_ground = 0 ;
p - > poszv + = ( gc + 80 ) ; // (TICSPERFRAME<<6);
if ( p - > poszv > = ( 4096 + 2048 ) ) p - > poszv = ( 4096 + 2048 ) ;
if ( p - > poszv > 2400 & & p - > falling_counter < 255 )
{
p - > falling_counter + + ;
2020-10-25 05:50:31 +00:00
if ( p - > falling_counter = = 38 & & ! S_CheckActorSoundPlaying ( pact , DUKE_SCREAM ) )
S_PlayActorSound ( DUKE_SCREAM , pact ) ;
2020-05-17 21:44:53 +00:00
}
if ( ( p - > posz + p - > poszv ) > = ( fz - ( i < < 8 ) ) ) // hit the ground
2020-08-07 20:20:29 +00:00
{
2020-10-25 05:50:31 +00:00
S_StopSound ( DUKE_SCREAM , pact ) ;
2020-05-17 21:44:53 +00:00
if ( sector [ p - > cursectnum ] . lotag ! = 1 )
{
if ( p - > falling_counter > 62 ) quickkill ( p ) ;
else if ( p - > falling_counter > 9 )
{
j = p - > falling_counter ;
2020-10-25 05:50:31 +00:00
pact - > s . extra - = j - ( krand ( ) & 3 ) ;
if ( pact - > s . extra < = 0 )
2020-05-17 21:44:53 +00:00
{
2020-10-25 05:50:31 +00:00
S_PlayActorSound ( SQUISHED , pact ) ;
2020-05-17 21:44:53 +00:00
SetPlayerPal ( p , PalEntry ( 63 , 63 , 0 , 0 ) ) ;
}
else
{
2020-10-25 05:50:31 +00:00
S_PlayActorSound ( DUKE_LAND , pact ) ;
S_PlayActorSound ( DUKE_LAND_HURT , pact ) ;
2020-05-17 21:44:53 +00:00
}
SetPlayerPal ( p , PalEntry ( 32 , 16 , 0 , 0 ) ) ;
}
2020-10-25 05:50:31 +00:00
else if ( p - > poszv > 2048 ) S_PlayActorSound ( DUKE_LAND , pact ) ;
2020-05-17 21:44:53 +00:00
}
2020-08-07 20:20:29 +00:00
}
2020-05-17 21:44:53 +00:00
}
}
else
{
p - > falling_counter = 0 ;
2020-10-25 05:50:31 +00:00
S_StopSound ( - 1 , pact , CHAN_VOICE ) ;
2020-05-17 21:44:53 +00:00
2020-08-07 19:59:11 +00:00
if ( psectlotag ! = ST_1_ABOVE_WATER & & psectlotag ! = ST_2_UNDERWATER & & p - > on_ground = = 0 & & p - > poszv > ( 6144 > > 1 ) )
2020-05-17 21:44:53 +00:00
p - > hard_landing = p - > poszv > > 10 ;
p - > on_ground = 1 ;
if ( i = = 40 )
{
//Smooth on the ground
int k = ( ( fz - ( i < < 8 ) ) - p - > posz ) > > 1 ;
if ( abs ( k ) < 256 ) k = 0 ;
p - > posz + = k ;
p - > poszv - = 768 ;
if ( p - > poszv < 0 ) p - > poszv = 0 ;
}
else if ( p - > jumping_counter = = 0 )
{
p - > posz + = ( ( fz - ( i < < 7 ) ) - p - > posz ) > > 1 ; //Smooth on the water
if ( p - > on_warping_sector = = 0 & & p - > posz > fz - ( 16 < < 8 ) )
{
p - > posz = fz - ( 16 < < 8 ) ;
p - > poszv > > = 1 ;
}
}
p - > on_warping_sector = 0 ;
2020-08-28 20:51:05 +00:00
if ( actions & SB_CROUCH )
2020-05-17 21:44:53 +00:00
{
playerCrouch ( snum ) ;
}
// jumping
2020-08-28 20:51:05 +00:00
if ( ( actions & SB_JUMP ) = = 0 & & p - > jumping_toggle = = 1 )
2020-05-17 21:44:53 +00:00
p - > jumping_toggle = 0 ;
2020-08-28 20:51:05 +00:00
else if ( ( actions & SB_JUMP ) )
2020-05-17 21:44:53 +00:00
{
playerJump ( snum , fz , cz ) ;
}
2020-08-28 20:51:05 +00:00
if ( p - > jumping_counter & & ( actions & SB_JUMP ) = = 0 )
2020-05-17 21:44:53 +00:00
p - > jumping_toggle = 0 ;
}
if ( p - > jumping_counter )
{
2020-08-28 20:51:05 +00:00
if ( ( actions & SB_JUMP ) = = 0 & & p - > jumping_toggle = = 1 )
2020-05-17 21:44:53 +00:00
p - > jumping_toggle = 0 ;
if ( p - > jumping_counter < ( 1024 + 256 ) )
{
if ( psectlotag = = 1 & & p - > jumping_counter > 768 )
{
p - > jumping_counter = 0 ;
p - > poszv = - 512 ;
}
else
{
2020-11-15 11:07:03 +00:00
p - > poszv - = bsin ( 128 + p - > jumping_counter ) / 12 ;
2020-05-17 21:44:53 +00:00
p - > jumping_counter + = 180 ;
p - > on_ground = 0 ;
}
}
else
{
p - > jumping_counter = 0 ;
p - > poszv = 0 ;
}
}
p - > posz + = p - > poszv ;
if ( p - > posz < ( cz + ( 4 < < 8 ) ) )
{
p - > jumping_counter = 0 ;
if ( p - > poszv < 0 )
p - > posxv = p - > posyv = 0 ;
p - > poszv = 128 ;
p - > posz = cz + ( 4 < < 8 ) ;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-28 20:51:05 +00:00
static void underwater ( int snum , ESyncBits actions , int psect , int fz , int cz )
2020-05-17 21:44:53 +00:00
{
auto p = & ps [ snum ] ;
2020-10-25 06:01:58 +00:00
auto pact = p - > GetActor ( ) ;
2020-05-17 21:44:53 +00:00
int psectlotag = sector [ psect ] . lotag ;
// under water
p - > jumping_counter = 0 ;
p - > pycount + = 32 ;
p - > pycount & = 2047 ;
2020-11-15 11:07:03 +00:00
p - > pyoff = bsin ( p - > pycount , - 7 ) ;
2020-05-17 21:44:53 +00:00
2020-10-25 06:01:58 +00:00
if ( ! S_CheckActorSoundPlaying ( pact , DUKE_UNDERWATER ) )
S_PlayActorSound ( DUKE_UNDERWATER , pact ) ;
2020-05-17 21:44:53 +00:00
2020-08-28 20:51:05 +00:00
if ( actions & SB_JUMP )
2020-05-17 21:44:53 +00:00
{
// jump
if ( p - > poszv > 0 ) p - > poszv = 0 ;
p - > poszv - = 348 ;
if ( p - > poszv < - ( 256 * 6 ) ) p - > poszv = - ( 256 * 6 ) ;
}
2020-08-28 20:51:05 +00:00
else if ( actions & SB_CROUCH )
2020-05-17 21:44:53 +00:00
{
// crouch
if ( p - > poszv < 0 ) p - > poszv = 0 ;
p - > poszv + = 348 ;
if ( p - > poszv > ( 256 * 6 ) ) p - > poszv = ( 256 * 6 ) ;
}
else
{
// normal view
if ( p - > poszv < 0 )
{
p - > poszv + = 256 ;
if ( p - > poszv > 0 )
p - > poszv = 0 ;
}
if ( p - > poszv > 0 )
{
p - > poszv - = 256 ;
if ( p - > poszv < 0 )
p - > poszv = 0 ;
}
}
if ( p - > poszv > 2048 )
p - > poszv > > = 1 ;
p - > posz + = p - > poszv ;
if ( p - > posz > ( fz - ( 15 < < 8 ) ) )
p - > posz + = ( ( fz - ( 15 < < 8 ) ) - p - > posz ) > > 1 ;
if ( p - > posz < ( cz + ( 4 < < 8 ) ) )
{
p - > posz = cz + ( 4 < < 8 ) ;
p - > poszv = 0 ;
}
if ( p - > scuba_on & & ( krand ( ) & 255 ) < 8 )
{
2020-10-25 06:01:58 +00:00
auto j = spawn ( pact , WATERBUBBLE ) ;
2020-11-15 11:07:03 +00:00
j - > s . x + = bcos ( p - > angle . ang . asbuild ( ) + 64 - ( global_random & 128 ) , - 6 ) ;
j - > s . y + = bsin ( p - > angle . ang . asbuild ( ) + 64 - ( global_random & 128 ) , - 6 ) ;
2020-10-25 06:01:58 +00:00
j - > s . xrepeat = 3 ;
j - > s . yrepeat = 2 ;
j - > s . z = p - > posz + ( 8 < < 8 ) ;
2020-05-17 21:44:53 +00:00
}
}
2020-05-18 06:26:09 +00:00
2020-05-18 20:28:12 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int operateTripbomb ( int snum )
2020-05-18 06:26:09 +00:00
{
auto p = & ps [ snum ] ;
int sx , sy , sz ;
2020-10-23 21:18:05 +00:00
short sect , hw ;
DDukeActor * hitsprt ;
2020-05-18 06:26:09 +00:00
hitscan ( p - > posx , p - > posy , p - > posz ,
2020-11-15 11:07:03 +00:00
p - > cursectnum , p - > angle . ang . bcos ( ) ,
p - > angle . ang . bsin ( ) , - p - > horizon . sum ( ) . asq16 ( ) > > 11 ,
2020-10-23 21:18:05 +00:00
& sect , & hw , & hitsprt , & sx , & sy , & sz , CLIPMASK1 ) ;
2020-05-18 06:26:09 +00:00
2020-10-23 21:18:05 +00:00
if ( sect < 0 | | hitsprt )
2020-05-18 06:26:09 +00:00
return 0 ;
if ( hw > = 0 & & sector [ sect ] . lotag > 2 )
return 0 ;
if ( hw > = 0 & & wall [ hw ] . overpicnum > = 0 )
if ( wall [ hw ] . overpicnum = = BIGFORCE )
return 0 ;
2020-10-25 06:12:04 +00:00
DDukeActor * j ;
DukeSectIterator it ( sect ) ;
while ( j = it . Next ( ) )
2020-05-18 06:26:09 +00:00
{
2020-10-25 06:12:04 +00:00
auto sj = & j - > s ;
2020-10-14 19:16:54 +00:00
if ( sj - > picnum = = TRIPBOMB & &
abs ( sj - > z - sz ) < ( 12 < < 8 ) & & ( ( sj - > x - sx ) * ( sj - > x - sx ) + ( sj - > y - sy ) * ( sj - > y - sy ) ) < ( 290 * 290 ) )
2020-05-18 06:26:09 +00:00
return 0 ;
}
2020-10-25 06:12:04 +00:00
if ( j = = nullptr & & hw > = 0 & & ( wall [ hw ] . cstat & 16 ) = = 0 )
2020-05-18 06:26:09 +00:00
if ( ( wall [ hw ] . nextsector > = 0 & & sector [ wall [ hw ] . nextsector ] . lotag < = 2 ) | | ( wall [ hw ] . nextsector = = - 1 & & sector [ sect ] . lotag < = 2 ) )
if ( ( ( sx - p - > posx ) * ( sx - p - > posx ) + ( sy - p - > posy ) * ( sy - p - > posy ) ) < ( 290 * 290 ) )
{
p - > posz = p - > oposz ;
p - > poszv = 0 ;
return 1 ;
}
return 0 ;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-18 22:26:07 +00:00
static void fireweapon ( int snum )
2020-05-18 06:26:09 +00:00
{
auto p = & ps [ snum ] ;
2020-11-02 19:24:07 +00:00
auto pact = p - > GetActor ( ) ;
2020-05-18 06:26:09 +00:00
2020-08-27 05:54:49 +00:00
p - > crack_time = CRACK_TIME ;
2020-05-18 06:26:09 +00:00
if ( p - > holster_weapon = = 1 )
{
if ( p - > last_pissed_time < = ( 26 * 218 ) & & p - > weapon_pos = = - 9 )
{
p - > holster_weapon = 0 ;
2020-09-16 11:01:09 +00:00
p - > oweapon_pos = p - > weapon_pos = 10 ;
2020-05-18 06:26:09 +00:00
FTA ( 74 , p ) ;
}
}
else switch ( p - > curr_weapon )
{
case HANDBOMB_WEAPON :
p - > hbomb_hold_delay = 0 ;
if ( p - > ammo_amount [ HANDBOMB_WEAPON ] > 0 )
2020-05-18 22:26:07 +00:00
p - > kickback_pic = 1 ;
2020-05-18 06:26:09 +00:00
break ;
case HANDREMOTE_WEAPON :
p - > hbomb_hold_delay = 0 ;
2020-05-18 22:26:07 +00:00
p - > kickback_pic = 1 ;
2020-05-18 06:26:09 +00:00
break ;
case PISTOL_WEAPON :
if ( p - > ammo_amount [ PISTOL_WEAPON ] > 0 )
{
p - > ammo_amount [ PISTOL_WEAPON ] - - ;
2020-05-18 22:26:07 +00:00
p - > kickback_pic = 1 ;
2020-05-18 06:26:09 +00:00
}
break ;
case CHAINGUN_WEAPON :
if ( p - > ammo_amount [ CHAINGUN_WEAPON ] > 0 ) // && p->random_club_frame == 0)
2020-05-18 22:26:07 +00:00
p - > kickback_pic = 1 ;
2020-05-18 06:26:09 +00:00
break ;
case SHOTGUN_WEAPON :
if ( p - > ammo_amount [ SHOTGUN_WEAPON ] > 0 & & p - > random_club_frame = = 0 )
2020-05-18 22:26:07 +00:00
p - > kickback_pic = 1 ;
2020-05-18 06:26:09 +00:00
break ;
case TRIPBOMB_WEAPON :
if ( p - > ammo_amount [ TRIPBOMB_WEAPON ] > 0 )
{
if ( operateTripbomb ( snum ) )
2020-05-18 22:26:07 +00:00
p - > kickback_pic = 1 ;
2020-05-18 06:26:09 +00:00
}
break ;
case SHRINKER_WEAPON :
case GROW_WEAPON :
if ( p - > curr_weapon = = GROW_WEAPON )
{
if ( p - > ammo_amount [ GROW_WEAPON ] > 0 )
{
2020-05-18 22:26:07 +00:00
p - > kickback_pic = 1 ;
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( EXPANDERSHOOT , pact ) ;
2020-05-18 06:26:09 +00:00
}
}
else if ( p - > ammo_amount [ SHRINKER_WEAPON ] > 0 )
{
2020-05-18 22:26:07 +00:00
p - > kickback_pic = 1 ;
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( SHRINKER_FIRE , pact ) ;
2020-05-18 06:26:09 +00:00
}
break ;
case FREEZE_WEAPON :
if ( p - > ammo_amount [ FREEZE_WEAPON ] > 0 )
{
2020-05-18 22:26:07 +00:00
p - > kickback_pic = 1 ;
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( CAT_FIRE , pact ) ;
2020-05-18 06:26:09 +00:00
}
break ;
case DEVISTATOR_WEAPON :
if ( p - > ammo_amount [ DEVISTATOR_WEAPON ] > 0 )
{
2020-05-18 22:26:07 +00:00
p - > kickback_pic = 1 ;
2020-05-18 06:26:09 +00:00
p - > hbomb_hold_delay = ! p - > hbomb_hold_delay ;
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( CAT_FIRE , pact ) ;
2020-05-18 06:26:09 +00:00
}
break ;
case RPG_WEAPON :
if ( p - > ammo_amount [ RPG_WEAPON ] > 0 )
{
2020-05-18 22:26:07 +00:00
p - > kickback_pic = 1 ;
2020-05-18 06:26:09 +00:00
}
break ;
2020-05-18 20:28:12 +00:00
case FLAMETHROWER_WEAPON : // Twentieth Anniversary World Tour
if ( isWorldTour ( ) & & p - > ammo_amount [ FLAMETHROWER_WEAPON ] > 0 )
{
2020-05-18 22:26:07 +00:00
p - > kickback_pic = 1 ;
2020-05-18 20:28:12 +00:00
if ( sector [ p - > cursectnum ] . lotag ! = 2 )
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( FLAMETHROWER_INTRO , pact ) ;
2020-05-18 20:28:12 +00:00
}
break ;
2020-05-18 06:26:09 +00:00
case KNEE_WEAPON :
if ( p - > quick_kick = = 0 )
{
2020-05-18 22:26:07 +00:00
p - > kickback_pic = 1 ;
2020-05-18 06:26:09 +00:00
}
break ;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-30 22:33:41 +00:00
static void operateweapon ( int snum , ESyncBits actions , int psect )
2020-05-18 06:26:09 +00:00
{
auto p = & ps [ snum ] ;
2020-10-24 05:34:39 +00:00
auto pact = p - > GetActor ( ) ;
int i , k ;
2020-05-18 06:26:09 +00:00
// already firing...
2020-05-18 20:28:12 +00:00
switch ( p - > curr_weapon )
2020-05-18 06:26:09 +00:00
{
2020-05-18 20:28:12 +00:00
case HANDBOMB_WEAPON : // grenade in NAM
2020-08-28 20:51:05 +00:00
if ( p - > kickback_pic = = 6 & & ( actions & SB_FIRE ) )
2020-05-18 06:26:09 +00:00
{
p - > rapid_fire_hold = 1 ;
2020-05-18 20:28:12 +00:00
break ;
2020-05-18 06:26:09 +00:00
}
2020-05-18 22:26:07 +00:00
p - > kickback_pic + + ;
if ( p - > kickback_pic = = 12 )
2020-05-18 06:26:09 +00:00
{
2020-05-18 20:28:12 +00:00
p - > ammo_amount [ HANDBOMB_WEAPON ] - - ;
2020-05-18 06:26:09 +00:00
2020-08-28 20:51:05 +00:00
if ( p - > on_ground & & ( actions & SB_CROUCH ) )
2020-05-18 06:26:09 +00:00
{
k = 15 ;
2020-10-07 06:12:37 +00:00
i = mulscale16 ( p - > horizon . sum ( ) . asq16 ( ) , 20 ) ;
2020-05-18 06:26:09 +00:00
}
else
{
k = 140 ;
2020-10-07 06:12:37 +00:00
i = - 512 - mulscale16 ( p - > horizon . sum ( ) . asq16 ( ) , 20 ) ;
2020-05-18 06:26:09 +00:00
}
2020-10-24 05:34:39 +00:00
auto spawned = EGS ( p - > cursectnum ,
2020-11-15 11:07:03 +00:00
p - > posx + p - > angle . ang . bcos ( - 6 ) ,
p - > posy + p - > angle . ang . bsin ( - 6 ) ,
2020-05-18 06:26:09 +00:00
p - > posz , HEAVYHBOMB , - 16 , 9 , 9 ,
2020-10-24 05:34:39 +00:00
p - > angle . ang . asbuild ( ) , ( k + ( p - > hbomb_hold_delay < < 5 ) ) , i , pact , 1 ) ;
2020-05-18 06:26:09 +00:00
2020-05-18 20:28:12 +00:00
if ( isNam ( ) )
2020-05-18 06:26:09 +00:00
{
2020-10-24 05:34:39 +00:00
spawned - > s . extra = mulscale ( krand ( ) , NAM_GRENADE_LIFETIME_VAR , 14 ) ;
2020-05-18 06:26:09 +00:00
}
if ( k = = 15 )
{
2020-10-24 05:34:39 +00:00
spawned - > s . yvel = 3 ;
spawned - > s . z + = ( 8 < < 8 ) ;
2020-05-18 06:26:09 +00:00
}
2020-10-24 05:34:39 +00:00
k = hits ( pact ) ;
2020-05-18 06:26:09 +00:00
if ( k < 512 )
{
2020-10-24 05:34:39 +00:00
spawned - > s . ang + = 1024 ;
spawned - > s . zvel / = 3 ;
spawned - > s . xvel / = 3 ;
2020-05-18 06:26:09 +00:00
}
p - > hbomb_on = 1 ;
}
2020-08-28 20:51:05 +00:00
else if ( p - > kickback_pic < 12 & & ( actions & SB_FIRE ) )
2020-05-18 06:26:09 +00:00
p - > hbomb_hold_delay + + ;
2020-05-18 22:26:07 +00:00
else if ( p - > kickback_pic > 19 )
2020-05-18 06:26:09 +00:00
{
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 06:26:09 +00:00
// don't change to remote when in NAM: grenades are timed
2020-05-18 20:28:12 +00:00
if ( isNam ( ) ) checkavailweapon ( p ) ;
else
{
p - > curr_weapon = HANDREMOTE_WEAPON ;
p - > last_weapon = - 1 ;
2020-08-03 05:05:38 +00:00
p - > oweapon_pos = p - > weapon_pos = 10 ;
2020-05-18 20:28:12 +00:00
}
2020-05-18 06:26:09 +00:00
}
2020-05-18 20:28:12 +00:00
break ;
case HANDREMOTE_WEAPON : // knife in NAM
2020-05-18 22:26:07 +00:00
p - > kickback_pic + + ;
2020-05-18 06:26:09 +00:00
2020-05-18 22:26:07 +00:00
if ( p - > kickback_pic = = 2 )
2020-05-18 06:26:09 +00:00
{
2020-05-18 20:28:12 +00:00
p - > hbomb_on = 0 ;
2020-05-18 06:26:09 +00:00
}
2020-05-18 22:26:07 +00:00
if ( p - > kickback_pic = = 10 )
2020-05-18 06:26:09 +00:00
{
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 20:28:12 +00:00
int weapon = isNam ( ) ? TRIPBOMB_WEAPON : HANDBOMB_WEAPON ;
if ( p - > ammo_amount [ weapon ] > 0 )
fi . addweapon ( p , weapon ) ;
2020-05-18 06:26:09 +00:00
else
checkavailweapon ( p ) ;
}
2020-05-18 20:28:12 +00:00
break ;
2020-05-18 06:26:09 +00:00
2020-05-18 20:28:12 +00:00
case PISTOL_WEAPON : // m-16 in NAM
2020-05-18 22:26:07 +00:00
if ( p - > kickback_pic = = 1 )
2020-05-18 06:26:09 +00:00
{
2020-10-24 05:34:39 +00:00
fi . shoot ( pact , SHOTSPARK1 ) ;
S_PlayActorSound ( PISTOL_FIRE , pact ) ;
2020-08-30 22:33:41 +00:00
lastvisinc = ud . levelclock + 32 ;
2020-05-18 20:28:12 +00:00
p - > visibility = 0 ;
2020-05-18 06:26:09 +00:00
}
2020-05-18 22:26:07 +00:00
else if ( p - > kickback_pic = = 2 )
2020-10-24 05:34:39 +00:00
spawn ( pact , SHELL ) ;
2020-05-18 20:28:12 +00:00
2020-05-18 22:26:07 +00:00
p - > kickback_pic + + ;
2020-05-18 20:28:12 +00:00
2020-05-18 22:26:07 +00:00
if ( p - > kickback_pic > = 5 )
2020-05-18 20:28:12 +00:00
{
if ( p - > ammo_amount [ PISTOL_WEAPON ] < = 0 | | ( p - > ammo_amount [ PISTOL_WEAPON ] % ( isNam ( ) ? 20 : 12 ) ) )
2020-05-18 06:26:09 +00:00
{
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 20:28:12 +00:00
checkavailweapon ( p ) ;
2020-05-18 06:26:09 +00:00
}
2020-05-18 20:28:12 +00:00
else
2020-05-18 06:26:09 +00:00
{
2020-05-18 22:26:07 +00:00
switch ( p - > kickback_pic )
2020-05-18 06:26:09 +00:00
{
2020-05-18 20:28:12 +00:00
case 5 :
2020-10-24 05:34:39 +00:00
S_PlayActorSound ( EJECT_CLIP , pact ) ;
2020-05-18 20:28:12 +00:00
break ;
//#ifdef NAM
// case WEAPON2_RELOAD_TIME - 15:
//#else
case 8 :
//#endif
2020-10-24 05:34:39 +00:00
S_PlayActorSound ( INSERT_CLIP , pact ) ;
2020-05-18 20:28:12 +00:00
break ;
2020-05-18 06:26:09 +00:00
}
}
2020-05-18 20:28:12 +00:00
}
2020-05-18 06:26:09 +00:00
2020-05-18 20:28:12 +00:00
// 3 second re-load time
2020-05-18 22:26:07 +00:00
if ( p - > kickback_pic = = ( isNam ( ) ? 50 : 27 ) )
2020-05-18 20:28:12 +00:00
{
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 20:28:12 +00:00
checkavailweapon ( p ) ;
}
break ;
2020-05-18 06:26:09 +00:00
2020-05-18 20:28:12 +00:00
case SHOTGUN_WEAPON :
2020-05-18 06:26:09 +00:00
2020-05-18 22:26:07 +00:00
p - > kickback_pic + + ;
2020-05-18 06:26:09 +00:00
2020-05-18 22:26:07 +00:00
if ( p - > kickback_pic = = 4 )
2020-05-18 20:28:12 +00:00
{
2020-10-24 05:34:39 +00:00
for ( int i = 0 ; i < 7 ; i + + )
fi . shoot ( pact , SHOTGUN ) ;
2020-05-18 20:28:12 +00:00
p - > ammo_amount [ SHOTGUN_WEAPON ] - - ;
2020-05-18 06:26:09 +00:00
2020-10-24 05:34:39 +00:00
S_PlayActorSound ( SHOTGUN_FIRE , pact ) ;
2020-05-18 06:26:09 +00:00
2020-08-30 22:33:41 +00:00
lastvisinc = ud . levelclock + 32 ;
2020-05-18 20:28:12 +00:00
p - > visibility = 0 ;
2020-05-18 06:26:09 +00:00
}
2020-05-18 22:26:07 +00:00
switch ( p - > kickback_pic )
2020-05-18 06:26:09 +00:00
{
case 13 :
checkavailweapon ( p ) ;
break ;
case 15 :
2020-10-24 05:34:39 +00:00
S_PlayActorSound ( SHOTGUN_COCK , pact ) ;
2020-05-18 06:26:09 +00:00
break ;
case 17 :
case 20 :
p - > kickback_pic + + ;
break ;
case 24 :
2020-10-24 05:34:39 +00:00
{
auto j = spawn ( pact , SHOTGUNSHELL ) ;
j - > s . ang + = 1024 ;
2020-05-18 06:26:09 +00:00
ssp ( j , CLIPMASK0 ) ;
2020-10-24 05:34:39 +00:00
j - > s . ang + = 1024 ;
2020-05-18 06:26:09 +00:00
p - > kickback_pic + + ;
break ;
2020-10-24 05:34:39 +00:00
}
2020-05-18 06:26:09 +00:00
case 31 :
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 06:26:09 +00:00
return ;
}
break ;
case CHAINGUN_WEAPON : // m-60 in NAM
2020-05-18 22:26:07 +00:00
p - > kickback_pic + + ;
2020-05-18 06:26:09 +00:00
2020-05-18 22:26:07 +00:00
if ( p - > kickback_pic < = 12 )
2020-05-18 06:26:09 +00:00
{
2020-05-18 22:26:07 +00:00
if ( ( ( p - > kickback_pic ) % 3 ) = = 0 )
2020-05-18 06:26:09 +00:00
{
p - > ammo_amount [ CHAINGUN_WEAPON ] - - ;
2020-05-18 22:26:07 +00:00
if ( ( p - > kickback_pic % 3 ) = = 0 )
2020-05-18 06:26:09 +00:00
{
2020-10-24 05:34:39 +00:00
auto j = spawn ( pact , SHELL ) ;
2020-05-18 06:26:09 +00:00
2020-10-24 05:34:39 +00:00
j - > s . ang + = 1024 ;
j - > s . ang & = 2047 ;
j - > s . xvel + = 32 ;
j - > s . z + = ( 3 < < 8 ) ;
2020-05-18 06:26:09 +00:00
ssp ( j , CLIPMASK0 ) ;
}
2020-10-24 05:34:39 +00:00
S_PlayActorSound ( CHAINGUN_FIRE , pact ) ;
fi . shoot ( pact , CHAINGUN ) ;
2020-08-30 22:33:41 +00:00
lastvisinc = ud . levelclock + 32 ;
2020-05-18 06:26:09 +00:00
p - > visibility = 0 ;
checkavailweapon ( p ) ;
2020-08-28 20:51:05 +00:00
if ( ( actions & SB_FIRE ) = = 0 )
2020-05-18 06:26:09 +00:00
{
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 06:26:09 +00:00
break ;
}
}
}
2020-05-18 22:26:07 +00:00
else if ( p - > kickback_pic > 10 )
2020-05-18 06:26:09 +00:00
{
2020-08-28 20:51:05 +00:00
if ( actions & SB_FIRE ) p - > okickback_pic = p - > kickback_pic = 1 ;
2020-08-03 05:02:30 +00:00
else p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 06:26:09 +00:00
}
break ;
case GROW_WEAPON : // m-14 with scope (sniper rifle)
2020-05-18 20:28:12 +00:00
bool check ;
if ( isNam ( ) )
2020-05-18 06:26:09 +00:00
{
2020-05-18 22:26:07 +00:00
p - > kickback_pic + + ;
check = ( p - > kickback_pic = = 3 ) ;
2020-05-18 06:26:09 +00:00
}
else
{
2020-05-18 22:26:07 +00:00
check = ( p - > kickback_pic > 3 ) ;
2020-05-18 06:26:09 +00:00
}
2020-05-18 20:28:12 +00:00
if ( check )
2020-05-18 06:26:09 +00:00
{
2020-05-18 20:28:12 +00:00
// fire now, but don't reload right away...
if ( isNam ( ) )
{
2020-05-18 22:26:07 +00:00
p - > kickback_pic + + ;
2020-05-18 06:26:09 +00:00
if ( p - > ammo_amount [ p - > curr_weapon ] < = 1 )
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 06:26:09 +00:00
}
2020-05-18 20:28:12 +00:00
else
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 20:28:12 +00:00
p - > ammo_amount [ p - > curr_weapon ] - - ;
2020-10-24 05:34:39 +00:00
fi . shoot ( pact , GROWSPARK ) ;
2020-05-18 20:28:12 +00:00
//#ifdef NAM
//#else
if ( ! ( aplWeaponFlags [ p - > curr_weapon ] [ snum ] & WEAPON_FLAG_NOVISIBLE ) )
{
// make them visible if not set...
p - > visibility = 0 ;
2020-08-30 22:33:41 +00:00
lastvisinc = ud . levelclock + 32 ;
2020-05-18 06:26:09 +00:00
}
2020-05-18 20:28:12 +00:00
checkavailweapon ( p ) ;
//#endif
2020-05-18 06:26:09 +00:00
}
2020-05-18 22:26:07 +00:00
else if ( ! isNam ( ) ) p - > kickback_pic + + ;
if ( isNam ( ) & & p - > kickback_pic > aplWeaponReload [ p - > curr_weapon ] [ snum ] ) // 30)
2020-05-18 06:26:09 +00:00
{
2020-05-18 20:28:12 +00:00
// reload now...
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 20:28:12 +00:00
if ( ! ( aplWeaponFlags [ p - > curr_weapon ] [ snum ] & WEAPON_FLAG_NOVISIBLE ) )
2020-05-18 06:26:09 +00:00
{
2020-05-18 20:28:12 +00:00
// make them visible if not set...
2020-05-18 06:26:09 +00:00
p - > visibility = 0 ;
2020-08-30 22:33:41 +00:00
lastvisinc = ud . levelclock + 32 ;
2020-05-18 06:26:09 +00:00
}
2020-05-18 20:28:12 +00:00
checkavailweapon ( p ) ;
}
break ;
case SHRINKER_WEAPON : // m-79 in NAM (Grenade launcher)
2020-05-18 22:26:07 +00:00
if ( ( ! isNam ( ) & & p - > kickback_pic > 10 ) | | ( isNam ( ) & & p - > kickback_pic = = 10 ) )
2020-05-18 20:28:12 +00:00
{
2020-05-18 22:26:07 +00:00
if ( isNam ( ) ) p - > kickback_pic + + ; // fire now, but wait for reload...
2020-08-03 05:02:30 +00:00
else p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 20:28:12 +00:00
p - > ammo_amount [ SHRINKER_WEAPON ] - - ;
2020-10-24 05:34:39 +00:00
fi . shoot ( pact , SHRINKER ) ;
2020-05-18 20:28:12 +00:00
if ( ! isNam ( ) )
2020-05-18 06:26:09 +00:00
{
p - > visibility = 0 ;
2020-05-18 20:28:12 +00:00
//flashColor = 176 + (252 << 8) + (120 << 16);
2020-08-30 22:33:41 +00:00
lastvisinc = ud . levelclock + 32 ;
2020-05-18 06:26:09 +00:00
checkavailweapon ( p ) ;
}
}
2020-05-18 22:26:07 +00:00
else if ( isNam ( ) & & p - > kickback_pic > 30 )
2020-05-18 20:28:12 +00:00
{
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 20:28:12 +00:00
p - > visibility = 0 ;
2020-08-30 22:33:41 +00:00
lastvisinc = ud . levelclock + 32 ;
2020-05-18 20:28:12 +00:00
checkavailweapon ( p ) ;
}
2020-05-18 22:26:07 +00:00
else p - > kickback_pic + + ;
2020-05-18 06:26:09 +00:00
break ;
case DEVISTATOR_WEAPON :
2020-05-18 22:26:07 +00:00
if ( p - > kickback_pic )
2020-05-18 06:26:09 +00:00
{
2020-05-18 22:26:07 +00:00
p - > kickback_pic + + ;
2020-05-18 06:26:09 +00:00
2020-08-05 19:48:16 +00:00
if ( isNam ( ) )
{
if ( ( p - > kickback_pic > = 2 ) & &
p - > kickback_pic < 5 & &
2020-05-18 22:26:07 +00:00
( p - > kickback_pic & 1 ) )
2020-05-18 06:26:09 +00:00
{
2020-08-05 19:48:16 +00:00
p - > visibility = 0 ;
2020-08-30 22:33:41 +00:00
lastvisinc = ud . levelclock + 32 ;
2020-10-24 05:34:39 +00:00
fi . shoot ( pact , RPG ) ;
2020-05-18 06:26:09 +00:00
p - > ammo_amount [ DEVISTATOR_WEAPON ] - - ;
checkavailweapon ( p ) ;
}
2020-09-16 11:01:09 +00:00
if ( p - > kickback_pic > 5 ) p - > okickback_pic = p - > kickback_pic = 0 ;
2020-08-05 19:48:16 +00:00
}
else if ( p - > kickback_pic & 1 )
{
p - > visibility = 0 ;
2020-08-30 22:33:41 +00:00
lastvisinc = ud . levelclock + 32 ;
2020-10-24 05:34:39 +00:00
fi . shoot ( pact , RPG ) ;
2020-08-05 19:48:16 +00:00
p - > ammo_amount [ DEVISTATOR_WEAPON ] - - ;
checkavailweapon ( p ) ;
2020-09-16 11:01:09 +00:00
if ( p - > ammo_amount [ DEVISTATOR_WEAPON ] < = 0 ) p - > okickback_pic = p - > kickback_pic = 0 ;
2020-08-05 19:48:16 +00:00
}
2020-09-16 11:01:09 +00:00
if ( p - > kickback_pic > 5 ) p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 06:26:09 +00:00
}
break ;
case FREEZE_WEAPON :
// flame thrower in NAM
2020-05-18 22:26:07 +00:00
if ( p - > kickback_pic < 4 )
2020-05-18 06:26:09 +00:00
{
2020-05-18 22:26:07 +00:00
p - > kickback_pic + + ;
if ( p - > kickback_pic = = 3 )
2020-05-18 06:26:09 +00:00
{
p - > ammo_amount [ p - > curr_weapon ] - - ;
p - > visibility = 0 ;
2020-08-30 22:33:41 +00:00
lastvisinc = ud . levelclock + 32 ;
2020-10-24 05:34:39 +00:00
fi . shoot ( pact , FREEZEBLAST ) ;
2020-05-18 06:26:09 +00:00
checkavailweapon ( p ) ;
}
2020-10-24 05:34:39 +00:00
if ( pact - > s . xrepeat < 32 )
2020-05-18 06:26:09 +00:00
{
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ; break ;
2020-05-18 06:26:09 +00:00
}
}
else
{
2020-08-28 20:51:05 +00:00
if ( actions & SB_FIRE )
2020-05-18 06:26:09 +00:00
{
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 1 ;
2020-10-24 05:34:39 +00:00
S_PlayActorSound ( CAT_FIRE , pact ) ;
2020-05-18 06:26:09 +00:00
}
2020-09-16 11:01:09 +00:00
else p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 06:26:09 +00:00
}
break ;
2020-05-18 20:28:12 +00:00
case FLAMETHROWER_WEAPON :
if ( ! isWorldTour ( ) ) // Twentieth Anniversary World Tour
break ;
2020-05-18 22:26:07 +00:00
p - > kickback_pic + + ;
if ( p - > kickback_pic = = 2 )
2020-05-18 20:28:12 +00:00
{
if ( sector [ p - > cursectnum ] . lotag ! = 2 )
{
p - > ammo_amount [ FLAMETHROWER_WEAPON ] - - ;
if ( snum = = screenpeek )
g_visibility = 0 ;
2020-10-24 05:34:39 +00:00
fi . shoot ( pact , FIREBALL ) ;
2020-05-18 20:28:12 +00:00
}
checkavailweapon ( p ) ;
}
2020-05-18 22:26:07 +00:00
else if ( p - > kickback_pic = = 16 )
2020-05-18 20:28:12 +00:00
{
2020-08-28 20:51:05 +00:00
if ( ( actions & SB_FIRE ) ! = 0 )
2020-05-18 20:28:12 +00:00
{
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 1 ;
2020-10-24 05:34:39 +00:00
S_PlayActorSound ( FLAMETHROWER_INTRO , pact ) ;
2020-05-18 20:28:12 +00:00
}
else
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 20:28:12 +00:00
}
break ;
2020-05-18 06:26:09 +00:00
case TRIPBOMB_WEAPON : // Claymore in NAM
2020-05-18 22:26:07 +00:00
if ( p - > kickback_pic < 4 )
2020-05-18 06:26:09 +00:00
{
p - > posz = p - > oposz ;
p - > poszv = 0 ;
2020-05-18 22:26:07 +00:00
if ( p - > kickback_pic = = 3 )
2020-10-24 05:34:39 +00:00
fi . shoot ( pact , HANDHOLDINGLASER ) ;
2020-05-18 06:26:09 +00:00
}
2020-05-18 22:26:07 +00:00
if ( p - > kickback_pic = = 16 )
2020-05-18 06:26:09 +00:00
{
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 06:26:09 +00:00
checkavailweapon ( p ) ;
2020-08-03 05:05:38 +00:00
p - > oweapon_pos = p - > weapon_pos = - 9 ;
2020-05-18 06:26:09 +00:00
}
2020-05-18 22:26:07 +00:00
else p - > kickback_pic + + ;
2020-05-18 06:26:09 +00:00
break ;
case KNEE_WEAPON :
2020-05-18 22:26:07 +00:00
p - > kickback_pic + + ;
2020-05-18 06:26:09 +00:00
2020-10-24 05:34:39 +00:00
if ( p - > kickback_pic = = 7 ) fi . shoot ( pact , KNEE ) ;
2020-05-18 22:26:07 +00:00
else if ( p - > kickback_pic = = 14 )
2020-05-18 06:26:09 +00:00
{
2020-08-28 20:51:05 +00:00
if ( actions & SB_FIRE )
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 1 + ( krand ( ) & 3 ) ;
else p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 06:26:09 +00:00
}
if ( p - > wantweaponfire > = 0 )
checkavailweapon ( p ) ;
break ;
case RPG_WEAPON : // m-72 in NAM (LAW)
2020-05-18 22:26:07 +00:00
p - > kickback_pic + + ;
if ( p - > kickback_pic = = 4 )
2020-05-18 06:26:09 +00:00
{
p - > ammo_amount [ RPG_WEAPON ] - - ;
2020-08-30 22:33:41 +00:00
lastvisinc = ud . levelclock + 32 ;
2020-05-18 06:26:09 +00:00
p - > visibility = 0 ;
2020-10-24 05:34:39 +00:00
fi . shoot ( pact , RPG ) ;
2020-05-18 06:26:09 +00:00
checkavailweapon ( p ) ;
}
2020-08-19 09:44:08 +00:00
else if ( p - > kickback_pic = = ( cl_dukefixrpgrecoil ? 13 : 20 ) )
2020-08-03 05:02:30 +00:00
p - > okickback_pic = p - > kickback_pic = 0 ;
2020-05-18 06:26:09 +00:00
break ;
}
}
2020-05-18 20:28:12 +00:00
2020-05-19 07:54:52 +00:00
//---------------------------------------------------------------------------
//
// this function exists because gotos suck. :P
//
//---------------------------------------------------------------------------
2020-08-29 11:32:14 +00:00
static void processweapon ( int snum , ESyncBits actions , int psect )
2020-05-19 07:54:52 +00:00
{
auto p = & ps [ snum ] ;
2020-10-25 05:34:25 +00:00
auto pact = p - > GetActor ( ) ;
auto s = & pact - > s ;
2020-05-19 07:54:52 +00:00
int shrunk = ( s - > yrepeat < 32 ) ;
2020-08-27 23:57:40 +00:00
// Set maximum for pistol slightly higher if playing with `cl_showmagamount 1`.
if ( ! cl_showmagamt )
{
if ( p - > ammo_amount [ PISTOL_WEAPON ] > PISTOL_MAXDEFAULT )
p - > ammo_amount [ PISTOL_WEAPON ] = PISTOL_MAXDEFAULT ;
if ( max_ammo_amount [ PISTOL_WEAPON ] ! = PISTOL_MAXDEFAULT )
max_ammo_amount [ PISTOL_WEAPON ] = PISTOL_MAXDEFAULT ;
}
else
{
short pistolAddition = 4 ;
short pistolNewMaximum = PISTOL_MAXDEFAULT + pistolAddition ;
if ( p - > ammo_amount [ PISTOL_WEAPON ] = = PISTOL_MAXDEFAULT & & max_ammo_amount [ PISTOL_WEAPON ] = = PISTOL_MAXDEFAULT )
p - > ammo_amount [ PISTOL_WEAPON ] + = pistolAddition ;
if ( max_ammo_amount [ PISTOL_WEAPON ] ! = pistolNewMaximum )
max_ammo_amount [ PISTOL_WEAPON ] = pistolNewMaximum ;
}
2020-08-27 22:03:35 +00:00
if ( isNamWW2GI ( ) & & ( actions & SB_HOLSTER ) ) // 'Holster Weapon
2020-05-19 07:54:52 +00:00
{
if ( isWW2GI ( ) )
{
2020-11-01 17:23:09 +00:00
SetGameVarID ( g_iReturnVarID , 0 , p - > GetActor ( ) , snum ) ;
SetGameVarID ( g_iWeaponVarID , p - > curr_weapon , p - > GetActor ( ) , snum ) ;
SetGameVarID ( g_iWorksLikeVarID , aplWeaponWorksLike [ p - > curr_weapon ] [ snum ] , p - > GetActor ( ) , snum ) ;
2020-11-01 16:57:40 +00:00
OnEvent ( EVENT_HOLSTER , snum , p - > GetActor ( ) , - 1 ) ;
2020-11-01 17:23:09 +00:00
if ( GetGameVarID ( g_iReturnVarID , p - > GetActor ( ) , snum ) = = 0 )
2020-05-19 07:54:52 +00:00
{
// now it uses the game definitions...
if ( aplWeaponFlags [ p - > curr_weapon ] [ snum ] & WEAPON_FLAG_HOLSTER_CLEARS_CLIP )
{
if ( p - > ammo_amount [ p - > curr_weapon ] > aplWeaponClip [ p - > curr_weapon ] [ snum ]
& & ( p - > ammo_amount [ p - > curr_weapon ] % aplWeaponClip [ p - > curr_weapon ] [ snum ] ) ! = 0 )
{
// throw away the remaining clip
p - > ammo_amount [ p - > curr_weapon ] - =
p - > ammo_amount [ p - > curr_weapon ] % aplWeaponClip [ p - > curr_weapon ] [ snum ] ;
// p->kickback_pic = aplWeaponFireDelay[p->curr_weapon][snum]+1; // animate, but don't shoot...
p - > kickback_pic = aplWeaponTotalTime [ p - > curr_weapon ] [ snum ] + 1 ; // animate, but don't shoot...
2020-08-28 20:51:05 +00:00
actions & = ~ SB_FIRE ; // not firing...
2020-05-19 07:54:52 +00:00
}
return ;
}
}
}
else if ( p - > curr_weapon = = PISTOL_WEAPON )
{
if ( p - > ammo_amount [ PISTOL_WEAPON ] > 20 )
{
// throw away the remaining clip
p - > ammo_amount [ PISTOL_WEAPON ] - = p - > ammo_amount [ PISTOL_WEAPON ] % 20 ;
p - > kickback_pic = 3 ; // animate, but don't shoot...
2020-08-28 20:51:05 +00:00
actions & = ~ SB_FIRE ; // not firing...
2020-05-19 07:54:52 +00:00
}
return ;
}
}
if ( isWW2GI ( ) & & ( aplWeaponFlags [ p - > curr_weapon ] [ snum ] & WEAPON_FLAG_GLOWS ) )
p - > random_club_frame + = 64 ; // Glowing
if ( ! isWW2GI ( ) & & ( p - > curr_weapon = = SHRINKER_WEAPON | | p - > curr_weapon = = GROW_WEAPON ) )
p - > random_club_frame + = 64 ; // Glowing
if ( p - > rapid_fire_hold = = 1 )
{
2020-08-28 20:51:05 +00:00
if ( actions & SB_FIRE ) return ;
2020-05-19 07:54:52 +00:00
p - > rapid_fire_hold = 0 ;
}
if ( shrunk | | p - > tipincs | | p - > access_incs )
2020-08-28 20:51:05 +00:00
actions & = ~ SB_FIRE ;
else if ( shrunk = = 0 & & ( actions & SB_FIRE ) & & p - > kickback_pic = = 0 & & p - > fist_incs = = 0 & &
2020-05-19 07:54:52 +00:00
p - > last_weapon = = - 1 & & ( p - > weapon_pos = = 0 | | p - > holster_weapon = = 1 ) )
{
if ( ! isWW2GI ( ) ) fireweapon ( snum ) ;
else fireweapon_ww ( snum ) ;
}
else if ( p - > kickback_pic )
{
2020-08-30 22:33:41 +00:00
if ( ! isWW2GI ( ) ) operateweapon ( snum , actions , psect ) ;
else operateweapon_ww ( snum , actions , psect ) ;
2020-05-19 07:54:52 +00:00
}
}
2020-05-18 22:26:07 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-19 07:03:07 +00:00
void processinput_d ( int snum )
2020-05-18 22:26:07 +00:00
{
2020-11-02 23:20:51 +00:00
int j , k , doubvel , fz , cz , truefdist ;
2020-10-25 06:12:04 +00:00
Collision chz , clz ;
bool shrunk ;
2020-08-27 22:03:35 +00:00
ESyncBits actions ;
2020-11-02 19:24:07 +00:00
short psect , psectlotag ;
2020-05-18 22:26:07 +00:00
struct player_struct * p ;
spritetype * s ;
p = & ps [ snum ] ;
2020-10-25 05:34:25 +00:00
auto pact = p - > GetActor ( ) ;
s = & pact - > s ;
2020-05-18 22:26:07 +00:00
2020-10-12 03:42:43 +00:00
p - > horizon . resetadjustment ( ) ;
p - > angle . resetadjustment ( ) ;
2020-05-19 17:50:31 +00:00
2020-08-27 22:03:35 +00:00
actions = PlayerInputBits ( snum , SB_ALL ) ;
2020-05-18 22:26:07 +00:00
2020-07-03 19:44:57 +00:00
auto sb_fvel = PlayerInputForwardVel ( snum ) ;
auto sb_svel = PlayerInputSideVel ( snum ) ;
auto sb_avel = PlayerInputAngVel ( snum ) ;
2020-05-18 22:26:07 +00:00
psect = p - > cursectnum ;
if ( psect = = - 1 )
{
if ( s - > extra > 0 & & ud . clipping = = 0 )
{
quickkill ( p ) ;
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( SQUISHED , pact ) ;
2020-05-18 22:26:07 +00:00
}
psect = 0 ;
}
psectlotag = sector [ psect ] . lotag ;
p - > spritebridge = 0 ;
shrunk = ( s - > yrepeat < 32 ) ;
2020-10-25 06:12:04 +00:00
getzrange_ex ( p - > posx , p - > posy , p - > posz , psect , & cz , chz , & fz , clz , 163L , CLIPMASK0 ) ;
2020-05-18 22:26:07 +00:00
j = getflorzofslope ( psect , p - > posx , p - > posy ) ;
p - > truefz = j ;
p - > truecz = getceilzofslope ( psect , p - > posx , p - > posy ) ;
truefdist = abs ( p - > posz - j ) ;
2020-10-25 06:12:04 +00:00
if ( clz . type = = kHitSector & & psectlotag = = 1 & & truefdist > PHEIGHT + ( 16 < < 8 ) )
2020-05-18 22:26:07 +00:00
psectlotag = 0 ;
2020-10-25 05:50:31 +00:00
pact - > floorz = fz ;
pact - > ceilingz = cz ;
2020-05-18 22:26:07 +00:00
2020-07-28 11:38:20 +00:00
if ( cl_syncinput )
2020-05-18 22:26:07 +00:00
{
2020-10-07 06:12:37 +00:00
p - > horizon . backup ( ) ;
2020-07-17 22:34:20 +00:00
calcviewpitch ( p , 1 ) ;
2020-05-18 22:26:07 +00:00
}
2020-10-25 06:12:04 +00:00
if ( chz . type = = kHitSprite )
2020-05-18 22:26:07 +00:00
{
2020-10-25 06:12:04 +00:00
if ( chz . actor - > s . statnum = = 1 & & chz . actor - > s . extra > = 0 )
2020-05-18 22:26:07 +00:00
{
2020-10-25 06:12:04 +00:00
chz . type = kHitNone ;
chz . actor = nullptr ;
2020-05-18 22:26:07 +00:00
cz = p - > truecz ;
}
}
2020-10-25 06:12:04 +00:00
if ( clz . type = = kHitSprite )
2020-05-18 22:26:07 +00:00
{
2020-10-25 06:12:04 +00:00
if ( ( clz . actor - > s . cstat & 33 ) = = 33 )
2020-05-18 22:26:07 +00:00
{
psectlotag = 0 ;
p - > footprintcount = 0 ;
p - > spritebridge = 1 ;
}
2020-10-25 06:12:04 +00:00
else if ( badguy ( clz . actor ) & & clz . actor - > s . xrepeat > 24 & & abs ( s - > z - clz . actor - > s . z ) < ( 84 < < 8 ) )
2020-05-18 22:26:07 +00:00
{
2020-10-25 06:12:04 +00:00
j = getangle ( clz . actor - > s . x - p - > posx , clz . actor - > s . y - p - > posy ) ;
2020-11-15 11:07:03 +00:00
p - > posxv - = bcos ( j , 4 ) ;
p - > posyv - = bsin ( j , 4 ) ;
2020-05-18 22:26:07 +00:00
}
}
if ( s - > extra > 0 ) fi . incur_damage ( p ) ;
else
{
s - > extra = 0 ;
p - > shield_amount = 0 ;
}
p - > last_extra = s - > extra ;
if ( p - > loogcnt > 0 ) p - > loogcnt - - ;
else p - > loogcnt = 0 ;
if ( p - > fist_incs )
{
if ( endoflevel ( snum ) ) return ;
}
if ( p - > timebeforeexit > 1 & & p - > last_extra > 0 )
{
if ( timedexit ( snum ) )
return ;
}
2020-07-16 13:03:09 +00:00
if ( s - > extra < = 0 & & ! ud . god )
2020-05-18 22:26:07 +00:00
{
playerisdead ( snum , psectlotag , fz , cz ) ;
2020-07-16 13:03:09 +00:00
return ;
2020-05-18 22:26:07 +00:00
}
if ( p - > transporter_hold > 0 )
{
p - > transporter_hold - - ;
if ( p - > transporter_hold = = 0 & & p - > on_warping_sector )
p - > transporter_hold = 2 ;
}
if ( p - > transporter_hold < 0 )
p - > transporter_hold + + ;
2020-11-02 23:20:51 +00:00
if ( p - > newOwner ! = nullptr )
2020-05-18 22:26:07 +00:00
{
p - > posxv = p - > posyv = s - > xvel = 0 ;
fi . doincrements ( p ) ;
2020-08-29 11:32:14 +00:00
if ( isWW2GI ( ) & & aplWeaponWorksLike [ p - > curr_weapon ] [ snum ] = = HANDREMOTE_WEAPON ) processweapon ( snum , actions , psect ) ;
if ( ! isWW2GI ( ) & & p - > curr_weapon = = HANDREMOTE_WEAPON ) processweapon ( snum , actions , psect ) ;
2020-05-18 22:26:07 +00:00
return ;
}
doubvel = TICSPERFRAME ;
2020-08-29 11:32:14 +00:00
checklook ( snum , actions ) ;
2020-11-02 23:20:51 +00:00
int ii = 40 ;
2020-05-18 22:26:07 +00:00
2020-10-17 08:44:00 +00:00
if ( p - > on_crane ! = nullptr )
2020-05-18 22:26:07 +00:00
goto HORIZONLY ;
2020-08-05 10:04:14 +00:00
playerweaponsway ( p , s ) ;
2020-05-18 22:26:07 +00:00
2020-08-09 06:24:48 +00:00
s - > xvel = clamp ( ksqrt ( ( p - > posx - p - > bobposx ) * ( p - > posx - p - > bobposx ) + ( p - > posy - p - > bobposy ) * ( p - > posy - p - > bobposy ) ) , 0 , 512 ) ;
2020-10-23 19:40:49 +00:00
if ( p - > on_ground ) p - > bobcounter + = p - > GetActor ( ) - > s . xvel > > 1 ;
2020-05-18 22:26:07 +00:00
2020-07-29 22:49:01 +00:00
backuppos ( p , ud . clipping = = 0 & & ( sector [ p - > cursectnum ] . floorpicnum = = MIRROR | | p - > cursectnum < 0 | | p - > cursectnum > = MAXSECTORS ) ) ;
2020-05-18 22:26:07 +00:00
// Shrinking code
2020-07-16 13:03:09 +00:00
if ( psectlotag = = ST_2_UNDERWATER )
2020-05-18 22:26:07 +00:00
{
2020-08-28 20:51:05 +00:00
underwater ( snum , actions , psect , fz , cz ) ;
2020-05-18 22:26:07 +00:00
}
else if ( p - > jetpack_on )
{
2020-08-28 20:51:05 +00:00
operateJetpack ( snum , actions , psectlotag , fz , cz , shrunk ) ;
2020-05-18 22:26:07 +00:00
}
2020-07-16 13:03:09 +00:00
else if ( psectlotag ! = ST_2_UNDERWATER )
2020-05-18 22:26:07 +00:00
{
2020-08-28 20:51:05 +00:00
movement ( snum , actions , psect , fz , cz , shrunk , truefdist , psectlotag ) ;
2020-05-18 22:26:07 +00:00
}
2020-08-05 12:57:47 +00:00
p - > psectlotag = psectlotag ;
2020-05-18 22:26:07 +00:00
//Do the quick lefts and rights
2020-07-17 23:34:13 +00:00
if ( movementBlocked ( snum ) )
2020-05-18 22:26:07 +00:00
{
doubvel = 0 ;
p - > posxv = 0 ;
p - > posyv = 0 ;
}
2020-08-03 11:19:45 +00:00
else if ( cl_syncinput )
2020-07-28 12:12:09 +00:00
{
//p->ang += syncangvel * constant
//ENGINE calculates angvel for you
// may still be needed later for demo recording
2020-05-18 22:26:07 +00:00
2020-10-08 03:47:30 +00:00
processavel ( p , & sb_avel ) ;
2020-11-07 07:25:06 +00:00
applylook ( & p - > angle , sb_avel , & p - > sync . actions ) ;
2020-05-18 22:26:07 +00:00
}
if ( p - > spritebridge = = 0 )
{
j = sector [ s - > sectnum ] . floorpicnum ;
if ( j = = PURPLELAVA | | sector [ s - > sectnum ] . ceilingpicnum = = PURPLELAVA )
{
if ( p - > boot_amount > 0 )
{
p - > boot_amount - - ;
p - > inven_icon = 7 ;
if ( p - > boot_amount < = 0 )
checkavailinven ( p ) ;
}
else
{
2020-11-02 19:24:07 +00:00
if ( ! S_CheckActorSoundPlaying ( pact , DUKE_LONGTERM_PAIN ) )
S_PlayActorSound ( DUKE_LONGTERM_PAIN , pact ) ;
2020-05-18 22:26:07 +00:00
SetPlayerPal ( p , PalEntry ( 32 , 0 , 8 , 0 ) ) ;
s - > extra - - ;
}
}
k = 0 ;
if ( p - > on_ground & & truefdist < = PHEIGHT + ( 16 < < 8 ) )
{
2020-08-07 21:30:08 +00:00
int whichsound = j = = HURTRAIL ? 0 : j = = FLOORSLIME ? 1 : j = = FLOORPLASMA ? 2 : - 1 ;
2020-05-18 22:26:07 +00:00
if ( j > = 0 ) k = makepainsounds ( snum , whichsound ) ;
}
if ( k )
{
FTA ( 75 , p ) ;
p - > boot_amount - = 2 ;
if ( p - > boot_amount < = 0 )
checkavailinven ( p ) ;
}
}
if ( p - > posxv | | p - > posyv | | sb_fvel | | sb_svel )
{
2020-08-27 05:54:49 +00:00
p - > crack_time = CRACK_TIME ;
2020-05-18 22:26:07 +00:00
2020-11-15 11:07:03 +00:00
k = bsin ( p - > bobcounter , - 12 ) ;
2020-05-18 22:26:07 +00:00
if ( truefdist < PHEIGHT + ( 8 < < 8 ) & & ( k = = 1 | | k = = 3 ) )
{
if ( p - > spritebridge = = 0 & & p - > walking_snd_toggle = = 0 & & p - > on_ground )
{
switch ( psectlotag )
{
case 0 :
2020-10-25 06:12:04 +00:00
if ( clz . type = = kHitSprite )
j = clz . actor - > s . picnum ;
else
j = sector [ psect ] . floorpicnum ;
2020-05-18 22:26:07 +00:00
switch ( j )
{
case PANNEL1 :
case PANNEL2 :
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( DUKE_WALKINDUCTS , pact ) ;
2020-05-18 22:26:07 +00:00
p - > walking_snd_toggle = 1 ;
break ;
}
break ;
case 1 :
if ( ( krand ( ) & 1 ) = = 0 )
2020-11-02 19:24:07 +00:00
S_PlayActorSound ( DUKE_ONWATER , pact ) ;
2020-05-18 22:26:07 +00:00
p - > walking_snd_toggle = 1 ;
break ;
}
}
}
else if ( p - > walking_snd_toggle > 0 )
p - > walking_snd_toggle - - ;
if ( p - > jetpack_on = = 0 & & p - > steroids_amount > 0 & & p - > steroids_amount < 400 )
doubvel < < = 1 ;
p - > posxv + = ( ( sb_fvel * doubvel ) < < 6 ) ;
p - > posyv + = ( ( sb_svel * doubvel ) < < 6 ) ;
bool check ;
2020-08-28 20:51:05 +00:00
if ( ! isWW2GI ( ) ) check = ( ( p - > curr_weapon = = KNEE_WEAPON & & p - > kickback_pic > 10 & & p - > on_ground ) | | ( p - > on_ground & & ( actions & SB_CROUCH ) ) ) ;
else check = ( ( aplWeaponWorksLike [ p - > curr_weapon ] [ snum ] = = KNEE_WEAPON & & p - > kickback_pic > 10 & & p - > on_ground ) | | ( p - > on_ground & & ( actions & SB_CROUCH ) ) ) ;
2020-05-18 22:26:07 +00:00
if ( check )
{
p - > posxv = mulscale ( p - > posxv , dukefriction - 0x2000 , 16 ) ;
p - > posyv = mulscale ( p - > posyv , dukefriction - 0x2000 , 16 ) ;
}
else
{
if ( psectlotag = = 2 )
{
p - > posxv = mulscale ( p - > posxv , dukefriction - 0x1400 , 16 ) ;
p - > posyv = mulscale ( p - > posyv , dukefriction - 0x1400 , 16 ) ;
}
else
{
p - > posxv = mulscale ( p - > posxv , dukefriction , 16 ) ;
p - > posyv = mulscale ( p - > posyv , dukefriction , 16 ) ;
}
}
if ( abs ( p - > posxv ) < 2048 & & abs ( p - > posyv ) < 2048 )
p - > posxv = p - > posyv = 0 ;
if ( shrunk )
{
p - > posxv =
mulscale16 ( p - > posxv , dukefriction - ( dukefriction > > 1 ) + ( dukefriction > > 2 ) ) ;
p - > posyv =
mulscale16 ( p - > posyv , dukefriction - ( dukefriction > > 1 ) + ( dukefriction > > 2 ) ) ;
}
}
HORIZONLY :
2020-11-02 23:20:51 +00:00
if ( psectlotag = = 1 | | p - > spritebridge = = 1 ) ii = ( 4L < < 8 ) ;
else ii = ( 20L < < 8 ) ;
2020-05-18 22:26:07 +00:00
if ( sector [ p - > cursectnum ] . lotag = = 2 ) k = 0 ;
else k = 1 ;
2020-10-25 07:50:03 +00:00
Collision clip { } ;
2020-05-18 22:26:07 +00:00
if ( ud . clipping )
{
p - > posx + = p - > posxv > > 14 ;
p - > posy + = p - > posyv > > 14 ;
updatesector ( p - > posx , p - > posy , & p - > cursectnum ) ;
2020-11-02 19:24:07 +00:00
changespritesect ( pact , p - > cursectnum ) ;
2020-05-18 22:26:07 +00:00
}
else
2020-10-25 07:50:03 +00:00
clipmove_ex ( & p - > posx , & p - > posy ,
2020-05-18 22:26:07 +00:00
& p - > posz , & p - > cursectnum ,
2020-11-02 23:20:51 +00:00
p - > posxv , p - > posyv , 164L , ( 4L < < 8 ) , ii , CLIPMASK0 , clip ) ;
2020-05-18 22:26:07 +00:00
if ( p - > jetpack_on = = 0 & & psectlotag ! = 2 & & psectlotag ! = 1 & & shrunk )
p - > posz + = 32 < < 8 ;
2020-10-25 07:50:03 +00:00
if ( clip . type ! = kHitNone )
checkplayerhurt_d ( p , clip ) ;
2020-05-18 22:26:07 +00:00
if ( p - > jetpack_on = = 0 )
{
if ( s - > xvel > 16 )
{
if ( psectlotag ! = 1 & & psectlotag ! = 2 & & p - > on_ground )
{
p - > pycount + = 52 ;
p - > pycount & = 2047 ;
2020-11-15 11:07:03 +00:00
p - > pyoff = abs ( s - > xvel * bsin ( p - > pycount ) ) / 1596 ;
2020-05-18 22:26:07 +00:00
}
}
else if ( psectlotag ! = 2 & & psectlotag ! = 1 )
p - > pyoff = 0 ;
}
// RBG***
2020-11-02 19:24:07 +00:00
setsprite ( pact , p - > posx , p - > posy , p - > posz + PHEIGHT ) ;
2020-05-18 22:26:07 +00:00
if ( psectlotag < 3 )
{
psect = s - > sectnum ;
if ( ud . clipping = = 0 & & sector [ psect ] . lotag = = 31 )
{
2020-11-04 18:09:38 +00:00
auto secact = ScriptIndexToActor ( sector [ psect ] . hitag ) ;
if ( secact & & secact - > s . xvel & & secact - > temp_data [ 0 ] = = 0 )
2020-05-18 22:26:07 +00:00
{
quickkill ( p ) ;
return ;
}
}
}
if ( truefdist < PHEIGHT & & p - > on_ground & & psectlotag ! = 1 & & shrunk = = 0 & & sector [ p - > cursectnum ] . lotag = = 1 )
2020-10-25 07:50:03 +00:00
if ( ! S_CheckActorSoundPlaying ( pact , DUKE_ONWATER ) )
S_PlayActorSound ( DUKE_ONWATER , pact ) ;
2020-05-18 22:26:07 +00:00
if ( p - > cursectnum ! = s - > sectnum )
2020-11-02 19:24:07 +00:00
changespritesect ( pact , p - > cursectnum ) ;
2020-05-18 22:26:07 +00:00
if ( ud . clipping = = 0 )
2020-10-21 23:12:16 +00:00
j = ( pushmove ( & p - > posx , & p - > posy , & p - > posz , & p - > cursectnum , 164L , ( 4L < < 8 ) , ( 4L < < 8 ) , CLIPMASK0 ) < 0 & & furthestangle ( p - > GetActor ( ) , 8 ) < 512 ) ;
2020-05-18 22:26:07 +00:00
else j = 0 ;
if ( ud . clipping = = 0 )
{
2020-10-25 05:50:31 +00:00
if ( abs ( pact - > floorz - pact - > ceilingz ) < ( 48 < < 8 ) | | j )
2020-05-18 22:26:07 +00:00
{
if ( ! ( sector [ s - > sectnum ] . lotag & 0x8000 ) & & ( isanunderoperator ( sector [ s - > sectnum ] . lotag ) | |
isanearoperator ( sector [ s - > sectnum ] . lotag ) ) )
2020-11-02 18:28:59 +00:00
fi . activatebysector ( s - > sectnum , pact ) ;
2020-05-18 22:26:07 +00:00
if ( j )
{
quickkill ( p ) ;
return ;
}
}
else if ( abs ( fz - cz ) < ( 32 < < 8 ) & & isanunderoperator ( sector [ psect ] . lotag ) )
2020-11-02 18:28:59 +00:00
fi . activatebysector ( psect , pact ) ;
2020-05-18 22:26:07 +00:00
}
// center_view
2020-08-27 22:03:35 +00:00
if ( actions & SB_CENTERVIEW | | p - > hard_landing )
2020-05-18 22:26:07 +00:00
{
playerCenterView ( snum ) ;
}
2020-08-29 11:32:14 +00:00
else if ( actions & SB_LOOK_UP )
2020-05-18 22:26:07 +00:00
{
2020-08-28 22:57:07 +00:00
playerLookUp ( snum , actions ) ;
2020-05-18 22:26:07 +00:00
}
2020-08-29 11:32:14 +00:00
else if ( actions & SB_LOOK_DOWN )
2020-05-18 22:26:07 +00:00
{
2020-08-28 22:57:07 +00:00
playerLookDown ( snum , actions ) ;
2020-05-18 22:26:07 +00:00
}
2020-08-29 11:32:14 +00:00
else if ( actions & SB_AIM_UP )
2020-05-18 22:26:07 +00:00
{
2020-08-28 22:57:07 +00:00
playerAimUp ( snum , actions ) ;
2020-05-18 22:26:07 +00:00
}
2020-08-29 11:32:14 +00:00
else if ( actions & SB_AIM_DOWN )
2020-05-18 22:26:07 +00:00
{ // aim_down
2020-08-28 22:57:07 +00:00
playerAimDown ( snum , actions ) ;
2020-05-18 22:26:07 +00:00
}
2020-07-17 01:00:43 +00:00
2020-08-05 07:53:22 +00:00
if ( cl_syncinput )
{
2020-11-07 07:25:06 +00:00
sethorizon ( & p - > horizon . horiz , PlayerHorizon ( snum ) , & p - > sync . actions ) ;
2020-08-05 07:53:22 +00:00
}
2020-08-05 09:24:32 +00:00
checkhardlanding ( p ) ;
2020-05-18 22:26:07 +00:00
//Shooting code/changes
if ( p - > show_empty_weapon > 0 )
{
p - > show_empty_weapon - - ;
if ( p - > show_empty_weapon = = 0 )
{
if ( p - > last_full_weapon = = GROW_WEAPON )
p - > subweapon | = ( 1 < < GROW_WEAPON ) ;
else if ( p - > last_full_weapon = = SHRINKER_WEAPON )
p - > subweapon & = ~ ( 1 < < GROW_WEAPON ) ;
fi . addweapon ( p , p - > last_full_weapon ) ;
return ;
}
}
2020-10-23 17:50:18 +00:00
dokneeattack ( snum , { FEM1 , FEM2 , FEM3 , FEM4 , FEM5 , FEM6 , FEM7 , FEM8 , FEM9 , FEM10 , PODFEM1 , NAKED1 , STATUE } ) ;
2020-05-18 22:26:07 +00:00
if ( fi . doincrements ( p ) ) return ;
if ( p - > weapon_pos ! = 0 )
{
if ( p - > weapon_pos = = - 9 )
{
if ( p - > last_weapon > = 0 )
{
2020-09-16 11:01:09 +00:00
p - > oweapon_pos = p - > weapon_pos = 10 ;
2020-05-18 22:26:07 +00:00
// if(p->curr_weapon == KNEE_WEAPON) p->kickback_pic = 1;
p - > last_weapon = - 1 ;
}
else if ( p - > holster_weapon = = 0 )
2020-09-16 11:01:09 +00:00
p - > oweapon_pos = p - > weapon_pos = 10 ;
2020-05-18 22:26:07 +00:00
}
else p - > weapon_pos - - ;
}
// HACKS
2020-08-29 11:32:14 +00:00
processweapon ( snum , actions , psect ) ;
2020-05-19 07:54:52 +00:00
}
2020-05-18 22:26:07 +00:00
2020-08-28 20:51:05 +00:00
void processmove_d ( int snum , ESyncBits actions , int psect , int fz , int cz , int shrunk , int truefdist )
2020-05-19 16:32:28 +00:00
{
int psectlotag = sector [ psect ] . lotag ;
auto p = & ps [ snum ] ;
if ( psectlotag = = 2 )
{
2020-08-28 20:51:05 +00:00
underwater ( snum , actions , psect , fz , cz ) ;
2020-05-19 16:32:28 +00:00
}
else if ( p - > jetpack_on )
{
2020-08-28 20:51:05 +00:00
operateJetpack ( snum , actions , psectlotag , fz , cz , shrunk ) ;
2020-05-19 16:32:28 +00:00
}
else if ( psectlotag ! = 2 )
{
2020-08-28 20:51:05 +00:00
movement ( snum , actions , psect , fz , cz , shrunk , truefdist , psectlotag ) ;
2020-05-19 16:32:28 +00:00
}
}
2020-05-14 10:14:03 +00:00
END_DUKE_NS