Skip to content

Commit

Permalink
Core/Spells: AoE spells should no longer take ObjectSize into factor.…
Browse files Browse the repository at this point in the history
… #10
  • Loading branch information
robinsch authored and henhouse committed Jul 16, 2015
1 parent 6113628 commit 6376dd0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/server/game/Chat/Commands/Level3.cpp
Expand Up @@ -3420,7 +3420,7 @@ bool ChatHandler::HandleGetDistanceCommand(const char* /*args*/)
return false;
}

PSendSysMessage(LANG_DISTANCE, m_session->GetPlayer()->GetDistance(pUnit), m_session->GetPlayer()->GetDistance2d(pUnit));
PSendSysMessage(LANG_DISTANCE, m_session->GetPlayer()->GetDistance(pUnit), m_session->GetPlayer()->GetDistance(pUnit, false), m_session->GetPlayer()->GetDistance2d(pUnit));

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/Entities/Object/Object.cpp
Expand Up @@ -1123,7 +1123,7 @@ float WorldObject::GetDistanceZ(const WorldObject* obj) const
return (dist > 0 ? dist : 0);
}

bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) const
bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D, bool includeObjectSize) const
{
float dx = GetPositionX() - obj->GetPositionX();
float dy = GetPositionY() - obj->GetPositionY();
Expand All @@ -1134,7 +1134,7 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool
distsq += dz*dz;
}
float sizefactor = GetObjectSize() + obj->GetObjectSize();
float maxdist = dist2compare + sizefactor;
float maxdist = dist2compare + (includeObjectSize ? sizefactor : 0.0f);

return distsq < maxdist * maxdist;
}
Expand Down
10 changes: 5 additions & 5 deletions src/server/game/Entities/Object/Object.h
Expand Up @@ -629,9 +629,9 @@ class WorldObject : public Object, public WorldLocation

virtual const char* GetNameForLocaleIdx(int32 /*locale_idx*/) const { return GetName(); }

float GetDistance(const WorldObject *obj) const
float GetDistance(const WorldObject *obj, bool includeObjectSize = true) const
{
float d = GetExactDist(obj) - GetObjectSize() - obj->GetObjectSize();
float d = GetExactDist(obj) - (includeObjectSize ? (GetObjectSize() + obj->GetObjectSize()) : 0.0f);
return d > 0.0f ? d : 0.0f;
}
float GetDistance(const Position &pos) const
Expand Down Expand Up @@ -671,15 +671,15 @@ class WorldObject : public Object, public WorldLocation
{ return IsInDist2d(x, y, dist + GetObjectSize()); }
bool IsWithinDist2d(const Position *pos, float dist) const
{ return IsInDist2d(pos, dist + GetObjectSize()); }
bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) const;
bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D, bool includeObjectSize = true) const;
// use only if you will sure about placing both object at same map
bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true) const
{
return obj && _IsWithinDist(obj, dist2compare, is3D);
}
bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true) const
bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true, bool includeObjectSize = true) const
{
return obj && IsInMap(obj) && _IsWithinDist(obj, dist2compare, is3D);
return obj && IsInMap(obj) && _IsWithinDist(obj, dist2compare, is3D, includeObjectSize);
}
bool IsWithinLOS(float x, float y, float z) const;
bool IsWithinLOSInMap(const WorldObject* obj) const;
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Spells/Spell.h
Expand Up @@ -715,7 +715,7 @@ namespace Trinity
default:
if (i_TargetType != SPELL_TARGETS_ENTRY && i_push_type == PUSH_SRC_CENTER && i_caster) // if caster then check distance from caster to target (because of model collision)
{
if (i_caster->IsWithinDistInMap(itr->getSource(), i_radius))
if (i_caster->IsWithinDistInMap(itr->getSource(), i_radius, true, false))
i_data->push_back(itr->getSource());
}
else
Expand Down

0 comments on commit 6376dd0

Please sign in to comment.