Detecting the correct NPC Behavior, any ideas?

Post » Sun Jan 20, 2013 11:04 pm

Anyone ever figure out how to detect sleep behavior while your not in the same cell as the NPC?
Lets give a example here
  • Player Location == Riverwood
  • NPC's location == Riften Blacksmith
  • GetSleepState does not function this way
Using GetSleepState on a NPC while they are not in the same cell, or loaded does not seem to work for me, so i had to detect Package & Game Hour

Reason for the Game Hour detection was to EvaluatePackage on a NPC, because Asbjorn would sometimes stay down in the basemant of Riften Blacksmith and not goto sleep period until the player actually entered the cell then his package would then Evaluate it self (reason for EVPBlacksmithOwner function). But what if another mod had changed the package schedule, this this would no longer be a valid sleep detection

Spoiler

ReferenceAlias Property pBalimund AutoReferenceAlias Property pAsbjorn AutoLocation Property pRiftenBlacksmithLocation AutoGlobalVariable Property pGameHour AutoPackage Property pRiftenBalimundSleep0x6 AutoPackage Property pRiftenAsbjornSleeps0x6 AutoFunction EVPBlacksmithOwner()    If RiftenBlacksmithOwnersDead()        Return    EndIf        If IsValidSleepHour()        Actor akBalimund = pBalimund.GetActorRef()        Actor akAsbjorn = pAsbjorn.GetActorRef()        If akBalimund.GetCurrentPackage() != pRiftenBalimundSleep0x6            akBalimund.EvaluatePackage()        EndIf        If akAsbjorn.GetCurrentPackage() != pRiftenAsbjornSleeps0x6            akAsbjorn.EvaluatePackage()        EndIf    EndIfEndFunctionBool Function IsValidSleepHour()    If (pGameHour.GetValue() >= 0 && pGameHour.GetValue() < 6)        Return True    EndIf    Return FalseEndFunctionBool Function RiftenBlacksmithOwnersSleeping()    Actor akBalimund = pBalimund.GetActorRef()    Actor akAsbjorn = pAsbjorn.GetActorRef()        ;incase the player has killed both actors, then they are sleeping with the fishes    If RiftenBlacksmithOwnersDead()        Return True    EndIf            If (akBalimund.GetCurrentPackage() == pRiftenBalimundSleep0x6 && akAsbjorn.GetCurrentPackage() == pRiftenAsbjornSleeps0x6) &&\        (akAsbjorn.GetCurrentLocation() == pRiftenBlacksmithLocation && akBalimund.GetCurrentLocation() == pRiftenBlacksmithLocation) &&\        IsValidSleepHour()        Return True    EndIf        Return FalseEndFunctionBool Function RiftenBlacksmithOwnersDead()    Actor akBalimund = pBalimund.GetActorRef()    Actor akAsbjorn = pAsbjorn.GetActorRef()        ;incase the player has killed both actors    If akAsbjorn.IsDead() && akBalimund.IsDead()        Return True    EndIf    Return FalseEndFunction
User avatar
Princess Johnson
 
Posts: 3435
Joined: Wed Feb 07, 2007 5:44 pm

Return to V - Skyrim