Skip to content

using CreateItemOnObject on chest with undroppable item

Hello! I'm creating an undroppable item on the chest with CreateItemOnObject, but my players can't loot it. It reads "That item cannot be given away". It works just fine if I place the item in the container inventory using the toolset, though.

How can I put this item in a chest using scripts in order to players be able to take it?

Thanks in advance!

Comments

  • NeverwinterWightsNeverwinterWights Member Posts: 339
    If you set the item undroppable (cursed) beforehand, the players won't be able to take it out the chest. You need to set the flag after the player gets it. You can do it one of two ways. You would need to run a script in the OnDisturbed event of the chest OR the modules OnAcquireItem event. The OnAcquireItem script may vary depending on whether or not you have tag based scripts enabled.

    The chest's OnDisturbered event: something like so:
    void main()
    {
        object oItem = GetInventoryDisturbItem();
        if (GetTag(oItem) == "NoDropDagger")//test item tag
        {
            SetItemCursedFlag(oItem, TRUE);
        }
    }
    

    The module OnAcquireItem event: (if you have tag based scripts turned on then give the script the same name as the tag of the item) something like so:
    #include "x2_inc_switches"
    void main()
    {
        int iEvent = GetUserDefinedItemEventNumber();
        if (iEvent != X2_ITEM_EVENT_ACQUIRE) return;
    
        object oItem = GetModuleItemAcquired();
        SetItemCursedFlag(oItem, TRUE);
    }
    

    Hope it helps. Good luck.
Sign In or Register to comment.