XP for disarming traps and picking locks in NWN2

There have been questions about this already when it comes to NWN1 and NWN:EE. How is this implemented in NWN2? Do you, just like with NWN, have to attach a script to every trap or locked chest to get the companion or PC who picks the lock or disarms the trap to get XP, or is there some general setting in the Module Properties where you can set this?

In the module I’m working on now you have a rogue companion that you can take with you when adventuring. I would like it that if you have her with you (or if you’re a rogue yourself) that you get XP everytime there’s a lock or trap that you’re disabling.

1 Like

I attach scripts. I didn’t find a “general setting” for this. I use “script template” with the proerties object to make it easier.

1 Like

Which script template do you use then? Can’t find anything in the Script Assist/Templates that deals with unlocking or deactivating tracks.

I made mines.

Huh?

Are we talking about NWN 1 or 2?

As for NWN2, there is already a XP-Script

If it’s concerning NWN1 you are in the wrong section of the forum :slight_smile:

But the script is placed here

1 Like

I am talking about NWN2.

So you mean that one can use this script on the Module Properties so that ALL disarming of traps gives you XP? As I tried asking in my first post:

I’m not sure the ga_xp_trap script can be set at the Module Properties…Or can it?

So, to be even clearer, is there a general script that you can set at the Module Properties or somewhere else global, so that you don’t have to set this script on EVERY trap or locked picked?

Now I understand, you want a global script. As far as I can say, the shown script in the screenshot is set automatically on painting a trap. So no need to ammend every single trap.

I should be possible to override it with the scripting you need.

This is still no scripting on the module itself, once the scripts are removed from the traps, they needed to be set manually on every instance again to activate them. I guess, a global solution is not possible, but this is just a guess from a beginner …

Right now there is a similar question pending in the NWN 1 section, but no answer so far. I guess it isn’t possible in NWN 1 too, plus there is no default script set on painting a trap.

1 Like

There’s no way of setting it by default, but if you want a lazy way you can make a script that cycles through all objects in the module or a specific area that fires upon loading that sets the appropriate script.

	object Trap = GetFirstObjectInArea(GetArea(OBJECT_SELF));
	while (GetIsObjectValid(Trap))
	{
		if (GetIsTrapped(Trap)) {
			switch(GetObjectType(Trap)) {
			case OBJECT_TYPE_TRIGGER:		SetEventHandler(Trap, SCRIPT_TRIGGER_ON_DISARMED, "ScriptName"); break;
			case OBJECT_TYPE_PLACEABLE:		SetEventHandler(Trap, SCRIPT_PLACEABLE_ON_DISARM, "ScriptName"); break;
			case OBJECT_TYPE_DOOR:			SetEventHandler(Trap, SCRIPT_DOOR_ON_DISARM, "ScriptName"); break;
			}
		}
		Trap = GetNextObjectInArea(GetArea(OBJECT_SELF));
	}
2 Likes

Ok, then I know.

@Akhacha - Thanks for the script. I don’t think I want to be cycling through all the objects in an area or the whole module though. I just needed to know if there was a global setting without having to add it to every locked chest that can be lock picked.

Precisely. Or a global setting like you can do with other stuff under the Module Properties.
What I mean is, the script you set at the OnModuleLoad has some settings, functions like SetModuleSwitch or SetGlobalInt where you activate stuff in the game engine. I thought there might have been something there to trigger that you always get XP when disarming traps or unlocking locks.

Here’s a picture example of what I mean:

That’s good to know. I am using mostly prefab areas and sometimes they come with traps that I keep. I hardly paint or use traps otherwise so I hadn’t thought about it maybe being automatically set if you paint a trap. However, I don’t think a locked chest has a script set automatically when adding that, does it? Actually, I only see that you can add a script with giving XP on the OnOpen of a chest, not when you unlock it, right? Or am I wrong?

1 Like