Skip to content

Commit

Permalink
Merge branch 'bugfixes'
Browse files Browse the repository at this point in the history
Fix docking behaviour (needs more testing)
Fix assassin chase behaviour
  • Loading branch information
cim-- committed Jun 29, 2014
2 parents e79cfe0 + c585ac7 commit 07cbf8f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
10 changes: 5 additions & 5 deletions Resources/AIs/oolite-assassinAI.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ this.aiStarted = function() {
behaviour: ai.behaviourEnterWitchspace,
reconsider: 15
},
{
condition: ai.conditionHasRememberedTarget,
behaviour: ai.behaviourFollowCurrentTarget,
reconsider: 15
},
/* Check for couriers */
{
preconfiguration: ai.configurationCheckScanner,
Expand Down Expand Up @@ -104,6 +99,11 @@ this.aiStarted = function() {
behaviour: ai.behaviourDestroyCurrentTarget,
reconsider: 20
},
{
condition: ai.conditionHasRememberedTarget,
behaviour: ai.behaviourFollowCurrentTarget,
reconsider: 15
},
{
preconfiguration: ai.configurationAppointGroupLeader,
condition: ai.conditionIsGroupLeader,
Expand Down
1 change: 1 addition & 0 deletions Resources/Scripts/oolite-populator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
29 changes: 27 additions & 2 deletions Resources/Scripts/oolite-priorityai.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -2960,7 +2975,6 @@ PriorityAIController.prototype.behaviourDockWithStation = function()
// and fall through
case "APPROACH":
case "BACK_OFF":
case "TRY_AGAIN_LATER":
this.ship.performFlyToRangeFromDestination();
break;
}
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -5987,7 +6012,7 @@ PriorityAIController.prototype.responseComponent_expectWitchspace_shipTargetLost
{
target = this.getParameter("oolite_rememberedTarget");
}
if (target) {
if (target && target.position) {
var pos = target.position;
var ws = system.wormholes;
// most likely to be most recent
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Entities/DockEntity.m
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ - (NSDictionary *) dockingInstructionsForShip:(ShipEntity *)ship
// 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);
}


Expand Down
4 changes: 2 additions & 2 deletions src/Core/Entities/StationEntity.m
Original file line number Diff line number Diff line change
Expand Up @@ -581,15 +581,15 @@ - (NSDictionary *) dockingInstructionsForShip:(ShipEntity *) ship
}
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
// not tested yet or returning TRY_AGAIN_LATER
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);
}


Expand Down

0 comments on commit 07cbf8f

Please sign in to comment.