Page 1 of 1

Checking if Spells Are Divine &/or Arcane

PostPosted: Wed Jan 24, 2007 4:52 am
Author: IceThorn
Does anyone know a function to check if a spell is divine or arcane or both? The only function I found was:

Get2DAString(string, string, int)

which I could use to check all the categories and create my own function. But I'd prefer to use one that's already done.

I need to no if a spell is divine & not arcane or is arcane and not divine.

PostPosted: Wed Jan 24, 2007 5:20 am
Author: Nob
You can either use a switch statement that works with the GetLastSpellCastClass() to check the class of the spell returned

So for example it might wind up something like:
Code: Select all
int SHS_GetIsSArcaneSpell(object oCaster)
{
    int bReturn;

    int iCasterClass = GetLastSpellCastClass();

    switch (iCasterClass)
    {
    case CLASS_TYPE_BARD:
    case CLASS_TYPE_SORCERER:
    case CLASS_TYPE_WIZARD:
        bReturn = TRUE;
    break;
    case CLASS_TYPE_CLERIC:
    case CLASS_TYPE_DRUID:
    case CLASS_TYPE_RANGER:
        bReturn = FALSE;
    }
    return bReturn;
}


Something like that, anyway.

I wouldn't recommend using 2da columns as spells.2da doesn't have a clear distinction, you could only check if columns for example had entries by caster class, so you would wind up with situations where spells might be applicable to both.

PostPosted: Wed Jan 24, 2007 5:52 am
Author: IceThorn
I need to check if the spell on a scroll is arcane or divine or both, so I don't have a caster yet.

I'm thinking that I have to do something like:

Code: Select all
string s2DAColumn = "";
int iSpellIsArcane = FALSE;
int iSpellIsDivine = FALSE;
           
s2DAColumn = "Bard";
iClassLevel = StringToInt(Get2DAString("spells", s2DAColumn, iSpell));
if(iClassLevel > 0 && iClassLevel < 11)    iSpellIsArcane = TRUE;

...

PostPosted: Wed Jan 24, 2007 5:54 am
Author: Nob
Are we talking scribed scrolls here, or any random generic scroll?

If the former, I think it might actually be easier to add an additional variable that gets flagged onto the scroll when its scribed, maybe?

PostPosted: Wed Jan 24, 2007 6:20 am
Author: IceThorn
Any scroll. It's for UMD checks.

PostPosted: Wed Jan 24, 2007 7:26 am
Author: Jonezie
You can use the Class restriction item properties on the scrolls, rather than digging around in the 2das. The function GetItemPropertySubType() will return the restricted class when used on an class restriction item property.

Code: Select all
int GetScrollType(object oItem)
{   
     int iClass, iReturn;
     int iBase = GetBaseItemType(oItem);

     if (iBase != BASE_ITEM_SCROLL)
         return -1;

     itemproperty ipProp = GetFirstItemProperty(oItem);

     while (GetIsItemPropertyValid(ipProp))
     {
        if (GetItemPropertyType(ipProp) == ITEM_PROPERTY_USE_LIMITATION_CLASS)
        {
            iClass = GetItemPropertySubType(ipProp);

            switch (iClass)
            {
                case CLASS_TYPE_BARD:
                case CLASS_TYPE_SORCERER:
                case CLASS_TYPE_WIZARD:
                    if (iReturn == 2 || iReturn == 3)
                        iReturn = 3;
                    else
                        iReturn = 1;
                break;

                case CLASS_TYPE_CLERIC:
                case CLASS_TYPE_DRUID:
                case CLASS_TYPE_RANGER:
                case CLASS_TYPE_PALADIN:
                    if (iReturn == 1 || iReturn == 3)
                        iReturn = 3;
                    else
                        iReturn = 2;
                break;
             }
        }

        ipProp = GetNextItemProperty(oItem);
     }
     return iReturn;
}


This function returns 1 for an arcane scroll, 2 for a divine scroll, and 3 for one that can be cast be either. If the scroll doesn't have any restrictions, it returns 0, and if the item passed into the function is not a scroll, it returns -1.

PostPosted: Wed Jan 24, 2007 2:04 pm
Author: IceThorn
That looks eerily similar to the code I wrote using 2da lookups - same exact return values. :shock:

I'll switch to your in order to avoid the 2da stuff.

Thanks!