Skip to content

Filters

Blixibon edited this page Jun 27, 2020 · 9 revisions

A filter tests a certain condition or set of conditions to filter through entities, like a trigger_once using a filter_activator_name that only allows an entity with the name "cow" to pass it. Click here for more information on filters in Source.

In Mapbase, all filters have been given the following new I/O/KV:

Inputs

  • TestEntity <ehandle> - Tests the filter against the specified entity and fires OnPass or OnFail based on the result. (TestActivator only uses the activator)
  • SetField <any> - Sets this filter's primary testing criteria (e.g. the name to test against the activator).

KeyValues

  • Pass caller when tested <boolean> - When tested with TestActivator or TestEntity, this causes the OnPass and OnFail outputs to use the entity that called the test as the caller instead of the filter itself.

New filters

Mapbase adds a few new filters so mappers could test more conditions:

Name Description
filter_activator_model Filters an entity by its model's name. This entity already exists in all games starting with Left 4 Dead, but Mapbase adds the option to filter by skin and supports matchers.
filter_activator_context Filters an entity by its response contexts. This entity already exists in all games starting with Left 4 Dead, but Mapbase allows for multiple contexts to be used at once and supports matchers.
filter_activator_squad Filters an NPC by its squad name, with the option to deny silent members. (enemy finders, vital allies in player_squad, etc.)
filter_activator_hintgroup Filters an NPC by its hint group, with the option to filter Hint Limit Nav.
filter_activator_keyfield Filters an entity by its keyvalues, serving as an extension of logic_keyfield.
filter_activator_relationship Filters an entity by its relationship to a target, or vice versa.
filter_activator_classify Filters an entity by its Classify() class. (e.g. CLASS_PLAYER_ALLY)
filter_activator_criteria Filters an entity by response criteria normally used in the response system.
filter_activator_involume Filters an entity by whether it's inside of a target entity's volume. (e.g. a trigger)
filter_activator_surfacedata Filters an entity by its surface data. (e.g. whether it's made of wood)

Redirect filters

Redirect filters are a new "class" of filters that take a separate entity from the activator and pass it to another filter. For example, a trigger_once using a filter_redirect_weapon gets the activator's weapon and passes it to a filter_activator_class, which checks if it's a weapon_pistol.

Here's a list of the redirect filters introduced in Mapbase:

Name Description
filter_redirect_weapon Redirects the activator's weapon. When used as a damage filter, this gets the weapon used in the damage.
filter_redirect_owner Redirects the activator's owner entity.
filter_redirect_inflictor As a damage filter, this redirects the inflictor of the damage, e.g. the grenade in an explosion. (filters normally use the attacker)

Damage manipulators

Damage manipulators are a family of filters designed to be used as damage filters, directly manipulating or operating with damage in some way. They don't actually filter anything themselves, but they can use a "secondary filter" to act as an actual damage filter or to control their behavior.

4 of these entities exist in Mapbase:

Name Description
filter_damage_transfer Causes damage taken by entities using this filter to transfer to a different entity, or a set of entities.
filter_damage_mod Modifies damage taken by entities using this filter.
filter_damage_logic Fires outputs with damage parameters whenever an entity using this filter takes damage.
filter_blood_control Controls whether blood can be emitted when an entity using this filter takes damage. (does not affect actual damage on its own)

filter_script

filter_script is a special filter which allows filter functions to be controlled by VScript. See VScript in Mapbase for more information on VScript.

Here's a list of the hooks filter_script can use:

Signature Description
bool PassesFilter(handle caller, handle entity) Check if the given caller and entity pass the filter.
bool PassesDamageFilter(handle caller, handle info) Check if the given caller and damage info pass the damage filter.
bool PassesFinalDamageFilter(handle caller, handle info) Used by filter_damage_redirect to distinguish between standalone filter calls and actually damaging an entity. Returns true if there's no unique behavior.
bool BloodAllowed(handle caller, handle info) Check if the given caller and damage info allow for the production of blood.
bool DamageMod(handle caller, handle info) Mods the damage info with the given caller.
Clone this wiki locally