PassiveSpell - TheComputerGeek2/MagicSpells GitHub Wiki

Source Code

This spell extends its options from Spell.

spell-class: ".PassiveSpell"

Description:

Passive spells are different from the rest of the spells in a way that they cannot be cast by the cast command, by cast items (clicking) or as sub-spells (by another spell like the Multi spell). Instead, Passive spells are considered as main spells, and they are only cast successfully when the listener listed in triggers happens. Only then will the Passive spell process its sub-spells listed in spells.

Based on the trigger specified the sub-spells cast can target entities that have caused them. For instance, a takedamage trigger fires whenever the caster is attacked. Attaching a pain spell with this trigger will hurt the attacker.

Configuration:

Since 4.0 Beta 13 some of these options support dynamic values through numeric or string expressions.

Option Description Type Default Supports expression
chance The likelihood that the passive spell will cast its sub-spells, in the interval [0, 100]. Float 100 true
delay The amount of time in ticks the passive spell will wait before casting spells. Integer -1 true
can-trigger Target list String List players false
ignore-cancelled Even if the trigger was cancelled, for instance through other plugins, the passive spell's sub-spells will still be cast when enabled. Boolean true false
send-failure-messages If the casting failed due to the passive's cooldown or reagents (cost) missing, this controls whether the str-on-cooldown, str-missing-reagents & str-cost should be sent. Boolean false false
cancel-default-action Cancel the event that activated this passive spell. For example, cancelling a takedamage trigger would negate the damage. Note that only triggers with the Cancellable property can be cancelled. Boolean false false
require-cancelled-event If enabled the trigger must be cancelled for the passive spell to cast its sub-spells. Boolean false false
cancel-default-action-when-cast-fails Cancels the event if the spells failed to cast. Boolean false false
triggers A list of triggers that the passive spell will attach itself to, either with the String Format Trigger or the Section Format Trigger. List false
spells A list of sub-spells to cast. Some triggers pass a targeted entity or location involved in the trigger event the spell, if targeted, would be cast on.

Note that before 4.0 Beta 14 Buff spells with targeted: false (default) and ExternalCommandSpell with require-player-target: false (default) on targeted triggers were cast on the caster instead of the target, which is no longer the case.
String List false
cast-without-target When true, any targeted spells cast by the passive are cast without a targeted entity or location, even if one is available. Boolean false false

Additional Placeholders:

  • str-on-cooldown:
    • %c: Returns rounded cooldown.

String Format Trigger:

String Format Trigger references the string after the listener is separated by a space. Some listeners have extra data which can be configured there (e.g. ticks 1).

triggers:
    # With string parameters:
    - <Listener Name> [String Parameters...]
    # Without string parameters:
    - <Listener Name>
# Example:
darkcloak:
    spell-class: ".PassiveSpell"
    triggers:
        - ticks 20
    spells:
        - darkcloak_invis
    modifiers:
        - lightlevel <7 required

An event priority can be appended to your listener's name, separated by an _ (e.g. dismount_highestpriority). This will let your server know in which order of priority to handle all event listeners (not just Passive spells, but events from other sources too).

Priority Description
lowestpriority Event call is of very low importance and should be run first, to allow other plugins to customise the outcome further.
lowpriority Event call is of low importance.
normalpriority Event call is neither important nor unimportant and may run normally.
highpriority Event call is of high importance.
highestpriority Event call is critical and must have the final say in what happens to the event.
monitorpriority Event is listened to purely for monitoring the outcome of an event.

Section Format Trigger:

Option Description Type Default
trigger Trigger name. Trigger
priority Priority in execution. Event Priority normal
. . . Per-trigger options.
# Example:
passive:
  spell-class: ".PassiveSpell"
  triggers:
    - trigger: <trigger name>
      priority: normal
      # . . .

Triggers:

⚠️ **GitHub.com Fallback** ⚠️