modifiers - TheComputerGeek2/MagicSpells GitHub Wiki

Description:

Modifiers allow an action to take place when a condition is met upon a spell being cast. For example, spells can require a condition to pass to be cast successfully.

Source Code

Configuration:

There are two types of modifier configurations:

  • Single - Action done based on one condition.
  • Modifier collections - Action to do based on multiple conditions. A pass condition can be specified where you can decide if the collection passes when ALL conditions pass or if ANY of the listed conditions passing is enough for the whole collection to pass. XOR defines that the collection can pass only if one of the listed conditions passes.

You can take a closer look at modifier collections on this guide, but on this page, we will only cover modifiers that are paired with a condition and an action for the condition.

Modifiers are a general spell option that contains a list of strings. Each of these strings contains a modifier, a pair with one condition and one action. The format for a modifier can be seen below. What's specified in round brackets is always required, what's specified in square brackets is only required if the condition or action expects a var value - more about these variables will be covered on the Modifier Conditions and Modifier Actions pages.

(condition) [condition var] (action) [action var]

You can specify a string to be sent to the caster of the spell if all modifiers fail to cast using the option str-modifier-failed. You can also send a string if a specific modifier fails by separating the message from the modifier with $$. Here's an example:

modifiers:
    - onground require$$You must be on the ground to cast this spell!
    # Color code supported
    - day required$$&4It must be &6day &4for this spell to cast successfully.

If you prepend the character ! (and surround the modifier string in quotes because YAML will screech at you), the condition outcome would be inverted. Say your modifier is day require. An inverted version, a condition that would only pass if it's nighttime, could be day deny and night require, but it can also be "!day require".

You might ask what the point of this is. There is a modifier action castinstead (spell) that will cast a different specified spell if the condition passes. So you could have something like day castinstead setNight.

Some conditions do not have a dualistic sibling (e.g. night and day), an inverted version of the condition. Say you configured the modifier facing to cast a spell if you're facing west - you would use facing west castinstead (spell). Now, if you want this other spell to only be cast if the caster is not facing west but some other direction, you can use "!facing west castinstead (spell)".

Conditions:

String Format Condition:

String Format Condition references the simple list of strings:

- (condition) [condition arg] (action) [action arg]

Section Format Condition:

(Not implemented yet.)

Conditions:

Operator:

When [operator] is mentioned in the ConditionVar, the following operators have to be specified:

  • Equals: = or :
  • Less than: <
  • Greater than: >

Actions:

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

Action Description Value Value supports expressions
required or require If the condition fails to pass, the spell will fail.
denied or deny If the condition passes, the spell will fail.
power or empower or multiply If the condition passes, the Spell Power will be multiplied by the amount specified in Value. Spell Power (Float) true
addpower or add If the condition passes, the amount specified in Value will be added to the current Spell Power. Spell Power (Float) true
cooldown If the condition passes, the spell's cooldown will be set to the amount specified in Value. Cooldown Seconds (Float) true
reagents If the condition passes, the spell's reagent cost quantity will be multiplied by the amount specified in Value. Multiplier (Float) true
casttime If the condition passes, the spell's cast-time will be set to the amount specified in Value. Cast Time seconds (Float) true
stop If the condition passes, no other modifiers for the spell will be processed.
continue If the condition fails to pass, no other modifiers for the spell will be processed.
cast If the condition passes, the spell specified in Value will be cast. Internal Spell Name false
castinstead If the condition passes, the spell specified in Value will be cast instead of this spell. Internal Spell Name false
variable If the condition passes, the variable modification specified in Value will be done. VarMod true
string If the condition passes, the string variable specified in Value will be set to the new value. Format: stringVar newValue. Since 4.0 Beta 14
message Since 4.0 Beta 16. If the condition passes, this sends a message to the caster. Rich Text true

Source Code

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