Checking if Spells Are Divine &/or Arcane
Moderator: Event DM
- IceThorn
- Team Member; Retired with Honors
- Posts: 5291
- Joined: Mon Jan 10, 2005 2:06 pm
- Location: Austin, Tx. (Central Time; GMT-6)
- Contact:
Checking if Spells Are Divine &/or Arcane
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.
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.
- Nob
- Lore Council Member
- Posts: 7930
- Joined: Mon Jun 30, 2003 1:19 am
- DM Avatar: Dead but still a Dreamer
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:
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.
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;
}
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
- IceThorn
- Team Member; Retired with Honors
- Posts: 5291
- Joined: Mon Jan 10, 2005 2:06 pm
- Location: Austin, Tx. (Central Time; GMT-6)
- Contact:
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:
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;
...
- Nob
- Lore Council Member
- Posts: 7930
- Joined: Mon Jun 30, 2003 1:19 am
- DM Avatar: Dead but still a Dreamer
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?
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
- Jonezie
- Team Member; Retired with Honors
- Posts: 3905
- Joined: Wed Jun 09, 2004 7:05 am
- Location: Melbourne (GMT +10)
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.
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.
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;
}