Index: ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js +++ ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js @@ -1232,7 +1232,7 @@ } // Move a tile outside the building let range = 4; - if (this.CheckTargetRangeExplicit(msg.data.target, range, range)) + if (this.CheckTargetRangeExplicit(msg.data.target, range, -1)) { // We are already at the target, or can't move at all this.FinishOrder(); @@ -2963,17 +2963,14 @@ "Order.LeaveFoundation": function(msg) { // Move a tile outside the building - var range = 4; - if (this.CheckTargetRangeExplicit(msg.data.target, range, range)) + let range = 4; + if (this.CheckTargetRangeExplicit(msg.data.target, range, -1)) { this.FinishOrder(); return; } - else - { - this.order.data.min = range; - this.SetNextState("WALKING"); - } + this.order.data.min = range; + this.SetNextState("WALKING"); }, "IDLE": { @@ -5785,7 +5782,7 @@ // Then second half of the rotation ang += halfDelta; let dist = randFloat(0.5, 1.5) * distance; - cmpUnitMotion.MoveToPointRange(pos.x - 0.5 * Math.sin(ang), pos.z - 0.5 * Math.cos(ang), dist, dist); + cmpUnitMotion.MoveToPointRange(pos.x - 0.5 * Math.sin(ang), pos.z - 0.5 * Math.cos(ang), dist, -1); }; UnitAI.prototype.SetFacePointAfterMove = function(val) Index: ps/trunk/source/simulation2/components/CCmpObstructionManager.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpObstructionManager.cpp +++ ps/trunk/source/simulation2/components/CCmpObstructionManager.cpp @@ -821,18 +821,26 @@ bool CCmpObstructionManager::IsInPointRange(entity_id_t ent, entity_pos_t px, entity_pos_t pz, entity_pos_t minRange, entity_pos_t maxRange, bool opposite) const { fixed dist = DistanceToPoint(ent, px, pz); - return dist != fixed::FromInt(-1) && dist <= maxRange + fixed::FromFloat(0.0001) && (opposite ? MaxDistanceToPoint(ent, px, pz) : dist) >= minRange - fixed::FromFloat(0.0001); + // Treat -1 max range as infinite + return dist != fixed::FromInt(-1) && + (dist <= (maxRange + fixed::FromFloat(0.0001)) || maxRange < fixed::Zero()) && + (opposite ? MaxDistanceToPoint(ent, px, pz) : dist) >= minRange - fixed::FromFloat(0.0001); } bool CCmpObstructionManager::IsInTargetRange(entity_id_t ent, entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange, bool opposite) const { fixed dist = DistanceToTarget(ent, target); - return dist != fixed::FromInt(-1) && dist <= maxRange + fixed::FromFloat(0.0001) && (opposite ? MaxDistanceToTarget(ent, target) : dist) >= minRange- fixed::FromFloat(0.0001); + // Treat -1 max range as infinite + return dist != fixed::FromInt(-1) && + (dist <= (maxRange + fixed::FromFloat(0.0001)) || maxRange < fixed::Zero()) && + (opposite ? MaxDistanceToTarget(ent, target) : dist) >= minRange - fixed::FromFloat(0.0001); } bool CCmpObstructionManager::IsPointInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t px, entity_pos_t pz, entity_pos_t minRange, entity_pos_t maxRange) const { entity_pos_t distance = (CFixedVector2D(x, z) - CFixedVector2D(px, pz)).Length(); - return distance <= maxRange + fixed::FromFloat(0.0001) && distance >= minRange - fixed::FromFloat(0.0001); + // Treat -1 max range as infinite + return (distance <= (maxRange + fixed::FromFloat(0.0001)) || maxRange < fixed::Zero()) && + distance >= minRange - fixed::FromFloat(0.0001); } bool CCmpObstructionManager::TestLine(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, bool relaxClearanceForUnits) const Index: ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp +++ ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp @@ -1081,7 +1081,8 @@ bool CCmpUnitMotion::TryGoingStraightToGoalPoint(const CFixedVector2D& from) { // Make sure the goal is a point (and not a point-like target like a formation controller) - if (m_MoveRequest.m_Type != MoveRequest::POINT) + if (m_MoveRequest.m_Type != MoveRequest::POINT || + m_MoveRequest.m_MinRange > fixed::Zero()) return false; // Fail if the goal is too far away Index: ps/trunk/source/simulation2/components/ICmpObstructionManager.h =================================================================== --- ps/trunk/source/simulation2/components/ICmpObstructionManager.h +++ ps/trunk/source/simulation2/components/ICmpObstructionManager.h @@ -201,16 +201,19 @@ /** * Check if the given entity is in range of the other point given those parameters. + * @param maxRange - if -1, treated as infinite. */ virtual bool IsInPointRange(entity_id_t ent, entity_pos_t px, entity_pos_t pz, entity_pos_t minRange, entity_pos_t maxRange, bool opposite) const = 0; /** * Check if the given entity is in range of the target given those parameters. + * @param maxRange - if -1, treated as infinite. */ virtual bool IsInTargetRange(entity_id_t ent, entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange, bool opposite) const = 0; /** * Check if the given point is in range of the other point given those parameters. + * @param maxRange - if -1, treated as infinite. */ virtual bool IsPointInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t px, entity_pos_t pz, entity_pos_t minRange, entity_pos_t maxRange) const = 0;