2014-03-15 16:59:03 +00:00
|
|
|
// SONIC ROBO BLAST 2
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
2021-05-07 15:45:56 +00:00
|
|
|
// Copyright (C) 1999-2021 by Sonic Team Junior.
|
2014-03-15 16:59:03 +00:00
|
|
|
//
|
|
|
|
// This program is free software distributed under the
|
|
|
|
// terms of the GNU General Public License, version 2.
|
|
|
|
// See the 'LICENSE' file for more details.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/// \file p_floor.c
|
|
|
|
/// \brief Floor animation, elevators
|
|
|
|
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "doomstat.h"
|
2016-06-04 20:19:52 +00:00
|
|
|
#include "m_random.h"
|
2014-03-15 16:59:03 +00:00
|
|
|
#include "p_local.h"
|
2016-09-29 13:23:58 +00:00
|
|
|
#include "p_slopes.h"
|
2014-03-15 16:59:03 +00:00
|
|
|
#include "r_state.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "z_zone.h"
|
|
|
|
#include "g_game.h"
|
|
|
|
#include "r_main.h"
|
|
|
|
|
|
|
|
// ==========================================================================
|
|
|
|
// FLOORS
|
|
|
|
// ==========================================================================
|
|
|
|
|
|
|
|
//
|
|
|
|
// Move a plane (floor or ceiling) and check for crushing
|
|
|
|
//
|
|
|
|
result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crush,
|
2020-04-17 23:08:01 +00:00
|
|
|
boolean ceiling, INT32 direction)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
fixed_t lastpos;
|
|
|
|
fixed_t destheight; // used to keep floors/ceilings from moving through each other
|
|
|
|
sector->moved = true;
|
|
|
|
|
2020-04-17 23:08:01 +00:00
|
|
|
if (ceiling)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 23:08:01 +00:00
|
|
|
lastpos = sector->ceilingheight;
|
|
|
|
// moving a ceiling
|
|
|
|
switch (direction)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
// moving a ceiling down
|
|
|
|
// keep ceiling from moving through floors
|
|
|
|
destheight = (dest > sector->floorheight) ? dest : sector->floorheight;
|
|
|
|
if (sector->ceilingheight - speed < destheight)
|
|
|
|
{
|
|
|
|
sector->ceilingheight = destheight;
|
|
|
|
if (P_CheckSector(sector, crush))
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 23:08:01 +00:00
|
|
|
sector->ceilingheight = lastpos;
|
|
|
|
P_CheckSector(sector, crush);
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2020-04-17 23:08:01 +00:00
|
|
|
return pastdest;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// crushing is possible
|
|
|
|
sector->ceilingheight -= speed;
|
|
|
|
if (P_CheckSector(sector, crush))
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 23:08:01 +00:00
|
|
|
sector->ceilingheight = lastpos;
|
|
|
|
P_CheckSector(sector, crush);
|
|
|
|
return crushed;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2020-04-17 23:08:01 +00:00
|
|
|
}
|
|
|
|
break;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 23:08:01 +00:00
|
|
|
case 1:
|
|
|
|
// moving a ceiling up
|
|
|
|
if (sector->ceilingheight + speed > dest)
|
|
|
|
{
|
|
|
|
sector->ceilingheight = dest;
|
|
|
|
if (P_CheckSector(sector, crush) && sector->numattached)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 23:08:01 +00:00
|
|
|
sector->ceilingheight = lastpos;
|
|
|
|
P_CheckSector(sector, crush);
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2020-04-17 23:08:01 +00:00
|
|
|
return pastdest;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sector->ceilingheight += speed;
|
|
|
|
if (P_CheckSector(sector, crush) && sector->numattached)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 23:08:01 +00:00
|
|
|
sector->ceilingheight = lastpos;
|
|
|
|
P_CheckSector(sector, crush);
|
|
|
|
return crushed;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2020-04-17 23:08:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lastpos = sector->floorheight;
|
|
|
|
// moving a floor
|
|
|
|
switch (direction)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
// Moving a floor down
|
|
|
|
if (sector->floorheight - speed < dest)
|
|
|
|
{
|
|
|
|
sector->floorheight = dest;
|
|
|
|
if (P_CheckSector(sector, crush) && sector->numattached)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 23:08:01 +00:00
|
|
|
sector->floorheight = lastpos;
|
|
|
|
P_CheckSector(sector, crush);
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2020-04-17 23:08:01 +00:00
|
|
|
return pastdest;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sector->floorheight -= speed;
|
|
|
|
if (P_CheckSector(sector, crush) && sector->numattached)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 23:08:01 +00:00
|
|
|
sector->floorheight = lastpos;
|
|
|
|
P_CheckSector(sector, crush);
|
|
|
|
return crushed;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2020-04-17 23:08:01 +00:00
|
|
|
}
|
|
|
|
break;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 23:08:01 +00:00
|
|
|
case 1:
|
|
|
|
// Moving a floor up
|
|
|
|
// keep floor from moving through ceilings
|
|
|
|
destheight = (dest < sector->ceilingheight) ? dest : sector->ceilingheight;
|
|
|
|
if (sector->floorheight + speed > destheight)
|
|
|
|
{
|
|
|
|
sector->floorheight = destheight;
|
|
|
|
if (P_CheckSector(sector, crush))
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 23:08:01 +00:00
|
|
|
sector->floorheight = lastpos;
|
|
|
|
P_CheckSector(sector, crush);
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2020-04-17 23:08:01 +00:00
|
|
|
return pastdest;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// crushing is possible
|
|
|
|
sector->floorheight += speed;
|
|
|
|
if (P_CheckSector(sector, crush))
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 23:08:01 +00:00
|
|
|
sector->floorheight = lastpos;
|
|
|
|
P_CheckSector(sector, crush);
|
|
|
|
return crushed;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2020-04-17 23:08:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// MOVE A FLOOR TO ITS DESTINATION (UP OR DOWN)
|
|
|
|
//
|
|
|
|
void T_MoveFloor(floormove_t *movefloor)
|
|
|
|
{
|
|
|
|
result_e res = 0;
|
|
|
|
boolean dontupdate = false;
|
|
|
|
|
|
|
|
if (movefloor->delaytimer)
|
|
|
|
{
|
|
|
|
movefloor->delaytimer--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = T_MovePlane(movefloor->sector,
|
|
|
|
movefloor->speed,
|
|
|
|
movefloor->floordestheight,
|
2020-04-17 23:08:01 +00:00
|
|
|
movefloor->crush, false, movefloor->direction);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
if (movefloor->type == bounceFloor)
|
|
|
|
{
|
|
|
|
const fixed_t origspeed = FixedDiv(movefloor->origspeed,(ELEVATORSPEED/2));
|
|
|
|
const fixed_t fs = abs(movefloor->sector->floorheight - lines[movefloor->texture].frontsector->floorheight);
|
|
|
|
const fixed_t bs = abs(movefloor->sector->floorheight - lines[movefloor->texture].backsector->floorheight);
|
|
|
|
if (fs < bs)
|
|
|
|
movefloor->speed = FixedDiv(fs,25*FRACUNIT) + FRACUNIT/4;
|
|
|
|
else
|
|
|
|
movefloor->speed = FixedDiv(bs,25*FRACUNIT) + FRACUNIT/4;
|
|
|
|
|
|
|
|
movefloor->speed = FixedMul(movefloor->speed,origspeed);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res == pastdest)
|
|
|
|
{
|
|
|
|
if (movefloor->direction == 1)
|
|
|
|
{
|
|
|
|
switch (movefloor->type)
|
|
|
|
{
|
|
|
|
case moveFloorByFrontSector:
|
|
|
|
if (movefloor->texture < -1) // chained linedef executing
|
|
|
|
P_LinedefExecute((INT16)(movefloor->texture + INT16_MAX + 2), NULL, NULL);
|
2017-09-28 13:39:47 +00:00
|
|
|
/* FALLTHRU */
|
2014-03-15 16:59:03 +00:00
|
|
|
case instantMoveFloorByFrontSector:
|
|
|
|
if (movefloor->texture > -1) // flat changing
|
|
|
|
movefloor->sector->floorpic = movefloor->texture;
|
|
|
|
break;
|
|
|
|
case bounceFloor: // Graue 03-12-2004
|
|
|
|
if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight)
|
|
|
|
movefloor->floordestheight = lines[movefloor->texture].backsector->floorheight;
|
|
|
|
else
|
|
|
|
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
|
|
|
|
movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1;
|
|
|
|
movefloor->sector->floorspeed = movefloor->speed * movefloor->direction;
|
|
|
|
movefloor->delaytimer = movefloor->delay;
|
|
|
|
P_RecalcPrecipInSector(movefloor->sector);
|
|
|
|
return; // not break, why did this work? Graue 04-03-2004
|
|
|
|
case bounceFloorCrush: // Graue 03-27-2004
|
|
|
|
if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight)
|
|
|
|
{
|
|
|
|
movefloor->floordestheight = lines[movefloor->texture].backsector->floorheight;
|
|
|
|
movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dy),4*FRACUNIT); // return trip, use dy
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
|
|
|
|
movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dx),4*FRACUNIT); // forward again, use dx
|
|
|
|
}
|
|
|
|
movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1;
|
|
|
|
movefloor->sector->floorspeed = movefloor->speed * movefloor->direction;
|
|
|
|
movefloor->delaytimer = movefloor->delay;
|
|
|
|
P_RecalcPrecipInSector(movefloor->sector);
|
|
|
|
return; // not break, why did this work? Graue 04-03-2004
|
|
|
|
case crushFloorOnce:
|
|
|
|
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
|
|
|
|
movefloor->direction = -1;
|
|
|
|
movefloor->sector->soundorg.z = movefloor->sector->floorheight;
|
|
|
|
S_StartSound(&movefloor->sector->soundorg,sfx_pstop);
|
|
|
|
P_RecalcPrecipInSector(movefloor->sector);
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (movefloor->direction == -1)
|
|
|
|
{
|
|
|
|
switch (movefloor->type)
|
|
|
|
{
|
|
|
|
case moveFloorByFrontSector:
|
|
|
|
if (movefloor->texture < -1) // chained linedef executing
|
|
|
|
P_LinedefExecute((INT16)(movefloor->texture + INT16_MAX + 2), NULL, NULL);
|
2017-09-28 13:39:47 +00:00
|
|
|
/* FALLTHRU */
|
2014-03-15 16:59:03 +00:00
|
|
|
case instantMoveFloorByFrontSector:
|
|
|
|
if (movefloor->texture > -1) // flat changing
|
|
|
|
movefloor->sector->floorpic = movefloor->texture;
|
|
|
|
break;
|
|
|
|
case bounceFloor: // Graue 03-12-2004
|
|
|
|
if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight)
|
|
|
|
movefloor->floordestheight = lines[movefloor->texture].backsector->floorheight;
|
|
|
|
else
|
|
|
|
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
|
|
|
|
movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1;
|
|
|
|
movefloor->sector->floorspeed = movefloor->speed * movefloor->direction;
|
|
|
|
movefloor->delaytimer = movefloor->delay;
|
|
|
|
P_RecalcPrecipInSector(movefloor->sector);
|
|
|
|
return; // not break, why did this work? Graue 04-03-2004
|
|
|
|
case bounceFloorCrush: // Graue 03-27-2004
|
|
|
|
if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight)
|
|
|
|
{
|
|
|
|
movefloor->floordestheight = lines[movefloor->texture].backsector->floorheight;
|
|
|
|
movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dy),4*FRACUNIT); // return trip, use dy
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
|
|
|
|
movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dx),4*FRACUNIT); // forward again, use dx
|
|
|
|
}
|
|
|
|
movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1;
|
|
|
|
movefloor->sector->floorspeed = movefloor->speed * movefloor->direction;
|
|
|
|
movefloor->delaytimer = movefloor->delay;
|
|
|
|
P_RecalcPrecipInSector(movefloor->sector);
|
|
|
|
return; // not break, why did this work? Graue 04-03-2004
|
|
|
|
case crushFloorOnce:
|
|
|
|
movefloor->sector->floordata = NULL; // Clear up the thinker so others can use it
|
|
|
|
P_RemoveThinker(&movefloor->thinker);
|
|
|
|
movefloor->sector->floorspeed = 0;
|
|
|
|
P_RecalcPrecipInSector(movefloor->sector);
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
movefloor->sector->floordata = NULL; // Clear up the thinker so others can use it
|
|
|
|
movefloor->sector->floorspeed = 0;
|
|
|
|
P_RemoveThinker(&movefloor->thinker);
|
|
|
|
dontupdate = true;
|
|
|
|
}
|
|
|
|
if (!dontupdate)
|
|
|
|
movefloor->sector->floorspeed = movefloor->speed*movefloor->direction;
|
|
|
|
else
|
|
|
|
movefloor->sector->floorspeed = 0;
|
|
|
|
|
|
|
|
P_RecalcPrecipInSector(movefloor->sector);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// T_MoveElevator
|
|
|
|
//
|
|
|
|
// Move an elevator to it's destination (up or down)
|
|
|
|
// Called once per tick for each moving floor.
|
|
|
|
//
|
|
|
|
// Passed an elevator_t structure that contains all pertinent info about the
|
|
|
|
// move. See p_spec.h for fields.
|
|
|
|
// No return.
|
|
|
|
//
|
|
|
|
// The function moves the planes differently based on direction, so if it's
|
|
|
|
// traveling really fast, the floor and ceiling won't hit each other and
|
|
|
|
// stop the lift.
|
|
|
|
void T_MoveElevator(elevator_t *elevator)
|
|
|
|
{
|
|
|
|
result_e res1 = 0, res2 = 0, res = 0;
|
|
|
|
boolean dontupdate = false;
|
|
|
|
fixed_t oldfloor, oldceiling;
|
|
|
|
|
|
|
|
if (elevator->delaytimer)
|
|
|
|
{
|
|
|
|
elevator->delaytimer--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (elevator->direction < 0) // moving down
|
|
|
|
{
|
|
|
|
if (elevator->type == elevateContinuous)
|
|
|
|
{
|
|
|
|
const fixed_t origspeed = FixedDiv(elevator->origspeed,(ELEVATORSPEED/2));
|
|
|
|
const fixed_t wh = abs(elevator->sector->floorheight - elevator->floorwasheight);
|
|
|
|
const fixed_t dh = abs(elevator->sector->floorheight - elevator->floordestheight);
|
|
|
|
|
|
|
|
// Slow down when reaching destination Tails 12-06-2000
|
|
|
|
if (wh < dh)
|
|
|
|
elevator->speed = FixedDiv(wh,25*FRACUNIT) + FRACUNIT/4;
|
|
|
|
else
|
|
|
|
elevator->speed = FixedDiv(dh,25*FRACUNIT) + FRACUNIT/4;
|
|
|
|
|
|
|
|
if (elevator->origspeed)
|
|
|
|
{
|
|
|
|
elevator->speed = FixedMul(elevator->speed,origspeed);
|
|
|
|
if (elevator->speed > elevator->origspeed)
|
|
|
|
elevator->speed = (elevator->origspeed);
|
|
|
|
if (elevator->speed < 1)
|
|
|
|
elevator->speed = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (elevator->speed > 3*FRACUNIT)
|
|
|
|
elevator->speed = 3*FRACUNIT;
|
|
|
|
if (elevator->speed < 1)
|
|
|
|
elevator->speed = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
oldfloor = elevator->sector->floorheight;
|
|
|
|
oldceiling = elevator->sector->ceilingheight;
|
|
|
|
|
|
|
|
res1 = T_MovePlane //jff 4/7/98 reverse order of ceiling/floor
|
|
|
|
(
|
|
|
|
elevator->sector,
|
|
|
|
elevator->speed,
|
|
|
|
elevator->ceilingdestheight,
|
|
|
|
elevator->distance,
|
2020-04-17 23:08:01 +00:00
|
|
|
true, // move ceiling
|
2014-03-15 16:59:03 +00:00
|
|
|
elevator->direction
|
|
|
|
);
|
|
|
|
|
|
|
|
res2 = T_MovePlane
|
|
|
|
(
|
|
|
|
elevator->sector,
|
|
|
|
elevator->speed,
|
|
|
|
elevator->floordestheight,
|
|
|
|
elevator->distance,
|
2020-04-17 23:08:01 +00:00
|
|
|
false, // move floor
|
2014-03-15 16:59:03 +00:00
|
|
|
elevator->direction
|
|
|
|
);
|
|
|
|
|
|
|
|
if (elevator->distance && (res1 == crushed || res2 == crushed))
|
|
|
|
{
|
|
|
|
res = crushed;
|
|
|
|
elevator->sector->floorheight = oldfloor;
|
|
|
|
elevator->sector->ceilingheight = oldceiling;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
res = res1;
|
|
|
|
}
|
|
|
|
else // moving up
|
|
|
|
{
|
|
|
|
if (elevator->type == elevateContinuous)
|
|
|
|
{
|
|
|
|
const fixed_t origspeed = FixedDiv(elevator->origspeed,(ELEVATORSPEED/2));
|
|
|
|
const fixed_t wc = abs(elevator->sector->ceilingheight - elevator->ceilingwasheight);
|
|
|
|
const fixed_t dc = abs(elevator->sector->ceilingheight - elevator->ceilingdestheight);
|
|
|
|
// Slow down when reaching destination Tails 12-06-2000
|
|
|
|
if (wc < dc)
|
|
|
|
elevator->speed = FixedDiv(wc,25*FRACUNIT) + FRACUNIT/4;
|
|
|
|
else
|
|
|
|
elevator->speed = FixedDiv(dc,25*FRACUNIT) + FRACUNIT/4;
|
|
|
|
|
|
|
|
if (elevator->origspeed)
|
|
|
|
{
|
|
|
|
elevator->speed = FixedMul(elevator->speed,origspeed);
|
|
|
|
if (elevator->speed > elevator->origspeed)
|
|
|
|
elevator->speed = (elevator->origspeed);
|
|
|
|
if (elevator->speed < 1)
|
|
|
|
elevator->speed = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (elevator->speed > 3*FRACUNIT)
|
|
|
|
elevator->speed = 3*FRACUNIT;
|
|
|
|
if (elevator->speed < 1)
|
|
|
|
elevator->speed = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
oldfloor = elevator->sector->floorheight;
|
|
|
|
oldceiling = elevator->sector->ceilingheight;
|
|
|
|
|
|
|
|
res1 = T_MovePlane //jff 4/7/98 reverse order of ceiling/floor
|
|
|
|
(
|
|
|
|
elevator->sector,
|
|
|
|
elevator->speed,
|
|
|
|
elevator->floordestheight,
|
|
|
|
elevator->distance,
|
2020-04-17 23:08:01 +00:00
|
|
|
false, // move floor
|
2014-03-15 16:59:03 +00:00
|
|
|
elevator->direction
|
|
|
|
);
|
|
|
|
|
|
|
|
if (res1 != crushed)
|
|
|
|
{
|
|
|
|
res2 = T_MovePlane
|
|
|
|
(
|
|
|
|
elevator->sector,
|
|
|
|
elevator->speed,
|
|
|
|
elevator->ceilingdestheight,
|
|
|
|
elevator->distance,
|
2020-04-17 23:08:01 +00:00
|
|
|
true, // move ceiling
|
2014-03-15 16:59:03 +00:00
|
|
|
elevator->direction
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (elevator->distance && (res1 == crushed || res2 == crushed))
|
|
|
|
{
|
|
|
|
res = crushed;
|
|
|
|
elevator->sector->floorheight = oldfloor;
|
|
|
|
elevator->sector->ceilingheight = oldceiling;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
res = res1;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
// make floor move sound
|
|
|
|
if (!(leveltime&7))
|
|
|
|
S_StartSound(&elevator->sector->soundorg, sfx_stnmov);
|
|
|
|
*/
|
|
|
|
if (res == pastdest || res == crushed) // if destination height acheived
|
|
|
|
{
|
|
|
|
if (elevator->type == elevateContinuous)
|
|
|
|
{
|
|
|
|
if (elevator->direction > 0)
|
|
|
|
{
|
|
|
|
elevator->high = 1;
|
|
|
|
elevator->low = 0;
|
|
|
|
elevator->direction = -1;
|
|
|
|
|
|
|
|
if (elevator->origspeed)
|
|
|
|
elevator->speed = elevator->origspeed;
|
|
|
|
else
|
|
|
|
elevator->speed = 3*FRACUNIT;
|
|
|
|
|
|
|
|
elevator->floorwasheight = elevator->floordestheight;
|
|
|
|
elevator->ceilingwasheight = elevator->ceilingdestheight;
|
|
|
|
|
|
|
|
if (elevator->low)
|
|
|
|
{
|
|
|
|
elevator->floordestheight =
|
|
|
|
P_FindNextHighestFloor(elevator->sector, elevator->sector->floorheight);
|
|
|
|
elevator->ceilingdestheight =
|
|
|
|
elevator->floordestheight + elevator->sector->ceilingheight - elevator->sector->floorheight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elevator->floordestheight =
|
|
|
|
P_FindNextLowestFloor(elevator->sector,elevator->sector->floorheight);
|
|
|
|
elevator->ceilingdestheight =
|
|
|
|
elevator->floordestheight + elevator->sector->ceilingheight - elevator->sector->floorheight;
|
|
|
|
}
|
|
|
|
// T_MoveElevator(elevator);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elevator->high = 0;
|
|
|
|
elevator->low = 1;
|
|
|
|
elevator->direction = 1;
|
|
|
|
|
|
|
|
if (elevator->origspeed)
|
|
|
|
elevator->speed = elevator->origspeed;
|
|
|
|
else
|
|
|
|
elevator->speed = 3*FRACUNIT;
|
|
|
|
|
|
|
|
elevator->floorwasheight = elevator->floordestheight;
|
|
|
|
elevator->ceilingwasheight = elevator->ceilingdestheight;
|
|
|
|
|
|
|
|
if (elevator->low)
|
|
|
|
{
|
|
|
|
elevator->floordestheight =
|
|
|
|
P_FindNextHighestFloor(elevator->sector, elevator->sector->floorheight);
|
|
|
|
elevator->ceilingdestheight =
|
|
|
|
elevator->floordestheight + elevator->sector->ceilingheight - elevator->sector->floorheight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elevator->floordestheight =
|
|
|
|
P_FindNextLowestFloor(elevator->sector,elevator->sector->floorheight);
|
|
|
|
elevator->ceilingdestheight =
|
|
|
|
elevator->floordestheight + elevator->sector->ceilingheight - elevator->sector->floorheight;
|
|
|
|
}
|
|
|
|
// T_MoveElevator(elevator);
|
|
|
|
}
|
|
|
|
elevator->delaytimer = elevator->delay;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elevator->sector->floordata = NULL; //jff 2/22/98
|
|
|
|
elevator->sector->ceilingdata = NULL; //jff 2/22/98
|
|
|
|
elevator->sector->ceilspeed = 0;
|
|
|
|
elevator->sector->floorspeed = 0;
|
|
|
|
P_RemoveThinker(&elevator->thinker); // remove elevator from actives
|
|
|
|
dontupdate = true;
|
|
|
|
}
|
|
|
|
// make floor stop sound
|
|
|
|
// S_StartSound(&elevator->sector->soundorg, sfx_pstop);
|
|
|
|
}
|
|
|
|
if (!dontupdate)
|
|
|
|
{
|
|
|
|
elevator->sector->floorspeed = elevator->speed*elevator->direction;
|
|
|
|
elevator->sector->ceilspeed = 42;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elevator->sector->floorspeed = 0;
|
|
|
|
elevator->sector->ceilspeed = 0;
|
|
|
|
elevator->sector->floordata = NULL;
|
|
|
|
elevator->sector->ceilingdata = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// T_ContinuousFalling
|
|
|
|
//
|
|
|
|
// A sector that continuously falls until its ceiling
|
|
|
|
// is below that of its actionsector's floor, then
|
|
|
|
// it instantly returns to its original position and
|
|
|
|
// falls again.
|
|
|
|
//
|
|
|
|
// Useful for things like intermittent falling lava.
|
|
|
|
//
|
2020-04-17 23:42:13 +00:00
|
|
|
void T_ContinuousFalling(continuousfall_t *faller)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 23:42:13 +00:00
|
|
|
faller->sector->ceilingheight += faller->speed*faller->direction;
|
|
|
|
faller->sector->floorheight += faller->speed*faller->direction;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
P_CheckSector(faller->sector, false);
|
|
|
|
|
2020-04-17 23:42:13 +00:00
|
|
|
if ((faller->direction == -1 && faller->sector->ceilingheight <= faller->destheight)
|
|
|
|
|| (faller->direction == 1 && faller->sector->floorheight >= faller->destheight))
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 23:42:13 +00:00
|
|
|
faller->sector->ceilingheight = faller->ceilingstartheight;
|
|
|
|
faller->sector->floorheight = faller->floorstartheight;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
2019-07-17 23:16:01 +00:00
|
|
|
P_CheckSector(faller->sector, false); // you might think this is irrelevant. you would be wrong
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
faller->sector->floorspeed = faller->speed*faller->direction;
|
|
|
|
faller->sector->ceilspeed = 42;
|
|
|
|
faller->sector->moved = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// P_SectorCheckWater
|
|
|
|
//
|
|
|
|
// Like P_MobjCheckWater, but takes a sector instead of a mobj.
|
|
|
|
static fixed_t P_SectorCheckWater(sector_t *analyzesector,
|
|
|
|
sector_t *elevatorsec)
|
|
|
|
{
|
|
|
|
fixed_t watertop;
|
|
|
|
|
|
|
|
// Default if no water exists.
|
|
|
|
watertop = analyzesector->floorheight - 512*FRACUNIT;
|
|
|
|
|
|
|
|
// see if we are in water, and set some flags for later
|
|
|
|
if (analyzesector->ffloors)
|
|
|
|
{
|
|
|
|
ffloor_t *rover;
|
|
|
|
|
|
|
|
for (rover = analyzesector->ffloors; rover; rover = rover->next)
|
|
|
|
{
|
|
|
|
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_SOLID)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// If the sector is below the water, don't bother.
|
|
|
|
if ((elevatorsec->ceilingheight + elevatorsec->floorheight)>>1 < *rover->bottomheight)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Do the same as above if the water is too shallow.
|
|
|
|
if (*rover->topheight < analyzesector->floorheight + abs((elevatorsec->ceilingheight - elevatorsec->floorheight)>>1))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (*rover->topheight > watertop) // highest water block is the one to go for
|
|
|
|
watertop = *rover->topheight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return watertop;
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
// T_BounceCheese ////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
// Bounces a floating cheese
|
|
|
|
|
2020-04-18 08:45:21 +00:00
|
|
|
void T_BounceCheese(bouncecheese_t *bouncer)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 21:32:39 +00:00
|
|
|
fixed_t sectorheight;
|
2014-03-15 16:59:03 +00:00
|
|
|
fixed_t halfheight;
|
|
|
|
fixed_t waterheight;
|
|
|
|
fixed_t floorheight;
|
|
|
|
sector_t *actionsector;
|
2020-04-17 21:32:39 +00:00
|
|
|
boolean remove;
|
2014-03-15 16:59:03 +00:00
|
|
|
INT32 i;
|
2020-04-17 20:26:04 +00:00
|
|
|
mtag_t tag = Tag_FGet(&bouncer->sourceline->tags);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 21:54:37 +00:00
|
|
|
if (bouncer->sector->crumblestate == CRUMBLE_RESTORE || bouncer->sector->crumblestate == CRUMBLE_WAIT
|
|
|
|
|| bouncer->sector->crumblestate == CRUMBLE_ACTIVATED) // Oops! Crumbler says to remove yourself!
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 21:54:37 +00:00
|
|
|
bouncer->sector->crumblestate = CRUMBLE_WAIT;
|
2014-03-15 16:59:03 +00:00
|
|
|
bouncer->sector->ceilingdata = NULL;
|
|
|
|
bouncer->sector->ceilspeed = 0;
|
|
|
|
bouncer->sector->floordata = NULL;
|
|
|
|
bouncer->sector->floorspeed = 0;
|
|
|
|
P_RemoveThinker(&bouncer->thinker); // remove bouncer from actives
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// You can use multiple target sectors, but at your own risk!!!
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS(tag, i)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
actionsector = §ors[i];
|
|
|
|
actionsector->moved = true;
|
|
|
|
|
2020-04-17 21:32:39 +00:00
|
|
|
sectorheight = abs(bouncer->sector->ceilingheight - bouncer->sector->floorheight);
|
|
|
|
halfheight = sectorheight/2;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
waterheight = P_SectorCheckWater(actionsector, bouncer->sector); // sorts itself out if there's no suitable water in the sector
|
|
|
|
|
2020-04-17 21:32:39 +00:00
|
|
|
floorheight = P_FloorzAtPos(actionsector->soundorg.x, actionsector->soundorg.y, bouncer->sector->floorheight, sectorheight);
|
|
|
|
|
|
|
|
remove = false;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// Water level is up to the ceiling.
|
|
|
|
if (waterheight > bouncer->sector->ceilingheight - halfheight && bouncer->sector->ceilingheight >= actionsector->ceilingheight) // Tails 01-08-2004
|
|
|
|
{
|
|
|
|
bouncer->sector->ceilingheight = actionsector->ceilingheight;
|
2020-04-17 21:32:39 +00:00
|
|
|
bouncer->sector->floorheight = actionsector->ceilingheight - sectorheight;
|
|
|
|
remove = true;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
// Water level is too shallow.
|
|
|
|
else if (waterheight < bouncer->sector->floorheight + halfheight && bouncer->sector->floorheight <= floorheight)
|
|
|
|
{
|
2020-04-17 21:32:39 +00:00
|
|
|
bouncer->sector->ceilingheight = floorheight + sectorheight;
|
2014-03-15 16:59:03 +00:00
|
|
|
bouncer->sector->floorheight = floorheight;
|
2020-04-17 21:32:39 +00:00
|
|
|
remove = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bouncer->ceilingwasheight = waterheight + halfheight;
|
|
|
|
bouncer->floorwasheight = waterheight - halfheight;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (remove)
|
|
|
|
{
|
2020-04-17 23:08:01 +00:00
|
|
|
T_MovePlane(bouncer->sector, 0, bouncer->sector->ceilingheight, false, true, -1); // update things on ceiling
|
|
|
|
T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, false, false, -1); // update things on floor
|
2014-03-15 16:59:03 +00:00
|
|
|
P_RecalcPrecipInSector(actionsector);
|
|
|
|
bouncer->sector->ceilingdata = NULL;
|
|
|
|
bouncer->sector->floordata = NULL;
|
|
|
|
bouncer->sector->floorspeed = 0;
|
|
|
|
bouncer->sector->ceilspeed = 0;
|
|
|
|
bouncer->sector->moved = true;
|
|
|
|
P_RemoveThinker(&bouncer->thinker); // remove bouncer from actives
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-24 20:15:31 +00:00
|
|
|
if (bouncer->speed >= 0) // move floor first to fix height desync and any bizarre bugs following that
|
|
|
|
{
|
|
|
|
T_MovePlane(bouncer->sector, bouncer->speed/2, bouncer->sector->floorheight - 70*FRACUNIT,
|
|
|
|
false, false, -1); // move floor
|
|
|
|
T_MovePlane(bouncer->sector, bouncer->speed/2, bouncer->sector->ceilingheight -
|
|
|
|
70*FRACUNIT, false, true, -1); // move ceiling
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
T_MovePlane(bouncer->sector, bouncer->speed/2, bouncer->sector->ceilingheight -
|
|
|
|
70*FRACUNIT, false, true, -1); // move ceiling
|
|
|
|
T_MovePlane(bouncer->sector, bouncer->speed/2, bouncer->sector->floorheight - 70*FRACUNIT,
|
|
|
|
false, false, -1); // move floor
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
bouncer->sector->floorspeed = -bouncer->speed/2;
|
|
|
|
bouncer->sector->ceilspeed = 42;
|
|
|
|
|
2020-04-18 08:45:21 +00:00
|
|
|
if ((bouncer->sector->ceilingheight < bouncer->ceilingwasheight && !bouncer->low) // Down
|
2020-04-17 21:32:39 +00:00
|
|
|
|| (bouncer->sector->ceilingheight > bouncer->ceilingwasheight && bouncer->low)) // Up
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
if (abs(bouncer->speed) < 6*FRACUNIT)
|
|
|
|
bouncer->speed -= bouncer->speed/3;
|
|
|
|
else
|
|
|
|
bouncer->speed -= bouncer->speed/2;
|
|
|
|
|
2020-04-18 08:45:21 +00:00
|
|
|
bouncer->low = !bouncer->low;
|
2014-03-15 16:59:03 +00:00
|
|
|
if (abs(bouncer->speed) > 6*FRACUNIT)
|
|
|
|
{
|
|
|
|
mobj_t *mp = (void *)&actionsector->soundorg;
|
|
|
|
actionsector->soundorg.z = bouncer->sector->floorheight;
|
|
|
|
S_StartSound(mp, sfx_splash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bouncer->sector->ceilingheight < bouncer->ceilingwasheight) // Down
|
|
|
|
{
|
|
|
|
bouncer->speed -= bouncer->distance;
|
|
|
|
}
|
|
|
|
else if (bouncer->sector->ceilingheight > bouncer->ceilingwasheight) // Up
|
|
|
|
{
|
|
|
|
bouncer->speed += gravity;
|
|
|
|
}
|
|
|
|
|
2014-08-04 03:49:33 +00:00
|
|
|
if (abs(bouncer->speed) < 2*FRACUNIT
|
|
|
|
&& abs(bouncer->sector->ceilingheight-bouncer->ceilingwasheight) < FRACUNIT/4)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
bouncer->sector->floorheight = bouncer->floorwasheight;
|
|
|
|
bouncer->sector->ceilingheight = bouncer->ceilingwasheight;
|
2020-04-17 23:08:01 +00:00
|
|
|
T_MovePlane(bouncer->sector, 0, bouncer->sector->ceilingheight, false, true, -1); // update things on ceiling
|
|
|
|
T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, false, false, -1); // update things on floor
|
2014-03-15 16:59:03 +00:00
|
|
|
bouncer->sector->ceilingdata = NULL;
|
|
|
|
bouncer->sector->floordata = NULL;
|
|
|
|
bouncer->sector->floorspeed = 0;
|
|
|
|
bouncer->sector->ceilspeed = 0;
|
|
|
|
bouncer->sector->moved = true;
|
|
|
|
P_RemoveThinker(&bouncer->thinker); // remove bouncer from actives
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bouncer->distance > 0)
|
|
|
|
bouncer->distance--;
|
|
|
|
|
|
|
|
if (actionsector)
|
|
|
|
P_RecalcPrecipInSector(actionsector);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
// T_StartCrumble ////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
// Crumbling platform Tails 03-11-2002
|
2020-04-26 09:55:10 +00:00
|
|
|
void T_StartCrumble(crumble_t *crumble)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
ffloor_t *rover;
|
|
|
|
sector_t *sector;
|
|
|
|
INT32 i;
|
2020-07-10 14:51:11 +00:00
|
|
|
mtag_t tag = Tag_FGet(&crumble->sourceline->tags);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// Once done, the no-return thinker just sits there,
|
|
|
|
// constantly 'returning'... kind of an oxymoron, isn't it?
|
2020-04-26 14:51:14 +00:00
|
|
|
if ((((crumble->flags & CF_REVERSE) && crumble->direction == -1)
|
|
|
|
|| (!(crumble->flags & CF_REVERSE) && crumble->direction == 1))
|
|
|
|
&& !(crumble->flags & CF_RETURN))
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->sector->ceilspeed = 0;
|
|
|
|
crumble->sector->floorspeed = 0;
|
2014-03-15 16:59:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-04-26 14:51:14 +00:00
|
|
|
if (crumble->timer != 0)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-26 14:51:14 +00:00
|
|
|
if (crumble->timer > 0) // Count down the timer
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-26 14:51:14 +00:00
|
|
|
if (--crumble->timer <= 0)
|
|
|
|
crumble->timer = -15*TICRATE; // Timer until platform returns to original position.
|
2014-03-15 16:59:03 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Timer isn't up yet, so just keep waiting.
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->sector->ceilspeed = 0;
|
|
|
|
crumble->sector->floorspeed = 0;
|
2014-03-15 16:59:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-04-26 14:51:14 +00:00
|
|
|
else if (++crumble->timer == 0) // Reposition back to original spot
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS(tag, i)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
sector = §ors[i];
|
|
|
|
|
|
|
|
for (rover = sector->ffloors; rover; rover = rover->next)
|
|
|
|
{
|
2020-04-26 14:51:14 +00:00
|
|
|
if (!(rover->flags & FF_CRUMBLE))
|
|
|
|
continue;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-26 14:51:14 +00:00
|
|
|
if (!(rover->flags & FF_FLOATBOB))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (rover->master != crumble->sourceline)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rover->alpha = crumble->origalpha;
|
|
|
|
|
|
|
|
if (rover->alpha == 0xff)
|
|
|
|
rover->flags &= ~FF_TRANSLUCENT;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Up!
|
2020-04-26 14:51:14 +00:00
|
|
|
if (crumble->flags & CF_REVERSE)
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->direction = -1;
|
2014-03-15 16:59:03 +00:00
|
|
|
else
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->direction = 1;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->sector->ceilspeed = 0;
|
|
|
|
crumble->sector->floorspeed = 0;
|
2014-03-15 16:59:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Flash to indicate that the platform is about to return.
|
2020-04-26 14:51:14 +00:00
|
|
|
if (crumble->timer > -224 && (leveltime % ((abs(crumble->timer)/8) + 1) == 0))
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS(tag, i)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
sector = §ors[i];
|
|
|
|
|
|
|
|
for (rover = sector->ffloors; rover; rover = rover->next)
|
|
|
|
{
|
2020-04-26 14:51:14 +00:00
|
|
|
if (rover->flags & FF_NORETURN)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!(rover->flags & FF_CRUMBLE))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!(rover->flags & FF_FLOATBOB))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (rover->master != crumble->sourceline)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (rover->alpha == crumble->origalpha)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-26 14:51:14 +00:00
|
|
|
rover->flags |= FF_TRANSLUCENT;
|
|
|
|
rover->alpha = 0x00;
|
|
|
|
}
|
|
|
|
else
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-26 14:51:14 +00:00
|
|
|
rover->alpha = crumble->origalpha;
|
|
|
|
|
|
|
|
if (rover->alpha == 0xff)
|
|
|
|
rover->flags &= ~FF_TRANSLUCENT;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We're about to go back to the original position,
|
|
|
|
// so set this to let other thinkers know what is
|
|
|
|
// about to happen.
|
2020-04-26 14:51:14 +00:00
|
|
|
if (crumble->timer < 0 && crumble->timer > -3)
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->sector->crumblestate = CRUMBLE_RESTORE; // makes T_BounceCheese remove itself
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
2020-04-26 14:51:14 +00:00
|
|
|
if ((!(crumble->flags & CF_REVERSE) && crumble->direction == -1)
|
|
|
|
|| ((crumble->flags & CF_REVERSE) && crumble->direction == 1)) // Down
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->sector->crumblestate = CRUMBLE_FALL; // Allow floating now.
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// Only fall like this if it isn't meant to float on water
|
2020-04-26 14:51:14 +00:00
|
|
|
if (!(crumble->flags & CF_FLOATBOB))
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->speed += gravity; // Gain more and more speed
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-26 14:51:14 +00:00
|
|
|
if ((!(crumble->flags & CF_REVERSE) && crumble->sector->ceilingheight >= -16384*FRACUNIT)
|
|
|
|
|| ((crumble->flags & CF_REVERSE) && crumble->sector->ceilingheight <= 16384*FRACUNIT))
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
T_MovePlane //jff 4/7/98 reverse order of ceiling/floor
|
|
|
|
(
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->sector,
|
|
|
|
crumble->speed,
|
2020-04-26 14:51:14 +00:00
|
|
|
crumble->sector->ceilingheight + crumble->direction*crumble->speed*2,
|
2020-04-17 23:08:01 +00:00
|
|
|
false,
|
|
|
|
true, // move ceiling
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->direction
|
2014-03-15 16:59:03 +00:00
|
|
|
);
|
|
|
|
|
2020-04-26 14:51:14 +00:00
|
|
|
T_MovePlane
|
|
|
|
(
|
|
|
|
crumble->sector,
|
|
|
|
crumble->speed,
|
|
|
|
crumble->sector->floorheight + crumble->direction*crumble->speed*2,
|
|
|
|
false,
|
|
|
|
false, // move floor
|
|
|
|
crumble->direction
|
2014-03-15 16:59:03 +00:00
|
|
|
);
|
|
|
|
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->sector->ceilspeed = 42;
|
|
|
|
crumble->sector->floorspeed = crumble->speed*crumble->direction;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // Up (restore to original position)
|
|
|
|
{
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->sector->crumblestate = CRUMBLE_WAIT;
|
|
|
|
crumble->sector->ceilingheight = crumble->ceilingwasheight;
|
|
|
|
crumble->sector->floorheight = crumble->floorwasheight;
|
|
|
|
crumble->sector->floordata = NULL;
|
|
|
|
crumble->sector->ceilingdata = NULL;
|
|
|
|
crumble->sector->ceilspeed = 0;
|
|
|
|
crumble->sector->floorspeed = 0;
|
|
|
|
crumble->sector->moved = true;
|
|
|
|
P_RemoveThinker(&crumble->thinker);
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS(tag, i)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
sector = §ors[i];
|
|
|
|
sector->moved = true;
|
|
|
|
P_RecalcPrecipInSector(sector);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
// T_MarioBlock //////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
// Mario hits a block!
|
|
|
|
//
|
2020-04-18 00:05:23 +00:00
|
|
|
void T_MarioBlock(mariothink_t *block)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
INT32 i;
|
|
|
|
|
|
|
|
T_MovePlane
|
|
|
|
(
|
|
|
|
block->sector,
|
|
|
|
block->speed,
|
|
|
|
block->sector->ceilingheight + 70*FRACUNIT * block->direction,
|
2020-04-17 23:08:01 +00:00
|
|
|
false,
|
|
|
|
true, // move ceiling
|
2014-03-15 16:59:03 +00:00
|
|
|
block->direction
|
|
|
|
);
|
|
|
|
|
|
|
|
T_MovePlane
|
|
|
|
(
|
|
|
|
block->sector,
|
|
|
|
block->speed,
|
|
|
|
block->sector->floorheight + 70*FRACUNIT * block->direction,
|
2020-04-17 23:08:01 +00:00
|
|
|
false,
|
|
|
|
false, // move floor
|
2014-03-15 16:59:03 +00:00
|
|
|
block->direction
|
|
|
|
);
|
|
|
|
|
2020-04-18 00:05:23 +00:00
|
|
|
if (block->sector->ceilingheight >= block->ceilingstartheight + 32*FRACUNIT) // Go back down now..
|
|
|
|
block->direction *= -1;
|
|
|
|
else if (block->sector->ceilingheight <= block->ceilingstartheight)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-18 00:05:23 +00:00
|
|
|
block->sector->ceilingheight = block->ceilingstartheight;
|
|
|
|
block->sector->floorheight = block->floorstartheight;
|
2014-03-15 16:59:03 +00:00
|
|
|
P_RemoveThinker(&block->thinker);
|
|
|
|
block->sector->floordata = NULL;
|
|
|
|
block->sector->ceilingdata = NULL;
|
|
|
|
block->sector->floorspeed = 0;
|
|
|
|
block->sector->ceilspeed = 0;
|
2016-11-22 16:21:30 +00:00
|
|
|
block->direction = 0;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS((INT16)block->tag, i)
|
2014-03-15 16:59:03 +00:00
|
|
|
P_RecalcPrecipInSector(§ors[i]);
|
|
|
|
}
|
|
|
|
|
2020-04-17 22:26:49 +00:00
|
|
|
void T_FloatSector(floatthink_t *floater)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
fixed_t cheeseheight;
|
2020-04-17 22:26:49 +00:00
|
|
|
fixed_t waterheight;
|
2014-03-15 16:59:03 +00:00
|
|
|
sector_t *actionsector;
|
|
|
|
INT32 secnum;
|
|
|
|
|
|
|
|
// Just find the first sector with the tag.
|
|
|
|
// Doesn't work with multiple sectors that have different floor/ceiling heights.
|
2020-04-25 08:47:45 +00:00
|
|
|
if ((secnum = Tag_Iterate_Sectors((INT16)floater->tag, 0)) < 0)
|
2020-04-17 22:26:49 +00:00
|
|
|
return;
|
|
|
|
actionsector = §ors[secnum];
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 22:26:49 +00:00
|
|
|
cheeseheight = (floater->sector->ceilingheight + floater->sector->floorheight)>>1;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 22:26:49 +00:00
|
|
|
//boolean floatanyway = false; // Ignore the crumblestate setting.
|
|
|
|
waterheight = P_SectorCheckWater(actionsector, floater->sector); // find the highest suitable water block around
|
|
|
|
|
|
|
|
if (waterheight == cheeseheight) // same height, no floating needed
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (floater->sector->floorheight == actionsector->floorheight && waterheight < cheeseheight) // too low
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (floater->sector->ceilingheight == actionsector->ceilingheight && waterheight > cheeseheight) // too high
|
|
|
|
return;
|
|
|
|
|
|
|
|
// we have something to float in! Or we're for some reason above the ground, let's fall anyway
|
|
|
|
if (floater->sector->crumblestate == CRUMBLE_NONE || floater->sector->crumblestate >= CRUMBLE_FALL/* || floatanyway*/)
|
|
|
|
EV_BounceSector(floater->sector, FRACUNIT, floater->sourceline);
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static mobj_t *SearchMarioNode(msecnode_t *node)
|
|
|
|
{
|
|
|
|
mobj_t *thing = NULL;
|
2016-06-09 13:16:02 +00:00
|
|
|
for (; node; node = node->m_thinglist_next)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
// Things which should NEVER be ejected from a MarioBlock, by type.
|
|
|
|
switch (node->m_thing->type)
|
|
|
|
{
|
|
|
|
case MT_NULL:
|
|
|
|
case MT_UNKNOWN:
|
2017-10-04 16:45:03 +00:00
|
|
|
case MT_TAILSOVERLAY:
|
2014-03-15 16:59:03 +00:00
|
|
|
case MT_THOK:
|
|
|
|
case MT_GHOST:
|
|
|
|
case MT_OVERLAY:
|
|
|
|
case MT_EMERALDSPAWN:
|
2016-10-13 14:13:33 +00:00
|
|
|
case MT_ELEMENTAL_ORB:
|
|
|
|
case MT_ATTRACT_ORB:
|
|
|
|
case MT_FORCE_ORB:
|
2016-10-13 14:13:33 +00:00
|
|
|
case MT_ARMAGEDDON_ORB:
|
|
|
|
case MT_WHIRLWIND_ORB:
|
2016-10-13 14:13:33 +00:00
|
|
|
case MT_PITY_ORB:
|
|
|
|
case MT_FLAMEAURA_ORB:
|
|
|
|
case MT_BUBBLEWRAP_ORB:
|
|
|
|
case MT_THUNDERCOIN_ORB:
|
2014-03-15 16:59:03 +00:00
|
|
|
case MT_IVSP:
|
|
|
|
case MT_SUPERSPARK:
|
|
|
|
case MT_RAIN:
|
|
|
|
case MT_SNOWFLAKE:
|
|
|
|
case MT_SPLISH:
|
2019-10-05 08:00:59 +00:00
|
|
|
case MT_LAVASPLISH:
|
2014-03-15 16:59:03 +00:00
|
|
|
case MT_SMOKE:
|
|
|
|
case MT_SMALLBUBBLE:
|
|
|
|
case MT_MEDIUMBUBBLE:
|
|
|
|
case MT_TFOG:
|
|
|
|
case MT_SEED:
|
|
|
|
case MT_PARTICLE:
|
|
|
|
case MT_SCORE:
|
|
|
|
case MT_DROWNNUMBERS:
|
|
|
|
case MT_GOTEMERALD:
|
2017-03-22 18:51:30 +00:00
|
|
|
case MT_LOCKON:
|
2014-03-15 16:59:03 +00:00
|
|
|
case MT_TAG:
|
2017-03-23 19:11:22 +00:00
|
|
|
case MT_GOTFLAG:
|
2014-03-15 16:59:03 +00:00
|
|
|
case MT_HOOP:
|
|
|
|
case MT_HOOPCOLLIDE:
|
|
|
|
case MT_NIGHTSCORE:
|
|
|
|
case MT_NAMECHECK: // DEFINITELY not this, because it is client-side.
|
|
|
|
continue;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Ignore popped monitors, too.
|
2016-10-12 21:06:40 +00:00
|
|
|
if (node->m_thing->health == 0 // this only really applies for monitors
|
|
|
|
|| (!(node->m_thing->flags & MF_MONITOR) && (mobjinfo[node->m_thing->type].flags & MF_MONITOR))) // gold monitor support
|
2014-03-15 16:59:03 +00:00
|
|
|
continue;
|
|
|
|
// Okay, we found something valid.
|
|
|
|
if (!thing // take either the first thing
|
|
|
|
|| node->m_thing->x < thing->x // or the thing with the lowest x value (left to right item order)
|
|
|
|
|| node->m_thing->y < thing->y) // or the thing with the lowest y value (top to bottom item order)
|
|
|
|
thing = node->m_thing;
|
|
|
|
}
|
|
|
|
return thing;
|
|
|
|
}
|
|
|
|
|
2020-04-18 09:05:58 +00:00
|
|
|
void T_MarioBlockChecker(mariocheck_t *block)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
line_t *masterline = block->sourceline;
|
|
|
|
if (SearchMarioNode(block->sector->touching_thinglist))
|
2016-06-06 18:02:08 +00:00
|
|
|
{
|
|
|
|
sides[masterline->sidenum[0]].midtexture = sides[masterline->sidenum[0]].bottomtexture; // Update textures
|
2017-01-16 17:33:07 +00:00
|
|
|
if (masterline->backsector)
|
|
|
|
block->sector->ceilingpic = block->sector->floorpic = masterline->backsector->ceilingpic; // Update flats to be backside's ceiling
|
2016-06-06 18:02:08 +00:00
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
else
|
2016-06-06 18:02:08 +00:00
|
|
|
{
|
2014-03-15 16:59:03 +00:00
|
|
|
sides[masterline->sidenum[0]].midtexture = sides[masterline->sidenum[0]].toptexture;
|
2017-01-16 17:33:07 +00:00
|
|
|
if (masterline->backsector)
|
|
|
|
block->sector->ceilingpic = block->sector->floorpic = masterline->backsector->floorpic; // Update flats to be backside's floor
|
2016-06-06 18:02:08 +00:00
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
static boolean P_IsPlayerValid(size_t playernum)
|
|
|
|
{
|
|
|
|
if (!playeringame[playernum])
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!players[playernum].mo)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (players[playernum].mo->health <= 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (players[playernum].spectator)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
// This is the Thwomp's 'brain'. It looks around for players nearby, and if
|
|
|
|
// it finds any, **SMASH**!!! Muahahhaa....
|
2020-04-18 08:26:03 +00:00
|
|
|
void T_ThwompSector(thwomp_t *thwomp)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
fixed_t thwompx, thwompy;
|
|
|
|
sector_t *actionsector;
|
2018-09-07 22:14:52 +00:00
|
|
|
ffloor_t *rover = NULL;
|
2014-03-15 16:59:03 +00:00
|
|
|
INT32 secnum;
|
2020-04-18 08:26:03 +00:00
|
|
|
fixed_t speed;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// If you just crashed down, wait a second before coming back up.
|
2020-04-18 08:26:03 +00:00
|
|
|
if (--thwomp->delay > 0)
|
2014-03-15 16:59:03 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Just find the first sector with the tag.
|
|
|
|
// Doesn't work with multiple sectors that have different floor/ceiling heights.
|
2020-04-25 08:47:45 +00:00
|
|
|
if ((secnum = Tag_Iterate_Sectors((INT16)thwomp->tag, 0)) < 0)
|
|
|
|
return;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
actionsector = §ors[secnum];
|
|
|
|
|
|
|
|
// Look for thwomp FOF
|
|
|
|
for (rover = actionsector->ffloors; rover; rover = rover->next)
|
2018-09-07 22:14:52 +00:00
|
|
|
{
|
2020-04-18 08:26:03 +00:00
|
|
|
if (rover->master == thwomp->sourceline)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rover)
|
|
|
|
return; // Didn't find any FOFs, so bail out
|
2018-09-07 22:14:52 +00:00
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
thwompx = actionsector->soundorg.x;
|
|
|
|
thwompy = actionsector->soundorg.y;
|
2018-09-07 22:14:52 +00:00
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
if (thwomp->direction == 0) // Not going anywhere, so look for players.
|
|
|
|
{
|
|
|
|
if (rover->flags & FF_EXISTS)
|
2018-09-07 22:14:52 +00:00
|
|
|
{
|
2020-04-18 08:26:03 +00:00
|
|
|
UINT8 i;
|
|
|
|
// scan the players to find victims!
|
|
|
|
for (i = 0; i < MAXPLAYERS; i++)
|
|
|
|
{
|
|
|
|
if (!P_IsPlayerValid(i))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (players[i].mo->z > thwomp->sector->ceilingheight)
|
|
|
|
continue;
|
|
|
|
|
2021-02-13 16:45:20 +00:00
|
|
|
if (P_AproxDistance(thwompx - players[i].mo->x, thwompy - players[i].mo->y) > 96*FRACUNIT)
|
2020-04-18 08:26:03 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
thwomp->direction = -1;
|
2018-09-07 22:14:52 +00:00
|
|
|
break;
|
2020-04-18 08:26:03 +00:00
|
|
|
}
|
2018-09-07 22:14:52 +00:00
|
|
|
}
|
2020-04-18 08:26:03 +00:00
|
|
|
|
|
|
|
thwomp->sector->ceilspeed = 0;
|
|
|
|
thwomp->sector->floorspeed = 0;
|
2018-09-07 22:14:52 +00:00
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
result_e res = 0;
|
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
if (thwomp->direction > 0) //Moving back up..
|
|
|
|
{
|
|
|
|
// Set the texture from the lower one (normal)
|
|
|
|
sides[thwomp->sourceline->sidenum[0]].midtexture = sides[thwomp->sourceline->sidenum[0]].bottomtexture;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
speed = thwomp->retractspeed;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
res = T_MovePlane
|
2014-03-15 16:59:03 +00:00
|
|
|
(
|
|
|
|
thwomp->sector, // sector
|
2020-04-18 08:26:03 +00:00
|
|
|
speed, // speed
|
|
|
|
thwomp->floorstartheight, // dest
|
|
|
|
false, // crush
|
|
|
|
false, // ceiling?
|
2014-03-15 16:59:03 +00:00
|
|
|
thwomp->direction // direction
|
|
|
|
);
|
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
if (res == ok || res == pastdest)
|
|
|
|
T_MovePlane
|
|
|
|
(
|
|
|
|
thwomp->sector, // sector
|
|
|
|
speed, // speed
|
|
|
|
thwomp->ceilingstartheight, // dest
|
|
|
|
false, // crush
|
|
|
|
true, // ceiling?
|
|
|
|
thwomp->direction // direction
|
|
|
|
);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
if (res == pastdest)
|
|
|
|
thwomp->direction = 0; // stop moving
|
|
|
|
}
|
|
|
|
else // Crashing down!
|
|
|
|
{
|
|
|
|
// Set the texture from the upper one (angry)
|
|
|
|
sides[thwomp->sourceline->sidenum[0]].midtexture = sides[thwomp->sourceline->sidenum[0]].toptexture;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
speed = thwomp->crushspeed;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
res = T_MovePlane
|
2014-03-15 16:59:03 +00:00
|
|
|
(
|
|
|
|
thwomp->sector, // sector
|
2020-04-18 08:26:03 +00:00
|
|
|
speed, // speed
|
2014-03-15 16:59:03 +00:00
|
|
|
P_FloorzAtPos(thwompx, thwompy, thwomp->sector->floorheight,
|
2020-04-18 08:26:03 +00:00
|
|
|
thwomp->sector->ceilingheight - thwomp->sector->floorheight), // dest
|
|
|
|
false, // crush
|
|
|
|
false, // ceiling?
|
2014-03-15 16:59:03 +00:00
|
|
|
thwomp->direction // direction
|
|
|
|
);
|
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
if (res == ok || res == pastdest)
|
|
|
|
T_MovePlane
|
|
|
|
(
|
|
|
|
thwomp->sector, // sector
|
|
|
|
speed, // speed
|
|
|
|
P_FloorzAtPos(thwompx, thwompy, thwomp->sector->floorheight,
|
|
|
|
thwomp->sector->ceilingheight
|
|
|
|
- (thwomp->sector->floorheight + speed))
|
|
|
|
+ (thwomp->sector->ceilingheight
|
|
|
|
- (thwomp->sector->floorheight + speed/2)), // dest
|
|
|
|
false, // crush
|
|
|
|
true, // ceiling?
|
|
|
|
thwomp->direction // direction
|
|
|
|
);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
if (res == pastdest)
|
2018-09-07 22:14:52 +00:00
|
|
|
{
|
2020-04-18 08:26:03 +00:00
|
|
|
if (rover->flags & FF_EXISTS)
|
|
|
|
S_StartSound((void *)&actionsector->soundorg, thwomp->sound);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-18 08:26:03 +00:00
|
|
|
thwomp->direction = 1; // start heading back up
|
|
|
|
thwomp->delay = TICRATE; // but only after a small delay
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
thwomp->sector->ceilspeed = 42;
|
2020-04-18 08:26:03 +00:00
|
|
|
thwomp->sector->floorspeed = speed*thwomp->direction;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
P_RecalcPrecipInSector(actionsector);
|
|
|
|
}
|
|
|
|
|
2020-04-18 07:21:04 +00:00
|
|
|
static boolean T_SectorHasEnemies(sector_t *sec)
|
|
|
|
{
|
|
|
|
msecnode_t *node = sec->touching_thinglist; // things touching this sector
|
|
|
|
mobj_t *mo;
|
|
|
|
while (node)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-18 07:21:04 +00:00
|
|
|
mo = node->m_thing;
|
2019-07-12 23:42:03 +00:00
|
|
|
|
2020-04-18 07:21:04 +00:00
|
|
|
if ((mo->flags & (MF_ENEMY|MF_BOSS))
|
|
|
|
&& mo->health > 0
|
|
|
|
&& mo->z < sec->ceilingheight
|
|
|
|
&& mo->z + mo->height > sec->floorheight)
|
|
|
|
return true;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-18 07:21:04 +00:00
|
|
|
node = node->m_thinglist_next;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
2020-04-18 07:21:04 +00:00
|
|
|
return false;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// T_NoEnemiesThinker
|
|
|
|
//
|
|
|
|
// Runs a linedef exec when no more MF_ENEMY/MF_BOSS objects with health are in the area
|
|
|
|
// \sa P_AddNoEnemiesThinker
|
|
|
|
//
|
2020-04-18 07:21:04 +00:00
|
|
|
void T_NoEnemiesSector(noenemies_t *nobaddies)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
2015-01-28 17:02:50 +00:00
|
|
|
sector_t *sec = NULL;
|
|
|
|
INT32 secnum = -1;
|
|
|
|
boolean FOFsector = false;
|
2020-04-17 20:26:04 +00:00
|
|
|
mtag_t tag = Tag_FGet(&nobaddies->sourceline->tags);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS(tag, secnum)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2015-01-28 17:02:50 +00:00
|
|
|
sec = §ors[secnum];
|
|
|
|
|
|
|
|
FOFsector = false;
|
|
|
|
|
|
|
|
// Check the lines of this sector, to see if it is a FOF control sector.
|
|
|
|
for (i = 0; i < sec->linecount; i++)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2015-01-28 17:02:50 +00:00
|
|
|
INT32 targetsecnum = -1;
|
2020-04-17 20:26:04 +00:00
|
|
|
mtag_t tag2 = Tag_FGet(&sec->lines[i]->tags);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2015-01-28 17:02:50 +00:00
|
|
|
if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
FOFsector = true;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS(tag2, targetsecnum)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-18 07:21:04 +00:00
|
|
|
if (T_SectorHasEnemies(§ors[targetsecnum]))
|
2015-01-28 17:02:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-04-18 07:21:04 +00:00
|
|
|
|
|
|
|
if (!FOFsector && T_SectorHasEnemies(sec))
|
|
|
|
return;
|
2015-01-28 17:02:50 +00:00
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 20:26:04 +00:00
|
|
|
CONS_Debug(DBG_GAMELOGIC, "Running no-more-enemies exec with tag of %d\n", tag);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2015-01-28 17:02:50 +00:00
|
|
|
// No enemies found, run the linedef exec and terminate this thinker
|
|
|
|
P_RunTriggerLinedef(nobaddies->sourceline, NULL, NULL);
|
2014-03-15 16:59:03 +00:00
|
|
|
P_RemoveThinker(&nobaddies->thinker);
|
|
|
|
}
|
|
|
|
|
2017-07-17 19:56:55 +00:00
|
|
|
//
|
|
|
|
// P_IsObjectOnRealGround
|
|
|
|
//
|
|
|
|
// Helper function for T_EachTimeThinker
|
|
|
|
// Like P_IsObjectOnGroundIn, except ONLY THE REAL GROUND IS CONSIDERED, NOT FOFS
|
|
|
|
// I'll consider whether to make this a more globally accessible function or whatever in future
|
|
|
|
// -- Monster Iestyn
|
|
|
|
//
|
|
|
|
static boolean P_IsObjectOnRealGround(mobj_t *mo, sector_t *sec)
|
|
|
|
{
|
|
|
|
// Is the object in reverse gravity?
|
|
|
|
if (mo->eflags & MFE_VERTICALFLIP)
|
|
|
|
{
|
|
|
|
// Detect if the player is on the ceiling.
|
|
|
|
if (mo->z+mo->height >= P_GetSpecialTopZ(mo, sec, sec))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// Nope!
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Detect if the player is on the floor.
|
|
|
|
if (mo->z <= P_GetSpecialBottomZ(mo, sec, sec))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-04-17 19:19:21 +00:00
|
|
|
static boolean P_IsMobjTouchingSector(mobj_t *mo, sector_t *sec)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 19:19:21 +00:00
|
|
|
msecnode_t *node;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 19:19:21 +00:00
|
|
|
if (mo->subsector->sector == sec)
|
|
|
|
return true;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 19:19:21 +00:00
|
|
|
if (!(sec->flags & SF_TRIGGERSPECIAL_TOUCH))
|
|
|
|
return false;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 19:19:21 +00:00
|
|
|
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
|
|
|
|
{
|
|
|
|
if (node->m_sector == sec)
|
|
|
|
return true;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
2020-04-17 19:19:21 +00:00
|
|
|
return false;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// T_EachTimeThinker
|
|
|
|
//
|
|
|
|
// Runs a linedef exec whenever a player enters an area.
|
|
|
|
// Keeps track of players currently in the area and notices any changes.
|
|
|
|
//
|
|
|
|
// \sa P_AddEachTimeThinker
|
|
|
|
//
|
2020-04-17 12:00:48 +00:00
|
|
|
void T_EachTimeThinker(eachtime_t *eachtime)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
size_t i, j;
|
|
|
|
sector_t *sec = NULL;
|
|
|
|
sector_t *targetsec = NULL;
|
|
|
|
INT32 secnum = -1;
|
2014-08-04 03:49:33 +00:00
|
|
|
boolean oldPlayersInArea[MAXPLAYERS];
|
|
|
|
boolean oldPlayersOnArea[MAXPLAYERS];
|
|
|
|
boolean *oldPlayersArea;
|
|
|
|
boolean *playersArea;
|
2014-03-15 16:59:03 +00:00
|
|
|
boolean FOFsector = false;
|
|
|
|
boolean floortouch = false;
|
2015-05-24 17:53:30 +00:00
|
|
|
fixed_t bottomheight, topheight;
|
2018-05-21 19:02:30 +00:00
|
|
|
ffloor_t *rover;
|
2020-04-17 20:26:04 +00:00
|
|
|
mtag_t tag = Tag_FGet(&eachtime->sourceline->tags);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAXPLAYERS; i++)
|
|
|
|
{
|
2020-04-17 12:00:48 +00:00
|
|
|
oldPlayersInArea[i] = eachtime->playersInArea[i];
|
|
|
|
oldPlayersOnArea[i] = eachtime->playersOnArea[i];
|
|
|
|
eachtime->playersInArea[i] = false;
|
|
|
|
eachtime->playersOnArea[i] = false;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS(tag, secnum)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
sec = §ors[secnum];
|
|
|
|
|
2014-08-04 03:49:33 +00:00
|
|
|
FOFsector = false;
|
|
|
|
|
|
|
|
if (GETSECSPECIAL(sec->special, 2) == 3 || GETSECSPECIAL(sec->special, 2) == 5)
|
|
|
|
floortouch = true;
|
|
|
|
else if (GETSECSPECIAL(sec->special, 2) >= 1 && GETSECSPECIAL(sec->special, 2) <= 8)
|
|
|
|
floortouch = false;
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
// Check the lines of this sector, to see if it is a FOF control sector.
|
|
|
|
for (i = 0; i < sec->linecount; i++)
|
|
|
|
{
|
|
|
|
INT32 targetsecnum = -1;
|
2020-04-17 20:26:04 +00:00
|
|
|
mtag_t tag2 = Tag_FGet(&sec->lines[i]->tags);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
FOFsector = true;
|
|
|
|
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS(tag2, targetsecnum)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
targetsec = §ors[targetsecnum];
|
|
|
|
|
2018-05-21 19:02:30 +00:00
|
|
|
// Find the FOF corresponding to the control linedef
|
|
|
|
for (rover = targetsec->ffloors; rover; rover = rover->next)
|
|
|
|
{
|
|
|
|
if (rover->master == sec->lines[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rover) // This should be impossible, but don't complain if it is the case somehow
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!(rover->flags & FF_EXISTS)) // If the FOF does not "exist", we pretend that nobody's there
|
|
|
|
continue;
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
for (j = 0; j < MAXPLAYERS; j++)
|
|
|
|
{
|
2020-04-17 19:19:21 +00:00
|
|
|
if (!P_IsPlayerValid(j))
|
2014-03-15 16:59:03 +00:00
|
|
|
continue;
|
|
|
|
|
2020-04-17 19:19:21 +00:00
|
|
|
if (!P_IsMobjTouchingSector(players[j].mo, targetsec))
|
2014-03-15 16:59:03 +00:00
|
|
|
continue;
|
|
|
|
|
2015-05-24 17:53:30 +00:00
|
|
|
topheight = P_GetSpecialTopZ(players[j].mo, sec, targetsec);
|
|
|
|
bottomheight = P_GetSpecialBottomZ(players[j].mo, sec, targetsec);
|
|
|
|
|
|
|
|
if (players[j].mo->z > topheight)
|
2014-03-15 16:59:03 +00:00
|
|
|
continue;
|
|
|
|
|
2015-05-24 17:53:30 +00:00
|
|
|
if (players[j].mo->z + players[j].mo->height < bottomheight)
|
2014-03-15 16:59:03 +00:00
|
|
|
continue;
|
|
|
|
|
2020-04-17 19:19:21 +00:00
|
|
|
if (floortouch && P_IsObjectOnGroundIn(players[j].mo, targetsec))
|
2020-04-17 12:00:48 +00:00
|
|
|
eachtime->playersOnArea[j] = true;
|
2014-03-15 16:59:03 +00:00
|
|
|
else
|
2020-04-17 12:00:48 +00:00
|
|
|
eachtime->playersInArea[j] = true;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!FOFsector)
|
|
|
|
{
|
|
|
|
for (i = 0; i < MAXPLAYERS; i++)
|
|
|
|
{
|
2020-04-17 19:19:21 +00:00
|
|
|
if (!P_IsPlayerValid(i))
|
2014-03-15 16:59:03 +00:00
|
|
|
continue;
|
|
|
|
|
2020-04-17 19:19:21 +00:00
|
|
|
if (!P_IsMobjTouchingSector(players[i].mo, sec))
|
2016-10-31 09:34:24 +00:00
|
|
|
continue;
|
2016-10-31 00:02:38 +00:00
|
|
|
|
|
|
|
if (!(players[i].mo->subsector->sector == sec
|
|
|
|
|| P_PlayerTouchingSectorSpecial(&players[i], 2, (GETSECSPECIAL(sec->special, 2))) == sec))
|
2014-03-15 16:59:03 +00:00
|
|
|
continue;
|
|
|
|
|
2020-04-17 19:19:21 +00:00
|
|
|
if (floortouch && P_IsObjectOnRealGround(players[i].mo, sec))
|
2020-04-17 12:00:48 +00:00
|
|
|
eachtime->playersOnArea[i] = true;
|
2014-03-15 16:59:03 +00:00
|
|
|
else
|
2020-04-17 12:00:48 +00:00
|
|
|
eachtime->playersInArea[i] = true;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if a new player entered.
|
|
|
|
// If not, check if a player hit the floor.
|
|
|
|
// If either condition is true, execute.
|
2020-04-17 19:19:21 +00:00
|
|
|
if (floortouch)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 19:19:21 +00:00
|
|
|
playersArea = eachtime->playersOnArea;
|
2014-03-15 16:59:03 +00:00
|
|
|
oldPlayersArea = oldPlayersOnArea;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-17 19:19:21 +00:00
|
|
|
playersArea = eachtime->playersInArea;
|
2014-03-15 16:59:03 +00:00
|
|
|
oldPlayersArea = oldPlayersInArea;
|
|
|
|
}
|
|
|
|
|
2020-04-17 19:19:21 +00:00
|
|
|
// Easy check... nothing has changed
|
|
|
|
if (!memcmp(playersArea, oldPlayersArea, sizeof(boolean)*MAXPLAYERS))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// If sector has an "all players" trigger type, all players need to be in area
|
|
|
|
if (GETSECSPECIAL(sec->special, 2) == 2 || GETSECSPECIAL(sec->special, 2) == 3)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 19:19:21 +00:00
|
|
|
for (i = 0; i < MAXPLAYERS; i++)
|
2014-08-04 03:49:33 +00:00
|
|
|
{
|
2020-04-17 19:19:21 +00:00
|
|
|
if (P_IsPlayerValid(i) && playersArea[i])
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2014-08-04 03:49:33 +00:00
|
|
|
|
2020-04-17 19:19:21 +00:00
|
|
|
// Trigger for every player who has entered (and exited, if triggerOnExit)
|
|
|
|
for (i = 0; i < MAXPLAYERS; i++)
|
|
|
|
{
|
|
|
|
if (playersArea[i] == oldPlayersArea[i])
|
|
|
|
continue;
|
2014-08-04 03:49:33 +00:00
|
|
|
|
2020-04-17 19:19:21 +00:00
|
|
|
// If player has just left, check if still valid
|
|
|
|
if (!playersArea[i] && (!eachtime->triggerOnExit || !P_IsPlayerValid(i)))
|
|
|
|
continue;
|
2014-08-04 03:49:33 +00:00
|
|
|
|
2020-04-17 20:26:04 +00:00
|
|
|
CONS_Debug(DBG_GAMELOGIC, "Trying to activate each time executor with tag %d\n", tag);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2014-08-04 03:49:33 +00:00
|
|
|
// 03/08/14 -Monster Iestyn
|
|
|
|
// No more stupid hacks involving changing eachtime->sourceline's tag or special or whatever!
|
|
|
|
// This should now run ONLY the stuff for eachtime->sourceline itself, instead of all trigger linedefs sharing the same tag.
|
|
|
|
// Makes much more sense doing it this way, honestly.
|
2020-04-17 19:19:21 +00:00
|
|
|
P_RunTriggerLinedef(eachtime->sourceline, players[i].mo, sec);
|
2014-11-12 00:55:07 +00:00
|
|
|
|
|
|
|
if (!eachtime->sourceline->special) // this happens only for "Trigger on X calls" linedefs
|
|
|
|
P_RemoveThinker(&eachtime->thinker);
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// T_RaiseSector
|
|
|
|
//
|
|
|
|
// Rises up to its topmost position when a
|
|
|
|
// player steps on it. Lowers otherwise.
|
|
|
|
//
|
2020-04-17 07:58:53 +00:00
|
|
|
void T_RaiseSector(raise_t *raise)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
msecnode_t *node;
|
|
|
|
mobj_t *thing;
|
|
|
|
sector_t *sector;
|
|
|
|
INT32 i;
|
2019-10-11 20:23:11 +00:00
|
|
|
boolean playeronme = false, active = false;
|
2020-04-17 08:19:02 +00:00
|
|
|
boolean moveUp;
|
2014-03-15 16:59:03 +00:00
|
|
|
fixed_t ceilingdestination, floordestination;
|
2020-04-17 09:11:36 +00:00
|
|
|
fixed_t speed, origspeed;
|
2020-04-17 08:19:02 +00:00
|
|
|
fixed_t distToNearestEndpoint;
|
2020-04-17 09:11:36 +00:00
|
|
|
INT32 direction;
|
2014-03-15 16:59:03 +00:00
|
|
|
result_e res = 0;
|
2020-07-10 14:51:11 +00:00
|
|
|
mtag_t tag = raise->tag;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 21:54:37 +00:00
|
|
|
if (raise->sector->crumblestate >= CRUMBLE_FALL || raise->sector->ceilingdata)
|
2014-03-15 16:59:03 +00:00
|
|
|
return;
|
|
|
|
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS(tag, i)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
sector = §ors[i];
|
|
|
|
|
|
|
|
// Is a player standing on me?
|
2016-06-09 13:16:02 +00:00
|
|
|
for (node = sector->touching_thinglist; node; node = node->m_thinglist_next)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
thing = node->m_thing;
|
|
|
|
|
|
|
|
if (!thing->player)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Ignore spectators.
|
|
|
|
if (thing->player && thing->player->spectator)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Option to require spindashing.
|
2020-04-17 07:58:53 +00:00
|
|
|
if (raise->flags & RF_SPINDASH && !(thing->player->pflags & PF_STARTDASH))
|
2014-03-15 16:59:03 +00:00
|
|
|
continue;
|
|
|
|
|
2015-05-24 17:53:30 +00:00
|
|
|
if (!(thing->z == P_GetSpecialTopZ(thing, raise->sector, sector)))
|
2014-03-15 16:59:03 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
playeronme = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-11-07 22:56:42 +00:00
|
|
|
|
2020-04-17 07:58:53 +00:00
|
|
|
if (raise->flags & RF_DYNAMIC) // Dynamically Sinking Platform^tm
|
2019-10-11 20:23:11 +00:00
|
|
|
{
|
2019-10-20 18:13:46 +00:00
|
|
|
#define shaketime 10
|
2020-04-17 07:58:53 +00:00
|
|
|
if (raise->shaketimer > shaketime) // State: moving
|
2019-10-11 20:23:11 +00:00
|
|
|
{
|
|
|
|
if (playeronme) // If player is standing on the platform, accelerate
|
|
|
|
{
|
2020-04-17 07:58:53 +00:00
|
|
|
raise->extraspeed += (FRACUNIT >> 5);
|
2019-10-11 20:23:11 +00:00
|
|
|
}
|
|
|
|
else // otherwise, decelerate until inflection
|
|
|
|
{
|
2020-04-17 07:58:53 +00:00
|
|
|
raise->extraspeed -= FRACUNIT >> 3;
|
|
|
|
if (raise->extraspeed <= 0) // inflection!
|
2019-10-11 20:23:11 +00:00
|
|
|
{
|
2020-04-17 07:58:53 +00:00
|
|
|
raise->extraspeed = 0;
|
|
|
|
raise->shaketimer = 0; // allow the shake to occur again (fucks over players attempting to jump-cheese)
|
2019-10-11 20:23:11 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-17 07:58:53 +00:00
|
|
|
active = raise->extraspeed > 0;
|
2019-10-11 20:23:11 +00:00
|
|
|
}
|
|
|
|
else // State: shaking
|
|
|
|
{
|
2020-04-17 07:58:53 +00:00
|
|
|
if (playeronme || raise->shaketimer)
|
2019-10-11 20:23:11 +00:00
|
|
|
{
|
|
|
|
active = true;
|
2020-04-17 07:58:53 +00:00
|
|
|
if (++raise->shaketimer > shaketime)
|
2019-10-11 20:23:11 +00:00
|
|
|
{
|
|
|
|
if (playeronme)
|
2020-04-17 07:58:53 +00:00
|
|
|
raise->extraspeed = FRACUNIT >> 5;
|
2019-10-11 20:23:11 +00:00
|
|
|
else
|
2020-04-17 07:58:53 +00:00
|
|
|
raise->extraspeed = FRACUNIT << 1;
|
2019-10-11 20:23:11 +00:00
|
|
|
}
|
|
|
|
else
|
2019-10-20 18:13:46 +00:00
|
|
|
{
|
2020-04-17 07:58:53 +00:00
|
|
|
raise->extraspeed = ((shaketime/2) - raise->shaketimer) << FRACBITS;
|
|
|
|
if (raise->extraspeed < -raise->basespeed/2)
|
|
|
|
raise->extraspeed = -raise->basespeed/2;
|
2019-10-20 18:13:46 +00:00
|
|
|
}
|
2019-10-11 20:23:11 +00:00
|
|
|
}
|
|
|
|
}
|
2019-10-20 18:13:46 +00:00
|
|
|
#undef shaketime
|
2019-10-11 20:23:11 +00:00
|
|
|
}
|
|
|
|
else // Air bobbing platform (not a Dynamically Sinking Platform^tm)
|
|
|
|
active = playeronme;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 08:19:02 +00:00
|
|
|
moveUp = active ^ (raise->flags & RF_REVERSE);
|
|
|
|
ceilingdestination = moveUp ? raise->ceilingtop : raise->ceilingbottom;
|
2020-04-17 09:11:36 +00:00
|
|
|
floordestination = ceilingdestination - (raise->sector->ceilingheight - raise->sector->floorheight);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 08:19:02 +00:00
|
|
|
if ((moveUp && raise->sector->ceilingheight >= ceilingdestination)
|
|
|
|
|| (!moveUp && raise->sector->ceilingheight <= ceilingdestination))
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 09:11:36 +00:00
|
|
|
raise->sector->floorheight = floordestination;
|
2020-04-17 08:19:02 +00:00
|
|
|
raise->sector->ceilingheight = ceilingdestination;
|
|
|
|
raise->sector->ceilspeed = 0;
|
|
|
|
raise->sector->floorspeed = 0;
|
|
|
|
return;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2020-04-17 09:11:36 +00:00
|
|
|
direction = moveUp ? 1 : -1;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 09:11:36 +00:00
|
|
|
origspeed = raise->basespeed;
|
|
|
|
if (!active)
|
|
|
|
origspeed /= 2;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 08:19:02 +00:00
|
|
|
// Speed up as you get closer to the middle, then slow down again
|
|
|
|
distToNearestEndpoint = min(raise->sector->ceilingheight - raise->ceilingbottom, raise->ceilingtop - raise->sector->ceilingheight);
|
2020-04-17 09:11:36 +00:00
|
|
|
speed = FixedMul(origspeed, FixedDiv(distToNearestEndpoint, (raise->ceilingtop - raise->ceilingbottom) >> 5));
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 09:11:36 +00:00
|
|
|
if (speed <= origspeed/16)
|
|
|
|
speed = origspeed/16;
|
|
|
|
else if (speed > origspeed)
|
|
|
|
speed = origspeed;
|
2019-10-20 18:13:46 +00:00
|
|
|
|
2020-04-17 09:11:36 +00:00
|
|
|
speed += raise->extraspeed;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
res = T_MovePlane
|
|
|
|
(
|
2020-04-17 09:11:36 +00:00
|
|
|
raise->sector, // sector
|
|
|
|
speed, // speed
|
2014-03-15 16:59:03 +00:00
|
|
|
ceilingdestination, // dest
|
2020-04-17 23:08:01 +00:00
|
|
|
false, // crush
|
|
|
|
true, // ceiling?
|
2020-04-17 09:11:36 +00:00
|
|
|
direction // direction
|
2014-03-15 16:59:03 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
if (res == ok || res == pastdest)
|
|
|
|
T_MovePlane
|
|
|
|
(
|
2020-04-17 09:11:36 +00:00
|
|
|
raise->sector, // sector
|
|
|
|
speed, // speed
|
2014-03-15 16:59:03 +00:00
|
|
|
floordestination, // dest
|
2020-04-17 23:08:01 +00:00
|
|
|
false, // crush
|
|
|
|
false, // ceiling?
|
2020-04-17 09:11:36 +00:00
|
|
|
direction // direction
|
2014-03-15 16:59:03 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
raise->sector->ceilspeed = 42;
|
2020-04-17 09:11:36 +00:00
|
|
|
raise->sector->floorspeed = speed*direction;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS(tag, i)
|
2014-03-15 16:59:03 +00:00
|
|
|
P_RecalcPrecipInSector(§ors[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_CameraScanner(elevator_t *elevator)
|
|
|
|
{
|
|
|
|
// leveltime is compared to make multiple scanners in one map function correctly.
|
|
|
|
static tic_t lastleveltime = 32000; // any number other than 0 should do here
|
|
|
|
static boolean camerascanned, camerascanned2;
|
|
|
|
|
|
|
|
if (leveltime != lastleveltime) // Back on the first camera scanner
|
|
|
|
{
|
|
|
|
camerascanned = camerascanned2 = false;
|
|
|
|
lastleveltime = leveltime;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (players[displayplayer].mo)
|
|
|
|
{
|
|
|
|
if (players[displayplayer].mo->subsector->sector == elevator->actionsector)
|
|
|
|
{
|
|
|
|
if (t_cam_dist == -42)
|
|
|
|
t_cam_dist = cv_cam_dist.value;
|
|
|
|
if (t_cam_height == -42)
|
|
|
|
t_cam_height = cv_cam_height.value;
|
|
|
|
if (t_cam_rotate == -42)
|
|
|
|
t_cam_rotate = cv_cam_rotate.value;
|
|
|
|
CV_SetValue(&cv_cam_height, FixedInt(elevator->sector->floorheight));
|
|
|
|
CV_SetValue(&cv_cam_dist, FixedInt(elevator->sector->ceilingheight));
|
|
|
|
CV_SetValue(&cv_cam_rotate, elevator->distance);
|
|
|
|
camerascanned = true;
|
|
|
|
}
|
|
|
|
else if (!camerascanned)
|
|
|
|
{
|
|
|
|
if (t_cam_height != -42 && cv_cam_height.value != t_cam_height)
|
|
|
|
CV_Set(&cv_cam_height, va("%f", (double)FIXED_TO_FLOAT(t_cam_height)));
|
|
|
|
if (t_cam_dist != -42 && cv_cam_dist.value != t_cam_dist)
|
|
|
|
CV_Set(&cv_cam_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam_dist)));
|
|
|
|
if (t_cam_rotate != -42 && cv_cam_rotate.value != t_cam_rotate)
|
|
|
|
CV_Set(&cv_cam_rotate, va("%f", (double)t_cam_rotate));
|
|
|
|
|
|
|
|
t_cam_dist = t_cam_height = t_cam_rotate = -42;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (splitscreen && players[secondarydisplayplayer].mo)
|
|
|
|
{
|
|
|
|
if (players[secondarydisplayplayer].mo->subsector->sector == elevator->actionsector)
|
|
|
|
{
|
|
|
|
if (t_cam2_rotate == -42)
|
|
|
|
t_cam2_dist = cv_cam2_dist.value;
|
|
|
|
if (t_cam2_rotate == -42)
|
|
|
|
t_cam2_height = cv_cam2_height.value;
|
|
|
|
if (t_cam2_rotate == -42)
|
|
|
|
t_cam2_rotate = cv_cam2_rotate.value;
|
|
|
|
CV_SetValue(&cv_cam2_height, FixedInt(elevator->sector->floorheight));
|
|
|
|
CV_SetValue(&cv_cam2_dist, FixedInt(elevator->sector->ceilingheight));
|
|
|
|
CV_SetValue(&cv_cam2_rotate, elevator->distance);
|
|
|
|
camerascanned2 = true;
|
|
|
|
}
|
|
|
|
else if (!camerascanned2)
|
|
|
|
{
|
|
|
|
if (t_cam2_height != -42 && cv_cam2_height.value != t_cam2_height)
|
|
|
|
CV_Set(&cv_cam2_height, va("%f", (double)FIXED_TO_FLOAT(t_cam2_height)));
|
|
|
|
if (t_cam2_dist != -42 && cv_cam2_dist.value != t_cam2_dist)
|
|
|
|
CV_Set(&cv_cam2_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam2_dist)));
|
|
|
|
if (t_cam2_rotate != -42 && cv_cam2_rotate.value != t_cam2_rotate)
|
|
|
|
CV_Set(&cv_cam2_rotate, va("%f", (double)t_cam2_rotate));
|
|
|
|
|
|
|
|
t_cam2_dist = t_cam2_height = t_cam2_rotate = -42;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-05 20:29:48 +00:00
|
|
|
void T_PlaneDisplace(planedisplace_t *pd)
|
|
|
|
{
|
|
|
|
sector_t *control, *target;
|
|
|
|
INT32 direction;
|
|
|
|
fixed_t diff;
|
|
|
|
|
|
|
|
control = §ors[pd->control];
|
|
|
|
target = §ors[pd->affectee];
|
|
|
|
|
|
|
|
if (control->floorheight == pd->last_height)
|
|
|
|
return; // no change, no movement
|
|
|
|
|
|
|
|
direction = (control->floorheight > pd->last_height) ? 1 : -1;
|
|
|
|
diff = FixedMul(control->floorheight-pd->last_height, pd->speed);
|
|
|
|
|
2017-04-11 21:33:04 +00:00
|
|
|
if (pd->reverse) // reverse direction?
|
|
|
|
{
|
|
|
|
direction *= -1;
|
|
|
|
diff *= -1;
|
|
|
|
}
|
|
|
|
|
2017-01-05 20:29:48 +00:00
|
|
|
if (pd->type == pd_floor || pd->type == pd_both)
|
2020-04-17 23:08:01 +00:00
|
|
|
T_MovePlane(target, INT32_MAX/2, target->floorheight+diff, false, false, direction); // move floor
|
2017-01-05 20:29:48 +00:00
|
|
|
if (pd->type == pd_ceiling || pd->type == pd_both)
|
2020-04-17 23:08:01 +00:00
|
|
|
T_MovePlane(target, INT32_MAX/2, target->ceilingheight+diff, false, true, direction); // move ceiling
|
2017-01-05 20:29:48 +00:00
|
|
|
|
|
|
|
pd->last_height = control->floorheight;
|
|
|
|
}
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
//
|
|
|
|
// EV_DoFloor
|
|
|
|
//
|
|
|
|
// Set up and start a floor thinker.
|
|
|
|
//
|
|
|
|
// Called by P_ProcessLineSpecial (linedef executors), P_ProcessSpecialSector
|
|
|
|
// (egg capsule button), P_PlayerInSpecialSector (buttons),
|
|
|
|
// and P_SpawnSpecials (continuous floor movers and instant lower).
|
|
|
|
//
|
2020-04-18 08:52:58 +00:00
|
|
|
void EV_DoFloor(line_t *line, floor_e floortype)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-18 08:52:58 +00:00
|
|
|
INT32 firstone = 1;
|
2014-03-15 16:59:03 +00:00
|
|
|
INT32 secnum = -1;
|
|
|
|
sector_t *sec;
|
|
|
|
floormove_t *dofloor;
|
2020-04-17 20:26:04 +00:00
|
|
|
mtag_t tag = Tag_FGet(&line->tags);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS(tag, secnum)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
sec = §ors[secnum];
|
|
|
|
|
|
|
|
if (sec->floordata) // if there's already a thinker on this floor,
|
|
|
|
continue; // then don't add another one
|
|
|
|
|
|
|
|
// new floor thinker
|
|
|
|
dofloor = Z_Calloc(sizeof (*dofloor), PU_LEVSPEC, NULL);
|
2019-04-20 20:37:19 +00:00
|
|
|
P_AddThinker(THINK_MAIN, &dofloor->thinker);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// make sure another floor thinker won't get started over this one
|
|
|
|
sec->floordata = dofloor;
|
|
|
|
|
|
|
|
// set up some generic aspects of the floormove_t
|
|
|
|
dofloor->thinker.function.acp1 = (actionf_p1)T_MoveFloor;
|
|
|
|
dofloor->type = floortype;
|
|
|
|
dofloor->crush = false; // default: types that crush will change this
|
|
|
|
dofloor->sector = sec;
|
|
|
|
|
|
|
|
switch (floortype)
|
|
|
|
{
|
|
|
|
// Lowers a floor to the lowest surrounding floor.
|
|
|
|
case lowerFloorToLowest:
|
|
|
|
dofloor->direction = -1; // down
|
|
|
|
dofloor->speed = FLOORSPEED*2; // 2 fracunits per tic
|
|
|
|
dofloor->floordestheight = P_FindLowestFloorSurrounding(sec);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Used for part of the Egg Capsule, when an FOF with type 666 is
|
|
|
|
// contacted by the player.
|
|
|
|
case raiseFloorToNearestFast:
|
|
|
|
dofloor->direction = -1; // down
|
|
|
|
dofloor->speed = FLOORSPEED*4; // 4 fracunits per tic
|
|
|
|
dofloor->floordestheight = P_FindNextHighestFloor(sec, sec->floorheight);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Used for sectors tagged to 50 linedefs (effectively
|
|
|
|
// changing the base height for placing things in that sector).
|
|
|
|
case instantLower:
|
|
|
|
dofloor->direction = -1; // down
|
|
|
|
dofloor->speed = INT32_MAX/2; // "instant" means "takes one tic"
|
|
|
|
dofloor->floordestheight = P_FindLowestFloorSurrounding(sec);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Linedef executor command, linetype 101.
|
|
|
|
// Front sector floor = destination height.
|
|
|
|
case instantMoveFloorByFrontSector:
|
|
|
|
dofloor->speed = INT32_MAX/2; // as above, "instant" is one tic
|
|
|
|
dofloor->floordestheight = line->frontsector->floorheight;
|
|
|
|
|
|
|
|
if (dofloor->floordestheight >= sec->floorheight)
|
|
|
|
dofloor->direction = 1; // up
|
|
|
|
else
|
|
|
|
dofloor->direction = -1; // down
|
|
|
|
|
|
|
|
// New for 1.09: now you can use the no climb flag to
|
|
|
|
// DISABLE the flat changing. This makes it work
|
|
|
|
// totally opposite the way linetype 106 does. Yet
|
|
|
|
// another reason I'll be glad to break backwards
|
|
|
|
// compatibility for the final.
|
|
|
|
if (line->flags & ML_NOCLIMB)
|
|
|
|
dofloor->texture = -1; // don't mess with the floorpic
|
|
|
|
else
|
|
|
|
dofloor->texture = line->frontsector->floorpic;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Linedef executor command, linetype 106.
|
|
|
|
// Line length = speed, front sector floor = destination height.
|
|
|
|
case moveFloorByFrontSector:
|
2021-02-13 16:45:20 +00:00
|
|
|
dofloor->speed = P_AproxDistance(line->dx, line->dy);
|
2014-03-15 16:59:03 +00:00
|
|
|
dofloor->speed = FixedDiv(dofloor->speed,8*FRACUNIT);
|
|
|
|
dofloor->floordestheight = line->frontsector->floorheight;
|
|
|
|
|
|
|
|
if (dofloor->floordestheight >= sec->floorheight)
|
|
|
|
dofloor->direction = 1; // up
|
|
|
|
else
|
|
|
|
dofloor->direction = -1; // down
|
|
|
|
|
|
|
|
// chained linedef executing ability
|
|
|
|
if (line->flags & ML_BLOCKMONSTERS)
|
|
|
|
{
|
|
|
|
// Only set it on one of the moving sectors (the
|
|
|
|
// smallest numbered) and only if the front side
|
|
|
|
// x offset is positive, indicating a valid tag.
|
|
|
|
if (firstone && sides[line->sidenum[0]].textureoffset > 0)
|
|
|
|
dofloor->texture = (sides[line->sidenum[0]].textureoffset>>FRACBITS) - 32769;
|
|
|
|
else
|
|
|
|
dofloor->texture = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// flat changing ability
|
|
|
|
else if (line->flags & ML_NOCLIMB)
|
|
|
|
dofloor->texture = line->frontsector->floorpic;
|
|
|
|
else
|
|
|
|
dofloor->texture = -1; // nothing special to do after movement completes
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case moveFloorByFrontTexture:
|
|
|
|
if (line->flags & ML_NOCLIMB)
|
|
|
|
dofloor->speed = INT32_MAX/2; // as above, "instant" is one tic
|
|
|
|
else
|
|
|
|
dofloor->speed = FixedDiv(sides[line->sidenum[0]].textureoffset,8*FRACUNIT); // texture x offset
|
|
|
|
dofloor->floordestheight = sec->floorheight + sides[line->sidenum[0]].rowoffset; // texture y offset
|
|
|
|
if (dofloor->floordestheight > sec->floorheight)
|
|
|
|
dofloor->direction = 1; // up
|
|
|
|
else
|
|
|
|
dofloor->direction = -1; // down
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
// Linedef executor command, linetype 108.
|
|
|
|
// dx = speed, dy = amount to lower.
|
|
|
|
case lowerFloorByLine:
|
|
|
|
dofloor->direction = -1; // down
|
|
|
|
dofloor->speed = FixedDiv(abs(line->dx),8*FRACUNIT);
|
|
|
|
dofloor->floordestheight = sec->floorheight - abs(line->dy);
|
|
|
|
if (dofloor->floordestheight > sec->floorheight) // wrapped around
|
|
|
|
I_Error("Can't lower sector %d\n", secnum);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Linedef executor command, linetype 109.
|
|
|
|
// dx = speed, dy = amount to raise.
|
|
|
|
case raiseFloorByLine:
|
|
|
|
dofloor->direction = 1; // up
|
|
|
|
dofloor->speed = FixedDiv(abs(line->dx),8*FRACUNIT);
|
|
|
|
dofloor->floordestheight = sec->floorheight + abs(line->dy);
|
|
|
|
if (dofloor->floordestheight < sec->floorheight) // wrapped around
|
|
|
|
I_Error("Can't raise sector %d\n", secnum);
|
|
|
|
break;
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Linetypes 2/3.
|
|
|
|
// Move floor up and down indefinitely like the old elevators.
|
|
|
|
case bounceFloor:
|
2021-02-13 16:45:20 +00:00
|
|
|
dofloor->speed = P_AproxDistance(line->dx, line->dy); // same speed as elevateContinuous
|
2014-03-15 16:59:03 +00:00
|
|
|
dofloor->speed = FixedDiv(dofloor->speed,4*FRACUNIT);
|
|
|
|
dofloor->origspeed = dofloor->speed; // it gets slowed down at the top and bottom
|
|
|
|
dofloor->floordestheight = line->frontsector->floorheight;
|
|
|
|
|
|
|
|
if (dofloor->floordestheight >= sec->floorheight)
|
|
|
|
dofloor->direction = 1; // up
|
|
|
|
else
|
|
|
|
dofloor->direction = -1; // down
|
|
|
|
|
|
|
|
// Any delay?
|
|
|
|
dofloor->delay = sides[line->sidenum[0]].textureoffset >> FRACBITS;
|
|
|
|
dofloor->delaytimer = sides[line->sidenum[0]].rowoffset >> FRACBITS; // Initial delay
|
|
|
|
|
|
|
|
dofloor->texture = (fixed_t)(line - lines); // hack: store source line number
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Linetypes 6/7.
|
|
|
|
// Like 2/3, but no slowdown at the top and bottom of movement,
|
|
|
|
// and the speed is line->dx the first way, line->dy for the
|
|
|
|
// return trip. Good for crushers.
|
|
|
|
case bounceFloorCrush:
|
|
|
|
dofloor->speed = FixedDiv(abs(line->dx),4*FRACUNIT);
|
|
|
|
dofloor->origspeed = dofloor->speed;
|
|
|
|
dofloor->floordestheight = line->frontsector->floorheight;
|
|
|
|
|
|
|
|
if (dofloor->floordestheight >= sec->floorheight)
|
|
|
|
dofloor->direction = 1; // up
|
|
|
|
else
|
|
|
|
dofloor->direction = -1; // down
|
|
|
|
|
|
|
|
// Any delay?
|
|
|
|
dofloor->delay = sides[line->sidenum[0]].textureoffset >> FRACBITS;
|
|
|
|
dofloor->delaytimer = sides[line->sidenum[0]].rowoffset >> FRACBITS; // Initial delay
|
|
|
|
|
|
|
|
dofloor->texture = (fixed_t)(line - lines); // hack: store source line number
|
|
|
|
break;
|
|
|
|
|
|
|
|
case crushFloorOnce:
|
|
|
|
dofloor->speed = FixedDiv(abs(line->dx),4*FRACUNIT);
|
|
|
|
dofloor->origspeed = dofloor->speed;
|
|
|
|
dofloor->floordestheight = line->frontsector->ceilingheight;
|
|
|
|
|
|
|
|
if (dofloor->floordestheight >= sec->floorheight)
|
|
|
|
dofloor->direction = 1; // up
|
|
|
|
else
|
|
|
|
dofloor->direction = -1; // down
|
|
|
|
|
|
|
|
// Any delay?
|
|
|
|
dofloor->delay = sides[line->sidenum[0]].textureoffset >> FRACBITS;
|
|
|
|
dofloor->delaytimer = sides[line->sidenum[0]].rowoffset >> FRACBITS;
|
|
|
|
|
|
|
|
dofloor->texture = (fixed_t)(line - lines); // hack: store source line number
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
firstone = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SoM: Boom elevator support.
|
|
|
|
//
|
|
|
|
// EV_DoElevator
|
|
|
|
//
|
|
|
|
// Handle elevator linedef types
|
|
|
|
//
|
|
|
|
// Passed the linedef that triggered the elevator and the elevator action
|
|
|
|
//
|
|
|
|
// jff 2/22/98 new type to move floor and ceiling in parallel
|
|
|
|
//
|
2020-04-18 08:52:58 +00:00
|
|
|
void EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
INT32 secnum = -1;
|
|
|
|
sector_t *sec;
|
|
|
|
elevator_t *elevator;
|
2020-04-17 20:26:04 +00:00
|
|
|
mtag_t tag = Tag_FGet(&line->tags);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// act on all sectors with the same tag as the triggering linedef
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS(tag, secnum)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
sec = §ors[secnum];
|
|
|
|
|
|
|
|
// If either floor or ceiling is already activated, skip it
|
|
|
|
if (sec->floordata || sec->ceilingdata)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// create and initialize new elevator thinker
|
|
|
|
elevator = Z_Calloc(sizeof (*elevator), PU_LEVSPEC, NULL);
|
2019-04-20 20:37:19 +00:00
|
|
|
P_AddThinker(THINK_MAIN, &elevator->thinker);
|
2014-03-15 16:59:03 +00:00
|
|
|
sec->floordata = elevator;
|
|
|
|
sec->ceilingdata = elevator;
|
|
|
|
elevator->thinker.function.acp1 = (actionf_p1)T_MoveElevator;
|
|
|
|
elevator->type = elevtype;
|
|
|
|
elevator->sourceline = line;
|
|
|
|
elevator->distance = 1; // Always crush unless otherwise
|
|
|
|
|
|
|
|
// set up the fields according to the type of elevator action
|
|
|
|
switch (elevtype)
|
|
|
|
{
|
|
|
|
// elevator down to next floor
|
|
|
|
case elevateDown:
|
|
|
|
elevator->direction = -1;
|
|
|
|
elevator->sector = sec;
|
|
|
|
elevator->speed = ELEVATORSPEED/2; // half speed
|
|
|
|
elevator->floordestheight = P_FindNextLowestFloor(sec, sec->floorheight);
|
|
|
|
elevator->ceilingdestheight = elevator->floordestheight
|
|
|
|
+ sec->ceilingheight - sec->floorheight;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// elevator up to next floor
|
|
|
|
case elevateUp:
|
|
|
|
elevator->direction = 1;
|
|
|
|
elevator->sector = sec;
|
|
|
|
elevator->speed = ELEVATORSPEED/4; // quarter speed
|
|
|
|
elevator->floordestheight = P_FindNextHighestFloor(sec, sec->floorheight);
|
|
|
|
elevator->ceilingdestheight = elevator->floordestheight
|
|
|
|
+ sec->ceilingheight - sec->floorheight;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// elevator up to highest floor
|
|
|
|
case elevateHighest:
|
|
|
|
elevator->direction = 1;
|
|
|
|
elevator->sector = sec;
|
|
|
|
elevator->speed = ELEVATORSPEED/4; // quarter speed
|
|
|
|
elevator->floordestheight = P_FindHighestFloorSurrounding(sec);
|
|
|
|
elevator->ceilingdestheight = elevator->floordestheight
|
|
|
|
+ sec->ceilingheight - sec->floorheight;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// elevator to floor height of activating switch's front sector
|
|
|
|
case elevateCurrent:
|
|
|
|
elevator->sector = sec;
|
|
|
|
elevator->speed = ELEVATORSPEED;
|
|
|
|
elevator->floordestheight = line->frontsector->floorheight;
|
|
|
|
elevator->ceilingdestheight = elevator->floordestheight
|
|
|
|
+ sec->ceilingheight - sec->floorheight;
|
|
|
|
elevator->direction = elevator->floordestheight > sec->floorheight? 1 : -1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case elevateContinuous:
|
|
|
|
if (customspeed)
|
|
|
|
{
|
2021-02-13 16:45:20 +00:00
|
|
|
elevator->origspeed = P_AproxDistance(line->dx, line->dy);
|
2014-03-15 16:59:03 +00:00
|
|
|
elevator->origspeed = FixedDiv(elevator->origspeed,4*FRACUNIT);
|
|
|
|
elevator->speed = elevator->origspeed;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elevator->speed = ELEVATORSPEED/2;
|
|
|
|
elevator->origspeed = elevator->speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
elevator->sector = sec;
|
|
|
|
elevator->low = !(line->flags & ML_NOCLIMB); // go down first unless noclimb is on
|
|
|
|
if (elevator->low)
|
|
|
|
{
|
|
|
|
elevator->direction = 1;
|
|
|
|
elevator->floordestheight = P_FindNextHighestFloor(sec, sec->floorheight);
|
|
|
|
elevator->ceilingdestheight = elevator->floordestheight
|
|
|
|
+ sec->ceilingheight - sec->floorheight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elevator->direction = -1;
|
|
|
|
elevator->floordestheight = P_FindNextLowestFloor(sec,sec->floorheight);
|
|
|
|
elevator->ceilingdestheight = elevator->floordestheight
|
|
|
|
+ sec->ceilingheight - sec->floorheight;
|
|
|
|
}
|
|
|
|
elevator->floorwasheight = elevator->sector->floorheight;
|
|
|
|
elevator->ceilingwasheight = elevator->sector->ceilingheight;
|
|
|
|
|
|
|
|
elevator->delay = sides[line->sidenum[0]].textureoffset >> FRACBITS;
|
|
|
|
elevator->delaytimer = sides[line->sidenum[0]].rowoffset >> FRACBITS; // Initial delay
|
|
|
|
break;
|
|
|
|
|
|
|
|
case bridgeFall:
|
|
|
|
elevator->direction = -1;
|
|
|
|
elevator->sector = sec;
|
|
|
|
elevator->speed = ELEVATORSPEED*4; // quadruple speed
|
|
|
|
elevator->floordestheight = P_FindNextLowestFloor(sec, sec->floorheight);
|
|
|
|
elevator->ceilingdestheight = elevator->floordestheight
|
|
|
|
+ sec->ceilingheight - sec->floorheight;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EV_CrumbleChain(sector_t *sec, ffloor_t *rover)
|
|
|
|
{
|
2017-09-25 19:35:04 +00:00
|
|
|
size_t i, leftmostvertex, rightmostvertex, topmostvertex, bottommostvertex;
|
|
|
|
fixed_t leftx, rightx, topy, bottomy, topz, bottomz, widthfactor, heightfactor, a, b, c, spacing;
|
|
|
|
mobjtype_t type;
|
|
|
|
tic_t lifetime;
|
|
|
|
INT16 flags;
|
|
|
|
|
|
|
|
sector_t *controlsec = rover->master->frontsector;
|
2020-04-17 20:26:04 +00:00
|
|
|
mtag_t tag = Tag_FGet(&controlsec->tags);
|
2017-09-25 19:35:04 +00:00
|
|
|
|
|
|
|
if (sec == NULL)
|
|
|
|
{
|
|
|
|
if (controlsec->numattached)
|
|
|
|
{
|
|
|
|
for (i = 0; i < controlsec->numattached; i++)
|
|
|
|
{
|
|
|
|
sec = §ors[controlsec->attached[i]];
|
|
|
|
if (!sec->ffloors)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (rover = sec->ffloors; rover; rover = rover->next)
|
|
|
|
{
|
|
|
|
if (rover->master->frontsector == controlsec)
|
|
|
|
EV_CrumbleChain(sec, rover);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
leftmostvertex = rightmostvertex = topmostvertex = bottommostvertex = 0;
|
|
|
|
widthfactor = heightfactor = FRACUNIT;
|
|
|
|
spacing = (32<<FRACBITS);
|
|
|
|
type = MT_ROCKCRUMBLE1;
|
|
|
|
lifetime = 3*TICRATE;
|
|
|
|
flags = 0;
|
2016-06-04 17:59:24 +00:00
|
|
|
|
2020-04-17 20:26:04 +00:00
|
|
|
if (tag != 0)
|
2016-06-04 17:59:24 +00:00
|
|
|
{
|
2020-04-17 20:26:04 +00:00
|
|
|
INT32 tagline = Tag_FindLineSpecial(14, tag);
|
2016-06-04 18:39:15 +00:00
|
|
|
if (tagline != -1)
|
2016-06-04 17:59:24 +00:00
|
|
|
{
|
2016-06-04 18:39:15 +00:00
|
|
|
if (sides[lines[tagline].sidenum[0]].toptexture)
|
|
|
|
type = (mobjtype_t)sides[lines[tagline].sidenum[0]].toptexture; // Set as object type in p_setup.c...
|
|
|
|
if (sides[lines[tagline].sidenum[0]].textureoffset)
|
|
|
|
spacing = sides[lines[tagline].sidenum[0]].textureoffset;
|
|
|
|
if (sides[lines[tagline].sidenum[0]].rowoffset)
|
2016-06-04 22:06:26 +00:00
|
|
|
{
|
2016-06-05 00:26:02 +00:00
|
|
|
if (sides[lines[tagline].sidenum[0]].rowoffset>>FRACBITS != -1)
|
2016-06-04 22:06:26 +00:00
|
|
|
lifetime = (sides[lines[tagline].sidenum[0]].rowoffset>>FRACBITS);
|
|
|
|
else
|
|
|
|
lifetime = 0;
|
|
|
|
}
|
2016-06-04 18:39:15 +00:00
|
|
|
flags = lines[tagline].flags;
|
2016-06-04 17:59:24 +00:00
|
|
|
}
|
|
|
|
}
|
2014-11-12 00:55:07 +00:00
|
|
|
|
2016-06-04 17:59:24 +00:00
|
|
|
#undef controlsec
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// soundorg z height never gets set normally, so MEH.
|
|
|
|
sec->soundorg.z = sec->floorheight;
|
2016-06-04 17:59:24 +00:00
|
|
|
S_StartSound(&sec->soundorg, mobjinfo[type].activesound);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2014-11-12 00:55:07 +00:00
|
|
|
// Find the outermost vertexes in the subsector
|
2014-03-15 16:59:03 +00:00
|
|
|
for (i = 0; i < sec->linecount; i++)
|
2014-11-12 00:55:07 +00:00
|
|
|
{
|
|
|
|
// Find the leftmost vertex in the subsector.
|
2014-03-15 16:59:03 +00:00
|
|
|
if ((sec->lines[i]->v1->x < sec->lines[leftmostvertex]->v1->x))
|
|
|
|
leftmostvertex = i;
|
2014-11-12 00:55:07 +00:00
|
|
|
// Find the rightmost vertex in the subsector.
|
2014-03-15 16:59:03 +00:00
|
|
|
if ((sec->lines[i]->v1->x > sec->lines[rightmostvertex]->v1->x))
|
|
|
|
rightmostvertex = i;
|
2014-11-12 00:55:07 +00:00
|
|
|
// Find the topmost vertex in the subsector.
|
2014-03-15 16:59:03 +00:00
|
|
|
if ((sec->lines[i]->v1->y > sec->lines[topmostvertex]->v1->y))
|
|
|
|
topmostvertex = i;
|
2014-11-12 00:55:07 +00:00
|
|
|
// Find the bottommost vertex in the subsector.
|
2014-03-15 16:59:03 +00:00
|
|
|
if ((sec->lines[i]->v1->y < sec->lines[bottommostvertex]->v1->y))
|
|
|
|
bottommostvertex = i;
|
2014-11-12 00:55:07 +00:00
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2016-06-04 17:59:24 +00:00
|
|
|
leftx = sec->lines[leftmostvertex]->v1->x+(spacing>>1);
|
2014-03-15 16:59:03 +00:00
|
|
|
rightx = sec->lines[rightmostvertex]->v1->x;
|
2016-06-04 17:59:24 +00:00
|
|
|
topy = sec->lines[topmostvertex]->v1->y-(spacing>>1);
|
2014-03-15 16:59:03 +00:00
|
|
|
bottomy = sec->lines[bottommostvertex]->v1->y;
|
|
|
|
|
2016-06-04 17:59:24 +00:00
|
|
|
topz = *rover->topheight-(spacing>>1);
|
2016-09-29 13:23:58 +00:00
|
|
|
bottomz = *rover->bottomheight;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2016-09-29 13:23:58 +00:00
|
|
|
if (flags & ML_EFFECT1)
|
|
|
|
{
|
|
|
|
widthfactor = (rightx + topy - leftx - bottomy)>>3;
|
|
|
|
heightfactor = (topz - *rover->bottomheight)>>2;
|
|
|
|
}
|
2016-06-04 17:59:24 +00:00
|
|
|
|
|
|
|
for (a = leftx; a < rightx; a += spacing)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2016-06-04 17:59:24 +00:00
|
|
|
for (b = topy; b > bottomy; b -= spacing)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
if (R_PointInSubsector(a, b)->sector == sec)
|
|
|
|
{
|
|
|
|
mobj_t *spawned = NULL;
|
2016-09-29 13:23:58 +00:00
|
|
|
if (*rover->t_slope)
|
2020-05-18 13:23:56 +00:00
|
|
|
topz = P_GetSlopeZAt(*rover->t_slope, a, b) - (spacing>>1);
|
2016-09-29 13:23:58 +00:00
|
|
|
if (*rover->b_slope)
|
2020-05-18 13:23:56 +00:00
|
|
|
bottomz = P_GetSlopeZAt(*rover->b_slope, a, b);
|
2016-09-29 13:23:58 +00:00
|
|
|
|
|
|
|
for (c = topz; c > bottomz; c -= spacing)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2014-11-12 00:55:07 +00:00
|
|
|
spawned = P_SpawnMobj(a, b, c, type);
|
2016-06-04 20:23:15 +00:00
|
|
|
spawned->angle += P_RandomKey(36)*ANG10; // irrelevant for default objects but might make sense for some custom ones
|
2016-06-04 20:19:52 +00:00
|
|
|
|
2016-06-04 17:59:24 +00:00
|
|
|
if (flags & ML_EFFECT1)
|
|
|
|
{
|
2021-02-13 16:45:20 +00:00
|
|
|
P_InstaThrust(spawned, R_PointToAngle2(sec->soundorg.x, sec->soundorg.y, a, b), FixedDiv(P_AproxDistance(a - sec->soundorg.x, b - sec->soundorg.y), widthfactor));
|
2016-11-24 15:23:13 +00:00
|
|
|
P_SetObjectMomZ(spawned, FixedDiv((c - bottomz), heightfactor), false);
|
2016-06-04 17:59:24 +00:00
|
|
|
}
|
2016-06-04 22:06:26 +00:00
|
|
|
|
|
|
|
spawned->fuse = lifetime;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// no longer exists (can't collide with again)
|
|
|
|
rover->flags &= ~FF_EXISTS;
|
|
|
|
rover->master->frontsector->moved = true;
|
2019-07-04 13:43:18 +00:00
|
|
|
P_RecalcPrecipInSector(sec);
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Used for bobbing platforms on the water
|
2020-04-18 08:52:58 +00:00
|
|
|
void EV_BounceSector(sector_t *sec, fixed_t momz, line_t *sourceline)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-18 08:45:21 +00:00
|
|
|
bouncecheese_t *bouncer;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// create and initialize new thinker
|
|
|
|
if (sec->ceilingdata) // One at a time, ma'am.
|
2020-04-18 08:52:58 +00:00
|
|
|
return;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
bouncer = Z_Calloc(sizeof (*bouncer), PU_LEVSPEC, NULL);
|
2019-04-20 20:37:19 +00:00
|
|
|
P_AddThinker(THINK_MAIN, &bouncer->thinker);
|
2014-03-15 16:59:03 +00:00
|
|
|
sec->ceilingdata = bouncer;
|
|
|
|
bouncer->thinker.function.acp1 = (actionf_p1)T_BounceCheese;
|
|
|
|
|
|
|
|
// set up the fields according to the type of elevator action
|
2020-04-18 08:45:21 +00:00
|
|
|
bouncer->sourceline = sourceline;
|
2014-03-15 16:59:03 +00:00
|
|
|
bouncer->sector = sec;
|
|
|
|
bouncer->speed = momz/2;
|
|
|
|
bouncer->distance = FRACUNIT;
|
2020-04-18 08:45:21 +00:00
|
|
|
bouncer->low = true;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// For T_ContinuousFalling special
|
2020-04-17 23:42:13 +00:00
|
|
|
void EV_DoContinuousFall(sector_t *sec, sector_t *backsector, fixed_t spd, boolean backwards)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-04-17 23:42:13 +00:00
|
|
|
continuousfall_t *faller;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// workaround for when there is no back sector
|
2020-04-17 23:42:13 +00:00
|
|
|
if (!backsector)
|
2014-03-15 16:59:03 +00:00
|
|
|
backsector = sec;
|
|
|
|
|
|
|
|
// create and initialize new thinker
|
|
|
|
faller = Z_Calloc(sizeof (*faller), PU_LEVSPEC, NULL);
|
2019-04-20 20:37:19 +00:00
|
|
|
P_AddThinker(THINK_MAIN, &faller->thinker);
|
2014-03-15 16:59:03 +00:00
|
|
|
faller->thinker.function.acp1 = (actionf_p1)T_ContinuousFalling;
|
|
|
|
|
|
|
|
// set up the fields
|
|
|
|
faller->sector = sec;
|
|
|
|
faller->speed = spd;
|
|
|
|
|
2020-04-17 23:42:13 +00:00
|
|
|
faller->floorstartheight = sec->floorheight;
|
|
|
|
faller->ceilingstartheight = sec->ceilingheight;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-17 23:42:13 +00:00
|
|
|
faller->destheight = backwards ? backsector->ceilingheight : backsector->floorheight;
|
|
|
|
faller->direction = backwards ? 1 : -1;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Some other 3dfloor special things Tails 03-11-2002 (Search p_mobj.c for description)
|
|
|
|
INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating,
|
|
|
|
player_t *player, fixed_t origalpha, boolean crumblereturn)
|
|
|
|
{
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble_t *crumble;
|
2014-03-15 16:59:03 +00:00
|
|
|
sector_t *foundsec;
|
|
|
|
INT32 i;
|
2020-04-17 20:26:04 +00:00
|
|
|
mtag_t tag = Tag_FGet(&rover->master->tags);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// If floor is already activated, skip it
|
|
|
|
if (sec->floordata)
|
|
|
|
return 0;
|
|
|
|
|
2020-04-17 21:54:37 +00:00
|
|
|
if (sec->crumblestate >= CRUMBLE_ACTIVATED)
|
2014-03-15 16:59:03 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-04-26 09:55:10 +00:00
|
|
|
// create and initialize new crumble thinker
|
|
|
|
crumble = Z_Calloc(sizeof (*crumble), PU_LEVSPEC, NULL);
|
|
|
|
P_AddThinker(THINK_MAIN, &crumble->thinker);
|
|
|
|
crumble->thinker.function.acp1 = (actionf_p1)T_StartCrumble;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-26 09:55:10 +00:00
|
|
|
// set up the fields
|
|
|
|
crumble->sector = sec;
|
|
|
|
crumble->speed = 0;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
if (player && player->mo && (player->mo->eflags & MFE_VERTICALFLIP))
|
|
|
|
{
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->direction = 1; // Up
|
2020-04-26 14:51:14 +00:00
|
|
|
crumble->flags |= CF_REVERSE;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
else
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->direction = -1; // Down
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->floorwasheight = crumble->sector->floorheight;
|
|
|
|
crumble->ceilingwasheight = crumble->sector->ceilingheight;
|
2020-04-26 14:51:14 +00:00
|
|
|
crumble->timer = TICRATE;
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->player = player;
|
2020-04-26 14:51:14 +00:00
|
|
|
crumble->origalpha = origalpha;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->sourceline = rover->master;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-26 09:55:10 +00:00
|
|
|
sec->floordata = crumble;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-26 14:51:14 +00:00
|
|
|
if (crumblereturn)
|
|
|
|
crumble->flags |= CF_RETURN;
|
2014-03-15 16:59:03 +00:00
|
|
|
if (floating)
|
2020-04-26 14:51:14 +00:00
|
|
|
crumble->flags |= CF_FLOATBOB;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-26 09:55:10 +00:00
|
|
|
crumble->sector->crumblestate = CRUMBLE_ACTIVATED;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2021-02-11 12:24:20 +00:00
|
|
|
TAG_ITER_SECTORS(tag, i)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
foundsec = §ors[i];
|
|
|
|
|
2020-04-26 09:55:10 +00:00
|
|
|
P_SpawnMobj(foundsec->soundorg.x, foundsec->soundorg.y, crumble->direction == 1 ? crumble->sector->floorheight : crumble->sector->ceilingheight, MT_CRUMBLEOBJ);
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-04-18 00:05:23 +00:00
|
|
|
void EV_MarioBlock(ffloor_t *rover, sector_t *sector, mobj_t *puncher)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2016-06-06 17:30:58 +00:00
|
|
|
sector_t *roversec = rover->master->frontsector;
|
|
|
|
fixed_t topheight = *rover->topheight;
|
2020-04-18 00:05:23 +00:00
|
|
|
mariothink_t *block;
|
2014-03-15 16:59:03 +00:00
|
|
|
mobj_t *thing;
|
|
|
|
fixed_t oldx = 0, oldy = 0, oldz = 0;
|
|
|
|
|
|
|
|
I_Assert(puncher != NULL);
|
|
|
|
I_Assert(puncher->player != NULL);
|
|
|
|
|
2016-06-06 17:30:58 +00:00
|
|
|
if (roversec->floordata || roversec->ceilingdata)
|
2020-04-18 00:05:23 +00:00
|
|
|
return;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2016-06-06 17:30:58 +00:00
|
|
|
if (!(rover->flags & FF_SOLID))
|
|
|
|
rover->flags |= (FF_SOLID|FF_RENDERALL|FF_CUTLEVEL);
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
// Find an item to pop out!
|
2016-06-06 17:30:58 +00:00
|
|
|
thing = SearchMarioNode(roversec->touching_thinglist);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-04-18 00:05:23 +00:00
|
|
|
if (!thing)
|
|
|
|
S_StartSound(puncher, sfx_mario1); // "Thunk!" sound - puncher is "close enough".
|
|
|
|
else // Found something!
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
const boolean itsamonitor = (thing->flags & MF_MONITOR) == MF_MONITOR;
|
|
|
|
// create and initialize new elevator thinker
|
|
|
|
|
|
|
|
block = Z_Calloc(sizeof (*block), PU_LEVSPEC, NULL);
|
2019-04-20 20:37:19 +00:00
|
|
|
P_AddThinker(THINK_MAIN, &block->thinker);
|
2016-06-06 17:30:58 +00:00
|
|
|
roversec->floordata = block;
|
|
|
|
roversec->ceilingdata = block;
|
2014-03-15 16:59:03 +00:00
|
|
|
block->thinker.function.acp1 = (actionf_p1)T_MarioBlock;
|
|
|
|
|
|
|
|
// Set up the fields
|
2016-06-06 17:30:58 +00:00
|
|
|
block->sector = roversec;
|
2020-04-18 00:05:23 +00:00
|
|
|
block->speed = 4*FRACUNIT;
|
|
|
|
block->direction = 1;
|
|
|
|
block->floorstartheight = block->sector->floorheight;
|
|
|
|
block->ceilingstartheight = block->sector->ceilingheight;
|
2020-04-25 08:47:45 +00:00
|
|
|
block->tag = (INT16)Tag_FGet(§or->tags);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
if (itsamonitor)
|
|
|
|
{
|
|
|
|
oldx = thing->x;
|
|
|
|
oldy = thing->y;
|
|
|
|
oldz = thing->z;
|
|
|
|
}
|
|
|
|
|
|
|
|
P_UnsetThingPosition(thing);
|
2016-06-06 17:30:58 +00:00
|
|
|
thing->x = sector->soundorg.x;
|
|
|
|
thing->y = sector->soundorg.y;
|
2014-03-15 16:59:03 +00:00
|
|
|
thing->z = topheight;
|
|
|
|
thing->momz = FixedMul(6*FRACUNIT, thing->scale);
|
|
|
|
P_SetThingPosition(thing);
|
|
|
|
if (thing->flags & MF_SHOOTABLE)
|
2015-02-13 16:15:58 +00:00
|
|
|
P_DamageMobj(thing, puncher, puncher, 1, 0);
|
2018-04-28 14:13:44 +00:00
|
|
|
else if (thing->type == MT_RING || thing->type == MT_COIN || thing->type == MT_TOKEN)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
thing->momz = FixedMul(3*FRACUNIT, thing->scale);
|
|
|
|
P_TouchSpecialThing(thing, puncher, false);
|
|
|
|
// "Thunk!" sound
|
|
|
|
S_StartSound(puncher, sfx_mario1); // Puncher is "close enough"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// "Powerup rise" sound
|
|
|
|
S_StartSound(puncher, sfx_mario9); // Puncher is "close enough"
|
|
|
|
}
|
|
|
|
|
2016-10-12 21:06:40 +00:00
|
|
|
if (itsamonitor && thing)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2016-10-12 21:06:40 +00:00
|
|
|
P_UnsetThingPosition(thing);
|
|
|
|
thing->x = oldx;
|
|
|
|
thing->y = oldy;
|
|
|
|
thing->z = oldz;
|
|
|
|
thing->momx = 1;
|
|
|
|
thing->momy = 1;
|
|
|
|
P_SetThingPosition(thing);
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|