2020-05-08 22:34:48 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
|
|
|
Copyright (C) 2017-2019 Nuke.YKT
|
2020-05-13 14:19:39 +00:00
|
|
|
Copyright (C) 2020 - Christoph Oelckers
|
2020-05-08 22:34:48 +00:00
|
|
|
|
|
|
|
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
|
|
|
|
|
|
|
|
Duke Nukem 3D is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
aint with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
Original Source: 1996 - Todd Replogle
|
|
|
|
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
#include "ns.h"
|
|
|
|
#include "global.h"
|
2020-07-03 21:56:14 +00:00
|
|
|
#include "names_r.h"
|
2020-05-08 22:34:48 +00:00
|
|
|
#include "serializer.h"
|
2020-10-22 16:55:45 +00:00
|
|
|
#include "dukeactor.h"
|
2020-05-08 22:34:48 +00:00
|
|
|
|
|
|
|
BEGIN_DUKE_NS
|
|
|
|
|
|
|
|
static int torchcnt;
|
|
|
|
static int jaildoorcnt;
|
|
|
|
static int minecartcnt;
|
|
|
|
static int lightnincnt;
|
|
|
|
|
2021-11-06 12:01:03 +00:00
|
|
|
static int torchsector[64];
|
2020-05-08 22:34:48 +00:00
|
|
|
static short torchsectorshade[64];
|
|
|
|
static short torchtype[64];
|
|
|
|
|
|
|
|
static short jaildoorsound[32];
|
|
|
|
static int jaildoordrag[32];
|
|
|
|
static int jaildoorspeed[32];
|
|
|
|
static short jaildoorsecthtag[32];
|
|
|
|
static int jaildoordist[32];
|
|
|
|
static short jaildoordir[32];
|
|
|
|
static short jaildooropen[32];
|
2021-11-06 22:49:12 +00:00
|
|
|
static int jaildoorsect[32];
|
2020-05-08 22:34:48 +00:00
|
|
|
|
|
|
|
static short minecartdir[16];
|
|
|
|
static int minecartspeed[16];
|
2021-11-06 22:49:12 +00:00
|
|
|
static int minecartchildsect[16];
|
2020-05-08 22:34:48 +00:00
|
|
|
static short minecartsound[16];
|
|
|
|
static int minecartdist[16];
|
|
|
|
static int minecartdrag[16];
|
|
|
|
static short minecartopen[16];
|
2021-11-06 22:49:12 +00:00
|
|
|
static int minecartsect[16];
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2021-11-06 22:49:12 +00:00
|
|
|
static int lightninsector[64];
|
2020-05-08 22:34:48 +00:00
|
|
|
static short lightninsectorshade[64];
|
|
|
|
|
|
|
|
static uint8_t brightness;
|
|
|
|
|
|
|
|
static int thunderflash;
|
|
|
|
static int thundertime;
|
|
|
|
static int winderflash;
|
|
|
|
static int windertime;
|
|
|
|
|
|
|
|
|
|
|
|
void lava_cleararrays()
|
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
jaildoorcnt = 0;
|
|
|
|
minecartcnt = 0;
|
|
|
|
torchcnt = 0;
|
|
|
|
lightnincnt = 0;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void lava_serialize(FSerializer& arc)
|
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
arc("torchcnt", torchcnt)
|
|
|
|
("jaildoorcnt", jaildoorcnt)
|
|
|
|
("minecartcnt", minecartcnt)
|
|
|
|
("lightnincnt", lightnincnt);
|
|
|
|
|
|
|
|
if (torchcnt)
|
|
|
|
arc.Array("torchsector", torchsector, torchcnt)
|
|
|
|
.Array("torchsectorshade", torchsectorshade, torchcnt)
|
|
|
|
.Array("torchtype", torchtype, torchcnt);
|
|
|
|
|
|
|
|
if (jaildoorcnt)
|
|
|
|
arc.Array("jaildoorsound", jaildoorsound, jaildoorcnt)
|
|
|
|
.Array("jaildoordrag", jaildoordrag, jaildoorcnt)
|
|
|
|
.Array("jaildoorspeed", jaildoorspeed, jaildoorcnt)
|
|
|
|
.Array("jaildoorsecthtag", jaildoorsecthtag, jaildoorcnt)
|
|
|
|
.Array("jaildoordist", jaildoordist, jaildoorcnt)
|
|
|
|
.Array("jaildoordir", jaildoordir, jaildoorcnt)
|
|
|
|
.Array("jaildooropen", jaildooropen, jaildoorcnt)
|
|
|
|
.Array("jaildoorsect", jaildoorsect, jaildoorcnt);
|
|
|
|
|
|
|
|
if (minecartcnt)
|
|
|
|
arc.Array("minecartdir", minecartdir, minecartcnt)
|
|
|
|
.Array("minecartspeed", minecartspeed, minecartcnt)
|
|
|
|
.Array("minecartchildsect", minecartchildsect, minecartcnt)
|
|
|
|
.Array("minecartsound", minecartsound, minecartcnt)
|
|
|
|
.Array("minecartdist", minecartdist, minecartcnt)
|
|
|
|
.Array("minecartdrag", minecartdrag, minecartcnt)
|
|
|
|
.Array("minecartopen", minecartopen, minecartcnt)
|
|
|
|
.Array("minecartsect", minecartsect, minecartcnt);
|
|
|
|
|
|
|
|
if (lightnincnt)
|
|
|
|
arc.Array("lightninsector", lightninsector, lightnincnt)
|
|
|
|
.Array("lightninsectorshade", lightninsectorshade, lightnincnt);
|
|
|
|
|
|
|
|
arc("brightness", brightness)
|
|
|
|
("thunderflash", thunderflash)
|
|
|
|
("thundertime", thundertime)
|
|
|
|
("winderflash", winderflash)
|
|
|
|
("windertime", windertime);
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
2020-10-22 16:55:45 +00:00
|
|
|
void addtorch(spritetype* s)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
if (torchcnt >= 64)
|
|
|
|
I_Error("Too many torch effects");
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2020-10-22 16:55:45 +00:00
|
|
|
torchsector[torchcnt] = s->sectnum;
|
2021-11-06 12:47:06 +00:00
|
|
|
torchsectorshade[torchcnt] = s->sector()->floorshade;
|
2020-10-22 16:55:45 +00:00
|
|
|
torchtype[torchcnt] = s->lotag;
|
2020-05-12 11:43:24 +00:00
|
|
|
torchcnt++;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
2020-10-22 16:55:45 +00:00
|
|
|
void addlightning(spritetype* s)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
if (lightnincnt >= 64)
|
|
|
|
I_Error("Too many lightnin effects");
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2020-10-22 16:55:45 +00:00
|
|
|
lightninsector[lightnincnt] = s->sectnum;
|
2021-11-06 12:47:06 +00:00
|
|
|
lightninsectorshade[lightnincnt] = s->sector()->floorshade;
|
2020-05-12 11:43:24 +00:00
|
|
|
lightnincnt++;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void addjaildoor(int p1, int p2, int iht, int jlt, int p3, int j)
|
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
if (jaildoorcnt >= 32)
|
|
|
|
I_Error("Too many jaildoor sectors");
|
|
|
|
|
2020-10-18 10:10:46 +00:00
|
|
|
if (jlt != 10 && jlt != 20 && jlt != 30 && jlt != 40)
|
|
|
|
{
|
2020-10-22 16:55:45 +00:00
|
|
|
Printf(PRINT_HIGH, "Bad direction %d for jail door with tag %d\n", jlt, iht);
|
2020-10-18 10:10:46 +00:00
|
|
|
return; // wouldn't work so let's skip it.
|
|
|
|
}
|
|
|
|
|
2020-05-12 11:43:24 +00:00
|
|
|
jaildoordist[jaildoorcnt] = p1;
|
|
|
|
jaildoorspeed[jaildoorcnt] = p2;
|
|
|
|
jaildoorsecthtag[jaildoorcnt] = iht;
|
|
|
|
jaildoorsect[jaildoorcnt] = j;
|
|
|
|
jaildoordrag[jaildoorcnt] = 0;
|
|
|
|
jaildooropen[jaildoorcnt] = 0;
|
|
|
|
jaildoordir[jaildoorcnt] = jlt;
|
|
|
|
jaildoorsound[jaildoorcnt] = p3;
|
|
|
|
jaildoorcnt++;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void addminecart(int p1, int p2, int i, int iht, int p3, int childsectnum)
|
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
if (minecartcnt >= 16)
|
2020-07-03 22:32:09 +00:00
|
|
|
I_Error("Too many minecart sectors");
|
2020-05-12 11:43:24 +00:00
|
|
|
minecartdist[minecartcnt] = p1;
|
|
|
|
minecartspeed[minecartcnt] = p2;
|
|
|
|
minecartsect[minecartcnt] = i;
|
|
|
|
minecartdir[minecartcnt] = sector[i].hitag;
|
|
|
|
minecartdrag[minecartcnt] = p1;
|
|
|
|
minecartopen[minecartcnt] = 1;
|
|
|
|
minecartsound[minecartcnt] = p3;
|
|
|
|
minecartchildsect[minecartcnt] = childsectnum;
|
|
|
|
minecartcnt++;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void dotorch(void)
|
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
int ds;
|
2021-11-07 15:58:48 +00:00
|
|
|
uint8_t shade;
|
2020-05-12 11:43:24 +00:00
|
|
|
ds = krand()&8;
|
|
|
|
for (int i = 0; i < torchcnt; i++)
|
|
|
|
{
|
2021-11-06 12:01:03 +00:00
|
|
|
auto sect = §or[torchsector[i]];
|
2020-05-12 11:43:24 +00:00
|
|
|
shade = torchsectorshade[i] - ds;
|
|
|
|
switch (torchtype[i])
|
|
|
|
{
|
|
|
|
case 0:
|
2021-11-06 12:01:03 +00:00
|
|
|
sect->floorshade = shade;
|
|
|
|
sect->ceilingshade = shade;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-11-06 12:01:03 +00:00
|
|
|
sect->ceilingshade = shade;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-11-06 12:01:03 +00:00
|
|
|
sect->floorshade = shade;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2021-11-06 12:01:03 +00:00
|
|
|
sect->ceilingshade = shade;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2021-11-06 12:01:03 +00:00
|
|
|
sect->floorshade = shade;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-11-17 21:46:17 +00:00
|
|
|
for (auto& wal : wallsofsector(sect))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-17 21:46:17 +00:00
|
|
|
if (wal.lotag != 1)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
switch (torchtype[i])
|
|
|
|
{
|
|
|
|
case 0:
|
2021-11-17 21:46:17 +00:00
|
|
|
wal.shade = shade;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-11-17 21:46:17 +00:00
|
|
|
wal.shade = shade;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-11-17 21:46:17 +00:00
|
|
|
wal.shade = shade;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-11-17 21:46:17 +00:00
|
|
|
wal.shade = shade;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void dojaildoor(void)
|
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
for (int i = 0; i < jaildoorcnt; i++)
|
|
|
|
{
|
2021-11-17 21:46:17 +00:00
|
|
|
int speed;
|
2021-11-06 22:49:12 +00:00
|
|
|
auto sectp = §or[jaildoorsect[i]];
|
2020-05-12 11:43:24 +00:00
|
|
|
if (numplayers > 2)
|
|
|
|
speed = jaildoorspeed[i];
|
|
|
|
else
|
|
|
|
speed = jaildoorspeed[i];
|
|
|
|
if (speed < 2)
|
|
|
|
speed = 2;
|
|
|
|
if (jaildooropen[i] == 1)
|
|
|
|
{
|
|
|
|
jaildoordrag[i] -= speed;
|
|
|
|
if (jaildoordrag[i] <= 0)
|
|
|
|
{
|
|
|
|
jaildoordrag[i] = 0;
|
|
|
|
jaildooropen[i] = 2;
|
|
|
|
switch (jaildoordir[i])
|
|
|
|
{
|
|
|
|
case 10:
|
|
|
|
jaildoordir[i] = 30;
|
|
|
|
break;
|
|
|
|
case 20:
|
|
|
|
jaildoordir[i] = 40;
|
|
|
|
break;
|
|
|
|
case 30:
|
|
|
|
jaildoordir[i] = 10;
|
|
|
|
break;
|
|
|
|
case 40:
|
|
|
|
jaildoordir[i] = 20;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-17 21:46:17 +00:00
|
|
|
for (auto& wal : wallsofsector(sectp))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-17 21:46:17 +00:00
|
|
|
int x = wal.x;
|
|
|
|
int y = wal.y;
|
2020-05-12 11:43:24 +00:00
|
|
|
switch (jaildoordir[i])
|
|
|
|
{
|
|
|
|
case 10:
|
2020-10-18 10:10:46 +00:00
|
|
|
y += speed;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 20:
|
2020-10-18 10:10:46 +00:00
|
|
|
x -= speed;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 30:
|
2020-10-18 10:10:46 +00:00
|
|
|
y -= speed;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 40:
|
2020-10-18 10:10:46 +00:00
|
|
|
x += speed;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-11-17 21:46:17 +00:00
|
|
|
dragpoint(&wal, x, y);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (jaildooropen[i] == 3)
|
|
|
|
{
|
|
|
|
jaildoordrag[i] -= speed;
|
|
|
|
if (jaildoordrag[i] <= 0)
|
|
|
|
{
|
|
|
|
jaildoordrag[i] = 0;
|
|
|
|
jaildooropen[i] = 0;
|
|
|
|
switch (jaildoordir[i])
|
|
|
|
{
|
|
|
|
case 10:
|
|
|
|
jaildoordir[i] = 30;
|
|
|
|
break;
|
|
|
|
case 20:
|
|
|
|
jaildoordir[i] = 40;
|
|
|
|
break;
|
|
|
|
case 30:
|
|
|
|
jaildoordir[i] = 10;
|
|
|
|
break;
|
|
|
|
case 40:
|
|
|
|
jaildoordir[i] = 20;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-17 21:46:17 +00:00
|
|
|
for (auto& wal : wallsofsector(sectp))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-17 21:46:17 +00:00
|
|
|
int x, y;
|
2020-05-12 11:43:24 +00:00
|
|
|
switch (jaildoordir[i])
|
|
|
|
{
|
2021-11-14 12:33:35 +00:00
|
|
|
default: // make case of bad parameters well defined.
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x;
|
|
|
|
y = wal.y;
|
2021-11-14 12:33:35 +00:00
|
|
|
break;
|
2020-05-12 11:43:24 +00:00
|
|
|
case 10:
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x;
|
|
|
|
y = wal.y + speed;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 20:
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x - speed;
|
|
|
|
y = wal.y;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 30:
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x;
|
|
|
|
y = wal.y - speed;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 40:
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x + speed;
|
|
|
|
y = wal.y;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-11-17 21:46:17 +00:00
|
|
|
dragpoint(&wal, x, y);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void moveminecart(void)
|
|
|
|
{
|
2021-11-07 15:58:48 +00:00
|
|
|
int i;
|
|
|
|
int csect;
|
2020-05-12 11:43:24 +00:00
|
|
|
int speed;
|
|
|
|
int y;
|
|
|
|
int x;
|
|
|
|
int cx;
|
|
|
|
int cy;
|
|
|
|
int max_x;
|
|
|
|
int min_y;
|
|
|
|
int max_y;
|
|
|
|
int min_x;
|
|
|
|
for (i = 0; i < minecartcnt; i++)
|
|
|
|
{
|
2021-11-06 22:49:12 +00:00
|
|
|
auto sectp = §or[minecartsect[i]];
|
2020-05-12 11:43:24 +00:00
|
|
|
speed = minecartspeed[i];
|
|
|
|
if (speed < 2)
|
|
|
|
speed = 2;
|
|
|
|
|
|
|
|
if (minecartopen[i] == 1)
|
|
|
|
{
|
|
|
|
minecartdrag[i] -= speed;
|
|
|
|
if (minecartdrag[i] <= 0)
|
|
|
|
{
|
|
|
|
minecartdrag[i] = minecartdist[i];
|
|
|
|
minecartopen[i] = 2;
|
|
|
|
switch (minecartdir[i])
|
|
|
|
{
|
|
|
|
case 10:
|
|
|
|
minecartdir[i] = 30;
|
|
|
|
break;
|
|
|
|
case 20:
|
|
|
|
minecartdir[i] = 40;
|
|
|
|
break;
|
|
|
|
case 30:
|
|
|
|
minecartdir[i] = 10;
|
|
|
|
break;
|
|
|
|
case 40:
|
|
|
|
minecartdir[i] = 20;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-17 21:46:17 +00:00
|
|
|
for (auto& wal : wallsofsector(sectp))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
switch (minecartdir[i])
|
|
|
|
{
|
2021-11-14 12:33:35 +00:00
|
|
|
default: // make case of bad parameters well defined.
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x;
|
|
|
|
y = wal.y;
|
2021-11-14 12:33:35 +00:00
|
|
|
break;
|
2020-05-12 11:43:24 +00:00
|
|
|
case 10:
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x;
|
|
|
|
y = wal.y + speed;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 20:
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x - speed;
|
|
|
|
y = wal.y;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 30:
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x;
|
|
|
|
y = wal.y - speed;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 40:
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x + speed;
|
|
|
|
y = wal.y;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-11-17 21:46:17 +00:00
|
|
|
dragpoint(&wal, x, y);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (minecartopen[i] == 2)
|
|
|
|
{
|
|
|
|
minecartdrag[i] -= speed;
|
|
|
|
if (minecartdrag[i] <= 0)
|
|
|
|
{
|
|
|
|
minecartdrag[i] = minecartdist[i];
|
|
|
|
minecartopen[i] = 1;
|
|
|
|
switch (minecartdir[i])
|
|
|
|
{
|
|
|
|
case 10:
|
|
|
|
minecartdir[i] = 30;
|
|
|
|
break;
|
|
|
|
case 20:
|
|
|
|
minecartdir[i] = 40;
|
|
|
|
break;
|
|
|
|
case 30:
|
|
|
|
minecartdir[i] = 10;
|
|
|
|
break;
|
|
|
|
case 40:
|
|
|
|
minecartdir[i] = 20;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-17 21:46:17 +00:00
|
|
|
for (auto& wal : wallsofsector(sectp))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
switch (minecartdir[i])
|
|
|
|
{
|
2021-11-14 14:03:50 +00:00
|
|
|
default: // make case of bad parameters well defined.
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x;
|
|
|
|
y = wal.y;
|
2021-11-14 14:03:50 +00:00
|
|
|
break;
|
2020-05-12 11:43:24 +00:00
|
|
|
case 10:
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x;
|
|
|
|
y = wal.y + speed;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 20:
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x - speed;
|
|
|
|
y = wal.y;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 30:
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x;
|
|
|
|
y = wal.y - speed;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
case 40:
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x + speed;
|
|
|
|
y = wal.y;
|
2020-05-12 11:43:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-11-17 21:46:17 +00:00
|
|
|
dragpoint(&wal, x, y);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
csect = minecartchildsect[i];
|
|
|
|
max_x = max_y = -0x20000;
|
|
|
|
min_x = min_y = 0x20000;
|
2021-11-17 21:46:17 +00:00
|
|
|
for (auto& wal : wallsofsector(csect))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-17 21:46:17 +00:00
|
|
|
x = wal.x;
|
|
|
|
y = wal.y;
|
2020-05-12 11:43:24 +00:00
|
|
|
if (x > max_x)
|
|
|
|
max_x = x;
|
|
|
|
if (y > max_y)
|
|
|
|
max_y = y;
|
|
|
|
if (x < min_x)
|
|
|
|
min_x = x;
|
|
|
|
if (y < min_y)
|
|
|
|
min_y = y;
|
|
|
|
}
|
|
|
|
cx = (max_x + min_x) >> 1;
|
|
|
|
cy = (max_y + min_y) >> 1;
|
2020-10-22 16:55:45 +00:00
|
|
|
DukeSectIterator it(csect);
|
|
|
|
while (auto a2 = it.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-04-15 17:21:43 +00:00
|
|
|
auto sj = a2->s;
|
2020-10-22 16:55:45 +00:00
|
|
|
if (badguy(sj))
|
|
|
|
setsprite(a2, cx, cy, sj->z);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void operatejaildoors(int hitag)
|
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
for (int i = 0; i < jaildoorcnt; i++)
|
|
|
|
{
|
|
|
|
if (jaildoorsecthtag[i] == hitag)
|
|
|
|
{
|
|
|
|
if (jaildooropen[i] == 0)
|
|
|
|
{
|
|
|
|
jaildooropen[i] = 1;
|
|
|
|
jaildoordrag[i] = jaildoordist[i];
|
|
|
|
if (!isRRRA() || jaildoorsound[i] != 0)
|
2020-11-02 19:23:05 +00:00
|
|
|
S_PlayActorSound(jaildoorsound[i], ps[screenpeek].GetActor());
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
if (jaildooropen[i] == 2)
|
|
|
|
{
|
|
|
|
jaildooropen[i] = 3;
|
|
|
|
jaildoordrag[i] = jaildoordist[i];
|
|
|
|
if (!isRRRA() || jaildoorsound[i] != 0)
|
2020-11-02 19:23:05 +00:00
|
|
|
S_PlayActorSound(jaildoorsound[i], ps[screenpeek].GetActor());
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void thunder(void)
|
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
struct player_struct* p;
|
|
|
|
int r1, r2;
|
2021-11-17 21:23:54 +00:00
|
|
|
int i = 0;
|
2021-05-12 15:33:33 +00:00
|
|
|
uint8_t shade;
|
2020-05-12 11:43:24 +00:00
|
|
|
|
|
|
|
p = &ps[screenpeek];
|
|
|
|
|
|
|
|
if (!thunderflash)
|
|
|
|
{
|
2021-05-09 07:05:42 +00:00
|
|
|
if (testgotpic(RRTILE2577, true))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
g_visibility = 256; // this is an engine variable
|
|
|
|
if (krand() > 65000)
|
|
|
|
{
|
|
|
|
thunderflash = 1;
|
|
|
|
thundertime = 256;
|
2020-07-25 07:32:54 +00:00
|
|
|
S_PlaySound(351 + (rand() % 3));
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_visibility = p->visibility;
|
|
|
|
brightness = ud.brightness >> 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
thundertime -= 4;
|
|
|
|
if (thundertime < 0)
|
|
|
|
{
|
|
|
|
thunderflash = 0;
|
|
|
|
brightness = ud.brightness >> 2;
|
2020-07-20 21:07:44 +00:00
|
|
|
thunder_brightness = brightness;
|
2020-05-12 11:43:24 +00:00
|
|
|
g_visibility = p->visibility;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!winderflash)
|
|
|
|
{
|
2021-05-09 07:05:42 +00:00
|
|
|
if (testgotpic(RRTILE2562, true))
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
if (krand() > 65000)
|
|
|
|
{
|
|
|
|
winderflash = 1;
|
|
|
|
windertime = 128;
|
2020-07-25 07:32:54 +00:00
|
|
|
S_PlaySound(351 + (rand() % 3));
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
windertime -= 4;
|
|
|
|
if (windertime < 0)
|
|
|
|
{
|
|
|
|
winderflash = 0;
|
|
|
|
for (i = 0; i < lightnincnt; i++)
|
|
|
|
{
|
2021-11-06 22:49:12 +00:00
|
|
|
auto sectp = §or[lightninsector[i]];
|
|
|
|
sectp->floorshade = (int8_t)lightninsectorshade[i];
|
|
|
|
sectp->ceilingshade = (int8_t)lightninsectorshade[i];
|
2021-11-17 21:46:17 +00:00
|
|
|
for (auto& wal : wallsofsector(sectp))
|
|
|
|
wal.shade = (int8_t)lightninsectorshade[i];
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (thunderflash == 1)
|
|
|
|
{
|
|
|
|
r1 = krand() & 4;
|
|
|
|
brightness += r1;
|
|
|
|
switch (r1)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
g_visibility = 2048;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
g_visibility = 1024;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
g_visibility = 512;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
g_visibility = 256;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_visibility = 4096;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (brightness > 8)
|
|
|
|
brightness = 0;
|
2020-07-20 21:07:44 +00:00
|
|
|
thunder_brightness = brightness;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
if (winderflash == 1)
|
|
|
|
{
|
|
|
|
r2 = krand() & 8;
|
|
|
|
shade = torchsectorshade[i] + r2;
|
|
|
|
for (i = 0; i < lightnincnt; i++)
|
|
|
|
{
|
2021-11-06 22:49:12 +00:00
|
|
|
auto sectp = §or[lightninsector[i]];
|
|
|
|
sectp->floorshade = lightninsectorshade[i] - shade;
|
|
|
|
sectp->ceilingshade = lightninsectorshade[i] - shade;
|
2021-11-17 21:46:17 +00:00
|
|
|
for (auto& wal : wallsofsector(sectp))
|
|
|
|
wal.shade = lightninsectorshade[i] - shade;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
END_DUKE_NS
|