Jump to content

hot to detect in a script if player is succesfully sneaking


tonycubed2

Recommended Posts

Greetings fellow modders,

 

It is easy to tell in a script if the player is in sneak mode. But not if he is succesfully sneaking with the screen eye closed. I know sneaking is based on sneak points, but I also see no way to track that either.

Any idea how to tell if a player is succesfully hidden/sneaking with the screen eye closed? Spent hours reading on ckit commands and on google but zero.....

 

:-(

 

Tony

 

Sands of Time mod

 

 

Link to comment
Share on other sites

  • 1 month later...

I would also really like to know this. Google doesn't give any hits and the creation kit wiki describes how stealth is measured but doesn't give a single command for it...

I got somewhat of an idea, which was that crime should have some sort of detection script, since crime isn't registered if you're not witnessed. But the crime page doesn't give many commands either...

Will try to read some crimescripts in the ckit. If I find something I'll let you know. Also if you find anything, please let me know.

 

(¤_¤)

Link to comment
Share on other sites

There is a way to catch it as an event through condition functions.
-New Quest called 'SneakDetect'
-New ReferenceAlias called 'Player'

Scriptname myPlayerScript extends ReferenceAlias
{Attached to players alias}
Event OnBeginSneak()
     debug.trace("omg im sneaking")
EndEvent

Event OnEndSneak()
     debug.trace("lol im not sneaking")
EndEvent

Event OnStealthFound()
debug.trace("im detected")
EndEvent

Event OnStealthLost()
debug.trace("im lost")
EndEvent

 

Now create a new spell.
type- ability
casting- constant
delivery- self

Now create 2 new magic effects.
archtype- script
..and same as above, nothing else.

Attach one of the new papyrus scripts to a magic effect.

Scriptname mySneakScript extends ActiveMagicEffect
{Condition Event - IsSneaking == 1}

myPlayerScript Property Detect Hidden
	myPlayerScript function get()
		;Make sure these match the quest and alias names
		return Quest.GetQuest("SneakDetect").GetAliasByName("Player") as myPlayerScript 
	endFunction
endProperty

Event OnEffectStart(Actor akTarget, Actor akCaster)
	Detect.OnBeginSneak()
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	Detect.OnEndSneak()
EndEvent
Scriptname myDetectScript extends ActiveMagicEffect
{Condition Event - GetDetected == 1}

myPlayerScript Property Detect Hidden
	myPlayerScript function get()
		;Make sure these match the quest and alias names
		return Quest.GetQuest("SneakDetect").GetAliasByName("Player") as myPlayerScript 
	endFunction
endProperty

Event OnEffectStart(Actor akTarget, Actor akCaster)
	Detect.OnStealthFound()
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	Detect.OnStealthLost()
EndEvent

 

Attach the magic effect to the spell and set the condition to IsSneaking == 1

Attach the magic effect to the spell and set the condition to GetDetected == 1


Last thing you do is add the spell to the same player alias on SneakDetect

Other scripters will be by soon to say just run you sneaky scripts directly in OnEffectStart and OnEffectFinish. They would probably be right, but my way can easily send the fake event to other scripts by added another property. Its also a bit limited too. If your stacks are getting complicated SendModEvent is the best way to go. I only didnt mention it because I thought there was some kind of issue with calling it on an activemagiceffect and some other types? Anyway, use SendModEvent instead of the full property if it works.

edit: I forgot the detected part :blink:

Link to comment
Share on other sites

Oh sorry, didn't expect such a quick reply! Thanks alot, I had no idea all those commands existed, especially GetDetected which was tricky to find.

Now, to the difficult task of integrating this into my script...

And also, you are the man!

Link to comment
Share on other sites

  • 1 month later...

 

scrivener07, on 07 Apr 2013 - 09:45, said:

 

 

There is a way to catch it as an event through condition functions.
-New Quest called 'SneakDetect'
-New ReferenceAlias called 'Player'

Scriptname myPlayerScript extends ReferenceAlias
{Attached to players alias}
Event OnBeginSneak()
     debug.trace("omg im sneaking")
EndEvent

Event OnEndSneak()
     debug.trace("lol im not sneaking")
EndEvent

Event OnStealthFound()
debug.trace("im detected")
EndEvent

Event OnStealthLost()
debug.trace("im lost")
EndEvent

 

Now create a new spell.
type- ability
casting- constant
delivery- self

Now create 2 new magic effects.
archtype- script
..and same as above, nothing else.

Attach one of the new papyrus scripts to a magic effect.

Scriptname mySneakScript extends ActiveMagicEffect
{Condition Event - IsSneaking == 1}

myPlayerScript Property Detect Hidden
	myPlayerScript function get()
		;Make sure these match the quest and alias names
		return Quest.GetQuest("SneakDetect").GetAliasByName("Player") as myPlayerScript 
	endFunction
endProperty

Event OnEffectStart(Actor akTarget, Actor akCaster)
	Detect.OnBeginSneak()
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	Detect.OnEndSneak()
EndEvent
Scriptname myDetectScript extends ActiveMagicEffect
{Condition Event - GetDetected == 1}

myPlayerScript Property Detect Hidden
	myPlayerScript function get()
		;Make sure these match the quest and alias names
		return Quest.GetQuest("SneakDetect").GetAliasByName("Player") as myPlayerScript 
	endFunction
endProperty

Event OnEffectStart(Actor akTarget, Actor akCaster)
	Detect.OnStealthFound()
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	Detect.OnStealthLost()
EndEvent

 

Attach the magic effect to the spell and set the condition to IsSneaking == 1

Attach the magic effect to the spell and set the condition to GetDetected == 1


Last thing you do is add the spell to the same player alias on SneakDetect

Other scripters will be by soon to say just run you sneaky scripts directly in OnEffectStart and OnEffectFinish. They would probably be right, but my way can easily send the fake event to other scripts by added another property. Its also a bit limited too. If your stacks are getting complicated SendModEvent is the best way to go. I only didnt mention it because I thought there was some kind of issue with calling it on an activemagiceffect and some other types? Anyway, use SendModEvent instead of the full property if it works.

edit: I forgot the detected part :blink:

 

 

 

I've done that and I got it to work except the get detected part.

On the playeralias script I added messageboxes as a test to see when i entered sneak/not sneak and detected/not detected.

The sneaking part works fine, but I'm not getting the detected to fire. Here's the two effect scripts along with the player alias script:

 

Sneaking Effect Script:

 

 

 

Scriptname CSisSneakingEffectScript extends ActiveMagicEffect  



{Condition Event - IsSneaking == 1}



CSSneakAliasScript Property Detect Hidden

    CSSneakAliasScript function get()

        ;Make sure these match the quest and alias names

        return Quest.GetQuest("CSSneakDetectQuest").GetAliasByName("PlayerAlias") as CSSneakAliasScript

    endFunction

endProperty



Event OnEffectStart(Actor akTarget, Actor akCaster)

    Detect.OnBeginSneak()

EndEvent



Event OnEffectFinish(Actor akTarget, Actor akCaster)

    Detect.OnEndSneak()

EndEvent

 

Detected Effect Script:

 

 

 

Scriptname CSGetDetectedEffectScript extends ActiveMagicEffect  



{Condition Event - GetDetected == 1}



CSSneakAliasScript Property Detect Hidden

    CSSneakAliasScript function get()

        ;Make sure these match the quest and alias names

        return Quest.GetQuest("CSSneakDetectQuest").GetAliasByName("PlayerAlias") as CSSneakAliasScript

    endFunction

endProperty



Event OnEffectStart(Actor akTarget, Actor akCaster)

    Detect.OnStealthFound()

EndEvent



Event OnEffectFinish(Actor akTarget, Actor akCaster)

    Detect.OnStealthLost()

EndEvent

 

and the player alias script:

 

 

 

Scriptname CSSneakAliasScript extends ReferenceAlias  

{Attached to players alias}



Event OnBeginSneak()

    debug.messagebox("I'm sneaking now.")

         debug.trace("omg im sneaking")

EndEvent



Event OnEndSneak()

    debug.messagebox("I'm not sneaking.")

         debug.trace("lol im not sneaking")

EndEvent



Event OnStealthFound()

    debug.messagebox("I'm Detected!")

    debug.trace("im detected")

EndEvent



Event OnStealthLost()

    debug.messagebox("I'm Lost!")

    debug.trace("im lost")

EndEvent

 

 

 

On the spell itself i have the two conditions checked as follows:

for IsSneaking effect - Target=S / Function Name = isSneaking / == 1

for getdetected effect - (I tried several combinations here, but can't seem to find one that works) as getdetected wants a specific target. so I tried having the target line as subject, with the function info as playerref == 1, I also tried target as PL, with the function info as playerref as well as leaving the function info blank. not sure what's going on but I can't seem to get the getdetected part to fire off when i'm detected or not.

 

Any help please? Thanks :smile:

 

Edit: please forgive the spacing within the code boxes. I had no control over the added spacing between lines. Also copying this over to the creation kit forum to see if anyone there may know of a solution.

 



 

Link to comment
Share on other sites

  • 6 years later...

I did a "cloak AOE spell" to pull this off. Pretty much I took a gamble that I was right when I originally posted my GetDetected sample.
But I was wrong.

More about cloak spells https://www.creationkit.com/index.php?title=Dynamically_Attaching_Scripts

What this will do is send a "ping" around the player and any actor in the ping radius will have an effect applied.
The effect will run the GetDetected condition function to see if the pinged actor has detected the player.

The core idea of capturing a condition function result with magic effect events is still how this works.
It was only the magic effect implementation details for this particular condition function I had wrong since the observer must be the MGEF subject.


Sample download.
https://drive.google.com/open?id=1I4tI5At8StGQ-TxpvpZD6d7LMBaOrEgH

Side Example: Line of Sight Condition Function
Other conditions work too, such as (LOS) line of sight.
https://cdn.discordapp.com/attachments/643251604308623380/643820901787238420/2019-11-12_09-33-19.mp4

It will track detection of the player by all actors in the cell. This is what matches to the sneak eye.
The monitor will signal detection all the time regardless of if the player is sneaking or not. You might want to add the IsSneaking == 1 condition check on the monitor effect too.
I took out Line Of Sight as a sample and made it only detection, but it proves the techniques are valid.

Thanks to Psyche for bringing this thread to my attention all these years later.
There are other pure code ways of finding GetDetection these days with skse too, but I feel its too complicated to explain in full. Ill let Psyche explain in brief.

The script I wrote is able to read and print data on every entity in my current cell, give me their names, or whatever else I specify, as well as tell me if they are currently detecting me or not.
It indexes the references and compares them one by one with the player using GetDetected in quick fashion.
I got the idea from this page (https://www.creationkit.com/index.php?title=GetNumRefs_-_Cell) where it shows in the example how to use the indexing in order to retrieve a table of data all at once.

Link to comment
Share on other sites

The script I wrote is able to read and print data on every entity in my current cell, give me their names, or whatever else I specify, as well as tell me if they are currently detecting me or not.

It indexes the references and compares them one by one with the player using GetDetected in quick fashion.

I got the idea from this page (https://www.creation...tNumRefs_-_Cell) where it shows in the example how to use the indexing in order to retrieve a table of data all at once.

Yeah I know of a way to do all of this using a script but I am not active on these forums. Send me a personal message if you need anything. Cheers.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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