Traps and XP (Help)

Hi, I am VERY new and I have no idea about the Neverwinter Nights Scripts, but I need help to know how to load or where to place a series of commands to be executed in the main campaign of the game.

What I am looking for is very basic; I want my character to get some XP every time he picks a lock or disarms a trap, like in Dragon Age: Origins. The problem is that I understand absolutely nothing and the information on the internet is very confusing to me.

I found that the game’s wiki has the exact command line for the game to give you some XP when you disable a trap;

“// Traps & XP
//
// Rewards player with XP if trap was disarmed
//
// by Incanus - big THX to Benn
// enjoy or destroy
//
// www.versuchungdermacht.de
object oPC; //player who disarmed trap
int nXP; //XP player gets
int nDC; //DC
int nlevel;
void main()
{
//Get PC who disarmed the trap
oPC = GetLastDisarmed();
//Get level of PC
nlevel = GetHitDice(oPC);
//Get DC for disarming trap (needed for calculation of XP)
nDC = GetTrapDisarmDC(OBJECT_SELF);
//Check, if trap was set by another PC. Otherwise give XP
if (GetTrapCreator(OBJECT_SELF)==OBJECT_INVALID)
{
nXP = (nDC-(15+nlevel))2nlevel;
GiveXPToCreature(oPC,nXP);
}
}”

Link: Traps and xp | NWNWiki | Fandom

What I don’t understand is in what format all those commands are saved, nor do I know where they are saved. I also don’t understand what the Wiki is referring to with “OnDisarm” it seems that it refers to an internal parameter of the game. Do I have to open some editor and add it manually? How is it done? I want to know that.

Thanks in advance and sorry for this noob question.

This is actually a lot more than you would think.

If you are trying to modify the main campaign to give you XP for every trap disarmed you would have to edit all the traps in the original campaign to have that script in the ‘OnDisarm’ event. If I recall correctly traps don’t have a default ondisarm script to just edit either so it wouldn’t be that easy. Honestly it would be very time consuming.

That script is more useful to a builder making a module than anyone in the main campaign.

1 Like

You could run a script that loops every trap in the module and alters the OnDisarm event I guess. Either do this offline or in game on the script console or OnModuleLoad.

1 Like

Thank you very much for the reply. Yes, I thought it was easier, but then I read that you had to use the editor for each trap of the game. It’s not impossible, but Neverwinter Nights has a lot of traps! Haha :smile:

It seems difficult, but I’ll try! Thanks for the reply. :slight_smile: