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 "compat.h"
|
|
|
|
#include "build.h"
|
|
|
|
#include "pragmas.h"
|
|
|
|
#include "mmulti.h"
|
|
|
|
#include "common_game.h"
|
|
|
|
|
|
|
|
#include "actor.h"
|
|
|
|
#include "ai.h"
|
2020-07-25 15:56:39 +00:00
|
|
|
#include "aistate.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "blood.h"
|
|
|
|
#include "db.h"
|
|
|
|
#include "dude.h"
|
|
|
|
#include "eventq.h"
|
|
|
|
#include "levels.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "seq.h"
|
2020-07-25 16:53:44 +00:00
|
|
|
#include "sound.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2020-10-11 09:56:27 +00:00
|
|
|
static void cultThinkSearch(spritetype *, XSPRITE *);
|
|
|
|
static void cultThinkGoto(spritetype *, XSPRITE *);
|
|
|
|
static void cultThinkChase(spritetype *, XSPRITE *);
|
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-21 15:34:32 +00:00
|
|
|
void TommySeqCallback(int, int nXSprite)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
XSPRITE *pXSprite = &xsprite[nXSprite];
|
|
|
|
int nSprite = pXSprite->reference;
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
2020-09-01 13:00:35 +00:00
|
|
|
int dx = CosScale16(pSprite->ang);
|
|
|
|
int dy = SinScale16(pSprite->ang);
|
2019-09-19 22:42:45 +00:00
|
|
|
int dz = gDudeSlope[nXSprite];
|
|
|
|
dx += Random3((5-gGameOptions.nDifficulty)*1000);
|
|
|
|
dy += Random3((5-gGameOptions.nDifficulty)*1000);
|
|
|
|
dz += Random3((5-gGameOptions.nDifficulty)*500);
|
|
|
|
actFireVector(pSprite, 0, 0, dx, dy, dz, VECTOR_TYPE_2);
|
|
|
|
sfxPlay3DSound(pSprite, 4001, -1, 0);
|
|
|
|
}
|
|
|
|
|
2020-11-21 15:34:32 +00:00
|
|
|
void TeslaSeqCallback(int, int nXSprite)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
XSPRITE *pXSprite = &xsprite[nXSprite];
|
|
|
|
int nSprite = pXSprite->reference;
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
if (Chance(dword_138BB0[gGameOptions.nDifficulty]))
|
|
|
|
{
|
2020-09-01 13:00:35 +00:00
|
|
|
int dx = CosScale16(pSprite->ang);
|
|
|
|
int dy = SinScale16(pSprite->ang);
|
2019-09-19 22:42:45 +00:00
|
|
|
int dz = gDudeSlope[nXSprite];
|
|
|
|
dx += Random3((5-gGameOptions.nDifficulty)*1000);
|
|
|
|
dy += Random3((5-gGameOptions.nDifficulty)*1000);
|
|
|
|
dz += Random3((5-gGameOptions.nDifficulty)*500);
|
2019-10-11 21:59:39 +00:00
|
|
|
actFireMissile(pSprite, 0, 0, dx, dy, dz, kMissileTeslaRegular);
|
2019-09-19 22:42:45 +00:00
|
|
|
sfxPlay3DSound(pSprite, 470, -1, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-21 15:34:32 +00:00
|
|
|
void ShotSeqCallback(int, int nXSprite)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
XSPRITE *pXSprite = &xsprite[nXSprite];
|
|
|
|
int nSprite = pXSprite->reference;
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
2020-09-01 13:00:35 +00:00
|
|
|
int dx = CosScale16(pSprite->ang);
|
|
|
|
int dy = SinScale16(pSprite->ang);
|
2019-09-19 22:42:45 +00:00
|
|
|
int dz = gDudeSlope[nXSprite];
|
|
|
|
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(pSprite, 0, 0, dx+r3, dy+r2, dz+r1, VECTOR_TYPE_1);
|
|
|
|
}
|
|
|
|
if (Chance(0x8000))
|
|
|
|
sfxPlay3DSound(pSprite, 1001, -1, 0);
|
|
|
|
else
|
|
|
|
sfxPlay3DSound(pSprite, 1002, -1, 0);
|
|
|
|
}
|
|
|
|
|
2020-11-21 15:34:32 +00:00
|
|
|
void cultThrowSeqCallback(int, int nXSprite)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
XSPRITE *pXSprite = &xsprite[nXSprite];
|
|
|
|
int nSprite = pXSprite->reference;
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
2019-10-11 21:59:39 +00:00
|
|
|
int nMissile = kThingArmedTNTStick;
|
2019-09-19 22:42:45 +00:00
|
|
|
if (gGameOptions.nDifficulty > 2)
|
2019-10-11 21:59:39 +00:00
|
|
|
nMissile = kThingArmedTNTBundle;
|
2019-09-19 22:42:45 +00:00
|
|
|
char v4 = Chance(0x6000);
|
|
|
|
sfxPlay3DSound(pSprite, 455, -1, 0);
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
|
2019-09-19 22:42:45 +00:00
|
|
|
spritetype *pTarget = &sprite[pXSprite->target];
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
|
2019-09-19 22:42:45 +00:00
|
|
|
int dx = pTarget->x - pSprite->x;
|
|
|
|
int dy = pTarget->y - pSprite->y;
|
|
|
|
int dz = pTarget->z - pSprite->z;
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
int nDist2 = nDist / 540;
|
|
|
|
if (nDist > 0x1e00)
|
|
|
|
v4 = 0;
|
|
|
|
spritetype *pMissile = actFireThing(pSprite, 0, 0, dz/128-14500, nMissile, (nDist2<<23)/120);
|
|
|
|
if (v4)
|
|
|
|
xsprite[pMissile->extra].Impact = 1;
|
|
|
|
else
|
2020-01-11 21:07:05 +00:00
|
|
|
evPost(pMissile->index, 3, 120*(1+Random(2)), kCmdOn);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-21 15:34:32 +00:00
|
|
|
void sub_68170(int, int nXSprite)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
XSPRITE *pXSprite = &xsprite[nXSprite];
|
|
|
|
int nSprite = pXSprite->reference;
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
2019-10-11 21:59:39 +00:00
|
|
|
int nMissile = kThingArmedTNTStick;
|
2019-09-19 22:42:45 +00:00
|
|
|
if (gGameOptions.nDifficulty > 2)
|
2019-10-11 21:59:39 +00:00
|
|
|
nMissile = kThingArmedTNTBundle;
|
2019-09-19 22:42:45 +00:00
|
|
|
sfxPlay3DSound(pSprite, 455, -1, 0);
|
|
|
|
spritetype *pMissile = actFireThing(pSprite, 0, 0, gDudeSlope[nXSprite]-9460, nMissile, 0x133333);
|
2020-01-11 21:07:05 +00:00
|
|
|
evPost(pMissile->index, 3, 120*(2+Random(2)), kCmdOn);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-21 15:34:32 +00:00
|
|
|
void sub_68230(int, int nXSprite)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
XSPRITE *pXSprite = &xsprite[nXSprite];
|
|
|
|
int nSprite = pXSprite->reference;
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
2019-10-11 21:59:39 +00:00
|
|
|
int nMissile = kThingArmedTNTStick;
|
2019-09-19 22:42:45 +00:00
|
|
|
if (gGameOptions.nDifficulty > 2)
|
2019-10-11 21:59:39 +00:00
|
|
|
nMissile = kThingArmedTNTBundle;
|
2019-09-19 22:42:45 +00:00
|
|
|
sfxPlay3DSound(pSprite, 455, -1, 0);
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
|
2019-09-19 22:42:45 +00:00
|
|
|
spritetype *pTarget = &sprite[pXSprite->target];
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
|
2019-09-19 22:42:45 +00:00
|
|
|
int dx = pTarget->x - pSprite->x;
|
|
|
|
int dy = pTarget->y - pSprite->y;
|
|
|
|
int dz = pTarget->z - pSprite->z;
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
int nDist2 = nDist / 540;
|
|
|
|
spritetype *pMissile = actFireThing(pSprite, 0, 0, dz/128-14500, nMissile, (nDist2<<17)/120);
|
|
|
|
xsprite[pMissile->extra].Impact = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char TargetNearExplosion(spritetype *pSprite)
|
|
|
|
{
|
2020-10-15 14:59:43 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(pSprite->sectnum);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
if (sprite[nSprite].type == kThingArmedTNTStick || sprite[nSprite].statnum == kStatExplosion)
|
2019-09-19 22:42:45 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-10-11 09:56:27 +00:00
|
|
|
static void cultThinkSearch(spritetype *pSprite, XSPRITE *pXSprite)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng);
|
|
|
|
sub_5F15C(pSprite, pXSprite);
|
|
|
|
}
|
|
|
|
|
2020-10-11 09:56:27 +00:00
|
|
|
static void cultThinkGoto(spritetype *pSprite, XSPRITE *pXSprite)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
|
2020-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
2019-09-19 22:42:45 +00:00
|
|
|
int dx = pXSprite->targetX-pSprite->x;
|
|
|
|
int dy = pXSprite->targetY-pSprite->y;
|
|
|
|
int nAngle = getangle(dx, dy);
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
aiChooseDirection(pSprite, pXSprite, nAngle);
|
|
|
|
if (nDist < 5120 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery)
|
|
|
|
{
|
|
|
|
switch (pXSprite->medium)
|
|
|
|
{
|
2019-10-19 19:11:39 +00:00
|
|
|
case kMediumNormal:
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSearch);
|
|
|
|
break;
|
2019-10-19 19:11:39 +00:00
|
|
|
case kMediumWater:
|
|
|
|
case kMediumGoo:
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSwimSearch);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aiThinkTarget(pSprite, pXSprite);
|
|
|
|
}
|
|
|
|
|
2020-10-11 09:56:27 +00:00
|
|
|
static void cultThinkChase(spritetype *pSprite, XSPRITE *pXSprite)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
if (pXSprite->target == -1)
|
|
|
|
{
|
|
|
|
switch (pXSprite->medium)
|
|
|
|
{
|
2019-10-19 19:11:39 +00:00
|
|
|
case kMediumNormal:
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistGoto);
|
|
|
|
break;
|
2019-10-19 19:11:39 +00:00
|
|
|
case kMediumWater:
|
|
|
|
case kMediumGoo:
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSwimGoto);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
|
2020-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
|
2019-09-19 22:42:45 +00:00
|
|
|
spritetype *pTarget = &sprite[pXSprite->target];
|
|
|
|
XSPRITE *pXTarget = &xsprite[pTarget->extra];
|
|
|
|
int dx = pTarget->x-pSprite->x;
|
|
|
|
int dy = pTarget->y-pSprite->y;
|
|
|
|
aiChooseDirection(pSprite, pXSprite, getangle(dx, dy));
|
|
|
|
if (pXTarget->health == 0)
|
|
|
|
{
|
|
|
|
switch (pXSprite->medium)
|
|
|
|
{
|
2019-10-19 19:11:39 +00:00
|
|
|
case kMediumNormal:
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSearch);
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pSprite->type == kDudeCultistTommy)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiPlay3DSound(pSprite, 4021+Random(4), AI_SFX_PRIORITY_1, -1);
|
|
|
|
else
|
|
|
|
aiPlay3DSound(pSprite, 1021+Random(4), AI_SFX_PRIORITY_1, -1);
|
|
|
|
break;
|
2019-10-19 19:11:39 +00:00
|
|
|
case kMediumWater:
|
|
|
|
case kMediumGoo:
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSwimSearch);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-10-19 19:11:39 +00:00
|
|
|
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
switch (pXSprite->medium)
|
|
|
|
{
|
2019-10-19 19:11:39 +00:00
|
|
|
case kMediumNormal:
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSearch);
|
|
|
|
break;
|
2019-10-19 19:11:39 +00:00
|
|
|
case kMediumWater:
|
|
|
|
case kMediumGoo:
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSwimSearch);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
if (nDist <= pDudeInfo->seeDist)
|
|
|
|
{
|
|
|
|
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
|
|
|
|
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
|
|
|
|
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
|
|
|
|
{
|
|
|
|
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery)
|
|
|
|
{
|
|
|
|
aiSetTarget(pXSprite, pXSprite->target);
|
|
|
|
int nXSprite = sprite[pXSprite->reference].extra;
|
|
|
|
gDudeSlope[nXSprite] = divscale(pTarget->z-pSprite->z, nDist, 10);
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeCultistTommy:
|
2019-09-19 22:42:45 +00:00
|
|
|
if (nDist < 0x1e00 && nDist > 0xe00 && klabs(nDeltaAngle) < 85 && !TargetNearExplosion(pTarget)
|
2019-10-21 19:46:41 +00:00
|
|
|
&& (pTarget->flags&2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type-kDudePlayer1].isRunning
|
2019-09-19 22:42:45 +00:00
|
|
|
&& Chance(0x8000))
|
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTThrow);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTThrow);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(pSprite, pXSprite, &cultistTThrow);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nDist < 0x4600 && klabs(nDeltaAngle) < 28)
|
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTProneFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 13) && (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo))
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTSwimFire);
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTProneFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTSwimFire);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistDodge);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistProneDodge);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSwimDodge);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTProneFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTSwimFire);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeCultistShotgun:
|
2019-09-19 22:42:45 +00:00
|
|
|
if (nDist < 0x2c00 && nDist > 0x1400 && !TargetNearExplosion(pTarget)
|
2019-10-21 19:46:41 +00:00
|
|
|
&& (pTarget->flags&2) && gGameOptions.nDifficulty >= 2 && IsPlayerSprite(pTarget) && !gPlayer[pTarget->type-kDudePlayer1].isRunning
|
2019-09-19 22:42:45 +00:00
|
|
|
&& Chance(0x8000))
|
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSThrow);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSThrow);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(pSprite, pXSprite, &cultistSThrow);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nDist < 0x3200 && klabs(nDeltaAngle) < 28)
|
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSProneFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSSwimFire);
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistTommy)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSProneFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSSwimFire);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistDodge);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistProneDodge);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSwimDodge);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSProneFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSSwimFire);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeCultistTesla:
|
2019-09-19 22:42:45 +00:00
|
|
|
if (nDist < 0x1e00 && nDist > 0xe00 && !TargetNearExplosion(pTarget)
|
2019-10-21 19:46:41 +00:00
|
|
|
&& (pTarget->flags&2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type-kDudePlayer1].isRunning
|
2019-09-19 22:42:45 +00:00
|
|
|
&& Chance(0x8000))
|
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTsThrow);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTsThrow);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(pSprite, pXSprite, &cultistTsThrow);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nDist < 0x3200 && klabs(nDeltaAngle) < 28)
|
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTsFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTsProneFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTsSwimFire);
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistTommy)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTsFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTsProneFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTsSwimFire);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistDodge);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistProneDodge);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSwimDodge);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTsFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTsProneFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistTsSwimFire);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeCultistTNT:
|
2019-09-19 22:42:45 +00:00
|
|
|
if (nDist < 0x2c00 && nDist > 0x1400 && klabs(nDeltaAngle) < 85
|
2019-09-30 07:18:01 +00:00
|
|
|
&& (pTarget->flags&2) && IsPlayerSprite(pTarget))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistDThrow);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistDThrow);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(pSprite, pXSprite, &cultistDThrow);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nDist < 0x1400 && klabs(nDeltaAngle) < 85
|
2019-09-30 07:18:01 +00:00
|
|
|
&& (pTarget->flags&2) && IsPlayerSprite(pTarget))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (pXSprite->medium != 1 && pXSprite->medium != kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultist139A78);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultist139A78);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(pSprite, pXSprite, &cultist139A78);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeCultistBeast:
|
2019-09-19 22:42:45 +00:00
|
|
|
if (nDist < 0x1e00 && nDist > 0xe00 && !TargetNearExplosion(pTarget)
|
2019-10-21 19:46:41 +00:00
|
|
|
&& (pTarget->flags&2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type-kDudePlayer1].isRunning
|
2019-09-19 22:42:45 +00:00
|
|
|
&& Chance(0x8000))
|
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSThrow);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSThrow);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(pSprite, pXSprite, &cultistSThrow);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nDist < 0x3200 && klabs(nDeltaAngle) < 28)
|
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSProneFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSSwimFire);
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeCultistTommy)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSProneFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSSwimFire);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistDodge);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistProneDodge);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSwimDodge);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (sub_5BDA8(pSprite, 14) && pXSprite->medium == kMediumNormal)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSProneFire);
|
2019-10-19 19:11:39 +00:00
|
|
|
else if (pXSprite->medium == kMediumWater || pXSprite->medium == kMediumGoo)
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSSwimFire);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (pXSprite->medium)
|
|
|
|
{
|
2019-10-19 19:11:39 +00:00
|
|
|
case kMediumNormal:
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistGoto);
|
|
|
|
break;
|
2019-10-19 19:11:39 +00:00
|
|
|
case kMediumWater:
|
|
|
|
case kMediumGoo:
|
2019-09-19 22:42:45 +00:00
|
|
|
aiNewState(pSprite, pXSprite, &cultistSwimGoto);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pXSprite->target = -1;
|
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|