taken from a post at blizzhackers, credits go to southern
WAYPOINTS
.recroute
.addwp
.saveroute
.rescp
Hi there, this waypoint system I am using in my World save and it works brilliantly.

Please note, when setting a way point after you have created a route, do not assign the waypoint to the npc! Assign it to it's spawn point! Otherwise, if npc killed, he will not resume route. I found this out myself, heh. Actually, I will post the macros I use for route creation:
1) .recroute -> creates the starting point of the route
2) .addwp -> repeat as necessary as you move forward to create the route you want for the npc
3) .saveroute -> do this once your route is complete. NOTE: YOU MUST CREATE A ROUTE THAT LOOPS ON ITSELF, OTHERWISE YOUR NPC WILL REACH THE END OF THE ROUTE AND PROMPTLY DISAPPEAR AS IT FLOATS BACK TO ITS STARTING POINT!
Also, make a note of the end waypoint number and the starting waypoint number
4) .rescp -> you need to reload the scp so that the waypoint takes effect
5) .setwp <number of first waypoint of route) -> click on spawnpoint first
6) spawn the relevant npc you want and watch as it goes it merry way
A useful tip is to create the spawn point first, but not necessarily the npc, so that when you create the route you know where to end on the way back.
You need to create a waypoints.scp file in the scripts folder of your W0W server.
Also, DO MAKE A NOTE OF THE ROUTES YOU CREATE BECAUSE YOU WILL LOSE TRACK OF WHAT IS WHAT!!
You need the following in the command.tcl file, if this is already there, then great:
"setwp" { return [Commands::setwp $player $cargs] }
"addwp" { return [Commands::addwp $player $cargs] }
"showwp" { return [Commands::showwp $player $cargs] }
"recroute" { return [Commands::recroute $player $cargs] }
"saveroute" { return [Commands::saveroute $player $cargs] }
AND:
proc setwp { player cargs} {
if {[GetPlevel $player]<4} {return "You are not allowed to use this command"}
if {![string is integer $cargs]} {return "This waypoint doesn't exist!"}
SetWayPoint [GetSelection $player] $cargs
return "OK: WP $cargs set for selected NPC"
}
proc addwp { player cargs } {
if {[GetPlevel $player]<4} {return "You are not allowed to use this command"}
set pname [GetName $player]
if {[file exists "scripts/recwaypoints"]} {
set recroutefile [open "scripts/recwaypoints" r]
set latestadded [gets $recroutefile]
set firstofroute [gets $recroutefile]
close $recroutefile
} else {
set latestadded 0
}
set hwaypoint [open "scripts/LatestWaypoint.txt" r]
set LatestWayP [expr { [gets $hwaypoint] + 1 }]
close $hwaypoint
set curPos [GetPos $player]
set map [lindex $curPos 0]
set x [lindex $curPos 1]
set y [lindex $curPos 2]
set z [lindex $curPos 3]
if {$latestadded==0} {
set hwaypointout [open "scripts/waypoints.scp" "a+"]
} else {
set hwaypointout [open "scripts/waypoints.scp" "a+"]
puts $hwaypointout "next=$LatestWayP\n"
}
set outline1 {[point }
set outline2 {]}
puts $hwaypointout "$outline1$LatestWayP$outline2"
if {$latestadded==0} {
puts $hwaypointout "pos=$x $y $z\n"
} else {
puts $hwaypointout "pos=$x $y $z"
}
close $hwaypointout
set hwaypoint [open "scripts/LatestWaypoint.txt" w]
puts $hwaypoint $LatestWayP
close $hwaypoint
if {$latestadded==0} {
return "Waypoint $LatestWayP created."
} else {
set recroutefile [open "scripts/recwaypoints" w]
puts $recroutefile $LatestWayP
puts $recroutefile $firstofroute
close $recroutefile
return "Waypoint $LatestWayP created for route and linked to Waypoint $latestadded."
}
}
proc showwp { player cargs } {
if {[GetPlevel $player]<4} {return "You are not allowed to use this command"}
if {![string is integer $cargs]} {return "This waypoint doesn't exist!"}
set curPos [lrange [string trim [split [GetScpValue "waypoints.scp" "point $cargs" "pos"]] "\\\{\}"] end-3 end]
set x [expr {round([lindex $curPos 0])}]
set y [expr {round([lindex $curPos 1])}]
SendPOI $player 2 $x $y 6 1637 "WayPoint $cargs"
return "WayPoint $cargs shown."
}
proc recroute { player cargs } {
if {[GetPlevel $player]<4} {return "You are not allowed to use this command"}
set pname [GetName $player]
if {[file exists "scripts/recwaypoints"]} {
return "Finish current route before creating another one!"
}
set hwaypoint [open "scripts/LatestWaypoint.txt" r]
set LatestWayP [expr { [gets $hwaypoint] + 1 }]
close $hwaypoint
set curPos [GetPos $player]
set map [lindex $curPos 0]
set x [lindex $curPos 1]
set y [lindex $curPos 2]
set z [lindex $curPos 3]
set hwaypointout [open "scripts/waypoints.scp" "a+"]
set outline1 {[point }
set outline2 {]}
puts $hwaypointout "$outline1$LatestWayP$outline2"
puts $hwaypointout "pos=$x $y $z"
close $hwaypointout
set hwaypoint [open "scripts/LatestWaypoint.txt" w]
puts $hwaypoint $LatestWayP
close $hwaypoint
set recroutefile [open "scripts/recwaypoints" w]
puts $recroutefile [expr $LatestWayP - 1]
# then to record the first one
puts $recroutefile $LatestWayP
close $recroutefile
return "Route begun."
}
proc saveroute { player cargs } {
if {[GetPlevel $player]<4} {return "You are not allowed to use this command"}
set pname [GetName $player]
if {[file exists "scripts/recwaypoints"]} {
set recroutefile [open "scripts/recwaypoints" r]
set latestadded [gets $recroutefile]
set firstofroute [gets $recroutefile]
close $recroutefile
set nothing [file delete "scripts/recwaypoints"]
set hwaypointout [open "scripts/waypoints.scp" "a+"]
puts $hwaypointout "next=$firstofroute\n"
close $hwaypointout
return "Route saved, WayPoint $latestadded linked to WayPoint $firstofroute."
} else {
return "Begin a route before trying to save it!"
}
}
Cheers fenger






