Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Enemy death triggers spell for player


edhelsereg
 Share

Recommended Posts

Hey everyone,

 

I'm trying to write a script that will cause a spell to cast on the player when they kill anything (rabbit, bandit, dragon, etc.)

 

I need a script because I don't think there is any other way to make a 'constant magic effect' (for armor) contain a 'fire and forget effect' type spell.

 

The closest script, in concept, to what I'm trying to do is the one for Dawnbreaker, this is my adaptation.

 

 

Scriptname KARestoreStaminaSCRIPT extends ActiveMagicEffect  

 
Spell Property RestoreStaminaAll Auto

 

Event OnDying Actor(Actor akKiller, Form akSource, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked )
 
Actor TargetActor = GetTargetActor()
 
; ; debug.trace(self + "OnDeath() casting RestoreStaminaAll from Target Actor:" + TargetActor)
 
RestoreStaminaAll.Cast(TargetActor, None)
 
EndEvent
 
 
How do I re-write this Script so the event is triggered by the death of a combat target of the player, while redirecting the cast spell effect to the player?
 
Thanks! Please let me know if more info is necessary.
Edited by edhelsereg
Link to comment
Share on other sites

  • 2 months later...

I wrote this script for my WIP Dhaerrow race mod.  Here it is, although I'm triggering different spells depending on the players level, so I think you'll want to remove the lines that I put a strike through, in order to get what you want. 

 

Scriptname yyyDrowOnKillShadowStalker extends ActiveMagicEffect  

Event OnDying(actor akKiller)
Debug.Notification("akKiller has killed something!")
    if (akKiller == game.getPlayer())
Debug.Notification("The player has killed something!")
    int level = akKiller.getLevel()
        if (level >= 60)
            Spell_Tier5.cast(akKiller,akKiller)
            Debug.Notification("TESTING Spell Tier 5 cast")
        elseif (level >= 50)
            Spell_Tier4.cast(akKiller,akKiller)
            Debug.Notification("TESTING Spell Tier 4 cast")
        elseif (level >= 40)
            Spell_Tier3.cast(akKiller,akKiller)
            Debug.Notification("TESTING Spell Tier 3 cast")
        elseif (level >= 30)
            Spell_Tier2.cast(akKiller,akKiller)
            Debug.Notification("TESTING Spell Tier 2 cast")
        elseif (level >= 20)
            Spell_Tier1.cast(akKiller,akKiller)
            Debug.Notification("TESTING Spell Tier 1 cast")
        elseif (level >= 0)
            Spell_Tier0.cast(akKiller,akKiller)
            Debug.Notification("TESTING Spell Tier 0 cast")
        else
            Debug.Notification("This message should never appear, right?")
        endif

    endif
EndEvent

Spell Property Spell_Tier5 Auto
Spell Property Spell_Tier4 Auto
Spell Property Spell_Tier3 Auto
Spell Property Spell_Tier2 Auto
Spell Property Spell_Tier1 Auto
Spell Property Spell_Tier0 Auto

 

I attached the script to a magic effect that has a target condition of the player having a getlightlevel of <= 40, which triggers my fun "on kill bonus spell" whenever something dies, while the player was in the shadows.  XD  This scripts works for me from kiling bunnies to summons to whatever else might die within the area of the magic effect for which it's been attached.

 

If anyone can help improve the script to only work when the player kills the target, please let me know!  I don't like it when a follower dies and my character gets the "on kill bonus."  I also would like for it to only target against hostile enemies, but am not sure how to do that either and am concerned that doing so would prevent the script from triggering against enemies that the player one shot kills...???  Finally, might it be possible to limit the script to only triggering when the player caused the damage that killed the actor that had died?  Again, it's kind of cheap when a summon or follower finishes something off and my player gets this bonus.

Edited by SkyrimModHunter
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...