public static void ProcessVersion6RemoveACFromItem(NWItem item) { // Start by pulling the custom AC off the item and halving it. // Durability is +1 for every 2 AC on the item. int amount = item.CustomAC / 2; if (amount > 0) { float newMax = DurabilityService.GetMaxDurability(item) + amount; float newCurrent = DurabilityService.GetDurability(item) + amount; DurabilityService.SetMaxDurability(item, newMax); DurabilityService.SetDurability(item, newCurrent); } item.CustomAC = 0; // Check all item properties. If the IP is a component Armor Class Bonus, remove it and replace with an increase to durability. foreach (var ip in item.ItemProperties) { if (_.GetItemPropertyType(ip) == (int)CustomItemPropertyType.ComponentBonus) { // Check the sub-type. If it's AC, then do the replacement. if (GetItemPropertySubType(ip) == (int)ComponentBonusType.ACUp) { amount = GetItemPropertyCostTableValue(ip) / 2; // Grant the durability up property if amount > 0 if (amount > 0) { // Unpack the IP we're working with. Adjust its type and value, then reapply it. var unpacked = NWNXItemProperty.UnpackIP(ip); unpacked.SubType = (int)ComponentBonusType.DurabilityUp; unpacked.CostTableValue = amount; var packed = NWNXItemProperty.PackIP(unpacked); BiowareXP2.IPSafeAddItemProperty(item, packed, 0.0f, AddItemPropertyPolicy.IgnoreExisting, true, true); } _.RemoveItemProperty(item, ip); } } } }
private static void ProcessVersion6_ComponentBonuses(NWItem item, ItemProperty ip) { // Component Bonuses if (_.GetItemPropertyType(ip) == ItemPropertyType.ComponentBonus) { // +AC Component Bonus if (GetItemPropertySubType(ip) == (int)ComponentBonusType.ACUp) { int amount = GetItemPropertyCostTableValue(ip) / 2; // Grant the durability up property if amount > 0 if (amount > 0) { // Unpack the IP we're working with. Adjust its type and value, then reapply it. var unpacked = NWNXItemProperty.UnpackIP(ip); unpacked.SubType = (int)ComponentBonusType.DurabilityUp; unpacked.CostTableValue = amount; var packed = NWNXItemProperty.PackIP(unpacked); BiowareXP2.IPSafeAddItemProperty(item, packed, 0.0f, AddItemPropertyPolicy.IgnoreExisting, true, true); } _.RemoveItemProperty(item, ip); } } }