feat(Core/Gameobject): add a range check for gameobjects (#7521)

This commit is contained in:
lineagedr
2021-08-31 11:34:43 +03:00
committed by GitHub
parent 1c43e6ac6e
commit ae8a78d90a
10 changed files with 256 additions and 48 deletions

View File

@@ -2058,8 +2058,10 @@ GameObject* Player::GetGameObjectIfCanInteractWith(ObjectGuid guid, GameobjectTy
{
if (go->GetGoType() == type)
{
if (go->IsWithinDistInMap(this, go->GetInteractionDistance()))
if (go->IsWithinDistInMap(this))
{
return go;
}
LOG_DEBUG("maps", "IsGameObjectOfTypeInRange: GameObject '%s' [%s] is too far away from player %s [%s] to be used by him (distance=%f, maximal 10 is allowed)",
go->GetGOInfo()->name.c_str(), go->GetGUID().ToString().c_str(), GetName().c_str(), GetGUID().ToString().c_str(), go->GetDistance(this));
@@ -7472,7 +7474,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
// not check distance for GO in case owned GO (fishing bobber case, for example)
// And permit out of range GO with no owner in case fishing hole
if (!go || (loot_type != LOOT_FISHINGHOLE && ((loot_type != LOOT_FISHING && loot_type != LOOT_FISHING_JUNK) || go->GetOwnerGUID() != GetGUID()) && !go->IsWithinDistInMap(this, INTERACTION_DISTANCE)) || (loot_type == LOOT_CORPSE && go->GetRespawnTime() && go->isSpawnedByDefault()))
if (!go || (loot_type != LOOT_FISHINGHOLE && ((loot_type != LOOT_FISHING && loot_type != LOOT_FISHING_JUNK) || go->GetOwnerGUID() != GetGUID()) && !go->IsWithinDistInMap(this)) || (loot_type == LOOT_CORPSE && go->GetRespawnTime() && go->isSpawnedByDefault()))
{
go->ForceValuesUpdateAtIndex(GAMEOBJECT_BYTES_1);
SendLootRelease(guid);