User:PROXiCiDE/GetSleepStateEx
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.
SyntaxEdit
Int Function GetSleepStateEx(Actor akActor,Package akSleepPackage = None,Location akLocation = None)
ParametersEdit
- 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 ValueEdit
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
ExampleEdit
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
ScriptEdit
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