aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVincent-Michael <Vincent_Michael@gmx.de>2014-04-08 17:27:41 +0200
committerVincent-Michael <Vincent_Michael@gmx.de>2014-04-08 17:27:41 +0200
commit5fd0e9783b7b7a35d8304522d6169291408346d2 (patch)
tree88050587d83392ff2fb928f14eacad49669be9ab /src
parent1f7260ca4b8ea351a8692cc51ec6fd933c000e14 (diff)
parent8d97a0e9060ebac9ddc6afbe069b48881f2a2b07 (diff)
Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Object/Object.cpp117
-rw-r--r--src/server/game/Entities/Player/Player.cpp3
-rwxr-xr-xsrc/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp5
3 files changed, 22 insertions, 103 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 132149af93b..64e6219f98c 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -2648,125 +2648,36 @@ void WorldObject::GetNearPoint(WorldObject const* /*searcher*/, float &x, float
{
GetNearPoint2D(x, y, distance2d+searcher_size, absAngle);
z = GetPositionZ();
+ // Should "searcher" be used instead of "this" when updating z coordinate ?
UpdateAllowedPositionZ(x, y, z);
- /*
// if detection disabled, return first point
- if (!sWorld->getIntConfig(CONFIG_DETECT_POS_COLLISION))
- {
- UpdateGroundPositionZ(x, y, z); // update to LOS height if available
+ if (!sWorld->getBoolConfig(CONFIG_DETECT_POS_COLLISION))
return;
- }
- // or remember first point
- float first_x = x;
- float first_y = y;
- bool first_los_conflict = false; // first point LOS problems
-
- // prepare selector for work
- ObjectPosSelector selector(GetPositionX(), GetPositionY(), GetObjectSize(), distance2d+searcher_size);
-
- // adding used positions around object
- {
- CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
- Cell cell(p);
- cell.SetNoCreate();
-
- Trinity::NearUsedPosDo u_do(*this, searcher, absAngle, selector);
- Trinity::WorldObjectWorker<Trinity::NearUsedPosDo> worker(this, u_do);
-
- TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::NearUsedPosDo>, GridTypeMapContainer > grid_obj_worker(worker);
- TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::NearUsedPosDo>, WorldTypeMapContainer > world_obj_worker(worker);
-
- CellLock<GridReadGuard> cell_lock(cell, p);
- cell_lock->Visit(cell_lock, grid_obj_worker, *GetMap(), *this, distance2d);
- cell_lock->Visit(cell_lock, world_obj_worker, *GetMap(), *this, distance2d);
- }
-
- // maybe can just place in primary position
- if (selector.CheckOriginal())
- {
- UpdateGroundPositionZ(x, y, z); // update to LOS height if available
-
- if (IsWithinLOS(x, y, z))
- return;
-
- first_los_conflict = true; // first point have LOS problems
- }
-
- float angle; // candidate of angle for free pos
-
- // special case when one from list empty and then empty side preferred
- if (selector.FirstAngle(angle))
- {
- GetNearPoint2D(x, y, distance2d, absAngle+angle);
- z = GetPositionZ();
- UpdateGroundPositionZ(x, y, z); // update to LOS height if available
-
- if (IsWithinLOS(x, y, z))
- return;
- }
-
- // set first used pos in lists
- selector.InitializeAngle();
-
- // select in positions after current nodes (selection one by one)
- while (selector.NextAngle(angle)) // angle for free pos
- {
- GetNearPoint2D(x, y, distance2d, absAngle+angle);
- z = GetPositionZ();
- UpdateGroundPositionZ(x, y, z); // update to LOS height if available
-
- if (IsWithinLOS(x, y, z))
- return;
- }
-
- // BAD NEWS: not free pos (or used or have LOS problems)
- // Attempt find _used_ pos without LOS problem
-
- if (!first_los_conflict)
- {
- x = first_x;
- y = first_y;
-
- UpdateGroundPositionZ(x, y, z); // update to LOS height if available
+ // return if the point is already in LoS
+ if (IsWithinLOS(x, y, z))
return;
- }
-
- // special case when one from list empty and then empty side preferred
- if (selector.IsNonBalanced())
- {
- if (!selector.FirstAngle(angle)) // _used_ pos
- {
- GetNearPoint2D(x, y, distance2d, absAngle+angle);
- z = GetPositionZ();
- UpdateGroundPositionZ(x, y, z); // update to LOS height if available
-
- if (IsWithinLOS(x, y, z))
- return;
- }
- }
- // set first used pos in lists
- selector.InitializeAngle();
+ // remember first point
+ float first_x = x;
+ float first_y = y;
+ float first_z = z;
- // select in positions after current nodes (selection one by one)
- while (selector.NextUsedAngle(angle)) // angle for used pos but maybe without LOS problem
+ // loop in a circle to look for a point in LoS using small steps
+ for (float angle = M_PI / 8; angle < M_PI * 2; angle += M_PI / 8)
{
- GetNearPoint2D(x, y, distance2d, absAngle+angle);
+ GetNearPoint2D(x, y, distance2d + searcher_size, absAngle + angle);
z = GetPositionZ();
- UpdateGroundPositionZ(x, y, z); // update to LOS height if available
-
+ UpdateAllowedPositionZ(x, y, z);
if (IsWithinLOS(x, y, z))
return;
}
- // BAD BAD NEWS: all found pos (free and used) have LOS problem :(
+ // still not in LoS, give up and return first position found
x = first_x;
y = first_y;
-
- UpdateGroundPositionZ(x, y, z); // update to LOS height if available
- */
+ z = first_z;
}
void WorldObject::GetClosePoint(float &x, float &y, float &z, float size, float distance2d /*= 0*/, float angle /*= 0*/) const
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 173be677c14..3c29288f88a 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -25704,6 +25704,9 @@ void Player::HandleFall(MovementInfo const& movementInfo)
if (damageperc > 0)
{
uint32 damage = (uint32)(damageperc * GetMaxHealth()*sWorld->getRate(RATE_DAMAGE_FALL));
+
+ if (GetCommandStatus(CHEAT_GOD))
+ damage = 0;
float height = movementInfo.pos.m_positionZ;
UpdateGroundPositionZ(movementInfo.pos.m_positionX, movementInfo.pos.m_positionY, height);
diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp
index 28e58c87323..c59762066ae 100755
--- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp
@@ -159,10 +159,15 @@ bool TargetedMovementGeneratorMedium<T, D>::DoUpdate(T* owner, uint32 time_diff)
if (TransportBase* transport = owner->GetDirectTransport())
transport->CalculatePassengerPosition(dest.x, dest.y, dest.z);
+ // First check distance
if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->CanFly())
targetMoved = !i_target->IsWithinDist3d(dest.x, dest.y, dest.z, allowed_dist);
else
targetMoved = !i_target->IsWithinDist2d(dest.x, dest.y, allowed_dist);
+
+ // then, if the target is in range, check also Line of Sight.
+ if (!targetMoved)
+ targetMoved = !i_target->IsWithinLOSInMap(owner);
}
if (i_recalculateTravel || targetMoved)