Added Item requirement and cleaned up config a bit
This commit is contained in:
parent
1650bdc9a9
commit
96b8f233e5
@ -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
|
||||
@ -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<uint32> sBobberEntries;
|
||||
|
||||
struct GuidHash { std::size_t operator()(ObjectGuid const& g) const noexcept { return std::hash<uint64>()(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<GameObject*> nearList;
|
||||
@ -132,9 +142,9 @@ 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)
|
||||
ScheduleAutoLoot(plr);
|
||||
ScheduleRecast(plr);
|
||||
return;
|
||||
}
|
||||
@ -157,6 +167,7 @@ public:
|
||||
sRecastDelayMs = sConfigMgr->GetOption<uint32>("AutoFish.RecastDelayMs", 500u);
|
||||
sRecastSpell = sConfigMgr->GetOption<uint32>("AutoFish.RecastSpell", 18248u);
|
||||
sAutoLootDelayMs = sConfigMgr->GetOption<uint32>("AutoFish.AutoLootDelayMs", 120u);
|
||||
sRequiredItemId = sConfigMgr->GetOption<uint32>("AutoFish.RequiredItemId", 0u);
|
||||
sBobberEntries = ParseEntryList(sConfigMgr->GetOption<std::string>("AutoFish.BobberEntries", "35591"));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user