Recordpath.mac, walkpath.mac, paths.mac converted.

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

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

Recordpath.mac, walkpath.mac, paths.mac converted.

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

Conversion of an old macro by BlueSkies and Jalapeno.

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
walkpath.mac

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
paths.mac

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

Zacaria
orc pawn
orc pawn
Posts: 19
Joined: Wed Dec 03, 2003 5:47 pm

Post by Zacaria » Thu Dec 04, 2003 11:21 pm

thanks for the update on that, just needed that for an idea I have on a camp/area script (hunter type)

Will post an update on it when I feel its working.

Sephin
orc pawn
orc pawn
Posts: 25
Joined: Fri Nov 28, 2003 2:33 pm

Post by Sephin » Tue Dec 09, 2003 11:41 pm

Excellent for a hunting multiple mob camping script. Awesome to incorporate if you want to make an elaborate rare spawn killer looter =) /tar rarespawn /face /mac follow would work but hey still awesome macro.

One problem I have is I keep looking upward when I run it and I just wonder why it does that. Other than that class 1 macro, congrats =)

hank
decaying skeleton
decaying skeleton
Posts: 6
Joined: Thu Dec 11, 2003 5:27 pm

Post by hank » Thu Dec 11, 2003 5:39 pm

When I try and use /macro walkpath from another macro, it gives me variable errors. If it would help to see the exact error let me know, but it was something like this:

bad var @33 /varset gINIFile "c:\macroquest\Paths.ini"



And yes the path is correct, and the walkpath runs wonderfully as long as I don't /macro it from within a macro.

Any ideas? I tried adding /zapvars before the /macro command with no luck.

GuardianX99
a lesser mummy
a lesser mummy
Posts: 43
Joined: Tue Dec 31, 2002 6:31 pm
Contact:

Post by GuardianX99 » Thu Dec 11, 2003 5:50 pm

You do realise that by macroing it from within another macro you are killing the macro you are running right?

hank
decaying skeleton
decaying skeleton
Posts: 6
Joined: Thu Dec 11, 2003 5:27 pm

Post by hank » Fri Dec 12, 2003 1:27 am

Right. I was using this to leave the zone if a certain red-con mob showed up.

Sephin
orc pawn
orc pawn
Posts: 25
Joined: Fri Nov 28, 2003 2:33 pm

Post by Sephin » Fri Dec 12, 2003 1:58 am

Even if I don't run from another mac it still looks upward all gay like and is real wobbily and unrealiable to hit the mark if. It also does not stop on the loc it just runs past.

User avatar
driftinsupra
Official loudmouth
Official loudmouth
Posts: 212
Joined: Tue Jan 28, 2003 9:25 pm

Post by driftinsupra » Fri Dec 12, 2003 3:55 pm

This looks cool...I think I might to try to add it to my bazaar.mac script so my walking doesnt look so odd.

User avatar
psychotik
a ghoul
a ghoul
Posts: 112
Joined: Mon Oct 06, 2003 3:48 am

Post by psychotik » Fri Dec 12, 2003 4:46 pm

use nolook in your /face

User avatar
driftinsupra
Official loudmouth
Official loudmouth
Posts: 212
Joined: Tue Jan 28, 2003 9:25 pm

Post by driftinsupra » Fri Dec 12, 2003 5:09 pm

hmmm. I almost got this into my bazaar scrip[t but I was wondering if anyone would be willing to toss some obsticle avoidance in there? I would love to use this since my movement right now looks kinda crappy but I am having the problem that when people get in the way I just stand there and keep running into them. I tried to add my obsticle avoidance stuff in there but I think I just butchered up everything and then it stopped working. Anyone else wanna give it a try?