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
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void aiPodSearch(DBloodActor* actor);
|
|
|
|
static void aiPodMove(DBloodActor* actor);
|
|
|
|
static void aiPodChase(DBloodActor* actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
AISTATE podIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
|
2020-11-21 19:10:45 +00:00
|
|
|
AISTATE podMove = { kAiStateMove, 7, -1, 3600, NULL, aiMoveTurn, aiPodMove, &podSearch };
|
|
|
|
AISTATE podSearch = { kAiStateSearch, 0, -1, 3600, NULL, aiMoveTurn, aiPodSearch, &podSearch };
|
2020-11-21 19:25:06 +00:00
|
|
|
AISTATE podStartChase = { kAiStateChase, 8, nPodStartChaseClient, 600, NULL, NULL, NULL, &podChase };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE podRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &podChase };
|
2020-11-21 19:10:45 +00:00
|
|
|
AISTATE podChase = { kAiStateChase, 6, -1, 0, NULL, aiMoveTurn, aiPodChase, NULL };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE tentacleIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
|
|
|
|
AISTATE tentacle13A6A8 = { kAiStateOther, 7, dword_279B3C, 0, NULL, NULL, NULL, &tentacle13A6C4 };
|
|
|
|
AISTATE tentacle13A6C4 = { kAiStateOther, -1, -1, 0, NULL, NULL, NULL, &tentacleChase };
|
|
|
|
AISTATE tentacle13A6E0 = { kAiStateOther, 8, dword_279B40, 0, NULL, NULL, NULL, &tentacle13A6FC };
|
|
|
|
AISTATE tentacle13A6FC = { kAiStateOther, -1, -1, 0, NULL, NULL, NULL, &tentacleIdle };
|
2020-11-21 19:10:45 +00:00
|
|
|
AISTATE tentacleMove = { kAiStateOther, 8, -1, 3600, NULL, aiMoveTurn, aiPodMove, &tentacleSearch };
|
|
|
|
AISTATE tentacleSearch = { kAiStateOther, 0, -1, 3600, NULL, aiMoveTurn, aiPodSearch, NULL };
|
2020-11-21 19:25:06 +00:00
|
|
|
AISTATE tentacleStartChase = { kAiStateOther, 6, nTentacleStartSearchClient, 120, NULL, NULL, NULL, &tentacleChase };
|
2019-09-19 22:42:45 +00:00
|
|
|
AISTATE tentacleRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &tentacleChase };
|
2020-11-21 19:10:45 +00:00
|
|
|
AISTATE tentacleChase = { kAiStateChase, 6, -1, 0, NULL, aiMoveTurn, aiPodChase, NULL };
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void sub_6FF08(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
sfxPlay3DSound(actor, 2503, -1, 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void sub_6FF54(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
sfxPlay3DSound(actor, 2500, -1, 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void podAttack(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();
|
2021-09-16 19:59:39 +00:00
|
|
|
|
2021-12-22 19:22:35 +00:00
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
2022-09-28 07:26:26 +00:00
|
|
|
auto dv = target->spr.pos - actor->spr.pos;
|
|
|
|
dv.X += Random2F(1000, 4);
|
|
|
|
dv.Y += Random2F(1000, 4);
|
|
|
|
double nDist = dv.XY().Length();
|
2021-09-16 19:59:39 +00:00
|
|
|
DBloodActor* pMissile = nullptr;
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
case kDudePodGreen:
|
2022-09-28 07:26:26 +00:00
|
|
|
dv.Z += 31.25;
|
2022-09-28 10:29:51 +00:00
|
|
|
if (pDudeInfo->SeeDist() * 1.6 < nDist)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
if (Chance(0x8000))
|
|
|
|
sfxPlay3DSound(actor, 2474, -1, 0);
|
|
|
|
else
|
|
|
|
sfxPlay3DSound(actor, 2475, -1, 0);
|
2022-09-28 07:26:26 +00:00
|
|
|
pMissile = actFireThing(actor, 0., -500., dv.Z / 32768 - 0.22125, kThingPodGreenBall, nDist * (2048. / 64800));
|
2021-09-16 19:59:39 +00:00
|
|
|
}
|
|
|
|
if (pMissile)
|
|
|
|
seqSpawn(68, pMissile, -1);
|
|
|
|
break;
|
|
|
|
case kDudePodFire:
|
2022-09-28 07:26:26 +00:00
|
|
|
dv.Z += 31.25;
|
2022-09-28 10:29:51 +00:00
|
|
|
if (pDudeInfo->SeeDist() * 1.6 < nDist)
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
sfxPlay3DSound(actor, 2454, -1, 0);
|
2022-09-28 07:26:26 +00:00
|
|
|
pMissile = actFireThing(actor, 0., -500., dv.Z / 32768 - 0.22125, kThingPodFireBall, nDist * (2048. / 64800));
|
2021-09-16 19:59:39 +00:00
|
|
|
}
|
|
|
|
if (pMissile)
|
|
|
|
seqSpawn(22, pMissile, -1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < 4; i++)
|
2021-12-29 18:41:41 +00:00
|
|
|
fxSpawnPodStuff(actor, 240);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void sub_70284(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
sfxPlay3DSound(actor, 2502, -1, 0);
|
|
|
|
int nDist, nBurn;
|
|
|
|
DAMAGE_TYPE dmgType;
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudeTentacleGreen:
|
|
|
|
default: // ???
|
|
|
|
nBurn = 0;
|
|
|
|
dmgType = kDamageBullet;
|
|
|
|
nDist = 50;
|
|
|
|
break;
|
|
|
|
case kDudeTentacleFire: // ???
|
|
|
|
nBurn = (gGameOptions.nDifficulty * 120) >> 2;
|
|
|
|
dmgType = kDamageExplode;
|
|
|
|
nDist = 75;
|
|
|
|
break;
|
|
|
|
}
|
2022-08-22 16:18:54 +00:00
|
|
|
actRadiusDamage(actor, actor->spr.pos, actor->sector(), nDist, 1, 5 * (1 + gGameOptions.nDifficulty), dmgType, 2, nBurn);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void aiPodSearch(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2022-09-03 22:38:26 +00:00
|
|
|
aiChooseDirection(actor, actor->xspr.goalAng);
|
2021-09-16 19:59:39 +00:00
|
|
|
aiThinkTarget(actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void aiPodMove(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
|
|
|
|
Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
|
2021-09-16 19:59:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-22 19:22:35 +00:00
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
2022-08-23 20:29:05 +00:00
|
|
|
auto dvec = actor->xspr.TargetPos.XY() - actor->spr.pos.XY();
|
2022-09-30 11:36:50 +00:00
|
|
|
DAngle nAngle = dvec.Angle();
|
2022-09-26 22:44:51 +00:00
|
|
|
double nDist = dvec.Length();
|
2022-09-27 20:00:52 +00:00
|
|
|
aiChooseDirection(actor, nAngle);
|
|
|
|
if (nDist < 32 && absangle(actor->spr.angle, nAngle) < pDudeInfo->Periphery())
|
|
|
|
{
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudePodGreen:
|
|
|
|
case kDudePodFire:
|
|
|
|
aiNewState(actor, &podSearch);
|
|
|
|
break;
|
|
|
|
case kDudeTentacleGreen:
|
|
|
|
case kDudeTentacleFire:
|
|
|
|
aiNewState(actor, &tentacleSearch);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aiThinkTarget(actor);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 21:48:22 +00:00
|
|
|
static void aiPodChase(DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-16 19:59:39 +00:00
|
|
|
if (actor->GetTarget() == nullptr) {
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudePodGreen:
|
|
|
|
case kDudePodFire:
|
|
|
|
aiNewState(actor, &podMove);
|
|
|
|
break;
|
|
|
|
case kDudeTentacleGreen:
|
|
|
|
case kDudeTentacleFire:
|
|
|
|
aiNewState(actor, &tentacleMove);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2021-12-22 19:22:35 +00:00
|
|
|
if (!(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax)) {
|
|
|
|
Printf(PRINT_HIGH, "actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax");
|
2021-09-16 19:59:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-22 19:22:35 +00:00
|
|
|
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
|
2021-12-22 19:02:43 +00:00
|
|
|
auto target = actor->GetTarget();
|
2021-12-29 18:41:41 +00:00
|
|
|
|
2022-08-23 20:30:40 +00:00
|
|
|
auto dvec = target->spr.pos.XY() - actor->spr.pos.XY();
|
2022-09-30 11:36:50 +00:00
|
|
|
DAngle nAngle = dvec.Angle();
|
2022-09-27 20:12:12 +00:00
|
|
|
double nDist = dvec.Length();
|
|
|
|
aiChooseDirection(actor, nAngle);
|
2021-12-22 19:48:11 +00:00
|
|
|
if (target->xspr.health == 0) {
|
2021-09-16 19:59:39 +00:00
|
|
|
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudePodGreen:
|
|
|
|
case kDudePodFire:
|
|
|
|
aiNewState(actor, &podSearch);
|
|
|
|
break;
|
|
|
|
case kDudeTentacleGreen:
|
|
|
|
case kDudeTentacleFire:
|
|
|
|
aiNewState(actor, &tentacleSearch);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2022-09-27 20:12:12 +00:00
|
|
|
if (nDist <= pDudeInfo->SeeDist())
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
2022-09-27 20:12:12 +00:00
|
|
|
DAngle nDeltaAngle = absangle(actor->spr.angle, nAngle);
|
2022-10-07 21:33:37 +00:00
|
|
|
double height = (pDudeInfo->eyeHeight * actor->spr.scale.Y);
|
2022-08-22 16:37:10 +00:00
|
|
|
if (cansee(target->spr.pos, target->sector(), actor->spr.pos.plusZ(-height), actor->sector()))
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
2022-09-27 20:12:12 +00:00
|
|
|
if (nDist < pDudeInfo->SeeDist() && abs(nDeltaAngle) <= pDudeInfo->Periphery())
|
2021-09-16 19:59:39 +00:00
|
|
|
{
|
|
|
|
aiSetTarget(actor, actor->GetTarget());
|
2022-09-27 20:12:12 +00:00
|
|
|
if (nDeltaAngle < DAngle15 && target->spr.type != kDudePodGreen && target->spr.type != kDudePodFire) {
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudePodGreen:
|
|
|
|
case kDudePodFire:
|
|
|
|
aiNewState(actor, &podStartChase);
|
|
|
|
break;
|
|
|
|
case kDudeTentacleGreen:
|
|
|
|
case kDudeTentacleFire:
|
|
|
|
aiNewState(actor, &tentacleStartChase);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-22 19:22:35 +00:00
|
|
|
switch (actor->spr.type) {
|
2021-09-16 19:59:39 +00:00
|
|
|
case kDudePodGreen:
|
|
|
|
case kDudePodFire:
|
|
|
|
aiNewState(actor, &podMove);
|
|
|
|
break;
|
|
|
|
case kDudeTentacleGreen:
|
|
|
|
case kDudeTentacleFire:
|
|
|
|
aiNewState(actor, &tentacleMove);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
actor->SetTarget(nullptr);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|