Jump to content

Pickpocket menu open - how to distinguish this from other containers?


Recommended Posts

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")
EndEvent

Event OnMenuOpen(String MenuName)
If MenuName == "ContainerMenu"
If PlayerRef.IsSneaking() <--- need more conditions than this...

 

(do stuff here)

 

EndIf
EndIf
EndEvent

Link to comment
Share on other sites

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 by maxarturo
Link to comment
Share on other sites

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

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 by maxarturo
Link to comment
Share on other sites

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 Auto
Message Property SM_NoPickpocket_MSG Auto

Event OnInit()
Self.BlockActivation()
EndEvent

Event OnActivate(ObjectReference akActionRef)
If akActionRef == PlayerRef
if PlayerRef.IsSneaking() ;do nothing since the akActionRef is trying to pickpocket
SM_NoPickpocket_MSG.Show()
else
Self.Activate(akActionRef, true) ;execute regular activation because akActionRef was not trying to pickpocket
Endif
EndIf
EndEvent

Edited by TyburnKetch
Link to comment
Share on other sites

@ 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

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

@ 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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...