Getting an item property's creator?

[Context: NWScript on NWN:EE, no NWNx]

I want to be able to see which object (caster) added an item property to an item, as happens with Flame Weapon or Magic Weapon. Is there a convenient way to do that? Basically, I am looking for an analog to GetEffectCreator(), but for item properties.

BTW, using Leto, I can noticed that the information is stored on the item property, under the item’s EffectList->CreatorID, along with some other potentially useful information, like the SpellID. But, I don’t know how to get to that info in NWScript. It would be nice if there was a generic way to access the object data.

Have you tried ObjectToJson(oItem)?

Also iirc effects and item properties are the same (but perhaps I’m mixing it up). So you could try to cycle through the item properties using GetFirstEffect() / GetNextEffect() and use GetEffectCrerator().

Using GetEffectCreator() doesn’t quite work, since NWScript only allows passing it variables of type effect, not itemproperty. My first thought was to try that, since it’s likely the same call internally.

I will have to look into the json approach. It looks promising! Thanks!

You have to use GetFirstEffect/GetNextEffect on the item (and not GetFirstItemProperty()/GetNextItemProperty()) to get the item properties as effects. Then you can use GetEffectCreator().

To identify the properties you can use GetEffectType() and GetEffectInteger().


        effect eEff = GetFirstEffect(oItem);
        while (GetIsEffectValid(eEff))
            int nEffectType = GetEffectType(eEff);
            int nEffInt0 = GetEffectInteger(eEff, 0);
            int nEffInt1 = GetEffectInteger(eEff, 1);
            int nEffInt2 = GetEffectInteger(eEff, 2);
            int nEffInt3 = GetEffectInteger(eEff, 3);
            int nEffInt4 = GetEffectInteger(eEff, 4);
            int nEffInt5 = GetEffectInteger(eEff, 5);
            int nEffInt6 = GetEffectInteger(eEff, 6);
            int nEffInt7 = GetEffectInteger(eEff, 7);

            int nEffectCasterLevel = GetEffectCasterLevel(eEff);
            object oCreator = GetEffectCreator(eEff);
            string sName;
            if (GetIsObjectValid(oCreator))
                sName = GetName(oCreator);

            int nDuration = GetEffectDuration(eEff);
            int nDurRemaining = GetEffectDurationRemaining(eEff);
            int nDurType = GetEffectDurationType(eEff);

            int nSpellId = GetEffectSpellId(eEff);

            eEff = GetNextEffect(oItem);

Item property type is one of the nEffInt?s (perhaps nEffInt0), subtype is one of the other nEffInt?s, same for costtable value and param1 value.

I guess items can’t have “effects” so you can probably ignore GetEffectType() (doesn’t return anything useful iirc) and only use GetEffectInteger() to identify the properties.

Quite nice! I didn’t know Get{First,Next}Effect() returned a valid effect when called on an item.

And, meanwhile, I learned quite a bit about JSON. It looks like that would also work for this purpose, though I don’t imagine it’s any faster.