- another formatting-only commit.

# Conflicts:
#	source/games/blood/src/ai.cpp
This commit is contained in:
Christoph Oelckers 2021-09-16 20:43:58 +02:00
parent fe92188b0c
commit 6968a072ae

View file

@ -963,7 +963,7 @@ void aiSetTarget(DBloodActor* actor, DBloodActor* target)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// // todo: split up and put most of its content in tables.
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1032,8 +1032,8 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
return nDamage; return nDamage;
} }
if (pSprite->type == kDudeModernCustomBurning) { if (pSprite->type == kDudeModernCustomBurning)
{
if (Chance(0x2000) && actor->dudeExtra.time < PlayClock) { if (Chance(0x2000) && actor->dudeExtra.time < PlayClock) {
playGenDudeSound(pSprite, kGenDudeSndBurning); playGenDudeSound(pSprite, kGenDudeSndBurning);
actor->dudeExtra.time = PlayClock + 360; actor->dudeExtra.time = PlayClock + 360;
@ -1255,50 +1255,63 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
return nDamage; return nDamage;
} }
//---------------------------------------------------------------------------
//
// todo: split up and put most of its content in tables.
//
//---------------------------------------------------------------------------
void RecoilDude(DBloodActor* actor) void RecoilDude(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
char v4 = Chance(0x8000); char v4 = Chance(0x8000);
DUDEEXTRA *pDudeExtra = &actor->dudeExtra; DUDEEXTRA* pDudeExtra = &actor->dudeExtra;
if (pSprite->statnum == kStatDude && (pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { if (pSprite->statnum == kStatDude && (pSprite->type >= kDudeBase && pSprite->type < kDudeMax))
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); {
switch (pSprite->type) { DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
switch (pSprite->type)
{
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
case kDudeModernCustom: { case kDudeModernCustom:
{
GENDUDEEXTRA* pExtra = genDudeExtra(pSprite); int rChance = getRecoilChance(pSprite); GENDUDEEXTRA* pExtra = genDudeExtra(pSprite); int rChance = getRecoilChance(pSprite);
if (pExtra->canElectrocute && pDudeExtra->teslaHit && !spriteIsUnderwater(pSprite, false)) { if (pExtra->canElectrocute && pDudeExtra->teslaHit && !spriteIsUnderwater(pSprite, false))
{
if (Chance(rChance << 3) || (dudeIsMelee(pXSprite) && Chance(rChance << 4))) aiGenDudeNewState(pSprite, &genDudeRecoilTesla); if (Chance(rChance << 3) || (dudeIsMelee(pXSprite) && Chance(rChance << 4))) aiGenDudeNewState(pSprite, &genDudeRecoilTesla);
else if (pExtra->canRecoil && Chance(rChance)) aiGenDudeNewState(pSprite, &genDudeRecoilL); else if (pExtra->canRecoil && Chance(rChance)) aiGenDudeNewState(pSprite, &genDudeRecoilL);
else if (canWalk(pSprite)) { else if (canWalk(pSprite))
{
if (Chance(rChance >> 2)) aiGenDudeNewState(pSprite, &genDudeDodgeL); if (Chance(rChance >> 2)) aiGenDudeNewState(pSprite, &genDudeDodgeL);
else if (Chance(rChance >> 1)) aiGenDudeNewState(pSprite, &genDudeDodgeShortL); else if (Chance(rChance >> 1)) aiGenDudeNewState(pSprite, &genDudeDodgeShortL);
} }
} else if (pExtra->canRecoil && Chance(rChance)) { }
else if (pExtra->canRecoil && Chance(rChance))
{
if (inDuck(pXSprite->aiState) && Chance(rChance >> 2)) aiGenDudeNewState(pSprite, &genDudeRecoilD); if (inDuck(pXSprite->aiState) && Chance(rChance >> 2)) aiGenDudeNewState(pSprite, &genDudeRecoilD);
else if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeRecoilW); else if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeRecoilW);
else aiGenDudeNewState(pSprite, &genDudeRecoilL); else aiGenDudeNewState(pSprite, &genDudeRecoilL);
}
}
short rState = inRecoil(pXSprite->aiState); short rState = inRecoil(pXSprite->aiState);
if (rState > 0) { if (rState > 0)
{
if (!canWalk(pSprite)) { if (!canWalk(pSprite))
{
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;
else pXSprite->aiState->nextState = &genDudeChaseNoWalkW; else pXSprite->aiState->nextState = &genDudeChaseNoWalkW;
} else if (!dudeIsMelee(pXSprite) || Chance(rChance >> 2)) { }
else if (!dudeIsMelee(pXSprite) || Chance(rChance >> 2))
{
if (rState == 1) pXSprite->aiState->nextState = (Chance(rChance) ? &genDudeDodgeL : &genDudeDodgeShortL); if (rState == 1) pXSprite->aiState->nextState = (Chance(rChance) ? &genDudeDodgeL : &genDudeDodgeShortL);
else if (rState == 2) pXSprite->aiState->nextState = (Chance(rChance) ? &genDudeDodgeD : &genDudeDodgeShortD); else if (rState == 2) pXSprite->aiState->nextState = (Chance(rChance) ? &genDudeDodgeD : &genDudeDodgeShortD);
else if (rState == 3) pXSprite->aiState->nextState = (Chance(rChance) ? &genDudeDodgeW : &genDudeDodgeShortW); else if (rState == 3) pXSprite->aiState->nextState = (Chance(rChance) ? &genDudeDodgeW : &genDudeDodgeShortW);
} }
else if (rState == 1) pXSprite->aiState->nextState = &genDudeChaseL; else if (rState == 1) pXSprite->aiState->nextState = &genDudeChaseL;
else if (rState == 2) pXSprite->aiState->nextState = &genDudeChaseD; else if (rState == 2) pXSprite->aiState->nextState = &genDudeChaseD;
@ -1317,14 +1330,17 @@ void RecoilDude(DBloodActor* actor)
case kDudeCultistTesla: case kDudeCultistTesla:
case kDudeCultistTNT: case kDudeCultistTNT:
case kDudeCultistBeast: case kDudeCultistBeast:
if (pSprite->type == kDudeCultistTommy) aiPlay3DSound(actor, 4013+Random(2), AI_SFX_PRIORITY_2, -1); if (pSprite->type == kDudeCultistTommy) aiPlay3DSound(actor, 4013 + Random(2), AI_SFX_PRIORITY_2, -1);
else aiPlay3DSound(actor, 1013+Random(2), AI_SFX_PRIORITY_2, -1); else aiPlay3DSound(actor, 1013 + Random(2), AI_SFX_PRIORITY_2, -1);
if (!v4 && pXSprite->medium == kMediumNormal) { if (!v4 && pXSprite->medium == kMediumNormal)
{
if (pDudeExtra->teslaHit) aiNewState(actor, &cultistTeslaRecoil); if (pDudeExtra->teslaHit) aiNewState(actor, &cultistTeslaRecoil);
else aiNewState(actor, &cultistRecoil); else aiNewState(actor, &cultistRecoil);
} else if (v4 && pXSprite->medium == kMediumNormal) { }
else if (v4 && pXSprite->medium == kMediumNormal)
{
if (pDudeExtra->teslaHit) aiNewState(actor, &cultistTeslaRecoil); if (pDudeExtra->teslaHit) aiNewState(actor, &cultistTeslaRecoil);
else if (gGameOptions.nDifficulty > 0) aiNewState(actor, &cultistProneRecoil); else if (gGameOptions.nDifficulty > 0) aiNewState(actor, &cultistProneRecoil);
else aiNewState(actor, &cultistRecoil); else aiNewState(actor, &cultistRecoil);
@ -1359,7 +1375,7 @@ void RecoilDude(DBloodActor* actor)
aiPlay3DSound(actor, 1106, AI_SFX_PRIORITY_2, -1); aiPlay3DSound(actor, 1106, AI_SFX_PRIORITY_2, -1);
if (pDudeExtra->teslaHit && pXSprite->data3 > pDudeInfo->startHealth/3) if (pDudeExtra->teslaHit && pXSprite->data3 > pDudeInfo->startHealth/3)
aiNewState(actor, &zombieATeslaRecoil); aiNewState(actor, &zombieATeslaRecoil);
else if (pXSprite->data3 > pDudeInfo->startHealth/3) else if (pXSprite->data3 > pDudeInfo->startHealth / 3)
aiNewState(actor, &zombieARecoil2); aiNewState(actor, &zombieARecoil2);
else else
aiNewState(actor, &zombieARecoil); aiNewState(actor, &zombieARecoil);
@ -1385,7 +1401,7 @@ void RecoilDude(DBloodActor* actor)
aiNewState(actor, &cerberusRecoil); aiNewState(actor, &cerberusRecoil);
break; break;
case kDudeCerberusOneHead: case kDudeCerberusOneHead:
aiPlay3DSound(actor, 2302+Random(2), AI_SFX_PRIORITY_2, -1); aiPlay3DSound(actor, 2302 + Random(2), AI_SFX_PRIORITY_2, -1);
aiNewState(actor, &cerberus2Recoil); aiNewState(actor, &cerberus2Recoil);
break; break;
case kDudeHellHound: case kDudeHellHound:
@ -1396,7 +1412,7 @@ void RecoilDude(DBloodActor* actor)
aiNewState(actor, &houndRecoil); aiNewState(actor, &houndRecoil);
break; break;
case kDudeTchernobog: case kDudeTchernobog:
aiPlay3DSound(actor, 2370+Random(2), AI_SFX_PRIORITY_2, -1); aiPlay3DSound(actor, 2370 + Random(2), AI_SFX_PRIORITY_2, -1);
aiNewState(actor, &tchernobogRecoil); aiNewState(actor, &tchernobogRecoil);
break; break;
case kDudeHand: case kDudeHand:
@ -1416,7 +1432,7 @@ void RecoilDude(DBloodActor* actor)
aiNewState(actor, &eelRecoil); aiNewState(actor, &eelRecoil);
break; break;
case kDudeGillBeast: { case kDudeGillBeast: {
XSECTOR *pXSector = NULL; XSECTOR* pXSector = NULL;
if (sector[pSprite->sectnum].extra > 0) if (sector[pSprite->sectnum].extra > 0)
pXSector = &xsector[sector[pSprite->sectnum].extra]; pXSector = &xsector[sector[pSprite->sectnum].extra];
aiPlay3DSound(actor, 1702, AI_SFX_PRIORITY_2, -1); aiPlay3DSound(actor, 1702, AI_SFX_PRIORITY_2, -1);
@ -1436,15 +1452,15 @@ void RecoilDude(DBloodActor* actor)
case kDudeSpiderBrown: case kDudeSpiderBrown:
case kDudeSpiderRed: case kDudeSpiderRed:
case kDudeSpiderBlack: case kDudeSpiderBlack:
aiPlay3DSound(actor, 1802+Random(1), AI_SFX_PRIORITY_2, -1); aiPlay3DSound(actor, 1802 + Random(1), AI_SFX_PRIORITY_2, -1);
aiNewState(actor, &spidDodge); aiNewState(actor, &spidDodge);
break; break;
case kDudeSpiderMother: case kDudeSpiderMother:
aiPlay3DSound(actor, 1851+Random(1), AI_SFX_PRIORITY_2, -1); aiPlay3DSound(actor, 1851 + Random(1), AI_SFX_PRIORITY_2, -1);
aiNewState(actor, &spidDodge); aiNewState(actor, &spidDodge);
break; break;
case kDudeInnocent: case kDudeInnocent:
aiPlay3DSound(actor, 7007+Random(2), AI_SFX_PRIORITY_2, -1); aiPlay3DSound(actor, 7007 + Random(2), AI_SFX_PRIORITY_2, -1);
if (pDudeExtra->teslaHit) if (pDudeExtra->teslaHit)
aiNewState(actor, &innocentTeslaRecoil); aiNewState(actor, &innocentTeslaRecoil);
else else
@ -1469,7 +1485,7 @@ void RecoilDude(DBloodActor* actor)
} }
break; break;
case kDudeBeast: case kDudeBeast:
aiPlay3DSound(actor, 9004+Random(2), AI_SFX_PRIORITY_2, -1); aiPlay3DSound(actor, 9004 + Random(2), AI_SFX_PRIORITY_2, -1);
if (pXSprite->medium == kMediumNormal) if (pXSprite->medium == kMediumNormal)
{ {
if (pDudeExtra->teslaHit) if (pDudeExtra->teslaHit)
@ -1503,31 +1519,38 @@ void RecoilDude(DBloodActor* actor)
} }
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void aiThinkTarget(DBloodActor* actor) void aiThinkTarget(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (Chance(pDudeInfo->alertChance)) if (Chance(pDudeInfo->alertChance))
{ {
for (int p = connecthead; p >= 0; p = connectpoint2[p]) for (int p = connecthead; p >= 0; p = connectpoint2[p])
{ {
PLAYER *pPlayer = &gPlayer[p]; PLAYER* pPlayer = &gPlayer[p];
if (pSprite->owner == pPlayer->nSprite || pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0) if (pSprite->owner == pPlayer->nSprite || pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue; continue;
int x = pPlayer->pSprite->x; int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y; int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z; int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum; int nSector = pPlayer->pSprite->sectnum;
int dx = x-pSprite->x; int dx = x - pSprite->x;
int dy = y-pSprite->y; int dy = y - pSprite->y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue; continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum)) if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
continue; continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(actor, pPlayer->actor()); aiSetTarget(actor, pPlayer->actor());
@ -1544,30 +1567,36 @@ void aiThinkTarget(DBloodActor* actor)
} }
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void aiLookForTarget(spritetype *pSprite, XSPRITE *pXSprite) void aiLookForTarget(spritetype *pSprite, XSPRITE *pXSprite)
{ {
auto actor = &bloodActors[pSprite->index]; auto actor = &bloodActors[pSprite->index];
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax); assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
if (Chance(pDudeInfo->alertChance)) if (Chance(pDudeInfo->alertChance))
{ {
for (int p = connecthead; p >= 0; p = connectpoint2[p]) for (int p = connecthead; p >= 0; p = connectpoint2[p])
{ {
PLAYER *pPlayer = &gPlayer[p]; PLAYER* pPlayer = &gPlayer[p];
if (pSprite->owner == pPlayer->nSprite || pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0) if (pSprite->owner == pPlayer->nSprite || pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
continue; continue;
int x = pPlayer->pSprite->x; int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y; int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z; int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum; int nSector = pPlayer->pSprite->sectnum;
int dx = x-pSprite->x; int dx = x - pSprite->x;
int dy = y-pSprite->y; int dy = y - pSprite->y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue; continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum)) if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
continue; continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(actor, pPlayer->actor()); aiSetTarget(actor, pPlayer->actor());
@ -1591,12 +1620,12 @@ void aiLookForTarget(spritetype *pSprite, XSPRITE *pXSprite)
while (DBloodActor* actor2 = it.Next()) while (DBloodActor* actor2 = it.Next())
{ {
spritetype* pSprite2 = &actor2->s(); spritetype* pSprite2 = &actor2->s();
int dx = pSprite2->x-pSprite->x; int dx = pSprite2->x - pSprite->x;
int dy = pSprite2->y-pSprite->y; int dy = pSprite2->y - pSprite->y;
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
if (pSprite2->type == kDudeInnocent) if (pSprite2->type == kDudeInnocent)
{ {
DUDEINFO *pDudeInfo = getDudeInfo(pSprite2->type); DUDEINFO* pDudeInfo = getDudeInfo(pSprite2->type);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist) if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue; continue;
aiSetTarget(actor, actor2); aiSetTarget(actor, actor2);
@ -1608,7 +1637,14 @@ void aiLookForTarget(spritetype *pSprite, XSPRITE *pXSprite)
} }
} }
void aiProcessDudes(void) { //---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void aiProcessDudes(void)
{
int nSprite; int nSprite;
StatIterator it(kStatDude); StatIterator it(kStatDude);
while ((nSprite = it.NextIndex()) >= 0) while ((nSprite = it.NextIndex()) >= 0)