Skip to content

Commit

Permalink
Merge pull request #1036 from myk002/myk_item_trigger
Browse files Browse the repository at this point in the history
reinstate modtools/item-trigger
  • Loading branch information
myk002 authored Mar 12, 2024
2 parents 39c4723 + 2a5f715 commit d4595d3
Show file tree
Hide file tree
Showing 3 changed files with 342 additions and 388 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Template for new versions:
- `agitation-rebalance`: alter mechanics of irriation-related attacks so they are less constant and are more responsive to recent player bahavior
- `fix/stuck-worship`: fix prayer so units don't get stuck in uninterruptible "Worship!" states
- `instruments`: provides information on how to craft the instruments used by the player civilization.
- `modtools/item-trigger`: (reinstated) modder's resource for triggering scripted content when specific items are used

## New Features
- `gui/settings-manager`: add import, export, and autoload for work details
Expand Down
165 changes: 95 additions & 70 deletions docs/modtools/item-trigger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,98 @@ modtools/item-trigger

.. dfhack-tool::
:summary: Run DFHack commands when a unit uses an item.
:tags: unavailable

This powerful tool triggers DFHack commands when a unit equips, unequips, or
attacks another unit with specified item types, specified item materials, or
specified item contaminants.

Arguments::

-clear
clear all registered triggers
-checkAttackEvery n
check the attack event at least every n ticks
-checkInventoryEvery n
check inventory event at least every n ticks
-itemType type
trigger the command for items of this type
examples:
ITEM_WEAPON_PICK
RING
-onStrike
trigger the command on appropriate weapon strikes
-onEquip mode
trigger the command when someone equips an appropriate item
Optionally, the equipment mode can be specified
Possible values for mode:
Hauled
Weapon
Worn
Piercing
Flask
WrappedAround
StuckIn
InMouth
Pet
SewnInto
Strapped
multiple values can be specified simultaneously
example: -onEquip [ Weapon Worn Hauled ]
-onUnequip mode
trigger the command when someone unequips an appropriate item
see above note regarding 'mode' values
-material mat
trigger the command on items with the given material
examples
INORGANIC:IRON
CREATURE:DWARF:BRAIN
PLANT:OAK:WOOD
-contaminant mat
trigger the command for items with a given material contaminant
examples
INORGANIC:GOLD
CREATURE:HUMAN:BLOOD
PLANT:MUSHROOM_HELMET_PLUMP:DRINK
WATER
-command [ commandStrs ]
specify the command to be executed
commandStrs
\\ATTACKER_ID
\\DEFENDER_ID
\\ITEM_MATERIAL
\\ITEM_MATERIAL_TYPE
\\ITEM_ID
\\ITEM_TYPE
\\CONTAMINANT_MATERIAL
\\CONTAMINANT_MATERIAL_TYPE
\\CONTAMINANT_MATERIAL_INDEX
\\MODE
\\UNIT_ID
\\anything -> \anything
anything -> anything
:tags: dev

This powerful tool triggers DFHack commands when a unit equips or unequips
items or attacks another unit with specified item types, specified item
materials, or specified item contaminants.

Usage
-----

::

modtools/item-trigger [<options>] --command [ <command> ]

At least one of the following options must be specified when registering a
trigger: ``--itemType``, ``--material``, or ``--contaminant``.

Options
-------

``--clear``
Clear existing registered triggers before adding the specified trigger. If
no new trigger is specified, this option just clears existing triggers.

``--checkAttackEvery <n>``
Check for attack events at least once every n ticks.

``--checkInventoryEvery <n>``
Check for inventory events at least once every n ticks.

``--itemType <type>``
Trigger the command for items of this type (as specified in the raws).
Examples::

ITEM_WEAPON_PICK
RING

``--material <mat>``
Trigger the command on items with the given material. Examples::

INORGANIC:IRON
CREATURE:DWARF:BRAIN
PLANT:OAK:WOOD

``--contaminant <mat>``
Trigger the command for items with a given material contaminant. Examples::

INORGANIC:GOLD
CREATURE:HUMAN:BLOOD
PLANT:MUSHROOM_HELMET_PLUMP:DRINK
WATER

``--onStrike``
Trigger the command on appropriate weapon strikes.

``--onEquip <mode>``
Trigger the command when someone equips an appropriate item. Optionally,
the equipment mode can be specified. Possible values for mode::

Hauled
Weapon
Worn
Piercing
Flask
WrappedAround
StuckIn
InMouth
Pet
SewnInto
Strapped

Multiple values can be specified simultaneously. Example::

-onEquip [ Weapon Worn Hauled ]

``--onUnequip <mode>``
Trigger the command when someone unequips an appropriate item. Same mode
values as ``--onEquip``.

``--command [ <commandStrs> ]``
Specify the command to be executed. The following tokens can be used in the
command and they will be replaced with appropriate values::

\\ATTACKER_ID
\\DEFENDER_ID
\\ITEM_MATERIAL
\\ITEM_MATERIAL_TYPE
\\ITEM_ID
\\ITEM_TYPE
\\CONTAMINANT_MATERIAL
\\CONTAMINANT_MATERIAL_TYPE
\\CONTAMINANT_MATERIAL_INDEX
\\MODE
\\UNIT_ID
\\anything -> \anything
anything -> anything
Loading

0 comments on commit d4595d3

Please sign in to comment.