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>
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
void DestroyBubble(DExhumedActor* pActor)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-18 21:53:37 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
runlist_DoSubRunRec(pSprite->lotag - 1);
|
2021-09-06 06:33:02 +00:00
|
|
|
runlist_DoSubRunRec(pSprite->owner);
|
2021-10-18 21:53:37 +00:00
|
|
|
runlist_SubRunRec(pActor->nRun);
|
|
|
|
DeleteActor(pActor);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-11-22 22:35:11 +00:00
|
|
|
DExhumedActor* BuildBubble(vec3_t pos, sectortype* pSector)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
int nSize = RandomSize(3);
|
|
|
|
if (nSize > 4) {
|
|
|
|
nSize -= 4;
|
|
|
|
}
|
|
|
|
|
2021-11-22 22:35:11 +00:00
|
|
|
auto pActor = insertActor(pSector, 402);
|
2021-10-18 21:53:37 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2021-09-06 06:33:02 +00:00
|
|
|
|
2021-10-30 10:26:42 +00:00
|
|
|
pSprite->pos = pos;
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->cstat = 0;
|
|
|
|
pSprite->shade = -32;
|
|
|
|
pSprite->pal = 0;
|
|
|
|
pSprite->clipdist = 5;
|
|
|
|
pSprite->xrepeat = 40;
|
|
|
|
pSprite->yrepeat = 40;
|
|
|
|
pSprite->xoffset = 0;
|
|
|
|
pSprite->yoffset = 0;
|
|
|
|
pSprite->picnum = 1;
|
|
|
|
pSprite->ang = inita;
|
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
|
|
|
pSprite->zvel = -1200;
|
|
|
|
pSprite->hitag = -1;
|
|
|
|
pSprite->extra = -1;
|
|
|
|
pSprite->lotag = runlist_HeadRun() + 1;
|
|
|
|
pSprite->backuppos();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
// GrabTimeSlot(3);
|
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
pActor->nFrame = 0;
|
|
|
|
pActor->nIndex = SeqOffsets[kSeqBubble] + nSize;
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, pActor, 0x140000);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x140000);
|
|
|
|
return pActor;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 19:07:58 +00:00
|
|
|
void AIBubble::Tick(RunListEvent* ev)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-18 21:53:37 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-11-21 19:13:19 +00:00
|
|
|
int nSeq = pActor->nIndex;
|
2021-10-18 21:53:37 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
seq_MoveSequence(pActor, nSeq, 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
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
if (pActor->nFrame >= SeqSize[nSeq]) {
|
|
|
|
pActor->nFrame = 0;
|
2021-10-15 19:07:58 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 19:07:58 +00:00
|
|
|
pSprite->z += pSprite->zvel;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-11-22 22:05:48 +00:00
|
|
|
auto pSector = pSprite->sector();
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-11-22 22:05:48 +00:00
|
|
|
if (pSprite->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
|
|
|
|
2021-11-22 22:05:48 +00:00
|
|
|
if (pSprite->hitag > -1 && pSectAbove != nullptr) {
|
2021-12-22 11:17:17 +00:00
|
|
|
BuildAnim(nullptr, 70, 0, pSprite->pos.X, pSprite->pos.Y, pSectAbove->floorz, pSectAbove, 64, 0);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
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
|
|
|
|
2021-10-15 19:07:58 +00:00
|
|
|
void AIBubble::Draw(RunListEvent* ev)
|
|
|
|
{
|
2021-10-18 21:53:37 +00:00
|
|
|
auto pActor = ev->pObjActor;
|
|
|
|
if (!pActor) return;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
seq_PlotSequence(ev->nParam, pActor->nIndex, pActor->nFrame, 1);
|
2021-12-04 18:08:50 +00:00
|
|
|
ev->pTSprite->ownerActor = nullptr;
|
2021-10-15 19:07:58 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
void DoBubbleMachines()
|
|
|
|
{
|
2021-10-18 21:53:37 +00:00
|
|
|
ExhumedStatIterator it(kStatBubbleMachine);
|
|
|
|
while (auto pActor = it.Next())
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-18 21:53:37 +00:00
|
|
|
pActor->nCount--;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
if (pActor->nCount <= 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-10-18 21:53:37 +00:00
|
|
|
pActor->nCount = (RandomWord() % pActor->nFrame) + 30;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2021-11-22 22:35:11 +00:00
|
|
|
BuildBubble(pSprite->pos, pSprite->sector());
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +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;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-18 21:53:37 +00:00
|
|
|
auto pSprite = &pActor->s();
|
2021-12-18 11:36:53 +00:00
|
|
|
pSprite->cstat = CSTAT_SPRITE_INVISIBLE;
|
2021-10-18 21:53:37 +00:00
|
|
|
ChangeActorStat(pActor, kStatBubbleMachine);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DoBubbles(int nPlayer)
|
|
|
|
{
|
2021-10-30 10:26:42 +00:00
|
|
|
vec3_t pos;
|
2021-11-22 22:35:11 +00:00
|
|
|
sectortype* pSector;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-11-22 22:35:11 +00:00
|
|
|
WheresMyMouth(nPlayer, &pos, &pSector);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-11-22 22:35:11 +00:00
|
|
|
auto pActor = BuildBubble(pos, pSector);
|
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
|