Jump to content

[Solved] Talk (instead of Pickpocket) while Sneaking


Koda

Recommended Posts

Edit 7: I've mostly acquired the functionality I was looking for and learned a ton about scripting along the way. Thanks to everyone for their insight! My methodology ended up being a [Cloak Effect] to apply "SetPlayerTeammate(true)" to all actors around the PC (when relevant, of course). If anyone has suggestions on fine-tuning or optimizing this, feel free to let me know!

 

Older/other methodologies below:

 

 

Edit 6: The overall goal remains: "disable pickpocket and enable normal dialogue activation while sneaking."

 

I got a fancy OnCrosshairRefChange script working, but it doesn't quite work because the Activation Prompt does not change from "Pickpocket" to "Talk" until after the NPC is targeted. As a result, it seems it will be more practical to automatically make any NPC near the player a teammate (provided they're not Hostile) as a sort of short-range aura effect.

 

 

 

Edit 5: The question was originally: "Is it possible to disable Pickpocket and Enable normal dialogue activation while Sneaking?" h38fh2mf has heroically revealed the solution as being "SetPlayerTeammate(true)".

 

Thus, the current quest is developing a script which flags any NPC the player targets as a teammate, then clears the flag when the target changes.

 

 

Edit4: The story so far~

 

The question was originally: "Is it possible to disable pickpocket and enable normal dialogue activation while sneaking?" The short answer appears to be no (see above), but there are a few workarounds. All of them have the problem, however, of removing the crosshair text (ie. "[E] Prompt, NPC Name") from NPCs when the player is in range (presumably because it wants to display "[E] Pickpocket, NPC Name" but can't).

 

Thus, I'm currently trying to force-display a faux prompt (or at least the NPC Name, so the Player knows who they're looking at) over an NPC when the player is in range to pickpocket them (which can be easily tracked). If anyone has any insight on how to script this, I'd be very grateful. Thanks!

 

 

 

I'm designing a scenario where I basically want the player to be unable to Pickpocket (but able to Talk with) NPCs while Sneaking, but I'm not sure if this is possible.

 

Edit3: Looked into Perk Entry points at ag12's suggestion. This opens a door as it allows NPCs to be interacted with even if they otherwise couldn't be (ie. Sneaking while Pickpocket is disabled) or to simply override the default activation (ie. ignore that Pickpocket is available even if it's not disabled). What has not been solved is actually activating the dialogue. The Activate() script simply runs the default activation (which is Pickpocket while sneaking) again, so I think I'm hoping for one of two ideal solutions.

 

1. Papyrus script to initiate dialogue (ideally from the player's end, but forcing the NPC to forcegreet the player might work as a last resort).

2. Prevent Sneak from making Pickpocket (rather than talk) the default activation for Actors in the first place. This would obviously be the most elegant solution but the core Sneak/Pickpocket mechanics seem hard-coded and I haven't found any way to change them.

 

Current (non-ideal but passable) solution: PerkEntry which overrides Activation (provided it's an Actor and the Player is Sneaking) with:

Game.GetPlayer().StartSneaking() ; Ends Sneaking
akTargetRef.Activate(Game.GetPlayer())
Game.GetPlayer().StartSneaking() ; Restarts Sneaking

This method just has a little hiccup in the sneaking animations, which is probably fine. If I go this route, however, I'd appreciate if anyone has any insight into how to change the floating target text (ie. [E] Pickpocket NPCName) so that the interaction is clearer to the player.

 

 

 

Edit2: Tested the script to remove the Pickpocket-flag, but this also disables Talk, so I'm a bit stuck at the moment.

 

Alternatively, a method of forcing Sneak animations even while the player is standing (and thus talking) normally would work, but I'm not aware of that being possible.

 

 

Edit:

Some additional research shows that the following SKSE functions might be useful, although I'll need to test if this defaults the interaction to "Talk" or just disables interaction entirely. A more efficient method than setting and clearing this flag on all races periodically would be preferable, though...

 

 

    Bool AllowPickpocket()
        Returns whether the player can be Pickpocket this race.

    SetAllowPickpocket()
        Sets the race's Allow Pickpocket flag to true.

    ClearAllowPickpocket()
        Clears the race's Allow Pickpocket flag.

 

 

 

 

 

 

 

 

Link to comment

I think most of the activation options are handled via entry points on perks, so you might want to have a look at these.

I have never done anything with sneaking or altering the entry points, just adding new ones, so I'm not entirely sure it will help you, but if it is indeed an entry point, it might be as simple as adding another condition, for example a GetVMQuestVariable to one of your global quest scripts in which you set a flag to block the player from pickpocketing.

Link to comment

I think most of the activation options are handled via entry points on perks, so you might want to have a look at these.

I have never done anything with sneaking or altering the entry points, just adding new ones, so I'm not entirely sure it will help you, but if it is indeed an entry point, it might be as simple as adding another condition, for example a GetVMQuestVariable to one of your global quest scripts in which you set a flag to block the player from pickpocketing.

 

Thanks a bunch! I've been able to make some progress (edited in detail into original post) with Perk Entry Points. I wasn't able to find any core functionalities of Sneak or Pick-pocket, so my current solution-in-progress may be the best I'll get with this engine.

 

If so, this leads a slight aesthetic problem I am trying to solve: if I leave Pickpocket Enabled and simply override it, the cross-hair/target text is still "Pickpocket" rather than "Talk" (or whatever else). If I disable Pickpocket (and override the "nothing"), Actors have no cross-hair/target text at all. Any idea if there would be a way to force or customize this type of text?

Link to comment

Thanks a bunch! I've been able to make some progress (edited in detail into original post) with Perk Entry Points. I wasn't able to find any core functionalities of Sneak or Pick-pocket, so my current solution-in-progress may be the best I'll get with this engine.

No problem, happy to help. 

 

If so, this leads a slight aesthetic problem I am trying to solve: if I leave Pickpocket Enabled and simply override it, the cross-hair/target text is still "Pickpocket" rather than "Talk" (or whatever else). If I disable Pickpocket (and override the "nothing"), Actors have no cross-hair/target text at all. Any idea if there would be a way to force or customize this type of text

Well, the way to get a custom text on the crosshair is, as far as I know and use it, to block all other sorts of activation, then, OnInit of a quest you'd give the player a new perk that has a custom entry point that adds a new activation option under certain conditions of your choosing. Usually the entry point then runs some sort of script fragment.

Now, the script fragment that can be attached to an entry points delivers the reference of the activated option.

If all else fails, a not very elegant, but probably working solution would be to run a small script on the fragment that throws the targeted reference into a reference alias with a force-greet package that uses the default Hello topic.

 

Of course the alias needs to be cleared right after, so that the player is able to exit dialogue without the force-greet going opening dialogue back up over and over again. I'd probably attach a script fragment to the force-greet package itself that runs on package completion (and make sure the actual force-greet procedure is set to complete the package) and clears the alias.

 

I know that this is most likely the most complicated way of doing it, but I honestly haven't spend enough time with entry points to know a better one. This is the work-around I'd try.

 

Hmm, I hope any of this makes sense to you. :P

Link to comment

 

Well, the way to get a custom text on the crosshair is, as far as I know and use it, to block all other sorts of activation, then, OnInit of a quest you'd give the player a new perk that has a custom entry point that adds a new activation option under certain conditions of your choosing. Usually the entry point then runs some sort of script fragment.

 

Hm, I feel like this is mostly what I have, but maybe I'm missing something to get the crosshair text to actually activate? Here's my current testing setup:

  • Nord TestNPC
  • Quest with Alias containing the Player, attached script does the following:
    • Removes Pickpocket flag from NordRace OnInit (ie. Player cannot Pickpocket the TestNPC)
    • Adds Perk which contains Activation Entry Point (described below)
  • Perk with no data except one Entry Point
    • Entry Point has Perk Owner (Player) Condition: Sneaking == 1 (ie. must be Sneaking)
    • Entry Point has Target Condition: IsActor == 1 (ie. only works on people, not objects)
    • Entry Point has Script Fragment edited in first post (un-sneak, activate target, re-sneak)

This fundamentally works as written: if the Player activates the Nord TestNPC while Sneaking, it will begin Dialogue rather than Pickpocket (because the player un-sneaks right before the activation). However, there is no cross-hair text while targeting the NPC.

 

Am I missing something somewhere, or should this be showing some sort of generic "[E] Activate" text according to your explanation? Perhaps I've misunderstood something.

Link to comment

Well, no. Not generic. There should be a text window inside the entry point menu to set the activation name. Namely "Button Label".

 

Button Label just causes a Messagebox options-menu to appear when the activation occurs with "What would you like to do? [buttonLabel]." It does not appear to affect the floating crosshair text at all (maybe it does when Pickpocket isn't involved but I haven't tested that since Pickpocket is very stubborn about being involved).

 

The problem is still just that if I'm standing normally, the crosshair text is "[E] Talk, NPCName" and if I'm Sneaking with Pickpocket Enabled, I get "[E] Pickpocket, NPCName", but if I Sneak with Pickpocket Disabled, neither the NPC Name nor any prompt is displayed.

 

Some progress is I've found a good condition on which to change the crosshair text or manually display the prompt/name (IsPlayerActionActive[11] == 1, oddly niche hard-coded condition that knows if the player is in Sneaking and in range of an NPC), I just don't know how to, well, script any of that. I'm assuming it's possible since people can get stuff like floating dynamic healthbars, though, so hopefully I'm getting there!

Link to comment
Actor akTarget
 
akTarget.SetPlayerTeammate(true)
; Can't pickpocket and can talk while sneaking
akTarget.SetPlayerTeammate(false)
; Can pickpocket and can't talk while sneaking

Did you try this?

 

This is perfect; thank you so much! I can't believe it was that simple.

 

In that case, I suppose I'll be trying to write a script where:

  • if the player is sneaking
  • and their target is a living, non-hostile actor
  • make the target a teammate
  • when the target changes, clear the original's teammate status

Does something like that seem reasonable, perhaps using something like "Game.GetCurrentCrosshairRef()"?

Link to comment

You can register event listener for crosshair ref change. But I can't answer if this is the best way to do it because I don't know what you want to do.

 

Well, the bare bones are I want the player to be unable to Pickpocket (but able to Talk) with Friendly/Neutral NPCs while Sneaking (while under the effect of the quest/spell/item/whatever I end up attaching all this to, anyway).

 

Since setting an NPC as Teammate is the cleanest way to achieve that, I'm trying to determine the cleanest way to:

  1. Automatically make whoever the player is targeting a Teammate
  2. Clear the Teammate status once they target something else (to prevent every NPC the player runs across from being permanently flagged)

 

Link to comment

Ok I think I understand, couple of problems I see with this though is that the actor may have already been a teammate so you have to check that. And teammates do this:

  • NPC will sneak if the player sneaks, stop sneaking if the player stops sneaking.
  • NPC will draw a weapon if the player draws a weapon.
  • NPC will equip their best armor (instead of wearing their default Outfit)
  • Crimes committed by the NPC are considered crimes the player has committed.
  • (Optional) NPC can be issued commands.
from http://www.creationkit.com/SetPlayerTeammate_-_Actor

 

Could look strange if every NPC you look at starts to sneak. Not sure there's a better way though other than SKSE plugin but it would add yet another dependency which is bad.

Link to comment
[T]he actor may have already been a teammate so you have to check that.

 

Will do. I figure that would be easy enough with something like the following:

 

 

 

; Somewhere in flag setting script
if CurrentTarget.IsPlayerTeammate()
  bool AlreadyTeammate = true
else
  CurrentTarget.SetPlayerTeammate(true)
  ; rest of code etc.
endIf

; Later, in flag clearing script
if !AlreadyTeammate
  ; Blah blah blah
endif

 

 

 

Could look strange if every NPC you look at starts to sneak. Not sure there's a better way though other than SKSE plugin but it would add yet another dependency which is bad.

 

Tested your list of behaviors a bit (ran around Whiterun making people Teammates with the console), and the only one which actually seems to occur is the synced weapon drawing (which I would argue is more immersive than the default behavior anyway). So, hopefully, the target Sneaking shouldn't be an issue (and there are workarounds if it is, eg. forcing them to stop sneaking).

 

Also, my mod will already require SKSE, so that's not something to worry about unless I'm misunderstanding you.

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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