From e6c7e5bc188c0b50203ad7f99d51022534002498 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 21 Oct 2021 18:22:14 +0200 Subject: [PATCH] - radial stuff. --- source/games/exhumed/src/aistuff.h | 2 -- source/games/exhumed/src/object.cpp | 4 +-- source/games/exhumed/src/player.cpp | 15 ++++------- source/games/exhumed/src/runlist.cpp | 38 +++++++++++++--------------- 4 files changed, 25 insertions(+), 34 deletions(-) diff --git a/source/games/exhumed/src/aistuff.h b/source/games/exhumed/src/aistuff.h index 1aa80e4f0..f90e30903 100644 --- a/source/games/exhumed/src/aistuff.h +++ b/source/games/exhumed/src/aistuff.h @@ -738,8 +738,6 @@ extern FreeListArray RunData; extern RunChannel sRunChannels[kMaxChannels]; extern short NewRun; -extern int nRadialOwner; -extern short nRadialSpr; void runlist_InitRun(); diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index 85c931dcb..83d771509 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -2176,9 +2176,9 @@ void AIObject::RadialDamage(RunListEvent* ev) if (pActor->nHealth > 0 && pSprite->cstat & 0x101 && (nStat != kStatExplodeTarget - || sprite[nRadialSpr].statnum == 201 + || ev->pRadialActor->s().statnum == 201 || (nRadialBullet != 3 && nRadialBullet > -1) - || sprite[nRadialSpr].statnum == kStatExplodeTrigger)) + || ev->pRadialActor->s().statnum == kStatExplodeTrigger)) { int nDamage = runlist_CheckRadialDamage(pActor); if (nDamage <= 0) { diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index a2efda470..fab39fb26 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -647,7 +647,6 @@ void AIPlayer::RadialDamage(RunListEvent* ev) void AIPlayer::Damage(RunListEvent* ev) { - int nSprite2; int nDamage = ev->nDamage; short nPlayer = RunData[ev->nRun].nObjIndex; short nAction = PlayerList[nPlayer].nAction; @@ -659,11 +658,7 @@ void AIPlayer::Damage(RunListEvent* ev) return; } - if (ev->nMessage != EMessageType::RadialDamage) - { - nSprite2 = ev->nParam; - } - else nSprite2 = nRadialOwner; + DExhumedActor* pActor2 = (ev->nMessage != EMessageType::RadialDamage) ? ev->pOtherActor : ev->pRadialActor->pTarget; // ok continue case 0x80000 as normal, loc_1C57C if (!PlayerList[nPlayer].nHealth) { @@ -703,7 +698,7 @@ void AIPlayer::Damage(RunListEvent* ev) PlayerList[nPlayer].field_2 = 0; PlayerList[nPlayer].nAction = 4; - if (nSprite2 > -1) + if (pActor2) { PlayerList[nPlayer].nPlayerSwear--; if (PlayerList[nPlayer].nPlayerSwear <= 0) @@ -721,9 +716,9 @@ void AIPlayer::Damage(RunListEvent* ev) else { // player has died - if (nSprite2 > -1 && sprite[nSprite2].statnum == 100) + if (pActor2 && pActor2->s().statnum == 100) { - short nPlayer2 = GetPlayerFromSprite(nSprite2); + short nPlayer2 = GetPlayerFromActor(pActor2); if (nPlayer2 == nPlayer) // player caused their own death { @@ -734,7 +729,7 @@ void AIPlayer::Damage(RunListEvent* ev) PlayerList[nPlayer].nPlayerScore++; } } - else if (nSprite2 < 0) + else if (pActor2 == nullptr) { PlayerList[nPlayer].nPlayerScore--; } diff --git a/source/games/exhumed/src/runlist.cpp b/source/games/exhumed/src/runlist.cpp index 03a3f05bf..ab7521627 100644 --- a/source/games/exhumed/src/runlist.cpp +++ b/source/games/exhumed/src/runlist.cpp @@ -32,13 +32,12 @@ enum }; -short nRadialSpr = -1; +DExhumedActor* pRadialActor; short nStackCount = 0; short word_966BE = 0; short ChannelList = -1; short ChannelLast = -1; -int nRadialOwner; int nDamageRadius; int nRadialDamage; short RunChain; @@ -68,12 +67,10 @@ void SerializeRunList(FSerializer& arc) if (arc.BeginObject("runlist")) { arc("data", RunData) - ("radialspr", nRadialSpr) ("stackcount", nStackCount) ("w966be", word_966BE) ("list", ChannelList) ("last", ChannelLast) - ("radialowner", nRadialOwner) ("damageradius", nDamageRadius) ("radialdamage", nRadialDamage) ("runchain", RunChain) @@ -179,7 +176,7 @@ void runlist_InitRun() PlayerList[i].nRun = -1; } - nRadialSpr = -1; + pRadialActor = nullptr; } void runlist_UnlinkRun(int nRun) @@ -1562,9 +1559,11 @@ void runlist_ProcessWallTag(int nWall, short nLotag, short nHitag) int runlist_CheckRadialDamage(short nSprite) { + auto pActor = &exhumedActors[nSprite]; auto pSprite = &sprite[nSprite]; + auto pRadialSpr = &pRadialActor->s(); - if (nSprite == nRadialSpr) { + if (nSprite == pRadialActor->GetSpriteIndex()) { return 0; } @@ -1572,17 +1571,17 @@ int runlist_CheckRadialDamage(short nSprite) return 0; } - if (pSprite->statnum >= kMaxStatus || sprite[nRadialSpr].statnum >= kMaxStatus) { + if (pSprite->statnum >= kMaxStatus || pRadialSpr->statnum >= kMaxStatus) { return 0; } - if (pSprite->statnum != 100 && nSprite == nRadialOwner) { + if (pSprite->statnum != 100 && pActor == pRadialActor->pTarget) { return 0; } - int x = (pSprite->x - sprite[nRadialSpr].x) >> 8; - int y = (pSprite->y - sprite[nRadialSpr].y) >> 8; - int z = (pSprite->z - sprite[nRadialSpr].z) >> 12; + int x = (pSprite->x - pRadialSpr->x) >> 8; + int y = (pSprite->y - pRadialSpr->y) >> 8; + int z = (pSprite->z - pRadialSpr->z) >> 12; if (abs(x) > nDamageRadius) { return 0; @@ -1617,10 +1616,10 @@ int runlist_CheckRadialDamage(short nSprite) pSprite->cstat = 0x101; if (((kStatExplodeTarget - pSprite->statnum) <= 1) || - cansee(sprite[nRadialSpr].x, - sprite[nRadialSpr].y, - sprite[nRadialSpr].z - 512, - sprite[nRadialSpr].sectnum, + cansee(pRadialSpr->x, + pRadialSpr->y, + pRadialSpr->z - 512, + pRadialSpr->sectnum, pSprite->x, pSprite->y, pSprite->z - 8192, @@ -1663,16 +1662,15 @@ void runlist_RadialDamageEnemy(short nSprite, short nDamage, short nRadius) return; } - if (nRadialSpr == -1) + if (pRadialActor == nullptr) { nRadialDamage = nDamage * 4; nDamageRadius = nRadius; - nRadialSpr = nSprite; - nRadialOwner = pSprite->owner; + pRadialActor = &exhumedActors[nSprite]; runlist_ExplodeSignalRun(); - nRadialSpr = -1; + pRadialActor = nullptr; } } @@ -1780,7 +1778,7 @@ void runlist_DispatchEvent(ExhumedAI* ai, int nObject, int nMessage, int nDamage ev.nRadialDamage = nRadialDamage; ev.nDamageRadius = nDamageRadius; ev.pOtherActor = nullptr; // &exhumedActors[nObject]; nObject is always 0 here, this was setting some random invalid target - ev.pRadialActor = &exhumedActors[nRadialSpr]; + ev.pRadialActor = pRadialActor; ai->RadialDamage(&ev); break; }