Scripts/GalCop_military_missile_conditions.js |
this.name = "GalCop_military_missile_conditions";
this.author = "Montana05";
this.description = "conditions for the purchase of Military Missiles G2";
this.version = "0.51";
this.copyright = "2021 Montana05";
this.licence = "CC BY-NC-SA 4.0";
"use strict";
this.allowAwardEquipment = function(equipment, ship, context)
{
var diceRoll = worldScripts.GalCop_military_missile_dice;
var dice = diceRoll.$GalCop_military_missile_dice;
var shipRole = ship.primaryRole;
// remainder from oolite-conditions.js:
// OXP hook to allow stations to forbid specific equipment
if(context == "purchase" && player.ship.dockedStation && player.ship.dockedStation.scriptInfo["oolite-barred-equipment"])
{
if (player.ship.dockedStation.scriptInfo["oolite-barred-equipment"].indexOf(equipment) != -1)
{
return false;
};
};
// OXP hook to allow ships to forbid specific "available to all" equipment
if(ship.scriptInfo && ship.scriptInfo["oolite-barred-equipment"] && ship.scriptInfo["oolite-barred-equipment"].indexOf(equipment) != -1)
{
return false;
};
// awarded equipment to NPC's on setup or added by JS
if(context == "npc" || context == "scripted")
{
// exclusively for Navy and police
if(equipment === "EQ_GALCOP_MILITARY_MISSILE" && (ship.scanClass === "CLASS_MILITARY" || ship.scanClass === "CLASS_POLICE"))
{
return true;
};
// for some criminals only
// roleIsInCategory always return "false" so check every role
if(equipment === "EQ_GALCOP_MILITARY_MOD_MISSILE" &&
(shipRole == "pirate-heavy-fighter" ||
shipRole == "pirate-heavy-freighter" ||
shipRole == "pirate-interceptor" ||
shipRole == "pirate-aegis-raider" ||
shipRole == "assassin-medium" ||
shipRole == "assassin-heavy"))
{
return true;
};
};
if(system && !system.sun.hasGoneNova && !system.sun.isGoingNova)
{
// shipyards at stations
if((context == "newShip" || context == "purchase") && player.ship.dockedStation)
{
// the original missiles are only available at
// Galactic Navy Sector Commands (Galactic Navy OXP) and Sentinel Stations (Anarchies OXP)
if(equipment === "EQ_GALCOP_MILITARY_MISSILE" &&
(player.ship.dockedStation.primaryRole.indexOf("navystat") != -1) ||
player.ship.dockedStation.primaryRole == "anarchies_sentinel_station")
{
return true;
};
// modified missiles
if(equipment === "EQ_GALCOP_MILITARY_MOD_MISSILE")
{
// there is a chance in anarchies, feudals and multi-gov systems
if(system.info.government <= 2 && dice > 75)
{
return true;
};
// independent and sleazy locations offer them as well once in a while
if(system.info.government > 2 && player.ship.dockedStation.allegiance != "galcop" && dice > 65)
{
return true;
};
};
};
};
// otherwise prohibited
return false;
};
|
Scripts/GalCop_military_missile_supply.js |
this.name = "GalCop_military_missile_supply";
this.author = "Montana05";
this.description = "replaces on some ships the core missiles";
this.version = "0.51";
this.copyright = "2021 Montana05";
this.licence = "CC BY-NC-SA 4.0";
"use strict";
// replaces on some police, assassin and pirate ships "Missiles" and "ECM Hardened Missiles" with "Military Missiles G2"
this.shipSpawned = function(ship)
{
var dice = Math.round(Math.random() * 100);
var shipRole = ship.primaryRole;
var shipMissiles = ship.missiles;
// basic check, shouldn't be necessary but better safe than sorry
if(ship.isSubEntity == false &&
ship.isWeapon == false &&
ship.isCargo == false &&
ship.isRock == false &&
shipMissiles.length > 0 &&
shipRole != "wreckage" )
{
// police ships in advanced government systems with money
if(ship.isPolice == true &&
system.info.government > 4 &&
system.info.economy < 2)
{
for(var i = shipMissiles.length - 1 ; i >= 0 ; i-- )
{
if(shipMissiles[i].equipmentKey == "EQ_MISSILE")
{
ship.removeEquipment("EQ_MISSILE");
ship.awardEquipment("EQ_GALCOP_MILITARY_MISSILE");
};
if(shipMissiles[i].equipmentKey == "EQ_HARDENED_MISSILE")
{
ship.removeEquipment("EQ_HARDENED_MISSILE");
ship.awardEquipment("EQ_GALCOP_MILITARY_MISSILE");
};
};
};
// random heavily armed pirates and assassins
if((shipRole == "pirate-heavy-fighter" ||
shipRole == "pirate-heavy-freighter" ||
shipRole == "pirate-interceptor" ||
shipRole == "pirate-aegis-raider" ||
shipRole == "assassin-medium" ||
shipRole == "assassin-heavy") &&
dice < 20)
{
for(var i = shipMissiles.length - 1 ; i >= 0 ; i-- )
{
if(shipMissiles[i].equipmentKey == "EQ_MISSILE")
{
ship.removeEquipment("EQ_MISSILE");
ship.awardEquipment("EQ_GALCOP_MILITARY_MOD_MISSILE");
};
if(shipMissiles[i].equipmentKey == "EQ_HARDENED_MISSILE")
{
ship.removeEquipment("EQ_HARDENED_MISSILE");
ship.awardEquipment("EQ_GALCOP_MILITARY_MOD_MISSILE");
};
};
};
};
}; |