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
|
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
/*
|
2019-08-31 07:47:15 +00:00
|
|
|
Selkis Boss AI code
|
2019-08-26 03:59:14 +00:00
|
|
|
*/
|
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
struct Scorpion
|
|
|
|
{
|
|
|
|
short nHealth;
|
|
|
|
short nFrame;
|
|
|
|
short nAction;
|
|
|
|
short nSprite;
|
|
|
|
short nTarget;
|
2020-11-29 19:52:16 +00:00
|
|
|
short nRun;
|
|
|
|
short nCount;
|
|
|
|
short nIndex;
|
|
|
|
int8_t nIndex2;
|
|
|
|
short nChannel;
|
2020-03-02 21:08:31 +00:00
|
|
|
};
|
|
|
|
|
2020-11-29 19:52:16 +00:00
|
|
|
TArray<Scorpion> scorpion;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2020-11-29 19:52:16 +00:00
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, Scorpion& w, Scorpion* def)
|
|
|
|
{
|
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc("health", w.nHealth)
|
|
|
|
("frame", w.nFrame)
|
|
|
|
("action", w.nAction)
|
|
|
|
("sprite", w.nSprite)
|
|
|
|
("target", w.nTarget)
|
|
|
|
("run", w.nRun)
|
|
|
|
("count", w.nCount)
|
|
|
|
("index", w.nIndex)
|
|
|
|
("index2", w.nIndex2)
|
|
|
|
("chan", w.nChannel)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SerializeScorpion(FSerializer& arc)
|
|
|
|
{
|
|
|
|
arc("scorpion", scorpion);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
void InitScorp()
|
|
|
|
{
|
2020-11-29 19:52:16 +00:00
|
|
|
scorpion.Clear();
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 16:37:39 +00:00
|
|
|
void BuildScorp(short nSprite, int x, int y, int z, short nSector, short nAngle, int nChannel)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2020-11-29 19:52:16 +00:00
|
|
|
auto nScorp = scorpion.Reserve(1);
|
2021-10-24 10:20:26 +00:00
|
|
|
auto pActor = &scorpion[nScorp];
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
2021-09-06 06:33:02 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nSprite == -1)
|
|
|
|
{
|
|
|
|
nSprite = insertsprite(nSector, 122);
|
2021-10-15 21:13:28 +00:00
|
|
|
pSprite = &sprite[nSprite];
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
changespritestat(nSprite, 122);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
assert(nSprite >= 0 && nSprite < kMaxSprites);
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->x = x;
|
|
|
|
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;
|
|
|
|
pActor->nSprite = nSprite;
|
|
|
|
pActor->nTarget = -1;
|
|
|
|
pActor->nCount = 0;
|
|
|
|
pActor->nIndex2 = 1;
|
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-15 16:37:39 +00:00
|
|
|
pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nScorp, 0x220000);
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nRun = runlist_AddRunRec(NewRun, nScorp, 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-17 14:22:25 +00:00
|
|
|
short nScorp = RunData[ev->nRun].nObjIndex;
|
2020-11-29 19:52:16 +00:00
|
|
|
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
2021-10-24 10:20:26 +00:00
|
|
|
auto pActor = &scorpion[nScorp];
|
|
|
|
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-17 14:22:25 +00:00
|
|
|
short nScorp = RunData[ev->nRun].nObjIndex;
|
2021-10-15 21:13:28 +00:00
|
|
|
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
2021-10-24 10:20:26 +00:00
|
|
|
auto pActor = &scorpion[nScorp];
|
|
|
|
short nSprite = pActor->nSprite;
|
2021-10-15 21:13:28 +00:00
|
|
|
|
|
|
|
ev->nDamage = runlist_CheckRadialDamage(nSprite);
|
|
|
|
if (ev->nDamage) Damage(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AIScorp::Damage(RunListEvent* ev)
|
|
|
|
{
|
2021-10-17 14:22:25 +00:00
|
|
|
short nScorp = RunData[ev->nRun].nObjIndex;
|
2021-10-15 21:13:28 +00:00
|
|
|
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
2021-10-24 10:20:26 +00:00
|
|
|
auto pActor = &scorpion[nScorp];
|
|
|
|
short nSprite = pActor->nSprite;
|
2021-10-15 21:13:28 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
short nAction = pActor->nAction;
|
2021-10-15 21:13:28 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-03-02 21:08:31 +00:00
|
|
|
bool bVal = false;
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
short nTarget = -1;
|
|
|
|
|
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-17 14:22:25 +00:00
|
|
|
nTarget = ev->nParam;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
if (nTarget >= 0)
|
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-24 10:20:26 +00:00
|
|
|
pActor->nTarget = nTarget;
|
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-15 21:13:28 +00:00
|
|
|
D3PlayFX(StaticSound[kSound41], nSprite);
|
|
|
|
Effect(ev, nTarget, 0);
|
|
|
|
}
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
void AIScorp::Tick(RunListEvent* ev)
|
|
|
|
{
|
2021-10-17 14:22:25 +00:00
|
|
|
short nScorp = RunData[ev->nRun].nObjIndex;
|
2021-10-15 21:13:28 +00:00
|
|
|
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
2021-10-24 10:20:26 +00:00
|
|
|
auto pActor = &scorpion[nScorp];
|
|
|
|
short nSprite = pActor->nSprite;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
short nAction = pActor->nAction;
|
2021-10-15 21:13:28 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
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-15 21:13:28 +00:00
|
|
|
short nTarget = -1;
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
if (pActor->nHealth) {
|
2021-10-15 21:13:28 +00:00
|
|
|
Gravity(nSprite);
|
|
|
|
}
|
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);
|
|
|
|
seq_MoveSequence(nSprite, 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];
|
|
|
|
nTarget = pActor->nTarget;
|
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-15 21:13:28 +00:00
|
|
|
if ((nScorp & 0x1F) == (totalmoves & 0x1F))
|
|
|
|
{
|
|
|
|
if (nTarget < 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:13:28 +00:00
|
|
|
nTarget = FindPlayer(nSprite, 500);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
if (nTarget >= 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:13:28 +00:00
|
|
|
D3PlayFX(StaticSound[kSound41], nSprite);
|
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;
|
|
|
|
pActor->nTarget = nTarget;
|
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-15 21:13:28 +00:00
|
|
|
Effect(ev, nTarget, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int nMov = MoveCreatureWithCaution(nSprite);
|
|
|
|
if ((nMov & 0xC000) == 0xC000)
|
|
|
|
{
|
|
|
|
if (nTarget == (nMov & 0x3FFF))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:13:28 +00:00
|
|
|
int nAngle = getangle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
|
|
|
|
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-15 21:13:28 +00:00
|
|
|
Effect(ev, nTarget, 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-15 21:13:28 +00:00
|
|
|
Effect(ev, nTarget, 0);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if ((nMov & 0xC000) == 0x8000)
|
|
|
|
{
|
|
|
|
Effect(ev, nTarget, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Effect(ev, nTarget, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-15 21:13:28 +00:00
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
if (nTarget == -1)
|
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nCount = 5;
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (PlotCourseToSprite(nSprite, nTarget) >= 768)
|
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = 1;
|
2021-10-15 21:13:28 +00:00
|
|
|
}
|
|
|
|
else if (nFlag & 0x80)
|
|
|
|
{
|
|
|
|
runlist_DamageEnemy(nTarget, nSprite, 7);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Effect(ev, nTarget, 2);
|
|
|
|
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-15 21:13:28 +00:00
|
|
|
int nBulletSprite = BuildBullet(nSprite, 16, 0, 0, -1, pSprite->ang, nTarget + 10000, 1);
|
|
|
|
if (nBulletSprite > -1)
|
|
|
|
{
|
|
|
|
PlotCourseToSprite(nBulletSprite & 0xffff, nTarget);
|
|
|
|
}
|
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-15 21:13:28 +00:00
|
|
|
int nSpiderSprite = BuildSpider(-1, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, pSprite->ang);
|
|
|
|
if (nSpiderSprite != -1)
|
|
|
|
{
|
|
|
|
sprite[nSpiderSprite].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-15 21:13:28 +00:00
|
|
|
sprite[nSpiderSprite].xvel = bcos(sprite[nSpiderSprite].ang, -8) * nVel;
|
|
|
|
sprite[nSpiderSprite].yvel = bsin(sprite[nSpiderSprite].ang, -8) * nVel;
|
|
|
|
sprite[nSpiderSprite].zvel = (-(RandomSize(5) + 3)) << 8;
|
|
|
|
}
|
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-15 21:13:28 +00:00
|
|
|
mydeletesprite(nSprite);
|
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-15 21:13:28 +00:00
|
|
|
void AIScorp::Effect(RunListEvent* ev, int nTarget, int mode)
|
|
|
|
{
|
2021-10-17 14:22:25 +00:00
|
|
|
short nScorp = RunData[ev->nRun].nObjIndex;
|
2021-10-15 21:13:28 +00:00
|
|
|
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
2021-10-24 10:20:26 +00:00
|
|
|
auto pActor = &scorpion[nScorp];
|
|
|
|
short nSprite = pActor->nSprite;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-24 10:20:26 +00:00
|
|
|
short nAction = pActor->nAction;
|
2021-10-15 21:13:28 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
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-15 21:13:28 +00:00
|
|
|
PlotCourseToSprite(nSprite, nTarget);
|
|
|
|
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-15 21:13:28 +00:00
|
|
|
if (cansee(pSprite->x, pSprite->y, pSprite->z - GetSpriteHeight(nSprite), pSprite->sectnum,
|
|
|
|
sprite[nTarget].x, sprite[nTarget].y, sprite[nTarget].z - GetSpriteHeight(nTarget), sprite[nTarget].sectnum))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-15 21:13:28 +00:00
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
|
|
|
pSprite->ang = GetMyAngle(sprite[nTarget].x - pSprite->x, sprite[nTarget].y - pSprite->y);
|
|
|
|
|
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
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (!nAction || nTarget == -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(sprite[nTarget].cstat & 0x101))
|
|
|
|
{
|
2021-10-24 10:20:26 +00:00
|
|
|
pActor->nAction = 0;
|
|
|
|
pActor->nFrame = 0;
|
|
|
|
pActor->nCount = 30;
|
|
|
|
pActor->nTarget = -1;
|
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
|