You are here

Just a tip

8 posts / 0 new
Last post
Hillyan
Just a tip

Hi, i've done my spellhooking script and it works.

It recalls original nwn spells (modified from prc) without problems, and it does what it's been programmed to do.

I've only a problem. The code calls the spells by constant SPELL_XXXX_XXX, by using the switch function and "case by case" script.
Prc spells does not have constants.

How can i recall the prc spell scripts? Is there a syntax to recall directly the spell scripts names?

Below the first part of code:

Code: [Select]
void main()
{
object oTarget;
int nSpell=GetSpellId();
int nSpellDC=GetSpellSaveDC();
int nCastLevel=GetCasterLevel(OBJECT_SELF);
object oCaster = OBJECT_SELF;
if (GetCasterLevel(OBJECT_SELF) > 20)
{
nCastLevel = (GetCasterLevel(OBJECT_SELF) + (GetLevelByXP(OBJECT_SELF)-40));
}


     switch (nSpell)
     {

//*Arcane Sfera 1

         //* Evoca I
    case SPELL_SUMMON_CREATURE_I:
               {int nMetaMagic = GetMetaMagicFeat();
               int nDuration = nCastLevel;


and so on...case by case.

Can you help me to recall the spell scripts in my script? I would like to edit by spellhooking the spells/epic spells effects, without importing, exporting, compiling.

  • up
    50%
  • down
    50%
meaglyn

The code does not "call" as in execute the spells by constant. It looks like it's using the constants to run local code for each spell. And you could just as well have the numbers there.  If what you want to do is simply have unmodified spells execute the original script with no changes you could:

1) let the spell hook return 0 and then let the engine run the normal script (i.e. don't call  SetModuleOverrideSpellScriptFinished(); before the return 

or

2)   run the script yourself in your case statement with ExecuteScript("spellscript", oCaster);

You could get the name of the impact script from the 2da if you want and you would not need to hardcode a case statement for every spell you are not changing. But if you are just going to do that you could use option 1...

However, if you want to change them then you will have to import the code. You won't get a different functionality by calling the existing script directly.

 

  • up
    50%
  • down
    50%
Hillyan

Ok, SOLVED.

I can recall every spells from the ID ROW of 2da.

"case x" where x is the row id in the 2da hak pf prc.

Then i can overrid it, as you say with the righ code (scripting mine), or let the original script run without calling it.

I'm very happy of this. :)

  • up
    50%
  • down
    50%
Shadooow

I would recommend avoid using this technique alltogether and instead use spell engine from community patch which lets you change not only caster level but anything else using variables. I wouldn't be suprised if your spellhook script had inside the spell cases code from patcch 1.23.

I've seen this technique somewhere and all I can say is that it is horrible way to use spellhook.

  • up
    50%
  • down
    50%
meaglyn

"community patch which lets you change not only caster level but anything else using variables."

This is not true. You can change only the things for which the patch uses variables.  "Anything else" is a bit of a stretch.

 

"I've seen this technique somewhere and all I can say is that it is horrible way to use spellhook." 

Based on what?    It costs a few extra instructions but can be significanlty easier to maintain than a 1000 individual spell scripts.

That said, I would not put a case statement for every single spell in it. I'd only do the ones that needed new code and have a way to  know  to skip that if the spell was unmodified.

  • up
    50%
  • down
    50%
Shadooow

okay, correct anything else to almost everything else.

1.72 allows to dynamically change: caster level, metamagic, DC, range of the AOE, damage cap, damage limit, damage type, saving throw, whether spell uses SR or not, and target type selection scheme.

There is not much else what you would want to change but allright "anything else" is overstatement. You got me there!

Based on what?    It costs a few extra instructions but can be significanlty easier to maintain than a 1000 individual spell scripts.

That said, I would not put a case statement for every single spell in it. I'd only do the ones that needed new code and have a way to  know  to skip that if the spell was unmodified.

If you are using this to change a few spells it is fine. But since the OP wants make global adjustment into caster level (based on the first few lines of his code) he will have to have case for every single spellscript and its script pasted there. I saw this exact method in some package already and I found it extremely hard to modify it. It is a mess. But maybe it is just my personal feeling idk.

 

EDIT: thing is that with CPP you can basically have single script in module load where you can make nearly 80% of the usual changes to the spellscripts externally and dynamically. Manual script editing would be required only for things not related to any of these spell informations such as adding additional creatures into list of summons or shapes into list of polymorphs etc.

EDIT2: now when I think about it adding additional shapes for polymorph spells could be done from 70_mod_polymorph script externally too.

  • up
    50%
  • down
    50%
meaglyn

I'm not knocking the CPP spell system. I use it myself and like it.  The variables do cover a lot of ground. But if you want to change the spell in a different way you have to code it yourself.   That's all I was saying.  I've done that in a number of cases. The spell router techniqie can is good at catching spells that get duplicated to your familiar etc too.

If the OP was doing just caster level changes (which may be the case) and is willing to use CPP then, yeah, that would be even better. But that does not make the other solution "horrible" by default  :)

 

  • up
    50%
  • down
    50%
Shadooow

I am not saying any other solution than mine is bad. Just this one.

  • up
    50%
  • down
    50%