aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/GameObject
diff options
context:
space:
mode:
authorJozef DĂșc <D0d0@users.noreply.github.com>2019-05-02 21:53:12 +0200
committerGiacomo Pozzoni <giacomopoz@gmail.com>2019-05-02 21:53:12 +0200
commit78070163dc6b9bb34ab2d006e9cc218548e861b7 (patch)
tree2337ac06ee7736948db16cb0b4fbb8339168f4a1 /src/server/game/Entities/GameObject
parentfe3bf57aba9a5009e7e17922391a0d9374915ab5 (diff)
Core/Object: Range check vol. 2 (#23226)
* Core/Object: Fix all missing parts for #23062 * Update GameObject.cpp
Diffstat (limited to 'src/server/game/Entities/GameObject')
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp86
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h5
2 files changed, 40 insertions, 51 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 2453182784a..dc6795969ee 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -2554,14 +2554,35 @@ float GameObject::GetInteractionDistance() const
{
switch (GetGoType())
{
- /// @todo find out how the client calculates the maximal usage distance to spellless working
- // gameobjects like guildbanks and mailboxes - 10.0 is a just an abitrary choosen number
- case GAMEOBJECT_TYPE_GUILD_BANK:
- case GAMEOBJECT_TYPE_MAILBOX:
+ case GAMEOBJECT_TYPE_AREADAMAGE:
+ return 0.0f;
+ case GAMEOBJECT_TYPE_QUESTGIVER:
+ case GAMEOBJECT_TYPE_TEXT:
+ case GAMEOBJECT_TYPE_FLAGSTAND:
+ case GAMEOBJECT_TYPE_FLAGDROP:
+ case GAMEOBJECT_TYPE_MINI_GAME:
+ return 5.5555553f;
+ case GAMEOBJECT_TYPE_BINDER:
return 10.0f;
- case GAMEOBJECT_TYPE_FISHINGHOLE:
+ case GAMEOBJECT_TYPE_CHAIR:
+ case GAMEOBJECT_TYPE_BARBER_CHAIR:
+ return 3.0f;
case GAMEOBJECT_TYPE_FISHINGNODE:
+ return 100.0f;
+ case GAMEOBJECT_TYPE_FISHINGHOLE:
return 20.0f + CONTACT_DISTANCE; // max spell range
+ case GAMEOBJECT_TYPE_CAMERA:
+ case GAMEOBJECT_TYPE_MAP_OBJECT:
+ case GAMEOBJECT_TYPE_DUNGEON_DIFFICULTY:
+ case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
+ case GAMEOBJECT_TYPE_DOOR:
+ return 5.0f;
+ // Following values are not blizzlike
+ case GAMEOBJECT_TYPE_GUILD_BANK:
+ case GAMEOBJECT_TYPE_MAILBOX:
+ // Successful mailbox interaction is rather critical to the client, failing it will start a minute-long cooldown until the next mail query may be executed.
+ // And since movement info update is not sent with mailbox interaction query, server may find the player outside of interaction range. Thus we increase it.
+ return 10.0f; // 5.0f is blizzlike
default:
return INTERACTION_DISTANCE;
}
@@ -2623,47 +2644,7 @@ bool GameObject::IsAtInteractDistance(Player const* player, SpellInfo const* spe
return IsAtInteractDistance(*player, maxRange);
}
- float distance;
- switch (GetGoType())
- {
- case GAMEOBJECT_TYPE_AREADAMAGE:
- distance = 0.0f;
- break;
- case GAMEOBJECT_TYPE_QUESTGIVER:
- case GAMEOBJECT_TYPE_TEXT:
- case GAMEOBJECT_TYPE_FLAGSTAND:
- case GAMEOBJECT_TYPE_FLAGDROP:
- case GAMEOBJECT_TYPE_MINI_GAME:
- distance = 5.5555553f;
- break;
- case GAMEOBJECT_TYPE_BINDER:
- distance = 10.0f;
- break;
- case GAMEOBJECT_TYPE_CHAIR:
- case GAMEOBJECT_TYPE_BARBER_CHAIR:
- distance = 3.0f;
- break;
- case GAMEOBJECT_TYPE_FISHINGNODE:
- distance = 100.0f;
- break;
- case GAMEOBJECT_TYPE_CAMERA:
- case GAMEOBJECT_TYPE_MAP_OBJECT:
- case GAMEOBJECT_TYPE_DUNGEON_DIFFICULTY:
- case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
- case GAMEOBJECT_TYPE_DOOR:
- default:
- distance = 5.0f;
- break;
-
- // Following values are not blizzlike
- case GAMEOBJECT_TYPE_MAILBOX:
- // Successful mailbox interaction is rather critical to the client, failing it will start a minute-long cooldown until the next mail query may be executed.
- // And since movement info update is not sent with mailbox interaction query, server may find the player outside of interaction range. Thus we increase it.
- distance = 10.0f; // 5.0f is blizzlike
- break;
- }
-
- return IsAtInteractDistance(*player, distance);
+ return IsAtInteractDistance(*player, GetInteractionDistance());
}
bool GameObject::IsAtInteractDistance(Position const& pos, float radius) const
@@ -2679,10 +2660,10 @@ bool GameObject::IsAtInteractDistance(Position const& pos, float radius) const
float maxY = displayInfo->maxY * scale + radius;
float maxZ = displayInfo->maxZ * scale + radius;
- QuaternionData localRotation = GetLocalRotation();
- G3D::Quat localRotationQuat(localRotation.x, localRotation.y, localRotation.z, localRotation.w);
+ QuaternionData worldRotation = GetWorldRotation();
+ G3D::Quat worldRotationQuat(worldRotation.x, worldRotation.y, worldRotation.z, worldRotation.w);
- return G3D::CoordinateFrame { { localRotationQuat }, { GetPositionX(), GetPositionY(), GetPositionZ() } }
+ return G3D::CoordinateFrame { { worldRotationQuat }, { GetPositionX(), GetPositionY(), GetPositionZ() } }
.toWorldSpace(G3D::Box { { minX, minY, minZ }, { maxX, maxY, maxZ } })
.contains({ pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() });
}
@@ -2690,6 +2671,11 @@ bool GameObject::IsAtInteractDistance(Position const& pos, float radius) const
return GetExactDist(&pos) <= radius;
}
+bool GameObject::IsWithinDistInMap(Player const* player) const
+{
+ return IsInMap(this) && InSamePhase(this) && IsAtInteractDistance(player);
+}
+
SpellInfo const* GameObject::GetSpellForLock(Player const* player) const
{
if (!player)
@@ -2708,7 +2694,7 @@ SpellInfo const* GameObject::GetSpellForLock(Player const* player) const
if (!lock->Type[i])
continue;
- if (lock->Type[i] == LOCK_KEY_SKILL)
+ if (lock->Type[i] == LOCK_KEY_SPELL)
if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(lock->Index[i]))
return spell;
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index 257e4ce99db..e44002628a5 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -285,7 +285,10 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
void UpdateModelPosition();
bool IsAtInteractDistance(Position const& pos, float radius) const;
- bool IsAtInteractDistance(Player const* player, SpellInfo const* spell) const;
+ bool IsAtInteractDistance(Player const* player, SpellInfo const* spell = nullptr) const;
+
+ bool IsWithinDistInMap(Player const* player) const;
+ using WorldObject::IsWithinDistInMap;
SpellInfo const* GetSpellForLock(Player const* player) const;