// This script is still in development and is not live in the RDG yet.
// Its purpose is to use constants stores on items to give item properties.
// This will allow us to use NWN item properties without raising the sell prices
// of the items outside of wanted goals.
//
// Note to builder this script should include a list of all variables tied to
// magic items. To allow for easy modification at a later date.

// This command will be used to add/remove item properties stored in variables
// on an item.
void AddRemoveItemEffect(object oItem, int iAddRemove = TRUE);

void RemoveItemProp(object oItem, int iItemPropertyType);

void AddRemoveItemEffect(object oItem, int iAddRemove)
    {
    itemproperty ipItem;
    int iAmount;
    if (GetLocalInt(oItem,"STR"))
        {
        iAmount = GetLocalInt(oItem,"STR");
        if (iAddRemove)
            {
            if (iAmount > 0)
                ipItem = ItemPropertyAbilityBonus(IP_CONST_ABILITY_STR,iAmount);
            else
                ipItem = ItemPropertyDecreaseAbility(IP_CONST_ABILITY_STR,iAmount);
            AddItemProperty(DURATION_TYPE_PERMANENT,ipItem,oItem);
            }
        else
            {
            if (iAmount > 0)
                RemoveItemProp(oItem,ITEM_PROPERTY_ABILITY_BONUS);
            else
                RemoveItemProp(oItem,ITEM_PROPERTY_DECREASED_ABILITY_SCORE);
            }
        }
    }

void RemoveItemProp(object oItem,int iItemPropertyType)
    {
    itemproperty ipItem = GetFirstItemProperty(oItem);
    while (GetIsItemPropertyValid(ipItem))
        {
        if (GetItemPropertyType(ipItem) == iItemPropertyType)
            RemoveItemProperty(oItem,ipItem);
        ipItem = GetNextItemProperty(oItem);
        }
    }
