diff --git a/conf/mod_autofish.conf.dist b/conf/mod_autofish.conf.dist index c934eab..6de5398 100644 --- a/conf/mod_autofish.conf.dist +++ b/conf/mod_autofish.conf.dist @@ -1,15 +1,38 @@ # AutoFish module AutoFish.Enabled = 1 -# How often to scan (ms). 150–250ms feels instant without being spammy. -AutoFish.TickMs = 200 -# Max distance to look for your own bobber + +# Delay between checking the bobber for a fish +# Values: 0-15000 +AuoFish.TickMs = 200 + +# Max distance to look for your own Bobber +# Values: 1.0-100.0 AutoFish.ScanRange = 30.0 -# Bobber entries to watch (comma-separated). Default covers classic/WotLK. + +# Bobber entries to watch +# Values: ID(s) of the bobber entities, comma separated AutoFish.BobberEntries = 35591 + # Automatically loot fish +# Values: 1 for on, 0 for off AutoFish.ServerAutoLoot = 1 + # Automatically Recast the fishing line +# Values: 1 for on, 0 for off AutoFish.AutoRecast = 1 + +# Delay before recasting the fishing line +# Values: AutoFish.RecastDelayMs = 500 + +# Spell ID used to recast the fishing line +# Values: Spell ID of "Fishing" AutoFish.RecastSpell = 18248 + +# Delay before looting from the loot window) +# Values: 0-3000 AutoFish.AutoLootDelayMs = 120 + +# Bag item required to activate autofish +# Values: Item ID, if 0 then no item required +AutoFish.RequiredItemId = 0 \ No newline at end of file diff --git a/src/mod_autofish.cpp b/src/mod_autofish.cpp index 0ad1b2f..a345dab 100644 --- a/src/mod_autofish.cpp +++ b/src/mod_autofish.cpp @@ -19,8 +19,9 @@ namespace uint32 sTickMs = 200; float sScanRange = 30.0f; uint32 sRecastDelayMs = 500; - uint32 sRecastSpell = 18248; // your corrected spell - uint32 sAutoLootDelayMs = 120; // small delay so pools populate loot + uint32 sRecastSpell = 18248; + uint32 sAutoLootDelayMs = 120; + uint32 sRequiredItemId = 0; std::vector sBobberEntries; struct GuidHash { std::size_t operator()(ObjectGuid const& g) const noexcept { return std::hash()(g.GetRawValue()); } }; @@ -45,6 +46,15 @@ namespace return out; } + bool RequirementMet(Player* plr) + { + if (!plr) + return false; + if (sRequiredItemId == 0) + return true; + return plr->HasItemCount(sRequiredItemId, 1, false); + } + void ScheduleRecast(Player* plr) { if (!sAutoRecast || !plr || !plr->IsInWorld()) @@ -71,7 +81,7 @@ namespace else { Player* plr = ObjectAccessor::FindPlayer(it->first); - if (plr && plr->IsInWorld() && plr->IsAlive() && !plr->IsInCombat()) + if (plr && plr->IsInWorld() && plr->IsAlive() && !plr->IsInCombat() && RequirementMet(plr)) plr->CastSpell(plr, sRecastSpell, true); it = sRecastTimers.erase(it); } @@ -90,9 +100,9 @@ namespace } Player* plr = ObjectAccessor::FindPlayer(it->first); - if (plr && plr->IsInWorld()) + if (plr && plr->IsInWorld() && RequirementMet(plr)) { - ObjectGuid lootGuid = plr->GetLootGUID(); // bobber for open water OR the pool GO for schools + ObjectGuid lootGuid = plr->GetLootGUID(); if (lootGuid.IsGameObject()) { if (GameObject* lootGo = ObjectAccessor::GetGameObject(*plr, lootGuid)) @@ -118,7 +128,7 @@ namespace void TryAutoFish(Player* plr) { - if (!plr || !plr->IsInWorld()) + if (!plr || !plr->IsInWorld() || !RequirementMet(plr)) return; std::list nearList; @@ -132,10 +142,10 @@ namespace if (go->getLootState() == GO_READY && go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE) { - go->Use(plr); // fires skillups/achievements and opens the correct loot source + go->Use(plr); if (sServerAutoLoot) - ScheduleAutoLoot(plr); // loot whatever the server opened (bobber or pool GO) - ScheduleRecast(plr); + ScheduleAutoLoot(plr); + ScheduleRecast(plr); return; } } @@ -157,6 +167,7 @@ public: sRecastDelayMs = sConfigMgr->GetOption("AutoFish.RecastDelayMs", 500u); sRecastSpell = sConfigMgr->GetOption("AutoFish.RecastSpell", 18248u); sAutoLootDelayMs = sConfigMgr->GetOption("AutoFish.AutoLootDelayMs", 120u); + sRequiredItemId = sConfigMgr->GetOption("AutoFish.RequiredItemId", 0u); sBobberEntries = ParseEntryList(sConfigMgr->GetOption("AutoFish.BobberEntries", "35591")); }