Use states in _00E_Complex_AddSilenceSC

This commit is contained in:
Eddoursul 2025-07-27 18:24:59 +02:00
parent 9442c10d26
commit 96f0e89d72
2 changed files with 44 additions and 15 deletions

View File

@ -1,11 +1,15 @@
Scriptname _00E_Complex_AddSilenceSC extends ObjectReference Scriptname _00E_Complex_AddSilenceSC extends ObjectReference
; Eddoursul: Reworked in 2.1.4 to use states and the OnTrigger() event to encure silence track removal
Event OnTriggerEnter(ObjectReference akActionRef) Event OnTriggerEnter(ObjectReference akActionRef)
If akActionRef == PlayerREF If akActionRef == PlayerREF
If (__Config_QuestToSet.GetCurrentStageID() >= __Config_iMinStage) && (__Config_QuestToSet.GetCurrentStageID() <= __Config_iMaxStage) If (__Config_QuestToSet.GetCurrentStageID() >= __Config_iMinStage) && (__Config_QuestToSet.GetCurrentStageID() <= __Config_iMaxStage)
_00E_SilenceLongTransitionHighPriority.Add() if GetState() == ""
bActive = true _00E_SilenceLongTransitionHighPriority.Add()
GoToState("WaitLeave")
endif
EndIf EndIf
EndIf EndIf
@ -15,27 +19,52 @@ Event OnTriggerLeave(ObjectReference akActionRef)
If akActionRef == PlayerREF If akActionRef == PlayerREF
_00E_SilenceLongTransitionHighPriority.Remove() _00E_SilenceLongTransitionHighPriority.Remove()
GoToState("")
UnregisterForUpdate() UnregisterForUpdate()
bActive = false ;Debug.Notification("Leaving area")
EndIf EndIf
EndEvent EndEvent
; 2.1.4 Failsafe to ensure silence removal when OnTriggerLeave does not fire Event OnCombatStateChanged(Actor akTarget, int aeCombatState)
Event OnTrigger(ObjectReference akActionRef) ;
If bActive && akActionRef == PlayerREF endEvent
RegisterForSingleUpdate(3.0)
EndIf
EndEvent
Event OnUpdate() State WaitLeave
_00E_SilenceLongTransitionHighPriority.Remove()
bActive = false Event OnBeginState()
EndEvent RegisterForSingleUpdate(3.0)
;Debug.Notification("Waiting to leave")
EndEvent
Event OnCombatStateChanged(Actor akTarget, int aeCombatState)
if akTarget == PlayerREF
; Remove silence on combat start
if aeCombatState == 1
GoToState("")
endif
endif
endEvent
Event OnTrigger(ObjectReference akActionRef)
If akActionRef == PlayerREF
RegisterForSingleUpdate(3.0)
EndIf
EndEvent
Event OnUpdate()
GoToState("")
EndEvent
Event OnEndState()
_00E_SilenceLongTransitionHighPriority.Remove()
;Debug.Notification("Leaving area")
EndEvent
EndState
int Property __Config_iMinStage Auto int Property __Config_iMinStage Auto
int Property __Config_iMaxStage Auto int Property __Config_iMaxStage Auto
Actor Property PlayerREF Auto Actor Property PlayerREF Auto
Quest Property __Config_QuestToSet Auto Quest Property __Config_QuestToSet Auto
MusicType Property _00E_SilenceLongTransitionHighPriority Auto MusicType Property _00E_SilenceLongTransitionHighPriority Auto
bool bActive