Can I use script to create a spell that costs health to cast

Post » Tue Jun 19, 2012 3:22 am

I'm planning to create a spell that costs health when cast, so I wrote a script, but it doesn't work...

Here's the script
Spoiler
Scriptname lmspellscript extends ObjectReference
{Damage health each time cast the spell}
Spell Property LMspell Auto
Event OnSpellCast(Form akspell)
Spell spellCast = akSpell as Spell
If spellCast == LMspell
Game.GetPlayer().DamageAV("health",50)
EndIf

EndEvent

LMspell should cost health to cast, but it doesn't subtract my character's health at all..
I've tried to attach the script to the magic effect used by LMspell, as well as a cuirass equipped by the player, none of them worked.

I'm pretty sure that I hooked up the spell property with LMspell so it won't be the cause.
The script can be compiled successfully.

Scripting is pretty new to me, I've just finish the scripting tutorials on the creationkit wiki :laugh:
I even don't know what kind of script should I use..
PLZ help, thanks a lot.
User avatar
JAY
 
Posts: 3433
Joined: Fri Sep 14, 2007 6:17 am

Post » Tue Jun 19, 2012 12:56 am

that would either need to be attached
1.directly to the actor casting the spell or
2.to an ability (or other constant effect spell) that would need to be active on the actor casting the spell

edit:for #2 you would need to change the first line to - extends ActiveMagicEffect
User avatar
Pat RiMsey
 
Posts: 3306
Joined: Fri Oct 19, 2007 1:22 am

Post » Tue Jun 19, 2012 9:32 am

This isn't a direct answer, but the ingame spell Equilibrium costs health to cast, and in return it gives you mana. You could look there and see how Bethesda set it up
User avatar
Ilona Neumann
 
Posts: 3308
Joined: Sat Aug 19, 2006 3:30 am

Post » Tue Jun 19, 2012 11:16 am

jackmix69 gives good advice. If I were you, I would try:
scriptname lmspellscript extends activemagiceffectEvent OnEffectStart(Actor Target,  Actor Caster)  caster.damageav("health", 50)endEvent

and then equip it on a new active effect, then add that active effect to the spell you want the effect to apply to. If you don't want it to use magicka too, you will have to uncheck the "autocalculate" box at the bottom of the spell box and set the spell cost to 0.
User avatar
Verity Hurding
 
Posts: 3455
Joined: Sat Jul 22, 2006 1:29 pm

Post » Mon Jun 18, 2012 10:45 pm

Unfortunately, you can't read the magnitude value from an ActiveMagicEffect script, or you could use Magnitude to calculate how much health to take.
User avatar
Chloe Botham
 
Posts: 3537
Joined: Wed Aug 30, 2006 12:11 am

Post » Tue Jun 19, 2012 5:34 am

This isn't a direct answer, but the ingame spell Equilibrium costs health to cast, and in return it gives you mana. You could look there and see how Bethesda set it up
jackmix69 gives good advice. If I were you, I would try:
scriptname lmspellscript extends activemagiceffectEvent OnEffectStart(Actor Target,  Actor Caster)  caster.damageav("health", 50)endEvent

and then equip it on a new active effect, then add that active effect to the spell you want the effect to apply to. If you don't want it to use magicka too, you will have to uncheck the "autocalculate" box at the bottom of the spell box and set the spell cost to 0.

Thanks, I'm going to try it out.
User avatar
Gisela Amaya
 
Posts: 3424
Joined: Tue Oct 23, 2007 4:29 pm


Return to V - Skyrim