- canSwim et.al.

This commit is contained in:
Christoph Oelckers 2021-05-06 10:24:29 +02:00
parent acec23e034
commit fb5916a3dd
5 changed files with 45 additions and 23 deletions

View file

@ -5184,7 +5184,7 @@ void MoveDude(DBloodActor* actor)
if (pSprite->type == kDudeModernCustom) { if (pSprite->type == kDudeModernCustom) {
evPost(actor, 0, kCallbackEnemeyBubble); evPost(actor, 0, kCallbackEnemeyBubble);
if (!canSwim(pSprite)) actKillDude(actor, actor, kDamageFall, 1000 << 4); if (!canSwim(actor)) actKillDude(actor, actor, kDamageFall, 1000 << 4);
break; break;
} }

View file

@ -227,7 +227,7 @@ bool CanMove(DBloodActor* actor, DBloodActor* target, int nAngle, int nRange)
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
case kDudeModernCustom: case kDudeModernCustom:
case kDudeModernCustomBurning: case kDudeModernCustomBurning:
if ((Crusher && !nnExtIsImmune(pSprite, pXSector->damageType)) || ((Water || Underwater) && !canSwim(pSprite))) return false; if ((Crusher && !nnExtIsImmune(pSprite, pXSector->damageType)) || ((Water || Underwater) && !canSwim(actor))) return false;
return true; return true;
[[fallthrough]]; [[fallthrough]];
#endif #endif
@ -1093,7 +1093,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
actKillDude(actor, actor, kDamageFall, 65535); actKillDude(actor, actor, kDamageFall, 65535);
} }
} }
else if (canWalk(pSprite) && !inDodge(pXSprite->aiState) && !inRecoil(pXSprite->aiState)) else if (canWalk(actor) && !inDodge(pXSprite->aiState) && !inRecoil(pXSprite->aiState))
{ {
if (!dudeIsMelee(actor)) if (!dudeIsMelee(actor))
{ {
@ -1101,7 +1101,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
{ {
if (!spriteIsUnderwater(actor)) if (!spriteIsUnderwater(actor))
{ {
if (!canDuck(pSprite) || !dudeIsPlayingSeq(actor, 14)) aiGenDudeNewState(actor, &genDudeDodgeShortL); if (!canDuck(actor) || !dudeIsPlayingSeq(actor, 14)) aiGenDudeNewState(actor, &genDudeDodgeShortL);
else aiGenDudeNewState(actor, &genDudeDodgeShortD); else aiGenDudeNewState(actor, &genDudeDodgeShortD);
if (Chance(0x0200)) if (Chance(0x0200))
@ -1279,7 +1279,7 @@ void RecoilDude(DBloodActor* actor)
{ {
if (Chance(rChance << 3) || (dudeIsMelee(actor) && Chance(rChance << 4))) aiGenDudeNewState(actor, &genDudeRecoilTesla); if (Chance(rChance << 3) || (dudeIsMelee(actor) && Chance(rChance << 4))) aiGenDudeNewState(actor, &genDudeRecoilTesla);
else if (pExtra->canRecoil && Chance(rChance)) aiGenDudeNewState(actor, &genDudeRecoilL); else if (pExtra->canRecoil && Chance(rChance)) aiGenDudeNewState(actor, &genDudeRecoilL);
else if (canWalk(pSprite)) else if (canWalk(actor))
{ {
if (Chance(rChance >> 2)) aiGenDudeNewState(actor, &genDudeDodgeL); if (Chance(rChance >> 2)) aiGenDudeNewState(actor, &genDudeDodgeL);
@ -1298,7 +1298,7 @@ void RecoilDude(DBloodActor* actor)
short rState = inRecoil(pXSprite->aiState); short rState = inRecoil(pXSprite->aiState);
if (rState > 0) if (rState > 0)
{ {
if (!canWalk(pSprite)) if (!canWalk(actor))
{ {
if (rState == 1) pXSprite->aiState->nextState = &genDudeChaseNoWalkL; if (rState == 1) pXSprite->aiState->nextState = &genDudeChaseNoWalkL;
else if (rState == 2) pXSprite->aiState->nextState = &genDudeChaseNoWalkD; else if (rState == 2) pXSprite->aiState->nextState = &genDudeChaseNoWalkD;

View file

@ -627,7 +627,7 @@ static void unicultThinkChase(DBloodActor* actor)
genDudeThrow2.nextState = &genDudeChaseL; genDudeThrow2.nextState = &genDudeChaseL;
if (dist > 5072 && Chance(0x5000)) if (dist > 5072 && Chance(0x5000))
{ {
if (!canDuck(pSprite) || Chance(0x4000)) aiGenDudeNewState(actor, &genDudeDodgeShortL); if (!canDuck(actor) || Chance(0x4000)) aiGenDudeNewState(actor, &genDudeDodgeShortL);
else aiGenDudeNewState(actor, &genDudeDodgeShortD); else aiGenDudeNewState(actor, &genDudeDodgeShortD);
} }
else else
@ -1202,7 +1202,7 @@ void aiGenDudeMoveForward(DBloodActor* actor)
int sin = Sin(pSprite->ang); int sin = Sin(pSprite->ang);
int cos = Cos(pSprite->ang); int cos = Cos(pSprite->ang);
int frontSpeed = gGenDudeExtra[pSprite->index].moveSpeed; int frontSpeed = actor->genDudeExtra().moveSpeed;
actor->xvel() += MulScale(cos, frontSpeed, 30); actor->xvel() += MulScale(cos, frontSpeed, 30);
actor->yvel() += MulScale(sin, frontSpeed, 30); actor->yvel() += MulScale(sin, frontSpeed, 30);
} }
@ -1304,7 +1304,7 @@ void aiGenDudeNewState(DBloodActor* actor, AISTATE* pAIState)
} }
if (!gGenDudeExtra[pSprite->index].canRecoil) if (!actor->genDudeExtra().canRecoil)
{ {
if (pAIState == &genDudeRecoilL || pAIState == &genDudeRecoilD) pAIState = &genDudeIdleL; if (pAIState == &genDudeRecoilL || pAIState == &genDudeRecoilD) pAIState = &genDudeIdleL;
else if (pAIState == &genDudeRecoilW) pAIState = &genDudeIdleW; else if (pAIState == &genDudeRecoilW) pAIState = &genDudeIdleW;
@ -1474,8 +1474,8 @@ void removeLeech(DBloodActor* actLeech, bool delSprite)
sfxPlay3DSoundCP(pLeech, 490, -1, 0,60000); sfxPlay3DSoundCP(pLeech, 490, -1, 0,60000);
if (pLeech->owner >= 0 && pLeech->owner < kMaxSprites) if (actLeech->GetOwner())
gGenDudeExtra[sprite[pLeech->owner].index].pLifeLeech = nullptr; actLeech->GetOwner()->genDudeExtra().pLifeLeech = nullptr;
if (delSprite) if (delSprite)
{ {
@ -2254,7 +2254,14 @@ void updateTargetOfSlaves(DBloodActor* actor)
pExtra->slaveCount = writeindex; pExtra->slaveCount = writeindex;
} }
short inDodge(AISTATE* aiState) { //---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
short inDodge(AISTATE* aiState)
{
if (aiState == &genDudeDodgeL) return 1; if (aiState == &genDudeDodgeL) return 1;
else if (aiState == &genDudeDodgeD) return 2; else if (aiState == &genDudeDodgeD) return 2;
else if (aiState == &genDudeDodgeW) return 3; else if (aiState == &genDudeDodgeW) return 3;
@ -2309,18 +2316,33 @@ short inDuck(AISTATE* aiState) {
} }
bool canSwim(spritetype* pSprite) { //---------------------------------------------------------------------------
return gGenDudeExtra[pSprite->index].canSwim; //
//
//
//---------------------------------------------------------------------------
bool canSwim(DBloodActor* actor)
{
return actor->genDudeExtra().canSwim;
} }
bool canDuck(spritetype* pSprite) { bool canDuck(DBloodActor* actor)
return gGenDudeExtra[pSprite->index].canDuck; {
return actor->genDudeExtra().canDuck;
} }
bool canWalk(spritetype* pSprite) { bool canWalk(DBloodActor* actor)
return gGenDudeExtra[pSprite->index].canWalk; {
return actor->genDudeExtra().canWalk;
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int genDudeSeqStartId(XSPRITE* pXSprite) { int genDudeSeqStartId(XSPRITE* pXSprite) {
if (genDudePrepare(&sprite[pXSprite->reference], kGenDudePropertyStates)) return pXSprite->data2; if (genDudePrepare(&sprite[pXSprite->reference], kGenDudePropertyStates)) return pXSprite->data2;
else return kGenDudeDefaultSeq; else return kGenDudeDefaultSeq;

View file

@ -215,9 +215,9 @@ int getRecoilChance(DBloodActor* pSprite);
bool dudeIsMelee(DBloodActor* pXSprite); bool dudeIsMelee(DBloodActor* pXSprite);
void updateTargetOfSlaves(DBloodActor* pSprite); void updateTargetOfSlaves(DBloodActor* pSprite);
void updateTargetOfLeech(DBloodActor* pSprite); void updateTargetOfLeech(DBloodActor* pSprite);
bool canSwim(spritetype* pSprite); bool canSwim(DBloodActor* actor);
bool canDuck(spritetype* pSprite); bool canDuck(DBloodActor* actor);
bool canWalk(spritetype* pSprite); bool canWalk(DBloodActor* actor);
short inDodge(AISTATE* aiState); short inDodge(AISTATE* aiState);
bool inIdle(AISTATE* aiState); bool inIdle(AISTATE* aiState);
bool inAttack(AISTATE* aiState); bool inAttack(AISTATE* aiState);

View file

@ -7485,7 +7485,7 @@ void aiPatrolThink(DBloodActor* actor) {
bool crouch = (pXSprite->unused1 & kDudeFlagCrouch), uwater = spriteIsUnderwater(actor); 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(actor)) || !canWalk(actor)))) {
aiPatrolStop(pSprite, -1); aiPatrolStop(pSprite, -1);
return; return;
} }