Casting Spell when item is equipped

Post » Thu Jun 21, 2012 10:54 pm

I've been working on a mod that creates two twin swords whose abilities only work if both are equipped. I was having a problem with that (http://www.gamesas.com/topic/1382081-weapon-enchantment-doesnt-work-in-one-hand/), so I moved on ahead to another point in the mod. When the swords are equipped, I want them to cast a spell on me (or at least freakin' add it!).
Scriptname TBoLvision extends activemagiceffectEvent OnEquipped(Actor akActor)	  akactor.AddSpell(BoLLight)EndEventEvent OnUnEquipped(Actor akActor)   akActor.RemoveSpell(BoLLight)EndEventweapon property TBoL1Luusi autoweapon property TBoL2Fuer autospell property BoLLight auto

This is just the latest failure, after many other ideas that seemed better. Anyone know how to do this?
User avatar
James Potter
 
Posts: 3418
Joined: Sat Jul 07, 2007 11:40 am

Post » Thu Jun 21, 2012 5:24 pm

Solved by:

Scriptname TBoLvision extends objectreference Event OnEquipped(Actor akActor)   if akActor == Game.GetPlayer()	  	  if (Game.GetPlayer().IsEquipped(TBoL2Fuer))  		 akactor.AddSpell(BoLLightcdy)	  endif   endif  EndEventEvent OnUnEquipped(Actor akActor)   akActor.RemoveSpell(BoLLightcdy)   akActor.DispelSpell(BoLLightcdy)EndEventweapon property TBoL1Luusi autoweapon property TBoL2Fuer autospell property BoLLightcdy auto

Works great! Now for the original problem...
User avatar
Ann Church
 
Posts: 3450
Joined: Sat Jul 29, 2006 7:41 pm

Post » Thu Jun 21, 2012 8:22 pm

Unless the spell is a constant self effect, I think what you actually want is to use the cast function, not AddSpell/RemoveSpell.
User avatar
Siobhan Thompson
 
Posts: 3443
Joined: Sun Nov 12, 2006 10:40 am

Post » Thu Jun 21, 2012 2:08 pm

Unless the spell is a constant self effect, I think what you actually want is to use the cast function, not AddSpell/RemoveSpell.

I didn't use the cast function because the spell is a Night Eye spell, and you wouldn't want that active during the day!
User avatar
Jonny
 
Posts: 3508
Joined: Wed Jul 18, 2007 9:04 am


Return to V - Skyrim