If the corpse has loot, it'll take you to it and begin looting, using the "You have looted.." messages to tell it whether it should continue looting. If it doesn't get a loot message, it stops looting and ends the subroutine.
$v90 is the saved target ID of the mob you just killed. You will want to make sure you save the ID of the mob you are killing, at a point somewhere in your attack code, so that it targets the correct corpse when it's dead.
You may need to increase/decrease the delays depending on your lag conditions.
Code: Select all
#Event CorpseTime "This corpse will decay in 0"
#Event Looted "--You have looted a "
Sub AutoLoot
/press esc
/target id $v90
/con
/delay 5
/doevents
/if n $v4==1 /goto :Continue
/if n $target(distance)<15 /goto :LootCorpse
/sendkey down up
:FaceCorpse
/delay 0
/face
/if n $target(distance)>14 /goto :FaceCorpse
:LootCorpse
/sendkey up up
/loot
/delay 10
/varset v3 0
:Looting
/delay 0
/varset v5 $v3
/click right corpse $v3
/delay 5
/doevents
/if n $v3>$v5 /goto :Looting
/press esc
:Continue
/varset v4 0
/return
Sub Event_CorpseTime
/varset v4 1
/return
Sub Event_Looted
/varadd v3 1
/return
