2019-08-31 19:18:15 -07:00
|
|
|
/*
|
2020-04-07 05:46:23 -07:00
|
|
|
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
|
2019-08-31 19:18:15 -07:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
2019-01-18 12:06:23 -08:00
|
|
|
|
2019-09-09 10:12:18 -07:00
|
|
|
/*QUAKED path_corner (1 0 0) (-8 -8 -8) (8 8 8) PC_WAIT PC_TELEPORT PC_FIREONCE
|
2021-07-14 02:49:30 -07:00
|
|
|
Node entities used for func_trains and func_guntargets.
|
|
|
|
|
|
|
|
-------- KEYS --------
|
2019-09-06 20:37:06 -07:00
|
|
|
"targetname" Name
|
2019-09-09 10:12:18 -07:00
|
|
|
"target" Next node.
|
|
|
|
"message" Target to trigger when a train passes this node.
|
|
|
|
"speed" New speed for passing train.
|
|
|
|
"yaw_speed" New yaw rotation for passing train. Currently unused.
|
|
|
|
"wait" Waiting time until we go to the next node.
|
2019-09-06 20:37:06 -07:00
|
|
|
|
2021-07-14 02:49:30 -07:00
|
|
|
-------- NOTES --------
|
2019-09-09 10:12:18 -07:00
|
|
|
When the PC_WAIT flag is set, the train will stop moving once it's passed this
|
|
|
|
node. The train will have to be triggered again for it to continue moving.
|
|
|
|
This is useful for elevators.
|
|
|
|
|
|
|
|
When the PC_TELEPORT flag is set, the train passing this node will immediately
|
|
|
|
teleport to the position of the next node (target).
|
|
|
|
|
|
|
|
With the PC_FIREONCE flag set, it'll only fire its target (message) once.
|
2020-10-25 04:38:41 -07:00
|
|
|
|
2021-07-14 02:49:30 -07:00
|
|
|
-------- TRIVIA --------
|
2020-10-25 04:38:41 -07:00
|
|
|
This entity was introduced in Quake (1996).
|
2019-09-06 20:37:06 -07:00
|
|
|
*/
|
|
|
|
|
2020-01-20 10:35:10 -08:00
|
|
|
#ifdef DEVELOPER
|
|
|
|
var int autocvar_dev_cornerspeed = 0;
|
|
|
|
#endif
|
|
|
|
|
2020-04-12 06:50:42 -07:00
|
|
|
enumflags
|
|
|
|
{
|
2019-09-09 09:55:58 -07:00
|
|
|
PC_WAIT,
|
|
|
|
PC_TELEPORT,
|
|
|
|
PC_FIREONCE
|
|
|
|
};
|
|
|
|
|
2019-01-18 12:06:23 -08:00
|
|
|
class path_corner:CBaseTrigger
|
|
|
|
{
|
2019-09-09 10:12:18 -07:00
|
|
|
int m_iFired;
|
2019-01-18 12:06:23 -08:00
|
|
|
float m_flSpeed;
|
2019-09-09 09:55:58 -07:00
|
|
|
float m_flYawSpeed;
|
2019-01-18 12:06:23 -08:00
|
|
|
float m_flWait;
|
|
|
|
|
2020-04-12 06:50:42 -07:00
|
|
|
void(void) path_corner;
|
2020-08-10 03:32:18 -07:00
|
|
|
virtual void(entity, int) Trigger;
|
2020-04-12 06:50:42 -07:00
|
|
|
virtual void(void) Respawn;
|
2020-09-08 16:56:46 -07:00
|
|
|
virtual void(string, string) SpawnKey;
|
2019-01-18 12:06:23 -08:00
|
|
|
};
|
|
|
|
|
2019-09-09 13:05:32 -07:00
|
|
|
void
|
2020-08-10 03:32:18 -07:00
|
|
|
path_corner::Trigger(entity act, int state)
|
2019-09-09 09:55:58 -07:00
|
|
|
{
|
2019-09-09 10:12:18 -07:00
|
|
|
entity a;
|
|
|
|
|
2020-11-28 13:52:56 -08:00
|
|
|
if ((spawnflags & PC_FIREONCE) && m_iFired) {
|
2019-09-09 10:12:18 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-08 13:49:35 -07:00
|
|
|
for (a = world; (a = find(a, ::targetname, m_strMessage));) {
|
2019-09-09 10:12:18 -07:00
|
|
|
CBaseTrigger trigger = (CBaseTrigger)a;
|
2020-08-10 03:32:18 -07:00
|
|
|
trigger.Trigger(act, state);
|
2019-09-09 10:12:18 -07:00
|
|
|
m_iFired = TRUE;
|
2019-09-09 09:55:58 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 13:05:32 -07:00
|
|
|
void
|
|
|
|
path_corner::Respawn(void)
|
2019-09-09 10:12:18 -07:00
|
|
|
{
|
2020-01-20 10:35:10 -08:00
|
|
|
#ifdef DEVELOPER
|
|
|
|
if (autocvar_dev_cornerspeed != 0) {
|
|
|
|
m_flSpeed = autocvar_dev_cornerspeed;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-09-09 10:12:18 -07:00
|
|
|
m_iFired = FALSE;
|
|
|
|
}
|
|
|
|
|
2020-09-08 16:56:46 -07:00
|
|
|
void
|
|
|
|
path_corner::SpawnKey(string strKey, string strValue)
|
|
|
|
{
|
|
|
|
switch (strKey) {
|
|
|
|
case "speed":
|
|
|
|
m_flSpeed = stof(strValue);
|
|
|
|
break;
|
|
|
|
case "yaw_speed":
|
|
|
|
m_flYawSpeed = stof(strValue);
|
|
|
|
break;
|
|
|
|
case "wait":
|
|
|
|
m_flWait = stof(strValue);
|
|
|
|
break;
|
|
|
|
case "message":
|
|
|
|
m_strMessage = strValue;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CBaseTrigger::SpawnKey(strKey, strValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 13:05:32 -07:00
|
|
|
void
|
|
|
|
path_corner::path_corner(void)
|
2019-01-18 12:06:23 -08:00
|
|
|
{
|
2020-09-09 22:00:28 -07:00
|
|
|
m_flWait = 1.0f;
|
2020-11-28 13:52:56 -08:00
|
|
|
m_flSpeed = 100.0f;
|
2019-01-18 12:06:23 -08:00
|
|
|
CBaseTrigger::CBaseTrigger();
|
|
|
|
}
|