GetAC(object, int)

From NWN Lexicon
Jump to: navigation, search

Retrieves the AC (armor class) of a creature.

int GetAC(
    object oObject,
    int nForFutureUse = 0


The object to get the AC of.
Parameter reserved for future use and currently does nothing. (Default: 0)


Returns the AC (armor class) of oObject if it is a creature.

Returns 0 if oObject is an item, door, or placeable.

Returns -1 if oObject is not a creature, item, door, or placeable.

nForFutureUse is not in use, and should not be changed.


This doesn't get any AC-versus bonuses - EG: Protection Against Evil grants +2 deflection AC against evil-only people, and doesn't get AC versus a specific damage type or racial type.

It will, in reality, return the exact AC value on the character sheet - this does not include versus-bonuses, and is the "AC versus all" of the character.

Doors, Placeables can be attacked, and do actually have an AC of 0, because only a critical miss (Getting a 1 on a d20) will miss it.

For those that really wondered, nForFutureUse in the toolset beta was named "nVersusType" with the default value RACIAL_TYPE_ALL. It presumably was able to retrieve AC including the VersusRacialTypeEffect and maybe VersusAlignmentEffect properties. Until NWN:EE and the introduction of GetEffectInteger these properties are difficult to work out, so it's a shame it was never added (or perhaps, added as a oVersus like how GetIsImmune works).




// this script can simulate an attack triggered when a door or 
// placeable is opened.  
// this script rolls a d20 and checks the results against the 
// person's AC; if the die roll is at least the AC of the target it 
// does d10 damage (kind of a very unfair trap that can't be
// searched for or disabled).
   object oPC = GetLastOpenedBy();
   int nDieRoll = d20();
   if (nDieRoll >= GetAC(oPC)) {
      effect eDamage = EffectDamage(d10(), DAMAGE_TYPE_PIERCING);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);

See Also



 author: Tom Cassiotis, editor: Jasperre