enderalse/scripts/source/_00e_phasmalist_newapparitionalias.psc
2021-10-06 00:59:59 +02:00

712 lines
25 KiB
Plaintext

Scriptname _00E_Phasmalist_NewApparitionAlias extends ReferenceAlias
; script that controls the apparition stats calculation and initialization. Additionally, it is responsible for the control of the apparition communication while it is summoned
; we prefer to place new actors instead of using only one actor
; due to the problem of keeping track of all apparitions,
; which might create memory leaks because of persistence;
; Additionally, temporary or accidental changes do not cumulate
; and lead to problems
; balancing data
Float Property fApparitionManaRate = 1.0 AutoReadOnly
Float Property fPlayerStatsMult = 0.20 AutoReadOnly
Float Property fPlayerConjSkillMult = 0.10 AutoReadOnly
Float Property fPlayerEnchSkillMult = 0.15 AutoReadOnly
Float Property fArcaneFeverLevel01 = 7.00 AutoReadOnly
Float Property fArcaneFeverLevel02 = 6.00 AutoReadOnly
Float Property fArcaneFeverLevel03 = 5.00 AutoReadOnly
Float Property fArcaneFeverModWarrior = -1.0 AutoReadOnly
Float Property fArcaneFeverModRanger = 0.0 AutoReadOnly
Float Property fArcaneFeverModHybrid = 0.0 AutoReadOnly
Float Property fArcaneFeverModMage = 1.0 AutoReadOnly
Int Property iGhostlyMageBoostDestructionPowerMod1 = 7 AutoReadOnly
Int Property iGhostlyMageBoostDestructionPowerMod2 = 15 AutoReadOnly
Int Property iGhostlyMageBoostDestructionPowerMod3 = 25 AutoReadOnly
Int Property iGhostlyMageBoostMagicka1 = 15 AutoReadOnly
Int Property iGhostlyMageBoostMagicka2 = 40 AutoReadOnly
Int Property iGhostlyMageBoostMagicka3 = 75 AutoReadOnly
Int Property iGhostlyRangerBoostArchery1 = 7 AutoReadOnly
Int Property iGhostlyRangerBoostArchery2 = 17 AutoReadOnly
Int Property iGhostlyRangerBoostArchery3 = 30 AutoReadOnly
Int Property iGhostlyRangerBoostCritChance1 = 7 AutoReadOnly
Int Property iGhostlyRangerBoostCritChance2 = 15 AutoReadOnly
Int Property iGhostlyRangerBoostCritChance3 = 25 AutoReadOnly
Int Property iGhostlyWarriorBoostMelee1 = 7 AutoReadOnly
Int Property iGhostlyWarriorBoostMelee2 = 17 AutoReadOnly
Int Property iGhostlyWarriorBoostMelee3 = 30 AutoReadOnly
Int Property iGhostlyWarriorBoostArmorSkill1 = 7 AutoReadOnly
Int Property iGhostlyWarriorBoostArmorSkill2 = 17 AutoReadOnly
Int Property iGhostlyWarriorBoostArmorSkill3 = 30 AutoReadOnly
Explosion Property _00E_Phasmalist_EnterWorldExp Auto
Perk Property _00E_Class_Phasmalist_P03_Talent_SummonApparation_01 Auto
Perk Property _00E_Class_Phasmalist_P03_Talent_SummonApparation_02 Auto
Perk Property _00E_Class_Phasmalist_P03_Talent_SummonApparation_03 Auto
Static Property XMarker Auto
Perk Property _00E_Class_Phasmalist_P08_A_EssenceSplit Auto
; Boost perks
Perk Property _00E_Class_Phasmalist_P05_A_Shamanism_01 Auto
Perk Property _00E_Class_Phasmalist_P05_A_Shamanism_02 Auto
Perk Property _00E_Class_Phasmalist_P05_A_Shamanism_03 Auto
Perk Property _00E_Class_Phasmalist_P05_B_Mischief_01 Auto
Perk Property _00E_Class_Phasmalist_P05_B_Mischief_02 Auto
Perk Property _00E_Class_Phasmalist_P05_B_Mischief_03 Auto
Perk Property _00E_Class_Phasmalist_P05_C_Violence_01 Auto
Perk Property _00E_Class_Phasmalist_P05_C_Violence_02 Auto
Perk Property _00E_Class_Phasmalist_P05_C_Violence_03 Auto
Message Property _00E_Phasmalist_CurrentlyEquipped Auto
ImageSpaceModifier Property _00E_ArkanistenfieberIMOD Auto
ImageSpaceModifier Property _00E_Phasmalist_ApparitionEnterWorldIMOD Auto
Sound Property _00E_FS_IncreaseArcaneFeverM Auto
_00E_FS_ForgottenStories_Functions Property ForgottenStoriesMiscDialogue Auto
Message Property _00E_Player_sArcaneFeverIncreased Auto
GlobalVariable Property _00E_Phasmalist_IsApparitionSummoned Auto
; The apparition should not be able to learn summon creature and mystical/mythical spells
FormList Property _00E_PhasmalistApparition_SpellBooks Auto
FormList Property _00E_PhasmalistApparition_Spells Auto
Int iCurrentBoostMagicka ; this is set in adjustBoost() to have the attribute set correctly in the stats calculation
Actor Property PlayerREF Auto
FormList Property _00E_AllAmmos Auto
_00E_Phasmalist_TrinketSC SummonTrinket
; Stores the reference of the current apparition while it's properly spawned, not being unsummoned, not dying, etc.
; Needed for the failsafe in OnLoadGame() and some other shenanigans
Actor Property AliasFailsafeRef = None Auto Hidden
;=====================================================================================
; SUMMON & SETUP
;=====================================================================================
Function Summon(_00E_Phasmalist_TrinketSC trinket, ObjectReference moveToRef, Bool bPhasmalismTankMode, Bool bSilent)
Actor akSelf = Self.GetActorReference()
SummonTrinket = trinket
bActivationBusy = bPhasmalismTankMode ; Reset just in case
_00E_Phasmalist_IsApparitionSummoned.SetValue(1)
Setup() ; init stats before any armor buffs are applied
If bSilent == False
_00E_Phasmalist_ApparitionEnterWorldIMOD.Apply()
EndIf
(akSelf.GetActorBase() as _00E_Phasmalist_ApparationSC).inventoryContainer.removeAllItems(akSelf, false, true)
If bPhasmalismTankMode == False
Int i = akSelf.GetNumItems()
While i > 0
i -= 1
Form item = akSelf.GetNthForm(i)
If item as Book
_RegisterSpellBook(akSelf, item)
EndIf
EndWhile
EndIf
akSelf.BlockActivation()
If bPhasmalismTankMode
akSelf.SetAV("Variable01", 1.0)
akSelf.EnableAI(False)
Else
If moveToRef == PlayerREF
_MoveToPlayer(akSelf, False)
EndIf
GoToState("Working")
EndIf
akSelf.Enable()
AliasFailsafeRef = akSelf
If bPhasmalismTankMode
; MoveTo needs to be done after Enable or the apparition ends on the neareast navmesh instead of the tank
akSelf.MoveTo(moveToRef)
EndIf
If bSilent == False
PlaySummonExplosion(akSelf)
EndIf
SendModEvent("Phasmalist_ApparationSummon")
EndFunction
Function PlaySummonExplosion(ObjectReference markerRef)
ObjectReference expMarker = markerRef.placeAtMe(XMarker)
expMarker.MoveTo(markerRef, 0.0, 0.0, 15)
expMarker.PlaceAtMe(_00E_Phasmalist_EnterWorldExp)
expMarker.Disable()
expMarker.Delete()
EndFunction
Int Property BOOST_CLASS_MAGE = 0 AutoReadOnly
Int Property BOOST_CLASS_RANGER = 1 AutoReadOnly
Int Property BOOST_CLASS_WARRIOR = 2 AutoReadOnly
Function Setup()
Actor akSelf = Self.GetActorReference()
SetupBehaviour(akSelf)
SetupNotPersistentStats(akSelf)
Float fAttributeMult = (fPlayerConjSkillMult * PlayerREF.GetAV("Conjuration") + fPlayerEnchSkillMult * PlayerREF.GetAV("Enchanting")) / 100.0 + 1.0
ApplyClassBoost(akSelf, BOOST_CLASS_MAGE, _00E_Class_Phasmalist_P05_A_Shamanism_01, _00E_Class_Phasmalist_P05_A_Shamanism_02, _00E_Class_Phasmalist_P05_A_Shamanism_03)
ApplyClassBoost(akSelf, BOOST_CLASS_RANGER, _00E_Class_Phasmalist_P05_B_Mischief_01, _00E_Class_Phasmalist_P05_B_Mischief_02, _00E_Class_Phasmalist_P05_B_Mischief_03)
ApplyClassBoost(akSelf, BOOST_CLASS_WARRIOR, _00E_Class_Phasmalist_P05_C_Violence_01, _00E_Class_Phasmalist_P05_C_Violence_02, _00E_Class_Phasmalist_P05_C_Violence_03)
If PlayerREF.HasPerk(_00E_Class_Phasmalist_P08_A_EssenceSplit)
Float fMaxAttributeValue = PlayerREF.GetBaseAV("Health")
Float fPlayerMagicka = PlayerREF.GetBaseAV("Magicka")
If fPlayerMagicka > fMaxAttributeValue
fMaxAttributeValue = fPlayerMagicka
EndIf
Float fPlayerStamina = PlayerREF.GetBaseAV("Stamina")
If fPlayerStamina > fMaxAttributeValue
fMaxAttributeValue = fPlayerStamina
EndIf
akSelf.ForceAV("Health", ((akSelf.GetBaseAV("Health") + fMaxAttributeValue * fPlayerStatsMult) * fAttributeMult) as int)
akSelf.ForceAV("Magicka", (((akSelf.GetBaseAV("Magicka") + fMaxAttributeValue * fPlayerStatsMult) * fAttributeMult) as int) + iCurrentBoostMagicka)
akSelf.ForceAV("Stamina", ((akSelf.GetBaseAV("Stamina") + fMaxAttributeValue * fPlayerStatsMult) * fAttributeMult) as int)
Else
akSelf.ForceAV("Health", ((akSelf.GetBaseAV("Health") + PlayerREF.GetBaseAV("Health") * fPlayerStatsMult) * fAttributeMult) as int)
akSelf.ForceAV("Magicka", (((akSelf.GetBaseAV("Magicka") + PlayerREF.GetBaseAV("Magicka") * fPlayerStatsMult) * fAttributeMult) as int) + iCurrentBoostMagicka)
akSelf.ForceAV("Stamina", ((akSelf.GetBaseAV("Stamina") + PlayerREF.GetBaseAV("Stamina") * fPlayerStatsMult) * fAttributeMult) as int)
EndIf
EndFunction
Function SetupBehaviour(Actor akSelf)
Int iRelationship = akSelf.GetRelationshipRank(PlayerREF)
If iRelationship < 3 && iRelationship >= 0
akSelf.SetRelationshipRank(PlayerREF, 3)
EndIf
akSelf.SetPlayerTeammate()
akSelf.SetAV("Confidence", 4) ; the apparition should never flee
akSelf.SetAV("Aggression", 0) ; the apparition should not initiate combat (-> stealth playstyle)
akSelf.SetAV("Sneak", 100)
akSelf.SetAV("Invisibility", 1) ; make the apparition undetectable when sneaking (-> stealth playstyle)
akSelf.IgnoreFriendlyHits() ; make the apparition ignore friendly fire from the PC
EndFunction
Function SetupNotPersistentStats(Actor akSelf)
akSelf.GetActorBase().SetCombatStyle(SummonTrinket.GetUsedCombatStyle())
akSelf.SetAV("HealRate", 50)
akSelf.SetAV("MagickaRate", fApparitionManaRate)
;failsafe since setav doesn't work sometimes
akSelf.ForceAV("HealRate", 50)
akSelf.ForceAV("MagickaRate", fApparitionManaRate)
EndFunction
Function ApplyClassBoost(Actor akSelf, Int iBoostClass, Perk boostPerk1, Perk boostPerk2, Perk boostPerk3)
If PlayerREF.HasPerk(boostPerk1)
If PlayerREF.HasPerk(boostPerk3)
_AddClassBoost(akSelf, iBoostClass, 3)
ElseIf PlayerREF.HasPerk(boostPerk2)
_AddClassBoost(akSelf, iBoostClass, 2)
Else
_AddClassBoost(akSelf, iBoostClass, 1)
EndIf
EndIf
EndFunction
Function _AddClassBoost(Actor akSelf, Int iBoostClass, Int iBoostLevel)
If iBoostClass == BOOST_CLASS_MAGE
Int iDestructionPowerMod = 0
If iBoostLevel == 3
iDestructionPowerMod = iGhostlyMageBoostDestructionPowerMod3
iCurrentBoostMagicka = iGhostlyMageBoostMagicka3 ; since magicka is boosted later again, we have to save this boost and apply it later to prevent overwriting old boosts
ElseIf iBoostLevel == 2
iDestructionPowerMod = iGhostlyMageBoostDestructionPowerMod2
iCurrentBoostMagicka = iGhostlyMageBoostMagicka2
Else
iDestructionPowerMod = iGhostlyMageBoostDestructionPowerMod1
iCurrentBoostMagicka = iGhostlyMageBoostMagicka1
EndIf
;akSelf.ForceAV("DestructionPowerMod", akSelf.GetAV("DestructionPowerMod") + iDestructionPowerMod)
akSelf.ModAV("DestructionPowerMod", iDestructionPowerMod)
ElseIf iBoostClass == BOOST_CLASS_RANGER
Int iBoostArchery = 0
Int iBoostCritChance = 0
If iBoostLevel == 3
iBoostArchery = iGhostlyRangerBoostArchery3
iBoostCritChance = iGhostlyRangerBoostCritChance3
ElseIf iBoostLevel == 2
iBoostArchery = iGhostlyRangerBoostArchery2
iBoostCritChance = iGhostlyRangerBoostCritChance2
Else
iBoostArchery = iGhostlyRangerBoostArchery1
iBoostCritChance = iGhostlyRangerBoostCritChance1
EndIf
;akSelf.ForceAV("Marksman", akSelf.GetAV("Marksman") + iBoostArchery)
akSelf.ModAV("Marksman", iBoostArchery)
;akSelf.ForceAV("CritChance", akSelf.GetAV("CritChance") + iBoostCritChance)
akSelf.ModAV("CritChance", iBoostCritChance)
ElseIf iBoostClass == BOOST_CLASS_WARRIOR
Int iBoostMelee = 0
Int iBoostArmor = 0
If iBoostLevel == 3
iBoostMelee = iGhostlyWarriorBoostMelee3
iBoostArmor = iGhostlyWarriorBoostArmorSkill3
ElseIf iBoostLevel == 2
iBoostMelee = iGhostlyWarriorBoostMelee2
iBoostArmor = iGhostlyWarriorBoostArmorSkill2
Else
iBoostMelee = iGhostlyWarriorBoostMelee1
iBoostArmor = iGhostlyWarriorBoostArmorSkill1
EndIf
;akSelf.ForceAV("HeavyArmor", akSelf.GetAV("HeavyArmor") + iBoostArmor)
akSelf.ModAV("HeavyArmor", iBoostArmor)
;akSelf.ForceAV("LightArmor", akSelf.GetAV("LightArmor") + iBoostArmor)
akSelf.ModAV("LightArmor", iBoostArmor)
;akSelf.ForceAV("MeleeDamage", akSelf.GetAV("MeleeDamage") + iBoostMelee)
akSelf.ModAV("MeleeDamage", iBoostMelee)
Else
Debug.Notification("Phasmalist Control Quest has issues: Unsupported boost class " + iBoostClass)
EndIf
Endfunction
;=====================================================================================
; UNSUMMON & CLEANUP
;=====================================================================================
Function Unsummon(Bool bSilent)
Actor akSelf = self.GetActorReference()
GoToState("")
AliasFailsafeRef = None
TransformFromWerewolf(akSelf, True, bSilent)
If bSilent == False
If akSelf.Is3DLoaded()
akSelf.PlaceAtMe(_00E_Phasmalist_EnterWorldExp)
EndIf
AddArcaneFever()
EndIf
_00E_Phasmalist_IsApparitionSummoned.SetValue(0)
akSelf.RemoveAllItems((akSelf.GetActorBase() as _00E_Phasmalist_ApparationSC).inventoryContainer, False, True)
akSelf.Disable()
Self.Clear()
ForgottenStoriesMiscDialogue.hideActorHealthBars(akSelf)
SummonTrinket = None
akSelf.Delete()
SendModEvent("Phasmalist_ApparationUnSummon")
EndFunction
Function AddArcaneFever()
Actor akSelf = Self.GetActorReference()
Float fHealthLostPercentage = 0
Float fMaxArcaneFeverAdd = 0
If akSelf.IsDead()
fHealthLostPercentage = 1.0
Else
fHealthLostPercentage = 1.0 - akSelf.GetActorValuePercentage("health")
If fHealthLostPercentage > 1.0
fHealthLostPercentage = 1.0
EndIf
EndIf
Int iTalentLevel = _00E_TalentLibrary.GetPlayerTalentLevel(_00E_Class_Phasmalist_P03_Talent_SummonApparation_01, _00E_Class_Phasmalist_P03_Talent_SummonApparation_02, _00E_Class_Phasmalist_P03_Talent_SummonApparation_03)
If iTalentLevel == 1
fMaxArcaneFeverAdd = fArcaneFeverLevel01
ElseIf iTalentLevel == 2
fMaxArcaneFeverAdd = fArcaneFeverLevel02
Else
fMaxArcaneFeverAdd = fArcaneFeverLevel03
EndIf
Int iTrinketType = SummonTrinket.type
If iTrinketType == 0
fMaxArcaneFeverAdd += fArcaneFeverModWarrior
ElseIf iTrinketType == 1
fMaxArcaneFeverAdd += fArcaneFeverModRanger
ElseIf iTrinketType == 2
fMaxArcaneFeverAdd += fArcaneFeverModMage
Else
fMaxArcaneFeverAdd += fArcaneFeverModHybrid
EndIf
Float fArcaneFeverAdd = fMaxArcaneFeverAdd * fHealthLostPercentage
If fArcaneFeverAdd > 0
PlayerREF.ModAV("LastFlattered", -fArcaneFeverAdd)
_00E_ArkanistenfieberIMOD.ApplyCrossFade()
_00E_FS_IncreaseArcaneFeverM.Play(PlayerREF)
_00E_Player_sArcaneFeverIncreased.Show(fArcaneFeverAdd, -1 * PlayerREF.GetAV("LastFlattered"))
EndIf
EndFunction
;=====================================================================================
; OTHER ACTIONS
;=====================================================================================
Function OnLoadGame()
; sometimes reloading a save with a summoned apparition from a game state without one can result in the apparationAlias (old alias) being cleared.
; To fix this, the script additionally keeps track of its content in a variable and refills itself onGameLoad
If AliasFailsafeRef
Self.ForceRefTo(AliasFailsafeRef)
EndIf
Actor akSelf = GetActorReference()
If akSelf
SetupNotPersistentStats(akSelf)
_ShowHealthBar()
EndIf
EndFunction
Function TeleportToPlayer(Bool bTeleportInFront, Bool bSilent)
Actor akSelf = Self.GetActorReference()
If akSelf
akSelf.Disable()
_MoveToPlayer(akSelf, bTeleportInFront)
akSelf.Enable()
If bSilent == False
akSelf.PlaceAtMe(_00E_Phasmalist_EnterWorldExp)
EndIf
EndIf
EndFunction
Function SetCombatStyle(CombatStyle newCombatStyle)
Actor akSelf = Self.GetActorReference()
If akSelf
_SetCombatStyle(akSelf, newCombatStyle)
EndIf
EndFunction
Function ShowStatsMenu()
Actor akSelf = Self.GetActorReference()
If akSelf
UIExtensions.initMenu("UIStatsMenu")
UIExtensions.openMenu("UIStatsMenu", akSelf)
EndIf
EndFunction
Function ShowEquipment()
Actor akSelf = Self.GetActorReference()
If akSelf
String text = _00E_Phasmalist_CurrentlyEquipped.GetName() + "\n\n"
Weapon EquippedWeapon = akSelf.GetEquippedWeapon()
If EquippedWeapon
text = text + EquippedWeapon.GetName() + "\n" ;weapon
If EquippedWeapon.IsBow()
Form[] arrows = _00E_AllAmmos.ToArray()
Int i = 0
Int nArrowCount
While i < arrows.Length
nArrowCount = akSelf.GetItemCount(arrows[i])
If nArrowCount > 0
text = text + (arrows[i].GetName() + " (" + nArrowCount +")\n")
EndIf
i += 1
EndWhile
EndIf
EndIf
text = _AddWornFormAsString(akSelf, 0x00000200, text) ;shield
text = _AddWornFormAsString(akSelf, 0x00001000, text) ;circlet
text = _AddWornFormAsString(akSelf, 0x00000004, text) ;body
text = _AddWornFormAsString(akSelf, 0x00000008, text) ;hands
text = _AddWornFormAsString(akSelf, 0x00000080, text) ;feet
text = _AddWornFormAsString(akSelf, 0x00000020, text) ;amulet
text = _AddWornFormAsString(akSelf, 0x00000040, text) ;ring
Debug.MessageBox(text)
EndIf
EndFunction
;=====================================================================================
; WEREWOLF
;=====================================================================================
FormList Property _00E_Phasmalist_CombatStyleWerewolfList Auto
Spell Property _00E_FS_Affinity_Soulcaller_ApparationWolfBoostSP Auto
Idle Property WerewolfTransformBack Auto
Idle Property IdleWerewolfTransformation Auto
Idle Property _00E_IdleStomp Auto
Explosion Property _00E_FS_Theriantrophist_TransEXP Auto
Race Property _00E_Theriantrophist_PlayerWerewolfRace Auto
ObjectReference Property _00E_FS_Affinity_Soulcaller_RemoveAndAddApparationItemsChest Auto
Float Property WEREWOLF_TRANSFORM_UNARMED_DAMAGE_BOOST = 20.0 AutoReadOnly
Float Property WEREWOLF_TRANSFORM_HEALTH_BOOST = 40.0 AutoReadOnly
Race WerewolfTranform_OriginalRace = None
Bool Function IsTransformedToWerewolf()
Return (WerewolfTranform_OriginalRace != None)
EndFunction
Function TransformToWerewolf(Actor akSpellTarget)
Actor akSelf = GetActorReference()
If (akSelf == None) || (akSelf != akSpellTarget)
Return
EndIf
akSelf.SetPlayerTeammate(False)
Utility.Wait(0.2)
akSelf.UnequipAll()
WerewolfTranform_OriginalRace = akSelf.getRace()
akSelf.PlayIdle(IdleWerewolfTransformation)
_SetCombatStyle(akSelf, _00E_Phasmalist_CombatStyleWerewolfList.GetAt(0) as CombatStyle)
_00E_FS_Affinity_Soulcaller_ApparationWolfBoostSP.SetNthEffectMagnitude(0, WEREWOLF_TRANSFORM_UNARMED_DAMAGE_BOOST)
_00E_FS_Affinity_Soulcaller_ApparationWolfBoostSP.SetNthEffectMagnitude(1, WEREWOLF_TRANSFORM_HEALTH_BOOST)
akSelf.AddSpell(_00E_FS_Affinity_Soulcaller_ApparationWolfBoostSP)
Utility.Wait(1)
ObjectReference expMarker = akSelf.PlaceAtMe(XMarker)
expMarker.MoveTo(akSelf, 0.0, 0.0, 100.0)
expMarker.PlaceAtMe(_00E_FS_Theriantrophist_TransEXP)
akSelf.SetRace(_00E_Theriantrophist_PlayerWerewolfRace)
expMarker.Disable()
expMarker.Delete()
Utility.Wait(0.2)
akSelf.SetPlayerTeammate(True)
EndFunction
Function TransformFromWerewolf(Actor akSpellTarget, Bool bIsUnsummoned, Bool bSilent)
Actor akSelf = GetActorReference()
If (IsTransformedToWerewolf() == False) || (akSelf == None) || (akSelf != akSpellTarget)
Return
EndIf
If akSelf.IsDead()
_TransformFromWerewolfDead(akSelf, bIsUnsummoned, bSilent)
Else
_TransformFromWerewolfAlive(akSelf, bIsUnsummoned, bSilent)
EndIf
WerewolfTranform_OriginalRace = None
EndFunction
Function _TransformFromWerewolfDead(Actor akSelf, Bool bIsUnsummoned, Bool bSilent)
GoToState("")
akSelf.RemoveAllItems(_00E_FS_Affinity_Soulcaller_RemoveAndAddApparationItemsChest)
akSelf.Resurrect()
_00E_FS_Affinity_Soulcaller_RemoveAndAddApparationItemsChest.RemoveAllItems(akSelf)
Utility.Wait(0.2)
If bSilent == False
akSelf.PlaceAtMe(_00E_FS_Theriantrophist_TransEXP)
EndIf
_SetCombatStyle(akSelf, SummonTrinket.GetUsedCombatStyle())
akSelf.RemoveSpell(_00E_FS_Affinity_Soulcaller_ApparationWolfBoostSP)
akSelf.SetRace(WerewolfTranform_OriginalRace)
Utility.Wait(0.2)
If bIsUnsummoned == False
GoToState("Working")
EndIf
akSelf.Kill()
EndFunction
Function _TransformFromWerewolfAlive(Actor akSelf, Bool bIsUnsummoned, Bool bSilent)
akSelf.SetPlayerTeammate(False)
If bSilent == False
akSelf.PlaceAtMe(_00E_FS_Theriantrophist_TransEXP)
EndIf
akSelf.PlayIdle(WerewolfTransformBack)
_SetCombatStyle(akSelf, SummonTrinket.GetUsedCombatStyle())
akSelf.RemoveSpell(_00E_FS_Affinity_Soulcaller_ApparationWolfBoostSP)
akSelf.SetRace(WerewolfTranform_OriginalRace)
; RemoveAllItems is necessary to correctly reequip items
akSelf.RemoveAllItems(_00E_FS_Affinity_Soulcaller_RemoveAndAddApparationItemsChest)
_00E_FS_Affinity_Soulcaller_RemoveAndAddApparationItemsChest.RemoveAllItems(akSelf)
akSelf.PlayIdle(_00E_IdleStomp)
If bIsUnsummoned
Utility.Wait(0.2)
Else
Utility.Wait(0.1)
SetupBehaviour(akSelf)
SetupNotPersistentStats(akSelf)
EndIf
EndFunction
;=====================================================================================
; HELPER FUNCTIONS
;=====================================================================================
String Function _AddWornFormAsString(Actor a, int slot, string s)
Form wornForm = a.GetWornForm(slot)
If wornForm
Return s + wornForm.GetName() + "\n"
EndIf
Return s
EndFunction
Function _ShowHealthBar()
Actor akSelf = Self.GetActorReference()
If akSelf && akSelf.IsDead() == False
ForgottenStoriesMiscDialogue.showActorHealthBars(akSelf)
EndIf
EndFunction
Float Property FRONT_TELEPORT_DISTANCE = 72.0 AutoReadOnly
Float Property BACK_TELEPORT_DISTANCE = 96.0 AutoReadOnly
Function _MoveToPlayer(Actor akSelf, Bool bTeleportInFront)
Float fHeadingAngle = PlayerREF.GetAngleZ()
If bTeleportInFront
akSelf.MoveTo(PlayerREF, FRONT_TELEPORT_DISTANCE * Math.sin(fHeadingAngle), FRONT_TELEPORT_DISTANCE * Math.cos(fHeadingAngle), 0, True)
akSelf.SetAngle(0, 0, fHeadingAngle + 180.0)
Else
fHeadingAngle += 180.0
akSelf.MoveTo(PlayerREF, BACK_TELEPORT_DISTANCE * Math.sin(fHeadingAngle), BACK_TELEPORT_DISTANCE * Math.cos(fHeadingAngle), 0, True)
EndIf
EndFunction
Function _SetCombatStyle(Actor akSelf, CombatStyle newCombatStyle)
akSelf.StopCombat()
akSelf.GetActorBase().SetCombatStyle(newCombatStyle)
EndFunction
Spell Function _GetSpellFromSpellBook(Form akBaseItem)
; The apparition should not be able to learn summon creature and mystical/mythical spells
Int iSpellBook = _00E_PhasmalistApparition_SpellBooks.Find(akBaseItem)
If iSpellBook >= 0
Return (_00E_PhasmalistApparition_Spells.GetAt(iSpellBook) as Spell)
Else
Return None
EndIf
EndFunction
Function _RegisterSpellBook(Actor akSelf, Form akBaseItem)
Spell bookSpell = _GetSpellFromSpellBook(akBaseItem)
If bookSpell
Self.GetActorReference().AddSpell(bookSpell, False)
EndIf
EndFunction
Function _UnregisterSpellBook(Actor akSelf, Form akBaseItem)
Spell bookSpell = _GetSpellFromSpellBook(akBaseItem)
If bookSpell
Self.GetActorReference().RemoveSpell(bookSpell)
EndIf
EndFunction
;=====================================================================================
; EVENTS
;=====================================================================================
Bool bActivationBusy = False
State Working
Event OnActivate(ObjectReference akActivator)
If akActivator == PlayerREF && bActivationBusy == False
bActivationBusy = True
UIExtensions.initMenu("UIWheelMenu")
UIExtensions.SetMenuPropertyIndexBool("UIWheelMenu", "optionEnabled", 0, true)
UIExtensions.SetMenuPropertyIndexBool("UIWheelMenu", "optionEnabled", 1, true)
UIExtensions.SetMenuPropertyIndexBool("UIWheelMenu", "optionEnabled", 4, true)
UIExtensions.SetMenuPropertyIndexBool("UIWheelMenu", "optionEnabled", 5, true)
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionText", 0, "$View_Attributes")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionLabelText", 0, "$View_Attributes")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionText", 1, "$Adapt_Combat_Style")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionLabelText", 1, "$Adapt_Combat_Style")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionText", 4, "$Currently_Equipped")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionLabelText", 4, "$Currently_Equipped")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionText", 5, "$Quit")
UIExtensions.SetMenuPropertyIndexString("UIWheelMenu", "optionLabelText", 5, "$Quit")
Int iChoice = UIExtensions.OpenMenu("UIWheelMenu", Self.GetActorReference())
If iChoice == 0
ShowStatsMenu()
ElseIf iChoice == 1
SummonTrinket.ChooseApparitionCombatStyle()
ElseIf iChoice == 4
ShowEquipment()
EndIf
bActivationBusy = False
EndIf
EndEvent
Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
If akBaseItem as Book
_RegisterSpellBook(Self.GetActorReference(), akBaseItem)
EndIf
EndEvent
Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
If akBaseItem as Book
Actor akSelf = Self.GetActorReference()
If akSelf.GetItemCount(akBaseItem) <= 0
_UnregisterSpellBook(akSelf, akBaseItem)
EndIf
EndIf
EndEvent
Event OnLoad()
bActivationBusy = False ; Safeguard
_ShowHealthBar()
EndEvent
Event OnDying(Actor akKiller)
AliasFailsafeRef = None
EndEvent
Event OnDeath(Actor akKiller)
AliasFailsafeRef = None
(GetOwningQuest() as _FS_Phasmalist_ControlQuest).UnsummonApparition()
EndEvent
Event OnCombatStateChanged(Actor akTarget, Int aeCombatState)
If aeCombatState == 1
_ShowHealthBar()
EndIf
EndEvent
EndState