advpath.inc -- follow/record/playback pathing include 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

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

advpath.inc -- follow/record/playback pathing include file

Post by ml2517 » Mon Jan 26, 2004 8:14 pm

Generic example of a calling macro:

Code: Select all

| 
|   [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 edited by ml2517 on Sat May 01, 2004 5:26 pm, edited 6 times in total.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Mon Jan 26, 2004 8:15 pm

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 
Last edited by ml2517 on Tue Apr 27, 2004 8:59 pm, edited 8 times in total.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Mon Jan 26, 2004 8:16 pm

advpath.inc

Code: Select all

|advpath.inc 
|Generic movement/pathing macro for inclusion in your own macros.
|Version 1.29
|Date:5/11/2004 4:00am 
|
||**
[advpath]
version=1.29
**|

#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 ml2517 on Tue May 11, 2004 5:17 am, edited 21 times in total.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

advpath2.inc (Second part of advpath) & advpath.txt

Post by ml2517 » Sun Feb 01, 2004 9:33 am

advpath2.inc

Code: Select all

|advpath2.inc 
|Generic movement/pathing macro for inclusion in your own macros. (2nd part)
|Version 1.27
|Date:5/8/2004 3:00pm 
|
||**
[advpath]
version=1.27
**|

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
/varset ObstacleCount ${Math.Calc[${ObstacleCount}+1]}
/varset TotalObstCount ${Math.Calc[${TotalObstCount}+1]}

/if (${PBFace.Equal[facef]}) {
    /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}]}
        /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 ((${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}+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 

advpath.txt

Code: Select all

|advpath.txt 
|Help file for advpath.inc 
|Version 1.09 
|Date:5/5/2004 11:00pm 
| 
| 
| 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: 
| -------------------------- 
| 
| Optional face direction, used to walk paths facing forward or backward (Defaults to facef) -------o
| 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  vvvvvvvvvvv
|                                            play:PATHFILENAME #|loop cf|cr|f|r pp|nopp z|noz [facef|faceb]
| 
| Optional face direction, forward or backward (Defaults to facef) ---o
| Size of the object ---------------------------------------o         |
| Number of sides of the object -----------------------o    |         |
| Command (pattern including the colon) -------o       |    |         |
|                                              |       |    |         |
|                                            vvvvvvv vvvvv vvvv  vvvvvvvvvvv
|                                            pattern:Sides Size [facef|faceb]
| 
| 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: 
| ------------------------------------------------------------- 
| 
| Optional face direction, used to walk paths facing forward or backward (Defaults to facef) -----------------o
| 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  vvvvvvvvvvv 
|                                       /call PlayFunction "PATHFILENAME #|loop cf|cr|f|r pp|nopp z|noz [facef|faceb]" 
|
| Optional face direction, forward or backward (Defaults to facef) -------------o
| Size of the object -------------------------------------------------o         | 
| Number of sides of the object ---------------------------------o    |         |
| (The quotes are necessary)                                     |    |         |
|                                                                |    |         | 
|                                                              vvvvv vvvv  vvvvvvvvvvv
|                                       /call PatternFunction "Sides Size [facef|faceb]" 
| 
| 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 edited by ml2517 on Sat May 08, 2004 4:14 pm, edited 5 times in total.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Sun Feb 01, 2004 9:36 am

Updated:
Added 4 defines at the top of advpath.inc that you can change to map to the keys that you use for movement in EQ.

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Mon Feb 02, 2004 1:32 pm

Honestly I don't think the obstacle avoidance was mine. Looks like something I stole from L124RD's MacroKit a long time ago. I borrowed several routines from him in finalizing autofight.inc. I'm sure I modified it since then, but I'm pretty sure the original work was his.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Mon Feb 02, 2004 3:33 pm

Ah, I'd robbed it from a script that had your name at the top. You get the credit until someone else claims it. :D

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Sun Feb 15, 2004 12:27 am

Updated:

Using new $distance code. Performance should be noticably increased.

There currently seems to be a problem with /look so the Z axis isn't going to be accurate until its fixed in MQ2.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Sat Mar 06, 2004 12:55 pm

Updated:

/press and /sendkey's completely removed and replaced with the new /keypress method.

Wylker
a lesser mummy
a lesser mummy
Posts: 42
Joined: Tue Feb 10, 2004 5:32 pm

Post by Wylker » Sat Mar 06, 2004 5:43 pm

ml2517 wrote:Updated:
Added 4 defines at the top of advpath.inc that you can change to map to the keys that you use for movement in EQ.
Am I blind? I dont see these =/

Wylker
a lesser mummy
a lesser mummy
Posts: 42
Joined: Tue Feb 10, 2004 5:32 pm

Post by Wylker » Sat Mar 06, 2004 5:51 pm

NM im a moron need new mq2 for new syntax support

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Sat Mar 06, 2004 7:41 pm

Updated:
advpath.inc
advpath.txt

I've added in a manual record mode that will let you precisely plot locs if auto mode isn't accurate enough for what you are recording.

To record in Auto mode just use the command as you always had:
/echo record PATHFILENAME

To record in Manual mode add the manual parameter like this:
/echo record PATHFILENAME manual

If you are in Manual record mode you plot locations with the new command that was added:
/echo plot

Once you are done plotting locations just issue the stop command as you always have:
/echo stop

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Sat Apr 10, 2004 6:58 pm

Updated:
advpath.inc has been compeletly updated for the new parm system. I'll be cleaning up all of my code and updating the code to better use the new system but this version is fully functional.

There are a few bug fixes I found while testing the code that have been fixed as well.

Please let me know if you find any bugs.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Thu Apr 15, 2004 8:07 pm

Updated:
Reduced head bobble a bit more. Checked with 4/15 udpate to make sure it works right.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Tue Apr 20, 2004 7:32 pm

Updated:
Changed all of the /newif lines to have a pair of parenthesis around them. This is in prep for the changes coming soon.