GS-Entbase: More Input/Output logic for the following ents:
trigger_changelevel, trigger_hurt, trigger_look, trigger_multiple & trigger_once. Plus a fix for func_guntarget
This commit is contained in:
parent
b48ce4d2ce
commit
2618d47ff3
6 changed files with 102 additions and 3 deletions
|
@ -223,4 +223,7 @@ void func_guntarget::func_guntarget(void)
|
|||
{
|
||||
m_flSpeed = 100;
|
||||
CBaseTrigger::CBaseTrigger();
|
||||
|
||||
if (m_strOnDeath)
|
||||
m_strOnDeath = CreateOutput(m_strOnDeath);
|
||||
}
|
||||
|
|
|
@ -54,12 +54,15 @@ class trigger_changelevel:CBaseTrigger
|
|||
float m_flChangeDelay;
|
||||
entity m_activator;
|
||||
|
||||
string m_strOnLevelChange;
|
||||
|
||||
void(void) trigger_changelevel;
|
||||
virtual void(void) Change;
|
||||
virtual void(entity, int) Trigger;
|
||||
virtual void(void) TouchTrigger;
|
||||
virtual void(void) Respawn;
|
||||
virtual int(entity, entity) IsInside;
|
||||
virtual void(entity, string, string) Input;
|
||||
virtual void(string, string) SpawnKey;
|
||||
};
|
||||
|
||||
|
@ -87,6 +90,12 @@ trigger_changelevel::Change(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!target) {
|
||||
UseOutput(m_activator, m_strOnLevelChange);
|
||||
} else {
|
||||
UseTargets(m_activator, TRIG_TOGGLE, m_flDelay);
|
||||
}
|
||||
|
||||
/* if some other entity triggered us... just find the next player. */
|
||||
if (!(m_activator.flags & FL_CLIENT)) {
|
||||
/* we need a player if we want to use landmarks at all */
|
||||
|
@ -147,6 +156,18 @@ trigger_changelevel::Respawn(void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
trigger_changelevel::Input(entity eAct, string strInput, string strData)
|
||||
{
|
||||
switch (strInput) {
|
||||
case "ChangeLevel":
|
||||
Trigger(eAct, TRIG_TOGGLE);
|
||||
break;
|
||||
default:
|
||||
CBaseTrigger::Input(eAct, strInput, strData);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
trigger_changelevel::SpawnKey(string strKey, string strValue)
|
||||
{
|
||||
|
@ -160,6 +181,11 @@ trigger_changelevel::SpawnKey(string strKey, string strValue)
|
|||
case "changedelay":
|
||||
m_flChangeDelay = stof(strValue);
|
||||
break;
|
||||
case "OnLevelChange":
|
||||
case "OnChangeLevel":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnLevelChange = strcat(m_strOnLevelChange, ",_", strValue);
|
||||
break;
|
||||
default:
|
||||
CBaseTrigger::SpawnKey(strKey, strValue);
|
||||
}
|
||||
|
@ -169,6 +195,9 @@ void
|
|||
trigger_changelevel::trigger_changelevel(void)
|
||||
{
|
||||
CBaseTrigger::CBaseTrigger();
|
||||
|
||||
if (m_strOnLevelChange)
|
||||
m_strOnLevelChange = CreateOutput(m_strOnLevelChange);
|
||||
}
|
||||
|
||||
vector
|
||||
|
|
|
@ -46,12 +46,17 @@ class trigger_hurt:CBaseTrigger
|
|||
float m_flNextDmg;
|
||||
int m_iDamage;
|
||||
float m_flDelay;
|
||||
|
||||
string m_strOnHurt;
|
||||
string m_strOnHurtPlayer;
|
||||
|
||||
void(void) trigger_hurt;
|
||||
|
||||
virtual void(entity, int) Trigger;
|
||||
virtual void(void) touch;
|
||||
virtual void(void) Respawn;
|
||||
virtual void(string, string) SpawnKey;
|
||||
virtual void(entity, string, string) Input;
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -86,7 +91,12 @@ trigger_hurt::touch(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (target) {
|
||||
if (!target) {
|
||||
if (other.flags & FL_CLIENT)
|
||||
UseOutput(other, m_strOnHurtPlayer);
|
||||
else
|
||||
UseOutput(other, m_strOnHurt);
|
||||
} else {
|
||||
if (spawnflags & SF_HURT_FIREONPLAYER) {
|
||||
if (other.flags & FL_CLIENT) {
|
||||
eActivator = other;
|
||||
|
@ -124,6 +134,18 @@ trigger_hurt::Respawn(void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
trigger_hurt::Input(entity eAct, string strInput, string strData)
|
||||
{
|
||||
switch (strInput) {
|
||||
case "SetDamage":
|
||||
m_iDamage = stoi(strData);
|
||||
break;
|
||||
default:
|
||||
CBaseTrigger::Input(eAct, strInput, strData);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
trigger_hurt::SpawnKey(string strKey, string strValue)
|
||||
{
|
||||
|
@ -134,6 +156,14 @@ trigger_hurt::SpawnKey(string strKey, string strValue)
|
|||
case "wait":
|
||||
m_flNextDmg = stof(strValue);
|
||||
break;
|
||||
case "OnHurt":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnHurt = strcat(m_strOnHurt, ",_", strValue);
|
||||
break;
|
||||
case "OnHurtPlayer":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnHurtPlayer = strcat(m_strOnHurtPlayer, ",_", strValue);
|
||||
break;
|
||||
default:
|
||||
CBaseTrigger::SpawnKey(strKey, strValue);
|
||||
}
|
||||
|
@ -147,4 +177,10 @@ trigger_hurt::trigger_hurt(void)
|
|||
m_flNextDmg = 0.5f;
|
||||
|
||||
CBaseTrigger::CBaseTrigger();
|
||||
|
||||
if (m_strOnHurt)
|
||||
m_strOnHurt = CreateOutput(m_strOnHurt);
|
||||
|
||||
if (m_strOnHurtPlayer)
|
||||
m_strOnHurtPlayer = CreateOutput(m_strOnHurtPlayer);
|
||||
}
|
||||
|
|
|
@ -41,9 +41,11 @@ class trigger_look:CBaseTrigger
|
|||
float m_flLookTime;
|
||||
string m_strLookTarget;
|
||||
float m_flDelay;
|
||||
|
||||
float m_flLooked;
|
||||
|
||||
/* Input/Output */
|
||||
string m_strOnTrigger;
|
||||
|
||||
void(void) trigger_look;
|
||||
|
||||
virtual void(void) Touch;
|
||||
|
@ -93,7 +95,11 @@ trigger_look::Touch(void)
|
|||
|
||||
/* trigger and disable entity, for now */
|
||||
SetSolid(SOLID_NOT);
|
||||
UseTargets(other, TRIG_TOGGLE, m_flDelay);
|
||||
|
||||
if (!target)
|
||||
UseOutput(other, m_strOnTrigger);
|
||||
else
|
||||
UseTargets(other, TRIG_TOGGLE, m_flDelay);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -120,6 +126,10 @@ trigger_look::SpawnKey(string strKey, string strValue)
|
|||
case "LookTime":
|
||||
m_flLookTime = stof(strValue);
|
||||
break;
|
||||
case "OnTrigger":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnTrigger = strcat(m_strOnTrigger, ",_", strValue);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -132,4 +142,7 @@ trigger_look::trigger_look(void)
|
|||
m_flFOV = 0.9f;
|
||||
|
||||
CBaseEntity::CBaseEntity();
|
||||
|
||||
if (m_strOnTrigger)
|
||||
m_strOnTrigger = CreateOutput(m_strOnTrigger);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,10 @@ enumflags
|
|||
class trigger_multiple:CBaseTrigger
|
||||
{
|
||||
float m_flWait;
|
||||
|
||||
/* Input/Output */
|
||||
string m_strOnStartTouch;
|
||||
string m_strOnTrigger;
|
||||
|
||||
void(void) trigger_multiple;
|
||||
virtual void(void) touch;
|
||||
|
@ -98,6 +101,10 @@ trigger_multiple::SpawnKey(string strKey, string strValue)
|
|||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnStartTouch = strcat(m_strOnStartTouch, ",_", strValue);
|
||||
break;
|
||||
case "OnTrigger":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnTrigger = strcat(m_strOnTrigger, ",_", strValue);
|
||||
break;
|
||||
default:
|
||||
CBaseTrigger::SpawnKey(strKey, strValue);
|
||||
}
|
||||
|
@ -108,6 +115,9 @@ trigger_multiple::trigger_multiple(void)
|
|||
{
|
||||
CBaseTrigger::CBaseTrigger();
|
||||
|
||||
if (m_strOnTrigger)
|
||||
m_strOnTrigger = CreateOutput(m_strOnTrigger);
|
||||
|
||||
if (m_strOnStartTouch)
|
||||
m_strOnStartTouch = CreateOutput(m_strOnStartTouch);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ enumflags
|
|||
class trigger_once:CBaseTrigger
|
||||
{
|
||||
string m_strOnStartTouch;
|
||||
string m_strOnTrigger;
|
||||
|
||||
void(void) trigger_once;
|
||||
|
||||
|
@ -85,6 +86,10 @@ trigger_once::SpawnKey(string strKey, string strValue)
|
|||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnStartTouch = strcat(m_strOnStartTouch, ",_", strValue);
|
||||
break;
|
||||
case "OnTrigger":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnTrigger = strcat(m_strOnTrigger, ",_", strValue);
|
||||
break;
|
||||
default:
|
||||
CBaseTrigger::SpawnKey(strKey, strValue);
|
||||
break;
|
||||
|
@ -96,6 +101,9 @@ trigger_once::trigger_once(void)
|
|||
{
|
||||
CBaseTrigger::CBaseTrigger();
|
||||
|
||||
if (m_strOnTrigger)
|
||||
m_strOnTrigger = CreateOutput(m_strOnTrigger);
|
||||
|
||||
if (m_strOnStartTouch)
|
||||
m_strOnStartTouch = CreateOutput(m_strOnStartTouch);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue