Page 1 of 1

Loot.mac - Much improved version

Posted: Mon May 03, 2004 10:41 am
by Gameross
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

Posted: Mon May 03, 2004 12:12 pm
by fice
you should use the code tags!

Posted: Mon May 03, 2004 12:23 pm
by Preocts
--------- 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.

Thanks for filling me in.

Posted: Mon May 03, 2004 4:35 pm
by Gameross
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?

Posted: Mon May 03, 2004 9:04 pm
by Yalp
looks like it should work, and thanks for updating and posting a corpse loot macro :) now i dont have to convert mine

Posted: Mon May 03, 2004 10:26 pm
by ieatacid
Works fine so far. Thanks.

Posted: Thu May 06, 2004 8:05 pm
by Yalp
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"

Posted: Thu May 06, 2004 8:32 pm
by ieatacid
Custom UI? Maybe the DoneButton is named something else.

Posted: Thu May 06, 2004 8:38 pm
by Dulapore
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.

Posted: Thu May 06, 2004 9:00 pm
by Yalp
yes i do have a custom UI, checking into it.

Posted: Thu May 06, 2004 10:37 pm
by Yalp
camping out worked, which i dont really understand lol, but hey it works right?

Posted: Thu May 06, 2004 10:52 pm
by Dulapore
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.

Posted: Fri May 07, 2004 12:03 am
by Yalp
ahh ok :) thanks for the epxlanation