How consume character magicka when casting from staff ?

Post » Sat Nov 17, 2012 3:31 am

I want to make spells cast from staves to consume some magicka from the character. It can be either a percent of the original spell cost or a specific value according to the spell level. For example, when casting a Thunderbolt using the Staff of Thunderbolts, I want the character to pay, say, 20% of the Thunderbolt cost. Or, if this is not possible, at least pay, say, 50 magicka since this is an expert spell.

By taking a look at staves in the CK, I see they just have an enchantment attached, and this enchantment is associated to the exact same spell characters can cast. So, seems the only difference is that the cost is removed from the staff energy instead of being removed from the character's magicka pool.

My questions are: How can I identify if a spell is being cast by the character or from a staff? Where can I put the script to consume magicka from the character? And how can I cancel the cast if the caster has no enough magicka (not consuming the staff energy)?
User avatar
zoe
 
Posts: 3298
Joined: Sun Nov 12, 2006 1:09 pm

Post » Fri Nov 16, 2012 3:20 pm

In early versions of some of my spells I did this by using PlayerRef.DamageAV("Magicka",10), after checking for perks that altered Magicka consumption.

There's probably a much more elegant way to do it, but failing all else, this will work.
User avatar
x_JeNnY_x
 
Posts: 3493
Joined: Wed Jul 05, 2006 3:52 pm

Post » Fri Nov 16, 2012 3:11 pm

Yes, DamageAV is the command I was hoping to use.

But where exactly should I place my script? Should I add a script to all staves and override the OnSpellCast() method? Does the game understand the spell is being cast by the item itself and not the player in this case?
User avatar
Andrea Pratt
 
Posts: 3396
Joined: Mon Jul 31, 2006 4:49 am


Return to V - Skyrim