I thought I could do this myself, but it turned out to be more complicated than I thought. I have armor that I would like to change properties to, enhance, during the game. The armor has AC Bonus +2, and I would like to change it to AC Bonus +3 ingame. I thought it wouldn’t be hard to script this, but it turned out to be beyond my knowledge. I looked at the lexcion which was somewhat helpful but…
My rough script looks like this at the moment, but it doesn’t compile yet:
void iProperty(object oObject)
{
itemproperty ipAdd = ItemPropertyACBonus(3);
AddItemProperty(DURATION_TYPE_PERMANENT, ipAdd, oCompanionArmor);
}
void main()
{
object oCompanionArmor = GetObjectByTag("armor1");
itemproperty ipRemoveFeat = ItemPropertyACBonus(2);
RemoveItemProperty(oCompanionArmor,ipRemoveFeat);
DelayCommand(0.3,iProperty(oCompanionArmor));
}
Ok, so I read some more in the lexicon and I managed to fix this somewhat. Now the script looks like this instead, and it compiles:
#include "x2_inc_itemprop"
void main()
{
object oCompanionArmor = GetObjectByTag("armor1");
itemproperty ipAdd=ItemPropertyACBonus(3);
if (GetIsObjectValid(oCompanionArmor))
{
IPSafeAddItemProperty(oCompanionArmor, ipAdd);
}
}
Still, since the armor already has AC Bonus +2, I’d like to remove that first. I’ll read some more and see what I can come up with.
Edit: If I read the lexicon correctly and inerpret the IPSafeAddItemProperty correctly, I shouldn’t need to remove the first AC Bonus, since that function already does that. Alright, time to test it ingame, I guess. I hope this works in NWN2, so there’s no bugs regarding this when it comes to that.
Amazing! It seems to work.
2 Likes
I have a number of items I’ve posted that change attributes including armor sets that change attributes based on which pieces are equipped and weapons that can change form (Rod of Lordly Might and others). Look at some of Silverwand items for scripts.
1 Like