Difference between revisions of "GetAC"

From NWN Lexicon
Jump to: navigation, search
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
+
{{DISPLAYTITLE:GetAAC(object, int)}}__NOTOC__
 
 
 
 
 
 
=GetAC(object, int)=
 
 
 
 
Retrieves the AC (armor class) of a creature.
 
Retrieves the AC (armor class) of a creature.
 
 
<nwscript>
 
<nwscript>
[[int | int ]] GetAC(
+
int GetAC(
    [[object | object ]] oObject,
+
    object oObject,
    [[int | int ]] nForFutureUse = 0
+
    int nForFutureUse = 0
);
+
);
 
</nwscript>
 
</nwscript>
 
 
====Parameters====
 
====Parameters====
  
''oObject''
+
;oObject
 +
:The object to get the AC of.
  
The object to get the AC of.
+
;nForFutureUse
 +
:Parameter reserved for future use and currently does nothing. (Default: 0)
  
''nForFutureUse''
+
====Description====
  
Parameter reserved for future use and currently does nothing. (Default: 0)
+
Returns the AC (armor class) of oObject if it is a creature.
  
<br />
+
Returns 0 if oObject is an item, door, or placeable.
  
====Description====
+
Returns -1 if oObject is not a creature, item, door, or placeable.
  
Returns the AC (armor class) of oObject if it is a creature. <br /><br /> Returns 0 if oObject is an item, door, or placeable. <br /> Returns -1 if oObject is not a creature, item, door, or placeable. <br /><br /> nForFutureUse is not in use, and should not be changed.
+
nForFutureUse is not in use, and should not be changed.
  
<br /><br />
+
====Remarks====
  
====Remarks====
+
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.
  
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. <br /><br /> 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. <br /><br /> 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.
+
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.
  
<br />
+
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====
 
====Version====
Line 45: Line 40:
  
 
<nwscript>
 
<nwscript>
// this script can simulate an attack triggered when a door or  
+
// this script can simulate an attack triggered when a door or  
// placeable is opened.   
+
// placeable is opened.   
// this script rolls a d20 and checks the results against the  
+
// 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  
+
// 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
+
// does d10 damage (kind of a very unfair trap that can't be
// searched for or disabled).
+
// searched for or disabled).
main()
+
main()
{
+
{
    object oPC = GetLastOpenedBy();
+
  object oPC = GetLastOpenedBy();
    int nDieRoll = d20();
+
  int nDieRoll = d20();
    if (nDieRoll &gt;= GetAC(oPC)) {
+
  if (nDieRoll >= GetAC(oPC)) {
      effect 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>
 
</nwscript>
  
Line 67: Line 62:
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
 
|
 
|
[[ GetItemACValue  | GetItemACValue ]]
+
[[GetItemACValue]]
 
|-
 
|-
 
|}
 
|}

Latest revision as of 22:39, 1 August 2020

Retrieves the AC (armor class) of a creature.

int GetAC(
    object oObject,
    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 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.

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 >= GetAC(oPC)) {
      effect eDamage = EffectDamage(d10(), DAMAGE_TYPE_PIERCING);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
   }
}

See Also

functions: 

GetItemACValue



 author: Tom Cassiotis, editor: Jasperre