• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

Forage macro

Redbot

💻❤️
Moderator
Joined
Oct 15, 2004
RedCents
104,018¢
Pronouns
He/Him
From the MQ2 Free section, written by bootyjuice modified by mdar. Why am I posting it here then? Mdar's version had several bugs, and I got them worked out. Enjoy.

Rich (BB code):
|yafm.mac 
| 
|Yet Another Forage Macro 
| 
|Ini File: yafm.ini 
| 
| 0 = destroy 
| x = keep at most x of this item 
| 
|New foraged items are added to the ini file automatically and are kept by default. 


|||||||||||||||||||| 
| Main 
|||||||||||||||||||| 
sub Main 

    /declare DefaultMaxSave int outer 

    /varset DefaultMaxSave ${Ini[yafm.ini,Default,MaxSave,${NotFound}]} 
    /if (${DefaultMaxSave}==${NotFound}) { 
       /ini "yafm.ini" "Default" "MaxSave" "100" 
        /varset DefaultMaxSave 100 
    } 

   /cleanup 

   | Verify that we have the ability to forage. 
   /if (${Me.Skill[Forage]}==0) { 
      /echo You cannot forage, silly person! 
      /goto :Exit 
   } 

   :Forage 

   | If we can forage then do so. 
   /if (${Me.AbilityReady[Forage]}) { 
      | Stand up.  Can't forage while sitting. 
      /if (${Me.State.NotEqual[STAND]}) { 
         /stand 
         /delay 5 
      } 

      /doability forage 
   } 

   | If we successfully foraged something then take care of it. 
   /if (${Cursor.ID}) { 
      /call HandleItem 
   } 

   /goto :Forage 

:Exit 
/return 

|||||||||||||||||||| 
| HandleItem 
|||||||||||||||||||| 
sub HandleItem 

   /declare ItemSetting int local 
   /declare NotFound int local 
   /declare ItemsHave int local 

   /varset NotFound -1 

   :LootIt 

   | Look up this item in yafm.ini 
   /varset ItemSetting ${Ini[yafm.ini,ForageList,${Cursor.Name},${NotFound}]} 
   /delay 5 

   | If the item isn't in the .ini file then add it. 
   /if (${ItemSetting}==${NotFound}) { 
       /ini "yafm.ini" "ForageList" "${Cursor.Name}" "${DefaultMaxSave}" 
       /varset ItemSetting ${DefaultMaxSave} 
   } 

   /varset ItemsHave ${FindItem=${Cursor.Name}} 

   | If we're keeping this item then stash it in our bags. 
   | Otherwise, just destroy it. 
   /if (${ItemSetting}>${ItemsHave}) { 
     /autoinventory 
   } else { 
     /destroy 
   } 

   /delay 5 
   /if (${Cursor.ID}) /goto :LootIt 

/return

Instructions:
Copy the code and save it to a text file named "yafm.mac" using notepad or wordpad. Put yafm.mac into your macros folder(which should be in c:\mq2\release\macros or whatever you named your mq2 folder). Go into everquest and type "/macro yafm". Let it run for awhile, and then quit.

It will automatically create a file called "yafm.ini" in your macro folder. Open that file up with notepad and you can edit how much of each item you will keep. It will look like this:

Rich (BB code):
[Default] 
MaxSave=100 
[ForageList] 
Roots=0 
Pod of Water=0 
Berries=100 
Vegetables=100 
Fishing Grubs=0 
Fruit=100 
Griffon Eggs=100 
Rabbit Meat=100

For example, setting "pod of water" to 50 will let you forage up to 50 pods of water and will delete the rest.

Whatever you do, don't set defaultmax or maxsave to 0. That could destroy your equipment if you click on it! Set it to 10 or 100 and you'll be fine.
 
When I run this in WW I get this message ...

The current macro has ended.

and

You no longer have a target.
You no longer have a target.

Any ideas? I didn't have a target or any macros running. I was already standing up, and I am able to hit forage manually, but the macreo isn't hitting it.

NVM. I didn't have forage selected in the abilities window. It is always the simple stuff.
 
Hmm... since the last patch and release of MQ2 I have syntex erros in compiling. I know it used to work before but many many syntax errors with the new release 1-28 of MQ2

MQ2Forage.cpp
MQ2Forage.cpp(1) : error C2059: syntax error : '|'
MQ2Forage.cpp(5) : error C2143: syntax error : missing ';' before '.'
MQ2Forage.cpp(5) : error C2501: 'yafm' : missing storage-class or type specifier
s
MQ2Forage.cpp(20) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(20) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(21) : error C2059: syntax error : '/'
MQ2Forage.cpp(21) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(21) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(21) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(21) : error C2059: syntax error : '=='
MQ2Forage.cpp(21) : error C2059: syntax error : ')'
MQ2Forage.cpp(24) : error C2143: syntax error : missing ';' before '}'
MQ2Forage.cpp(24) : error C2059: syntax error : '}'
MQ2Forage.cpp(29) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(29) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(29) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(29) : error C2059: syntax error : '=='
MQ2Forage.cpp(29) : error C2059: syntax error : ')'
MQ2Forage.cpp(32) : error C2143: syntax error : missing ';' before '}'
MQ2Forage.cpp(32) : error C2501: 'Exit' : missing storage-class or type specifie
rs
MQ2Forage.cpp(32) : error C2143: syntax error : missing ';' before '}'
MQ2Forage.cpp(32) : error C2059: syntax error : '}'
MQ2Forage.cpp(36) : error C2143: syntax error : missing ';' before '|'
MQ2Forage.cpp(36) : error C2501: 'Forage' : missing storage-class or type specif
iers
MQ2Forage.cpp(37) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(37) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(37) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(37) : error C2059: syntax error : ')'
MQ2Forage.cpp(37) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(38) : error C2001: newline in constant
MQ2Forage.cpp(38) : error C2015: too many characters in constant
MQ2Forage.cpp(47) : error C2059: syntax error : '|'
MQ2Forage.cpp(48) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(48) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(48) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(48) : error C2059: syntax error : ')'
MQ2Forage.cpp(48) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(52) : error C2059: syntax error : '/'
MQ2Forage.cpp(54) : error C2470: 'Forage' : looks like a function definition, bu
t there is no formal parameter list; skipping apparent body
MQ2Forage.cpp(55) : error C2059: syntax error : '/'
MQ2Forage.cpp(72) : error C2059: syntax error : '/'
MQ2Forage.cpp(74) : error C2001: newline in constant
MQ2Forage.cpp(74) : error C2015: too many characters in constant
MQ2Forage.cpp(75) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(75) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(75) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(75) : error C2059: syntax error : '=='
MQ2Forage.cpp(75) : error C2059: syntax error : ')'
MQ2Forage.cpp(77) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(77) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(78) : error C2059: syntax error : '}'
MQ2Forage.cpp(78) : error C2143: syntax error : missing ';' before '}'
MQ2Forage.cpp(78) : error C2059: syntax error : '}'
MQ2Forage.cpp(80) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(80) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(82) : error C2059: syntax error : '|'
MQ2Forage.cpp(82) : error C2001: newline in constant
MQ2Forage.cpp(82) : error C2015: too many characters in constant
MQ2Forage.cpp(84) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(84) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(84) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(84) : error C2059: syntax error : '>'
MQ2Forage.cpp(84) : error C2059: syntax error : ')'
MQ2Forage.cpp(86) : error C2143: syntax error : missing ';' before '}'
MQ2Forage.cpp(86) : error C2059: syntax error : '}'
MQ2Forage.cpp(88) : error C2143: syntax error : missing ';' before '}'
MQ2Forage.cpp(88) : error C2059: syntax error : '}'
MQ2Forage.cpp(91) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(91) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(91) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(91) : error C2059: syntax error : ')'
MQ2Forage.cpp(91) : error C2059: syntax error : '/'
MQ2Forage.cpp(93) : error C2143: syntax error : missing ';' before '/'
MQ2Forage.cpp(93) : error C2501: 'LootIt' : missing storage-class or type specif
iers

ok I've double checked everything but i'm not a programming wiz, just know it worked before the patch and now this is what i get :(
 
Last edited:
blackbat said:
Hmm... since the last patch and release of MQ2 I have syntex erros in compiling. I know it used to work before but many many syntax errors with the new release 1-28 of MQ2

MQ2Forage.cpp
MQ2Forage.cpp(1) : error C2059: syntax error : '|'
MQ2Forage.cpp(5) : error C2143: syntax error : missing ';' before '.'
MQ2Forage.cpp(5) : error C2501: 'yafm' : missing storage-class or type specifier
s
MQ2Forage.cpp(20) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(20) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(21) : error C2059: syntax error : '/'
MQ2Forage.cpp(21) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(21) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(21) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(21) : error C2059: syntax error : '=='
MQ2Forage.cpp(21) : error C2059: syntax error : ')'
MQ2Forage.cpp(24) : error C2143: syntax error : missing ';' before '}'
MQ2Forage.cpp(24) : error C2059: syntax error : '}'
MQ2Forage.cpp(29) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(29) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(29) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(29) : error C2059: syntax error : '=='
MQ2Forage.cpp(29) : error C2059: syntax error : ')'
MQ2Forage.cpp(32) : error C2143: syntax error : missing ';' before '}'
MQ2Forage.cpp(32) : error C2501: 'Exit' : missing storage-class or type specifie
rs
MQ2Forage.cpp(32) : error C2143: syntax error : missing ';' before '}'
MQ2Forage.cpp(32) : error C2059: syntax error : '}'
MQ2Forage.cpp(36) : error C2143: syntax error : missing ';' before '|'
MQ2Forage.cpp(36) : error C2501: 'Forage' : missing storage-class or type specif
iers
MQ2Forage.cpp(37) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(37) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(37) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(37) : error C2059: syntax error : ')'
MQ2Forage.cpp(37) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(38) : error C2001: newline in constant
MQ2Forage.cpp(38) : error C2015: too many characters in constant
MQ2Forage.cpp(47) : error C2059: syntax error : '|'
MQ2Forage.cpp(48) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(48) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(48) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(48) : error C2059: syntax error : ')'
MQ2Forage.cpp(48) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(52) : error C2059: syntax error : '/'
MQ2Forage.cpp(54) : error C2470: 'Forage' : looks like a function definition, bu
t there is no formal parameter list; skipping apparent body
MQ2Forage.cpp(55) : error C2059: syntax error : '/'
MQ2Forage.cpp(72) : error C2059: syntax error : '/'
MQ2Forage.cpp(74) : error C2001: newline in constant
MQ2Forage.cpp(74) : error C2015: too many characters in constant
MQ2Forage.cpp(75) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(75) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(75) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(75) : error C2059: syntax error : '=='
MQ2Forage.cpp(75) : error C2059: syntax error : ')'
MQ2Forage.cpp(77) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(77) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(78) : error C2059: syntax error : '}'
MQ2Forage.cpp(78) : error C2143: syntax error : missing ';' before '}'
MQ2Forage.cpp(78) : error C2059: syntax error : '}'
MQ2Forage.cpp(80) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(80) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(82) : error C2059: syntax error : '|'
MQ2Forage.cpp(82) : error C2001: newline in constant
MQ2Forage.cpp(82) : error C2015: too many characters in constant
MQ2Forage.cpp(84) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(84) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(84) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(84) : error C2059: syntax error : '>'
MQ2Forage.cpp(84) : error C2059: syntax error : ')'
MQ2Forage.cpp(86) : error C2143: syntax error : missing ';' before '}'
MQ2Forage.cpp(86) : error C2059: syntax error : '}'
MQ2Forage.cpp(88) : error C2143: syntax error : missing ';' before '}'
MQ2Forage.cpp(88) : error C2059: syntax error : '}'
MQ2Forage.cpp(91) : error C2143: syntax error : missing ')' before '{'
MQ2Forage.cpp(91) : error C2143: syntax error : missing ';' before '{'
MQ2Forage.cpp(91) : error C2447: '{' : missing function header (old-style formal
list?)
MQ2Forage.cpp(91) : error C2059: syntax error : ')'
MQ2Forage.cpp(91) : error C2059: syntax error : '/'
MQ2Forage.cpp(93) : error C2143: syntax error : missing ';' before '/'
MQ2Forage.cpp(93) : error C2501: 'LootIt' : missing storage-class or type specif
iers

ok I've double checked everything but i'm not a programming wiz, just know it worked before the patch and now this is what i get :(

Check that you didn't delete any of the }'s ;'s ect anyware if you deleted any of them it will fuck the rest of it up
 
lol nope I coppied the .cppfile backup i had (from before any of my compile) didnt touch the text at all
 
Guys, it's a macro. You're not supposed to compile it :P

Copy it and paste it to notepad, then save it as forage.mac and put it in your release/macros folder.
 
I can't seem to get this to work, which is not surprising since I am a newb to this. I have the macro where it should be, I type in /macro yafm. At this point nothing really happens, it says "you have lost your current target" in my main chat window, and the file that is generated only contains [Default]
MaxSave=100. Any help on how to make it work would be swell.

NM - it seems to be working now =)
 
Last edited:
Nice, i will start to use this actually (Can i run 2 diff WinEQ's and 1 have it just forage and the other do my normal bard macroing? Or will they conflict one another?)
Also, When i run it and i get off, if that zone has more forajable *lol* items, will it list those also? Or should i just add the names and # of them that i was on it?
Thanks in Advanced! :p
 
bah, macro? what for?
Use the PLUGIN *cackle*
Rich (BB code):
/* 
   MQ2AutoForage 

   Simple plugin to automate the tast of foraging (and eventually fishing). 

   Syntax: 

   /startforage         - commence autoforaging. 
   /stopforage            - stop autoforaging. 
   /keepitem {item}      - add/change the item in the .ini file to auto-keep. 
   /destroyitem {item}      - add/change the item in the .ini file to auto-destroy. 

   NB: Parts of this code shamelessly stolen from other plugins on this board. 
       When complete i will work out the full list of acknowledements. 

   TODO: 
   -  Add fishing to plugin 
   -  Add detection if in a trade window 
   -  Add detection if forage/fish is a legitimate ability 
   -  BIG code tidy up 
   -  Comment code 


   DONE: 
   -  Add ability to modify ini file on-the-fly from within game. 
   -  Add ability to read/write to ini file to decide 
      whether to keep/destroy items 
   -  Add combat detection 
*/ 

#include "../MQ2Plugin.h" 

PreSetup("MQ2AutoForage"); 

void StartForageCommand(PSPAWNINFO pChar, PCHAR szLine); 
void StopForageCommand(PSPAWNINFO pChar, PCHAR szLine); 
void KeepItemCommand(PSPAWNINFO pChar, PCHAR szLine); 
void DestroyItemCommand(PSPAWNINFO pChar, PCHAR szLine); 
bool CheckAbilityReady(PCHAR szSkillName); 
void HandleItem(PCHARINFO pCharInfo); 
void Load_INI(VOID); 
bool Check_INI(VOID); 

bool IsForaging=false; 
bool HasForaged=false; 
bool ForageSuccess=false; 
bool KeepDestroy=false; 
bool KeepItem=false; 
bool WasSitting=false; 
bool AutoKeepEnabled=true; 
bool AutoAddEnabled=true; 
bool MQ2ForageEnabled=false; 

PLUGIN_API VOID InitializePlugin(VOID) 
{ 
   AddCommand("/startforage",StartForageCommand); 
   AddCommand("/stopforage",StopForageCommand); 
   AddCommand("/keepitem",KeepItemCommand); 
   AddCommand("/destroyitem",DestroyItemCommand); 
    
   if (MQ2Globals::gGameState==GAMESTATE_INGAME) { 
      if (GetCharInfo()) { 
         sprintf(INIFileName,"%s\\MQ2Forage_%s_%s.ini",gszINIPath,GetCharInfo()->Name,GetCharInfo()->Server); 
         Load_INI(); 
         MQ2ForageEnabled=true; 
      } 
   } else MQ2ForageEnabled=false; 
} 

PLUGIN_API VOID ShutdownPlugin(VOID) 
{ 
   RemoveCommand("/startforage"); 
   RemoveCommand("/stopforage"); 
} 

PLUGIN_API VOID OnZoned(VOID) 
{ 
   Load_INI(); 
} 

PLUGIN_API VOID OnPulse(VOID) 
{ 

   if (!MQ2ForageEnabled) 
   { 
      return; 
   } 

   PSPAWNINFO pChSpawn = GetCharInfo()->pSpawn; 
   PCHARINFO pCharInfo = NULL; 

   if ((IsForaging) && !(*EQADDR_ATTACK > 0)) { 
      if (CheckAbilityReady("Forage")) 
      { 
         if (pChSpawn->StandState == STANDSTATE_SIT) { 
            DoCommand(pChSpawn, "/stand"); 
            WasSitting=true; 
         } else if (pChSpawn->pActorInfo->SpellETA == 0) { 
            HasForaged=true; 
            DoAbility(pChSpawn,"Forage"); 
         } 
      } 
   } 

   if (ForageSuccess) 
   { 
      if (NULL == (pCharInfo = GetCharInfo())) return; 

      if (pCharInfo->Cursor) { 
         ForageSuccess=false; 
         HandleItem(pCharInfo); 
      } 
   } 

   if (!ForageSuccess && KeepDestroy) { 
      if (NULL == (pCharInfo = GetCharInfo())) return; 

      if (pCharInfo->Cursor && KeepItem) { 
         DoCommand(pChSpawn, "/autoinventory"); 
      } else if (pCharInfo->Cursor && !KeepItem) { 
         DoCommand(pChSpawn, "/destroy"); 
      } else if (!pCharInfo->Cursor) { 
         KeepDestroy=false; 
         KeepItem=false; 
         HasForaged=false; 
      } 
      if (WasSitting) { 
         WasSitting=false; 
         DoCommand(pChSpawn, "/sit"); 
      } 
   } 
} 

PLUGIN_API DWORD OnIncomingChat(PCHAR Line, DWORD Color) 
{ 
   if (HasForaged && strstr(Line, "You have scrounged up")) 
   { 
      ForageSuccess=true; 
   } 
   else if (HasForaged && strstr(Line, "You fail to locate")) 
   { 
      ForageSuccess=false; 
      HasForaged=false; 
      KeepItem=false; 
      KeepDestroy=false; 
   } 
   return 0; 
} 


PLUGIN_API void SetGameState(DWORD GameState) 
{ 
   if (GameState==GAMESTATE_INGAME) { 
      if (GetCharInfo()) { 
         sprintf(INIFileName,"%s\\MQ2Forage_%s_%s.ini",gszINIPath,GetCharInfo()->Name,GetCharInfo()->Server); 
         Load_INI(); 
         MQ2ForageEnabled=true; 
      } 
   } else { 
      MQ2ForageEnabled=false; 
   } 
} 

void StartForageCommand(PSPAWNINFO pChar, PCHAR szLine){ 
   if (MQ2ForageEnabled) { 
      WriteChatColor("Auto-Forage Enabled",CONCOLOR_GREEN); 
      IsForaging=true; 
   } 
} 

void StopForageCommand(PSPAWNINFO pChar, PCHAR szLine){ 
   if (MQ2ForageEnabled) { 
      WriteChatColor("Auto-Forage Disabled",CONCOLOR_RED); 
      IsForaging=false; 
   } 
} 

void KeepItemCommand(PSPAWNINFO pChar, PCHAR szLine){ 
   char szZone[64]; 
   char szMsg[MAX_STRING]; 
   PCHARINFO pCharInfo = GetCharInfo(); 

   if (MQ2ForageEnabled) { 
      sprintf(szMsg, "Now auto-keeping item: %s", szLine); 
      WriteChatColor(szMsg, CONCOLOR_YELLOW); 
      sprintf(szZone,"%s",GetFullZone(pCharInfo->zoneId)); 
      WritePrivateProfileString(szZone,szLine,"keep",INIFileName); 
   } 
} 

void DestroyItemCommand(PSPAWNINFO pChar, PCHAR szLine){ 
   char szZone[64]; 
   char szMsg[MAX_STRING]; 
   PCHARINFO pCharInfo = GetCharInfo(); 

   if (MQ2ForageEnabled) { 
      sprintf(szMsg, "Now auto-destroying item: %s", szLine); 
      WriteChatColor(szMsg, CONCOLOR_YELLOW); 
      sprintf(szZone,"%s",GetFullZone(pCharInfo->zoneId)); 
      WritePrivateProfileString(szZone,szLine,"destroy",INIFileName); 
   } 
} 
bool CheckAbilityReady(PCHAR szSkillName) 
{ 
   for (DWORD nSkill=0;szSkills[nSkill];nSkill++) { 
      if (!stricmp(szSkillName,szSkills[nSkill])) { 
         if (GetCharInfo()->Skill[nSkill]>252) { 
            return false; 
         } 
         for (DWORD nAbility=0;nAbility<10;nAbility++) { 
            if (EQADDR_DOABILITYLIST[nAbility] == nSkill) { 
               if (nAbility<4) { 
                  nAbility+=7; 
               } else { 
                  nAbility-=3; 
               } 
             
               if (SkillDict[nSkill]->AltTimer==2) { 
                  return gbAltTimerReady?true:false; 
               } else { 
                  return EQADDR_DOABILITYAVAILABLE[nSkill]?true:false; 
               } 
            } 
         } 
      } 
   } 
   return false; 
} 

void HandleItem(PCHARINFO pCharInfo){ 
   CHAR szMsg[MAX_STRING] = {0}; 
   CHAR szItem[64] = {0}; 
   PSPAWNINFO pChSpawn = GetCharInfo()->pSpawn; 

   sprintf(szItem,"%s",pCharInfo->Cursor->Item->Name); 
    
   KeepDestroy=true; 

   KeepItem=Check_INI(); 

   if (KeepItem) { 
      sprintf(szMsg, "Keeping: %s", szItem); 
      WriteChatColor(szMsg,CONCOLOR_GREEN); 
   } else { 
      sprintf(szMsg, "Destroying: %s", szItem); 
      WriteChatColor(szMsg,CONCOLOR_RED); 
   } 
} 

void Load_INI(VOID) 
{ 
   char szTemp[MAX_STRING]; 

   GetPrivateProfileString("General","AutoKeepAll","NULL",szTemp,MAX_STRING,INIFileName); 
   if (strstr(szTemp,"NULL")) { 
      WriteChatColor("MQ2Forage: INI not found, creating defaults.", CONCOLOR_RED); 
      WritePrivateProfileString("General","AutoKeepAll","on",INIFileName); 
      WritePrivateProfileString("General","AutoAddAll","on",INIFileName); 
   } else { 
      GetPrivateProfileString("General","AutoKeepAll","NULL",szTemp,MAX_STRING,INIFileName); 
      if ((strcmp(szTemp,"NULL"))||strcmp(szTemp,"on")) { 
         AutoKeepEnabled=true; 
      } else { 
         AutoKeepEnabled=false; 
      } 
   } 

   GetPrivateProfileString("General","AutoAddAll","NULL",szTemp,MAX_STRING,INIFileName); 
   if ((strcmp(szTemp,"NULL"))||strcmp(szTemp,"on")) { 
      AutoAddEnabled=true; 
   } else { 
      AutoAddEnabled=false; 
   } 
} 

bool Check_INI(VOID) 
{ 
   char szTemp[MAX_STRING]; 
   char szKeep[MAX_STRING]; 
   char szItem[64]; 
   char szZone[64]; 
   char szMsg1[MAX_STRING]; 
   bool ItemSetting=false; 

   PCHARINFO pChar = GetCharInfo(); 

   sprintf(szItem,"%s",pChar->Cursor->Item->Name); 
   sprintf(szZone,"%s",GetFullZone(pChar->zoneId)); 
   sprintf(szKeep,"%s",AutoKeepEnabled?"keep":"destroy"); 

   GetPrivateProfileString(szZone,szItem,"NULL",szTemp,MAX_STRING,INIFileName); 
   if (strstr(szTemp,"NULL")) { 
      if (AutoKeepEnabled) { 
         ItemSetting=true; 
      } 
    
      if (AutoAddEnabled) { 
         WritePrivateProfileString(szZone,szItem,szKeep,INIFileName); 
      } 
   } else if (strstr(szTemp,"keep")) { 
      ItemSetting=true; 
   } else if (strstr(szTemp,"destroy")) { 
      ItemSetting=false; 
   } else { 
      sprintf(szMsg1, "MQ2Forage: Bad status in ini for item %s in zone %s. Using global setting.",szItem,szZone); 
      WriteChatColor(szMsg1, CONCOLOR_RED); 
      if (AutoKeepEnabled) { 
         ItemSetting=true; 
      } 
   } 

   return ItemSetting; 
}
 
This works great. I left my Ranger in Broodlands all day and when I got home, I found he had died. :mad: (Hide failed) When I went to get my corpse I was thinking that I had nothing. To my surprised...I had so much stuff I had to delete things just to fill bags because he was still foraging at bind point. Some items were selling in bazaar for 150pp each.

Was an awesome way to make 3.1k and get forage to (191) AFK. :D
 
jmustful said:
This works great. I left my Ranger in Broodlands all day and when I got home, I found he had died. :mad: (Hide failed) When I went to get my corpse I was thinking that I had nothing. To my surprised...I had so much stuff I had to delete things just to fill bags because he was still foraging at bind point. Some items were selling in bazaar for 150pp each.

Was an awesome way to make 3.1k and get forage to (191) AFK. :D

/add to 'success stories' :)
 
How hard would it be to add some code in the forage macro to check to see if you are taking damage and either /gate or /q out of game so if you do die the res timer won't expire.

EDIT: Or, anyone know a safe place to forage in DoN? I tried Thundercrest Isles, the zone in is pretty safe. There is a place you can get where it should be safe even if someone trains the zone out, but people can still be dicks and train the mobs to you which I found out the other day. Wish I had logging on so I could know who did it. Maybe we can /warp under the world and forage all day there.
 
if you want... just use the no fall damage offset and warp ont he Z axis to be under the world and forage there
 
are you compiling the rest of macroquest2 with it?
 
Useing the fishing drinking forageing macro instead.
 
Last edited:
siddin said:
bah, macro? what for?
Use the PLUGIN *cackle*
Rich (BB code):
/* 
   MQ2AutoForage 

   Simple plugin to automate the tast of foraging (and eventually fishing). 

   Syntax: 

   /startforage         - commence autoforaging. 
   /stopforage            - stop autoforaging. 
   /keepitem {item}      - add/change the item in the .ini file to auto-keep. 
   /destroyitem {item}      - add/change the item in the .ini file to auto-destroy. 

   NB: Parts of this code shamelessly stolen from other plugins on this board. 
       When complete i will work out the full list of acknowledements. 

   TODO: 
   -  Add fishing to plugin 
   -  Add detection if in a trade window 
   -  Add detection if forage/fish is a legitimate ability 
   -  BIG code tidy up 
   -  Comment code 


   DONE: 
   -  Add ability to modify ini file on-the-fly from within game. 
   -  Add ability to read/write to ini file to decide 
      whether to keep/destroy items 
   -  Add combat detection 
*/ 

#include "../MQ2Plugin.h" 

PreSetup("MQ2AutoForage"); 

void StartForageCommand(PSPAWNINFO pChar, PCHAR szLine); 
void StopForageCommand(PSPAWNINFO pChar, PCHAR szLine); 
void KeepItemCommand(PSPAWNINFO pChar, PCHAR szLine); 
void DestroyItemCommand(PSPAWNINFO pChar, PCHAR szLine); 
bool CheckAbilityReady(PCHAR szSkillName); 
void HandleItem(PCHARINFO pCharInfo); 
void Load_INI(VOID); 
bool Check_INI(VOID); 

bool IsForaging=false; 
bool HasForaged=false; 
bool ForageSuccess=false; 
bool KeepDestroy=false; 
bool KeepItem=false; 
bool WasSitting=false; 
bool AutoKeepEnabled=true; 
bool AutoAddEnabled=true; 
bool MQ2ForageEnabled=false; 

PLUGIN_API VOID InitializePlugin(VOID) 
{ 
   AddCommand("/startforage",StartForageCommand); 
   AddCommand("/stopforage",StopForageCommand); 
   AddCommand("/keepitem",KeepItemCommand); 
   AddCommand("/destroyitem",DestroyItemCommand); 
    
   if (MQ2Globals::gGameState==GAMESTATE_INGAME) { 
      if (GetCharInfo()) { 
         sprintf(INIFileName,"%s\\MQ2Forage_%s_%s.ini",gszINIPath,GetCharInfo()->Name,GetCharInfo()->Server); 
         Load_INI(); 
         MQ2ForageEnabled=true; 
      } 
   } else MQ2ForageEnabled=false; 
} 

PLUGIN_API VOID ShutdownPlugin(VOID) 
{ 
   RemoveCommand("/startforage"); 
   RemoveCommand("/stopforage"); 
} 

PLUGIN_API VOID OnZoned(VOID) 
{ 
   Load_INI(); 
} 

PLUGIN_API VOID OnPulse(VOID) 
{ 

   if (!MQ2ForageEnabled) 
   { 
      return; 
   } 

   PSPAWNINFO pChSpawn = GetCharInfo()->pSpawn; 
   PCHARINFO pCharInfo = NULL; 

   if ((IsForaging) && !(*EQADDR_ATTACK > 0)) { 
      if (CheckAbilityReady("Forage")) 
      { 
         if (pChSpawn->StandState == STANDSTATE_SIT) { 
            DoCommand(pChSpawn, "/stand"); 
            WasSitting=true; 
         } else if (pChSpawn->pActorInfo->SpellETA == 0) { 
            HasForaged=true; 
            DoAbility(pChSpawn,"Forage"); 
         } 
      } 
   } 

   if (ForageSuccess) 
   { 
      if (NULL == (pCharInfo = GetCharInfo())) return; 

      if (pCharInfo->Cursor) { 
         ForageSuccess=false; 
         HandleItem(pCharInfo); 
      } 
   } 

   if (!ForageSuccess && KeepDestroy) { 
      if (NULL == (pCharInfo = GetCharInfo())) return; 

      if (pCharInfo->Cursor && KeepItem) { 
         DoCommand(pChSpawn, "/autoinventory"); 
      } else if (pCharInfo->Cursor && !KeepItem) { 
         DoCommand(pChSpawn, "/destroy"); 
      } else if (!pCharInfo->Cursor) { 
         KeepDestroy=false; 
         KeepItem=false; 
         HasForaged=false; 
      } 
      if (WasSitting) { 
         WasSitting=false; 
         DoCommand(pChSpawn, "/sit"); 
      } 
   } 
} 

PLUGIN_API DWORD OnIncomingChat(PCHAR Line, DWORD Color) 
{ 
   if (HasForaged && strstr(Line, "You have scrounged up")) 
   { 
      ForageSuccess=true; 
   } 
   else if (HasForaged && strstr(Line, "You fail to locate")) 
   { 
      ForageSuccess=false; 
      HasForaged=false; 
      KeepItem=false; 
      KeepDestroy=false; 
   } 
   return 0; 
} 


PLUGIN_API void SetGameState(DWORD GameState) 
{ 
   if (GameState==GAMESTATE_INGAME) { 
      if (GetCharInfo()) { 
         sprintf(INIFileName,"%s\\MQ2Forage_%s_%s.ini",gszINIPath,GetCharInfo()->Name,GetCharInfo()->Server); 
         Load_INI(); 
         MQ2ForageEnabled=true; 
      } 
   } else { 
      MQ2ForageEnabled=false; 
   } 
} 

void StartForageCommand(PSPAWNINFO pChar, PCHAR szLine){ 
   if (MQ2ForageEnabled) { 
      WriteChatColor("Auto-Forage Enabled",CONCOLOR_GREEN); 
      IsForaging=true; 
   } 
} 

void StopForageCommand(PSPAWNINFO pChar, PCHAR szLine){ 
   if (MQ2ForageEnabled) { 
      WriteChatColor("Auto-Forage Disabled",CONCOLOR_RED); 
      IsForaging=false; 
   } 
} 

void KeepItemCommand(PSPAWNINFO pChar, PCHAR szLine){ 
   char szZone[64]; 
   char szMsg[MAX_STRING]; 
   PCHARINFO pCharInfo = GetCharInfo(); 

   if (MQ2ForageEnabled) { 
      sprintf(szMsg, "Now auto-keeping item: %s", szLine); 
      WriteChatColor(szMsg, CONCOLOR_YELLOW); 
      sprintf(szZone,"%s",GetFullZone(pCharInfo->zoneId)); 
      WritePrivateProfileString(szZone,szLine,"keep",INIFileName); 
   } 
} 

void DestroyItemCommand(PSPAWNINFO pChar, PCHAR szLine){ 
   char szZone[64]; 
   char szMsg[MAX_STRING]; 
   PCHARINFO pCharInfo = GetCharInfo(); 

   if (MQ2ForageEnabled) { 
      sprintf(szMsg, "Now auto-destroying item: %s", szLine); 
      WriteChatColor(szMsg, CONCOLOR_YELLOW); 
      sprintf(szZone,"%s",GetFullZone(pCharInfo->zoneId)); 
      WritePrivateProfileString(szZone,szLine,"destroy",INIFileName); 
   } 
} 
bool CheckAbilityReady(PCHAR szSkillName) 
{ 
   for (DWORD nSkill=0;szSkills[nSkill];nSkill++) { 
      if (!stricmp(szSkillName,szSkills[nSkill])) { 
         if (GetCharInfo()->Skill[nSkill]>252) { 
            return false; 
         } 
         for (DWORD nAbility=0;nAbility<10;nAbility++) { 
            if (EQADDR_DOABILITYLIST[nAbility] == nSkill) { 
               if (nAbility<4) { 
                  nAbility+=7; 
               } else { 
                  nAbility-=3; 
               } 
             
               if (SkillDict[nSkill]->AltTimer==2) { 
                  return gbAltTimerReady?true:false; 
               } else { 
                  return EQADDR_DOABILITYAVAILABLE[nSkill]?true:false; 
               } 
            } 
         } 
      } 
   } 
   return false; 
} 

void HandleItem(PCHARINFO pCharInfo){ 
   CHAR szMsg[MAX_STRING] = {0}; 
   CHAR szItem[64] = {0}; 
   PSPAWNINFO pChSpawn = GetCharInfo()->pSpawn; 

   sprintf(szItem,"%s",pCharInfo->Cursor->Item->Name); 
    
   KeepDestroy=true; 

   KeepItem=Check_INI(); 

   if (KeepItem) { 
      sprintf(szMsg, "Keeping: %s", szItem); 
      WriteChatColor(szMsg,CONCOLOR_GREEN); 
   } else { 
      sprintf(szMsg, "Destroying: %s", szItem); 
      WriteChatColor(szMsg,CONCOLOR_RED); 
   } 
} 

void Load_INI(VOID) 
{ 
   char szTemp[MAX_STRING]; 

   GetPrivateProfileString("General","AutoKeepAll","NULL",szTemp,MAX_STRING,INIFileName); 
   if (strstr(szTemp,"NULL")) { 
      WriteChatColor("MQ2Forage: INI not found, creating defaults.", CONCOLOR_RED); 
      WritePrivateProfileString("General","AutoKeepAll","on",INIFileName); 
      WritePrivateProfileString("General","AutoAddAll","on",INIFileName); 
   } else { 
      GetPrivateProfileString("General","AutoKeepAll","NULL",szTemp,MAX_STRING,INIFileName); 
      if ((strcmp(szTemp,"NULL"))||strcmp(szTemp,"on")) { 
         AutoKeepEnabled=true; 
      } else { 
         AutoKeepEnabled=false; 
      } 
   } 

   GetPrivateProfileString("General","AutoAddAll","NULL",szTemp,MAX_STRING,INIFileName); 
   if ((strcmp(szTemp,"NULL"))||strcmp(szTemp,"on")) { 
      AutoAddEnabled=true; 
   } else { 
      AutoAddEnabled=false; 
   } 
} 

bool Check_INI(VOID) 
{ 
   char szTemp[MAX_STRING]; 
   char szKeep[MAX_STRING]; 
   char szItem[64]; 
   char szZone[64]; 
   char szMsg1[MAX_STRING]; 
   bool ItemSetting=false; 

   PCHARINFO pChar = GetCharInfo(); 

   sprintf(szItem,"%s",pChar->Cursor->Item->Name); 
   sprintf(szZone,"%s",GetFullZone(pChar->zoneId)); 
   sprintf(szKeep,"%s",AutoKeepEnabled?"keep":"destroy"); 

   GetPrivateProfileString(szZone,szItem,"NULL",szTemp,MAX_STRING,INIFileName); 
   if (strstr(szTemp,"NULL")) { 
      if (AutoKeepEnabled) { 
         ItemSetting=true; 
      } 
    
      if (AutoAddEnabled) { 
         WritePrivateProfileString(szZone,szItem,szKeep,INIFileName); 
      } 
   } else if (strstr(szTemp,"keep")) { 
      ItemSetting=true; 
   } else if (strstr(szTemp,"destroy")) { 
      ItemSetting=false; 
   } else { 
      sprintf(szMsg1, "MQ2Forage: Bad status in ini for item %s in zone %s. Using global setting.",szItem,szZone); 
      WriteChatColor(szMsg1, CONCOLOR_RED); 
      if (AutoKeepEnabled) { 
         ItemSetting=true; 
      } 
   } 

   return ItemSetting; 
}
This will sound really stupid... but I don't have any idea how to go about using this. I'm sorry to bother you, but could you please explain this to me?
 
what exactly do u not understand? kinda hard to awnser such a vague question hehe..do u mean as far as compiling it or using it in game or......? let us know so we can actually be able to awnser u correctly =P
 
Katrav said:
This will sound really stupid... but I don't have any idea how to go about using this. I'm sorry to bother you, but could you please explain this to me?


I think he's asking how to use it.

/plugin mq2autoforage
/mac forage
 
ok i tried the plugin and it said no ini file then it said making default but then i tried it and it just does nothing and for the mac when i try the yafm.mac it say's lost target marco ended any help would be great on how i could make them work
 
I had some serious bugs with Yafm ... took me a bit to fix it all. If you can't get the plugin to work I can post my yafm mod / my Advforage.mac.
 
ok i tried the plugin and it said no ini file then it said making default but then i tried it and it just does nothing and for the mac when i try the yafm.mac it say's lost target marco ended any help would be great on how i could make them work


you have to set up a forage hotbutton in your actions tab. That will solve that prob with the mac. The plugin only told you that because you did not already have an .ini file set up telling the plugin what to keep or destroy. The plugin made one automatically and as of now everything is set to save.
 
shadowman33 said:
you have to set up a forage hotbutton in your actions tab. That will solve that prob with the mac. The plugin only told you that because you did not already have an .ini file set up telling the plugin what to keep or destroy. The plugin made one automatically and as of now everything is set to save.


I already have a forage hotbutton made and the mac still wont work ................................... Now about the ini. this is what mine looks like

[Default]
MaxSave=100

should i make it look like the one posted by red bot???
 
well it looks like that because it has not gathered anything yet. When you start to forage stuff, the ini will update itself to keep everything you pick up I believe up to a quantity of 100. You need to go back into the ini and change the value to how many you want to save of whatever item you are foraging. Now as for the hotbutton, do you have a hotbutton set up say where 1-0 is like for melee, etc.? You need to set up the hotbutton in the actions window, like where find,sit/run, etc. At the top of that window click on the tabs till you see the abilities page. That is where it needs to be set up at so it is the same as typing /doability. If that is where you have it already, then I am sorry I do not know why it will not work for you. I have used yafm since it came out and have never had a single moments problem with it. For that matter, the plugin has always worked perfectly also.
 
You are missing the [Forage List]

Rich (BB code):
[Default] 
MaxSave=100 
[ForageList] 
Roots=0
 
eqlover said:
How hard would it be to add some code in the forage macro to check to see if you are taking damage and either /gate or /q out of game so if you do die the res timer won't expire.

EDIT: Or, anyone know a safe place to forage in DoN? I tried Thundercrest Isles, the zone in is pretty safe. There is a place you can get where it should be safe even if someone trains the zone out, but people can still be dicks and train the mobs to you which I found out the other day. Wish I had logging on so I could know who did it. Maybe we can /warp under the world and forage all day there.
use the nokos in ultrawarp
 
yes, mac yafm does work but getting it to stop ingame is a mystery atm. lol
 
just load up another mac you can end and fire it then stop that one ...
 
Army can you post a good forage macro that is working, all mine are broken. mq2autofrage does not work either..
 
the forage macro i am using...

use like any ther macro

/mac forage (or whatever name you give it)

ENSURE YAFM.ini is in macro directory

and end macro /end

to easy

8-)

Rich (BB code):
|yafm.mac 
| 
|Yet Another Forage Macro 
| 
|Ini File: yafm.ini 
| 
| 0 = destroy 
| x = keep at most x of this item 
| 
|New foraged items are added to the ini file automatically and are kept by default. 


|||||||||||||||||||| 
| Main 
|||||||||||||||||||| 
sub Main 

    /declare DefaultMaxSave int outer 

    /varset DefaultMaxSave ${Ini[yafm.ini,Default,MaxSave,${NotFound}]} 
    /if (${DefaultMaxSave}==${NotFound}) { 
       /ini "yafm.ini" "Default" "MaxSave" "100" 
        /varset DefaultMaxSave 100 
    } 

   /cleanup 

   | Verify that we have the ability to forage. 
   /if (${Me.Skill[Forage]}==0) { 
      /echo You cannot forage, silly person! 
      /goto :Exit 
   } 

   :Forage 

   | If we can forage then do so. 
   /if (${Me.AbilityReady[Forage]}) { 
      | Stand up.  Can't forage while sitting. 
      /if (${Me.State.NotEqual[STAND]}) { 
         /stand 
         /delay 5 
      } 

      /doability forage 
   } 

   | If we successfully foraged something then take care of it. 
   /if (${Cursor.ID}) { 
      /call HandleItem 
   } 

   /goto :Forage 

:Exit 
/return 

|||||||||||||||||||| 
| HandleItem 
|||||||||||||||||||| 
sub HandleItem 

   /declare ItemSetting int local 
   /declare NotFound int local 
   /declare ItemsHave int local 

   /varset NotFound -1 

   :LootIt 

   | Look up this item in yafm.ini 
   /varset ItemSetting ${Ini[yafm.ini,ForageList,${Cursor.Name},${NotFound}]} 
   /delay 5 

   | If the item isn't in the .ini file then add it. 
   /if (${ItemSetting}==${NotFound}) { 
       /ini "yafm.ini" "ForageList" "${Cursor.Name}" "${DefaultMaxSave}" 
       /varset ItemSetting ${DefaultMaxSave} 
   } 

   /varset ItemsHave ${FindItem=${Cursor.Name}} 

   | If we're keeping this item then stash it in our bags. 
   | Otherwise, just destroy it. 
   /if (${ItemSetting}>${ItemsHave}) { 
     /autoinventory 
   } else { 
     /destroy 
   } 

   /delay 5 
   /if (${Cursor.ID}) /goto :LootIt 

/return

the YAFM.ini

Rich (BB code):
[Default]
MaxSave=100
[ForageList]
Rabbit Meat=100
Pod of Water=100
Fruit=100
Berries=100
Pine Sap=100
Fishing Grubs=100
Shadowjade Fern Seeds=100
Roots=100
Frozen Crystal Shard=100
Mask of Deception=100
NULL=100
Shadowjade Fern Leaves=100
Arctic Mussels=40
Glob of Slush Water=40
Arctic Scallop=40
Small Chunk of Velium=0
Tuft of Dire Wolf Fur=10000

Iron Ration=100
Fuzzlecutter Formula 5000=100
Trader's Satchel=100
 
How to turn off a macro? I treid /marco forage
said it ended put was actually still running.



Nubie Posted before I read that last post... /end works just fine and great macro too!
 
/endmac works

if you type /mac forage, it will end the current macro, and star the one you typed in, so it will just re-initilize the forage macro again.
 
I have no idea what I am doing wrong. I have 2 characters in the same zone on the same computer with the same command /startforage and one of them is foraging and the other one isn't but it say it was enabled but only one is working. Since this is not a mac I do not know where to begin to look for the problem. Any suggestions? I am using the MQ2AutoForage.
 
Forage macro

Users who are viewing this thread

Back
Top
Cart