- converted FuncSet/FuncSoul to a class.

This commit is contained in:
Christoph Oelckers 2021-10-15 23:18:58 +02:00
parent d77a5208f3
commit 61df236588
2 changed files with 505 additions and 485 deletions

View file

@ -626,6 +626,21 @@ struct AIScorp : public ExhumedAI
void RadialDamage(RunListEvent* ev) override;
};
struct AISet : public ExhumedAI
{
void Tick(RunListEvent* ev) override;
void Damage(RunListEvent* ev) override;
void Draw(RunListEvent* ev) override;
void RadialDamage(RunListEvent* ev) override;
};
struct AISoul : public ExhumedAI
{
void Tick(RunListEvent* ev) override;
};
void runlist_DispatchEvent(ExhumedAI* ai, int nObject, int nMessage, int nDamage, int nRun);
typedef void(*AiFunc)(int, int, int, int nRun);

View file

@ -183,15 +183,11 @@ void BuildSoul(int nSet)
pSprite->owner = runlist_AddRunRec(NewRun, nSprite, 0x230000);
}
void FuncSoul(int nObject, int nMessage, int, int nRun)
void AISoul::Tick(RunListEvent* ev)
{
short nSprite = RunData[nRun].nVal;
short nSprite = RunData[ev->nRun].nVal;
auto pSprite = &sprite[nSprite];
switch (nMessage)
{
case 0x20000:
{
seq_MoveSequence(nSprite, SeqOffsets[kSeqSet] + 75, 0);
if (pSprite->xrepeat < 32)
@ -221,52 +217,44 @@ void FuncSoul(int nObject, int nMessage, int, int nRun)
}
}
case 0x80000:
case 0xA0000:
case 0x90000:
return;
default:
Printf("unknown msg %d for Soul\n", nMessage);
}
}
void FuncSet(int nObject, int nMessage, int nDamage, int nRun)
void FuncSoul(int nObject, int nMessage, int nDamage, int nRun)
{
short nSet = RunData[nRun].nVal;
AISoul ai;
runlist_DispatchEvent(&ai, nObject, nMessage, nDamage, nRun);
}
void AISet::RadialDamage(RunListEvent* ev)
{
short nSet = RunData[ev->nRun].nVal;
assert(nSet >= 0 && nSet < (int)SetList.Size());
short nSprite = SetList[nSet].nSprite;
short nAction = SetList[nSet].nAction;
if (nAction == 5)
{
ev->nDamage = runlist_CheckRadialDamage(nSprite);
// fall through to case 0x80000
}
Damage(ev);
}
void AISet::Damage(RunListEvent* ev)
{
short nSet = RunData[ev->nRun].nVal;
assert(nSet >= 0 && nSet < (int)SetList.Size());
short nSprite = SetList[nSet].nSprite;
short nAction = SetList[nSet].nAction;
auto pSprite = &sprite[nSprite];
bool bVal = false;
switch (nMessage)
{
default:
{
Printf("unknown msg %d for Set\n", nMessage);
return;
}
case 0xA0000:
{
if (nAction == 5)
{
nDamage = runlist_CheckRadialDamage(nSprite);
// fall through to case 0x80000
}
fallthrough__;
}
case 0x80000:
{
if (nDamage && SetList[nSet].nHealth > 0)
if (ev->nDamage && SetList[nSet].nHealth > 0)
{
if (nAction != 1)
{
SetList[nSet].nHealth -= dmgAdjust(nDamage);
SetList[nSet].nHealth -= dmgAdjust(ev->nDamage);
}
if (SetList[nSet].nHealth <= 0)
@ -292,17 +280,30 @@ void FuncSet(int nObject, int nMessage, int nDamage, int nRun)
SetList[nSet].nFrame = 0;
}
}
}
void AISet::Draw(RunListEvent* ev)
{
short nSet = RunData[ev->nRun].nVal;
assert(nSet >= 0 && nSet < (int)SetList.Size());
short nAction = SetList[nSet].nAction;
seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqSet] + SetSeq[nAction].a, SetList[nSet].nFrame, SetSeq[nAction].b);
return;
}
case 0x90000:
void AISet::Tick(RunListEvent* ev)
{
seq_PlotSequence(nObject, SeqOffsets[kSeqSet] + SetSeq[nAction].a, SetList[nSet].nFrame, SetSeq[nAction].b);
return;
}
short nSet = RunData[ev->nRun].nVal;
assert(nSet >= 0 && nSet < (int)SetList.Size());
short nSprite = SetList[nSet].nSprite;
short nAction = SetList[nSet].nAction;
auto pSprite = &sprite[nSprite];
bool bVal = false;
case 0x20000:
{
Gravity(nSprite);
short nSeq = SeqOffsets[kSeqSet] + SetSeq[SetList[nSet].nAction].a;
@ -691,6 +692,10 @@ void FuncSet(int nObject, int nMessage, int nDamage, int nRun)
return;
}
}
void FuncSet(int nObject, int nMessage, int nDamage, int nRun)
{
AISet ai;
runlist_DispatchEvent(&ai, nObject, nMessage, nDamage, nRun);
}
END_PS_NS