2015-05-19 21:54:34 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1997, 2005 - 3D Realms Entertainment
|
|
|
|
|
|
|
|
This file is part of Shadow Warrior version 1.2
|
|
|
|
|
|
|
|
Shadow Warrior 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
Original Source: 1997 - Frank Maddin and Jim Norwood
|
|
|
|
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-10-09 16:09:05 +00:00
|
|
|
#include "ns.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "build.h"
|
|
|
|
|
|
|
|
#include "names2.h"
|
|
|
|
#include "panel.h"
|
2020-08-05 22:18:45 +00:00
|
|
|
#include "misc.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "tags.h"
|
|
|
|
#include "sector.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "weapon.h"
|
|
|
|
#include "jtags.h"
|
|
|
|
|
2019-03-21 02:24:19 +00:00
|
|
|
#include "network.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
#include "break.h"
|
2020-08-05 22:18:45 +00:00
|
|
|
#include "misc.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "sprite.h"
|
|
|
|
#include "light.h"
|
2019-12-09 20:19:05 +00:00
|
|
|
#include "gstrings.h"
|
|
|
|
#include "secrets.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
BEGIN_SW_NS
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
#define LAVASIZ 128
|
|
|
|
#define LAVALOGSIZ 7
|
|
|
|
#define LAVAMAXDROPS 32
|
|
|
|
#define DEFAULT_DOOR_SPEED 800
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SINE_FLOOR = (1 << 0),
|
|
|
|
SINE_CEILING = (1 << 1),
|
|
|
|
SINE_SLOPED = BIT(3),
|
|
|
|
};
|
|
|
|
|
2019-10-09 17:58:09 +00:00
|
|
|
ANIMATOR DoGrating;
|
|
|
|
void DoPlayerBeginForceJump(PLAYERp);
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
short FindNextSectorByTag(short sectnum, int tag);
|
|
|
|
short LevelSecrets;
|
2020-09-09 18:32:24 +00:00
|
|
|
bool TestVatorMatchActive(short match);
|
|
|
|
bool TestSpikeMatchActive(short match);
|
|
|
|
bool TestRotatorMatchActive(short match);
|
|
|
|
bool TestSlidorMatchActive(short match);
|
2021-11-05 21:43:59 +00:00
|
|
|
int PlayerCheckDeath(PLAYERp, DSWActor*);
|
2021-11-02 23:45:43 +00:00
|
|
|
void DoVatorOperate(PLAYERp, short);
|
|
|
|
void DoVatorMatch(PLAYERp pp, short match);
|
2021-11-02 18:53:03 +00:00
|
|
|
void DoRotatorOperate(PLAYERp, short);
|
|
|
|
void DoRotatorMatch(PLAYERp pp, short match, bool);
|
2021-11-02 21:37:33 +00:00
|
|
|
void DoSlidorOperate(PLAYERp, short);
|
|
|
|
void DoSlidorMatch(PLAYERp pp, short match, bool);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void KillMatchingCrackSprites(short match);
|
2015-05-19 21:54:34 +00:00
|
|
|
int DoTrapReset(short match);
|
|
|
|
int DoTrapMatch(short match);
|
|
|
|
|
|
|
|
PLAYERp GlobPlayerP;
|
|
|
|
|
2021-04-02 10:55:58 +00:00
|
|
|
TPointer<SECT_USER> SectUser[MAXSECTORS];
|
2021-04-02 09:13:33 +00:00
|
|
|
TPointer<USER> User[MAXSPRITES];
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ANIM Anim[MAXANIM];
|
|
|
|
short AnimCnt = 0;
|
|
|
|
|
|
|
|
SINE_WAVE_FLOOR SineWaveFloor[MAX_SINE_WAVE][21];
|
|
|
|
SINE_WALL SineWall[MAX_SINE_WALL][MAX_SINE_WALL_POINTS];
|
|
|
|
SPRING_BOARD SpringBoard[20];
|
|
|
|
|
2020-09-09 18:32:24 +00:00
|
|
|
void SetSectorWallBits(short sectnum, int bit_mask, bool set_sectwall, bool set_nextwall)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short wall_num, start_wall;
|
|
|
|
|
|
|
|
wall_num = start_wall = sector[sectnum].wallptr;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (set_sectwall)
|
|
|
|
SET(wall[wall_num].extra, bit_mask);
|
|
|
|
|
2019-11-27 07:33:34 +00:00
|
|
|
if (set_nextwall)
|
|
|
|
{
|
|
|
|
uint16_t const nextwall = wall[wall_num].nextwall;
|
2021-11-11 00:01:30 +00:00
|
|
|
if (validWallIndex(nextwall))
|
2019-11-27 07:33:34 +00:00
|
|
|
SET(wall[nextwall].extra, bit_mask);
|
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
wall_num = wall[wall_num].point2;
|
|
|
|
}
|
|
|
|
while (wall_num != start_wall);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void WallSetupDontMove(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SPRITEp spu, spl;
|
|
|
|
WALLp wallp;
|
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
SWStatIterator it(STAT_WALL_DONT_MOVE_UPPER);
|
|
|
|
while (auto iActor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
spu = &iActor->s();
|
|
|
|
SWStatIterator it1(STAT_WALL_DONT_MOVE_LOWER);
|
|
|
|
while (auto jActor = it1.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
spl = &jActor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (spu->lotag == spl->lotag)
|
|
|
|
{
|
2021-11-11 19:20:00 +00:00
|
|
|
for (wallp = &wall[0]; wallp < &wall[numwalls]; wallp++)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (wallp->x < spl->x && wallp->x > spu->x && wallp->y < spl->y && wallp->y > spu->y)
|
|
|
|
{
|
|
|
|
SET(wallp->extra, WALLFX_DONT_MOVE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-27 07:33:34 +00:00
|
|
|
static void WallSetupLoop(WALLp wp, int16_t lotag, int16_t extra)
|
|
|
|
{
|
|
|
|
// set first wall
|
|
|
|
{
|
|
|
|
SET(wp->extra, extra);
|
|
|
|
uint16_t const nextwall = wp->nextwall;
|
2021-11-11 00:01:30 +00:00
|
|
|
if (validWallIndex(nextwall))
|
2019-11-27 07:33:34 +00:00
|
|
|
SET(wall[nextwall].extra, extra);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Travel all the way around loop setting wall bits
|
|
|
|
for (uint16_t wall_num = wp->point2;
|
|
|
|
wall[wall_num].lotag != lotag;
|
|
|
|
wall_num = wall[wall_num].point2)
|
|
|
|
{
|
|
|
|
SET(wall[wall_num].extra, extra);
|
|
|
|
uint16_t const nextwall = wall[wall_num].nextwall;
|
2021-11-11 00:01:30 +00:00
|
|
|
if (validWallIndex(nextwall))
|
2019-11-27 07:33:34 +00:00
|
|
|
SET(wall[nextwall].extra, extra);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void WallSetup(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short NextSineWall = 0;
|
|
|
|
WALLp wp;
|
|
|
|
|
|
|
|
WallSetupDontMove();
|
|
|
|
|
|
|
|
memset(SineWall, -1, sizeof(SineWall));
|
|
|
|
|
2020-09-06 18:49:43 +00:00
|
|
|
extern int x_min_bound, y_min_bound, x_max_bound, y_max_bound;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-11 19:20:00 +00:00
|
|
|
for (wp = &wall[0]; wp < &wall[numwalls]; wp++)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (wp->picnum == FAF_PLACE_MIRROR_PIC)
|
|
|
|
wp->picnum = FAF_MIRROR_PIC;
|
|
|
|
|
2021-12-01 18:55:18 +00:00
|
|
|
if (wp->picnum == FAF_PLACE_MIRROR_PIC+1)
|
|
|
|
wp->picnum = FAF_MIRROR_PIC+1;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// this overwrites the lotag so it needs to be called LAST - its down there
|
|
|
|
// SetupWallForBreak(wp);
|
|
|
|
|
|
|
|
switch (wp->lotag)
|
|
|
|
{
|
|
|
|
case TAG_WALL_LOOP_DONT_SPIN:
|
|
|
|
{
|
2019-11-27 07:33:34 +00:00
|
|
|
WallSetupLoop(wp, TAG_WALL_LOOP_DONT_SPIN, WALLFX_LOOP_DONT_SPIN);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_WALL_LOOP_DONT_SCALE:
|
|
|
|
{
|
2019-11-27 07:33:34 +00:00
|
|
|
WallSetupLoop(wp, TAG_WALL_LOOP_DONT_SCALE, WALLFX_DONT_SCALE);
|
2015-05-19 21:54:34 +00:00
|
|
|
wp->lotag = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_WALL_LOOP_OUTER_SECONDARY:
|
|
|
|
{
|
2019-11-27 07:33:34 +00:00
|
|
|
// make sure it's a red wall
|
2021-11-11 00:01:30 +00:00
|
|
|
if (validWallIndex(wp->nextwall))
|
|
|
|
{
|
|
|
|
WallSetupLoop(wp, TAG_WALL_LOOP_OUTER_SECONDARY, WALLFX_LOOP_OUTER | WALLFX_LOOP_OUTER_SECONDARY);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-01 18:55:18 +00:00
|
|
|
Printf(PRINT_HIGH, "one-sided wall %d in loop setup\n", wallnum(wp));
|
2021-11-11 00:01:30 +00:00
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_WALL_LOOP_OUTER:
|
|
|
|
{
|
2019-11-27 07:33:34 +00:00
|
|
|
// make sure it's a red wall
|
2021-11-11 00:01:30 +00:00
|
|
|
if (validWallIndex(wp->nextwall))
|
|
|
|
{
|
|
|
|
WallSetupLoop(wp, TAG_WALL_LOOP_OUTER, WALLFX_LOOP_OUTER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-01 18:55:18 +00:00
|
|
|
Printf(PRINT_HIGH, "one-sided wall %d in loop setup\n", wallnum(wp));
|
2021-11-11 00:01:30 +00:00
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
wp->lotag = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_WALL_DONT_MOVE:
|
|
|
|
{
|
|
|
|
// set first wall
|
|
|
|
SET(wp->extra, WALLFX_DONT_MOVE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_WALL_LOOP_SPIN_2X:
|
|
|
|
{
|
2019-11-27 07:33:34 +00:00
|
|
|
WallSetupLoop(wp, TAG_WALL_LOOP_SPIN_2X, WALLFX_LOOP_SPIN_2X);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_WALL_LOOP_SPIN_4X:
|
|
|
|
{
|
2019-11-27 07:33:34 +00:00
|
|
|
WallSetupLoop(wp, TAG_WALL_LOOP_SPIN_4X, WALLFX_LOOP_SPIN_4X);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_WALL_LOOP_REVERSE_SPIN:
|
|
|
|
{
|
2019-11-27 07:33:34 +00:00
|
|
|
WallSetupLoop(wp, TAG_WALL_LOOP_REVERSE_SPIN, WALLFX_LOOP_REVERSE_SPIN);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_WALL_SINE_Y_BEGIN:
|
|
|
|
case TAG_WALL_SINE_X_BEGIN:
|
|
|
|
{
|
2020-03-06 15:49:49 +00:00
|
|
|
short wall_num, cnt, num_points, type, tag_end;
|
2015-05-19 21:54:34 +00:00
|
|
|
SINE_WALLp sw;
|
|
|
|
short range = 250, speed = 3, peak = 0;
|
|
|
|
|
|
|
|
tag_end = wp->lotag + 2;
|
|
|
|
|
|
|
|
type = wp->lotag - TAG_WALL_SINE_Y_BEGIN;
|
|
|
|
|
|
|
|
|
|
|
|
// count up num_points
|
2021-12-01 18:55:18 +00:00
|
|
|
for (wall_num = wallnum(wp), num_points = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
num_points < MAX_SINE_WALL_POINTS && wall[wall_num].lotag != tag_end;
|
|
|
|
wall_num = wall[wall_num].point2, num_points++)
|
|
|
|
{
|
|
|
|
if (num_points == 0)
|
|
|
|
{
|
|
|
|
if (wall[wall_num].hitag)
|
|
|
|
range = wall[wall_num].hitag;
|
|
|
|
}
|
|
|
|
else if (num_points == 1)
|
|
|
|
{
|
|
|
|
if (wall[wall_num].hitag)
|
|
|
|
speed = wall[wall_num].hitag;
|
|
|
|
}
|
|
|
|
else if (num_points == 2)
|
|
|
|
{
|
|
|
|
if (wall[wall_num].hitag)
|
|
|
|
peak = wall[wall_num].hitag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (peak)
|
|
|
|
num_points = peak;
|
|
|
|
|
2021-12-01 18:55:18 +00:00
|
|
|
for (wall_num = wallnum(wp), cnt = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
cnt < MAX_SINE_WALL_POINTS && wall[wall_num].lotag != tag_end;
|
|
|
|
wall_num = wall[wall_num].point2, cnt++)
|
|
|
|
{
|
|
|
|
// set the first on up
|
|
|
|
sw = &SineWall[NextSineWall][cnt];
|
|
|
|
|
|
|
|
sw->type = type;
|
|
|
|
sw->wall = wall_num;
|
|
|
|
sw->speed_shift = speed;
|
|
|
|
sw->range = range;
|
|
|
|
|
|
|
|
// don't allow bullet holes/stars
|
|
|
|
SET(wall[wall_num].extra, WALLFX_DONT_STICK);
|
|
|
|
|
|
|
|
if (!sw->type)
|
|
|
|
sw->orig_xy = wall[wall_num].y - (sw->range >> 2);
|
|
|
|
else
|
|
|
|
sw->orig_xy = wall[wall_num].x - (sw->range >> 2);
|
|
|
|
|
|
|
|
sw->sintable_ndx = cnt * (2048 / num_points);
|
|
|
|
}
|
|
|
|
|
|
|
|
NextSineWall++;
|
|
|
|
|
|
|
|
ASSERT(NextSineWall < MAX_SINE_WALL);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// this overwrites the lotag so it needs to be called LAST
|
|
|
|
SetupWallForBreak(wp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void SectorLiquidSet(short i)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SECT_USERp sectu;
|
|
|
|
|
|
|
|
// ///////////////////////////////////
|
|
|
|
//
|
|
|
|
// CHECK for pics that mean something
|
|
|
|
//
|
|
|
|
// ///////////////////////////////////
|
|
|
|
|
|
|
|
if (sector[i].floorpicnum >= 300 && sector[i].floorpicnum <= 307)
|
|
|
|
{
|
|
|
|
sectu = GetSectUser(i);
|
|
|
|
|
|
|
|
SET(sector[i].extra, SECTFX_LIQUID_WATER);
|
|
|
|
}
|
|
|
|
else if (sector[i].floorpicnum >= 320 && sector[i].floorpicnum <= 343)
|
|
|
|
{
|
|
|
|
sectu = GetSectUser(i);
|
|
|
|
|
|
|
|
SET(sector[i].extra, SECTFX_LIQUID_WATER);
|
|
|
|
}
|
|
|
|
else if (sector[i].floorpicnum >= 780 && sector[i].floorpicnum <= 794)
|
|
|
|
{
|
|
|
|
sectu = GetSectUser(i);
|
|
|
|
|
|
|
|
SET(sector[i].extra, SECTFX_LIQUID_WATER);
|
|
|
|
}
|
|
|
|
else if (sector[i].floorpicnum >= 890 && sector[i].floorpicnum <= 897)
|
|
|
|
{
|
|
|
|
sectu = GetSectUser(i);
|
|
|
|
|
|
|
|
SET(sector[i].extra, SECTFX_LIQUID_WATER);
|
|
|
|
}
|
|
|
|
else if (sector[i].floorpicnum >= 175 && sector[i].floorpicnum <= 182)
|
|
|
|
{
|
|
|
|
sectu = GetSectUser(i);
|
|
|
|
|
|
|
|
SET(sector[i].extra, SECTFX_LIQUID_LAVA);
|
|
|
|
if (!sectu->damage)
|
|
|
|
sectu->damage = 40;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void SectorSetup(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-03-06 15:49:49 +00:00
|
|
|
short i = 0, tag;
|
|
|
|
short NextSineWave = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-03-06 15:49:49 +00:00
|
|
|
short ndx;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
WallSetup();
|
|
|
|
|
|
|
|
for (ndx = 0; ndx < MAX_SECTOR_OBJECTS; ndx++)
|
|
|
|
{
|
|
|
|
memset(&SectorObject[ndx], -1, sizeof(SectorObject[0]));
|
|
|
|
// 0 pointers
|
2021-07-10 12:25:18 +00:00
|
|
|
//memset(&SectorObject[ndx].sectp, nullptr, sizeof(SectorObject[0].sectp));
|
|
|
|
SectorObject[ndx].PreMoveAnimator = nullptr;
|
|
|
|
SectorObject[ndx].PostMoveAnimator = nullptr;
|
|
|
|
SectorObject[ndx].Animator = nullptr;
|
|
|
|
SectorObject[ndx].controller = nullptr;
|
|
|
|
SectorObject[ndx].sp_child = nullptr;
|
2019-11-08 04:22:58 +00:00
|
|
|
SectorObject[ndx].xmid = INT32_MAX;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(SineWaveFloor, -1, sizeof(SineWaveFloor));
|
|
|
|
memset(SpringBoard, -1, sizeof(SpringBoard));
|
|
|
|
|
|
|
|
LevelSecrets = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < numsectors; i++)
|
|
|
|
{
|
2021-11-02 17:37:57 +00:00
|
|
|
tag = sector[i].lotag;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// ///////////////////////////////////
|
|
|
|
//
|
|
|
|
// CHECK for pics that mean something
|
|
|
|
//
|
|
|
|
// ///////////////////////////////////
|
|
|
|
|
|
|
|
// ///////////////////////////////////
|
|
|
|
//
|
|
|
|
// CHECK for flags
|
|
|
|
//
|
|
|
|
// ///////////////////////////////////
|
|
|
|
|
|
|
|
if (TEST(sector[i].extra, SECTFX_SINK))
|
|
|
|
{
|
|
|
|
SectorLiquidSet(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEST(sector[i].floorstat, FLOOR_STAT_PLAX))
|
|
|
|
{
|
|
|
|
// don't do a z adjust for FAF area
|
|
|
|
if (sector[i].floorpicnum != FAF_PLACE_MIRROR_PIC)
|
|
|
|
{
|
|
|
|
SET(sector[i].extra, SECTFX_Z_ADJUST);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEST(sector[i].ceilingstat, CEILING_STAT_PLAX))
|
|
|
|
{
|
|
|
|
// don't do a z adjust for FAF area
|
|
|
|
if (sector[i].ceilingpicnum != FAF_PLACE_MIRROR_PIC)
|
|
|
|
{
|
|
|
|
SET(sector[i].extra, SECTFX_Z_ADJUST);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ///////////////////////////////////
|
|
|
|
//
|
|
|
|
// CHECK for sector/sprite objects
|
|
|
|
//
|
|
|
|
// ///////////////////////////////////
|
|
|
|
|
|
|
|
if (tag >= TAG_OBJECT_CENTER && tag < TAG_OBJECT_CENTER + 100)
|
|
|
|
{
|
|
|
|
SetupSectorObject(i, tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ///////////////////////////////////
|
|
|
|
//
|
|
|
|
// CHECK lo and hi tags
|
|
|
|
//
|
|
|
|
// ///////////////////////////////////
|
|
|
|
|
|
|
|
switch (tag)
|
|
|
|
{
|
|
|
|
case TAG_SECRET_AREA_TRIGGER:
|
|
|
|
LevelSecrets++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG_DOOR_SLIDING:
|
2020-09-09 17:52:52 +00:00
|
|
|
SetSectorWallBits(i, WALLFX_DONT_STICK, true, true);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG_SINE_WAVE_FLOOR:
|
|
|
|
case TAG_SINE_WAVE_CEILING:
|
|
|
|
case TAG_SINE_WAVE_BOTH:
|
|
|
|
{
|
|
|
|
SINE_WAVE_FLOOR *swf;
|
|
|
|
short near_sect = i, base_sect = i;
|
2019-12-03 09:44:56 +00:00
|
|
|
uint16_t swf_ndx = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
short cnt = 0, sector_cnt;
|
|
|
|
int range;
|
|
|
|
int range_diff = 0;
|
|
|
|
int wave_diff = 0;
|
|
|
|
short peak_dist = 0;
|
|
|
|
short speed_shift = 3;
|
|
|
|
short num;
|
|
|
|
|
|
|
|
num = (tag - TAG_SINE_WAVE_FLOOR) / 20;
|
|
|
|
|
|
|
|
// set the first on up
|
|
|
|
swf = &SineWaveFloor[NextSineWave][swf_ndx];
|
|
|
|
|
|
|
|
swf->flags = 0;
|
|
|
|
|
|
|
|
switch (num)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SET(swf->flags, SINE_FLOOR);
|
|
|
|
if (TEST(sector[base_sect].floorstat, FLOOR_STAT_SLOPE))
|
|
|
|
{
|
|
|
|
SET(swf->flags, SINE_SLOPED);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
SET(swf->flags, SINE_CEILING);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
SET(swf->flags, SINE_FLOOR | SINE_CEILING);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
swf->sector = near_sect;
|
|
|
|
ASSERT(sector[swf->sector].hitag != 0);
|
|
|
|
swf->range = range = Z(sector[swf->sector].hitag);
|
|
|
|
swf->floor_origz = sector[swf->sector].floorz - (range >> 2);
|
|
|
|
swf->ceiling_origz = sector[swf->sector].ceilingz - (range >> 2);
|
|
|
|
|
|
|
|
// look for the rest by distance
|
2020-09-09 17:52:52 +00:00
|
|
|
for (swf_ndx = 1, sector_cnt = 1; true; swf_ndx++)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// near_sect = FindNextSectorByTag(base_sect,
|
|
|
|
// TAG_SINE_WAVE_FLOOR + swf_ndx);
|
|
|
|
near_sect = FindNextSectorByTag(base_sect, tag + swf_ndx);
|
|
|
|
|
|
|
|
if (near_sect >= 0)
|
|
|
|
{
|
|
|
|
swf = &SineWaveFloor[NextSineWave][swf_ndx];
|
|
|
|
|
|
|
|
if (swf_ndx == 1 && sector[near_sect].hitag)
|
|
|
|
range_diff = sector[near_sect].hitag;
|
|
|
|
else if (swf_ndx == 2 && sector[near_sect].hitag)
|
|
|
|
speed_shift = sector[near_sect].hitag;
|
|
|
|
else if (swf_ndx == 3 && sector[near_sect].hitag)
|
|
|
|
peak_dist = sector[near_sect].hitag;
|
|
|
|
|
|
|
|
swf->sector = near_sect;
|
|
|
|
swf->floor_origz = sector[swf->sector].floorz - (range >> 2);
|
|
|
|
swf->ceiling_origz = sector[swf->sector].ceilingz - (range >> 2);
|
|
|
|
range -= range_diff;
|
|
|
|
swf->range = range;
|
|
|
|
|
|
|
|
base_sect = swf->sector;
|
|
|
|
sector_cnt++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ASSERT(swf_ndx <= SIZ(SineWaveFloor[NextSineWave]));
|
|
|
|
|
|
|
|
// more than 6 waves and something in high tag - set up wave
|
|
|
|
// dissapate
|
|
|
|
if (sector_cnt > 8 && sector[base_sect].hitag)
|
|
|
|
{
|
|
|
|
wave_diff = sector[base_sect].hitag;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup the sintable_ndx based on the actual number of
|
|
|
|
// sectors (swf_ndx)
|
|
|
|
for (swf = &SineWaveFloor[NextSineWave][0], cnt = 0; swf->sector >= 0 && swf < (SINE_WAVE_FLOORp)&SineWaveFloor[SIZ(SineWaveFloor)]; swf++, cnt++)
|
|
|
|
{
|
|
|
|
if (peak_dist)
|
|
|
|
swf->sintable_ndx = cnt * (2048 / peak_dist);
|
|
|
|
else
|
|
|
|
swf->sintable_ndx = cnt * (2048 / swf_ndx);
|
|
|
|
|
|
|
|
swf->speed_shift = speed_shift;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set up the a real wave that dissapates at the end
|
|
|
|
if (wave_diff)
|
|
|
|
{
|
|
|
|
for (cnt = sector_cnt - 1; cnt >= 0; cnt--)
|
|
|
|
{
|
|
|
|
// only do the last (actually the first) few for the
|
|
|
|
// dissapate
|
|
|
|
if (cnt > 8)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
swf = &SineWaveFloor[NextSineWave][cnt];
|
|
|
|
|
|
|
|
swf->range -= wave_diff;
|
|
|
|
|
|
|
|
wave_diff += wave_diff;
|
|
|
|
|
|
|
|
if (swf->range < Z(4))
|
|
|
|
swf->range = Z(4);
|
|
|
|
|
|
|
|
// reset origz's based on new range
|
|
|
|
swf->floor_origz = sector[swf->sector].floorz - (swf->range >> 2);
|
|
|
|
swf->ceiling_origz = sector[swf->sector].ceilingz - (swf->range >> 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NextSineWave++;
|
|
|
|
|
|
|
|
ASSERT(NextSineWave < MAX_SINE_WAVE);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void SectorMidPoint(short sectnum, int *xmid, int *ymid, int *zmid)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short startwall, endwall, j;
|
|
|
|
int xsum = 0, ysum = 0;
|
|
|
|
WALLp wp;
|
|
|
|
|
|
|
|
startwall = sector[sectnum].wallptr;
|
|
|
|
endwall = startwall + sector[sectnum].wallnum - 1;
|
|
|
|
|
|
|
|
for (wp = &wall[startwall], j = startwall; j <= endwall; wp++, j++)
|
|
|
|
{
|
|
|
|
xsum += wp->x;
|
|
|
|
ysum += wp->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
*xmid = xsum / (endwall - startwall + 1);
|
|
|
|
*ymid = ysum / (endwall - startwall + 1);
|
|
|
|
|
|
|
|
*zmid = DIV2(sector[sectnum].floorz + sector[sectnum].ceilingz);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void DoSpringBoard(PLAYERp pp/*, short sectnum*/)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
pp->jump_speed = -sector[pp->cursectnum].hitag;
|
|
|
|
DoPlayerBeginForceJump(pp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void DoSpringBoardDown(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
unsigned sb;
|
|
|
|
SPRING_BOARD *sbp;
|
|
|
|
|
|
|
|
for (sb = 0; sb < SIZ(SpringBoard); sb++)
|
|
|
|
{
|
|
|
|
sbp = &SpringBoard[sb];
|
|
|
|
|
|
|
|
// if empty set up an entry to close the sb later
|
|
|
|
if (sbp->Sector != -1)
|
|
|
|
{
|
|
|
|
if ((sbp->TimeOut -= synctics) <= 0)
|
|
|
|
{
|
|
|
|
int destz;
|
|
|
|
|
2019-11-19 20:35:35 +00:00
|
|
|
destz = sector[nextsectorneighborz(sbp->Sector, sector[sbp->Sector].floorz, 1, 1)].floorz;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 17:39:27 +00:00
|
|
|
AnimSet(ANIM_Floorz, sbp->Sector, nullptr, destz, 256);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
sector[sbp->Sector].lotag = TAG_SPRING_BOARD;
|
|
|
|
|
|
|
|
sbp->Sector = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
short FindNextSectorByTag(short sectnum, int tag)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short next_sectnum, startwall, endwall, j;
|
|
|
|
|
|
|
|
startwall = sector[sectnum].wallptr;
|
|
|
|
endwall = startwall + sector[sectnum].wallnum - 1;
|
|
|
|
|
|
|
|
for (j = startwall; j <= endwall; j++)
|
|
|
|
{
|
|
|
|
next_sectnum = wall[j].nextsector;
|
|
|
|
|
|
|
|
if (next_sectnum >= 0)
|
|
|
|
{
|
|
|
|
if (sector[next_sectnum].lotag == tag)
|
|
|
|
{
|
|
|
|
return next_sectnum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
int SectorDistance(short sect1, int sect2)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short wallnum1, wallnum2;
|
|
|
|
|
|
|
|
if (sect1 < 0 || sect2 < 0)
|
|
|
|
return 9999999;
|
|
|
|
|
|
|
|
wallnum1 = sector[sect1].wallptr;
|
|
|
|
wallnum2 = sector[sect2].wallptr;
|
|
|
|
|
|
|
|
// return the distance between the two sectors.
|
|
|
|
return Distance(wall[wallnum1].x, wall[wallnum1].y, wall[wallnum2].x, wall[wallnum2].y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
int SectorDistanceByMid(short sect1, int sect2)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int sx1, sy1, sx2, sy2, trash;
|
|
|
|
|
|
|
|
SectorMidPoint(sect1, &sx1, &sy1, &trash);
|
|
|
|
SectorMidPoint(sect2, &sx2, &sy2, &trash);
|
|
|
|
|
|
|
|
// return the distance between the two sectors.
|
|
|
|
return Distance(sx1, sy1, sx2, sy2);
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
short DoSpawnActorTrigger(short match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-03-06 15:49:49 +00:00
|
|
|
short spawn_count = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
SPRITEp sp;
|
|
|
|
|
2021-11-01 18:08:45 +00:00
|
|
|
SWStatIterator it(STAT_SPAWN_TRIGGER);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-01 18:08:45 +00:00
|
|
|
sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (sp->hitag == match)
|
|
|
|
{
|
2021-11-03 18:52:51 +00:00
|
|
|
if (ActorSpawn(actor))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-01 18:08:45 +00:00
|
|
|
DoSpawnTeleporterEffectPlace(actor);
|
2021-11-06 09:09:53 +00:00
|
|
|
PlaySound(DIGI_PLAYER_TELEPORT, actor, v3df_none);
|
2015-05-19 21:54:34 +00:00
|
|
|
spawn_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return spawn_count;
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
int OperateSector(short sectnum, short player_is_operating)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
PLAYERp pp = GlobPlayerP;
|
|
|
|
|
|
|
|
// Don't let actors operate locked or secret doors
|
|
|
|
if (!player_is_operating)
|
|
|
|
{
|
|
|
|
SPRITEp fsp;
|
|
|
|
|
2021-04-02 10:55:58 +00:00
|
|
|
if (SectUser[sectnum].Data() && SectUser[sectnum]->stag == SECT_LOCK_DOOR)
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
SWSectIterator it(sectnum);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
fsp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-04-02 10:55:58 +00:00
|
|
|
if (SectUser[fsp->sectnum].Data() && SectUser[fsp->sectnum]->stag == SECT_LOCK_DOOR)
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (fsp->statnum == STAT_VATOR && SP_TAG1(fsp) == SECT_VATOR && TEST_BOOL7(fsp))
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
if (fsp->statnum == STAT_ROTATOR && SP_TAG1(fsp) == SECT_ROTATOR && TEST_BOOL7(fsp))
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
if (fsp->statnum == STAT_SLIDOR && SP_TAG1(fsp) == SECT_SLIDOR && TEST_BOOL7(fsp))
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//CON_Message("Operating sectnum %d",sectnum);
|
|
|
|
//CON_Message("stag = %d, lock = %d",SectUser[sectnum]->stag,SECT_LOCK_DOOR);
|
|
|
|
|
2021-11-02 17:37:57 +00:00
|
|
|
switch (sector[sectnum].lotag)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
case TAG_VATOR:
|
|
|
|
DoVatorOperate(pp, sectnum);
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case TAG_ROTATOR:
|
|
|
|
DoRotatorOperate(pp, sectnum);
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case TAG_SLIDOR:
|
|
|
|
DoSlidorOperate(pp, sectnum);
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
int
|
2015-05-19 21:54:34 +00:00
|
|
|
OperateWall(short wallnum, short player_is_operating)
|
|
|
|
{
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
enum
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:05:46 +00:00
|
|
|
SWITCH_LEVER = 581,
|
|
|
|
SWITCH_FUSE = 558,
|
|
|
|
SWITCH_FLIP = 561,
|
|
|
|
SWITCH_RED_CHAIN = 563,
|
|
|
|
SWITCH_GREEN_CHAIN = 565,
|
|
|
|
SWITCH_TOUCH = 567,
|
|
|
|
SWITCH_DRAGON = 569,
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
SWITCH_LIGHT = 551,
|
|
|
|
SWITCH_1 = 575,
|
|
|
|
SWITCH_3 = 579,
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
SWITCH_SHOOTABLE_1 = 577,
|
|
|
|
SWITCH_4 = 571,
|
|
|
|
SWITCH_5 = 573,
|
|
|
|
SWITCH_6 = 583,
|
|
|
|
EXIT_SWITCH = 2470,
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
SWITCH_SKULL = 553,
|
|
|
|
};
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
short AnimateSwitch(SPRITEp sp, short tgt_value)
|
|
|
|
{
|
2015-05-19 21:54:34 +00:00
|
|
|
// if the value is not ON or OFF
|
|
|
|
// then it is a straight toggle
|
|
|
|
|
|
|
|
switch (sp->picnum)
|
|
|
|
{
|
2020-09-09 17:52:52 +00:00
|
|
|
// set to true/ON
|
2015-05-19 21:54:34 +00:00
|
|
|
case SWITCH_SKULL:
|
|
|
|
case SWITCH_LEVER:
|
|
|
|
case SWITCH_LIGHT:
|
|
|
|
case SWITCH_SHOOTABLE_1:
|
|
|
|
case SWITCH_1:
|
|
|
|
case SWITCH_3:
|
|
|
|
case SWITCH_FLIP:
|
|
|
|
case SWITCH_RED_CHAIN:
|
|
|
|
case SWITCH_GREEN_CHAIN:
|
|
|
|
case SWITCH_TOUCH:
|
|
|
|
case SWITCH_DRAGON:
|
|
|
|
case SWITCH_4:
|
|
|
|
case SWITCH_5:
|
|
|
|
case SWITCH_6:
|
|
|
|
case EXIT_SWITCH:
|
|
|
|
|
|
|
|
// dont toggle - return the current state
|
|
|
|
if (tgt_value == 999)
|
2021-11-02 19:48:46 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
sp->picnum += 1;
|
|
|
|
|
|
|
|
// if the tgt_value should be true
|
|
|
|
// flip it again - recursive but only once
|
2021-11-02 19:48:46 +00:00
|
|
|
if (tgt_value == false)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
AnimateSwitch(sp, tgt_value);
|
2021-11-02 19:48:46 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// set to true
|
|
|
|
case SWITCH_SKULL + 1:
|
|
|
|
case SWITCH_LEVER + 1:
|
|
|
|
case SWITCH_LIGHT + 1:
|
|
|
|
case SWITCH_1 + 1:
|
|
|
|
case SWITCH_3 + 1:
|
|
|
|
case SWITCH_FLIP + 1:
|
|
|
|
case SWITCH_RED_CHAIN + 1:
|
|
|
|
case SWITCH_GREEN_CHAIN + 1:
|
|
|
|
case SWITCH_TOUCH + 1:
|
|
|
|
case SWITCH_DRAGON + 1:
|
|
|
|
case SWITCH_SHOOTABLE_1 + 1:
|
|
|
|
case SWITCH_4+1:
|
|
|
|
case SWITCH_5+1:
|
|
|
|
case SWITCH_6+1:
|
|
|
|
case EXIT_SWITCH+1:
|
|
|
|
|
|
|
|
// dont toggle - return the current state
|
|
|
|
if (tgt_value == 999)
|
2021-11-02 19:48:46 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
sp->picnum -= 1;
|
|
|
|
|
2021-11-02 19:58:26 +00:00
|
|
|
if (tgt_value == int(true))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
AnimateSwitch(sp, tgt_value);
|
2021-11-02 19:48:46 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2021-11-02 19:48:46 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
void SectorExp(DSWActor* actor, short sectnum, short orig_ang, int zh)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
SPRITEp sp = &actor->s();
|
|
|
|
USERp u = actor->u();
|
2015-05-19 21:54:34 +00:00
|
|
|
SPRITEp exp;
|
|
|
|
USERp eu;
|
|
|
|
int x,y,z;
|
|
|
|
|
2018-02-16 06:38:31 +00:00
|
|
|
RESET(sp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL|CSTAT_SPRITE_ALIGNMENT_FLOOR);
|
2015-05-19 21:54:34 +00:00
|
|
|
SectorMidPoint(sectnum, &x, &y, &z);
|
|
|
|
sp->ang = orig_ang;
|
|
|
|
sp->x = x;
|
|
|
|
sp->y = y;
|
|
|
|
sp->z = z;
|
|
|
|
|
|
|
|
// randomize the explosions
|
|
|
|
sp->ang += RANDOM_P2(256) - 128;
|
|
|
|
sp->x += RANDOM_P2(1024) - 512;
|
|
|
|
sp->y += RANDOM_P2(1024) - 512;
|
|
|
|
sp->z = zh;
|
|
|
|
|
|
|
|
// setup vars needed by SectorExp
|
2021-11-02 19:48:46 +00:00
|
|
|
ChangeActorSect(actor, sectnum);
|
2015-05-19 21:54:34 +00:00
|
|
|
getzsofslope(sp->sectnum, sp->x, sp->y, &u->hiz, &u->loz);
|
|
|
|
|
|
|
|
// spawn explosion
|
2021-11-04 23:16:01 +00:00
|
|
|
auto explosion = SpawnSectorExp(actor);
|
|
|
|
if (!explosion) return;
|
|
|
|
exp = &explosion->s();
|
|
|
|
eu = explosion->u();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
exp->xrepeat += (RANDOM_P2(32<<8)>>8) - 16;
|
|
|
|
exp->yrepeat += (RANDOM_P2(32<<8)>>8) - 16;
|
|
|
|
eu->xchange = MOVEx(92, exp->ang);
|
|
|
|
eu->ychange = MOVEy(92, exp->ang);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void DoExplodeSector(short match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short orig_ang;
|
|
|
|
int zh;
|
|
|
|
|
|
|
|
SECTORp sectp;
|
|
|
|
|
|
|
|
orig_ang = 0; //sp->ang;
|
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
SWStatIterator it(STAT_EXPLODING_CEIL_FLOOR);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
auto esp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (match != esp->lotag)
|
|
|
|
continue;
|
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
if (!actor->hasU())
|
|
|
|
/*u = */SpawnUser(actor, 0, nullptr);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
sectp = §or[esp->sectnum];
|
|
|
|
|
|
|
|
sectp->ceilingz -= Z(SP_TAG4(esp));
|
|
|
|
|
|
|
|
if (SP_TAG5(esp))
|
|
|
|
{
|
|
|
|
sectp->floorheinum = SP_TAG5(esp);
|
|
|
|
SET(sectp->floorstat, FLOOR_STAT_SLOPE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SP_TAG6(esp))
|
|
|
|
{
|
|
|
|
sectp->ceilingheinum = SP_TAG6(esp);
|
|
|
|
SET(sectp->ceilingstat, CEILING_STAT_SLOPE);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (zh = sectp->ceilingz; zh < sectp->floorz; zh += Z(60))
|
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
SectorExp(actor, esp->sectnum, orig_ang, zh + Z(RANDOM_P2(64)) - Z(32));
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// don't need it any more
|
2021-11-02 19:48:46 +00:00
|
|
|
KillActor(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-29 18:49:57 +00:00
|
|
|
int DoSpawnSpot(DSWActor* actor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-10-29 18:49:57 +00:00
|
|
|
USER* u = actor->u();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if ((u->WaitTics -= synctics) < 0)
|
|
|
|
{
|
2021-10-30 18:00:02 +00:00
|
|
|
change_actor_stat(actor, STAT_SPAWN_SPOT);
|
2021-10-30 19:44:51 +00:00
|
|
|
SpawnShrap(actor, nullptr);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (u->LastDamage == 1)
|
|
|
|
{
|
2021-10-30 20:53:24 +00:00
|
|
|
KillActor(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// spawns shrap when killing an object
|
2021-11-02 19:05:46 +00:00
|
|
|
void DoSpawnSpotsForKill(short match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SPRITEp sp;
|
|
|
|
USERp u;
|
|
|
|
|
|
|
|
if (match < 0)
|
|
|
|
return;
|
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
SWStatIterator it(STAT_SPAWN_SPOT);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// change the stat num and set the delay correctly to call SpawnShrap
|
|
|
|
if (sp->hitag == SPAWN_SPOT && sp->lotag == match)
|
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
u = actor->u();
|
|
|
|
change_actor_stat(actor, STAT_NO_STATE);
|
2015-05-19 21:54:34 +00:00
|
|
|
u->ActorActionFunc = DoSpawnSpot;
|
|
|
|
u->WaitTics = SP_TAG5(sp) * 15;
|
2021-11-02 19:48:46 +00:00
|
|
|
SetActorZ(actor, &sp->pos);
|
2015-05-19 21:54:34 +00:00
|
|
|
// setting for Killed
|
|
|
|
u->LastDamage = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// spawns shrap when damaging an object
|
2021-11-02 19:05:46 +00:00
|
|
|
void DoSpawnSpotsForDamage(short match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SPRITEp sp;
|
|
|
|
USERp u;
|
|
|
|
|
|
|
|
if (match < 0)
|
|
|
|
return;
|
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
SWStatIterator it(STAT_SPAWN_SPOT);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// change the stat num and set the delay correctly to call SpawnShrap
|
|
|
|
|
|
|
|
if (sp->hitag == SPAWN_SPOT && sp->lotag == match)
|
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
u = actor->u();
|
|
|
|
change_actor_stat(actor, STAT_NO_STATE);
|
2015-05-19 21:54:34 +00:00
|
|
|
u->ActorActionFunc = DoSpawnSpot;
|
|
|
|
u->WaitTics = SP_TAG7(sp) * 15;
|
|
|
|
// setting for Damaged
|
|
|
|
u->LastDamage = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void DoSoundSpotMatch(short match, short sound_num, short sound_type)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SPRITEp sp;
|
|
|
|
int flags;
|
|
|
|
short snd2play;
|
|
|
|
|
|
|
|
//sound_type is not used
|
|
|
|
|
|
|
|
sound_num--;
|
|
|
|
|
|
|
|
ASSERT(sound_num >= 0);
|
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
SWStatIterator it(STAT_SOUND_SPOT);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (SP_TAG2(sp) == match && !TEST_BOOL6(sp))
|
|
|
|
{
|
|
|
|
short snd[3];
|
|
|
|
|
|
|
|
snd[0] = SP_TAG13(sp); // tag4 is copied to tag13
|
|
|
|
snd[1] = SP_TAG5(sp);
|
|
|
|
snd[2] = SP_TAG6(sp);
|
|
|
|
|
|
|
|
snd2play = 0;
|
|
|
|
flags = 0;
|
|
|
|
|
|
|
|
if (TEST_BOOL2(sp))
|
|
|
|
flags = v3df_follow|v3df_nolookup|v3df_init;
|
|
|
|
|
|
|
|
// play once and only once
|
|
|
|
if (TEST_BOOL1(sp))
|
|
|
|
SET_BOOL6(sp);
|
|
|
|
|
|
|
|
// don't pan
|
|
|
|
if (TEST_BOOL4(sp))
|
|
|
|
flags |= v3df_dontpan;
|
|
|
|
// add doppler
|
|
|
|
if (TEST_BOOL5(sp))
|
|
|
|
flags |= v3df_doppler;
|
|
|
|
// random
|
|
|
|
if (TEST_BOOL3(sp))
|
|
|
|
{
|
|
|
|
if (snd[0] && snd[1])
|
|
|
|
{
|
2021-09-20 06:59:54 +00:00
|
|
|
snd2play = snd[RandomRange(2)];
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (snd[0] && snd[1] && snd[2])
|
|
|
|
{
|
2021-09-20 06:59:54 +00:00
|
|
|
snd2play = snd[RandomRange(3)];
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (snd[sound_num])
|
|
|
|
{
|
|
|
|
snd2play = snd[sound_num];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (snd2play <= 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (TEST_BOOL7(sp))
|
|
|
|
{
|
|
|
|
PLAYERp pp = GlobPlayerP;
|
|
|
|
|
|
|
|
if (pp)
|
|
|
|
{
|
|
|
|
if (pp == Player+myconnectindex)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(snd2play, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-02 22:08:59 +00:00
|
|
|
PlaySound(snd2play, actor, flags);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-31 17:10:59 +00:00
|
|
|
void DoSoundSpotStopSound(short match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
|
2021-10-31 17:10:59 +00:00
|
|
|
SWStatIterator it(STAT_SOUND_SPOT);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-10-31 17:10:59 +00:00
|
|
|
auto sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// found match and is a follow type
|
|
|
|
if (SP_TAG2(sp) == match && TEST_BOOL2(sp))
|
|
|
|
{
|
2021-10-31 17:10:59 +00:00
|
|
|
DeleteNoSoundOwner(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void DoStopSoundSpotMatch(short match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SPRITEp sp;
|
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
SWStatIterator it(STAT_STOP_SOUND_SPOT);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (SP_TAG2(sp) == match)
|
|
|
|
{
|
|
|
|
DoSoundSpotStopSound(SP_TAG5(sp));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-09 18:32:24 +00:00
|
|
|
bool TestKillSectorObject(SECTOR_OBJECTp sop)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (TEST(sop->flags, SOBJ_KILLABLE))
|
|
|
|
{
|
|
|
|
KillMatchingCrackSprites(sop->match_event);
|
|
|
|
// get new sectnums
|
|
|
|
CollapseSectorObject(sop, sop->xmid, sop->ymid);
|
|
|
|
DoSpawnSpotsForKill(sop->match_event);
|
|
|
|
KillSectorObjectSprites(sop);
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
short DoSectorObjectKillMatch(short match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SECTOR_OBJECTp sop;
|
|
|
|
|
|
|
|
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
|
|
|
{
|
2020-05-22 12:11:03 +00:00
|
|
|
if (SO_EMPTY(sop))
|
2015-05-19 21:54:34 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (sop->match_event == match)
|
|
|
|
return TestKillSectorObject(sop);
|
|
|
|
}
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
bool SearchExplodeSectorMatch(short match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// THIS IS ONLY CALLED FROM DoMatchEverything
|
2021-11-02 19:48:46 +00:00
|
|
|
SWStatIterator it(STAT_SPRITE_HIT_MATCH);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
auto sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (sp->hitag == match)
|
|
|
|
{
|
|
|
|
KillMatchingCrackSprites(match);
|
|
|
|
DoExplodeSector(match);
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void KillMatchingCrackSprites(short match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SPRITEp sp;
|
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
SWStatIterator it(STAT_SPRITE_HIT_MATCH);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (sp->hitag == match)
|
|
|
|
{
|
|
|
|
if (TEST(SP_TAG8(sp), BIT(2)))
|
|
|
|
continue;
|
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
KillActor(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:58:26 +00:00
|
|
|
void WeaponExplodeSectorInRange(DSWActor* wActor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:58:26 +00:00
|
|
|
SPRITEp wp = &wActor->s();
|
|
|
|
USERp wu = wActor->u();
|
2015-05-19 21:54:34 +00:00
|
|
|
SPRITEp sp;
|
|
|
|
int dist;
|
|
|
|
int radius;
|
|
|
|
|
2021-11-02 19:48:46 +00:00
|
|
|
SWStatIterator it(STAT_SPRITE_HIT_MATCH);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// test to see if explosion is close to crack sprite
|
2019-12-26 06:28:16 +00:00
|
|
|
dist = FindDistance3D(wp->x - sp->x, wp->y - sp->y, wp->z - sp->z);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (sp->clipdist == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
radius = (((int)sp->clipdist) << 2) * 8;
|
|
|
|
|
|
|
|
if ((unsigned int)dist > (wu->Radius/2) + radius)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!FAFcansee(wp->x,wp->y,wp->z,wp->sectnum,sp->x,sp->y,sp->z,sp->sectnum))
|
|
|
|
continue;
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
// pass in explosion type
|
2021-11-04 23:31:54 +00:00
|
|
|
MissileHitMatch(wActor, WPN_ROCKET, actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-02 20:35:24 +00:00
|
|
|
void ShootableSwitch(DSWActor* actor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 20:35:24 +00:00
|
|
|
SPRITEp sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
switch (sp->picnum)
|
|
|
|
{
|
|
|
|
case SWITCH_SHOOTABLE_1:
|
|
|
|
//RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
|
2021-11-02 20:35:24 +00:00
|
|
|
OperateSprite(actor, false);
|
2015-05-19 21:54:34 +00:00
|
|
|
sp->picnum = SWITCH_SHOOTABLE_1 + 1;
|
|
|
|
break;
|
|
|
|
case SWITCH_FUSE:
|
|
|
|
case SWITCH_FUSE + 1:
|
|
|
|
RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
|
2021-11-02 20:35:24 +00:00
|
|
|
OperateSprite(actor, false);
|
2015-05-19 21:54:34 +00:00
|
|
|
sp->picnum = SWITCH_FUSE + 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void DoDeleteSpriteMatch(short match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
static short StatList[] =
|
|
|
|
{
|
|
|
|
STAT_DEFAULT,
|
|
|
|
STAT_VATOR,
|
|
|
|
STAT_SPIKE,
|
|
|
|
STAT_TRAP,
|
|
|
|
STAT_ITEM,
|
|
|
|
STAT_LIGHTING,
|
|
|
|
STAT_STATIC_FIRE,
|
|
|
|
STAT_AMBIENT,
|
|
|
|
STAT_FAF
|
|
|
|
};
|
|
|
|
|
|
|
|
int del_x = 0,del_y = 0;
|
|
|
|
unsigned stat;
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
while (true)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:58:26 +00:00
|
|
|
DSWActor* found = nullptr;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// search for a DELETE_SPRITE with same match tag
|
2021-11-02 19:58:26 +00:00
|
|
|
SWStatIterator it(STAT_DELETE_SPRITE);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:58:26 +00:00
|
|
|
auto sp = &actor->s();
|
|
|
|
if (sp->lotag == match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:58:26 +00:00
|
|
|
found = actor;
|
|
|
|
del_x = sp->x;
|
|
|
|
del_y = sp->y;
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:58:26 +00:00
|
|
|
if (found == nullptr)
|
2015-05-19 21:54:34 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
for (stat = 0; stat < SIZ(StatList); stat++)
|
|
|
|
{
|
2021-10-31 17:10:59 +00:00
|
|
|
SWStatIterator it(StatList[stat]);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-10-31 17:10:59 +00:00
|
|
|
auto sp = &actor->s();
|
2021-10-12 20:21:08 +00:00
|
|
|
if (del_x == sp->x && del_y == sp->y)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// special case lighting delete of Fade On/off after fades
|
|
|
|
if (StatList[stat] == STAT_LIGHTING)
|
|
|
|
{
|
|
|
|
// set shade to darkest and then kill it
|
2021-10-12 20:21:08 +00:00
|
|
|
sp->shade = int8_t(SP_TAG6(sp));
|
|
|
|
sp->pal = 0;
|
2021-11-01 13:44:27 +00:00
|
|
|
SectorLightShade(actor, sp->shade);
|
|
|
|
DiffuseLighting(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2021-10-31 17:10:59 +00:00
|
|
|
SpriteQueueDelete(actor);
|
|
|
|
KillActor(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// kill the DELETE_SPRITE
|
2021-11-02 19:58:26 +00:00
|
|
|
KillActor(found);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void DoChangorMatch(short match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SPRITEp sp;
|
|
|
|
SECTORp sectp;
|
|
|
|
|
2021-11-02 19:58:26 +00:00
|
|
|
SWStatIterator it(STAT_CHANGOR);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:58:26 +00:00
|
|
|
auto sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
sectp = §or[sp->sectnum];
|
|
|
|
|
|
|
|
if (SP_TAG2(sp) != match)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (TEST_BOOL1(sp))
|
|
|
|
{
|
|
|
|
sectp->ceilingpicnum = SP_TAG4(sp);
|
|
|
|
sectp->ceilingz += Z(SP_TAG5(sp));
|
|
|
|
sectp->ceilingheinum += SP_TAG6(sp);
|
|
|
|
|
|
|
|
if (sectp->ceilingheinum)
|
|
|
|
SET(sectp->ceilingstat, CEILING_STAT_SLOPE);
|
|
|
|
else
|
|
|
|
RESET(sectp->ceilingstat, CEILING_STAT_SLOPE);
|
|
|
|
|
|
|
|
sectp->ceilingshade += SP_TAG7(sp);
|
|
|
|
sectp->ceilingpal += SP_TAG8(sp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sectp->floorpicnum = SP_TAG4(sp);
|
|
|
|
sectp->floorz += Z(SP_TAG5(sp));
|
|
|
|
sectp->floorheinum += SP_TAG6(sp);
|
|
|
|
|
|
|
|
if (sectp->floorheinum)
|
|
|
|
SET(sectp->floorstat, FLOOR_STAT_SLOPE);
|
|
|
|
else
|
|
|
|
RESET(sectp->floorstat, FLOOR_STAT_SLOPE);
|
|
|
|
|
|
|
|
sectp->floorshade += SP_TAG7(sp);
|
|
|
|
sectp->floorpal += SP_TAG8(sp);
|
|
|
|
}
|
|
|
|
|
|
|
|
sectp->visibility += SP_TAG9(sp);
|
|
|
|
|
|
|
|
// if not set then go ahead and kill it
|
|
|
|
if (TEST_BOOL2(sp) == 0)
|
|
|
|
{
|
2021-11-02 19:58:26 +00:00
|
|
|
KillActor(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void DoMatchEverything(PLAYERp pp, short match, short state)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
PLAYERp bak;
|
|
|
|
|
|
|
|
bak = GlobPlayerP;
|
|
|
|
GlobPlayerP = pp;
|
2021-07-10 12:25:18 +00:00
|
|
|
// CAREFUL! pp == nullptr is a valid case for this routine
|
2015-05-19 21:54:34 +00:00
|
|
|
DoStopSoundSpotMatch(match);
|
|
|
|
DoSoundSpotMatch(match, 1, SOUND_EVERYTHING_TYPE);
|
|
|
|
GlobPlayerP = bak;
|
|
|
|
|
|
|
|
DoLightingMatch(match, state);
|
|
|
|
|
|
|
|
DoQuakeMatch(match);
|
|
|
|
|
|
|
|
// make sure all vators are inactive before allowing
|
|
|
|
// to repress switch
|
|
|
|
if (!TestVatorMatchActive(match))
|
|
|
|
DoVatorMatch(pp, match);
|
|
|
|
|
|
|
|
if (!TestSpikeMatchActive(match))
|
2020-03-07 13:51:49 +00:00
|
|
|
DoSpikeMatch(match);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (!TestRotatorMatchActive(match))
|
2020-09-09 17:52:52 +00:00
|
|
|
DoRotatorMatch(pp, match, false);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (!TestSlidorMatchActive(match))
|
2020-09-09 17:52:52 +00:00
|
|
|
DoSlidorMatch(pp, match, false);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
DoSectorObjectKillMatch(match);
|
|
|
|
DoSectorObjectSetScale(match);
|
|
|
|
|
|
|
|
DoSOevent(match, state);
|
|
|
|
DoSpawnActorTrigger(match);
|
|
|
|
|
|
|
|
// this may or may not find an exploding sector
|
|
|
|
SearchExplodeSectorMatch(match);
|
|
|
|
|
|
|
|
CopySectorMatch(match);
|
|
|
|
DoWallMoveMatch(match);
|
|
|
|
DoSpawnSpotsForKill(match);
|
|
|
|
|
|
|
|
DoTrapReset(match);
|
|
|
|
DoTrapMatch(match);
|
|
|
|
|
|
|
|
SpawnItemsMatch(match);
|
|
|
|
DoChangorMatch(match);
|
|
|
|
DoDeleteSpriteMatch(match);
|
|
|
|
}
|
|
|
|
|
2020-09-09 18:32:24 +00:00
|
|
|
bool ComboSwitchTest(short combo_type, short match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-09-09 18:28:05 +00:00
|
|
|
int state;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 19:58:26 +00:00
|
|
|
SWStatIterator it(STAT_DEFAULT);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 19:58:26 +00:00
|
|
|
auto sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (sp->lotag == combo_type && sp->hitag == match)
|
|
|
|
{
|
|
|
|
// dont toggle - get the current state
|
|
|
|
state = AnimateSwitch(sp, 999);
|
|
|
|
|
|
|
|
// if any one is not set correctly then switch is not set
|
|
|
|
if (state != SP_TAG3(sp))
|
|
|
|
{
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: switches are always wall sprites
|
2021-11-02 20:35:24 +00:00
|
|
|
int OperateSprite(DSWActor* actor, short player_is_operating)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 20:35:24 +00:00
|
|
|
SPRITEp sp = &actor->s();
|
|
|
|
USERp u = actor->u();
|
2021-07-10 12:25:18 +00:00
|
|
|
PLAYERp pp = nullptr;
|
2015-05-19 21:54:34 +00:00
|
|
|
short state;
|
|
|
|
short key_num=0;
|
|
|
|
extern STATE s_Pachinko1Operate[];
|
|
|
|
extern STATE s_Pachinko2Operate[];
|
|
|
|
extern STATE s_Pachinko3Operate[];
|
|
|
|
extern STATE s_Pachinko4Operate[];
|
|
|
|
|
|
|
|
if (Prediction)
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (sp->picnum == ST1)
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (player_is_operating)
|
|
|
|
{
|
|
|
|
pp = GlobPlayerP;
|
|
|
|
|
|
|
|
if (!FAFcansee(pp->posx, pp->posy, pp->posz, pp->cursectnum, sp->x, sp->y, sp->z - DIV2(SPRITEp_SIZE_Z(sp)), sp->sectnum))
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (sp->lotag)
|
|
|
|
{
|
|
|
|
case TOILETGIRL_R0:
|
|
|
|
case WASHGIRL_R0:
|
|
|
|
case CARGIRL_R0:
|
|
|
|
case MECHANICGIRL_R0:
|
|
|
|
case SAILORGIRL_R0:
|
|
|
|
case PRUNEGIRL_R0:
|
|
|
|
{
|
|
|
|
short choose_snd;
|
|
|
|
|
|
|
|
u->FlagOwner = 1;
|
|
|
|
u->WaitTics = SEC(4);
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
if (pp != Player+myconnectindex) return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
choose_snd = STD_RANDOM_RANGE(1000);
|
|
|
|
if (sp->lotag == CARGIRL_R0)
|
|
|
|
{
|
|
|
|
if (choose_snd > 700)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG44052, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else if (choose_snd > 500)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG45014, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else if (choose_snd > 250)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG44068, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG45010, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (sp->lotag == MECHANICGIRL_R0)
|
|
|
|
{
|
|
|
|
if (choose_snd > 700)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG44027, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else if (choose_snd > 500)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG44038, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else if (choose_snd > 250)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG44039, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG44048, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (sp->lotag == SAILORGIRL_R0)
|
|
|
|
{
|
|
|
|
if (choose_snd > 700)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG45018, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else if (choose_snd > 500)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG45030, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else if (choose_snd > 250)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG45033, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG45043, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (sp->lotag == PRUNEGIRL_R0)
|
|
|
|
{
|
|
|
|
if (choose_snd > 700)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG45053, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else if (choose_snd > 500)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG45067, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else if (choose_snd > 250)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG46005, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_JG46010, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (sp->lotag == TOILETGIRL_R0)
|
|
|
|
{
|
|
|
|
if (choose_snd > 700)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_WHATYOUEATBABY, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else if (choose_snd > 500)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_WHATDIEDUPTHERE, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else if (choose_snd > 250)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_YOUGOPOOPOO, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_PULLMYFINGER, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (choose_snd > 700)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_SOAPYOUGOOD, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else if (choose_snd > 500)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_WASHWANG, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else if (choose_snd > 250)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_DROPSOAP, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_REALTITS, v3df_dontpan|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case PACHINKO1:
|
|
|
|
|
|
|
|
// Don't mess with it if it's already going
|
2020-09-09 17:52:52 +00:00
|
|
|
if (u->WaitTics > 0) return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 22:08:59 +00:00
|
|
|
PlaySound(DIGI_PFLIP, actor, v3df_none);
|
2021-09-20 06:59:54 +00:00
|
|
|
u->WaitTics = SEC(3) + SEC(RandomRange(10));
|
2021-10-30 18:11:31 +00:00
|
|
|
ChangeState(actor,s_Pachinko1Operate);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case PACHINKO2:
|
|
|
|
|
|
|
|
// Don't mess with it if it's already going
|
2020-09-09 17:52:52 +00:00
|
|
|
if (u->WaitTics > 0) return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 22:08:59 +00:00
|
|
|
PlaySound(DIGI_PFLIP, actor, v3df_none);
|
2021-09-20 06:59:54 +00:00
|
|
|
u->WaitTics = SEC(3) + SEC(RandomRange(10));
|
2021-10-30 18:11:31 +00:00
|
|
|
ChangeState(actor,s_Pachinko2Operate);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case PACHINKO3:
|
|
|
|
|
|
|
|
// Don't mess with it if it's already going
|
2020-09-09 17:52:52 +00:00
|
|
|
if (u->WaitTics > 0) return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 22:08:59 +00:00
|
|
|
PlaySound(DIGI_PFLIP, actor, v3df_none);
|
2021-09-20 06:59:54 +00:00
|
|
|
u->WaitTics = SEC(3) + SEC(RandomRange(10));
|
2021-10-30 18:11:31 +00:00
|
|
|
ChangeState(actor,s_Pachinko3Operate);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case PACHINKO4:
|
|
|
|
|
|
|
|
// Don't mess with it if it's already going
|
2020-09-09 17:52:52 +00:00
|
|
|
if (u->WaitTics > 0) return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 22:08:59 +00:00
|
|
|
PlaySound(DIGI_PFLIP, actor, v3df_none);
|
2021-09-20 06:59:54 +00:00
|
|
|
u->WaitTics = SEC(3) + SEC(RandomRange(10));
|
2021-10-30 18:11:31 +00:00
|
|
|
ChangeState(actor,s_Pachinko4Operate);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case SWITCH_LOCKED:
|
|
|
|
key_num = sp->hitag;
|
|
|
|
if (pp->HasKey[key_num - 1])
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i=0; i<numsectors; i++)
|
|
|
|
{
|
2021-04-02 10:55:58 +00:00
|
|
|
if (SectUser[i].Data() && SectUser[i]->stag == SECT_LOCK_DOOR && SectUser[i]->number == key_num)
|
2015-05-19 21:54:34 +00:00
|
|
|
SectUser[i]->number = 0; // unlock all doors of this type
|
|
|
|
}
|
2021-11-01 08:10:19 +00:00
|
|
|
UnlockKeyLock(key_num, actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case TAG_COMBO_SWITCH_EVERYTHING:
|
|
|
|
|
|
|
|
// change the switch state
|
|
|
|
AnimateSwitch(sp, -1);
|
2021-11-02 22:08:59 +00:00
|
|
|
PlaySound(DIGI_REGULARSWITCH, actor, v3df_none);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (ComboSwitchTest(TAG_COMBO_SWITCH_EVERYTHING, sp->hitag))
|
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
DoMatchEverything(pp, sp->hitag, true);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case TAG_COMBO_SWITCH_EVERYTHING_ONCE:
|
|
|
|
|
|
|
|
// change the switch state
|
|
|
|
AnimateSwitch(sp, -1);
|
2021-11-02 22:08:59 +00:00
|
|
|
PlaySound(DIGI_REGULARSWITCH, actor, v3df_none);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (ComboSwitchTest(TAG_COMBO_SWITCH_EVERYTHING, sp->hitag))
|
|
|
|
{
|
2021-11-02 19:48:46 +00:00
|
|
|
DoMatchEverything(pp, sp->hitag, true);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sp->lotag = 0;
|
|
|
|
sp->hitag = 0;
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case TAG_SWITCH_EVERYTHING:
|
|
|
|
state = AnimateSwitch(sp, -1);
|
|
|
|
DoMatchEverything(pp, sp->hitag, state);
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case TAG_SWITCH_EVERYTHING_ONCE:
|
|
|
|
state = AnimateSwitch(sp, -1);
|
|
|
|
DoMatchEverything(pp, sp->hitag, state);
|
|
|
|
sp->lotag = 0;
|
|
|
|
sp->hitag = 0;
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case TAG_LIGHT_SWITCH:
|
|
|
|
|
|
|
|
state = AnimateSwitch(sp, -1);
|
|
|
|
DoLightingMatch(sp->hitag, state);
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case TAG_SPRITE_SWITCH_VATOR:
|
|
|
|
{
|
|
|
|
// make sure all vators are inactive before allowing
|
|
|
|
// to repress switch
|
|
|
|
if (!TestVatorMatchActive(sp->hitag))
|
|
|
|
DoVatorMatch(pp, sp->hitag);
|
|
|
|
|
|
|
|
if (!TestSpikeMatchActive(sp->hitag))
|
2020-03-07 13:51:49 +00:00
|
|
|
DoSpikeMatch(sp->hitag);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (!TestRotatorMatchActive(sp->hitag))
|
2020-09-09 17:52:52 +00:00
|
|
|
DoRotatorMatch(pp, sp->hitag, false);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (!TestSlidorMatchActive(sp->hitag))
|
2020-09-09 17:52:52 +00:00
|
|
|
DoSlidorMatch(pp, sp->hitag, false);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_LEVEL_EXIT_SWITCH:
|
|
|
|
{
|
|
|
|
AnimateSwitch(sp, -1);
|
|
|
|
|
2021-11-02 22:08:59 +00:00
|
|
|
PlaySound(DIGI_BIGSWITCH, actor, v3df_none);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-04 19:15:15 +00:00
|
|
|
MapRecord *map;
|
2015-05-19 21:54:34 +00:00
|
|
|
if (sp->hitag)
|
2020-09-04 19:15:15 +00:00
|
|
|
map = FindMapByLevelNum(sp->hitag);
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
2021-05-01 21:10:04 +00:00
|
|
|
map = FindNextMap(currentLevel);
|
2021-07-20 08:51:34 +00:00
|
|
|
ChangeLevel(map, g_nextskill);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_SPRITE_GRATING:
|
|
|
|
{
|
|
|
|
USERp u;
|
|
|
|
|
2021-10-30 18:00:02 +00:00
|
|
|
change_actor_stat(actor, STAT_NO_STATE);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-10-30 18:00:02 +00:00
|
|
|
u = SpawnUser(actor, 0, nullptr);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
u->ActorActionFunc = DoGrating;
|
|
|
|
|
|
|
|
sp->lotag = 0;
|
|
|
|
sp->hitag /= 2;
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_SO_SCALE_SWITCH:
|
|
|
|
AnimateSwitch(sp, -1);
|
|
|
|
DoSectorObjectSetScale(sp->hitag);
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case TAG_SO_SCALE_ONCE_SWITCH:
|
|
|
|
AnimateSwitch(sp, -1);
|
|
|
|
DoSectorObjectSetScale(sp->hitag);
|
|
|
|
sp->lotag = 0;
|
|
|
|
sp->hitag = 0;
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
case TAG_SO_EVENT_SWITCH:
|
|
|
|
{
|
|
|
|
state = AnimateSwitch(sp, -1);
|
|
|
|
|
2021-07-10 12:25:18 +00:00
|
|
|
DoMatchEverything(nullptr, sp->hitag, state);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
sp->hitag = 0;
|
|
|
|
sp->lotag = 0;
|
|
|
|
|
2021-11-02 22:08:59 +00:00
|
|
|
PlaySound(DIGI_REGULARSWITCH, actor, v3df_none);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_ROTATE_SO_SWITCH:
|
|
|
|
{
|
|
|
|
short so_num;
|
|
|
|
SECTOR_OBJECTp sop;
|
|
|
|
|
|
|
|
so_num = sp->hitag;
|
|
|
|
|
|
|
|
ASSERT(so_num <= 20);
|
|
|
|
ASSERT(SectorObject[so_num].num_sectors != -1);
|
|
|
|
|
|
|
|
AnimateSwitch(sp, -1);
|
|
|
|
|
|
|
|
sop = &SectorObject[so_num];
|
|
|
|
|
|
|
|
sop->ang_tgt = NORM_ANGLE(sop->ang_tgt + 512);
|
|
|
|
|
2021-11-02 22:08:59 +00:00
|
|
|
PlaySound(DIGI_BIGSWITCH, actor, v3df_none);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int DoTrapReset(short match)
|
|
|
|
{
|
|
|
|
SPRITEp sp;
|
|
|
|
USERp u;
|
|
|
|
|
2021-11-02 20:43:33 +00:00
|
|
|
SWStatIterator it(STAT_TRAP);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 20:43:33 +00:00
|
|
|
sp = &actor->s();
|
|
|
|
u = actor->u();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (sp->lotag != match)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// if correct type and matches
|
|
|
|
if (sp->hitag == FIREBALL_TRAP)
|
|
|
|
u->WaitTics = 0;
|
|
|
|
|
|
|
|
// if correct type and matches
|
|
|
|
if (sp->hitag == BOLT_TRAP)
|
|
|
|
u->WaitTics = 0;
|
|
|
|
|
|
|
|
// if correct type and matches
|
|
|
|
if (sp->hitag == SPEAR_TRAP)
|
|
|
|
u->WaitTics = 0;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int DoTrapMatch(short match)
|
|
|
|
{
|
|
|
|
SPRITEp sp;
|
|
|
|
USERp u;
|
|
|
|
|
|
|
|
// may need to be reset to fire immediately
|
|
|
|
|
2021-11-02 20:43:33 +00:00
|
|
|
SWStatIterator it(STAT_TRAP);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 20:43:33 +00:00
|
|
|
sp = &actor->s();
|
|
|
|
u = actor->u();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (sp->lotag != match)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// if correct type and matches
|
|
|
|
if (sp->hitag == FIREBALL_TRAP)
|
|
|
|
{
|
|
|
|
u->WaitTics -= synctics;
|
|
|
|
|
|
|
|
if (u->WaitTics <= 0)
|
|
|
|
{
|
|
|
|
u->WaitTics = 1 * 120;
|
2021-10-29 18:49:57 +00:00
|
|
|
InitFireballTrap(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if correct type and matches
|
|
|
|
if (sp->hitag == BOLT_TRAP)
|
|
|
|
{
|
|
|
|
u->WaitTics -= synctics;
|
|
|
|
|
|
|
|
if (u->WaitTics <= 0)
|
|
|
|
{
|
|
|
|
u->WaitTics = 1 * 120;
|
2021-10-29 18:49:57 +00:00
|
|
|
InitBoltTrap(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if correct type and matches
|
|
|
|
if (sp->hitag == SPEAR_TRAP)
|
|
|
|
{
|
|
|
|
u->WaitTics -= synctics;
|
|
|
|
|
|
|
|
if (u->WaitTics <= 0)
|
|
|
|
{
|
|
|
|
u->WaitTics = 1 * 120;
|
2021-11-04 17:23:30 +00:00
|
|
|
InitSpearTrap(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void OperateTripTrigger(PLAYERp pp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (Prediction)
|
|
|
|
return;
|
|
|
|
|
2019-12-03 09:44:51 +00:00
|
|
|
if (pp->cursectnum < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SECTORp sectp = §or[pp->cursectnum];
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
// old method
|
2021-11-02 17:37:57 +00:00
|
|
|
switch (sector[pp->cursectnum].lotag)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// same tag for sector as for switch
|
|
|
|
case TAG_LEVEL_EXIT_SWITCH:
|
|
|
|
{
|
2020-09-04 19:15:15 +00:00
|
|
|
MapRecord *map;
|
2015-05-19 21:54:34 +00:00
|
|
|
if (sectp->hitag)
|
2020-09-04 19:15:15 +00:00
|
|
|
map = FindMapByLevelNum(sectp->hitag);
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
2021-05-01 21:10:04 +00:00
|
|
|
map = FindNextMap(currentLevel);
|
2021-07-20 08:51:34 +00:00
|
|
|
ChangeLevel(map, g_nextskill);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_SECRET_AREA_TRIGGER:
|
|
|
|
if (pp == Player+myconnectindex)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_ANCIENTSECRET, v3df_dontpan|v3df_doppler|v3df_follow,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-09 20:19:05 +00:00
|
|
|
SECRET_Trigger(pp->cursectnum);
|
|
|
|
|
2020-01-06 01:41:47 +00:00
|
|
|
PutStringInfo(pp, GStrings("TXTS_SECRET"));
|
2015-05-19 21:54:34 +00:00
|
|
|
// always give to the first player
|
|
|
|
Player->SecretsFound++;
|
|
|
|
sectp->lotag = 0;
|
|
|
|
sectp->hitag = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG_TRIGGER_EVERYTHING:
|
|
|
|
DoMatchEverything(pp, sectp->hitag, -1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG_TRIGGER_EVERYTHING_ONCE:
|
|
|
|
DoMatchEverything(pp, sectp->hitag, -1);
|
|
|
|
sectp->lotag = 0;
|
|
|
|
sectp->hitag = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG_SECTOR_TRIGGER_VATOR:
|
|
|
|
if (!TestVatorMatchActive(sectp->hitag))
|
|
|
|
DoVatorMatch(pp, sectp->hitag);
|
|
|
|
if (!TestSpikeMatchActive(sectp->hitag))
|
2020-03-07 13:51:49 +00:00
|
|
|
DoSpikeMatch(sectp->hitag);
|
2015-05-19 21:54:34 +00:00
|
|
|
if (!TestRotatorMatchActive(sectp->hitag))
|
2020-09-09 17:52:52 +00:00
|
|
|
DoRotatorMatch(pp, sectp->hitag, false);
|
2015-05-19 21:54:34 +00:00
|
|
|
if (!TestSlidorMatchActive(sectp->hitag))
|
2020-09-09 17:52:52 +00:00
|
|
|
DoSlidorMatch(pp, sectp->hitag, false);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG_LIGHT_TRIGGER:
|
|
|
|
DoLightingMatch(sectp->hitag, -1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG_SO_SCALE_TRIGGER:
|
|
|
|
DoSectorObjectSetScale(sectp->hitag);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG_SO_SCALE_ONCE_TRIGGER:
|
|
|
|
DoSectorObjectSetScale(sectp->hitag);
|
|
|
|
sectp->lotag = 0;
|
|
|
|
sectp->hitag = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG_TRIGGER_ACTORS:
|
|
|
|
{
|
|
|
|
int dist;
|
2020-10-15 15:45:07 +00:00
|
|
|
int i;
|
2015-05-19 21:54:34 +00:00
|
|
|
SPRITEp sp;
|
|
|
|
USERp u;
|
|
|
|
|
|
|
|
dist = sectp->hitag;
|
|
|
|
|
2021-11-02 20:43:33 +00:00
|
|
|
SWStatIterator it(STAT_ENEMY);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 20:43:33 +00:00
|
|
|
sp = &actor->s();
|
|
|
|
u = actor->u();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (TEST(u->Flags, SPR_WAIT_FOR_TRIGGER))
|
|
|
|
{
|
|
|
|
if (Distance(sp->x, sp->y, pp->posx, pp->posy) < dist)
|
|
|
|
{
|
2021-10-30 11:15:02 +00:00
|
|
|
u->targetActor = pp->Actor();
|
2015-05-19 21:54:34 +00:00
|
|
|
RESET(u->Flags, SPR_WAIT_FOR_TRIGGER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_TRIGGER_MISSILE_TRAP:
|
|
|
|
{
|
|
|
|
// reset traps so they fire immediately
|
|
|
|
DoTrapReset(sector[pp->cursectnum].hitag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_TRIGGER_EXPLODING_SECTOR:
|
|
|
|
{
|
2021-07-10 12:25:18 +00:00
|
|
|
DoMatchEverything(nullptr, sector[pp->cursectnum].hitag, -1);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_SPAWN_ACTOR_TRIGGER:
|
|
|
|
{
|
2021-07-10 12:25:18 +00:00
|
|
|
DoMatchEverything(nullptr, sector[pp->cursectnum].hitag, -1);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
sector[pp->cursectnum].hitag = 0;
|
|
|
|
sector[pp->cursectnum].lotag = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TAG_SO_EVENT_TRIGGER:
|
|
|
|
{
|
2021-07-10 12:25:18 +00:00
|
|
|
DoMatchEverything(nullptr, sector[pp->cursectnum].hitag, -1);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
sector[pp->cursectnum].hitag = 0;
|
|
|
|
sector[pp->cursectnum].lotag = 0;
|
|
|
|
|
2019-12-18 10:09:01 +00:00
|
|
|
PlaySound(DIGI_REGULARSWITCH, pp, v3df_none);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void OperateContinuousTrigger(PLAYERp pp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (Prediction)
|
|
|
|
return;
|
|
|
|
|
2019-12-03 09:44:51 +00:00
|
|
|
if (pp->cursectnum < 0)
|
|
|
|
return;
|
|
|
|
|
2021-11-14 12:33:35 +00:00
|
|
|
switch (sector[pp->cursectnum].lotag)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
case TAG_TRIGGER_MISSILE_TRAP:
|
|
|
|
{
|
|
|
|
DoTrapMatch(sector[pp->cursectnum].hitag);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
short PlayerTakeSectorDamage(PLAYERp pp)
|
|
|
|
{
|
2021-04-02 10:55:58 +00:00
|
|
|
SECT_USERp sectu = SectUser[pp->cursectnum].Data();
|
2021-11-02 20:43:33 +00:00
|
|
|
USERp u = pp->Actor()->u();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// the calling routine must make sure sectu exists
|
|
|
|
if ((u->DamageTics -= synctics) < 0)
|
|
|
|
{
|
|
|
|
u->DamageTics = DAMAGE_TIME;
|
|
|
|
|
|
|
|
PlayerUpdateHealth(pp, -sectu->damage);
|
2021-11-05 21:43:59 +00:00
|
|
|
PlayerCheckDeath(pp, nullptr);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Needed in order to see if Player should grunt if he can't find a wall to operate on
|
|
|
|
// If player is too far away, don't grunt
|
2021-11-02 19:05:46 +00:00
|
|
|
enum { PLAYER_SOUNDEVENT_TAG = 900 };
|
2020-09-09 18:32:24 +00:00
|
|
|
bool NearThings(PLAYERp pp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short neartagsect, neartagwall, neartagsprite;
|
|
|
|
int neartaghitdist;
|
|
|
|
|
|
|
|
|
|
|
|
// Check player's current sector for triggered sound
|
|
|
|
if (sector[pp->cursectnum].hitag == PLAYER_SOUNDEVENT_TAG)
|
|
|
|
{
|
|
|
|
if (pp == Player+myconnectindex)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(sector[pp->cursectnum].lotag, v3df_follow|v3df_dontpan,pp);
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-10-08 03:23:29 +00:00
|
|
|
neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, pp->angle.ang.asbuild(),
|
2015-05-19 21:54:34 +00:00
|
|
|
&neartagsect, &neartagwall, &neartagsprite,
|
2021-07-10 12:25:18 +00:00
|
|
|
&neartaghitdist, 1024L, NTAG_SEARCH_LO_HI, nullptr);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
// hit a sprite? Check to see if it has sound info in it!
|
|
|
|
// This can work with any sprite!
|
|
|
|
if (neartagsprite >= 0)
|
|
|
|
{
|
|
|
|
SPRITEp sp = &sprite[neartagsprite];
|
|
|
|
|
|
|
|
// Go through list of cases
|
|
|
|
if (sp->hitag == PLAYER_SOUNDEVENT_TAG)
|
|
|
|
{
|
|
|
|
if (pp == Player+myconnectindex)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(sp->lotag, v3df_follow|v3df_dontpan,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2020-09-09 17:52:52 +00:00
|
|
|
return false; // Return false so he doesn't grunt
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (neartagwall >= 0)
|
|
|
|
{
|
|
|
|
// Check player's current sector for triggered sound
|
|
|
|
if (wall[neartagwall].hitag == PLAYER_SOUNDEVENT_TAG)
|
|
|
|
{
|
|
|
|
if (pp == Player+myconnectindex)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(wall[neartagwall].lotag, v3df_follow|v3df_dontpan,pp);
|
2020-09-09 17:52:52 +00:00
|
|
|
return false; // We are playing a sound so don't return true
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
// This only gets called if nothing else worked, check for nearness to a wall
|
|
|
|
{
|
2021-11-03 23:23:05 +00:00
|
|
|
HITINFO hitinfo;
|
2020-10-08 03:23:29 +00:00
|
|
|
short dang = pp->angle.ang.asbuild();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
FAFhitscan(pp->posx, pp->posy, pp->posz - Z(30), pp->cursectnum, // Start position
|
2020-11-15 10:27:22 +00:00
|
|
|
bcos(dang), // X vector of 3D ang
|
|
|
|
bsin(dang), // Y vector of 3D ang
|
|
|
|
0, // Z vector of 3D ang
|
2015-05-19 22:01:22 +00:00
|
|
|
&hitinfo, CLIPMASK_MISSILE);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 22:01:22 +00:00
|
|
|
if (hitinfo.sect < 0)
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 22:01:22 +00:00
|
|
|
if (Distance(hitinfo.pos.x, hitinfo.pos.y, pp->posx, pp->posy) > 1500)
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// hit a sprite?
|
2021-11-03 23:23:05 +00:00
|
|
|
if (hitinfo.hitactor != nullptr)
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (neartagsect >= 0)
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 22:01:22 +00:00
|
|
|
if (hitinfo.wall >= 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
WALLp wp;
|
|
|
|
|
2015-05-19 22:01:22 +00:00
|
|
|
wp = &wall[hitinfo.wall];
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Near a plain old vanilla wall. Can't do anything but grunt.
|
|
|
|
if (!TEST(wp->extra, WALLFX_DONT_STICK) && pp == Player+myconnectindex)
|
|
|
|
{
|
|
|
|
if (STD_RANDOM_RANGE(1000) > 970)
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_HITTINGWALLS, v3df_follow|v3df_dontpan,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
2019-12-18 10:09:01 +00:00
|
|
|
PlayerSound(DIGI_SEARCHWALL, v3df_follow|v3df_dontpan,pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
short nti_cnt;
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void NearTagList(NEAR_TAG_INFOp ntip, PLAYERp pp, int z, int dist, int type, int count)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short save_lotag, save_hitag;
|
|
|
|
short neartagsector, neartagwall, neartagsprite;
|
|
|
|
int neartaghitdist;
|
|
|
|
|
|
|
|
|
2020-10-08 03:23:29 +00:00
|
|
|
neartag(pp->posx, pp->posy, z, pp->cursectnum, pp->angle.ang.asbuild(),
|
2015-05-19 21:54:34 +00:00
|
|
|
&neartagsector, &neartagwall, &neartagsprite,
|
2021-07-10 12:25:18 +00:00
|
|
|
&neartaghitdist, dist, type, nullptr);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (neartagsector >= 0)
|
|
|
|
{
|
|
|
|
// save off values
|
|
|
|
save_lotag = sector[neartagsector].lotag;
|
|
|
|
save_hitag = sector[neartagsector].hitag;
|
|
|
|
|
|
|
|
ntip->dist = neartaghitdist;
|
|
|
|
ntip->sectnum = neartagsector;
|
|
|
|
ntip->wallnum = -1;
|
2021-11-06 11:40:32 +00:00
|
|
|
ntip->actor = nullptr;
|
2015-05-19 21:54:34 +00:00
|
|
|
nti_cnt++;
|
|
|
|
ntip++;
|
|
|
|
|
|
|
|
if (nti_cnt >= count)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// remove them
|
|
|
|
sector[neartagsector].lotag = 0;
|
|
|
|
sector[neartagsector].hitag = 0;
|
|
|
|
|
|
|
|
NearTagList(ntip, pp, z, dist, type, count);
|
|
|
|
|
|
|
|
// reset off values
|
|
|
|
sector[neartagsector].lotag = save_lotag;
|
|
|
|
sector[neartagsector].hitag = save_hitag;
|
|
|
|
}
|
|
|
|
else if (neartagwall >= 0)
|
|
|
|
{
|
|
|
|
// save off values
|
|
|
|
save_lotag = wall[neartagwall].lotag;
|
|
|
|
save_hitag = wall[neartagwall].hitag;
|
|
|
|
|
|
|
|
ntip->dist = neartaghitdist;
|
|
|
|
ntip->sectnum = -1;
|
|
|
|
ntip->wallnum = neartagwall;
|
2021-11-06 11:40:32 +00:00
|
|
|
ntip->actor = nullptr;
|
2015-05-19 21:54:34 +00:00
|
|
|
nti_cnt++;
|
|
|
|
ntip++;
|
2021-11-06 11:40:32 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
if (nti_cnt >= count)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// remove them
|
|
|
|
wall[neartagwall].lotag = 0;
|
|
|
|
wall[neartagwall].hitag = 0;
|
|
|
|
|
|
|
|
NearTagList(ntip, pp, z, dist, type, count);
|
|
|
|
|
|
|
|
// reset off values
|
|
|
|
wall[neartagwall].lotag = save_lotag;
|
|
|
|
wall[neartagwall].hitag = save_hitag;
|
|
|
|
}
|
|
|
|
else if (neartagsprite >= 0)
|
|
|
|
{
|
2021-11-06 11:40:32 +00:00
|
|
|
auto actor = &swActors[neartagsprite];
|
|
|
|
auto sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
// save off values
|
2021-11-02 20:43:33 +00:00
|
|
|
save_lotag = sp->lotag;
|
|
|
|
save_hitag = sp->hitag;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ntip->dist = neartaghitdist;
|
|
|
|
ntip->sectnum = -1;
|
|
|
|
ntip->wallnum = -1;
|
2021-11-06 11:40:32 +00:00
|
|
|
ntip->actor = actor;
|
2015-05-19 21:54:34 +00:00
|
|
|
nti_cnt++;
|
|
|
|
ntip++;
|
|
|
|
|
|
|
|
if (nti_cnt >= count)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// remove them
|
2021-11-02 20:43:33 +00:00
|
|
|
sp->lotag = 0;
|
|
|
|
sp->hitag = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
NearTagList(ntip, pp, z, dist, type, count);
|
|
|
|
|
|
|
|
// reset off values
|
2021-11-02 20:43:33 +00:00
|
|
|
sp->lotag = save_lotag;
|
|
|
|
sp->hitag = save_hitag;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ntip->dist = -1;
|
|
|
|
ntip->sectnum = -1;
|
|
|
|
ntip->wallnum = -1;
|
2021-11-06 11:40:32 +00:00
|
|
|
ntip->actor = nullptr;
|
2015-05-19 21:54:34 +00:00
|
|
|
nti_cnt++;
|
|
|
|
ntip++;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void BuildNearTagList(NEAR_TAG_INFOp ntip, int size, PLAYERp pp, int z, int dist, int type, int count)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
memset(ntip, -1, size);
|
|
|
|
nti_cnt = 0;
|
|
|
|
NearTagList(ntip, pp, z, dist, type, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int DoPlayerGrabStar(PLAYERp pp)
|
|
|
|
{
|
2021-07-10 12:25:18 +00:00
|
|
|
SPRITEp sp = nullptr;
|
2015-05-19 21:54:34 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
// MUST check exact z's of each star or it will never work
|
|
|
|
for (i = 0; i < MAX_STAR_QUEUE; i++)
|
|
|
|
{
|
2021-11-02 21:05:24 +00:00
|
|
|
if (StarQueue[i] != nullptr)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 21:05:24 +00:00
|
|
|
sp = &StarQueue[i]->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-26 06:28:16 +00:00
|
|
|
if (FindDistance3D(sp->x - pp->posx, sp->y - pp->posy, sp->z - pp->posz + Z(12)) < 500)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < MAX_STAR_QUEUE)
|
|
|
|
{
|
|
|
|
// Pull a star out of wall and up your ammo
|
|
|
|
PlayerUpdateAmmo(pp, WPN_STAR, 1);
|
2021-11-02 22:08:59 +00:00
|
|
|
PlaySound(DIGI_ITEM, StarQueue[i], v3df_none);
|
2021-11-02 21:05:24 +00:00
|
|
|
KillActor(StarQueue[i]);
|
|
|
|
StarQueue[i] = nullptr;
|
2015-05-19 21:54:34 +00:00
|
|
|
if (TEST(pp->WpnFlags, BIT(WPN_STAR)))
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
SET(pp->WpnFlags, BIT(WPN_STAR));
|
|
|
|
InitWeaponStar(pp);
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void PlayerOperateEnv(PLAYERp pp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-09-09 18:32:24 +00:00
|
|
|
bool found;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-04 23:33:07 +00:00
|
|
|
if (Prediction || !pp->Actor())
|
2015-05-19 21:54:34 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Switch & door activations
|
|
|
|
//
|
|
|
|
|
2020-08-28 20:51:05 +00:00
|
|
|
if (pp->input.actions & SB_OPEN)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-28 20:51:05 +00:00
|
|
|
if (pp->KeyPressBits & SB_OPEN)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// if space bar pressed
|
|
|
|
short nt_ndx;
|
|
|
|
NEAR_TAG_INFO nti[16];
|
|
|
|
|
|
|
|
if (DoPlayerGrabStar(pp))
|
|
|
|
{
|
2020-08-28 20:51:05 +00:00
|
|
|
pp->KeyPressBits &= ~SB_OPEN;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NearThings(pp); // Check for player sound specified in a level sprite
|
|
|
|
}
|
|
|
|
|
|
|
|
BuildNearTagList(nti, sizeof(nti), pp, pp->posz, 2048L, NTAG_SEARCH_LO_HI, 8);
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
found = false;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// try and find a sprite
|
|
|
|
for (nt_ndx = 0; nti[nt_ndx].dist >= 0; nt_ndx++)
|
|
|
|
{
|
2021-11-06 11:40:32 +00:00
|
|
|
if (nti[nt_ndx].actor != nullptr && nti[nt_ndx].dist < 1024 + 768)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-06 11:40:32 +00:00
|
|
|
if (OperateSprite(nti[nt_ndx].actor, true))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-28 20:51:05 +00:00
|
|
|
pp->KeyPressBits &= ~SB_OPEN;
|
2020-09-09 17:52:52 +00:00
|
|
|
found = true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if not found look at different z positions
|
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
int z[3];
|
|
|
|
unsigned i;
|
|
|
|
NEAR_TAG_INFO nti[16];
|
|
|
|
short nt_ndx;
|
2021-11-02 20:43:33 +00:00
|
|
|
auto psp = &pp->Actor()->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-02 20:43:33 +00:00
|
|
|
z[0] = psp->z - SPRITEp_SIZE_Z(psp) - Z(10);
|
|
|
|
z[1] = psp->z;
|
2015-05-19 21:54:34 +00:00
|
|
|
z[2] = DIV2(z[0] + z[1]);
|
|
|
|
|
|
|
|
for (i = 0; i < SIZ(z); i++)
|
|
|
|
{
|
|
|
|
BuildNearTagList(nti, sizeof(nti), pp, z[i], 1024 + 768L, NTAG_SEARCH_LO_HI, 8);
|
|
|
|
|
|
|
|
for (nt_ndx = 0; nti[nt_ndx].dist >= 0; nt_ndx++)
|
|
|
|
{
|
2021-11-06 11:40:32 +00:00
|
|
|
if (nti[nt_ndx].actor != nullptr && nti[nt_ndx].dist < 1024 + 768)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-06 11:40:32 +00:00
|
|
|
if (OperateSprite(nti[nt_ndx].actor, true))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-28 20:51:05 +00:00
|
|
|
pp->KeyPressBits &= ~SB_OPEN;
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
int neartaghitdist;
|
2020-03-06 15:49:49 +00:00
|
|
|
short neartagsector, neartagwall;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
neartaghitdist = nti[0].dist;
|
|
|
|
neartagsector = nti[0].sectnum;
|
|
|
|
neartagwall = nti[0].wallnum;
|
|
|
|
|
|
|
|
if (neartagsector >= 0 && neartaghitdist < 1024)
|
|
|
|
{
|
2020-09-09 17:52:52 +00:00
|
|
|
if (OperateSector(neartagsector, true))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// Release the key
|
2020-08-28 20:51:05 +00:00
|
|
|
pp->KeyPressBits &= ~SB_OPEN;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (neartagwall >= 0 && neartaghitdist < 1024)
|
|
|
|
{
|
2020-09-09 17:52:52 +00:00
|
|
|
if (OperateWall(neartagwall, true))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-28 20:51:05 +00:00
|
|
|
pp->KeyPressBits &= ~SB_OPEN;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Trigger operations
|
|
|
|
//
|
|
|
|
|
2021-11-02 17:37:57 +00:00
|
|
|
switch (sector[pp->cursectnum].lotag)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
case TAG_VATOR:
|
|
|
|
DoVatorOperate(pp, pp->cursectnum);
|
2020-03-07 13:51:49 +00:00
|
|
|
DoSpikeOperate(pp->cursectnum);
|
2015-05-19 21:54:34 +00:00
|
|
|
DoRotatorOperate(pp, pp->cursectnum);
|
|
|
|
DoSlidorOperate(pp, pp->cursectnum);
|
|
|
|
break;
|
|
|
|
case TAG_SPRING_BOARD:
|
2020-03-07 13:51:54 +00:00
|
|
|
DoSpringBoard(pp/*, pp->cursectnum*/);
|
2020-08-28 20:51:05 +00:00
|
|
|
pp->KeyPressBits &= ~SB_OPEN;
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
case TAG_DOOR_ROTATE:
|
2020-09-09 17:52:52 +00:00
|
|
|
if (OperateSector(pp->cursectnum, true))
|
2020-08-28 20:51:05 +00:00
|
|
|
pp->KeyPressBits &= ~SB_OPEN;
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Reset the key when syncbit key is not in use
|
2020-08-28 20:51:05 +00:00
|
|
|
pp->KeyPressBits |= SB_OPEN;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ////////////////////////////
|
|
|
|
//
|
|
|
|
// Sector Damage
|
|
|
|
//
|
|
|
|
// ////////////////////////////
|
|
|
|
|
2019-12-03 09:44:51 +00:00
|
|
|
SECT_USERp sectu;
|
2021-04-02 10:55:58 +00:00
|
|
|
if (pp->cursectnum >= 0 && (sectu = SectUser[pp->cursectnum].Data()) && sectu->damage)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-03 09:44:51 +00:00
|
|
|
SECTORp sectp = §or[pp->cursectnum];
|
2015-05-19 21:54:34 +00:00
|
|
|
if (TEST(sectu->flags, SECTFU_DAMAGE_ABOVE_SECTOR))
|
|
|
|
{
|
|
|
|
PlayerTakeSectorDamage(pp);
|
|
|
|
}
|
2021-11-04 23:33:07 +00:00
|
|
|
else if ((SPRITEp_BOS(&pp->Actor()->s()) >= sectp->floorz) && !TEST(pp->Flags, PF_DIVING))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
PlayerTakeSectorDamage(pp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-04 23:33:07 +00:00
|
|
|
USERp u = pp->Actor()->u();
|
2015-05-19 21:54:34 +00:00
|
|
|
u->DamageTics = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ////////////////////////////
|
|
|
|
//
|
|
|
|
// Trigger stuff
|
|
|
|
//
|
|
|
|
// ////////////////////////////
|
|
|
|
|
|
|
|
OperateContinuousTrigger(pp);
|
|
|
|
|
|
|
|
// just changed sectors
|
|
|
|
if (pp->lastcursectnum != pp->cursectnum)
|
|
|
|
{
|
|
|
|
OperateTripTrigger(pp);
|
|
|
|
|
2019-12-03 09:44:51 +00:00
|
|
|
if (pp->cursectnum >= 0 && TEST(sector[pp->cursectnum].extra, SECTFX_WARP_SECTOR))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (!TEST(pp->Flags2, PF2_TELEPORTED))
|
|
|
|
{
|
|
|
|
DoPlayerWarpTeleporter(pp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RESET(pp->Flags2, PF2_TELEPORTED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void DoSineWaveFloor(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SINE_WAVE_FLOOR *swf;
|
|
|
|
int newz;
|
2021-11-16 17:53:40 +00:00
|
|
|
int wave;
|
|
|
|
int flags;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
for (wave = 0; wave < MAX_SINE_WAVE; wave++)
|
|
|
|
{
|
|
|
|
for (swf = &SineWaveFloor[wave][0], flags = swf->flags; swf->sector >= 0 && swf < &SineWaveFloor[wave][SIZ(SineWaveFloor[wave])]; swf++)
|
|
|
|
{
|
|
|
|
|
|
|
|
swf->sintable_ndx = NORM_ANGLE(swf->sintable_ndx + (synctics << swf->speed_shift));
|
|
|
|
|
|
|
|
if (TEST(flags, SINE_FLOOR))
|
|
|
|
{
|
2021-01-04 11:36:54 +00:00
|
|
|
newz = swf->floor_origz + MulScale(swf->range, bsin(swf->sintable_ndx), 14);
|
2015-05-19 21:54:34 +00:00
|
|
|
sector[swf->sector].floorz = newz;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEST(flags, SINE_CEILING))
|
|
|
|
{
|
2021-01-04 11:36:54 +00:00
|
|
|
newz = swf->ceiling_origz + MulScale(swf->range, bsin(swf->sintable_ndx), 14);
|
2015-05-19 21:54:34 +00:00
|
|
|
sector[swf->sector].ceilingz = newz;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SLOPED SIN-WAVE FLOORS:
|
|
|
|
|
|
|
|
It's best to program sloped sin-wave floors in 2 steps:
|
|
|
|
1. First set the floorz of the floor as the sin code normally does it.
|
|
|
|
2. Adjust the slopes by calling alignflorslope once for each sector.
|
|
|
|
|
|
|
|
Note: For this to work, the first wall of each sin-wave sector must be
|
|
|
|
aligned on the same side of each sector for the entire strip.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (wave = 0; wave < MAX_SINE_WAVE; wave++)
|
|
|
|
{
|
|
|
|
for (swf = &SineWaveFloor[wave][0], flags = swf->flags; swf->sector >= 0 && swf < &SineWaveFloor[wave][SIZ(SineWaveFloor[wave])]; swf++)
|
|
|
|
{
|
|
|
|
if (!TEST(sector[swf->sector].floorstat, FLOOR_STAT_SLOPE))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (TEST(flags, SINE_SLOPED))
|
|
|
|
{
|
|
|
|
WALLp wal;
|
|
|
|
if (sector[swf->sector].wallnum == 4)
|
|
|
|
{
|
|
|
|
//Set wal to the wall on the opposite side of the sector
|
|
|
|
wal = &wall[sector[swf->sector].wallptr+2];
|
|
|
|
|
|
|
|
//Pass (Sector, x, y, z)
|
|
|
|
alignflorslope(swf->sector,wal->x,wal->y,
|
|
|
|
sector[wal->nextsector].floorz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void DoSineWaveWall(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SINE_WALL *sw;
|
2017-01-23 11:21:32 +00:00
|
|
|
int New;
|
2015-05-19 21:54:34 +00:00
|
|
|
short sw_num;
|
|
|
|
|
|
|
|
for (sw_num = 0; sw_num < MAX_SINE_WAVE; sw_num++)
|
|
|
|
{
|
|
|
|
for (sw = &SineWall[sw_num][0]; sw->wall >= 0 && sw < &SineWall[sw_num][MAX_SINE_WALL_POINTS]; sw++)
|
|
|
|
{
|
|
|
|
// move through the sintable
|
|
|
|
sw->sintable_ndx = NORM_ANGLE(sw->sintable_ndx + (synctics << sw->speed_shift));
|
|
|
|
|
|
|
|
if (!sw->type)
|
|
|
|
{
|
2021-01-04 11:36:54 +00:00
|
|
|
New = sw->orig_xy + MulScale(sw->range, bsin(sw->sintable_ndx), 14);
|
2017-01-23 11:21:32 +00:00
|
|
|
// wall[sw->wall].y = New;
|
2021-11-18 00:15:18 +00:00
|
|
|
dragpoint(sw->wall, wall[sw->wall].x, New);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-04 11:36:54 +00:00
|
|
|
New = sw->orig_xy + MulScale(sw->range, bsin(sw->sintable_ndx), 14);
|
2017-01-23 11:21:32 +00:00
|
|
|
// wall[sw->wall].x = New;
|
2021-11-18 00:15:18 +00:00
|
|
|
dragpoint(sw->wall, New, wall[sw->wall].y);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void DoAnim(int numtics)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int i, animval;
|
|
|
|
|
|
|
|
for (i = AnimCnt - 1; i >= 0; i--)
|
|
|
|
{
|
2020-12-08 19:42:52 +00:00
|
|
|
animval = Anim[i].Addr();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// if LESS THAN goal
|
|
|
|
if (animval < Anim[i].goal)
|
|
|
|
{
|
|
|
|
// move it
|
|
|
|
animval += (numtics * PIXZ(Anim[i].vel));
|
|
|
|
|
|
|
|
Anim[i].vel += Anim[i].vel_adj * numtics;
|
|
|
|
|
|
|
|
// if the other way make it equal
|
|
|
|
if (animval > Anim[i].goal)
|
|
|
|
animval = Anim[i].goal;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if GREATER THAN goal
|
|
|
|
if (animval > Anim[i].goal)
|
|
|
|
{
|
|
|
|
animval -= (numtics * PIXZ(Anim[i].vel));
|
|
|
|
|
|
|
|
Anim[i].vel += Anim[i].vel_adj * numtics;
|
|
|
|
|
|
|
|
if (animval < Anim[i].goal)
|
|
|
|
animval = Anim[i].goal;
|
|
|
|
}
|
|
|
|
|
2020-12-08 19:42:52 +00:00
|
|
|
Anim[i].Addr() =animval;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// EQUAL this entry has finished
|
|
|
|
if (animval == Anim[i].goal)
|
|
|
|
{
|
|
|
|
ANIM_CALLBACKp acp = Anim[i].callback;
|
|
|
|
|
2021-07-10 12:25:18 +00:00
|
|
|
// do a callback when done if not nullptr
|
2015-05-19 21:54:34 +00:00
|
|
|
if (Anim[i].callback)
|
|
|
|
(*Anim[i].callback)(&Anim[i], Anim[i].callbackdata);
|
|
|
|
|
|
|
|
// only delete it if the callback has not changed
|
|
|
|
// Logic here is that if the callback changed then something
|
|
|
|
// else must be happening with it - dont delete it
|
|
|
|
if (Anim[i].callback == acp)
|
|
|
|
{
|
|
|
|
// decrement the count
|
|
|
|
AnimCnt--;
|
|
|
|
|
|
|
|
// move the last entry to the current one to free the last
|
|
|
|
// entry up
|
|
|
|
Anim[i] = Anim[AnimCnt];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void AnimClear(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
AnimCnt = 0;
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
short AnimGetGoal(int animtype, int animindex, DSWActor* animactor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
j = -1;
|
|
|
|
for (i = 0; i < AnimCnt; i++)
|
|
|
|
{
|
2021-11-02 17:39:27 +00:00
|
|
|
if (animtype == Anim[i].animtype && animindex == Anim[i].animindex && animactor == Anim[i].animactor )
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
j = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void AnimDelete(int animtype, int animindex, DSWActor* animactor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
j = -1;
|
|
|
|
for (i = 0; i < AnimCnt; i++)
|
|
|
|
{
|
2021-11-02 17:39:27 +00:00
|
|
|
if (animtype == Anim[i].animtype && animindex == Anim[i].animindex && animactor == Anim[i].animactor )
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
j = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// decrement the count
|
|
|
|
AnimCnt--;
|
|
|
|
|
|
|
|
// move the last entry to the current one to free the last entry up
|
|
|
|
Anim[j] = Anim[AnimCnt];
|
|
|
|
|
|
|
|
//DSPRINTF(ds, "Deleted a Anim");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
short AnimSet(int animtype, int animindex, DSWActor* animactor, fixed_t thegoal, int thevel)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
ASSERT(AnimCnt < MAXANIM - 1);
|
|
|
|
|
|
|
|
j = AnimCnt;
|
|
|
|
|
|
|
|
// look for existing animation and reset it
|
|
|
|
for (i = 0; i < AnimCnt; i++)
|
|
|
|
{
|
2021-11-02 17:39:27 +00:00
|
|
|
if (animtype == Anim[i].animtype && animindex == Anim[i].animindex && animactor == Anim[i].animactor )
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
j = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-08 19:42:52 +00:00
|
|
|
Anim[j].animtype = animtype;
|
2021-11-02 17:39:27 +00:00
|
|
|
Anim[j].animindex = animindex;
|
|
|
|
Anim[j].animactor = animactor;
|
2015-05-19 21:54:34 +00:00
|
|
|
Anim[j].goal = thegoal;
|
|
|
|
Anim[j].vel = Z(thevel);
|
|
|
|
Anim[j].vel_adj = 0;
|
2021-07-10 12:25:18 +00:00
|
|
|
Anim[j].callback = nullptr;
|
|
|
|
Anim[j].callbackdata = nullptr;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (j == AnimCnt)
|
|
|
|
AnimCnt++;
|
|
|
|
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
short AnimSetCallback(short anim_ndx, ANIM_CALLBACKp call, SECTOR_OBJECTp data)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
ASSERT(anim_ndx < AnimCnt);
|
|
|
|
|
|
|
|
if (anim_ndx == -1)
|
|
|
|
return anim_ndx;
|
|
|
|
|
|
|
|
Anim[anim_ndx].callback = call;
|
|
|
|
Anim[anim_ndx].callbackdata = data;
|
|
|
|
|
|
|
|
return anim_ndx;
|
|
|
|
}
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
short AnimSetVelAdj(short anim_ndx, short vel_adj)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
ASSERT(anim_ndx < AnimCnt);
|
|
|
|
|
|
|
|
if (anim_ndx == -1)
|
|
|
|
return anim_ndx;
|
|
|
|
|
|
|
|
Anim[anim_ndx].vel_adj = vel_adj;
|
|
|
|
|
|
|
|
return anim_ndx;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void DoPanning(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int nx, ny;
|
2020-10-15 15:45:07 +00:00
|
|
|
int i;
|
2015-05-19 21:54:34 +00:00
|
|
|
SPRITEp sp;
|
|
|
|
SECTORp sectp;
|
|
|
|
WALLp wallp;
|
|
|
|
|
2021-11-02 20:43:33 +00:00
|
|
|
|
|
|
|
SWStatIterator it(STAT_FLOOR_PAN);
|
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 20:43:33 +00:00
|
|
|
sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
sectp = §or[sp->sectnum];
|
|
|
|
|
2021-01-04 11:36:54 +00:00
|
|
|
nx = MulScale(sp->xvel, bcos(sp->ang), 20);
|
|
|
|
ny = MulScale(sp->xvel, bsin(sp->ang), 20);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-05-12 14:50:20 +00:00
|
|
|
sectp->addfloorxpan((float)nx);
|
|
|
|
sectp->addfloorypan((float)ny);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-10-15 15:40:22 +00:00
|
|
|
it.Reset(STAT_CEILING_PAN);
|
2021-11-02 20:43:33 +00:00
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 20:43:33 +00:00
|
|
|
sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
sectp = §or[sp->sectnum];
|
|
|
|
|
2021-01-04 11:36:54 +00:00
|
|
|
nx = MulScale(sp->xvel, bcos(sp->ang), 20);
|
|
|
|
ny = MulScale(sp->xvel, bsin(sp->ang), 20);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-05-12 14:50:20 +00:00
|
|
|
sectp->addceilingxpan((float)nx);
|
|
|
|
sectp->addceilingypan((float)ny);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-10-15 15:40:22 +00:00
|
|
|
it.Reset(STAT_WALL_PAN);
|
2021-11-02 20:43:33 +00:00
|
|
|
while (auto actor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-02 20:43:33 +00:00
|
|
|
sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
wallp = &wall[sp->owner];
|
|
|
|
|
2021-01-04 11:36:54 +00:00
|
|
|
nx = MulScale(sp->xvel, bcos(sp->ang), 20);
|
|
|
|
ny = MulScale(sp->xvel, bsin(sp->ang), 20);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-05-12 14:50:20 +00:00
|
|
|
wallp->addxpan((float)nx);
|
|
|
|
wallp->addypan((float)ny);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-02 19:05:46 +00:00
|
|
|
void DoSector(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SECTOR_OBJECTp sop;
|
2020-09-09 18:32:24 +00:00
|
|
|
bool riding;
|
2015-05-19 21:54:34 +00:00
|
|
|
int sync_flag;
|
|
|
|
short pnum;
|
|
|
|
int min_dist,dist,a,b,c;
|
|
|
|
PLAYERp pp;
|
|
|
|
|
|
|
|
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
|
|
|
{
|
|
|
|
|
2020-05-22 12:11:03 +00:00
|
|
|
if (SO_EMPTY(sop))
|
2015-05-19 21:54:34 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
riding = false;
|
2015-05-19 21:54:34 +00:00
|
|
|
min_dist = 999999;
|
|
|
|
|
|
|
|
TRAVERSE_CONNECT(pnum)
|
|
|
|
{
|
|
|
|
pp = &Player[pnum];
|
|
|
|
|
|
|
|
if (pp->sop_riding == sop)
|
|
|
|
{
|
2020-09-09 17:52:52 +00:00
|
|
|
riding = true;
|
2021-07-10 12:25:18 +00:00
|
|
|
pp->sop_riding = nullptr;
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DISTANCE(pp->posx, pp->posy, sop->xmid, sop->ymid, dist, a, b, c);
|
|
|
|
if (dist < min_dist)
|
|
|
|
min_dist = dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sop->Animator)
|
|
|
|
{
|
|
|
|
(*sop->Animator)(sop);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// force sync SOs to be updated regularly
|
|
|
|
if ((sync_flag = TEST(sop->flags, SOBJ_SYNC1|SOBJ_SYNC2)) != 0)
|
|
|
|
{
|
|
|
|
if (sync_flag == SOBJ_SYNC1)
|
|
|
|
MoveSectorObjects(sop, synctics);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (MoveSkip2 == 0)
|
|
|
|
MoveSectorObjects(sop, synctics*2);
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (riding)
|
|
|
|
{
|
|
|
|
// if riding move smoothly
|
|
|
|
// update every time
|
|
|
|
MoveSectorObjects(sop, synctics);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (min_dist < 15000)
|
|
|
|
{
|
|
|
|
// if close update every other time
|
|
|
|
if (MoveSkip2 == 0)
|
|
|
|
MoveSectorObjects(sop, synctics * 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if further update every 4th time
|
|
|
|
if (MoveSkip4 == 0)
|
|
|
|
MoveSectorObjects(sop, synctics * 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DoPanning();
|
|
|
|
DoLighting();
|
|
|
|
DoSineWaveFloor();
|
|
|
|
DoSineWaveWall();
|
|
|
|
DoSpringBoardDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#include "saveable.h"
|
|
|
|
|
|
|
|
static saveable_code saveable_sector_code[] =
|
|
|
|
{
|
|
|
|
SAVE_CODE(DoSpawnSpot),
|
|
|
|
};
|
|
|
|
|
|
|
|
saveable_module saveable_sector =
|
|
|
|
{
|
|
|
|
// code
|
|
|
|
saveable_sector_code,
|
|
|
|
SIZ(saveable_sector_code),
|
|
|
|
|
|
|
|
// data
|
2021-07-10 12:25:18 +00:00
|
|
|
nullptr,
|
2015-05-19 21:54:34 +00:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
END_SW_NS
|