Git Repos / fte_dogmode / qc / triggers / filter.qc
Last update to this file was on 2025-03-30 at 19:29.
Show filter.qc
//==============================================================================
// trigger_filter
//==============================================================================
//======================================================================
// constants
//======================================================================
#ifdef SSQC
//----------------------------------------------------------------------
// trigger_changelevel spawnflags -- CEV
//----------------------------------------------------------------------
typedef enumflags
{
SPAWNFLAG_TRIGGER_FILTER_NEGATE_RESULT = 1,
SPAWNFLAG_TRIGGER_FILTER_RELAY_ACTIVATOR = 2
// SPAWNFLAG_NOT_ON_EASY = 256, // see base_entities.qc -- CEV
// SPAWNFLAG_NOT_ON_NORMAL = 512,
// SPAWNFLAG_NOT_ON_HARD_OR_NIGHTMARE = 1024,
// SPAWNFLAG_NOT_IN_DEATHMATCH = 2048,
// SPAWNFLAG_NOT_IN_COOP = 4096,
// SPAWNFLAG_NOT_IN_SP = 8192,
// SPAWNFLAG_NOT_ON_SKILL2 = 32768, // see base_entities.qc -- CEV
// SPAWNFLAG_NOT_ON_SKILL3 = 65536, // see base_entities.qc -- CEV
// SPAWNFLAG_CENTERPRINTALL = 131072 // see base_entities.qc -- CEV
} trigger_filter_spawnflags;
#endif
#ifdef SSQC
//----------------------------------------------------------------------
typedef enum
{
TRIGGER_FILTER_FIELD_STATE = 0,
TRIGGER_FILTER_FIELD_HEALTH = 1,
TRIGGER_FILTER_FIELD_WEAPON = 2,
TRIGGER_FILTER_FIELD_FLAGS = 3,
TRIGGER_FILTER_FIELD_SPAWNFLAGS = 4,
TRIGGER_FILTER_FIELD_CLASSNAME = 5,
TRIGGER_FILTER_FIELD_ESTATE = 6,
TRIGGER_FILTER_FIELD_TARGETNAME = 8,
TRIGGER_FILTER_FIELD_ITEMS = 10,
TRIGGER_FILTER_FIELD_COUNT = 11,
TRIGGER_FILTER_FIELD_CNT = 12,
TRIGGER_FILTER_FIELD_TYPE = 13
} trigger_filter_fields;
//----------------------------------------------------------------------
typedef enum
{
TRIGGER_FILTER_FIELDTYPE_FLOAT = 0,
TRIGGER_FILTER_FIELDTYPE_STRING = 1,
TRIGGER_FILTER_FIELDTYPE_FLAG = 2
} trigger_filter_filedtypes;
//----------------------------------------------------------------------
typedef enum
{
TRIGGER_FILTER_OP_EQUALS = 0,
TRIGGER_FILTER_OP_LT = 1,
TRIGGER_FILTER_OP_LTE = 2,
TRIGGER_FILTER_OP_GT = 3,
TRIGGER_FILTER_OP_GTE = 4,
TRIGGER_FILTER_OP_BITMASK_AND = 5,
TRIGGER_FILTER_OP_BITMASK_OR = 6
} trigger_filter_operations;
#endif
//======================================================================
// fields
//======================================================================
#ifdef SSQC
.string include; // trigger_filter
.string type; // trigger_filter
#endif
//======================================================================
// forward declarations
//======================================================================
#ifdef SSQC
// trigger_filter
void() trigger_filter_use;
void(entity e) trigger_filter_init;
void() trigger_filter;
#endif
//------------------------------------------------------------------------------
#ifdef SSQC
//----------------------------------------------------------------------
// TODO CEV: this needs comments
//----------------------------------------------------------------------
// class trigger_filter: base_trigger
// {
//--------------------------------------------------------------
void() trigger_filter_use =
{
self.state = 0;
if (self.estate != STATE_ACTIVE)
return;
local entity targ;
local float fieldtype, op, result, targfloat;
local string targstring;
targfloat = fieldtype = op = result = 0;
targstring = "";
if (self.include != "")
{
targ = find (world, targetname, self.include);
if (!targ)
targ = find (world, targetname2,
self.include);
if (!targ)
return;
}
else
{
targ = activator;
}
op = self.weapon;
switch (self.style)
{
case TRIGGER_FILTER_FIELD_STATE:
fieldtype = TRIGGER_FILTER_FIELDTYPE_FLOAT;
targfloat = targ.state;
break;
case TRIGGER_FILTER_FIELD_ESTATE:
fieldtype = TRIGGER_FILTER_FIELDTYPE_FLOAT;
targfloat = targ.estate;
break;
case TRIGGER_FILTER_FIELD_HEALTH:
fieldtype = TRIGGER_FILTER_FIELDTYPE_FLOAT;
targfloat = targ.health;
break;
case TRIGGER_FILTER_FIELD_COUNT:
fieldtype = TRIGGER_FILTER_FIELDTYPE_FLOAT;
targfloat = targ.count;
break;
case TRIGGER_FILTER_FIELD_CNT:
fieldtype = TRIGGER_FILTER_FIELDTYPE_FLOAT;
targfloat = targ.cnt;
break;
case TRIGGER_FILTER_FIELD_WEAPON:
fieldtype = TRIGGER_FILTER_FIELDTYPE_FLOAT;
targfloat = targ.weapon;
break;
case TRIGGER_FILTER_FIELD_FLAGS:
fieldtype = TRIGGER_FILTER_FIELDTYPE_FLAG;
targfloat = targ.flags;
break;
case TRIGGER_FILTER_FIELD_SPAWNFLAGS:
fieldtype = TRIGGER_FILTER_FIELDTYPE_FLAG;
targfloat = targ.spawnflags;
break;
case TRIGGER_FILTER_FIELD_ITEMS:
fieldtype = TRIGGER_FILTER_FIELDTYPE_FLAG;
targfloat = targ.items;
break;
case TRIGGER_FILTER_FIELD_CLASSNAME:
fieldtype = TRIGGER_FILTER_FIELDTYPE_STRING;
targstring = targ.classname;
break;
case TRIGGER_FILTER_FIELD_TARGETNAME:
fieldtype = TRIGGER_FILTER_FIELDTYPE_STRING;
targstring = targ.targetname;
break;
case TRIGGER_FILTER_FIELD_TYPE:
fieldtype = TRIGGER_FILTER_FIELDTYPE_STRING;
targstring = targ.type;
break;
}
if (fieldtype == TRIGGER_FILTER_FIELDTYPE_FLOAT)
{
if (op == TRIGGER_FILTER_OP_EQUALS)
{
if (targfloat == self.count)
result = 1;
}
else if (op == TRIGGER_FILTER_OP_LT)
{
if (targfloat < self.count)
result = 1;
}
else if (op == TRIGGER_FILTER_OP_LTE)
{
if (targfloat <= self.count)
result = 1;
}
else if (op == TRIGGER_FILTER_OP_GT)
{
if (targfloat > self.count)
result = 1;
}
else if (op == TRIGGER_FILTER_OP_GTE)
{
if (targfloat >= self.count)
result = 1;
}
else if (op == TRIGGER_FILTER_OP_BITMASK_AND)
{
if (targfloat & self.count)
result = 1;
}
else if (op == TRIGGER_FILTER_OP_BITMASK_OR)
{
if (targfloat | self.count)
result = 1;
}
else
{
if (targfloat == self.count)
result = 1;
}
}
else if (fieldtype == TRIGGER_FILTER_FIELDTYPE_FLAG)
{
if (op == TRIGGER_FILTER_OP_EQUALS)
{
if (targfloat == self.aflag)
result = 1;
}
else if (op == TRIGGER_FILTER_OP_BITMASK_AND)
{
if (targfloat & self.aflag)
result = 1;
}
else if (op == TRIGGER_FILTER_OP_BITMASK_OR)
{
if (targfloat | self.aflag)
result = 1;
}
else
{
if (targfloat == self.aflag)
result = 1;
}
}
else if (fieldtype == TRIGGER_FILTER_FIELDTYPE_STRING)
{
if (targstring == self.type)
result = 1;
}
else
{
objerror ("invalid fieldtype");
return;
}
if (self.spawnflags & SPAWNFLAG_TRIGGER_FILTER_NEGATE_RESULT)
// negate
result = 1 - result;
if (result)
{
self.state = 1;
// relay activator as owner
if (activator.owner && self.spawnflags &
SPAWNFLAG_TRIGGER_FILTER_RELAY_ACTIVATOR)
{
activator = activator.owner;
}
sub_usetargets ();
if (other.classtype == CT_TRIGGER_EVERYTHING &&
other.spawnflags & 1 && other.wait)
{
other.attack_finished = time + other.wait;
}
}
};
//--------------------------------------------------------------
void(entity e) trigger_filter_init =
{
e.classname = "trigger_filter";
e.classtype = CT_TRIGGER_FILTER;
e.use = trigger_filter_use;
base_trigger_init (e);
};
//--------------------------------------------------------------
void() trigger_filter =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;
trigger_filter_init (self);
};
// };
#endif
Return to the top of this page or return to the overview of this repo.
Log filter.qc
Date | Commit Message | Author | + | - |
---|---|---|---|---|
2025-03-30 | Big commit. Entity networking, etc. | cev | +98 | -63 |
2024-06-15 | Major update, committing as-is, will have bugs | cev | +9 | |
2024-03-24 | 2nd pass refactor, rework QC class structure | cev | +64 | -34 |
2024-01-09 | Continue OO / Class-based refactor | cev | +11 | -10 |
2023-12-09 | Start OO / class-based refactor, work on items | cev | +177 | -167 |
2023-11-20 | changes to movement, build environment, file reorg | cev | +226 |
Return to the top of this page or return to the overview of this repo.