End patrols when supplies are low. Pirate interceptors will avoid fights then.
This commit is contained in:
parent
fd5fcfeeb3
commit
a710d2f746
@ -2,7 +2,8 @@
|
||||
|
||||
pirateInterceptorAI.js
|
||||
|
||||
Priority-based AI for pirate interceptors (fly defense for
|
||||
Priority-based AI for pirate interceptors (fly defense for other
|
||||
pirates)
|
||||
|
||||
Oolite
|
||||
Copyright © 2004-2013 Giles C Williams and contributors
|
||||
@ -48,24 +49,40 @@ this.aiStarted = function() {
|
||||
},
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 10
|
||||
truebranch: [
|
||||
{
|
||||
/* If supplies are low, flee */
|
||||
condition: ai.conditionLowSupplies,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 10
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
/* don't check odds first, make sure we get at least a little
|
||||
* weapons fire */
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsHunters,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 20
|
||||
},
|
||||
{
|
||||
condition: ai.conditionScannerContainsShipAttackingPirate,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 20
|
||||
/* If supplies are low, return to base */
|
||||
condition: ai.conditionLowSupplies,
|
||||
falsebranch: [
|
||||
{
|
||||
/* don't check odds first, make sure we get at
|
||||
* least a little weapons fire */
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsHunters,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 20
|
||||
},
|
||||
{
|
||||
condition: ai.conditionScannerContainsShipAttackingPirate,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 20
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -1514,6 +1514,10 @@ this._addPirateAssistant = function(role,lead,pos)
|
||||
// interceptors not actually part of group: they just get the
|
||||
// same destinations
|
||||
this._setWeapons(asst[0],2.3); // heavily armed
|
||||
if (asst[0].autoWeapons)
|
||||
{
|
||||
asst[0].awardEquipment("EQ_FUEL_INJECTION"); // interceptors always have injectors
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1342,6 +1342,33 @@ PriorityAIController.prototype.conditionLosingCombat = function()
|
||||
}
|
||||
|
||||
|
||||
PriorityAIController.prototype.conditionLowSupplies = function()
|
||||
{
|
||||
if (this.__ltcache.oolite_conditionLowSupplies !== undefined)
|
||||
{
|
||||
return this.__ltcache.oolite_conditionLowSupplies;
|
||||
}
|
||||
// out of missiles
|
||||
if (this.ship.missileCapacity > 0 && this.ship.missiles.length == 0)
|
||||
{
|
||||
log(this.ship.name,"Missiles low");
|
||||
this.__ltcache.oolite_conditionLowSupplies = true;
|
||||
return true;
|
||||
}
|
||||
// or fuel for injectors is low
|
||||
if (this.ship.fuel < 3.5 && this.ship.equipmentStatus("EQ_FUEL_INJECTION") == "EQUIPMENT_OK")
|
||||
{
|
||||
log(this.ship.name,"Fuel low");
|
||||
this.__ltcache.oolite_conditionLowSupplies = true;
|
||||
return true;
|
||||
}
|
||||
log(this.ship.name,"Supplies okay");
|
||||
// TODO: when NPC systems damage is added, check for that here
|
||||
this.__ltcache.oolite_conditionLowSupplies = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
PriorityAIController.prototype.conditionMothershipInCombat = function()
|
||||
{
|
||||
if (this.ship.group)
|
||||
@ -2212,7 +2239,7 @@ PriorityAIController.prototype.conditionMissileOutOfFuel = function()
|
||||
|
||||
PriorityAIController.prototype.conditionPatrolIsOver = function()
|
||||
{
|
||||
return this.ship.distanceTravelled > 200000;
|
||||
return this.ship.distanceTravelled > 200000 || this.conditionLowSupplies();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user