2020-05-10 10:42:47 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
|
|
|
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
|
2020-05-13 14:19:39 +00:00
|
|
|
Copyright (C) 2020 - Christoph Oelckers
|
2020-05-10 10:42:47 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2020-05-10 14:53:09 +00:00
|
|
|
#include <utility>
|
2020-05-10 10:42:47 +00:00
|
|
|
#include "ns.h"
|
|
|
|
#include "global.h"
|
2020-06-24 19:21:02 +00:00
|
|
|
#include "sounds.h"
|
2020-10-24 07:35:43 +00:00
|
|
|
#include "dukeactor.h"
|
2020-11-26 15:03:40 +00:00
|
|
|
#include "interpolate.h"
|
2020-05-10 10:42:47 +00:00
|
|
|
|
|
|
|
// PRIMITIVE
|
|
|
|
BEGIN_DUKE_NS
|
|
|
|
|
2020-11-26 15:03:40 +00:00
|
|
|
static int interptype[] = { Interp_Sect_Floorz, Interp_Sect_Ceilingz, Interp_Wall_X, Interp_Wall_Y };
|
|
|
|
|
2022-11-25 16:43:13 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool ceilingspace(sectortype* sectp)
|
|
|
|
{
|
2022-12-09 09:48:47 +00:00
|
|
|
return (sectp && (sectp->ceilingstat & CSTAT_SECTOR_SKY) && sectp->ceilingpal == 0 && (tilesurface(sectp->ceilingtexture) == TSURF_OUTERSPACE));
|
2022-11-25 16:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool floorspace(sectortype* sectp)
|
|
|
|
{
|
2022-12-14 07:14:06 +00:00
|
|
|
// Yes, ceilingpal in this check is correct...
|
2022-12-09 09:48:47 +00:00
|
|
|
return (sectp && (sectp->floorstat & CSTAT_SECTOR_SKY) && sectp->ceilingpal == 0 && (tilesurface(sectp->floortexture) == TSURF_OUTERSPACE));
|
2022-11-25 16:43:13 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 10:42:47 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
static bool haltsoundhack;
|
|
|
|
|
2022-01-09 22:03:11 +00:00
|
|
|
int callsound(sectortype* sn, DDukeActor* whatsprite, bool endstate)
|
2020-05-10 10:42:47 +00:00
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
if (!isRRRA() && haltsoundhack)
|
|
|
|
{
|
|
|
|
haltsoundhack = 0;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-10-23 15:38:49 +00:00
|
|
|
DukeSectIterator it(sn);
|
|
|
|
while (auto act = it.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-11-20 07:10:15 +00:00
|
|
|
if (issoundcontroller(act) && act->spr.lotag < 1000)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2020-10-23 15:38:49 +00:00
|
|
|
if (whatsprite == nullptr) whatsprite = act;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-12-21 20:39:57 +00:00
|
|
|
int snum = act->spr.lotag;
|
2020-05-12 11:43:24 +00:00
|
|
|
auto flags = S_GetUserFlags(snum);
|
2020-08-01 09:56:02 +00:00
|
|
|
|
|
|
|
// Reset if the desired actor isn't playing anything.
|
2021-12-21 20:39:57 +00:00
|
|
|
bool hival = S_IsSoundValid(act->spr.hitag);
|
2022-12-22 08:49:42 +00:00
|
|
|
if (act->counter == 1 && !hival && !endstate)
|
2020-08-01 09:56:02 +00:00
|
|
|
{
|
2020-10-23 15:38:49 +00:00
|
|
|
if (!S_CheckActorSoundPlaying(act->temp_actor, snum))
|
2022-12-22 08:49:42 +00:00
|
|
|
act->counter = 0;
|
2020-08-01 09:56:02 +00:00
|
|
|
}
|
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
if (act->counter == 0)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
if ((flags & (SF_GLOBAL | SF_DTAG)) != SF_GLOBAL)
|
|
|
|
{
|
|
|
|
if (snum)
|
|
|
|
{
|
2021-12-21 20:39:57 +00:00
|
|
|
if (act->spr.hitag && snum != act->spr.hitag)
|
|
|
|
S_StopSound(act->spr.hitag, act->temp_actor);
|
2020-07-25 07:32:54 +00:00
|
|
|
S_PlayActorSound(snum, whatsprite);
|
2020-10-23 15:38:49 +00:00
|
|
|
act->temp_actor = whatsprite;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
if ((act->sector()->lotag & 0xff) != ST_22_SPLITTING_DOOR)
|
2022-12-22 08:49:42 +00:00
|
|
|
act->counter = 1;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-21 20:39:57 +00:00
|
|
|
else if (act->spr.hitag < 1000)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-10-01 10:59:43 +00:00
|
|
|
// The original code performed these two actions in reverse order which in case of a looped sound being stopped
|
|
|
|
// being the same as the sound about to be started, the newly started sound would fall through some cracks in the sound system and be rejected.
|
|
|
|
// Here this case needs to be simulated.
|
|
|
|
bool stopped = false;
|
2021-12-21 20:39:57 +00:00
|
|
|
if ((flags & SF_LOOP) || (act->spr.hitag && act->spr.hitag != act->spr.lotag))
|
2022-10-01 10:59:43 +00:00
|
|
|
{
|
2021-12-21 20:39:57 +00:00
|
|
|
S_StopSound(act->spr.lotag, act->temp_actor);
|
2022-10-01 10:59:43 +00:00
|
|
|
if (act->spr.hitag == act->spr.lotag) stopped = true;
|
|
|
|
}
|
|
|
|
if (act->spr.hitag && !stopped) S_PlayActorSound(act->spr.hitag, whatsprite);
|
2022-12-22 08:49:42 +00:00
|
|
|
act->counter = 0;
|
2020-10-23 15:38:49 +00:00
|
|
|
act->temp_actor = whatsprite;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2021-12-21 20:39:57 +00:00
|
|
|
return act->spr.lotag;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
2020-05-10 10:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int check_activator_motion(int lotag)
|
|
|
|
{
|
2020-10-23 15:40:58 +00:00
|
|
|
DukeStatIterator it(STAT_ACTIVATOR);
|
|
|
|
while (auto act = it.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act->spr.lotag == lotag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-09-12 19:06:33 +00:00
|
|
|
for (int j = animates.Size() - 1; j >= 0; j--)
|
|
|
|
if (act->sector() == animates[j].sect)
|
2020-05-12 11:43:24 +00:00
|
|
|
return(1);
|
|
|
|
|
2020-10-23 15:40:58 +00:00
|
|
|
DukeStatIterator it1(STAT_EFFECTOR);
|
|
|
|
while (auto act2 = it1.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if (act->sector() == act2->sector())
|
2021-12-21 17:19:45 +00:00
|
|
|
switch (act2->spr.lotag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
case SE_11_SWINGING_DOOR:
|
|
|
|
case SE_30_TWO_WAY_TRAIN:
|
2020-10-23 15:40:58 +00:00
|
|
|
if (act2->temp_data[4])
|
2020-05-12 11:43:24 +00:00
|
|
|
return(1);
|
|
|
|
break;
|
|
|
|
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
|
|
|
|
if (isRRRA()) break;
|
2021-11-14 11:25:25 +00:00
|
|
|
[[fallthrough]];
|
2020-05-12 11:43:24 +00:00
|
|
|
case SE_20_STRETCH_BRIDGE:
|
|
|
|
case SE_31_FLOOR_RISE_FALL:
|
|
|
|
case SE_32_CEILING_RISE_FALL:
|
2022-12-22 08:49:42 +00:00
|
|
|
if (act2->counter)
|
2020-05-12 11:43:24 +00:00
|
|
|
return(1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(0);
|
2020-05-10 10:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool isanunderoperator(int lotag)
|
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
switch (lotag & 0xff)
|
|
|
|
{
|
|
|
|
case ST_15_WARP_ELEVATOR:
|
|
|
|
case ST_16_PLATFORM_DOWN:
|
|
|
|
case ST_17_PLATFORM_UP:
|
|
|
|
case ST_18_ELEVATOR_DOWN:
|
|
|
|
case ST_19_ELEVATOR_UP:
|
|
|
|
case ST_26_SPLITTING_ST_DOOR:
|
|
|
|
return true;
|
|
|
|
case ST_22_SPLITTING_DOOR:
|
|
|
|
return !isRR();
|
|
|
|
}
|
|
|
|
return false;
|
2020-05-10 10:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool isanearoperator(int lotag)
|
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
switch (lotag & 0xff)
|
|
|
|
{
|
|
|
|
case ST_9_SLIDING_ST_DOOR:
|
|
|
|
case ST_15_WARP_ELEVATOR:
|
|
|
|
case ST_16_PLATFORM_DOWN:
|
|
|
|
case ST_17_PLATFORM_UP:
|
|
|
|
case ST_18_ELEVATOR_DOWN:
|
|
|
|
case ST_19_ELEVATOR_UP:
|
|
|
|
case ST_20_CEILING_DOOR:
|
|
|
|
case ST_21_FLOOR_DOOR:
|
|
|
|
case ST_22_SPLITTING_DOOR:
|
|
|
|
case ST_23_SWINGING_DOOR:
|
|
|
|
case ST_25_SLIDING_DOOR:
|
|
|
|
case ST_26_SPLITTING_ST_DOOR:
|
|
|
|
case ST_29_TEETH_DOOR:
|
|
|
|
return true;
|
|
|
|
case 41:
|
|
|
|
return isRR();
|
|
|
|
}
|
|
|
|
return false;
|
2020-05-10 10:42:47 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 14:53:09 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-09-12 16:26:27 +00:00
|
|
|
int findplayer(const DDukeActor* actor, double* d)
|
2020-05-10 14:53:09 +00:00
|
|
|
{
|
2021-11-07 13:55:28 +00:00
|
|
|
int j, closest_player;
|
2022-09-12 16:26:27 +00:00
|
|
|
const auto s = actor->spr.pos;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
|
|
|
if (ud.multimode < 2)
|
|
|
|
{
|
2022-11-21 04:24:01 +00:00
|
|
|
if (d) *d = (ps[myconnectindex].GetActor()->getPrevPosWithOffsetZ() - s).plusZ(28).Sum();
|
2020-05-12 11:43:24 +00:00
|
|
|
return myconnectindex;
|
|
|
|
}
|
|
|
|
|
2022-09-12 16:26:27 +00:00
|
|
|
double closest = 0x7fffffff;
|
2020-05-12 11:43:24 +00:00
|
|
|
closest_player = 0;
|
|
|
|
|
|
|
|
for (j = connecthead; j >= 0; j = connectpoint2[j])
|
|
|
|
{
|
2022-11-21 04:24:01 +00:00
|
|
|
double x = (ps[j].GetActor()->getPrevPosWithOffsetZ() - s).plusZ(28).Sum();
|
2021-12-21 17:19:45 +00:00
|
|
|
if (x < closest && ps[j].GetActor()->spr.extra > 0)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
closest_player = j;
|
|
|
|
closest = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d) *d = closest;
|
|
|
|
return closest_player;
|
2020-05-10 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-09-12 16:26:27 +00:00
|
|
|
int findotherplayer(int p, double* d)
|
2020-05-10 14:53:09 +00:00
|
|
|
{
|
2021-11-07 13:55:28 +00:00
|
|
|
int j, closest_player;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2022-09-12 16:26:27 +00:00
|
|
|
double closest = 0x7fffffff;
|
2020-05-12 11:43:24 +00:00
|
|
|
closest_player = p;
|
|
|
|
|
|
|
|
for (j = connecthead; j >= 0; j = connectpoint2[j])
|
2021-12-21 17:19:45 +00:00
|
|
|
if (p != j && ps[j].GetActor()->spr.extra > 0)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-11-21 04:24:01 +00:00
|
|
|
double x = (ps[j].GetActor()->getPrevPosWithOffsetZ() - ps[p].GetActor()->getPosWithOffsetZ()).Sum();
|
2020-05-12 11:43:24 +00:00
|
|
|
|
|
|
|
if (x < closest)
|
|
|
|
{
|
|
|
|
closest_player = j;
|
|
|
|
closest = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*d = closest;
|
|
|
|
return closest_player;
|
2020-05-10 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-01-27 17:31:08 +00:00
|
|
|
double getanimatevalue(int type, int index)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case anim_floorz:
|
2022-09-12 17:47:07 +00:00
|
|
|
return sector[index].floorz;
|
2022-01-27 17:31:08 +00:00
|
|
|
case anim_ceilingz:
|
2022-09-12 17:47:07 +00:00
|
|
|
return sector[index].ceilingz;
|
2022-01-27 17:31:08 +00:00
|
|
|
case anim_vertexx:
|
2022-09-12 17:47:07 +00:00
|
|
|
return wall[index].pos.X;
|
2022-01-27 17:31:08 +00:00
|
|
|
case anim_vertexy:
|
2022-09-12 17:47:07 +00:00
|
|
|
return wall[index].pos.Y;
|
2022-01-27 17:31:08 +00:00
|
|
|
default:
|
|
|
|
assert(false);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double getanimatevalue(int i)
|
|
|
|
{
|
2022-09-12 19:06:33 +00:00
|
|
|
return getanimatevalue(animates[i].type, animates[i].target);
|
2022-01-27 17:31:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void setanimatevalue(int type, int index, double value)
|
2020-07-20 18:40:29 +00:00
|
|
|
{
|
|
|
|
static int scratch;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case anim_floorz:
|
2022-09-12 17:47:07 +00:00
|
|
|
sector[index].setfloorz(value);
|
2022-01-27 17:31:08 +00:00
|
|
|
break;
|
2020-07-20 18:40:29 +00:00
|
|
|
case anim_ceilingz:
|
2022-09-12 17:47:07 +00:00
|
|
|
sector[index].setceilingz(value);
|
2022-01-27 17:31:08 +00:00
|
|
|
break;
|
2020-07-20 18:40:29 +00:00
|
|
|
case anim_vertexx:
|
2022-01-28 17:47:53 +00:00
|
|
|
|
2022-09-12 17:47:07 +00:00
|
|
|
wall[index].pos.X = value;
|
2022-01-28 16:03:14 +00:00
|
|
|
wall[index].moved();
|
2022-01-27 17:31:08 +00:00
|
|
|
break;
|
2020-07-20 18:40:29 +00:00
|
|
|
case anim_vertexy:
|
2022-01-28 17:47:53 +00:00
|
|
|
|
2022-09-12 17:47:07 +00:00
|
|
|
wall[index].pos.Y = value;
|
2022-01-28 16:03:14 +00:00
|
|
|
wall[index].moved();
|
2022-01-27 17:31:08 +00:00
|
|
|
break;
|
2020-07-20 18:40:29 +00:00
|
|
|
default:
|
|
|
|
assert(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-27 17:31:08 +00:00
|
|
|
void setanimatevalue(int i, double value)
|
2020-07-20 18:40:29 +00:00
|
|
|
{
|
2022-09-12 19:06:33 +00:00
|
|
|
return setanimatevalue(animates[i].type, animates[i].target, value);
|
2020-07-20 18:40:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-10 14:53:09 +00:00
|
|
|
void doanimations(void)
|
|
|
|
{
|
2022-09-12 19:06:33 +00:00
|
|
|
for (int i = animates.Size() - 1; i >= 0; i--)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
double a = getanimatevalue(i);
|
2022-09-12 19:06:33 +00:00
|
|
|
double const v = animates[i].vel * TICSPERFRAME;
|
|
|
|
auto dasectp = animates[i].sect;
|
2022-12-10 09:20:01 +00:00
|
|
|
int type = animates[i].type;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2022-09-12 19:06:33 +00:00
|
|
|
if (a == animates[i].goal)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-09-12 19:06:33 +00:00
|
|
|
StopInterpolation(animates[i].target, interptype[animates[i].type]);
|
|
|
|
|
|
|
|
animates[i] = animates.Last();
|
|
|
|
animates.Pop();
|
2021-11-18 18:20:12 +00:00
|
|
|
if (dasectp->lotag == ST_18_ELEVATOR_DOWN || dasectp->lotag == ST_19_ELEVATOR_UP)
|
2022-12-10 09:20:01 +00:00
|
|
|
if (type == anim_ceilingz)
|
2020-05-12 11:43:24 +00:00
|
|
|
continue;
|
|
|
|
|
2021-11-18 18:20:12 +00:00
|
|
|
if ((dasectp->lotag & 0xff) != ST_22_SPLITTING_DOOR)
|
2022-01-09 22:03:11 +00:00
|
|
|
callsound(dasectp, nullptr, true);
|
2020-05-12 11:43:24 +00:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-09-12 19:06:33 +00:00
|
|
|
if (v > 0) { a = min(a + v, animates[i].goal); }
|
|
|
|
else { a = max(a + v, animates[i].goal); }
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2022-12-10 09:20:01 +00:00
|
|
|
if (type == anim_floorz)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
for (auto p = connecthead; p >= 0; p = connectpoint2[p])
|
2021-11-21 07:56:39 +00:00
|
|
|
if (ps[p].cursector == dasectp)
|
2022-11-21 04:20:08 +00:00
|
|
|
if ((dasectp->floorz - ps[p].GetActor()->getOffsetZ()) < 64)
|
2020-10-23 15:40:58 +00:00
|
|
|
if (ps[p].GetActor()->GetOwner() != nullptr)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-11-20 08:14:51 +00:00
|
|
|
ps[p].GetActor()->spr.pos.Z += v;
|
2022-09-11 22:17:09 +00:00
|
|
|
ps[p].vel.Z = 0;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
|
2021-11-18 18:20:12 +00:00
|
|
|
DukeSectIterator it(dasectp);
|
2020-10-23 15:40:58 +00:00
|
|
|
while (auto act = it.Next())
|
2020-10-14 19:40:15 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act->spr.statnum != STAT_EFFECTOR)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-11-16 05:33:17 +00:00
|
|
|
if (act->spr.statnum != STAT_PLAYER)
|
|
|
|
{
|
|
|
|
act->backupz();
|
|
|
|
act->spr.pos.Z += v;
|
|
|
|
}
|
2022-09-12 17:47:07 +00:00
|
|
|
act->floorz = dasectp->floorz + v;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-10-14 19:40:15 +00:00
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2022-01-27 17:31:08 +00:00
|
|
|
setanimatevalue(i, a);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-05-10 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-09-12 17:47:07 +00:00
|
|
|
int getanimationindex(int animtype, sectortype* animtargetp)
|
2020-05-10 14:53:09 +00:00
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
int i, j;
|
|
|
|
|
|
|
|
j = -1;
|
2022-11-15 11:03:44 +00:00
|
|
|
int animtarget = sectindex(animtargetp);
|
2022-09-12 19:06:33 +00:00
|
|
|
for (i = animates.Size() - 1; i >= 0; i--)
|
|
|
|
if (animtype == animates[i].type && animtarget == animates[i].target)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
j = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(j);
|
2020-05-10 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-09-12 17:47:07 +00:00
|
|
|
static int dosetanimation(sectortype* animsect, int animtype, int animtarget, double thegoal, double thevel)
|
2020-05-10 14:53:09 +00:00
|
|
|
{
|
2022-09-12 19:06:33 +00:00
|
|
|
int j = -1;
|
2020-05-10 14:53:09 +00:00
|
|
|
|
2022-09-12 19:06:33 +00:00
|
|
|
for (unsigned i = 0; i < animates.Size(); i++)
|
|
|
|
if (animtype == animates[i].type && animtarget == animates[i].target)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
j = i;
|
|
|
|
break;
|
|
|
|
}
|
2020-05-10 14:53:09 +00:00
|
|
|
|
2022-09-12 19:06:33 +00:00
|
|
|
if (j == -1) j = animates.Reserve(1);
|
|
|
|
|
|
|
|
auto animval = getanimatevalue(animtype, animtarget);
|
|
|
|
animates[j].sect = animsect;
|
|
|
|
animates[j].type = animtype;
|
|
|
|
animates[j].target = animtarget;
|
|
|
|
animates[j].goal = thegoal;
|
2022-01-27 17:31:08 +00:00
|
|
|
if (thegoal >= animval)
|
2022-09-12 19:06:33 +00:00
|
|
|
animates[j].vel = thevel;
|
2020-05-12 11:43:24 +00:00
|
|
|
else
|
2022-09-12 19:06:33 +00:00
|
|
|
animates[j].vel = -thevel;
|
2020-05-10 14:53:09 +00:00
|
|
|
|
2022-09-12 19:06:33 +00:00
|
|
|
StartInterpolation(animates[j].target, interptype[animates[j].type]);
|
2020-05-12 11:43:24 +00:00
|
|
|
return(j);
|
2020-05-10 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
2022-09-12 17:47:07 +00:00
|
|
|
int setanimation(sectortype* animsect, int animtype, walltype* animtarget, double thegoal, double thevel)
|
2021-11-18 17:35:59 +00:00
|
|
|
{
|
|
|
|
assert(animtype == anim_vertexx || animtype == anim_vertexy);
|
2022-11-15 11:03:44 +00:00
|
|
|
return dosetanimation(animsect, animtype, wallindex(animtarget), thegoal, thevel);
|
2021-11-18 17:35:59 +00:00
|
|
|
}
|
|
|
|
|
2022-09-12 17:47:07 +00:00
|
|
|
int setanimation(sectortype* animsect, int animtype, sectortype* animtarget, double thegoal, double thevel)
|
2021-11-18 17:35:59 +00:00
|
|
|
{
|
|
|
|
assert(animtype == anim_ceilingz || animtype == anim_floorz);
|
2022-11-15 11:03:44 +00:00
|
|
|
return dosetanimation(animsect, animtype, sectindex(animtarget), thegoal, thevel);
|
2021-11-18 17:35:59 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 14:53:09 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-23 15:46:46 +00:00
|
|
|
bool activatewarpelevators(DDukeActor* actor, int d) //Parm = sectoreffectornum
|
2020-05-10 14:53:09 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto sect = actor->sector();
|
2020-05-12 11:43:24 +00:00
|
|
|
|
|
|
|
// See if the sector exists
|
|
|
|
|
2020-10-23 15:46:46 +00:00
|
|
|
DukeStatIterator it(STAT_EFFECTOR);
|
|
|
|
DDukeActor *act2;
|
|
|
|
while ((act2 = it.Next()))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act2->spr.lotag == SE_17_WARP_ELEVATOR || (isRRRA() && act2->spr.lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL))
|
|
|
|
if (act2->spr.hitag == actor->spr.hitag)
|
2022-09-14 19:04:07 +00:00
|
|
|
if ((abs(sect->floorz - actor->temp_pos.X) > act2->spr.yint * maptoworld) ||
|
2021-11-20 23:33:17 +00:00
|
|
|
(act2->sector()->hitag == (sect->hitag - d)))
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-10-23 15:46:46 +00:00
|
|
|
if (act2 == nullptr)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
d = 0;
|
|
|
|
return 1; // No find
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (d == 0)
|
2020-10-23 15:46:46 +00:00
|
|
|
S_PlayActorSound(ELEVATOR_OFF, actor);
|
|
|
|
else S_PlayActorSound(ELEVATOR_ON, actor);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-14 21:28:36 +00:00
|
|
|
it.Reset(STAT_EFFECTOR);
|
2020-10-23 15:46:46 +00:00
|
|
|
while ((act2 = it.Next()))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act2->spr.lotag == SE_17_WARP_ELEVATOR || (isRRRA() && act2->spr.lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL))
|
|
|
|
if (act2->spr.hitag == actor->spr.hitag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
act2->counter = d;
|
2022-08-22 17:32:51 +00:00
|
|
|
if (act2->spr.lotag == SE_17_WARP_ELEVATOR) act2->temp_data[1] = d; //Make all check warp (only SE17, in SE18 this is a coordinate)
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2020-05-10 14:53:09 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
|
2020-05-10 14:53:09 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-18 17:35:59 +00:00
|
|
|
static void handle_st09(sectortype* sptr, DDukeActor* actor)
|
2020-05-10 14:53:09 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
double dax, day, dax2, day2, sp;
|
2021-11-17 21:49:27 +00:00
|
|
|
walltype* wallfind[2];
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2022-09-12 17:47:07 +00:00
|
|
|
sp = (sptr->extra >> 4) / 16.;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//first find center point by averaging all points
|
2022-09-12 17:47:07 +00:00
|
|
|
dax = 0, day = 0;
|
2022-11-15 14:24:17 +00:00
|
|
|
for (auto& wal : sptr->walls)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
dax += wal.pos.X;
|
|
|
|
day += wal.pos.Y;
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2022-11-15 13:59:28 +00:00
|
|
|
dax /= sptr->walls.Size();
|
|
|
|
day /= sptr->walls.Size();
|
2020-10-23 17:05:42 +00:00
|
|
|
|
|
|
|
//find any points with either same x or same y coordinate
|
|
|
|
// as center (dax, day) - should be 2 points found.
|
2021-11-17 21:49:27 +00:00
|
|
|
wallfind[0] = nullptr;
|
|
|
|
wallfind[1] = nullptr;
|
2022-11-15 14:24:17 +00:00
|
|
|
for (auto& wal : sptr->walls)
|
2022-09-12 17:47:07 +00:00
|
|
|
// more precise checks won't work here.
|
|
|
|
if (abs(wal.pos.X - dax) <= (1 / 32.) || abs(wal.pos.Y - day) <= (1 / 32.))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-17 21:49:27 +00:00
|
|
|
if (wallfind[0] == nullptr)
|
|
|
|
wallfind[0] = &wal;
|
|
|
|
else wallfind[1] = &wal;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
for (int j = 0; j < 2; j++)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-17 21:49:27 +00:00
|
|
|
auto wal = wallfind[j];
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2021-11-17 21:49:27 +00:00
|
|
|
//find what direction door should open by averaging the
|
|
|
|
// 2 neighboring points of wallfind[0] & wallfind[1].
|
|
|
|
auto prevwall = wal - 1;
|
2022-11-15 14:44:33 +00:00
|
|
|
if (prevwall < sptr->walls.Data()) prevwall += sptr->walls.Size();
|
2021-11-17 21:49:27 +00:00
|
|
|
|
2022-09-12 17:47:07 +00:00
|
|
|
if ((wal->pos.X == dax) && (wal->pos.Y == day))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
dax2 = ((prevwall->pos.X + wal->point2Wall()->pos.X) * 0.5) - wal->pos.X;
|
|
|
|
day2 = ((prevwall->pos.Y + wal->point2Wall()->pos.Y) * 0.5) - wal->pos.Y;
|
2020-10-23 17:05:42 +00:00
|
|
|
if (dax2 != 0)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
dax2 = wal->point2Wall()->point2Wall()->pos.X;
|
|
|
|
dax2 -= wal->point2Wall()->pos.X;
|
|
|
|
setanimation(sptr, anim_vertexx, wal, wal->pos.X + dax2, sp);
|
|
|
|
setanimation(sptr, anim_vertexx, prevwall, prevwall->pos.X + dax2, sp);
|
|
|
|
setanimation(sptr, anim_vertexx, wal->point2Wall(), wal->point2Wall()->pos.X + dax2, sp);
|
2021-11-18 17:35:59 +00:00
|
|
|
callsound(sptr, actor);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
else if (day2 != 0)
|
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
day2 = wal->point2Wall()->point2Wall()->pos.Y;
|
|
|
|
day2 -= wal->point2Wall()->pos.Y;
|
|
|
|
setanimation(sptr, anim_vertexy, wal, wal->pos.Y + day2, sp);
|
|
|
|
setanimation(sptr, anim_vertexy, prevwall, prevwall->pos.Y + day2, sp);
|
|
|
|
setanimation(sptr, anim_vertexy, wal->point2Wall(), wal->point2Wall()->pos.Y + day2, sp);
|
2021-11-18 17:35:59 +00:00
|
|
|
callsound(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
dax2 = ((prevwall->pos.X + wal->point2Wall()->pos.X) * 0.5) - wal->pos.X;
|
|
|
|
day2 = ((prevwall->pos.Y + wal->point2Wall()->pos.Y) * 0.5) - wal->pos.Y;
|
2020-10-23 17:05:42 +00:00
|
|
|
if (dax2 != 0)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-18 17:35:59 +00:00
|
|
|
setanimation(sptr, anim_vertexx, wal, dax, sp);
|
|
|
|
setanimation(sptr, anim_vertexx, prevwall, dax + dax2, sp);
|
|
|
|
setanimation(sptr, anim_vertexx, wal->point2Wall(), dax + dax2, sp);
|
|
|
|
callsound(sptr, actor);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
else if (day2 != 0)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-18 17:35:59 +00:00
|
|
|
setanimation(sptr, anim_vertexy, wal, day, sp);
|
|
|
|
setanimation(sptr, anim_vertexy, prevwall, day + day2, sp);
|
|
|
|
setanimation(sptr, anim_vertexy, wal->point2Wall(), day + day2, sp);
|
|
|
|
callsound(sptr, actor);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-11-18 17:38:09 +00:00
|
|
|
static void handle_st15(sectortype* sptr, DDukeActor* actor)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2021-12-31 17:47:00 +00:00
|
|
|
if (!actor->isPlayer()) return;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-11-18 17:38:09 +00:00
|
|
|
DukeSectIterator it(sptr);
|
2020-10-23 17:08:11 +00:00
|
|
|
DDukeActor* a2;
|
|
|
|
while ((a2 = it.Next()))
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2022-12-01 19:54:41 +00:00
|
|
|
if (iseffector(a2) && a2->spr.lotag == ST_17_PLATFORM_UP) break;
|
2020-10-14 19:40:15 +00:00
|
|
|
}
|
2020-10-23 17:08:11 +00:00
|
|
|
if (!a2) return;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
if (actor->sector() == sptr)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2020-10-23 17:08:11 +00:00
|
|
|
if (activatewarpelevators(a2, -1))
|
|
|
|
activatewarpelevators(a2, 1);
|
|
|
|
else if (activatewarpelevators(a2, 1))
|
|
|
|
activatewarpelevators(a2, -1);
|
2020-05-12 11:43:24 +00:00
|
|
|
return;
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-14 16:22:43 +00:00
|
|
|
if (sptr->floorz > a2->spr.pos.Z)
|
2020-10-23 17:08:11 +00:00
|
|
|
activatewarpelevators(a2, -1);
|
2020-10-23 17:05:42 +00:00
|
|
|
else
|
2020-10-23 17:08:11 +00:00
|
|
|
activatewarpelevators(a2, 1);
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-11-18 17:38:09 +00:00
|
|
|
static void handle_st16(sectortype* sptr, DDukeActor* actor)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
int i = getanimationindex(anim_floorz, sptr);
|
2021-11-17 23:29:46 +00:00
|
|
|
sectortype* sectp;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
if (i == -1)
|
|
|
|
{
|
2022-09-03 15:27:41 +00:00
|
|
|
sectp = nextsectorneighborzptr(sptr, sptr->floorz, Find_FloorDown);
|
2021-11-17 23:29:46 +00:00
|
|
|
if (sectp == nullptr)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-09-03 15:27:41 +00:00
|
|
|
sectp = nextsectorneighborzptr(sptr, sptr->floorz, Find_FloorUp);
|
2021-11-17 23:29:46 +00:00
|
|
|
if (sectp == nullptr) return;
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2022-09-12 17:47:07 +00:00
|
|
|
setanimation(sptr, anim_floorz, sptr, sectp->floorz, sptr->extra / 256.);
|
2021-11-18 17:38:09 +00:00
|
|
|
callsound(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-18 17:43:25 +00:00
|
|
|
static void handle_st18(sectortype* sptr, DDukeActor* actor)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
int i = getanimationindex(anim_floorz, sptr);
|
2020-10-23 17:05:42 +00:00
|
|
|
|
|
|
|
if (i == -1)
|
2020-10-14 21:28:36 +00:00
|
|
|
{
|
2022-09-03 15:27:41 +00:00
|
|
|
auto sectp = nextsectorneighborzptr(sptr, sptr->floorz, Find_FloorUp);
|
|
|
|
if (sectp == nullptr) sectp = nextsectorneighborzptr(sptr, sptr->floorz, Find_FloorDown);
|
2021-11-17 23:29:46 +00:00
|
|
|
if (sectp == nullptr) return;
|
2022-09-12 17:47:07 +00:00
|
|
|
double speed = sptr->extra / 256.;
|
|
|
|
setanimation(sptr, anim_floorz, sptr, sectp->floorz, speed);
|
2022-11-07 17:16:41 +00:00
|
|
|
setanimation(sptr, anim_ceilingz, sptr, sectp->floorz + sptr->ceilingz - sptr->floorz, speed);
|
2021-11-18 17:43:25 +00:00
|
|
|
callsound(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-18 17:43:25 +00:00
|
|
|
static void handle_st29(sectortype* sptr, DDukeActor* actor)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
double j;
|
2020-10-23 17:05:42 +00:00
|
|
|
|
|
|
|
if (sptr->lotag & 0x8000)
|
2022-09-12 17:47:07 +00:00
|
|
|
j = nextsectorneighborzptr(sptr, sptr->ceilingz, Find_FloorDown | Find_Safe)->floorz;
|
2020-10-23 17:05:42 +00:00
|
|
|
else
|
2022-09-12 17:47:07 +00:00
|
|
|
j = nextsectorneighborzptr(sptr, sptr->ceilingz, Find_CeilingUp | Find_Safe)->ceilingz;
|
2020-10-23 17:05:42 +00:00
|
|
|
|
2020-10-23 17:09:27 +00:00
|
|
|
DukeStatIterator it(STAT_EFFECTOR);
|
|
|
|
while (auto act2 = it.Next())
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if ((act2->spr.lotag == 22) &&
|
|
|
|
(act2->spr.hitag == sptr->hitag))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
act2->sector()->extra = -act2->sector()->extra;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2022-12-22 08:49:42 +00:00
|
|
|
act2->counter = sectindex(sptr);
|
2020-10-23 17:09:27 +00:00
|
|
|
act2->temp_data[1] = 1;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
sptr->lotag ^= 0x8000;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2022-09-12 17:47:07 +00:00
|
|
|
setanimation(sptr, anim_ceilingz, sptr, j, sptr->extra / 256.);
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-11-18 17:43:25 +00:00
|
|
|
callsound(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-18 17:43:25 +00:00
|
|
|
static void handle_st20(sectortype* sptr, DDukeActor* actor)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
double j = 0;
|
2020-10-23 17:05:42 +00:00
|
|
|
REDODOOR:
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
if (sptr->lotag & 0x8000)
|
|
|
|
{
|
2020-10-23 17:10:40 +00:00
|
|
|
DDukeActor* a2;
|
2021-11-18 17:43:25 +00:00
|
|
|
DukeSectIterator it(sptr);
|
2020-10-23 17:10:40 +00:00
|
|
|
while ((a2 = it.Next()))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
if (a2->spr.statnum == STAT_EFFECTOR && a2->spr.lotag == SE_9_DOWN_OPEN_DOOR_LIGHTS)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
j = a2->spr.pos.Z;
|
2020-10-23 17:05:42 +00:00
|
|
|
break;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-23 17:10:40 +00:00
|
|
|
if (a2 == nullptr)
|
2022-09-12 17:47:07 +00:00
|
|
|
j = sptr->floorz;
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-03 15:27:41 +00:00
|
|
|
auto sectp = nextsectorneighborzptr(sptr, sptr->ceilingz, Find_CeilingUp);
|
2020-10-23 17:05:42 +00:00
|
|
|
|
2022-09-12 17:47:07 +00:00
|
|
|
if (sectp) j = sectp->ceilingz;
|
2020-05-12 11:43:24 +00:00
|
|
|
else
|
|
|
|
{
|
2020-10-23 17:05:42 +00:00
|
|
|
sptr->lotag |= 32768;
|
|
|
|
goto REDODOOR;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
sptr->lotag ^= 0x8000;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2022-09-12 17:47:07 +00:00
|
|
|
setanimation(sptr, anim_ceilingz, sptr, j, sptr->extra / 256.);
|
2021-11-18 17:43:25 +00:00
|
|
|
callsound(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-11-18 17:43:25 +00:00
|
|
|
static void handle_st21(sectortype* sptr, DDukeActor* actor)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
int i = getanimationindex(anim_floorz, sptr);
|
|
|
|
double j;
|
2020-10-23 17:05:42 +00:00
|
|
|
if (i >= 0)
|
|
|
|
{
|
2022-09-12 19:06:33 +00:00
|
|
|
if (animates[i].goal == sptr->ceilingz)
|
|
|
|
animates[i].goal = nextsectorneighborzptr(sptr, sptr->ceilingz, Find_FloorDown | Find_Safe)->floorz;
|
|
|
|
else animates[i].goal = sptr->ceilingz;
|
|
|
|
j = animates[i].goal;
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-08-28 09:35:03 +00:00
|
|
|
if (sptr->ceilingz == sptr->floorz)
|
2022-09-12 17:47:07 +00:00
|
|
|
j = nextsectorneighborzptr(sptr, sptr->ceilingz, Find_FloorDown | Find_Safe)->floorz;
|
|
|
|
else j = sptr->ceilingz;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
sptr->lotag ^= 0x8000;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2022-09-12 17:47:07 +00:00
|
|
|
if (setanimation(sptr, anim_floorz, sptr, j, sptr->extra / 256.) >= 0)
|
2021-11-18 17:43:25 +00:00
|
|
|
callsound(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-11-18 17:43:25 +00:00
|
|
|
static void handle_st22(sectortype* sptr, DDukeActor* actor)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
int j;
|
|
|
|
double z;
|
|
|
|
double speed = sptr->extra / 256.;
|
2020-10-23 17:05:42 +00:00
|
|
|
if ((sptr->lotag & 0x8000))
|
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
z = (sptr->ceilingz + sptr->floorz) * 0.5;
|
|
|
|
j = setanimation(sptr, anim_floorz, sptr, z, speed);
|
|
|
|
j = setanimation(sptr, anim_ceilingz, sptr, z, speed);
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
z = nextsectorneighborzptr(sptr, sptr->floorz, Find_FloorDown | Find_Safe)->floorz;
|
|
|
|
j = setanimation(sptr, anim_floorz, sptr, z, speed);
|
|
|
|
z = nextsectorneighborzptr(sptr, sptr->ceilingz, Find_CeilingUp | Find_Safe)->ceilingz;
|
|
|
|
j = setanimation(sptr, anim_ceilingz, sptr, z, speed);
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
sptr->lotag ^= 0x8000;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-11-18 17:43:25 +00:00
|
|
|
callsound(sptr, actor);
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-11-18 17:46:04 +00:00
|
|
|
static void handle_st23(sectortype* sptr, DDukeActor* actor)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
|
|
|
int q = 0;
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2020-10-23 17:15:18 +00:00
|
|
|
DukeStatIterator it(STAT_EFFECTOR);
|
|
|
|
DDukeActor* act2;
|
|
|
|
while ((act2 = it.Next()))
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if (act2->spr.lotag == SE_11_SWINGING_DOOR && act2->sector() == sptr && !act2->temp_data[4])
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2020-10-23 17:05:42 +00:00
|
|
|
break;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2020-10-23 17:15:18 +00:00
|
|
|
if (!act2) return;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-11-20 23:33:17 +00:00
|
|
|
int l = act2->sector()->lotag & 0x8000;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:15:18 +00:00
|
|
|
if (act2)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2021-12-24 09:53:27 +00:00
|
|
|
DukeStatIterator itr(STAT_EFFECTOR);
|
2021-01-03 04:44:57 +00:00
|
|
|
|
2021-12-24 09:53:27 +00:00
|
|
|
while (auto act3 = itr.Next())
|
2021-01-03 04:44:57 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (l == (act3->sector()->lotag & 0x8000) && act3->spr.lotag == SE_11_SWINGING_DOOR && act2->spr.hitag == act3->spr.hitag && act3->temp_data[4])
|
2021-01-03 04:44:57 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-24 09:53:27 +00:00
|
|
|
itr.Reset(STAT_EFFECTOR);
|
|
|
|
while (auto act3 = itr.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (l == (act3->sector()->lotag & 0x8000) && act3->spr.lotag == SE_11_SWINGING_DOOR && act2->spr.hitag == act3->spr.hitag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
if (act3->sector()->lotag & 0x8000) act3->sector()->lotag &= 0x7fff;
|
|
|
|
else act3->sector()->lotag |= 0x8000;
|
2020-10-23 17:15:18 +00:00
|
|
|
act3->temp_data[4] = 1;
|
|
|
|
act3->temp_data[3] = -act3->temp_data[3];
|
2020-10-23 17:05:42 +00:00
|
|
|
if (q == 0)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-18 17:46:04 +00:00
|
|
|
callsound(sptr, act3);
|
2020-10-23 17:05:42 +00:00
|
|
|
q = 1;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-14 21:28:36 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-18 17:46:04 +00:00
|
|
|
static void handle_st25(sectortype* sptr, DDukeActor* actor)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2020-10-23 17:16:39 +00:00
|
|
|
DukeStatIterator it(STAT_EFFECTOR);
|
|
|
|
DDukeActor* act2;
|
|
|
|
while ((act2 = it.Next()))
|
2020-10-14 21:28:36 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if (act2->spr.lotag == 15 && act2->sector() == sptr)
|
2020-10-23 17:16:39 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2020-10-23 17:16:39 +00:00
|
|
|
if (act2 == nullptr)
|
2020-10-23 17:05:42 +00:00
|
|
|
return;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
it.Reset(STAT_EFFECTOR);
|
2020-10-23 17:16:39 +00:00
|
|
|
while (auto act3 = it.Next())
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act3->spr.hitag == act2->spr.hitag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act3->spr.lotag == 15)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
act3->sector()->lotag ^= 0x8000; // Toggle the open or close
|
2022-11-25 12:13:50 +00:00
|
|
|
act3->spr.Angles.Yaw += DAngle180;
|
2021-11-20 23:33:17 +00:00
|
|
|
if (act3->temp_data[4]) callsound(act3->sector(), act3);
|
|
|
|
callsound(act3->sector(), act3);
|
|
|
|
if (act3->sector()->lotag & 0x8000) act3->temp_data[4] = 1;
|
2020-10-23 17:16:39 +00:00
|
|
|
else act3->temp_data[4] = 2;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-14 21:28:36 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-18 17:46:04 +00:00
|
|
|
static void handle_st27(sectortype* sptr, DDukeActor* actor)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2020-10-23 17:17:30 +00:00
|
|
|
DukeStatIterator it(STAT_EFFECTOR);
|
|
|
|
while (auto act2 = it.Next())
|
2020-10-14 21:28:36 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if ((act2->spr.lotag & 0xff) == 20 && act2->sector() == sptr) //Bridge
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
|
2021-11-18 17:46:04 +00:00
|
|
|
sptr->lotag ^= 0x8000;
|
|
|
|
if (sptr->lotag & 0x8000) //OPENING
|
2022-12-22 08:49:42 +00:00
|
|
|
act2->counter = 1;
|
|
|
|
else act2->counter = 2;
|
2021-11-18 17:46:04 +00:00
|
|
|
callsound(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
break;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-10-14 21:28:36 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-18 17:46:04 +00:00
|
|
|
static void handle_st28(sectortype* sptr, DDukeActor* actor)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
|
|
|
//activate the rest of them
|
2020-10-23 17:19:30 +00:00
|
|
|
int j = -1;
|
2021-11-18 17:46:04 +00:00
|
|
|
DukeSectIterator it(sptr);
|
2020-10-23 17:19:30 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-10-14 19:40:15 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.statnum == 3 && (a2->spr.lotag & 0xff) == 21)
|
2020-10-23 17:19:30 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
j = a2->spr.hitag;
|
2020-10-23 17:05:42 +00:00
|
|
|
break; //Found it
|
2020-10-23 17:19:30 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:19:30 +00:00
|
|
|
if (j == -1) return;
|
|
|
|
DukeStatIterator it1(STAT_EFFECTOR);
|
|
|
|
while (auto act3 = it.Next())
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2022-12-22 08:49:42 +00:00
|
|
|
if ((act3->spr.lotag & 0xff) == 21 && !act3->counter &&
|
2021-12-21 17:19:45 +00:00
|
|
|
(act3->spr.hitag) == j)
|
2022-12-22 08:49:42 +00:00
|
|
|
act3->counter = 1;
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2021-11-18 17:46:04 +00:00
|
|
|
callsound(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-18 17:51:19 +00:00
|
|
|
void operatesectors(sectortype* sptr, DDukeActor *actor)
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2021-11-17 22:31:08 +00:00
|
|
|
int j=0;
|
2020-10-23 17:05:42 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
switch (sptr->lotag & (0x3fff))
|
|
|
|
{
|
|
|
|
|
|
|
|
case 41:
|
|
|
|
if (isRR()) operatejaildoors(sptr->hitag);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
if (!isRR()) break;
|
2022-11-15 14:24:17 +00:00
|
|
|
for (auto& wal : sptr->walls)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-09-12 17:47:07 +00:00
|
|
|
setanimation(sptr, anim_vertexx, &wal, wal.pos.X + 64, 1 / 4.);
|
|
|
|
if (wal.twoSided()) setanimation(sptr, anim_vertexx, wal.nextWall(), wal.nextWall()->pos.X + 64, 1 / 4.);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ST_30_ROTATE_RISE_BRIDGE:
|
2020-10-23 17:20:46 +00:00
|
|
|
{
|
2021-12-05 23:50:33 +00:00
|
|
|
auto act = barrier_cast<DDukeActor*>(sptr->hitagactor);
|
2020-11-04 18:15:44 +00:00
|
|
|
if (!act) break;
|
2022-09-14 21:30:10 +00:00
|
|
|
if (act->tempval == 0 || act->tempval == 256) callsound(sptr, actor);
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act->spr.extra == 1) act->spr.extra = 3;
|
|
|
|
else act->spr.extra = 1;
|
2020-10-23 17:05:42 +00:00
|
|
|
break;
|
2020-10-23 17:20:46 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
|
|
|
|
case ST_31_TWO_WAY_TRAIN:
|
2020-10-23 17:20:46 +00:00
|
|
|
{
|
2021-12-05 23:50:33 +00:00
|
|
|
auto act = barrier_cast<DDukeActor*>(sptr->hitagactor);
|
2020-11-04 18:15:44 +00:00
|
|
|
if (!act) break;
|
2020-10-23 17:20:46 +00:00
|
|
|
if (act->temp_data[4] == 0)
|
|
|
|
act->temp_data[4] = 1;
|
2020-10-23 17:05:42 +00:00
|
|
|
|
2021-11-18 17:51:19 +00:00
|
|
|
callsound(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
break;
|
2020-10-23 17:20:46 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
case ST_26_SPLITTING_ST_DOOR: //The split doors
|
2022-09-12 17:47:07 +00:00
|
|
|
i = getanimationindex(anim_ceilingz, sptr);
|
2020-10-23 17:05:42 +00:00
|
|
|
if (i == -1) //if the door has stopped
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2020-10-23 17:05:42 +00:00
|
|
|
haltsoundhack = 1;
|
|
|
|
sptr->lotag &= 0xff00;
|
|
|
|
sptr->lotag |= ST_22_SPLITTING_DOOR;
|
2021-11-18 17:51:19 +00:00
|
|
|
operatesectors(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
sptr->lotag &= 0xff00;
|
|
|
|
sptr->lotag |= ST_9_SLIDING_ST_DOOR;
|
2021-11-18 17:51:19 +00:00
|
|
|
operatesectors(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
sptr->lotag &= 0xff00;
|
|
|
|
sptr->lotag |= ST_26_SPLITTING_ST_DOOR;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
return;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
case ST_9_SLIDING_ST_DOOR:
|
2021-11-18 17:35:59 +00:00
|
|
|
handle_st09(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_15_WARP_ELEVATOR://Warping elevators
|
2021-11-18 17:38:09 +00:00
|
|
|
handle_st15(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_16_PLATFORM_DOWN:
|
|
|
|
case ST_17_PLATFORM_UP:
|
2021-11-18 17:38:09 +00:00
|
|
|
handle_st16(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_18_ELEVATOR_DOWN:
|
|
|
|
case ST_19_ELEVATOR_UP:
|
2021-11-18 17:43:25 +00:00
|
|
|
handle_st18(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_29_TEETH_DOOR:
|
2021-11-18 17:43:25 +00:00
|
|
|
handle_st29(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
return;
|
|
|
|
case ST_20_CEILING_DOOR:
|
2021-11-18 17:43:25 +00:00
|
|
|
handle_st20(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_21_FLOOR_DOOR:
|
2021-11-18 17:43:25 +00:00
|
|
|
handle_st21(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_22_SPLITTING_DOOR:
|
2021-11-18 17:43:25 +00:00
|
|
|
handle_st22(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_23_SWINGING_DOOR: //Swingdoor
|
2021-11-18 17:46:04 +00:00
|
|
|
handle_st23(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_25_SLIDING_DOOR: //Subway type sliding doors
|
|
|
|
{
|
2021-11-18 17:46:04 +00:00
|
|
|
handle_st25(sptr, actor);
|
2020-05-12 11:43:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
case ST_27_STRETCH_BRIDGE: //Extended bridge
|
2021-11-18 17:46:04 +00:00
|
|
|
handle_st27(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_28_DROP_FLOOR:
|
2021-11-18 17:46:04 +00:00
|
|
|
handle_st28(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
return;
|
2020-10-14 19:40:15 +00:00
|
|
|
}
|
2020-05-10 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-11-19 14:40:35 +00:00
|
|
|
void operateactivators(int low, player_struct* plr)
|
2020-05-10 14:53:09 +00:00
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
int i, j, k;
|
2021-11-06 20:53:15 +00:00
|
|
|
Cycler * p;
|
2020-05-12 11:43:24 +00:00
|
|
|
walltype* wal;
|
|
|
|
|
2022-11-20 13:13:11 +00:00
|
|
|
for (i = cyclers.Size() - 1; i >= 0; i--)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-06 20:53:15 +00:00
|
|
|
p = &cyclers[i];
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-11-06 20:53:15 +00:00
|
|
|
|
|
|
|
if (p->hitag == low)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-18 19:17:47 +00:00
|
|
|
auto sect = p->sector;
|
2021-11-06 20:53:15 +00:00
|
|
|
p->state = !p->state;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-11-06 20:53:15 +00:00
|
|
|
sect->floorshade = sect->ceilingshade = (int8_t)p->shade2;
|
2022-11-15 14:44:33 +00:00
|
|
|
wal = sect->walls.Data();
|
2022-11-15 13:59:28 +00:00
|
|
|
for (j = sect->walls.Size(); j > 0; j--, wal++)
|
2021-11-06 20:53:15 +00:00
|
|
|
wal->shade = (int8_t)p->shade2;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
k = -1;
|
2020-10-23 17:35:59 +00:00
|
|
|
DukeStatIterator it(STAT_ACTIVATOR);
|
|
|
|
while (auto act = it.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act->spr.lotag == low)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-11-20 11:43:24 +00:00
|
|
|
if (islockedactivator(act))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
act->sector()->lotag ^= 16384;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2022-11-19 14:40:35 +00:00
|
|
|
if (plr)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-20 23:33:17 +00:00
|
|
|
if (act->sector()->lotag & 16384)
|
2022-11-19 14:40:35 +00:00
|
|
|
FTA(4, plr);
|
|
|
|
else FTA(8, plr);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
switch (act->spr.hitag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
2022-08-28 09:35:03 +00:00
|
|
|
if (act->sector()->floorz != act->sector()->ceilingz)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2022-08-28 09:35:03 +00:00
|
|
|
if (act->sector()->floorz == act->sector()->ceilingz)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-11-20 23:33:17 +00:00
|
|
|
if (act->sector()->lotag < 3)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-24 09:53:27 +00:00
|
|
|
DukeSectIterator itr(act->sector());
|
|
|
|
while (auto a2 = itr.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.statnum == 3) switch (a2->spr.lotag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
|
|
|
|
if (isRRRA()) break;
|
2021-11-14 11:25:25 +00:00
|
|
|
[[fallthrough]];
|
2020-05-12 11:43:24 +00:00
|
|
|
case SE_36_PROJ_SHOOTER:
|
|
|
|
case SE_31_FLOOR_RISE_FALL:
|
|
|
|
case SE_32_CEILING_RISE_FALL:
|
2022-12-22 08:49:42 +00:00
|
|
|
a2->counter = 1 - a2->counter;
|
2021-11-20 23:33:17 +00:00
|
|
|
callsound(act->sector(), a2);
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-09 22:03:11 +00:00
|
|
|
if (k == -1 && (act->sector()->lotag & 0xff) == SE_22_TEETH_DOOR)
|
2021-11-20 23:33:17 +00:00
|
|
|
k = callsound(act->sector(), act);
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-11-20 23:33:17 +00:00
|
|
|
operatesectors(act->sector(), act);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-20 10:58:19 +00:00
|
|
|
operaterespawns(low);
|
2020-05-10 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 16:05:36 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void operatemasterswitches(int low)
|
|
|
|
{
|
2020-10-23 17:35:59 +00:00
|
|
|
DukeStatIterator it(STAT_STANDABLE);
|
|
|
|
while (auto act2 = it.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-11-19 08:02:40 +00:00
|
|
|
if (ismasterswitch(act2) && act2->spr.lotag == low && act2->spr.yint == 0)
|
2022-11-19 09:58:35 +00:00
|
|
|
{
|
2022-09-01 16:15:52 +00:00
|
|
|
act2->spr.yint = 1;
|
2022-11-19 09:58:35 +00:00
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-05-10 16:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-10 16:52:25 +00:00
|
|
|
void operateforcefields(DDukeActor *effector, int low)
|
2020-05-10 16:05:36 +00:00
|
|
|
{
|
2021-11-17 23:30:37 +00:00
|
|
|
for (int p = numanimwalls-1; p >= 0; p--)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-17 23:30:37 +00:00
|
|
|
auto wal = animwall[p].wall;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-11-17 21:50:56 +00:00
|
|
|
if (low == wal->lotag || low == -1)
|
2022-12-10 18:03:17 +00:00
|
|
|
if (tileflags(wal->overtexture) & (TFLAG_FORCEFIELD | TFLAG_ANIMFORCEFIELD))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
animwall[p].tag = 0;
|
|
|
|
|
2021-11-17 21:50:56 +00:00
|
|
|
if (wal->cstat)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-17 21:50:56 +00:00
|
|
|
wal->cstat = 0;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2022-12-05 10:27:25 +00:00
|
|
|
if (effector && iseffector(effector) && effector->spr.lotag == SE_30_TWO_WAY_TRAIN)
|
2021-11-17 21:50:56 +00:00
|
|
|
wal->lotag = 0;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
else
|
2021-12-18 14:16:31 +00:00
|
|
|
wal->cstat = (CSTAT_WALL_BLOCK | CSTAT_WALL_ALIGN_BOTTOM | CSTAT_WALL_MASKED | CSTAT_WALL_BLOCK_HITSCAN);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-10 16:05:36 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 18:59:38 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-05 10:27:25 +00:00
|
|
|
void checkhitwall(DDukeActor* spr, walltype* wal, const DVector3& pos)
|
2020-05-10 18:59:38 +00:00
|
|
|
{
|
2022-12-20 21:25:48 +00:00
|
|
|
if (wal->overtexture == mirrortex && (spr->flags2 & SFLAG2_BREAKMIRRORS))
|
2022-12-05 10:27:25 +00:00
|
|
|
{
|
|
|
|
lotsofglass(spr, wal, 70);
|
|
|
|
wal->cstat &= ~CSTAT_WALL_MASKED;
|
2022-12-10 17:29:53 +00:00
|
|
|
wal->setovertexture(TexMan.CheckForTexture("MIRRORBROKE", ETextureType::Any));
|
2022-12-05 10:27:25 +00:00
|
|
|
wal->portalflags = 0;
|
|
|
|
S_PlayActorSound(GLASS_HEAVYBREAK, spr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-08 21:49:02 +00:00
|
|
|
auto handler = [=](const BreakWallRec* data) ->bool
|
2022-12-05 10:27:25 +00:00
|
|
|
{
|
|
|
|
if (!data->handler)
|
|
|
|
{
|
|
|
|
S_PlayActorSound(data->breaksound, spr);
|
2022-12-08 21:49:02 +00:00
|
|
|
return true;
|
2022-12-05 10:27:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-08 21:49:02 +00:00
|
|
|
VMValue args[7] = { wal, data->brokentex.GetIndex(), data->breaksound.index(), spr, pos.X, pos.Y, pos.Z};
|
2022-12-05 10:27:25 +00:00
|
|
|
VMCall(data->handler, args, 7, nullptr, 0);
|
|
|
|
}
|
2022-12-08 21:49:02 +00:00
|
|
|
return false;
|
2022-12-05 10:27:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (wal->twoSided() && wal->nextSector()->floorz > pos.Z && wal->nextSector()->floorz - wal->nextSector()->ceilingz)
|
|
|
|
{
|
2022-12-10 18:03:17 +00:00
|
|
|
auto data = breakWallMap.CheckKey(wal->overtexture.GetIndex());
|
2022-12-05 10:27:25 +00:00
|
|
|
if (data && (data->flags & 1) && (!(data->flags & 2) || wal->cstat & CSTAT_WALL_MASKED))
|
|
|
|
{
|
2022-12-08 21:49:02 +00:00
|
|
|
if (handler(data)) wal->setovertexture(data->brokentex);
|
2022-12-05 10:27:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-10 18:03:17 +00:00
|
|
|
auto data = breakWallMap.CheckKey(wal->walltexture.GetIndex());
|
2022-12-05 10:27:25 +00:00
|
|
|
if (data && !(data->flags & 1))
|
|
|
|
{
|
2022-12-08 21:49:02 +00:00
|
|
|
if (handler(data)) wal->setwalltexture(data->brokentex);
|
2022-12-05 10:27:25 +00:00
|
|
|
}
|
2020-05-10 18:59:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-05 14:29:45 +00:00
|
|
|
bool checkhitceiling(sectortype* sectp)
|
|
|
|
{
|
2022-12-09 09:48:47 +00:00
|
|
|
auto data = breakCeilingMap.CheckKey(sectp->ceilingtexture.GetIndex());
|
2022-12-05 14:29:45 +00:00
|
|
|
if (data && !(data->flags & 1))
|
|
|
|
{
|
|
|
|
if (!data->handler)
|
|
|
|
{
|
2022-12-08 21:49:02 +00:00
|
|
|
sectp->setceilingtexture(data->brokentex);
|
2022-12-05 14:29:45 +00:00
|
|
|
S_PlayActorSound(data->breaksound, ps[screenpeek].GetActor()); // this is nonsense but what the original code did.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-08 21:49:02 +00:00
|
|
|
VMValue args[7] = { sectp, data->brokentex.GetIndex(), data->breaksound.index()};
|
2022-12-05 14:29:45 +00:00
|
|
|
VMCall(data->handler, args, 3, nullptr, 0);
|
|
|
|
}
|
|
|
|
if (data->flags & 1)
|
|
|
|
{
|
|
|
|
if (!sectp->hitag)
|
|
|
|
{
|
|
|
|
DukeSectIterator it(sectp);
|
|
|
|
while (auto act = it.Next())
|
|
|
|
{
|
|
|
|
if (iseffector(act) && act->spr.lotag == SE_12_LIGHT_SWITCH)
|
|
|
|
{
|
|
|
|
DukeStatIterator it1(STAT_EFFECTOR);
|
|
|
|
while (auto act2 = it1.Next())
|
|
|
|
{
|
|
|
|
if (act2->spr.hitag == act->spr.hitag)
|
|
|
|
act2->temp_data[3] = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int j = krand() & 1;
|
|
|
|
DukeStatIterator it(STAT_EFFECTOR);
|
|
|
|
while (auto act = it.Next())
|
|
|
|
{
|
|
|
|
if (act->spr.hitag == (sectp->hitag) && act->spr.lotag == SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT)
|
|
|
|
{
|
|
|
|
act->temp_data[2] = j;
|
|
|
|
act->temp_data[4] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (data->flags & 2)
|
|
|
|
{
|
|
|
|
ceilingglass(ps[myconnectindex].GetActor(), sectp, 10);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-01-01 15:08:12 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void checkhitdefault(DDukeActor* targ, DDukeActor* proj)
|
|
|
|
{
|
|
|
|
if ((targ->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL) && targ->spr.hitag == 0 && targ->spr.lotag == 0 && targ->spr.statnum == STAT_DEFAULT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (((proj->flags3 & SFLAG3_CANHURTSHOOTER) || proj->GetOwner() != targ) && targ->spr.statnum != STAT_PROJECTILE)
|
|
|
|
{
|
|
|
|
if (badguy(targ))
|
|
|
|
{
|
|
|
|
if (targ->spr.scale.X < targ->FloatVar(NAME_minhitscale))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (proj->flags4 & SFLAG4_DOUBLEHITDAMAGE) proj->spr.extra <<= 1;
|
|
|
|
|
|
|
|
if (!(targ->flags3 & SFLAG3_NOHITJIBS) && !(proj->flags3 & SFLAG3_NOHITJIBS))
|
|
|
|
{
|
|
|
|
auto spawned = spawn(proj, DukeJibs6Class);
|
|
|
|
if (spawned)
|
|
|
|
{
|
|
|
|
if (proj->spr.pal == 6)
|
|
|
|
spawned->spr.pal = 6;
|
|
|
|
spawned->spr.pos.Z += 4;
|
|
|
|
spawned->vel.X = 1;
|
|
|
|
spawned->spr.scale = DVector2(0.375, 0.375);
|
|
|
|
spawned->spr.Angles.Yaw = DAngle22_5 / 4 - randomAngle(22.5 / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Owner = proj->GetOwner();
|
|
|
|
|
|
|
|
if (Owner && Owner->isPlayer() && !(targ->flags3 & SFLAG3_NOSHOTGUNBLOOD))
|
|
|
|
if (ps[Owner->PlayerIndex()].curr_weapon == SHOTGUN_WEAPON)
|
|
|
|
{
|
|
|
|
shoot(targ, DukeBloodSplat3Class);
|
|
|
|
shoot(targ, DukeBloodSplat1Class);
|
|
|
|
shoot(targ, DukeBloodSplat2Class);
|
|
|
|
shoot(targ, DukeBloodSplat4Class);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(targ->flags2 & SFLAG2_NODAMAGEPUSH))
|
|
|
|
{
|
|
|
|
if ((targ->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0)
|
|
|
|
targ->spr.Angles.Yaw = proj->spr.Angles.Yaw + DAngle180;
|
|
|
|
|
|
|
|
targ->vel.X = -proj->spr.extra * 0.25;
|
|
|
|
auto sp = targ->sector();
|
|
|
|
pushmove(targ->spr.pos, &sp, 8, 4, 4, CLIPMASK0);
|
|
|
|
if (sp != targ->sector() && sp != nullptr)
|
|
|
|
ChangeActorSect(targ, sp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (targ->spr.statnum == STAT_ZOMBIEACTOR)
|
|
|
|
{
|
|
|
|
ChangeActorStat(targ, STAT_ACTOR);
|
|
|
|
targ->timetosleep = SLEEPTIME;
|
|
|
|
}
|
|
|
|
if (!shrinkersizecheck(proj->GetClass(), targ)) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (targ->spr.statnum != STAT_ZOMBIEACTOR)
|
|
|
|
{
|
|
|
|
if ((proj->flags2 & SFLAG2_FREEZEDAMAGE) && ((targ->isPlayer() && targ->spr.pal == 1) || (gs.freezerhurtowner == 0 && proj->GetOwner() == targ)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto hitpic = static_cast<PClassActor*>(proj->GetClass());
|
|
|
|
auto Owner = proj->GetOwner();
|
|
|
|
if (Owner && Owner->isPlayer())
|
|
|
|
{
|
|
|
|
if (targ->isPlayer() && ud.coop != 0 && ud.ffire == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto tOwner = targ->GetOwner();
|
|
|
|
if (hitpic == DukeFireballClass && tOwner && tOwner->GetClass() != DukeFireballClass) // hack alert! Even with damage types this special check needs to stay.
|
|
|
|
hitpic = DukeFlamethrowerFlameClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
targ->attackertype = hitpic;
|
|
|
|
targ->hitextra += proj->spr.extra;
|
|
|
|
if (!(targ->flags4 & SFLAG4_NODAMAGETURN))
|
|
|
|
targ->hitang = proj->spr.Angles.Yaw;
|
|
|
|
targ->SetHitOwner(Owner);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (targ->spr.statnum == STAT_PLAYER)
|
|
|
|
{
|
|
|
|
auto p = targ->PlayerIndex();
|
|
|
|
if (ps[p].newOwner != nullptr)
|
|
|
|
{
|
|
|
|
ps[p].newOwner = nullptr;
|
|
|
|
ps[p].GetActor()->restoreloc();
|
|
|
|
|
|
|
|
updatesector(ps[p].GetActor()->getPosWithOffsetZ(), &ps[p].cursector);
|
|
|
|
|
|
|
|
DukeStatIterator it(STAT_ACTOR);
|
|
|
|
while (auto itActor = it.Next())
|
|
|
|
{
|
|
|
|
if (itActor->flags2 & SFLAG2_CAMERA) itActor->spr.yint = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!shrinkersizecheck(proj->GetClass(), targ))
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto hitowner = targ->GetHitOwner();
|
|
|
|
if (!hitowner || !hitowner->isPlayer())
|
|
|
|
if (ud.player_skill >= 3)
|
|
|
|
proj->spr.extra += (proj->spr.extra >> 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-12-05 14:29:45 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-10 18:59:38 +00:00
|
|
|
void allignwarpelevators(void)
|
|
|
|
{
|
2020-10-23 18:02:57 +00:00
|
|
|
DukeStatIterator it(STAT_EFFECTOR);
|
|
|
|
while (auto act = it.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act->spr.lotag == SE_17_WARP_ELEVATOR && act->spr.shade > 16)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2020-10-23 18:02:57 +00:00
|
|
|
DukeStatIterator it1(STAT_EFFECTOR);
|
|
|
|
while (auto act2 = it1.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if ((act2->spr.lotag) == SE_17_WARP_ELEVATOR && act != act2 && act->spr.hitag == act2->spr.hitag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2022-10-09 07:31:51 +00:00
|
|
|
act2->sector()->setfloorz(act->sector()->floorz);
|
|
|
|
act2->sector()->setceilingz(act->sector()->ceilingz);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-10 18:59:38 +00:00
|
|
|
}
|
2020-05-10 16:05:36 +00:00
|
|
|
|
2020-07-06 00:05:31 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-09-08 11:16:27 +00:00
|
|
|
void moveclouds(double interpfrac)
|
2020-07-06 00:05:31 +00:00
|
|
|
{
|
2020-10-23 17:05:42 +00:00
|
|
|
// The math here is very messy.. :(
|
2022-09-08 11:16:27 +00:00
|
|
|
int myclock = interpfrac < 0.5 ? PlayClock-2 : PlayClock;
|
2020-08-31 17:22:21 +00:00
|
|
|
if (myclock > cloudclock || myclock < (cloudclock - 7))
|
2020-07-06 00:05:31 +00:00
|
|
|
{
|
2020-08-31 17:22:21 +00:00
|
|
|
cloudclock = myclock + 6;
|
2020-07-06 00:05:31 +00:00
|
|
|
|
|
|
|
// cloudx/y were an array, but all entries were always having the same value so a single pair is enough.
|
2022-11-25 11:30:40 +00:00
|
|
|
cloudx += (float)ps[screenpeek].GetActor()->spr.Angles.Yaw.Cos() * 0.5f;
|
|
|
|
cloudy += (float)ps[screenpeek].GetActor()->spr.Angles.Yaw.Sin() * 0.5f;
|
2020-07-06 00:05:31 +00:00
|
|
|
for (int i = 0; i < numclouds; i++)
|
|
|
|
{
|
2022-08-03 13:50:27 +00:00
|
|
|
// no clamping here!
|
|
|
|
clouds[i]->ceilingxpan_ = cloudx;
|
|
|
|
clouds[i]->ceilingypan_ = cloudy;
|
2021-11-17 23:04:52 +00:00
|
|
|
clouds[i]->exflags |= SECTOREX_CLOUDSCROLL;
|
2020-07-06 00:05:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-11 10:52:36 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-07-06 00:05:31 +00:00
|
|
|
|
2022-12-11 10:52:36 +00:00
|
|
|
void resetswitch(int tag)
|
|
|
|
{
|
|
|
|
DukeStatIterator it2(STAT_DEFAULT);
|
|
|
|
while (auto act2 = it2.Next())
|
|
|
|
{
|
|
|
|
auto& ext = GetExtInfo(act2->spr.spritetexture());
|
|
|
|
if (ext.switchindex > 0 && ext.switchphase == 1 && act2->spr.hitag == tag)
|
|
|
|
{
|
|
|
|
auto& swdef = switches[ext.switchindex];
|
|
|
|
if (swdef.type == SwitchDef::Regular && swdef.flags & SwitchDef::resettable)
|
|
|
|
{
|
|
|
|
act2->spr.setspritetexture(swdef.states[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-10 14:53:09 +00:00
|
|
|
|
2022-12-11 13:21:01 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void tag10000specialswitch(int snum, DDukeActor* act, const DVector3& v)
|
|
|
|
{
|
|
|
|
DDukeActor* switches[3];
|
|
|
|
int switchcount = 0, j;
|
|
|
|
S_PlaySound3D(SWITCH_ON, act, v);
|
|
|
|
DukeSpriteIterator itr;
|
|
|
|
while (auto actt = itr.Next())
|
|
|
|
{
|
|
|
|
int jht = actt->spr.hitag;
|
|
|
|
auto ext = GetExtInfo(actt->spr.spritetexture());
|
|
|
|
if (jht == 10000 && ext.switchphase == 0 && ::switches[ext.switchindex].type == SwitchDef::Multi)
|
|
|
|
{
|
|
|
|
if (switchcount < 3)
|
|
|
|
{
|
|
|
|
switches[switchcount] = actt;
|
|
|
|
switchcount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (switchcount == 3)
|
|
|
|
{
|
|
|
|
// This once was a linear search over sprites[] so bring things back in order, just to be safe.
|
|
|
|
if (switches[0]->GetIndex() > switches[1]->GetIndex()) std::swap(switches[0], switches[1]);
|
|
|
|
if (switches[0]->GetIndex() > switches[2]->GetIndex()) std::swap(switches[0], switches[2]);
|
|
|
|
if (switches[1]->GetIndex() > switches[2]->GetIndex()) std::swap(switches[1], switches[2]);
|
|
|
|
|
|
|
|
S_PlaySound3D(78, act, v);
|
|
|
|
for (j = 0; j < switchcount; j++)
|
|
|
|
{
|
|
|
|
switches[j]->spr.hitag = 0;
|
|
|
|
switches[j]->spr.setspritetexture(::switches[GetExtInfo(switches[j]->spr.spritetexture()).switchindex].states[3]);
|
2022-12-11 14:42:33 +00:00
|
|
|
checkhitswitch(snum, nullptr, switches[j]);
|
2022-12-11 13:21:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-10 10:42:47 +00:00
|
|
|
|
2022-12-11 14:09:12 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void togglespriteswitches(DDukeActor* act, const TexExtInfo& ext, int lotag, int& correctdips, int& numdips)
|
|
|
|
{
|
|
|
|
auto& swdef = switches[ext.switchindex];
|
|
|
|
|
|
|
|
DukeStatIterator it(STAT_DEFAULT);
|
|
|
|
while (auto other = it.Next())
|
|
|
|
{
|
|
|
|
if (lotag != other->spr.lotag) continue;
|
|
|
|
|
|
|
|
auto& other_ext = GetExtInfo(other->spr.spritetexture());
|
|
|
|
auto& other_swdef = switches[other_ext.switchindex];
|
|
|
|
|
|
|
|
switch (other_swdef.type)
|
|
|
|
{
|
|
|
|
case SwitchDef::Combo:
|
|
|
|
if (other_ext.switchphase == 0)
|
|
|
|
{
|
2022-12-11 14:16:19 +00:00
|
|
|
if (act == other) other->spr.setspritetexture(other_swdef.states[1]);
|
2022-12-11 14:09:12 +00:00
|
|
|
else if (other->spr.hitag == 0) correctdips++;
|
|
|
|
numdips++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-11 14:16:19 +00:00
|
|
|
if (act == other) other->spr.setspritetexture(other_swdef.states[0]);
|
2022-12-11 14:09:12 +00:00
|
|
|
else if (other->spr.hitag == 1) correctdips++;
|
|
|
|
numdips++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SwitchDef::Multi:
|
|
|
|
other->spr.setspritetexture(other_swdef.states[(other_ext.switchphase + 1) & 3]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SwitchDef::Access:
|
|
|
|
case SwitchDef::Regular:
|
|
|
|
if (other->spr.hitag != 999 || other_ext.switchphase != 1 || !(other_swdef.flags & SwitchDef::resettable))
|
|
|
|
{
|
|
|
|
other->spr.setspritetexture(other_swdef.states[1 - other_ext.switchphase]);
|
|
|
|
}
|
|
|
|
// one of RR's ugly hacks.
|
|
|
|
if (other->spr.hitag == 999 && other_ext.switchphase == 0 && (other_swdef.flags & SwitchDef::resettable))
|
|
|
|
{
|
|
|
|
DukeStatIterator it1(STAT_LUMBERMILL);
|
|
|
|
while (auto other2 = it1.Next())
|
|
|
|
{
|
|
|
|
CallOnUse(other2, nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-11 14:16:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void togglewallswitches(walltype* wwal, const TexExtInfo& ext, int lotag, int& correctdips, int& numdips)
|
|
|
|
{
|
|
|
|
for (auto& wal : wall)
|
|
|
|
{
|
|
|
|
if (lotag != wal.lotag) continue;
|
|
|
|
|
2022-12-10 18:03:17 +00:00
|
|
|
auto& other_ext = GetExtInfo(wal.walltexture);
|
2022-12-11 14:16:19 +00:00
|
|
|
auto& other_swdef = switches[other_ext.switchindex];
|
|
|
|
|
|
|
|
switch (other_swdef.type)
|
|
|
|
{
|
|
|
|
case SwitchDef::Combo:
|
|
|
|
if (other_ext.switchphase == 0)
|
|
|
|
{
|
|
|
|
if (&wal == wwal) wal.setwalltexture(other_swdef.states[1]);
|
|
|
|
else if (wal.hitag == 0) correctdips++;
|
|
|
|
numdips++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (&wal == wwal) wal.setwalltexture(other_swdef.states[0]);
|
|
|
|
else if (wal.hitag == 1) correctdips++;
|
|
|
|
numdips++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SwitchDef::Multi:
|
|
|
|
wal.setwalltexture(other_swdef.states[(other_ext.switchphase + 1) & 3]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SwitchDef::Access:
|
|
|
|
case SwitchDef::Regular:
|
|
|
|
wal.setwalltexture(other_swdef.states[1 - other_ext.switchphase]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-11 14:42:33 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// how NOT to implement switches...
|
|
|
|
// (even after cleaning up the hard coded texture checks it's still a disaster)
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool checkhitswitch(int snum, walltype* wwal, DDukeActor* act)
|
|
|
|
{
|
|
|
|
uint8_t switchpal;
|
|
|
|
int lotag, hitag, correctdips, numdips;
|
|
|
|
DVector2 spos;
|
|
|
|
FTextureID texid;
|
2022-12-29 12:55:59 +00:00
|
|
|
int swresult = 0;
|
2022-12-11 14:42:33 +00:00
|
|
|
|
|
|
|
if (wwal == nullptr && act == nullptr) return 0;
|
|
|
|
correctdips = 1;
|
|
|
|
numdips = 0;
|
|
|
|
|
|
|
|
if (act)
|
|
|
|
{
|
|
|
|
lotag = act->spr.lotag;
|
|
|
|
if (lotag == 0) return 0;
|
|
|
|
hitag = act->spr.hitag;
|
|
|
|
spos = act->spr.pos.XY();
|
|
|
|
texid = act->spr.spritetexture();
|
|
|
|
switchpal = act->spr.pal;
|
|
|
|
|
|
|
|
// custom switches that maintain themselves can immediately abort.
|
2022-12-29 12:55:59 +00:00
|
|
|
swresult = CallTriggerSwitch(act, &ps[snum]);
|
|
|
|
if (swresult == 1) return true;
|
2022-12-11 14:42:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lotag = wwal->lotag;
|
|
|
|
if (lotag == 0) return 0;
|
|
|
|
hitag = wwal->hitag;
|
|
|
|
spos = wwal->pos;
|
2022-12-10 18:03:17 +00:00
|
|
|
texid = wwal->walltexture;
|
2022-12-11 14:42:33 +00:00
|
|
|
switchpal = wwal->pal;
|
|
|
|
}
|
|
|
|
auto& ext = GetExtInfo(texid);
|
|
|
|
auto& swdef = switches[ext.switchindex];
|
|
|
|
|
2022-12-29 12:55:59 +00:00
|
|
|
if (swresult == 0)
|
2022-12-11 14:42:33 +00:00
|
|
|
{
|
2022-12-29 12:55:59 +00:00
|
|
|
// check if the switch may be activated.
|
|
|
|
switch (swdef.type)
|
|
|
|
{
|
|
|
|
case SwitchDef::Combo:
|
|
|
|
break;
|
2022-12-11 14:42:33 +00:00
|
|
|
|
2022-12-29 12:55:59 +00:00
|
|
|
case SwitchDef::Access:
|
2023-01-08 09:34:14 +00:00
|
|
|
if (fi.checkaccessswitch(snum, switchpal, act, wwal))
|
2022-12-29 12:55:59 +00:00
|
|
|
return 0;
|
|
|
|
[[fallthrough]];
|
2022-12-11 14:42:33 +00:00
|
|
|
|
2022-12-29 12:55:59 +00:00
|
|
|
case SwitchDef::Regular:
|
|
|
|
case SwitchDef::Multi:
|
|
|
|
if (check_activator_motion(lotag)) return 0;
|
|
|
|
break;
|
2022-12-11 14:42:33 +00:00
|
|
|
|
2022-12-29 12:55:59 +00:00
|
|
|
default:
|
|
|
|
if (isadoorwall(texid) == 0) return 0;
|
|
|
|
break;
|
|
|
|
}
|
2022-12-11 14:42:33 +00:00
|
|
|
|
2022-12-29 12:55:59 +00:00
|
|
|
togglespriteswitches(act, ext, lotag, correctdips, numdips);
|
|
|
|
togglewallswitches(wwal, ext, lotag, correctdips, numdips);
|
2022-12-11 14:42:33 +00:00
|
|
|
|
2022-12-29 12:55:59 +00:00
|
|
|
if (lotag == -1)
|
|
|
|
{
|
|
|
|
setnextmap(false);
|
|
|
|
return 1;
|
|
|
|
}
|
2022-12-11 14:42:33 +00:00
|
|
|
|
2022-12-29 12:55:59 +00:00
|
|
|
// Yet another crude RRRA hack that cannot be fully generalized.
|
|
|
|
if (hitag == 10001 && swdef.flags & SwitchDef::oneway && isRRRA())
|
|
|
|
{
|
|
|
|
act->spr.setspritetexture(swdef.states[1]);
|
|
|
|
if (ps[snum].SeaSick == 0)
|
|
|
|
ps[snum].SeaSick = 350;
|
|
|
|
operateactivators(668, &ps[snum]);
|
|
|
|
operatemasterswitches(668);
|
|
|
|
S_PlayActorSound(328, ps[snum].GetActor());
|
|
|
|
return 1;
|
|
|
|
}
|
2022-12-11 14:42:33 +00:00
|
|
|
}
|
2022-12-29 12:55:59 +00:00
|
|
|
DVector3 v(spos, ps[snum].GetActor()->getOffsetZ());
|
2022-12-11 14:42:33 +00:00
|
|
|
|
|
|
|
if (swdef.type != SwitchDef::None || isadoorwall(texid))
|
|
|
|
{
|
2022-12-29 12:55:59 +00:00
|
|
|
if (swresult == 0)
|
2022-12-11 14:42:33 +00:00
|
|
|
{
|
2022-12-29 12:55:59 +00:00
|
|
|
if (swdef.type == SwitchDef::Combo)
|
2022-12-11 14:42:33 +00:00
|
|
|
{
|
2022-12-29 12:55:59 +00:00
|
|
|
FSoundID sound = swdef.soundid != NO_SOUND ? swdef.soundid : S_FindSoundByResID(SWITCH_ON);
|
|
|
|
if (act) S_PlaySound3D(sound, act, v);
|
|
|
|
else S_PlaySound3D(sound, ps[snum].GetActor(), v);
|
|
|
|
if (numdips != correctdips) return 0;
|
|
|
|
S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].GetActor(), v);
|
|
|
|
}
|
|
|
|
if (swdef.type == SwitchDef::Multi)
|
|
|
|
{
|
|
|
|
lotag += ext.switchphase;
|
|
|
|
if (hitag == 10000 && act && isRRRA()) // no idea if the game check is really needed for something this far off the beaten path...
|
|
|
|
{
|
|
|
|
tag10000specialswitch(snum, act, v);
|
|
|
|
return 1;
|
|
|
|
}
|
2022-12-11 14:42:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DukeStatIterator itr(STAT_EFFECTOR);
|
|
|
|
while (auto other = itr.Next())
|
|
|
|
{
|
|
|
|
if (other->spr.hitag == lotag)
|
|
|
|
{
|
|
|
|
switch (other->spr.lotag)
|
|
|
|
{
|
|
|
|
case 46:
|
|
|
|
case SE_47_LIGHT_SWITCH:
|
|
|
|
case SE_48_LIGHT_SWITCH:
|
|
|
|
if (!isRRRA()) break;
|
|
|
|
[[fallthrough]];
|
|
|
|
|
|
|
|
case SE_12_LIGHT_SWITCH:
|
|
|
|
other->sector()->floorpal = 0;
|
2022-12-22 08:49:42 +00:00
|
|
|
other->counter++;
|
|
|
|
if (other->counter == 2)
|
|
|
|
other->counter++;
|
2022-12-11 14:42:33 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case SE_24_CONVEYOR:
|
|
|
|
case SE_34:
|
|
|
|
case SE_25_PISTON:
|
|
|
|
other->temp_data[4] = !other->temp_data[4];
|
|
|
|
if (other->temp_data[4])
|
|
|
|
FTA(15, &ps[snum]);
|
|
|
|
else FTA(2, &ps[snum]);
|
|
|
|
break;
|
|
|
|
case SE_21_DROP_FLOOR:
|
|
|
|
FTA(2, &ps[screenpeek]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
operateactivators(lotag, &ps[snum]);
|
2022-12-10 16:52:25 +00:00
|
|
|
operateforcefields(ps[snum].GetActor(), lotag);
|
2022-12-11 14:42:33 +00:00
|
|
|
operatemasterswitches(lotag);
|
|
|
|
|
|
|
|
if (swdef.type == SwitchDef::Combo) return 1;
|
|
|
|
|
|
|
|
if (hitag == 0 && isadoorwall(texid) == 0)
|
|
|
|
{
|
|
|
|
FSoundID sound = swdef.soundid != NO_SOUND ? swdef.soundid : S_FindSoundByResID(SWITCH_ON);
|
|
|
|
if (act) S_PlaySound3D(sound, act, v);
|
|
|
|
else S_PlaySound3D(sound, ps[snum].GetActor(), v);
|
|
|
|
}
|
|
|
|
else if (hitag != 0)
|
|
|
|
{
|
|
|
|
auto flags = S_GetUserFlags(hitag);
|
|
|
|
|
|
|
|
if (act && (flags & SF_TALK) == 0)
|
|
|
|
S_PlaySound3D(hitag, act, v);
|
|
|
|
else
|
|
|
|
S_PlayActorSound(hitag, ps[snum].GetActor());
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-12-10 16:52:25 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void animatewalls(void)
|
|
|
|
{
|
|
|
|
static FTextureID noise, ff1, ff2;
|
|
|
|
|
|
|
|
// all that was done here is to open the system up sufficiently to allow replacing the textures being used without having to use ART files.
|
|
|
|
// Custom animated textures are better done with newly written controller actors.
|
|
|
|
if (!noise.isValid()) noise = TexMan.CheckForTexture("SCREENBREAK6", ETextureType::Any);
|
|
|
|
if (!ff1.isValid()) ff1 = TexMan.CheckForTexture("W_FORCEFIELD", ETextureType::Any);
|
|
|
|
if (!ff2.isValid()) ff2 = TexMan.CheckForTexture("W_FORCEFIELD2", ETextureType::Any);
|
|
|
|
|
|
|
|
if (ps[screenpeek].sea_sick_stat == 1)
|
|
|
|
{
|
|
|
|
for (auto& wal : wall)
|
|
|
|
{
|
2022-12-10 18:03:17 +00:00
|
|
|
if (tileflags(wal.walltexture) & TFLAG_SEASICKWALL)
|
2022-12-10 16:52:25 +00:00
|
|
|
wal.addxpan(6);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int t;
|
|
|
|
|
|
|
|
for (int p = 0; p < numanimwalls; p++)
|
|
|
|
{
|
|
|
|
auto wal = animwall[p].wall;
|
2022-12-10 18:03:17 +00:00
|
|
|
auto texid = wal->walltexture;
|
2022-12-10 16:52:25 +00:00
|
|
|
|
|
|
|
if (!animwall[p].overpic)
|
|
|
|
{
|
2022-12-10 18:03:17 +00:00
|
|
|
if (tileflags(wal->walltexture) & TFLAG_ANIMSCREEN)
|
2022-12-10 16:52:25 +00:00
|
|
|
{
|
|
|
|
if ((krand() & 255) < 16)
|
|
|
|
{
|
|
|
|
wal->setwalltexture(noise);
|
|
|
|
}
|
|
|
|
}
|
2022-12-10 18:03:17 +00:00
|
|
|
else if (tileflags(wal->walltexture) & TFLAG_ANIMSCREENNOISE)
|
2022-12-10 16:52:25 +00:00
|
|
|
{
|
|
|
|
if (animwall[p].origtex.isValid())
|
|
|
|
wal->setwalltexture(animwall[p].origtex);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
texid = texid + 1;
|
|
|
|
if (texid.GetIndex() > noise.GetIndex() + 3 || texid.GetIndex() < noise.GetIndex()) texid = noise;
|
|
|
|
wal->setwalltexture(texid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-10 18:03:17 +00:00
|
|
|
if (tileflags(wal->overtexture) & TFLAG_ANIMFORCEFIELD && wal->cstat & CSTAT_WALL_MASKED)
|
2022-12-10 16:52:25 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
t = animwall[p].tag;
|
|
|
|
|
|
|
|
if (wal->cstat & CSTAT_WALL_ANY_EXCEPT_BLOCK)
|
|
|
|
{
|
|
|
|
wal->addxpan(-t / 4096.f);
|
|
|
|
wal->addypan(-t / 4096.f);
|
|
|
|
|
|
|
|
if (wal->extra == 1)
|
|
|
|
{
|
|
|
|
wal->extra = 0;
|
|
|
|
animwall[p].tag = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
animwall[p].tag += 128;
|
|
|
|
|
|
|
|
if (animwall[p].tag < (128 << 4))
|
|
|
|
{
|
|
|
|
if (animwall[p].tag & 128)
|
|
|
|
wal->setovertexture(ff1);
|
|
|
|
else wal->setovertexture(ff2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((krand() & 255) < 32)
|
|
|
|
animwall[p].tag = 128 << (krand() & 3);
|
|
|
|
else wal->setovertexture(ff2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-12-11 14:42:33 +00:00
|
|
|
|
2020-05-10 10:42:47 +00:00
|
|
|
END_DUKE_NS
|