Well, after going through this again today when I was actually awake I figured out I wasn't passing valid parameters to the IPSafeAddItemProperty which is why that function wasn't working. But going off Shadow's logic/example, I tested that the temp Arcane Spell Failure reduction item property applied to the armor doesn't increase its price at the stores and that a PC can logout with that temp property on the armor and get back in again with ILR turned on the server (which were my main concerns anyway).
So after realizing I really did waste my Friday night on this thing, I put together this much simplified and cleaner version a littel bit ago that doesn't rely on .2da edits or toolset blueprints. Just plugin these scripts to your module OnEquip and OnUnequip and bards in your module will not suffer arcane spell failure while wearing light armor.
//mod_onequip_bard
#include "x2_inc_itemprop"
int GetItemACBase( object oItem)
{
if( !GetIsObjectValid( oItem) || (GetBaseItemType( oItem) != BASE_ITEM_ARMOR)) return -1;
int nTorso = GetItemAppearance( oItem, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO);
string sACBase = Get2DAString( "des_crft_appear", "BaseAC", nTorso);
return StringToInt( sACBase);
}
void main()
{
object oPC = GetPCItemLastEquippedBy();
object oItem = GetPCItemLastEquipped();
if (GetLevelByclass(class_TYPE_BARD, oPC) && GetBaseItemType(oItem) == BASE_ITEM_ARMOR) { //Is this a bard equipping armor?
int iACVal = GetItemACBase(oItem);
if (iACVal > 0 && iACVal < 5) { //Only apply the Arcane Spellcasting Reduction if they equipped light armor
itemproperty ipAdd;
switch (iACVal) {
case 1: ipAdd = ItemPropertyArcaneSpellFailure(IP_CONST_ARCANE_SPELL_FAILURE_MINUS_5_PERCENT);break;
case 2: ipAdd = ItemPropertyArcaneSpellFailure(IP_CONST_ARCANE_SPELL_FAILURE_MINUS_10_PERCENT);break;
case 3: ipAdd = ItemPropertyArcaneSpellFailure(IP_CONST_ARCANE_SPELL_FAILURE_MINUS_20_PERCENT);break;
case 4: ipAdd = ItemPropertyArcaneSpellFailure(IP_CONST_ARCANE_SPELL_FAILURE_MINUS_20_PERCENT);break;
default:return;
}
IPSafeAddItemProperty(oItem, ipAdd, 999999.9, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING);
DelayCommand(0.5, SendMessageToPC(oPC, "As a Bard you suffer no increase to Arcane Spell Failure wearing this light armor."));
}
}
}
//mod_onunequ_bard
#include "x2_inc_itemprop"
int GetItemACBase( object oItem)
{
if( !GetIsObjectValid( oItem) || (GetBaseItemType( oItem) != BASE_ITEM_ARMOR)) return -1;
int nTorso = GetItemAppearance( oItem, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO);
string sACBase = Get2DAString( "des_crft_appear", "BaseAC", nTorso);
return StringToInt( sACBase);
}
void main()
{
object oPC = GetPCItemLastUnequippedBy();
object oItem = GetPCItemLastUnequipped();
if (GetLevelByclass(class_TYPE_BARD, oPC) && GetBaseItemType(oItem) == BASE_ITEM_ARMOR) {
int iACVal = GetItemACBase(oItem);
if (iACVal > 0 && iACVal < 5)
IPRemoveMatchingItemProperties(oItem, ITEM_PROPERTY_ARCANE_SPELL_FAILURE, DURATION_TYPE_TEMPORARY);
}
}
Modifié par Thayan, 21 mai 2011 - 08:04 .