ForageDestroy.mac - Now MQ2Data compliant

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

xander
a lesser mummy
a lesser mummy
Posts: 33
Joined: Thu Apr 22, 2004 11:40 pm

ForageDestroy.mac - Now MQ2Data compliant

Post by xander » Thu Apr 22, 2004 11:45 pm

OK guys, this is my first post, so be gentle. :) This is the one I was using, decided to try my hand at making it mq2data compliant. It works fine for me, but there are probably some coding mistakes. So here goes.

Code: Select all

|ForageDestroy.mac 
|Based off of Grimjack's forage.mac - Thank you =) 
|edit the /varset DestroyArray to reflect what you want to destroy. 
|If you add more update DestArraySize to reflect the change. 
|The next value in the array would be like this. 
|/varset DestroyArray(20) "what you want" 
|And you would update DestArraySize like this. 
|/varset DestArraySize 21 
|
|Edited by Xander for mq2data compliance

sub Main 
   /cleanup 
   /declare DestArraySize global 
   /declare LoopCount global 
   /declare DestroyArray array 
   /varset DestroyArray(0) "Fishing Grubs"
   /varset DestroyArray(1) "Pod of Water" 
   /varset DestroyArray(2) "Small Chunk of Velium"
   /varset DestroyArray(3) "Berries"
   /varset DestroyArray(4) "Fruit"
   /varset DestroyArray(5) "Roots"
   /varset DestroyArray(6) "Rabbit Meat"
   /varset DestroyArray(7) "Arctic Mussels"
   /varset DestroyArray(8) "Arctic Scallop"
   /varset DestroyArray(9) "Glob of Slush Water"
   /varset DestArraySize 10
   /varset LoopCount 0 
   :Forage 
       /delay 1s 
       /if (${Cursor.ID}) /call ItemSort
       /if (!${Cursor.ID}) {
	   /if (${Me.Skill[Forage]} > 0) /doability forage 
       }
       /if (${Cursor.ID}) /call ItemSort
       /goto :Forage 
   :loop 
/return 

sub ItemSort 
   :itemchecker 
      /if (${Cursor.ID}) { 
          /if (${Cursor.Name.Find[@DestroyArray(@LoopCount)]}) {
            /echo Destroying ${Cursor.Name} 
	    /destroy
            /delay 2s 
         } 
      /varadd LoopCount 1 
      /if (${Cursor.ID}) {
        /if (@LoopCount<@DestArraySize) /goto :itemchecker 
        }
   } 

   /if (${Cursor.ID}) { 
      /echo Keeping ${Cursor.Name} 
      /autoinventory 
      /delay 1s 
   } 
   /doevents 
   /varset LoopCount 0 
/return
Last edited by xander on Mon Apr 26, 2004 11:01 pm, edited 5 times in total.
Xander

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Fri Apr 23, 2004 12:12 am

Only things I see that need to be fixed are below:

Code: Select all

sub ItemSort 
   :itemchecker 
      /if (${Cursor.ID}) { 
          [color=cyan]/if (${Cursor.Name.Find[@DestroyArray(@LoopCount)]}) [/color]{ 
          [color=cyan]/echo Destroying ${Cursor.Name}[/color]
       /destroy 
            /delay 2s 
         } 
      /varadd LoopCount 1 
      /if (${Cursor.ID}) { 
        /if (@LoopCount<@DestArraySize) /goto :itemchecker 
        } 
   } 

   /if (${Cursor.ID}) { 
      [color=cyan]/echo Keeping ${Cursor.Name}[/color] 
      /autoinventory 
      /delay 1s 
   } 
   /doevents 
   /varset LoopCount 0 
/return

xander
a lesser mummy
a lesser mummy
Posts: 33
Joined: Thu Apr 22, 2004 11:40 pm

Updated

Post by xander » Fri Apr 23, 2004 12:31 am

Updated with those changes, thanks. Looks much cleaner that way.
Xander

robdawg
a ghoul
a ghoul
Posts: 114
Joined: Tue Mar 23, 2004 11:54 am
Contact:

....

Post by robdawg » Fri Apr 23, 2004 12:51 pm

Would like to say this macro rocks and I used it for 6 hours straight with no problems.

Just wish it had INI support *OR* I was good enough to write INI support. :)
ROBDAWG

[url=http://www.seathound.com]Seat Hound[/url]
[url=http://www.sportsrumormill.com]Sports Rumor Mill[/url]
[url=http://www.packerforum.com]Packer Forum[/url]

Ketamine
orc pawn
orc pawn
Posts: 18
Joined: Thu Feb 26, 2004 4:12 pm

Post by Ketamine » Fri Apr 23, 2004 2:35 pm

This seems to be destroying EVERYTHING I forage, not just what it is told to. Anyone else having this problem or know why I am?

JimJohnson
a grimling bloodguard
a grimling bloodguard
Posts: 1299
Joined: Sat Oct 11, 2003 6:00 am

Post by JimJohnson » Fri Apr 23, 2004 4:05 pm

works fine for me

Ketamine
orc pawn
orc pawn
Posts: 18
Joined: Thu Feb 26, 2004 4:12 pm

Post by Ketamine » Fri Apr 23, 2004 7:54 pm

Now its not destroying everything I am foraging. Just Planar Fruits :?

Ketamine
orc pawn
orc pawn
Posts: 18
Joined: Thu Feb 26, 2004 4:12 pm

Post by Ketamine » Fri Apr 23, 2004 8:14 pm

Think I figured that out. Since Planar Fruit has the word "fruit" in it it was destroying it. I removed the fruit line and now it works fine.

xander
a lesser mummy
a lesser mummy
Posts: 33
Joined: Thu Apr 22, 2004 11:40 pm

Post by xander » Fri Apr 23, 2004 8:24 pm

This is the code that's doing it:

Code: Select all

/if (${Cursor.ID}) { 
         [color=cyan] /if (${Cursor.Name.Find[@DestroyArray(@LoopCount)]}) [/color]{ 
            /echo Destroying ${Cursor.Name} 
       /destroy 
            /delay 2s 
         } 
This is looking for the text in the destroy array to see if it is in the text of the item on your cursor. I don't know how to make it require an exact match, sorry. As it is, if it finds a partial (IE 'fruit' in 'Planar Fruit') it evaluates to true and destroys it. Anyone know how to require an exact match in the expression?
Xander

User avatar
SimpleMynd_01
a lesser mummy
a lesser mummy
Posts: 71
Joined: Thu May 08, 2003 3:16 pm

No promiises...

Post by SimpleMynd_01 » Fri Apr 23, 2004 11:13 pm

Try:

Code: Select all

/if (${Cursor.Name.Find[[color=red]=[/color]@DestroyArray(@LoopCount)]}) { 
That's the way everything else seems to work for exact matches.

-SimeplMynd

Remblan
orc pawn
orc pawn
Posts: 10
Joined: Thu Apr 22, 2004 2:44 am

Post by Remblan » Sat Apr 24, 2004 12:40 am

Only 2 minor problem2 with this one for me:

1) When I forage an item the is in the destroy list in spams the MQ window with 8 destroying NULL messages after destroying the foraged item

2) Would love a way to run this while med so that it stands me up and possible sits me back down. I tried to impliment a /stand command but all it did was stand me up as soon as I sat down :(

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

Post by Preocts » Sat Apr 24, 2004 6:50 am

In response to people who are looking for INI support. Here is a snippet from my own personal macro that runs 100% of the time my druid is logged in.

Code: Select all

 #Event Foraged "You have scrounged"
Sub Event_Foraged
  /delay 5
  /declare DoubleCheck local
  /varset DoubleCheck "${Cursor.Name}"

  /if (!${Ini[druid.ini,ForageList,${Cursor.Name}].Length}) {
    /ini "druid.ini" "ForageList" "${Cursor.Name}" "-1"
  } else {
    /if (${Ini[druid.ini,ForageList,${Cursor.Name}]}) {
      /if (${FindItemCount["=${Cursor.Name}"]}>=${Ini[druid.ini,ForageList,${Cursor.Name}]} && ${Ini[druid.ini,ForageList,${Cursor.Name}]}!=-1) /goto :Destroy
    } else {
      :Destroy
      /if (${Cursor.Name.Equal["@DoubleCheck"]}) /destroy
      /return
    }
  }

  :LootIt
    /autoinventory
    /delay 5
    /if (${Cursor.ID}) /goto :LootIt
/return
The ini is populated by the macro and has three possible settings. 0, -1, or any number. 0 will destroy that item if foraged. -1 will keep all. If you give it any other number, say 20, the macro will keep up to 20 of that item and destroy any extra that are foraged.

Code: Select all

[ForageList]
Fruit=-1
Pod of Water=40
Roots=0
2) Would love a way to run this while med so that it stands me up and possible sits me back down. I tried to impliment a /stand command but all it did was stand me up as soon as I sat down

Code: Select all

/if (${Me.AbilityReady["Forage"]}) {
  /if (${Me.Sitting}) {
    /stand
    /delay 3
    /doability Forage
    /sit
  } else {
    /doability Forage
  }
}

game_slave
orc pawn
orc pawn
Posts: 18
Joined: Wed Apr 21, 2004 6:50 pm

Post by game_slave » Sat Apr 24, 2004 2:29 pm

Here is a working macro based mostly on Preocts code. I changed some names(Druid to forage) and added some echos so you would know what was happening. I am looking to add statistics maybe later on but for now this macro works very well.

Code: Select all

|Forage.mac
|Based off code from Preocts(thanks!) and code from various other forage macros.
|In the forage.ini file use -1 to keep all, 0 to destroy all and any other number to keep just that many.


sub Main
   /cleanup
   :Forage
    /if (${Me.State.NotEqual[STAND]}) {
      /stand
      /delay 5
   }
   /delay 1s
   /if (${Me.Skill[Forage]} > 0) /doability forage
       }
       /if (${Cursor.ID}) /call ItemSort
       /goto :Forage
   :loop
/return
sub ItemSort
  /delay 5
  /declare DoubleCheck local
  /varset DoubleCheck "${Cursor.Name}"

  /if (!${Ini[forage.ini,ForageList,${Cursor.Name}].Length}) {
    /ini "Forage.ini" "ForageList" "${Cursor.Name}" "-1"
  } else {
    /if (${Ini[forage.ini,ForageList,${Cursor.Name}]}) {
      /if (${FindItemCount["=${Cursor.Name}"]}>=${Ini[forage.ini,ForageList,${Cursor.Name}]} && ${Ini[forage.ini,ForageList,${Cursor.Name}]}!=-1) /goto :Destroy
    } else {
      :Destroy
      /if (${Cursor.Name.Equal["@DoubleCheck"]}) {
      /echo Destroying ${Cursor.Name}
      /destroy
      /return
    }
  }

  :LootIt
  	/echo Keeping ${Cursor.Name}
    /autoinventory
    /delay 5
    /if (${Cursor.ID}) /goto :LootIt
/return 

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

Post by Preocts » Thu Apr 29, 2004 6:31 am

Glad to hear you were able to make a working mac out of that snippet. Here is a general question for anyone who uses forage macs. What kind of stats are useful to record. My present macro tracks Forage: Attempts, Successes, Failures, Keeps, Destorys, and the number of each different item foraged for the 'day'. ((my macro has an option to reset these stats))

Once there are a few things worked out with the new Uservars I'll post my foraging.inc.

xander
a lesser mummy
a lesser mummy
Posts: 33
Joined: Thu Apr 22, 2004 11:40 pm

Post by xander » Thu Apr 29, 2004 6:55 am

I've never felt the need to know the stats at all myself.
Xander