2015-05-19 21:54:34 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1997, 2005 - 3D Realms Entertainment
|
|
|
|
|
|
|
|
This file is part of Shadow Warrior version 1.2
|
|
|
|
|
|
|
|
Shadow Warrior is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
Original Source: 1997 - Frank Maddin and Jim Norwood
|
|
|
|
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-10-09 16:09:05 +00:00
|
|
|
#include "ns.h"
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "build.h"
|
|
|
|
|
|
|
|
#include "names2.h"
|
|
|
|
#include "panel.h"
|
|
|
|
#include "tags.h"
|
|
|
|
#include "sector.h"
|
|
|
|
#include "ai.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "game.h"
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
BEGIN_SW_NS
|
|
|
|
|
2022-09-04 22:35:11 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-12-11 02:49:58 +00:00
|
|
|
short DoSectorObjectSetScale(short match)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-31 14:50:44 +00:00
|
|
|
SECTOR_OBJECT* sop;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
|
|
|
{
|
2020-05-22 12:11:03 +00:00
|
|
|
if (SO_EMPTY(sop))
|
2015-05-19 21:54:34 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (sop->match_event == match)
|
|
|
|
{
|
2021-12-27 16:22:41 +00:00
|
|
|
sop->flags |= (SOBJ_DYNAMIC);
|
2023-05-28 08:47:17 +00:00
|
|
|
sop->PreMoveScale = true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
switch (sop->scale_active_type)
|
|
|
|
{
|
|
|
|
case SO_SCALE_RANDOM_POINT:
|
|
|
|
if (sop->scale_type == SO_SCALE_HOLD || sop->scale_type == SO_SCALE_NONE)
|
|
|
|
{
|
|
|
|
// if holding start it up
|
|
|
|
sop->scale_type = sop->scale_active_type;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if moving set to hold
|
|
|
|
sop->scale_type = SO_SCALE_HOLD;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SO_SCALE_DEST:
|
|
|
|
|
|
|
|
sop->scale_type = sop->scale_active_type;
|
|
|
|
|
2022-09-03 18:40:57 +00:00
|
|
|
if (sop->scale_dist == sop->scale_dist_max)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// make it negative
|
|
|
|
if (sop->scale_speed > 0)
|
|
|
|
sop->scale_speed = -sop->scale_speed;
|
|
|
|
}
|
2022-09-03 18:40:57 +00:00
|
|
|
else if (sop->scale_dist == sop->scale_dist_min)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// make it positive
|
|
|
|
if (sop->scale_speed < 0)
|
|
|
|
sop->scale_speed = -sop->scale_speed;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// make it positive
|
|
|
|
if (sop->scale_speed < 0)
|
|
|
|
sop->scale_speed = -sop->scale_speed;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SO_SCALE_RANDOM:
|
|
|
|
case SO_SCALE_CYCLE:
|
|
|
|
if (sop->scale_type == SO_SCALE_HOLD)
|
|
|
|
{
|
|
|
|
// if holding start it up
|
|
|
|
sop->scale_type = sop->scale_active_type;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if moving set to hold
|
|
|
|
sop->scale_type = SO_SCALE_HOLD;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-09-04 22:35:11 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-12-11 02:49:58 +00:00
|
|
|
short DoSOevent(short match, short state)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-31 14:50:44 +00:00
|
|
|
SECTOR_OBJECT* sop;
|
2015-05-19 21:54:34 +00:00
|
|
|
short vel_adj=0, spin_adj=0;
|
|
|
|
|
|
|
|
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
|
|
|
{
|
2020-05-22 12:11:03 +00:00
|
|
|
if (SO_EMPTY(sop))
|
2015-05-19 21:54:34 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (sop->match_event == match)
|
|
|
|
{
|
2021-12-29 05:53:36 +00:00
|
|
|
if ((sop->flags & SOBJ_WAIT_FOR_EVENT))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-10-03 19:43:55 +00:00
|
|
|
if (sop->save_vel > 0 || sop->save_spin_speed > nullAngle)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-27 17:58:15 +00:00
|
|
|
sop->flags &= ~(SOBJ_WAIT_FOR_EVENT);
|
2015-05-19 21:54:34 +00:00
|
|
|
sop->vel = sop->save_vel;
|
2022-10-03 19:43:55 +00:00
|
|
|
sop->spin_speed = sop->save_spin_speed;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-24 14:21:44 +00:00
|
|
|
auto me_act = sop->match_event_actor;
|
|
|
|
if (me_act == nullptr)
|
2015-05-19 21:54:34 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// toggle
|
|
|
|
if (state == -1)
|
|
|
|
{
|
2021-12-24 23:03:43 +00:00
|
|
|
if (TEST_BOOL3(me_act))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 23:03:43 +00:00
|
|
|
RESET_BOOL3(me_act);
|
2021-12-29 05:40:52 +00:00
|
|
|
state = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-24 23:03:43 +00:00
|
|
|
SET_BOOL3(me_act);
|
2021-12-29 08:27:13 +00:00
|
|
|
state = 1;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-29 08:27:13 +00:00
|
|
|
if (state == 1)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 14:21:44 +00:00
|
|
|
spin_adj = (int)SP_TAG3(me_act);
|
2021-12-24 23:03:43 +00:00
|
|
|
vel_adj = SP_TAG7(me_act);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2021-12-29 05:40:52 +00:00
|
|
|
else if (state == 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-24 14:21:44 +00:00
|
|
|
spin_adj = -(int)SP_TAG3(me_act);
|
2021-12-24 23:03:43 +00:00
|
|
|
vel_adj = -SP_TAG7(me_act);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2022-10-03 19:47:05 +00:00
|
|
|
sop->spin_speed += DAngle::fromBuild(spin_adj);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-24 23:03:43 +00:00
|
|
|
if (TEST_BOOL1(me_act))
|
2015-05-19 21:54:34 +00:00
|
|
|
sop->vel_tgt += vel_adj;
|
|
|
|
else
|
|
|
|
sop->vel += vel_adj;
|
|
|
|
|
2021-12-24 23:03:43 +00:00
|
|
|
if (TEST_BOOL2(me_act))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
sop->dir *= -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-04 22:35:11 +00:00
|
|
|
//---------------------------------------------------------------------------
|
2015-05-19 21:54:34 +00:00
|
|
|
//
|
|
|
|
// SCALING - PreAnimator
|
|
|
|
//
|
2022-09-04 22:35:11 +00:00
|
|
|
//---------------------------------------------------------------------------
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-31 14:50:44 +00:00
|
|
|
void ScaleSectorObject(SECTOR_OBJECT* sop)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
switch (sop->scale_type)
|
|
|
|
{
|
|
|
|
case SO_SCALE_NONE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SO_SCALE_HOLD:
|
|
|
|
break;
|
|
|
|
|
|
|
|
// to dest
|
|
|
|
case SO_SCALE_DEST:
|
2022-09-03 18:40:57 +00:00
|
|
|
sop->scale_dist += sop->scale_speed;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2022-09-03 18:40:57 +00:00
|
|
|
if (sop->scale_dist > sop->scale_dist_max)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 18:40:57 +00:00
|
|
|
sop->scale_dist = sop->scale_dist_max;
|
2015-05-19 21:54:34 +00:00
|
|
|
sop->scale_type = SO_SCALE_HOLD;
|
|
|
|
}
|
2022-09-03 18:40:57 +00:00
|
|
|
else if (sop->scale_dist < sop->scale_dist_min)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 18:40:57 +00:00
|
|
|
sop->scale_dist = sop->scale_dist_min;
|
2015-05-19 21:54:34 +00:00
|
|
|
sop->scale_type = SO_SCALE_HOLD;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
// random direction change
|
|
|
|
case SO_SCALE_RANDOM:
|
|
|
|
|
2022-09-03 18:40:57 +00:00
|
|
|
sop->scale_dist += sop->scale_speed;
|
|
|
|
if (sop->scale_dist > sop->scale_dist_max)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
sop->scale_speed *= -1;
|
2022-09-03 18:40:57 +00:00
|
|
|
sop->scale_dist = sop->scale_dist_max;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2022-09-03 18:40:57 +00:00
|
|
|
else if (sop->scale_dist < sop->scale_dist_min)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
sop->scale_speed *= -1;
|
2022-09-03 18:40:57 +00:00
|
|
|
sop->scale_dist = sop->scale_dist_min;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (RANDOM_P2(1024) < sop->scale_rand_freq<<3)
|
|
|
|
{
|
|
|
|
sop->scale_speed *= -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
// cycle through max and min
|
|
|
|
case SO_SCALE_CYCLE:
|
2022-09-03 18:40:57 +00:00
|
|
|
sop->scale_dist += sop->scale_speed;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2022-09-03 18:40:57 +00:00
|
|
|
if (sop->scale_dist > sop->scale_dist_max)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
sop->scale_speed *= -1;
|
2022-09-03 18:40:57 +00:00
|
|
|
sop->scale_dist = sop->scale_dist_max;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2022-09-03 18:40:57 +00:00
|
|
|
else if (sop->scale_dist < sop->scale_dist_min)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
sop->scale_speed *= -1;
|
2022-09-03 18:40:57 +00:00
|
|
|
sop->scale_dist = sop->scale_dist_min;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-04 22:35:11 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
DVector2 ScaleRandomPoint(SECTOR_OBJECT* sop, int k, DAngle ang, const DVector2& pos)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 20:57:07 +00:00
|
|
|
sop->scale_point_dist[k] += sop->scale_point_speed[k];
|
|
|
|
if (sop->scale_point_dist[k] > sop->scale_point_dist_max)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 20:57:07 +00:00
|
|
|
sop->scale_point_speed[k] *= -1;
|
|
|
|
sop->scale_point_dist[k] = sop->scale_point_dist_max;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2022-09-03 20:57:07 +00:00
|
|
|
else if (sop->scale_point_dist[k] < sop->scale_point_dist_min)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 20:57:07 +00:00
|
|
|
sop->scale_point_speed[k] *= -1;
|
|
|
|
sop->scale_point_dist[k] = sop->scale_point_dist_min;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (RANDOM_P2(1024) < sop->scale_point_rand_freq)
|
|
|
|
{
|
2022-09-03 20:57:07 +00:00
|
|
|
sop->scale_point_speed[k] *= -1;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// change up speed at random
|
2022-09-03 20:32:29 +00:00
|
|
|
if (RANDOM_P2(1024) < (sop->scale_point_rand_freq / 2))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 20:57:07 +00:00
|
|
|
double half = sop->scale_point_base_speed / 2;
|
|
|
|
double quart = sop->scale_point_base_speed / 4;
|
|
|
|
sop->scale_point_speed[k] = sop->scale_point_base_speed + (RandomRangeF(half) - quart);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2022-09-03 20:57:07 +00:00
|
|
|
double xmul = (sop->scale_point_dist[k] * sop->scale_x_mult) * (1 / 256.);
|
|
|
|
double ymul = (sop->scale_point_dist[k] * sop->scale_y_mult) * (1 / 256.);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2022-09-03 20:32:29 +00:00
|
|
|
DVector2 ret;
|
|
|
|
|
2022-09-03 20:57:07 +00:00
|
|
|
ret.X = pos.X + xmul * ang.Cos();
|
|
|
|
ret.Y = pos.Y + ymul * ang.Sin();
|
2022-09-03 20:32:29 +00:00
|
|
|
return ret;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2022-09-04 22:35:11 +00:00
|
|
|
//---------------------------------------------------------------------------
|
2015-05-19 21:54:34 +00:00
|
|
|
//
|
|
|
|
// Morph point - move point around
|
|
|
|
//
|
2022-09-04 22:35:11 +00:00
|
|
|
//---------------------------------------------------------------------------
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-12-31 14:50:44 +00:00
|
|
|
void MorphTornado(SECTOR_OBJECT* sop)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-31 14:43:47 +00:00
|
|
|
sectortype* *sectp;
|
2015-05-19 21:54:34 +00:00
|
|
|
int j;
|
|
|
|
|
|
|
|
// z direction
|
2021-11-24 22:07:02 +00:00
|
|
|
ASSERT(sop->op_main_sector != nullptr);
|
2022-09-03 18:23:41 +00:00
|
|
|
sop->morph_z += sop->morph_z_speed;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// move vector
|
2021-11-25 17:16:56 +00:00
|
|
|
if (sop->morph_wall_point == nullptr)
|
2015-05-19 21:54:34 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// place at correct x,y offset from center
|
2023-10-03 05:43:04 +00:00
|
|
|
DVector2 pos = sop->pmid.XY() - sop->morph_off;
|
2022-09-03 18:23:41 +00:00
|
|
|
DVector2 spos = pos;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// move it from last x,y
|
2022-09-03 18:23:41 +00:00
|
|
|
DVector2 mpos = pos + sop->morph_ang.ToVector() * sop->morph_speed;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// bound check radius
|
2022-09-03 18:40:57 +00:00
|
|
|
if ((sop->pmid - mpos).Length() > sop->morph_dist_max + sop->scale_dist)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 18:23:41 +00:00
|
|
|
// find and reverse angle
|
2022-09-30 11:51:37 +00:00
|
|
|
sop->morph_ang = (mpos - sop->pmid).Angle() + DAngle180;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// move back some from last point
|
2022-09-03 18:23:41 +00:00
|
|
|
mpos = spos + sop->morph_ang.ToVector() * sop->morph_speed * 2;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// save x,y back as offset info
|
2023-10-03 05:43:04 +00:00
|
|
|
sop->morph_off = sop->pmid.XY() - mpos;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if ((RANDOM_P2(1024<<4)>>4) < sop->morph_rand_freq)
|
2022-09-04 22:04:29 +00:00
|
|
|
sop->morph_ang = RandomAngle();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// move it x,y
|
2022-09-03 18:23:41 +00:00
|
|
|
dragpoint(sop->morph_wall_point, mpos);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// bound the Z
|
2022-09-03 18:23:41 +00:00
|
|
|
double ceilz = sop->op_main_sector->ceilingz;
|
|
|
|
double florz = sop->op_main_sector->floorz;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
|
|
|
|
{
|
2021-11-19 21:35:08 +00:00
|
|
|
if ((*sectp)->hasU() &&
|
2021-12-29 05:53:36 +00:00
|
|
|
((*sectp)->flags & SECTFU_SO_SLOPE_CEILING_TO_POINT))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 18:23:41 +00:00
|
|
|
if (sop->morph_z > florz)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 18:23:41 +00:00
|
|
|
sop->morph_z_speed *= -1;
|
|
|
|
sop->morph_z = florz;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2022-09-03 18:23:41 +00:00
|
|
|
else if (sop->morph_z < ceilz)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 18:23:41 +00:00
|
|
|
sop->morph_z_speed *= -1;
|
|
|
|
sop->morph_z = ceilz;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2022-09-03 18:23:41 +00:00
|
|
|
alignceilslope(*sectp, DVector3(mpos, sop->morph_z));
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-04 22:35:11 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2015-05-19 21:54:34 +00:00
|
|
|
// moves center point around and aligns slope
|
2022-09-04 22:35:11 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-12-31 14:50:44 +00:00
|
|
|
void MorphFloor(SECTOR_OBJECT* sop)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-31 14:43:47 +00:00
|
|
|
sectortype* *sectp;
|
2015-05-19 21:54:34 +00:00
|
|
|
int j;
|
|
|
|
|
|
|
|
// z direction
|
2021-11-24 22:07:02 +00:00
|
|
|
ASSERT(sop->op_main_sector != nullptr);
|
2022-09-03 18:23:41 +00:00
|
|
|
sop->morph_z -= sop->morph_z_speed;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// move vector
|
2021-11-25 17:16:56 +00:00
|
|
|
if (sop->morph_wall_point == nullptr)
|
2015-05-19 21:54:34 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// place at correct x,y offset from center
|
2022-09-03 18:23:41 +00:00
|
|
|
auto pos = sop->pmid - sop->morph_off;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// move it from last x,y
|
2023-10-03 05:43:04 +00:00
|
|
|
DVector2 mpos = pos.XY() + sop->morph_ang.ToVector() * sop->morph_speed;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// save x,y back as offset info
|
2023-10-03 05:43:04 +00:00
|
|
|
sop->morph_off = sop->pmid.XY() - mpos;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// bound check radius
|
2022-09-03 18:23:41 +00:00
|
|
|
if ((sop->pmid - mpos).Length() > sop->morph_dist_max)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// go in the other direction
|
2022-09-03 18:23:41 +00:00
|
|
|
sop->morph_ang = sop->morph_ang + DAngle180;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// back it up and save it off
|
2023-10-03 05:43:04 +00:00
|
|
|
mpos = pos.XY() + sop->morph_ang.ToVector() * sop->morph_speed;
|
|
|
|
sop->morph_off = sop->pmid.XY() - mpos;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((RANDOM_P2(1024<<4)>>4) < sop->morph_rand_freq)
|
2022-09-04 22:04:29 +00:00
|
|
|
sop->morph_ang = RandomAngle();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// move x,y point "just like in build"
|
2022-09-03 18:23:41 +00:00
|
|
|
dragpoint(sop->morph_wall_point, mpos);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// bound the Z
|
2022-09-03 18:23:41 +00:00
|
|
|
double florz = sop->op_main_sector->floorz;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2022-09-03 18:23:41 +00:00
|
|
|
const double MORPH_FLOOR_ZRANGE = 300;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2022-09-03 18:23:41 +00:00
|
|
|
if (sop->morph_z > MORPH_FLOOR_ZRANGE)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 18:23:41 +00:00
|
|
|
sop->morph_z = MORPH_FLOOR_ZRANGE;
|
|
|
|
sop->morph_z_speed *= -1;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2022-09-03 18:23:41 +00:00
|
|
|
else if (sop->morph_z < -MORPH_FLOOR_ZRANGE)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 18:23:41 +00:00
|
|
|
sop->morph_z = -MORPH_FLOOR_ZRANGE;
|
|
|
|
sop->morph_z_speed *= -1;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
|
|
|
|
{
|
2021-11-19 21:35:08 +00:00
|
|
|
if ((*sectp)->hasU() &&
|
2021-12-29 05:53:36 +00:00
|
|
|
((*sectp)->flags & SECTFU_SO_SLOPE_CEILING_TO_POINT))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 18:23:41 +00:00
|
|
|
alignflorslope(*sectp, DVector3(mpos, florz + sop->morph_z));
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-04 22:35:11 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-08-21 14:12:38 +00:00
|
|
|
void SOBJ_AlignFloorToPoint(SECTOR_OBJECT* sop, const DVector3& pos)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-31 14:43:47 +00:00
|
|
|
sectortype* *sectp;
|
2015-05-19 21:54:34 +00:00
|
|
|
int j;
|
|
|
|
|
|
|
|
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
|
|
|
|
{
|
2021-11-19 21:35:08 +00:00
|
|
|
if ((*sectp)->hasU() &&
|
2021-12-29 05:53:36 +00:00
|
|
|
((*sectp)->flags & SECTFU_SO_SLOPE_CEILING_TO_POINT))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-08-21 14:12:38 +00:00
|
|
|
alignflorslope(*sectp, pos);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-04 22:35:11 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-08-21 14:12:38 +00:00
|
|
|
void SOBJ_AlignCeilingToPoint(SECTOR_OBJECT* sop, const DVector3& pos)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-12-31 14:43:47 +00:00
|
|
|
sectortype* *sectp;
|
2015-05-19 21:54:34 +00:00
|
|
|
int j;
|
|
|
|
|
|
|
|
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
|
|
|
|
{
|
2021-11-19 21:35:08 +00:00
|
|
|
if ((*sectp)->hasU() &&
|
2021-12-29 05:53:36 +00:00
|
|
|
((*sectp)->flags & SECTFU_SO_SLOPE_CEILING_TO_POINT))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-08-21 14:12:38 +00:00
|
|
|
alignceilslope(*sectp, pos);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-04 22:35:11 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2015-05-19 21:54:34 +00:00
|
|
|
// moves center point around and aligns slope
|
2022-09-04 22:35:11 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-12-31 14:50:44 +00:00
|
|
|
void SpikeFloor(SECTOR_OBJECT* sop)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// z direction
|
2021-11-24 22:07:02 +00:00
|
|
|
ASSERT(sop->op_main_sector != nullptr);
|
2022-09-03 18:23:41 +00:00
|
|
|
sop->morph_z -= sop->morph_z_speed;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// move vector
|
2021-11-25 17:16:56 +00:00
|
|
|
if (sop->morph_wall_point == nullptr)
|
2015-05-19 21:54:34 +00:00
|
|
|
return;
|
|
|
|
|
2022-08-21 14:12:38 +00:00
|
|
|
// place at correct x,y offset from center
|
2022-09-03 18:23:41 +00:00
|
|
|
auto pos = sop->pmid - sop->morph_off;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// bound the Z
|
|
|
|
|
2022-09-03 18:23:41 +00:00
|
|
|
const double MORPH_FLOOR_ZRANGE = 300;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2022-09-03 18:23:41 +00:00
|
|
|
if (sop->morph_z > MORPH_FLOOR_ZRANGE)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 18:23:41 +00:00
|
|
|
sop->morph_z = MORPH_FLOOR_ZRANGE;
|
|
|
|
sop->morph_z_speed *= -1;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2022-09-03 18:23:41 +00:00
|
|
|
else if (sop->morph_z < -MORPH_FLOOR_ZRANGE)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2022-09-03 18:23:41 +00:00
|
|
|
sop->morph_z = -MORPH_FLOOR_ZRANGE;
|
|
|
|
sop->morph_z_speed *= -1;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2022-09-03 18:23:41 +00:00
|
|
|
pos.Z = sop->op_main_sector->floorz + sop->morph_z;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2022-08-21 14:12:38 +00:00
|
|
|
SOBJ_AlignFloorToPoint(sop, pos);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2022-09-04 22:35:11 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
END_SW_NS
|