• Tutorials

  • Home
  • DoesAttackSucceed

    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
    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:
    If a script returns a result containing the character 'N' then the script processing is terminated and the attack fails.
    If a script returns a result containing the character 'Y' then the script processing is terminated and the attack succeeds.
    If no script returns a 'N' or 'Y' then the attack succeeds if HitDice > thac0.

    Parameters

    Parameter [0] = result of the preceding script.
    Parameter [5] = value determined by the HitDice
    Parameter [6] = computed thac0

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

    Context

    Combatant - the attacker - $AttackerContext()
    Combatant - the target - $TargetContext()
    Item - the weapon used, if any - $ItemContext()

    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 "Physcially 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", therby 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'.