Changing interaction behavior to use(player)
This commit is contained in:
parent
12475ef9c2
commit
2d9736d6df
@ -2,16 +2,19 @@
|
|||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "GameObject.h"
|
#include "GameObject.h"
|
||||||
#include "ObjectAccessor.h"
|
#include "ObjectAccessor.h"
|
||||||
#include "GridNotifiers.h"
|
|
||||||
#include "CellImpl.h"
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include "WorldSession.h"
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
#include <list>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
std::vector<uint32> sBobberEntries;
|
|
||||||
bool sEnabled = true;
|
bool sEnabled = true;
|
||||||
uint32 sTickMs = 200;
|
uint32 sTickMs = 200;
|
||||||
float sScanRange = 30.0f;
|
float sScanRange = 30.0f;
|
||||||
|
std::vector<uint32> sBobberEntries;
|
||||||
|
|
||||||
std::vector<uint32> ParseEntryList(std::string const& csv)
|
std::vector<uint32> ParseEntryList(std::string const& csv)
|
||||||
{
|
{
|
||||||
@ -20,47 +23,41 @@ namespace
|
|||||||
std::string item;
|
std::string item;
|
||||||
while (std::getline(ss, item, ','))
|
while (std::getline(ss, item, ','))
|
||||||
{
|
{
|
||||||
auto trim = [](std::string& s)
|
item.erase(0, item.find_first_not_of(" \t\r\n"));
|
||||||
{
|
item.erase(item.find_last_not_of(" \t\r\n") + 1);
|
||||||
s.erase(0, s.find_first_not_of(" \t\r\n"));
|
|
||||||
s.erase(s.find_last_not_of(" \t\r\n") + 1);
|
|
||||||
};
|
|
||||||
trim(item);
|
|
||||||
if (!item.empty())
|
if (!item.empty())
|
||||||
out.push_back(static_cast<uint32>(std::stoul(item)));
|
out.push_back(uint32(std::stoul(item)));
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TryAutoLootNearbyBobber(Player* plr)
|
void TryAutoFish(Player* plr)
|
||||||
{
|
{
|
||||||
if (!plr || !plr->IsInWorld())
|
if (!plr || !plr->IsInWorld())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::list<GameObject*> goList;
|
std::list<GameObject*> nearList;
|
||||||
Acore::AllGameObjectsMatchingOneEntryInRange check(plr, sBobberEntries, sScanRange);
|
for (auto entry : sBobberEntries)
|
||||||
Acore::GameObjectListSearcher<Acore::AllGameObjectsMatchingOneEntryInRange> searcher(plr, goList, check);
|
plr->GetGameObjectListWithEntryInGrid(nearList, entry, sScanRange);
|
||||||
Cell::VisitObjects(plr, searcher, sScanRange);
|
|
||||||
|
|
||||||
for (GameObject* go : goList)
|
for (GameObject* go : nearList)
|
||||||
{
|
{
|
||||||
if (!go)
|
if (!go || go->GetOwnerGUID() != plr->GetGUID())
|
||||||
continue;
|
continue;
|
||||||
if (go->GetOwnerGUID() != plr->GetGUID())
|
|
||||||
continue;
|
if (go->getLootState() == GO_READY && go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE)
|
||||||
if (go->getLootState() == GO_READY)
|
|
||||||
{
|
{
|
||||||
plr->SendLoot(go->GetGUID(), LOOT_FISHING);
|
go->Use(plr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AutoFish_WorldUpdate : public WorldScript
|
class AutoFish_WorldScript : public WorldScript
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AutoFish_WorldUpdate() : WorldScript("AutoFish_WorldUpdate") {}
|
AutoFish_WorldScript() : WorldScript("AutoFish_WorldScript") {}
|
||||||
|
|
||||||
void OnAfterConfigLoad(bool) override
|
void OnAfterConfigLoad(bool) override
|
||||||
{
|
{
|
||||||
@ -87,12 +84,12 @@ public:
|
|||||||
Player* plr = kv.second;
|
Player* plr = kv.second;
|
||||||
if (!plr || !plr->IsInWorld() || plr->IsGameMaster())
|
if (!plr || !plr->IsInWorld() || plr->IsGameMaster())
|
||||||
continue;
|
continue;
|
||||||
TryAutoLootNearbyBobber(plr);
|
TryAutoFish(plr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddSC_autofish_world()
|
void AddSC_autofish_world()
|
||||||
{
|
{
|
||||||
new AutoFish_WorldUpdate();
|
new AutoFish_WorldScript();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user