Does Attack Succeed

Immediately after rolling the HitDice and computing thac0 we search for Special Ability scripts in the following order:

  1. The attacking Combatant

  2. The attacking Character

  3. The target Combatant

  4. The Target Character

  5. The item (weapon) used in the attack

  6. The Attacking Character's Class

  7. The Attacking Character's Race

  8. The Target Character's Class

  9. The Target Character's Race

  10. If the target is a monster then the monster type of the target.


So we do 10 'Searches'. Each search can result in zero or more scripts being executed.


We look for scripts named DoesAttackSucceed.

All of the searches are executed in the order listed above. If any of these 'search lists' has multiple scripts with the name “DoesAttackSucceed” then they are run in an undefined order and the result of the last one will be used, even if it is an empty string.

The scripts are free to use hook parameters to pass information from one script to the next. All hook parameters not specified in the 'Parameters” discussion (below) begin as empty strings.

The result of each search that returns a non-empty string is saved. The result of the last search that returns a non-empty string is used as follows:


Parameters

The script has access to two parameters:

Parameter 5 = the value determined by the HitDice

Parameter 6 = The computed thac0

These parameters may be fetched using the $GET_HOOK_PARAM(n) , where n is 5 or 6.


Hook Parameter [0] contains the result of the preceding script.

Context


Example of use


Let us provide "Stainless Armor" that prevents attacks from non-magical weapons.

We give all magical weapons a Special Ability named "Magical".

We give "Stainless Armor" a Special Ability named "Physically Impervious".

We write a script for "Physically Impervious" named OnReadyArmor and, when the "Stainless Armor" is readied, the script gives the wearer a Special Ability named "Physically Impervious".

We attach a script named DoesAttackSucceed to the Special Ability "Physically Impervious". This script looks at the attack weapon and, if it does not have the Special Ability "Magical", then it returns "N", thereby causing the attack to fail.

So here is what happens when a character wearing "Stainless Armor" is attacked with a "Club":

An attack is made with a Club.

We search the target combatant and find a Special Ability named "Physically Impervious".

We search the Special Ability for a script named "DoesAttackSucceed".

We run the script with 'Club' as the weapon parameter.

The script examines 'Club' for a Special Ability named "Magical". None is found so the script returns "N", causing the attack to fail.

To attempt to say it one more time in a slightly different way......The Special Ability named "Physically Impervious" has a script named "DoesAttackSucceed" which allows the attack to succeed only if the weapon being used is 'Magical'.