• Hail, we're RedGuides. We want you to play six (yes, 6!) EverQuest characters at once. We have scripts and a friendly community to help, please join our playstyle and say hello! 👋
  • We've added LLM sections to our Terms & Rules and Resource Rules, for everyone's sanity & in-game safety.
    Read more
    a. Do not replace your voice with an LLM. This goes for your posts and your scripts. Drafting and editing with a tool is fine, but don't take you out of what you share.
    b. Do not replace your EQ character's voice with an LLM. We don't want scripts that speak over /ooc, /shout or other public channels. This has been an unwritten rule that's kept casino scripts off the site for decades, but we're now compelled to make it clear: keep automated communication private.

    Why Does RG Review Scripts?
    Nearly every LLM-written Lua script we see is making your character do impossible things, and rarely in a way that's beneficial to you. We've seen heavy server hammering, /target over impossible distances when /nav spawn would passively accomplish the same thing, a spawn search that fires 20+ times per second, and other pointless actions that are likely annoying GMs.

    You are welcome to use LLMs as a tool to structure, draft, and edit your work, but please read critically before hitting /lua run

MQ2Fishing

Alatyami

NotAddicted.com Engineer (Retired)
Based largely on HTW's MQ2AutoForage, read the notes for the author's credits.

MQ2Fishing.cpp
Rich (BB code):
/*
Alatyami's fishing modification to HTW's MQ2AutoForage (http://www.macroquest2.com, Nov 18, 2005).

Syntax:
   /startfishing			- Start Fishing
   /stopfishing				- Stop Fishing
   /keepitem [item]			- Add Item to keep list
   /destroyitem [item]		- Add Item to destroylist

MQ2Fishing Modification List

[05/08/2006] - Alatyami 
	* Added in chat event for running out of bait.
	* Removed Forage commands and coverted for fishing.
	* Changed INI for fishing.
        * Gave the chat a fisherman's flavor.

TO DO LIST:
	* Handle equiping poles when they break.
	* Add in Fishing Companion usage.

*/
#include "../MQ2Plugin.h"

PreSetup("MQ2Fishing");

void StartFishingCommand(PSPAWNINFO pChar, PCHAR szLine);
void StopFishingCommand(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 IsFishing=false;
bool HasFished=false;
bool FishingSuccess=false;
bool KeepDestroy=false;
bool KeepItem=false;
bool WasSitting=false;
bool AutoKeepEnabled=true;
bool AutoAddEnabled=true;
bool MQ2FishingEnabled=false;

PLUGIN_API VOID InitializePlugin(VOID)
{
   AddCommand("/startfishing",StartFishingCommand);
   AddCommand("/stopfishing",StopFishingCommand);
   AddCommand("/keepitem",KeepItemCommand);
   AddCommand("/destroyitem",DestroyItemCommand);
   
   if (MQ2Globals::gGameState==GAMESTATE_INGAME) {
      if (GetCharInfo()) {
         sprintf(INIFileName,"%s\\MQ2Fishing_%s_%s.ini",gszINIPath,GetCharInfo()->Name,EQADDR_SERVERNAME);
         Load_INI();
         MQ2FishingEnabled=true;
      }
   } else MQ2FishingEnabled=false;
}

PLUGIN_API VOID ShutdownPlugin(VOID)
{
   RemoveCommand("/startfishing");
   RemoveCommand("/stopfishing");
}

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

PLUGIN_API VOID OnPulse(VOID)
{

   if (!MQ2FishingEnabled)
   {
      return;
   }

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

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

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

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

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

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

PLUGIN_API DWORD OnIncomingChat(PCHAR Line, DWORD Color)
{  
   // Caught something
   if (HasFished && strstr(Line, "You caught"))
   {
      FishingSuccess=true;
   }
   // Didn't catch anything
   else if (HasFished && strstr(Line, "You didn't"))
   {
      FishingSuccess=false;
      HasFished=false;
      KeepItem=false;
      KeepDestroy=false;
   }
   // Out of bait
   else if (HasFished && strstr(Line, "You can't fish without fishing bait"))
   {
      WriteChatColor("Argh! Ye outa bait! Ye can't be fishin' wit'out ye bait!",CONCOLOR_RED);
      IsFishing=false;
   }
   return 0;
}


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

void StartFishingCommand(PSPAWNINFO pChar, PCHAR szLine){
   if (MQ2FishingEnabled) {
      WriteChatColor("Fishing Enabled",CONCOLOR_GREEN);
      IsFishing=true;
   }
}

void StopFishingCommand(PSPAWNINFO pChar, PCHAR szLine){
   if (MQ2FishingEnabled) {
      WriteChatColor("Fishing Disabled",CONCOLOR_RED);
      IsFishing=false;
   }
}

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

   if (MQ2FishingEnabled) {
      sprintf(szMsg, "Ar matey I'll start keepin' %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 (MQ2FishingEnabled) {
      sprintf(szMsg, "Ye heard da captin! %s is going to d' plank!", 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 (GetCharInfo2()->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",GetCharInfo2()->Cursor->Item->Name);
   
   KeepDestroy=true;

   KeepItem=Check_INI();

   if (KeepItem) {
      sprintf(szMsg, "Putting %s in the treasure chest.", szItem);
      WriteChatColor(szMsg,CONCOLOR_GREEN);
   } else {
      sprintf(szMsg, "Tossing %s ashore.", 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("MQ2Fishing: INI not found, creating one w/ 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",GetCharInfo2()->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, "MQ2Fishing: Bad status in ini for item %s in zone %s. Using default setting.",szItem,szZone);
      WriteChatColor(szMsg1, CONCOLOR_RED);
      if (AutoKeepEnabled) {
         ItemSetting=true;
      }
   }

   return ItemSetting;
}
 
Last edited:
Nice..
I was wondering, if you could make it possible to turn of it's own internal cursor (item) handling, and leave that to ther plugins such as MQ2AutoDestroy or MQ2Cursor? :)

Beware, line 298 is "broken", so you when compiling this needs to be fixed (it's a simple matter of removing the surplus spaces/tabs) ;)
 
Rich (BB code):
  if (!FishingSuccess && KeepDestroy) {
      if (NULL == (pCharInfo = GetCharInfo())) return;

      if (GetCharInfo2()->Cursor && KeepItem) {
         DoCommand(pChSpawn, "/autoinventory");
      } else if (GetCharInfo2()->Cursor && !KeepItem) {
         DoCommand(pChSpawn, "/destroy");
      } else

delete all this and it should work perfectly, although I did not test it. Remember to leave the "if".
 
MQ2Fishing

Users who are viewing this thread

Back
Top
Cart