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"
|
2020-08-18 07:52:08 +00:00
|
|
|
#include "aistuff.h"
|
2020-03-02 21:08:31 +00:00
|
|
|
#include "exhumed.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "engine.h"
|
|
|
|
#include "sequence.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include <assert.h>
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2020-10-11 09:33:28 +00:00
|
|
|
static actionSeq SpiderSeq[] = {
|
2020-03-02 21:08:31 +00:00
|
|
|
{16, 0},
|
|
|
|
{8, 0},
|
|
|
|
{32, 0},
|
|
|
|
{24, 0},
|
|
|
|
{0, 0},
|
|
|
|
{40, 1},
|
|
|
|
{41, 1}
|
|
|
|
};
|
2019-12-05 19:40:53 +00:00
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-09-07 07:48:05 +00:00
|
|
|
DExhumedActor* BuildSpider(DExhumedActor* spp, const DVector3& pos, sectortype* pSector, DAngle nAngle)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
if (spp == nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-11-22 23:35:29 +00:00
|
|
|
spp = insertActor(pSector, 99);
|
2022-08-17 17:03:45 +00:00
|
|
|
spp->spr.pos = pos;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
ChangeActorStat(spp, 99);
|
2020-11-29 18:31:49 +00:00
|
|
|
|
2022-08-17 17:03:45 +00:00
|
|
|
spp->spr.pos.Z = spp->sector()->floorz;
|
2022-11-25 12:13:50 +00:00
|
|
|
nAngle = spp->spr.Angles.Yaw;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-12-23 16:12:23 +00:00
|
|
|
spp->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
|
|
|
|
spp->spr.shade = -12;
|
2022-10-04 17:13:26 +00:00
|
|
|
spp->clipdist = 3.75;
|
2022-09-03 08:02:25 +00:00
|
|
|
spp->vel.X = 0;
|
|
|
|
spp->vel.Y = 0;
|
|
|
|
spp->vel.Z = 0;
|
2022-10-07 21:52:29 +00:00
|
|
|
spp->spr.scale = DVector2(0.625, 0.625);
|
2021-12-30 15:51:56 +00:00
|
|
|
spp->spr.pal = spp->sector()->ceilingpal;
|
2021-12-23 16:12:23 +00:00
|
|
|
spp->spr.xoffset = 0;
|
|
|
|
spp->spr.yoffset = 0;
|
2022-11-25 12:13:50 +00:00
|
|
|
spp->spr.Angles.Yaw = nAngle;
|
2021-12-23 16:12:23 +00:00
|
|
|
spp->spr.picnum = 1;
|
|
|
|
spp->spr.hitag = 0;
|
|
|
|
spp->spr.lotag = runlist_HeadRun() + 1;
|
|
|
|
spp->spr.extra = -1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-12-05 19:40:53 +00:00
|
|
|
// GrabTimeSlot(3);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-29 18:31:49 +00:00
|
|
|
spp->nAction = 0;
|
|
|
|
spp->nFrame = 0;
|
2021-10-18 18:05:33 +00:00
|
|
|
spp->pTarget = nullptr;
|
2020-11-29 18:31:49 +00:00
|
|
|
spp->nHealth = 160;
|
2021-10-18 18:05:33 +00:00
|
|
|
spp->nPhase = Counters[kCountSpider]++;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2022-05-23 22:30:41 +00:00
|
|
|
spp->spr.intowner = runlist_AddRunRec(spp->spr.lotag - 1, spp, 0xC0000);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-18 18:05:33 +00:00
|
|
|
spp->nRun = runlist_AddRunRec(NewRun, spp, 0xC0000);
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2023-04-21 11:11:52 +00:00
|
|
|
spp->nSeqFile = "spider";
|
|
|
|
|
2020-08-23 12:39:14 +00:00
|
|
|
nCreaturesTotal++;
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2021-10-18 18:05:33 +00:00
|
|
|
return spp;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
void AISpider::Tick(RunListEvent* ev)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
auto spp = ev->pObjActor;
|
|
|
|
if (!spp) return;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-11-21 20:09:27 +00:00
|
|
|
int nAction = spp->nAction;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2022-09-11 06:45:06 +00:00
|
|
|
double nVel = 0.25;
|
2021-10-15 21:25:20 +00:00
|
|
|
|
|
|
|
if (spp->nHealth)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-12-23 16:12:23 +00:00
|
|
|
if (spp->spr.cstat & CSTAT_SPRITE_YFLIP)
|
2020-03-02 21:08:31 +00:00
|
|
|
{
|
2022-09-10 19:24:40 +00:00
|
|
|
spp->spr.pos.Z = spp->sector()->ceilingz + GetActorHeight(spp);
|
2021-10-15 21:25:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
Gravity(spp);
|
2020-03-02 21:08:31 +00:00
|
|
|
}
|
2021-10-15 21:25:20 +00:00
|
|
|
}
|
|
|
|
|
2023-04-16 07:08:33 +00:00
|
|
|
const auto& spiderSeq = getSequence(spp->nSeqFile, SpiderSeq[nAction].nSeqId);
|
2023-04-15 22:03:23 +00:00
|
|
|
const auto& seqFrame = spiderSeq.frames[spp->nFrame];
|
2021-10-15 21:25:20 +00:00
|
|
|
|
2023-04-15 10:25:40 +00:00
|
|
|
spp->spr.picnum = spp->nFrame < 9 ? seqFrame.getFirstPicnum() : -1;
|
2021-10-15 21:25:20 +00:00
|
|
|
|
2023-04-15 11:48:48 +00:00
|
|
|
seqFrame.playSound(spp);
|
2020-03-02 21:08:31 +00:00
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
spp->nFrame++;
|
2023-04-15 22:03:23 +00:00
|
|
|
if (spp->nFrame >= spiderSeq.frames.Size()) {
|
2021-10-15 21:25:20 +00:00
|
|
|
spp->nFrame = 0;
|
|
|
|
}
|
|
|
|
|
2021-12-07 17:53:02 +00:00
|
|
|
DExhumedActor* pTarget = spp->pTarget;
|
2021-10-15 21:25:20 +00:00
|
|
|
|
2021-12-21 22:18:23 +00:00
|
|
|
if (pTarget == nullptr || pTarget->spr.cstat & CSTAT_SPRITE_BLOCK_ALL)
|
2021-10-15 21:25:20 +00:00
|
|
|
{
|
|
|
|
switch (nAction)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:25:20 +00:00
|
|
|
default:
|
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
case 0:
|
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
if ((spp->nPhase & 0x1F) == (totalmoves & 0x1F))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
if (pTarget == nullptr) {
|
|
|
|
pTarget = FindPlayer(spp, 100);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:25:20 +00:00
|
|
|
|
2021-10-18 18:05:33 +00:00
|
|
|
if (pTarget)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:25:20 +00:00
|
|
|
spp->nAction = 1;
|
|
|
|
spp->nFrame = 0;
|
2021-10-18 18:05:33 +00:00
|
|
|
spp->pTarget = pTarget;
|
2021-10-15 21:25:20 +00:00
|
|
|
|
2022-09-03 10:06:50 +00:00
|
|
|
spp->VelFromAngle();
|
2021-10-15 21:25:20 +00:00
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
if (pTarget) {
|
2022-09-11 06:45:06 +00:00
|
|
|
nVel *= 2;
|
2021-10-15 21:25:20 +00:00
|
|
|
}
|
|
|
|
goto case_3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
if (!spp->nFrame)
|
|
|
|
{
|
2020-11-29 18:31:49 +00:00
|
|
|
spp->nFrame = 0;
|
2021-10-15 21:25:20 +00:00
|
|
|
spp->nAction = 1;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-18 18:05:33 +00:00
|
|
|
[[fallthrough]];
|
2021-10-15 21:25:20 +00:00
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
case_3:
|
2021-12-30 15:51:56 +00:00
|
|
|
auto pSector =spp->sector();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-12-23 16:12:23 +00:00
|
|
|
if (spp->spr.cstat & CSTAT_SPRITE_YFLIP)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2022-09-03 08:02:25 +00:00
|
|
|
spp->vel.Z = 0;
|
2022-12-09 13:24:36 +00:00
|
|
|
auto tex = TexMan.GetGameTexture(spp->spr.spritetexture());
|
|
|
|
spp->spr.pos.Z = pSector->ceilingz + (tex->GetDisplayHeight() / 8.); // was << 5 in Build coordinates
|
2019-12-05 19:40:53 +00:00
|
|
|
|
2021-12-18 12:14:56 +00:00
|
|
|
if (pSector->ceilingstat & CSTAT_SECTOR_SKY)
|
2019-12-05 19:40:53 +00:00
|
|
|
{
|
2021-12-23 16:12:23 +00:00
|
|
|
spp->spr.cstat ^= CSTAT_SPRITE_YFLIP;
|
2022-09-09 17:29:11 +00:00
|
|
|
spp->vel.Z = 1./256.;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
spp->nAction = 3;
|
|
|
|
spp->nFrame = 0;
|
2019-12-05 19:40:53 +00:00
|
|
|
}
|
2021-10-15 21:25:20 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 18:05:33 +00:00
|
|
|
if ((totalmoves & 0x1F) == (spp->nPhase & 0x1F))
|
2021-10-15 21:25:20 +00:00
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
PlotCourseToSprite(spp, pTarget);
|
2021-10-15 21:25:20 +00:00
|
|
|
|
|
|
|
if (RandomSize(3))
|
2019-12-05 19:40:53 +00:00
|
|
|
{
|
2022-09-03 10:06:50 +00:00
|
|
|
spp->VelFromAngle();
|
2019-12-05 19:40:53 +00:00
|
|
|
}
|
2021-10-15 21:25:20 +00:00
|
|
|
else
|
2019-12-05 19:40:53 +00:00
|
|
|
{
|
2022-09-03 08:02:25 +00:00
|
|
|
spp->vel.X = 0;
|
|
|
|
spp->vel.Y = 0;
|
2019-12-05 19:40:53 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
if (spp->nAction == 1 && RandomBit())
|
|
|
|
{
|
2021-12-23 16:12:23 +00:00
|
|
|
if (spp->spr.cstat & CSTAT_SPRITE_YFLIP)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-12-23 16:12:23 +00:00
|
|
|
spp->spr.cstat ^= CSTAT_SPRITE_YFLIP;
|
2022-09-09 17:29:11 +00:00
|
|
|
spp->vel.Z = 1./256.;
|
2022-09-10 19:24:40 +00:00
|
|
|
spp->spr.pos.Z = spp->sector()->ceilingz+ GetActorHeight(spp);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:25:20 +00:00
|
|
|
else
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2022-09-09 17:29:11 +00:00
|
|
|
spp->vel.Z = -20;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-12-05 19:40:53 +00:00
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
spp->nAction = 3;
|
|
|
|
spp->nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
if (!RandomSize(3)) {
|
2021-10-18 18:05:33 +00:00
|
|
|
D3PlayFX(StaticSound[kSound29], spp);
|
2019-12-05 19:40:53 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-15 21:25:20 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
if (!spp->nFrame)
|
|
|
|
{
|
2022-05-23 22:30:41 +00:00
|
|
|
runlist_DoSubRunRec(spp->spr.intowner);
|
2021-12-23 16:12:23 +00:00
|
|
|
runlist_FreeRun(spp->spr.lotag - 1);
|
2021-10-15 21:25:20 +00:00
|
|
|
runlist_SubRunRec(spp->nRun);
|
2021-12-23 16:12:23 +00:00
|
|
|
spp->spr.cstat = CSTAT_SPRITE_INVISIBLE;
|
2021-10-18 18:05:33 +00:00
|
|
|
DeleteActor(spp);
|
2021-10-15 21:25:20 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
if (pTarget)
|
2021-10-15 21:25:20 +00:00
|
|
|
{
|
2023-04-16 07:08:33 +00:00
|
|
|
if (seqFrame.flags & 0x80)
|
2021-10-15 21:25:20 +00:00
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
runlist_DamageEnemy(pTarget, spp, 3);
|
|
|
|
D3PlayFX(StaticSound[kSound38], spp);
|
2021-10-15 21:25:20 +00:00
|
|
|
}
|
|
|
|
|
2022-09-10 22:02:17 +00:00
|
|
|
if (PlotCourseToSprite(spp, pTarget) < 64) {
|
2021-10-15 21:25:20 +00:00
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:25:20 +00:00
|
|
|
|
|
|
|
spp->nAction = 1;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-29 18:31:49 +00:00
|
|
|
spp->nAction = 0;
|
2022-09-03 08:02:25 +00:00
|
|
|
spp->vel.X = 0;
|
|
|
|
spp->vel.Y = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
spp->nFrame = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
spp->pTarget = nullptr;
|
2021-10-15 21:25:20 +00:00
|
|
|
spp->nAction = 0;
|
|
|
|
spp->nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2022-09-03 08:02:25 +00:00
|
|
|
spp->vel.X = 0;
|
|
|
|
spp->vel.Y = 0;
|
2021-10-15 21:25:20 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2022-09-11 06:45:06 +00:00
|
|
|
auto nMov = movespritevel(spp, spp->vel, nVel, -5, CLIPMASK0);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 18:05:33 +00:00
|
|
|
if (nMov.type == kHitNone && nMov.exbits == 0)
|
2021-10-15 21:25:20 +00:00
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 18:05:33 +00:00
|
|
|
if (nMov.exbits & kHitAux1
|
2022-09-03 08:03:30 +00:00
|
|
|
&& spp->vel.Z < 0
|
2021-10-21 21:41:54 +00:00
|
|
|
&& hiHit.type != kHitSprite
|
2021-12-30 15:51:56 +00:00
|
|
|
&& !((spp->sector()->ceilingstat) & CSTAT_SECTOR_SKY))
|
2021-10-15 21:25:20 +00:00
|
|
|
{
|
2021-12-23 16:12:23 +00:00
|
|
|
spp->spr.cstat |= CSTAT_SPRITE_YFLIP;
|
2022-09-10 19:24:40 +00:00
|
|
|
spp->spr.pos.Z = spp->sector()->ceilingz + GetActorHeight(spp);
|
2022-09-03 08:02:25 +00:00
|
|
|
spp->vel.Z = 0;
|
2021-10-15 21:25:20 +00:00
|
|
|
|
|
|
|
spp->nAction = 1;
|
|
|
|
spp->nFrame = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
switch (nMov.type)
|
2021-10-15 21:25:20 +00:00
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
case kHitWall:
|
2021-10-15 21:25:20 +00:00
|
|
|
{
|
2022-11-25 12:13:50 +00:00
|
|
|
spp->spr.Angles.Yaw += DAngle45;
|
2022-09-03 10:06:50 +00:00
|
|
|
spp->VelFromAngle();
|
2021-10-15 21:25:20 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-10-18 18:05:33 +00:00
|
|
|
case kHitSprite:
|
2021-10-15 21:25:20 +00:00
|
|
|
{
|
2021-11-26 13:26:03 +00:00
|
|
|
if (nMov.actor() == pTarget)
|
2021-10-15 21:25:20 +00:00
|
|
|
{
|
2022-11-25 12:13:50 +00:00
|
|
|
auto nAngDiff = absangle(spp->spr.Angles.Yaw, (pTarget->spr.pos - spp->spr.pos).Angle());
|
2022-09-10 22:18:09 +00:00
|
|
|
if (nAngDiff < DAngle22_5 / 2)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:25:20 +00:00
|
|
|
spp->nAction = 2;
|
2020-11-29 18:31:49 +00:00
|
|
|
spp->nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2021-10-15 21:25:20 +00:00
|
|
|
default:
|
2019-08-31 07:47:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
if (spp->nAction == 3)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:25:20 +00:00
|
|
|
spp->nAction = 1;
|
|
|
|
spp->nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:25:20 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
void AISpider::Draw(RunListEvent* ev)
|
|
|
|
{
|
2023-04-21 11:11:52 +00:00
|
|
|
if (const auto spp = ev->pObjActor)
|
|
|
|
{
|
|
|
|
const auto spiderSeq = &SpiderSeq[spp->nAction];
|
|
|
|
seq_PlotSequence(ev->nParam, spp->nSeqFile, spiderSeq->nSeqId, spp->nFrame, spiderSeq->nFlags);
|
|
|
|
}
|
2021-10-15 21:25:20 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
void AISpider::RadialDamage(RunListEvent* ev)
|
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
auto spp = ev->pObjActor;
|
|
|
|
if (!spp) return;
|
2019-12-05 19:40:53 +00:00
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
if (spp->nHealth <= 0)
|
|
|
|
return;
|
2019-12-05 19:40:53 +00:00
|
|
|
|
2021-10-18 18:05:33 +00:00
|
|
|
ev->nDamage = runlist_CheckRadialDamage(spp);
|
2021-10-15 21:25:20 +00:00
|
|
|
Damage(ev);
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
void AISpider::Damage(RunListEvent* ev)
|
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
auto spp = ev->pObjActor;
|
|
|
|
if (!spp) return;
|
2021-10-15 21:25:20 +00:00
|
|
|
|
|
|
|
if (!ev->nDamage)
|
|
|
|
return;
|
|
|
|
|
2021-10-18 18:05:33 +00:00
|
|
|
DExhumedActor* pTarget = ev->pOtherActor;
|
2021-10-15 21:25:20 +00:00
|
|
|
|
|
|
|
spp->nHealth -= dmgAdjust(ev->nDamage);
|
|
|
|
if (spp->nHealth > 0)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
NOTE:
|
|
|
|
nTarget check was added, but should we return if it's invalid instead
|
|
|
|
or should code below (action set, b set) happen?
|
|
|
|
Other AI doesn't show consistency in this regard (see Scorpion code)
|
|
|
|
*/
|
2021-12-21 22:18:23 +00:00
|
|
|
if (pTarget && pTarget->spr.statnum == 100)
|
2021-10-15 21:25:20 +00:00
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
spp->pTarget = pTarget;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:25:20 +00:00
|
|
|
|
|
|
|
spp->nAction = 4;
|
|
|
|
spp->nFrame = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// creature is dead, make some chunks
|
|
|
|
spp->nHealth = 0;
|
|
|
|
spp->nAction = 5;
|
|
|
|
spp->nFrame = 0;
|
|
|
|
|
2021-12-23 16:12:23 +00:00
|
|
|
spp->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
2021-10-15 21:25:20 +00:00
|
|
|
|
|
|
|
nCreaturesKilled++;
|
|
|
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
{
|
2023-04-15 22:03:23 +00:00
|
|
|
BuildCreatureChunk(spp, getSequence("spider", i + 41).getFirstPicnum());
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:25:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|