Glanzer Posted July 7, 2022 Share Posted July 7, 2022 Is there a way to distinguish between the ContainerMenu that is opened when pickpocketing and other ContainerMenus that open from sacks and other items? They all have the same menu type ("ContainerMenu"). I need to know if it's a pickpocket attempt, and I need to detect this BEFORE the actual pickpocket of an item. I do have the condition "if player is sneaking" (and that is working), but I need more conditions to narrow it down. I don't know how to reference the target npc or find out who the container owner is. Here is a snippet of code I have which is working: Event OnInit() RegisterForMenu("ContainerMenu")EndEventEvent OnMenuOpen(String MenuName) If MenuName == "ContainerMenu" If PlayerRef.IsSneaking() <--- need more conditions than this... (do stuff here) EndIf EndIfEndEvent Link to comment Share on other sites More sharing options...
maxarturo Posted July 7, 2022 Share Posted July 7, 2022 (edited) Unless there is an SKSE add-on, then no. But you can detect a pickpocket attempt by slightly modifing the logic you posted. * Just an example of the logic. * The animation name is invalid, i just added something. Event OnInit() RegisterForAnimationEvent(Player, "SNEAKING") RegisterForMenu("ContainerMenu") EndEvent Event OnAnimationEvent(ObjectReference akSource, string asEventName) PlayerSneaking = True EndEvent Event OnMenuOpen(String MenuName) If ( PlayerSneaking == True ) && ( MenuName == "ContainerMenu" ) (do stuff here) EndIf EndEvent Edited July 7, 2022 by maxarturo Link to comment Share on other sites More sharing options...
Glanzer Posted July 8, 2022 Author Share Posted July 8, 2022 The problem is that the code is invoked if I open ANY container while sneaking, e.g. a sack, a barrel, etc. The sneaking code I have already works. Or did I misunderstand? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted July 8, 2022 Share Posted July 8, 2022 If you want to require SKSE you can add the function call GetCurrentCrosshairRef as part of your conditions i.e.If (PlayerRef.IsSneaking()) && (Game.GetCurrentCrosshairRef() as Actor) Unless you just mean stealing in general rather than pickpocketing an NPC, then outside of an SKSE DLL that can get the data at the engine level and modify behavior there, I do not know. Link to comment Share on other sites More sharing options...
maxarturo Posted July 8, 2022 Share Posted July 8, 2022 (edited) I didn't understand you correctly the first time, but IsharaMeradin suggestion should work just fine.By the way IsharaMeradin, hi, long time no see.Example: Event OnInit() RegisterForMenu("ContainerMenu") EndEvent Event OnMenuOpen(String MenuName) If (PlayerRef.IsSneaking()) && (Game.GetCurrentCrosshairRef() as Actor) && ( MenuName == "ContainerMenu" ) (do stuff here) EndIf EndEvent But if you have a specific npc where this should work and not to any npc, then things are more easy to accomplish.You just need to add to that actor a script to detect if the player is attempting a pickpocet him/her. Edited July 8, 2022 by maxarturo Link to comment Share on other sites More sharing options...
TyburnKetch Posted July 8, 2022 Share Posted July 8, 2022 (edited) If you are wanting to limit pickpocketing on a certain npc put the script on the actor themselves and use blockactivation. If you need it on a dynamic level then you could probably set up some sort of alias that holds the script that conditionally gets filled.In the mod I am currently working on I do not want the user to be able to pickpocket some npcs and so I have a script on those npcs that blocks activation as a rule (oninit). Below is the simple script I have on the npc: Actor Property PlayerRef AutoMessage Property SM_NoPickpocket_MSG AutoEvent OnInit()Self.BlockActivation()EndEventEvent OnActivate(ObjectReference akActionRef)If akActionRef == PlayerRefif PlayerRef.IsSneaking() ;do nothing since the akActionRef is trying to pickpocketSM_NoPickpocket_MSG.Show()elseSelf.Activate(akActionRef, true) ;execute regular activation because akActionRef was not trying to pickpocketEndifEndIfEndEvent Edited July 8, 2022 by TyburnKetch Link to comment Share on other sites More sharing options...
maxarturo Posted July 8, 2022 Share Posted July 8, 2022 @ TyburnKetch You can do this without the need to use a script running on those npcs. Just create a new race and assigned the 'can't be pickpocket' flag on the race. * The function 'Activate()' when used directly on actors will interfere with the actor's dialogue. Link to comment Share on other sites More sharing options...
TyburnKetch Posted July 8, 2022 Share Posted July 8, 2022 Yes. I contemplated new races but for my needs it was not necessary. I have also not had any issues with activate() and dialogue on my npcs. I do not doubt it could be an issue, but I have not experienced it. When you say interfere what are you referring to? Link to comment Share on other sites More sharing options...
maxarturo Posted July 8, 2022 Share Posted July 8, 2022 @ TyburnKetch Yeah... I had just woken up and my brain was not fully functional, now that it is, the issue is not with an 'Activate()' function but... If you have a script directly attached to an actor that it's running an 'OnActivate' event, and that actor has dialogue, every time the player responds to the actor's dialogue, that respond will also sent an 'activate' event, and vise versa. So, the script living directly on that actor needs 'Fail Safes' to ensure that only the desirable 'Activate' events will fire, and not every time the player responds. Link to comment Share on other sites More sharing options...
TyburnKetch Posted July 8, 2022 Share Posted July 8, 2022 Ah. Yes. That makes sense. Link to comment Share on other sites More sharing options...
Recommended Posts