Area cold damage script

If by any chance, you’re saving the game, changing the script and reloading that saved game, the changes won’t work, because it’ll still use the old script.
You must restart/reload the module for the script changes to have effect.

Not reloading anything or changing the script now.

Will try one last thing. Restart the toolset and the module and then test again to see if it works.

Still doesn’t work. I think I’ll try travus’ script now and see how that behaves.

Look, it works, I tested it, here it is:

Are you sure you saved the new script?

Yes…really strange…

It doesn’t make any sense at all. And when trying travus’ script instead, the cloak gives my character cold damage as soon as I pick it up (and I pick it up in another area than the one with the cold damage). Sigh, I’m getting so tired of these weird bugs…

What version of the game do you have?

1.023 I think it is. On this computer (with Win7) it’s the game from the original disks updated as far as it goes (I’ve had it on this computer for many, many years and never had any real issues with the game). On my laptop with Win10 I run the gog version of the game.
I could check it on my laptop tomorrow I guess.

Ensure you put my script in the AREA’s OnHeartbeat handler, not the module handler. Also, the cloak must be equipped, not just in the inventory.

@andgalf, is this a big module? If you want, I could try to set it up for you, if you post the module here or send it to me.
I’m finding it hard to believe that this is a weird “bug” that makes a fully tested and working script not work.
It could be there is something else interfering in the module that eluded us in this thread.

Yes, it’s a big module. And far too big with all the stuff in the override folder to just post here. I think I’ll skip that. I’ll check with my laptop tomorrow, or otherwise I’ll just use your script as it is. Everything in it works except for when removing the cloak.

@travus Yes, at first I missed putting your script in the OnHeartbeat, but after I did that, and I picked up the cloak that I had dumped on the ground in another area (that doesn’t have this script of yours, of course) the cloak gave my character cold damage every 5 seconds or so when it was just in the inventory. So, I never got to the area with your script.

I’m using stock scripts like x2_mod_def_aqu, x2_mod_def_act, x2_mod_def_load, x2_mod_def_equ and so forth on my module properites, if that has anything to do with anything. The only thing I’ve modified is the OnPlayerDeath script.

Give my script a unique name and put it only in the area’s OnHeartbeat handler. If it has the same name as a stock script it will potentially cause conflicts. Especially if you are using the override folder.

Well, it already has a unique name…I’m calling it s_mm_coldscript3 right now. I don’t think there’s any stockscript with that kind of a name. But, sure, I can change it to something really weird.

Didn’t work. This is getting extremely tireing. I will give up on this for a while. I should probably get some sleep now. I think I’ll just use clangeddin’s script for now.

Here is an updated OnHeartbeat script with a failsafe, in-case you need it. This is assuming the tag of the area in question is “mistymountains”:

Place this script in the area's OnHeartbeat handler.
This script will only effect non-associate party members who are not wearing the cloak and not resting.

#include "ginc_item"

void main()
	object oPC = GetFirstPC();

	if (GetTag(GetArea(oPC)) != "mistymountains") return;		
	object oFM = GetFirstFactionMember(oPC, FALSE);
	while (GetIsObjectValid(oFM))
		if (!GetAssociateType(oFM) && !GetIsItemEquipped("wintercloak", oFM) && !GetIsResting(oFM))
			ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(Random(6) + 1, DAMAGE_TYPE_COLD), oFM);
			ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectNWN2SpecialEffectFile("sp_ice_hit"), oFM);
		oFM = GetNextFactionMember(oPC, FALSE);
1 Like

Hi again, travus!

I tested your script with the failsafe and now everything works as it should. So odd that that should be required though.
A question about this script: Should one be concerned of using an area heartbeat script due to it using to much computer power, and would that in that case be a bad thing for the module, or is it a minor thing that one can ignore?

Tried again to find the reason for this weird bug and another thing I noticed was that when placing your script without the failsafe in OnHeartbeatScript under Properties of the mistymountains area was: Wherever I set my Set Start Location, whichever area, the character gets cold damage. And it’s so strange, 'cause it should only run once I enter the mistymountains area. This script is nowhere else in my module. I tried to see if I had somehow made a copy of ginc_object and messed things up that way, but no…I’ve tried and looked in the hak packs I use but there are no scripts in those at all. In my override folder the only script there is gui_bhvr_update since I use Tchos HD UI panels and dialogue v1_3-81-1-3.
Somehow, there must be a script in my module that is messing with things…

I’ve also tried now on my laptop with Win10 and NWN2 gog version, but it’s the same there.
Somehow, I must have a script somewhere that is messing with the settings of heartbeat scripts or something…I haven’t been able to find it though. I actually thought I had, cause I had for some strange reason copied nw_c2_default1 to my own scripts in the module. I erased that one though (making a backup copy first of my module directory) but everything was the same after that.

Heartbeat scripts only bog the game down when there are lots of actors/animations/effects involved and/or if there are many HB scripts running at the same time. At least that’s what I’ve noticed. This little area HB script will have practically no effect on performance. Also note that a pseudo HB script is still running in the background just like a normal HB script. So both methods will still use resources.

If you are interested in trying to solve why the cold damage was effecting other areas without using the failsafe script, then try doing this:
Put that area in it’s own module folder. Make sure there are no other areas in that folder. You’ll have to change transitions to/from that area when doing this. Then use the script without the failsafe.
After doing that, does the cold damage still carry over to other areas?

Ok. I’ve done some further testing. Not the thing you suggested, so I might try that but still…

I tested with emptying my override folder: Problem still exists
I tested with putting the script in the heartbeat of another area: Problem still exists.

It is really odd…

Things are getting weirder still. I tried and made an entirely new module from scratch. Had two small areas as erfs that I imported. Placed your script under heartbeat in the area the PC wasn’t in. Tested and the PC is still getting damaged. In this module there are no other scripts at all, and no hak paks used.

I’m beginning to think it’s something in ginc_item that is causing this.

I think I know why that is - scripts are always active within the same module regardless of which area you occupy. So it’s important to use a failsafe, when required, to effectively “turn off” a running HB script.
If you try the troubleshooting method I mentioned above, I think you will find that problem will go away when not using a failsafe.