Lua:trigger ff script

From Fortress Forever Wiki
Jump to navigationJump to search


This entity is functionally the same as trigger_multiple. Most of these functions will also work with the other trigger_* entities.

A trigger_ff_script is a brush-based scriptable entity. Unlike most Source entities, which represent one type of object and have predetermined behavior, the scriptability behind this entity makes it extremely flexibile.

trigger_ff_script entities represent areas that can affect, and be affected by players. Such items might be the capture points in a CTF map, nobuild areas, or team-killing laser fields.

These entities are placed in a map editor, such as Hammer, and must be given a name in order to function correctly. This name will be used to link it into the map's corresponding Lua file. So, whenever you put a named trigger_ff_script entity in your map, the game attempts to find a correspondingly named function in mapname.lua.

FF includes a number of pre-existing game modes that require very little work to implement in your own maps--that is, assuming your map's gameplay is similar enough to one of these templates. You'll simply need to add the appropriate entities, give them the proper names, and you're all set. More on that can be found by looking at the available map templates.

Creating a trigger_ff_script

-- This is my first base trigger!
endzone = trigger_ff_script:new({
       points_per_score = 6,
       fortpoints_per_score = 100
       allowedmethod = redTeamOnly
--Access to events is typically in the following format:

function endzone:ontrigger( entity )
  --What to do when this method is called
  --return anything, if necessary


allowed( allowed_entity )

Decides whether the entity allowed_entity (usually a player) may activate the trigger. Return true if the trigger is allowed, otherwise return false.

onfailtouch( touch_entity )

Called when allowed() returns false. touch_entity refers to the entity that was tested earlier.

ontouch( trigger_entity )

Called when an entity starts touching the trigger.

onendtouch( trigger_entity )

Called when an entity stops touching the trigger.

ontrigger( trigger_entity )

Called when this entity is triggered. Note that this takes into account the wait time of this trigger, whereas ontouch() does not.

onbuild( build_entity )

Called when someone tries to place Buildables inside the trigger. build_entity refers to the thing being built. Return false or EVENT_DISALLOWED to prevent the player from building.

onexplode( explode_entity )

Called when something (such as a grenade or detpack) is about to explode inside the trigger. explode_entity refers to the thing exploding. Return false or EVENT_DISALLOWED to prevent the explosion from occurring. Return EVENT_ALLOWED to allow the explosion.

oninfect( infect_entity )

Called when a player is about to become infected when inside the trigger. Return false or EVENT_DISALLOWED to prevent the player from being infected.