Jump to content

[LE] Need help with script: add spells when armor is equipped


Recommended 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
Link to comment
Share on other sites

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.creationkit.com/index.php?title=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
Link to comment
Share on other sites

  • 3 years later...

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
Link to comment
Share on other sites

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:

 

 

 

Scriptname PlayerSpellArmorCheck extends ReferenceAlias 

Armor Property helmetProperty Auto
Armor Property cuirassProperty Auto
Armor Property bootsProperty Auto
Armor Property gauntletsProperty Auto
Armor Property ringProperty Auto
Actor Property PlayerRef Auto
Spell Property SpellProperty Auto 

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
    If PlayerRef.IsEquipped(helmetProperty) && PlayerRef.IsEquipped(cuirassProperty) && PlayerRef.IsEquipped(bootsProperty) && PlayerRef.IsEquipped(gauntletsProperty) && PlayerRef.IsEquipped(ringProperty)    
       PlayerRef.AddSpell(spellProperty)
       spellProperty.Cast(PlayerRef)
    EndIf
EndEvent 

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
    If PlayerRef.IsEquipped(helmetProperty) && PlayerRef.IsEquipped(cuirassProperty) && PlayerRef.IsEquipped(bootsProperty) && PlayerRef.IsEquipped(gauntletsProperty) && PlayerRef.IsEquipped(ringProperty)    
        ;do nothing 
    Else
        PlayerRef.DispelSpell(spellProperty)
        PlayerRef.RemoveSpell(spellProperty)
    Endif 
EndEvent

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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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:

 

 

Scriptname ArmorPropertyMagicEffect extends ObjectReference 

Spell Property SpellProperty Auto 

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) 
    If akNewContainer as Actor 
        (akNewContainer as Actor).AddSpell(SpellProperty)
    Endif 
    
    If akOldContainer as Actor 
        Actor OldActorRef = akOldContainer as Actor 
        If OldActorRef.GetItemCount(Self.GetBaseObject()) == 0
            OldActorRef.RemoveSpell(SpellProperty) 
        Endif 
    Endif 
EndEvent

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...