enderalse/source/scripts/_00e_frozenmescript.psc

226 lines
6.8 KiB
Plaintext

Scriptname _00E_FrozenMEScript extends activemagiceffect
{Script that controls the behaviour of frozen enemies!}
;=====================================================================================
; STATES
;=====================================================================================
Auto State Default
Event OnEffectStart(Actor akTarget, Actor akCaster)
Debug.Trace(self + ", OnEffectStart (Default): akTarget = " + akTarget + "; akCaster = " + akCaster)
FrozenActor = akCaster
If FrozenActor && FrozenActor.GetAVPercentage("Health") > 0.1 && FrozenActor.HasPerk(_00E_FrozenPerk) == False
_00E_A1_ArcticWindFreezeM.Play(akTarget)
FrozenActor.AddPerk(_00E_FrozenPerk)
FrozenActor.EnableAI(False)
FrozenActor.SetAV("Paralysis", 1.0) ; Prevents movement and attacking.
GoToState("Frozen")
EndIf
Debug.Trace(self + ", OnEffectStart (Default): done")
EndEvent
EndState
;====================================== FROZEN STATE =================================
State Frozen
;/
Event OnBeginState()
Debug.Trace(self + ", OnBeginState (Frozen)")
PositionMarkerRef = FrozenActor.PlaceAtMe(XMarker)
Debug.Trace(self + ", OnBeginState (Frozen): done")
EndEvent /;
Event OnUpdate()
bHitLock = False
EndEvent
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
Debug.Trace(self + ", OnHit: akAggressor = " + akAggressor + "; akSource = " + akSource + "; akProjectile = " + akProjectile + "; abPowerAttack = " + abPowerAttack + "; abSneakAttack = " + abSneakAttack + "; abBashAttack = " + abBashAttack + "; abBashAttack = " + abHitBlocked)
WPNImpactBladeVsIce.Play(FrozenActor)
If FrozenActor.IsEssential()
Return
EndIf
Float fShatterChance
If PlayerREF.HasPerk(_04E_30_UNI_SongOfWinterFrostDamagePerk)
fShatterChance = __Config_BaseShatterChance * 2.0
Else
fShatterChance = __Config_BaseShatterChance
EndIf
If bHitLock == False
bHitLock = True
If akSource.HasKeyword(WeaponTypeBluntWeapon)
fShatterChance += __Config_ShatterChanceBluntWeaponBonus
EndIf
If abPowerAttack
fShatterChance += __Config_ShatterChancePowerAttackBonus
EndIf
If ShockSpells.HasForm(akSource)
fShatterChance += __Config_ShatterChanceShockSpellBonus
fShatterChance += 1.0
EndIf
If akSource == _00E_A1_OnslaughtCloakDMG
fShatterChance += __Config_ShatterChanceOnslaughtSpellBonus
If _00E_Synergy_ArcticWindOnslaught.GetValueInt() == 0
_00E_Synergy_ArcticWindOnslaught.SetValueInt(1)
Levelsystem.ShowSynergyMessage()
EndIf
EndIf
If Utility.RandomFloat() < fShatterChance
If bNoShatter == False
GoToState("Finished")
ShatterEnemy()
Debug.Trace(self + ", OnHit: shatter!")
EndIf
Else
If bNoShatter == False
RegisterForSingleUpdate(1.5)
EndIf
EndIf
EndIf
Debug.Trace(self + ", OnHit: done")
EndEvent
Event OnDying(Actor akKiller)
Debug.Trace(self + ", OnDying")
bNoShatter = True
EnableTargetAI()
; FrozenActor.EnableAI(True)
; Self.Dispel()
Debug.Trace(self + ", OnDying: done")
EndEvent
Event OnEffectFinish(Actor akTarget, Actor akCaster)
Debug.Trace(self + ", OnEffectFinish")
bNoShatter = True
GoToState("Finished")
_00E_A1_ArcticWindFreezeM.Play(akTarget)
FrozenActor.SetAlpha(1.0, true)
; Debug.Trace(self + ", OnEffectFinish: distance from the marker: " + FrozenActor.GetDistance(PositionMarkerRef))
EnableTargetAI()
FrozenActor.RemovePerk(_00E_FrozenPerk)
; DeletePositionMarker()
Debug.Trace(self + ", OnEffectFinish: done")
EndEvent
EndState
;====================================== FINISHED STATE ===============================
State Finished
; Do nothing
EndState
;=====================================================================================
; FUNCTIONS
;=====================================================================================
Function ShatterEnemy()
; EnableTargetAI()
FrozenActor.Kill(PlayerREF)
Utility.Wait(0.1)
FrozenActor.PlaceAtMe(_00E_FrostShatteringExplosion02)
If FrozenActor.HasKeyword(ActorTypeNPC) || FrozenActor.GetRace() == DraugrRace
FrozenActor.PlaceAtMe(_00E_FS_MAGIceGoreExplosion)
Else
FrozenActor.PlaceAtMe(_00E_FrostShatteringExplosion)
EndIf
FrozenActor.SetCriticalStage(FrozenActor.CritStage_DisintegrateStart)
FrozenActor.SetAlpha(0.0, true)
FrozenActor.AttachAshPile(_00E_ShatteredEnemyPile)
WPNImpactBladeVsIce.Play(FrozenActor)
Game.ShakeCamera(afStrength = 0.3)
Utility.Wait(0.5)
FrozenActor.SetCriticalStage(FrozenActor.CritStage_DisintegrateEnd)
If _00E_AchievementsEnabled.GetValueInt() == 1 && _00E_FrozenAchievementUnlocked.GetValueInt() == 0
Steam.UnlockAchievement("END_FROZEN_01")
_00E_FrozenAchievementUnlocked.SetValueInt(1)
EndIf
; DeletePositionMarker()
EndFunction
Function DeletePositionMarker()
If PositionMarkerRef
PositionMarkerRef.Disable()
PositionMarkerRef.Delete()
PositionMarkerRef = None
EndIf
EndFunction
Function EnableTargetAI()
If bReenabledAI == False
bReenabledAI = True
FrozenActor.SetAV("Paralysis", 0)
;/ If PositionMarkerRef
FrozenActor.MoveTo(PositionMarkerRef)
EndIf /;
FrozenActor.EnableAI(True)
EndIf
EndFunction
;=====================================================================================
; PROPERTIES
;=====================================================================================
Bool bHitLock
Bool bReenabledAI
Bool bNoShatter
Actor FrozenActor
ObjectReference PositionMarkerRef
Float Property __Config_BaseShatterChance = 0.06 AutoReadOnly
Float Property __Config_ShatterChancePowerAttackBonus = 0.035 AutoReadOnly
Float Property __Config_ShatterChanceBluntWeaponBonus = 0.02 AutoReadOnly
Float Property __Config_ShatterChanceShockSpellBonus = 0.025 AutoReadOnly
Float Property __Config_ShatterChanceOnslaughtSpellBonus = 0.04 AutoReadOnly
_00E_QuestFunctions Property Levelsystem Auto
GlobalVariable Property _00E_Synergy_ArcticWindOnslaught Auto
GlobalVariable Property _00E_FrozenAchievementUnlocked Auto
GlobalVariable Property _00E_AchievementsEnabled Auto
Spell Property _00E_A1_OnslaughtCloakDMG Auto
Sound Property _00E_A1_ArcticWindFreezeM Auto
Race Property DraugrRace Auto
Actor Property PlayerREF Auto
Activator Property _00E_ShatteredEnemyPile Auto
Keyword Property WeaponTypeBluntWeapon Auto
Keyword Property ActorTypeNPC Auto
Explosion Property _00E_FrostShatteringExplosion Auto
Explosion Property _00E_FrostShatteringExplosion02 Auto
Explosion Property _00E_FS_MAGIceGoreExplosion Auto
FormList Property ShockSpells Auto
Perk Property _00E_FrozenPerk Auto
Perk Property _04E_30_UNI_SongOfWinterFrostDamagePerk Auto
Sound Property WPNImpactBladeVsIce Auto
Static Property XMarker Auto