2020-05-05 09:58:39 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
|
|
|
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
|
|
|
|
Copyright (C) 2017-2019 - Nuke.YKT
|
|
|
|
Copyright (C) 2020 - Christoph Oelckers
|
|
|
|
|
|
|
|
This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition
|
|
|
|
|
|
|
|
Duke Nukem 3D 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, 3D 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.
|
|
|
|
|
|
|
|
This file is a combination of code from the following sources:
|
|
|
|
- EDuke 2 by Matt Saettler
|
|
|
|
- JFDuke by Jonathon Fowler (jf@jonof.id.au),
|
|
|
|
- DukeGDX and RedneckGDX by Alexander Makarov-[M210] (m210-2007@mail.ru)
|
|
|
|
- Redneck Rampage reconstructed source by Nuke.YKT
|
|
|
|
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "ns.h"
|
|
|
|
#include "global.h"
|
2020-05-07 20:30:19 +00:00
|
|
|
#include "namesdyn.h"
|
2020-05-05 09:58:39 +00:00
|
|
|
|
|
|
|
BEGIN_DUKE_NS
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
bool ceilingspace_d(int sectnum);
|
|
|
|
bool ceilingspace_r(int sectnum);
|
|
|
|
bool floorspace_d(int sectnum);
|
|
|
|
bool floorspace_r(int sectnum);
|
|
|
|
void addweapon_d(struct player_struct *p, int weapon);
|
|
|
|
void addweapon_r(struct player_struct *p, int weapon);
|
|
|
|
void hitradius_d(short i, int r, int hp1, int hp2, int hp3, int hp4);
|
|
|
|
void hitradius_r(short i, int r, int hp1, int hp2, int hp3, int hp4);
|
|
|
|
int movesprite_d(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype);
|
|
|
|
int movesprite_r(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype);
|
|
|
|
void lotsofmoney_d(spritetype *s, short n);
|
|
|
|
void lotsofmail_d(spritetype *s, short n);
|
|
|
|
void lotsofpaper_d(spritetype *s, short n);
|
|
|
|
void lotsoffeathers_r(spritetype *s, short n);
|
|
|
|
void guts_d(spritetype* s, short gtype, short n, short p);
|
|
|
|
void guts_r(spritetype* s, short gtype, short n, short p);
|
|
|
|
void gutsdir_d(spritetype* s, short gtype, short n, short p);
|
|
|
|
void gutsdir_r(spritetype* s, short gtype, short n, short p);
|
|
|
|
int ifhitsectors_d(int sectnum);
|
|
|
|
int ifhitsectors_r(int sectnum);
|
|
|
|
int ifhitbyweapon_r(int sn);
|
|
|
|
int ifhitbyweapon_d(int sn);
|
|
|
|
|
|
|
|
bool ceilingspace(int sectnum)
|
2020-05-07 12:38:01 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
return isRR()? ceilingspace_r(sectnum) : ceilingspace_d(sectnum);
|
|
|
|
}
|
2020-05-07 12:38:01 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
bool floorspace(int sectnum)
|
|
|
|
{
|
|
|
|
return isRR()? floorspace_r(sectnum) : floorspace_d(sectnum);
|
|
|
|
}
|
2020-05-07 12:38:01 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void addweapon(struct player_struct *p, int weapon)
|
|
|
|
{
|
|
|
|
if (isRR()) addweapon_r(p, weapon);
|
|
|
|
else addweapon_d(p, weapon);
|
|
|
|
}
|
2020-05-05 13:25:59 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4)
|
2020-05-05 13:25:59 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
if (isRR()) hitradius_r(i, r, hp1, hp2, hp3, hp4);
|
|
|
|
else hitradius_d(i, r, hp1, hp2, hp3, hp4);
|
|
|
|
}
|
2020-05-05 16:47:07 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype)
|
|
|
|
{
|
|
|
|
if (isRR()) return movesprite_r(spritenum, xchange, ychange, zchange, cliptype);
|
|
|
|
else return movesprite_d(spritenum, xchange, ychange, zchange, cliptype);
|
2020-05-05 13:25:59 +00:00
|
|
|
}
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void lotsofmoney(spritetype *s, short n)
|
|
|
|
{
|
|
|
|
if (isRR()) lotsoffeathers_r(s, n);
|
|
|
|
else lotsofmoney_d(s, n);
|
|
|
|
}
|
2020-05-05 13:25:59 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void lotsofmail(spritetype *s, short n)
|
2020-05-05 13:25:59 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
if (isRR()) lotsoffeathers_r(s, n);
|
|
|
|
else lotsofmail_d(s, n);
|
|
|
|
}
|
2020-05-05 16:47:07 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void lotsofpaper(spritetype *s, short n)
|
|
|
|
{
|
|
|
|
if (isRR()) lotsoffeathers_r(s, n);
|
|
|
|
else lotsofpaper_d(s, n);
|
2020-05-05 14:33:23 +00:00
|
|
|
}
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void guts(spritetype* s, short gtype, short n, short p)
|
|
|
|
{
|
|
|
|
if (isRR()) guts_r(s, gtype, n, p);
|
|
|
|
else guts_d(s, gtype, n, p);
|
|
|
|
}
|
2020-05-05 16:47:07 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void gutsdir(spritetype* s, short gtype, short n, short p)
|
2020-05-05 14:33:23 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
if (isRR()) gutsdir_r(s, gtype, n, p);
|
|
|
|
else gutsdir_d(s, gtype, n, p);
|
|
|
|
}
|
2020-05-05 14:33:23 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
int ifhitsectors(int sectnum)
|
|
|
|
{
|
|
|
|
return isRR()? ifhitsectors_r(sectnum) : ifhitsectors_d(sectnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ifhitbyweapon(int sectnum)
|
|
|
|
{
|
|
|
|
return isRR()? ifhitbyweapon_r(sectnum) : ifhitbyweapon_d(sectnum);
|
2020-05-05 14:33:23 +00:00
|
|
|
}
|
2020-05-05 13:25:59 +00:00
|
|
|
|
2020-05-05 14:33:23 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void addammo(short weapon, struct player_struct* p, short amount)
|
2020-05-05 14:33:23 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
p->ammo_amount[weapon] += amount;
|
2020-05-05 14:33:23 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
if (p->ammo_amount[weapon] > max_ammo_amount[weapon])
|
|
|
|
p->ammo_amount[weapon] = max_ammo_amount[weapon];
|
2020-05-05 13:25:59 +00:00
|
|
|
}
|
|
|
|
|
2020-05-05 20:07:54 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void checkavailinven(struct player_struct* p)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (p->firstaid_amount > 0)
|
|
|
|
p->inven_icon = ICON_FIRSTAID;
|
|
|
|
else if (p->steroids_amount > 0)
|
|
|
|
p->inven_icon = ICON_STEROIDS;
|
|
|
|
else if (p->holoduke_amount > 0)
|
|
|
|
p->inven_icon = ICON_HOLODUKE;
|
|
|
|
else if (p->jetpack_amount > 0)
|
|
|
|
p->inven_icon = ICON_JETPACK;
|
|
|
|
else if (p->heat_amount > 0)
|
|
|
|
p->inven_icon = ICON_HEATS;
|
|
|
|
else if (p->scuba_amount > 0)
|
|
|
|
p->inven_icon = ICON_SCUBA;
|
|
|
|
else if (p->boot_amount > 0)
|
|
|
|
p->inven_icon = ICON_BOOTS;
|
|
|
|
else p->inven_icon = ICON_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void checkavailweapon(struct player_struct* p)
|
|
|
|
{
|
|
|
|
short i, snum;
|
|
|
|
int weap;
|
|
|
|
|
|
|
|
if (p->wantweaponfire >= 0)
|
|
|
|
{
|
|
|
|
weap = p->wantweaponfire;
|
|
|
|
p->wantweaponfire = -1;
|
|
|
|
|
|
|
|
if (weap == p->curr_weapon) return;
|
|
|
|
else if (p->gotweapon[weap] && p->ammo_amount[weap] > 0)
|
|
|
|
{
|
|
|
|
addweapon(p, weap);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
weap = p->curr_weapon;
|
|
|
|
if (p->gotweapon[weap] && p->ammo_amount[weap] > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
snum = sprite[p->i].yvel;
|
|
|
|
|
2020-05-09 09:44:50 +00:00
|
|
|
int max = MAX_WEAPON;
|
|
|
|
for (i = 0; i <= max; i++)
|
2020-05-05 20:07:54 +00:00
|
|
|
{
|
|
|
|
weap = ud.wchoice[snum][i];
|
|
|
|
if ((g_gameType & GAMEFLAG_SHAREWARE) && weap > 6) continue;
|
|
|
|
|
|
|
|
if (weap == 0) weap = max;
|
|
|
|
else weap--;
|
|
|
|
|
2020-05-09 09:44:50 +00:00
|
|
|
if (weap == MIN_WEAPON || (p->gotweapon[weap] && p->ammo_amount[weap] > 0))
|
2020-05-05 20:07:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-05-09 09:44:50 +00:00
|
|
|
if (i == MAX_WEAPON) weap = MIN_WEAPON;
|
2020-05-05 20:07:54 +00:00
|
|
|
|
|
|
|
// Found the weapon
|
|
|
|
|
|
|
|
p->last_weapon = p->curr_weapon;
|
|
|
|
p->random_club_frame = 0;
|
|
|
|
p->curr_weapon = weap;
|
2020-05-06 14:10:44 +00:00
|
|
|
if (isWW2GI())
|
2020-05-05 20:07:54 +00:00
|
|
|
{
|
|
|
|
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum);
|
|
|
|
if (p->curr_weapon >= 0)
|
|
|
|
{
|
|
|
|
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetGameVarID(g_iWorksLikeVarID, -1, p->i, snum);
|
|
|
|
}
|
|
|
|
OnEvent(EVENT_CHANGEWEAPON, p->i, snum, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
p->kickback_pic = 0;
|
|
|
|
if (p->holster_weapon == 1)
|
|
|
|
{
|
|
|
|
p->holster_weapon = 0;
|
|
|
|
p->weapon_pos = 10;
|
|
|
|
}
|
|
|
|
else p->weapon_pos = -1;
|
|
|
|
}
|
|
|
|
|
2020-05-05 22:08:08 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void clearcamera(player_struct* ps)
|
|
|
|
{
|
|
|
|
ps->newowner = -1;
|
|
|
|
ps->posx = ps->oposx;
|
|
|
|
ps->posy = ps->oposy;
|
|
|
|
ps->posz = ps->oposz;
|
|
|
|
ps->q16ang = ps->oq16ang;
|
|
|
|
updatesector(ps->posx, ps->posy, &ps->cursectnum);
|
|
|
|
setpal(ps);
|
|
|
|
|
2020-05-09 18:27:06 +00:00
|
|
|
int k = headspritestat[STAT_ACTOR];
|
2020-05-05 22:08:08 +00:00
|
|
|
while (k >= 0)
|
|
|
|
{
|
|
|
|
if (sprite[k].picnum == CAMERA1)
|
|
|
|
sprite[k].yvel = 0;
|
|
|
|
k = nextspritestat[k];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
int ssp(short i, unsigned int cliptype) //The set sprite function
|
2020-05-05 22:08:08 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
spritetype* s;
|
|
|
|
int movetype;
|
2020-05-05 22:08:08 +00:00
|
|
|
|
|
|
|
s = &sprite[i];
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
movetype = movesprite(i,
|
|
|
|
(s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14,
|
|
|
|
(s->xvel * (sintable[s->ang & 2047])) >> 14, s->zvel,
|
|
|
|
cliptype);
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
return (movetype == 0);
|
|
|
|
}
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void insertspriteq(int i)
|
|
|
|
{
|
|
|
|
if (spriteqamount > 0)
|
|
|
|
{
|
|
|
|
if (spriteq[spriteqloc] >= 0)
|
|
|
|
sprite[spriteq[spriteqloc]].xrepeat = 0;
|
|
|
|
spriteq[spriteqloc] = i;
|
|
|
|
spriteqloc = (spriteqloc + 1) % spriteqamount;
|
2020-05-05 22:08:08 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
else sprite[i].xrepeat = sprite[i].yrepeat = 0;
|
|
|
|
}
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// consolidation of several nearly identical functions
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void lotsofstuff(spritetype* s, short n, int spawntype)
|
|
|
|
{
|
|
|
|
short i, j;
|
|
|
|
for (i = n; i > 0; i--)
|
2020-05-05 22:08:08 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
short r1 = krand(), r2 = krand(); // using the RANDCORRECT version from RR.
|
|
|
|
// TRANSITIONAL RedNukem sets the spawner as owner.
|
|
|
|
j = EGS(s->sectnum, s->x, s->y, s->z - (r2 % (47 << 8)), spawntype, -32, 8, 8, r1 & 2047, 0, 0, 0, 5);
|
|
|
|
sprite[j].cstat = krand() & 12;
|
|
|
|
}
|
|
|
|
}
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// movesector - why is this in actors.cpp?
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void ms(short i)
|
|
|
|
{
|
|
|
|
//T1,T2 and T3 are used for all the sector moving stuff!!!
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
short startwall, endwall, x;
|
|
|
|
int tx, ty;
|
|
|
|
spritetype* s;
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
s = &sprite[i];
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
s->x += (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14;
|
|
|
|
s->y += (s->xvel * (sintable[s->ang & 2047])) >> 14;
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
int j = hittype[i].temp_data[1];
|
|
|
|
int k = hittype[i].temp_data[2];
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
startwall = sector[s->sectnum].wallptr;
|
|
|
|
endwall = startwall + sector[s->sectnum].wallnum;
|
|
|
|
for (x = startwall; x < endwall; x++)
|
|
|
|
{
|
|
|
|
rotatepoint(
|
|
|
|
0, 0,
|
|
|
|
msx[j], msy[j],
|
|
|
|
k & 2047, &tx, &ty);
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
dragpoint(x, s->x + tx, s->y + ty);
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
2020-05-06 14:10:44 +00:00
|
|
|
|
2020-05-06 19:11:36 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void movecyclers(void)
|
|
|
|
{
|
|
|
|
short q, j, x, t, s, * c;
|
|
|
|
walltype* wal;
|
|
|
|
char cshade;
|
|
|
|
|
|
|
|
for (q = numcyclers - 1; q >= 0; q--)
|
|
|
|
{
|
|
|
|
|
|
|
|
c = &cyclers[q][0];
|
|
|
|
s = c[0];
|
|
|
|
|
|
|
|
t = c[3];
|
|
|
|
j = t + (sintable[c[1] & 2047] >> 10);
|
|
|
|
cshade = c[2];
|
|
|
|
|
|
|
|
if (j < cshade) j = cshade;
|
|
|
|
else if (j > t) j = t;
|
|
|
|
|
|
|
|
c[1] += sector[s].extra;
|
|
|
|
if (c[5])
|
|
|
|
{
|
|
|
|
wal = &wall[sector[s].wallptr];
|
|
|
|
for (x = sector[s].wallnum; x > 0; x--, wal++)
|
|
|
|
if (wal->hitag != 1)
|
|
|
|
{
|
|
|
|
wal->shade = j;
|
|
|
|
|
|
|
|
if ((wal->cstat & 2) && wal->nextwall >= 0)
|
|
|
|
wall[wal->nextwall].shade = j;
|
|
|
|
|
|
|
|
}
|
|
|
|
sector[s].floorshade = sector[s].ceilingshade = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void movedummyplayers(void)
|
|
|
|
{
|
|
|
|
short i, p, nexti;
|
|
|
|
|
|
|
|
i = headspritestat[STAT_DUMMYPLAYER];
|
|
|
|
while (i >= 0)
|
|
|
|
{
|
|
|
|
nexti = nextspritestat[i];
|
|
|
|
|
|
|
|
p = sprite[sprite[i].owner].yvel;
|
|
|
|
|
|
|
|
if ((!isRR() && ps[p].on_crane >= 0) || sector[ps[p].cursectnum].lotag != 1 || sprite[ps[p].i].extra <= 0)
|
|
|
|
{
|
|
|
|
ps[p].dummyplayersprite = -1;
|
|
|
|
deletesprite(i);
|
|
|
|
i = nexti;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ps[p].on_ground && ps[p].on_warping_sector == 1 && sector[ps[p].cursectnum].lotag == 1)
|
|
|
|
{
|
|
|
|
sprite[i].cstat = 257;
|
|
|
|
sprite[i].z = sector[sprite[i].sectnum].ceilingz + (27 << 8);
|
2020-05-08 22:34:48 +00:00
|
|
|
sprite[i].ang = ps[p].getang();
|
2020-05-06 19:11:36 +00:00
|
|
|
if (hittype[i].temp_data[0] == 8)
|
|
|
|
hittype[i].temp_data[0] = 0;
|
|
|
|
else hittype[i].temp_data[0]++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sector[sprite[i].sectnum].lotag != 2) sprite[i].z = sector[sprite[i].sectnum].floorz;
|
|
|
|
sprite[i].cstat = (short)32768;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sprite[i].x += (ps[p].posx - ps[p].oposx);
|
|
|
|
sprite[i].y += (ps[p].posy - ps[p].oposy);
|
|
|
|
setsprite(i, sprite[i].x, sprite[i].y, sprite[i].z);
|
|
|
|
i = nexti;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int otherp;
|
|
|
|
void moveplayers(void) //Players
|
|
|
|
{
|
|
|
|
short i, nexti;
|
|
|
|
int otherx;
|
|
|
|
spritetype* s;
|
|
|
|
struct player_struct* p;
|
|
|
|
|
|
|
|
i = headspritestat[STAT_PLAYER];
|
|
|
|
while (i >= 0)
|
|
|
|
{
|
|
|
|
nexti = nextspritestat[i];
|
|
|
|
|
|
|
|
s = &sprite[i];
|
|
|
|
p = &ps[s->yvel];
|
|
|
|
if (s->owner >= 0)
|
|
|
|
{
|
|
|
|
if (p->newowner >= 0) //Looking thru the camera
|
|
|
|
{
|
|
|
|
s->x = p->oposx;
|
|
|
|
s->y = p->oposy;
|
|
|
|
hittype[i].bposz = s->z = p->oposz + PHEIGHT;
|
2020-05-08 22:34:48 +00:00
|
|
|
s->ang = p->getoang();
|
2020-05-06 19:11:36 +00:00
|
|
|
setsprite(i, s->x, s->y, s->z);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ud.multimode > 1)
|
|
|
|
otherp = findotherplayer(s->yvel, &otherx);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
otherp = s->yvel;
|
|
|
|
otherx = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
execute(i, s->yvel, otherx);
|
|
|
|
|
2020-05-07 08:28:31 +00:00
|
|
|
p->oq16ang = p->q16ang;
|
|
|
|
|
2020-05-06 19:11:36 +00:00
|
|
|
if (ud.multimode > 1)
|
|
|
|
if (sprite[ps[otherp].i].extra > 0)
|
|
|
|
{
|
|
|
|
if (s->yrepeat > 32 && sprite[ps[otherp].i].yrepeat < 32)
|
|
|
|
{
|
|
|
|
if (otherx < 1400 && p->knee_incs == 0)
|
|
|
|
{
|
|
|
|
p->knee_incs = 1;
|
|
|
|
p->weapon_pos = -1;
|
|
|
|
p->actorsqu = ps[otherp].i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ud.god)
|
|
|
|
{
|
|
|
|
s->extra = p->max_player_health;
|
|
|
|
s->cstat = 257;
|
|
|
|
if (!isWW2GI() && !isRR())
|
|
|
|
p->jetpack_amount = 1599;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (s->extra > 0)
|
|
|
|
{
|
|
|
|
// currently alive...
|
|
|
|
|
|
|
|
hittype[i].owner = i;
|
|
|
|
|
|
|
|
if (ud.god == 0)
|
|
|
|
if (ceilingspace(s->sectnum) || floorspace(s->sectnum))
|
|
|
|
quickkill(p);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
p->posx = s->x;
|
|
|
|
p->posy = s->y;
|
|
|
|
p->posz = s->z - (20 << 8);
|
|
|
|
|
|
|
|
p->newowner = -1;
|
|
|
|
|
|
|
|
if (p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS)
|
|
|
|
{
|
2020-05-08 22:34:48 +00:00
|
|
|
int ang = p->getang();
|
2020-05-06 19:11:36 +00:00
|
|
|
ang += getincangle(ang, getangle(sprite[p->wackedbyactor].x - p->posx, sprite[p->wackedbyactor].y - p->posy)) >> 1;
|
2020-05-08 22:34:48 +00:00
|
|
|
p->setang(ang & 2047);
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
s->ang = p->getang();
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (p->holoduke_on == -1)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
i = nexti;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hittype[i].bposx = s->x;
|
|
|
|
hittype[i].bposy = s->y;
|
|
|
|
hittype[i].bposz = s->z;
|
|
|
|
|
|
|
|
s->cstat = 0;
|
|
|
|
|
|
|
|
if (s->xrepeat < 42)
|
|
|
|
{
|
|
|
|
s->xrepeat += 4;
|
|
|
|
s->cstat |= 2;
|
|
|
|
}
|
|
|
|
else s->xrepeat = 42;
|
|
|
|
if (s->yrepeat < 36)
|
|
|
|
s->yrepeat += 4;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s->yrepeat = 36;
|
|
|
|
if (sector[s->sectnum].lotag != ST_2_UNDERWATER)
|
|
|
|
makeitfall(i);
|
|
|
|
if (s->zvel == 0 && sector[s->sectnum].lotag == ST_1_ABOVE_WATER)
|
|
|
|
s->z += (32 << 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->extra < 8)
|
|
|
|
{
|
|
|
|
s->xvel = 128;
|
2020-05-08 22:34:48 +00:00
|
|
|
s->ang = p->getang();
|
2020-05-06 19:11:36 +00:00
|
|
|
s->extra++;
|
|
|
|
//IFMOVING; // JBF 20040825: is really "if (ssp(i,CLIPMASK0)) ;" which is probably
|
|
|
|
ssp(i, CLIPMASK0); // not the safest of ideas because a zealous optimiser probably sees
|
|
|
|
// it as redundant, so I'll call the "ssp(i,CLIPMASK0)" explicitly.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-08 22:34:48 +00:00
|
|
|
s->ang = 2047 - (p->getang());
|
2020-05-06 19:11:36 +00:00
|
|
|
setsprite(i, s->x, s->y, s->z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sector[s->sectnum].ceilingstat & 1)
|
|
|
|
s->shade += (sector[s->sectnum].ceilingshade - s->shade) >> 1;
|
|
|
|
else
|
|
|
|
s->shade += (sector[s->sectnum].floorshade - s->shade) >> 1;
|
|
|
|
|
|
|
|
i = nexti;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-07 07:49:05 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void movefx(void)
|
|
|
|
{
|
|
|
|
short i, j, nexti, p;
|
|
|
|
int x, ht;
|
|
|
|
spritetype* s;
|
|
|
|
|
|
|
|
i = headspritestat[STAT_FX];
|
|
|
|
while (i >= 0)
|
|
|
|
{
|
|
|
|
s = &sprite[i];
|
|
|
|
|
|
|
|
nexti = nextspritestat[i];
|
|
|
|
|
|
|
|
switch (s->picnum)
|
|
|
|
{
|
|
|
|
case RESPAWN:
|
|
|
|
if (sprite[i].extra == 66)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
|
|
|
j = spawn(i, sprite[i].hitag);
|
|
|
|
if (isRRRA())
|
|
|
|
{
|
|
|
|
respawn_rrra(i, j);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sprite[i].extra > (66 - 13))
|
|
|
|
sprite[i].extra++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MUSICANDSFX:
|
|
|
|
|
|
|
|
ht = s->hitag;
|
|
|
|
|
|
|
|
if (hittype[i].temp_data[1] != (int)SoundEnabled())
|
|
|
|
{
|
|
|
|
hittype[i].temp_data[1] = SoundEnabled();
|
|
|
|
hittype[i].temp_data[0] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->lotag >= 1000 && s->lotag < 2000)
|
|
|
|
{
|
|
|
|
x = ldist(&sprite[ps[screenpeek].i], s);
|
|
|
|
if (x < ht && hittype[i].temp_data[0] == 0)
|
|
|
|
{
|
|
|
|
FX_SetReverb(s->lotag - 1000);
|
|
|
|
hittype[i].temp_data[0] = 1;
|
|
|
|
}
|
|
|
|
if (x >= ht && hittype[i].temp_data[0] == 1)
|
|
|
|
{
|
|
|
|
FX_SetReverb(0);
|
|
|
|
FX_SetReverbDelay(0);
|
|
|
|
hittype[i].temp_data[0] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (s->lotag < 999 && (unsigned)sector[s->sectnum].lotag < ST_9_SLIDING_ST_DOOR && snd_ambience && sector[sprite[i].sectnum].floorz != sector[sprite[i].sectnum].ceilingz)
|
|
|
|
{
|
|
|
|
auto flags = S_GetUserFlags(s->lotag);
|
|
|
|
if (flags & SF_MSFX)
|
|
|
|
{
|
|
|
|
int x = dist(&sprite[ps[screenpeek].i], s);
|
|
|
|
|
|
|
|
if (x < ht && hittype[i].temp_data[0] == 0)
|
|
|
|
{
|
|
|
|
// Start playing an ambience sound.
|
|
|
|
A_PlaySound(s->lotag, i, CHAN_AUTO, CHANF_LOOP);
|
|
|
|
hittype[i].temp_data[0] = 1; // AMBIENT_SFX_PLAYING
|
|
|
|
}
|
|
|
|
else if (x >= ht && hittype[i].temp_data[0] == 1)
|
|
|
|
{
|
|
|
|
// Stop playing ambience sound because we're out of its range.
|
|
|
|
S_StopEnvSound(s->lotag, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((flags & (SF_GLOBAL | SF_DTAG)) == SF_GLOBAL)
|
|
|
|
{
|
|
|
|
if (hittype[i].temp_data[4] > 0) hittype[i].temp_data[4]--;
|
|
|
|
else for (p = connecthead; p >= 0; p = connectpoint2[p])
|
|
|
|
if (p == myconnectindex && ps[p].cursectnum == s->sectnum)
|
|
|
|
{
|
|
|
|
S_PlaySound(s->lotag + (unsigned)global_random % (s->hitag + 1));
|
|
|
|
hittype[i].temp_data[4] = 26 * 40 + (global_random % (26 * 40));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i = nexti;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// split out of movestandables
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void movecrane(int i, int crane)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
auto s = &sprite[i];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
//t[0] = state
|
|
|
|
//t[1] = checking sector number
|
|
|
|
|
|
|
|
if (s->xvel) getglobalz(i);
|
|
|
|
|
|
|
|
if (t[0] == 0) //Waiting to check the sector
|
|
|
|
{
|
|
|
|
int j = headspritesect[t[1]];
|
|
|
|
while (j >= 0)
|
|
|
|
{
|
|
|
|
int nextj = nextspritesect[j];
|
|
|
|
switch (sprite[j].statnum)
|
|
|
|
{
|
|
|
|
case STAT_ACTOR:
|
|
|
|
case STAT_ZOMBIEACTOR:
|
|
|
|
case STAT_STANDABLE:
|
|
|
|
case STAT_PLAYER:
|
|
|
|
s->ang = getangle(msx[t[4] + 1] - s->x, msy[t[4] + 1] - s->y);
|
|
|
|
setsprite(j, msx[t[4] + 1], msy[t[4] + 1], sprite[j].z);
|
|
|
|
t[0]++;
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
j = nextj;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (t[0] == 1)
|
|
|
|
{
|
|
|
|
if (s->xvel < 184)
|
|
|
|
{
|
|
|
|
s->picnum = crane + 1;
|
|
|
|
s->xvel += 8;
|
|
|
|
}
|
|
|
|
//IFMOVING; // JBF 20040825: see my rant above about this
|
|
|
|
ssp(i, CLIPMASK0);
|
|
|
|
if (sect == t[1])
|
|
|
|
t[0]++;
|
|
|
|
}
|
|
|
|
else if (t[0] == 2 || t[0] == 7)
|
|
|
|
{
|
|
|
|
s->z += (1024 + 512);
|
|
|
|
|
|
|
|
if (t[0] == 2)
|
|
|
|
{
|
|
|
|
if ((sector[sect].floorz - s->z) < (64 << 8))
|
|
|
|
if (s->picnum > crane) s->picnum--;
|
|
|
|
|
|
|
|
if ((sector[sect].floorz - s->z) < (4096 + 1024))
|
|
|
|
t[0]++;
|
|
|
|
}
|
|
|
|
if (t[0] == 7)
|
|
|
|
{
|
|
|
|
if ((sector[sect].floorz - s->z) < (64 << 8))
|
|
|
|
{
|
|
|
|
if (s->picnum > crane) s->picnum--;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (s->owner == -2)
|
|
|
|
{
|
|
|
|
auto p = findplayer(s, &x);
|
|
|
|
spritesound(isRR() ? 390 : DUKE_GRUNT, ps[p].i);
|
|
|
|
if (ps[p].on_crane == i)
|
|
|
|
ps[p].on_crane = -1;
|
|
|
|
}
|
|
|
|
t[0]++;
|
|
|
|
s->owner = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (t[0] == 3)
|
|
|
|
{
|
|
|
|
s->picnum++;
|
|
|
|
if (s->picnum == (crane + 2))
|
|
|
|
{
|
|
|
|
auto p = checkcursectnums(t[1]);
|
|
|
|
if (p >= 0 && ps[p].on_ground)
|
|
|
|
{
|
|
|
|
s->owner = -2;
|
|
|
|
ps[p].on_crane = i;
|
|
|
|
spritesound(isRR() ? 390 : DUKE_GRUNT, ps[p].i);
|
2020-05-08 22:34:48 +00:00
|
|
|
ps[p].setang(s->ang + 1024);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int j = headspritesect[t[1]];
|
|
|
|
while (j >= 0)
|
|
|
|
{
|
|
|
|
switch (sprite[j].statnum)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 6:
|
|
|
|
s->owner = j;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
j = nextspritesect[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t[0]++;//Grabbed the sprite
|
|
|
|
t[2] = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (t[0] == 4) //Delay before going up
|
|
|
|
{
|
|
|
|
t[2]++;
|
|
|
|
if (t[2] > 10)
|
|
|
|
t[0]++;
|
|
|
|
}
|
|
|
|
else if (t[0] == 5 || t[0] == 8)
|
|
|
|
{
|
|
|
|
if (t[0] == 8 && s->picnum < (crane + 2))
|
|
|
|
if ((sector[sect].floorz - s->z) > 8192)
|
|
|
|
s->picnum++;
|
|
|
|
|
|
|
|
if (s->z < msx[t[4] + 2])
|
|
|
|
{
|
|
|
|
t[0]++;
|
|
|
|
s->xvel = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
s->z -= (1024 + 512);
|
|
|
|
}
|
|
|
|
else if (t[0] == 6)
|
|
|
|
{
|
|
|
|
if (s->xvel < 192)
|
|
|
|
s->xvel += 8;
|
|
|
|
s->ang = getangle(msx[t[4]] - s->x, msy[t[4]] - s->y);
|
|
|
|
//IFMOVING; // JBF 20040825: see my rant above about this
|
|
|
|
ssp(i, CLIPMASK0);
|
|
|
|
if (((s->x - msx[t[4]]) * (s->x - msx[t[4]]) + (s->y - msy[t[4]]) * (s->y - msy[t[4]])) < (128 * 128))
|
|
|
|
t[0]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (t[0] == 9)
|
|
|
|
t[0] = 0;
|
|
|
|
|
|
|
|
setsprite(msy[t[4] + 2], s->x, s->y, s->z - (34 << 8));
|
|
|
|
|
|
|
|
if (s->owner != -1)
|
|
|
|
{
|
|
|
|
auto p = findplayer(s, &x);
|
|
|
|
|
|
|
|
int j = ifhitbyweapon(i);
|
|
|
|
if (j >= 0)
|
|
|
|
{
|
|
|
|
if (s->owner == -2)
|
|
|
|
if (ps[p].on_crane == i)
|
|
|
|
ps[p].on_crane = -1;
|
|
|
|
s->owner = -1;
|
|
|
|
s->picnum = crane;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->owner >= 0)
|
|
|
|
{
|
|
|
|
setsprite(s->owner, s->x, s->y, s->z);
|
|
|
|
|
|
|
|
hittype[s->owner].bposx = s->x;
|
|
|
|
hittype[s->owner].bposy = s->y;
|
|
|
|
hittype[s->owner].bposz = s->z;
|
|
|
|
|
|
|
|
s->zvel = 0;
|
|
|
|
}
|
|
|
|
else if (s->owner == -2)
|
|
|
|
{
|
2020-05-08 22:34:48 +00:00
|
|
|
auto ang = ps[p].getang();
|
2020-05-07 07:49:05 +00:00
|
|
|
ps[p].oposx = ps[p].posx = s->x - (sintable[(ang + 512) & 2047] >> 6);
|
|
|
|
ps[p].oposy = ps[p].posy = s->y - (sintable[ang & 2047] >> 6);
|
|
|
|
ps[p].oposz = ps[p].posz = s->z + (2 << 8);
|
|
|
|
setsprite(ps[p].i, ps[p].posx, ps[p].posy, ps[p].posz);
|
|
|
|
ps[p].cursectnum = sprite[ps[p].i].sectnum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void movefountain(int i, int fountain)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
auto s = &sprite[i];
|
|
|
|
int x;
|
|
|
|
if (t[0] > 0)
|
|
|
|
{
|
|
|
|
if (t[0] < 20)
|
|
|
|
{
|
|
|
|
t[0]++;
|
|
|
|
|
|
|
|
s->picnum++;
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
if (s->picnum == fountain + 3)
|
|
|
|
s->picnum = fountain + 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
findplayer(s, &x);
|
|
|
|
|
|
|
|
if (x > 512)
|
|
|
|
{
|
|
|
|
t[0] = 0;
|
2020-05-07 20:30:19 +00:00
|
|
|
s->picnum = fountain;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
else t[0] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void moveflammable(int i, int tire, int box, int pool)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
auto s = &sprite[i];
|
|
|
|
int j;
|
|
|
|
if (hittype[i].temp_data[0] == 1)
|
|
|
|
{
|
|
|
|
hittype[i].temp_data[1]++;
|
|
|
|
if ((hittype[i].temp_data[1] & 3) > 0) return;
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
if (!isRR() && s->picnum == tire && hittype[i].temp_data[1] == 32)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
s->cstat = 0;
|
2020-05-07 20:30:19 +00:00
|
|
|
j = spawn(i, pool);
|
2020-05-07 07:49:05 +00:00
|
|
|
sprite[j].shade = 127;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (s->shade < 64) s->shade++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
j = s->xrepeat - (krand() & 7);
|
|
|
|
if (j < 10)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
s->xrepeat = j;
|
|
|
|
|
|
|
|
j = s->yrepeat - (krand() & 7);
|
|
|
|
if (j < 4)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
s->yrepeat = j;
|
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
if (box >= 0 && s->picnum == box)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
makeitfall(i);
|
|
|
|
hittype[i].ceilingz = sector[s->sectnum].ceilingz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void detonate(int i, int explosion)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
auto s = &sprite[i];
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
earthquaketime = 16;
|
|
|
|
|
|
|
|
int j = headspritestat[STAT_EFFECTOR];
|
|
|
|
while (j >= 0)
|
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
if (s->hitag == sprite[j].hitag)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
if (sprite[j].lotag == SE_13_EXPLOSIVE)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
if (hittype[j].temp_data[2] == 0)
|
|
|
|
hittype[j].temp_data[2] = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
else if (sprite[j].lotag == SE_8_UP_OPEN_DOOR_LIGHTS)
|
|
|
|
hittype[j].temp_data[4] = 1;
|
|
|
|
else if (sprite[j].lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
if (hittype[j].temp_data[0] == 0)
|
|
|
|
hittype[j].temp_data[0] = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
else if (sprite[j].lotag == SE_21_DROP_FLOOR)
|
|
|
|
hittype[j].temp_data[0] = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
j = nextspritestat[j];
|
|
|
|
}
|
|
|
|
|
|
|
|
s->z -= (32 << 8);
|
|
|
|
|
|
|
|
if ((t[3] == 1 && s->xrepeat) || s->lotag == -99)
|
|
|
|
{
|
|
|
|
int x = s->extra;
|
|
|
|
spawn(i, explosion);
|
|
|
|
hitradius(i, seenineblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x);
|
|
|
|
spritesound(PIPEBOMB_EXPLODE, i);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
|
|
|
|
if (s->xrepeat)
|
|
|
|
for (int x = 0; x < 8; x++) RANDOMSCRAP(s, i);
|
|
|
|
|
|
|
|
deletesprite(i);
|
|
|
|
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void movemasterswitch(int i, int spectype1, int spectype2)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
auto s = &sprite[i];
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
if (s->yvel == 1)
|
|
|
|
{
|
|
|
|
s->hitag--;
|
|
|
|
if (s->hitag <= 0)
|
|
|
|
{
|
|
|
|
operatesectors(s->sectnum, i);
|
|
|
|
|
|
|
|
int j = headspritesect[s->sectnum];
|
|
|
|
while (j >= 0)
|
|
|
|
{
|
|
|
|
if (sprite[j].statnum == 3)
|
|
|
|
{
|
|
|
|
switch (sprite[j].lotag)
|
|
|
|
{
|
|
|
|
case SE_2_EARTHQUAKE:
|
|
|
|
case SE_21_DROP_FLOOR:
|
|
|
|
case SE_31_FLOOR_RISE_FALL:
|
|
|
|
case SE_32_CEILING_RISE_FALL:
|
|
|
|
case SE_36_PROJ_SHOOTER:
|
|
|
|
hittype[j].temp_data[0] = 1;
|
|
|
|
break;
|
|
|
|
case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT:
|
|
|
|
hittype[j].temp_data[4] = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sprite[j].statnum == 6)
|
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
if (sprite[j].picnum == spectype1 || sprite[j].picnum == spectype2) // SEENINE and OOZFILTER
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
sprite[j].shade = -31;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
j = nextspritesect[j];
|
|
|
|
}
|
|
|
|
deletesprite(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void movetrash(int i)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
auto s = &sprite[i];
|
|
|
|
if (s->xvel == 0) s->xvel = 1;
|
|
|
|
if (ssp(i, CLIPMASK0))
|
|
|
|
{
|
|
|
|
makeitfall(i);
|
|
|
|
if (krand() & 1) s->zvel -= 256;
|
|
|
|
if (klabs(s->xvel) < 48)
|
|
|
|
s->xvel += (krand() & 3);
|
|
|
|
}
|
|
|
|
else deletesprite(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void movewaterdrip(int i, int drip)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
auto s = &sprite[i];
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
|
|
|
|
if (t[1])
|
|
|
|
{
|
|
|
|
t[1]--;
|
|
|
|
if (t[1] == 0)
|
|
|
|
s->cstat &= 32767;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
makeitfall(i);
|
|
|
|
ssp(i, CLIPMASK0);
|
|
|
|
if (s->xvel > 0) s->xvel -= 2;
|
|
|
|
|
|
|
|
if (s->zvel == 0)
|
|
|
|
{
|
|
|
|
s->cstat |= 32768;
|
|
|
|
|
|
|
|
if (s->pal != 2 && (isRR() || s->hitag == 0))
|
|
|
|
spritesound(SOMETHING_DRIPPING, i);
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
if (sprite[s->owner].picnum != drip)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hittype[i].bposz = s->z = t[0];
|
|
|
|
t[1] = 48 + (krand() & 31);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void movedoorshock(int i)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
auto s = &sprite[i];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
int j = abs(sector[sect].ceilingz - sector[sect].floorz) >> 9;
|
|
|
|
s->yrepeat = j + 4;
|
|
|
|
s->xrepeat = 16;
|
|
|
|
s->z = sector[sect].floorz;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void movetouchplate(int i, int plate)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
auto s = &sprite[i];
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
int x;
|
|
|
|
int p;
|
|
|
|
|
|
|
|
if (t[1] == 1 && s->hitag >= 0) //Move the sector floor
|
|
|
|
{
|
|
|
|
x = sector[sect].floorz;
|
|
|
|
|
|
|
|
if (t[3] == 1)
|
|
|
|
{
|
|
|
|
if (x >= t[2])
|
|
|
|
{
|
|
|
|
sector[sect].floorz = x;
|
|
|
|
t[1] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sector[sect].floorz += sector[sect].extra;
|
|
|
|
p = checkcursectnums(sect);
|
|
|
|
if (p >= 0) ps[p].posz += sector[sect].extra;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (x <= s->z)
|
|
|
|
{
|
|
|
|
sector[sect].floorz = s->z;
|
|
|
|
t[1] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sector[sect].floorz -= sector[sect].extra;
|
|
|
|
p = checkcursectnums(sect);
|
|
|
|
if (p >= 0)
|
|
|
|
ps[p].posz -= sector[sect].extra;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t[5] == 1) return;
|
|
|
|
|
|
|
|
p = checkcursectnums(sect);
|
|
|
|
if (p >= 0 && (ps[p].on_ground || s->ang == 512))
|
|
|
|
{
|
|
|
|
if (t[0] == 0 && !check_activator_motion(s->lotag))
|
|
|
|
{
|
|
|
|
t[0] = 1;
|
|
|
|
t[1] = 1;
|
|
|
|
t[3] = !t[3];
|
|
|
|
operatemasterswitches(s->lotag);
|
|
|
|
operateactivators(s->lotag, p);
|
|
|
|
if (s->hitag > 0)
|
|
|
|
{
|
|
|
|
s->hitag--;
|
|
|
|
if (s->hitag == 0) t[5] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else t[0] = 0;
|
|
|
|
|
|
|
|
if (t[1] == 1)
|
|
|
|
{
|
|
|
|
int j = headspritestat[STAT_STANDABLE];
|
|
|
|
while (j >= 0)
|
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
if (j != i && sprite[j].picnum == plate && sprite[j].lotag == s->lotag)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
hittype[j].temp_data[1] = 1;
|
|
|
|
hittype[j].temp_data[3] = t[3];
|
|
|
|
}
|
|
|
|
j = nextspritestat[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void moveooz(int i, int seenine, int seeninedead, int ooz, int explosion)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
auto s = &sprite[i];
|
2020-05-07 20:30:19 +00:00
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
int j;
|
|
|
|
if (s->shade != -32 && s->shade != -33)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
if (s->xrepeat)
|
|
|
|
j = (ifhitbyweapon(i) >= 0);
|
|
|
|
else
|
|
|
|
j = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
if (j || s->shade == -31)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
if (j) s->lotag = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
t[3] = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
j = headspritestat[STAT_STANDABLE];
|
|
|
|
while (j >= 0)
|
|
|
|
{
|
|
|
|
if (s->hitag == sprite[j].hitag && (sprite[j].picnum == seenine || sprite[j].picnum == ooz))
|
|
|
|
sprite[j].shade = -32;
|
|
|
|
j = nextspritestat[j];
|
|
|
|
}
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (s->shade == -32)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
if (s->lotag > 0)
|
|
|
|
{
|
|
|
|
s->lotag -= 3;
|
|
|
|
if (s->lotag <= 0) s->lotag = -99;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
s->shade = -33;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
else
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
if (s->xrepeat > 0)
|
|
|
|
{
|
|
|
|
hittype[i].temp_data[2]++;
|
|
|
|
if (hittype[i].temp_data[2] == 3)
|
|
|
|
{
|
|
|
|
if (s->picnum == ooz)
|
|
|
|
{
|
|
|
|
hittype[i].temp_data[2] = 0;
|
|
|
|
detonate(i, explosion);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (s->picnum != (seeninedead + 1))
|
|
|
|
{
|
|
|
|
hittype[i].temp_data[2] = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
if (s->picnum == seeninedead) s->picnum++;
|
|
|
|
else if (s->picnum == seenine)
|
|
|
|
s->picnum = seeninedead;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
detonate(i, explosion);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
detonate(i, explosion);
|
|
|
|
return;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void movecanwithsomething(int i)
|
|
|
|
{
|
|
|
|
auto s = &sprite[i];
|
|
|
|
makeitfall(i);
|
|
|
|
int j = ifhitbyweapon(i);
|
|
|
|
if (j >= 0)
|
|
|
|
{
|
|
|
|
spritesound(VENT_BUST, i);
|
|
|
|
for (j = 0; j < 10; j++)
|
|
|
|
RANDOMSCRAP(s, i);
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
if (s->lotag) spawn(i, s->lotag);
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
deletesprite(i);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-07 12:38:01 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void bounce(int i)
|
2020-05-07 12:38:01 +00:00
|
|
|
{
|
|
|
|
int k, l, daang, dax, day, daz, xvect, yvect, zvect;
|
|
|
|
short hitsect;
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
|
|
|
|
xvect = mulscale10(s->xvel, sintable[(s->ang + 512) & 2047]);
|
|
|
|
yvect = mulscale10(s->xvel, sintable[s->ang & 2047]);
|
|
|
|
zvect = s->zvel;
|
|
|
|
|
|
|
|
hitsect = s->sectnum;
|
|
|
|
|
|
|
|
k = sector[hitsect].wallptr; l = wall[k].point2;
|
|
|
|
daang = getangle(wall[l].x - wall[k].x, wall[l].y - wall[k].y);
|
|
|
|
|
|
|
|
if (s->z < (hittype[i].floorz + hittype[i].ceilingz) >> 1)
|
|
|
|
k = sector[hitsect].ceilingheinum;
|
|
|
|
else
|
|
|
|
k = sector[hitsect].floorheinum;
|
|
|
|
|
|
|
|
dax = mulscale14(k, sintable[(daang) & 2047]);
|
|
|
|
day = mulscale14(k, sintable[(daang + 1536) & 2047]);
|
|
|
|
daz = 4096;
|
|
|
|
|
|
|
|
k = xvect * dax + yvect * day + zvect * daz;
|
|
|
|
l = dax * dax + day * day + daz * daz;
|
|
|
|
if ((abs(k) >> 14) < l)
|
|
|
|
{
|
|
|
|
k = divscale17(k, l);
|
|
|
|
xvect -= mulscale16(dax, k);
|
|
|
|
yvect -= mulscale16(day, k);
|
|
|
|
zvect -= mulscale16(daz, k);
|
|
|
|
}
|
|
|
|
|
|
|
|
s->zvel = zvect;
|
|
|
|
s->xvel = ksqrt(dmulscale8(xvect, xvect, yvect, yvect));
|
|
|
|
s->ang = getangle(xvect, yvect);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2020-05-07 20:30:19 +00:00
|
|
|
// taken out of moveweapon
|
2020-05-07 12:38:01 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
void movetongue(int i, int tongue, int jaw)
|
2020-05-07 12:38:01 +00:00
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
|
|
|
|
hittype[i].temp_data[0] = sintable[(hittype[i].temp_data[1]) & 2047] >> 9;
|
|
|
|
hittype[i].temp_data[1] += 32;
|
|
|
|
if (hittype[i].temp_data[1] > 2047)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sprite[s->owner].statnum == MAXSTATUS)
|
|
|
|
if (badguy(&sprite[s->owner]) == 0)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
s->ang = sprite[s->owner].ang;
|
|
|
|
s->x = sprite[s->owner].x;
|
|
|
|
s->y = sprite[s->owner].y;
|
|
|
|
if (sprite[s->owner].picnum == APLAYER)
|
|
|
|
s->z = sprite[s->owner].z - (34 << 8);
|
|
|
|
for (int k = 0; k < hittype[i].temp_data[0]; k++)
|
|
|
|
{
|
|
|
|
int q = EGS(s->sectnum,
|
|
|
|
s->x + ((k * sintable[(s->ang + 512) & 2047]) >> 9),
|
|
|
|
s->y + ((k * sintable[s->ang & 2047]) >> 9),
|
2020-05-07 20:30:19 +00:00
|
|
|
s->z + ((k * ksgn(s->zvel)) * abs(s->zvel / 12)), tongue, -40 + (k << 1),
|
2020-05-07 12:38:01 +00:00
|
|
|
8, 8, 0, 0, 0, i, 5);
|
|
|
|
sprite[q].cstat = 128;
|
|
|
|
sprite[q].pal = 8;
|
|
|
|
}
|
|
|
|
int k = hittype[i].temp_data[0]; // do not depend on the above loop counter.
|
|
|
|
int q = EGS(s->sectnum,
|
|
|
|
s->x + ((k * sintable[(s->ang + 512) & 2047]) >> 9),
|
|
|
|
s->y + ((k * sintable[s->ang & 2047]) >> 9),
|
2020-05-07 20:30:19 +00:00
|
|
|
s->z + ((k * ksgn(s->zvel)) * abs(s->zvel / 12)), jaw, -40,
|
2020-05-07 12:38:01 +00:00
|
|
|
32, 32, 0, 0, 0, i, 5);
|
|
|
|
sprite[q].cstat = 128;
|
|
|
|
if (hittype[i].temp_data[1] > 512 && hittype[i].temp_data[1] < (1024))
|
2020-05-07 20:30:19 +00:00
|
|
|
sprite[q].picnum = jaw + 1;
|
2020-05-07 12:38:01 +00:00
|
|
|
}
|
|
|
|
|
2020-05-08 22:34:48 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool respawnmarker(int i, int yellow, int green)
|
|
|
|
{
|
|
|
|
hittype[i].temp_data[0]++;
|
|
|
|
if (hittype[i].temp_data[0] > respawnitemtime)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (hittype[i].temp_data[0] >= (respawnitemtime >> 1) && hittype[i].temp_data[0] < ((respawnitemtime >> 1) + (respawnitemtime >> 2)))
|
|
|
|
sprite[i].picnum = yellow;
|
|
|
|
else if (hittype[i].temp_data[0] > ((respawnitemtime >> 1) + (respawnitemtime >> 2)))
|
|
|
|
sprite[i].picnum = green;
|
|
|
|
makeitfall(i);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool rat(int i, bool makesound)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
makeitfall(i);
|
|
|
|
if (ssp(i, CLIPMASK0))
|
|
|
|
{
|
|
|
|
if (makesound && (krand() & 255) == 0) spritesound(RATTY, i);
|
|
|
|
s->ang += (krand() & 31) - 15 + (sintable[(hittype[i].temp_data[0] << 8) & 2047] >> 11);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hittype[i].temp_data[0]++;
|
|
|
|
if (hittype[i].temp_data[0] > 1)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else s->ang = (krand() & 2047);
|
|
|
|
}
|
|
|
|
if (s->xvel < 128)
|
|
|
|
s->xvel += 2;
|
|
|
|
s->ang += (krand() & 3) - 6;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-06 19:11:36 +00:00
|
|
|
|
2020-05-08 22:34:48 +00:00
|
|
|
bool queball(int i, int pocket, int queball, int stripeball)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
int j, nextj;
|
|
|
|
if (s->xvel)
|
|
|
|
{
|
|
|
|
j = headspritestat[0];
|
|
|
|
while (j >= 0)
|
|
|
|
{
|
|
|
|
nextj = nextspritestat[j];
|
|
|
|
if (sprite[j].picnum == pocket && ldist(&sprite[j], s) < 52)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
j = nextj;
|
|
|
|
}
|
|
|
|
|
|
|
|
j = clipmove(&s->x, &s->y, &s->z, &s->sectnum,
|
|
|
|
(((s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14) * TICSPERFRAME) << 11,
|
|
|
|
(((s->xvel * (sintable[s->ang & 2047])) >> 14) * TICSPERFRAME) << 11,
|
|
|
|
24L, (4 << 8), (4 << 8), CLIPMASK1);
|
|
|
|
|
|
|
|
if (j & 49152)
|
|
|
|
{
|
|
|
|
if ((j & 49152) == 32768)
|
|
|
|
{
|
|
|
|
j &= (MAXWALLS - 1);
|
|
|
|
int k = getangle(
|
|
|
|
wall[wall[j].point2].x - wall[j].x,
|
|
|
|
wall[wall[j].point2].y - wall[j].y);
|
|
|
|
s->ang = ((k << 1) - s->ang) & 2047;
|
|
|
|
}
|
|
|
|
else if ((j & 49152) == 49152)
|
|
|
|
{
|
|
|
|
j &= (MAXSPRITES - 1);
|
|
|
|
checkhitsprite(i, j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s->xvel--;
|
|
|
|
if (s->xvel < 0) s->xvel = 0;
|
|
|
|
if (s->picnum == stripeball)
|
|
|
|
{
|
|
|
|
s->cstat = 257;
|
|
|
|
s->cstat |= 4 & s->xvel;
|
|
|
|
s->cstat |= 8 & s->xvel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int p = findplayer(s, &x);
|
|
|
|
|
|
|
|
if (x < 1596)
|
|
|
|
{
|
|
|
|
|
|
|
|
// if(s->pal == 12)
|
|
|
|
{
|
|
|
|
j = getincangle(ps[p].getang(), getangle(s->x - ps[p].posx, s->y - ps[p].posy));
|
|
|
|
if (j > -64 && j < 64 && PlayerInput(p, SK_OPEN))
|
|
|
|
if (ps[p].toggle_key_flag == 1)
|
|
|
|
{
|
|
|
|
int a = headspritestat[1];
|
|
|
|
while (a >= 0)
|
|
|
|
{
|
|
|
|
if (sprite[a].picnum == queball || sprite[a].picnum == stripeball)
|
|
|
|
{
|
|
|
|
j = getincangle(ps[p].getang(), getangle(sprite[a].x - ps[p].posx, sprite[a].y - ps[p].posy));
|
|
|
|
if (j > -64 && j < 64)
|
|
|
|
{
|
|
|
|
int l;
|
|
|
|
findplayer(&sprite[a], &l);
|
|
|
|
if (x > l) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
a = nextspritestat[a];
|
|
|
|
}
|
|
|
|
if (a == -1)
|
|
|
|
{
|
|
|
|
if (s->pal == 12)
|
|
|
|
s->xvel = 164;
|
|
|
|
else s->xvel = 140;
|
|
|
|
s->ang = ps[p].getang();
|
|
|
|
ps[p].toggle_key_flag = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (x < 512 && s->sectnum == ps[p].cursectnum)
|
|
|
|
{
|
|
|
|
s->ang = getangle(s->x - ps[p].posx, s->y - ps[p].posy);
|
|
|
|
s->xvel = 48;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void forcesphere(int i, int forcesphere)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
if (s->yvel == 0)
|
|
|
|
{
|
|
|
|
s->yvel = 1;
|
|
|
|
|
|
|
|
for (int l = 512; l < (2048 - 512); l += 128)
|
|
|
|
for (int j = 0; j < 2048; j += 128)
|
|
|
|
{
|
|
|
|
int k = spawn(i, forcesphere);
|
|
|
|
sprite[k].cstat = 257 + 128;
|
|
|
|
sprite[k].clipdist = 64;
|
|
|
|
sprite[k].ang = j;
|
|
|
|
sprite[k].zvel = sintable[l & 2047] >> 5;
|
|
|
|
sprite[k].xvel = sintable[(l + 512) & 2047] >> 9;
|
|
|
|
sprite[k].owner = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t[3] > 0)
|
|
|
|
{
|
|
|
|
if (s->zvel < 6144)
|
|
|
|
s->zvel += 192;
|
|
|
|
s->z += s->zvel;
|
|
|
|
if (s->z > sector[sect].floorz)
|
|
|
|
s->z = sector[sect].floorz;
|
|
|
|
t[3]--;
|
|
|
|
if (t[3] == 0)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (t[2] > 10)
|
|
|
|
{
|
|
|
|
int j = headspritestat[5];
|
|
|
|
while (j >= 0)
|
|
|
|
{
|
|
|
|
if (sprite[j].owner == i && sprite[j].picnum == forcesphere)
|
|
|
|
hittype[j].temp_data[1] = 1 + (krand() & 63);
|
|
|
|
j = nextspritestat[j];
|
|
|
|
}
|
|
|
|
t[3] = 64;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void recon(int i, int explosion, int firelaser, int attacksnd, int painsnd, int roamsnd, int shift, int (*getspawn)(int i))
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
int j, a;
|
|
|
|
|
|
|
|
getglobalz(i);
|
|
|
|
|
|
|
|
if (sector[s->sectnum].ceilingstat & 1)
|
|
|
|
s->shade += (sector[s->sectnum].ceilingshade - s->shade) >> 1;
|
|
|
|
else s->shade += (sector[s->sectnum].floorshade - s->shade) >> 1;
|
|
|
|
|
|
|
|
if (s->z < sector[sect].ceilingz + (32 << 8))
|
|
|
|
s->z = sector[sect].ceilingz + (32 << 8);
|
|
|
|
|
|
|
|
if (ud.multimode < 2)
|
|
|
|
{
|
|
|
|
if (actor_tog == 1)
|
|
|
|
{
|
|
|
|
s->cstat = (short)32768;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (actor_tog == 2) s->cstat = 257;
|
|
|
|
}
|
|
|
|
j = ifhitbyweapon(i); if (j >= 0)
|
|
|
|
{
|
|
|
|
if (s->extra < 0 && t[0] != -1)
|
|
|
|
{
|
|
|
|
t[0] = -1;
|
|
|
|
s->extra = 0;
|
|
|
|
}
|
|
|
|
if (painsnd >= 0) spritesound(painsnd, i);
|
|
|
|
RANDOMSCRAP(s, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t[0] == -1)
|
|
|
|
{
|
|
|
|
s->z += 1024;
|
|
|
|
t[2]++;
|
|
|
|
if ((t[2] & 3) == 0) spawn(i, explosion);
|
|
|
|
getglobalz(i);
|
|
|
|
s->ang += 96;
|
|
|
|
s->xvel = 128;
|
|
|
|
j = ssp(i, CLIPMASK0);
|
|
|
|
if (j != 1 || s->z > hittype[i].floorz)
|
|
|
|
{
|
|
|
|
for (int l = 0; l < 16; l++)
|
|
|
|
RANDOMSCRAP(s, i);
|
|
|
|
spritesound(LASERTRIP_EXPLODE, i);
|
2020-05-09 09:44:50 +00:00
|
|
|
int sp = getspawn(i);
|
|
|
|
if (sp >= 0) spawn(i, sp);
|
2020-05-08 22:34:48 +00:00
|
|
|
ps[myconnectindex].actors_killed++;
|
|
|
|
deletesprite(i);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (s->z > hittype[i].floorz - (48 << 8))
|
|
|
|
s->z = hittype[i].floorz - (48 << 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
int x;
|
|
|
|
int p = findplayer(s, &x);
|
|
|
|
j = s->owner;
|
|
|
|
|
|
|
|
// 3 = findplayerz, 4 = shoot
|
|
|
|
|
|
|
|
if (t[0] >= 4)
|
|
|
|
{
|
|
|
|
t[2]++;
|
|
|
|
if ((t[2] & 15) == 0)
|
|
|
|
{
|
|
|
|
a = s->ang;
|
|
|
|
s->ang = hittype[i].tempang;
|
|
|
|
if (attacksnd >= 0) spritesound(attacksnd, i);
|
|
|
|
shoot(i, firelaser);
|
|
|
|
s->ang = a;
|
|
|
|
}
|
|
|
|
if (t[2] > (26 * 3) || !cansee(s->x, s->y, s->z - (16 << 8), s->sectnum, ps[p].posx, ps[p].posy, ps[p].posz, ps[p].cursectnum))
|
|
|
|
{
|
|
|
|
t[0] = 0;
|
|
|
|
t[2] = 0;
|
|
|
|
}
|
|
|
|
else hittype[i].tempang +=
|
|
|
|
getincangle(hittype[i].tempang, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) / 3;
|
|
|
|
}
|
|
|
|
else if (t[0] == 2 || t[0] == 3)
|
|
|
|
{
|
|
|
|
t[3] = 0;
|
|
|
|
if (s->xvel > 0) s->xvel -= 16;
|
|
|
|
else s->xvel = 0;
|
|
|
|
|
|
|
|
if (t[0] == 2)
|
|
|
|
{
|
|
|
|
int l = ps[p].posz - s->z;
|
|
|
|
if (abs(l) < (48 << 8)) t[0] = 3;
|
|
|
|
else s->z += sgn(ps[p].posz - s->z) << shift; // The shift here differs between Duke and RR.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
t[2]++;
|
|
|
|
if (t[2] > (26 * 3) || !cansee(s->x, s->y, s->z - (16 << 8), s->sectnum, ps[p].posx, ps[p].posy, ps[p].posz, ps[p].cursectnum))
|
|
|
|
{
|
|
|
|
t[0] = 1;
|
|
|
|
t[2] = 0;
|
|
|
|
}
|
|
|
|
else if ((t[2] & 15) == 0 && attacksnd >= 0)
|
|
|
|
{
|
|
|
|
spritesound(attacksnd, i);
|
|
|
|
shoot(i, firelaser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s->ang += getincangle(s->ang, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) >> 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t[0] != 2 && t[0] != 3)
|
|
|
|
{
|
|
|
|
int l = ldist(&sprite[j], s);
|
|
|
|
if (l <= 1524)
|
|
|
|
{
|
|
|
|
a = s->ang;
|
|
|
|
s->xvel >>= 1;
|
|
|
|
}
|
|
|
|
else a = getangle(sprite[j].x - s->x, sprite[j].y - s->y);
|
|
|
|
|
|
|
|
if (t[0] == 1 || t[0] == 4) // Found a locator and going with it
|
|
|
|
{
|
|
|
|
l = dist(&sprite[j], s);
|
|
|
|
|
|
|
|
if (l <= 1524) { if (t[0] == 1) t[0] = 0; else t[0] = 5; }
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Control speed here
|
|
|
|
if (l > 1524) { if (s->xvel < 256) s->xvel += 32; }
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (s->xvel > 0) s->xvel -= 16;
|
|
|
|
else s->xvel = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t[0] < 2) t[2]++;
|
|
|
|
|
|
|
|
if (x < 6144 && t[0] < 2 && t[2] > (26 * 4))
|
|
|
|
{
|
|
|
|
t[0] = 2 + (krand() & 2);
|
|
|
|
t[2] = 0;
|
|
|
|
hittype[i].tempang = s->ang;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t[0] == 0 || t[0] == 5)
|
|
|
|
{
|
|
|
|
if (t[0] == 0)
|
|
|
|
t[0] = 1;
|
|
|
|
else t[0] = 4;
|
|
|
|
j = s->owner = LocateTheLocator(s->hitag, -1);
|
|
|
|
if (j == -1)
|
|
|
|
{
|
|
|
|
s->hitag = j = hittype[i].temp_data[5];
|
|
|
|
s->owner = LocateTheLocator(j, -1);
|
|
|
|
j = s->owner;
|
|
|
|
if (j == -1)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else s->hitag++;
|
|
|
|
}
|
|
|
|
|
|
|
|
t[3] = getincangle(s->ang, a);
|
|
|
|
s->ang += t[3] >> 3;
|
|
|
|
|
|
|
|
if (s->z < sprite[j].z)
|
|
|
|
s->z += 1024;
|
|
|
|
else s->z -= 1024;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (roamsnd >= 0 && S_CheckSoundPlaying(roamsnd) < 2)
|
|
|
|
A_PlaySound(roamsnd, i);
|
|
|
|
|
|
|
|
ssp(i, CLIPMASK0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ooz(int i)
|
|
|
|
{
|
|
|
|
getglobalz(i);
|
|
|
|
|
|
|
|
int j = (hittype[i].floorz - hittype[i].ceilingz) >> 9;
|
|
|
|
if (j > 255) j = 255;
|
|
|
|
|
|
|
|
int x = 25 - (j >> 1);
|
|
|
|
if (x < 8) x = 8;
|
|
|
|
else if (x > 48) x = 48;
|
|
|
|
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
s->yrepeat = j;
|
|
|
|
s->xrepeat = x;
|
|
|
|
s->z = hittype[i].floorz;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void reactor(int i, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BURNT)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
|
|
|
|
if (t[4] == 1)
|
|
|
|
{
|
|
|
|
int j = headspritesect[sect];
|
|
|
|
while (j >= 0)
|
|
|
|
{
|
|
|
|
if (sprite[j].picnum == SECTOREFFECTOR)
|
|
|
|
{
|
|
|
|
if (sprite[j].lotag == 1)
|
|
|
|
{
|
|
|
|
sprite[j].lotag = (short)65535;
|
|
|
|
sprite[j].hitag = (short)65535;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sprite[j].picnum == REACTOR)
|
|
|
|
{
|
|
|
|
sprite[j].picnum = REACTORBURNT;
|
|
|
|
}
|
|
|
|
else if (sprite[j].picnum == REACTOR2)
|
|
|
|
{
|
|
|
|
sprite[j].picnum = REACTOR2BURNT;
|
|
|
|
}
|
|
|
|
else if (sprite[j].picnum == REACTORBURNT || sprite[j].picnum == REACTOR2BURNT)
|
|
|
|
{
|
|
|
|
sprite[j].cstat = (short)32768;
|
|
|
|
}
|
|
|
|
j = nextspritesect[j];
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t[1] >= 20)
|
|
|
|
{
|
|
|
|
t[4] = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int x;
|
|
|
|
int p = findplayer(s, &x);
|
|
|
|
|
|
|
|
t[2]++;
|
|
|
|
if (t[2] == 4) t[2] = 0;
|
|
|
|
|
|
|
|
if (x < 4096)
|
|
|
|
{
|
|
|
|
if ((krand() & 255) < 16)
|
|
|
|
{
|
|
|
|
if (!S_CheckSoundPlaying(DUKE_LONGTERM_PAIN))
|
|
|
|
spritesound(DUKE_LONGTERM_PAIN, ps[p].i);
|
|
|
|
|
|
|
|
spritesound(SHORT_CIRCUIT, i);
|
|
|
|
|
|
|
|
sprite[ps[p].i].extra--;
|
|
|
|
SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0));
|
|
|
|
}
|
|
|
|
t[0] += 128;
|
|
|
|
if (t[3] == 0)
|
|
|
|
t[3] = 1;
|
|
|
|
}
|
|
|
|
else t[3] = 0;
|
|
|
|
|
|
|
|
if (t[1])
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
t[1]++;
|
|
|
|
|
|
|
|
t[4] = s->z;
|
|
|
|
s->z = sector[sect].floorz - (krand() % (sector[sect].floorz - sector[sect].ceilingz));
|
|
|
|
|
|
|
|
switch (t[1])
|
|
|
|
{
|
|
|
|
case 3:
|
|
|
|
//Turn on all of those flashing sectoreffector.
|
|
|
|
hitradius(i, 4096,
|
|
|
|
impact_damage << 2,
|
|
|
|
impact_damage << 2,
|
|
|
|
impact_damage << 2,
|
|
|
|
impact_damage << 2);
|
|
|
|
j = headspritestat[6];
|
|
|
|
while (j >= 0)
|
|
|
|
{
|
|
|
|
if (sprite[j].picnum == MASTERSWITCH)
|
|
|
|
if (sprite[j].hitag == s->hitag)
|
|
|
|
if (sprite[j].yvel == 0)
|
|
|
|
sprite[j].yvel = 1;
|
|
|
|
j = nextspritestat[j];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
case 7:
|
|
|
|
case 10:
|
|
|
|
case 15:
|
|
|
|
j = headspritesect[sect];
|
|
|
|
while (j >= 0)
|
|
|
|
{
|
|
|
|
int l = nextspritesect[j];
|
|
|
|
|
|
|
|
if (j != i)
|
|
|
|
{
|
|
|
|
deletesprite(j);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
j = l;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (x = 0; x < 16; x++)
|
|
|
|
RANDOMSCRAP(s, i);
|
|
|
|
|
|
|
|
s->z = t[4];
|
|
|
|
t[4] = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int j = ifhitbyweapon(i);
|
|
|
|
if (j >= 0)
|
|
|
|
{
|
|
|
|
for (x = 0; x < 32; x++)
|
|
|
|
RANDOMSCRAP(s, i);
|
|
|
|
if (s->extra < 0)
|
|
|
|
t[1] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void camera(int i)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
if (t[0] == 0)
|
|
|
|
{
|
|
|
|
t[1] += 8;
|
|
|
|
if (camerashitable)
|
|
|
|
{
|
|
|
|
int j = ifhitbyweapon(i);
|
|
|
|
if (j >= 0)
|
|
|
|
{
|
|
|
|
t[0] = 1; // static
|
|
|
|
s->cstat = (short)32768;
|
|
|
|
for (int x = 0; x < 5; x++)
|
|
|
|
RANDOMSCRAP(s, i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->hitag > 0)
|
|
|
|
{
|
|
|
|
if (t[1] < s->hitag)
|
|
|
|
s->ang += 8;
|
|
|
|
else if (t[1] < (s->hitag * 3))
|
|
|
|
s->ang -= 8;
|
|
|
|
else if (t[1] < (s->hitag << 2))
|
|
|
|
s->ang += 8;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
t[1] = 8;
|
|
|
|
s->ang += 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-05 09:58:39 +00:00
|
|
|
|
2020-05-09 18:27:06 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// taken out of moveexplosion
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void forcesphere(int i)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
int l = s->xrepeat;
|
|
|
|
if (t[1] > 0)
|
|
|
|
{
|
|
|
|
t[1]--;
|
|
|
|
if (t[1] == 0)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hittype[s->owner].temp_data[1] == 0)
|
|
|
|
{
|
|
|
|
if (t[0] < 64)
|
|
|
|
{
|
|
|
|
t[0]++;
|
|
|
|
l += 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (t[0] > 64)
|
|
|
|
{
|
|
|
|
t[0]--;
|
|
|
|
l -= 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
s->x = sprite[s->owner].x;
|
|
|
|
s->y = sprite[s->owner].y;
|
|
|
|
s->z = sprite[s->owner].z;
|
|
|
|
s->ang += hittype[s->owner].temp_data[0];
|
|
|
|
|
|
|
|
if (l > 64) l = 64;
|
|
|
|
else if (l < 1) l = 1;
|
|
|
|
|
|
|
|
s->xrepeat = l;
|
|
|
|
s->yrepeat = l;
|
|
|
|
s->shade = (l >> 1) - 48;
|
|
|
|
|
|
|
|
for (int j = t[0]; j > 0; j--)
|
|
|
|
ssp(i, CLIPMASK0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void watersplash2(int i)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
t[0]++;
|
|
|
|
if (t[0] == 1)
|
|
|
|
{
|
|
|
|
if (sector[sect].lotag != 1 && sector[sect].lotag != 2)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!S_CheckSoundPlaying(ITEM_SPLASH))
|
|
|
|
spritesound(ITEM_SPLASH, i);
|
|
|
|
}
|
|
|
|
if (t[0] == 3)
|
|
|
|
{
|
|
|
|
t[0] = 0;
|
|
|
|
t[1]++;
|
|
|
|
}
|
|
|
|
if (t[1] == 5)
|
|
|
|
deletesprite(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void frameeffect1(int i)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
if (s->owner >= 0)
|
|
|
|
{
|
|
|
|
t[0]++;
|
|
|
|
|
|
|
|
if (t[0] > 7)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (t[0] > 4)
|
|
|
|
s->cstat |= 512 + 2;
|
|
|
|
else if (t[0] > 2)
|
|
|
|
s->cstat |= 2;
|
|
|
|
s->xoffset = sprite[s->owner].xoffset;
|
|
|
|
s->yoffset = sprite[s->owner].yoffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool money(int i, int BLOODPOOL)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
|
|
|
|
s->xvel = (krand() & 7) + (sintable[hittype[i].temp_data[0] & 2047] >> 9);
|
|
|
|
hittype[i].temp_data[0] += (krand() & 63);
|
|
|
|
if ((hittype[i].temp_data[0] & 2047) > 512 && (hittype[i].temp_data[0] & 2047) < 1596)
|
|
|
|
{
|
|
|
|
if (sector[sect].lotag == 2)
|
|
|
|
{
|
|
|
|
if (s->zvel < 64)
|
|
|
|
s->zvel += (gc >> 5) + (krand() & 7);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (s->zvel < 144)
|
|
|
|
s->zvel += (gc >> 5) + (krand() & 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
ssp(i, CLIPMASK0);
|
|
|
|
|
|
|
|
if ((krand() & 3) == 0)
|
|
|
|
setsprite(i, s->x, s->y, s->z);
|
|
|
|
|
|
|
|
if (s->sectnum == -1)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
int l = getflorzofslope(s->sectnum, s->x, s->y);
|
|
|
|
|
|
|
|
if (s->z > l)
|
|
|
|
{
|
|
|
|
s->z = l;
|
|
|
|
|
|
|
|
insertspriteq(i);
|
|
|
|
sprite[i].picnum++;
|
|
|
|
|
|
|
|
int j = headspritestat[STAT_MISC];
|
|
|
|
while (j >= 0)
|
|
|
|
{
|
|
|
|
if (sprite[j].picnum == BLOODPOOL)
|
|
|
|
if (ldist(s, &sprite[j]) < 348)
|
|
|
|
{
|
|
|
|
s->pal = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
j = nextspritestat[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool jibs(int i, int JIBS6, bool timeout, bool callsetsprite, bool floorcheck, bool zcheck1, bool zcheck2)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
|
|
|
|
if (s->xvel > 0) s->xvel--;
|
|
|
|
else s->xvel = 0;
|
|
|
|
|
|
|
|
if (timeout)
|
|
|
|
{
|
|
|
|
if (t[5] < 30 * 10)
|
|
|
|
t[5]++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->zvel > 1024 && s->zvel < 1280)
|
|
|
|
{
|
|
|
|
setsprite(i, s->x, s->y, s->z);
|
|
|
|
sect = s->sectnum;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (callsetsprite) setsprite(i, s->x, s->y, s->z);
|
|
|
|
|
|
|
|
int l = getflorzofslope(sect, s->x, s->y);
|
|
|
|
int x = getceilzofslope(sect, s->x, s->y);
|
|
|
|
if (x == l || sect < 0 || sect >= MAXSECTORS)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->z < l - (2 << 8))
|
|
|
|
{
|
|
|
|
if (t[1] < 2) t[1]++;
|
|
|
|
else if (sector[sect].lotag != 2)
|
|
|
|
{
|
|
|
|
t[1] = 0;
|
|
|
|
if (zcheck1)
|
|
|
|
{
|
|
|
|
if (t[0] > 6) t[0] = 0;
|
|
|
|
else t[0]++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (t[0] > 2)
|
|
|
|
t[0] = 0;
|
|
|
|
else t[0]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->zvel < 6144)
|
|
|
|
{
|
|
|
|
if (sector[sect].lotag == 2)
|
|
|
|
{
|
|
|
|
if (s->zvel < 1024)
|
|
|
|
s->zvel += 48;
|
|
|
|
else s->zvel = 1024;
|
|
|
|
}
|
|
|
|
else s->zvel += gc - 50;
|
|
|
|
}
|
|
|
|
|
|
|
|
s->x += (s->xvel * sintable[(s->ang + 512) & 2047]) >> 14;
|
|
|
|
s->y += (s->xvel * sintable[s->ang & 2047]) >> 14;
|
|
|
|
s->z += s->zvel;
|
|
|
|
|
|
|
|
if (floorcheck && s->z >= sector[s->sectnum].floorz)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (zcheck2)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (t[2] == 0)
|
|
|
|
{
|
|
|
|
if (s->sectnum == -1)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ((sector[s->sectnum].floorstat & 2))
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
t[2]++;
|
|
|
|
}
|
|
|
|
l = getflorzofslope(s->sectnum, s->x, s->y);
|
|
|
|
|
|
|
|
s->z = l - (2 << 8);
|
|
|
|
s->xvel = 0;
|
|
|
|
|
|
|
|
if (s->picnum == JIBS6)
|
|
|
|
{
|
|
|
|
t[1]++;
|
|
|
|
if ((t[1] & 3) == 0 && t[0] < 7)
|
|
|
|
t[0]++;
|
|
|
|
if (t[1] > 20)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { s->picnum = JIBS6; t[0] = 0; t[1] = 0; }
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool bloodpool(int i, bool puke, int TIRE)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
|
|
|
|
if (t[0] == 0)
|
|
|
|
{
|
|
|
|
t[0] = 1;
|
|
|
|
if (sector[sect].floorstat & 2)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else insertspriteq(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
makeitfall(i);
|
|
|
|
|
|
|
|
int x;
|
|
|
|
int p = findplayer(s, &x);
|
|
|
|
|
|
|
|
s->z = hittype[i].floorz - (FOURSLEIGHT);
|
|
|
|
|
|
|
|
if (t[2] < 32)
|
|
|
|
{
|
|
|
|
t[2]++;
|
|
|
|
if (hittype[i].picnum == TIRE)
|
|
|
|
{
|
|
|
|
if (s->xrepeat < 64 && s->yrepeat < 64)
|
|
|
|
{
|
|
|
|
s->xrepeat += krand() & 3;
|
|
|
|
s->yrepeat += krand() & 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (s->xrepeat < 32 && s->yrepeat < 32)
|
|
|
|
{
|
|
|
|
s->xrepeat += krand() & 3;
|
|
|
|
s->yrepeat += krand() & 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x < 844 && s->xrepeat > 6 && s->yrepeat > 6)
|
|
|
|
{
|
|
|
|
if (s->pal == 0 && (krand() & 255) < 16 && !puke)
|
|
|
|
{
|
|
|
|
if (ps[p].boot_amount > 0)
|
|
|
|
ps[p].boot_amount--;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!S_CheckSoundPlaying(DUKE_LONGTERM_PAIN))
|
|
|
|
spritesound(DUKE_LONGTERM_PAIN, ps[p].i);
|
|
|
|
sprite[ps[p].i].extra--;
|
|
|
|
SetPlayerPal(&ps[p], PalEntry(32, 16, 0, 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t[1] == 1) return false;
|
|
|
|
t[1] = 1;
|
|
|
|
|
|
|
|
if (hittype[i].picnum == TIRE)
|
|
|
|
ps[p].footprintcount = 10;
|
|
|
|
else ps[p].footprintcount = 3;
|
|
|
|
|
|
|
|
ps[p].footprintpal = s->pal;
|
|
|
|
ps[p].footprintshade = s->shade;
|
|
|
|
|
|
|
|
if (t[2] == 32)
|
|
|
|
{
|
|
|
|
s->xrepeat -= 6;
|
|
|
|
s->yrepeat -= 6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else t[1] = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void shell(int i, bool morecheck)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
|
|
|
|
ssp(i, CLIPMASK0);
|
|
|
|
|
|
|
|
if (sect < 0 || morecheck)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sector[sect].lotag == 2)
|
|
|
|
{
|
|
|
|
t[1]++;
|
|
|
|
if (t[1] > 8)
|
|
|
|
{
|
|
|
|
t[1] = 0;
|
|
|
|
t[0]++;
|
|
|
|
t[0] &= 3;
|
|
|
|
}
|
|
|
|
if (s->zvel < 128) s->zvel += (gc / 13); // 8
|
|
|
|
else s->zvel -= 64;
|
|
|
|
if (s->xvel > 0)
|
|
|
|
s->xvel -= 4;
|
|
|
|
else s->xvel = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
t[1]++;
|
|
|
|
if (t[1] > 3)
|
|
|
|
{
|
|
|
|
t[1] = 0;
|
|
|
|
t[0]++;
|
|
|
|
t[0] &= 3;
|
|
|
|
}
|
|
|
|
if (s->zvel < 512) s->zvel += (gc / 3); // 52;
|
|
|
|
if (s->xvel > 0)
|
|
|
|
s->xvel--;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void glasspieces(int i)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
|
|
|
|
makeitfall(i);
|
|
|
|
|
|
|
|
if (s->zvel > 4096) s->zvel = 4096;
|
|
|
|
if (sect < 0)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->z == hittype[i].floorz - (FOURSLEIGHT) && t[0] < 3)
|
|
|
|
{
|
|
|
|
s->zvel = -((3 - t[0]) << 8) - (krand() & 511);
|
|
|
|
if (sector[sect].lotag == 2)
|
|
|
|
s->zvel >>= 1;
|
|
|
|
s->xrepeat >>= 1;
|
|
|
|
s->yrepeat >>= 1;
|
|
|
|
if (rnd(96))
|
|
|
|
setsprite(i, s->x, s->y, s->z);
|
|
|
|
t[0]++;//Number of bounces
|
|
|
|
}
|
|
|
|
else if (t[0] == 3)
|
|
|
|
{
|
|
|
|
deletesprite(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->xvel > 0)
|
|
|
|
{
|
|
|
|
s->xvel -= 2;
|
|
|
|
s->cstat = ((s->xvel & 3) << 2);
|
|
|
|
}
|
|
|
|
else s->xvel = 0;
|
|
|
|
|
|
|
|
ssp(i, CLIPMASK0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void scrap(int i, int SCRAP1, int SCRAP6)
|
|
|
|
{
|
|
|
|
spritetype* s = &sprite[i];
|
|
|
|
int sect = s->sectnum;
|
|
|
|
auto t = &hittype[i].temp_data[0];
|
|
|
|
|
|
|
|
if (s->xvel > 0)
|
|
|
|
s->xvel--;
|
|
|
|
else s->xvel = 0;
|
|
|
|
|
|
|
|
if (s->zvel > 1024 && s->zvel < 1280)
|
|
|
|
{
|
|
|
|
setsprite(i, s->x, s->y, s->z);
|
|
|
|
sect = s->sectnum;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->z < sector[sect].floorz - (2 << 8))
|
|
|
|
{
|
|
|
|
if (t[1] < 1) t[1]++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
t[1] = 0;
|
|
|
|
|
|
|
|
if (s->picnum < SCRAP6 + 8)
|
|
|
|
{
|
|
|
|
if (t[0] > 6)
|
|
|
|
t[0] = 0;
|
|
|
|
else t[0]++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (t[0] > 2)
|
|
|
|
t[0] = 0;
|
|
|
|
else t[0]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (s->zvel < 4096) s->zvel += gc - 50;
|
|
|
|
s->x += (s->xvel * sintable[(s->ang + 512) & 2047]) >> 14;
|
|
|
|
s->y += (s->xvel * sintable[s->ang & 2047]) >> 14;
|
|
|
|
s->z += s->zvel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (s->picnum == SCRAP1 && s->yvel > 0)
|
|
|
|
{
|
|
|
|
int j = spawn(i, s->yvel);
|
|
|
|
setsprite(j, s->x, s->y, s->z);
|
|
|
|
getglobalz(j);
|
|
|
|
sprite[j].hitag = sprite[j].lotag = 0;
|
|
|
|
}
|
|
|
|
deletesprite(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-05 09:58:39 +00:00
|
|
|
END_DUKE_NS
|