Difference between revisions of "User:PROXiCiDE/GetSleepStateEx"
Jump to navigation
Jump to search
imported>PROXiCiDE |
imported>PROXiCiDE |
||
Line 1: | Line 1: | ||
Extended version of GetSleepState. Helpful detecting if a actor is sleeping in a interior while the player is in a exterior due to the limitation of GetSleepState. If the actor and player are both in the same location it will return the normal GetSleepState values. | |||
== Syntax == | == Syntax == | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Function | Int Function GetSleepStateEx(Actor akActor,Package akSleepPackage = None,Location akLocation = None) | ||
</source> | </source> | ||
== Parameters == | == Parameters == | ||
* | *akActor: The actor to detect if they are sleeping. | ||
* | *akSleepPackage: AI Package that contains the Sleep information. | ||
**'''Default''': | **'''Default''': None | ||
*akLocation : Compare the location of the Actor. | |||
**'''Default''': None | |||
== Return Value == | == Return Value == | ||
The actor's current sleep state. | |||
*5 Dead, sleeping with the fishes? | |||
*6 Actor has the sleep package | |||
*7 Actor has the sleep package and the confirmed location | |||
Following is returned if the actor is waking up or the package has changed during | |||
*16 Sleep package has ended / expired | |||
*17 Sleep package has ended / expired, actor still remains in the location | |||
Error Codes | |||
*-1 Invalid Actor | |||
== Example == | == Example == | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Int nSleepResults = GetSleepStateEx(akBalimund,pRiftenBalimundSleep0x6,pRiftenBlacksmithLocation) | |||
;Check for both normal value of GetSleepState incase the player is same location as Actor | |||
;else lets check for Dead or the Sleep Package | |||
If nSleepResults == 3 || nSleepResults == 5 || nSleepResults == 7 | |||
Debug.Trace("Actor is sleeping") | |||
EndIf | |||
</source> | </source> | ||
== Script == | == Script == | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Function | Int Function GetSleepStateEx(Actor akActor,Package akSleepPackage = None,Location akLocation = None) | ||
If | Int iResults = -1 | ||
Return | |||
If akActor == None | |||
Return iResults | |||
EndIf | EndIf | ||
If akActor.IsDead() | |||
iResults = 5 | |||
Else | |||
Bool bValidate = False | |||
;Detect normal sleep state | |||
If akActor.GetCurrentLocation().IsSameLocation(Game.GetPlayer().GetCurrentLocation()) | |||
Return akActor.GetSleepState() | |||
Else | |||
;Extended sleep detection | |||
If akLocation == None && akSleepPackage != None | |||
If | If akActor.GetCurrentPackage() == akSleepPackage | ||
bValidate = True | |||
iResults = 6 | |||
EndIf | |||
EndIf | EndIf | ||
If akLocation != None && akSleepPackage != None | |||
If | If akActor.GetCurrentPackage() == akSleepPackage && akActor.GetCurrentLocation() == akLocation | ||
bValidate = True | |||
iResults = 7 | |||
EndIf | |||
EndIf | EndIf | ||
If bValidate | |||
If | ;Lets check incase the schedule for the package has expired | ||
akActor.EvaluatePackage() | |||
If akActor.GetCurrentPackage() != akSleepPackage | |||
iResults += 10 | |||
EndIf | |||
EndIf | EndIf | ||
EndIf | EndIf | ||
EndIf | EndIf | ||
Return iResults | |||
EndFunction | EndFunction | ||
</source> | </source> | ||
== See Also == | |||
*[[Actor Script]] | |||
*[[GetSleepState - Actor|GetSleepState]] | |||
*[[GetSleeping]] | |||
*[[IsPCSleeping]] |
Latest revision as of 17:31, 7 February 2014
Extended version of GetSleepState. Helpful detecting if a actor is sleeping in a interior while the player is in a exterior due to the limitation of GetSleepState. If the actor and player are both in the same location it will return the normal GetSleepState values.
Syntax[edit | edit source]
Int Function GetSleepStateEx(Actor akActor,Package akSleepPackage = None,Location akLocation = None)
Parameters[edit | edit source]
- akActor: The actor to detect if they are sleeping.
- akSleepPackage: AI Package that contains the Sleep information.
- Default: None
- akLocation : Compare the location of the Actor.
- Default: None
Return Value[edit | edit source]
The actor's current sleep state.
- 5 Dead, sleeping with the fishes?
- 6 Actor has the sleep package
- 7 Actor has the sleep package and the confirmed location
Following is returned if the actor is waking up or the package has changed during
- 16 Sleep package has ended / expired
- 17 Sleep package has ended / expired, actor still remains in the location
Error Codes
- -1 Invalid Actor
Example[edit | edit source]
Int nSleepResults = GetSleepStateEx(akBalimund,pRiftenBalimundSleep0x6,pRiftenBlacksmithLocation)
;Check for both normal value of GetSleepState incase the player is same location as Actor
;else lets check for Dead or the Sleep Package
If nSleepResults == 3 || nSleepResults == 5 || nSleepResults == 7
Debug.Trace("Actor is sleeping")
EndIf
Script[edit | edit source]
Int Function GetSleepStateEx(Actor akActor,Package akSleepPackage = None,Location akLocation = None)
Int iResults = -1
If akActor == None
Return iResults
EndIf
If akActor.IsDead()
iResults = 5
Else
Bool bValidate = False
;Detect normal sleep state
If akActor.GetCurrentLocation().IsSameLocation(Game.GetPlayer().GetCurrentLocation())
Return akActor.GetSleepState()
Else
;Extended sleep detection
If akLocation == None && akSleepPackage != None
If akActor.GetCurrentPackage() == akSleepPackage
bValidate = True
iResults = 6
EndIf
EndIf
If akLocation != None && akSleepPackage != None
If akActor.GetCurrentPackage() == akSleepPackage && akActor.GetCurrentLocation() == akLocation
bValidate = True
iResults = 7
EndIf
EndIf
If bValidate
;Lets check incase the schedule for the package has expired
akActor.EvaluatePackage()
If akActor.GetCurrentPackage() != akSleepPackage
iResults += 10
EndIf
EndIf
EndIf
EndIf
Return iResults
EndFunction