Loot & Sell helper

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

Moderator: MacroQuest Developers

anon_coward
a lesser mummy
a lesser mummy
Posts: 40
Joined: Wed Mar 24, 2004 11:11 pm

Loot & Sell helper

Post by anon_coward » Thu Oct 14, 2004 5:56 pm

So I got a little time this morning to check my last minute changes, and everything looks like it's working. Enjoy :)

Edit: Also to warn you, there are quite a few /echo commands throughout the macro, It generates quite a bit of spam, but it's helpful to me to know what's it doing.

Code: Select all

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| Author: anon_coward
|
| Initial release: 10/14/04
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| Description: 
| This macro helps with looting and selling.  There are 2 main parts, looting
| and selling.  The looting code is run once you open a corpse.  Once you click
| the corpse open it automatically empties the corpse and adds the items to the
| INI file.  Then later when you open a merchant, it will automatically sell
| items that are in the INI file.
|
| Each item has an entry in the INI file with one of 4 numbers which mean:
| KEEP, DESTROY, LEAVE, or SELL.  Items with the KEEP setting are automatically
| looted, and skipped during the selling part.  The DESTROY setting picks the
| item up off the corpse and it is immediately destroyed.  Use with CAUTION.
| This is great for LDON collect missions.  Setting an item to LEAVE means the
| next time it won't pick it up so it stays on the corpse.  And finally SELL is
| the magic setting to have it both autolooted and autosold.
|
| There is a special check for ${Me.Name} when looting so if you open your own
| corpse, the INI is ignored and every item should just be looted.  WARNING:
| MAKE SURE YOU ALREADY GOT YOUR REZ.
|
| Finally, you can turn it on and off by using '/echo SET PAUSED' to toggle.
| The same command pauses and resumes the macro.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| Here are the command it expects:
| Print settings about an item or your inventory with:
| ... /echo SHOW LOOT   - display current setting for the item on cursor
| ... /echo SHOW SELL   - list all inventory items marked to sell
|
| With an item on the cursor, you change settings with
| ... /echo SET KEEP    - just loot this item into inventory
| ... /echo SET DESTROY - take off the corpse and /destroy it
| ... /echo SET LEAVE   - just leave it on the corpse
| ... /echo SET SELL    - put it in inventory and autosell at the next vendor
|
| And finally, to turn it on and off
| ... /echo SET PAUSED  - toggle it on/off with the same command
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

#Event Print "[MQ2] PRINT #1#"
#Event Print "[MQ2] SHOW #1#"
#Event Set   "[MQ2] SET #1#"
#Event Help  "[MQ2] HELP #1#"
#Event Help  "[MQ2] HELP"

Sub Main

    /echo Loot helper started
    /call Init

    :MainLoop
    /delay 0
    /doevents
    /if (${PAUSED}) /goto :MainLoop
    /if (${Merchant.Open})        /call SellLoot
    /if (${Window[LootWnd].Open}) /call LootCorpse
    /goto :MainLoop

/endmacro

Sub Init

    /if (!${Defined[PAUSED]}) /declare PAUSED bool outer FALSE

    |A few constants for handling loot
    /if (!${Defined[LOOT_KEEP]})     /declare LOOT_KEEP     int    outer 1
    /if (!${Defined[LOOT_DESTROY]})  /declare LOOT_DESTROY  int    outer 2
    /if (!${Defined[LOOT_LEAVE]})    /declare LOOT_LEAVE    int    outer 3
    /if (!${Defined[LOOT_SELL]})     /declare LOOT_SELL     int    outer 4

    |A table for mapping numbers to strings for printing
    /if (!${Defined[LOOT_SETTINGS]}) /declare LOOT_SETTINGS[4] string outer
    /varset LOOT_SETTINGS[${LOOT_KEEP}]    KEEP
    /varset LOOT_SETTINGS[${LOOT_DESTROY}] DESTROY
    /varset LOOT_SETTINGS[${LOOT_LEAVE}]   LEAVE
    /varset LOOT_SETTINGS[${LOOT_SELL}]    SELL

    |Default values for specific types of loot
    /if (!${Defined[LOOT_DEFAULT]})  /declare LOOT_DEFAULT  int    outer ${LOOT_SELL}
    /if (!${Defined[LOOT_NO_DROP]})  /declare LOOT_NO_DROP  int    outer ${LOOT_LEAVE}

    /echo Droppable loot defaults to .. ${LOOT_SETTINGS[${LOOT_DEFAULT}]}
    /echo No Drop loot defaults to .... ${LOOT_SETTINGS[${LOOT_NO_DROP}]}

/return

Sub LootCorpse

    /delay 1s
    /declare total int local ${Corpse.Items}

    /if (!${total}) /goto :DoneLooting

    /declare WATCHDOG     timer local
    /declare not_found    int   local -1
    /declare item_setting int   local
    /declare slot         int   local
    /for slot 1 to ${total}

        /varset WATCHDOG 5s
        :ClearCursor
        /delay 0
        /doevents
        /if (!${WATCHDOG}) {
            /echo Item stuck on the cursor. Abort!
            /goto :DoneLooting
        }
        /if (${Cursor.ID}) {
            /autoinventory
            /delay 5
            /goto :ClearCursor
        }

        /varset item_setting ${Ini[Loot.ini,Loot,${Corpse.Item[${slot}].Name},${not_found}]}

        | If the item isn't in the .ini file then add it.
        /if (${item_setting}==${not_found}) {
            /varset item_setting ${LOOT_DEFAULT}
            /if (${Corpse.Item[${slot}].NoDrop}) {
                /varset item_setting ${LOOT_NO_DROP}
            }

            /echo Adding to INI "${Corpse.Item[${slot}].Name}" (${LOOT_SETTINGS[${item_setting}]})
            /ini Loot.ini Loot "${Corpse.Item[${slot}].Name}" ${item_setting}
        }

        /if (${item_setting}==${LOOT_DESTROY} && !${Corpse.Name.Find[${Me}]}) {
            /echo -- You destroyed a <<${Corpse.Item[${slot}].Name}>>.-- (${LOOT_SETTINGS[${item_setting}]})
            /itemnotify loot${slot} leftmouseup 
            /delay 5
            /if (${Window[ConfirmationDialogBox].Open}) {
                /notify ConfirmationDialogBox Yes_Button leftmouseup
                /delay 5
            }
            /if (${Cursor.ID}) {
                /destroy
                /delay 5
            } else {
                /echo Uh oh, DESTROY item didn't show up on Cursor
            }

        } else /if (${item_setting}==${LOOT_KEEP} || ${item_setting}==${LOOT_SELL} || ${Corpse.Name.Find[${Me}]}) {
            /echo -- You have looted a <<${Corpse.Item[${slot}]}>>.-- (${LOOT_SETTINGS[${item_setting}]})
            /itemnotify loot${slot} rightmouseup 
            /delay 5
            /if (${Window[ConfirmationDialogBox].Open}) {
                /notify ConfirmationDialogBox Yes_Button leftmouseup
                /delay 5
            }

        } else /if (${item_setting}==${LOOT_LEAVE}) {
            /echo -- You left a <<${Corpse.Item[${slot}]}>>.-- (${LOOT_SETTINGS[${item_setting}]})

        } else {
            /echo Umm, something is wrong in the loot code
            /echo I don't know what to do with ${Corpse.Item[${slot}]}
            /echo I guess I'll just leave it there ><
        }
    /next slot

    :DoneLooting
    /notify LootWnd DoneButton leftmouseup
    /delay 5

/return

Sub SellLoot(bool JUST_PRINT)

    /if (!${Defined[JUST_PRINT]}) /declare JUST_PRINT bool local FALSE
    /if (${Merchant.Open} && !${JUST_PRINT}) {
        /declare i int local
        /for i 10 downto 1
            /popup AUTO SELLING in ${i} sec
            /delay 1s
            /if (!${Merchant.Open}) /return
        /next i
    }

    /declare plat   int local ${Me.Platinum}
    /declare gold   int local ${Me.Gold}
    /declare silver int local ${Me.Silver}
    /declare copper int local ${Me.Copper}

    /declare not_found    int local -1
    /declare item_setting int local
    /declare slot         int local
    /declare spot         int local
    /for slot 1 to 8
        /if (${InvSlot[pack${slot}].Item.Container}) {
            /for spot 1 to ${InvSlot[pack${slot}].Item.Container}
                /if (!${InvSlot[pack${slot}].Item.Item[${spot}].ID}) /goto :NextSpot
                /varset item_setting ${Ini[wizard.ini,Loot,${InvSlot[pack${slot}].Item.Item[${spot}]},${not_found}]}

                /if (${item_setting}==${not_found}) {
                    /echo Dunno what to do with ${InvSlot[pack${slot}].Item.Item[${spot}]} pack${slot} slot${spot}

                } else /if (${item_setting}==${LOOT_KEEP}) {
                    /goto :NextSpot

                } else /if (${item_setting}==${LOOT_DESTROY}) {
                    /echo Should have DESTROYED ${InvSlot[pack${slot}].Item.Item[${spot}]} pack${slot} slot${spot}

                } else /if (${item_setting}==${LOOT_LEAVE}) {
                    /echo Should have LEFT ${InvSlot[pack${slot}].Item.Item[${spot}]} pack${slot} slot${spot}

                } else /if (${item_setting}==${LOOT_SELL}) {
                    /echo Selling ${InvSlot[pack${slot}].Item.Item[${spot}]}
                    /if (${JUST_PRINT}) /goto :NextSpot

                    /if (!${Window[InventoryWindow].Open}) /nomodkey /keypress inventory
                    /delay 5
                    /if (!${Window[pack${slot}].Open}) /nomodkey /itemnotify pack${slot} rightmouseup
                    /delay 5
                    /nomodkey /itemnotify ${InvSlot[pack${slot}].Item.Item[${spot}].InvSlot} leftmouseup
                    /delay 5
                    /nomodkey /shift /notify MerchantWnd MW_Sell_Button leftmouseup
                    /delay 5

                } else {
                    /echo Bogus item setting: ${InvSlot[pack${slot}].Item.Item[${spot}]} => ${item_setting}
                }
            :NextSpot
            /next spot

            /if (${Window[pack${slot}].Open}) /nomodkey /itemnotify pack${slot} rightmouseup
            /delay 1s

        } else {
            /if (!${InvSlot[pack${slot}].Item.ID}) /goto :NextSlot
            /varset item_setting ${Ini[wizard.ini,Loot,${InvSlot[pack${slot}].Item},${not_found}]} slot${slot}

            /if (${item_setting}==${not_found}) {
                /echo Dunno what to do with ${InvSlot[pack${slot}].Item} slot${slot}

            } else /if (${item_setting}==${LOOT_KEEP}) {
                /goto :NextSlot

            } else /if (${item_setting}==${LOOT_DESTROY}) {
                /echo Should have DESTROYED ${InvSlot[pack${slot}].Item} slot${slot}

            } else /if (${item_setting}==${LOOT_LEAVE}) {
                /echo Should have LEFT ${InvSlot[pack${slot}].Item} slot${slot}

            } else /if (${item_setting}==${LOOT_SELL}) {
                /echo Selling ${InvSlot[pack${slot}].Item}
                /if (${JUST_PRINT}) /goto :NextSlot

                /if (!${Window[InventoryWindow].Open}) /nomodkey /keypress inventory
                /delay 5
                /nomodkey /itemnotify pack${slot} leftmouseup
                /delay 5
                /nomodkey /shift /notify MerchantWnd MW_Sell_Button leftmouseup
                /delay 5

             } else {
                /echo Bogus item setting: ${InvSlot[pack${slot}].Item} => ${item_setting}
             }
        }
    :NextSlot
    /next slot

    /varcalc plat   ${Me.Platinum}-${plat}
    /varcalc gold   ${Me.Gold}-${gold}
    /varcalc silver ${Me.Silver}-${silver}
    /varcalc copper ${Me.Copper}-${copper}

    /if (${plat} || ${gold} || ${silver} || ${copper}) {
        /echo Made ${plat}pp ${gold}gp ${silver}sp ${copper}cp
    }

    /nomodkey /notify MerchantWnd DoneButton leftmouseup
    /delay 5
    /if (${Window[InventoryWindow].Open}) /nomodkey /keypress inventory
    /delay 5

/return

Sub SetLootPreference(int pref)

    /if (!${Cursor.ID}) {
        /echo Pick up something on your cursor before typing this command
        /return
    }

    /if (!${Defined[pref]}) {
        /declare not_found    int local -1
        /declare item_setting int local ${Ini[Loot.ini,Loot,"${Cursor}",${not_found}]}
        /if (${item_setting}==${not_found}) {
            /echo No entry for ${Cursor}
        } else /if (${item_setting}==${LOOT_KEEP}) {
            /echo Pick up <<${Cursor}>>
        } else /if (${item_setting}==${LOOT_DESTROY}) {
            /echo Pick up & DESTROY <<${Cursor}>>
        } else /if (${item_setting}==${LOOT_LEAVE}) {
            /echo Leave <<${Cursor}>> on corpse
        } else /if (${item_setting}==${LOOT_SELL}) {
            /echo Pick up <<${Cursor}>> (to sell)
        } else {
            /echo Unknown TYPE for Loot <<${Cursor}>>
        }
        /return
    }

    /if (${pref} < 1 || ${pref} > 4) {
        /echo Prefence ID ${pref} out of range.  ERROR processing command
        /return
    }

    /echo Setting preferenc "${Cursor.Name}" => ${LOOT_SETTINGS[${pref}]}
    /ini Loot.ini Loot "${Cursor.Name}" ${pref}
    /if (${pref}==${LOOT_DESTROY}) /destroy

/return

Sub Event_Print(string EventTxt,string CmdName)

    /if (${CmdName.Find[LOOT]}) {
        /call SetLootPreference

    } else /if (${CmdName.Find[SELL]}) {
        /call SellLoot TRUE

    } else {
        /echo Unknown command: ${CmdName}
        /echo for more info type /echo HELP 
    }

/return

Sub Event_Set(string EventTxt,string CmdName)

    /if (${CmdName.Find[SAVE]} || ${CmdName.Find[KEEP]}) {
        /call SetLootPreference ${LOOT_KEEP}

    } else /if (${CmdName.Find[DESTROY]}) {
        /call SetLootPreference ${LOOT_DESTROY}

    } else /if (${CmdName.Find[LEAVE]}) {
        /call SetLootPreference ${LOOT_LEAVE}

    } else /if (${CmdName.Find[SELL]}) {
        /call SetLootPreference ${LOOT_SELL}

    } else /if (${CmdName.Find[PAUSE]}) {
        /if (${PAUSED}) {
            /varset PAUSED FALSE
            /echo ${Macro.Name} is active again
        } else {
            /varset PAUSED TRUE
            /echo ${Macro.Name} is being paused
            /echo type '/echo SET PAUSED' to resume
        }

    } else {
        /echo Unknown command: ${CmdName}
        /echo for more info type /echo HELP 
    }

/return

Sub Event_Help(string EventTxt,string CmdName)

    /if (!${Defined[CmdName]}) {
        /echo Help options are
        /echo ... /echo HELP LOOT

    } else /if (${CmdName.Find[LOOT]}) {
        /echo Loot choices are
        /echo ... /echo SHOW LOOT   - display current setting for the item on cursor
        /echo ... /echo SHOW SELL   - list all inventory items marked to sell
        /echo
        /echo With an item on the cursor, you change settings with
        /echo ... /echo SET KEEP    - just loot this item into inventory
        /echo ... /echo SET DESTROY - take off the corpse and /destroy it
        /echo ... /echo SET LEAVE   - just leave it on the corpse
        /echo ... /echo SET SELL    - put it in inventory and autosell at the next vendor
        /echo
        /echo And finally, to turn it on and off
        /echo ... /echo SET PAUSED  - toggle it on/off with the same command
        /echo
        /echo Droppable loot defaults to .. ${LOOT_SETTINGS[${LOOT_DEFAULT}]}
        /echo No Drop loot defaults to .... ${LOOT_SETTINGS[${LOOT_NO_DROP}]}

    } else {
        /echo Sorry, no help for ${CmdName}.
    }

/return
Last edited by anon_coward on Fri Oct 15, 2004 5:21 pm, edited 3 times in total.

hiipii
a ghoul
a ghoul
Posts: 93
Joined: Sat Jun 19, 2004 5:01 pm

Post by hiipii » Thu Oct 14, 2004 6:33 pm

Pretty nice im definately gonna check this out when mq works again =)

eqaussie
a ghoul
a ghoul
Posts: 124
Joined: Tue Mar 16, 2004 5:58 am

Post by eqaussie » Thu Oct 14, 2004 7:57 pm

Looks great, would look greater as a plugin :)

Will test it out once MQ back on the air.

anon_coward
a lesser mummy
a lesser mummy
Posts: 40
Joined: Wed Mar 24, 2004 11:11 pm

Post by anon_coward » Thu Oct 14, 2004 8:02 pm

A plugin would be overkill for something this simple, but you can convert this to a include file easy enough to use it with other macros.

ScubaSki
a lesser mummy
a lesser mummy
Posts: 55
Joined: Mon Jun 21, 2004 8:27 pm

Post by ScubaSki » Fri Oct 15, 2004 12:33 am

I wholeheartedly disagree. This would make an awesome plugin.
[code:1]Sub Main
:loop
/if !${me.understand} /call readsig
/if ${me.still.doesn't.understand} /call rtfm
/if ${me.STILL.DOESN'T.FUCKING.UNDERSTAND} /call findgun
goto :loop
/endmacro[/code:1]

anon_coward
a lesser mummy
a lesser mummy
Posts: 40
Joined: Wed Mar 24, 2004 11:11 pm

Post by anon_coward » Fri Oct 15, 2004 4:28 am

During selling It was giving a false warning for items set to KEEP. Fixed above.

I guess I don't understand why this is better as a plugin than an include file (how I actually use it). I think plugin if I want access to structs not exposed through MQ2Data, or need C++ to code something that just doesnt lend itself to MQ scripting. Help me see the bigger picture that I'm obviously missing. As it is now, I only have 2 functions to call from my main script, everything is pretty well encapsulated.

hiipii
a ghoul
a ghoul
Posts: 93
Joined: Sat Jun 19, 2004 5:01 pm

Post by hiipii » Fri Oct 15, 2004 6:08 pm

Basically plugins run faster and more reliably and you can easily run macros while using plugins.

Process
a lesser mummy
a lesser mummy
Posts: 73
Joined: Fri Jun 25, 2004 5:30 pm

How about an autolooting function?

Post by Process » Thu Oct 21, 2004 5:03 pm

This macro is wonderful! I love not having carpal tunnel while looting after I killed 50 mobs in an AE group.

I would love to suggest one thing though...How about some functionality which would allow for an "autoloot loop". In other words, some functionality which would constantly search for the nearest corpse and automatically try to loot that corpse. I already have a hotkey that looks like this:

Code: Select all

/pause 4, /target corpse
/loot
This automatically targets the nearest corpse to me and tries to loot it. Could this be implemented as a loop into this macro? I would do it myself, but I'm quite ignorant when it comes to any type of programming. The closest thing I've had to luck when making macros, came about by me subtly editting others' macros.

If someone could show me what to add to this macro to bring about this functionality - That would be very appreciated.

Thanks again!

Process

Process
a lesser mummy
a lesser mummy
Posts: 73
Joined: Fri Jun 25, 2004 5:30 pm

Looped Looting

Post by Process » Fri Oct 22, 2004 2:10 pm

Ok. I did some minor changes, and I'm the first to admit that I have no clue what I'm doing. However, it seems to be working so far.

This allows me to constantly look for mobs that are loot'able, to loot them, then look for another.

If anyone sees any problems with my additions, let me know.

Code: Select all

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 
| 
| Author: anon_coward 
| 
| Initial release: 10/14/04 
| 
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 
| 
| Description: 
| This macro helps with looting and selling.  There are 2 main parts, looting 
| and selling.  The looting code is run once you open a corpse.  Once you click 
| the corpse open it automatically empties the corpse and adds the items to the 
| INI file.  Then later when you open a merchant, it will automatically sell 
| items that are in the INI file. 
| 
| Each item has an entry in the INI file with one of 4 numbers which mean: 
| KEEP, DESTROY, LEAVE, or SELL.  Items with the KEEP setting are automatically 
| looted, and skipped during the selling part.  The DESTROY setting picks the 
| item up off the corpse and it is immediately destroyed.  Use with CAUTION. 
| This is great for LDON collect missions.  Setting an item to LEAVE means the 
| next time it won't pick it up so it stays on the corpse.  And finally SELL is 
| the magic setting to have it both autolooted and autosold. 
| 
| There is a special check for ${Me.Name} when looting so if you open your own 
| corpse, the INI is ignored and every item should just be looted.  WARNING: 
| MAKE SURE YOU ALREADY GOT YOUR REZ. 
| 
| Finally, you can turn it on and off by using '/echo SET PAUSED' to toggle. 
| The same command pauses and resumes the macro. 
| 
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 
| 
| Here are the command it expects: 
| Print settings about an item or your inventory with: 
| ... /echo SHOW LOOT   - display current setting for the item on cursor 
| ... /echo SHOW SELL   - list all inventory items marked to sell 
| 
| With an item on the cursor, you change settings with 
| ... /echo SET KEEP    - just loot this item into inventory 
| ... /echo SET DESTROY - take off the corpse and /destroy it 
| ... /echo SET LEAVE   - just leave it on the corpse 
| ... /echo SET SELL    - put it in inventory and autosell at the next vendor 
| 
| And finally, to turn it on and off 
| ... /echo SET PAUSED  - toggle it on/off with the same command 
| 
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 

#Event Print "[MQ2] PRINT #1#" 
#Event Print "[MQ2] SHOW #1#" 
#Event Set   "[MQ2] SET #1#" 
#Event Help  "[MQ2] HELP #1#" 
#Event Help  "[MQ2] HELP" 

Sub Main 

    /echo Loot helper started 
    /call Init 

    :MainLoop
    /target corpse 
    /delay 6
    /loot 
    /delay 0 
    /doevents 
    /if (${PAUSED}) /goto :MainLoop 
    /if (${Merchant.Open})        /call SellLoot 
    /if (${Window[LootWnd].Open}) /call LootCorpse 
    /goto :MainLoop 

/endmacro 

Sub Init 

    /if (!${Defined[PAUSED]}) /declare PAUSED bool outer FALSE 

    |A few constants for handling loot 
    /if (!${Defined[LOOT_KEEP]})     /declare LOOT_KEEP     int    outer 1 
    /if (!${Defined[LOOT_DESTROY]})  /declare LOOT_DESTROY  int    outer 2 
    /if (!${Defined[LOOT_LEAVE]})    /declare LOOT_LEAVE    int    outer 3 
    /if (!${Defined[LOOT_SELL]})     /declare LOOT_SELL     int    outer 4 

    |A table for mapping numbers to strings for printing 
    /if (!${Defined[LOOT_SETTINGS]}) /declare LOOT_SETTINGS[4] string outer 
    /varset LOOT_SETTINGS[${LOOT_KEEP}]    KEEP 
    /varset LOOT_SETTINGS[${LOOT_DESTROY}] DESTROY 
    /varset LOOT_SETTINGS[${LOOT_LEAVE}]   LEAVE 
    /varset LOOT_SETTINGS[${LOOT_SELL}]    SELL 

    |Default values for specific types of loot 
    /if (!${Defined[LOOT_DEFAULT]})  /declare LOOT_DEFAULT  int    outer ${LOOT_SELL} 
    /if (!${Defined[LOOT_NO_DROP]})  /declare LOOT_NO_DROP  int    outer ${LOOT_LEAVE} 

    /echo Droppable loot defaults to .. ${LOOT_SETTINGS[${LOOT_DEFAULT}]} 
    /echo No Drop loot defaults to .... ${LOOT_SETTINGS[${LOOT_NO_DROP}]} 

/return 

Sub LootCorpse 

    /delay 1s 
    /declare total int local ${Corpse.Items} 

    /if (!${total}) /goto :DoneLooting 

    /declare WATCHDOG     timer local 
    /declare not_found    int   local -1 
    /declare item_setting int   local 
    /declare slot         int   local 
    /for slot 1 to ${total} 

        /varset WATCHDOG 5s 
        :ClearCursor 
        /delay 0 
        /doevents 
        /if (!${WATCHDOG}) { 
            /echo Item stuck on the cursor. Abort! 
            /goto :DoneLooting 
        } 
        /if (${Cursor.ID}) { 
            /autoinventory 
            /delay 5 
            /goto :ClearCursor 
        } 

        /varset item_setting ${Ini[Loot.ini,Loot,${Corpse.Item[${slot}].Name},${not_found}]} 

        | If the item isn't in the .ini file then add it. 
        /if (${item_setting}==${not_found}) { 
            /varset item_setting ${LOOT_DEFAULT} 
            /if (${Corpse.Item[${slot}].NoDrop}) { 
                /varset item_setting ${LOOT_NO_DROP} 
            } 

            /echo Adding to INI "${Corpse.Item[${slot}].Name}" (${LOOT_SETTINGS[${item_setting}]}) 
            /ini Loot.ini Loot "${Corpse.Item[${slot}].Name}" ${item_setting} 
        } 

        /if (${item_setting}==${LOOT_DESTROY} && !${Corpse.Name.Find[${Me}]}) { 
            /echo -- You destroyed a <<${Corpse.Item[${slot}].Name}>>.-- (${LOOT_SETTINGS[${item_setting}]}) 
            /itemnotify loot${slot} leftmouseup 
            /delay 5 
            /if (${Window[ConfirmationDialogBox].Open}) { 
                /notify ConfirmationDialogBox Yes_Button leftmouseup 
                /delay 5 
            } 
            /if (${Cursor.ID}) { 
                /destroy 
                /delay 5 
            } else { 
                /echo Uh oh, DESTROY item didn't show up on Cursor 
            } 

        } else /if (${item_setting}==${LOOT_KEEP} || ${item_setting}==${LOOT_SELL} || ${Corpse.Name.Find[${Me}]}) { 
            /echo -- You have looted a <<${Corpse.Item[${slot}]}>>.-- (${LOOT_SETTINGS[${item_setting}]}) 
            /itemnotify loot${slot} rightmouseup 
            /delay 5 
            /if (${Window[ConfirmationDialogBox].Open}) { 
                /notify ConfirmationDialogBox Yes_Button leftmouseup 
                /delay 5 
            } 

        } else /if (${item_setting}==${LOOT_LEAVE}) { 
            /echo -- You left a <<${Corpse.Item[${slot}]}>>.-- (${LOOT_SETTINGS[${item_setting}]}) 

        } else { 
            /echo Umm, something is wrong in the loot code 
            /echo I don't know what to do with ${Corpse.Item[${slot}]} 
            /echo I guess I'll just leave it there >< 
        } 
    /next slot 

    :DoneLooting 
    /notify LootWnd DoneButton leftmouseup 
    /delay 5 

/return 

Sub SellLoot(bool JUST_PRINT) 

    /if (!${Defined[JUST_PRINT]}) /declare JUST_PRINT bool local FALSE 
    /if (${Merchant.Open} && !${JUST_PRINT}) { 
        /declare i int local 
        /for i 10 downto 1 
            /popup AUTO SELLING in ${i} sec 
            /delay 1s 
            /if (!${Merchant.Open}) /return 
        /next i 
    } 

    /declare plat   int local ${Me.Platinum} 
    /declare gold   int local ${Me.Gold} 
    /declare silver int local ${Me.Silver} 
    /declare copper int local ${Me.Copper} 

    /declare not_found    int local -1 
    /declare item_setting int local 
    /declare slot         int local 
    /declare spot         int local 
    /for slot 1 to 8 
        /if (${InvSlot[pack${slot}].Item.Container}) { 
            /for spot 1 to ${InvSlot[pack${slot}].Item.Container} 
                /if (!${InvSlot[pack${slot}].Item.Item[${spot}].ID}) /goto :NextSpot 
                /varset item_setting ${Ini[wizard.ini,Loot,${InvSlot[pack${slot}].Item.Item[${spot}]},${not_found}]} 

                /if (${item_setting}==${not_found}) { 
                    /echo Dunno what to do with ${InvSlot[pack${slot}].Item.Item[${spot}]} pack${slot} slot${spot} 

                } else /if (${item_setting}==${LOOT_KEEP}) { 
                    /goto :NextSpot 

                } else /if (${item_setting}==${LOOT_DESTROY}) { 
                    /echo Should have DESTROYED ${InvSlot[pack${slot}].Item.Item[${spot}]} pack${slot} slot${spot} 

                } else /if (${item_setting}==${LOOT_LEAVE}) { 
                    /echo Should have LEFT ${InvSlot[pack${slot}].Item.Item[${spot}]} pack${slot} slot${spot} 

                } else /if (${item_setting}==${LOOT_SELL}) { 
                    /echo Selling ${InvSlot[pack${slot}].Item.Item[${spot}]} 
                    /if (${JUST_PRINT}) /goto :NextSpot 

                    /if (!${Window[InventoryWindow].Open}) /nomodkey /keypress inventory 
                    /delay 5 
                    /if (!${Window[pack${slot}].Open}) /nomodkey /itemnotify pack${slot} rightmouseup 
                    /delay 5 
                    /nomodkey /itemnotify ${InvSlot[pack${slot}].Item.Item[${spot}].InvSlot} leftmouseup 
                    /delay 5 
                    /nomodkey /shift /notify MerchantWnd MW_Sell_Button leftmouseup 
                    /delay 5 

                } else { 
                    /echo Bogus item setting: ${InvSlot[pack${slot}].Item.Item[${spot}]} => ${item_setting} 
                } 
            :NextSpot 
            /next spot 

            /if (${Window[pack${slot}].Open}) /nomodkey /itemnotify pack${slot} rightmouseup 
            /delay 1s 

        } else { 
            /if (!${InvSlot[pack${slot}].Item.ID}) /goto :NextSlot 
            /varset item_setting ${Ini[wizard.ini,Loot,${InvSlot[pack${slot}].Item},${not_found}]} slot${slot} 

            /if (${item_setting}==${not_found}) { 
                /echo Dunno what to do with ${InvSlot[pack${slot}].Item} slot${slot} 

            } else /if (${item_setting}==${LOOT_KEEP}) { 
                /goto :NextSlot 

            } else /if (${item_setting}==${LOOT_DESTROY}) { 
                /echo Should have DESTROYED ${InvSlot[pack${slot}].Item} slot${slot} 

            } else /if (${item_setting}==${LOOT_LEAVE}) { 
                /echo Should have LEFT ${InvSlot[pack${slot}].Item} slot${slot} 

            } else /if (${item_setting}==${LOOT_SELL}) { 
                /echo Selling ${InvSlot[pack${slot}].Item} 
                /if (${JUST_PRINT}) /goto :NextSlot 

                /if (!${Window[InventoryWindow].Open}) /nomodkey /keypress inventory 
                /delay 5 
                /nomodkey /itemnotify pack${slot} leftmouseup 
                /delay 5 
                /nomodkey /shift /notify MerchantWnd MW_Sell_Button leftmouseup 
                /delay 5 

             } else { 
                /echo Bogus item setting: ${InvSlot[pack${slot}].Item} => ${item_setting} 
             } 
        } 
    :NextSlot 
    /next slot 

    /varcalc plat   ${Me.Platinum}-${plat} 
    /varcalc gold   ${Me.Gold}-${gold} 
    /varcalc silver ${Me.Silver}-${silver} 
    /varcalc copper ${Me.Copper}-${copper} 

    /if (${plat} || ${gold} || ${silver} || ${copper}) { 
        /echo Made ${plat}pp ${gold}gp ${silver}sp ${copper}cp 
    } 

    /nomodkey /notify MerchantWnd DoneButton leftmouseup 
    /delay 5 
    /if (${Window[InventoryWindow].Open}) /nomodkey /keypress inventory 
    /delay 5 

/return 

Sub SetLootPreference(int pref) 

    /if (!${Cursor.ID}) { 
        /echo Pick up something on your cursor before typing this command 
        /return 
    } 

    /if (!${Defined[pref]}) { 
        /declare not_found    int local -1 
        /declare item_setting int local ${Ini[Loot.ini,Loot,"${Cursor}",${not_found}]} 
        /if (${item_setting}==${not_found}) { 
            /echo No entry for ${Cursor} 
        } else /if (${item_setting}==${LOOT_KEEP}) { 
            /echo Pick up <<${Cursor}>> 
        } else /if (${item_setting}==${LOOT_DESTROY}) { 
            /echo Pick up & DESTROY <<${Cursor}>> 
        } else /if (${item_setting}==${LOOT_LEAVE}) { 
            /echo Leave <<${Cursor}>> on corpse 
        } else /if (${item_setting}==${LOOT_SELL}) { 
            /echo Pick up <<${Cursor}>> (to sell) 
        } else { 
            /echo Unknown TYPE for Loot <<${Cursor}>> 
        } 
        /return 
    } 

    /if (${pref} < 1 || ${pref} > 4) { 
        /echo Prefence ID ${pref} out of range.  ERROR processing command 
        /return 
    } 

    /echo Setting preferenc "${Cursor.Name}" => ${LOOT_SETTINGS[${pref}]} 
    /ini Loot.ini Loot "${Cursor.Name}" ${pref} 
    /if (${pref}==${LOOT_DESTROY}) /destroy 

/return 

Sub Event_Print(string EventTxt,string CmdName) 

    /if (${CmdName.Find[LOOT]}) { 
        /call SetLootPreference 

    } else /if (${CmdName.Find[SELL]}) { 
        /call SellLoot TRUE 

    } else { 
        /echo Unknown command: ${CmdName} 
        /echo for more info type /echo HELP 
    } 

/return 

Sub Event_Set(string EventTxt,string CmdName) 

    /if (${CmdName.Find[SAVE]} || ${CmdName.Find[KEEP]}) { 
        /call SetLootPreference ${LOOT_KEEP} 

    } else /if (${CmdName.Find[DESTROY]}) { 
        /call SetLootPreference ${LOOT_DESTROY} 

    } else /if (${CmdName.Find[LEAVE]}) { 
        /call SetLootPreference ${LOOT_LEAVE} 

    } else /if (${CmdName.Find[SELL]}) { 
        /call SetLootPreference ${LOOT_SELL} 

    } else /if (${CmdName.Find[PAUSE]}) { 
        /if (${PAUSED}) { 
            /varset PAUSED FALSE 
            /echo ${Macro.Name} is active again 
        } else { 
            /varset PAUSED TRUE 
            /echo ${Macro.Name} is being paused 
            /echo type '/echo SET PAUSED' to resume 
        } 

    } else { 
        /echo Unknown command: ${CmdName} 
        /echo for more info type /echo HELP 
    } 

/return 

Sub Event_Help(string EventTxt,string CmdName) 

    /if (!${Defined[CmdName]}) { 
        /echo Help options are 
        /echo ... /echo HELP LOOT 

    } else /if (${CmdName.Find[LOOT]}) { 
        /echo Loot choices are 
        /echo ... /echo SHOW LOOT   - display current setting for the item on cursor 
        /echo ... /echo SHOW SELL   - list all inventory items marked to sell 
        /echo 
        /echo With an item on the cursor, you change settings with 
        /echo ... /echo SET KEEP    - just loot this item into inventory 
        /echo ... /echo SET DESTROY - take off the corpse and /destroy it 
        /echo ... /echo SET LEAVE   - just leave it on the corpse 
        /echo ... /echo SET SELL    - put it in inventory and autosell at the next vendor 
        /echo 
        /echo And finally, to turn it on and off 
        /echo ... /echo SET PAUSED  - toggle it on/off with the same command 
        /echo 
        /echo Droppable loot defaults to .. ${LOOT_SETTINGS[${LOOT_DEFAULT}]} 
        /echo No Drop loot defaults to .... ${LOOT_SETTINGS[${LOOT_NO_DROP}]} 

    } else { 
        /echo Sorry, no help for ${CmdName}. 
    } 

/return
All I added was this:

Code: Select all

    /target corpse 
    /delay 6
    /loot 
Any opinions?

Thanks,

Process

anon_coward
a lesser mummy
a lesser mummy
Posts: 40
Joined: Wed Mar 24, 2004 11:11 pm

Post by anon_coward » Fri Oct 22, 2004 6:13 pm

How about this:

Code: Select all

    /if (${NearestSpawn[npc corpse radius 5].ID}) {
        /target corpse
        /loot
    }
That way it will only try to loot corpses that are near you. If people want it included in the original macro, I would want to add an event for corpses you cant loot so you don't spam you trying to loot the same corpse until it opens.

Process
a lesser mummy
a lesser mummy
Posts: 73
Joined: Fri Jun 25, 2004 5:30 pm

Post by Process » Mon Oct 25, 2004 1:08 pm

I think that's a great idea! I say go for it, put the functionality in - At least as an option.

Great job. Thanks again!

Process

jimse80
decaying skeleton
decaying skeleton
Posts: 2
Joined: Thu Oct 28, 2004 5:43 am

Post by jimse80 » Thu Oct 28, 2004 5:48 am

I am pretty new to MQ2, and found this macro, it is simply awesome if i could find out why it doesnt sell for me.
When i start to trade it just says "Dunno what to do with ......................".

anon_coward
a lesser mummy
a lesser mummy
Posts: 40
Joined: Wed Mar 24, 2004 11:11 pm

Post by anon_coward » Thu Oct 28, 2004 11:39 am

It only sells items the macro has automatically looted before. I wanted to make sure it didn't start selling my equipment (which my first version did :shock: ) If you manually looted a new item that you want to always auto sell, pick it up on the cursor and type:

Code: Select all

/echo set sell
From now on that item will always be autosold. You can show what items are recorded in the INI file and with which option by typing:

Code: Select all

/echo show sell
Read the documentation for more.

jimse80
decaying skeleton
decaying skeleton
Posts: 2
Joined: Thu Oct 28, 2004 5:43 am

Post by jimse80 » Thu Oct 28, 2004 3:59 pm

Dont know what i am doing wrong, I have tried to mark items manually but still doesnt sell them.
Just tried to make a new .INI file that didnt help, is there anything in the plugin that could be wrong?

Jackalo
orc pawn
orc pawn
Posts: 11
Joined: Mon Feb 07, 2005 9:33 pm

Post by Jackalo » Sun Feb 13, 2005 11:43 am

This macro doesn't seem to be functioning for me in the Sell Loot area. Sure, it'll loot corpses correctly, but when it comes to selling to merchants, it doesn't seem to load the item codes from the INI file correctly, and everything is marked as 0 instead of their appropriate numbers (4,2, etc).

I'm going to see if I can't fix it, as it'll make farming in HHK a lot easier. :cool: