Seeking Help with OnDisturbed / detecting when an item is stolen.
LonelyRonin
Member Posts: 4
Hi I'm hoping someone can help me out with a problem I'm having.
I'm trying to implement a creature like the Brierhearts from Skyrim, so when a particular item gets stolen from their inventory they die.
I set the spawn condition NW_FLAG_DISTURBED_EVENT (I've tested this with a custom OnSpawn script & the NW_GENERIC_MASTER variable) to trigger the OnUserDefined script and added a switch statement:
If anyone can tell me where I'm going wrong it would be greatly appreciated.
I'm trying to implement a creature like the Brierhearts from Skyrim, so when a particular item gets stolen from their inventory they die.
I set the spawn condition NW_FLAG_DISTURBED_EVENT (I've tested this with a custom OnSpawn script & the NW_GENERIC_MASTER variable) to trigger the OnUserDefined script and added a switch statement:
void main() { effect eBLESS = EffectVisualEffect(SPELL_BLESS); switch (GetUserDefinedEventNumber()) { // Event 1008 case EVENT_DISTURBED: SpeakString("Event #1008 occurred! Inventory changed!"); ApplyEffectToObject(DURATION_TYPE_INSTANT, eBLESS, OBJECT_SELF); break; } }I have other case statements for other events that trigger fine, but the disturbed event never triggers when the target gets pickpocketed, the code seem to run fine for a container just not npcs/creatures.
If anyone can tell me where I'm going wrong it would be greatly appreciated.
0
Comments
My knowledge of the toolset is old and probably out dated but doesn't the OnUnAcquireItem script only run for PC characters not NPCs ? hence my attempts at an OnDisturbed or OnUserDefined script.
In the toolset it can be found by clicking Edit, Module Properties and then the Events tab shows the script associated with unacquire.
I saw this section in the unacquire code
Bear in mind that they are module events, not creature events.
The ones that only work for PCs are OnPlayerEquipItem and OnPlayerUnEquipItem, which you don't need here.
I have the basic idea working now, I really appreciate the help, thanks.
I have had a few fights with OnDisturbed ( specifically, when a non-pc creature was dropping an item into a placeable inventory ) . I gave up and I use a heartbeat script to check for the item.
How did you solve your problem?
Dropping an item into a placeable inventory is different. OnDisturbed fires on the placeable. See Lexicon for the functions you use to discover the item, event and actor.
OnDisturbed can detect both adding and removing from a chest, I thought, its supposed to detect when something is pick-pocketed but it doesn't. Npc inventories aren't treated as containers, as I was my thinking at the time.
I believe you can use OnDisturbed to detect both INVENTORY_DISTURB_TYPE_ADDED & INVENTORY_DISTURB_TYPE_REMOVED events, INVENTORY_DISTURB_TYPE_STOLEN doesn't seem to apply to containers (from my limited testing).
OnDisturbed test script of a chest:
The code below is a dirty little proof of concept I did to see if it would suit my purposes.
Proleric - thanks for your comment. And you're right, I am working on a placeable inventory. LonelyRonin thanks for pasting your test. Thanks to both of yous for the inspiration. I will take another look at OnDisturbed.
I was hoping to use the OnDisturbed event to manage the inventories comings and goings. It seems that event only triggers for player characters ( and not for all creatures ).