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 };
|
|
|
|
|
2020-05-10 10:42:47 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
static bool haltsoundhack;
|
|
|
|
|
2020-10-23 15:38:49 +00:00
|
|
|
int callsound(int sn, DDukeActor* whatsprite)
|
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
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
auto si = act->s;
|
2020-10-14 19:40:15 +00:00
|
|
|
if (si->picnum == MUSICANDSFX && si->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
|
|
|
|
2020-10-14 19:40:15 +00:00
|
|
|
int snum = si->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.
|
2020-10-14 19:40:15 +00:00
|
|
|
bool hival = S_IsSoundValid(si->hitag);
|
2020-10-23 15:38:49 +00:00
|
|
|
if (act->temp_data[0] == 1 && !hival)
|
2020-08-01 09:56:02 +00:00
|
|
|
{
|
2020-10-23 15:38:49 +00:00
|
|
|
if (!S_CheckActorSoundPlaying(act->temp_actor, snum))
|
|
|
|
act->temp_data[0] = 0;
|
2020-08-01 09:56:02 +00:00
|
|
|
}
|
|
|
|
|
2020-10-23 15:38:49 +00:00
|
|
|
if (act->temp_data[0] == 0)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
if ((flags & (SF_GLOBAL | SF_DTAG)) != SF_GLOBAL)
|
|
|
|
{
|
|
|
|
if (snum)
|
|
|
|
{
|
2020-10-14 19:40:15 +00:00
|
|
|
if (si->hitag && snum != si->hitag)
|
2020-10-23 15:38:49 +00:00
|
|
|
S_StopSound(si->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-11-06 12:47:06 +00:00
|
|
|
if ((si->sector()->lotag & 0xff) != ST_22_SPLITTING_DOOR)
|
2020-10-23 15:38:49 +00:00
|
|
|
act->temp_data[0] = 1;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-14 19:40:15 +00:00
|
|
|
else if (si->hitag < 1000)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2020-10-14 19:40:15 +00:00
|
|
|
if ((flags & SF_LOOP) || (si->hitag && si->hitag != si->lotag))
|
2020-10-23 15:38:49 +00:00
|
|
|
S_StopSound(si->lotag, act->temp_actor);
|
2020-10-14 19:40:15 +00:00
|
|
|
if (si->hitag) S_PlayActorSound(si->hitag, whatsprite);
|
2020-10-23 15:38:49 +00:00
|
|
|
act->temp_data[0] = 0;
|
|
|
|
act->temp_actor = whatsprite;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-10-14 19:40:15 +00:00
|
|
|
return si->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-04-15 17:21:43 +00:00
|
|
|
if (act->s->lotag == lotag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2020-10-23 15:40:58 +00:00
|
|
|
for (int j = animatecnt - 1; j >= 0; j--)
|
2021-04-15 17:21:43 +00:00
|
|
|
if (act->s->sectnum == animatesect[j])
|
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-04-15 17:21:43 +00:00
|
|
|
if (act->s->sectnum == act2->s->sectnum)
|
|
|
|
switch (act2->s->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:
|
2020-10-23 15:40:58 +00:00
|
|
|
if (act2->temp_data[0])
|
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
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-23 15:44:45 +00:00
|
|
|
int findplayer(const DDukeActor* actor, int* 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
|
|
|
int x, closest;
|
2021-04-15 17:21:43 +00:00
|
|
|
auto s = &actor->s->pos;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
|
|
|
if (ud.multimode < 2)
|
|
|
|
{
|
|
|
|
if (d) *d = abs(ps[myconnectindex].oposx - s->x) + abs(ps[myconnectindex].oposy - s->y) + ((abs(ps[myconnectindex].oposz - s->z + (28 << 8))) >> 4);
|
|
|
|
return myconnectindex;
|
|
|
|
}
|
|
|
|
|
|
|
|
closest = 0x7fffffff;
|
|
|
|
closest_player = 0;
|
|
|
|
|
|
|
|
for (j = connecthead; j >= 0; j = connectpoint2[j])
|
|
|
|
{
|
|
|
|
x = abs(ps[j].oposx - s->x) + abs(ps[j].oposy - s->y) + ((abs(ps[j].oposz - s->z + (28 << 8))) >> 4);
|
2021-04-15 17:21:43 +00:00
|
|
|
if (x < closest && ps[j].GetActor()->s->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
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int findotherplayer(int p, int* d)
|
|
|
|
{
|
2021-11-07 13:55:28 +00:00
|
|
|
int j, closest_player;
|
2020-05-12 11:43:24 +00:00
|
|
|
int x, closest;
|
|
|
|
|
|
|
|
closest = 0x7fffffff;
|
|
|
|
closest_player = p;
|
|
|
|
|
|
|
|
for (j = connecthead; j >= 0; j = connectpoint2[j])
|
2021-04-15 17:21:43 +00:00
|
|
|
if (p != j && ps[j].GetActor()->s->extra > 0)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-10-31 06:52:52 +00:00
|
|
|
x = abs(ps[j].oposx - ps[p].pos.x) + abs(ps[j].oposy - ps[p].pos.y) + (abs(ps[j].oposz - ps[p].pos.z) >> 4);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-07-20 18:40:29 +00:00
|
|
|
int* animateptr(int type, int index)
|
|
|
|
{
|
|
|
|
static int scratch;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case anim_floorz:
|
|
|
|
return §or[index].floorz;
|
|
|
|
case anim_ceilingz:
|
|
|
|
return §or[index].ceilingz;
|
|
|
|
case anim_vertexx:
|
|
|
|
return &wall[index].x;
|
|
|
|
case anim_vertexy:
|
|
|
|
return &wall[index].y;
|
|
|
|
default:
|
|
|
|
assert(false);
|
|
|
|
return &scratch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int* animateptr(int i)
|
|
|
|
{
|
|
|
|
return animateptr(animatetype[i], animatetarget[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-05-10 14:53:09 +00:00
|
|
|
void doanimations(void)
|
|
|
|
{
|
2020-10-23 15:40:58 +00:00
|
|
|
int i, a, p, v, dasect;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
|
|
|
for (i = animatecnt - 1; i >= 0; i--)
|
|
|
|
{
|
2020-07-20 18:40:29 +00:00
|
|
|
a = *animateptr(i);
|
2020-05-12 11:43:24 +00:00
|
|
|
v = animatevel[i] * TICSPERFRAME;
|
|
|
|
dasect = animatesect[i];
|
|
|
|
|
|
|
|
if (a == animategoal[i])
|
|
|
|
{
|
2020-11-26 15:03:40 +00:00
|
|
|
StopInterpolation(animatetarget[i], interptype[animatetype[i]]);
|
2020-05-12 11:43:24 +00:00
|
|
|
|
|
|
|
animatecnt--;
|
2020-07-20 18:40:29 +00:00
|
|
|
animatetype[i] = animatetype[animatecnt];
|
|
|
|
animatetarget[i] = animatetarget[animatecnt];
|
2020-05-12 11:43:24 +00:00
|
|
|
animategoal[i] = animategoal[animatecnt];
|
|
|
|
animatevel[i] = animatevel[animatecnt];
|
|
|
|
animatesect[i] = animatesect[animatecnt];
|
|
|
|
if (sector[animatesect[i]].lotag == ST_18_ELEVATOR_DOWN || sector[animatesect[i]].lotag == ST_19_ELEVATOR_UP)
|
2020-07-20 18:40:29 +00:00
|
|
|
if (animatetype[i] == anim_ceilingz)
|
2020-05-12 11:43:24 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((sector[dasect].lotag & 0xff) != ST_22_SPLITTING_DOOR)
|
2020-11-02 22:06:20 +00:00
|
|
|
callsound(dasect, nullptr);
|
2020-05-12 11:43:24 +00:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v > 0) { a = min(a + v, animategoal[i]); }
|
|
|
|
else { a = max(a + v, animategoal[i]); }
|
|
|
|
|
2020-07-20 18:40:29 +00:00
|
|
|
if (animatetype[i] == anim_floorz)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
for (p = connecthead; p >= 0; p = connectpoint2[p])
|
|
|
|
if (ps[p].cursectnum == dasect)
|
2021-10-31 06:52:52 +00:00
|
|
|
if ((sector[dasect].floorz - ps[p].pos.z) < (64 << 8))
|
2020-10-23 15:40:58 +00:00
|
|
|
if (ps[p].GetActor()->GetOwner() != nullptr)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-10-31 06:52:52 +00:00
|
|
|
ps[p].pos.z += v;
|
2020-05-12 11:43:24 +00:00
|
|
|
ps[p].poszv = 0;
|
|
|
|
}
|
|
|
|
|
2020-10-23 15:40:58 +00:00
|
|
|
DukeSectIterator it(dasect);
|
|
|
|
while (auto act = it.Next())
|
2020-10-14 19:40:15 +00:00
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
if (act->s->statnum != STAT_EFFECTOR)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
act->s->backupz();
|
|
|
|
act->s->z += v;
|
2020-10-23 15:40:58 +00:00
|
|
|
act->floorz = sector[dasect].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
|
|
|
}
|
|
|
|
|
2020-07-20 18:40:29 +00:00
|
|
|
*animateptr(i) = a;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-05-10 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-07-20 18:40:29 +00:00
|
|
|
int getanimationgoal(int animtype, int animtarget)
|
2020-05-10 14:53:09 +00:00
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
int i, j;
|
|
|
|
|
|
|
|
j = -1;
|
|
|
|
for (i = animatecnt - 1; i >= 0; i--)
|
2020-07-20 18:40:29 +00:00
|
|
|
if (animtype == animatetype[i] && animtarget == animatetarget[i])
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
j = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(j);
|
2020-05-10 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-07 08:47:57 +00:00
|
|
|
int setanimation(int animsect, int animtype, int animtarget, int thegoal, int thevel)
|
2020-05-10 14:53:09 +00:00
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
int i, j;
|
2020-05-10 14:53:09 +00:00
|
|
|
|
2020-05-12 11:43:24 +00:00
|
|
|
if (animatecnt >= MAXANIMATES - 1)
|
|
|
|
return(-1);
|
2020-05-10 14:53:09 +00:00
|
|
|
|
2020-05-12 11:43:24 +00:00
|
|
|
j = animatecnt;
|
|
|
|
for (i = 0; i < animatecnt; i++)
|
2020-07-20 18:40:29 +00:00
|
|
|
if (animtype == animatetype[i] && animtarget == animatetarget[i])
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
j = i;
|
|
|
|
break;
|
|
|
|
}
|
2020-05-10 14:53:09 +00:00
|
|
|
|
2020-07-20 18:40:29 +00:00
|
|
|
auto animptr = animateptr(animtype, animtarget);
|
2020-05-12 11:43:24 +00:00
|
|
|
animatesect[j] = animsect;
|
2020-07-20 18:40:29 +00:00
|
|
|
animatetype[j] = animtype;
|
|
|
|
animatetarget[j] = animtarget;
|
2020-05-12 11:43:24 +00:00
|
|
|
animategoal[j] = thegoal;
|
|
|
|
if (thegoal >= *animptr)
|
|
|
|
animatevel[j] = thevel;
|
|
|
|
else
|
|
|
|
animatevel[j] = -thevel;
|
2020-05-10 14:53:09 +00:00
|
|
|
|
2020-05-12 11:43:24 +00:00
|
|
|
if (j == animatecnt) animatecnt++;
|
2020-05-10 14:53:09 +00:00
|
|
|
|
2020-11-26 15:03:40 +00:00
|
|
|
StartInterpolation(animatetarget[i], interptype[animatetype[i]]);
|
2020-05-12 11:43:24 +00:00
|
|
|
return(j);
|
2020-05-10 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 23:35:47 +00:00
|
|
|
int setanimation(int animsect, int animtype, walltype* animtarget, int thegoal, int thevel)
|
|
|
|
{
|
|
|
|
assert(animtype == anim_vertexx || animtype == anim_vertexy);
|
|
|
|
return setanimation(animsect, animtype, wallnum(animtarget), thegoal, thevel);
|
|
|
|
}
|
2020-05-10 14:53:09 +00:00
|
|
|
|
2021-11-18 17:35:59 +00:00
|
|
|
int setanimation(int animsect, int animtype, sectortype* animtarget, int thegoal, int thevel)
|
|
|
|
{
|
|
|
|
assert(animtype == anim_ceilingz || animtype == anim_floorz);
|
|
|
|
return setanimation(animsect, animtype, sectnum(animtarget), thegoal, thevel);
|
|
|
|
}
|
|
|
|
|
|
|
|
int setanimation(sectortype* animsect, int animtype, walltype* animtarget, int thegoal, int thevel)
|
|
|
|
{
|
|
|
|
assert(animtype == anim_vertexx || animtype == anim_vertexy);
|
|
|
|
return setanimation(sectnum(animsect), animtype, wallnum(animtarget), thegoal, thevel);
|
|
|
|
}
|
|
|
|
|
|
|
|
int setanimation(sectortype* animsect, int animtype, sectortype* animtarget, int thegoal, int thevel)
|
|
|
|
{
|
|
|
|
assert(animtype == anim_ceilingz || animtype == anim_floorz);
|
|
|
|
return setanimation(sectnum(animsect), animtype, sectnum(animtarget), thegoal, thevel);
|
|
|
|
}
|
|
|
|
|
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-11-17 23:50:33 +00:00
|
|
|
auto sect = actor->s->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-04-15 17:21:43 +00:00
|
|
|
if (act2->s->lotag == SE_17_WARP_ELEVATOR || (isRRRA() && act2->s->lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL))
|
|
|
|
if (act2->s->hitag == actor->s->hitag)
|
2021-11-17 23:50:33 +00:00
|
|
|
if ((abs(sect->floorz - actor->temp_data[2]) > act2->s->yvel) ||
|
|
|
|
(act2->getSector()->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-04-15 17:21:43 +00:00
|
|
|
if (act2->s->lotag == SE_17_WARP_ELEVATOR || (isRRRA() && act2->s->lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL))
|
|
|
|
if (act2->s->hitag == actor->s->hitag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2020-10-23 15:46:46 +00:00
|
|
|
act2->temp_data[0] = d;
|
|
|
|
act2->temp_data[1] = d; //Make all check warp
|
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
|
|
|
{
|
2020-10-23 17:05:42 +00:00
|
|
|
int dax, day, dax2, day2, sp;
|
2021-11-17 21:49:27 +00:00
|
|
|
walltype* wallfind[2];
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
sp = sptr->extra >> 4;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//first find center point by averaging all points
|
|
|
|
dax = 0L, day = 0L;
|
2021-11-17 21:49:27 +00:00
|
|
|
for (auto& wal : wallsofsector(sptr))
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2021-11-17 21:49:27 +00:00
|
|
|
dax += wal.x;
|
|
|
|
day += wal.y;
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
2021-11-17 21:49:27 +00:00
|
|
|
dax /= sptr->wallnum;
|
|
|
|
day /= sptr->wallnum;
|
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;
|
|
|
|
for (auto& wal : wallsofsector(sptr))
|
|
|
|
if ((wal.x == dax) || (wal.y == day))
|
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];
|
|
|
|
|
|
|
|
//find what direction door should open by averaging the
|
|
|
|
// 2 neighboring points of wallfind[0] & wallfind[1].
|
|
|
|
auto prevwall = wal - 1;
|
|
|
|
if (prevwall < sptr->firstWall()) prevwall += sptr->wallnum;
|
|
|
|
|
|
|
|
if ((wal->x == dax) && (wal->y == day))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-17 21:49:27 +00:00
|
|
|
dax2 = ((prevwall->x + wal->point2Wall()->x) >> 1) - wal->x;
|
|
|
|
day2 = ((prevwall->y + wal->point2Wall()->y) >> 1) - wal->y;
|
2020-10-23 17:05:42 +00:00
|
|
|
if (dax2 != 0)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-17 21:49:27 +00:00
|
|
|
dax2 = wal->point2Wall()->point2Wall()->x;
|
|
|
|
dax2 -= wal->point2Wall()->x;
|
2021-11-18 17:35:59 +00:00
|
|
|
setanimation(sptr, anim_vertexx, wal, wal->x + dax2, sp);
|
|
|
|
setanimation(sptr, anim_vertexx, prevwall, prevwall->x + dax2, sp);
|
|
|
|
setanimation(sptr, anim_vertexx, wal->point2Wall(), wal->point2Wall()->x + 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)
|
|
|
|
{
|
2021-11-17 21:49:27 +00:00
|
|
|
day2 = wal->point2Wall()->point2Wall()->y;
|
|
|
|
day2 -= wal->point2Wall()->y;
|
2021-11-18 17:35:59 +00:00
|
|
|
setanimation(sptr, anim_vertexy, wal, wal->y + day2, sp);
|
|
|
|
setanimation(sptr, anim_vertexy, prevwall, prevwall->y + day2, sp);
|
|
|
|
setanimation(sptr, anim_vertexy, wal->point2Wall(), wal->point2Wall()->y + day2, sp);
|
|
|
|
callsound(sptr, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-17 21:49:27 +00:00
|
|
|
dax2 = ((prevwall->x + wal->point2Wall()->x) >> 1) - wal->x;
|
|
|
|
day2 = ((prevwall->y + wal->point2Wall()->y) >> 1) - wal->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
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
static void handle_st15(int sn, DDukeActor* actor)
|
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
if (actor->s->picnum != TILE_APLAYER) return;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
sectortype* sptr = §or[sn];
|
2020-10-23 17:08:11 +00:00
|
|
|
DukeSectIterator it(sn);
|
|
|
|
DDukeActor* a2;
|
|
|
|
while ((a2 = it.Next()))
|
2020-10-23 17:05:42 +00:00
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
if (a2->s->picnum == SECTOREFFECTOR && a2->s->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-04-15 17:21:43 +00:00
|
|
|
if (actor->s->sectnum == sn)
|
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
|
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
if (sptr->floorz > a2->s->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
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
static void handle_st16(int sn, DDukeActor* actor)
|
|
|
|
{
|
|
|
|
sectortype* sptr = §or[sn];
|
|
|
|
int i = getanimationgoal(anim_floorz, sn);
|
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)
|
|
|
|
{
|
2021-11-17 23:29:46 +00:00
|
|
|
sectp = nextsectorneighborzptr(sptr, sptr->floorz, 1, 1);
|
|
|
|
if (sectp == nullptr)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-17 23:29:46 +00:00
|
|
|
sectp = nextsectorneighborzptr(sptr, sptr->floorz, 1, -1);
|
|
|
|
if (sectp == nullptr) return;
|
|
|
|
setanimation(sn, anim_floorz, sn, sectp->floorz, sptr->extra);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-10-23 17:05:42 +00:00
|
|
|
else
|
|
|
|
{
|
2021-11-17 23:29:46 +00:00
|
|
|
setanimation(sn, anim_floorz, sn, sectp->floorz, sptr->extra);
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
callsound(sn, actor);
|
|
|
|
}
|
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static void handle_st18(int sn, DDukeActor* actor)
|
|
|
|
{
|
|
|
|
sectortype* sptr = §or[sn];
|
|
|
|
int i = getanimationgoal(anim_floorz, sn);
|
|
|
|
|
|
|
|
if (i == -1)
|
2020-10-14 21:28:36 +00:00
|
|
|
{
|
2021-11-17 23:29:46 +00:00
|
|
|
auto sectp = nextsectorneighborzptr(sptr, sptr->floorz, 1, -1);
|
2021-11-19 10:21:10 +00:00
|
|
|
if (sectp == nullptr) sectp = nextsectorneighborzptr(sptr, sptr->floorz, 1, 1);
|
2021-11-17 23:29:46 +00:00
|
|
|
if (sectp == nullptr) return;
|
|
|
|
int j = sectp->floorz;
|
2020-10-23 17:05:42 +00:00
|
|
|
int q = sptr->extra;
|
|
|
|
int l = sptr->ceilingz - sptr->floorz;
|
|
|
|
setanimation(sn, anim_floorz, sn, j, q);
|
|
|
|
setanimation(sn, anim_ceilingz, sn, j + l, q);
|
|
|
|
callsound(sn, actor);
|
|
|
|
}
|
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static void handle_st29(int sn, DDukeActor* actor)
|
|
|
|
{
|
|
|
|
sectortype* sptr = §or[sn];
|
2020-10-23 17:09:27 +00:00
|
|
|
int j;
|
2020-10-23 17:05:42 +00:00
|
|
|
|
|
|
|
if (sptr->lotag & 0x8000)
|
2021-11-17 23:29:46 +00:00
|
|
|
j = nextsectorneighborzptr(sptr, sptr->ceilingz, 1, 1)->floorz;
|
2020-10-23 17:05:42 +00:00
|
|
|
else
|
2021-11-17 23:29:46 +00:00
|
|
|
j = nextsectorneighborzptr(sn, sptr->ceilingz, -1, -1)->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-04-15 17:21:43 +00:00
|
|
|
if ((act2->s->lotag == 22) &&
|
|
|
|
(act2->s->hitag == sptr->hitag))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-06 12:47:06 +00:00
|
|
|
act2->getSector()->extra = -act2->getSector()->extra;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:09:27 +00:00
|
|
|
act2->temp_data[0] = sn;
|
|
|
|
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
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
setanimation(sn, anim_ceilingz, sn, j, sptr->extra);
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
callsound(sn, actor);
|
|
|
|
}
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static void handle_st20(int sn, DDukeActor* actor)
|
|
|
|
{
|
|
|
|
sectortype* sptr = §or[sn];
|
2021-11-14 14:03:50 +00:00
|
|
|
int 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;
|
|
|
|
DukeSectIterator it(sn);
|
|
|
|
while ((a2 = it.Next()))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
if (a2->s->statnum == 3 && a2->s->lotag == 9)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
j = a2->s->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)
|
2020-10-23 17:05:42 +00:00
|
|
|
j = sptr->floorz;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-17 23:29:46 +00:00
|
|
|
auto sectp = nextsectorneighborzptr(sptr, sptr->ceilingz, -1, -1);
|
2020-10-23 17:05:42 +00:00
|
|
|
|
2021-11-17 23:29:46 +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
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
setanimation(sn, anim_ceilingz, sn, j, sptr->extra);
|
|
|
|
callsound(sn, 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
|
|
|
static void handle_st21(int sn, DDukeActor* actor)
|
|
|
|
{
|
|
|
|
sectortype* sptr = §or[sn];
|
|
|
|
int i = getanimationgoal(anim_floorz, sn);
|
|
|
|
int j;
|
|
|
|
if (i >= 0)
|
|
|
|
{
|
2021-04-04 22:14:15 +00:00
|
|
|
if (animategoal[i] == sptr->ceilingz)
|
2021-11-17 23:29:46 +00:00
|
|
|
animategoal[i] = nextsectorneighborzptr(sptr, sptr->ceilingz, 1, 1)->floorz;
|
2020-10-23 17:05:42 +00:00
|
|
|
else animategoal[i] = sptr->ceilingz;
|
|
|
|
j = animategoal[i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sptr->ceilingz == sptr->floorz)
|
2021-11-17 23:29:46 +00:00
|
|
|
j = nextsectorneighborzptr(sn, sptr->ceilingz, 1, 1)->floorz;
|
2020-10-23 17:05:42 +00:00
|
|
|
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
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
if (setanimation(sn, anim_floorz, sn, j, sptr->extra) >= 0)
|
|
|
|
callsound(sn, 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
|
|
|
static void handle_st22(int sn, DDukeActor* actor)
|
|
|
|
{
|
|
|
|
sectortype* sptr = §or[sn];
|
|
|
|
int j, q;
|
|
|
|
if ((sptr->lotag & 0x8000))
|
|
|
|
{
|
|
|
|
q = (sptr->ceilingz + sptr->floorz) >> 1;
|
|
|
|
j = setanimation(sn, anim_floorz, sn, q, sptr->extra);
|
|
|
|
j = setanimation(sn, anim_ceilingz, sn, q, sptr->extra);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-17 23:29:46 +00:00
|
|
|
q = nextsectorneighborzptr(sptr, sptr->floorz, 1, 1)->floorz;
|
2020-10-23 17:05:42 +00:00
|
|
|
j = setanimation(sn, anim_floorz, sn, q, sptr->extra);
|
2021-11-17 23:29:46 +00:00
|
|
|
q = nextsectorneighborzptr(sptr, sptr->ceilingz, -1, -1)->ceilingz;
|
2020-10-23 17:05:42 +00:00
|
|
|
j = setanimation(sn, anim_ceilingz, sn, q, sptr->extra);
|
|
|
|
}
|
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
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
callsound(sn, 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
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
static void handle_st23(int sn, DDukeActor* actor)
|
|
|
|
{
|
|
|
|
int q = 0;
|
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-04-15 17:21:43 +00:00
|
|
|
if (act2->s->lotag == SE_11_SWINGING_DOOR && act2->s->sectnum == sn && !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-06 12:47:06 +00:00
|
|
|
int l = act2->getSector()->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
|
|
|
{
|
2020-10-23 17:15:18 +00:00
|
|
|
DukeStatIterator it(STAT_EFFECTOR);
|
2021-01-03 04:44:57 +00:00
|
|
|
|
|
|
|
while (auto act3 = it.Next())
|
|
|
|
{
|
2021-11-06 12:47:06 +00:00
|
|
|
if (l == (act3->getSector()->lotag & 0x8000) && act3->s->lotag == SE_11_SWINGING_DOOR && act2->s->hitag == act3->s->hitag && act3->temp_data[4])
|
2021-01-03 04:44:57 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
it.Reset(STAT_EFFECTOR);
|
2020-10-23 17:15:18 +00:00
|
|
|
while (auto act3 = it.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-06 12:47:06 +00:00
|
|
|
if (l == (act3->getSector()->lotag & 0x8000) && act3->s->lotag == SE_11_SWINGING_DOOR && act2->s->hitag == act3->s->hitag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-06 12:47:06 +00:00
|
|
|
if (act3->getSector()->lotag & 0x8000) act3->getSector()->lotag &= 0x7fff;
|
|
|
|
else act3->getSector()->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
|
|
|
{
|
2020-10-23 17:15:18 +00:00
|
|
|
callsound(sn, 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
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static void handle_st25(int sn, DDukeActor* actor)
|
|
|
|
{
|
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-04-15 17:21:43 +00:00
|
|
|
if (act2->s->lotag == 15 && act2->s->sectnum == sn)
|
2020-10-23 17:16:39 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2020-10-23 17:05:42 +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-04-15 17:21:43 +00:00
|
|
|
if (act3->s->hitag == act2->s->hitag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
if (act3->s->lotag == 15)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-06 12:47:06 +00:00
|
|
|
act3->getSector()->lotag ^= 0x8000; // Toggle the open or close
|
2021-04-15 17:21:43 +00:00
|
|
|
act3->s->ang += 1024;
|
|
|
|
if (act3->temp_data[4]) callsound(act3->s->sectnum, act3);
|
|
|
|
callsound(act3->s->sectnum, act3);
|
2021-11-06 12:47:06 +00:00
|
|
|
if (act3->getSector()->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
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static void handle_st27(int sn, DDukeActor* actor)
|
|
|
|
{
|
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-04-15 17:21:43 +00:00
|
|
|
if ((act2->s->lotag & 0xff) == 20 && act2->s->sectnum == sn) //Bridge
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
|
2020-10-23 17:05:42 +00:00
|
|
|
sector[sn].lotag ^= 0x8000;
|
|
|
|
if (sector[sn].lotag & 0x8000) //OPENING
|
2020-10-23 17:17:30 +00:00
|
|
|
act2->temp_data[0] = 1;
|
|
|
|
else act2->temp_data[0] = 2;
|
2020-10-23 17:05:42 +00:00
|
|
|
callsound(sn, actor);
|
|
|
|
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
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static void handle_st28(int sn, DDukeActor* actor)
|
|
|
|
{
|
|
|
|
//activate the rest of them
|
2020-10-23 17:19:30 +00:00
|
|
|
int j = -1;
|
|
|
|
DukeSectIterator it(sn);
|
|
|
|
while (auto a2 = it.Next())
|
2020-10-14 19:40:15 +00:00
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
if (a2->s->statnum == 3 && (a2->s->lotag & 0xff) == 21)
|
2020-10-23 17:19:30 +00:00
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
j = a2->s->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
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
if ((act3->s->lotag & 0xff) == 21 && !act3->temp_data[0] &&
|
|
|
|
(act3->s->hitag) == j)
|
2020-10-23 17:19:30 +00:00
|
|
|
act3->temp_data[0] = 1;
|
2020-10-23 17:05:42 +00:00
|
|
|
}
|
|
|
|
callsound(sn, actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-23 17:35:59 +00:00
|
|
|
void operatesectors(int sn, 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;
|
|
|
|
sectortype* sptr;
|
|
|
|
|
|
|
|
sptr = §or[sn];
|
|
|
|
|
|
|
|
switch (sptr->lotag & (0x3fff))
|
|
|
|
{
|
|
|
|
|
|
|
|
case 41:
|
|
|
|
if (isRR()) operatejaildoors(sptr->hitag);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
if (!isRR()) break;
|
2021-11-17 21:50:56 +00:00
|
|
|
for (auto& wal : wallsofsector(sptr))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-17 23:35:47 +00:00
|
|
|
setanimation(sn, anim_vertexx, &wal, wal.x + 1024, 4);
|
|
|
|
if (wal.nextwall >= 0) setanimation(sn, anim_vertexx, wal.nextwall, wal.nextWall()->x + 1024, 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-11-07 15:46:23 +00:00
|
|
|
auto act = ScriptIndexToActor(sptr->hitag);
|
2020-11-04 18:15:44 +00:00
|
|
|
if (!act) break;
|
2020-10-23 17:20:46 +00:00
|
|
|
if (act->tempang == 0 || act->tempang == 256) callsound(sn, actor);
|
2021-04-15 17:21:43 +00:00
|
|
|
if (act->s->extra == 1) act->s->extra = 3;
|
|
|
|
else act->s->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-11-07 15:46:23 +00:00
|
|
|
auto act = ScriptIndexToActor(sptr->hitag);
|
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
|
|
|
|
2020-10-23 17:20:46 +00:00
|
|
|
callsound(sn, 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
|
|
|
|
i = getanimationgoal(anim_ceilingz, sn);
|
|
|
|
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;
|
2020-10-23 17:20:46 +00:00
|
|
|
operatesectors(sn, actor);
|
2020-10-23 17:05:42 +00:00
|
|
|
sptr->lotag &= 0xff00;
|
|
|
|
sptr->lotag |= ST_9_SLIDING_ST_DOOR;
|
2020-10-23 17:20:46 +00:00
|
|
|
operatesectors(sn, 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
|
|
|
|
handle_st15(sn, actor);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_16_PLATFORM_DOWN:
|
|
|
|
case ST_17_PLATFORM_UP:
|
|
|
|
handle_st16(sn, actor);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_18_ELEVATOR_DOWN:
|
|
|
|
case ST_19_ELEVATOR_UP:
|
|
|
|
handle_st18(sn, actor);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_29_TEETH_DOOR:
|
|
|
|
handle_st29(sn, actor);
|
|
|
|
return;
|
|
|
|
case ST_20_CEILING_DOOR:
|
|
|
|
handle_st20(sn, actor);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_21_FLOOR_DOOR:
|
|
|
|
handle_st21(sn, actor);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_22_SPLITTING_DOOR:
|
|
|
|
handle_st22(sn, actor);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_23_SWINGING_DOOR: //Swingdoor
|
|
|
|
handle_st23(sn, actor);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_25_SLIDING_DOOR: //Subway type sliding doors
|
|
|
|
{
|
|
|
|
handle_st25(sn, 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
|
|
|
|
handle_st27(sn, actor);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ST_28_DROP_FLOOR:
|
|
|
|
handle_st28(sn, actor);
|
|
|
|
return;
|
2020-10-14 19:40:15 +00:00
|
|
|
}
|
2020-05-10 14:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-23 17:35:59 +00:00
|
|
|
void operateactivators(int low, int plnum)
|
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;
|
|
|
|
|
|
|
|
for (i = numcyclers - 1; i >= 0; i--)
|
|
|
|
{
|
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-06 20:53:15 +00:00
|
|
|
auto sect = p->sector();
|
|
|
|
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;
|
2021-11-07 07:46:15 +00:00
|
|
|
wal = sect->firstWall();
|
2021-11-06 20:53:15 +00:00
|
|
|
for (j = sect->wallnum; j > 0; j--, wal++)
|
|
|
|
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-04-15 17:21:43 +00:00
|
|
|
if (act->s->lotag == low)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
if (act->s->picnum == ACTIVATORLOCKED)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-06 12:47:06 +00:00
|
|
|
act->getSector()->lotag ^= 16384;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2020-10-23 17:35:59 +00:00
|
|
|
if (plnum >= 0)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-06 12:47:06 +00:00
|
|
|
if (act->getSector()->lotag & 16384)
|
2020-10-23 17:35:59 +00:00
|
|
|
FTA(4, &ps[plnum]);
|
|
|
|
else FTA(8, &ps[plnum]);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
switch (act->s->hitag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-11-06 12:47:06 +00:00
|
|
|
if (act->getSector()->floorz != act->getSector()->ceilingz)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-11-06 12:47:06 +00:00
|
|
|
if (act->getSector()->floorz == act->getSector()->ceilingz)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-11-06 12:47:06 +00:00
|
|
|
if (act->getSector()->lotag < 3)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
DukeSectIterator it(act->s->sectnum);
|
2020-10-23 17:35:59 +00:00
|
|
|
while (auto a2 = it.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
if (a2->s->statnum == 3) switch (a2->s->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:
|
2020-10-23 17:35:59 +00:00
|
|
|
a2->temp_data[0] = 1 - a2->temp_data[0];
|
2021-04-15 17:21:43 +00:00
|
|
|
callsound(act->s->sectnum, a2);
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-06 12:47:06 +00:00
|
|
|
if (k == -1 && (act->getSector()->lotag & 0xff) == 22)
|
2021-04-15 17:21:43 +00:00
|
|
|
k = callsound(act->s->sectnum, act);
|
2020-05-12 11:43:24 +00:00
|
|
|
|
2021-04-15 17:21:43 +00:00
|
|
|
operatesectors(act->s->sectnum, act);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:14:03 +00:00
|
|
|
fi.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
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
if (act2->s->picnum == MASTERSWITCH && act2->s->lotag == low && act2->s->yvel == 0)
|
|
|
|
act2->s->yvel = 1;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-05-10 16:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-23 18:02:57 +00:00
|
|
|
void operateforcefields_common(DDukeActor *effector, int low, const std::initializer_list<int> &tiles)
|
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)
|
|
|
|
if (isIn(wal->overpicnum, tiles))
|
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
|
|
|
|
2021-04-15 17:21:43 +00:00
|
|
|
if (effector && effector->s->picnum == SECTOREFFECTOR && effector->s->lotag == 30)
|
2021-11-17 21:50:56 +00:00
|
|
|
wal->lotag = 0;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
else
|
2021-11-17 21:50:56 +00:00
|
|
|
wal->cstat = 85;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-10 16:05:36 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 18:59:38 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-17 23:32:46 +00:00
|
|
|
void breakwall(int newpn, DDukeActor* spr, walltype* wal)
|
2020-05-10 18:59:38 +00:00
|
|
|
{
|
2021-11-17 23:32:46 +00:00
|
|
|
wal->picnum = newpn;
|
2020-07-25 07:32:54 +00:00
|
|
|
S_PlayActorSound(VENT_BUST, spr);
|
|
|
|
S_PlayActorSound(GLASS_HEAVYBREAK, spr);
|
2021-11-17 23:38:20 +00:00
|
|
|
lotsofglass(spr, wal, 10);
|
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-04-15 17:21:43 +00:00
|
|
|
if (act->s->lotag == SE_17_WARP_ELEVATOR && act->s->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-04-15 17:21:43 +00:00
|
|
|
if ((act2->s->lotag) == SE_17_WARP_ELEVATOR && act != act2 && act->s->hitag == act2->s->hitag)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-06 12:47:06 +00:00
|
|
|
act2->getSector()->floorz = act->getSector()->floorz;
|
|
|
|
act2->getSector()->ceilingz = act->getSector()->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
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-08-31 17:22:21 +00:00
|
|
|
void moveclouds(double smoothratio)
|
2020-07-06 00:05:31 +00:00
|
|
|
{
|
2020-10-23 17:05:42 +00:00
|
|
|
// The math here is very messy.. :(
|
2021-02-18 10:46:36 +00:00
|
|
|
int myclock = smoothratio < 32768? 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.
|
2021-05-12 15:57:36 +00:00
|
|
|
cloudx += (float)ps[screenpeek].angle.ang.fcos() * 0.5f;
|
|
|
|
cloudy += (float)ps[screenpeek].angle.ang.fsin() * 0.5f;
|
2020-07-06 00:05:31 +00:00
|
|
|
for (int i = 0; i < numclouds; i++)
|
|
|
|
{
|
2021-04-04 18:35:38 +00:00
|
|
|
if (!testnewrenderer)
|
|
|
|
{
|
2021-11-17 23:04:52 +00:00
|
|
|
clouds[i]->setceilingxpan(cloudx);
|
|
|
|
clouds[i]->setceilingypan(cloudy);
|
2021-04-04 18:35:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// no clamping here!
|
2021-11-17 23:04:52 +00:00
|
|
|
clouds[i]->ceilingxpan_ = cloudx;
|
|
|
|
clouds[i]->ceilingypan_ = cloudy;
|
2021-04-04 18:35:38 +00:00
|
|
|
}
|
2021-11-17 23:04:52 +00:00
|
|
|
clouds[i]->exflags |= SECTOREX_CLOUDSCROLL;
|
2020-07-06 00:05:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-10 14:53:09 +00:00
|
|
|
|
2020-05-10 10:42:47 +00:00
|
|
|
|
|
|
|
END_DUKE_NS
|