mirror of
https://github.com/ZDoom/Raze.git
synced 2025-05-09 07:21:09 +00:00
- converted FuncScorp to a class.
This commit is contained in:
parent
5418c4326f
commit
d77a5208f3
2 changed files with 362 additions and 332 deletions
|
@ -617,6 +617,15 @@ struct AIRoach : public ExhumedAI
|
|||
void RadialDamage(RunListEvent* ev) override;
|
||||
};
|
||||
|
||||
struct AIScorp : public ExhumedAI
|
||||
{
|
||||
void Effect(RunListEvent* ev, int nTarget, int mode);
|
||||
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);
|
||||
|
|
|
@ -130,7 +130,7 @@ void BuildScorp(short nSprite, int x, int y, int z, short nSector, short nAngle,
|
|||
pSprite->extra = -1;
|
||||
pSprite->hitag = 0;
|
||||
|
||||
// GrabTimeSlot(3);
|
||||
// GrabTimeSlot(3);
|
||||
|
||||
scorpion[nScorp].nHealth = 20000;
|
||||
scorpion[nScorp].nFrame = 0;
|
||||
|
@ -148,12 +148,32 @@ void BuildScorp(short nSprite, int x, int y, int z, short nSector, short nAngle,
|
|||
nCreaturesTotal++;
|
||||
}
|
||||
|
||||
void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
||||
void AIScorp::Draw(RunListEvent* ev)
|
||||
{
|
||||
short nScorp = RunData[nRun].nVal;
|
||||
short nScorp = RunData[ev->nRun].nVal;
|
||||
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
||||
short nAction = scorpion[nScorp].nAction;
|
||||
|
||||
seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqScorp] + ScorpSeq[nAction].a, scorpion[nScorp].nFrame, ScorpSeq[nAction].b);
|
||||
}
|
||||
|
||||
void AIScorp::RadialDamage(RunListEvent* ev)
|
||||
{
|
||||
short nScorp = RunData[ev->nRun].nVal;
|
||||
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
||||
short nSprite = scorpion[nScorp].nSprite;
|
||||
|
||||
ev->nDamage = runlist_CheckRadialDamage(nSprite);
|
||||
if (ev->nDamage) Damage(ev);
|
||||
}
|
||||
|
||||
|
||||
void AIScorp::Damage(RunListEvent* ev)
|
||||
{
|
||||
short nScorp = RunData[ev->nRun].nVal;
|
||||
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
||||
short nSprite = scorpion[nScorp].nSprite;
|
||||
|
||||
short nAction = scorpion[nScorp].nAction;
|
||||
auto pSprite = &sprite[nSprite];
|
||||
|
||||
|
@ -161,37 +181,11 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
|||
|
||||
short nTarget = -1;
|
||||
|
||||
switch (nMessage)
|
||||
{
|
||||
default:
|
||||
{
|
||||
Printf("unknown msg %d for Scorp\n", nMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
case 0x90000:
|
||||
{
|
||||
seq_PlotSequence(nObject, SeqOffsets[kSeqScorp] + ScorpSeq[nAction].a, scorpion[nScorp].nFrame, ScorpSeq[nAction].b);
|
||||
return;
|
||||
}
|
||||
|
||||
case 0xA0000:
|
||||
{
|
||||
nDamage = runlist_CheckRadialDamage(nSprite);
|
||||
if (!nDamage) {
|
||||
return;
|
||||
}
|
||||
// else fall through to case 0x80000
|
||||
fallthrough__;
|
||||
}
|
||||
|
||||
case 0x80000:
|
||||
{
|
||||
if (scorpion[nScorp].nHealth <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
scorpion[nScorp].nHealth -= dmgAdjust(nDamage);
|
||||
scorpion[nScorp].nHealth -= dmgAdjust(ev->nDamage);
|
||||
|
||||
if (scorpion[nScorp].nHealth <= 0)
|
||||
{
|
||||
|
@ -210,7 +204,7 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
|||
}
|
||||
else
|
||||
{
|
||||
nTarget = nObject;
|
||||
nTarget = ev->nIndex;
|
||||
|
||||
if (nTarget >= 0)
|
||||
{
|
||||
|
@ -232,13 +226,23 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
|||
}
|
||||
|
||||
D3PlayFX(StaticSound[kSound41], nSprite);
|
||||
|
||||
goto FS_Pink_A;
|
||||
}
|
||||
Effect(ev, nTarget, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void AIScorp::Tick(RunListEvent* ev)
|
||||
{
|
||||
short nScorp = RunData[ev->nRun].nVal;
|
||||
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
||||
short nSprite = scorpion[nScorp].nSprite;
|
||||
|
||||
short nAction = scorpion[nScorp].nAction;
|
||||
auto pSprite = &sprite[nSprite];
|
||||
|
||||
bool bVal = false;
|
||||
|
||||
short nTarget = -1;
|
||||
|
||||
case 0x20000:
|
||||
{
|
||||
if (scorpion[nScorp].nHealth) {
|
||||
Gravity(nSprite);
|
||||
}
|
||||
|
@ -302,8 +306,7 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
|||
if (scorpion[nScorp].nIndex2 <= 0)
|
||||
{
|
||||
scorpion[nScorp].nIndex2 = RandomSize(5);
|
||||
// GOTO FS_Pink_A:
|
||||
goto FS_Pink_A;
|
||||
Effect(ev, nTarget, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -318,23 +321,24 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
|||
scorpion[nScorp].nAction = 2;
|
||||
scorpion[nScorp].nFrame = 0;
|
||||
}
|
||||
|
||||
goto FS_Red;
|
||||
Effect(ev, nTarget, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
goto FS_Pink_A;
|
||||
Effect(ev, nTarget, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if ((nMov & 0xC000) == 0x8000)
|
||||
{
|
||||
goto FS_Pink_A;
|
||||
Effect(ev, nTarget, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
goto FS_Pink_B;
|
||||
Effect(ev, nTarget, 1);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case 2:
|
||||
|
@ -355,8 +359,8 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
|||
runlist_DamageEnemy(nTarget, nSprite, 7);
|
||||
}
|
||||
}
|
||||
|
||||
goto FS_Red;
|
||||
Effect(ev, nTarget, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
case 3:
|
||||
|
@ -461,20 +465,30 @@ void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
void AIScorp::Effect(RunListEvent* ev, int nTarget, int mode)
|
||||
{
|
||||
short nScorp = RunData[ev->nRun].nVal;
|
||||
assert(nScorp >= 0 && nScorp < (int)scorpion.Size());
|
||||
short nSprite = scorpion[nScorp].nSprite;
|
||||
|
||||
FS_Pink_A:
|
||||
short nAction = scorpion[nScorp].nAction;
|
||||
auto pSprite = &sprite[nSprite];
|
||||
|
||||
bool bVal = false;
|
||||
|
||||
if (mode == 0)
|
||||
{
|
||||
PlotCourseToSprite(nSprite, nTarget);
|
||||
pSprite->ang += RandomSize(7) - 63;
|
||||
pSprite->ang &= kAngleMask;
|
||||
|
||||
pSprite->xvel = bcos(pSprite->ang);
|
||||
pSprite->yvel = bsin(pSprite->ang);
|
||||
|
||||
FS_Pink_B:
|
||||
}
|
||||
if (mode <= 1)
|
||||
{
|
||||
if (scorpion[nScorp].nCount)
|
||||
{
|
||||
scorpion[nScorp].nCount--;
|
||||
|
@ -502,8 +516,8 @@ FS_Pink_B:
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FS_Red:
|
||||
if (!nAction || nTarget == -1) {
|
||||
return;
|
||||
}
|
||||
|
@ -519,4 +533,11 @@ FS_Red:
|
|||
pSprite->yvel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FuncScorp(int nObject, int nMessage, int nDamage, int nRun)
|
||||
{
|
||||
AIScorp ai;
|
||||
runlist_DispatchEvent(&ai, nObject, nMessage, nDamage, nRun);
|
||||
}
|
||||
END_PS_NS
|
||||
|
|
Loading…
Reference in a new issue