Page 1 of 1

Feedme.mac v1.4

Posted: Tue Aug 31, 2004 1:24 pm
by A_Druid_00
The text at the top of the macro says it all. All you have to do is change the /declare myfood and mydrink lines to reflect the food you want to eat, and the drink you want to drink. Really simple and efficient.

If you don't have your food/drink in pack1 like I do, this macro won't automagically close the bag for you. If its in pack1 though, it'll open the bag, snag the food, and then put the food in your pack1 slot, closing the bag as a result. The whole thing happens so fast, about the only thing that lets you know its working is the sound of the packs opening/closing

Fixes:
11/4 Final update for now. I may revisit this and add ini support, but nowhere in the near future. All I did this time around was define separate Subs for the eating and drinking thresholds.
11/2 Cleaned up some things based on Cr4zyb4rd's suggestions.
11/1 Did away with the /delay before looping and now it just checks Me.Hunger and Thirst and attempts to eat/drink if it goes below 5000 on either. I should probably rewrite it to eat or drink based on which is below 5000, but what can I say? I'm lazy

9/3 Fixed bug that was causing 'mouseup' errors due to attempting to open bags while casting. Also added an extra /autoinventory and dropped the delay to 90 seconds at the end to bag any forages picked up since the last time the macro fired; mainly due to using Cr4zyb4rd's autoskills plugin along with this one; leaving me with a massive amount of foraged goodies on my cursor.

Known issues:
None, feel free to add suggestions on how to clean it up though

Code: Select all

Sub Main 

:mainloop 
   /if (${Me.Casting.ID}) /goto :mainloop 
   /if (${Me.Hunger}<=5000) /call EatMe 
   /if (${Me.Thirst}<=5000) /call DrinkMe 
   /goto :mainloop   
/return

Sub EatMe 
   /declare myfood string local Rye of Eternity 
   /declare mypack string local 
   /declare myslot string local 
   /varset mypack ${FindItem[=${myfood}].InvSlot.Pack} 
   /varset myslot ${FindItem[=${myfood}].InvSlot} 
:clearcursor
   /autoinventory 
   /if (${Cursor.ID}) /goto :clearcursor
   /if (${mypack}) { 
   /if (!${Window[${InvSlot[${mypack}].Name}].Open}) /nomodkey /itemnotify ${mypack} rightmouseup 
} 
:WaitForBagOpen 
   /nomodkey /ctrl /itemnotify ${myslot} leftmouseup 
   /if (!${Cursor.ID}) /goto :WaitForBagOpen 
   /nomodkey /itemnotify pack1 leftmouseup 
   /nomodkey /itemnotify pack1 rightmouseup 
   /nomodkey /itemnotify pack1 leftmouseup 
/return 

Sub DrinkMe 
   /declare mydrink string local Water of Eternity 
   /declare mypack string local 
   /declare myslot string local 
   /varset mypack ${FindItem[=${mydrink}].InvSlot.Pack} 
   /varset myslot ${FindItem[=${mydrink}].InvSlot} 
:clearcursor
   /autoinventory 
   /if (${Cursor.ID}) /goto :clearcursor
   /if (${mypack}) { 
   /if (!${Window[${InvSlot[${mypack}].Name}].Open}) /nomodkey /itemnotify ${mypack} rightmouseup 
} 
:WaitForBagOpen 
   /nomodkey /ctrl /itemnotify ${myslot} leftmouseup 
   /if (!${Cursor.ID}) /goto :WaitForBagOpen 
   /nomodkey /itemnotify pack1 leftmouseup 
   /nomodkey /itemnotify pack1 rightmouseup 
   /nomodkey /itemnotify pack1 leftmouseup 
/return

Posted: Tue Aug 31, 2004 6:52 pm
by Cr4zyb4rd
this is NOT a "finished" macro, as should be pretty obvious by looking at it. i didn't want it posted here :(

Posted: Tue Aug 31, 2004 7:06 pm
by A_Druid_00
It works for me, though I added in another /delay or two to slow it down a tad :(

Posted: Thu Sep 02, 2004 1:33 am
by PhoenixZorn
Want I should move it to snippets?

Posted: Thu Sep 02, 2004 3:30 am
by Cr4zyb4rd
Doesn't matter to me, but I'm not "supporting" it :)

Posted: Fri Sep 03, 2004 9:57 pm
by A_Druid_00
Updated to fix the problem with 'mouseup' while casting. It now waits for casting to be over before firing.

Posted: Mon Nov 01, 2004 10:19 pm
by A_Druid_00
11/1 Did away with the /delay before looping and now it just checks Me.Hunger and Thirst and attempts to eat/drink if it goes below 5000 on either. I should probably rewrite it to eat or drink based on which is below 5000, but what can I say? I'm lazy
Minor update, but I figured I'd share. I've actually rewritten this as a .inc file and #include it in most of the macros I run now, I should probably just move this to snippets.

Posted: Tue Nov 02, 2004 5:03 am
by Cr4zyb4rd
You really should have some sort of delay in the loop, if only so you're not throwing cpu cycles at checking your food state every macro pulse. (If a .inc, go a step farther and use a timer/event instead so that they can handle it with their other events). Also (keeping speed in mind) you might want to quit using the ${stuff} hack and handle food/drink explicitly.

Code: Select all

   /if (${Cursor.ID}) /autoinventory 
   /delay 2 
could just be /autoinventory. You're in no danger of sending nonexistant items to a backpack. And I'm reasonably sure you don't need a delay here.

Move the casting check higher up, in fact I'd make it the very first statement of the loop, since this gives us a chance to fail out early and save even more cycles.

I'm not sure what's going on in :WaitForBagOpen. Seems to me the :WaitForBagOpen should be above the line that actually checks if it's open, and we've already JUST checked for Casting.ID...

edit: I'd post the changes I'm outlining, but I know you're trying to figure this stuff out for yourself. If you get stumped, lemme know.

Posted: Tue Nov 02, 2004 7:28 am
by A_Druid_00
Honestly, speed didn't really concern me, since it's not going very far if hunger/thirst is above the threshold of 5000. Good point on the /autoinventory and delay, I'll fix that; though I swear there was a reason I had it in there in the first place.

I actually had issues when spamming heals/nukes where I would actually get a spell started in between the start of the mac and the time it got to waitforbagopen. Getting rid of the delay above will probably fix that, so I'll pull the 2nd casting check too.

As far as the placement of :waitforbagopen, that's where you threw it into your quick and dirty version of Macro Requests, and it seems to work fine there. It just checks to see if it picked anything up from {myslot} and if it didn't it goes back and tries to pick it back up again, in hopes that {mypack} is open this time.

Posted: Tue Nov 02, 2004 10:25 am
by Cr4zyb4rd
Honestly, speed didn't really concern me, since it's not going very far if hunger/thirst is above the threshold of 5000.
It doesn't matter how far it's going..you're looping over it again and again with no delay == eating cycles.
I actually had issues when spamming heals/nukes where I would actually get a spell started in between the start of the mac and the time it got to waitforbagopen.
The way I understand it (though I've never looked) macros are given their own timeslice where it runs as many commands as it can every time a "macro pulse" happens. The upshot is that unless you have a /delay in there somewhere, everything should be pretty much atomic. Think of it as if your macro were looking at a "snapshot" of the game..unless you actually click something, cast a spell, put in a hard delay, the state of affairs game-wise isn't going to change much. That delay after the autoinventory probably came from my rough version.

The bag thing is fine, it's just that the bag being open is really the condition you should be checking for. I didn't know how to do that when I wrote the original.

Code: Select all

/delay 5s ${Window[${InvSlot[${mypack}].Name}].Open}
should probably work in place of the loop...if it takes more than 5 seconds for the bag to open, you have some other issue. :)

Posted: Tue Nov 02, 2004 10:34 am
by A_Druid_00
So basically, instead of:

Code: Select all

   /if (!${Window[${InvSlot[${mypack}].Name}].Open}) /nomodkey /itemnotify ${mypack} rightmouseup 
} 
:WaitForBagOpen 
   /nomodkey /ctrl /itemnotify ${myslot} leftmouseup 
   /if (!${Cursor.ID}) /goto :WaitForBagOpen 
Use:

Code: Select all

   /if (!${Window[${InvSlot[${mypack}].Name}].Open}) /nomodkey /itemnotify ${mypack} rightmouseup 
} 
   /delay 5s ${Window[${InvSlot[${mypack}].Name}].Open} 
   /nomodkey /ctrl /itemnotify ${myslot} leftmouseup 
I want to make sure it's right before I update the top post.

Posted: Tue Nov 02, 2004 2:05 pm
by Cr4zyb4rd
Looks right, but
I want to make sure it's right before I update the top post.
I suggest testing it. Only asshats like me post un-tested code.

Posted: Tue Nov 02, 2004 2:17 pm
by A_Druid_00
Hopefully I can get on Wednesday and give it a whirl then!