raze/source/games/exhumed/src/queen.cpp

1521 lines
36 KiB
C++
Raw Normal View History

//-------------------------------------------------------------------------
/*
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.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "aistuff.h"
#include "exhumed.h"
#include "engine.h"
#include "sequence.h"
#include "player.h"
2019-09-21 15:47:55 +00:00
#include "sound.h"
#include "names.h"
#include <assert.h>
BEGIN_PS_NS
enum
{
2021-10-15 20:55:03 +00:00
kMaxQueens = 1,
kMaxEggs = 10,
kMaxTails = 7
};
short QueenCount = 0;
static actionSeq QueenSeq[] = {
{0, 0},
{0, 0},
{9, 0},
{36, 0},
{18, 0},
{27, 0},
{45, 0},
{45, 0},
{54, 1},
{53, 1},
{55, 1}
};
static actionSeq HeadSeq[] = {
{56, 1},
{65, 0},
{65, 0},
{65, 0},
{65, 0},
{65, 0},
{74, 0},
{82, 0},
{90, 0}
};
static actionSeq EggSeq[] = {
{19, 1},
{18, 1},
{0, 0},
{9, 0},
{23, 1},
};
struct Queen
{
2021-10-26 19:10:51 +00:00
DExhumedActor* pActor;
DExhumedActor* pTarget;
short nHealth;
short nFrame;
short nAction;
short nAction2;
short nIndex;
short nIndex2;
short nChannel;
};
struct Egg
{
2021-10-26 18:13:03 +00:00
DExhumedActor* pActor;
DExhumedActor* pTarget;
short nHealth;
2020-11-29 23:40:25 +00:00
short nFrame;
short nAction;
short nRun;
short nCounter;
};
struct Head
{
DExhumedActor* pActor;
DExhumedActor* pTarget;
short nHealth;
2020-11-29 23:40:25 +00:00
short nFrame;
short nAction;
short nRun;
short nIndex;
short nIndex2;
short nChannel;
};
2020-11-29 23:40:25 +00:00
FreeListArray<Egg, kMaxEggs> QueenEgg;
int nQHead = 0;
short nHeadVel;
short nVelShift;
2021-10-26 19:10:51 +00:00
DExhumedActor* tailspr[kMaxTails];
2020-11-29 23:40:25 +00:00
Queen QueenList[kMaxQueens];
Head QueenHead;
int MoveQX[25];
int MoveQY[25];
int MoveQZ[25];
short MoveQS[25];
short MoveQA[25];
2020-11-29 23:40:25 +00:00
FSerializer& Serialize(FSerializer& arc, const char* keyname, Queen& w, Queen* def)
{
if (arc.BeginObject(keyname))
{
arc("health", w.nHealth)
("frame", w.nFrame)
("action", w.nAction)
2021-10-26 19:10:51 +00:00
("sprite", w.pActor)
("target", w.pTarget)
("ata", w.nAction2)
("atc", w.nIndex)
("at10", w.nIndex2)
2020-11-29 23:40:25 +00:00
.EndObject();
}
return arc;
}
2020-11-29 23:40:25 +00:00
FSerializer& Serialize(FSerializer& arc, const char* keyname, Egg& w, Egg* def)
{
if (arc.BeginObject(keyname))
{
arc("health", w.nHealth)
("frame", w.nFrame)
("action", w.nAction)
2021-10-26 18:13:03 +00:00
("sprite", w.pActor)
("target", w.pTarget)
("runptr", w.nRun)
("atc", w.nCounter)
2020-11-29 23:40:25 +00:00
.EndObject();
}
return arc;
}
2020-11-29 23:40:25 +00:00
FSerializer& Serialize(FSerializer& arc, const char* keyname, Head& w, Head* def)
{
if (arc.BeginObject(keyname))
{
arc("health", w.nHealth)
("frame", w.nFrame)
("action", w.nAction)
("sprite", w.pActor)
("target", w.pTarget)
("at8", w.nRun)
("atc", w.nIndex)
("tails", w.nIndex2)
2020-11-29 23:40:25 +00:00
.EndObject();
}
return arc;
}
2020-11-29 23:40:25 +00:00
void SerializeQueen(FSerializer& arc)
{
if (arc.BeginObject("queen"))
{
arc("count", QueenCount);
if (QueenCount == 0) // only save the rest if we got a queen. There can only be one.
{
for (int i = 0; i < kMaxEggs; i++)
{
QueenEgg[i].nRun = -1;
}
2020-11-29 23:40:25 +00:00
arc("qhead", nQHead)
("headvel", nHeadVel)
("velshift", nVelShift)
("head", QueenHead)
.Array("tailspr", tailspr, countof(tailspr))
("queen", QueenList[0])
("eggs", QueenEgg)
.Array("moveqx", MoveQX, countof(MoveQX))
.Array("moveqy", MoveQY, countof(MoveQY))
.Array("moveqz", MoveQZ, countof(MoveQZ))
.Array("moveqa", MoveQA, countof(MoveQA))
.Array("moveqs", MoveQS, countof(MoveQS));
}
arc.EndObject();
}
}
void InitQueens()
{
QueenCount = 1;
2020-11-29 23:40:25 +00:00
QueenEgg.Clear();
for (int i = 0; i < kMaxEggs; i++)
{
QueenEgg[i].nRun = -1;
}
}
int GrabEgg()
{
2020-11-29 23:40:25 +00:00
auto egg = QueenEgg.Get();
if (egg == -1) return -1;
return egg;
}
2021-10-26 19:10:51 +00:00
void BlowChunks(DExhumedActor* pActor)
{
for (int i = 0; i < 4; i++)
{
2021-10-26 19:15:07 +00:00
BuildCreatureChunk(pActor, seq_GetSeqPicnum(16, i + 41, 0));
}
}
void DestroyEgg(short nEgg)
{
2021-10-26 18:13:03 +00:00
auto pActor = QueenEgg[nEgg].pActor;
auto pSprite = &pActor->s();
if (QueenEgg[nEgg].nAction != 4)
{
BuildAnim(nullptr, 34, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, pSprite->xrepeat, 4);
}
else
{
for (int i = 0; i < 4; i++)
{
2021-10-26 19:15:07 +00:00
BuildCreatureChunk(pActor, seq_GetSeqPicnum(kSeqQueenEgg, (i % 2) + 24, 0));
}
}
runlist_DoSubRunRec(pSprite->owner);
runlist_DoSubRunRec(pSprite->lotag - 1);
runlist_SubRunRec(QueenEgg[nEgg].nRun);
QueenEgg[nEgg].nRun = -1;
2021-10-26 18:13:03 +00:00
DeleteActor(pActor);
2020-11-29 23:40:25 +00:00
QueenEgg.Release(nEgg);
}
void DestroyAllEggs()
{
for (int i = 0; i < kMaxEggs; i++)
{
if (QueenEgg[i].nRun > -1)
{
DestroyEgg(i);
}
}
}
void SetHeadVel(DExhumedActor* pActor)
{
auto pSprite = &pActor->s();
short nAngle = pSprite->ang;
pSprite->xvel = bcos(nAngle, nVelShift);
pSprite->yvel = bsin(nAngle, nVelShift);
}
2021-10-26 18:52:25 +00:00
Collision QueenAngleChase(DExhumedActor* pActor, DExhumedActor* pActor2, int val1, int val2)
{
short nAngle;
2021-10-26 18:52:25 +00:00
spritetype* pSprite = &pActor->s();
if (pActor2 == nullptr)
{
pSprite->zvel = 0;
nAngle = pSprite->ang;
}
else
{
2021-10-26 18:52:25 +00:00
spritetype* pSprite2 = &pActor2->s();
int nTileY = (tileHeight(pSprite2->picnum) * pSprite2->yrepeat) * 2;
int nMyAngle = GetMyAngle(pSprite2->x - pSprite->x, pSprite2->y - pSprite->y);
int edx = ((pSprite2->z - nTileY) - pSprite->z) >> 8;
uint32_t xDiff = abs(pSprite2->x - pSprite->x);
uint32_t yDiff = abs(pSprite2->y - pSprite->y);
uint32_t sqrtVal = xDiff * xDiff + yDiff * yDiff;
if (sqrtVal > INT_MAX)
{
DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__);
sqrtVal = INT_MAX;
}
int nSqrt = ksqrt(sqrtVal);
int var_14 = GetMyAngle(nSqrt, edx);
int nAngDelta = AngleDelta(pSprite->ang, nMyAngle, 1024);
if (abs(nAngDelta) > 127)
{
2021-10-15 20:55:03 +00:00
val1 /= abs(nAngDelta >> 7);
if (val1 < 256)
val1 = 256;
}
if (abs(nAngDelta) > val2)
{
if (nAngDelta < 0)
nAngDelta = -val2;
else
nAngDelta = val2;
}
nAngle = (nAngDelta + pSprite->ang) & kAngleMask;
pSprite->zvel = (AngleDelta(pSprite->zvel, var_14, 24) + pSprite->zvel) & kAngleMask;
}
pSprite->ang = nAngle;
int da = pSprite->zvel;
int x = abs(bcos(da));
int v26 = x * ((val1 * bcos(nAngle)) >> 14);
int v27 = x * ((val1 * bsin(nAngle)) >> 14);
uint32_t xDiff = abs((int32_t)(v26 >> 8));
uint32_t yDiff = abs((int32_t)(v27 >> 8));
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;
if (sqrtNum > INT_MAX)
{
DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__);
sqrtNum = INT_MAX;
}
int nSqrt = ksqrt(sqrtNum) * bsin(da);
2021-10-26 18:52:25 +00:00
return movesprite(pActor, v26 >> 2, v27 >> 2, bsin(bobangle, -5) + (nSqrt >> 13), 0, 0, CLIPMASK1);
}
int DestroyTailPart()
{
if (!QueenHead.nIndex2) {
return 0;
}
2021-10-26 19:10:51 +00:00
auto pActor = tailspr[--QueenHead.nIndex2];
2021-10-26 19:10:51 +00:00
BlowChunks(pActor);
BuildExplosion(pActor);
for (int i = 0; i < 5; i++)
{
2021-10-26 19:10:51 +00:00
short nHeight = GetActorHeight(pActor);
BuildLavaLimb(pActor, i, nHeight);
}
2021-10-26 19:10:51 +00:00
DeleteActor(pActor);
return 1;
}
void BuildTail()
{
auto pSprite = &QueenHead.pActor->s();
int x = pSprite->x;
int y = pSprite->x;
int z = pSprite->x;
int nSector =pSprite->sectnum;
int i;
for (i = 0; i < kMaxTails; i++)
{
2021-10-26 19:10:51 +00:00
auto pTailActor = insertActor(nSector, 121);
auto pTailSprite = &pTailActor->s();
tailspr[i] = pTailActor;
pTailSprite->lotag = runlist_HeadRun() + 1;
2021-10-26 19:10:51 +00:00
pTailSprite->owner = runlist_AddRunRec(pTailSprite->lotag - 1, (i + 1), 0x1B0000);
pTailSprite->shade = -12;
pTailSprite->x = x;
pTailSprite->y = y;
pTailSprite->hitag = 0;
pTailSprite->cstat = 0;
pTailSprite->clipdist = 100;
pTailSprite->xrepeat = 80;
pTailSprite->yrepeat = 80;
pTailSprite->picnum = 1;
2021-10-26 19:10:51 +00:00
pTailSprite->pal = sector[pTailSprite->sectnum].ceilingpal;
pTailSprite->xoffset = 0;
pTailSprite->yoffset = 0;
pTailSprite->z = z;
pTailSprite->extra = -1;
}
for (i = 0; i < 24 + 1; i++)
{
MoveQX[i] = x;
MoveQZ[i] = z;
MoveQY[i] = y;
assert(nSector >= 0 && nSector < kMaxSectors);
MoveQS[i] = nSector;
}
nQHead = 0;
QueenHead.nIndex2 = 7;
}
void BuildQueenEgg(short nQueen, int nVal)
{
int nEgg = GrabEgg();
if (nEgg < 0) {
return;
}
2021-10-26 19:10:51 +00:00
auto pActor = QueenList[nQueen].pActor;
auto pSprite = &pActor->s();
int x = pSprite->x;
int y = pSprite->y;
int nSector =pSprite->sectnum;
int nFloorZ = sector[nSector].floorz;
short nAngle = pSprite->ang;
2021-10-26 18:13:03 +00:00
auto pActor2 = insertActor(nSector, 121);
auto pSprite2 = &pActor2->s();
pSprite2->x = x;
pSprite2->y = y;
pSprite2->z = nFloorZ;
pSprite2->pal = 0;
pSprite2->clipdist = 50;
pSprite2->xoffset = 0;
pSprite2->yoffset = 0;
pSprite2->shade = -12;
pSprite2->picnum = 1;
pSprite2->ang = (RandomSize(9) + (nAngle - 256)) & kAngleMask;
pSprite2->backuppos();
if (!nVal)
{
pSprite2->xrepeat = 30;
pSprite2->yrepeat = 30;
pSprite2->xvel = bcos(pSprite2->ang);
pSprite2->yvel = bsin(pSprite2->ang);
pSprite2->zvel = -6000;
pSprite2->cstat = 0;
}
else
{
pSprite2->xrepeat = 60;
pSprite2->yrepeat = 60;
pSprite2->xvel = 0;
pSprite2->yvel = 0;
pSprite2->zvel = -2000;
pSprite2->cstat = 0x101;
}
pSprite2->lotag = runlist_HeadRun() + 1;
pSprite2->extra = -1;
pSprite2->hitag = 0;
GrabTimeSlot(3);
QueenEgg[nEgg].nHealth = 200;
2020-11-29 23:40:25 +00:00
QueenEgg[nEgg].nFrame = 0;
2021-10-26 18:13:03 +00:00
QueenEgg[nEgg].pActor = pActor2;
2021-10-26 19:10:51 +00:00
QueenEgg[nEgg].pTarget = QueenList[nQueen].pTarget;
if (nVal)
{
nVal = 4;
QueenEgg[nEgg].nCounter = 200;
}
QueenEgg[nEgg].nAction = nVal;
pSprite2->owner = runlist_AddRunRec(pSprite2->lotag - 1, nEgg, 0x1D0000);
QueenEgg[nEgg].nRun = runlist_AddRunRec(NewRun, nEgg, 0x1D0000);
}
2021-10-15 20:55:03 +00:00
void AIQueenEgg::Tick(RunListEvent* ev)
{
short nEgg = RunData[ev->nRun].nObjIndex;
2021-10-15 20:55:03 +00:00
Egg* pEgg = &QueenEgg[nEgg];
2021-10-26 18:13:03 +00:00
auto pActor = pEgg->pActor;
auto pSprite = &pActor->s();
short nAction = pEgg->nAction;
2021-10-26 18:13:03 +00:00
DExhumedActor* pTarget = nullptr;
bool bVal = false;
2021-10-15 20:55:03 +00:00
if (pEgg->nHealth <= 0)
{
DestroyEgg(nEgg);
return;
}
if (nAction == 0 || nAction == 4) {
2021-10-26 18:13:03 +00:00
Gravity(pActor);
2021-10-15 20:55:03 +00:00
}
short nSeq = SeqOffsets[kSeqQueenEgg] + EggSeq[nAction].a;
pSprite->picnum = seq_GetSeqPicnum2(nSeq, pEgg->nFrame);
if (nAction != 4)
{
2021-10-26 18:13:03 +00:00
seq_MoveSequence(pActor, nSeq, pEgg->nFrame);
2021-10-15 20:55:03 +00:00
pEgg->nFrame++;
if (pEgg->nFrame >= SeqSize[nSeq])
{
2021-10-15 20:55:03 +00:00
pEgg->nFrame = 0;
bVal = true;
}
2021-10-26 18:13:03 +00:00
pTarget = UpdateEnemy(&pEgg->pActor);
pEgg->pTarget = pTarget;
2021-10-15 20:55:03 +00:00
2021-10-26 18:13:03 +00:00
if (pTarget && (pTarget->s().cstat & 0x101) == 0)
2021-10-15 20:55:03 +00:00
{
2021-10-26 18:13:03 +00:00
pEgg->pTarget = nullptr;
2021-10-15 20:55:03 +00:00
pEgg->nAction = 0;
}
else
{
2021-10-26 18:13:03 +00:00
pTarget = FindPlayer(pActor, 1000, true);
pEgg->pTarget = pTarget;
2021-10-15 20:55:03 +00:00
}
}
switch (nAction)
{
case 0:
{
2021-10-26 18:13:03 +00:00
auto nMov = MoveCreature(pActor);
2021-10-26 18:13:03 +00:00
if (nMov.exbits & kHitAux2)
{
2021-10-15 20:55:03 +00:00
if (!RandomSize(1))
{
pEgg->nAction = 1;
pEgg->nFrame = 0;
}
else
{
DestroyEgg(nEgg);
}
2021-10-15 20:55:03 +00:00
}
else
{
short nAngle;
2021-10-26 18:13:03 +00:00
switch (nMov.type)
2021-10-15 20:55:03 +00:00
{
default:
return;
2021-10-26 18:13:03 +00:00
case kHitWall:
nAngle = GetWallNormal(nMov.index);
2021-10-15 20:55:03 +00:00
break;
2021-10-26 18:13:03 +00:00
case kHitSprite:
nAngle = nMov.actor->s().ang;
2021-10-15 20:55:03 +00:00
break;
}
2021-10-15 20:55:03 +00:00
pSprite->ang = nAngle;
pSprite->xvel = bcos(nAngle, -1);
pSprite->yvel = bsin(nAngle, -1);
}
2021-10-15 20:55:03 +00:00
break;
}
2021-10-15 20:55:03 +00:00
case 1:
{
if (bVal)
{
pEgg->nAction = 3;
pSprite->cstat = 0x101;
}
break;
}
2021-10-15 20:55:03 +00:00
case 2:
case 3:
{
2021-10-26 18:52:25 +00:00
auto nMov = QueenAngleChase(pActor, pTarget, nHeadVel, 64);
2021-10-26 18:52:25 +00:00
switch (nMov.type)
2021-10-15 20:55:03 +00:00
{
2021-10-26 18:52:25 +00:00
case kHitSprite:
if (nMov.actor->s().statnum != 121)
{
2021-10-26 18:52:25 +00:00
runlist_DamageEnemy(nMov.actor, pActor, 5);
2021-10-15 20:55:03 +00:00
}
2021-10-26 18:52:25 +00:00
[[fallthrough]];
case kHitWall:
2021-10-15 20:55:03 +00:00
pSprite->ang += (RandomSize(9) + 768);
pSprite->ang &= kAngleMask;
pSprite->xvel = bcos(pSprite->ang, -3);
pSprite->yvel = bsin(pSprite->ang, -3);
pSprite->zvel = -RandomSize(5);
break;
}
2021-10-15 20:55:03 +00:00
return;
}
2021-10-15 20:55:03 +00:00
case 4:
{
2021-10-26 18:13:03 +00:00
auto nMov = MoveCreature(pActor);
2021-10-26 18:13:03 +00:00
if (nMov.exbits & kHitAux2)
2021-10-15 20:55:03 +00:00
{
pSprite->zvel = -(pSprite->zvel - 256);
if (pSprite->zvel < -512)
{
pSprite->zvel = 0;
}
}
pEgg->nCounter--;
if (pEgg->nCounter <= 0)
2021-10-15 20:55:03 +00:00
{
2021-10-24 11:20:50 +00:00
auto pWaspSprite = BuildWasp(nullptr, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, pSprite->ang, true);
pSprite->z = pWaspSprite->s().z;
2021-10-15 20:55:03 +00:00
DestroyEgg(nEgg);
}
break;
}
}
}
2021-10-15 20:55:03 +00:00
void AIQueenEgg::RadialDamage(RunListEvent* ev)
{
short nEgg = RunData[ev->nRun].nObjIndex;
2021-10-15 20:55:03 +00:00
Egg* pEgg = &QueenEgg[nEgg];
2021-10-26 18:13:03 +00:00
auto pActor = pEgg->pActor;
auto pSprite = &pActor->s();
2021-10-20 21:54:26 +00:00
auto pRadial = &ev->pRadialActor->s();
2021-10-20 21:54:26 +00:00
if (pRadial->statnum != 121 && (pSprite->cstat & 0x101) != 0)
2021-10-15 20:55:03 +00:00
{
2021-10-26 18:13:03 +00:00
int nDamage = runlist_CheckRadialDamage(pActor);
2021-10-15 20:55:03 +00:00
pEgg->nHealth -= nDamage;
}
}
2021-10-15 20:55:03 +00:00
void AIQueenEgg::Damage(RunListEvent* ev)
{
short nEgg = RunData[ev->nRun].nObjIndex;
2021-10-15 20:55:03 +00:00
Egg* pEgg = &QueenEgg[nEgg];
2021-10-15 20:55:03 +00:00
if (ev->nDamage != 0 && pEgg->nHealth > 0)
{
pEgg->nHealth -= ev->nDamage;
2021-10-15 20:55:03 +00:00
if (pEgg->nHealth <= 0)
DestroyEgg(nEgg);
}
}
2021-10-15 20:55:03 +00:00
void AIQueenEgg::Draw(RunListEvent* ev)
{
short nEgg = RunData[ev->nRun].nObjIndex;
2021-10-15 20:55:03 +00:00
Egg* pEgg = &QueenEgg[nEgg];
seq_PlotSequence(ev->nParam, SeqOffsets[kSeqQueenEgg] + EggSeq[pEgg->nAction].a, pEgg->nFrame, EggSeq[pEgg->nAction].b);
2021-10-15 20:55:03 +00:00
}
void BuildQueenHead(short nQueen)
{
2021-10-26 19:10:51 +00:00
auto pActor = QueenList[nQueen].pActor;
auto pSprite = &pActor->s();
int x = pSprite->x;
int y = pSprite->y;
short nAngle = pSprite->ang;
int nSector =pSprite->sectnum;
int z = sector[nSector].floorz;
auto pActor2 = insertActor(nSector, 121);
auto pSprite2 = &pActor2->s();
pSprite2->x = x;
pSprite2->y = y;
pSprite2->z = z;
pSprite2->clipdist = 70;
pSprite2->xrepeat = 80;
pSprite2->yrepeat = 80;
pSprite2->cstat = 0;
pSprite2->picnum = 1;
pSprite2->shade = -12;
pSprite2->pal = 0;
pSprite2->xoffset = 0;
pSprite2->yoffset = 0;
pSprite2->ang = nAngle;
nVelShift = 2;
SetHeadVel(pActor2);
pSprite2->zvel = -8192;
pSprite2->lotag = runlist_HeadRun() + 1;
pSprite2->hitag = 0;
pSprite2->extra = -1;
GrabTimeSlot(3);
QueenHead.nHealth = 800;
QueenHead.nAction = 0;
2021-10-26 19:10:51 +00:00
QueenHead.pTarget = QueenList[nQueen].pTarget;
2020-11-29 23:40:25 +00:00
QueenHead.nFrame = 0;
QueenHead.pActor = pActor2;
QueenHead.nIndex = 0;
QueenHead.nChannel = QueenList[nQueen].nChannel;
pSprite2->owner = runlist_AddRunRec(pSprite2->lotag - 1, 0, 0x1B0000);
QueenHead.nRun = runlist_AddRunRec(NewRun, 0, 0x1B0000);
QueenHead.nIndex2 = 0;
}
2021-10-15 20:55:03 +00:00
void AIQueenHead::Tick(RunListEvent* ev)
{
auto pActor = QueenHead.pActor;
auto pSprite = &pActor->s();
int nSector = pSprite->sectnum;
assert(nSector >= 0 && nSector < kMaxSectors);
short nAction = QueenHead.nAction;
2021-10-26 18:13:03 +00:00
short nHd;
int var_14 = 0;
2021-10-15 20:55:03 +00:00
if (nAction == 0) {
Gravity(pActor);
2021-10-15 20:55:03 +00:00
}
short nSeq = SeqOffsets[kSeqQueen] + HeadSeq[QueenHead.nAction].a;
seq_MoveSequence(pActor, nSeq, QueenHead.nFrame);
2021-10-15 20:55:03 +00:00
pSprite->picnum = seq_GetSeqPicnum2(nSeq, QueenHead.nFrame);
QueenHead.nFrame++;
if (QueenHead.nFrame >= SeqSize[nSeq])
{
2021-10-15 20:55:03 +00:00
QueenHead.nFrame = 0;
var_14 = 1;
}
auto pTarget = QueenHead.pTarget;
2021-10-26 18:13:03 +00:00
if (pTarget)
2021-10-15 20:55:03 +00:00
{
2021-10-26 18:13:03 +00:00
if (!(pTarget->s().cstat & 0x101))
2021-10-15 20:55:03 +00:00
{
pTarget = nullptr;
QueenHead.pTarget = pTarget;
2021-10-15 20:55:03 +00:00
}
}
else
{
pTarget = FindPlayer(pActor, 1000);
QueenHead.pTarget = pTarget;
2021-10-15 20:55:03 +00:00
}
2021-10-15 20:55:03 +00:00
switch (nAction)
{
case 0:
if (QueenHead.nIndex > 0)
2021-10-15 20:55:03 +00:00
{
QueenHead.nIndex--;
if (QueenHead.nIndex == 0)
2021-10-15 20:55:03 +00:00
{
BuildTail();
2021-10-15 20:55:03 +00:00
QueenHead.nAction = 6;
nHeadVel = 800;
pSprite->cstat = 0x101;
}
else if (QueenHead.nIndex < 60)
{
2021-10-15 20:55:03 +00:00
pSprite->shade--;
}
2021-10-15 20:55:03 +00:00
}
else
{
auto nMov = MoveCreature(pActor);
2021-10-15 20:55:03 +00:00
// original BUG - this line doesn't exist in original code?
short nNewAng = pSprite->ang;
if (nMov.exbits == 0)
{
if (nMov.type == kHitSprite) nNewAng = nMov.actor->s().ang;
else if (nMov.type == kHitWall) nNewAng = GetWallNormal(nMov.index);
}
else if (nMov.exbits == kHitAux2)
{
2021-10-15 20:55:03 +00:00
pSprite->zvel = -(pSprite->zvel >> 1);
if (pSprite->zvel > -256)
{
2021-10-15 20:55:03 +00:00
nVelShift = 100;
pSprite->zvel = 0;
}
}
2021-10-15 20:55:03 +00:00
// original BUG - var_18 isn't being set if the check above == 0x20000 ?
pSprite->ang = nNewAng;
nVelShift++;
if (nVelShift < 5)
{
SetHeadVel(pActor);
}
2021-10-15 20:55:03 +00:00
else
{
2021-10-15 20:55:03 +00:00
pSprite->xvel = 0;
pSprite->yvel = 0;
2021-10-15 20:55:03 +00:00
if (pSprite->zvel == 0)
{
QueenHead.nIndex = 120;
2021-10-15 20:55:03 +00:00
}
}
}
2021-10-15 20:55:03 +00:00
break;
2021-10-15 20:55:03 +00:00
case 6:
if (var_14)
{
QueenHead.nAction = 1;
QueenHead.nFrame = 0;
break;
}
[[fallthrough]];
2021-10-15 20:55:03 +00:00
case 1:
2021-10-26 18:13:03 +00:00
if ((pTarget->s().z - 51200) > pSprite->z)
2021-10-15 20:55:03 +00:00
{
QueenHead.nAction = 4;
QueenHead.nFrame = 0;
}
else
{
pSprite->z -= 2048;
goto __MOVEQS;
}
break;
2021-10-15 20:55:03 +00:00
case 4:
case 7:
case 8:
if (var_14)
{
int nRnd = RandomSize(2);
2021-10-15 20:55:03 +00:00
if (nRnd == 0)
{
QueenHead.nAction = 4;
}
else if (nRnd == 1)
{
QueenHead.nAction = 7;
}
else
{
QueenHead.nAction = 8;
}
}
if (pTarget)
2021-10-15 20:55:03 +00:00
{
2021-10-26 18:52:25 +00:00
auto nMov = QueenAngleChase(pActor, pTarget, nHeadVel, 64);
2021-10-26 18:52:25 +00:00
if (nMov.type == kHitSprite)
2021-10-15 20:55:03 +00:00
{
2021-10-26 18:52:25 +00:00
if (nMov.actor == pTarget)
2021-10-15 20:55:03 +00:00
{
runlist_DamageEnemy(pTarget, pActor, 10);
D3PlayFX(StaticSound[kSoundQTail] | 0x2000, pActor);
2021-10-15 20:55:03 +00:00
pSprite->ang += RandomSize(9) + 768;
pSprite->ang &= kAngleMask;
2021-10-15 20:55:03 +00:00
pSprite->zvel = (-20) - RandomSize(6);
SetHeadVel(pActor);
2021-10-15 20:55:03 +00:00
}
}
}
2021-10-15 20:55:03 +00:00
// switch break. MoveQS stuff?
__MOVEQS:
MoveQX[nQHead] = pSprite->x;
MoveQY[nQHead] = pSprite->y;
MoveQZ[nQHead] = pSprite->z;
assert(validSectorIndex(pSprite->sectnum));
2021-10-15 20:55:03 +00:00
MoveQS[nQHead] = pSprite->sectnum;
MoveQA[nQHead] = pSprite->ang;
2021-10-15 20:55:03 +00:00
nHd = nQHead;
for (int i = 0; i < QueenHead.nIndex2; i++)
2021-10-15 20:55:03 +00:00
{
nHd -= 3;
if (nHd < 0) {
nHd += (24 + 1); // TODO - enum/define for these
//assert(nHd < 24 && nHd >= 0);
}
2021-10-15 20:55:03 +00:00
int var_20 = MoveQS[nHd];
2021-10-26 19:10:51 +00:00
auto pTActor = tailspr[i];
if (pTActor)
2021-10-15 20:55:03 +00:00
{
2021-10-26 19:10:51 +00:00
auto pTSprite = &pTActor->s();
if (var_20 != pTSprite->sectnum)
{
assert(var_20 >= 0 && var_20 < kMaxSectors);
ChangeActorSect(pTActor, var_20);
}
2021-10-26 19:10:51 +00:00
pTSprite->x = MoveQX[nHd];
pTSprite->y = MoveQY[nHd];
pTSprite->z = MoveQZ[nHd];
pTSprite->ang = MoveQA[nHd];
}
2021-10-15 20:55:03 +00:00
}
2021-10-15 20:55:03 +00:00
nQHead++;
if (nQHead >= 25)
{
nQHead = 0;
}
2021-10-15 20:55:03 +00:00
break;
2021-10-15 20:55:03 +00:00
case 5:
QueenHead.nIndex--;
if (QueenHead.nIndex <= 0)
2021-10-15 20:55:03 +00:00
{
QueenHead.nIndex = 3;
if (QueenHead.nIndex2--)
2021-10-15 20:55:03 +00:00
{
if (QueenHead.nIndex2 >= 15 || QueenHead.nIndex2 < 10)
2021-10-15 20:55:03 +00:00
{
int x = pSprite->x;
int y = pSprite->y;
int z = pSprite->z;
int nSector =pSprite->sectnum;
2021-10-15 20:55:03 +00:00
int nAngle = RandomSize(11) & kAngleMask;
pSprite->xrepeat = 127 - QueenHead.nIndex2;
pSprite->yrepeat = 127 - QueenHead.nIndex2;
2021-10-15 20:55:03 +00:00
pSprite->cstat = 0x8000;
// DEMO-TODO: in disassembly angle was used without masking and thus causing OOB issue.
// This behavior probably would be needed emulated for demo compatibility
int dx = bcos(nAngle, 10);
int dy = bsin(nAngle, 10);
int dz = (RandomSize(5) - RandomSize(5)) << 7;
movesprite(pActor, dx, dy, dz, 0, 0, CLIPMASK1);
2021-10-26 19:10:51 +00:00
BlowChunks(pActor);
BuildExplosion(pActor);
ChangeActorSect(pActor, nSector);
2021-10-15 20:55:03 +00:00
pSprite->x = x;
pSprite->y = y;
pSprite->z = z;
if (QueenHead.nIndex2 < 10) {
for (int i = (10 - QueenHead.nIndex2) * 2; i > 0; i--)
2021-10-15 20:55:03 +00:00
{
BuildLavaLimb(pActor, i, GetActorHeight(pActor));
}
}
2021-10-15 20:55:03 +00:00
}
}
else
{
BuildExplosion(pActor);
2021-10-15 20:55:03 +00:00
int i;
for (i = 0; i < 10; i++)
{
2021-10-26 19:10:51 +00:00
BlowChunks(pActor);
}
2021-10-15 20:55:03 +00:00
for (i = 0; i < 20; i++)
{
BuildLavaLimb(pActor, i, GetActorHeight(pActor));
}
2021-10-15 20:55:03 +00:00
runlist_SubRunRec(pSprite->owner);
runlist_SubRunRec(QueenHead.nRun);
DeleteActor(pActor);
runlist_ChangeChannel(QueenHead.nChannel, 1);
}
2021-10-15 20:55:03 +00:00
}
break;
}
}
2021-10-15 20:55:03 +00:00
void AIQueenHead::RadialDamage(RunListEvent* ev)
{
auto pSprite = &QueenHead.pActor->s();
2021-10-20 21:54:26 +00:00
auto pRadial = &ev->pRadialActor->s();
2021-10-15 20:55:03 +00:00
2021-10-20 21:54:26 +00:00
if (pRadial->statnum != 121 && (pSprite->cstat & 0x101) != 0)
2021-10-15 20:55:03 +00:00
{
ev->nDamage = runlist_CheckRadialDamage(QueenHead.pActor);
2021-10-15 20:55:03 +00:00
if (ev->nDamage) Damage(ev);
}
}
2021-10-15 20:55:03 +00:00
void AIQueenHead::Damage(RunListEvent* ev)
{
auto pActor = QueenHead.pActor;
auto pSprite = &pActor->s();
2021-10-15 20:55:03 +00:00
if (QueenHead.nHealth > 0 && ev->nDamage != 0)
{
QueenHead.nHealth -= ev->nDamage;
if (!RandomSize(4))
{
QueenHead.pTarget = ev->pOtherActor;
2021-10-15 20:55:03 +00:00
QueenHead.nAction = 7;
QueenHead.nFrame = 0;
}
if (QueenHead.nHealth <= 0)
{
if (DestroyTailPart())
{
2021-10-15 20:55:03 +00:00
QueenHead.nHealth = 200;
nHeadVel += 100;
}
else
{
2021-10-15 20:55:03 +00:00
QueenHead.nAction = 5;
QueenHead.nFrame = 0;
QueenHead.nIndex = 0;
QueenHead.nIndex2 = 80;
2021-10-15 20:55:03 +00:00
pSprite->cstat = 0;
}
}
2021-10-15 20:55:03 +00:00
}
}
2021-10-15 20:55:03 +00:00
void AIQueenHead::Draw(RunListEvent* ev)
{
short nHead = RunData[ev->nRun].nObjIndex;
2021-10-15 20:55:03 +00:00
short nAction = QueenHead.nAction;
short nSeq = SeqOffsets[kSeqQueen];
int edx;
if (nHead == 0)
{
edx = HeadSeq[nAction].b;
nSeq += HeadSeq[nAction].a;
}
2021-10-15 20:55:03 +00:00
else
{
edx = 1;
nSeq += 73;
}
seq_PlotSequence(ev->nParam, nSeq, QueenHead.nFrame, edx);
2021-10-15 20:55:03 +00:00
}
2021-10-26 19:10:51 +00:00
void BuildQueen(DExhumedActor* pActor, int x, int y, int z, int nSector, int nAngle, int nChannel)
{
QueenCount--;
short nQueen = QueenCount;
if (nQueen < 0) {
return;
}
2021-10-26 19:10:51 +00:00
spritetype* pSprite;
2021-10-26 19:10:51 +00:00
if (pActor == nullptr)
{
2021-10-26 19:10:51 +00:00
pActor = insertActor(nSector, 121);
pSprite = &pActor->s();
}
else
{
2021-10-26 19:10:51 +00:00
ChangeActorStat(pActor, 121);
pSprite = &pActor->s();
x = pSprite->x;
y = pSprite->y;
z = pSprite->sector()->floorz;
nAngle = pSprite->ang;
}
pSprite->x = x;
pSprite->y = y;
pSprite->z = z;
pSprite->cstat = 0x101;
pSprite->pal = 0;
pSprite->shade = -12;
pSprite->clipdist = 100;
pSprite->xrepeat = 80;
pSprite->yrepeat = 80;
pSprite->xoffset = 0;
pSprite->yoffset = 0;
pSprite->picnum = 1;
pSprite->ang = nAngle;
pSprite->xvel = 0;
pSprite->yvel = 0;
pSprite->zvel = 0;
pSprite->lotag = runlist_HeadRun() + 1;
pSprite->extra = -1;
pSprite->hitag = 0;
GrabTimeSlot(3);
QueenList[nQueen].nAction = 0;
QueenList[nQueen].nHealth = 4000;
QueenList[nQueen].nFrame = 0;
2021-10-26 19:10:51 +00:00
QueenList[nQueen].pActor = pActor;
QueenList[nQueen].pTarget = nullptr;
QueenList[nQueen].nAction2 = 0;
QueenList[nQueen].nIndex2 = 5;
QueenList[nQueen].nIndex = 0;
QueenList[nQueen].nChannel = nChannel;
nHeadVel = 800;
pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, nQueen, 0x1A0000);
runlist_AddRunRec(NewRun, nQueen, 0x1A0000);
nCreaturesTotal++;
}
2021-10-26 19:10:51 +00:00
void SetQueenSpeed(DExhumedActor* pActor, int nSpeed)
{
2021-10-26 19:10:51 +00:00
auto pSprite = &pActor->s();
pSprite->xvel = bcos(pSprite->ang, -(2 - nSpeed));
pSprite->yvel = bsin(pSprite->ang, -(2 - nSpeed));
}
2021-10-15 20:55:03 +00:00
void AIQueen::Tick(RunListEvent* ev)
{
short nQueen = RunData[ev->nRun].nObjIndex;
assert(nQueen >= 0 && nQueen < kMaxQueens);
2021-10-26 19:10:51 +00:00
auto pActor = QueenList[nQueen].pActor;
auto pSprite = &pActor->s();
short nAction = QueenList[nQueen].nAction;
short si = QueenList[nQueen].nAction2;
2021-10-26 19:10:51 +00:00
auto pTarget = QueenList[nQueen].pTarget;
bool bVal = false;
2021-10-15 20:55:03 +00:00
if (si < 3) {
2021-10-26 19:10:51 +00:00
Gravity(pActor);
2021-10-15 20:55:03 +00:00
}
short nSeq = SeqOffsets[kSeqQueen] + QueenSeq[nAction].a;
pSprite->picnum = seq_GetSeqPicnum2(nSeq, QueenList[nQueen].nFrame);
2021-10-26 19:10:51 +00:00
seq_MoveSequence(pActor, nSeq, QueenList[nQueen].nFrame);
2021-10-15 20:55:03 +00:00
QueenList[nQueen].nFrame++;
if (QueenList[nQueen].nFrame >= SeqSize[nSeq])
{
2021-10-15 20:55:03 +00:00
QueenList[nQueen].nFrame = 0;
bVal = true;
}
2021-10-15 20:55:03 +00:00
short nFlag = FrameFlag[SeqBase[nSeq] + QueenList[nQueen].nFrame];
2021-10-26 19:10:51 +00:00
if (pActor != nullptr)
2021-10-15 20:55:03 +00:00
{
if (nAction < 7)
{
2021-10-15 20:55:03 +00:00
if (!(pSprite->cstat & 0x101))
{
2021-10-26 19:10:51 +00:00
pTarget = nullptr;
QueenList[nQueen].pTarget = nullptr;
2021-10-15 20:55:03 +00:00
QueenList[nQueen].nAction = 0;
}
2021-10-15 20:55:03 +00:00
}
}
switch (nAction)
{
case 0:
{
2021-10-26 19:10:51 +00:00
if (pTarget == nullptr)
2021-10-15 20:55:03 +00:00
{
2021-10-26 19:10:51 +00:00
pTarget = FindPlayer(pActor, 60);
2021-10-15 20:55:03 +00:00
}
2021-10-26 19:10:51 +00:00
if (pTarget)
2021-10-15 20:55:03 +00:00
{
QueenList[nQueen].nAction = QueenList[nQueen].nAction2 + 1;
2021-10-15 20:55:03 +00:00
QueenList[nQueen].nFrame = 0;
2021-10-26 19:10:51 +00:00
QueenList[nQueen].pTarget = pTarget;
QueenList[nQueen].nIndex = RandomSize(7);
2021-10-26 19:10:51 +00:00
SetQueenSpeed(pActor, si);
2021-10-15 20:55:03 +00:00
}
break;
}
2021-10-15 20:55:03 +00:00
case 6:
{
if (bVal)
{
BuildQueenEgg(nQueen, 1);
QueenList[nQueen].nAction = 3;
QueenList[nQueen].nIndex = RandomSize(6) + 60;
2021-10-15 20:55:03 +00:00
}
2021-10-15 20:55:03 +00:00
break;
}
2021-10-15 20:55:03 +00:00
case 1:
case 2:
case 3:
{
QueenList[nQueen].nIndex--;
2021-10-15 20:55:03 +00:00
if ((nQueen & 0x1F) == (totalmoves & 0x1F))
{
if (si < 2)
{
if (QueenList[nQueen].nIndex <= 0)
{
2021-10-15 20:55:03 +00:00
QueenList[nQueen].nFrame = 0;
pSprite->xvel = 0;
pSprite->yvel = 0;
QueenList[nQueen].nAction = si + 4;
QueenList[nQueen].nIndex = RandomSize(6) + 30;
2021-10-15 20:55:03 +00:00
break;
}
else
{
if (QueenList[nQueen].nIndex2 < 5)
{
QueenList[nQueen].nIndex2++;
}
2021-10-15 20:55:03 +00:00
// then to PLOTSPRITE
}
}
2021-10-15 20:55:03 +00:00
else
{
if (QueenList[nQueen].nIndex <= 0)
{
2021-10-24 11:20:50 +00:00
if (Counters[kCountWasp] < 100)
{
2021-10-15 20:55:03 +00:00
QueenList[nQueen].nAction = 6;
QueenList[nQueen].nFrame = 0;
break;
}
2021-10-15 20:55:03 +00:00
else
{
QueenList[nQueen].nIndex = 30000;
2021-10-15 20:55:03 +00:00
// then to PLOTSPRITE
}
}
2021-10-15 20:55:03 +00:00
}
2021-10-15 20:55:03 +00:00
// loc_35B4B
2021-10-26 19:10:51 +00:00
PlotCourseToSprite(pActor, pTarget);
SetQueenSpeed(pActor, si);
2021-10-15 20:55:03 +00:00
}
2021-10-26 19:10:51 +00:00
auto nMov = MoveCreatureWithCaution(pActor);
2021-10-26 19:10:51 +00:00
switch (nMov.type)
2021-10-15 20:55:03 +00:00
{
2021-10-26 19:10:51 +00:00
case kHitSprite:
if ((si == 2) && (nMov.actor == pTarget))
2021-10-15 20:55:03 +00:00
{
2021-10-26 19:10:51 +00:00
runlist_DamageEnemy(pTarget, pActor, 5);
2021-10-15 20:55:03 +00:00
break;
}
2021-10-26 18:52:25 +00:00
[[fallthrough]];
2021-10-15 20:55:03 +00:00
case 0x8000:
pSprite->ang += 256;
pSprite->ang &= kAngleMask;
2021-10-26 19:10:51 +00:00
SetQueenSpeed(pActor, si);
2021-10-15 20:55:03 +00:00
break;
}
2021-10-15 20:55:03 +00:00
// loc_35BD2
2021-10-26 19:10:51 +00:00
if (nAction && pTarget != nullptr)
2021-10-15 20:55:03 +00:00
{
2021-10-26 19:10:51 +00:00
if (!(pTarget->s().cstat & 0x101))
2021-10-15 20:55:03 +00:00
{
QueenList[nQueen].nAction = 0;
QueenList[nQueen].nFrame = 0;
QueenList[nQueen].nIndex = 100;
2021-10-26 19:10:51 +00:00
QueenList[nQueen].pTarget = nullptr;
2021-10-15 20:55:03 +00:00
pSprite->xvel = 0;
pSprite->yvel = 0;
}
}
2021-10-15 20:55:03 +00:00
break;
}
2021-10-15 20:55:03 +00:00
case 4:
case 5:
{
if (bVal && QueenList[nQueen].nIndex2 <= 0)
2021-10-15 20:55:03 +00:00
{
QueenList[nQueen].nAction = 0;
QueenList[nQueen].nIndex = 15;
2021-10-15 20:55:03 +00:00
}
else
{
if (nFlag & 0x80)
{
QueenList[nQueen].nIndex2--;
2021-10-26 19:10:51 +00:00
PlotCourseToSprite(pActor, pTarget);
2021-10-15 20:55:03 +00:00
if (!si)
{
2021-10-26 19:10:51 +00:00
BuildBullet(pActor, 12, -1, pSprite->ang, pTarget, 1);
}
2021-10-15 20:55:03 +00:00
else
{
2021-10-15 20:55:03 +00:00
BuildQueenEgg(nQueen, 0);
}
2021-10-15 20:55:03 +00:00
}
}
2021-10-15 20:55:03 +00:00
break;
}
case 7:
{
if (bVal)
{
QueenList[nQueen].nAction = 0;
QueenList[nQueen].nFrame = 0;
}
2021-10-15 20:55:03 +00:00
break;
}
2021-10-15 20:55:03 +00:00
case 8:
case 9:
{
if (bVal)
{
if (nAction == 9)
{
QueenList[nQueen].nIndex--;
if (QueenList[nQueen].nIndex <= 0)
2021-10-15 20:55:03 +00:00
{
pSprite->cstat = 0;
2021-10-15 20:55:03 +00:00
for (int i = 0; i < 20; i++)
{
2021-10-26 19:15:07 +00:00
auto pChunkActor = BuildCreatureChunk(pActor, seq_GetSeqPicnum(kSeqQueen, 57, 0));
2021-10-26 19:15:07 +00:00
pChunkActor->s().picnum = kQueenChunk + (i % 3);
pChunkActor->s().xrepeat = 100;
pChunkActor->s().yrepeat = 100;
2021-10-15 20:55:03 +00:00
}
2021-10-26 19:15:07 +00:00
auto pChunkActor = BuildCreatureChunk(pActor, seq_GetSeqPicnum(kSeqQueen, 57, 0));
2021-10-26 19:15:07 +00:00
pChunkActor->s().picnum = kTile3126;
pChunkActor->s().yrepeat = 100;
pChunkActor->s().xrepeat = 100;
2021-10-15 20:55:03 +00:00
PlayFXAtXYZ(
StaticSound[kSound40],
pSprite->x,
pSprite->y,
pSprite->z,
pSprite->sectnum);
2021-10-15 20:55:03 +00:00
BuildQueenHead(nQueen);
2021-10-15 20:55:03 +00:00
QueenList[nQueen].nAction++;
}
}
2021-10-15 20:55:03 +00:00
else
QueenList[nQueen].nAction++;
}
2021-10-15 20:55:03 +00:00
break;
}
2021-10-15 20:55:03 +00:00
case 10:
{
pSprite->cstat &= 0xFEFE;
break;
}
}
}
2021-10-15 20:55:03 +00:00
void AIQueen::RadialDamage(RunListEvent* ev)
{
short nQueen = RunData[ev->nRun].nObjIndex;
2021-10-15 20:55:03 +00:00
assert(nQueen >= 0 && nQueen < kMaxQueens);
2021-10-26 19:10:51 +00:00
auto pActor = QueenList[nQueen].pActor;
auto pSprite = &pActor->s();
2021-10-20 21:54:26 +00:00
auto pRadial = &ev->pOtherActor->s();
2021-10-20 21:54:26 +00:00
if (pRadial->statnum != 121 && (pSprite->cstat & 0x101) != 0)
2021-10-15 20:55:03 +00:00
{
2021-10-26 19:10:51 +00:00
ev->nDamage = runlist_CheckRadialDamage(pActor);
2021-10-15 20:55:03 +00:00
if (ev->nDamage) Damage(ev);
}
}
2021-10-15 20:55:03 +00:00
void AIQueen::Damage(RunListEvent* ev)
{
short nQueen = RunData[ev->nRun].nObjIndex;
2021-10-15 20:55:03 +00:00
assert(nQueen >= 0 && nQueen < kMaxQueens);
2021-10-26 19:10:51 +00:00
auto pActor = QueenList[nQueen].pActor;
auto pSprite = &pActor->s();
short si = QueenList[nQueen].nAction2;
2021-10-15 20:55:03 +00:00
if (QueenList[nQueen].nHealth > 0)
{
QueenList[nQueen].nHealth -= dmgAdjust(ev->nDamage);
2021-10-15 20:55:03 +00:00
if (QueenList[nQueen].nHealth <= 0)
{
pSprite->xvel = 0;
pSprite->yvel = 0;
pSprite->zvel = 0;
QueenList[nQueen].nAction2++;
switch (QueenList[nQueen].nAction2)
2021-10-15 20:55:03 +00:00
{
case 1:
QueenList[nQueen].nHealth = 4000;
QueenList[nQueen].nAction = 7;
2021-10-24 17:18:11 +00:00
BuildAnim(nullptr, 36, 0, pSprite->x, pSprite->y, pSprite->z - 7680, pSprite->sectnum, pSprite->xrepeat, 4);
2021-10-15 20:55:03 +00:00
break;
case 2:
QueenList[nQueen].nHealth = 4000;
QueenList[nQueen].nAction = 7;
DestroyAllEggs();
break;
case 3:
QueenList[nQueen].nAction = 8;
QueenList[nQueen].nHealth = 0;
QueenList[nQueen].nIndex = 5;
2021-10-15 20:55:03 +00:00
nCreaturesKilled++;
break;
}
2021-10-15 20:55:03 +00:00
QueenList[nQueen].nFrame = 0;
}
2021-10-15 20:55:03 +00:00
else
{
if (si > 0 && !RandomSize(4))
{
QueenList[nQueen].nAction = 7;
QueenList[nQueen].nFrame = 0;
}
}
2021-10-15 20:55:03 +00:00
}
}
2021-10-15 20:55:03 +00:00
void AIQueen::Draw(RunListEvent* ev)
{
short nQueen = RunData[ev->nRun].nObjIndex;
2021-10-15 20:55:03 +00:00
assert(nQueen >= 0 && nQueen < kMaxQueens);
short nAction = QueenList[nQueen].nAction;
seq_PlotSequence(ev->nParam, SeqOffsets[kSeqQueen] + QueenSeq[nAction].a, QueenList[nQueen].nFrame, QueenSeq[nAction].b);
2021-10-15 20:55:03 +00:00
}
END_PS_NS