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

2108 lines
49 KiB
C++
Raw Normal View History

2020-05-07 12:55:04 +00:00
//-------------------------------------------------------------------------
/*
Copyright (C) 1996, 2003 - 3D Realms Entertainment
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
Copyright (C) 2020 - Christoph Oelckers
This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition
Duke Nukem 3D is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Original Source: 1996 - Todd Replogle
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
EDuke enhancements integrated: 04/13/2003 - Matt Saettler
Note: EDuke source was in transition. Changes are in-progress in the
source as it is released.
This file contains parts of DukeGDX by Alexander Makarov-[M210] (m210-2007@mail.ru)
2020-05-07 12:55:04 +00:00
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "global.h"
#include "names_d.h"
#include "serializer.h"
#include "dukeactor.h"
2020-05-07 12:55:04 +00:00
BEGIN_DUKE_NS
2020-05-16 10:47:01 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-22 17:08:10 +00:00
void check_fta_sounds_d(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 LIZTROOPONTOILET:
case LIZTROOPJUSTSIT:
case LIZTROOPSHOOT:
case LIZTROOPJETPACK:
case LIZTROOPDUCKING:
case LIZTROOPRUNNING:
case LIZTROOP:
2020-10-22 17:08:10 +00:00
S_PlayActorSound(PRED_RECOG, actor);
2020-05-16 10:47:01 +00:00
break;
case LIZMAN:
case LIZMANSPITTING:
case LIZMANFEEDING:
case LIZMANJUMP:
2020-10-22 17:08:10 +00:00
S_PlayActorSound(CAPT_RECOG, actor);
2020-05-16 10:47:01 +00:00
break;
case PIGCOP:
case PIGCOPDIVE:
2020-10-22 17:08:10 +00:00
S_PlayActorSound(PIG_RECOG, actor);
2020-05-16 10:47:01 +00:00
break;
case RECON:
2020-10-22 17:08:10 +00:00
S_PlayActorSound(RECO_RECOG, actor);
2020-05-16 10:47:01 +00:00
break;
case DRONE:
2020-10-22 17:08:10 +00:00
S_PlayActorSound(DRON_RECOG, actor);
2020-05-16 10:47:01 +00:00
break;
case COMMANDER:
case COMMANDERSTAYPUT:
2020-10-22 17:08:10 +00:00
S_PlayActorSound(COMM_RECOG, actor);
2020-05-16 10:47:01 +00:00
break;
case ORGANTIC:
2020-10-22 17:08:10 +00:00
S_PlayActorSound(TURR_RECOG, actor);
2020-05-16 10:47:01 +00:00
break;
case OCTABRAIN:
case OCTABRAINSTAYPUT:
2020-10-22 17:08:10 +00:00
S_PlayActorSound(OCTA_RECOG, actor);
2020-05-16 10:47:01 +00:00
break;
case BOSS1:
S_PlaySound(BOS1_RECOG);
2020-05-16 10:47:01 +00:00
break;
case BOSS2:
if (actor->spr.pal == 1)
S_PlaySound(BOS2_RECOG);
else S_PlaySound(WHIPYOURASS);
2020-05-16 10:47:01 +00:00
break;
case BOSS3:
if (actor->spr.pal == 1)
S_PlaySound(BOS3_RECOG);
else S_PlaySound(RIPHEADNECK);
2020-05-16 10:47:01 +00:00
break;
case BOSS4:
case BOSS4STAYPUT:
if (actor->spr.pal == 1)
S_PlaySound(BOS4_RECOG);
S_PlaySound(BOSS4_FIRSTSEE);
2020-05-16 10:47:01 +00:00
break;
}
}
2020-05-07 12:55:04 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void addweapon_d(player_struct *p, int weapon, bool wswitch)
2020-05-07 12:55:04 +00:00
{
if ( p->gotweapon[weapon] == 0 )
2020-05-07 12:55:04 +00:00
{
p->gotweapon[weapon] = true;
if (weapon == SHRINKER_WEAPON)
p->gotweapon[GROW_WEAPON] = true;
2020-05-07 12:55:04 +00:00
}
if (!wswitch) return;
2020-05-07 12:55:04 +00:00
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;
p->curr_weapon = weapon;
p->wantweaponfire = -1;
2020-05-07 12:55:04 +00:00
switch (weapon)
{
case KNEE_WEAPON:
case TRIPBOMB_WEAPON:
case HANDREMOTE_WEAPON:
case HANDBOMB_WEAPON:
2020-05-07 12:55:04 +00:00
break;
case SHOTGUN_WEAPON:
2020-10-22 17:12:48 +00:00
S_PlayActorSound(SHOTGUN_COCK, p->GetActor());
2020-05-07 12:55:04 +00:00
break;
case PISTOL_WEAPON:
2020-10-22 17:12:48 +00:00
S_PlayActorSound(INSERT_CLIP, p->GetActor());
2020-05-07 12:55:04 +00:00
break;
default:
2020-10-22 17:12:48 +00:00
S_PlayActorSound(SELECT_WEAPON, p->GetActor());
2020-05-07 12:55:04 +00:00
break;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-22 17:12:48 +00:00
bool ifsquished(DDukeActor* actor, int p)
2020-05-07 12:55:04 +00:00
{
if (isRR()) return false; // this function is a no-op in RR's source.
bool squishme = false;
if (actor->isPlayer() && ud.clipping)
2020-05-07 12:55:04 +00:00
return false;
auto sectp = actor->sector();
double floorceildist = sectp->floorz - sectp->ceilingz;
2020-05-07 12:55:04 +00:00
if (sectp->lotag != ST_23_SWINGING_DOOR)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:13:49 +00:00
if (actor->spr.pal == 1)
squishme = floorceildist < 32 && (sectp->lotag & 32768) == 0;
2020-05-07 12:55:04 +00:00
else
squishme = floorceildist < 12;
2020-05-07 12:55:04 +00:00
}
if (squishme)
{
FTA(QUOTE_SQUISHED, &ps[p]);
2020-10-22 17:12:48 +00:00
if (badguy(actor))
2022-09-03 08:02:25 +00:00
actor->vel.X = 0;
2020-05-07 12:55:04 +00:00
2021-12-21 18:13:49 +00:00
if (actor->spr.pal == 1)
2020-05-07 12:55:04 +00:00
{
actor->attackertype = SHOTSPARK1;
actor->hitextra = 1;
2020-05-07 12:55:04 +00:00
return false;
}
return true;
}
return false;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int hp4)
2020-05-07 12:55:04 +00:00
{
double radius = r * inttoworld;
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-11-15 23:19:34 +00:00
if(actor->spr.picnum != SHRINKSPARK && !(actor->spr.picnum == RPG && actor->spr.scale.X < 0.171875))
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) < radius * 16) // what value range is this supposed to be? The check that was here did not multiply correctly
2020-05-07 12:55:04 +00:00
{
2022-11-15 14:44:33 +00:00
auto wal = dasectp->walls.Data();
double d = (wal->pos - actor->spr.pos.XY()).Sum();
if (d < radius)
fi.checkhitceiling(dasectp);
2020-05-07 12:55:04 +00:00
else
{
auto thirdpoint = wal->point2Wall()->point2Wall();
d = (thirdpoint->pos - actor->spr.pos.XY()).Sum();
if (d < radius)
fi.checkhitceiling(dasectp);
2020-05-07 12:55:04 +00:00
}
}
2022-11-15 14:24:17 +00:00
for (auto& wal : dasectp->walls)
{
if ((wal.pos - actor->spr.pos.XY()).Sum() < radius)
2020-05-07 12:55:04 +00:00
{
if (wal.twoSided())
2020-05-07 12:55:04 +00:00
{
search.Add(wal.nextSector());
2020-05-07 12:55:04 +00:00
}
2022-08-22 16:39:33 +00:00
DVector3 w1(((wal.pos + wal.point2Wall()->pos) * 0.5 + actor->spr.pos) * 0.5, actor->spr.pos.Z); // half way between the actor and the wall's center.
2021-11-21 08:00:47 +00:00
sectortype* sect = wal.sectorp();
2022-08-22 16:39:33 +00:00
updatesector(w1, &sect);
if (sect && cansee(w1, sect, actor->spr.pos, actor->sector()))
2022-08-23 20:39:07 +00:00
fi.checkhitwall(actor, &wal, DVector3(wal.pos, actor->spr.pos.Z), actor->spr.picnum);
2020-05-07 12:55:04 +00:00
}
}
}
2021-11-15 23:19:34 +00:00
}
double q = zrand(32) - 16;
auto Owner = actor->GetOwner();
for (int x = 0; x < 7; x++)
2020-05-07 12:55:04 +00:00
{
DukeStatIterator itj(statlist[x]);
while (auto act2 = itj.Next())
2020-05-07 12:55:04 +00:00
{
if (isWorldTour() && Owner)
2020-05-07 12:55:04 +00:00
{
if (Owner->isPlayer() && act2->isPlayer() && ud.coop != 0 && ud.ffire == 0 && Owner != act2)
2020-05-14 22:32:11 +00:00
{
2020-05-07 12:55:04 +00:00
continue;
2020-05-14 22:32:11 +00:00
}
2021-12-21 18:39:33 +00:00
if (actor->spr.picnum == FLAMETHROWERFLAME && ((Owner->spr.picnum == FIREFLY && act2->spr.picnum == FIREFLY) || (Owner->spr.picnum == BOSS5 && act2->spr.picnum == BOSS5)))
2020-05-14 22:32:11 +00:00
{
2020-05-07 12:55:04 +00:00
continue;
2020-05-14 22:32:11 +00:00
}
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:39:33 +00:00
if (actor->spr.picnum != SHRINKSPARK || (act2->spr.cstat & CSTAT_SPRITE_BLOCK_ALL))
if ((actor->spr.pos - act2->spr.pos).Length() < radius)
2020-05-07 12:55:04 +00:00
{
if (badguy(act2) && !cansee(act2->spr.pos.plusZ(q), act2->sector(), actor->spr.pos.plusZ(q), actor->sector()))
2020-10-12 19:30:12 +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
{
if (actor->spr.picnum == SHRINKSPARK && act2->spr.picnum != SHARK && (act2 == Owner || act2->spr.scale.X < 0.375))
2020-05-07 12:55:04 +00:00
{
continue;
}
2021-12-21 18:13:49 +00:00
if (actor->spr.picnum == MORTER && act2 == Owner)
{
continue;
}
double dist = (actor->getPosWithOffsetZ() - act2->spr.pos).Length();
if (dist < radius && cansee(act2->spr.pos.plusZ(-8), act2->sector(), actor->spr.pos.plusZ(-12), actor->sector()))
2020-05-07 12:55:04 +00:00
{
act2->hitang = (act2->spr.pos - actor->spr.pos).Angle();
2021-12-21 18:39:33 +00:00
if (actor->spr.picnum == RPG && act2->spr.extra > 0)
act2->attackertype = RPG;
else if (!isWorldTour())
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:13:49 +00:00
if (actor->spr.picnum == SHRINKSPARK)
act2->attackertype = SHRINKSPARK;
else act2->attackertype = RADIUSEXPLOSION;
2020-05-07 12:55:04 +00:00
}
else
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:13:49 +00:00
if (actor->spr.picnum == SHRINKSPARK || actor->spr.picnum == FLAMETHROWERFLAME)
act2-> attackertype = actor->spr.picnum;
else if (actor->spr.picnum != FIREBALL || !Owner || !Owner->isPlayer())
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:13:49 +00:00
if (actor->spr.picnum == LAVAPOOL)
act2->attackertype = FLAMETHROWERFLAME;
else
act2->attackertype = RADIUSEXPLOSION;
2020-05-07 12:55:04 +00:00
}
else
act2->attackertype = FLAMETHROWERFLAME;
}
2021-12-21 18:13:49 +00:00
if (actor->spr.picnum != SHRINKSPARK && (!isWorldTour() || actor->spr.picnum != LAVAPOOL))
{
if (dist < radius / 3)
2020-05-07 12:55:04 +00:00
{
if (hp4 == hp3) hp4++;
act2->hitextra = hp3 + (krand() % (hp4 - hp3));
2020-05-07 12:55:04 +00:00
}
else if (dist < 2 * radius / 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 (dist < radius)
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
}
2022-11-22 22:41:02 +00:00
if (!actorflag(act2, SFLAG2_NORADIUSPUSH) && !bossguy(act2))
2020-05-07 12:55:04 +00:00
{
2022-09-11 20:57:56 +00:00
if (act2->vel.X < 0) act2->vel.X = 0;
act2->vel.X += ( (actor->spr.extra / 4.));
2020-05-07 12:55:04 +00:00
}
if (actorflag(act2, SFLAG_HITRADIUSCHECK))
fi.checkhitsprite(act2, actor);
}
else if (actor->spr.extra == 0) act2->hitextra = 0;
2021-12-21 18:39:33 +00:00
if (act2->spr.picnum != RADIUSEXPLOSION && Owner && Owner->spr.statnum < MAXSTATUS)
{
if (act2->isPlayer())
2020-05-07 12:55:04 +00:00
{
int p = act2->spr.yint;
if (isWorldTour() && act2->attackertype == FLAMETHROWERFLAME && Owner->isPlayer())
2020-05-07 12:55:04 +00:00
{
ps[p].numloogs = -1 - actor->spr.yint;
}
2020-11-02 23:20:51 +00:00
if (ps[p].newOwner != nullptr)
{
clearcamera(&ps[p]);
2020-05-07 12:55:04 +00:00
}
}
act2->SetHitOwner(actor->GetOwner());
2020-05-07 12:55:04 +00:00
}
}
}
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2022-09-13 18:09:29 +00:00
int movesprite_ex_d(DDukeActor* actor, const DVector3& change, unsigned int cliptype, Collision &result)
2020-05-07 12:55:04 +00:00
{
int bg = badguy(actor);
2020-05-07 12:55:04 +00:00
if (actor->spr.statnum == STAT_MISC || (bg && actor->spr.scale.X < 0.0625))
2020-05-07 12:55:04 +00:00
{
2022-09-13 18:09:29 +00:00
actor->spr.pos += change;
2020-05-07 12:55:04 +00:00
if (bg)
2022-02-06 21:45:47 +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
2022-08-29 20:27:45 +00:00
auto ppos = actor->spr.pos;
ppos.Z -= (tileHeight(actor->spr.picnum) * actor->spr.scale.Y) * 0.5;
2020-05-07 12:55:04 +00:00
if (bg)
{
if (actor->spr.scale.X > 0.9375 )
clipmove(ppos, &dasectp, change * 0.5, 64., 4., 4., cliptype, result);
2020-05-07 12:55:04 +00:00
else
{
double clipdist;
2021-12-21 18:13:49 +00:00
if (actor->spr.picnum == LIZMAN)
clipdist = 18.25;
else if (actorflag(actor, SFLAG_BADGUY))
clipdist = actor->clipdist;
2020-05-07 12:55:04 +00:00
else
clipdist = 12;
2020-05-07 12:55:04 +00:00
clipmove(ppos, &dasectp, change * 0.5, clipdist, 4., 4., cliptype, result);
2020-05-07 12:55:04 +00:00
}
// conditional code from hell...
2021-11-21 08:05:58 +00:00
if (dasectp == nullptr || (dasectp != nullptr &&
2021-11-18 19:55:22 +00:00
((actor->actorstayput != nullptr && actor->actorstayput != dasectp) ||
2021-12-21 18:13:49 +00:00
((actor->spr.picnum == BOSS2) && actor->spr.pal == 0 && dasectp->lotag != 3) ||
((actor->spr.picnum == BOSS1 || actor->spr.picnum == BOSS2) && dasectp->lotag == ST_1_ABOVE_WATER) ||
(dasectp->lotag == ST_1_ABOVE_WATER && (actor->spr.picnum == LIZMAN || (actor->spr.picnum == LIZTROOP && actor->vel.Z == 0)))
))
)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:13:49 +00:00
if (dasectp && dasectp->lotag == ST_1_ABOVE_WATER && actor->spr.picnum == LIZMAN)
actor->spr.Angles.Yaw = randomAngle();
2021-12-21 18:13:49 +00:00
else if ((actor->temp_data[0]&3) == 1 && actor->spr.picnum != COMMANDER)
actor->spr.Angles.Yaw = randomAngle();
2022-08-22 16:34:01 +00:00
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.Angles.Yaw += DAngle90 + DAngle45;
2020-05-07 12:55:04 +00:00
}
else
{
2021-12-21 18:13:49 +00:00
if (actor->spr.statnum == STAT_PROJECTILE)
clipmove(ppos, &dasectp, change * 0.5, 0.5, 4., 4., cliptype, result);
2020-05-07 12:55:04 +00:00
else
clipmove(ppos, &dasectp, change * 0.5, actor->clipdist, 4., 4., cliptype, result);
2020-05-07 12:55:04 +00:00
}
2022-08-29 20:27:45 +00:00
actor->spr.pos.XY() = ppos.XY();
2020-05-07 12:55:04 +00:00
2022-02-03 23:45:24 +00:00
if (dasectp != nullptr && dasectp != actor->sector())
ChangeActorSect(actor, dasectp);
2022-09-13 18:09:29 +00:00
double daz = actor->spr.pos.Z + change.Z * 0.5;
2022-02-03 23:45:24 +00:00
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
}
//---------------------------------------------------------------------------
//
//
2020-05-07 12:55:04 +00:00
//
//---------------------------------------------------------------------------
void lotsofmoney_d(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 lotsofmail_d(DDukeActor *actor, int n)
2020-05-07 12:55:04 +00:00
{
lotsofstuff(actor, n, MAIL);
2020-05-07 12:55:04 +00:00
}
void lotsofpaper_d(DDukeActor *actor, int n)
2020-05-07 12:55:04 +00:00
{
lotsofstuff(actor, n, PAPER);
2020-05-07 12:55:04 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int ifhitbyweapon_d(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
{
if (actor->isPlayer())
2020-05-07 12:55:04 +00:00
{
if (ud.god && actor->attackertype != SHRINKSPARK) return -1;
2020-05-07 12:55:04 +00:00
p = actor->PlayerIndex();
if (hitowner &&
hitowner->isPlayer() &&
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->isPlayer() && 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
}
}
2022-01-20 07:31:08 +00:00
if (attackerflag(actor, SFLAG2_DOUBLEDMGTHRUST))
{
ps[p].vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.25;
2022-01-20 07:31:08 +00:00
}
else
{
ps[p].vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.125;
}
2020-05-07 12:55:04 +00:00
}
else
{
if (actor->hitextra == 0)
if (actor->attackertype == SHRINKSPARK && actor->spr.scale.X < 0.375)
2020-05-07 12:55:04 +00:00
return -1;
if (isWorldTour() && actor->attackertype == FIREFLY && actor->spr.scale.X < 0.75)
2020-05-07 12:55:04 +00:00
{
if (actor->attackertype != RADIUSEXPLOSION && actor->attackertype != RPG)
2020-05-07 12:55:04 +00:00
return -1;
}
actor->spr.extra -= actor->hitextra;
auto Owner = actor->GetOwner();
2022-11-28 17:57:50 +00:00
if (!actorflag(actor, SFLAG2_IGNOREHITOWNER) && Owner && Owner->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
}
}
if (ud.multimode < 2 || !isWorldTour()
|| actor->attackertype != FLAMETHROWERFLAME
|| actor->hitextra >= 0
2021-12-21 18:13:49 +00:00
|| actor->spr.extra > 0
|| !actor->isPlayer()
|| ps[actor->PlayerIndex()].numloogs > 0
|| hitowner == nullptr)
2020-05-07 12:55:04 +00:00
{
actor->hitextra = -1;
2020-05-07 12:55:04 +00:00
return -1;
}
else
2020-05-07 12:55:04 +00:00
{
p = actor->PlayerIndex();
2021-12-21 18:13:49 +00:00
actor->spr.extra = 0;
ps[p].wackedbyactor = hitowner;
2020-05-07 12:55:04 +00:00
if (hitowner->isPlayer() && hitowner != ps[p].GetActor())
ps[p].frag_ps = hitowner->PlayerIndex(); // set the proper player index here - this previously set the sprite index...
2020-05-07 12:55:04 +00:00
actor->SetHitOwner(ps[p].GetActor());
actor->hitextra = -1;
2020-05-07 12:55:04 +00:00
return FLAMETHROWERFLAME;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void movefallers_d(void)
2020-05-07 12:55:04 +00:00
{
int j;
2020-05-07 12:55:04 +00:00
2020-10-22 17:31:06 +00:00
DukeStatIterator iti(STAT_FALLER);
while (auto act = iti.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
{
2022-02-07 07:47:18 +00:00
act->spr.pos.Z -= 16;
DAngle saved_angle = act->spr.Angles.Yaw;
int x = act->spr.extra;
2020-10-22 17:31:06 +00:00
j = fi.ifhitbyweapon(act);
if (j >= 0)
2020-05-07 12:55:04 +00:00
{
if (gs.actorinfo[j].flags2 & SFLAG2_EXPLOSIVE)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:39:33 +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 itj(STAT_FALLER);
while (auto a2 = itj.Next())
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:39:33 +00:00
if (a2->spr.hitag == act->spr.hitag)
2020-05-07 12:55:04 +00:00
{
2020-10-22 17:31:06 +00:00
a2->temp_data[0] = 1;
a2->spr.cstat &= ~CSTAT_SPRITE_ONE_SIDE;
if (a2->spr.picnum == CEILINGSTEAM || a2->spr.picnum == STEAM)
a2->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
2020-05-07 12:55:04 +00:00
}
}
}
}
else
{
act->hitextra = 0;
2021-12-21 18:39:33 +00:00
act->spr.extra = x;
2020-05-07 12:55:04 +00:00
}
}
act->spr.Angles.Yaw = saved_angle;
act->spr.pos.Z += 16;
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:39:33 +00:00
if (act->spr.lotag > 0)
2020-05-07 12:55:04 +00:00
{
2021-12-21 18:39:33 +00:00
act->spr.lotag-=3;
if (act->spr.lotag <= 0)
2020-05-07 12:55:04 +00:00
{
2022-09-13 17:55:54 +00:00
act->vel.X = 2 + krandf(4);
act->vel.Z = -4 + krandf(4);
2020-05-07 12:55:04 +00:00
}
}
else
{
2022-09-14 17:29:29 +00:00
if (act->vel.X > 0)
2020-05-07 12:55:04 +00:00
{
2022-09-03 08:05:20 +00:00
act->vel.X -= 0.5;
2020-10-22 17:31:06 +00:00
ssp(act, CLIPMASK0);
2020-05-07 12:55:04 +00:00
}
double grav;
2022-11-25 16:43:13 +00:00
if (floorspace(act->sector())) grav = 0;
2020-05-07 12:55:04 +00:00
else
{
2022-11-25 16:43:13 +00:00
if (ceilingspace(act->sector()))
grav = gs.gravity / 6;
2020-05-07 12:55:04 +00:00
else
grav = gs.gravity;
2020-05-07 12:55:04 +00:00
}
2022-08-20 18:11:01 +00:00
if (act->spr.pos.Z < sectp->floorz - 1)
2020-05-07 12:55:04 +00:00
{
act->vel.Z += grav;
if (act->vel.Z > 24)
2022-09-11 17:28:45 +00:00
act->vel.Z = 24;
act->spr.pos.Z += act->vel.Z;
2020-05-07 12:55:04 +00:00
}
2022-08-20 18:11:01 +00:00
if ((sectp->floorz - act->spr.pos.Z) < 16)
2020-05-07 12:55:04 +00:00
{
j = 1 + (krand() & 7);
for (int x = 0; x < j; x++) RANDOMSCRAP(act);
act->Destroy();
2020-05-07 12:55:04 +00:00
}
}
}
}
}
2020-05-07 12:55:04 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void movestandables_d(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() || actorflag(act, SFLAG2_DIENOW))
2020-05-07 12:55:04 +00:00
{
act->Destroy();
2020-05-07 12:55:04 +00:00
continue;
}
2022-01-16 23:51:40 +00:00
if (act->GetClass() != RUNTIME_CLASS(DDukeActor))
{
CallTick(act);
continue;
}
2020-05-07 12:55:04 +00:00
else if (isIn(picnum,
2020-05-07 12:55:04 +00:00
EXPLODINGBARREL,
WOODENHORSE,
HORSEONSIDE,
FLOORFLAME,
FIREBARREL,
FIREVASE,
NUKEBARREL,
NUKEBARRELDENTED,
NUKEBARRELLEAKED,
TOILETWATER,
RUBBERCAN,
STEAM,
CEILINGSTEAM,
WATERBUBBLEMAKER))
2020-05-07 12:55:04 +00:00
{
double 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
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void moveweapons_d(void)
{
2020-10-22 18:21:21 +00:00
DukeStatIterator it(STAT_PROJECTILE);
while (auto act = it.Next())
{
if (!act->insector() || actorflag(act, SFLAG2_DIENOW))
{
act->Destroy();
continue;
}
if (act->GetClass() != RUNTIME_CLASS(DDukeActor))
{
CallTick(act);
continue;
}
switch(act->spr.picnum)
{
case SHOTSPARK1:
{
double x;
2020-10-23 15:44:45 +00:00
int p = findplayer(act, &x);
2020-10-22 18:21:21 +00:00
execute(act, p, x);
break;
2020-05-07 12:55:04 +00:00
}
}
2020-05-07 12:55:04 +00:00
}
}
2020-05-07 22:03:51 +00:00
//---------------------------------------------------------------------------
//
//
2020-05-07 22:03:51 +00:00
//
//---------------------------------------------------------------------------
void movetransports_d(void)
{
int warpspriteto;
double ll;
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
{
2020-10-22 19:42:02 +00:00
auto Owner = act->GetOwner();
2020-10-22 19:42:02 +00:00
if (Owner == act)
2020-05-07 22:03:51 +00:00
{
continue;
}
2020-10-22 19:42:02 +00:00
auto sectp = act->sector();
int sectlotag = sectp->lotag;
2020-10-22 19:42:02 +00:00
int onfloorz = act->temp_data[4];
2020-10-22 19:42:02 +00:00
if (act->temp_data[0] > 0) act->temp_data[0]--;
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 18:45:48 +00:00
switch (act2->spr.statnum)
2020-05-07 22:03:51 +00:00
{
case STAT_PLAYER:
2020-10-22 19:42:02 +00:00
if (act2->GetOwner())
2020-05-07 22:03:51 +00:00
{
2020-10-22 19:42:02 +00:00
int p = act2->PlayerIndex();
2020-05-07 22:03:51 +00:00
ps[p].on_warping_sector = 1;
2020-05-07 22:03:51 +00:00
if (ps[p].transporter_hold == 0 && ps[p].jumping_counter == 0)
{
if (ps[p].on_ground && sectlotag == 0 && onfloorz && ps[p].jetpack_on == 0)
{
2021-12-21 18:45:48 +00:00
if (act->spr.pal == 0)
2020-05-07 22:03:51 +00:00
{
2020-10-22 19:42:02 +00:00
spawn(act, TRANSPORTERBEAM);
S_PlayActorSound(TELEPORTER, act);
2020-05-07 22:03:51 +00:00
}
for (int 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;
}
ps[p].Angles.setYaw(Owner->spr.Angles.Yaw, true);
2020-10-22 19:42:02 +00:00
if (Owner->GetOwner() != Owner)
{
2020-10-22 19:42:02 +00:00
act->temp_data[0] = 13;
Owner->temp_data[0] = 13;
2020-05-07 22:03:51 +00:00
ps[p].transporter_hold = 13;
}
ps[p].GetActor()->spr.pos = Owner->spr.pos;
ps[p].GetActor()->backuppos();
ps[p].setbobpos();
ChangeActorSect(act2, Owner->sector());
ps[p].setCursector(act2->sector());
2021-12-21 18:45:48 +00:00
if (act->spr.pal == 0)
2020-05-07 22:03:51 +00:00
{
2020-10-22 19:42:02 +00:00
auto k = spawn(Owner, TRANSPORTERBEAM);
if (k) S_PlayActorSound(TELEPORTER, k);
2020-05-07 22:03:51 +00:00
}
2020-05-07 22:03:51 +00:00
break;
}
}
else if (!(sectlotag == 1 && ps[p].on_ground == 1)) break;
if (onfloorz == 0 && abs(act->spr.pos.Z - ps[p].GetActor()->getOffsetZ()) < 24)
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].GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
ps[p].GetActor()->backupvec2();
if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11))
ps[p].GetActor()->spr.pos.Z = Owner->spr.pos.Z - 24 + gs.playerheight;
else ps[p].GetActor()->spr.pos.Z = Owner->spr.pos.Z + 24 + gs.playerheight;
ps[p].GetActor()->backupz();
2020-10-22 19:42:02 +00:00
auto pa = ps[p].GetActor();
pa->opos = ps[p].GetActor()->getPosWithOffsetZ();
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;
}
int k = 0;
if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].GetActor()->getOffsetZ() > (sectp->floorz - 16) && (PlayerInput(p, SB_CROUCH) || ps[p].vel.Z > 8))
// if( onfloorz && sectlotag == 1 && ps[p].pos.z > (sectp->floorz-(6<<8)) )
2020-05-07 22:03:51 +00:00
{
k = 1;
if (screenpeek == p)
{
FX_StopAllSounds();
}
if (ps[p].GetActor()->spr.extra > 0)
2020-10-22 19:42:02 +00:00
S_PlayActorSound(DUKE_UNDERWATER, act2);
ps[p].GetActor()->spr.pos.Z = Owner->sector()->ceilingz + 7 + gs.playerheight;
ps[p].GetActor()->backupz();
// this is actually below the precision <20>f the original Build coordinate system...
ps[p].vel.X = ((krand() & 8192) ? 1 / 64. : -1 / 64.);
ps[p].vel.Y = ((krand() & 8192) ? 1 / 64. : -1 / 64.);
2020-05-07 22:03:51 +00:00
}
if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].GetActor()->getOffsetZ() < (sectp->ceilingz + 6))
2020-05-07 22:03:51 +00:00
{
k = 1;
2021-12-21 18:45:48 +00:00
// if( act2->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, act2);
ps[p].GetActor()->spr.pos.Z = Owner->sector()->floorz - 7 + gs.playerheight;
ps[p].GetActor()->backupz();
2020-05-07 22:03:51 +00:00
ps[p].jumping_toggle = 1;
ps[p].jumping_counter = 0;
}
2020-05-07 22:03:51 +00:00
if (k == 1)
{
ps[p].GetActor()->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
ps[p].GetActor()->backupvec2();
2020-10-22 19:42:02 +00:00
if (!Owner || 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());
ChangeActorSect(act2, Owner->sector());
SetActor(act2, act2->spr.pos);
2020-05-07 22:03:51 +00:00
if ((krand() & 255) < 32)
2020-10-22 19:42:02 +00:00
spawn(act2, WATERSPLASH2);
2020-05-07 22:03:51 +00:00
if (sectlotag == 1)
for (int l = 0; l < 9; l++)
{
2020-10-22 19:42:02 +00:00
auto q = spawn(ps[p].GetActor(), WATERBUBBLE);
2022-09-12 16:37:35 +00:00
if (q) q->spr.pos.Z += krandf(64);
}
2020-05-07 22:03:51 +00:00
}
}
break;
2020-05-07 22:03:51 +00:00
case STAT_ACTOR:
2022-11-30 18:39:06 +00:00
if (actorflag(act, SFLAG3_DONTDIVEALIVE) && act2->spr.extra > 0) continue;
[[fallthrough]];
2020-05-07 22:03:51 +00:00
case STAT_PROJECTILE:
case STAT_MISC:
case STAT_FALLER:
case STAT_DUMMYPLAYER:
2022-11-28 17:57:50 +00:00
if (actorflag(act, SFLAG2_DONTDIVE)) continue;
2022-09-14 18:55:50 +00:00
ll = abs(act2->vel.Z);
2020-05-07 22:03:51 +00:00
{
warpspriteto = 0;
if (ll && sectlotag == 2 && act2->spr.pos.Z < (sectp->ceilingz + ll) && act2->vel.Z < 0)
2020-05-07 22:03:51 +00:00
warpspriteto = 1;
if (ll && sectlotag == 1 && act2->spr.pos.Z > (sectp->floorz - ll) && act2->vel.Z > 0)
2020-05-07 22:03:51 +00:00
warpspriteto = 1;
if (sectlotag == 0 && (onfloorz || abs(act2->spr.pos.Z - act->spr.pos.Z) < 16))
2020-05-07 22:03:51 +00:00
{
2021-12-21 18:45:48 +00:00
if ((!Owner || Owner->GetOwner() != Owner) && onfloorz && act->temp_data[0] > 0 && act2->spr.statnum != STAT_MISC)
2020-05-07 22:03:51 +00:00
{
2020-10-22 19:42:02 +00:00
act->temp_data[0]++;
2020-05-07 22:03:51 +00:00
goto BOLT;
}
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 == 2)
{
act2->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
break;
}
[[fallthrough]];
default:
if (act2->spr.statnum == 5 && !(sectlotag == 1 || sectlotag == 2))
break;
[[fallthrough]];
case WATERBUBBLE:
//if( rnd(192) && a2->s.picnum == WATERBUBBLE)
// break;
if (sectlotag > 0)
2020-05-07 22:03:51 +00:00
{
auto k = spawn(act2, WATERSPLASH2);
if (k && sectlotag == 1 && act2->spr.statnum == 4)
{
2022-09-13 17:55:54 +00:00
k->vel.X = act2->vel.X * 0.5;
k->spr.Angles.Yaw = act2->spr.Angles.Yaw;
ssp(k, 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 (act2->spr.statnum == STAT_PROJECTILE || (checkcursectnums(act->sector()) == -1 && checkcursectnums(Owner->sector()) == -1))
{
act2->spr.pos += (Owner->spr.pos - act->spr.pos.XY()).plusZ(-Owner->sector()->floorz);
act2->spr.Angles.Yaw = Owner->spr.Angles.Yaw;
act2->backupang();
if (act->spr.pal == 0)
{
auto k = spawn(act, TRANSPORTERBEAM);
if (k) S_PlayActorSound(TELEPORTER, k);
k = spawn(Owner, TRANSPORTERBEAM);
if (k) S_PlayActorSound(TELEPORTER, k);
}
if (Owner && 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.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
2022-02-04 08:50:40 +00:00
act2->spr.pos.Z = Owner->spr.pos.Z + 16;
act2->backupz();
ChangeActorSect(act2, Owner->sector());
2020-05-07 22:03:51 +00:00
}
break;
case ST_1_ABOVE_WATER:
act2->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
act2->spr.pos.Z = Owner->sector()->ceilingz + ll;
act2->backupz();
ChangeActorSect(act2, Owner->sector());
break;
case ST_2_UNDERWATER:
act2->spr.pos.XY() += Owner->spr.pos.XY() - act->spr.pos.XY();
act2->spr.pos.Z = Owner->sector()->ceilingz - ll;
act2->backupz();
ChangeActorSect(act2, Owner->sector());
break;
}
2020-05-07 22:03:51 +00:00
break;
}
}
}
break;
2020-05-07 22:03:51 +00:00
}
}
BOLT:;
}
}
2020-05-07 12:55:04 +00:00
2020-05-08 22:34:48 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-22 20:07:09 +00:00
static void flamethrowerflame(DDukeActor *actor)
2020-05-08 22:34:48 +00:00
{
auto sectp = actor->sector();
double xx;
int p = findplayer(actor, &xx);
execute(actor, p, xx);
actor->temp_data[0]++;
if (sectp->lotag == 2)
2020-05-08 22:34:48 +00:00
{
spawn(actor, EXPLOSION2)->spr.shade = 127;
actor->Destroy();
2020-05-08 22:34:48 +00:00
return;
}
2022-08-22 21:42:42 +00:00
auto dapos = actor->spr.pos;
2020-05-08 22:34:48 +00:00
2020-10-22 20:07:09 +00:00
getglobalz(actor);
2020-05-08 22:34:48 +00:00
int ds = actor->temp_data[0] / 6;
if (actor->spr.scale.X < 0.1250)
{
2022-10-07 21:44:21 +00:00
actor->spr.scale.X += (ds * REPEAT_SCALE);
2022-10-07 21:46:28 +00:00
actor->spr.scale.Y = (actor->spr.scale.X);
}
actor->clipdist += ds * 0.25;
if (actor->temp_data[0] <= 2)
actor->temp_data[3] = krand() % 10;
if (actor->temp_data[0] > 30)
2020-05-08 22:34:48 +00:00
{
spawn(actor, EXPLOSION2)->spr.shade = 127;
actor->Destroy();
2020-05-08 22:34:48 +00:00
return;
}
2020-10-22 20:07:09 +00:00
Collision coll;
movesprite_ex(actor, DVector3(actor->spr.Angles.Yaw.ToVector() * actor->vel.X, actor->vel.Z), CLIPMASK1, coll);
2020-05-08 22:34:48 +00:00
if (!actor->insector())
2020-05-08 22:34:48 +00:00
{
actor->Destroy();
2020-05-08 22:34:48 +00:00
return;
}
2020-10-22 20:07:09 +00:00
if (coll.type != kHitSprite)
2020-05-08 22:34:48 +00:00
{
2022-02-03 23:55:12 +00:00
if (actor->spr.pos.Z < actor->ceilingz)
2020-05-08 22:34:48 +00:00
{
coll.setSector(actor->sector());
2022-09-11 17:28:45 +00:00
actor->vel.Z -= 1/256.;
2020-05-08 22:34:48 +00:00
}
2022-02-03 23:45:24 +00:00
else if ((actor->spr.pos.Z > actor->floorz && actor->sector()->lotag != 1)
|| (actor->spr.pos.Z > actor->floorz + 16 && actor->sector()->lotag == 1))
2020-05-08 22:34:48 +00:00
{
coll.setSector(actor->sector());
if (actor->sector()->lotag != 1)
2022-09-11 17:28:45 +00:00
actor->vel.Z += 1/256.;
2020-05-08 22:34:48 +00:00
}
}
2020-10-22 20:07:09 +00:00
if (coll.type != 0) {
actor->vel.XY().Zero();
2022-09-03 08:02:25 +00:00
actor->vel.Z = 0;
2020-10-22 20:07:09 +00:00
if (coll.type == kHitSprite)
2020-05-08 22:34:48 +00:00
{
fi.checkhitsprite(coll.actor(), actor);
if (coll.actor()->isPlayer())
S_PlayActorSound(PISTOL_BODYHIT, coll.actor());
2020-05-08 22:34:48 +00:00
}
2020-10-22 20:07:09 +00:00
else if (coll.type == kHitWall)
2020-05-08 22:34:48 +00:00
{
2022-08-22 21:42:42 +00:00
SetActor(actor, dapos);
2022-08-23 20:39:07 +00:00
fi.checkhitwall(actor, coll.hitWall, actor->spr.pos, actor->spr.picnum);
2020-05-08 22:34:48 +00:00
}
2020-10-22 20:07:09 +00:00
else if (coll.type == kHitSector)
2020-05-08 22:34:48 +00:00
{
2022-08-22 21:42:42 +00:00
SetActor(actor, dapos);
if (actor->vel.Z < 0)
fi.checkhitceiling(actor->sector());
2020-05-08 22:34:48 +00:00
}
if (actor->spr.scale.X >= 0.15625)
2020-05-08 22:34:48 +00:00
{
int x = actor->spr.extra;
fi.hitradius(actor, gs.rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x);
2020-05-08 22:34:48 +00:00
}
else
{
int x = actor->spr.extra + (global_random & 3);
fi.hitradius(actor, (gs.rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x);
2020-05-08 22:34:48 +00:00
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-22 20:18:47 +00:00
static void heavyhbomb(DDukeActor *actor)
{
2020-10-22 20:18:47 +00:00
auto Owner = actor->GetOwner();
auto sectp = actor->sector();
int l;
double xx;
int p = findplayer(actor, &xx);
if (xx < 1220 / 16.) actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
2021-12-21 18:45:48 +00:00
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;
2022-09-03 08:02:25 +00:00
actor->vel.X = 0;
goto DETONATEB;
}
}
2021-12-21 18:45:48 +00:00
if (actor->spr.picnum != BOUNCEMINE)
{
2020-10-22 20:18:47 +00:00
makeitfall(actor);
if (sectp->lotag != 1 && actor->spr.pos.Z >= actor->floorz - FOURSLEIGHT_F && actor->spr.yint < 3)
{
if (actor->spr.yint > 0 || (actor->spr.yint == 0 && actor->floorz == sectp->floorz))
2020-10-22 20:18:47 +00:00
S_PlayActorSound(PIPEBOMB_BOUNCE, actor);
actor->vel.Z = -(4 - actor->spr.yint);
if (actor->sector()->lotag == 2)
2022-09-03 08:04:16 +00:00
actor->vel.Z *= 0.25;
actor->spr.yint++;
}
2022-02-03 23:45:24 +00:00
if (actor->spr.pos.Z < actor->ceilingz) // && sectp->lotag != 2 )
{
2022-02-03 23:45:24 +00:00
actor->spr.pos.Z = actor->ceilingz + 3;
2022-09-03 08:02:25 +00:00
actor->vel.Z = 0;
}
}
2020-10-22 20:18:47 +00:00
Collision coll;
movesprite_ex(actor, DVector3(actor->spr.Angles.Yaw.ToVector() * actor->vel.X, actor->vel.Z), CLIPMASK0, coll);
if (actor->sector()->lotag == 1 && actor->vel.Z == 0)
{
actor->spr.pos.Z += 32;
if (actor->temp_data[5] == 0)
{
actor->temp_data[5] = 1;
2020-10-22 20:18:47 +00:00
spawn(actor, WATERSPLASH2);
}
}
else actor->temp_data[5] = 0;
if (actor->temp_data[3] == 0 && (actor->spr.picnum == BOUNCEMINE || actor->spr.picnum == MORTER) && (coll.type || xx < 844/16.))
{
actor->temp_data[3] = 1;
actor->temp_data[4] = 0;
l = 0;
2022-09-03 08:02:25 +00:00
actor->vel.X = 0;
goto DETONATEB;
}
if ( Owner && Owner->isPlayer())
2020-10-22 20:18:47 +00:00
l = Owner->PlayerIndex();
else l = -1;
if(actor->vel.X > 0)
{
2022-09-11 17:28:45 +00:00
actor->vel.X -= 5. / 16;
if (sectp->lotag == 2)
2022-09-11 17:28:45 +00:00
actor->vel.X -= 10. / 16;
if(actor->vel.X < 0)
2022-09-03 08:02:25 +00:00
actor->vel.X = 0;
if (int(actor->vel.X * 16) & 8) actor->spr.cstat ^= CSTAT_SPRITE_XFLIP;
}
2020-10-22 20:18:47 +00:00
if (coll.type== kHitWall)
{
auto wal = coll.hitWall;
2022-08-23 20:39:07 +00:00
fi.checkhitwall(actor, wal, actor->spr.pos, actor->spr.picnum);
DAngle k = wal->delta().Angle();
actor->spr.Angles.Yaw = k * 2 - actor->spr.Angles.Yaw;
2022-09-03 08:04:16 +00:00
actor->vel.X *= 0.5;
}
DETONATEB:
if (actor->temp_data[3] == 1)
{
actor->temp_data[4]++;
if (actor->temp_data[4] == 2)
{
int x = actor->spr.extra;
int m = 0;
2021-12-21 18:45:48 +00:00
switch (actor->spr.picnum)
{
case MORTER: m = gs.morterblastradius; break;
case BOUNCEMINE: m = gs.bouncemineblastradius; break;
}
2020-10-22 20:18:47 +00:00
fi.hitradius(actor, m, x >> 2, x >> 1, x - (x >> 2), x);
spawn(actor, EXPLOSION2);
if (actor->vel.Z == 0) spawn(actor, EXPLOSION2BOT);
2020-10-22 20:18:47 +00:00
S_PlayActorSound(PIPEBOMB_EXPLODE, actor);
for (x = 0; x < 8; x++)
2020-10-22 20:18:47 +00:00
RANDOMSCRAP(actor);
}
if (actor->spr.scale.Y)
{
2022-10-07 21:46:28 +00:00
actor->spr.scale.Y = (0);
return;
}
if (actor->temp_data[4] > 20)
{
actor->Destroy();
return;
}
}
if (actor->temp_data[0] < 8) actor->temp_data[0]++;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-08 22:34:48 +00:00
void moveactors_d(void)
{
2021-11-21 08:05:58 +00:00
int p;
2020-10-22 20:48:51 +00:00
DukeStatIterator it(STAT_ACTOR);
while (auto act = it.Next())
2020-05-08 22:34:48 +00:00
{
2022-11-27 22:36:39 +00:00
if (act->spr.picnum == QUEBALL)
{
int a = 0;
}
auto sectp = act->sector();
2020-05-08 22:34:48 +00:00
if (act->spr.scale.X == 0 || sectp == nullptr || actorflag(act, SFLAG2_DIENOW))
2020-05-08 22:34:48 +00:00
{
act->Destroy();
2020-05-08 22:34:48 +00:00
continue;
}
2020-10-22 20:48:51 +00:00
int *t = &act->temp_data[0];
2020-05-08 22:34:48 +00:00
2022-01-21 00:04:08 +00:00
if (act->GetClass() != RUNTIME_CLASS(DDukeActor))
{
CallTick(act);
}
else switch (act->spr.picnum)
2020-05-08 22:34:48 +00:00
{
case FLAMETHROWERFLAME:
2020-10-22 20:48:51 +00:00
if (isWorldTour()) flamethrowerflame(act);
2020-05-08 22:34:48 +00:00
continue;
case BOUNCEMINE:
case MORTER:
2020-10-22 20:48:51 +00:00
spawn(act, FRAMEEFFECT1)->temp_data[0] = 3;
heavyhbomb(act);
2020-05-08 22:34:48 +00:00
continue;
}
2022-11-28 17:57:50 +00:00
if (monsterCheatCheck(act) && badguy(act))
2020-05-08 22:34:48 +00:00
{
2022-11-28 17:57:50 +00:00
continue;
2020-05-08 22:34:48 +00:00
}
double xx;
p = findplayer(act, &xx);
2020-05-08 22:34:48 +00:00
execute(act, p, xx);
2020-05-08 22:34:48 +00:00
}
}
2020-05-09 18:27:06 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-10-22 20:51:51 +00:00
static void fireflyflyingeffect(DDukeActor *actor)
{
double xx;
int p = findplayer(actor, &xx);
execute(actor, p, xx);
2020-10-22 20:51:51 +00:00
auto Owner = actor->GetOwner();
if (!Owner || Owner->spr.picnum != FIREFLY)
{
actor->Destroy();
return;
}
if (Owner->spr.scale.X >= 0.375 || Owner->spr.pal == 1)
actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
else
actor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
auto dvec = Owner->spr.pos.XY() - ps[p].GetActor()->spr.pos.XY();
double dist = dvec.Length();
if (dist != 0.0) dvec /= dist;
actor->spr.pos = Owner->spr.pos + DVector3(dvec.X * -0.625, dvec.Y * -0.625, 8);
if (Owner->spr.extra <= 0)
{
actor->Destroy();
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-09 18:27:06 +00:00
void moveexplosions_d(void) // STATNUM 5
{
int p;
double xx;
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
{
if (!act->insector() || act->spr.scale.X == 0)
2020-05-09 18:27:06 +00:00
{
act->Destroy();
2020-05-09 18:27:06 +00:00
continue;
}
if (act->GetClass() != RUNTIME_CLASS(DDukeActor))
{
CallTick(act);
continue;
}
auto sectp = act->sector();
2020-05-09 18:27:06 +00:00
2021-12-21 18:45:48 +00:00
switch (act->spr.picnum)
2020-05-09 18:27:06 +00:00
{
case FIREFLYFLYINGEFFECT:
2020-10-22 20:51:51 +00:00
if (isWorldTour()) fireflyflyingeffect(act);
continue;
2020-05-09 18:27:06 +00:00
case NEON1:
case NEON2:
case NEON3:
case NEON4:
case NEON5:
case NEON6:
2021-12-21 18:45:48 +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 NUKEBUTTON:
case NUKEBUTTON + 1:
case NUKEBUTTON + 2:
case NUKEBUTTON + 3:
if (act->temp_data[0])
2020-05-09 18:27:06 +00:00
{
act->temp_data[0]++;
2020-10-22 20:51:51 +00:00
auto Owner = act->GetOwner();
if (act->temp_data[0] == 8) act->spr.picnum = NUKEBUTTON + 1;
else if (act->temp_data[0] == 16 && Owner)
2020-05-09 18:27:06 +00:00
{
2021-12-21 18:45:48 +00:00
act->spr.picnum = NUKEBUTTON + 2;
2020-10-22 20:51:51 +00:00
ps[Owner->PlayerIndex()].fist_incs = 1;
2020-05-09 18:27:06 +00:00
}
2020-10-22 20:51:51 +00:00
if (Owner && ps[Owner->PlayerIndex()].fist_incs == 26)
2021-12-21 18:45:48 +00:00
act->spr.picnum = NUKEBUTTON + 3;
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 MONEY + 1:
case MAIL + 1:
case PAPER + 1:
act->vel.Z = act->floorz = getflorzofslopeptr(act->sector(), act->spr.pos.X, act->spr.pos.Y);
2020-05-09 18:27:06 +00:00
break;
case MONEY:
case MAIL:
case PAPER:
2020-10-22 20:51:51 +00:00
money(act, BLOODPOOL);
2020-05-09 18:27:06 +00:00
break;
case BLOODPOOL:
case PUKE:
2022-01-26 23:41:33 +00:00
bloodpool(act, act->spr.picnum == PUKE);
2020-05-09 18:27:06 +00:00
continue;
case LAVAPOOL:
case ONFIRE:
2020-07-06 13:48:51 +00:00
case ONFIRESMOKE:
2020-05-09 18:27:06 +00:00
case BURNEDCORPSE:
case LAVAPOOLBUBBLE:
case WHISPYSMOKE:
if (!isWorldTour())
continue;
[[fallthrough]];
2020-05-09 18:27:06 +00:00
case BURNING:
case BURNING2:
case FECES:
case WATERBUBBLE:
case SMALLSMOKE:
case EXPLOSION2:
case SHRINKEREXPLOSION:
case EXPLOSION2BOT:
case BLOOD:
case LASERSITE:
case FORCERIPPLE:
case TRANSPORTERSTAR:
case TRANSPORTERBEAM:
p = findplayer(act, &xx);
execute(act, p, xx);
2020-05-09 18:27:06 +00:00
continue;
case SHELL:
case SHOTGUNSHELL:
2022-08-20 18:11:01 +00:00
shell(act, sectp->floorz + 24 < act->spr.pos.Z);
2020-05-09 18:27:06 +00:00
continue;
case GLASSPIECES:
2022-11-30 18:39:06 +00:00
case GLASSPIECES1:
case GLASSPIECES2:
2020-10-22 20:51:51 +00:00
glasspieces(act);
2020-05-09 18:27:06 +00:00
continue;
}
}
}
2020-05-10 07:08:02 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void handle_se06_d(DDukeActor* actor)
{
2021-11-20 23:33:17 +00:00
auto sc = actor->sector();
2021-12-21 18:45:48 +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)))
actor->vel.X -= (k >> 5) / 16.;
if (actor->temp_data[4] > ((k >> 1) - 1) && actor->temp_data[4] < (k - (k >> 3)))
2022-09-03 08:02:25 +00:00
actor->vel.X = 0;
if (actor->temp_data[4] < (k >> 1))
actor->vel.X += (k >> 5) / 16.;
if (actor->temp_data[4] < ((k >> 1) - (k >> 3)))
{
actor->temp_data[4] = 0;
actor->vel.X = k / 16.;
}
}
else actor->vel.X = k / 16.;
DukeStatIterator it(STAT_EFFECTOR);
while (auto act2 = it.Next())
{
if ((act2->spr.lotag == SE_14_SUBWAY_CAR) && (sh == act2->spr.hitag) && (act2->temp_data[0] == actor->temp_data[0]))
{
act2->vel.X = actor->vel.X;
//if( actor->temp_data[4] == 1 )
{
if (act2->temp_pos.X == 0)
act2->temp_pos.X = (act2->spr.pos - actor->spr.pos).LengthSquared();
int x = Sgn((act2->spr.pos - actor->spr.pos).LengthSquared() - act2->temp_pos.X);
if (act2->spr.extra)
x = -x;
actor->vel.X += x / 16.;
}
act2->temp_data[4] = actor->temp_data[4];
}
}
handle_se14(actor, true, RPG, JIBS6);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void handle_se28(DDukeActor* actor)
{
if (actor->temp_data[5] > 0)
{
actor->temp_data[5]--;
return;
}
if (actor->temp_data[0] == 0)
{
double x;
findplayer(actor, &x);
if (x > 15500 / 16.)
return;
actor->temp_data[0] = 1;
actor->temp_data[1] = 64 + (krand() & 511);
actor->temp_data[2] = 0;
}
else
{
actor->temp_data[2]++;
if (actor->temp_data[2] > actor->temp_data[1])
{
actor->temp_data[0] = 0;
ps[screenpeek].visibility = ud.const_visibility;
return;
}
else if (actor->temp_data[2] == (actor->temp_data[1] >> 1))
S_PlayActorSound(THUNDER, actor);
else if (actor->temp_data[2] == (actor->temp_data[1] >> 3))
S_PlayActorSound(LIGHTNING_SLAP, actor);
else if (actor->temp_data[2] == (actor->temp_data[1] >> 2))
{
DukeStatIterator it(STAT_DEFAULT);
while (auto act2 = it.Next())
{
2021-12-21 18:45:48 +00:00
if (act2->spr.picnum == NATURALLIGHTNING && act2->spr.hitag == actor->spr.hitag)
act2->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
}
}
else if (actor->temp_data[2] > (actor->temp_data[1] >> 3) && actor->temp_data[2] < (actor->temp_data[1] >> 2))
{
int j = !!cansee(actor->spr.pos, actor->sector(), ps[screenpeek].GetActor()->getPosWithOffsetZ(), ps[screenpeek].cursector);
if (rnd(192) && (actor->temp_data[2] & 1))
{
if (j) ps[screenpeek].visibility = 0;
}
else if (j) ps[screenpeek].visibility = ud.const_visibility;
DukeStatIterator it(STAT_DEFAULT);
while (auto act2 = it.Next())
{
2021-12-21 18:45:48 +00:00
if (act2->spr.picnum == NATURALLIGHTNING && act2->spr.hitag == actor->spr.hitag)
{
if (rnd(32) && (actor->temp_data[2] & 1))
{
act2->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
spawn(act2, SMALLSMOKE);
double x;
2020-10-23 15:44:45 +00:00
int p = findplayer(actor, &x);
auto psa = ps[p].GetActor();
double dist = (psa->spr.pos.XY() - act2->spr.pos.XY()).LengthSquared();
if (dist < 49*48)
{
2020-10-25 06:21:33 +00:00
if (S_CheckActorSoundPlaying(psa, DUKE_LONGTERM_PAIN) < 1)
S_PlayActorSound(DUKE_LONGTERM_PAIN, psa);
S_PlayActorSound(SHORT_CIRCUIT, psa);
psa->spr.extra -= 8 + (krand() & 7);
SetPlayerPal(&ps[p], PalEntry(32, 16, 0, 0));
}
return;
}
else act2->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
}
}
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-05-10 07:08:02 +00:00
void moveeffectors_d(void) //STATNUM 3
{
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();
switch (act->spr.lotag)
2020-05-10 07:08:02 +00:00
{
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_d(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, true, 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:
handle_se05(act);
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, false);
2020-05-10 07:08:02 +00:00
break;
case SE_10_DOOR_AUTO_CLOSE:
{
static const int tags[] = { 20, 21, 22, 26, 0};
2020-10-22 21:17:51 +00:00
handle_se10(act, tags);
2020-05-10 07:08:02 +00:00
break;
}
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_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 SE_24_CONVEYOR:
2020-11-27 19:06:38 +00:00
case SE_34:
{
2022-09-12 19:59:34 +00:00
handle_se24(act, true, 0.25);
2020-05-10 07:08:02 +00:00
break;
}
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
2020-10-22 21:17:51 +00:00
if (act->temp_data[4] == 0) break;
2022-09-12 21:35:48 +00:00
handle_se25(act, -1, -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_28_LIGHTNING:
2020-10-22 21:17:51 +00:00
handle_se28(act);
2020-05-10 07:08:02 +00:00
break;
2020-11-27 19:06:38 +00:00
case SE_29_WAVES:
handle_se29(act);
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, true);
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:
2022-11-30 16:15:44 +00:00
if (ud.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
2020-10-22 21:17:51 +00:00
if (act->temp_data[0])
2020-05-10 07:08:02 +00:00
{
2020-10-22 21:17:51 +00:00
if (act->temp_data[0] == 1)
fi.shoot(act, sc->extra, nullptr);
2020-10-22 21:17:51 +00:00
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;
case 130:
2020-10-22 21:17:51 +00:00
handle_se130(act, 80, EXPLOSION2);
2020-05-10 07:08:02 +00:00
break;
case 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();
2022-11-15 13:59:28 +00:00
if (sc->walls.Size() != 4) continue;
auto wal = &sc->walls[2];
if (wal->nextSector()) alignflorslope(act->sector(), DVector3(wal->pos, wal->nextSector()->floorz));
2020-05-10 07:08:02 +00:00
}
}
2020-05-08 22:34:48 +00:00
2020-05-13 22:04:14 +00:00
//---------------------------------------------------------------------------
//
2020-10-22 21:41:07 +00:00
//
2020-05-13 22:04:14 +00:00
//
//---------------------------------------------------------------------------
2020-11-01 14:56:50 +00:00
void move_d(DDukeActor *actor, int playernum, int xvel)
2020-05-13 22:04:14 +00:00
{
2022-09-14 21:59:05 +00:00
DAngle goalang, angdif;
double daxvel;
2020-05-13 22:04:14 +00:00
2021-12-21 18:45:48 +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[playernum].newOwner != nullptr)
goalang = (ps[playernum].GetActor()->opos.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[playernum].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle();
angdif = deltaangle(actor->spr.Angles.Yaw, goalang) * 0.25;
if (angdif > -DAngle22_5 / 16 && angdif < nullAngle) angdif = nullAngle;
actor->spr.Angles.Yaw += angdif;
2020-05-13 22:04:14 +00:00
}
if (a & spin)
actor->spr.Angles.Yaw += DAngle45 * BobVal(actor->temp_data[0] << 3);
2020-05-13 22:04:14 +00:00
if (a & face_player_slow)
{
2020-11-02 23:20:51 +00:00
if (ps[playernum].newOwner != nullptr)
goalang = (ps[playernum].GetActor()->opos.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[playernum].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle();
angdif = DAngle22_5 * 0.25 * Sgn(deltaangle(actor->spr.Angles.Yaw, goalang).Degrees()); // this looks very wrong...
actor->spr.Angles.Yaw += angdif;
2020-05-13 22:04:14 +00:00
}
if ((a & jumptoplayer) == jumptoplayer)
{
if (actor->temp_data[0] < 16)
actor->vel.Z -= BobVal(512 + (actor->temp_data[0] << 4)) * 2;
2020-05-13 22:04:14 +00:00
}
if (a & face_player_smart)
{
DVector2 newpos = ps[playernum].GetActor()->spr.pos.XY() + (ps[playernum].vel.XY() * (4. / 3.));
goalang = (newpos - actor->spr.pos.XY()).Angle();
angdif = deltaangle(actor->spr.Angles.Yaw, goalang) * 0.25;
2022-09-14 21:59:05 +00:00
if (angdif > -DAngle22_5/16 && angdif < nullAngle) angdif = nullAngle;
actor->spr.Angles.Yaw += 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
{
2022-02-03 21:06:09 +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
{
if (!actor->isPlayer()) actor->backupvec2();
2022-02-06 21:45:47 +00:00
SetActor(actor, actor->spr.pos);
2020-05-13 22:04:14 +00:00
}
return;
}
if (actor->spr.picnum == WATERBUBBLE)
{
int a = 0;
}
auto moveptr = &ScriptCode[actor->temp_data[1]];
2020-05-13 22:04:14 +00:00
if (a & geth) actor->vel.X += (moveptr[0] / 16. - actor->vel.X) * 0.5;
if (a & getv) actor->vel.Z += (moveptr[1] / 16. - actor->vel.Z) * 0.5;
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
if (!actor->isPlayer())
2020-11-01 14:56:50 +00:00
alterang(a, actor, playernum);
2020-05-13 22:04:14 +00:00
2022-09-11 20:57:56 +00:00
if (abs(actor->vel.X) < 6 / 16.) actor->vel.X = 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
if (actor->vel.X != 0 || actor->vel.Z != 0)
2020-05-13 22:04:14 +00:00
{
2021-12-21 18:45:48 +00:00
if (a && actor->spr.picnum != ROTATEGUN)
2020-05-13 22:04:14 +00:00
{
2021-12-21 18:45:48 +00:00
if ((actor->spr.picnum == DRONE || actor->spr.picnum == COMMANDER) && actor->spr.extra > 0)
2020-05-13 22:04:14 +00:00
{
2021-12-21 18:45:48 +00:00
if (actor->spr.picnum == COMMANDER)
2020-05-13 22:04:14 +00:00
{
double c, f;
calcSlope(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y, &c, &f);
actor->floorz = f;
actor->ceilingz = c;
if (actor->spr.pos.Z > f - 8)
2020-05-13 22:04:14 +00:00
{
actor->spr.pos.Z = f - 8;
2022-09-03 08:02:25 +00:00
actor->vel.Z = 0;
2020-05-13 22:04:14 +00:00
}
if (actor->spr.pos.Z < c + 80)
2020-05-13 22:04:14 +00:00
{
actor->spr.pos.Z = c + 80;
2022-09-03 08:02:25 +00:00
actor->vel.Z = 0;
2020-05-13 22:04:14 +00:00
}
}
else
{
if (actor->vel.Z > 0)
2020-05-13 22:04:14 +00:00
{
double f = getflorzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
actor->floorz = f;
if (actor->spr.pos.Z > f - 30)
actor->spr.pos.Z = f - 30;
2020-05-13 22:04:14 +00:00
}
else
{
double c = getceilzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
actor->ceilingz = c;
if (actor->spr.pos.Z < c + 50)
2020-05-13 22:04:14 +00:00
{
actor->spr.pos.Z = c + 50;
2022-09-03 08:02:25 +00:00
actor->vel.Z = 0;
2020-05-13 22:04:14 +00:00
}
}
}
}
2021-12-21 18:45:48 +00:00
else if (actor->spr.picnum != ORGANTIC)
2020-05-13 22:04:14 +00:00
{
if (actor->vel.Z > 0 && actor->floorz < actor->spr.pos.Z)
actor->spr.pos.Z = actor->floorz;
if (actor->vel.Z < 0)
2020-05-13 22:04:14 +00:00
{
double c = getceilzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
if (actor->spr.pos.Z < c + 66)
2020-05-13 22:04:14 +00:00
{
actor->spr.pos.Z = c + 66;
2022-09-03 08:04:16 +00:00
actor->vel.Z *= 0.5;
2020-05-13 22:04:14 +00:00
}
}
}
}
2022-09-14 21:59:05 +00:00
daxvel = actor->vel.X;
angdif = actor->spr.Angles.Yaw;
2020-05-13 22:04:14 +00:00
2021-12-21 18:45:48 +00:00
if (a && actor->spr.picnum != ROTATEGUN)
2020-05-13 22:04:14 +00:00
{
if (xvel < 960 && actor->spr.scale.X > 0.25 )
2020-05-13 22:04:14 +00:00
{
2022-09-14 21:59:05 +00:00
daxvel = -(1024 - xvel) * maptoworld;
angdif = (ps[playernum].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle();
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
{
2022-09-11 22:08:42 +00:00
ps[playernum].vel.X = 0;
ps[playernum].vel.Y = 0;
2020-05-13 22:04:14 +00:00
}
else
{
2022-09-11 22:08:42 +00:00
ps[playernum].vel.XY() *= gs.playerfriction - 0.125;
2020-05-13 22:04:14 +00:00
}
}
2022-11-28 17:57:50 +00:00
else if (!actorflag(actor, SFLAG2_FLOATING))
2020-05-13 22:04:14 +00:00
{
if (!*(moveptr + 1))
2020-05-13 22:04:14 +00:00
{
2022-02-03 21:06:09 +00:00
if (actor->opos.Z != actor->spr.pos.Z || (ud.multimode < 2 && ud.player_skill < 2))
{
if ((actor->temp_data[0] & 1) || ps[playernum].actorsqu == actor) return;
2022-09-14 21:59:05 +00:00
else daxvel *= 2;
}
else
{
if ((actor->temp_data[0] & 3) || ps[playernum].actorsqu == actor) return;
2022-09-14 21:59:05 +00:00
else daxvel *= 4;
}
2020-05-13 22:04:14 +00:00
}
}
}
2020-10-22 21:41:07 +00:00
Collision coll;
2022-11-27 10:56:27 +00:00
actor->movflag = movesprite_ex(actor, DVector3(angdif.ToVector() * daxvel, actor->vel.Z), CLIPMASK0, coll);
2020-05-13 22:04:14 +00:00
}
if (a)
{
if (actor->sector()->ceilingstat & CSTAT_SECTOR_SKY)
actor->spr.shade += (actor->sector()->ceilingshade - actor->spr.shade) >> 1;
else actor->spr.shade += (actor->sector()->floorshade - actor->spr.shade) >> 1;
2020-05-13 22:04:14 +00:00
if (actor->sector()->floorpicnum == MIRROR)
actor->Destroy();
2020-05-13 22:04:14 +00:00
}
}
2020-10-22 21:41:07 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void fall_d(DDukeActor *actor, int g_p)
2020-05-14 07:07:07 +00:00
{
fall_common(actor, g_p, JIBS6, DRONE, BLOODPOOL, SHOTSPARK1, SQUISHED, THUD, nullptr);
2020-05-14 07:07:07 +00:00
}
bool spawnweapondebris_d(int picnum)
2020-05-14 17:23:36 +00:00
{
return picnum == BLIMP;
2020-05-14 17:23:36 +00:00
}
2020-06-23 19:12:15 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void think_d(void)
{
thinktime.Reset();
thinktime.Clock();
movefta(); //ST 2
2020-06-23 19:12:15 +00:00
moveweapons_d(); //ST 4
moveplayers(); //ST 10
movefallers_d(); //ST 12
moveexplosions_d(); //ST 5
actortime.Reset();
actortime.Clock();
moveactors_d(); //ST 1
actortime.Unclock();
moveeffectors_d(); //ST 3
movestandables_d(); //ST 6
doanimations();
2022-11-20 21:07:10 +00:00
tickstat(STAT_FX); //ST 11
2020-06-23 19:12:15 +00:00
thinktime.Unclock();
}
2020-05-07 12:55:04 +00:00
END_DUKE_NS