2019-11-20 16:21:32 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 sirlemonhead, Nuke.YKT
|
|
|
|
This file is part of PCExhumed.
|
|
|
|
PCExhumed is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-11-22 23:11:37 +00:00
|
|
|
#include "ns.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "engine.h"
|
|
|
|
#include "exhumed.h"
|
2020-08-18 07:52:08 +00:00
|
|
|
#include "aistuff.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "player.h"
|
|
|
|
#include "view.h"
|
|
|
|
#include "status.h"
|
|
|
|
#include "sound.h"
|
2020-08-23 14:24:54 +00:00
|
|
|
#include "mapinfo.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
2020-08-18 08:28:19 +00:00
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2021-11-07 22:52:45 +00:00
|
|
|
int NearSector[kMaxSectors] = { 0 };
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
short nPushBlocks;
|
|
|
|
|
|
|
|
// TODO - moveme?
|
|
|
|
short overridesect;
|
2021-11-07 22:52:45 +00:00
|
|
|
int NearCount = -1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-17 07:01:17 +00:00
|
|
|
DExhumedActor* nBodySprite[50];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-21 21:41:54 +00:00
|
|
|
int sprceiling, sprfloor;
|
|
|
|
Collision loHit, hiHit;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-10-11 11:14:32 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
kMaxPushBlocks = 100,
|
|
|
|
kMaxMoveChunks = 75
|
|
|
|
};
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
// think this belongs in init.c?
|
|
|
|
BlockInfo sBlockInfo[kMaxPushBlocks];
|
|
|
|
|
2021-09-17 07:24:14 +00:00
|
|
|
DExhumedActor *nChunkSprite[kMaxMoveChunks];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-29 23:51:56 +00:00
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, BlockInfo& w, BlockInfo* def)
|
|
|
|
{
|
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc("at8", w.field_8)
|
2021-10-22 15:45:06 +00:00
|
|
|
("sprite", w.pActor)
|
2020-11-29 23:51:56 +00:00
|
|
|
("x", w.x)
|
|
|
|
("y", w.y)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-29 23:51:56 +00:00
|
|
|
void SerializeMove(FSerializer& arc)
|
|
|
|
{
|
|
|
|
if (arc.BeginObject("move"))
|
|
|
|
{
|
|
|
|
arc("nearcount", NearCount)
|
|
|
|
.Array("nearsector", NearSector, NearCount)
|
|
|
|
("pushcount", nPushBlocks)
|
|
|
|
.Array("blocks", sBlockInfo, nPushBlocks)
|
|
|
|
("chunkcount", nCurChunkNum)
|
|
|
|
.Array("chunks", nChunkSprite, kMaxMoveChunks)
|
|
|
|
("overridesect", overridesect)
|
|
|
|
.Array("bodysprite", nBodySprite, 50)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
}
|
2019-12-26 21:00:04 +00:00
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
signed int lsqrt(int a1)
|
|
|
|
{
|
2020-02-04 21:45:10 +00:00
|
|
|
int v1;
|
|
|
|
int v2;
|
|
|
|
signed int result;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
v1 = a1;
|
|
|
|
v2 = a1 - 0x40000000;
|
2020-02-04 21:45:10 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
result = 0;
|
2020-02-04 21:45:10 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (v2 >= 0)
|
|
|
|
{
|
2020-02-04 21:45:10 +00:00
|
|
|
result = 32768;
|
2019-08-31 07:47:15 +00:00
|
|
|
v1 = v2;
|
|
|
|
}
|
|
|
|
if (v1 - ((result << 15) + 0x10000000) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= (result << 15) + 0x10000000;
|
2020-02-04 21:45:10 +00:00
|
|
|
result += 16384;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
if (v1 - ((result << 14) + 0x4000000) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= (result << 14) + 0x4000000;
|
2020-02-04 21:45:10 +00:00
|
|
|
result += 8192;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
if (v1 - ((result << 13) + 0x1000000) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= (result << 13) + 0x1000000;
|
|
|
|
result += 4096;
|
|
|
|
}
|
|
|
|
if (v1 - ((result << 12) + 0x400000) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= (result << 12) + 0x400000;
|
|
|
|
result += 2048;
|
|
|
|
}
|
|
|
|
if (v1 - ((result << 11) + 0x100000) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= (result << 11) + 0x100000;
|
|
|
|
result += 1024;
|
|
|
|
}
|
|
|
|
if (v1 - ((result << 10) + 0x40000) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= (result << 10) + 0x40000;
|
|
|
|
result += 512;
|
|
|
|
}
|
|
|
|
if (v1 - ((result << 9) + 0x10000) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= (result << 9) + 0x10000;
|
|
|
|
result += 256;
|
|
|
|
}
|
|
|
|
if (v1 - ((result << 8) + 0x4000) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= (result << 8) + 0x4000;
|
|
|
|
result += 128;
|
|
|
|
}
|
|
|
|
if (v1 - ((result << 7) + 4096) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= (result << 7) + 4096;
|
|
|
|
result += 64;
|
|
|
|
}
|
|
|
|
if (v1 - ((result << 6) + 1024) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= (result << 6) + 1024;
|
|
|
|
result += 32;
|
|
|
|
}
|
|
|
|
if (v1 - (32 * result + 256) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= 32 * result + 256;
|
|
|
|
result += 16;
|
|
|
|
}
|
|
|
|
if (v1 - (16 * result + 64) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= 16 * result + 64;
|
|
|
|
result += 8;
|
|
|
|
}
|
|
|
|
if (v1 - (8 * result + 16) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= 8 * result + 16;
|
|
|
|
result += 4;
|
|
|
|
}
|
|
|
|
if (v1 - (4 * result + 4) >= 0)
|
|
|
|
{
|
|
|
|
v1 -= 4 * result + 4;
|
|
|
|
result += 2;
|
|
|
|
}
|
|
|
|
if (v1 - (2 * result + 1) >= 0)
|
2020-02-04 21:45:10 +00:00
|
|
|
result += 1;
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return result;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MoveThings()
|
|
|
|
{
|
2020-08-28 07:07:36 +00:00
|
|
|
thinktime.Reset();
|
|
|
|
thinktime.Clock();
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
UndoFlashes();
|
|
|
|
DoLights();
|
|
|
|
|
|
|
|
if (nFreeze)
|
|
|
|
{
|
|
|
|
if (nFreeze == 1 || nFreeze == 2) {
|
|
|
|
DoSpiritHead();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-28 07:07:36 +00:00
|
|
|
actortime.Reset();
|
|
|
|
actortime.Clock();
|
2019-08-31 07:47:15 +00:00
|
|
|
runlist_ExecObjects();
|
|
|
|
runlist_CleanRunRecs();
|
2020-08-28 07:07:36 +00:00
|
|
|
actortime.Unclock();
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DoBubbleMachines();
|
|
|
|
DoDrips();
|
|
|
|
DoMovingSects();
|
|
|
|
DoRegenerates();
|
|
|
|
|
2021-05-02 13:54:19 +00:00
|
|
|
if (currentLevel->gameflags & LEVEL_EX_COUNTDOWN)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
DoFinale();
|
|
|
|
if (lCountDown < 1800 && nDronePitch < 2400 && !lFinaleStart)
|
|
|
|
{
|
|
|
|
nDronePitch += 64;
|
|
|
|
BendAmbientSound();
|
|
|
|
}
|
|
|
|
}
|
2020-08-28 07:07:36 +00:00
|
|
|
|
|
|
|
thinktime.Unclock();
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResetMoveFifo()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
movefifoend = 0;
|
|
|
|
movefifopos = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// not used
|
|
|
|
void clipwall()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void BuildNear(int x, int y, int walldist, int nSector)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
NearSector[0] = nSector;
|
|
|
|
NearCount = 1;
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (i < NearCount)
|
|
|
|
{
|
2021-11-09 16:27:54 +00:00
|
|
|
int nSector =NearSector[i];
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-11-09 16:32:50 +00:00
|
|
|
int nWall = sector[nSector].wallptr;
|
|
|
|
int nWallCount = sector[nSector].wallnum;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
nWallCount--;
|
|
|
|
if (nWallCount < 0)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
short nNextSector = wall[nWall].nextsector;
|
|
|
|
|
|
|
|
if (nNextSector >= 0)
|
|
|
|
{
|
|
|
|
int j = 0;
|
|
|
|
for (; j < NearCount; j++)
|
|
|
|
{
|
|
|
|
// loc_14F4D:
|
|
|
|
if (nNextSector == NearSector[j])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j >= NearCount)
|
|
|
|
{
|
|
|
|
vec2_t pos = { x, y };
|
|
|
|
if (clipinsidebox(&pos, nWall, walldist))
|
|
|
|
{
|
|
|
|
NearSector[NearCount] = wall[nWall].nextsector;
|
|
|
|
NearCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nWall++;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-09-20 06:26:39 +00:00
|
|
|
int BelowNear(DExhumedActor* pActor)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-09-20 06:26:39 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2021-11-09 16:27:54 +00:00
|
|
|
int nSector =pSprite->sectnum;
|
2021-09-06 06:33:02 +00:00
|
|
|
int z = pSprite->z;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 21:41:54 +00:00
|
|
|
int z2;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 21:41:54 +00:00
|
|
|
if (loHit.type == kHitSprite)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-21 21:41:54 +00:00
|
|
|
z2 = loHit.actor->s().z;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
z2 = sector[nSector].floorz + SectDepth[nSector];
|
|
|
|
|
|
|
|
if (NearCount > 0)
|
|
|
|
{
|
|
|
|
short edx;
|
|
|
|
|
|
|
|
for (int i = 0; i < NearCount; i++)
|
|
|
|
{
|
|
|
|
int nSect2 = NearSector[i];
|
|
|
|
|
|
|
|
while (nSect2 >= 0)
|
|
|
|
{
|
|
|
|
edx = nSect2;
|
|
|
|
nSect2 = SectBelow[nSect2];
|
|
|
|
}
|
|
|
|
|
|
|
|
int ecx = sector[edx].floorz + SectDepth[edx];
|
|
|
|
int eax = ecx - z;
|
|
|
|
|
|
|
|
if (eax < 0 && eax >= -5120)
|
|
|
|
{
|
|
|
|
z2 = ecx;
|
|
|
|
nSector = edx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
if (z2 < pSprite->z)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->z = z2;
|
2019-08-31 07:47:15 +00:00
|
|
|
overridesect = nSector;
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->zvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-08-18 08:28:19 +00:00
|
|
|
bTouchFloor = true;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 21:41:54 +00:00
|
|
|
return kHitAux2;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 21:41:54 +00:00
|
|
|
Collision movespritez(DExhumedActor* pActor, int z, int height, int, int clipdist)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-21 21:41:54 +00:00
|
|
|
spritetype* pSprite = &pActor->s();
|
2021-11-09 16:27:54 +00:00
|
|
|
int nSector =pSprite->sectnum;
|
2019-08-31 07:47:15 +00:00
|
|
|
assert(nSector >= 0 && nSector < kMaxSectors);
|
|
|
|
|
|
|
|
overridesect = nSector;
|
2019-09-25 21:16:12 +00:00
|
|
|
short edi = nSector;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
// backup cstat
|
2019-09-25 21:16:12 +00:00
|
|
|
uint16_t cstat = pSprite->cstat;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
pSprite->cstat &= ~CSTAT_SPRITE_BLOCK;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 21:41:54 +00:00
|
|
|
Collision nRet(0);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
short nSectFlags = SectFlag[nSector];
|
|
|
|
|
|
|
|
if (nSectFlags & kSectUnderwater) {
|
2019-08-31 07:47:15 +00:00
|
|
|
z >>= 1;
|
|
|
|
}
|
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
int spriteZ = pSprite->z;
|
2019-08-31 07:47:15 +00:00
|
|
|
int floorZ = sector[nSector].floorz;
|
|
|
|
|
|
|
|
int ebp = spriteZ + z;
|
|
|
|
int eax = sector[nSector].ceilingz + (height >> 1);
|
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
if ((nSectFlags & kSectUnderwater) && ebp < eax) {
|
2019-08-31 07:47:15 +00:00
|
|
|
ebp = eax;
|
|
|
|
}
|
|
|
|
|
|
|
|
// loc_151E7:
|
2021-11-08 23:24:04 +00:00
|
|
|
while (ebp > pSprite->sector()->floorz && SectBelow[pSprite->sectnum] >= 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2019-09-25 21:16:12 +00:00
|
|
|
edi = SectBelow[pSprite->sectnum];
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 21:41:54 +00:00
|
|
|
ChangeActorSect(pActor, edi);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
if (edi != nSector)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2019-09-25 21:16:12 +00:00
|
|
|
pSprite->z = ebp;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (SectFlag[edi] & kSectUnderwater)
|
|
|
|
{
|
2021-10-21 21:41:54 +00:00
|
|
|
if (pActor == PlayerList[nLocalPlayer].Actor()) {
|
|
|
|
D3PlayFX(StaticSound[kSound2], pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
if (pSprite->statnum <= 107) {
|
|
|
|
pSprite->hitag = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-25 21:16:12 +00:00
|
|
|
else
|
|
|
|
{
|
2021-11-08 23:24:04 +00:00
|
|
|
while ((ebp < pSprite->sector()->ceilingz) && (SectAbove[pSprite->sectnum] >= 0))
|
2019-09-25 21:16:12 +00:00
|
|
|
{
|
|
|
|
edi = SectAbove[pSprite->sectnum];
|
|
|
|
|
2021-10-21 21:41:54 +00:00
|
|
|
ChangeActorSect(pActor, edi);
|
2019-09-25 21:16:12 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
// This function will keep the player from falling off cliffs when you're too close to the edge.
|
|
|
|
// This function finds the highest and lowest z coordinates that your clipping BOX can get to.
|
2021-10-21 21:41:54 +00:00
|
|
|
int hihit, lohit;
|
2021-10-30 11:37:43 +00:00
|
|
|
vec3_t pos = pSprite->pos;
|
|
|
|
pos.z -= 256;
|
|
|
|
getzrange(&pSprite->pos, pSprite->sectnum,
|
2019-09-25 21:16:12 +00:00
|
|
|
&sprceiling, &hihit, &sprfloor, &lohit, 128, CLIPMASK0);
|
2021-10-21 21:41:54 +00:00
|
|
|
hiHit.setFromEngine(hihit);
|
|
|
|
loHit.setFromEngine(lohit);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
int mySprfloor = sprfloor;
|
|
|
|
|
2021-10-21 21:41:54 +00:00
|
|
|
if (loHit.type != kHitSprite) {
|
2019-09-25 21:16:12 +00:00
|
|
|
mySprfloor += SectDepth[pSprite->sectnum];
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ebp > mySprfloor)
|
|
|
|
{
|
|
|
|
if (z > 0)
|
|
|
|
{
|
2020-08-18 08:28:19 +00:00
|
|
|
bTouchFloor = true;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 21:41:54 +00:00
|
|
|
if (loHit.type == kHitSprite)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2019-09-25 21:16:12 +00:00
|
|
|
// Path A
|
2021-10-21 21:41:54 +00:00
|
|
|
auto pFloorSprite = &loHit.actor->s();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 21:41:54 +00:00
|
|
|
if (pSprite->statnum == 100 && pFloorSprite->statnum != 0 && pFloorSprite->statnum < 100)
|
2019-09-25 21:16:12 +00:00
|
|
|
{
|
|
|
|
short nDamage = (z >> 9);
|
|
|
|
if (nDamage)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-21 21:41:54 +00:00
|
|
|
runlist_DamageEnemy(loHit.actor, pActor, nDamage << 1);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
pSprite->zvel = -z;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-09-25 21:16:12 +00:00
|
|
|
else
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-21 21:41:54 +00:00
|
|
|
if (pFloorSprite->statnum == 0 || pFloorSprite->statnum > 199)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-21 21:41:54 +00:00
|
|
|
nRet.exbits |= kHitAux2;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-21 21:41:54 +00:00
|
|
|
nRet = loHit;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
pSprite->zvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-09-25 21:16:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Path B
|
|
|
|
if (SectBelow[pSprite->sectnum] == -1)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-21 21:41:54 +00:00
|
|
|
nRet.exbits |= kHitAux2;
|
2019-09-25 21:16:12 +00:00
|
|
|
|
|
|
|
short nSectDamage = SectDamage[pSprite->sectnum];
|
|
|
|
|
|
|
|
if (nSectDamage != 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2019-09-25 21:16:12 +00:00
|
|
|
if (pSprite->hitag < 15)
|
|
|
|
{
|
2021-10-21 21:41:54 +00:00
|
|
|
IgniteSprite(pActor);
|
2019-09-25 21:16:12 +00:00
|
|
|
pSprite->hitag = 20;
|
|
|
|
}
|
|
|
|
nSectDamage >>= 2;
|
|
|
|
nSectDamage = nSectDamage - (nSectDamage>>2);
|
|
|
|
if (nSectDamage) {
|
2021-10-21 21:41:54 +00:00
|
|
|
runlist_DamageEnemy(pActor, nullptr, nSectDamage);
|
2019-09-25 21:16:12 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
pSprite->zvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// loc_1543B:
|
|
|
|
ebp = mySprfloor;
|
2019-09-25 21:16:12 +00:00
|
|
|
pSprite->z = mySprfloor;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-21 21:41:54 +00:00
|
|
|
if ((ebp - height) < sprceiling && (hiHit.type == kHitSprite || SectAbove[pSprite->sectnum] == -1))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
ebp = sprceiling + height;
|
2021-10-21 21:41:54 +00:00
|
|
|
nRet.exbits |= kHitAux1;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (spriteZ <= floorZ && ebp > floorZ)
|
|
|
|
{
|
|
|
|
if ((SectDepth[nSector] != 0) || (edi != nSector && (SectFlag[edi] & kSectUnderwater)))
|
|
|
|
{
|
|
|
|
assert(nSector >= 0 && nSector < kMaxSectors);
|
2021-10-21 21:41:54 +00:00
|
|
|
BuildSplash(pActor, nSector);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
pSprite->cstat = cstat; // restore cstat
|
|
|
|
pSprite->z = ebp;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
if (pSprite->statnum == 100)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2019-09-25 21:16:12 +00:00
|
|
|
BuildNear(pSprite->x, pSprite->y, clipdist + (clipdist / 2), pSprite->sectnum);
|
2021-10-21 21:41:54 +00:00
|
|
|
nRet.exbits |= BelowNear(pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nRet;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 22:31:28 +00:00
|
|
|
int GetActorHeight(DExhumedActor* actor)
|
|
|
|
{
|
|
|
|
return tileHeight(actor->s().picnum) * actor->s().yrepeat * 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
DExhumedActor* insertActor(int sect, int stat)
|
|
|
|
{
|
|
|
|
int ndx = insertsprite(sect, stat);
|
|
|
|
return ndx >= 0 ? &exhumedActors[ndx] : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-21 18:25:15 +00:00
|
|
|
Collision movesprite(DExhumedActor* pActor, int dx, int dy, int dz, int ceildist, int flordist, unsigned int clipmask)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-21 18:25:15 +00:00
|
|
|
spritetype *pSprite = &pActor->s();
|
2020-08-18 08:28:19 +00:00
|
|
|
bTouchFloor = false;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
int x = pSprite->x;
|
|
|
|
int y = pSprite->y;
|
|
|
|
int z = pSprite->z;
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2021-10-21 18:25:15 +00:00
|
|
|
int nSpriteHeight = GetActorHeight(pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
int nClipDist = (int8_t)pSprite->clipdist << 2;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-11-07 17:53:42 +00:00
|
|
|
int nSector = pSprite->sectnum;
|
2019-08-31 07:47:15 +00:00
|
|
|
assert(nSector >= 0 && nSector < kMaxSectors);
|
|
|
|
|
|
|
|
int floorZ = sector[nSector].floorz;
|
|
|
|
|
|
|
|
if ((SectFlag[nSector] & kSectUnderwater) || (floorZ < z))
|
|
|
|
{
|
|
|
|
dx >>= 1;
|
|
|
|
dy >>= 1;
|
|
|
|
}
|
|
|
|
|
2021-10-21 21:41:54 +00:00
|
|
|
Collision nRet = movespritez(pActor, dz, nSpriteHeight, flordist, nClipDist);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
nSector = pSprite->sectnum; // modified in movespritez so re-grab this variable
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
if (pSprite->statnum == 100)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-21 18:25:15 +00:00
|
|
|
short nPlayer = GetPlayerFromActor(pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
int varA = 0;
|
|
|
|
int varB = 0;
|
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
CheckSectorFloor(overridesect, pSprite->z, &varB, &varA);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (varB || varA)
|
|
|
|
{
|
2021-10-21 10:51:16 +00:00
|
|
|
PlayerList[nPlayer].nXDamage = varB;
|
|
|
|
PlayerList[nPlayer].nYDamage = varA;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 10:51:16 +00:00
|
|
|
dx += PlayerList[nPlayer].nXDamage;
|
|
|
|
dy += PlayerList[nPlayer].nYDamage;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-25 21:16:12 +00:00
|
|
|
CheckSectorFloor(overridesect, pSprite->z, &dx, &dy);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-30 10:26:42 +00:00
|
|
|
int colv = clipmove(&pSprite->pos, &nSector, dx, dy, nClipDist, nSpriteHeight, flordist, clipmask);
|
2021-10-21 21:41:54 +00:00
|
|
|
Collision coll(colv);
|
|
|
|
if (coll.type != kHitNone) // originally this or'ed the two values which can create unpredictable bad values in some edge cases.
|
|
|
|
{
|
|
|
|
coll.exbits = nRet.exbits;
|
|
|
|
nRet = coll;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
if ((nSector != pSprite->sectnum) && nSector >= 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-21 21:41:54 +00:00
|
|
|
if (nRet.exbits & kHitAux2) {
|
2019-08-31 07:47:15 +00:00
|
|
|
dz = 0;
|
|
|
|
}
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if ((sector[nSector].floorz - z) < (dz + flordist))
|
|
|
|
{
|
2019-09-25 21:16:12 +00:00
|
|
|
pSprite->x = x;
|
|
|
|
pSprite->y = y;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-21 18:25:15 +00:00
|
|
|
ChangeActorSect(pActor, nSector);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2019-09-25 21:16:12 +00:00
|
|
|
if (pSprite->pal < 5 && !pSprite->hitag)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-11-08 23:24:04 +00:00
|
|
|
pSprite->pal = pSprite->sector()->ceilingpal;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-21 21:41:54 +00:00
|
|
|
return nRet;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-20 22:00:26 +00:00
|
|
|
void Gravity(DExhumedActor* actor)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-20 22:00:26 +00:00
|
|
|
auto pSprite = &actor->s();
|
2021-11-09 16:27:54 +00:00
|
|
|
int nSector =pSprite->sectnum;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (SectFlag[nSector] & kSectUnderwater)
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
if (pSprite->statnum != 100)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
if (pSprite->zvel <= 1024)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
if (pSprite->zvel < 2048) {
|
|
|
|
pSprite->zvel += 512;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->zvel -= 64;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
if (pSprite->zvel > 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->zvel -= 64;
|
|
|
|
if (pSprite->zvel < 0) {
|
|
|
|
pSprite->zvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-06 06:33:02 +00:00
|
|
|
else if (pSprite->zvel < 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->zvel += 64;
|
|
|
|
if (pSprite->zvel > 0) {
|
|
|
|
pSprite->zvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->zvel += 512;
|
|
|
|
if (pSprite->zvel > 16384) {
|
|
|
|
pSprite->zvel = 16384;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 18:25:15 +00:00
|
|
|
Collision MoveCreature(DExhumedActor* pActor)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-21 18:25:15 +00:00
|
|
|
auto pSprite = &pActor->s();
|
|
|
|
return movesprite(pActor, pSprite->xvel << 8, pSprite->yvel << 8, pSprite->zvel, 15360, -5120, CLIPMASK0);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 18:25:15 +00:00
|
|
|
Collision MoveCreatureWithCaution(DExhumedActor* pActor)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-21 18:25:15 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2021-09-06 06:33:02 +00:00
|
|
|
int x = pSprite->x;
|
|
|
|
int y = pSprite->y;
|
|
|
|
int z = pSprite->z;
|
|
|
|
short nSectorPre = pSprite->sectnum;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 18:25:15 +00:00
|
|
|
auto ecx = MoveCreature(pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-11-09 16:27:54 +00:00
|
|
|
int nSector =pSprite->sectnum;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nSector != nSectorPre)
|
|
|
|
{
|
|
|
|
int zDiff = sector[nSectorPre].floorz - sector[nSector].floorz;
|
|
|
|
if (zDiff < 0) {
|
|
|
|
zDiff = -zDiff;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (zDiff > 15360 || (SectFlag[nSector] & kSectUnderwater) || (SectBelow[nSector] > -1 && SectFlag[SectBelow[nSector]]) || SectDamage[nSector])
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->x = x;
|
|
|
|
pSprite->y = y;
|
|
|
|
pSprite->z = z;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 18:25:15 +00:00
|
|
|
ChangeActorSect(pActor, nSectorPre);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->ang = (pSprite->ang + 256) & kAngleMask;
|
|
|
|
pSprite->xvel = bcos(pSprite->ang, -2);
|
|
|
|
pSprite->yvel = bsin(pSprite->ang, -2);
|
2021-10-21 18:25:15 +00:00
|
|
|
return Collision(0);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ecx;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-20 21:02:23 +00:00
|
|
|
int GetAngleToSprite(DExhumedActor* a1, DExhumedActor* a2)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-20 21:02:23 +00:00
|
|
|
if (!a1 || !a2)
|
2019-08-31 07:47:15 +00:00
|
|
|
return -1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-20 21:02:23 +00:00
|
|
|
auto pSprite1 = &a1->s();
|
|
|
|
auto pSprite2 = &a2->s();
|
2021-09-06 06:33:02 +00:00
|
|
|
|
|
|
|
return GetMyAngle(pSprite2->x - pSprite1->x, pSprite2->y - pSprite1->y);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 18:06:49 +00:00
|
|
|
int PlotCourseToSprite(DExhumedActor* pActor1, DExhumedActor* pActor2)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-21 18:06:49 +00:00
|
|
|
if (pActor1 == nullptr || pActor2 == nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
return -1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-21 18:06:49 +00:00
|
|
|
auto pSprite1 = &pActor1->s();
|
|
|
|
auto pSprite2 = &pActor2->s();
|
2021-09-06 06:33:02 +00:00
|
|
|
int x = pSprite2->x - pSprite1->x;
|
|
|
|
int y = pSprite2->y - pSprite1->y;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite1->ang = GetMyAngle(x, y);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-01-04 12:02:00 +00:00
|
|
|
uint32_t x2 = abs(x);
|
|
|
|
uint32_t y2 = abs(y);
|
2020-06-17 19:27:10 +00:00
|
|
|
|
|
|
|
uint32_t diff = x2 * x2 + y2 * y2;
|
|
|
|
|
|
|
|
if (diff > INT_MAX)
|
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__);
|
2020-06-17 19:27:10 +00:00
|
|
|
diff = INT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ksqrt(diff);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 18:06:49 +00:00
|
|
|
DExhumedActor* FindPlayer(DExhumedActor* pActor, int nDistance, bool dontengage)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-21 18:06:49 +00:00
|
|
|
auto pSprite = &pActor->s();
|
|
|
|
int var_18 = !dontengage;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-02-04 21:45:10 +00:00
|
|
|
if (nDistance < 0)
|
|
|
|
nDistance = 100;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
int x = pSprite->x;
|
|
|
|
int y = pSprite->y;
|
2021-11-09 16:27:54 +00:00
|
|
|
int nSector =pSprite->sectnum;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-21 18:06:49 +00:00
|
|
|
int z = pSprite->z - GetActorHeight(pActor);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-02-04 21:45:10 +00:00
|
|
|
nDistance <<= 8;
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2021-10-21 18:06:49 +00:00
|
|
|
DExhumedActor* pPlayerActor = nullptr;
|
2019-08-31 07:47:15 +00:00
|
|
|
int i = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (i >= nTotalPlayers)
|
2021-10-21 18:06:49 +00:00
|
|
|
return nullptr;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-21 18:06:49 +00:00
|
|
|
pPlayerActor = PlayerList[i].Actor();
|
|
|
|
auto pPlayerSprite = &pPlayerActor->s();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-21 18:06:49 +00:00
|
|
|
if ((pPlayerSprite->cstat & 0x101) && (!(pPlayerSprite->cstat & 0x8000)))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-21 18:06:49 +00:00
|
|
|
int v9 = abs(pPlayerSprite->x - x);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-02-04 21:45:10 +00:00
|
|
|
if (v9 < nDistance)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-21 18:06:49 +00:00
|
|
|
int v10 = abs(pPlayerSprite->y - y);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-21 18:06:49 +00:00
|
|
|
if (v10 < nDistance && cansee(pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->z - 7680, pPlayerSprite->sectnum, x, y, z, nSector))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
i++;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (var_18) {
|
2021-10-21 18:06:49 +00:00
|
|
|
PlotCourseToSprite(pActor, pPlayerActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-21 18:06:49 +00:00
|
|
|
return pPlayerActor;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-11-09 16:27:54 +00:00
|
|
|
void CheckSectorFloor(int nSector, int z, int *x, int *y)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSpeed = SectSpeed[nSector];
|
|
|
|
|
|
|
|
if (!nSpeed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
short nFlag = SectFlag[nSector];
|
|
|
|
short nAng = nFlag & kAngleMask;
|
|
|
|
|
|
|
|
if (z >= sector[nSector].floorz)
|
|
|
|
{
|
2020-11-14 08:45:08 +00:00
|
|
|
*x += bcos(nAng, 3) * nSpeed;
|
|
|
|
*y += bsin(nAng, 3) * nSpeed;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else if (nFlag & 0x800)
|
|
|
|
{
|
2020-11-14 08:45:08 +00:00
|
|
|
*x += bcos(nAng, 4) * nSpeed;
|
|
|
|
*y += bsin(nAng, 4) * nSpeed;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 18:06:49 +00:00
|
|
|
int GetUpAngle(DExhumedActor* pActor1, int nVal, DExhumedActor* pActor2, int ecx)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-21 18:06:49 +00:00
|
|
|
auto pSprite1 = &pActor1->s();
|
|
|
|
auto pSprite2 = &pActor2->s();
|
2021-09-06 06:33:02 +00:00
|
|
|
int x = pSprite2->x - pSprite1->x;
|
|
|
|
int y = pSprite2->y - pSprite1->y;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
int ebx = (pSprite2->z + ecx) - (pSprite1->z + nVal);
|
|
|
|
int edx = (pSprite2->z + ecx) - (pSprite1->z + nVal);
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
ebx >>= 4;
|
|
|
|
edx >>= 8;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
ebx = -ebx;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
ebx -= edx;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int nSqrt = lsqrt(x * x + y * y);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return GetMyAngle(nSqrt, ebx);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitPushBlocks()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
nPushBlocks = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int GrabPushBlock()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nPushBlocks >= kMaxPushBlocks) {
|
|
|
|
return -1;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return nPushBlocks++;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CreatePushBlock(int nSector)
|
|
|
|
{
|
2021-11-07 22:52:45 +00:00
|
|
|
auto sectp = §or[nSector];
|
2019-08-31 07:47:15 +00:00
|
|
|
int nBlock = GrabPushBlock();
|
|
|
|
int i;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-11-07 22:52:45 +00:00
|
|
|
int startwall = sectp->wallptr;
|
|
|
|
int nWalls = sectp->wallnum;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-02-04 21:45:10 +00:00
|
|
|
int xSum = 0;
|
|
|
|
int ySum = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
for (i = 0; i < nWalls; i++)
|
|
|
|
{
|
2020-02-04 21:45:10 +00:00
|
|
|
xSum += wall[startwall + i].x;
|
|
|
|
ySum += wall[startwall + i].y;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-02-04 21:45:10 +00:00
|
|
|
int xAvg = xSum / nWalls;
|
|
|
|
int yAvg = ySum / nWalls;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-02-04 21:45:10 +00:00
|
|
|
sBlockInfo[nBlock].x = xAvg;
|
|
|
|
sBlockInfo[nBlock].y = yAvg;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-22 15:45:06 +00:00
|
|
|
auto pActor = insertActor(nSector, 0);
|
|
|
|
auto pSprite = &pActor->s();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-22 15:45:06 +00:00
|
|
|
sBlockInfo[nBlock].pActor = pActor;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->x = xAvg;
|
|
|
|
pSprite->y = yAvg;
|
2021-11-07 22:52:45 +00:00
|
|
|
pSprite->z = sectp->floorz - 256;
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->cstat = 0x8000;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int var_28 = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
for (i = 0; i < nWalls; i++)
|
|
|
|
{
|
2021-01-04 12:02:00 +00:00
|
|
|
uint32_t xDiff = abs(xAvg - wall[startwall + i].x);
|
|
|
|
uint32_t yDiff = abs(yAvg - wall[startwall + i].y);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-06-22 10:24:21 +00:00
|
|
|
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;
|
|
|
|
|
|
|
|
if (sqrtNum > INT_MAX)
|
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__);
|
2020-06-22 10:24:21 +00:00
|
|
|
sqrtNum = INT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
int nSqrt = ksqrt(sqrtNum);
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nSqrt > var_28) {
|
|
|
|
var_28 = nSqrt;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
sBlockInfo[nBlock].field_8 = var_28;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->clipdist = (var_28 & 0xFF) << 2;
|
2021-11-07 22:52:45 +00:00
|
|
|
sectp->extra = nBlock;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-11-09 16:27:54 +00:00
|
|
|
void MoveSector(int nSector, int nAngle, int *nXVel, int *nYVel)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nSector == -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int nXVect, nYVect;
|
|
|
|
|
|
|
|
if (nAngle < 0)
|
|
|
|
{
|
|
|
|
nXVect = *nXVel;
|
|
|
|
nYVect = *nYVel;
|
|
|
|
nAngle = GetMyAngle(nXVect, nYVect);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-14 08:45:08 +00:00
|
|
|
nXVect = bcos(nAngle, 6);
|
|
|
|
nYVect = bsin(nAngle, 6);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-11-07 22:52:45 +00:00
|
|
|
sectortype *pSector = §or[nSector];
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-11-07 22:52:45 +00:00
|
|
|
short nBlock = pSector->extra;
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSectFlag = SectFlag[nSector];
|
|
|
|
|
2021-11-07 22:52:45 +00:00
|
|
|
int nFloorZ = pSector->floorz;
|
|
|
|
int startwall = pSector->wallptr;
|
|
|
|
int nWalls = pSector->wallnum;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
walltype *pStartWall = &wall[startwall];
|
|
|
|
short nNextSector = wall[startwall].nextsector;
|
|
|
|
|
|
|
|
BlockInfo *pBlockInfo = &sBlockInfo[nBlock];
|
|
|
|
|
2021-10-30 10:26:42 +00:00
|
|
|
vec3_t pos;
|
|
|
|
|
|
|
|
pos.x = sBlockInfo[nBlock].x;
|
2019-08-31 07:47:15 +00:00
|
|
|
int x_b = sBlockInfo[nBlock].x;
|
|
|
|
|
2021-10-30 10:26:42 +00:00
|
|
|
pos.y = sBlockInfo[nBlock].y;
|
2019-08-31 07:47:15 +00:00
|
|
|
int y_b = sBlockInfo[nBlock].y;
|
|
|
|
|
2021-11-07 17:53:42 +00:00
|
|
|
int nSectorB = nSector;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
int nZVal;
|
|
|
|
|
|
|
|
int bUnderwater = nSectFlag & kSectUnderwater;
|
|
|
|
|
|
|
|
if (nSectFlag & kSectUnderwater)
|
|
|
|
{
|
2021-11-07 22:52:45 +00:00
|
|
|
nZVal = pSector->ceilingz;
|
2021-10-30 10:26:42 +00:00
|
|
|
pos.z = sector[nNextSector].ceilingz + 256;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-11-07 22:52:45 +00:00
|
|
|
pSector->ceilingz = sector[nNextSector].ceilingz;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-07 22:52:45 +00:00
|
|
|
nZVal = pSector->floorz;
|
2021-10-30 10:26:42 +00:00
|
|
|
pos.z = sector[nNextSector].floorz - 256;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-11-07 22:52:45 +00:00
|
|
|
pSector->floorz = sector[nNextSector].floorz;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-30 10:26:42 +00:00
|
|
|
clipmove(&pos, &nSectorB, nXVect, nYVect, pBlockInfo->field_8, 0, 0, CLIPMASK1);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-30 10:26:42 +00:00
|
|
|
int yvect = pos.y - y_b;
|
|
|
|
int xvect = pos.x - x_b;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nSectorB != nNextSector && nSectorB != nSector)
|
|
|
|
{
|
|
|
|
yvect = 0;
|
|
|
|
xvect = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!bUnderwater)
|
|
|
|
{
|
2021-10-30 10:26:42 +00:00
|
|
|
pos = { x_b, y_b, nZVal };
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-30 10:26:42 +00:00
|
|
|
clipmove(&pos, &nSectorB, nXVect, nYVect, pBlockInfo->field_8, 0, 0, CLIPMASK1);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-30 10:26:42 +00:00
|
|
|
int ebx = pos.x;
|
2019-08-31 07:47:15 +00:00
|
|
|
int ecx = x_b;
|
2021-10-30 10:26:42 +00:00
|
|
|
int edx = pos.y;
|
2019-08-31 07:47:15 +00:00
|
|
|
int eax = xvect;
|
|
|
|
int esi = y_b;
|
|
|
|
|
|
|
|
if (eax < 0) {
|
|
|
|
eax = -eax;
|
|
|
|
}
|
|
|
|
|
|
|
|
ebx -= ecx;
|
|
|
|
ecx = eax;
|
|
|
|
eax = ebx;
|
|
|
|
edx -= esi;
|
|
|
|
|
|
|
|
if (eax < 0) {
|
|
|
|
eax = -eax;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ecx > eax)
|
|
|
|
{
|
|
|
|
xvect = ebx;
|
|
|
|
}
|
|
|
|
|
|
|
|
eax = yvect;
|
|
|
|
if (eax < 0) {
|
|
|
|
eax = -eax;
|
|
|
|
}
|
|
|
|
|
|
|
|
ebx = eax;
|
|
|
|
eax = edx;
|
|
|
|
|
|
|
|
if (eax < 0) {
|
|
|
|
eax = -eax;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ebx > eax) {
|
|
|
|
yvect = edx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GREEN
|
|
|
|
if (yvect || xvect)
|
|
|
|
{
|
2021-10-20 20:27:16 +00:00
|
|
|
ExhumedSectIterator it(nSector);
|
|
|
|
while (auto pActor = it.Next())
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-20 20:27:16 +00:00
|
|
|
auto sp = &pActor->s();
|
|
|
|
if (sp->statnum < 99)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-20 20:27:16 +00:00
|
|
|
sp->x += xvect;
|
|
|
|
sp->y += yvect;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-30 10:26:42 +00:00
|
|
|
pos.z = sp->z;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-30 10:26:42 +00:00
|
|
|
if ((nSectFlag & kSectUnderwater) || pos.z != nZVal || sp->cstat & 0x8000)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-30 10:26:42 +00:00
|
|
|
pos.x = sp->x;
|
|
|
|
pos.y = sp->y;
|
2019-08-31 07:47:15 +00:00
|
|
|
nSectorB = nSector;
|
|
|
|
|
2021-10-30 10:26:42 +00:00
|
|
|
clipmove(&pos, &nSectorB, -xvect, -yvect, 4 * sp->clipdist, 0, 0, CLIPMASK0);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nSectorB >= 0 && nSectorB < kMaxSectors && nSectorB != nSector) {
|
2021-10-20 20:27:16 +00:00
|
|
|
ChangeActorSect(pActor, nSectorB);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-15 17:10:51 +00:00
|
|
|
it.Reset(nNextSector);
|
2021-10-20 20:27:16 +00:00
|
|
|
while (auto pActor = it.Next())
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-20 20:27:16 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2021-10-15 22:34:31 +00:00
|
|
|
if (pSprite->statnum >= 99)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-30 10:26:42 +00:00
|
|
|
pos = pSprite->pos;
|
2019-08-31 07:47:15 +00:00
|
|
|
nSectorB = nNextSector;
|
|
|
|
|
2021-10-30 10:26:42 +00:00
|
|
|
clipmove(&pos, &nSectorB,
|
2021-10-15 22:34:31 +00:00
|
|
|
-xvect - (bcos(nAngle) * (4 * pSprite->clipdist)),
|
|
|
|
-yvect - (bsin(nAngle) * (4 * pSprite->clipdist)),
|
|
|
|
4 * pSprite->clipdist, 0, 0, CLIPMASK0);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (nSectorB != nNextSector && (nSectorB == nSector || nNextSector == nSector))
|
|
|
|
{
|
2021-10-15 22:34:31 +00:00
|
|
|
if (nSectorB != nSector || nFloorZ >= pSprite->z)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
if (nSectorB >= 0 && nSectorB < kMaxSectors) {
|
2021-10-20 20:27:16 +00:00
|
|
|
ChangeActorSect(pActor, nSectorB);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-20 20:27:16 +00:00
|
|
|
movesprite(pActor,
|
2021-10-15 22:34:31 +00:00
|
|
|
(xvect << 14) + bcos(nAngle) * pSprite->clipdist,
|
|
|
|
(yvect << 14) + bsin(nAngle) * pSprite->clipdist,
|
2019-08-31 07:47:15 +00:00
|
|
|
0, 0, 0, CLIPMASK0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < nWalls; i++)
|
|
|
|
{
|
|
|
|
dragpoint(startwall, xvect + pStartWall->x, yvect + pStartWall->y, 0);
|
|
|
|
pStartWall++;
|
|
|
|
startwall++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pBlockInfo->x += xvect;
|
|
|
|
pBlockInfo->y += yvect;
|
|
|
|
}
|
|
|
|
|
|
|
|
// loc_163DD
|
|
|
|
xvect <<= 14;
|
|
|
|
yvect <<= 14;
|
|
|
|
|
|
|
|
if (!(nSectFlag & kSectUnderwater))
|
|
|
|
{
|
2021-10-20 20:27:16 +00:00
|
|
|
ExhumedSectIterator it(nSector);
|
|
|
|
while (auto pActor = it.Next())
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-20 20:27:16 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2021-10-15 22:34:31 +00:00
|
|
|
if (pSprite->statnum >= 99 && nZVal == pSprite->z && !(pSprite->cstat & 0x8000))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
nSectorB = nSector;
|
2021-10-30 10:26:42 +00:00
|
|
|
clipmove(&pSprite->pos, &nSectorB, xvect, yvect, 4 * pSprite->clipdist, 5120, -5120, CLIPMASK0);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nSectFlag & kSectUnderwater) {
|
|
|
|
pSector->ceilingz = nZVal;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pSector->floorz = nZVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
*nXVel = xvect;
|
|
|
|
*nYVel = yvect;
|
2020-05-26 00:13:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Update player position variables, in case the player sprite was moved by a sector,
|
|
|
|
Otherwise these can be out of sync when used in sound code (before being updated in PlayerFunc()).
|
|
|
|
Can cause local player sounds to play off-centre.
|
|
|
|
TODO: Might need to be done elsewhere too?
|
|
|
|
*/
|
2021-10-15 22:34:31 +00:00
|
|
|
auto pActor = PlayerList[nLocalPlayer].Actor();
|
|
|
|
auto pSprite = &pActor->s();
|
|
|
|
initx = pSprite->x;
|
|
|
|
inity = pSprite->y;
|
|
|
|
initz = pSprite->z;
|
|
|
|
inita = pSprite->ang;
|
|
|
|
initsect = pSprite->sectnum;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 19:10:17 +00:00
|
|
|
void SetQuake(DExhumedActor* pActor, int nVal)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-21 19:10:17 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2021-09-06 06:33:02 +00:00
|
|
|
int x = pSprite->x;
|
|
|
|
int y = pSprite->y;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-02-04 21:45:10 +00:00
|
|
|
nVal *= 256;
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
for (int i = 0; i < nTotalPlayers; i++)
|
|
|
|
{
|
2021-10-21 20:39:17 +00:00
|
|
|
auto pPlayerActor = PlayerList[i].Actor();
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 20:39:17 +00:00
|
|
|
uint32_t xDiff = abs((int32_t)((pPlayerActor->s().x - x) >> 8));
|
|
|
|
uint32_t yDiff = abs((int32_t)((pPlayerActor->s().y - y) >> 8));
|
2020-06-22 10:24:21 +00:00
|
|
|
|
|
|
|
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;
|
|
|
|
|
|
|
|
if (sqrtNum > INT_MAX)
|
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__);
|
2020-06-22 10:24:21 +00:00
|
|
|
sqrtNum = INT_MAX;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-06-22 10:24:21 +00:00
|
|
|
int nSqrt = ksqrt(sqrtNum);
|
2020-02-04 21:45:10 +00:00
|
|
|
|
|
|
|
int eax = nVal;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nSqrt)
|
|
|
|
{
|
|
|
|
eax = eax / nSqrt;
|
|
|
|
|
|
|
|
if (eax >= 256)
|
|
|
|
{
|
|
|
|
if (eax > 3840) {
|
|
|
|
eax = 3840;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eax = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eax > nQuake[i]) {
|
|
|
|
nQuake[i] = eax;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 17:57:46 +00:00
|
|
|
Collision AngleChase(DExhumedActor* pActor, DExhumedActor* pActor2, int ebx, int ecx, int push1)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-21 17:57:46 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2021-09-06 06:33:02 +00:00
|
|
|
int nClipType = pSprite->statnum != 107;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
/* bjd - need to handle cliptype to clipmask change that occured in later build engine version */
|
|
|
|
if (nClipType == 1) {
|
|
|
|
nClipType = CLIPMASK1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nClipType = CLIPMASK0;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
short nAngle;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-21 17:57:46 +00:00
|
|
|
if (pActor2 == nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->zvel = 0;
|
|
|
|
nAngle = pSprite->ang;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-21 17:57:46 +00:00
|
|
|
auto pSprite2 = &pActor2->s();
|
2021-09-06 06:33:02 +00:00
|
|
|
|
|
|
|
int nHeight = tileHeight(pSprite2->picnum) * pSprite2->yrepeat * 2;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
int nMyAngle = GetMyAngle(pSprite2->x - pSprite->x, pSprite2->y - pSprite->y);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
uint32_t xDiff = abs(pSprite2->x - pSprite->x);
|
|
|
|
uint32_t yDiff = abs(pSprite2->y - pSprite->y);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-06-22 10:24:21 +00:00
|
|
|
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;
|
|
|
|
|
|
|
|
if (sqrtNum > INT_MAX)
|
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__);
|
2020-06-22 10:24:21 +00:00
|
|
|
sqrtNum = INT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
int nSqrt = ksqrt(sqrtNum);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
int var_18 = GetMyAngle(nSqrt, ((pSprite2->z - nHeight) - pSprite->z) >> 8);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
int nAngDelta = AngleDelta(pSprite->ang, nMyAngle, 1024);
|
2021-01-04 12:02:00 +00:00
|
|
|
int nAngDelta2 = abs(nAngDelta);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nAngDelta2 > 63)
|
|
|
|
{
|
2021-01-04 12:02:00 +00:00
|
|
|
nAngDelta2 = abs(nAngDelta >> 6);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
ebx /= nAngDelta2;
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2020-02-04 21:45:10 +00:00
|
|
|
if (ebx < 5) {
|
2019-08-31 07:47:15 +00:00
|
|
|
ebx = 5;
|
2020-02-04 21:45:10 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-01-04 12:02:00 +00:00
|
|
|
int nAngDeltaC = abs(nAngDelta);
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nAngDeltaC > push1)
|
|
|
|
{
|
|
|
|
if (nAngDelta >= 0)
|
|
|
|
nAngDelta = push1;
|
|
|
|
else
|
|
|
|
nAngDelta = -push1;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
nAngle = (nAngDelta + pSprite->ang) & kAngleMask;
|
|
|
|
int nAngDeltaD = AngleDelta(pSprite->zvel, var_18, 24);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->zvel = (pSprite->zvel + nAngDeltaD) & kAngleMask;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->ang = nAngle;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
int eax = abs(bcos(pSprite->zvel));
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-14 08:45:08 +00:00
|
|
|
int x = ((bcos(nAngle) * ebx) >> 14) * eax;
|
|
|
|
int y = ((bsin(nAngle) * ebx) >> 14) * eax;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-02-04 21:45:10 +00:00
|
|
|
int xshift = x >> 8;
|
|
|
|
int yshift = y >> 8;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-06-22 10:24:21 +00:00
|
|
|
uint32_t sqrtNum = xshift * xshift + yshift * yshift;
|
|
|
|
|
|
|
|
if (sqrtNum > INT_MAX)
|
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__);
|
2020-06-22 10:24:21 +00:00
|
|
|
sqrtNum = INT_MAX;
|
|
|
|
}
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
int z = bsin(pSprite->zvel) * ksqrt(sqrtNum);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-21 17:57:46 +00:00
|
|
|
return movesprite(pActor, x >> 2, y >> 2, (z >> 13) + bsin(ecx, -5), 0, 0, nClipType);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-11-09 16:32:50 +00:00
|
|
|
int GetWallNormal(int nWall)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-09-25 21:16:12 +00:00
|
|
|
nWall &= kMaxWalls-1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int nWall2 = wall[nWall].point2;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int nAngle = GetMyAngle(wall[nWall2].x - wall[nWall].x, wall[nWall2].y - wall[nWall].y);
|
|
|
|
return (nAngle + 512) & kAngleMask;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-11-07 17:53:42 +00:00
|
|
|
void WheresMyMouth(int nPlayer, vec3_t* pos, int *sectnum)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-09-17 13:52:44 +00:00
|
|
|
auto pActor = PlayerList[nPlayer].Actor();
|
|
|
|
auto pSprite = &pActor->s();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-30 10:26:42 +00:00
|
|
|
int height = GetActorHeight(pActor) >> 1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
*sectnum = pSprite->sectnum;
|
2021-10-30 10:26:42 +00:00
|
|
|
*pos = pSprite->pos;
|
|
|
|
pos->z -= height;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-30 10:26:42 +00:00
|
|
|
clipmove(pos, sectnum,
|
2021-09-06 06:33:02 +00:00
|
|
|
bcos(pSprite->ang, 7),
|
|
|
|
bsin(pSprite->ang, 7),
|
2019-08-31 07:47:15 +00:00
|
|
|
5120, 1280, 1280, CLIPMASK1);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitChunks()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
nCurChunkNum = 0;
|
2021-09-17 07:24:14 +00:00
|
|
|
memset(nChunkSprite, 0, sizeof(nChunkSprite));
|
2021-09-17 13:33:07 +00:00
|
|
|
memset(nBodyGunSprite, 0, sizeof(nBodyGunSprite));
|
2021-09-17 07:01:17 +00:00
|
|
|
memset(nBodySprite, 0, sizeof(nBodySprite));
|
2019-08-31 07:47:15 +00:00
|
|
|
nCurBodyNum = 0;
|
|
|
|
nCurBodyGunNum = 0;
|
|
|
|
nBodyTotal = 0;
|
|
|
|
nChunkTotal = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-09-17 13:33:07 +00:00
|
|
|
DExhumedActor* GrabBodyGunSprite()
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-09-17 13:33:07 +00:00
|
|
|
auto pActor = nBodyGunSprite[nCurBodyGunNum];
|
|
|
|
spritetype* pSprite;
|
|
|
|
if (pActor == nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-17 13:33:07 +00:00
|
|
|
pActor = insertActor(0, 899);
|
|
|
|
pSprite = &pActor->s();
|
|
|
|
nBodyGunSprite[nCurBodyGunNum] = pActor;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->lotag = -1;
|
|
|
|
pSprite->owner = -1;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-24 06:24:02 +00:00
|
|
|
pSprite = &pActor->s();
|
2021-10-24 18:21:27 +00:00
|
|
|
DestroyAnim(pActor);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->lotag = -1;
|
|
|
|
pSprite->owner = -1;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
nCurBodyGunNum++;
|
|
|
|
if (nCurBodyGunNum >= 50) { // TODO - enum/define
|
|
|
|
nCurBodyGunNum = 0;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->cstat = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-17 13:33:07 +00:00
|
|
|
return pActor;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-09-17 07:24:14 +00:00
|
|
|
DExhumedActor* GrabBody()
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-09-17 07:01:17 +00:00
|
|
|
DExhumedActor* pActor = nullptr;
|
2021-09-06 06:33:02 +00:00
|
|
|
spritetype* pSprite = nullptr;
|
2019-08-31 07:47:15 +00:00
|
|
|
do
|
|
|
|
{
|
2021-09-17 07:01:17 +00:00
|
|
|
pActor = nBodySprite[nCurBodyNum];
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-17 07:01:17 +00:00
|
|
|
if (pActor == nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-17 07:01:17 +00:00
|
|
|
pActor = insertActor(0, 899);
|
|
|
|
pSprite = &pActor->s();
|
|
|
|
nBodySprite[nCurBodyNum] = pActor;
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->cstat = 0x8000;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-09-17 07:01:17 +00:00
|
|
|
else
|
|
|
|
pSprite = &pActor->s();
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
nCurBodyNum++;
|
|
|
|
if (nCurBodyNum >= 50) {
|
|
|
|
nCurBodyNum = 0;
|
|
|
|
}
|
2021-09-06 06:33:02 +00:00
|
|
|
} while (pSprite->cstat & 0x101);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nBodyTotal < 50) {
|
|
|
|
nBodyTotal++;
|
|
|
|
}
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->cstat = 0;
|
2021-09-17 07:01:17 +00:00
|
|
|
return pActor;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-09-17 07:24:14 +00:00
|
|
|
DExhumedActor* GrabChunkSprite()
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-09-17 07:24:14 +00:00
|
|
|
auto pActor = nChunkSprite[nCurChunkNum];
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-17 07:24:14 +00:00
|
|
|
if (pActor == nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-17 07:24:14 +00:00
|
|
|
pActor = insertActor(0, 899);
|
|
|
|
nChunkSprite[nCurChunkNum] = pActor;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-09-17 07:24:14 +00:00
|
|
|
else if (pActor->s().statnum)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2019-08-26 03:59:14 +00:00
|
|
|
// TODO MonoOut("too many chunks being used at once!\n");
|
2021-09-17 07:24:14 +00:00
|
|
|
return nullptr;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-17 07:24:14 +00:00
|
|
|
ChangeActorStat(pActor, 899);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
nCurChunkNum++;
|
2020-10-11 09:33:28 +00:00
|
|
|
if (nCurChunkNum >= kMaxMoveChunks)
|
2019-08-31 07:47:15 +00:00
|
|
|
nCurChunkNum = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-10-11 09:33:28 +00:00
|
|
|
if (nChunkTotal < kMaxMoveChunks)
|
2019-08-31 07:47:15 +00:00
|
|
|
nChunkTotal++;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-17 07:24:14 +00:00
|
|
|
pActor->s().cstat = 0x80;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-17 07:24:14 +00:00
|
|
|
return pActor;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 19:10:17 +00:00
|
|
|
DExhumedActor* BuildCreatureChunk(DExhumedActor* pSrc, int nPic, bool bSpecial)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-15 22:31:28 +00:00
|
|
|
auto actor = GrabChunkSprite();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 22:31:28 +00:00
|
|
|
if (actor == nullptr) {
|
2021-10-21 19:10:17 +00:00
|
|
|
return nullptr;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 22:31:28 +00:00
|
|
|
auto pSprite = &actor->s();
|
2021-10-21 19:10:17 +00:00
|
|
|
auto pSrcSpr = &pSrc->s();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 19:10:17 +00:00
|
|
|
pSprite->x = pSrcSpr->x;
|
|
|
|
pSprite->y = pSrcSpr->y;
|
|
|
|
pSprite->z = pSrcSpr->z;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 19:10:17 +00:00
|
|
|
ChangeActorSect(actor, pSrcSpr->sectnum);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->cstat = 0x80;
|
|
|
|
pSprite->shade = -12;
|
|
|
|
pSprite->pal = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xvel = (RandomSize(5) - 16) << 7;
|
|
|
|
pSprite->yvel = (RandomSize(5) - 16) << 7;
|
|
|
|
pSprite->zvel = (-(RandomSize(8) + 512)) << 3;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 19:10:17 +00:00
|
|
|
if (bSpecial)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xvel *= 4;
|
|
|
|
pSprite->yvel *= 4;
|
|
|
|
pSprite->zvel *= 2;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xrepeat = 64;
|
|
|
|
pSprite->yrepeat = 64;
|
|
|
|
pSprite->xoffset = 0;
|
|
|
|
pSprite->yoffset = 0;
|
|
|
|
pSprite->picnum = nPic;
|
|
|
|
pSprite->lotag = runlist_HeadRun() + 1;
|
|
|
|
pSprite->clipdist = 40;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
// GrabTimeSlot(3);
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->extra = -1;
|
2021-10-21 19:10:17 +00:00
|
|
|
pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, actor, 0xD0000);
|
|
|
|
pSprite->hitag = runlist_AddRunRec(NewRun, actor, 0xD0000);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-21 19:10:17 +00:00
|
|
|
return actor;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 19:58:07 +00:00
|
|
|
void AICreatureChunk::Tick(RunListEvent* ev)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-21 19:10:17 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
|
|
|
auto pSprite = &pActor->s();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-20 22:00:26 +00:00
|
|
|
Gravity(pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
int nSector = pSprite->sectnum;
|
|
|
|
pSprite->pal = sector[nSector].ceilingpal;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 18:25:15 +00:00
|
|
|
auto nVal = movesprite(pActor, pSprite->xvel << 10, pSprite->yvel << 10, pSprite->zvel, 2560, -2560, CLIPMASK1);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
if (pSprite->z >= sector[nSector].floorz)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
// re-grab this variable as it may have changed in movesprite(). Note the check above is against the value *before* movesprite so don't change it.
|
2021-09-06 06:33:02 +00:00
|
|
|
nSector = pSprite->sectnum;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
|
|
|
pSprite->zvel = 0;
|
|
|
|
pSprite->z = sector[nSector].floorz;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-21 18:25:15 +00:00
|
|
|
if (!nVal.type && !nVal.exbits)
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
short nAngle;
|
|
|
|
|
2021-10-21 18:25:15 +00:00
|
|
|
if (nVal.exbits & kHitAux2)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->cstat = 0x8000;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-21 18:25:15 +00:00
|
|
|
if (nVal.exbits & kHitAux1)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xvel >>= 1;
|
|
|
|
pSprite->yvel >>= 1;
|
|
|
|
pSprite->zvel = -pSprite->zvel;
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-10-21 18:25:15 +00:00
|
|
|
else if (nVal.type == kHitSprite)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-21 18:25:15 +00:00
|
|
|
nAngle = nVal.actor->s().ang;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-21 18:25:15 +00:00
|
|
|
else if (nVal.type == kHitWall)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-21 18:25:15 +00:00
|
|
|
nAngle = GetWallNormal(nVal.index);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// loc_16E0C
|
2021-09-06 06:33:02 +00:00
|
|
|
int nSqrt = lsqrt(((pSprite->yvel >> 10) * (pSprite->yvel >> 10)
|
|
|
|
+ (pSprite->xvel >> 10) * (pSprite->xvel >> 10)) >> 8);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xvel = bcos(nAngle) * (nSqrt >> 1);
|
|
|
|
pSprite->yvel = bsin(nAngle) * (nSqrt >> 1);
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
runlist_DoSubRunRec(pSprite->owner);
|
|
|
|
runlist_FreeRun(pSprite->lotag - 1);
|
|
|
|
runlist_SubRunRec(pSprite->hitag);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-21 18:25:15 +00:00
|
|
|
ChangeActorStat(pActor, 0);
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->hitag = 0;
|
|
|
|
pSprite->lotag = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 19:10:17 +00:00
|
|
|
DExhumedActor* UpdateEnemy(DExhumedActor** ppEnemy)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-21 19:10:17 +00:00
|
|
|
if (*ppEnemy)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-21 19:10:17 +00:00
|
|
|
if (!((*ppEnemy)->s().cstat & 0x101)) {
|
|
|
|
*ppEnemy = nullptr;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-21 19:10:17 +00:00
|
|
|
return *ppEnemy;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|