2021-10-05 22:15:58 +00:00
|
|
|
Scriptname _00E_AutoSaveSystem_Functions extends Quest
|
|
|
|
|
|
|
|
Event OnInit()
|
|
|
|
|
|
|
|
fUpdateTime = Utility.GetIniFloat("fAutosaveEveryXMins:SaveGame")
|
2023-11-28 17:14:37 +00:00
|
|
|
If fUpdateTime <= 0.0 ; just in case
|
|
|
|
fUpdateTime = 60
|
|
|
|
EndIf
|
|
|
|
|
2021-10-05 22:15:58 +00:00
|
|
|
RegisterForSingleUpdate(fUpdateTime*60)
|
|
|
|
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
Event OnUpdate()
|
|
|
|
|
|
|
|
If bAutosaveSystemStopped == false
|
|
|
|
If Utility.IsInMenuMode() == false && UI.IsTextInputEnabled() == false && UI.IsMenuOpen("Dialogue Menu") == false && PlayerREF.IsDead() == false && PlayerREF.IsInCombat() == false && Game.IsFightingControlsEnabled() == true
|
|
|
|
Game.RequestAutoSave()
|
|
|
|
RegisterForSingleUpdate(fUpdateTime*60)
|
|
|
|
Else
|
|
|
|
RegisterForSingleUpdate(5)
|
|
|
|
EndIf
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
EndEvent
|
|
|
|
|
2023-12-03 19:10:04 +00:00
|
|
|
; called from _00E_AutosaveIntervalAlias to update ini setting fAutosaveEveryXMins in case it was changed
|
2021-10-05 22:15:58 +00:00
|
|
|
Function UpdateAutoSaveInterval()
|
|
|
|
|
|
|
|
fUpdateTime = Utility.GetIniFloat("fAutosaveEveryXMins:SaveGame")
|
2023-11-28 17:14:37 +00:00
|
|
|
If fUpdateTime <= 0.0 ; just in case
|
2021-10-05 22:15:58 +00:00
|
|
|
fUpdateTime = 60
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
UnregisterForUpdate()
|
|
|
|
RegisterForSingleUpdate(fUpdateTime*60)
|
|
|
|
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function StopAutosaveSystem()
|
|
|
|
bAutosaveSystemStopped = true
|
|
|
|
UnregisterForUpdate()
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function ResumeAutosaveSystemInXMinutes(float _fMinutes = 0.0)
|
|
|
|
|
|
|
|
If _fMinutes == 0.0
|
|
|
|
_fMinutes = fUpdateTime
|
|
|
|
If _fMinutes == 0.0 ; just in case
|
|
|
|
_fMinutes = 60
|
|
|
|
EndIf
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
UnregisterForUpdate() ; just in case again
|
|
|
|
RegisterForSingleUpdate(_fMinutes*60)
|
|
|
|
bAutosaveSystemStopped = false
|
|
|
|
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
; not used yet btw / maybe will never be used
|
|
|
|
; called shortly before the end of every quest, parameter is always the quest name
|
|
|
|
Function RequestHardSave(string _sQuestName)
|
|
|
|
|
|
|
|
Utility.Wait(0.1) ; in case we are in a menu (debug message boxes / dialogue etc)
|
|
|
|
Game.SaveGame(_sQuestName)
|
|
|
|
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
bool bAutosaveSystemStopped = false
|
|
|
|
float fUpdateTime
|
|
|
|
Actor Property PlayerREF Auto
|