Try again to fix docking code
This commit is contained in:
parent
1eea9448a0
commit
2ef15dfb84
@ -1336,6 +1336,7 @@ this._addFreighter = function(pos)
|
||||
t[0].homeSystem = system.ID;
|
||||
t[0].destinationSystem = this._weightedNearbyTradeSystem();
|
||||
goods = "PLENTIFUL_GOODS";
|
||||
t[0].fuel = 7;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2947,6 +2947,21 @@ PriorityAIController.prototype.behaviourDockWithStation = function()
|
||||
this.ship.performFaceDestination();
|
||||
// and will reconsider in a little bit
|
||||
break;
|
||||
case "TRY_AGAIN_LATER":
|
||||
if (this.distance(station) < 5000)
|
||||
{
|
||||
if (this.__ltcache.oolite_dockingclearpos)
|
||||
{
|
||||
this.ship.destination = this.__ltcache.oolite_dockingclearpos;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ship.destination = station.position.add(Vector3D.randomDirection(8000+station.collisionRadius));
|
||||
this.__ltcache.oolite_dockingclearpos = this.ship.destination;
|
||||
}
|
||||
}
|
||||
this.ship.performFlyToRangeFromDestination();
|
||||
break;
|
||||
case "APPROACH_COORDINATES":
|
||||
if (this.ship.escortGroup && this.ship.escortGroup.count > 1)
|
||||
{
|
||||
@ -2960,7 +2975,6 @@ PriorityAIController.prototype.behaviourDockWithStation = function()
|
||||
// and fall through
|
||||
case "APPROACH":
|
||||
case "BACK_OFF":
|
||||
case "TRY_AGAIN_LATER":
|
||||
this.ship.performFlyToRangeFromDestination();
|
||||
break;
|
||||
}
|
||||
@ -4845,6 +4859,7 @@ PriorityAIController.prototype.responsesAddDocking = function(handlers)
|
||||
{
|
||||
handlers.stationWithdrewDockingClearance = this.responseComponent_docking_stationWithdrewDockingClearance;
|
||||
handlers.shipAchievedDesiredRange = this.responseComponent_docking_shipAchievedDesiredRange;
|
||||
handlers.shipAIFrustrated = this.responseComponent_docking_shipAIFrustrated;
|
||||
}
|
||||
|
||||
/* Override of standard handlers for use while escorting */
|
||||
@ -5912,6 +5927,16 @@ PriorityAIController.prototype.responseComponent_docking_shipAchievedDesiredRang
|
||||
}
|
||||
|
||||
|
||||
PriorityAIController.prototype.responseComponent_docking_shipAIFrustrated = function()
|
||||
{
|
||||
var station = this.getParameter("oolite_dockingStation",null);
|
||||
station.abortDockingForShip(this.ship);
|
||||
this.communicate("oolite_abortDocking",{},3);
|
||||
this.setParameter("oolite_dockingStation",null);
|
||||
this.reconsiderNow();
|
||||
}
|
||||
|
||||
|
||||
PriorityAIController.prototype.responseComponent_docking_stationWithdrewDockingClearance = function()
|
||||
{
|
||||
this.setParameter("oolite_dockingStation",null);
|
||||
|
@ -322,7 +322,7 @@ MA 02110-1301, USA.
|
||||
// some error has occurred - log it, and send the try-again message
|
||||
OOLogERR(@"station.issueDockingInstructions.failed", @"couldn't addShipToShipsOnApproach:%@ in %@, retrying later -- shipsOnApproach:\n%@", ship, self, shipsOnApproach);
|
||||
|
||||
return OOMakeDockingInstructions(station, [ship position], 0, 100, @"TRY_AGAIN_LATER", nil, NO, -1);
|
||||
return OOMakeDockingInstructions(station, [ship position], 200, 100, @"TRY_AGAIN_LATER", nil, NO, -1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -581,7 +581,7 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, HPVector coords,
|
||||
}
|
||||
if (chosenDock == nil)
|
||||
{
|
||||
if (player_is_ahead || ([docking isEqualToString:@"TOO_BIG_TO_DOCK"] && !alldockstoosmall))
|
||||
if (player_is_ahead || ([docking isEqualToString:@"TOO_BIG_TO_DOCK"] && !alldockstoosmall) || docking == nil)
|
||||
{
|
||||
// either player is manually docking and we can't allocate new docks,
|
||||
// or the last dock was too small, and there may be an acceptable one
|
||||
@ -589,7 +589,7 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, HPVector coords,
|
||||
docking = @"TRY_AGAIN_LATER";
|
||||
}
|
||||
// no docks accept this ship (or the player is blocking them)
|
||||
return OOMakeDockingInstructions(self, [ship position], 0, 100, docking, nil, NO, -1);
|
||||
return OOMakeDockingInstructions(self, [ship position], 200, 100, docking, nil, NO, -1);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user