- spriteIsUnderwater

This commit is contained in:
Christoph Oelckers 2021-05-05 20:40:31 +02:00
parent 75258c8b29
commit d907627156
5 changed files with 59 additions and 51 deletions

View file

@ -2958,7 +2958,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType)
if (damageType == kDamageBurn) if (damageType == kDamageBurn)
{ {
if (pExtra->availDeaths[kDamageBurn] && !spriteIsUnderwater(pSprite)) if (pExtra->availDeaths[kDamageBurn] && !spriteIsUnderwater(actor))
{ {
if (pExtra->canBurn) if (pExtra->canBurn)
{ {

View file

@ -451,13 +451,13 @@ void aiActivateDude(DBloodActor* actor)
pDudeExtraE->active = 1; pDudeExtraE->active = 1;
if (actor->GetTarget() == nullptr) if (actor->GetTarget() == nullptr)
{ {
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchW); if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeSearchW);
else aiGenDudeNewState(actor, &genDudeSearchL); else aiGenDudeNewState(actor, &genDudeSearchL);
} }
else else
{ {
if (Chance(0x4000)) playGenDudeSound(actor,kGenDudeSndTargetSpot); if (Chance(0x4000)) playGenDudeSound(actor,kGenDudeSndTargetSpot);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeChaseW); if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeChaseW);
else aiGenDudeNewState(actor, &genDudeChaseL); else aiGenDudeNewState(actor, &genDudeChaseL);
} }
break; break;
@ -1038,7 +1038,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
} }
if (pXSprite->burnTime == 0) pXSprite->burnTime = 2400; if (pXSprite->burnTime == 0) pXSprite->burnTime = 2400;
if (spriteIsUnderwater(pSprite, false)) if (spriteIsUnderwater(actor, false))
{ {
pSprite->type = kDudeModernCustom; pSprite->type = kDudeModernCustom;
pXSprite->burnTime = 0; pXSprite->burnTime = 0;
@ -1063,7 +1063,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
if (pExtra->weaponType == kGenDudeWeaponKamikaze) if (pExtra->weaponType == kGenDudeWeaponKamikaze)
doExplosion(pSprite, pXSprite->data1 - kTrapExploder); doExplosion(pSprite, pXSprite->data1 - kTrapExploder);
if (spriteIsUnderwater(pSprite)) if (spriteIsUnderwater(actor))
{ {
pXSprite->health = 0; pXSprite->health = 0;
return nDamage; return nDamage;
@ -1099,7 +1099,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
{ {
if (inIdle(pXSprite->aiState) || Chance(getDodgeChance(pSprite))) if (inIdle(pXSprite->aiState) || Chance(getDodgeChance(pSprite)))
{ {
if (!spriteIsUnderwater(pSprite)) if (!spriteIsUnderwater(actor))
{ {
if (!canDuck(pSprite) || !dudeIsPlayingSeq(actor, 14)) aiGenDudeNewState(actor, &genDudeDodgeShortL); if (!canDuck(pSprite) || !dudeIsPlayingSeq(actor, 14)) aiGenDudeNewState(actor, &genDudeDodgeShortL);
else aiGenDudeNewState(actor, &genDudeDodgeShortD); else aiGenDudeNewState(actor, &genDudeDodgeShortD);
@ -1275,7 +1275,7 @@ void RecoilDude(DBloodActor* actor)
{ {
GENDUDEEXTRA* pExtra = &actor->genDudeExtra(); GENDUDEEXTRA* pExtra = &actor->genDudeExtra();
int rChance = getRecoilChance(pSprite); 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); if (Chance(rChance << 3) || (dudeIsMelee(pXSprite) && Chance(rChance << 4))) aiGenDudeNewState(actor, &genDudeRecoilTesla);
else if (pExtra->canRecoil && Chance(rChance)) aiGenDudeNewState(actor, &genDudeRecoilL); else if (pExtra->canRecoil && Chance(rChance)) aiGenDudeNewState(actor, &genDudeRecoilL);
@ -1291,7 +1291,7 @@ void RecoilDude(DBloodActor* actor)
else if (pExtra->canRecoil && Chance(rChance)) else if (pExtra->canRecoil && Chance(rChance))
{ {
if (inDuck(pXSprite->aiState) && Chance(rChance >> 2)) aiGenDudeNewState(actor, &genDudeRecoilD); 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); else aiGenDudeNewState(actor, &genDudeRecoilL);
} }
@ -1974,7 +1974,7 @@ void aiInitSprite(DBloodActor* actor)
pXSprite->data3 = 0; pXSprite->data3 = 0;
// make dude follow the markers // make dude follow the markers
bool uwater = spriteIsUnderwater(pSprite); bool uwater = spriteIsUnderwater(actor);
if (pXSprite->target_i <= 0 || sprite[pXSprite->target_i].type != kMarkerPath) { if (pXSprite->target_i <= 0 || sprite[pXSprite->target_i].type != kMarkerPath) {
pXSprite->target_i = -1; aiPatrolSetMarker(pSprite, pXSprite); pXSprite->target_i = -1; aiPatrolSetMarker(pSprite, pXSprite);
} }

View file

@ -456,7 +456,7 @@ static void unicultThinkGoto(DBloodActor* actor)
// if reached target, change to search mode // if reached target, change to search mode
if (approxDist(dx, dy) < 5120 && abs(pSprite->ang - nAngle) < getDudeInfo(pSprite->type)->periphery) 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); else aiGenDudeNewState(actor, &genDudeSearchL);
} }
aiThinkTarget(actor); aiThinkTarget(actor);
@ -477,7 +477,7 @@ static void unicultThinkChase(DBloodActor* actor)
auto const targetactor = actor->GetTarget(); auto const targetactor = actor->GetTarget();
if (targetactor == nullptr) if (targetactor == nullptr)
{ {
if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(actor, &genDudeGotoW); if(spriteIsUnderwater(actor,false)) aiGenDudeNewState(actor, &genDudeGotoW);
else aiGenDudeNewState(actor, &genDudeGotoL); else aiGenDudeNewState(actor, &genDudeGotoL);
return; return;
} }
@ -490,7 +490,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (pXTarget == nullptr) // target lost if (pXTarget == nullptr) // target lost
{ {
if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(actor, &genDudeSearchShortW); if(spriteIsUnderwater(actor,false)) aiGenDudeNewState(actor, &genDudeSearchShortW);
else aiGenDudeNewState(actor, &genDudeSearchShortL); else aiGenDudeNewState(actor, &genDudeSearchShortL);
actor->SetTarget(nullptr); actor->SetTarget(nullptr);
return; return;
@ -503,10 +503,10 @@ static void unicultThinkChase(DBloodActor* actor)
if ((!IsPlayerSprite(pTarget)) || ((pPlayer = getPlayerById(pTarget->type)) != NULL && pPlayer->fraggerId == pSprite->index)) if ((!IsPlayerSprite(pTarget)) || ((pPlayer = getPlayerById(pTarget->type)) != NULL && pPlayer->fraggerId == pSprite->index))
{ {
playGenDudeSound(actor, kGenDudeSndTargetDead); playGenDudeSound(actor, kGenDudeSndTargetDead);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchShortW); if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeSearchShortW);
else aiGenDudeNewState(actor, &genDudeSearchShortL); else aiGenDudeNewState(actor, &genDudeSearchShortL);
} }
else if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeGotoW); else if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeGotoW);
else aiGenDudeNewState(actor, &genDudeGotoL); else aiGenDudeNewState(actor, &genDudeGotoL);
actor->SetTarget(nullptr); actor->SetTarget(nullptr);
return; return;
@ -532,7 +532,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (!pExtra->canAttack) if (!pExtra->canAttack)
{ {
if (pExtra->canWalk) aiSetTarget(actor, actor); // targeting self??? 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); else aiGenDudeNewState(actor, &genDudeGotoL);
return; return;
} }
@ -541,7 +541,7 @@ static void unicultThinkChase(DBloodActor* actor)
PLAYER* pPlayer = &gPlayer[pTarget->type - kDudePlayer1]; PLAYER* pPlayer = &gPlayer[pTarget->type - kDudePlayer1];
if (powerupCheck(pPlayer, kPwUpShadowCloak) > 0) if (powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
{ {
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchShortW); if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeSearchShortW);
else aiGenDudeNewState(actor, &genDudeSearchShortL); else aiGenDudeNewState(actor, &genDudeSearchShortL);
actor->SetTarget(nullptr); actor->SetTarget(nullptr);
return; return;
@ -555,7 +555,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (dist > pDudeInfo->seeDist || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, if (dist > pDudeInfo->seeDist || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum,
pSprite->x, pSprite->y, pSprite->z - eyeAboveZ, pSprite->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); else aiGenDudeNewState(actor, &genDudeSearchL);
actor->SetTarget(nullptr); actor->SetTarget(nullptr);
return; return;
@ -564,7 +564,7 @@ static void unicultThinkChase(DBloodActor* actor)
// is the target visible? // is the target visible?
if (dist < pDudeInfo->seeDist && abs(losAngle) <= pDudeInfo->periphery) { 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); playGenDudeSound(actor, kGenDudeSndChasing);
actor->dudeSlope = DivScale(pTarget->z - pSprite->z, dist, 10); actor->dudeSlope = DivScale(pTarget->z - pSprite->z, dist, 10);
@ -579,12 +579,12 @@ static void unicultThinkChase(DBloodActor* actor)
{ {
if (!gThingInfoExtra[curWeapon - kThingBase].allowThrow) if (!gThingInfoExtra[curWeapon - kThingBase].allowThrow)
{ {
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW); if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeChaseW);
else aiGenDudeNewState(actor, &genDudeChaseL); else aiGenDudeNewState(actor, &genDudeChaseL);
return; 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); int pHit = HitScan(pSprite, pSprite->z, dx, dy, 0, 16777280, 0);
switch (pHit) { 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) switch (curWeapon)
{ {
@ -646,7 +646,7 @@ static void unicultThinkChase(DBloodActor* actor)
} else if (dist <= meleeVector->maxDist) } else if (dist <= meleeVector->maxDist)
{ {
if (spriteIsUnderwater(pSprite, false)) if (spriteIsUnderwater(actor, false))
{ {
if (Chance(0x9000)) aiGenDudeNewState(actor, &genDudePunch); if (Chance(0x9000)) aiGenDudeNewState(actor, &genDudePunch);
else aiGenDudeNewState(actor, &genDudeDodgeW); else aiGenDudeNewState(actor, &genDudeDodgeW);
@ -736,7 +736,7 @@ static void unicultThinkChase(DBloodActor* actor)
case kMissileFlameSpray: case kMissileFlameSpray:
case kMissileFlameHound: case kMissileFlameHound:
//viewSetSystemMessage("%d", pXTarget->burnTime); //viewSetSystemMessage("%d", pXTarget->burnTime);
if (spriteIsUnderwater(pSprite, false)) if (spriteIsUnderwater(actor, false))
{ {
if (dist > meleeVector->maxDist) aiGenDudeNewState(actor, &genDudeChaseW); if (dist > meleeVector->maxDist) aiGenDudeNewState(actor, &genDudeChaseW);
else if (Chance(0x8000)) aiGenDudeNewState(actor, &genDudePunch); else if (Chance(0x8000)) aiGenDudeNewState(actor, &genDudePunch);
@ -826,7 +826,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (weaponType != kGenDudeWeaponMissile && genDudeAdjustSlope(actor, dist, weaponType) if (weaponType != kGenDudeWeaponMissile && genDudeAdjustSlope(actor, dist, weaponType)
&& dist < (int)(6000 + Random(2000)) && pExtra->baseDispersion < kGenDudeMaxDispersion >> 1) break; && 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); else aiGenDudeNewState(actor, &genDudeChaseL);
return; return;
case 3: case 3:
@ -839,11 +839,11 @@ static void unicultThinkChase(DBloodActor* actor)
{ {
if (pExtra->baseDispersion < 1024 && weaponType != kGenDudeWeaponMissile) 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 if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeDodgeShorterD);
else aiGenDudeNewState(actor, &genDudeDodgeShorterL); 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 if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeDodgeShortD);
else aiGenDudeNewState(actor, &genDudeDodgeShortL); else aiGenDudeNewState(actor, &genDudeDodgeShortL);
@ -854,7 +854,7 @@ static void unicultThinkChase(DBloodActor* actor)
{ {
if (!inAttack(pXHSprite->aiState)) 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 if (inDuck(pXSprite->aiState)) aiGenDudeNewState(hitactor, &genDudeDodgeShorterD);
else aiGenDudeNewState(hitactor, &genDudeDodgeShorterL); else aiGenDudeNewState(hitactor, &genDudeDodgeShorterL);
@ -908,7 +908,7 @@ static void unicultThinkChase(DBloodActor* actor)
|| (dist <= (int)(pExtra->fireDist / ClipLow(Random(4), 1)))) || (dist <= (int)(pExtra->fireDist / ClipLow(Random(4), 1))))
{ {
//viewSetSystemMessage("GO CHASE"); //viewSetSystemMessage("GO CHASE");
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW); if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeChaseW);
else aiGenDudeNewState(actor, &genDudeChaseL); else aiGenDudeNewState(actor, &genDudeChaseL);
return; return;
@ -919,7 +919,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (wd1 < (wd2 << 3)) if (wd1 < (wd2 << 3))
{ {
//viewSetSystemMessage("OBJ SIZE: %d DUDE SIZE: %d", wd1, wd2); //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 if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeDodgeShorterD);
else aiGenDudeNewState(actor, &genDudeDodgeShorterL); 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 (((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); else aiGenDudeNewState(actor, &genDudeChaseL);
pXSprite->goalAng = Random(kAng360); pXSprite->goalAng = Random(kAng360);
//viewSetSystemMessage("WALL OR SPRITE TOUCH"); //viewSetSystemMessage("WALL OR SPRITE TOUCH");
@ -945,7 +945,7 @@ static void unicultThinkChase(DBloodActor* actor)
} }
else else
{ {
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW); if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeChaseW);
else aiGenDudeNewState(actor, &genDudeChaseL); else aiGenDudeNewState(actor, &genDudeChaseL);
//viewSetSystemMessage("TOO BIG OBJECT TO DODGE!!!!!!!!"); //viewSetSystemMessage("TOO BIG OBJECT TO DODGE!!!!!!!!");
} }
@ -963,7 +963,7 @@ static void unicultThinkChase(DBloodActor* actor)
//viewSetSystemMessage("WALL VHIT: %d", gHitInfo.hitwall); //viewSetSystemMessage("WALL VHIT: %d", gHitInfo.hitwall);
if ((actor != gHitInfo.hitactor) && (pHWall->type != kWallGib || !masked || pXHWall == NULL || !pXHWall->triggerVector || pXHWall->locked)) 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); else aiGenDudeNewState(actor, &genDudeChaseL);
return; return;
} }
@ -985,7 +985,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (dudeDist < mdist) if (dudeDist < mdist)
{ {
//viewSetSystemMessage("DUDE CLOSE TO OBJ: %d, MDIST: %d", 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); else aiGenDudeNewState(actor, &genDudeChaseL);
return; return;
} }
@ -1011,7 +1011,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (failed) if (failed)
{ {
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeSearchW); if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeSearchW);
else aiGenDudeNewState(actor, &genDudeSearchL); else aiGenDudeNewState(actor, &genDudeSearchL);
return; return;
} }
@ -1081,11 +1081,11 @@ int checkAttackState(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); 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 return 1; //water
} }
@ -1293,7 +1293,7 @@ void aiGenDudeNewState(DBloodActor* actor, AISTATE* pAIState)
else if (pAIState == &genDudeChaseW) pAIState = &genDudeChaseNoWalkW; else if (pAIState == &genDudeChaseW) pAIState = &genDudeChaseNoWalkW;
else if (pAIState == &genDudeRecoilTesla) { else if (pAIState == &genDudeRecoilTesla) {
if (spriteIsUnderwater(pSprite, false)) pAIState = &genDudeRecoilW; if (spriteIsUnderwater(actor, false)) pAIState = &genDudeRecoilW;
else pAIState = &genDudeRecoilL; 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) 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) { spritetype* leechIsDropped(spritetype* pSprite) {
@ -2309,18 +2312,18 @@ bool genDudePrepare(spritetype* pSprite, int propId) {
if (oldStatus != pExtra->canWalk) { if (oldStatus != pExtra->canWalk) {
if (!spriRangeIsFine(pXSprite->target_i)) if (!spriRangeIsFine(pXSprite->target_i))
{ {
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeIdleW); if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeIdleW);
else aiGenDudeNewState(actor, &genDudeIdleL); else aiGenDudeNewState(actor, &genDudeIdleL);
} }
else if (pExtra->canWalk) 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 if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeChaseD);
else aiGenDudeNewState(actor, &genDudeChaseL); else aiGenDudeNewState(actor, &genDudeChaseL);
} }
else else
{ {
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeChaseNoWalkW); if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeChaseNoWalkW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeChaseNoWalkD); else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeChaseNoWalkD);
else aiGenDudeNewState(actor, &genDudeChaseNoWalkL); else aiGenDudeNewState(actor, &genDudeChaseNoWalkL);
} }

View file

@ -200,7 +200,7 @@ void killDudeLeech(spritetype* pLeech);
void removeLeech(spritetype* pLeech, bool delSprite = true); void removeLeech(spritetype* pLeech, bool delSprite = true);
void removeDudeStuff(spritetype* pSprite); void removeDudeStuff(spritetype* pSprite);
spritetype* leechIsDropped(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); bool playGenDudeSound(DBloodActor* actor, int mode);
void aiGenDudeMoveForward(DBloodActor* actor); void aiGenDudeMoveForward(DBloodActor* actor);
void aiGenDudeChooseDirection(DBloodActor* actor, int a3, int aXvel = -1, int aYvel = -1); void aiGenDudeChooseDirection(DBloodActor* actor, int a3, int aXvel = -1, int aYvel = -1);

View file

@ -1253,6 +1253,7 @@ void nnExtProcessSuperSprites() {
continue; continue;
} }
auto debrisactor = &bloodActors[gPhysSpritesList[i]];
spritetype* pDebris = &sprite[gPhysSpritesList[i]]; spritetype* pDebris = &sprite[gPhysSpritesList[i]];
int idx = pDebris->index; int idx = pDebris->index;
@ -1316,7 +1317,7 @@ void nnExtProcessSuperSprites() {
pXDebris->goalAng = getangle(xvel[idx], yvel[idx]) & 2047; pXDebris->goalAng = getangle(xvel[idx], yvel[idx]) & 2047;
int ang = pDebris->ang & 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)) { else if (Chance(0x1000 - mass)) {
if (zvel[idx] > 0x100) debrisBubble(idx); if (zvel[idx] > 0x100) debrisBubble(idx);
@ -1550,6 +1551,7 @@ void debrisMove(int listIndex) {
int nSprite = gPhysSpritesList[listIndex]; int nSprite = gPhysSpritesList[listIndex];
int nXSprite = sprite[nSprite].extra; XSPRITE* pXDebris = &xsprite[nXSprite]; int nXSprite = sprite[nSprite].extra; XSPRITE* pXDebris = &xsprite[nXSprite];
spritetype* pSprite = &sprite[nSprite]; int nSector = pSprite->sectnum; spritetype* pSprite = &sprite[nSprite]; int nSector = pSprite->sectnum;
auto actor = &bloodActors[nSprite];
int top, bottom, i; int top, bottom, i;
GetSpriteExtents(pSprite, &top, &bottom); GetSpriteExtents(pSprite, &top, &bottom);
@ -1646,7 +1648,7 @@ void debrisMove(int listIndex) {
case kMarkerUpGoo: case kMarkerUpGoo:
int pitch = (150000 - (gSpriteMass[pSprite->extra].mass << 9)) + Random3(8192); int pitch = (150000 - (gSpriteMass[pSprite->extra].mass << 9)) + Random3(8192);
sfxPlay3DSoundCP(pSprite, 720, -1, 0, pitch, 75 - Random(40)); sfxPlay3DSoundCP(pSprite, 720, -1, 0, pitch, 75 - Random(40));
if (!spriteIsUnderwater(pSprite)) { if (!spriteIsUnderwater(actor)) {
evKill(pSprite->index, 3, kCallbackEnemeyBubble); evKill(pSprite->index, 3, kCallbackEnemeyBubble);
} else { } else {
evPost(pSprite->index, 3, 0, kCallbackEnemeyBubble); evPost(pSprite->index, 3, 0, kCallbackEnemeyBubble);
@ -3927,7 +3929,7 @@ bool condCheckSprite(XSPRITE* pXCond, int cmpOp, bool PUSH) {
} }
break; break;
case 30: 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); else if (PUSH) condPush(pXCond, OBJ_SECTOR, pSpr->sectnum);
return true; return true;
case 31: case 31:
@ -4747,6 +4749,7 @@ void useDudeSpawn(XSPRITE* pXSource, spritetype* pSprite) {
bool modernTypeOperateSprite(int nSprite, spritetype* pSprite, XSPRITE* pXSprite, EVENT event) { bool modernTypeOperateSprite(int nSprite, spritetype* pSprite, XSPRITE* pXSprite, EVENT event) {
auto actor = &bloodActors[pSprite->index];
if (event.cmd >= kCmdLock && event.cmd <= kCmdToggleLock) { if (event.cmd >= kCmdLock && event.cmd <= kCmdToggleLock) {
switch (event.cmd) { switch (event.cmd) {
case kCmdLock: case kCmdLock:
@ -6632,6 +6635,7 @@ bool aiPatrolMarkerReached(spritetype* pSprite, XSPRITE* pXSprite) {
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
auto actor = &bloodActors[pSprite->index];
DUDEINFO_EXTRA* pExtra = &gDudeInfoExtra[pSprite->type - kDudeBase]; DUDEINFO_EXTRA* pExtra = &gDudeInfoExtra[pSprite->type - kDudeBase];
if (spriRangeIsFine(pXSprite->target_i) && sprite[pXSprite->target_i].type == kMarkerPath) { 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 (approxDist(oX, oY) <= okDist) {
if (spriteIsUnderwater(pSprite) || pExtra->flying) { if (spriteIsUnderwater(actor) || pExtra->flying) {
okDist = pMarker->clipdist << 4; okDist = pMarker->clipdist << 4;
int ztop, zbot, ztop2, zbot2; int ztop, zbot, ztop2, zbot2;
@ -6900,7 +6904,7 @@ void aiPatrolMove(DBloodActor* actor) {
int vel = (pXSprite->unused1 & kDudeFlagCrouch) ? kMaxPatrolCrouchVelocity : kMaxPatrolVelocity; int vel = (pXSprite->unused1 & kDudeFlagCrouch) ? kMaxPatrolCrouchVelocity : kMaxPatrolVelocity;
int goalAng = 341; int goalAng = 341;
if (pExtra->flying || spriteIsUnderwater(pSprite)) { if (pExtra->flying || spriteIsUnderwater(actor)) {
goalAng >>= 1; goalAng >>= 1;
zvel[pSprite->index] = dz; 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) { void aiPatrolFlagsMgr(spritetype* pSource, XSPRITE* pXSource, spritetype* pDest, XSPRITE* pXDest, bool copy, bool init) {
auto destactor = &bloodActors[pDest->index];
// copy flags // copy flags
if (copy) { if (copy) {
@ -7441,7 +7446,7 @@ void aiPatrolFlagsMgr(spritetype* pSource, XSPRITE* pXSource, spritetype* pDest,
aiPatrolSetMarker(pDest, pXDest); aiPatrolSetMarker(pDest, pXDest);
if (spriteIsUnderwater(pDest)) aiPatrolState(pDest, kAiStatePatrolWaitW); if (spriteIsUnderwater(destactor)) aiPatrolState(pDest, kAiStatePatrolWaitW);
else aiPatrolState(pDest, kAiStatePatrolWaitL); else aiPatrolState(pDest, kAiStatePatrolWaitL);
pXDest->data3 = 0; // reset the spot progress 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)))) { if (!spriRangeIsFine(nMarker) || (pSprite->type == kDudeModernCustom && ((uwater && !canSwim(pSprite)) || !canWalk(pSprite)))) {
aiPatrolStop(pSprite, -1); aiPatrolStop(pSprite, -1);
return; return;