Jump to content

Walking an NPC


Recommended Posts

I just can't seem to get my NPC to start walking. It's even acknowledged the position of my navpoint evidently by turning and facing its direction, but for some reason it just refuses to take even a single step towards it.

 

I don't understand. What am I missing (or doing wrong) here?

 

affect ( "walker", FLUSH )
{
	set ( "SET_WEAPON", "WP_NONE" );
	set ( "SET_WALKSPEED", 200 );
	set ( "SET_PLAYER_TEAM", "TEAM_PLAYER" );
	set ( "SET_ENEMY_TEAM", "TEAM_ENEMY" );
	set ( "SET_BEHAVIOR_STATE", "BS_DEFAULT" );
	set ( "SET_CHASE_ENEMIES", "true" );
	set ( "SET_LOOK_FOR_ENEMIES", "true" );
	set ( "SET_IGNOREALERTS", "false" );
	set ( "SET_WALKING", "true" );
	set ( "SET_RUNNING", "true" );
	wait ( 4000.000 );
	task ( "walkmofo" )
	{
		set ( "SET_NAVGOAL", "point1" );
	}
	dowait ( "walkmofo" );
	remove ( "walkmofo" );
}
{
"classname" "NPC_spawner"
"origin" "-430 -3442 488"
"NPC_type" "luke"
"spawnflags" "32"
"angle" "2"
"npc_targetname" "walker"
}
{
"classname" "waypoint_navgoal"
"origin" "757 -3385 488"
"angle" "246"
"targetname" "point1"
}
Link to comment

Thanks @@therfiles. Yeah, I've tried that. It didn't seem to make a difference. I'm wondering whether "waypoint_navgoal" is an entity with a brush unknown to me... but since the NPC is responding to the location, I get the feeling that something in my script is missing. Is the NPC waypoint walking buggy in this engine? Should I be trying to move the waypoint around to a different location?

Link to comment

Hmmm. Here's something I've tried in the past: Preform a couple of simple tests where you vary the distance from the NPC to the waypoint. Start really close and then move it farther and farther back. I haven't found a good solution to this problem, but at the very least you can create a crude trail of navgoals that can do the same job.

Cerez and Asgarath83 like this
Link to comment

Hmmm. Here's something I've tried in the past: Preform a couple of simple tests where you vary the distance from the NPC to the waypoint. Start really close and then move it farther and farther back. I haven't found a good solution to this problem, but at the very least you can create a crude trail of navgoals that can do the same job.

You almost never need more than one navgoal; it's just a matter of having a proper waypoint network. That's what the ordinary waypoint entity (without navgoal) is for.

Link to comment

You almost never need more than one navgoal; it's just a matter of having a proper waypoint network. That's what the ordinary waypoint entity (without navgoal) is for.

Could you elaborate on this, @@mrwonko? A waypoint network? o.O

 

Hmmm. Here's something I've tried in the past: Preform a couple of simple tests where you vary the distance from the NPC to the waypoint.

You're right! Moving the "waypoint_navgoal" closer has made it work, and the NPC walks to that point now. I wonder if there's a way to increase this programmed vision cap on them through ICARUS. I've tried applying an increased "SET_VISRANGE", but that doesn't seem to affect it.

therfiles likes this
Link to comment

@@mrwonko, is there any way to increase the range of visibility for waypoints to NPCs -- whether through ICARUS or by changing the code?

 

It doesn't make sense to me to have to litter the map with so many waypoints. It'd be a much better course of action to increase the range of visibility for NPCs and use only as many waypoints as is absolutely necessary.

therfiles likes this
Link to comment

Explain -- lol! How does having to place hundreds of waypoints benefit anyone?

You'd need to place a navgoal at every corner anyway; just make it a normal waypoint, which can be connected at any distance and can also be used for path finding outside of navgoals (e.g. when an enemy tries to chase the player). You can send an enemy to the opposite site of the map if you have a proper waypoint network.

 

Generally needing some kind of pathfinding network - be it waypoints, a navmesh or whatever - is super common, as is having to create it manually, especially in older games. (And even in modern games like Skyrim, where a first approximation can be automatically generated, you still need a lot of manual adjusting.)

 

What controls the distance between waypoints sought by the NPC in the code?

No.
Link to comment

You'd need to place a navgoal at every corner anyway; just make it a normal waypoint, which can be connected at any distance and can also be used for path finding outside of navgoals (e.g. when an enemy tries to chase the player). You can send an enemy to the opposite site of the map if you have a proper waypoint network.

 

Generally needing some kind of pathfinding network - be it waypoints, a navmesh or whatever - is super common, as is having to create it manually, especially in older games. (And even in modern games like Skyrim, where a first approximation can be automatically generated, you still need a lot of manual adjusting.)

This would be fine if simply placing two navgoal waypoints, and a connecting standard waypoint between them would be sufficient. But as it stands, the NPC requires a new waypoint every five steps, which is quite ridiculous! If I wanted to script a detailed NPC movement environment, I'd need to place thousands of these waypoints all over this room.

 

2gtxef7.png

 

Is there any way to increase the range of waypoint visibility for NPCs here?

Link to comment

The problem occurred with me several times too! Interestingly quite an opposite case took place as well - then the NPC won't stop and will continue to walk even after reaching the waypoint (the problem was with the script though). Somehow I managed to change that. There a few things, which sometimes help, like adding clip brushed onto the steps or making the space wider. However even this can't be the last remedy, unfortunately.

 

I don't know about raising the range of waypoint visibility. On my maps NPCs walk quite long distances (in the city streets). I use lots of yellow waypoints, which are relatively close to each other. Navgoals also boast a small distance from each other, otherwise the NPCs don't get to the way.

 

Interestingly, that I made several lines of parallel paths of waypoints, and NPCs sometimes choose very strange ways of going to their next navgoal.

Link to comment

I have a question: how does the game decide which waypoints are linked to which navgoal? At the moment is seems to be choosing them random, based on their proximity and some other, to me unknown factors. :/

 

2cf44s8.png

 

This is starting to drive me insane, by the way. No matter how many waypoints I place in-between, the NPC just decides to go random and accept only certain waypoints, and ignore others. When told to go to a navgoal on the far side, it just sits there like a dumbass, ignoring all the waypoints that I've placed leading there. :mad: So frustrating!

Link to comment

Oh MY GOD! I have to daisy chain these fuckers, one to the other?!!! That's it! I give up! JESUS! Worst NPC path scripting system ever!

 

How can I possibly concentrate on creating intelligent AI when I have to deal with this shit? The stupid NPC is not even smart enough to calculate a path to the objective using available waypoints? That's ridiculous!

 

So basically I have to create SP "bot routes" for the NPCs so they'll have a scripted path to roam on. That's about as primitive as it can possibly get.

therfiles likes this
Link to comment

You almost never need more than one navgoal; it's just a matter of having a proper waypoint network. That's what the ordinary waypoint entity (without navgoal) is for.

 

Interesting. I've never heard of this before. All the classic tutorials just mention using the navgoal. If this works, it could be quite awesome. But it seems like there are still some problems...I'll poke an SP map sometime.

Link to comment

Complain to someone else, idgaf. I've never had issues with the system and it yields good results; connecting waypoints automatically is done ingame during loading, so connecting arbitrary distant waypoints would be O(n^2), hence the limit.

Could you give me an aerial in-game screenshot (with 'nav show all') of how you've done this on one of your level/map designs where it works, please? I'm curious about the spacing between the waypoints you're using.

 

6rj4sz.png

 

I've just tried to create a simple setup with 3 distant navgoals and a single linking waypoint in the middle, connecting them all properly to one another. The result is that the NPC walks to the far end to one navgoal, and then forgets about all other navgoals' existence -- because it is located too far from them -- and the game says goodbye to the instructions in my script:

 

rem ( "Random Walker Test Script" );

affect ( "walker", FLUSH )
{
	set ( "SET_WEAPON", "WP_NONE" );
	set ( "SET_PLAYER_TEAM", "TEAM_PLAYER" );
	set ( "SET_ENEMY_TEAM", "TEAM_ENEMY" );
	set ( "SET_BEHAVIOR_STATE", "BS_DEFAULT" );
	set ( "SET_CHASE_ENEMIES", "true" );
	set ( "SET_LOOK_FOR_ENEMIES", "true" );
	set ( "SET_IGNOREALERTS", "false" );
	set ( "SET_WALKING", "true" );
	set ( "SET_RUNNING", "false" );
	wait ( 4000.000 );
	loop ( -1.000 )
	{
		task ( "casualwalk" )
		{
			if ( random ( 0, 3 ) > 2 )
			{
				set ( "SET_NAVGOAL", "wpoint3" );
			}
			else ()
			{
				if ( random ( 0, 3 ) > 1 )
				{
					set ( "SET_NAVGOAL", "wpoint2" );
				}
				else ()
				{
					if ( random ( 0, 3 ) > 0 )
					{
						set ( "SET_NAVGOAL", "wpoint1" );
					}
				}
			}
		}
		do ( "casualwalk" );
		wait ( "casualwalk" );
		wait ( random ( 0, 4000 ) );
	}
}
I honestly don't understand how you can be okay with this if you're doing serious NPC scripting -- unless I am still missing something and/or doing something wrong.
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...