2020-05-05 09:58:39 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
|
|
|
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
|
|
|
|
Copyright (C) 2017-2019 - Nuke.YKT
|
|
|
|
Copyright (C) 2020 - Christoph Oelckers
|
|
|
|
|
|
|
|
This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition
|
|
|
|
|
|
|
|
Duke Nukem 3D is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
Original Source: 1996 - Todd Replogle
|
|
|
|
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
|
|
|
|
|
|
|
EDuke enhancements integrated: 04/13/2003 - Matt Saettler
|
|
|
|
|
|
|
|
Note: EDuke source was in transition. Changes are in-progress in the
|
|
|
|
source as it is released.
|
|
|
|
|
|
|
|
This file is a combination of code from the following sources:
|
|
|
|
- EDuke 2 by Matt Saettler
|
|
|
|
- JFDuke by Jonathon Fowler (jf@jonof.id.au),
|
|
|
|
- DukeGDX and RedneckGDX by Alexander Makarov-[M210] (m210-2007@mail.ru)
|
|
|
|
- Redneck Rampage reconstructed source by Nuke.YKT
|
|
|
|
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "ns.h"
|
2022-12-03 16:09:40 +00:00
|
|
|
#include "vm.h"
|
2020-05-05 09:58:39 +00:00
|
|
|
#include "global.h"
|
2020-07-03 21:56:14 +00:00
|
|
|
#include "names.h"
|
2020-06-23 19:12:15 +00:00
|
|
|
#include "stats.h"
|
2020-07-06 11:26:26 +00:00
|
|
|
#include "constants.h"
|
2020-10-17 07:14:31 +00:00
|
|
|
#include "dukeactor.h"
|
2020-05-05 09:58:39 +00:00
|
|
|
|
|
|
|
BEGIN_DUKE_NS
|
|
|
|
|
2023-04-30 06:57:28 +00:00
|
|
|
|
2023-07-22 08:24:20 +00:00
|
|
|
void moveactor(DDukeActor* actor, int p, double pdist, const int killit_flag)
|
2023-04-30 06:57:28 +00:00
|
|
|
{
|
2023-07-22 08:24:20 +00:00
|
|
|
if (killit_flag == 1)
|
2023-04-30 06:57:28 +00:00
|
|
|
{
|
|
|
|
// if player was set to squish, first stop that..
|
2023-10-02 09:36:39 +00:00
|
|
|
const auto pp = getPlayer(p);
|
|
|
|
if (pp->actorsqu == actor) pp->actorsqu = nullptr;
|
2023-04-30 06:57:28 +00:00
|
|
|
actor->flags2 |= SFLAG2_DIENOW;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
move(actor, p, pdist);
|
|
|
|
|
|
|
|
if (actor->spr.statnum == STAT_ACTOR)
|
|
|
|
{
|
|
|
|
if (badguy(actor))
|
|
|
|
{
|
|
|
|
if (actor->spr.scale.X > 0.9375) return;
|
|
|
|
if (ud.respawn_monsters == 1 && actor->spr.extra <= 0) return;
|
|
|
|
}
|
|
|
|
else if (ud.respawn_items == 1 && (actor->spr.cstat & CSTAT_SPRITE_INVISIBLE)) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (actor->spr.statnum == STAT_ACTOR || (actor->spr.statnum == STAT_STANDABLE && (actor->flags1 & SFLAG_CHECKSLEEP)))
|
|
|
|
{
|
|
|
|
if (actor->timetosleep > 1)
|
|
|
|
actor->timetosleep--;
|
|
|
|
else if (actor->timetosleep == 1)
|
|
|
|
ChangeActorStat(actor, STAT_ZOMBIEACTOR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-12-03 16:09:40 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// this is the implementation of DDukeActor::Tick. It is native so that
|
|
|
|
// its internally needed accesss does not have to be made public.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void TickActor(DDukeActor* self)
|
|
|
|
{
|
2022-12-17 11:41:56 +00:00
|
|
|
if (self->spr.statnum == STAT_ACTOR || self->spr.statnum == STAT_PLAYER || (self->flags3 & SFLAG3_FORCERUNCON))
|
2022-12-03 16:09:40 +00:00
|
|
|
{
|
2022-12-17 11:41:56 +00:00
|
|
|
double pdist;
|
|
|
|
int p;
|
|
|
|
|
|
|
|
if (self->spr.statnum != STAT_PLAYER)
|
|
|
|
{
|
|
|
|
p = findplayer(self, &pdist);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ud.multimode > 1)
|
|
|
|
p = findotherplayer(self->PlayerIndex(), &pdist);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p = self->PlayerIndex();
|
|
|
|
pdist = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run sprite animations.
|
2022-12-21 12:20:14 +00:00
|
|
|
if (self->curAction->name != NAME_None)
|
2022-12-17 11:41:56 +00:00
|
|
|
{
|
|
|
|
// This code was utterly cryptic in the original source.
|
2022-12-21 12:20:14 +00:00
|
|
|
int numframes = self->curAction->numframes;
|
|
|
|
int increment = self->curAction->increment;
|
|
|
|
int delay = self->curAction->delay;
|
2022-12-17 11:41:56 +00:00
|
|
|
|
|
|
|
self->spr.lotag += TICSPERFRAME;
|
|
|
|
if (self->spr.lotag > delay)
|
|
|
|
{
|
2022-12-17 14:55:01 +00:00
|
|
|
self->actioncounter++;
|
2022-12-17 11:41:56 +00:00
|
|
|
self->spr.lotag = 0;
|
2022-12-17 14:55:01 +00:00
|
|
|
self->curframe += increment;
|
2022-12-17 11:41:56 +00:00
|
|
|
}
|
2022-12-17 14:55:01 +00:00
|
|
|
if (abs(self->curframe) >= abs(numframes * increment))
|
|
|
|
self->curframe = 0;
|
2022-12-17 11:41:56 +00:00
|
|
|
}
|
|
|
|
|
2023-07-22 08:24:20 +00:00
|
|
|
int killit_flag = 0;
|
|
|
|
bool conres = execute(self, p, pdist, &killit_flag);
|
2023-04-30 06:57:28 +00:00
|
|
|
if (!conres && (self->flags4 & SFLAG4_CONOVERRIDE))
|
2022-12-03 16:09:40 +00:00
|
|
|
{
|
2023-04-30 06:57:28 +00:00
|
|
|
self->flags4 |= SFLAG4_INRUNSTATE;
|
2022-12-03 16:09:40 +00:00
|
|
|
IFVIRTUALPTR(self, DDukeActor, RunState)
|
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
VMValue val[] = { self, getPlayer(p), pdist};
|
2023-04-30 06:57:28 +00:00
|
|
|
try
|
|
|
|
{
|
2023-04-30 08:05:21 +00:00
|
|
|
VMCall(func, val, 3, nullptr, 0);
|
2023-04-30 06:57:28 +00:00
|
|
|
}
|
|
|
|
catch(const CDukeKillEvent& ev)
|
|
|
|
{
|
2023-07-22 08:24:20 +00:00
|
|
|
killit_flag = 1;
|
2023-04-30 06:57:28 +00:00
|
|
|
if (ev.Type() == 1)
|
|
|
|
{
|
|
|
|
self->Destroy();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2022-12-03 16:09:40 +00:00
|
|
|
}
|
2023-04-30 06:57:28 +00:00
|
|
|
self->flags4 &= ~SFLAG4_INRUNSTATE;
|
|
|
|
conres = true;
|
2022-12-03 16:09:40 +00:00
|
|
|
}
|
2023-04-30 06:57:28 +00:00
|
|
|
// moveactor gets only called for actors with a scripted runner.
|
2023-07-22 08:24:20 +00:00
|
|
|
if (conres) moveactor(self, p, pdist, killit_flag);
|
2022-12-03 16:09:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-30 13:29:34 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void respawnhitag(DDukeActor* actor)
|
|
|
|
{
|
2022-12-20 21:25:48 +00:00
|
|
|
if (actor->flags2 & SFLAG2_TRIGGERRESPAWN)
|
2022-11-30 13:29:34 +00:00
|
|
|
{
|
|
|
|
if (actor->spr.yint) operaterespawns(actor->spr.yint);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (actor->spr.hitag >= 0) operaterespawns(actor->spr.hitag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-06 11:26:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// this was once a macro
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 17:14:41 +00:00
|
|
|
void RANDOMSCRAP(DDukeActor* origin)
|
2020-07-06 11:26:26 +00:00
|
|
|
{
|
2022-09-11 21:05:42 +00:00
|
|
|
int r1 = krand(), r2 = krand(), r3 = krand(), r4 = krand();
|
|
|
|
DVector3 offset;
|
|
|
|
offset.X = krandf(16) - 8;
|
|
|
|
offset.Y = krandf(16) - 8;
|
|
|
|
offset.Z = krandf(16) - 8;
|
|
|
|
|
2022-10-07 16:51:29 +00:00
|
|
|
double v = isRR() ? 0.125 : 0.375;
|
2022-09-14 18:53:34 +00:00
|
|
|
|
|
|
|
auto a = randomAngle();
|
|
|
|
auto vel = krandf(4) + 4;
|
|
|
|
auto zvel = -krandf(8) - 2;
|
|
|
|
|
2022-12-29 08:56:14 +00:00
|
|
|
auto spawned = CreateActor(origin->sector(), origin->spr.pos + offset, DukeScrapClass, -8, DVector2(v, v), a, vel, zvel, origin, STAT_MISC);
|
2022-11-14 22:55:46 +00:00
|
|
|
if (spawned)
|
|
|
|
{
|
|
|
|
spawned->spriteextra = (r4 & 15);
|
|
|
|
}
|
2020-07-06 11:26:26 +00:00
|
|
|
}
|
|
|
|
|
2020-05-05 14:33:23 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2023-10-02 04:41:13 +00:00
|
|
|
void addammo(int weapon, DukePlayer* player, int amount)
|
2020-05-05 14:33:23 +00:00
|
|
|
{
|
2020-10-21 16:42:47 +00:00
|
|
|
player->ammo_amount[weapon] += amount;
|
2020-05-05 14:33:23 +00:00
|
|
|
|
2020-11-29 12:54:58 +00:00
|
|
|
if (player->ammo_amount[weapon] > gs.max_ammo_amount[weapon])
|
|
|
|
player->ammo_amount[weapon] = gs.max_ammo_amount[weapon];
|
2020-05-05 13:25:59 +00:00
|
|
|
}
|
|
|
|
|
2020-05-05 20:07:54 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2023-10-02 04:41:13 +00:00
|
|
|
void checkavailinven(DukePlayer* player)
|
2020-05-05 20:07:54 +00:00
|
|
|
{
|
|
|
|
|
2020-10-21 16:42:47 +00:00
|
|
|
if (player->firstaid_amount > 0)
|
|
|
|
player->inven_icon = ICON_FIRSTAID;
|
|
|
|
else if (player->steroids_amount > 0)
|
|
|
|
player->inven_icon = ICON_STEROIDS;
|
|
|
|
else if (player->holoduke_amount > 0)
|
|
|
|
player->inven_icon = ICON_HOLODUKE;
|
|
|
|
else if (player->jetpack_amount > 0)
|
|
|
|
player->inven_icon = ICON_JETPACK;
|
|
|
|
else if (player->heat_amount > 0)
|
|
|
|
player->inven_icon = ICON_HEATS;
|
|
|
|
else if (player->scuba_amount > 0)
|
|
|
|
player->inven_icon = ICON_SCUBA;
|
|
|
|
else if (player->boot_amount > 0)
|
|
|
|
player->inven_icon = ICON_BOOTS;
|
|
|
|
else player->inven_icon = ICON_NONE;
|
2020-05-05 20:07:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2023-10-02 04:41:13 +00:00
|
|
|
void checkavailweapon(DukePlayer* player)
|
2020-05-05 20:07:54 +00:00
|
|
|
{
|
2021-11-07 13:07:08 +00:00
|
|
|
int i, snum;
|
2020-05-05 20:07:54 +00:00
|
|
|
int weap;
|
|
|
|
|
2020-10-21 16:42:47 +00:00
|
|
|
if (player->wantweaponfire >= 0)
|
2020-05-05 20:07:54 +00:00
|
|
|
{
|
2020-10-21 16:42:47 +00:00
|
|
|
weap = player->wantweaponfire;
|
|
|
|
player->wantweaponfire = -1;
|
2020-05-05 20:07:54 +00:00
|
|
|
|
2020-10-21 16:42:47 +00:00
|
|
|
if (weap == player->curr_weapon) return;
|
|
|
|
else if (player->gotweapon[weap] && player->ammo_amount[weap] > 0)
|
2020-05-05 20:07:54 +00:00
|
|
|
{
|
2022-11-12 08:33:33 +00:00
|
|
|
fi.addweapon(player, weap, true);
|
2020-05-05 20:07:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 16:42:47 +00:00
|
|
|
weap = player->curr_weapon;
|
2022-11-12 08:33:33 +00:00
|
|
|
if (player->gotweapon[weap])
|
|
|
|
{
|
2023-10-02 04:26:45 +00:00
|
|
|
if (player->ammo_amount[weap] > 0 || (WeaponSwitch(player - (DukePlayer*)PlayerArray) & 2) == 0)
|
2022-11-12 08:33:33 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-05-05 20:07:54 +00:00
|
|
|
|
2020-10-21 16:42:47 +00:00
|
|
|
snum = player->GetPlayerNum();
|
2020-05-05 20:07:54 +00:00
|
|
|
|
2020-05-09 09:44:50 +00:00
|
|
|
int max = MAX_WEAPON;
|
|
|
|
for (i = 0; i <= max; i++)
|
2020-05-05 20:07:54 +00:00
|
|
|
{
|
|
|
|
weap = ud.wchoice[snum][i];
|
|
|
|
if ((g_gameType & GAMEFLAG_SHAREWARE) && weap > 6) continue;
|
|
|
|
|
|
|
|
if (weap == 0) weap = max;
|
|
|
|
else weap--;
|
|
|
|
|
2020-10-21 16:42:47 +00:00
|
|
|
if (weap == MIN_WEAPON || (player->gotweapon[weap] && player->ammo_amount[weap] > 0))
|
2020-05-05 20:07:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-05-09 09:44:50 +00:00
|
|
|
if (i == MAX_WEAPON) weap = MIN_WEAPON;
|
2020-05-05 20:07:54 +00:00
|
|
|
|
|
|
|
// Found the weapon
|
|
|
|
|
2020-10-21 16:42:47 +00:00
|
|
|
player->last_weapon = player->curr_weapon;
|
|
|
|
player->random_club_frame = 0;
|
|
|
|
player->curr_weapon = weap;
|
2020-05-06 14:10:44 +00:00
|
|
|
if (isWW2GI())
|
2020-05-05 20:07:54 +00:00
|
|
|
{
|
2023-10-02 09:36:58 +00:00
|
|
|
const auto pact = player->GetActor();
|
|
|
|
SetGameVarID(g_iWeaponVarID, player->curr_weapon, pact, snum); // snum is player index!
|
|
|
|
|
2020-10-21 16:42:47 +00:00
|
|
|
if (player->curr_weapon >= 0)
|
2020-05-05 20:07:54 +00:00
|
|
|
{
|
2023-10-02 09:36:58 +00:00
|
|
|
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(player->curr_weapon, snum), pact, snum);
|
2020-05-05 20:07:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-02 09:36:58 +00:00
|
|
|
SetGameVarID(g_iWorksLikeVarID, -1, pact, snum);
|
2020-05-05 20:07:54 +00:00
|
|
|
}
|
2023-10-02 09:36:58 +00:00
|
|
|
OnEvent(EVENT_CHANGEWEAPON, snum, pact, -1);
|
2020-05-05 20:07:54 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 16:42:47 +00:00
|
|
|
player->okickback_pic = player->kickback_pic = 0;
|
|
|
|
if (player->holster_weapon == 1)
|
2020-05-05 20:07:54 +00:00
|
|
|
{
|
2020-10-21 16:42:47 +00:00
|
|
|
player->holster_weapon = 0;
|
|
|
|
player->weapon_pos = 10;
|
2020-05-05 20:07:54 +00:00
|
|
|
}
|
2020-10-21 16:42:47 +00:00
|
|
|
else player->weapon_pos = -1;
|
2020-05-05 20:07:54 +00:00
|
|
|
}
|
|
|
|
|
2020-05-05 22:08:08 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2023-10-02 04:41:13 +00:00
|
|
|
void clearcamera(DukePlayer* ps)
|
2020-05-05 22:08:08 +00:00
|
|
|
{
|
2023-10-02 09:37:18 +00:00
|
|
|
const auto pact = ps->GetActor();
|
2020-11-02 23:20:51 +00:00
|
|
|
ps->newOwner = nullptr;
|
2023-10-02 09:37:18 +00:00
|
|
|
pact->restoreloc();
|
|
|
|
updatesector(pact->getPosWithOffsetZ(), &ps->cursector);
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-10-21 17:38:53 +00:00
|
|
|
DukeStatIterator it(STAT_ACTOR);
|
|
|
|
while (auto k = it.Next())
|
2020-05-05 22:08:08 +00:00
|
|
|
{
|
2022-12-20 21:25:48 +00:00
|
|
|
if (k->flags2 & SFLAG2_CAMERA)
|
2022-09-01 16:15:52 +00:00
|
|
|
k->spr.yint = 0;
|
2020-05-05 22:08:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 17:38:53 +00:00
|
|
|
int ssp(DDukeActor* const actor, unsigned int cliptype) //The set sprite function
|
2020-05-05 22:08:08 +00:00
|
|
|
{
|
2020-10-24 07:31:15 +00:00
|
|
|
Collision c;
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2022-11-25 12:13:50 +00:00
|
|
|
return movesprite_ex(actor, DVector3(actor->spr.Angles.Yaw.ToVector() * actor->vel.X, actor->vel.Z), cliptype, c) == kHitNone;
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2022-12-15 20:12:20 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-10-24 07:40:10 +00:00
|
|
|
void insertspriteq(DDukeActor* const actor)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
|
|
|
if (spriteqamount > 0)
|
|
|
|
{
|
2020-10-24 07:40:10 +00:00
|
|
|
if (spriteq[spriteqloc] != nullptr)
|
|
|
|
{
|
2021-12-07 16:09:28 +00:00
|
|
|
// todo: Make list size a CVAR.
|
2022-11-20 18:25:23 +00:00
|
|
|
spriteq[spriteqloc]->Destroy();
|
2020-10-24 07:40:10 +00:00
|
|
|
}
|
|
|
|
spriteq[spriteqloc] = actor;
|
2020-05-07 20:30:19 +00:00
|
|
|
spriteqloc = (spriteqloc + 1) % spriteqamount;
|
2020-05-05 22:08:08 +00:00
|
|
|
}
|
2022-10-07 21:52:29 +00:00
|
|
|
else actor->spr.scale = DVector2(0, 0);
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// consolidation of several nearly identical functions
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2022-12-12 18:39:17 +00:00
|
|
|
void lotsofstuff(DDukeActor* actor, int n, PClassActor* spawntype)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
2020-10-24 07:35:43 +00:00
|
|
|
for (int i = n; i > 0; i--)
|
2020-05-05 22:08:08 +00:00
|
|
|
{
|
2022-09-14 18:53:34 +00:00
|
|
|
DAngle r1 = randomAngle();
|
2022-02-12 11:37:27 +00:00
|
|
|
double r2 = zrand(47);
|
2022-10-07 16:51:29 +00:00
|
|
|
auto j = CreateActor(actor->sector(), actor->spr.pos.plusZ(-r2), spawntype, -32, DVector2(0.125, 0.125), r1, 0., 0., actor, 5);
|
2021-12-21 16:32:28 +00:00
|
|
|
if (j) j->spr.cstat = randomFlip();
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-09-11 16:41:52 +00:00
|
|
|
// movesector - used by sector effectors
|
2020-05-07 20:30:19 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2022-09-11 14:29:12 +00:00
|
|
|
void movesector(DDukeActor* const actor, int msindex, DAngle rotation)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
|
|
|
//T1,T2 and T3 are used for all the sector moving stuff!!!
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.pos.XY() += actor->spr.Angles.Yaw.ToVector() * actor->vel.X;
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2022-11-15 14:24:17 +00:00
|
|
|
for(auto& wal : actor->sector()->walls)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
2022-10-10 00:50:41 +00:00
|
|
|
dragpoint(&wal, actor->spr.pos.XY() + mspos[msindex].Rotated(rotation));
|
2022-09-11 14:29:12 +00:00
|
|
|
msindex++;
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-06 14:10:44 +00:00
|
|
|
|
2020-05-06 19:11:36 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void movecyclers(void)
|
|
|
|
{
|
2022-11-20 13:13:11 +00:00
|
|
|
for (int q = cyclers.Size() - 1; q >= 0; q--)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2021-11-06 20:53:15 +00:00
|
|
|
Cycler* c = &cyclers[q];
|
2021-11-18 19:17:47 +00:00
|
|
|
auto sect = c->sector;
|
2020-05-06 19:11:36 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
int shade = c->shade2;
|
2022-09-15 17:17:27 +00:00
|
|
|
int j = shade + int(BobVal(c->lotag) * 16);
|
2021-11-06 20:53:15 +00:00
|
|
|
int cshade = c->shade1;
|
2020-05-06 19:11:36 +00:00
|
|
|
|
|
|
|
if (j < cshade) j = cshade;
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (j > shade) j = shade;
|
2020-05-06 19:11:36 +00:00
|
|
|
|
2021-11-06 20:53:15 +00:00
|
|
|
c->lotag += sect->extra;
|
|
|
|
if (c->state)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2022-11-15 14:24:17 +00:00
|
|
|
for (auto& wal : sect->walls)
|
2021-11-07 16:27:05 +00:00
|
|
|
{
|
|
|
|
if (wal.hitag != 1)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2021-11-07 16:27:05 +00:00
|
|
|
wal.shade = j;
|
2020-05-06 19:11:36 +00:00
|
|
|
|
2021-11-21 07:42:36 +00:00
|
|
|
if ((wal.cstat & CSTAT_WALL_BOTTOM_SWAP) && wal.twoSided())
|
2021-11-07 16:27:05 +00:00
|
|
|
wal.nextWall()->shade = j;
|
2020-05-06 19:11:36 +00:00
|
|
|
|
|
|
|
}
|
2021-11-07 16:27:05 +00:00
|
|
|
}
|
2021-11-06 20:53:15 +00:00
|
|
|
sect->floorshade = sect->ceilingshade = j;
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-20 12:57:51 +00:00
|
|
|
void addcycler(sectortype* sector, int lotag, int shade, int shade2, int hitag, int state)
|
|
|
|
{
|
2022-11-20 13:13:11 +00:00
|
|
|
cyclers.Reserve(1);
|
|
|
|
cyclers.Last().sector = sector;
|
|
|
|
cyclers.Last().lotag = lotag;
|
|
|
|
cyclers.Last().shade1 = shade;
|
|
|
|
cyclers.Last().shade2 = shade2;
|
|
|
|
cyclers.Last().hitag = hitag;
|
|
|
|
cyclers.Last().state = state;
|
2022-11-20 12:57:51 +00:00
|
|
|
}
|
|
|
|
|
2020-05-06 19:11:36 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void movedummyplayers(void)
|
|
|
|
{
|
2020-10-21 19:14:25 +00:00
|
|
|
DukeStatIterator iti(STAT_DUMMYPLAYER);
|
|
|
|
while (auto act = iti.Next())
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2020-10-21 19:14:25 +00:00
|
|
|
if (!act->GetOwner()) continue;
|
2023-10-02 09:37:40 +00:00
|
|
|
const auto p = getPlayer(act->GetOwner()->PlayerIndex());
|
|
|
|
const auto pact = p->GetActor();
|
2020-05-06 19:11:36 +00:00
|
|
|
|
2023-10-02 09:37:40 +00:00
|
|
|
if ((!isRR() && p->on_crane != nullptr) || !p->insector() || p->cursector->lotag != 1 || getPlayer(0)->GetActor()->spr.extra <= 0)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2023-10-02 09:37:40 +00:00
|
|
|
p->dummyplayersprite = nullptr;
|
2022-11-20 18:25:23 +00:00
|
|
|
act->Destroy();
|
2020-05-06 19:11:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-02 09:37:40 +00:00
|
|
|
if (p->on_ground && p->on_warping_sector == 1 && p->cursector->lotag == 1)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
act->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
|
2022-08-20 16:56:13 +00:00
|
|
|
act->spr.pos.Z = act->sector()->ceilingz + 27;
|
2023-10-02 09:37:40 +00:00
|
|
|
act->spr.Angles.Yaw = pact->spr.Angles.Yaw;
|
2022-12-22 08:49:42 +00:00
|
|
|
if (act->counter == 8)
|
|
|
|
act->counter = 0;
|
|
|
|
else act->counter++;
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-08-20 16:56:13 +00:00
|
|
|
if (act->sector()->lotag != 2) act->spr.pos.Z = act->sector()->floorz;
|
2021-12-21 16:32:28 +00:00
|
|
|
act->spr.cstat = CSTAT_SPRITE_INVISIBLE;
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-02 09:37:40 +00:00
|
|
|
act->spr.pos.XY() += pact->spr.pos.XY() - pact->opos.XY();
|
2022-02-06 20:11:08 +00:00
|
|
|
SetActor(act, act->spr.pos);
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 19:14:25 +00:00
|
|
|
void moveplayers(void)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2022-09-12 16:26:27 +00:00
|
|
|
double other;
|
2020-05-06 19:11:36 +00:00
|
|
|
|
2020-10-21 19:14:25 +00:00
|
|
|
DukeStatIterator iti(STAT_PLAYER);
|
|
|
|
while (auto act = iti.Next())
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2020-10-21 19:14:25 +00:00
|
|
|
int pn = act->PlayerIndex();
|
2023-10-02 02:51:13 +00:00
|
|
|
auto p = getPlayer(pn);
|
2021-01-04 02:27:31 +00:00
|
|
|
|
2020-10-21 19:14:25 +00:00
|
|
|
if (act->GetOwner())
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2020-11-02 23:20:51 +00:00
|
|
|
if (p->newOwner != nullptr) //Looking thru the camera
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2023-10-02 09:38:06 +00:00
|
|
|
act->restoreloc();
|
2022-02-06 20:11:08 +00:00
|
|
|
SetActor(act, act->spr.pos);
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-17 11:41:56 +00:00
|
|
|
TickActor(act);
|
2020-05-06 19:11:36 +00:00
|
|
|
if (ud.multimode > 1)
|
2020-10-21 19:14:25 +00:00
|
|
|
{
|
2022-12-17 11:41:56 +00:00
|
|
|
otherp = findotherplayer(pn, &other);
|
2023-10-02 02:51:13 +00:00
|
|
|
auto psp = getPlayer(otherp)->GetActor();
|
2023-10-02 09:38:06 +00:00
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
if (psp->spr.extra > 0)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2022-10-07 21:33:37 +00:00
|
|
|
if (act->spr.scale.Y > 0.5 && psp->spr.scale.Y < 0.5)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2022-09-12 16:26:27 +00:00
|
|
|
if (other < 1400/16. && p->knee_incs == 0)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
|
|
|
p->knee_incs = 1;
|
|
|
|
p->weapon_pos = -1;
|
2023-10-02 09:38:06 +00:00
|
|
|
p->actorsqu = psp;
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-21 19:14:25 +00:00
|
|
|
}
|
2020-05-06 19:11:36 +00:00
|
|
|
if (ud.god)
|
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
act->spr.extra = gs.max_player_health;
|
|
|
|
act->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
|
2020-05-06 19:11:36 +00:00
|
|
|
if (!isWW2GI() && !isRR())
|
|
|
|
p->jetpack_amount = 1599;
|
|
|
|
}
|
|
|
|
|
2020-10-17 08:30:11 +00:00
|
|
|
if (p->actorsqu != nullptr)
|
2020-08-05 07:43:06 +00:00
|
|
|
{
|
2023-10-02 09:38:06 +00:00
|
|
|
act->spr.Angles.Yaw += deltaangle(act->spr.Angles.Yaw, (p->actorsqu->spr.pos.XY() - act->spr.pos.XY()).Angle()) * 0.25;
|
2020-08-05 07:43:06 +00:00
|
|
|
}
|
|
|
|
|
2021-12-21 16:32:28 +00:00
|
|
|
if (act->spr.extra > 0)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
|
|
|
// currently alive...
|
|
|
|
|
2020-10-21 19:14:25 +00:00
|
|
|
act->SetHitOwner(act);
|
2020-05-06 19:11:36 +00:00
|
|
|
|
|
|
|
if (ud.god == 0)
|
2022-11-25 16:43:13 +00:00
|
|
|
if (ceilingspace(act->sector()) || floorspace(act->sector()))
|
2020-05-06 19:11:36 +00:00
|
|
|
quickkill(p);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-02 09:38:06 +00:00
|
|
|
act->spr.pos.Z += 20;
|
2020-11-02 23:20:51 +00:00
|
|
|
p->newOwner = nullptr;
|
2020-08-05 07:43:06 +00:00
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
if (p->wackedbyactor != nullptr && p->wackedbyactor->spr.statnum < MAXSTATUS)
|
2020-08-05 07:43:06 +00:00
|
|
|
{
|
2023-10-02 09:38:06 +00:00
|
|
|
act->spr.Angles.Yaw += deltaangle(act->spr.Angles.Yaw, (p->wackedbyactor->spr.pos.XY() - act->spr.pos.XY()).Angle()) * 0.5;
|
2020-08-05 07:43:06 +00:00
|
|
|
}
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-21 08:48:38 +00:00
|
|
|
if (p->holoduke_on == nullptr)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2022-11-20 18:25:23 +00:00
|
|
|
act->Destroy();
|
2020-05-06 19:11:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-12-21 16:32:28 +00:00
|
|
|
act->spr.cstat = 0;
|
2020-05-06 19:11:36 +00:00
|
|
|
|
2022-10-07 21:33:37 +00:00
|
|
|
if (act->spr.scale.X < 0.65625)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2022-10-07 21:44:21 +00:00
|
|
|
act->spr.scale.X += (0.0625);
|
2021-12-21 16:32:28 +00:00
|
|
|
act->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT;
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
2022-10-07 21:46:28 +00:00
|
|
|
else act->spr.scale.X = (0.65625);
|
2022-10-06 17:21:19 +00:00
|
|
|
|
2022-10-07 21:33:37 +00:00
|
|
|
if (act->spr.scale.Y < 0.5625)
|
2022-10-08 09:12:54 +00:00
|
|
|
act->spr.scale.Y += (0.0625);
|
2020-05-06 19:11:36 +00:00
|
|
|
else
|
|
|
|
{
|
2022-10-07 21:46:28 +00:00
|
|
|
act->spr.scale.Y = (0.5625);
|
2021-12-30 15:51:56 +00:00
|
|
|
if (act->sector()->lotag != ST_2_UNDERWATER)
|
2020-10-21 19:14:25 +00:00
|
|
|
makeitfall(act);
|
2022-09-03 08:03:30 +00:00
|
|
|
if (act->vel.Z == 0 && act->sector()->lotag == ST_1_ABOVE_WATER)
|
2022-08-20 15:59:15 +00:00
|
|
|
act->spr.pos.Z += 32;
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
|
2021-12-21 16:32:28 +00:00
|
|
|
if (act->spr.extra < 8)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2022-09-03 08:05:20 +00:00
|
|
|
act->vel.X = 8;
|
2021-12-21 16:32:28 +00:00
|
|
|
act->spr.extra++;
|
2020-10-21 19:14:25 +00:00
|
|
|
ssp(act, CLIPMASK0);
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-06 20:11:08 +00:00
|
|
|
SetActor(act, act->spr.pos);
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-30 15:24:51 +00:00
|
|
|
if (act->insector())
|
2021-12-07 08:44:28 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if (act->sector()->ceilingstat & CSTAT_SECTOR_SKY)
|
|
|
|
act->spr.shade += (act->sector()->ceilingshade - act->spr.shade) >> 1;
|
2021-12-07 08:44:28 +00:00
|
|
|
else
|
2021-12-30 15:51:56 +00:00
|
|
|
act->spr.shade += (act->sector()->floorshade - act->spr.shade) >> 1;
|
2021-12-07 08:44:28 +00:00
|
|
|
}
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-07 07:49:05 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-14 16:12:36 +00:00
|
|
|
void movefallers(void)
|
|
|
|
{
|
|
|
|
DukeStatIterator iti(STAT_FALLER);
|
|
|
|
while (auto act = iti.Next())
|
|
|
|
{
|
|
|
|
auto sectp = act->sector();
|
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (act->counter == 0)
|
2022-12-14 16:12:36 +00:00
|
|
|
{
|
|
|
|
act->spr.pos.Z -= 16;
|
|
|
|
DAngle saved_angle = act->spr.Angles.Yaw;
|
|
|
|
int x = act->spr.extra;
|
|
|
|
int j = fi.ifhitbyweapon(act);
|
|
|
|
if (j >= 0)
|
|
|
|
{
|
2022-12-16 15:56:47 +00:00
|
|
|
if (j == 2) // explosive
|
2022-12-14 16:12:36 +00:00
|
|
|
{
|
|
|
|
if (act->spr.extra <= 0)
|
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
act->counter = 1;
|
2022-12-14 16:12:36 +00:00
|
|
|
DukeStatIterator itj(STAT_FALLER);
|
|
|
|
while (auto a2 = itj.Next())
|
|
|
|
{
|
|
|
|
if (a2->spr.hitag == act->spr.hitag)
|
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
a2->counter = 1;
|
2022-12-14 16:12:36 +00:00
|
|
|
a2->spr.cstat &= ~CSTAT_SPRITE_ONE_SIDE;
|
2022-12-29 08:56:14 +00:00
|
|
|
if (a2->IsKindOf(DukeSteamBaseClass))
|
2022-12-14 16:12:36 +00:00
|
|
|
a2->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
act->hitextra = 0;
|
|
|
|
act->spr.extra = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
act->spr.Angles.Yaw = saved_angle;
|
|
|
|
act->spr.pos.Z += 16;
|
|
|
|
}
|
2022-12-22 08:49:42 +00:00
|
|
|
else if (act->counter == 1)
|
2022-12-14 16:12:36 +00:00
|
|
|
{
|
|
|
|
if (act->spr.lotag > 0)
|
|
|
|
{
|
|
|
|
act->spr.lotag -= 3;
|
|
|
|
if (act->spr.lotag <= 0 || isRR())
|
|
|
|
{
|
|
|
|
act->vel.X = 2 + krandf(4);
|
|
|
|
act->vel.Z = -4 + krandf(4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (act->vel.X > 0)
|
|
|
|
{
|
|
|
|
act->vel.X -= 0.5;
|
|
|
|
ssp(act, CLIPMASK0);
|
|
|
|
}
|
|
|
|
|
|
|
|
double grav;
|
|
|
|
if (floorspace(act->sector())) grav = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ceilingspace(act->sector()))
|
|
|
|
grav = gs.gravity / 6;
|
|
|
|
else
|
|
|
|
grav = gs.gravity;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (act->spr.pos.Z < sectp->floorz - 1)
|
|
|
|
{
|
|
|
|
act->vel.Z += grav;
|
|
|
|
if (act->vel.Z > 24)
|
|
|
|
act->vel.Z = 24;
|
|
|
|
act->spr.pos.Z += act->vel.Z;
|
|
|
|
}
|
|
|
|
if ((sectp->floorz - act->spr.pos.Z) < 16)
|
|
|
|
{
|
|
|
|
int j = 1 + (krand() & 7);
|
|
|
|
for (int x = 0; x < j; x++) RANDOMSCRAP(act);
|
|
|
|
act->Destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-30 15:21:09 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// well, also surfacing...
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void checkdive(DDukeActor* transporter, DDukeActor* transported)
|
|
|
|
{
|
|
|
|
auto sectp = transporter->sector();
|
|
|
|
int sectlotag = sectp->lotag;
|
|
|
|
auto Owner = transporter->GetOwner();
|
|
|
|
int warpdir;
|
|
|
|
int onfloorz = transporter->temp_data[4];
|
|
|
|
Collision coll;
|
|
|
|
|
|
|
|
double ll = abs(transported->vel.Z), ll2;
|
|
|
|
if (transported->vel.Z >= 0)
|
|
|
|
warpdir = 2;
|
|
|
|
else
|
|
|
|
warpdir = 1;
|
|
|
|
|
|
|
|
int warpspriteto = 0;
|
|
|
|
if (ll && sectlotag == ST_2_UNDERWATER && transported->spr.pos.Z < sectp->ceilingz + ll && warpdir == 1)
|
|
|
|
warpspriteto = 1;
|
|
|
|
|
|
|
|
if (ll && sectlotag == ST_1_ABOVE_WATER && transported->spr.pos.Z > sectp->floorz - ll && warpdir == 2)
|
|
|
|
warpspriteto = 1;
|
|
|
|
|
|
|
|
if (ud.mapflags & MFLAG_ALLSECTORTYPES)
|
|
|
|
{
|
|
|
|
if (ll && sectlotag == ST_161_CEILING_TELEPORT && transported->spr.pos.Z < (sectp->ceilingz + ll) && warpdir == 1)
|
|
|
|
{
|
|
|
|
warpspriteto = 1;
|
|
|
|
ll2 = ll - abs(transported->spr.pos.Z - sectp->ceilingz);
|
|
|
|
}
|
|
|
|
else if (sectlotag == ST_161_CEILING_TELEPORT && transported->spr.pos.Z < (sectp->ceilingz + 3.90625) && warpdir == 1)
|
|
|
|
{
|
|
|
|
warpspriteto = 1;
|
|
|
|
ll2 = zmaptoworld;
|
|
|
|
}
|
|
|
|
if (ll && sectlotag == ST_160_FLOOR_TELEPORT && transported->spr.pos.Z > (sectp->floorz - ll) && warpdir == 2)
|
|
|
|
{
|
|
|
|
warpspriteto = 1;
|
|
|
|
ll2 = ll - abs(sectp->floorz - transported->spr.pos.Z);
|
|
|
|
}
|
|
|
|
else if (sectlotag == ST_160_FLOOR_TELEPORT && transported->spr.pos.Z > (sectp->floorz - 3.90625) && warpdir == 2)
|
|
|
|
{
|
|
|
|
warpspriteto = 1;
|
|
|
|
ll2 = zmaptoworld;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sectlotag == ST_0_NO_EFFECT && (onfloorz || abs(transported->spr.pos.Z - transporter->spr.pos.Z) < 16))
|
|
|
|
{
|
|
|
|
if ((!Owner || Owner->GetOwner() != Owner) && onfloorz && transporter->counter > 0 && transported->spr.statnum != STAT_MISC)
|
|
|
|
{
|
|
|
|
transporter->counter++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
warpspriteto = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (warpspriteto)
|
|
|
|
{
|
|
|
|
if ((transported->flags1 & SFLAG_NOTELEPORT)) return;
|
|
|
|
if (transported->GetClass() == DukePlayerOnWaterClass)
|
|
|
|
{
|
|
|
|
if (sectlotag == ST_2_UNDERWATER)
|
|
|
|
{
|
|
|
|
transported->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (transported->GetClass() != DukeWaterBubbleClass)
|
|
|
|
{
|
|
|
|
if (transported->spr.statnum == STAT_MISC && !(sectlotag == ST_1_ABOVE_WATER || sectlotag == ST_2_UNDERWATER || ((ud.mapflags & MFLAG_ALLSECTORTYPES) && (sectlotag == ST_160_FLOOR_TELEPORT || sectlotag == ST_161_CEILING_TELEPORT))))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (sectlotag > 0)
|
|
|
|
{
|
|
|
|
auto spawned = spawn(transported, DukeWaterSplashClass);
|
|
|
|
if (spawned && sectlotag == 1 && transported->spr.statnum == 4)
|
|
|
|
{
|
|
|
|
spawned->vel.X = transported->vel.X * 0.5;
|
|
|
|
spawned->spr.Angles.Yaw = transported->spr.Angles.Yaw;
|
|
|
|
ssp(spawned, CLIPMASK0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (sectlotag)
|
|
|
|
{
|
|
|
|
case ST_0_NO_EFFECT:
|
|
|
|
if (onfloorz)
|
|
|
|
{
|
|
|
|
if (transported->spr.statnum == STAT_PROJECTILE || (checkcursectnums(transporter->sector()) == -1 && checkcursectnums(Owner->sector()) == -1))
|
|
|
|
{
|
|
|
|
transported->spr.pos += (Owner->spr.pos - transporter->spr.pos.XY()).plusZ(-Owner->sector()->floorz);
|
|
|
|
transported->spr.Angles.Yaw = Owner->spr.Angles.Yaw;
|
|
|
|
|
|
|
|
transported->backupang();
|
|
|
|
|
|
|
|
if (transporter->spr.pal == 0 || isRR())
|
|
|
|
{
|
|
|
|
auto beam = spawn(transporter, DukeTransporterBeamClass);
|
|
|
|
if (beam) S_PlayActorSound(TELEPORTER, beam);
|
|
|
|
|
|
|
|
beam = spawn(Owner, DukeTransporterBeamClass);
|
|
|
|
if (beam) S_PlayActorSound(TELEPORTER, beam);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Owner && Owner->GetOwner() == Owner)
|
|
|
|
{
|
|
|
|
transporter->counter = 13;
|
|
|
|
Owner->counter = 13;
|
|
|
|
}
|
|
|
|
|
|
|
|
ChangeActorSect(transported, Owner->sector());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
transported->spr.pos.XY() += Owner->spr.pos.XY() - transporter->spr.pos.XY();
|
|
|
|
transported->spr.pos.Z = Owner->spr.pos.Z + 16;
|
|
|
|
transported->backupz();
|
|
|
|
ChangeActorSect(transported, Owner->sector());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ST_1_ABOVE_WATER:
|
|
|
|
transported->spr.pos.XY() += Owner->spr.pos.XY() - transporter->spr.pos.XY();
|
|
|
|
transported->spr.pos.Z = Owner->sector()->ceilingz + ll;
|
|
|
|
transported->backupz();
|
|
|
|
ChangeActorSect(transported, Owner->sector());
|
|
|
|
break;
|
|
|
|
case ST_2_UNDERWATER:
|
|
|
|
transported->spr.pos.XY() += Owner->spr.pos.XY() - transporter->spr.pos.XY();
|
|
|
|
transported->spr.pos.Z = Owner->sector()->ceilingz - ll;
|
|
|
|
transported->backupz();
|
|
|
|
ChangeActorSect(transported, Owner->sector());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ST_160_FLOOR_TELEPORT:
|
|
|
|
if (!(ud.mapflags & MFLAG_ALLSECTORTYPES)) break;
|
|
|
|
transported->spr.pos.XY() += Owner->spr.pos.XY() - transporter->spr.pos.XY();
|
|
|
|
transported->spr.pos.Z = Owner->sector()->ceilingz + ll2;
|
|
|
|
transported->backupz();
|
|
|
|
|
|
|
|
ChangeActorSect(transported, Owner->sector());
|
|
|
|
|
|
|
|
movesprite_ex(transported, DVector3(transported->spr.Angles.Yaw.ToVector() * transported->vel.X, 0), CLIPMASK1, coll);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case ST_161_CEILING_TELEPORT:
|
|
|
|
if (!(ud.mapflags & MFLAG_ALLSECTORTYPES)) break;
|
|
|
|
transported->spr.pos += Owner->spr.pos.XY() - transporter->spr.pos.XY();
|
|
|
|
transported->spr.pos.Z = Owner->sector()->floorz - ll;
|
|
|
|
transported->backupz();
|
|
|
|
|
|
|
|
ChangeActorSect(transported, Owner->sector());
|
|
|
|
|
|
|
|
movesprite_ex(transported, DVector3(transported->spr.Angles.Yaw.ToVector() * transported->vel.X, 0), CLIPMASK1, coll);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-14 16:12:36 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-03 16:24:41 +00:00
|
|
|
void tickstat(int stat, bool deleteinvalid)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2022-11-20 21:07:10 +00:00
|
|
|
DukeStatIterator iti(stat);
|
2020-10-24 08:30:17 +00:00
|
|
|
while (auto act = iti.Next())
|
2022-11-20 21:07:10 +00:00
|
|
|
{
|
2022-12-20 21:25:48 +00:00
|
|
|
if ((act->flags2 & SFLAG2_DIENOW) || act->sector() == nullptr || (deleteinvalid && act->spr.scale.X == 0))
|
2022-11-20 21:07:10 +00:00
|
|
|
{
|
2022-12-17 11:41:56 +00:00
|
|
|
addkill(act);
|
2022-11-20 21:07:10 +00:00
|
|
|
act->Destroy();
|
|
|
|
}
|
2022-12-11 23:58:04 +00:00
|
|
|
else if (stat != STAT_ACTOR || !badguy(act) || !monsterCheatCheck(act))
|
|
|
|
{
|
|
|
|
CallTick(act);
|
2023-04-30 06:57:28 +00:00
|
|
|
|
|
|
|
// check if DIENOW was set by Tick()
|
|
|
|
if ((act->flags2 & SFLAG2_DIENOW))
|
|
|
|
{
|
|
|
|
addkill(act);
|
|
|
|
act->Destroy();
|
|
|
|
}
|
2022-12-11 23:58:04 +00:00
|
|
|
}
|
2022-11-20 21:07:10 +00:00
|
|
|
}
|
2022-11-20 10:58:19 +00:00
|
|
|
}
|
2022-11-20 07:10:15 +00:00
|
|
|
|
2022-11-20 10:58:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2022-11-20 10:58:19 +00:00
|
|
|
void operaterespawns(int low)
|
|
|
|
{
|
|
|
|
DukeStatIterator it(STAT_FX);
|
|
|
|
while (auto act = it.Next())
|
|
|
|
{
|
|
|
|
CallOnRespawn(act, low);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-20 10:58:19 +00:00
|
|
|
|
2020-05-07 07:49:05 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-12 08:25:41 +00:00
|
|
|
void detonate(DDukeActor *actor, PClassActor* explosion)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2022-11-30 16:15:44 +00:00
|
|
|
ud.earthquaketime = 16;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-10-21 19:57:18 +00:00
|
|
|
DukeStatIterator itj(STAT_EFFECTOR);
|
|
|
|
while (auto effector = itj.Next())
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (actor->spr.hitag == effector->spr.hitag)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (effector->spr.lotag == SE_13_EXPLOSIVE)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-24 20:23:12 +00:00
|
|
|
if (effector->temp_data[2] == 0)
|
|
|
|
effector->temp_data[2] = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2021-12-21 16:39:25 +00:00
|
|
|
else if (effector->spr.lotag == SE_8_UP_OPEN_DOOR_LIGHTS)
|
2020-10-24 20:23:12 +00:00
|
|
|
effector->temp_data[4] = 1;
|
2021-12-21 16:39:25 +00:00
|
|
|
else if (effector->spr.lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
if (effector->counter == 0)
|
|
|
|
effector->counter = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2021-12-21 16:39:25 +00:00
|
|
|
else if (effector->spr.lotag == SE_21_DROP_FLOOR)
|
2022-12-22 08:49:42 +00:00
|
|
|
effector->counter = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
|
|
|
|
2022-08-20 15:59:15 +00:00
|
|
|
actor->spr.pos.Z -= 32;
|
2020-05-07 20:30:19 +00:00
|
|
|
|
2022-10-07 21:33:37 +00:00
|
|
|
if ((actor->temp_data[3] == 1 && actor->spr.scale.X != 0) || actor->spr.lotag == -99)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
int x = actor->spr.extra;
|
2020-10-21 19:57:18 +00:00
|
|
|
spawn(actor, explosion);
|
2022-12-29 15:59:07 +00:00
|
|
|
hitradius(actor, gs.seenineblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x);
|
2020-10-21 19:57:18 +00:00
|
|
|
S_PlayActorSound(PIPEBOMB_EXPLODE, actor);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
|
2022-10-07 21:33:37 +00:00
|
|
|
if (actor->spr.scale.X != 0)
|
2020-10-21 19:57:18 +00:00
|
|
|
for (int x = 0; x < 8; x++) RANDOMSCRAP(actor);
|
2020-05-07 20:30:19 +00:00
|
|
|
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-07 20:30:19 +00:00
|
|
|
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-28 23:51:26 +00:00
|
|
|
void gutsdir(DDukeActor* actor, PClassActor* gtype, int n, int p)
|
2020-10-21 22:05:08 +00:00
|
|
|
{
|
2022-10-07 16:51:29 +00:00
|
|
|
double scale;
|
2020-10-21 22:05:08 +00:00
|
|
|
|
2022-10-07 21:33:37 +00:00
|
|
|
if (badguy(actor) && actor->spr.scale.X < 0.25)
|
2022-10-07 16:51:29 +00:00
|
|
|
scale = 0.125;
|
|
|
|
else scale = 0.5;
|
2020-10-21 22:05:08 +00:00
|
|
|
|
2022-08-23 20:46:54 +00:00
|
|
|
double gutz = actor->spr.pos.Z - 8;
|
2022-09-27 11:59:57 +00:00
|
|
|
double floorz = getflorzofslopeptr(actor->sector(), actor->spr.pos);
|
2020-10-21 22:05:08 +00:00
|
|
|
|
2022-08-23 20:46:54 +00:00
|
|
|
if (gutz > floorz - 8)
|
|
|
|
gutz = floorz - 8;
|
2020-10-21 22:05:08 +00:00
|
|
|
|
2022-12-21 15:31:51 +00:00
|
|
|
gutz += actor->IntVar(NAME_gutsoffset);
|
2020-10-21 22:05:08 +00:00
|
|
|
|
|
|
|
for (int j = 0; j < n; j++)
|
|
|
|
{
|
2022-09-14 18:53:34 +00:00
|
|
|
auto a = randomAngle();
|
|
|
|
auto vel = krandf(8) + 16;
|
|
|
|
auto zvel = -krandf(8) - 2;
|
|
|
|
|
2020-10-21 22:05:08 +00:00
|
|
|
// TRANSITIONAL: owned by a player???
|
2023-10-02 02:51:13 +00:00
|
|
|
CreateActor(actor->sector(), DVector3(actor->spr.pos.XY(), gutz), gtype, -32, DVector2(scale, scale), a, vel, zvel, getPlayer(p)->GetActor(), 5);
|
2020-10-21 22:05:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-29 14:19:22 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void blastceiling(DDukeActor* actor, double radius)
|
|
|
|
{
|
|
|
|
BFSSectorSearch search(actor->sector());
|
|
|
|
|
|
|
|
while (auto dasectp = search.GetNext())
|
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
|
|
|
auto wal = dasectp->walls.Data();
|
|
|
|
double d = (wal->pos - actor->spr.pos.XY()).Sum();
|
|
|
|
if (d < radius)
|
|
|
|
checkhitceiling(dasectp);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto thirdpoint = wal->point2Wall()->point2Wall();
|
|
|
|
d = (thirdpoint->pos - actor->spr.pos.XY()).Sum();
|
|
|
|
if (d < radius)
|
|
|
|
checkhitceiling(dasectp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto& wal : dasectp->walls)
|
|
|
|
{
|
|
|
|
if ((wal.pos - actor->spr.pos.XY()).Sum() < radius)
|
|
|
|
{
|
|
|
|
if (wal.twoSided())
|
|
|
|
{
|
|
|
|
search.Add(wal.nextSector());
|
|
|
|
}
|
|
|
|
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.
|
|
|
|
sectortype* sect = wal.sectorp();
|
|
|
|
updatesector(w1, §);
|
|
|
|
|
|
|
|
if (sect && cansee(w1, sect, actor->spr.pos, actor->sector()))
|
|
|
|
checkhitwall(actor, &wal, DVector3(wal.pos, actor->spr.pos.Z));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-12-29 15:59:07 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void hitradius(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int hp4)
|
|
|
|
{
|
|
|
|
double radius = r * inttoworld;
|
|
|
|
static const uint8_t statlist[] = { STAT_DEFAULT, STAT_ACTOR, STAT_STANDABLE, STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC };
|
|
|
|
|
|
|
|
if (!(actor->flags3 & SFLAG3_NOCEILINGBLAST))
|
|
|
|
{
|
|
|
|
blastceiling(actor, radius);
|
|
|
|
}
|
|
|
|
|
|
|
|
double q = zrand(32) - (isRR() ? 24 : 16);
|
|
|
|
|
|
|
|
auto Owner = actor->GetOwner();
|
|
|
|
for (int x = 0; x < 7; x++)
|
|
|
|
{
|
|
|
|
DukeStatIterator itj(statlist[x]);
|
|
|
|
while (auto act2 = itj.Next())
|
|
|
|
{
|
|
|
|
if (Owner)
|
|
|
|
{
|
|
|
|
if (Owner->isPlayer() && act2->isPlayer() && ud.coop != 0 && ud.ffire == 0 && Owner != act2 /* && (dmflags & NOFRIENDLYRADIUSDMG)*/)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (actor->flags3 & SFLAG3_HITRADIUS_DONTHURTSPECIES && !Owner->isPlayer() && Owner->GetClass() == act2->GetClass())
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x == 0 || x >= 5 || (act2->flags1 & SFLAG_HITRADIUS_CHECKHITONLY))
|
|
|
|
{
|
|
|
|
if (!(actor->flags3 & SFLAG3_HITRADIUS_NODAMAGE) || (act2->spr.cstat & CSTAT_SPRITE_BLOCK_ALL))
|
|
|
|
if ((actor->spr.pos - act2->spr.pos).Length() < radius)
|
|
|
|
{
|
|
|
|
if (badguy(act2) && !cansee(act2->spr.pos.plusZ(q), act2->sector(), actor->spr.pos.plusZ(q), actor->sector()))
|
|
|
|
continue;
|
|
|
|
checkhitsprite(act2, actor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (act2->spr.extra >= 0 && act2 != actor && ((act2->flags1 & SFLAG_HITRADIUS_FORCEEFFECT) || badguy(act2) || (act2->spr.cstat & CSTAT_SPRITE_BLOCK_ALL)))
|
|
|
|
{
|
2022-12-31 16:16:11 +00:00
|
|
|
if (!shrinkersizecheck(actor->GetClass(), act2))
|
2022-12-29 15:59:07 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (actor->flags3 & SFLAG3_HITRADIUS_DONTHURTSHOOTER && act2 == Owner)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (actor->flags3 & SFLAG3_HITRADIUS_NOEFFECT)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
double dist = (act2->getPosWithOffsetZ() - actor->spr.pos).Length();
|
|
|
|
|
|
|
|
if (dist < radius && cansee(act2->spr.pos.plusZ(-8), act2->sector(), actor->spr.pos.plusZ(-12), actor->sector()))
|
|
|
|
{
|
|
|
|
act2->hitang = (act2->spr.pos - actor->spr.pos).Angle();
|
|
|
|
act2->attackertype = CallGetRadiusDamageType(actor, act2->spr.extra);
|
|
|
|
|
|
|
|
if (!(actor->flags3 & SFLAG3_HITRADIUS_NODAMAGE))
|
|
|
|
{
|
|
|
|
if (dist < radius / 3)
|
|
|
|
{
|
|
|
|
if (hp4 == hp3) hp4++;
|
|
|
|
act2->hitextra = hp3 + (krand() % (hp4 - hp3));
|
|
|
|
}
|
|
|
|
else if (dist < 2 * radius / 3)
|
|
|
|
{
|
|
|
|
if (hp3 == hp2) hp3++;
|
|
|
|
act2->hitextra = hp2 + (krand() % (hp3 - hp2));
|
|
|
|
}
|
|
|
|
else if (dist < radius)
|
|
|
|
{
|
|
|
|
if (hp2 == hp1) hp2++;
|
|
|
|
act2->hitextra = hp1 + (krand() % (hp2 - hp1));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(act2->flags2 & SFLAG2_NORADIUSPUSH) && !bossguy(act2))
|
|
|
|
{
|
|
|
|
if (act2->vel.X < 0) act2->vel.X = 0;
|
|
|
|
act2->vel.X += ((actor->spr.extra / 4.));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((act2->flags1 & SFLAG_HITRADIUSCHECK))
|
|
|
|
checkhitsprite(act2, actor);
|
|
|
|
}
|
|
|
|
else if (actor->spr.extra == 0) act2->hitextra = 0;
|
|
|
|
|
|
|
|
if (act2->GetClass() != DukeRadiusExplosionClass && Owner && Owner->spr.statnum < MAXSTATUS)
|
|
|
|
{
|
|
|
|
if (act2->isPlayer())
|
|
|
|
{
|
2023-10-02 09:38:22 +00:00
|
|
|
const auto p = getPlayer(act2->PlayerIndex());
|
2022-12-29 15:59:07 +00:00
|
|
|
|
|
|
|
if (act2->attackertype == DukeFlamethrowerFlameClass && Owner->isPlayer())
|
|
|
|
{
|
2023-10-02 09:38:22 +00:00
|
|
|
p->numloogs = -1 - actor->spr.yint;
|
2022-12-29 15:59:07 +00:00
|
|
|
}
|
|
|
|
|
2023-10-02 09:38:22 +00:00
|
|
|
if (p->newOwner != nullptr)
|
2022-12-29 15:59:07 +00:00
|
|
|
{
|
2023-10-02 09:38:22 +00:00
|
|
|
clearcamera(p);
|
2022-12-29 15:59:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
act2->SetHitOwner(actor->GetOwner());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-29 18:17:49 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
int movesprite_ex(DDukeActor* actor, const DVector3& change, unsigned int cliptype, Collision& result)
|
|
|
|
{
|
|
|
|
int bg = badguy(actor);
|
|
|
|
|
|
|
|
if (actor->spr.statnum == STAT_MISC || (bg && actor->spr.scale.X < 0.0625))
|
|
|
|
{
|
|
|
|
actor->spr.pos += change;
|
|
|
|
if (bg)
|
|
|
|
SetActor(actor, actor->spr.pos);
|
|
|
|
return result.setNone();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto dasectp = actor->sector();
|
|
|
|
|
|
|
|
auto ppos = actor->spr.pos;
|
|
|
|
|
|
|
|
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
|
|
|
|
ppos.Z -= tex->GetDisplayHeight() * actor->spr.scale.Y * 0.5;
|
|
|
|
|
|
|
|
if (bg)
|
|
|
|
{
|
|
|
|
if (actor->spr.scale.X > 0.9375)
|
|
|
|
clipmove(ppos, &dasectp, change * 0.5, 64., 4., 4., cliptype, result);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// todo: move this mess to the actor definitions once we have them all available.
|
|
|
|
double clipdist = actor->FloatVar(NAME_moveclipdist);
|
|
|
|
if (clipdist == 0)
|
|
|
|
{
|
|
|
|
if ((actor->flags1 & SFLAG_BADGUY) && !isRR())
|
|
|
|
clipdist = actor->clipdist;
|
|
|
|
else
|
|
|
|
clipdist = 12;
|
|
|
|
}
|
|
|
|
|
|
|
|
clipmove(ppos, &dasectp, change * 0.5, clipdist, 4., 4., cliptype, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
// conditional code from hell...
|
|
|
|
if (dasectp == nullptr || (dasectp != nullptr &&
|
|
|
|
((actor->actorstayput != nullptr && actor->actorstayput != dasectp) ||
|
|
|
|
((actor->flags3 & SFLAG3_ST3CONFINED) && actor->spr.pal == 0 && dasectp->lotag != ST_3_BOSS2) ||
|
|
|
|
((actor->flags3 & SFLAG3_DONTENTERWATER) && dasectp->lotag == ST_1_ABOVE_WATER) ||
|
|
|
|
((actor->flags3 & SFLAG3_DONTENTERWATERONGROUND) && actor->vel.Z == 0 && dasectp->lotag == ST_1_ABOVE_WATER))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (dasectp && dasectp->lotag == ST_1_ABOVE_WATER && (actor->flags3 & SFLAG3_RANDOMANGLEONWATER))
|
|
|
|
actor->spr.Angles.Yaw = randomAngle();
|
|
|
|
else if ((actor->counter & 3) == 1 && !(actor->flags3 & SFLAG3_NORANDOMANGLEWHENBLOCKED))
|
|
|
|
actor->spr.Angles.Yaw = randomAngle();
|
|
|
|
SetActor(actor, actor->spr.pos);
|
|
|
|
if (dasectp == nullptr) dasectp = §or[0];
|
|
|
|
return result.setSector(dasectp);
|
|
|
|
}
|
|
|
|
if ((result.type == kHitWall || result.type == kHitSprite) && (actor->cgg == 0)) actor->spr.Angles.Yaw += DAngle90 + DAngle45;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (actor->spr.statnum == STAT_PROJECTILE)
|
|
|
|
clipmove(ppos, &dasectp, change * 0.5, 0.5, 4., 4., cliptype, result);
|
|
|
|
else
|
|
|
|
clipmove(ppos, &dasectp, change * 0.5, actor->clipdist, 4., 4., cliptype, result);
|
|
|
|
}
|
|
|
|
actor->spr.pos.XY() = ppos.XY();
|
|
|
|
|
|
|
|
if (dasectp != nullptr && dasectp != actor->sector())
|
|
|
|
ChangeActorSect(actor, dasectp);
|
|
|
|
|
|
|
|
double daz = actor->spr.pos.Z + change.Z * 0.5;
|
|
|
|
if (daz > actor->ceilingz && daz <= actor->floorz)
|
|
|
|
actor->spr.pos.Z = daz;
|
|
|
|
else if (result.type == kHitNone)
|
|
|
|
return result.setSector(dasectp);
|
|
|
|
|
|
|
|
return result.type;
|
|
|
|
}
|
|
|
|
|
2022-12-30 11:38:36 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void move(DDukeActor* actor, int pnum, double pdist)
|
|
|
|
{
|
|
|
|
DAngle goalang, angdif;
|
|
|
|
double daxvel;
|
|
|
|
|
|
|
|
int a = actor->spr.hitag;
|
|
|
|
|
|
|
|
if (a == -1) a = 0;
|
|
|
|
|
|
|
|
actor->counter++;
|
|
|
|
|
2023-10-02 09:38:48 +00:00
|
|
|
const auto p = getPlayer(pnum);
|
|
|
|
const auto pact = p->GetActor();
|
|
|
|
|
2022-12-30 11:38:36 +00:00
|
|
|
if (a & face_player)
|
|
|
|
{
|
2023-10-02 09:38:48 +00:00
|
|
|
if (p->newOwner != nullptr)
|
|
|
|
goalang = (pact->opos.XY() - actor->spr.pos.XY()).Angle();
|
|
|
|
else goalang = (pact->spr.pos.XY() - actor->spr.pos.XY()).Angle();
|
2022-12-30 11:38:36 +00:00
|
|
|
angdif = deltaangle(actor->spr.Angles.Yaw, goalang) * 0.25;
|
|
|
|
if (angdif > -DAngle22_5 / 16 && angdif < nullAngle) angdif = nullAngle;
|
|
|
|
actor->spr.Angles.Yaw += angdif;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a & spin)
|
|
|
|
actor->spr.Angles.Yaw += DAngle45 * BobVal(actor->counter << 3);
|
|
|
|
|
|
|
|
if (a & face_player_slow)
|
|
|
|
{
|
2023-10-02 09:38:48 +00:00
|
|
|
if (p->newOwner != nullptr)
|
|
|
|
goalang = (pact->opos.XY() - actor->spr.pos.XY()).Angle();
|
|
|
|
else goalang = (pact->spr.pos.XY() - actor->spr.pos.XY()).Angle();
|
2022-12-30 11:38:36 +00:00
|
|
|
angdif = DAngle22_5 * 0.25 * Sgn(deltaangle(actor->spr.Angles.Yaw, goalang).Degrees()); // this looks very wrong...
|
|
|
|
actor->spr.Angles.Yaw += angdif;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a & antifaceplayerslow)
|
|
|
|
{
|
2023-10-02 09:38:48 +00:00
|
|
|
if (p->newOwner != nullptr)
|
|
|
|
goalang = ((pact->opos.XY() - actor->spr.pos.XY()).Angle() + DAngle180);
|
|
|
|
else goalang = ((pact->spr.pos.XY() - actor->spr.pos.XY()).Angle() + DAngle180);
|
2022-12-30 11:38:36 +00:00
|
|
|
angdif = DAngle22_5 * 0.25 * Sgn(deltaangle(actor->spr.Angles.Yaw, goalang).Degrees()); // this looks very wrong...
|
|
|
|
actor->spr.Angles.Yaw += angdif;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((a & jumptoplayer) == jumptoplayer)
|
|
|
|
{
|
|
|
|
if (actor->counter < 16)
|
|
|
|
actor->vel.Z -= BobVal(512 + (actor->counter << 4)) * actor->FloatVar(NAME_jumptoplayer_factor);
|
|
|
|
}
|
|
|
|
else if (a & justjump1)
|
|
|
|
{
|
|
|
|
if (actor->counter < 8)
|
|
|
|
actor->vel.Z -= BobVal(512 + (actor->counter << 4)) * actor->FloatVar(NAME_justjump1_factor);
|
|
|
|
}
|
|
|
|
if (a & justjump2)
|
|
|
|
{
|
|
|
|
if (actor->counter < 8)
|
|
|
|
actor->vel.Z -= BobVal(512 + (actor->counter << 4)) * actor->FloatVar(NAME_justjump2_factor);
|
|
|
|
}
|
|
|
|
if (a & windang)
|
|
|
|
{
|
|
|
|
if (actor->counter < 8)
|
|
|
|
actor->vel.Z -= BobVal(512 + (actor->counter << 4)) * actor->FloatVar(NAME_windang_factor);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (a & face_player_smart)
|
|
|
|
{
|
2023-10-02 09:38:48 +00:00
|
|
|
DVector2 newpos = pact->spr.pos.XY() + (p->vel.XY() * (4. / 3.));
|
2022-12-30 11:38:36 +00:00
|
|
|
goalang = (newpos - 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (actor->curMove->name == NAME_None || a == 0)
|
|
|
|
{
|
|
|
|
if ((badguy(actor) && actor->spr.extra <= 0) || (actor->opos.X != actor->spr.pos.X) || (actor->opos.Y != actor->spr.pos.Y))
|
|
|
|
{
|
|
|
|
if (!actor->isPlayer()) actor->backupvec2();
|
|
|
|
SetActor(actor, actor->spr.pos);
|
|
|
|
}
|
|
|
|
if (badguy(actor) && actor->spr.extra <= 0)
|
|
|
|
{
|
|
|
|
if (actor->sector()->ceilingstat & CSTAT_SECTOR_SKY)
|
|
|
|
{
|
|
|
|
if (actor->sector()->shadedsector == 1)
|
|
|
|
{
|
|
|
|
actor->spr.shade += (16 - actor->spr.shade) >> 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
actor->spr.shade += (actor->sector()->ceilingshade - actor->spr.shade) >> 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
actor->spr.shade += (actor->sector()->floorshade - actor->spr.shade) >> 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a & geth) actor->vel.X += (actor->curMove->movex - actor->vel.X) * 0.5;
|
|
|
|
if (a & getv) actor->vel.Z += (actor->curMove->movez - actor->vel.Z) * 0.5;
|
|
|
|
|
|
|
|
if (a & dodgebullet)
|
|
|
|
dodge(actor);
|
|
|
|
|
|
|
|
if (!actor->isPlayer())
|
|
|
|
alterang(a, actor, pnum);
|
|
|
|
|
|
|
|
if (abs(actor->vel.X) < 6 / 16.) actor->vel.X = 0;
|
|
|
|
|
|
|
|
a = badguy(actor);
|
|
|
|
|
|
|
|
if (actor->vel.X != 0 || actor->vel.Z != 0)
|
|
|
|
{
|
|
|
|
if (a && !(actor->flags3 & SFLAG3_NOVERTICALMOVE))
|
|
|
|
{
|
|
|
|
if ((actor->flags2 & SFLAG2_FLOATING) && actor->spr.extra > 0)
|
|
|
|
{
|
|
|
|
double fdist = actor->FloatVar(NAME_floating_floordist);
|
|
|
|
double cdist = actor->FloatVar(NAME_floating_ceilingdist);
|
|
|
|
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 - fdist)
|
|
|
|
{
|
|
|
|
actor->spr.pos.Z = f - fdist;
|
|
|
|
actor->vel.Z = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (actor->spr.pos.Z < c + cdist)
|
|
|
|
{
|
|
|
|
actor->spr.pos.Z = c + cdist;
|
|
|
|
actor->vel.Z = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (actor->vel.Z > 0 && actor->floorz < actor->spr.pos.Z)
|
|
|
|
actor->spr.pos.Z = actor->floorz;
|
|
|
|
if (actor->vel.Z < 0)
|
|
|
|
{
|
|
|
|
double c = getceilzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
|
|
|
|
if (actor->spr.pos.Z < c + 66)
|
|
|
|
{
|
|
|
|
actor->spr.pos.Z = c + 66;
|
|
|
|
actor->vel.Z *= 0.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
daxvel = actor->vel.X;
|
|
|
|
angdif = actor->spr.Angles.Yaw;
|
|
|
|
|
|
|
|
if (a && !(actor->flags3 & SFLAG3_MOVE_NOPLAYERINTERACT))
|
|
|
|
{
|
|
|
|
if (pdist < 60 && actor->spr.scale.X > 0.25)
|
|
|
|
{
|
|
|
|
|
|
|
|
daxvel = -(64 - pdist);
|
2023-10-02 09:38:48 +00:00
|
|
|
angdif = (pact->spr.pos.XY() - actor->spr.pos.XY()).Angle();
|
2022-12-30 11:38:36 +00:00
|
|
|
|
|
|
|
if (pdist < 32)
|
|
|
|
{
|
2023-10-02 09:38:48 +00:00
|
|
|
p->vel.X = 0;
|
|
|
|
p->vel.Y = 0;
|
2022-12-30 11:38:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-02 09:38:48 +00:00
|
|
|
p->vel.XY() *= gs.playerfriction - 0.125;
|
2022-12-30 11:38:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!(actor->flags2 & SFLAG2_FLOATING))
|
|
|
|
{
|
|
|
|
if (actor->curMove->movez == 0)
|
|
|
|
{
|
|
|
|
if (actor->opos.Z != actor->spr.pos.Z || (ud.multimode < 2 && ud.player_skill < 2))
|
|
|
|
{
|
2023-10-02 09:38:48 +00:00
|
|
|
if ((actor->counter & 1) || p->actorsqu == actor) return;
|
2022-12-30 11:38:36 +00:00
|
|
|
else daxvel *= 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-02 09:38:48 +00:00
|
|
|
if ((actor->counter & 3) || p->actorsqu == actor) return;
|
2022-12-30 11:38:36 +00:00
|
|
|
else daxvel *= 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (actor->sector()->lotag != ST_1_ABOVE_WATER)
|
|
|
|
{
|
|
|
|
daxvel *= actor->FloatVar(NAME_landmovefactor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
daxvel *= actor->FloatVar(NAME_watermovefactor);
|
|
|
|
}
|
|
|
|
|
|
|
|
Collision coll;
|
|
|
|
actor->movflag = movesprite_ex(actor, DVector3(angdif.ToVector() * daxvel, actor->vel.Z), CLIPMASK0, coll);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a)
|
|
|
|
{
|
|
|
|
if (actor->sector()->ceilingstat & CSTAT_SECTOR_SKY)
|
|
|
|
{
|
|
|
|
if (actor->sector()->shadedsector == 1)
|
|
|
|
{
|
|
|
|
actor->spr.shade += (16 - actor->spr.shade) >> 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
actor->spr.shade += (actor->sector()->ceilingshade - actor->spr.shade) >> 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else actor->spr.shade += (actor->sector()->floorshade - actor->spr.shade) >> 1;
|
|
|
|
|
|
|
|
if (actor->sector()->floortexture == mirrortex)
|
|
|
|
actor->Destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-10 07:08:02 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-09-11 16:01:27 +00:00
|
|
|
// Rotating sector
|
|
|
|
//
|
|
|
|
// temp_data[1]: mspos index
|
|
|
|
// temp_angle: current angle
|
|
|
|
// temp_data[3]: checkz / acceleration, depending on mode.
|
2020-05-10 07:08:02 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-01-19 09:48:18 +00:00
|
|
|
void handle_se00(DDukeActor* actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
sectortype *sect = actor->sector();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 16:01:27 +00:00
|
|
|
double zchange = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-21 21:39:12 +00:00
|
|
|
auto Owner = actor->GetOwner();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
if (!Owner || Owner->spr.lotag == -1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-01 00:14:17 +00:00
|
|
|
DAngle ang_amount = DAngle::fromQ16(sect->extra << 2);
|
2022-09-11 16:01:27 +00:00
|
|
|
double direction = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-31 21:55:41 +00:00
|
|
|
if (sect->lotag == 30)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 16:01:27 +00:00
|
|
|
ang_amount *= 0.25;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.extra == 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-14 21:30:10 +00:00
|
|
|
if (actor->tempval < 256)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-14 21:30:10 +00:00
|
|
|
actor->tempval += 4;
|
|
|
|
if (actor->tempval >= 256)
|
2022-10-01 10:59:43 +00:00
|
|
|
callsound(actor->sector(), actor, true);
|
2022-11-19 18:01:17 +00:00
|
|
|
if (actor->spr.detail) direction = 1;
|
2022-09-11 16:01:27 +00:00
|
|
|
else direction = -1;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2022-09-14 21:30:10 +00:00
|
|
|
else actor->tempval = 256;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-02-06 21:45:47 +00:00
|
|
|
if (sect->floorz > actor->spr.pos.Z) //z's are touching
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-02-07 08:05:36 +00:00
|
|
|
sect->addfloorz(-2);
|
2022-12-13 12:46:30 +00:00
|
|
|
zchange = -2;
|
2022-02-06 21:45:47 +00:00
|
|
|
if (sect->floorz < actor->spr.pos.Z)
|
2022-08-28 19:05:45 +00:00
|
|
|
sect->setfloorz(actor->spr.pos.Z);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-06 21:45:47 +00:00
|
|
|
else if (sect->floorz < actor->spr.pos.Z) //z's are touching
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-02-07 08:05:36 +00:00
|
|
|
sect->addfloorz(2);
|
2022-09-11 16:01:27 +00:00
|
|
|
zchange = 2;
|
2022-02-06 21:45:47 +00:00
|
|
|
if (sect->floorz > actor->spr.pos.Z)
|
2022-08-28 19:05:45 +00:00
|
|
|
sect->setfloorz(actor->spr.pos.Z);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-21 17:29:44 +00:00
|
|
|
else if (actor->spr.extra == 3)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-14 21:30:10 +00:00
|
|
|
if (actor->tempval > 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-14 21:30:10 +00:00
|
|
|
actor->tempval -= 4;
|
|
|
|
if (actor->tempval <= 0)
|
2022-10-01 10:59:43 +00:00
|
|
|
callsound(actor->sector(), actor, true);
|
2022-11-19 18:01:17 +00:00
|
|
|
if (actor->spr.detail) direction = -1;
|
2022-09-11 16:01:27 +00:00
|
|
|
else direction = 1;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2022-09-14 21:30:10 +00:00
|
|
|
else actor->tempval = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 18:18:33 +00:00
|
|
|
double checkz = actor->temp_pos.Z;
|
2022-02-07 08:05:36 +00:00
|
|
|
if (sect->floorz > checkz) //z's are touching
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-02-07 08:05:36 +00:00
|
|
|
sect->addfloorz(-2);
|
2022-09-11 16:01:27 +00:00
|
|
|
zchange = -2;
|
2022-02-07 08:05:36 +00:00
|
|
|
if (sect->floorz < checkz)
|
|
|
|
sect->setfloorz(checkz);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 08:05:36 +00:00
|
|
|
else if (sect->floorz < checkz) //z's are touching
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-02-07 08:05:36 +00:00
|
|
|
sect->addfloorz(2);
|
2022-09-11 16:01:27 +00:00
|
|
|
zchange = 2;
|
2022-02-07 08:05:36 +00:00
|
|
|
if (sect->floorz > checkz)
|
|
|
|
sect->setfloorz(checkz);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.Angles.Yaw += ang_amount * direction;
|
2022-09-11 16:01:27 +00:00
|
|
|
actor->temp_angle += ang_amount * direction;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
if (Owner->counter == 0) return;
|
|
|
|
if (Owner->counter == 2)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-11-25 12:13:50 +00:00
|
|
|
if (Owner->spr.Angles.Yaw.Normalized360() > DAngle180)
|
2022-09-11 16:01:27 +00:00
|
|
|
direction = -1;
|
|
|
|
else direction = 1;
|
2022-09-11 18:18:33 +00:00
|
|
|
if (actor->temp_pos.Y == 0)
|
|
|
|
actor->temp_pos.Y = (actor->spr.pos.XY() - Owner->spr.pos.XY()).Length();
|
|
|
|
actor->vel.X = actor->temp_pos.Y;
|
2022-08-29 17:27:52 +00:00
|
|
|
actor->spr.pos.XY() = Owner->spr.pos.XY();
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.Angles.Yaw += ang_amount * direction;
|
2022-09-11 16:01:27 +00:00
|
|
|
actor->temp_angle += ang_amount * direction;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 16:01:27 +00:00
|
|
|
if (direction && (sect->floorstat & CSTAT_SECTOR_ALIGN))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 09:39:03 +00:00
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 09:39:03 +00:00
|
|
|
const auto p = getPlayer(i);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 09:39:03 +00:00
|
|
|
if (p->cursector == actor->sector() && p->on_ground == 1)
|
|
|
|
{
|
|
|
|
const auto pact = p->GetActor();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 09:39:03 +00:00
|
|
|
pact->spr.Angles.Yaw += ang_amount * direction;
|
|
|
|
pact->spr.pos.Z += zchange;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 09:39:03 +00:00
|
|
|
auto result = rotatepoint(Owner->spr.pos, pact->spr.pos.XY(), ang_amount * direction);
|
|
|
|
p->bobpos += (result - pact->spr.pos.XY());
|
|
|
|
pact->spr.pos.XY() = result;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-21 00:10:50 +00:00
|
|
|
DukeSectIterator itp(actor->sector());
|
2021-12-21 18:09:05 +00:00
|
|
|
while (auto act2 = itp.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-20 21:25:48 +00:00
|
|
|
if (act2->spr.statnum != STAT_EFFECTOR && act2->spr.statnum != STAT_PROJECTILE && !(act2->flags2 & SFLAG2_NOROTATEWITHSECTOR))
|
2022-01-19 09:48:18 +00:00
|
|
|
{
|
|
|
|
if (act2->isPlayer() && act2->GetOwner())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-01-19 09:48:18 +00:00
|
|
|
continue;
|
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-11-25 12:13:50 +00:00
|
|
|
act2->spr.Angles.Yaw += ang_amount * direction;
|
2022-08-16 21:27:44 +00:00
|
|
|
act2->norm_ang();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 16:01:27 +00:00
|
|
|
act2->spr.pos.Z += zchange;
|
2022-08-27 11:06:17 +00:00
|
|
|
|
2022-09-11 16:41:52 +00:00
|
|
|
auto pos = rotatepoint(Owner->spr.pos, act2->spr.pos.XY(), ang_amount * direction);
|
2022-08-27 11:06:17 +00:00
|
|
|
act2->spr.pos.X = pos.X;
|
|
|
|
act2->spr.pos.Y = pos.Y;
|
2022-01-19 09:48:18 +00:00
|
|
|
}
|
2022-09-11 16:01:27 +00:00
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
}
|
2022-09-11 16:01:27 +00:00
|
|
|
movesector(actor, actor->temp_data[1], actor->temp_angle);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:39:12 +00:00
|
|
|
void handle_se01(DDukeActor *actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
int sh = actor->spr.hitag;
|
2020-10-21 21:39:12 +00:00
|
|
|
if (actor->GetOwner() == nullptr) //Init
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-21 21:39:12 +00:00
|
|
|
actor->SetOwner(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-21 21:39:12 +00:00
|
|
|
DukeStatIterator it(STAT_EFFECTOR);
|
|
|
|
while (auto ac = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 16:41:52 +00:00
|
|
|
if (ac->spr.lotag == SE_19_EXPLOSION_LOWERS_CEILING && ac->spr.hitag == sh)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-09-11 16:41:52 +00:00
|
|
|
// Subway car
|
2020-05-10 07:08:02 +00:00
|
|
|
//
|
2022-09-11 16:41:52 +00:00
|
|
|
// temp_data[1]: mspos index
|
|
|
|
// temp_angle: rotation angle
|
2020-05-10 07:08:02 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-28 23:51:26 +00:00
|
|
|
void handle_se14(DDukeActor* actor, bool checkstat, PClassActor* RPG)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2021-12-21 17:29:44 +00:00
|
|
|
int st = actor->spr.lotag;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-11-01 06:56:49 +00:00
|
|
|
if (actor->GetOwner() == nullptr)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
auto NewOwner = LocateTheLocator(actor->temp_data[3], §or[actor->counter]);
|
2020-11-01 06:56:49 +00:00
|
|
|
|
|
|
|
if (NewOwner == nullptr)
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
I_Error("Could not find any locators for SE# 6 and 14 with a hitag of %d.", actor->temp_data[3]);
|
2020-11-01 06:56:49 +00:00
|
|
|
}
|
|
|
|
actor->SetOwner(NewOwner);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2020-11-01 06:56:49 +00:00
|
|
|
auto Owner = actor->GetOwner();
|
2022-09-13 21:29:41 +00:00
|
|
|
double dist = (Owner->spr.pos.XY() - actor->spr.pos.XY()).LengthSquared();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-13 21:29:41 +00:00
|
|
|
if (dist < 64*64)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
if (st == 6)
|
2021-12-21 17:19:45 +00:00
|
|
|
if (Owner->spr.hitag & 1)
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] = sc->extra; //Slow it down
|
|
|
|
actor->temp_data[3]++;
|
2022-12-22 08:49:42 +00:00
|
|
|
auto NewOwner = LocateTheLocator(actor->temp_data[3], §or[actor->counter]);
|
2020-11-01 06:56:49 +00:00
|
|
|
if (NewOwner == nullptr)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[3] = 0;
|
2022-12-22 08:49:42 +00:00
|
|
|
NewOwner = LocateTheLocator(0, §or[actor->counter]);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2020-11-01 06:56:49 +00:00
|
|
|
if (NewOwner) actor->SetOwner(NewOwner);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2020-11-01 06:56:49 +00:00
|
|
|
Owner = actor->GetOwner();
|
2022-09-03 08:03:30 +00:00
|
|
|
if(actor->vel.X != 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-30 11:38:21 +00:00
|
|
|
auto curangle = (Owner->spr.pos.XY() - actor->spr.pos.XY()).Angle();
|
2022-11-25 12:13:50 +00:00
|
|
|
auto diffangle = deltaangle(actor->spr.Angles.Yaw, curangle) * 0.125;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 16:41:52 +00:00
|
|
|
actor->temp_angle += diffangle;
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.Angles.Yaw += diffangle;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-18 12:14:56 +00:00
|
|
|
bool statstate = (!checkstat || ((sc->floorstat & CSTAT_SECTOR_SKY) == 0 && (sc->ceilingstat & CSTAT_SECTOR_SKY) == 0));
|
2022-09-11 16:41:52 +00:00
|
|
|
if (actor->vel.X == sc->extra * maptoworld)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
if (statstate)
|
|
|
|
{
|
2022-02-06 21:59:30 +00:00
|
|
|
if (!S_CheckSoundPlaying(actor->tempsound))
|
|
|
|
S_PlayActorSound(actor->tempsound, actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2021-12-18 12:14:56 +00:00
|
|
|
if ((!checkstat || !statstate) && (ud.monsters_off == 0 && sc->floorpal == 0 && (sc->floorstat & CSTAT_SECTOR_SKY) && rnd(8)))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-13 21:44:21 +00:00
|
|
|
double dist2;
|
2023-10-02 09:39:26 +00:00
|
|
|
const auto p = getPlayer(findplayer(actor, &dist2));
|
|
|
|
|
2022-09-13 21:44:21 +00:00
|
|
|
if (dist2 < 1280)//20480)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-25 12:13:50 +00:00
|
|
|
auto saved_angle = actor->spr.Angles.Yaw;
|
2023-10-02 09:39:26 +00:00
|
|
|
actor->spr.Angles.Yaw = (actor->spr.pos.XY() - p->GetActor()->spr.pos.XY()).Angle();
|
2022-12-29 09:56:10 +00:00
|
|
|
shoot(actor, RPG);
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.Angles.Yaw = saved_angle;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-11 16:41:52 +00:00
|
|
|
if (actor->vel.X <= 4 && statstate)
|
2022-02-06 21:59:30 +00:00
|
|
|
S_StopSound(actor->tempsound, actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 09:39:26 +00:00
|
|
|
if (((sc->floorz - sc->ceilingz) < 108) && (ud.clipping == 0 && actor->vel.X >= 12))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 09:39:26 +00:00
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
{
|
|
|
|
const auto p = getPlayer(i);
|
|
|
|
const auto pact = p->GetActor();
|
|
|
|
|
|
|
|
if (pact->spr.extra > 0)
|
2020-11-01 07:00:03 +00:00
|
|
|
{
|
2023-10-02 09:39:26 +00:00
|
|
|
auto sect = p->cursector;
|
|
|
|
updatesector(pact->getPosWithOffsetZ(), §);
|
|
|
|
if ((sect == nullptr && ud.clipping == 0) || (sect == actor->sector() && p->cursector != actor->sector()))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 09:39:26 +00:00
|
|
|
pact->spr.pos.XY() = actor->spr.pos.XY();
|
|
|
|
p->setCursector(actor->sector());
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 09:39:26 +00:00
|
|
|
SetActor(pact, actor->spr.pos);
|
|
|
|
quickkill(p);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2020-11-01 07:00:03 +00:00
|
|
|
}
|
2023-10-02 09:39:26 +00:00
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-11-25 12:13:50 +00:00
|
|
|
auto vec = actor->spr.Angles.Yaw.ToVector() * actor->vel.X;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 09:39:26 +00:00
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
2020-11-01 07:00:03 +00:00
|
|
|
{
|
2023-10-02 09:39:26 +00:00
|
|
|
const auto p = getPlayer(i);
|
|
|
|
const auto pact = p->GetActor();
|
|
|
|
|
|
|
|
if (p->insector() && p->cursector->lotag != 2)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 09:39:26 +00:00
|
|
|
if (po[i].os == actor->sector())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 09:39:26 +00:00
|
|
|
po[i].opos += vec;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2023-10-02 09:39:26 +00:00
|
|
|
if (actor->sector() == pact->sector())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 09:39:26 +00:00
|
|
|
auto result = rotatepoint(actor->spr.pos.XY(), pact->spr.pos.XY(), diffangle);
|
|
|
|
pact->spr.pos.XY() = result + vec;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 09:39:26 +00:00
|
|
|
p->bobpos += vec;
|
|
|
|
pact->spr.Angles.Yaw += diffangle;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (numplayers > 1)
|
|
|
|
{
|
2023-10-02 09:39:26 +00:00
|
|
|
pact->backupvec2();
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2023-10-02 09:39:26 +00:00
|
|
|
if (pact->spr.extra <= 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 09:39:26 +00:00
|
|
|
pact->spr.pos.XY() = pact->spr.pos.XY();
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-01 07:00:03 +00:00
|
|
|
}
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-11-01 07:00:03 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-01-07 15:36:02 +00:00
|
|
|
if (a2->spr.statnum != STAT_PLAYER && a2->sector()->lotag != 2 &&
|
2022-12-02 21:25:07 +00:00
|
|
|
(!iseffector(a2) || a2->spr.lotag == SE_49_POINT_LIGHT || a2->spr.lotag == SE_50_SPOT_LIGHT) &&
|
2022-11-20 11:43:24 +00:00
|
|
|
!islocator(a2))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 16:41:52 +00:00
|
|
|
a2->spr.pos.XY() = rotatepoint(actor->spr.pos.XY(), a2->spr.pos.XY(), diffangle) + vec;
|
2022-11-25 12:13:50 +00:00
|
|
|
a2->spr.Angles.Yaw += diffangle;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (numplayers > 1)
|
|
|
|
{
|
2021-12-30 16:10:08 +00:00
|
|
|
a2->backupvec2();
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-11 16:41:52 +00:00
|
|
|
movesector(actor, actor->temp_data[1], actor->temp_angle);
|
2022-01-30 11:25:15 +00:00
|
|
|
// I have no idea why this is here, but the SE's sector must never, *EVER* change, or the map will corrupt.
|
2022-02-06 21:45:47 +00:00
|
|
|
//SetActor(actor, actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 09:39:26 +00:00
|
|
|
if (((sc->floorz - sc->ceilingz) < 108) && (ud.clipping == 0 && actor->vel.X >= 12))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 09:39:26 +00:00
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
{
|
|
|
|
const auto p = getPlayer(i);
|
|
|
|
const auto pact = p->GetActor();
|
|
|
|
|
|
|
|
if (pact->spr.extra > 0)
|
2020-11-01 07:00:03 +00:00
|
|
|
{
|
2023-10-02 09:39:26 +00:00
|
|
|
auto k = p->cursector;
|
|
|
|
updatesector(pact->getPosWithOffsetZ(), &k);
|
|
|
|
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && p->cursector != actor->sector()))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 09:39:26 +00:00
|
|
|
pact->spr.pos.XY() = actor->spr.pos.XY();
|
|
|
|
pact->backupvec2();
|
|
|
|
p->setCursector(actor->sector());
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 09:39:26 +00:00
|
|
|
SetActor(pact, actor->spr.pos);
|
|
|
|
quickkill(p);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2020-11-01 07:00:03 +00:00
|
|
|
}
|
2023-10-02 09:39:26 +00:00
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-24 09:53:27 +00:00
|
|
|
auto actOwner = actor->GetOwner();
|
|
|
|
if (actOwner)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-24 09:53:27 +00:00
|
|
|
DukeSectIterator itr(actOwner->sector());
|
2020-11-01 07:00:43 +00:00
|
|
|
while (auto a2 = itr.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-02 21:25:07 +00:00
|
|
|
if (a2->spr.statnum == 1 && badguy(a2) && !iseffector(a2) && !islocator(a2))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto k = a2->sector();
|
2022-09-11 16:41:52 +00:00
|
|
|
updatesector(a2->spr.pos, &k);
|
2021-12-30 15:51:56 +00:00
|
|
|
if (a2->spr.extra >= 0 && k == actor->sector())
|
2020-11-01 07:00:43 +00:00
|
|
|
{
|
2022-12-29 08:56:14 +00:00
|
|
|
gutsdir(a2, DukeJibs6Class, 72, myconnectindex);
|
2020-11-01 07:00:43 +00:00
|
|
|
S_PlayActorSound(SQUISHED, actor);
|
2022-11-20 18:25:23 +00:00
|
|
|
a2->Destroy();
|
2020-11-01 07:00:43 +00:00
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-09-11 18:31:40 +00:00
|
|
|
// Two way train
|
2020-05-10 07:08:02 +00:00
|
|
|
//
|
2022-09-11 18:31:40 +00:00
|
|
|
// temp_data[1]: mspos index
|
|
|
|
// temp_angle: rotation angle
|
|
|
|
// temp_data[3]: locator tag
|
2020-05-10 07:08:02 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-28 23:51:26 +00:00
|
|
|
void handle_se30(DDukeActor *actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-21 22:00:43 +00:00
|
|
|
auto Owner = actor->GetOwner();
|
|
|
|
if (Owner == nullptr)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[3] = !actor->temp_data[3];
|
2022-12-22 08:49:42 +00:00
|
|
|
Owner = LocateTheLocator(actor->temp_data[3], §or[actor->counter]);
|
2020-10-21 22:00:43 +00:00
|
|
|
actor->SetOwner(Owner);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-11 18:31:40 +00:00
|
|
|
auto dist = (Owner->spr.pos.XY() - actor->spr.pos.XY()).Length();
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[4] == 1) // Starting to go
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 18:31:40 +00:00
|
|
|
if (dist < (128 - 8))
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] = 2;
|
2020-05-10 07:08:02 +00:00
|
|
|
else
|
|
|
|
{
|
2022-09-11 18:31:40 +00:00
|
|
|
if (actor->vel.X == 0)
|
2022-11-19 14:40:35 +00:00
|
|
|
operateactivators(actor->spr.hitag + (!actor->temp_data[3]), nullptr);
|
2022-09-11 18:31:40 +00:00
|
|
|
if (actor->vel.X < 16)
|
2022-09-03 08:05:20 +00:00
|
|
|
actor->vel.X += 1;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[4] == 2)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 18:31:40 +00:00
|
|
|
if (dist <= 8)
|
2022-09-03 08:02:25 +00:00
|
|
|
actor->vel.X = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-03 08:03:30 +00:00
|
|
|
if(actor->vel.X > 0)
|
2022-09-03 08:05:20 +00:00
|
|
|
actor->vel.X -= 1;
|
2020-05-10 07:08:02 +00:00
|
|
|
else
|
|
|
|
{
|
2022-09-03 08:02:25 +00:00
|
|
|
actor->vel.X = 0;
|
2022-11-19 14:40:35 +00:00
|
|
|
operateactivators(actor->spr.hitag + (short)actor->temp_data[3], nullptr);
|
2020-10-21 22:00:43 +00:00
|
|
|
actor->SetOwner(nullptr);
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.Angles.Yaw += DAngle180;
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] = 0;
|
2022-12-10 16:52:25 +00:00
|
|
|
operateforcefields(actor, actor->spr.hitag);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-03 08:03:30 +00:00
|
|
|
if(actor->vel.X != 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-25 12:13:50 +00:00
|
|
|
auto vect = actor->spr.Angles.Yaw.ToVector() * actor->vel.X;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-08-20 18:57:54 +00:00
|
|
|
if ((sc->floorz - sc->ceilingz) < 108)
|
2020-05-10 07:08:02 +00:00
|
|
|
if (ud.clipping == 0)
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2020-10-21 22:00:43 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
auto psp = getPlayer(p)->GetActor();
|
2021-12-21 17:19:45 +00:00
|
|
|
if (psp->spr.extra > 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
auto k = getPlayer(p)->cursector;
|
|
|
|
updatesector(getPlayer(p)->GetActor()->getPosWithOffsetZ(), &k);
|
|
|
|
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && getPlayer(p)->cursector != actor->sector()))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->GetActor()->spr.pos.XY() = actor->spr.pos.XY();
|
|
|
|
getPlayer(p)->setCursector(actor->sector());
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 02:51:13 +00:00
|
|
|
SetActor(getPlayer(p)->GetActor(), actor->spr.pos);
|
|
|
|
quickkill(getPlayer(p));
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-21 22:00:43 +00:00
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
auto psp = getPlayer(p)->GetActor();
|
2021-12-30 15:51:56 +00:00
|
|
|
if (psp->sector() == actor->sector())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->GetActor()->spr.pos.XY() += vect;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (numplayers > 1)
|
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->GetActor()->backupvec2();
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->bobpos += vect;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
if (po[p].os == actor->sector())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 18:31:40 +00:00
|
|
|
po[p].opos += vect;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
DukeSectIterator its(actor->sector());
|
2020-10-21 22:00:43 +00:00
|
|
|
while (auto a2 = its.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-13 15:16:48 +00:00
|
|
|
if (!iseffector(a2) && !islocator(a2) && !a2->isPlayer())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 18:31:40 +00:00
|
|
|
a2->spr.pos += vect;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (numplayers > 1)
|
|
|
|
{
|
2021-12-30 16:10:08 +00:00
|
|
|
a2->backupvec2();
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-11 18:31:40 +00:00
|
|
|
movesector(actor, actor->temp_data[1], actor->temp_angle);
|
2022-02-06 21:45:47 +00:00
|
|
|
//SetActor(actor, actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-02-05 22:46:55 +00:00
|
|
|
if ((sc->floorz - sc->ceilingz) < 108)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
if (ud.clipping == 0)
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(p)->GetActor()->spr.extra > 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
auto k = getPlayer(p)->cursector;
|
|
|
|
updatesector(getPlayer(p)->GetActor()->getPosWithOffsetZ(), &k);
|
|
|
|
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && getPlayer(p)->cursector != actor->sector()))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->GetActor()->spr.pos.XY() = actor->spr.pos.XY();
|
|
|
|
getPlayer(p)->GetActor()->backupvec2();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->setCursector(actor->sector());
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 02:51:13 +00:00
|
|
|
SetActor(getPlayer(p)->GetActor(), actor->spr.pos);
|
|
|
|
quickkill(getPlayer(p));
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 22:00:43 +00:00
|
|
|
if (Owner)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-21 00:04:16 +00:00
|
|
|
DukeSectIterator it(Owner->sector());
|
2020-10-21 22:00:43 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-02 21:25:07 +00:00
|
|
|
if (a2->spr.statnum == STAT_ACTOR && badguy(a2) && !iseffector(a2) && !islocator(a2))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
// if(a2->spr.sector != actor->spr.sector)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto k = a2->sector();
|
2022-09-11 18:31:40 +00:00
|
|
|
updatesector(a2->spr.pos, &k);
|
2021-12-30 15:51:56 +00:00
|
|
|
if (a2->spr.extra >= 0 && k == actor->sector())
|
2020-10-21 22:00:43 +00:00
|
|
|
{
|
2022-12-29 08:56:14 +00:00
|
|
|
gutsdir(a2, DukeJibs6Class, 24, myconnectindex);
|
2020-10-21 22:00:43 +00:00
|
|
|
S_PlayActorSound(SQUISHED, a2);
|
2022-11-20 18:25:23 +00:00
|
|
|
a2->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-21 22:00:43 +00:00
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-09-11 19:11:00 +00:00
|
|
|
// Earthquake
|
2020-05-10 07:08:02 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
void handle_se02(DDukeActor* actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2021-12-21 17:29:44 +00:00
|
|
|
int sh = actor->spr.hitag;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->temp_data[4] > 0 && actor->counter == 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[4] < sh)
|
|
|
|
actor->temp_data[4]++;
|
2022-12-22 08:49:42 +00:00
|
|
|
else actor->counter = 1;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter > 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter++;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 19:11:00 +00:00
|
|
|
actor->vel.X = 3 / 16.;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter > 96)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = -1; //Stop the quake
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] = -1;
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
if ((actor->counter & 31) == 8)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-30 16:15:44 +00:00
|
|
|
ud.earthquaketime = 48;
|
2023-10-02 02:51:13 +00:00
|
|
|
S_PlayActorSound(EARTHQUAKE, getPlayer(screenpeek)->GetActor());
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (abs(sc->floorheinum - actor->temp_data[0]) < 8)
|
|
|
|
sc->setfloorslope(actor->temp_data[0]);
|
|
|
|
else sc->setfloorslope(sc->getfloorslope() + (Sgn(actor->temp_data[0] - sc->getfloorslope()) << 4));
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-11-25 12:13:50 +00:00
|
|
|
auto vect = actor->spr.Angles.Yaw.ToVector() * actor->vel.X;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(p)->cursector == actor->sector() && getPlayer(p)->on_ground)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->GetActor()->spr.pos.XY() += vect;
|
|
|
|
getPlayer(p)->bobpos += vect;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 22:10:43 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-02 21:25:07 +00:00
|
|
|
if (!iseffector(a2))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 19:11:00 +00:00
|
|
|
a2->spr.pos += vect;
|
2022-08-22 16:34:01 +00:00
|
|
|
SetActor(a2, a2->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-11 19:11:00 +00:00
|
|
|
movesector(actor, actor->temp_data[1], nullAngle);
|
2022-02-06 21:45:47 +00:00
|
|
|
//SetActor(actor, actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-09-11 19:43:49 +00:00
|
|
|
// lights off
|
2020-05-10 07:08:02 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:10:43 +00:00
|
|
|
void handle_se03(DDukeActor *actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2021-12-21 17:29:44 +00:00
|
|
|
int sh = actor->spr.hitag;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[4] == 0) return;
|
2022-09-14 20:49:01 +00:00
|
|
|
double xx;
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2022-09-14 20:49:01 +00:00
|
|
|
findplayer(actor, &xx);
|
2020-10-21 22:10:43 +00:00
|
|
|
|
2020-11-02 21:39:41 +00:00
|
|
|
int palvals = actor->palvals;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if ((global_random / (sh + 1) & 31) < 4 && !actor->temp_data[2])
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-21 22:10:43 +00:00
|
|
|
sc->ceilingpal = palvals >> 8;
|
|
|
|
sc->floorpal = palvals & 0xff;
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = actor->spr.shade + (global_random & 15);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
sc->ceilingpal = actor->spr.pal;
|
|
|
|
sc->floorpal = actor->spr.pal;
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = actor->temp_data[3];
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
sc->ceilingshade = actor->counter;
|
|
|
|
sc->floorshade = actor->counter;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-11-15 14:24:17 +00:00
|
|
|
for(auto& wal : sc->walls)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-07 16:36:09 +00:00
|
|
|
if (wal.hitag != 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
wal.shade = actor->counter;
|
2021-12-18 14:11:21 +00:00
|
|
|
if ((wal.cstat & CSTAT_WALL_BOTTOM_SWAP) && wal.twoSided())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-07 16:36:09 +00:00
|
|
|
wal.nextWall()->shade = wal.shade;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-09-11 19:43:49 +00:00
|
|
|
// lights
|
2020-05-10 07:08:02 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:10:43 +00:00
|
|
|
void handle_se04(DDukeActor *actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2021-12-21 17:29:44 +00:00
|
|
|
int sh = actor->spr.hitag;
|
2020-05-10 07:08:02 +00:00
|
|
|
int j;
|
|
|
|
|
2020-11-02 21:39:41 +00:00
|
|
|
int palvals = actor->palvals;
|
2020-10-21 22:10:43 +00:00
|
|
|
|
2020-05-10 07:08:02 +00:00
|
|
|
if ((global_random / (sh + 1) & 31) < 4)
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1] = actor->spr.shade + (global_random & 15);//Got really bright
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = actor->spr.shade + (global_random & 15);
|
2020-10-21 22:10:43 +00:00
|
|
|
sc->ceilingpal = palvals >> 8;
|
|
|
|
sc->floorpal = palvals & 0xff;
|
2020-05-10 07:08:02 +00:00
|
|
|
j = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1] = actor->temp_data[2];
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = actor->temp_data[3];
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
sc->ceilingpal = actor->spr.pal;
|
|
|
|
sc->floorpal = actor->spr.pal;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
j = 0;
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
sc->floorshade = actor->temp_data[1];
|
|
|
|
sc->ceilingshade = actor->temp_data[1];
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-11-15 14:24:17 +00:00
|
|
|
for (auto& wal : sc->walls)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-07 16:36:09 +00:00
|
|
|
if (j) wal.pal = (palvals & 0xff);
|
2021-12-21 17:29:44 +00:00
|
|
|
else wal.pal = actor->spr.pal;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-11-07 16:36:09 +00:00
|
|
|
if (wal.hitag != 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
wal.shade = actor->counter;
|
2021-12-18 14:11:21 +00:00
|
|
|
if ((wal.cstat & CSTAT_WALL_BOTTOM_SWAP) && wal.twoSided())
|
2021-11-07 16:36:09 +00:00
|
|
|
wal.nextWall()->shade = wal.shade;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 22:10:43 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
if (a2->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-18 12:14:56 +00:00
|
|
|
if (sc->ceilingstat & CSTAT_SECTOR_SKY)
|
2021-12-21 18:09:05 +00:00
|
|
|
a2->spr.shade = sc->ceilingshade;
|
|
|
|
else a2->spr.shade = sc->floorshade;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[4])
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-09-11 19:43:49 +00:00
|
|
|
// boss
|
2020-05-10 07:08:02 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-11-29 14:12:35 +00:00
|
|
|
void handle_se05(DDukeActor* actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2022-09-11 19:43:49 +00:00
|
|
|
int j;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 19:43:49 +00:00
|
|
|
double x;
|
|
|
|
int p = findplayer(actor, &x);
|
|
|
|
if (x < 512)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-25 12:13:50 +00:00
|
|
|
auto ang = actor->spr.Angles.Yaw;
|
2023-10-02 02:51:13 +00:00
|
|
|
actor->spr.Angles.Yaw = (actor->spr.pos.XY() - getPlayer(p)->GetActor()->spr.pos.XY()).Angle();
|
2022-12-29 09:56:10 +00:00
|
|
|
shoot(actor, isRR()? RedneckFirelaserClass : DukeFirelaserClass);
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.Angles.Yaw = ang;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 22:14:54 +00:00
|
|
|
auto Owner = actor->GetOwner();
|
|
|
|
if (Owner == nullptr) //Start search
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] = 0;
|
2022-09-11 19:43:49 +00:00
|
|
|
double maxdist = 0x7fffffff;
|
2020-05-10 07:08:02 +00:00
|
|
|
while (1) //Find the shortest dist
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
auto NewOwner = LocateTheLocator(actor->temp_data[4], nullptr);
|
2020-10-21 22:14:54 +00:00
|
|
|
if (NewOwner == nullptr) break;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 02:51:13 +00:00
|
|
|
double dist = (getPlayer(p)->GetActor()->spr.pos.XY() - NewOwner->spr.pos.XY()).LengthSquared();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 19:43:49 +00:00
|
|
|
if (maxdist > dist)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-21 22:14:54 +00:00
|
|
|
Owner = NewOwner;
|
2022-09-11 19:43:49 +00:00
|
|
|
maxdist = dist;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4]++;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 22:14:54 +00:00
|
|
|
actor->SetOwner(Owner);
|
|
|
|
if (!Owner) return; // Undefined case - was not checked.
|
2022-09-11 19:43:49 +00:00
|
|
|
actor->vel.Z = (Sgn(Owner->spr.pos.Z - actor->spr.pos.Z) / 16);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 19:43:49 +00:00
|
|
|
if ((Owner->spr.pos.XY() - actor->spr.pos.XY()).LengthSquared() < 64 * 64)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-08-20 19:14:00 +00:00
|
|
|
// Huh?
|
|
|
|
//auto ta = actor->spr.angle;
|
2022-09-30 11:38:21 +00:00
|
|
|
//actor->spr.angle = (ps[p].pos.XY() - actor->spr.pos.XY()).Angle();
|
2022-08-20 19:14:00 +00:00
|
|
|
//actor->spr.angle = ta;
|
2020-10-21 22:14:54 +00:00
|
|
|
actor->SetOwner(nullptr);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
2022-09-11 19:43:49 +00:00
|
|
|
else actor->vel.X = 16;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-30 11:38:21 +00:00
|
|
|
auto ang = (Owner->spr.pos.XY() - actor->spr.pos.XY()).Angle();
|
2022-11-25 12:13:50 +00:00
|
|
|
auto angdiff = deltaangle(actor->spr.Angles.Yaw, ang) / 8;
|
|
|
|
actor->spr.Angles.Yaw += angdiff;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (rnd(32))
|
|
|
|
{
|
2022-09-11 19:43:49 +00:00
|
|
|
actor->temp_angle += angdiff;
|
2020-05-10 07:08:02 +00:00
|
|
|
sc->ceilingshade = 127;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-11 19:43:49 +00:00
|
|
|
actor->temp_angle +=
|
2023-10-02 02:51:13 +00:00
|
|
|
deltaangle(actor->temp_angle + DAngle90, (getPlayer(p)->GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle()) * 0.25;
|
2020-05-10 07:08:02 +00:00
|
|
|
sc->ceilingshade = 0;
|
|
|
|
}
|
2020-10-21 22:14:54 +00:00
|
|
|
j = fi.ifhitbyweapon(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
if (j >= 0)
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[3]++;
|
|
|
|
if (actor->temp_data[3] == 5)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 17:28:45 +00:00
|
|
|
actor->vel.Z += 4;
|
2023-10-02 02:51:13 +00:00
|
|
|
FTA(7, getPlayer(myconnectindex));
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-03 08:03:30 +00:00
|
|
|
actor->spr.pos.Z += actor->vel.Z;
|
2022-09-04 20:51:39 +00:00
|
|
|
sc->setceilingz(actor->vel.Z);
|
2022-12-22 08:49:42 +00:00
|
|
|
sector[actor->counter].setceilingz(actor->vel.Z);
|
2022-09-11 19:43:49 +00:00
|
|
|
movesector(actor, actor->temp_data[1], actor->temp_angle);
|
2022-02-06 21:45:47 +00:00
|
|
|
//SetActor(actor, actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:14:54 +00:00
|
|
|
void handle_se08(DDukeActor *actor, bool checkhitag1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
// work only if its moving
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2021-12-21 17:29:44 +00:00
|
|
|
int st = actor->spr.lotag;
|
|
|
|
int sh = actor->spr.hitag;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 19:46:47 +00:00
|
|
|
int change, goal = -1;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-21 22:14:54 +00:00
|
|
|
if (actor->temp_data[4])
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-21 22:14:54 +00:00
|
|
|
actor->temp_data[4]++;
|
|
|
|
if (actor->temp_data[4] > 8)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-09-11 19:46:47 +00:00
|
|
|
goal = 1;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2022-09-12 17:47:07 +00:00
|
|
|
else goal = getanimationindex(anim_ceilingz, actor->sector());
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 19:46:47 +00:00
|
|
|
if (goal >= 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-21 22:14:54 +00:00
|
|
|
if ((sc->lotag & 0x8000) || actor->temp_data[4])
|
2022-09-11 19:46:47 +00:00
|
|
|
change = -actor->temp_data[3];
|
2020-05-10 07:08:02 +00:00
|
|
|
else
|
2022-09-11 19:46:47 +00:00
|
|
|
change = actor->temp_data[3];
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 19:46:47 +00:00
|
|
|
if (st == 9) change = -change;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-21 22:14:54 +00:00
|
|
|
DukeStatIterator it(STAT_EFFECTOR);
|
|
|
|
while (auto ac = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (((ac->spr.lotag) == st) && (ac->spr.hitag) == sh)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sect = ac->sector();
|
2022-09-11 19:46:47 +00:00
|
|
|
int minshade = ac->spr.shade;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-11-15 14:24:17 +00:00
|
|
|
for (auto& wal : sect->walls)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-07 16:36:09 +00:00
|
|
|
if (wal.hitag != 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 19:46:47 +00:00
|
|
|
wal.shade += change;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 19:46:47 +00:00
|
|
|
if (wal.shade < minshade)
|
|
|
|
wal.shade = minshade;
|
2021-11-07 16:36:09 +00:00
|
|
|
else if (wal.shade > ac->temp_data[2])
|
|
|
|
wal.shade = ac->temp_data[2];
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-11-21 07:42:36 +00:00
|
|
|
if (wal.twoSided())
|
2021-11-07 16:36:09 +00:00
|
|
|
if (wal.nextWall()->hitag != 1)
|
|
|
|
wal.nextWall()->shade = wal.shade;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-11 19:46:47 +00:00
|
|
|
sect->floorshade += change;
|
|
|
|
sect->ceilingshade += change;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 19:46:47 +00:00
|
|
|
if (sect->floorshade < minshade)
|
|
|
|
sect->floorshade = minshade;
|
2022-12-22 08:49:42 +00:00
|
|
|
else if (sect->floorshade > ac->counter)
|
|
|
|
sect->floorshade = ac->counter;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 19:46:47 +00:00
|
|
|
if (sect->ceilingshade < minshade)
|
|
|
|
sect->ceilingshade = minshade;
|
2020-10-21 22:14:54 +00:00
|
|
|
else if (sect->ceilingshade > ac->temp_data[1])
|
|
|
|
sect->ceilingshade = ac->temp_data[1];
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-14 16:55:50 +00:00
|
|
|
if (checkhitag1 && sect->hitag == 1)
|
2020-10-21 22:14:54 +00:00
|
|
|
sect->ceilingshade = ac->temp_data[1];
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-09-11 20:06:20 +00:00
|
|
|
// door auto close
|
2020-05-10 07:08:02 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:14:54 +00:00
|
|
|
void handle_se10(DDukeActor* actor, const int* specialtags)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2021-12-21 17:29:44 +00:00
|
|
|
int sh = actor->spr.hitag;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-30 13:05:39 +00:00
|
|
|
if ((sc->lotag & 0xff) == ST_27_STRETCH_BRIDGE || (sc->floorz > sc->ceilingz && (sc->lotag & 0xff) != ST_23_SWINGING_DOOR) || sc->lotag == 32791 - 65536)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
int j = 1;
|
|
|
|
|
2022-12-30 13:05:39 +00:00
|
|
|
if ((sc->lotag & 0xff) != ST_27_STRETCH_BRIDGE)
|
2020-05-10 07:08:02 +00:00
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2022-12-30 13:05:39 +00:00
|
|
|
if (sc->lotag != ST_30_ROTATE_RISE_BRIDGE && sc->lotag != ST_31_TWO_WAY_TRAIN && sc->lotag != ST_0_NO_EFFECT)
|
2023-10-02 02:51:13 +00:00
|
|
|
if (actor->sector() == getPlayer(p)->GetActor()->sector())
|
2020-05-10 07:08:02 +00:00
|
|
|
j = 0;
|
|
|
|
|
|
|
|
if (j == 1)
|
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter > sh)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
if (specialtags) for (int i = 0; specialtags[i]; i++)
|
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
if (actor->sector()->lotag == specialtags[i] && getanimationindex(anim_ceilingz, actor->sector()) >= 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-12-30 15:51:56 +00:00
|
|
|
fi.activatebysector(actor->sector(), actor);
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2022-12-22 08:49:42 +00:00
|
|
|
else actor->counter++;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
2022-12-22 08:49:42 +00:00
|
|
|
else actor->counter = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-09-11 20:06:20 +00:00
|
|
|
// swinging door
|
2020-05-10 07:08:02 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:20:47 +00:00
|
|
|
void handle_se11(DDukeActor *actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->temp_data[0] > 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->temp_data[0]--;
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[4])
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-15 14:24:17 +00:00
|
|
|
for(auto& wal : sc->walls)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-07 16:36:09 +00:00
|
|
|
DukeStatIterator it(STAT_ACTOR);
|
2020-10-21 22:20:47 +00:00
|
|
|
while (auto ac = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-08-17 21:24:44 +00:00
|
|
|
if (ac->spr.extra > 0 && badguy(ac) && IsCloseToWall(ac->spr.pos.XY(), &wal, 16) == EClose::InFront)
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-01-03 04:44:57 +00:00
|
|
|
}
|
|
|
|
|
2022-09-01 16:15:52 +00:00
|
|
|
int k = (actor->spr.yint >> 3) * actor->temp_data[3];
|
2022-09-11 20:06:20 +00:00
|
|
|
actor->temp_angle += mapangle(k);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] += k;
|
2022-09-11 20:06:20 +00:00
|
|
|
movesector(actor, actor->temp_data[1], actor->temp_angle);
|
2022-02-06 21:45:47 +00:00
|
|
|
//SetActor(actor, actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-11-15 14:24:17 +00:00
|
|
|
for(auto& wal : sc->walls)
|
2021-01-03 04:44:57 +00:00
|
|
|
{
|
2021-11-07 16:36:09 +00:00
|
|
|
DukeStatIterator it(STAT_PLAYER);
|
2020-10-21 22:20:47 +00:00
|
|
|
while (auto ac = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-08-17 21:24:44 +00:00
|
|
|
if (ac->GetOwner() && IsCloseToWall(ac->spr.pos.XY(), &wal, 9) == EClose::InFront)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->temp_data[0] = 8; // Delay
|
2022-09-11 20:06:20 +00:00
|
|
|
actor->temp_angle -= mapangle(k);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] -= k;
|
2022-09-11 20:06:20 +00:00
|
|
|
movesector(actor, actor->temp_data[1], actor->temp_angle);
|
2022-02-06 21:45:47 +00:00
|
|
|
//SetActor(actor, actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[4] <= -511 || actor->temp_data[4] >= 512)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] = 0;
|
2022-09-11 20:06:20 +00:00
|
|
|
actor->temp_angle = mapangle(actor->temp_angle.Buildang() & 0xffffff00); // Gross hack! What is this supposed to do?
|
|
|
|
movesector(actor, actor->temp_data[1], actor->temp_angle);
|
2022-02-06 21:45:47 +00:00
|
|
|
//SetActor(actor, actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:20:47 +00:00
|
|
|
void handle_se12(DDukeActor *actor, int planeonly)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter == 3 || actor->temp_data[3] == 1) //Lights going off
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
sc->floorpal = 0;
|
|
|
|
sc->ceilingpal = 0;
|
|
|
|
|
2022-11-15 14:24:17 +00:00
|
|
|
for (auto& wal : sc->walls)
|
2021-11-18 22:00:24 +00:00
|
|
|
{
|
|
|
|
if (wal.hitag != 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
wal.shade = actor->temp_data[1];
|
2021-11-18 22:00:24 +00:00
|
|
|
wal.pal = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2021-11-18 22:00:24 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
sc->floorshade = actor->temp_data[1];
|
|
|
|
sc->ceilingshade = actor->temp_data[2];
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-11-20 23:33:17 +00:00
|
|
|
DukeSectIterator it(sc);
|
2020-10-21 22:20:47 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-18 12:14:56 +00:00
|
|
|
if (sc->ceilingstat & CSTAT_SECTOR_SKY)
|
2021-12-21 17:19:45 +00:00
|
|
|
a2->spr.shade = sc->ceilingshade;
|
|
|
|
else a2->spr.shade = sc->floorshade;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[3] == 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter == 1) //Lights flickering on
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
// planeonly 1 is RRRA SE47, planeonly 2 is SE48
|
|
|
|
int compshade = planeonly == 2 ? sc->ceilingshade : sc->floorshade;
|
2021-12-21 17:29:44 +00:00
|
|
|
if (compshade > actor->spr.shade)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (planeonly != 2) sc->floorpal = actor->spr.pal;
|
|
|
|
if (planeonly != 1) sc->ceilingpal = actor->spr.pal;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (planeonly != 2) sc->floorshade -= 2;
|
|
|
|
if (planeonly != 1) sc->ceilingshade -= 2;
|
|
|
|
|
2022-11-15 14:24:17 +00:00
|
|
|
for (auto& wal : sc->walls)
|
2021-11-18 22:00:24 +00:00
|
|
|
{
|
|
|
|
if (wal.hitag != 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
wal.pal = actor->spr.pal;
|
2021-11-18 22:00:24 +00:00
|
|
|
wal.shade -= 2;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2021-11-18 22:00:24 +00:00
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2022-12-22 08:49:42 +00:00
|
|
|
else actor->counter = 2;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 22:20:47 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-18 12:14:56 +00:00
|
|
|
if (sc->ceilingstat & CSTAT_SECTOR_SKY)
|
2021-12-21 17:19:45 +00:00
|
|
|
a2->spr.shade = sc->ceilingshade;
|
|
|
|
else a2->spr.shade = sc->floorshade;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-09-11 20:28:05 +00:00
|
|
|
// explosive
|
2020-05-10 07:08:02 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:20:47 +00:00
|
|
|
void handle_se13(DDukeActor* actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[2])
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 20:28:05 +00:00
|
|
|
double amt = ((actor->spr.yint << 5) | 1) * zmaptoworld;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 20:28:05 +00:00
|
|
|
if (actor->spr.intangle == 512)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-11-02 21:39:41 +00:00
|
|
|
if (actor->spriteextra)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 20:28:05 +00:00
|
|
|
if (abs(actor->temp_pos.Y - sc->ceilingz) >= amt)
|
|
|
|
sc->addceilingz(Sgn(actor->temp_pos.Y - sc->ceilingz) * amt);
|
|
|
|
else sc->setceilingz(actor->temp_pos.Y);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-11 20:28:05 +00:00
|
|
|
if (abs(actor->temp_pos.Z - sc->floorz) >= amt)
|
|
|
|
sc->addfloorz(Sgn(actor->temp_pos.Z - sc->floorz) * amt);
|
|
|
|
else sc->setfloorz(actor->temp_pos.Z);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-11 20:28:05 +00:00
|
|
|
if (abs(actor->temp_pos.Z - sc->floorz) >= amt)
|
|
|
|
sc->addfloorz(Sgn(actor->temp_pos.Z - sc->floorz) * amt);
|
|
|
|
else sc->setfloorz(actor->temp_pos.Z);
|
|
|
|
|
|
|
|
if (abs(actor->temp_pos.Y - sc->ceilingz) >= amt)
|
|
|
|
sc->addceilingz(Sgn(actor->temp_pos.Y - sc->ceilingz) * amt);
|
|
|
|
sc->setceilingz(actor->temp_pos.Y);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[3] == 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
//Change the shades
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[3]++;
|
2021-12-18 12:23:08 +00:00
|
|
|
sc->ceilingstat ^= CSTAT_SECTOR_SKY;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-10-19 16:02:05 +00:00
|
|
|
if (actor->spr.intangle == 512)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-15 14:24:17 +00:00
|
|
|
for (auto& wal : sc->walls)
|
2021-12-21 17:29:44 +00:00
|
|
|
wal.shade = actor->spr.shade;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
sc->floorshade = actor->spr.shade;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(0)->one_parallax_sectnum != nullptr)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
sc->setceilingtexture(getPlayer(0)->one_parallax_sectnum->ceilingtexture);
|
|
|
|
sc->ceilingshade = getPlayer(0)->one_parallax_sectnum->ceilingshade;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2]++;
|
|
|
|
if (actor->temp_data[2] > 256)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-25 12:13:50 +00:00
|
|
|
if (actor->temp_data[2] == 4 && actor->spr.Angles.Yaw != DAngle90)
|
2020-10-21 22:20:47 +00:00
|
|
|
for (int x = 0; x < 7; x++) RANDOMSCRAP(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:25:11 +00:00
|
|
|
void handle_se15(DDukeActor* actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[4])
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-03 08:05:20 +00:00
|
|
|
actor->vel.X = 1;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[4] == 1) //Opening
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-01 16:15:52 +00:00
|
|
|
if (actor->temp_data[3] >= (actor->spr.yint >> 3))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] = 0; //Turn off the sliders
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[3]++;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (actor->temp_data[4] == 2)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[3] < 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] = 0;
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[3]--;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-09-14 20:02:28 +00:00
|
|
|
movesector(actor, actor->temp_data[1], nullAngle);
|
2022-02-06 21:45:47 +00:00
|
|
|
//SetActor(actor, actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-02 22:26:55 +00:00
|
|
|
void handle_se16(DDukeActor* actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-14 19:08:27 +00:00
|
|
|
actor->temp_angle += DAngle22_5 / 4;
|
2022-08-20 18:57:54 +00:00
|
|
|
if (sc->floorz < sc->ceilingz) actor->spr.shade = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-14 19:08:27 +00:00
|
|
|
else if (sc->ceilingz < actor->temp_pos.Z)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
//The following code check to see if
|
|
|
|
//there is any other sprites in the sector.
|
|
|
|
//If there isn't, then kill this sectoreffector
|
|
|
|
//itself.....
|
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 22:25:11 +00:00
|
|
|
DDukeActor* a2;
|
|
|
|
while ((a2 = it.Next()))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-29 08:56:14 +00:00
|
|
|
if (a2->IsKindOf(DukeReactorClass) && a2->spritesetindex == 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-10-21 22:25:11 +00:00
|
|
|
if (a2 == nullptr)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-21 17:29:44 +00:00
|
|
|
else actor->spr.shade = 1;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-08-20 18:57:54 +00:00
|
|
|
if (actor->spr.shade) sc->addceilingz(4);
|
|
|
|
else sc->addceilingz(-2);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-14 19:08:27 +00:00
|
|
|
movesector(actor, actor->temp_data[1], actor->temp_angle);
|
2022-02-06 21:45:47 +00:00
|
|
|
//SetActor(actor, actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:25:11 +00:00
|
|
|
void handle_se17(DDukeActor* actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2021-12-21 17:29:44 +00:00
|
|
|
int sh = actor->spr.hitag;
|
2022-09-14 19:04:07 +00:00
|
|
|
double refheight = actor->spr.yint * zmaptoworld;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
double q = actor->counter * refheight * 4;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-02-04 16:49:48 +00:00
|
|
|
sc->addceilingz(q);
|
|
|
|
sc->addfloorz(q);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 22:25:11 +00:00
|
|
|
while (auto act1 = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act1->spr.statnum == STAT_PLAYER && act1->GetOwner())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-01 16:15:52 +00:00
|
|
|
int p = act1->spr.yint;
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->GetActor()->spr.pos.Z += q;
|
|
|
|
getPlayer(p)->truefz += q;
|
|
|
|
getPlayer(p)->truecz += q;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2022-11-15 23:56:13 +00:00
|
|
|
if (act1->spr.statnum != STAT_EFFECTOR && act1->spr.statnum != STAT_PLAYER)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-02-04 16:49:48 +00:00
|
|
|
act1->spr.pos.Z += q;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-03 23:44:13 +00:00
|
|
|
act1->floorz = sc->floorz;
|
|
|
|
act1->ceilingz = sc->ceilingz;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter) //If in motion
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-14 19:04:07 +00:00
|
|
|
if (abs(sc->floorz - actor->temp_pos.X) <= refheight)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-23 15:46:46 +00:00
|
|
|
activatewarpelevators(actor, 0);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter == -1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-14 19:04:07 +00:00
|
|
|
if (sc->floorz > actor->temp_pos.Y)
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-09-14 19:04:07 +00:00
|
|
|
else if (sc->ceilingz < actor->temp_pos.Z) return;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[1] == 0) return;
|
|
|
|
actor->temp_data[1] = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-21 22:25:11 +00:00
|
|
|
DDukeActor* act2;
|
2021-12-24 09:53:27 +00:00
|
|
|
DukeStatIterator itr(STAT_EFFECTOR);
|
|
|
|
while ((act2 = itr.Next()))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (actor != act2 && (act2->spr.lotag) == 17)
|
2022-12-22 08:49:42 +00:00
|
|
|
if ((sc->hitag - actor->counter) == (act2->sector()->hitag) && sh == (act2->spr.hitag))
|
2020-05-10 07:08:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-10-21 22:25:11 +00:00
|
|
|
if (act2 == nullptr) return;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-11-21 00:04:16 +00:00
|
|
|
DukeSectIterator its(actor->sector());
|
2020-10-21 22:25:11 +00:00
|
|
|
while (auto act3 = its.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
if (act3->spr.statnum == STAT_PLAYER && act3->GetOwner())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-01 15:26:46 +00:00
|
|
|
int p = act3->PlayerIndex();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-11-21 04:24:01 +00:00
|
|
|
act3->opos -= act3->spr.pos;
|
|
|
|
act3->spr.pos.XY() += act2->spr.pos.XY() - actor->spr.pos.XY();
|
|
|
|
act3->spr.pos.Z += act2->sector()->floorz - sc->floorz;
|
|
|
|
act3->opos += act3->spr.pos;
|
2022-10-07 07:38:11 +00:00
|
|
|
|
2023-10-02 02:51:13 +00:00
|
|
|
if (q > 0) getPlayer(p)->GetActor()->backupz();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-02-03 23:44:13 +00:00
|
|
|
act3->floorz = act2->sector()->floorz;
|
|
|
|
act3->ceilingz = act2->sector()->ceilingz;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->setbobpos();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->truefz = act3->floorz;
|
|
|
|
getPlayer(p)->truecz = act3->ceilingz;
|
|
|
|
getPlayer(p)->bobcounter = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
ChangeActorSect(act3, act2->sector());
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->setCursector(act2->sector());
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2021-12-21 18:09:05 +00:00
|
|
|
else if (act3->spr.statnum != STAT_EFFECTOR)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-10-07 07:38:11 +00:00
|
|
|
act3->opos -= act3->spr.pos;
|
|
|
|
act3->spr.pos.XY() += act2->spr.pos.XY() - actor->spr.pos.XY();
|
|
|
|
act3->spr.pos.Z += act2->sector()->floorz - sc->floorz;
|
|
|
|
act3->opos += act3->spr.pos;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-10-07 07:38:11 +00:00
|
|
|
if (q > 0) act3->backupz();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
ChangeActorSect(act3, act2->sector());
|
2022-08-22 16:34:01 +00:00
|
|
|
SetActor(act3, act3->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-02-03 23:44:13 +00:00
|
|
|
act3->floorz = act2->sector()->floorz;
|
|
|
|
act3->ceilingz = act2->sector()->ceilingz;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:30:22 +00:00
|
|
|
void handle_se18(DDukeActor *actor, bool morecheck)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-08-22 17:32:51 +00:00
|
|
|
double extra = sc->extra * zmaptoworld;
|
|
|
|
double goal = FixedToFloat<8>(actor->temp_data[1]);
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (actor->spr.pal)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-08-22 17:32:51 +00:00
|
|
|
if (actor->spr.intangle == 512)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-08-22 17:32:51 +00:00
|
|
|
sc->addceilingz(-extra);
|
|
|
|
if (sc->ceilingz <= goal)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-08-22 17:32:51 +00:00
|
|
|
sc->setceilingz(goal);
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-08-22 17:32:51 +00:00
|
|
|
sc->addfloorz(extra);
|
2020-05-10 07:08:02 +00:00
|
|
|
if (morecheck)
|
|
|
|
{
|
2021-11-21 00:04:16 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 22:30:22 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-31 17:47:00 +00:00
|
|
|
if (a2->isPlayer() && a2->GetOwner())
|
2022-08-22 17:32:51 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(a2->PlayerIndex())->on_ground == 1) getPlayer(a2->PlayerIndex())->GetActor()->spr.pos.Z += extra;
|
2022-08-22 17:32:51 +00:00
|
|
|
}
|
2022-09-03 08:03:30 +00:00
|
|
|
if (a2->vel.Z == 0 && a2->spr.statnum != STAT_EFFECTOR && a2->spr.statnum != STAT_PROJECTILE)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-16 00:07:10 +00:00
|
|
|
if (!a2->isPlayer()) a2->spr.pos.Z += extra;
|
2022-02-03 23:44:13 +00:00
|
|
|
a2->floorz = sc->floorz;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-22 17:32:51 +00:00
|
|
|
if (sc->floorz >= goal)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-08-22 17:32:51 +00:00
|
|
|
sc->setfloorz(goal);
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-08-22 17:32:51 +00:00
|
|
|
if (actor->spr.intangle == 512)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-08-22 17:32:51 +00:00
|
|
|
sc->addceilingz(extra);
|
|
|
|
if (sc->ceilingz >= actor->spr.pos.Z)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-02-07 07:59:20 +00:00
|
|
|
sc->setceilingz(actor->spr.pos.Z);
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-08-22 17:32:51 +00:00
|
|
|
sc->addfloorz(-extra);
|
2020-05-10 07:08:02 +00:00
|
|
|
if (morecheck)
|
|
|
|
{
|
2021-11-21 00:04:16 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 22:30:22 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-31 17:47:00 +00:00
|
|
|
if (a2->isPlayer() && a2->GetOwner())
|
2022-08-22 17:32:51 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(a2->PlayerIndex())->on_ground == 1) getPlayer(a2->PlayerIndex())->GetActor()->spr.pos.Z -= extra;
|
2022-08-22 17:32:51 +00:00
|
|
|
}
|
2022-09-03 08:03:30 +00:00
|
|
|
if (a2->vel.Z == 0 && a2->spr.statnum != STAT_EFFECTOR && a2->spr.statnum != STAT_PROJECTILE)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-16 00:07:10 +00:00
|
|
|
if (!a2->isPlayer()) a2->spr.pos.Z -= extra;
|
2022-02-03 23:44:13 +00:00
|
|
|
a2->floorz = sc->floorz;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-22 17:32:51 +00:00
|
|
|
if (sc->floorz <= actor->spr.pos.Z)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-02-07 07:59:20 +00:00
|
|
|
sc->setfloorz(actor->spr.pos.Z);
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2]++;
|
|
|
|
if (actor->temp_data[2] >= actor->spr.hitag)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] = 0;
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-01-02 11:27:36 +00:00
|
|
|
DDukeActor* ifhitsectors(sectortype* sect)
|
|
|
|
{
|
|
|
|
DukeStatIterator it(STAT_MISC);
|
|
|
|
while (auto a1 = it.Next())
|
|
|
|
{
|
2022-12-20 21:25:48 +00:00
|
|
|
if ((a1->flags1 & SFLAG_TRIGGER_IFHITSECTOR) && sect == a1->sector())
|
2022-01-02 11:27:36 +00:00
|
|
|
return a1;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-09 23:56:40 +00:00
|
|
|
void handle_se19(DDukeActor *actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2021-12-21 17:19:45 +00:00
|
|
|
int sh = actor->spr.hitag;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter == 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter++;
|
2022-11-15 14:24:17 +00:00
|
|
|
for (auto& wal : sc->walls)
|
2021-11-15 21:59:51 +00:00
|
|
|
{
|
2022-12-10 18:03:17 +00:00
|
|
|
if (tileflags(wal.overtexture) & TFLAG_FORCEFIELD)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-18 14:16:31 +00:00
|
|
|
wal.cstat &= (CSTAT_WALL_TRANSLUCENT | CSTAT_WALL_1WAY | CSTAT_WALL_XFLIP | CSTAT_WALL_ALIGN_BOTTOM | CSTAT_WALL_BOTTOM_SWAP);
|
2022-12-09 23:56:40 +00:00
|
|
|
wal.setovertexture(FNullTextureID());
|
2021-11-15 21:59:51 +00:00
|
|
|
auto nextwal = wal.nextWall();
|
|
|
|
if (nextwal != nullptr)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-09 23:56:40 +00:00
|
|
|
nextwal->setovertexture(FNullTextureID());
|
2021-12-18 14:16:31 +00:00
|
|
|
nextwal->cstat &= (CSTAT_WALL_TRANSLUCENT | CSTAT_WALL_1WAY | CSTAT_WALL_XFLIP | CSTAT_WALL_ALIGN_BOTTOM | CSTAT_WALL_BOTTOM_SWAP);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-15 21:59:51 +00:00
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-08-20 18:57:54 +00:00
|
|
|
if (sc->ceilingz < sc->floorz)
|
2022-09-11 21:31:20 +00:00
|
|
|
sc->addceilingz(actor->spr.yint * zmaptoworld);
|
2020-05-10 07:08:02 +00:00
|
|
|
else
|
|
|
|
{
|
2022-08-20 18:57:54 +00:00
|
|
|
sc->setceilingz(sc->floorz);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-21 22:30:22 +00:00
|
|
|
DukeStatIterator it(STAT_EFFECTOR);
|
|
|
|
while (auto a2 = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-21 22:30:22 +00:00
|
|
|
auto a2Owner = a2->GetOwner();
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.lotag == 0 && a2->spr.hitag == sh && a2Owner)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sectp = a2Owner->sector();
|
|
|
|
a2->sector()->floorpal = a2->sector()->ceilingpal = sectp->floorpal;
|
|
|
|
a2->sector()->floorshade = a2->sector()->ceilingshade = sectp->floorshade;
|
2022-12-22 08:49:42 +00:00
|
|
|
a2Owner->counter = 2;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else //Not hit yet
|
|
|
|
{
|
2022-01-02 11:27:36 +00:00
|
|
|
auto hitter = ifhitsectors(actor->sector());
|
2020-10-21 22:30:22 +00:00
|
|
|
if (hitter)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
FTA(8, getPlayer(myconnectindex));
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-21 22:30:22 +00:00
|
|
|
DukeStatIterator it(STAT_EFFECTOR);
|
|
|
|
while (auto ac = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
int x = ac->spr.lotag & 0x7fff;
|
2020-05-10 07:08:02 +00:00
|
|
|
switch (x)
|
|
|
|
{
|
|
|
|
case 0:
|
2021-12-21 17:19:45 +00:00
|
|
|
if (ac->spr.hitag == sh && ac->GetOwner())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sectp = ac->sector();
|
2021-12-21 17:19:45 +00:00
|
|
|
sectp->floorshade = sectp->ceilingshade = ac->GetOwner()->spr.shade;
|
|
|
|
sectp->floorpal = sectp->ceilingpal = ac->GetOwner()->spr.pal;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
case 12:
|
|
|
|
//case 18:
|
|
|
|
case 19:
|
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
if (sh == ac->spr.hitag)
|
2022-12-22 08:49:42 +00:00
|
|
|
if (ac->counter == 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
ac->counter = 1; //Shut them all on
|
2020-10-21 22:30:22 +00:00
|
|
|
ac->SetOwner(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:35:30 +00:00
|
|
|
void handle_se20(DDukeActor* actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter == 0) return;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 22:56:23 +00:00
|
|
|
//if(actor->vel.X != 0) //Moving
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
auto vec = actor->spr.Angles.Yaw.ToVector() * (actor->counter == 1 ? 0.5 : -0.5);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->temp_data[3] += actor->counter == 1? 8 :- 8;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 22:56:23 +00:00
|
|
|
actor->spr.pos += vec;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-01 16:15:52 +00:00
|
|
|
if (actor->temp_data[3] <= 0 || (actor->temp_data[3] >> 6) >= (actor->spr.yint >> 6))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 22:56:23 +00:00
|
|
|
actor->spr.pos -= vec;
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 22:35:30 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-12 16:26:27 +00:00
|
|
|
if (a2->spr.statnum != STAT_EFFECTOR && a2->vel.Z == 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 22:56:23 +00:00
|
|
|
actor->spr.pos += vec;
|
2021-12-18 12:23:08 +00:00
|
|
|
if (a2->sector()->floorstat & CSTAT_SECTOR_SLOPE)
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.statnum == 2)
|
2020-10-21 22:35:30 +00:00
|
|
|
makeitfall(a2);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-15 22:32:41 +00:00
|
|
|
auto& wal = actor->temp_walls;
|
2022-09-11 22:56:23 +00:00
|
|
|
dragpoint(wal[0], wal[0]->pos + vec);
|
|
|
|
dragpoint(wal[1], wal[1]->pos + vec);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(p)->cursector == actor->sector() && getPlayer(p)->on_ground)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->GetActor()->spr.pos.XY() += vec;
|
|
|
|
getPlayer(p)->GetActor()->backupvec2();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2023-10-02 02:51:13 +00:00
|
|
|
SetActor(getPlayer(p)->GetActor(), getPlayer(p)->GetActor()->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-10-12 17:00:29 +00:00
|
|
|
sc->addfloorxpan(-(float)vec.X * 2);
|
|
|
|
sc->addfloorypan(-(float)vec.Y * 2);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-10-12 17:00:29 +00:00
|
|
|
sc->addceilingxpan(-(float)vec.X * 2);
|
|
|
|
sc->addceilingypan(-(float)vec.Y * 2);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:35:30 +00:00
|
|
|
void handle_se21(DDukeActor* actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2022-09-11 21:35:31 +00:00
|
|
|
double lp;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter == 0) return;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 21:35:31 +00:00
|
|
|
if (actor->spr.intangle == 1536)
|
|
|
|
lp = sc->ceilingz;
|
2020-05-10 07:08:02 +00:00
|
|
|
else
|
2022-09-11 21:35:31 +00:00
|
|
|
lp = sc->floorz;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter == 1) //Decide if the sector should go up or down
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 21:35:31 +00:00
|
|
|
actor->vel.Z = (Sgn(actor->spr.pos.Z - lp) * (actor->spr.yint << 4) * zmaptoworld);
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter++;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->extra == 0)
|
|
|
|
{
|
2022-09-11 21:45:55 +00:00
|
|
|
lp += actor->vel.Z;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-11 21:45:55 +00:00
|
|
|
if (abs(lp - actor->spr.pos.Z) < 4)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 21:45:55 +00:00
|
|
|
lp = actor->spr.pos.Z;
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2022-02-02 23:50:36 +00:00
|
|
|
|
2022-09-11 21:45:55 +00:00
|
|
|
if (actor->spr.intangle == 1536)
|
|
|
|
sc->setceilingz(lp);
|
2022-02-02 23:50:36 +00:00
|
|
|
else
|
2022-09-11 21:45:55 +00:00
|
|
|
sc->setfloorz(lp);
|
2022-02-02 23:50:36 +00:00
|
|
|
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else sc->extra--;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:35:30 +00:00
|
|
|
void handle_se22(DDukeActor* actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[1])
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
if (getanimationindex(anim_ceilingz, §or[actor->counter]) >= 0)
|
2022-09-11 21:31:20 +00:00
|
|
|
sc->addceilingz(sc->extra * 9 * zmaptoworld);
|
2021-12-23 15:03:43 +00:00
|
|
|
else actor->temp_data[1] = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:35:30 +00:00
|
|
|
void handle_se26(DDukeActor* actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2022-09-03 08:03:30 +00:00
|
|
|
double zvel = actor->vel.Z;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-03 08:05:20 +00:00
|
|
|
actor->vel.X = 2;
|
2022-11-25 12:13:50 +00:00
|
|
|
DVector2 vect = 2 * actor->spr.Angles.Yaw.ToVector(); // was: (32 * b sin) >> 14
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.shade++;
|
|
|
|
if (actor->spr.shade > 7)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-08-29 21:13:54 +00:00
|
|
|
actor->spr.pos.XY() = actor->temp_pos.XY();
|
2022-08-29 20:26:20 +00:00
|
|
|
sc->addfloorz(-((zvel * actor->spr.shade) - zvel));
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.shade = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
2022-08-29 20:26:20 +00:00
|
|
|
sc->addfloorz(zvel);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 22:35:30 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.statnum != 3 && a2->spr.statnum != 10)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-08-29 20:26:20 +00:00
|
|
|
a2->spr.pos = DVector3(vect, zvel);
|
2022-08-22 16:34:01 +00:00
|
|
|
SetActor(a2, a2->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(p)->GetActor()->sector() == actor->sector() && getPlayer(p)->on_ground)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->fric.X += vect.X;
|
|
|
|
getPlayer(p)->fric.Y += vect.Y;
|
|
|
|
getPlayer(p)->GetActor()->spr.pos.Z += zvel;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-09-14 20:02:28 +00:00
|
|
|
movesector(actor, actor->temp_data[1], nullAngle);
|
2022-02-06 21:45:47 +00:00
|
|
|
//SetActor(actor, actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:40:57 +00:00
|
|
|
void handle_se27(DDukeActor* actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
int sh = actor->spr.hitag;
|
2022-09-14 20:49:01 +00:00
|
|
|
int p;
|
|
|
|
double xx;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (ud.recstat == 0) return;
|
|
|
|
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->temp_angle = actor->spr.Angles.Yaw;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-14 20:49:01 +00:00
|
|
|
p = findplayer(actor, &xx);
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(p)->GetActor()->spr.extra > 0 && myconnectindex == screenpeek)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter < 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-11-02 22:53:55 +00:00
|
|
|
ud.cameraactor = actor;
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter++;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2023-10-02 02:51:13 +00:00
|
|
|
else if (ud.recstat == 2 && getPlayer(p)->newOwner == nullptr)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
if (cansee(actor->spr.pos, actor->sector(), getPlayer(p)->GetActor()->getPosWithOffsetZ(), getPlayer(p)->cursector))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-14 20:49:01 +00:00
|
|
|
if (xx < sh * maptoworld)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-11-02 22:53:55 +00:00
|
|
|
ud.cameraactor = actor;
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 999;
|
2023-10-02 02:51:13 +00:00
|
|
|
actor->spr.Angles.Yaw += deltaangle(actor->spr.Angles.Yaw, (getPlayer(p)->GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle()) * 0.125;
|
|
|
|
actor->spr.yint = 100 + int((actor->spr.pos.Z - getPlayer(p)->GetActor()->getOffsetZ()) * (256. / 257.));
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
}
|
2022-12-22 08:49:42 +00:00
|
|
|
else if (actor->counter == 999)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-11-02 22:53:55 +00:00
|
|
|
if (ud.cameraactor == actor)
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
|
|
|
else actor->counter = -10;
|
2020-11-02 22:53:55 +00:00
|
|
|
ud.cameraactor = actor;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
actor->spr.Angles.Yaw = (getPlayer(p)->GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Angle();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter == 999)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-11-02 22:53:55 +00:00
|
|
|
if (ud.cameraactor == actor)
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
|
|
|
else actor->counter = -20;
|
2020-11-02 22:53:55 +00:00
|
|
|
ud.cameraactor = actor;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-09-12 19:59:34 +00:00
|
|
|
void handle_se24(DDukeActor *actor, bool scroll, double mult)
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[4]) return;
|
2020-10-21 22:50:01 +00:00
|
|
|
|
2022-11-25 12:13:50 +00:00
|
|
|
auto vec = actor->spr.Angles.Yaw.ToVector() * actor->spr.yint / 256.;
|
2020-10-21 22:50:01 +00:00
|
|
|
|
2021-11-21 00:04:16 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 22:50:01 +00:00
|
|
|
while (auto a2 = it.Next())
|
|
|
|
{
|
2022-09-03 08:03:30 +00:00
|
|
|
if (a2->vel.Z >= 0)
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
switch (a2->spr.statnum)
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
2022-01-18 22:00:58 +00:00
|
|
|
case STAT_MISC:
|
2022-01-19 07:51:48 +00:00
|
|
|
case STAT_STANDABLE:
|
|
|
|
case STAT_ACTOR:
|
|
|
|
case STAT_DEFAULT:
|
2022-12-20 21:25:48 +00:00
|
|
|
if (a2->flags1 & SFLAG_SE24_REMOVE)
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
2022-10-07 21:52:29 +00:00
|
|
|
a2->spr.scale = DVector2(0, 0);
|
2020-10-21 22:50:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-12-20 21:25:48 +00:00
|
|
|
if ((a2->flags1 & SFLAG_SE24_NOCARRY) || wallswitchcheck(a2) || GetExtInfo(a2->spr.spritetexture()).switchindex > 0)
|
2022-01-19 07:51:48 +00:00
|
|
|
continue;
|
2020-10-21 22:50:01 +00:00
|
|
|
|
2022-02-03 23:45:24 +00:00
|
|
|
if (a2->spr.pos.Z > a2->floorz - 16)
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
2022-09-12 19:59:34 +00:00
|
|
|
a2->spr.pos += vec * mult;
|
2020-10-21 22:50:01 +00:00
|
|
|
|
2022-08-22 16:34:01 +00:00
|
|
|
SetActor(a2, a2->spr.pos);
|
2020-10-21 22:50:01 +00:00
|
|
|
|
2022-01-19 07:51:48 +00:00
|
|
|
if (a2->sector()->floorstat & CSTAT_SECTOR_SLOPE)
|
|
|
|
if (a2->spr.statnum == STAT_ZOMBIEACTOR)
|
|
|
|
makeitfall(a2);
|
2020-10-21 22:50:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto p = connecthead; p >= 0; p = connectpoint2[p])
|
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(p)->cursector == actor->sector() && getPlayer(p)->on_ground)
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
if (abs(getPlayer(p)->GetActor()->getOffsetZ() - getPlayer(p)->truefz) < gs.playerheight + 9)
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
getPlayer(p)->fric += vec * (1. / 8.); // keeping the original velocity. to match the animation it should be ~1/24.
|
2020-10-21 22:50:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-09-01 16:15:52 +00:00
|
|
|
if (scroll) actor->sector()->addfloorxpan(actor->spr.yint / 128.f);
|
2020-10-21 22:50:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-09-12 21:35:48 +00:00
|
|
|
void handle_se25(DDukeActor* actor, int snd1, int snd2)
|
2020-10-21 22:59:42 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sec = actor->sector();
|
2022-11-05 15:00:39 +00:00
|
|
|
auto add = actor->spr.yint * (1 / 16.);
|
2020-10-21 22:59:42 +00:00
|
|
|
|
2022-08-20 18:11:01 +00:00
|
|
|
if (sec->floorz <= sec->ceilingz)
|
2021-12-21 17:19:45 +00:00
|
|
|
actor->spr.shade = 0;
|
2022-09-12 21:35:48 +00:00
|
|
|
else if (sec->ceilingz <= actor->temp_pos.Z)
|
2021-12-21 17:19:45 +00:00
|
|
|
actor->spr.shade = 1;
|
2020-10-21 22:59:42 +00:00
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
if (actor->spr.shade)
|
2020-10-21 22:59:42 +00:00
|
|
|
{
|
2022-09-12 21:35:48 +00:00
|
|
|
sec->addceilingz(add);
|
2022-08-20 18:11:01 +00:00
|
|
|
if (sec->ceilingz > sec->floorz)
|
2020-10-21 22:59:42 +00:00
|
|
|
{
|
2022-08-28 19:05:45 +00:00
|
|
|
sec->setceilingz(sec->floorz);
|
2022-12-14 20:49:20 +00:00
|
|
|
if (ud.pistonsound && snd1 >= 0)
|
2020-10-21 22:59:42 +00:00
|
|
|
S_PlayActorSound(snd1, actor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-12 21:35:48 +00:00
|
|
|
sec->addceilingz(-add);
|
|
|
|
if (sec->ceilingz < actor->temp_pos.Z)
|
2020-10-21 22:59:42 +00:00
|
|
|
{
|
2022-09-12 21:35:48 +00:00
|
|
|
sec->setceilingz(actor->temp_pos.Z);
|
2022-12-14 20:49:20 +00:00
|
|
|
if (ud.pistonsound && snd2 >= 0)
|
2020-10-21 22:59:42 +00:00
|
|
|
S_PlayActorSound(snd2, actor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:40:57 +00:00
|
|
|
void handle_se32(DDukeActor *actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter == 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
// Choose dir
|
|
|
|
|
2022-09-11 21:31:20 +00:00
|
|
|
double targetval = actor->spr.yint * zmaptoworld;
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[2] == 1) // Retract
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-12 19:52:47 +00:00
|
|
|
if (actor->spr.intangle != 1536)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 21:31:20 +00:00
|
|
|
if (abs(sc->ceilingz - actor->spr.pos.Z) < targetval * 2)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-02-07 07:59:20 +00:00
|
|
|
sc->setceilingz(actor->spr.pos.Z);
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] = 0;
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2022-09-11 21:31:20 +00:00
|
|
|
else sc->addceilingz(Sgn(actor->spr.pos.Z - sc->ceilingz) * targetval);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-12 19:52:47 +00:00
|
|
|
if (abs(sc->ceilingz - actor->temp_pos.Z) < targetval * 2)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-12 19:52:47 +00:00
|
|
|
sc->setceilingz(actor->temp_pos.Z);
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] = 0;
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2022-09-12 19:52:47 +00:00
|
|
|
else sc->addceilingz(Sgn(actor->temp_pos.Z - sc->ceilingz) * targetval);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-09-11 21:31:20 +00:00
|
|
|
if ((actor->spr.intangle & 2047) == 1536)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-11 21:31:20 +00:00
|
|
|
if (abs(sc->ceilingz - actor->spr.pos.Z) < targetval * 2)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] = !actor->temp_data[2];
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2022-02-07 07:59:20 +00:00
|
|
|
sc->setceilingz(actor->spr.pos.Z);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2022-09-11 21:31:20 +00:00
|
|
|
else sc->addceilingz(Sgn(actor->spr.pos.Z - sc->ceilingz) * targetval);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-12 19:52:47 +00:00
|
|
|
if (abs(sc->ceilingz - actor->temp_pos.Z) < targetval * 2)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] = !actor->temp_data[2];
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2022-09-12 19:52:47 +00:00
|
|
|
else sc->addceilingz(-Sgn(actor->spr.pos.Z - actor->temp_pos.Z) * targetval);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-12 18:39:17 +00:00
|
|
|
void handle_se35(DDukeActor *actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-03 15:43:39 +00:00
|
|
|
if (sc->ceilingz > actor->spr.pos.Z)
|
2020-05-10 07:08:02 +00:00
|
|
|
for (int j = 0; j < 8; j++)
|
|
|
|
{
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.Angles.Yaw = randomAngle(90);
|
2022-12-29 08:56:14 +00:00
|
|
|
auto spawned = spawn(actor, DukeSmallSmokeClass);
|
2021-11-19 11:32:12 +00:00
|
|
|
if (spawned)
|
|
|
|
{
|
2022-09-11 21:31:20 +00:00
|
|
|
spawned->vel.X = 6 + krandf(8);
|
2021-11-19 11:32:12 +00:00
|
|
|
ssp(spawned, CLIPMASK0);
|
2022-08-22 16:34:01 +00:00
|
|
|
SetActor(spawned, spawned->spr.pos);
|
2021-11-19 11:32:12 +00:00
|
|
|
if (rnd(16))
|
2022-12-29 08:56:14 +00:00
|
|
|
spawn(actor, DukeExplosion2Class);
|
2021-11-19 11:32:12 +00:00
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 21:31:20 +00:00
|
|
|
|
|
|
|
double targetval = actor->spr.yint * zmaptoworld;
|
2022-12-22 08:49:42 +00:00
|
|
|
switch (actor->counter)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2022-09-11 21:31:20 +00:00
|
|
|
sc->addceilingz(targetval);
|
2022-08-20 18:11:01 +00:00
|
|
|
if (sc->ceilingz > sc->floorz)
|
2022-08-28 19:05:45 +00:00
|
|
|
sc->setfloorz(sc->ceilingz);
|
2022-08-20 18:11:01 +00:00
|
|
|
if (sc->ceilingz > actor->spr.pos.Z + 32)
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter++;
|
2020-05-10 07:08:02 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2022-09-11 21:31:20 +00:00
|
|
|
sc->addceilingz(-targetval * 4);
|
2022-09-12 21:39:14 +00:00
|
|
|
if (sc->ceilingz < actor->temp_pos.Y)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-09-12 21:39:14 +00:00
|
|
|
sc->setceilingz(actor->temp_pos.Y);
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-29 09:56:10 +00:00
|
|
|
void handle_se36(DDukeActor* actor)
|
|
|
|
{
|
|
|
|
if (actor->counter)
|
|
|
|
{
|
|
|
|
if (actor->counter == 1)
|
|
|
|
shoot(actor, GetSpawnType(actor->sector()->extra));
|
|
|
|
else if (actor->counter == 26 * 5)
|
|
|
|
actor->counter = 0;
|
|
|
|
actor->counter++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:40:57 +00:00
|
|
|
void handle_se128(DDukeActor *actor)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-15 22:32:41 +00:00
|
|
|
auto wal = actor->temp_walls[0];
|
|
|
|
if (!wal) return; // E4L1 contains an uninitialized SE128 which would crash without this.
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-11-15 22:32:41 +00:00
|
|
|
//if (wal->cstat | 32) // this has always been bugged, the condition can never be false.
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-18 14:16:31 +00:00
|
|
|
wal->cstat &= ~CSTAT_WALL_1WAY;
|
|
|
|
wal->cstat |= CSTAT_WALL_MASKED;
|
2021-11-21 07:42:36 +00:00
|
|
|
if (wal->twoSided())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-18 14:16:31 +00:00
|
|
|
wal->nextWall()->cstat &= ~CSTAT_WALL_1WAY;
|
|
|
|
wal->nextWall()->cstat |= CSTAT_WALL_MASKED;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-08 17:21:29 +00:00
|
|
|
// else return;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-10 18:03:17 +00:00
|
|
|
auto data = breakWallMap.CheckKey(wal->overtexture.GetIndex());
|
2022-12-08 21:49:02 +00:00
|
|
|
FTextureID newtex = data? data->brokentex : FNullTextureID();
|
|
|
|
wal->setovertexture(newtex);
|
2021-11-15 22:32:41 +00:00
|
|
|
auto nextwal = wal->nextWall();
|
|
|
|
if (nextwal)
|
2022-12-08 21:49:02 +00:00
|
|
|
nextwal->setovertexture(newtex);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter < actor->temp_data[1]) actor->counter++;
|
2020-05-10 07:08:02 +00:00
|
|
|
else
|
|
|
|
{
|
2021-12-18 14:16:31 +00:00
|
|
|
wal->cstat &= (CSTAT_WALL_TRANSLUCENT | CSTAT_WALL_1WAY | CSTAT_WALL_XFLIP | CSTAT_WALL_ALIGN_BOTTOM | CSTAT_WALL_BOTTOM_SWAP);
|
2021-11-15 22:32:41 +00:00
|
|
|
if (nextwal)
|
2021-12-18 14:16:31 +00:00
|
|
|
nextwal->cstat &= (CSTAT_WALL_TRANSLUCENT | CSTAT_WALL_1WAY | CSTAT_WALL_XFLIP | CSTAT_WALL_ALIGN_BOTTOM | CSTAT_WALL_BOTTOM_SWAP);
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-12 18:39:17 +00:00
|
|
|
void handle_se130(DDukeActor *actor, int countmax)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter > countmax)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2022-11-20 18:25:23 +00:00
|
|
|
actor->Destroy();
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-12-22 08:49:42 +00:00
|
|
|
else actor->counter++;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2022-09-03 15:43:39 +00:00
|
|
|
double x = sc->floorz - sc->ceilingz;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (rnd(64))
|
|
|
|
{
|
2022-12-29 08:56:14 +00:00
|
|
|
auto k = spawn(actor, DukeExplosion2Class);
|
2021-11-19 11:32:12 +00:00
|
|
|
if (k)
|
|
|
|
{
|
2022-10-05 22:08:51 +00:00
|
|
|
double s = 0.03125 + (krand() & 7) * REPEAT_SCALE;
|
2022-10-07 21:52:29 +00:00
|
|
|
k->spr.scale = DVector2(s, s);
|
2022-09-03 15:43:39 +00:00
|
|
|
k->spr.pos.Z = sc->floorz + krandf(x);
|
2022-11-25 12:13:50 +00:00
|
|
|
k->spr.Angles.Yaw += DAngle45 - randomAngle(90);
|
2022-09-13 17:55:54 +00:00
|
|
|
k->vel.X = krandf(8);
|
2021-11-19 11:32:12 +00:00
|
|
|
ssp(k, CLIPMASK0);
|
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-13 22:04:14 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2022-09-11 21:51:48 +00:00
|
|
|
|
|
|
|
void handle_se29(DDukeActor* actor)
|
|
|
|
{
|
|
|
|
auto sc = actor->sector();
|
|
|
|
actor->spr.hitag += 64;
|
|
|
|
double val = actor->spr.yint * BobVal(actor->spr.hitag) / 64.;
|
|
|
|
sc->setfloorz(actor->spr.pos.Z + val);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2020-10-21 23:04:13 +00:00
|
|
|
void handle_se31(DDukeActor* actor, bool choosedir)
|
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sec = actor->sector();
|
2020-10-21 23:04:13 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (actor->counter == 1)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
|
|
|
// Choose dir
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (choosedir && actor->temp_data[3] > 0)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[3]--;
|
2020-10-21 23:04:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[2] == 1) // Retract
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2022-09-09 17:30:18 +00:00
|
|
|
if (actor->spr.intangle != 1536)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2022-09-09 17:30:18 +00:00
|
|
|
if (abs(sec->floorz- actor->spr.pos.Z) < actor->temp_pos.Z)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2022-02-07 07:59:20 +00:00
|
|
|
sec->setfloorz(actor->spr.pos.Z);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] = 0;
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2021-12-23 15:03:43 +00:00
|
|
|
if (choosedir) actor->temp_data[3] = actor->spr.hitag;
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2020-10-21 23:04:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-09 17:30:18 +00:00
|
|
|
double l = Sgn(actor->spr.pos.Z - sec->floorz) * actor->temp_pos.Z;
|
|
|
|
sec->addfloorz(l);
|
2020-10-21 23:04:13 +00:00
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 23:04:13 +00:00
|
|
|
while (auto a2 = it.Next())
|
|
|
|
{
|
2021-12-31 17:47:00 +00:00
|
|
|
if (a2->isPlayer() && a2->GetOwner())
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(a2->PlayerIndex())->on_ground == 1)
|
|
|
|
getPlayer(a2->PlayerIndex())->GetActor()->spr.pos.Z += l;
|
2022-09-03 08:03:30 +00:00
|
|
|
if (a2->vel.Z == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2022-11-16 00:07:10 +00:00
|
|
|
if (!a2->isPlayer()) a2->spr.pos.Z += l;
|
2022-02-03 23:44:13 +00:00
|
|
|
a2->floorz = sec->floorz;
|
2020-10-21 23:04:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-09 17:30:18 +00:00
|
|
|
if (abs(sec->floorz - actor->temp_pos.Y) < actor->temp_pos.Z)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2022-10-09 07:31:51 +00:00
|
|
|
sec->setfloorz(actor->temp_pos.Y);
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] = 0;
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2021-12-23 15:03:43 +00:00
|
|
|
if (choosedir) actor->temp_data[3] = actor->spr.hitag;
|
2020-10-21 23:04:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-09 17:30:18 +00:00
|
|
|
double l = Sgn(actor->temp_pos.Y - sec->floorz) * actor->temp_pos.Z;
|
|
|
|
sec->addfloorz(l);
|
2020-10-21 23:04:13 +00:00
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 23:04:13 +00:00
|
|
|
while (auto a2 = it.Next())
|
|
|
|
{
|
2021-12-31 17:47:00 +00:00
|
|
|
if (a2->isPlayer() && a2->GetOwner())
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(a2->PlayerIndex())->on_ground == 1)
|
|
|
|
getPlayer(a2->PlayerIndex())->GetActor()->spr.pos.Z += l;
|
2022-09-03 08:03:30 +00:00
|
|
|
if (a2->vel.Z == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2022-11-16 00:07:10 +00:00
|
|
|
if (!a2->isPlayer()) a2->spr.pos.Z += l;
|
2022-02-03 23:44:13 +00:00
|
|
|
a2->floorz = sec->floorz;
|
2020-10-21 23:04:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-09-09 17:30:18 +00:00
|
|
|
if ((actor->spr.intangle & 2047) == 1536)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2022-09-09 17:30:18 +00:00
|
|
|
if (abs(actor->spr.pos.Z - sec->floorz) < actor->temp_pos.Z)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] = 1;
|
|
|
|
if (choosedir) actor->temp_data[3] = actor->spr.hitag;
|
2020-10-21 23:04:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-09 17:30:18 +00:00
|
|
|
double l = Sgn(actor->spr.pos.Z - sec->floorz) * actor->temp_pos.Z;
|
|
|
|
sec->addfloorz(l);
|
2020-10-21 23:04:13 +00:00
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 23:04:13 +00:00
|
|
|
while (auto a2 = it.Next())
|
|
|
|
{
|
2021-12-31 17:47:00 +00:00
|
|
|
if (a2->isPlayer() && a2->GetOwner())
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(a2->PlayerIndex())->on_ground == 1)
|
|
|
|
getPlayer(a2->PlayerIndex())->GetActor()->spr.pos.Z += l;
|
2022-09-03 08:03:30 +00:00
|
|
|
if (a2->vel.Z == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2022-11-16 00:07:10 +00:00
|
|
|
if (!a2->isPlayer()) a2->spr.pos.Z += l;
|
2022-02-03 23:44:13 +00:00
|
|
|
a2->floorz = sec->floorz;
|
2020-10-21 23:04:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-09 17:30:18 +00:00
|
|
|
if (abs(sec->floorz - actor->temp_pos.Y) < actor->temp_pos.Z)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
actor->counter = 0;
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] = 1;
|
|
|
|
actor->temp_data[3] = actor->spr.hitag;
|
2020-10-21 23:04:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-09 17:30:18 +00:00
|
|
|
double l = Sgn(actor->spr.pos.Z - actor->temp_pos.Y) * actor->temp_pos.Z;
|
|
|
|
sec->addfloorz(-l);
|
2020-10-21 23:04:13 +00:00
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 23:04:13 +00:00
|
|
|
while (auto a2 = it.Next())
|
|
|
|
{
|
2021-12-31 17:47:00 +00:00
|
|
|
if (a2->isPlayer() && a2->GetOwner())
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(a2->PlayerIndex())->on_ground == 1)
|
|
|
|
getPlayer(a2->PlayerIndex())->GetActor()->spr.pos.Z -= l;
|
2022-09-03 08:03:30 +00:00
|
|
|
if (a2->vel.Z == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2022-11-16 00:07:10 +00:00
|
|
|
if (!a2->isPlayer()) a2->spr.pos.Z -= l;
|
2022-02-03 23:44:13 +00:00
|
|
|
a2->floorz = sec->floorz;
|
2020-10-21 23:04:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 23:10:56 +00:00
|
|
|
void getglobalz(DDukeActor* actor)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-09-29 17:52:01 +00:00
|
|
|
double zr;
|
2020-10-21 23:10:56 +00:00
|
|
|
Collision hz, lz;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if( actor->spr.statnum == STAT_PLAYER || actor->spr.statnum == STAT_STANDABLE || actor->spr.statnum == STAT_ZOMBIEACTOR || actor->spr.statnum == STAT_ACTOR || actor->spr.statnum == STAT_PROJECTILE)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if(actor->spr.statnum == STAT_PROJECTILE)
|
2022-09-29 17:52:01 +00:00
|
|
|
zr = 0.25;
|
|
|
|
else zr = 7.9375;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
auto cc = actor->spr.cstat2;
|
|
|
|
actor->spr.cstat2 |= CSTAT2_SPRITE_NOFIND; // don't clip against self. getzrange cannot detect this because it only receives a coordinate.
|
2022-10-03 21:31:02 +00:00
|
|
|
getzrange(actor->spr.pos.plusZ(-1), actor->sector(), &actor->ceilingz, hz, &actor->floorz, lz, zr, CLIPMASK0);
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.cstat2 = cc;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2022-01-12 23:42:34 +00:00
|
|
|
actor->spr.cstat2 &= ~CSTAT2_SPRITE_NOSHADOW;
|
2021-12-21 17:19:45 +00:00
|
|
|
if( lz.type == kHitSprite && (lz.actor()->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0 )
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if( badguy(lz.actor()) && lz.actor()->spr.pal != 1)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if( actor->spr.statnum != STAT_PROJECTILE)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-01-12 23:42:34 +00:00
|
|
|
actor->spr.cstat2 |= CSTAT2_SPRITE_NOSHADOW; // No shadows on actors
|
2022-09-03 08:05:20 +00:00
|
|
|
actor->vel.X = -16;
|
2020-10-21 23:10:56 +00:00
|
|
|
ssp(actor, CLIPMASK0);
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-31 17:47:00 +00:00
|
|
|
else if(lz.actor()->isPlayer() && badguy(actor) )
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-01-12 23:42:34 +00:00
|
|
|
actor->spr.cstat2 |= CSTAT2_SPRITE_NOSHADOW; // No shadows on actors
|
2022-09-03 08:05:20 +00:00
|
|
|
actor->vel.X = -16;
|
2020-10-21 23:10:56 +00:00
|
|
|
ssp(actor, CLIPMASK0);
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
2021-12-31 17:47:00 +00:00
|
|
|
else if(actor->spr.statnum == STAT_PROJECTILE && lz.actor()->isPlayer() && actor->GetOwner() == actor)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-02-03 23:44:13 +00:00
|
|
|
actor->ceilingz = actor->sector()->ceilingz;
|
|
|
|
actor->floorz = actor->sector()->floorz;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-03 23:44:13 +00:00
|
|
|
actor->ceilingz = actor->sector()->ceilingz;
|
|
|
|
actor->floorz = actor->sector()->floorz;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 23:11:38 +00:00
|
|
|
void makeitfall(DDukeActor* actor)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-12-20 21:25:48 +00:00
|
|
|
if (actor->flags3 & SFLAG3_NOGRAVITY) return;
|
2022-12-19 17:45:27 +00:00
|
|
|
|
2022-09-11 22:34:18 +00:00
|
|
|
double grav;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2022-11-25 16:43:13 +00:00
|
|
|
if( floorspace(actor->sector()) )
|
2022-09-11 22:34:18 +00:00
|
|
|
grav = 0;
|
2020-05-13 22:04:14 +00:00
|
|
|
else
|
|
|
|
{
|
2022-12-30 15:54:04 +00:00
|
|
|
if (ceilingspace(actor->sector()) || actor->sector()->lotag == ST_2_UNDERWATER)
|
|
|
|
grav = gs.gravity / 6;
|
|
|
|
else grav = gs.gravity * actor->FloatVar(NAME_gravityfactor);
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if ((actor->spr.statnum == STAT_ACTOR || actor->spr.statnum == STAT_PLAYER || actor->spr.statnum == STAT_ZOMBIEACTOR || actor->spr.statnum == STAT_STANDABLE))
|
2020-10-21 23:11:38 +00:00
|
|
|
{
|
2021-12-24 09:53:27 +00:00
|
|
|
Collision coll;
|
2022-09-29 17:52:01 +00:00
|
|
|
getzrange(actor->spr.pos.plusZ(-1), actor->sector(), &actor->ceilingz, coll, &actor->floorz, coll, 7.9375, CLIPMASK0);
|
2020-10-21 23:11:38 +00:00
|
|
|
}
|
2020-05-13 22:04:14 +00:00
|
|
|
else
|
|
|
|
{
|
2022-02-03 23:44:13 +00:00
|
|
|
actor->ceilingz = actor->sector()->ceilingz;
|
|
|
|
actor->floorz = actor->sector()->floorz;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
|
2022-02-03 23:45:24 +00:00
|
|
|
if( actor->spr.pos.Z < actor->floorz - FOURSLEIGHT_F)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-12-19 17:45:27 +00:00
|
|
|
if( actor->sector()->lotag == ST_2_UNDERWATER && actor->vel.Z > 3122/256.)
|
2022-09-11 17:28:45 +00:00
|
|
|
actor->vel.Z = 3144 / 256.;
|
|
|
|
if (actor->vel.Z < 24)
|
2022-09-11 22:34:18 +00:00
|
|
|
actor->vel.Z += grav;
|
2022-09-11 17:28:45 +00:00
|
|
|
else actor->vel.Z = 24;
|
2022-09-03 08:03:30 +00:00
|
|
|
actor->spr.pos.Z += actor->vel.Z;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
2022-02-03 23:45:24 +00:00
|
|
|
if (actor->spr.pos.Z >= actor->floorz - FOURSLEIGHT_F)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-02-03 23:45:24 +00:00
|
|
|
actor->spr.pos.Z = actor->floorz - FOURSLEIGHT_F;
|
2022-09-03 08:02:25 +00:00
|
|
|
actor->vel.Z = 0;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 23:12:16 +00:00
|
|
|
int dodge(DDukeActor* actor)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-09-12 20:06:43 +00:00
|
|
|
auto oldpos = actor->spr.pos.XY();
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2020-10-21 23:12:16 +00:00
|
|
|
DukeStatIterator it(STAT_PROJECTILE);
|
|
|
|
while (auto ac = it.Next())
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if (ac->GetOwner() == ac || ac->sector() != actor->sector())
|
2020-05-13 22:04:14 +00:00
|
|
|
continue;
|
|
|
|
|
2022-09-12 20:06:43 +00:00
|
|
|
auto delta = ac->spr.pos.XY() - oldpos;
|
2022-11-25 12:13:50 +00:00
|
|
|
auto bvect = ac->spr.Angles.Yaw.ToVector() * 1024;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2022-11-25 12:13:50 +00:00
|
|
|
if (actor->spr.Angles.Yaw.ToVector().dot(delta) >= 0)
|
2022-09-12 20:06:43 +00:00
|
|
|
{
|
|
|
|
if (bvect.dot(delta) < 0)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-09-12 20:06:43 +00:00
|
|
|
double d = bvect.X * delta.Y - bvect.Y * delta.X;
|
|
|
|
if (abs(d) < 256 * 64)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.Angles.Yaw -= DAngle90 + randomAngle(180);
|
2020-05-13 22:04:14 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2022-09-12 20:06:43 +00:00
|
|
|
}
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-09-12 20:37:08 +00:00
|
|
|
DAngle furthestangle(DDukeActor *actor, int angs)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-09-12 20:40:55 +00:00
|
|
|
double d, greatestd;
|
|
|
|
DAngle furthest_angle = DAngle360;
|
2021-12-06 11:24:22 +00:00
|
|
|
HitInfo hit{};
|
2020-05-13 22:04:14 +00:00
|
|
|
|
|
|
|
greatestd = -(1 << 30);
|
2022-09-12 20:40:55 +00:00
|
|
|
DAngle angincs = DAngle360 / angs;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-12-31 17:47:00 +00:00
|
|
|
if (!actor->isPlayer())
|
2022-12-22 08:49:42 +00:00
|
|
|
if ((actor->counter & 63) > 2) return(actor->spr.Angles.Yaw + DAngle180);
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2022-11-25 12:13:50 +00:00
|
|
|
for (DAngle j = actor->spr.Angles.Yaw; j < DAngle360 + actor->spr.Angles.Yaw; j += angincs)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-09-12 20:40:55 +00:00
|
|
|
hitscan(actor->spr.pos.plusZ(-8), actor->sector(), DVector3(j.ToVector() * 1024, 0), hit, CLIPMASK1);
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2022-09-12 22:46:38 +00:00
|
|
|
d = (hit.hitpos.XY() - actor->spr.pos.XY()).Sum();
|
2020-05-13 22:04:14 +00:00
|
|
|
|
|
|
|
if (d > greatestd)
|
|
|
|
{
|
|
|
|
greatestd = d;
|
|
|
|
furthest_angle = j;
|
|
|
|
}
|
|
|
|
}
|
2022-09-12 20:40:55 +00:00
|
|
|
return furthest_angle.Normalized360();
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2021-11-17 23:07:38 +00:00
|
|
|
// return value was changed to what its only caller really expects
|
2020-05-13 22:04:14 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-09-12 20:58:52 +00:00
|
|
|
int furthestcanseepoint(DDukeActor *actor, DDukeActor* tosee, DVector2& pos)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-09-14 21:40:51 +00:00
|
|
|
DAngle angincs;
|
2021-12-06 11:24:22 +00:00
|
|
|
HitInfo hit{};
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if ((actor->counter & 63)) return -1;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
|
|
|
if (ud.multimode < 2 && ud.player_skill < 3)
|
2022-09-14 21:40:51 +00:00
|
|
|
angincs = DAngle180;
|
|
|
|
else angincs = DAngle360 / (1 + (krand() & 1));
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2022-11-25 12:13:50 +00:00
|
|
|
for (auto j = tosee->spr.Angles.Yaw; j < tosee->spr.Angles.Yaw + DAngle360; j += (angincs - randomAngle(90)))
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-09-14 21:40:51 +00:00
|
|
|
hitscan(tosee->spr.pos.plusZ(-16), tosee->sector(), DVector3(j.ToVector() * 1024, 64 - krandf(128)), hit, CLIPMASK1);
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2022-09-12 22:46:38 +00:00
|
|
|
double d = (hit.hitpos.XY() - tosee->spr.pos.XY()).Sum();
|
|
|
|
double da = (hit.hitpos.XY() - actor->spr.pos.XY()).Sum();
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-11-25 23:08:59 +00:00
|
|
|
if (d < da && hit.hitSector)
|
2022-08-20 16:34:00 +00:00
|
|
|
if (cansee(hit.hitpos, hit.hitSector, actor->spr.pos.plusZ(-16), actor->sector()))
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-09-12 20:58:52 +00:00
|
|
|
pos = hit.hitpos.XY();
|
2021-11-17 23:07:38 +00:00
|
|
|
return 1;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-17 23:07:38 +00:00
|
|
|
return 0;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-11-01 09:45:09 +00:00
|
|
|
void alterang(int ang, DDukeActor* actor, int playernum)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-09-12 20:37:08 +00:00
|
|
|
DAngle goalang, aang, angdif;
|
|
|
|
int j;
|
2020-05-13 22:04:14 +00:00
|
|
|
int ticselapsed;
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
auto moveptr = &ScriptCode[actor->temp_data[1]];
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
ticselapsed = (actor->counter) & 31;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2022-11-25 12:13:50 +00:00
|
|
|
aang = actor->spr.Angles.Yaw;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2022-12-21 12:32:00 +00:00
|
|
|
actor->vel.X += (actor->curMove->movex - actor->vel.X) / 5;
|
2022-09-11 20:57:56 +00:00
|
|
|
if (actor->vel.Z < (648 / 256.))
|
|
|
|
{
|
2022-12-21 12:32:00 +00:00
|
|
|
actor->vel.Z += (actor->curMove->movez - actor->vel.Z) / 5;
|
2022-09-11 20:57:56 +00:00
|
|
|
}
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2020-10-22 14:40:48 +00:00
|
|
|
if (isRRRA() && (ang & windang))
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.Angles.Yaw = WindDir;
|
2020-10-22 14:40:48 +00:00
|
|
|
else if (ang & seekplayer)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2023-10-02 02:51:13 +00:00
|
|
|
DDukeActor* holoduke = !isRR()? getPlayer(playernum)->holoduke_on.Get() : nullptr;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2020-11-02 21:26:32 +00:00
|
|
|
// NOTE: looks like 'Owner' is set to target sprite ID...
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2022-02-06 21:45:47 +00:00
|
|
|
if (holoduke && cansee(holoduke->spr.pos, holoduke->sector(), actor->spr.pos, actor->sector()))
|
2020-10-22 14:40:48 +00:00
|
|
|
actor->SetOwner(holoduke);
|
2023-10-02 02:51:13 +00:00
|
|
|
else actor->SetOwner(getPlayer(playernum)->GetActor());
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2020-10-22 14:40:48 +00:00
|
|
|
auto Owner = actor->GetOwner();
|
2021-12-31 17:47:00 +00:00
|
|
|
if (Owner->isPlayer())
|
2022-09-30 11:38:21 +00:00
|
|
|
goalang = (actor->ovel - actor->spr.pos.XY()).Angle();
|
2020-05-13 22:04:14 +00:00
|
|
|
else
|
2022-09-30 11:38:21 +00:00
|
|
|
goalang = (Owner->spr.pos.XY() - actor->spr.pos.XY()).Angle();
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2022-12-29 21:48:43 +00:00
|
|
|
if (actor->vel.X != 0 && !(actor->flags3 & SFLAG3_QUICKALTERANG))
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2022-11-24 11:03:47 +00:00
|
|
|
angdif = deltaangle(aang, goalang);
|
2020-05-13 22:04:14 +00:00
|
|
|
|
|
|
|
if (ticselapsed < 2)
|
|
|
|
{
|
2023-01-06 10:39:55 +00:00
|
|
|
if (abs(angdif) < DAngle45)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2023-01-06 10:39:55 +00:00
|
|
|
DAngle add = DAngle22_5 - randomAngle(DAngle45);
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.Angles.Yaw += add;
|
2023-01-06 10:39:55 +00:00
|
|
|
if (hits(actor) < 52.75)
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.Angles.Yaw -= add;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ticselapsed > 18 && ticselapsed < 26) // choose
|
|
|
|
{
|
2023-01-06 10:39:55 +00:00
|
|
|
if (abs(angdif) < DAngle90) actor->spr.Angles.Yaw = goalang;
|
2022-11-25 12:13:50 +00:00
|
|
|
else actor->spr.Angles.Yaw += angdif * 0.25;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-25 12:13:50 +00:00
|
|
|
else actor->spr.Angles.Yaw = goalang;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ticselapsed < 1)
|
|
|
|
{
|
|
|
|
j = 2;
|
2020-10-22 14:40:48 +00:00
|
|
|
if (ang & furthestdir)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2020-10-22 14:40:48 +00:00
|
|
|
goalang = furthestangle(actor, j);
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.Angles.Yaw = goalang;
|
2023-10-02 02:51:13 +00:00
|
|
|
actor->SetOwner(getPlayer(playernum)->GetActor());
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
|
2020-10-22 14:40:48 +00:00
|
|
|
if (ang & fleeenemy)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2020-10-22 14:40:48 +00:00
|
|
|
goalang = furthestangle(actor, j);
|
2022-11-25 12:13:50 +00:00
|
|
|
actor->spr.Angles.Yaw = goalang;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-30 13:28:59 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// special checks for RR's extended sector types, now available everywhere
|
2023-04-30 06:57:28 +00:00
|
|
|
//
|
|
|
|
// note that we cannot kill stuff in here, we have to defer this until the
|
|
|
|
// end of the Tick() function.
|
2022-12-30 13:28:59 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static int fallspecial(DDukeActor* actor, int playernum)
|
|
|
|
{
|
|
|
|
int sphit = 0;
|
|
|
|
if (ud.mapflags & MFLAG_ALLSECTORTYPES)
|
|
|
|
{
|
|
|
|
if (actor->sector()->lotag == ST_801_ROCKY)
|
|
|
|
{
|
|
|
|
if (actor->GetClass() == RedneckRockClass)
|
|
|
|
{
|
|
|
|
spawn(actor, RedneckRock2Class);
|
|
|
|
spawn(actor, RedneckRock2Class);
|
2023-04-30 06:57:28 +00:00
|
|
|
actor->flags2 |= SFLAG2_DIENOW;
|
2022-12-30 13:28:59 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (actor->sector()->lotag == ST_802_KILLBADGUYS)
|
|
|
|
{
|
|
|
|
if (!actor->isPlayer() && badguy(actor) && actor->spr.pos.Z == actor->floorz - FOURSLEIGHT_F)
|
|
|
|
{
|
|
|
|
spawnguts(actor, DukeJibs6Class, 5);
|
|
|
|
S_PlayActorSound(SQUISHED, actor);
|
2023-04-30 06:57:28 +00:00
|
|
|
actor->flags2 |= SFLAG2_DIENOW;
|
2022-12-30 13:28:59 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (actor->sector()->lotag == ST_803_KILLROCKS)
|
|
|
|
{
|
|
|
|
if (actor->GetClass() == RedneckRock2Class)
|
2023-04-30 06:57:28 +00:00
|
|
|
actor->flags2 |= SFLAG2_DIENOW;
|
2022-12-30 13:28:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ud.mapflags & (MFLAG_ALLSECTORTYPES | MFLAG_SECTORTYPE800))
|
|
|
|
{
|
|
|
|
if (actor->sector()->lotag == ST_800_KILLSTUFF)
|
|
|
|
{
|
|
|
|
if (!actor->isPlayer() && badguy(actor) && actor->spriteextra < 128)
|
|
|
|
{
|
|
|
|
actor->spr.pos.Z = actor->floorz - FOURSLEIGHT_F;
|
|
|
|
actor->vel.Z = 8000 / 256.;
|
|
|
|
actor->spr.extra = 0;
|
|
|
|
actor->spriteextra++;
|
|
|
|
sphit = 1;
|
|
|
|
}
|
|
|
|
else if (!actor->isPlayer())
|
|
|
|
{
|
|
|
|
if (!actor->spriteextra)
|
2023-04-30 06:57:28 +00:00
|
|
|
actor->flags2 |= SFLAG2_DIENOW;
|
2022-12-30 13:28:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
actor->attackertype = DukeShotSparkClass;
|
|
|
|
actor->hitextra = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tilesurface(actor->sector()->floortexture) == TSURF_MAGMA)
|
|
|
|
{
|
|
|
|
if (!(actor->flags3 & SFLAG3_MAGMAIMMUNE) && actor->spr.pal != 19)
|
|
|
|
{
|
|
|
|
if ((krand() & 3) == 1)
|
|
|
|
{
|
|
|
|
actor->attackertype = DukeShotSparkClass;
|
|
|
|
actor->hitextra = 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sphit;
|
|
|
|
}
|
|
|
|
|
2020-05-14 07:07:07 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// the indirections here are to keep this core function free of game references
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-30 13:28:59 +00:00
|
|
|
void fall(DDukeActor *actor, int playernum)
|
2020-05-14 07:07:07 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xoffset = 0;
|
|
|
|
actor->spr.yoffset = 0;
|
2022-12-31 07:05:24 +00:00
|
|
|
if (actor->flags3 & SFLAG3_NOGRAVITY) return;
|
2020-05-14 07:07:07 +00:00
|
|
|
// if(!gotz)
|
|
|
|
{
|
2022-09-11 22:34:18 +00:00
|
|
|
double grav;
|
2020-05-14 07:07:07 +00:00
|
|
|
|
2022-12-30 13:28:59 +00:00
|
|
|
int sphit = fallspecial(actor, playernum);
|
2022-11-25 16:43:13 +00:00
|
|
|
if (floorspace(actor->sector()))
|
2022-09-11 22:34:18 +00:00
|
|
|
grav = 0;
|
2020-05-14 07:07:07 +00:00
|
|
|
else
|
|
|
|
{
|
2022-11-25 16:43:13 +00:00
|
|
|
if (ceilingspace(actor->sector()) || actor->sector()->lotag == 2)
|
2022-09-11 22:34:18 +00:00
|
|
|
grav = gs.gravity / 6;
|
|
|
|
else grav = gs.gravity;
|
2020-05-14 07:07:07 +00:00
|
|
|
}
|
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
if (actor->cgg <= 0 || (actor->sector()->floorstat & CSTAT_SECTOR_SLOPE))
|
2020-05-14 07:07:07 +00:00
|
|
|
{
|
2020-10-22 16:51:20 +00:00
|
|
|
getglobalz(actor);
|
|
|
|
actor->cgg = 6;
|
2020-05-14 07:07:07 +00:00
|
|
|
}
|
2020-10-22 16:51:20 +00:00
|
|
|
else actor->cgg--;
|
2020-05-14 07:07:07 +00:00
|
|
|
|
2022-02-03 23:45:24 +00:00
|
|
|
if (actor->spr.pos.Z < actor->floorz - FOURSLEIGHT_F)
|
2020-05-14 07:07:07 +00:00
|
|
|
{
|
2022-09-11 22:34:18 +00:00
|
|
|
actor->vel.Z += grav;
|
2022-09-03 08:03:30 +00:00
|
|
|
actor->spr.pos.Z += actor->vel.Z;
|
2020-05-14 07:07:07 +00:00
|
|
|
|
2022-09-11 17:28:45 +00:00
|
|
|
if (actor->vel.Z > 24) actor->vel.Z = 24;
|
2020-05-14 07:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-03 23:55:12 +00:00
|
|
|
actor->spr.pos.Z = actor->floorz - FOURSLEIGHT_F;
|
2020-05-14 07:07:07 +00:00
|
|
|
|
2021-12-31 17:47:00 +00:00
|
|
|
if (badguy(actor) || (actor->isPlayer() && actor->GetOwner()))
|
2020-05-14 07:07:07 +00:00
|
|
|
{
|
|
|
|
|
2022-09-03 08:03:30 +00:00
|
|
|
if (actor->vel.Z > (3084/256.) && actor->spr.extra <= 1)
|
2020-05-14 07:07:07 +00:00
|
|
|
{
|
2022-12-29 22:03:29 +00:00
|
|
|
if (actor->spr.pal != 1 && !(actor->flags3 & SFLAG3_NOJIBS))
|
2020-05-14 07:07:07 +00:00
|
|
|
{
|
2021-12-31 17:47:00 +00:00
|
|
|
if (actor->isPlayer() && actor->spr.extra > 0)
|
2020-05-14 07:07:07 +00:00
|
|
|
goto SKIPJIBS;
|
|
|
|
if (sphit)
|
|
|
|
{
|
2022-12-29 08:56:14 +00:00
|
|
|
spawnguts(actor, DukeJibs6Class, 5);
|
2022-12-21 07:40:51 +00:00
|
|
|
S_PlayActorSound(SQUISHED, actor);
|
2020-05-14 07:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-29 08:56:14 +00:00
|
|
|
spawnguts(actor, DukeJibs6Class, 15);
|
2022-12-21 07:40:51 +00:00
|
|
|
S_PlayActorSound(SQUISHED, actor);
|
2022-12-29 08:56:14 +00:00
|
|
|
spawn(actor, DukeBloodPoolClass);
|
2020-05-14 07:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SKIPJIBS:
|
|
|
|
|
2022-12-29 08:56:14 +00:00
|
|
|
actor->attackertype = DukeShotSparkClass;
|
2022-01-23 23:10:25 +00:00
|
|
|
actor->hitextra = 1;
|
2022-09-03 08:02:25 +00:00
|
|
|
actor->vel.Z = 0;
|
2020-05-14 07:07:07 +00:00
|
|
|
}
|
2022-09-03 08:03:30 +00:00
|
|
|
else if (actor->vel.Z > 8 && actor->sector()->lotag != 1)
|
2020-05-14 07:07:07 +00:00
|
|
|
{
|
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sect = actor->sector();
|
2022-10-08 08:51:23 +00:00
|
|
|
pushmove(actor->spr.pos, §, 8., 4., 4., CLIPMASK0);
|
2021-12-30 15:51:56 +00:00
|
|
|
if (sect != actor->sector() && sect != nullptr)
|
2021-11-26 20:52:01 +00:00
|
|
|
ChangeActorSect(actor, sect);
|
2020-05-14 07:07:07 +00:00
|
|
|
|
2022-12-21 07:40:51 +00:00
|
|
|
S_PlayActorSound(THUD, actor);
|
2020-05-14 07:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-30 15:51:56 +00:00
|
|
|
if (actor->sector()->lotag == 1)
|
2022-12-21 15:31:51 +00:00
|
|
|
actor->spr.pos.Z += actor->IntVar(NAME_falladjustz);
|
2022-09-03 08:02:25 +00:00
|
|
|
else actor->vel.Z = 0;
|
2020-05-14 07:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2020-09-11 20:54:52 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-18 19:51:09 +00:00
|
|
|
DDukeActor *LocateTheLocator(int n, sectortype* sect)
|
2020-06-23 19:12:15 +00:00
|
|
|
{
|
2020-11-01 06:56:49 +00:00
|
|
|
DukeStatIterator it(STAT_LOCATOR);
|
|
|
|
while (auto ac = it.Next())
|
2020-06-23 19:12:15 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if ((sect == nullptr || sect == ac->sector()) && n == ac->spr.lotag)
|
2020-11-01 06:56:49 +00:00
|
|
|
return ac;
|
2020-06-23 19:12:15 +00:00
|
|
|
}
|
2020-11-01 06:56:49 +00:00
|
|
|
return nullptr;
|
2020-06-23 19:12:15 +00:00
|
|
|
}
|
|
|
|
|
2020-09-11 20:54:52 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-01-02 14:44:52 +00:00
|
|
|
|
|
|
|
void movefta(void)
|
|
|
|
{
|
2022-09-14 20:49:01 +00:00
|
|
|
double xx;
|
2022-01-02 14:44:52 +00:00
|
|
|
int canseeme, p;
|
|
|
|
sectortype* psect, * ssect;
|
|
|
|
|
2022-01-09 20:24:38 +00:00
|
|
|
auto check_fta_sounds = [](DDukeActor* act)
|
|
|
|
{
|
2022-12-14 14:28:03 +00:00
|
|
|
if (act->spr.extra > 0)
|
2022-11-30 18:39:06 +00:00
|
|
|
CallPlayFTASound(act);
|
2022-01-09 20:24:38 +00:00
|
|
|
};
|
|
|
|
|
2022-01-02 14:44:52 +00:00
|
|
|
DukeStatIterator it(STAT_ZOMBIEACTOR);
|
|
|
|
while (auto act = it.Next())
|
|
|
|
{
|
2022-09-14 20:49:01 +00:00
|
|
|
p = findplayer(act, &xx);
|
2022-01-02 14:44:52 +00:00
|
|
|
canseeme = 0;
|
|
|
|
|
|
|
|
ssect = psect = act->sector();
|
|
|
|
|
2023-10-02 02:51:13 +00:00
|
|
|
if (getPlayer(p)->GetActor()->spr.extra > 0)
|
2022-01-02 14:44:52 +00:00
|
|
|
{
|
2022-09-14 20:49:01 +00:00
|
|
|
if (xx < 30000 / 16.)
|
2022-01-02 14:44:52 +00:00
|
|
|
{
|
|
|
|
act->timetosleep++;
|
2022-10-03 13:00:52 +00:00
|
|
|
if (act->timetosleep >= int(xx / 16.))
|
2022-01-02 14:44:52 +00:00
|
|
|
{
|
|
|
|
if (badguy(act))
|
|
|
|
{
|
2022-10-06 18:44:52 +00:00
|
|
|
auto xyrand = []() -> double { return (64 - (krand() & 127)) * maptoworld; };
|
2023-10-02 02:51:13 +00:00
|
|
|
double px = getPlayer(p)->GetActor()->opos.X - xyrand();
|
|
|
|
double py = getPlayer(p)->GetActor()->opos.Y - xyrand();
|
2022-02-06 19:02:58 +00:00
|
|
|
updatesector(DVector3(px, py, 0), &psect);
|
2022-01-02 14:44:52 +00:00
|
|
|
if (psect == nullptr)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2022-10-06 18:44:52 +00:00
|
|
|
double sx = act->spr.pos.X - xyrand();
|
|
|
|
double sy = act->spr.pos.Y - xyrand();
|
2022-02-06 19:02:58 +00:00
|
|
|
// The second updatesector call here used px and py again and was redundant as coded.
|
2022-01-02 14:44:52 +00:00
|
|
|
|
2022-12-16 11:47:30 +00:00
|
|
|
// SFLAG_LOOKALLAROUND is set for all actors in Duke.
|
2022-12-20 21:25:48 +00:00
|
|
|
if (act->spr.pal == 33 || (act->flags1 & SFLAG_LOOKALLAROUND) ||
|
|
|
|
((act->flags1 & SFLAG_LOOKALLAROUNDWITHPAL8) && act->spr.pal == 8) ||
|
2022-11-25 12:13:50 +00:00
|
|
|
(act->spr.Angles.Yaw.Cos() * (px - sx) + act->spr.Angles.Yaw.Sin() * (py - sy) >= 0))
|
2022-01-02 14:44:52 +00:00
|
|
|
{
|
2022-02-12 11:37:27 +00:00
|
|
|
double r1 = zrand(32);
|
|
|
|
double r2 = zrand(52);
|
2023-10-02 02:51:13 +00:00
|
|
|
canseeme = cansee({ sx, sy, act->spr.pos.Z - r2 }, act->sector(), { px, py, getPlayer(p)->GetActor()->getPrevOffsetZ() - r1 }, getPlayer(p)->cursector);
|
2022-01-02 14:44:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int r1 = krand();
|
|
|
|
int r2 = krand();
|
2023-10-02 02:51:13 +00:00
|
|
|
canseeme = cansee(act->spr.pos.plusZ(-(r2 & 31)), act->sector(), getPlayer(p)->GetActor()->getPrevPosWithOffsetZ().plusZ(-(r1 & 31)), getPlayer(p)->cursector);
|
2022-01-02 14:44:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (canseeme)
|
|
|
|
{
|
2022-12-20 21:25:48 +00:00
|
|
|
if ((act->flags1 & SFLAG_MOVEFTA_MAKESTANDABLE))
|
2022-01-02 14:44:52 +00:00
|
|
|
{
|
|
|
|
if (act->sector()->ceilingstat & CSTAT_SECTOR_SKY)
|
|
|
|
act->spr.shade = act->sector()->ceilingshade;
|
|
|
|
else act->spr.shade = act->sector()->floorshade;
|
|
|
|
|
|
|
|
act->timetosleep = 0;
|
|
|
|
ChangeActorStat(act, STAT_STANDABLE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
act->timetosleep = 0;
|
2022-01-09 20:24:38 +00:00
|
|
|
check_fta_sounds(act);
|
2022-01-02 14:44:52 +00:00
|
|
|
ChangeActorStat(act, STAT_ACTOR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else act->timetosleep = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (badguy(act))
|
|
|
|
{
|
|
|
|
if (act->sector()->ceilingstat & CSTAT_SECTOR_SKY)
|
|
|
|
act->spr.shade = act->sector()->ceilingshade;
|
|
|
|
else act->spr.shade = act->sector()->floorshade;
|
|
|
|
|
2022-12-16 11:47:30 +00:00
|
|
|
// wakeup is an RR feature, this flag will allow it to use in Duke, too.
|
2022-12-20 21:25:48 +00:00
|
|
|
if ((act->flags1 & SFLAG_MOVEFTA_WAKEUPCHECK))
|
2022-01-02 14:44:52 +00:00
|
|
|
{
|
|
|
|
if (wakeup(act, p))
|
|
|
|
{
|
|
|
|
act->timetosleep = 0;
|
2022-01-09 20:24:38 +00:00
|
|
|
check_fta_sounds(act);
|
2022-01-02 14:44:52 +00:00
|
|
|
ChangeActorStat(act, STAT_ACTOR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-15 20:12:20 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void actorsizeto(DDukeActor* actor, double x, double y)
|
|
|
|
{
|
|
|
|
// JBF 20030805: As I understand it, if repeat becomes 0 it basically kills the
|
|
|
|
// sprite, which is why the "sizeto 0 41" calls in 1.3d became "sizeto 4 41" in
|
|
|
|
// 1.4, so instead of patching the CONs I'll surruptitiously patch the code here
|
|
|
|
//if (!isPlutoPak() && *insptr == 0) *insptr = 4;
|
|
|
|
|
|
|
|
double siz = (x - actor->spr.scale.X);
|
|
|
|
actor->spr.scale.X = (clamp(actor->spr.scale.X + Sgn(siz) * REPEAT_SCALE, 0., 4.));
|
|
|
|
|
|
|
|
auto scale = actor->spr.scale.Y;
|
|
|
|
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
|
|
|
|
if ((actor->isPlayer() && scale < 0.5626) || y < scale || (scale * (tex->GetDisplayHeight() + 8)) < actor->floorz - actor->ceilingz)
|
|
|
|
{
|
|
|
|
siz = (y - actor->spr.scale.Y);
|
|
|
|
actor->spr.scale.Y = (clamp(actor->spr.scale.Y + Sgn(siz) * REPEAT_SCALE, 0., 4.));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void spawndebris(DDukeActor* g_ac, int dnum, int count)
|
|
|
|
{
|
|
|
|
if (dnum < 0 || dnum >= ScrapMax) return; // this code only works with scrap and nothing else.
|
2022-12-29 22:03:29 +00:00
|
|
|
bool weap = (g_ac->flags3 & SFLAG3_SPAWNWEAPONDEBRIS);
|
2022-12-15 20:12:20 +00:00
|
|
|
|
|
|
|
if (g_ac->insector())
|
|
|
|
for (int j = count; j >= 0; j--)
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
if (weap)
|
|
|
|
s = 0;
|
|
|
|
else s = (krand() % 3);
|
|
|
|
DVector3 offs;
|
|
|
|
offs.X = krandf(16) - 8;
|
|
|
|
offs.Y = krandf(16) - 8;
|
|
|
|
offs.Z = -krandf(16) - 8;
|
|
|
|
|
|
|
|
auto a = randomAngle();
|
|
|
|
auto vel = krandf(8) + 2;
|
|
|
|
auto zvel = -krandf(8);
|
|
|
|
DVector2 scale(0.5 + (krand() & 15) * REPEAT_SCALE, 0.5 + (krand() & 15) * REPEAT_SCALE);
|
|
|
|
|
2022-12-29 08:56:14 +00:00
|
|
|
auto spawned = CreateActor(g_ac->sector(), g_ac->spr.pos + offs, DukeScrapClass, g_ac->spr.shade, scale, a, vel, zvel, g_ac, STAT_MISC);
|
2022-12-15 20:12:20 +00:00
|
|
|
if (spawned)
|
|
|
|
{
|
|
|
|
spawned->spriteextra = dnum + s;
|
|
|
|
if (weap)
|
|
|
|
spawned->spr.yint = (j % 15) + 1;
|
|
|
|
else spawned->spr.yint = -1;
|
|
|
|
spawned->spr.pal = g_ac->spr.pal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-06-23 19:12:15 +00:00
|
|
|
|
2022-12-15 20:12:20 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void actoroperate(DDukeActor* g_ac)
|
|
|
|
{
|
2022-12-30 13:05:39 +00:00
|
|
|
if (g_ac->sector()->lotag == ST_0_NO_EFFECT)
|
2022-12-15 20:12:20 +00:00
|
|
|
{
|
|
|
|
HitInfo hit{};
|
|
|
|
neartag(g_ac->spr.pos.plusZ(-32), g_ac->sector(), g_ac->spr.Angles.Yaw, hit, 48, NT_Lotag | NT_NoSpriteCheck);
|
|
|
|
auto sectp = hit.hitSector;
|
|
|
|
if (sectp)
|
|
|
|
{
|
|
|
|
if (isanearoperator(sectp->lotag))
|
|
|
|
if ((sectp->lotag & 0xff) == ST_23_SWINGING_DOOR || sectp->floorz == sectp->ceilingz)
|
|
|
|
if ((sectp->lotag & 16384) == 0 && (sectp->lotag & 32768) == 0)
|
|
|
|
{
|
|
|
|
DukeSectIterator it(sectp);
|
|
|
|
DDukeActor* a2;
|
|
|
|
while ((a2 = it.Next()))
|
|
|
|
{
|
|
|
|
if (isactivator(a2))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (a2 == nullptr)
|
|
|
|
operatesectors(sectp, g_ac);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void garybanjo(DDukeActor* g_ac)
|
|
|
|
{
|
|
|
|
if (banjosound == 0)
|
|
|
|
{
|
|
|
|
int rnum = (krand() & 3) + 1;
|
|
|
|
if (rnum == 4)
|
|
|
|
{
|
|
|
|
banjosound = 262;
|
|
|
|
}
|
|
|
|
else if (rnum == 1)
|
|
|
|
{
|
|
|
|
banjosound = 272;
|
|
|
|
}
|
|
|
|
else if (rnum == 2)
|
|
|
|
{
|
|
|
|
banjosound = 273;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
banjosound = 273;
|
|
|
|
}
|
|
|
|
S_PlayActorSound(banjosound, g_ac, CHAN_WEAPON);
|
|
|
|
}
|
|
|
|
else if (!S_CheckActorSoundPlaying(g_ac, banjosound))
|
|
|
|
S_PlayActorSound(banjosound, g_ac, CHAN_WEAPON);
|
|
|
|
}
|
2020-05-05 09:58:39 +00:00
|
|
|
END_DUKE_NS
|