Scriptname _FS_Phasmalist_ControlQuest extends Quest ; the main phasmalist quest that aggregates references to the aliases who do the main work and provides a global interface for some utility functions _00E_Phasmalist_ApparationAlias Property apparationAlias auto _00E_Phasmalist_DespectralizeCont Property despectralizeContainerAlias auto _00E_Phasmalist_ApparationInventory Property spectralizeContainer auto Quest Property FS_NQ08 auto Perk Property _00E_Class_Phasmalist_P02_CraftTier1 Auto Shout Property _00E_Phasmalist_A3_MoveApparationToPlayerShout auto WordofPower Property _00E_A3_Phasmalist_MoveApparationToPlayer1 auto MiscObject Property _00E_UpdateInventoryItem auto MiscObject Property _00E_Phasmalist_Invis_EnchantmentRequirement Auto GlobalVariable Property _00E_AchievementsEnabled Auto GlobalVariable Property _00E_PhasmalistAchievementUnlocked Auto bool bCreatedFirstTrinket = false ; use only if necessary, if possible add _FS_Phasmalist_ControlQuest as a property! _FS_Phasmalist_ControlQuest function getControlQuest() global return Game.GetFormFromFile(0x0101ec71, "Enderal - Forgotten Stories.esm") as _FS_Phasmalist_ControlQuest Endfunction ; use only if necessary, if possible add _FS_Phasmalist_AffinityControlQuest as a property! _FS_Phasmalist_AffinityControlQuest function getAffinityControlQuest() global return ((getControlQuest() as Quest) as _FS_Phasmalist_AffinityControlQuest) EndFunction function unsummonApparationIfExists() global getControlQuest().apparationAlias.unsummonIfExists() Endfunction function moveApparationToPlayer() global getControlQuest().apparationAlias.teleportToPlayer() Endfunction ; Event called by _00E_Phasmalist_Soul Function OnPlayerSoulCollected() If FS_NQ08.getStage() == 5 || FS_NQ08.getStage() == 1 If Game.getPlayer().hasPerk(_00E_Class_Phasmalist_P02_CraftTier1) FS_NQ08.setStage(10) Else FS_NQ08.setStage(7) RegisterForModEvent("Phasmalist_Learn_Soulsmith1", "OnUnlockSoulsmithNovice") EndIf EndIf EndFunction ; Event called by _00E_Phasmalist_Workbench function OnPlayerItemSpectralized() If FS_NQ08.getStage() == 15 FS_NQ08.setStage(20) EndIf Endfunction ; Event called by _00E_Phasmalist_TrinketSC function OnPlayerTrinketCreated() If bCreatedFirstTrinket == false Actor Player = Game.GetPlayer() bCreatedFirstTrinket = true If !Player.HasSpell(_00E_Phasmalist_A3_MoveApparationToPlayerShout) Player.addShout(_00E_Phasmalist_A3_MoveApparationToPlayerShout) Game.unlockWord(_00E_A3_Phasmalist_MoveApparationToPlayer1) EndIf If FS_NQ08.getStage() == 10 FS_NQ08.setStage(15) EndIf If _00E_AchievementsEnabled.GetValueInt() == 1 && _00E_PhasmalistAchievementUnlocked.GetValueInt() == 0 _00E_PhasmalistAchievementUnlocked.SetValueInt(1) Game.UnlockAchievement("END_APPARITION_01") EndIf EndIf RemoveEnchantmentItem() AddEnchantmentItem() Endfunction Event OnUnlockSoulsmithNovice(string eventName, string strArg, float numArg, Form sender) If FS_NQ08.getStage() == 7 FS_NQ08.setStage(10) UnRegisterForModEvent("Phasmalist_Learn_Soulsmith1") EndIf Endevent function OnPlayerApparationSummoned() ; currently do nothing Endfunction ; called on loadgame by _00E_Phasmalist_LoadGameFailsave, attached to an alias of quest abilities function LoadGameFailsave() apparationAlias.failsaveRefillOnLoad() apparationAlias.initNotPersistentStats() If FS_NQ08.getStage() == 7 RegisterForModEvent("Phasmalist_Learn_Soulsmith1", "OnUnlockSoulsmithNovice") EndIf ((self as Quest) as _FS_Phasmalist_AffinityControlQuest).OnGameLoad() Endfunction function forceInventoryContainerLoad(ObjectReference cont) cont.additem(_00E_UpdateInventoryItem) cont.removeitem(_00E_UpdateInventoryItem) Endfunction Function AddEnchantmentItem() Actor PlayerREF = Game.GetPlayer() float fEnchantment = PlayerREF.GetActorValue("Enchanting") If _00E_Phasmalist_Invis_EnchantmentRequirement == None _00E_Phasmalist_Invis_EnchantmentRequirement = Game.GetFormFromFile(0x020020C2, "Till-PR135.esp") as MiscObject EndIf PlayerREF.AddItem(_00E_Phasmalist_Invis_EnchantmentRequirement, fEnchantment as int, true) EndFunction Function RemoveEnchantmentItem(int _iDefault = 0) If _00E_Phasmalist_Invis_EnchantmentRequirement == None _00E_Phasmalist_Invis_EnchantmentRequirement = Game.GetFormFromFile(0x020020C2, "Till-PR135.esp") as MiscObject EndIf Actor PlayerREF = Game.GetPlayer() If _iDefault > 0 PlayerREF.RemoveItem(_00E_Phasmalist_Invis_EnchantmentRequirement, _iDefault, true) Else PlayerREF.RemoveItem(_00E_Phasmalist_Invis_EnchantmentRequirement, PlayerREF.GetItemCount(_00E_Phasmalist_Invis_EnchantmentRequirement), true) EndIf EndFunction