Running script on attack?

Post » Mon Jun 18, 2012 8:38 am

I want to run a script on a weapon, where each time I attack there's a small chance of the weapon being dropped. Any idea how this could be done?
User avatar
Eliza Potter
 
Posts: 3481
Joined: Mon Mar 05, 2007 3:20 am

Post » Mon Jun 18, 2012 6:06 pm

I want to run a script on a weapon, where each time I attack there's a small chance of the weapon being dropped. Any idea how this could be done?
Just posted this in another thread too, so here goes:

You can do this by adding an enchantment with a script attatched to it to your weapon, example:

1) Make a new weapon myweapon
2) Make a new enchantment myenchantment
3) Make a new magic-effect myeffect

4) Set the myeffect's settings/variables to:
casting type: fire and forgetdelivery: contactand if you want it to have no cost, base cost: 0

5) Add a papyrus script to your effect modeled after this:
Scriptname myscript extends ActiveMagicEffect{mydescription}Event OnEffectStart(Actor akTarget, Actor akCaster)if akCaster == Game.GetPlayer()  Debug.MessageBox("We hit them")EndIfEndEvent

6) Add myeffect to myenchantment, then myenchantment to myweapon

The current script will just create a little window in-game whenever the player hits someone with the weapon saying "we hit them"
User avatar
Andrew Tarango
 
Posts: 3454
Joined: Wed Oct 17, 2007 10:07 am


Return to V - Skyrim