Add auto_weapons (ship.autoWeapons) parameter to shipdata.
If set (default 0), then populator has discretion to change ship weapons and other items to fit the ship's role. So far just does fore and aft lasers.
This commit is contained in:
parent
1015ec32a4
commit
894d3d683b
@ -49,6 +49,7 @@
|
||||
aft_eject_position = "0.0 -4.5 -23.0";
|
||||
ai_type = "scavengerAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
(
|
||||
@ -186,6 +187,7 @@
|
||||
aft_weapon_type = "WEAPON_PULSE_LASER";
|
||||
ai_type = "traderAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
(
|
||||
@ -296,7 +298,8 @@
|
||||
};
|
||||
"oolite_template_anaconda-pirate" =
|
||||
{
|
||||
like_ship = "oolite_template_anaconda";
|
||||
// like_ship = "oolite_template_anaconda";
|
||||
like_ship = "anaconda"; // will switch to the template after 1.80
|
||||
is_template = 1;
|
||||
aft_weapon_type = "WEAPON_BEAM_LASER";
|
||||
escort_roles = (
|
||||
@ -318,6 +321,7 @@
|
||||
aft_eject_position = "0.0 -8.0 -21.5";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
(
|
||||
@ -537,6 +541,7 @@
|
||||
aft_weapon_type = "WEAPON_BEAM_LASER";
|
||||
ai_type = "traderAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
(
|
||||
@ -642,7 +647,8 @@
|
||||
};
|
||||
"oolite_template_boa-pirate" =
|
||||
{
|
||||
like_ship = "oolite_template_boa";
|
||||
// like_ship = "oolite_template_boa";
|
||||
like_ship = "boa"; // will switch to the template after 1.80
|
||||
is_template = 1;
|
||||
escort_roles = (
|
||||
{ "role" = "pirate-medium-fighter"; min = 2; max = 2; }
|
||||
@ -663,6 +669,7 @@
|
||||
aft_weapon_type = "WEAPON_BEAM_LASER";
|
||||
ai_type = "traderAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
(
|
||||
@ -768,7 +775,8 @@
|
||||
};
|
||||
"oolite_template_boa-mk2-pirate" =
|
||||
{
|
||||
like_ship = "oolite_template_boa-mk2";
|
||||
// like_ship = "oolite_template_boa-mk2";
|
||||
like_ship = "boa-mk2"; // will switch to the template after 1.80
|
||||
is_template = 1;
|
||||
escort_roles = (
|
||||
{ "role" = "pirate-heavy-fighter"; min = 2; max = 2; }
|
||||
@ -914,6 +922,7 @@
|
||||
aft_eject_position = "0.0 15.5 -33.0";
|
||||
ai_type = "traderAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
(
|
||||
@ -1058,6 +1067,7 @@
|
||||
aft_eject_position = "0.0 7.5 -21.0";
|
||||
ai_type = "traderAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
(
|
||||
@ -1518,6 +1528,7 @@
|
||||
aft_eject_position = "0.0 3.0 -38.0";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
(
|
||||
@ -1630,6 +1641,7 @@
|
||||
aft_eject_position = "0.0 4.5 -11.0";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
energy_recharge_rate = 4;
|
||||
exhaust = ("0.0 0.0 -20.0 5.0 4.0 1.0");
|
||||
@ -1707,6 +1719,7 @@
|
||||
aft_eject_position = "0.0 7.5 -16.5";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
energy_recharge_rate = 2.5;
|
||||
exhaust = ("-7.5 0.0 -35.58 4.0 4.0 1.0", "7.5 0.0 -35.58 4.0 4.0 1.0");
|
||||
@ -1741,6 +1754,7 @@
|
||||
aft_eject_position = "0.0 5.5 -17.0";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
energy_recharge_rate = 3;
|
||||
exhaust = ("0.0 0.0 -27.5 10.0 8.0 1.0");
|
||||
@ -1814,6 +1828,7 @@
|
||||
aft_eject_position = "0.0 5.75 -8.0";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
(
|
||||
@ -1950,6 +1965,7 @@
|
||||
aft_eject_position = "0.0 15.5 -50.0";
|
||||
ai_type = "traderAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
custom_views =
|
||||
(
|
||||
@ -2247,6 +2263,7 @@
|
||||
aft_eject_position = "0.0 7.5 -18.0";
|
||||
ai_type = "pirateAI.js";
|
||||
auto_ai = yes;
|
||||
auto_weapons = yes;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
energy_recharge_rate = 2;
|
||||
exhaust = ("0.0 0.0 -17.0 8.0 6.0 1.0");
|
||||
|
@ -1159,6 +1159,7 @@ this._addFreighter = function(pos)
|
||||
t[0].destinationSystem = system.ID;
|
||||
t[0].setCargoType("SCARCE_GOODS");
|
||||
}
|
||||
this._setEscortWeapons(t[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1184,6 +1185,7 @@ this._addCourier = function(pos)
|
||||
gs[i].bounty = 0;
|
||||
}
|
||||
}
|
||||
this._setEscortWeapons(t[0]);
|
||||
return t;
|
||||
}
|
||||
|
||||
@ -1260,6 +1262,8 @@ this._addSmuggler = function(pos)
|
||||
}
|
||||
t[0].setCargoType("ILLEGAL_GOODS");
|
||||
t[0].awardEquipment("EQ_FUEL_INJECTION"); // smugglers always have injectors
|
||||
this._setWeapons(t[0],1.2); // rarely good weapons
|
||||
this._setEscortWeapons(t[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1272,6 +1276,7 @@ this._addLightHunter = function(pos)
|
||||
h.ships[i].bounty = 0;
|
||||
h.ships[i].homeSystem = system.ID;
|
||||
h.ships[i].destinationSystem = system.ID;
|
||||
this._setWeapons(h.ships[i],1.5); // mixed weapons
|
||||
}
|
||||
}
|
||||
|
||||
@ -1340,6 +1345,17 @@ this._addHunterPack = function(pos,home,dest,role,returning)
|
||||
hs[i].fuel = 7;
|
||||
hs[i].homeSystem = t[0].homeSystem;
|
||||
hs[i].destinationSystem = t[0].destinationSystem;
|
||||
this._setWeapons(hs[i],1.5); // mixed weapons
|
||||
}
|
||||
if (role == "hunter-heavy")
|
||||
{
|
||||
// occasionally give heavy hunters aft lasers
|
||||
this._setWeapons(t[0],2.2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// usually ensure medium hunters have beam lasers
|
||||
this._setWeapons(t[0],1.9);
|
||||
}
|
||||
t[0].switchAI("bountyHunterLeaderAI.js");
|
||||
}
|
||||
@ -1360,6 +1376,7 @@ this._addIndependentPirate = function(pos)
|
||||
if (!pos.isStation && !pos.isPlanet)
|
||||
{
|
||||
pg.ships[i].setCargoType("PIRATE_GOODS");
|
||||
this._setWeapons(pg.ships[i],1.3); // rarely well-armed
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1383,6 +1400,7 @@ this._addPirateAssistant = function(role,lead,pos)
|
||||
asst[0].setBounty(50+system.government+Math.floor(Math.random()*36),"setup actions");
|
||||
// interceptors not actually part of group: they just get the
|
||||
// same destinations
|
||||
this._setWeapons(asst[0],2.3); // heavily armed
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1390,6 +1408,18 @@ this._addPirateAssistant = function(role,lead,pos)
|
||||
lead.group.addShip(asst[0]);
|
||||
asst[0].switchAI("pirateFighterAI.js");
|
||||
asst[0].setBounty(20+system.government+Math.floor(Math.random()*12),"setup actions");
|
||||
if (role == "pirate-light-fighter")
|
||||
{
|
||||
this._setWeapons(asst[0],1.2); // basic fighters
|
||||
}
|
||||
else if (role == "pirate-medium-fighter")
|
||||
{
|
||||
this._setWeapons(asst[0],1.8); // often beam weapons
|
||||
}
|
||||
else if (role == "pirate-heavy-fighter")
|
||||
{
|
||||
this._setWeapons(asst[0],2.05); // very rarely aft lasers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1429,14 +1459,7 @@ this._addPiratePack = function(pos,leader,lf,mf,hf,thug,home,destination,returni
|
||||
}
|
||||
lead[0].awardEquipment("EQ_SHIELD_BOOSTER");
|
||||
lead[0].awardEquipment("EQ_ECM");
|
||||
if (lead[0].aftWeapon != "EQ_WEAPON_MILITARY_LASER")
|
||||
{
|
||||
lead[0].aftWeapon = "EQ_WEAPON_BEAM_LASER";
|
||||
}
|
||||
if (lead[0].forwardWeapon != "EQ_WEAPON_MILITARY_LASER")
|
||||
{
|
||||
lead[0].forwardWeapon = "EQ_WEAPON_BEAM_LASER";
|
||||
}
|
||||
this._setWeapons(lead[0],2.8); // usually give aft laser
|
||||
// next line is temporary for debugging!
|
||||
lead[0].displayName = lead[0].name + " - FLAGSHIP";
|
||||
if (returning)
|
||||
@ -1463,6 +1486,7 @@ this._addPiratePack = function(pos,leader,lf,mf,hf,thug,home,destination,returni
|
||||
{
|
||||
lead[0].setCargoType("PIRATE_GOODS");
|
||||
}
|
||||
this._setEscortWeapons(lead[0]);
|
||||
lead[0].switchAI("pirateFreighterAI.js");
|
||||
return lead[0];
|
||||
}
|
||||
@ -1620,6 +1644,109 @@ this._roleExists = function(role)
|
||||
}
|
||||
|
||||
|
||||
/* Run _setWeapons on the escort group */
|
||||
this._setEscortWeapons = function(mothership)
|
||||
{
|
||||
if (!mothership.escortGroup)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var eg = mothership.escortGroup.ships;
|
||||
for (var i = eg.length-1 ; i >= 0 ; i--)
|
||||
{
|
||||
var ship = eg[i];
|
||||
if (ship == mothership)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!ship.autoWeapons)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var pr = ship.primaryRole;
|
||||
if (pr == "escort" || pr == "pirate-light-fighter")
|
||||
{
|
||||
this._setWeapons(ship,1.3); // usually lightly armed as escorts
|
||||
}
|
||||
else if (pr == "escort-medium" || pr == "pirate-medium-fighter")
|
||||
{
|
||||
this._setWeapons(ship,1.8); // usually heavily armed as escorts
|
||||
}
|
||||
else if (pr == "escort-heavy" || pr == "pirate-heavy-fighter")
|
||||
{
|
||||
this._setWeapons(ship,2.05); // rarely have an aft laser
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Levels:
|
||||
* <= 1: FP
|
||||
* 2: FB
|
||||
* 3: FB, AB (rare in core)
|
||||
* 4: FM, AB (not used in core)
|
||||
* >= 5: FM, AM (not used in core)
|
||||
* Fractional levels may be one or other (e.g. 2.2 = 80% 2, 20% 3)
|
||||
* Side weapons unchanged
|
||||
*/
|
||||
this._setWeapons = function(ship,level)
|
||||
{
|
||||
if (!ship.autoWeapons)
|
||||
{
|
||||
// default is not to change anything
|
||||
return false;
|
||||
}
|
||||
var fwent = ship;
|
||||
if (ship.forwardWeapon == null)
|
||||
{
|
||||
var se = ship.subEntities;
|
||||
for (var i=0;i<se.length;i++)
|
||||
{
|
||||
if (se[i].forwardWeapon != null)
|
||||
{
|
||||
if (fwent != ship)
|
||||
{
|
||||
return false; // auto_weapons doesn't work on ships with MFLs
|
||||
}
|
||||
fwent = se[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
var choice = Math.floor(level);
|
||||
if (level-Math.floor(level) > Math.random())
|
||||
{
|
||||
choice++;
|
||||
}
|
||||
if (choice <= 1)
|
||||
{
|
||||
fwent.forwardWeapon = "EQ_WEAPON_PULSE_LASER";
|
||||
ship.aftWeapon = null;
|
||||
}
|
||||
else if (choice == 2)
|
||||
{
|
||||
fwent.forwardWeapon = "EQ_WEAPON_BEAM_LASER";
|
||||
ship.aftWeapon = null;
|
||||
}
|
||||
else if (choice == 3)
|
||||
{
|
||||
fwent.forwardWeapon = "EQ_WEAPON_BEAM_LASER";
|
||||
ship.aftWeapon = "EQ_WEAPON_BEAM_LASER";
|
||||
}
|
||||
else if (choice == 4)
|
||||
{
|
||||
fwent.forwardWeapon = "EQ_WEAPON_MILITARY_LASER";
|
||||
ship.aftWeapon = "EQ_WEAPON_BEAM_LASER";
|
||||
}
|
||||
else if (choice >= 5)
|
||||
{
|
||||
fwent.forwardWeapon = "EQ_WEAPON_MILITARY_LASER";
|
||||
ship.aftWeapon = "EQ_WEAPON_MILITARY_LASER";
|
||||
}
|
||||
// log(this.name,"Set "+fwent.forwardWeapon+"/"+ship.aftWeapon+" for "+ship.name+" ("+ship.primaryRole+")");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
this._setFuel = function(ship)
|
||||
{
|
||||
if (ship.homeSystem != system.ID)
|
||||
|
@ -541,6 +541,7 @@ typedef enum
|
||||
- (Vector) forwardWeaponOffset;
|
||||
- (Vector) portWeaponOffset;
|
||||
- (Vector) starboardWeaponOffset;
|
||||
- (BOOL) hasAutoWeapons;
|
||||
|
||||
- (BOOL) isFrangible;
|
||||
- (BOOL) suppressFlightNotifications;
|
||||
|
@ -287,7 +287,7 @@ static ShipEntity *doOctreesCollide(ShipEntity *prime, ShipEntity *other);
|
||||
military_jammer_active = NO;
|
||||
cloakPassive = [shipDict oo_boolForKey:@"cloak_passive" defaultValue:YES]; // Nikos - switched passive cloak default to YES 20120523
|
||||
cloakAutomatic = [shipDict oo_boolForKey:@"cloak_automatic" defaultValue:YES];
|
||||
|
||||
|
||||
missiles = [shipDict oo_intForKey:@"missiles" defaultValue:0];
|
||||
max_missiles = [shipDict oo_intForKey:@"max_missiles" defaultValue:missiles];
|
||||
if (max_missiles > SHIPENTITY_MAX_MISSILES) max_missiles = SHIPENTITY_MAX_MISSILES;
|
||||
@ -7199,6 +7199,12 @@ NSComparisonResult ComparePlanetsBySurfaceDistance(id i1, id i2, void* context)
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) hasAutoWeapons
|
||||
{
|
||||
return [[self shipInfoDictionary] oo_fuzzyBooleanForKey:@"auto_weapons" defaultValue:NO];
|
||||
}
|
||||
|
||||
|
||||
- (void) setShipScript:(NSString *)script_name
|
||||
{
|
||||
NSMutableDictionary *properties = nil;
|
||||
|
@ -168,6 +168,7 @@ enum
|
||||
kShip_AIFoundTarget, // AI "found target", entity, read/write
|
||||
kShip_AIPrimaryAggressor, // AI "primary aggressor", entity, read/write
|
||||
kShip_autoAI, // bool, read-only, auto_ai from shipdata
|
||||
kShip_autoWeapons, // bool, read-only, auto_weapons from shipdata
|
||||
kShip_beaconCode, // beacon code, string, read/write
|
||||
kShip_boundingBox, // boundingBox, vector, read-only
|
||||
kShip_bounty, // bounty, unsigned int, read/write
|
||||
@ -299,6 +300,7 @@ static JSPropertySpec sShipProperties[] =
|
||||
{ "AIFoundTarget", kShip_AIFoundTarget, OOJS_PROP_READWRITE_CB },
|
||||
{ "AIPrimaryAggressor", kShip_AIPrimaryAggressor, OOJS_PROP_READWRITE_CB },
|
||||
{ "autoAI", kShip_autoAI, OOJS_PROP_READONLY_CB },
|
||||
{ "autoWeapons", kShip_autoWeapons, OOJS_PROP_READONLY_CB },
|
||||
{ "beaconCode", kShip_beaconCode, OOJS_PROP_READWRITE_CB },
|
||||
{ "boundingBox", kShip_boundingBox, OOJS_PROP_READONLY_CB },
|
||||
{ "bounty", kShip_bounty, OOJS_PROP_READWRITE_CB },
|
||||
@ -584,6 +586,10 @@ static JSBool ShipGetProperty(JSContext *context, JSObject *this, jsid propID, j
|
||||
case kShip_autoAI:
|
||||
*value = OOJSValueFromBOOL([entity hasAutoAI]);
|
||||
return YES;
|
||||
|
||||
case kShip_autoWeapons:
|
||||
*value = OOJSValueFromBOOL([entity hasAutoWeapons]);
|
||||
return YES;
|
||||
|
||||
case kShip_accuracy:
|
||||
return JS_NewNumberValue(context, [entity accuracy], value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user