First off, I had no idea that you could give limbs names and then extract those names with DBP. You learn something new everyday.
The way I approached the whole way point thing is to give each npc a path, made up of as many way points as you want. When the npc reaches the current way point they are walking toward (this can be determined by calculating the distance between the way point) simply have the npc go to the next way point. I also found it simplified things if I used a "looping path", ie one that when the npc reaches the last way point they start to walk toward the first first point. In your case you only have two way points so this is what's going to happen anyway.
Below is a practice demo I created, it has some maths to work out which direction to turn the npc which you may be able to improve upon.
`this program demonstrates a simple way point system
dim way_point_position#(2,5,2) :`way point coordinates (npc number, way point number, x and z)
dim current_waypoint(2) :`the current way point the npc is walking toward (npc number)
dim facing#(2) :`current facing of the npc
gosub GENERAL_SET_UP
gosub CONSTANTS
gosub MAKE_OBJECTS
gosub STARTING_VARIABLES
make matrix 1, 1000, 1000, 10, 10
position camera 500,1000,500
point camera 500,0,500
`main_loop
do
if space_pressed = 0
if spacekey() = 1
space_pressed = 1
gosub STARTING_VARIABLES
endif
endif
if spacekey() = 0 then space_pressed = 0
gosub MOVE_NPC
set cursor 0,0
print "Red Triangle"
print "current waypoint : ", current_waypoint(1)
print "x cooridnate of current waypoint :", way_point_position#(1,current_waypoint(1),1)
print "z cooridnate of current waypoint :", way_point_position#(1,current_waypoint(1),2)
print
print "Yellow Triangle"
print "current waypoint : ", current_waypoint(2)
print "x cooridnate of current waypoint :", way_point_position#(2,current_waypoint(2),1)
print "z cooridnate of current waypoint :", way_point_position#(2,current_waypoint(2),2)
sync
loop
end
GENERAL_SET_UP:
sync on
sync rate 60
hide mouse
set camera range 1, 3000
set window off
randomize timer()
cls
return
CONSTANTS:
number_of_npcs = 2
walk_spd# = 1.0
turn_speed# = 1.5
number_of_waypoints = 4 :`number of points in a way path
`write way point data to array
restore _way_point_data
for i = 1 to number_of_npcs
for j = 1 to number_of_waypoints
read way_point_position#(i,j,1), way_point_position#(i,j,2)
next j
next i
return
MAKE_OBJECTS:
`make some marker objects for the waypoints
for i = 1 to number_of_npcs
for j = 1 to number_of_waypoints
inc marker_id
make object sphere marker_id, 15
color object marker_id, rgb(0,255,0)
position object marker_id, way_point_position#(i,j,1), 0, way_point_position#(i,j,2)
next j
next i
`make two triangles to act as the npcs
make object triangle 101, 0,5,15, 10,5,-15, -10,5,-15
color object 101, rgb(250,0,0)
set object emissive 101, rgb(100,0,0)
make object triangle 102, 0,5,15, 10,5,-15, -10,5,-15
color object 102, rgb(250,250,0)
set object emissive 102, rgb(100,100,0)
return
STARTING_VARIABLES:
`starting position of npcs
for i = 1 to number_of_npcs
`pick a random way point for the npc to start at
current_waypoint(i) = rnd(4) + 1
position object 100 + i, way_point_position#(i,current_waypoint(i),1),0,way_point_position#(i,current_waypoint(i),2)
next i
return
MOVE_NPC:
for i = 1 to number_of_npcs
`calculate the angle and distance between npc and way point
opp# = way_point_position#(i,current_waypoint(i),1) - object position x(100+i)
adj# = way_point_position#(i,current_waypoint(i),2) - object position z(100+i)
distance_to_waypoint# = sqrt(opp#^2 + adj#^2)
angle# = atanfull(opp#,adj#)
if angle# < 0 then angle# = angle# + 360
`determine the smallest angle between the npc's facing# and the angle to way point
diff_a# = wrapvalue(angle# - facing#(i))
diff_b# = wrapvalue(facing#(i) - angle#)
if diff_a# < diff_b#
diff# = diff_a#
else
diff# = diff_b#
endif
`diff is now the smallest "difference" between the npc's facing and the angle between the
`npc's position and the position of the way point and is essentially the angle they have to turn
`in order to be facing the way point
`determine which direction to turn the npc
if diff# > 2
`only do this if the npc has to turn more than 2 degrees to face the way point
if diff# = diff_a#
facing#(i) = wrapvalue(facing#(i) + turn_speed#)
else
facing#(i) = wrapvalue(facing#(i) - turn_speed#)
endif
else
`if they have to turn less then two degrees to face the way point just point them at it
facing#(i) = angle#
endif
`rotate and move npc
yrotate object 100+i, facing#(i)
`if diff# is less than 10 degree start moving the npc toward the way point
`if you change 10.0 to say 150.0, you'll notice that the npc starts walking toward the
`way point before they are properly facing it so they will move in a wider arc
if diff# < 10.0
move object 100+i, walk_spd#
endif
`if the npc is within 20.0 units of the waypoint
if distance_to_waypoint# < 20.0 then current_waypoint(i) = current_waypoint(i) + 1
if current_waypoint(i) > number_of_waypoints then current_waypoint(i) = 1
next i
return
`each line of way point data represents a path
`each block of two numbers in each line is the x and z coordinate of a way point
_way_point_data:
` first second third forth
data 100.0,100.0, 100.0,900.0, 900.0,900.0, 900.0,100.0
data 150.0,150.0, 850.0,850.0, 150.0,850.0, 850.0,150.0
If you want to have your npcs going up hills, ramps, stairs etc, then you use the same approach but use a simple ray cast downward to work out where the ground is to determine what the y coordinate of the npcs needs to be. You don't have to give the way points a y coordinate, just keep the xz cooridates and let the ray cast deal with the the y position for you. I've used this basic method and it works pretty well, with all my npcs walking around, happily going up and down stairs.
This is only one approach and it's pretty simple, I suspect that if you have dozens of npcs then giving each their own path may not be possible but what you could do is allocate a single path to a number of npcs and have them all start at a differen point. In the demo above, you could easilly have four npcs per path, for instance.
As you can see, I've got the way point positions in data blocks within the code, but I would recommend using zeroSlave's method of extracting the limb data and writing that to an array instead.
Thinking about it, to get the connectedness of your way points (ie what to way points make a path and I'm also thinking that everything I've written has answered your question) all you need to do is name your limbs in a structured manner so you can use the string commands to slice up the name so you can code how to write the limb data to the array. For instance you currently have the limb names "PED.WP.1" and "PED.WP.2". If you changed this to "PED.WP.1.S" and PED.WP.1.E", this would then slice up to mean:
PED = predestrian (I'm guessing here)
WP = waypoint (again, I'm guessing)
1 = the ident number of the path
S = start point
E = end point
so:
PED.WP.2.S = start point of path 2
PED.WP.2.E = end point of path 2
PED.WP.3.S = start point of path 3
PED.WP.3.E = end point of path 3
and so on.
I've only just thought of this and it's getting late so I don't have time to do an example but hopefully this is making sense to you.