Large area - how many npcs dare I have?

If it’s those pesky peasants then having them switch on and off sounds like a good idea. That’ll stop them plotting revolutions ! Let them eat cake ? Give them no cake at all, they can stand there and wait until they’re asked to do something :man_supervillain:

In other games I’ve played with big cities you do sometimes notice them sort of switching back on.

Hopefully you get it working and I don’t want to seem defeatist but I’d still be worried if I had an area that crashed and go for the grand chop, I’m not brave enough to face a recall at a later date.

2 Likes

@Tsongo - I’m pretty optimistic we may get it working now. I need to get it working. I spent all day today with removing NPCs, adding waypoints, copying to blueprints, renaming resrefs, adding them to the OnClientEnter scritp for spawning, converting lots of buildings to environment objects and doing walkmesh cutters. I want all that slaving work to be worth it.

1 Like

Yeah, and then they demand you doing quests for them. The nerve.

3 Likes

A bit of an update on this:

kevL_s has graciously taken a lot of his time today to try to sort this out with me. I’m extremely grateful for all his patience and help! Today I believe we PM:d for about 3 hours with almost (it felt like) endless testing on my part. It is still not working, but we are optimistic and have at least got to the gist of the problem, which is the PlayImmobileAmbientAnimations(); function. Without PlayImmobileAmbientAnimations(); there are no crashes. These animations are on the heartbeat scripts of the characters, so of course the game engine gets bogged down when 90-100 NPCs are going to move around in the area.

The weird thing when testing all this was that no matter what we did with ClearAllActions and whatnot, I still had crashes, and other REALLY weird issues. When removing the PlayImmobileAmbientAnimations(); altogether there were no crashes whatsoever.

kevL_s believed the problem lies in x0_i0_anims, and he said he would do a deepdive into @TonyK 's advanced animation-handling code tomorrow, and that this could solve the problem. This is pretty complex though (or so he told me) so it will take quite a while to get this sorted out. Me and him are on totally different time zones which makes things a bit tricky, but I’m glad we could take a lot of time today to test things out.

Worst case scenario: If we can’t find the solution to this, I guess I will just have to do without ambient animations and (perhaps) do some triggers in the area that when you enter those I make some waypoints or something and make the NPCs move a bit, I don’t know. It sucks that this game still is pretty buggy when you try, like I do, to do things outside of the norm.

2 Likes

@andgalf
@kevL_s

You may have already tried this, but just in case …

Have you tried to delay the heartbeat of all NPCs from even start running until the PC is in the area fully?

And, alongside that, ensured no heartbeat on creatures run at all until the PC is in the same area as them?

1 Like

Yep, we tried that. Still crashed.

Yep, as I said, we did extensive testing.
We delayed the heartbeat script with 4 seconds.

1 Like

@andgalf

I also have this function run on my own creatures HB script, and I was trying to remember how many NPCs and how big an area mine may be compared to your own.

I have a 16 x 16 size area with around 25 NPCs that loads OK.

In module 2, a smaller 8 x 8 size area with around 40 NPCs that loads OK.

EDIT: OK, I just noticed the original post details again.

I can try to create a quick 32 x 32 area with that many NPCs to test if you want? Let me know if that would be of any help to you?

Also, just out of interest, did the area also not crash if made smaller, but kept the same number of NPCs?

1 Like

That I haven’t tried.

What I did now though, just out of interest, was to copy TonyK’s nw_c2_default1 into my override. I then did a couple of jumps between modules. I was surprised that there were no crashes at all now. I’ll still wait for kevL_s opinions on this but, well, this looked good. Not sure I want all the other AI stuff in there since I’ve balanced the fights for example to the vanilla game system (even though everyone seems to think this new AI system is far superior overall).
I use kevL_s own custom scripts for the other slots on the NPCs. He has made sure the NPCs only can do basic stuff in this area/module, just to be kind to the game engine.

1 Like

@andgalf

(CORRECTED): I also use the standard AI with my own modifications - I like the idea of it, but it does clash a lot with my own scripts - Maybe you are experiencing the same with your own latest stuff? I suspect it will be something like this.

I was able to rewrite the AI systems myself to work alongside my own scripts, but if you are having to rely on someone else’s scripts, there is room for this kind of issue … especially of they are updating at the same time.

1 Like

I’m actually pretty sure (but not certain) I could maybe use the whole system as it is, since I don’t have my own AI modifications, but I’m halfway through my adventure (can’t call it module since there are several modules now in this campaign, and it’s not a campaign per se…uugh) and I don’t want to have to go back and change stats for enemies. Combat is not the focus on my adventure anyway. It’s just there for a bit of fun between the (hopefully) interesting conversations, choices and quests.

Thanks for trying to help, though, @Lance_Botelle !

2 Likes

@andgalf

Just let me know if you want another test bed to check something from another perspective.

However, it sounds like you and @kevL_s have it covered. :slightly_smiling_face:

2 Likes

@Lance_Botelle - Thanks. Like I mentioned, we devoted at least 3 hours (maybe even 4, actually) to this today, so I feel a bit drained now (and a bit relieved with this final test) and now I can maybe (finally!) move on with my adventure and continue with one of the quests instead that I was in the middle of before all these crashes happened a few days ago.

I’m also really glad that we could pinpoint the problem (well, that’s all @kevL_s doing, of course) down to the animations. So many times before with NWN2 you don’t know what the heck is going on and why something is buggy (yes, I’m talking about the buggy dialogue system, for instance, where everything works 90% of the time and in some circumstances is highly irregular with bugs and strange behaviour).

2 Likes

Here’s a strange idea rather than shrink the area shrink the npc’s, put them all close together and see what happens. It might be that you’re causing problems having animations playing too far away and the computer’s having issues keeping up with the distances between them and what you can actually see.

1 Like

PlayMobileAmbientAnimations() i think – maybe the immobile-anims function also.

next step: add a check for distance to PC < 50.0 else ClearAllActions()

Then parse through the front-end that Tony wrote for x0_i0_anims and pull the relevant bits …

 
@TonyK

at present, our heartbeat does this →

	if (GetSpawnInCondition(NW_FLAG_SLEEPING_AT_NIGHT) || GetHasEffect(EFFECT_TYPE_SLEEP))
	{
		if (!Random(3))
		{
			effect eVis = EffectVisualEffect(VFX_IMP_SLEEP);
			ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF);
		}
	}
	else if (GetCurrentAction(OBJECT_SELF) == ACTION_INVALID // <- i was hoping this would to it but nope
		&& !IsInConversation(OBJECT_SELF))
	{
		if (GetWalkCondition(NW_WALK_FLAG_CONSTANT))
		{
			WalkWayPoints();
		}
		else if (GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS)
			||   GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS_AVIAN))
		{
			PlayMobileAmbientAnimations();
		}
		else if (GetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS))
		{
			PlayImmobileAmbientAnimations();
		}
	}
1 Like

I just abused my computer and I’m feeling guilty now ! I did a test on npc numbers and could practically hear it screaming.

32x32 320 npcs, gave up waiting for the area to load… Inconclusive test due to the tester not having enough patience.

16x16 320 npcs, relatively long load time but it worked. The load screen was really weird, the bar at the bottom kept filling up and then going backwards.

16x16 200 npcs, loaded normally no problem.

I think you’re dealing with a combination of npcs and area size.

2 Likes

lol. Now add a second module and make it a Campaign … transition from one module to the other …

the initial load usually goes okay, but either leaving or re-entering the module/area → crash

the gargantuan area ain’t helpin’ am sure …

 
oh and make sure all NPCs have

X2_L_SPAWN_USE_AMBIENT=1

set in their script-variables slot

I deleted it because I didn’t want it in my modules folder !

Why is that in the variables slot, I’ve never used that except for creatures that actually spawn ?

the heartbeat script (nw_c2_default1) checks if that variable is set, and if so plays mobile animations.

shouldn’t matter if they spawned-by-script or were pre-placed, since even pre-placed creatures (tend to) run their OnSpawn script, which converts that variable into a SpawnInCondition →

    // in the OnSpawn script - nw_c2_default9
    // Enable mobile ambient animations by setting a variable
    if (GetCreatureFlag(oSelf, CREATURE_VAR_USE_SPAWN_AMBIENT)) // <- this is the "X2_L_SPAWN_USE_AMBIENT" var
        SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS);

I did it, not a campaign a module, two areas 16x16 200 npcs and you can jump about in between them without an issue. The npcs have the variable and wander about.

I even put in some trees… Grass next !

edit, just saw your post… There I was thinking you had to spawn them ! I could’ve saved on triggers !

1 Like

@Tsongo - Remember that my area is 32x24. :slightly_smiling_face: and I have three companions in the party.

EDIT: I don’t have quite a normal jumping script between modules either since there are some functions with storing the party and storing the roster since there are 8 (or 9) potential companions. You can only have 3 in the party in my adventure.