Detecting if player is target of a spell effect

Post » Tue Dec 29, 2009 8:24 pm

Is there a way to detect if the player is the target of a sun damage effect for example? Even better if there were also a way to get the magnitude of it :)
User avatar
The Time Car
 
Posts: 3435
Joined: Sat Oct 27, 2007 7:13 pm

Post » Wed Dec 30, 2009 11:01 am

There's this: http://cs.elderscrolls.com/constwiki/index.php/HasMagicEffect

And I think OBSE can get the magnitude by walking through all the effects on the player and and then checking the magnitude of the correct one.

In fact, it must be possible because refscope will tell you all the effects on a character, and their magnitude.
User avatar
Gracie Dugdale
 
Posts: 3397
Joined: Wed Jun 14, 2006 11:02 pm

Post » Wed Dec 30, 2009 11:24 am

Thanks much, Showler! ^_^
User avatar
Jason White
 
Posts: 3531
Joined: Fri Jul 27, 2007 12:54 pm

Post » Tue Dec 29, 2009 6:57 pm

And I think OBSE can get the magnitude by walking through all the effects on the player and and then checking the magnitude of the correct one.

In fact, it must be possible because refscope will tell you all the effects on a character, and their magnitude.

Yes, that's pretty much exactly what RefScope does. I use GetActiveEffectCount to get the number of active effects on the actor, then loop that many times and use GetNthActiveEffectCode with the index number to get each magic effect code. If MagicEffectHasNoMagnitudeC returns false for the magic effect code, GetNthActiveEffectMagnitude (again with the index number from the loop) tells me the magnitude.

In your case, Dominick, you'll want to check whether the magic effect is SUDG (Sun Damage). You can do that by calling MagicEffectFromChars "SUDG" to load the numeric code for SUDG into a ref variable, then compare that against the one returned from GetNthActiveEffectCode each time through the loop. (You don't need to bother with checking MagicEffectHasNoMagnitudeC for a SUDG effect since you know in advance that it always has a magnitude.)

Working with active effects is a little tricky. Each active effect is associated with both a magic item (such as a spell or enchantment, identified by a FormID) and a magic effect (such as Sun Damage or Bound Boots, identified by a numeric code), where the magic effect is one of the ones defined in the magic item's effect list. Some OBSE commands operate on the active effect, some operate on the magic item, and some operate on the magic effect code. It took some careful thinking to figure out how various commands from those different groups should be used together.
User avatar
P PoLlo
 
Posts: 3408
Joined: Wed Oct 31, 2007 10:05 am


Return to IV - Oblivion