Adjust Saving Throws
When a character is about to affected by a spell, he is sometimes allowed to cast a saving throw to determine the extent of the spell effect. For example, if his throw succeeds, any damage might be reduced by half. These scripts allow the designer to modify the results of the saving throw by supplying a positive or negative integer to be added to the actual throw after any default adjustments have been made. There are five type of spell effects built into the engine (it is relatively easy to add others using Special Abilities or even building them into the engine) and each causes a script of a different name to be run:
Type of Spell Effect |
Script Name |
Spell |
SaveVsSp_xxx |
Paralysis / Poison / Death Magic |
SaveVsPPDM_xxx |
Petrification / Polymorph |
SaveVsPP_xxx |
Breath Weapon |
SaveVsBW_xxx |
Rod / Staff / Wand |
SaveVsRSW_xxx |
The “xxx” portion of the Script Name is determined by where the engine finds the script. This is done so that the script itself will not have to determine if it is attached to the caster or to the object of the spell. For the case of a script attached to a spell there would be no ambiguity and the “xxx” portion should not be needed. But it is included for the sake of symmetry. The engine searches the following places, in this order:
Search Location |
Value of “xxx” |
The character who cast the spell |
“Cast” |
The character performing the saving throw |
“Save” |
The spell that was cast |
“Spell” |
The monster type of the caster |
“CastMon” |
The monster type of the character performing the saving throw |
“SaveMon” |
Return Value
The script should return a number which will be added to the default saving throw. The default saving throw can be found in Hook Parameter [5].
Parameters
Hook Parameter [5] is set to the saving throw dice roll after all default adjustments have been applied. The value of this parameter is set before running the first script and the engine does not change it after that. Normally this would not be changed by the scripts. But it can be changed and the final value of Hook Parameter [5] plus the value returned by the last script that is run will be used as the final value of the “Saving Throw”.
Hook Parameter [0] is set to the result of the previous “Adjust Saving Throw” script that was run or to the empty string if it is the first script to run. So, several scripts can make adjustments by returning the value of Hook Parameter[0] plus or minus any additional adjustment. Or, of course, a script could ignore the results of previous scripts and return a value that will override all previous results.
Context
Character - the $AttackerContext of the spell caster
Character - the target - $TargetContext of the character performing the saving throw
Spell - $SpellContext of the spell that was cast