Scriptname Dirty_FollowerScript extends ActiveMagicEffect Spell Dirty_Spell_Blood1 Spell Dirty_Spell_Blood2 Spell Dirty_Spell_Blood3 Spell Dirty_Spell_Blood4 Spell Dirty_Spell_Dirt1 Spell Dirty_Spell_Dirt2 Spell Dirty_Spell_Dirt3 Spell Dirty_Spell_Dirt4 Spell Dirty_Spell_Clean Spell Dirty_Spell_Swimming Spell Dirty_Spell_IsRaining GlobalVariable Dirty_RandomDirtDuration GlobalVariable Dirty_PlayerHitBloodyChance Actor MySelf Event OnEffectStart(Actor akTarget, Actor akCaster) Debug.Trace("Dirty_FollowerScript OnEffectStart akTarget=" + akTarget) MySelf = akTarget Dirty_Spell_Blood1 = Game.GetFormFromFile(0x809, "Dirt and Blood - Dynamic Visuals.esp") as Spell Dirty_Spell_Blood2 = Game.GetFormFromFile(0x80A, "Dirt and Blood - Dynamic Visuals.esp") as Spell Dirty_Spell_Blood3 = Game.GetFormFromFile(0x80B, "Dirt and Blood - Dynamic Visuals.esp") as Spell Dirty_Spell_Blood4 = Game.GetFormFromFile(0x839, "Dirt and Blood - Dynamic Visuals.esp") as Spell Dirty_Spell_Dirt1 = Game.GetFormFromFile(0x806, "Dirt and Blood - Dynamic Visuals.esp") as Spell Dirty_Spell_Dirt2 = Game.GetFormFromFile(0x807, "Dirt and Blood - Dynamic Visuals.esp") as Spell Dirty_Spell_Dirt3 = Game.GetFormFromFile(0x808, "Dirt and Blood - Dynamic Visuals.esp") as Spell Dirty_Spell_Dirt4 = Game.GetFormFromFile(0x838, "Dirt and Blood - Dynamic Visuals.esp") as Spell Dirty_Spell_Clean = Game.GetFormFromFile(0x80C, "Dirt and Blood - Dynamic Visuals.esp") as Spell Dirty_Spell_Swimming = Game.GetFormFromFile(0x825, "Dirt and Blood - Dynamic Visuals.esp") as Spell Dirty_Spell_IsRaining = Game.GetFormFromFile(0x85D, "Dirt and Blood - Dynamic Visuals.esp") as Spell Dirty_RandomDirtDuration = Game.GetFormFromFile(0x829, "Dirt and Blood - Dynamic Visuals.esp") as GlobalVariable Dirty_PlayerHitBloodyChance = Game.GetFormFromFile(0x82A, "Dirt and Blood - Dynamic Visuals.esp") as GlobalVariable MySelf.AddSpell(Dirty_Spell_Swimming) MySelf.AddSpell(Dirty_Spell_IsRaining) UntilNextTime() EndEvent Event OnUpdateGameTime() Debug.Trace("Dirty_FollowerScript OnUpdateGameTime MySelf=" + MySelf) If Dirty_RandomDirtDuration.GetValue() == 3 ; nothing else If MySelf.HasSpell(Dirty_Spell_Dirt4) ; nothing elseif MySelf.HasSpell(Dirty_Spell_Dirt3) MySelf.AddSpell(Dirty_Spell_Dirt4, false) MySelf.RemoveSpell(Dirty_Spell_Dirt3) elseif MySelf.HasSpell(Dirty_Spell_Dirt2) MySelf.AddSpell(Dirty_Spell_Dirt3, false) MySelf.RemoveSpell(Dirty_Spell_Dirt2) elseif MySelf.HasSpell(Dirty_Spell_Dirt1) MySelf.AddSpell(Dirty_Spell_Dirt2, false) MySelf.RemoveSpell(Dirty_Spell_Dirt1) elseif MySelf.HasSpell(Dirty_Spell_Clean) MySelf.AddSpell(Dirty_Spell_Dirt1, false) MySelf.RemoveSpell(Dirty_Spell_Clean) elseif MySelf.HasSpell(Dirty_Spell_Blood4) MySelf.AddSpell(Dirty_Spell_Dirt4, false) MySelf.RemoveSpell(Dirty_Spell_Blood4) elseif MySelf.HasSpell(Dirty_Spell_Blood3) MySelf.AddSpell(Dirty_Spell_Dirt4, false) MySelf.RemoveSpell(Dirty_Spell_Blood3) elseif MySelf.HasSpell(Dirty_Spell_Blood2) MySelf.AddSpell(Dirty_Spell_Dirt3, false) MySelf.RemoveSpell(Dirty_Spell_Blood2) elseif MySelf.HasSpell(Dirty_Spell_Blood1) MySelf.AddSpell(Dirty_Spell_Dirt2, false) MySelf.RemoveSpell(Dirty_Spell_Blood1) Endif Endif UntilNextTime() EndEvent Function UntilNextTime() Int RandomTime If Dirty_RandomDirtDuration.GetValue() == 0 RandomTime = Utility.RandomInt(48, 96) elseif Dirty_RandomDirtDuration.GetValue() == 1 RandomTime = Utility.RandomInt(24, 48) elseif Dirty_RandomDirtDuration.GetValue() == 2 RandomTime = Utility.RandomInt(12, 24) elseif Dirty_RandomDirtDuration.GetValue() == 3 RandomTime = 24 endif RegisterForSingleUpdateGameTime(RandomTime) EndFunction Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) ;Debug.Trace("Dirty_FollowerScript OnHit MySelf=" + MySelf) GoToState("Busy") if !abHitBlocked && (akSource as Weapon) && !MySelf.HasSpell(Dirty_Spell_Blood4) && MySelf.GetActorValuePercentage("Health") < 1.0 int hit_chance float hit_applies hit_chance = Utility.RandomInt(1, 100) hit_applies = Dirty_PlayerHitBloodyChance.GetValue() if abPowerAttack || abSneakAttack || (MySelf.GetActorValue("Health") < 50.0) hit_chance -= 20 endif ;Debug.Trace("Dirty_FollowerScript OnHit hit_chance=" + hit_chance + " <= hit_applies=" + hit_applies) if hit_chance <= hit_applies if MySelf.HasSpell(Dirty_Spell_Blood3) MySelf.AddSpell(Dirty_Spell_Blood4, false) MySelf.RemoveSpell(Dirty_Spell_Blood3) elseif MySelf.HasSpell(Dirty_Spell_Blood2) MySelf.AddSpell(Dirty_Spell_Blood3, false) MySelf.RemoveSpell(Dirty_Spell_Blood2) Elseif MySelf.HasSpell(Dirty_Spell_Blood1) MySelf.AddSpell(Dirty_Spell_Blood2, false) MySelf.RemoveSpell(Dirty_Spell_Blood1) elseif MySelf.HasSpell(Dirty_Spell_Dirt4) MySelf.AddSpell(Dirty_Spell_Blood4, false) MySelf.RemoveSpell(Dirty_Spell_Dirt4) elseif MySelf.HasSpell(Dirty_Spell_Dirt3) MySelf.AddSpell(Dirty_Spell_Blood3, false) MySelf.RemoveSpell(Dirty_Spell_Dirt3) elseif MySelf.HasSpell(Dirty_Spell_Dirt2) MySelf.AddSpell(Dirty_Spell_Blood2, false) MySelf.RemoveSpell(Dirty_Spell_Dirt2) elseif MySelf.HasSpell(Dirty_Spell_Dirt1) MySelf.AddSpell(Dirty_Spell_Blood1, false) MySelf.RemoveSpell(Dirty_Spell_Dirt1) elseif MySelf.HasSpell(Dirty_Spell_Clean) MySelf.AddSpell(Dirty_Spell_Blood1, false) MySelf.RemoveSpell(Dirty_Spell_Clean) else MySelf.AddSpell(Dirty_Spell_Blood1, false) endif endif endif Utility.Wait(1.0) GoToState("") EndEvent State Busy Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) EndEvent EndState