NSTrigger: add method CanBeTriggeredBy() which filters out various entity types.
This commit is contained in:
parent
e820e74dbc
commit
854c5907a6
3 changed files with 67 additions and 4 deletions
|
@ -46,6 +46,21 @@ typedef enum
|
||||||
TRIG_TOGGLE
|
TRIG_TOGGLE
|
||||||
} triggermode_t;
|
} triggermode_t;
|
||||||
|
|
||||||
|
enumflags
|
||||||
|
{
|
||||||
|
TOUCHFILTER_CLIENTS,
|
||||||
|
TOUCHFILTER_NPCS,
|
||||||
|
TOUCHFILTER_PUSHABLE,
|
||||||
|
TOUCHFILTER_PHYSICS,
|
||||||
|
TOUCHFILTER_FRIENDLIES,
|
||||||
|
TOUCHFILTER_CLIENTSINVEHICLES,
|
||||||
|
TOUCHFILTER_EVERYTHING,
|
||||||
|
TOUCHFILTER_CLIENTSNOTINVEHICLES,
|
||||||
|
TOUCHFILTER_DEBRIS,
|
||||||
|
TOUCHFILTER_NPCSINVEHICLES,
|
||||||
|
TOUCHFILTER_NOBOTS
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/** NSTrigger handles all the non-input as well as Legacy (Quake, GoldSource) style
|
/** NSTrigger handles all the non-input as well as Legacy (Quake, GoldSource) style
|
||||||
trigger behaviour. It also deals with masters, touches, blocking and so on.
|
trigger behaviour. It also deals with masters, touches, blocking and so on.
|
||||||
|
@ -77,6 +92,9 @@ public:
|
||||||
virtual void Restore(string,string);
|
virtual void Restore(string,string);
|
||||||
virtual void Input(entity,string,string);
|
virtual void Input(entity,string,string);
|
||||||
|
|
||||||
|
/* Called to check if the target entity can touch trigger itself. */
|
||||||
|
virtual bool CanBeTriggeredBy(entity);
|
||||||
|
|
||||||
/** Called whenever we're legacy triggered by another object or function. */
|
/** Called whenever we're legacy triggered by another object or function. */
|
||||||
virtual void Trigger(entity, triggermode_t);
|
virtual void Trigger(entity, triggermode_t);
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,48 @@ NSTrigger::NSTrigger(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
|
|
||||||
|
bool
|
||||||
|
NSTrigger::CanBeTriggeredBy(entity testEnt)
|
||||||
|
{
|
||||||
|
/* easy way out */
|
||||||
|
if (spawnflags & TOUCHFILTER_EVERYTHING)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* filters */
|
||||||
|
if (!(spawnflags & TOUCHFILTER_CLIENTS) && (testEnt.flags & FL_CLIENT))
|
||||||
|
return false;
|
||||||
|
if (!(spawnflags & TOUCHFILTER_NPCS) && (testEnt.flags & FL_MONSTER))
|
||||||
|
return false;
|
||||||
|
if (!(spawnflags & TOUCHFILTER_PUSHABLE) && (testEnt.classname == "func_pushable"))
|
||||||
|
return false;
|
||||||
|
if (!(spawnflags & TOUCHFILTER_PHYSICS) && (testEnt.isPhysics == true))
|
||||||
|
return false;
|
||||||
|
if (!(spawnflags & TOUCHFILTER_FRIENDLIES) && (testEnt.flags & FL_MONSTER) && (testEnt.m_iAlliance == 0))
|
||||||
|
return false;
|
||||||
|
if (!(spawnflags & TOUCHFILTER_CLIENTSINVEHICLES) && (testEnt.flags & FL_CLIENT) && (testEnt.flags & FL_INVEHICLE))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
if (!spawnflags & TOUCHFILTER_CLIENTSNOTINVEHICLES) {
|
||||||
|
return false;
|
||||||
|
if (!spawnflags &TRIGTELE_DEBRIS) && )
|
||||||
|
return false;
|
||||||
|
if (!spawnflags &TRIGTELE_NPCSINVEHICLES) && )
|
||||||
|
return false;
|
||||||
|
if (!spawnflags &TRIGTELE_NOBOTS) && )
|
||||||
|
return false;
|
||||||
|
*/
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* legacy trigger architecture */
|
/* legacy trigger architecture */
|
||||||
void
|
void
|
||||||
NSTrigger::Trigger(entity act, triggermode_t state)
|
NSTrigger::Trigger(entity act, triggermode_t state)
|
||||||
{
|
{
|
||||||
|
breakpoint();
|
||||||
NSLog("^2%s::^3Trigger^7: Triggered by %s with no consequence",
|
NSLog("^2%s::^3Trigger^7: Triggered by %s with no consequence",
|
||||||
classname, act.classname);
|
classname, act.classname);
|
||||||
}
|
}
|
||||||
|
@ -50,6 +88,9 @@ NSTrigger::UseTargets(entity act, int state, float fDelay)
|
||||||
remove(self);
|
remove(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if not (target)
|
||||||
|
return;
|
||||||
|
|
||||||
if not (m_strKillTarget)
|
if not (m_strKillTarget)
|
||||||
if not (target)
|
if not (target)
|
||||||
return;
|
return;
|
||||||
|
@ -158,6 +199,8 @@ NSTrigger::HasTriggerTarget(void)
|
||||||
{
|
{
|
||||||
if not (target)
|
if not (target)
|
||||||
return false;
|
return false;
|
||||||
|
if (target == "")
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -323,6 +366,7 @@ NSTrigger::_TouchHandler(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* start touch in case we haven't */
|
/* start touch in case we haven't */
|
||||||
if (m_beingTouched != true)
|
if (m_beingTouched != true)
|
||||||
StartTouch(other);
|
StartTouch(other);
|
||||||
|
|
|
@ -308,12 +308,12 @@ Sound_PrecacheFile(string fileName)
|
||||||
{
|
{
|
||||||
filestream scriptFile;
|
filestream scriptFile;
|
||||||
string lineStream;
|
string lineStream;
|
||||||
int braceDepth;
|
int braceDepth = 0i;
|
||||||
string sndDefName = "";
|
string sndDefName = "";
|
||||||
int startIndex = g_sounds_count;
|
int startIndex = g_sounds_count;
|
||||||
|
|
||||||
if (g_sounds_count >= SOUNDSHADER_MAX)
|
if (g_sounds_count >= SOUNDSHADER_MAX)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
scriptFile = fopen(fileName, FILE_READ);
|
scriptFile = fopen(fileName, FILE_READ);
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ Sound_PrecacheFile(string fileName)
|
||||||
g_sounds_count++;
|
g_sounds_count++;
|
||||||
|
|
||||||
if (g_sounds_count >= SOUNDSHADER_MAX)
|
if (g_sounds_count >= SOUNDSHADER_MAX)
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -795,6 +795,7 @@ Sound_GetID(string defName)
|
||||||
{
|
{
|
||||||
if (defName == "")
|
if (defName == "")
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return (int)hash_get(g_hashsounds, defName, -1);
|
return (int)hash_get(g_hashsounds, defName, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,7 +924,7 @@ SoundSource_Init(void)
|
||||||
|
|
||||||
/* file doesn't exist. that's okay. */
|
/* file doesn't exist. that's okay. */
|
||||||
if (manifestFile < 0) {
|
if (manifestFile < 0) {
|
||||||
error(sprintf("loading %S failed.\n", manifestStart));
|
//error(sprintf("loading %S failed.\n", manifestStart));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue