Loot.mac - Much improved version

Post your completed (working) macros here. Only for macros using MQ2Data syntax!

Moderator: MacroQuest Developers

Gameross
a lesser mummy
a lesser mummy
Posts: 46
Joined: Mon May 03, 2004 10:11 am

Loot.mac - Much improved version

Post by Gameross » Mon May 03, 2004 10:41 am

This is my first macro of any consequence based on Bob the Builders Loot.mac macro but with a lot of added code to smooth looting out and account for lag/etc.

Improvements made:

1. Commented the code
2. Make sure ya have your corpse targetted before trying to loot.
3. If corpse can't be summoned close enough to loot, abort looting and face your corpse.
4. Try to get a accurate corpse item count to do all looting at one time. Should help in laggy enviroments a lot.
5. Give an error if trying to leave more items on the corpse than there are items.
6. Won't accidently loot last item unless /mac loot 0 is specified.
7. Will now loot items the first time around even with lag and pretty fast once looting begins.
8. Added code tags now that I know how. See! I'm learning!

Updated 05/07/04
1. Mostly cleanup and implimentations of things a little differently using new things I've learned.
2. Now checks for your corpse by name.
3. If a corpse was completely empty, it won't come off it so you have a chance to get a resurrection before ya pop off it automatically.
4. You can now set LootingLag to the # of seconds to wait between item count updates to make sure you're getting all items in 1 looting.

Code: Select all

| Revision Date: 05/07/04  Time: 5:33am cst

#Event CorpseTooFar "The corpse is too far away to summon." 

Sub main 
/declare LootTotal int -1
/declare LootSlot int 
/declare LootLeft int ${Param0}
/declare Loop int
/declare CorpseName string ${Me.Name}'s corpse

| Some extra lag compensation for EQWing multiple toons (Like me) so looting is more reliable in the background.
| Set LootingLag to the number of seconds to wait for updates to the Loot Total count before assuming all loot accounted for.
/declare LootingLag int 3

| Check number items to be left on corpse specified.  If not, default to 1 and explain parameter. 
/if (!${Defined[Param0]}) { 
	/varset LootLeft 1 
	/echo Using default LootLeft of ${LootLeft} 
	/call MacroParams
}

| Get corpse on target and continue if able to target your corpse. 
/target mycorpse
/if (${CorpseName.NotEqual[${Target.CleanName}]}) {
	/popup Unable to target your corpse.
	/echo Unable to target your corpse.
	/endmacro
}
	
:PullCorpseClose
/corpse
/loot
/delay 1s
/doevents
/if (${Me.State.NotEqual[BIND]}) /goto :PullCorpseClose

| Try to get a accurate corpse item count to do all looting at one time.
:LootLag
/delay 1s
/if (${LootTotal}!=${Corpse.Items}) { 
	/varset LootTotal ${Corpse.Items}
	/varset Loop 0
	/goto :LootLag
} else {
/varcalc Loop ${Loop}+1
/if (${Loop}<${LootingLag}) /goto :LootLag
}

| Just some extra safety.
/if (${LootTotal}==0) {
	/popup This corpse appears to be empty.
	/echo This corpse appears to be empty.  If it needs a resurrection, ya better hurry before ya automatically come off the corpse.
	/endmacro
}

| Make sure not to loot to much/completely accidently.
/if (${LootTotal}<=${LootLeft}) {
	/popup Looting aborted.  Error in number items to be left on corpse.  Found ${LootTotal} lootable item(s)
	/echo Looting aborted.  Error in number items to be left on corpse.  Found ${LootTotal} lootable item(s)
	/call MacroParams
	/notify LootWnd DoneButton leftmouseup
	/endmacro
}

| Set the number of items to actually loot leaving LootLeft number items on the corpse.
/varset LootTotal ${Math.Calc[${Corpse.Items}-${LootLeft}]} 

/popup Looting all but ${LootLeft} item(s) 

|Main Looting Loop
/for LootSlot 1 to ${LootTotal} 

| Loot all items fast the first time around even with connection lag or the lag when looting bags.
:LootItem
/itemnotify loot${LootSlot} rightmouseup
/delay ${LootingLag}
/if (${Corpse.Item[${LootSlot}].ID}==NULL) {
	/next LootSlot
} else {
	/delay ${LootingLag}
	/goto :LootItem
}

:DoneLooting
/notify LootWnd DoneButton leftmouseup 
/popup Done looting.  ${LootLeft} Item(s) left on your corpse.
/echo Done looting.  ${LootLeft} Item(s) left on your corpse.
/endmacro 

Sub MacroParams
/echo Useage: /mac loot <# items to leave on corpse> 
/echo Useage: /mac loot 0 <Loots all items> 
/return

Sub Event_CorpseTooFar
/echo Corpse to far away to summon.  Macro Ending.
/popup Corpse to far away to summon.
/face
/endmacro
Last edited by Gameross on Tue May 11, 2004 5:44 am, edited 2 times in total.

User avatar
fice
a hill giant
a hill giant
Posts: 187
Joined: Thu Jul 17, 2003 3:28 pm

Post by fice » Mon May 03, 2004 12:12 pm

you should use the code tags!

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

Post by Preocts » Mon May 03, 2004 12:23 pm

--------- CUT HERE ---------
:shock: OMG flashback to the UUencoded days of news groups. Well, before programs did the encoding and decoding for ya anyway.

But on a serious note I fully agree that you need to put that in code tags.

Gameross
a lesser mummy
a lesser mummy
Posts: 46
Joined: Mon May 03, 2004 10:11 am

Thanks for filling me in.

Post by Gameross » Mon May 03, 2004 4:35 pm

Thanks for filling me in guys. I truely am a novice here.

So, beyond my ignorance of how to post this code, how's it working for you guys?

Yalp
a ghoul
a ghoul
Posts: 90
Joined: Thu Dec 05, 2002 6:28 pm

Post by Yalp » Mon May 03, 2004 9:04 pm

looks like it should work, and thanks for updating and posting a corpse loot macro :) now i dont have to convert mine
Because i wouldn't have it any other way

User avatar
ieatacid
Developer
Developer
Posts: 2727
Joined: Wed Sep 03, 2003 7:44 pm

Post by ieatacid » Mon May 03, 2004 10:26 pm

Works fine so far. Thanks.

Yalp
a ghoul
a ghoul
Posts: 90
Joined: Thu Dec 05, 2002 6:28 pm

Post by Yalp » Thu May 06, 2004 8:05 pm

macro is failing on line 73

Code: Select all

/notify LootWnd DoneButton leftmouseup 
error is
"Window 'LootWnd' not available."
"Could not send notification to LootWnd DoneButton"
Because i wouldn't have it any other way

User avatar
ieatacid
Developer
Developer
Posts: 2727
Joined: Wed Sep 03, 2003 7:44 pm

Post by ieatacid » Thu May 06, 2004 8:32 pm

Custom UI? Maybe the DoneButton is named something else.

Dulapore
a lesser mummy
a lesser mummy
Posts: 67
Joined: Thu Feb 26, 2004 4:39 am

Post by Dulapore » Thu May 06, 2004 8:38 pm

Yalp. Camp and come back, or type /loadskin uiname 1. Then try it again. If that's it, just make sure to load MQ before you login.

Yalp
a ghoul
a ghoul
Posts: 90
Joined: Thu Dec 05, 2002 6:28 pm

Post by Yalp » Thu May 06, 2004 9:00 pm

yes i do have a custom UI, checking into it.
Because i wouldn't have it any other way

Yalp
a ghoul
a ghoul
Posts: 90
Joined: Thu Dec 05, 2002 6:28 pm

Post by Yalp » Thu May 06, 2004 10:37 pm

camping out worked, which i dont really understand lol, but hey it works right?
Because i wouldn't have it any other way

Dulapore
a lesser mummy
a lesser mummy
Posts: 67
Joined: Thu Feb 26, 2004 4:39 am

Post by Dulapore » Thu May 06, 2004 10:52 pm

Lax has explained it a few times here and there. MQ doesn't get the list of windows unless it watches them get initialized at load time, or when you do a /loadskin.

Yalp
a ghoul
a ghoul
Posts: 90
Joined: Thu Dec 05, 2002 6:28 pm

Post by Yalp » Fri May 07, 2004 12:03 am

ahh ok :) thanks for the epxlanation
Because i wouldn't have it any other way