4
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

61 lines
1.4 KiB

Scriptname FXBirdFleeSCRIPT extends ObjectReference
{Triggers birds to fly away}
; Eddoursul 2024.01.21: Use states and updates, added OnReset
sound property BirdFlockSound auto
sound property BirdFlockFleeSound auto
bool property PlayerTriggered = false auto
{check if player is only actor that can trigger - Default FALSE}
int instanceID00
;*************************************************
auto state Init
Event OnCellAttach()
RegisterForSingleUpdate(0.5)
endEvent
event OnUpdate()
instanceID00 = BirdFlockSound.Play(Self)
GotoState("Waiting")
endevent
endstate
;*************************************************
State Waiting
Event onTriggerEnter(ObjectReference akActionRef)
if ! PlayerTriggered || (akActionRef as Actor && akActionRef == Game.GetForm(0x14))
GotoState("Triggered")
PlayAnimation("PlayAnim01")
BirdFlockFleeSound.Play(Self)
RegisterForSingleUpdate(0.5)
endif
endEvent
endState
;*************************************************
State Triggered
event OnUpdate()
GotoState("WaitForReset")
Sound.StopInstance(instanceID00)
instanceID00 = 0
endevent
endState
;*************************************************
State WaitForReset
event OnReset()
GotoState("Init")
; OnReset fires after onCellAttach()
if Is3DLoaded()
RegisterForSingleUpdate(0.5)
endif
endevent
endState
;*************************************************