Examples

edit

Trigger Types

edit

There are six main sorts of triggers you'll use:

Brush triggers This is something like a trigger_multiple - an area brush that triggers when you walk over it.
Point triggers These are used as func_goalinfo entities, and can have mins and maxs set to define their actual size. They trigger when you walk into the defined area surrounding the entity - they can also do other effects, such as showing a model that becomes invisible while active, etc.
Untouchable triggers These are usually set as info_notnull, and act as relays or simply alternative triggers (i.e. two entities with the same name, one only triggerable by blue and one only triggerable by red).
Flags These are used as func_goalitem entities (or func_flag, same thing), and are 'carried' by the player when successfully touched.
Standard entities These are things like func_door, or info_player_start entities - they act in more or less the usual fashion, but the criteria and cascading triggers still operate.
Special entities These are things like the func_commandpoint - new entities that have special behaviour defined by the entity. (More on these later).

Sample Flag

edit

A 'flag' is an entity that can only be carried, but only by one team, and does various effects when carried.

{
    // The red flag

    "classname" "func_goalitem"
    // this one is set by the editor when you position the entity:
    "origin" "1248 1984 -328"

    // What it looks like    
    "model" "models/flags/r_flag.md3"    // Model to use    
    "light" "200"                        // Dynamic light
    "color" "1 0 0"                      // Pure red
    "sparkle" "1 0 0"                    // Generate smoke puffs around carrier

    // What it's called
    "groupname" "redflag"

    // Criteria
    "allowteams" "blue"    // Only blue players can trigger (i.e. carry)

    // Messages on trigger
    // Centerprint message to activator:
    "carried_message" "~You have taken the ^1RED^* flag!"
    // Tell everyone activator has done it:
    "carried_all_message" "~%N has TAKEN the ^1RED^* flag!"
    // Tell everyone activator dropped the flag:
    "active_all_message" "~%N has DROPPED the ^1RED^* flag!"
    "inactive_all_message" "The ^1RED^* flag has returned."
    // Play Sound to team:
    "carried_team_sound" "~sound/teamplay/voc_team_flag.wav"
    // Play Sound to non-team players:
    "carried_nonteam_sound" "~sound/teamplay/voc_enemy_flag.wav"
    // Play Sound to activator:
    "carried_sound" "~sound/teamplay/voc_you_flag.wav"

    // Flaginfo (shown on \flaginfo command)
    "carried_flaginfo" "%N has the ^1RED^* flag."
    "active_flaginfo" "The ^1RED^* flag has been dropped at $l."			
    // Flags must use $l for active_flaginfo and active_all_message
    "inactive_flaginfo" "The ^1RED^* flag is at the red base."

    // Misc
    // Reveal spies on trigger, show flag above player when carried:
    "flags" "revealagent,showcarry"
    // Wait 45 seconds before going inactive (i.e. back to base):
    "wait" "45"
}

Sample Capture Point

edit

Now we have a flag, we need somewhere to capture it.

{
    // The capture point in the blue base

    "classname" "trigger_multiple"
    // Origin/size defined by brush (never set)
    "model" "*10"

    // Criteria
    // Only trigger if activator holds redflag:
    "holding" "redflag"

    // Messages
    // Centerprint message to everyone:
    "active_all_message" "~%N has CAPTURED the ^1RED^* flag!"
    "active_message" "You have scored 2 frags for capturing the flag."
    // Play sound to activator:
    "active_sound" "~sound/teamplay/voc_blue_scores.wav"
    // Play sound to activator's team (apart from activator):
    "active_team_sound" "sound/teamplay/flagcap_blu.wav"

    // 'Give' bonuses
    "give" "score=+2,health=+100,armor=+200,ammo_shells=+200,ammo_nails=+200,ammo_cells=+200,ammo_rockets=+200,ammo_medikit=+50,gren1=+4,gren2=+2"    
    // Give activator's team 10 points (the teamscore, not the players on the team):
    "teamscore" "10"

    // When activated, force redflag to inactive (back to base),
    // trigger scorer (optional extra 10 points entity):
    "activetarget" "redflag=~inactive,scorer"
}

Sample Command Point

edit

To make things a little more interesting, why don't we have a 'scorer' command point that gives players an extra 10 points when they capture the flag?

{
    // A button to press to claim the command point

    "classname" "func_button"
    "model" "*1"
    "angle" "-2"
    "wait" "5"
    // Trigger the scorer command point when activated:
    "activetarget" "scorer_cp"
}

{
    // The scorer command point (no model, so must be triggered by another entity)

    "classname" "func_commandpoint"
    "origin" "448 832 -128"

    // Misc
    "groupname" "scorer_cp"

    // Messages
    "active_all_message" "~%N has claimed the\ncapture bonus for the %T!"

    // On activation (i.e. touch if we have a model, or trigger by a button
    // or something otherwise)
    // All entities named 'scorer' are locked to activators team:
    "teamset" "scorer"
    // Set scorer to inactive (i.e. ready to be activated):
    "activetarget" "scorer=inactive"
}

{
    // An untouchable 'scorer' entity
    "classname" "info_notnull"    
    "origin" "444 828 -84"         // Hardly 'essential' in this case...

    // Misc
    "groupname" "scorer"           // So other entities can reference
    // Prevent scorer from being triggered initially
    // (i.e. until command point is claimed):
    "initialstate" "disabled"

    // On activation
    "teamscore" "10"               // Give the activator's team 10 points
    // Go inactive after 1 second (the chances of someone capturing twice
    // in under a second are pretty slim...):
    "wait" "1"
}

Sample Hud

edit

We've forgotten something - we need to show a player if he's carrying the flag or not, or he's liable to get confused (and upset if he finds he's had it for the last 5 minutes without capturing). We need a HUD entity.

{
    // A HUD entity shown to the red flag carrier
    "classname" "func_hud"
    "origin" "1252 1980 -292"

    // Entity never actually activates, just show this model:
    "inactive_model" "models/flags/r_flag.md3"
    "slot" "1"            // Display it in slot 1 (top left)
    "holding" "redflag"   // Only player holding redflag can see this entity
}