Trigger counter

Trigger counter

Classname: trigger_counter
Purpose: Triggering events with multiple or ordered triggers.
H2 Code: triggers.hc
Incited by Speeed, I've finally done some work on this one, & figred out two previously undocumented fields for this entity, msg2 and puzzle_id, not mentioned in the hcode help.

Can be reset by trigger_counter_reset, and have triggering sequences passed to it by trigger_combination_assign.

Fields

target Value is a name; Entity with matching targetname value is triggered.
netname Value is a string, Ordered trigger_coumters need to share a unique netname value with their triggers (not their targets), otherwise the map won't start. netname doesn't seem to be necessary for unordered trigger_counters, and is at least sometimes omitted with them in the Raven maps.
count must be the number of triggers until the counter fires for unordered counting and number of triggers - 1 for ordered counting. After the counter has been triggered "count" times (default 2), it will fire all of it's targets and shut off, unless you specify a wait time.

Notes on ordered trigger_counters:

  • Spawnflag 2 (ORDERED) must be set.
  • The trigger_counter and its triggers must share a unique netname-value; this does not appear on the target.
  • The triggers that trigger the counter need to be ordered using their aflag field
  • The first trigger is 1, second is 2, etc.
  • If a trigger is hit out of order, the counter resets
  • Speeed discovered that if a monster death is used as a trigger (by giving the monster a target value) gibbing the monster will count as 2 (it sort of looks as if the death counts as one and the splatter as another.) This problem can be solved by having the monster target a NOTOUCH trigger_once entity, which itself targets the trugger_counter (using netname doesn't work, and neither does interposing a trigger_relay).
wait how long to wait after successful before giving it another try. Default is -1, meaning it works once and shuts off. If you specify a wait time, the trigger will become a multiple trigger.
puzzle_id Value is a name, which is targetted when the player first departs from the correct sequence. Used in egypt2 (to activate the teleport that tosses you off the floor buttons), and romeric4 (to spawn the skull wizards that appear when you don't get the right button sequence).
msg2 Value is a number, of the message that appears when you get the combination wrong. Appears in romeric4 with value 286 ("the sequence is incorrect").
mangle This entity has the ability to have a non-sequential sequence of numbers as a combination using mangle. The format is like a vector, for example, if you want the counter (ordered) to work only if the count order of 3, 5, 7 is used, enter the value "3 5 7" (no quotes).

Furthermore, a trigger_combination_assign entity can pass it's "mangle" value to trigger_counter when it uses it. This way you can have a number of different possible combinations that could be used and only one would be right (depending, say, on which path the player took). The values can be as high as you like (okay, from 1 to 65336), so you can have any number of buttons in this puzzle.

(wording lifted from hcode comments via Eutectic, but I have tested it now).

spawnflags:
  • 1 = NO MESSAGE: If set, suppresses "X more to go" and "sequence complete" messages and bell sound. Doesn't suppress "nothing seemed to happen" with ordered ones.
  • 2 = ORDERED: If set, marks trigger as ordered, see comments on count field above.
  • 4 = ALWAYS RETURN: Supposedly buttons will stay down when the correct combination is achieved unless this flag is set, but in fact they seem to pop back anyway (sez tiglari, doesn't work for Eutectic either).
  • 8 = DEACTIVATED : if set, counter cannot start counting until it is activated by a trigger_activate entity (untested, at least by tiglari).

Back to the list.