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 gargThinkTarget(DBloodActor *);
|
|
|
|
static void gargThinkSearch(DBloodActor *);
|
|
|
|
static void gargThinkGoto(DBloodActor *);
|
|
|
|
static void gargMoveDodgeUp(DBloodActor *);
|
|
|
|
static void gargMoveDodgeDown(DBloodActor *);
|
|
|
|
static void gargThinkChase(DBloodActor *);
|
|
|
|
static void entryFStatue(DBloodActor *);
|
|
|
|
static void entrySStatue(DBloodActor *);
|
|
|
|
static void gargMoveForward(DBloodActor *);
|
|
|
|
static void gargMoveSlow(DBloodActor *);
|
|
|
|
static void gargMoveSwoop(DBloodActor *);
|
|
|
|
static void gargMoveFly(DBloodActor *);
|
|
|
|
static void playStatueBreakSnd(DBloodActor*);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE gargoyleFIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, gargThinkTarget, NULL };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE gargoyleStatueIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, NULL, NULL };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE gargoyleFChase = { kAiStateChase, 0, -1, 0, NULL, gargMoveForward, gargThinkChase, &gargoyleFIdle };
|
|
|
|
AISTATE gargoyleFGoto = { kAiStateMove, 0, -1, 600, NULL, gargMoveForward, gargThinkGoto, &gargoyleFIdle };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE gargoyleFSlash = { kAiStateChase, 6, nSlashFClient, 120, NULL, NULL, NULL, &gargoyleFChase };
|
|
|
|
AISTATE gargoyleFThrow = { kAiStateChase, 6, nThrowFClient, 120, NULL, NULL, NULL, &gargoyleFChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE gargoyleSThrow = { kAiStateChase, 6, nThrowSClient, 120, NULL, gargMoveForward, NULL, &gargoyleFChase };
|
|
|
|
AISTATE gargoyleSBlast = { kAiStateChase, 7, nBlastSClient, 60, NULL, gargMoveSlow, NULL, &gargoyleFChase };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE gargoyleFRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &gargoyleFChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE gargoyleFSearch = { kAiStateSearch, 0, -1, 120, NULL, gargMoveForward, gargThinkSearch, &gargoyleFIdle };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE gargoyleFMorph2 = { kAiStateOther, -1, -1, 0, entryFStatue, NULL, NULL, &gargoyleFIdle };
|
|
|
|
AISTATE gargoyleFMorph = { kAiStateOther, 6, -1, 0, NULL, NULL, NULL, &gargoyleFMorph2 };
|
|
|
|
AISTATE gargoyleSMorph2 = { kAiStateOther, -1, -1, 0, entrySStatue, NULL, NULL, &gargoyleFIdle };
|
|
|
|
AISTATE gargoyleSMorph = { kAiStateOther, 6, -1, 0, NULL, NULL, NULL, &gargoyleSMorph2 };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE gargoyleSwoop = { kAiStateOther, 0, -1, 120, NULL, gargMoveSwoop, gargThinkChase, &gargoyleFChase };
|
|
|
|
AISTATE gargoyleFly = { kAiStateMove, 0, -1, 120, NULL, gargMoveFly, gargThinkChase, &gargoyleFChase };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE gargoyleTurn = { kAiStateMove, 0, -1, 120, NULL, aiMoveTurn, NULL, &gargoyleFChase };
|
2020-10-11 09:56:27 +00:00
|
|
|
AISTATE gargoyleDodgeUp = { kAiStateMove, 0, -1, 60, NULL, gargMoveDodgeUp, NULL, &gargoyleFChase };
|
|
|
|
AISTATE gargoyleFDodgeUpRight = { kAiStateMove, 0, -1, 90, NULL, gargMoveDodgeUp, NULL, &gargoyleFChase };
|
|
|
|
AISTATE gargoyleFDodgeUpLeft = { kAiStateMove, 0, -1, 90, NULL, gargMoveDodgeUp, NULL, &gargoyleFChase };
|
|
|
|
AISTATE gargoyleDodgeDown = { kAiStateMove, 0, -1, 120, NULL, gargMoveDodgeDown, NULL, &gargoyleFChase };
|
|
|
|
AISTATE gargoyleFDodgeDownRight = { kAiStateMove, 0, -1, 90, NULL, gargMoveDodgeDown, NULL, &gargoyleFChase };
|
|
|
|
AISTATE gargoyleFDodgeDownLeft = { kAiStateMove, 0, -1, 90, NULL, gargMoveDodgeDown, NULL, &gargoyleFChase };
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
AISTATE statueFBreakSEQ = { kAiStateOther, 5, -1, 0, entryFStatue, NULL, playStatueBreakSnd, &gargoyleFMorph2};
|
|
|
|
AISTATE statueSBreakSEQ = { kAiStateOther, 5, -1, 0, entrySStatue, NULL, playStatueBreakSnd, &gargoyleSMorph2};
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void playStatueBreakSnd(DBloodActor* actor) {
|
|
|
|
auto pXSprite = &actor->x();
|
|
|
|
auto pSprite = &actor->s();
|
2021-05-05 09:51:10 +00:00
|
|
|
aiPlay3DSound(actor, 313, AI_SFX_PRIORITY_1, -1);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void SlashFSeqCallback(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-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
|
|
|
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
|
2019-09-19 22:42:45 +00:00
|
|
|
int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2;
|
|
|
|
int height2 = (pTarget->yrepeat*pDudeInfoT->eyeHeight)<<2;
|
|
|
|
int dz = height-height2;
|
2020-09-01 13:00:35 +00:00
|
|
|
int dx = CosScale16(pSprite->ang);
|
|
|
|
int dy = SinScale16(pSprite->ang);
|
2021-08-30 18:28:24 +00:00
|
|
|
actFireVector(actor, 0, 0, dx, dy, dz, kVectorGargSlash);
|
2019-09-19 22:42:45 +00:00
|
|
|
int r1 = Random(50);
|
|
|
|
int r2 = Random(50);
|
2021-08-30 18:28:24 +00:00
|
|
|
actFireVector(actor, 0, 0, dx+r2, dy-r1, dz, kVectorGargSlash);
|
2019-09-19 22:42:45 +00:00
|
|
|
r1 = Random(50);
|
|
|
|
r2 = Random(50);
|
2021-08-30 18:28:24 +00:00
|
|
|
actFireVector(actor, 0, 0, dx-r2, dy+r1, dz, kVectorGargSlash);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void ThrowFSeqCallback(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-12-05 19:22:29 +00:00
|
|
|
actFireThing(actor, 0, 0, actor->dudeSlope-7500, kThingBone, 0xeeeee);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void BlastSSeqCallback(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();
|
2019-09-19 22:42:45 +00:00
|
|
|
wrand(); // ???
|
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 height = (pSprite->yrepeat*getDudeInfo(pSprite->type)->eyeHeight) << 2;
|
2019-09-19 22:42:45 +00:00
|
|
|
int dx = pXSprite->targetX-pSprite->x;
|
|
|
|
int dy = pXSprite->targetY-pSprite->y;
|
|
|
|
int x = pSprite->x;
|
|
|
|
int y = pSprite->y;
|
|
|
|
int z = height;
|
|
|
|
TARGETTRACK tt = { 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;
|
2021-05-05 15:25:37 +00:00
|
|
|
BloodStatIterator it(kStatDude);
|
|
|
|
while (auto actor2 = it.Next())
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-05-05 15:25:37 +00:00
|
|
|
spritetype* pSprite2 = &actor2->s();
|
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 (tt.at10)
|
|
|
|
{
|
2021-01-04 11:59:00 +00:00
|
|
|
int t = DivScale(nDist, tt.at10, 12);
|
2021-05-05 15:25:37 +00:00
|
|
|
x2 += (actor->xvel() * t) >> 12;
|
|
|
|
y2 += (actor->yvel() * t) >> 12;
|
|
|
|
z2 += (actor->zvel() * t) >> 8;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
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;
|
2021-05-05 11:39:16 +00:00
|
|
|
GetActorExtents(actor2, &top, &bottom);
|
2019-09-19 22:42:45 +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);
|
|
|
|
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
|
2021-01-04 12:02:00 +00:00
|
|
|
if (abs(nDeltaAngle) <= tt.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
|
|
|
if (tz > -0x333)
|
2021-01-04 11:59:00 +00:00
|
|
|
aim.dz = DivScale(tz, nDist, 10);
|
2019-09-19 22:42:45 +00:00
|
|
|
else if (tz < -0x333 && tz > -0xb33)
|
2021-01-04 11:59:00 +00:00
|
|
|
aim.dz = DivScale(tz, nDist, 10)+9460;
|
2019-09-19 22:42:45 +00:00
|
|
|
else if (tz < -0xb33 && tz > -0x3000)
|
2021-01-04 11:59:00 +00:00
|
|
|
aim.dz = DivScale(tz, nDist, 10)+9460;
|
2019-09-19 22:42:45 +00:00
|
|
|
else if (tz < -0x3000)
|
2021-01-04 11:59:00 +00:00
|
|
|
aim.dz = DivScale(tz, nDist, 10)-7500;
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2021-01-04 11:59:00 +00:00
|
|
|
aim.dz = DivScale(tz, nDist, 10);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
else
|
2021-01-04 11:59:00 +00:00
|
|
|
aim.dz = DivScale(tz, nDist, 10);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-07 19:47:43 +00:00
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
// allow to fire missile in non-player targets
|
|
|
|
if (IsPlayerSprite(pTarget) || gModernMap) {
|
|
|
|
actFireMissile(pSprite, -120, 0, aim.dx, aim.dy, aim.dz, kMissileArcGargoyle);
|
|
|
|
actFireMissile(pSprite, 120, 0, aim.dx, aim.dy, aim.dz, kMissileArcGargoyle);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (IsPlayerSprite(pTarget)) {
|
|
|
|
actFireMissile(pSprite, -120, 0, aim.dx, aim.dy, aim.dz, kMissileArcGargoyle);
|
|
|
|
actFireMissile(pSprite, 120, 0, aim.dx, aim.dy, aim.dz, kMissileArcGargoyle);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void ThrowSSeqCallback(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-12-05 19:22:29 +00:00
|
|
|
actFireThing(actor, 0, 0, actor->dudeSlope - 7500, kThingBone, Chance(0x6000) ? 0x133333 : 0x111111);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void gargThinkTarget(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-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);
|
2021-10-06 20:20:57 +00:00
|
|
|
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
|
|
|
|
if (pDudeExtraE->active && pDudeExtraE->thinkTime < 10)
|
|
|
|
pDudeExtraE->thinkTime++;
|
|
|
|
else if (pDudeExtraE->thinkTime >= 10 && pDudeExtraE->active)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
pXSprite->goalAng += 256;
|
2021-05-05 15:25:37 +00:00
|
|
|
POINT3D* pTarget = &actor->basePoint();
|
2021-09-16 18:38:46 +00:00
|
|
|
aiSetTarget(actor, pTarget->x, pTarget->y, pTarget->z);
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleTurn);
|
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
|
|
|
{
|
2021-10-06 20:20:57 +00:00
|
|
|
pDudeExtraE->thinkTime = 0;
|
2021-09-16 18:38:46 +00:00
|
|
|
aiSetTarget(actor, pPlayer->actor());
|
|
|
|
aiActivateDude(actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
else if (nDist < pDudeInfo->hearDist)
|
|
|
|
{
|
2021-10-06 20:20:57 +00:00
|
|
|
pDudeExtraE->thinkTime = 0;
|
2021-09-16 18:38:46 +00:00
|
|
|
aiSetTarget(actor, x, y, z);
|
|
|
|
aiActivateDude(actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void gargThinkSearch(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-06 21:48:22 +00:00
|
|
|
auto pXSprite = &actor->x();
|
2021-09-15 22:17:37 +00:00
|
|
|
aiChooseDirection(actor,pXSprite->goalAng);
|
2021-09-16 18:49:25 +00:00
|
|
|
aiLookForTarget(actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void gargThinkGoto(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-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 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, &gargoyleFSearch);
|
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 gargMoveDodgeUp(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-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 nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
|
|
|
|
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
|
|
|
|
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
|
|
|
|
int nCos = Cos(pSprite->ang);
|
|
|
|
int nSin = Sin(pSprite->ang);
|
2020-11-06 21:48:22 +00:00
|
|
|
int dx = actor->xvel();
|
|
|
|
int dy = actor->yvel();
|
2021-01-04 10:40:08 +00:00
|
|
|
int t1 = DMulScale(dx, nCos, dy, nSin, 30);
|
|
|
|
int t2 = DMulScale(dx, nSin, -dy, nCos, 30);
|
2019-09-19 22:42:45 +00:00
|
|
|
if (pXSprite->dodgeDir > 0)
|
|
|
|
t2 += pDudeInfo->sideSpeed;
|
|
|
|
else
|
|
|
|
t2 -= pDudeInfo->sideSpeed;
|
|
|
|
|
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() = -0x1d555;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void gargMoveDodgeDown(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-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 nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
|
|
|
|
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
|
|
|
|
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
|
|
|
|
if (pXSprite->dodgeDir == 0)
|
|
|
|
return;
|
|
|
|
int nCos = Cos(pSprite->ang);
|
|
|
|
int nSin = Sin(pSprite->ang);
|
2020-11-06 21:48:22 +00:00
|
|
|
int dx = actor->xvel();
|
|
|
|
int dy = actor->yvel();
|
2021-01-04 10:40:08 +00:00
|
|
|
int t1 = DMulScale(dx, nCos, dy, nSin, 30);
|
|
|
|
int t2 = DMulScale(dx, nSin, -dy, nCos, 30);
|
2019-09-19 22:42:45 +00:00
|
|
|
if (pXSprite->dodgeDir > 0)
|
|
|
|
t2 += pDudeInfo->sideSpeed;
|
|
|
|
else
|
|
|
|
t2 -= pDudeInfo->sideSpeed;
|
|
|
|
|
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() = 0x44444;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void gargThinkChase(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, &gargoyleFGoto);
|
2019-09-19 22:42:45 +00:00
|
|
|
return;
|
|
|
|
}
|
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-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
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, &gargoyleFSearch);
|
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, &gargoyleFSearch);
|
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;
|
|
|
|
// Should be dudeInfo[pTarget->type-kDudeBase]
|
|
|
|
int height2 = (pDudeInfo->eyeHeight*pTarget->yrepeat)<<2;
|
|
|
|
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());
|
2019-09-19 22:42:45 +00:00
|
|
|
int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y);
|
2021-05-05 11:39:16 +00:00
|
|
|
switch (pSprite->type)
|
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeGargoyleFlesh:
|
2021-01-04 12:02:00 +00:00
|
|
|
if (nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2021-09-16 19:34:16 +00:00
|
|
|
sfxPlay3DSound(actor, 1408, 0, 0);
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleFThrow);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-05-05 14:43:42 +00:00
|
|
|
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeGargoyleStone)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:34:16 +00:00
|
|
|
sfxPlay3DSound(actor, 1408, 0, 0);
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleFThrow);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2021-09-16 19:34:16 +00:00
|
|
|
sfxPlay3DSound(actor, 1408, 0, 0);
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleFThrow);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-01-04 12:02:00 +00:00
|
|
|
else if (nDist < 0x400 && abs(nDeltaAngle) < 85)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2021-09-16 19:34:16 +00:00
|
|
|
sfxPlay3DSound(actor, 1406, 0, 0);
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleFSlash);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-05-05 14:43:42 +00:00
|
|
|
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeGargoyleStone)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:34:16 +00:00
|
|
|
sfxPlay3DSound(actor, 1406, 0, 0);
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleFSlash);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2021-09-16 19:34:16 +00:00
|
|
|
sfxPlay3DSound(actor, 1406, 0, 0);
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleFSlash);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((height2-height > 0x2000 || floorZ-bottom > 0x2000) && nDist < 0x1400 && nDist > 0xa00)
|
|
|
|
{
|
2021-05-05 09:51:10 +00:00
|
|
|
aiPlay3DSound(actor, 1400, AI_SFX_PRIORITY_1, -1);
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleSwoop);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2021-01-04 12:02:00 +00:00
|
|
|
else if ((height2-height < 0x2000 || floorZ-bottom < 0x2000) && abs(nDeltaAngle) < 85)
|
2021-05-05 09:51:10 +00:00
|
|
|
aiPlay3DSound(actor, 1400, AI_SFX_PRIORITY_1, -1);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeGargoyleStone:
|
2021-01-04 12:02:00 +00:00
|
|
|
if (nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2021-09-16 19:34:16 +00:00
|
|
|
sfxPlay3DSound(actor, 1457, 0, 0);
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleSBlast);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-05-05 14:43:42 +00:00
|
|
|
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeGargoyleFlesh)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:34:16 +00:00
|
|
|
sfxPlay3DSound(actor, 1457, 0, 0);
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleSBlast);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2021-09-16 19:34:16 +00:00
|
|
|
sfxPlay3DSound(actor, 1457, 0, 0);
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleSBlast);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-01-04 12:02:00 +00:00
|
|
|
else if (nDist < 0x400 && abs(nDeltaAngle) < 85)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
|
|
|
switch (hit)
|
|
|
|
{
|
|
|
|
case -1:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleFSlash);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-05-05 14:43:42 +00:00
|
|
|
if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeGargoyleFlesh)
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleFSlash);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
default:
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleFSlash);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((height2-height > 0x2000 || floorZ-bottom > 0x2000) && nDist < 0x1400 && nDist > 0x800)
|
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pSprite->type == kDudeGargoyleFlesh)
|
2021-05-05 09:51:10 +00:00
|
|
|
aiPlay3DSound(actor, 1400, AI_SFX_PRIORITY_1, -1);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2021-05-05 09:51:10 +00:00
|
|
|
aiPlay3DSound(actor, 1450, AI_SFX_PRIORITY_1, -1);
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleSwoop);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2021-01-04 12:02:00 +00:00
|
|
|
else if ((height2-height < 0x2000 || floorZ-bottom < 0x2000) && abs(nDeltaAngle) < 85)
|
2021-05-05 09:51:10 +00:00
|
|
|
aiPlay3DSound(actor, 1450, AI_SFX_PRIORITY_1, -1);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleFly);
|
2019-09-19 22:42:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-07 12:46:03 +00:00
|
|
|
aiNewState(actor, &gargoyleFGoto);
|
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 entryFStatue(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-06 21:48:22 +00:00
|
|
|
auto pSprite = &actor->s();
|
2019-09-19 22:42:45 +00:00
|
|
|
DUDEINFO *pDudeInfo = &dudeInfo[6];
|
2020-12-05 22:49:51 +00:00
|
|
|
actHealDude(actor, pDudeInfo->startHealth, pDudeInfo->startHealth);
|
2019-10-11 21:59:39 +00:00
|
|
|
pSprite->type = kDudeGargoyleFlesh;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void entrySStatue(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-06 21:48:22 +00:00
|
|
|
auto pSprite = &actor->s();
|
2019-09-19 22:42:45 +00:00
|
|
|
DUDEINFO *pDudeInfo = &dudeInfo[7];
|
2020-12-05 22:49:51 +00:00
|
|
|
actHealDude(actor, pDudeInfo->startHealth, pDudeInfo->startHealth);
|
2019-10-11 21:59:39 +00:00
|
|
|
pSprite->type = kDudeGargoyleStone;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void gargMoveForward(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-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 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<<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 ((unsigned int)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>>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);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void gargMoveSlow(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-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 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<<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 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>>1;
|
|
|
|
t2 >>= 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);
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeGargoyleFlesh:
|
2020-11-06 21:48:22 +00:00
|
|
|
actor->zvel() = 0x44444;
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kDudeGargoyleStone:
|
2020-11-06 21:48:22 +00:00
|
|
|
actor->zvel() = 0x35555;
|
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
|
|
|
static void gargMoveSwoop(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-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 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<<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 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>>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);
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeGargoyleFlesh:
|
2020-11-06 21:48:22 +00:00
|
|
|
actor->zvel() = t1;
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kDudeGargoyleStone:
|
2020-11-06 21:48:22 +00:00
|
|
|
actor->zvel() = t1;
|
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
|
|
|
static void gargMoveFly(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-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 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<<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 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);
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kDudeGargoyleFlesh:
|
2020-11-06 21:48:22 +00:00
|
|
|
actor->zvel() = -t1;
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kDudeGargoyleStone:
|
2020-11-06 21:48:22 +00:00
|
|
|
actor->zvel() = -t1;
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|