Aller au contenu

Photo

Bizarre NPC behavior


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
In my mod, there is a part where I have two columns of soldiers walking in formation down a road.  This has been working fine for me but in recent playtests, the soldiers have been behaving oddly.  They do not follow their leaders and after abou 15 seconds, jump to a waypoing far down the line. 

This only happens if I play through the mod up to the point in the story where the soldiers appear.  If I set my start point at their location and run their script directly, they behave just fine. 

I have been trying to think of other things that I am changing that would affect their behavior and I can't, so I'm wondering if I have too many creatures doing things in my mod and that is making these NPC's behave poorly.  Is that a possibility?  Is there a way to test this?


I will post the script upon request. 

#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
I'd have to slog back through the walkwaypoints script to make sure, but basically I think it's the result of a few different kludged bug fixes interacting with eachother.

First, the walkwaypoints script has a line that jumps the NPC to the next waypoint if the pathfinding gets bogged down, along with another line that increments the next waypoint if something funny happens.
Then, you have the new collisions with NWN2 and the blocked script that can cause the NPC to do funny things. In addition, I think some of the rubberbanding that was implemented for PCs can also affect NPC's, though I really don't know for sure.

For my march columns, I set an integer on the NPCs that disables their heartbeat call to walkwaypoints. The command itself is ActionMoveToObject, with the object being the squad leader, all with a distance of 0.5 or 1.0 meters. Even then, for larger groups I break it down, where each NPC just follows the NPC in front of them. That way, they aren't all blocking eachother's path.

I think the inconsistency you're seeing is from how the different NPC's are first spawned and the particular order in which they run their scripts. If the first one in line starts first, then every thing is fine, but if the guy in the back tries to move first, everything goes haywire. Even the milliseconds of delay between the different heartbeats could affect how clear the path looks ahead. A fresh start runs everything quickly, and the NPCs start moving before they have a chance to foul each other. A stressed system doesn't run their heartbeats simultaneously, and so the NPCs have a chance to get in eachother's way.

BTW, this is the one issue I really wish could be fixed in any new patch, that NPC's unable to find a path to their target location would move as close as possible to the target location, along the straight line between them and their target, instead of just giving up completely and standing in place. I would even make the pathfinding dumber, so that NPCs (and PCs) don't just instantly find their way out of a maze, but instead bumble their way through using a very simple algorithm, like walk forward until you hit a wall, and then try going left or right until you hit another wall, rinse and repeat.

#3
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
What you say makes sense, and I totally agree about the pathfinding. I could do so much more if the pathfinding would do what you described.

#4
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
HA! It was the walkwaypoint system after all, Just like you said, Lugaid. The NPCs here are script hidden for about 1/2 of the module. It just so turns out that due to a coincidence in the tags of the NPCs and their waypoints that the walkwaypoint system was active for some of them. Apparently this was causing commands to queue up and cause problems. All I did finally was clear all actions in the script that unhides them and everything worked fine! What a bug!

Don't know if I would have gotten that one by myself. Thanks a ton!

#5
Dann-J

Dann-J
  • Members
  • 3 161 messages
SetWalkCondition(NW_WALK_FLAG_PAUSED, TRUE) in their OnSpawn scripts might also help cure their premature ambulation. Then when you unhide them you can use SetWalkCondition(NW_WALK_FLAG_PAUSED, FALSE) to make them start using their walkpoints.

Modifié par DannJ, 19 janvier 2012 - 11:06 .


#6
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
That's a good idea Dann, thanks.