Difference between revisions of "GetAC"

From NWN Lexicon
Jump to: navigation, search
(Created page with " =GetAC(object, int)= Retrieves the AC (armor class) of a creature. int  GetAC(      object  oObject,      int  nFo...")
 
Line 7: Line 7:
 
Retrieves the AC (armor class) of a creature.
 
Retrieves the AC (armor class) of a creature.
  
 +
<nwscript>
 
  [[int | int ]] GetAC(
 
  [[int | int ]] GetAC(
 
      [[object | object ]] oObject,
 
      [[object | object ]] oObject,
 
      [[int | int ]] nForFutureUse = 0
 
      [[int | int ]] nForFutureUse = 0
 
  );
 
  );
 +
</nwscript>
  
 
====Parameters====
 
====Parameters====
Line 42: Line 44:
 
====Example====
 
====Example====
  
<font color="#007f00">// this script can simulate an attack triggered when a door or  
+
<nwscript>
  </font><font color="#007f00">// placeable is opened.   
+
// this script can simulate an attack triggered when a door or  
  </font><font color="#007f00">// this script rolls a d20 and checks the results against the  
+
  // placeable is opened.   
  </font><font color="#007f00">// person's AC; if the die roll is at least the AC of the target it  
+
  // this script rolls a d20 and checks the results against the  
  </font><font color="#007f00">// does d10 damage (kind of a very unfair trap that can't be
+
  // person's AC; if the die roll is at least the AC of the target it  
  </font><font color="#007f00">// searched for or disabled).
+
  // does d10 damage (kind of a very unfair trap that can't be
  </font>main()
+
  // searched for or disabled).
 +
  main()
 
  {
 
  {
     <font color="#0000ff">object</font> oPC = GetLastOpenedBy();
+
     object oPC = GetLastOpenedBy();
     <font color="#0000ff">int</font> nDieRoll = d20();
+
     int nDieRoll = d20();
     <font color="#0000ff">if</font> (nDieRoll &gt;= GetAC(oPC)) {
+
     if (nDieRoll &gt;= GetAC(oPC)) {
       <font color="#0000ff">effect</font> eDamage = EffectDamage(d10(), DAMAGE_TYPE_PIERCING);
+
       effect eDamage = EffectDamage(d10(), DAMAGE_TYPE_PIERCING);
 
       ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
 
       ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
 
     }
 
     }
 
  }
 
  }
 +
</nwscript>
  
 
====See Also====
 
====See Also====

Revision as of 20:37, 25 August 2012



GetAC(object, int)

Retrieves the AC (armor class) of a creature.

 [[int | int ]] GetAC(
     [[object | object ]] oObject,
     [[int | int ]] nForFutureUse = 0
 );

Parameters

oObject

The object to get the AC of.

nForFutureUse

Parameter reserved for future use and currently does nothing. (Default: 0)


Description

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.



Remarks

This shouldn't get any AC-versus bonuses - EG: Protection Against Evil grants +2 deflection AC against evil-only people, or AC verus a specific damage 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.


Version

1.28

Example

 // 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).
 main()
 {
    object oPC = GetLastOpenedBy();
    int nDieRoll = d20();
    if (nDieRoll &gt;= GetAC(oPC)) {
       effect eDamage = EffectDamage(d10(), DAMAGE_TYPE_PIERCING);
       ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
    }
 }

See Also

functions: 

GetItemACValue



 author: Tom Cassiotis, editor: Jasperre