LoopSpell - TheComputerGeek2/MagicSpells GitHub Wiki

Source Code

spell-class: ".targeted.LoopSpell"

targeting cast argument values:

Value Supported
entity true
location true
entity_from_location false

Spell Effect Positions:

  • delayed - Plays the effect at the loop's location when the loop ends.

Description:

The LoopSpell allows for the caster to repeatedly cast spells at either a target, the target's location or their own location for some duration of time and a certain amount of iterations. The LoopSpell can also be used without a target or location if the targeted option is set to false.

Configuration:

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

Option Description Type Default Supports expressions
delay Defines how long, in ticks, before the loop starts. Since 4.0 Beta 13: With negative values, the iterations are done immediately, instead of at the beginning of the next tick. Long 0 true
duration Defines how long, in ticks, the loop will last. If less than or equal to 0, the loop will last indefinitely unless iterations are specified. Long 0 true
interval Defines how long, in ticks, the interval between casting the spells. Since 4.0 Beta 13: When <=0, all of the iterations of the loop are done at once. Long 20 true
iterations Defines how many total iterations the loop will do. If less than or equal to 0, the loop will last indefinitely unless duration is specified. Integer 0 true
y-offset Vertical offset when casting at a location Double 0 true
targeted If true, depending on require-entity-target and point-blank, the loop will target an entity or location. If false, spells will be cast without an entity or location target. Boolean true true
point-blank If true and require-entity-target, the loop will target the initial location of the caster. Boolean false true
stop-on-fail If true, if a spell fails to cast, the loop will stop. Boolean false true
only-count-on-success If true, an iteration of the loop only counts towards iterations if all of the subspells in spells succeed. Boolean false true
pass-targeting If true, the spell's can-target list will be passed down to targeted entity spells in spells when casting. Boolean true true
cancel-on-death If true, dying will cancel the loop. Will always cancel if targeting a non-player entity. Boolean false true
require-entity-target If true, targets an entity for the loop. Boolean false true
cast-random-spell-instead If true, the loop will instead randomly cast one spell in spells each iteration. Boolean false true
skip-first If true, skips loop-modifiers, variable-mods-loop, loop-target-modifiers, loop-location-modifiers and variable-mods-target-loop on the first iteration of the loop. Boolean false true
skip-first-loop-modifiers If true, skip loop-modifiers on the first iteration of the loop. Uses the value of skip-first as its default. Boolean skipFirst true
skip-first-variable-mods-loop If true, skip variable-mods-loop on the first iteration of the loop. Uses the value of skip-first as its default. Boolean skipFirst true
skip-first-loop-target-modifiers If true, skip loop-target-modifiers on the first iteration of the loop. Uses the value of skip-first as its default. Boolean skipFirst true
skip-first-loop-location-modifiers If true, skip loop-location-modifiers on the first iteration of the loop. Uses the value of skip-first as its default. Boolean skipFirst true
skip-first-variable-mods-target-loop If true, skip variable-mods-target-loop on the first iteration of the loop. Uses the value of skip-first as its default. Boolean skipFirst true
str-fade-self Message sent to the caster when the loop ends. Rich Text true
str-fade-target Message sent to the target when the loop ends. Rich Text true
spell-on-end Sub-spell casted when the loop ends. String false
spells List of sub-spells casted on each iteration of the loop. String List false
variable-mods-loop List of variable modifications performed on the caster on each iteration of the loop. Performed before loop-modifiers and loop-target-modifiers are checked. String List false
variable-mods-target-loop List of variable modifications performed on the target on each iteration of the loop. Performed before loop-modifiers and loop-target-modifiers are checked. String List false
loop-modifiers List of modifiers checked at the beginning of each iteration of the loop. Checked after variable-mods-loop and variable-mods-target-loop are performed. String List false
loop-target-modifiers List of target modifiers checked at the beginning of each iteration of the loop. Checked after variable-mods-loop and variable-mods-target-loop are performed. String List false
loop-location-modifiers List of location modifiers checked at the beginning of each iteration of the loop. Checked after variable-mods-loop and variable-mods-target-loop are performed. String List false

Example:

Strikes targeted entity with lightning for up to 200 ticks (10 seconds). If the entity dies before the duration of the LoopSpell ends, the loop will cancel.

PerpetualLightning:
    spell-class: ".targeted.LoopSpell"
    delay: 10
    duration: 200
    require-entity-target: true
    cancel-on-death: true
    str-fade-self: "The foe has been slain, thus the lightning strikes cease."
    spells: 
        - lightning

Variable Example:

Increments a variable by 1 each time a loop occurs. When the variable reaches its maximum value, the loop ends.

variables:
    increasingvar:
          type: player
          permanent: false
          default: 0
          min: 0
          max: 10

IncreasingVariableLoop:
    spell-class: ".targeted.LoopSpell"
    require-entity-target: false
    variable-mods-loop: 
        - increasingvar +1
    str-fade-self: "The variable has reached its maximum value of %var:increasingvar%"
    spells:
        - IncreasingVarDummy(mode=full)
    loop-modifiers:
        - variable increasingvar=10 denied

IncreasingVarDummy:
    spell-class: ".targeted.DummySpell"
    target-self: true
    str-cast-self: "The current value of the variable is %var:increasingvar%"
    helper-spell: true