2021-10-05 22:15:58 +00:00
|
|
|
Scriptname _00E_GUI_ActorHealthBar extends ski_widgetbase
|
|
|
|
|
|
|
|
float _scale = 1.0
|
|
|
|
int _maxEntries = 5
|
|
|
|
float _fadeInDuration = 250.0
|
|
|
|
float _fadeOutDuration = 750.0
|
|
|
|
float _moveDuration = 1000.0
|
|
|
|
float _removeDuration = 15000.0
|
|
|
|
Form[] _currentlyDisplayedActors
|
|
|
|
|
2024-02-29 22:28:19 +00:00
|
|
|
int function _GetScriptVersion() Global
|
|
|
|
return 1
|
|
|
|
endFunction
|
|
|
|
|
2021-10-05 22:15:58 +00:00
|
|
|
string function GetWidgetSource()
|
2024-01-12 13:56:46 +00:00
|
|
|
return "skyui/companionpanel.swf"
|
2021-10-05 22:15:58 +00:00
|
|
|
endFunction
|
|
|
|
|
|
|
|
string function GetWidgetType()
|
|
|
|
return "EFFPanel"
|
|
|
|
endFunction
|
|
|
|
|
|
|
|
int function GetVersion()
|
|
|
|
return 1
|
|
|
|
endFunction
|
|
|
|
|
|
|
|
float property Scale
|
|
|
|
float function get()
|
|
|
|
return _scale
|
|
|
|
endFunction
|
|
|
|
|
|
|
|
function set(float a_val)
|
|
|
|
_scale = a_val
|
|
|
|
if (Ready)
|
|
|
|
UpdateWidgetScale()
|
|
|
|
endIf
|
|
|
|
endFunction
|
|
|
|
endProperty
|
|
|
|
|
|
|
|
int Property MaxEntries
|
|
|
|
int function get()
|
|
|
|
return _maxEntries
|
|
|
|
endFunction
|
|
|
|
|
|
|
|
function set(int a_val)
|
|
|
|
_maxEntries = a_val
|
|
|
|
if (Ready)
|
|
|
|
UpdateMaxEntries()
|
|
|
|
endIf
|
|
|
|
endFunction
|
|
|
|
endProperty
|
|
|
|
|
|
|
|
float property FadeInDuration
|
|
|
|
float function get()
|
|
|
|
return _fadeInDuration
|
|
|
|
endFunction
|
|
|
|
|
|
|
|
function set(float a_val)
|
|
|
|
_fadeInDuration = a_val
|
|
|
|
if (Ready)
|
|
|
|
UpdateFadeInDuration()
|
|
|
|
endIf
|
|
|
|
endFunction
|
|
|
|
endProperty
|
|
|
|
|
|
|
|
float property FadeOutDuration
|
|
|
|
float function get()
|
|
|
|
return _fadeOutDuration
|
|
|
|
endFunction
|
|
|
|
|
|
|
|
function set(float a_val)
|
|
|
|
_fadeOutDuration = a_val
|
|
|
|
if (Ready)
|
|
|
|
UpdateFadeOutDuration()
|
|
|
|
endIf
|
|
|
|
endFunction
|
|
|
|
endProperty
|
|
|
|
|
|
|
|
float property MoveDuration
|
|
|
|
float function get()
|
|
|
|
return _moveDuration
|
|
|
|
endFunction
|
|
|
|
|
|
|
|
function set(float a_val)
|
|
|
|
_moveDuration = a_val
|
|
|
|
if (Ready)
|
|
|
|
UpdateMoveDuration()
|
|
|
|
endIf
|
|
|
|
endFunction
|
|
|
|
endProperty
|
|
|
|
|
|
|
|
float property RemoveDuration
|
|
|
|
float function get()
|
|
|
|
return _removeDuration
|
|
|
|
endFunction
|
|
|
|
|
|
|
|
function set(float a_val)
|
|
|
|
_removeDuration = a_val
|
|
|
|
if (Ready)
|
|
|
|
UpdateRemoveDuration()
|
|
|
|
endIf
|
|
|
|
endFunction
|
|
|
|
endProperty
|
|
|
|
|
|
|
|
; @override SKI_WidgetBase
|
|
|
|
event OnWidgetReset()
|
|
|
|
parent.OnWidgetReset()
|
|
|
|
UpdateWidgetScale()
|
|
|
|
UpdateMaxEntries()
|
|
|
|
UpdateFadeInDuration()
|
|
|
|
UpdateFadeOutDuration()
|
|
|
|
UpdateMoveDuration()
|
|
|
|
UpdateRemoveDuration()
|
|
|
|
endEvent
|
|
|
|
|
|
|
|
event OnGameReload()
|
2022-08-01 14:28:02 +00:00
|
|
|
|
2024-02-07 15:20:32 +00:00
|
|
|
if SKSE.GetVersion() == 0
|
|
|
|
Debug.Trace("NO SKSE: companion health bars are disabled")
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
2021-10-05 22:15:58 +00:00
|
|
|
parent.OnGameReload()
|
|
|
|
|
2024-01-17 21:25:32 +00:00
|
|
|
If Game.GetModByName("SkyUI_SE.esp") == 255 || _00E_ActorHealthBarsEnabled.GetValue() == 0
|
|
|
|
return
|
2021-10-05 22:22:24 +00:00
|
|
|
endif
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2024-01-17 21:25:32 +00:00
|
|
|
RegisterEvents()
|
2022-08-01 01:33:22 +00:00
|
|
|
|
2022-08-10 20:21:49 +00:00
|
|
|
Utility.Wait(FadeOutDuration / 1000.0 + 1.0)
|
2022-08-01 01:33:22 +00:00
|
|
|
|
2021-10-05 22:22:24 +00:00
|
|
|
int i = _currentlyDisplayedActors.Length
|
2021-10-05 22:15:58 +00:00
|
|
|
While i > 0
|
2022-08-01 01:33:22 +00:00
|
|
|
i -= 1
|
2021-10-05 22:22:24 +00:00
|
|
|
Actor akActor = _currentlyDisplayedActors[i] as Actor
|
2024-02-11 19:27:09 +00:00
|
|
|
If ! akActor || akActor.GetFormID() == 0 || akActor.IsDeleted() || akActor.IsDisabled() || ! akActor.IsInCombat()
|
2021-10-05 22:15:58 +00:00
|
|
|
_currentlyDisplayedActors[i] = None
|
2021-10-05 22:22:24 +00:00
|
|
|
else
|
|
|
|
AddActorRaw(akActor)
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
|
|
|
EndWhile
|
|
|
|
|
2022-08-10 20:21:49 +00:00
|
|
|
Actor[] aFollowers = EnderalFunctions.GetPlayerFollowers()
|
|
|
|
i = aFollowers.length
|
|
|
|
while i > 0
|
|
|
|
i -= 1
|
|
|
|
if aFollowers[i] && _currentlyDisplayedActors.find(aFollowers[i]) < 0
|
|
|
|
AddActors(aFollowers[i])
|
2021-10-05 22:22:24 +00:00
|
|
|
endif
|
2022-08-10 20:21:49 +00:00
|
|
|
endwhile
|
|
|
|
|
2021-10-05 22:22:24 +00:00
|
|
|
Endevent
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2024-01-17 21:25:32 +00:00
|
|
|
function RegisterEvents()
|
|
|
|
|
|
|
|
if _currentlyDisplayedActors.length == 0
|
|
|
|
_currentlyDisplayedActors = new Form[4]
|
|
|
|
endif
|
|
|
|
|
|
|
|
UI.Invoke(HUD_MENU, WidgetRoot + ".removeAllActors")
|
|
|
|
RegisterForModEvent("Enderal_ShowActorHealth", "AddActors")
|
|
|
|
RegisterForModEvent("Enderal_HideActorHealth", "RemoveActors")
|
|
|
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function UnregisterEvents()
|
|
|
|
UI.Invoke(HUD_MENU, WidgetRoot + ".removeAllActors")
|
|
|
|
UnregisterForModEvent("Enderal_ShowActorHealth")
|
|
|
|
UnregisterForModEvent("Enderal_HideActorHealth")
|
|
|
|
endfunction
|
|
|
|
|
2021-10-05 22:15:58 +00:00
|
|
|
Function UpdateWidgetScale()
|
|
|
|
UI.InvokeFloat(HUD_MENU, WidgetRoot + ".setScale", _scale * 100.0)
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function UpdateMaxEntries()
|
|
|
|
UI.InvokeInt(HUD_MENU, WidgetRoot + ".setEntryCount", _maxEntries)
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function UpdateFadeInDuration()
|
|
|
|
UI.InvokeFloat(HUD_MENU, WidgetRoot + ".setFadeInDuration", _fadeInDuration / 1000.0)
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function UpdateFadeOutDuration()
|
|
|
|
UI.InvokeFloat(HUD_MENU, WidgetRoot + ".setFadeOutDuration", _fadeOutDuration / 1000.0)
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function UpdateMoveDuration()
|
|
|
|
UI.InvokeFloat(HUD_MENU, WidgetRoot + ".setMoveDuration", _moveDuration / 1000.0)
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function UpdateRemoveDuration()
|
|
|
|
UI.InvokeFloat(HUD_MENU, WidgetRoot + ".setRemoveDuration", _removeDuration)
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function AddActors(Form aForm)
|
2022-08-01 01:33:22 +00:00
|
|
|
if ! aForm
|
|
|
|
return
|
|
|
|
endif
|
2022-08-10 20:21:49 +00:00
|
|
|
AddActorRaw(aForm)
|
2021-10-05 22:22:24 +00:00
|
|
|
if _currentlyDisplayedActors.find(aForm) < 0
|
2022-08-10 20:21:49 +00:00
|
|
|
int i = _currentlyDisplayedActors.find(none)
|
|
|
|
if i >= 0
|
|
|
|
_currentlyDisplayedActors[i] = aForm
|
|
|
|
endif
|
2021-10-05 22:15:58 +00:00
|
|
|
;we do not have enough place in the array - the added actor will not be save game persistent
|
2021-10-05 22:22:24 +00:00
|
|
|
endif
|
2021-10-05 22:15:58 +00:00
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function RemoveActors(Form aForm)
|
2022-08-01 01:33:22 +00:00
|
|
|
if ! aForm
|
|
|
|
return
|
|
|
|
endif
|
2022-08-10 20:21:49 +00:00
|
|
|
RemoveActorRaw(aForm)
|
2021-10-05 22:15:58 +00:00
|
|
|
int i = _currentlyDisplayedActors.find(aForm)
|
|
|
|
if i >= 0
|
|
|
|
_currentlyDisplayedActors[i] = None
|
|
|
|
Endif
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function AddActorRaw(Form aActor)
|
|
|
|
UI.InvokeForm(HUD_MENU, WidgetRoot + ".addPanelActors", aActor)
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function RemoveActorRaw(Form aActor)
|
|
|
|
UI.InvokeForm(HUD_MENU, WidgetRoot + ".removePanelActors", aActor)
|
|
|
|
EndFunction
|
2024-01-17 21:25:32 +00:00
|
|
|
|
|
|
|
GlobalVariable Property _00E_ActorHealthBarsEnabled Auto
|