mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 00:41:55 +00:00
- converted FuncRoach to a class.
This commit is contained in:
parent
25de6fe4c5
commit
5418c4326f
2 changed files with 267 additions and 251 deletions
|
@ -609,6 +609,14 @@ struct AIRex : public ExhumedAI
|
|||
void RadialDamage(RunListEvent* ev) override;
|
||||
};
|
||||
|
||||
struct AIRoach : 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);
|
||||
|
||||
typedef void(*AiFunc)(int, int, int, int nRun);
|
||||
|
|
|
@ -151,45 +151,42 @@ void GoRoach(short nSprite)
|
|||
pSprite->yvel = bsin(pSprite->ang, -1) - bsin(pSprite->ang, -3);
|
||||
}
|
||||
|
||||
void FuncRoach(int nObject, int nMessage, int nDamage, int nRun)
|
||||
void AIRoach::Draw(RunListEvent* ev)
|
||||
{
|
||||
short nRoach = RunData[nRun].nVal;
|
||||
short nRoach = RunData[ev->nRun].nVal;
|
||||
assert(nRoach >= 0 && nRoach < (int)RoachList.Size());
|
||||
short nAction = RoachList[nRoach].nAction;
|
||||
|
||||
seq_PlotSequence(ev->nIndex, RoachSeq[nAction].a + SeqOffsets[kSeqRoach], RoachList[nRoach].nFrame, RoachSeq[nAction].b);
|
||||
return;
|
||||
}
|
||||
|
||||
void AIRoach::RadialDamage(RunListEvent* ev)
|
||||
{
|
||||
short nRoach = RunData[ev->nRun].nVal;
|
||||
assert(nRoach >= 0 && nRoach < (int)RoachList.Size());
|
||||
short nSprite = RoachList[nRoach].nSprite;
|
||||
|
||||
ev->nDamage = runlist_CheckRadialDamage(nSprite);
|
||||
Damage(ev);
|
||||
}
|
||||
|
||||
void AIRoach::Damage(RunListEvent* ev)
|
||||
{
|
||||
short nRoach = RunData[ev->nRun].nVal;
|
||||
assert(nRoach >= 0 && nRoach < (int)RoachList.Size());
|
||||
|
||||
short nSprite = RoachList[nRoach].nSprite;
|
||||
auto pSprite = &sprite[nSprite];
|
||||
short nAction = RoachList[nRoach].nAction;
|
||||
|
||||
bool bVal = false;
|
||||
|
||||
switch (nMessage)
|
||||
{
|
||||
default:
|
||||
{
|
||||
Printf("unknown msg %d for Roach\n", nMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
case 0x90000:
|
||||
{
|
||||
seq_PlotSequence(nObject, RoachSeq[nAction].a + SeqOffsets[kSeqRoach], RoachList[nRoach].nFrame, RoachSeq[nAction].b);
|
||||
return;
|
||||
}
|
||||
|
||||
case 0xA0000: // fall through to next case
|
||||
{
|
||||
nDamage = runlist_CheckRadialDamage(nSprite);
|
||||
fallthrough__;
|
||||
}
|
||||
case 0x80000:
|
||||
{
|
||||
if (nDamage)
|
||||
if (ev->nDamage)
|
||||
{
|
||||
if (RoachList[nRoach].nHealth <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
RoachList[nRoach].nHealth -= dmgAdjust(nDamage);
|
||||
RoachList[nRoach].nHealth -= dmgAdjust(ev->nDamage);
|
||||
if (RoachList[nRoach].nHealth <= 0)
|
||||
{
|
||||
pSprite->xvel = 0;
|
||||
|
@ -210,7 +207,7 @@ void FuncRoach(int nObject, int nMessage, int nDamage, int nRun)
|
|||
}
|
||||
else
|
||||
{
|
||||
short nSprite2 = nObject;
|
||||
short nSprite2 = ev->nIndex;
|
||||
if (nSprite2 >= 0)
|
||||
{
|
||||
if (sprite[nSprite2].statnum < 199) {
|
||||
|
@ -234,12 +231,18 @@ void FuncRoach(int nObject, int nMessage, int nDamage, int nRun)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 0x20000:
|
||||
void AIRoach::Tick(RunListEvent* ev)
|
||||
{
|
||||
short nRoach = RunData[ev->nRun].nVal;
|
||||
assert(nRoach >= 0 && nRoach < (int)RoachList.Size());
|
||||
|
||||
short nSprite = RoachList[nRoach].nSprite;
|
||||
auto pSprite = &sprite[nSprite];
|
||||
short nAction = RoachList[nRoach].nAction;
|
||||
bool bVal = false;
|
||||
|
||||
Gravity(nSprite);
|
||||
|
||||
int nSeq = SeqOffsets[kSeqRoach] + RoachSeq[RoachList[nRoach].nAction].a;
|
||||
|
@ -427,6 +430,11 @@ void FuncRoach(int nObject, int nMessage, int nDamage, int nRun)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FuncRoach(int nObject, int nMessage, int nDamage, int nRun)
|
||||
{
|
||||
AIRoach ai;
|
||||
runlist_DispatchEvent(&ai, nObject, nMessage, nDamage, nRun);
|
||||
}
|
||||
}
|
||||
|
||||
END_PS_NS
|
||||
|
|
Loading…
Reference in a new issue