[-] Fixed collision detection for oil tankers
This commit is contained in:
parent
4dafa76a97
commit
16ab7b89f4
3 changed files with 20 additions and 4 deletions
|
@ -374,6 +374,13 @@ int COrder_Resource::MoveToResource_Terrain(CUnit &unit)
|
|||
switch (DoActionMove(unit)) {
|
||||
case PF_UNREACHABLE:
|
||||
unit.Wait = 10;
|
||||
if (unit.Player->AiEnabled) {
|
||||
this->Range++;
|
||||
if (this->Range >= 5) {
|
||||
this->Range = 0;
|
||||
AiCanNotMove(unit);
|
||||
}
|
||||
}
|
||||
if (FindTerrainType(unit.Type->MovementMask, MapFieldForest, 9999, *unit.Player, unit.tilePos, &pos)) {
|
||||
this->goalPos = pos;
|
||||
DebugPrint("Found a better place to harvest %d,%d\n" _C_ pos.x _C_ pos.y);
|
||||
|
|
|
@ -541,10 +541,14 @@ static int CostMoveToCallBack_Default(unsigned int index, const CUnit &unit)
|
|||
// moving unit are crossable
|
||||
cost += AStarMovingUnitCrossingCost;
|
||||
} else {
|
||||
// for non moving unit Always Fail unless goal is unit
|
||||
// for non moving unit Always Fail unless goal is unit, or unit can attack the target
|
||||
if (&unit != goal) {
|
||||
if (goal->Player->IsEnemy(unit) && unit.IsAgressive() && CanTarget(*unit.Type, *goal->Type)) {
|
||||
cost += 2 * AStarMovingUnitCrossingCost;
|
||||
} else {
|
||||
// FIXME: Need support for moving a fixed unit to add cost
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
//cost += AStarFixedUnitCrossingCost;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,8 +221,13 @@ class BestDepotFinder
|
|||
}
|
||||
|
||||
// calck real travel distance
|
||||
|
||||
d = UnitReachable(worker->Container ? *worker->Container : *worker, *dest, 1);
|
||||
if (worker->Container) {
|
||||
UnmarkUnitFieldFlags(*worker->Container);
|
||||
}
|
||||
d = UnitReachable(*worker, *dest, 1);
|
||||
if (worker->Container) {
|
||||
MarkUnitFieldFlags(*worker->Container);
|
||||
}
|
||||
//
|
||||
// Take this depot?
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue