SpellLingeringScripts
This hook is run at the end of spell processing. It is designed to help implement spells such as 'Dispell Magic', which remove the effects of previous spells.
For the sake of simplicity, we will describe this function for very particular spells so that the terminology does not get reduced to 'Party of the First Part' and such nonsense.
- The combatant who cast the spell which created the lingering Spell Effects. We will use the word 'Creator' to refer to this combatant.
- The combatant who cast a spell which will examine the lingering Spell Effects and perhaps cancel them. We will use the word 'Destroyer' to refer to this combatant.
Let us say we have a spell called 'Vinyard' that causes lingering spell effects:
- Grape Vine graphics over an area of the combat screen
- Blockages – preventing movement within the affected area
Let us say we have a spell called 'Grape Wilt' that kills grape vines over some area. 'Susan the Souse' (the creator) casts 'Vinyard', which leaves lingering effects over a large area. Along comes 'Teetotaler Theresa' (the destroyer) who casts 'Grape Wilt'. It has an area of effect and is designed to cancel the effect of 'Vinyard'.
The engine examines the spell 'Grape Wilt' and finds and runs a script called 'SpellLingeringScripts'. That script returns the name of a script that should be run for each
lingering spell effect. Let us say that it returns 'Destroy Grape Vines'. The engine then examines all the lingering effects of previously cast spells. For each such lingering effect, the engine finds the spell that caused the effect and searches for scripts by the name 'Destroy Grape Vines'. It will run such scripts with information necessary to determine whether or not 'Grape Wilt' should cancel the Spell Effect created by 'Vinyard'. Namely:
- $SpellContext() will be the spell cast by the 'Creator' – in this case the spell Vinyard.
- $AttackerContext() with be the 'Creator' combatant – in this case 'Susan the Souse'.
- $TargetContext() will be the 'Destroyer' combatant – in this case 'Teetotaler Threresa'.
- Hook Parameter[7] will be the 'Creator' spell-casting level at the time the spell was cast.
- Other Hook parameters will be unchanged from those that are defined when the script named “SpellLingeringScripts” exited ($RETURN). So, assuming that “SpellLingeringScripts does not change them, HookParameter[5] is the the name of the 'Destroyer' spell and HookParameter[6] is the level of the 'Destroyer'
In our example, we will assume that 'Vinyard' has Special Ability with a script named 'Destroy Grape Vines'. That script will run in the Context of the spell 'Vinyard' with hookParameter[5] set to “Grape Wilt” and can return a value:
- “AREA” which will cause the lingering effects of the spell 'Vinyard' to be deleted in the area of effect of the spell 'Grape Wilt'
- “ALL” which will cause all lingering effects of 'Vinyard' to be removed.
- “TARGETS” which will cause lingering effects of 'Vinyard' to be removed at the location of each combatant within the area of 'Grape Wilt's effect.
Parameters
Parameter [5] = name of the spell cast by the 'Destroyer'
Parameter [6] = Destroyer's spell-casting level at the time spell is cast
Parameter [7] = Creator's spell-casting level at the time spell is cast
Context
spell – The spell being cast
Note:
The 'spell-casting levels' are determined firstly by the magic-school of the spell being cast. Magic User spells use the Magic-User level and the Cleric spells use the Cleric level. These can be overridden at the time the spell is cast by using the hook “SpellCasterLevel”.