HasEffectKeyword or HasMagicEffectWithKeyword ?

Post » Sun Nov 18, 2012 5:02 pm

Per the Wiki BOTH use the player as a REFERENCE, so what is the real differences than if they both work on an actor?

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

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


Is it that the player is an object reference and so HasEffectKeyword would not work on other actors that are not persistent?

If there is a diffidence the wikki probably should not use the player as an example for HasEffectKeyword as it is confusing?


What do I use to check a spell (AKsource) do I use HasKeyword!

More clear: What do I use to check the key word in a spell (AKsource). Do I just use HasKeyword ?
User avatar
Marquis T
 
Posts: 3425
Joined: Fri Aug 31, 2007 4:39 pm

Post » Sun Nov 18, 2012 6:47 pm

I don't know about the difference between those first to functions, but to answer the second question, how to check for keywords on a spell, no that won't work.

You'll want to use the SKSE functions added to the Spell script GetNumEffects() and GetNthEffectMagicEffect, and then a loop like this:

int numEffects = someSpell.GetNumEffects()int index = 0bool keywordFound = falsewhile(index < numEffects)	If(someSpell.GetNthEffectMagicEffect().HasKeyword(someKeyword))		keywordFound = true		index = numEffects	;this will make the loop stop immediately when the keyword was found in case the spell still has many more magic effects which you don't need to check anymore	Else		index += 1				 ;update index to continue loop	EndIfendWhile
User avatar
Stephani Silva
 
Posts: 3372
Joined: Wed Jan 17, 2007 10:11 pm

Post » Sun Nov 18, 2012 2:21 pm

Sorry I was not clear, try this:

What do I use to check the key word in a spell (AKsource)? Do I use just HasKeyword ?

HasKeyword does work by doing this:


Spell TSpell = Aksource

if Tspell.HasKeyword()
debug.messagebox("works")
endif


I have used it successfully to detect the vanilla keywords in vanilla spells. But I want to be sure I am using the best one as there seem to be so many "get key word" type functions.

Because I am confused by the MANY get keyword functions I started using them all at one time. But I would like to know the best one to use instead.


I don't know about the difference between those first to functions, but to answer the second question, how to check for keywords on a spell, no that won't work.

You'll want to use the SKSE functions added to the Spell script GetNumEffects() and GetNthEffectMagicEffect, and then a loop like this:

int numEffects = someSpell.GetNumEffects()int index = 0bool keywordFound = falsewhile(index < numEffects)	If(someSpell.GetNthEffectMagicEffect().HasKeyword(someKeyword))		keywordFound = true		index = numEffects	;this will make the loop stop immediately when the keyword was found in case the spell still has many more magic effects which you don't need to check anymore	Else		index += 1				 ;update index to continue loop	EndIfendWhile
User avatar
Georgine Lee
 
Posts: 3353
Joined: Wed Oct 04, 2006 11:50 am

Post » Sun Nov 18, 2012 8:41 pm

Per the Wiki BOTH use the player as a REFERENCE, so what is the real differences than if they both work on an actor?

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

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


Is it that the player is an object reference and so HasEffectKeyword would not work on other actors that are not persistent?

If there is a diffidence the wikki probably should not use the player as an example for HasEffectKeyword as it is confusing?


What do I use to check a spell (AKsource) do I use HasKeyword!

More clear: What do I use to check the key word in a spell (AKsource). Do I just use HasKeyword ?

I don't know if this helps, i created a shroud effect which i activated by setting the effect to be activated as a Voice.
Now when i wanted to detect whether the player had that effect present, HasMagicEffectWithKeyword would not work. I resorted to using HasEffectKeyword.

From that, i have assumed rightly or wrongly the following, i'm more than happy to be corrected if this is not the case

HasKeyword checks only the object and not any type of effect on the object
HasMagicEffectWithKeyword checks if a spell with keyword is on the object
HasEffectKeyword checks for any other effect which is not classed as a magic/(spell) effect
User avatar
Monika Fiolek
 
Posts: 3472
Joined: Tue Jun 20, 2006 6:57 pm

Post » Mon Nov 19, 2012 12:08 am

The following is my speculation, but it is based on a lot of my time playing with keywords:

HasKeyword checks for ANY keyword on the ref. This keyword could be from a spell magic effect or from wearing clothing with the keyword or anything that pass a keyword to the REF. I feel this make it the best all round Catch All way to check for a key word as in MOST cases the keyword would not be on the ref if it was not because of a spell or wearing an item. What I mean is that keyword MagicFireFX is not going to be on the actor unless a casted spell put it there. Because clothing or a disease would use a slightly different keyword.

HasMagicEffectWithKeyword checks only the magic effect's key word, this would seem logically to be the best way to detect the presence of a spell. But I do not think in practice it really is.

HasEffectKeyword seems to sometimes work and sometimes not work, I have not found a pattern yet as to what the REASON is.
Maybe it is because the spell is not in effect per the conditions of the spell.


The wiki is clear as MUD on all of these, but I am unwilling to put my findings on the Wiki without confirmation from others. It would be Nice if a Bethesda rep would tells us definitively. I can understand that they do not have time to answer every stupid question we have, but where the wiki is wrong or contradicting I would hope they could help us when ever they can.


I don't know if this helps, i created a shroud effect which i activated by setting the effect to be activated as a Voice.
Now when i wanted to detect whether the player had that effect present, HasMagicEffectWithKeyword would not work. I resorted to using HasEffectKeyword.

From that, i have assumed rightly or wrongly the following, i'm more than happy to be corrected if this is not the case

HasKeyword checks only the object and not any type of effect on the object
HasMagicEffectWithKeyword checks if a spell with keyword is on the object
HasEffectKeyword checks for any other effect which is not classed as a magic/(spell) effect
User avatar
Liv Staff
 
Posts: 3473
Joined: Wed Oct 25, 2006 10:51 pm

Post » Sun Nov 18, 2012 8:13 pm

Unfortunately I'm as confused by the wiki as I think you must be when it comes to telling the difference between these functions, but I was wondering if you'd searched for them each in Skyrim's Papyrus source?

How the devs used them and any comments about them might prove to be enlightening.

Cipscis
User avatar
James Rhead
 
Posts: 3474
Joined: Sat Jul 14, 2007 7:32 am

Post » Sun Nov 18, 2012 11:54 am

They are too busy to read all the threads so I highly doubt it :P
For me too, I didn't read the whole topic just yet, but I think this is the 'possible' theory

According to the wiki:

HasMagicEffectWithKeyword - Actor;;;; --> Checks to see if this actor is currently being affected by a Magic Effect with the given Keyword.HasEffectKeyword - ObjectReference;;;; --> Checks to see if the specified keyword is attached to a magic effect that belongs to an active effect currently on this reference.

The key here is whenever the Magic Effect is activeMagicEffect or not.
The spell can have multiple Magic Effect, and depends on conditions, some MagicEffect is activeMagicEffect or just MagicEffect (not yet activated).
That's why there are MagicEffect script and activeMagicEffect script, imo
User avatar
Shiarra Curtis
 
Posts: 3393
Joined: Thu Jan 04, 2007 3:22 pm


Return to V - Skyrim