mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-18 23:21:43 +00:00
- converted FuncWasp to a class.
This commit is contained in:
parent
8d7f37066f
commit
601d358b49
2 changed files with 252 additions and 235 deletions
|
@ -653,6 +653,13 @@ struct AISpider : public ExhumedAI
|
|||
void RadialDamage(RunListEvent* ev) override;
|
||||
};
|
||||
|
||||
struct AIWasp : public ExhumedAI
|
||||
{
|
||||
void Tick(RunListEvent* ev) override;
|
||||
void Damage(RunListEvent* ev) override;
|
||||
void Draw(RunListEvent* ev) override;
|
||||
void RadialDamage(RunListEvent* ev) override;
|
||||
};
|
||||
|
||||
|
||||
void runlist_DispatchEvent(ExhumedAI* ai, int nObject, int nMessage, int nDamage, int nRun);
|
||||
|
|
|
@ -88,7 +88,7 @@ void InitWasps()
|
|||
|
||||
void SetWaspVel(short nSprite)
|
||||
{
|
||||
auto pSprite = &sprite[nSprite];
|
||||
auto pSprite = &sprite[nSprite];
|
||||
pSprite->xvel = bcos(pSprite->ang);
|
||||
pSprite->yvel = bsin(pSprite->ang);
|
||||
}
|
||||
|
@ -101,13 +101,13 @@ int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
|
|||
if (nSprite == -2) {
|
||||
bEggWasp = true;
|
||||
}
|
||||
auto pSprite = &sprite[nSprite];
|
||||
auto pSprite = &sprite[nSprite];
|
||||
|
||||
if (nSprite < 0)
|
||||
{
|
||||
nSprite = insertsprite(nSector, 107);
|
||||
assert(nSprite >= 0 && nSprite < kMaxSprites);
|
||||
pSprite = &sprite[nSprite];
|
||||
pSprite = &sprite[nSprite];
|
||||
|
||||
pSprite->x = x;
|
||||
pSprite->y = y;
|
||||
|
@ -146,10 +146,10 @@ int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
|
|||
pSprite->lotag = runlist_HeadRun() + 1;
|
||||
pSprite->extra = -1;
|
||||
|
||||
// GrabTimeSlot(3);
|
||||
// GrabTimeSlot(3);
|
||||
|
||||
WaspList[nWasp].nAction = 0;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
WaspList[nWasp].nSprite = nSprite;
|
||||
WaspList[nWasp].nTarget = -1;
|
||||
WaspList[nWasp].nHealth = 800;
|
||||
|
@ -177,248 +177,258 @@ int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
|
|||
return nSprite;
|
||||
}
|
||||
|
||||
void FuncWasp(int nObject, int nMessage, int nDamage, int nRun)
|
||||
void AIWasp::Draw(RunListEvent* ev)
|
||||
{
|
||||
short nWasp = RunData[nRun].nVal;
|
||||
short nWasp = RunData[ev->nRun].nVal;
|
||||
short nAction = WaspList[nWasp].nAction;
|
||||
|
||||
seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqWasp] + WaspSeq[nAction].a, WaspList[nWasp].nFrame, WaspSeq[nAction].b);
|
||||
return;
|
||||
}
|
||||
|
||||
void AIWasp::RadialDamage(RunListEvent* ev)
|
||||
{
|
||||
short nWasp = RunData[ev->nRun].nVal;
|
||||
short nSprite = WaspList[nWasp].nSprite;
|
||||
auto pSprite = &sprite[nSprite];
|
||||
auto pSprite = &sprite[nSprite];
|
||||
|
||||
if (!(pSprite->cstat & 0x101))
|
||||
return;
|
||||
|
||||
ev->nDamage = runlist_CheckRadialDamage(nSprite);
|
||||
Damage(ev);
|
||||
}
|
||||
|
||||
void AIWasp::Damage(RunListEvent* ev)
|
||||
{
|
||||
short nWasp = RunData[ev->nRun].nVal;
|
||||
short nSprite = WaspList[nWasp].nSprite;
|
||||
auto pSprite = &sprite[nSprite];
|
||||
short nAction = WaspList[nWasp].nAction;
|
||||
|
||||
if (!ev->nDamage) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (WaspList[nWasp].nHealth > 0)
|
||||
{
|
||||
WaspList[nWasp].nHealth -= dmgAdjust(ev->nDamage, 3);
|
||||
|
||||
if (WaspList[nWasp].nHealth > 0)
|
||||
{
|
||||
if (!RandomSize(4))
|
||||
{
|
||||
WaspList[nWasp].nAction = 3;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
}
|
||||
|
||||
WaspList[nWasp].nAction = 1;
|
||||
pSprite->ang += RandomSize(9) + 768;
|
||||
pSprite->ang &= kAngleMask;
|
||||
|
||||
WaspList[nWasp].nVel = 3000;
|
||||
|
||||
pSprite->zvel = (-20) - RandomSize(6);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Wasp is dead
|
||||
WaspList[nWasp].nAction = 4;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
|
||||
pSprite->cstat = 0;
|
||||
pSprite->ang = (pSprite->ang + 1024) & kAngleMask;
|
||||
|
||||
SetWaspVel(nSprite);
|
||||
|
||||
pSprite->zvel = 512;
|
||||
|
||||
nCreaturesKilled++;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void AIWasp::Tick(RunListEvent* ev)
|
||||
{
|
||||
short nWasp = RunData[ev->nRun].nVal;
|
||||
short nSprite = WaspList[nWasp].nSprite;
|
||||
auto pSprite = &sprite[nSprite];
|
||||
short nAction = WaspList[nWasp].nAction;
|
||||
|
||||
short nTarget = -1;
|
||||
|
||||
bool bVal = false;
|
||||
|
||||
switch (nMessage)
|
||||
short nSeq = SeqOffsets[kSeqWasp] + WaspSeq[nAction].a;
|
||||
|
||||
pSprite->picnum = seq_GetSeqPicnum2(nSeq, WaspList[nWasp].nFrame);
|
||||
|
||||
seq_MoveSequence(nSprite, nSeq, WaspList[nWasp].nFrame);
|
||||
|
||||
WaspList[nWasp].nFrame++;
|
||||
if (WaspList[nWasp].nFrame >= SeqSize[nSeq])
|
||||
{
|
||||
case 0x90000:
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
bVal = true;
|
||||
}
|
||||
|
||||
if (WaspList[nWasp].nHealth > 0)
|
||||
{
|
||||
nTarget = WaspList[nWasp].nTarget;
|
||||
|
||||
if (nTarget > -1 && (!(sprite[nTarget].cstat & 0x101) || (SectFlag[sprite[nTarget].sectnum] & kSectUnderwater)))
|
||||
{
|
||||
seq_PlotSequence(nObject, SeqOffsets[kSeqWasp] + WaspSeq[nAction].a, WaspList[nWasp].nFrame, WaspSeq[nAction].b);
|
||||
// goto pink
|
||||
WaspList[nWasp].nTarget = -1;
|
||||
WaspList[nWasp].nAction = 0;
|
||||
WaspList[nWasp].nCount = RandomSize(6);
|
||||
return;
|
||||
}
|
||||
|
||||
case 0xA0000:
|
||||
{
|
||||
if (!(pSprite->cstat & 0x101))
|
||||
return;
|
||||
|
||||
nDamage = runlist_CheckRadialDamage(nSprite);
|
||||
// fall through to case 0x80000
|
||||
fallthrough__;
|
||||
}
|
||||
|
||||
case 0x80000:
|
||||
{
|
||||
if (!nDamage) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (WaspList[nWasp].nHealth > 0)
|
||||
{
|
||||
WaspList[nWasp].nHealth -= dmgAdjust(nDamage, 3);
|
||||
|
||||
if (WaspList[nWasp].nHealth > 0)
|
||||
{
|
||||
if (!RandomSize(4))
|
||||
{
|
||||
WaspList[nWasp].nAction = 3;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
}
|
||||
|
||||
WaspList[nWasp].nAction = 1;
|
||||
pSprite->ang += RandomSize(9) + 768;
|
||||
pSprite->ang &= kAngleMask;
|
||||
|
||||
WaspList[nWasp].nVel = 3000;
|
||||
|
||||
pSprite->zvel = (-20) - RandomSize(6);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Wasp is dead
|
||||
WaspList[nWasp].nAction = 4;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
|
||||
pSprite->cstat = 0;
|
||||
pSprite->ang = (pSprite->ang + 1024) & kAngleMask;
|
||||
|
||||
SetWaspVel(nSprite);
|
||||
|
||||
pSprite->zvel = 512;
|
||||
|
||||
nCreaturesKilled++;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case 0x20000:
|
||||
{
|
||||
short nSeq = SeqOffsets[kSeqWasp] + WaspSeq[nAction].a;
|
||||
|
||||
pSprite->picnum = seq_GetSeqPicnum2(nSeq, WaspList[nWasp].nFrame);
|
||||
|
||||
seq_MoveSequence(nSprite, nSeq, WaspList[nWasp].nFrame);
|
||||
|
||||
WaspList[nWasp].nFrame++;
|
||||
if (WaspList[nWasp].nFrame >= SeqSize[nSeq])
|
||||
{
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
bVal = true;
|
||||
}
|
||||
|
||||
if (WaspList[nWasp].nHealth > 0)
|
||||
{
|
||||
nTarget = WaspList[nWasp].nTarget;
|
||||
|
||||
if (nTarget > -1 && (!(sprite[nTarget].cstat & 0x101) || (SectFlag[sprite[nTarget].sectnum] & kSectUnderwater)))
|
||||
{
|
||||
// goto pink
|
||||
WaspList[nWasp].nTarget = -1;
|
||||
WaspList[nWasp].nAction = 0;
|
||||
WaspList[nWasp].nCount = RandomSize(6);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (nAction)
|
||||
{
|
||||
default:
|
||||
return;
|
||||
|
||||
case 0:
|
||||
{
|
||||
pSprite->zvel = bsin(WaspList[nWasp].nAngle, -4);
|
||||
|
||||
WaspList[nWasp].nAngle += WaspList[nWasp].nAngle2;
|
||||
WaspList[nWasp].nAngle &= kAngleMask;
|
||||
|
||||
MoveCreature(nSprite);
|
||||
|
||||
if (nTarget >= 0)
|
||||
{
|
||||
WaspList[nWasp].nCount--;
|
||||
if (WaspList[nWasp].nCount > 0)
|
||||
{
|
||||
PlotCourseToSprite(nSprite, nTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
pSprite->zvel = 0;
|
||||
WaspList[nWasp].nAction = 1;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
WaspList[nWasp].nVel = 1500;
|
||||
WaspList[nWasp].nCount = RandomSize(5) + 60;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((nWasp & 0x1F) == (totalmoves & 0x1F)) {
|
||||
WaspList[nWasp].nTarget = FindPlayer(nSprite, 60);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
WaspList[nWasp].nCount--;
|
||||
|
||||
if (WaspList[nWasp].nCount <= 0)
|
||||
{
|
||||
WaspList[nWasp].nAction = 0;
|
||||
WaspList[nWasp].nCount = RandomSize(6);
|
||||
return;
|
||||
}
|
||||
|
||||
int nChaseVal = AngleChase(nSprite, nTarget, WaspList[nWasp].nVel, 0, 16);
|
||||
|
||||
switch (nChaseVal & 0xC000)
|
||||
{
|
||||
default:
|
||||
return;
|
||||
|
||||
case 0x8000:
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
case 0xC000:
|
||||
{
|
||||
short nSprite2 = (nChaseVal & 0x3FFF);
|
||||
if (nSprite2 == nTarget)
|
||||
{
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
runlist_DamageEnemy(nSprite2, nSprite, WaspList[nWasp].nDamage);
|
||||
WaspList[nWasp].nAction = 2;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
if (bVal)
|
||||
{
|
||||
pSprite->ang += RandomSize(9) + 768;
|
||||
pSprite->ang &= kAngleMask;
|
||||
pSprite->zvel = (-20) - RandomSize(6);
|
||||
|
||||
WaspList[nWasp].nAction = 1;
|
||||
WaspList[nWasp].nVel = 3000;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
int nMove = MoveCreature(nSprite) & 0x8000;
|
||||
nMove |= 0xC000;
|
||||
|
||||
if (nMove)
|
||||
{
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
pSprite->zvel = 1024;
|
||||
WaspList[nWasp].nAction = 5;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
short nSector = pSprite->sectnum;
|
||||
|
||||
pSprite->z += pSprite->zvel;
|
||||
|
||||
if (pSprite->z >= sector[nSector].floorz)
|
||||
{
|
||||
if (SectBelow[nSector] > -1)
|
||||
{
|
||||
BuildSplash(nSprite, nSector);
|
||||
pSprite->cstat |= 0x8000;
|
||||
}
|
||||
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
pSprite->zvel = 0;
|
||||
WaspList[nWasp].nAction = 6;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
runlist_SubRunRec(WaspList[nWasp].nRun);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (nAction)
|
||||
{
|
||||
default:
|
||||
return;
|
||||
|
||||
case 0:
|
||||
{
|
||||
pSprite->zvel = bsin(WaspList[nWasp].nAngle, -4);
|
||||
|
||||
WaspList[nWasp].nAngle += WaspList[nWasp].nAngle2;
|
||||
WaspList[nWasp].nAngle &= kAngleMask;
|
||||
|
||||
MoveCreature(nSprite);
|
||||
|
||||
if (nTarget >= 0)
|
||||
{
|
||||
WaspList[nWasp].nCount--;
|
||||
if (WaspList[nWasp].nCount > 0)
|
||||
{
|
||||
PlotCourseToSprite(nSprite, nTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
pSprite->zvel = 0;
|
||||
WaspList[nWasp].nAction = 1;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
WaspList[nWasp].nVel = 1500;
|
||||
WaspList[nWasp].nCount = RandomSize(5) + 60;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((nWasp & 0x1F) == (totalmoves & 0x1F)) {
|
||||
WaspList[nWasp].nTarget = FindPlayer(nSprite, 60);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
WaspList[nWasp].nCount--;
|
||||
|
||||
if (WaspList[nWasp].nCount <= 0)
|
||||
{
|
||||
WaspList[nWasp].nAction = 0;
|
||||
WaspList[nWasp].nCount = RandomSize(6);
|
||||
return;
|
||||
}
|
||||
|
||||
int nChaseVal = AngleChase(nSprite, nTarget, WaspList[nWasp].nVel, 0, 16);
|
||||
|
||||
switch (nChaseVal & 0xC000)
|
||||
{
|
||||
default:
|
||||
return;
|
||||
|
||||
case 0x8000:
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
case 0xC000:
|
||||
{
|
||||
short nSprite2 = (nChaseVal & 0x3FFF);
|
||||
if (nSprite2 == nTarget)
|
||||
{
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
runlist_DamageEnemy(nSprite2, nSprite, WaspList[nWasp].nDamage);
|
||||
WaspList[nWasp].nAction = 2;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
if (bVal)
|
||||
{
|
||||
pSprite->ang += RandomSize(9) + 768;
|
||||
pSprite->ang &= kAngleMask;
|
||||
pSprite->zvel = (-20) - RandomSize(6);
|
||||
|
||||
WaspList[nWasp].nAction = 1;
|
||||
WaspList[nWasp].nVel = 3000;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
int nMove = MoveCreature(nSprite) & 0x8000;
|
||||
nMove |= 0xC000;
|
||||
|
||||
if (nMove)
|
||||
{
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
pSprite->zvel = 1024;
|
||||
WaspList[nWasp].nAction = 5;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
short nSector = pSprite->sectnum;
|
||||
|
||||
pSprite->z += pSprite->zvel;
|
||||
|
||||
if (pSprite->z >= sector[nSector].floorz)
|
||||
{
|
||||
if (SectBelow[nSector] > -1)
|
||||
{
|
||||
BuildSplash(nSprite, nSector);
|
||||
pSprite->cstat |= 0x8000;
|
||||
}
|
||||
|
||||
pSprite->xvel = 0;
|
||||
pSprite->yvel = 0;
|
||||
pSprite->zvel = 0;
|
||||
WaspList[nWasp].nAction = 6;
|
||||
WaspList[nWasp].nFrame = 0;
|
||||
runlist_SubRunRec(WaspList[nWasp].nRun);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FuncWasp(int nObject, int nMessage, int nDamage, int nRun)
|
||||
{
|
||||
AIWasp ai;
|
||||
runlist_DispatchEvent(&ai, nObject, nMessage, 0, nRun);
|
||||
}
|
||||
|
||||
END_PS_NS
|
||||
|
|
Loading…
Reference in a new issue