Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Dark Dreams of Furiae - a new module for NWN:EE! Buy now
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Prevent player from dropping item

xypherxypher Member Posts: 9
Hello,

I am trying to keep a player from being able to drop an item once they acquire it into their inventory. The item isn't set as undroppable in the toolset options as they retrieve it from a container. I saw a similar post to this and I thought I did it correctly, but even after taking the item I can still right click and drop it from my inv. or drag and drop it out into the game world. I attempted via this method in my OnAcquire module script:

SetDroppableFlag(oItem, FALSE);

I also tried with the SetCursedItemFlag since its description sounded like it did the same thing? Neither work when I set it to false. My logic was, when the item is acquired set that item to be undroppable.

Comments

  • DazDaz Member Posts: 75
    You want:
    SetItemCursedFlag(oItem, TRUE);
    

    SetDroppableFlag is to indicate if an item can drop as loot or not for NPCs.

  • xypherxypher Member Posts: 9
    Thanks for the clarification on Droppable flag. I just tried that other way again to be sure I didn't have it wrong, but SetItemCursedFlag doesn't work either. Below is my snippet of code from my OnAcquire script. The SetLocalInt works so it is getting inside that if statement.

    pxea2urwd76e.png

    In case this helps, the item is being created dynamically in script of OnOpen whenever the inventory of this object is opened.

  • AncarionAncarion Member Posts: 131
    That's very odd. I use that function often, and have never had a problem with it. One thing most likely unrelated that I would suggest is to change the first line to
    if (GetTag(oItem)=="HUNTWOLF" etc. etc.
    
    On the outside chance that another object with that tag might exist in game. That could lead to unpredictable behavior.

  • xypherxypher Member Posts: 9
    edited 1:07AM
    Wow. I had my custom script logic underneath the default switch logic (I guess it is turned on for tag-based scripting) and my code wasn't ever getting ran because it returned before then. I got it working just fine now. I do have a question: can I remove the default logic with no strings attached, have a clean OnAcquire script and just add what I need? Or should I leave the default code below:

    (I'm just not 100% on what that means or how it works at the moment since I'm still learning)
    15mau578ol31.png


    EDIT: Also, thanks for the tip Ancarion. For my module I actually do expect there to be multiple existing at the same time in some instances.

  • ProlericProleric Member Posts: 612
    As a rule-of-thumb, I wouldn't change default logic unless there was a compelling reason.

    Some of the default AI is really easy to break.

    In this particular case, I have the default code before the custom code, with no problems.

    What the default code says is "return if X2_EXECUTE_SCRIPT_END is returned by a script with the same name as the tag". That suggests that you actually have a tag-based script which is executing in addition to your custom logic, when the default code is placed last.

  • xypherxypher Member Posts: 9
    edited 2:09PM
    Got it. Thanks, Proleric. I will look into this further. I was messing around with tag-based scripting when going through the Lexicon and perhaps I still left old scripts in this module.

    EDIT: Sure enough, I had a tag-based script for that item and I completely forgot about that. That was messing with all sorts of stuff when I was originally setting up this whole gameplay mechanic. Now that I understand better how this is working I actually moved all that code into the tag-based script and have it working that way. Thank you.

Sign In or Register to comment.