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"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "engine.h"
|
|
|
|
#include "exhumed.h"
|
|
|
|
#include "sequence.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 WaspSeq[] = {
|
2020-03-02 21:08:31 +00:00
|
|
|
{0, 0},
|
|
|
|
{0, 0},
|
|
|
|
{9, 0},
|
|
|
|
{18, 0},
|
|
|
|
{27, 1},
|
|
|
|
{28, 1},
|
|
|
|
{29, 1}
|
|
|
|
};
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
void SetWaspVel(spritetype* pSprite)
|
2020-11-29 20:09:41 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xvel = bcos(pSprite->ang);
|
|
|
|
pSprite->yvel = bsin(pSprite->ang);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-11-23 00:18:20 +00:00
|
|
|
DExhumedActor* BuildWasp(DExhumedActor* pActor, int x, int y, int z, sectortype* pSector, int nAngle, bool bEggWasp)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-24 11:20:50 +00:00
|
|
|
spritetype* pSprite;
|
|
|
|
if (pActor == nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-11-23 00:18:20 +00:00
|
|
|
pActor = insertActor(pSector, 107);
|
2021-10-24 11:20:50 +00:00
|
|
|
pSprite = &pActor->s();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-24 11:20:50 +00:00
|
|
|
pSprite = &pActor->s();
|
2021-09-06 06:33:02 +00:00
|
|
|
nAngle = pSprite->ang;
|
2021-10-24 11:20:50 +00:00
|
|
|
ChangeActorStat(pActor, 107);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->shade = -12;
|
2021-12-18 17:40:25 +00:00
|
|
|
pSprite->cstat = CSTAT_SPRITE_BLOCK_ALL;
|
2021-11-08 23:24:04 +00:00
|
|
|
pSprite->pal = pSprite->sector()->ceilingpal;
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->clipdist = 70;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2019-11-13 15:36:31 +00:00
|
|
|
if (bEggWasp)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xrepeat = 20;
|
|
|
|
pSprite->yrepeat = 20;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xrepeat = 50;
|
|
|
|
pSprite->yrepeat = 50;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xoffset = 0;
|
|
|
|
pSprite->yoffset = 0;
|
|
|
|
pSprite->picnum = 1;
|
|
|
|
pSprite->ang = nAngle;
|
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
|
|
|
pSprite->zvel = 0;
|
|
|
|
pSprite->hitag = 0;
|
|
|
|
pSprite->lotag = runlist_HeadRun() + 1;
|
|
|
|
pSprite->extra = -1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:29:25 +00:00
|
|
|
// GrabTimeSlot(3);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-24 11:20:50 +00:00
|
|
|
pActor->pTarget = nullptr;
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nHealth = 800;
|
|
|
|
pActor->nDamage = 10;
|
2021-10-24 11:20:50 +00:00
|
|
|
pActor->nPhase = Counters[kCountWasp]++;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2019-11-13 15:36:31 +00:00
|
|
|
if (bEggWasp)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nCount = 60;
|
|
|
|
pActor->nDamage /= 2;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nCount = RandomSize(5);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nAngle = 0;
|
|
|
|
pActor->nVel = 0;
|
|
|
|
pActor->nAngle2 = RandomSize(7) + 127;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, pActor, 0x1E0000);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x1E0000);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-08-23 12:39:14 +00:00
|
|
|
nCreaturesTotal++;
|
2021-10-24 11:20:50 +00:00
|
|
|
return pActor;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 21:29:25 +00:00
|
|
|
void AIWasp::Draw(RunListEvent* ev)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-24 11:20:50 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
2021-11-21 19:34:15 +00:00
|
|
|
int nAction = pActor->nAction;
|
2021-10-15 21:29:25 +00:00
|
|
|
|
2021-10-24 11:15:40 +00:00
|
|
|
seq_PlotSequence(ev->nParam, SeqOffsets[kSeqWasp] + WaspSeq[nAction].a, pActor->nFrame, WaspSeq[nAction].b);
|
2021-10-15 21:29:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AIWasp::RadialDamage(RunListEvent* ev)
|
|
|
|
{
|
2021-10-24 11:20:50 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
|
|
|
auto pSprite = &pActor->s();
|
2021-10-15 21:29:25 +00:00
|
|
|
|
2021-12-18 17:40:25 +00:00
|
|
|
if (!(pSprite->cstat & CSTAT_SPRITE_BLOCK_ALL))
|
2021-10-15 21:29:25 +00:00
|
|
|
return;
|
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
ev->nDamage = runlist_CheckRadialDamage(pActor);
|
2021-10-15 21:29:25 +00:00
|
|
|
Damage(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AIWasp::Damage(RunListEvent* ev)
|
|
|
|
{
|
2021-10-24 11:20:50 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
|
|
|
auto pSprite = &pActor->s();
|
2021-10-15 21:29:25 +00:00
|
|
|
|
|
|
|
if (!ev->nDamage) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-24 11:15:40 +00:00
|
|
|
if (pActor->nHealth > 0)
|
2021-10-15 21:29:25 +00:00
|
|
|
{
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nHealth -= dmgAdjust(ev->nDamage, 3);
|
2021-10-15 21:29:25 +00:00
|
|
|
|
2021-10-24 11:15:40 +00:00
|
|
|
if (pActor->nHealth > 0)
|
2021-10-15 21:29:25 +00:00
|
|
|
{
|
|
|
|
if (!RandomSize(4))
|
|
|
|
{
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nAction = 3;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:29:25 +00:00
|
|
|
}
|
|
|
|
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nAction = 1;
|
2021-10-15 21:29:25 +00:00
|
|
|
pSprite->ang += RandomSize(9) + 768;
|
|
|
|
pSprite->ang &= kAngleMask;
|
|
|
|
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nVel = 3000;
|
2021-10-15 21:29:25 +00:00
|
|
|
|
|
|
|
pSprite->zvel = (-20) - RandomSize(6);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Wasp is dead
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nAction = 4;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:29:25 +00:00
|
|
|
|
|
|
|
pSprite->cstat = 0;
|
|
|
|
pSprite->ang = (pSprite->ang + 1024) & kAngleMask;
|
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
SetWaspVel(pSprite);
|
2021-10-15 21:29:25 +00:00
|
|
|
|
|
|
|
pSprite->zvel = 512;
|
|
|
|
|
|
|
|
nCreaturesKilled++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AIWasp::Tick(RunListEvent* ev)
|
|
|
|
{
|
2021-10-24 11:20:50 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
|
|
|
auto pSprite = &pActor->s();
|
2021-11-21 19:34:15 +00:00
|
|
|
int nAction = pActor->nAction;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
DExhumedActor* pTarget = nullptr;
|
2020-03-02 21:08:31 +00:00
|
|
|
|
|
|
|
bool bVal = false;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-11-21 19:34:15 +00:00
|
|
|
int nSeq = SeqOffsets[kSeqWasp] + WaspSeq[nAction].a;
|
2021-10-15 21:29:25 +00:00
|
|
|
|
2021-10-24 11:15:40 +00:00
|
|
|
pSprite->picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame);
|
2021-10-15 21:29:25 +00:00
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
seq_MoveSequence(pActor, nSeq, pActor->nFrame);
|
2021-10-15 21:29:25 +00:00
|
|
|
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nFrame++;
|
|
|
|
if (pActor->nFrame >= SeqSize[nSeq])
|
2021-10-15 21:29:25 +00:00
|
|
|
{
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:29:25 +00:00
|
|
|
bVal = true;
|
|
|
|
}
|
|
|
|
|
2021-10-24 11:15:40 +00:00
|
|
|
if (pActor->nHealth > 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 11:20:50 +00:00
|
|
|
pTarget = pActor->pTarget;
|
2021-10-15 21:29:25 +00:00
|
|
|
|
2021-12-18 17:40:25 +00:00
|
|
|
if (pTarget && (!(pTarget->s().cstat & CSTAT_SPRITE_BLOCK_ALL) || (pTarget->s().sector()->Flag & kSectUnderwater)))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:29:25 +00:00
|
|
|
// goto pink
|
2021-10-24 11:20:50 +00:00
|
|
|
pActor->pTarget = nullptr;
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nCount = RandomSize(6);
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-10-15 21:29:25 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:29:25 +00:00
|
|
|
switch (nAction)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:29:25 +00:00
|
|
|
case 0:
|
|
|
|
{
|
2021-10-24 11:15:40 +00:00
|
|
|
pSprite->zvel = bsin(pActor->nAngle, -4);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nAngle += pActor->nAngle2;
|
|
|
|
pActor->nAngle &= kAngleMask;
|
2021-10-15 21:29:25 +00:00
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
MoveCreature(pActor);
|
2021-10-15 21:29:25 +00:00
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
if (pTarget)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nCount--;
|
|
|
|
if (pActor->nCount > 0)
|
2021-10-15 21:29:25 +00:00
|
|
|
{
|
2021-10-24 11:20:50 +00:00
|
|
|
PlotCourseToSprite(pActor, pTarget);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:29:25 +00:00
|
|
|
else
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:29:25 +00:00
|
|
|
pSprite->zvel = 0;
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nAction = 1;
|
|
|
|
pActor->nFrame = 0;
|
|
|
|
pActor->nVel = 1500;
|
|
|
|
pActor->nCount = RandomSize(5) + 60;
|
2021-10-15 21:29:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-24 11:20:50 +00:00
|
|
|
if ((pActor->nPhase & 0x1F) == (totalmoves & 0x1F)) {
|
|
|
|
pActor->pTarget = FindPlayer(pActor, 60);
|
2021-10-15 21:29:25 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2021-10-15 21:29:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:29:25 +00:00
|
|
|
case 1:
|
|
|
|
{
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nCount--;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 11:15:40 +00:00
|
|
|
if (pActor->nCount <= 0)
|
2021-10-15 21:29:25 +00:00
|
|
|
{
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nCount = RandomSize(6);
|
2021-10-15 21:29:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
auto nChaseVal = AngleChase(pActor, pTarget, pActor->nVel, 0, 16);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
switch (nChaseVal.type)
|
2021-10-15 21:29:25 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
case kHitWall:
|
2021-10-15 21:29:25 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2020-03-02 21:08:31 +00:00
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
case kHitSprite:
|
2021-10-15 21:29:25 +00:00
|
|
|
{
|
2021-11-26 13:26:03 +00:00
|
|
|
if (nChaseVal.actor() == pTarget)
|
2021-10-15 21:29:25 +00:00
|
|
|
{
|
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
2021-10-24 11:20:50 +00:00
|
|
|
runlist_DamageEnemy(pTarget, pActor, pActor->nDamage);
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nAction = 2;
|
|
|
|
pActor->nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2021-10-15 21:29:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:29:25 +00:00
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
if (bVal)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:29:25 +00:00
|
|
|
pSprite->ang += RandomSize(9) + 768;
|
|
|
|
pSprite->ang &= kAngleMask;
|
|
|
|
pSprite->zvel = (-20) - RandomSize(6);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nAction = 1;
|
|
|
|
pActor->nVel = 3000;
|
2021-10-15 21:29:25 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case 4:
|
|
|
|
{
|
2021-10-24 11:20:50 +00:00
|
|
|
auto nMove = MoveCreature(pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 11:20:50 +00:00
|
|
|
//if (nMove.type != kHitNone) // The code messed up the return value so this check always was true.
|
2021-10-15 21:29:25 +00:00
|
|
|
{
|
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
|
|
|
pSprite->zvel = 1024;
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nAction = 5;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:29:25 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:29:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case 5:
|
|
|
|
{
|
2021-11-22 21:38:27 +00:00
|
|
|
auto pSector =pSprite->sector();
|
2021-10-15 21:29:25 +00:00
|
|
|
|
|
|
|
pSprite->z += pSprite->zvel;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-11-22 21:38:27 +00:00
|
|
|
if (pSprite->z >= pSector->floorz)
|
2021-10-15 21:29:25 +00:00
|
|
|
{
|
2021-11-22 22:05:48 +00:00
|
|
|
if (pSector->pBelow != nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-11-22 21:38:27 +00:00
|
|
|
BuildSplash(pActor, pSector);
|
2021-12-18 17:40:25 +00:00
|
|
|
pSprite->cstat |= CSTAT_SPRITE_INVISIBLE;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 21:29:25 +00:00
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
|
|
|
pSprite->zvel = 0;
|
2021-10-24 11:15:40 +00:00
|
|
|
pActor->nAction = 6;
|
|
|
|
pActor->nFrame = 0;
|
|
|
|
runlist_SubRunRec(pActor->nRun);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:29:25 +00:00
|
|
|
|
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:29:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|