Jump to content

Checking if a player has a certain active magic effect on them


icecreamassassin

Recommended Posts

So I want to be able to pass an IF check in a script when a player is effected by a certain shrine blessing or another, but all the functions I am finding apply to KNOWING the spell or for MagicEffect, but the blessing doesn't have a magic effect associated with it, just the spell ability.

 

Anyone know how to poll for if a player is under the effect of a certain spell or ability?

Link to comment
Share on other sites

It's easy to check if the character has a certain magic effect or magic effect keyword. Just use HasMagicEffect or HasMagicEffectWithKeyword:

 

http://www.creationkit.com/HasMagicEffect_-_Actor

 

http://www.creationkit.com/HasMagicEffectWithKeyword_-_Actor

 

Checking for a specific spell is harder. If you're only checking for shrine effects you can use the OnSpellCast event because technically activating a shrine causes the actor to cast a spell on themselves.

 

http://www.creationkit.com/OnSpellCast_-_ObjectReference

Edited by lofgren
Link to comment
Share on other sites

@FireFlicker: Actually this doesn't work because of what I said above; that command is for checking if the player KNOWS that ability, whereas with an active effect like the shrine effects, those are actually cast on the player, so it's not registered as known by the player

 

@Iofgren: Thanks, that's exactly what I'm lookiing for, I didn't realize it was a spell cast BY the player ON themselves so that will be much easier to poll for.

Link to comment
Share on other sites

ah crud... spoke too soon. The first two don't seem to help the situation, because they are ones I' have tried before. The first two don't work because the shrine spell doesn't have a unique magic effect attached to them, as I mentioned originally.

 

The OnSpellCast one will be doable, but I think what I will have to do it set up a player alias that check for the spell being cast and sets a global variable. I just won't be able to set the variable back if the shrine effect goes away so it won't quite function the way I imagined it, but oh well.

 

I basically have a set of treasure chests scattered around which have an invisible activator around them that you click in place of the chest itself which checks for if you have the correct blessing, and if so activates the chest, and if not displays a message, I just can't get it to poll for the blessing properly :( hmmm oh well guess global is the way I need to go

Link to comment
Share on other sites

Oh wait I think I figured out how I can get it to work. I have a quest handler that dynamically polls for when you activate a shrine already in place I'll just have it also trigger the global on for that shrine when the shrine is activated and turn off the global for all the others, that way the chests will only activate for the matching blessing type

Link to comment
Share on other sites

You could use a perk to avoid polling, or even just edit the shrine script.

 

Which shrine doesn't have a unique magic effect? It's been a while since I worked with shrines but as I recall they all have unqiue magic effects with the MagicBlessing keyword.

Edited by lofgren
Link to comment
Share on other sites

None of them do, all they have is an ability with some generic spell effects, there is no "Magic Effect" classed form attached to them in any way so far as I can tell...

 

My handler is working ok, aside from the fact that you have to use the shrine twice for it to register for some reason :tongue: I think I may just set up a player alias which looks for the Spell Cast event since the spell comes from the player technically, and set the global through that, hopefully it will avoid the issue with activating the shrine twice.

 

Weird thing though is I have the script to check fro the global attached to the container, and when you activate it, it will endlessly and repeatedly open the stupid chest if you have the right blessing. I thought that a script only processes once and then exits until the next event is called on it unless it has an update call or a while loop. Any idea why the hell the stupid thing would be re-opening itself? I even tried setting an INT conditional so it would fail that too and it still ignores it, it's freaking weird and frankly really pissing me off :D

 

anyways, here's the code:

 

EDIT: Just saw that I set the condition for the DoOnce wrong :P

GlobalVariable Property ShrineBlessed Auto
Int Property DoOnce Auto

Event OnActivate(ObjectReference akActionRef)
    if akActionRef == Game.GetPlayer()
        if ShrineBlessed.GetValue() == 1
            if DoOnce == 0
                Self.Lock(False)
                Self.Activate(Game.GetPlayer())
                DoOnce == 1
            endif
        else
            Debug.Messagebox("There seems to be no way to unlock this chest, and no matter how you push or prod, it does not open")
        endif
    endif
endevent
Link to comment
Share on other sites

Are these vanilla shrines? I just checked in the CK and most if not all of the shrines have a unique magic effect with the MagicBlessing keyword.

 

 

 

Further none of the blessings are abilities. They are all fire-and-forget spells.

 

Do you have any other mods loaded? One of them is messing with your shrines.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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