The village idiot asks again....

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

DekeFentle
a lesser mummy
a lesser mummy
Posts: 48
Joined: Wed Oct 22, 2003 1:41 pm

The village idiot asks again....

Post by DekeFentle » Thu Dec 04, 2003 2:00 pm

Would someone take a crack at upgrading these? They seem to be a great idea. I did PM Blueskys with no reponse.
Jalapeno wrote:We have changed a few things in the script and I have also included a macro that will display all of your path names for you so that you may easily recall them when using the walkpath macro.

Files included are:
recordpath.mac
walkpath.mac
paths.mac




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>] 
|       To end the script, you MUST /varset v98 1

#turbo 25 

#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" $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 
    
    /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

WALKPATH.MAC

Code: Select all

|    WalkPath.mac 
|    by BlueSkies and Jalapeno 
|       BlueSkies.SC@comcast.net 
|       Jalapeno.SC@comcast.net 

|    /macro WalkPath <pathname> <distancethreshold> [<startpoint> <endpoint>]

#turbo 25

#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","$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 nopredict 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 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

PATHS.MAC

Code: Select all

|    [7-5-2003]
|    Jalapeno & BlueSkies
    
|    Provides a list of all recorded paths.

#turbo 25

Sub Main
    /varset l0 "REPLACEME\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

Walkpath Example:
/macro WalkPath NexusBookToQeynosBook 3 1 50
This would walk path NexusBookToQeynosBook 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 NexusBookToQeynosBook 3 27 4
This would walk path NexusBookToQeynosBook with a Distance Threshold of
3. It will start at point 27 and end at point 4.
Revelation 6:8

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Thu Dec 04, 2003 7:17 pm

EDIT: Actually, decided to post it in the depot. Here http://macroquest2.com/phpBB2/viewtopic.php?p=29860