GetEffectCasterLevel() question

I tried to be detailed below, so that it’s easy to confirm what I am seeing. But, the short version is that I am seeing incorrect GetEffectCasterLevel() results for spell effects cast using an item (a scroll). Curious if anyone else is seeing this.

Playing with some effect stuff, I did a little test where I modified Cat’s Grace (NW_S0_CatGrace) so that the last line of the impact script is
PrintString("nw_s0_catsgrace: GetCasterLevel()="+IntToString(GetCasterLevel(OBJECT_SELF))+", GetEffectLinkId()="+GetEffectLinkId(eLink));
Then, I set up a short script in the in-game debug console (with implicit main):

object oCreature = OBJECT_SELF;
effect eEff = GetFirstEffect(oCreature);
string sLinkID, sSpellName;
int nSpellID, nCasterLevel;
while ( GetIsEffectValid(eEff) )
    sLinkID = GetEffectLinkId(eEff);
    nSpellID = GetEffectSpellId(eEff);
    sSpellName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpellID)));
    nCasterLevel = GetEffectCasterLevel(eEff);
    PrintString("checking for spell "+sSpellName+" ("+IntToString(nSpellID)+"): nCasterLevel="+IntToString(nCasterLevel)+", LinkID="+sLinkID);
    eEff = GetNextEffect(oCreature);

I picked an NPC as OBJECT_SELF and then used a Cat’s Grace scroll (caster level 3) on that NPC. Then I ran the console script. Here’s what was in my log.

nw_s0_catsgrace: GetCasterLevel()=3, GetEffectLinkId()=1e00f
[CHAT WINDOW TEXT] [Mon Sep 18 00:19:02] Arba Styl uses Cat's Grace
[CHAT WINDOW TEXT] [Mon Sep 18 00:19:03] Lost Item: Cat's Grace
checking for spell Cat's Grace (13): nCasterLevel=10, LinkID=1e00f
checking for spell Cat's Grace (13): nCasterLevel=10, LinkID=1e00f
[CHAT WINDOW TEXT] [Mon Sep 18 00:19:16] [RunScriptChunk:2296,Valid] OK

As you can see, the spell script correctly reported the caster level as 3. But, GetEffectCasterLevel() reported it as 10. And, I waited out the spell and it expired in 6 minutes, so it was at caster level 3.

So, the question is: What am I missing here? Am I using GetEffectCasterLevel() incorrectly? Is it broken? The lexicon notes that this (new to EE) function is used internally in the dispel effect functions. But, it seems likely someone would have noticed if dispelling weren’t working properly.

BTW, it’s maybe noteworthy that, when I have my PC (a wizard) actually cast the spell (rather than use an item), the caster level is reported correctly. As dumb as it sounds, it almost seems like GetEffectCasterLevel() is using GetEffectCreator() and then getting that creator’s caster level, which would give this odd result.

GetEffectCasterLevel will get the character’s caster level; which is not the effective caster level for a scroll (internal to the scroll), is your character perchance a 10th level wizard?

The PC was level a 33 wizard (plus a couple of non-casting classes, level 38 total). I don’t see how the 10 was related to anything.

BTW, I just re-ran the same test, using a PC with no caster levels at all (but UMD) to use the scroll. Same result, with level 3 reported from GetCasterLevel() inside the spell script and level 10 reported from GetEffectCasterLevel().

The description for the function says, “Returns the caster level set when the effect was created as part of a spell script.”

I would have thought that Beamdog just exposed whatever internal function gets an effect’s caster level that is used in the dispel effects. Giving the caster level of the creature who used the scroll (who might not be a caster at all) seems like an odd choice, not the most useful one, and not what is needed for the dispel mechanics.

Interesting, that foils what my guess would have been. (As to things making sense in my experience very little of the internal logic in these things follows a thread I can pull, anyways, I’ve had to learn that the hard way in several things unfortunately.)

The only thing I can imagine is that something is changing that variable after the caster level is computed but that leaves the questions of both “what?” and “why?”