revised Itemfarm.mac request

Macro requests from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

Juji
decaying skeleton
decaying skeleton
Posts: 6
Joined: Thu Dec 26, 2002 1:43 pm

revised Itemfarm.mac request

Post by Juji » Tue May 20, 2003 6:54 pm

Was wondering if anyone had a revised edition for this macro since its a little outdated.

I don't mind supervising it to collect my items, just would like for it to automatically take me to each ground spawn for the time being.


http://macroquest2.com/phpBB2/viewtopic ... light=farm

Thanks, Juji

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Post by grimjack » Thu May 22, 2003 8:00 am

This should walk you to the item and pause for 30 seconds before again targeting the closest item and walking you to it. I am not at home so I have not tested it. I don't think /click is functional enough to have it pick up the item automaticly yet but I'll see what I can think up for that part when I get a chance. I'll update this once I get home and test it.

Let me know what you think.

Thanks

Code: Select all

| - Farming2.mac -
| use /macro farming2 "item name"

#include routines.mac
#define MyXLOC v40
#define MyYLOC v41
#define ItemWeWant v42

Sub Main
   /varset ItemWeWant $p0
   :mainloop
   /call TargetItem
   /call RunToItem
   /delay 30s
   /goto :mainloop
/return

Sub RunToItem
   :runloop
   /face item
   /if n $distance(item)>=10/call AutoRun 1
   /if n $distance(item)<10 /goto :done
   /goto CheckObst
   /goto :runloop
   :done
   /call AutoRun 0
/return

sub TargetItem
   /echo Selecting $ItemWeWant
   /itemtarget $ItemWeWant
/return 

sub CheckObst
   /if n $MyXLOC==$char(x) /if n $MyYLOC==$char(y) /call HitObst 5
   /varset MyXLOC $char(x)
   /varset MyYLOC $char(y)
   /varset ObstCount 0
/return

sub HitObst
   /sendkey up up

   /sendkey down down 
   /if n $rand(99)>50 {


      /delay 3s
      /sendkey up down
      /sendkey down Right
      /delay $p0 
      /sendkey up Right
      /sendkey down up
      /delay 3s
      /sendkey up up
   } else {
      /delay 3s
      /sendkey up down
      /sendkey down left
      /delay $p0 
      /sendkey up left
      /sendkey down up
      /delay 3s
      /sendkey up up       
   }
   /sendkey up down
   /sendkey up Right
   /sendkey up Left
   /sendkey down up
/return 

Last edited by grimjack on Mon May 26, 2003 2:51 am, edited 1 time in total.

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Fixed many errors.

Post by grimjack » Thu May 22, 2003 1:06 pm

#include routines.mac
#define MyXLOC v40
#define MyYLOC v41
#define ItemWeWant v42

Sub Main
/varset ItemWeWant $p0
:mainloop
/call TargetItem
/call RunToItem
/goto :mainloop
/return

Sub RunToItem
:runloop
/face item
/if n $distance(item)>=10 /call AutoRun 1
/if n $distance(item)<10 /goto :done
/call CheckObst
/goto :runloop
:done
/call AutoRun 0
/return

sub TargetItem
/echo Selecting $ItemWeWant
/itemtarget $ItemWeWant
/return

sub CheckObst
/if n $MyXLOC==$char(x) /if n $MyYLOC==$char(y) /call HitObst 5
/varset MyXLOC $char(x)
/varset MyYLOC $char(y)
/return

sub HitObst
/sendkey up up

/sendkey down down
/if n $rand(99)>50 {


/delay 3s
/sendkey up down
/sendkey down Right
/delay $p0
/sendkey up Right
/sendkey down up
/delay 3s
/sendkey up up
} else {
/delay 3s
/sendkey up down
/sendkey down left
/delay $p0
/sendkey up left
/sendkey down up
/delay 3s
/sendkey up up
}
/sendkey up down
/sendkey up Right
/sendkey up Left
/sendkey down up
/return
Last edited by grimjack on Mon May 26, 2003 4:01 am, edited 1 time in total.

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Farming script that does forage too

Post by grimjack » Mon May 26, 2003 3:06 am

NM concept never fleshed out

boldor
a ghoul
a ghoul
Posts: 94
Joined: Tue Sep 10, 2002 11:46 am

Post by boldor » Wed May 28, 2003 1:54 pm

This sorta macro was to pick up ground spawn items. Not sure if the new /click function can handle these sorta of items since there is no hard location of X,Y telling it where to go.

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Post by grimjack » Wed May 28, 2003 6:25 pm

boldor wrote:This sorta macro was to pick up ground spawn items. Not sure if the new /click function can handle these sorta of items since there is no hard location of X,Y telling it where to go.
Currently there is no way I can have it auto pick up. However if you sit with the one I did write it is very easy to pick them up yourself. It won't move on until you do. Even if click was working 100 percent with spawns up trees and such it can be very buggy. The one I said NM about was adding forrage to the same script. It was a request from a friend and we both decided that we had no real need to do both at the same time.

The current script works very well for what it was designed for and that is bringing you right up to the groundspawn where it should be in your field of vision without much adjustment. You can run through a hell of a lot of ground spawns rather fast. I don't see a need for one unassisted for multiple reasons. AFK macroing is very dangerous. And the work that would have to be put into it would be more trouble than it is worth.

Thanks

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Thu May 29, 2003 8:01 am

Interesting... there should be a way to make click work on ground spawns, doors, etc. Maybe we can figure out how to do /click right target or some such. Perhaps using the struct for SPAWNINFO, since that has XY coordinates in it?
MQ2: Think of it as Evolution in action.

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Thu May 29, 2003 8:11 am

Code: Select all

typedef struct _GROUNDITEM {
	/*0x00*/	struct _GROUNDITEM *pPrev;
	/*0x04*/	struct _GROUNDITEM *pNext;
	/*0x08*/	DWORD ID;
	/*0x0c*/	DWORD DropID;
	/*0x10*/	DWORD Unknown0x10;
	/*0x14*/	DWORD DxID;
	/*0x18*/	BYTE Unknown0x18[176];
	/*0xc8*/	DWORD Unknown0xc8;
	/*0xcc*/	FLOAT Heading;
	/*0xd0*/	FLOAT Z;
	/*0xd4*/	FLOAT X;
	/*0xd8*/	FLOAT Y;
	/*0xdc*/	CHAR Name[30];
} GROUNDITEM, *PGROUNDITEM;
Should be possible to use this to come up with a routine to allow clicking on ground targets.
MQ2: Think of it as Evolution in action.

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Post by grimjack » Fri May 30, 2003 1:41 am

Mckorr wrote:

Code: Select all

typedef struct _GROUNDITEM {
	/*0x00*/	struct _GROUNDITEM *pPrev;
	/*0x04*/	struct _GROUNDITEM *pNext;
	/*0x08*/	DWORD ID;
	/*0x0c*/	DWORD DropID;
	/*0x10*/	DWORD Unknown0x10;
	/*0x14*/	DWORD DxID;
	/*0x18*/	BYTE Unknown0x18[176];
	/*0xc8*/	DWORD Unknown0xc8;
	/*0xcc*/	FLOAT Heading;
	/*0xd0*/	FLOAT Z;
	/*0xd4*/	FLOAT X;
	/*0xd8*/	FLOAT Y;
	/*0xdc*/	CHAR Name[30];
} GROUNDITEM, *PGROUNDITEM;
Should be possible to use this to come up with a routine to allow clicking on ground targets.
At one time this was possible. You could /click left item. It would click the last item targeted with /itemtarget as long as it was on your screen. It would be nifty to have this working again but it's not that big of a deal to me. With ground spawns under the ground and up tree's automating these type of pickups does not work well anyhow. Doors on the other hand would be great.

One last thing, how will you get the x/y screen position? Is it one of the unknowns in the structure or can that be figured out by the x/y/z zone location?

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Fri May 30, 2003 9:01 am

Look at the struct above, XYZ are already there.

Code: Select all

GROUNDITEM ItemLoc;
MoveMouse(ItemLoc->X,ItemLoc->Y);
Something to that effect.
MQ2: Think of it as Evolution in action.

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Fri May 30, 2003 9:16 am

You could try this (at work, no compiler, so can't test it). In EQLib_Mouse.cpp, replace

Code: Select all

	//move the mouse to coordinates from above 
	ClickX = (atoi(ButtonX) + XMLloc.x + (int)(XMLloc.w/2)); 
	ClickY = (atoi(ButtonY) + XMLloc.y + (int)(XMLloc.h/2) - Adjust_y); 
	MoveMouse(ClickX, ClickY);
With

Code: Select all

PGROUNDITEM ItemLoc;
if (!strnicmp(szArg1,"item",4)) {
   ClickX=ItemLoc->X;
   ClickY=ItemLoc->Y;
} else {
   ClickX = (atoi(ButtonX) + XMLloc.x + (int)(XMLloc.w/2)); 
   ClickY = (atoi(ButtonY) + XMLloc.y + (int)(XMLloc.h/2) - Adjust_y);
   }
MoveMouse(ClickX, ClickY);
Off the top of my head, and completely untested, but might let you click on an item you have targeted with /itemtarget.
MQ2: Think of it as Evolution in action.

User avatar
Stargazer
a lesser mummy
a lesser mummy
Posts: 32
Joined: Mon Sep 30, 2002 3:30 pm

Post by Stargazer » Fri May 30, 2003 10:52 am

I think that the big problem here is converting your x,y,z spatial coordinates into real mouse coordinates on the screen. That will all depend on which perspective, camara angle, zoom, etc that you are using. I think that is why originally when Plaz implemented "/click left item" that he had to examinine each pixel on the screen to make it work. There may be a way if you are looking from the directly above perspective and you are in the center of the screen that you could get your x,y spatial coords and then calculate what the x,y mouse location of the item might be on the screen, but I am not sure that would be very accurate either. I may give this a try and see if I can make it work.
Cromwell Stargazer

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Fri May 30, 2003 11:28 am

I see what you mean. Yeah, the struct probably contains the loc of the item, and you'd have to go to that loc, then find the item on the screen, then click on it. Okay, disregard bogus code above.
MQ2: Think of it as Evolution in action.

Shark
a lesser mummy
a lesser mummy
Posts: 47
Joined: Wed May 21, 2003 12:23 pm

Post by Shark » Fri May 30, 2003 5:04 pm

Agreed, viewport and such would muck that up real bad. Also in as far as changing code at that spot in mouse.cpp it would never get there. The code would report and error and quit before it reached it.

If you knew which view you were using and what the appropriate offsets were you could do a simple mouse walking around a target area using a series of explicit location clicks. Just make sure there is nothing on the cursor and nothing open or covering the area where you are going to be looking.

That could get a little intensive but would only need to use it when you actually arrived at the item to pick up.

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Fri May 30, 2003 7:11 pm

lol Hey, I wrote that section of code. It would get there, it would just mess things up bad.

MoveMouse is only called in two places, once for simple XY coordinates and once for everything else. Pretty much anything you insert just before MoveMouse is called at the end of ParseMouseLoc is guaranteed to get noticed... it just might screw things up and crash you to desktop. Probably would screw things up and crash you to desktop.
MQ2: Think of it as Evolution in action.