2016-03-01 15:47:10 +00:00
|
|
|
// Emacs style mode select -*- C++ -*-
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// $Id:$
|
|
|
|
//
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
//
|
|
|
|
// This source is available for distribution and/or modification
|
|
|
|
// only under the terms of the DOOM Source Code License as
|
|
|
|
// published by id Software. All rights reserved.
|
|
|
|
//
|
|
|
|
// The source is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
// $Log:$
|
|
|
|
//
|
|
|
|
// DESCRIPTION: Ceiling animation (lowering, crushing, raising)
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "s_sndseq.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "r_state.h"
|
|
|
|
#include "gi.h"
|
2016-09-19 17:14:30 +00:00
|
|
|
#include "serializer.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
#include "p_spec.h"
|
2017-01-08 17:45:30 +00:00
|
|
|
#include "g_levellocals.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// CEILINGS
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2016-11-24 20:36:02 +00:00
|
|
|
IMPLEMENT_CLASS(DCeiling, false, false)
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
DCeiling::DCeiling ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2016-09-19 17:14:30 +00:00
|
|
|
void DCeiling::Serialize(FSerializer &arc)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
Super::Serialize (arc);
|
2016-09-19 17:14:30 +00:00
|
|
|
arc.Enum("type", m_Type)
|
|
|
|
("bottomheight", m_BottomHeight)
|
|
|
|
("topheight", m_TopHeight)
|
|
|
|
("speed", m_Speed)
|
|
|
|
("speed1", m_Speed1)
|
|
|
|
("speed2", m_Speed2)
|
|
|
|
("crush", m_Crush)
|
|
|
|
("silent", m_Silent)
|
|
|
|
("direction", m_Direction)
|
|
|
|
("texture", m_Texture)
|
|
|
|
("newspecial", m_NewSpecial)
|
|
|
|
("tag", m_Tag)
|
|
|
|
("olddirecton", m_OldDirection)
|
|
|
|
.Enum("crushmode", m_CrushMode);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void DCeiling::PlayCeilingSound ()
|
|
|
|
{
|
|
|
|
if (m_Sector->Flags & SECF_SILENTMOVE) return;
|
|
|
|
if (m_Sector->seqType >= 0)
|
|
|
|
{
|
|
|
|
SN_StartSequence (m_Sector, CHAN_CEILING, m_Sector->seqType, SEQ_PLATFORM, 0, false);
|
|
|
|
}
|
|
|
|
else if (m_Sector->SeqName != NAME_None)
|
|
|
|
{
|
|
|
|
SN_StartSequence (m_Sector, CHAN_CEILING, m_Sector->SeqName, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_Silent == 2)
|
|
|
|
SN_StartSequence (m_Sector, CHAN_CEILING, "Silence", 0);
|
|
|
|
else if (m_Silent == 1)
|
|
|
|
SN_StartSequence (m_Sector, CHAN_CEILING, "CeilingSemiSilent", 0);
|
|
|
|
else
|
|
|
|
SN_StartSequence (m_Sector, CHAN_CEILING, "CeilingNormal", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// DCeiling :: Tick
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void DCeiling::Tick ()
|
|
|
|
{
|
2016-04-08 11:59:03 +00:00
|
|
|
EMoveResult res;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
switch (m_Direction)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
// IN STASIS
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
// UP
|
2016-04-08 12:18:46 +00:00
|
|
|
res = m_Sector->MoveCeiling (m_Speed, m_TopHeight, m_Direction);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-04-08 11:59:03 +00:00
|
|
|
if (res == EMoveResult::pastdest)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
switch (m_Type)
|
|
|
|
{
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilCrushAndRaise:
|
2016-03-01 15:47:10 +00:00
|
|
|
m_Direction = -1;
|
|
|
|
m_Speed = m_Speed1;
|
|
|
|
if (!SN_IsMakingLoopingSound (m_Sector))
|
|
|
|
PlayCeilingSound ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
// movers with texture change, change the texture then get removed
|
|
|
|
case genCeilingChgT:
|
|
|
|
case genCeilingChg0:
|
|
|
|
m_Sector->SetSpecial(&m_NewSpecial);
|
|
|
|
// fall through
|
|
|
|
case genCeilingChg:
|
|
|
|
m_Sector->SetTexture(sector_t::ceiling, m_Texture);
|
|
|
|
// fall through
|
|
|
|
default:
|
|
|
|
SN_StopSequence (m_Sector, CHAN_CEILING);
|
|
|
|
Destroy ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -1:
|
|
|
|
// DOWN
|
2016-04-08 12:18:46 +00:00
|
|
|
res = m_Sector->MoveCeiling (m_Speed, m_BottomHeight, m_Crush, m_Direction, m_CrushMode == ECrushMode::crushHexen);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-04-08 11:59:03 +00:00
|
|
|
if (res == EMoveResult::pastdest)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
switch (m_Type)
|
|
|
|
{
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilCrushAndRaise:
|
|
|
|
case DCeiling::ceilCrushRaiseAndStay:
|
2016-03-01 15:47:10 +00:00
|
|
|
m_Speed = m_Speed2;
|
|
|
|
m_Direction = 1;
|
|
|
|
if (!SN_IsMakingLoopingSound (m_Sector))
|
|
|
|
PlayCeilingSound ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
// in the case of ceiling mover/changer, change the texture
|
|
|
|
// then remove the active ceiling
|
|
|
|
case genCeilingChgT:
|
|
|
|
case genCeilingChg0:
|
|
|
|
m_Sector->SetSpecial(&m_NewSpecial);
|
|
|
|
// fall through
|
|
|
|
case genCeilingChg:
|
|
|
|
m_Sector->SetTexture(sector_t::ceiling, m_Texture);
|
|
|
|
// fall through
|
|
|
|
default:
|
|
|
|
SN_StopSequence (m_Sector, CHAN_CEILING);
|
|
|
|
Destroy ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // ( res != pastdest )
|
|
|
|
{
|
2016-04-08 11:59:03 +00:00
|
|
|
if (res == EMoveResult::crushed)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
switch (m_Type)
|
|
|
|
{
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilCrushAndRaise:
|
|
|
|
case DCeiling::ceilLowerAndCrush:
|
2016-03-25 01:08:22 +00:00
|
|
|
if (m_CrushMode == ECrushMode::crushSlowdown)
|
2016-04-01 14:37:19 +00:00
|
|
|
m_Speed = 1. / 8;
|
2016-10-17 04:19:08 +00:00
|
|
|
break;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
DCeiling::DCeiling (sector_t *sec)
|
|
|
|
: DMovingCeiling (sec)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-30 07:41:46 +00:00
|
|
|
DCeiling::DCeiling (sector_t *sec, double speed1, double speed2, int silent)
|
2016-03-01 15:47:10 +00:00
|
|
|
: DMovingCeiling (sec)
|
|
|
|
{
|
|
|
|
m_Crush = -1;
|
2016-03-25 01:08:22 +00:00
|
|
|
m_CrushMode = ECrushMode::crushDoom;
|
2016-03-01 15:47:10 +00:00
|
|
|
m_Speed = m_Speed1 = speed1;
|
|
|
|
m_Speed2 = speed2;
|
|
|
|
m_Silent = silent;
|
2016-10-06 19:20:49 +00:00
|
|
|
m_BottomHeight = 0;
|
|
|
|
m_TopHeight = 0;
|
|
|
|
m_Direction = 0;
|
|
|
|
m_Texture = FNullTextureID();
|
|
|
|
m_Tag = 0;
|
|
|
|
m_OldDirection = 0;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag,
|
2016-03-30 07:41:46 +00:00
|
|
|
double speed, double speed2, double height,
|
2016-04-09 10:07:34 +00:00
|
|
|
int crush, int silent, int change, DCeiling::ECrushMode hexencrush)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-03-30 07:41:46 +00:00
|
|
|
double targheight = 0; // Silence, GCC
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// if ceiling already moving, don't start a second function on it
|
|
|
|
if (sec->PlaneMoving(sector_t::ceiling))
|
|
|
|
{
|
2016-04-21 14:07:41 +00:00
|
|
|
return false;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// new door thinker
|
2016-04-08 18:44:55 +00:00
|
|
|
DCeiling *ceiling = new DCeiling (sec, speed, speed2, silent & ~4);
|
2017-01-02 20:40:52 +00:00
|
|
|
vertex_t *spot = sec->Lines[0]->v1;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilCrushAndRaise:
|
|
|
|
case DCeiling::ceilCrushRaiseAndStay:
|
2016-03-30 07:41:46 +00:00
|
|
|
ceiling->m_TopHeight = sec->ceilingplane.fD();
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilLowerAndCrush:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->FindHighestFloorPoint (&spot);
|
2016-03-07 16:24:30 +00:00
|
|
|
targheight += height;
|
2016-03-01 15:47:10 +00:00
|
|
|
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = -1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilRaiseToHighest:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->FindHighestCeilingSurrounding (&spot);
|
|
|
|
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = 1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilLowerByValue:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->ceilingplane.ZatPoint (spot) - height;
|
|
|
|
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = -1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilRaiseByValue:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->ceilingplane.ZatPoint (spot) + height;
|
|
|
|
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = 1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilMoveToValue:
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-03-30 07:41:46 +00:00
|
|
|
double diff = height - sec->ceilingplane.ZatPoint (spot);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
targheight = height;
|
|
|
|
if (diff < 0)
|
|
|
|
{
|
|
|
|
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, height);
|
|
|
|
ceiling->m_Direction = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, height);
|
|
|
|
ceiling->m_Direction = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilLowerToHighestFloor:
|
2016-08-03 10:59:40 +00:00
|
|
|
targheight = sec->FindHighestFloorSurrounding (&spot) + height;
|
2016-03-01 15:47:10 +00:00
|
|
|
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = -1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilRaiseToHighestFloor:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->FindHighestFloorSurrounding (&spot);
|
|
|
|
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = 1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilLowerInstant:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->ceilingplane.ZatPoint (spot) - height;
|
|
|
|
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = -1;
|
|
|
|
ceiling->m_Speed = height;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilRaiseInstant:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->ceilingplane.ZatPoint (spot) + height;
|
|
|
|
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = 1;
|
|
|
|
ceiling->m_Speed = height;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilLowerToNearest:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->FindNextLowestCeiling (&spot);
|
|
|
|
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = -1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilRaiseToNearest:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->FindNextHighestCeiling (&spot);
|
|
|
|
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = 1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilLowerToLowest:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->FindLowestCeilingSurrounding (&spot);
|
|
|
|
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = -1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilRaiseToLowest:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->FindLowestCeilingSurrounding (&spot);
|
|
|
|
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = 1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilLowerToFloor:
|
2016-08-03 10:59:40 +00:00
|
|
|
targheight = sec->FindHighestFloorPoint (&spot) + height;
|
2016-03-01 15:47:10 +00:00
|
|
|
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = -1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilRaiseToFloor: // [RH] What's this for?
|
2016-08-03 10:59:40 +00:00
|
|
|
targheight = sec->FindHighestFloorPoint (&spot) + height;
|
2016-03-01 15:47:10 +00:00
|
|
|
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = 1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilLowerToHighest:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->FindHighestCeilingSurrounding (&spot);
|
|
|
|
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = -1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilLowerByTexture:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->ceilingplane.ZatPoint (spot) - sec->FindShortestUpperAround ();
|
|
|
|
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = -1;
|
|
|
|
break;
|
|
|
|
|
2016-04-09 10:07:34 +00:00
|
|
|
case DCeiling::ceilRaiseByTexture:
|
2016-03-01 15:47:10 +00:00
|
|
|
targheight = sec->ceilingplane.ZatPoint (spot) + sec->FindShortestUpperAround ();
|
|
|
|
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
|
|
|
ceiling->m_Direction = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break; // Silence GCC
|
|
|
|
}
|
|
|
|
|
|
|
|
ceiling->m_Tag = tag;
|
|
|
|
ceiling->m_Type = type;
|
|
|
|
ceiling->m_Crush = crush;
|
2016-03-25 01:08:22 +00:00
|
|
|
ceiling->m_CrushMode = hexencrush;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Do not interpolate instant movement ceilings.
|
|
|
|
// Note for ZDoomGL: Check to make sure that you update the sector
|
|
|
|
// after the ceiling moves, because it hasn't actually moved yet.
|
2016-03-30 07:41:46 +00:00
|
|
|
double movedist;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
if (ceiling->m_Direction < 0)
|
|
|
|
{
|
2016-03-30 07:41:46 +00:00
|
|
|
movedist = sec->ceilingplane.fD() - ceiling->m_BottomHeight;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-30 07:41:46 +00:00
|
|
|
movedist = ceiling->m_TopHeight - sec->ceilingplane.fD();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
if (ceiling->m_Speed >= movedist)
|
|
|
|
{
|
|
|
|
ceiling->StopInterpolation(true);
|
2016-04-08 18:44:55 +00:00
|
|
|
if (silent & 4) ceiling->m_Silent = 2;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// set texture/type change properties
|
|
|
|
if (change & 3) // if a texture change is indicated
|
|
|
|
{
|
|
|
|
if (change & 4) // if a numeric model change
|
|
|
|
{
|
|
|
|
sector_t *modelsec;
|
|
|
|
|
|
|
|
//jff 5/23/98 find model with floor at target height if target
|
|
|
|
//is a floor type
|
|
|
|
modelsec = (/*type == ceilRaiseToHighest ||*/
|
2016-04-09 10:07:34 +00:00
|
|
|
type == DCeiling::ceilRaiseToFloor ||
|
2016-03-01 15:47:10 +00:00
|
|
|
/*type == ceilLowerToHighest ||*/
|
2016-04-09 10:07:34 +00:00
|
|
|
type == DCeiling::ceilLowerToFloor) ?
|
2016-03-01 15:47:10 +00:00
|
|
|
sec->FindModelFloorSector (targheight) :
|
|
|
|
sec->FindModelCeilingSector (targheight);
|
|
|
|
if (modelsec != NULL)
|
|
|
|
{
|
|
|
|
ceiling->m_Texture = modelsec->GetTexture(sector_t::ceiling);
|
|
|
|
switch (change & 3)
|
|
|
|
{
|
|
|
|
case 1: // type is zeroed
|
|
|
|
ceiling->m_NewSpecial.Clear();
|
2016-04-09 10:07:34 +00:00
|
|
|
ceiling->m_Type = DCeiling::genCeilingChg0;
|
2016-03-01 15:47:10 +00:00
|
|
|
break;
|
|
|
|
case 2: // type is copied
|
|
|
|
sec->GetSpecial(&ceiling->m_NewSpecial);
|
2016-04-09 10:07:34 +00:00
|
|
|
ceiling->m_Type = DCeiling::genCeilingChgT;
|
2016-03-01 15:47:10 +00:00
|
|
|
break;
|
|
|
|
case 3: // type is left alone
|
2016-04-09 10:07:34 +00:00
|
|
|
ceiling->m_Type = DCeiling::genCeilingChg;
|
2016-03-01 15:47:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (line) // else if a trigger model change
|
|
|
|
{
|
|
|
|
ceiling->m_Texture = line->frontsector->GetTexture(sector_t::ceiling);
|
|
|
|
switch (change & 3)
|
|
|
|
{
|
|
|
|
case 1: // type is zeroed
|
|
|
|
ceiling->m_NewSpecial.Clear();
|
2016-04-09 10:07:34 +00:00
|
|
|
ceiling->m_Type = DCeiling::genCeilingChg0;
|
2016-03-01 15:47:10 +00:00
|
|
|
break;
|
|
|
|
case 2: // type is copied
|
|
|
|
line->frontsector->GetSpecial(&ceiling->m_NewSpecial);
|
2016-04-09 10:07:34 +00:00
|
|
|
ceiling->m_Type = DCeiling::genCeilingChgT;
|
2016-03-01 15:47:10 +00:00
|
|
|
break;
|
|
|
|
case 3: // type is left alone
|
2016-04-09 10:07:34 +00:00
|
|
|
ceiling->m_Type = DCeiling::genCeilingChg;
|
2016-03-01 15:47:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ceiling->PlayCeilingSound ();
|
2016-04-09 10:07:34 +00:00
|
|
|
return ceiling != NULL;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-11-30 00:25:51 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(DCeiling, CreateCeiling)
|
|
|
|
{
|
|
|
|
PARAM_PROLOGUE;
|
2016-12-02 11:06:49 +00:00
|
|
|
PARAM_POINTER_NOT_NULL(sec, sector_t);
|
2016-11-30 00:25:51 +00:00
|
|
|
PARAM_INT(type);
|
|
|
|
PARAM_POINTER(ln, line_t);
|
|
|
|
PARAM_FLOAT(speed);
|
|
|
|
PARAM_FLOAT(speed2);
|
|
|
|
PARAM_FLOAT_DEF(height);
|
|
|
|
PARAM_INT_DEF(crush);
|
|
|
|
PARAM_INT_DEF(silent);
|
|
|
|
PARAM_INT_DEF(change);
|
|
|
|
PARAM_INT_DEF(crushmode);
|
|
|
|
ACTION_RETURN_BOOL(P_CreateCeiling(sec, (DCeiling::ECeiling)type, ln, 0, speed, speed2, height, crush, silent, change, (DCeiling::ECrushMode)crushmode));
|
|
|
|
}
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// EV_DoCeiling
|
|
|
|
// Move a ceiling up/down and all around!
|
|
|
|
//
|
|
|
|
// [RH] Added tag, speed, speed2, height, crush, silent, change params
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line,
|
2016-03-30 07:41:46 +00:00
|
|
|
int tag, double speed, double speed2, double height,
|
2016-03-25 01:08:22 +00:00
|
|
|
int crush, int silent, int change, DCeiling::ECrushMode hexencrush)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
int secnum;
|
|
|
|
bool rtn;
|
|
|
|
sector_t* sec;
|
|
|
|
|
|
|
|
rtn = false;
|
|
|
|
|
|
|
|
// check if a manual trigger, if so do just the sector on the backside
|
|
|
|
if (tag == 0)
|
|
|
|
{
|
|
|
|
if (!line || !(sec = line->backsector))
|
|
|
|
return rtn;
|
2017-01-07 18:32:24 +00:00
|
|
|
secnum = sec->sectornum;
|
2016-03-01 15:47:10 +00:00
|
|
|
// [RH] Hack to let manual crushers be retriggerable, too
|
|
|
|
tag ^= secnum | 0x1000000;
|
|
|
|
P_ActivateInStasisCeiling (tag);
|
2016-04-09 10:07:34 +00:00
|
|
|
return P_CreateCeiling(sec, type, line, tag, speed, speed2, height, crush, silent, change, hexencrush);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reactivate in-stasis ceilings...for certain types.
|
|
|
|
// This restarts a crusher after it has been stopped
|
|
|
|
if (type == DCeiling::ceilCrushAndRaise)
|
|
|
|
{
|
|
|
|
P_ActivateInStasisCeiling (tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
// affects all sectors with the same tag as the linedef
|
|
|
|
FSectorTagIterator it(tag);
|
|
|
|
while ((secnum = it.Next()) >= 0)
|
|
|
|
{
|
2017-01-07 18:32:24 +00:00
|
|
|
rtn |= P_CreateCeiling(&level.sectors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
return rtn;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// Restart a ceiling that's in-stasis
|
|
|
|
// [RH] Passed a tag instead of a line and rewritten to use a list
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void P_ActivateInStasisCeiling (int tag)
|
|
|
|
{
|
|
|
|
DCeiling *scan;
|
|
|
|
TThinkerIterator<DCeiling> iterator;
|
|
|
|
|
|
|
|
while ( (scan = iterator.Next ()) )
|
|
|
|
{
|
|
|
|
if (scan->m_Tag == tag && scan->m_Direction == 0)
|
|
|
|
{
|
|
|
|
scan->m_Direction = scan->m_OldDirection;
|
|
|
|
scan->PlayCeilingSound ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// EV_CeilingCrushStop
|
|
|
|
// Stop a ceiling from crushing!
|
|
|
|
// [RH] Passed a tag instead of a line and rewritten to use a list
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2016-08-09 15:09:12 +00:00
|
|
|
bool EV_CeilingCrushStop (int tag, bool remove)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
bool rtn = false;
|
|
|
|
DCeiling *scan;
|
|
|
|
TThinkerIterator<DCeiling> iterator;
|
|
|
|
|
2016-08-09 15:09:12 +00:00
|
|
|
scan = iterator.Next();
|
|
|
|
while (scan != nullptr)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-08-09 15:09:12 +00:00
|
|
|
DCeiling *next = iterator.Next();
|
2016-03-01 15:47:10 +00:00
|
|
|
if (scan->m_Tag == tag && scan->m_Direction != 0)
|
|
|
|
{
|
2016-08-09 15:09:12 +00:00
|
|
|
if (!remove)
|
|
|
|
{
|
|
|
|
SN_StopSequence(scan->m_Sector, CHAN_CEILING);
|
|
|
|
scan->m_OldDirection = scan->m_Direction;
|
|
|
|
scan->m_Direction = 0; // in-stasis;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scan->Destroy();
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
rtn = true;
|
|
|
|
}
|
2016-08-09 15:09:12 +00:00
|
|
|
scan = next;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rtn;
|
|
|
|
}
|