2020-05-05 09:58:39 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
|
|
|
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
|
|
|
|
Copyright (C) 2017-2019 - Nuke.YKT
|
|
|
|
Copyright (C) 2020 - Christoph Oelckers
|
|
|
|
|
|
|
|
This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition
|
|
|
|
|
|
|
|
Duke Nukem 3D is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
Original Source: 1996 - Todd Replogle
|
|
|
|
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
|
|
|
|
|
|
|
EDuke enhancements integrated: 04/13/2003 - Matt Saettler
|
|
|
|
|
|
|
|
Note: EDuke source was in transition. Changes are in-progress in the
|
|
|
|
source as it is released.
|
|
|
|
|
|
|
|
This file is a combination of code from the following sources:
|
|
|
|
- EDuke 2 by Matt Saettler
|
|
|
|
- JFDuke by Jonathon Fowler (jf@jonof.id.au),
|
|
|
|
- DukeGDX and RedneckGDX by Alexander Makarov-[M210] (m210-2007@mail.ru)
|
|
|
|
- Redneck Rampage reconstructed source by Nuke.YKT
|
|
|
|
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "ns.h"
|
|
|
|
#include "global.h"
|
2020-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
|
|
|
|
|
2020-10-21 23:11:38 +00:00
|
|
|
int adjustfall(DDukeActor* s, int c);
|
2020-05-14 07:07:07 +00:00
|
|
|
|
2020-06-30 15:30:48 +00:00
|
|
|
|
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
|
|
|
{
|
2020-07-20 21:21:27 +00:00
|
|
|
int r1 = krand(), r2 = krand(), r3 = krand(), r4 = krand(), r5 = krand(), r6 = krand(), r7 = krand();
|
|
|
|
int v = isRR() ? 16 : 48;
|
2021-12-30 15:51:56 +00:00
|
|
|
EGS(origin->sector(),
|
2021-12-22 11:29:00 +00:00
|
|
|
origin->spr.pos.X + (r7 & 255) - 128, origin->spr.pos.Y + (r6 & 255) - 128, origin->spr.pos.Z - (8 << 8) - (r5 & 8191),
|
2020-10-21 17:14:41 +00:00
|
|
|
TILE_SCRAP6 + (r4 & 15), -8, v, v, r3 & 2047, (r2 & 63) + 64, -512 - (r1 & 2047), origin, 5);
|
2020-07-06 11:26:26 +00:00
|
|
|
}
|
|
|
|
|
2020-06-30 15:30:48 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// wrapper to ensure that if a sound actor is killed, the sound is stopped as well.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 17:14:41 +00:00
|
|
|
void deletesprite(DDukeActor *const actor)
|
2020-06-30 15:30:48 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (actor->spr.picnum == MUSICANDSFX && actor->temp_data[0] == 1)
|
|
|
|
S_StopSound(actor->spr.lotag, actor);
|
2021-12-15 17:51:14 +00:00
|
|
|
|
2021-12-06 16:00:15 +00:00
|
|
|
actor->Destroy();
|
2020-06-30 15:30:48 +00:00
|
|
|
}
|
|
|
|
|
2020-05-05 14:33:23 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 16:42:47 +00:00
|
|
|
void addammo(int weapon, struct player_struct* 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
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 16:42:47 +00:00
|
|
|
void checkavailinven(struct player_struct* 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
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 16:42:47 +00:00
|
|
|
void checkavailweapon(struct player_struct* 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
|
|
|
{
|
2020-10-21 16:42:47 +00:00
|
|
|
fi.addweapon(player, weap);
|
2020-05-05 20:07:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 16:42:47 +00:00
|
|
|
weap = player->curr_weapon;
|
|
|
|
if (player->gotweapon[weap] && player->ammo_amount[weap] > 0)
|
2020-05-05 20:07:54 +00:00
|
|
|
return;
|
|
|
|
|
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
|
|
|
{
|
2021-08-30 06:07:40 +00:00
|
|
|
SetGameVarID(g_iWeaponVarID, player->curr_weapon, player->GetActor(), 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
|
|
|
{
|
2021-12-05 12:43:31 +00:00
|
|
|
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(player->curr_weapon, snum), player->GetActor(), snum);
|
2020-05-05 20:07:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-21 16:42:47 +00:00
|
|
|
SetGameVarID(g_iWorksLikeVarID, -1, player->GetActor(), snum);
|
2020-05-05 20:07:54 +00:00
|
|
|
}
|
2020-11-01 16:57:40 +00:00
|
|
|
OnEvent(EVENT_CHANGEWEAPON, snum, player->GetActor(), -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
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void clearcamera(player_struct* ps)
|
|
|
|
{
|
2020-11-02 23:20:51 +00:00
|
|
|
ps->newOwner = nullptr;
|
2021-12-22 11:40:42 +00:00
|
|
|
ps->pos.X = ps->opos.X;
|
2021-12-22 11:42:06 +00:00
|
|
|
ps->pos.Y = ps->opos.Y;
|
2021-12-22 11:44:17 +00:00
|
|
|
ps->pos.Z = ps->opos.Z;
|
2020-10-07 12:13:21 +00:00
|
|
|
ps->angle.restore();
|
2021-12-22 09:40:26 +00:00
|
|
|
updatesector(ps->pos.X, ps->pos.Y, &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
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (k->spr.picnum == TILE_CAMERA1)
|
|
|
|
k->spr.yvel = 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
|
|
|
|
2020-10-24 07:31:15 +00:00
|
|
|
return movesprite_ex(actor,
|
2021-12-21 17:19:45 +00:00
|
|
|
MulScale(actor->spr.xvel, bcos(actor->spr.ang), 14),
|
|
|
|
MulScale(actor->spr.xvel, bsin(actor->spr.ang), 14), actor->spr.zvel,
|
2020-10-24 07:31:15 +00:00
|
|
|
cliptype, c) == kHitNone;
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-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.
|
2021-12-21 17:19:45 +00:00
|
|
|
spriteq[spriteqloc]->spr.xrepeat = 0;
|
2021-12-07 16:09:28 +00:00
|
|
|
deletesprite(spriteq[spriteqloc]);
|
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
|
|
|
}
|
2021-12-21 17:19:45 +00:00
|
|
|
else actor->spr.xrepeat = actor->spr.yrepeat = 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
|
|
|
|
2020-10-24 07:35:43 +00:00
|
|
|
void lotsofstuff(DDukeActor* actor, int n, int 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
|
|
|
{
|
2020-10-24 07:35:43 +00:00
|
|
|
int r1 = krand(), r2 = krand(); // using the RANDCORRECT version from RR.
|
2021-12-30 15:51:56 +00:00
|
|
|
auto j = EGS(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - (r2 % (47 << 8)), spawntype, -32, 8, 8, r1 & 2047, 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
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// movesector - why is this in actors.cpp?
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-10-24 08:04:10 +00:00
|
|
|
void ms(DDukeActor* const actor)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
|
|
|
//T1,T2 and T3 are used for all the sector moving stuff!!!
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2021-12-22 10:57:10 +00:00
|
|
|
actor->spr.pos.X += MulScale(actor->spr.xvel, bcos(actor->spr.ang), 14);
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.pos.Y += MulScale(actor->spr.xvel, bsin(actor->spr.ang), 14);
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2020-10-24 08:04:10 +00:00
|
|
|
int j = actor->temp_data[1];
|
|
|
|
int k = actor->temp_data[2];
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
for(auto& wal : wallsofsector(actor->sector()))
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
2021-12-17 17:22:42 +00:00
|
|
|
vec2_t t;
|
|
|
|
rotatepoint({ 0, 0 }, { msx[j], msy[j] }, k & 2047, &t);
|
2020-05-05 22:08:08 +00:00
|
|
|
|
2021-12-22 11:17:17 +00:00
|
|
|
dragpoint(&wal, actor->spr.pos.X + t.X, actor->spr.pos.Y + t.Y);
|
2020-05-07 20:30:19 +00:00
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
2020-05-06 14:10:44 +00:00
|
|
|
|
2020-05-06 19:11:36 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void movecyclers(void)
|
|
|
|
{
|
2021-05-11 22:48:41 +00:00
|
|
|
for (int q = numcyclers - 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;
|
|
|
|
int j = shade + bsin(c->lotag, -10);
|
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
|
|
|
{
|
2021-11-07 16:27:05 +00:00
|
|
|
for (auto& wal : wallsofsector(sect))
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void movedummyplayers(void)
|
|
|
|
{
|
2020-10-21 19:14:25 +00:00
|
|
|
int p;
|
2020-05-06 19:11:36 +00:00
|
|
|
|
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;
|
|
|
|
p = act->GetOwner()->PlayerIndex();
|
2020-05-06 19:11:36 +00:00
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
if ((!isRR() && ps[p].on_crane != nullptr) || !ps[p].insector() || ps[p].cursector->lotag != 1 || ps->GetActor()->spr.extra <= 0)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2020-10-25 06:21:33 +00:00
|
|
|
ps[p].dummyplayersprite = nullptr;
|
2020-10-21 19:14:25 +00:00
|
|
|
deletesprite(act);
|
2020-05-06 19:11:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-21 07:56:39 +00:00
|
|
|
if (ps[p].on_ground && ps[p].on_warping_sector == 1 && ps[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;
|
2021-12-30 15:51:56 +00:00
|
|
|
act->spr.pos.Z = act->sector()->ceilingz + (27 << 8);
|
2021-12-21 16:32:28 +00:00
|
|
|
act->spr.ang = ps[p].angle.ang.asbuild();
|
2020-10-24 08:13:21 +00:00
|
|
|
if (act->temp_data[0] == 8)
|
|
|
|
act->temp_data[0] = 0;
|
|
|
|
else act->temp_data[0]++;
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-30 15:51:56 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-22 11:40:42 +00:00
|
|
|
act->spr.pos.X += (ps[p].pos.X - ps[p].opos.X);
|
2021-12-22 11:42:06 +00:00
|
|
|
act->spr.pos.Y += (ps[p].pos.Y - ps[p].opos.Y);
|
2021-12-21 16:32:28 +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
|
|
|
{
|
|
|
|
int otherx;
|
|
|
|
|
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();
|
|
|
|
auto p = &ps[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
|
|
|
{
|
2021-12-22 11:40:42 +00:00
|
|
|
act->spr.pos.X = p->opos.X;
|
2021-12-22 11:42:06 +00:00
|
|
|
act->spr.pos.Y = p->opos.Y;
|
2021-12-22 11:44:17 +00:00
|
|
|
act->spr.pos.Z = p->opos.Z + gs.playerheight;
|
2021-12-30 16:10:08 +00:00
|
|
|
act->backupz();
|
2021-12-21 16:32:28 +00:00
|
|
|
act->spr.ang = p->angle.oang.asbuild();
|
|
|
|
SetActor(act, act->spr.pos);
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ud.multimode > 1)
|
2020-10-21 19:14:25 +00:00
|
|
|
otherp = findotherplayer(pn, &otherx);
|
2020-05-06 19:11:36 +00:00
|
|
|
else
|
|
|
|
{
|
2020-10-21 19:14:25 +00:00
|
|
|
otherp = pn;
|
2020-05-06 19:11:36 +00:00
|
|
|
otherx = 0;
|
|
|
|
}
|
|
|
|
|
2020-10-21 19:14:25 +00:00
|
|
|
execute(act, pn, otherx);
|
2020-05-06 19:11:36 +00:00
|
|
|
|
|
|
|
if (ud.multimode > 1)
|
2020-10-21 19:14:25 +00:00
|
|
|
{
|
|
|
|
auto psp = ps[otherp].GetActor();
|
2021-12-21 17:19:45 +00:00
|
|
|
if (psp->spr.extra > 0)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act->spr.yrepeat > 32 && psp->spr.yrepeat < 32)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
|
|
|
if (otherx < 1400 && p->knee_incs == 0)
|
|
|
|
{
|
|
|
|
p->knee_incs = 1;
|
|
|
|
p->weapon_pos = -1;
|
2020-10-17 08:30:11 +00:00
|
|
|
p->actorsqu = ps[otherp].GetActor();
|
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
|
|
|
{
|
2021-12-22 11:17:17 +00:00
|
|
|
p->angle.addadjustment(getincanglebam(p->angle.ang, bvectangbam(p->actorsqu->spr.pos.X - p->pos.X, p->actorsqu->spr.pos.Y - p->pos.Y)) >> 2);
|
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)
|
2021-12-30 15:51:56 +00:00
|
|
|
if (fi.ceilingspace(act->sector()) || fi.floorspace(act->sector()))
|
2020-05-06 19:11:36 +00:00
|
|
|
quickkill(p);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-22 10:57:10 +00:00
|
|
|
p->pos.X = act->spr.pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
p->pos.Y = act->spr.pos.Y;
|
2021-12-22 11:29:00 +00:00
|
|
|
p->pos.Z = act->spr.pos.Z - (20 << 8);
|
2020-05-06 19:11:36 +00:00
|
|
|
|
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
|
|
|
{
|
2021-12-22 11:17:17 +00:00
|
|
|
p->angle.addadjustment(getincanglebam(p->angle.ang, bvectangbam(p->wackedbyactor->spr.pos.X - p->pos.X, p->wackedbyactor->spr.pos.Y - p->pos.Y)) >> 1);
|
2020-08-05 07:43:06 +00:00
|
|
|
}
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
2021-12-21 16:32:28 +00:00
|
|
|
act->spr.ang = p->angle.ang.asbuild();
|
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
|
|
|
{
|
2020-10-21 19:14:25 +00:00
|
|
|
deletesprite(act);
|
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
|
|
|
|
2021-12-21 16:32:28 +00:00
|
|
|
if (act->spr.xrepeat < 42)
|
2020-05-06 19:11:36 +00:00
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
act->spr.xrepeat += 4;
|
|
|
|
act->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT;
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
2021-12-21 16:32:28 +00:00
|
|
|
else act->spr.xrepeat = 42;
|
|
|
|
if (act->spr.yrepeat < 36)
|
|
|
|
act->spr.yrepeat += 4;
|
2020-05-06 19:11:36 +00:00
|
|
|
else
|
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
act->spr.yrepeat = 36;
|
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);
|
2021-12-30 15:51:56 +00:00
|
|
|
if (act->spr.zvel == 0 && act->sector()->lotag == ST_1_ABOVE_WATER)
|
2021-12-22 11:29:00 +00:00
|
|
|
act->spr.pos.Z += (32 << 8);
|
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
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
act->spr.xvel = 128;
|
|
|
|
act->spr.ang = p->angle.ang.asbuild();
|
|
|
|
act->spr.extra++;
|
2020-10-21 19:14:25 +00:00
|
|
|
ssp(act, CLIPMASK0);
|
2020-05-06 19:11:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
act->spr.ang = 2047 - (p->angle.ang.asbuild());
|
|
|
|
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
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void movefx(void)
|
|
|
|
{
|
2020-10-24 08:30:17 +00:00
|
|
|
int p;
|
2020-05-07 07:49:05 +00:00
|
|
|
int x, ht;
|
|
|
|
|
2020-10-24 08:30:17 +00:00
|
|
|
DukeStatIterator iti(STAT_FX);
|
|
|
|
while (auto act = iti.Next())
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
switch (act->spr.picnum)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
case RESPAWN:
|
2021-12-21 16:32:28 +00:00
|
|
|
if (act->spr.extra == 66)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
auto j = spawn(act, act->spr.hitag);
|
2021-11-19 11:32:12 +00:00
|
|
|
if (isRRRA() && j)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
2020-10-24 08:30:17 +00:00
|
|
|
respawn_rrra(act, j);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-24 08:30:17 +00:00
|
|
|
deletesprite(act);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-21 16:32:28 +00:00
|
|
|
else if (act->spr.extra > (66 - 13))
|
|
|
|
act->spr.extra++;
|
2020-05-07 07:49:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MUSICANDSFX:
|
|
|
|
|
2021-12-21 16:32:28 +00:00
|
|
|
ht = act->spr.hitag;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-10-24 08:21:43 +00:00
|
|
|
if (act->temp_data[1] != (int)SoundEnabled())
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-24 08:21:43 +00:00
|
|
|
act->temp_data[1] = SoundEnabled();
|
|
|
|
act->temp_data[0] = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
|
2021-12-21 16:32:28 +00:00
|
|
|
if (act->spr.lotag >= 1000 && act->spr.lotag < 2000)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-24 08:30:17 +00:00
|
|
|
x = ldist(ps[screenpeek].GetActor(), act);
|
2020-10-24 08:21:43 +00:00
|
|
|
if (x < ht && act->temp_data[0] == 0)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
FX_SetReverb(act->spr.lotag - 1100);
|
2020-10-24 08:21:43 +00:00
|
|
|
act->temp_data[0] = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-10-24 08:21:43 +00:00
|
|
|
if (x >= ht && act->temp_data[0] == 1)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
FX_SetReverb(0);
|
|
|
|
FX_SetReverbDelay(0);
|
2020-10-24 08:21:43 +00:00
|
|
|
act->temp_data[0] = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-30 15:51:56 +00:00
|
|
|
else if (act->spr.lotag < 999 && (unsigned)act->sector()->lotag < ST_9_SLIDING_ST_DOOR && snd_ambience && act->sector()->floorz != act->sector()->ceilingz)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
int flags = S_GetUserFlags(act->spr.lotag);
|
2020-05-07 07:49:05 +00:00
|
|
|
if (flags & SF_MSFX)
|
|
|
|
{
|
2021-12-24 09:53:27 +00:00
|
|
|
int distance = dist(ps[screenpeek].GetActor(), act);
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-24 09:53:27 +00:00
|
|
|
if (distance < ht && act->temp_data[0] == 0)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
// Start playing an ambience sound.
|
2021-12-21 16:32:28 +00:00
|
|
|
S_PlayActorSound(act->spr.lotag, act, CHAN_AUTO, CHANF_LOOP);
|
2020-10-24 08:21:43 +00:00
|
|
|
act->temp_data[0] = 1; // AMBIENT_SFX_PLAYING
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2021-12-24 09:53:27 +00:00
|
|
|
else if (distance >= ht && act->temp_data[0] == 1)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
// Stop playing ambience sound because we're out of its range.
|
2021-12-21 16:32:28 +00:00
|
|
|
S_StopSound(act->spr.lotag, act);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((flags & (SF_GLOBAL | SF_DTAG)) == SF_GLOBAL)
|
|
|
|
{
|
2020-10-24 08:21:43 +00:00
|
|
|
if (act->temp_data[4] > 0) act->temp_data[4]--;
|
2020-05-07 07:49:05 +00:00
|
|
|
else for (p = connecthead; p >= 0; p = connectpoint2[p])
|
2021-12-30 15:51:56 +00:00
|
|
|
if (p == myconnectindex && ps[p].cursector == act->sector())
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
S_PlaySound(act->spr.lotag + (unsigned)global_random % (act->spr.hitag + 1));
|
2020-10-24 08:21:43 +00:00
|
|
|
act->temp_data[4] = 26 * 40 + (global_random % (26 * 40));
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// split out of movestandables
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-24 08:37:20 +00:00
|
|
|
void movecrane(DDukeActor *actor, int crane)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sectp = actor->sector();
|
2020-05-07 07:49:05 +00:00
|
|
|
int x;
|
2021-12-23 15:03:43 +00:00
|
|
|
auto& cpt = cranes[actor->temp_data[4]];
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
//actor->temp_data[0] = state
|
|
|
|
//actor->temp_data[1] = checking sector number
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-21 16:32:28 +00:00
|
|
|
if (actor->spr.xvel) getglobalz(actor);
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 0) //Waiting to check the sector
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-11-18 20:05:27 +00:00
|
|
|
DukeSectIterator it(actor->temp_sect);
|
2020-10-24 08:37:20 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
switch (a2->spr.statnum)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
case STAT_ACTOR:
|
|
|
|
case STAT_ZOMBIEACTOR:
|
|
|
|
case STAT_STANDABLE:
|
|
|
|
case STAT_PLAYER:
|
2021-12-30 11:31:36 +00:00
|
|
|
actor->spr.ang = getangle(cpt.pole.X - actor->spr.pos.X, cpt.pole.Y - actor->spr.pos.Y);
|
|
|
|
SetActor(a2, { cpt.pole.X, cpt.pole.Y, a2->spr.pos.Z });
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2020-05-07 07:49:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (actor->temp_data[0] == 1)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
if (actor->spr.xvel < 184)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
actor->spr.picnum = crane + 1;
|
|
|
|
actor->spr.xvel += 8;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
//IFMOVING; // JBF 20040825: see my rant above about this
|
2020-10-24 08:37:20 +00:00
|
|
|
ssp(actor, CLIPMASK0);
|
2021-12-30 15:51:56 +00:00
|
|
|
if (actor->sector() == actor->temp_sect)
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (actor->temp_data[0] == 2 || actor->temp_data[0] == 7)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z += (1024 + 512);
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 2)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
if ((sectp->floorz - actor->spr.pos.Z) < (64 << 8))
|
2021-12-21 16:32:28 +00:00
|
|
|
if (actor->spr.picnum > crane) actor->spr.picnum--;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
if ((sectp->floorz - actor->spr.pos.Z) < (4096 + 1024))
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 7)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
if ((sectp->floorz - actor->spr.pos.Z) < (64 << 8))
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
if (actor->spr.picnum > crane) actor->spr.picnum--;
|
2020-05-07 07:49:05 +00:00
|
|
|
else
|
|
|
|
{
|
2020-10-24 08:37:20 +00:00
|
|
|
if (actor->IsActiveCrane())
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-24 08:37:20 +00:00
|
|
|
int p = findplayer(actor, &x);
|
|
|
|
S_PlayActorSound(isRR() ? 390 : DUKE_GRUNT, ps[p].GetActor());
|
|
|
|
if (ps[p].on_crane == actor)
|
2020-10-17 08:44:00 +00:00
|
|
|
ps[p].on_crane = nullptr;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2020-11-04 20:25:59 +00:00
|
|
|
actor->SetActiveCrane(false);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (actor->temp_data[0] == 3)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
actor->spr.picnum++;
|
|
|
|
if (actor->spr.picnum == (crane + 2))
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-11-18 20:05:27 +00:00
|
|
|
int p = checkcursectnums(actor->temp_sect);
|
2020-05-07 07:49:05 +00:00
|
|
|
if (p >= 0 && ps[p].on_ground)
|
|
|
|
{
|
2020-10-24 08:37:20 +00:00
|
|
|
actor->SetActiveCrane(true);
|
|
|
|
ps[p].on_crane = actor;
|
|
|
|
S_PlayActorSound(isRR() ? 390 : DUKE_GRUNT, ps[p].GetActor());
|
2021-12-21 16:32:28 +00:00
|
|
|
ps[p].angle.settarget(actor->spr.ang + 1024);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-18 20:05:27 +00:00
|
|
|
DukeSectIterator it(actor->temp_sect);
|
2020-10-24 08:37:20 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
switch (a2->spr.statnum)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 6:
|
2020-10-24 08:37:20 +00:00
|
|
|
actor->SetOwner(a2);
|
2020-05-07 07:49:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;//Grabbed the sprite
|
|
|
|
actor->temp_data[2] = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (actor->temp_data[0] == 4) //Delay before going up
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2]++;
|
|
|
|
if (actor->temp_data[2] > 10)
|
|
|
|
actor->temp_data[0]++;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (actor->temp_data[0] == 5 || actor->temp_data[0] == 8)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 8 && actor->spr.picnum < (crane + 2))
|
2021-12-22 11:29:00 +00:00
|
|
|
if ((sectp->floorz - actor->spr.pos.Z) > 8192)
|
2021-12-21 16:32:28 +00:00
|
|
|
actor->spr.picnum++;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-30 11:29:46 +00:00
|
|
|
if (actor->spr.pos.Z < cpt.pos.Z)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2021-12-21 16:32:28 +00:00
|
|
|
actor->spr.xvel = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
else
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z -= (1024 + 512);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (actor->temp_data[0] == 6)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
if (actor->spr.xvel < 192)
|
|
|
|
actor->spr.xvel += 8;
|
2021-12-30 11:28:48 +00:00
|
|
|
actor->spr.ang = getangle(cpt.pos.X - actor->spr.pos.X, cpt.pos.Y - actor->spr.pos.Y);
|
2020-10-24 08:37:20 +00:00
|
|
|
ssp(actor, CLIPMASK0);
|
2021-12-30 11:28:48 +00:00
|
|
|
if (((actor->spr.pos.X - cpt.pos.X) * (actor->spr.pos.X - cpt.pos.X) + (actor->spr.pos.Y - cpt.pos.Y) * (actor->spr.pos.Y - cpt.pos.Y)) < (128 * 128))
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (actor->temp_data[0] == 9)
|
|
|
|
actor->temp_data[0] = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-07 16:09:28 +00:00
|
|
|
if (cpt.poleactor)
|
2021-12-22 11:29:00 +00:00
|
|
|
SetActor(cpt.poleactor, { actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - (34 << 8) });
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-10-24 08:37:20 +00:00
|
|
|
auto Owner = actor->GetOwner();
|
2020-11-04 20:25:59 +00:00
|
|
|
if (Owner != nullptr || actor->IsActiveCrane())
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-24 08:37:20 +00:00
|
|
|
int p = findplayer(actor, &x);
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-10-21 19:41:14 +00:00
|
|
|
int j = fi.ifhitbyweapon(actor);
|
2020-05-07 07:49:05 +00:00
|
|
|
if (j >= 0)
|
|
|
|
{
|
2020-10-24 08:37:20 +00:00
|
|
|
if (actor->IsActiveCrane())
|
|
|
|
if (ps[p].on_crane == actor)
|
2020-10-17 08:44:00 +00:00
|
|
|
ps[p].on_crane = nullptr;
|
2020-10-24 08:37:20 +00:00
|
|
|
actor->SetActiveCrane(false);
|
2021-12-21 16:32:28 +00:00
|
|
|
actor->spr.picnum = crane;
|
2020-05-07 07:49:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-04 20:25:59 +00:00
|
|
|
if (Owner != nullptr)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:32:28 +00:00
|
|
|
SetActor(Owner, actor->spr.pos);
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-30 17:21:02 +00:00
|
|
|
Owner->opos = actor->spr.pos;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-21 16:32:28 +00:00
|
|
|
actor->spr.zvel = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-10-24 08:37:20 +00:00
|
|
|
else if (actor->IsActiveCrane())
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-07 12:13:21 +00:00
|
|
|
auto ang = ps[p].angle.ang.asbuild();
|
2021-12-22 11:40:42 +00:00
|
|
|
ps[p].opos.X = ps[p].pos.X;
|
2021-12-22 11:42:06 +00:00
|
|
|
ps[p].opos.Y = ps[p].pos.Y;
|
2021-12-22 11:44:17 +00:00
|
|
|
ps[p].opos.Z = ps[p].pos.Z;
|
2021-12-22 10:57:10 +00:00
|
|
|
ps[p].pos.X = actor->spr.pos.X - bcos(ang, -6);
|
2021-12-22 11:17:17 +00:00
|
|
|
ps[p].pos.Y = actor->spr.pos.Y - bsin(ang, -6);
|
2021-12-22 11:29:00 +00:00
|
|
|
ps[p].pos.Z = actor->spr.pos.Z + (2 << 8);
|
2021-11-26 20:52:01 +00:00
|
|
|
SetActor(ps[p].GetActor(), ps[p].pos);
|
2021-12-30 15:51:56 +00:00
|
|
|
ps[p].setCursector(ps[p].GetActor()->sector());
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 19:46:39 +00:00
|
|
|
void movefountain(DDukeActor *actor, int fountain)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
int x;
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] > 0)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] < 20)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2020-10-21 19:46:39 +00:00
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
actor->spr.picnum++;
|
2020-10-21 19:46:39 +00:00
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
if (actor->spr.picnum == fountain + 3)
|
|
|
|
actor->spr.picnum = fountain + 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-21 19:46:39 +00:00
|
|
|
findplayer(actor, &x);
|
2020-05-07 07:49:05 +00:00
|
|
|
|
|
|
|
if (x > 512)
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 0;
|
2021-12-21 17:19:45 +00:00
|
|
|
actor->spr.picnum = fountain;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else actor->temp_data[0] = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 19:46:39 +00:00
|
|
|
void moveflammable(DDukeActor* actor, int tire, int box, int pool)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
int j;
|
2020-10-24 20:18:05 +00:00
|
|
|
if (actor->temp_data[0] == 1)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-24 20:18:05 +00:00
|
|
|
actor->temp_data[1]++;
|
|
|
|
if ((actor->temp_data[1] & 3) > 0) return;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-21 16:39:25 +00:00
|
|
|
if (!isRR() && actor->spr.picnum == tire && actor->temp_data[1] == 32)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
actor->spr.cstat = 0;
|
2020-10-21 19:46:39 +00:00
|
|
|
auto spawned = spawn(actor, pool);
|
2021-12-21 17:19:45 +00:00
|
|
|
if (spawned) spawned->spr.shade = 127;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.shade < 64) actor->spr.shade++;
|
2020-05-07 07:49:05 +00:00
|
|
|
else
|
|
|
|
{
|
2020-10-21 19:46:39 +00:00
|
|
|
deletesprite(actor);
|
2020-05-07 07:49:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-21 16:39:25 +00:00
|
|
|
j = actor->spr.xrepeat - (krand() & 7);
|
2020-10-12 20:05:22 +00:00
|
|
|
if (j < 10)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-21 19:46:39 +00:00
|
|
|
deletesprite(actor);
|
2020-05-07 07:49:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-21 16:39:25 +00:00
|
|
|
actor->spr.xrepeat = j;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-21 16:39:25 +00:00
|
|
|
j = actor->spr.yrepeat - (krand() & 7);
|
2020-10-12 20:05:22 +00:00
|
|
|
if (j < 4)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-21 19:46:39 +00:00
|
|
|
deletesprite(actor);
|
2020-05-07 07:49:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-21 16:39:25 +00:00
|
|
|
actor->spr.yrepeat = j;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2021-12-21 16:39:25 +00:00
|
|
|
if (box >= 0 && actor->spr.picnum == box)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-21 19:46:39 +00:00
|
|
|
makeitfall(actor);
|
2021-12-30 15:51:56 +00:00
|
|
|
actor->ceilingz = actor->sector()->ceilingz;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-12 20:05:22 +00:00
|
|
|
|
2020-05-07 07:49:05 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 19:57:18 +00:00
|
|
|
void detonate(DDukeActor *actor, int explosion)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
earthquaketime = 16;
|
|
|
|
|
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
|
|
|
{
|
2020-10-24 20:23:12 +00:00
|
|
|
if (effector->temp_data[0] == 0)
|
|
|
|
effector->temp_data[0] = 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)
|
2020-10-24 20:23:12 +00:00
|
|
|
effector->temp_data[0] = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z -= (32 << 8);
|
2020-05-07 20:30:19 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if ((actor->temp_data[3] == 1 && actor->spr.xrepeat) || 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);
|
2020-11-29 12:54:58 +00:00
|
|
|
fi.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
|
|
|
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.xrepeat)
|
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
|
|
|
|
2020-10-21 19:57:18 +00:00
|
|
|
deletesprite(actor);
|
2020-05-07 20:30:19 +00:00
|
|
|
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 19:57:18 +00:00
|
|
|
void movemasterswitch(DDukeActor *actor, int spectype1, int spectype2)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.yvel == 1)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
actor->spr.hitag--;
|
|
|
|
if (actor->spr.hitag <= 0)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
operatesectors(actor->sector(), actor);
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-11-21 00:04:16 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 19:57:18 +00:00
|
|
|
while (auto effector = it.Next())
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (effector->spr.statnum == STAT_EFFECTOR)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
switch (effector->spr.lotag)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
|
|
|
case SE_2_EARTHQUAKE:
|
|
|
|
case SE_21_DROP_FLOOR:
|
|
|
|
case SE_31_FLOOR_RISE_FALL:
|
|
|
|
case SE_32_CEILING_RISE_FALL:
|
|
|
|
case SE_36_PROJ_SHOOTER:
|
2020-10-21 19:57:18 +00:00
|
|
|
effector->temp_data[0] = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
break;
|
|
|
|
case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT:
|
2020-10-21 19:57:18 +00:00
|
|
|
effector->temp_data[4] = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-12-21 16:39:25 +00:00
|
|
|
else if (effector->spr.statnum == STAT_STANDABLE)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (effector->spr.picnum == spectype1 || effector->spr.picnum == spectype2) // SEENINE and OOZFILTER
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
effector->spr.shade = -31;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-04 11:01:32 +00:00
|
|
|
// we cannot delete this because it may be used as a sound source.
|
|
|
|
// This originally depended on undefined behavior as the deleted sprite was still used for the sound
|
|
|
|
// with no checking if it got reused in the mean time.
|
2021-12-21 16:39:25 +00:00
|
|
|
actor->spr.picnum = 0; // give it a picnum without any behavior attached, just in case
|
|
|
|
actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
|
|
|
|
actor->spr.cstat2 |= CSTAT2_SPRITE_NOFIND;
|
2021-11-26 20:52:01 +00:00
|
|
|
ChangeActorStat(actor, STAT_REMOVED);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 20:17:25 +00:00
|
|
|
void movetrash(DDukeActor *actor)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.xvel == 0) actor->spr.xvel = 1;
|
2020-10-21 20:17:25 +00:00
|
|
|
if (ssp(actor, CLIPMASK0))
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-21 20:17:25 +00:00
|
|
|
makeitfall(actor);
|
2021-12-21 16:39:25 +00:00
|
|
|
if (krand() & 1) actor->spr.zvel -= 256;
|
|
|
|
if (abs(actor->spr.xvel) < 48)
|
|
|
|
actor->spr.xvel += (krand() & 3);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-10-21 20:17:25 +00:00
|
|
|
else deletesprite(actor);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 20:17:25 +00:00
|
|
|
void movewaterdrip(DDukeActor *actor, int drip)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[1])
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1]--;
|
|
|
|
if (actor->temp_data[1] == 0)
|
2021-12-21 16:39:25 +00:00
|
|
|
actor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-21 20:17:25 +00:00
|
|
|
makeitfall(actor);
|
|
|
|
ssp(actor, CLIPMASK0);
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.xvel > 0) actor->spr.xvel -= 2;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.zvel == 0)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.pal != 2 && (isRR() || actor->spr.hitag == 0))
|
2020-10-21 20:17:25 +00:00
|
|
|
S_PlayActorSound(SOMETHING_DRIPPING, actor);
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-10-21 20:17:25 +00:00
|
|
|
auto Owner = actor->GetOwner();
|
2021-12-21 16:39:25 +00:00
|
|
|
if (!Owner || Owner->spr.picnum != drip)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-21 20:17:25 +00:00
|
|
|
deletesprite(actor);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->spr.pos.Z = actor->temp_data[0];
|
2021-12-30 16:10:08 +00:00
|
|
|
actor->backupz();
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1] = 48 + (krand() & 31);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 20:17:25 +00:00
|
|
|
void movedoorshock(DDukeActor* actor)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sectp = actor->sector();
|
2021-11-06 21:45:02 +00:00
|
|
|
int j = abs(sectp->ceilingz - sectp->floorz) >> 9;
|
2021-12-21 16:39:25 +00:00
|
|
|
actor->spr.yrepeat = j + 4;
|
|
|
|
actor->spr.xrepeat = 16;
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z = sectp->floorz;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 20:22:12 +00:00
|
|
|
void movetouchplate(DDukeActor* actor, int plate)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sectp = actor->sector();
|
2020-05-07 07:49:05 +00:00
|
|
|
int x;
|
|
|
|
int p;
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[1] == 1 && actor->spr.hitag >= 0) //Move the sector floor
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-11-06 21:45:02 +00:00
|
|
|
x = sectp->floorz;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[3] == 1)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (x >= actor->temp_data[2])
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sectp->setfloorz(x);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1] = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sectp->addfloorz(sectp->extra);
|
2021-12-30 15:51:56 +00:00
|
|
|
p = checkcursectnums(actor->sector());
|
2021-12-22 09:41:47 +00:00
|
|
|
if (p >= 0) ps[p].pos.Z += sectp->extra;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
if (x <= actor->spr.pos.Z)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sectp->setfloorz(actor->spr.pos.Z);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1] = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sectp->addfloorz(-sectp->extra);
|
2021-12-30 15:51:56 +00:00
|
|
|
p = checkcursectnums(actor->sector());
|
2020-05-07 07:49:05 +00:00
|
|
|
if (p >= 0)
|
2021-12-22 09:41:47 +00:00
|
|
|
ps[p].pos.Z -= sectp->extra;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[5] == 1) return;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
p = checkcursectnums(actor->sector());
|
2021-12-21 16:39:25 +00:00
|
|
|
if (p >= 0 && (ps[p].on_ground || actor->spr.ang == 512))
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 0 && !check_activator_motion(actor->spr.lotag))
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 1;
|
|
|
|
actor->temp_data[1] = 1;
|
|
|
|
actor->temp_data[3] = !actor->temp_data[3];
|
2021-12-21 16:39:25 +00:00
|
|
|
operatemasterswitches(actor->spr.lotag);
|
|
|
|
operateactivators(actor->spr.lotag, p);
|
|
|
|
if (actor->spr.hitag > 0)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
actor->spr.hitag--;
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->spr.hitag == 0) actor->temp_data[5] = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else actor->temp_data[0] = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[1] == 1)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-21 20:22:12 +00:00
|
|
|
DukeStatIterator it(STAT_STANDABLE);
|
|
|
|
while (auto act2 = it.Next())
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (act2 != actor && act2->spr.picnum == plate && act2->spr.lotag == actor->spr.lotag)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-10-21 20:22:12 +00:00
|
|
|
act2->temp_data[1] = 1;
|
2021-12-23 15:03:43 +00:00
|
|
|
act2->temp_data[3] = actor->temp_data[3];
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 20:22:12 +00:00
|
|
|
void moveooz(DDukeActor* actor, int seenine, int seeninedead, int ooz, int explosion)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2020-05-07 20:30:19 +00:00
|
|
|
int j;
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.shade != -32 && actor->spr.shade != -33)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.xrepeat)
|
2020-10-21 20:22:12 +00:00
|
|
|
j = (fi.ifhitbyweapon(actor) >= 0);
|
2020-05-07 20:30:19 +00:00
|
|
|
else
|
|
|
|
j = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-21 16:39:25 +00:00
|
|
|
if (j || actor->spr.shade == -31)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (j) actor->spr.lotag = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[3] = 1;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-10-21 20:22:12 +00:00
|
|
|
DukeStatIterator it(STAT_STANDABLE);
|
|
|
|
while (auto act2 = it.Next())
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.hitag == act2->spr.hitag && (act2->spr.picnum == seenine || act2->spr.picnum == ooz))
|
|
|
|
act2->spr.shade = -32;
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.shade == -32)
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.lotag > 0)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
actor->spr.lotag -= 3;
|
|
|
|
if (actor->spr.lotag <= 0) actor->spr.lotag = -99;
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
|
|
|
else
|
2021-12-21 16:39:25 +00:00
|
|
|
actor->spr.shade = -33;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
else
|
2020-05-07 07:49:05 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.xrepeat > 0)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
2020-10-21 20:22:12 +00:00
|
|
|
actor->temp_data[2]++;
|
|
|
|
if (actor->temp_data[2] == 3)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.picnum == ooz)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
2020-10-21 20:22:12 +00:00
|
|
|
actor->temp_data[2] = 0;
|
|
|
|
detonate(actor, explosion);
|
2020-05-07 20:30:19 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.picnum != (seeninedead + 1))
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
2020-10-21 20:22:12 +00:00
|
|
|
actor->temp_data[2] = 0;
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-21 16:39:25 +00:00
|
|
|
if (actor->spr.picnum == seeninedead) actor->spr.picnum++;
|
|
|
|
else if (actor->spr.picnum == seenine)
|
|
|
|
actor->spr.picnum = seeninedead;
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-21 20:22:12 +00:00
|
|
|
detonate(actor, explosion);
|
2020-05-07 20:30:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2020-10-21 20:22:12 +00:00
|
|
|
detonate(actor, explosion);
|
2020-05-07 20:30:19 +00:00
|
|
|
return;
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
2020-05-07 20:30:19 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-05-07 20:30:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2020-10-21 20:22:12 +00:00
|
|
|
void movecanwithsomething(DDukeActor* actor)
|
2020-05-07 20:30:19 +00:00
|
|
|
{
|
2020-10-21 20:22:12 +00:00
|
|
|
makeitfall(actor);
|
|
|
|
int j = fi.ifhitbyweapon(actor);
|
2020-05-07 20:30:19 +00:00
|
|
|
if (j >= 0)
|
|
|
|
{
|
2020-10-21 20:22:12 +00:00
|
|
|
S_PlayActorSound(VENT_BUST, actor);
|
2020-05-07 20:30:19 +00:00
|
|
|
for (j = 0; j < 10; j++)
|
2020-10-21 20:22:12 +00:00
|
|
|
RANDOMSCRAP(actor);
|
2020-05-07 07:49:05 +00:00
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
if (actor->spr.lotag) spawn(actor, actor->spr.lotag);
|
2020-10-21 20:22:12 +00:00
|
|
|
deletesprite(actor);
|
2020-05-07 07:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-07 12:38:01 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 20:29:35 +00:00
|
|
|
void bounce(DDukeActor* actor)
|
2020-05-07 12:38:01 +00:00
|
|
|
{
|
2021-12-21 17:17:12 +00:00
|
|
|
int xvect = MulScale(actor->spr.xvel, bcos(actor->spr.ang), 10);
|
|
|
|
int yvect = MulScale(actor->spr.xvel, bsin(actor->spr.ang), 10);
|
|
|
|
int zvect = actor->spr.zvel;
|
2020-05-07 12:38:01 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sectp = actor->sector();
|
2020-05-07 12:38:01 +00:00
|
|
|
|
2021-11-24 15:34:21 +00:00
|
|
|
int daang = getangle(sectp->firstWall()->delta());
|
2020-05-07 12:38:01 +00:00
|
|
|
|
2021-11-15 21:53:16 +00:00
|
|
|
int k, l;
|
2021-12-22 11:29:00 +00:00
|
|
|
if (actor->spr.pos.Z < (actor->floorz + actor->ceilingz) >> 1)
|
2021-11-06 21:45:02 +00:00
|
|
|
k = sectp->ceilingheinum;
|
2020-05-07 12:38:01 +00:00
|
|
|
else
|
2021-11-06 21:45:02 +00:00
|
|
|
k = sectp->floorheinum;
|
2020-05-07 12:38:01 +00:00
|
|
|
|
2021-01-04 11:36:54 +00:00
|
|
|
int dax = MulScale(k, bsin(daang), 14);
|
|
|
|
int day = MulScale(k, -bcos(daang), 14);
|
2020-10-21 20:29:35 +00:00
|
|
|
int daz = 4096;
|
2020-05-07 12:38:01 +00:00
|
|
|
|
|
|
|
k = xvect * dax + yvect * day + zvect * daz;
|
|
|
|
l = dax * dax + day * day + daz * daz;
|
|
|
|
if ((abs(k) >> 14) < l)
|
|
|
|
{
|
2021-01-04 11:51:41 +00:00
|
|
|
k = DivScale(k, l, 17);
|
2021-01-04 11:36:54 +00:00
|
|
|
xvect -= MulScale(dax, k, 16);
|
|
|
|
yvect -= MulScale(day, k, 16);
|
|
|
|
zvect -= MulScale(daz, k, 16);
|
2020-05-07 12:38:01 +00:00
|
|
|
}
|
|
|
|
|
2021-12-21 17:17:12 +00:00
|
|
|
actor->spr.zvel = zvect;
|
|
|
|
actor->spr.xvel = ksqrt(DMulScale(xvect, xvect, yvect, yvect, 8));
|
|
|
|
actor->spr.ang = getangle(xvect, yvect);
|
2020-05-07 12:38:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2020-05-07 20:30:19 +00:00
|
|
|
// taken out of moveweapon
|
2020-05-07 12:38:01 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 20:29:35 +00:00
|
|
|
void movetongue(DDukeActor *actor, int tongue, int jaw)
|
2020-05-07 12:38:01 +00:00
|
|
|
{
|
2020-11-14 09:49:46 +00:00
|
|
|
actor->temp_data[0] = bsin(actor->temp_data[1], -9);
|
2020-10-21 20:29:35 +00:00
|
|
|
actor->temp_data[1] += 32;
|
|
|
|
if (actor->temp_data[1] > 2047)
|
2020-05-07 12:38:01 +00:00
|
|
|
{
|
2020-10-21 20:29:35 +00:00
|
|
|
deletesprite(actor);
|
2020-05-07 12:38:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-21 20:29:35 +00:00
|
|
|
auto Owner = actor->GetOwner();
|
|
|
|
if (!Owner) return;
|
|
|
|
|
2021-12-21 17:17:12 +00:00
|
|
|
if (Owner->spr.statnum == MAXSTATUS)
|
2020-10-21 20:29:35 +00:00
|
|
|
if (badguy(Owner) == 0)
|
2020-05-07 12:38:01 +00:00
|
|
|
{
|
2020-10-21 20:29:35 +00:00
|
|
|
deletesprite(actor);
|
2020-05-07 12:38:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-21 17:17:12 +00:00
|
|
|
actor->spr.ang = Owner->spr.ang;
|
2021-12-22 10:57:10 +00:00
|
|
|
actor->spr.pos.X = Owner->spr.pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.pos.Y = Owner->spr.pos.Y;
|
2021-12-31 17:47:00 +00:00
|
|
|
if (Owner->isPlayer())
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z = Owner->spr.pos.Z - (34 << 8);
|
2020-10-21 20:29:35 +00:00
|
|
|
for (int k = 0; k < actor->temp_data[0]; k++)
|
2020-05-07 12:38:01 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto q = EGS(actor->sector(),
|
2021-12-22 10:57:10 +00:00
|
|
|
actor->spr.pos.X + MulScale(k, bcos(actor->spr.ang), 9),
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.pos.Y + MulScale(k, bsin(actor->spr.ang), 9),
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z + ((k * Sgn(actor->spr.zvel)) * abs(actor->spr.zvel / 12)), tongue, -40 + (k << 1),
|
2020-10-21 20:29:35 +00:00
|
|
|
8, 8, 0, 0, 0, actor, 5);
|
|
|
|
if (q)
|
|
|
|
{
|
2021-12-21 17:17:12 +00:00
|
|
|
q->spr.cstat = CSTAT_SPRITE_YCENTER;
|
|
|
|
q->spr.pal = 8;
|
2020-10-21 20:29:35 +00:00
|
|
|
}
|
2020-05-07 12:38:01 +00:00
|
|
|
}
|
2020-10-21 20:29:35 +00:00
|
|
|
int k = actor->temp_data[0]; // do not depend on the above loop counter.
|
2021-12-30 15:51:56 +00:00
|
|
|
auto spawned = EGS(actor->sector(),
|
2021-12-22 10:57:10 +00:00
|
|
|
actor->spr.pos.X + MulScale(k, bcos(actor->spr.ang), 9),
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.pos.Y + MulScale(k, bsin(actor->spr.ang), 9),
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z + ((k * Sgn(actor->spr.zvel)) * abs(actor->spr.zvel / 12)), jaw, -40,
|
2020-10-21 20:29:35 +00:00
|
|
|
32, 32, 0, 0, 0, actor, 5);
|
|
|
|
if (spawned)
|
|
|
|
{
|
2021-12-21 17:17:12 +00:00
|
|
|
spawned->spr.cstat = CSTAT_SPRITE_YCENTER;
|
2020-10-21 20:29:35 +00:00
|
|
|
if (actor->temp_data[1] > 512 && actor->temp_data[1] < (1024))
|
2021-12-21 17:17:12 +00:00
|
|
|
spawned->spr.picnum = jaw + 1;
|
2020-10-21 20:29:35 +00:00
|
|
|
}
|
2020-05-07 12:38:01 +00:00
|
|
|
}
|
|
|
|
|
2020-05-08 22:34:48 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2020-10-18 08:42:26 +00:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 20:29:35 +00:00
|
|
|
void rpgexplode(DDukeActor *actor, int hit, const vec3_t &pos, int EXPLOSION2, int EXPLOSION2BOT, int newextra, int playsound)
|
2020-10-18 08:42:26 +00:00
|
|
|
{
|
2020-10-21 20:29:35 +00:00
|
|
|
auto explosion = spawn(actor, EXPLOSION2);
|
2021-11-19 11:32:12 +00:00
|
|
|
if (!explosion) return;
|
2021-12-21 17:19:45 +00:00
|
|
|
explosion->spr.pos = pos;
|
2020-10-18 08:42:26 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xrepeat < 10)
|
2020-10-18 08:42:26 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
explosion->spr.xrepeat = 6;
|
|
|
|
explosion->spr.yrepeat = 6;
|
2020-10-18 08:42:26 +00:00
|
|
|
}
|
2020-10-22 19:19:24 +00:00
|
|
|
else if (hit == kHitSector)
|
2020-10-18 08:42:26 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel > 0 && EXPLOSION2BOT >= 0)
|
2020-10-21 20:29:35 +00:00
|
|
|
spawn(actor, EXPLOSION2BOT);
|
2020-10-24 17:44:10 +00:00
|
|
|
else
|
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
explosion->spr.cstat |= CSTAT_SPRITE_YFLIP;
|
2021-12-22 11:29:00 +00:00
|
|
|
explosion->spr.pos.Z += (48 << 8);
|
2020-10-24 17:44:10 +00:00
|
|
|
}
|
2020-10-18 08:42:26 +00:00
|
|
|
}
|
2021-12-21 17:29:44 +00:00
|
|
|
if (newextra > 0) actor->spr.extra = newextra;
|
2020-10-21 20:29:35 +00:00
|
|
|
S_PlayActorSound(playsound, actor);
|
2020-10-18 08:42:26 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xrepeat >= 10)
|
2020-10-18 08:42:26 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
int x = actor->spr.extra;
|
2020-11-29 12:54:58 +00:00
|
|
|
fi.hitradius(actor, gs.rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x);
|
2020-10-18 08:42:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
int x = actor->spr.extra + (global_random & 3);
|
2020-11-29 12:54:58 +00:00
|
|
|
fi.hitradius(actor, (gs.rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x);
|
2020-10-18 08:42:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2020-05-08 22:34:48 +00:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 20:34:45 +00:00
|
|
|
bool respawnmarker(DDukeActor *actor, int yellow, int green)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 20:34:45 +00:00
|
|
|
actor->temp_data[0]++;
|
2020-11-29 12:54:58 +00:00
|
|
|
if (actor->temp_data[0] > gs.respawnitemtime)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 20:34:45 +00:00
|
|
|
deletesprite(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-11-29 12:54:58 +00:00
|
|
|
if (actor->temp_data[0] >= (gs.respawnitemtime >> 1) && actor->temp_data[0] < ((gs.respawnitemtime >> 1) + (gs.respawnitemtime >> 2)))
|
2021-12-21 17:19:45 +00:00
|
|
|
actor->spr.picnum = yellow;
|
2020-11-29 12:54:58 +00:00
|
|
|
else if (actor->temp_data[0] > ((gs.respawnitemtime >> 1) + (gs.respawnitemtime >> 2)))
|
2021-12-21 17:19:45 +00:00
|
|
|
actor->spr.picnum = green;
|
2020-10-21 20:34:45 +00:00
|
|
|
makeitfall(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 20:34:45 +00:00
|
|
|
bool rat(DDukeActor* actor, bool makesound)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 20:34:45 +00:00
|
|
|
makeitfall(actor);
|
|
|
|
if (ssp(actor, CLIPMASK0))
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 20:34:45 +00:00
|
|
|
if (makesound && (krand() & 255) == 0) S_PlayActorSound(RATTY, actor);
|
2021-12-21 17:17:12 +00:00
|
|
|
actor->spr.ang += (krand() & 31) - 15 + bsin(actor->temp_data[0] << 8, -11);
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-21 20:34:45 +00:00
|
|
|
actor->temp_data[0]++;
|
|
|
|
if (actor->temp_data[0] > 1)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 20:34:45 +00:00
|
|
|
deletesprite(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
2021-12-21 17:17:12 +00:00
|
|
|
else actor->spr.ang = (krand() & 2047);
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2021-12-21 17:17:12 +00:00
|
|
|
if (actor->spr.xvel < 128)
|
|
|
|
actor->spr.xvel += 2;
|
|
|
|
actor->spr.ang += (krand() & 3) - 6;
|
2020-05-08 22:34:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-06 19:11:36 +00:00
|
|
|
|
2020-10-21 20:34:45 +00:00
|
|
|
bool queball(DDukeActor *actor, int pocket, int queball, int stripeball)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xvel)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 20:34:45 +00:00
|
|
|
DukeStatIterator it(STAT_DEFAULT);
|
|
|
|
while (auto aa = it.Next())
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (aa->spr.picnum == pocket && ldist(aa, actor) < 52)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 20:34:45 +00:00
|
|
|
deletesprite(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 20:43:23 +00:00
|
|
|
Collision coll;
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sect = actor->sector();
|
2021-12-21 17:29:44 +00:00
|
|
|
int j = clipmove(actor->spr.pos, §,
|
|
|
|
(MulScale(actor->spr.xvel, bcos(actor->spr.ang), 14) * TICSPERFRAME) << 11,
|
|
|
|
(MulScale(actor->spr.xvel, bsin(actor->spr.ang), 14) * TICSPERFRAME) << 11,
|
2020-10-21 20:43:23 +00:00
|
|
|
24L, (4 << 8), (4 << 8), CLIPMASK1, coll);
|
2021-12-30 15:36:04 +00:00
|
|
|
actor->setsector(sect);
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2020-10-21 20:43:23 +00:00
|
|
|
if (j == kHitWall)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-11-26 12:41:15 +00:00
|
|
|
int k = getangle(coll.hitWall->delta());
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang = ((k << 1) - actor->spr.ang) & 2047;
|
2021-11-15 21:53:16 +00:00
|
|
|
}
|
2020-10-21 20:43:23 +00:00
|
|
|
else if (j == kHitSprite)
|
2020-10-24 04:33:31 +00:00
|
|
|
{
|
2021-11-26 12:41:15 +00:00
|
|
|
fi.checkhitsprite(actor, coll.actor());
|
2020-10-24 04:33:31 +00:00
|
|
|
}
|
2020-10-21 20:43:23 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xvel--;
|
|
|
|
if (actor->spr.xvel < 0) actor->spr.xvel = 0;
|
|
|
|
if (actor->spr.picnum == stripeball)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
|
|
|
|
actor->spr.cstat |= (CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP) & ESpriteFlags::FromInt(actor->spr.xvel);
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int x;
|
2020-10-21 20:43:23 +00:00
|
|
|
int p = findplayer(actor, &x);
|
2020-05-08 22:34:48 +00:00
|
|
|
|
|
|
|
if (x < 1596)
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
// if(actor->spr.pal == 12)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-22 11:17:17 +00:00
|
|
|
int j = getincangle(ps[p].angle.ang.asbuild(), getangle(actor->spr.pos.X - ps[p].pos.X, actor->spr.pos.Y - ps[p].pos.Y));
|
2020-08-28 20:51:05 +00:00
|
|
|
if (j > -64 && j < 64 && PlayerInput(p, SB_OPEN))
|
2020-05-08 22:34:48 +00:00
|
|
|
if (ps[p].toggle_key_flag == 1)
|
|
|
|
{
|
2020-10-21 20:34:45 +00:00
|
|
|
DukeStatIterator it(STAT_ACTOR);
|
|
|
|
DDukeActor *act2;
|
|
|
|
while ((act2 = it.Next()))
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
if (act2->spr.picnum == queball || act2->spr.picnum == stripeball)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-22 11:17:17 +00:00
|
|
|
j = getincangle(ps[p].angle.ang.asbuild(), getangle(act2->spr.pos.X - ps[p].pos.X, act2->spr.pos.Y - ps[p].pos.Y));
|
2020-05-08 22:34:48 +00:00
|
|
|
if (j > -64 && j < 64)
|
|
|
|
{
|
|
|
|
int l;
|
2020-10-23 15:44:45 +00:00
|
|
|
findplayer(act2, &l);
|
2020-05-08 22:34:48 +00:00
|
|
|
if (x > l) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-21 20:34:45 +00:00
|
|
|
if (act2 == nullptr)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.pal == 12)
|
|
|
|
actor->spr.xvel = 164;
|
|
|
|
else actor->spr.xvel = 140;
|
|
|
|
actor->spr.ang = ps[p].angle.ang.asbuild();
|
2020-05-08 22:34:48 +00:00
|
|
|
ps[p].toggle_key_flag = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-30 15:51:56 +00:00
|
|
|
if (x < 512 && actor->sector() == ps[p].cursector)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.ang = getangle(actor->spr.pos.X - ps[p].pos.X, actor->spr.pos.Y - ps[p].pos.Y);
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xvel = 48;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 20:59:56 +00:00
|
|
|
void forcesphere(DDukeActor* actor, int forcesphere)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sectp = actor->sector();
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.yvel == 0)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.yvel = 1;
|
2020-05-08 22:34:48 +00:00
|
|
|
|
|
|
|
for (int l = 512; l < (2048 - 512); l += 128)
|
|
|
|
for (int j = 0; j < 2048; j += 128)
|
|
|
|
{
|
2020-10-21 20:59:56 +00:00
|
|
|
auto k = spawn(actor, forcesphere);
|
2021-11-19 11:32:12 +00:00
|
|
|
if (k)
|
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
k->spr.cstat = CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_YCENTER;
|
|
|
|
k->spr.clipdist = 64;
|
|
|
|
k->spr.ang = j;
|
|
|
|
k->spr.zvel = bsin(l, -5);
|
|
|
|
k->spr.xvel = bcos(l, -9);
|
2021-11-19 11:32:12 +00:00
|
|
|
k->SetOwner(actor);
|
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[3] > 0)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel < 6144)
|
|
|
|
actor->spr.zvel += 192;
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z += actor->spr.zvel;
|
|
|
|
if (actor->spr.pos.Z > sectp->floorz)
|
|
|
|
actor->spr.pos.Z = sectp->floorz;
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[3]--;
|
|
|
|
if (actor->temp_data[3] == 0)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 20:59:56 +00:00
|
|
|
deletesprite(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (actor->temp_data[2] > 10)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 20:59:56 +00:00
|
|
|
DukeStatIterator it(STAT_MISC);
|
|
|
|
while (auto aa = it.Next())
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (aa->GetOwner() == actor && aa->spr.picnum == forcesphere)
|
2020-10-21 20:59:56 +00:00
|
|
|
aa->temp_data[1] = 1 + (krand() & 63);
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[3] = 64;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 20:59:56 +00:00
|
|
|
void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int painsnd, int roamsnd, int shift, int (*getspawn)(DDukeActor* i))
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sectp = actor->sector();
|
2020-10-21 20:59:56 +00:00
|
|
|
int a;
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2020-10-21 20:59:56 +00:00
|
|
|
getglobalz(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-18 12:14:56 +00:00
|
|
|
if (sectp->ceilingstat & CSTAT_SECTOR_SKY)
|
2021-12-21 17:17:12 +00:00
|
|
|
actor->spr.shade += (sectp->ceilingshade - actor->spr.shade) >> 1;
|
|
|
|
else actor->spr.shade += (sectp->floorshade - actor->spr.shade) >> 1;
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
if (actor->spr.pos.Z < sectp->ceilingz + (32 << 8))
|
|
|
|
actor->spr.pos.Z = sectp->ceilingz + (32 << 8);
|
2020-05-08 22:34:48 +00:00
|
|
|
|
|
|
|
if (ud.multimode < 2)
|
|
|
|
{
|
|
|
|
if (actor_tog == 1)
|
|
|
|
{
|
2021-12-21 17:17:12 +00:00
|
|
|
actor->spr.cstat = CSTAT_SPRITE_INVISIBLE;
|
2020-05-08 22:34:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-21 17:17:12 +00:00
|
|
|
else if (actor_tog == 2) actor->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2020-10-21 20:59:56 +00:00
|
|
|
if (fi.ifhitbyweapon(actor) >= 0)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->spr.extra < 0 && actor->temp_data[0] != -1)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = -1;
|
2021-12-21 17:17:12 +00:00
|
|
|
actor->spr.extra = 0;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2020-10-21 20:59:56 +00:00
|
|
|
if (painsnd >= 0) S_PlayActorSound(painsnd, actor);
|
|
|
|
RANDOMSCRAP(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == -1)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z += 1024;
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2]++;
|
|
|
|
if ((actor->temp_data[2] & 3) == 0) spawn(actor, explosion);
|
2020-10-21 20:59:56 +00:00
|
|
|
getglobalz(actor);
|
2021-12-21 17:17:12 +00:00
|
|
|
actor->spr.ang += 96;
|
|
|
|
actor->spr.xvel = 128;
|
2020-10-21 20:59:56 +00:00
|
|
|
int j = ssp(actor, CLIPMASK0);
|
2021-12-22 11:29:00 +00:00
|
|
|
if (j != 1 || actor->spr.pos.Z > actor->floorz)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
|
|
|
for (int l = 0; l < 16; l++)
|
2020-10-21 20:59:56 +00:00
|
|
|
RANDOMSCRAP(actor);
|
|
|
|
S_PlayActorSound(LASERTRIP_EXPLODE, actor);
|
|
|
|
int sp = getspawn(actor);
|
|
|
|
if (sp >= 0) spawn(actor, sp);
|
2020-05-08 22:34:48 +00:00
|
|
|
ps[myconnectindex].actors_killed++;
|
2020-10-21 20:59:56 +00:00
|
|
|
deletesprite(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
if (actor->spr.pos.Z > actor->floorz - (48 << 8))
|
|
|
|
actor->spr.pos.Z = actor->floorz - (48 << 8);
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int x;
|
2020-10-23 15:44:45 +00:00
|
|
|
int p = findplayer(actor, &x);
|
2020-10-21 20:59:56 +00:00
|
|
|
auto Owner = actor->GetOwner();
|
2020-05-08 22:34:48 +00:00
|
|
|
|
|
|
|
// 3 = findplayerz, 4 = shoot
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] >= 4)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2]++;
|
|
|
|
if ((actor->temp_data[2] & 15) == 0)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 17:17:12 +00:00
|
|
|
a = actor->spr.ang;
|
|
|
|
actor->spr.ang = actor->tempang;
|
2020-10-21 20:59:56 +00:00
|
|
|
if (attacksnd >= 0) S_PlayActorSound(attacksnd, actor);
|
2020-10-24 05:34:39 +00:00
|
|
|
fi.shoot(actor, firelaser);
|
2021-12-21 17:17:12 +00:00
|
|
|
actor->spr.ang = a;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2021-12-30 15:51:56 +00:00
|
|
|
if (actor->temp_data[2] > (26 * 3) || !cansee(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - (16 << 8), actor->sector(), ps[p].pos.X, ps[p].pos.Y, ps[p].pos.Z, ps[p].cursector))
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 0;
|
|
|
|
actor->temp_data[2] = 0;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2020-10-21 20:59:56 +00:00
|
|
|
else actor->tempang +=
|
2021-12-22 11:17:17 +00:00
|
|
|
getincangle(actor->tempang, getangle(ps[p].pos.X - actor->spr.pos.X, ps[p].pos.Y - actor->spr.pos.Y)) / 3;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (actor->temp_data[0] == 2 || actor->temp_data[0] == 3)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[3] = 0;
|
2021-12-21 17:17:12 +00:00
|
|
|
if (actor->spr.xvel > 0) actor->spr.xvel -= 16;
|
|
|
|
else actor->spr.xvel = 0;
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 2)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
int l = ps[p].pos.Z - actor->spr.pos.Z;
|
2021-12-23 15:03:43 +00:00
|
|
|
if (abs(l) < (48 << 8)) actor->temp_data[0] = 3;
|
2021-12-22 11:29:00 +00:00
|
|
|
else actor->spr.pos.Z += Sgn(ps[p].pos.Z - actor->spr.pos.Z) << shift; // The shift here differs between Duke and RR.
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2]++;
|
2021-12-30 15:51:56 +00:00
|
|
|
if (actor->temp_data[2] > (26 * 3) || !cansee(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - (16 << 8), actor->sector(), ps[p].pos.X, ps[p].pos.Y, ps[p].pos.Z, ps[p].cursector))
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 1;
|
|
|
|
actor->temp_data[2] = 0;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else if ((actor->temp_data[2] & 15) == 0 && attacksnd >= 0)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 20:59:56 +00:00
|
|
|
S_PlayActorSound(attacksnd, actor);
|
2020-10-24 05:34:39 +00:00
|
|
|
fi.shoot(actor, firelaser);
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.ang += getincangle(actor->spr.ang, getangle(ps[p].pos.X - actor->spr.pos.X, ps[p].pos.Y - actor->spr.pos.Y)) >> 2;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] != 2 && actor->temp_data[0] != 3 && Owner)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 20:59:56 +00:00
|
|
|
int l = ldist(Owner, actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
if (l <= 1524)
|
|
|
|
{
|
2021-12-21 17:17:12 +00:00
|
|
|
a = actor->spr.ang;
|
|
|
|
actor->spr.xvel >>= 1;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2021-12-22 11:17:17 +00:00
|
|
|
else a = getangle(Owner->spr.pos.X - actor->spr.pos.X, Owner->spr.pos.Y - actor->spr.pos.Y);
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 1 || actor->temp_data[0] == 4) // Found a locator and going with it
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 20:59:56 +00:00
|
|
|
l = dist(Owner, actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (l <= 1524) { if (actor->temp_data[0] == 1) actor->temp_data[0] = 0; else actor->temp_data[0] = 5; }
|
2020-05-08 22:34:48 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Control speed here
|
2021-12-21 17:17:12 +00:00
|
|
|
if (l > 1524) { if (actor->spr.xvel < 256) actor->spr.xvel += 32; }
|
2020-05-08 22:34:48 +00:00
|
|
|
else
|
|
|
|
{
|
2021-12-21 17:17:12 +00:00
|
|
|
if (actor->spr.xvel > 0) actor->spr.xvel -= 16;
|
|
|
|
else actor->spr.xvel = 0;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] < 2) actor->temp_data[2]++;
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (x < 6144 && actor->temp_data[0] < 2 && actor->temp_data[2] > (26 * 4))
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 2 + (krand() & 2);
|
|
|
|
actor->temp_data[2] = 0;
|
2021-12-21 17:17:12 +00:00
|
|
|
actor->tempang = actor->spr.ang;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 0 || actor->temp_data[0] == 5)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 0)
|
|
|
|
actor->temp_data[0] = 1;
|
|
|
|
else actor->temp_data[0] = 4;
|
2021-12-21 17:17:12 +00:00
|
|
|
auto NewOwner = LocateTheLocator(actor->spr.hitag, nullptr);
|
2020-10-21 20:59:56 +00:00
|
|
|
if (!NewOwner)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 17:17:12 +00:00
|
|
|
actor->spr.hitag = actor->temp_data[5];
|
|
|
|
NewOwner = LocateTheLocator(actor->spr.hitag, nullptr);
|
2020-10-21 20:59:56 +00:00
|
|
|
if (!NewOwner)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 20:59:56 +00:00
|
|
|
deletesprite(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-12-21 17:17:12 +00:00
|
|
|
else actor->spr.hitag++;
|
2020-11-01 06:56:49 +00:00
|
|
|
actor->SetOwner(NewOwner);
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[3] = getincangle(actor->spr.ang, a);
|
|
|
|
actor->spr.ang += actor->temp_data[3] >> 3;
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
if (actor->spr.pos.Z < Owner->spr.pos.Z)
|
|
|
|
actor->spr.pos.Z += 1024;
|
|
|
|
else actor->spr.pos.Z -= 1024;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 21:39:12 +00:00
|
|
|
if (roamsnd >= 0 && S_CheckActorSoundPlaying(actor, roamsnd) < 1)
|
2020-10-21 20:59:56 +00:00
|
|
|
S_PlayActorSound(roamsnd, actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2020-10-21 20:59:56 +00:00
|
|
|
ssp(actor, CLIPMASK0);
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:04:14 +00:00
|
|
|
void ooz(DDukeActor *actor)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 21:04:14 +00:00
|
|
|
getglobalz(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2020-10-21 21:04:14 +00:00
|
|
|
int j = (actor->floorz - actor->ceilingz) >> 9;
|
2020-05-08 22:34:48 +00:00
|
|
|
if (j > 255) j = 255;
|
|
|
|
|
|
|
|
int x = 25 - (j >> 1);
|
|
|
|
if (x < 8) x = 8;
|
|
|
|
else if (x > 48) x = 48;
|
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
actor->spr.yrepeat = j;
|
|
|
|
actor->spr.xrepeat = x;
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z = actor->floorz;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-20 23:41:52 +00:00
|
|
|
void reactor(DDukeActor* const actor, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BURNT, int REACTORSPARK, int REACTOR2SPARK)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sectp = actor->sector();
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[4] == 1)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2021-12-21 18:09:05 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
if (a2->spr.picnum == SECTOREFFECTOR)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
if (a2->spr.lotag == 1)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
a2->spr.lotag = -1;
|
|
|
|
a2->spr.hitag = -1;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-21 18:09:05 +00:00
|
|
|
else if (a2->spr.picnum == REACTOR)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
a2->spr.picnum = REACTORBURNT;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2021-12-21 18:09:05 +00:00
|
|
|
else if (a2->spr.picnum == REACTOR2)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
a2->spr.picnum = REACTOR2BURNT;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2021-12-21 18:09:05 +00:00
|
|
|
else if (a2->spr.picnum == REACTORSPARK || a2->spr.picnum == REACTOR2SPARK)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
a2->spr.cstat = CSTAT_SPRITE_INVISIBLE;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2020-10-21 21:04:14 +00:00
|
|
|
}
|
|
|
|
return;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[1] >= 20)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] = 1;
|
2020-05-08 22:34:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int x;
|
2020-10-23 15:44:45 +00:00
|
|
|
int p = findplayer(actor, &x);
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2]++;
|
|
|
|
if (actor->temp_data[2] == 4) actor->temp_data[2] = 0;
|
2020-05-08 22:34:48 +00:00
|
|
|
|
|
|
|
if (x < 4096)
|
|
|
|
{
|
|
|
|
if ((krand() & 255) < 16)
|
|
|
|
{
|
|
|
|
if (!S_CheckSoundPlaying(DUKE_LONGTERM_PAIN))
|
2020-10-21 21:04:14 +00:00
|
|
|
S_PlayActorSound(DUKE_LONGTERM_PAIN, ps[p].GetActor());
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2020-10-21 21:04:14 +00:00
|
|
|
S_PlayActorSound(SHORT_CIRCUIT, actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
ps[p].GetActor()->spr.extra--;
|
2020-05-08 22:34:48 +00:00
|
|
|
SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0));
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] += 128;
|
|
|
|
if (actor->temp_data[3] == 0)
|
|
|
|
actor->temp_data[3] = 1;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else actor->temp_data[3] = 0;
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[1])
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1]++;
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] = actor->spr.pos.Z;
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z = sectp->floorz - (krand() % (sectp->floorz - sectp->ceilingz));
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
switch (actor->temp_data[1])
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
|
|
|
case 3:
|
2020-10-14 16:55:50 +00:00
|
|
|
{
|
2020-05-08 22:34:48 +00:00
|
|
|
//Turn on all of those flashing sectoreffector.
|
2020-10-21 21:04:14 +00:00
|
|
|
fi.hitradius(actor, 4096,
|
2020-11-29 14:09:23 +00:00
|
|
|
gs.impact_damage << 2,
|
|
|
|
gs.impact_damage << 2,
|
|
|
|
gs.impact_damage << 2,
|
|
|
|
gs.impact_damage << 2);
|
2020-10-21 21:04:14 +00:00
|
|
|
DukeStatIterator it(STAT_STANDABLE);
|
2021-12-21 18:09:05 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
if (a2->spr.picnum == MASTERSWITCH)
|
|
|
|
if (a2->spr.hitag == actor->spr.hitag)
|
|
|
|
if (a2->spr.yvel == 0)
|
|
|
|
a2->spr.yvel = 1;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
break;
|
2020-10-14 16:55:50 +00:00
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
case 4:
|
|
|
|
case 7:
|
|
|
|
case 10:
|
|
|
|
case 15:
|
2020-10-14 17:24:24 +00:00
|
|
|
{
|
2021-11-20 23:41:52 +00:00
|
|
|
DukeSectIterator it(actor->sector());
|
2020-10-21 21:04:14 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 21:04:14 +00:00
|
|
|
if (a2 != actor)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 21:04:14 +00:00
|
|
|
deletesprite(a2);
|
2020-07-31 23:04:17 +00:00
|
|
|
break;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2020-10-14 17:24:24 +00:00
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
for (x = 0; x < 16; x++)
|
2020-10-21 21:04:14 +00:00
|
|
|
RANDOMSCRAP(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->spr.pos.Z = actor->temp_data[4];
|
|
|
|
actor->temp_data[4] = 0;
|
2020-05-08 22:34:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-21 21:04:14 +00:00
|
|
|
int j = fi.ifhitbyweapon(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
if (j >= 0)
|
|
|
|
{
|
|
|
|
for (x = 0; x < 32; x++)
|
2020-10-21 21:04:14 +00:00
|
|
|
RANDOMSCRAP(actor);
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.extra < 0)
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1] = 1;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:04:14 +00:00
|
|
|
void camera(DDukeActor *actor)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 0)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-11-29 12:54:58 +00:00
|
|
|
if (gs.camerashitable)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-21 21:04:14 +00:00
|
|
|
int j = fi.ifhitbyweapon(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
if (j >= 0)
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 1; // static
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.cstat = CSTAT_SPRITE_INVISIBLE;
|
2020-05-08 22:34:48 +00:00
|
|
|
for (int x = 0; x < 5; x++)
|
2020-10-21 21:04:14 +00:00
|
|
|
RANDOMSCRAP(actor);
|
2020-05-08 22:34:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.hitag > 0)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-09-23 23:05:42 +00:00
|
|
|
// alias our temp_data array indexes.
|
2021-12-23 15:03:43 +00:00
|
|
|
auto& increment = actor->temp_data[1];
|
|
|
|
auto& minimum = actor->temp_data[2];
|
|
|
|
auto& maximum = actor->temp_data[3];
|
|
|
|
auto& setupflag = actor->temp_data[4];
|
2020-09-23 23:05:42 +00:00
|
|
|
|
2020-09-23 08:31:12 +00:00
|
|
|
// set up camera if already not.
|
2020-09-23 23:05:42 +00:00
|
|
|
if (setupflag != 1)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-09-23 23:05:42 +00:00
|
|
|
increment = 8;
|
2021-12-21 17:29:44 +00:00
|
|
|
minimum = actor->spr.ang - actor->spr.hitag - increment;
|
|
|
|
maximum = actor->spr.ang + actor->spr.hitag - increment;
|
2020-09-23 23:05:42 +00:00
|
|
|
setupflag = 1;
|
2020-09-23 08:31:12 +00:00
|
|
|
}
|
|
|
|
|
2020-09-23 23:05:42 +00:00
|
|
|
// update angle accordingly.
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.ang == minimum || actor->spr.ang == maximum)
|
2020-09-23 08:31:12 +00:00
|
|
|
{
|
2020-09-23 23:05:42 +00:00
|
|
|
increment = -increment;
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang += increment;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
2021-12-21 17:29:44 +00:00
|
|
|
else if (actor->spr.ang + increment < minimum)
|
2020-09-23 08:31:12 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang = minimum;
|
2020-09-23 08:31:12 +00:00
|
|
|
}
|
2021-12-21 17:29:44 +00:00
|
|
|
else if (actor->spr.ang + increment > maximum)
|
2020-09-23 08:31:12 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang = maximum;
|
2020-09-23 23:05:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang += increment;
|
2020-09-23 08:31:12 +00:00
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-05 09:58:39 +00:00
|
|
|
|
2020-05-09 18:27:06 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// taken out of moveexplosion
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:11:06 +00:00
|
|
|
void forcesphereexplode(DDukeActor *actor)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
int l = actor->spr.xrepeat;
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[1] > 0)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1]--;
|
|
|
|
if (actor->temp_data[1] == 0)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:11:06 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-10-21 21:11:06 +00:00
|
|
|
auto Owner = actor->GetOwner();
|
|
|
|
if (!Owner) return;
|
|
|
|
if (Owner->temp_data[1] == 0)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] < 64)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2020-05-09 18:27:06 +00:00
|
|
|
l += 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] > 64)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]--;
|
2020-05-09 18:27:06 +00:00
|
|
|
l -= 3;
|
|
|
|
}
|
|
|
|
|
2021-12-22 10:57:10 +00:00
|
|
|
actor->spr.pos.X = Owner->spr.pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.pos.Y = Owner->spr.pos.Y;
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z = Owner->spr.pos.Z;
|
2021-12-21 17:19:45 +00:00
|
|
|
actor->spr.ang += Owner->temp_data[0];
|
2020-05-09 18:27:06 +00:00
|
|
|
|
|
|
|
if (l > 64) l = 64;
|
|
|
|
else if (l < 1) l = 1;
|
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
actor->spr.xrepeat = l;
|
|
|
|
actor->spr.yrepeat = l;
|
|
|
|
actor->spr.shade = (l >> 1) - 48;
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
for (int j = actor->temp_data[0]; j > 0; j--)
|
2020-10-21 21:11:06 +00:00
|
|
|
ssp(actor, CLIPMASK0);
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:11:06 +00:00
|
|
|
void watersplash2(DDukeActor* actor)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sectp = actor->sector();
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
|
|
|
if (actor->temp_data[0] == 1)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-11-06 21:45:02 +00:00
|
|
|
if (sectp->lotag != 1 && sectp->lotag != 2)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:11:06 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!S_CheckSoundPlaying(ITEM_SPLASH))
|
2020-10-21 21:11:06 +00:00
|
|
|
S_PlayActorSound(ITEM_SPLASH, actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 3)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 0;
|
|
|
|
actor->temp_data[1]++;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[1] == 5)
|
2020-10-21 21:11:06 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:11:06 +00:00
|
|
|
void frameeffect1(DDukeActor *actor)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:11:06 +00:00
|
|
|
auto Owner = actor->GetOwner();
|
|
|
|
if (Owner)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] > 7)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:11:06 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (actor->temp_data[0] > 4) actor->spr.cstat |= CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT;
|
|
|
|
else if (actor->temp_data[0] > 2) actor->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT;
|
2021-12-21 17:19:45 +00:00
|
|
|
actor->spr.xoffset = Owner->spr.xoffset;
|
|
|
|
actor->spr.yoffset = Owner->spr.yoffset;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:11:06 +00:00
|
|
|
bool money(DDukeActor* actor, int BLOODPOOL)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sectp = actor->sector();
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xvel = (krand() & 7) + bsin(actor->temp_data[0], -9);
|
2020-10-21 21:11:06 +00:00
|
|
|
actor->temp_data[0] += (krand() & 63);
|
|
|
|
if ((actor->temp_data[0] & 2047) > 512 && (actor->temp_data[0] & 2047) < 1596)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-11-06 21:45:02 +00:00
|
|
|
if (sectp->lotag == 2)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel < 64)
|
|
|
|
actor->spr.zvel += (gs.gravity >> 5) + (krand() & 7);
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
else
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel < 144)
|
|
|
|
actor->spr.zvel += (gs.gravity >> 5) + (krand() & 7);
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 21:11:06 +00:00
|
|
|
ssp(actor, CLIPMASK0);
|
2020-05-09 18:27:06 +00:00
|
|
|
|
|
|
|
if ((krand() & 3) == 0)
|
2021-12-21 17:29:44 +00:00
|
|
|
SetActor(actor, actor->spr.pos);
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-30 15:24:51 +00:00
|
|
|
if (!actor->insector())
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:11:06 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
2021-12-30 15:51:56 +00:00
|
|
|
int l = getflorzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
if (actor->spr.pos.Z > l)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z = l;
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2020-10-21 21:11:06 +00:00
|
|
|
insertspriteq(actor);
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.picnum++;
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2020-10-21 21:11:06 +00:00
|
|
|
DukeStatIterator it(STAT_MISC);
|
|
|
|
while (auto aa = it.Next())
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (aa->spr.picnum == BLOODPOOL)
|
2020-10-21 21:11:06 +00:00
|
|
|
if (ldist(actor, aa) < 348)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.pal = 2;
|
2020-05-09 18:27:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:18:24 +00:00
|
|
|
bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool floorcheck, bool zcheck1, bool zcheck2)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sectp = actor->sector();
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xvel > 0) actor->spr.xvel--;
|
|
|
|
else actor->spr.xvel = 0;
|
2020-05-09 18:27:06 +00:00
|
|
|
|
|
|
|
if (timeout)
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[5] < 30 * 10)
|
|
|
|
actor->temp_data[5]++;
|
2020-05-09 18:27:06 +00:00
|
|
|
else
|
|
|
|
{
|
2020-10-21 21:18:24 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel > 1024 && actor->spr.zvel < 1280)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
SetActor(actor, actor->spr.pos);
|
2021-12-30 15:51:56 +00:00
|
|
|
sectp = actor->sector();
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (callsetsprite) SetActor(actor, actor->spr.pos);
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-11-06 21:45:02 +00:00
|
|
|
// this was after the slope calls, but we should avoid calling that for invalid sectors.
|
2021-12-30 15:24:51 +00:00
|
|
|
if (!actor->insector())
|
2021-11-06 21:45:02 +00:00
|
|
|
{
|
|
|
|
deletesprite(actor);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-12-22 11:17:17 +00:00
|
|
|
int l = getflorzofslopeptr(sectp, actor->spr.pos.X, actor->spr.pos.Y);
|
|
|
|
int x = getceilzofslopeptr(sectp, actor->spr.pos.X, actor->spr.pos.Y);
|
2021-11-06 21:45:02 +00:00
|
|
|
if (x == l)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:18:24 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
if (actor->spr.pos.Z < l - (2 << 8))
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[1] < 2) actor->temp_data[1]++;
|
2021-11-06 21:45:02 +00:00
|
|
|
else if (sectp->lotag != 2)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1] = 0;
|
2020-05-09 18:27:06 +00:00
|
|
|
if (zcheck1)
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] > 6) actor->temp_data[0] = 0;
|
|
|
|
else actor->temp_data[0]++;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] > 2)
|
|
|
|
actor->temp_data[0] = 0;
|
|
|
|
else actor->temp_data[0]++;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel < 6144)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-11-06 21:45:02 +00:00
|
|
|
if (sectp->lotag == 2)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel < 1024)
|
|
|
|
actor->spr.zvel += 48;
|
|
|
|
else actor->spr.zvel = 1024;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
2021-12-21 17:29:44 +00:00
|
|
|
else actor->spr.zvel += gs.gravity - 50;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
|
2021-12-22 10:57:10 +00:00
|
|
|
actor->spr.pos.X += MulScale(actor->spr.xvel, bcos(actor->spr.ang), 14);
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.pos.Y += MulScale(actor->spr.xvel, bsin(actor->spr.ang), 14);
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z += actor->spr.zvel;
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
if (floorcheck && actor->spr.pos.Z >= actor->sector()->floorz)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:18:24 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (zcheck2)
|
|
|
|
{
|
2020-10-21 21:18:24 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[2] == 0)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-30 15:24:51 +00:00
|
|
|
if (!actor->insector())
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:18:24 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
2021-12-30 15:51:56 +00:00
|
|
|
if ((actor->sector()->floorstat & CSTAT_SECTOR_SLOPE))
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:18:24 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2]++;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
2021-12-30 15:51:56 +00:00
|
|
|
l = getflorzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z = l - (2 << 8);
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xvel = 0;
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.picnum == JIBS6)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1]++;
|
|
|
|
if ((actor->temp_data[1] & 3) == 0 && actor->temp_data[0] < 7)
|
|
|
|
actor->temp_data[0]++;
|
|
|
|
if (actor->temp_data[1] > 20)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:18:24 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else { actor->spr.picnum = JIBS6; actor->temp_data[0] = 0; actor->temp_data[1] = 0; }
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:18:24 +00:00
|
|
|
bool bloodpool(DDukeActor* actor, bool puke, int TIRE)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sectp = actor->sector();
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 0)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 1;
|
2021-12-18 12:23:08 +00:00
|
|
|
if (sectp->floorstat & CSTAT_SECTOR_SLOPE)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:18:24 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-10-21 21:18:24 +00:00
|
|
|
else insertspriteq(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 21:18:24 +00:00
|
|
|
makeitfall(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
|
|
|
|
int x;
|
2020-10-23 15:44:45 +00:00
|
|
|
int p = findplayer(actor, &x);
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z = actor->floorz - (FOURSLEIGHT);
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[2] < 32)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2]++;
|
2021-12-27 22:52:16 +00:00
|
|
|
if (actor->attackertype == TIRE)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xrepeat < 64 && actor->spr.yrepeat < 64)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xrepeat += krand() & 3;
|
|
|
|
actor->spr.yrepeat += krand() & 3;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xrepeat < 32 && actor->spr.yrepeat < 32)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xrepeat += krand() & 3;
|
|
|
|
actor->spr.yrepeat += krand() & 3;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (x < 844 && actor->spr.xrepeat > 6 && actor->spr.yrepeat > 6)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.pal == 0 && (krand() & 255) < 16 && !puke)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
|
|
|
if (ps[p].boot_amount > 0)
|
|
|
|
ps[p].boot_amount--;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!S_CheckSoundPlaying(DUKE_LONGTERM_PAIN))
|
2020-10-21 21:18:24 +00:00
|
|
|
S_PlayActorSound(DUKE_LONGTERM_PAIN, ps[p].GetActor());
|
2021-12-21 17:19:45 +00:00
|
|
|
ps[p].GetActor()->spr.extra--;
|
2020-05-09 18:27:06 +00:00
|
|
|
SetPlayerPal(&ps[p], PalEntry(32, 16, 0, 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[1] == 1) return false;
|
|
|
|
actor->temp_data[1] = 1;
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-27 22:52:16 +00:00
|
|
|
if (actor->attackertype == TIRE)
|
2020-05-09 18:27:06 +00:00
|
|
|
ps[p].footprintcount = 10;
|
|
|
|
else ps[p].footprintcount = 3;
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
ps[p].footprintpal = actor->spr.pal;
|
|
|
|
ps[p].footprintshade = actor->spr.shade;
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[2] == 32)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xrepeat -= 6;
|
|
|
|
actor->spr.yrepeat -= 6;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else actor->temp_data[1] = 0;
|
2020-05-09 18:27:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:18:24 +00:00
|
|
|
void shell(DDukeActor* actor, bool morecheck)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sectp = actor->sector();
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2020-10-21 21:18:24 +00:00
|
|
|
ssp(actor, CLIPMASK0);
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-30 15:24:51 +00:00
|
|
|
if (!actor->insector() || morecheck)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:18:24 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-06 21:45:02 +00:00
|
|
|
if (sectp->lotag == 2)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1]++;
|
|
|
|
if (actor->temp_data[1] > 8)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1] = 0;
|
|
|
|
actor->temp_data[0]++;
|
|
|
|
actor->temp_data[0] &= 3;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel < 128) actor->spr.zvel += (gs.gravity / 13); // 8
|
|
|
|
else actor->spr.zvel -= 64;
|
|
|
|
if (actor->spr.xvel > 0)
|
|
|
|
actor->spr.xvel -= 4;
|
|
|
|
else actor->spr.xvel = 0;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1]++;
|
|
|
|
if (actor->temp_data[1] > 3)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1] = 0;
|
|
|
|
actor->temp_data[0]++;
|
|
|
|
actor->temp_data[0] &= 3;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel < 512) actor->spr.zvel += (gs.gravity / 3); // 52;
|
|
|
|
if (actor->spr.xvel > 0)
|
|
|
|
actor->spr.xvel--;
|
2020-05-09 18:27:06 +00:00
|
|
|
else
|
|
|
|
{
|
2020-10-21 21:18:24 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:18:24 +00:00
|
|
|
void glasspieces(DDukeActor* actor)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sectp = actor->sector();
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2020-10-21 21:18:24 +00:00
|
|
|
makeitfall(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel > 4096) actor->spr.zvel = 4096;
|
2021-12-30 15:24:51 +00:00
|
|
|
if (!actor->insector())
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:18:24 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->spr.pos.Z == actor->floorz - (FOURSLEIGHT) && actor->temp_data[0] < 3)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->spr.zvel = -((3 - actor->temp_data[0]) << 8) - (krand() & 511);
|
2021-11-06 21:45:02 +00:00
|
|
|
if (sectp->lotag == 2)
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.zvel >>= 1;
|
|
|
|
actor->spr.xrepeat >>= 1;
|
|
|
|
actor->spr.yrepeat >>= 1;
|
2020-05-09 18:27:06 +00:00
|
|
|
if (rnd(96))
|
2021-12-21 17:29:44 +00:00
|
|
|
SetActor(actor, actor->spr.pos);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;//Number of bounces
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (actor->temp_data[0] == 3)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2020-10-21 21:18:24 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xvel > 0)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xvel -= 2;
|
2021-12-18 11:28:48 +00:00
|
|
|
static const ESpriteFlags flips[] = { 0, CSTAT_SPRITE_XFLIP, CSTAT_SPRITE_YFLIP, CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP };
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.cstat = flips[actor->spr.xvel & 3];
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
2021-12-21 17:29:44 +00:00
|
|
|
else actor->spr.xvel = 0;
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2020-10-21 21:18:24 +00:00
|
|
|
ssp(actor, CLIPMASK0);
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:18:24 +00:00
|
|
|
void scrap(DDukeActor* actor, int SCRAP1, int SCRAP6)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sectp = actor->sector();
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xvel > 0)
|
|
|
|
actor->spr.xvel--;
|
|
|
|
else actor->spr.xvel = 0;
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel > 1024 && actor->spr.zvel < 1280)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
SetActor(actor, actor->spr.pos);
|
2021-12-30 15:51:56 +00:00
|
|
|
sectp = actor->sector();
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
if (actor->spr.pos.Z < sectp->floorz - (2 << 8))
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[1] < 1) actor->temp_data[1]++;
|
2020-05-09 18:27:06 +00:00
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[1] = 0;
|
2020-05-09 18:27:06 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.picnum < SCRAP6 + 8)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] > 6)
|
|
|
|
actor->temp_data[0] = 0;
|
|
|
|
else actor->temp_data[0]++;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] > 2)
|
|
|
|
actor->temp_data[0] = 0;
|
|
|
|
else actor->temp_data[0]++;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel < 4096) actor->spr.zvel += gs.gravity - 50;
|
2021-12-22 10:57:10 +00:00
|
|
|
actor->spr.pos.X += MulScale(actor->spr.xvel, bcos(actor->spr.ang), 14);
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.pos.Y += MulScale(actor->spr.xvel, bsin(actor->spr.ang), 14);
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z += actor->spr.zvel;
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.picnum == SCRAP1 && actor->spr.yvel > 0)
|
2020-05-09 18:27:06 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
auto spawned = spawn(actor, actor->spr.yvel);
|
2021-11-19 11:32:12 +00:00
|
|
|
if (spawned)
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
SetActor(spawned, actor->spr.pos);
|
2021-11-19 11:32:12 +00:00
|
|
|
getglobalz(spawned);
|
2021-12-21 17:19:45 +00:00
|
|
|
spawned->spr.hitag = spawned->spr.lotag = 0;
|
2021-11-19 11:32:12 +00:00
|
|
|
}
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
2020-10-21 21:18:24 +00:00
|
|
|
deletesprite(actor);
|
2020-05-09 18:27:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 22:05:08 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-07 13:07:08 +00:00
|
|
|
void gutsdir(DDukeActor* actor, int gtype, int n, int p)
|
2020-10-21 22:05:08 +00:00
|
|
|
{
|
|
|
|
int sx, sy;
|
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
if (badguy(actor) && actor->spr.xrepeat < 16)
|
2020-10-21 22:05:08 +00:00
|
|
|
sx = sy = 8;
|
|
|
|
else sx = sy = 32;
|
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
int gutz = actor->spr.pos.Z - (8 << 8);
|
2021-12-22 11:17:17 +00:00
|
|
|
int floorz = getflorzofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
|
2020-10-21 22:05:08 +00:00
|
|
|
|
|
|
|
if (gutz > (floorz - (8 << 8)))
|
|
|
|
gutz = floorz - (8 << 8);
|
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
gutz += gs.actorinfo[actor->spr.picnum].gutsoffset;
|
2020-10-21 22:05:08 +00:00
|
|
|
|
|
|
|
for (int j = 0; j < n; j++)
|
|
|
|
{
|
|
|
|
int a = krand() & 2047;
|
|
|
|
int r1 = krand();
|
|
|
|
int r2 = krand();
|
|
|
|
// TRANSITIONAL: owned by a player???
|
2021-12-30 15:51:56 +00:00
|
|
|
EGS(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y, gutz, gtype, -32, sx, sy, a, 256 + (r2 & 127), -512 - (r1 & 2047), ps[p].GetActor(), 5);
|
2020-10-21 22:05:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-10 07:08:02 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// taken out of moveeffectors
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:39:12 +00:00
|
|
|
void handle_se00(DDukeActor* actor, int LASERLINE)
|
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
|
|
|
|
|
|
|
int zchange = 0;
|
|
|
|
|
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
|
|
|
{
|
2020-10-21 21:39:12 +00:00
|
|
|
deletesprite(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-31 21:55:41 +00:00
|
|
|
int q = sect->extra >> 3;
|
2020-05-10 07:08:02 +00:00
|
|
|
int l = 0;
|
|
|
|
|
2020-10-31 21:55:41 +00:00
|
|
|
if (sect->lotag == 30)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
q >>= 2;
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.extra == 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-31 21:55:41 +00:00
|
|
|
if (actor->tempang < 256)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-31 21:55:41 +00:00
|
|
|
actor->tempang += 4;
|
|
|
|
if (actor->tempang >= 256)
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.clipdist) l = 1;
|
2020-05-10 07:08:02 +00:00
|
|
|
else l = -1;
|
|
|
|
}
|
2020-10-31 21:55:41 +00:00
|
|
|
else actor->tempang = 256;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
if (sect->floorz > actor->spr.pos.Z) //z's are touching
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sect->addfloorz(-512);
|
2020-05-10 07:08:02 +00:00
|
|
|
zchange = -512;
|
2021-12-22 11:29:00 +00:00
|
|
|
if (sect->floorz < actor->spr.pos.Z)
|
2021-12-27 21:32:26 +00:00
|
|
|
sect->setfloorz(actor->spr.pos.Z);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
else if (sect->floorz < actor->spr.pos.Z) //z's are touching
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sect->addfloorz(512);
|
2020-05-10 07:08:02 +00:00
|
|
|
zchange = 512;
|
2021-12-22 11:29:00 +00:00
|
|
|
if (sect->floorz > actor->spr.pos.Z)
|
2021-12-27 21:32:26 +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
|
|
|
{
|
2020-10-31 21:55:41 +00:00
|
|
|
if (actor->tempang > 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-31 21:55:41 +00:00
|
|
|
actor->tempang -= 4;
|
|
|
|
if (actor->tempang <= 0)
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.clipdist) l = -1;
|
2020-05-10 07:08:02 +00:00
|
|
|
else l = 1;
|
|
|
|
}
|
2020-10-31 21:55:41 +00:00
|
|
|
else actor->tempang = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-31 21:55:41 +00:00
|
|
|
if (sect->floorz > actor->temp_data[3]) //z's are touching
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sect->addfloorz(-512);
|
2020-05-10 07:08:02 +00:00
|
|
|
zchange = -512;
|
2020-10-31 21:55:41 +00:00
|
|
|
if (sect->floorz < actor->temp_data[3])
|
2021-12-27 21:32:26 +00:00
|
|
|
sect->setfloorz(actor->temp_data[3]);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2020-10-31 21:55:41 +00:00
|
|
|
else if (sect->floorz < actor->temp_data[3]) //z's are touching
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sect->addfloorz(512);
|
2020-05-10 07:08:02 +00:00
|
|
|
zchange = 512;
|
2020-10-31 21:55:41 +00:00
|
|
|
if (sect->floorz > actor->temp_data[3])
|
2021-12-27 21:32:26 +00:00
|
|
|
sect->setfloorz(actor->temp_data[3]);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang += (l * q);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] += (l * q);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-21 21:39:12 +00:00
|
|
|
if (Owner->temp_data[0] == 0) return;
|
|
|
|
if (Owner->temp_data[0] == 2)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-21 21:39:12 +00:00
|
|
|
deletesprite(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
if (Owner->spr.ang > 1024)
|
2020-05-10 07:08:02 +00:00
|
|
|
l = -1;
|
|
|
|
else l = 1;
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[3] == 0)
|
|
|
|
actor->temp_data[3] = ldist(actor, Owner);
|
|
|
|
actor->spr.xvel = actor->temp_data[3];
|
2021-12-22 10:57:10 +00:00
|
|
|
actor->spr.pos.X = Owner->spr.pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.pos.Y = Owner->spr.pos.Y;
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang += (l * q);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] += (l * q);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-18 12:23:08 +00:00
|
|
|
if (l && (sect->floorstat & CSTAT_SECTOR_ALIGN))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
int p;
|
|
|
|
for (p = connecthead; p >= 0; p = connectpoint2[p])
|
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if (ps[p].cursector == actor->sector() && ps[p].on_ground == 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-07 12:13:21 +00:00
|
|
|
ps[p].angle.addadjustment(l * q);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-22 09:41:47 +00:00
|
|
|
ps[p].pos.Z += zchange;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-17 17:22:42 +00:00
|
|
|
vec2_t res;
|
2021-12-21 17:19:45 +00:00
|
|
|
rotatepoint(Owner->spr.pos.vec2, ps[p].pos.vec2, (q * l), &res);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-30 11:57:39 +00:00
|
|
|
ps[p].bobpos.X += res.X - ps[p].pos.X;
|
2021-12-30 11:59:45 +00:00
|
|
|
ps[p].bobpos.Y += res.Y - ps[p].pos.Y;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-17 17:22:42 +00:00
|
|
|
ps[p].pos.vec2 = res;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-21 21:39:12 +00:00
|
|
|
auto psp = ps[p].GetActor();
|
2021-12-21 17:19:45 +00:00
|
|
|
if (psp->spr.extra <= 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
psp->spr.pos.vec2 = res;
|
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
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
if (act2->spr.statnum != 3 && act2->spr.statnum != 4)
|
|
|
|
if (LASERLINE < 0 || act2->spr.picnum != LASERLINE)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-31 17:47:00 +00:00
|
|
|
if (act2->isPlayer() && act2->GetOwner())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-12-21 18:09:05 +00:00
|
|
|
act2->spr.ang += (l * q);
|
|
|
|
act2->spr.ang &= 2047;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
act2->spr.pos.Z += zchange;
|
2021-12-21 18:09:05 +00:00
|
|
|
rotatepoint(Owner->spr.pos.vec2, act2->spr.pos.vec2, (q* l), &act2->spr.pos.vec2);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-10-21 21:39:12 +00:00
|
|
|
ms(actor);
|
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
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (ac->spr.lotag == 19 && ac->spr.hitag == sh)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 21:56:46 +00:00
|
|
|
void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
|
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-01-13 21:34:43 +00:00
|
|
|
auto NewOwner = LocateTheLocator(actor->temp_data[3], §or[actor->temp_data[0]]);
|
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();
|
|
|
|
int j = ldist(Owner, actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-11-01 06:56:49 +00:00
|
|
|
if (j < 1024)
|
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-01-13 21:34:43 +00:00
|
|
|
auto NewOwner = LocateTheLocator(actor->temp_data[3], §or[actor->temp_data[0]]);
|
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-01-13 21:34:43 +00:00
|
|
|
NewOwner = LocateTheLocator(0, §or[actor->temp_data[0]]);
|
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();
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xvel)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 11:17:17 +00:00
|
|
|
int x = getangle(Owner->spr.pos.X - actor->spr.pos.X, Owner->spr.pos.Y - actor->spr.pos.Y);
|
2021-12-21 17:29:44 +00:00
|
|
|
int q = getincangle(actor->spr.ang, x) >> 3;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] += q;
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang += q;
|
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));
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xvel == sc->extra)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
if (statstate)
|
|
|
|
{
|
2021-12-30 11:54:08 +00:00
|
|
|
if (!S_CheckSoundPlaying(actor->ovel.X))
|
|
|
|
S_PlayActorSound(actor->ovel.X, 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
|
|
|
{
|
2020-10-23 15:44:45 +00:00
|
|
|
int p = findplayer(actor, &x);
|
2020-05-10 07:08:02 +00:00
|
|
|
if (x < 20480)
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
j = actor->spr.ang;
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.ang = getangle(actor->spr.pos.X - ps[p].pos.X, actor->spr.pos.Y - ps[p].pos.Y);
|
2020-10-24 05:34:39 +00:00
|
|
|
fi.shoot(actor, RPG);
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang = j;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xvel <= 64 && statstate)
|
2021-12-30 11:54:08 +00:00
|
|
|
S_StopSound(actor->ovel.X, actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if ((sc->floorz - sc->ceilingz) < (108 << 8))
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (ud.clipping == 0 && actor->spr.xvel >= 192)
|
2020-05-10 07:08:02 +00:00
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2020-11-01 07:00:03 +00:00
|
|
|
{
|
|
|
|
auto psp = ps[p].GetActor();
|
2021-12-21 17:19:45 +00:00
|
|
|
if (psp->spr.extra > 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-21 07:56:39 +00:00
|
|
|
auto k = ps[p].cursector;
|
2021-12-22 09:40:26 +00:00
|
|
|
updatesector(ps[p].pos.X, ps[p].pos.Y, &k);
|
2021-12-30 15:51:56 +00:00
|
|
|
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 10:57:10 +00:00
|
|
|
ps[p].pos.X = actor->spr.pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
ps[p].pos.Y = actor->spr.pos.Y;
|
2021-12-30 15:51:56 +00:00
|
|
|
ps[p].setCursector(actor->sector());
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
SetActor(ps[p].GetActor(), actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
quickkill(&ps[p]);
|
|
|
|
}
|
|
|
|
}
|
2020-11-01 07:00:03 +00:00
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
int m = MulScale(actor->spr.xvel, bcos(actor->spr.ang), 14);
|
|
|
|
x = MulScale(actor->spr.xvel, bsin(actor->spr.ang), 14);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2020-11-01 07:00:03 +00:00
|
|
|
{
|
|
|
|
auto psp = ps[p].GetActor();
|
2021-11-21 07:56:39 +00:00
|
|
|
if (ps[p].insector() && ps[p].cursector->lotag != 2)
|
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
|
|
|
{
|
2021-12-30 11:19:38 +00:00
|
|
|
po[p].opos.X += m;
|
2021-12-30 11:20:32 +00:00
|
|
|
po[p].opos.Y += x;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
if (actor->sector() == psp->sector())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
rotatepoint(actor->spr.pos.vec2, ps[p].pos.vec2, q, &ps[p].pos.vec2);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-22 09:36:09 +00:00
|
|
|
ps[p].pos.X += m;
|
2021-12-22 09:40:26 +00:00
|
|
|
ps[p].pos.Y += x;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-30 11:57:39 +00:00
|
|
|
ps[p].bobpos.X += m;
|
2021-12-30 11:59:45 +00:00
|
|
|
ps[p].bobpos.Y += x;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-07 12:13:21 +00:00
|
|
|
ps[p].angle.addadjustment(q);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (numplayers > 1)
|
|
|
|
{
|
2021-12-22 11:40:42 +00:00
|
|
|
ps[p].opos.X = ps[p].pos.X;
|
2021-12-22 11:42:06 +00:00
|
|
|
ps[p].opos.Y = ps[p].pos.Y;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2021-12-21 17:19:45 +00:00
|
|
|
if (psp->spr.extra <= 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 10:57:10 +00:00
|
|
|
psp->spr.pos.X = ps[p].pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
psp->spr.pos.Y = ps[p].pos.Y;
|
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 &&
|
|
|
|
(a2->spr.picnum != SECTOREFFECTOR || a2->spr.lotag == SE_49_POINT_LIGHT || a2->spr.lotag == SE_50_SPOT_LIGHT) &&
|
|
|
|
a2->spr.picnum != LOCATORS)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
rotatepoint(actor->spr.pos.vec2, a2->spr.pos.vec2, q, &a2->spr.pos.vec2);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-22 10:57:10 +00:00
|
|
|
a2->spr.pos.X += m;
|
2021-12-22 11:17:17 +00:00
|
|
|
a2->spr.pos.Y += x;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 18:09:05 +00:00
|
|
|
a2->spr.ang += q;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-01 06:51:50 +00:00
|
|
|
ms(actor);
|
2021-12-21 17:29:44 +00:00
|
|
|
SetActor(actor, actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if ((sc->floorz - sc->ceilingz) < (108 << 8))
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (ud.clipping == 0 && actor->spr.xvel >= 192)
|
2020-05-10 07:08:02 +00:00
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2020-11-01 07:00:03 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (ps[p].GetActor()->spr.extra > 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-21 07:56:39 +00:00
|
|
|
auto k = ps[p].cursector;
|
2021-12-22 09:40:26 +00:00
|
|
|
updatesector(ps[p].pos.X, ps[p].pos.Y, &k);
|
2021-12-30 15:51:56 +00:00
|
|
|
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 11:40:42 +00:00
|
|
|
ps[p].opos.X = ps[p].pos.X = actor->spr.pos.X;
|
2021-12-22 11:42:06 +00:00
|
|
|
ps[p].opos.Y = ps[p].pos.Y = actor->spr.pos.Y;
|
2021-12-30 15:51:56 +00:00
|
|
|
ps[p].setCursector(actor->sector());
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
SetActor(ps[p].GetActor(), actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
quickkill(&ps[p]);
|
|
|
|
}
|
|
|
|
}
|
2020-11-01 07:00:03 +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
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.statnum == 1 && badguy(a2) && a2->spr.picnum != SECTOREFFECTOR && a2->spr.picnum != LOCATORS)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto k = a2->sector();
|
2021-12-22 11:17:17 +00:00
|
|
|
updatesector(a2->spr.pos.X, a2->spr.pos.Y, &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
|
|
|
{
|
2020-10-21 22:05:08 +00:00
|
|
|
gutsdir(a2, JIBS6, 72, myconnectindex);
|
2020-11-01 07:00:43 +00:00
|
|
|
S_PlayActorSound(SQUISHED, actor);
|
|
|
|
deletesprite(a2);
|
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:00:43 +00:00
|
|
|
void handle_se30(DDukeActor *actor, int JIBS6)
|
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-01-13 21:34:43 +00:00
|
|
|
Owner = LocateTheLocator(actor->temp_data[3], §or[actor->temp_data[0]]);
|
2020-10-21 22:00:43 +00:00
|
|
|
actor->SetOwner(Owner);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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
|
|
|
{
|
2020-10-21 22:00:43 +00:00
|
|
|
if (ldist(Owner, actor) < (2048 - 128))
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] = 2;
|
2020-05-10 07:08:02 +00:00
|
|
|
else
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xvel == 0)
|
2021-12-23 15:03:43 +00:00
|
|
|
operateactivators(actor->spr.hitag + (!actor->temp_data[3]), -1);
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xvel < 256)
|
|
|
|
actor->spr.xvel += 16;
|
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
|
|
|
{
|
2021-12-26 10:44:32 +00:00
|
|
|
int l = FindDistance2D(Owner->spr.pos.vec2 - actor->spr.pos.vec2);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (l <= 128)
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xvel = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xvel > 0)
|
|
|
|
actor->spr.xvel -= 16;
|
2020-05-10 07:08:02 +00:00
|
|
|
else
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xvel = 0;
|
2021-12-23 15:03:43 +00:00
|
|
|
operateactivators(actor->spr.hitag + (short)actor->temp_data[3], -1);
|
2020-10-21 22:00:43 +00:00
|
|
|
actor->SetOwner(nullptr);
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang += 1024;
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[4] = 0;
|
2021-12-21 17:29:44 +00:00
|
|
|
fi.operateforcefields(actor, actor->spr.hitag);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xvel)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
int l = MulScale(actor->spr.xvel, bcos(actor->spr.ang), 14);
|
|
|
|
int x = MulScale(actor->spr.xvel, bsin(actor->spr.ang), 14);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if ((sc->floorz - sc->ceilingz) < (108 << 8))
|
|
|
|
if (ud.clipping == 0)
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2020-10-21 22:00:43 +00:00
|
|
|
{
|
|
|
|
auto psp = ps[p].GetActor();
|
2021-12-21 17:19:45 +00:00
|
|
|
if (psp->spr.extra > 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-21 07:56:39 +00:00
|
|
|
auto k = ps[p].cursector;
|
2021-12-22 09:40:26 +00:00
|
|
|
updatesector(ps[p].pos.X, ps[p].pos.Y, &k);
|
2021-12-30 15:51:56 +00:00
|
|
|
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 10:57:10 +00:00
|
|
|
ps[p].pos.X = actor->spr.pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
ps[p].pos.Y = actor->spr.pos.Y;
|
2021-12-30 15:51:56 +00:00
|
|
|
ps[p].setCursector(actor->sector());
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
SetActor(ps[p].GetActor(), actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
quickkill(&ps[p]);
|
|
|
|
}
|
|
|
|
}
|
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])
|
|
|
|
{
|
2020-10-21 22:00:43 +00:00
|
|
|
auto psp = ps[p].GetActor();
|
2021-12-30 15:51:56 +00:00
|
|
|
if (psp->sector() == actor->sector())
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 09:36:09 +00:00
|
|
|
ps[p].pos.X += l;
|
2021-12-22 09:40:26 +00:00
|
|
|
ps[p].pos.Y += x;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (numplayers > 1)
|
|
|
|
{
|
2021-12-22 11:40:42 +00:00
|
|
|
ps[p].opos.X = ps[p].pos.X;
|
2021-12-22 11:42:06 +00:00
|
|
|
ps[p].opos.Y = ps[p].pos.Y;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-30 11:57:39 +00:00
|
|
|
ps[p].bobpos.X += l;
|
2021-12-30 11:59:45 +00:00
|
|
|
ps[p].bobpos.Y += x;
|
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
|
|
|
{
|
2021-12-30 11:19:38 +00:00
|
|
|
po[p].opos.X += l;
|
2021-12-30 11:20:32 +00:00
|
|
|
po[p].opos.Y += x;
|
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
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
if (a2->spr.picnum != SECTOREFFECTOR && a2->spr.picnum != LOCATORS)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 10:57:10 +00:00
|
|
|
a2->spr.pos.X += l;
|
2021-12-22 11:17:17 +00:00
|
|
|
a2->spr.pos.Y += x;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 22:00:43 +00:00
|
|
|
ms(actor);
|
2021-12-21 17:29:44 +00:00
|
|
|
SetActor(actor, actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if ((sc->floorz - sc->ceilingz) < (108 << 8))
|
|
|
|
{
|
|
|
|
if (ud.clipping == 0)
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2021-12-21 17:19:45 +00:00
|
|
|
if (ps[p].GetActor()->spr.extra > 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-21 07:56:39 +00:00
|
|
|
auto k = ps[p].cursector;
|
2021-12-22 09:40:26 +00:00
|
|
|
updatesector(ps[p].pos.X, ps[p].pos.Y, &k);
|
2021-12-30 15:51:56 +00:00
|
|
|
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 10:57:10 +00:00
|
|
|
ps[p].pos.X = actor->spr.pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
ps[p].pos.Y = actor->spr.pos.Y;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-22 11:40:42 +00:00
|
|
|
ps[p].opos.X = ps[p].pos.X;
|
2021-12-22 11:42:06 +00:00
|
|
|
ps[p].opos.Y = ps[p].pos.Y;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
ps[p].setCursector(actor->sector());
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
SetActor(ps[p].GetActor(), actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
quickkill(&ps[p]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.statnum == 1 && badguy(a2) && a2->spr.picnum != SECTOREFFECTOR && a2->spr.picnum != LOCATORS)
|
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();
|
2021-12-22 11:17:17 +00:00
|
|
|
updatesector(a2->spr.pos.X, a2->spr.pos.Y, &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
|
|
|
{
|
2020-10-21 22:05:08 +00:00
|
|
|
gutsdir(a2, JIBS6, 24, myconnectindex);
|
2020-10-21 22:00:43 +00:00
|
|
|
S_PlayActorSound(SQUISHED, a2);
|
|
|
|
deletesprite(a2);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-21 22:00:43 +00:00
|
|
|
}
|
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
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[4] > 0 && actor->temp_data[0] == 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]++;
|
|
|
|
else actor->temp_data[0] = 1;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] > 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xvel = 3;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] > 96)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = -1; //Stop the quake
|
|
|
|
actor->temp_data[4] = -1;
|
2020-10-21 22:10:43 +00:00
|
|
|
deletesprite(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if ((actor->temp_data[0] & 31) == 8)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
earthquaketime = 48;
|
2020-10-21 22:10:43 +00:00
|
|
|
S_PlayActorSound(EARTHQUAKE, ps[screenpeek].GetActor());
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (abs(sc->floorheinum - actor->temp_data[5]) < 8)
|
2022-01-09 12:38:10 +00:00
|
|
|
sc->setfloorslope(actor->temp_data[5]);
|
|
|
|
else sc->setfloorslope(sc->getfloorslope() + (Sgn(actor->temp_data[5] - sc->getfloorslope()) << 4));
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
int m = MulScale(actor->spr.xvel, bcos(actor->spr.ang), 14);
|
|
|
|
int x = MulScale(actor->spr.xvel, bsin(actor->spr.ang), 14);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2021-12-30 15:51:56 +00:00
|
|
|
if (ps[p].cursector == actor->sector() && ps[p].on_ground)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 09:36:09 +00:00
|
|
|
ps[p].pos.X += m;
|
2021-12-22 09:40:26 +00:00
|
|
|
ps[p].pos.Y += x;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-30 11:57:39 +00:00
|
|
|
ps[p].bobpos.X += m;
|
2021-12-30 11:59:45 +00:00
|
|
|
ps[p].bobpos.Y += x;
|
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.picnum != SECTOREFFECTOR)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 10:57:10 +00:00
|
|
|
a2->spr.pos.X += m;
|
2021-12-22 11:17:17 +00:00
|
|
|
a2->spr.pos.Y += x;
|
2021-12-21 18:09:05 +00:00
|
|
|
SetActor(a2, a2->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-21 22:10:43 +00:00
|
|
|
ms(actor);
|
2021-12-21 17:29:44 +00:00
|
|
|
SetActor(actor, actor->spr.pos);
|
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;
|
2021-11-14 14:03:50 +00:00
|
|
|
int x;
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2021-11-14 14:03:50 +00:00
|
|
|
findplayer(actor, &x);
|
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(actor->temp_data[5] > 0) { actor->temp_data[5]--; break; }
|
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
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
// actor->temp_data[5] = 4+(global_random&7);
|
2020-10-21 22:10:43 +00:00
|
|
|
sc->ceilingpal = palvals >> 8;
|
|
|
|
sc->floorpal = palvals & 0xff;
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = actor->spr.shade + (global_random & 15);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
// actor->temp_data[5] = 4+(global_random&3);
|
2021-12-21 17:29:44 +00:00
|
|
|
sc->ceilingpal = actor->spr.pal;
|
|
|
|
sc->floorpal = actor->spr.pal;
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = actor->temp_data[3];
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
sc->ceilingshade = actor->temp_data[0];
|
|
|
|
sc->floorshade = actor->temp_data[0];
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-11-07 16:36:09 +00:00
|
|
|
for(auto& wal : wallsofsector(sc))
|
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
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
wal.shade = actor->temp_data[0];
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
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
|
|
|
|
actor->temp_data[0] = 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];
|
|
|
|
actor->temp_data[0] = 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
|
|
|
|
2021-11-07 16:36:09 +00:00
|
|
|
for (auto& wal : wallsofsector(sc))
|
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
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
wal.shade = actor->temp_data[0];
|
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])
|
2020-10-21 22:10:43 +00:00
|
|
|
deletesprite(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:14:54 +00:00
|
|
|
void handle_se05(DDukeActor* actor, int FIRELASER)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sc = actor->sector();
|
2020-10-21 22:14:54 +00:00
|
|
|
int j, l, m;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-23 15:44:45 +00:00
|
|
|
int x, p = findplayer(actor, &x);
|
2020-05-10 07:08:02 +00:00
|
|
|
if (x < 8192)
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
j = actor->spr.ang;
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.ang = getangle(actor->spr.pos.X - ps[p].pos.X, actor->spr.pos.Y - ps[p].pos.Y);
|
2020-10-24 05:34:39 +00:00
|
|
|
fi.shoot(actor, FIRELASER);
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang = j;
|
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;
|
2020-05-10 07:08:02 +00:00
|
|
|
l = 0x7fffffff;
|
|
|
|
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
|
|
|
|
2020-10-21 22:14:54 +00:00
|
|
|
m = ldist(ps[p].GetActor(), NewOwner);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (l > m)
|
|
|
|
{
|
2020-10-21 22:14:54 +00:00
|
|
|
Owner = NewOwner;
|
2020-05-10 07:08:02 +00:00
|
|
|
l = m;
|
|
|
|
}
|
|
|
|
|
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.
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.zvel = Sgn(Owner->spr.pos.Z - actor->spr.pos.Z) << 4;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 22:14:54 +00:00
|
|
|
if (ldist(Owner, actor) < 1024)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
auto ta = actor->spr.ang;
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.ang = getangle(ps[p].pos.X - actor->spr.pos.X, ps[p].pos.Y - actor->spr.pos.Y);
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang = ta;
|
2020-10-21 22:14:54 +00:00
|
|
|
actor->SetOwner(nullptr);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
2021-12-21 17:29:44 +00:00
|
|
|
else actor->spr.xvel = 256;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-22 11:17:17 +00:00
|
|
|
x = getangle(Owner->spr.pos.X - actor->spr.pos.X, Owner->spr.pos.Y - actor->spr.pos.Y);
|
2021-12-21 17:29:44 +00:00
|
|
|
int q = getincangle(actor->spr.ang, x) >> 3;
|
|
|
|
actor->spr.ang += q;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (rnd(32))
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] += q;
|
2020-05-10 07:08:02 +00:00
|
|
|
sc->ceilingshade = 127;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] +=
|
|
|
|
getincangle(actor->temp_data[2] + 512, getangle(ps[p].pos.X - actor->spr.pos.X, ps[p].pos.Y - actor->spr.pos.Y)) >> 2;
|
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
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.zvel += 1024;
|
2020-05-10 07:08:02 +00:00
|
|
|
FTA(7, &ps[myconnectindex]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z += actor->spr.zvel;
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addceilingz(actor->spr.zvel);
|
2022-01-13 21:34:43 +00:00
|
|
|
sector[actor->temp_data[0]].addceilingz(actor->spr.zvel);
|
2020-10-21 22:14:54 +00:00
|
|
|
ms(actor);
|
2021-12-21 17:29:44 +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
|
|
|
|
|
|
|
int x, j = -1;
|
|
|
|
|
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
|
|
|
{
|
2020-10-21 22:14:54 +00:00
|
|
|
deletesprite(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
j = 1;
|
|
|
|
}
|
2021-12-30 15:51:56 +00:00
|
|
|
else j = getanimationgoal(anim_ceilingz, actor->sector());
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (j >= 0)
|
|
|
|
{
|
2020-10-21 22:14:54 +00:00
|
|
|
if ((sc->lotag & 0x8000) || actor->temp_data[4])
|
2021-12-23 15:03:43 +00:00
|
|
|
x = -actor->temp_data[3];
|
2020-05-10 07:08:02 +00:00
|
|
|
else
|
2021-12-23 15:03:43 +00:00
|
|
|
x = actor->temp_data[3];
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
if (st == 9) x = -x;
|
|
|
|
|
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();
|
2021-12-21 17:19:45 +00:00
|
|
|
int m = ac->spr.shade;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-11-07 16:36:09 +00:00
|
|
|
for (auto& wal : wallsofsector(sect))
|
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
|
|
|
{
|
2021-11-07 16:36:09 +00:00
|
|
|
wal.shade += x;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-11-07 16:36:09 +00:00
|
|
|
if (wal.shade < m)
|
|
|
|
wal.shade = m;
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-14 16:55:50 +00:00
|
|
|
sect->floorshade += x;
|
|
|
|
sect->ceilingshade += x;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-14 16:55:50 +00:00
|
|
|
if (sect->floorshade < m)
|
|
|
|
sect->floorshade = m;
|
2020-10-21 22:14:54 +00:00
|
|
|
else if (sect->floorshade > ac->temp_data[0])
|
|
|
|
sect->floorshade = ac->temp_data[0];
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-14 16:55:50 +00:00
|
|
|
if (sect->ceilingshade < m)
|
|
|
|
sect->ceilingshade = m;
|
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
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
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
|
|
|
|
2021-12-10 06:26:56 +00:00
|
|
|
if ((sc->lotag & 0xff) == 27 || (sc->floorz > sc->ceilingz && (sc->lotag & 0xff) != 23) || sc->lotag == 32791 - 65536)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
int j = 1;
|
|
|
|
|
|
|
|
if ((sc->lotag & 0xff) != 27)
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
|
|
|
if (sc->lotag != 30 && sc->lotag != 31 && sc->lotag != 0)
|
2021-12-30 15:51:56 +00:00
|
|
|
if (actor->sector() == ps[p].GetActor()->sector())
|
2020-05-10 07:08:02 +00:00
|
|
|
j = 0;
|
|
|
|
|
|
|
|
if (j == 1)
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] > sh)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
if (specialtags) for (int i = 0; specialtags[i]; i++)
|
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if (actor->sector()->lotag == specialtags[i] && getanimationgoal(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);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else actor->temp_data[0]++;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else actor->temp_data[0] = 0;
|
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();
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[5] > 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[5]--;
|
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
|
|
|
{
|
2021-11-18 22:00:24 +00:00
|
|
|
for(auto& wal : wallsofsector(sc))
|
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
|
|
|
{
|
2021-12-22 11:17:17 +00:00
|
|
|
if (ac->spr.extra > 0 && badguy(ac) && clipinsidebox(ac->spr.pos.X, ac->spr.pos.Y, wallnum(&wal), 256) == 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-01-03 04:44:57 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
int k = (actor->spr.yvel >> 3) * actor->temp_data[3];
|
|
|
|
actor->temp_data[2] += k;
|
|
|
|
actor->temp_data[4] += k;
|
2021-01-03 04:44:57 +00:00
|
|
|
ms(actor);
|
2021-12-21 17:29:44 +00:00
|
|
|
SetActor(actor, actor->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-11-18 22:00:24 +00:00
|
|
|
for(auto& wal : wallsofsector(sc))
|
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
|
|
|
{
|
2021-12-22 11:17:17 +00:00
|
|
|
if (ac->GetOwner() && clipinsidebox(ac->spr.pos.X, ac->spr.pos.Y, wallnum(&wal), 144) == 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[5] = 8; // Delay
|
|
|
|
actor->temp_data[2] -= k;
|
|
|
|
actor->temp_data[4] -= k;
|
2021-01-03 04:44:57 +00:00
|
|
|
ms(actor);
|
2021-12-21 17:29:44 +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;
|
|
|
|
actor->temp_data[2] &= 0xffffff00;
|
2020-10-21 22:20:47 +00:00
|
|
|
ms(actor);
|
2021-12-21 17:29:44 +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();
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 3 || actor->temp_data[3] == 1) //Lights going off
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
sc->floorpal = 0;
|
|
|
|
sc->ceilingpal = 0;
|
|
|
|
|
2021-11-18 22:00:24 +00:00
|
|
|
for (auto& wal : wallsofsector(sc))
|
|
|
|
{
|
|
|
|
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];
|
|
|
|
actor->temp_data[0] = 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
|
|
|
{
|
2020-10-21 22:20:47 +00:00
|
|
|
deletesprite(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 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;
|
|
|
|
|
2021-11-18 22:00:24 +00:00
|
|
|
for (auto& wal : wallsofsector(sc))
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else actor->temp_data[0] = 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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
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
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
int j = (actor->spr.yvel << 5) | 1;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.ang == 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
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (abs(actor->temp_data[0] - sc->ceilingz) >= j)
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addceilingz(Sgn(actor->temp_data[0] - sc->ceilingz) * j);
|
|
|
|
else sc->setceilingz(actor->temp_data[0]);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (abs(actor->temp_data[1] - sc->floorz) >= j)
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addfloorz(Sgn(actor->temp_data[1] - sc->floorz) * j);
|
|
|
|
else sc->setfloorz(actor->temp_data[1]);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (abs(actor->temp_data[1] - sc->floorz) >= j)
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addfloorz(Sgn(actor->temp_data[1] - sc->floorz) * j);
|
|
|
|
else sc->setfloorz(actor->temp_data[1]);
|
2021-12-23 15:03:43 +00:00
|
|
|
if (abs(actor->temp_data[0] - sc->ceilingz) >= j)
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addceilingz(Sgn(actor->temp_data[0] - sc->ceilingz) * j);
|
|
|
|
sc->setceilingz(actor->temp_data[0]);
|
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
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.ang == 512)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-18 22:00:24 +00:00
|
|
|
for (auto& wal : wallsofsector(sc))
|
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
|
|
|
|
2021-11-17 23:08:52 +00:00
|
|
|
if (ps[0].one_parallax_sectnum != nullptr)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-17 23:08:52 +00:00
|
|
|
sc->ceilingpicnum = ps[0].one_parallax_sectnum->ceilingpicnum;
|
|
|
|
sc->ceilingshade = ps[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
|
|
|
{
|
2020-10-21 22:20:47 +00:00
|
|
|
deletesprite(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[2] == 4 && actor->spr.ang != 512)
|
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
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xvel = 16;
|
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
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[3] >= (actor->spr.yvel >> 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
|
|
|
}
|
|
|
|
|
2020-10-21 22:25:11 +00:00
|
|
|
ms(actor);
|
2021-12-21 17:29:44 +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_se16(DDukeActor* actor, int REACTOR, int REACTOR2)
|
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
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] += 32;
|
2021-12-21 17:29:44 +00:00
|
|
|
if (sc->floorz < sc->ceilingz) actor->spr.shade = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (sc->ceilingz < actor->temp_data[3])
|
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
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.picnum == REACTOR || a2->spr.picnum == REACTOR2)
|
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
|
|
|
{
|
2020-10-21 22:25:11 +00:00
|
|
|
deletesprite(actor);
|
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
|
|
|
}
|
|
|
|
|
2021-12-27 21:32:26 +00:00
|
|
|
if (actor->spr.shade) sc->addceilingz(1024);
|
|
|
|
else sc->addceilingz(-512);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-21 22:25:11 +00:00
|
|
|
ms(actor);
|
2021-12-21 17:29:44 +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;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
int q = actor->temp_data[0] * (actor->spr.yvel << 2);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-27 21:32:26 +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
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
int p = act1->spr.yvel;
|
2021-12-22 11:44:17 +00:00
|
|
|
if (numplayers < 2) ps[p].opos.Z = ps[p].pos.Z;
|
2021-12-22 09:41:47 +00:00
|
|
|
ps[p].pos.Z += q;
|
2020-05-10 07:08:02 +00:00
|
|
|
ps[p].truefz += q;
|
|
|
|
ps[p].truecz += q;
|
2021-12-22 11:44:17 +00:00
|
|
|
if (numplayers > 1) ps[p].opos.Z = ps[p].pos.Z;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act1->spr.statnum != STAT_EFFECTOR)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-30 16:10:08 +00:00
|
|
|
act1->backupz();
|
2021-12-22 11:29:00 +00:00
|
|
|
act1->spr.pos.Z += q;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 22:25:11 +00:00
|
|
|
act1->floorz = sc->floorz;
|
|
|
|
act1->ceilingz = sc->ceilingz;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0]) //If in motion
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (abs(sc->floorz - actor->temp_data[2]) <= actor->spr.yvel)
|
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;
|
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == -1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (sc->floorz > actor->temp_data[3])
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (sc->ceilingz < actor->temp_data[4]) 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)
|
2021-12-23 15:03:43 +00:00
|
|
|
if ((sc->hitag - actor->temp_data[0]) == (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
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
int p = act3->spr.yvel;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-22 10:57:10 +00:00
|
|
|
ps[p].pos.X += act2->spr.pos.X - actor->spr.pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
ps[p].pos.Y += act2->spr.pos.Y - actor->spr.pos.Y;
|
2021-12-30 15:51:56 +00:00
|
|
|
ps[p].pos.Z = act2->sector()->floorz - (sc->floorz - ps[p].pos.Z);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
act3->floorz = act2->sector()->floorz;
|
|
|
|
act3->ceilingz = act2->sector()->ceilingz;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-30 11:57:39 +00:00
|
|
|
ps[p].bobpos.X = ps[p].opos.X = ps[p].pos.X;
|
2021-12-30 11:59:45 +00:00
|
|
|
ps[p].bobpos.Y = ps[p].opos.Y = ps[p].pos.Y;
|
2021-12-22 11:44:17 +00:00
|
|
|
ps[p].opos.Z = ps[p].pos.Z;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-11-01 08:45:37 +00:00
|
|
|
ps[p].truefz = act3->floorz;
|
|
|
|
ps[p].truecz = act3->ceilingz;
|
2020-05-10 07:08:02 +00:00
|
|
|
ps[p].bobcounter = 0;
|
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
ChangeActorSect(act3, act2->sector());
|
|
|
|
ps[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
|
|
|
{
|
2021-12-22 10:57:10 +00:00
|
|
|
act3->spr.pos.X += act2->spr.pos.X - actor->spr.pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
act3->spr.pos.Y += act2->spr.pos.Y - actor->spr.pos.Y;
|
2021-12-30 15:51:56 +00:00
|
|
|
act3->spr.pos.Z = act2->sector()->floorz - (sc->floorz - act3->spr.pos.Z);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-30 16:10:08 +00:00
|
|
|
act3->backupz();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
ChangeActorSect(act3, act2->sector());
|
2021-12-21 18:09:05 +00:00
|
|
|
SetActor(act3, act3->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-30 15:51:56 +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
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0])
|
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
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (actor->spr.ang == 512)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addceilingz(-sc->extra);
|
2021-12-23 15:03:43 +00:00
|
|
|
if (sc->ceilingz <= actor->temp_data[1])
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->setceilingz(actor->temp_data[1]);
|
2020-10-21 22:30:22 +00:00
|
|
|
deletesprite(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addfloorz(sc->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())
|
2021-12-22 09:41:47 +00:00
|
|
|
if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].pos.Z += sc->extra;
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && a2->spr.statnum != STAT_PROJECTILE)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
a2->spr.pos.Z += sc->extra;
|
2020-10-21 22:30:22 +00:00
|
|
|
a2->floorz = sc->floorz;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
if (sc->floorz >= actor->temp_data[1])
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->setfloorz(actor->temp_data[1]);
|
2020-10-21 22:30:22 +00:00
|
|
|
deletesprite(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (actor->spr.ang == 512)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addceilingz(sc->extra);
|
2021-12-22 11:29:00 +00:00
|
|
|
if (sc->ceilingz >= actor->spr.pos.Z)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->setceilingz(actor->spr.pos.Z);
|
2020-10-21 22:30:22 +00:00
|
|
|
deletesprite(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addfloorz(-sc->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())
|
2021-12-22 09:41:47 +00:00
|
|
|
if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].pos.Z -= sc->extra;
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && a2->spr.statnum != STAT_PROJECTILE)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
a2->spr.pos.Z -= sc->extra;
|
2020-10-21 22:30:22 +00:00
|
|
|
a2->floorz = sc->floorz;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-22 11:29:00 +00:00
|
|
|
if (sc->floorz <= actor->spr.pos.Z)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->setfloorz(actor->spr.pos.Z);
|
2020-10-21 22:30:22 +00:00
|
|
|
deletesprite(actor);
|
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;
|
|
|
|
actor->temp_data[0] = 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-01-07 15:36:02 +00:00
|
|
|
if (actorflag(a1, SFLAG_TRIGGER_IFHITSECTOR) && sect == a1->sector())
|
2022-01-02 11:27:36 +00:00
|
|
|
return a1;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:30:22 +00:00
|
|
|
void handle_se19(DDukeActor *actor, int BIGFORCE)
|
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
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0])
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2021-11-15 21:59:51 +00:00
|
|
|
for (auto& wal : wallsofsector(sc))
|
|
|
|
{
|
|
|
|
if (wal.overpicnum == BIGFORCE)
|
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);
|
2021-11-15 21:59:51 +00:00
|
|
|
wal.overpicnum = 0;
|
|
|
|
auto nextwal = wal.nextWall();
|
|
|
|
if (nextwal != nullptr)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-11-15 21:59:51 +00:00
|
|
|
nextwal->overpicnum = 0;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->ceilingz < sc->floorz)
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addceilingz(actor->spr.yvel);
|
2020-05-10 07:08:02 +00:00
|
|
|
else
|
|
|
|
{
|
2021-12-27 21:32:26 +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;
|
2020-10-21 22:30:22 +00:00
|
|
|
a2Owner->temp_data[0] = 2;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-21 22:30:22 +00:00
|
|
|
deletesprite(actor);
|
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
|
|
|
{
|
|
|
|
FTA(8, &ps[myconnectindex]);
|
|
|
|
|
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)
|
2020-10-21 22:30:22 +00:00
|
|
|
if (ac->temp_data[0] == 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-21 22:30:22 +00:00
|
|
|
ac->temp_data[0] = 1; //Shut them all on
|
|
|
|
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
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 0) return;
|
|
|
|
if (actor->temp_data[0] == 1) actor->spr.xvel = 8;
|
2021-12-21 17:29:44 +00:00
|
|
|
else actor->spr.xvel = -8;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xvel) //Moving
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
int x = MulScale(actor->spr.xvel, bcos(actor->spr.ang), 14);
|
|
|
|
int l = MulScale(actor->spr.xvel, bsin(actor->spr.ang), 14);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[3] += actor->spr.xvel;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-22 10:57:10 +00:00
|
|
|
actor->spr.pos.X += x;
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.pos.Y += l;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[3] <= 0 || (actor->temp_data[3] >> 6) >= (actor->spr.yvel >> 6))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 10:57:10 +00:00
|
|
|
actor->spr.pos.X -= x;
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.pos.Y -= l;
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 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
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.statnum != 3 && a2->spr.zvel == 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 10:57:10 +00:00
|
|
|
a2->spr.pos.X += x;
|
2021-12-22 11:17:17 +00:00
|
|
|
a2->spr.pos.Y += l;
|
2021-12-21 17:19:45 +00:00
|
|
|
SetActor(a2, a2->spr.pos);
|
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;
|
2021-12-22 10:06:32 +00:00
|
|
|
dragpoint(wal[0], wal[0]->pos.X + x, wal[0]->pos.Y + l);
|
|
|
|
dragpoint(wal[1], wal[1]->pos.X + x, wal[1]->pos.Y + l);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2021-12-30 15:51:56 +00:00
|
|
|
if (ps[p].cursector == actor->sector() && ps[p].on_ground)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 09:36:09 +00:00
|
|
|
ps[p].pos.X += x;
|
2021-12-22 09:40:26 +00:00
|
|
|
ps[p].pos.Y += l;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-22 11:40:42 +00:00
|
|
|
ps[p].opos.X = ps[p].pos.X;
|
2021-12-22 11:42:06 +00:00
|
|
|
ps[p].opos.Y = ps[p].pos.Y;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-22 09:41:47 +00:00
|
|
|
SetActor(ps[p].GetActor(), { ps[p].pos.X, ps[p].pos.Y, ps[p].pos.Z + gs.playerheight });
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2020-11-25 19:52:06 +00:00
|
|
|
sc->addfloorxpan(-x / 8.f);
|
|
|
|
sc->addfloorypan(-l / 8.f);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-11-25 19:52:06 +00:00
|
|
|
sc->addceilingxpan(-x / 8.f);
|
|
|
|
sc->addceilingypan(-l / 8.f);
|
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();
|
2020-05-10 07:08:02 +00:00
|
|
|
int* lp;
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 0) return;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.ang == 1536)
|
2021-12-27 21:32:26 +00:00
|
|
|
lp = sc->ceilingzptr();
|
2020-05-10 07:08:02 +00:00
|
|
|
else
|
2021-12-27 21:32:26 +00:00
|
|
|
lp = sc->floorzptr();
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 1) //Decide if the sector should go up or down
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.zvel = Sgn(actor->spr.pos.Z - *lp) * (actor->spr.yvel << 4);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->extra == 0)
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
*lp += actor->spr.zvel;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
if (abs(*lp - actor->spr.pos.Z) < 1024)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
*lp = actor->spr.pos.Z;
|
2020-10-21 22:35:30 +00:00
|
|
|
deletesprite(actor);
|
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-01-13 21:34:43 +00:00
|
|
|
if (getanimationgoal(anim_ceilingz, §or[actor->temp_data[0]]) >= 0)
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addceilingz(sc->extra * 9);
|
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();
|
2020-10-21 22:35:30 +00:00
|
|
|
int x, l;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xvel = 32;
|
|
|
|
l = MulScale(actor->spr.xvel, bcos(actor->spr.ang), 14);
|
|
|
|
x = MulScale(actor->spr.xvel, bsin(actor->spr.ang), 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
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->spr.pos.X = actor->temp_data[3];
|
|
|
|
actor->spr.pos.Y = actor->temp_data[4];
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addfloorz(-((actor->spr.zvel * actor->spr.shade) - actor->spr.zvel));
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.shade = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addfloorz(actor->spr.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
|
|
|
{
|
2021-12-22 10:57:10 +00:00
|
|
|
a2->spr.pos.X += l;
|
2021-12-22 11:17:17 +00:00
|
|
|
a2->spr.pos.Y += x;
|
2021-12-22 11:29:00 +00:00
|
|
|
a2->spr.pos.Z += actor->spr.zvel;
|
2021-12-21 17:19:45 +00:00
|
|
|
SetActor(a2, a2->spr.pos);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
2021-12-30 15:51:56 +00:00
|
|
|
if (ps[p].GetActor()->sector() == actor->sector() && ps[p].on_ground)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 09:26:51 +00:00
|
|
|
ps[p].fric.X += l << 5;
|
2021-12-22 09:28:51 +00:00
|
|
|
ps[p].fric.Y += x << 5;
|
2021-12-22 09:41:47 +00:00
|
|
|
ps[p].pos.Z += actor->spr.zvel;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 22:35:30 +00:00
|
|
|
ms(actor);
|
2021-12-21 17:29:44 +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;
|
2020-05-10 07:08:02 +00:00
|
|
|
int x, p;
|
|
|
|
|
|
|
|
if (ud.recstat == 0) return;
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->tempang = actor->spr.ang;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2020-10-23 15:44:45 +00:00
|
|
|
p = findplayer(actor, &x);
|
2021-12-21 17:19:45 +00:00
|
|
|
if (ps[p].GetActor()->spr.extra > 0 && myconnectindex == screenpeek)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] < 0)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-11-02 22:53:55 +00:00
|
|
|
ud.cameraactor = actor;
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2020-11-02 23:20:51 +00:00
|
|
|
else if (ud.recstat == 2 && ps[p].newOwner == nullptr)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if (cansee(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, actor->sector(), ps[p].pos.X, ps[p].pos.Y, ps[p].pos.Z, ps[p].cursector))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-05-12 15:57:36 +00:00
|
|
|
if (x < sh)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-11-02 22:53:55 +00:00
|
|
|
ud.cameraactor = actor;
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 999;
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.ang += getincangle(actor->spr.ang, getangle(ps[p].pos.X - actor->spr.pos.X, ps[p].pos.Y - actor->spr.pos.Y)) >> 3;
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.yvel = 100 + ((actor->spr.pos.Z - ps[p].pos.Z) / 257);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (actor->temp_data[0] == 999)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-11-02 22:53:55 +00:00
|
|
|
if (ud.cameraactor == actor)
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 0;
|
|
|
|
else actor->temp_data[0] = -10;
|
2020-11-02 22:53:55 +00:00
|
|
|
ud.cameraactor = actor;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-22 11:17:17 +00:00
|
|
|
actor->spr.ang = getangle(ps[p].pos.X - actor->spr.pos.X, ps[p].pos.Y - actor->spr.pos.Y);
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 999)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-11-02 22:53:55 +00:00
|
|
|
if (ud.cameraactor == actor)
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 0;
|
|
|
|
else actor->temp_data[0] = -20;
|
2020-11-02 22:53:55 +00:00
|
|
|
ud.cameraactor = actor;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-01-25 21:26:53 +00:00
|
|
|
void handle_se24(DDukeActor *actor, const int16_t *list1, const int16_t *list2, bool scroll, int TRIPBOMB, int LASERLINE, int shift)
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
2021-11-06 12:53:18 +00:00
|
|
|
auto testlist = [](const int16_t* list, int val) { for (int i = 0; list[i] > 0; i++) if (list[i] == val) return true; return false; };
|
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
|
|
|
|
2021-12-21 17:19:45 +00:00
|
|
|
int x = MulScale(actor->spr.yvel, bcos(actor->spr.ang), 18);
|
|
|
|
int l = MulScale(actor->spr.yvel, bsin(actor->spr.ang), 18);
|
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())
|
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
if (a2->spr.zvel >= 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
|
|
|
{
|
|
|
|
case 5:
|
2021-12-21 18:09:05 +00:00
|
|
|
if (testlist(list1, a2->spr.picnum))
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
2021-12-21 18:09:05 +00:00
|
|
|
a2->spr.xrepeat = a2->spr.yrepeat = 0;
|
2020-10-21 22:50:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
2021-12-21 18:09:05 +00:00
|
|
|
if (a2->spr.picnum == LASERLINE)
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-11-14 11:25:25 +00:00
|
|
|
[[fallthrough]];
|
2020-10-21 22:50:01 +00:00
|
|
|
case 6:
|
2021-12-21 18:09:05 +00:00
|
|
|
if (a2->spr.picnum == TRIPBOMB) break;
|
2021-11-14 11:25:25 +00:00
|
|
|
[[fallthrough]];
|
2020-10-21 22:50:01 +00:00
|
|
|
case 1:
|
|
|
|
case 0:
|
2021-12-21 18:09:05 +00:00
|
|
|
if (testlist(list2, a2->spr.picnum) ||
|
2020-10-21 22:50:01 +00:00
|
|
|
wallswitchcheck(a2))
|
|
|
|
break;
|
|
|
|
|
2022-01-25 21:26:53 +00:00
|
|
|
if (!(gs.actorinfo[a2->spr.picnum].flags & SFLAG_SE24_NOFLOORCHECK))
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
if (a2->spr.pos.Z > (a2->floorz - (16 << 8)))
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
2021-12-22 10:57:10 +00:00
|
|
|
a2->spr.pos.X += x >> shift;
|
2021-12-22 11:17:17 +00:00
|
|
|
a2->spr.pos.Y += l >> shift;
|
2020-10-21 22:50:01 +00:00
|
|
|
|
2021-12-21 18:09:05 +00:00
|
|
|
SetActor(a2, a2->spr.pos);
|
2020-10-21 22:50:01 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
if (a2->sector()->floorstat & CSTAT_SECTOR_SLOPE)
|
2022-01-25 21:26:53 +00:00
|
|
|
if (a2->spr.statnum == STAT_ZOMBIEACTOR)
|
2020-10-21 22:50:01 +00:00
|
|
|
makeitfall(a2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto p = connecthead; p >= 0; p = connectpoint2[p])
|
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if (ps[p].cursector == actor->sector() && ps[p].on_ground)
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
2021-12-22 09:41:47 +00:00
|
|
|
if (abs(ps[p].pos.Z - ps[p].truefz) < gs.playerheight + (9 << 8))
|
2020-10-21 22:50:01 +00:00
|
|
|
{
|
2021-12-22 09:26:51 +00:00
|
|
|
ps[p].fric.X += x << 3;
|
2021-12-22 09:28:51 +00:00
|
|
|
ps[p].fric.Y += l << 3;
|
2020-10-21 22:50:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-21 17:19:45 +00:00
|
|
|
if (scroll) actor->sector()->addfloorxpan(actor->spr.yvel / 128.f);
|
2020-10-21 22:50:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:59:42 +00:00
|
|
|
void handle_se25(DDukeActor* actor, int t_index, int snd1, int snd2)
|
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
auto sec = actor->sector();
|
2020-10-21 22:59:42 +00:00
|
|
|
|
|
|
|
if (sec->floorz <= sec->ceilingz)
|
2021-12-21 17:19:45 +00:00
|
|
|
actor->spr.shade = 0;
|
2021-12-23 15:03:43 +00:00
|
|
|
else if (sec->ceilingz <= actor->temp_data[t_index])
|
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
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sec->addceilingz(actor->spr.yvel << 4);
|
2020-10-21 22:59:42 +00:00
|
|
|
if (sec->ceilingz > sec->floorz)
|
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sec->setceilingz(sec->floorz);
|
2020-10-21 22:59:42 +00:00
|
|
|
if (pistonsound && snd1 >= 0)
|
|
|
|
S_PlayActorSound(snd1, actor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sec->addceilingz(-actor->spr.yvel << 4);
|
2021-12-23 15:03:43 +00:00
|
|
|
if (sec->ceilingz < actor->temp_data[t_index])
|
2020-10-21 22:59:42 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sec->setceilingz(actor->temp_data[t_index]);
|
2020-10-21 22:59:42 +00:00
|
|
|
if (pistonsound && snd2 >= 0)
|
|
|
|
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
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 1)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
// Choose dir
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[2] == 1) // Retract
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.ang != 1536)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
if (abs(sc->ceilingz - actor->spr.pos.Z) < (actor->spr.yvel << 1))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +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;
|
|
|
|
actor->temp_data[0] = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2021-12-27 21:32:26 +00:00
|
|
|
else sc->addceilingz(Sgn(actor->spr.pos.Z - sc->ceilingz) * actor->spr.yvel);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (abs(sc->ceilingz - actor->temp_data[1]) < (actor->spr.yvel << 1))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->setceilingz(actor->temp_data[1]);
|
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;
|
|
|
|
actor->temp_data[0] = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2022-01-05 11:45:10 +00:00
|
|
|
else sc->addceilingz(Sgn(actor->temp_data[1] - sc->ceilingz) * actor->spr.yvel);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if ((actor->spr.ang & 2047) == 1536)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
if (abs(sc->ceilingz - actor->spr.pos.Z) < (actor->spr.yvel << 1))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 0;
|
|
|
|
actor->temp_data[2] = !actor->temp_data[2];
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->setceilingz(actor->spr.pos.Z);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
2021-12-27 21:32:26 +00:00
|
|
|
else sc->addceilingz(Sgn(actor->spr.pos.Z - sc->ceilingz) * actor->spr.yvel);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (abs(sc->ceilingz - actor->temp_data[1]) < (actor->spr.yvel << 1))
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 0;
|
|
|
|
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
|
|
|
}
|
2021-12-27 21:32:26 +00:00
|
|
|
else sc->addceilingz(-Sgn(actor->spr.pos.Z - actor->temp_data[1]) * actor->spr.yvel);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:40:57 +00:00
|
|
|
void handle_se35(DDukeActor *actor, int SMALLSMOKE, int EXPLOSION2)
|
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
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
if (sc->ceilingz > actor->spr.pos.Z)
|
2020-05-10 07:08:02 +00:00
|
|
|
for (int j = 0; j < 8; j++)
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang += krand() & 511;
|
2020-10-21 22:40:57 +00:00
|
|
|
auto spawned = spawn(actor, SMALLSMOKE);
|
2021-11-19 11:32:12 +00:00
|
|
|
if (spawned)
|
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
spawned->spr.xvel = 96 + (krand() & 127);
|
2021-11-19 11:32:12 +00:00
|
|
|
ssp(spawned, CLIPMASK0);
|
2021-12-21 17:19:45 +00:00
|
|
|
SetActor(spawned, spawned->spr.pos);
|
2021-11-19 11:32:12 +00:00
|
|
|
if (rnd(16))
|
|
|
|
spawn(actor, EXPLOSION2);
|
|
|
|
}
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
switch (actor->temp_data[0])
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addceilingz(actor->spr.yvel);
|
2020-05-10 07:08:02 +00:00
|
|
|
if (sc->ceilingz > sc->floorz)
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->setfloorz(sc->ceilingz);
|
2021-12-22 11:29:00 +00:00
|
|
|
if (sc->ceilingz > actor->spr.pos.Z + (32 << 8))
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0]++;
|
2020-05-10 07:08:02 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->addceilingz(-(actor->spr.yvel << 2));
|
2021-12-23 15:03:43 +00:00
|
|
|
if (sc->ceilingz < actor->temp_data[4])
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sc->setceilingz(actor->temp_data[4]);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 0;
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
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
|
|
|
|
|
|
|
wal->overpicnum++;
|
2021-11-15 22:32:41 +00:00
|
|
|
auto nextwal = wal->nextWall();
|
|
|
|
if (nextwal)
|
|
|
|
nextwal->overpicnum++;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] < actor->temp_data[1]) actor->temp_data[0]++;
|
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);
|
2020-10-21 22:40:57 +00:00
|
|
|
deletesprite(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 22:40:57 +00:00
|
|
|
void handle_se130(DDukeActor *actor, int countmax, int EXPLOSION2)
|
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
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] > countmax)
|
2020-05-10 07:08:02 +00:00
|
|
|
{
|
2020-10-21 22:40:57 +00:00
|
|
|
deletesprite(actor);
|
2020-05-10 07:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-23 15:03:43 +00:00
|
|
|
else actor->temp_data[0]++;
|
2020-05-10 07:08:02 +00:00
|
|
|
|
|
|
|
int x = sc->floorz - sc->ceilingz;
|
|
|
|
|
|
|
|
if (rnd(64))
|
|
|
|
{
|
2020-10-21 22:40:57 +00:00
|
|
|
auto k = spawn(actor, EXPLOSION2);
|
2021-11-19 11:32:12 +00:00
|
|
|
if (k)
|
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
k->spr.xrepeat = k->spr.yrepeat = 2 + (krand() & 7);
|
2021-12-22 11:29:00 +00:00
|
|
|
k->spr.pos.Z = sc->floorz - (krand() % x);
|
2021-12-21 17:19:45 +00:00
|
|
|
k->spr.ang += 256 - (krand() % 511);
|
|
|
|
k->spr.xvel = krand() & 127;
|
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
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
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
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
if (actor->temp_data[0] == 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
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.ang != 1536)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
if (abs(sec->floorz - actor->spr.pos.Z) < actor->spr.yvel)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sec->setfloorz(actor->spr.pos.Z);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[2] = 0;
|
|
|
|
actor->temp_data[0] = 0;
|
|
|
|
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
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
int l = Sgn(actor->spr.pos.Z - sec->floorz) * actor->spr.yvel;
|
2021-12-27 21:32:26 +00:00
|
|
|
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())
|
2020-10-21 23:04:13 +00:00
|
|
|
if (ps[a2->PlayerIndex()].on_ground == 1)
|
2021-12-22 09:41:47 +00:00
|
|
|
ps[a2->PlayerIndex()].pos.Z += l;
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
a2->spr.pos.Z += l;
|
2020-10-21 23:04:13 +00:00
|
|
|
a2->floorz = sec->floorz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (abs(sec->floorz - actor->temp_data[1]) < actor->spr.yvel)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2021-12-27 21:32:26 +00:00
|
|
|
sec->setfloorz(actor->temp_data[1]);
|
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;
|
|
|
|
actor->temp_data[0] = 0;
|
|
|
|
if (choosedir) actor->temp_data[3] = actor->spr.hitag;
|
2020-10-21 23:04:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
int l = Sgn(actor->temp_data[1] - sec->floorz) * actor->spr.yvel;
|
2021-12-27 21:32:26 +00:00
|
|
|
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())
|
2020-10-21 23:04:13 +00:00
|
|
|
if (ps[a2->PlayerIndex()].on_ground == 1)
|
2021-12-22 09:41:47 +00:00
|
|
|
ps[a2->PlayerIndex()].pos.Z += l;
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
a2->spr.pos.Z += l;
|
2020-10-21 23:04:13 +00:00
|
|
|
a2->floorz = sec->floorz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if ((actor->spr.ang & 2047) == 1536)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
if (abs(actor->spr.pos.Z - sec->floorz) < actor->spr.yvel)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
callsound(actor->sector(), actor);
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 0;
|
|
|
|
actor->temp_data[2] = 1;
|
|
|
|
if (choosedir) actor->temp_data[3] = actor->spr.hitag;
|
2020-10-21 23:04:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
int l = Sgn(actor->spr.pos.Z - sec->floorz) * actor->spr.yvel;
|
2021-12-27 21:32:26 +00:00
|
|
|
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())
|
2020-10-21 23:04:13 +00:00
|
|
|
if (ps[a2->PlayerIndex()].on_ground == 1)
|
2021-12-22 09:41:47 +00:00
|
|
|
ps[a2->PlayerIndex()].pos.Z += l;
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
a2->spr.pos.Z += l;
|
2020-10-21 23:04:13 +00:00
|
|
|
a2->floorz = sec->floorz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
if (abs(sec->floorz - actor->temp_data[1]) < actor->spr.yvel)
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
actor->temp_data[0] = 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
|
|
|
|
{
|
2021-12-23 15:03:43 +00:00
|
|
|
int l = Sgn(actor->spr.pos.Z - actor->temp_data[1]) * actor->spr.yvel;
|
2021-12-27 21:32:26 +00:00
|
|
|
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())
|
2020-10-21 23:04:13 +00:00
|
|
|
if (ps[a2->PlayerIndex()].on_ground == 1)
|
2021-12-22 09:41:47 +00:00
|
|
|
ps[a2->PlayerIndex()].pos.Z -= l;
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
|
2020-10-21 23:04:13 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
a2->spr.pos.Z -= l;
|
2020-10-21 23:04:13 +00:00
|
|
|
a2->floorz = sec->floorz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 23:10:56 +00:00
|
|
|
void getglobalz(DDukeActor* actor)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2020-10-21 23:10:56 +00:00
|
|
|
int zr;
|
|
|
|
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)
|
2020-05-13 22:04:14 +00:00
|
|
|
zr = 4;
|
|
|
|
else zr = 127;
|
|
|
|
|
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.
|
2021-12-30 15:51:56 +00:00
|
|
|
getzrange({ actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - (FOURSLEIGHT) }, 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
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xvel = -256;
|
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
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xvel = -256;
|
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
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
actor->ceilingz = actor->sector()->ceilingz;
|
|
|
|
actor->floorz = actor->sector()->floorz;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-30 15:51:56 +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
|
|
|
{
|
2020-10-21 23:11:38 +00:00
|
|
|
int c;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
if( fi.floorspace(actor->sector()) )
|
2020-05-13 22:04:14 +00:00
|
|
|
c = 0;
|
|
|
|
else
|
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if( fi.ceilingspace(actor->sector()) || actor->sector()->lotag == ST_2_UNDERWATER)
|
2020-11-29 12:54:58 +00:00
|
|
|
c = gs.gravity/6;
|
|
|
|
else c = gs.gravity;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2020-05-13 22:04:14 +00:00
|
|
|
if (isRRRA())
|
|
|
|
{
|
2020-10-21 23:11:38 +00:00
|
|
|
c = adjustfall(actor, c); // this accesses sprite indices and cannot be in shared code. Should be done better.
|
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;
|
2021-12-30 15:51:56 +00:00
|
|
|
getzrange({ actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - (FOURSLEIGHT) }, actor->sector(), &actor->ceilingz, coll, &actor->floorz, coll, 127, CLIPMASK0);
|
2020-10-21 23:11:38 +00:00
|
|
|
}
|
2020-05-13 22:04:14 +00:00
|
|
|
else
|
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
actor->ceilingz = actor->sector()->ceilingz;
|
|
|
|
actor->floorz = actor->sector()->floorz;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
if( actor->spr.pos.Z < actor->floorz-(FOURSLEIGHT) )
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if( actor->sector()->lotag == 2 && actor->spr.zvel > 3122 )
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.zvel = 3144;
|
|
|
|
if(actor->spr.zvel < 6144)
|
|
|
|
actor->spr.zvel += c;
|
|
|
|
else actor->spr.zvel = 6144;
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z += actor->spr.zvel;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
2021-12-22 11:29:00 +00:00
|
|
|
if( actor->spr.pos.Z >= actor->floorz-(FOURSLEIGHT) )
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z = actor->floorz - FOURSLEIGHT;
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.zvel = 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
|
|
|
{
|
2020-11-14 09:49:46 +00:00
|
|
|
int bx, by, mx, my, bxvect, byvect, d;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-12-22 10:57:10 +00:00
|
|
|
mx = actor->spr.pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
my = actor->spr.pos.Y;
|
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;
|
|
|
|
|
2021-12-22 10:57:10 +00:00
|
|
|
bx = ac->spr.pos.X - mx;
|
2021-12-22 11:17:17 +00:00
|
|
|
by = ac->spr.pos.Y - my;
|
2021-12-21 18:09:05 +00:00
|
|
|
bxvect = bcos(ac->spr.ang);
|
|
|
|
byvect = bsin(ac->spr.ang);
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (bcos(actor->spr.ang) * bx + bsin(actor->spr.ang) * by >= 0)
|
2020-05-13 22:04:14 +00:00
|
|
|
if (bxvect * bx + byvect * by < 0)
|
|
|
|
{
|
|
|
|
d = bxvect * by - byvect * bx;
|
|
|
|
if (abs(d) < 65536 * 64)
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang -= 512 + (krand() & 1024);
|
2020-05-13 22:04:14 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 23:12:16 +00:00
|
|
|
int furthestangle(DDukeActor *actor, int angs)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2021-11-17 22:53:11 +00:00
|
|
|
int j, furthest_angle = 0, angincs;
|
2021-11-25 23:08:59 +00:00
|
|
|
int d, greatestd;
|
2021-12-06 11:24:22 +00:00
|
|
|
HitInfo hit{};
|
2020-05-13 22:04:14 +00:00
|
|
|
|
|
|
|
greatestd = -(1 << 30);
|
|
|
|
angincs = 2048 / angs;
|
|
|
|
|
2021-12-31 17:47:00 +00:00
|
|
|
if (!actor->isPlayer())
|
2021-12-21 17:29:44 +00:00
|
|
|
if ((actor->temp_data[0] & 63) > 2) return(actor->spr.ang + 1024);
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
for (j = actor->spr.ang; j < (2048 + actor->spr.ang); j += angincs)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
hitscan({ actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - (8 << 8) }, actor->sector(), { bcos(j), bsin(j), 0 }, hit, CLIPMASK1);
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-12-22 11:17:17 +00:00
|
|
|
d = abs(hit.hitpos.X - actor->spr.pos.X) + abs(hit.hitpos.Y - actor->spr.pos.Y);
|
2020-05-13 22:04:14 +00:00
|
|
|
|
|
|
|
if (d > greatestd)
|
|
|
|
{
|
|
|
|
greatestd = d;
|
|
|
|
furthest_angle = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (furthest_angle & 2047);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
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
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-21 23:12:16 +00:00
|
|
|
int furthestcanseepoint(DDukeActor *actor, DDukeActor* tosee, int* dax, int* day)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2021-11-17 23:07:38 +00:00
|
|
|
int j, angincs;
|
2021-11-25 23:08:59 +00:00
|
|
|
int d, da;//, d, cd, ca,tempx,tempy,cx,cy;
|
2021-12-06 11:24:22 +00:00
|
|
|
HitInfo hit{};
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2020-10-21 23:12:16 +00:00
|
|
|
if ((actor->temp_data[0] & 63)) return -1;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
|
|
|
if (ud.multimode < 2 && ud.player_skill < 3)
|
|
|
|
angincs = 2048 / 2;
|
|
|
|
else angincs = 2048 / (1 + (krand() & 1));
|
|
|
|
|
2021-12-21 18:09:05 +00:00
|
|
|
for (j = tosee->spr.ang; j < (2048 + tosee->spr.ang); j += (angincs - (krand() & 511)))
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
hitscan({ tosee->spr.pos.X, tosee->spr.pos.Y, tosee->spr.pos.Z - (16 << 8) }, tosee->sector(), { bcos(j), bsin(j), 16384 - (krand() & 32767) }, hit, CLIPMASK1);
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-12-22 11:17:17 +00:00
|
|
|
d = abs(hit.hitpos.X - tosee->spr.pos.X) + abs(hit.hitpos.Y - tosee->spr.pos.Y);
|
|
|
|
da = abs(hit.hitpos.X - actor->spr.pos.X) + abs(hit.hitpos.Y - actor->spr.pos.Y);
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-11-25 23:08:59 +00:00
|
|
|
if (d < da && hit.hitSector)
|
2021-12-30 15:51:56 +00:00
|
|
|
if (cansee(hit.hitpos.X, hit.hitpos.Y, hit.hitpos.Z, hit.hitSector, actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - (16 << 8), actor->sector()))
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2021-12-22 09:36:09 +00:00
|
|
|
*dax = hit.hitpos.X;
|
2021-12-22 09:40:26 +00:00
|
|
|
*day = hit.hitpos.Y;
|
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
|
|
|
{
|
2021-11-07 13:07:08 +00:00
|
|
|
int aang, angdif, goalang, 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
|
|
|
|
2021-12-23 15:03:43 +00:00
|
|
|
ticselapsed = (actor->temp_data[0]) & 31;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
aang = actor->spr.ang;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xvel += (*moveptr - actor->spr.xvel) / 5;
|
|
|
|
if (actor->spr.zvel < 648) actor->spr.zvel += ((*(moveptr + 1) << 4) - actor->spr.zvel) / 5;
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2020-10-22 14:40:48 +00:00
|
|
|
if (isRRRA() && (ang & windang))
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang = WindDir;
|
2020-10-22 14:40:48 +00:00
|
|
|
else if (ang & seekplayer)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
2021-12-05 23:20:46 +00:00
|
|
|
DDukeActor* holoduke = !isRR()? ps[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
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
if (holoduke && cansee(holoduke->spr.pos.X, holoduke->spr.pos.Y, holoduke->spr.pos.Z, holoduke->sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, actor->sector()))
|
2020-10-22 14:40:48 +00:00
|
|
|
actor->SetOwner(holoduke);
|
2020-11-01 09:45:09 +00:00
|
|
|
else actor->SetOwner(ps[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())
|
2021-12-30 11:55:05 +00:00
|
|
|
goalang = getangle(actor->ovel.X - actor->spr.pos.X, actor->ovel.Y - actor->spr.pos.Y);
|
2020-05-13 22:04:14 +00:00
|
|
|
else
|
2021-12-22 11:17:17 +00:00
|
|
|
goalang = getangle(Owner->spr.pos.X - actor->spr.pos.X, Owner->spr.pos.Y - actor->spr.pos.Y);
|
2020-05-13 22:04:14 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.xvel && actor->spr.picnum != TILE_DRONE)
|
2020-05-13 22:04:14 +00:00
|
|
|
{
|
|
|
|
angdif = getincangle(aang, goalang);
|
|
|
|
|
|
|
|
if (ticselapsed < 2)
|
|
|
|
{
|
|
|
|
if (abs(angdif) < 256)
|
|
|
|
{
|
|
|
|
j = 128 - (krand() & 256);
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang += j;
|
2020-10-22 14:40:48 +00:00
|
|
|
if (hits(actor) < 844)
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang -= j;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ticselapsed > 18 && ticselapsed < 26) // choose
|
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (abs(angdif >> 2) < 128) actor->spr.ang = goalang;
|
|
|
|
else actor->spr.ang += angdif >> 2;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-21 17:29:44 +00:00
|
|
|
else actor->spr.ang = 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);
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang = goalang;
|
2020-11-01 09:45:09 +00:00
|
|
|
actor->SetOwner(ps[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);
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.ang = goalang; // += angdif; // = getincangle(aang,goalang)>>1;
|
2020-05-13 22:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 07:07:07 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// the indirections here are to keep this core function free of game references
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-11-01 09:49:50 +00:00
|
|
|
void fall_common(DDukeActor *actor, int playernum, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(DDukeActor*, int))
|
2020-05-14 07:07:07 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.xoffset = 0;
|
|
|
|
actor->spr.yoffset = 0;
|
2020-05-14 07:07:07 +00:00
|
|
|
// if(!gotz)
|
|
|
|
{
|
2020-05-14 10:52:59 +00:00
|
|
|
int c;
|
2020-05-14 07:07:07 +00:00
|
|
|
|
2020-11-01 09:49:50 +00:00
|
|
|
int sphit = fallspecial? fallspecial(actor, playernum) : 0;
|
2021-12-30 15:51:56 +00:00
|
|
|
if (fi.floorspace(actor->sector()))
|
2020-05-14 07:07:07 +00:00
|
|
|
c = 0;
|
|
|
|
else
|
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if (fi.ceilingspace(actor->sector()) || actor->sector()->lotag == 2)
|
2020-11-29 12:54:58 +00:00
|
|
|
c = gs.gravity / 6;
|
|
|
|
else c = 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
|
|
|
|
2021-12-22 11:29:00 +00:00
|
|
|
if (actor->spr.pos.Z < (actor->floorz - FOURSLEIGHT))
|
2020-05-14 07:07:07 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.zvel += c;
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z += actor->spr.zvel;
|
2020-05-14 07:07:07 +00:00
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel > 6144) actor->spr.zvel = 6144;
|
2020-05-14 07:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z = actor->floorz - FOURSLEIGHT;
|
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
|
|
|
{
|
|
|
|
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.zvel > 3084 && actor->spr.extra <= 1)
|
2020-05-14 07:07:07 +00:00
|
|
|
{
|
2021-12-21 17:29:44 +00:00
|
|
|
if (actor->spr.pal != 1 && actor->spr.picnum != DRONE)
|
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)
|
|
|
|
{
|
2020-10-22 17:21:21 +00:00
|
|
|
fi.guts(actor, JIBS6, 5, playernum);
|
2020-10-22 16:51:20 +00:00
|
|
|
S_PlayActorSound(squished, actor);
|
2020-05-14 07:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-22 17:21:21 +00:00
|
|
|
fi.guts(actor, JIBS6, 15, playernum);
|
2020-10-22 16:51:20 +00:00
|
|
|
S_PlayActorSound(squished, actor);
|
|
|
|
spawn(actor, BLOODPOOL);
|
2020-05-14 07:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SKIPJIBS:
|
|
|
|
|
2021-12-27 22:52:16 +00:00
|
|
|
actor->attackertype = SHOTSPARK1;
|
2022-01-23 23:10:25 +00:00
|
|
|
actor->hitextra = 1;
|
2021-12-21 17:29:44 +00:00
|
|
|
actor->spr.zvel = 0;
|
2020-05-14 07:07:07 +00:00
|
|
|
}
|
2021-12-30 15:51:56 +00:00
|
|
|
else if (actor->spr.zvel > 2048 && actor->sector()->lotag != 1)
|
2020-05-14 07:07:07 +00:00
|
|
|
{
|
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sect = actor->sector();
|
2021-12-21 17:29:44 +00:00
|
|
|
pushmove(&actor->spr.pos, §, 128, (4 << 8), (4 << 8), 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
|
|
|
|
2020-10-22 16:51:20 +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)
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->spr.pos.Z += gs.actorinfo[actor->spr.picnum].falladjustz;
|
2021-12-21 17:29:44 +00:00
|
|
|
else actor->spr.zvel = 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
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void recordoldspritepos()
|
|
|
|
{
|
|
|
|
for (int statNum = 0; statNum < MAXSTATUS; statNum++)
|
|
|
|
{
|
2020-10-21 21:56:46 +00:00
|
|
|
DukeStatIterator it(statNum);
|
|
|
|
while (auto ac = it.Next())
|
2020-09-11 20:54:52 +00:00
|
|
|
{
|
2021-12-30 16:10:08 +00:00
|
|
|
ac->backuploc();
|
2020-09-11 20:54:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-02 14:44:52 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
void movefta(void)
|
|
|
|
{
|
|
|
|
int x, px, py, sx, sy;
|
|
|
|
int canseeme, p;
|
|
|
|
sectortype* psect, * ssect;
|
|
|
|
|
2022-01-09 20:24:38 +00:00
|
|
|
auto check_fta_sounds = [](DDukeActor* act)
|
|
|
|
{
|
|
|
|
if (isRR()) check_fta_sounds_r(act);
|
|
|
|
else check_fta_sounds_d(act);
|
|
|
|
};
|
|
|
|
|
2022-01-02 14:44:52 +00:00
|
|
|
DukeStatIterator it(STAT_ZOMBIEACTOR);
|
|
|
|
while (auto act = it.Next())
|
|
|
|
{
|
|
|
|
p = findplayer(act, &x);
|
|
|
|
canseeme = 0;
|
|
|
|
|
|
|
|
ssect = psect = act->sector();
|
|
|
|
|
|
|
|
if (ps[p].GetActor()->spr.extra > 0)
|
|
|
|
{
|
|
|
|
if (x < 30000)
|
|
|
|
{
|
|
|
|
act->timetosleep++;
|
|
|
|
if (act->timetosleep >= (x >> 8))
|
|
|
|
{
|
|
|
|
if (badguy(act))
|
|
|
|
{
|
|
|
|
px = ps[p].opos.X + 64 - (krand() & 127);
|
|
|
|
py = ps[p].opos.Y + 64 - (krand() & 127);
|
|
|
|
updatesector(px, py, &psect);
|
|
|
|
if (psect == nullptr)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
sx = act->spr.pos.X + 64 - (krand() & 127);
|
|
|
|
sy = act->spr.pos.Y + 64 - (krand() & 127);
|
|
|
|
updatesector(px, py, &ssect);
|
|
|
|
if (ssect == nullptr)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SFLAG_MOVEFTA_CHECKSEE is set for all actors in Duke.
|
|
|
|
if (act->spr.pal == 33 || actorflag(act, SFLAG_MOVEFTA_CHECKSEE) ||
|
2022-01-07 15:36:02 +00:00
|
|
|
(actorflag(act, SFLAG_MOVEFTA_CHECKSEEWITHPAL8) && act->spr.pal == 8) ||
|
2022-01-02 14:44:52 +00:00
|
|
|
(bcos(act->spr.ang) * (px - sx) + bsin(act->spr.ang) * (py - sy) >= 0))
|
|
|
|
{
|
|
|
|
int r1 = krand();
|
|
|
|
int r2 = krand();
|
|
|
|
canseeme = cansee(sx, sy, act->spr.pos.Z - (r2 % (52 << 8)), act->sector(), px, py, ps[p].opos.Z - (r1 % (32 << 8)), ps[p].cursector);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int r1 = krand();
|
|
|
|
int r2 = krand();
|
|
|
|
canseeme = cansee(act->spr.pos.X, act->spr.pos.Y, act->spr.pos.Z - ((r2 & 31) << 8), act->sector(), ps[p].opos.X, ps[p].opos.Y, ps[p].opos.Z - ((r1 & 31) << 8), ps[p].cursector);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (canseeme)
|
|
|
|
{
|
2022-01-07 15:36:02 +00:00
|
|
|
if (actorflag(act, 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-01-04 08:39:55 +00:00
|
|
|
// wakeup is an RR feature, this flag will later allow it to use in Duke, too.
|
2022-01-07 15:36:02 +00:00
|
|
|
if (actorflag(act, 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-23 19:12:15 +00:00
|
|
|
|
|
|
|
|
2020-05-05 09:58:39 +00:00
|
|
|
END_DUKE_NS
|