Police witchpoint patrols AI adjustments

This commit is contained in:
cim 2013-08-12 18:45:09 +01:00
parent 2ad55255f1
commit b829eef4a2
3 changed files with 56 additions and 4 deletions

View File

@ -35,12 +35,17 @@ this.aiStarted = function() {
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")
{
ai.setParameter("oolite_leaderRole","police-station-patrol");
ai.setWaypointGenerator(ai.waypointsStationPatrol);
ai.setParameter("oolite_flag_patrolStation",true);
}
else if (this.ship.primaryRole == "police-witchpoint-patrol")
{
ai.setParameter("oolite_leaderRole","police-witchpoint-patrol");
ai.setWaypointGenerator(ai.waypointsWitchpointPatrol);
}
else
{
ai.setParameter("oolite_leaderRole","police");
@ -118,6 +123,10 @@ this.aiStarted = function() {
behaviour: ai.behaviourApproachDestination,
reconsider: 30
},
{
condition: ai.conditionPatrolIsOver,
truebranch: ai.templateReturnToBase()
},
/* No patrol route set up. Make one */
{
configuration: ai.configurationSetWaypoint,
@ -139,6 +148,15 @@ this.aiStarted = function() {
behaviour: ai.behaviourApproachDestination,
reconsider: 30
},
{
condition: ai.conditionPatrolIsOver,
truebranch: [
{
condition: ai.conditionMainPlanetNearby,
truebranch: ai.templateReturnToBase()
}
]
},
/* No patrol route set up. Make one */
{
configuration: ai.configurationSetWaypoint,

View File

@ -362,7 +362,7 @@ this.AILib = function(ship)
var template = worldScripts["oolite-libPriorityAI"]._getCommunication(commsRole,commsPersonality,key);
if (template != "")
{
if (params.isShip)
if (params && params.isShip)
{
params = this.entityCommsParams(params);
}
@ -5017,6 +5017,39 @@ AILib.prototype.waypointsStationPatrol = function()
}
AILib.prototype.waypointsWitchpointPatrol = function()
{
if (this.ship.distanceTravelled > system.mainPlanet.position.z + 200000)
{
this.setParameter("oolite_waypoint",system.mainStation.position);
this.setParameter("oolite_waypointRange",10000);
}
else
{
var waypoints = [
new Vector3D(15E3,0,5E3),
new Vector3D(0,15E3,-5E3),
new Vector3D(-15E3,0,5E3),
new Vector3D(0,-15E3,-5E3)
];
var waypoint = waypoints[0];
for (var i=0;i<=3;i++)
{
if (this.distance(waypoints[i]) < 500)
{
waypoint = waypoints[(i+1)%4];
break;
}
}
this.setParameter("oolite_waypoint",waypoint);
this.setParameter("oolite_waypointRange",100);
}
}
/* ********** Communications data ****************/
/* Warning: OXPs should only interact with this through the provided

View File

@ -1550,10 +1550,11 @@ this._addInterceptors = function(pos)
for (var i = 0 ; i < h.ships.length ; i++)
{
h.ships[i].bounty = 0;
// h.ships[i].switchAI("policeWitchpointPatrolAI.js");
h.ships[i].primaryRole = "police-witchpoint-patrol";
h.ships[i].maxEscorts = 16;
h.ships[i].homeSystem = system.ID;
h.ships[i].destinationSystem = system.ID;
h.ships[i].AIScript.oolite_intership.initial_group = h.ships.length;
h.ships[i].switchAI("policeAI.js");
}
}