It is no longer possible to set variables from the command line so I had to change the way you control the record macro. As it is now it will keep recording as long as you have a target. Press esc to loose the target and it will stop. When doing the manual record you sit down on the spot where you want to make waypoint.
recordpath.mac
Code: Select all
| RecordPath.mac
| by BlueSkies and Jalapeno
| BlueSkies.SC@comcast.net
| Jalapeno.SC@comcast.net
|
| /macro RecordPath <Pathname> Manual|Auto [<AutoInterval>]
|
| Converted by blueninja. Changed behavior:
| To continues to record as long as you have a target, press escape to loose the target and the recording will stop
| When using manual record sit down on the spot you want to make a waypoint to record it.
#turbo 25
|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
|Global Timers
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"
/declare gINIFile global
/varset gINIFile "CHANGEME\Paths.ini"
/declare tAutoTimer timer
/declare sLastX global
/declare sLastY global
/declare sNumPoints global
/declare gPathNum global
/declare gAutoFlag global
/declare gAutoInterval global
/varset sNumPoints 0
/varset gAutoInterval 50
/varset sLastX -5000
/varset sLastY -5000
/varset gPathNum @Param0
/if @Param1=="auto" {
/varset gAutoFlag eAuto
/if $defined(Param2)==TRUE {
/varset gAutoInterval @Param2
}
} 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 $char(state)==SIT {
/stand
/call Snapshot
}
}
/if $target()==TRUE /goto :MainLoop
/ini "@gINIFile" @gPathNum "numpoints" $int(@sNumPoints)
/echo [RecordPath] Script Ended.
/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
/declare l0 local
/declare l1 local
/declare l2 local
/declare l3 local
/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" @gPathNum "$int(@sNumPoints) Y" @l0
/ini "@gINIFile" @gPathNum "$int(@sNumPoints) X" @l1
/echo Path File Updated.
/return
Code: Select all
| WalkPath.mac
| by BlueSkies and Jalapeno
| BlueSkies.SC@comcast.net
| Jalapeno.SC@comcast.net
| Converted by blueninja.
| /macro WalkPath <pathname> <distancethreshold> [<startpoint> <endpoint>]
#turbo 25
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"
/declare gINIFile local
/declare gPathNumber local
/declare gStartPoint local
/declare gEndPoint local
/declare gStep local
/declare gThreshold local
/declare tEchoTimer timer
/declare l0 local
/declare l1 local
/declare l2 local
/declare l3 local
/varset gINIFile "CHANGEME\Paths.ini"
/varset gPathNumber @Param0
/varset gThreshold @Param1
/varset gStartPoint @Param2
/varset gEndPoint @Param3
/if @gThreshold=="" {
/echo No Threshold specified -- using 3.
/varset gThreshold 2
}
/if n @gStartPoint==0 {
/varset gStartPoint 1
/varset gEndPoint $int($ini("@gINIFile","@gPathNumber","numpoints"))
}
/if n @gStartPoint==-1 {
/varset gEndPoint 1
/varset gStartPoint $int($ini("@gINIFile","@gPathNumber","numpoints"))
}
/varset l0 @gStartPoint
/if @gStartPoint<@gEndPoint {
/varset gStep 1
} else /if @gStartPoint>@gEndPoint {
/varset gStep -1
}
/varset l1 $int($ini("@gINIFile","@gPathNumber","$int(@l0) Y"))
/varset l2 $int($ini("@gINIFile","@gPathNumber","$int(@l0) X"))
/face loc @l1, @l2
/call AutoRun 1
:MainLoop
/varset l1 $int($ini("@gINIFile","@gPathNumber","$int(@l0) Y"))
/varset l2 $int($ini("@gINIFile","@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 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 @Param0==1 /sendkey down up
/if @Param0==0 /sendkey up up
/return
Code: Select all
| [7-5-2003]
| Jalapeno & BlueSkies
| Converted by blueninja.
| Provides a list of all recorded paths.
#turbo 25
Sub Main
/declare l0 local
/declare l1 local
/declare l2 local
/declare l3 local
/varset l0 "CHANGEME\Paths.ini"
/echo **** Path Entries >>
/varset l1 $ini("@l0",-1,-1)
/varset l2 $left($instr("|",@l1),@l1)
:repeat
/echo @l2
/varcalc l3 $strlen(@l1)-$strlen(@l2)-1
/varset l1 $right(@l3,@l1)
/if @l1=="|" {
/echo End of Path Entries.
/return
}
/varset l2 $left($instr("|",@l1),@l1)
/goto :repeat
/return



