ItemPropertyACBonusVsSAlign(int, int)

Sets an "armor class bonus against specific alignment" itemproperty.

itemproperty ItemPropertyACBonusVsSAlign(
    int nAlign,
    int nACBonus
);

Parameters

nAlign

IP_CONST_ALIGNMENT_*

nACBonus

AC bonus to add; 1 to 20 are valid.


Description

Sets item property AC bonus vs. specific alignment, such as Chaotic Good. You need to specify the specific alignment constant (IP_CONST_ALIGNMENT_*) and the AC bonus, which should be an integer between 1 and 20.

The type of AC bonus depends on the type of the item. Thanks to Nailog for providing this information:

Items that gain a Deflection bonus: Creature Skins, staves, rings, melee weapons, helmets, cloaks, belts, gloves, and ranged weapons that use ammunition.

Items that gain an Armor bonus: Armors and bracers.

Items that gain a Natural Armor bonus: Amulets.

Items that gain a Shield bonus: Shields.

Items that gain a Dodge bonus: Boots.



Remarks

The itemproperty commands are special constructors - they construct an itemproperty "object" which can then be applied to an item using the AddItemProperty command, much like effects need to be first constructed, then applied with ApplyEffectToObject.

It will often be a good idea to remove similar itemproperties from the item first. There's a command in the "x2_inc_itemprop" include file called IPSafeAddItemProperty which will do that for you. Check IPSafeAddItemProperty for current bug report.

The IP_CONST_ALIGNMENT_* constant can be retrieved off this type of item property using GetItemPropertySubType. The bonus can be retrieved using GetItemPropertCostTableValue.


Version

1.62

Example

#include "x2_inc_itemprop"
//The include is for the IPSafeAddItemProperty function

//Gives the entering PC's armor a +15 AC bonus against chaotic evil
void main()
{
object oPC=GetEnteringObject();
if (!GetIsPC(oPC)) return; // stop if not a PC
object oItem = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
if (!GetIsObjectValid(oItem)) return; // stop if not armor/clothing

int nAlign = IP_CONST_ALIGNMENT_CE;
int nACBonus = 15;

itemproperty ipAdd = ItemPropertyACBonusVsSAlign(nAlign, nACBonus);

IPSafeAddItemProperty(oItem, ipAdd);

// test by watching for "AC increased" at bottom of Character Record
}

See Also

functions: AddItemProperty | IPSafeAddItemProperty
categories: Item Creation Functions
constants: IP_CONST_ALIGNMENT_* Constants


 author: Lilac Soul, editor: Peter Busby, additional contributor(s): Nailog