Change autoAIs for more testing what we have so far.
Set trader, pirate, escort, hunter, police AIs to JS by default
This commit is contained in:
parent
5ce15389d6
commit
a4ae37c849
@ -35,16 +35,17 @@ this.aiStarted = function() {
|
||||
ai.setParameter("oolite_flag_listenForDistressCall",true);
|
||||
ai.setParameter("oolite_flag_markOffenders",true);
|
||||
|
||||
if (false) // 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_leaderRole","police");
|
||||
|
||||
ai.setParameter("oolite_escortRole","wingman");
|
||||
/* Needs to use existing entries in descriptions.plist */
|
||||
|
@ -16,15 +16,15 @@
|
||||
|
||||
{
|
||||
"asteroid" = "dumbAI.plist";
|
||||
"escort" = "escortAI.plist";
|
||||
"hunter" = "route1patrolAI.plist";
|
||||
"interceptor" = "route1patrolAI.plist";
|
||||
"escort" = "escortAI.js";
|
||||
"hunter" = "bountyHunterAI.js";
|
||||
"interceptor" = "policeAI.js";
|
||||
"miner" = "minerAI.plist";
|
||||
"pirate" = "pirateAI.plist";
|
||||
"police" = "route1patrolAI.plist";
|
||||
"trader" = "route1traderAI.plist";
|
||||
"pirate" = "pirateAI.js";
|
||||
"police" = "policeAI.js";
|
||||
"trader" = "traderAI.js";
|
||||
"scavenger" = "scavengerAI.plist";
|
||||
"shuttle" = "fallingShuttleAI.plist";
|
||||
"sunskim-trader" = "route2sunskimAI.plist";
|
||||
"wingman" = "escortAI.plist";
|
||||
"sunskim-trader" = "traderAI.js";
|
||||
"wingman" = "policeAI.js";
|
||||
}
|
||||
|
@ -184,7 +184,7 @@
|
||||
{
|
||||
aft_eject_position = "0.0 -20.0 -67.0";
|
||||
aft_weapon_type = "WEAPON_PULSE_LASER";
|
||||
ai_type = "route1traderAI.plist";
|
||||
ai_type = "traderAI.js";
|
||||
auto_ai = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
@ -294,7 +294,7 @@
|
||||
};
|
||||
"oolite_template_asp" = {
|
||||
aft_eject_position = "0.0 -8.0 -21.5";
|
||||
ai_type = "pirateAI.plist";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
@ -513,7 +513,7 @@
|
||||
{
|
||||
aft_eject_position = "0.0 -15.0 -50.5";
|
||||
aft_weapon_type = "WEAPON_BEAM_LASER";
|
||||
ai_type = "route1traderAI.plist";
|
||||
ai_type = "traderAI.js";
|
||||
auto_ai = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
@ -624,7 +624,7 @@
|
||||
{
|
||||
aft_eject_position = "0.0 -18.75 -50.75";
|
||||
aft_weapon_type = "WEAPON_BEAM_LASER";
|
||||
ai_type = "route1traderAI.plist";
|
||||
ai_type = "traderAI.js";
|
||||
auto_ai = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
@ -861,7 +861,7 @@
|
||||
"oolite_template_cobra3" =
|
||||
{
|
||||
aft_eject_position = "0.0 15.5 -33.0";
|
||||
ai_type = "route1traderAI.plist";
|
||||
ai_type = "traderAI.js";
|
||||
auto_ai = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
@ -988,7 +988,7 @@
|
||||
{
|
||||
like_ship = "oolite_template_cobra3";
|
||||
is_template = 1;
|
||||
ai_type = "pirateAI.plist";
|
||||
ai_type = "pirateAI.js";
|
||||
bounty = 50;
|
||||
energy_recharge_rate = 3;
|
||||
forward_weapon_type = "WEAPON_PULSE_LASER";
|
||||
@ -1010,7 +1010,7 @@
|
||||
};
|
||||
"oolite_template_cobramk1" = {
|
||||
aft_eject_position = "0.0 7.5 -21.0";
|
||||
ai_type = "route1traderAI.plist";
|
||||
ai_type = "traderAI.js";
|
||||
auto_ai = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
@ -1111,7 +1111,7 @@
|
||||
{
|
||||
like_ship = "oolite_template_cobramk1";
|
||||
is_template = 1;
|
||||
ai_type = "pirateAI.plist";
|
||||
ai_type = "pirateAI.js";
|
||||
energy_recharge_rate = 3.75;
|
||||
forward_weapon_type = "WEAPON_BEAM_LASER";
|
||||
has_fuel_injection = 0.25;
|
||||
@ -1461,7 +1461,7 @@
|
||||
};
|
||||
"oolite_template_ferdelance" = {
|
||||
aft_eject_position = "0.0 3.0 -38.0";
|
||||
ai_type = "pirateAI.plist";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
@ -1573,7 +1573,7 @@
|
||||
"oolite_template_gecko" =
|
||||
{
|
||||
aft_eject_position = "0.0 4.5 -11.0";
|
||||
ai_type = "pirateAI.plist";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
energy_recharge_rate = 4;
|
||||
@ -1650,7 +1650,7 @@
|
||||
"oolite_template_krait" =
|
||||
{
|
||||
aft_eject_position = "0.0 7.5 -16.5";
|
||||
ai_type = "pirateAI.plist";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
energy_recharge_rate = 2.5;
|
||||
@ -1684,7 +1684,7 @@
|
||||
};
|
||||
"oolite_template_mamba" = {
|
||||
aft_eject_position = "0.0 5.5 -17.0";
|
||||
ai_type = "pirateAI.plist";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
energy_recharge_rate = 3;
|
||||
@ -1748,7 +1748,7 @@
|
||||
"oolite_template_moray" =
|
||||
{
|
||||
aft_eject_position = "0.0 5.75 -8.0";
|
||||
ai_type = "pirateAI.plist";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
@ -1857,7 +1857,7 @@
|
||||
{
|
||||
like_ship = "oolite_template_moray";
|
||||
is_template = 1;
|
||||
ai_type = "route1traderAI.plist";
|
||||
ai_type = "traderAI.js";
|
||||
likely_cargo = 7;
|
||||
max_cargo = 22;
|
||||
materials =
|
||||
@ -1884,7 +1884,7 @@
|
||||
"oolite_template_python" =
|
||||
{
|
||||
aft_eject_position = "0.0 15.5 -50.0";
|
||||
ai_type = "route1traderAI.plist";
|
||||
ai_type = "traderAI.js";
|
||||
auto_ai = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
@ -1987,7 +1987,7 @@
|
||||
{
|
||||
like_ship = "oolite_template_python";
|
||||
is_template = 1;
|
||||
ai_type = "pirateAI.plist";
|
||||
ai_type = "pirateAI.js";
|
||||
energy_recharge_rate = 3.5;
|
||||
escorts = 2;
|
||||
has_ecm = 0.75;
|
||||
@ -2174,7 +2174,7 @@
|
||||
};
|
||||
"oolite_template_sidewinder" = {
|
||||
aft_eject_position = "0.0 7.5 -18.0";
|
||||
ai_type = "pirateAI.plist";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
energy_recharge_rate = 2;
|
||||
@ -2342,7 +2342,7 @@
|
||||
"oolite_template_viper" =
|
||||
{
|
||||
aft_eject_position = "0.0 6.5 -28.0";
|
||||
ai_type = "route1patrolAI.plist";
|
||||
ai_type = "policeAI.js";
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
energy_recharge_rate = 4;
|
||||
exhaust = ("12.5 0.0 -27.5 6.0 6.0 1.5", "-12.5 0.0 -27.5 6.0 6.0 1.5");
|
||||
@ -2456,7 +2456,7 @@
|
||||
"oolite_template_viper-interceptor" =
|
||||
{
|
||||
aft_eject_position = "0.0 10.5 -22.0";
|
||||
ai_type = "route1patrolAI.plist";
|
||||
ai_type = "policeAI.js";
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
energy_recharge_rate = 6;
|
||||
exhaust = (
|
||||
|
@ -561,7 +561,7 @@ this.AILib = function(ship)
|
||||
if (this.ship.group && this.ship.group.leader != this.ship && this.ship.group.leader.escortGroup.containsShip(this.ship))
|
||||
{
|
||||
var leader = this.ship.group.leader;
|
||||
if (leader.target.target == leader && leader.target.hasHostileTarget && leader.target.position.distanceTo(this.ship) < this.ship.scannerRange)
|
||||
if (leader.target && leader.target.target == leader && leader.target.hasHostileTarget && leader.target.position.distanceTo(this.ship) < this.ship.scannerRange)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -1125,7 +1125,7 @@ this.AILib = function(ship)
|
||||
var handlers = {};
|
||||
this.responsesAddStandard(handlers);
|
||||
this.setUpHandlers(handlers);
|
||||
if (!this.ship.target)
|
||||
if (!this.ship.target || !this.ship.target.isValid || !this.ship.target.isShip)
|
||||
{
|
||||
this.reconsiderNow();
|
||||
return;
|
||||
@ -1133,7 +1133,6 @@ this.AILib = function(ship)
|
||||
if (!this.isAggressive(this.ship.target))
|
||||
{
|
||||
// repelling succeeded
|
||||
this.ship.removeDefenseTarget(this.ship.target);
|
||||
if (this.ship.escortGroup)
|
||||
{
|
||||
// also tell escorts to stop attacking it
|
||||
@ -1146,6 +1145,7 @@ this.AILib = function(ship)
|
||||
}
|
||||
}
|
||||
}
|
||||
this.ship.removeDefenseTarget(this.ship.target);
|
||||
this.ship.target = null;
|
||||
}
|
||||
else
|
||||
@ -1810,7 +1810,7 @@ this.AILib = function(ship)
|
||||
{
|
||||
if (this.ship.group && this.ship.group.leader && this.ship.group.leader.hasHostileTarget)
|
||||
{
|
||||
if (this.ship.distanceTo(this.ship.group.leader.target) < this.ship.scannerRange)
|
||||
if (this.ship.position.distanceTo(this.ship.group.leader.target) < this.ship.scannerRange)
|
||||
{
|
||||
this.ship.target = this.ship.group.leader.target;
|
||||
this.ship.addDefenseTarget(this.ship.target);
|
||||
@ -2363,7 +2363,7 @@ this.AILib = function(ship)
|
||||
if (this.getParameter("oolite_flag_markOffenders"))
|
||||
{
|
||||
attacker.setBounty(attacker.bounty | 7,"seen by police");
|
||||
this.addDefenseTarget(attacker);
|
||||
this.ship.addDefenseTarget(attacker);
|
||||
this.reconsiderNow();
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ this.systemWillPopulate = function()
|
||||
{
|
||||
r2t.heatInsulation = reqInsulation;
|
||||
}
|
||||
r2t.switchAI("route2sunskimAI.plist");
|
||||
r2t.switchAI("traderAI.js");
|
||||
}
|
||||
});
|
||||
|
||||
@ -216,10 +216,13 @@ this.systemWillPopulate = function()
|
||||
{
|
||||
var hunter = system.addShips("police",1,pos,0)[0];
|
||||
}
|
||||
hunter.switchAI("policeAI.js");
|
||||
}
|
||||
else
|
||||
{
|
||||
var hunter = system.addShips("hunter",1,pos,0)[0];
|
||||
hunter.switchAI("bountyHunterAI.js");
|
||||
|
||||
}
|
||||
hunter.setBounty(0,"setup actions");
|
||||
return hunter;
|
||||
@ -239,8 +242,6 @@ this.systemWillPopulate = function()
|
||||
groupCount: hunters,
|
||||
callback: function(pos) {
|
||||
var hunter = addHunter(pos);
|
||||
hunter.switchAI("route2patrolAI.plist");
|
||||
hunter.AIState = (Math.random()<0.5)?"HEAD_FOR_PLANET":"HEAD_FOR_SUN";
|
||||
}
|
||||
});
|
||||
|
||||
@ -333,11 +334,16 @@ this.systemWillRepopulate = function()
|
||||
{
|
||||
newtrader.heatInsulation = reqIns;
|
||||
}
|
||||
newtrader.switchAI("route2sunskimAI.plist");
|
||||
newtrader.primaryRole = "trader";
|
||||
newtrader.switchAI("traderAI.js");
|
||||
// and encourage sunskimming
|
||||
newtrader.fuel = Math.random()*2;
|
||||
newtrader.setCargoType("PLENTIFUL_GOODS");
|
||||
}
|
||||
else
|
||||
{
|
||||
var newtrader = system.addShips("trader",1,[0,0,0],7500)[0];
|
||||
newtrader.setCargoType("SCARCE_GOODS");
|
||||
}
|
||||
newtrader.setBounty(0,"setup actions");
|
||||
return;
|
||||
@ -351,14 +357,7 @@ this.systemWillRepopulate = function()
|
||||
if (current < target)
|
||||
{
|
||||
var newpolice = system.mainStation.launchShipWithRole("police");
|
||||
if (Math.random() < 0.2)
|
||||
{
|
||||
newpolice.switchAI("route2patrolAI.plist");
|
||||
}
|
||||
else
|
||||
{
|
||||
newpolice.switchAI("route1patrolAI.plist");
|
||||
}
|
||||
newpolice.switchAI("policeAI.js");
|
||||
newpolice.setBounty(0,"setup actions");
|
||||
}
|
||||
else
|
||||
@ -376,10 +375,7 @@ this.systemWillRepopulate = function()
|
||||
if (current < target)
|
||||
{
|
||||
var newhunter = system.addShips("hunter",1,[0,0,0],7500)[0];
|
||||
if (Math.random() < 0.2)
|
||||
{
|
||||
newhunter.switchAI("route2patrolAI.plist");
|
||||
}
|
||||
newhunter.switchAI("bountyHunterAI.js");
|
||||
newhunter.setBounty(0,"setup actions");
|
||||
}
|
||||
}
|
||||
|
@ -12293,12 +12293,12 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
||||
if ([escort group] == escortGroup) [escort setGroup:nil];
|
||||
if ([escort owner] == self) [escort setOwner:escort];
|
||||
if(target && [target isStation]) [escort setTargetStation:target];
|
||||
// JSAI: needs slightly different implementation of delay
|
||||
// JSAI: handles own delay
|
||||
if (![[[escort getAI] name] isEqualToString:@"nullAI.plist"])
|
||||
{
|
||||
[escort setAITo:@"dockingAI.plist"];
|
||||
[ai setState:@"ABORT" afterDelay:delay + 0.25];
|
||||
}
|
||||
[ai setState:@"ABORT" afterDelay:delay + 0.25];
|
||||
[escort doScriptEvent:OOJSID("escortDock") withArgument:[NSNumber numberWithFloat:delay]];
|
||||
}
|
||||
|
||||
|
@ -1391,13 +1391,15 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, HPVector coords,
|
||||
[ship setCargoFlag:CARGO_FLAG_FULL_PLENTIFUL];
|
||||
if (sunskimmer)
|
||||
{
|
||||
[ship setFuel:(Ranrot()&31)];
|
||||
[UNIVERSE makeSunSkimmer:ship andSetAI:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[ship switchAITo:@"exitingTraderAI.plist"];
|
||||
// JSAI: not needed - traderAI.js handles exiting if full fuel and plentiful cargo
|
||||
// [ship switchAITo:@"exitingTraderAI.plist"];
|
||||
if([ship fuel] == 0) [ship setFuel:70];
|
||||
if ([ship hasRole:@"sunskim-trader"]) [UNIVERSE makeSunSkimmer:ship andSetAI:NO];
|
||||
// if ([ship hasRole:@"sunskim-trader"]) [UNIVERSE makeSunSkimmer:ship andSetAI:NO];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1464,7 +1466,7 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, HPVector coords,
|
||||
[escort_ship setGroup:escortGroup];
|
||||
[escort_ship setOwner:ship];
|
||||
|
||||
[escort_ship switchAITo:@"escortAI.plist"];
|
||||
[escort_ship switchAITo:@"escortAI.js"];
|
||||
[self addShipToLaunchQueue:escort_ship withPriority:NO];
|
||||
|
||||
}
|
||||
@ -1881,7 +1883,7 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, HPVector coords,
|
||||
|
||||
[escort_ship setScanClass: CLASS_NEUTRAL];
|
||||
[escort_ship setCargoFlag: CARGO_FLAG_FULL_PLENTIFUL];
|
||||
[escort_ship switchAITo:@"escortAI.plist"];
|
||||
[escort_ship switchAITo:@"escortAI.js"];
|
||||
[self addShipToLaunchQueue:escort_ship withPriority:NO];
|
||||
|
||||
}
|
||||
@ -1932,10 +1934,10 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, HPVector coords,
|
||||
[patrol_ship setScanClass: CLASS_POLICE];
|
||||
if ([patrol_ship heatInsulation] < [self heatInsulation])
|
||||
[patrol_ship setHeatInsulation:[self heatInsulation]];
|
||||
[patrol_ship setPrimaryRole:@"police"];
|
||||
[patrol_ship setPrimaryRole:@"police-station-patrol"];
|
||||
[patrol_ship setBounty:0 withReason:kOOLegalStatusReasonSetup];
|
||||
[patrol_ship setGroup:[self stationGroup]]; // who's your Daddy
|
||||
[patrol_ship switchAITo:@"planetPatrolAI.plist"];
|
||||
[patrol_ship switchAITo:@"policeAI.js"];
|
||||
[self addShipToLaunchQueue:patrol_ship withPriority:NO];
|
||||
[self acceptPatrolReportFrom:patrol_ship];
|
||||
[patrol_ship autorelease];
|
||||
|
@ -2120,11 +2120,12 @@ GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, DOC
|
||||
[ship setCargoFlag: CARGO_FLAG_FULL_SCARCE];
|
||||
if ([ship hasRole:@"sunskim-trader"] && randf() < 0.25) // select 1/4 of the traders suitable for sunskimming.
|
||||
{
|
||||
[ship setCargoFlag: CARGO_FLAG_FULL_PLENTIFUL];
|
||||
[self makeSunSkimmer:ship andSetAI:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[ship switchAITo:@"route1traderAI.plist"];
|
||||
[ship switchAITo:@"traderAI.js"];
|
||||
}
|
||||
|
||||
if (([ship pendingEscortCount] > 0)&&((Ranrot() % 7) < government)) // remove escorts if we feel safe
|
||||
@ -2272,11 +2273,12 @@ GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, DOC
|
||||
[ship setCargoFlag:CARGO_FLAG_FULL_SCARCE];
|
||||
if ([ship hasRole:@"sunskim-trader"] && randf() < 0.25)
|
||||
{
|
||||
[ship setCargoFlag:CARGO_FLAG_FULL_PLENTIFUL];
|
||||
[self makeSunSkimmer:ship andSetAI:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[ship switchAITo:@"route1traderAI.plist"];
|
||||
[ship switchAITo:@"traderAI.js"];
|
||||
}
|
||||
}
|
||||
else if ([role isEqual:@"pirate"])
|
||||
@ -8036,7 +8038,8 @@ static NSDictionary *sCachedSystemData = nil;
|
||||
|
||||
- (void) makeSunSkimmer:(ShipEntity *) ship andSetAI:(BOOL)setAI
|
||||
{
|
||||
if (setAI) [ship switchAITo:@"route2sunskimAI.plist"]; // perfectly acceptable for both route 2 & 3
|
||||
if (setAI) [ship switchAITo:@"traderAI.js"]; // perfectly acceptable for both route 2 & 3
|
||||
[ship setFuel:(Ranrot()&31)];
|
||||
// slow ships need extra insulation or they will burn up when sunskimming. (Tested at biggest sun in G3: Aenqute)
|
||||
float minInsulation = 1000 / [ship maxFlightSpeed] + 1;
|
||||
if ([ship heatInsulation] < minInsulation) [ship setHeatInsulation:minInsulation];
|
||||
|
Loading…
x
Reference in New Issue
Block a user