Skip to content

๐Ÿ’ฅ Triggers โ€‹

When using MMOItems or MMOCore, you will need to specify when a specific skill should be executed: when damaging an entity, when being damaged, when crouching etc. This is done using triggers. MMOItems used to call them casting modes.

Available Triggers โ€‹

These are the trigger types that you can use in MMO plugins to define when some skill is supposed to run.

Combat & Damage โ€‹

Skill TriggerDescriptionTarget EntityTarget Block
KILL_ENTITYActivates the skill when a player kills an entityThe killed entity-
KILL_PLAYERActivates the skill when a player kills an playerThe killed player-
ATTACKActivates the skill when the player attacks somethingThe entity the player attacked-
DAMAGEDActivates the skill when the player takes damage--
DAMAGED_BY_ENTITYActivates the skill when the player takes damage from an entityThe entity that damaged the player-
DEATHActivates the skill when the player dies--

Projectiles โ€‹

Skill TriggerDescriptionTarget EntityTarget Block
SHOOT_TRIDENTWhen the player shoots a tridentThe projectile-
TRIDENT_TICKActivates every tick when a trident is still midairThe projectile-
TRIDENT_LANDWhen a trident lands on the groundThe projectile-
TRIDENT_HITWhen a thrown trident hits an entityThe hit entity-
SHOOT_BOWWhen the player fires an arrowThe projectile-
ARROW_TICKActivates every tick when an arrow is still midairThe projectile-
ARROW_LANDWhen an arrow lands on the groundThe projectile-
ARROW_HITWhen a fired arrow hits an entityThe hit entity-

Player Clicks โ€‹

Skill TriggerDescriptionTarget EntityTarget Block
RIGHT_CLICKOn player right click--
LEFT_CLICKOn player left click--
SHIFT_RIGHT_CLICKOn player right click while sneaking--
SHIFT_LEFT_CLICKOn player left click while sneaking--

Blocks โ€‹

Skill TriggerDescriptionTarget EntityTarget Block
BREAK_BLOCKWhen a player breaks a block-Location of mined block
PLACE_BLOCKWhen a player places a block-Located of placed block

MMOCore Triggers โ€‹

These triggers are only available when MMOCore is installed. If you try to use them without MMOCore installed, you will run into errors.

Skill TriggerDescriptionTarget EntityTarget Block
ENTER_COMBATActivates skills when a player enters combat.--
QUIT_COMBATActivates skills when a player quits combat.--

Items โ€‹

Skill TriggerDescriptionTarget EntityTarget Block
DROP_ITEMActivates the skill when a player press QThe dropped item-
SHIFT_DROP_ITEMActivates the skill when a player press Shift + QThe dropped item-
SWAP_ITEMSActivates the skill when a player press F--
SHIFT_SWAP_ITEMSActivates the skill when a player press Shift + F--
EQUIP_ARMORActivates the skill when a player enquip armorThe player-
UNEQUIP_ARMORActivates the skill when a player unenquip armorThe player-

Miscellaneous โ€‹

Skill TriggerDescriptionTarget EntityTarget Block
LOGINActivates the skill when a player logins--
SNEAKActivates the skill when a player sneaks--
TELEPORTActivates the skill when a player teleport-The target teleport location
TIMERCasts the skill every X ticks--

When a skill/script is triggered โ€‹

Some trigger types pass on special properties to the script/skill they trigger. For instance; when using the ATTACK trigger type:

  • The <target> internal variable can be used to access the entity being damaged,
  • The <attack> internal variable returns metadata about the current attack,
  • <attack.damage> returns the attack damage.

Trigger types featuring entities/projectiles like ATTACK, DAMAGED, DAMAGED_BY_ENTITY, KILL_ENTITY, SHOOT_TRIDENT, ARROW_TICK etc. allow the user to use the <target> internal variable to access the shot projectile. These triggers also unlock the use of entity and location targeters such as target and target_location.

Trigger types featuring world locations like TRIDENT_LAND or ARROW_HIT unlock the target_location location targeter as well as the <target_location> internal variable.

Some triggers like TIMER or RIGHT_CLICK do not unlock any additional internal variable.

ATTACK is the only trigger type which unlocks the <attack> internal variable as well as special mechanics (multiply_damage) or conditions (has_damage_type).

Custom Triggers โ€‹

MythicLib allows users to define their own triggers and manually call them. This is a complex - yet super powerful - functionality that adds another layer of configurability on top of existing skills.

Defining custom triggers โ€‹

You can define custom triggers inside the MythicLib/triggers.yml configuration file. Note that this file only contains user-defined triggers, as the triggers presented above are hard-coded and cannot be edited.

yml
# Triggered on weapon crits
# Corresponding on-hit effect: on_hit_effects/weapon_crits
# Call in script:              script/on_hit_effects.yml>weapon_crit_script
CRIT:

  # When set to false, send messages to the player
  # when skills cannot cast due to them being on cooldown,
  # missing mana/stamina....
  silent: true

# Triggered on special mage abilities
MAGE_BURN:
  silent: true

Calling custom triggers โ€‹

You can call custom triggers from inside a MMOLib script using the call_trigger mechanic. "Calling a trigger" refers to casting all the skills of a given player with matching trigger. For instance, on all player/mob attacks, MMOLib calls the ATTACK trigger under the hood.

Let's take the built-in weapon crits as an example. We would like to create a skill trigger, that gets called whenever a player performs a weapon critical strike while attacking.

The following code snippet is taken from the default MythicLib/script/on_hit_effects.yml file, which defines the behavior of weapon crits.

yml
# Called to check if weapon crits may apply
weapon_crit_script_check:
  conditions:
    - 'has_damage_type{types="weapon,unarmed"}'

# Called when a weapon crit occurs
weapon_crit_script:
  mechanics:
    - 'set_double{var=crit_coef;val="<stat.critical_strike_power> / 100"}'
    - 'multiply_damage{scalar="<crit_coef>";dtype=WEAPON}'
    - 'multiply_damage{scalar="<crit_coef>";dtype=UNARMED}'
    - 'mark_crit{dtype="WEAPON,UNARMED"}'
    - 'call_trigger{trigger=crit}'
    # [...]

As you can see, when the weapon_crit_script script is called (i.e when a weapon crit occurs), the script eventually uses the call_trigger mechanic to call the CRIT user-defined skill trigger, that we defined earlier. This has the effect of casting all the caster's skills with trigger set to CRIT.

WARNING

You can use the call_trigger mechanic to call ANY trigger, not only user-defined triggers. This can be used to create more complex behaviors like on-hit skill triggers, though it is the user's responsibility to make sure the proper skill metadata arguments are provided when calling built-in skill triggers.

Disabling user-defined triggers โ€‹

This feature is quite hard to comprehend - if you wish to disable this feature altogether, simply comment out/delete the content of the triggers.yml file. Do not delete the config file itself, otherwise it will regenerate with its default content.

Powered by VitePress