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 "engine.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "exhumed.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 ScorpSeq[] = {
|
2019-08-31 07:47:15 +00:00
|
|
|
{0, 0},
|
|
|
|
{8, 0},
|
|
|
|
{29, 0},
|
|
|
|
{19, 0},
|
|
|
|
{45, 1},
|
|
|
|
{46, 1},
|
|
|
|
{47, 1},
|
|
|
|
{48, 1},
|
|
|
|
{50, 1},
|
|
|
|
{53, 1}
|
2019-08-26 03:59:14 +00:00
|
|
|
};
|
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
void BuildScorp(DExhumedActor* pActor, int x, int y, int z, short nSector, short nAngle, int nChannel)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
spritetype* pSprite;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
if (pActor == nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
pActor = insertActor(nSector, 122);
|
|
|
|
pSprite = &pActor->s();
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
ChangeActorStat(pActor, 122);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
pSprite = &pActor->s();
|
2021-09-06 06:33:02 +00:00
|
|
|
x = pSprite->x;
|
|
|
|
y = pSprite->y;
|
|
|
|
z = sector[pSprite->sectnum].floorz;
|
|
|
|
nAngle = pSprite->ang;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
pSprite->x = x;
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->y = y;
|
|
|
|
pSprite->z = z;
|
|
|
|
pSprite->cstat = 0x101;
|
|
|
|
pSprite->clipdist = 70;
|
|
|
|
pSprite->shade = -12;
|
|
|
|
pSprite->xrepeat = 80;
|
|
|
|
pSprite->yrepeat = 80;
|
|
|
|
pSprite->picnum = 1;
|
|
|
|
pSprite->pal = sector[pSprite->sectnum].ceilingpal;
|
|
|
|
pSprite->xoffset = 0;
|
|
|
|
pSprite->yoffset = 0;
|
|
|
|
pSprite->ang = nAngle;
|
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
|
|
|
pSprite->zvel = 0;
|
|
|
|
pSprite->lotag = runlist_HeadRun() + 1;
|
|
|
|
pSprite->extra = -1;
|
|
|
|
pSprite->hitag = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
// GrabTimeSlot(3);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nHealth = 20000;
|
|
|
|
pActor->nFrame = 0;
|
|
|
|
pActor->nAction = 0;
|
2021-10-18 16:57:16 +00:00
|
|
|
pActor->pTarget = nullptr;
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nCount = 0;
|
|
|
|
pActor->nIndex2 = 1;
|
2021-10-18 16:57:16 +00:00
|
|
|
pActor->nPhase = Counters[kCountScorp]++;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nChannel = nChannel;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, pActor, 0x220000);
|
|
|
|
pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x220000);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-23 12:39:14 +00:00
|
|
|
nCreaturesTotal++;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
void AIScorp::Draw(RunListEvent* ev)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
short nAction = pActor->nAction;
|
2021-10-15 21:13:28 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
seq_PlotSequence(ev->nParam, SeqOffsets[kSeqScorp] + ScorpSeq[nAction].a, pActor->nFrame, ScorpSeq[nAction].b);
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
void AIScorp::RadialDamage(RunListEvent* ev)
|
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
2021-10-15 21:13:28 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
ev->nDamage = runlist_CheckRadialDamage(pActor);
|
2021-10-15 21:13:28 +00:00
|
|
|
if (ev->nDamage) Damage(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AIScorp::Damage(RunListEvent* ev)
|
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
2021-10-15 21:13:28 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
short nAction = pActor->nAction;
|
2021-10-18 16:57:16 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
bool bVal = false;
|
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
DExhumedActor* pTarget = nullptr;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
if (pActor->nHealth <= 0) {
|
2021-10-15 21:13:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nHealth -= dmgAdjust(ev->nDamage);
|
2021-10-15 21:13:28 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
if (pActor->nHealth <= 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nHealth = 0;
|
|
|
|
pActor->nAction = 4;
|
|
|
|
pActor->nFrame = 0;
|
|
|
|
pActor->nCount = 10;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
|
|
|
pSprite->zvel = 0;
|
|
|
|
pSprite->cstat &= 0xFEFE;
|
|
|
|
|
|
|
|
nCreaturesKilled++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
pTarget = ev->pOtherActor;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
if (pTarget)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:13:28 +00:00
|
|
|
if (pSprite->statnum == 100 || (pSprite->statnum < 199 && !RandomSize(5)))
|
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
pActor->pTarget = pTarget;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
if (!RandomSize(5))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = RandomSize(2) + 4;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:13:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
if (RandomSize(2)) {
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
D3PlayFX(StaticSound[kSound41], pActor);
|
|
|
|
Effect(ev, pTarget, 0);
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
void AIScorp::Tick(RunListEvent* ev)
|
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
short nAction = pActor->nAction;
|
2021-10-18 16:57:16 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
bool bVal = false;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
DExhumedActor* pTarget = nullptr;
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
if (pActor->nHealth) {
|
2021-10-18 16:57:16 +00:00
|
|
|
Gravity(pActor);
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
int nSeq = SeqOffsets[kSeqScorp] + ScorpSeq[nAction].a;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
pSprite->picnum = seq_GetSeqPicnum2(nSeq, pActor->nFrame);
|
2021-10-18 16:57:16 +00:00
|
|
|
seq_MoveSequence(pActor, nSeq, pActor->nFrame);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nFrame++;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
if (pActor->nFrame >= SeqSize[nSeq])
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:13:28 +00:00
|
|
|
bVal = true;
|
|
|
|
}
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
int nFlag = FrameFlag[SeqBase[nSeq] + pActor->nFrame];
|
2021-10-18 16:57:16 +00:00
|
|
|
pTarget = pActor->pTarget;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
switch (nAction)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
case 0:
|
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
if (pActor->nCount > 0)
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nCount--;
|
2021-10-15 21:13:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
if ((pActor->nPhase & 0x1F) == (totalmoves & 0x1F))
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
if (pTarget == nullptr)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
pTarget = FindPlayer(pActor, 500);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
if (pTarget)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
D3PlayFX(StaticSound[kSound41], pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:13:28 +00:00
|
|
|
pSprite->xvel = bcos(pSprite->ang);
|
|
|
|
pSprite->yvel = bsin(pSprite->ang);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = 1;
|
2021-10-18 16:57:16 +00:00
|
|
|
pActor->pTarget = pTarget;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
case 1:
|
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nIndex2--;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
if (pActor->nIndex2 <= 0)
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nIndex2 = RandomSize(5);
|
2021-10-18 16:57:16 +00:00
|
|
|
Effect(ev, pTarget, 0);
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
auto nMov = MoveCreatureWithCaution(pActor);
|
|
|
|
if (nMov.type == kHitSprite)
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
if (pTarget == nMov.actor)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
int nAngle = getangle(pTarget->s().x - pSprite->x, pTarget->s().y - pSprite->y);
|
2021-10-15 21:13:28 +00:00
|
|
|
if (AngleDiff(pSprite->ang, nAngle) < 64)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = 2;
|
|
|
|
pActor->nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-18 16:57:16 +00:00
|
|
|
Effect(ev, pTarget, 2);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:13:28 +00:00
|
|
|
else
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
Effect(ev, pTarget, 0);
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2021-10-18 16:57:16 +00:00
|
|
|
else if (nMov.type == kHitWall)
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
Effect(ev, pTarget, 0);
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
Effect(ev, pTarget, 1);
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
case 2:
|
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
if (pTarget == nullptr)
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nCount = 5;
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
if (PlotCourseToSprite(pActor, pTarget) >= 768)
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = 1;
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
else if (nFlag & 0x80)
|
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
runlist_DamageEnemy(pTarget, pActor, 7);
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-18 16:57:16 +00:00
|
|
|
Effect(ev, pTarget, 2);
|
2021-10-15 21:13:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
if (bVal)
|
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nIndex--;
|
|
|
|
if (pActor->nIndex <= 0)
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = 1;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
pSprite->xvel = bcos(pSprite->ang);
|
|
|
|
pSprite->yvel = bsin(pSprite->ang);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:13:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
if (!(nFlag & 0x80)) {
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
auto nBulletSprite = BuildBullet(pActor, 16, -1, pSprite->ang, pTarget, 1);
|
|
|
|
if (nBulletSprite)
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
PlotCourseToSprite(nBulletSprite, pTarget);
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
{
|
|
|
|
if (!bVal) {
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
if (pActor->nHealth > 0)
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = 1;
|
|
|
|
pActor->nFrame = 0;
|
|
|
|
pActor->nCount = 0;
|
2021-10-15 21:13:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nCount--;
|
|
|
|
if (pActor->nCount <= 0)
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = 8;
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = RandomBit() + 6;
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
if (bVal)
|
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction++; // set to 9
|
|
|
|
pActor->nFrame = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
runlist_ChangeChannel(pActor->nChannel, 1);
|
2021-10-15 21:13:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
auto pSpiderActor = BuildSpider(nullptr, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, pSprite->ang);
|
|
|
|
if (pSpiderActor)
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
auto pSpiderSprite = &pSpiderActor->s();
|
|
|
|
pSpiderSprite->ang = RandomSize(11);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
int nVel = RandomSize(5) + 1;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
pSpiderSprite->xvel = bcos(pSpiderSprite->ang, -8) * nVel;
|
|
|
|
pSpiderSprite->yvel = bsin(pSpiderSprite->ang, -8) * nVel;
|
|
|
|
pSpiderSprite->zvel = (-(RandomSize(5) + 3)) << 8;
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
case 9:
|
|
|
|
{
|
|
|
|
pSprite->cstat &= 0xFEFE;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
if (bVal)
|
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
runlist_SubRunRec(pActor->nRun);
|
2021-10-15 21:13:28 +00:00
|
|
|
runlist_DoSubRunRec(pSprite->owner);
|
|
|
|
runlist_FreeRun(pSprite->lotag - 1);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
DeleteActor(pActor);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:13:28 +00:00
|
|
|
|
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
void AIScorp::Effect(RunListEvent* ev, DExhumedActor* pTarget, int mode)
|
2021-10-15 21:13:28 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
short nAction = pActor->nAction;
|
2021-10-18 16:57:16 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
bool bVal = false;
|
|
|
|
|
|
|
|
if (mode == 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-18 16:57:16 +00:00
|
|
|
PlotCourseToSprite(pActor, pTarget);
|
2021-10-15 21:13:28 +00:00
|
|
|
pSprite->ang += RandomSize(7) - 63;
|
|
|
|
pSprite->ang &= kAngleMask;
|
|
|
|
|
|
|
|
pSprite->xvel = bcos(pSprite->ang);
|
|
|
|
pSprite->yvel = bsin(pSprite->ang);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2021-10-15 21:13:28 +00:00
|
|
|
if (mode <= 1)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
if (pActor->nCount)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nCount--;
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nCount = 45;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
if (cansee(pSprite->x, pSprite->y, pSprite->z - GetActorHeight(pActor), pSprite->sectnum,
|
|
|
|
pTarget->s().x, pTarget->s().y, pTarget->s().z - GetActorHeight(pTarget), pTarget->s().sectnum))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:13:28 +00:00
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
2021-10-18 16:57:16 +00:00
|
|
|
pSprite->ang = GetMyAngle(pTarget->s().x - pSprite->x, pTarget->s().y - pSprite->y);
|
2021-10-15 21:13:28 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nIndex = RandomSize(2) + RandomSize(3);
|
2021-10-15 21:13:28 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
if (!pActor->nIndex) {
|
|
|
|
pActor->nCount = RandomSize(5);
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = 3;
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
if (!nAction || pTarget == nullptr) {
|
2019-08-31 07:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-18 16:57:16 +00:00
|
|
|
if (!(pTarget->s().cstat & 0x101))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nFrame = 0;
|
|
|
|
pActor->nCount = 30;
|
2021-10-18 16:57:16 +00:00
|
|
|
pActor->pTarget = nullptr;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
2021-10-15 21:13:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
|
|
|
{
|
|
|
|
AIScorp ai;
|
|
|
|
runlist_DispatchEvent(&ai, nObject, nMessage, nDamage, nRun);
|
|
|
|
}
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|