Author Topic: Catching spells cast on inventory objects /or/ item creation feat scripts  (Read 814 times)

Legacy_CheeseshireCat

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-0


               Can anyone help me with one issue? How do I trigger a script off a *standard* spells cast onto an inventory object (including blank scrolls/potion bottles)?

Or, what scripts handle the standard item creation feats?

(Or, where can I get the *searchable* standard NWN scripts? Didn't work with the toolset for a few years...)

I need to modify item creation *a little* for my mod, and don't wanna to have to redo it completely or use haks for the purpose.

TIA
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Catching spells cast on inventory objects /or/ item creation feat scripts
« Reply #1 on: November 13, 2010, 06:31:27 pm »


               You'll want to enable spellhooking in your module by setting a string variable in Edit>Module Properties>Advanced>Variables with the Name X2_S_UD_SPELLSCRIPT and the Value set to the name of your spellhook script.

Now in your spellhook script you'll use the following relevant functions:

#include "x2_inc_switches"

void main()
{
object oCaster = OBJECT_SELF;
object oTarget = GetSpellTargetObject();
int nSpell = GetSpellId();
int nSpellDC = GetSpellSaveDC();
int nCastLevel = GetCasterLevel(oCaster);

if(nSpell == SPELL_MAGIC_WEAPON)
    {
    //Do something then execute the default spell script
    }

if(nSpell == SPELL_TIME_STOP)
    {
    //Do something then bypass the default spell script
    SetModuleOverrideSpellScriptFinished();
    }
}
I use this on my server's "magic forge" to allow casters to create magic items by casting spells directly on the items.

-420
               
               

               


                     Modifié par 420, 13 novembre 2010 - 06:32 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Catching spells cast on inventory objects /or/ item creation feat scripts
« Reply #2 on: November 13, 2010, 07:27:27 pm »


                 Bio Script Searcher
               
               

               


                     Modifié par Lightfoot8, 13 novembre 2010 - 07:29 .
                     
                  


            

Legacy_CheeseshireCat

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-0
Catching spells cast on inventory objects /or/ item creation feat scripts
« Reply #3 on: November 16, 2010, 08:54:08 am »


               Thanks, guys. Also, odd, but I was expecting the "subscribe to the thread" to drop me the notifiers of replies to mailbox...
               
               

               
            

Legacy_CheeseshireCat

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-0
Catching spells cast on inventory objects /or/ item creation feat scripts
« Reply #4 on: November 16, 2010, 09:18:16 pm »


               Just in case. Did that, modified crafting script (x2_inc_craft), etc... Spent *four hours* (!) trying to find out why stuff just doesn't work (i.e., doesn't work at all, even when I inserted floating text for debugging). Finally, found that I also need to recompile a few barely related scripts for it to work. @.@ In particular, x2_pc_craft
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Catching spells cast on inventory objects /or/ item creation feat scripts
« Reply #5 on: November 16, 2010, 10:05:35 pm »


               I am not sure I follow what you are saying.

Include Files Do not compile on there own to make a runnable script. They are included into other scripts and then compiled into that main script. It is a methoid of keeping thins constant across several scripts. Also a way to be able to reuse code in several scripts without having to rewrite it every time.

It is also advisable (rule of thumb but not a firm rule) that you not modify the standard include files. The reason behind this is that it is not always eaisy to find or recompile every script that uses it. Somethimes in rear cases there are hard coded reasons behind why Bioware did things the way they did. If you want to modify standard include files it is often better to make a copy of it with a new name and include it into your scripts instead. This also make it a lot easier to identify scripts that may show up that still use the unmodified include. It could save you hours tracking down bugs that show up later.
               
               

               


                     Modifié par Lightfoot8, 16 novembre 2010 - 10:09 .
                     
                  


            

Legacy_CheeseshireCat

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-0
Catching spells cast on inventory objects /or/ item creation feat scripts
« Reply #6 on: November 18, 2010, 08:00:20 pm »


               That was what I did in the end. And what I meant is, it was pretty hard to catch which of the "main" scripts I have to alter.