- use actor parameter in all calls to aiGenDudeNewState.

# Conflicts:
#	source/games/blood/src/aiunicult.cpp
This commit is contained in:
Christoph Oelckers 2021-08-31 21:52:26 +02:00
parent 9de6c7df46
commit c848518746
5 changed files with 127 additions and 125 deletions

View file

@ -2966,7 +2966,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType)
if (pXSprite->data2 == kGenDudeDefaultSeq) // don't inherit palette for burning if using default animation
pSprite->pal = 0;
aiGenDudeNewState(pSprite, &genDudeBurnGoto);
aiGenDudeNewState(actor, &genDudeBurnGoto);
actHealDude(actor, dudeInfo[55].startHealth, dudeInfo[55].startHealth);
if (pXSprite->burnTime <= 0) pXSprite->burnTime = 1200;
actor->dudeExtra.time = PlayClock + 360;

View file

@ -451,20 +451,20 @@ void aiActivateDude(DBloodActor* actor)
pDudeExtraE->active = 1;
if (actor->GetTarget() == nullptr)
{
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchW);
else aiGenDudeNewState(pSprite, &genDudeSearchL);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchW);
else aiGenDudeNewState(actor, &genDudeSearchL);
}
else
{
if (Chance(0x4000)) playGenDudeSound(pSprite, kGenDudeSndTargetSpot);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeChaseW);
else aiGenDudeNewState(pSprite, &genDudeChaseL);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeChaseW);
else aiGenDudeNewState(actor, &genDudeChaseL);
}
break;
}
case kDudeModernCustomBurning:
if (actor->GetTarget() == nullptr) aiGenDudeNewState(pSprite, &genDudeBurnSearch);
else aiGenDudeNewState(pSprite, &genDudeBurnChase);
if (actor->GetTarget() == nullptr) aiGenDudeNewState(actor, &genDudeBurnSearch);
else aiGenDudeNewState(actor, &genDudeBurnChase);
break;
#endif
case kDudeCultistTommyProne:
@ -1043,7 +1043,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
pSprite->type = kDudeModernCustom;
pXSprite->burnTime = 0;
pXSprite->health = 1; // so it can be killed with flame weapons while underwater and if already was burning dude before.
aiGenDudeNewState(pSprite, &genDudeGotoW);
aiGenDudeNewState(actor, &genDudeGotoW);
}
return nDamage;
@ -1081,7 +1081,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
if (pXSprite->data2 == kGenDudeDefaultSeq) // don't inherit palette for burning if using default animation
pSprite->pal = 0;
aiGenDudeNewState(pSprite, &genDudeBurnGoto);
aiGenDudeNewState(actor, &genDudeBurnGoto);
actHealDude(actor, dudeInfo[55].startHealth, dudeInfo[55].startHealth);
actor->dudeExtra.time = PlayClock + 360;
evKill(actor, kCallbackFXFlameLick);
@ -1101,8 +1101,8 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
{
if (!spriteIsUnderwater(pSprite))
{
if (!canDuck(pSprite) || !dudeIsPlayingSeq(actor, 14)) aiGenDudeNewState(pSprite, &genDudeDodgeShortL);
else aiGenDudeNewState(pSprite, &genDudeDodgeShortD);
if (!canDuck(pSprite) || !dudeIsPlayingSeq(actor, 14)) aiGenDudeNewState(actor, &genDudeDodgeShortL);
else aiGenDudeNewState(actor, &genDudeDodgeShortD);
if (Chance(0x0200))
playGenDudeSound(pSprite, kGenDudeSndGotHit);
@ -1110,7 +1110,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
}
else if (dudeIsPlayingSeq(actor, 13))
{
aiGenDudeNewState(pSprite, &genDudeDodgeShortW);
aiGenDudeNewState(actor, &genDudeDodgeShortW);
}
}
}
@ -1277,23 +1277,22 @@ void RecoilDude(DBloodActor* actor)
int rChance = getRecoilChance(pSprite);
if (pExtra->canElectrocute && pDudeExtra->teslaHit && !spriteIsUnderwater(pSprite, false))
{
if (Chance(rChance << 3) || (dudeIsMelee(pXSprite) && Chance(rChance << 4))) aiGenDudeNewState(pSprite, &genDudeRecoilTesla);
else if (pExtra->canRecoil && Chance(rChance)) aiGenDudeNewState(pSprite, &genDudeRecoilL);
if (Chance(rChance << 3) || (dudeIsMelee(pXSprite) && Chance(rChance << 4))) aiGenDudeNewState(actor, &genDudeRecoilTesla);
else if (pExtra->canRecoil && Chance(rChance)) aiGenDudeNewState(actor, &genDudeRecoilL);
else if (canWalk(pSprite))
{
if (Chance(rChance >> 2)) aiGenDudeNewState(pSprite, &genDudeDodgeL);
else if (Chance(rChance >> 1)) aiGenDudeNewState(pSprite, &genDudeDodgeShortL);
if (Chance(rChance >> 2)) aiGenDudeNewState(actor, &genDudeDodgeL);
else if (Chance(rChance >> 1)) aiGenDudeNewState(actor, &genDudeDodgeShortL);
}
}
else if (pExtra->canRecoil && Chance(rChance))
{
if (inDuck(pXSprite->aiState) && Chance(rChance >> 2)) aiGenDudeNewState(pSprite, &genDudeRecoilD);
else if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeRecoilW);
else aiGenDudeNewState(pSprite, &genDudeRecoilL);
if (inDuck(pXSprite->aiState) && Chance(rChance >> 2)) aiGenDudeNewState(actor, &genDudeRecoilD);
else if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeRecoilW);
else aiGenDudeNewState(actor, &genDudeRecoilL);
}
short rState = inRecoil(pXSprite->aiState);
@ -1359,7 +1358,7 @@ void RecoilDude(DBloodActor* actor)
break;
#ifdef NOONE_EXTENSIONS
case kDudeModernCustomBurning:
aiGenDudeNewState(pSprite, &genDudeBurnGoto);
aiGenDudeNewState(actor, &genDudeBurnGoto);
break;
#endif
case kDudeZombieButcher:
@ -1675,7 +1674,7 @@ void aiProcessDudes(void)
if (pXSprite->stateTimer == 0 && pXSprite->aiState && pXSprite->aiState->nextState
&& (pXSprite->aiState->stateTicks > 0 || seqGetStatus(3, pSprite->extra) < 0))
{
aiGenDudeNewState(pSprite, pXSprite->aiState->nextState);
aiGenDudeNewState(actor, pXSprite->aiState->nextState);
}
int hinder = ((pExtra->isMelee) ? 25 : 5) << 4;
if (pXSprite->health <= 0 || hinder > actor->cumulDamage) break;

View file

@ -142,7 +142,7 @@ static bool genDudeAdjustSlope(DBloodActor* actor, int dist, int weaponType, int
{
spritetype* pSprite = &actor->s();
XSPRITE* pXSprite = &actor->x();
if (spriRangeIsFine(pXSprite->target_i))
if (actor->GetTarget() != nullptr)
{
int fStart = 0;
int fEnd = 0;
@ -455,8 +455,8 @@ 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(pSprite, &genDudeSearchW);
else aiGenDudeNewState(pSprite, &genDudeSearchL);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchW);
else aiGenDudeNewState(actor, &genDudeSearchL);
}
aiThinkTarget(actor);
}
@ -472,9 +472,12 @@ static void unicultThinkChase(DBloodActor* actor)
auto const pXSprite = &actor->x();
auto const pSprite = &actor->s();
if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax) return;
else if (pXSprite->target_i < 0 || pXSprite->target_i >= kMaxSprites) {
if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(pSprite, &genDudeGotoW);
else aiGenDudeNewState(pSprite, &genDudeGotoL);
auto const targetactor = actor->GetTarget();
if (targetactor == nullptr)
{
if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(actor, &genDudeGotoW);
else aiGenDudeNewState(actor, &genDudeGotoL);
return;
} else {
@ -482,13 +485,12 @@ static void unicultThinkChase(DBloodActor* actor)
}
auto const targetactor = actor->GetTarget();
XSPRITE* pXTarget = !targetactor || !targetactor->IsDudeActor() || !targetactor->hasX() ? nullptr : &targetactor->x();
if (pXTarget == nullptr) // target lost
{
if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(pSprite, &genDudeSearchShortW);
else aiGenDudeNewState(pSprite, &genDudeSearchShortL);
if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(actor, &genDudeSearchShortW);
else aiGenDudeNewState(actor, &genDudeSearchShortL);
actor->SetTarget(nullptr);
return;
}
@ -500,11 +502,11 @@ static void unicultThinkChase(DBloodActor* actor)
if ((!IsPlayerSprite(pTarget)) || ((pPlayer = getPlayerById(pTarget->type)) != NULL && pPlayer->fraggerId == pSprite->index))
{
playGenDudeSound(pSprite, kGenDudeSndTargetDead);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchShortW);
else aiGenDudeNewState(pSprite, &genDudeSearchShortL);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchShortW);
else aiGenDudeNewState(actor, &genDudeSearchShortL);
}
else if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeGotoW);
else aiGenDudeNewState(pSprite, &genDudeGotoL);
else if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeGotoW);
else aiGenDudeNewState(actor, &genDudeGotoL);
actor->SetTarget(nullptr);
return;
}
@ -527,8 +529,8 @@ static void unicultThinkChase(DBloodActor* actor)
if (!pExtra->canAttack)
{
if (pExtra->canWalk) aiSetTarget(actor, actor); // targeting self???
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeGotoW);
else aiGenDudeNewState(pSprite, &genDudeGotoL);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeGotoW);
else aiGenDudeNewState(actor, &genDudeGotoL);
return;
}
else if (IsPlayerSprite(pTarget))
@ -536,8 +538,8 @@ static void unicultThinkChase(DBloodActor* actor)
PLAYER* pPlayer = &gPlayer[pTarget->type - kDudePlayer1];
if (powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
{
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchShortW);
else aiGenDudeNewState(pSprite, &genDudeSearchShortL);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchShortW);
else aiGenDudeNewState(actor, &genDudeSearchShortL);
actor->SetTarget(nullptr);
return;
}
@ -550,8 +552,8 @@ 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(pSprite, &genDudeSearchW);
else aiGenDudeNewState(pSprite, &genDudeSearchL);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeSearchW);
else aiGenDudeNewState(actor, &genDudeSearchL);
actor->SetTarget(nullptr);
return;
}
@ -574,8 +576,8 @@ static void unicultThinkChase(DBloodActor* actor)
{
if (!gThingInfoExtra[curWeapon - kThingBase].allowThrow)
{
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW);
else aiGenDudeNewState(pSprite, &genDudeChaseL);
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW);
else aiGenDudeNewState(actor, &genDudeChaseL);
return;
}
@ -587,7 +589,7 @@ static void unicultThinkChase(DBloodActor* actor)
case 4:
return;
default:
aiGenDudeNewState(pSprite, &genDudeThrow);
aiGenDudeNewState(actor, &genDudeThrow);
return;
}
@ -600,7 +602,7 @@ static void unicultThinkChase(DBloodActor* actor)
{
if (pLeech == NULL)
{
aiGenDudeNewState(pSprite, &genDudeThrow2);
aiGenDudeNewState(actor, &genDudeThrow2);
genDudeThrow2.nextState = &genDudeDodgeShortL;
return;
}
@ -610,7 +612,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (ldist > 3 || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum,
pLeech->x, pLeech->y, pLeech->z, pLeech->sectnum) || pXLeech->target_i == -1)
{
aiGenDudeNewState(pSprite, &genDudeThrow2);
aiGenDudeNewState(actor, &genDudeThrow2);
genDudeThrow2.nextState = &genDudeDodgeShortL;
}
else
@ -618,23 +620,23 @@ static void unicultThinkChase(DBloodActor* actor)
genDudeThrow2.nextState = &genDudeChaseL;
if (dist > 5072 && Chance(0x5000))
{
if (!canDuck(pSprite) || Chance(0x4000)) aiGenDudeNewState(pSprite, &genDudeDodgeShortL);
else aiGenDudeNewState(pSprite, &genDudeDodgeShortD);
if (!canDuck(pSprite) || Chance(0x4000)) aiGenDudeNewState(actor, &genDudeDodgeShortL);
else aiGenDudeNewState(actor, &genDudeDodgeShortD);
}
else
{
aiGenDudeNewState(pSprite, &genDudeChaseL);
aiGenDudeNewState(actor, &genDudeChaseL);
}
}
}
return;
case kModernThingThrowableRock:
if (Chance(0x4000)) aiGenDudeNewState(pSprite, &genDudeThrow2);
if (Chance(0x4000)) aiGenDudeNewState(actor, &genDudeThrow2);
else playGenDudeSound(pSprite, kGenDudeSndTargetSpot);
return;
default:
aiGenDudeNewState(pSprite, &genDudeThrow2);
aiGenDudeNewState(actor, &genDudeThrow2);
return;
}
@ -643,25 +645,24 @@ static void unicultThinkChase(DBloodActor* actor)
if (spriteIsUnderwater(pSprite, false))
{
if (Chance(0x9000)) aiGenDudeNewState(pSprite, &genDudePunch);
else aiGenDudeNewState(pSprite, &genDudeDodgeW);
if (Chance(0x9000)) aiGenDudeNewState(actor, &genDudePunch);
else aiGenDudeNewState(actor, &genDudeDodgeW);
}
else if (Chance(0x9000)) aiGenDudeNewState(pSprite, &genDudePunch);
else aiGenDudeNewState(pSprite, &genDudeDodgeL);
else if (Chance(0x9000)) aiGenDudeNewState(actor, &genDudePunch);
else aiGenDudeNewState(actor, &genDudeDodgeL);
return;
}
else
{
int state = checkAttackState(&bloodActors[pXSprite->reference]);
if (state == 1) aiGenDudeNewState(pSprite, &genDudeChaseW);
if (state == 1) aiGenDudeNewState(actor, &genDudeChaseW);
else if (state == 2)
{
if (Chance(0x5000)) aiGenDudeNewState(pSprite, &genDudeChaseD);
else aiGenDudeNewState(pSprite, &genDudeChaseL);
if (Chance(0x5000)) aiGenDudeNewState(actor, &genDudeChaseD);
else aiGenDudeNewState(actor, &genDudeChaseL);
}
else aiGenDudeNewState(pSprite, &genDudeChaseL);
else aiGenDudeNewState(actor, &genDudeChaseL);
return;
}
}
@ -689,15 +690,15 @@ static void unicultThinkChase(DBloodActor* actor)
{
if (dist <= meleeVector->maxDist)
{
aiGenDudeNewState(pSprite, &genDudePunch);
aiGenDudeNewState(actor, &genDudePunch);
return;
}
else
{
int state = checkAttackState(&bloodActors[pXSprite->reference]);
if (state == 1) aiGenDudeNewState(pSprite, &genDudeChaseW);
else if (state == 2) aiGenDudeNewState(pSprite, &genDudeChaseD);
else aiGenDudeNewState(pSprite, &genDudeChaseL);
int state = checkAttackState(actor);
if (state == 1) aiGenDudeNewState(actor, &genDudeChaseW);
else if (state == 2) aiGenDudeNewState(actor, &genDudeChaseD);
else aiGenDudeNewState(actor, &genDudeChaseL);
return;
}
}
@ -724,25 +725,25 @@ static void unicultThinkChase(DBloodActor* actor)
if (mdist == defDist) mdist = 3000;
if (dist > mdist || pXSprite->locked == 1) break;
else if (dist <= meleeVector->maxDist && Chance(0x9000))
aiGenDudeNewState(pSprite, &genDudePunch);
else if (state == 1) aiGenDudeNewState(pSprite, &genDudeChaseW);
else if (state == 2) aiGenDudeNewState(pSprite, &genDudeChaseD);
else aiGenDudeNewState(pSprite, &genDudeChaseL);
aiGenDudeNewState(actor, &genDudePunch);
else if (state == 1) aiGenDudeNewState(actor, &genDudeChaseW);
else if (state == 2) aiGenDudeNewState(actor, &genDudeChaseD);
else aiGenDudeNewState(actor, &genDudeChaseL);
return;
case kMissileFlameSpray:
case kMissileFlameHound:
//viewSetSystemMessage("%d", pXTarget->burnTime);
if (spriteIsUnderwater(pSprite, false))
{
if (dist > meleeVector->maxDist) aiGenDudeNewState(pSprite, &genDudeChaseW);
else if (Chance(0x8000)) aiGenDudeNewState(pSprite, &genDudePunch);
else aiGenDudeNewState(pSprite, &genDudeDodgeShortW);
if (dist > meleeVector->maxDist) aiGenDudeNewState(actor, &genDudeChaseW);
else if (Chance(0x8000)) aiGenDudeNewState(actor, &genDudePunch);
else aiGenDudeNewState(actor, &genDudeDodgeShortW);
return;
}
else if (dist <= 4000 && pXTarget->burnTime >= 2000 && pXTarget->burnSource == pSprite->index)
{
if (dist > meleeVector->maxDist) aiGenDudeNewState(pSprite, &genDudeChaseL);
else aiGenDudeNewState(pSprite, &genDudePunch);
if (dist > meleeVector->maxDist) aiGenDudeNewState(actor, &genDudeChaseL);
else aiGenDudeNewState(actor, &genDudePunch);
return;
}
vdist = 3500 + (gGameOptions.nDifficulty * 400);
@ -760,7 +761,7 @@ static void unicultThinkChase(DBloodActor* actor)
return;
}
int state = checkAttackState(&bloodActors[pXSprite->reference]);
int state = checkAttackState(actor);
int kAngle = (dudeIsMelee(pXSprite) || dist <= kGenDudeMaxMeleeDist) ? pDudeInfo->periphery : kGenDudeKlabsAng;
if (dist < vdist && abs(losAngle) < kAngle)
@ -821,8 +822,8 @@ 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(pSprite, &genDudeChaseW);
else aiGenDudeNewState(pSprite, &genDudeChaseL);
else if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW);
else aiGenDudeNewState(actor, &genDudeChaseL);
return;
case 3:
if (pHSprite->statnum == kStatFX || pHSprite->statnum == kStatProjectile || pHSprite->statnum == kStatDebris)
@ -834,13 +835,13 @@ static void unicultThinkChase(DBloodActor* actor)
{
if (pExtra->baseDispersion < 1024 && weaponType != kGenDudeWeaponMissile)
{
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeDodgeShorterW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(pSprite, &genDudeDodgeShorterD);
else aiGenDudeNewState(pSprite, &genDudeDodgeShorterL);
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeDodgeShorterW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeDodgeShorterD);
else aiGenDudeNewState(actor, &genDudeDodgeShorterL);
}
else if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeDodgeShortW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(pSprite, &genDudeDodgeShortD);
else aiGenDudeNewState(pSprite, &genDudeDodgeShortL);
else if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeDodgeShortW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeDodgeShortD);
else aiGenDudeNewState(actor, &genDudeDodgeShortL);
switch (pHSprite->type)
{
@ -849,9 +850,9 @@ static void unicultThinkChase(DBloodActor* actor)
{
if (!inAttack(pXHSprite->aiState))
{
if (spriteIsUnderwater(pHSprite)) aiGenDudeNewState(pHSprite, &genDudeDodgeShorterW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(pHSprite, &genDudeDodgeShorterD);
else aiGenDudeNewState(pHSprite, &genDudeDodgeShorterL);
if (spriteIsUnderwater(pHSprite)) aiGenDudeNewState(hitactor, &genDudeDodgeShorterW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(hitactor, &genDudeDodgeShorterD);
else aiGenDudeNewState(hitactor, &genDudeDodgeShorterL);
// preferable in opposite sides
if (Chance(0x8000))
@ -903,8 +904,8 @@ static void unicultThinkChase(DBloodActor* actor)
|| (dist <= (int)(pExtra->fireDist / ClipLow(Random(4), 1))))
{
//viewSetSystemMessage("GO CHASE");
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW);
else aiGenDudeNewState(pSprite, &genDudeChaseL);
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW);
else aiGenDudeNewState(actor, &genDudeChaseL);
return;
}
@ -914,9 +915,9 @@ static void unicultThinkChase(DBloodActor* actor)
if (wd1 < (wd2 << 3))
{
//viewSetSystemMessage("OBJ SIZE: %d DUDE SIZE: %d", wd1, wd2);
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeDodgeShorterW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(pSprite, &genDudeDodgeShorterD);
else aiGenDudeNewState(pSprite, &genDudeDodgeShorterL);
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeDodgeShorterW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeDodgeShorterD);
else aiGenDudeNewState(actor, &genDudeDodgeShorterL);
if (pSprite->x < pHSprite->x)
{
@ -931,8 +932,8 @@ static void unicultThinkChase(DBloodActor* actor)
if (((gSpriteHit[pSprite->extra].hit & 0xc000) == 0x8000) || ((gSpriteHit[pSprite->extra].hit & 0xc000) == 0xc000))
{
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW);
else aiGenDudeNewState(pSprite, &genDudeChaseL);
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW);
else aiGenDudeNewState(actor, &genDudeChaseL);
pXSprite->goalAng = Random(kAng360);
//viewSetSystemMessage("WALL OR SPRITE TOUCH");
}
@ -940,8 +941,8 @@ static void unicultThinkChase(DBloodActor* actor)
}
else
{
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW);
else aiGenDudeNewState(pSprite, &genDudeChaseL);
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW);
else aiGenDudeNewState(actor, &genDudeChaseL);
//viewSetSystemMessage("TOO BIG OBJECT TO DODGE!!!!!!!!");
}
return;
@ -958,8 +959,8 @@ 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(pSprite, &genDudeChaseW);
else aiGenDudeNewState(pSprite, &genDudeChaseL);
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW);
else aiGenDudeNewState(actor, &genDudeChaseL);
return;
}
}
@ -980,8 +981,8 @@ static void unicultThinkChase(DBloodActor* actor)
if (dudeDist < mdist)
{
//viewSetSystemMessage("DUDE CLOSE TO OBJ: %d, MDIST: %d", dudeDist, mdist);
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW);
else aiGenDudeNewState(pSprite, &genDudeChaseL);
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeChaseW);
else aiGenDudeNewState(actor, &genDudeChaseL);
return;
}
else if (targetDist <= mdist >> 1)
@ -1006,8 +1007,8 @@ static void unicultThinkChase(DBloodActor* actor)
if (failed)
{
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeSearchW);
else aiGenDudeNewState(pSprite, &genDudeSearchL);
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(actor, &genDudeSearchW);
else aiGenDudeNewState(actor, &genDudeSearchL);
return;
}
break;
@ -1022,15 +1023,15 @@ static void unicultThinkChase(DBloodActor* actor)
switch (state)
{
case 1:
aiGenDudeNewState(pSprite, &genDudeFireW);
aiGenDudeNewState(actor, &genDudeFireW);
pXSprite->aiState->nextState = &genDudeFireW;
break;
case 2:
aiGenDudeNewState(pSprite, &genDudeFireD);
aiGenDudeNewState(actor, &genDudeFireD);
pXSprite->aiState->nextState = &genDudeFireD;
break;
default:
aiGenDudeNewState(pSprite, &genDudeFireL);
aiGenDudeNewState(actor, &genDudeFireL);
pXSprite->aiState->nextState = &genDudeFireL;
break;
}
@ -1046,19 +1047,19 @@ static void unicultThinkChase(DBloodActor* actor)
}
else if (state == 1 && pXSprite->aiState != &genDudeChaseW && pXSprite->aiState != &genDudeFireW)
{
aiGenDudeNewState(pSprite, &genDudeChaseW);
aiGenDudeNewState(actor, &genDudeChaseW);
pXSprite->aiState->nextState = &genDudeFireW;
}
else if (state == 2 && pXSprite->aiState != &genDudeChaseD && pXSprite->aiState != &genDudeFireD)
{
aiGenDudeNewState(pSprite, &genDudeChaseD);
aiGenDudeNewState(actor, &genDudeChaseD);
pXSprite->aiState->nextState = &genDudeFireD;
}
else if (pXSprite->aiState != &genDudeChaseL && pXSprite->aiState != &genDudeFireL)
{
aiGenDudeNewState(pSprite, &genDudeChaseL);
aiGenDudeNewState(actor, &genDudeChaseL);
pXSprite->aiState->nextState = &genDudeFireL;
}
}
@ -1241,14 +1242,15 @@ void aiGenDudeChooseDirection(spritetype* pSprite, XSPRITE* pXSprite, int a3, in
//
//---------------------------------------------------------------------------
void aiGenDudeNewState(spritetype* pSprite, AISTATE* pAIState) {
if (!xspriRangeIsFine(pSprite->extra)) {
Printf(PRINT_HIGH, "!xspriRangeIsFine(pSprite->extra)");
void aiGenDudeNewState(DBloodActor* actor, AISTATE* pAIState)
{
if (!actor->hasX())
{
return;
}
auto actor = &bloodActors[pSprite->index];
XSPRITE* pXSprite = &xsprite[pSprite->extra];
auto const pSprite = &actor->s();
auto const pXSprite = &actor->x();
// redirect dudes which cannot walk to non-walk states
if (!actor->genDudeExtra().canWalk)
@ -2164,6 +2166,7 @@ bool genDudePrepare(spritetype* pSprite, int propId) {
return false;
}
auto actor = &bloodActors[pSprite->index];
XSPRITE* pXSprite = &xsprite[pSprite->extra];
GENDUDEEXTRA* pExtra = &gGenDudeExtra[pSprite->index]; pExtra->updReq[propId] = false;
@ -2282,20 +2285,20 @@ bool genDudePrepare(spritetype* pSprite, int propId) {
if (oldStatus != pExtra->canWalk) {
if (!spriRangeIsFine(pXSprite->target_i))
{
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeIdleW);
else aiGenDudeNewState(pSprite, &genDudeIdleL);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeIdleW);
else aiGenDudeNewState(actor, &genDudeIdleL);
}
else if (pExtra->canWalk)
{
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeChaseW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(pSprite, &genDudeChaseD);
else aiGenDudeNewState(pSprite, &genDudeChaseL);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeChaseW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeChaseD);
else aiGenDudeNewState(actor, &genDudeChaseL);
}
else
{
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeChaseNoWalkW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(pSprite, &genDudeChaseNoWalkD);
else aiGenDudeNewState(pSprite, &genDudeChaseNoWalkL);
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(actor, &genDudeChaseNoWalkW);
else if (inDuck(pXSprite->aiState)) aiGenDudeNewState(actor, &genDudeChaseNoWalkD);
else aiGenDudeNewState(actor, &genDudeChaseNoWalkL);
}
}
break;
@ -2415,11 +2418,11 @@ void aiGenDudeInitSprite(spritetype* pSprite, XSPRITE* pXSprite)
case kDudeModernCustom: {
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->active = 0;
aiGenDudeNewState(pSprite, &genDudeIdleL);
aiGenDudeNewState(actor, &genDudeIdleL);
break;
}
case kDudeModernCustomBurning:
aiGenDudeNewState(pSprite, &genDudeBurnGoto);
aiGenDudeNewState(actor, &genDudeBurnGoto);
pXSprite->burnTime = 1200;
break;
}

View file

@ -204,7 +204,7 @@ bool spriteIsUnderwater(spritetype* pSprite, bool oldWay = false);
bool playGenDudeSound(spritetype* pSprite, int mode);
void aiGenDudeMoveForward(DBloodActor* actor);
void aiGenDudeChooseDirection(spritetype* pSprite, XSPRITE* pXSprite, int a3, int aXvel = -1, int aYvel = -1);
void aiGenDudeNewState(spritetype* pSprite, AISTATE* pAIState);
void aiGenDudeNewState(DBloodActor* actor, AISTATE* pAIState);
int getGenDudeMoveSpeed(spritetype* pSprite, int which, bool mul, bool shift);
int checkAttackState(DBloodActor* actor);
bool doExplosion(spritetype* pSprite, int nType);

View file

@ -1779,7 +1779,7 @@ void aiSetGenIdleState(spritetype* pSprite, XSPRITE* pXSprite)
switch (pSprite->type) {
case kDudeModernCustom:
case kDudeModernCustomBurning:
aiGenDudeNewState(pSprite, &genIdle);
aiGenDudeNewState(actor, &genIdle);
break;
default:
aiNewState(actor, &genIdle);
@ -6594,7 +6594,7 @@ void aiPatrolState(spritetype* pSprite, int state) {
if (newState->stateType != state || (!nSeqOverride && seq != newState->seqId))
continue;
if (pSprite->type == kDudeModernCustom) aiGenDudeNewState(pSprite, newState);
if (pSprite->type == kDudeModernCustom) aiGenDudeNewState(actor, newState);
else aiNewState(&bloodActors[pXSprite->reference], newState);
if (crouch) pXSprite->unused1 |= kDudeFlagCrouch;