2021-10-05 22:15:58 +00:00
|
|
|
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
|
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
_00E_Phasmalist_NewApparitionAlias Property NewApparitionAlias Auto
|
|
|
|
_00E_Phasmalist_DespectralizeCont Property despectralizeContainerAlias Auto
|
|
|
|
_00E_Phasmalist_ApparationInventory Property spectralizeContainer Auto
|
|
|
|
_00E_Phasmalist_PlayerAliasScript Property PlayerAlias Auto
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
Quest Property FS_NQ08 Auto
|
2021-10-05 22:15:58 +00:00
|
|
|
Perk Property _00E_Class_Phasmalist_P02_CraftTier1 Auto
|
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
Shout Property _00E_Phasmalist_A3_MoveApparationToPlayerShout Auto
|
|
|
|
WordofPower Property _00E_A3_Phasmalist_MoveApparationToPlayer1 Auto
|
2021-10-05 22:15:58 +00:00
|
|
|
|
|
|
|
MiscObject Property _00E_UpdateInventoryItem auto
|
|
|
|
MiscObject Property _00E_Phasmalist_Invis_EnchantmentRequirement Auto
|
|
|
|
|
|
|
|
GlobalVariable Property _00E_PhasmalistAchievementUnlocked Auto
|
2021-10-05 22:59:59 +00:00
|
|
|
GlobalVariable Property _00E_Phasmalist_TankMode Auto
|
|
|
|
|
|
|
|
Message Property _00E_Phasmalist_NoApparitionCurrentlySummoned Auto
|
|
|
|
|
2021-10-12 02:10:35 +00:00
|
|
|
Perk Property _00E_Class_Phasmalist_P05_C_Violence_01 Auto
|
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
Actor Property PlayerREF Auto
|
|
|
|
|
|
|
|
Bool bCreatedFirstTrinket = false
|
|
|
|
|
|
|
|
Int iScriptVersion = 0
|
2023-12-06 14:34:43 +00:00
|
|
|
Int Property CURRENT_SCRIPT_VERSION = 3 AutoReadOnly
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
|
|
|
|
;=====================================================================================
|
|
|
|
; GLOBAL FUNCTIONS
|
|
|
|
;=====================================================================================
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2024-02-29 22:28:19 +00:00
|
|
|
int function _GetScriptVersion() Global
|
|
|
|
return 1
|
|
|
|
endFunction
|
|
|
|
|
2021-10-05 22:15:58 +00:00
|
|
|
; use only if necessary, if possible add _FS_Phasmalist_ControlQuest as a property!
|
2021-10-05 22:59:59 +00:00
|
|
|
_FS_Phasmalist_ControlQuest Function getControlQuest() Global
|
|
|
|
Return Game.GetFormFromFile(0x0101ec71, "Enderal - Forgotten Stories.esm") as _FS_Phasmalist_ControlQuest
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function UnsummonApparitionIfExists() Global
|
|
|
|
getControlQuest().UnsummonApparition()
|
|
|
|
EndFunction
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
Function MoveApparitionToPlayer() Global
|
|
|
|
getControlQuest().TeleportApparitionToPlayer()
|
2021-10-05 22:15:58 +00:00
|
|
|
EndFunction
|
|
|
|
|
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
;=====================================================================================
|
|
|
|
; HELPER EVENTS & FUNCTIONS
|
|
|
|
;=====================================================================================
|
|
|
|
|
|
|
|
Event OnInit()
|
|
|
|
iScriptVersion = CURRENT_SCRIPT_VERSION
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
; called on loadgame by _00E_Phasmalist_LoadGameFailsave, attached to an alias of quest abilities
|
|
|
|
Function LoadGameFailsave()
|
|
|
|
; Version update
|
|
|
|
If iScriptVersion < CURRENT_SCRIPT_VERSION
|
2023-12-06 14:34:43 +00:00
|
|
|
If iScriptVersion < 3
|
|
|
|
; Update placeholder
|
2021-10-05 22:59:59 +00:00
|
|
|
EndIf
|
|
|
|
|
|
|
|
iScriptVersion = CURRENT_SCRIPT_VERSION
|
|
|
|
EndIf
|
|
|
|
|
2023-12-06 14:34:43 +00:00
|
|
|
NewApparitionAlias.OnLoadGame()
|
2021-10-05 22:59:59 +00:00
|
|
|
|
2023-12-06 14:34:43 +00:00
|
|
|
If FS_NQ08.GetCurrentStageId() == 7
|
2021-10-05 22:59:59 +00:00
|
|
|
RegisterForModEvent("Phasmalist_Learn_Soulsmith1", "OnUnlockSoulsmithNovice")
|
|
|
|
EndIf
|
|
|
|
EndFunction
|
2021-10-05 22:15:58 +00:00
|
|
|
|
|
|
|
; Event called by _00E_Phasmalist_Soul
|
|
|
|
Function OnPlayerSoulCollected()
|
2024-01-10 14:08:24 +00:00
|
|
|
If FS_NQ08.GetCurrentStageID() == 5 || FS_NQ08.GetCurrentStageID() == 1
|
2021-10-05 22:59:59 +00:00
|
|
|
If PlayerREF.hasPerk(_00E_Class_Phasmalist_P02_CraftTier1)
|
2024-01-10 14:08:24 +00:00
|
|
|
FS_NQ08.SetCurrentStageID(10)
|
2021-10-05 22:15:58 +00:00
|
|
|
Else
|
2024-01-10 14:08:24 +00:00
|
|
|
FS_NQ08.SetCurrentStageID(7)
|
2021-10-05 22:15:58 +00:00
|
|
|
RegisterForModEvent("Phasmalist_Learn_Soulsmith1", "OnUnlockSoulsmithNovice")
|
|
|
|
EndIf
|
|
|
|
EndIf
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
; Event called by _00E_Phasmalist_Workbench
|
2021-10-05 22:59:59 +00:00
|
|
|
Function OnPlayerItemSpectralized()
|
2024-01-10 14:08:24 +00:00
|
|
|
If FS_NQ08.GetCurrentStageID() == 15
|
|
|
|
FS_NQ08.SetCurrentStageID(20)
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
2021-10-05 22:59:59 +00:00
|
|
|
EndFunction
|
2021-10-05 22:15:58 +00:00
|
|
|
|
|
|
|
; Event called by _00E_Phasmalist_TrinketSC
|
2021-10-05 22:59:59 +00:00
|
|
|
Function OnPlayerTrinketCreated()
|
|
|
|
If bCreatedFirstTrinket == False
|
|
|
|
bCreatedFirstTrinket = True
|
|
|
|
If !PlayerREF.HasSpell(_00E_Phasmalist_A3_MoveApparationToPlayerShout)
|
|
|
|
PlayerREF.AddShout(_00E_Phasmalist_A3_MoveApparationToPlayerShout)
|
2021-10-05 22:15:58 +00:00
|
|
|
Game.unlockWord(_00E_A3_Phasmalist_MoveApparationToPlayer1)
|
|
|
|
EndIf
|
|
|
|
|
2024-01-10 14:08:24 +00:00
|
|
|
If FS_NQ08.GetCurrentStageID() == 10
|
|
|
|
FS_NQ08.SetCurrentStageID(15)
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
|
|
|
|
2024-01-10 00:46:13 +00:00
|
|
|
If _00E_PhasmalistAchievementUnlocked.GetValueInt() == 0
|
2021-10-05 22:15:58 +00:00
|
|
|
_00E_PhasmalistAchievementUnlocked.SetValueInt(1)
|
2022-08-03 21:19:58 +00:00
|
|
|
Steam.UnlockAchievement("END_APPARITION_01")
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
|
|
|
EndIf
|
|
|
|
RemoveEnchantmentItem()
|
|
|
|
AddEnchantmentItem()
|
2021-10-05 22:59:59 +00:00
|
|
|
EndFunction
|
2021-10-05 22:15:58 +00:00
|
|
|
|
|
|
|
Event OnUnlockSoulsmithNovice(string eventName, string strArg, float numArg, Form sender)
|
2024-01-10 14:08:24 +00:00
|
|
|
If FS_NQ08.GetCurrentStageID() == 7
|
|
|
|
FS_NQ08.SetCurrentStageID(10)
|
2021-10-05 22:15:58 +00:00
|
|
|
UnRegisterForModEvent("Phasmalist_Learn_Soulsmith1")
|
|
|
|
EndIf
|
2021-10-05 22:59:59 +00:00
|
|
|
EndEvent
|
|
|
|
|
|
|
|
Function ForceInventoryContainerLoad(ObjectReference cont)
|
|
|
|
cont.additem(_00E_UpdateInventoryItem)
|
|
|
|
cont.removeitem(_00E_UpdateInventoryItem)
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function AddEnchantmentItem()
|
2023-12-08 02:45:53 +00:00
|
|
|
PlayerREF.AddItem(_00E_Phasmalist_Invis_EnchantmentRequirement, PlayerREF.GetActorValue("Enchanting") as int, True)
|
2021-10-05 22:59:59 +00:00
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function RemoveEnchantmentItem(Int _iDefault = 0)
|
|
|
|
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
|
2021-10-05 22:15:58 +00:00
|
|
|
|
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
;=====================================================================================
|
|
|
|
; EQUIPPED TRINKET
|
|
|
|
;=====================================================================================
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
_00E_Phasmalist_TrinketSC EquippedTrinket
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
Function OnTrinketEquipped(_00E_Phasmalist_TrinketSC trinket)
|
|
|
|
EquippedTrinket = Trinket
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function OnTrinketUnequipped(_00E_Phasmalist_TrinketSC trinket)
|
|
|
|
If trinket == EquippedTrinket
|
|
|
|
EquippedTrinket = None
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
2021-10-05 22:59:59 +00:00
|
|
|
UnsummonApparition()
|
|
|
|
EndFunction
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
_00E_Phasmalist_TrinketSC Function GetEquippedTrinket()
|
|
|
|
Return EquippedTrinket
|
|
|
|
EndFunction
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
Bool Function IsTrinketEquipped()
|
|
|
|
Return (EquippedTrinket != None)
|
|
|
|
EndFunction
|
2021-10-05 22:15:58 +00:00
|
|
|
|
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
;=====================================================================================
|
|
|
|
; APPARITION CONTROL
|
|
|
|
;=====================================================================================
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
Keyword Property _00E_Phasmalist_NoSummonLocation Auto
|
|
|
|
Keyword Property _00E_Phasmalist_NoSummonLocationTown Auto
|
|
|
|
Perk Property _00E_Class_Phasmalist_P08_B_PhasmalicVeil Auto
|
|
|
|
|
|
|
|
Int CurrentSummonState = 0
|
|
|
|
|
|
|
|
Int Property SUMMON_STATE_IDLE = 0 AutoReadOnly
|
|
|
|
Int Property SUMMON_STATE_SUMMONING = 1 AutoReadOnly
|
|
|
|
Int Property SUMMON_STATE_UNSUMMONING = 2 AutoReadOnly
|
|
|
|
Int Property SUMMON_STATE_BUSY = 3 AutoReadOnly
|
|
|
|
|
|
|
|
Bool Function IsBadApparitionLocation(Location loc)
|
|
|
|
If loc
|
|
|
|
If loc.HasKeyword(_00E_Phasmalist_NoSummonLocation)
|
|
|
|
Return True
|
|
|
|
ElseIf loc.HasKeyword(_00E_Phasmalist_NoSummonLocationTown) && PlayerREF.HasPerk(_00E_Class_Phasmalist_P08_B_PhasmalicVeil) == False
|
|
|
|
Return True
|
|
|
|
EndIf
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
2021-10-05 22:59:59 +00:00
|
|
|
|
|
|
|
Return False
|
2021-10-05 22:15:58 +00:00
|
|
|
EndFunction
|
|
|
|
|
2021-10-05 22:59:59 +00:00
|
|
|
Actor Function GetApparitionRef()
|
2023-12-08 02:57:30 +00:00
|
|
|
Return NewApparitionAlias.GetActorReference()
|
2021-10-05 22:59:59 +00:00
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Actor Function GetApparitionFailsafeRef()
|
|
|
|
If CurrentSummonState == SUMMON_STATE_UNSUMMONING
|
|
|
|
Return None
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
2021-10-05 22:59:59 +00:00
|
|
|
Return NewApparitionAlias.AliasFailsafeRef
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Bool Function IsApparitionSpawned()
|
2023-12-08 02:57:30 +00:00
|
|
|
If NewApparitionAlias.GetActorReference()
|
2021-10-05 22:59:59 +00:00
|
|
|
Return (CurrentSummonState != SUMMON_STATE_UNSUMMONING) ; It exists and is not being unsummoned
|
|
|
|
Else
|
|
|
|
Return (CurrentSummonState == SUMMON_STATE_SUMMONING) ; It's not there yet but spawning
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
2021-10-05 22:59:59 +00:00
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Bool Function IsApparitionChangingSummonStatus()
|
|
|
|
Return (CurrentSummonState == SUMMON_STATE_SUMMONING || CurrentSummonState == SUMMON_STATE_UNSUMMONING)
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function SummonApparition(ObjectReference placeAtRef, Bool bPhasmalismTankMode = False, Bool bSilent = False)
|
|
|
|
If _TryLockSummonState(SUMMON_STATE_SUMMONING) == False
|
|
|
|
Return
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
UnregisterTeleportKey()
|
|
|
|
|
|
|
|
If bPhasmalismTankMode && bSilent == False
|
|
|
|
bSilent = True
|
|
|
|
NewApparitionAlias.PlaySummonExplosion(placeAtRef)
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
; Unsummon previous apparition
|
|
|
|
If NewApparitionAlias.GetRef() != None
|
|
|
|
NewApparitionAlias.Unsummon(bSilent)
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
; Create new apparition
|
|
|
|
_00E_Phasmalist_TrinketSC trinket = GetEquippedTrinket()
|
|
|
|
If trinket
|
|
|
|
Actor summonedRef = placeAtRef.placeAtMe(trinket.connectedApparation, abInitiallyDisabled = True) as Actor
|
|
|
|
If summonedRef
|
|
|
|
NewApparitionAlias.ForceRefTo(summonedRef)
|
|
|
|
NewApparitionAlias.Summon(trinket, placeAtRef, bPhasmalismTankMode, bSilent)
|
|
|
|
EndIf
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
RegisterTeleportKey()
|
|
|
|
|
|
|
|
_UnlockSummonState()
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function UnsummonApparition(Bool bSilent = False)
|
|
|
|
If _TryLockSummonState(SUMMON_STATE_UNSUMMONING)
|
|
|
|
UnregisterTeleportKey()
|
|
|
|
If NewApparitionAlias.GetRef() != None
|
|
|
|
NewApparitionAlias.Unsummon(bSilent)
|
|
|
|
EndIf
|
|
|
|
RegisterTeleportKey()
|
|
|
|
|
|
|
|
_UnlockSummonState()
|
|
|
|
EndIf
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function TeleportApparitionToPlayer(Bool bTeleportInFront = False, Bool bSilent = False)
|
|
|
|
If _TryLockSummonState(SUMMON_STATE_BUSY)
|
|
|
|
NewApparitionAlias.TeleportToPlayer(bTeleportInFront, bSilent)
|
|
|
|
_UnlockSummonState()
|
|
|
|
EndIf
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function SetApparitionCombatStyle(CombatStyle newCombatStyle)
|
|
|
|
If _TryLockSummonState(SUMMON_STATE_BUSY)
|
|
|
|
NewApparitionAlias.SetCombatStyle(newCombatStyle)
|
|
|
|
_UnlockSummonState()
|
|
|
|
EndIf
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function ShowApparitionStats()
|
|
|
|
If _TryLockSummonState(SUMMON_STATE_BUSY)
|
|
|
|
NewApparitionAlias.ShowStatsMenu()
|
|
|
|
_UnlockSummonState()
|
|
|
|
EndIf
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function ShowApparitionEquipment()
|
|
|
|
If _TryLockSummonState(SUMMON_STATE_BUSY)
|
|
|
|
NewApparitionAlias.ShowEquipment()
|
|
|
|
_UnlockSummonState()
|
|
|
|
EndIf
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function TransformApparitionToWerewolf(Actor akSpellTarget)
|
|
|
|
If _TryLockSummonState(SUMMON_STATE_BUSY)
|
|
|
|
NewApparitionAlias.TransformToWerewolf(akSpellTarget)
|
|
|
|
_UnlockSummonState()
|
|
|
|
EndIf
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function TransformApparitionFromWerewolf(Actor akSpellTarget)
|
|
|
|
If _TryLockSummonState(SUMMON_STATE_BUSY)
|
|
|
|
NewApparitionAlias.TransformFromWerewolf(akSpellTarget, False, False)
|
|
|
|
_UnlockSummonState()
|
|
|
|
EndIf
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Bool Function _TryLockSummonState(Int newSummonState)
|
|
|
|
While CurrentSummonState != SUMMON_STATE_IDLE
|
|
|
|
If newSummonState == SUMMON_STATE_BUSY || newSummonState == SUMMON_STATE_UNSUMMONING
|
|
|
|
; There's no point to do newSummonState if the apparition is being unsummoned
|
|
|
|
If CurrentSummonState == SUMMON_STATE_UNSUMMONING
|
|
|
|
Return False
|
|
|
|
EndIf
|
|
|
|
EndIf
|
|
|
|
Utility.WaitMenuMode(0.1)
|
|
|
|
EndWhile
|
|
|
|
|
|
|
|
CurrentSummonState = newSummonState
|
|
|
|
Return True
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function _UnlockSummonState()
|
|
|
|
CurrentSummonState = SUMMON_STATE_IDLE
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
|
|
|
|
;=====================================================================================
|
|
|
|
; CALL APPARITION KEY
|
|
|
|
;=====================================================================================
|
|
|
|
|
|
|
|
Int Property iTeleportApparitionKeyCode = 34 Auto Hidden
|
|
|
|
|
|
|
|
Location Property _00E_Dreamworld_Location Auto
|
|
|
|
|
|
|
|
Function ChangeTeleportKey(int iKeyCode)
|
|
|
|
UnregisterTeleportKey()
|
|
|
|
iTeleportApparitionKeyCode = iKeyCode
|
|
|
|
RegisterTeleportKey()
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function RegisterTeleportKey()
|
|
|
|
If iTeleportApparitionKeyCode != 0
|
|
|
|
RegisterForKey(iTeleportApparitionKeyCode)
|
|
|
|
EndIf
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function UnregisterTeleportKey()
|
|
|
|
If iTeleportApparitionKeyCode != 0
|
|
|
|
UnregisterForKey(iTeleportApparitionKeyCode)
|
|
|
|
EndIf
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Event OnKeyDown(int iKeyCode)
|
|
|
|
If iKeyCode == iTeleportApparitionKeyCode
|
|
|
|
UnregisterTeleportKey()
|
|
|
|
If Utility.IsInMenuMode() == False && UI.IsTextInputEnabled() == False && Game.IsFightingControlsEnabled() && UI.IsMenuOpen("Dialogue Menu") == False && PlayerREF.GetCurrentLocation() != _00E_Dreamworld_Location
|
|
|
|
If IsApparitionSpawned() == False || _00E_Phasmalist_TankMode.GetValue() != 0
|
|
|
|
_00E_Phasmalist_NoApparitionCurrentlySummoned.Show()
|
|
|
|
Else
|
|
|
|
TeleportApparitionToPlayer(True)
|
|
|
|
EndIf
|
|
|
|
EndIf
|
|
|
|
RegisterTeleportKey()
|
|
|
|
EndIf
|
|
|
|
EndEvent
|