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 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
|
|
|
{
|
2020-11-07 14:16:12 +00:00
|
|
|
XSPRITE* pXSprite = &actor->x();
|
|
|
|
spritetype* pSprite = &actor->s();
|
2021-05-05 08:12:31 +00:00
|
|
|
if (!actor->ValidateTarget(__FUNCTION__)) return;
|
2021-05-05 08:22:26 +00:00
|
|
|
spritetype *pTarget = &actor->GetTarget()->s();
|
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 = pSprite->z-pTarget->z;
|
|
|
|
dx += Random3(2000);
|
|
|
|
dy += Random3(2000);
|
2021-08-30 18:28:24 +00:00
|
|
|
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
|
|
|
{
|
2020-11-06 21:48:22 +00:00
|
|
|
auto pXSprite = &actor->x();
|
|
|
|
auto pSprite = &actor->s();
|
2021-09-15 22:17:37 +00:00
|
|
|
aiChooseDirection(actor,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 gillThinkGoto(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);
|
2020-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
2019-09-19 22:42:45 +00:00
|
|
|
XSECTOR *pXSector;
|
|
|
|
int nXSector = sector[pSprite->sectnum].extra;
|
|
|
|
if (nXSector > 0)
|
|
|
|
pXSector = &xsector[nXSector];
|
|
|
|
else
|
|
|
|
pXSector = NULL;
|
|
|
|
int dx = pXSprite->targetX-pSprite->x;
|
|
|
|
int dy = pXSprite->targetY-pSprite->y;
|
|
|
|
int nAngle = getangle(dx, dy);
|
|
|
|
int nDist = approxDist(dx, dy);
|
2021-09-15 22:17:37 +00:00
|
|
|
aiChooseDirection(actor,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
|
|
|
{
|
|
|
|
if (pXSector && pXSector->Underwater)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSearch);
|
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 gillThinkChase(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();
|
2021-05-05 07:47:08 +00:00
|
|
|
if (actor->GetTarget() == nullptr)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
XSECTOR *pXSector;
|
|
|
|
int nXSector = sector[pSprite->sectnum].extra;
|
|
|
|
if (nXSector > 0)
|
|
|
|
pXSector = &xsector[nXSector];
|
|
|
|
else
|
|
|
|
pXSector = NULL;
|
|
|
|
if (pXSector && pXSector->Underwater)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSearch);
|
2019-09-19 22:42:45 +00:00
|
|
|
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);
|
2021-05-05 08:12:31 +00:00
|
|
|
if (!actor->ValidateTarget(__FUNCTION__)) return;
|
2021-05-05 08:22:26 +00:00
|
|
|
spritetype *pTarget = &actor->GetTarget()->s();
|
|
|
|
XSPRITE* pXTarget = &actor->GetTarget()->x();
|
2019-09-19 22:42:45 +00:00
|
|
|
int dx = pTarget->x-pSprite->x;
|
|
|
|
int dy = pTarget->y-pSprite->y;
|
2021-09-15 22:17:37 +00:00
|
|
|
aiChooseDirection(actor,getangle(dx, dy));
|
2019-09-19 22:42:45 +00:00
|
|
|
if (pXTarget->health == 0)
|
|
|
|
{
|
|
|
|
XSECTOR *pXSector;
|
|
|
|
int nXSector = sector[pSprite->sectnum].extra;
|
|
|
|
if (nXSector > 0)
|
|
|
|
pXSector = &xsector[nXSector];
|
|
|
|
else
|
|
|
|
pXSector = NULL;
|
|
|
|
if (pXSector && pXSector->Underwater)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSearch);
|
2019-09-19 22:42:45 +00:00
|
|
|
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
|
|
|
{
|
|
|
|
XSECTOR *pXSector;
|
|
|
|
int nXSector = sector[pSprite->sectnum].extra;
|
|
|
|
if (nXSector > 0)
|
|
|
|
pXSector = &xsector[nXSector];
|
|
|
|
else
|
|
|
|
pXSector = NULL;
|
|
|
|
if (pXSector && pXSector->Underwater)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSearch);
|
2019-09-19 22:42:45 +00:00
|
|
|
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))
|
|
|
|
{
|
2021-01-04 12:02:00 +00:00
|
|
|
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-05-05 07:47:08 +00:00
|
|
|
aiSetTarget(actor, actor->GetTarget());
|
2021-01-04 11:59:00 +00:00
|
|
|
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
|
2021-01-04 12:02:00 +00:00
|
|
|
if (nDist < 921 && abs(nDeltaAngle) < 28)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
XSECTOR *pXSector;
|
|
|
|
int nXSector = sector[pSprite->sectnum].extra;
|
|
|
|
if (nXSector > 0)
|
|
|
|
pXSector = &xsector[nXSector];
|
|
|
|
else
|
|
|
|
pXSector = NULL;
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
if (pXSector && pXSector->Underwater)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimBite);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastBite);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-05-05 14:43:42 +00:00
|
|
|
if (pSprite->type != gHitInfo.hitactor->s().type)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
if (pXSector && pXSector->Underwater)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimBite);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastBite);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pXSector && pXSector->Underwater)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimDodge);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastDodge);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (pXSector && pXSector->Underwater)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimBite);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastBite);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XSECTOR *pXSector;
|
|
|
|
int nXSector = sector[pSprite->sectnum].extra;
|
|
|
|
if (nXSector > 0)
|
|
|
|
pXSector = &xsector[nXSector];
|
|
|
|
else
|
|
|
|
pXSector = NULL;
|
|
|
|
if (pXSector && pXSector->Underwater)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimGoto);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastGoto);
|
2021-09-16 19:34:16 +00:00
|
|
|
sfxPlay3DSound(actor, 1701, -1, 0);
|
2021-05-05 07:47:08 +00:00
|
|
|
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
|
|
|
{
|
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);
|
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);
|
2021-09-15 22:17:37 +00:00
|
|
|
aiChooseDirection(actor,nAngle);
|
2021-01-04 12:02:00 +00:00
|
|
|
if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
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 gillThinkSwimChase(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();
|
2021-05-05 07:47:08 +00:00
|
|
|
if (actor->GetTarget() == nullptr)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
2019-09-19 22:42:45 +00:00
|
|
|
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);
|
2021-05-05 08:12:31 +00:00
|
|
|
if (!actor->ValidateTarget(__FUNCTION__)) return;
|
2021-05-05 08:22:26 +00:00
|
|
|
spritetype *pTarget = &actor->GetTarget()->s();
|
|
|
|
XSPRITE* pXTarget = &actor->GetTarget()->x();
|
2019-09-19 22:42:45 +00:00
|
|
|
int dx = pTarget->x-pSprite->x;
|
|
|
|
int dy = pTarget->y-pSprite->y;
|
2021-09-15 22:17:37 +00:00
|
|
|
aiChooseDirection(actor,getangle(dx, dy));
|
2019-09-19 22:42:45 +00:00
|
|
|
if (pXTarget->health == 0)
|
|
|
|
{
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
2019-09-19 22:42:45 +00:00
|
|
|
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
|
|
|
{
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimSearch);
|
2019-09-19 22:42:45 +00:00
|
|
|
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->z;
|
|
|
|
int top, bottom;
|
2021-05-05 11:39:16 +00:00
|
|
|
GetActorExtents(actor, &top, &bottom);
|
2019-09-19 22:42:45 +00:00
|
|
|
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
|
|
|
{
|
2021-05-05 07:47:08 +00:00
|
|
|
aiSetTarget(actor, actor->GetTarget());
|
2021-01-04 12:02:00 +00:00
|
|
|
if (nDist < 0x400 && abs(nDeltaAngle) < 85)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimBite);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
|
|
|
{
|
2021-05-05 09:51:10 +00:00
|
|
|
aiPlay3DSound(actor, 1700, AI_SFX_PRIORITY_1, -1);
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeast13A154);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeast13A154);
|
2019-09-19 22:42:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gillBeastSwimGoto);
|
2021-05-05 07:47:08 +00:00
|
|
|
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
|
|
|
{
|
2020-11-06 21:48:22 +00:00
|
|
|
auto pXSprite = &actor->x();
|
|
|
|
auto pSprite = &actor->s();
|
2019-09-19 22:42:45 +00:00
|
|
|
int nSprite = pSprite->index;
|
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 nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
|
|
|
|
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
|
|
|
|
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
|
|
|
|
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2;
|
2021-01-04 12:02:00 +00:00
|
|
|
if (abs(nAng) > 341)
|
2019-09-19 22:42:45 +00:00
|
|
|
return;
|
2021-05-05 07:47:08 +00:00
|
|
|
if (actor->GetTarget() == nullptr)
|
2019-09-19 22:42:45 +00:00
|
|
|
pSprite->ang = (pSprite->ang+256)&2047;
|
|
|
|
int dx = pXSprite->targetX-pSprite->x;
|
|
|
|
int dy = pXSprite->targetY-pSprite->y;
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
if (Random(64) < 32 && nDist <= 0x400)
|
|
|
|
return;
|
|
|
|
int nCos = Cos(pSprite->ang);
|
|
|
|
int nSin = Sin(pSprite->ang);
|
2020-11-06 21:48:22 +00:00
|
|
|
int vx = actor->xvel();
|
|
|
|
int vy = actor->yvel();
|
2021-01-04 10:40:08 +00:00
|
|
|
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
|
|
|
|
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
|
2021-05-05 07:47:08 +00:00
|
|
|
if (actor->GetTarget() == nullptr)
|
2019-09-19 22:42:45 +00:00
|
|
|
t1 += nAccel;
|
|
|
|
else
|
|
|
|
t1 += nAccel>>2;
|
2021-01-04 10:40:08 +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_6CD74(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);
|
2020-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
2021-05-05 08:12:31 +00:00
|
|
|
if (!actor->ValidateTarget(__FUNCTION__)) return;
|
2021-05-05 08:22:26 +00:00
|
|
|
spritetype *pTarget = &actor->GetTarget()->s();
|
2020-02-05 21:17:05 +00:00
|
|
|
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
|
|
|
|
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
|
2019-09-19 22:42:45 +00:00
|
|
|
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
|
|
|
|
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
|
|
|
|
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
|
|
|
|
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2;
|
2021-01-04 12:02:00 +00:00
|
|
|
if (abs(nAng) > 341)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
pXSprite->goalAng = (pSprite->ang+512)&2047;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int dx = pXSprite->targetX-pSprite->x;
|
|
|
|
int dy = pXSprite->targetY-pSprite->y;
|
|
|
|
int dz = z2 - z;
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
if (Chance(0x600) && nDist <= 0x400)
|
|
|
|
return;
|
|
|
|
int nCos = Cos(pSprite->ang);
|
|
|
|
int nSin = Sin(pSprite->ang);
|
2020-11-06 21:48:22 +00:00
|
|
|
int vx = actor->xvel();
|
|
|
|
int vy = actor->yvel();
|
2021-01-04 10:40:08 +00:00
|
|
|
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
|
|
|
|
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
|
2019-09-19 22:42:45 +00:00
|
|
|
t1 += nAccel;
|
2021-01-04 10:40:08 +00:00
|
|
|
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
|
|
|
|
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
|
2020-11-06 21:48:22 +00:00
|
|
|
actor->zvel() = -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
|
|
|
{
|
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);
|
2020-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
2021-05-05 08:12:31 +00:00
|
|
|
if (!actor->ValidateTarget(__FUNCTION__)) return;
|
2021-05-05 08:22:26 +00:00
|
|
|
spritetype *pTarget = &actor->GetTarget()->s();
|
2020-02-05 21:17:05 +00:00
|
|
|
int z = pSprite->z + getDudeInfo(pSprite->type)->eyeHeight;
|
|
|
|
int z2 = pTarget->z + getDudeInfo(pTarget->type)->eyeHeight;
|
2019-09-19 22:42:45 +00:00
|
|
|
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
|
|
|
|
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
|
|
|
|
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
|
|
|
|
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2;
|
2021-01-04 12:02:00 +00:00
|
|
|
if (abs(nAng) > 341)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
pSprite->ang = (pSprite->ang+512)&2047;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int dx = pXSprite->targetX-pSprite->x;
|
|
|
|
int dy = pXSprite->targetY-pSprite->y;
|
|
|
|
int dz = (z2 - z)<<3;
|
|
|
|
int nDist = approxDist(dx, dy);
|
|
|
|
if (Chance(0x4000) && nDist <= 0x400)
|
|
|
|
return;
|
|
|
|
int nCos = Cos(pSprite->ang);
|
|
|
|
int nSin = Sin(pSprite->ang);
|
2020-11-06 21:48:22 +00:00
|
|
|
int vx = actor->xvel();
|
|
|
|
int vy = actor->yvel();
|
2021-01-04 10:40:08 +00:00
|
|
|
int t1 = DMulScale(vx, nCos, vy, nSin, 30);
|
|
|
|
int t2 = DMulScale(vx, nSin, -vy, nCos, 30);
|
2019-09-19 22:42:45 +00:00
|
|
|
t1 += nAccel>>1;
|
2021-01-04 10:40:08 +00:00
|
|
|
actor->xvel() = DMulScale(t1, nCos, t2, nSin, 30);
|
|
|
|
actor->yvel() = DMulScale(t1, nSin, -t2, nCos, 30);
|
2020-11-06 21:48:22 +00:00
|
|
|
actor->zvel() = dz;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|