Attempting to fix autofishing from pools
This commit is contained in:
parent
8417de8b0f
commit
1650bdc9a9
@ -19,15 +19,15 @@ namespace
|
||||
uint32 sTickMs = 200;
|
||||
float sScanRange = 30.0f;
|
||||
uint32 sRecastDelayMs = 500;
|
||||
uint32 sRecastSpell = 18248;
|
||||
uint32 sAutoLootDelayMs = 120;
|
||||
uint32 sRecastSpell = 18248; // your corrected spell
|
||||
uint32 sAutoLootDelayMs = 120; // small delay so pools populate loot
|
||||
std::vector<uint32> sBobberEntries;
|
||||
|
||||
struct GuidHash { std::size_t operator()(ObjectGuid const& g) const noexcept { return std::hash<uint64>()(g.GetRawValue()); } };
|
||||
|
||||
std::unordered_map<ObjectGuid, uint32, GuidHash> sRecastTimers;
|
||||
|
||||
struct PendingLoot { ObjectGuid bobber; uint32 timer; };
|
||||
struct PendingLoot { uint32 timer; };
|
||||
std::unordered_map<ObjectGuid, PendingLoot, GuidHash> sLootTimers;
|
||||
|
||||
std::vector<uint32> ParseEntryList(std::string const& csv)
|
||||
@ -52,11 +52,11 @@ namespace
|
||||
sRecastTimers[plr->GetGUID()] = sRecastDelayMs;
|
||||
}
|
||||
|
||||
void ScheduleAutoLoot(Player* plr, GameObject* bobber)
|
||||
void ScheduleAutoLoot(Player* plr)
|
||||
{
|
||||
if (!sServerAutoLoot || !plr || !bobber)
|
||||
if (!sServerAutoLoot || !plr)
|
||||
return;
|
||||
sLootTimers[plr->GetGUID()] = PendingLoot{ bobber->GetGUID(), sAutoLootDelayMs };
|
||||
sLootTimers[plr->GetGUID()] = PendingLoot{ sAutoLootDelayMs };
|
||||
}
|
||||
|
||||
void TickRecast(uint32 diff)
|
||||
@ -90,20 +90,26 @@ namespace
|
||||
}
|
||||
|
||||
Player* plr = ObjectAccessor::FindPlayer(it->first);
|
||||
GameObject* bobber = it->second.bobber ? ObjectAccessor::GetGameObject(*plr, it->second.bobber) : nullptr;
|
||||
|
||||
if (plr && bobber && plr->IsInWorld() && bobber->IsInWorld())
|
||||
if (plr && plr->IsInWorld())
|
||||
{
|
||||
Loot* loot = &bobber->loot;
|
||||
for (uint32 i = 0; i < loot->items.size(); ++i)
|
||||
ObjectGuid lootGuid = plr->GetLootGUID(); // bobber for open water OR the pool GO for schools
|
||||
if (lootGuid.IsGameObject())
|
||||
{
|
||||
if (loot->items[i].is_looted)
|
||||
continue;
|
||||
InventoryResult msg = EQUIP_ERR_OK;
|
||||
plr->StoreLootItem(uint8(i), loot, msg);
|
||||
if (GameObject* lootGo = ObjectAccessor::GetGameObject(*plr, lootGuid))
|
||||
{
|
||||
Loot* loot = &lootGo->loot;
|
||||
for (uint32 i = 0; i < loot->items.size(); ++i)
|
||||
{
|
||||
if (loot->items[i].is_looted)
|
||||
continue;
|
||||
InventoryResult msg = EQUIP_ERR_OK;
|
||||
plr->StoreLootItem(uint8(i), loot, msg);
|
||||
}
|
||||
plr->SendLootRelease(lootGuid);
|
||||
if (lootGo->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE)
|
||||
lootGo->SetLootState(GO_JUST_DEACTIVATED);
|
||||
}
|
||||
}
|
||||
plr->SendLootRelease(bobber->GetGUID());
|
||||
bobber->SetLootState(GO_JUST_DEACTIVATED);
|
||||
}
|
||||
|
||||
it = sLootTimers.erase(it);
|
||||
@ -126,12 +132,10 @@ namespace
|
||||
|
||||
if (go->getLootState() == GO_READY && go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE)
|
||||
{
|
||||
go->Use(plr);
|
||||
|
||||
go->Use(plr); // fires skillups/achievements and opens the correct loot source
|
||||
if (sServerAutoLoot)
|
||||
ScheduleAutoLoot(plr, go);
|
||||
|
||||
ScheduleRecast(plr);
|
||||
ScheduleAutoLoot(plr); // loot whatever the server opened (bobber or pool GO)
|
||||
ScheduleRecast(plr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user