advpath.inc v1.31 -- follow/record/playback pathing inc file

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot. MQ2Data format only!

Moderator: MacroQuest Developers

Vexix
Genbot Janitor
Posts: 245
Joined: Sat Apr 17, 2004 10:10 am

advpath.inc v1.31 -- follow/record/playback pathing inc file

Post by Vexix » Sun Aug 08, 2004 1:24 am

My mmmmmMacro mmmmMOOOjo is strong today. . .

Advpath.inc version 1.31
Advpath2.inc version 1.31
Advpath.txt version 1.31

Full credit for this include file goes to ml2517, who created it. He's done some amazing work here. I'm just doing a bit of window dressing. ;)

I've gone through advpath.inc, and have added a bit of different code that should decrease the lag cha-cha-cha and stuttering that advpath did sometimes.

If you have other things you want changed in advpath.inc, let me know. I'm considering changing the /doevents calls to limiting them to /doevents LocalRecord. /doevent LocalPlot, etc., to allow the calling macro to decide whether it wants a general open /doevents call.

Another idea is to enable strafing for when advpath hits and object, but is slowly sliding around it. A good coating of grease should speed it up quite a bit. Will experiment with this with genbot first.

Also thought that adding in another possible hit obstacle response of back tracking the the previous loc might help advpath as well.

Another possibility would be to change the /call Delay 3 subroutine so that you could use exit early conditions in it. This would be a bit tricky, since the exit early condition would get evaluated and saved as soon as you called the sub, and then never change. I can get around this using my CollapseParams sub from genbot which uses @{} as placeholders for ${}.

Other ideas?

--Vexix
Last edited by Vexix on Sun Aug 08, 2004 8:06 am, edited 6 times in total.

Vexix
Genbot Janitor
Posts: 245
Joined: Sat Apr 17, 2004 10:10 am

Post by Vexix » Sun Aug 08, 2004 1:30 am

Generic example of a calling macro and advpath instructions:

|advpath.txt
|Help file for advpath.inc
|Version 1.31
|Date:08/08/2004
|
|
| Syntax:
| -------
| Commands:
|
| play: (Plays back a pathfile that you've recorded earlier.)
|
| pattern: (Plays back an shape based on the number of sides and size you specify.)
|
| record (Starts recording a pathfile.)
|
| plot (Plots a location to your pathfile if you are recording in manual mode.)
|
| stop (If recording, stops recording and saves to file. If playing back a path,
| stops playback. If following, stops following the player or NPC.)
|
| goto (Attempts to run you to the location you specify.)
|
| pause (Pauses playback, recording or following if they are currently being performed.
| If you issue pause again, the action is resumed. You can cancel a paused
| process by issuing a stop command.)
|
| follow (Follows a player or NPC.)
|
| distance (Sets the distance you want to stay away from the player/npc you are following.)
|
| silent (Toggles between silent and verbose output.)
|
| + (Increases the distance at which the program thinks you've reached your plotted
| locations. Use this to increase one by one if you are stuttering and running
| back and forth.)
|
| - (Decreases the distance at which the program thinks you've reached your plotted
| locations. Use this to decrease one by one if you are no longer stuttering and
| and want to make sure you are being as accurate as possible.)
|
|
| Individual Command Syntax:
| --------------------------
|
| Zone or Don't Zone at the end of playback ----------------------------------------------o
| Pingpong from start to finish and back again or Don't Pingpong ------------------o |
| Direction: Closest Forward, Closest Reverse, Forward or Reverse --------o | |
| Number of iterations to play the pathfile or loop forever ------o | | |
| Pathfile Name (no spaces) ---------------------------o | | | |
| Command (play including the colon) ----------o | | | | |
| | | | | | |
| vvvv vvvvvvvvvv vvvvvv vvvvvvvvv vvvvvvv vvvvv
| play:PATHFILENAME #|loop cf|cr|f|r pp|nopp z|noz
|
| Size of the object ---------------------------------------o
| Number of sides of the object -----------------------o |
| Command (pattern including the colon) -------o | |
| | | |
| vvvvvvv vvvvv vvvv
| pattern:Sides Size
|
| Optional manual record mode --o
| FileName (no spaces)-o |
| Command --o | |
| | | |
| vvv vvvvvvvvvv vvvvvv
| record PATHFILENAME manual
|
| Command --o
| |
| vvvvv
| plot
|
| Command --o
| |
| vvv
| stop
|
| X Coordinate --------------------------------------------o
| Y Coordinate -------------------------------------o |
| Command -------------------------------------o | |
| | | |
| vvvv vvvvvv vvvvvv
| goto YCoord XCoord
| Command --o
| |
| vvvvv
| pause
|
| PlayerName --------o
| Command ---o |
| | |
| vvvvvv vvvvvvvvvv
| follow PLAYERNAME
|
| Distance in locs ----o
| Command ---o |
| | |
| vvvvvvvv vvvvvvvvv
| distance DISTANCE#
|
| Command --o
| |
| vvvvvv
| silent
|
| Command --o
| |
| vvv
| +
|
| Command --o
| |
| vvv
| -
|
|
| You can also call these functions directly from your scripts:
| -------------------------------------------------------------
|
| Zone or Don't Zone at the end of playback --------------------------------------------------------o
| Pingpong from start to finish and back again or Don't Pingpong ----------------------------o |
| Direction: Closest Forward, Closest Reverse, Forward or Reverse ------------------o | |
| Number of iterations to play the pathfile or loop forever ----------------o | | |
| PathfileName (no spaces) ---------------------------------------o | | | |
| (The quotes are necessary) | | | | |
| vvvvvvvvvvvv vvvvvv vvvvvvvvv vvvvvvv vvvvv
| /call PlayFunction "PATHFILENAME #|loop cf|cr|f|r pp|nopp z|noz"
|
| Size of the object ------------------o
| Number of sides of the object --o |
| (The quotes are necessary) | |
| | |
| vvvvv vvvv
| /call PatternFunction "Sides Size"
|
| Optional manual record mode ----------------o
| FileName (no spaces) ------------o |
| (The quotes are necessary) | |
| vvvvvvvvvvvv vvvvvv
| /call RecordFunction "PATHFILENAME" manual
|
| /call PlotFunction
|
| /call StopFunction
|
| Z Coordinate (Optional) ------------------o
| X Coordinate ----------------------o |
| Y Coordinate ----------------o | |
| | | |
| | | |
| vvvvvv vvvvvv vvvvvv
| /call GotoFunction YCoord XCoord ZCoord
|
| /call PauseFunction
|
| Player or NPC Name to follow -------o
| (The quotes are necessary) |
| vvvvvvvvvvvvvvv
| /call FollowFunction "PlayerorNPCName"
|
|
| Distance in locs ----------------o
| Command -----------o |
| | |
| vvvvvvvvvvvvvvvv vvvvvvvvv
| /call DistanceFunction DISTANCE#
|
| /call SilentFunction
|
| /call AddModFunction
|
| /call SubModFunction
|
| ------------------------------------------------------------------------------------------------------------
| EXAMPLES:
|
| You could then do some cool things like this:
| -- Assuming you had a pathfile recorded called "PoKtoNexxus" that walks you from the PoT stone in PoK
| to the Nexxus stone in PoK.
|
| The below means: Play pathfile "PoKtoNexxus" | 1 time | going forward from the closest loc to the last loc |
| Do Not ping pong from first loc to the last and back again | zone at the end of the pathfile
|
| /echo play:PoKtoNexxus 1 cf nopp z
|
| ------------------------------------------------------------------------------------------------------------
|
| Playback command stacking is available in two forms: Using the semicolon in between commands
| (Never end a line with a semicolon.)
| ------------------------------------------------------------------------------------------------------------
| |
| o----------------o---------------------------o
| | |
| v v
| /echo play:PoKtoNexxus 1 f nopp z;NexxustoBazaar 10 cr nopp z;BazaartoShadHav 1 cf nopp noz
|
| ------------------------------------------------------------------------------------------------------------
|
| Playback command stacking is also available by tacking a + to the end of your line. You could do this
| indefinately like below.
| ------------------------------------------------------------------------------------------------------------
| |
| o----------------------------------------------------------------------o
| |
| v
| /echo play:PoKtoNexxus 1 f nopp z;NexxustoBazaar 10 r nopp z;BazaartoShadHav 1 f nopp noz+
| /echo play:AnotherPath 3 cr pp noz;YetAnother 1 f nopp z;MyPath 2 cf nopp noz+
| /echo play:Path88 1 f nopp z;HolyPathBatman 10 cr nopp z;NotDoneYetPath 1 f nopp z+
| ---- etc... etc... to start playback of all of this you issue your last line without the + like below. -----
| /echo play:Path1 1 f nopp z;Path2 10 r nopp z
|
| ------------------------------------------------------------------------------------------------------------
|
| - Credit to McKorr for some of the Obstacle code and Sharp_FLT for a brief math refresher =)
|
| ------------------------------------------------------------------------------------------------------------

|
| [Last Modified: 4/27/2004 8:00pm]
|
| Example calling script for advpath.inc
|
|
|
| -----------------------------------------------------------------------------------------------------------
| The first parameter of InitAPFVars is FaceFast, change this to 1 to use /face fast
| or 0 to use the slower /face command.
| ==> Recommended: 1
| -----------------------------------------------------------------------------------------------------------
| The second parameter of InitAPFVars is SpeedSense, the lower the number the less accurate
| the route it will follow. Do not go below 1. I don't recommend going over 15.
| ==> Recommended: 15
| -----------------------------------------------------------------------------------------------------------
| The third parameter of InitAPFVars is FollowDistance, this is the distance you'd like to
| stay away from the player/npc you are following.
| ==> Recommended: 20
| -----------------------------------------------------------------------------------------------------------
| ====> NOTE: if you /call InitAPFVars without specifying these parameters the defaults will automatically
| be used.
| -----------------------------------------------------------------------------------------------------------
|
|
| If you need to be done playing a pathfile before you do other commands simply check like this:
| ----------------------------------------------------------------------------------------------
| /if (${PathingFlag}==0) do whatever
|
|
| If you need following to be stopped before you do other commands simply check like this:
| ----------------------------------------------------------------------------------------
| /if (${FollowFlag}==0) do whatever
|


|
| ------- You have to add this above your Sub Main to include advpath.inc to your script. -------------------
#include advpath.inc


Sub Main
| -------- You have to add this above your Main loop to Init the variables. ---------------------------------
/call InitAPFVars 1 15 20


:YourScriptLoop
| -------- You need to add this call to your loop section in Main. ------------------------------------------
/call AdvPathPoll


/doevents
/delay 1
/goto :YourScriptLoop
/return



|
| [Last Modified: 4/27/2004 8:00pm]
|
| Example of using advpath.inc to walk from location to location and do things along the way
|

#include advpath.inc


Sub Main
/call InitAPFVars 1 15 20

:MainLoop
/doevents

| This is my first pathfile - I walk from my starting point to the first location
| where I'd like to do something.
| --------------------------------------------------------------------------------
/call PlayFunction "PATH1 1 cf nopp noz"
/call WaitTilThere

| --------------------------------------------------------------------------------
| * Put the code where you'd like to do things like target mobs, buy things etc here.
| ---------------------------------------------------------------------------------

| This is my second pathfile - I walk from my current point to the second location
| where I'd like to do something.
| --------------------------------------------------------------------------------
/call PlayFunction "PATH2 1 f nopp noz"
/call WaitTilThere

| --------------------------------------------------------------------------------
| * Put the code where you'd like to do things like target mobs, buy things etc here.
| ---------------------------------------------------------------------------------

| This is my third pathfile - I walk from my current point back to the first location
| where I'll start it all over again
| --------------------------------------------------------------------------------
/call PlayFunction "PATH3 1 f nopp noz"
/call WaitTilThere

/goto :MainLoop
/return

Sub WaitTilThere
:LoopTilThere
/if (${PathingFlag}==1) {
/call AdvPathPoll
/delay 0
/doevents
/goto :LoopTilThere
}
/return
Last edited by Vexix on Sun Aug 08, 2004 8:06 am, edited 2 times in total.

Vexix
Genbot Janitor
Posts: 245
Joined: Sat Apr 17, 2004 10:10 am

Post by Vexix » Sun Aug 08, 2004 1:32 am

advpath.inc

Code: Select all

|advpath.inc 
|Generic movement/pathing macro for inclusion in your own macros. 
|Version 1.31
|Date:08/08/2004
| 
||** 
[advpath] 
version=1.31
**| 

#include advpath2.inc 

#Event LocalRecord "[MQ2] record#*#" 
#Event LocalPlot "[MQ2] plot#*#" 
#Event LocalDistance "[MQ2] distance#*#" 
#Event LocalPlay "[MQ2] play:#*#" 
#Event LocalStop "[MQ2] stop#*#" 
#Event LocalGoto "[MQ2] goto#*#" 
#Event LocalPause "[MQ2] pause#*#" 
#Event LocalFollow "[MQ2] follow#*#" 
#Event LocalSilent "[MQ2] silent#*#" 
#Event LocalPattern "[MQ2] pattern:#*#" 
#Event LocalAddMod "[MQ2] +#*#" 
#Event LocalSubMod "[MQ2] -#*#" 
#Event ZoneEvent "#*#You have entered#*#" 

Sub AdvPathPoll 
/if (${PathingFlag}==1 && ${CheckLocTimer}<=0) /call IncrementLoc ${LocArray[${CurrLoc}].Arg[1]} ${LocArray[${CurrLoc}].Arg[2]} ${LocArray[${CurrLoc}].Arg[3]} 
/if (${RecordPathFlag}==1) /call RecordPath 
/if (${FollowFlag}==1) { 
    /call TrackFollow 
    /call CheckForTarget 
    /if (${CheckLocTimer}<=0 && ${PauseFlag}==0 && ${NumLocs}>${CurrLoc}) /call FollowIncLoc ${LocArray[${CurrLoc}].Arg[1]} ${LocArray[${CurrLoc}].Arg[2]} ${LocArray[${CurrLoc}].Arg[3]} 
} 
/return 


Sub ShapePlot(ObjectNumSides,ObjectSize,CharStartY,CharStartX,CharStartZ) 
/declare PointNumber int local 
/for PointNumber 1 to ${ObjectNumSides} 
    /varset XCoordinate[${PointNumber}] ${Math.Calc[${Math.Calc[${ObjectSize}*${Math.Cos[${Math.Calc[${Math.Calc[360/${ObjectNumSides}]}*${Math.Calc[${PointNumber}-1]}]}]}]}+${CharStartX}]} 
    /varset YCoordinate[${PointNumber}] ${Math.Calc[${Math.Calc[${ObjectSize}*${Math.Sin[${Math.Calc[${Math.Calc[360/${ObjectNumSides}]}*${Math.Calc[${PointNumber}-1]}]}]}]}+${CharStartY}]} 
    /varset ZCoordinate[${PointNumber}] ${CharStartZ} 
/next PointNumber 
/for PointNumber 1 to ${ObjectNumSides} 
    /varset LocArray[${PointNumber}] ${YCoordinate[${PointNumber}]} ${XCoordinate[${PointNumber}]} ${ZCoordinate[${PointNumber}]} 
/next PointNumber 
/varset CurrLoc 1 
/varset NumLocs ${ObjectNumSides} 
/return 


Sub TargetMob(TgtName) 
/declare a int local 
/if (${NearestSpawn[1,pc "${TgtName}"].ID}>0) { 
    /if (${FollowFlag}==1 && ${ZoneTimer}==0) { 
        /for a 0 to ${Group} 
            /if (${Group[${a}].Name.Equal[${TgtName}]}) /return 
        /next a 
    } 
    /target clear 
    /call Delay 2 
    /target pc "${TgtName}" 
    /call Delay 4 
    /if (${Target.ID} && ${Target.CleanName.Equal["${TgtName}"]}) { 
        /varset ZoneTimer 0 
        /varset ZoneFlag 0 
        /varset FollowFlag 1 
        /varset FollowID ${Target.ID} 
        /if (${CurrLoc}==1) /varset CurrFollLoc ${Spawn[${FollowID}].Y} ${Spawn[${FollowID}].X} ${Spawn[${FollowID}].Z} 
        /if (${SilentFlag}==0) /echo -[ Following -( ${Target.CleanName} )- ]- 
    } 
} else /if (${NearestSpawn[1,npc "${TgtName}"].ID}>0) { 
    /target clear 
    /call Delay 2 
    /target npc "${TgtName}" 
    /call Delay 4 
    /if (${Target.ID}>0 && ${Target.CleanName.Equal["${TgtName}"]}) { 
        /varset ZoneTimer 0 
        /varset ZoneFlag 0 
        /varset FollowFlag 1 
        /varset FollowID ${Target.ID} 
        /if (${CurrLoc}==1) /varset CurrFollLoc ${Spawn[${FollowID}].Y} ${Spawn[${FollowID}].X} ${Spawn[${FollowID}].Z} 
        /if (${SilentFlag}==0) /echo -[ Following -( ${Target.CleanName} )- ]- 
    } 
} else /if (${ZoneFollow}==1) { 
    /if (${CurrLoc}==${NumLocs}) { 
        /if (${ZoneTimer}>0) { 
            /varset ZoneFlag 1 
            /delay 1s 
        } else { 
            /if (${ZoneFlag}==0) { 
                /call ClearLocs 
                /call TryToZone 
            } else { 
                /varset ZoneFlag 0 
                /varset FollowID 0 
                /call StopFunction 
            } 
        } 
    } 
} 
/return 


Sub TrackFollow 
/declare TempIndex int local 
/if (${FollowFlag}==1) { 
    /if (${FollowID}>0) {    
        /if (${NumLocs}==1) { 
            /if (${Spawn[${FollowID}].Distance3D}>${FollowDistance}) { 
                /if (!${Me.Moving}) { 
                    /varset LocArray[${NumLocs}] ${CurrFollLoc} 
                    /varset NumLocs ${Math.Calc[${NumLocs}+1]} 
                } 
                /varset LocArray[${NumLocs}] ${Spawn[${FollowID}].Y} ${Spawn[${FollowID}].X} ${Spawn[${FollowID}].Z} 
                /call StoreHeading ${NumLocs} 
                /if (${LocArray[${NumLocs}].NotEqual["0 0 0"]} && ${LocArray[${NumLocs}].NotEqual["NULL NULL NULL"]}) /varset NumLocs ${Math.Calc[${NumLocs}+1]} 
            } 
        } else { 
            /varset TempIndex ${Math.Calc[${NumLocs}-1]} 
            /if (${Math.Distance[${LocArray[${TempIndex}].Arg[1]},${LocArray[${TempIndex}].Arg[2]},${LocArray[${TempIndex}].Arg[3]}:${Spawn[${FollowID}].Y},${Spawn[${FollowID}].X},${Spawn[${FollowID}].Z}]}>${If[${Spawn[${FollowID}].Speed}!=0,${Math.Calc[${Math.Calc[${Spawn[${FollowID}].Speed}/${SpeedSense}]}+${DistanceModifier}]},${Math.Calc[${Math.Calc[200/${SpeedSense}]}+${DistanceModifier}]}]}) { 
                /varset LocArray[${NumLocs}] ${Spawn[${FollowID}].Y} ${Spawn[${FollowID}].X} ${Spawn[${FollowID}].Z} 
                /if ((${LocArray[${NumLocs}].NotEqual["0 0 0"]} && ${LocArray[${NumLocs}].NotEqual["NULL NULL NULL"]})&&(${Math.Distance[${LocArray[${TempIndex}].Arg[1]},${LocArray[${TempIndex}].Arg[2]},${LocArray[${TempIndex}].Arg[3]}:${Spawn[${FollowID}].Y},${Spawn[${FollowID}].X},${Spawn[${FollowID}].Z}]}<500)) /varset NumLocs ${Math.Calc[${NumLocs}+1]} 
            } 
        } 
    } 
} 
/doevents 
/return 


Sub StoreHeading(Index) 
/varset StoreHeading ${Heading[${LocArray[${Index}].Arg[1]},${LocArray[${Index}].Arg[2]}].DegreesCCW} 
/return 


Sub TryToZone 
/declare InCurrZone string local 
/declare TempStoreTgt int local 
/varset TempStoreTgt 0 
/varset InCurrZone ${Zone.Name} 
/call Move 0 
/if (${Target.ID}>0) /varset TempStoreTgt ${Target.ID} 
/doortarget 
/delay 3 
/if (${Target.Name.Find["port"]} || ${Target.Name.Find["tele"]} || ${Target.Name.Find["prtl"]}) /goto :Port 
/goto :NotPort 
:Port 
/if (${Target.Distance}<=50) { 
    /if (${PBFace.Equal[facef]}) { 
        /face fast nolook door 
    } else { 
        /face fast nolook away door 
    } 
    :ZoneMoveCloser 
    /if (${Target.Distance}>15) /call SimpleKeyPress FORWARD 1 0 
    /if (${Target.Distance}<11) /call SimpleKeyPress BACK 1 0 
    /if (${Target.Distance}>15) /goto :ZoneMoveCloser 
    /if (${Target.Distance}<11) /goto :ZoneMoveCloser 
    /keypress USE hold 
    /keypress USE 
    /delay 1 
    /keypress USE hold 
    /keypress USE 
    /varset ZoneTimer 5s 
    :WaitForZone 
    /delay 1 
    /if (${Zone.Name.NotEqual["${InCurrZone}"]}) /goto :Zoned 
    /if (${ZoneTimer}>0) /goto :WaitForZone 
    /if (${TempStoreTgt}>0) { 
        /if (${Spawn[${FollowID}].ID}>0) /target id ${TempStoreTgt} 
    } else { 
        /target clear 
    } 
    :Zoned 
} 
:NotPort 
/if (${Zone.Name.Equal["${InCurrZone}"]}) { 
    /if (${PBFace.Equal[facef]}) { 
        /keypress FORWARD 
        /keypress FORWARD hold 
        /delay 2s 
        /keypress FORWARD 
    } else { 
        /keypress BACK 
        /keypress BACK hold 
        /delay 2s 
        /keypress BACK 
    } 
    /if (${TempStoreTgt}>0) { 
        /if (${Zone.Name.Equal["${InCurrZone}"]} && ${Spawn[${TempStoreTgt}].ID}>0) /target id ${TempStoreTgt} 
    } else { 
        /target clear 
    } 
    /varset ZoneTimer 20s 
    :WaitForZone2 
    /delay 1 
    /if (${Zone.Name.NotEqual["${InCurrZone}"]}) /goto :Zoned2 
    /if (${ZoneTimer}>0) /goto :WaitForZone2 
    /if (${SilentFlag}==0) /echo  -(( Couldn't zone properly.  Stopping. ))-      
    /varset PauseHolder NULL 
    /varset PauseFlag 0 
    /varset PathingFlag 0 
    /varset FollowFlag 0 
    /varset RecordPathFlag 0 
    /call ClearLocs 
    :Zoned2 
} 
/call Move 0 
/return 


Sub FollowFunction(FuncText) 
/if (${PauseFlag}==0) { 
    /if (${PathingFlag}==0) { 
        /if (${RecordPathFlag}==0) { 
            /if (${FuncText.Length}==0) { 
                /varset FollowName NULL 
            } else { 
                /varset FollowName ${FuncText} 
            } 
            /if (${FollowName.NotEqual["NULL"]}) { 
                /call ClearLocs 
                /call Move 0 
                /call TargetMob "${FollowName}" 
                /varset PBFace facef 
            } else { 
                /if (${SilentFlag}==0) /echo -(( No follow target specified. You must provide the name of the npc/player you want to follow. ))- 
            } 
        } else { 
            /if (${SilentFlag}==0) /echo -(( You cannot start following while recording a pathfile! ))- 
        } 
    } else { 
        /if (${SilentFlag}==0) /echo -(( You cannot start following while playing back a pathfile! ))- 
    } 
} else { 
    /if (${SilentFlag}==0) /echo -(( You cannot start following while paused! ))- 
} 
/return 


Sub Event_LocalFollow(EvtText) 
/if (${EvtText.Mid[7,6].Equal["follow"]}) { 
    /call FollowFunction "${EvtText.Right[-13]}" 
} 
/return 


Sub PauseFunction 
/if (${PauseFlag}==0) { 
    /if (${PathingFlag}==0) { 
        /if (${FollowFlag}==0) { 
            /if (${RecordPathFlag}==0) { 
                /if (${SilentFlag}==0) /echo -(( There is nothing to pause or unpause! ))- 
            } else { 
                /varset PauseFlag 1 
                /varset PauseHolder record 
                /varset RecordPathFlag 0 
                /if (${SilentFlag}==0) /echo -[ PAUSED recording of path file -( ${RecordPFName} )- ]- 
                /if (${SilentFlag}==0) /echo -[ Issue the pause command again to resume recording. ]- 
            } 
        } else { 
            /varset PauseFlag 1 
            /varset PauseHolder follow 
            /call Move 0 
            /if (${SilentFlag}==0) /echo -[ PAUSED following of -( ${FollowName} )- ]- 
            /if (${SilentFlag}==0) /echo -[ Issue the pause command again to resume following. ]- 
        } 
    } else { 
        /varset PauseFlag 1 
        /varset PauseHolder playback 
        /varset PathingFlag 0 
        /call Move 0 
        /if (${SilentFlag}==0) /echo -[ PAUSED playback of path file -( ${PBPFName} )- ]- 
        /if (${SilentFlag}==0) /echo -[ Issue the pause command again to resume playback. ]- 
    } 
} else { 
    /if (${PauseHolder.Equal["record"]}) { 
        /varset PauseFlag 0 
        /varset RecordPathFlag 1 
        /if (${SilentFlag}==0) /echo -[ RESUMED recording of path file -( ${RecordPFName} )- ]- 
    } 
    /if (${PauseHolder.Equal["playback"]}) { 
        /varset PauseFlag 0 
        /varset PathingFlag 1 
        /if (${SilentFlag}==0) /echo -[ RESUMED playback of path file -( ${PBPFName} )- ]- 
    } 
    /if (${PauseHolder.Equal["follow"]}) { 
        /varset PauseFlag 0 
        /if (${SilentFlag}==0) /echo -[ RESUMED following of -( ${FollowName} )- ]- 
    } 
} 
/return 


Sub Event_LocalPause(EvtText) 
/if (${EvtText.Mid[7,5].Equal["pause"]}) { 
    /call PauseFunction 
} 
/return 


Sub PlotFunction 
/if (${ManualRecord}==1) { 
    /if (${RecordPathFlag}==1) { 
        /varset LocArray[${NumLocs}] ${Me.Y} ${Me.X} ${Me.Z} 
        /if (${SilentFlag}==0) /echo Location: Y:${LocArray[${NumLocs}].Arg[1]} X:${LocArray[${NumLocs}].Arg[2]} Z:${LocArray[${NumLocs}].Arg[3]} Plotted 
        /varset NumLocs ${Math.Calc[${NumLocs}+1]} 
    } else { 
        /if (${PauseFlag}==0) { 
            /if (${SilentFlag}==0) /echo -[ You aren't recording anything! ]- 
        } else { 
            /if (${SilentFlag}==0) /echo -[ You must unpause your recording in order to plot! ]- 
        } 
    } 
} else { 
    /if (${SilentFlag}==0) /echo -[ You are not in Manual Record Mode! ]- 
} 
/return 


Sub Event_LocalPlot(EvtText) 
/if (${EvtText.Mid[7,4].Equal["plot"]}) { 
    /call PlotFunction 
} 
/return 


Sub PlayFunction(FuncText) 
/declare PlayNm string local 
/declare PlayItr string local 
/declare PlayDctn string local 
/declare PlayPong string local 
/declare PlayZn string local 
/declare PlayFace string local 
/declare TempCountVar int local 
/if (${PauseFlag}==0) { 
    /if (${PathingFlag}==0) { 
        /if (${RecordPathFlag}==0) { 
            /if (${FollowFlag}==0) { 
                /if (${GetMoreCommands}==1) { 
                    /varset GetMoreCommands 0 
                } else { 
                    /varset PlayQueueNum 1 
                } 

                :InitParse 
                :ParsePlayCommands 

                /if (${FuncText.Find[" "]}>0) /varset PlayNm ${FuncText.Left[${FuncText.Find[" "]}]} 
                /if (${FuncText.Find[" "]}>0) /varset FuncText ${FuncText.Right[${Math.Calc[${FuncText.Length}-${FuncText.Find[" "]}]}]} 

                /if (${FuncText.Find[" "]}>0) /varset PlayItr ${FuncText.Left[${FuncText.Find[" "]}]} 
                /if (${FuncText.Find[" "]}>0) /varset FuncText ${FuncText.Right[${Math.Calc[${FuncText.Length}-${FuncText.Find[" "]}]}]} 

                /if (${FuncText.Find[" "]}>0) /varset PlayDctn ${FuncText.Left[${FuncText.Find[" "]}]} 
                /if (${FuncText.Find[" "]}>0) /varset FuncText ${FuncText.Right[${Math.Calc[${FuncText.Length}-${FuncText.Find[" "]}]}]} 

                /if (${FuncText.Find[" "]}>0) /varset PlayPong ${FuncText.Left[${FuncText.Find[" "]}]} 
                /if (${FuncText.Find[" "]}>0) /varset FuncText ${FuncText.Right[${Math.Calc[${FuncText.Length}-${FuncText.Find[" "]}]}]} 

                /if (${FuncText.Arg[2].Find["facef"]}>0 || ${FuncText.Arg[2].Find["faceb"]}>0) { 
                    /if (${FuncText.Find[";"]}>0) { 

                        /if (${FuncText.Find[" "]}>0) /varset PlayZn ${FuncText.Left[${Math.Calc[${FuncText.Find[" "]}-1]}]} 
                        /if (${FuncText.Find[" "]}>0) /varset FuncText ${FuncText.Right[${Math.Calc[${FuncText.Length}-${FuncText.Find[" "]}]}]} 

                        /varset PlayFace ${FuncText.Left[${Math.Calc[${FuncText.Find[";"]}-1]}]} 
                        /varset FuncText ${FuncText.Right[${Math.Calc[${FuncText.Length}-${FuncText.Find[";"]}]}]} 

                        /if (${PlayNm.Length}!=0 && ${PlayItr.Length}!=0 && ${PlayDctn.Length}!=0 && ${PlayPong.Length}!=0 && ${PlayZn.Length}!=0 && ${PlayFace.Length}!=0) { 
                            /varset PlayCommandQueue[${PlayQueueNum}] ${PlayNm} ${PlayItr} ${PlayDctn} ${PlayPong} ${PlayZn} ${PlayFace} 
                            /varset PlayQueueNum ${Math.Calc[${PlayQueueNum}+1]} 
                            /goto :InitParse 
                        } else { 
                            /if (${SilentFlag}==0) /echo -(( Playback syntax error detected.  Please try your command again. ))- 
                            /return 
                        } 
                    } else { 
                        /if (${FuncText.Find["+"]}>0) { 

                            /if (${FuncText.Find[" "]}>0) /varset PlayZn ${FuncText.Left[${FuncText.Find[" "]}]} 
                            /if (${FuncText.Find[" "]}>0) /varset FuncText ${FuncText.Right[${Math.Calc[${FuncText.Length}-${FuncText.Find[" "]}]}]} 

                            /varset PlayFace ${FuncText.Left[${Math.Calc[${FuncText.Find["+"]}-1]}]} 
                            /varset GetMoreCommands 1 
                        } else { 
                            /if (${FuncText.Find[" "]}>0) /varset PlayZn ${FuncText.Left[${FuncText.Find[" "]}]} 
                            /if (${FuncText.Find[" "]}>0) /varset FuncText ${FuncText.Right[${Math.Calc[${FuncText.Length}-${FuncText.Find[" "]}]}]} 
                            /varset PlayFace ${FuncText} 
                        } 

                        /if (${PlayNm.Length}!=0 && ${PlayItr.Length}!=0 && ${PlayDctn.Length}!=0 && ${PlayPong.Length}!=0 && ${PlayZn.Length}!=0 && ${PlayFace.Length}!=0) { 
                            /varset PlayCommandQueue[${PlayQueueNum}] ${PlayNm} ${PlayItr} ${PlayDctn} ${PlayPong} ${PlayZn} ${PlayFace} 
                            /if (${GetMoreCommands}==1) /varset PlayQueueNum ${Math.Calc[${PlayQueueNum}+1]} 
                            /goto :DonePlayParse 
                        } else { 
                            /if (${SilentFlag}==0) /echo -(( Playback syntax error detected.  Please try your command again. ))- 
                            /return 
                        } 
                    } 
                } else { 
                    /if (${FuncText.Find[";"]}>0) { 
                        /if (${FuncText.Find[";"]}>0) /varset PlayZn ${FuncText.Left[${Math.Calc[${FuncText.Find[";"]}-1]}]} 
                        /if (${FuncText.Find[";"]}>0) /varset FuncText ${FuncText.Right[${Math.Calc[${FuncText.Length}-${FuncText.Find[";"]}]}]} 

                        /if (${PlayNm.Length}!=0 && ${PlayItr.Length}!=0 && ${PlayDctn.Length}!=0 && ${PlayPong.Length}!=0 && ${PlayZn.Length}!=0) { 
                            /varset PlayCommandQueue[${PlayQueueNum}] ${PlayNm} ${PlayItr} ${PlayDctn} ${PlayPong} ${PlayZn} facef 
                            /varset PlayQueueNum ${Math.Calc[${PlayQueueNum}+1]} 
                            /goto :InitParse 
                        } else { 
                            /if (${SilentFlag}==0) /echo -(( Playback syntax error detected.  Please try your command again. ))- 
                            /return 
                        } 
                    } else { 
                        /if (${FuncText.Find["+"]}>0) { 
                            /varset PlayZn ${FuncText.Left[${Math.Calc[${FuncText.Find["+"]}-1]}]} 
                            /varset GetMoreCommands 1 
                        } else { 
                            /varset PlayZn ${FuncText} 
                        } 

                        /if (${PlayNm.Length}!=0 && ${PlayItr.Length}!=0 && ${PlayDctn.Length}!=0 && ${PlayPong.Length}!=0 && ${PlayZn.Length}!=0) { 
                            /varset PlayCommandQueue[${PlayQueueNum}] ${PlayNm} ${PlayItr} ${PlayDctn} ${PlayPong} ${PlayZn} facef 
                            /if (${GetMoreCommands}==1) /varset PlayQueueNum ${Math.Calc[${PlayQueueNum}+1]} 
                            /goto :DonePlayParse 
                        } else { 
                            /if (${SilentFlag}==0) /echo -(( Playback syntax error detected.  Please try your command again. ))- 
                            /return 
                        } 
                    } 
                } 

                :DonePlayParse 

                /if (${GetMoreCommands}==1) { 
                    /if (${SilentFlag}==0) /echo -[ Path Extender Detected. ${Math.Calc[${PlayQueueNum}-1].Int} commands queued.  Continue entering lines. ]- 
                    /return 
                } 

                /if (${SilentFlag}==0) /echo -[------------------------------------------------]- 
                /if (${SilentFlag}==0) /echo -[ There ${If[${PlayQueueNum}==1,is,are]} ${PlayQueueNum} ${If[${PlayQueueNum}==1,path,paths]} to be run. 
                /if (${SilentFlag}==0) /echo -[------------------------------------------------]- 
                /for TempCountVar 1 to ${PlayQueueNum} 
                    /if (${SilentFlag}==0) /echo -[ Path Command ${TempCountVar}: ${PlayCommandQueue[${TempCountVar}]} 
                /next TempCountVar 
                /if (${SilentFlag}==0) /echo -[------------------------------------------------]- 

                /varset PlayQueueCurr 1 
                /call GetCommand 
                /call LoadPathFile "${PBPFName}" 
                /if (${Macro.Return}==0) { 
                    /if (${SilentFlag}==0) /echo -[ Started play back of path file -( ${PBPFName} )- ]- 
                        /if (${Direction.Equal["forward"]}) { 
                            /if (${PBDirection.Find["c"]}) { 
                                /call GetClosestLoc 
                                /call StoreHeading ${CurrLoc} 
                            } else { 
                                /varset CurrLoc 1 
                                /call StoreHeading ${CurrLoc} 
                            } 
                        } else { 
                            /if (${PBDirection.Find["c"]}) { 
                                /call GetClosestLoc 
                                /call StoreHeading ${CurrLoc} 
                            } else { 
                                /varset CurrLoc ${NumLocs} 
                                /call StoreHeading ${CurrLoc} 
                            } 
                        } 
                    /varset PathingFlag 1 
                } 

            } else { 
                /if (${SilentFlag}==0) /echo -(( You cannot start playback while in follow mode! ))- 
            } 
        } else { 
            /if (${SilentFlag}==0) /echo -(( You cannot start playback while recording! ))- 
        } 
   } else { 
        /if (${SilentFlag}==0) /echo -(( You are already playing back path file -( ${PBPFName} )- ))- 
   } 
} else { 
    /if (${SilentFlag}==0) /echo -(( You cannot start playback while paused! ))- 
} 
/return 


Sub Event_LocalPlay(EvtText) 
/if (${EvtText.Mid[7,5].Equal["play:"]}) { 
    /call PlayFunction "${EvtText.Right[-11]}" 
} 
/return  


Sub PatternFunction(FuncText) 
/if (${PauseFlag}==0) { 
    /if (${PathingFlag}==0) { 
        /if (${FollowFlag}==0) { 
            /if (${RecordPathFlag}==0) { 
                /if (${FuncText.Arg[3].Length}==0) { 
                    /if (${FuncText.Arg[1].Length}!=0 && ${FuncText.Arg[2].Length}!=0) { 
                        /call ShapePlot ${FuncText.Arg[1]} ${FuncText.Arg[2]} ${Me.Y} ${Me.X} ${Me.Z} 
                        /varset RecordPFName TempShape 
                        /varset RecordPathFlag 1 
                        /call StopFunction 
                        /varset PlotFlag 1 
                        /call PlayFunction "${RecordPFName} loop cf nopp noz facef" 
                    } 
                } else { 
                    /if (${FuncText.Arg[1].Length}!=0 && ${FuncText.Arg[2].Length}!=0 && ${FuncText.Arg[3].Length}!=0) { 
                        /call ShapePlot ${FuncText.Arg[1]} ${FuncText.Arg[2]} ${Me.Y} ${Me.X} ${Me.Z} 
                        /varset RecordPFName TempShape 
                        /varset RecordPathFlag 1 
                        /call StopFunction 
                        /varset PlotFlag 1 
                        /if (${FuncText.Arg[3].Equal[faceb]}) { 
                            /call PlayFunction "${RecordPFName} loop cf nopp noz faceb" 
                        } else { 
                            /call PlayFunction "${RecordPFName} loop cf nopp noz facef" 
                        } 
                    } 
                } 
            } else { 
                /if (${SilentFlag}==0) /echo -(( You are already recording path file -( ${RecordPFName} )- ))- 
            } 
       } else { 
           /if (${SilentFlag}==0) /echo -(( You cannot start a pattern playback while in follow mode! ))- 
       } 
   } else { 
        /if (${SilentFlag}==0) /echo -(( You cannot start a pattern playback while playing back a path! ))- 
   } 
} else { 
    /if (${SilentFlag}==0) /echo -(( You cannot start a pattern playback while paused! ))- 
} 
/return 


Sub Event_LocalPattern(EvtText) 
/if (${EvtText.Mid[7,8].Equal["pattern:"]}) { 
    /call PatternFunction "${EvtText.Right[-14]}" 
} 
/return 


Sub RecordFunction(FuncText) 
/if (${FuncText.Arg[2].Equal["manual"]}) { 
    /varset ManualRecord 1 
} else { 
    /varset ManualRecord 0 
} 
/if (${PauseFlag}==0) { 
    /if (${PathingFlag}==0) { 
        /if (${FollowFlag}==0) { 
            /if (${RecordPathFlag}==0) { 
                /varset RecordPFName ${FuncText.Arg[1]} 
                /varset RecordPathFlag 1 
                /call ClearLocs 
                /if (${SilentFlag}==0) /echo -[ Started recording path file -( ${RecordPFName} )- ]- 
            } else { 
                /if (${SilentFlag}==0) /echo -(( You are already recording path file -( ${RecordPFName} )- ))- 
            } 
       } else { 
           /if (${SilentFlag}==0) /echo -(( You cannot start recording while in follow mode! ))- 
       } 
   } else { 
        /if (${SilentFlag}==0) /echo -(( You cannot start recording while playing back a path! ))- 
   } 
} else { 
    /if (${SilentFlag}==0) /echo -(( You cannot start recording while paused! ))- 
} 
/return 


Sub Event_LocalRecord(EvtText) 
/if (${EvtText.Mid[7,6].Equal["record"]}) { 
    /call RecordFunction "${EvtText.Right[-13]}" 
} 
/return 


Sub GotoFunction(TempYCoord,TempXCoord,TempZCoord) 
/if ((${Defined[TempXCoord]}) && (${Defined[TempYCoord]})) /goto :Defined 
    /if (${SilentFlag}==0) /echo -(( You must at least provide the Y and X coordinates to run to. ))- 
    /return 
:Defined 
/if (${Defined[TempZCoord]}) { 
} else { 
    /declare TempZCoord float local 
    /varset TempZCoord ${Me.Z} 
} 
/if (${PauseFlag}==0) { 
    /if (${PathingFlag}==0) { 
        /if (${FollowFlag}==0) { 
            /if (${RecordPathFlag}==0) { 
                /call ClearLocs 
                /varset LocArray[1] ${TempYCoord} ${TempXCoord} ${TempZCoord} 
                /varset LocArray[2] ${TempYCoord} ${TempXCoord} ${TempZCoord} 
                /varset RecordPFName GotoLoc 
                /varset RecordPathFlag 1 
                /varset CurrLoc 1 
                /varset NumLocs 2 
                /call StopFunction 
                /call PlayFunction "${RecordPFName} 1 f nopp noz" 
                /if (${SilentFlag}==0) /echo -[ Running to location:${TempYCoord},${TempXCoord},${TempZCoord} ]- 
            } else { 
                /if (${SilentFlag}==0) /echo -(( You cannot use goto while recording. ))- 
            } 
       } else { 
           /if (${SilentFlag}==0) /echo -(( You cannot use goto while in follow mode! ))- 
       } 
   } else { 
        /if (${SilentFlag}==0) /echo -(( You cannot use goto while playing back a path! ))- 
   } 
} else { 
    /if (${SilentFlag}==0) /echo -(( You cannot use goto while paused! ))- 
} 
/return 


Sub Event_LocalGoto(EvtText) 
/if (${EvtText.Mid[7,4].Equal["goto"]}) { 
    /varset EvtText ${EvtText.Right[-11]} 
    /declare TempYCrd string local 
    /declare TempXCrd string local 
    /declare TempZCrd string local 
    /if (${EvtText.Arg[1].Length}!=0 && ${EvtText.Arg[2].Length}!=0) { 
        /if (${EvtText.Find[" "]}>0) { 
            /varset TempYCrd ${EvtText.Mid[1,${EvtText.Find[" "]}]} 
            /varset EvtText ${EvtText.Mid[${Math.Calc[${EvtText.Find[" "]}+1]},${Math.Calc[${EvtText.Length}-${EvtText.Find[" "]}]}]} 
        } 
        /if (${EvtText.Find[" "]}>0) { 
            /varset TempXCrd ${EvtText.Mid[1,${EvtText.Find[" "]}]} 
            /varset EvtText ${EvtText.Mid[${Math.Calc[${EvtText.Find[" "]}+1]},${Math.Calc[${EvtText.Length}-${EvtText.Find[" "]}]}]} 
            /if (${EvtText.Length}>0) { 
                /varset TempZCrd ${EvtText.Arg[1]} 
            } else { 
                /varset TempZCrd ${Me.Z} 
            } 
        } else { 
            /varset TempXCrd ${EvtText.Arg[1]} 
            /varset TempZCrd ${Me.Z} 
        } 
        /call GotoFunction "${TempYCrd}" "${TempXCrd}" "${TempZCrd}" 
    } else { 
        /if (${SilentFlag}==0) /echo -(( You must at least provide the Y and X coordinates to run to. ))- 
    } 

} 
/return 


Sub DistanceFunction(FuncText) 
    /varset FollowDistance ${FuncText} 
    /if (${SilentFlag}==0) /echo -[ Follow Distance :[${Int[${FollowDistance}]}] ]- 
/return 


Sub Event_LocalDistance(EvtText) 
/if (${EvtText.Mid[7,8].Equal["distance"]}) { 
    /call DistanceFunction "${EvtText.Right[-15]}" 
} 
/return 


Sub SilentFunction 
/if (${SilentFlag}==0) { 
    /varset SilentFlag 1 
    /echo -[ Silent Mode ON ]- 
} else { 
    /varset SilentFlag 0 
    /echo -[ Silent Mode OFF ]- 
} 
/return 


Sub Event_LocalSilent(EvtText) 
/if (${EvtText.Right[-6].Equal["silent"]}) { 
    /call SilentFunction 
} 
/return 


Sub StopFunction 
/declare AdvPathIniFile string local 
/declare NumOfRecs int local 
/declare ClearVar string local 
/declare RecCounter int local 
/declare RecClrCounter int local 
/if (${PathingFlag}==0) { 
    /if (${RecordPathFlag}==0) { 
        /if (${FollowFlag}==0) { 
            /if (${PauseFlag}==0) { 
                /if (${SilentFlag}==0) /echo -(( There is nothing to be stopped! ))- 
            } else { 
                /if (${SilentFlag}==0) /echo -[ Pause stopped and cleared! ]- 
            } 
        } else { 
            /varset FollowFlag 0 
            /call ClearLocs 
            /call Move 0 
            /if (${SilentFlag}==0) /echo -[ Stopped following -( ${FollowName} )- ]- 
        } 
    } else { 
        /if (${NumLocs}>1) { 
            /varset RecordPathFlag 0 
            /if (${SilentFlag}==0) /echo -[ Stopped recording path file -( ${RecordPFName} )- ]- 
            /if (${SilentFlag}==0) /echo -[ Saving path file -( ${RecordPFName} )- Stand By... ]- 
            /varset AdvPathIniFile PathFile_${RecordPFName}.ini 

            /varset RecClrCounter 0 
            :ClearRF 
            /varset ClearVar ${Ini[${AdvPathIniFile},PFLocs,${Int[${RecClrCounter}]},NOTFOUND]} 
            /if (${ClearVar.NotEqual["NOTFOUND"]}) { 
                /ini "${AdvPathIniFile}" "PFLocs" "${Int[${RecClrCounter}]}" "Empty" 
                /varset RecClrCounter ${Math.Calc[${RecClrCounter}+1]} 
                /goto :ClearRF 
            } 
            /goto :DoneClearRF 
            :DoneClearRF 
            
            /varset RecCounter 0 
            :CheckClearRF 
            /if (${RecCounter}==${RecClrCounter}) /goto :DoneCheckClearRF 

            /varset ClearVar ${Ini[${AdvPathIniFile},PFLocs,${Int[${RecCounter}]},NOTFOUND]} 
            /if (${ClearVar.Equal["Empty"]}) { 
               /varset RecCounter ${Math.Calc[${RecCounter}+1]} 
               /goto :CheckClearRF 
            } 
            /goto :CheckClearRF 
            :DoneCheckClearRF 
  
            /for NumOfRecs 0 to ${Math.Calc[${NumLocs}-2].Int} 
                /ini "${AdvPathIniFile}" "PFLocs" "${Int[${NumOfRecs}]}" "${LocArray[${Math.Calc[${NumOfRecs}+1]}]}" 
            /next NumOfRecs 

            /varset RecCounter 0 
            :CheckRF 
            /if (${RecCounter}==${Math.Calc[${NumLocs}-1]}) /goto :DoneCheckRF 

            /varset ClearVar ${Ini[${AdvPathIniFile},PFLocs,${Int[${RecCounter}]},NOTFOUND]} 

            /if (${ClearVar.Equal["NOTFOUND"]}) /goto :CheckRF 
            /if (${ClearVar.Equal["Empty"]}) /goto :CheckRF 
            /varset RecCounter ${Math.Calc[${RecCounter}+1]} 
            /goto :CheckRF 

            :DoneCheckRF 
            /if (${SilentFlag}==0) /echo -[ Save Completed. There were ${Math.Calc[${NumLocs}-1].Int} records total. ]- 
        } else { 
            /varset RecordPathFlag 0 
            /if (${SilentFlag}==0) /echo -(( There were no locations to record! ))- 
        } 
    } 
} else { 
    /if (${SilentFlag}==0) /echo -[ Playback stopped! ]- 
    /call Move 0 
} 
/varset PauseHolder NULL 
/varset PauseFlag 0 
/varset PathingFlag 0 
/varset RecordPathFlag 0 
/varset PlotFlag 1 
/call ClearLocs 
/return 


Sub Event_LocalStop(EvtText) 
/if (${EvtText.Right[-6].Equal["stop"]}) { 
    /call StopFunction 
} 
/return 


Sub Event_ZoneEvent 
/varset FollowID 0 
/if (${FollowFlag}==1) { 
    /varset ZoneTimer 30s 
    /call ClearLocs 
    /call Move 0 
    /delay 3s 
    /call ClearLocs 
    /call TargetMob "${FollowName}" 
} 
/if (${PathingFlag}==1) { 
    /call ClearLocs 
    /call Move 0 
    /delay 3s 
    /call ClearLocs 
} 
/call Move 0 
/return 


Sub SubModFunction 
/if (${DistanceModifier}>0) /varset DistanceModifier ${Math.Calc[${DistanceModifier}-1]} 
/if (${SilentFlag}==0) /echo -[ Distance Modifier:[${Int[${DistanceModifier}]}] ]- 
/return 


Sub Event_LocalSubMod(EvtText) 
/if (${EvtText.Right[-6].Equal["-"]}) { 
    /call SubModFunction 
} 
/return 


Sub AddModFunction 
/varset DistanceModifier ${Math.Calc[${DistanceModifier}+1]} 
/if (${SilentFlag}==0) /echo -[ Distance Modifier:[${Int[${DistanceModifier}]}] ]- 
/return 


Sub Event_LocalAddMod(EvtText) 
/if (${EvtText.Right[-6].Equal["+"]}) { 
    /call AddModFunction 
} 
/return 


Sub InitAPFVars(FaceF,SpeedS,FollowDst) 
/declare CurrLoc int outer 
/declare NumLocs int outer 
/declare LocArray[5000] string outer 
/declare PathingFlag int outer 
/declare FollowID int outer 
/declare SpeedSense int outer 
/declare UseFaceFast int outer 
/declare MyLastXLoc float outer 
/declare MyLastYLoc float outer 
/declare MyLastZLoc float outer 
/declare ObstacleCount int outer 
/declare CurrZone string outer 
/declare LastLoc string outer 
/declare TotalObstCount int outer 
/declare FollowName string outer 
/declare RecordPathFlag int outer 
/declare PauseFlag int outer 
/declare PauseHolder string outer 
/declare PlayCommandQueue[100] string outer 
/declare PlayQueueNum int outer 
/declare PlayQueueCurr int outer 
/declare RecordPFName string outer 
/declare PBPFName string outer 
/declare PBIterations string outer 
/declare PBFace string outer 
/declare Iterations int outer 
/declare PBDirection string outer 
/declare Direction string outer 
/declare GetMoreCommands int outer 
/declare PBPingPong string outer 
/declare PingPongCount int outer 
/declare PBZone string outer 
/declare FollowFlag int outer 
/declare ZoneFollow int outer 
/declare SilentFlag int outer 
/declare DelayTimer timer outer 
/declare ZoneTimer timer outer 
/declare ZoneFlag int outer 
/declare XCoordinate[100] float outer 
/declare YCoordinate[100] float outer 
/declare ZCoordinate[100] float outer 
/declare DistanceModifier int outer 
/declare FollowDistance int outer 
/declare CheckLocTimer timer outer 
/declare PositionTimer timer outer 
/declare StoreHeading int outer 
/declare CurrFollLoc string outer 
/declare DoorMoveTimer timer outer 
/declare ManualRecord int outer 
/declare PlotFlag int outer 
/varset PlotFlag 0 
/varset DoorMoveTimer 0 
/varset PositionTimer 0 
/varset CheckLocTimer 0 
/varset DistanceModifier 0 
/varset ZoneFlag 0 
/if (${Defined[FaceF]}) { 
    /varset UseFaceFast ${FaceF} 
} else { 
    /varset UseFaceFast 1 
} 
/if (${Defined[SpeedS]}) { 
    /varset SpeedSense ${SpeedS} 
} else { 
    /varset SpeedSense 15 
} 
/if (${Defined[FollowDst]}) { 
    /varset FollowDistance ${FollowDst} 
} else { 
    /varset FollowDistance 20 
} 
/varset SilentFlag 0 
/varset ZoneFollow 1 
/varset FollowFlag 0 
/varset PauseHolder NULL 
/varset PauseFlag 0 
/varset GetMoreCommands 0 
/varset PlayQueueCurr 1 
/varset PlayQueueNum 1 
/varset PBPFName NULL 
/varset RecordPFName NULL 
/varset RecordPathFlag 0 
/varset CurrLoc 1 
/varset NumLocs 1 
/varset PathingFlag 0 
/varset MyLastYLoc ${Me.Y} 
/varset MyLastXLoc ${Me.X} 
/varset MyLastZLoc ${Me.Z} 
/varset ObstacleCount 0 
/varset TotalObstCount 0 
/echo Advpath.inc by ml2517 -- Initialized. 
/return 
Last edited by Vexix on Sun Aug 08, 2004 8:08 am, edited 1 time in total.

Vexix
Genbot Janitor
Posts: 245
Joined: Sat Apr 17, 2004 10:10 am

Post by Vexix » Sun Aug 08, 2004 1:33 am

advpath2.inc

Code: Select all


|advpath2.inc 
|Generic movement/pathing macro for inclusion in your own macros. (2nd part) 
|Version 1.31
|Date:08/08/2004
| 
||** 
[advpath] 
version=1.31
**| 

Sub SimpleKeyPress(Function,Duration,DelayType) 
/if (!${Defined[DelayType]}) { 
    /declare DelayType int local 
    /varset DelayType 1 
} 
/if (${Function.Equal[FORWARD]} && ${PBFace.Equal[faceb]}) { 
    /varset Function BACK 
} else /if (${Function.Equal[BACK]} && ${PBFace.Equal[faceb]}) { 
    /varset Function FORWARD 
} 
/keypress ${Function} 
/keypress ${Function} hold 
/if (${DelayType}==1) { 
    /call Delay ${Duration} 
} else { 
    /delay ${Duration} 
} 
/keypress ${Function} 
/return 


Sub CheckObstacle 
/if (${PlotFlag}==0 && ${Math.Distance[${MyLastYLoc},${MyLastXLoc},${MyLastZLoc}]}<1) /call CheckDoor 
/if (${PlotFlag}==0 && ${Math.Distance[${MyLastYLoc},${MyLastXLoc},${MyLastZLoc}]}<1) /call HitObstacle 
/varset MyLastYLoc ${Me.Y} 
/varset MyLastXLoc ${Me.X} 
/varset MyLastZLoc ${Me.Z} 
/varset ObstacleCount 0 
/return 



Sub CheckDoor 
/declare CharDirection int local 
/declare TempVarDoor int local 
/declare TempStoreTgt int local 
/varset TempStoreTgt 0 

/if (${Target.ID}>0) /varset TempStoreTgt ${Target.ID} 
/doortarget 

/if (${Target.Name.Find["door"]} && ${Target.Distance}<=12) { 
    /call Move 0 
    /if (${Me.Heading.DegreesCCW}>=315) { 
        /look 0 
        /if (${PBFace.Equal[facef]}) { 
            /face fast nolook heading 0 
            /varset CharDirection 0 
        } else { 
            /face fast nolook heading 180 
            /varset CharDirection 180 
        } 
        /goto :GotHeading 
    } 
    /if (${Me.Heading.DegreesCCW}<45) { 
        /look 0 
        /if (${PBFace.Equal[facef]}) { 
            /face fast nolook heading 0 
            /varset CharDirection 0 
        } else { 
            /face fast nolook heading 180 
            /varset CharDirection 180 
        } 
        /goto :GotHeading 
    } 
    /if (${Me.Heading.DegreesCCW}>=45 && ${Me.Heading.DegreesCCW}<135) { 
        /look 0 
        /if (${PBFace.Equal[facef]}) { 
            /face fast nolook heading 90 
            /varset CharDirection 90 
        } else { 
            /face fast nolook heading 270 
            /varset CharDirection 270 
        } 
        /goto :GotHeading 
    } 
    /if (${Me.Heading.DegreesCCW}>=135 && ${Me.Heading.DegreesCCW}<225) { 
        /look 0 
        /if (${PBFace.Equal[facef]}) { 
            /face fast nolook heading 180 
            /varset CharDirection 180 
        } else { 
            /face fast nolook heading 0 
            /varset CharDirection 0 
        } 
        /goto :GotHeading 
    } 
    /if (${Me.Heading.DegreesCCW}>=225 && ${Me.Heading.DegreesCCW}<315) { 
        /look 0 
        /if (${PBFace.Equal[facef]}) { 
            /face fast nolook heading 270 
            /varset CharDirection 270 
        } else { 
            /face fast nolook heading 90 
            /varset CharDirection 90 
        } 
        /goto :GotHeading 
    } 

    :GotHeading 

    /varset TempVarDoor 0 
    :DoorMoveCloser 
    /varset TempVarDoor ${Math.Calc[${TempVarDoor}+1]} 

    /if (${TempVarDoor}>50) /goto :DoorDoneMoveCloser 
    /if (${PBFace.Equal[facef]}) { 
        /if (${Target.Distance}>10) /call SimpleKeyPress FORWARD 1 
        /if (${Target.Distance}<8) /call SimpleKeyPress BACK 1 
    } else { 
        /if (${Target.Distance}>10) /call SimpleKeyPress BACK 1 
        /if (${Target.Distance}<8) /call SimpleKeyPress FORWARD 1 
    } 

    /if (${Target.Distance}>10) /goto :DoorMoveCloser 
    /if (${Target.Distance}<8) /goto :DoorMoveCloser 
    :DoorDoneMoveCloser 

    /call Delay 0 

    /keypress USE HOLD 
    /keypress USE 
    /call Delay 1s 
    
    /varset DoorMoveTimer 1s 
    /varset TempVarDoor 0 
    :DoorMoveAway 
    /if (${DoorMoveTimer}>0) { 
        /varset TempVarDoor ${Math.Calc[${TempVarDoor}+1]} 
        /if (${TempVarDoor}>50) /goto :DoorDoneMoveAway 
        /if (${PBFace.Equal[facef]}) { 
            /if (${Target.Distance}>21) /call SimpleKeyPress FORWARD 1 
            /if (${Target.Distance}<16) /call SimpleKeyPress BACK 1 
        } else { 
            /if (${Target.Distance}>21) /call SimpleKeyPress BACK 1 
            /if (${Target.Distance}<16) /call SimpleKeyPress FORWARD 1 
        } 
        /if (${Target.Distance}>21) /goto :DoorMoveAway 
        /if (${Target.Distance}<16) /goto :DoorMoveAway 
        :DoorDoneMoveAway 
    } 

    /call Delay 0 
    /if ((${Target.Heading.DegreesCCW}>355)&&(${Target.Heading.DegreesCCW}<5)) { 
        /if (${CharDirection}==0) { 
                /varset TempVarDoor 0 
                /look 0 
                /face fast nolook heading 337 
                :DoorNorth1 
                /varset TempVarDoor ${Math.Calc[${TempVarDoor}+1]} 
                /if (${PBFace.Equal[facef]}) { 
                    /call SimpleKeyPress FORWARD 1 
                } else { 
                    /call SimpleKeyPress BACK 1 
                } 
                /if (${TempVarDoor}<1) /goto :DoorNorth1 
                /face fast nolook door 
        } else { 
                /varset TempVarDoor 0 
                /look 0 
                /face fast nolook heading 203 
                :DoorNorth2 
                /varset TempVarDoor ${Math.Calc[${TempVarDoor}+1]} 
                /if (${PBFace.Equal[facef]}) { 
                    /call SimpleKeyPress FORWARD 1 
                } else { 
                    /call SimpleKeyPress BACK 1 
                } 
                /if (${TempVarDoor}<1) /goto :DoorNorth2 
                /face fast nolook door 
        } 
    } 
    /if ((${Target.Heading.DegreesCCW}>85)&&(${Target.Heading.DegreesCCW}<95)) { 
        /if (${CharDirection}==90) { 
                /varset TempVarDoor 0 
                /look 0 
                /face fast nolook heading 67 
                :DoorWest1 
                /varset TempVarDoor ${Math.Calc[${TempVarDoor}+1]} 
                /if (${PBFace.Equal[facef]}) { 
                    /call SimpleKeyPress FORWARD 1 
                } else { 
                    /call SimpleKeyPress BACK 1 
                } 
                /if (${TempVarDoor}<1) /goto :DoorWest1 
                /face fast nolook door 
        } else { 
                /varset TempVarDoor 0 
                /look 0 
                /face fast nolook heading 293 
                :DoorWest2 
                /varset TempVarDoor ${Math.Calc[${TempVarDoor}+1]} 
                /if (${PBFace.Equal[facef]}) { 
                    /call SimpleKeyPress FORWARD 1 
                } else { 
                    /call SimpleKeyPress BACK 1 
                } 
                /if (${TempVarDoor}<1) /goto :DoorWest2 
                /face fast nolook door 
        } 
    } 
    /if ((${Target.Heading.DegreesCCW}>175)&&(${Target.Heading.DegreesCCW}<185)) { 
        /if (${CharDirection}==180) { 
                /varset TempVarDoor 0 
                /look 0 
                /face fast nolook heading 157 
                :DoorSouth1 
                /varset TempVarDoor ${Math.Calc[${TempVarDoor}+1]} 
                /if (${PBFace.Equal[facef]}) { 
                    /call SimpleKeyPress FORWARD 1 
                } else { 
                    /call SimpleKeyPress BACK 1 
                } 
                /if (${TempVarDoor}<1) /goto :DoorSouth1 
                /face fast nolook door 
        } else { 
                /varset TempVarDoor 0 
                /look 0 
                /face fast nolook heading 23 
                :DoorSouth2 
                /varset TempVarDoor ${Math.Calc[${TempVarDoor}+1]} 
                /if (${PBFace.Equal[facef]}) { 
                    /call SimpleKeyPress FORWARD 1 
                } else { 
                    /call SimpleKeyPress BACK 1 
                } 
                /if (${TempVarDoor}<1) /goto :DoorSouth2 
                /face fast nolook door 
        } 
    } 
    /if ((${Target.Heading.DegreesCCW}>265)&&(${Target.Heading.DegreesCCW}<275)) { 
        /if (${CharDirection}==270) { 
                /varset TempVarDoor 0 
                /look 0 
                /face fast nolook heading 247 
                :DoorEast1 
                /varset TempVarDoor ${Math.Calc[${TempVarDoor}+1]} 
                /if (${PBFace.Equal[facef]}) { 
                    /call SimpleKeyPress FORWARD 1 
                } else { 
                    /call SimpleKeyPress BACK 1 
                } 
                /if (${TempVarDoor}<1) /goto :DoorEast1 
                /face fast nolook door 
        } else { 
                /varset TempVarDoor 0 
                /look 0 
                /face fast nolook heading 113 
                :DoorEast2 
                /varset TempVarDoor ${Math.Calc[${TempVarDoor}+1]} 
                /if (${PBFace.Equal[facef]}) { 
                    /call SimpleKeyPress FORWARD 1 
                } else { 
                    /call SimpleKeyPress BACK 1 
                } 
                /if (${TempVarDoor}<1) /goto :DoorEast2 
                /face fast nolook door 
        } 
    } 
    /if (${PBFace.Equal[facef]}) { 
        /call Move 1 
    } else { 
        /keypress FORWARD hold 
        /delay 8 
        /keypress FORWARD 
        /call Move 1 
    } 
} 
/if (${TempStoreTgt}>0) { 
    /if (${Spawn[${TempStoreTgt}].ID}) /target id ${TempStoreTgt} 
} else { 
    /target clear 
} 
/return 


Sub CheckForTarget 
/if ((${FollowFlag}==1)&&(${ObstacleCount}<7)&&(!${Target.CleanName.Equal["${FollowName}"]})) { 
    /call TargetMob "${FollowName}" 
} 
/return 


Sub CheckMoving 
/if (${PauseFlag}==0 && ${Me.Speed}==0) { 
    /call Move 1 
} 
/return 


Sub ClearLocs 
/varset CurrLoc 1 
/varset NumLocs 1 
/varset ObstacleCount 0 
/varset TotalObstCount 0 
/return 


Sub Delay(DelayTime) 
| 
| Time Critical /call's that do simple calculations go in the for loop.  
| Do not put things in here that might interfere with other functions. 
| 
/varset DelayTimer ${DelayTime} 
:DlyLoop 
/delay 1 
/if (${FollowFlag}==1) /call TrackFollow 
/if (${DelayTimer}>0) /goto :DlyLoop 
/return 


Sub FindLookAngle(TY,TX,TZ) 
/declare Angle float local 
/declare LevOrWet int local 
/declare TempFacing float local 
/varset LevOrWet 0 
/declare FY float local 
/declare FX float local 
/declare FZ float local 
/varset FZ ${Me.Z} 
/if (${Me.FeetWet}) { 
    /varset TZ ${Math.Calc[${TZ}+3]} 
    /varset LevOrWet ${Math.Calc[${LevOrWet}+1]} 
} 
/if (${Me.Levitating}) { 
    /varset TZ ${Math.Calc[${TZ}+5]} 
    /varset LevOrWet ${Math.Calc[${LevOrWet}+1]} 
} 
/varset FY ${Me.Y} 
/varset FX ${Me.X} 
/varset Angle ${Math.Abs[${Math.Asin[${If[${Math.Abs[${Math.Abs[${FZ}-${TZ}]}/${Math.Distance[${TY},${TX},${TZ}:${FY},${FX},${FZ}]}]}<=1,${Math.Calc[${Math.Abs[${FZ}-${TZ}]}/${Math.Distance[${TY},${TX},${TZ}:${FY},${FX},${FZ}]}]},1]}]}]} 

/if (${FZ}>${TZ}) { 
    /varset Angle ${Math.Calc[${Angle}*-1]} 
} else /if (${TZ}==${FZ}) { 
    /varset Angle 0 
} 
/if (${LevOrWet}==0) /varset Angle ${Math.Calc[${Math.Calc[${Angle}\20]}*20]} 
/if (${FollowFlag}==1 && ${CurrLoc}<3 && ${Me.Speed}==0) { 
    /if (${PBFace.Equal[facef]}) { 
        /face nolook loc ${TY},${TX} 
    } else { 
        /face nolook away loc ${TY},${TX} 
    } 
    :WaitForTurnStart 
    /varset TempFacing ${Me.Heading.DegreesCCW} 
    /call Delay 1 
    /if (${Me.Heading.DegreesCCW}!=${TempFacing}) /goto :WaitForTurnStart 
} 
/if (${UseFaceFast}==0) { 
    /if (${Math.Abs[${Me.Heading.DegreesCCW}-${Heading[${TY},${TX}].DegreesCCW}]}>${If[${Me.Speed}>0,${Math.Calc[2700/${Me.Speed}]},10]}) { 
        /call Move 0 
        /if (${PBFace.Equal[facef]}) { 
            /face nolook loc ${TY},${TX} 
        } else { 
            /face nolook away loc ${TY},${TX} 
        } 
        :WaitForTurnLook 
        /varset TempFacing ${Me.Heading.DegreesCCW} 
        /call Delay 1 
        /if (${Me.Heading.DegreesCCW}!=${TempFacing}) /goto :WaitForTurnLook 
        /call Delay 1 
    } else { 
        /if (${PBFace.Equal[facef]}) { 
            /face nolook loc ${TY},${TX} 
        } else { 
            /face nolook away loc ${TY},${TX} 
        } 
    } 
} else { 
    /if (${PBFace.Equal[facef]}) { 
        /face fast nolook loc ${TY},${TX} 
    } else { 
        /face fast nolook away loc ${TY},${TX} 
    } 
} 
/look ${Angle} 
/return 


Sub FollowIncLoc(TY,TX,TZ) 
/if (${TY.Equal[NULL]} && ${TX.Equal[NULL]} && ${TZ.Equal[NULL]}) { 
    /call Move 0 
    /return 
} 
/declare TempFacing float local 
/varset CheckLocTimer 1 
/varset ObstacleCount ${Math.Calc[${ObstacleCount}+1]} 
/varset TotalObstCount ${Math.Calc[${TotalObstCount}+1]} 
/varset PositionTimer 1s 

/if (${Spawn[${FollowID}].ID} && ${Spawn[${FollowID}].Distance3D}<=${Math.Calc[${FollowDistance}+${Math.Calc[${Me.Speed}/30]}]}) { 
    /call Move 0 
    /if (${Spawn[${FollowID}].ID} && ${Spawn[${FollowID}].Speed}==0) { 
        /face nolook id ${FollowID} 
        :WaitForTurnFoll 
        /varset TempFacing ${Me.Heading.DegreesCCW} 
        /call Delay 1 
        /if (${Me.Heading.DegreesCCW}!=${TempFacing}) /goto :WaitForTurnFoll 
        :FollowDistClose 
        /if (${PositionTimer}>0 && ${Spawn[${FollowID}].ID}) { 
            /if (${Spawn[${FollowID}].Distance3D}>${Math.Calc[${FollowDistance}+8]}) /call SimpleKeyPress FORWARD 1 
            /if (${Spawn[${FollowID}].Distance3D}<${Math.Calc[${FollowDistance}-8]}) /call SimpleKeyPress BACK 1 
            /if (${Spawn[${FollowID}].Distance3D}>${Math.Calc[${FollowDistance}+8]}) /goto :FollowDistClose 
            /if (${Spawn[${FollowID}].Distance3D}<${Math.Calc[${FollowDistance}-8]}) /goto :FollowDistClose 
        } 
    } 

    /call ClearLocs 
    /if (${CurrLoc}==1) /varset CurrFollLoc ${Spawn[${FollowID}].Y} ${Spawn[${FollowID}].X} ${Spawn[${FollowID}].Z} 
    /return 
} 

/if ((${Heading[${TY},${TX}].DegreesCCW}<${Math.Calc[${StoreHeading}-90]})||(${Heading[${TY},${TX}].DegreesCCW}>${Math.Calc[${StoreHeading}+90]})||(${Math.Distance[${TY},${TX},${TZ}]}<${If[${Me.Speed}!=0,${Math.Calc[${Math.Calc[${Me.Speed}/${SpeedSense}]}+${DistanceModifier}]},${Math.Calc[${Math.Calc[200/${SpeedSense}]}+${DistanceModifier}]}]})) { 
    /varset LastLoc ${LocArray[${CurrLoc}]} 
    /varset CurrLoc ${Math.Calc[${CurrLoc}+1]} 
    /if (${CurrLoc}<${NumLocs}) /call StoreHeading ${CurrLoc} 
    /varset ObstacleCount 0 
    /varset TotalObstCount 0 
} 
/if (${CurrLoc}==${NumLocs}) { 
    /call Move 0 
    /if (${Spawn[${FollowID}].ID}) { 
        /face nolook id ${FollowID} 
        :WaitForTurnFoll2 
        /varset TempFacing ${Me.Heading.DegreesCCW} 
        /call Delay 1 
        /if (${Me.Heading.DegreesCCW}!=${TempFacing}) /goto :WaitForTurnFoll2 
        :FollowDistClose2 
        /if (${PositionTimer}>0 && ${Spawn[${FollowID}].ID} && ${Spawn[${FollowID}].Speed}==0) { 
        /if (${Spawn[${FollowID}].Distance3D}<${Math.Calc[${FollowDistance}+8]}) { 
                /if (${Spawn[${FollowID}].Distance3D}>${Math.Calc[${FollowDistance}+8]}) /call SimpleKeyPress FORWARD 1 
                /if (${Spawn[${FollowID}].Distance3D}<${Math.Calc[${FollowDistance}-8]}) /call SimpleKeyPress BACK 1 
                /if (${Spawn[${FollowID}].Distance3D}>${Math.Calc[${FollowDistance}+8]}) /goto :FollowDistClose2 
                /if (${Spawn[${FollowID}].Distance3D}<${Math.Calc[${FollowDistance}-8]}) /goto :FollowDistClose2 
            } 
        } 
    } 
    /call ClearLocs 
    /if (${CurrLoc}==1) /varset CurrFollLoc ${Spawn[${FollowID}].Y} ${Spawn[${FollowID}].X} ${Spawn[${FollowID}].Z} 
    /return 
} 
/if (${ObstacleCount}>6) /call CheckObstacle 
/if (${CurrLoc}<${NumLocs}) { 
    /if (${TotalObstCount}>50) { 
        /varset LastLoc ${LocArray[${CurrLoc}]} 
        /varset CurrLoc ${Math.Calc[${CurrLoc}+1]} 
        /varset ObstacleCount 0 
        /varset TotalObstCount 0 
    } 
} else { 
    /echo -(( Cannot get to location because of obstacles!  Aborting. ))- 
    /call StopFunction 
    /return 
} 
/if (${NumLocs}>${CurrLoc}) { 
    /call FindLookAngle ${LocArray[${CurrLoc}].Arg[1]} ${LocArray[${CurrLoc}].Arg[2]} ${LocArray[${CurrLoc}].Arg[3]} 
    /call CheckMoving 
} 
/return 

Sub GetClosestLoc 

/declare FindClosest int local 
/declare TempClosest float local 
/declare Closest int local 
/varset TempClosest 9999 
/varset Closest 1 
/for FindClosest 1 to ${NumLocs} 
    /if (${Math.Distance[${LocArray[${FindClosest}].Arg[1]},${LocArray[${FindClosest}].Arg[2]},${LocArray[${FindClosest}].Arg[3]}]}<${TempClosest}) { 
        /varset TempClosest ${Math.Distance[${LocArray[${FindClosest}].Arg[1]},${LocArray[${FindClosest}].Arg[2]},${LocArray[${FindClosest}].Arg[3]}]} 
        /varset Closest ${FindClosest} 
    } 
/next FindClosest 
/varset CurrLoc ${Closest} 
/return 


Sub GetCommand 
/varset PathingFlag 0 
/varset PBPFName ${PlayCommandQueue[${PlayQueueCurr}].Arg[1]} 
/varset PBIterations ${PlayCommandQueue[${PlayQueueCurr}].Arg[2]} 
/varset PBDirection ${PlayCommandQueue[${PlayQueueCurr}].Arg[3]} 
/varset PBPingPong ${PlayCommandQueue[${PlayQueueCurr}].Arg[4]} 
/varset PBZone ${PlayCommandQueue[${PlayQueueCurr}].Arg[5]} 
/varset PBFace ${PlayCommandQueue[${PlayQueueCurr}].Arg[6]} 

/if (${PBDirection.Find["r"]}) { 
    /varset Direction reverse 
} else { 
    /varset Direction forward 
} 
/if (${PBPingPong.Find["nopp"]}) { 
    /varset PingPongCount 0 
} else { 
    /varset PingPongCount 1 
} 
/if (${PBIterations.Find["loop"]}) { 
    /varset Iterations 1 
} else { 
    /varset Iterations ${PBIterations} 
} 
/return 


| Partially plagerized from McKorr's autofight.inc 
Sub HitObstacle 
/call Move 0 
/if (${PBFace.Equal[facef]}) { 
    /keypress BACK 
    /keypress BACK hold 
    /call Delay ${Math.Calc[${Math.Rand[3]}+3].Int} 
    /keypress BACK 
} else { 
    /keypress FORWARD 
    /keypress FORWARD hold 
    /call Delay ${Math.Calc[${Math.Rand[3]}+3].Int} 
    /keypress FORWARD 
} 

/if (${Math.Rand[99]}>49) { 
    /keypress RIGHT 
    /keypress RIGHT hold 
} else { 
    /keypress LEFT 
    /keypress LEFT hold 
} 
/call Delay ${Math.Calc[${Math.Rand[3]}+3].Int} 
/keypress RIGHT 
/keypress LEFT 
/call Move 1 
/call Delay 3 
/keypress JUMP 
/call Delay 1 
/if (${PBFace.Equal[facef]}) { 
    /face fast nolook loc ${LocArray[${CurrLoc}].Arg[1]},${LocArray[${CurrLoc}].Arg[2]} 
} else { 
    /face fast nolook away loc ${LocArray[${CurrLoc}].Arg[1]},${LocArray[${CurrLoc}].Arg[2]} 
} 
/return 


Sub IncrementLoc(TY,TX,TZ) 
/varset CheckLocTimer 1 
/declare HeadingDelta int local
/varset ObstacleCount ${Math.Calc[${ObstacleCount}+1]} 
/varset TotalObstCount ${Math.Calc[${TotalObstCount}+1]} 

/varcalc HeadingDelta ${Math.Abs[${Heading[${TY},${TX}].DegreesCCW}-${StoreHeading}]}
/if (${HeadingDelta}>90 && ${HeadingDelta}<270) { 
    /varset LastLoc ${LocArray[${CurrLoc}]} 
    /if (${Direction.Equal["forward"]}) { 
        /varset CurrLoc ${Math.Calc[${CurrLoc}+1]} 
        /call StoreHeading ${CurrLoc} 
    } else { 
        /varset CurrLoc ${Math.Calc[${CurrLoc}-1]} 
        /call StoreHeading ${CurrLoc} 
    } 
    /varset ObstacleCount 0 
    /varset TotalObstCount 0 
    /varset TY ${LocArray[${CurrLoc}].Arg[1]}
    /varset TX ${LocArray[${CurrLoc}].Arg[2]}
    /varset TZ ${LocArray[${CurrLoc}].Arg[3]}
} 

/if (${PBFace.Equal[facef]}) { 
    /if (${Math.Distance[${TY},${TX},${TZ}]}<${If[${Me.Speed}!=0,${Math.Calc[${Math.Calc[${Me.Speed}/${SpeedSense}]}+${DistanceModifier}]},${Math.Calc[${Math.Calc[200/${SpeedSense}]}+${DistanceModifier}]}]}) { 
        /varset LastLoc ${LocArray[${CurrLoc}]} 
        /if (${Direction.Equal["forward"]}) { 
            /varset CurrLoc ${Math.Calc[${CurrLoc}+1]} 
            /call StoreHeading ${CurrLoc} 
        } else { 
            /varset CurrLoc ${Math.Calc[${CurrLoc}-1]} 
            /call StoreHeading ${CurrLoc} 
        } 
        /varset ObstacleCount 0 
        /varset TotalObstCount 0 
    } 
} else { 
    /if (${Math.Distance[${TY},${TX},${TZ}]}<${If[${Me.Speed}!=0,${Math.Calc[${Math.Calc[${Me.Speed}/${SpeedSense}]}+${DistanceModifier}+10]},${Math.Calc[${Math.Calc[200/${SpeedSense}]}+${DistanceModifier}+10]}]}) { 
        /varset LastLoc ${LocArray[${CurrLoc}]} 
        /if (${Direction.Equal["forward"]}) { 
            /varset CurrLoc ${Math.Calc[${CurrLoc}+1]} 
            /call StoreHeading ${CurrLoc} 
        } else { 
            /varset CurrLoc ${Math.Calc[${CurrLoc}-1]} 
            /call StoreHeading ${CurrLoc} 
        } 
        /varset ObstacleCount 0 
        /varset TotalObstCount 0 
    } 
} 

/if (${Direction.Equal["forward"]}) { 
    /if (${CurrLoc}>${NumLocs}) { 
        /if (${PingPongCount}==0) { 
            /if (${PBIterations.NotEqual["loop"]}) { 
                /varset Iterations ${Math.Calc[${Iterations}-1]} 
            } else { 
                /varset CurrLoc 1 
                /call StoreHeading ${CurrLoc} 
            } 
            /if (${Iterations}==0) { 
                /if (${PBZone.Equal["z"]}) /call TryToZone 
                /if (${PlayQueueCurr}==${PlayQueueNum}) { 
                    /call Move 0 
                    /varset PlayQueueCurr 1 
                    /varset PlayQueueNum 1 
                    /varset PathingFlag 0 
                    /call ClearLocs 
                    /if (${SilentFlag}==0) /echo -[ Done with playback! ]- 
                } else { 
                    /varset PlayQueueCurr ${Math.Calc[${PlayQueueCurr}+1]} 
                    /call Move 0                  
                    /call GetCommand 
                    /call LoadPathFile "${PBPFName}" 
                    /if (${Macro.Return}==0) { 
                        /if (${SilentFlag}==0) /echo -[ Started play back of path file -( ${PBPFName} )- ]- 
                        /if (${Direction.Equal["forward"]}) { 
                            /if (${PBDirection.Find["c"]}) { 
                                /call GetClosestLoc 
                                /call StoreHeading ${CurrLoc} 
                            } else { 
                                /varset CurrLoc 1 
                                /call StoreHeading ${CurrLoc} 
                            } 
                        } else { 
                            /if (${PBDirection.Find["c"]}) {  
                                /call GetClosestLoc 
                                /call StoreHeading ${CurrLoc} 
                            } else { 
                                /varset CurrLoc ${NumLocs} 
                                /call StoreHeading ${CurrLoc} 
                            } 
                        } 
                        /varset PathingFlag 1 
                    } 
                } 
            } else { 
                /if (${PBPingPong.Equal["pp"]}) {            
                    /varset PingPongCount 1 
                    /varset Direction reverse 
                    /varset CurrLoc ${NumLocs} 
                    /call StoreHeading ${CurrLoc} 
                } 
            } 
        } else { 
            /varset PingPongCount ${Math.Calc[${PingPongCount}-1]} 
            /varset Direction reverse 
            /varset CurrLoc ${NumLocs} 
            /call StoreHeading ${CurrLoc} 
        } 
    } 
    /if (${ObstacleCount}>6) /call CheckObstacle 
    /if (${TotalObstCount}>50) { 
        /varset LastLoc ${LocArray[${CurrLoc}]} 
        /if (${CurrLoc}<${NumLocs}) { 
            /varset CurrLoc ${Math.Calc[${CurrLoc}+1]} 
            /call StoreHeading ${CurrLoc} 
            /varset ObstacleCount 0 
            /varset TotalObstCount 0 
        } else { 
            /echo -(( Cannot get to location because of obstacles!  Aborting. ))- 
            /call StopFunction 
            /return 
        } 
    } 
    /if (${PathingFlag}==1) { 
        /call FindLookAngle ${LocArray[${CurrLoc}].Arg[1]} ${LocArray[${CurrLoc}].Arg[2]} ${LocArray[${CurrLoc}].Arg[3]} 
        /call CheckMoving 
    } 
} else { 
    /if (${CurrLoc}<1) { 
        /if (${PingPongCount}==0) { 
            /if (${PBIterations.NotEqual["loop"]}) { 
                /varset Iterations ${Math.Calc[${Iterations}-1]} 
            } else { 
                /varset CurrLoc ${NumLocs} 
                /call StoreHeading ${CurrLoc} 
            } 
            /if (${Iterations}==0) { 
                /if (${PBZone.Equal["z"]}) /call TryToZone 
                /if (${PlayQueueCurr}==${PlayQueueNum}) { 
                    /call Move 0 
                    /varset PlayQueueCurr 1 
                    /varset PlayQueueNum 1 
                    /varset PathingFlag 0 
                    /call ClearLocs 
                    /if (${SilentFlag}==0) /echo -[ Done with playback! ]- 
                } else { 
                    /varset PlayQueueCurr ${Math.Calc[${PlayQueueCurr}+1]} 
                    /call Move 0 
                    /call GetCommand 
                    /call LoadPathFile "${PBPFName}" 
                    /if (${Macro.Return}==0) { 
                        /if (${SilentFlag}==0) /echo -[ Started play back of path file -( ${PBPFName} )- ]- 
                        /if (${Direction.Equal["forward"]}) { 
                            /if (${PBDirection.Find["c"]}) { 
                                /call GetClosestLoc 
                                /call StoreHeading ${CurrLoc} 
                            } else { 
                                /varset CurrLoc 1 
                                /call StoreHeading ${CurrLoc} 
                            } 
                        } else { 
                            /if (${PBDirection.Find["c"]}) { 
                                /call GetClosestLoc 
                                /call StoreHeading ${CurrLoc} 
                            } else { 
                                /varset CurrLoc ${NumLocs} 
                                /call StoreHeading ${CurrLoc} 
                            } 
                        } 
                        /varset PathingFlag 1 
                    } 
                } 
            } else { 
                /if (${PBPingPong.Equal["pp"]}) { 
                    /varset PingPongCount 1 
                    /varset Direction forward 
                    /varset CurrLoc 1 
                    /call StoreHeading ${CurrLoc} 
                } 
            } 
        } else { 
            /varset PingPongCount ${Math.Calc[${PingPongCount}-1]} 
            /varset Direction forward 
            /varset CurrLoc 1 
            /call StoreHeading ${CurrLoc} 
        } 
    } 
    /if (${ObstacleCount}>6) /call CheckObstacle 
    /if (${TotalObstCount}>50) { 
        /if (${CurrLoc}>1) { 
            /varset LastLoc ${LocArray[${CurrLoc}]} 
            /varset CurrLoc ${Math.Calc[${CurrLoc}-1]} 
            /call StoreHeading ${CurrLoc} 
            /varset ObstacleCount 0 
            /varset TotalObstCount 0 
        } else { 
            /echo -(( Cannot get to location because of obstacles!  Aborting. ))- 
            /call StopFunction 
            /return 
        } 
    } 
    /if (${PathingFlag}==1) { 
        /call FindLookAngle ${LocArray[${CurrLoc}].Arg[1]} ${LocArray[${CurrLoc}].Arg[2]} ${LocArray[${CurrLoc}].Arg[3]} 
        /call CheckMoving 
    } 
} 
/doevents 
/return 


Sub LoadPathFile(PFIniName) 
/declare AdvPathIniFile string local 
/varset AdvPathIniFile PathFile_${PFIniName}.ini 
/call ClearLocs 
:LoadPlayFile 
/varset LocArray[${NumLocs}] ${Ini[${AdvPathIniFile},PFLocs,${Int[${Math.Calc[${NumLocs}-1]}]},NOTFOUND]} 
/if (${LocArray[${NumLocs}].Equal["NOTFOUND"]}) { 
    /varset NumLocs ${Math.Calc[${NumLocs}-1]} 
    /goto :DoneLoadPlayFile 
} 
/if (${LocArray[${NumLocs}].Equal["Empty"]}) { 
    /varset NumLocs ${Math.Calc[${NumLocs}-1]} 
    /goto :DoneLoadPlayFile 
} 
/varset NumLocs ${Math.Calc[${NumLocs}+1]} 
/goto :LoadPlayFile 

:DoneLoadPlayFile 
/if (${NumLocs}<1) { 
    /if (${SilentFlag}==0) /echo -(( No pathing information found in -( ${PFIniName} )- ))- 
    /varset PathingFlag 0 
    /call ClearLocs 
    /return 1 
} 
/return 0 


Sub Move(MoveCommand) 
/if (${PauseFlag}==0) { 
    /if (${MoveCommand}==1) { 
        /if (${PBFace.Equal[facef]}) { 
            /keypress FORWARD 
            /keypress FORWARD hold 
        } else { 
            /keypress BACK 
            /keypress BACK hold 
        } 
    } else { 
        /keypress FORWARD 
        /keypress RIGHT 
        /keypress LEFT 
        /keypress BACK 
    } 
} else { 
    /if (${MoveCommand}==0) { 
        /keypress FORWARD 
        /keypress RIGHT 
        /keypress LEFT 
        /keypress BACK 
    } 
} 
/return 


Sub RecordPath 
/declare TempIndex int local 
/if (${ManualRecord}==0) { 
    /if (${RecordPathFlag}==1) { 
        /if (${NumLocs}==1) { 
            /varset LocArray[${NumLocs}] ${Me.Y} ${Me.X} ${Me.Z} 
            /varset NumLocs ${Math.Calc[${NumLocs}+1]} 
        } else { 
            /varset TempIndex ${Math.Calc[${NumLocs}-1]} 
            /if (${Math.Distance[${LocArray[${TempIndex}].Arg[1]},${LocArray[${TempIndex}].Arg[2]},${LocArray[${TempIndex}].Arg[3]}]}>12) { 
                /varset LocArray[${NumLocs}] ${Me.Y} ${Me.X} ${Me.Z} 
                /if (${SilentFlag}==0) /echo Location: Y:${LocArray[${NumLocs}].Arg[1]} X:${LocArray[${NumLocs}].Arg[2]} Z:${LocArray[${NumLocs}].Arg[3]} Plotted 
                /varset NumLocs ${Math.Calc[${NumLocs}+1]} 
            } 
        } 
    } 
} 
/doevents 
/return 
Last edited by Vexix on Sun Aug 08, 2004 8:09 am, edited 1 time in total.

Vexix
Genbot Janitor
Posts: 245
Joined: Sat Apr 17, 2004 10:10 am

Post by Vexix » Sun Aug 08, 2004 1:34 am

This space left intentionally blank.

A_Druid_00
Macro Maker Extraordinaire
Posts: 2378
Joined: Tue Jul 13, 2004 12:45 pm
Location: Rolling on the Lawn Farting

Post by A_Druid_00 » Sun Aug 08, 2004 3:03 am

Bah, now no one wil post about their random < and > crashes when using genbot anymore :lol:
[quote]<DigitalMocking> man, A_Druid_00 really does love those long ass if statements
<dont_know_at_all> i don't use his macro because i'm frightened of it[/quote]
[quote][12:45] <dont_know_at_all> never use a macro when you can really fuck up things with a plugin[/quote]

wardave
a ghoul
a ghoul
Posts: 120
Joined: Sun Jan 25, 2004 4:38 am

Post by wardave » Thu Aug 12, 2004 4:26 am

I remeber then this would follow through zones, like if i was running the char could follow me through stones/books just about anything. Does this version do that or is that gone?

A_Druid_00
Macro Maker Extraordinaire
Posts: 2378
Joined: Tue Jul 13, 2004 12:45 pm
Location: Rolling on the Lawn Farting

Post by A_Druid_00 » Thu Aug 12, 2004 7:11 am

It does as of last weekend.
[quote]<DigitalMocking> man, A_Druid_00 really does love those long ass if statements
<dont_know_at_all> i don't use his macro because i'm frightened of it[/quote]
[quote][12:45] <dont_know_at_all> never use a macro when you can really fuck up things with a plugin[/quote]

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Thu Aug 12, 2004 7:28 am

Ok, I've figured out how to use this great bit of code as the INC file that it is. Now how do I create (maybe I missed it, call me blind) a macro to run this so that I can PLOT a new INI file for a macro I am making?

Thanks in advance.

EDIT I have found this much, but it doesn't help me in making a macro from which to run it.

Code: Select all

| Optional manual record mode ----------------o 
| FileName (no spaces) ------------o | 
| (The quotes are necessary) | | 
| vvvvvvvvvvvv vvvvvv 
| /call RecordFunction "PATHFILENAME" manual 
| 
| /call PlotFunction 
| 
| /call StopFunction 
Further edit: Will this work with hotkeys to tell it when to plot, and stop?

Code: Select all

| make advpath ini files
|
| Makepath.mac

#include advpath.inc

Submain

/call RecordFunction "Param0" manual
/call PlotFunction
/call StopFunction
Yeah it's dirty and won't work as shown, but I'm looking for a confirmation of whether or not something like that will work. I'll put in proper /return and a loop to keep it going later.
Also can you make a path that goes from point a to point b with a zone between them? I am assuming you can and would have the play back say z vs noz, right?
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

Vexix
Genbot Janitor
Posts: 245
Joined: Sat Apr 17, 2004 10:10 am

Post by Vexix » Thu Aug 12, 2004 7:49 am

Achallenged1,

Best way to practice with it is like this:

Code: Select all

| 
| [Last Modified: 4/27/2004 8:00pm] 
| 
| Example of using advpath.inc to walk from location to location and do things along the way 
| 

#include advpath.inc 


Sub Main 
/call InitAPFVars 1 15 20 

:MainLoop 
/doevents 

| This is my first pathfile - I walk from my starting point to the first location 
| where I'd like to do something. 
| -------------------------------------------------------------------------------- 
/call PlayFunction "PATH1 1 cf nopp noz" 
/call WaitTilThere 

| -------------------------------------------------------------------------------- 
| * Put the code where you'd like to do things like target mobs, buy things etc here. 
| --------------------------------------------------------------------------------- 

| This is my second pathfile - I walk from my current point to the second location 
| where I'd like to do something. 
| -------------------------------------------------------------------------------- 
/call PlayFunction "PATH2 1 f nopp noz" 
/call WaitTilThere 

| -------------------------------------------------------------------------------- 
| * Put the code where you'd like to do things like target mobs, buy things etc here. 
| --------------------------------------------------------------------------------- 

| This is my third pathfile - I walk from my current point back to the first location 
| where I'll start it all over again 
| -------------------------------------------------------------------------------- 
/call PlayFunction "PATH3 1 f nopp noz" 
/call WaitTilThere 

/goto :MainLoop 
/return 

Sub WaitTilThere 
:LoopTilThere 
/if (${PathingFlag}==1) { 
/call AdvPathPoll 
/delay 0 
/doevents 
/goto :LoopTilThere 
} 
/return
That's a good way to play some paths. For recording, I would make a mac like this:

Code: Select all

Sub Main
/call InitAPFVars 1 15 20 
:LoopTilThere 
/if (${PathingFlag}==1) { 
/call AdvPathPoll 
/delay 0 
/doevents 
/goto :LoopTilThere 
} 
/return
And then use the /echo record filename command to start recording, and /echo stop to stop. Play around with it. :)

--Vexix

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Thu Aug 12, 2004 7:56 am

Thanks Vexis, that's what I was looking for, a way to record plots.

I'd semi figured out the running, and basically took it straight from the help text and started modifying it to meet my needs. I'm working on a faction script so I can work up my faction in SH so I can do brewing in there. As it is, most my toons do not have enough faction to buy in there, yet.
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Thu Aug 12, 2004 9:35 pm

Code: Select all

#Include advpath.inc
Sub Main 
/call InitAPFVars 1 15 20 
:LoopTilThere 
/if (${PathingFlag}==1) { 
/call AdvPathPoll 
/delay 0 
/doevents 
/goto :LoopTilThere 
} 
/return
Ok, it starts and immediately ends. Trying to think of how to make it run now....

Code: Select all

#include advpath.inc

/declare junk int
/var junk 0

Sub Main 
/call InitAPFVars 1 15 20 
:LoopTilThere 
/if (${junk}! 1) { 
/call AdvPathPoll 
/delay 0 
/doevents 
/goto :LoopTilThere 
} 
/return
Would that likely work? I'm done playing for tonight so not testing it, for now.
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

Vexix
Genbot Janitor
Posts: 245
Joined: Sat Apr 17, 2004 10:10 am

Post by Vexix » Thu Aug 12, 2004 10:01 pm

Er, right. Try:

Code: Select all

#Include advpath.inc 
Sub Main 
/call InitAPFVars 1 15 20 
:LoopTilThere 
/call AdvPathPoll 
/doevents 
/goto :LoopTilThere 
/return
--Vexix

User avatar
Bad Karma
a snow griffon
a snow griffon
Posts: 346
Joined: Sat Nov 22, 2003 9:34 pm
Contact:

Post by Bad Karma » Thu Aug 12, 2004 10:11 pm

aChallenged1 wrote:I'm working on a faction script so I can work up my faction in SH so I can do brewing in there. As it is, most my toons do not have enough faction to buy in there, yet.
I wrote one quite some time back, but never updated it because it was no longer needed. Pretty sure I posted it here (check the archives)...

Better yet, I'll repost it in the Conversion Help forum, including my path files. Feel free to convert it, and please, repost if you do, so others can benefit from it.
[b]- Bad Karma
________________________________________[/b]

In our own quest for excellence, we should strive to take the time to help those who help themselves.

All others should [b]RTFM[/b]!!!!!!!!!

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Thu Aug 12, 2004 10:37 pm

Thanks, once I have it working I'll definately post it.
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!