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

