Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- extended the run list to handle actor targets.
Also renamed fields to be more descriptive.
  • Loading branch information
coelckers committed Oct 17, 2021
1 parent 1b8d3f9 commit 5a9978a
Show file tree
Hide file tree
Showing 25 changed files with 219 additions and 190 deletions.
22 changes: 10 additions & 12 deletions source/games/exhumed/src/aistuff.h
Expand Up @@ -406,8 +406,9 @@ enum

struct RunStruct
{
int nRef;
int nVal;
int nAIType; // todo later: replace this with an AI pointer
int nObjIndex; // If object is a non-actor / not refactored yet.
DExhumedActor* pObjActor; // If object is an actor
short next;
short prev;
};
Expand Down Expand Up @@ -437,15 +438,15 @@ enum class EMessageType
struct RunListEvent
{
EMessageType nMessage;
int nIndex; // mostly the player, sometimes the channel list
int nParam; // mostly the player, sometimes the channel list
int nObjIndex;
DExhumedActor* pObjActor;
tspritetype* pTSprite; // for the draw event
DExhumedActor* pActor; // for the damage event, radialSpr for radial damage - owner will not be passed as it can be retrieved from this.
DExhumedActor* pOtherActor; // for the damage event, radialSpr for radial damage - owner will not be passed as it can be retrieved from this.
int nDamage, nRun;

int nRadialDamage; // Radial damage needs a bit more info.
int nDamageRadius;

int RunValue() const;
};

struct ExhumedAI
Expand Down Expand Up @@ -736,11 +737,6 @@ typedef void(*AiFunc)(int, int, int, int nRun);

extern FreeListArray<RunStruct, kMaxRuns> RunData;

inline int RunListEvent::RunValue() const
{
return RunData[nRun].nVal;
}

extern RunChannel sRunChannels[kMaxChannels];
extern short NewRun;
extern int nRadialOwner;
Expand All @@ -750,7 +746,9 @@ void runlist_InitRun();

int runlist_GrabRun();
int runlist_FreeRun(int nRun);
int runlist_AddRunRec(int a, int b, int c);
int runlist_AddRunRec(int index, int object, int aitype);
int runlist_AddRunRec(int index, DExhumedActor* object, int aitype);
int runlist_AddRunRec(int index, RunStruct* other);
int runlist_HeadRun();
void runlist_InitChan();
void runlist_ChangeChannel(int eax, short dx);
Expand Down
6 changes: 3 additions & 3 deletions source/games/exhumed/src/anims.cpp
Expand Up @@ -152,7 +152,7 @@ short GetAnimSprite(short nAnim)

void AIAnim::Tick(RunListEvent* ev)
{
short nAnim = RunData[ev->nRun].nVal;
short nAnim = RunData[ev->nRun].nObjIndex;
assert(nAnim >= 0 && nAnim < kMaxAnims);

short nSprite = AnimList[nAnim].nSprite;
Expand Down Expand Up @@ -264,11 +264,11 @@ void AIAnim::Tick(RunListEvent* ev)

void AIAnim::Draw(RunListEvent* ev)
{
short nAnim = RunData[ev->nRun].nVal;
short nAnim = RunData[ev->nRun].nObjIndex;
assert(nAnim >= 0 && nAnim < kMaxAnims);
short nSeq = AnimList[nAnim].nSeq;

seq_PlotSequence(ev->nIndex, nSeq, AnimList[nAnim].field_2, 0x101);
seq_PlotSequence(ev->nParam, nSeq, AnimList[nAnim].field_2, 0x101);
ev->pTSprite->owner = -1;
}

Expand Down
12 changes: 6 additions & 6 deletions source/games/exhumed/src/anubis.cpp
Expand Up @@ -157,7 +157,7 @@ void BuildAnubis(int nSprite, int x, int y, int z, int nSector, int nAngle, uint

void AIAnubis::Tick(RunListEvent* ev)
{
int nAnubis = ev->RunValue();
int nAnubis = RunData[ev->nRun].nObjIndex;
auto ap = &AnubisList[nAnubis];
int nSprite = ap->nSprite;
auto sp = &sprite[nSprite];
Expand Down Expand Up @@ -399,13 +399,13 @@ void AIAnubis::Tick(RunListEvent* ev)

void AIAnubis::Draw(RunListEvent* ev)
{
auto ap = &AnubisList[ev->RunValue()];
seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqAnubis] + AnubisSeq[ap->nAction].a, ap->nFrame, AnubisSeq[ap->nAction].b);
auto ap = &AnubisList[RunData[ev->nRun].nObjIndex];
seq_PlotSequence(ev->nParam, SeqOffsets[kSeqAnubis] + AnubisSeq[ap->nAction].a, ap->nFrame, AnubisSeq[ap->nAction].b);
}

void AIAnubis::RadialDamage(RunListEvent* ev)
{
auto ap = &AnubisList[ev->RunValue()];
auto ap = &AnubisList[RunData[ev->nRun].nObjIndex];
if (ap->nAction < 11)
{
ev->nDamage = runlist_CheckRadialDamage(ap->nSprite);
Expand All @@ -415,7 +415,7 @@ void AIAnubis::RadialDamage(RunListEvent* ev)

void AIAnubis::Damage(RunListEvent* ev)
{
auto ap = &AnubisList[ev->RunValue()];
auto ap = &AnubisList[RunData[ev->nRun].nObjIndex];
int nSprite = ap->nSprite;
auto sp = &sprite[nSprite];
int nAction = ap->nAction;
Expand All @@ -430,7 +430,7 @@ void AIAnubis::Damage(RunListEvent* ev)

if (ap->nHealth > 0)
{
int nTarget = ev->nIndex;
int nTarget = ev->nParam;

// loc_258D6:
if (nTarget < 0) {
Expand Down
6 changes: 3 additions & 3 deletions source/games/exhumed/src/bubbles.cpp
Expand Up @@ -164,7 +164,7 @@ int BuildBubble(int x, int y, int z, short nSector)

void AIBubble::Tick(RunListEvent* ev)
{
short nBubble = RunData[ev->nRun].nVal;
short nBubble = RunData[ev->nRun].nObjIndex;
assert(nBubble >= 0 && nBubble < kMaxBubbles);

short nSprite = BubbleList[nBubble].nSprite;
Expand Down Expand Up @@ -197,10 +197,10 @@ void AIBubble::Tick(RunListEvent* ev)

void AIBubble::Draw(RunListEvent* ev)
{
short nBubble = RunData[ev->nRun].nVal;
short nBubble = RunData[ev->nRun].nObjIndex;
assert(nBubble >= 0 && nBubble < kMaxBubbles);

seq_PlotSequence(ev->nIndex, BubbleList[nBubble].nSeq, BubbleList[nBubble].nFrame, 1);
seq_PlotSequence(ev->nParam, BubbleList[nBubble].nSeq, BubbleList[nBubble].nFrame, 1);
ev->pTSprite->owner = -1;
}

Expand Down
6 changes: 3 additions & 3 deletions source/games/exhumed/src/bullet.cpp
Expand Up @@ -813,7 +813,7 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va

void AIBullet::Tick(RunListEvent* ev)
{
short nBullet = RunData[ev->nRun].nVal;
short nBullet = RunData[ev->nRun].nObjIndex;
assert(nBullet >= 0 && nBullet < kMaxBullets);

short nSeq = SeqOffsets[BulletList[nBullet].nSeq];
Expand Down Expand Up @@ -853,12 +853,12 @@ void AIBullet::Tick(RunListEvent* ev)

void AIBullet::Draw(RunListEvent* ev)
{
short nBullet = RunData[ev->nRun].nVal;
short nBullet = RunData[ev->nRun].nObjIndex;
assert(nBullet >= 0 && nBullet < kMaxBullets);

short nSeq = SeqOffsets[BulletList[nBullet].nSeq];

short nSprite2 = ev->nIndex;
short nSprite2 = ev->nParam;
mytsprite[nSprite2].statnum = 1000;

if (BulletList[nBullet].nType == 15)
Expand Down
18 changes: 9 additions & 9 deletions source/games/exhumed/src/fish.cpp
Expand Up @@ -149,7 +149,7 @@ void BuildBlood(int x, int y, int z, short nSector)

void AIFishLimb::Tick(RunListEvent* ev)
{
short nFish = RunData[ev->nRun].nVal;
short nFish = RunData[ev->nRun].nObjIndex;
short nSprite = FishChunk[nFish].nSprite;
assert(nSprite >= 0 && nSprite < kMaxSprites);
auto pSprite = &sprite[nSprite];
Expand Down Expand Up @@ -204,9 +204,9 @@ void AIFishLimb::Tick(RunListEvent* ev)

void AIFishLimb::Draw(RunListEvent* ev)
{
short nFish = RunData[ev->nRun].nVal;
short nFish = RunData[ev->nRun].nObjIndex;
int nSeq = SeqOffsets[kSeqFish] + FishChunk[nFish].nSeqIndex;
seq_PlotSequence(ev->nIndex, nSeq, FishChunk[nFish].nIndex, 1);
seq_PlotSequence(ev->nParam, nSeq, FishChunk[nFish].nIndex, 1);
}


Expand Down Expand Up @@ -315,18 +315,18 @@ void DestroyFish(short nFish)

void AIFish::Draw(RunListEvent* ev)
{
short nFish = RunData[ev->nRun].nVal;
short nFish = RunData[ev->nRun].nObjIndex;
assert(nFish >= 0 && nFish < (int)FishList.Size());
short nAction = FishList[nFish].nAction;

seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqFish] + FishSeq[nAction].a, FishList[nFish].nFrame, FishSeq[nAction].b);
seq_PlotSequence(ev->nParam, SeqOffsets[kSeqFish] + FishSeq[nAction].a, FishList[nFish].nFrame, FishSeq[nAction].b);
ev->pTSprite->owner = -1;
return;
}

void AIFish::RadialDamage(RunListEvent* ev)
{
short nFish = RunData[ev->nRun].nVal;
short nFish = RunData[ev->nRun].nObjIndex;
short nSprite = FishList[nFish].nSprite;

if (FishList[nFish].nHealth <= 0) {
Expand All @@ -347,7 +347,7 @@ void AIFish::RadialDamage(RunListEvent* ev)

void AIFish::Damage(RunListEvent* ev)
{
short nFish = RunData[ev->nRun].nVal;
short nFish = RunData[ev->nRun].nObjIndex;
assert(nFish >= 0 && nFish < (int)FishList.Size());
short nAction = FishList[nFish].nAction;
short nSprite = FishList[nFish].nSprite;
Expand Down Expand Up @@ -385,7 +385,7 @@ void AIFish::Damage(RunListEvent* ev)
}
else
{
short nTarget = ev->nIndex;
short nTarget = ev->nParam;
if (nTarget >= 0 && sprite[nTarget].statnum < 199)
{
FishList[nFish].nTarget = nTarget;
Expand All @@ -399,7 +399,7 @@ void AIFish::Damage(RunListEvent* ev)

void AIFish::Tick(RunListEvent* ev)
{
short nFish = RunData[ev->nRun].nVal;
short nFish = RunData[ev->nRun].nObjIndex;
assert(nFish >= 0 && nFish < (int)FishList.Size());
short nAction = FishList[nFish].nAction;
short nSprite = FishList[nFish].nSprite;
Expand Down
8 changes: 4 additions & 4 deletions source/games/exhumed/src/grenade.cpp
Expand Up @@ -278,16 +278,16 @@ void ExplodeGrenade(short nGrenade)

void AIGrenade::Draw(RunListEvent* ev)
{
short nGrenade = RunData[ev->nRun].nVal;
short nGrenade = RunData[ev->nRun].nObjIndex;
assert(nGrenade >= 0 && nGrenade < kMaxGrenades);
short nSeq = GrenadeList[nGrenade].field_C ? SeqOffsets[kSeqGrenBoom] : SeqOffsets[kSeqGrenRoll] + GrenadeList[nGrenade].field_A;
seq_PlotSequence(ev->nIndex, nSeq, GrenadeList[nGrenade].field_2 >> 8, 1);
seq_PlotSequence(ev->nParam, nSeq, GrenadeList[nGrenade].field_2 >> 8, 1);
}


void AIGrenade::Tick(RunListEvent* ev)
{
short nGrenade = RunData[ev->nRun].nVal;
short nGrenade = RunData[ev->nRun].nObjIndex;
assert(nGrenade >= 0 && nGrenade < kMaxGrenades);

short nGrenadeSprite = GrenadeList[nGrenade].nSprite;
Expand Down Expand Up @@ -415,7 +415,7 @@ void AIGrenade::Tick(RunListEvent* ev)

void AIGrenade::RadialDamage(RunListEvent* ev)
{
short nGrenade = RunData[ev->nRun].nVal;
short nGrenade = RunData[ev->nRun].nObjIndex;
assert(nGrenade >= 0 && nGrenade < kMaxGrenades);

short nGrenadeSprite = GrenadeList[nGrenade].nSprite;
Expand Down
16 changes: 8 additions & 8 deletions source/games/exhumed/src/lavadude.cpp
Expand Up @@ -115,7 +115,7 @@ int BuildLavaLimb(int nSprite, int edx, int ebx)

void AILavaDudeLimb::Tick(RunListEvent* ev)
{
short nSprite = RunData[ev->nRun].nVal;
short nSprite = RunData[ev->nRun].nObjIndex;
assert(nSprite >= 0 && nSprite < kMaxSprites);
auto pSprite = &sprite[nSprite];

Expand All @@ -139,10 +139,10 @@ void AILavaDudeLimb::Tick(RunListEvent* ev)

void AILavaDudeLimb::Draw(RunListEvent* ev)
{
short nSprite = RunData[ev->nRun].nVal;
short nSprite = RunData[ev->nRun].nObjIndex;
assert(nSprite >= 0 && nSprite < kMaxSprites);
auto pSprite = &sprite[nSprite];
seq_PlotSequence(ev->nIndex, (SeqOffsets[kSeqLavag] + 30) + pSprite->picnum, 0, 1);
seq_PlotSequence(ev->nParam, (SeqOffsets[kSeqLavag] + 30) + pSprite->picnum, 0, 1);
}

void FuncLavaLimb(int nObject, int nMessage, int nDamage, int nRun)
Expand Down Expand Up @@ -211,20 +211,20 @@ void BuildLava(short nSprite, int x, int y, int, short nSector, short nAngle, in

void AILavaDude::Draw(RunListEvent* ev)
{
unsigned nLava = RunData[ev->nRun].nVal;
unsigned nLava = RunData[ev->nRun].nObjIndex;
assert(nLava < LavaList.Size());

short nAction = LavaList[nLava].nAction;
short nSeq = LavadudeSeq[nAction].a + SeqOffsets[kSeqLavag];

seq_PlotSequence(ev->nIndex, nSeq, LavaList[nLava].nFrame, LavadudeSeq[nAction].b);
seq_PlotSequence(ev->nParam, nSeq, LavaList[nLava].nFrame, LavadudeSeq[nAction].b);
ev->pTSprite->owner = -1;
return;
}

void AILavaDude::Damage(RunListEvent* ev)
{
unsigned nLava = RunData[ev->nRun].nVal;
unsigned nLava = RunData[ev->nRun].nObjIndex;
assert(nLava < LavaList.Size());

short nAction = LavaList[nLava].nAction;
Expand All @@ -250,7 +250,7 @@ void AILavaDude::Damage(RunListEvent* ev)
}
else
{
short nTarget = ev->nIndex;
short nTarget = ev->nParam;

if (nTarget >= 0)
{
Expand All @@ -276,7 +276,7 @@ void AILavaDude::Damage(RunListEvent* ev)

void AILavaDude::Tick(RunListEvent* ev)
{
unsigned nLava = RunData[ev->nRun].nVal;
unsigned nLava = RunData[ev->nRun].nObjIndex;
assert(nLava < LavaList.Size());

short nAction = LavaList[nLava].nAction;
Expand Down
12 changes: 6 additions & 6 deletions source/games/exhumed/src/lion.cpp
Expand Up @@ -141,16 +141,16 @@ void BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle)

void AILion::Draw(RunListEvent* ev)
{
short nLion = RunData[ev->nRun].nVal;
short nLion = RunData[ev->nRun].nObjIndex;
assert(nLion >= 0 && nLion < (int)LionList.Size());
short nAction = LionList[nLion].nAction;

seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqLion] + LionSeq[nAction].a, LionList[nLion].nFrame, LionSeq[nAction].b);
seq_PlotSequence(ev->nParam, SeqOffsets[kSeqLion] + LionSeq[nAction].a, LionList[nLion].nFrame, LionSeq[nAction].b);
}

void AILion::RadialDamage(RunListEvent* ev)
{
short nLion = RunData[ev->nRun].nVal;
short nLion = RunData[ev->nRun].nObjIndex;
assert(nLion >= 0 && nLion < (int)LionList.Size());

short nSprite = LionList[nLion].nSprite;
Expand All @@ -162,7 +162,7 @@ void AILion::RadialDamage(RunListEvent* ev)

void AILion::Damage(RunListEvent* ev)
{
short nLion = RunData[ev->nRun].nVal;
short nLion = RunData[ev->nRun].nObjIndex;
assert(nLion >= 0 && nLion < (int)LionList.Size());

short nSprite = LionList[nLion].nSprite;
Expand Down Expand Up @@ -203,7 +203,7 @@ void AILion::Damage(RunListEvent* ev)
}
else
{
short nTarget = ev->nIndex;
short nTarget = ev->nParam;

if (nTarget > -1)
{
Expand Down Expand Up @@ -243,7 +243,7 @@ void AILion::Damage(RunListEvent* ev)

void AILion::Tick(RunListEvent* ev)
{
short nLion = RunData[ev->nRun].nVal;
short nLion = RunData[ev->nRun].nObjIndex;
assert(nLion >= 0 && nLion < (int)LionList.Size());

short nSprite = LionList[nLion].nSprite;
Expand Down
2 changes: 1 addition & 1 deletion source/games/exhumed/src/move.cpp
Expand Up @@ -1507,7 +1507,7 @@ int BuildCreatureChunk(int nVal, int nPic)

void AICreatureChunk::Tick(RunListEvent* ev)
{
int nSprite = RunData[ev->nRun].nVal;
int nSprite = RunData[ev->nRun].nObjIndex;
assert(nSprite >= 0 && nSprite < kMaxSprites);
auto pSprite = &sprite[nSprite];

Expand Down

0 comments on commit 5a9978a

Please sign in to comment.