Scriptname _00E_PlayerSetUpScript extends ObjectReference {Initializes all the necessary Quests, maintains the player, contains various OnPlayerLoadGame() failsafes. This script is important for proper updating, do not overwrite it.} Float Property CURRENT_PATCH_VERSION = 2.13 AutoReadOnly ;===================================================================================== ; EVENTS ;===================================================================================== Event OnInit() If self != (PlayerREF as ObjectReference) return EndIf ; needs the IsInMenuMode() check to prevent stuck messages when FS is not loaded While Utility.IsInMenuMode() Utility.WaitMenuMode(0.1) EndWhile CheckForgottenStories() _00E_Func_CheckSKSE.Run() _00E_Func_CheckEnderalDLL.Run() If fPatchVersion == 0.00 fPatchVersion = CURRENT_PATCH_VERSION EndIf GoToState("RealPlayer") PlayerREF.SetActorValue("speedMult", 95) PlayerREF.SetActorValue("Healrate", 0) EnableDisableKillmove() ; starts all quests that are in the formlist Int iIndex = QuestsToStart.GetSize() While iIndex > 0 iIndex -= 1 Quest kQuest = QuestsToStart.GetAt(iIndex) as Quest kQuest.Start() endwhile If Game.GetModByName("Enderal_FS_More_Affinities.esp") != 255 Game.QuitToMainMenu() Debug.MessageBox("Enderal_FS_More_Affinities.esp is outdated and does not work with Enderal SE. Please, uninstall or update the mod.") EndIf EndEvent Event OnPlayerLoadGame() If self == (PlayerREF as ObjectReference) ; A check just in case. Most likely this condition is always True CheckForgottenStories() _00E_Func_CheckSKSE.Run() _00E_Func_CheckEnderalDLL.Run() Maintenance() If GetState() != "RealPlayer" GoToState("RealPlayer") EndIf EndIf EndEvent State RealPlayer ;/ Event OnBeginState() Debug.Trace(self + ": OnBeginState RealPlayer") EndEvent /; EndState ;===================================================================================== ; ALL UPDATES ;===================================================================================== Function EnableDisableKillmove() ; it seems like that this ini setting does not do stuff by itself (or it is bugged) ; therefore we need to read it from the file and change the global with which the killmoves are conditioned If Utility.GetINIBool("bVATSDisable:VATS") == false KillMove.SetValueInt(1) Else KillMove.SetValueInt(0) EndIf EndFunction Function SetAutoSaveInterval() ; updates the autosave interval _00E_AutoSaveSystem_Functions AutoSaveSystem_Functions = Game.GetFormFromFile(0x00048141, "Skyrim.esm") as _00E_AutoSaveSystem_Functions AutoSaveSystem_Functions.UpdateAutoSaveInterval() EndFunction Function FailsafeMQ05PrologueAliases() ; failsafe for issue 1536, fills empty aliases If MQ05PrologueFunctions == None MQ05PrologueFunctions = Game.GetForm(0x00033A5B) as _00E_MQ05Prologue_Functions EndIf MQ05PrologueFunctions.FillEmptyAliasesFailsafe() EndFunction Function RefreshMountNamesOnLoad() _00E_NQ06_Functions NQ06Functions = Game.GetForm(0x725BA) as _00E_NQ06_Functions NQ06Functions.RefreshNamesOnSaveLoad() EndFunction Function _ResetPerk(Perk p) If PlayerREF.HasPerk(p) PlayerREF.RemovePerk(p) PlayerREF.AddPerk(p) EndIf EndFunction Function ResetArmorWeightPerks() ; Perks modifying armor weights need some push on each game load to work. ; The push is needed only if the player is over-encumbered on game load. ; If the player is not over-encumbered, the push is not needed because checking the inventory, picking up items, sheathing/drawing a weapon will reset the perks anyway. If PlayerREF.IsOverEncumbered() _ResetPerk(_00E_Class_Keeper_P05_C_Conditioning) _ResetPerk(_00E_Class_Vagrant_P05_B_Lightweight) EndIf EndFunction ;===================================================================================== ; MAINTENANCE ;===================================================================================== function CheckForgottenStories() ; If Enderal - Forgotten Stories.esm is not loaded, kick the player back to main menu if (Game.GetForm(0x4320E) as GlobalVariable).GetValue() as Int != 1 Utility.wait(2.0) Game.QuitToMainMenu() Debug.MessageBox("Enderal - Forgotten Stories.esm is not loaded! The game will not run properly. Open Data Files and enable it.") return EndIf endfunction Function Maintenance() if fPatchVersion <= 2.13 Debug.MessageBox("A savegame was loaded which was made before the release of Enderal SE. In this save, several new features won't be available and there is a chance that you'll encounter grave bugs. Please, start a new game.") ;Game.QuitToMainMenu() ;return endif if fPatchVersion < CURRENT_PATCH_VERSION ; fPatchVersion = CURRENT_PATCH_VERSION endif ; changes to the actor value healrate will not persist in consecutive saves ; every time a save gets loaded the healrate needs to be set to 0, otherwise it will go back again to default at 0.7 ; this is called before active magic effects of potions or spells are applied to the player which could also alter the value PlayerREF.SetActorValue("Healrate", 0) ; Workaround for broken physics on loading saves, made on a mount If PlayerREF.IsOnMount() PlayerREF.Dismount() EndIf ; Clear stuck help messages, leaking between game loads Message.ResetHelpMessage("Clear") (Game.GetForm(0xAC80E) as Message).ShowAsHelpMessage("Clear", 0.1, 1, 1) EnableDisableKillmove() ResetArmorWeightPerks() SetAutoSaveInterval() FailsafeMQ05PrologueAliases() RefreshMountNamesOnLoad() SendModEvent("Enderal_GameLoaded") EndFunction ;===================================================================================== ; PROPERTIES ;===================================================================================== float fPatchVersion _00E_MQ05Prologue_Functions Property MQ05PrologueFunctions Auto Actor Property PlayerREF Auto FormList Property QuestsToStart Auto GlobalVariable Property KillMove Auto Perk Property _00E_Class_Keeper_P05_C_Conditioning Auto Perk Property _00E_Class_Vagrant_P05_B_Lightweight Auto _00E_QuestFunctions Property Levelsystem Auto