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 "blood.h"
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void cerberusThinkSearch(DBloodActor *actor);
|
|
|
|
static void cerberusThinkTarget(DBloodActor *actor);
|
|
|
|
static void cerberusThinkGoto(DBloodActor *actor);
|
|
|
|
static void cerberusThinkChase(DBloodActor *actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE cerberusIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, cerberusThinkTarget, NULL };
|
|
|
|
AISTATE cerberusSearch = { kAiStateSearch, 7, -1, 1800, NULL, aiMoveForward, cerberusThinkSearch, &cerberusIdle };
|
|
|
|
AISTATE cerberusChase = { kAiStateChase, 7, -1, 0, NULL, aiMoveForward, cerberusThinkChase, NULL };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE cerberusRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &cerberusSearch };
|
|
|
|
AISTATE cerberusTeslaRecoil = { kAiStateRecoil, 4, -1, 0, NULL, NULL, NULL, &cerberusSearch };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE cerberusGoto = { kAiStateMove, 7, -1, 600, NULL, aiMoveForward, cerberusThinkGoto, &cerberusIdle };
|
|
|
|
AISTATE cerberusBite = { kAiStateChase, 6, nCerberusBiteClient, 60, NULL, NULL, NULL, &cerberusChase };
|
|
|
|
AISTATE cerberusBurn = { kAiStateChase, 6, nCerberusBurnClient, 60, NULL, NULL, NULL, &cerberusChase };
|
|
|
|
AISTATE cerberus3Burn = { kAiStateChase, 6, nCerberusBurnClient2, 60, NULL, NULL, NULL, &cerberusChase };
|
|
|
|
AISTATE cerberus2Idle = { kAiStateIdle, 0, -1, 0, NULL, NULL, cerberusThinkTarget, NULL };
|
|
|
|
AISTATE cerberus2Search = { kAiStateSearch, 7, -1, 1800, NULL, aiMoveForward, cerberusThinkSearch, &cerberus2Idle };
|
|
|
|
AISTATE cerberus2Chase = { kAiStateChase, 7, -1, 0, NULL, aiMoveForward, cerberusThinkChase, NULL };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE cerberus2Recoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &cerberus2Search };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE cerberus2Goto = { kAiStateMove, 7, -1, 600, NULL, aiMoveForward, cerberusThinkGoto, &cerberus2Idle };
|
|
|
|
AISTATE cerberus2Bite = { kAiStateChase, 6, nCerberusBiteClient, 60, NULL, NULL, NULL, &cerberus2Chase };
|
|
|
|
AISTATE cerberus2Burn = { kAiStateChase, 6, nCerberusBurnClient, 60, NULL, NULL, NULL, &cerberus2Chase };
|
|
|
|
AISTATE cerberus4Burn = { kAiStateChase, 6, nCerberusBurnClient2, 60, NULL, NULL, NULL, &cerberus2Chase };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE cerberus139890 = { kAiStateOther, 7, -1, 120, NULL, aiMoveTurn, NULL, &cerberusChase };
|
|
|
|
AISTATE cerberus1398AC = { kAiStateOther, 7, -1, 120, NULL, aiMoveTurn, NULL, &cerberusChase };
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void cerberusBiteSeqCallback(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-07 14:16:12 +00:00
|
|
|
XSPRITE* pXSprite = &actor->x();
|
|
|
|
spritetype *pSprite = &actor->s();
|
2020-09-01 13:00:35 +00:00
|
|
|
int dx = CosScale16(pSprite->ang);
|
|
|
|
int dy = SinScale16(pSprite->ang);
|
2020-10-11 10:38:17 +00:00
|
|
|
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) {
|
2020-10-11 10:38:17 +00:00
|
|
|
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
|
2019-09-19 22:42:45 +00:00
|
|
|
return;
|
2019-10-19 19:11:39 +00:00
|
|
|
}
|
2020-10-11 10:38:17 +00:00
|
|
|
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) {
|
2020-10-11 10:38:17 +00:00
|
|
|
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites");
|
2019-09-19 22:42:45 +00:00
|
|
|
return;
|
2019-10-19 19:11:39 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
spritetype *pTarget = &sprite[pXSprite->target];
|
|
|
|
int dz = pTarget->z-pSprite->z;
|
2021-08-30 18:28:24 +00:00
|
|
|
actFireVector(actor, 350, -100, dx, dy, dz, kVectorCerberusHack);
|
|
|
|
actFireVector(actor, -350, 0, dx, dy, dz, kVectorCerberusHack);
|
|
|
|
actFireVector(actor, 0, 0, dx, dy, dz, kVectorCerberusHack);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void cerberusBurnSeqCallback(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-07 14:16:12 +00:00
|
|
|
XSPRITE* pXSprite = &actor->x();
|
|
|
|
spritetype* pSprite = &actor->s();
|
2020-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
2019-09-19 22:42:45 +00:00
|
|
|
int height = pDudeInfo->eyeHeight*pSprite->yrepeat;
|
2020-10-11 10:38:17 +00:00
|
|
|
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) {
|
2020-10-11 10:38:17 +00:00
|
|
|
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites");
|
2019-09-19 22:42:45 +00:00
|
|
|
return;
|
2019-10-19 19:11:39 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
int x = pSprite->x;
|
|
|
|
int y = pSprite->y;
|
|
|
|
int z = height; // ???
|
|
|
|
TARGETTRACK tt1 = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa };
|
|
|
|
Aim aim;
|
2020-09-01 13:00:35 +00:00
|
|
|
aim.dx = CosScale16(pSprite->ang);
|
|
|
|
aim.dy = SinScale16(pSprite->ang);
|
2020-11-07 15:26:14 +00:00
|
|
|
aim.dz = actor->dudeSlope;
|
2019-09-19 22:42:45 +00:00
|
|
|
int nClosest = 0x7fffffff;
|
2020-10-15 15:15:45 +00:00
|
|
|
int nSprite2;
|
|
|
|
StatIterator it(kStatDude);
|
|
|
|
while ((nSprite2 = it.NextIndex()) >= 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite2 = &sprite[nSprite2];
|
2019-09-30 07:18:01 +00:00
|
|
|
if (pSprite == pSprite2 || !(pSprite2->flags&8))
|
2019-09-19 22:42:45 +00:00
|
|
|
continue;
|
|
|
|
int x2 = pSprite2->x;
|
|
|
|
int y2 = pSprite2->y;
|
|
|
|
int z2 = pSprite2->z;
|
|
|
|
int nDist = approxDist(x2-x, y2-y);
|
|
|
|
if (nDist == 0 || nDist > 0x2800)
|
|
|
|
continue;
|
|
|
|
if (tt1.at10)
|
|
|
|
{
|
2021-01-04 11:59:00 +00:00
|
|
|
int t = DivScale(nDist, tt1.at10, 12);
|
2019-09-19 22:42:45 +00:00
|
|
|
x2 += (xvel[nSprite2]*t)>>12;
|
|
|
|
y2 += (yvel[nSprite2]*t)>>12;
|
|
|
|
z2 += (zvel[nSprite2]*t)>>8;
|
|
|
|
}
|
2021-01-04 11:36:54 +00:00
|
|
|
int tx = x+MulScale(Cos(pSprite->ang), nDist, 30);
|
|
|
|
int ty = y+MulScale(Sin(pSprite->ang), nDist, 30);
|
2021-01-04 11:57:26 +00:00
|
|
|
int tz = z+MulScale(actor->dudeSlope, nDist, 10);
|
|
|
|
int tsr = MulScale(9460, nDist, 10);
|
2019-09-19 22:42:45 +00:00
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pSprite2, &top, &bottom);
|
|
|
|
if (tz-tsr > bottom || tz+tsr < top)
|
|
|
|
continue;
|
|
|
|
int dx = (tx-x2)>>4;
|
|
|
|
int dy = (ty-y2)>>4;
|
|
|
|
int dz = (tz-z2)>>8;
|
|
|
|
int nDist2 = ksqrt(dx*dx+dy*dy+dz*dz);
|
|
|
|
if (nDist2 < nClosest)
|
|
|
|
{
|
|
|
|
int nAngle = getangle(x2-x, y2-y);
|
|
|
|
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
|
2021-01-04 12:02:00 +00:00
|
|
|
if (abs(nDeltaAngle) <= tt1.at8)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int tz = pSprite2->z-pSprite->z;
|
|
|
|
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
|
|
|
|
{
|
|
|
|
nClosest = nDist2;
|
2020-09-01 13:00:35 +00:00
|
|
|
aim.dx = CosScale16(nAngle);
|
|
|
|
aim.dy = SinScale16(nAngle);
|
2021-01-04 11:59:00 +00:00
|
|
|
aim.dz = DivScale(tz, nDist, 10);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
aim.dz = tz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeCerberusTwoHead:
|
|
|
|
actFireMissile(pSprite, -350, 0, aim.dx, aim.dy, aim.dz, kMissileFireballCerberus);
|
|
|
|
actFireMissile(pSprite, 350, -100, aim.dx, aim.dy, aim.dz, kMissileFireballCerberus);
|
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
|
|
|
actFireMissile(pSprite, 350, -100, aim.dx, aim.dy, aim.dz, kMissileFireballCerberus);
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void cerberusBurnSeqCallback2(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-07 14:16:12 +00:00
|
|
|
XSPRITE* pXSprite = &actor->x();
|
|
|
|
spritetype* pSprite = &actor->s();
|
2020-10-11 10:38:17 +00:00
|
|
|
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) {
|
2020-10-11 10:38:17 +00:00
|
|
|
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites");
|
2019-09-19 22:42:45 +00:00
|
|
|
return;
|
2019-10-19 19:11:39 +00:00
|
|
|
}
|
2020-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
2019-09-19 22:42:45 +00:00
|
|
|
int height = pDudeInfo->eyeHeight*pSprite->yrepeat;
|
2019-10-19 19:11:39 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
int x = pSprite->x;
|
|
|
|
int y = pSprite->y;
|
|
|
|
int z = height; // ???
|
|
|
|
TARGETTRACK tt1 = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa };
|
|
|
|
Aim aim;
|
|
|
|
int ax, ay, az;
|
2020-09-01 13:00:35 +00:00
|
|
|
aim.dx = ax = CosScale16(pSprite->ang);
|
|
|
|
aim.dy = ay = SinScale16(pSprite->ang);
|
2020-11-07 15:26:14 +00:00
|
|
|
aim.dz = actor->dudeSlope;
|
2019-09-19 22:42:45 +00:00
|
|
|
az = 0;
|
|
|
|
int nClosest = 0x7fffffff;
|
2020-10-15 15:15:45 +00:00
|
|
|
int nSprite2;
|
|
|
|
StatIterator it(kStatDude);
|
|
|
|
while ((nSprite2 = it.NextIndex()) >= 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite2 = &sprite[nSprite2];
|
2019-09-30 07:18:01 +00:00
|
|
|
if (pSprite == pSprite2 || !(pSprite2->flags&8))
|
2019-09-19 22:42:45 +00:00
|
|
|
continue;
|
|
|
|
int x2 = pSprite2->x;
|
|
|
|
int y2 = pSprite2->y;
|
|
|
|
int z2 = pSprite2->z;
|
|
|
|
int nDist = approxDist(x2-x, y2-y);
|
|
|
|
if (nDist == 0 || nDist > 0x2800)
|
|
|
|
continue;
|
|
|
|
if (tt1.at10)
|
|
|
|
{
|
2021-01-04 11:59:00 +00:00
|
|
|
int t = DivScale(nDist, tt1.at10, 12);
|
2019-09-19 22:42:45 +00:00
|
|
|
x2 += (xvel[nSprite2]*t)>>12;
|
|
|
|
y2 += (yvel[nSprite2]*t)>>12;
|
|
|
|
z2 += (zvel[nSprite2]*t)>>8;
|
|
|
|
}
|
2021-01-04 11:36:54 +00:00
|
|
|
int tx = x+MulScale(Cos(pSprite->ang), nDist, 30);
|
|
|
|
int ty = y+MulScale(Sin(pSprite->ang), nDist, 30);
|
2021-01-04 11:57:26 +00:00
|
|
|
int tz = z+MulScale(actor->dudeSlope, nDist, 10);
|
|
|
|
int tsr = MulScale(9460, nDist, 10);
|
2019-09-19 22:42:45 +00:00
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pSprite2, &top, &bottom);
|
|
|
|
if (tz-tsr > bottom || tz+tsr < top)
|
|
|
|
continue;
|
|
|
|
int dx = (tx-x2)>>4;
|
|
|
|
int dy = (ty-y2)>>4;
|
|
|
|
int dz = (tz-z2)>>8;
|
|
|
|
int nDist2 = ksqrt(dx*dx+dy*dy+dz*dz);
|
|
|
|
if (nDist2 < nClosest)
|
|
|
|
{
|
|
|
|
int nAngle = getangle(x2-x, y2-y);
|
|
|
|
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
|
2021-01-04 12:02:00 +00:00
|
|
|
if (abs(nDeltaAngle) <= tt1.at8)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo2 = getDudeInfo(pSprite2->type);
|
2019-09-19 22:42:45 +00:00
|
|
|
int height = (pDudeInfo2->aimHeight*pSprite2->yrepeat)<<2;
|
|
|
|
int tz = (z2-height)-z;
|
|
|
|
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
|
|
|
|
{
|
|
|
|
nClosest = nDist2;
|
2020-09-01 13:00:35 +00:00
|
|
|
aim.dx = CosScale16(nAngle);
|
|
|
|
aim.dy = SinScale16(nAngle);
|
2021-01-04 11:59:00 +00:00
|
|
|
aim.dz = DivScale(tz, nDist, 10);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
aim.dz = tz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeCerberusTwoHead:
|
|
|
|
actFireMissile(pSprite, 350, -100, aim.dx, aim.dy, -aim.dz, kMissileFlameHound);
|
|
|
|
actFireMissile(pSprite, -350, 0, ax, ay, az, kMissileFlameHound);
|
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
|
|
|
actFireMissile(pSprite, 350, -100, aim.dx, aim.dy, -aim.dz, kMissileFlameHound);
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void cerberusThinkSearch(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-06 21:48:22 +00:00
|
|
|
auto pXSprite = &actor->x();
|
|
|
|
auto pSprite = &actor->s();
|
2019-09-19 22:42:45 +00:00
|
|
|
aiChooseDirection(pSprite, pXSprite, pXSprite->goalAng);
|
2020-11-06 21:48:22 +00:00
|
|
|
aiThinkTarget(actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void cerberusThinkTarget(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-06 21:48:22 +00:00
|
|
|
auto pXSprite = &actor->x();
|
|
|
|
auto pSprite = &actor->s();
|
2020-10-11 10:38:17 +00:00
|
|
|
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) {
|
2020-10-11 10:38:17 +00:00
|
|
|
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
|
2019-10-19 19:11:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
2020-12-04 22:21:42 +00:00
|
|
|
DUDEEXTRA_at6_u1 *pDudeExtraE = &actor->dudeExtra.at6.u1;
|
2020-11-21 22:40:33 +00:00
|
|
|
if (pDudeExtraE->xval3 && pDudeExtraE->xval2 < 10)
|
|
|
|
pDudeExtraE->xval2++;
|
|
|
|
else if (pDudeExtraE->xval2 >= 10 && pDudeExtraE->xval3)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
pXSprite->goalAng += 256;
|
|
|
|
POINT3D *pTarget = &baseSprite[pSprite->index];
|
|
|
|
aiSetTarget(pXSprite, pTarget->x, pTarget->y, pTarget->z);
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pSprite->type == kDudeCerberusTwoHead)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberus139890);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberus1398AC);
|
2019-09-19 22:42:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Chance(pDudeInfo->alertChance))
|
|
|
|
{
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
|
|
|
{
|
|
|
|
PLAYER *pPlayer = &gPlayer[p];
|
2019-10-19 19:11:39 +00:00
|
|
|
if (pPlayer->pXSprite->health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
continue;
|
|
|
|
int x = pPlayer->pSprite->x;
|
|
|
|
int y = pPlayer->pSprite->y;
|
|
|
|
int z = pPlayer->pSprite->z;
|
|
|
|
int nSector = pPlayer->pSprite->sectnum;
|
|
|
|
int dx = x-pSprite->x;
|
|
|
|
int dy = y-pSprite->y;
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
|
|
|
|
continue;
|
|
|
|
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
|
|
|
|
continue;
|
|
|
|
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
|
2021-01-04 12:02:00 +00:00
|
|
|
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-21 22:40:33 +00:00
|
|
|
pDudeExtraE->xval1 = 0;
|
2019-10-21 19:46:41 +00:00
|
|
|
aiSetTarget(pXSprite, pPlayer->nSprite);
|
2020-11-06 21:48:22 +00:00
|
|
|
aiActivateDude(&bloodActors[pXSprite->reference]);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
else if (nDist < pDudeInfo->hearDist)
|
|
|
|
{
|
2020-11-21 22:40:33 +00:00
|
|
|
pDudeExtraE->xval1 = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
aiSetTarget(pXSprite, x, y, z);
|
2020-11-06 21:48:22 +00:00
|
|
|
aiActivateDude(&bloodActors[pXSprite->reference]);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void cerberusThinkGoto(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-06 21:48:22 +00:00
|
|
|
auto pXSprite = &actor->x();
|
|
|
|
auto pSprite = &actor->s();
|
2020-10-11 10:38:17 +00:00
|
|
|
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) {
|
2020-10-11 10:38:17 +00:00
|
|
|
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
|
2019-10-19 19:11:39 +00:00
|
|
|
return;
|
|
|
|
}
|
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);
|
2021-01-04 12:02:00 +00:00
|
|
|
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeCerberusTwoHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberusSearch);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberus2Search);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-06 21:48:22 +00:00
|
|
|
aiThinkTarget(actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void cerberusThinkChase(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-06 21:48:22 +00:00
|
|
|
auto pXSprite = &actor->x();
|
|
|
|
auto pSprite = &actor->s();
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pXSprite->target == -1) {
|
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeCerberusTwoHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberusGoto);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberus2Goto);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
|
2020-10-11 10:38:17 +00:00
|
|
|
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) {
|
2020-10-11 10:38:17 +00:00
|
|
|
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
|
2019-10-19 19:11:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
2019-10-19 19:11:39 +00:00
|
|
|
|
2020-10-11 10:38:17 +00:00
|
|
|
///assert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
|
2019-10-19 19:11:39 +00:00
|
|
|
if (!(pXSprite->target >= 0 && pXSprite->target < kMaxSprites)) {
|
2020-10-11 10:38:17 +00:00
|
|
|
Printf(PRINT_HIGH, "pXSprite->target >= 0 && pXSprite->target < kMaxSprites");
|
2019-09-19 22:42:45 +00:00
|
|
|
return;
|
2019-10-19 19:11:39 +00:00
|
|
|
}
|
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));
|
2019-10-11 21:59:39 +00:00
|
|
|
|
|
|
|
if (pXTarget->health == 0) {
|
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeCerberusTwoHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberusSearch);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberus2Search);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
|
2019-10-19 19:11:39 +00:00
|
|
|
if (IsPlayerSprite(pTarget) && powerupCheck(&gPlayer[pTarget->type-kDudePlayer1], kPwUpShadowCloak) > 0) {
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeCerberusTwoHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberusSearch);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberus2Search);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
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))
|
|
|
|
{
|
2021-01-04 12:02:00 +00:00
|
|
|
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) {
|
2019-09-19 22:42:45 +00:00
|
|
|
aiSetTarget(pXSprite, pXSprite->target);
|
2019-10-11 21:59:39 +00:00
|
|
|
|
2021-01-04 12:02:00 +00:00
|
|
|
if (nDist < 0x1b00 && nDist > 0xd00 && abs(nDeltaAngle) < 85) {
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeCerberusTwoHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberusBurn);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberus2Burn);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
|
2021-01-04 12:02:00 +00:00
|
|
|
else if (nDist < 0xb00 && nDist > 0x500 && abs(nDeltaAngle) < 85) {
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeCerberusTwoHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberus3Burn);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberus4Burn);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
2021-01-04 12:02:00 +00:00
|
|
|
else if (nDist < 0x200 && abs(nDeltaAngle) < 85)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeCerberusTwoHead:
|
|
|
|
switch (hit) {
|
|
|
|
case -1:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberusBite);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeHellHound)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberusBite);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
default:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberusBite);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeCerberusOneHead:
|
|
|
|
switch (hit) {
|
|
|
|
case -1:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberus2Bite);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (pSprite->type != sprite[gHitInfo.hitsprite].type && sprite[gHitInfo.hitsprite].type != kDudeHellHound)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberus2Bite);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
default:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberus2Bite);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeCerberusTwoHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberusGoto);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &cerberus2Goto);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
pXSprite->target = -1;
|
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|