Redo JSAI comms methodology
Now much more possible for OXPs to add more comms messages. Priority system to allow occasional messages on particular topics without overwhelming the comms with constant updates. Also, fix my text editor using 2 tabs as the indent level for JS...
This commit is contained in:
parent
db62296090
commit
cda41d73eb
@ -30,79 +30,72 @@ this.name = "Oolite Bounty Hunter AI";
|
||||
this.version = "1.79";
|
||||
|
||||
this.aiStarted = function() {
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
|
||||
ai.setParameter("oolite_flag_listenForDistressCall",true);
|
||||
ai.setWaypointGenerator(ai.waypointsSpacelanePatrol);
|
||||
ai.setParameter("oolite_flag_listenForDistressCall",true);
|
||||
ai.setWaypointGenerator(ai.waypointsSpacelanePatrol);
|
||||
|
||||
/* Communications currently for debugging purposes. Need to either
|
||||
* be removed or given a much bigger set of phrases to choose from
|
||||
* before 1.79 */
|
||||
ai.setCommunication("oolite_distressResponseSender","Hold on, [p1]!");
|
||||
ai.setCommunication("oolite_distressResponseAggressor","[p1]. Cease your attack or be destroyed!");
|
||||
ai.setCommunication("oolite_beginningAttack","Scan confirms criminal status of [p1]. Commencing attack run");
|
||||
ai.setCommunication("oolite_quiriumCascade","%N! Q-bomb!");
|
||||
ai.setCommunication("oolite_friendlyFire","Hey! Watch where you're shooting, [p1].");
|
||||
ai.setCommunicationsRole("hunter");
|
||||
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
{
|
||||
condition: ai.conditionLosingCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Check for distress calls */
|
||||
{
|
||||
condition: ai.conditionHasReceivedDistressCall,
|
||||
behaviour: ai.behaviourRespondToDistressCall,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Check for profitable targets */
|
||||
{
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsFugitive,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 1
|
||||
},
|
||||
{
|
||||
condition: ai.conditionScannerContainsHuntableOffender,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 1
|
||||
},
|
||||
/* What about loot? */
|
||||
{
|
||||
condition: ai.conditionScannerContainsSalvageForMe,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourCollectSalvage,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Check we're in a real system */
|
||||
{
|
||||
condition: ai.conditionInInterstellarSpace,
|
||||
configuration: ai.configurationSelectWitchspaceDestination,
|
||||
behaviour: ai.behaviourEnterWitchspace,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Nothing interesting here. Patrol for a bit */
|
||||
{
|
||||
condition: ai.conditionHasWaypoint,
|
||||
configuration: ai.configurationSetDestinationToWaypoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
/* No patrol route set up. Make one */
|
||||
{
|
||||
configuration: ai.configurationSetWaypoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]);
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
{
|
||||
condition: ai.conditionLosingCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Check for distress calls */
|
||||
{
|
||||
condition: ai.conditionHasReceivedDistressCall,
|
||||
behaviour: ai.behaviourRespondToDistressCall,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Check for profitable targets */
|
||||
{
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsFugitive,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 1
|
||||
},
|
||||
{
|
||||
condition: ai.conditionScannerContainsHuntableOffender,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 1
|
||||
},
|
||||
/* What about loot? */
|
||||
{
|
||||
condition: ai.conditionScannerContainsSalvageForMe,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourCollectSalvage,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Check we're in a real system */
|
||||
{
|
||||
condition: ai.conditionInInterstellarSpace,
|
||||
configuration: ai.configurationSelectWitchspaceDestination,
|
||||
behaviour: ai.behaviourEnterWitchspace,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Nothing interesting here. Patrol for a bit */
|
||||
{
|
||||
condition: ai.conditionHasWaypoint,
|
||||
configuration: ai.configurationSetDestinationToWaypoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
/* No patrol route set up. Make one */
|
||||
{
|
||||
configuration: ai.configurationSetWaypoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]);
|
||||
}
|
@ -30,60 +30,62 @@ this.name = "Oolite Defense Ship AI";
|
||||
this.version = "1.79";
|
||||
|
||||
this.aiStarted = function() {
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
|
||||
ai.setCommunicationsRole("defenseShip");
|
||||
|
||||
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
{
|
||||
condition: ai.conditionLosingCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourRepelCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionMothershipIsAttackingHostileTarget,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourRepelCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Battle is over; return to base */
|
||||
{
|
||||
condition: ai.conditionHomeStationNearby,
|
||||
configuration: ai.configurationSetHomeStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionHomeStationExists,
|
||||
configuration: ai.configurationSetDestinationToHomeStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
/* Or at least return to somewhere */
|
||||
{
|
||||
condition: ai.conditionFriendlyStationNearby,
|
||||
configuration: ai.configurationSetNearbyFriendlyStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionFriendlyStationExists,
|
||||
configuration: ai.configurationSetDestinationToNearestFriendlyStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
// stuck and no friendly stations
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
// TODO: behaviour search for wormholes
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]);
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
{
|
||||
condition: ai.conditionLosingCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourRepelCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionMothershipIsAttackingHostileTarget,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourRepelCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Battle is over; return to base */
|
||||
{
|
||||
condition: ai.conditionHomeStationNearby,
|
||||
configuration: ai.configurationSetHomeStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionHomeStationExists,
|
||||
configuration: ai.configurationSetDestinationToHomeStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
/* Or at least return to somewhere */
|
||||
{
|
||||
condition: ai.conditionFriendlyStationNearby,
|
||||
configuration: ai.configurationSetNearbyFriendlyStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionFriendlyStationExists,
|
||||
configuration: ai.configurationSetDestinationToNearestFriendlyStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
// stuck and no friendly stations
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
// TODO: behaviour search for wormholes
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]);
|
||||
}
|
@ -30,86 +30,89 @@ this.name = "Oolite Escort AI";
|
||||
this.version = "1.79";
|
||||
|
||||
this.aiStarted = function() {
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
|
||||
ai.setPriorities([
|
||||
ai.setCommunicationsRole("escort");
|
||||
|
||||
|
||||
ai.setPriorities([
|
||||
{
|
||||
condition: ai.conditionLosingCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionMothershipInCombat,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionLosingCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
condition: ai.conditionMothershipUnderAttack,
|
||||
configuration: ai.configurationAcquireDefensiveEscortTarget,
|
||||
behaviour: ai.behaviourRepelCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionMothershipInCombat,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionMothershipUnderAttack,
|
||||
configuration: ai.configurationAcquireDefensiveEscortTarget,
|
||||
behaviour: ai.behaviourRepelCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionMothershipIsAttacking,
|
||||
configuration: ai.configurationAcquireOffensiveEscortTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
behaviour: ai.behaviourRejoinMothership,
|
||||
reconsider: 5
|
||||
}
|
||||
]
|
||||
condition: ai.conditionMothershipIsAttacking,
|
||||
configuration: ai.configurationAcquireOffensiveEscortTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
// if we're in combat but mothership isn't, then we need
|
||||
// to finish this fight off and get back to them
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourRepelCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionWitchspaceEntryRequested,
|
||||
behaviour: ai.behaviourEnterWitchspace,
|
||||
reconsider: 15
|
||||
},
|
||||
{
|
||||
condition: ai.conditionIsEscorting,
|
||||
behaviour: ai.behaviourEscortMothership,
|
||||
reconsider: 60
|
||||
},
|
||||
/* Don't have a mothership */
|
||||
{
|
||||
condition: ai.conditionFriendlyStationNearby,
|
||||
configuration: ai.configurationSetNearbyFriendlyStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
/* And it's not because they just docked either */
|
||||
{
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsShipNeedingEscort,
|
||||
behaviour: ai.behaviourOfferToEscort,
|
||||
reconsider: 15
|
||||
},
|
||||
{
|
||||
condition: ai.conditionFriendlyStationExists,
|
||||
configuration: ai.configurationSetDestinationToNearestFriendlyStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
/* No friendly stations and no nearby ships needing escort */
|
||||
{
|
||||
condition: ai.conditionCanWitchspaceOut,
|
||||
configuration: ai.configurationSelectWitchspaceDestination,
|
||||
behaviour: ai.behaviourEnterWitchspace,
|
||||
reconsider: 20
|
||||
},
|
||||
/* And we're stuck here, but something to escort will probably
|
||||
* show up at the witchpoint sooner or later */
|
||||
{
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
behaviour: ai.approachDestination,
|
||||
reconsider: 30
|
||||
behaviour: ai.behaviourRejoinMothership,
|
||||
reconsider: 5
|
||||
}
|
||||
]);
|
||||
]
|
||||
},
|
||||
{
|
||||
// if we're in combat but mothership isn't, then we need
|
||||
// to finish this fight off and get back to them
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourRepelCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionWitchspaceEntryRequested,
|
||||
behaviour: ai.behaviourEnterWitchspace,
|
||||
reconsider: 15
|
||||
},
|
||||
{
|
||||
condition: ai.conditionIsEscorting,
|
||||
behaviour: ai.behaviourEscortMothership,
|
||||
reconsider: 60
|
||||
},
|
||||
/* Don't have a mothership */
|
||||
{
|
||||
condition: ai.conditionFriendlyStationNearby,
|
||||
configuration: ai.configurationSetNearbyFriendlyStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
/* And it's not because they just docked either */
|
||||
{
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsShipNeedingEscort,
|
||||
behaviour: ai.behaviourOfferToEscort,
|
||||
reconsider: 15
|
||||
},
|
||||
{
|
||||
condition: ai.conditionFriendlyStationExists,
|
||||
configuration: ai.configurationSetDestinationToNearestFriendlyStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
/* No friendly stations and no nearby ships needing escort */
|
||||
{
|
||||
condition: ai.conditionCanWitchspaceOut,
|
||||
configuration: ai.configurationSelectWitchspaceDestination,
|
||||
behaviour: ai.behaviourEnterWitchspace,
|
||||
reconsider: 20
|
||||
},
|
||||
/* And we're stuck here, but something to escort will probably
|
||||
* show up at the witchpoint sooner or later */
|
||||
{
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
behaviour: ai.approachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]);
|
||||
}
|
@ -30,40 +30,42 @@ this.name = "Oolite Constrictor AI";
|
||||
this.version = "1.79";
|
||||
|
||||
this.aiStarted = function() {
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
ai.setCommunicationsRole("pirate");
|
||||
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
{
|
||||
preconfiguration: function()
|
||||
{
|
||||
if (this.ship.script._checkDistance)
|
||||
{
|
||||
preconfiguration: function()
|
||||
{
|
||||
if (this.ship.script._checkDistance)
|
||||
{
|
||||
this.ship.script._checkDistance();
|
||||
}
|
||||
},
|
||||
condition: ai.conditionLosingCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Stop following me! */
|
||||
{
|
||||
condition: ai.conditionPlayerNearby,
|
||||
configuration: ai.configurationAcquirePlayerAsTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Return to witchpoint */
|
||||
{
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 5
|
||||
this.ship.script._checkDistance();
|
||||
}
|
||||
]);
|
||||
},
|
||||
condition: ai.conditionLosingCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Stop following me! */
|
||||
{
|
||||
condition: ai.conditionPlayerNearby,
|
||||
configuration: ai.configurationAcquirePlayerAsTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Return to witchpoint */
|
||||
{
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 5
|
||||
}
|
||||
]);
|
||||
}
|
@ -30,149 +30,149 @@ this.name = "Oolite Pirate AI";
|
||||
this.version = "1.79";
|
||||
|
||||
this.aiStarted = function() {
|
||||
this.ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
this.ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
|
||||
ai.setParameter("oolite_flag_watchForCargo",true);
|
||||
/* This communication is necessary but needs more variety and moving to descriptions.plist so it can be translated */
|
||||
ai.setCommunication("oolite_piracyAlert","You're outnumbered, [p1]! Power down your weapons, dump [p2] containers and we'll let you go.");
|
||||
ai.setParameter("oolite_flag_watchForCargo",true);
|
||||
/* This communication is necessary but needs more variety and moving to descriptions.plist so it can be translated */
|
||||
ai.setCommunicationsRole("pirate");
|
||||
|
||||
|
||||
ai.setPriorities([
|
||||
/* Combat */
|
||||
ai.setPriorities([
|
||||
/* Combat */
|
||||
{
|
||||
condition: ai.conditionLosingCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionCargoDemandsMet,
|
||||
/* Let them go if they've dropped enough cargo and stop firing back */
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionLosingCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionCargoDemandsMet,
|
||||
/* Let them go if they've dropped enough cargo and stop firing back */
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionInCombatWithHostiles,
|
||||
configuration: ai.configurationAcquireHostileCombatTarget,
|
||||
behaviour: ai.behaviourRepelCurrentTarget,
|
||||
reconsider: 5
|
||||
}
|
||||
],
|
||||
falsebranch: [
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsSalvageForGroup,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionScannerContainsSalvageForMe,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourCollectSalvage,
|
||||
reconsider: 20
|
||||
},
|
||||
// if can't scoop, hang around waiting for the others,
|
||||
// unless the entire group has enough cargo
|
||||
{
|
||||
notcondition: ai.conditionGroupHasEnoughLoot,
|
||||
configuration: ai.configurationSetDestinationToGroupLeader,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 15
|
||||
}
|
||||
]
|
||||
},
|
||||
/* Stay out of the way of hunters */
|
||||
{
|
||||
condition: ai.conditionScannerContainsHunters,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourLeaveVicinityOfTarget,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Regroup if necessary */
|
||||
{
|
||||
preconfiguration: ai.configurationAppointGroupLeader,
|
||||
condition: ai.conditionGroupIsSeparated,
|
||||
configuration: ai.configurationSetDestinationToGroupLeader,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 15
|
||||
},
|
||||
{
|
||||
condition: ai.conditionGroupHasEnoughLoot,
|
||||
/* Find a station to dock at */
|
||||
truebranch: [
|
||||
/* TODO */
|
||||
{
|
||||
condition: ai.conditionIsGroupLeader,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionFriendlyStationNearby,
|
||||
configuration: ai.configurationSetNearbyFriendlyStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionFriendlyStationExists,
|
||||
configuration: ai.configurationSetDestinationToNearestFriendlyStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionCanWitchspaceOut,
|
||||
configuration: ai.configurationSelectWitchspaceDestination,
|
||||
behaviour: ai.behaviourEnterWitchspace,
|
||||
reconsider: 20
|
||||
}
|
||||
]
|
||||
},
|
||||
/* Once the group leader has docked, another one gets
|
||||
* appointed, and they can decide what to do next */
|
||||
{
|
||||
behaviour: ai.behaviourFollowGroupLeader,
|
||||
reconsider: 15
|
||||
}
|
||||
|
||||
],
|
||||
/* Look for more loot */
|
||||
falsebranch: [
|
||||
{
|
||||
condition: ai.conditionIsGroupLeader,
|
||||
truebranch: [
|
||||
{
|
||||
preconfiguration: ai.configurationForgetCargoDemand,
|
||||
condition: ai.conditionScannerContainsPirateVictims,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionCombatOddsGood,
|
||||
behaviour: ai.behaviourRobTarget,
|
||||
reconsider: 5
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
/* move to a position on one of the space lanes, preferring lane 1 */
|
||||
configuration: ai.configurationSetDestinationToPirateLurk,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
behaviour: ai.behaviourFollowGroupLeader,
|
||||
reconsider: 15
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
// full of loot, but stuck in system and no friendly stations
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
// TODO: behaviour search for wormholes
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
condition: ai.conditionInCombatWithHostiles,
|
||||
configuration: ai.configurationAcquireHostileCombatTarget,
|
||||
behaviour: ai.behaviourRepelCurrentTarget,
|
||||
reconsider: 5
|
||||
}
|
||||
]);
|
||||
],
|
||||
falsebranch: [
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsSalvageForGroup,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionScannerContainsSalvageForMe,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourCollectSalvage,
|
||||
reconsider: 20
|
||||
},
|
||||
// if can't scoop, hang around waiting for the others,
|
||||
// unless the entire group has enough cargo
|
||||
{
|
||||
notcondition: ai.conditionGroupHasEnoughLoot,
|
||||
configuration: ai.configurationSetDestinationToGroupLeader,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 15
|
||||
}
|
||||
]
|
||||
},
|
||||
/* Stay out of the way of hunters */
|
||||
{
|
||||
condition: ai.conditionScannerContainsHunters,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourLeaveVicinityOfTarget,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Regroup if necessary */
|
||||
{
|
||||
preconfiguration: ai.configurationAppointGroupLeader,
|
||||
condition: ai.conditionGroupIsSeparated,
|
||||
configuration: ai.configurationSetDestinationToGroupLeader,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 15
|
||||
},
|
||||
{
|
||||
condition: ai.conditionGroupHasEnoughLoot,
|
||||
/* Find a station to dock at */
|
||||
truebranch: [
|
||||
/* TODO */
|
||||
{
|
||||
condition: ai.conditionIsGroupLeader,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionFriendlyStationNearby,
|
||||
configuration: ai.configurationSetNearbyFriendlyStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionFriendlyStationExists,
|
||||
configuration: ai.configurationSetDestinationToNearestFriendlyStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionCanWitchspaceOut,
|
||||
configuration: ai.configurationSelectWitchspaceDestination,
|
||||
behaviour: ai.behaviourEnterWitchspace,
|
||||
reconsider: 20
|
||||
}
|
||||
]
|
||||
},
|
||||
/* Once the group leader has docked, another one gets
|
||||
* appointed, and they can decide what to do next */
|
||||
{
|
||||
behaviour: ai.behaviourFollowGroupLeader,
|
||||
reconsider: 15
|
||||
}
|
||||
|
||||
],
|
||||
/* Look for more loot */
|
||||
falsebranch: [
|
||||
{
|
||||
condition: ai.conditionIsGroupLeader,
|
||||
truebranch: [
|
||||
{
|
||||
preconfiguration: ai.configurationForgetCargoDemand,
|
||||
condition: ai.conditionScannerContainsPirateVictims,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionCombatOddsGood,
|
||||
behaviour: ai.behaviourRobTarget,
|
||||
reconsider: 5
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
/* move to a position on one of the space lanes, preferring lane 1 */
|
||||
configuration: ai.configurationSetDestinationToPirateLurk,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
behaviour: ai.behaviourFollowGroupLeader,
|
||||
reconsider: 15
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
// full of loot, but stuck in system and no friendly stations
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
// TODO: behaviour search for wormholes
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]);
|
||||
|
||||
}
|
@ -30,142 +30,141 @@ this.name = "Oolite Police AI";
|
||||
this.version = "1.79";
|
||||
|
||||
this.aiStarted = function() {
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
|
||||
ai.setParameter("oolite_flag_listenForDistressCall",true);
|
||||
ai.setParameter("oolite_flag_markOffenders",true);
|
||||
ai.setParameter("oolite_flag_listenForDistressCall",true);
|
||||
ai.setParameter("oolite_flag_markOffenders",true);
|
||||
|
||||
if (this.ship.primaryRole == "police-station-patrol") // TODO: some way to determine whether this ship should launch as station patrol
|
||||
if (this.ship.primaryRole == "police-station-patrol") // TODO: some way to determine whether this ship should launch as station patrol
|
||||
{
|
||||
ai.setParameter("oolite_leaderRole","police-station-patrol");
|
||||
ai.setWaypointGenerator(ai.waypointsStationPatrol);
|
||||
ai.setParameter("oolite_flag_patrolStation",true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ai.setParameter("oolite_leaderRole","police");
|
||||
ai.setWaypointGenerator(ai.waypointsSpacelanePatrol);
|
||||
}
|
||||
|
||||
ai.setParameter("oolite_escortRole","wingman");
|
||||
/* Needs to use existing entries in descriptions.plist */
|
||||
|
||||
ai.setCommunicationsRole("police");
|
||||
|
||||
// TODO: return to base after long patrols
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
{
|
||||
ai.setParameter("oolite_leaderRole","police-station-patrol");
|
||||
ai.setWaypointGenerator(ai.waypointsStationPatrol);
|
||||
ai.setParameter("oolite_flag_patrolStation",true);
|
||||
}
|
||||
else
|
||||
condition: ai.conditionLosingCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
ai.setParameter("oolite_leaderRole","police");
|
||||
ai.setWaypointGenerator(ai.waypointsSpacelanePatrol);
|
||||
}
|
||||
|
||||
ai.setParameter("oolite_escortRole","wingman");
|
||||
/* Needs to use existing entries in descriptions.plist */
|
||||
ai.setCommunication("oolite_markForFines","Attention, [p1]. Your offences will result in a fine if you dock at %H station..");
|
||||
|
||||
ai.setCommunication("oolite_patrolReportIn","[p1], sector is clear");
|
||||
|
||||
// TODO: return to base after long patrols
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Check for distress calls */
|
||||
{
|
||||
condition: ai.conditionHasReceivedDistressCall,
|
||||
behaviour: ai.behaviourRespondToDistressCall,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Check for offenders */
|
||||
{
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsFugitive,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 1
|
||||
},
|
||||
{
|
||||
condition: ai.conditionScannerContainsHuntableOffender,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 1
|
||||
},
|
||||
{
|
||||
condition: ai.conditionScannerContainsFineableOffender,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourFineCurrentTarget,
|
||||
reconsider: 10
|
||||
},
|
||||
/* What about escape pods? */
|
||||
{
|
||||
condition: ai.conditionScannerContainsEscapePods,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourCollectSalvage,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Regroup if necessary */
|
||||
{
|
||||
preconfiguration: ai.configurationAppointGroupLeader,
|
||||
condition: ai.conditionGroupIsSeparated,
|
||||
configuration: ai.configurationSetDestinationToGroupLeader,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 15
|
||||
},
|
||||
{
|
||||
condition: ai.conditionGroupLeaderIsStation,
|
||||
/* Group leader is the station: a short-range patrol or
|
||||
* defense ship */
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionLosingCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
condition: ai.conditionHasWaypoint,
|
||||
configuration: ai.configurationSetDestinationToWaypoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
/* No patrol route set up. Make one */
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Check for distress calls */
|
||||
{
|
||||
condition: ai.conditionHasReceivedDistressCall,
|
||||
behaviour: ai.behaviourRespondToDistressCall,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Check for offenders */
|
||||
{
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsFugitive,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 1
|
||||
},
|
||||
{
|
||||
condition: ai.conditionScannerContainsHuntableOffender,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourDestroyCurrentTarget,
|
||||
reconsider: 1
|
||||
},
|
||||
{
|
||||
condition: ai.conditionScannerContainsFineableOffender,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourFineCurrentTarget,
|
||||
reconsider: 10
|
||||
},
|
||||
/* What about escape pods? */
|
||||
{
|
||||
condition: ai.conditionScannerContainsEscapePods,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourCollectSalvage,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Regroup if necessary */
|
||||
{
|
||||
preconfiguration: ai.configurationAppointGroupLeader,
|
||||
condition: ai.conditionGroupIsSeparated,
|
||||
configuration: ai.configurationSetDestinationToGroupLeader,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 15
|
||||
},
|
||||
{
|
||||
condition: ai.conditionGroupLeaderIsStation,
|
||||
/* Group leader is the station: a short-range patrol or
|
||||
* defense ship */
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionHasWaypoint,
|
||||
configuration: ai.configurationSetDestinationToWaypoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
/* No patrol route set up. Make one */
|
||||
{
|
||||
configuration: ai.configurationSetWaypoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
],
|
||||
/* Group leader is not station: i.e. this is a long-range
|
||||
* patrol unit */
|
||||
falsebranch: [
|
||||
{
|
||||
/* The group leader leads the patrol */
|
||||
condition: ai.conditionIsGroupLeader,
|
||||
truebranch: [
|
||||
/* Nothing interesting here. Patrol for a bit */
|
||||
{
|
||||
condition: ai.conditionHasWaypoint,
|
||||
configuration: ai.configurationSetDestinationToWaypoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
/* No patrol route set up. Make one */
|
||||
{
|
||||
configuration: ai.configurationSetWaypoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
],
|
||||
/* Other ships in the group will set themselves up
|
||||
* as escorts if possible, or looser followers if
|
||||
* not */
|
||||
falsebranch: [
|
||||
{
|
||||
preconfiguration: ai.configurationEscortGroupLeader,
|
||||
condition: ai.conditionIsEscorting,
|
||||
behaviour: ai.behaviourEscortMothership,
|
||||
reconsider: 30
|
||||
},
|
||||
/* if we can't set up as an escort */
|
||||
{
|
||||
behaviour: ai.behaviourFollowGroupLeader,
|
||||
reconsider: 15
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
configuration: ai.configurationSetWaypoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]);
|
||||
],
|
||||
/* Group leader is not station: i.e. this is a long-range
|
||||
* patrol unit */
|
||||
falsebranch: [
|
||||
{
|
||||
/* The group leader leads the patrol */
|
||||
condition: ai.conditionIsGroupLeader,
|
||||
truebranch: [
|
||||
/* Nothing interesting here. Patrol for a bit */
|
||||
{
|
||||
condition: ai.conditionHasWaypoint,
|
||||
configuration: ai.configurationSetDestinationToWaypoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
/* No patrol route set up. Make one */
|
||||
{
|
||||
configuration: ai.configurationSetWaypoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
],
|
||||
/* Other ships in the group will set themselves up
|
||||
* as escorts if possible, or looser followers if
|
||||
* not */
|
||||
falsebranch: [
|
||||
{
|
||||
preconfiguration: ai.configurationEscortGroupLeader,
|
||||
condition: ai.conditionIsEscorting,
|
||||
behaviour: ai.behaviourEscortMothership,
|
||||
reconsider: 30
|
||||
},
|
||||
/* if we can't set up as an escort */
|
||||
{
|
||||
behaviour: ai.behaviourFollowGroupLeader,
|
||||
reconsider: 15
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
||||
|
||||
}
|
@ -32,6 +32,8 @@ this.version = "1.79";
|
||||
this.aiStarted = function() {
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
|
||||
ai.setCommunicationsRole("station");
|
||||
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
{
|
||||
|
@ -30,63 +30,64 @@ this.name = "Oolite Scavenger AI";
|
||||
this.version = "1.79";
|
||||
|
||||
this.aiStarted = function() {
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
|
||||
ai.setCommunicationsRole("scavenger");
|
||||
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Is there any loot? */
|
||||
{
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsSalvageForMe,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourCollectSalvage,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Branch for mining ships: if we can usefully mine asteroids, do so */
|
||||
{
|
||||
condition: ai.conditionScannerContainsMiningOpportunity,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourMineTarget,
|
||||
reconsider: 20
|
||||
},
|
||||
/* No loot and no safe way to make some; return to base */
|
||||
{
|
||||
condition: ai.conditionHomeStationNearby,
|
||||
configuration: ai.configurationSetHomeStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionHomeStationExists,
|
||||
configuration: ai.configurationSetDestinationToHomeStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
/* Or at least return to somewhere */
|
||||
{
|
||||
condition: ai.conditionFriendlyStationNearby,
|
||||
configuration: ai.configurationSetNearbyFriendlyStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionFriendlyStationExists,
|
||||
configuration: ai.configurationSetDestinationToNearestFriendlyStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
// stuck and no friendly stations
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
// TODO: behaviour search for wormholes
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]);
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Is there any loot? */
|
||||
{
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsSalvageForMe,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourCollectSalvage,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Branch for mining ships: if we can usefully mine asteroids, do so */
|
||||
{
|
||||
condition: ai.conditionScannerContainsMiningOpportunity,
|
||||
configuration: ai.configurationAcquireScannedTarget,
|
||||
behaviour: ai.behaviourMineTarget,
|
||||
reconsider: 20
|
||||
},
|
||||
/* No loot and no safe way to make some; return to base */
|
||||
{
|
||||
condition: ai.conditionHomeStationNearby,
|
||||
configuration: ai.configurationSetHomeStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionHomeStationExists,
|
||||
configuration: ai.configurationSetDestinationToHomeStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
/* Or at least return to somewhere */
|
||||
{
|
||||
condition: ai.conditionFriendlyStationNearby,
|
||||
configuration: ai.configurationSetNearbyFriendlyStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionFriendlyStationExists,
|
||||
configuration: ai.configurationSetDestinationToNearestFriendlyStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
// stuck and no friendly stations
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
// TODO: behaviour search for wormholes
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]);
|
||||
}
|
@ -30,59 +30,59 @@ this.name = "Oolite Shuttle AI";
|
||||
this.version = "1.79";
|
||||
|
||||
this.aiStarted = function() {
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
|
||||
ai.setParameter("oolite_flag_sendsDistressCalls",true);
|
||||
ai.setParameter("oolite_flag_allowPlanetaryLanding",true);
|
||||
ai.setParameter("oolite_flag_sendsDistressCalls",true);
|
||||
ai.setParameter("oolite_flag_allowPlanetaryLanding",true);
|
||||
|
||||
ai.setCommunication("oolite_landingOnPlanet","Commencing final approach to %N spaceport");
|
||||
ai.setCommunicationsRole("shuttle");
|
||||
|
||||
ai.setPriorities([
|
||||
ai.setPriorities([
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
behaviour: ai.behaviourFleeCombat
|
||||
},
|
||||
{
|
||||
condition: ai.conditionHasSelectedStation,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
behaviour: ai.behaviourFleeCombat
|
||||
condition: ai.conditionSelectedStationNearby,
|
||||
configuration: ai.configurationSetSelectedStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionHasSelectedStation,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionSelectedStationNearby,
|
||||
configuration: ai.configurationSetSelectedStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
configuration: ai.configurationSetDestinationToSelectedStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
condition: ai.conditionHasSelectedPlanet,
|
||||
truebranch: [
|
||||
{
|
||||
preconfiguration: ai.configurationSetDestinationToSelectedPlanet,
|
||||
condition: ai.conditionNearDestination,
|
||||
behaviour: ai.behaviourLandOnPlanet
|
||||
},
|
||||
{
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]
|
||||
},
|
||||
/* TODO: need to try to hitchhike out! */
|
||||
{
|
||||
condition: ai.conditionInInterstellarSpace,
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
configuration: ai.configurationSelectShuttleDestination,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 1
|
||||
configuration: ai.configurationSetDestinationToSelectedStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]);
|
||||
]
|
||||
},
|
||||
{
|
||||
condition: ai.conditionHasSelectedPlanet,
|
||||
truebranch: [
|
||||
{
|
||||
preconfiguration: ai.configurationSetDestinationToSelectedPlanet,
|
||||
condition: ai.conditionNearDestination,
|
||||
behaviour: ai.behaviourLandOnPlanet
|
||||
},
|
||||
{
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]
|
||||
},
|
||||
/* TODO: need to try to hitchhike out! */
|
||||
{
|
||||
condition: ai.conditionInInterstellarSpace,
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
configuration: ai.configurationSelectShuttleDestination,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 1
|
||||
}
|
||||
]);
|
||||
}
|
@ -30,44 +30,44 @@ this.name = "Oolite Main Station AI";
|
||||
this.version = "1.79";
|
||||
|
||||
this.aiStarted = function() {
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
|
||||
ai.setParameter("oolite_flag_listenForDistressCall",true);
|
||||
ai.setParameter("oolite_flag_markOffenders",true);
|
||||
ai.setParameter("oolite_stationPatrolRole","police-station-patrol");
|
||||
ai.setParameter("oolite_flag_listenForDistressCall",true);
|
||||
ai.setParameter("oolite_flag_markOffenders",true);
|
||||
ai.setParameter("oolite_stationPatrolRole","police-station-patrol");
|
||||
|
||||
ai.setCommunication("oolite_distressResponseAggressor","This is protected space, [p1]. Acts of aggression will not be tolerated!");
|
||||
ai.setCommunicationsRole("station");
|
||||
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
{
|
||||
preconfiguration: ai.configurationStationValidateTarget,
|
||||
condition: ai.conditionInCombat,
|
||||
behaviour: ai.behaviourStationLaunchDefenseShips,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Respond to distress calls */
|
||||
{
|
||||
condition: ai.conditionHasReceivedDistressCall,
|
||||
behaviour: ai.behaviourStationRespondToDistressCall,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Scan */
|
||||
{
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsSalvage,
|
||||
behaviour: ai.behaviourStationLaunchSalvager,
|
||||
reconsider: 60 // long delay to avoid launching too many at once
|
||||
},
|
||||
{
|
||||
notcondition: ai.conditionScannerContainsPatrol,
|
||||
behaviour: ai.behaviourStationLaunchPatrol,
|
||||
reconsider: 60
|
||||
},
|
||||
{
|
||||
configuration: ai.configurationStationReduceAlertLevel,
|
||||
behaviour: ai.behaviourStationManageTraffic,
|
||||
reconsider: 60
|
||||
}
|
||||
]);
|
||||
ai.setPriorities([
|
||||
/* Fight */
|
||||
{
|
||||
preconfiguration: ai.configurationStationValidateTarget,
|
||||
condition: ai.conditionInCombat,
|
||||
behaviour: ai.behaviourStationLaunchDefenseShips,
|
||||
reconsider: 5
|
||||
},
|
||||
/* Respond to distress calls */
|
||||
{
|
||||
condition: ai.conditionHasReceivedDistressCall,
|
||||
behaviour: ai.behaviourStationRespondToDistressCall,
|
||||
reconsider: 20
|
||||
},
|
||||
/* Scan */
|
||||
{
|
||||
preconfiguration: ai.configurationCheckScanner,
|
||||
condition: ai.conditionScannerContainsSalvage,
|
||||
behaviour: ai.behaviourStationLaunchSalvager,
|
||||
reconsider: 60 // long delay to avoid launching too many at once
|
||||
},
|
||||
{
|
||||
notcondition: ai.conditionScannerContainsPatrol,
|
||||
behaviour: ai.behaviourStationLaunchPatrol,
|
||||
reconsider: 60
|
||||
},
|
||||
{
|
||||
configuration: ai.configurationStationReduceAlertLevel,
|
||||
behaviour: ai.behaviourStationManageTraffic,
|
||||
reconsider: 60
|
||||
}
|
||||
]);
|
||||
}
|
@ -30,127 +30,122 @@ this.name = "Oolite Trader AI";
|
||||
this.version = "1.79";
|
||||
|
||||
this.aiStarted = function() {
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
var ai = new worldScripts["oolite-libPriorityAI"].AILib(this.ship);
|
||||
|
||||
ai.setParameter("oolite_flag_sendsDistressCalls",true);
|
||||
ai.setParameter("oolite_flag_sendsDistressCalls",true);
|
||||
|
||||
/* Communications currently for debugging purposes. Need to either
|
||||
* be removed or given a much bigger set of phrases to choose from
|
||||
* before 1.79 */
|
||||
ai.setCommunication("oolite_selectedStation","Heading for [p1]");
|
||||
ai.setCommunication("oolite_selectedWitchspaceDestination","Prepare for witchspace jump to [p1]");
|
||||
ai.setCommunication("oolite_agreeingToDumpCargo","Take our cargo but please let us go!");
|
||||
ai.setCommunicationsRole("trader");
|
||||
|
||||
|
||||
ai.setPriorities([
|
||||
ai.setPriorities([
|
||||
{
|
||||
condition: ai.conditionLosingCombat,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionLosingCombat,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionPiratesCanBePaidOff,
|
||||
behaviour: ai.behaviourPayOffPirates,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
// not required to destroy target, just to get it to leave
|
||||
behaviour: ai.behaviourRepelCurrentTarget,
|
||||
reconsider: 5
|
||||
condition: ai.conditionPiratesCanBePaidOff,
|
||||
behaviour: ai.behaviourPayOffPirates,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionCargoIsProfitableHere,
|
||||
// branch to head for station
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionHasSelectedStation,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionSelectedStationNearby,
|
||||
configuration: ai.configurationSetSelectedStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionSelectedStationNearMainPlanet,
|
||||
truebranch: [
|
||||
{
|
||||
notcondition: ai.conditionMainPlanetNearby,
|
||||
configuration: ai.configurationSetDestinationToMainPlanet,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]
|
||||
},
|
||||
// either the station isn't near the planet, or we are
|
||||
{
|
||||
configuration: ai.configurationSetDestinationToSelectedStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
],
|
||||
falsebranch: [
|
||||
{
|
||||
configuration: ai.configurationSelectRandomTradeStation,
|
||||
behaviour: ai.behaviourReconsider
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
// jump to another system if possible, sunskim if not
|
||||
falsebranch: [
|
||||
{
|
||||
condition: ai.conditionCanWitchspaceOut,
|
||||
configuration: ai.configurationSelectWitchspaceDestination,
|
||||
behaviour: ai.behaviourEnterWitchspace,
|
||||
reconsider: 20
|
||||
},
|
||||
{
|
||||
condition: ai.conditionReadyToSunskim,
|
||||
configuration: ai.configurationSetDestinationToSunskimEnd,
|
||||
behaviour: ai.behaviourSunskim,
|
||||
reconsider: 20
|
||||
},
|
||||
{
|
||||
condition: ai.conditionSunskimPossible,
|
||||
configuration: ai.configurationSetDestinationToSunskimStart,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]
|
||||
}, // end of cargoprofitable true/false branches
|
||||
{
|
||||
// if we're here, the cargo isn't profitable, and we can't
|
||||
// witchspace out or sunskim
|
||||
condition: ai.conditionInInterstellarSpace,
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
// TODO: behaviour search for wormholes
|
||||
behaviour: ai.behaviourApproachDestination
|
||||
},
|
||||
{
|
||||
condition: ai.conditionFriendlyStationNearby,
|
||||
configuration: ai.configurationSetNearbyFriendlyStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionFriendlyStationExists,
|
||||
configuration: ai.configurationSetDestinationToNearestFriendlyStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
// stuck and no friendly stations
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
// TODO: behaviour search for wormholes
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
behaviour: ai.behaviourFleeCombat,
|
||||
reconsider: 5
|
||||
}
|
||||
]);
|
||||
]
|
||||
},
|
||||
{
|
||||
condition: ai.conditionInCombat,
|
||||
configuration: ai.configurationAcquireCombatTarget,
|
||||
// not required to destroy target, just to get it to leave
|
||||
behaviour: ai.behaviourRepelCurrentTarget,
|
||||
reconsider: 5
|
||||
},
|
||||
{
|
||||
condition: ai.conditionCargoIsProfitableHere,
|
||||
// branch to head for station
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionHasSelectedStation,
|
||||
truebranch: [
|
||||
{
|
||||
condition: ai.conditionSelectedStationNearby,
|
||||
configuration: ai.configurationSetSelectedStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionSelectedStationNearMainPlanet,
|
||||
truebranch: [
|
||||
{
|
||||
notcondition: ai.conditionMainPlanetNearby,
|
||||
configuration: ai.configurationSetDestinationToMainPlanet,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]
|
||||
},
|
||||
// either the station isn't near the planet, or we are
|
||||
{
|
||||
configuration: ai.configurationSetDestinationToSelectedStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
],
|
||||
falsebranch: [
|
||||
{
|
||||
configuration: ai.configurationSelectRandomTradeStation,
|
||||
behaviour: ai.behaviourReconsider
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
// jump to another system if possible, sunskim if not
|
||||
falsebranch: [
|
||||
{
|
||||
condition: ai.conditionCanWitchspaceOut,
|
||||
configuration: ai.configurationSelectWitchspaceDestination,
|
||||
behaviour: ai.behaviourEnterWitchspace,
|
||||
reconsider: 20
|
||||
},
|
||||
{
|
||||
condition: ai.conditionReadyToSunskim,
|
||||
configuration: ai.configurationSetDestinationToSunskimEnd,
|
||||
behaviour: ai.behaviourSunskim,
|
||||
reconsider: 20
|
||||
},
|
||||
{
|
||||
condition: ai.conditionSunskimPossible,
|
||||
configuration: ai.configurationSetDestinationToSunskimStart,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]
|
||||
}, // end of cargoprofitable true/false branches
|
||||
{
|
||||
// if we're here, the cargo isn't profitable, and we can't
|
||||
// witchspace out or sunskim
|
||||
condition: ai.conditionInInterstellarSpace,
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
// TODO: behaviour search for wormholes
|
||||
behaviour: ai.behaviourApproachDestination
|
||||
},
|
||||
{
|
||||
condition: ai.conditionFriendlyStationNearby,
|
||||
configuration: ai.configurationSetNearbyFriendlyStationForDocking,
|
||||
behaviour: ai.behaviourDockWithStation,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
condition: ai.conditionFriendlyStationExists,
|
||||
configuration: ai.configurationSetDestinationToNearestFriendlyStation,
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
},
|
||||
{
|
||||
// stuck and no friendly stations
|
||||
configuration: ai.configurationSetDestinationToWitchpoint,
|
||||
// TODO: behaviour search for wormholes
|
||||
behaviour: ai.behaviourApproachDestination,
|
||||
reconsider: 30
|
||||
}
|
||||
]);
|
||||
}
|
@ -592,6 +592,16 @@
|
||||
"Leave %H now or be destroyed.",
|
||||
"%H Police. Offending ship targeted. Moving to intercept."
|
||||
);
|
||||
|
||||
// comms message templates for priority AI
|
||||
"oolite-comms-makePirateDemand" = "Your cargo or your life, [oolite_entityName]. [oolite_demandSize] barrels and we'll let you go."; // TODO: variety
|
||||
"oolite-comms-acceptPirateDemand" = "[beg-for-mercy]";
|
||||
"oolite-comms-makeDistressCall" = "[distress-call]";
|
||||
"oolite-comms-markForFines" = "[police-warning]";
|
||||
"oolite-comms-distressResponseAggressor" = "[police-attack-warning]";
|
||||
"oolite-comms-offenceDetected" = "[police-attack-warning]";
|
||||
|
||||
|
||||
// /general docking
|
||||
"docking-welcome" =
|
||||
(
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -773,9 +773,12 @@
|
||||
[self performFlee];
|
||||
}
|
||||
|
||||
// tell it!
|
||||
if (ship->isPlayer)
|
||||
// tell it! (only plist AIs send comms here; JS AIs are
|
||||
// expected to handle their own)
|
||||
if (ship->isPlayer && ![[[self getAI] name] isEqualToString:@"nullAI.plist"])
|
||||
{
|
||||
[ship doScriptEvent:OOJSID("distressMessageReceived") withArgument:aggressor_ship andArgument:self];
|
||||
|
||||
if (!is_buoy && [self primaryAggressor] == ship && energy < 0.375 * maxEnergy)
|
||||
{
|
||||
[self sendExpandedMessage:@"[beg-for-mercy]" toShip:ship];
|
||||
|
Loading…
x
Reference in New Issue
Block a user