Food.mac -- Simple Food/Drink buyer with INI (v1.02)

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

Moderator: MacroQuest Developers

User avatar
Night Hawk
a grimling bloodguard
a grimling bloodguard
Posts: 590
Joined: Fri Aug 13, 2004 4:56 pm

Food.mac -- Simple Food/Drink buyer with INI (v1.02)

Post by Night Hawk » Mon Aug 30, 2004 5:57 pm

Description: Buys Food and Drink from a specific vendor with use of simple INI settings

Files: food.mac, food.ini, common/buy.inc


I always keep the same food in drink going in my pack and thought a simple macro would be nice. Then decided it make it easy to change and use for others.

This macro uses Override's Buy.inc from his site:
http://www.soc-music.com/mq2/
Make sure you have this file, as I'm not posting it here.

v1.02 Changed lines checkings if the food/drink you needed was greater than 1. Need to be ">=" so it would still buy if you only needed 1.

v1.01 Added in a simple checker to make sure you have money on you. I couldn't really figure out a great way to do it. So I check to see that you at least have 5pp or 50gp.
Also added a ranger checker.

v1.00 Intial release.

Food.mac

Code: Select all

|- food.mac
|- By: Drumstix42
|- Date: August 29th, 2004
|- Credit to Override for buy.inc
|-- Description: Buys Food and Drink from a specific vendor with use of simple INI settings.
|-- Files: food.mac, food.ini, common/buy.inc

#include common/buy.inc

Sub Main
   |-- Check Platinum and Gold. Sorry folks, silver just don't cut it
   /if ( ((${Me.Platinum}<5)&&(${Me.Gold}<1))||((${Me.Platinum}<5)&&(${Me.Gold}<50)) ) {
      /echo You need to have some money before you buy anything.
      /end
   }
   
   |--  Total Wanted minus Current Drink
   /declare DrinkNeeded int local ${Math.Calc[${Ini[food.ini,Drink,Ammount]}-${FindItemCount[=${Ini[food.ini,Drink,Name]}]}].Int}
   /declare FoodNeeded int local ${Math.Calc[${Ini[food.ini,Food,Ammount]}-${FindItemCount[=${Ini[food.ini,Food,Name]}]}].Int}
   
   |-- Ammount of each that will be bought
   /declare DrinkWanted int local ${Ini[food.ini,Drink,Ammount]}
   /declare FoodWanted int local ${Ini[food.ini,Food,Ammount]}
   
   |-- Merchant Name
   /declare MerchantName string local ${Ini[food.ini,Merchant,Name]}
   
   |-- Names with quotes for Buy.inc
   /declare DrinkName string local "${Ini[food.ini,Drink,Name]}"
   /declare FoodName string local "${Ini[food.ini,Food,Name]}"
   
   |-- Names again for the two echo's
   /declare Drink string local ${Ini[food.ini,Drink,Name]}
   /declare Food string local ${Ini[food.ini,Food,Name]}
   
   |-- Make sure nothing is on the cursor first
   /call ClearCursor
   
   /echo Merchant: ${MerchantName}

   /if (${DrinkNeeded}>1) {
      /echo Buying ${DrinkNeeded} ${Drink}s
   } else {
      /echo Buying ${DrinkNeeded} ${Drink}
   }
   /if (${FoodNeeded}>1) {
      /echo Buying ${FoodNeeded} ${Food}s
   } else {
      /echo Buying ${FoodNeeded} ${Food}
   }
   
   |-- Target Merchant, and buy food/drink if needed
   /target npc ${MerchantName}
   |-- Make sure Merchant is in range
   /if (${Target.Distance}>20) {
      /echo Merchant is too far away. Get closer!
      /end
   }
   /nomodkey /click right target
   /delay 1s
   /if (${DrinkNeeded}>=1) /call Buy ${DrinkName} ${DrinkWanted}
   /delay 1s
   /if (${FoodNeeded}>=1) /call Buy ${FoodName} ${FoodWanted}
   /delay 1s
   /notify MerchantWnd DoneButton leftmouseup
   
   /echo Done.
   
/return

Sub ClearCursor
   :CusorLoop
    /if (${Cursor.ID}) {
       /autoinventory
       /if (${Cursor.ID}) /goto :CusorLoop
    }
/return

Food.ini Sample

Code: Select all

[Merchant]
Name=Vuli Ironstove

[Drink]
Name=Water Flask
Ammount=80

[Food]
Name=Iron Ration
Ammount=40

The ammount is the ammount of food/drink you want to have after the macro is done. So if you have 20 current food, and want to have 40 overall, you would set ammount to 40.

I just kept the INI simple, since I only use 1 type of food or drink, but you can of course change it to anything you want, as this is just a sample.

User avatar
Night Hawk
a grimling bloodguard
a grimling bloodguard
Posts: 590
Joined: Fri Aug 13, 2004 4:56 pm

Post by Night Hawk » Wed Sep 01, 2004 4:16 pm

Updated. See change notes.

User avatar
Night Hawk
a grimling bloodguard
a grimling bloodguard
Posts: 590
Joined: Fri Aug 13, 2004 4:56 pm

Post by Night Hawk » Thu Sep 02, 2004 2:57 am

Has anyone tried this out. Seems simple enough. Just wanna make sure I didn't miss anything obvious.

efudd
a lesser mummy
a lesser mummy
Posts: 50
Joined: Sun Jan 04, 2004 8:00 pm

Post by efudd » Thu Sep 02, 2004 3:46 am

This makes me cry.

Why?!

-e

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Thu Sep 02, 2004 7:14 am

Finally a reprieve from the odious task of buying food! Fudd, won't you help me turn this into a plugin and get it added to the distribution?

efudd
a lesser mummy
a lesser mummy
Posts: 50
Joined: Sun Jan 04, 2004 8:00 pm

Post by efudd » Thu Sep 02, 2004 8:54 pm

ah ha! .. ha ha.. er.. No. I won't. :P

-e