http://macroquest2.com/phpBB2/viewtopic ... 7057#17057
These can not be used without our update to the MQ source, which implements INI file access.
Enjoy!
Code: Select all
|**
RecordPath.mac
by BlueSkies and Jalapeno
BlueSkies.SC@comcast.net
Jalapeno.SC@comcast.net
Description:
Records EQ Path data for later use by WalkPath.mac for
automating walking in zones. At the moment, RecordPath.mac
uses /mqlog commands to save path information, and you
will need a parser to translate the mqlog into a path file.
I have written a parser that does this, and saves it as an
include file that will be automatically added to
WalkPath.mac.
Note:
This script uses functionality that may not exist in your
version of MacroQuest. The /ini command, which writes data
to an INI file, was created mostly because we wanted a way
to output path data from this macro, without having to run
a seperate application outside of MacroQuest to make that
data useable.
If you get an error while running this script, you want to
check to see if your version of MacroQuest includes this
functionality. At the time of this writing (6-29-03), our
INI functions are not included in the CVS build of MacroQuest.
You can download our copy of the MacroQuest source, which
is basically the current (6-29-03) CVS build, plus our INI
functions. Compile as normal and you're good to go.
This script should serve as a good example as to how File Manipulation
functions (even those as simple as the ones we provide) can
improve the quality of both the scripting language itself,
and the scripts written using it.
Usage:
/macro RecordPath <Pathnum> Manual|Auto [<AutoInterval>]
Pathnum refers to the number this path will be
saved under.
When executed with the 'Manual' flag, you will have to
tell the script when you reach a map point that you want
to save it as part of the path. This is done by setting
global variable v99 to 1, as follows:
(in EQ's chat window:)
/varset v99 1
It is a good idea to place this into a 'Socials' button
that you can press, instead of having to type it out.
RecordPath will tell you when it has added the entry.
When executed with the 'Auto' flag, you do not need to
tell the script when to add a path point. Instead, it
will do it automatically, every (by default) 5 seconds.
You can change this by specifying a different Interval
for the 'AutoInterval' paramater. This is done in 10ths
of a second. For example, 10 = 1 second, 50 = 5 seconds,
etc. If you specify 0 for this, it will record a point
with every single iteration, making for VERY big paths.
When you are done recording your path, set Variable v98
to 1 and the script will tell you when it has ended.
Example:
/macro RecordPath 1 Auto 2s
This will set the auto record interval to 2 seconds,
and turn on record. It will save the path as
Path Number 1.
/macro RecordPath 1 Auto 5
This will set the auto record interval to half a second
(5 tenths), and turn on record.
**IMPORTANT**
To end the script, you MUST /varset v98 1, or the parser
will NOT work. Doing this allows the script to send
last-minute data about the path to the log file, which
the parser REQUIRES. You must do this EVEN IF you are
running the script in auto mode.
Please see the documentation included with my RecordPath Output
Parser for more information on how to turn the mqlog output
into a path file that WalkPath.mac can use.
**|
#turbo 10
#DEFINE gINIFile v10
|Constants:
#DEFINE cXThresh 2 |Change these two constants to increase the
#DEFINE cYThresh 2 |distance at which the Snapshot sub will ignore
|subsequent calls. This cuts down on clutter in
|the output, and cleaner path execution.
|Enumerations
|Enum Auto
#DEFINE eManual 0
#DEFINE eAuto 1
|UI Variables
#DEFINE uiDoRecord v99
#DEFINE uiQuit v98
|Global Variables
#DEFINE gPathNum v50
#DEFINE gAutoFlag v51 |Enum Auto
#DEFINE gAutoInterval v52
|Static Variables
|Sub Snapshot
#DEFINE sLastX v70
#DEFINE sLastY v71
#DEFINE sNumPoints v72
|Global Timers
#DEFINE tAutoTimer t1
Sub Main
|Initialization:
|Note -- Edit the following line to represent the full path where you want your Paths.ini file
| to be stored. Like: "c:\macroquest\macros\data\Paths.ini"
/varset gINIFile "REPLACEME\Paths.ini"
/varset sLastX -5000
/varset sLastY -5000
/varset gPathNum $p0
/if $p1=="auto" {
/varset gAutoFlag eAuto
/if $p2!="" {
/varset gAutoInterval $p2
} else {
/varset gAutoInterval 50
}
} else {
/varset gAutoFlag eManual
}
/mqlog RECORDPATH $gPathNum|
/echo [RecordPath] Script started, initialization complete.
/if $gAutoFlag==eAuto /echo Automatically recording path every $calc($gAutoInterval/10) seconds.
/if $gAutoFlag==eManual /echo Manually recording path via '/varset v99 1'.
|Main Loop
:MainLoop
/doevents
/if n $gAutoFlag==eAuto {
/if n $tAutoTimer==0 {
/call Snapshot
/varset tAutoTimer $gAutoInterval
}
} else /if $gAutoFlag==eManual {
/if n $uiDoRecord==1 {
/varset uiDoRecord 0
/call Snapshot
}
}
/if $uiQuit!=1 /goto :MainLoop
/ini "$gINIFile" $int($gPathNum) "numpoints" $int($sNumPoints)
/echo [RecordPath] Script Ended. Please check your Logs folder for log output.
/return
Sub Snapshot
|$l0 = Current X
|$l1 = Current Y
|$l2 = X Complient (1=Not Complient)
|$l3 = Y Complient (1=Not Complient) (Both of these must be 1
| to ignore the call)
|$sLastX = the last X coordinate seen by this subroutine
|$sLastY = the last Y coordinate seen by this subroutine
|$cXThresh = The X threshold at which this subroutine will
| ignore calls
|$cYThresh = The Y threshold at which this subroutine will
| ignore calls
/varset l0 $char(y)
/varset l1 $char(x)
/if n $l0<=$calc($sLastX+cXThresh) /if n $l0=>$calc($sLastX-cXThresh) /varset l2 1
/if n $l1<=$calc($sLastY+cYThresh) /if n $l1=>$calc($sLastY-cYThresh) /varset l3 1
/if n $l2==1 /if n $l3==1 {
/echo Too close to last coordinate
/return
}
|The coordinates are complient.
/varset sLastX $l0
/varset sLastY $l1
/varset sNumPoints $calc($sNumPoints+1)
/ini "$gINIFile" $int($gPathNum) "$int($sNumPoints) Y" $l0
/ini "$gINIFile" $int($gPathNum) "$int($sNumPoints) X" $l1
/echo Path File Updated.
/returnCode: Select all
|**
WalkPath.mac
by BlueSkies and Jalapeno
BlueSkies.SC@comcast.net
Jalapeno.SC@comcast.net
Description:
WalkPath is the counterpart to RecordPath that walks (or runs)
your character along the pre-recorded paths recorded by
RecordPath.
Note:
This script uses functionality that may not exist in your
version of MacroQuest. The $ini function, which reads data
from an INI file, was created mostly because we wanted a way
to input path data to this macro.
If you get an error while running this script, you want to
check to see if your version of MacroQuest includes this
functionality. At the time of this writing (6-29-03), our
INI functions are not included in the CVS build of MacroQuest.
You can download our copy of the MacroQuest source, which
is basically the current (6-29-03) CVS build, plus our INI
functions. Compile as normal and you're good to go.
This script should serve as a good example as to how File Manipulation
functions (even those as simple as the ones we provide) can
improve the quality of both the scripting language itself,
and the scripts written using it.
Usage:
/macro WalkPath <pathnumber> <distancethreshold> [<startpoint> <endpoint>]
PathNumber is the number of the path you want to run.
DistanceThreshold is the tolerance number for how close
to the point the script will get before deciding it
has reached the point. Smaller numbers are best when
points are very close together or when you need dead-
on accuracy (like in dungeons, etc).
StartPoint is the point at which to start from. If this
is omitted, it will start from point 1 and end at the
last point. If StartPoint is -1, the macro will run
from End to Beginning (you don't need to know how many
points there are in order to run back through a path).
Also, EndPoint will not need to be specified.
EndPoint is the point at which the script will end.
If StartPoint is specified, EndPoint must be. EndPoint
can be greater than or less than StartPoint (if you want
to walk back through a path, you'd specify an end point
less than the start point).
Example:
/macro WalkPath 1 3 1 50
This would walk path #1 with a Distance Threshold of
3 (which means that it has a tolerance of 3 units
of distance where it will declare a point as reached).
It will start at point 1, and end at point 50.
/macro WalkPath 1 3 27 4
This would walk path #1 with a Distance Threshold of
3. It will start at point 27 and end at point 4.
*NOTE*
It is not advisable to modify this script directly.
Please see the documentation included with my RecordPath Output
Parser for more information on how to turn the mqlog output
into a path file that WalkPath.mac can use.
**|
#turbo 1000
#DEFINE gPathNumber v50
#DEFINE gStartPoint v51
#DEFINE gEndPoint v52
#DEFINE gStep v53
#DEFINE gThreshold v54
#DEFINE tEchoTimer t0
#DEFINE gINIFile v10
Sub Main
|Initialization
|Note -- Edit the following line to represent the full path where you want your Paths.ini file
| to be stored. Like: "c:\macroquest\macros\data\Paths.ini"
/varset gINIFile "REPLACEME\Paths.ini"
/varset gPathNumber $p0
/varset gThreshold $p1
/varset gStartPoint $p2
/varset gEndPoint $p3
/if $gThreshold=="" {
/echo No Threshold specified -- using 3.
/varset gThreshold 2
}
/if n $gStartPoint==0 {
/varset gStartPoint 1
/varset gEndPoint $int($ini("$gINIFile","$int($gPathNumber)","numpoints"))
}
/if n $gStartPoint==-1 {
/varset gEndPoint 1
/varset gStartPoint $int($ini("$gINIFile","$int($gPathNumber)","numpoints"))
}
/varset l0 $gStartPoint
/if $gStartPoint<$gEndPoint {
/varset gStep 1
} else /if $gStartPoint>$gEndPoint {
/varset gStep -1
}
/varset l1 $int($ini("$gINIFile","$int($gPathNumber)","$int($l0) Y"))
/varset l2 $int($ini("$gINIFile","$int($gPathNumber)","$int($l0) X"))
/face nopredict loc $l1, $l2
/call AutoRun 1
:MainLoop
/varset l1 $int($ini("$gINIFile","$int($gPathNumber)","$int($l0) Y"))
/varset l2 $int($ini("$gINIFile","$int($gPathNumber)","$int($l0) X"))
/varset tEchoTimer 5
/if $l0==$gStartPoint /echo $distance($l1,$l2)
:MainLoop2
/doevents
/if $tEchoTimer==0 {
/varset tEchoTimer 1s
/echo $distance($l1,$l2)
}
|The 'fast' paramater of the /face function prevents the command
|from smoothing out the turn, and instead immediately turns your
|character to face the specified direction. It is commented out here
|in favor of the smoothed /face, because it looks more natural and
|realistic. However, you will see problems with high-resolution paths
|(ie, paths in which the distances in between snapshots is very low) where
|your character will run in circles around points. There are two things
|you can do about this. The first is to increase the DistanceThreshold
|number that you pass when you start the script. The second is to uncomment
|the "/face fast nopredict" line, and comment the "/face nopredict" line.
|This will look a little less natural, but if you're using a high-
|resolution path in the first place, it really shouldn't matter.
|Another time where you might want to use /face fast is in dungeons or
|other tight areas where precision is important.
|/face fast nopredict loc $l1, $l2
/face nopredict loc $l1, $l2
/if n $distance($l1,$l2)>$gThreshold /goto :MainLoop2
/echo Point $l0 Reached.
/varset l0 $int($calc($l0+$gStep))
/if $l3==1 /goto :MainLoopExit
/if $l0==$gEndPoint /varset l3 1
/goto :MainLoop
:MainLoopExit
/call AutoRun 0
/echo Destination reached. Exiting.
/return
Sub AutoRun
/if $p0==1 /sendkey down up
/if $p0==0 /sendkey up up
/return
