Zone Template Triggers - torilmud/docs GitHub Wiki

Zone Template Triggers

Zone triggers allow you to execute a list of command based on some kind of event occurring in the zone. Any zone command can be executed by a trigger. These triggers are a great way to create dynamic events in zones.

Triggers are stored in the .tpl zone template files. See the documentation for zone templates for more information.

Example

The following trigger will load NPC 98305 whenever NPC 98301 is killed in the zone. It will only go off once every 10 seconds.

  {
      "trigger": "NPC Death",
      "npcVnum": 98301,
      "resetTime": 40,
      "commands": [
        {
          "command": "load npc",
          "vnum": 98305,
          "room": 98301,
          "delay": 4
        }
      ]
    }

Trigger fields

The following triggers are common throughout most triggers. See the individual trigger documentation below for examples and trigger-specific fields.

  • trigger: The type of trigger.
  • resetTime (optional): The amount of time in pulses (1/4th of a second) before this trigger can reset after being activated.
  • chance (optional): The percentage chance for this trigger to activate when triggered.
  • roomFilter (optional): Only activate if the event takes place in a room that matches this filter. Uses the standard room target field.
  • npcVnum: The vnum of the NPC to trigger on.
  • itemVnum: The vnum of the item to trigger on.
  • roomVnum: The vnum of the room to trigger on.
  • squadVnum: The vnum of the squad to trigger on.

Trigger: NPC Death

Trigger off an NPC's death.

{
      "trigger": "NPC Death",
      "npcVnum": 98301,
      "commands": [
        {
          "command": "message",
          "text": "---> Trigger activated"
        }
      ]
    }

Trigger: NPC Clear

Trigger when all NPCs have been cleared from the zone or rooms matching the filter.

{
      "trigger": "NPC Clear",
      "npcVnum": 98301,
      "roomFilter": {
        "sector": "forest"
      },
      "commands": [
        {
          "command": "message",
          "text": "---> Trigger activated"
        }
      ]
    }

Trigger: NPC Health

Trigger when an NPC's health hits a certain percentage. Note that this will only fire one time per percetange, regardless of the NPC healing.

  • value: The percentage value to trigger off of. Only multiples of 5 are accepted.

This example will trigger when NPC 98301 hits 50% health for the first time:

{
      "trigger": "NPC Health",
      "npcVnum": 98301,
      "value": 50,
      "commands": [
        {
          "command": "message",
          "text": "---> Trigger activated"
        }
      ]
    }

Trigger: Squad Death

Trigger off a squad's death.

{
      "trigger": "Squad Death",
      "squadVnum": 98301,
      "commands": [
        {
          "command": "message",
          "text": "---> Trigger activated"
        }
      ]
    }

Trigger: Squad Clear

Trigger when all squad members have been cleared from the zone or rooms matching the filter.

{
      "trigger": "Squad Clear",
      "squadVnum": 98301,
      "roomFilter": {
        "sector": "desert"
      },
      "commands": [
        {
          "command": "message",
          "text": "---> Trigger activated"
        }
      ]
    }

Trigger: Room Clear

Trigger when all NPCs have been cleared from the rooms matching the filter.

This example will trigger when all NPCs are cleared from 98300, 98325, and 98375.

{
      "trigger": "Room Clear",
      "roomFilter": {
        "vnums": [98300, 98325, 98375]
      },
      "commands": [
        {
          "command": "message",
          "text": "---> Trigger activated"
        }
      ]
    }

Trigger: PC Death

Trigger off of a PC's death either in the whole zone or rooms matching the filter.

The following will trigger whenever a PC dies in a room set to subzone 2.

{
      "trigger": "PC Death",
      "roomFilter": {
        "subzone": 2
      },
      "commands": [
        {
          "command": "message",
          "text": "---> Trigger activated"
        }
      ]
    }

Trigger: PC Use Power

Trigger off of a PC using a specific power anywhere in the zone or in a room matching the filter.

  • name: The name of the power to trigger off of.

This example will trigger whenever a PC uses the power Ice Storm in a room between 98325 and 98330.

{
      "trigger": "PC Use Power",
      "name": "Ice Storm",
      "roomFilter": {
        "vnumStart": 98325,
        "vnumEnd": 98330
      },
      "commands": [
        {
          "command": "message",
          "text": "---> Trigger activated"
        }
      ]
    }

Trigger: PC Enter Room

Triggers whenever a PC enters the specified room.

{
      "trigger": "PC Enter Room",
      "roomVnum": 98350,
      "commands": [
        {
          "command": "message",
          "text": "---> Trigger activated"
        }
      ]
    }

Trigger: Take Item

Triggers whenever a PC takes an item from a room matching the filter.

This example will trigger when item 98301 is taken from room 98325.

{
      "trigger": "Take Item",
      "itemVnum": 98301,
      "roomFilter": {
        "vnum": 98325
      },
      "commands": [
        {
          "command": "message",
          "text": "---> Trigger activated"
        }
      ]
    }

Trigger: Drop Item

Triggers whenever a PC drops an item in a room matching the filter.

This example will trigger when item 98301 is dropped in a forest sector room.

{
      "trigger": "Drop Item",
      "itemVnum": 98301,
      "roomFilter": {
        "sector": "forest"
      },
      "commands": [
        {
          "command": "message",
          "text": "---> Trigger activated"
        }
      ]
    }

Trigger: Exit Change

Triggers whenever an exit flag is changed to the matching state.

This example will trigger whenever the south exit in 98325 is opened.

Current allowed states are: open, close, lock, unlock.

{
      "trigger": "Exit Change",
      "state": "open",
      "exit": "south",
      "roomVnum": 98325,
      "commands": [
        {
          "command": "message",
          "text": "---> Trigger activated"
        }
      ]
    }