raze/source/games/duke/src/actors_r.cpp

4082 lines
93 KiB
C++
Raw Normal View History

2020-05-07 12:55:04 +00:00
//-------------------------------------------------------------------------
/*
Copyright (C) 1996, 2003 - 3D Realms Entertainment
Copyright (C) 2017-2019 Nuke.YKT
2020-05-13 14:19:39 +00:00
Copyright (C) 2020 - Christoph Oelckers
2020-05-07 12:55:04 +00:00
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
2020-05-07 12:55:04 +00:00
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
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "global.h"
#include "names_r.h"
2020-07-07 15:56:20 +00:00
#include "mapinfo.h"
#include "dukeactor.h"
2020-05-07 12:55:04 +00:00
BEGIN_DUKE_NS
2020-05-08 22:34:48 +00:00
void dojaildoor();
void moveminecart();
2020-10-22 20:31:10 +00:00
void ballreturn(DDukeActor* spr);
void pinsectorresetdown(sectortype* sect);
int pinsectorresetup(sectortype* sect);
int checkpins(sectortype* sect);
void resetpins(sectortype* sect);
2020-05-08 22:34:48 +00:00
void resetlanepics(void);
2020-05-07 12:55:04 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
bool ceilingspace_r(sectortype* sectp)
2020-05-07 12:55:04 +00:00
{
if (sectp && (sectp->ceilingstat & CSTAT_SECTOR_SKY) && sectp->ceilingpal == 0)
2020-05-07 12:55:04 +00:00
{
switch(sectp->ceilingpicnum)
2020-05-07 12:55:04 +00:00
{
case MOONSKY1:
case BIGORBIT1:
return 1;
2020-05-07 12:55:04 +00:00
}
}
return 0;
}
2020-05-07 12:55:04 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
bool floorspace_r(sectortype* sectp)
2020-05-07 12:55:04 +00:00
{
if (sectp && (sectp->floorstat & CSTAT_SECTOR_SKY) && sectp->ceilingpal == 0)
2020-05-07 12:55:04 +00:00
{
switch(sectp->floorpicnum)
2020-05-07 12:55:04 +00:00
{
case MOONSKY1:
case BIGORBIT1:
return 1;
2020-05-07 12:55:04 +00:00
}
}
return 0;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-22 17:08:10 +00:00
void check_fta_sounds_r(DDukeActor* actor)
2020-05-16 10:47:01 +00:00
{
if (actor->spr.extra > 0) switch (actor->spr.picnum)
2020-05-16 10:47:01 +00:00
{
case COOT: // LIZTROOP
if (!isRRRA() && (krand() & 3) == 2)
2020-10-22 17:08:10 +00:00
S_PlayActorSound(PRED_RECOG, actor);
2020-05-16 10:47:01 +00:00
break;
case BILLYCOCK:
case BILLYRAY:
case BRAYSNIPER: // PIGCOP
2020-10-22 17:08:10 +00:00
S_PlayActorSound(PIG_RECOG, actor);
2020-05-16 10:47:01 +00:00
break;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void addweapon_r(struct player_struct* p, int weapon)
2020-05-07 12:55:04 +00:00
{
int cw = p->curr_weapon;
2020-05-07 12:55:04 +00:00
if (p->OnMotorcycle || p->OnBoat)
{
p->gotweapon[weapon] = true;;
if (weapon == THROWSAW_WEAPON)
2020-05-07 12:55:04 +00:00
{
p->gotweapon[BUZZSAW_WEAPON] = true;
p->ammo_amount[BUZZSAW_WEAPON] = 1;
2020-05-07 12:55:04 +00:00
}
else if (weapon == CROSSBOW_WEAPON)
2020-05-07 12:55:04 +00:00
{
p->gotweapon[CHICKEN_WEAPON] = true;
p->gotweapon[DYNAMITE_WEAPON] = true;
2020-05-07 12:55:04 +00:00
}
else if (weapon == SLINGBLADE_WEAPON)
2020-05-07 12:55:04 +00:00
{
p->ammo_amount[SLINGBLADE_WEAPON] = 1;
2020-05-07 12:55:04 +00:00
}
return;
}
if (p->gotweapon[weapon] == 0)
{
p->gotweapon[weapon] = true;;
if (weapon == THROWSAW_WEAPON)
2020-05-07 12:55:04 +00:00
{
p->gotweapon[BUZZSAW_WEAPON] = true;
p->ammo_amount[BUZZSAW_WEAPON] = 1;
2020-05-07 12:55:04 +00:00
}
if (isRRRA())
{
if (weapon == CROSSBOW_WEAPON)
2020-05-07 12:55:04 +00:00
{
p->gotweapon[CHICKEN_WEAPON] = true;
2020-05-07 12:55:04 +00:00
}
if (weapon == SLINGBLADE_WEAPON)
2020-05-07 12:55:04 +00:00
{
p->ammo_amount[SLINGBLADE_WEAPON] = 50;
2020-05-07 12:55:04 +00:00
}
}
if (weapon == CROSSBOW_WEAPON)
{
p->gotweapon[DYNAMITE_WEAPON] = true;
}
2020-05-07 12:55:04 +00:00
if (weapon != DYNAMITE_WEAPON)
2020-05-07 12:55:04 +00:00
cw = weapon;
}
else
cw = weapon;
if (weapon == DYNAMITE_WEAPON)
2020-05-07 12:55:04 +00:00
p->last_weapon = -1;
p->random_club_frame = 0;
if (p->holster_weapon == 0)
{
p->weapon_pos = -1;
p->last_weapon = p->curr_weapon;
}
else
{
p->weapon_pos = 10;
p->holster_weapon = 0;
p->last_weapon = -1;
}
p->okickback_pic = p->kickback_pic = 0;
2020-05-07 12:55:04 +00:00
p->curr_weapon = cw;
p->wantweaponfire = -1;
2020-05-07 12:55:04 +00:00
switch (weapon)
{
case SLINGBLADE_WEAPON:
if (!isRRRA()) break;
2020-05-07 12:55:04 +00:00
case KNEE_WEAPON:
2020-07-20 21:21:27 +00:00
case DYNAMITE_WEAPON:
2020-05-07 12:55:04 +00:00
case TRIPBOMB_WEAPON:
case THROWINGDYNAMITE_WEAPON:
2020-05-07 12:55:04 +00:00
break;
case SHOTGUN_WEAPON:
2020-11-02 19:23:05 +00:00
S_PlayActorSound(SHOTGUN_COCK, p->GetActor());
2020-05-07 12:55:04 +00:00
break;
case PISTOL_WEAPON:
2020-11-02 19:23:05 +00:00
S_PlayActorSound(INSERT_CLIP, p->GetActor());
2020-05-07 12:55:04 +00:00
break;
default:
2020-11-02 19:23:05 +00:00
S_PlayActorSound(EJECT_CLIP, p->GetActor());
2020-05-07 12:55:04 +00:00
break;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int hp4)
2020-05-07 12:55:04 +00:00
{
static const uint8_t statlist[] = { STAT_DEFAULT, STAT_ACTOR, STAT_STANDABLE, STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC };
2021-12-21 18:13:49 +00:00
if (actor->spr.xrepeat >= 11 || !(actor->spr.picnum == RPG || ((isRRRA()) && actor->spr.picnum == RPG2)))
2020-05-07 12:55:04 +00:00
{
BFSSectorSearch search(actor->sector());
while (auto dasectp = search.GetNext())
2020-05-07 12:55:04 +00:00
{
if (((dasectp->ceilingz - actor->spr.pos.Z) >> 8) < r)
2020-05-07 12:55:04 +00:00
{
auto wal = dasectp->firstWall();
int d = abs(wal->pos.X - actor->spr.pos.X) + abs(wal->pos.Y - actor->spr.pos.Y);
2020-05-07 12:55:04 +00:00
if (d < r)
fi.checkhitceiling(dasectp);
else
2020-05-07 12:55:04 +00:00
{
auto thirdpoint = wal->point2Wall()->point2Wall();
d = abs(thirdpoint->pos.X - actor->spr.pos.X) + abs(thirdpoint->pos.Y - actor->spr.pos.Y);
if (d < r)
fi.checkhitceiling(dasectp);
2020-05-07 12:55:04 +00:00
}
}
for (auto& wal : wallsofsector(dasectp))
{
if ((abs(wal.pos.X - actor->spr.pos.X) + abs(wal.pos.Y - actor->spr.pos.Y)) < r)
{
if (wal.twoSided())
{
search.Add(wal.nextSector());
}
int x1 = (((wal.pos.X + wal.point2Wall()->pos.X) >> 1) + actor->spr.pos.X) >> 1;
int y1 = (((wal.pos.Y + wal.point2Wall()->pos.Y) >> 1) + actor->spr.pos.Y) >> 1;
2021-11-21 08:05:58 +00:00
auto sect = wal.sectorp();
updatesector(x1, y1, &sect);
if (sect != nullptr && cansee(x1, y1, actor->spr.pos.Z, sect, actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, actor->sector()))
fi.checkhitwall(actor, &wal, wal.pos.X, wal.pos.Y, actor->spr.pos.Z, actor->spr.picnum);
}
}
}
}
2020-05-07 12:55:04 +00:00
int q = -(24 << 8) + (krand() & ((32 << 8) - 1));
2020-05-07 12:55:04 +00:00
auto Owner = actor->GetOwner();
for (int x = 0; x < 7; x++)
2020-05-07 12:55:04 +00:00
{
DukeStatIterator it1(statlist[x]);
while (auto act2 = it1.Next())
2020-05-07 12:55:04 +00:00
{
2022-01-26 23:41:33 +00:00
if (x == 0 || x >= 5 || actorflag(act2, SFLAG_HITRADIUS_FLAG1))
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
if (act2->spr.cstat & CSTAT_SPRITE_BLOCK_ALL)
if (dist(actor, act2) < r)
2020-05-07 12:55:04 +00:00
{
if (badguy(act2) && !cansee(act2->spr.pos.X, act2->spr.pos.Y, act2->spr.pos.Z + q, act2->sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z + q, actor->sector()))
{
2020-05-08 22:34:48 +00:00
continue;
}
fi.checkhitsprite(act2, actor);
2020-05-07 12:55:04 +00:00
}
}
else if (act2->spr.extra >= 0 && act2 != actor && (actorflag(act2, SFLAG_HITRADIUS_FLAG2) || badguy(act2) || (act2->spr.cstat & CSTAT_SPRITE_BLOCK_ALL)))
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:13:49 +00:00
if (actor->spr.picnum == MORTER && act2 == Owner)
2020-05-07 12:55:04 +00:00
{
continue;
}
2021-12-21 18:13:49 +00:00
if ((isRRRA()) && actor->spr.picnum == CHEERBOMB && act2 == Owner)
{
continue;
}
if (act2->spr.picnum == APLAYER) act2->spr.pos.Z -= gs.playerheight;
int d = dist(actor, act2);
if (act2->spr.picnum == APLAYER) act2->spr.pos.Z += gs.playerheight;
if (d < r && cansee(act2->spr.pos.X, act2->spr.pos.Y, act2->spr.pos.Z - (8 << 8), act2->sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - (12 << 8), actor->sector()))
{
2021-12-21 18:56:46 +00:00
if ((isRRRA()) && act2->spr.picnum == MINION && act2->spr.pal == 19)
2020-05-07 12:55:04 +00:00
{
continue;
}
act2->hitang = getangle(act2->spr.pos.X - actor->spr.pos.X, act2->spr.pos.Y - actor->spr.pos.Y);
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if (actor->spr.picnum == RPG && act2->spr.extra > 0)
act2->attackertype = RPG;
2021-12-21 18:56:46 +00:00
else if ((isRRRA()) && actor->spr.picnum == RPG2 && act2->spr.extra > 0)
act2->attackertype = RPG;
else
act2->attackertype = RADIUSEXPLOSION;
2020-05-07 12:55:04 +00:00
if (d < r / 3)
{
if (hp4 == hp3) hp4++;
act2->hitextra = hp3 + (krand() % (hp4 - hp3));
2020-05-07 12:55:04 +00:00
}
else if (d < 2 * r / 3)
2020-05-07 12:55:04 +00:00
{
if (hp3 == hp2) hp3++;
act2->hitextra = hp2 + (krand() % (hp3 - hp2));
2020-05-07 12:55:04 +00:00
}
else if (d < r)
2020-05-07 12:55:04 +00:00
{
if (hp2 == hp1) hp2++;
act2->hitextra = hp1 + (krand() % (hp2 - hp1));
2020-05-07 12:55:04 +00:00
}
2021-12-21 18:56:46 +00:00
int pic = act2->spr.picnum;
if ((isRRRA())?
(pic != HULK && pic != MAMA && pic != BILLYPLAY && pic != COOTPLAY && pic != MAMACLOUD) :
(pic != HULK && pic != SBMOVE))
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
if (act2->spr.xvel < 0) act2->spr.xvel = 0;
act2->spr.xvel += (act2->spr.extra << 2);
}
2020-05-07 12:55:04 +00:00
if (actorflag(act2, SFLAG_HITRADIUSCHECK))
fi.checkhitsprite(act2, actor);
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if (act2->spr.picnum != RADIUSEXPLOSION &&
Owner && Owner->spr.statnum < MAXSTATUS)
{
2021-12-21 18:56:46 +00:00
if (act2->spr.picnum == APLAYER)
2020-05-07 12:55:04 +00:00
{
int p = act2->PlayerIndex();
2020-11-02 23:20:51 +00:00
if (ps[p].newOwner != nullptr)
2020-05-07 12:55:04 +00:00
{
clearcamera(&ps[p]);
2020-05-07 12:55:04 +00:00
}
}
act2->SetHitOwner(actor->GetOwner());
2020-05-07 12:55:04 +00:00
}
}
}
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int movesprite_ex_r(DDukeActor* actor, int xchange, int ychange, int zchange, unsigned int cliptype, Collision &result)
2020-05-07 12:55:04 +00:00
{
int clipdist;
int bg = badguy(actor);
2020-05-07 12:55:04 +00:00
2021-12-21 18:13:49 +00:00
if (actor->spr.statnum == 5 || (bg && actor->spr.xrepeat < 4))
2020-05-07 12:55:04 +00:00
{
actor->spr.pos.X += (xchange * TICSPERFRAME) >> 2;
actor->spr.pos.Y += (ychange * TICSPERFRAME) >> 2;
actor->spr.pos.Z += (zchange * TICSPERFRAME) >> 2;
2020-05-07 12:55:04 +00:00
if (bg)
2021-12-21 18:13:49 +00:00
SetActor(actor, actor->spr.pos);
return result.setNone();
2020-05-07 12:55:04 +00:00
}
auto dasectp = actor->sector();
2020-05-07 12:55:04 +00:00
2021-12-21 18:13:49 +00:00
vec3_t pos = actor->spr.pos;
2021-12-22 09:41:47 +00:00
pos.Z -= ((tileHeight(actor->spr.picnum) * actor->spr.yrepeat) << 1);
2020-05-07 12:55:04 +00:00
if (bg)
{
2021-12-21 18:13:49 +00:00
if (actor->spr.xrepeat > 60)
clipmove(pos, &dasectp, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024, (4 << 8), (4 << 8), cliptype, result);
else
2020-05-07 12:55:04 +00:00
{
clipdist = 192;
clipmove(pos, &dasectp, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), clipdist, (4 << 8), (4 << 8), cliptype, result);
2020-05-07 12:55:04 +00:00
}
2021-11-21 08:05:58 +00:00
if (dasectp == nullptr || (dasectp != nullptr && actor->actorstayput != nullptr && actor->actorstayput != dasectp))
2020-05-07 12:55:04 +00:00
{
2021-11-21 08:05:58 +00:00
if (dasectp && dasectp->lotag == ST_1_ABOVE_WATER)
2021-12-21 18:13:49 +00:00
actor->spr.ang = (krand() & 2047);
else if ((actor->temp_data[0] & 3) == 1)
2021-12-21 18:13:49 +00:00
actor->spr.ang = (krand() & 2047);
SetActor(actor, actor->spr.pos);
2021-11-21 08:05:58 +00:00
if (dasectp == nullptr) dasectp = &sector[0];
return result.setSector(dasectp);
2020-05-07 12:55:04 +00:00
}
if ((result.type == kHitWall || result.type == kHitSprite) && (actor->cgg == 0)) actor->spr.ang += 768;
2020-05-07 12:55:04 +00:00
}
else
{
2021-12-21 18:13:49 +00:00
if (actor->spr.statnum == STAT_PROJECTILE)
clipmove(pos, &dasectp, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 8, (4 << 8), (4 << 8), cliptype, result);
2020-05-07 12:55:04 +00:00
else
clipmove(pos, &dasectp, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 128, (4 << 8), (4 << 8), cliptype, result);
2020-05-07 12:55:04 +00:00
}
actor->spr.pos.X = pos.X;
actor->spr.pos.Y = pos.Y;
2020-05-07 12:55:04 +00:00
2021-11-21 08:05:58 +00:00
if (dasectp)
if ((dasectp != actor->sector()))
ChangeActorSect(actor, dasectp);
int daz = actor->spr.pos.Z + ((zchange * TICSPERFRAME) >> 3);
if ((daz > actor->ceilingz) && (daz <= actor->floorz))
actor->spr.pos.Z = daz;
else if (result.type == kHitNone)
2021-11-21 08:05:58 +00:00
return result.setSector(dasectp);
2020-05-07 12:55:04 +00:00
return result.type;
2020-05-07 12:55:04 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void lotsoffeathers_r(DDukeActor *actor, int n)
2020-05-07 12:55:04 +00:00
{
lotsofstuff(actor, n, MONEY);
2020-05-07 12:55:04 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void guts_r(DDukeActor* actor, int gtype, int n, int p)
2020-05-07 12:55:04 +00:00
{
int gutz, floorz;
int j;
2020-05-07 12:55:04 +00:00
int sx, sy;
uint8_t pal;
2021-12-21 18:56:46 +00:00
if (badguy(actor) && actor->spr.xrepeat < 16)
2020-05-07 12:55:04 +00:00
sx = sy = 8;
else sx = sy = 32;
gutz = actor->spr.pos.Z - (8 << 8);
floorz = getflorzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
2020-05-07 12:55:04 +00:00
if (gutz > (floorz - (8 << 8)))
gutz = floorz - (8 << 8);
2021-12-21 18:56:46 +00:00
gutz += gs.actorinfo[actor->spr.picnum].gutsoffset;
2021-12-21 18:56:46 +00:00
if (badguy(actor) && actor->spr.pal == 6)
2020-05-07 12:55:04 +00:00
pal = 6;
else
{
pal = 0;
if (isRRRA())
{
2021-12-21 18:56:46 +00:00
if (actor->spr.picnum == MINION && (actor->spr.pal == 8 || actor->spr.pal == 19)) pal = actor->spr.pal;
2020-05-07 12:55:04 +00:00
}
}
for (j = 0; j < n; j++)
{
// RANDCORRECT version from RR.
int a = krand() & 2047;
int r1 = krand();
int r2 = krand();
int r3 = krand();
int r4 = krand();
int r5 = krand();
// TRANSITIONAL: owned by a player???
auto spawned = EGS(actor->sector(), actor->spr.pos.X + (r5 & 255) - 128, actor->spr.pos.Y + (r4 & 255) - 128, gutz - (r3 & 8191), gtype, -32, sx >> 1, sy >> 1, a, 48 + (r2 & 31), -512 - (r1 & 2047), ps[p].GetActor(), 5);
if (spawned && pal != 0)
spawned->spr.pal = pal;
2020-05-07 12:55:04 +00:00
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int ifhitbyweapon_r(DDukeActor *actor)
2020-05-07 12:55:04 +00:00
{
int p;
auto hitowner = actor->GetHitOwner();
2020-05-07 12:55:04 +00:00
if (actor->hitextra >= 0)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:13:49 +00:00
if (actor->spr.extra >= 0)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:13:49 +00:00
if (actor->spr.picnum == APLAYER)
2020-05-07 12:55:04 +00:00
{
if (ud.god) return -1;
2020-05-07 12:55:04 +00:00
p = actor->PlayerIndex();
2020-05-07 12:55:04 +00:00
if (hitowner &&
hitowner->spr.picnum == APLAYER &&
2020-05-07 12:55:04 +00:00
ud.coop == 1 &&
ud.ffire == 0)
return -1;
actor->spr.extra -= actor->hitextra;
2020-05-07 12:55:04 +00:00
if (hitowner)
2020-05-07 12:55:04 +00:00
{
if (actor->spr.extra <= 0 && actor->attackertype != FREEZEBLAST)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:13:49 +00:00
actor->spr.extra = 0;
2020-05-07 12:55:04 +00:00
ps[p].wackedbyactor = hitowner;
2020-05-07 12:55:04 +00:00
if (hitowner->spr.picnum == APLAYER && p != hitowner->PlayerIndex())
2020-05-07 12:55:04 +00:00
{
ps[p].frag_ps = hitowner->PlayerIndex();
2020-05-07 12:55:04 +00:00
}
actor->SetHitOwner(ps[p].GetActor());
2020-05-07 12:55:04 +00:00
}
}
int pn = actor->attackertype;
2020-05-14 19:52:00 +00:00
if (pn == RPG2 && !isRRRA()) pn = 0; // avoid messing around with gotos.
switch (pn)
{
case RADIUSEXPLOSION:
case RPG:
case HYDRENT:
case HEAVYHBOMB:
case SEENINE:
case OOZFILTER:
case EXPLODINGBARREL:
2022-01-19 09:48:18 +00:00
case POWDERKEG:
case RPG2:
ps[p].vel.X += actor->hitextra * bcos(actor->hitang, 2);
ps[p].vel.Y += actor->hitextra * bsin(actor->hitang, 2);
break;
default:
ps[p].vel.X += actor->hitextra * bcos(actor->hitang, 1);
ps[p].vel.Y += actor->hitextra * bsin(actor->hitang, 1);
break;
}
2020-05-07 12:55:04 +00:00
}
else
{
if (actor->hitextra == 0)
2021-12-21 18:13:49 +00:00
if (actor->spr.xrepeat < 24)
2020-05-07 12:55:04 +00:00
return -1;
actor->spr.extra -= actor->hitextra;
2021-12-21 18:13:49 +00:00
if (actor->spr.picnum != RECON && actor->GetOwner() && actor->GetOwner()->spr.statnum < MAXSTATUS)
actor->SetOwner(hitowner);
2020-05-07 12:55:04 +00:00
}
actor->hitextra = -1;
return actor->attackertype;
2020-05-07 12:55:04 +00:00
}
}
actor->hitextra = -1;
2020-05-07 12:55:04 +00:00
return -1;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void respawn_rrra(DDukeActor* oldact, DDukeActor* newact)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
newact->spr.pal = oldact->spr.pal;
if (newact->spr.picnum == MAMA)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
if (newact->spr.pal == 30)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
newact->spr.xrepeat = 26;
newact->spr.yrepeat = 26;
newact->spr.clipdist = 75;
2020-05-07 12:55:04 +00:00
}
2021-12-21 18:56:46 +00:00
else if (newact->spr.pal == 31)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
newact->spr.xrepeat = 36;
newact->spr.yrepeat = 36;
newact->spr.clipdist = 100;
2020-05-07 12:55:04 +00:00
}
2021-12-21 18:56:46 +00:00
else if (newact->spr.pal == 32)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
newact->spr.xrepeat = 50;
newact->spr.yrepeat = 50;
newact->spr.clipdist = 100;
2020-05-07 12:55:04 +00:00
}
else
{
2021-12-21 18:56:46 +00:00
newact->spr.xrepeat = 50;
newact->spr.yrepeat = 50;
newact->spr.clipdist = 100;
2020-05-07 12:55:04 +00:00
}
}
2021-12-21 18:56:46 +00:00
if (newact->spr.pal == 8)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
newact->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT;
}
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if (newact->spr.pal != 6)
{
deletesprite(oldact);
return;
2020-05-07 12:55:04 +00:00
}
oldact->spr.extra = (66 - 13);
2021-12-21 18:56:46 +00:00
newact->spr.pal = 0;
2020-05-07 12:55:04 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void movefallers_r(void)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:31:06 +00:00
DukeStatIterator it(STAT_FALLER);
while (auto act = it.Next())
2020-05-07 12:55:04 +00:00
{
auto sectp = act->sector();
2020-05-07 12:55:04 +00:00
2020-10-22 17:31:06 +00:00
if (act->temp_data[0] == 0)
2020-05-07 12:55:04 +00:00
{
act->spr.pos.Z -= (16 << 8);
2021-12-21 18:56:46 +00:00
act->temp_data[1] = act->spr.ang;
int x = act->spr.extra;
2020-10-22 17:31:06 +00:00
int j = fi.ifhitbyweapon(act);
if (j >= 0)
2020-05-07 12:55:04 +00:00
{
if (j == RPG || (isRRRA() && j == RPG2) || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
if (act->spr.extra <= 0)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:31:06 +00:00
act->temp_data[0] = 1;
DukeStatIterator itr(STAT_FALLER);
while (auto ac2 = itr.Next())
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
if (ac2->spr.hitag == act->spr.hitag)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:31:06 +00:00
ac2->temp_data[0] = 1;
ac2->spr.cstat &= ~CSTAT_SPRITE_ONE_SIDE;
if (ac2->spr.picnum == CEILINGSTEAM || ac2->spr.picnum == STEAM)
ac2->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
2020-05-07 12:55:04 +00:00
}
}
}
}
else
{
act->hitextra = 0;
2021-12-21 18:56:46 +00:00
act->spr.extra = x;
2020-05-07 12:55:04 +00:00
}
}
2021-12-21 18:56:46 +00:00
act->spr.ang = act->temp_data[1];
act->spr.pos.Z += (16 << 8);
2020-05-07 12:55:04 +00:00
}
2020-10-22 17:31:06 +00:00
else if (act->temp_data[0] == 1)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
if (act->spr.lotag > 0)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
act->spr.lotag -= 3;
act->spr.xvel = ((64 + krand()) & 127);
act->spr.zvel = -(1024 + (krand() & 1023));
2020-05-07 12:55:04 +00:00
}
else
{
2021-12-21 18:56:46 +00:00
if (act->spr.xvel > 0)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
act->spr.xvel -= 2;
2020-10-22 17:31:06 +00:00
ssp(act, CLIPMASK0);
2020-05-07 12:55:04 +00:00
}
2020-10-22 17:31:06 +00:00
int x;
if (fi.floorspace(act->sector())) x = 0;
2020-05-07 12:55:04 +00:00
else
{
if (fi.ceilingspace(act->sector()))
x = gs.gravity / 6;
2020-05-07 12:55:04 +00:00
else
x = gs.gravity;
2020-05-07 12:55:04 +00:00
}
if (act->spr.pos.Z < (sectp->floorz - FOURSLEIGHT))
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
act->spr.zvel += x;
if (act->spr.zvel > 6144)
act->spr.zvel = 6144;
act->spr.pos.Z += act->spr.zvel;
2020-05-07 12:55:04 +00:00
}
if ((sectp->floorz - act->spr.pos.Z) < (16 << 8))
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:31:06 +00:00
int j = 1 + (krand() & 7);
for (x = 0; x < j; x++) RANDOMSCRAP(act);
deletesprite(act);
2020-05-07 12:55:04 +00:00
}
}
}
}
}
//---------------------------------------------------------------------------
//
// split out of movestandables
//
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void movecrack(DDukeActor* actor)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
if (actor->spr.hitag > 0)
2020-05-07 12:55:04 +00:00
{
actor->temp_data[0] = actor->spr.cstat;
actor->temp_data[1] = actor->spr.ang;
int j = fi.ifhitbyweapon(actor);
if (j == RPG || (isRRRA() && j == RPG2) || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER)
2020-05-07 12:55:04 +00:00
{
DukeStatIterator it(STAT_STANDABLE);
while (auto a1 = it.Next())
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
if (actor->spr.hitag == a1->spr.hitag && (a1->spr.picnum == OOZFILTER || a1->spr.picnum == SEENINE))
if (a1->spr.shade != -32)
a1->spr.shade = -32;
2020-05-07 12:55:04 +00:00
}
detonate(actor, EXPLOSION2);
}
else
{
actor->spr.cstat = ESpriteFlags::FromInt(actor->temp_data[0]);
actor->spr.ang = actor->temp_data[1];
2021-12-21 18:56:46 +00:00
actor->spr.extra = 0;
2020-05-07 12:55:04 +00:00
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-22 17:46:42 +00:00
static void movebolt(DDukeActor* actor)
2020-05-07 12:55:04 +00:00
{
int x;
auto sectp = actor->sector();
2020-05-07 12:55:04 +00:00
findplayer(actor, &x);
2020-05-07 12:55:04 +00:00
if (x > 20480) return;
if (actor->temp_data[3] == 0)
actor->temp_data[3] = sectp->floorshade;
2020-05-07 12:55:04 +00:00
CLEAR_THE_BOLT:
if (actor->temp_data[2])
2020-05-07 12:55:04 +00:00
{
actor->temp_data[2]--;
sectp->floorshade = 20;
sectp->ceilingshade = 20;
2020-05-07 12:55:04 +00:00
return;
}
2021-12-21 18:56:46 +00:00
if ((actor->spr.xrepeat | actor->spr.yrepeat) == 0)
2020-05-07 12:55:04 +00:00
{
actor->spr.xrepeat = actor->temp_data[0];
actor->spr.yrepeat = actor->temp_data[1];
2020-05-07 12:55:04 +00:00
}
else if ((krand() & 8) == 0)
{
actor->temp_data[0] = actor->spr.xrepeat;
actor->temp_data[1] = actor->spr.yrepeat;
actor->temp_data[2] = global_random & 4;
2021-12-21 18:56:46 +00:00
actor->spr.xrepeat = actor->spr.yrepeat = 0;
2020-05-07 12:55:04 +00:00
goto CLEAR_THE_BOLT;
}
2021-12-21 18:56:46 +00:00
actor->spr.picnum++;
2020-05-07 12:55:04 +00:00
int l = global_random & 7;
2021-12-21 18:56:46 +00:00
actor->spr.xrepeat = l + 8;
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if (l & 1) actor->spr.cstat ^= CSTAT_SPRITE_TRANSLUCENT;
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if (actor->spr.picnum == (BOLT1 + 1) && (krand() & 1) && sectp->floorpicnum == HURTRAIL)
2020-10-22 17:46:42 +00:00
S_PlayActorSound(SHORT_CIRCUIT, actor);
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if (actor->spr.picnum == BOLT1 + 4) actor->spr.picnum = BOLT1;
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if (actor->spr.picnum & 1)
2020-05-07 12:55:04 +00:00
{
sectp->floorshade = 0;
sectp->ceilingshade = 0;
2020-05-07 12:55:04 +00:00
}
else
{
sectp->floorshade = 20;
sectp->ceilingshade = 20;
2020-05-07 12:55:04 +00:00
}
}
//---------------------------------------------------------------------------
//
// this has been broken up into lots of smaller subfunctions
//
//---------------------------------------------------------------------------
void movestandables_r(void)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:51:42 +00:00
DukeStatIterator it(STAT_STANDABLE);
while (auto act = it.Next())
2020-05-07 12:55:04 +00:00
{
int picnum = act->spr.picnum;
2020-05-07 12:55:04 +00:00
if (!act->insector())
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:51:42 +00:00
deletesprite(act);
2020-05-07 12:55:04 +00:00
continue;
}
if (picnum >= CRANE && picnum <= CRANE +3)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:51:42 +00:00
movecrane(act, CRANE);
2020-05-07 12:55:04 +00:00
}
else if (picnum >= WATERFOUNTAIN && picnum <= WATERFOUNTAIN + 3)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:51:42 +00:00
movefountain(act, WATERFOUNTAIN);
2020-05-07 12:55:04 +00:00
}
else if (AFLAMABLE(picnum))
{
2022-01-26 23:41:33 +00:00
moveflammable(act, BLOODPOOL);
2020-05-07 12:55:04 +00:00
}
else if (picnum >= CRACK1 && picnum <= CRACK1 + 3)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:51:42 +00:00
movecrack(act);
2020-05-07 12:55:04 +00:00
}
else if (picnum == OOZFILTER || picnum == SEENINE || picnum == SEENINEDEAD || picnum == (SEENINEDEAD + 1))
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:51:42 +00:00
moveooz(act, SEENINE, SEENINEDEAD, OOZFILTER, EXPLOSION2);
2020-05-07 12:55:04 +00:00
}
else if (picnum == MASTERSWITCH)
{
2020-10-22 17:51:42 +00:00
movemasterswitch(act, SEENINE, OOZFILTER);
2020-05-07 12:55:04 +00:00
}
else if (picnum == TRASH)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:51:42 +00:00
movetrash(act);
2020-05-07 12:55:04 +00:00
}
else if (picnum >= BOLT1 && picnum <= BOLT1 + 3)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:51:42 +00:00
movebolt(act);
2020-05-07 12:55:04 +00:00
}
else if (picnum == WATERDRIP)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:51:42 +00:00
movewaterdrip(act, WATERDRIP);
2020-05-07 12:55:04 +00:00
}
else if (picnum == DOORSHOCK)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:51:42 +00:00
movedoorshock(act);
2020-05-07 12:55:04 +00:00
}
else if (picnum == TOUCHPLATE)
{
2020-10-22 17:51:42 +00:00
movetouchplate(act, TOUCHPLATE);
2020-05-07 12:55:04 +00:00
}
else if (picnum == CANWITHSOMETHING)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:51:42 +00:00
movecanwithsomething(act);
2020-05-07 12:55:04 +00:00
}
else if (isIn(picnum,
2020-05-07 12:55:04 +00:00
EXPLODINGBARREL,
WOODENHORSE,
HORSEONSIDE,
FIREBARREL,
FIREVASE,
NUKEBARREL,
NUKEBARRELDENTED,
NUKEBARRELLEAKED,
TOILETWATER,
RUBBERCAN,
STEAM,
CEILINGSTEAM))
2020-05-07 12:55:04 +00:00
{
int x;
2020-10-23 15:44:45 +00:00
int p = findplayer(act, &x);
2020-10-22 17:51:42 +00:00
execute(act, p, x);
2020-05-07 12:55:04 +00:00
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-22 17:59:38 +00:00
static void chickenarrow(DDukeActor* actor)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
actor->spr.hitag++;
if (actor->attackertype != BOSS2 && actor->spr.xrepeat >= 10 && actor->sector()->lotag != 2)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:59:38 +00:00
auto spawned = spawn(actor, SMALLSMOKE);
if (spawned) spawned->spr.pos.Z += (1 << 8);
if ((krand() & 15) == 2)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:59:38 +00:00
spawn(actor, MONEY);
}
}
DDukeActor* ts = actor->seek_actor;
if (!ts) return;
2020-10-22 17:59:38 +00:00
if (ts->spr.extra <= 0)
actor->seek_actor = nullptr;
2021-12-21 18:56:46 +00:00
if (actor->seek_actor && actor->spr.hitag > 5)
{
int ang, ang2, ang3;
ang = getangle(ts->spr.pos.X - actor->spr.pos.X, ts->spr.pos.Y - actor->spr.pos.Y);
2021-12-21 18:56:46 +00:00
ang2 = ang - actor->spr.ang;
ang3 = abs(ang2);
if (ang2 < 100)
{
if (ang3 > 1023)
2021-12-21 18:56:46 +00:00
actor->spr.ang += 51;
else
2021-12-21 18:56:46 +00:00
actor->spr.ang -= 51;
2020-05-07 12:55:04 +00:00
}
else if (ang2 > 100)
{
if (ang3 > 1023)
2021-12-21 18:56:46 +00:00
actor->spr.ang -= 51;
else
2021-12-21 18:56:46 +00:00
actor->spr.ang += 51;
}
else
2021-12-21 18:56:46 +00:00
actor->spr.ang = ang;
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if (actor->spr.hitag > 180)
if (actor->spr.zvel <= 0)
actor->spr.zvel += 200;
}
}
2020-05-07 12:55:04 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-22 18:07:05 +00:00
static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const vec3_t &oldpos)
{
if (isRRRA())
{
if (targ->spr.picnum == MINION
2021-12-21 18:56:46 +00:00
&& (proj->spr.picnum == RPG || proj->spr.picnum == RPG2)
&& targ->spr.pal == 19)
2020-05-07 12:55:04 +00:00
{
2020-10-22 18:07:05 +00:00
S_PlayActorSound(RPG_EXPLODE, proj);
spawn(proj, EXPLOSION2)->spr.pos = oldpos;
return true;
}
}
2021-12-21 18:56:46 +00:00
else if (proj->spr.picnum == FREEZEBLAST && targ->spr.pal == 1)
if (badguy(targ) || targ->spr.picnum == APLAYER)
{
2020-10-22 18:07:05 +00:00
auto star = spawn(proj, TRANSPORTERSTAR);
if (star)
{
star->spr.pal = 1;
star->spr.xrepeat = 32;
star->spr.yrepeat = 32;
}
2020-10-22 18:07:05 +00:00
deletesprite(proj);
return true;
}
2020-05-07 12:55:04 +00:00
fi.checkhitsprite(targ, proj);
2020-05-07 12:55:04 +00:00
if (targ->spr.picnum == APLAYER)
{
int p = targ->spr.yvel;
2020-10-22 18:07:05 +00:00
S_PlayActorSound(PISTOL_BODYHIT, targ);
2021-12-21 18:56:46 +00:00
if (proj->spr.picnum == SPIT)
{
if (isRRRA() && proj->GetOwner() && proj->GetOwner()->spr.picnum == MAMA)
2020-05-07 12:55:04 +00:00
{
2020-10-22 18:07:05 +00:00
guts_r(proj, RABBITJIBA, 2, myconnectindex);
guts_r(proj, RABBITJIBB, 2, myconnectindex);
guts_r(proj, RABBITJIBC, 2, myconnectindex);
2020-05-07 12:55:04 +00:00
}
ps[p].horizon.addadjustment(32);
ps[p].sync.actions |= SB_CENTERVIEW;
2020-05-07 12:55:04 +00:00
if (ps[p].loogcnt == 0)
2020-05-07 12:55:04 +00:00
{
2020-10-22 18:07:05 +00:00
if (!S_CheckActorSoundPlaying(ps[p].GetActor(), DUKE_LONGTERM_PAIN))
S_PlayActorSound(DUKE_LONGTERM_PAIN, ps[p].GetActor());
2020-05-07 12:55:04 +00:00
2020-10-22 18:07:05 +00:00
int j = 3 + (krand() & 3);
ps[p].numloogs = j;
ps[p].loogcnt = 24 * 4;
for (int x = 0; x < j; x++)
2020-05-07 12:55:04 +00:00
{
ps[p].loogie[x].X = krand() % 320;
ps[p].loogie[x].Y = krand() % 200;
2020-05-07 12:55:04 +00:00
}
}
}
}
return false;
}
2020-05-07 12:55:04 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-07 12:55:04 +00:00
static bool weaponhitwall(DDukeActor *proj, walltype* wal, const vec3_t& oldpos)
{
if (isRRRA() && proj->GetOwner() && proj->GetOwner()->spr.picnum == MAMA)
{
2020-10-22 18:07:05 +00:00
guts_r(proj, RABBITJIBA, 2, myconnectindex);
guts_r(proj, RABBITJIBB, 2, myconnectindex);
guts_r(proj, RABBITJIBC, 2, myconnectindex);
}
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if (proj->spr.picnum != RPG && (!isRRRA() || proj->spr.picnum != RPG2) && proj->spr.picnum != FREEZEBLAST && proj->spr.picnum != SPIT && proj->spr.picnum != SHRINKSPARK && (wal->overpicnum == MIRROR || wal->picnum == MIRROR))
{
2021-11-24 15:34:21 +00:00
int k = getangle(wal->delta());
2021-12-21 18:56:46 +00:00
proj->spr.ang = ((k << 1) - proj->spr.ang) & 2047;
2020-10-22 18:07:05 +00:00
proj->SetOwner(proj);
spawn(proj, TRANSPORTERSTAR);
return true;
}
else
{
SetActor(proj, oldpos);
fi.checkhitwall(proj, wal, proj->spr.pos.X, proj->spr.pos.Y, proj->spr.pos.Z, proj->spr.picnum);
2021-12-21 18:56:46 +00:00
if (!isRRRA() && proj->spr.picnum == FREEZEBLAST)
{
if (wal->overpicnum != MIRROR && wal->picnum != MIRROR)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
proj->spr.extra >>= 1;
if (proj->spr.xrepeat > 8)
proj->spr.xrepeat -= 2;
if (proj->spr.yrepeat > 8)
proj->spr.yrepeat -= 2;
proj->spr.yvel--;
2020-05-07 12:55:04 +00:00
}
2021-11-24 15:34:21 +00:00
int k = getangle(wal->delta());
2021-12-21 18:56:46 +00:00
proj->spr.ang = ((k << 1) - proj->spr.ang) & 2047;
return true;
}
2021-12-21 18:56:46 +00:00
if (proj->spr.picnum == SHRINKSPARK)
{
if (wal->picnum >= RRTILE3643 && wal->picnum < RRTILE3643 + 3)
{
2020-10-22 18:07:05 +00:00
deletesprite(proj);
}
2021-12-21 18:56:46 +00:00
if (proj->spr.extra <= 0)
2020-05-07 12:55:04 +00:00
{
proj->spr.pos.X += bcos(proj->spr.ang, -7);
proj->spr.pos.Y += bsin(proj->spr.ang, -7);
2020-10-22 18:07:05 +00:00
auto Owner = proj->GetOwner();
if (!isRRRA() || !Owner || (Owner->spr.picnum != CHEER && Owner->spr.picnum != CHEERSTAYPUT))
2020-05-07 12:55:04 +00:00
{
2020-10-22 18:07:05 +00:00
auto j = spawn(proj, CIRCLESTUCK);
if (j)
{
j->spr.xrepeat = 8;
j->spr.yrepeat = 8;
j->spr.cstat = CSTAT_SPRITE_ALIGNMENT_WALL;
j->spr.ang = (j->spr.ang + 512) & 2047;
2021-12-21 18:56:46 +00:00
j->spr.clipdist = MulScale(proj->spr.xrepeat, tileWidth(proj->spr.picnum), 7);
}
2020-05-07 12:55:04 +00:00
}
2020-10-22 18:07:05 +00:00
deletesprite(proj);
return true;
2020-05-07 12:55:04 +00:00
}
if (wal->overpicnum != MIRROR && wal->picnum != MIRROR)
{
2021-12-21 18:56:46 +00:00
proj->spr.extra -= 20;
proj->spr.yvel--;
}
2021-11-24 15:34:21 +00:00
int k = getangle(wal->delta());
2021-12-21 18:56:46 +00:00
proj->spr.ang = ((k << 1) - proj->spr.ang) & 2047;
return true;
}
}
return false;
}
2020-05-07 12:55:04 +00:00
2020-10-22 18:07:05 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-22 18:07:05 +00:00
bool weaponhitsector(DDukeActor *proj, const vec3_t& oldpos)
{
SetActor(proj, oldpos);
if (isRRRA() && proj->GetOwner() && proj->GetOwner()->spr.picnum == MAMA)
{
2020-10-22 18:07:05 +00:00
guts_r(proj, RABBITJIBA, 2, myconnectindex);
guts_r(proj, RABBITJIBB, 2, myconnectindex);
guts_r(proj, RABBITJIBC, 2, myconnectindex);
}
2021-12-21 18:56:46 +00:00
if (proj->spr.zvel < 0)
{
if (proj->sector()->ceilingstat & CSTAT_SECTOR_SKY)
if (proj->sector()->ceilingpal == 0)
2020-05-07 12:55:04 +00:00
{
2020-10-22 18:07:05 +00:00
deletesprite(proj);
return true;
}
2020-05-07 12:55:04 +00:00
fi.checkhitceiling(proj->sector());
}
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if (!isRRRA() && proj->spr.picnum == FREEZEBLAST)
{
2020-10-22 18:07:05 +00:00
bounce(proj);
ssp(proj, CLIPMASK1);
2021-12-21 18:56:46 +00:00
proj->spr.extra >>= 1;
if (proj->spr.xrepeat > 8)
proj->spr.xrepeat -= 2;
if (proj->spr.yrepeat > 8)
proj->spr.yrepeat -= 2;
proj->spr.yvel--;
return true;
}
return false;
}
2020-05-07 12:55:04 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-07 12:55:04 +00:00
2020-10-22 18:21:21 +00:00
static void weaponcommon_r(DDukeActor *proj)
{
2020-10-22 18:21:21 +00:00
int k, p;
int ll;
2020-05-07 12:55:04 +00:00
p = -1;
if (proj->spr.picnum == RPG && proj->sector()->lotag == 2)
{
2021-12-21 18:56:46 +00:00
k = proj->spr.xvel >> 1;
ll = proj->spr.zvel >> 1;
}
else if (isRRRA() && proj->spr.picnum == RPG2 && proj->sector()->lotag == 2)
{
2021-12-21 18:56:46 +00:00
k = proj->spr.xvel >> 1;
ll = proj->spr.zvel >> 1;
}
else
{
2021-12-21 18:56:46 +00:00
k = proj->spr.xvel;
ll = proj->spr.zvel;
}
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
auto oldpos = proj->spr.pos;
2020-05-07 12:55:04 +00:00
2020-10-22 18:21:21 +00:00
getglobalz(proj);
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
switch (proj->spr.picnum)
{
case RPG:
if (proj->attackertype != BOSS2 && proj->spr.xrepeat >= 10 && proj->sector()->lotag != 2)
{
spawn(proj, SMALLSMOKE)->spr.pos.Z += (1 << 8);
}
break;
case RPG2:
if (!isRRRA()) break;
2020-10-22 18:21:21 +00:00
chickenarrow(proj);
break;
2020-05-07 12:55:04 +00:00
case RRTILE1790:
if (!isRRRA()) break;
2021-12-21 18:56:46 +00:00
if (proj->spr.extra)
{
2021-12-21 18:56:46 +00:00
proj->spr.zvel = -(proj->spr.extra * 250);
proj->spr.extra--;
}
else
2020-10-22 18:21:21 +00:00
makeitfall(proj);
if (proj->spr.xrepeat >= 10 && proj->sector()->lotag != 2)
{
spawn(proj, SMALLSMOKE)->spr.pos.Z += (1 << 8);
}
break;
}
2020-05-07 12:55:04 +00:00
Collision coll;
movesprite_ex(proj,
2021-12-21 18:56:46 +00:00
MulScale(k, bcos(proj->spr.ang), 14),
MulScale(k, bsin(proj->spr.ang), 14), ll, CLIPMASK1, coll);
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if ((proj->spr.picnum == RPG || (isRRRA() && isIn(proj->spr.picnum, RPG2, RRTILE1790))) && proj->temp_actor != nullptr)
if (FindDistance2D(proj->spr.pos.vec2 - proj->temp_actor->spr.pos.vec2) < 256)
coll.setSprite(proj->temp_actor);
2020-05-07 12:55:04 +00:00
if (!proj->insector()) // || (isRR() && proj->sector()->filler == 800))
{
2020-10-22 18:21:21 +00:00
deletesprite(proj);
return;
}
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if (coll.type != kHitSprite && proj->spr.picnum != FREEZEBLAST)
{
if (proj->spr.pos.Z < proj->ceilingz)
{
coll.setSector(proj->sector());
2021-12-21 18:56:46 +00:00
proj->spr.zvel = -1;
}
else
if (proj->spr.pos.Z > proj->floorz)
{
coll.setSector(proj->sector());
if (proj->sector()->lotag != 1)
2021-12-21 18:56:46 +00:00
proj->spr.zvel = 1;
}
}
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if (proj->spr.picnum == FIRELASER)
{
for (k = -3; k < 2; k++)
{
auto x = EGS(proj->sector(),
proj->spr.pos.X + MulScale(k, bcos(proj->spr.ang), 9),
proj->spr.pos.Y + MulScale(k, bsin(proj->spr.ang), 9),
proj->spr.pos.Z + ((k * Sgn(proj->spr.zvel)) * abs(proj->spr.zvel / 24)), FIRELASER, -40 + (k << 2),
2021-12-21 18:56:46 +00:00
proj->spr.xrepeat, proj->spr.yrepeat, 0, 0, 0, proj->GetOwner(), 5);
if (x)
{
x->spr.cstat = CSTAT_SPRITE_YCENTER;
2021-12-21 18:56:46 +00:00
x->spr.pal = proj->spr.pal;
}
}
}
2021-12-21 18:56:46 +00:00
else if (proj->spr.picnum == SPIT) if (proj->spr.zvel < 6144)
proj->spr.zvel += gs.gravity - 112;
if (coll.type != 0)
{
if (coll.type == kHitSprite)
{
if (weaponhitsprite(proj, coll.actor(), oldpos)) return;
}
else if (coll.type == kHitWall)
{
if (weaponhitwall(proj, coll.hitWall, oldpos)) return;
}
else if (coll.type == kHitSector)
{
2020-10-22 18:21:21 +00:00
if (weaponhitsector(proj, oldpos)) return;
}
2020-05-07 12:55:04 +00:00
2021-12-21 18:56:46 +00:00
if (proj->spr.picnum != SPIT)
{
2021-12-21 18:56:46 +00:00
if (proj->spr.picnum == RPG) rpgexplode(proj, coll.type, oldpos, EXPLOSION2, -1, -1, RPG_EXPLODE);
else if (isRRRA() && proj->spr.picnum == RPG2) rpgexplode(proj, coll.type, oldpos, EXPLOSION2, -1, 150, 247);
else if (isRRRA() && proj->spr.picnum == RRTILE1790) rpgexplode(proj, coll.type, oldpos, EXPLOSION2, -1, 160, RPG_EXPLODE);
else if (proj->spr.picnum != FREEZEBLAST && proj->spr.picnum != FIRELASER && proj->spr.picnum != SHRINKSPARK)
{
auto spawned = spawn(proj, 1441);
if (spawned)
{
spawned->spr.xrepeat = spawned->spr.yrepeat = proj->spr.xrepeat >> 1;
if (coll.type == kHitSector)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:56:46 +00:00
if (proj->spr.zvel < 0)
{
spawned->spr.cstat |= CSTAT_SPRITE_YFLIP;
spawned->spr.pos.Z += (72 << 8);
}
2020-05-07 12:55:04 +00:00
}
}
}
}
2020-10-22 18:21:21 +00:00
deletesprite(proj);
return;
}
if ((proj->spr.picnum == RPG || (isRRRA() && proj->spr.picnum == RPG2)) && proj->sector()->lotag == 2 && proj->spr.xrepeat >= 10 && rnd(184))
2020-10-22 18:21:21 +00:00
spawn(proj, WATERBUBBLE);
}
2020-05-07 12:55:04 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-07 12:55:04 +00:00
void moveweapons_r(void)
{
2020-10-22 18:21:21 +00:00
DukeStatIterator it(STAT_PROJECTILE);
while (auto proj = it.Next())
{
if (!proj->insector())
{
2020-10-22 18:21:21 +00:00
deletesprite(proj);
continue;
}
2020-05-07 12:55:04 +00:00
switch (proj->spr.picnum)
{
case RADIUSEXPLOSION:
2020-10-22 18:21:21 +00:00
deletesprite(proj);
continue;
case TONGUE:
2020-10-22 18:21:21 +00:00
movetongue(proj, TONGUE, INNERJAW);
continue;
2020-05-07 12:55:04 +00:00
case FREEZEBLAST:
if (proj->spr.yvel < 1 || proj->spr.extra < 2 || (proj->spr.xvel | proj->spr.zvel) == 0)
{
2020-10-22 18:21:21 +00:00
auto star = spawn(proj, TRANSPORTERSTAR);
if (star)
{
star->spr.pal = 1;
star->spr.xrepeat = 32;
star->spr.yrepeat = 32;
}
2020-10-22 18:21:21 +00:00
deletesprite(proj);
continue;
2020-05-07 12:55:04 +00:00
}
[[fallthrough]];
case RPG2:
case RRTILE1790:
if (!isRRRA()) continue;
[[fallthrough]];
case SHRINKSPARK:
case RPG:
case FIRELASER:
case SPIT:
case COOLEXPLOSION1:
case OWHIP:
case UWHIP:
2020-10-22 18:21:21 +00:00
weaponcommon_r(proj);
2020-05-07 12:55:04 +00:00
continue;
case SHOTSPARK1:
{
int x;
2020-10-23 15:44:45 +00:00
int p = findplayer(proj, &x);
2020-10-22 18:21:21 +00:00
execute(proj, p, x);
continue;
2020-05-07 12:55:04 +00:00
}
}
2020-05-07 12:55:04 +00:00
}
}
2020-05-07 22:03:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void movetransports_r(void)
{
uint8_t warpdir = 0, warpspriteto;
int k, p, sectlotag;
int ll2 = 0, ll, onfloorz;
2020-10-22 19:42:02 +00:00
Collision coll;
2020-05-07 22:03:51 +00:00
//Transporters
2020-05-07 22:03:51 +00:00
2020-10-22 19:42:02 +00:00
DukeStatIterator iti(STAT_TRANSPORT);
while (auto act = iti.Next())
2020-05-07 22:03:51 +00:00
{
auto sectp = act->sector();
sectlotag = sectp->lotag;
2020-05-07 22:03:51 +00:00
2020-10-22 19:42:02 +00:00
auto Owner = act->GetOwner();
if (Owner == act || Owner == nullptr)
2020-05-07 22:03:51 +00:00
{
continue;
}
2020-11-01 13:56:23 +00:00
onfloorz = act->temp_data[4];
2020-05-07 22:03:51 +00:00
2020-11-01 13:56:23 +00:00
if (act->temp_data[0] > 0) act->temp_data[0]--;
2020-05-07 22:03:51 +00:00
DukeSectIterator itj(act->sector());
2020-10-22 19:42:02 +00:00
while (auto act2 = itj.Next())
2020-05-07 22:03:51 +00:00
{
2021-12-21 19:02:06 +00:00
switch (act2->spr.statnum)
2020-05-07 22:03:51 +00:00
{
case STAT_PLAYER: // Player
2020-05-07 22:03:51 +00:00
2020-10-22 19:42:02 +00:00
if (act2->GetOwner())
2020-05-07 22:03:51 +00:00
{
2021-12-21 19:02:06 +00:00
p = act2->spr.yvel;
2020-05-07 22:03:51 +00:00
ps[p].on_warping_sector = 1;
if (ps[p].transporter_hold == 0 && ps[p].jumping_counter == 0)
{
if (ps[p].on_ground && sectlotag == 0 && onfloorz && ps[p].jetpack_on == 0)
{
2020-10-22 19:42:02 +00:00
spawn(act, TRANSPORTERBEAM);
S_PlayActorSound(TELEPORTER, act);
2020-05-07 22:03:51 +00:00
for (k = connecthead; k >= 0; k = connectpoint2[k])
if (ps[k].cursector == Owner->sector())
2020-05-07 22:03:51 +00:00
{
ps[k].frag_ps = p;
ps[k].GetActor()->spr.extra = 0;
2020-05-07 22:03:51 +00:00
}
ps[p].angle.ang = buildang(Owner->spr.ang);
2020-05-07 22:03:51 +00:00
2020-10-22 19:42:02 +00:00
if (Owner->GetOwner() != Owner)
2020-05-07 22:03:51 +00:00
{
2020-11-01 13:56:23 +00:00
act->temp_data[0] = 13;
2020-10-22 19:42:02 +00:00
Owner->temp_data[0] = 13;
2020-05-07 22:03:51 +00:00
ps[p].transporter_hold = 13;
}
ps[p].bobpos.X = ps[p].opos.X = ps[p].pos.X = Owner->spr.pos.X;
ps[p].bobpos.Y = ps[p].opos.Y = ps[p].pos.Y = Owner->spr.pos.Y;
ps[p].opos.Z = ps[p].pos.Z = Owner->spr.pos.Z - (gs.playerheight - (4 << 8));
2020-05-07 22:03:51 +00:00
ChangeActorSect(act2, Owner->sector());
ps[p].setCursector(act2->sector());
2020-05-07 22:03:51 +00:00
2020-10-22 19:42:02 +00:00
auto beam = spawn(Owner, TRANSPORTERBEAM);
if (beam) S_PlayActorSound(TELEPORTER, beam);
2020-05-07 22:03:51 +00:00
break;
}
}
else break;
if (onfloorz == 0 && abs(act->spr.pos.Z - ps[p].pos.Z) < 6144)
if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && PlayerInput(p, SB_JUMP)) ||
(ps[p].jetpack_on && PlayerInput(p, SB_CROUCH)))
2020-05-07 22:03:51 +00:00
{
ps[p].opos.X = ps[p].pos.X += Owner->spr.pos.X - act->spr.pos.X;
ps[p].opos.Y = ps[p].pos.Y += Owner->spr.pos.Y - act->spr.pos.Y;
2020-05-07 22:03:51 +00:00
if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11))
ps[p].pos.Z = Owner->spr.pos.Z - 6144;
else ps[p].pos.Z = Owner->spr.pos.Z + 6144;
ps[p].opos.Z = ps[p].pos.Z;
2020-05-07 22:03:51 +00:00
ChangeActorSect(act2, Owner->sector());
2021-11-21 07:45:07 +00:00
ps[p].setCursector(Owner->sector());
2020-05-07 22:03:51 +00:00
break;
}
k = 0;
if (isRRRA())
{
2021-12-22 09:41:47 +00:00
if (onfloorz && sectlotag == 160 && ps[p].pos.Z > (sectp->floorz - (48 << 8)))
2020-05-07 22:03:51 +00:00
{
k = 2;
ps[p].opos.Z = ps[p].pos.Z =
2021-11-20 23:33:17 +00:00
Owner->sector()->ceilingz + (7 << 8);
2020-05-07 22:03:51 +00:00
}
2021-12-22 09:41:47 +00:00
if (onfloorz && sectlotag == 161 && ps[p].pos.Z < (sectp->ceilingz + (6 << 8)))
2020-05-07 22:03:51 +00:00
{
k = 2;
if (ps[p].GetActor()->spr.extra <= 0) break;
ps[p].opos.Z = ps[p].pos.Z =
2021-11-20 23:33:17 +00:00
Owner->sector()->floorz - (49 << 8);
2020-05-07 22:03:51 +00:00
}
}
2021-12-22 09:41:47 +00:00
if ((onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].pos.Z > (sectp->floorz - (6 << 8))) ||
2020-05-07 22:03:51 +00:00
(onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].OnMotorcycle))
{
if (ps[p].OnBoat) break;
k = 1;
if (screenpeek == p)
{
FX_StopAllSounds();
}
2020-10-22 19:42:02 +00:00
S_PlayActorSound(DUKE_UNDERWATER, ps[p].GetActor());
ps[p].opos.Z = ps[p].pos.Z =
2021-11-20 23:33:17 +00:00
Owner->sector()->ceilingz + (7 << 8);
2020-05-07 22:03:51 +00:00
if (ps[p].OnMotorcycle)
ps[p].moto_underwater = 1;
}
2021-12-22 09:41:47 +00:00
if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].pos.Z < (sectp->ceilingz + (6 << 8)))
2020-05-07 22:03:51 +00:00
{
k = 1;
if (ps[p].GetActor()->spr.extra <= 0) break;
2020-05-07 22:03:51 +00:00
if (screenpeek == p)
{
FX_StopAllSounds();
}
2020-10-22 19:42:02 +00:00
S_PlayActorSound(DUKE_GASP, ps[p].GetActor());
2020-05-07 22:03:51 +00:00
ps[p].opos.Z = ps[p].pos.Z =
2021-11-20 23:33:17 +00:00
Owner->sector()->floorz - (7 << 8);
2020-05-07 22:03:51 +00:00
}
if (k == 1)
{
ps[p].opos.X = ps[p].pos.X += Owner->spr.pos.X - act->spr.pos.X;
ps[p].opos.Y = ps[p].pos.Y += Owner->spr.pos.Y - act->spr.pos.Y;
2020-05-07 22:03:51 +00:00
2020-10-22 19:42:02 +00:00
if (Owner->GetOwner() != Owner)
2020-05-07 22:03:51 +00:00
ps[p].transporter_hold = -2;
2021-11-21 07:45:07 +00:00
ps[p].setCursector(Owner->sector());
2020-05-07 22:03:51 +00:00
ChangeActorSect(act2, Owner->sector());
2020-05-07 22:03:51 +00:00
if ((krand() & 255) < 32)
2020-10-22 19:42:02 +00:00
spawn(ps[p].GetActor(), WATERSPLASH2);
2020-05-07 22:03:51 +00:00
}
else if (isRRRA() && k == 2)
{
ps[p].opos.X = ps[p].pos.X += Owner->spr.pos.X - act->spr.pos.X;
ps[p].opos.Y = ps[p].pos.Y += Owner->spr.pos.Y - act->spr.pos.Y;
2020-05-07 22:03:51 +00:00
2020-10-22 19:42:02 +00:00
if (Owner->GetOwner() != Owner)
2020-05-07 22:03:51 +00:00
ps[p].transporter_hold = -2;
2021-11-21 07:45:07 +00:00
ps[p].setCursector(Owner->sector());
2020-05-07 22:03:51 +00:00
ChangeActorSect(act2, Owner->sector());
2020-05-07 22:03:51 +00:00
}
}
break;
case STAT_ACTOR:
2021-12-21 19:02:06 +00:00
if (act->spr.picnum == SHARK ||
(isRRRA() && (act->spr.picnum == CHEERBOAT || act->spr.picnum == HULKBOAT || act->spr.picnum == MINIONBOAT || act->spr.picnum == UFO1_RRRA)) ||
(!isRRRA() && (act->spr.picnum == UFO1_RR || act->spr.picnum == UFO2 || act->spr.picnum == UFO3 || act->spr.picnum == UFO4 || act->spr.picnum == UFO5))) continue;
[[fallthrough]];
2020-05-07 22:03:51 +00:00
case STAT_PROJECTILE:
case STAT_MISC:
case STAT_DUMMYPLAYER:
2021-12-21 19:02:06 +00:00
ll = abs(act2->spr.zvel);
2020-05-07 22:03:51 +00:00
if (isRRRA())
{
2021-12-21 19:02:06 +00:00
if (act2->spr.zvel >= 0)
2020-05-07 22:03:51 +00:00
warpdir = 2;
else
warpdir = 1;
}
{
warpspriteto = 0;
if (ll && sectlotag == ST_2_UNDERWATER && act2->spr.pos.Z < (sectp->ceilingz + ll))
2020-05-07 22:03:51 +00:00
warpspriteto = 1;
if (ll && sectlotag == ST_1_ABOVE_WATER && act2->spr.pos.Z > (sectp->floorz - ll))
2021-12-21 19:02:06 +00:00
if (!isRRRA() || (act2->spr.picnum != CHEERBOAT && act2->spr.picnum != HULKBOAT && act2->spr.picnum != MINIONBOAT))
2020-05-07 22:03:51 +00:00
warpspriteto = 1;
if (isRRRA())
{
if (ll && sectlotag == 161 && act2->spr.pos.Z < (sectp->ceilingz + ll) && warpdir == 1)
2020-05-07 22:03:51 +00:00
{
warpspriteto = 1;
ll2 = ll - abs(act2->spr.pos.Z - sectp->ceilingz);
2020-05-07 22:03:51 +00:00
}
else if (sectlotag == 161 && act2->spr.pos.Z < (sectp->ceilingz + 1000) && warpdir == 1)
2020-05-07 22:03:51 +00:00
{
warpspriteto = 1;
ll2 = 1;
}
if (ll && sectlotag == 160 && act2->spr.pos.Z > (sectp->floorz - ll) && warpdir == 2)
2020-05-07 22:03:51 +00:00
{
warpspriteto = 1;
ll2 = ll - abs(sectp->floorz - act2->spr.pos.Z);
2020-05-07 22:03:51 +00:00
}
else if (sectlotag == 160 && act2->spr.pos.Z > (sectp->floorz - 1000) && warpdir == 2)
2020-05-07 22:03:51 +00:00
{
warpspriteto = 1;
ll2 = 1;
}
}
if (sectlotag == 0 && (onfloorz || abs(act2->spr.pos.Z - act->spr.pos.Z) < 4096))
2020-05-07 22:03:51 +00:00
{
2021-12-21 19:02:06 +00:00
if (Owner->GetOwner() != Owner && onfloorz && act->temp_data[0] > 0 && act2->spr.statnum != 5)
2020-05-07 22:03:51 +00:00
{
2020-11-01 13:56:23 +00:00
act->temp_data[0]++;
2020-05-08 22:34:48 +00:00
continue;
2020-05-07 22:03:51 +00:00
}
warpspriteto = 1;
}
if (warpspriteto)
2020-05-07 22:03:51 +00:00
{
if (actorflag(act2, SFLAG_NOTELEPORT)) continue;
switch (act2->spr.picnum)
2020-05-07 22:03:51 +00:00
{
case PLAYERONWATER:
if (sectlotag == ST_2_UNDERWATER)
{
act2->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
break;
}
[[fallthrough]];
default:
if (act2->spr.statnum == 5 && !(sectlotag == ST_1_ABOVE_WATER || sectlotag == ST_2_UNDERWATER || (isRRRA() && (sectlotag == 160 || sectlotag == 161))))
break;
[[fallthrough]];
2020-05-07 22:03:51 +00:00
case WATERBUBBLE:
if (rnd(192) && act2->spr.picnum == WATERBUBBLE)
break;
2020-05-07 22:03:51 +00:00
if (sectlotag > 0)
2020-05-07 22:03:51 +00:00
{
auto spawned = spawn(act2, WATERSPLASH2);
if (spawned && sectlotag == 1 && act2->spr.statnum == 4)
{
spawned->spr.xvel = act2->spr.xvel >> 1;
spawned->spr.ang = act2->spr.ang;
ssp(spawned, CLIPMASK0);
}
2020-05-07 22:03:51 +00:00
}
switch (sectlotag)
2020-05-07 22:03:51 +00:00
{
case ST_0_NO_EFFECT:
if (onfloorz)
2020-05-07 22:03:51 +00:00
{
if (checkcursectnums(act->sector()) == -1 && checkcursectnums(Owner->sector()) == -1)
{
act2->spr.pos.X += (Owner->spr.pos.X - act->spr.pos.X);
act2->spr.pos.Y += (Owner->spr.pos.Y - act->spr.pos.Y);
act2->spr.pos.Z -= act->spr.pos.Z - Owner->sector()->floorz;
act2->spr.ang = Owner->spr.ang;
2020-05-07 22:03:51 +00:00
act2->backupang();
2020-05-07 22:03:51 +00:00
auto beam = spawn(act, TRANSPORTERBEAM);
if (beam) S_PlayActorSound(TELEPORTER, beam);
2020-05-07 22:03:51 +00:00
beam = spawn(Owner, TRANSPORTERBEAM);
if (beam) S_PlayActorSound(TELEPORTER, beam);
2020-05-07 22:03:51 +00:00
if (Owner->GetOwner() != Owner)
{
act->temp_data[0] = 13;
Owner->temp_data[0] = 13;
}
ChangeActorSect(act2, Owner->sector());
2020-05-07 22:03:51 +00:00
}
}
else
{
act2->spr.pos.X += (Owner->spr.pos.X - act->spr.pos.X);
act2->spr.pos.Y += (Owner->spr.pos.Y - act->spr.pos.Y);
act2->spr.pos.Z = Owner->spr.pos.Z + 4096;
act2->backupz();
2020-05-07 22:03:51 +00:00
ChangeActorSect(act2, Owner->sector());
2020-05-07 22:03:51 +00:00
}
break;
case ST_1_ABOVE_WATER:
act2->spr.pos.X += (Owner->spr.pos.X - act->spr.pos.X);
act2->spr.pos.Y += (Owner->spr.pos.Y - act->spr.pos.Y);
act2->spr.pos.Z = Owner->sector()->ceilingz + ll;
2020-05-07 22:03:51 +00:00
act2->backupz();
2020-05-07 22:03:51 +00:00
ChangeActorSect(act2, Owner->sector());
2020-05-07 22:03:51 +00:00
break;
case ST_2_UNDERWATER:
act2->spr.pos.X += (Owner->spr.pos.X - act->spr.pos.X);
act2->spr.pos.Y += (Owner->spr.pos.Y - act->spr.pos.Y);
act2->spr.pos.Z = Owner->sector()->floorz - ll;
2020-05-07 22:03:51 +00:00
act2->backupz();
2020-05-07 22:03:51 +00:00
ChangeActorSect(act2, Owner->sector());
2020-05-07 22:03:51 +00:00
break;
2020-05-07 22:03:51 +00:00
case 160:
if (!isRRRA()) break;
act2->spr.pos.X += (Owner->spr.pos.X - act->spr.pos.X);
act2->spr.pos.Y += (Owner->spr.pos.Y - act->spr.pos.Y);
act2->spr.pos.Z = Owner->sector()->ceilingz + ll2;
2020-05-07 22:03:51 +00:00
act2->backupz();
2020-05-07 22:03:51 +00:00
ChangeActorSect(act2, Owner->sector());
2020-05-07 22:03:51 +00:00
movesprite_ex(act2, MulScale(act2->spr.xvel, bcos(act2->spr.ang), 14),
MulScale(act2->spr.xvel, bsin(act2->spr.ang), 14), 0, CLIPMASK1, coll);
2020-05-07 22:03:51 +00:00
break;
case 161:
if (!isRRRA()) break;
act2->spr.pos.X += (Owner->spr.pos.X - act->spr.pos.X);
act2->spr.pos.Y += (Owner->spr.pos.Y - act->spr.pos.Y);
act2->spr.pos.Z = Owner->sector()->floorz - ll2;
2020-05-07 22:03:51 +00:00
act2->backupz();
2020-05-07 22:03:51 +00:00
ChangeActorSect(act2, Owner->sector());
2020-05-07 22:03:51 +00:00
movesprite_ex(act2, MulScale(act2->spr.xvel, bcos(act2->spr.ang), 14),
MulScale(act2->spr.xvel, bsin(act2->spr.ang), 14), 0, CLIPMASK1, coll);
2020-05-07 22:03:51 +00:00
break;
}
2020-05-07 22:03:51 +00:00
break;
}
}
}
break;
}
}
}
}
2020-05-08 22:34:48 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void rrra_specialstats()
{
2020-10-22 20:21:40 +00:00
Collision coll;
DukeStatIterator it(117);
while (auto act = it.Next())
2020-05-08 22:34:48 +00:00
{
if (act->spr.hitag > 2)
act->spr.hitag = 0;
if ((act->spr.picnum == RRTILE8488 || act->spr.picnum == RRTILE8490) && act->spr.hitag != 2)
2020-05-08 22:34:48 +00:00
{
act->spr.hitag = 2;
act->spr.extra = -100;
2020-05-08 22:34:48 +00:00
}
if (act->spr.hitag == 0)
2020-05-08 22:34:48 +00:00
{
act->spr.extra++;
if (act->spr.extra >= 30)
act->spr.hitag = 1;
2020-05-08 22:34:48 +00:00
}
else if (act->spr.hitag == 1)
2020-05-08 22:34:48 +00:00
{
act->spr.extra--;
if (act->spr.extra <= -30)
act->spr.hitag = 0;
2020-05-08 22:34:48 +00:00
}
else if (act->spr.hitag == 2)
2020-05-08 22:34:48 +00:00
{
act->spr.extra--;
if (act->spr.extra <= -104)
2020-05-08 22:34:48 +00:00
{
spawn(act, act->spr.lotag);
2020-10-22 20:21:40 +00:00
deletesprite(act);
2020-05-08 22:34:48 +00:00
}
}
movesprite_ex(act, 0, 0, act->spr.extra * 2, CLIPMASK0, coll);
2020-05-08 22:34:48 +00:00
}
it.Reset(118);
2020-10-22 20:21:40 +00:00
while (auto act = it.Next())
2020-05-08 22:34:48 +00:00
{
if (act->spr.hitag > 1)
act->spr.hitag = 0;
if (act->spr.hitag == 0)
2020-05-08 22:34:48 +00:00
{
act->spr.extra++;
if (act->spr.extra >= 20)
act->spr.hitag = 1;
2020-05-08 22:34:48 +00:00
}
else if (act->spr.hitag == 1)
2020-05-08 22:34:48 +00:00
{
act->spr.extra--;
if (act->spr.extra <= -20)
act->spr.hitag = 0;
2020-05-08 22:34:48 +00:00
}
movesprite_ex(act, 0, 0, act->spr.extra, CLIPMASK0, coll);
2020-05-08 22:34:48 +00:00
}
2020-05-14 07:07:07 +00:00
if (ps[screenpeek].MamaEnd > 0)
2020-05-08 22:34:48 +00:00
{
2020-05-14 07:07:07 +00:00
ps[screenpeek].MamaEnd--;
if (ps[screenpeek].MamaEnd == 0)
2020-05-08 22:34:48 +00:00
{
CompleteLevel(nullptr);
2020-05-08 22:34:48 +00:00
}
}
if (enemysizecheat > 0)
{
DukeSpriteIterator itr;
while (auto act = itr.Next())
2020-05-08 22:34:48 +00:00
{
switch (act->spr.picnum)
2020-05-08 22:34:48 +00:00
{
//case 4049:
//case 4050:
case BILLYCOCK:
case BILLYRAY:
case BILLYRAYSTAYPUT:
case BRAYSNIPER:
case DOGRUN:
case LTH:
case HULKJUMP:
case HULK:
case HULKSTAYPUT:
case HEN:
case DRONE:
case PIG:
case MINION:
case MINIONSTAYPUT:
case UFO1_RRRA:
case UFO2:
case UFO3:
case UFO4:
case UFO5:
case COOT:
case COOTSTAYPUT:
case VIXEN:
case BIKERB:
case BIKERBV2:
case BIKER:
case MAKEOUT:
case CHEERB:
case CHEER:
case CHEERSTAYPUT:
case COOTPLAY:
case BILLYPLAY:
case MINIONBOAT:
case HULKBOAT:
case CHEERBOAT:
case RABBIT:
case MAMA:
if (enemysizecheat == 3)
{
act->spr.xrepeat <<= 1;
act->spr.yrepeat <<= 1;
act->spr.clipdist = MulScale(act->spr.xrepeat, tileWidth(act->spr.picnum), 7);
2020-05-08 22:34:48 +00:00
}
else if (enemysizecheat == 2)
{
act->spr.xrepeat >>= 1;
act->spr.yrepeat >>= 1;
act->spr.clipdist = MulScale(act->spr.xrepeat, tileHeight(act->spr.picnum), 7);
2020-05-08 22:34:48 +00:00
}
break;
}
2020-05-08 22:34:48 +00:00
}
enemysizecheat = 0;
}
it.Reset(121);
2020-10-22 20:21:40 +00:00
while (auto act = it.Next())
2020-05-08 22:34:48 +00:00
{
act->spr.extra++;
if (act->spr.extra < 100)
2020-05-08 22:34:48 +00:00
{
if (act->spr.extra == 90)
2020-05-08 22:34:48 +00:00
{
act->spr.picnum--;
if (act->spr.picnum < PIG + 7)
act->spr.picnum = PIG + 7;
act->spr.extra = 1;
2020-05-08 22:34:48 +00:00
}
2020-10-22 20:21:40 +00:00
movesprite_ex(act, 0, 0, -300, CLIPMASK0, coll);
if (act->sector()->ceilingz + (4 << 8) > act->spr.pos.Z)
2020-05-08 22:34:48 +00:00
{
act->spr.picnum = 0;
act->spr.extra = 100;
2020-05-08 22:34:48 +00:00
}
}
else if (act->spr.extra == 200)
2020-05-08 22:34:48 +00:00
{
SetActor(act, { act->spr.pos.X, act->spr.pos.Y, act->sector()->floorz - 10 });
act->spr.extra = 1;
act->spr.picnum = PIG + 11;
2020-10-22 20:21:40 +00:00
spawn(act, TRANSPORTERSTAR);
2020-05-08 22:34:48 +00:00
}
}
it.Reset(119);
2020-10-22 20:21:40 +00:00
while (auto act = it.Next())
2020-05-08 22:34:48 +00:00
{
if (act->spr.hitag > 0)
2020-05-08 22:34:48 +00:00
{
if (act->spr.extra == 0)
2020-05-08 22:34:48 +00:00
{
act->spr.hitag--;
act->spr.extra = 150;
2020-10-22 20:21:40 +00:00
spawn(act, RABBIT);
2020-05-08 22:34:48 +00:00
}
else
act->spr.extra--;
2020-05-08 22:34:48 +00:00
}
}
it.Reset(116);
2020-10-22 20:21:40 +00:00
while (auto act = it.Next())
2020-05-08 22:34:48 +00:00
{
if (act->spr.extra)
2020-05-08 22:34:48 +00:00
{
if (act->spr.extra == act->spr.lotag)
S_PlaySound(183);
act->spr.extra--;
2020-10-22 20:21:40 +00:00
int j = movesprite_ex(act,
MulScale(act->spr.hitag, bcos(act->spr.ang), 14),
MulScale(act->spr.hitag, bsin(act->spr.ang), 14),
act->spr.hitag << 1, CLIPMASK0, coll);
2020-05-08 22:34:48 +00:00
if (j > 0)
{
2020-10-22 20:21:40 +00:00
S_PlayActorSound(PIPEBOMB_EXPLODE, act);
deletesprite(act);
2020-05-08 22:34:48 +00:00
}
if (act->spr.extra == 0)
2020-05-08 22:34:48 +00:00
{
S_PlaySound(215);
2020-10-22 20:21:40 +00:00
deletesprite(act);
2020-05-08 22:34:48 +00:00
earthquaketime = 32;
SetPlayerPal(&ps[myconnectindex], PalEntry(32, 32, 32, 48));
}
}
}
it.Reset(115);
2020-10-22 20:21:40 +00:00
while (auto act = it.Next())
2020-05-08 22:34:48 +00:00
{
if (act->spr.extra)
2020-05-08 22:34:48 +00:00
{
if (act->spr.picnum != RRTILE8162)
act->spr.picnum = RRTILE8162;
act->spr.extra--;
if (act->spr.extra == 0)
2020-05-08 22:34:48 +00:00
{
int rvar;
rvar = krand() & 127;
if (rvar < 96)
{
act->spr.picnum = RRTILE8162 + 3;
2020-05-08 22:34:48 +00:00
}
else if (rvar < 112)
{
if (ps[screenpeek].SlotWin & 1)
{
act->spr.picnum = RRTILE8162 + 3;
2020-05-08 22:34:48 +00:00
}
else
{
act->spr.picnum = RRTILE8162 + 2;
2020-10-22 20:21:40 +00:00
spawn(act, BATTERYAMMO);
2020-05-08 22:34:48 +00:00
ps[screenpeek].SlotWin |= 1;
2020-10-22 20:21:40 +00:00
S_PlayActorSound(52, act);
2020-05-08 22:34:48 +00:00
}
}
else if (rvar < 120)
{
if (ps[screenpeek].SlotWin & 2)
{
act->spr.picnum = RRTILE8162 + 3;
2020-05-08 22:34:48 +00:00
}
else
{
act->spr.picnum = RRTILE8162 + 6;
2020-10-22 20:21:40 +00:00
spawn(act, HEAVYHBOMB);
2020-05-08 22:34:48 +00:00
ps[screenpeek].SlotWin |= 2;
2020-10-22 20:21:40 +00:00
S_PlayActorSound(52, act);
2020-05-08 22:34:48 +00:00
}
}
else if (rvar < 126)
{
if (ps[screenpeek].SlotWin & 4)
{
act->spr.picnum = RRTILE8162 + 3;
2020-05-08 22:34:48 +00:00
}
else
{
act->spr.picnum = RRTILE8162 + 5;
2020-10-22 20:21:40 +00:00
spawn(act, SIXPAK);
2020-05-08 22:34:48 +00:00
ps[screenpeek].SlotWin |= 4;
2020-10-22 20:21:40 +00:00
S_PlayActorSound(52, act);
2020-05-08 22:34:48 +00:00
}
}
else
{
if (ps[screenpeek].SlotWin & 8)
{
act->spr.picnum = RRTILE8162 + 3;
2020-05-08 22:34:48 +00:00
}
else
{
act->spr.picnum = RRTILE8162 + 4;
2020-10-22 20:21:40 +00:00
spawn(act, ATOMICHEALTH);
2020-05-08 22:34:48 +00:00
ps[screenpeek].SlotWin |= 8;
2020-10-22 20:21:40 +00:00
S_PlayActorSound(52, act);
2020-05-08 22:34:48 +00:00
}
}
}
}
}
it.Reset(122);
2020-10-22 20:21:40 +00:00
while (auto act = it.Next())
2020-05-08 22:34:48 +00:00
{
if (act->spr.extra)
2020-05-08 22:34:48 +00:00
{
if (act->spr.picnum != RRTILE8589)
act->spr.picnum = RRTILE8589;
act->spr.extra--;
if (act->spr.extra == 0)
2020-05-08 22:34:48 +00:00
{
int rvar;
rvar = krand() & 127;
if (rvar < 96)
{
act->spr.picnum = RRTILE8589 + 4;
2020-05-08 22:34:48 +00:00
}
else if (rvar < 112)
{
if (ps[screenpeek].SlotWin & 1)
{
act->spr.picnum = RRTILE8589 + 4;
2020-05-08 22:34:48 +00:00
}
else
{
act->spr.picnum = RRTILE8589 + 5;
2020-10-22 20:21:40 +00:00
spawn(act, BATTERYAMMO);
2020-05-08 22:34:48 +00:00
ps[screenpeek].SlotWin |= 1;
2020-10-22 20:21:40 +00:00
S_PlayActorSound(342, act);
2020-05-08 22:34:48 +00:00
}
}
else if (rvar < 120)
{
if (ps[screenpeek].SlotWin & 2)
{
act->spr.picnum = RRTILE8589 + 4;
2020-05-08 22:34:48 +00:00
}
else
{
act->spr.picnum = RRTILE8589 + 6;
2020-10-22 20:21:40 +00:00
spawn(act, HEAVYHBOMB);
2020-05-08 22:34:48 +00:00
ps[screenpeek].SlotWin |= 2;
2020-10-22 20:21:40 +00:00
S_PlayActorSound(342, act);
2020-05-08 22:34:48 +00:00
}
}
else if (rvar < 126)
{
if (ps[screenpeek].SlotWin & 4)
{
act->spr.picnum = RRTILE8589 + 4;
2020-05-08 22:34:48 +00:00
}
else
{
act->spr.picnum = RRTILE8589 + 2;
2020-10-22 20:21:40 +00:00
spawn(act, SIXPAK);
2020-05-08 22:34:48 +00:00
ps[screenpeek].SlotWin |= 4;
2020-10-22 20:21:40 +00:00
S_PlayActorSound(342, act);
2020-05-08 22:34:48 +00:00
}
}
else
{
if (ps[screenpeek].SlotWin & 8)
{
act->spr.picnum = RRTILE8589 + 4;
2020-05-08 22:34:48 +00:00
}
else
{
act->spr.picnum = RRTILE8589 + 3;
2020-10-22 20:21:40 +00:00
spawn(act, ATOMICHEALTH);
2020-05-08 22:34:48 +00:00
ps[screenpeek].SlotWin |= 8;
2020-10-22 20:21:40 +00:00
S_PlayActorSound(342, act);
2020-05-08 22:34:48 +00:00
}
}
}
}
}
it.Reset(123);
2020-10-22 20:21:40 +00:00
while (auto act = it.Next())
2020-05-08 22:34:48 +00:00
{
if (act->spr.lotag == 5)
2020-05-08 22:34:48 +00:00
if (!S_CheckSoundPlaying(330))
2020-10-22 20:21:40 +00:00
S_PlayActorSound(330, act);
2020-05-08 22:34:48 +00:00
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void rr_specialstats()
{
2020-10-22 20:24:55 +00:00
DukeStatIterator it(107);
while (auto act = it.Next())
2020-05-08 22:34:48 +00:00
{
if (act->spr.hitag == 100)
2020-05-08 22:34:48 +00:00
{
act->spr.pos.Z += (4 << 8);
if (act->spr.pos.Z >= act->sector()->floorz + 15168)
act->spr.pos.Z = act->sector()->floorz + 15168;
2020-05-08 22:34:48 +00:00
}
if (act->spr.picnum == LUMBERBLADE)
2020-05-08 22:34:48 +00:00
{
act->spr.extra++;
if (act->spr.extra == 192)
2020-05-08 22:34:48 +00:00
{
act->spr.hitag = 0;
act->spr.pos.Z = act->sector()->floorz - 15168;
act->spr.extra = 0;
act->spr.picnum = RRTILE3410;
2020-11-01 15:42:41 +00:00
DukeStatIterator it2(STAT_DEFAULT);
while (auto act2 = it2.Next())
2020-05-08 22:34:48 +00:00
{
if (act2->spr.picnum == 128)
if (act2->spr.hitag == 999)
act2->spr.picnum = 127;
2020-05-08 22:34:48 +00:00
}
}
}
}
if (chickenplant)
{
it.Reset(106);
2020-10-22 20:24:55 +00:00
while (auto act = it.Next())
2020-05-08 22:34:48 +00:00
{
switch (act->spr.picnum)
2020-05-08 22:34:48 +00:00
{
case RRTILE285:
act->spr.lotag--;
if (act->spr.lotag < 0)
2020-05-08 22:34:48 +00:00
{
spawn(act, RRTILE3190)->spr.ang = act->spr.ang;
act->spr.lotag = 128;
2020-05-08 22:34:48 +00:00
}
break;
case RRTILE286:
act->spr.lotag--;
if (act->spr.lotag < 0)
2020-05-08 22:34:48 +00:00
{
spawn(act, RRTILE3192)->spr.ang = act->spr.ang;
act->spr.lotag = 256;
2020-05-08 22:34:48 +00:00
}
break;
case RRTILE287:
act->spr.lotag--;
if (act->spr.lotag < 0)
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:24:55 +00:00
lotsoffeathers_r(act, (krand() & 3) + 4);
act->spr.lotag = 84;
2020-05-08 22:34:48 +00:00
}
break;
case RRTILE288:
act->spr.lotag--;
if (act->spr.lotag < 0)
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:24:55 +00:00
auto j = spawn(act, RRTILE3132);
act->spr.lotag = 96;
if (j && !isRRRA()) S_PlayActorSound(472, j);
2020-05-08 22:34:48 +00:00
}
break;
case RRTILE289:
act->spr.lotag--;
if (act->spr.lotag < 0)
2020-05-08 22:34:48 +00:00
{
spawn(act, RRTILE3120)->spr.ang = act->spr.ang;
act->spr.lotag = 448;
2020-05-08 22:34:48 +00:00
}
break;
case RRTILE290:
act->spr.lotag--;
if (act->spr.lotag < 0)
2020-05-08 22:34:48 +00:00
{
spawn(act, RRTILE3122)->spr.ang = act->spr.ang;
act->spr.lotag = 64;
2020-05-08 22:34:48 +00:00
}
break;
case RRTILE291:
act->spr.lotag--;
if (act->spr.lotag < 0)
2020-05-08 22:34:48 +00:00
{
spawn(act, RRTILE3123)->spr.ang = act->spr.ang;
act->spr.lotag = 512;
2020-05-08 22:34:48 +00:00
}
break;
case RRTILE292:
act->spr.lotag--;
if (act->spr.lotag < 0)
2020-05-08 22:34:48 +00:00
{
spawn(act, RRTILE3124)->spr.ang = act->spr.ang;
act->spr.lotag = 224;
2020-05-08 22:34:48 +00:00
}
break;
case RRTILE293:
act->spr.lotag--;
if (act->spr.lotag < 0)
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:24:55 +00:00
fi.guts(act, JIBS1, 1, myconnectindex);
fi.guts(act, JIBS2, 1, myconnectindex);
fi.guts(act, JIBS3, 1, myconnectindex);
fi.guts(act, JIBS4, 1, myconnectindex);
act->spr.lotag = 256;
2020-05-08 22:34:48 +00:00
}
break;
}
}
}
it.Reset(STAT_BOWLING);
2020-10-22 20:24:55 +00:00
while (auto act = it.Next())
2020-05-08 22:34:48 +00:00
{
if (act->spr.picnum == BOWLINGPINSPOT)
if (act->spr.lotag == 100)
2020-05-08 22:34:48 +00:00
{
auto pst = pinsectorresetup(act->sector());
2020-05-08 22:34:48 +00:00
if (pst)
{
act->spr.lotag = 0;
if (act->spr.extra == 1)
2020-05-08 22:34:48 +00:00
{
pst = checkpins(act->sector());
2020-05-08 22:34:48 +00:00
if (!pst)
{
act->spr.extra = 2;
2020-05-08 22:34:48 +00:00
}
}
if (act->spr.extra == 2)
2020-05-08 22:34:48 +00:00
{
act->spr.extra = 0;
resetpins(act->sector());
2020-05-08 22:34:48 +00:00
}
}
}
}
it.Reset(108);
2020-10-22 20:24:55 +00:00
while (auto act = it.Next())
2020-05-08 22:34:48 +00:00
{
if (act->spr.picnum == RRTILE296)
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:24:55 +00:00
int x;
2020-10-23 15:44:45 +00:00
int p = findplayer(act, &x);
2020-05-08 22:34:48 +00:00
if (x < 2047)
{
2020-11-01 15:42:41 +00:00
DukeStatIterator it2(108);
while (auto act2 = it2.Next())
2020-05-08 22:34:48 +00:00
{
if (act2->spr.picnum == RRTILE297)
2020-05-08 22:34:48 +00:00
{
ps[p].angle.ang = buildang(act2->spr.ang);
ps[p].bobpos.X = ps[p].opos.X = ps[p].pos.X = act2->spr.pos.X;
ps[p].bobpos.Y = ps[p].opos.Y = ps[p].pos.Y = act2->spr.pos.Y;
ps[p].opos.Z = ps[p].pos.Z = act2->spr.pos.Z - (36 << 8);
2020-10-22 20:24:55 +00:00
auto pact = ps[p].GetActor();
ChangeActorSect(pact, act2->sector());
2021-11-21 07:45:07 +00:00
ps[p].setCursector(pact->sector());
2020-10-22 20:24:55 +00:00
S_PlayActorSound(70, act2);
deletesprite(act2);
2020-05-08 22:34:48 +00:00
}
}
}
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-22 20:18:47 +00:00
static void heavyhbomb(DDukeActor *actor)
{
auto sectp = actor->sector();
2020-10-22 20:18:47 +00:00
int x, l;
auto Owner = actor->GetOwner();
2021-12-21 19:02:06 +00:00
if ((actor->spr.cstat & CSTAT_SPRITE_INVISIBLE))
{
actor->temp_data[2]--;
if (actor->temp_data[2] <= 0)
{
2020-10-22 20:18:47 +00:00
S_PlayActorSound(TELEPORTER, actor);
spawn(actor, TRANSPORTERSTAR);
2021-12-21 19:02:06 +00:00
actor->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
}
return;
}
2020-10-23 15:44:45 +00:00
int p = findplayer(actor, &x);
2021-12-21 19:02:06 +00:00
if (x < 1220) actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
else actor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
if (actor->temp_data[3] == 0)
{
2020-10-22 20:18:47 +00:00
int j = fi.ifhitbyweapon(actor);
if (j >= 0)
{
actor->temp_data[3] = 1;
actor->temp_data[4] = 0;
l = 0;
2021-12-21 19:02:06 +00:00
actor->spr.xvel = 0;
goto DETONATEB;
}
}
2020-10-22 20:18:47 +00:00
makeitfall(actor);
if (sectp->lotag != 1 && (!isRRRA() || sectp->lotag != 160) && actor->spr.pos.Z >= actor->floorz - (FOURSLEIGHT) && actor->spr.yvel < 3)
{
2021-12-21 19:02:06 +00:00
if (actor->spr.yvel > 0 || (actor->spr.yvel == 0 && actor->floorz == sectp->floorz))
{
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum != CHEERBOMB)
2020-10-22 20:18:47 +00:00
S_PlayActorSound(PIPEBOMB_BOUNCE, actor);
else
{
actor->temp_data[3] = 1;
actor->temp_data[4] = 1;
l = 0;
goto DETONATEB;
}
}
2021-12-21 19:02:06 +00:00
actor->spr.zvel = -((4 - actor->spr.yvel) << 8);
if (actor->sector()->lotag == 2)
2021-12-21 19:02:06 +00:00
actor->spr.zvel >>= 2;
actor->spr.yvel++;
}
if (actor->spr.picnum != CHEERBOMB && actor->spr.pos.Z < actor->ceilingz + (16 << 8) && sectp->lotag != 2)
{
actor->spr.pos.Z = actor->ceilingz + (16 << 8);
2021-12-21 19:02:06 +00:00
actor->spr.zvel = 0;
}
2020-10-22 20:18:47 +00:00
Collision coll;
movesprite_ex(actor,
2021-12-21 19:02:06 +00:00
MulScale(actor->spr.xvel, bcos(actor->spr.ang), 14),
MulScale(actor->spr.xvel, bsin(actor->spr.ang), 14),
actor->spr.zvel, CLIPMASK0, coll);
if (actor->sector()->lotag == 1 && actor->spr.zvel == 0)
{
actor->spr.pos.Z += (32 << 8);
if (actor->temp_data[5] == 0)
{
actor->temp_data[5] = 1;
2020-10-22 20:18:47 +00:00
spawn(actor, WATERSPLASH2);
2021-12-21 19:02:06 +00:00
if (isRRRA() && actor->spr.picnum == MORTER)
actor->spr.xvel = 0;
}
}
else actor->temp_data[5] = 0;
if (actor->temp_data[3] == 0 && actor->spr.picnum == MORTER && (coll.type || x < 844))
{
actor->temp_data[3] = 1;
actor->temp_data[4] = 0;
l = 0;
2021-12-21 19:02:06 +00:00
actor->spr.xvel = 0;
goto DETONATEB;
}
if (actor->temp_data[3] == 0 && actor->spr.picnum == CHEERBOMB && (coll.type || x < 844))
{
actor->temp_data[3] = 1;
actor->temp_data[4] = 0;
l = 0;
2021-12-21 19:02:06 +00:00
actor->spr.xvel = 0;
goto DETONATEB;
}
if (Owner && Owner->spr.picnum == APLAYER)
2020-10-22 20:18:47 +00:00
l = Owner->PlayerIndex();
else l = -1;
2021-12-21 19:02:06 +00:00
if (actor->spr.xvel > 0)
{
2021-12-21 19:02:06 +00:00
actor->spr.xvel -= 5;
if (sectp->lotag == 2)
2021-12-21 19:02:06 +00:00
actor->spr.xvel -= 10;
2021-12-21 19:02:06 +00:00
if (actor->spr.xvel < 0)
actor->spr.xvel = 0;
if (actor->spr.xvel & 8) actor->spr.cstat ^= CSTAT_SPRITE_XFLIP;
}
2020-10-22 20:18:47 +00:00
if (coll.type == kHitWall)
{
auto wal = coll.hitWall;
fi.checkhitwall(actor, wal, actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, actor->spr.picnum);
2021-11-24 15:34:21 +00:00
int k = getangle(wal->delta());
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == CHEERBOMB)
{
actor->temp_data[3] = 1;
actor->temp_data[4] = 0;
l = 0;
2021-12-21 19:02:06 +00:00
actor->spr.xvel = 0;
goto DETONATEB;
}
2021-12-21 19:02:06 +00:00
actor->spr.ang = ((k << 1) - actor->spr.ang) & 2047;
actor->spr.xvel >>= 1;
}
DETONATEB:
if ((l >= 0 && ps[l].hbomb_on == 0) || actor->temp_data[3] == 1)
{
actor->temp_data[4]++;
if (actor->temp_data[4] == 2)
{
2021-12-21 19:02:06 +00:00
x = actor->spr.extra;
int m = 0;
2021-12-21 19:02:06 +00:00
switch (actor->spr.picnum)
{
2022-01-19 09:48:18 +00:00
case POWDERKEG: m = gs.tripbombblastradius; break; // powder keg
case HEAVYHBOMB: m = gs.pipebombblastradius; break;
case HBOMBAMMO: m = gs.pipebombblastradius; break;
case MORTER: m = gs.morterblastradius; break;
case CHEERBOMB: m = gs.morterblastradius; break;
}
if (actor->sector()->lotag != 800)
{
2020-10-22 20:18:47 +00:00
fi.hitradius(actor, m, x >> 2, x >> 1, x - (x >> 2), x);
spawn(actor, EXPLOSION2);
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == CHEERBOMB)
2020-10-22 20:18:47 +00:00
spawn(actor, BURNING);
S_PlayActorSound(PIPEBOMB_EXPLODE, actor);
for (x = 0; x < 8; x++)
2020-10-22 20:18:47 +00:00
RANDOMSCRAP(actor);
}
}
2021-12-21 19:02:06 +00:00
if (actor->spr.yrepeat)
{
2021-12-21 19:02:06 +00:00
actor->spr.yrepeat = 0;
return;
}
if (actor->temp_data[4] > 20)
{
2020-10-22 20:18:47 +00:00
deletesprite(actor);
return;
}
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == CHEERBOMB)
{
2020-10-22 20:18:47 +00:00
spawn(actor, BURNING);
deletesprite(actor);
return;
}
}
else if (actor->spr.picnum == HEAVYHBOMB && x < 788 && actor->temp_data[0] > 7 && actor->spr.xvel == 0)
if (cansee(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - (8 << 8), actor->sector(), ps[p].pos.X, ps[p].pos.Y, ps[p].pos.Z, ps[p].cursector))
if (ps[p].ammo_amount[DYNAMITE_WEAPON] < gs.max_ammo_amount[DYNAMITE_WEAPON])
2021-12-21 19:02:06 +00:00
if (actor->spr.pal == 0)
{
if (ud.coop >= 1)
{
2020-10-22 20:18:47 +00:00
for (int j = 0; j < ps[p].weapreccnt; j++)
2021-12-21 19:02:06 +00:00
if (ps[p].weaprecs[j] == actor->spr.picnum)
return;
if (ps[p].weapreccnt < 255)
2021-12-21 19:02:06 +00:00
ps[p].weaprecs[ps[p].weapreccnt++] = actor->spr.picnum;
}
addammo(DYNAMITE_WEAPON, &ps[p], 1);
addammo(CROSSBOW_WEAPON, &ps[p], 1);
2020-10-22 20:18:47 +00:00
S_PlayActorSound(DUKE_GET, ps[p].GetActor());
2020-10-22 20:18:47 +00:00
if (ps[p].gotweapon[DYNAMITE_WEAPON] == 0 || Owner == ps[p].GetActor())
fi.addweapon(&ps[p], DYNAMITE_WEAPON);
if (!Owner || Owner->spr.picnum != APLAYER)
{
SetPlayerPal(&ps[p], PalEntry(32, 0, 32, 0));
}
if (Owner && (Owner->attackertype != HEAVYHBOMB || ud.respawn_items == 0 || Owner->spr.picnum == APLAYER))
{
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == HEAVYHBOMB && Owner->spr.picnum != APLAYER && ud.coop)
return;
2020-10-22 20:18:47 +00:00
deletesprite(actor);
return;
}
else
{
actor->temp_data[2] = gs.respawnitemtime;
2020-10-22 20:18:47 +00:00
spawn(actor, RESPAWNMARKERRED);
2021-12-21 19:02:06 +00:00
actor->spr.cstat = CSTAT_SPRITE_INVISIBLE;
}
}
if (actor->temp_data[0] < 8) actor->temp_data[0]++;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-22 20:31:10 +00:00
static int henstand(DDukeActor *actor)
{
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == HENSTAND || actor->spr.picnum == HENSTAND + 1)
{
2021-12-21 19:02:06 +00:00
actor->spr.lotag--;
if (actor->spr.lotag == 0)
{
2020-10-22 20:31:10 +00:00
spawn(actor, HEN);
deletesprite(actor);
return 1;
}
}
if (actor->sector()->lotag == 900)
2021-12-21 19:02:06 +00:00
actor->spr.xvel = 0;
if (actor->spr.xvel)
{
2020-10-22 20:31:10 +00:00
makeitfall(actor);
Collision coll;
movesprite_ex(actor,
2021-12-21 19:02:06 +00:00
MulScale(bcos(actor->spr.ang), actor->spr.xvel, 14),
MulScale(bsin(actor->spr.ang), actor->spr.xvel, 14),
actor->spr.zvel, CLIPMASK0, coll);
2020-10-22 20:31:10 +00:00
if (coll.type)
{
2020-10-22 20:31:10 +00:00
if (coll.type == kHitWall)
{
int k = getangle(coll.hitWall->delta());
2021-12-21 19:02:06 +00:00
actor->spr.ang = ((k << 1) - actor->spr.ang) & 2047;
}
2020-10-22 20:31:10 +00:00
else if (coll.type == kHitSprite)
{
auto hitact = coll.actor();
fi.checkhitsprite(actor, hitact);
if (hitact->spr.picnum == HEN)
{
2020-10-22 20:31:10 +00:00
auto ns = spawn(hitact, HENSTAND);
deletesprite(hitact);
if (ns)
{
ns->spr.xvel = 32;
ns->spr.lotag = 40;
2021-12-21 19:02:06 +00:00
ns->spr.ang = actor->spr.ang;
}
}
}
}
2021-12-21 19:02:06 +00:00
actor->spr.xvel--;
if (actor->spr.xvel < 0) actor->spr.xvel = 0;
actor->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
if (actor->spr.picnum == BOWLINGPIN)
{
2021-12-21 19:02:06 +00:00
actor->spr.cstat |= CSTAT_SPRITE_XFLIP & ESpriteFlags::FromInt(actor->spr.xvel);
actor->spr.cstat |= CSTAT_SPRITE_YFLIP & ESpriteFlags::FromInt(actor->spr.xvel);
if (krand() & 1)
2021-12-21 19:02:06 +00:00
actor->spr.picnum = BOWLINGPIN + 1;
}
2021-12-21 19:02:06 +00:00
else if (actor->spr.picnum == HENSTAND)
{
2021-12-21 19:02:06 +00:00
actor->spr.cstat |= CSTAT_SPRITE_XFLIP & ESpriteFlags::FromInt(actor->spr.xvel);
actor->spr.cstat |= CSTAT_SPRITE_YFLIP & ESpriteFlags::FromInt(actor->spr.xvel);
if (krand() & 1)
2021-12-21 19:02:06 +00:00
actor->spr.picnum = HENSTAND + 1;
if (!actor->spr.xvel)
2020-10-22 20:31:10 +00:00
return 2;//deletesprite(actor); still needs to run a script but should not do on a deleted object
}
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == BOWLINGPIN || (actor->spr.picnum == BOWLINGPIN + 1 && !actor->spr.xvel))
{
2020-10-22 20:31:10 +00:00
return 2;//deletesprite(actor); still needs to run a script but should not do on a deleted object
}
}
else if (actor->sector()->lotag == 900)
{
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == BOWLINGBALL)
2020-10-22 20:31:10 +00:00
ballreturn(actor);
deletesprite(actor);
return 1;
}
return 0;
}
2020-05-09 18:27:06 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-08 22:34:48 +00:00
void moveactors_r(void)
{
int x;
2020-10-22 20:48:51 +00:00
int p;
Collision coll;
dojaildoor();
moveminecart();
2020-05-08 22:34:48 +00:00
if (isRRRA())
{
rrra_specialstats();
}
rr_specialstats();
2020-10-22 20:48:51 +00:00
DukeStatIterator it(STAT_ACTOR);
while (auto act = it.Next())
{
bool deleteafterexecute = false; // taking a cue here from RedNukem to not run scripts on deleted sprites.
2020-05-08 22:34:48 +00:00
if( act->spr.xrepeat == 0 || !act->insector())
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:48:51 +00:00
deletesprite(act);
2020-05-08 22:34:48 +00:00
continue;
}
auto sectp = act->sector();
2021-12-21 19:02:06 +00:00
switch(act->spr.picnum)
{
case RESPAWNMARKERRED:
case RESPAWNMARKERYELLOW:
case RESPAWNMARKERGREEN:
2020-10-22 20:48:51 +00:00
if (!respawnmarker(act, RESPAWNMARKERYELLOW, RESPAWNMARKERGREEN)) continue;
2020-05-08 22:34:48 +00:00
break;
case RAT:
2020-10-22 20:48:51 +00:00
if (!rat(act, !isRRRA())) continue;
break;
case RRTILE3190:
case RRTILE3191:
case RRTILE3192:
2020-10-22 20:48:51 +00:00
if (!chickenplant)
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:48:51 +00:00
deletesprite(act);
2020-05-08 22:34:48 +00:00
continue;
}
if (sectp->lotag == 903)
2020-10-22 20:48:51 +00:00
makeitfall(act);
movesprite_ex(act,
2021-12-21 19:02:06 +00:00
MulScale(act->spr.xvel, bcos(act->spr.ang), 14),
MulScale(act->spr.xvel, bsin(act->spr.ang), 14),
act->spr.zvel,CLIPMASK0, coll);
switch (sectp->lotag)
{
case 901:
2021-12-21 19:02:06 +00:00
act->spr.picnum = RRTILE3191;
break;
case 902:
2021-12-21 19:02:06 +00:00
act->spr.picnum = RRTILE3192;
break;
case 903:
if (act->spr.pos.Z >= sectp->floorz - (8<<8))
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:48:51 +00:00
deletesprite(act);
2020-05-08 22:34:48 +00:00
continue;
}
break;
case 904:
2020-10-22 20:48:51 +00:00
deletesprite(act);
2020-05-08 22:34:48 +00:00
continue;
break;
}
2020-10-22 20:48:51 +00:00
if (coll.type > kHitSector)
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:48:51 +00:00
deletesprite(act);
2020-05-08 22:34:48 +00:00
continue;
}
break;
2020-05-08 22:34:48 +00:00
case RRTILE3120:
case RRTILE3122:
case RRTILE3123:
case RRTILE3124:
2020-10-22 20:48:51 +00:00
if (!chickenplant)
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:48:51 +00:00
deletesprite(act);
2020-05-08 22:34:48 +00:00
continue;
}
2020-10-22 20:48:51 +00:00
makeitfall(act);
movesprite_ex(act,
2021-12-21 19:02:06 +00:00
MulScale(act->spr.xvel, bcos(act->spr.ang), 14),
MulScale(act->spr.xvel, bsin(act->spr.ang), 14),
act->spr.zvel,CLIPMASK0, coll);
2020-10-22 20:48:51 +00:00
if (coll.type > kHitSector)
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:48:51 +00:00
deletesprite(act);
2020-05-08 22:34:48 +00:00
continue;
}
if (sectp->lotag == 903)
{
if (act->spr.pos.Z >= sectp->floorz - (4<<8))
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:48:51 +00:00
deletesprite(act);
2020-05-08 22:34:48 +00:00
continue;
}
}
else if (sectp->lotag == 904)
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:48:51 +00:00
deletesprite(act);
2020-05-08 22:34:48 +00:00
continue;
}
break;
2020-05-08 22:34:48 +00:00
case RRTILE3132:
2020-10-22 20:48:51 +00:00
if (!chickenplant)
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:48:51 +00:00
deletesprite(act);
2020-05-08 22:34:48 +00:00
continue;
}
2020-10-22 20:48:51 +00:00
makeitfall(act);
movesprite_ex(act,
2021-12-21 19:02:06 +00:00
MulScale(act->spr.xvel, bcos(act->spr.ang), 14),
MulScale(act->spr.xvel, bsin(act->spr.ang), 14),
act->spr.zvel,CLIPMASK0, coll);
if (act->spr.pos.Z >= sectp->floorz - (8<<8))
{
if (sectp->lotag == 1)
{
2020-10-22 20:48:51 +00:00
auto j = spawn(act, WATERSPLASH2);
if (j) j->spr.pos.Z = j->sector()->floorz;
}
2020-10-22 20:48:51 +00:00
deletesprite(act);
2020-05-08 22:34:48 +00:00
continue;
}
break;
case BOWLINGBALL:
2021-12-21 19:02:06 +00:00
if (act->spr.xvel)
{
if(!S_CheckSoundPlaying(356))
2020-10-22 20:48:51 +00:00
S_PlayActorSound(356,act);
}
else
{
2020-10-22 20:48:51 +00:00
spawn(act,BOWLINGBALLSPRITE);
deletesprite(act);
2020-05-08 22:34:48 +00:00
continue;
}
if (act->sector()->lotag == 900)
{
S_StopSound(356, nullptr);
}
[[fallthrough]];
case BOWLINGPIN:
case BOWLINGPIN+1:
case HENSTAND:
case HENSTAND+1:
{
2020-10-22 20:48:51 +00:00
int todo = henstand(act);
if (todo == 2) deleteafterexecute = true;
if (todo == 1) continue;
break;
}
2020-05-08 22:34:48 +00:00
case QUEBALL:
case STRIPEBALL:
2020-10-22 20:48:51 +00:00
if (!queball(act, POCKET, QUEBALL, STRIPEBALL)) continue;
break;
case FORCESPHERE:
2020-10-22 20:48:51 +00:00
forcesphere(act, FORCESPHERE);
continue;
case RECON:
case UFO1_RR:
case UFO2:
case UFO3:
case UFO4:
case UFO5:
2020-10-22 20:48:51 +00:00
recon(act, EXPLOSION2, FIRELASER, -1, -1, 457, 8, [](DDukeActor* act) ->int
2020-05-08 22:34:48 +00:00
{
if (isRRRA() && ufospawnsminion)
return MINION;
2021-12-21 19:02:06 +00:00
else if (act->spr.picnum == UFO1_RR)
2020-05-08 22:34:48 +00:00
return HEN;
2021-12-21 19:02:06 +00:00
else if (act->spr.picnum == UFO2)
2020-05-08 22:34:48 +00:00
return COOT;
2021-12-21 19:02:06 +00:00
else if (act->spr.picnum == UFO3)
2020-05-08 22:34:48 +00:00
return COW;
2021-12-21 19:02:06 +00:00
else if (act->spr.picnum == UFO4)
2020-05-08 22:34:48 +00:00
return PIG;
2021-12-21 19:02:06 +00:00
else if (act->spr.picnum == UFO5)
2020-05-08 22:34:48 +00:00
return BILLYRAY;
else return -1;
2020-05-08 22:34:48 +00:00
});
continue;
2020-05-08 22:34:48 +00:00
case OOZ:
2020-10-22 20:48:51 +00:00
ooz(act);
continue;
2020-05-08 22:34:48 +00:00
case EMPTYBIKE:
2020-05-08 22:34:48 +00:00
if (!isRRRA()) break;
2020-10-22 20:48:51 +00:00
makeitfall(act);
getglobalz(act);
if (sectp->lotag == 1)
{
SetActor(act, { act->spr.pos.X,act->spr.pos.Y,act->floorz + (16 << 8) });
}
break;
case EMPTYBOAT:
2020-05-08 22:34:48 +00:00
if (!isRRRA()) break;
2020-10-22 20:48:51 +00:00
makeitfall(act);
getglobalz(act);
break;
2020-05-08 22:34:48 +00:00
2022-01-19 09:48:18 +00:00
case POWDERKEG:
if (!isRRRA() || (sectp->lotag != 1 && sectp->lotag != 160))
2021-12-21 19:02:06 +00:00
if (act->spr.xvel)
2020-05-08 22:34:48 +00:00
{
2020-10-22 20:48:51 +00:00
movesprite_ex(act,
2021-12-21 19:02:06 +00:00
MulScale(act->spr.xvel, bcos(act->spr.ang), 14),
MulScale(act->spr.xvel, bsin(act->spr.ang), 14),
act->spr.zvel,CLIPMASK0, coll);
act->spr.xvel--;
2020-05-08 22:34:48 +00:00
}
break;
2020-05-08 22:34:48 +00:00
case CHEERBOMB:
if (!isRRRA()) break;
[[fallthrough]];
2020-05-08 22:34:48 +00:00
case MORTER:
case HEAVYHBOMB:
2020-10-22 20:48:51 +00:00
heavyhbomb(act);
continue;
case REACTORBURNT:
case REACTOR2BURNT:
continue;
case REACTOR:
case REACTOR2:
2020-10-22 20:48:51 +00:00
reactor(act, REACTOR, REACTOR2, REACTORBURNT, REACTOR2BURNT, REACTORSPARK, REACTOR2SPARK);
continue;
2020-05-08 22:34:48 +00:00
case CAMERA1:
2020-10-22 20:48:51 +00:00
camera(act);
continue;
}
2020-05-08 22:34:48 +00:00
// #ifndef VOLOMEONE
2020-10-22 20:48:51 +00:00
if( ud.multimode < 2 && badguy(act) )
{
if( actor_tog == 1)
{
2021-12-21 19:02:06 +00:00
act->spr.cstat = CSTAT_SPRITE_INVISIBLE;
continue;
}
2021-12-21 19:02:06 +00:00
else if(actor_tog == 2) act->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
}
2020-05-08 22:34:48 +00:00
// #endif
2020-10-23 15:44:45 +00:00
p = findplayer(act,&x);
2020-05-08 22:34:48 +00:00
2020-10-22 20:48:51 +00:00
execute(act,p,x);
if (deleteafterexecute) deletesprite(act);
}
2020-05-08 22:34:48 +00:00
}
2020-05-09 18:27:06 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void moveexplosions_r(void) // STATNUM 5
{
int p;
2020-05-09 18:27:06 +00:00
int x, * t;
2020-10-22 20:51:51 +00:00
DukeStatIterator it(STAT_MISC);
while (auto act = it.Next())
2020-05-09 18:27:06 +00:00
{
2020-10-22 20:51:51 +00:00
t = &act->temp_data[0];
auto sectp = act->sector();
2020-05-09 18:27:06 +00:00
if (!act->insector() || act->spr.xrepeat == 0)
2020-05-09 18:27:06 +00:00
{
2020-10-22 20:51:51 +00:00
deletesprite(act);
2020-05-09 18:27:06 +00:00
continue;
}
2021-12-21 19:02:06 +00:00
switch (act->spr.picnum)
2020-05-09 18:27:06 +00:00
{
case SHOTGUNSPRITE:
if (act->sector()->lotag == 800)
if (act->spr.pos.Z >= act->sector()->floorz - (8 << 8))
2020-05-09 18:27:06 +00:00
{
2020-10-22 20:51:51 +00:00
deletesprite(act);
2020-05-09 18:27:06 +00:00
continue;
}
break;
case NEON1:
case NEON2:
case NEON3:
case NEON4:
case NEON5:
case NEON6:
2021-12-21 19:02:06 +00:00
if ((global_random / (act->spr.lotag + 1) & 31) > 4) act->spr.shade = -127;
else act->spr.shade = 127;
2020-05-09 18:27:06 +00:00
continue;
case BLOODSPLAT1:
case BLOODSPLAT2:
case BLOODSPLAT3:
case BLOODSPLAT4:
if (act->temp_data[0] == 7 * 26) continue;
act->spr.pos.Z += 16 + (krand() & 15);
act->temp_data[0]++;
if ((act->temp_data[0] % 9) == 0) act->spr.yrepeat++;
2020-05-09 18:27:06 +00:00
continue;
case FORCESPHERE:
2020-10-22 20:51:51 +00:00
forcesphereexplode(act);
2020-05-09 18:27:06 +00:00
continue;
case MUD:
act->temp_data[0]++;
if (act->temp_data[0] == 1)
2020-05-09 18:27:06 +00:00
{
if (sectp->floorpicnum != 3073)
2020-05-09 18:27:06 +00:00
{
2020-10-22 20:51:51 +00:00
deletesprite(act);
2020-05-09 18:27:06 +00:00
continue;
}
if (S_CheckSoundPlaying(22))
2020-10-22 20:51:51 +00:00
S_PlayActorSound(22, act);
2020-05-09 18:27:06 +00:00
}
if (act->temp_data[0] == 3)
2020-05-09 18:27:06 +00:00
{
act->temp_data[0] = 0;
act->temp_data[1]++;
2020-05-09 18:27:06 +00:00
}
if (act->temp_data[1] == 5)
2020-10-22 20:51:51 +00:00
deletesprite(act);
2020-05-09 18:27:06 +00:00
continue;
case WATERSPLASH2:
2020-10-22 20:51:51 +00:00
watersplash2(act);
2020-05-09 18:27:06 +00:00
continue;
case FRAMEEFFECT1:
2020-10-22 20:51:51 +00:00
frameeffect1(act);
2020-05-09 18:27:06 +00:00
continue;
case INNERJAW:
case INNERJAW + 1:
2020-10-23 15:44:45 +00:00
p = findplayer(act, &x);
2020-05-09 18:27:06 +00:00
if (x < 512)
{
SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0));
ps[p].GetActor()->spr.extra -= 4;
2020-05-09 18:27:06 +00:00
}
[[fallthrough]];
2020-05-09 18:27:06 +00:00
case COOLEXPLOSION1:
case FIRELASER:
case OWHIP:
case UWHIP:
2021-12-21 19:02:06 +00:00
if (act->spr.extra != 999)
act->spr.extra = 999;
2020-05-09 18:27:06 +00:00
else
{
2020-10-22 20:51:51 +00:00
deletesprite(act);
2020-05-09 18:27:06 +00:00
continue;
}
break;
case TONGUE:
2020-10-22 20:51:51 +00:00
deletesprite(act);
2020-05-09 18:27:06 +00:00
continue;
2020-10-22 20:51:51 +00:00
case FEATHER + 1: // feather
act->floorz = act->spr.pos.Z = getflorzofslopeptr(act->sector(), act->spr.pos.X, act->spr.pos.Y);
if (act->sector()->lotag == 800)
2020-05-09 18:27:06 +00:00
{
2020-10-22 20:51:51 +00:00
deletesprite(act);
2020-05-09 18:27:06 +00:00
continue;
}
break;
2020-10-22 20:51:51 +00:00
case FEATHER:
if (!money(act, BLOODPOOL)) continue;
2020-05-09 18:27:06 +00:00
if (act->sector()->lotag == 800)
if (act->spr.pos.Z >= act->sector()->floorz - (8 << 8))
2020-05-09 18:27:06 +00:00
{
2020-10-22 20:51:51 +00:00
deletesprite(act);
2020-05-09 18:27:06 +00:00
continue;
}
break;
case RRTILE2460:
case RRTILE2465:
case BIKEJIBA:
case BIKEJIBB:
case BIKEJIBC:
case BIKERJIBA:
case BIKERJIBB:
case BIKERJIBC:
case BIKERJIBD:
case CHEERJIBA:
case CHEERJIBB:
case CHEERJIBC:
case CHEERJIBD:
case FBOATJIBA:
case FBOATJIBB:
case RABBITJIBA:
case RABBITJIBB:
case RABBITJIBC:
case MAMAJIBA:
case MAMAJIBB:
if (!isRRRA()) break;
[[fallthrough]];
2020-05-09 18:27:06 +00:00
case BILLYJIBA:
case BILLYJIBB:
case HULKJIBA:
case HULKJIBB:
case HULKJIBC:
case MINJIBA:
case MINJIBB:
case MINJIBC:
case COOTJIBA:
case COOTJIBB:
case COOTJIBC:
case JIBS1:
case JIBS2:
case JIBS3:
case JIBS4:
case JIBS5:
case JIBS6:
case DUKETORSO:
case DUKEGUN:
case DUKELEG:
2021-12-21 19:02:06 +00:00
if (!jibs(act, JIBS6, false, true, true, act->spr.picnum == DUKELEG || act->spr.picnum == DUKETORSO || act->spr.picnum == DUKEGUN,
isRRRA() && (act->spr.picnum == RRTILE2465 || act->spr.picnum == RRTILE2560))) continue;
if (act->sector()->lotag == 800)
if (act->spr.pos.Z >= act->sector()->floorz - (8 << 8))
2020-05-09 18:27:06 +00:00
{
2020-10-22 20:51:51 +00:00
deletesprite(act);
2020-05-09 18:27:06 +00:00
continue;
}
continue;
case BLOODPOOL:
2022-01-26 23:41:33 +00:00
if (!bloodpool(act, false)) continue;
2020-05-09 18:27:06 +00:00
if (act->sector()->lotag == 800)
if (act->spr.pos.Z >= act->sector()->floorz - (8 << 8))
2020-05-09 18:27:06 +00:00
{
2020-10-22 20:51:51 +00:00
deletesprite(act);
2020-05-09 18:27:06 +00:00
}
continue;
case BURNING:
case WATERBUBBLE:
case SMALLSMOKE:
case EXPLOSION2:
case EXPLOSION3:
case BLOOD:
case FORCERIPPLE:
case TRANSPORTERSTAR:
case TRANSPORTERBEAM:
2020-10-23 15:44:45 +00:00
p = findplayer(act, &x);
2020-10-22 20:51:51 +00:00
execute(act, p, x);
2020-05-09 18:27:06 +00:00
continue;
case SHELL:
case SHOTGUNSHELL:
2020-10-22 20:51:51 +00:00
shell(act, false);
2020-05-09 18:27:06 +00:00
continue;
case GLASSPIECES:
case GLASSPIECES + 1:
case GLASSPIECES + 2:
case POPCORN:
2020-10-22 20:51:51 +00:00
glasspieces(act);
2020-05-09 18:27:06 +00:00
continue;
}
2021-12-21 19:02:06 +00:00
if (act->spr.picnum >= SCRAP6 && act->spr.picnum <= SCRAP5 + 3)
2020-05-09 18:27:06 +00:00
{
2020-10-22 20:51:51 +00:00
scrap(act, SCRAP1, SCRAP6);
2020-05-09 18:27:06 +00:00
}
}
}
2020-05-10 07:08:02 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void handle_se06_r(DDukeActor *actor)
{
2021-11-20 23:33:17 +00:00
auto sc = actor->sector();
2021-12-21 19:02:06 +00:00
int sh = actor->spr.hitag;
int k = sc->extra;
if (actor->temp_data[4] > 0)
{
actor->temp_data[4]--;
if (actor->temp_data[4] >= (k - (k >> 3)))
2021-12-21 19:02:06 +00:00
actor->spr.xvel -= (k >> 5);
if (actor->temp_data[4] > ((k >> 1) - 1) && actor->temp_data[4] < (k - (k >> 3)))
2021-12-21 19:02:06 +00:00
actor->spr.xvel = 0;
if (actor->temp_data[4] < (k >> 1))
2021-12-21 19:02:06 +00:00
actor->spr.xvel += (k >> 5);
if (actor->temp_data[4] < ((k >> 1) - (k >> 3)))
{
actor->temp_data[4] = 0;
2021-12-21 19:02:06 +00:00
actor->spr.xvel = k;
if ((!isRRRA() || lastlevel) && hulkspawn)
{
hulkspawn--;
auto ns = spawn(actor, HULK);
if (ns)
{
ns->spr.pos.Z = ns->sector()->ceilingz;
ns->spr.pal = 33;
}
if (!hulkspawn)
{
ns = EGS(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->sector()->ceilingz + 119428, 3677, -8, 16, 16, 0, 0, 0, actor, 5);
if (ns)
{
ns->spr.cstat = CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT;
ns->spr.pal = 7;
ns->spr.xrepeat = 80;
ns->spr.yrepeat = 255;
}
ns = spawn(actor, 296);
if (ns)
{
ns->spr.cstat = 0;
ns->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
ns->spr.pos.Z = actor->sector()->floorz - 6144;
}
deletesprite(actor);
return;
}
}
}
}
else
{
2021-12-21 19:02:06 +00:00
actor->spr.xvel = k;
DukeSectIterator it(actor->sector());
while (auto a2 = it.Next())
{
if (a2->spr.picnum == UFOBEAM && ufospawn && ++ufocnt == 64)
{
int pn;
ufocnt = 0;
ufospawn--;
if (!isRRRA())
{
switch (krand() & 3)
{
default:
case 0:
pn = UFO1_RR;
break;
case 1:
pn = UFO2;
break;
case 2:
pn = UFO3;
break;
case 3:
pn = UFO4;
break;
}
}
else pn = UFO1_RRRA;
auto ns = spawn(actor, pn);
if (ns) ns->spr.pos.Z = ns->sector()->ceilingz;
}
}
}
DukeStatIterator it(STAT_EFFECTOR);
while (auto act2 = it.Next())
{
if ((act2->spr.lotag == 14) && (sh == act2->spr.hitag) && (act2->temp_data[0] == actor->temp_data[0]))
{
2021-12-21 19:02:06 +00:00
act2->spr.xvel = actor->spr.xvel;
// if( actor->temp_data[4] == 1 )
{
if (act2->temp_data[5] == 0)
act2->temp_data[5] = dist(act2, actor);
int x = Sgn(dist(act2, actor) - act2->temp_data[5]);
if (act2->spr.extra) x = -x;
2021-12-21 19:02:06 +00:00
actor->spr.xvel += x;
}
act2->temp_data[4] = actor->temp_data[4];
}
}
handle_se14(actor, false, RPG, JIBS6);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-10 07:08:02 +00:00
void moveeffectors_r(void) //STATNUM 3
{
2020-10-22 21:17:51 +00:00
int l;
2020-05-10 07:08:02 +00:00
clearfriction();
2020-10-22 21:17:51 +00:00
DukeStatIterator it(STAT_EFFECTOR);
while (auto act = it.Next())
2020-05-10 07:08:02 +00:00
{
2021-11-20 23:33:17 +00:00
auto sc = act->sector();
int st = act->spr.lotag;
2020-05-10 07:08:02 +00:00
switch (st)
{
case SE_0_ROTATING_SECTOR:
2022-01-19 09:48:18 +00:00
handle_se00(act);
2020-05-10 07:08:02 +00:00
break;
2020-05-10 07:08:02 +00:00
case SE_1_PIVOT: //Nothing for now used as the pivot
2020-10-22 21:17:51 +00:00
handle_se01(act);
2020-05-10 07:08:02 +00:00
break;
2020-05-10 07:08:02 +00:00
case SE_6_SUBWAY:
2020-10-22 21:17:51 +00:00
handle_se06_r(act);
break;
2020-05-10 07:08:02 +00:00
case SE_14_SUBWAY_CAR:
2020-10-22 21:17:51 +00:00
handle_se14(act, false, RPG, JIBS6);
2020-05-10 07:08:02 +00:00
break;
case SE_30_TWO_WAY_TRAIN:
2020-10-22 21:17:51 +00:00
handle_se30(act, JIBS6);
2020-05-10 07:08:02 +00:00
break;
case SE_2_EARTHQUAKE:
2020-10-22 21:17:51 +00:00
handle_se02(act);
2020-05-10 07:08:02 +00:00
break;
//Flashing sector lights after reactor EXPLOSION2
case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT:
2020-10-22 21:17:51 +00:00
handle_se03(act);
2020-05-10 07:08:02 +00:00
break;
case SE_4_RANDOM_LIGHTS:
2020-10-22 21:17:51 +00:00
handle_se04(act);
2020-05-10 07:08:02 +00:00
break;
//BOSS
case SE_5_BOSS:
2020-10-22 21:17:51 +00:00
handle_se05(act, FIRELASER);
2020-05-10 07:08:02 +00:00
break;
case SE_8_UP_OPEN_DOOR_LIGHTS:
case SE_9_DOWN_OPEN_DOOR_LIGHTS:
2020-10-22 21:17:51 +00:00
handle_se08(act, true);
2020-05-10 07:08:02 +00:00
break;
case SE_10_DOOR_AUTO_CLOSE:
2020-10-22 21:17:51 +00:00
handle_se10(act, nullptr);
2020-05-10 07:08:02 +00:00
break;
2020-10-22 21:17:51 +00:00
2020-05-10 07:08:02 +00:00
case SE_11_SWINGING_DOOR:
2020-10-22 21:17:51 +00:00
handle_se11(act);
2020-05-10 07:08:02 +00:00
break;
2020-05-10 07:08:02 +00:00
case SE_12_LIGHT_SWITCH:
2020-10-22 21:17:51 +00:00
handle_se12(act);
2020-05-10 07:08:02 +00:00
break;
case SE_47_LIGHT_SWITCH:
2020-10-22 21:17:51 +00:00
if (isRRRA()) handle_se12(act, 1);
2020-05-10 07:08:02 +00:00
break;
2020-05-10 07:08:02 +00:00
case SE_48_LIGHT_SWITCH:
2020-10-22 21:17:51 +00:00
if (isRRRA()) handle_se12(act, 2);
2020-05-10 07:08:02 +00:00
break;
2020-05-10 07:08:02 +00:00
case SE_13_EXPLOSIVE:
2020-10-22 21:17:51 +00:00
handle_se13(act);
2020-05-10 07:08:02 +00:00
break;
case SE_15_SLIDING_DOOR:
2020-10-22 21:17:51 +00:00
handle_se15(act);
2020-05-10 07:08:02 +00:00
break;
case SE_16_REACTOR:
2020-10-22 21:17:51 +00:00
handle_se16(act, REACTOR, REACTOR2);
2020-05-10 07:08:02 +00:00
break;
case SE_17_WARP_ELEVATOR:
2020-10-22 21:17:51 +00:00
handle_se17(act);
2020-05-10 07:08:02 +00:00
break;
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
2020-10-22 21:17:51 +00:00
handle_se18(act, true);
2020-05-10 07:08:02 +00:00
break;
case SE_19_EXPLOSION_LOWERS_CEILING:
2020-10-22 21:17:51 +00:00
handle_se19(act, BIGFORCE);
2020-05-10 07:08:02 +00:00
break;
case SE_20_STRETCH_BRIDGE:
2020-10-22 21:17:51 +00:00
handle_se20(act);
2020-05-10 07:08:02 +00:00
break;
case SE_21_DROP_FLOOR:
2020-10-22 21:17:51 +00:00
handle_se21(act);
2020-05-10 07:08:02 +00:00
break;
case SE_22_TEETH_DOOR:
2020-10-22 21:17:51 +00:00
handle_se22(act);
2020-05-10 07:08:02 +00:00
break;
case 156:
if (!isRRRA()) break;
[[fallthrough]];
2020-05-10 07:08:02 +00:00
case SE_24_CONVEYOR:
2020-11-27 19:06:38 +00:00
case SE_34:
{
handle_se24(act, st != 156, 1);
2020-05-10 07:08:02 +00:00
break;
}
2020-10-21 22:50:01 +00:00
2020-11-27 19:06:38 +00:00
case SE_35:
2020-10-22 21:17:51 +00:00
handle_se35(act, SMALLSMOKE, EXPLOSION2);
2020-05-10 07:08:02 +00:00
break;
2020-11-27 19:06:38 +00:00
case SE_25_PISTON: //PISTONS
if (act->temp_data[4] == 0) break;
2020-10-22 21:17:51 +00:00
handle_se25(act, 4, isRRRA() ? 371 : -1, isRRRA() ? 167 : -1);
2020-05-10 07:08:02 +00:00
break;
2020-11-27 19:06:38 +00:00
case SE_26:
2020-10-22 21:17:51 +00:00
handle_se26(act);
2020-05-10 07:08:02 +00:00
break;
case SE_27_DEMO_CAM:
2020-10-22 21:17:51 +00:00
handle_se27(act);
2020-05-10 07:08:02 +00:00
break;
2020-11-27 19:06:38 +00:00
case SE_29_WAVES:
act->spr.hitag += 64;
l = MulScale(act->spr.yvel, bsin(act->spr.hitag), 12);
sc->setfloorz(act->spr.pos.Z + l);
2020-05-10 07:08:02 +00:00
break;
2020-11-27 19:06:38 +00:00
case SE_31_FLOOR_RISE_FALL: // True Drop Floor
2020-10-22 21:17:51 +00:00
handle_se31(act, false);
2020-05-10 07:08:02 +00:00
break;
2020-11-27 19:06:38 +00:00
case SE_32_CEILING_RISE_FALL: // True Drop Ceiling
2020-10-22 21:17:51 +00:00
handle_se32(act);
2020-05-10 07:08:02 +00:00
break;
2020-11-27 19:06:38 +00:00
case SE_33_QUAKE_DEBRIS:
2020-05-10 07:08:02 +00:00
if (earthquaketime > 0 && (krand() & 7) == 0)
2020-10-22 21:17:51 +00:00
RANDOMSCRAP(act);
2020-05-10 07:08:02 +00:00
break;
2020-11-27 19:06:38 +00:00
case SE_36_PROJ_SHOOTER:
2020-05-10 07:08:02 +00:00
if (act->temp_data[0])
2020-05-10 07:08:02 +00:00
{
if (act->temp_data[0] == 1)
fi.shoot(act, sc->extra);
else if (act->temp_data[0] == 26 * 5)
act->temp_data[0] = 0;
act->temp_data[0]++;
2020-05-10 07:08:02 +00:00
}
break;
case SE_128_GLASS_BREAKING:
2020-10-22 21:17:51 +00:00
handle_se128(act);
2020-05-10 07:08:02 +00:00
break;
2020-11-27 19:06:38 +00:00
case SE_130:
2020-10-22 21:17:51 +00:00
handle_se130(act, 80, EXPLOSION2);
2020-05-10 07:08:02 +00:00
break;
2020-11-27 19:06:38 +00:00
case SE_131:
2020-10-22 21:17:51 +00:00
handle_se130(act, 40, EXPLOSION2);
2020-05-10 07:08:02 +00:00
break;
}
}
//Sloped sin-wave floors!
it.Reset(STAT_EFFECTOR);
2020-10-22 21:17:51 +00:00
while (auto act = it.Next())
2020-05-10 07:08:02 +00:00
{
if (act->spr.lotag != SE_29_WAVES) continue;
2021-11-20 23:33:17 +00:00
auto sc = act->sector();
2020-05-10 07:08:02 +00:00
if (sc->wallnum != 4) continue;
2021-11-16 17:07:24 +00:00
auto wal = sc->firstWall() + 2;
alignflorslope(act->sector(), wal->pos.X, wal->pos.Y, wal->nextSector()->floorz);
2020-05-10 07:08:02 +00:00
}
}
2020-05-07 12:55:04 +00:00
2020-05-13 22:04:14 +00:00
//---------------------------------------------------------------------------
//
// game specific part of makeitfall.
//
//---------------------------------------------------------------------------
2020-10-21 23:11:38 +00:00
int adjustfall(DDukeActor *actor, int c)
2020-05-13 22:04:14 +00:00
{
if ((actor->spr.picnum == BIKERB || actor->spr.picnum == CHEERB) && c == gs.gravity)
c = gs.gravity>>2;
else if (actor->spr.picnum == BIKERBV2 && c == gs.gravity)
c = gs.gravity>>3;
2020-05-13 22:04:14 +00:00
return c;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-11-01 14:56:50 +00:00
void move_r(DDukeActor *actor, int pnum, int xvel)
2020-05-13 22:04:14 +00:00
{
int l;
int goalang, angdif;
2020-05-13 22:04:14 +00:00
int daxvel;
2021-12-21 19:02:06 +00:00
int a = actor->spr.hitag;
2020-05-13 22:04:14 +00:00
if (a == -1) a = 0;
actor->temp_data[0]++;
2020-05-13 22:04:14 +00:00
if (a & face_player)
{
2020-11-02 23:20:51 +00:00
if (ps[pnum].newOwner != nullptr)
goalang = getangle(ps[pnum].opos.X - actor->spr.pos.X, ps[pnum].opos.Y - actor->spr.pos.Y);
else goalang = getangle(ps[pnum].pos.X - actor->spr.pos.X, ps[pnum].pos.Y - actor->spr.pos.Y);
2021-12-21 19:02:06 +00:00
angdif = getincangle(actor->spr.ang, goalang) >> 2;
2020-05-13 22:04:14 +00:00
if (angdif > -8 && angdif < 0) angdif = 0;
2021-12-21 19:02:06 +00:00
actor->spr.ang += angdif;
2020-05-13 22:04:14 +00:00
}
if (a & spin)
actor->spr.ang += bsin(actor->temp_data[0] << 3, -6);
2020-05-13 22:04:14 +00:00
if (a & face_player_slow)
{
2020-11-02 23:20:51 +00:00
if (ps[pnum].newOwner != nullptr)
goalang = getangle(ps[pnum].opos.X - actor->spr.pos.X, ps[pnum].opos.Y - actor->spr.pos.Y);
else goalang = getangle(ps[pnum].pos.X - actor->spr.pos.X, ps[pnum].pos.Y - actor->spr.pos.Y);
2021-12-21 19:02:06 +00:00
angdif = Sgn(getincangle(actor->spr.ang, goalang)) << 5;
2020-05-13 22:04:14 +00:00
if (angdif > -32 && angdif < 0)
{
angdif = 0;
2021-12-21 19:02:06 +00:00
actor->spr.ang = goalang;
2020-05-13 22:04:14 +00:00
}
2021-12-21 19:02:06 +00:00
actor->spr.ang += angdif;
2020-05-13 22:04:14 +00:00
}
if (isRRRA())
{
if (a & antifaceplayerslow)
{
2020-11-02 23:20:51 +00:00
if (ps[pnum].newOwner != nullptr)
goalang = (getangle(ps[pnum].opos.X - actor->spr.pos.X, ps[pnum].opos.Y - actor->spr.pos.Y) + 1024) & 2047;
else goalang = (getangle(ps[pnum].pos.X - actor->spr.pos.X, ps[pnum].pos.Y - actor->spr.pos.Y) + 1024) & 2047;
2021-12-21 19:02:06 +00:00
angdif = Sgn(getincangle(actor->spr.ang, goalang)) << 5;
2020-05-13 22:04:14 +00:00
if (angdif > -32 && angdif < 0)
{
angdif = 0;
2021-12-21 19:02:06 +00:00
actor->spr.ang = goalang;
2020-05-13 22:04:14 +00:00
}
2021-12-21 19:02:06 +00:00
actor->spr.ang += angdif;
2020-05-13 22:04:14 +00:00
}
if ((a & jumptoplayer) == jumptoplayer)
{
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == CHEER)
2020-05-13 22:04:14 +00:00
{
if (actor->temp_data[0] < 16)
actor->spr.zvel -= bcos(actor->temp_data[0] << 4) / 40;
2020-05-13 22:04:14 +00:00
}
else
{
if (actor->temp_data[0] < 16)
actor->spr.zvel -= bcos(actor->temp_data[0] << 4, -5);
2020-05-13 22:04:14 +00:00
}
}
if (a & justjump1)
{
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == RABBIT)
2020-05-13 22:04:14 +00:00
{
if (actor->temp_data[0] < 8)
actor->spr.zvel -= bcos(actor->temp_data[0] << 4) / 30;
2020-05-13 22:04:14 +00:00
}
2021-12-21 19:02:06 +00:00
else if (actor->spr.picnum == MAMA)
2020-05-13 22:04:14 +00:00
{
if (actor->temp_data[0] < 8)
actor->spr.zvel -= bcos(actor->temp_data[0] << 4) / 35;
2020-05-13 22:04:14 +00:00
}
}
if (a & justjump2)
{
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == RABBIT)
2020-05-13 22:04:14 +00:00
{
if (actor->temp_data[0] < 8)
actor->spr.zvel -= bcos(actor->temp_data[0] << 4) / 24;
2020-05-13 22:04:14 +00:00
}
2021-12-21 19:02:06 +00:00
else if (actor->spr.picnum == MAMA)
2020-05-13 22:04:14 +00:00
{
if (actor->temp_data[0] < 8)
actor->spr.zvel -= bcos(actor->temp_data[0] << 4) / 28;
2020-05-13 22:04:14 +00:00
}
}
if (a & windang)
{
if (actor->temp_data[0] < 8)
actor->spr.zvel -= bcos(actor->temp_data[0] << 4) / 24;
2020-05-13 22:04:14 +00:00
}
}
else if ((a & jumptoplayer) == jumptoplayer)
{
if (actor->temp_data[0] < 16)
actor->spr.zvel -= bcos(actor->temp_data[0] << 4, -5);
2020-05-13 22:04:14 +00:00
}
if (a & face_player_smart)
{
2020-10-02 20:14:20 +00:00
int newx, newy;
2020-05-13 22:04:14 +00:00
newx = ps[pnum].pos.X + (ps[pnum].vel.X / 768);
newy = ps[pnum].pos.Y + (ps[pnum].vel.Y / 768);
goalang = getangle(newx - actor->spr.pos.X, newy - actor->spr.pos.Y);
2021-12-21 19:02:06 +00:00
angdif = getincangle(actor->spr.ang, goalang) >> 2;
2020-05-13 22:04:14 +00:00
if (angdif > -8 && angdif < 0) angdif = 0;
2021-12-21 19:02:06 +00:00
actor->spr.ang += angdif;
2020-05-13 22:04:14 +00:00
}
if (actor->temp_data[1] == 0 || a == 0)
2020-05-13 22:04:14 +00:00
{
2021-12-30 17:21:02 +00:00
if ((badguy(actor) && actor->spr.extra <= 0) || (actor->opos.X != actor->spr.pos.X) || (actor->opos.Y != actor->spr.pos.Y))
2020-05-13 22:04:14 +00:00
{
actor->backupvec2();
2021-12-21 19:02:06 +00:00
SetActor(actor, actor->spr.pos);
2020-05-13 22:04:14 +00:00
}
2021-12-21 19:02:06 +00:00
if (badguy(actor) && actor->spr.extra <= 0)
2020-05-13 22:04:14 +00:00
{
if (actor->sector()->ceilingstat & CSTAT_SECTOR_SKY)
2020-05-13 22:04:14 +00:00
{
if (actor->sector()->shadedsector == 1)
2020-05-13 22:04:14 +00:00
{
2021-12-21 19:02:06 +00:00
actor->spr.shade += (16 - actor->spr.shade) >> 1;
2020-05-13 22:04:14 +00:00
}
else
{
actor->spr.shade += (actor->sector()->ceilingshade - actor->spr.shade) >> 1;
2020-05-13 22:04:14 +00:00
}
}
else
{
actor->spr.shade += (actor->sector()->floorshade - actor->spr.shade) >> 1;
2020-05-13 22:04:14 +00:00
}
}
return;
}
auto moveptr = &ScriptCode[actor->temp_data[1]];
2020-05-13 22:04:14 +00:00
2021-12-21 19:02:06 +00:00
if (a & geth) actor->spr.xvel += (*moveptr - actor->spr.xvel) >> 1;
if (a & getv) actor->spr.zvel += ((*(moveptr + 1) << 4) - actor->spr.zvel) >> 1;
2020-05-13 22:04:14 +00:00
if (a & dodgebullet)
2020-10-22 21:41:07 +00:00
dodge(actor);
2020-05-13 22:04:14 +00:00
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum != APLAYER)
2020-11-01 14:56:50 +00:00
alterang(a, actor, pnum);
2020-05-13 22:04:14 +00:00
2021-12-21 19:02:06 +00:00
if (actor->spr.xvel > -6 && actor->spr.xvel < 6) actor->spr.xvel = 0;
2020-05-13 22:04:14 +00:00
2020-10-22 21:41:07 +00:00
a = badguy(actor);
2020-05-13 22:04:14 +00:00
2021-12-21 19:02:06 +00:00
if (actor->spr.xvel || actor->spr.zvel)
2020-05-13 22:04:14 +00:00
{
if (a)
{
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == DRONE && actor->spr.extra > 0)
2020-05-13 22:04:14 +00:00
{
2021-12-21 19:02:06 +00:00
if (actor->spr.zvel > 0)
2020-05-13 22:04:14 +00:00
{
actor->floorz = l = getflorzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
2020-05-13 22:04:14 +00:00
if (isRRRA())
{
if (actor->spr.pos.Z > (l - (28 << 8)))
actor->spr.pos.Z = l - (28 << 8);
2020-05-13 22:04:14 +00:00
}
else
{
if (actor->spr.pos.Z > (l - (30 << 8)))
actor->spr.pos.Z = l - (30 << 8);
2020-05-13 22:04:14 +00:00
}
}
else
{
actor->ceilingz = l = getceilzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
if ((actor->spr.pos.Z - l) < (50 << 8))
2020-05-13 22:04:14 +00:00
{
actor->spr.pos.Z = l + (50 << 8);
2021-12-21 19:02:06 +00:00
actor->spr.zvel = 0;
2020-05-13 22:04:14 +00:00
}
}
}
if (actor->spr.zvel > 0 && actor->floorz < actor->spr.pos.Z)
actor->spr.pos.Z = actor->floorz;
2021-12-21 19:02:06 +00:00
if (actor->spr.zvel < 0)
2020-05-13 22:04:14 +00:00
{
l = getceilzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
if ((actor->spr.pos.Z - l) < (66 << 8))
2020-05-13 22:04:14 +00:00
{
actor->spr.pos.Z = l + (66 << 8);
2021-12-21 19:02:06 +00:00
actor->spr.zvel >>= 1;
2020-05-13 22:04:14 +00:00
}
}
}
2021-12-21 19:02:06 +00:00
else if (actor->spr.picnum == APLAYER)
if ((actor->spr.pos.Z - actor->ceilingz) < (32 << 8))
actor->spr.pos.Z = actor->ceilingz + (32 << 8);
2020-05-13 22:04:14 +00:00
2021-12-21 19:02:06 +00:00
daxvel = actor->spr.xvel;
angdif = actor->spr.ang;
2020-05-13 22:04:14 +00:00
if (a)
{
2021-12-21 19:02:06 +00:00
if (xvel < 960 && actor->spr.xrepeat > 16)
2020-05-13 22:04:14 +00:00
{
2020-11-01 14:56:50 +00:00
daxvel = -(1024 - xvel);
angdif = getangle(ps[pnum].pos.X - actor->spr.pos.X, ps[pnum].pos.Y - actor->spr.pos.Y);
2020-05-13 22:04:14 +00:00
2020-11-01 14:56:50 +00:00
if (xvel < 512)
2020-05-13 22:04:14 +00:00
{
ps[pnum].vel.X = 0;
ps[pnum].vel.Y = 0;
2020-05-13 22:04:14 +00:00
}
else
{
ps[pnum].vel.X = MulScale(ps[pnum].vel.X, gs.playerfriction - 0x2000, 16);
ps[pnum].vel.Y = MulScale(ps[pnum].vel.Y, gs.playerfriction - 0x2000, 16);
2020-05-13 22:04:14 +00:00
}
}
2021-12-21 19:02:06 +00:00
else if ((isRRRA() && actor->spr.picnum != DRONE && actor->spr.picnum != SHARK && actor->spr.picnum != UFO1_RRRA) ||
(!isRRRA() && actor->spr.picnum != DRONE && actor->spr.picnum != SHARK && actor->spr.picnum != UFO1_RR
&& actor->spr.picnum != UFO2 && actor->spr.picnum != UFO3 && actor->spr.picnum != UFO4 && actor->spr.picnum != UFO5))
2020-05-13 22:04:14 +00:00
{
2021-12-30 17:21:02 +00:00
if (actor->opos.Z != actor->spr.pos.Z || (ud.multimode < 2 && ud.player_skill < 2))
2020-05-13 22:04:14 +00:00
{
if ((actor->temp_data[0] & 1) || ps[pnum].actorsqu == actor) return;
2020-05-13 22:04:14 +00:00
else daxvel <<= 1;
}
else
{
if ((actor->temp_data[0] & 3) || ps[pnum].actorsqu == actor) return;
2020-05-13 22:04:14 +00:00
else daxvel <<= 2;
}
}
}
if (isRRRA())
{
if (actor->sector()->lotag != 1)
2020-05-13 22:04:14 +00:00
{
2021-12-21 19:02:06 +00:00
switch (actor->spr.picnum)
2020-05-13 22:04:14 +00:00
{
case MINIONBOAT:
case HULKBOAT:
case CHEERBOAT:
daxvel >>= 1;
break;
}
}
else if (actor->sector()->lotag == 1)
2020-05-13 22:04:14 +00:00
{
2021-12-21 19:02:06 +00:00
switch (actor->spr.picnum)
2020-05-13 22:04:14 +00:00
{
case BIKERB:
case BIKERBV2:
case CHEERB:
daxvel >>= 1;
break;
}
}
}
2020-10-22 21:41:07 +00:00
Collision coll;
actor->movflag = movesprite_ex(actor,
MulScale(daxvel, bcos(angdif), 14),
2021-12-21 19:02:06 +00:00
MulScale(daxvel, bsin(angdif), 14), actor->spr.zvel, CLIPMASK0, coll);
2020-05-13 22:04:14 +00:00
}
if (a)
{
if (actor->sector()->ceilingstat & CSTAT_SECTOR_SKY)
2020-05-13 22:04:14 +00:00
{
if (actor->sector()->shadedsector == 1)
2020-05-13 22:04:14 +00:00
{
2021-12-21 19:02:06 +00:00
actor->spr.shade += (16 - actor->spr.shade) >> 1;
2020-05-13 22:04:14 +00:00
}
else
{
actor->spr.shade += (actor->sector()->ceilingshade - actor->spr.shade) >> 1;
2020-05-13 22:04:14 +00:00
}
}
else actor->spr.shade += (actor->sector()->floorshade - actor->spr.shade) >> 1;
2020-05-13 22:04:14 +00:00
if (actor->sector()->floorpicnum == MIRROR)
2020-10-22 21:41:07 +00:00
deletesprite(actor);
2020-05-13 22:04:14 +00:00
}
}
void fakebubbaspawn(DDukeActor *actor, int g_p)
2020-05-14 07:07:07 +00:00
{
fakebubba_spawn++;
switch (fakebubba_spawn)
{
default:
break;
case 1:
spawn(actor, PIG);
2020-05-14 07:07:07 +00:00
break;
case 2:
spawn(actor, MINION);
2020-05-14 07:07:07 +00:00
break;
case 3:
spawn(actor, CHEER);
2020-05-14 07:07:07 +00:00
break;
case 4:
spawn(actor, VIXEN);
2020-11-02 18:54:20 +00:00
operateactivators(666, g_p);
2020-05-14 07:07:07 +00:00
break;
}
}
//---------------------------------------------------------------------------
//
// special checks in fall that only apply to RR.
2020-05-14 07:07:07 +00:00
//
//---------------------------------------------------------------------------
2020-11-01 09:49:50 +00:00
static int fallspecial(DDukeActor *actor, int playernum)
2020-05-14 07:07:07 +00:00
{
int sphit = 0;
if (isRRRA())
{
if (actor->sector()->lotag == 801)
2020-05-14 07:07:07 +00:00
{
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == ROCK)
2020-05-14 07:07:07 +00:00
{
spawn(actor, ROCK2);
spawn(actor, ROCK2);
addspritetodelete();
2020-05-14 07:07:07 +00:00
}
return 0;
}
else if (actor->sector()->lotag == 802)
2020-05-14 07:07:07 +00:00
{
if (actor->spr.picnum != APLAYER && badguy(actor) && actor->spr.pos.Z == actor->floorz - FOURSLEIGHT)
2020-05-14 07:07:07 +00:00
{
2020-10-22 17:21:21 +00:00
fi.guts(actor, JIBS6, 5, playernum);
S_PlayActorSound(SQUISHED, actor);
addspritetodelete();
2020-05-14 07:07:07 +00:00
}
return 0;
}
else if (actor->sector()->lotag == 803)
2020-05-14 07:07:07 +00:00
{
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == ROCK2)
addspritetodelete();
2020-05-14 07:07:07 +00:00
return 0;
}
}
if (actor->sector()->lotag == 800)
2020-05-14 07:07:07 +00:00
{
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum == 40)
2020-05-14 07:07:07 +00:00
{
addspritetodelete();
2020-05-14 07:07:07 +00:00
return 0;
}
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum != APLAYER && (badguy(actor) || actor->spr.picnum == HEN || actor->spr.picnum == COW || actor->spr.picnum == PIG || actor->spr.picnum == DOGRUN || actor->spr.picnum == RABBIT) && (!isRRRA() || actor->spriteextra < 128))
2020-05-14 07:07:07 +00:00
{
actor->spr.pos.Z = actor->floorz - FOURSLEIGHT;
2021-12-21 19:02:06 +00:00
actor->spr.zvel = 8000;
actor->spr.extra = 0;
actor->spriteextra++;
2020-05-14 07:07:07 +00:00
sphit = 1;
}
2021-12-21 19:02:06 +00:00
else if (actor->spr.picnum != APLAYER)
2020-05-14 07:07:07 +00:00
{
if (!actor->spriteextra)
addspritetodelete();
2020-05-14 07:07:07 +00:00
return 0;
}
actor->attackertype = SHOTSPARK1;
actor->hitextra = 1;
2020-05-14 07:07:07 +00:00
}
else if (isRRRA() && (actor->sector()->floorpicnum == RRTILE7820 || actor->sector()->floorpicnum == RRTILE7768))
2020-05-14 07:07:07 +00:00
{
2021-12-21 19:02:06 +00:00
if (actor->spr.picnum != MINION && actor->spr.pal != 19)
2020-05-14 07:07:07 +00:00
{
if ((krand() & 3) == 1)
{
actor->attackertype = SHOTSPARK1;
actor->hitextra = 5;
2020-05-14 07:07:07 +00:00
}
}
}
return sphit;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void fall_r(DDukeActor* ac, int g_p)
2020-05-14 07:07:07 +00:00
{
fall_common(ac, g_p, JIBS6, DRONE, BLOODPOOL, SHOTSPARK1, 69, 158, fallspecial);
2020-05-14 07:07:07 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-22 21:41:07 +00:00
void destroyit(DDukeActor *actor)
{
int lotag = 0, hitag = 0;
DDukeActor* spr = nullptr;
2021-11-21 08:05:58 +00:00
DukeSectIterator it1(actor->sector());
2020-10-22 21:41:07 +00:00
while (auto a2 = it1.Next())
{
if (a2->spr.picnum == RRTILE63)
{
lotag = a2->spr.lotag;
2020-10-22 21:41:07 +00:00
spr = a2;
if (a2->spr.hitag)
hitag = a2->spr.hitag;
}
}
2020-10-22 21:41:07 +00:00
DukeStatIterator it(STAT_DESTRUCT);
while (auto a2 = it.Next())
{
auto it_sect = a2->sector();
if (hitag && hitag == a2->spr.hitag)
2020-10-22 21:41:07 +00:00
{
DukeSectIterator its(it_sect);
while (auto a3 = its.Next())
{
if (a3->spr.picnum == DESTRUCTO)
{
a3->attackertype = SHOTSPARK1;
a3->hitextra = 1;
}
}
2020-10-22 21:41:07 +00:00
}
if (spr && spr->sector() != it_sect)
if (lotag == a2->spr.lotag)
{
auto sect = spr->sector();
2021-11-20 23:33:17 +00:00
auto destsect = spr->sector();
auto srcsect = it_sect;
2021-11-16 17:07:24 +00:00
auto destwal = destsect->firstWall();
auto srcwal = srcsect->firstWall();
for (int i = 0; i < destsect->wallnum; i++, srcwal++, destwal++)
{
2021-11-16 17:07:24 +00:00
destwal->picnum = srcwal->picnum;
destwal->overpicnum = srcwal->overpicnum;
destwal->shade = srcwal->shade;
destwal->xrepeat = srcwal->xrepeat;
destwal->yrepeat = srcwal->yrepeat;
destwal->xpan_ = srcwal->xpan_;
destwal->ypan_ = srcwal->ypan_;
if (isRRRA() && destwal->twoSided())
{
2021-11-16 17:07:24 +00:00
destwal->cstat = 0;
destwal->nextWall()->cstat = 0;
}
}
destsect->setfloorz(srcsect->floorz);
destsect->setceilingz(srcsect->ceilingz);
destsect->ceilingstat = srcsect->ceilingstat;
destsect->floorstat = srcsect->floorstat;
destsect->ceilingpicnum = srcsect->ceilingpicnum;
destsect->ceilingheinum = srcsect->ceilingheinum;
destsect->ceilingshade = srcsect->ceilingshade;
destsect->ceilingpal = srcsect->ceilingpal;
destsect->ceilingxpan_ = srcsect->ceilingxpan_;
destsect->ceilingypan_ = srcsect->ceilingypan_;
destsect->floorpicnum = srcsect->floorpicnum;
destsect->floorheinum = srcsect->floorheinum;
destsect->floorshade = srcsect->floorshade;
destsect->floorpal = srcsect->floorpal;
destsect->floorxpan_ = srcsect->floorxpan_;
destsect->floorypan_ = srcsect->floorypan_;
destsect->visibility = srcsect->visibility;
destsect->keyinfo = srcsect->keyinfo;
destsect->lotag = srcsect->lotag;
destsect->hitag = srcsect->hitag;
destsect->extra = srcsect->extra;
}
}
it1.Reset(actor->sector());
while (auto a2 = it1.Next())
{
switch (a2->spr.picnum)
{
case DESTRUCTO:
case RRTILE63:
case TORNADO:
case APLAYER:
case COOT:
break;
default:
2020-10-22 21:41:07 +00:00
deletesprite(a2);
break;
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void mamaspawn(DDukeActor *actor)
{
if (mamaspawn_count)
{
mamaspawn_count--;
spawn(actor, RABBIT);
}
}
2020-05-14 17:23:36 +00:00
bool spawnweapondebris_r(int picnum, int dnum)
{
return dnum == SCRAP1;
}
void respawnhitag_r(DDukeActor *actor)
2020-05-14 17:23:36 +00:00
{
switch (actor->spr.picnum)
2020-05-14 17:23:36 +00:00
{
case FEM10:
case NAKED1:
case STATUE:
if (actor->spr.yvel) fi.operaterespawns(actor->spr.yvel);
2020-05-14 17:23:36 +00:00
break;
default:
if (actor->spr.hitag >= 0) fi.operaterespawns(actor->spr.hitag);
2020-05-14 17:23:36 +00:00
break;
}
}
2020-06-23 19:12:15 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void thunder(void);
void think_r(void)
{
thinktime.Reset();
thinktime.Clock();
recordoldspritepos();
2020-06-23 19:12:15 +00:00
movefta(); //ST 2
2020-06-23 19:12:15 +00:00
moveweapons_r(); //ST 4
movetransports_r(); //ST 9
moveplayers(); //ST 10
movefallers_r(); //ST 12
moveexplosions_r(); //ST 5
actortime.Reset();
actortime.Clock();
moveactors_r(); //ST 1
actortime.Unclock();
moveeffectors_r(); //ST 3
movestandables_r(); //ST 6
doanimations();
movefx(); //ST 11
if (numplayers < 2 && thunderon)
thunder();
thinktime.Unclock();
}
2020-05-07 12:55:04 +00:00
END_DUKE_NS