Script Request

I would like to have a script to place in my override folder that would permit each member of my party to gain BAB +1 for each 5 levels of trained “Spot”. (Not from Wisdom bonus or equipment or feat.) Sort of like the way Tumble works with AC.

I have been using the “Difficulty Modifier Module” with the opponents having a bonus of +4 on all six abilities. I like it that way, but it make the enemies very difficult to hit, so I would like to balance it out just a bit better. Also gives me a compelling reason to train my characters in Spot. To make matters worse, most of my characters operate and under a BAB handicap because of multi-classing anyway. So I would be really grateful if a script like this could be written. I tried using dm_setattackbase, but it’s effect is only temporary.

I don’t have time to post full working scripts here, but here is the small code snippet that will give you some ideas how you could implement this:

int nSpellID = 12345; // some unique spell id
int nSpot = GetSkillRank(SKILL_SPOT, oPC);

if (nSpot >= 5)
	int nBAB = GetTRUEBaseAttackBonus(oPC);
	effect eBAB = EffectBABMinimum(nBAB + nSpot/5);
		   eBAB = SupernaturalEffect(eBAB);
		   eBAB = SetEffectSpellID(eBAB, nSpellID);

	if (GetHasSpellEffect(nSpellID, oPC))
		RemoveEffectsFromSpell(oPC, nSpellID);
		DelayCommand(0.1f, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBAB, oPC, HoursToSeconds(48)));
		ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBAB, oPC, HoursToSeconds(48));
else if (GetHasSpellEffect(nSpellID, oPC))
	RemoveEffectsFromSpell(oPC, nSpellID);

(it requires nw_i0_spells as an include in order to be compiled).

big question tho: where to hook it?

Asking the real question… :slight_smile:

tbh i have a routine that lowers Tumble based on the level of opponent. That is, instead of using a Skill to adjust a combat-value, a Skill is adjusted by a combat-value. But it seems sorta the same,

I ended up using the generic NPC OnPerceive event/script – nw_c2_default2


if (isSeen && isEnemy)

'cause we just don’t have an OnSkillChanged event …

Try with this script, I called it script_spotbab, it should be called from OnPlayerRest and OnPlayerLevelup events.

If there are scripts on those slots already, simply add a line inside them that calls this script via the ExecuteScript function.

#include "nw_i0_spells"

// You can change this to any NEGATIVE value you want. DO NOT USE -1.
// Be careful it does not overlap with other negative ID effects.

const int EFFECT_SPOTBAB = -5000; 

void ApplySpotBAB(object oPC, int nSPOT)
	effect eBAB = EffectBABMinimum(GetTRUEBaseAttackBonus(oPC) + (nSPOT / 5));
	eBAB = SupernaturalEffect(eBAB);
	eBAB = SetEffectSpellId(eBAB, EFFECT_SPOTBAB);

void main()
	object oPC = OBJECT_SELF;
	RemoveEffectsFromSpell(oPC, EFFECT_SPOTBAB);
	int nSPOT = GetSkillRank(SKILL_SPOT, oPC, TRUE);
	if (nSPOT >= 5) DelayCommand(0.0f, ApplySpotBAB(oPC, nSPOT));

To make it a bit clearer, here’s how the two scripts of OnPlayerRest and OnPlayerLevelup should look like to work in tandem with the script above:

On Player Rest Script:

void main()
	object oPC = GetLastPCRested();
	int nREST = GetLastRestEventType();
	if (nREST == REST_EVENTTYPE_REST_FINISHED) ExecuteScript("script_spotbab", oPC);

On Player Levelup Script:

void main()
	object oPC = GetPCLevellingUp();
	ExecuteScript("script_spotbab", oPC);

Normally, the OnPlayerRest event should not be necessary, however, if you are loading a saved game, or you want to relevel with in-game tools, or some kind of bug happens, rest is the failsafe event that should fix whatever issue arises.

There would also be another alternative approach, that does not involve in modifying the event slots of the module properties, it requires to make a custom persistent and passive feat that fires the script_spotbab as a spell impact script, however I think that the route takes longer to implement and might cause trouble with other mods such as Kaedrin’s PRC if you are not careful in how you edit the 2DAs.


I created the three scripts you provided - OnPlayerLevelup.nss, OnPlayerRest.nss, script_spotbab.nss - and complied them with nssclc (no errors) and stuck the compiled files and source files in a Spot_BAB folder in my override directory.

Obviously it did not work as it is apparent I am a novice at development:woozy_face:! Is there a master file in NWN2 that I need to embed the player scripts in or call them from? What file contains these “slots” you mentioned earlier?

You must slot those two (ONPlayerLevelup and OnPlayerRest) scripts in the module properties. Let me show you the how in the screenshot:


I really appreciate the help. However, I have tried everything conceivable to try to get the toolset to load and it simply refuses to. I have tried multiple versions of DX9, reinstalling dotnetfx35, messing with compatibility settings and a few other things I am embarrassed to mention. So unless somebody has written a compatibility wrapper for it, I am just stuck.

@mindrider try these steps:

  1. Install DirectX 9.0с (run dxsetup.exe).
  2. Install DirectX SDK (it’s very important!).
  3. Install Visual C++ Redistributable (if your OS is 32-bit, run VCRHyb86.exe; if it’s 64-bit, run VCRHyb64.exe).

Ok, then we will go with the other approach, the persistent feat one. With this other method, there’s no need to launch the Toolset.

This feat will be actually HIDDEN so you won’t see it in your character’s sheet.

Keep in mind that this WILL have compatibility issues with mods that override feat.2da and spells.2da (like Kaedrin’s PRC) either in the override folder or in their haks.

If by any chance you want it to work with Kaedrin’s PRC, with some more work we can make it so we implement this change into Kaedrin’s PRC directly (at least the version in your computer)

That said, here it is, just unzip this file in your override folder and you should be good to go:

1 Like

I appreciate the effort but even after installing these the toolset still refuses to load. Event viewer says this:

P1: nwn2toolsetlauncher.exe
P3: 4a89fba1
P4: mscorlib
P6: 5b85e257
P7: 3480
P8: d8
P9: System.IO.FileNotFoundException

That worked great! I do not use Kaedrin’s PRC because it conflicts with the Artisan Class upgrade that KevL_s created. But SpotBAB seems to work fine with OC Makeover SOZ. I plan to test it a LOT more :grinning:!
Thank you so much for putting this together.

1 Like

That is the significant one. It means (obviously) that you are missing an important file somewhere. When you reinstalled NwN2 did you run the installer as an administrator?


1 Like

Don’t forget to check your AV software for a block message.

1 Like

Finally got this one sorted out. Originally the toolset refused to load at all. But after some of the software installs it would at least attempt to load. I noticed that that loading window would crash as it was loading the talk table. So I had a thought. I have always maintained the dialog.tlk file in the “nwn2” folder located in Documents. I copied the Dialog.tlk file to the application “nwn2” folder and the toolset came right up. I am not sure which folder it was originally installed to (I use the GoG version) but the game has always worked just fine with it in the Documents nwn2 folder. I have made quite few modifications to the original install over the past four years.

caveat: generally speaking it’s not a good idea to muck with the installation folder

the only exception i can think of (aside from installing toolset plugins) is the Dialog.Tlk

The .Tlk is originally in the root of the installation folder. As an “override” it can go in the root of the player folder (Documents).

But the toolset won’t use a Dialog.Tlk in the documents folder … it accesses the one in the installation folder, so to override Dialog.Tlk with a custom version requires backing up the original and putting the custom .Tlk in the root of the installation folder

there are likely other things, perhaps terrain-texture packs etc, that would need to go in the installation hierarchy …

1 Like