Loot Nearest Corpse

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot. MQ2Data format only!

Moderator: MacroQuest Developers

EQBot_man
a ghoul
a ghoul
Posts: 111
Joined: Mon May 17, 2004 6:35 pm

Loot Nearest Corpse

Post by EQBot_man » Mon Jul 26, 2004 10:12 pm

So I found no reliable corpse looting subroutine. So I wrote my own for two different circumstances. I've tested these a lot so they work pretty well.

This first one will take a string input and will loot the entire corpse and search for that item. I used this while camping for the shrink wand in the deep. This subroutine has been tweaked and played with over and over again for reliable looting in real EQ circumstances(a mob aggroing you while looting, it fucking up and you never standing up, and possibly dying from that, etc).

This subroutine will target the nearest corpse. Then if it the corpse less than 120feet away it will move to it reliably and loot it. IF its more than 120 it will return(so you don't run off all crazy and die). Also if an item is worth 5pp or more, or has a tribute value of 500 or more it will keep it. If you don't finish looting the corpse within 7seconds of the subroutine being called you will stand up just in case you are stuck. In my main programs I call the subroutine twice in a row. I've found while camping for things somethign would aggro and my macro wouldn't finish looting the corpse. Just call it twice in a row and you should be fine, but like anything try it out first to see if you need to change any of the code. You can call another routine to camp you out after you find what you want or whatever. Add the /call function where you see: |/call FindWand, left over from when I found my wand:

/call LootMob "Wand of"
/call LootMob "Wand of"


8.10.2004 - I realized I had posted my includes verbatim. I use /mqgoto instead of the regular /goto. I changed it should work fine now

Code: Select all

sub LootMob(Loot)
| Note: the number 4.3 in the /varset MoveDelay was empirically
|	set for IRS5 ( Speed = 150 )
/declare MoveDelay int local
/declare LootSlot int local 1

/keypress ESC
/keypress ESC
/keypress ESC
/keypress ESC
/timed 150 /stand
/timed 155	 /notify LootWnd DoneButton leftmouseup
:Top

    /target npc corpse
    /delay 2
    	/if (${Target.Distance}<15) {
        		/face fast
	} else /if (${Target.Distance}>=15 && ${Target.Distance}<120) {
        	/face fast
        	/keypress forward hold
		/varset MoveDelay ${Math.Calc[(${Target.Distance})/4.3]}
		    	/keypress forward hold
		    	/delay ${MoveDelay}
		/keypress forward
		/goto :Top
    	} else {
    		/echo Corpse is too far away
    		/keypress ESC
    		/return
    	}

	/echo Looking for "${Loot}"
    :LootWnd
    /loot

    /if (!${Window[LootWnd].Open}) /goto :LootWnd
   :lootloop
	/if (${Me.State.Equal["STAND"]}) /goto :doneloot
   /if (${Corpse.Items}==0) {
      	/goto :doneloot
   }

   /if (${LootSlot}>=32) /goto :doneloot

   :Loot
   /itemnotify Loot${LootSlot} leftmouseup
   /delay 1s

   	/if (${Window[ConfirmationDialogBox].Open}) {
   		/notify ConfirmationDialogBox Yes_Button leftmouseup
   		/delay 1s
   	}

   /if (${String[${Cursor.Name}].Find[${Loot}]}) {
   	    /echo YOU WIN: ${Cursor.Name}
	    /autoinv
	    /delay 2
	    |/call FindWand

   } else {
	/if (${Cursor.Value}>5000 || ${Cursor.Tribute}>500) {
		/echo ${Cursor.Name} is worth more than 5pp or tribute is greater than 500
   	  	/autoinv
   	  	/delay 5
   	} else {
		/echo Destroying ${Cursor}
		/destroy
		/delay 5
   	}
   }

   /varcalc LootSlot ${LootSlot}+1
   /goto :lootloop
   :doneloot
   /notify LootWnd DoneButton leftmouseup
   /varset LootSlot 0
/return
This next one Will just loot everything in a 120 unit range:

Code: Select all

sub Lootnpc
| Note: the number 4.3 in the /varset MoveDelay was empirically
|	set for IRS5 ( Speed = 150 )
/declare MoveDelay int local
/declare LootSlot int local 1

/keypress ESC
/keypress ESC
/keypress ESC
/keypress ESC
/timed 70 /stand
/timed 75 /notify LootWnd DoneButton leftmouseup

:Top

    /target corpse
    /delay 2
    	/if (${Target.Distance}<15) {
	        		/face fast
		} else /if (${Target.Distance}>=15 && ${Target.Distance}<120) {
	        	/face fast
	        	/keypress forward hold
			/varset MoveDelay ${Math.Calc[(${Target.Distance})/4.3]}
			    	/keypress forward hold
			    	/delay ${MoveDelay}
			/keypress forward
			/goto :Top
	    	} else {
	    		/echo Corpse is too far away
	    		/keypress ESC
	    		/return
    	}

    :LootWnd
    /loot
    /delay 1
    /if (!${Window[LootWnd].Open}) /goto :LootWnd
   :lootloop

	/if (${Me.State.Equal["STAND"]}) /goto :doneloot

   /if (${Corpse.Items}==0) {
      	/goto :doneloot
   }

   /if (${LootSlot}>=32) /goto :doneloot

   :Loot
   /itemnotify Loot${LootSlot} leftmouseup
   /delay 1s

   	/if (${Window[ConfirmationDialogBox].Open}) {
   		/notify ConfirmationDialogBox Yes_Button leftmouseup
   		/delay 1s
   	}

	    /autoinventory
	    /delay 2

   /varcalc LootSlot ${LootSlot}+1
   /goto :lootloop
   :doneloot
   /notify LootWnd DoneButton leftmouseup
   /varset LootSlot 0
Last edited by EQBot_man on Mon Aug 09, 2004 9:57 am, edited 4 times in total.

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Mon Jul 26, 2004 10:18 pm

Can simply add in:

Code: Select all

/if (${Target.Name}==(${Me.Name}'s corpse)) /endmacro
or something of that nature.

fantum409
a ghoul
a ghoul
Posts: 141
Joined: Fri Nov 14, 2003 10:03 pm

Post by fantum409 » Tue Aug 03, 2004 6:02 am

OMG pure evil. You fall and die near bind point while SOK... you wake up perma-naked. heh.

Drumstix42 has a good idea there

Code: Select all

/if (${String[${Target.Name}].Equal[${Me.Name}'s corpse]}) /endmacro

Chill
Contributing Member
Contributing Member
Posts: 435
Joined: Fri May 07, 2004 5:06 pm
Location: Erie, PA

Check before looting

Post by Chill » Sat Aug 07, 2004 10:15 pm

I suggest checking the item to see if its something you want to loot BEFORE looting. Unless you are killing a lot of mobs in exactly the same spot or NEED to keep your camp tidey for some other reason, it would be faster and avoids destroying items.

EQBot_man
a ghoul
a ghoul
Posts: 111
Joined: Mon May 17, 2004 6:35 pm

Post by EQBot_man » Sat Aug 07, 2004 11:02 pm

I changed my final post to reflect my final subroutines after lots of testing. Feel free to look at them and use them as you wand

loadingpleasewait
a snow griffon
a snow griffon
Posts: 332
Joined: Sat Sep 14, 2002 8:46 am

Re: Check before looting

Post by loadingpleasewait » Sat Aug 07, 2004 11:13 pm

Chill wrote:I suggest checking the item to see if its something you want to loot BEFORE looting. Unless you are killing a lot of mobs in exactly the same spot or NEED to keep your camp tidey for some other reason, it would be faster and avoids destroying items.
If you left a corpse there, would it not just keep trying to loot the same corpse over and over again? I think it would..
LOADING PLEASE WAIT...

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Sun Aug 08, 2004 12:18 am

you'd have to get into ID Checking I'm guessing if you wanted to go that route.

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 » Sun Aug 08, 2004 10:22 am

Don't use Target.Name, use Target.CleanName. Or change what it compares to.

EQBot_man
a ghoul
a ghoul
Posts: 111
Joined: Mon May 17, 2004 6:35 pm

application?

Post by EQBot_man » Mon Aug 09, 2004 2:07 am

I wrote these loot corpse sub routines to help me farm Spider silks, Bone Chips, and the Wand of Imperciptibility. The lootnpc(Loot) subroutine is for doing just that...looking for an exact item that you want and estroying the rest. If you are doing automated unattended farming of one item, this is what you want. Not sure of the application you are using it for but it works to loot a mob of a specific farming item

Shenlon
a ghoul
a ghoul
Posts: 103
Joined: Fri Jul 30, 2004 8:02 am

Post by Shenlon » Fri Sep 10, 2004 8:27 am

EQBot_man, I have used your loot macro in one of my own macros and for the vast majority of the time, it works perfectly. However, every now and then I will get stuck with no target and in the /loot loop. So all I get is tons and tons of spam saying that I must first target a corpse to loot. After running this macro for a week or so on and off I believe I have only gotten in 3 or 4 times, so it has been difficult to pin down what happens to throw your code off like that. Anyways, I just added a small line right above /loot.

Code: Select all

/if (${Target}==NULL) /return
Don't know if you have had that problem or not, just thought I might point out what I did to fix it in case anyone else had the problem.


***EDIT***
Nevermind, ran into an error with this method, hope no one used it in a macro yet.

wolfbaby
a lesser mummy
a lesser mummy
Posts: 45
Joined: Mon Sep 06, 2004 5:34 am

Post by wolfbaby » Mon Sep 13, 2004 10:12 am

if you make a ini file to let the mq2 know what to loot ,that will be better

twisted82
decaying skeleton
decaying skeleton
Posts: 7
Joined: Tue Mar 23, 2004 5:52 pm

Post by twisted82 » Sun Oct 24, 2004 12:17 pm

Getting error,

Code: Select all

/Varset failed, variable 'MoveDelay' not found
(Lootnpc):  /varset MoveDelay ${Math.Calc[(${Target.Distance})/4.3]} 
Im still learning commands, but the /variable is stated.


First thing, yes - I have /declare MoveDelay int local ..

Any suggestions as to WTF is going on ? ..


-Edit-
I've solved my own problem, I had moved the /declare MoveDelay int local out of the sub, without changing the local to outer. Like I said, I'm new to this ..

Now, how to figure out the run speed of jboots: 4.3=IRS5 sigh ..


-Twisted82-
Im just a noob, trying to get a nut.

Dark_Lord_X
orc pawn
orc pawn
Posts: 16
Joined: Fri Oct 01, 2004 5:42 pm

Post by Dark_Lord_X » Sun Oct 24, 2004 3:38 pm

Jboots = 135

DeeGee
a ghoul
a ghoul
Posts: 116
Joined: Wed Sep 22, 2004 4:51 pm

Post by DeeGee » Mon Nov 15, 2004 10:09 am

Shenlon wrote:

Code: Select all

/if (${Target}==NULL) /return
Don't know if you have had that problem or not, just thought I might point out what I did to fix it in case anyone else had the problem.


***EDIT***
Nevermind, ran into an error with this method, hope no one used it in a macro yet.
I had the same issues as you. What I did was add this to all loops.

Code: Select all

/if (!${Target.ID}) /goto :doneloot

mrwhionyx
decaying skeleton
decaying skeleton
Posts: 2
Joined: Thu Apr 12, 2007 5:27 am

First Item

Post by mrwhionyx » Sun Jun 17, 2007 8:03 pm

I'm having issues with the 2nd macro post of looting all npc corpse's in the area around me. It only seems loot the first item then ends the macro. Now I know I'm new to this, But I have looked it over and I can't see the code that would be stopping this.