Jump to content

OnSit is it reliable?


antstubell

Recommended Posts

So here's another of my wacky ideas - almost finished, so player is going yo have Tarot cards read. Conditions are that the NPC reader has to be sitting and player has to be sitting. I have a chair activator and a sit marker which makes player sit, NPC sits as she normally would because she is running Sit package (scheduled, she won't always be there). Using OnActivate for the chair activator to make player sit, is not a problem but I need to register when player gets up/is not sitting and not sitting in that specific chair so other stuff can be disabled/enabled/etc. Wiki says OnSit is not reliable, I'm sure I used this years ago without a problem. So with Sitting in mind what do I need to check for, how would I script, an event that checks player is sitting in THAT chair, the NPC is sitting in HER chair (maybe location conditions are needed here?) - player controls will be disabled during 'the reading' and enabled when it is over so player can get up and finally when player gets up (Is not sitting in THAT chair) then the event is over - but it is repeatable.

Phew! Hope I got the idea over and thanks for any input.

Link to comment
Share on other sites

Thanks. MysticMeg? Have some respect for the elderly lady her name is Nelly The Hag.

 

EDIT: An OnActivate event though doesn't catch when player stands up. My current script, although not tested, I'm sure will not disable the objects I want.

 

Actor Property PlayerRef Auto
Actor Property MyActor Auto
ObjectReference Property ChairMarkerREF Auto
ObjectReference Property TarotReadBox Auto
ObjectReference Property TarotGiveBox Auto

Event OnActivate(ObjectReference akActionRef)
if akActionRef == PlayerREF
ChairMarkerREF.Activate(PlayerREF)
EndIf

If PlayerRef.GetSitState() == True && MyActor.GetSitState() == True
Debug.Notification ("I am sitting and so is Nelly")
TarotReadBox.Enable()
TarotGiveBox.Enable()
EndIf

If PlayerRef.GetSitState() == False || MyActor.GetSitState() == False
TarotReadBox.Disable()
TarotGiveBox.Disable()
EndIf

EndEvent

 

Edited by antstubell
Link to comment
Share on other sites

All 'Furniture' can run an "Activate" event, when pressing "E" to sit and to get up, although there is the issue that the 'Furniture' will send 3 activation events instead of 2, if you use the "Forward" key instead of the "E" key to get up from the furniture.
This can easily be resolved by doing the next:


Auto State WaitingSitting
Event OnActivate(ObjectReference akActionRef)
       if ( akActionRef == Game.GetPlayer() )
            GoToState("Busy")
            Utility.Wait(2.0)
            GoToState("StandingUp")
 
            ; Do Your Stuff
 
   EndIf
EndEvent
EndState
 
 
State StandingUp
Event OnActivate(ObjectReference akActionRef)
            GoToState("Busy")
       if ( akActionRef == Game.GetPlayer() )
            Utility.Wait(1.5)
    EndIf

            ; Do Your Stuff

            GoToState("WaitingSitting")
 
EndEvent
EndState
 
 
State Busy
Event OnActivate(ObjectReference akActionRef)
      ;Do nothing.
EndEvent
EndState

The time required (Wait) and the order of the "States" is absolutely crucial for the "Activate Event" to work correctly on a furniture, this is an example script taken from my "Add Blessing On Throne Sit" script, which the time requiered for both animation to play on the throne furniture is exactly, On Sit 2 sec and on Get Up 1.5 sec.
Have a plesant day.

 

 

EDIT: Changed the order of the second "GoToState" in "State StandingUp", it was wrongly assigned.

Edited by maxarturo
Link to comment
Share on other sites

@maxarturo

This almost works for me. I've added necessary properties and a function that should fire when player sits down. It only fires every second activation. Meaning player sits, my notification appears telling me I am in the function. Player stands, waits then sits again - this time no notification so it didn't go to the function. Third time works fine as 1st time

 

Actor Property PlayerRef Auto
ObjectReference Property ChairMarkerREF Auto

Auto State WaitingSitting
Event OnActivate(ObjectReference akActionRef)
if akActionRef == PlayerREF
ChairMarkerREF.Activate(PlayerREF)

GoToState("Busy")
Utility.Wait(2.0)
GoToState("StandingUp")

; Do Your Stuff
CardRead()

EndIf
EndEvent
EndState


State StandingUp
Event OnActivate(ObjectReference akActionRef)
if akActionRef == PlayerREF
ChairMarkerREF.Activate(PlayerREF)

GoToState("Busy")

Utility.Wait(1.5)
EndIf
GoToState("WaitingSitting")

; Do Your Stuff
EndEvent
EndState


State Busy
Event OnActivate(ObjectReference akActionRef)
;Do nothing.
EndEvent
EndState
; ----------------------------------------------------------------------
Function CardRead()
Debug.Notification ("Waiting for Nelly to read cards")

EndFunction

 

Link to comment
Share on other sites

As i explained, the 'Wait' and the order of the 'States' is absolutely crucial for the "Activate" event to work correctly on a sit furniture.


The first thing that needs to fire when activated, is the "Busy" state, otherwise a third activation will be send.


From the script i posted, the part you can add your functions is only the part that writes " ; Do Your Stuff ".

You cannot modify the script structure without encountering issues.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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