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 gillThinkSearch(DBloodActor*);
|
|
|
|
static void gillThinkGoto(DBloodActor*);
|
|
|
|
static void gillThinkChase(DBloodActor*);
|
|
|
|
static void gillThinkSwimGoto(DBloodActor*);
|
|
|
|
static void gillThinkSwimChase(DBloodActor*);
|
|
|
|
static void sub_6CB00(DBloodActor*);
|
|
|
|
static void sub_6CD74(DBloodActor*);
|
|
|
|
static void sub_6D03C(DBloodActor*);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
AISTATE gillBeastIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE gillBeastChase = { kAiStateChase, 9, -1, 0, NULL, aiMoveForward, gillThinkChase, NULL };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE gillBeastDodge = { kAiStateMove, 9, -1, 90, NULL, aiMoveDodge, NULL, &gillBeastChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE gillBeastGoto = { kAiStateMove, 9, -1, 600, NULL, aiMoveForward, gillThinkGoto, &gillBeastIdle };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE gillBeastBite = { kAiStateChase, 6, nGillBiteClient, 120, NULL, NULL, NULL, &gillBeastChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE gillBeastSearch = { kAiStateMove, 9, -1, 120, NULL, aiMoveForward, gillThinkSearch, &gillBeastIdle };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE gillBeastRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &gillBeastDodge };
|
|
|
|
AISTATE gillBeastSwimIdle = { kAiStateIdle, 10, -1, 0, NULL, NULL, aiThinkTarget, NULL };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE gillBeastSwimChase = { kAiStateChase, 10, -1, 0, NULL, sub_6CB00, gillThinkSwimChase, NULL };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE gillBeastSwimDodge = { kAiStateMove, 10, -1, 90, NULL, aiMoveDodge, NULL, &gillBeastSwimChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE gillBeastSwimGoto = { kAiStateMove, 10, -1, 600, NULL, aiMoveForward, gillThinkSwimGoto, &gillBeastSwimIdle };
|
|
|
|
AISTATE gillBeastSwimSearch = { kAiStateSearch, 10, -1, 120, NULL, aiMoveForward, gillThinkSearch, &gillBeastSwimIdle };
|
|
|
|
AISTATE gillBeastSwimBite = { kAiStateChase, 7, nGillBiteClient, 0, NULL, NULL, gillThinkSwimChase, &gillBeastSwimChase };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE gillBeastSwimRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &gillBeastSwimDodge };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE gillBeast13A138 = { kAiStateOther, 10, -1, 120, NULL, sub_6CD74, gillThinkSwimChase, &gillBeastSwimChase };
|
|
|
|
AISTATE gillBeast13A154 = { kAiStateOther, 10, -1, 0, NULL, sub_6D03C, gillThinkSwimChase, &gillBeastSwimChase };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE gillBeast13A170 = { kAiStateOther, 10, -1, 120, NULL, NULL, aiMoveTurn, &gillBeastSwimChase };
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void GillBiteSeqCallback(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:02:43 +00:00
|
|
|
auto target = actor->GetTarget();
|
2022-08-16 21:15:49 +00:00
|
|
|
int dx = bcos(actor->int_ang());
|
|
|
|
int dy = bsin(actor->int_ang());
|
2022-01-30 17:09:26 +00:00
|
|
|
int dz = actor->int_pos().Z - target->int_pos().Z;
|
2021-09-16 19:59:39 +00:00
|
|
|
dx += Random3(2000);
|
|
|
|
dy += Random3(2000);
|
|
|
|
actFireVector(actor, 0, 0, dx, dy, dz, kVectorGillBite);
|
|
|
|
actFireVector(actor, 0, 0, dx, dy, dz, kVectorGillBite);
|
|
|
|
actFireVector(actor, 0, 0, dx, dy, dz, kVectorGillBite);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void gillThinkSearch(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-22 21:49:50 +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 gillThinkGoto(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
|
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
2021-11-19 17:35:55 +00:00
|
|
|
|
2021-12-30 15:51:56 +00:00
|
|
|
auto pSector = actor->sector();
|
2021-11-19 17:35:55 +00:00
|
|
|
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
|
|
|
|
|
2022-08-22 16:31:23 +00:00
|
|
|
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
|
|
|
|
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nAngle = getangle(dx, dy);
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
aiChooseDirection(actor, nAngle);
|
2022-08-16 21:15:49 +00:00
|
|
|
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &gillBeastSearch);
|
|
|
|
}
|
|
|
|
aiThinkTarget(actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void gillThinkChase(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-30 15:51:56 +00:00
|
|
|
auto pSector = actor->sector();
|
2021-11-19 17:35:55 +00:00
|
|
|
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
|
|
|
|
|
2021-09-16 19:59:39 +00:00
|
|
|
if (actor->GetTarget() == nullptr)
|
|
|
|
{
|
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &gillBeastSearch);
|
|
|
|
return;
|
|
|
|
}
|
2021-12-22 19:22:35 +00:00
|
|
|
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
|
|
|
|
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();
|
2022-01-30 17:09:26 +00:00
|
|
|
int dx = target->int_pos().X - actor->int_pos().X;
|
|
|
|
int dy = target->int_pos().Y - actor->int_pos().Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
aiChooseDirection(actor, getangle(dx, dy));
|
2021-12-22 21:49:50 +00:00
|
|
|
if (actor->xspr.health == 0)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &gillBeastSearch);
|
|
|
|
return;
|
|
|
|
}
|
2021-12-22 19:02:43 +00:00
|
|
|
if (target->IsPlayerActor() && powerupCheck(&gPlayer[target->spr.type - kDudePlayer1], kPwUpShadowCloak) > 0)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &gillBeastSearch);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
if (nDist <= pDudeInfo->seeDist)
|
|
|
|
{
|
2022-08-16 21:17:01 +00:00
|
|
|
int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->int_ang()) & 2047) - 1024;
|
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());
|
2022-01-30 17:09:26 +00:00
|
|
|
actor->dudeSlope = nDist == 0 ? 0 : DivScale(target->int_pos().Z - actor->int_pos().Z, nDist, 10);
|
2021-09-16 19:59:39 +00:00
|
|
|
if (nDist < 921 && abs(nDeltaAngle) < 28)
|
|
|
|
{
|
2022-01-30 17:09:26 +00:00
|
|
|
int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0);
|
2021-09-16 19:59:39 +00:00
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &gillBeastSwimBite);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &gillBeastBite);
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-12-22 19:22:35 +00:00
|
|
|
if (actor->spr.type != gHitInfo.actor()->spr.type)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &gillBeastSwimBite);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &gillBeastBite);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &gillBeastSwimDodge);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &gillBeastDodge);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &gillBeastSwimBite);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &gillBeastBite);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2021-09-16 19:59:39 +00:00
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &gillBeastSwimGoto);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &gillBeastGoto);
|
|
|
|
sfxPlay3DSound(actor, 1701, -1, 0);
|
|
|
|
actor->SetTarget(nullptr);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void gillThinkSwimGoto(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
|
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
2022-08-22 16:31:23 +00:00
|
|
|
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
|
|
|
|
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nAngle = getangle(dx, dy);
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
aiChooseDirection(actor, nAngle);
|
2022-08-16 21:15:49 +00:00
|
|
|
if (nDist < 512 && abs(actor->int_ang() - nAngle) < pDudeInfo->periphery)
|
2021-09-16 19:59:39 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
|
|
|
aiThinkTarget(actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void gillThinkSwimChase(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
if (actor->GetTarget() == nullptr)
|
|
|
|
{
|
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
|
|
|
return;
|
|
|
|
}
|
2021-12-22 19:22:35 +00:00
|
|
|
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
|
|
|
|
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();
|
2022-01-30 17:09:26 +00:00
|
|
|
int dx = target->int_pos().X - actor->int_pos().X;
|
|
|
|
int dy = target->int_pos().Y - actor->int_pos().Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
aiChooseDirection(actor, getangle(dx, dy));
|
2021-12-22 21:49:50 +00:00
|
|
|
if (actor->xspr.health == 0)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
|
|
|
return;
|
|
|
|
}
|
2021-12-22 19:02:43 +00:00
|
|
|
if (target->IsPlayerActor() && powerupCheck(&gPlayer[target->spr.type - kDudePlayer1], kPwUpShadowCloak) > 0)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
if (nDist <= pDudeInfo->seeDist)
|
|
|
|
{
|
2022-08-16 21:17:01 +00:00
|
|
|
int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->int_ang()) & 2047) - 1024;
|
2022-08-22 16:36:41 +00:00
|
|
|
double height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) * REPEAT_SCALE;
|
2021-09-16 19:59:39 +00:00
|
|
|
int top, bottom;
|
|
|
|
GetActorExtents(actor, &top, &bottom);
|
2022-08-22 16:36:41 +00:00
|
|
|
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());
|
|
|
|
if (nDist < 0x400 && abs(nDeltaAngle) < 85)
|
|
|
|
aiNewState(actor, &gillBeastSwimBite);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aiPlay3DSound(actor, 1700, AI_SFX_PRIORITY_1, -1);
|
|
|
|
aiNewState(actor, &gillBeast13A154);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aiNewState(actor, &gillBeast13A154);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
aiNewState(actor, &gillBeastSwimGoto);
|
|
|
|
actor->SetTarget(nullptr);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void sub_6CB00(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
|
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
2022-08-16 21:17:01 +00:00
|
|
|
int nAng = ((actor->xspr.goalAng + 1024 - actor->int_ang()) & 2047) - 1024;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
|
2022-08-16 21:20:03 +00:00
|
|
|
actor->set_int_ang((actor->int_ang() + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047);
|
2021-09-16 19:59:39 +00:00
|
|
|
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 27) / 120) / 120) << 2;
|
|
|
|
if (abs(nAng) > 341)
|
|
|
|
return;
|
|
|
|
if (actor->GetTarget() == nullptr)
|
2022-08-21 17:19:47 +00:00
|
|
|
actor->spr.angle += DAngle45;
|
2022-08-22 16:31:23 +00:00
|
|
|
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
|
|
|
|
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
if (Random(64) < 32 && nDist <= 0x400)
|
|
|
|
return;
|
2022-08-16 21:15:49 +00:00
|
|
|
int nCos = Cos(actor->int_ang());
|
|
|
|
int nSin = Sin(actor->int_ang());
|
2021-12-30 10:15:27 +00:00
|
|
|
int vx = actor->vel.X;
|
2021-12-30 10:16:31 +00:00
|
|
|
int vy = actor->vel.Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
|
|
|
|
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
|
|
|
|
if (actor->GetTarget() == nullptr)
|
|
|
|
t1 += nAccel;
|
|
|
|
else
|
|
|
|
t1 += nAccel >> 2;
|
2021-12-30 10:15:27 +00:00
|
|
|
actor->vel.X = DMulScale(t1, nCos, t2, nSin, 30);
|
2021-12-30 10:16:31 +00:00
|
|
|
actor->vel.Y = DMulScale(t1, nSin, -t2, nCos, 30);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void sub_6CD74(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
|
|
|
|
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();
|
2022-01-30 17:09:26 +00:00
|
|
|
int z = actor->int_pos().Z + getDudeInfo(actor->spr.type)->eyeHeight;
|
|
|
|
int z2 = target->int_pos().Z + getDudeInfo(target->spr.type)->eyeHeight;
|
2022-08-16 21:17:01 +00:00
|
|
|
int nAng = ((actor->xspr.goalAng + 1024 - actor->int_ang()) & 2047) - 1024;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
|
2022-08-16 21:20:03 +00:00
|
|
|
actor->set_int_ang((actor->int_ang() + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047);
|
2021-09-16 19:59:39 +00:00
|
|
|
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 27) / 120) / 120) << 2;
|
|
|
|
if (abs(nAng) > 341)
|
|
|
|
{
|
2022-08-16 21:15:49 +00:00
|
|
|
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
|
2021-09-16 19:59:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-08-22 16:31:23 +00:00
|
|
|
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
|
|
|
|
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int dz = z2 - z;
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
if (Chance(0x600) && nDist <= 0x400)
|
|
|
|
return;
|
2022-08-16 21:15:49 +00:00
|
|
|
int nCos = Cos(actor->int_ang());
|
|
|
|
int nSin = Sin(actor->int_ang());
|
2021-12-30 10:15:27 +00:00
|
|
|
int vx = actor->vel.X;
|
2021-12-30 10:16:31 +00:00
|
|
|
int vy = actor->vel.Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
|
|
|
|
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
|
|
|
|
t1 += nAccel;
|
2021-12-30 10:15:27 +00:00
|
|
|
actor->vel.X = DMulScale(t1, nCos, t2, nSin, 30);
|
2021-12-30 10:16:31 +00:00
|
|
|
actor->vel.Y = DMulScale(t1, nSin, -t2, nCos, 30);
|
2021-12-30 10:17:28 +00:00
|
|
|
actor->vel.Z = -dz;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void sub_6D03C(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
|
|
|
|
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();
|
2022-01-30 17:09:26 +00:00
|
|
|
int z = actor->int_pos().Z + getDudeInfo(actor->spr.type)->eyeHeight;
|
|
|
|
int z2 = target->int_pos().Z + getDudeInfo(target->spr.type)->eyeHeight;
|
2022-08-16 21:17:01 +00:00
|
|
|
int nAng = ((actor->xspr.goalAng + 1024 - actor->int_ang()) & 2047) - 1024;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
|
2022-08-16 21:20:03 +00:00
|
|
|
actor->set_int_ang((actor->int_ang() + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047);
|
2021-09-16 19:59:39 +00:00
|
|
|
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 27) / 120) / 120) << 2;
|
|
|
|
if (abs(nAng) > 341)
|
|
|
|
{
|
2022-08-21 17:19:47 +00:00
|
|
|
actor->spr.angle += DAngle90;
|
2021-09-16 19:59:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-08-22 16:31:23 +00:00
|
|
|
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
|
|
|
|
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int dz = (z2 - z) << 3;
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
if (Chance(0x4000) && nDist <= 0x400)
|
|
|
|
return;
|
2022-08-16 21:15:49 +00:00
|
|
|
int nCos = Cos(actor->int_ang());
|
|
|
|
int nSin = Sin(actor->int_ang());
|
2021-12-30 10:15:27 +00:00
|
|
|
int vx = actor->vel.X;
|
2021-12-30 10:16:31 +00:00
|
|
|
int vy = actor->vel.Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
|
|
|
|
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
|
|
|
|
t1 += nAccel >> 1;
|
2021-12-30 10:15:27 +00:00
|
|
|
actor->vel.X = DMulScale(t1, nCos, t2, nSin, 30);
|
2021-12-30 10:16:31 +00:00
|
|
|
actor->vel.Y = DMulScale(t1, nSin, -t2, nCos, 30);
|
2021-12-30 10:17:28 +00:00
|
|
|
actor->vel.Z = dz;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|