Jump to content

Enabling an object or NPC with a trigger, but having the object/NPC disable again after a few seconds.


Recommended Posts

Hi

 

I'd like the player to enter a trigger zone, which would cause an object or NPC to appear, but then the object would fade after several seconds.

I'm working on a spooky mod, where objects or NPCs fade in or out like the Dunwich quarries situation.

 

Any way to do this without too much fuss? A timer comes to mind, and a enable/disable self activate trigger, but I don't know how to use the two together.

 

Thanks for any advice.

 

Link to comment
Share on other sites

Trigger with attached script OnTriggerEnter event which enables a no keyword LinkedRef starts a timer which disables the LinkedRef, outline would be;

Event OnTriggerEnter(ObjectReference akActionRef)
If (akActionRef == Game.GetPlayer()) 
   ObjectReference MyLinkedRef = Self.GetLinkedRef(apKeyword = None)
   If (MyLinkedRef != None) && (MyLinkedRef.IsEnabled() == False) ; stops retriggering when active
      MyLinkedRef.Enable()
      Self.StartTimer(afInterval = 30.0, aiTimerID = 10) ; ObjectReference attached timers must have a timer value
   Endif
EndIf
EndEvent

Event OnTimer(Int aiTimerID)
ObjectReference MyLinkedRef = Self.GetLinkedRef(apKeyword = None)
If (MyLinkedRef != None)
   MyLinkedRef.Disable()
Endif
EndEvent
Link to comment
Share on other sites

Wow, looks great! Big fan of your work. I'm stunned that one of the modders I respect would respond to me.

Thanks so much. I'll give it a try. Timers were always a bit of a black box to me, but this seems straightforward.

 

Trigger with attached script OnTriggerEnter event which enables a no keyword LinkedRef starts a timer which disables the LinkedRef, outline would be;

Event OnTriggerEnter(ObjectReference akActionRef)
If (akActionRef == Game.GetPlayer() 
   ObjectReference MyLinkedRef = Self.GetLinkedRef(apKeyword = None)
   If (MyLinkedRef != None) && (MyLinkedRef.IsEnabled() == False) ; stops retriggering when active
      MyLinkedRef.Enable()
      Self.StartTimer(afInterval = 30.0, aiTimerID = 10) ; ObjectReference attached timers must have a timer value
   Endif
EndIf
EndEvent

Event OnTimer(Int aiTimerID)
ObjectReference MyLinkedRef = Self.GetLinkedRef(apKeyword = None)
If (MyLinkedRef != None)
   MyLinkedRef.Disable()
Endif
EndEvent

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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