Jump to content

Help on removing and adding spells with condititions


Ryyz

Recommended Posts

So I'm trying to make some changes to shrines. I want to make it where if you use a shrine it adds a spell and if you interact with a different shrine it removes the previous spell and adds one from that shrine.

 

I thought have a script that checks if the player has the spell for that shrine and if player doesn't add it but if it does remove it... the problem with that is if the player interacts with the same shrine again it removes the spell from that shrine. This is easy with magiceffects but I don't know how to do it with spells.

 

I also thought have the script linked to that specific activator but that causes incompatibilities with mods that add new shrines to places. I'm not sure if there's a way to make it apply to every activator using that base rather than just an object reference.

Link to comment
Share on other sites

I think you could this by storing the current shrine somewhere and then compare on interacting with any shrine. Maybe use an alias and set that to the shrine when adding a spell, compare the alias when interacting and if the same do nothing else set the alias again to the new shrine and set the new spell?

 

diziet

 

edit: or, check the shrine in a series of if statements, in the statement that matches check to see if the active magic effect already exists, act accordingly

Link to comment
Share on other sites

  • 3 years later...

So, here is how I would go about it.    

So, say you have a KynarethShrineSpell 

You create a Spell called 'GrantKynarethSpell':
Type - Ability
Casting - Constant Effect
Delivery - Self.

And you create a Magic Effect:   'GrantKynarethSpellEffect', which you assign as effect into GrantKynarethSpell
Archetype: Script
Casting type: constant effect.
Totally silent, no visual effect, etc.
This effect has a keyword:  "ShrineSpellKeyword", and box "Dispel effects with these keywords" is checked.
Target conditions of the Effect:
Target must be player (GetIsID  Player == 1)
Target must not have the shrine's spell (HasSpell KynarethShrineSpell == 0.0)

To this effect you attach a script:   

ScriptName GrantShrineSpellScript extends ActiveMagicEffect

Spell Property ShrineSpell Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
	akTarget.AddSpell(ShrineSpell)
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	akTarget.RemoveSpell(ShrineSpell)
EndEvent

And you populate ShrineSpell property with KynarethShrineSpell  spell.
When you activate a shrine of Kynareth, you add code:   akActionRef.AddSpell(GrantKynarethSpell)

Likewise, you have a GrantTalosSpell with GrantTalosSpell Effect which also has ShrineSpellKeyword keyword, and has GrantShrineSpellScript attached, but its property is filled with TalosShrineSpell.

Sooo...    when player activate a shrine, and does not have that shrine's spell already, it applies the Grant***Spell ability to player.   Which will dispel any Grant***SpellEffect player might already have.   That will trigger its OnEffectFinish event, removing that shrines spell.
And as the new effect is applied, its OnEffectStart   will add the spell for shrine player activated.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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