![]() |
Understanding Waypointing
Can someone explain to me how the bot's waypointing system works ? (HPB bots) ???
|
Re: Understanding Waypointing
It depends what part of the waypointing you need to know. e.g.
Or all of them :) I had a lot of trouble with waypoints when I started making bots up, I specifically had a hard time figuring out how a bot goes from one waypoint to another for some reason! How waypoints are stored in the game All waypoints are stored in a large array e.g. call it "waypoints". Each waypoints has co-ordinates on the map (x,y,z) (Vector type). They also have Flags. The flags are a bitmask of additional information that is useful for a bot to navigate properly (Or if it is a special waypoint), for example a crouch waypoint, or a ladder waypoint, or a sniper waypoint. There are also special waypoints in HPB Bot called 'aiming' waypoints, useful for sniper waypoints and sentry waypoints to show the direction of a nearby waypoint. There is another special flag called DELETED that tells the bots that the waypoint in the array is invalid and can be overwritten by a new waypoint. Each waypoint also has a list of other waypoints that can be reached from the current waypoint. This is used for path finding. The waypoint code structure looks something like: Code:
Waypoints are stored in a file in binary format. First a waypoint header is stored in the file. Code:
typedef struct When loading the waypoints the header is read first and the header is checked for its validity, if it is valid then all waypoints are read sequentially. How waypoints are added/deleted from the waypoints array Code:
void addWaypoint ( edict_t *pEdict, int flags ) |
Re: Understanding Waypointing
Hmm...this helped a lot ! These basic explanations made me understand more about the waypoint system...What I can't understand is what kind of mathematical or geometrical algorithms are used to figure out how bots find the nearest waypoint to some point, how they find out a retreat wpt...say just around a corner and stuff :d and what are paths ? wouldn't it be simplier without the paths ? or is that used for path experience...say that it tell s the bot that some area is dangerous being campers or snipers there....am I close ?
|
Re: Understanding Waypointing
Paths are required to allow bots to know what other waypoints are reachable from a selected waypoint.
for example, one waypoint will have a list of waypoint indexes to all other waypoints it can go to. waypoint index, 0 : 1 1 : 2 // this waypoint goes to 2 2 : 3,4 // this waypoint goes to either 3 or 4 3 : 1 // this waypoint goes back to 1 4 : 1 paths can usually be symmetric i.e. if a waypoint is reachable in one direction then it is reachable in the other. But this may not be the case in some situations such as a waypoint on the top of a ledge and a waypoint on the ground. The waypoint on the ledge will have a path to the waypoint on the ground, but the waypoint on the ground should not have a path to the waypoint on the ledge, unless the waypoint has a special type (e.g. FL_FLY) and the mod allows players to fly! How paths are generated for each waypoint Paths are generated by looping through each waypoint in the "waypoints" array and using things called tracelines that trace a line, funnily enough :), from one waypoint to another to determine if it is visible. Code:
#define REACHABLE_RANGE 500 // 500 units away How bots move towards its "current waypoint" The bot needs to find the waypoint index in the waypoint array of the nearest waypoint first. The waypoint index is stored as its "current waypoint index". To do this it must loop through all waypoints in the waypoint array. Code:
Code:
// find a waypoint To do this there is a function in HPBBot i think called BotNavigate(), this is called every frame. It always checks if Code:
#define WAYPOINT_TOUCH_DISTANCE 32 The bot must find a path from one place to another , for xample, in TFC the bot might want to find a flag and return it to the base. To do this, in the HPB_BOT, there are special flags called Code:
FL_CAPTURE_POINT Code:
See the wiki on path-finding http://wiki.bots-united.com (username : wiki , password: nospam) Using certain types of path finding algorithms can be intensive to CPU so usually a path is generated and the result of waypoint indexes the bot should go to in sequence is stored in the bot. Whenever the bot reaches its next waypoint, the bots new waypoint becomes the next waypoint in the path list. retreating, cover waypoints, camping The HPB Bots dont retreat. Some bots do, its a heavier subject. This requires extra information, such as a waypoint visibility table, which tells the bot which waypoints are visible from another. Just like the findRandomWaypointWithFlags function, we could loop though all waypoints again and see which one is not visible from a threat. and get the nearest one, then make that our goal, and run towards it for cover, when the bot reaches the goal, maybe it should crouch too! Some bots have special camping flags that tell the bot to crouch and wait for a while before moving off again. hope it helps |
All times are GMT +2. The time now is 19:57. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.