Attempt to fix autoloot

This commit is contained in:
Flerp 2025-11-01 17:40:15 -07:00
parent 2d9736d6df
commit 6c70f57e8e

View File

@ -3,7 +3,7 @@
#include "GameObject.h"
#include "ObjectAccessor.h"
#include "Config.h"
#include "WorldSession.h"
#include "LootMgr.h"
#include <sstream>
#include <vector>
#include <list>
@ -12,6 +12,7 @@
namespace
{
bool sEnabled = true;
bool sServerAutoLoot = true;
uint32 sTickMs = 200;
float sScanRange = 30.0f;
std::vector<uint32> sBobberEntries;
@ -48,6 +49,17 @@ namespace
if (go->getLootState() == GO_READY && go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE)
{
go->Use(plr);
if (sServerAutoLoot)
{
Loot* loot = &go->loot;
for (uint32 i = 0; i < loot->items.size(); ++i)
plr->StoreLootItem(i, loot);
plr->SendLootRelease(go->GetGUID());
go->SetLootState(GO_JUST_DEACTIVATED);
}
return;
}
}
@ -62,6 +74,7 @@ public:
void OnAfterConfigLoad(bool) override
{
sEnabled = sConfigMgr->GetOption<bool>("AutoFish.Enabled", true);
sServerAutoLoot = sConfigMgr->GetOption<bool>("AutoFish.ServerAutoLoot", true);
sTickMs = sConfigMgr->GetOption<uint32>("AutoFish.TickMs", 200u);
sScanRange = sConfigMgr->GetOption<float>("AutoFish.ScanRange", 30.0f);
sBobberEntries = ParseEntryList(sConfigMgr->GetOption<std::string>("AutoFish.BobberEntries", "35591"));