Routines.mac - Improved

Macro depository for macros written before the user variable changes that broke all of them.

Moderator: MacroQuest Developers

User avatar
L124RD
Site Admin
Site Admin
Posts: 1343
Joined: Fri Jun 14, 2002 12:15 am
Location: Cyberspace
Contact:

Routines.mac - Improved

Post by L124RD » Fri Jun 14, 2002 2:05 pm

This is an improved version of the routines.mac file. Just adding a few changes to make it more random and so that it works on slower comps.
Changes:
- BuyItems: added a random delay between 0 and 3
- SellItems: added a random delay between 0 and 3
- GotoTarg: The distance is now random between 0 and 5, I needed this mostly for my own macros when i needed to be pretty close to exactly where i needed to be
- GotoLoc: The distance is now random between 0 and 5.
Enjoy!

Code: Select all

| - routines.mac -
| Generic routines that may be used a lot.
| ----------------------------
| Original Version by: Plazmic
| Improved by: L124RD


Sub BuyItems

   /sendkey down shift

   /for v81 1 to $p0
      /click left merchant buy
      /delay $rand(3)
   /next v81

   /sendkey up shift

/return


| ----------------------------


Sub SellItem
   /sendkey down shift
   :SellItem
      /finditem $p0
      /if $find()==FALSE /goto :DoneSellItem
      /click left merchant sell
      /delay $rand(3)
   /goto :SellItem
   :DoneSellItem
   /sendkey up shift
/return


| ----------------------------


Sub BackPedal
   /if $p0==$v79 /return
   /varset v79 $p0
   /if $p0==1 /sendkey down up
   /if $p0==0 /sendkey up up
/return


| ----------------------------


Sub AutoRun
   /if $p0==$v80 /return
   /varset v80 $p0
   /if $p0==1 /sendkey down up
   /if $p0==0 /sendkey up up
/return


| ----------------------------


Sub GotoLoc
   /varset v91 $rand(5)
   :GotoLocLoop
      /face loc $p0
      /if "$p1"=="u" /Press u
      /call AutoRun 1
   /if n $distance($p0)>$v91 /goto :GotoLocLoop
   /call AutoRun 0
/return


| ----------------------------


Sub GotoTarg
    /varset v91 $rand(5)
   /target $p0
   :GotoTargLoop
      /face
      /if "$p1"=="u" /Press u
      /call AutoRun 1
   /if n $target(distance)>$v91 /goto :GotoTargLoop
   /call AutoRun 0
/return

| ----------------------------

Sub BuyItems
   /press down shift
   /for p1 1 to $p0
      /varcalc p2 $char(plat)*1000+$char(gold)*100+$char(silver)*10+$char(copper)
      /click left merchant buy
      :BuyItemsLoop
         /delay 0
      /if n $calc($char(plat)*1000+$char(gold)*100+$char(silver)*10+$char(copper))==$p2 /goto :BuyItemsLoop
   /next p1
   /press up shift
/return

| ----------------------------

Sub SellItem
   /sendkey down shift
   :SellItem
      /finditem $p0
      /if $find()==FALSE /goto :DoneSellItem
      /varcalc p2 $char(plat)*1000+$char(gold)*100+$char(silver)*10+$char(copper)
      /click left merchant sell
      :SellItemLoop
         /delay 0
      /if n $calc($char(plat)*1000+$char(gold)*100+$char(silver)*10+$char(copper))==$p2 /goto :SellItemLoop     
   /goto :SellItem
   :DoneSellItem
   /sendkey up shift
/return

| ----------------------------

Sub FindCombiner
   /for p1 7 downto 0
      /if "$pack($p1,combine)"=="$p0" /return $p1
   /next p1
   /echo You do not appear to have a valid $p0 container.
/return 99 

| End of routines.mac
Last edited by L124RD on Mon Jul 08, 2002 11:54 pm, edited 3 times in total.

User avatar
L124RD
Site Admin
Site Admin
Posts: 1343
Joined: Fri Jun 14, 2002 12:15 am
Location: Cyberspace
Contact:

Post by L124RD » Sat Jun 15, 2002 1:20 pm

Salutations,
Bumping since i made some changes... relized that since the random is called every time, there is a high chance that you will just stop at 5 clicks away from the point. Made the random before the calls so you should now actually stop at a point between 0 and 5, not just 5...

User avatar
L124RD
Site Admin
Site Admin
Posts: 1343
Joined: Fri Jun 14, 2002 12:15 am
Location: Cyberspace
Contact:

Post by L124RD » Mon Jul 08, 2002 5:20 pm

Salutations,
Should work with newest mq...

Plazmic
The One
The One
Posts: 800
Joined: Fri Jun 14, 2002 12:31 am
Contact:

Post by Plazmic » Mon Jul 08, 2002 8:15 pm

Some of this really should be rewritten... and to let people see how to write faster (and #turbo compatible code)

BuyItems and SellItem concept author lost...
FindCombiner concept from Sparr...

[Edit] Code zapped now that it's in the main post ;)
Last edited by Plazmic on Wed Jul 10, 2002 3:08 am, edited 1 time in total.
- Plazmic

User avatar
L124RD
Site Admin
Site Admin
Posts: 1343
Joined: Fri Jun 14, 2002 12:15 am
Location: Cyberspace
Contact:

Post by L124RD » Mon Jul 08, 2002 11:55 pm

Salutations,
Updated to include Plazmic's Update

eq_freak
a ghoul
a ghoul
Posts: 105
Joined: Mon Jun 24, 2002 7:17 am

Post by eq_freak » Tue Jul 09, 2002 7:17 pm

Delay 0 makes it #turbo compatible? I figured it would at least have to be Delay 1?

Plazmic
The One
The One
Posts: 800
Joined: Fri Jun 14, 2002 12:31 am
Contact:

Post by Plazmic » Wed Jul 10, 2002 3:07 am

/delay 0 is the bomb ;)
The presense of a /delay triggers MQ to let the client breathe, but we don't waste time waitng .1 of a second before running the next command...
- Plazmic

GD
a snow griffon
a snow griffon
Posts: 353
Joined: Sat Jun 29, 2002 11:57 pm

Post by GD » Wed Jul 10, 2002 3:43 pm

And which is more effecient, using "/delay 0" or "/doevents"?

User avatar
L124RD
Site Admin
Site Admin
Posts: 1343
Joined: Fri Jun 14, 2002 12:15 am
Location: Cyberspace
Contact:

Post by L124RD » Wed Jul 10, 2002 4:01 pm

Salutations,
I use /doevents to allow the events to process... but if i'm using one without any events i just use /delay 0

LamahHerder
a hill giant
a hill giant
Posts: 299
Joined: Sat Jun 29, 2002 2:37 am

Sub Autorun

Post by LamahHerder » Thu Jul 11, 2002 3:05 pm

You may wana change the random or completley remove it
I just didnt want to go to the same exact spot over and over, wanted it to be a lil more real-like since i call it often

for #turbo btw

Code: Select all

Sub GotoLoc
/echo GotoLoc
	/varset v81 $calc($rand(35)+2)

	:GotoLocLoop
		/face fast loc $p0
		/if "$p1"=="u" /Press u
		/if n $distance($p0)>16 /sendkey down up
		/if n $distance($p0)<7 /sendkey down down
		/if n $distance($p0)<17 /sendkey up up
		/if n $distance($p0)>6 /sendkey up down
		/if n $distance($p0)>$v81 /goto :GotoLocLoop
/return

User avatar
L124RD
Site Admin
Site Admin
Posts: 1343
Joined: Fri Jun 14, 2002 12:15 am
Location: Cyberspace
Contact:

Post by L124RD » Thu Jul 11, 2002 3:28 pm

Salutations,
the random will change each time...

LamahHerder
a hill giant
a hill giant
Posts: 299
Joined: Sat Jun 29, 2002 2:37 am

Re: Sub Autorun

Post by LamahHerder » Thu Jul 11, 2002 4:59 pm

You may wana change the random or completley remove it
I just didnt want to go to the same exact spot over and over, wanted it to be a lil more life like since i change locations often

for #turbo btw

Code: Select all

Sub GoToLoc
	/varset v81 $calc($rand(30)+8)
	:startGoToLoc
		/if n $distance($p0)<$v81 /goto :endGoToLoc
		/face loc $p0
		/if "$p1"=="u" /Press u
		/if n $distance($p0)>12 /sendkey down up
		/if n $distance($p0)<$v81 /goto :endGoToLoc
		/if n $distance($p0)>$v81 /goto :startGoToLoc
	:endGoToLoc
		/sendkey up up
/return
Edit = Fixed it, was broken 8*)

User avatar
L124RD
Site Admin
Site Admin
Posts: 1343
Joined: Fri Jun 14, 2002 12:15 am
Location: Cyberspace
Contact:

Post by L124RD » Thu Jul 11, 2002 6:10 pm

Salutations,
Your version is less exact, being within 8 to 37 of the point you want, if you are doing a quest macro, this can throw it off ALOT!
The way you have coded your macro, it would be faster if you changed the last if (for goto :startgotoloc) if it was /goto :startgotoloc
Why do you have two checks if you are within the distance?
Why not send key down up at the begining? you put it in the middle of your macro...

LamahHerder
a hill giant
a hill giant
Posts: 299
Joined: Sat Jun 29, 2002 2:37 am

A better #turbo gotoloc

Post by LamahHerder » Fri Jul 12, 2002 3:17 pm

To deal with getting stuck on crap
once again adjust the $rand to how close u wana get to a loc

Code: Select all

Sub GoToLoc
	/face loc $p0
	/varset v81 $calc($rand(5)+3)
	/varset v96 "$char(x)"
	/varset v97 "$char(y)"
	/goto :moveGoToLoc
	
	:moveGoToLoc
		/varset v96 "$char(x)"
		/varset v97 "$char(y)"
		/delay 1
		/if n $distance($p0)<$v81 /goto :endGoToLoc
		/face fast loc $p0
		/if "$p1"=="u" /Press u
		/if n $distance($p0)>12 /sendkey down up
		/if n "$v96"=="$char(x)" /if n "$v97"=="$char(y)" /goto :stuckGoToLoc
		/if n $distance($p0)<$v81 /goto :endGoToLoc
		/if n $distance($p0)>$v81 /goto :moveGoToLoc
	:stuckGoToLoc
		/press U
		/varset v98 $char(heading)
		/face heading $calc($v98+50)
		/delay 1
		/goto :moveGoToLoc
	:endGoToLoc
		/sendkey up up
/return
Last edited by LamahHerder on Fri Jul 12, 2002 3:46 pm, edited 2 times in total.

User avatar
L124RD
Site Admin
Site Admin
Posts: 1343
Joined: Fri Jun 14, 2002 12:15 am
Location: Cyberspace
Contact:

Post by L124RD » Fri Jul 12, 2002 3:44 pm

Salutations,
If you can tell you're stuck now, why not put the press u in the stuck loop, ie your against a door. The stuck loop will move you a little to the right, then snap you back at the begining of movetoloc, making it pretty pointless except for the fifth of a second when you aren't facing the location...