Author Topic: RE: Spell Customization, Spellhooking, and des_crft_spells  (Read 323 times)

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Spell Customization, Spellhooking, and des_crft_spells
« on: July 06, 2011, 06:57:11 pm »


               After a couple of hours of trying to modify Flame Arrow so that it functions like its 3.5 pnp counterpart (adds +1d6 additional fire damage property to a normal projectile) I learned something I thought I'd share about the way that des_crft_spells.2DA and the BioWare spellhook system are tied together.

When I first converted the Flame Arrow spell I could not get it to cast the spell on any item other than a scroll no mater what I did. I could target the projectiles (and other items), but everytime I'd get an error message stating that the spell could not target that item. After some trial and error, I found the issue...

BioWare has tied their spellhook system directly into des_crft_spells.2DA - which, if your spell loops through the spellhook subroutine (like all the BioWare spells do), controls more specifically what the spell can target. Thus, I'll attempt to explain what the 2DA does - if you know of additional information feel free to fill it in...

des_crft_spells.2da

Label - self explanatory, same as other 2DAs.

IPRP_SpellIndex - The line number that this spell appears on in iprp_spells.2DA.

NoPotion - The spell cannot be used to craft potions. 0 = False, 1 = True.

NoWand - The spell cannot be used to craft wands. 0 = False, 1 = True.

NoScroll - The spell cannot be used to craft scrolls. 0 = False, 1 = True.

Level - The innate level of the spell. Looks to match the INNATE parameter in spells.2DA.

CastOnItems - Determines whether or not the spell can be cast on items. 0 = No, 1 = Yes.

That last field - CastOnItems - is what gave me a headache. If you look in the des_crft_spells.2DA you'll notice that any spell that can be used to enhance an item - bless weapon, flame weapon, etc. - has this parameter set to 1. Thus, contrary to what previous documentation alludes too, the des_crft_*.2DAs affect far more than just the BioWare crafting system.

Hopefully someone else gains some benefit from this info...
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
RE: Spell Customization, Spellhooking, and des_crft_spells
« Reply #1 on: July 06, 2011, 07:19:46 pm »


               Thanks, Pstemarie. Thats useful information.
               
               

               
            

Legacy_Alex Warren

  • Sr. Member
  • ****
  • Posts: 326
  • Karma: +0/-0
RE: Spell Customization, Spellhooking, and des_crft_spells
« Reply #2 on: July 06, 2011, 08:17:10 pm »


               Additional info (this is how it looks in spellhook script):

This function is located at the end of default spellhook, right after tag-based scripting OnSpellCastAt event:
//-----------------------------------------------------------------------
       // Prevent any spell that has no special coding to handle targetting of items
       // from being cast on items. We do this because we can not predict how
       // all the hundreds spells in NWN will react when cast on items
       //-----------------------------------------------------------------------
       if (nContinue) {
           nContinue = X2CastOnItemWasAllowed(oTarget);
       }

And this is how it works (also from the spellhook):
//------------------------------------------------------------------------------
// GZ: This is a filter I added to prevent spells from firing their original spell
// script when they were cast on items and do not have special coding for that
// case. If you add spells that can be cast on items you need to put them into
// des_crft_spells.2da
//------------------------------------------------------------------------------
int X2CastOnItemWasAllowed(object oItem)
{
    int bAllow = (Get2DAString(X2_CI_CRAFTING_SP_2DA,"CastOnItems",GetSpellId()) == "1");
    if (!bAllow)
    {
        FloatingTextStrRefOnCreature(83453, OBJECT_SELF); // not cast spell on item
    }
    return bAllow;

}

(form x2_inc_craft.nss)
// 2da for matching spells to properties
const string X2_CI_CRAFTING_SP_2DA = "des_crft_spells" ;

End of additional info '<img'>