Scriptname _00E_PlayerSetUpScript extends ObjectReference  
{Initializes all the necessary Quests, maintains the player, contains various OnPlayerLoadGame() failsafes}

Float Property CURRENT_PATCH_VERSION = 2.09 AutoReadOnly


;=====================================================================================
;              							EVENTS                  					 
;=====================================================================================

Event OnInit()
	
	; needs the IsInMenuMode() check to prevent stuck messages when FS is not loaded
	While Utility.IsInMenuMode()
		Utility.WaitMenuMode(0.1)
	EndWhile
	
	CheckIfForgottenStoriesIsLoaded()
	
	If self == (PlayerREF as ObjectReference)
		
		If fPatchVersion == 0.00
			fPatchVersion = CURRENT_PATCH_VERSION
		EndIf
		
		GoToState("RealPlayer")
		PlayerREF.SetActorValue("speedMult", 95)
		PlayerREF.SetActorValue("Healrate", 0)
		
		EnableDisableKillmove()
		
		AddPerks()
	
		DisableRegularWaiting()
		StartQuests(QuestsToStart)
		
	EndIf

EndEvent

Event OnPlayerLoadGame()
	If self == (PlayerREF as ObjectReference) ; A check just in case. Most likely this condition is always True
		CheckIfForgottenStoriesIsLoaded()
		Maintenance()
		If GetState() != "RealPlayer" ; Post-1.2.5.0 version update
			GoToState("RealPlayer")
		EndIf
	EndIf
EndEvent

State RealPlayer

	;/ Event OnBeginState()
		Debug.Trace(self + ": OnBeginState RealPlayer")
	EndEvent /;

EndState


;=====================================================================================
;              							 FUNCTIONS                    					 
;=====================================================================================

Function CheckIfForgottenStoriesIsLoaded()
	
	; function that quits back to the main menu when the Enderal - Forgotten Stories.esm is not not being added to the plugins.txt
	; and hence not being loaded in-game. Unknown reason, probably write protection issues	
	
	If Game.GetModByName("Enderal - Forgotten Stories.esm") == 255
		bFSWasNotLoadedBefore = true
		_00E_Game_ForgottenStoriesNotLoaded.Show()
		Game.QuitToMainMenu()
	Else
		If bFSWasNotLoadedBefore == true
			AddPerks()
			If FSQuestsToStartFailsafePatch1560 == None
				FSQuestsToStartFailsafePatch1560 = Game.GetFormFromFile(0x0102F4B0, "Enderal - Forgotten Stories.esm") as FormList
			EndIf
			StartQuests(FSQuestsToStartFailsafePatch1560)
			bFSWasNotLoadedBefore = false
		EndIf
	EndIf

EndFunction

;=====================================================================================
;              							 1.5.8.0                   					 
;=====================================================================================

Function AddPerks()
	
	; adds the new Balancing perks for alchemy potions to the player, this is needed because of the changes with the Lycantroph
	PlayerREF.AddPerk(_00E_FS_Alchemy_BalancingPerk)
	PlayerREF.AddPerk(_00E_FS_Alchemy_BalancingPerk_RestorePotions)
	
EndFunction

Function DisableRegularWaiting()
{Disables regular waiting by adding the no-wait ability}

	PlayerREF.AddSpell(_00E_AbBlockWaiting, False)

EndFunction

Function StartQuests(Formlist QuestList)
	
	; starts all quests that are in the formlist
	Int iIndex = QuestList.GetSize() 
	While iIndex
		iIndex -= 1
		Quest  kQuest = QuestList.GetAt(iIndex) as Quest
		kQuest.Start()
	endwhile
	
EndFunction


;=====================================================================================
;              							 2.0.6
;=====================================================================================

Function UpdateMQ12b_206()
	_00E_MQ12b_Functions MQ12bFunctions = Game.GetFormFromFile(0x0002EBAD, "Skyrim.esm") as _00E_MQ12b_Functions
	Quest MQ15 = Game.GetFormFromFile(0x0002EBB0, "Skyrim.esm") as Quest
	If MQ12bFunctions.GetStage() >= 135 && MQ15.GetStage() < 5
		MQ12bFunctions.OldReenableDisabledNPC()
	EndIf
EndFunction


;=====================================================================================
;              							 2.0.8
;=====================================================================================

Function Update_208()
	; Obsolete abilities cleanup
	_00E_FS_NQ07_Functions FS_NQ07_Quest = Game.GetFormFromFile(0x0001CA09, "Enderal - Forgotten Stories.esm") as _00E_FS_NQ07_Functions
	Int iFS_NQ07Stage = FS_NQ07_Quest.GetStage()
	If iFS_NQ07Stage >= 5 && iFS_NQ07Stage < 410
		FS_NQ07_Quest.UpdateAarosCarryTraySpell()
	Else
		RemoveObsoleteSpell(0x0009A893, "Skyrim.esm", 0x000F649A, "Skyrim.esm")
	EndIf

	RemoveObsoleteSpell(0x0010D339, "Skyrim.esm", 0x000F649A, "Skyrim.esm")
	RemoveObsoleteSpell(0x0006FFAF, "Skyrim.esm", 0x000F6498, "Skyrim.esm")
	RemoveObsoleteSpell(0x000F64A0, "Skyrim.esm", 0x000F6498, "Skyrim.esm")

	; Refill _00E_AnimTest_SC package arrays where needed
	FillAnimTestPackages(0x00137889, "Skyrim.esm", 0x00070657, "Skyrim.esm")
	FillAnimTestPackages(0x0013788A, "Skyrim.esm", 0x00070657, "Skyrim.esm")
	FillAnimTestPackages(0x0013789F, "Skyrim.esm", 0x00070657, "Skyrim.esm")
	FillAnimTestPackages(0x001378A2, "Skyrim.esm", 0x00070657, "Skyrim.esm")
	FillAnimTestPackages(0x001378AA, "Skyrim.esm", 0x00070657, "Skyrim.esm")
	FillAnimTestPackages(0x001378AB, "Skyrim.esm", 0x00070657, "Skyrim.esm")
	FillAnimTestPackages(0x00147E12, "Skyrim.esm", 0x00070657, "Skyrim.esm")
	FillAnimTestPackages(0x00147E14, "Skyrim.esm", 0x00070657, "Skyrim.esm")
	
	FillAnimTestPackages(0x0010D336, "Skyrim.esm", 0x00070645, "Skyrim.esm")
	FillAnimTestPackages(0x0010D33B, "Skyrim.esm", 0x00070645, "Skyrim.esm")
	FillAnimTestPackages(0x00147DEA, "Skyrim.esm", 0x00070645, "Skyrim.esm")
	FillAnimTestPackages(0x00147E37, "Skyrim.esm", 0x00070645, "Skyrim.esm")

	; "Gypsy minstrels" update
	Keyword performSpotKwd = Game.GetFormFromFile(0x000FB905, "Skyrim.esm") as Keyword
	(Game.GetFormFromFile(0x00044EBC, "Skyrim.esm") as _00E_BardPlayInstrumentScript).LinkedPlayMarkerKeyword = performSpotKwd

	(Game.GetFormFromFile(0x00046D79, "Skyrim.esm") as _00E_GypsyMinstrelsControlScript).UpdateWaypoint()
EndFunction

Function RemoveObsoleteSpell(Int idNPC, String esmNPC, Int idSpell, String esmSpell)
	Spell obsoleteSpell = Game.GetFormFromFile(idSpell, esmSpell) as Spell
	(Game.GetFormFromFile(idNPC, esmNPC) as Actor).RemoveSpell(obsoleteSpell)
EndFunction

Function FillAnimTestPackages(Int idNPC, String esmNPC, Int idPackage, String esmPackage)
	Package newPackage = Game.GetFormFromFile(idPackage, esmPackage) as Package
	(Game.GetFormFromFile(idNPC, esmNPC) as _00E_AnimTest_SC).UpdateFillPackages(newPackage)
EndFunction


;=====================================================================================
;              							 2.0.9
;=====================================================================================

Function Update_209()
	Spell abSoulcaller = Game.GetFormFromFile(0x002F0EA, "Enderal - Forgotten Stories.esm") as Spell
	If PlayerREF.HasSpell(abSoulcaller)
		PlayerREF.RemoveSpell(abSoulcaller)
		Utility.Wait(1)
		PlayerREF.AddSpell(abSoulcaller, False)
	EndIf

	Perk perkBloodlust = Game.GetFormFromFile(0x00069D38, "Skyrim.esm") as Perk
	_ResetPerk(perkBloodlust)

	_00E_PlayerhousingMaster.GetMaster().Update_209()

	; Previous versions may have silence tracks stuck
	Levelsystem.RemoveSilence()
EndFunction


;=====================================================================================
;              							 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") == 1)
		KillMove.SetValueInt(0)
	ElseIf (Utility.GetINIBool("bVATSDisable:VATS") == 0)
		KillMove.SetValueInt(1)
	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.GetFormFromFile(0x00033A5B, "Skyrim.esm") as _00E_MQ05Prologue_Functions
	EndIf
	MQ05PrologueFunctions.FillEmptyAliasesFailsafe()

EndFunction

Function RefreshMountNamesOnLoad()

	_00E_NQ06_Functions NQ06Functions = Game.GetFormFromFile(0x000725BA,"Skyrim.esm") 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

Function FixMoreAffinitiesMod()
{Fixes "More Affinites" mod missing properties in the Levelsystem scripts}

	_00E_QuestFunctions QuestFunctionsScript = (Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") as Quest) as _00E_QuestFunctions
	If QuestFunctionsScript._00E_RemoveAllItems_TrashContainer == NONE

		Debug.Messagebox("Found broken scripts caused by mod >>More Affinities<<. Press OK to fix scripts.")
		_00E_ConfigMenu ConfigMenuScript = (Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") as Quest) as _00E_ConfigMenu
		ConfigMenuScript.controlQuest = (Game.GetFormFromFile(0x0101EC71, "Enderal - Forgotten Stories.esm") as Quest) as _FS_Phasmalist_ControlQuest
		ConfigMenuScript._00E_ConfigMenu_DisableCraftingTutorials = Game.GetFormFromFile(0x00046D8E, "Skyrim.esm") as Message
		ConfigMenuScript._00E_ConfigMenu_DisableMenuTutorials = Game.GetFormFromFile(0x00046D8A, "Skyrim.esm") as Message
		ConfigMenuScript._00E_ConfigMenu_DisableOtherTutorials = Game.GetFormFromFile(0x00046D8F, "Skyrim.esm") as Message
		ConfigMenuScript._00E_ConfigMenu_DisableQuestTutorials = Game.GetFormFromFile(0x00046D8C, "Skyrim.esm") as Message
		ConfigMenuScript._00E_ConfigMenu_DisableReadAloudBooks = Game.GetFormFromFile(0x0102E982, "Enderal - Forgotten Stories.esm") as Message
		ConfigMenuScript._00E_ConfigMenu_DisableSkillTutorials = Game.GetFormFromFile(0x00046D8D, "Skyrim.esm") as Message
		ConfigMenuScript._00E_ConfigMenu_GameplayOptions = Game.GetFormFromFile(0x0102F1BC, "Enderal - Forgotten Stories.esm") as Message
		ConfigMenuScript._00E_ConfigMenu_Meditate = Game.GetFormFromFile(0x00046D98, "Skyrim.esm") as Message
		ConfigMenuScript._00E_ConfigMenu_OtherOptions = Game.GetFormFromFile(0x00046D89, "Skyrim.esm") as Message
		ConfigMenuScript._00E_ConfigMenu_VideoSkip = Game.GetFormFromFile(0x0102E983, "Enderal - Forgotten Stories.esm") as Message
		ConfigMenuScript._00E_DisableCraftingTutorials = Game.GetFormFromFile(0x00046D90, "Skyrim.esm") as GlobalVariable
		ConfigMenuScript._00E_DisableMenuTutorials = Game.GetFormFromFile(0x00046D8B, "Skyrim.esm") as GlobalVariable
		ConfigMenuScript._00E_DisableOtherTutorials = Game.GetFormFromFile(0x00046D93, "Skyrim.esm") as GlobalVariable
		ConfigMenuScript._00E_DisableQuestTutorials = Game.GetFormFromFile(0x00046D92, "Skyrim.esm") as GlobalVariable
		ConfigMenuScript._00E_DisableReadAloudBooks = Game.GetFormFromFile(0x0102E984, "Enderal - Forgotten Stories.esm") as GlobalVariable
		ConfigMenuScript._00E_DisableSkillTutorials = Game.GetFormFromFile(0x00046D91, "Skyrim.esm") as GlobalVariable
		ConfigMenuScript._00E_FS_ConfigMenu_Mount_Teleport = Game.GetFormFromFile(0x0102F1B9, "Enderal - Forgotten Stories.esm") as Message
		ConfigMenuScript._00E_FS_ConfigMenu_Phasmalist_Teleport = Game.GetFormFromFile(0x0101F2B6, "Enderal - Forgotten Stories.esm") as Message
		ConfigMenuScript._00E_FS_IsForgottenStoriesActivated = Game.GetFormFromFile(0x0004320E, "Skyrim.esm") as GlobalVariable
		ConfigMenuScript._00E_HorseFlute_New = ((Game.GetFormFromFile(0x000725BA, "Skyrim.esm") as Quest).GetAliasByName("HorseFlute")) as _00E_Horseflute_SC
		ConfigMenuScript._00E_VideoSkip = Game.GetFormFromFile(0x0102E985, "Enderal - Forgotten Stories.esm") as GlobalVariable
	
	
		QuestFunctionsScript.BastionPerks = Game.GetFormFromFile(0x0006686B, "Skyrim.esm") as Formlist
		QuestFunctionsScript.DerwishPerks = Game.GetFormFromFile(0x0006686D, "Skyrim.esm") as Formlist
		QuestFunctionsScript.ElementalismPerks = Game.GetFormFromFile(0x00066875, "Skyrim.esm") as Formlist
		QuestFunctionsScript.EspionagePerks = Game.GetFormFromFile(0x00066889, "Skyrim.esm") as Formlist
		QuestFunctionsScript.GameHour = Game.GetFormFromFile(0x00000038, "Skyrim.esm") as GlobalVariable
		QuestFunctionsScript.Gold001 = Game.GetFormFromFile(0x0000000f, "Skyrim.esm") as MiscObject
		QuestFunctionsScript.LifeAndDeathPerks = Game.GetFormFromFile(0x00066873, "Skyrim.esm") as Formlist
		QuestFunctionsScript.MAGIllusionCharm = Game.GetFormFromFile(0x00075805, "Skyrim.esm") as Sound
		QuestFunctionsScript.ManipulationPerks = Game.GetFormFromFile(0x0006686A, "Skyrim.esm") as Formlist
		QuestFunctionsScript.PlayerSkillMenu = ((Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") as Quest).GetAliasByName("Player") as Alias)  as _00E_Game_SkillmenuSC
		QuestFunctionsScript.RagePerks = Game.GetFormFromFile(0x00066887, "Skyrim.esm") as Formlist
		QuestFunctionsScript.SympathyEsme = Game.GetFormFromFile(0x0102A498, "Enderal - Forgotten Stories.esm") as GlobalVariable
		QuestFunctionsScript.TrickeryPerks = Game.GetFormFromFile(0x0006687F, "Skyrim.esm") as Formlist
		QuestFunctionsScript.VagabondPerks = Game.GetFormFromFile(0x00066877, "Skyrim.esm") as Formlist
		QuestFunctionsScript._00E_AchievementsEnabled = Game.GetFormFromFile(0x00046F83, "Skyrim.esm") as GlobalVariable
		QuestFunctionsScript._00E_AllAmmos = Game.GetFormFromFile(0x000456C0, "Skyrim.esm") as Formlist
		QuestFunctionsScript._00E_ArmorSetScript_sSetBonusRemoved = Game.GetFormFromFile(0x00036F96, "Skyrim.esm") as Message
		QuestFunctionsScript._00E_DisableQuestTutorials = Game.GetFormFromFile(0x00046D92, "Skyrim.esm") as GlobalVariable
		QuestFunctionsScript._00E_DisableSkillTutorials = Game.GetFormFromFile(0x00046D91, "Skyrim.esm") as GlobalVariable
		QuestFunctionsScript._00E_FS_A3_AlreadyKnowThisLevel = Game.GetFormFromFile(0x0102F533, "Enderal - Forgotten Stories.esm") as Message
		QuestFunctionsScript._00E_FS_A3_NeedToLearnOtherLevels = Game.GetFormFromFile(0x0101EC7D, "Enderal - Forgotten Stories.esm") as Message
		QuestFunctionsScript._00E_FS_A3_sIn = Game.GetFormFromFile(0x00043BE0, "Skyrim.esm") as Message
		QuestFunctionsScript._00E_FS_A3_sMageClassName = Game.GetFormFromFile(0x00043BE4, "Skyrim.esm") as Message
		QuestFunctionsScript._00E_FS_A3_sRogueClassName = Game.GetFormFromFile(0x00043BE3, "Skyrim.esm") as Message
		QuestFunctionsScript._00E_FS_A3_sToUnlockThisClass = Game.GetFormFromFile(0x00043BE1, "Skyrim.esm") as Message
		QuestFunctionsScript._00E_FS_A3_sWarriorClassName = Game.GetFormFromFile(0x00043BE2, "Skyrim.esm") as Message
		QuestFunctionsScript._00E_FS_A3_sYouNeedSkillpoints = Game.GetFormFromFile(0x00043BDF, "Skyrim.esm") as Message
		QuestFunctionsScript._00E_FS_NQ02_Esme = Game.GetFormFromFile(0x0101F0D0, "Enderal - Forgotten Stories.esm") as ActorBase
		QuestFunctionsScript._00E_FS_NQR05_SlowMotionSP = Game.GetFormFromFile(0x0102E2BD, "Enderal - Forgotten Stories.esm") as Spell
		QuestFunctionsScript._00E_FS_NQR05_SlowMotion_IntroM = Game.GetFormFromFile(0x0102E2BF, "Enderal - Forgotten Stories.esm") as Sound
		QuestFunctionsScript._00E_FS_NQR05_SlowMotion_OutroM = Game.GetFormFromFile(0x0102E2C1, "Enderal - Forgotten Stories.esm") as Sound
		QuestFunctionsScript._00E_Levelsystem_sAbilityStanceQyrai = Game.GetFormFromFile(0x00046D9B, "Skyrim.esm") as Message
		QuestFunctionsScript._00E_Levelsystem_sAbilityStanceSkaragg = Game.GetFormFromFile(0x00046D9C, "Skyrim.esm") as Message
		QuestFunctionsScript._00E_PleaseRemoveMoney = Game.GetFormFromFile(0x000480DA, "Skyrim.esm") as Message
		QuestFunctionsScript._00E_RemoveAllItems_TrashContainer = Game.GetFormFromFile(0x000469E7, "Skyrim.esm") as ObjectReference
		QuestFunctionsScript._00E_SkillbookWarning = Game.GetFormFromFile(0x00031ACF, "Skyrim.esm") as Message
	
	
		_00E_Game_SkillmenuSC SkillMenuScript = ((Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") as Quest).GetAliasByName("Player") as Alias) as _00E_Game_SkillmenuSC
		SkillMenuScript._00E_FS_Game_Affinity_Spectralist = Game.GetFormFromFile(0x01029A35, "Skyrim.esm") as Message
	
	
		_00E_PlayerHousing_CellNameSC CellNameScript = ((Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") as Quest).GetAliasByName("Player") as Alias) as _00E_PlayerHousing_CellNameSC
		CellNameScript.FS_NQR03 = Game.GetFormFromFile(0x0014CEA2, "Skyrim.esm") as Quest
		CellNameScript.FS_NQR03_RhalataTemple = Game.GetFormFromFile(0x0010D1C2, "Skyrim.esm") as Cell
		CellNameScript._00E_sPlayerHouseMarketQuarterName = Game.GetFormFromFile(0x00047CA5, "Skyrim.esm") as Message
		CellNameScript._00E_sPlayerHouseNobleQuarterName = Game.GetFormFromFile(0x00047CA6, "Skyrim.esm") as Message
		CellNameScript._00E_sRhalataTempleName = Game.GetFormFromFile(0x00047C29, "Skyrim.esm") as Message
	
	
		_00E_WeatherControlScriptSC WeatherControlScript = ((Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") as Quest).GetAliasByName("Player") as Alias) as _00E_WeatherControlScriptSC
		WeatherControlScript.CapitalCityCastleWorld = Game.GetFormFromFile(0x00070729, "Skyrim.esm") as WorldSpace
		WeatherControlScript.CapitalCityLocation = Game.GetFormFromFile(0x000A1A12, "Skyrim.esm") as Location
		WeatherControlScript.MQ09 = Game.GetFormFromFile(0x0007FA91, "Skyrim.esm") as Quest
		WeatherControlScript.MQ12b = Game.GetFormFromFile(0x0002EBAD, "Skyrim.esm") as Quest
		WeatherControlScript.MQ17 = Game.GetFormFromFile(0x0007FA93, "Skyrim.esm") as Quest
		WeatherControlScript.SkyrimOvercastRain = Game.GetFormFromFile(0x000C821F, "Skyrim.esm") as Weather
		WeatherControlScript.Vyn = Game.GetFormFromFile(0x00001D3C, "Skyrim.esm") as WorldSpace
		WeatherControlScript._00E_EnderalOvercast = Game.GetFormFromFile(0x00072785, "Skyrim.esm") as Weather
		WeatherControlScript._00E_MQ11c_SilberhainDeadWeather = Game.GetFormFromFile(0x00096807, "Skyrim.esm") as GlobalVariable
		WeatherControlScript._00E_SuntempleLocations = Game.GetFormFromFile(0x0003BB5B, "Skyrim.esm") as FormList
	
		Utility.Wait(1)
		Debug.Messagebox("Scripts fixed. Make sure to save the game. Restart the client and reload the save that you just created.\n If you have set items equipped, unequip them all and re-equip them for potential set bonuses to apply.")
	EndIf

EndFunction

;=====================================================================================
;              							 MAINTENANCE                   					 
;=====================================================================================

Function Maintenance()
	
	If fPatchVersion < 1.62 && !bdoOnce
		int iButton01 = _00E_Game_OldSaves_01.Show()
		If iButton01 == 0
			Game.QuitToMainMenu()
		ElseIf iButton01 == 1
			int iButton02 = _00E_Game_OldSaves_02.Show()
			If iButton02 == 0
				Game.QuitToMainMenu()
			ElseIf iButton02 == 1
				bdoOnce = true
			EndIf
		EndIf
	ElseIf fPatchVersion >= 1.62 && fPatchVersion < CURRENT_PATCH_VERSION
		; only do this once when update 2.0.6 (SE) is applied
		If fPatchVersion < 2.06
			UpdateMQ12b_206()
		EndIf
		; only do this once when update 2.0.8 (SE) is applied
		If fPatchVersion < 2.08
			Update_208()
		EndIf
		; only do this once when update 2.0.9 (SE) is applied
		If fPatchVersion < 2.09
			Update_209()
		EndIf
		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)
	
	EnableDisableKillmove()
	
	ResetArmorWeightPerks()
	
	SetAutoSaveInterval()
	
	FailsafeMQ05PrologueAliases()
	
	RefreshMountNamesOnLoad()
	
	; fixes properties that were accidentally set to NONE by the "More Affinities" mod
	If Game.GetModByName("Enderal_FS_More_Affinities.esp") != 255
		FixMoreAffinitiesMod()
	EndIf

EndFunction

;=====================================================================================
;              							 PROPERTIES                   					 
;=====================================================================================

float fPatchVersion
bool bdoOnce = false
bool bFSWasNotLoadedBefore = false

_00E_MQ05Prologue_Functions Property MQ05PrologueFunctions Auto

Perk Property _00E_FS_Alchemy_BalancingPerk Auto
Perk Property _00E_FS_Alchemy_BalancingPerk_RestorePotions Auto

Spell Property _00E_AbBlockWaiting Auto
Actor Property PlayerREF Auto

FormList Property QuestsToStart Auto
FormList Property FSQuestsToStartFailsafePatch1560 Auto

Message Property _00E_Game_OldSaves_01 Auto
Message Property _00E_Game_OldSaves_02 Auto
Message Property _00E_Game_ForgottenStoriesNotLoaded 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