Code : Tout sélectionner
;/ Decompiled by Champollion V1.0.1
Source : tpCelestineAIScript.psc
Modified : 2014-04-01 10:14:04
Compiled : 2014-04-01 10:16:35
User : Animax
Computer : ANIMESH-DESKTOP
/;
scriptName tpCelestineAIScript extends ReferenceAlias
;-- Properties --------------------------------------
scene property _sceneMiscAlteration auto
spell property _spellHealOther auto
spell property _spellHealingHands auto
spell property _spellLesserOakFlesh auto
spell property _spellTransmute auto
scene property _sceneMiscRestoration auto
spell property _spellRally auto
scene property _sceneHeal auto
spell property _spellPacify auto
spell property _spellCourage auto
miscobject property _objOreIron auto
scene property _sceneCalm auto
scene property _sceneMiscIllusion auto
keyword property _keywordDaedra auto
spell property _spellLesserGrandHealing auto
keyword property _keywordDwarven auto
ReferenceAlias property _tpCelestineTargetRef auto
keyword property _keywordAnimal auto
keyword property _keywordDragon auto
miscobject property _objOreSiver auto
spell property _spellCalm auto
spell property _spellCallToArms auto
spell property _spellLesserStoneFlesh auto
spell property _spellMuffle auto
scene property _sceneBuff auto
spell property _spellInvisibility auto
spell property _spellHarmony auto
spell property _spellMageLight auto
spell property _spellGrandHealing auto
keyword property _keywordUndead auto
spell property _spellLesserIronFlesh auto
spell property _spellLesserEbonyFlesh auto
;-- Variables ---------------------------------------
tpCelestineAIQuestScript _tpCelestineAIQuestRef
Actor _playerRef
Float _updateIntervalNormal
Float _updateIntervalCombat
Float _selfAVMagicka
Float _spellSelectedEffectiveCost
Bool _isInCombat
Actor _selfRef
;-- Functions ---------------------------------------
function BuffAllies()
if _tpCelestineAIQuestRef._spellBuff != -1
if _selfRef.IsInCombat() == true
_tpCelestineAIQuestRef._spellBuff = self.GetAvailableSpell("BuffAlteration", 0)
if _tpCelestineAIQuestRef._spellBuff > 0
_tpCelestineTargetRef.ForceRefTo(_playerRef as objectreference)
_sceneBuff.Start()
while _sceneBuff.IsPlaying() == true
utility.Wait(0.500000)
endWhile
endIf
endIf
if _selfRef.IsInCombat() == true
_tpCelestineAIQuestRef._spellBuff = self.GetAvailableSpell("BuffIllusion", 0)
if _tpCelestineAIQuestRef._spellBuff > 0
_tpCelestineTargetRef.ForceRefTo(_playerRef as objectreference)
_sceneBuff.Start()
while _sceneBuff.IsPlaying() == true
utility.Wait(0.500000)
endWhile
endIf
endIf
spell equippedSpellRH = _selfRef.GetEquippedSpell(1)
if equippedSpellRH
_selfRef.UnequipSpell(equippedSpellRH, 1)
endIf
endIf
endFunction
function CalmTargets(Bool isMultiTargets, Actor currentTarget)
if _tpCelestineAIQuestRef._spellCalm != -1
if currentTarget.HasKeyword(_keywordDragon) == false
Int maxLvlSpellCalm = 0
Int maxLvlSpellPacify = 0
Int maxLvlSpellHarmony = 0
Int maxLvlSpellCalmDualCast = 0
Int maxLvlSpellPacifyDualCast = 0
if currentTarget.HasKeyword(_keywordAnimal) == true
maxLvlSpellCalm = 25
maxLvlSpellPacify = 36
maxLvlSpellHarmony = 41
maxLvlSpellCalmDualCast = 55
maxLvlSpellPacifyDualCast = 79
elseIf currentTarget.HasKeyword(_keywordUndead) == true
maxLvlSpellCalm = 17
maxLvlSpellPacify = 28
maxLvlSpellHarmony = 33
maxLvlSpellCalmDualCast = 37
maxLvlSpellPacifyDualCast = 61
else
maxLvlSpellCalm = 27
maxLvlSpellPacify = 38
maxLvlSpellHarmony = 43
maxLvlSpellCalmDualCast = 59
maxLvlSpellPacifyDualCast = 83
endIf
Int currentTargetLevel = currentTarget.GetLevel()
if isMultiTargets == false
if currentTargetLevel <= maxLvlSpellCalm
_tpCelestineAIQuestRef._spellCalm = self.GetAvailableSpell("Calm", 1)
elseIf currentTargetLevel <= maxLvlSpellPacify
_tpCelestineAIQuestRef._spellCalm = self.GetAvailableSpell("Calm", 3)
elseIf currentTargetLevel <= maxLvlSpellCalmDualCast
_tpCelestineAIQuestRef._spellCalm = self.GetAvailableSpell("Calm", 2)
elseIf currentTargetLevel <= maxLvlSpellPacifyDualCast
_tpCelestineAIQuestRef._spellCalm = self.GetAvailableSpell("Calm", 4)
else
_tpCelestineAIQuestRef._spellCalm = 0
endIf
else
if currentTargetLevel <= maxLvlSpellPacify
_tpCelestineAIQuestRef._spellCalm = self.GetAvailableSpell("Calm", 3)
elseIf currentTargetLevel <= maxLvlSpellHarmony
_tpCelestineAIQuestRef._spellCalm = self.GetAvailableSpell("Calm", 5)
elseIf currentTargetLevel <= maxLvlSpellPacifyDualCast
_tpCelestineAIQuestRef._spellCalm = self.GetAvailableSpell("Calm", 4)
else
_tpCelestineAIQuestRef._spellCalm = 0
endIf
if _tpCelestineAIQuestRef._spellCalm == 0
if currentTargetLevel <= maxLvlSpellCalm
_tpCelestineAIQuestRef._spellCalm = self.GetAvailableSpell("Calm", 1)
elseIf currentTargetLevel <= maxLvlSpellCalmDualCast
_tpCelestineAIQuestRef._spellCalm = self.GetAvailableSpell("Calm", 2)
endIf
endIf
endIf
if _tpCelestineAIQuestRef._spellCalm > 0
_tpCelestineTargetRef.ForceRefTo(currentTarget as objectreference)
_sceneCalm.Start()
while _sceneCalm.IsPlaying() == true
utility.Wait(0.500000)
endWhile
spell equippedSpellRH = _selfRef.GetEquippedSpell(1)
if equippedSpellRH
_selfRef.UnequipSpell(equippedSpellRH, 1)
endIf
endIf
endIf
endIf
endFunction
function OnCellDetach()
if _selfRef.IsPlayerTeamMate() == false
self.UnregisterForUpdate()
self.RegisterForSingleLOSGain(_selfRef, _playerRef as objectreference)
endIf
endFunction
function MageLight()
if _tpCelestineAIQuestRef._spellMiscAlteration != -1
_tpCelestineAIQuestRef._spellMiscAlteration = self.GetAvailableSpell("MiscAlteration", 1)
if _tpCelestineAIQuestRef._spellMiscAlteration > 0
_tpCelestineTargetRef.ForceRefTo(_playerRef as objectreference)
_sceneMiscAlteration.Start()
while _sceneMiscAlteration.IsPlaying() == true
utility.Wait(0.500000)
endWhile
endIf
endIf
endFunction
function OnInit()
self.Initialize()
endFunction
function Invisibility()
if _tpCelestineAIQuestRef._spellMiscIllusion != -1
_tpCelestineAIQuestRef._spellMiscIllusion = self.GetAvailableSpell("MiscIllusion", 2)
if _tpCelestineAIQuestRef._spellMiscIllusion > 0
_tpCelestineTargetRef.ForceRefTo(_playerRef as objectreference)
_sceneMiscIllusion.Start()
while _sceneMiscIllusion.IsPlaying() == true
utility.Wait(0.500000)
endWhile
endIf
endIf
endFunction
function OnCombatStateChanged(Actor akTarget, Int aeCombatState)
if _selfRef.IsPlayerTeamMate() == true
if _selfRef.IsOnMount() == false
if _selfRef.IsInCombat() == true && _isInCombat == false
_isInCombat = true
if _playerRef.IsWeaponDrawn() == true
utility.Wait(3.00000)
self.BuffAllies()
else
self.CalmTargets(false, akTarget)
endIf
self.RegisterForSingleUpdate(_updateIntervalCombat)
elseIf _selfRef.IsInCombat() == false && _isInCombat == true
_isInCombat = false
self.DispelHarmfulEffects()
self.RegisterForSingleUpdate(_updateIntervalNormal)
endIf
else
self.UnregisterForUpdate()
endIf
endIf
endFunction
Int function GetAvailableSpell(String spellCategory, Int spellSelected)
_selfAVMagicka = _selfRef.GetActorValue("Magicka")
if spellCategory == "BuffAlteration"
Float selfAVAlteration = _selfRef.GetActorValue("Alteration")
if selfAVAlteration >= 75 as Float
_spellSelectedEffectiveCost = _spellLesserEbonyFlesh.GetEffectiveMagickaCost(_selfRef) as Float * 2.00000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 14
endIf
_spellSelectedEffectiveCost = _spellLesserIronFlesh.GetEffectiveMagickaCost(_selfRef) as Float * 2.00000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 13
endIf
_spellSelectedEffectiveCost = _spellLesserStoneFlesh.GetEffectiveMagickaCost(_selfRef) as Float * 2.00000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 12
endIf
_spellSelectedEffectiveCost = _spellLesserOakFlesh.GetEffectiveMagickaCost(_selfRef) as Float * 2.00000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 11
endIf
elseIf selfAVAlteration >= 50 as Float
_spellSelectedEffectiveCost = _spellLesserIronFlesh.GetEffectiveMagickaCost(_selfRef) as Float * 2.00000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 13
endIf
_spellSelectedEffectiveCost = _spellLesserStoneFlesh.GetEffectiveMagickaCost(_selfRef) as Float * 2.00000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 12
endIf
_spellSelectedEffectiveCost = _spellLesserOakFlesh.GetEffectiveMagickaCost(_selfRef) as Float * 2.00000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 11
endIf
elseIf selfAVAlteration >= 25 as Float
_spellSelectedEffectiveCost = _spellLesserStoneFlesh.GetEffectiveMagickaCost(_selfRef) as Float * 2.00000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 12
endIf
_spellSelectedEffectiveCost = _spellLesserOakFlesh.GetEffectiveMagickaCost(_selfRef) as Float * 2.00000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 11
endIf
elseIf selfAVAlteration >= 0 as Float
_spellSelectedEffectiveCost = _spellLesserOakFlesh.GetEffectiveMagickaCost(_selfRef) as Float * 2.00000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 11
endIf
endIf
return 0
elseIf spellCategory == "BuffIllusion"
Float selfAVIllusion = _selfRef.GetActorValue("Illusion")
if selfAVIllusion >= 100 as Float
_spellSelectedEffectiveCost = _spellCallToArms.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 3
endIf
_spellSelectedEffectiveCost = _spellRally.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 2
endIf
_spellSelectedEffectiveCost = _spellCourage.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
elseIf selfAVIllusion >= 50 as Float
_spellSelectedEffectiveCost = _spellRally.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 2
endIf
_spellSelectedEffectiveCost = _spellCourage.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
elseIf selfAVIllusion > 0 as Float
_spellSelectedEffectiveCost = _spellCourage.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
endIf
return 0
elseIf spellCategory == "Calm"
Float selfavillusion = _selfRef.GetActorValue("Illusion")
if selfavillusion >= 100 as Float
if spellSelected == 5
_spellSelectedEffectiveCost = _spellHarmony.GetEffectiveMagickaCost(_selfRef) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 5
endIf
_spellSelectedEffectiveCost = _spellPacify.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 4
endIf
elseIf spellSelected == 4
_spellSelectedEffectiveCost = _spellPacify.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 4
endIf
elseIf spellSelected == 3
_spellSelectedEffectiveCost = _spellPacify.GetEffectiveMagickaCost(_selfRef) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 3
endIf
_spellSelectedEffectiveCost = _spellCalm.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 2
endIf
elseIf spellSelected == 2
_spellSelectedEffectiveCost = _spellCalm.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 2
endIf
elseIf spellSelected == 1
_spellSelectedEffectiveCost = _spellCalm.GetEffectiveMagickaCost(_selfRef) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
endIf
elseIf selfavillusion >= 75 as Float
if spellSelected == 5 || spellSelected == 4
_spellSelectedEffectiveCost = _spellPacify.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 4
endIf
elseIf spellSelected == 3
_spellSelectedEffectiveCost = _spellPacify.GetEffectiveMagickaCost(_selfRef) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 3
endIf
_spellSelectedEffectiveCost = _spellCalm.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 2
endIf
elseIf spellSelected == 2
_spellSelectedEffectiveCost = _spellCalm.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 2
endIf
elseIf spellSelected == 1
_spellSelectedEffectiveCost = _spellCalm.GetEffectiveMagickaCost(_selfRef) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
endIf
elseIf selfavillusion >= 25 as Float
if spellSelected == 3 || spellSelected == 2
_spellSelectedEffectiveCost = _spellCalm.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 2
endIf
elseIf spellSelected == 1
_spellSelectedEffectiveCost = _spellCalm.GetEffectiveMagickaCost(_selfRef) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
endIf
endIf
return 0
elseIf spellCategory == "Heal"
Float selfAVRestoration = _selfRef.GetActorValue("Restoration")
if selfAVRestoration >= 75 as Float
if spellSelected == 7
_spellSelectedEffectiveCost = (_spellGrandHealing.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 7
endIf
_spellSelectedEffectiveCost /= 2 as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 6
endIf
_spellSelectedEffectiveCost = (_spellLesserGrandHealing.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 5
endIf
_spellSelectedEffectiveCost /= 2 as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 4
endIf
elseIf spellSelected == 6
_spellSelectedEffectiveCost = _spellGrandHealing.GetEffectiveMagickaCost(_selfRef) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 6
endIf
_spellSelectedEffectiveCost = (_spellLesserGrandHealing.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 5
endIf
_spellSelectedEffectiveCost /= 2 as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 4
endIf
elseIf spellSelected == 5
_spellSelectedEffectiveCost = (_spellLesserGrandHealing.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 5
endIf
_spellSelectedEffectiveCost /= 2 as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 4
endIf
elseIf spellSelected == 4
_spellSelectedEffectiveCost = _spellLesserGrandHealing.GetEffectiveMagickaCost(_selfRef) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 4
endIf
elseIf spellSelected == 3
_spellSelectedEffectiveCost = (_spellHealOther.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 3
endIf
_spellSelectedEffectiveCost /= 2 as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 2
endIf
_spellSelectedEffectiveCost = (_spellHealingHands.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
elseIf spellSelected == 2
_spellSelectedEffectiveCost = _spellHealOther.GetEffectiveMagickaCost(_selfRef) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 2
endIf
_spellSelectedEffectiveCost = (_spellHealingHands.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
elseIf spellSelected == 1
_spellSelectedEffectiveCost = (_spellHealingHands.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
endIf
elseIf selfAVRestoration >= 50 as Float
if spellSelected == 3
_spellSelectedEffectiveCost = (_spellHealOther.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 3
endIf
_spellSelectedEffectiveCost /= 2 as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 2
endIf
_spellSelectedEffectiveCost = (_spellHealingHands.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
elseIf spellSelected == 2
_spellSelectedEffectiveCost = _spellHealOther.GetEffectiveMagickaCost(_selfRef) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 2
endIf
_spellSelectedEffectiveCost = (_spellHealingHands.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
elseIf spellSelected == 1
_spellSelectedEffectiveCost = (_spellHealingHands.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
endIf
elseIf selfAVRestoration >= 25 as Float
if spellSelected <= 3
_spellSelectedEffectiveCost = (_spellHealingHands.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
endIf
endIf
return 0
elseIf spellCategory == "MiscAlteration"
Float selfavalteration = _selfRef.GetActorValue("Alteration")
if selfavalteration >= 50 as Float
if spellSelected == 2
_spellSelectedEffectiveCost = _spellTransmute.GetEffectiveMagickaCost(_selfRef) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 2
endIf
elseIf spellSelected == 1
_spellSelectedEffectiveCost = (_spellMageLight.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
endIf
elseIf selfavalteration >= 25 as Float
if spellSelected == 1
_spellSelectedEffectiveCost = (_spellMageLight.GetEffectiveMagickaCost(_selfRef) * 2) as Float
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
endIf
endIf
return 0
elseIf spellCategory == "MiscIllusion"
Float selfavillusion = _selfRef.GetActorValue("Illusion")
if selfavillusion >= 75 as Float
if spellSelected == 2
_spellSelectedEffectiveCost = _spellInvisibility.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 2
endIf
elseIf spellSelected == 1
_spellSelectedEffectiveCost = _spellMuffle.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
endIf
elseIf selfavillusion >= 25 as Float
if spellSelected == 1
_spellSelectedEffectiveCost = _spellMuffle.GetEffectiveMagickaCost(_selfRef) as Float * 2.80000
if _selfAVMagicka >= _spellSelectedEffectiveCost
return 1
endIf
endIf
endIf
return 0
elseIf spellCategory == "MiscRestoration"
return 1
endIf
endFunction
function Muffle()
if _tpCelestineAIQuestRef._spellMiscIllusion != -1
_tpCelestineAIQuestRef._spellMiscIllusion = self.GetAvailableSpell("MiscIllusion", 1)
if _tpCelestineAIQuestRef._spellMiscIllusion > 0
_sceneMiscIllusion.Start()
while _sceneMiscIllusion.IsPlaying() == true
utility.Wait(0.500000)
endWhile
endIf
endIf
endFunction
function HealTargets(Bool isMultiTargets, Actor currentTarget)
if _tpCelestineAIQuestRef._spellHeal != -1
if currentTarget.HasKeyword(_keywordDwarven) == false && currentTarget.HasKeyword(_keywordDaedra) == false && currentTarget.HasKeyword(_keywordUndead) == false
Float currentTargetHealth = currentTarget.GetActorValue("Health")
Float currentTargetMaxHealth = currentTargetHealth / currentTarget.GetActorValuePercentage("Health")
Float currentTargetHealthLoss = currentTargetMaxHealth - currentTargetHealth
if isMultiTargets == false
if currentTargetHealthLoss >= 200 as Float
_tpCelestineAIQuestRef._spellHeal = self.GetAvailableSpell("Heal", 3)
elseIf currentTargetHealthLoss >= 100 as Float
_tpCelestineAIQuestRef._spellHeal = self.GetAvailableSpell("Heal", 2)
elseIf currentTargetHealthLoss >= 50 as Float
_tpCelestineAIQuestRef._spellHeal = self.GetAvailableSpell("Heal", 1)
else
_tpCelestineAIQuestRef._spellHeal = 0
endIf
else
Float playerHealth = _playerRef.GetActorValue("Health")
Float playerMaxHealth = playerHealth / _playerRef.GetActorValuePercentage("Health")
Float playerHealthLoss = playerMaxHealth - playerHealth
if playerHealthLoss > 0 as Float && currentTargetHealthLoss > 0 as Float
if playerHealthLoss >= 400 as Float || currentTargetHealthLoss >= 400 as Float
_tpCelestineAIQuestRef._spellHeal = self.GetAvailableSpell("Heal", 7)
elseIf playerHealthLoss >= 200 as Float || currentTargetHealthLoss >= 200 as Float
_tpCelestineAIQuestRef._spellHeal = self.GetAvailableSpell("Heal", 6)
elseIf playerHealthLoss >= 100 as Float || currentTargetHealthLoss >= 100 as Float
_tpCelestineAIQuestRef._spellHeal = self.GetAvailableSpell("Heal", 5)
elseIf playerHealthLoss >= 50 as Float || currentTargetHealthLoss >= 50 as Float
_tpCelestineAIQuestRef._spellHeal = self.GetAvailableSpell("Heal", 4)
else
_tpCelestineAIQuestRef._spellHeal = 0
endIf
endIf
endIf
if _tpCelestineAIQuestRef._spellHeal == 1
_tpCelestineTargetRef.ForceRefTo(currentTarget as objectreference)
_sceneHeal.Start()
while _sceneHeal.IsPlaying() == true
if _selfRef.GetActorValue("Magicka") >= _spellSelectedEffectiveCost && currentTarget.GetActorValuePercentage("Health") < 0.900000
utility.Wait(1.00000)
_selfRef.DamageActorValue("Magicka", _spellSelectedEffectiveCost)
else
_sceneHeal.Stop()
endIf
endWhile
spell equippedSpellRH = _selfRef.GetEquippedSpell(1)
if equippedSpellRH
_selfRef.UnequipSpell(equippedSpellRH, 1)
endIf
elseIf _tpCelestineAIQuestRef._spellHeal > 0
_tpCelestineTargetRef.ForceRefTo(_playerRef as objectreference)
while _selfRef.GetActorValue("Magicka") >= _spellSelectedEffectiveCost && _playerRef.GetActorValuePercentage("Health") < 0.900000
_sceneHeal.Start()
while _sceneHeal.IsPlaying() == true
utility.Wait(0.500000)
endWhile
endWhile
spell equippedspellrh = _selfRef.GetEquippedSpell(1)
if equippedspellrh
_selfRef.UnequipSpell(equippedspellrh, 1)
endIf
endIf
endIf
endIf
endFunction
function Initialize()
if self.GetActorRef() as Bool && game.GetPlayer() as Bool
_tpCelestineAIQuestRef = self.GetOwningQuest() as tpCelestineAIQuestScript
_playerRef = game.GetPlayer()
_selfRef = self.GetActorRef()
_isInCombat = false
_spellSelectedEffectiveCost = 0 as Float
_selfAVMagicka = 0 as Float
_updateIntervalNormal = 10.0000
_updateIntervalCombat = 1.00000
self.RegisterForSingleLOSGain(_selfRef, _playerRef as objectreference)
endIf
endFunction
function DispelHarmfulEffects()
if _tpCelestineAIQuestRef._spellMiscRestoration != -1
_tpCelestineAIQuestRef._spellMiscRestoration = self.GetAvailableSpell("MiscRestoration", 0)
if _tpCelestineAIQuestRef._spellMiscRestoration > 0
_tpCelestineTargetRef.ForceRefTo(_playerRef as objectreference)
_sceneMiscRestoration.Start()
while _sceneMiscRestoration.IsPlaying() == true
utility.Wait(0.500000)
endWhile
endIf
endIf
endFunction
function OnUpdate()
if _selfRef.IsInCombat() == false
if _playerRef.IsSneaking() == true
self.Muffle()
endIf
self.Invisibility()
if _selfRef.IsInInterior() == true
self.MageLight()
endIf
self.TransmuteOre()
self.RegisterForSingleUpdate(_updateIntervalNormal)
else
if _selfRef.IsBleedingOut() == false
Actor combatTarget = _selfRef.GetCombatTarget()
if combatTarget
if combatTarget.IsDead() == false && combatTarget != _playerRef
if _playerRef.IsWeaponDrawn() == false
self.CalmTargets(false, combatTarget)
endIf
endIf
Bool isAlly = false
Actor aroundCombatTarget = game.FindRandomActorFromRef(combatTarget as objectreference, 400.000)
Actor aroundSelfTarget = game.FindRandomActorFromRef(_selfRef as objectreference, 400.000)
if aroundCombatTarget as Bool && aroundCombatTarget.IsDead() == false
if aroundCombatTarget != _selfRef && aroundCombatTarget != _playerRef && aroundCombatTarget != combatTarget
if aroundCombatTarget.IsHostileToActor(_selfRef) == true
isAlly == false
self.CalmTargets(true, aroundCombatTarget)
else
isAlly == true
self.HealTargets(true, aroundCombatTarget)
endIf
endIf
endIf
if isAlly == true
self.HealTargets(false, aroundCombatTarget)
endIf
if aroundSelfTarget as Bool && aroundSelfTarget.IsDead() == false
if aroundSelfTarget != _playerRef && aroundSelfTarget != combatTarget
if aroundSelfTarget.IsHostileToActor(_selfRef) == true
isAlly == false
self.CalmTargets(true, aroundSelfTarget)
else
isAlly == true
self.HealTargets(true, aroundSelfTarget)
endIf
endIf
endIf
if isAlly == true
self.HealTargets(false, aroundSelfTarget)
endIf
self.HealTargets(false, _playerRef)
endIf
endIf
self.RegisterForSingleUpdate(_updateIntervalCombat)
endIf
endFunction
; Skipped compiler generated GotoState
function OnGainLOS(Actor akViewer, objectreference akTarget)
self.RegisterForSingleUpdate(_updateIntervalNormal)
endFunction
function OnSpellCast(form akSpell)
spell spellCast = akSpell as spell
if spellCast
if _selfAVMagicka == _selfRef.GetActorValue("Magicka")
if spellCast.GetEffectiveMagickaCost(_selfRef) > 0
_selfRef.DamageActorValue("Magicka", _spellSelectedEffectiveCost)
endIf
endIf
self.TradeStaminaForMagicka()
endIf
endFunction
; Skipped compiler generated GetState
function TransmuteOre()
if _tpCelestineAIQuestRef._spellMiscAlteration != -1
Int oreCount = _selfRef.GetItemCount(_objOreIron as form) * 2 + _selfRef.GetItemCount(_objOreSiver as form)
if oreCount > 0
_tpCelestineAIQuestRef._spellMiscAlteration = self.GetAvailableSpell("MiscAlteration", 2)
if _tpCelestineAIQuestRef._spellMiscAlteration > 0
while oreCount > 0 && _selfRef.GetActorValue("Magicka") >= _spellSelectedEffectiveCost
_sceneMiscAlteration.Start()
while _sceneMiscAlteration.IsPlaying() == true
utility.Wait(1.00000)
endWhile
oreCount -= 1
endWhile
endIf
endIf
endIf
endFunction
function TradeStaminaForMagicka()
Float selfAVStamina = _selfRef.GetActorValue("Stamina")
if _selfRef.GetActorValue("Magicka") < selfAVStamina
_selfRef.RestoreActorValue("Magicka", selfAVStamina)
_selfRef.DamageActorValue("Stamina", selfAVStamina)
endIf
endFunction