Adding item property through a script

I know there are several threads that talk about this, but I thought I’d make a new one since it’s easier and less confusing.

So I have this item that’s in the game world in a container, or it might be in the inventory of the PC or one of the companions. I would like to add an item property to this item only if certain conditions are set. I will probably do this through dialouge, I think. The property I’d like to add is the Cast Spell: Unique Power (Single Use) that gets activated through a i_itemtag_ac script. So here’s the script I made. I know through reading a bunch of old posts where I’ve asked similar questions before (getting answers and script examples from @travus @kevL_s and @Lance_Botelle ) that this can be a bit complicated. If I remember correctly there are some caveats to consider when it comes to a script like this, but…well, anyway. Here’s the script I was intending to use. I hope this is alright, and would work:

#include "x2_inc_itemprop"

void main()

object oPainting = GetObjectByTag("ipainting");

itemproperty ipProperty = ItemPropertyCastSpell(IP_CONST_CASTSPELL_UNIQUE_POWER,1);

//AddItemProperty(DURATION_TYPE_PERMANENT, ipProperty, oPainting);

IPSafeAddItemProperty(oPainting, ipProperty, 0.0);


Like I said, I would put this script in a conversation. Then I would add another script with i_itemtag_ac where I put code what I want to happen if the player activates the item.

Thanks for your time!

I tested it, and it seems to be working. When activating the oPainting it disappeared. I had not intended that, but I actually wanted that. I guess there must be a difference between IP_CONST_CASTSPELL_UNIQUE_POWER and IP_CONST_CASTSPELL_UNIQUE_POWER_SELF_ONLY.

1 Like

I realized when thinking and testing this further that I don’t really need to add the itemproperty. However, in certain circumstances, depending on how the player approaches things, I will have to do a script to remove the item property. I think I have some script like that from @kevL_s in my previous module. I’ll see if I can find it.

EDIT: After further consideration, and setting things up, I found out that I didn’t need that either.