#Event CorpseTooFar "The corpse is too far away to summon."
Sub main
/declare LootTotal int
/declare LootSlot int
/declare LootLeft int
/varset LootLeft ${Param0}
| Check number items to be left on corpse specified. If not, default to 1 and explain parameter.
/if (!${Defined[Param0]}) {
/varset LootLeft 1
/echo Useage: /mac loot <# items to leave on corpse>
/echo Useage: /mac loot 0 <Loots all items>
/echo Using default LootLeft of ${LootLeft}
}
| Get corpse on target and continue if able to target your corpse.
/target mycorpse
/if (${Target.Type.NotEqual[CORPSE]} || !${Target.ID}) {
/echo Unable to target your corpse.
/endmacro
}
:PullCorpseClose
/sumcorpse
/doevents
/loot
/delay 1s
/if (${Me.State.NotEqual[BIND]}) { /goto :PullCorpseClose }
/varset LootTotal 0
| Try to get a accurate corpse item count to do all looting at one time.
:LootLag
/if (${LootTotal}!=${Corpse.Items}) {
/varset LootTotal ${Corpse.Items}
/delay 1s
/goto :LootLag
}
| Make sure not to loot to much/completely accidently.
/if (${LootTotal}<=${LootLeft}) {
/echo Looting aborted. Error in number items to be left on corpse.
/echo Do: /mac loot 0 To completely loot your corpse
/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}]}
|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 5
/if (${Corpse.Item[${LootSlot}].ID}==NULL) {
/next LootSlot
} else {
/delay 5
/goto :LootItem
}
:DoneLooting
/notify LootWnd DoneButton leftmouseup
/echo Done looting. ${LootLeft} Item(s) left on your corpse.
/endmacro
Sub Event_CorpseTooFar
/echo Corpse to far away to summon. Macro Ending.
/face
/endmacro