Jump to content

Photo

Need help with script: add spells when armor is equipped

spells spell script armor ring magic

  • Please log in to reply
17 replies to this topic

#11
lofgren

lofgren

    Resident poster

  • Supporter
  • PipPipPipPipPip
  • 3,261 posts
If it's on an alias then it should fire every time because it's only being triggered when that persistent object is equipped.

#12
FafnirEtherion

FafnirEtherion

    Resident poster

  • Members
  • PipPipPipPipPip
  • 2,590 posts

Hey ! Thanks for the tips, guys !

I hope I'll manage to script properly ^^ !



#13
FafnirEtherion

FafnirEtherion

    Resident poster

  • Members
  • PipPipPipPipPip
  • 2,590 posts

So, here's my script :

 

Scriptname YellowLanternRingScript extends ObjectReference
SPELL Property SummonYellowLanternBowConstructSpell Auto
SPELL Property SummonYellowLanternFrostbiteSpiderConstructSpell Auto
SPELL Property SummonYellowLanternKatanaConstructSpell Auto
SPELL Property SummonYellowLanternScytheConstructSpell Auto
SPELL Property SummonYellowLanternSkeletonConstructSpell Auto
SPELL Property YellowLanternArrowsSpell Auto
SPELL Property YellowLanternAuraLightSpell Auto
SPELL Property YellowLanternAuraStrongSpell Auto
SPELL Property YellowLanternBeamSpell Auto
SPELL Property YellowLanternBoltExplo Auto
SPELL Property YellowLanternBoltSpell Auto
SPELL Property YellowLanternBowSpell Auto
SPELL Property YellowLanternKatanaSpell Auto
SPELL Property YellowLanternScytheSpell Auto

 

Event OnEquipped(Actor AkActor)

Game.GetPlayer().AddSpell(YellowLanternAuraLightSpell)
Game.GetPlayer().AddSpell(SummonYellowLanternBowConstructSpell)
Game.GetPlayer().AddSpell(SummonYellowLanternFrostbiteSpiderConstructSpell)
Game.GetPlayer().AddSpell(SummonYellowLanternKatanaConstructSpell)
Game.GetPlayer().AddSpell(SummonYellowLanternScytheConstructSpell)
Game.GetPlayer().AddSpell(SummonYellowLanternSkeletonConstructSpell)
Game.GetPlayer().AddSpell(YellowLanternArrowsSpell)
Game.GetPlayer().AddSpell(YellowLanternAuraStrongSpell)
Game.GetPlayer().AddSpell(YellowLanternBeamSpell)
Game.GetPlayer().AddSpell(YellowLanternBoltExplo)
Game.GetPlayer().AddSpell(YellowLanternBoltSpell)
Game.GetPlayer().AddSpell(YellowLanternBowSpell)
Game.GetPlayer().AddSpell(YellowLanternKatanaSpell)
Game.GetPlayer().AddSpell(YellowLanternScytheSpell)
EndEvent

 

Event OnUnequipped(Actor AkActor)

Game.GetPlayer().RemoveSpell(YellowLanternAuraLightSpell)
Game.GetPlayer().RemoveSpell(SummonYellowLanternBowConstructSpell)
Game.GetPlayer().RemoveSpell(SummonYellowLanternFrostbiteSpiderConstructSpell)
Game.GetPlayer().RemoveSpell(SummonYellowLanternKatanaConstructSpell)
Game.GetPlayer().RemoveSpell(SummonYellowLanternScytheConstructSpell)
Game.GetPlayer().RemoveSpell(SummonYellowLanternSkeletonConstructSpell)
Game.GetPlayer().RemoveSpell(YellowLanternArrowsSpell)
Game.GetPlayer().RemoveSpell(YellowLanternAuraStrongSpell)
Game.GetPlayer().RemoveSpell(YellowLanternBeamSpell)
Game.GetPlayer().RemoveSpell(YellowLanternBoltExplo)
Game.GetPlayer().RemoveSpell(YellowLanternBoltSpell)
Game.GetPlayer().RemoveSpell(YellowLanternBowSpell)
Game.GetPlayer().RemoveSpell(YellowLanternKatanaSpell)
Game.GetPlayer().RemoveSpell(YellowLanternScytheSpell)
EndEvent

 

I don't know why, but only the YellowLanternAuraLightSpell is added / removed of the player inventory when I equip the ring...

It's worth noting that at first, The script was like that

 

Scriptname YellowLanternRingScript extends ObjectReference
SPELL Property YellowLanternAuraLightSpell Auto

 

Event OnEquipped(Actor AkActor)
Game.GetPlayer().AddSpell(YellowLanternAuraLightSpell)
EndEvent

 

Event OnUnequipped(Actor AkActor)
Game.GetPlayer().RemoveSpell(YellowLanternAuraLightSpell)
EndEvent

 

Then, I added every other spells after a quick ingame check to see if the aura spell was properly added

 

 

 

 

 

EDIT ! Nevermind, I re-started a game to test the script from a fresh save and it worked flawlessly ! I am REALLY happy right now :D !!! I've just made my first working script ^^ ! Hurrah !!!


Edited by FafnirEterion, 20 February 2017 - 03:50 PM.


#14
Masterofnet

Masterofnet

    Fan

  • Banned
  • PipPipPip
  • 406 posts

Ok

 

1.  If you are looking for help with script, post it like this.  Much easier to read.

2.  Have you made sure to fill all of the script properties?

3.  If you have all the properties filled, and you are having an issue like this,  just attempt to add and remove one spell at a time.   If it works add another.

4.  Keep in mind, depending on what some of these spells are, it may be better to use YourSpell.Cast(AkActor, AkActor) 

     http://www.creationk...le=Cast_-_Spell

5.  You should be able to put allot of these magic effects on one spell.   You should not need a separate spell for every different effect.

 

Hopefully other people will offer some help also.  

 

Way to show some initiative! 

Scriptname YellowLanternRingScript extends ObjectReference

SPELL Property SummonYellowLanternBowConstructSpell Auto
SPELL Property SummonYellowLanternFrostbiteSpiderConstructSpell Auto
SPELL Property SummonYellowLanternKatanaConstructSpell Auto
SPELL Property SummonYellowLanternScytheConstructSpell Auto
SPELL Property SummonYellowLanternSkeletonConstructSpell Auto
SPELL Property YellowLanternArrowsSpell Auto
SPELL Property YellowLanternAuraLightSpell Auto
SPELL Property YellowLanternAuraStrongSpell Auto
SPELL Property YellowLanternBeamSpell Auto
SPELL Property YellowLanternBoltExplo Auto
SPELL Property YellowLanternBoltSpell Auto
SPELL Property YellowLanternBowSpell Auto
SPELL Property YellowLanternKatanaSpell Auto
SPELL Property YellowLanternScytheSpell Auto
 
Event OnEquipped(Actor AkActor)
  If AkActor = Game.GetPlayer()
    AkActor.AddSpell(YellowLanternAuraLightSpell)
    AkActor.AddSpell(SummonYellowLanternBowConstructSpell)
    AkActor.AddSpell(SummonYellowLanternFrostbiteSpiderConstructSpell)
    AkActor.AddSpell(SummonYellowLanternKatanaConstructSpell)
    AkActor.AddSpell(SummonYellowLanternScytheConstructSpell)
    AkActor.AddSpell(SummonYellowLanternSkeletonConstructSpell)
    AkActor.AddSpell(YellowLanternArrowsSpell)
    AkActor.AddSpell(YellowLanternAuraStrongSpell)
    AkActor.AddSpell(YellowLanternBeamSpell)
    AkActor.AddSpell(YellowLanternBoltExplo)
    AkActor.AddSpell(YellowLanternBoltSpell)
    AkActor.AddSpell(YellowLanternBowSpell)
    AkActor.AddSpell(YellowLanternKatanaSpell)
    AkActor.AddSpell(YellowLanternScytheSpell)
  EndIf
EndEvent

Event OnUnequipped(Actor AkActor)
  If AkActor = Game.GetPlayer()
    AkActor.RemoveSpell(YellowLanternAuraLightSpell)
    AkActor.RemoveSpell(SummonYellowLanternBowConstructSpell)
    AkActor.RemoveSpell(SummonYellowLanternFrostbiteSpiderConstructSpell)
    AkActor.RemoveSpell(SummonYellowLanternKatanaConstructSpell)
    AkActor.RemoveSpell(SummonYellowLanternScytheConstructSpell)
    AkActor.RemoveSpell(SummonYellowLanternSkeletonConstructSpell)
    AkActor.RemoveSpell(YellowLanternArrowsSpell)
    AkActor.RemoveSpell(YellowLanternAuraStrongSpell)
    AkActor.RemoveSpell(YellowLanternBeamSpell)
    AkActor.RemoveSpell(YellowLanternBoltExplo)
    AkActor.RemoveSpell(YellowLanternBoltSpell)
    AkActor.RemoveSpell(YellowLanternBowSpell)
    AkActor.RemoveSpell(YellowLanternKatanaSpell)
    AkActor.RemoveSpell(YellowLanternScytheSpell)
  EndIf
EndEvent

Edited by Masterofnet, 20 February 2017 - 10:46 PM.


#15
carbondz2010

carbondz2010

    Enthusiast

  • Members
  • PipPip
  • 102 posts

I can do add and also activate the spells (magic effect) if I equip and dispell then remove if I unequip, but is there any ways to add and activate for a set of armor?

but Idk where should I put the script

 

so far but not working

If (Game.GetPlayer().IsEquipped(helmetProperty AND cuirassProperty AND bootsProperty AND gauntletsProperty AND ringProperty)) THEN
   akActor.AddSpell(spellProperty)
   spellProperty.Cast(akActor)
Else
    akactor.DispelSpell(spellProperty)
    akActor.RemoveSpell(spellProperty)
EndIf

Edited by carbondz2010, 19 May 2020 - 06:11 AM.


#16
dylbill

dylbill

    Faithful poster

  • Supporter
  • PipPipPipPip
  • 1,346 posts

You would put the script on a reference alias in a new quest pointing at the player. Also looks like theres some syntax errors in your script. It should look like: 

 

Spoiler
 
Name the script something more unique though. I think it would be better though to make your spell a constant effect ability, and put the conditions directly on the spell / magic effect instead of using a script to cast the spell.


#17
carbondz2010

carbondz2010

    Enthusiast

  • Members
  • PipPip
  • 102 posts

Thanks, this is working but need to make script each equipment with the same code.

'----------------Here for helmet,then need all armor parts----------'

Scriptname HelmetPropertyMagicEffect extends ObjectReference  

Armor Property HelmetProperty Auto
Armor Property CuirassProperty Auto
Armor Property BootsProperty Auto
Armor Property GauntletsProperty Auto
Armor Property RingProperty Auto
Spell Property SpellProperty Auto 

Event OnEquipped(Actor AkActor)
    If AkActor.IsEquipped(HelmetProperty) && AkActor.IsEquipped(CuirassProperty) && AkActor.IsEquipped(BootsProperty) && AkActor.IsEquipped(GauntletsProperty) && AkActor.IsEquipped(RingProperty)    
       AkActor.AddSpell(SpellProperty)
      SpellProperty.Cast(AkActor)
    EndIf
EndEvent 

Event OnUnequipped(Actor AkActor)
    If AkActor.IsEquipped(HelmetProperty) && AkActor.IsEquipped(CuirassProperty) && AkActor.IsEquipped(BootsProperty) && AkActor.IsEquipped(GauntletsProperty) && AkActor.IsEquipped(RingProperty)    
        ;do nothing 
    Else
        AkActor.DispelSpell(SpellProperty)
        AkActor.RemoveSpell(SpellProperty)
    Endif 
EndEvent

I change the OnObjectEquipped to OnEquipped

I change the OnObjectUnequipped to OnUnequipped

 

 

I try to followers or other NPC not working. just me as player will work with the spell.

Any idea?


Edited by carbondz2010, 19 May 2020 - 01:50 PM.


#18
dylbill

dylbill

    Faithful poster

  • Supporter
  • PipPipPipPip
  • 1,346 posts

Hmm, not sure, that should be working. But for better performance, try making your spell type to Ability, you may need to change the magic effects to Constant Effect. Then put the conditions on the spell / magic effects directly in the Creation Kit. 

 

GetEquipped Helmet == 1 AND 

GetEquipped Cuirass == 1 AND 

ect... 

 

That way, the magic effects only become active when all of the armor is equipped, and they become inactive if they aren't all equipped. Then put this script on each armor piece: 

Spoiler






Also tagged with one or more of these keywords: spells, spell, script, armor, ring, magic

Page loaded in: 1.084 seconds