You are here

How to add a new spell?

4 posts / 0 new
Last post
4760
4760's picture
How to add a new spell?

Well, the title says it all...

I added a spell I created in spells.2da (basically, I copied the FEAT_SUMMON_BAATEZU line, changed the X2_SummBaatez script to my new summon_slaad, and made the slaads class in classes.2da along with their feats in feats.2da, as well as the racialtypes.2da and racialsubtypes.2da changes needed for the red, blue and green slaads).

Obviously the special spell-like ability is never called by the slaads in game. But I know the script works as expected (I swapped it with another one the slaads have access to - this one being a stock spell - and the summoned slaads appeared, so it's not the code itself, but the fact it's not fired that's the cause here).

So it's either something I did wrong (to be sure, I even added the constants for the race, subrace, feat and spell in nwscript.nss), or new spells can't be added. I guess it's the first reason (I didn't use it, but I think Kaedrin's pack adds prestige classes, which have their own specific spells).

I couldn't find a detailed tutorial, does anybody have any advice?

 

Thanks in advance

  • up
    50%
  • down
    50%
kevL's
kevL's's picture

tl;dr Either find (or write) a HenchSpells.2da editor, or use the Custom-AI hook in DetermineCombatRound().
 

  • (I didn't use it, but I think Kaedrin's pack adds prestige classes, which have their own specific spells)

Kaedrin added many spells and feats, but it's unlikely the AI is going to cast them ...

... (innate) AI-casting (other than custom-AI casting) is something I've looked at but haven't tinkered with /caveat

note that the usual method, that i've seen, for custom creatures using custom spells/feats is to package Custom-AI scripts with the model (ie, scripts that override the stock AI and/or TonyK's AI). Eg. Beholder Eye, Rust Monster... advanced Mind Flayer.

- am going off the top of my head there, i feel reasonably sure only about the Beholder Eye.


A long time ago, Pain bundled an app that can edit HenchSpells.2da ... but i can't find it, regretably. Basically it converts the large integers in HenchSpells to meaningful bits.

    Label         SpellInfo TargetInfo EffectWeight EffectTypes DamageInfo SaveType    SaveDCType
0   Acid_Fog      369148929 75566244   ****         0           102817808  -1073741824 -1000
1   Aid           369640451 69206031   0.09         548         ****       0           ****
2   Animate_Dead  370172937 100663319  55.9017      ****        ****       ****        ****
3   Barkskin      370164738 69206031   0.5          ****        18173187   262144      0
4   Bestow_Curse  369124353 69206031   0.3          16          0          -1072954304 -1000
5   Blade_Barrier 369148160 986        ****         987         ****       ****        ****
6   Bless         369632259 67180260   0.04         516         ****       0           ****


etc.

The bits should relate to constants that are defined in the AI, such as

const int HENCH_SPELL_INFO_BUFF_MASK         = 0x0f000000;
const int HENCH_SPELL_INFO_BUFF_CASTER_LEVEL = 0x01000000;
const int HENCH_SPELL_INFO_BUFF_HD_LEVEL     = 0x02000000;

const int HENCH_SPELL_INFO_SPELL_TYPE_AC_BUFF        = 2;
const int HENCH_SPELL_INFO_SPELL_TYPE_BUFF           = 3;
const int HENCH_SPELL_INFO_SPELL_TYPE_PERSISTENTAREA = 4;
const int HENCH_SPELL_INFO_SPELL_TYPE_POLYMORPH      = 5;
const int HENCH_SPELL_INFO_SPELL_TYPE_DISPEL         = 6;
const int HENCH_SPELL_INFO_SPELL_TYPE_INVISIBLE      = 7;
const int HENCH_SPELL_INFO_SPELL_TYPE_CURECONDITION  = 8;
const int HENCH_SPELL_INFO_SPELL_TYPE_SUMMON         = 9;


- note there's the "summon" mask ... or something like that. But without the editor (I think Pain bundled it with 'his version of' NWNx4..) and iirc it was written by TonyK, then modified a bit by Pain himself.



So I'd suggest simply hooking the stock AI w/ "X2_SPECIAL_COMBAT_AI_SCRIPT" ... not sure if you've done this before.

by hook or crook, anyone using the slaad has to stick (eg. package a blueprint .Utc with this string already defined on the blueprint)

SetLocalString(oSlaad, "X2_SPECIAL_COMBAT_AI_SCRIPT", "my_summon_slaad");

on the creature. Then if/when DetermineCombatRound() is called in 'nw_i0_generic', it's going to try to execute the my_summon_slaad script, which you can use to cast the new spell.

In that script, check for conditions under which to summon another slaad. (i'm not up on what they should be: stuff like perhaps not already done, or pet-slaad does not exist, or hp < 50%, etc.)

if the extra slaad is a go, make sure your custom-AI script sets this variable on the original slaad:

SetLocalInt(OBJECT_SELF, "X2_SPECIAL_COMBAT_AI_SCRIPT_OK", TRUE);

which tells the AI, DetermineCombatRound() has found something to do next round - ie, summon another slaad. (so it won't go fiddling about trying to decide an attack or something).

That int gets deleted by DCR, and the custom script executes, and hopefully another slaad appears. Or, the conditions to summon are not met, and DCR decides what to do on its own,


--
there was ofc more detailed info about things on our previous board, social.bioware, but the Wayback Machine seems to be konking out.

  • up
    100%
  • down
    0%
kevL's
kevL&#039;s's picture

oh my, at least i found screenshots

of the SpellsEditor as a function of the NeverWorker app



  • up
    50%
  • down
    50%
4760
4760's picture

SpellsEditor as a function of the NeverWorker app

 

I found the NeverWorker app on my NWN2 drive! Thanks for the info, I'm now looking at henchspells.2da smiley

  • up
    50%
  • down
    50%