Spell Lingering Scripts
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. There are two spell-casters involved and we will need to refer to them by some words:
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.
Let us say that 'Susan the Souse' (The creator) casts 'Vinyard', which leaves lingering effects over a large area.
Now 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 a Special Ability with a script named 'SpellLingeringScripts'. The engine runs that script and it 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 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 Hook parameters[6] and [7] set to the casters' levels. The script 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.
Hook Parameters for 'SpellLingeringScripts'
Hook Parameter[5] will be the name of the spell cast by the 'Destroyer' – in this case “Grape Wilt”.
Hook Parameter[6] will be the 'Destroyer's spell-casting level at the time he cast his spell.
Context for 'SpellLingeringScripts'
$SpellContext() – The spell being cast by the 'Destroyer' – in the example: 'Grape Wilt'.
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”.