Is there a standard way of detecting when a small container in the PC’s inventory is opened? I have a small custom chest that behaves just like other containers in that you can open it in game in the normal manner. The thing is I can’t see an easy way of detecting this via script, when the thing is opened in the inventory.
Also is there a way of enforcing the D&D behaviour that cursed worn items cannot be removed besides using tag based scripting to re-equip the item as soon as it is unequipped?
Can you make the container open its inventory through unique power self only instead of the default “open” option? That would automatically “detect” when it’s opened since it would trigger OnActivateItem. I don’t know that there is an easy way to check for a PC opening a container in their inventory by default.
As for cursed equipment, maybe you can trick the game into thinking inventory is full upon unequipping the item, preventing its unequipping in the first place?
You can use GetItemCursedFlag() in the OnPlayerUnEquipItem to re-equip it. No tag-based scripting necessary.
What is the purpose in detecting that the PC opened the container?
Depending on the effect you are trying to achieve, you could consider making the ‘container’ not really a container. Then, when it is used it could open a container with everything inside it, and you could detect that…
@JFK It’s supposed to be a workaround for the fact that the OnAquire is wonkey for things in containers. That fires as soon as the PC has the container and not when the item is extracted from the container into the PC’s inventory. Ideally I would have simulated the PC touching the item in the container but there doesn’t appear to be an OnUsed event for items either.
@squattingmonk The cursed flag only prevents the PC from getting rid of a cursed item, it doesn’t prevent them from unequipping it. This is not how cursed items are supposed to work in D&D. If rings and amulets can be unequipped it leaves the door open for the PC equipping an item to counter the cursed one. Also cursed weapons while being unequippable, are supposed to be the only weapon a PC can use until the curse is lifted. Not too sure about cursed armour but fortunately I am trying to get cursed jewellery to work here.
Whether OnAcquire is wonky or not is debateable. For many purposes, such as possessing plot items, acquiring the container quite rightly counts as acquiring the item. Can you cast more light on why your case is different?
I think @squattingmonk was suggesting that you write a script to enforce cursed items by trapping the unequip event & re-equipping the item.
About the cursed items and what you want to do: it’s discussed in detail here (Bioware Archive).
Did you know that you can’t move an item out of a container if it is Undroppable? You get an error message if you try. That means for a cursed item you have to allow it to be droppable while it is in its container and be able to catch it at some point after it is moved to make it undroppable.
On my PC, Symantec blocked a coin miner download. Maybe it’s time to change hosts?
Sorry. I didn’t have any problems with opening this link (probably because of browser extensions I’m using that block such kinds of things), just found it on Google.
I use Opera. It’s got a built-in bitcoin mining blocker as well as a built-in ad-blocker.
I guess by wonkey, you mean that when the PC has the container they have everything in the container already. So when they pull it out of the container, they are not acquiring it because they already have it. BUT you can tell if it is in the container or not.
It might not be the best, but in the OnAcquire script for the Item (not the container), you can have a function to get the container item and cycle through its inventory. If it finds the item is inside, the function delays a period of time (6 seconds or so) and then calls itself again. If it doesn’t find itself, it double checks if the PC still possesses it (ItemPossesedBy) and does what ever it is you want it to do. It think JFK’s suggestion of using an item instead of the container which opens a storage inventory when a special power is used as a cleaner and more reactive solution.