2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** p_pillar.cpp
|
|
|
|
** Handles pillars
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2006-06-11 01:37:00 +00:00
|
|
|
** Copyright 1998-2006 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_spec.h"
|
|
|
|
#include "g_level.h"
|
|
|
|
#include "s_sndseq.h"
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS (DPillar)
|
|
|
|
|
|
|
|
DPillar::DPillar ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void DPillar::Serialize (FArchive &arc)
|
|
|
|
{
|
|
|
|
Super::Serialize (arc);
|
|
|
|
arc << m_Type
|
|
|
|
<< m_FloorSpeed
|
|
|
|
<< m_CeilingSpeed
|
|
|
|
<< m_FloorTarget
|
|
|
|
<< m_CeilingTarget
|
2008-03-19 22:47:04 +00:00
|
|
|
<< m_Crush
|
|
|
|
<< m_Hexencrush;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DPillar::Tick ()
|
|
|
|
{
|
|
|
|
int r, s;
|
|
|
|
fixed_t oldfloor, oldceiling;
|
|
|
|
|
|
|
|
oldfloor = m_Sector->floorplane.d;
|
|
|
|
oldceiling = m_Sector->ceilingplane.d;
|
|
|
|
|
|
|
|
if (m_Type == pillarBuild)
|
|
|
|
{
|
2008-03-19 22:47:04 +00:00
|
|
|
r = MoveFloor (m_FloorSpeed, m_FloorTarget, m_Crush, 1, m_Hexencrush);
|
|
|
|
s = MoveCeiling (m_CeilingSpeed, m_CeilingTarget, m_Crush, -1, m_Hexencrush);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-19 22:47:04 +00:00
|
|
|
r = MoveFloor (m_FloorSpeed, m_FloorTarget, m_Crush, -1, m_Hexencrush);
|
|
|
|
s = MoveCeiling (m_CeilingSpeed, m_CeilingTarget, m_Crush, 1, m_Hexencrush);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (r == pastdest && s == pastdest)
|
|
|
|
{
|
|
|
|
SN_StopSequence (m_Sector);
|
|
|
|
Destroy ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (r == crushed)
|
|
|
|
{
|
2008-03-19 22:47:04 +00:00
|
|
|
MoveFloor (m_FloorSpeed, oldfloor, -1, -1, m_Hexencrush);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
if (s == crushed)
|
|
|
|
{
|
2008-03-19 22:47:04 +00:00
|
|
|
MoveCeiling (m_CeilingSpeed, oldceiling, -1, 1, m_Hexencrush);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed,
|
2008-03-19 22:47:04 +00:00
|
|
|
fixed_t floordist, fixed_t ceilingdist, int crush, bool hexencrush)
|
2006-02-24 04:48:15 +00:00
|
|
|
: DMover (sector)
|
|
|
|
{
|
|
|
|
fixed_t newheight;
|
|
|
|
vertex_t *spot;
|
|
|
|
|
|
|
|
sector->floordata = sector->ceilingdata = this;
|
|
|
|
setinterpolation (INTERP_SectorFloor, sector);
|
|
|
|
setinterpolation (INTERP_SectorCeiling, sector);
|
|
|
|
|
|
|
|
m_Type = type;
|
|
|
|
m_Crush = crush;
|
2008-03-19 22:47:04 +00:00
|
|
|
m_Hexencrush = hexencrush;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (type == pillarBuild)
|
|
|
|
{
|
|
|
|
// If the pillar height is 0, have the floor and ceiling meet halfway
|
|
|
|
if (floordist == 0)
|
|
|
|
{
|
|
|
|
newheight = (sector->CenterFloor () + sector->CenterCeiling ()) / 2;
|
|
|
|
m_FloorTarget = sector->floorplane.PointToDist (sector->soundorg[0], sector->soundorg[1], newheight);
|
|
|
|
m_CeilingTarget = sector->ceilingplane.PointToDist (sector->soundorg[0], sector->soundorg[1], newheight);
|
|
|
|
floordist = newheight - sector->CenterFloor ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newheight = sector->CenterFloor () + floordist;
|
|
|
|
m_FloorTarget = sector->floorplane.PointToDist (sector->soundorg[0], sector->soundorg[1], newheight);
|
|
|
|
m_CeilingTarget = sector->ceilingplane.PointToDist (sector->soundorg[0], sector->soundorg[1], newheight);
|
|
|
|
}
|
|
|
|
ceilingdist = sector->CenterCeiling () - newheight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If one of the heights is 0, figure it out based on the
|
|
|
|
// surrounding sectors
|
|
|
|
if (floordist == 0)
|
|
|
|
{
|
|
|
|
newheight = sector->FindLowestFloorSurrounding (&spot);
|
|
|
|
m_FloorTarget = sector->floorplane.PointToDist (spot, newheight);
|
|
|
|
floordist = sector->floorplane.ZatPoint (spot) - newheight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newheight = sector->floorplane.ZatPoint (0, 0) - floordist;
|
|
|
|
m_FloorTarget = sector->floorplane.PointToDist (0, 0, newheight);
|
|
|
|
}
|
|
|
|
if (ceilingdist == 0)
|
|
|
|
{
|
|
|
|
newheight = sector->FindHighestCeilingSurrounding (&spot);
|
|
|
|
m_CeilingTarget = sector->ceilingplane.PointToDist (spot, newheight);
|
|
|
|
ceilingdist = newheight - sector->ceilingplane.ZatPoint (spot);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newheight = sector->ceilingplane.ZatPoint (0, 0) + ceilingdist;
|
|
|
|
m_CeilingTarget = sector->ceilingplane.PointToDist (0, 0, newheight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The speed parameter applies to whichever part of the pillar
|
|
|
|
// travels the farthest. The other part's speed is then set so
|
|
|
|
// that it arrives at its destination at the same time.
|
|
|
|
if (floordist > ceilingdist)
|
|
|
|
{
|
|
|
|
m_FloorSpeed = speed;
|
|
|
|
m_CeilingSpeed = Scale (speed, ceilingdist, floordist);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_CeilingSpeed = speed;
|
|
|
|
m_FloorSpeed = Scale (speed, floordist, ceilingdist);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sector->seqType >= 0)
|
- Fixed compilation with mingw again.
- Added multiple-choice sound sequences. These overcome one of the major
deficiences of the Hexen-inherited SNDSEQ system while still being Hexen
compatible: Custom door sounds can now use different opening and closing
sequences, for both normal and blazing speeds.
- Added a serializer for TArray.
- Added a countof macro to doomtype.h. See the1's blog to find out why
it's implemented the way it is.
<http://blogs.msdn.com/the1/articles/210011.aspx>
- Added a new method to FRandom for getting random numbers larger than 255,
which lets me:
- Fixed: SNDSEQ delayrand commands could delay for no more than 255 tics.
- Fixed: If you're going to have sector_t.SoundTarget, then they need to
be included in the pointer cleanup scans.
- Ported back newer name code from 2.1.
- Fixed: Using -warp with only one parameter in Doom and Heretic to
select a map on episode 1 no longer worked.
- New: Loading a multiplayer save now restores the players based on
their names rather than on their connection order. Using connection
order was sensible when -net was the only way to start a network game,
but with -host/-join, it's not so nice. Also, if there aren't enough
players in the save, then the extra players will be spawned normally,
so you can continue a saved game with more players than you started it
with.
- Added some new SNDSEQ commands to make it possible to define Heretic's
ambient sounds in SNDSEQ: volumerel, volumerand, slot, randomsequence,
delayonce, and restart. With these, it is basically possible to obsolete
all of the $ambient SNDINFO commands.
- Fixed: Sound sequences would only execute one command each time they were
ticked.
- Fixed: No bounds checking was done on the volume sound sequences played at.
- Fixed: The tic parameter to playloop was useless and caused it to
act like a redundant playrepeat. I have removed all the logic that
caused playloop to play repeating sounds, and now it acts like an
infinite sequence of play/delay commands until the sequence is
stopped.
- Fixed: Sound sequences were ticked every frame, not every tic, so all
the delay commands were timed incorrectly and varied depending on your
framerate. Since this is useful for restarting looping sounds that got
cut off, I have not changed this. Instead, the delay commands now
record the tic when execution should resume, not the number of tics
left to delay.
SVN r57 (trunk)
2006-04-21 01:22:55 +00:00
|
|
|
SN_StartSequence (sector, sector->seqType, SEQ_PLATFORM, 0);
|
2006-02-24 04:48:15 +00:00
|
|
|
else
|
- Fixed compilation with mingw again.
- Added multiple-choice sound sequences. These overcome one of the major
deficiences of the Hexen-inherited SNDSEQ system while still being Hexen
compatible: Custom door sounds can now use different opening and closing
sequences, for both normal and blazing speeds.
- Added a serializer for TArray.
- Added a countof macro to doomtype.h. See the1's blog to find out why
it's implemented the way it is.
<http://blogs.msdn.com/the1/articles/210011.aspx>
- Added a new method to FRandom for getting random numbers larger than 255,
which lets me:
- Fixed: SNDSEQ delayrand commands could delay for no more than 255 tics.
- Fixed: If you're going to have sector_t.SoundTarget, then they need to
be included in the pointer cleanup scans.
- Ported back newer name code from 2.1.
- Fixed: Using -warp with only one parameter in Doom and Heretic to
select a map on episode 1 no longer worked.
- New: Loading a multiplayer save now restores the players based on
their names rather than on their connection order. Using connection
order was sensible when -net was the only way to start a network game,
but with -host/-join, it's not so nice. Also, if there aren't enough
players in the save, then the extra players will be spawned normally,
so you can continue a saved game with more players than you started it
with.
- Added some new SNDSEQ commands to make it possible to define Heretic's
ambient sounds in SNDSEQ: volumerel, volumerand, slot, randomsequence,
delayonce, and restart. With these, it is basically possible to obsolete
all of the $ambient SNDINFO commands.
- Fixed: Sound sequences would only execute one command each time they were
ticked.
- Fixed: No bounds checking was done on the volume sound sequences played at.
- Fixed: The tic parameter to playloop was useless and caused it to
act like a redundant playrepeat. I have removed all the logic that
caused playloop to play repeating sounds, and now it acts like an
infinite sequence of play/delay commands until the sequence is
stopped.
- Fixed: Sound sequences were ticked every frame, not every tic, so all
the delay commands were timed incorrectly and varied depending on your
framerate. Since this is useful for restarting looping sounds that got
cut off, I have not changed this. Instead, the delay commands now
record the tic when execution should resume, not the number of tics
left to delay.
SVN r57 (trunk)
2006-04-21 01:22:55 +00:00
|
|
|
SN_StartSequence (sector, "Floor", 0);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool EV_DoPillar (DPillar::EPillar type, int tag, fixed_t speed, fixed_t height,
|
2008-03-19 22:47:04 +00:00
|
|
|
fixed_t height2, int crush, bool hexencrush)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
bool rtn = false;
|
|
|
|
int secnum = -1;
|
|
|
|
|
|
|
|
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0)
|
|
|
|
{
|
|
|
|
sector_t *sec = §ors[secnum];
|
|
|
|
|
|
|
|
if (sec->floordata || sec->ceilingdata)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
fixed_t flor, ceil;
|
|
|
|
|
|
|
|
flor = sec->CenterFloor ();
|
|
|
|
ceil = sec->CenterCeiling ();
|
|
|
|
|
|
|
|
if (type == DPillar::pillarBuild && flor == ceil)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (type == DPillar::pillarOpen && flor != ceil)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rtn = true;
|
2008-03-19 22:47:04 +00:00
|
|
|
new DPillar (sec, type, speed, height, height2, crush, hexencrush);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
return rtn;
|
|
|
|
}
|