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.
|
|
|
|
*/
|
2018-12-30 17:00:38 -08:00
|
|
|
|
2020-08-07 05:07:38 -07:00
|
|
|
/*QUAKED trigger_relay (0 .5 .8) ? TRLY_ONCE
|
2019-09-06 20:37:06 -07:00
|
|
|
"targetname" Name
|
|
|
|
"target" Target when triggered.
|
|
|
|
"killtarget" Target to kill when triggered.
|
2020-08-07 05:07:38 -07:00
|
|
|
"delay" Delay til the target is triggered.
|
|
|
|
"triggerstate" Desired state of the triggered entity.
|
2019-09-06 20:37:06 -07:00
|
|
|
|
2020-08-07 05:07:38 -07:00
|
|
|
This is an inbetween trigger that forces a desired output state
|
|
|
|
instead of toggling e.g. a door open.
|
|
|
|
|
|
|
|
When the spawnflag TRLY_ONCE is set, the trigger_relay will be removed upon
|
|
|
|
triggering its targets.
|
2019-09-06 20:37:06 -07:00
|
|
|
*/
|
|
|
|
|
2020-08-07 05:07:38 -07:00
|
|
|
enumflags
|
|
|
|
{
|
|
|
|
TRLY_ONCE,
|
|
|
|
};
|
|
|
|
|
|
|
|
class trigger_relay:CBaseTrigger
|
|
|
|
{
|
|
|
|
int m_iTriggerState;
|
|
|
|
int m_iEnabled;
|
|
|
|
|
|
|
|
void(void) trigger_relay;
|
2020-08-10 03:32:18 -07:00
|
|
|
virtual void(entity, int) Trigger;
|
2020-08-07 05:07:38 -07:00
|
|
|
virtual void(void) Respawn;
|
2020-09-08 16:56:46 -07:00
|
|
|
virtual void(string, string) SpawnKey;
|
2020-08-07 05:07:38 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2020-08-10 03:32:18 -07:00
|
|
|
trigger_relay::Trigger(entity act, int state)
|
2020-08-07 05:07:38 -07:00
|
|
|
{
|
|
|
|
if (m_iEnabled == FALSE)
|
|
|
|
return;
|
|
|
|
if (spawnflags & TRLY_ONCE)
|
|
|
|
m_iEnabled = FALSE;
|
|
|
|
|
2020-09-21 09:10:31 -07:00
|
|
|
UseTargets(act, m_iTriggerState, m_flDelay);
|
2020-08-07 05:07:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
trigger_relay::Respawn(void)
|
|
|
|
{
|
|
|
|
m_iEnabled = TRUE;
|
|
|
|
}
|
|
|
|
|
2020-09-08 16:56:46 -07:00
|
|
|
void
|
|
|
|
trigger_relay::SpawnKey(string strKey, string strValue)
|
|
|
|
{
|
|
|
|
switch (strKey) {
|
|
|
|
case "triggerstate":
|
|
|
|
m_iTriggerState = stoi(strValue);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CBaseTrigger::SpawnKey(strKey, strValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-07 05:07:38 -07:00
|
|
|
void
|
|
|
|
trigger_relay::trigger_relay(void)
|
|
|
|
{
|
|
|
|
CBaseTrigger::CBaseTrigger();
|
|
|
|
}
|