- converted FuncAnubis into a class.

This commit is contained in:
Christoph Oelckers 2021-10-15 21:07:33 +02:00
parent ce78b23fb6
commit 0fc490bf40
2 changed files with 320 additions and 314 deletions

View file

@ -438,6 +438,13 @@ struct AIAnim : public ExhumedAI
void Draw(RunListEvent* ev) override;
};
struct AIAnubis : public ExhumedAI
{
void Tick(RunListEvent* ev) override;
void Draw(RunListEvent* ev) override;
void RadialDamage(RunListEvent* ev) override;
void Damage(RunListEvent* ev) override;
};
void runlist_DispatchEvent(ExhumedAI* ai, int nObject, int nMessage, int nDamage, int nRun);

View file

@ -155,28 +155,16 @@ void BuildAnubis(int nSprite, int x, int y, int z, int nSector, int nAngle, uint
nCreaturesTotal++;
}
void FuncAnubis(int nObject, int nMessage, int nDamage, int nRun)
void AIAnubis::Tick(RunListEvent* ev)
{
int nAnubis = RunData[nRun].nVal;
int nAnubis = ev->RunValue();
auto ap = &AnubisList[nAnubis];
assert(nAnubis >= 0 && nAnubis < (int)AnubisList.Size());
int nSprite = ap->nSprite;
auto sp = &sprite[nSprite];
short nAction = ap->nAction;
int nAction = ap->nAction;
bool bVal = false;
switch (nMessage)
{
default:
{
DebugOut("unknown msg %d for Anubis\n", nMessage);
return;
}
case 0x20000:
{
if (nAction < 11) {
Gravity(nSprite);
}
@ -409,23 +397,30 @@ void FuncAnubis(int nObject, int nMessage, int nDamage, int nRun)
return;
}
case 0x90000:
void AIAnubis::Draw(RunListEvent* ev)
{
seq_PlotSequence(nObject, SeqOffsets[kSeqAnubis] + AnubisSeq[nAction].a, ap->nFrame, AnubisSeq[nAction].b);
break;
auto ap = &AnubisList[ev->RunValue()];
seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqAnubis] + AnubisSeq[ap->nAction].a, ap->nFrame, AnubisSeq[ap->nAction].b);
}
case 0xA0000: // fall through to next case
void AIAnubis::RadialDamage(RunListEvent* ev)
{
if (nAction >= 11) {
return;
auto ap = &AnubisList[ev->RunValue()];
if (ap->nAction < 11)
{
ev->nDamage = runlist_CheckRadialDamage(ap->nSprite);
Damage(ev);
}
}
nDamage = runlist_CheckRadialDamage(nSprite);
fallthrough__;
}
case 0x80000:
void AIAnubis::Damage(RunListEvent* ev)
{
auto ap = &AnubisList[ev->RunValue()];
int nSprite = ap->nSprite;
auto sp = &sprite[nSprite];
int nAction = ap->nAction;
int nDamage = ev->nDamage;
if (nDamage)
{
if (ap->nHealth <= 0)
@ -435,7 +430,7 @@ void FuncAnubis(int nObject, int nMessage, int nDamage, int nRun)
if (ap->nHealth > 0)
{
int nTarget = nObject;
int nTarget = ev->nIndex;
// loc_258D6:
if (nTarget < 0) {
@ -492,14 +487,18 @@ void FuncAnubis(int nObject, int nMessage, int nDamage, int nRun)
if (nAction < 11)
{
DropMagic(nSprite);
ap->nAction = (nMessage == 0xA0000) + 11;
ap->nAction = (ev->nMessage == EMessageType::RadialDamage) + 11;
ap->nFrame = 0;
}
}
}
}
return;
}
}
void FuncAnubis(int nObject, int nMessage, int nDamage, int nRun)
{
AIAnubis ai;
runlist_DispatchEvent(&ai, nObject, nMessage, nDamage, nRun);
}
END_PS_NS