2019-09-19 22:42:45 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
|
|
|
|
|
|
|
This file is part of NBlood.
|
|
|
|
|
|
|
|
NBlood is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-09-21 18:59:54 +00:00
|
|
|
|
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "build.h"
|
|
|
|
|
|
|
|
#include "blood.h"
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2021-09-16 19:59:39 +00:00
|
|
|
static void cultThinkSearch(DBloodActor*);
|
|
|
|
static void cultThinkGoto(DBloodActor*);
|
|
|
|
static void cultThinkChase(DBloodActor*);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
AISTATE cultistIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
|
|
|
|
AISTATE cultistProneIdle = { kAiStateIdle, 17, -1, 0, NULL, NULL, aiThinkTarget, NULL };
|
|
|
|
AISTATE fanaticProneIdle = { kAiStateIdle, 17, -1, 0, NULL, NULL, aiThinkTarget, NULL };
|
|
|
|
AISTATE cultistProneIdle3 = { kAiStateIdle, 17, -1, 0, NULL, NULL, aiThinkTarget, NULL };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE cultistChase = { kAiStateChase, 9, -1, 0, NULL, aiMoveForward, cultThinkChase, NULL };
|
|
|
|
AISTATE fanaticChase = { kAiStateChase, 0, -1, 0, NULL, aiMoveTurn, cultThinkChase, NULL };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE cultistDodge = { kAiStateMove, 9, -1, 90, NULL, aiMoveDodge, NULL, &cultistChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE cultistGoto = { kAiStateMove, 9, -1, 600, NULL, aiMoveForward, cultThinkGoto, &cultistIdle };
|
|
|
|
AISTATE cultistProneChase = { kAiStateChase, 14, -1, 0, NULL, aiMoveForward, cultThinkChase, NULL };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE cultistProneDodge = { kAiStateMove, 14, -1, 90, NULL, aiMoveDodge, NULL, &cultistProneChase };
|
|
|
|
AISTATE cultistTThrow = { kAiStateChase, 7, nThrowClient, 120, NULL, NULL, NULL, &cultistTFire };
|
|
|
|
AISTATE cultistSThrow = { kAiStateChase, 7, nThrowClient, 120, NULL, NULL, NULL, &cultistSFire };
|
|
|
|
AISTATE cultistTsThrow = { kAiStateChase, 7, nThrowClient, 120, NULL, NULL, NULL, &cultistTsFire };
|
|
|
|
AISTATE cultistDThrow = { kAiStateChase, 7, nThrowClient, 120, NULL, NULL, NULL, &cultistChase };
|
|
|
|
AISTATE cultist139A78 = { kAiStateChase, 7, n68170Client, 120, NULL, NULL, NULL, &cultistChase };
|
|
|
|
AISTATE cultist139A94 = { kAiStateChase, 7, n68230Client, 120, NULL, NULL, NULL, &cultistIdle };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE cultist139AB0 = { kAiStateChase, 7, n68230Client, 120, NULL, NULL, cultThinkSearch, &cultist139A94 };
|
|
|
|
AISTATE cultist139ACC = { kAiStateChase, 7, n68230Client, 120, NULL, NULL, cultThinkSearch, &cultist139AB0 };
|
|
|
|
AISTATE cultist139AE8 = { kAiStateChase, 7, n68230Client, 120, NULL, NULL, cultThinkSearch, &cultist139AE8 };
|
|
|
|
AISTATE cultistSearch = { kAiStateSearch, 9, -1, 1800, NULL, aiMoveForward, cultThinkSearch, &cultistIdle };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE cultistSFire = { kAiStateChase, 6, nShotClient, 60, NULL, NULL, NULL, &cultistChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE cultistTFire = { kAiStateChase, 6, nTommyClient, 0, NULL, aiMoveTurn, cultThinkChase, &cultistTFire };
|
|
|
|
AISTATE cultistTsFire = { kAiStateChase, 6, nTeslaClient, 0, NULL, aiMoveTurn, cultThinkChase, &cultistChase };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE cultistSProneFire = { kAiStateChase, 8, nShotClient, 60, NULL, NULL, NULL, &cultistProneChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE cultistTProneFire = { kAiStateChase, 8, nTommyClient, 0, NULL, aiMoveTurn, cultThinkChase, &cultistTProneFire };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE cultistTsProneFire = { kAiStateChase, 8, nTeslaClient, 0, NULL, aiMoveTurn, NULL, &cultistTsProneFire };
|
|
|
|
AISTATE cultistRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &cultistDodge };
|
|
|
|
AISTATE cultistProneRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &cultistProneDodge };
|
|
|
|
AISTATE cultistTeslaRecoil = { kAiStateRecoil, 4, -1, 0, NULL, NULL, NULL, &cultistDodge };
|
|
|
|
AISTATE cultistSwimIdle = { kAiStateIdle, 13, -1, 0, NULL, NULL, aiThinkTarget, NULL };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE cultistSwimChase = { kAiStateChase, 13, -1, 0, NULL, aiMoveForward, cultThinkChase, NULL };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE cultistSwimDodge = { kAiStateMove, 13, -1, 90, NULL, aiMoveDodge, NULL, &cultistSwimChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE cultistSwimGoto = { kAiStateMove, 13, -1, 600, NULL, aiMoveForward, cultThinkGoto, &cultistSwimIdle };
|
|
|
|
AISTATE cultistSwimSearch = { kAiStateSearch, 13, -1, 1800, NULL, aiMoveForward, cultThinkSearch, &cultistSwimIdle };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE cultistSSwimFire = { kAiStateChase, 8, nShotClient, 60, NULL, NULL, NULL, &cultistSwimChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE cultistTSwimFire = { kAiStateChase, 8, nTommyClient, 0, NULL, aiMoveTurn, cultThinkChase, &cultistTSwimFire };
|
|
|
|
AISTATE cultistTsSwimFire = { kAiStateChase, 8, nTeslaClient, 0, NULL, aiMoveTurn, cultThinkChase, &cultistTsSwimFire };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE cultistSwimRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &cultistSwimDodge };
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void TommySeqCallback(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
spritetype* pSprite = &actor->s();
|
2021-10-30 06:22:27 +00:00
|
|
|
int dx = bcos(pSprite->ang);
|
2021-10-30 06:22:17 +00:00
|
|
|
int dy = bsin(pSprite->ang);
|
2021-09-16 19:59:39 +00:00
|
|
|
int dz = actor->dudeSlope;
|
|
|
|
dx += Random3((5 - gGameOptions.nDifficulty) * 1000);
|
|
|
|
dy += Random3((5 - gGameOptions.nDifficulty) * 1000);
|
|
|
|
dz += Random3((5 - gGameOptions.nDifficulty) * 500);
|
|
|
|
actFireVector(actor, 0, 0, dx, dy, dz, kVectorBullet);
|
|
|
|
sfxPlay3DSound(actor, 4001, -1, 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void TeslaSeqCallback(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
spritetype* pSprite = &actor->s();
|
|
|
|
if (Chance(dword_138BB0[gGameOptions.nDifficulty]))
|
|
|
|
{
|
2021-10-30 06:22:27 +00:00
|
|
|
int dx = bcos(pSprite->ang);
|
2021-10-30 06:22:17 +00:00
|
|
|
int dy = bsin(pSprite->ang);
|
2021-09-16 19:59:39 +00:00
|
|
|
int dz = actor->dudeSlope;
|
|
|
|
dx += Random3((5 - gGameOptions.nDifficulty) * 1000);
|
|
|
|
dy += Random3((5 - gGameOptions.nDifficulty) * 1000);
|
|
|
|
dz += Random3((5 - gGameOptions.nDifficulty) * 500);
|
2021-09-04 18:09:56 +00:00
|
|
|
actFireMissile(actor, 0, 0, dx, dy, dz, kMissileTeslaRegular);
|
2021-09-16 19:59:39 +00:00
|
|
|
sfxPlay3DSound(actor, 470, -1, 0);
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void ShotSeqCallback(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
spritetype* pSprite = &actor->s();
|
2021-10-30 06:22:27 +00:00
|
|
|
int dx = bcos(pSprite->ang);
|
2021-10-30 06:22:17 +00:00
|
|
|
int dy = bsin(pSprite->ang);
|
2021-09-16 19:59:39 +00:00
|
|
|
int dz = actor->dudeSlope;
|
|
|
|
dx += Random2((5 - gGameOptions.nDifficulty) * 1000 - 500);
|
|
|
|
dy += Random2((5 - gGameOptions.nDifficulty) * 1000 - 500);
|
|
|
|
dz += Random2((5 - gGameOptions.nDifficulty) * 500);
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
int r1 = Random3(500);
|
|
|
|
int r2 = Random3(1000);
|
|
|
|
int r3 = Random3(1000);
|
|
|
|
actFireVector(actor, 0, 0, dx + r3, dy + r2, dz + r1, kVectorShell);
|
|
|
|
}
|
|
|
|
if (Chance(0x8000))
|
|
|
|
sfxPlay3DSound(actor, 1001, -1, 0);
|
|
|
|
else
|
|
|
|
sfxPlay3DSound(actor, 1002, -1, 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void cultThrowSeqCallback(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
spritetype* pSprite = &actor->s();
|
|
|
|
int nMissile = kThingArmedTNTStick;
|
|
|
|
if (gGameOptions.nDifficulty > 2)
|
|
|
|
nMissile = kThingArmedTNTBundle;
|
2021-11-16 17:30:23 +00:00
|
|
|
uint8_t v4 = Chance(0x6000);
|
2021-09-16 19:59:39 +00:00
|
|
|
sfxPlay3DSound(actor, 455, -1, 0);
|
|
|
|
if (!actor->ValidateTarget(__FUNCTION__)) return;
|
|
|
|
spritetype* pTarget = &actor->GetTarget()->s();
|
|
|
|
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
|
2021-12-22 10:57:10 +00:00
|
|
|
int dx = pTarget->pos.X - pSprite->pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
int dy = pTarget->pos.Y - pSprite->pos.Y;
|
2021-12-22 11:29:00 +00:00
|
|
|
int dz = pTarget->pos.Z - pSprite->pos.Z;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
int nDist2 = nDist / 540;
|
|
|
|
if (nDist > 0x1e00)
|
|
|
|
v4 = 0;
|
|
|
|
auto* pMissile = actFireThing(actor, 0, 0, dz / 128 - 14500, nMissile, (nDist2 << 23) / 120);
|
|
|
|
if (v4)
|
|
|
|
pMissile->x().Impact = 1;
|
|
|
|
else
|
2021-08-27 07:44:47 +00:00
|
|
|
evPostActor(pMissile, 120 * (1 + Random(2)), kCmdOn);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void sub_68170(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
int nMissile = kThingArmedTNTStick;
|
|
|
|
if (gGameOptions.nDifficulty > 2)
|
|
|
|
nMissile = kThingArmedTNTBundle;
|
|
|
|
sfxPlay3DSound(actor, 455, -1, 0);
|
|
|
|
auto pMissile = actFireThing(actor, 0, 0, actor->dudeSlope - 9460, nMissile, 0x133333);
|
2021-08-27 07:44:47 +00:00
|
|
|
evPostActor(pMissile, 120 * (2 + Random(2)), kCmdOn);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void sub_68230(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
spritetype* pSprite = &actor->s();
|
|
|
|
int nMissile = kThingArmedTNTStick;
|
|
|
|
if (gGameOptions.nDifficulty > 2)
|
|
|
|
nMissile = kThingArmedTNTBundle;
|
|
|
|
sfxPlay3DSound(actor, 455, -1, 0);
|
|
|
|
if (!actor->ValidateTarget(__FUNCTION__)) return;
|
|
|
|
spritetype* pTarget = &actor->GetTarget()->s();
|
|
|
|
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
|
2021-12-22 10:57:10 +00:00
|
|
|
int dx = pTarget->pos.X - pSprite->pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
int dy = pTarget->pos.Y - pSprite->pos.Y;
|
2021-12-22 11:29:00 +00:00
|
|
|
int dz = pTarget->pos.Z - pSprite->pos.Z;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
int nDist2 = nDist / 540;
|
|
|
|
auto pMissile = actFireThing(actor, 0, 0, dz / 128 - 14500, nMissile, (nDist2 << 17) / 120);
|
|
|
|
pMissile->x().Impact = 1;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2021-11-16 17:30:23 +00:00
|
|
|
static bool TargetNearExplosion(spritetype* pSprite)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-11-23 23:35:46 +00:00
|
|
|
BloodSectIterator it(pSprite->sector());
|
2021-09-16 19:59:39 +00:00
|
|
|
while (auto actor = it.Next())
|
|
|
|
{
|
2021-12-21 22:18:23 +00:00
|
|
|
if (actor->spr.type == kThingArmedTNTStick || actor->spr.statnum == kStatExplosion)
|
2021-11-16 17:30:23 +00:00
|
|
|
return true;
|
2021-09-16 19:59:39 +00:00
|
|
|
}
|
2021-11-16 17:30:23 +00:00
|
|
|
return false;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void cultThinkSearch(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
auto pXSprite = &actor->x();
|
|
|
|
aiChooseDirection(actor, pXSprite->goalAng);
|
|
|
|
aiLookForTarget(actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void cultThinkGoto(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
auto pXSprite = &actor->x();
|
|
|
|
auto pSprite = &actor->s();
|
|
|
|
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
|
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
|
2021-12-22 10:57:10 +00:00
|
|
|
int dx = pXSprite->targetX - pSprite->pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
int dy = pXSprite->targetY - pSprite->pos.Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nAngle = getangle(dx, dy);
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
aiChooseDirection(actor, nAngle);
|
|
|
|
if (nDist < 5120 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
|
|
|
|
{
|
|
|
|
switch (pXSprite->medium)
|
|
|
|
{
|
|
|
|
case kMediumNormal:
|
|
|
|
aiNewState(actor, &cultistSearch);
|
|
|
|
break;
|
|
|
|
case kMediumWater:
|
|
|
|
case kMediumGoo:
|
|
|
|
aiNewState(actor, &cultistSwimSearch);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aiThinkTarget(actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void cultThinkChase(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
auto pXSprite = &actor->x();
|
|
|
|
auto pSprite = &actor->s();
|
|
|
|
if (actor->GetTarget() == nullptr)
|
|
|
|
{
|
|
|
|
switch (pXSprite->medium)
|
|
|
|
{
|
|
|
|
case kMediumNormal:
|
|
|
|
aiNewState(actor, &cultistGoto);
|
|
|
|
break;
|
|
|
|
case kMediumWater:
|
|
|
|
case kMediumGoo:
|
|
|
|
aiNewState(actor, &cultistSwimGoto);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
|
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
|
|
|
|
spritetype* pTarget = &actor->GetTarget()->s();
|
|
|
|
XSPRITE* pXTarget = &actor->GetTarget()->x();
|
2021-12-22 10:57:10 +00:00
|
|
|
int dx = pTarget->pos.X - pSprite->pos.X;
|
2021-12-22 11:17:17 +00:00
|
|
|
int dy = pTarget->pos.Y - pSprite->pos.Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
aiChooseDirection(actor, getangle(dx, dy));
|
|
|
|
if (pXTarget->health == 0)
|
|
|
|
{
|
|
|
|
switch (pXSprite->medium)
|
|
|
|
{
|
|
|
|
case kMediumNormal:
|
|
|
|
aiNewState(actor, &cultistSearch);
|
|
|
|
if (pSprite->type == kDudeCultistTommy)
|
|
|
|
aiPlay3DSound(actor, 4021 + Random(4), AI_SFX_PRIORITY_1, -1);
|
|
|
|
else
|
|
|
|
aiPlay3DSound(actor, 1021 + Random(4), AI_SFX_PRIORITY_1, -1);
|
|
|
|
break;
|
|
|
|
case kMediumWater:
|
|
|
|
case kMediumGoo:
|
|
|
|
aiNewState(actor, &cultistSwimSearch);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type - kDudePlayer1], kPwUpShadowCloak) > 0)
|
|
|
|
{
|
|
|
|
switch (pXSprite->medium)
|
|
|
|
{
|
|
|
|
case kMediumNormal:
|
|
|
|
aiNewState(actor, &cultistSearch);
|
|
|
|
break;
|
|
|
|
case kMediumWater:
|
|
|
|
case kMediumGoo:
|
|
|
|
aiNewState(actor, &cultistSwimSearch);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int nDist = approxDist(dx, dy);
|
2021-12-21 11:00:01 +00:00
|
|
|
if (nDist > 0 && nDist <= pDudeInfo->seeDist)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
|
|
|
|
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
|
2021-12-22 11:29:00 +00:00
|
|
|
if (cansee(pTarget->pos.X, pTarget->pos.Y, pTarget->pos.Z, pTarget->sector(), pSprite->pos.X, pSprite->pos.Y, pSprite->pos.Z - height, pSprite->sector()))
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
|
|
|
|
{
|
|
|
|
aiSetTarget(actor, actor->GetTarget());
|
2021-12-22 11:29:00 +00:00
|
|
|
actor->dudeSlope = nDist == 0 ? 0 : DivScale(pTarget->pos.Z - pSprite->pos.Z, nDist, 10);
|
2021-09-16 19:59:39 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeCultistTommy:
|
|
|
|
if (nDist < 0x1e00 && nDist > 0xe00 && abs(nDeltaAngle) < 85 && !TargetNearExplosion(pTarget)
|
|
|
|
&& (pTarget->flags & 2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type - kDudePlayer1].isRunning
|
|
|
|
&& Chance(0x8000))
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0);
|
2021-09-16 19:59:39 +00:00
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
if (pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistTThrow);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-12-21 22:18:23 +00:00
|
|
|
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2021-09-16 19:59:39 +00:00
|
|
|
aiNewState(actor, &cultistTThrow);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(actor, &cultistTThrow);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nDist < 0x4600 && abs(nDeltaAngle) < 28)
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0);
|
2021-09-16 19:59:39 +00:00
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistTFire);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistTProneFire);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 13) && (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo))
|
|
|
|
aiNewState(actor, &cultistTSwimFire);
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-12-21 22:18:23 +00:00
|
|
|
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistTFire);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistTProneFire);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistTSwimFire);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistDodge);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistProneDodge);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistSwimDodge);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistTFire);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistTProneFire);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistTSwimFire);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kDudeCultistShotgun:
|
|
|
|
if (nDist < 0x2c00 && nDist > 0x1400 && !TargetNearExplosion(pTarget)
|
|
|
|
&& (pTarget->flags & 2) && gGameOptions.nDifficulty >= 2 && IsPlayerSprite(pTarget) && !gPlayer[pTarget->type - kDudePlayer1].isRunning
|
|
|
|
&& Chance(0x8000))
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0);
|
2021-09-16 19:59:39 +00:00
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
if (pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistSThrow);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-12-21 22:18:23 +00:00
|
|
|
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2021-09-16 19:59:39 +00:00
|
|
|
aiNewState(actor, &cultistSThrow);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(actor, &cultistSThrow);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nDist < 0x3200 && abs(nDeltaAngle) < 28)
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0);
|
2021-09-16 19:59:39 +00:00
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistSFire);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistSProneFire);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistSSwimFire);
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-12-21 22:18:23 +00:00
|
|
|
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistTommy)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistSFire);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistSProneFire);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistSSwimFire);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistDodge);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistProneDodge);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistSwimDodge);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistSFire);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistSProneFire);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistSSwimFire);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kDudeCultistTesla:
|
|
|
|
if (nDist < 0x1e00 && nDist > 0xe00 && !TargetNearExplosion(pTarget)
|
|
|
|
&& (pTarget->flags & 2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type - kDudePlayer1].isRunning
|
|
|
|
&& Chance(0x8000))
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0);
|
2021-09-16 19:59:39 +00:00
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
if (pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistTsThrow);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-12-21 22:18:23 +00:00
|
|
|
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2021-09-16 19:59:39 +00:00
|
|
|
aiNewState(actor, &cultistTsThrow);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(actor, &cultistTsThrow);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nDist < 0x3200 && abs(nDeltaAngle) < 28)
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0);
|
2021-09-16 19:59:39 +00:00
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistTsFire);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistTsProneFire);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistTsSwimFire);
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-12-21 22:18:23 +00:00
|
|
|
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistTommy)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistTsFire);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistTsProneFire);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistTsSwimFire);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistDodge);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistProneDodge);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistSwimDodge);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistTsFire);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistTsProneFire);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistTsSwimFire);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kDudeCultistTNT:
|
|
|
|
if (nDist < 0x2c00 && nDist > 0x1400 && abs(nDeltaAngle) < 85
|
|
|
|
&& (pTarget->flags & 2) && IsPlayerSprite(pTarget))
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0);
|
2021-09-16 19:59:39 +00:00
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
if (pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistDThrow);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-12-21 22:18:23 +00:00
|
|
|
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2021-09-16 19:59:39 +00:00
|
|
|
aiNewState(actor, &cultistDThrow);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(actor, &cultistDThrow);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nDist < 0x1400 && abs(nDeltaAngle) < 85
|
|
|
|
&& (pTarget->flags & 2) && IsPlayerSprite(pTarget))
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0);
|
2021-09-16 19:59:39 +00:00
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
if (pXSprite->medium != 1 && pXSprite->medium != kMediumGoo)
|
|
|
|
aiNewState(actor, &cultist139A78);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-12-21 22:18:23 +00:00
|
|
|
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2021-09-16 19:59:39 +00:00
|
|
|
aiNewState(actor, &cultist139A78);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(actor, &cultist139A78);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kDudeCultistBeast:
|
|
|
|
if (nDist < 0x1e00 && nDist > 0xe00 && !TargetNearExplosion(pTarget)
|
|
|
|
&& (pTarget->flags & 2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type - kDudePlayer1].isRunning
|
|
|
|
&& Chance(0x8000))
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0);
|
2021-09-16 19:59:39 +00:00
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
if (pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistSThrow);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-12-21 22:18:23 +00:00
|
|
|
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2021-09-16 19:59:39 +00:00
|
|
|
aiNewState(actor, &cultistSThrow);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(actor, &cultistSThrow);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nDist < 0x3200 && abs(nDeltaAngle) < 28)
|
|
|
|
{
|
2021-12-22 11:29:00 +00:00
|
|
|
int hit = HitScan(actor, pSprite->pos.Z, dx, dy, 0, CLIPMASK1, 0);
|
2021-09-16 19:59:39 +00:00
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistSFire);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistSProneFire);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistSSwimFire);
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-12-21 22:18:23 +00:00
|
|
|
if (pSprite->type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeCultistTommy)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistSFire);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistSProneFire);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistSSwimFire);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistDodge);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistProneDodge);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistSwimDodge);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistSFire);
|
|
|
|
else if (dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal)
|
|
|
|
aiNewState(actor, &cultistSProneFire);
|
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
|
|
|
aiNewState(actor, &cultistSSwimFire);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (pXSprite->medium)
|
|
|
|
{
|
|
|
|
case kMediumNormal:
|
|
|
|
aiNewState(actor, &cultistGoto);
|
|
|
|
break;
|
|
|
|
case kMediumWater:
|
|
|
|
case kMediumGoo:
|
|
|
|
aiNewState(actor, &cultistSwimGoto);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
actor->SetTarget(nullptr);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|