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 <random>
|
|
|
|
|
|
|
|
#include "build.h"
|
|
|
|
#include "compat.h"
|
|
|
|
|
|
|
|
#include "blood.h"
|
2021-08-27 19:38:02 +00:00
|
|
|
#include "misc.h"
|
2020-09-01 17:49:05 +00:00
|
|
|
#include "d_net.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
int basePath[kMaxSectors];
|
|
|
|
|
2019-12-05 20:42:35 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
unsigned int GetWaveValue(unsigned int nPhase, int nType)
|
|
|
|
{
|
|
|
|
switch (nType)
|
|
|
|
{
|
|
|
|
case 0:
|
2020-09-01 13:00:35 +00:00
|
|
|
return 0x8000-(Cos(FixedToInt(nPhase<<10))>>15);
|
2019-09-19 22:42:45 +00:00
|
|
|
case 1:
|
|
|
|
return nPhase;
|
|
|
|
case 2:
|
2020-09-01 13:00:35 +00:00
|
|
|
return 0x10000-(Cos(FixedToInt(nPhase<<9))>>14);
|
2019-09-19 22:42:45 +00:00
|
|
|
case 3:
|
2020-09-01 13:00:35 +00:00
|
|
|
return Sin(FixedToInt(nPhase<<9))>>14;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
return nPhase;
|
|
|
|
}
|
|
|
|
|
2020-01-11 21:07:05 +00:00
|
|
|
char SetSpriteState(int nSprite, XSPRITE* pXSprite, int nState)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-09-21 11:02:17 +00:00
|
|
|
if ((pXSprite->busy & 0xffff) == 0 && pXSprite->state == nState)
|
2019-09-19 22:42:45 +00:00
|
|
|
return 0;
|
2020-09-01 13:00:35 +00:00
|
|
|
pXSprite->busy = IntToFixed(nState);
|
2019-09-19 22:42:45 +00:00
|
|
|
pXSprite->state = nState;
|
|
|
|
evKill(nSprite, 3);
|
2019-10-15 12:36:50 +00:00
|
|
|
if ((sprite[nSprite].flags & kHitagRespawn) != 0 && sprite[nSprite].inittype >= kDudeBase && sprite[nSprite].inittype < kDudeMax)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
pXSprite->respawnPending = 3;
|
2019-10-11 21:59:39 +00:00
|
|
|
evPost(nSprite, 3, gGameOptions.nMonsterRespawnTime, kCallbackRespawn);
|
2019-09-19 22:42:45 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (pXSprite->restState != nState && pXSprite->waitTime > 0)
|
2020-01-11 21:07:05 +00:00
|
|
|
evPost(nSprite, 3, (pXSprite->waitTime * 120) / 10, pXSprite->restState ? kCmdOn : kCmdOff);
|
2019-09-19 22:42:45 +00:00
|
|
|
if (pXSprite->txID)
|
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pXSprite->command != kCmdLink && pXSprite->triggerOn && pXSprite->state)
|
2020-01-11 21:07:05 +00:00
|
|
|
evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command);
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pXSprite->command != kCmdLink && pXSprite->triggerOff && !pXSprite->state)
|
2020-01-11 21:07:05 +00:00
|
|
|
evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-09-21 11:02:17 +00:00
|
|
|
|
|
|
|
|
2020-01-11 21:07:05 +00:00
|
|
|
char SetWallState(int nWall, XWALL *pXWall, int nState)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
if ((pXWall->busy&0xffff) == 0 && pXWall->state == nState)
|
|
|
|
return 0;
|
2020-09-01 13:00:35 +00:00
|
|
|
pXWall->busy = IntToFixed(nState);
|
2019-09-19 22:42:45 +00:00
|
|
|
pXWall->state = nState;
|
|
|
|
evKill(nWall, 0);
|
|
|
|
if (pXWall->restState != nState && pXWall->waitTime > 0)
|
2020-01-11 21:07:05 +00:00
|
|
|
evPost(nWall, 0, (pXWall->waitTime*120) / 10, pXWall->restState ? kCmdOn : kCmdOff);
|
2019-09-19 22:42:45 +00:00
|
|
|
if (pXWall->txID)
|
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pXWall->command != kCmdLink && pXWall->triggerOn && pXWall->state)
|
2020-01-11 21:07:05 +00:00
|
|
|
evSend(nWall, 0, pXWall->txID, (COMMAND_ID)pXWall->command);
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pXWall->command != kCmdLink && pXWall->triggerOff && !pXWall->state)
|
2020-01-11 21:07:05 +00:00
|
|
|
evSend(nWall, 0, pXWall->txID, (COMMAND_ID)pXWall->command);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-01-11 21:07:05 +00:00
|
|
|
char SetSectorState(int nSector, XSECTOR *pXSector, int nState)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
if ((pXSector->busy&0xffff) == 0 && pXSector->state == nState)
|
|
|
|
return 0;
|
2020-09-01 13:00:35 +00:00
|
|
|
pXSector->busy = IntToFixed(nState);
|
2019-09-19 22:42:45 +00:00
|
|
|
pXSector->state = nState;
|
|
|
|
evKill(nSector, 6);
|
|
|
|
if (nState == 1)
|
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pXSector->command != kCmdLink && pXSector->triggerOn && pXSector->txID)
|
2020-01-11 21:07:05 +00:00
|
|
|
evSend(nSector, 6, pXSector->txID, (COMMAND_ID)pXSector->command);
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pXSector->stopOn)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
pXSector->stopOn = 0;
|
|
|
|
pXSector->stopOff = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-10-25 20:53:41 +00:00
|
|
|
else if (pXSector->reTriggerA)
|
2020-01-11 21:07:05 +00:00
|
|
|
evPost(nSector, 6, (pXSector->waitTimeA * 120) / 10, kCmdOff);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pXSector->command != kCmdLink && pXSector->triggerOff && pXSector->txID)
|
2020-01-11 21:07:05 +00:00
|
|
|
evSend(nSector, 6, pXSector->txID, (COMMAND_ID)pXSector->command);
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pXSector->stopOff)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
pXSector->stopOn = 0;
|
|
|
|
pXSector->stopOff = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-10-25 20:53:41 +00:00
|
|
|
else if (pXSector->reTriggerB)
|
2020-01-11 21:07:05 +00:00
|
|
|
evPost(nSector, 6, (pXSector->waitTimeB * 120) / 10, kCmdOn);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int gBusyCount = 0;
|
2020-12-06 20:56:09 +00:00
|
|
|
BUSY gBusy[];
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
void AddBusy(int a1, BUSYID a2, int nDelta)
|
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nDelta != 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < gBusyCount; i++)
|
|
|
|
{
|
2020-11-21 19:25:06 +00:00
|
|
|
if (gBusy[i].index == a1 && gBusy[i].type == a2)
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == gBusyCount)
|
|
|
|
{
|
2020-12-06 20:56:09 +00:00
|
|
|
if (gBusyCount == kMaxBusyCount)
|
2019-09-19 22:42:45 +00:00
|
|
|
return;
|
2020-11-21 19:25:06 +00:00
|
|
|
gBusy[i].index = a1;
|
|
|
|
gBusy[i].type = a2;
|
|
|
|
gBusy[i].busy = nDelta > 0 ? 0 : 65536;
|
2019-09-19 22:42:45 +00:00
|
|
|
gBusyCount++;
|
|
|
|
}
|
2020-11-21 19:25:06 +00:00
|
|
|
gBusy[i].delta = nDelta;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReverseBusy(int a1, BUSYID a2)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < gBusyCount; i++)
|
|
|
|
{
|
2020-11-21 19:25:06 +00:00
|
|
|
if (gBusy[i].index == a1 && gBusy[i].type == a2)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-21 19:25:06 +00:00
|
|
|
gBusy[i].delta = -gBusy[i].delta;
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int GetSourceBusy(EVENT a1)
|
|
|
|
{
|
|
|
|
int nIndex = a1.index;
|
|
|
|
switch (a1.type)
|
|
|
|
{
|
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
int nXIndex = sector[nIndex].extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXIndex > 0 && nXIndex < kMaxXSectors);
|
2019-09-19 22:42:45 +00:00
|
|
|
return xsector[nXIndex].busy;
|
|
|
|
}
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
int nXIndex = wall[nIndex].extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXIndex > 0 && nXIndex < kMaxXWalls);
|
2019-09-19 22:42:45 +00:00
|
|
|
return xwall[nXIndex].busy;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
int nXIndex = sprite[nIndex].extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXIndex > 0 && nXIndex < kMaxXSprites);
|
2019-09-19 22:42:45 +00:00
|
|
|
return xsprite[nXIndex].busy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-11 21:59:39 +00:00
|
|
|
void LifeLeechOperate(spritetype *pSprite, XSPRITE *pXSprite, EVENT event)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdSpritePush:
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int nPlayer = pXSprite->data4;
|
2020-09-01 17:49:05 +00:00
|
|
|
if (nPlayer >= 0 && nPlayer < kMaxPlayers && playeringame[nPlayer])
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
PLAYER *pPlayer = &gPlayer[nPlayer];
|
|
|
|
if (pPlayer->pXSprite->health > 0)
|
|
|
|
{
|
2021-08-27 19:38:02 +00:00
|
|
|
evKill(pSprite->index, 3);
|
2019-10-25 20:53:41 +00:00
|
|
|
pPlayer->ammoCount[8] = ClipHigh(pPlayer->ammoCount[8]+pXSprite->data3, gAmmoInfo[8].max);
|
2019-10-21 19:46:41 +00:00
|
|
|
pPlayer->hasWeapon[9] = 1;
|
2021-08-18 09:56:06 +00:00
|
|
|
if (pPlayer->curWeapon != kWeapLifeLeech)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-08-27 19:38:02 +00:00
|
|
|
if (!VanillaMode() && checkFired6or7(pPlayer)) // if tnt/spray is actively used, do not switch weapon
|
|
|
|
break;
|
2019-10-21 19:46:41 +00:00
|
|
|
pPlayer->weaponState = 0;
|
|
|
|
pPlayer->nextWeapon = 9;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
case kCmdSpriteProximity:
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2021-09-15 22:40:09 +00:00
|
|
|
int nTarget = pXSprite->target_i;
|
2019-09-19 22:42:45 +00:00
|
|
|
if (nTarget >= 0 && nTarget < kMaxSprites)
|
|
|
|
{
|
|
|
|
if (!pXSprite->stateTimer)
|
|
|
|
{
|
|
|
|
spritetype *pTarget = &sprite[nTarget];
|
2019-10-07 19:29:52 +00:00
|
|
|
if (pTarget->statnum == kStatDude && !(pTarget->flags&32) && pTarget->extra > 0 && pTarget->extra < kMaxXSprites)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pSprite, &top, &bottom);
|
|
|
|
int nType = pTarget->type-kDudeBase;
|
2020-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(nType+kDudeBase);
|
2019-09-19 22:42:45 +00:00
|
|
|
int z1 = (top-pSprite->z)-256;
|
|
|
|
int x = pTarget->x;
|
|
|
|
int y = pTarget->y;
|
|
|
|
int z = pTarget->z;
|
|
|
|
int nDist = approxDist(x - pSprite->x, y - pSprite->y);
|
|
|
|
if (nDist != 0 && cansee(pSprite->x, pSprite->y, top, pSprite->sectnum, x, y, z, pTarget->sectnum))
|
|
|
|
{
|
2021-01-04 11:59:00 +00:00
|
|
|
int t = DivScale(nDist, 0x1aaaaa, 12);
|
2019-09-19 22:42:45 +00:00
|
|
|
x += (xvel[nTarget]*t)>>12;
|
|
|
|
y += (yvel[nTarget]*t)>>12;
|
|
|
|
int angBak = pSprite->ang;
|
|
|
|
pSprite->ang = getangle(x-pSprite->x, y-pSprite->y);
|
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 tz = pTarget->z - (pTarget->yrepeat * pDudeInfo->aimHeight) * 4;
|
2021-01-04 11:59:00 +00:00
|
|
|
int dz = DivScale(tz - top - 256, nDist, 10);
|
2019-10-11 21:59:39 +00:00
|
|
|
int nMissileType = kMissileLifeLeechAltNormal + (pXSprite->data3 ? 1 : 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
int t2;
|
|
|
|
if (!pXSprite->data3)
|
2021-05-12 00:00:06 +00:00
|
|
|
t2 = 120 / 10;
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2021-05-12 00:00:06 +00:00
|
|
|
t2 = (3*120) / 10;
|
2019-09-19 22:42:45 +00:00
|
|
|
spritetype *pMissile = actFireMissile(pSprite, 0, z1, dx, dy, dz, nMissileType);
|
|
|
|
if (pMissile)
|
|
|
|
{
|
|
|
|
pMissile->owner = pSprite->owner;
|
|
|
|
pXSprite->stateTimer = 1;
|
2019-10-11 21:59:39 +00:00
|
|
|
evPost(pSprite->index, 3, t2, kCallbackLeechStateTimer);
|
2019-09-19 22:42:45 +00:00
|
|
|
pXSprite->data3 = ClipLow(pXSprite->data3-1, 0);
|
|
|
|
}
|
|
|
|
pSprite->ang = angBak;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
actPostSprite(pSprite->index, kStatFree);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActivateGenerator(int);
|
|
|
|
|
2019-10-11 21:59:39 +00:00
|
|
|
void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
2020-02-07 19:47:43 +00:00
|
|
|
|
2020-03-30 19:54:28 +00:00
|
|
|
#ifdef NOONE_EXTENSIONS
|
2020-04-07 20:30:00 +00:00
|
|
|
if (gModernMap && modernTypeOperateSprite(nSprite, pSprite, pXSprite, event))
|
|
|
|
return;
|
2020-05-05 18:50:14 +00:00
|
|
|
#endif
|
|
|
|
|
2020-04-07 20:30:00 +00:00
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdLock:
|
|
|
|
pXSprite->locked = 1;
|
|
|
|
return;
|
|
|
|
case kCmdUnlock:
|
|
|
|
pXSprite->locked = 0;
|
2020-03-30 19:54:28 +00:00
|
|
|
return;
|
2020-04-07 20:30:00 +00:00
|
|
|
case kCmdToggleLock:
|
|
|
|
pXSprite->locked = pXSprite->locked ^ 1;
|
|
|
|
return;
|
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pSprite->statnum == kStatDude && pSprite->type >= kDudeBase && pSprite->type < kDudeMax) {
|
2019-10-13 22:29:19 +00:00
|
|
|
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
2020-01-11 21:07:05 +00:00
|
|
|
SetSpriteState(nSprite, pXSprite, 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kCmdSpriteProximity:
|
|
|
|
if (pXSprite->state) break;
|
|
|
|
fallthrough__;
|
|
|
|
case kCmdOn:
|
|
|
|
case kCmdSpritePush:
|
|
|
|
case kCmdSpriteTouch:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!pXSprite->state) SetSpriteState(nSprite, pXSprite, 1);
|
2020-11-06 21:48:22 +00:00
|
|
|
aiActivateDude(&bloodActors[pXSprite->reference]);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-10-13 22:29:19 +00:00
|
|
|
|
|
|
|
return;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
switch (pSprite->type) {
|
|
|
|
case kTrapMachinegun:
|
|
|
|
if (pXSprite->health <= 0) break;
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, 0)) break;
|
2019-10-11 21:59:39 +00:00
|
|
|
seqSpawn(40, 3, pSprite->extra, -1);
|
|
|
|
break;
|
|
|
|
case kCmdOn:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, 1)) break;
|
2019-10-11 21:59:39 +00:00
|
|
|
seqSpawn(38, 3, pSprite->extra, nMGunOpenClient);
|
|
|
|
if (pXSprite->data1 > 0)
|
|
|
|
pXSprite->data2 = pXSprite->data1;
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kThingFallingRock:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (SetSpriteState(nSprite, pXSprite, 1))
|
2019-09-30 07:18:01 +00:00
|
|
|
pSprite->flags |= 7;
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kThingWallCrack:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (SetSpriteState(nSprite, pXSprite, 0))
|
2019-09-19 22:42:45 +00:00
|
|
|
actPostSprite(nSprite, kStatFree);
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kThingCrateFace:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (SetSpriteState(nSprite, pXSprite, 0))
|
2019-09-19 22:42:45 +00:00
|
|
|
actPostSprite(nSprite, kStatFree);
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kTrapZapSwitchable:
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
|
|
|
pXSprite->state = 0;
|
|
|
|
pSprite->cstat |= CSTAT_SPRITE_INVISIBLE;
|
|
|
|
pSprite->cstat &= ~CSTAT_SPRITE_BLOCK;
|
|
|
|
break;
|
|
|
|
case kCmdOn:
|
|
|
|
pXSprite->state = 1;
|
|
|
|
pSprite->cstat &= (unsigned short)~CSTAT_SPRITE_INVISIBLE;
|
|
|
|
pSprite->cstat |= CSTAT_SPRITE_BLOCK;
|
|
|
|
break;
|
|
|
|
case kCmdToggle:
|
|
|
|
pXSprite->state ^= 1;
|
|
|
|
pSprite->cstat ^= CSTAT_SPRITE_INVISIBLE;
|
|
|
|
pSprite->cstat ^= CSTAT_SPRITE_BLOCK;
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kTrapFlame:
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, 0)) break;
|
2019-09-19 22:42:45 +00:00
|
|
|
seqSpawn(40, 3, pSprite->extra, -1);
|
|
|
|
sfxKill3DSound(pSprite, 0, -1);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kCmdOn:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, 1)) break;
|
2019-10-11 21:59:39 +00:00
|
|
|
seqSpawn(38, 3, pSprite->extra, -1);
|
|
|
|
sfxPlay3DSound(pSprite, 441, 0, 0);
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kSwitchPadlock:
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
2020-01-11 21:07:05 +00:00
|
|
|
SetSpriteState(nSprite, pXSprite, 0);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kCmdOn:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, 1)) break;
|
2019-09-19 22:42:45 +00:00
|
|
|
seqSpawn(37, 3, pSprite->extra, -1);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
default:
|
2020-01-11 21:07:05 +00:00
|
|
|
SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1);
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pXSprite->state) seqSpawn(37, 3, pSprite->extra, -1);
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kSwitchToggle:
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, 0)) break;
|
2019-09-19 22:42:45 +00:00
|
|
|
sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kCmdOn:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, 1)) break;
|
2019-09-19 22:42:45 +00:00
|
|
|
sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
default:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1)) break;
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pXSprite->state) sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0);
|
|
|
|
else sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0);
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kSwitchOneWay:
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, 0)) break;
|
2019-10-11 21:59:39 +00:00
|
|
|
sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0);
|
2019-09-21 11:02:17 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kCmdOn:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, 1)) break;
|
2019-10-11 21:59:39 +00:00
|
|
|
sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0);
|
2019-09-21 11:02:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, pXSprite->restState ^ 1)) break;
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pXSprite->state) sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0);
|
|
|
|
else sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0);
|
2019-09-21 11:02:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kSwitchCombo:
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
|
|
|
pXSprite->data1--;
|
|
|
|
if (pXSprite->data1 < 0)
|
|
|
|
pXSprite->data1 += pXSprite->data3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pXSprite->data1++;
|
|
|
|
if (pXSprite->data1 >= pXSprite->data3)
|
|
|
|
pXSprite->data1 -= pXSprite->data3;
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
sfxPlay3DSound(pSprite, pXSprite->data4, -1, 0);
|
2019-10-11 21:59:39 +00:00
|
|
|
|
|
|
|
if (pXSprite->command == kCmdLink && pXSprite->txID > 0)
|
2020-01-11 21:07:05 +00:00
|
|
|
evSend(nSprite, 3, pXSprite->txID, kCmdLink);
|
2019-10-11 21:59:39 +00:00
|
|
|
|
|
|
|
if (pXSprite->data1 == pXSprite->data2)
|
2020-01-11 21:07:05 +00:00
|
|
|
SetSpriteState(nSprite, pXSprite, 1);
|
2019-10-11 21:59:39 +00:00
|
|
|
else
|
2020-01-11 21:07:05 +00:00
|
|
|
SetSpriteState(nSprite, pXSprite, 0);
|
2019-10-11 21:59:39 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kMarkerDudeSpawn:
|
2020-12-05 17:32:49 +00:00
|
|
|
if (gGameOptions.nMonsterSettings && pXSprite->data1 >= kDudeBase && pXSprite->data1 < kDudeMax)
|
|
|
|
{
|
|
|
|
auto actor = &bloodActors[pSprite->index];
|
|
|
|
spritetype* pSpawn = &actSpawnDude(actor, pXSprite->data1, -1, 0)->s();
|
2019-10-13 22:29:19 +00:00
|
|
|
if (pSpawn) {
|
2019-09-19 22:42:45 +00:00
|
|
|
XSPRITE *pXSpawn = &xsprite[pSpawn->extra];
|
2020-09-01 19:27:32 +00:00
|
|
|
gKillMgr.AddNewKill(1);
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (pXSprite->data1) {
|
|
|
|
case kDudeBurningInnocent:
|
|
|
|
case kDudeBurningCultist:
|
|
|
|
case kDudeBurningZombieButcher:
|
|
|
|
case kDudeBurningTinyCaleb:
|
2019-10-13 22:29:19 +00:00
|
|
|
case kDudeBurningBeast: {
|
2020-02-05 21:17:05 +00:00
|
|
|
pXSpawn->health = getDudeInfo(pXSprite->data1)->startHealth << 4;
|
2019-10-11 21:59:39 +00:00
|
|
|
pXSpawn->burnTime = 10;
|
2021-09-15 22:40:09 +00:00
|
|
|
pXSpawn->target_i = -1;
|
2020-11-06 21:48:22 +00:00
|
|
|
aiActivateDude(&bloodActors[pXSpawn->reference]);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
2019-12-05 20:42:35 +00:00
|
|
|
default:
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kMarkerEarthQuake:
|
2019-09-19 22:42:45 +00:00
|
|
|
pXSprite->triggerOn = 0;
|
|
|
|
pXSprite->isTriggered = 1;
|
2020-01-11 21:07:05 +00:00
|
|
|
SetSpriteState(nSprite, pXSprite, 1);
|
2019-10-11 21:59:39 +00:00
|
|
|
for (int p = connecthead; p >= 0; p = connectpoint2[p]) {
|
2019-09-19 22:42:45 +00:00
|
|
|
spritetype *pPlayerSprite = gPlayer[p].pSprite;
|
|
|
|
int dx = (pSprite->x - pPlayerSprite->x)>>4;
|
|
|
|
int dy = (pSprite->y - pPlayerSprite->y)>>4;
|
|
|
|
int dz = (pSprite->z - pPlayerSprite->z)>>8;
|
|
|
|
int nDist = dx*dx+dy*dy+dz*dz+0x40000;
|
2021-01-04 11:51:41 +00:00
|
|
|
gPlayer[p].quakeEffect = DivScale(pXSprite->data1, nDist, 16);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kThingTNTBarrel:
|
2019-10-25 20:53:41 +00:00
|
|
|
if (pSprite->flags & kHitagRespawn) return;
|
2019-09-19 22:42:45 +00:00
|
|
|
fallthrough__;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kThingArmedTNTStick:
|
|
|
|
case kThingArmedTNTBundle:
|
|
|
|
case kThingArmedSpray:
|
2020-12-05 11:17:28 +00:00
|
|
|
actExplodeSprite(&bloodActors[pSprite->index]);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kTrapExploder:
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOn:
|
2020-01-11 21:07:05 +00:00
|
|
|
SetSpriteState(nSprite, pXSprite, 1);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
2019-09-21 11:02:17 +00:00
|
|
|
default:
|
2019-10-11 21:59:39 +00:00
|
|
|
pSprite->cstat &= (unsigned short)~CSTAT_SPRITE_INVISIBLE;
|
2020-12-05 11:17:28 +00:00
|
|
|
actExplodeSprite(&bloodActors[pSprite->index]);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kThingArmedRemoteBomb:
|
|
|
|
if (pSprite->statnum != kStatRespawn) {
|
2020-12-05 11:17:28 +00:00
|
|
|
if (event.cmd != kCmdOn) actExplodeSprite(&bloodActors[pSprite->index]);
|
2020-01-11 21:07:05 +00:00
|
|
|
else {
|
|
|
|
sfxPlay3DSound(pSprite, 454, 0, 0);
|
|
|
|
evPost(nSprite, 3, 18, kCmdOff);
|
|
|
|
}
|
|
|
|
}
|
2020-05-22 16:28:03 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kThingArmedProxBomb:
|
|
|
|
if (pSprite->statnum != kStatRespawn) {
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdSpriteProximity:
|
|
|
|
if (pXSprite->state) break;
|
|
|
|
sfxPlay3DSound(pSprite, 452, 0, 0);
|
2020-01-11 21:07:05 +00:00
|
|
|
evPost(nSprite, 3, 30, kCmdOff);
|
2019-10-11 21:59:39 +00:00
|
|
|
pXSprite->state = 1;
|
2019-12-05 20:42:35 +00:00
|
|
|
fallthrough__;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kCmdOn:
|
|
|
|
sfxPlay3DSound(pSprite, 451, 0, 0);
|
|
|
|
pXSprite->Proximity = 1;
|
2019-09-21 11:02:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2020-12-05 11:17:28 +00:00
|
|
|
actExplodeSprite(&bloodActors[pSprite->index]);
|
2019-09-21 11:02:17 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kThingDroppedLifeLeech:
|
|
|
|
LifeLeechOperate(pSprite, pXSprite, event);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kGenTrigger:
|
|
|
|
case kGenDripWater:
|
|
|
|
case kGenDripBlood:
|
|
|
|
case kGenMissileFireball:
|
|
|
|
case kGenMissileEctoSkull:
|
|
|
|
case kGenDart:
|
|
|
|
case kGenBubble:
|
|
|
|
case kGenBubbleMulti:
|
|
|
|
case kGenSound:
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
2020-01-11 21:07:05 +00:00
|
|
|
SetSpriteState(nSprite, pXSprite, 0);
|
2019-09-21 11:02:17 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kCmdRepeat:
|
|
|
|
if (pSprite->type != kGenTrigger) ActivateGenerator(nSprite);
|
2020-01-11 21:07:05 +00:00
|
|
|
if (pXSprite->txID) evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command);
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pXSprite->busyTime > 0) {
|
|
|
|
int nRand = Random2(pXSprite->data1);
|
2020-01-11 21:07:05 +00:00
|
|
|
evPost(nSprite, 3, 120*(nRand+pXSprite->busyTime) / 10, kCmdRepeat);
|
2019-10-11 21:59:39 +00:00
|
|
|
}
|
2019-09-21 11:02:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2019-10-11 21:59:39 +00:00
|
|
|
if (!pXSprite->state) {
|
2020-01-11 21:07:05 +00:00
|
|
|
SetSpriteState(nSprite, pXSprite, 1);
|
|
|
|
evPost(nSprite, 3, 0, kCmdRepeat);
|
2019-10-11 21:59:39 +00:00
|
|
|
}
|
2019-09-21 11:02:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kSoundPlayer:
|
2020-03-26 08:00:46 +00:00
|
|
|
if (gGameOptions.nGameType == 0)
|
|
|
|
{
|
|
|
|
if (gMe->pXSprite->health <= 0)
|
|
|
|
break;
|
|
|
|
gMe->restTime = 0;
|
|
|
|
}
|
2021-04-11 19:13:24 +00:00
|
|
|
sndStartSample(pXSprite->data1, -1, 1, 0, CHANF_FORCE);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kThingObjectGib:
|
|
|
|
case kThingObjectExplode:
|
|
|
|
case kThingBloodBits:
|
|
|
|
case kThingBloodChunks:
|
|
|
|
case kThingZombieHead:
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, 0)) break;
|
2020-11-06 21:48:22 +00:00
|
|
|
actActivateGibObject(&bloodActors[pXSprite->reference]);
|
2019-09-21 11:02:17 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kCmdOn:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, 1)) break;
|
2020-11-06 21:48:22 +00:00
|
|
|
actActivateGibObject(&bloodActors[pXSprite->reference]);
|
2019-09-21 11:02:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2020-01-11 21:07:05 +00:00
|
|
|
if (!SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1)) break;
|
2020-11-06 21:48:22 +00:00
|
|
|
actActivateGibObject(&bloodActors[pXSprite->reference]);
|
2019-09-21 11:02:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
default:
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
2020-01-11 21:07:05 +00:00
|
|
|
SetSpriteState(nSprite, pXSprite, 0);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case kCmdOn:
|
2020-01-11 21:07:05 +00:00
|
|
|
SetSpriteState(nSprite, pXSprite, 1);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
default:
|
2020-01-11 21:07:05 +00:00
|
|
|
SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
void SetupGibWallState(walltype *pWall, XWALL *pXWall)
|
|
|
|
{
|
|
|
|
walltype *pWall2 = NULL;
|
|
|
|
if (pWall->nextwall >= 0)
|
|
|
|
pWall2 = &wall[pWall->nextwall];
|
|
|
|
if (pXWall->state)
|
|
|
|
{
|
|
|
|
pWall->cstat &= ~65;
|
|
|
|
if (pWall2)
|
|
|
|
{
|
|
|
|
pWall2->cstat &= ~65;
|
|
|
|
pWall->cstat &= ~16;
|
|
|
|
pWall2->cstat &= ~16;
|
|
|
|
}
|
2019-09-21 11:02:17 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
char bVector = pXWall->triggerVector != 0;
|
|
|
|
pWall->cstat |= 1;
|
|
|
|
if (bVector)
|
|
|
|
pWall->cstat |= 64;
|
|
|
|
if (pWall2)
|
|
|
|
{
|
|
|
|
pWall2->cstat |= 1;
|
|
|
|
if (bVector)
|
|
|
|
pWall2->cstat |= 64;
|
|
|
|
pWall->cstat |= 16;
|
|
|
|
pWall2->cstat |= 16;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-21 11:02:17 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
void OperateWall(int nWall, XWALL *pXWall, EVENT event) {
|
|
|
|
walltype *pWall = &wall[nWall];
|
2019-11-08 19:57:01 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdLock:
|
|
|
|
pXWall->locked = 1;
|
|
|
|
return;
|
|
|
|
case kCmdUnlock:
|
|
|
|
pXWall->locked = 0;
|
|
|
|
return;
|
|
|
|
case kCmdToggleLock:
|
|
|
|
pXWall->locked ^= 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
2020-02-07 19:47:43 +00:00
|
|
|
if (gModernMap && modernTypeOperateWall(nWall, pWall, pXWall, event))
|
|
|
|
return;
|
2020-01-26 11:19:01 +00:00
|
|
|
#endif
|
2020-02-07 19:47:43 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
switch (pWall->type) {
|
|
|
|
case kWallGib:
|
|
|
|
if (GetWallType(nWall) != pWall->type) break;
|
|
|
|
char bStatus;
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOn:
|
|
|
|
case kCmdWallImpact:
|
|
|
|
bStatus = SetWallState(nWall, pXWall, 1);
|
|
|
|
break;
|
|
|
|
case kCmdOff:
|
|
|
|
bStatus = SetWallState(nWall, pXWall, 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
bStatus = SetWallState(nWall, pXWall, pXWall->state ^ 1);
|
|
|
|
break;
|
|
|
|
}
|
2019-11-08 19:57:01 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
if (bStatus) {
|
|
|
|
SetupGibWallState(pWall, pXWall);
|
|
|
|
if (pXWall->state) {
|
|
|
|
CGibVelocity vel(100, 100, 250);
|
|
|
|
int nType = ClipRange(pXWall->data, 0, 31);
|
|
|
|
if (nType > 0)
|
|
|
|
GibWall(nWall, (GIBTYPE)nType, &vel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
|
|
|
SetWallState(nWall, pXWall, 0);
|
|
|
|
break;
|
|
|
|
case kCmdOn:
|
|
|
|
SetWallState(nWall, pXWall, 1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SetWallState(nWall, pXWall, pXWall->state ^ 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
2019-11-08 19:57:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
}
|
2019-11-08 19:57:01 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
void SectorStartSound(int nSector, int nState)
|
|
|
|
{
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2020-01-26 11:19:01 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->statnum == kStatDecoration && pSprite->type == kSoundSector)
|
|
|
|
{
|
|
|
|
int nXSprite = pSprite->extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSprite > 0 && nXSprite < kMaxXSprites);
|
2020-01-26 11:19:01 +00:00
|
|
|
XSPRITE *pXSprite = &xsprite[nXSprite];
|
|
|
|
if (nState)
|
|
|
|
{
|
|
|
|
if (pXSprite->data3)
|
|
|
|
sfxPlay3DSound(pSprite, pXSprite->data3, 0, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pXSprite->data1)
|
|
|
|
sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
2019-11-08 19:57:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
void SectorEndSound(int nSector, int nState)
|
|
|
|
{
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2020-01-26 11:19:01 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->statnum == kStatDecoration && pSprite->type == kSoundSector)
|
|
|
|
{
|
|
|
|
int nXSprite = pSprite->extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSprite > 0 && nXSprite < kMaxXSprites);
|
2020-01-26 11:19:01 +00:00
|
|
|
XSPRITE *pXSprite = &xsprite[nXSprite];
|
|
|
|
if (nState)
|
|
|
|
{
|
|
|
|
if (pXSprite->data2)
|
|
|
|
sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pXSprite->data4)
|
|
|
|
sfxPlay3DSound(pSprite, pXSprite->data4, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-08 19:57:01 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
void PathSound(int nSector, int nSound)
|
|
|
|
{
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2020-01-26 11:19:01 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->statnum == kStatDecoration && pSprite->type == kSoundSector)
|
|
|
|
sfxPlay3DSound(pSprite, nSound, 0, 0);
|
|
|
|
}
|
2019-11-08 19:57:01 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
void DragPoint(int nWall, int x, int y)
|
|
|
|
{
|
2021-03-19 19:40:44 +00:00
|
|
|
sector[wall[nWall].sector].dirty = 255;
|
2020-01-26 11:19:01 +00:00
|
|
|
viewInterpolateWall(nWall, &wall[nWall]);
|
|
|
|
wall[nWall].x = x;
|
|
|
|
wall[nWall].y = y;
|
2019-11-08 19:57:01 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
int vsi = numwalls;
|
|
|
|
int vb = nWall;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (wall[vb].nextwall >= 0)
|
|
|
|
{
|
|
|
|
vb = wall[wall[vb].nextwall].point2;
|
2021-03-19 19:40:44 +00:00
|
|
|
sector[wall[vb].sector].dirty = 255;
|
2020-01-26 11:19:01 +00:00
|
|
|
viewInterpolateWall(vb, &wall[vb]);
|
|
|
|
wall[vb].x = x;
|
|
|
|
wall[vb].y = y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vb = nWall;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (wall[lastwall(vb)].nextwall >= 0)
|
|
|
|
{
|
|
|
|
vb = wall[lastwall(vb)].nextwall;
|
2021-03-19 19:40:44 +00:00
|
|
|
sector[wall[vb].sector].dirty = 255;
|
2020-01-26 11:19:01 +00:00
|
|
|
viewInterpolateWall(vb, &wall[vb]);
|
|
|
|
wall[vb].x = x;
|
|
|
|
wall[vb].y = y;
|
2019-11-08 19:57:01 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
vsi--;
|
|
|
|
} while (vb != nWall && vsi > 0);
|
2019-11-08 19:57:01 +00:00
|
|
|
break;
|
2020-01-26 11:19:01 +00:00
|
|
|
}
|
|
|
|
vsi--;
|
|
|
|
} while (vb != nWall && vsi > 0);
|
2019-11-08 19:57:01 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
void TranslateSector(int nSector, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, int a11, char a12)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
int nXSector = sector[nSector].extra;
|
|
|
|
XSECTOR *pXSector = &xsector[nXSector];
|
2021-04-11 06:45:19 +00:00
|
|
|
int v20 = interpolatedvalue(a6, a9, a2);
|
|
|
|
int vc = interpolatedvalue(a6, a9, a3);
|
2020-01-26 11:19:01 +00:00
|
|
|
int v28 = vc - v20;
|
2021-04-11 06:45:19 +00:00
|
|
|
int v24 = interpolatedvalue(a7, a10, a2);
|
|
|
|
int v8 = interpolatedvalue(a7, a10, a3);
|
2020-01-26 11:19:01 +00:00
|
|
|
int v2c = v8 - v24;
|
2021-04-11 06:45:19 +00:00
|
|
|
int v44 = interpolatedvalue(a8, a11, a2);
|
|
|
|
int vbp = interpolatedvalue(a8, a11, a3);
|
2020-01-26 11:19:01 +00:00
|
|
|
int v14 = vbp - v44;
|
|
|
|
int nWall = sector[nSector].wallptr;
|
|
|
|
if (a12)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < sector[nSector].wallnum; nWall++, i++)
|
|
|
|
{
|
|
|
|
x = baseWall[nWall].x;
|
|
|
|
y = baseWall[nWall].y;
|
|
|
|
if (vbp)
|
|
|
|
RotatePoint((int*)&x, (int*)&y, vbp, a4, a5);
|
|
|
|
DragPoint(nWall, x+vc-a4, y+v8-a5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (int i = 0; i < sector[nSector].wallnum; nWall++, i++)
|
|
|
|
{
|
|
|
|
int v10 = wall[nWall].point2;
|
|
|
|
x = baseWall[nWall].x;
|
|
|
|
y = baseWall[nWall].y;
|
|
|
|
if (wall[nWall].cstat&16384)
|
|
|
|
{
|
|
|
|
if (vbp)
|
|
|
|
RotatePoint((int*)&x, (int*)&y, vbp, a4, a5);
|
|
|
|
DragPoint(nWall, x+vc-a4, y+v8-a5);
|
|
|
|
if ((wall[v10].cstat&49152) == 0)
|
|
|
|
{
|
|
|
|
x = baseWall[v10].x;
|
|
|
|
y = baseWall[v10].y;
|
|
|
|
if (vbp)
|
|
|
|
RotatePoint((int*)&x, (int*)&y, vbp, a4, a5);
|
|
|
|
DragPoint(v10, x+vc-a4, y+v8-a5);
|
|
|
|
}
|
|
|
|
continue;
|
2019-11-08 19:57:01 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
if (wall[nWall].cstat&32768)
|
|
|
|
{
|
|
|
|
if (vbp)
|
|
|
|
RotatePoint((int*)&x, (int*)&y, -vbp, a4, a5);
|
|
|
|
DragPoint(nWall, x-(vc-a4), y-(v8-a5));
|
|
|
|
if ((wall[v10].cstat&49152) == 0)
|
|
|
|
{
|
|
|
|
x = baseWall[v10].x;
|
|
|
|
y = baseWall[v10].y;
|
|
|
|
if (vbp)
|
|
|
|
RotatePoint((int*)&x, (int*)&y, -vbp, a4, a5);
|
|
|
|
DragPoint(v10, x-(vc-a4), y-(v8-a5));
|
2019-10-07 19:29:52 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
continue;
|
2019-10-07 19:29:52 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
}
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2020-01-26 11:19:01 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
// allow to move markers by sector movements in game if flags 1 is added in editor.
|
|
|
|
switch (pSprite->statnum) {
|
|
|
|
case kStatMarker:
|
|
|
|
case kStatPathMarker:
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
if (!gModernMap || !(pSprite->flags & 0x1)) continue;
|
|
|
|
#else
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2019-10-07 19:29:52 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
x = baseSprite[nSprite].x;
|
|
|
|
y = baseSprite[nSprite].y;
|
|
|
|
if (sprite[nSprite].cstat&8192)
|
|
|
|
{
|
|
|
|
if (vbp)
|
|
|
|
RotatePoint((int*)&x, (int*)&y, vbp, a4, a5);
|
|
|
|
viewBackupSpriteLoc(nSprite, pSprite);
|
|
|
|
pSprite->ang = (pSprite->ang+v14)&2047;
|
|
|
|
pSprite->x = x+vc-a4;
|
|
|
|
pSprite->y = y+v8-a5;
|
|
|
|
}
|
|
|
|
else if (sprite[nSprite].cstat&16384)
|
|
|
|
{
|
|
|
|
if (vbp)
|
|
|
|
RotatePoint((int*)& x, (int*)& y, -vbp, a4, a4);
|
|
|
|
viewBackupSpriteLoc(nSprite, pSprite);
|
|
|
|
pSprite->ang = (pSprite->ang-v14)&2047;
|
|
|
|
pSprite->x = x-(vc-a4);
|
|
|
|
pSprite->y = y-(v8-a5);
|
|
|
|
}
|
|
|
|
else if (pXSector->Drag)
|
|
|
|
{
|
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pSprite, &top, &bottom);
|
|
|
|
int floorZ = getflorzofslope(nSector, pSprite->x, pSprite->y);
|
|
|
|
if (!(pSprite->cstat&48) && floorZ <= bottom)
|
|
|
|
{
|
|
|
|
if (v14)
|
|
|
|
RotatePoint((int*)&pSprite->x, (int*)&pSprite->y, v14, v20, v24);
|
|
|
|
viewBackupSpriteLoc(nSprite, pSprite);
|
|
|
|
pSprite->ang = (pSprite->ang+v14)&2047;
|
|
|
|
pSprite->x += v28;
|
|
|
|
pSprite->y += v2c;
|
2019-10-07 19:29:52 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-07 19:29:52 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
void ZTranslateSector(int nSector, XSECTOR *pXSector, int a3, int a4)
|
|
|
|
{
|
|
|
|
sectortype *pSector = §or[nSector];
|
|
|
|
viewInterpolateSector(nSector, pSector);
|
|
|
|
int dz = pXSector->onFloorZ-pXSector->offFloorZ;
|
|
|
|
if (dz != 0)
|
|
|
|
{
|
|
|
|
int oldZ = pSector->floorz;
|
2021-01-04 11:36:54 +00:00
|
|
|
baseFloor[nSector] = pSector->floorz = pXSector->offFloorZ + MulScale(dz, GetWaveValue(a3, a4), 16);
|
2020-01-26 11:19:01 +00:00
|
|
|
velFloor[nSector] += (pSector->floorz-oldZ)<<8;
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2020-01-26 11:19:01 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->statnum == kStatMarker || pSprite->statnum == kStatPathMarker)
|
|
|
|
continue;
|
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pSprite, &top, &bottom);
|
|
|
|
if (pSprite->cstat&8192)
|
|
|
|
{
|
|
|
|
viewBackupSpriteLoc(nSprite, pSprite);
|
|
|
|
pSprite->z += pSector->floorz-oldZ;
|
2019-10-07 19:29:52 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
else if (pSprite->flags&2)
|
|
|
|
pSprite->flags |= 4;
|
|
|
|
else if (oldZ <= bottom && !(pSprite->cstat&48))
|
|
|
|
{
|
|
|
|
viewBackupSpriteLoc(nSprite, pSprite);
|
|
|
|
pSprite->z += pSector->floorz-oldZ;
|
2019-10-07 19:29:52 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
}
|
|
|
|
dz = pXSector->onCeilZ-pXSector->offCeilZ;
|
|
|
|
if (dz != 0)
|
|
|
|
{
|
|
|
|
int oldZ = pSector->ceilingz;
|
2021-01-04 11:36:54 +00:00
|
|
|
baseCeil[nSector] = pSector->ceilingz = pXSector->offCeilZ + MulScale(dz, GetWaveValue(a3, a4), 16);
|
2020-01-26 11:19:01 +00:00
|
|
|
velCeil[nSector] += (pSector->ceilingz-oldZ)<<8;
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2020-01-26 11:19:01 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->statnum == kStatMarker || pSprite->statnum == kStatPathMarker)
|
|
|
|
continue;
|
|
|
|
if (pSprite->cstat&16384)
|
|
|
|
{
|
|
|
|
viewBackupSpriteLoc(nSprite, pSprite);
|
|
|
|
pSprite->z += pSector->ceilingz-oldZ;
|
2019-11-08 19:57:01 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-07 19:29:52 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
int GetHighestSprite(int nSector, int nStatus, int *a3)
|
|
|
|
{
|
|
|
|
*a3 = sector[nSector].floorz;
|
|
|
|
int v8 = -1;
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2020-01-26 11:19:01 +00:00
|
|
|
{
|
|
|
|
if (sprite[nSprite].statnum == nStatus || nStatus == kStatFree)
|
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pSprite, &top, &bottom);
|
|
|
|
if (top-pSprite->z > *a3)
|
|
|
|
{
|
|
|
|
*a3 = top-pSprite->z;
|
|
|
|
v8 = nSprite;
|
2019-11-08 19:57:01 +00:00
|
|
|
}
|
2019-10-07 19:29:52 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
return v8;
|
2019-10-07 19:29:52 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
int GetCrushedSpriteExtents(unsigned int nSector, int *pzTop, int *pzBot)
|
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pzTop != NULL && pzBot != NULL);
|
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
int vc = -1;
|
|
|
|
sectortype *pSector = §or[nSector];
|
|
|
|
int vbp = pSector->ceilingz;
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2020-01-26 11:19:01 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->statnum == kStatDude || pSprite->statnum == kStatThing)
|
|
|
|
{
|
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pSprite, &top, &bottom);
|
|
|
|
if (vbp > top)
|
|
|
|
{
|
|
|
|
vbp = top;
|
|
|
|
*pzTop = top;
|
|
|
|
*pzBot = bottom;
|
|
|
|
vc = nSprite;
|
|
|
|
}
|
2019-09-21 11:02:17 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
return vc;
|
2019-09-21 11:02:17 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
int VCrushBusy(unsigned int nSector, unsigned int a2)
|
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
int nXSector = sector[nSector].extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSector > 0 && nXSector < kMaxXSectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
XSECTOR *pXSector = &xsector[nXSector];
|
|
|
|
int nWave;
|
|
|
|
if (pXSector->busy < a2)
|
|
|
|
nWave = pXSector->busyWaveA;
|
|
|
|
else
|
|
|
|
nWave = pXSector->busyWaveB;
|
|
|
|
int dz1 = pXSector->onCeilZ - pXSector->offCeilZ;
|
|
|
|
int vc = pXSector->offCeilZ;
|
|
|
|
if (dz1 != 0)
|
2021-01-04 11:36:54 +00:00
|
|
|
vc += MulScale(dz1, GetWaveValue(a2, nWave), 16);
|
2020-01-26 11:19:01 +00:00
|
|
|
int dz2 = pXSector->onFloorZ - pXSector->offFloorZ;
|
|
|
|
int v10 = pXSector->offFloorZ;
|
|
|
|
if (dz2 != 0)
|
2021-01-04 11:36:54 +00:00
|
|
|
v10 += MulScale(dz2, GetWaveValue(a2, nWave), 16);
|
2020-01-26 11:19:01 +00:00
|
|
|
int v18;
|
|
|
|
if (GetHighestSprite(nSector, 6, &v18) >= 0 && vc >= v18)
|
|
|
|
return 1;
|
|
|
|
viewInterpolateSector(nSector, §or[nSector]);
|
|
|
|
if (dz1 != 0)
|
|
|
|
sector[nSector].ceilingz = vc;
|
|
|
|
if (dz2 != 0)
|
|
|
|
sector[nSector].floorz = v10;
|
|
|
|
pXSector->busy = a2;
|
|
|
|
if (pXSector->command == kCmdLink && pXSector->txID)
|
|
|
|
evSend(nSector, 6, pXSector->txID, kCmdLink);
|
|
|
|
if ((a2&0xffff) == 0)
|
|
|
|
{
|
2020-09-01 13:00:35 +00:00
|
|
|
SetSectorState(nSector, pXSector, FixedToInt(a2));
|
|
|
|
SectorEndSound(nSector, FixedToInt(a2));
|
2020-01-26 11:19:01 +00:00
|
|
|
return 3;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
int VSpriteBusy(unsigned int nSector, unsigned int a2)
|
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
int nXSector = sector[nSector].extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSector > 0 && nXSector < kMaxXSectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
XSECTOR *pXSector = &xsector[nXSector];
|
|
|
|
int nWave;
|
|
|
|
if (pXSector->busy < a2)
|
|
|
|
nWave = pXSector->busyWaveA;
|
|
|
|
else
|
|
|
|
nWave = pXSector->busyWaveB;
|
|
|
|
int dz1 = pXSector->onFloorZ - pXSector->offFloorZ;
|
|
|
|
if (dz1 != 0)
|
|
|
|
{
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2020-01-26 11:19:01 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->cstat&8192)
|
|
|
|
{
|
|
|
|
viewBackupSpriteLoc(nSprite, pSprite);
|
2021-01-04 11:36:54 +00:00
|
|
|
pSprite->z = baseSprite[nSprite].z+MulScale(dz1, GetWaveValue(a2, nWave), 16);
|
2019-09-21 11:02:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
int dz2 = pXSector->onCeilZ - pXSector->offCeilZ;
|
|
|
|
if (dz2 != 0)
|
|
|
|
{
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2020-01-26 11:19:01 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->cstat&16384)
|
|
|
|
{
|
|
|
|
viewBackupSpriteLoc(nSprite, pSprite);
|
2021-01-04 11:36:54 +00:00
|
|
|
pSprite->z = baseSprite[nSprite].z+MulScale(dz2, GetWaveValue(a2, nWave), 16);
|
2019-12-05 20:42:35 +00:00
|
|
|
}
|
2019-11-24 20:53:51 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
pXSector->busy = a2;
|
|
|
|
if (pXSector->command == kCmdLink && pXSector->txID)
|
|
|
|
evSend(nSector, 6, pXSector->txID, kCmdLink);
|
|
|
|
if ((a2&0xffff) == 0)
|
|
|
|
{
|
2020-09-01 13:00:35 +00:00
|
|
|
SetSectorState(nSector, pXSector, FixedToInt(a2));
|
|
|
|
SectorEndSound(nSector, FixedToInt(a2));
|
2020-01-26 11:19:01 +00:00
|
|
|
return 3;
|
2019-12-05 20:42:35 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2019-12-05 20:42:35 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
int VDoorBusy(unsigned int nSector, unsigned int a2)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
int nXSector = sector[nSector].extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSector > 0 && nXSector < kMaxXSectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
XSECTOR *pXSector = &xsector[nXSector];
|
|
|
|
int vbp;
|
|
|
|
if (pXSector->state)
|
|
|
|
vbp = 65536/ClipLow((120*pXSector->busyTimeA)/10, 1);
|
|
|
|
else
|
|
|
|
vbp = -65536/ClipLow((120*pXSector->busyTimeB)/10, 1);
|
|
|
|
int top, bottom;
|
|
|
|
int nSprite = GetCrushedSpriteExtents(nSector,&top,&bottom);
|
|
|
|
if (nSprite >= 0 && a2 > pXSector->busy)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites);
|
2020-01-26 11:19:01 +00:00
|
|
|
XSPRITE *pXSprite = &xsprite[pSprite->extra];
|
|
|
|
if (pXSector->onCeilZ > pXSector->offCeilZ || pXSector->onFloorZ < pXSector->offFloorZ)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
if (pXSector->interruptable)
|
|
|
|
{
|
|
|
|
if (pXSector->Crush)
|
|
|
|
{
|
|
|
|
if (pXSprite->health <= 0)
|
|
|
|
return 2;
|
|
|
|
int nDamage;
|
|
|
|
if (pXSector->data == 0)
|
|
|
|
nDamage = 500;
|
|
|
|
else
|
|
|
|
nDamage = pXSector->data;
|
2021-06-16 19:13:04 +00:00
|
|
|
actDamageSprite(nSprite, &sprite[nSprite], kDamageFall, nDamage<<4);
|
2019-09-21 11:02:17 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
a2 = ClipRange(a2-(vbp/2)*4, 0, 65536);
|
2019-09-21 11:02:17 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
else if (pXSector->Crush && pXSprite->health > 0)
|
|
|
|
{
|
|
|
|
int nDamage;
|
|
|
|
if (pXSector->data == 0)
|
|
|
|
nDamage = 500;
|
|
|
|
else
|
|
|
|
nDamage = pXSector->data;
|
2021-06-16 19:13:04 +00:00
|
|
|
actDamageSprite(nSprite, &sprite[nSprite], kDamageFall, nDamage<<4);
|
2020-01-26 11:19:01 +00:00
|
|
|
a2 = ClipRange(a2-(vbp/2)*4, 0, 65536);
|
2019-10-12 20:45:46 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
else if (nSprite >= 0 && a2 < pXSector->busy)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites);
|
2020-01-26 11:19:01 +00:00
|
|
|
XSPRITE *pXSprite = &xsprite[pSprite->extra];
|
|
|
|
if (pXSector->offCeilZ > pXSector->onCeilZ || pXSector->offFloorZ < pXSector->onFloorZ)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
if (pXSector->interruptable)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
if (pXSector->Crush)
|
|
|
|
{
|
|
|
|
if (pXSprite->health <= 0)
|
|
|
|
return 2;
|
|
|
|
int nDamage;
|
|
|
|
if (pXSector->data == 0)
|
|
|
|
nDamage = 500;
|
|
|
|
else
|
|
|
|
nDamage = pXSector->data;
|
2021-06-16 19:13:04 +00:00
|
|
|
actDamageSprite(nSprite, &sprite[nSprite], kDamageFall, nDamage<<4);
|
2020-01-26 11:19:01 +00:00
|
|
|
}
|
|
|
|
a2 = ClipRange(a2+(vbp/2)*4, 0, 65536);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
else if (pXSector->Crush && pXSprite->health > 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
int nDamage;
|
|
|
|
if (pXSector->data == 0)
|
|
|
|
nDamage = 500;
|
|
|
|
else
|
|
|
|
nDamage = pXSector->data;
|
2021-06-16 19:13:04 +00:00
|
|
|
actDamageSprite(nSprite, &sprite[nSprite], kDamageFall, nDamage<<4);
|
2020-01-26 11:19:01 +00:00
|
|
|
a2 = ClipRange(a2+(vbp/2)*4, 0, 65536);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
int nWave;
|
|
|
|
if (pXSector->busy < a2)
|
|
|
|
nWave = pXSector->busyWaveA;
|
|
|
|
else
|
|
|
|
nWave = pXSector->busyWaveB;
|
|
|
|
ZTranslateSector(nSector, pXSector, a2, nWave);
|
|
|
|
pXSector->busy = a2;
|
|
|
|
if (pXSector->command == kCmdLink && pXSector->txID)
|
|
|
|
evSend(nSector, 6, pXSector->txID, kCmdLink);
|
|
|
|
if ((a2&0xffff) == 0)
|
|
|
|
{
|
2020-09-01 13:00:35 +00:00
|
|
|
SetSectorState(nSector, pXSector, FixedToInt(a2));
|
|
|
|
SectorEndSound(nSector, FixedToInt(a2));
|
2020-01-26 11:19:01 +00:00
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
return 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
int HDoorBusy(unsigned int nSector, unsigned int a2)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
sectortype *pSector = §or[nSector];
|
|
|
|
int nXSector = pSector->extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSector > 0 && nXSector < kMaxXSectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
XSECTOR *pXSector = &xsector[nXSector];
|
|
|
|
int nWave;
|
|
|
|
if (pXSector->busy < a2)
|
|
|
|
nWave = pXSector->busyWaveA;
|
|
|
|
else
|
|
|
|
nWave = pXSector->busyWaveB;
|
|
|
|
spritetype *pSprite1 = &sprite[pXSector->marker0];
|
|
|
|
spritetype *pSprite2 = &sprite[pXSector->marker1];
|
|
|
|
TranslateSector(nSector, GetWaveValue(pXSector->busy, nWave), GetWaveValue(a2, nWave), pSprite1->x, pSprite1->y, pSprite1->x, pSprite1->y, pSprite1->ang, pSprite2->x, pSprite2->y, pSprite2->ang, pSector->type == kSectorSlide);
|
|
|
|
ZTranslateSector(nSector, pXSector, a2, nWave);
|
|
|
|
pXSector->busy = a2;
|
|
|
|
if (pXSector->command == kCmdLink && pXSector->txID)
|
|
|
|
evSend(nSector, 6, pXSector->txID, kCmdLink);
|
|
|
|
if ((a2&0xffff) == 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-09-01 13:00:35 +00:00
|
|
|
SetSectorState(nSector, pXSector, FixedToInt(a2));
|
|
|
|
SectorEndSound(nSector, FixedToInt(a2));
|
2020-01-26 11:19:01 +00:00
|
|
|
return 3;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
return 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
int RDoorBusy(unsigned int nSector, unsigned int a2)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
sectortype *pSector = §or[nSector];
|
|
|
|
int nXSector = pSector->extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSector > 0 && nXSector < kMaxXSectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
XSECTOR *pXSector = &xsector[nXSector];
|
|
|
|
int nWave;
|
|
|
|
if (pXSector->busy < a2)
|
|
|
|
nWave = pXSector->busyWaveA;
|
|
|
|
else
|
|
|
|
nWave = pXSector->busyWaveB;
|
|
|
|
spritetype *pSprite = &sprite[pXSector->marker0];
|
|
|
|
TranslateSector(nSector, GetWaveValue(pXSector->busy, nWave), GetWaveValue(a2, nWave), pSprite->x, pSprite->y, pSprite->x, pSprite->y, 0, pSprite->x, pSprite->y, pSprite->ang, pSector->type == kSectorRotate);
|
|
|
|
ZTranslateSector(nSector, pXSector, a2, nWave);
|
|
|
|
pXSector->busy = a2;
|
|
|
|
if (pXSector->command == kCmdLink && pXSector->txID)
|
|
|
|
evSend(nSector, 6, pXSector->txID, kCmdLink);
|
|
|
|
if ((a2&0xffff) == 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-09-01 13:00:35 +00:00
|
|
|
SetSectorState(nSector, pXSector, FixedToInt(a2));
|
|
|
|
SectorEndSound(nSector, FixedToInt(a2));
|
2020-01-26 11:19:01 +00:00
|
|
|
return 3;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
return 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
int StepRotateBusy(unsigned int nSector, unsigned int a2)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
sectortype *pSector = §or[nSector];
|
|
|
|
int nXSector = pSector->extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSector > 0 && nXSector < kMaxXSectors);
|
2019-09-19 22:42:45 +00:00
|
|
|
XSECTOR *pXSector = &xsector[nXSector];
|
2020-01-26 11:19:01 +00:00
|
|
|
spritetype *pSprite = &sprite[pXSector->marker0];
|
|
|
|
int vbp;
|
|
|
|
if (pXSector->busy < a2)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
vbp = pXSector->data+pSprite->ang;
|
|
|
|
int nWave = pXSector->busyWaveA;
|
|
|
|
TranslateSector(nSector, GetWaveValue(pXSector->busy, nWave), GetWaveValue(a2, nWave), pSprite->x, pSprite->y, pSprite->x, pSprite->y, pXSector->data, pSprite->x, pSprite->y, vbp, 1);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
vbp = pXSector->data-pSprite->ang;
|
|
|
|
int nWave = pXSector->busyWaveB;
|
|
|
|
TranslateSector(nSector, GetWaveValue(pXSector->busy, nWave), GetWaveValue(a2, nWave), pSprite->x, pSprite->y, pSprite->x, pSprite->y, vbp, pSprite->x, pSprite->y, pXSector->data, 1);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
pXSector->busy = a2;
|
|
|
|
if (pXSector->command == kCmdLink && pXSector->txID)
|
|
|
|
evSend(nSector, 6, pXSector->txID, kCmdLink);
|
|
|
|
if ((a2&0xffff) == 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-09-01 13:00:35 +00:00
|
|
|
SetSectorState(nSector, pXSector, FixedToInt(a2));
|
|
|
|
SectorEndSound(nSector, FixedToInt(a2));
|
2020-01-26 11:19:01 +00:00
|
|
|
pXSector->data = vbp&2047;
|
|
|
|
return 3;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
return 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
int GenSectorBusy(unsigned int nSector, unsigned int a2)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2019-09-19 22:42:45 +00:00
|
|
|
sectortype *pSector = §or[nSector];
|
2020-01-26 11:19:01 +00:00
|
|
|
int nXSector = pSector->extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSector > 0 && nXSector < kMaxXSectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
XSECTOR *pXSector = &xsector[nXSector];
|
|
|
|
pXSector->busy = a2;
|
|
|
|
if (pXSector->command == kCmdLink && pXSector->txID)
|
|
|
|
evSend(nSector, 6, pXSector->txID, kCmdLink);
|
|
|
|
if ((a2&0xffff) == 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-09-01 13:00:35 +00:00
|
|
|
SetSectorState(nSector, pXSector, FixedToInt(a2));
|
|
|
|
SectorEndSound(nSector, FixedToInt(a2));
|
2020-01-26 11:19:01 +00:00
|
|
|
return 3;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int PathBusy(unsigned int nSector, unsigned int a2)
|
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
sectortype *pSector = §or[nSector];
|
|
|
|
int nXSector = pSector->extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSector > 0 && nXSector < kMaxXSectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
XSECTOR *pXSector = &xsector[nXSector];
|
|
|
|
spritetype *pSprite = &sprite[basePath[nSector]];
|
|
|
|
spritetype *pSprite1 = &sprite[pXSector->marker0];
|
|
|
|
XSPRITE *pXSprite1 = &xsprite[pSprite1->extra];
|
|
|
|
spritetype *pSprite2 = &sprite[pXSector->marker1];
|
|
|
|
XSPRITE *pXSprite2 = &xsprite[pSprite2->extra];
|
|
|
|
int nWave = pXSprite1->wave;
|
|
|
|
TranslateSector(nSector, GetWaveValue(pXSector->busy, nWave), GetWaveValue(a2, nWave), pSprite->x, pSprite->y, pSprite1->x, pSprite1->y, pSprite1->ang, pSprite2->x, pSprite2->y, pSprite2->ang, 1);
|
|
|
|
ZTranslateSector(nSector, pXSector, a2, nWave);
|
|
|
|
pXSector->busy = a2;
|
|
|
|
if ((a2&0xffff) == 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
evPost(nSector, 6, (120*pXSprite2->waitTime)/10, kCmdOn);
|
|
|
|
pXSector->state = 0;
|
|
|
|
pXSector->busy = 0;
|
|
|
|
if (pXSprite1->data4)
|
|
|
|
PathSound(nSector, pXSprite1->data4);
|
|
|
|
pXSector->marker0 = pXSector->marker1;
|
|
|
|
pXSector->data = pXSprite2->data1;
|
|
|
|
return 3;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
return 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
void OperateDoor(unsigned int nSector, XSECTOR *pXSector, EVENT event, BUSYID busyWave)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
|
|
|
if (!pXSector->busy) break;
|
|
|
|
AddBusy(nSector, busyWave, -65536/ClipLow((pXSector->busyTimeB*120)/10, 1));
|
|
|
|
SectorStartSound(nSector, 1);
|
|
|
|
break;
|
|
|
|
case kCmdOn:
|
|
|
|
if (pXSector->busy == 0x10000) break;
|
|
|
|
AddBusy(nSector, busyWave, 65536/ClipLow((pXSector->busyTimeA*120)/10, 1));
|
|
|
|
SectorStartSound(nSector, 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (pXSector->busy & 0xffff) {
|
|
|
|
if (pXSector->interruptable) {
|
|
|
|
ReverseBusy(nSector, busyWave);
|
|
|
|
pXSector->state = !pXSector->state;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
char t = !pXSector->state; int nDelta;
|
|
|
|
|
|
|
|
if (t) nDelta = 65536/ClipLow((pXSector->busyTimeA*120)/10, 1);
|
|
|
|
else nDelta = -65536/ClipLow((pXSector->busyTimeB*120)/10, 1);
|
|
|
|
|
|
|
|
AddBusy(nSector, busyWave, nDelta);
|
|
|
|
SectorStartSound(nSector, pXSector->state);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
char SectorContainsDudes(int nSector)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
if (sprite[nSprite].statnum == kStatDude)
|
|
|
|
return 1;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
return 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
void TeleFrag(int nKiller, int nSector)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->statnum == kStatDude)
|
2021-06-16 19:13:04 +00:00
|
|
|
actDamageSprite(nKiller, pSprite, kDamageExplode, 4000);
|
2020-01-26 11:19:01 +00:00
|
|
|
else if (pSprite->statnum == kStatThing)
|
2021-06-16 19:13:04 +00:00
|
|
|
actDamageSprite(nKiller, pSprite, kDamageExplode, 4000);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
void OperateTeleport(unsigned int nSector, XSECTOR *pXSector)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
int nDest = pXSector->marker0;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nDest < kMaxSprites);
|
2020-01-26 11:19:01 +00:00
|
|
|
spritetype *pDest = &sprite[nDest];
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pDest->statnum == kStatMarker);
|
|
|
|
assert(pDest->type == kMarkerWarpDest);
|
|
|
|
assert(pDest->sectnum >= 0 && pDest->sectnum < kMaxSectors);
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->statnum == kStatDude)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
PLAYER *pPlayer;
|
|
|
|
char bPlayer = IsPlayerSprite(pSprite);
|
|
|
|
if (bPlayer)
|
|
|
|
pPlayer = &gPlayer[pSprite->type-kDudePlayer1];
|
|
|
|
else
|
|
|
|
pPlayer = NULL;
|
|
|
|
if (bPlayer || !SectorContainsDudes(pDest->sectnum))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
if (!(gGameOptions.uNetGameFlags&2))
|
|
|
|
TeleFrag(pXSector->data, pDest->sectnum);
|
|
|
|
pSprite->x = pDest->x;
|
|
|
|
pSprite->y = pDest->y;
|
|
|
|
pSprite->z += sector[pDest->sectnum].floorz-sector[nSector].floorz;
|
|
|
|
pSprite->ang = pDest->ang;
|
|
|
|
ChangeSpriteSect(nSprite, pDest->sectnum);
|
|
|
|
sfxPlay3DSound(pDest, 201, -1, 0);
|
|
|
|
xvel[nSprite] = yvel[nSprite] = zvel[nSprite] = 0;
|
2020-11-26 16:19:42 +00:00
|
|
|
gInterpolateSprite.Clear(nSprite);
|
2019-09-19 22:42:45 +00:00
|
|
|
viewBackupSpriteLoc(nSprite, pSprite);
|
2020-01-26 11:19:01 +00:00
|
|
|
if (pPlayer)
|
|
|
|
{
|
|
|
|
playerResetInertia(pPlayer);
|
|
|
|
pPlayer->zViewVel = pPlayer->zWeaponVel = 0;
|
2021-08-21 02:43:24 +00:00
|
|
|
pPlayer->angle.settarget(pSprite->ang, true);
|
2020-01-26 11:19:01 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OperatePath(unsigned int nSector, XSECTOR *pXSector, EVENT event)
|
|
|
|
{
|
|
|
|
int nSprite;
|
|
|
|
spritetype *pSprite = NULL;
|
|
|
|
XSPRITE *pXSprite;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
spritetype *pSprite2 = &sprite[pXSector->marker0];
|
|
|
|
XSPRITE *pXSprite2 = &xsprite[pSprite2->extra];
|
|
|
|
int nId = pXSprite2->data2;
|
2020-12-31 14:08:03 +00:00
|
|
|
StatIterator it(kStatPathMarker);
|
2020-10-15 15:15:45 +00:00
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->type == kMarkerPath)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
pXSprite = &xsprite[pSprite->extra];
|
|
|
|
if (pXSprite->data1 == nId)
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
// trigger marker after it gets reached
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
if (gModernMap && pXSprite2->state != 1)
|
2020-02-07 19:47:43 +00:00
|
|
|
trTriggerSprite(pSprite2->index, pXSprite2, kCmdOn);
|
2020-01-26 11:19:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (nSprite < 0) {
|
|
|
|
viewSetSystemMessage("Unable to find path marker with id #%d for path sector #%d", nId, nSector);
|
|
|
|
pXSector->state = 0;
|
|
|
|
pXSector->busy = 0;
|
|
|
|
return;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
|
|
|
|
pXSector->marker1 = nSprite;
|
|
|
|
pXSector->offFloorZ = pSprite2->z;
|
|
|
|
pXSector->onFloorZ = pSprite->z;
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOn:
|
|
|
|
pXSector->state = 0;
|
|
|
|
pXSector->busy = 0;
|
|
|
|
AddBusy(nSector, BUSYID_7, 65536/ClipLow((120*pXSprite2->busyTime)/10,1));
|
|
|
|
if (pXSprite2->data3) PathSound(nSector, pXSprite2->data3);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OperateSector(unsigned int nSector, XSECTOR *pXSector, EVENT event)
|
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
sectortype *pSector = §or[nSector];
|
|
|
|
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
2020-12-06 20:56:09 +00:00
|
|
|
if (gModernMap && modernTypeOperateSector(nSector, pSector, pXSector, event))
|
|
|
|
return;
|
2020-01-26 11:19:01 +00:00
|
|
|
#endif
|
2020-12-06 20:56:09 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdLock:
|
|
|
|
pXSector->locked = 1;
|
|
|
|
break;
|
|
|
|
case kCmdUnlock:
|
|
|
|
pXSector->locked = 0;
|
|
|
|
break;
|
|
|
|
case kCmdToggleLock:
|
|
|
|
pXSector->locked ^= 1;
|
|
|
|
break;
|
|
|
|
case kCmdStopOff:
|
|
|
|
pXSector->stopOn = 0;
|
|
|
|
pXSector->stopOff = 1;
|
|
|
|
break;
|
|
|
|
case kCmdStopOn:
|
|
|
|
pXSector->stopOn = 1;
|
|
|
|
pXSector->stopOff = 0;
|
|
|
|
break;
|
|
|
|
case kCmdStopNext:
|
|
|
|
pXSector->stopOn = 1;
|
|
|
|
pXSector->stopOff = 1;
|
|
|
|
break;
|
|
|
|
default:
|
2020-12-06 20:56:09 +00:00
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
if (gModernMap && pXSector->unused1) break;
|
|
|
|
#endif
|
2020-01-26 11:19:01 +00:00
|
|
|
switch (pSector->type) {
|
|
|
|
case kSectorZMotionSprite:
|
|
|
|
OperateDoor(nSector, pXSector, event, BUSYID_1);
|
|
|
|
break;
|
|
|
|
case kSectorZMotion:
|
|
|
|
OperateDoor(nSector, pXSector, event, BUSYID_2);
|
|
|
|
break;
|
|
|
|
case kSectorSlideMarked:
|
|
|
|
case kSectorSlide:
|
|
|
|
OperateDoor(nSector, pXSector, event, BUSYID_3);
|
|
|
|
break;
|
|
|
|
case kSectorRotateMarked:
|
|
|
|
case kSectorRotate:
|
|
|
|
OperateDoor(nSector, pXSector, event, BUSYID_4);
|
|
|
|
break;
|
|
|
|
case kSectorRotateStep:
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOn:
|
|
|
|
pXSector->state = 0;
|
|
|
|
pXSector->busy = 0;
|
|
|
|
AddBusy(nSector, BUSYID_5, 65536/ClipLow((120*pXSector->busyTimeA)/10, 1));
|
|
|
|
SectorStartSound(nSector, 0);
|
|
|
|
break;
|
|
|
|
case kCmdOff:
|
|
|
|
pXSector->state = 1;
|
|
|
|
pXSector->busy = 65536;
|
|
|
|
AddBusy(nSector, BUSYID_5, -65536/ClipLow((120*pXSector->busyTimeB)/10, 1));
|
|
|
|
SectorStartSound(nSector, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kSectorTeleport:
|
|
|
|
OperateTeleport(nSector, pXSector);
|
|
|
|
break;
|
|
|
|
case kSectorPath:
|
|
|
|
OperatePath(nSector, pXSector, event);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!pXSector->busyTimeA && !pXSector->busyTimeB) {
|
|
|
|
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdOff:
|
|
|
|
SetSectorState(nSector, pXSector, 0);
|
|
|
|
break;
|
|
|
|
case kCmdOn:
|
|
|
|
SetSectorState(nSector, pXSector, 1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SetSectorState(nSector, pXSector, pXSector->state ^ 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
OperateDoor(nSector, pXSector, event, BUSYID_6);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
void InitPath(unsigned int nSector, XSECTOR *pXSector)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
int nSprite;
|
|
|
|
spritetype *pSprite;
|
|
|
|
XSPRITE *pXSprite;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2020-01-26 11:19:01 +00:00
|
|
|
int nId = pXSector->data;
|
2020-12-31 14:08:03 +00:00
|
|
|
StatIterator it(kStatPathMarker);
|
2020-10-15 15:15:45 +00:00
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-26 11:19:01 +00:00
|
|
|
pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->type == kMarkerPath)
|
|
|
|
{
|
|
|
|
pXSprite = &xsprite[pSprite->extra];
|
|
|
|
if (pXSprite->data1 == nId)
|
|
|
|
break;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
|
|
|
|
if (nSprite < 0) {
|
2020-10-11 10:22:36 +00:00
|
|
|
//I_Error("Unable to find path marker with id #%d", nId);
|
2020-01-26 11:19:01 +00:00
|
|
|
viewSetSystemMessage("Unable to find path marker with id #%d for path sector #%d", nId, nSector);
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pXSector->marker0 = nSprite;
|
|
|
|
basePath[nSector] = nSprite;
|
|
|
|
if (pXSector->state)
|
|
|
|
evPost(nSector, 6, 0, kCmdOn);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
void LinkSector(int nSector, XSECTOR *pXSector, EVENT event)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
sectortype *pSector = §or[nSector];
|
2020-01-26 11:19:01 +00:00
|
|
|
int nBusy = GetSourceBusy(event);
|
|
|
|
switch (pSector->type) {
|
|
|
|
case kSectorZMotionSprite:
|
|
|
|
VSpriteBusy(nSector, nBusy);
|
|
|
|
break;
|
|
|
|
case kSectorZMotion:
|
|
|
|
VDoorBusy(nSector, nBusy);
|
|
|
|
break;
|
|
|
|
case kSectorSlideMarked:
|
|
|
|
case kSectorSlide:
|
|
|
|
HDoorBusy(nSector, nBusy);
|
|
|
|
break;
|
|
|
|
case kSectorRotateMarked:
|
|
|
|
case kSectorRotate:
|
2020-11-30 20:43:12 +00:00
|
|
|
// force synchronised input here for now.
|
|
|
|
setForcedSyncInput();
|
2020-01-26 11:19:01 +00:00
|
|
|
RDoorBusy(nSector, nBusy);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pXSector->busy = nBusy;
|
|
|
|
if ((pXSector->busy&0xffff) == 0)
|
2020-09-01 13:00:35 +00:00
|
|
|
SetSectorState(nSector, pXSector, FixedToInt(nBusy));
|
2020-01-26 11:19:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LinkSprite(int nSprite, XSPRITE *pXSprite, EVENT event) {
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
int nBusy = GetSourceBusy(event);
|
2020-04-12 20:30:49 +00:00
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kSwitchCombo:
|
|
|
|
{
|
|
|
|
if (event.type == 3)
|
|
|
|
{
|
|
|
|
int nSprite2 = event.index;
|
|
|
|
int nXSprite2 = sprite[nSprite2].extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSprite2 > 0 && nXSprite2 < kMaxXSprites);
|
2020-02-07 19:47:43 +00:00
|
|
|
pXSprite->data1 = xsprite[nXSprite2].data1;
|
|
|
|
if (pXSprite->data1 == pXSprite->data2)
|
|
|
|
SetSpriteState(nSprite, pXSprite, 1);
|
|
|
|
else
|
|
|
|
SetSpriteState(nSprite, pXSprite, 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-07 19:47:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
pXSprite->busy = nBusy;
|
|
|
|
if ((pXSprite->busy & 0xffff) == 0)
|
2020-09-01 13:00:35 +00:00
|
|
|
SetSpriteState(nSprite, pXSprite, FixedToInt(nBusy));
|
2020-02-07 19:47:43 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-07 19:47:43 +00:00
|
|
|
void LinkWall(int nWall, XWALL *pXWall, EVENT event)
|
|
|
|
{
|
|
|
|
int nBusy = GetSourceBusy(event);
|
|
|
|
pXWall->busy = nBusy;
|
|
|
|
if ((pXWall->busy & 0xffff) == 0)
|
2020-09-01 13:00:35 +00:00
|
|
|
SetWallState(nWall, pXWall, FixedToInt(nBusy));
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-02-07 19:47:43 +00:00
|
|
|
void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command) {
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
2020-02-07 19:47:43 +00:00
|
|
|
if (!pXSector->locked && !pXSector->isTriggered) {
|
|
|
|
|
|
|
|
if (pXSector->triggerOnce)
|
|
|
|
pXSector->isTriggered = 1;
|
|
|
|
|
|
|
|
if (pXSector->decoupled && pXSector->txID > 0)
|
|
|
|
evSend(nSector, 6, pXSector->txID, (COMMAND_ID)pXSector->command);
|
|
|
|
|
|
|
|
else {
|
|
|
|
EVENT event;
|
|
|
|
event.cmd = command;
|
|
|
|
OperateSector(nSector, pXSector, event);
|
|
|
|
}
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-07 19:47:43 +00:00
|
|
|
void trTriggerWall(unsigned int nWall, XWALL *pXWall, int command) {
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nWall < (unsigned int)numwalls);
|
2020-02-07 19:47:43 +00:00
|
|
|
if (!pXWall->locked && !pXWall->isTriggered) {
|
|
|
|
|
|
|
|
if (pXWall->triggerOnce)
|
|
|
|
pXWall->isTriggered = 1;
|
|
|
|
|
|
|
|
if (pXWall->decoupled && pXWall->txID > 0)
|
|
|
|
evSend(nWall, 0, pXWall->txID, (COMMAND_ID)pXWall->command);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-02-07 19:47:43 +00:00
|
|
|
else {
|
|
|
|
EVENT event;
|
|
|
|
event.cmd = command;
|
|
|
|
OperateWall(nWall, pXWall, event);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-07 19:47:43 +00:00
|
|
|
void trTriggerSprite(unsigned int nSprite, XSPRITE *pXSprite, int command) {
|
|
|
|
if (!pXSprite->locked && !pXSprite->isTriggered) {
|
|
|
|
|
|
|
|
if (pXSprite->triggerOnce)
|
|
|
|
pXSprite->isTriggered = 1;
|
2019-09-24 19:58:21 +00:00
|
|
|
|
2020-02-07 19:47:43 +00:00
|
|
|
if (pXSprite->Decoupled && pXSprite->txID > 0)
|
|
|
|
evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command);
|
|
|
|
|
|
|
|
else {
|
|
|
|
EVENT event;
|
|
|
|
event.cmd = command;
|
|
|
|
OperateSprite(nSprite, pXSprite, event);
|
|
|
|
}
|
2019-09-24 19:58:21 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-03 17:00:07 +00:00
|
|
|
void trTriggerSprite(DBloodActor* actor, int command) {
|
|
|
|
trTriggerSprite(actor->s().index, &actor->x(), command);
|
|
|
|
}
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-02-07 19:47:43 +00:00
|
|
|
void trMessageSector(unsigned int nSector, EVENT event) {
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSector < (unsigned int)numsectors);
|
|
|
|
assert(sector[nSector].extra > 0 && sector[nSector].extra < kMaxXSectors);
|
2020-02-07 19:47:43 +00:00
|
|
|
XSECTOR *pXSector = &xsector[sector[nSector].extra];
|
|
|
|
if (!pXSector->locked || event.cmd == kCmdUnlock || event.cmd == kCmdToggleLock) {
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdLink:
|
|
|
|
LinkSector(nSector, pXSector, event);
|
|
|
|
break;
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
case kCmdModernUse:
|
|
|
|
modernTypeTrigger(6, nSector, event);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
OperateSector(nSector, pXSector, event);
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-07 19:47:43 +00:00
|
|
|
void trMessageWall(unsigned int nWall, EVENT event) {
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nWall < (unsigned int)numwalls);
|
|
|
|
assert(wall[nWall].extra > 0 && wall[nWall].extra < kMaxXWalls);
|
2020-02-07 19:47:43 +00:00
|
|
|
|
|
|
|
XWALL *pXWall = &xwall[wall[nWall].extra];
|
|
|
|
if (!pXWall->locked || event.cmd == kCmdUnlock || event.cmd == kCmdToggleLock) {
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdLink:
|
|
|
|
LinkWall(nWall, pXWall, event);
|
|
|
|
break;
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
case kCmdModernUse:
|
|
|
|
modernTypeTrigger(0, nWall, event);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
OperateWall(nWall, pXWall, event);
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-07 19:47:43 +00:00
|
|
|
void trMessageSprite(unsigned int nSprite, EVENT event) {
|
|
|
|
if (sprite[nSprite].statnum != kStatFree) {
|
2019-11-24 20:53:51 +00:00
|
|
|
|
2020-02-07 19:47:43 +00:00
|
|
|
XSPRITE* pXSprite = &xsprite[sprite[nSprite].extra];
|
|
|
|
if (!pXSprite->locked || event.cmd == kCmdUnlock || event.cmd == kCmdToggleLock) {
|
|
|
|
switch (event.cmd) {
|
|
|
|
case kCmdLink:
|
|
|
|
LinkSprite(nSprite, pXSprite, event);
|
2019-11-24 20:53:51 +00:00
|
|
|
break;
|
2020-02-07 19:47:43 +00:00
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
case kCmdModernUse:
|
|
|
|
modernTypeTrigger(3, nSprite, event);
|
2019-11-24 20:53:51 +00:00
|
|
|
break;
|
2020-02-07 19:47:43 +00:00
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
OperateSprite(nSprite, pXSprite, event);
|
2019-11-24 20:53:51 +00:00
|
|
|
break;
|
2019-09-21 11:02:17 +00:00
|
|
|
}
|
2019-11-24 20:53:51 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
void ProcessMotion(void)
|
|
|
|
{
|
|
|
|
sectortype *pSector;
|
|
|
|
int nSector;
|
|
|
|
for (pSector = sector, nSector = 0; nSector < numsectors; nSector++, pSector++)
|
|
|
|
{
|
|
|
|
int nXSector = pSector->extra;
|
|
|
|
if (nXSector <= 0)
|
|
|
|
continue;
|
|
|
|
XSECTOR *pXSector = &xsector[nXSector];
|
|
|
|
if (pXSector->bobSpeed != 0)
|
|
|
|
{
|
|
|
|
if (pXSector->bobAlways)
|
|
|
|
pXSector->bobTheta += pXSector->bobSpeed;
|
|
|
|
else if (pXSector->busy == 0)
|
|
|
|
continue;
|
|
|
|
else
|
2021-01-04 11:36:54 +00:00
|
|
|
pXSector->bobTheta += MulScale(pXSector->bobSpeed, pXSector->busy, 16);
|
|
|
|
int vdi = MulScale(Sin(pXSector->bobTheta), pXSector->bobZRange<<8, 30);
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->cstat&24576)
|
|
|
|
{
|
|
|
|
viewBackupSpriteLoc(nSprite, pSprite);
|
|
|
|
pSprite->z += vdi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pXSector->bobFloor)
|
|
|
|
{
|
|
|
|
int floorZ = pSector->floorz;
|
|
|
|
viewInterpolateSector(nSector, pSector);
|
|
|
|
pSector->floorz = baseFloor[nSector]+vdi;
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
2019-09-30 07:18:01 +00:00
|
|
|
if (pSprite->flags&2)
|
|
|
|
pSprite->flags |= 4;
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pSprite, &top, &bottom);
|
|
|
|
if (bottom >= floorZ && (pSprite->cstat&48) == 0)
|
|
|
|
{
|
|
|
|
viewBackupSpriteLoc(nSprite, pSprite);
|
|
|
|
pSprite->z += vdi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pXSector->bobCeiling)
|
|
|
|
{
|
|
|
|
int ceilZ = pSector->ceilingz;
|
|
|
|
viewInterpolateSector(nSector, pSector);
|
|
|
|
pSector->ceilingz = baseCeil[nSector]+vdi;
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pSprite, &top, &bottom);
|
|
|
|
if (top <= ceilZ && (pSprite->cstat&48) == 0)
|
|
|
|
{
|
|
|
|
viewBackupSpriteLoc(nSprite, pSprite);
|
|
|
|
pSprite->z += vdi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AlignSlopes(void)
|
|
|
|
{
|
|
|
|
sectortype *pSector;
|
|
|
|
int nSector;
|
|
|
|
for (pSector = sector, nSector = 0; nSector < numsectors; nSector++, pSector++)
|
|
|
|
{
|
|
|
|
if (qsector_filler[nSector])
|
|
|
|
{
|
|
|
|
walltype *pWall = &wall[pSector->wallptr+qsector_filler[nSector]];
|
|
|
|
walltype *pWall2 = &wall[pWall->point2];
|
|
|
|
int nNextSector = pWall->nextsector;
|
|
|
|
if (nNextSector >= 0)
|
|
|
|
{
|
|
|
|
int x = (pWall->x+pWall2->x)/2;
|
|
|
|
int y = (pWall->y+pWall2->y)/2;
|
|
|
|
viewInterpolateSector(nSector, pSector);
|
|
|
|
alignflorslope(nSector, x, y, getflorzofslope(nNextSector, x, y));
|
|
|
|
alignceilslope(nSector, x, y, getceilzofslope(nNextSector, x, y));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-11 21:07:05 +00:00
|
|
|
int(*gBusyProc[])(unsigned int, unsigned int) =
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
VCrushBusy,
|
|
|
|
VSpriteBusy,
|
|
|
|
VDoorBusy,
|
|
|
|
HDoorBusy,
|
|
|
|
RDoorBusy,
|
|
|
|
StepRotateBusy,
|
|
|
|
GenSectorBusy,
|
|
|
|
PathBusy
|
|
|
|
};
|
|
|
|
|
|
|
|
void trProcessBusy(void)
|
|
|
|
{
|
|
|
|
memset(velFloor, 0, sizeof(velFloor));
|
|
|
|
memset(velCeil, 0, sizeof(velCeil));
|
|
|
|
for (int i = gBusyCount-1; i >= 0; i--)
|
|
|
|
{
|
2020-12-06 20:56:09 +00:00
|
|
|
int nStatus;
|
2021-05-03 22:03:01 +00:00
|
|
|
int oldBusy = gBusy[i].busy;
|
|
|
|
gBusy[i].busy = ClipRange(oldBusy+gBusy[i].delta*4, 0, 65536);
|
2020-12-06 20:56:09 +00:00
|
|
|
#ifdef NOONE_EXTENSIONS
|
2021-05-03 22:03:01 +00:00
|
|
|
if (!gModernMap || !xsector[sector[gBusy[i].index].extra].unused1) nStatus = gBusyProc[gBusy[i].type](gBusy[i].index, gBusy[i].busy);
|
2020-12-06 20:56:09 +00:00
|
|
|
else nStatus = 3; // allow to pause/continue motion for sectors any time by sending special command
|
|
|
|
#else
|
2021-05-03 22:03:01 +00:00
|
|
|
nStatus = gBusyProc[gBusy[i].type](gBusy[i].at0, gBusy[i].at8);
|
2020-12-06 20:56:09 +00:00
|
|
|
#endif
|
2019-11-08 19:57:01 +00:00
|
|
|
switch (nStatus) {
|
|
|
|
case 1:
|
2020-11-21 19:25:06 +00:00
|
|
|
gBusy[i].busy = oldBusy;
|
2019-11-08 19:57:01 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-11-21 19:25:06 +00:00
|
|
|
gBusy[i].busy = oldBusy;
|
|
|
|
gBusy[i].delta = -gBusy[i].delta;
|
2019-11-08 19:57:01 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
gBusy[i] = gBusy[--gBusyCount];
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ProcessMotion();
|
|
|
|
AlignSlopes();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitGenerator(int);
|
|
|
|
|
|
|
|
void trInit(void)
|
|
|
|
{
|
|
|
|
gBusyCount = 0;
|
|
|
|
for (int i = 0; i < numwalls; i++)
|
|
|
|
{
|
|
|
|
baseWall[i].x = wall[i].x;
|
|
|
|
baseWall[i].y = wall[i].y;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < kMaxSprites; i++)
|
|
|
|
{
|
|
|
|
if (sprite[i].statnum < kStatFree)
|
|
|
|
{
|
2019-09-30 07:18:01 +00:00
|
|
|
sprite[i].inittype = sprite[i].type;
|
2019-09-19 22:42:45 +00:00
|
|
|
baseSprite[i].x = sprite[i].x;
|
|
|
|
baseSprite[i].y = sprite[i].y;
|
|
|
|
baseSprite[i].z = sprite[i].z;
|
|
|
|
}
|
|
|
|
else
|
2019-09-30 07:18:01 +00:00
|
|
|
sprite[i].inittype = -1;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
for (int i = 0; i < numwalls; i++)
|
|
|
|
{
|
|
|
|
int nXWall = wall[i].extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXWall < kMaxXWalls);
|
2019-09-19 22:42:45 +00:00
|
|
|
if (nXWall > 0)
|
|
|
|
{
|
|
|
|
XWALL *pXWall = &xwall[nXWall];
|
|
|
|
if (pXWall->state)
|
|
|
|
pXWall->busy = 65536;
|
|
|
|
}
|
|
|
|
}
|
2020-10-11 10:38:17 +00:00
|
|
|
assert((numsectors >= 0) && (numsectors < kMaxSectors));
|
2019-09-19 22:42:45 +00:00
|
|
|
for (int i = 0; i < numsectors; i++)
|
|
|
|
{
|
|
|
|
sectortype *pSector = §or[i];
|
|
|
|
baseFloor[i] = pSector->floorz;
|
|
|
|
baseCeil[i] = pSector->ceilingz;
|
|
|
|
int nXSector = pSector->extra;
|
|
|
|
if (nXSector > 0)
|
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSector < kMaxXSectors);
|
2019-09-19 22:42:45 +00:00
|
|
|
XSECTOR *pXSector = &xsector[nXSector];
|
|
|
|
if (pXSector->state)
|
|
|
|
pXSector->busy = 65536;
|
2019-09-30 07:18:01 +00:00
|
|
|
switch (pSector->type)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
case kSectorCounter:
|
2020-01-26 11:19:01 +00:00
|
|
|
#ifdef NOONE_EXTENSIONS
|
2020-04-12 20:30:49 +00:00
|
|
|
if (gModernMap)
|
|
|
|
pXSector->triggerOff = false;
|
|
|
|
else
|
2020-01-26 11:19:01 +00:00
|
|
|
#endif
|
2020-04-12 20:30:49 +00:00
|
|
|
pXSector->triggerOnce = 1;
|
2019-10-11 21:59:39 +00:00
|
|
|
evPost(i, 6, 0, kCallbackCounterCheck);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kSectorZMotion:
|
|
|
|
case kSectorZMotionSprite:
|
2019-09-19 22:42:45 +00:00
|
|
|
ZTranslateSector(i, pXSector, pXSector->busy, 1);
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kSectorSlideMarked:
|
|
|
|
case kSectorSlide:
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
spritetype *pSprite1 = &sprite[pXSector->marker0];
|
|
|
|
spritetype *pSprite2 = &sprite[pXSector->marker1];
|
|
|
|
TranslateSector(i, 0, -65536, pSprite1->x, pSprite1->y, pSprite1->x, pSprite1->y, pSprite1->ang, pSprite2->x, pSprite2->y, pSprite2->ang, pSector->type == kSectorSlide);
|
2019-09-19 22:42:45 +00:00
|
|
|
for (int j = 0; j < pSector->wallnum; j++)
|
|
|
|
{
|
|
|
|
baseWall[pSector->wallptr+j].x = wall[pSector->wallptr+j].x;
|
|
|
|
baseWall[pSector->wallptr+j].y = wall[pSector->wallptr+j].y;
|
|
|
|
}
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(i);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
baseSprite[nSprite].x = sprite[nSprite].x;
|
|
|
|
baseSprite[nSprite].y = sprite[nSprite].y;
|
|
|
|
baseSprite[nSprite].z = sprite[nSprite].z;
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
TranslateSector(i, 0, pXSector->busy, pSprite1->x, pSprite1->y, pSprite1->x, pSprite1->y, pSprite1->ang, pSprite2->x, pSprite2->y, pSprite2->ang, pSector->type == kSectorSlide);
|
2019-09-19 22:42:45 +00:00
|
|
|
ZTranslateSector(i, pXSector, pXSector->busy, 1);
|
|
|
|
break;
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
case kSectorRotateMarked:
|
|
|
|
case kSectorRotate:
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
spritetype *pSprite1 = &sprite[pXSector->marker0];
|
|
|
|
TranslateSector(i, 0, -65536, pSprite1->x, pSprite1->y, pSprite1->x, pSprite1->y, 0, pSprite1->x, pSprite1->y, pSprite1->ang, pSector->type == kSectorRotate);
|
2019-09-19 22:42:45 +00:00
|
|
|
for (int j = 0; j < pSector->wallnum; j++)
|
|
|
|
{
|
|
|
|
baseWall[pSector->wallptr+j].x = wall[pSector->wallptr+j].x;
|
|
|
|
baseWall[pSector->wallptr+j].y = wall[pSector->wallptr+j].y;
|
|
|
|
}
|
2020-10-15 14:48:32 +00:00
|
|
|
int nSprite;
|
|
|
|
SectIterator it(i);
|
|
|
|
while ((nSprite = it.NextIndex()) >= 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
baseSprite[nSprite].x = sprite[nSprite].x;
|
|
|
|
baseSprite[nSprite].y = sprite[nSprite].y;
|
|
|
|
baseSprite[nSprite].z = sprite[nSprite].z;
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
TranslateSector(i, 0, pXSector->busy, pSprite1->x, pSprite1->y, pSprite1->x, pSprite1->y, 0, pSprite1->x, pSprite1->y, pSprite1->ang, pSector->type == kSectorRotate);
|
2019-09-19 22:42:45 +00:00
|
|
|
ZTranslateSector(i, pXSector, pXSector->busy, 1);
|
|
|
|
break;
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
case kSectorPath:
|
2019-09-19 22:42:45 +00:00
|
|
|
InitPath(i, pXSector);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < kMaxSprites; i++)
|
|
|
|
{
|
|
|
|
int nXSprite = sprite[i].extra;
|
|
|
|
if (sprite[i].statnum < kStatFree && nXSprite > 0)
|
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSprite < kMaxXSprites);
|
2019-09-19 22:42:45 +00:00
|
|
|
XSPRITE *pXSprite = &xsprite[nXSprite];
|
|
|
|
if (pXSprite->state)
|
|
|
|
pXSprite->busy = 65536;
|
2019-10-11 21:59:39 +00:00
|
|
|
switch (sprite[i].type) {
|
|
|
|
case kSwitchPadlock:
|
2019-09-19 22:42:45 +00:00
|
|
|
pXSprite->triggerOnce = 1;
|
|
|
|
break;
|
2020-01-26 11:19:01 +00:00
|
|
|
#ifdef NOONE_EXTENSIONS
|
2019-10-11 21:59:39 +00:00
|
|
|
case kModernRandom:
|
|
|
|
case kModernRandom2:
|
2020-02-07 19:47:43 +00:00
|
|
|
if (!gModernMap || pXSprite->state == pXSprite->restState) break;
|
2020-03-01 20:36:28 +00:00
|
|
|
evPost(i, 3, (120 * pXSprite->busyTime) / 10, kCmdRepeat);
|
|
|
|
if (pXSprite->waitTime > 0)
|
|
|
|
evPost(i, 3, (pXSprite->waitTime * 120) / 10, pXSprite->restState ? kCmdOn : kCmdOff);
|
2020-02-07 19:47:43 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kModernSeqSpawner:
|
|
|
|
case kModernObjDataAccumulator:
|
|
|
|
case kModernDudeTargetChanger:
|
|
|
|
case kModernEffectSpawner:
|
|
|
|
case kModernWindGenerator:
|
2020-02-07 19:47:43 +00:00
|
|
|
if (pXSprite->state == pXSprite->restState) break;
|
2020-03-01 20:36:28 +00:00
|
|
|
evPost(i, 3, 0, kCmdRepeat);
|
|
|
|
if (pXSprite->waitTime > 0)
|
|
|
|
evPost(i, 3, (pXSprite->waitTime * 120) / 10, pXSprite->restState ? kCmdOn : kCmdOff);
|
2020-02-07 19:47:43 +00:00
|
|
|
break;
|
2020-01-26 11:19:01 +00:00
|
|
|
#endif
|
2019-10-11 21:59:39 +00:00
|
|
|
case kGenTrigger:
|
|
|
|
case kGenDripWater:
|
|
|
|
case kGenDripBlood:
|
|
|
|
case kGenMissileFireball:
|
|
|
|
case kGenDart:
|
|
|
|
case kGenBubble:
|
|
|
|
case kGenBubbleMulti:
|
2020-02-07 19:47:43 +00:00
|
|
|
case kGenMissileEctoSkull:
|
2019-10-11 21:59:39 +00:00
|
|
|
case kGenSound:
|
2019-09-19 22:42:45 +00:00
|
|
|
InitGenerator(i);
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kThingArmedProxBomb:
|
2019-09-19 22:42:45 +00:00
|
|
|
pXSprite->Proximity = 1;
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kThingFallingRock:
|
|
|
|
if (pXSprite->state) sprite[i].flags |= 7;
|
|
|
|
else sprite[i].flags &= ~7;
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-10-25 20:53:41 +00:00
|
|
|
if (pXSprite->Vector) sprite[i].cstat |= CSTAT_SPRITE_BLOCK_HITSCAN;
|
|
|
|
if (pXSprite->Push) sprite[i].cstat |= 4096;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
2019-10-25 20:53:41 +00:00
|
|
|
|
2020-01-11 21:07:05 +00:00
|
|
|
evSend(0, 0, kChannelLevelStart, kCmdOn);
|
2019-10-25 20:53:41 +00:00
|
|
|
switch (gGameOptions.nGameType) {
|
|
|
|
case 1:
|
2020-01-11 21:07:05 +00:00
|
|
|
evSend(0, 0, kChannelLevelStartCoop, kCmdOn);
|
2019-10-25 20:53:41 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-01-11 21:07:05 +00:00
|
|
|
evSend(0, 0, kChannelLevelStartMatch, kCmdOn);
|
2019-10-25 20:53:41 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-01-11 21:07:05 +00:00
|
|
|
evSend(0, 0, kChannelLevelStartMatch, kCmdOn);
|
|
|
|
evSend(0, 0, kChannelLevelStartTeamsOnly, kCmdOn);
|
2019-10-25 20:53:41 +00:00
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void trTextOver(int nId)
|
|
|
|
{
|
2020-08-03 17:11:48 +00:00
|
|
|
const char *pzMessage = currentLevel->GetMessage(nId);
|
2019-09-19 22:42:45 +00:00
|
|
|
if (pzMessage)
|
2019-09-19 06:10:18 +00:00
|
|
|
viewSetMessage(pzMessage, VanillaMode() ? 0 : 8, MESSAGE_PRIORITY_INI); // 8: gold
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitGenerator(int nSprite)
|
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSprite < kMaxSprites);
|
2019-09-19 22:42:45 +00:00
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pSprite->statnum != kMaxStatus);
|
2019-09-19 22:42:45 +00:00
|
|
|
int nXSprite = pSprite->extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSprite > 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
XSPRITE *pXSprite = &xsprite[nXSprite];
|
2019-09-21 11:02:17 +00:00
|
|
|
switch (sprite[nSprite].type) {
|
2019-10-11 21:59:39 +00:00
|
|
|
case kGenTrigger:
|
|
|
|
pSprite->cstat &= ~CSTAT_SPRITE_BLOCK;
|
|
|
|
pSprite->cstat |= CSTAT_SPRITE_INVISIBLE;
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
if (pXSprite->state != pXSprite->restState && pXSprite->busyTime > 0)
|
2020-01-11 21:07:05 +00:00
|
|
|
evPost(nSprite, 3, (120*(pXSprite->busyTime+Random2(pXSprite->data1)))/10, kCmdRepeat);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActivateGenerator(int nSprite)
|
|
|
|
{
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nSprite < kMaxSprites);
|
2019-09-19 22:42:45 +00:00
|
|
|
spritetype *pSprite = &sprite[nSprite];
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(pSprite->statnum != kMaxStatus);
|
2019-09-19 22:42:45 +00:00
|
|
|
int nXSprite = pSprite->extra;
|
2020-10-11 10:38:17 +00:00
|
|
|
assert(nXSprite > 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
XSPRITE *pXSprite = &xsprite[nXSprite];
|
|
|
|
switch (pSprite->type) {
|
2019-10-11 21:59:39 +00:00
|
|
|
case kGenDripWater:
|
|
|
|
case kGenDripBlood: {
|
2019-09-21 11:02:17 +00:00
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pSprite, &top, &bottom);
|
2019-10-11 21:59:39 +00:00
|
|
|
actSpawnThing(pSprite->sectnum, pSprite->x, pSprite->y, bottom, (pSprite->type == kGenDripWater) ? kThingDripWater : kThingDripBlood);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-02-07 19:47:43 +00:00
|
|
|
case kGenSound:
|
|
|
|
sfxPlay3DSound(pSprite, pXSprite->data2, -1, 0);
|
2019-09-21 11:02:17 +00:00
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kGenMissileFireball:
|
|
|
|
switch (pXSprite->data2) {
|
|
|
|
case 0:
|
2020-11-07 14:16:12 +00:00
|
|
|
FireballTrapSeqCallback(3, &bloodActors[nSprite]);
|
2019-10-11 21:59:39 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
seqSpawn(35, 3, nXSprite, nFireballTrapClient);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
seqSpawn(36, 3, nXSprite, nFireballTrapClient);
|
|
|
|
break;
|
2019-09-21 11:02:17 +00:00
|
|
|
}
|
|
|
|
break;
|
2020-02-07 19:47:43 +00:00
|
|
|
case kGenMissileEctoSkull:
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kGenBubble:
|
|
|
|
case kGenBubbleMulti: {
|
2019-09-21 11:02:17 +00:00
|
|
|
int top, bottom;
|
|
|
|
GetSpriteExtents(pSprite, &top, &bottom);
|
2019-10-11 21:59:39 +00:00
|
|
|
gFX.fxSpawn((pSprite->type == kGenBubble) ? FX_23 : FX_26, pSprite->sectnum, pSprite->x, pSprite->y, top, 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void FireballTrapSeqCallback(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-07 14:16:12 +00:00
|
|
|
spritetype* pSprite = &actor->s();
|
2019-09-19 22:42:45 +00:00
|
|
|
if (pSprite->cstat&32)
|
2019-10-11 21:59:39 +00:00
|
|
|
actFireMissile(pSprite, 0, 0, 0, 0, (pSprite->cstat&8) ? 0x4000 : -0x4000, kMissileFireball);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2020-09-01 13:00:35 +00:00
|
|
|
actFireMissile(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), 0, kMissileFireball);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void MGunFireSeqCallback(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
|
|
|
if (pXSprite->data2 > 0 || pXSprite->data1 == 0)
|
|
|
|
{
|
|
|
|
if (pXSprite->data2 > 0)
|
|
|
|
{
|
|
|
|
pXSprite->data2--;
|
|
|
|
if (pXSprite->data2 == 0)
|
2020-11-07 14:16:12 +00:00
|
|
|
evPost(pXSprite->reference, 3, 1, kCmdOff);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-09-01 13:00:35 +00:00
|
|
|
int dx = CosScale16(pSprite->ang)+Random2(1000);
|
|
|
|
int dy = SinScale16(pSprite->ang)+Random2(1000);
|
2019-09-19 22:42:45 +00:00
|
|
|
int dz = Random2(1000);
|
2021-08-30 18:28:24 +00:00
|
|
|
actFireVector(actor, 0, 0, dx, dy, dz, kVectorBullet);
|
2019-09-19 22:42:45 +00:00
|
|
|
sfxPlay3DSound(pSprite, 359, -1, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-07 14:16:12 +00:00
|
|
|
void MGunOpenSeqCallback(int, DBloodActor* actor)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-07 14:16:12 +00:00
|
|
|
seqSpawn(39, 3, actor->s().extra, nMGunFireClient);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-21 19:25:06 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-11-21 19:25:06 +00:00
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, BUSY& w, BUSY* def)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-21 19:25:06 +00:00
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc("index", w.index)
|
|
|
|
("type", w.type)
|
|
|
|
("delta", w.delta)
|
|
|
|
("busy", w.busy)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-11-21 19:25:06 +00:00
|
|
|
void SerializeTriggers(FSerializer& arc)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-11-21 19:25:06 +00:00
|
|
|
if (arc.BeginObject("triggers"))
|
|
|
|
{
|
|
|
|
arc("busycount", gBusyCount)
|
|
|
|
.Array("busy", gBusy, gBusyCount)
|
|
|
|
.Array("basepath", basePath, numsectors)
|
|
|
|
.EndObject();
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|