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
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
Original Source: 1996 - Todd Replogle
|
|
|
|
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "ns.h"
|
|
|
|
#include "global.h"
|
2020-07-03 21:56:14 +00:00
|
|
|
#include "names_r.h"
|
2020-10-21 17:14:41 +00:00
|
|
|
#include "dukeactor.h"
|
2021-06-09 21:53:05 +00:00
|
|
|
#include "buildtiles.h"
|
2020-05-08 22:34:48 +00:00
|
|
|
|
|
|
|
BEGIN_DUKE_NS
|
|
|
|
|
2020-10-22 20:31:10 +00:00
|
|
|
void ballreturn(DDukeActor *ball)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-10-22 20:31:10 +00:00
|
|
|
DukeStatIterator it(STAT_BOWLING);
|
|
|
|
while (auto act = it.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
if (act->spr.picnum == RRTILE281 && ball->sector() == act->sector())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2020-10-22 20:31:10 +00:00
|
|
|
DukeStatIterator it2(STAT_BOWLING);
|
|
|
|
while (auto act2 = it2.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act2->spr.picnum == BOWLINGBALLSPOT && act->spr.hitag == act2->spr.hitag)
|
2020-10-22 20:31:10 +00:00
|
|
|
spawn(act2, BOWLINGBALLSPRITE);
|
2021-12-21 17:19:45 +00:00
|
|
|
if (act2->spr.picnum == BOWLINGPINSPOT && act->spr.hitag == act2->spr.hitag && act2->spr.lotag == 0)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
act2->spr.lotag = 100;
|
|
|
|
act2->spr.extra++;
|
2021-11-20 23:33:17 +00:00
|
|
|
pinsectorresetdown(act2->sector());
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
2021-11-18 19:17:47 +00:00
|
|
|
void pinsectorresetdown(sectortype* sec)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-11-18 19:01:33 +00:00
|
|
|
int j = getanimationgoal(anim_ceilingz, sec);
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2020-05-12 11:43:24 +00:00
|
|
|
if (j == -1)
|
|
|
|
{
|
2022-02-02 23:46:04 +00:00
|
|
|
j = sec->int_floorz();
|
2021-11-18 18:20:12 +00:00
|
|
|
setanimation(sec, anim_ceilingz, sec, j, 64);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
2021-11-18 19:17:47 +00:00
|
|
|
int pinsectorresetup(sectortype* sec)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2021-11-18 19:01:33 +00:00
|
|
|
int j = getanimationgoal(anim_ceilingz, sec);
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2020-05-12 11:43:24 +00:00
|
|
|
if (j == -1)
|
|
|
|
{
|
2022-02-02 23:46:04 +00:00
|
|
|
j = nextsectorneighborzptr(sec, sec->int_ceilingz(), Find_CeilingUp | Find_Safe)->int_ceilingz();
|
2021-11-18 18:20:12 +00:00
|
|
|
setanimation(sec, anim_ceilingz, sec, j, 64);
|
2020-05-12 11:43:24 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
2021-11-18 19:17:47 +00:00
|
|
|
int checkpins(sectortype* sect)
|
2020-05-08 22:34:48 +00:00
|
|
|
{
|
2020-05-12 11:43:24 +00:00
|
|
|
int x, y;
|
2021-11-07 08:58:09 +00:00
|
|
|
bool pins[10] = {};
|
|
|
|
int tag = 0;
|
|
|
|
int pin = 0;
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2020-10-22 20:31:10 +00:00
|
|
|
DukeSectIterator it(sect);
|
|
|
|
while (auto a2 = it.Next())
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.picnum == BOWLINGPIN)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
pin++;
|
2021-12-21 17:19:45 +00:00
|
|
|
pins[a2->spr.lotag] = true;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.picnum == BOWLINGPINSPOT)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
tag = a2->spr.hitag;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
|
2020-05-12 11:43:24 +00:00
|
|
|
if (tag)
|
|
|
|
{
|
2021-06-09 21:53:05 +00:00
|
|
|
tag += LANEPICS + 1;
|
|
|
|
TileFiles.tileMakeWritable(tag);
|
|
|
|
tileCopySection(LANEPICS + 1, 0, 0, 128, 64, tag, 0, 0);
|
2021-11-07 08:58:09 +00:00
|
|
|
for (int i = 0; i < 10; i++)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-07 08:58:09 +00:00
|
|
|
if (pins[i])
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
switch (i)
|
|
|
|
{
|
2021-11-14 14:03:50 +00:00
|
|
|
default:
|
2020-05-12 11:43:24 +00:00
|
|
|
case 0:
|
|
|
|
x = 64;
|
|
|
|
y = 48;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
x = 56;
|
|
|
|
y = 40;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
x = 72;
|
|
|
|
y = 40;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
x = 48;
|
|
|
|
y = 32;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
x = 64;
|
|
|
|
y = 32;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
x = 80;
|
|
|
|
y = 32;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
x = 40;
|
|
|
|
y = 24;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
x = 56;
|
|
|
|
y = 24;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
x = 72;
|
|
|
|
y = 24;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
x = 88;
|
|
|
|
y = 24;
|
|
|
|
break;
|
2020-10-22 20:31:10 +00:00
|
|
|
}
|
2021-06-09 21:53:05 +00:00
|
|
|
tileCopySection(LANEPICS, 0, 0, 8, 8, tag, x - 4, y - 10);
|
2020-10-22 20:31:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pin;
|
|
|
|
}
|
|
|
|
|
2021-11-18 19:17:47 +00:00
|
|
|
void resetpins(sectortype* sect)
|
2020-10-22 20:31:10 +00:00
|
|
|
{
|
2021-11-14 12:33:35 +00:00
|
|
|
int i, tag = 0;
|
2020-10-22 20:31:10 +00:00
|
|
|
int x, y;
|
|
|
|
DukeSectIterator it(sect);
|
|
|
|
while (auto a2 = it.Next())
|
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.picnum == BOWLINGPIN)
|
2020-10-22 20:31:10 +00:00
|
|
|
deletesprite(a2);
|
|
|
|
}
|
|
|
|
it.Reset(sect);
|
|
|
|
while (auto a2 = it.Next())
|
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.picnum == 283)
|
2020-10-22 20:31:10 +00:00
|
|
|
{
|
2021-06-09 21:53:05 +00:00
|
|
|
auto spawned = spawn(a2, BOWLINGPIN);
|
2021-11-19 11:32:12 +00:00
|
|
|
if (spawned)
|
2020-10-22 20:31:10 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
spawned->spr.lotag = a2->spr.lotag;
|
|
|
|
if (spawned->spr.lotag == 3 || spawned->spr.lotag == 5)
|
2021-11-19 11:32:12 +00:00
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
spawned->spr.clipdist = (1 + (krand() % 1)) * 16 + 32;
|
2021-11-19 11:32:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
spawned->spr.clipdist = (1 + (krand() % 1)) * 16 + 32;
|
2021-11-19 11:32:12 +00:00
|
|
|
}
|
2022-08-16 21:27:44 +00:00
|
|
|
spawned->add_int_ang(-(((krand() & 32) - (krand() & 64)) & 2047));
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-10-22 20:31:10 +00:00
|
|
|
}
|
2021-12-21 17:19:45 +00:00
|
|
|
if (a2->spr.picnum == 280)
|
|
|
|
tag = a2->spr.hitag;
|
2020-10-22 20:31:10 +00:00
|
|
|
}
|
|
|
|
if (tag)
|
|
|
|
{
|
|
|
|
tag += LANEPICS + 1;
|
2021-06-09 21:53:05 +00:00
|
|
|
TileFiles.tileMakeWritable(tag);
|
2020-10-22 20:31:10 +00:00
|
|
|
tileCopySection(LANEPICS + 1, 0, 0, 128, 64, tag, 0, 0);
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
switch (i)
|
|
|
|
{
|
2021-11-14 14:03:50 +00:00
|
|
|
default:
|
2020-10-22 20:31:10 +00:00
|
|
|
case 0:
|
|
|
|
x = 64;
|
|
|
|
y = 48;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
x = 56;
|
|
|
|
y = 40;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
x = 72;
|
|
|
|
y = 40;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
x = 48;
|
|
|
|
y = 32;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
x = 64;
|
|
|
|
y = 32;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
x = 80;
|
|
|
|
y = 32;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
x = 40;
|
|
|
|
y = 24;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
x = 56;
|
|
|
|
y = 24;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
x = 72;
|
|
|
|
y = 24;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
x = 88;
|
|
|
|
y = 24;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tileCopySection(LANEPICS, 0, 0, 8, 8, tag, x - 4, y - 10);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void resetlanepics(void)
|
|
|
|
{
|
2021-07-25 10:43:03 +00:00
|
|
|
if (!isRR()) return;
|
2020-05-12 11:43:24 +00:00
|
|
|
int x, y;
|
2021-11-07 08:58:09 +00:00
|
|
|
for (int tag = 0; tag < 4; tag++)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
2021-11-07 08:58:09 +00:00
|
|
|
int pic = tag + 1;
|
2020-05-12 11:43:24 +00:00
|
|
|
if (pic == 0) continue;
|
2020-10-22 20:31:10 +00:00
|
|
|
pic += LANEPICS + 1;
|
2021-06-09 21:53:05 +00:00
|
|
|
TileFiles.tileMakeWritable(pic);
|
2020-10-22 20:31:10 +00:00
|
|
|
tileCopySection(LANEPICS + 1, 0, 0, 128, 64, pic, 0, 0);
|
2021-11-07 08:58:09 +00:00
|
|
|
for (int i = 0; i < 10; i++)
|
2020-05-12 11:43:24 +00:00
|
|
|
{
|
|
|
|
switch (i)
|
|
|
|
{
|
2021-11-14 14:03:50 +00:00
|
|
|
default:
|
2020-10-22 20:31:10 +00:00
|
|
|
case 0:
|
|
|
|
x = 64;
|
|
|
|
y = 48;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
x = 56;
|
|
|
|
y = 40;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
x = 72;
|
|
|
|
y = 40;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
x = 48;
|
|
|
|
y = 32;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
x = 64;
|
|
|
|
y = 32;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
x = 80;
|
|
|
|
y = 32;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
x = 40;
|
|
|
|
y = 24;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
x = 56;
|
|
|
|
y = 24;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
x = 72;
|
|
|
|
y = 24;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
x = 88;
|
|
|
|
y = 24;
|
|
|
|
break;
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
2020-10-22 20:31:10 +00:00
|
|
|
tileCopySection(LANEPICS, 0, 0, 8, 8, pic, x - 4, y - 10);
|
2020-05-12 11:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-08 22:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
END_DUKE_NS
|
|
|
|
|