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

1201 lines
30 KiB
C++
Raw Normal View History

2020-05-15 20:59:13 +00:00
//-------------------------------------------------------------------------
/*
Copyright (C) 1996, 2003 - 3D Realms Entertainment
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
Copyright (C) 2020 - Christoph Oelckers
This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition
Duke Nukem 3D is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Original Source: 1996 - Todd Replogle
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
EDuke enhancements integrated: 04/13/2003 - Matt Saettler
Note: EDuke source was in transition. Changes are in-progress in the
source as it is released.
*/
//-------------------------------------------------------------------------
#include <utility>
#include "ns.h"
#include "global.h"
2020-06-24 19:21:02 +00:00
#include "sounds.h"
2020-09-06 10:44:58 +00:00
#include "automap.h"
2020-10-21 17:38:53 +00:00
#include "dukeactor.h"
#include "interpolate.h"
2020-05-15 20:59:13 +00:00
BEGIN_DUKE_NS
2020-05-15 21:46:18 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2021-11-18 18:06:08 +00:00
DDukeActor* EGS(sectortype* whatsectp, int s_x, int s_y, int s_z, int s_pn, int8_t s_s, int8_t s_xr, int8_t s_yr, int s_a, int s_ve, int s_zv, DDukeActor* s_ow, int8_t s_ss)
2020-05-15 21:46:18 +00:00
{
// sector pointer must be strictly validated here or the engine will crash.
if (whatsectp == nullptr || !validSectorIndex(sectnum(whatsectp))) return nullptr;
auto act = static_cast<DDukeActor*>(::InsertActor(RUNTIME_CLASS(DDukeActor), whatsectp, s_ss));
2020-05-15 21:46:18 +00:00
if (act == nullptr) return nullptr;
SetupGameVarsForActor(act);
2020-05-15 21:46:18 +00:00
act->spr.pos.X = s_x;
act->spr.pos.Y = s_y;
act->spr.pos.Z = s_z;
2021-12-21 20:57:23 +00:00
act->spr.cstat = 0;
act->spr.picnum = s_pn;
act->spr.shade = s_s;
act->spr.xrepeat = s_xr;
act->spr.yrepeat = s_yr;
act->spr.pal = 0;
act->spr.ang = s_a;
act->spr.xvel = s_ve;
act->spr.zvel = s_zv;
act->spr.xoffset = 0;
act->spr.yoffset = 0;
act->spr.yvel = 0;
act->spr.clipdist = 0;
act->spr.pal = 0;
act->spr.lotag = 0;
act->spr.backuploc();
2020-05-15 21:46:18 +00:00
2020-10-24 05:34:54 +00:00
act->lastvx = 0;
act->lastvy = 0;
act->timetosleep = 0;
2021-11-18 19:55:22 +00:00
act->actorstayput = nullptr;
2020-10-24 05:34:54 +00:00
act->extra = -1;
act->cgg = 0;
act->movflag = 0;
act->tempang = 0;
act->dispicnum = 0;
2020-11-02 20:21:52 +00:00
act->SetHitOwner(s_ow);
act->SetOwner(s_ow);
if (s_ow)
{
act->picnum = s_ow->spr.picnum;
2020-11-02 20:21:52 +00:00
act->floorz = s_ow->floorz;
act->ceilingz = s_ow->ceilingz;
}
else
{
}
2020-11-02 20:21:52 +00:00
2020-10-24 05:34:54 +00:00
memset(act->temp_data, 0, sizeof(act->temp_data));
if (gs.actorinfo[s_pn].scriptaddress)
2020-05-15 21:46:18 +00:00
{
auto sa = &ScriptCode[gs.actorinfo[s_pn].scriptaddress];
2021-12-21 20:57:23 +00:00
act->spr.extra = sa[0];
2020-10-24 05:34:54 +00:00
act->temp_data[4] = sa[1];
act->temp_data[1] = sa[2];
2021-12-21 20:57:23 +00:00
act->spr.hitag = sa[3];
2020-05-15 21:46:18 +00:00
}
else
{
2021-12-21 20:57:23 +00:00
act->spr.extra = 0;
act->spr.hitag = 0;
2020-05-15 21:46:18 +00:00
}
2021-12-21 20:57:23 +00:00
if (show2dsector[act->spr.sectno()]) act->spr.cstat2 |= CSTAT2_SPRITE_MAPPED;
else act->spr.cstat2 &= ~CSTAT2_SPRITE_MAPPED;
2020-05-15 21:46:18 +00:00
2021-12-22 20:06:31 +00:00
act->sprext = {};
act->spsmooth = {};
2020-05-15 21:46:18 +00:00
2020-11-02 20:21:52 +00:00
return act;
2020-05-15 21:46:18 +00:00
}
2020-05-15 20:59:13 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
bool initspriteforspawn(DDukeActor* act, const std::initializer_list<int> &excludes)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
act->picnum = act->spr.picnum;
act->timetosleep = 0;
act->extra = -1;
2020-10-24 05:34:54 +00:00
2021-12-21 20:57:23 +00:00
act->spr.backuppos();
2020-10-24 05:34:54 +00:00
act->SetOwner(act);
act->SetHitOwner(act);
act->cgg = 0;
act->movflag = 0;
act->tempang = 0;
act->dispicnum = 0;
2021-12-21 20:57:23 +00:00
act->floorz = act->spr.sector()->floorz;
act->ceilingz = act->spr.sector()->ceilingz;
2020-10-24 05:34:54 +00:00
act->lastvx = 0;
act->lastvy = 0;
act->actorstayput = nullptr;
2020-05-15 20:59:13 +00:00
2021-12-23 15:24:11 +00:00
act->temp_data[0] = act->temp_data[1] = act->temp_data[2] = act->temp_data[3] = act->temp_data[4] = act->temp_data[5] = 0;
act->temp_actor = nullptr;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
if (act->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK)
if (!isIn(act->spr.picnum, excludes) && (act->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK))
{
2021-12-21 20:57:23 +00:00
if (act->spr.shade == 127) return false;
if (wallswitchcheck(act) && (act->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL))
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
if (act->spr.picnum != TILE_ACCESSSWITCH && act->spr.picnum != TILE_ACCESSSWITCH2 && act->spr.pal)
2020-05-15 20:59:13 +00:00
{
if ((ud.multimode < 2) || (ud.multimode > 1 && ud.coop == 1))
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
act->spr.xrepeat = act->spr.yrepeat = 0;
act->spr.cstat = 0;
act->spr.lotag = act->spr.hitag = 0;
return false;
2020-05-15 20:59:13 +00:00
}
}
2021-12-21 20:57:23 +00:00
act->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
if (act->spr.pal && act->spr.picnum != TILE_ACCESSSWITCH && act->spr.picnum != TILE_ACCESSSWITCH2)
act->spr.pal = 0;
return false;
}
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
if (act->spr.hitag)
{
ChangeActorStat(act, 12);
2021-12-21 20:57:23 +00:00
act->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
act->spr.extra = gs.impact_damage;
return false;
2020-05-15 20:59:13 +00:00
}
}
2021-12-21 20:57:23 +00:00
int s = act->spr.picnum;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
if (act->spr.cstat & CSTAT_SPRITE_BLOCK) act->spr.cstat |= CSTAT_SPRITE_BLOCK_HITSCAN;
2020-05-15 20:59:13 +00:00
if (gs.actorinfo[s].scriptaddress)
{
2021-12-21 20:57:23 +00:00
act->spr.extra = ScriptCode[gs.actorinfo[s].scriptaddress];
2021-12-23 15:24:11 +00:00
act->temp_data[4] = ScriptCode[gs.actorinfo[s].scriptaddress+1];
act->temp_data[1] = ScriptCode[gs.actorinfo[s].scriptaddress+2];
int s3 = ScriptCode[gs.actorinfo[s].scriptaddress+3];
2021-12-21 20:57:23 +00:00
if (s3 && act->spr.hitag == 0)
act->spr.hitag = s3;
}
2021-12-23 15:24:11 +00:00
else act->temp_data[1] = act->temp_data[4] = 0;
return true;
}
2020-05-15 20:59:13 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
DDukeActor* spawn(DDukeActor* actj, int pn)
{
if (actj)
{
auto spawned = EGS(actj->spr.sector(), actj->spr.pos.X, actj->spr.pos.Y, actj->spr.pos.Z, pn, 0, 0, 0, 0, 0, 0, actj, 0);
if (spawned)
2020-05-15 20:59:13 +00:00
{
spawned->picnum = actj->spr.picnum;
return fi.spawninit(actj, spawned, nullptr);
2020-05-15 20:59:13 +00:00
}
}
return nullptr;
2020-05-15 20:59:13 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-11-02 17:58:23 +00:00
void spawninitdefault(DDukeActor* actj, DDukeActor *act)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
if (gs.actorinfo[act->spr.picnum].scriptaddress)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
if (actj == nullptr && act->spr.lotag > ud.player_skill)
2020-05-15 20:59:13 +00:00
{
// make it go away...
2021-12-21 20:57:23 +00:00
act->spr.xrepeat = act->spr.yrepeat = 0;
ChangeActorStat(act, STAT_MISC);
2020-05-15 20:59:13 +00:00
return;
}
// Init the size
2021-12-21 20:57:23 +00:00
if (act->spr.xrepeat == 0 || act->spr.yrepeat == 0)
act->spr.xrepeat = act->spr.yrepeat = 1;
2020-05-15 20:59:13 +00:00
if (actorflag(act, SFLAG_BADGUY))
2020-05-15 20:59:13 +00:00
{
if (ud.monsters_off == 1)
{
2021-12-21 20:57:23 +00:00
act->spr.xrepeat = act->spr.yrepeat = 0;
ChangeActorStat(act, STAT_MISC);
2020-05-15 20:59:13 +00:00
return;
}
2020-11-02 17:58:23 +00:00
makeitfall(act);
2020-05-15 20:59:13 +00:00
if (actorflag(act, SFLAG_BADGUYSTAYPUT))
2021-12-21 20:57:23 +00:00
act->actorstayput = act->spr.sector();
2020-05-15 20:59:13 +00:00
if (!isRR() || actorflag(act, SFLAG_KILLCOUNT)) // Duke is just like Doom - Bad guys always count as kill.
2020-05-15 20:59:13 +00:00
ps[myconnectindex].max_actors_killed++;
2021-12-21 20:57:23 +00:00
act->spr.clipdist = 80;
2020-11-02 17:58:23 +00:00
if (actj)
2020-05-15 20:59:13 +00:00
{
if (actj->spr.picnum == RESPAWN)
2021-12-21 20:57:23 +00:00
act->tempang = act->spr.pal = actj->spr.pal;
ChangeActorStat(act, STAT_ACTOR);
2020-05-15 20:59:13 +00:00
}
else ChangeActorStat(act, STAT_ZOMBIEACTOR);
2020-05-15 20:59:13 +00:00
}
else
{
2021-12-21 20:57:23 +00:00
act->spr.clipdist = 40;
2020-11-02 17:58:23 +00:00
act->SetOwner(act);
ChangeActorStat(act, STAT_ACTOR);
2020-05-15 20:59:13 +00:00
}
2020-10-24 05:34:54 +00:00
act->timetosleep = 0;
2020-05-15 20:59:13 +00:00
2020-11-02 17:58:23 +00:00
if (actj)
2021-12-21 20:57:23 +00:00
act->spr.ang = actj->spr.ang;
2020-05-15 20:59:13 +00:00
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2021-12-21 20:57:23 +00:00
void spawntransporter(DDukeActor *actj, DDukeActor* act, bool beam)
2020-05-15 20:59:13 +00:00
{
2020-11-02 20:21:52 +00:00
if (actj == nullptr) return;
2020-05-15 20:59:13 +00:00
if (beam)
{
2021-12-21 20:57:23 +00:00
act->spr.xrepeat = 31;
act->spr.yrepeat = 1;
act->spr.pos.Z = actj->spr.sector()->floorz - (isRR() ? PHEIGHT_RR : PHEIGHT_DUKE);
2020-05-15 20:59:13 +00:00
}
else
{
2021-12-21 20:57:23 +00:00
if (actj->spr.statnum == 4)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
act->spr.xrepeat = 8;
act->spr.yrepeat = 8;
2020-05-15 20:59:13 +00:00
}
else
{
2021-12-21 20:57:23 +00:00
act->spr.xrepeat = 48;
act->spr.yrepeat = 64;
if (actj->spr.statnum == 10 || badguy(actj))
act->spr.pos.Z -= (32 << 8);
2020-05-15 20:59:13 +00:00
}
}
2021-12-21 20:57:23 +00:00
act->spr.shade = -127;
act->spr.cstat = CSTAT_SPRITE_YCENTER | CSTAT_SPRITE_TRANSLUCENT;
act->spr.ang = actj->spr.ang;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
act->spr.xvel = 128;
ChangeActorStat(act, STAT_MISC);
ssp(act, CLIPMASK0);
SetActor(act, act->spr.pos);
2020-05-15 20:59:13 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2021-12-21 20:57:23 +00:00
int spawnbloodpoolpart1(DDukeActor* act)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
auto s1 = act->spr.sector();
2020-05-15 20:59:13 +00:00
updatesector(act->spr.pos.X + 108, act->spr.pos.Y + 108, &s1);
2021-12-21 20:57:23 +00:00
if (s1 && s1->floorz == act->spr.sector()->floorz)
2020-05-15 20:59:13 +00:00
{
updatesector(act->spr.pos.X - 108, act->spr.pos.Y - 108, &s1);
2021-12-21 20:57:23 +00:00
if (s1 && s1->floorz == act->spr.sector()->floorz)
2020-05-15 20:59:13 +00:00
{
updatesector(act->spr.pos.X + 108, act->spr.pos.Y - 108, &s1);
2021-12-21 20:57:23 +00:00
if (s1 && s1->floorz == act->spr.sector()->floorz)
2020-05-15 20:59:13 +00:00
{
updatesector(act->spr.pos.X - 108, act->spr.pos.Y + 108, &s1);
2021-12-21 20:57:23 +00:00
if (s1 && s1->floorz != act->spr.sector()->floorz)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
act->spr.xrepeat = act->spr.yrepeat = 0; ChangeActorStat(act, STAT_MISC); return true;
2020-05-15 20:59:13 +00:00
}
}
2021-12-21 20:57:23 +00:00
else { act->spr.xrepeat = act->spr.yrepeat = 0; ChangeActorStat(act, STAT_MISC); return true; }
2020-05-15 20:59:13 +00:00
}
2021-12-21 20:57:23 +00:00
else { act->spr.xrepeat = act->spr.yrepeat = 0; ChangeActorStat(act, STAT_MISC); return true; }
2020-05-15 20:59:13 +00:00
}
2021-12-21 20:57:23 +00:00
else { act->spr.xrepeat = act->spr.yrepeat = 0; ChangeActorStat(act, STAT_MISC); return true; }
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
if (act->spr.sector()->lotag == 1)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
ChangeActorStat(act, STAT_MISC);
2020-05-15 20:59:13 +00:00
return true;
}
return false;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2021-12-21 20:57:23 +00:00
void initfootprint(DDukeActor* actj, DDukeActor* act)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
auto sect = act->spr.sector();
2020-11-02 20:21:52 +00:00
if (actj)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
auto s1 = act->spr.sector();
2020-05-15 20:59:13 +00:00
updatesector(act->spr.pos.X + 84, act->spr.pos.Y + 84, &s1);
2021-12-21 20:57:23 +00:00
if (s1 && s1->floorz == act->spr.sector()->floorz)
2020-05-15 20:59:13 +00:00
{
updatesector(act->spr.pos.X - 84, act->spr.pos.Y - 84, &s1);
2021-12-21 20:57:23 +00:00
if (s1 && s1->floorz == act->spr.sector()->floorz)
2020-05-15 20:59:13 +00:00
{
updatesector(act->spr.pos.X + 84, act->spr.pos.Y - 84, &s1);
2021-12-21 20:57:23 +00:00
if (s1 && s1->floorz == act->spr.sector()->floorz)
2020-05-15 20:59:13 +00:00
{
updatesector(act->spr.pos.X - 84, act->spr.pos.Y + 84, &s1);
2021-12-21 20:57:23 +00:00
if (s1 && s1->floorz != act->spr.sector()->floorz)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
act->spr.xrepeat = act->spr.yrepeat = 0; ChangeActorStat(act, STAT_MISC); return;
2020-05-15 20:59:13 +00:00
}
}
2021-12-21 20:57:23 +00:00
else { act->spr.xrepeat = act->spr.yrepeat = 0; return; }
2020-05-15 20:59:13 +00:00
}
2021-12-21 20:57:23 +00:00
else { act->spr.xrepeat = act->spr.yrepeat = 0; return; }
2020-05-15 20:59:13 +00:00
}
2021-12-21 20:57:23 +00:00
else { act->spr.xrepeat = act->spr.yrepeat = 0; return; }
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
act->spr.cstat = CSTAT_SPRITE_ALIGNMENT_FLOOR;
if ((ps[actj->spr.yvel].footprintcount & 1)) act->spr.cstat |= CSTAT_SPRITE_XFLIP;
act->spr.ang = actj->spr.ang;
2020-05-15 20:59:13 +00:00
}
act->spr.pos.Z = sect->floorz;
2021-11-17 23:47:46 +00:00
if (sect->lotag != 1 && sect->lotag != 2)
2021-12-21 20:57:23 +00:00
act->spr.xrepeat = act->spr.yrepeat = 32;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
insertspriteq(act);
ChangeActorStat(act, STAT_MISC);
2020-05-15 20:59:13 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2021-12-21 20:57:23 +00:00
void initshell(DDukeActor* actj, DDukeActor* act, bool isshell)
2020-05-15 20:59:13 +00:00
{
if (actj)
2020-05-15 20:59:13 +00:00
{
int snum, a;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
if (actj->spr.picnum == TILE_APLAYER)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
snum = actj->spr.yvel;
a = ps[snum].angle.ang.asbuild() - (krand() & 63) + 8; //Fine tune
2020-05-15 20:59:13 +00:00
2021-12-23 15:24:11 +00:00
act->temp_data[0] = krand() & 1;
act->spr.pos.Z = (3 << 8) + ps[snum].pyoff + ps[snum].pos.Z - (ps[snum].horizon.sum().asq16() >> 12) + (!isshell ? (3 << 8) : 0);
2021-12-21 20:57:23 +00:00
act->spr.zvel = -(krand() & 255);
2020-05-15 20:59:13 +00:00
}
else
{
2021-12-21 20:57:23 +00:00
a = act->spr.ang;
act->spr.pos.Z = actj->spr.pos.Z - gs.playerheight + (3 << 8);
2020-05-15 20:59:13 +00:00
}
act->spr.pos.X = actj->spr.pos.X + bcos(a, -7);
act->spr.pos.Y = actj->spr.pos.Y + bsin(a, -7);
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
act->spr.shade = -8;
2020-05-15 20:59:13 +00:00
if (isNamWW2GI())
{
// to the right, with feeling
2021-12-21 20:57:23 +00:00
act->spr.ang = a + 512;
act->spr.xvel = 30;
2020-05-15 20:59:13 +00:00
}
else
{
2021-12-21 20:57:23 +00:00
act->spr.ang = a - 512;
act->spr.xvel = 20;
2020-05-15 20:59:13 +00:00
}
2021-12-21 20:57:23 +00:00
act->spr.xrepeat = act->spr.yrepeat = isRR() && isshell? 2 : 4;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
ChangeActorStat(act, STAT_MISC);
2020-05-15 20:59:13 +00:00
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2021-12-21 20:57:23 +00:00
void initcrane(DDukeActor* actj, DDukeActor* act, int CRANEPOLE)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
auto sect = act->spr.sector();
act->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_ONE_SIDE;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
act->spr.picnum += 2;
act->spr.pos.Z = sect->ceilingz + (48 << 8);
2021-12-23 15:24:11 +00:00
act->temp_data[4] = cranes.Reserve(1);
2020-05-15 20:59:13 +00:00
2021-12-23 15:24:11 +00:00
auto& apt = cranes[act->temp_data[4]];
apt.x = act->spr.pos.X;
apt.y = act->spr.pos.Y;
apt.z = act->spr.pos.Z;
apt.poleactor = nullptr;
2020-05-15 20:59:13 +00:00
DukeStatIterator it(STAT_DEFAULT);
while (auto act = it.Next())
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
if (act->spr.picnum == CRANEPOLE && act->spr.hitag == (act->spr.hitag))
2020-05-15 20:59:13 +00:00
{
apt.poleactor = act;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
act->temp_sect = act->spr.sector();
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
act->spr.xrepeat = 48;
act->spr.yrepeat = 128;
2020-05-15 20:59:13 +00:00
apt.polex = act->spr.pos.X;
apt.poley = act->spr.pos.Y;
2020-05-15 20:59:13 +00:00
act->spr.pos.X = act->spr.pos.X;
act->spr.pos.Y = act->spr.pos.Y;
act->spr.pos.Z = act->spr.pos.Z;
2021-12-21 20:57:23 +00:00
act->spr.shade = act->spr.shade;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
SetActor(act, act->spr.pos);
2020-05-15 20:59:13 +00:00
break;
}
}
2021-12-21 20:57:23 +00:00
act->SetOwner(nullptr);
act->spr.extra = 8;
ChangeActorStat(act, STAT_STANDABLE);
2020-05-15 20:59:13 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void initwaterdrip(DDukeActor* actj, DDukeActor* actor)
2020-05-15 20:59:13 +00:00
{
if (actj && (actj->spr.statnum == 10 || actj->spr.statnum == 1))
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
actor->spr.shade = 32;
if (actj->spr.pal != 1)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
actor->spr.pal = 2;
actor->spr.pos.Z -= (18 << 8);
2020-05-15 20:59:13 +00:00
}
else actor->spr.pos.Z -= (13 << 8);
actor->spr.ang = getangle(ps[connecthead].pos.X - actor->spr.pos.X, ps[connecthead].pos.Y - actor->spr.pos.Y);
2021-12-21 20:57:23 +00:00
actor->spr.xvel = 48 - (krand() & 31);
ssp(actor, CLIPMASK0);
2020-05-15 20:59:13 +00:00
}
else if (!actj)
2020-05-15 20:59:13 +00:00
{
actor->spr.pos.Z += (4 << 8);
2021-12-23 15:24:11 +00:00
actor->temp_data[0] = actor->spr.pos.Z;
if (!isRR()) actor->temp_data[1] = krand() & 127;
2020-05-15 20:59:13 +00:00
}
2021-12-21 20:57:23 +00:00
actor->spr.xrepeat = 24;
actor->spr.yrepeat = 24;
ChangeActorStat(actor, STAT_STANDABLE);
2020-05-15 20:59:13 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int initreactor(DDukeActor* actj, DDukeActor* actor, bool isrecon)
2020-05-15 20:59:13 +00:00
{
if (isrecon)
{
2021-12-21 20:57:23 +00:00
if (actor->spr.lotag > ud.player_skill)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
actor->spr.xrepeat = actor->spr.yrepeat = 0;
ChangeActorStat(actor, STAT_MISC);
2020-05-15 20:59:13 +00:00
return true;
}
if (!isRR() || actorflag(actor, SFLAG_KILLCOUNT)) // Duke is just like Doom - Bad guys always count as kill.
2020-05-15 20:59:13 +00:00
ps[myconnectindex].max_actors_killed++;
actor->temp_data[5] = 0;
2020-05-15 20:59:13 +00:00
if (ud.monsters_off == 1)
{
2021-12-21 20:57:23 +00:00
actor->spr.xrepeat = actor->spr.yrepeat = 0;
ChangeActorStat(actor, STAT_MISC);
2020-05-15 20:59:13 +00:00
return false;
}
2021-12-21 20:57:23 +00:00
actor->spr.extra = 130;
2020-05-15 20:59:13 +00:00
}
else
2021-12-21 20:57:23 +00:00
actor->spr.extra = gs.impact_damage;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
actor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL; // Make it hitable
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
if (ud.multimode < 2 && actor->spr.pal != 0)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
actor->spr.xrepeat = actor->spr.yrepeat = 0;
ChangeActorStat(actor, STAT_MISC);
2020-05-15 20:59:13 +00:00
return false;
}
2021-12-21 20:57:23 +00:00
actor->spr.pal = 0;
actor->spr.shade = -17;
2020-05-15 20:59:13 +00:00
ChangeActorStat(actor, 2);
2020-05-15 20:59:13 +00:00
return false;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void spawneffector(DDukeActor* actor, TArray<DDukeActor*>* actors)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
auto sectp = actor->spr.sector();
int d, clostest = 0;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
actor->spr.yvel = sectp->extra;
actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
actor->spr.xrepeat = actor->spr.yrepeat = 0;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
switch (actor->spr.lotag)
2020-05-15 20:59:13 +00:00
{
case SE_28_LIGHTNING:
2021-12-23 15:24:11 +00:00
if (!isRR()) actor->temp_data[5] = 65;// Delay for lightning
2020-05-15 20:59:13 +00:00
break;
case SE_7_TELEPORT: // Transporters!!!!
case SE_23_ONE_WAY_TELEPORT:// XPTR END
2021-12-21 20:57:23 +00:00
if (actor->spr.lotag != SE_23_ONE_WAY_TELEPORT && actors)
2020-05-15 20:59:13 +00:00
{
for(auto act2 : *actors)
{
if (act2->spr.statnum < MAXSTATUS && act2->spr.picnum == SECTOREFFECTOR && (act2->spr.lotag == SE_7_TELEPORT || act2->spr.lotag == SE_23_ONE_WAY_TELEPORT) &&
2021-12-21 20:57:23 +00:00
actor != act2 && act2->spr.hitag == actor->spr.hitag)
2020-11-02 21:20:41 +00:00
{
actor->SetOwner(act2);
2020-05-15 20:59:13 +00:00
break;
}
}
2020-11-02 21:20:41 +00:00
}
else actor->SetOwner(actor);
2020-05-15 20:59:13 +00:00
2021-12-23 15:24:11 +00:00
actor->temp_data[4] = sectp->floorz == actor->spr.pos.Z;
2021-12-21 20:57:23 +00:00
actor->spr.cstat = 0;
ChangeActorStat(actor, STAT_TRANSPORT);
2020-05-15 20:59:13 +00:00
return;
case SE_1_PIVOT:
2020-11-02 21:26:32 +00:00
actor->SetOwner(nullptr);
2021-12-23 15:24:11 +00:00
actor->temp_data[0] = 1;
2020-05-15 20:59:13 +00:00
break;
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
if (actor->spr.ang == 512)
2020-05-15 20:59:13 +00:00
{
2021-12-23 15:24:11 +00:00
actor->temp_data[1] = sectp->ceilingz;
2021-12-21 20:57:23 +00:00
if (actor->spr.pal)
sectp->ceilingz = actor->spr.pos.Z;
2020-05-15 20:59:13 +00:00
}
else
{
2021-12-23 15:24:11 +00:00
actor->temp_data[1] = sectp->floorz;
2021-12-21 20:57:23 +00:00
if (actor->spr.pal)
sectp->floorz = actor->spr.pos.Z;
2020-05-15 20:59:13 +00:00
}
2021-12-21 20:57:23 +00:00
actor->spr.hitag <<= 2;
2020-05-15 20:59:13 +00:00
break;
case SE_19_EXPLOSION_LOWERS_CEILING:
2020-11-02 21:26:32 +00:00
actor->SetOwner(nullptr);
2020-05-15 20:59:13 +00:00
break;
case SE_25_PISTON: // Pistons
2020-05-15 20:59:13 +00:00
if (!isRR())
{
2021-12-23 15:24:11 +00:00
actor->temp_data[3] = sectp->ceilingz;
actor->temp_data[4] = 1;
2020-05-15 20:59:13 +00:00
}
else
2021-12-23 15:24:11 +00:00
actor->temp_data[4] = sectp->ceilingz;
2020-05-15 20:59:13 +00:00
sectp->ceilingz = actor->spr.pos.Z;
StartInterpolation(sectp, Interp_Sect_Ceilingz);
2020-05-15 20:59:13 +00:00
break;
case SE_35:
sectp->ceilingz = actor->spr.pos.Z;
2020-05-15 20:59:13 +00:00
break;
case SE_27_DEMO_CAM:
2020-05-15 20:59:13 +00:00
if (ud.recstat == 1)
{
2021-12-21 20:57:23 +00:00
actor->spr.xrepeat = actor->spr.yrepeat = 64;
actor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
2020-05-15 20:59:13 +00:00
}
break;
case SE_47_LIGHT_SWITCH:
case SE_48_LIGHT_SWITCH:
2020-05-15 20:59:13 +00:00
if (!isRRRA()) break;
[[fallthrough]];
case SE_12_LIGHT_SWITCH:
2020-05-15 20:59:13 +00:00
2021-12-23 15:24:11 +00:00
actor->temp_data[1] = sectp->floorshade;
actor->temp_data[2] = sectp->ceilingshade;
2020-05-15 20:59:13 +00:00
break;
case SE_13_EXPLOSIVE:
2020-11-02 21:26:32 +00:00
{
2021-12-23 15:24:11 +00:00
actor->temp_data[0] = sectp->ceilingz;
actor->temp_data[1] = sectp->floorz;
2020-05-15 20:59:13 +00:00
2021-12-23 15:24:11 +00:00
bool ceiling = (abs(actor->temp_data[0] - actor->spr.pos.Z) < abs(actor->temp_data[1] - actor->spr.pos.Z));
actor->spriteextra = ceiling;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
if (actor->spr.ang == 512)
2020-05-15 20:59:13 +00:00
{
2020-11-02 21:26:32 +00:00
if (ceiling)
sectp->ceilingz = actor->spr.pos.Z;
2020-05-15 20:59:13 +00:00
else
sectp->floorz = actor->spr.pos.Z;
2020-05-15 20:59:13 +00:00
}
else
sectp->ceilingz = sectp->floorz = actor->spr.pos.Z;
2020-05-15 20:59:13 +00:00
if (sectp->ceilingstat & CSTAT_SECTOR_SKY)
2020-05-15 20:59:13 +00:00
{
2021-12-18 12:23:08 +00:00
sectp->ceilingstat ^= CSTAT_SECTOR_SKY;
2021-12-23 15:24:11 +00:00
actor->temp_data[3] = 1;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
if (!ceiling && actor->spr.ang == 512)
2020-05-15 20:59:13 +00:00
{
2021-12-18 12:23:08 +00:00
sectp->ceilingstat ^= CSTAT_SECTOR_SKY;
2021-12-23 15:24:11 +00:00
actor->temp_data[3] = 0;
2020-05-15 20:59:13 +00:00
}
sectp->ceilingshade =
sectp->floorshade;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
if (actor->spr.ang == 512)
2020-05-15 20:59:13 +00:00
{
for (auto& wl : wallsofsector(sectp))
2020-05-15 20:59:13 +00:00
{
if (wl.twoSided())
{
auto nsec = wl.nextSector();
if (!(nsec->ceilingstat & CSTAT_SECTOR_SKY))
2020-05-15 20:59:13 +00:00
{
sectp->ceilingpicnum = nsec->ceilingpicnum;
sectp->ceilingshade = nsec->ceilingshade;
break; //Leave early
2020-05-15 20:59:13 +00:00
}
}
2020-05-15 20:59:13 +00:00
}
}
}
break;
2020-11-02 21:26:32 +00:00
}
case SE_17_WARP_ELEVATOR:
2020-11-02 21:20:41 +00:00
{
2021-12-23 15:24:11 +00:00
actor->temp_data[2] = sectp->floorz; //Stopping loc
actor->temp_data[3] = safenextsectorneighborzptr(sectp, sectp->floorz, -1, -1)->ceilingz;
actor->temp_data[4] = safenextsectorneighborzptr(sectp, sectp->ceilingz, 1, 1)->floorz;
2020-05-15 20:59:13 +00:00
if (numplayers < 2)
{
StartInterpolation(sectp, Interp_Sect_Floorz);
StartInterpolation(sectp, Interp_Sect_Ceilingz);
2020-05-15 20:59:13 +00:00
}
break;
2020-11-02 21:20:41 +00:00
}
case 156:
break;
case 34:
StartInterpolation(sectp, Interp_Sect_FloorPanX);
break;
case SE_24_CONVEYOR:
StartInterpolation(sectp, Interp_Sect_FloorPanX);
2021-12-21 20:57:23 +00:00
actor->spr.yvel <<= 1;
case SE_36_PROJ_SHOOTER:
2020-05-15 20:59:13 +00:00
break;
case SE_20_STRETCH_BRIDGE:
2020-05-15 20:59:13 +00:00
{
int q;
walltype* closewall = nullptr;
2020-05-15 20:59:13 +00:00
//find the two most clostest wall x's and y's
q = 0x7fffffff;
for (auto& wal : wallsofsector(sectp))
2020-05-15 20:59:13 +00:00
{
d = FindDistance2D(actor->spr.pos.X - wal.pos.X, actor->spr.pos.Y - wal.pos.Y);
2020-05-15 20:59:13 +00:00
if (d < q)
{
q = d;
closewall = &wal;
2020-05-15 20:59:13 +00:00
}
}
actor->temp_walls[0] = closewall;
2020-05-15 20:59:13 +00:00
q = 0x7fffffff;
for (auto& wal : wallsofsector(sectp))
2020-05-15 20:59:13 +00:00
{
d = FindDistance2D(actor->spr.pos.X - wal.pos.X, actor->spr.pos.Y - wal.pos.Y);
if (d < q && &wal != actor->temp_walls[0])
2020-05-15 20:59:13 +00:00
{
q = d;
closewall = &wal;
2020-05-15 20:59:13 +00:00
}
}
actor->temp_walls[1] = closewall;
StartInterpolation(sectp, Interp_Sect_FloorPanX);
StartInterpolation(sectp, Interp_Sect_FloorPanY);
2020-05-15 20:59:13 +00:00
break;
}
case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT:
2020-05-15 20:59:13 +00:00
2021-12-23 15:24:11 +00:00
actor->temp_data[3] = sectp->floorshade;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
sectp->floorshade = actor->spr.shade;
sectp->ceilingshade = actor->spr.shade;
2020-05-15 20:59:13 +00:00
actor->palvals = (sectp->ceilingpal << 8) | sectp->floorpal;
2020-05-15 20:59:13 +00:00
//fix all the walls;
2021-11-17 22:31:08 +00:00
for (auto& wal : wallsofsector(sectp))
2020-05-15 20:59:13 +00:00
{
2021-11-17 22:31:08 +00:00
if (!(wal.hitag & 1))
2021-12-21 20:57:23 +00:00
wal.shade = actor->spr.shade;
if ((wal.cstat & CSTAT_WALL_BOTTOM_SWAP) && wal.twoSided())
2021-12-21 20:57:23 +00:00
wal.nextWall()->shade = actor->spr.shade;
2020-05-15 20:59:13 +00:00
}
break;
case SE_31_FLOOR_RISE_FALL:
2021-12-23 15:24:11 +00:00
actor->temp_data[1] = sectp->floorz;
// actor->temp_data[2] = actor->spr.hitag;
if (actor->spr.ang != 1536) sectp->floorz = actor->spr.pos.Z;
2020-05-15 20:59:13 +00:00
2021-11-17 22:31:08 +00:00
for (auto& wal : wallsofsector(sectp))
if (wal.hitag == 0) wal.hitag = 9999;
2020-05-15 20:59:13 +00:00
StartInterpolation(sectp, Interp_Sect_Floorz);
2020-05-15 20:59:13 +00:00
break;
case SE_32_CEILING_RISE_FALL:
2021-12-23 15:24:11 +00:00
actor->temp_data[1] = sectp->ceilingz;
actor->temp_data[2] = actor->spr.hitag;
if (actor->spr.ang != 1536) sectp->ceilingz = actor->spr.pos.Z;
2020-05-15 20:59:13 +00:00
2021-11-17 22:31:08 +00:00
for (auto& wal : wallsofsector(sectp))
if (wal.hitag == 0) wal.hitag = 9999;
2020-05-15 20:59:13 +00:00
StartInterpolation(sectp, Interp_Sect_Ceilingz);
2020-05-15 20:59:13 +00:00
break;
case SE_4_RANDOM_LIGHTS: //Flashing lights
2020-05-15 20:59:13 +00:00
2021-12-23 15:24:11 +00:00
actor->temp_data[2] = sectp->floorshade;
2020-05-15 20:59:13 +00:00
actor->palvals = (sectp->ceilingpal << 8) | sectp->floorpal;
2020-05-15 20:59:13 +00:00
2021-11-17 22:31:08 +00:00
for (auto& wal : wallsofsector(sectp))
2021-12-23 15:24:11 +00:00
if (wal.shade > actor->temp_data[3])
actor->temp_data[3] = wal.shade;
2020-05-15 20:59:13 +00:00
break;
case SE_9_DOWN_OPEN_DOOR_LIGHTS:
if (sectp->lotag &&
labs(sectp->ceilingz - actor->spr.pos.Z) > 1024)
sectp->lotag |= 32768; //If its open
[[fallthrough]];
case SE_8_UP_OPEN_DOOR_LIGHTS:
2020-05-15 20:59:13 +00:00
//First, get the ceiling-floor shade
2021-12-23 15:24:11 +00:00
actor->temp_data[0] = sectp->floorshade;
actor->temp_data[1] = sectp->ceilingshade;
2020-05-15 20:59:13 +00:00
2021-11-17 22:31:08 +00:00
for (auto& wal : wallsofsector(sectp))
2021-12-23 15:24:11 +00:00
if (wal.shade > actor->temp_data[2])
actor->temp_data[2] = wal.shade;
2020-05-15 20:59:13 +00:00
2021-12-23 15:24:11 +00:00
actor->temp_data[3] = 1; //Take Out;
2020-05-15 20:59:13 +00:00
break;
case 88:
//First, get the ceiling-floor shade
if (!isRR()) break;
2021-12-23 15:24:11 +00:00
actor->temp_data[0] = sectp->floorshade;
actor->temp_data[1] = sectp->ceilingshade;
2020-05-15 20:59:13 +00:00
2021-11-17 22:31:08 +00:00
for (auto& wal : wallsofsector(sectp))
2021-12-23 15:24:11 +00:00
if (wal.shade > actor->temp_data[2])
actor->temp_data[2] = wal.shade;
2020-05-15 20:59:13 +00:00
2021-12-23 15:24:11 +00:00
actor->temp_data[3] = 1; //Take Out;
2020-05-15 20:59:13 +00:00
break;
case SE_11_SWINGING_DOOR://Pivitor rotater
2021-12-23 15:24:11 +00:00
if (actor->spr.ang > 1024) actor->temp_data[3] = 2;
else actor->temp_data[3] = -2;
[[fallthrough]];
case SE_0_ROTATING_SECTOR:
case SE_2_EARTHQUAKE://Earthquakemakers
case SE_5_BOSS://Boss Creature
case SE_6_SUBWAY://Subway
case SE_14_SUBWAY_CAR://Caboos
case SE_15_SLIDING_DOOR://Subwaytype sliding door
case SE_16_REACTOR://That rotating blocker reactor thing
case SE_26://ESCELATOR
case SE_30_TWO_WAY_TRAIN://No rotational subways
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
if (actor->spr.lotag == 0)
2020-05-15 20:59:13 +00:00
{
if (sectp->lotag == 30)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
if (actor->spr.pal) actor->spr.clipdist = 1;
else actor->spr.clipdist = 0;
2021-12-23 15:24:11 +00:00
actor->temp_data[3] = sectp->floorz;
sectp->hitagactor = actor;
2020-05-15 20:59:13 +00:00
}
2020-11-02 21:20:41 +00:00
bool found = false;
if (actors) for(auto act2 : *actors)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
if (act2->spr.statnum < MAXSTATUS)
if (act2->spr.picnum == SECTOREFFECTOR &&
act2->spr.lotag == SE_1_PIVOT &&
act2->spr.hitag == actor->spr.hitag)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
if (actor->spr.ang == 512)
2020-05-15 20:59:13 +00:00
{
actor->spr.pos.X = act2->spr.pos.X;
actor->spr.pos.Y = act2->spr.pos.Y;
2020-05-15 20:59:13 +00:00
}
2020-11-02 21:20:41 +00:00
found = true;
actor->SetOwner(act2);
2020-05-15 20:59:13 +00:00
break;
}
}
2020-11-02 21:20:41 +00:00
if (!found)
2020-05-15 20:59:13 +00:00
{
2021-12-21 20:57:23 +00:00
actor->spr.picnum = 0;
actor->spr.cstat2 = CSTAT2_SPRITE_NOFIND;
actor->spr.cstat = CSTAT_SPRITE_INVISIBLE;
ChangeActorStat(actor, STAT_REMOVED);
Printf("Found lonely Sector Effector (lotag 0) at (%d,%d)\n", actor->spr.pos.X, actor->spr.pos.Y);
return;
2020-05-15 20:59:13 +00:00
}
}
2021-12-23 15:24:11 +00:00
actor->temp_data[1] = tempwallptr;
2021-11-17 22:35:20 +00:00
for (auto& wal : wallsofsector(sectp))
2020-05-15 20:59:13 +00:00
{
msx[tempwallptr] = wal.pos.X - actor->spr.pos.X;
msy[tempwallptr] = wal.pos.Y - actor->spr.pos.Y;
2020-05-15 20:59:13 +00:00
tempwallptr++;
if (tempwallptr > 2047)
{
I_Error("Too many moving sectors at (%d,%d).\n", wal.pos.X, wal.pos.Y);
2020-05-15 20:59:13 +00:00
}
}
2021-12-21 20:57:23 +00:00
if (actor->spr.lotag == SE_30_TWO_WAY_TRAIN || actor->spr.lotag == SE_6_SUBWAY || actor->spr.lotag == SE_14_SUBWAY_CAR || actor->spr.lotag == SE_5_BOSS)
2020-05-15 20:59:13 +00:00
{
if (sectp->hitag == -1)
2021-12-21 20:57:23 +00:00
actor->spr.extra = 0;
else actor->spr.extra = 1;
2020-05-15 20:59:13 +00:00
sectp->hitagactor = actor;
2020-05-15 20:59:13 +00:00
sectortype* s = nullptr;
2021-11-17 22:35:20 +00:00
for (auto& wal : wallsofsector(sectp))
2020-05-15 20:59:13 +00:00
{
if (wal.twoSided() &&
2021-11-17 22:35:20 +00:00
wal.nextSector()->hitag == 0 &&
(wal.nextSector()->lotag < 3 || (isRRRA() && wal.nextSector()->lotag == 160)))
2020-05-15 20:59:13 +00:00
{
s = wal.nextSector();
2020-05-15 20:59:13 +00:00
break;
}
}
if (s == nullptr)
2020-05-15 20:59:13 +00:00
{
I_Error("Subway found no zero'd sectors with locators\nat (%d,%d).\n", actor->spr.pos.X, actor->spr.pos.Y);
2020-05-15 20:59:13 +00:00
}
2020-11-02 21:26:32 +00:00
actor->SetOwner(nullptr);
actor->temp_sect = s;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
if (actor->spr.lotag != SE_30_TWO_WAY_TRAIN)
2021-12-23 15:24:11 +00:00
actor->temp_data[3] = actor->spr.hitag;
2020-05-15 20:59:13 +00:00
}
2021-12-21 20:57:23 +00:00
else if (actor->spr.lotag == SE_16_REACTOR)
2021-12-23 15:24:11 +00:00
actor->temp_data[3] = sectp->ceilingz;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
else if (actor->spr.lotag == SE_26)
2020-05-15 20:59:13 +00:00
{
2021-12-23 15:24:11 +00:00
actor->temp_data[3] = actor->spr.pos.X;
actor->temp_data[4] = actor->spr.pos.Y;
2021-12-21 20:57:23 +00:00
if (actor->spr.shade == sectp->floorshade) //UP
actor->spr.zvel = -256;
2020-05-15 20:59:13 +00:00
else
2021-12-21 20:57:23 +00:00
actor->spr.zvel = 256;
2020-05-15 20:59:13 +00:00
2021-12-21 20:57:23 +00:00
actor->spr.shade = 0;
2020-05-15 20:59:13 +00:00
}
2021-12-21 20:57:23 +00:00
else if (actor->spr.lotag == SE_2_EARTHQUAKE)
2020-05-15 20:59:13 +00:00
{
2021-12-23 15:24:11 +00:00
actor->temp_data[5] = actor->spr.sector()->floorheinum;
2021-12-21 20:57:23 +00:00
actor->spr.sector()->setfloorslope(0);
2020-05-15 20:59:13 +00:00
}
}
2021-12-21 20:57:23 +00:00
switch (actor->spr.lotag)
2020-05-15 20:59:13 +00:00
{
case SE_6_SUBWAY:
case SE_14_SUBWAY_CAR:
2020-11-02 21:20:41 +00:00
{
int j = callsound(sectp, actor);
2020-05-15 20:59:13 +00:00
if (j == -1)
{
if (!isRR()) j = SUBWAY; // Duke
2021-12-21 20:57:23 +00:00
else if (actor->spr.sector()->floorpal == 7) j = 456;
2020-05-15 20:59:13 +00:00
else j = 75;
}
2020-11-02 21:20:41 +00:00
actor->lastvx = j;
}
[[fallthrough]];
case SE_30_TWO_WAY_TRAIN:
2020-05-15 20:59:13 +00:00
if (numplayers > 1) break;
[[fallthrough]];
case SE_0_ROTATING_SECTOR:
case SE_1_PIVOT:
case SE_5_BOSS:
case SE_11_SWINGING_DOOR:
case SE_15_SLIDING_DOOR:
case SE_16_REACTOR:
case SE_26:
setsectinterpolate(actor->spr.sector());
2020-05-15 20:59:13 +00:00
break;
2020-11-27 19:06:38 +00:00
case SE_29_WAVES:
StartInterpolation(actor->spr.sector(), Interp_Sect_Floorheinum);
StartInterpolation(actor->spr.sector(), Interp_Sect_Floorz);
2020-11-27 19:06:38 +00:00
break;
2020-05-15 20:59:13 +00:00
}
if ((!isRR() && actor->spr.lotag >= 40 && actor->spr.lotag <= 45) ||
(isRRRA() && actor->spr.lotag >= 150 && actor->spr.lotag <= 155))
ChangeActorStat(actor, STAT_RAROR);
2020-05-15 20:59:13 +00:00
else
ChangeActorStat(actor, STAT_EFFECTOR);
2020-05-15 20:59:13 +00:00
}
2020-05-16 10:47:01 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2021-11-17 23:38:20 +00:00
void lotsofglass(DDukeActor *actor, walltype* wal, int n)
2020-05-16 10:47:01 +00:00
{
2021-11-17 22:45:41 +00:00
int j, z, a;
2021-11-17 23:47:46 +00:00
sectortype* sect = nullptr;
2020-05-16 10:47:01 +00:00
2021-11-17 23:38:20 +00:00
if (wal == nullptr)
2020-05-16 10:47:01 +00:00
{
for (j = n - 1; j >= 0; j--)
{
2021-12-21 20:57:23 +00:00
a = actor->spr.ang - 256 + (krand() & 511) + 1024;
EGS(actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), 1024 - (krand() & 1023), actor, 5);
2020-05-16 10:47:01 +00:00
}
return;
}
int x1 = wal->pos.X;
int y1 = wal->pos.Y;
2021-11-17 22:45:41 +00:00
auto delta = wal->delta() / (n + 1);
2020-05-16 10:47:01 +00:00
2021-12-22 09:28:51 +00:00
x1 -= Sgn(delta.Y);
2021-12-22 09:26:51 +00:00
y1 += Sgn(delta.X);
2020-05-16 10:47:01 +00:00
for (j = n; j > 0; j--)
{
2021-12-22 09:26:51 +00:00
x1 += delta.X;
2021-12-22 09:28:51 +00:00
y1 += delta.Y;
2020-05-16 10:47:01 +00:00
updatesector(x1, y1, &sect);
2021-11-17 23:47:46 +00:00
if (sect)
2020-05-16 10:47:01 +00:00
{
2021-11-17 23:47:46 +00:00
z = sect->floorz - (krand() & (abs(sect->ceilingz - sect->floorz)));
2020-05-16 10:47:01 +00:00
if (z < -(32 << 8) || z >(32 << 8))
z = actor->spr.pos.Z - (32 << 8) + (krand() & ((64 << 8) - 1));
2021-12-21 20:57:23 +00:00
a = actor->spr.ang - 1024;
EGS(actor->spr.sector(), x1, y1, z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), -(krand() & 1023), actor, 5);
2020-05-16 10:47:01 +00:00
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void spriteglass(DDukeActor* actor, int n)
2020-05-16 10:47:01 +00:00
{
for (int j = n; j > 0; j--)
2020-05-16 10:47:01 +00:00
{
int a = krand() & 2047;
int z = actor->spr.pos.Z - ((krand() & 16) << 8);
auto k = EGS(actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, z, TILE_GLASSPIECES + (j % 3), krand() & 15, 36, 36, a, 32 + (krand() & 63), -512 - (krand() & 2047), actor, 5);
2021-12-21 20:57:23 +00:00
if (k) k->spr.pal = actor->spr.pal;
2020-05-16 10:47:01 +00:00
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void ceilingglass(DDukeActor* actor, sectortype* sectp, int n)
2020-05-16 10:47:01 +00:00
{
2021-11-17 22:45:41 +00:00
int j, z;
int a;
2020-05-16 10:47:01 +00:00
for (auto& wal : wallsofsector(sectp))
2020-05-16 10:47:01 +00:00
{
int x1 = wal.pos.X;
int y1 = wal.pos.Y;
2020-05-16 10:47:01 +00:00
2021-11-17 22:45:41 +00:00
auto delta = wal.delta() / (n + 1);
2020-05-16 10:47:01 +00:00
for (j = n; j > 0; j--)
{
2021-12-22 09:26:51 +00:00
x1 += delta.X;
2021-12-22 09:28:51 +00:00
y1 += delta.Y;
2020-05-16 10:47:01 +00:00
a = krand() & 2047;
z = sectp->ceilingz + ((krand() & 15) << 8);
2021-11-18 18:06:08 +00:00
EGS(sectp, x1, y1, z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, (krand() & 31), 0, actor, 5);
2020-05-16 10:47:01 +00:00
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2021-11-17 23:38:20 +00:00
void lotsofcolourglass(DDukeActor* actor, walltype* wal, int n)
2020-05-16 10:47:01 +00:00
{
2021-11-17 22:45:41 +00:00
int j, z;
2021-11-17 23:47:46 +00:00
sectortype* sect = nullptr;
2020-11-02 19:00:15 +00:00
int a;;
2020-05-16 10:47:01 +00:00
2021-11-17 23:38:20 +00:00
if (wal == nullptr)
2020-05-16 10:47:01 +00:00
{
for (j = n - 1; j >= 0; j--)
{
a = krand() & 2047;
auto k = EGS(actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - (krand() & (63 << 8)), TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), 1024 - (krand() & 2047), actor, 5);
if (k) k->spr.pal = krand() & 15;
2020-05-16 10:47:01 +00:00
}
return;
}
2021-11-17 22:45:41 +00:00
int x1 = wal->pos.X;
int y1 = wal->pos.Y;
2020-05-16 10:47:01 +00:00
2021-11-17 23:38:20 +00:00
auto delta = wal->delta() / (n + 1);
2020-05-16 10:47:01 +00:00
for (j = n; j > 0; j--)
{
2021-12-22 09:26:51 +00:00
x1 += delta.X;
2021-12-22 09:28:51 +00:00
y1 += delta.Y;
2020-05-16 10:47:01 +00:00
updatesector(x1, y1, &sect);
2021-11-17 23:47:46 +00:00
z = sect->floorz - (krand() & (abs(sect->ceilingz - sect->floorz)));
2020-05-16 10:47:01 +00:00
if (z < -(32 << 8) || z >(32 << 8))
z = actor->spr.pos.Z - (32 << 8) + (krand() & ((64 << 8) - 1));
2021-12-21 20:57:23 +00:00
a = actor->spr.ang - 1024;
auto k = EGS(actor->spr.sector(), x1, y1, z, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, 32 + (krand() & 63), -(krand() & 2047), actor, 5);
if (k) k->spr.pal = krand() & 7;
2020-05-16 10:47:01 +00:00
}
}
2020-05-15 20:59:13 +00:00
END_DUKE_NS