2019-11-20 16:21:32 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 sirlemonhead, Nuke.YKT
|
|
|
|
This file is part of PCExhumed.
|
|
|
|
PCExhumed 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-11-22 23:11:37 +00:00
|
|
|
#include "ns.h"
|
2020-08-18 07:52:08 +00:00
|
|
|
#include "aistuff.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "exhumed.h"
|
|
|
|
#include "engine.h"
|
|
|
|
#include "sequence.h"
|
2020-08-23 14:24:54 +00:00
|
|
|
#include "mapinfo.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include <assert.h>
|
2023-03-18 01:44:37 +00:00
|
|
|
#include "player.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
void DestroyBubble(DExhumedActor* pActor)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-12-23 16:02:21 +00:00
|
|
|
runlist_DoSubRunRec(pActor->spr.lotag - 1);
|
2022-05-23 22:30:41 +00:00
|
|
|
runlist_DoSubRunRec(pActor->spr.intowner);
|
2021-10-18 21:53:37 +00:00
|
|
|
runlist_SubRunRec(pActor->nRun);
|
|
|
|
DeleteActor(pActor);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2023-03-28 05:49:25 +00:00
|
|
|
static DExhumedActor* BuildBubble(const DVector3& pos, sectortype* pSector, const int nPlayer = nLocalPlayer)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
int nSize = RandomSize(3);
|
2023-03-28 05:49:25 +00:00
|
|
|
if (nSize > 4)
|
2019-08-31 07:47:15 +00:00
|
|
|
nSize -= 4;
|
|
|
|
|
2023-03-28 05:49:25 +00:00
|
|
|
// Was inita global previously.
|
|
|
|
const auto nAngle = PlayerList[nPlayer].pActor->spr.Angles.Yaw;
|
|
|
|
const auto pActor = insertActor(pSector, 402);
|
2021-12-23 16:02:21 +00:00
|
|
|
|
2022-08-20 13:42:53 +00:00
|
|
|
pActor->spr.pos = pos;
|
2021-12-23 16:02:21 +00:00
|
|
|
pActor->spr.cstat = 0;
|
|
|
|
pActor->spr.shade = -32;
|
|
|
|
pActor->spr.pal = 0;
|
2022-10-04 17:13:26 +00:00
|
|
|
pActor->clipdist = 1.25;
|
2022-10-07 21:52:29 +00:00
|
|
|
pActor->spr.scale = DVector2(0.625, 0.625);
|
2021-12-23 16:02:21 +00:00
|
|
|
pActor->spr.xoffset = 0;
|
|
|
|
pActor->spr.yoffset = 0;
|
|
|
|
pActor->spr.picnum = 1;
|
2023-03-28 05:49:25 +00:00
|
|
|
pActor->spr.Angles.Yaw = nAngle;
|
2022-09-03 08:02:25 +00:00
|
|
|
pActor->vel.X = 0;
|
|
|
|
pActor->vel.Y = 0;
|
2022-09-09 17:29:11 +00:00
|
|
|
pActor->vel.Z = -1200 / 256.;
|
2021-12-23 16:02:21 +00:00
|
|
|
pActor->spr.hitag = -1;
|
|
|
|
pActor->spr.extra = -1;
|
|
|
|
pActor->spr.lotag = runlist_HeadRun() + 1;
|
2021-12-30 16:10:08 +00:00
|
|
|
pActor->backuppos();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
// GrabTimeSlot(3);
|
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
pActor->nFrame = 0;
|
2023-04-15 22:11:01 +00:00
|
|
|
pActor->nSeqFile = "bubble";
|
|
|
|
pActor->nSeq = nSize;
|
2022-05-23 22:30:41 +00:00
|
|
|
pActor->spr.intowner = runlist_AddRunRec(pActor->spr.lotag - 1, pActor, 0x140000);
|
2021-10-18 21:53:37 +00:00
|
|
|
pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x140000);
|
2023-03-28 05:49:25 +00:00
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
return pActor;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void AIBubble::Tick(RunListEvent* ev)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2023-03-28 05:49:25 +00:00
|
|
|
const auto pActor = ev->pObjActor;
|
2021-10-18 21:53:37 +00:00
|
|
|
if (!pActor) return;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2023-04-15 22:11:01 +00:00
|
|
|
const auto& bubbSeq = getSequence(pActor->nSeqFile, pActor->nSeq);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2023-04-15 22:11:01 +00:00
|
|
|
playFrameSound(pActor, bubbSeq[pActor->nFrame]);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
pActor->nFrame++;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2023-04-15 22:11:01 +00:00
|
|
|
if (pActor->nFrame >= bubbSeq.Size())
|
2021-10-18 21:53:37 +00:00
|
|
|
pActor->nFrame = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2022-09-03 08:03:30 +00:00
|
|
|
pActor->spr.pos.Z = pActor->vel.Z;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2023-03-28 05:49:25 +00:00
|
|
|
const auto pSector = pActor->sector();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2022-08-20 15:17:50 +00:00
|
|
|
if (pActor->spr.pos.Z <= pSector->ceilingz)
|
2021-10-15 19:07:58 +00:00
|
|
|
{
|
2021-11-22 22:05:48 +00:00
|
|
|
auto pSectAbove = pSector->pAbove;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2023-03-28 05:49:25 +00:00
|
|
|
if (pActor->spr.hitag > -1 && pSectAbove != nullptr)
|
2023-04-15 22:11:01 +00:00
|
|
|
BuildAnim(nullptr, "seebubbl", 0, DVector3(pActor->spr.pos.XY(), pSectAbove->floorz), pSectAbove, 1., 0);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
DestroyBubble(pActor);
|
2021-10-15 19:07:58 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-10-15 19:07:58 +00:00
|
|
|
void AIBubble::Draw(RunListEvent* ev)
|
|
|
|
{
|
2023-04-15 22:11:01 +00:00
|
|
|
if (const auto pActor = ev->pObjActor)
|
|
|
|
{
|
|
|
|
seq_PlotSequence(ev->nParam, pActor->nSeqFile, pActor->nSeq, pActor->nFrame, 1);
|
|
|
|
ev->pTSprite->ownerActor = nullptr;
|
|
|
|
}
|
2021-10-15 19:07:58 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
void DoBubbleMachines()
|
|
|
|
{
|
2021-10-18 21:53:37 +00:00
|
|
|
ExhumedStatIterator it(kStatBubbleMachine);
|
2023-03-28 05:49:25 +00:00
|
|
|
while (const auto itActor = it.Next())
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2023-03-28 05:49:25 +00:00
|
|
|
itActor->nCount--;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2023-03-28 05:49:25 +00:00
|
|
|
if (itActor->nCount <= 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2023-03-28 05:49:25 +00:00
|
|
|
itActor->nCount = (RandomWord() % itActor->nFrame) + 30;
|
|
|
|
BuildBubble(itActor->spr.pos, itActor->sector());
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
void BuildBubbleMachine(DExhumedActor* pActor)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-18 21:53:37 +00:00
|
|
|
pActor->nFrame = 75;
|
|
|
|
pActor->nCount = pActor->nFrame;
|
2021-12-23 16:02:21 +00:00
|
|
|
pActor->spr.cstat = CSTAT_SPRITE_INVISIBLE;
|
2021-10-18 21:53:37 +00:00
|
|
|
ChangeActorStat(pActor, kStatBubbleMachine);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 06:09:26 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
void DoBubbles(int nPlayer)
|
|
|
|
{
|
2021-11-22 22:35:11 +00:00
|
|
|
sectortype* pSector;
|
2023-03-28 05:49:25 +00:00
|
|
|
const auto pos = WheresMyMouth(nPlayer, &pSector);
|
|
|
|
const auto pActor = BuildBubble(pos, pSector, nPlayer);
|
2021-12-21 22:18:23 +00:00
|
|
|
pActor->spr.hitag = nPlayer;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|