diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index e1bc4452c..e90353309 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2958,7 +2958,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType) if (damageType == kDamageBurn) { - if (pExtra->availDeaths[kDamageBurn] && !spriteIsUnderwater(pSprite)) + if (pExtra->availDeaths[kDamageBurn] && !spriteIsUnderwater(actor)) { if (pExtra->canBurn) { diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index cca535c3c..fb322ddd4 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -451,13 +451,13 @@ void aiActivateDude(DBloodActor* actor) pDudeExtraE->active = 1; if (actor->GetTarget() == nullptr) { - if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchW); + if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeSearchW); else aiGenDudeNewState(actor, &genDudeSearchL); } else { if (Chance(0x4000)) playGenDudeSound(actor,kGenDudeSndTargetSpot); - if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeChaseW); + if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeChaseW); else aiGenDudeNewState(actor, &genDudeChaseL); } break; @@ -1038,7 +1038,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType } if (pXSprite->burnTime == 0) pXSprite->burnTime = 2400; - if (spriteIsUnderwater(pSprite, false)) + if (spriteIsUnderwater(actor, false)) { pSprite->type = kDudeModernCustom; pXSprite->burnTime = 0; @@ -1063,7 +1063,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType if (pExtra->weaponType == kGenDudeWeaponKamikaze) doExplosion(pSprite, pXSprite->data1 - kTrapExploder); - if (spriteIsUnderwater(pSprite)) + if (spriteIsUnderwater(actor)) { pXSprite->health = 0; return nDamage; @@ -1099,7 +1099,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType { if (inIdle(pXSprite->aiState) || Chance(getDodgeChance(pSprite))) { - if (!spriteIsUnderwater(pSprite)) + if (!spriteIsUnderwater(actor)) { if (!canDuck(pSprite) || !dudeIsPlayingSeq(actor, 14)) aiGenDudeNewState(actor, &genDudeDodgeShortL); else aiGenDudeNewState(actor, &genDudeDodgeShortD); @@ -1275,7 +1275,7 @@ void RecoilDude(DBloodActor* actor) { GENDUDEEXTRA* pExtra = &actor->genDudeExtra(); int rChance = getRecoilChance(pSprite); - if (pExtra->canElectrocute && pDudeExtra->teslaHit && !spriteIsUnderwater(pSprite, false)) + if (pExtra->canElectrocute && pDudeExtra->teslaHit && !spriteIsUnderwater(actor, false)) { if (Chance(rChance << 3) || (dudeIsMelee(pXSprite) && Chance(rChance << 4))) aiGenDudeNewState(actor, &genDudeRecoilTesla); else if (pExtra->canRecoil && Chance(rChance)) aiGenDudeNewState(actor, &genDudeRecoilL); @@ -1291,7 +1291,7 @@ void RecoilDude(DBloodActor* actor) else if (pExtra->canRecoil && Chance(rChance)) { if (inDuck(pXSprite->aiState) && Chance(rChance >> 2)) aiGenDudeNewState(actor, &genDudeRecoilD); - else if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeRecoilW); + else if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeRecoilW); else aiGenDudeNewState(actor, &genDudeRecoilL); } @@ -1974,7 +1974,7 @@ void aiInitSprite(DBloodActor* actor) pXSprite->data3 = 0; // make dude follow the markers - bool uwater = spriteIsUnderwater(pSprite); + bool uwater = spriteIsUnderwater(actor); if (pXSprite->target_i <= 0 || sprite[pXSprite->target_i].type != kMarkerPath) { pXSprite->target_i = -1; aiPatrolSetMarker(pSprite, pXSprite); } diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 4af885680..66ee6c1ce 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -456,7 +456,7 @@ static void unicultThinkGoto(DBloodActor* actor) // if reached target, change to search mode if (approxDist(dx, dy) < 5120 && abs(pSprite->ang - nAngle) < getDudeInfo(pSprite->type)->periphery) { - if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchW); + if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeSearchW); else aiGenDudeNewState(actor, &genDudeSearchL); } aiThinkTarget(actor); @@ -477,7 +477,7 @@ static void unicultThinkChase(DBloodActor* actor) auto const targetactor = actor->GetTarget(); if (targetactor == nullptr) { - if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(actor, &genDudeGotoW); + if(spriteIsUnderwater(actor,false)) aiGenDudeNewState(actor, &genDudeGotoW); else aiGenDudeNewState(actor, &genDudeGotoL); return; } @@ -490,7 +490,7 @@ static void unicultThinkChase(DBloodActor* actor) if (pXTarget == nullptr) // target lost { - if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(actor, &genDudeSearchShortW); + if(spriteIsUnderwater(actor,false)) aiGenDudeNewState(actor, &genDudeSearchShortW); else aiGenDudeNewState(actor, &genDudeSearchShortL); actor->SetTarget(nullptr); return; @@ -503,10 +503,10 @@ static void unicultThinkChase(DBloodActor* actor) if ((!IsPlayerSprite(pTarget)) || ((pPlayer = getPlayerById(pTarget->type)) != NULL && pPlayer->fraggerId == pSprite->index)) { playGenDudeSound(actor, kGenDudeSndTargetDead); - if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchShortW); + if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeSearchShortW); else aiGenDudeNewState(actor, &genDudeSearchShortL); } - else if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeGotoW); + else if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeGotoW); else aiGenDudeNewState(actor, &genDudeGotoL); actor->SetTarget(nullptr); return; @@ -532,7 +532,7 @@ static void unicultThinkChase(DBloodActor* actor) if (!pExtra->canAttack) { if (pExtra->canWalk) aiSetTarget(actor, actor); // targeting self??? - if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeGotoW); + if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeGotoW); else aiGenDudeNewState(actor, &genDudeGotoL); return; } @@ -541,7 +541,7 @@ static void unicultThinkChase(DBloodActor* actor) PLAYER* pPlayer = &gPlayer[pTarget->type - kDudePlayer1]; if (powerupCheck(pPlayer, kPwUpShadowCloak) > 0) { - if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchShortW); + if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeSearchShortW); else aiGenDudeNewState(actor, &genDudeSearchShortL); actor->SetTarget(nullptr); return; @@ -555,7 +555,7 @@ static void unicultThinkChase(DBloodActor* actor) if (dist > pDudeInfo->seeDist || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - eyeAboveZ, pSprite->sectnum)) { - if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchW); + if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeSearchW); else aiGenDudeNewState(actor, &genDudeSearchL); actor->SetTarget(nullptr); return; @@ -564,7 +564,7 @@ static void unicultThinkChase(DBloodActor* actor) // is the target visible? if (dist < pDudeInfo->seeDist && abs(losAngle) <= pDudeInfo->periphery) { - if ((PlayClock & 64) == 0 && Chance(0x3000) && !spriteIsUnderwater(pSprite, false)) + if ((PlayClock & 64) == 0 && Chance(0x3000) && !spriteIsUnderwater(actor, false)) playGenDudeSound(actor, kGenDudeSndChasing); actor->dudeSlope = DivScale(pTarget->z - pSprite->z, dist, 10); @@ -579,12 +579,12 @@ static void unicultThinkChase(DBloodActor* actor) { if (!gThingInfoExtra[curWeapon - kThingBase].allowThrow) { - if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW); + if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeChaseW); else aiGenDudeNewState(actor, &genDudeChaseL); return; } - else if (dist < 12264 && dist > 7680 && !spriteIsUnderwater(pSprite, false) && curWeapon != kModernThingEnemyLifeLeech) + else if (dist < 12264 && dist > 7680 && !spriteIsUnderwater(actor, false) && curWeapon != kModernThingEnemyLifeLeech) { int pHit = HitScan(pSprite, pSprite->z, dx, dy, 0, 16777280, 0); switch (pHit) { @@ -597,7 +597,7 @@ static void unicultThinkChase(DBloodActor* actor) } } - else if (dist > 4072 && dist <= 11072 && !spriteIsUnderwater(pSprite, false) && pSprite->owner != (kMaxSprites - 1)) + else if (dist > 4072 && dist <= 11072 && !spriteIsUnderwater(actor, false) && pSprite->owner != (kMaxSprites - 1)) { switch (curWeapon) { @@ -646,7 +646,7 @@ static void unicultThinkChase(DBloodActor* actor) } else if (dist <= meleeVector->maxDist) { - if (spriteIsUnderwater(pSprite, false)) + if (spriteIsUnderwater(actor, false)) { if (Chance(0x9000)) aiGenDudeNewState(actor, &genDudePunch); else aiGenDudeNewState(actor, &genDudeDodgeW); @@ -736,7 +736,7 @@ static void unicultThinkChase(DBloodActor* actor) case kMissileFlameSpray: case kMissileFlameHound: //viewSetSystemMessage("%d", pXTarget->burnTime); - if (spriteIsUnderwater(pSprite, false)) + if (spriteIsUnderwater(actor, false)) { if (dist > meleeVector->maxDist) aiGenDudeNewState(actor, &genDudeChaseW); else if (Chance(0x8000)) aiGenDudeNewState(actor, &genDudePunch); @@ -826,7 +826,7 @@ static void unicultThinkChase(DBloodActor* actor) if (weaponType != kGenDudeWeaponMissile && genDudeAdjustSlope(actor, dist, weaponType) && dist < (int)(6000 + Random(2000)) && pExtra->baseDispersion < kGenDudeMaxDispersion >> 1) break; - else if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW); + else if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeChaseW); else aiGenDudeNewState(actor, &genDudeChaseL); return; case 3: @@ -839,11 +839,11 @@ static void unicultThinkChase(DBloodActor* actor) { if (pExtra->baseDispersion < 1024 && weaponType != kGenDudeWeaponMissile) { - if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeDodgeShorterW); + if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeDodgeShorterW); else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeDodgeShorterD); else aiGenDudeNewState(actor, &genDudeDodgeShorterL); } - else if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeDodgeShortW); + else if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeDodgeShortW); else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeDodgeShortD); else aiGenDudeNewState(actor, &genDudeDodgeShortL); @@ -854,7 +854,7 @@ static void unicultThinkChase(DBloodActor* actor) { if (!inAttack(pXHSprite->aiState)) { - if (spriteIsUnderwater(pHSprite)) aiGenDudeNewState(hitactor, &genDudeDodgeShorterW); + if (spriteIsUnderwater(hitactor)) aiGenDudeNewState(hitactor, &genDudeDodgeShorterW); else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(hitactor, &genDudeDodgeShorterD); else aiGenDudeNewState(hitactor, &genDudeDodgeShorterL); @@ -908,7 +908,7 @@ static void unicultThinkChase(DBloodActor* actor) || (dist <= (int)(pExtra->fireDist / ClipLow(Random(4), 1)))) { //viewSetSystemMessage("GO CHASE"); - if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW); + if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeChaseW); else aiGenDudeNewState(actor, &genDudeChaseL); return; @@ -919,7 +919,7 @@ static void unicultThinkChase(DBloodActor* actor) if (wd1 < (wd2 << 3)) { //viewSetSystemMessage("OBJ SIZE: %d DUDE SIZE: %d", wd1, wd2); - if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeDodgeShorterW); + if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeDodgeShorterW); else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeDodgeShorterD); else aiGenDudeNewState(actor, &genDudeDodgeShorterL); @@ -936,7 +936,7 @@ static void unicultThinkChase(DBloodActor* actor) if (((gSpriteHit[pSprite->extra].hit & 0xc000) == 0x8000) || ((gSpriteHit[pSprite->extra].hit & 0xc000) == 0xc000)) { - if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW); + if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeChaseW); else aiGenDudeNewState(actor, &genDudeChaseL); pXSprite->goalAng = Random(kAng360); //viewSetSystemMessage("WALL OR SPRITE TOUCH"); @@ -945,7 +945,7 @@ static void unicultThinkChase(DBloodActor* actor) } else { - if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW); + if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeChaseW); else aiGenDudeNewState(actor, &genDudeChaseL); //viewSetSystemMessage("TOO BIG OBJECT TO DODGE!!!!!!!!"); } @@ -963,7 +963,7 @@ static void unicultThinkChase(DBloodActor* actor) //viewSetSystemMessage("WALL VHIT: %d", gHitInfo.hitwall); if ((actor != gHitInfo.hitactor) && (pHWall->type != kWallGib || !masked || pXHWall == NULL || !pXHWall->triggerVector || pXHWall->locked)) { - if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW); + if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeChaseW); else aiGenDudeNewState(actor, &genDudeChaseL); return; } @@ -985,7 +985,7 @@ static void unicultThinkChase(DBloodActor* actor) if (dudeDist < mdist) { //viewSetSystemMessage("DUDE CLOSE TO OBJ: %d, MDIST: %d", dudeDist, mdist); - if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW); + if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeChaseW); else aiGenDudeNewState(actor, &genDudeChaseL); return; } @@ -1011,7 +1011,7 @@ static void unicultThinkChase(DBloodActor* actor) if (failed) { - if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeSearchW); + if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeSearchW); else aiGenDudeNewState(actor, &genDudeSearchL); return; } @@ -1081,11 +1081,11 @@ int checkAttackState(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - if (dudeIsPlayingSeq(actor, 14) || spriteIsUnderwater(pSprite,false)) + if (dudeIsPlayingSeq(actor, 14) || spriteIsUnderwater(actor,false)) { - if ( !dudeIsPlayingSeq(actor, 14) || spriteIsUnderwater(pSprite,false)) + if ( !dudeIsPlayingSeq(actor, 14) || spriteIsUnderwater(actor,false)) { - if (spriteIsUnderwater(pSprite,false)) + if (spriteIsUnderwater(actor,false)) { return 1; //water } @@ -1293,7 +1293,7 @@ void aiGenDudeNewState(DBloodActor* actor, AISTATE* pAIState) else if (pAIState == &genDudeChaseW) pAIState = &genDudeChaseNoWalkW; else if (pAIState == &genDudeRecoilTesla) { - if (spriteIsUnderwater(pSprite, false)) pAIState = &genDudeRecoilW; + if (spriteIsUnderwater(actor, false)) pAIState = &genDudeRecoilW; else pAIState = &genDudeRecoilL; } @@ -1399,9 +1399,12 @@ bool playGenDudeSound(DBloodActor* actor, int mode) // //--------------------------------------------------------------------------- -bool spriteIsUnderwater(spritetype* pSprite, bool oldWay) { +bool spriteIsUnderwater(DBloodActor* actor, bool oldWay) +{ + auto const pSprite = &actor->s(); + auto const pXSprite = &actor->x(); return ((sector[pSprite->sectnum].extra >= 0 && xsector[sector[pSprite->sectnum].extra].Underwater) - || (oldWay && (xsprite[pSprite->extra].medium == kMediumWater || xsprite[pSprite->extra].medium == kMediumGoo))); + || (oldWay && (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo))); } spritetype* leechIsDropped(spritetype* pSprite) { @@ -2309,18 +2312,18 @@ bool genDudePrepare(spritetype* pSprite, int propId) { if (oldStatus != pExtra->canWalk) { if (!spriRangeIsFine(pXSprite->target_i)) { - if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeIdleW); + if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeIdleW); else aiGenDudeNewState(actor, &genDudeIdleL); } else if (pExtra->canWalk) { - if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeChaseW); + if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeChaseW); else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeChaseD); else aiGenDudeNewState(actor, &genDudeChaseL); } else { - if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeChaseNoWalkW); + if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeChaseNoWalkW); else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeChaseNoWalkD); else aiGenDudeNewState(actor, &genDudeChaseNoWalkL); } diff --git a/source/games/blood/src/aiunicult.h b/source/games/blood/src/aiunicult.h index 0e064fd8e..3ebc31e4c 100644 --- a/source/games/blood/src/aiunicult.h +++ b/source/games/blood/src/aiunicult.h @@ -200,7 +200,7 @@ void killDudeLeech(spritetype* pLeech); void removeLeech(spritetype* pLeech, bool delSprite = true); void removeDudeStuff(spritetype* pSprite); spritetype* leechIsDropped(spritetype* pSprite); -bool spriteIsUnderwater(spritetype* pSprite, bool oldWay = false); +bool spriteIsUnderwater(DBloodActor* pSprite, bool oldWay = false); bool playGenDudeSound(DBloodActor* actor, int mode); void aiGenDudeMoveForward(DBloodActor* actor); void aiGenDudeChooseDirection(DBloodActor* actor, int a3, int aXvel = -1, int aYvel = -1); diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 8db5364a8..c3712a1de 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1253,6 +1253,7 @@ void nnExtProcessSuperSprites() { continue; } + auto debrisactor = &bloodActors[gPhysSpritesList[i]]; spritetype* pDebris = &sprite[gPhysSpritesList[i]]; int idx = pDebris->index; @@ -1316,7 +1317,7 @@ void nnExtProcessSuperSprites() { pXDebris->goalAng = getangle(xvel[idx], yvel[idx]) & 2047; int ang = pDebris->ang & 2047; - if ((uwater = spriteIsUnderwater(pDebris)) == false) evKill(idx, 3, kCallbackEnemeyBubble); + if ((uwater = spriteIsUnderwater(debrisactor)) == false) evKill(idx, 3, kCallbackEnemeyBubble); else if (Chance(0x1000 - mass)) { if (zvel[idx] > 0x100) debrisBubble(idx); @@ -1550,6 +1551,7 @@ void debrisMove(int listIndex) { int nSprite = gPhysSpritesList[listIndex]; int nXSprite = sprite[nSprite].extra; XSPRITE* pXDebris = &xsprite[nXSprite]; spritetype* pSprite = &sprite[nSprite]; int nSector = pSprite->sectnum; + auto actor = &bloodActors[nSprite]; int top, bottom, i; GetSpriteExtents(pSprite, &top, &bottom); @@ -1646,7 +1648,7 @@ void debrisMove(int listIndex) { case kMarkerUpGoo: int pitch = (150000 - (gSpriteMass[pSprite->extra].mass << 9)) + Random3(8192); sfxPlay3DSoundCP(pSprite, 720, -1, 0, pitch, 75 - Random(40)); - if (!spriteIsUnderwater(pSprite)) { + if (!spriteIsUnderwater(actor)) { evKill(pSprite->index, 3, kCallbackEnemeyBubble); } else { evPost(pSprite->index, 3, 0, kCallbackEnemeyBubble); @@ -3927,7 +3929,7 @@ bool condCheckSprite(XSPRITE* pXCond, int cmpOp, bool PUSH) { } break; case 30: - if (!spriteIsUnderwater(pSpr) && !spriteIsUnderwater(pSpr, true)) return false; + if (!spriteIsUnderwater(spractor) && !spriteIsUnderwater(spractor, true)) return false; else if (PUSH) condPush(pXCond, OBJ_SECTOR, pSpr->sectnum); return true; case 31: @@ -4747,6 +4749,7 @@ void useDudeSpawn(XSPRITE* pXSource, spritetype* pSprite) { bool modernTypeOperateSprite(int nSprite, spritetype* pSprite, XSPRITE* pXSprite, EVENT event) { + auto actor = &bloodActors[pSprite->index]; if (event.cmd >= kCmdLock && event.cmd <= kCmdToggleLock) { switch (event.cmd) { case kCmdLock: @@ -6632,6 +6635,7 @@ bool aiPatrolMarkerReached(spritetype* pSprite, XSPRITE* pXSprite) { assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); + auto actor = &bloodActors[pSprite->index]; DUDEINFO_EXTRA* pExtra = &gDudeInfoExtra[pSprite->type - kDudeBase]; if (spriRangeIsFine(pXSprite->target_i) && sprite[pXSprite->target_i].type == kMarkerPath) { @@ -6642,7 +6646,7 @@ bool aiPatrolMarkerReached(spritetype* pSprite, XSPRITE* pXSprite) { if (approxDist(oX, oY) <= okDist) { - if (spriteIsUnderwater(pSprite) || pExtra->flying) { + if (spriteIsUnderwater(actor) || pExtra->flying) { okDist = pMarker->clipdist << 4; int ztop, zbot, ztop2, zbot2; @@ -6900,7 +6904,7 @@ void aiPatrolMove(DBloodActor* actor) { int vel = (pXSprite->unused1 & kDudeFlagCrouch) ? kMaxPatrolCrouchVelocity : kMaxPatrolVelocity; int goalAng = 341; - if (pExtra->flying || spriteIsUnderwater(pSprite)) { + if (pExtra->flying || spriteIsUnderwater(actor)) { goalAng >>= 1; zvel[pSprite->index] = dz; @@ -7409,6 +7413,7 @@ int aiPatrolSearchTargets(spritetype* pSprite, XSPRITE* pXSprite) { void aiPatrolFlagsMgr(spritetype* pSource, XSPRITE* pXSource, spritetype* pDest, XSPRITE* pXDest, bool copy, bool init) { + auto destactor = &bloodActors[pDest->index]; // copy flags if (copy) { @@ -7441,7 +7446,7 @@ void aiPatrolFlagsMgr(spritetype* pSource, XSPRITE* pXSource, spritetype* pDest, aiPatrolSetMarker(pDest, pXDest); - if (spriteIsUnderwater(pDest)) aiPatrolState(pDest, kAiStatePatrolWaitW); + if (spriteIsUnderwater(destactor)) aiPatrolState(pDest, kAiStatePatrolWaitW); else aiPatrolState(pDest, kAiStatePatrolWaitL); pXDest->data3 = 0; // reset the spot progress @@ -7473,7 +7478,7 @@ void aiPatrolThink(DBloodActor* actor) { } - bool crouch = (pXSprite->unused1 & kDudeFlagCrouch), uwater = spriteIsUnderwater(pSprite); + bool crouch = (pXSprite->unused1 & kDudeFlagCrouch), uwater = spriteIsUnderwater(actor); if (!spriRangeIsFine(nMarker) || (pSprite->type == kDudeModernCustom && ((uwater && !canSwim(pSprite)) || !canWalk(pSprite)))) { aiPatrolStop(pSprite, -1); return;