Server Totals
Mikona - (1)
Le'Or - (1)
M'Chek - (1)
Wilderness - (1)
Underdark - (0)
Elysia - (0)
Ferrell - (0)
Deglos - (0)
Visimontium - (0)
Total players: 4
Gallery

Links Menu

Checking if Spells Are Divine &/or Arcane

Moderators: Nighthawk4, Dungeon Masters

Checking if Spells Are Divine &/or Arcane

PostAuthor: IceThorn » Wed Jan 24, 2007 4:52 am

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.
User avatar
IceThorn
Team Member; Retired with Honors
 
Posts: 5292
Joined: Mon Jan 10, 2005 2:06 pm
Location: Austin, Tx. (Central Time; GMT-6)

PostAuthor: Nob » Wed Jan 24, 2007 5:20 am

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.
"Andrinor grant me the patience not to kill those who screw things up through stupidity, the power to incinerate those who screw things up on purpose, and the wisdom to distinguish between one and the other." -The War Mage's Serenity Prayer
User avatar
Nob
Elder DM
Elder DM
 
Posts: 7630
Joined: Mon Jun 30, 2003 1:19 am
DM Avatar: Dead but still a Dreamer

PostAuthor: IceThorn » Wed Jan 24, 2007 5:52 am

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;

...
User avatar
IceThorn
Team Member; Retired with Honors
 
Posts: 5292
Joined: Mon Jan 10, 2005 2:06 pm
Location: Austin, Tx. (Central Time; GMT-6)

PostAuthor: Nob » Wed Jan 24, 2007 5:54 am

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?
"Andrinor grant me the patience not to kill those who screw things up through stupidity, the power to incinerate those who screw things up on purpose, and the wisdom to distinguish between one and the other." -The War Mage's Serenity Prayer
User avatar
Nob
Elder DM
Elder DM
 
Posts: 7630
Joined: Mon Jun 30, 2003 1:19 am
DM Avatar: Dead but still a Dreamer

PostAuthor: IceThorn » Wed Jan 24, 2007 6:20 am

Any scroll. It's for UMD checks.
User avatar
IceThorn
Team Member; Retired with Honors
 
Posts: 5292
Joined: Mon Jan 10, 2005 2:06 pm
Location: Austin, Tx. (Central Time; GMT-6)

PostAuthor: Jonezie » Wed Jan 24, 2007 7:26 am

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.
User avatar
Jonezie
Team Member; Retired with Honors
 
Posts: 3906
Joined: Wed Jun 09, 2004 7:05 am
Location: Melbourne (GMT +10)

PostAuthor: IceThorn » Wed Jan 24, 2007 2:04 pm

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!
User avatar
IceThorn
Team Member; Retired with Honors
 
Posts: 5292
Joined: Mon Jan 10, 2005 2:06 pm
Location: Austin, Tx. (Central Time; GMT-6)


Return to NWN Scripting

Who is online

Registered users: Bing [Bot], Google [Bot]