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 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
|
|
|
{
|
2022-08-16 21:15:49 +00:00
|
|
|
int dx = bcos(actor->int_ang());
|
|
|
|
int dy = bsin(actor->int_ang());
|
2021-12-22 19:22:35 +00:00
|
|
|
if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
|
|
|
|
Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
|
2021-09-16 19:59:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!actor->ValidateTarget(__FUNCTION__)) return;
|
2021-12-22 19:02:43 +00:00
|
|
|
auto target = actor->GetTarget();
|
2022-01-30 17:09:26 +00:00
|
|
|
int dz = target->int_pos().Z - actor->int_pos().Z;
|
2021-09-16 19:59:39 +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
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
|
|
|
int height = pDudeInfo->eyeHeight * actor->spr.yrepeat;
|
2021-09-16 19:59:39 +00:00
|
|
|
if (!actor->ValidateTarget(__FUNCTION__)) return;
|
2021-09-16 17:28:42 +00:00
|
|
|
|
2022-01-30 17:09:26 +00:00
|
|
|
int x = actor->int_pos().X;
|
|
|
|
int y = actor->int_pos().Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int z = height; // ???
|
|
|
|
TARGETTRACK tt1 = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa };
|
|
|
|
Aim aim;
|
2022-08-16 21:15:49 +00:00
|
|
|
aim.dx = bcos(actor->int_ang());
|
|
|
|
aim.dy = bsin(actor->int_ang());
|
2021-09-16 19:59:39 +00:00
|
|
|
aim.dz = actor->dudeSlope;
|
|
|
|
int nClosest = 0x7fffffff;
|
|
|
|
BloodStatIterator it(kStatDude);
|
|
|
|
while (auto actor2 = it.Next())
|
|
|
|
{
|
2021-12-22 19:30:29 +00:00
|
|
|
if (actor == actor2 || !(actor2->spr.flags & 8))
|
2021-09-16 19:59:39 +00:00
|
|
|
continue;
|
2022-01-30 17:09:26 +00:00
|
|
|
int x2 = actor2->int_pos().X;
|
|
|
|
int y2 = actor2->int_pos().Y;
|
|
|
|
int z2 = actor2->int_pos().Z;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nDist = approxDist(x2 - x, y2 - y);
|
|
|
|
if (nDist == 0 || nDist > 0x2800)
|
|
|
|
continue;
|
|
|
|
if (tt1.at10)
|
|
|
|
{
|
|
|
|
int t = DivScale(nDist, tt1.at10, 12);
|
2022-09-01 18:56:12 +00:00
|
|
|
x2 += (actor2->int_vel().X * t) >> 12;
|
|
|
|
y2 += (actor2->int_vel().Y * t) >> 12;
|
|
|
|
z2 += (actor2->int_vel().Z * t) >> 8;
|
2021-09-16 19:59:39 +00:00
|
|
|
}
|
2022-08-16 21:17:01 +00:00
|
|
|
int tx = x + MulScale(Cos(actor->int_ang()), nDist, 30);
|
|
|
|
int ty = y + MulScale(Sin(actor->int_ang()), nDist, 30);
|
2021-09-16 19:59:39 +00:00
|
|
|
int tz = z + MulScale(actor->dudeSlope, nDist, 10);
|
|
|
|
int tsr = MulScale(9460, nDist, 10);
|
|
|
|
int top, bottom;
|
2021-12-22 19:30:29 +00:00
|
|
|
GetActorExtents(actor2, &top, &bottom);
|
2021-09-16 19:59:39 +00:00
|
|
|
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);
|
2022-08-16 21:15:49 +00:00
|
|
|
int nDeltaAngle = ((nAngle - actor->int_ang() + 1024) & 2047) - 1024;
|
2021-09-16 19:59:39 +00:00
|
|
|
if (abs(nDeltaAngle) <= tt1.at8)
|
|
|
|
{
|
2022-01-30 17:09:26 +00:00
|
|
|
int tz1 = actor2->int_pos().Z - actor->int_pos().Z;
|
2021-12-30 15:51:56 +00:00
|
|
|
if (cansee(x, y, z, actor->sector(), x2, y2, z2, actor2->sector()))
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
nClosest = nDist2;
|
2021-10-30 06:22:27 +00:00
|
|
|
aim.dx = bcos(nAngle);
|
2021-10-30 06:22:17 +00:00
|
|
|
aim.dy = bsin(nAngle);
|
2021-12-24 09:25:18 +00:00
|
|
|
aim.dz = DivScale(tz1, nDist, 10);
|
2021-09-16 19:59:39 +00:00
|
|
|
}
|
|
|
|
else
|
2021-12-24 09:25:18 +00:00
|
|
|
aim.dz = tz1;
|
2021-09-16 19:59:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudeCerberusTwoHead:
|
2021-12-29 18:41:41 +00:00
|
|
|
actFireMissile(actor, -350, 0, aim.dx, aim.dy, aim.dz, kMissileFireballCerberus);
|
|
|
|
actFireMissile(actor, 350, -100, aim.dx, aim.dy, aim.dz, kMissileFireballCerberus);
|
2021-09-16 19:59:39 +00:00
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
2021-12-29 18:41:41 +00:00
|
|
|
actFireMissile(actor, 350, -100, aim.dx, aim.dy, aim.dz, kMissileFireballCerberus);
|
2021-09-16 19:59:39 +00:00
|
|
|
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
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
if (!actor->ValidateTarget(__FUNCTION__)) return;
|
2021-12-22 19:22:35 +00:00
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
|
|
|
int height = pDudeInfo->eyeHeight * actor->spr.yrepeat;
|
2021-09-16 19:59:39 +00:00
|
|
|
|
2022-01-30 17:09:26 +00:00
|
|
|
int x = actor->int_pos().X;
|
|
|
|
int y = actor->int_pos().Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int z = height; // ???
|
|
|
|
TARGETTRACK tt1 = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa };
|
|
|
|
Aim aim;
|
|
|
|
int ax, ay, az;
|
2022-08-16 21:15:49 +00:00
|
|
|
aim.dx = ax = bcos(actor->int_ang());
|
|
|
|
aim.dy = ay = bsin(actor->int_ang());
|
2021-09-16 19:59:39 +00:00
|
|
|
aim.dz = actor->dudeSlope;
|
|
|
|
az = 0;
|
|
|
|
int nClosest = 0x7fffffff;
|
|
|
|
BloodStatIterator it(kStatDude);
|
|
|
|
while (auto actor2 = it.Next())
|
|
|
|
{
|
2021-12-22 19:13:19 +00:00
|
|
|
if (actor == actor2 || !(actor2->spr.flags & 8))
|
2021-09-16 19:59:39 +00:00
|
|
|
continue;
|
2022-01-30 17:09:26 +00:00
|
|
|
int x2 = actor2->int_pos().X;
|
|
|
|
int y2 = actor2->int_pos().Y;
|
|
|
|
int z2 = actor2->int_pos().Z;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nDist = approxDist(x2 - x, y2 - y);
|
|
|
|
if (nDist == 0 || nDist > 0x2800)
|
|
|
|
continue;
|
|
|
|
if (tt1.at10)
|
|
|
|
{
|
|
|
|
int t = DivScale(nDist, tt1.at10, 12);
|
2022-09-01 18:56:12 +00:00
|
|
|
x2 += (actor->int_vel().X * t) >> 12;
|
|
|
|
y2 += (actor->int_vel().Y * t) >> 12;
|
|
|
|
z2 += (actor->int_vel().Z * t) >> 8;
|
2021-09-16 19:59:39 +00:00
|
|
|
}
|
2022-08-16 21:17:01 +00:00
|
|
|
int tx = x + MulScale(Cos(actor->int_ang()), nDist, 30);
|
|
|
|
int ty = y + MulScale(Sin(actor->int_ang()), nDist, 30);
|
2021-09-16 19:59:39 +00:00
|
|
|
int tz = z + MulScale(actor->dudeSlope, nDist, 10);
|
|
|
|
int tsr = MulScale(9460, nDist, 10);
|
|
|
|
int top, bottom;
|
|
|
|
GetActorExtents(actor2, &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);
|
2022-08-16 21:15:49 +00:00
|
|
|
int nDeltaAngle = ((nAngle - actor->int_ang() + 1024) & 2047) - 1024;
|
2021-09-16 19:59:39 +00:00
|
|
|
if (abs(nDeltaAngle) <= tt1.at8)
|
|
|
|
{
|
2021-12-22 19:13:19 +00:00
|
|
|
DUDEINFO* pDudeInfo2 = getDudeInfo(actor2->spr.type);
|
2021-12-24 09:25:18 +00:00
|
|
|
int height1 = (pDudeInfo2->aimHeight * actor2->spr.yrepeat) << 2;
|
|
|
|
int tz1 = (z2 - height1) - z;
|
2021-12-30 15:51:56 +00:00
|
|
|
if (cansee(x, y, z, actor->sector(), x2, y2, z2, actor2->sector()))
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
nClosest = nDist2;
|
2021-10-30 06:22:27 +00:00
|
|
|
aim.dx = bcos(nAngle);
|
2021-10-30 06:22:17 +00:00
|
|
|
aim.dy = bsin(nAngle);
|
2021-12-24 09:25:18 +00:00
|
|
|
aim.dz = DivScale(tz1, nDist, 10);
|
2021-09-16 19:59:39 +00:00
|
|
|
}
|
|
|
|
else
|
2021-12-24 09:25:18 +00:00
|
|
|
aim.dz = tz1;
|
2021-09-16 19:59:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudeCerberusTwoHead:
|
2021-12-29 18:41:41 +00:00
|
|
|
actFireMissile(actor, 350, -100, aim.dx, aim.dy, -aim.dz, kMissileFlameHound);
|
|
|
|
actFireMissile(actor, -350, 0, ax, ay, az, kMissileFlameHound);
|
2021-09-16 19:59:39 +00:00
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
2021-12-29 18:41:41 +00:00
|
|
|
actFireMissile(actor, 350, -100, aim.dx, aim.dy, -aim.dz, kMissileFlameHound);
|
2021-09-16 19:59:39 +00:00
|
|
|
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
|
|
|
{
|
2022-09-03 22:38:26 +00:00
|
|
|
aiChooseDirection(actor, actor->xspr.goalAng);
|
2021-09-16 19:59:39 +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
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
|
|
|
|
Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
|
2021-09-16 19:59:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-22 19:22:35 +00:00
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
2021-09-16 19:59:39 +00:00
|
|
|
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
|
|
|
|
if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10)
|
|
|
|
pDudeExtraE->thinkTime++;
|
|
|
|
else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active)
|
|
|
|
{
|
2022-09-03 22:38:26 +00:00
|
|
|
actor->xspr.goalAng += DAngle45;
|
2022-08-10 22:13:36 +00:00
|
|
|
aiSetTarget(actor, actor->basePoint);
|
2021-12-22 19:22:35 +00:00
|
|
|
if (actor->spr.type == kDudeCerberusTwoHead)
|
2021-09-16 19:59:39 +00:00
|
|
|
aiNewState(actor, &cerberus139890);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &cerberus1398AC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Chance(pDudeInfo->alertChance))
|
|
|
|
{
|
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p])
|
|
|
|
{
|
|
|
|
PLAYER* pPlayer = &gPlayer[p];
|
2021-12-22 21:49:50 +00:00
|
|
|
if (pPlayer->actor->xspr.health == 0 || powerupCheck(pPlayer, kPwUpShadowCloak) > 0)
|
2021-09-16 19:59:39 +00:00
|
|
|
continue;
|
2022-08-22 16:36:41 +00:00
|
|
|
auto ppos = pPlayer->actor->spr.pos;
|
2022-08-23 20:31:50 +00:00
|
|
|
auto dvect = ppos.XY() - actor->spr.pos;
|
2021-12-30 15:51:56 +00:00
|
|
|
auto pSector = pPlayer->actor->sector();
|
2022-08-23 20:31:50 +00:00
|
|
|
int nDist = approxDist(dvect);
|
2021-09-16 19:59:39 +00:00
|
|
|
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
|
|
|
|
continue;
|
2022-08-22 16:36:41 +00:00
|
|
|
double height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) * REPEAT_SCALE;
|
|
|
|
if (!cansee(ppos, pSector, actor->spr.pos.plusZ(-height), actor->sector()))
|
2021-09-16 19:59:39 +00:00
|
|
|
continue;
|
2022-08-29 00:55:16 +00:00
|
|
|
int nDeltaAngle = getincangle(actor->int_ang(), getangle(dvect));
|
2021-09-16 19:59:39 +00:00
|
|
|
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
|
|
|
|
{
|
|
|
|
pDudeExtraE->thinkTime = 0;
|
2021-12-29 18:41:41 +00:00
|
|
|
aiSetTarget(actor, pPlayer->actor);
|
2021-09-16 19:59:39 +00:00
|
|
|
aiActivateDude(actor);
|
|
|
|
}
|
|
|
|
else if (nDist < pDudeInfo->hearDist)
|
|
|
|
{
|
|
|
|
pDudeExtraE->thinkTime = 0;
|
2022-08-23 20:31:50 +00:00
|
|
|
aiSetTarget(actor, ppos);
|
2021-09-16 19:59:39 +00:00
|
|
|
aiActivateDude(actor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void cerberusThinkGoto(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
|
|
|
|
Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
|
2021-09-16 19:59:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-22 19:22:35 +00:00
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
2022-08-23 20:29:05 +00:00
|
|
|
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
|
|
|
int nAngle = getangle(dvec);
|
2022-09-26 22:44:51 +00:00
|
|
|
double nDist = dvec.Length();
|
2022-09-03 22:38:26 +00:00
|
|
|
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
2022-09-26 22:44:51 +00:00
|
|
|
if (nDist < 32 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudeCerberusTwoHead:
|
|
|
|
aiNewState(actor, &cerberusSearch);
|
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
|
|
|
aiNewState(actor, &cerberus2Search);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
if (actor->GetTarget() == nullptr) {
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudeCerberusTwoHead:
|
|
|
|
aiNewState(actor, &cerberusGoto);
|
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
|
|
|
aiNewState(actor, &cerberus2Goto);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-22 19:22:35 +00:00
|
|
|
///assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
|
|
|
|
if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
|
|
|
|
Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
|
2021-09-16 19:59:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-22 19:22:35 +00:00
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
2021-09-16 19:59:39 +00:00
|
|
|
|
|
|
|
if (!actor->ValidateTarget(__FUNCTION__)) return;
|
2021-12-22 19:02:43 +00:00
|
|
|
auto target = actor->GetTarget();
|
2021-12-29 18:41:41 +00:00
|
|
|
|
2022-08-23 20:30:40 +00:00
|
|
|
auto dvec = target->spr.pos.XY() - actor->spr.pos.XY();
|
|
|
|
int nAngle = getangle(dvec);
|
|
|
|
int nDist = approxDist(dvec);
|
2022-09-03 22:38:26 +00:00
|
|
|
aiChooseDirection(actor, DAngle::fromBuild(nAngle));
|
2019-10-19 19:11:39 +00:00
|
|
|
|
2021-12-22 19:48:11 +00:00
|
|
|
if (target->xspr.health == 0) {
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudeCerberusTwoHead:
|
|
|
|
aiNewState(actor, &cerberusSearch);
|
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
|
|
|
aiNewState(actor, &cerberus2Search);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-10-19 19:11:39 +00:00
|
|
|
|
2021-12-22 19:02:43 +00:00
|
|
|
if (target->IsPlayerActor() && powerupCheck(&gPlayer[target->spr.type - kDudePlayer1], kPwUpShadowCloak) > 0) {
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudeCerberusTwoHead:
|
|
|
|
aiNewState(actor, &cerberusSearch);
|
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
|
|
|
aiNewState(actor, &cerberus2Search);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
|
2022-08-23 20:30:40 +00:00
|
|
|
|
2021-09-16 19:59:39 +00:00
|
|
|
if (nDist <= pDudeInfo->seeDist)
|
|
|
|
{
|
2022-08-29 00:55:16 +00:00
|
|
|
int nDeltaAngle = getincangle(actor->int_ang(), nAngle);
|
2022-08-22 16:36:41 +00:00
|
|
|
double height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) * REPEAT_SCALE;
|
|
|
|
if (cansee(target->spr.pos, target->sector(), actor->spr.pos.plusZ(-height), actor->sector()))
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) {
|
|
|
|
aiSetTarget(actor, actor->GetTarget());
|
2019-10-11 21:59:39 +00:00
|
|
|
|
2021-09-16 19:59:39 +00:00
|
|
|
if (nDist < 0x1b00 && nDist > 0xd00 && abs(nDeltaAngle) < 85) {
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudeCerberusTwoHead:
|
|
|
|
aiNewState(actor, &cerberusBurn);
|
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
|
|
|
aiNewState(actor, &cerberus2Burn);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
|
2021-09-16 19:59:39 +00:00
|
|
|
else if (nDist < 0xb00 && nDist > 0x500 && abs(nDeltaAngle) < 85) {
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudeCerberusTwoHead:
|
|
|
|
aiNewState(actor, &cerberus3Burn);
|
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
|
|
|
aiNewState(actor, &cerberus4Burn);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nDist < 0x200 && abs(nDeltaAngle) < 85)
|
|
|
|
{
|
2022-08-23 20:30:40 +00:00
|
|
|
int dx = dvec.X * worldtoint;
|
|
|
|
int dy = dvec.Y * worldtoint;
|
2022-08-23 20:45:42 +00:00
|
|
|
int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0);
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudeCerberusTwoHead:
|
|
|
|
switch (hit) {
|
|
|
|
case -1:
|
|
|
|
aiNewState(actor, &cerberusBite);
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-12-22 19:22:35 +00:00
|
|
|
if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeHellHound)
|
2021-09-16 19:59:39 +00:00
|
|
|
aiNewState(actor, &cerberusBite);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(actor, &cerberusBite);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
|
|
|
switch (hit) {
|
|
|
|
case -1:
|
|
|
|
aiNewState(actor, &cerberus2Bite);
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-12-22 19:22:35 +00:00
|
|
|
if (actor->spr.type != gHitInfo.actor()->spr.type && gHitInfo.actor()->spr.type != kDudeHellHound)
|
2021-09-16 19:59:39 +00:00
|
|
|
aiNewState(actor, &cerberus2Bite);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aiNewState(actor, &cerberus2Bite);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudeCerberusTwoHead:
|
|
|
|
aiNewState(actor, &cerberusGoto);
|
|
|
|
break;
|
|
|
|
case kDudeCerberusOneHead:
|
|
|
|
aiNewState(actor, &cerberus2Goto);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
actor->SetTarget(nullptr);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|