Scriptname CastingManagement extends activemagiceffect Message Property SpellFailedMSG Auto ; fill this with something along the lines of "The spell failed."Actor Property PlayerREF AutoSound Property MAGFail AutoEvent OnEffectStart(Actor akTarget, Actor akCaster) bool LeftSpellFailed = false ; we use these to check whether we should bool RightSpellFailed = false ; inform the player that the spell failed or not float LeftSpellSkill ; we need separate skill checks for either hands float RightSpellSkill int RandomRate = Utility.RandomInt() Spell LeftHandSpell = akCaster.GetEquippedSpell(0) ; first off, get the equipped spells.. Spell RightHandSpell = akCaster.GetEquippedSpell(1) if ( LeftHandSpell ) LeftSpellSkill = GetSpellSkill (LeftHandSpell, akCaster) ; ..then check for the casting actor skill if ( ( RandomRate - LeftSpellSkill ) > 0 ) akCaster.InterruptCast() LeftSpellFailed = true endif endif if ( RightHandSpell ) RightSpellSkill = GetSpellSkill (RightHandSpell, akCaster) if ( ( RandomRate - RightSpellSkill ) > 0 ) akCaster.InterruptCast() RightSpellFailed = true endif endif If ( ( akCaster == PlayerREF ) && ( ( LeftSpellFailed ) || ( RightSpellFailed ) ) ) SpellFailedMSG.Show() ; your spell failed! LOL! NOOB! MAGFail.play(akCaster) EndIfEndEventFloat Function GetSpellSkill(Spell ActorSpell, Actor CastingActor) float ActorSkill if ( ActorSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() == "Alteration" ) ActorSkill = CastingActor.GetActorValue("Alteration") elseif ( ActorSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() == "Conjuration") ActorSkill = CastingActor.GetActorValue("Conjuration") elseif ( ActorSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() == "Destruction") ActorSkill = CastingActor.GetActorValue("Destruction") elseif ( ActorSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() == "Illusion" ) ActorSkill = CastingActor.GetActorValue("Illusion") elseif ( ActorSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() == "Restoration" ) ActorSkill = CastingActor.GetActorValue("Restoration") endif return ActorSkillEndFunction
Scriptname CastingManagement extends activemagiceffect Sound Property MAGFail AutoEvent OnEffectStart(Actor akTarget, Actor akCaster) Bool SpellFail = false Spell LeftHandSpell = akCaster.GetEquippedSpell(0) Spell RightHandSpell = akCaster.GetEquippedSpell(1) if ( LeftHandSpell ) SpellFail = ( ( Utility.RandomInt() - akCaster.GetActorValue( LeftHandSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() ) ) > 0 ) endif if ( RightHandSpell ) SpellFail = ( ( Utility.RandomInt() - akCaster.GetActorValue( RightHandSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() ) ) > 0 ) endif if ( SpellFail ) akCaster.InterruptCast() MAGFail.play(akCaster) endifEndEvent