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 calebThinkSearch(DBloodActor*);
|
|
|
|
static void calebThinkGoto(DBloodActor*);
|
|
|
|
static void calebThinkChase(DBloodActor*);
|
|
|
|
static void calebThinkSwimGoto(DBloodActor*);
|
|
|
|
static void calebThinkSwimChase(DBloodActor*);
|
|
|
|
static void sub_65D04(DBloodActor*);
|
|
|
|
static void sub_65F44(DBloodActor*);
|
|
|
|
static void sub_661E0(DBloodActor*);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
AISTATE tinycalebIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE tinycalebChase = { kAiStateChase, 6, -1, 0, NULL, aiMoveForward, calebThinkChase, NULL };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE tinycalebDodge = { kAiStateMove, 6, -1, 90, NULL, aiMoveDodge, NULL, &tinycalebChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE tinycalebGoto = { kAiStateMove, 6, -1, 600, NULL, aiMoveForward, calebThinkGoto, &tinycalebIdle };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE tinycalebAttack = { kAiStateChase, 0, nAttackClient, 120, NULL, NULL, NULL, &tinycalebChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE tinycalebSearch = { kAiStateSearch, 6, -1, 120, NULL, aiMoveForward, calebThinkSearch, &tinycalebIdle };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE tinycalebRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &tinycalebDodge };
|
|
|
|
AISTATE tinycalebTeslaRecoil = { kAiStateRecoil, 4, -1, 0, NULL, NULL, NULL, &tinycalebDodge };
|
|
|
|
AISTATE tinycalebSwimIdle = { kAiStateIdle, 10, -1, 0, NULL, NULL, aiThinkTarget, NULL };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE tinycalebSwimChase = { kAiStateChase, 8, -1, 0, NULL, sub_65D04, calebThinkSwimChase, NULL };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE tinycalebSwimDodge = { kAiStateMove, 8, -1, 90, NULL, aiMoveDodge, NULL, &tinycalebSwimChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE tinycalebSwimGoto = { kAiStateMove, 8, -1, 600, NULL, aiMoveForward, calebThinkSwimGoto, &tinycalebSwimIdle };
|
|
|
|
AISTATE tinycalebSwimSearch = { kAiStateSearch, 8, -1, 120, NULL, aiMoveForward, calebThinkSearch, &tinycalebSwimIdle };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE tinycalebSwimAttack = { kAiStateChase, 10, nAttackClient, 0, NULL, NULL, NULL, &tinycalebSwimChase };
|
|
|
|
AISTATE tinycalebSwimRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &tinycalebSwimDodge };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE tinycaleb139660 = { kAiStateOther, 8, -1, 120, NULL, sub_65F44, calebThinkSwimChase, &tinycalebSwimChase };
|
|
|
|
AISTATE tinycaleb13967C = { kAiStateOther, 8, -1, 0, NULL, sub_661E0, calebThinkSwimChase, &tinycalebSwimChase };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE tinycaleb139698 = { kAiStateOther, 8, -1, 120, NULL, aiMoveTurn, NULL, &tinycalebSwimChase };
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void SeqAttackCallback(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
int dx = bcos(actor->spr.ang);
|
|
|
|
int dy = bsin(actor->spr.ang);
|
2021-09-16 19:59:39 +00:00
|
|
|
int dz = actor->dudeSlope;
|
|
|
|
dx += Random2(1500);
|
|
|
|
dy += Random2(1500);
|
|
|
|
dz += Random2(1500);
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
{
|
|
|
|
int r1 = Random3(500);
|
|
|
|
int r2 = Random3(1000);
|
|
|
|
int r3 = Random3(1000);
|
|
|
|
actFireVector(actor, 0, 0, dx + r3, dy + r2, dz + r1, kVectorShell);
|
|
|
|
}
|
|
|
|
if (Chance(0x8000))
|
|
|
|
sfxPlay3DSound(actor, 10000 + Random(5), -1, 0);
|
|
|
|
if (Chance(0x8000))
|
|
|
|
sfxPlay3DSound(actor, 1001, -1, 0);
|
|
|
|
else
|
|
|
|
sfxPlay3DSound(actor, 1002, -1, 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void calebThinkSearch(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 calebThinkGoto(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-22 19:22:35 +00:00
|
|
|
auto pSector = actor->spr.sector();
|
2021-11-19 17:35:55 +00:00
|
|
|
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
|
|
|
|
|
2021-12-22 21:49:50 +00:00
|
|
|
int dx = actor->xspr.targetX - actor->spr.pos.X;
|
|
|
|
int dy = actor->xspr.targetY - actor->spr.pos.Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nAngle = getangle(dx, dy);
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
aiChooseDirection(actor, nAngle);
|
2021-12-22 19:22:35 +00:00
|
|
|
if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &tinycalebSwimSearch);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &tinycalebSearch);
|
|
|
|
}
|
|
|
|
aiThinkTarget(actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void calebThinkChase(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
auto pSector = actor->spr.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, &tinycalebSwimSearch);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &tinycalebSearch);
|
|
|
|
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-12-22 19:02:43 +00:00
|
|
|
auto target = actor->GetTarget();
|
2021-12-22 19:48:11 +00:00
|
|
|
|
2021-12-22 19:22:35 +00:00
|
|
|
int dx = target->spr.pos.X - actor->spr.pos.X;
|
|
|
|
int dy = target->spr.pos.Y - actor->spr.pos.Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
aiChooseDirection(actor, getangle(dx, dy));
|
2021-12-22 19:48:11 +00:00
|
|
|
if (target->xspr.health == 0)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &tinycalebSwimSearch);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aiPlay3DSound(actor, 11000 + Random(4), AI_SFX_PRIORITY_1, -1);
|
|
|
|
aiNewState(actor, &tinycalebSearch);
|
|
|
|
}
|
|
|
|
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, &tinycalebSwimSearch);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &tinycalebSearch);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
if (nDist <= pDudeInfo->seeDist)
|
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
|
|
|
|
int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat) << 2;
|
|
|
|
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.sector()))
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
|
|
|
|
{
|
|
|
|
aiSetTarget(actor, actor->GetTarget());
|
2021-12-22 19:22:35 +00:00
|
|
|
actor->dudeSlope = nDist == 0 ? 0 : DivScale(target->spr.pos.Z-actor->spr.pos.Z, nDist, 10);
|
2021-09-16 19:59:39 +00:00
|
|
|
if (nDist < 0x599 && abs(nDeltaAngle) < 28)
|
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
int hit = HitScan(actor, actor->spr.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, &tinycalebSwimAttack);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &tinycalebAttack);
|
|
|
|
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, &tinycalebSwimAttack);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &tinycalebAttack);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &tinycalebSwimDodge);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &tinycalebDodge);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &tinycalebSwimAttack);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &tinycalebAttack);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2021-09-16 19:59:39 +00:00
|
|
|
if (pXSector && pXSector->Underwater)
|
|
|
|
aiNewState(actor, &tinycalebSwimGoto);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &tinycalebGoto);
|
|
|
|
if (Chance(0x2000))
|
|
|
|
sfxPlay3DSound(actor, 10000 + Random(5), -1, 0);
|
|
|
|
actor->SetTarget(nullptr);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void calebThinkSwimGoto(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-12-22 21:49:50 +00:00
|
|
|
int dx = actor->xspr.targetX - actor->spr.pos.X;
|
|
|
|
int dy = actor->xspr.targetY - actor->spr.pos.Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nAngle = getangle(dx, dy);
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
aiChooseDirection(actor, nAngle);
|
2021-12-22 19:22:35 +00:00
|
|
|
if (nDist < 512 && abs(actor->spr.ang - nAngle) < pDudeInfo->periphery)
|
2021-09-16 19:59:39 +00:00
|
|
|
aiNewState(actor, &tinycalebSwimSearch);
|
|
|
|
aiThinkTarget(actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void calebThinkSwimChase(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
if (actor->GetTarget() == nullptr)
|
|
|
|
{
|
|
|
|
aiNewState(actor, &tinycalebSwimGoto);
|
|
|
|
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-12-22 19:02:43 +00:00
|
|
|
auto target = actor->GetTarget();
|
2021-12-22 19:48:11 +00:00
|
|
|
|
2021-12-22 19:22:35 +00:00
|
|
|
int dx = target->spr.pos.X - actor->spr.pos.X;
|
|
|
|
int dy = target->spr.pos.Y - actor->spr.pos.Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
aiChooseDirection(actor, getangle(dx, dy));
|
2021-12-22 19:48:11 +00:00
|
|
|
if (target->xspr.health == 0)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
aiNewState(actor, &tinycalebSwimSearch);
|
|
|
|
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, &tinycalebSwimSearch);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
if (nDist <= pDudeInfo->seeDist)
|
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
int nDeltaAngle = ((getangle(dx, dy) + 1024 - actor->spr.ang) & 2047) - 1024;
|
|
|
|
int height = pDudeInfo->eyeHeight + actor->spr.pos.Z;
|
2021-09-16 19:59:39 +00:00
|
|
|
int top, bottom;
|
|
|
|
GetActorExtents(actor, &top, &bottom);
|
2021-12-22 19:22:35 +00:00
|
|
|
if (cansee(target->spr.pos.X, target->spr.pos.Y, target->spr.pos.Z, target->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - height, actor->spr.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, &tinycalebSwimAttack);
|
|
|
|
else
|
|
|
|
aiNewState(actor, &tinycaleb13967C);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
aiNewState(actor, &tinycalebSwimGoto);
|
|
|
|
actor->SetTarget(nullptr);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void sub_65D04(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-12-22 21:49:50 +00:00
|
|
|
int nAng = ((actor->xspr.goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
|
2021-12-22 19:22:35 +00:00
|
|
|
actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nAccel = pDudeInfo->frontSpeed << 2;
|
|
|
|
if (abs(nAng) > 341)
|
|
|
|
return;
|
|
|
|
if (actor->GetTarget() == nullptr)
|
2021-12-22 19:22:35 +00:00
|
|
|
actor->spr.ang = (actor->spr.ang + 256) & 2047;
|
2021-12-22 21:49:50 +00:00
|
|
|
int dx = actor->xspr.targetX - actor->spr.pos.X;
|
|
|
|
int dy = actor->xspr.targetY - actor->spr.pos.Y;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
if (Random(64) < 32 && nDist <= 0x400)
|
|
|
|
return;
|
2021-12-22 19:22:35 +00:00
|
|
|
int nCos = Cos(actor->spr.ang);
|
|
|
|
int nSin = Sin(actor->spr.ang);
|
2021-09-04 10:52:02 +00:00
|
|
|
int vx = actor->xvel;
|
|
|
|
int vy = actor->yvel;
|
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-09-04 10:52:02 +00:00
|
|
|
actor->xvel = DMulScale(t1, nCos, t2, nSin, 30);
|
|
|
|
actor->yvel = 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_65F44(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-09-16 17:30:35 +00:00
|
|
|
|
2021-12-22 19:02:43 +00:00
|
|
|
auto target = actor->GetTarget();
|
2021-12-22 19:22:35 +00:00
|
|
|
int z = actor->spr.pos.Z + getDudeInfo(actor->spr.type)->eyeHeight;
|
2021-12-22 19:02:43 +00:00
|
|
|
int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight;
|
2021-12-22 21:49:50 +00:00
|
|
|
int nAng = ((actor->xspr.goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
|
2021-12-22 19:22:35 +00:00
|
|
|
actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nAccel = pDudeInfo->frontSpeed << 2;
|
|
|
|
if (abs(nAng) > 341)
|
|
|
|
{
|
2021-12-22 21:49:50 +00:00
|
|
|
actor->xspr.goalAng = (actor->spr.ang + 512) & 2047;
|
2021-09-16 19:59:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-22 21:49:50 +00:00
|
|
|
int dx = actor->xspr.targetX - actor->spr.pos.X;
|
|
|
|
int dy = actor->xspr.targetY - actor->spr.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;
|
2021-12-22 19:22:35 +00:00
|
|
|
int nCos = Cos(actor->spr.ang);
|
|
|
|
int nSin = Sin(actor->spr.ang);
|
2021-09-04 10:52:02 +00:00
|
|
|
int vx = actor->xvel;
|
|
|
|
int vy = actor->yvel;
|
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-09-04 10:52:02 +00:00
|
|
|
actor->xvel = DMulScale(t1, nCos, t2, nSin, 30);
|
|
|
|
actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30);
|
|
|
|
actor->zvel = -dz;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void sub_661E0(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-09-16 17:30:35 +00:00
|
|
|
|
2021-12-22 19:02:43 +00:00
|
|
|
auto target = actor->GetTarget();
|
2021-12-22 19:22:35 +00:00
|
|
|
int z = actor->spr.pos.Z + getDudeInfo(actor->spr.type)->eyeHeight;
|
2021-12-22 19:02:43 +00:00
|
|
|
int z2 = target->spr.pos.Z + getDudeInfo(target->spr.type)->eyeHeight;
|
2021-12-22 21:49:50 +00:00
|
|
|
int nAng = ((actor->xspr.goalAng + 1024 - actor->spr.ang) & 2047) - 1024;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
|
2021-12-22 19:22:35 +00:00
|
|
|
actor->spr.ang = (actor->spr.ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
|
2021-09-16 19:59:39 +00:00
|
|
|
int nAccel = pDudeInfo->frontSpeed << 2;
|
|
|
|
if (abs(nAng) > 341)
|
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
actor->spr.ang = (actor->spr.ang + 512) & 2047;
|
2021-09-16 19:59:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-22 21:49:50 +00:00
|
|
|
int dx = actor->xspr.targetX - actor->spr.pos.X;
|
|
|
|
int dy = actor->xspr.targetY - actor->spr.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;
|
2021-12-22 19:22:35 +00:00
|
|
|
int nCos = Cos(actor->spr.ang);
|
|
|
|
int nSin = Sin(actor->spr.ang);
|
2021-09-04 10:52:02 +00:00
|
|
|
int vx = actor->xvel;
|
|
|
|
int vy = actor->yvel;
|
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-09-04 10:52:02 +00:00
|
|
|
actor->xvel = DMulScale(t1, nCos, t2, nSin, 30);
|
|
|
|
actor->yvel = DMulScale(t1, nSin, -t2, nCos, 30);
|
|
|
|
actor->zvel = dz;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|