[Petra] do not pass min == max range in moveToRange
Original diff D2512 Reported on forum by gameboy: https://wildfiregames.com/forum/index.php?/topic/27384-strange-landing-on-the-island-and-unable-to-attack/ Units with goal where minrange = maxrange rarely arrive to destination, because they miss it. See Todo in unitmotion Relative part: In the meantime, one should avoid that 'Speed over a turn' > MaxRange - MinRange, in case where min-range is not 0 and max-range is not infinity. For that reason avoid passing minrange = maxrange from ai. Also warn in cpp unitmoition when getting this kind of command. Differential revision: D3149 Reviewed by: @wraitii This was SVN commit r24315.
This commit is contained in:
parent
5a66f89044
commit
3ffc23008d
@ -277,7 +277,7 @@ PETRA.DefenseArmy.prototype.clear = function(gameState)
|
||||
continue;
|
||||
|
||||
if (destination && !gameState.isPlayerMutualAlly(gameState.ai.HQ.territoryMap.getOwner(ent.position())))
|
||||
ent.moveToRange(destination[0], destination[1], radius, radius+5);
|
||||
ent.moveToRange(destination[0], destination[1], radius, radius + 5);
|
||||
else
|
||||
ent.stopMoving();
|
||||
}
|
||||
|
@ -584,7 +584,7 @@ PETRA.DefenseManager.prototype.checkEvents = function(gameState, events)
|
||||
let pos = attacker.position();
|
||||
let range = attacker.attackRange("Ranged") ? attacker.attackRange("Ranged").max + 15 : 25;
|
||||
if (range * range > API3.SquareVectorDistance(pos, target.position()))
|
||||
target.moveToRange(pos[0], pos[1], range, range);
|
||||
target.moveToRange(pos[0], pos[1], range, range + 5);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ PETRA.NavalManager.prototype.moveApart = function(gameState)
|
||||
// New transport ships receive boarding commands only on the following turn.
|
||||
if (gameState.ai.playedTurn < ship.getMetadata(PlayerID, "turnPreviousPosition") + 2)
|
||||
continue;
|
||||
ship.moveToRange(shipPosition[0] + randFloat(-1, 1), shipPosition[1] + randFloat(-1, 1), 30, 30);
|
||||
ship.moveToRange(shipPosition[0] + randFloat(-1, 1), shipPosition[1] + randFloat(-1, 1), 30, 35);
|
||||
blockedShips.push(ship);
|
||||
blockedIds.push(ship.id());
|
||||
}
|
||||
@ -601,7 +601,7 @@ PETRA.NavalManager.prototype.moveApart = function(gameState)
|
||||
continue;
|
||||
if (API3.SquareVectorDistance(shipPosition, dock.position()) > 4900)
|
||||
continue;
|
||||
ship.moveToRange(dock.position()[0], dock.position()[1], 70, 70);
|
||||
ship.moveToRange(dock.position()[0], dock.position()[1], 70, 75);
|
||||
}
|
||||
|
||||
}
|
||||
@ -630,7 +630,7 @@ PETRA.NavalManager.prototype.moveApart = function(gameState)
|
||||
// New transport ships receives boarding commands only on the following turn.
|
||||
if (gameState.ai.playedTurn < ship.getMetadata(PlayerID, "turnPreviousPosition") + 2)
|
||||
continue;
|
||||
ship.moveToRange(shipPosition[0] + randFloat(-1, 1), shipPosition[1] + randFloat(-1, 1), 30, 30);
|
||||
ship.moveToRange(shipPosition[0] + randFloat(-1, 1), shipPosition[1] + randFloat(-1, 1), 30, 35);
|
||||
blockedShips.push(ship);
|
||||
blockedIds.push(ship.id());
|
||||
}
|
||||
@ -658,7 +658,7 @@ PETRA.NavalManager.prototype.moveApart = function(gameState)
|
||||
continue;
|
||||
if (API3.SquareVectorDistance(shipPosition, dock.position()) > 4900)
|
||||
continue;
|
||||
ship.moveToRange(dock.position()[0], dock.position()[1], 70, 70);
|
||||
ship.moveToRange(dock.position()[0], dock.position()[1], 70, 75);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -678,10 +678,10 @@ PETRA.NavalManager.prototype.moveApart = function(gameState)
|
||||
unitAIState != "INDIVIDUAL.RETURNRESOURCE.APPROACHING")
|
||||
{
|
||||
if (distSquare < 1600)
|
||||
blockingShip.moveToRange(shipPosition[0], shipPosition[1], 40, 40);
|
||||
blockingShip.moveToRange(shipPosition[0], shipPosition[1], 40, 45);
|
||||
}
|
||||
else if (distSquare < 900)
|
||||
blockingShip.moveToRange(shipPosition[0], shipPosition[1], 30, 30);
|
||||
blockingShip.moveToRange(shipPosition[0], shipPosition[1], 30, 35);
|
||||
}
|
||||
|
||||
for (let blockingShip of gameState.ai.HQ.tradeManager.traders.filter(API3.Filters.byClass("Ship")).values())
|
||||
@ -698,10 +698,10 @@ PETRA.NavalManager.prototype.moveApart = function(gameState)
|
||||
if (unitAIState != "INDIVIDUAL.TRADE.APPROACHINGMARKET")
|
||||
{
|
||||
if (distSquare < 1600)
|
||||
blockingShip.moveToRange(shipPosition[0], shipPosition[1], 40, 40);
|
||||
blockingShip.moveToRange(shipPosition[0], shipPosition[1], 40, 45);
|
||||
}
|
||||
else if (distSquare < 900)
|
||||
blockingShip.moveToRange(shipPosition[0], shipPosition[1], 30, 30);
|
||||
blockingShip.moveToRange(shipPosition[0], shipPosition[1], 30, 35);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -382,7 +382,7 @@ PETRA.HQ.prototype.dispatchUnits = function(gameState)
|
||||
--num1;
|
||||
ent.setMetadata(PlayerID, "allied", true);
|
||||
let range = 1.5 * cc.footprintRadius();
|
||||
ent.moveToRange(cc.position()[0], cc.position()[1], range, range);
|
||||
ent.moveToRange(cc.position()[0], cc.position()[1], range, range + 5);
|
||||
break;
|
||||
}
|
||||
});
|
||||
@ -401,7 +401,7 @@ PETRA.HQ.prototype.dispatchUnits = function(gameState)
|
||||
--num2;
|
||||
ent.setMetadata(PlayerID, "allied", true);
|
||||
let range = 1.5 * cc.footprintRadius();
|
||||
ent.moveToRange(cc.position()[0], cc.position()[1], range, range);
|
||||
ent.moveToRange(cc.position()[0], cc.position()[1], range, range + 5);
|
||||
break;
|
||||
}
|
||||
});
|
||||
@ -420,7 +420,7 @@ PETRA.HQ.prototype.dispatchUnits = function(gameState)
|
||||
--num;
|
||||
ent.setMetadata(PlayerID, "allied", true);
|
||||
let range = 1.5 * cc.footprintRadius();
|
||||
ent.moveToRange(cc.position()[0], cc.position()[1], range, range);
|
||||
ent.moveToRange(cc.position()[0], cc.position()[1], range, range + 5);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
@ -393,7 +393,7 @@ PETRA.TransportPlan.prototype.onBoarding = function(gameState)
|
||||
continue;
|
||||
}
|
||||
if (this.nTry[ent.id()] > 1)
|
||||
ent.moveToRange(newPos[0], newPos[1], 30, 30);
|
||||
ent.moveToRange(newPos[0], newPos[1], 30, 35);
|
||||
ent.garrison(ship, true);
|
||||
}
|
||||
else if (API3.SquareVectorDistance(this.boardingPos[shipId], newPos) > 225)
|
||||
@ -599,9 +599,9 @@ PETRA.TransportPlan.prototype.onSailing = function(gameState)
|
||||
let goal = ent.getMetadata(PlayerID, "endPos");
|
||||
let dist = goal ? API3.VectorDistance(pos, goal) : 0;
|
||||
if (dist > 30)
|
||||
ent.moveToRange(goal[0], goal[1], dist-20, dist-20);
|
||||
ent.moveToRange(goal[0], goal[1], dist-25, dist-20);
|
||||
else
|
||||
ent.moveToRange(pos[0], pos[1], 20, 20);
|
||||
ent.moveToRange(pos[0], pos[1], 20, 25);
|
||||
ent.setMetadata(PlayerID, "transport", undefined);
|
||||
ent.setMetadata(PlayerID, "onBoard", undefined);
|
||||
ent.setMetadata(PlayerID, "endPos", undefined);
|
||||
|
@ -1501,6 +1501,9 @@ bool CCmpUnitMotion::MoveTo(MoveRequest request)
|
||||
{
|
||||
PROFILE("MoveTo");
|
||||
|
||||
if (request.m_MinRange == request.m_MaxRange && !request.m_MinRange.IsZero())
|
||||
LOGWARNING("MaxRange must be larger than MinRange; See CCmpUnitMotion.cpp for more information");
|
||||
|
||||
CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle());
|
||||
if (!cmpPosition || !cmpPosition->IsInWorld())
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user