enderalse/scripts/source/_00e_phasmalist_workbench.psc

258 lines
9.6 KiB
Plaintext
Raw Normal View History

Scriptname _00E_Phasmalist_Workbench extends ObjectReference
; script that is attached to all phasmalist workbenches and manages their gui and functions
Message Property illegalTrinket auto
{Message objects whose title is the message that is displayed when the player tries to summon an apparation but wears no phasmalist trinket object}
Message Property reallyDespectralize auto
_FS_Phasmalist_ControlQuest Property phasmalistControlQuest auto
ObjectReference Property spectralizerContainer auto
{the container items that should be spectralized are put in; should be the same for all workbenches}
ObjectReference Property _00E_Phasmalist_DespectralizingContainerReference auto
Keyword Property _00E_Phasmalist_CraftingWorkbench_NPCMarker auto
Actor Property PlayerREF Auto
Message Property _00E_Theriantrophist_CantCraftMSG Auto
Race Property _00E_Theriantrophist_PlayerWerewolfRace Auto
bool visualActive = false
bool summoned = false
Event onInit()
blockActivation()
Endevent
Event onActivate(ObjectReference akActionRef)
If akActionRef == PlayerREF
ObjectReference akSelf = Self as ObjectReference
If PlayerREF.GetRace() == _00E_Theriantrophist_PlayerWerewolfRace
_00E_Theriantrophist_CantCraftMSG.Show()
ElseIf ((!(akSelf as _00E_Playerhousing_Furniture)) || ((akSelf as _00E_Playerhousing_Furniture) && (Game.GetFormFromFile(0x00043270, "Skyrim.esm") as _00E_PlayerhousingMaster).GetState() == "Buildmode"))
chooseAction()
EndIf
Else
Activate(akActionRef, true)
EndIf
Endevent
; Summons the apparation and places it in the tank
function startVisual()
If !visualActive
visualActive = true
ObjectReference PlaceAtMarker = getlinkedRef(_00E_Phasmalist_CraftingWorkbench_NPCMarker)
If PlaceAtMarker == None
PlaceAtMarker = PlayerREF
EndIf
If !phasmalistControlQuest.apparationAlias.getRef()
summoned = true
Actor summonedActor = PlaceAtMarker.placeAtMe(phasmalistControlQuest.apparationAlias.getEquippedTrinket().connectedApparation) as Actor
summonedActor.disable()
phasmalistControlQuest.apparationAlias.forceRefTo(summonedActor)
gotoState("Waiting")
phasmalistControlQuest.apparationAlias.enterWorld()
gotoState("")
Else
phasmalistControlQuest.apparationAlias.getRef().moveTo(PlaceAtMarker)
phasmalistControlQuest.apparationAlias.playEnterWorldVisualsAndSound()
EndIf
EndIf
Endfunction
; releases the apparation from the tank
function stopVisual()
If visualActive
visualActive = false
If summoned
summoned = false
phasmalistControlQuest.apparationAlias.unsummon()
Else
phasmalistControlQuest.apparationAlias.teleportToPlayer()
EndIf
EndIf
Endfunction
function chooseAction()
If phasmalistControlQuest == None
phasmalistControlQuest = _FS_Phasmalist_ControlQuest.getControlQuest()
EndIf
UIExtensions.initMenu("UIWheelMenu")
UIExtensions.SetMenuPropertyIndexBool("UIWheelMenu", "optionEnabled", 0, true)
UIExtensions.SetMenuPropertyIndexBool("UIWheelMenu", "optionEnabled", 4, true)
UIExtensions.SetMenuPropertyIndexBool("UIWheelMenu", "optionEnabled", 5, true)
UIExtensions.SetMenuPropertyIndexBool("UIWheelMenu", "optionEnabled", 1, true)
UIExtensions.SetMenuPropertyIndexBool("UIWheelMenu", "optionEnabled", 6, true)
UIExtensions.SetMenuPropertyIndexBool("UIWheelMenu", "optionEnabled", 2, true)
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionText", 0, "$Create_Talisman")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionLabelText", 0, "$Create_Talisman")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionText", 4, "$Equip")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionLabelText", 4, "$Equip")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionText", 5, "$Adapt_Combat_Style")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionLabelText", 5, "$Adapt_Combat_Style")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionText", 1, "$View_Attributes")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionLabelText", 1, "$View_Attributes")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionText", 6, "$Currently_Equipped")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionLabelText", 6, "$Currently_Equipped")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionText", 2, "$Quit")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionLabelText", 2, "$Quit")
int choosenAction = UIExtensions.OpenMenu("UIWheelMenu")
If (choosenAction == 0)
RegisterForMenu("Crafting Menu")
phasmalistControlQuest.AddEnchantmentItem()
stopVisual()
self.activate(PlayerREF, true)
ElseIf (choosenAction == 2 || choosenAction == -1)
stopVisual()
return
Else
_00E_Phasmalist_TrinketSC equippedAmulet = phasmalistControlQuest.apparationAlias.getEquippedTrinket()
If equippedAmulet == None || (!phasmalistControlQuest.apparationAlias.getActorReference() && !equippedAmulet.connectedApparation.inventoryContainer)
illegalTrinket.show()
chooseAction()
return
EndIf
startVisual()
If (choosenAction == 1)
phasmalistControlQuest.apparationAlias.showStatsMenu()
Utility.Wait(0.2)
chooseAction()
ElseIf (choosenAction == 4)
showEquipApparationMenu()
ElseIf (choosenAction == 5)
(equippedAmulet as _00E_Phasmalist_TrinketSC).modifyApparation()
chooseAction()
ElseIf (choosenAction == 6)
Debug.MessageBox(phasmalistControlQuest.apparationAlias.getEquipmentString())
Utility.Wait(0.2)
chooseAction()
EndIf
EndIf
Endfunction
Event OnMenuClose(String MenuName)
If MenuName == "Crafting Menu"
UnregisterForMenu("Crafting Menu")
phasmalistControlQuest.RemoveEnchantmentItem()
EndIf
EndEvent
function showEquipApparationMenu()
UIExtensions.initMenu("UIWheelMenu")
UIExtensions.SetMenuPropertyIndexBool("UIWheelMenu", "optionEnabled", 0, true)
UIExtensions.SetMenuPropertyIndexBool("UIWheelMenu", "optionEnabled", 1, true)
UIExtensions.SetMenuPropertyIndexBool("UIWheelMenu", "optionEnabled", 4, true)
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionText", 0, "$Spectralize")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionLabelText", 0, "$Spectralize")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionText", 1, "$Despectralize")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionLabelText", 1, "$Despectralize")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionText", 4, "$Quit")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionLabelText", 4, "$Quit")
int choosenAction = UIExtensions.OpenMenu("UIWheelMenu", phasmalistControlQuest.apparationAlias.getActorReference())
If choosenAction == 0
gotoState("Spectralize")
ElseIf choosenAction == 1
gotoState("Despectralize")
Else
chooseAction()
EndIf
return
Endfunction
STATE Spectralize
Event onBeginState()
string ApparitionName= phasmalistControlQuest.apparationAlias.getActorReference().GetDisplayName()
phasmalistControlQuest.spectralizeContainer.forceRefTo(spectralizerContainer)
spectralizerContainer.SetDisplayName(ApparitionName)
spectralizerContainer.activate(PlayerREF)
RegisterForMenu("ContainerMenu")
; rest is done in onMenuClosed
Endevent
Event OnMenuClose(String MenuName)
Actor ApparitionAliasActor = phasmalistControlQuest.apparationAlias.getActorReference()
If (ApparitionAliasActor) && phasmalistControlQuest.spectralizeContainer.evaluateAndClose(ApparitionAliasActor)
phasmalistControlQuest.OnPlayerItemSpectralized()
EndIf
;should not happen any more, since the apparation is summoned automatically for visual reasons
;Else
; phasmalistControlQuest.spectralizeContainer.evaluateAndClose(phasmalistControlQuest.apparationAlias.getEquippedTrinket().connectedApparation.inventoryContainer)
;EndIf
phasmalistControlQuest.spectralizeContainer.clear()
UnregisterForMenu("ContainerMenu")
gotoState("")
chooseAction()
EndEvent
EndSTATE
STATE Despectralize
Event onBeginState()
reallyDespectralize.show()
;If (ApparitionAliasActor)
; phasmalistControlQuest.despectralizeContainerAlias.forceRefTo(ApparitionAliasActor)
; ApparitionAliasActor.OpenInventory(false); ShowGiftMenu(false, None, true, true)
;Else
;phasmalistControlQuest.despectralizeContainerAlias.forceRefTo(phasmalistControlQuest.apparationAlias.getEquippedTrinket().connectedApparation.inventoryContainer)
;phasmalistControlQuest.despectralizeContainerAlias.getRef().activate(PlayerREF)
;EndIf
; changed to this to "fix" the stolen flag on items
If _00E_Phasmalist_DespectralizingContainerReference == None
_00E_Phasmalist_DespectralizingContainerReference = Game.GetFormFromFile(0x0102F5AB, "Enderal - Forgotten Stories.esm") as ObjectReference
EndIf
Actor ApparitionAliasActor = phasmalistControlQuest.apparationAlias.getActorReference()
ApparitionAliasActor.RemoveAllItems(_00E_Phasmalist_DespectralizingContainerReference, false, true)
phasmalistControlQuest.despectralizeContainerAlias.forceRefTo(_00E_Phasmalist_DespectralizingContainerReference)
_00E_Phasmalist_DespectralizingContainerReference.SetDisplayName(ApparitionAliasActor.GetDisplayName())
_00E_Phasmalist_DespectralizingContainerReference.Activate(PlayerREF)
RegisterForMenu("ContainerMenu")
; rest is done in onMenuClosed
Endevent
Event OnMenuClose(String MenuName)
phasmalistControlQuest.despectralizeContainerAlias.clear()
Actor ApparitionAliasActor = phasmalistControlQuest.apparationAlias.getActorReference()
_00E_Phasmalist_DespectralizingContainerReference.RemoveAllItems(ApparitionAliasActor, false, true)
UnregisterForMenu("ContainerMenu")
gotoState("")
chooseAction()
EndEvent
EndSTATE
STATE Waiting
Event onActivate(ObjectReference akActionRef)
Endevent
EndSTATE