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
|
|
|
|
2021-11-22 23:35:29 +00:00
|
|
|
DExhumedActor* BuildSpider(DExhumedActor* spp, int x, int y, int z, sectortype* pSector, int nAngle)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2020-11-29 18:31:49 +00:00
|
|
|
spritetype* sp;
|
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);
|
2021-10-18 18:05:33 +00:00
|
|
|
sp = &spp->s();
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-18 18:05:33 +00:00
|
|
|
ChangeActorStat(spp, 99);
|
|
|
|
sp = &spp->s();
|
2020-11-29 18:31:49 +00:00
|
|
|
|
2021-12-22 10:57:10 +00:00
|
|
|
x = sp->pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
y = sp->pos.Y;
|
2021-11-08 23:24:04 +00:00
|
|
|
z = sp->sector()->floorz;
|
2020-11-29 18:31:49 +00:00
|
|
|
nAngle = sp->ang;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-12-22 10:57:10 +00:00
|
|
|
sp->pos.X = x;
|
2021-12-22 11:17:17 +00:00
|
|
|
sp->pos.Y = y;
|
2020-11-29 18:31:49 +00:00
|
|
|
sp->z = z;
|
2021-12-18 17:40:25 +00:00
|
|
|
sp->cstat = CSTAT_SPRITE_BLOCK_ALL;
|
2020-11-29 18:31:49 +00:00
|
|
|
sp->shade = -12;
|
|
|
|
sp->clipdist = 15;
|
|
|
|
sp->xvel = 0;
|
|
|
|
sp->yvel = 0;
|
|
|
|
sp->zvel = 0;
|
|
|
|
sp->xrepeat = 40;
|
|
|
|
sp->yrepeat = 40;
|
2021-11-08 23:24:04 +00:00
|
|
|
sp->pal = sp->sector()->ceilingpal;
|
2020-11-29 18:31:49 +00:00
|
|
|
sp->xoffset = 0;
|
|
|
|
sp->yoffset = 0;
|
|
|
|
sp->ang = nAngle;
|
|
|
|
sp->picnum = 1;
|
|
|
|
sp->hitag = 0;
|
|
|
|
sp->lotag = runlist_HeadRun() + 1;
|
|
|
|
sp->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
|
|
|
|
2021-10-18 18:05:33 +00:00
|
|
|
sp->owner = runlist_AddRunRec(sp->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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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-10-18 18:05:33 +00:00
|
|
|
auto sp = &spp->s();
|
2021-11-21 20:09:27 +00:00
|
|
|
int nAction = spp->nAction;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
int nVel = 6;
|
|
|
|
|
|
|
|
if (spp->nHealth)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-12-18 15:09:58 +00:00
|
|
|
if (sp->cstat & CSTAT_SPRITE_YFLIP)
|
2020-03-02 21:08:31 +00:00
|
|
|
{
|
2021-11-08 23:24:04 +00:00
|
|
|
sp->z = sp->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
|
|
|
}
|
|
|
|
|
|
|
|
int nSeq = SeqOffsets[kSeqSpider] + SpiderSeq[nAction].a;
|
|
|
|
|
|
|
|
sp->picnum = seq_GetSeqPicnum2(nSeq, spp->nFrame);
|
|
|
|
|
2021-10-18 18:05:33 +00:00
|
|
|
seq_MoveSequence(spp, nSeq, spp->nFrame);
|
2021-10-15 21:25:20 +00:00
|
|
|
|
|
|
|
int nFrameFlag = FrameFlag[SeqBase[nSeq] + spp->nFrame];
|
2020-03-02 21:08:31 +00:00
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
spp->nFrame++;
|
|
|
|
if (spp->nFrame >= SeqSize[nSeq]) {
|
|
|
|
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
|
|
|
|
|
|
|
sp->xvel = bcos(sp->ang);
|
|
|
|
sp->yvel = bsin(sp->ang);
|
|
|
|
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) {
|
2021-10-15 21:25:20 +00:00
|
|
|
nVel++;
|
|
|
|
}
|
|
|
|
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-11-22 21:38:27 +00:00
|
|
|
auto pSector =sp->sector();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-12-18 15:09:58 +00:00
|
|
|
if (sp->cstat & CSTAT_SPRITE_YFLIP)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:25:20 +00:00
|
|
|
sp->zvel = 0;
|
2021-11-22 21:38:27 +00:00
|
|
|
sp->z = pSector->ceilingz + (tileHeight(sp->picnum) << 5);
|
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-18 15:39:44 +00:00
|
|
|
sp->cstat ^= CSTAT_SPRITE_YFLIP;
|
2021-10-15 21:25:20 +00:00
|
|
|
sp->zvel = 1;
|
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
|
|
|
{
|
2021-10-15 21:25:20 +00:00
|
|
|
sp->xvel = bcos(sp->ang);
|
|
|
|
sp->yvel = bsin(sp->ang);
|
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
|
|
|
{
|
2021-10-15 21:25:20 +00:00
|
|
|
sp->xvel = 0;
|
|
|
|
sp->yvel = 0;
|
2019-12-05 19:40:53 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
if (spp->nAction == 1 && RandomBit())
|
|
|
|
{
|
2021-12-18 15:09:58 +00:00
|
|
|
if (sp->cstat & CSTAT_SPRITE_YFLIP)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-12-18 15:39:44 +00:00
|
|
|
sp->cstat ^= CSTAT_SPRITE_YFLIP;
|
2021-10-15 21:25:20 +00:00
|
|
|
sp->zvel = 1;
|
2021-11-22 21:38:27 +00:00
|
|
|
sp->z = pSector->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
|
|
|
{
|
2021-10-15 21:25:20 +00:00
|
|
|
sp->zvel = -5120;
|
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)
|
|
|
|
{
|
|
|
|
runlist_DoSubRunRec(sp->owner);
|
|
|
|
runlist_FreeRun(sp->lotag - 1);
|
|
|
|
runlist_SubRunRec(spp->nRun);
|
2021-12-18 11:36:53 +00:00
|
|
|
sp->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
|
|
|
{
|
|
|
|
if (nFrameFlag & 0x80)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2021-10-18 18:05:33 +00:00
|
|
|
if (PlotCourseToSprite(spp, pTarget) < 1024) {
|
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;
|
|
|
|
sp->xvel = 0;
|
|
|
|
sp->yvel = 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
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
sp->xvel = 0;
|
|
|
|
sp->yvel = 0;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 18:05:33 +00:00
|
|
|
auto nMov = movesprite(spp, sp->xvel << nVel, sp->yvel << nVel, sp->zvel, 1280, -1280, 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
|
2021-10-15 21:25:20 +00:00
|
|
|
&& sp->zvel < 0
|
2021-10-21 21:41:54 +00:00
|
|
|
&& hiHit.type != kHitSprite
|
2021-12-18 12:23:08 +00:00
|
|
|
&& !((sp->sector()->ceilingstat) & CSTAT_SECTOR_SKY))
|
2021-10-15 21:25:20 +00:00
|
|
|
{
|
2021-12-18 15:02:15 +00:00
|
|
|
sp->cstat |= CSTAT_SPRITE_YFLIP;
|
2021-11-08 23:24:04 +00:00
|
|
|
sp->z = GetActorHeight(spp) + sp->sector()->ceilingz;
|
2021-10-15 21:25:20 +00:00
|
|
|
sp->zvel = 0;
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
sp->ang = (sp->ang + 256) & 0x7EF;
|
|
|
|
sp->xvel = bcos(sp->ang);
|
|
|
|
sp->yvel = bsin(sp->ang);
|
|
|
|
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
|
|
|
{
|
2021-12-22 11:17:17 +00:00
|
|
|
int nAng = getangle(pTarget->spr.pos.X - sp->pos.X, pTarget->spr.pos.Y - sp->pos.Y);
|
2021-10-15 21:25:20 +00:00
|
|
|
if (AngleDiff(sp->ang, nAng) < 64)
|
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
|
|
|
|
2021-10-15 21:25:20 +00:00
|
|
|
void AISpider::Draw(RunListEvent* ev)
|
|
|
|
{
|
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
|
|
|
|
2021-10-17 14:22:25 +00:00
|
|
|
seq_PlotSequence(ev->nParam, SeqOffsets[kSeqSpider] + SpiderSeq[nAction].a, spp->nFrame, SpiderSeq[nAction].b);
|
2021-10-15 21:25:20 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +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
|
|
|
|
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;
|
|
|
|
auto sp = &spp->s();
|
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-18 17:40:25 +00:00
|
|
|
sp->cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
2021-10-15 21:25:20 +00:00
|
|
|
|
|
|
|
nCreaturesKilled++;
|
|
|
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
{
|
2021-10-26 19:15:07 +00:00
|
|
|
BuildCreatureChunk(spp, seq_GetSeqPicnum(kSeqSpider, i + 41, 0));
|
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
|