Problem with farming.mac

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

OldNecro
a ghoul
a ghoul
Posts: 136
Joined: Thu Dec 19, 2002 3:09 am

Problem with farming.mac

Post by OldNecro » Thu Dec 19, 2002 3:12 am

What is wrong with this code?

Code: Select all

| - Farming.mac - 
| use /macro farming.mac "item name"  |without the "s 
| press F9 once and make sure ur char is in the center 
| and zoom out as much as possible 
#include routines.mac 
#event fading_invis "You feel yourself starting to appear."

Sub Main 
   varset v85 0 
   varset v87 1 
   varset v90 0 
   /mqlog 
   :again 
   /call StatStuff 
   /delay 5    
   /itemtarget $p0 
   /call Runto 
   /call AutoRun 0 
   /delay 10 
   /delay 20 
   /call Pickup 
   /goto :again 

/return 

Sub Runto 
   /echo running 
   /face item 
   /call AutoRun 1 
   :runningto 
   /varadd v85 1 
   /varset v67 "$char(x)" 
   /varset v68 "$char(y)" 
   /if n "$v67"=="$char(x)" /if "$v68"=="$char(y)" /call Tree 
   /if n "$v85"=="50" /face item 
   /if n "$v85"=="50" /varset v85 0 
   /if n "$distance(item)"<"10" /goto :done 
   /goto :runningto 
   :done 

/return 

sub Pickup 

   /echo picking up 
   /face item 
   /cleanup 
   /delay 20 
   /click left item 
   /delay 30 
   /click left auto 
   /delay 5 
   /varadd v87 1 
/return 

sub Tree 

   /delay 10 
   /varcalc v69 $char(heading)+20 
   /face heading $v69 
   /sendkey down up 
   /delay 5 
   /call runto 

/return 

sub StatStuff 

   /echo starting to look for the $v87 , $p0 
   /if n "$V87"=="10  /varadd V90 10 
   /if n "$v87"=="10" /mqlog You have found $v90 , $p0 
   /if n "$v87"=="10" /varset v87 1 

/return

sub event_fading_invis

   /press 3

/return
Anyone have any idea? I am using the old UI and all. This gives errors for the first 3 variables and never picks anything up. It just locks up EQ for about 20 seconds when it finds something, then moves on.

Any help would be appreciated. Thanks!

User avatar
SingleServing
a hill giant
a hill giant
Posts: 195
Joined: Tue Dec 17, 2002 11:00 pm

Nutz

Post by SingleServing » Thu Dec 19, 2002 3:22 am

Call me crazy but

Code: Select all

Sub Main 
   varset v85 0 
   varset v87 1 
   varset v90 0 
   /mqlog
/varset!=varset

Try the / that should get you started =)

OldNecro
a ghoul
a ghoul
Posts: 136
Joined: Thu Dec 19, 2002 3:09 am

Post by OldNecro » Thu Dec 19, 2002 9:23 am

OMG LOL - That's what I get for using someone else's code... I can write, but I can't debug for the life of me!

Thanks, we'll see what happens. :)

-OldNecro

OldNecro
a ghoul
a ghoul
Posts: 136
Joined: Thu Dec 19, 2002 3:09 am

Post by OldNecro » Thu Dec 19, 2002 9:34 am

Didnn't work... The variables no longer give errors of course, but I am still getting the "Usage: if <condition> blah blah" message as if there's a problem with the if statements somewhere. It will walk up to the ground spawn, open my inventory, but never pick up the item. Then it locks up EQ for 20-30 seconds and goes to the next closest item and does it all again. Any other thoughts?

Thanks!

-OldNecro

OldNecro
a ghoul
a ghoul
Posts: 136
Joined: Thu Dec 19, 2002 3:09 am

Post by OldNecro » Thu Dec 19, 2002 10:49 am

Ok, I got it working for the most part.

It works great, as long as the item is actually visible on the screen. However, sometimes the ground spawns are inside trees, rocks, walls, and even under the ground. If it happens upon an item in one of these cases, it freaks out and starts giving error messages for the /click commands and just walks back and forth over the area where the item is even though it can't click on it.

Is there any way to make it remember where it's been and just ignore spawns at that exact loc if it was unable to click the item the first time and move on to the next? They do eventually despawn and pop up somwhere else in the zone...

Thanks,

-OldNecro

I R monk
orc pawn
orc pawn
Posts: 28
Joined: Tue Dec 10, 2002 4:29 pm

Post by I R monk » Thu Dec 19, 2002 11:01 am

just a thought you do a clean up before you do your /click left item
/cleanup does a series of esc's and and a I, /left click item tries to click on the item you have targeted if its on the screen.

you might try the following all though i'm not sure i have the following line right.... /varset "v95" "$p0"


| - Farming.mac -
| use /macro farming.mac "item name" |without the "s
| press F9 once and make sure ur char is in the center
| and zoom out as much as possible
#define ItemToHunt v95
#include routines.mac
#event fading_invis "You feel yourself starting to appear."

Sub Main
/varset v85 0
/varset v87 1
/varset v90 0
/varset "v95" "$p0"
/mqlog Farming.mac started, I'll be hunting "$ItemToHunt"
/cleanup
:Again
/call StatStuff
/delay 5
/itemtarget "$ItemToHunt"
/call Runto
/call AutoRun 0
/delay 30
/call Pickup
/goto :Again

/return

Sub Runto
/echo running
/face item
/call AutoRun 1
:Runningto
/varadd v85 1
/varset v67 $char(x)
/varset v68 $char(y)
/if n $v67==$char(x) /if n $v68==$char(y) /call Tree
/if n $v85==50 /face item
/if n $v85==50 /varset v85 0
/if n $distance(item)<10 /goto :Done
/goto :Runningto
:Done

/return

sub Pickup

/echo picking up
/face item
/click left item
/press i
/delay 30
/click left auto
/delay 5
/varadd v87 1
/press i
/return

sub Tree

/delay 10
/varcalc v69 $char(heading)+20
/face heading $v69
/sendkey down up
/delay 5
/call Runto

/return

sub StatStuff

/echo starting to look for the $v87 , "$ItemToHunt"
/if n $V87==10 /varadd V90 10
/if n $v87==10 /mqlog You have found $v90 , "$ItemToHunt"
/if n $v87==10 /varset v87 1

/return

sub event_fading_invis

/press 3

/return

I R monk
orc pawn
orc pawn
Posts: 28
Joined: Tue Dec 10, 2002 4:29 pm

Post by I R monk » Thu Dec 19, 2002 11:19 am

err nm see you fixed it already.

on the other problem you might try useing an combo of the following

after you target an item by name get its x and y loc.
add to the sub Pickup a number of pick up tries say 10
if you cant pick it up in 10 tries then add the x and y to an array and have your /targetitem filter out any x and y's that you were not able to pick up.

Just a quick though on how to resolve that problem

OldNecro
a ghoul
a ghoul
Posts: 136
Joined: Thu Dec 19, 2002 3:09 am

Post by OldNecro » Thu Dec 19, 2002 11:57 am

Yeah the code you posted worked perfectly also once I removed the quotes from around all the variables (/shrug)

Except with the same hanging on invisible items of course...

Do you have any code examples of how I would make /itemtarget ignore spawns I have already tried to pick up 2 or 3 times and failed? Also, would there be a way to store that information in a file somehow that it can read from so I don't have to rebuild that table of unreachable locs every time I run the macro, or is that beyond the scope of the program?

Thanks so much for all the help...

-OldNecro

I R monk
orc pawn
orc pawn
Posts: 28
Joined: Tue Dec 10, 2002 4:29 pm

Post by I R monk » Thu Dec 19, 2002 3:02 pm

May have spoke to soon no real filters for /itemtarget other than name.

Next line of thought, say were hunting yew leafs,
Do all yew leafs in the zone have the same id? if not
Will /item show the id for the ground spawns?
if so will /target id target a ground item?
if so we can build 1 array from the /item list and a 2nd array from the can not pick up list, then use the 2nd to filter the first each time you refreash the 1st.

may just be sol though.

lifewolf
a ghoul
a ghoul
Posts: 143
Joined: Fri Oct 18, 2002 6:29 pm

Post by lifewolf » Fri Dec 20, 2002 1:37 am

What was said about the if thing.

Those are almost all integer compares (/if n Var1<SIGN>Var2)

You apparently cant have quotes around Var1 and Var2 doing an int compare (/if n) since they are numbers not strings.

OldNecro
a ghoul
a ghoul
Posts: 136
Joined: Thu Dec 19, 2002 3:09 am

Post by OldNecro » Fri Dec 20, 2002 5:17 am

Aye thanks wolf... I did figure that part out eventually.

Monk, I just looked and yew leaves are listed as "*Green Leaf15835" or something to that effect. Every single one of them is called that though, even the number after the name is exactly the same in every case... Is there any way to grab an array containing the location of all the ground spawns in the zone that is updated every tick and add unreachable spawn locations to an array so that they are ignored? How would the logic work to make /itemtarget ignore the nearest item if it is in that unreachable array and go to the next closest item? Can the itemtarget routine itself somehow be modified to include this cyclic functionality?

I know I'm getting pretty advanced here, but when I learn a new scripting language I really like to push its limits when possible to make sure I pick up all the nuances... Does the readme really list EVERY possible command that MQ supports? Is there any way to add your own logics like operator overrides, etc? All of these things may open a door to be able to do what I want here. Just not much in the way of advanced topics here on the boards :(

Any thoughts?

-OldNecro

I R monk
orc pawn
orc pawn
Posts: 28
Joined: Tue Dec 10, 2002 4:29 pm

Post by I R monk » Fri Dec 20, 2002 11:34 am

Wonder if theres a chance for a new section on this MB, some thing like
Topic MQ Indepth
where each command can be expanded upon, and diffrent examples of usage listed.

As far as I can see there is no way to limit the command
/itemtarget. to any thing other than an item name.

which means you will always target the closest one, only thing i can see doing is if its one in the array that cant be picked up then face a diffrent direction and run for a while, then /itemtarget again and hope a diffrent one is closer this time.

This command might offer some hope for items below the earth though
/filter [macros (all, enchanced,none)] [skills (all,increase,none)] [target money food encumber debug (on,off)] [name (add, remove) <text>] [zrange <zrange>]

but again not to indepth on its usage.

OldNecro
a ghoul
a ghoul
Posts: 136
Joined: Thu Dec 19, 2002 3:09 am

Post by OldNecro » Fri Dec 20, 2002 12:01 pm

I was giving this a little more thought last night...

If there was a way to just get a list of the actual loc's of every drop in the zone, I could just drop that stuff in an array along with the calculated distance and do a quicksort on each pass of the loop, but that would still require there to be a way to target an item by its location rather than name or ID number. I've got a feeling the program just isn't capable of this sort of thing tho... :(