| Path | 
                
                    | Scripts/astromine_market.js | "use strict";
this.name = "czgf_market";
this.author = "spara";
this.copyright = "2014 spara";
this.license     = "CC BY-NC-SA 4.0";
this.$originalDefs = {
      "food" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "textiles" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "radioactives" : [0, 0, 40, 2, 3, 8, 1, 3, 0],
      "slaves" : [0, 0, 24, 2, 4, 7, 1, 4, 0],
      "liquor_wines" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "luxuries" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "narcotics" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "computers" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "machinery" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "alloys" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "firearms" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "furs" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "minerals" : [0, 0, 17, 2, 2, 24, 1, 3, 0],
      "gold" : [0, 0, 90, 2, 4, 15, 1, 4, 1],
      "platinum" : [0, 0, 180, 2, 4, 10, 1, 3, 1],
      "gem_stones" : [0, 0, 40, 2, 4, 8, 1, 5, 2],
      "alien_items" : [0, 0, 0, 0, 0, 0, 0, 0, 0]
};
this.updateLocalCommodityDefinition = function(goodDefinition) {
	var commodity = goodDefinition.key;
	var oldDefs = this.$originalDefs[commodity];
	//old style definition found for the good. calculate it the old way
	if (oldDefs) {
		var market_base_price = oldDefs[2];
		var market_eco_adjust_price = oldDefs[3];
		var market_eco_adjust_quantity = oldDefs[4];
		var market_base_quantity = oldDefs[5];
		var market_mask_price = oldDefs[6];
		var market_mask_quantity = oldDefs[7];
		var market_rnd = Math.floor(Math.random() * 256);
		var economy = system.economy;
		var price = (market_base_price + (market_rnd & market_mask_price) + (economy * market_eco_adjust_price)) & 255;
		price *= 0.4;
		var quantity = (market_base_quantity + (market_rnd & market_mask_quantity) - (economy * market_eco_adjust_quantity)) & 255;
		if (quantity > 127) quantity = 0;
		quantity &= 63;
		goodDefinition.price = price * 10;
		goodDefinition.quantity = quantity;
	}
	//no definition found. nullify the goods.
	else {
		goodDefinition.price = 0;
		goodDefinition.quantity = 0;
	}
	return goodDefinition;
};
 | 
                
                    | Scripts/comlimesc.js | "use strict";
this.name      = "comlimesc"; 
this.author    = "eric walch"; 
this.copyright = "� 2008 eric walch."; 
this.description = "Code for a comlim escape pod"; 
this.version   = "1.00";
/* The original legacy code couldn't check who killed the pod but always blamed the player for its death */
this.shipDied = function (who)
{
    if (who && who.isPlayer)
    {
        this.ship.commsMessage(expandDescription("[commissarharakiri]"));
        player.bounty |= 200;
    }
}; | 
                
                    | Scripts/commies.js | "use strict";
this.name      = "communist_population"; 
this.author    = "eric walch"; 
this.copyright = "� 2009 Dr Nil."; 
this.description = "Code for a communist_population"; 
this._shipSpawnOverride = false;
this._sourceGov = -1;
this._destGov = -1;
this._debug = false;
this.startUpComplete = function() {
    // remove the original interstellar space populator from commies (which doesn't work anyway)
    delete worldScripts.communist_population.shipWillExitWitchspace;
}
this.shipWillEnterWitchspace = function (cause) {
    this._sourceGov = system.info.government;
    this._destGov = System.infoForSystem(galaxyNumber, player.ship.nextSystem).government;
}
this.interstellarSpaceWillPopulate = function() {
    if (this._sourceGov === 4 || this._destGov === 4) {
        if (Math.random() > 0.80) {
			system.setPopulator("commies_comgrc_1", {
				location: "WITCHPOINT",
				callback: function(pos) {
                    system.addShips("comgrc", 1, pos);
                }}
			);
            //system.legacy_addShips("comgrc", 1);
            //system.addShips("comgrc-defender", 2);
            //system.legacy_addShips("comgrc-defender", 2);
        }
        if (Math.random() > 0.90) {
			system.setPopulator("commies_comgrc_2", {
				location: "WITCHPOINT",
				callback: function(pos) {
                    system.addShips("comgrc", 1, pos);
                }}
			);
            //system.legacy_addShips("comgrc", 1);
            //system.addShips("comgrc-defender", 3);
            //system.legacy_addShips("comgrc-defender", 3);
        }
    }
}
/*this.shipWillExitWitchspace = function () {
    if (system.info.government === 4) {
        if (system.isInterstellarSpace) this.witchspacePopulator()
    }
}*/
this.systemWillPopulate = function () {
    if (system.info.government !== 4) return;
	// get the witchpoint position for later calculations that replace the deprecated function "legacy_addSystemShips"
	// which works on the WP - Main Station lane. However, that lane isn't directly accessible via the "fromCoordinateSystem" functions
	// so we have to create our own lane
	var wpPos = null;
	var wp = system.shipsWithPrimaryRole("buoy-witchpoint")[0];
	if (!wp || wp.length === 0) {
		wpPos = new Vector3D(0, 0, 0);
	} else {
		wpPos = wp.position;
	}
	
    for (var i = 0; i < 4; i++) {
		if (Math.random() > 0.50) {
			var posCom = Vector3D.interpolate(wpPos, system.mainStation.position, 0.55 + i * 0.12);
			system.setPopulator("commies_workcom_" + i, {
				location: "COORDINATES",
				coordinates: posCom,
				callback: function(pos) {
					var wc = system.addShips("workcom", 1, pos, 0);
					if ((!wc || wc.length === 0) && worldScripts.communist_population._debug === true) log("commies.populator", "OOPS! No worker's commuters spawned (1)");
				}}
			);
			//system.legacy_addSystemShips("workcom", 1, 0.55+i*0.12)
		}
	};
    if (system.techLevel > 6 && Math.random() > 0.75) {
		var pos1 = Vector3D(0, 0.45, 2.6).fromCoordinateSystem("sps");
		system.setPopulator("commies_workcom_a", {
			location: "COORDINATES",
			coordinates: pos1,
			callback: function(pos) {
				var wc = system.addShips("workcom", 1, pos, 0);
				if ((!wc || wc.length === 0) && worldScripts.communist_population._debug === true) log("commies.populator", "OOPS! No worker's commuters spawned (a)");
			}}
		);
		//system.legacy_addShipsAt("workcom", 1, "sps", [0, 0.45, 2.6]);
	}
    for (var i = 0; i < 2; i++) {
		if (Math.random() > 0.75) {
			var posLiner = Vector3D.interpolate(wpPos, system.mainStation.position, 0.3 + i * 0.05);
			system.setPopulator("commies_comliner_" + i, {
				location: "COORDINATES",
				coordinates: posLiner,
				callback: function(pos) {
					var lin = system.addShips("comlim", 1, pos, 0);
					if (!lin || lin.length === 0) log("commies.populator", "OOPS! No com liners spawned (1)");
				}}
			);
			//system.legacy_addSystemShips("comlim", 1, 0.3+i*0.05)
		}
	};
    if (system.techLevel > 6 && Math.random() > 0.90) {
		var pos2 = Vector3D(0, 0.6, 2.8).fromCoordinateSystem("sps");
		system.setPopulator("commies_comlin_a", {
			location: "COORDINATES",
			coordinates: pos2,
			callback: function(pos) {
				var lin = system.addShips("comlim", 1, pos, 0);
				if ((!lin || lin.length === 0) && worldScripts.communist_population._debug === true) log("commies.populator", "OOPS! No com liners spawned (a)");
			}}
		);
		//system.legacy_addShipsAt("comlim", 1, "sps", [0, 0.6, 2.8]);
	}
    if (Math.random() > 0.75) {
		var posViper = Vector3D.interpolate(wpPos, system.mainStation.position, 0.47);
		system.setPopulator("commies_comviper", {
			location: "COORDINATES",
			coordinates: posViper,
			callback: function(pos) {
				var vp = system.addShips("comviper", 5, pos, 0);
				if ((!vp || vp.length === 0) && worldScripts.communist_population._debug === true) log("commies.populator", "OOPS! No com vipers spawned");
			}}
		);
		//system.legacy_addSystemShips("comviper", 5, 0.47);
	}
    if (Math.random() > 0.10) {
		var posPol = Vector3D.interpolate(wpPos, system.mainStation.position, 0.48);
		system.setPopulator("commies_politicop", {
			location: "COORDINATES",
			coordinates: posPol,
			callback: function(pos) {
				var pc = system.addShips("politicop", 1, pos, 0);
				if ((!pc || pc.length === 0) && worldScripts.communist_population._debug === true) log("commies.populator", "OOPS! No politicops spawned (1)");
			}}
		);
		//system.legacy_addSystemShips("politicop", 1, 0.48);
	}
    if (system.techLevel > 6 && Math.random() > 0.95) {
		var posPol2 = Vector3D(0, 0.45, 2.7).fromCoordinateSystem("sps");
		system.setPopulator("commies_politicop_a", {
			location: "COORDINATES",
			coordinates: posPol2,
			callback: function(pos) {
				var pc = system.addShips("politicop", 1, pos, 0)[0];
				if ((!pc || pc.length === 0) && worldScripts.communist_population._debug === true) log("commies.populator", "OOPS! No politicops spawned");
			}}
		);
		//system.legacy_addShipsAt("politicop", 1, "sps", [0, 0.45, 2.7]);
	}
    if (system.techLevel > 6 && system.techLevel < 10) {
		if (!worldScripts.station_validator || worldScripts.station_validator.$deaths("comczgf").length === 0) {
			var posFct = Vector3D(0, 0.40, 2.6).fromCoordinateSystem("sps");
			system.setPopulator("commies_comczgf", {
				location: "COORDINATES",
				coordinates: posFct,
				deterministic: true,
				callback: function(pos) {
					var fct = system.addShips("comczgf", 1, pos, 0)[0];
					if ((!fct || fct.length === 0) && worldScripts.communist_population._debug === true) log("commies.populator", "OOPS! No factories spawned");
				}}
			);
		}
		//system.legacy_addShipsAt("comczgf", 1, "sps", [0, 0.40, 2.6]);
	}
    if (system.techLevel > 9) {
		if (!worldScripts.station_validator || worldScripts.station_validator.$deaths("comslapu").length === 0) {
			var posSlapu = Vector3D(0, 0.40, 2.6).fromCoordinateSystem("sps");
			system.setPopulator("commies_slapu", {
				location: "COORDINATES",
				coordinates: posSlapu,
				deterministic: true,
				callback: function(pos) {
					var sla = system.addShips("comslapu", 1, pos, 0)[0];
					if ((!sla || sla.length === 0) && worldScripts.communist_population._debug === true) log("commies.populator", "OOPS! No slapu's spawned");
				}}
			);
		}
		//system.legacy_addShipsAt("comslapu", 1, "sps", [0, 0.40, 2.6]);
	}
	// note: astromines are not spawned directly, but are set up to be the Rock Hermits in the system.
}
/*this.witchspacePopulator = function() {
    if (Math.random() > 0.80)  {
		system.addShips("comgrc", 1);
        //system.legacy_addShips("comgrc", 1);
		system.addShips("comgrc-defender", 2);
        //system.legacy_addShips("comgrc-defender", 2);
    }
    if (Math.random() > 0.90) {
		system.addShips("comgrc", 1);
        //system.legacy_addShips("comgrc", 1);
		system.addShips("comgrc-defender", 3);
        //system.legacy_addShips("comgrc-defender", 3);
    }
}*/
 | 
                
                    | Scripts/commies_conditions.js | "use strict";
this.name        = "Commies_Conditions";
this.author      = "phkb";
this.copyright   = "2016 phkb";
this.description = "Condition script for ships and equipment.";
this.licence     = "CC BY-NC-SA 3.0";
this.allowSpawnShip = function(shipKey) {
	if (system.info.government === 4 || worldScripts.communist_population._shipSpawnOverride === true) return true;
	return false;
} | 
                
                    | Scripts/czgf_market.js | "use strict";
this.name = "czgf_market";
this.author = "spara";
this.copyright = "2014 spara";
this.license     = "CC BY-NC-SA 4.0";
this.$originalDefs = {
      "food" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "textiles" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "radioactives" : [0, 0, 62, 2, 2, 6, 1, 2, 0],
      "slaves" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "liquor_wines" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "luxuries" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "narcotics" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "computers" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "machinery" : [0, 0, 81, 2, 2, 15, 1, 3, 0],
      "alloys" : [0, 0, 60, 2, 2, 20, 1, 2, 0],
      "firearms" : [0, 0, 75, 2, 3, 14, 1, 4, 0],
      "furs" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "minerals" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "gold" : [0, 0, 0, 0, 0, 0, 0, 0, 1],
      "platinum" : [0, 0, 0, 0, 0, 0, 0, 0, 1],
      "gem_stones" : [0, 0, 34, 2, 2, 0, 1, 0, 2],
      "alien_items" : [0, 0, 0, 0, 0, 0, 0, 0, 0]
};
this.updateLocalCommodityDefinition = function(goodDefinition) {
	var commodity = goodDefinition.key;
	var oldDefs = this.$originalDefs[commodity];
	//old style definition found for the good. calculate it the old way
	if (oldDefs) {
		var market_base_price = oldDefs[2];
		var market_eco_adjust_price = oldDefs[3];
		var market_eco_adjust_quantity = oldDefs[4];
		var market_base_quantity = oldDefs[5];
		var market_mask_price = oldDefs[6];
		var market_mask_quantity = oldDefs[7];
		var market_rnd = Math.floor(Math.random() * 256);
		var economy = system.economy;
		var price = (market_base_price + (market_rnd & market_mask_price) + (economy * market_eco_adjust_price)) & 255;
		price *= 0.4;
		var quantity = (market_base_quantity + (market_rnd & market_mask_quantity) - (economy * market_eco_adjust_quantity)) & 255;
		if (quantity > 127) quantity = 0;
		quantity &= 63;
		goodDefinition.price = price * 10;
		goodDefinition.quantity = quantity;
	}
	//no definition found. nullify the goods.
	else {
		goodDefinition.price = 0;
		goodDefinition.quantity = 0;
	}
	return goodDefinition;
};
 | 
                
                    | Scripts/slapu_market.js | "use strict";
this.name = "slapu_market";
this.author = "spara";
this.copyright = "2014 spara";
this.license     = "CC BY-NC-SA 4.0";
this.$originalDefs = {
      "food" : [0, 0, 10, 2, 2, 12, 1, 2, 0],
      "textiles" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "radioactives" : [0, 0, 60, 2, 2, 6, 1, 2, 0],
      "slaves" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "liquor_wines" : [0, 0, 70, 2, 2, 4, 1, 2, 0],
      "luxuries" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "narcotics" : [0, 0, 80, 2, 2, 8, 1, 2, 0],
      "computers" : [0, 0, 125, 2, 2, 10, 1, 2, 0],
      "machinery" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "alloys" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "firearms" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "furs" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "minerals" : [0, 0, 0, 0, 0, 0, 0, 0, 0],
      "gold" : [0, 0, 0, 0, 0, 0, 0, 0, 1],
      "platinum" : [0, 0, 0, 0, 0, 0, 0, 0, 1],
      "gem_stones" : [0, 0, 34, 2, 2, 0, 1, 0, 2],
      "alien_items" : [0, 0, 80, -4, -4, 0, 1, 0, 0]
};
this.updateLocalCommodityDefinition = function(goodDefinition) {
	var commodity = goodDefinition.key;
	var oldDefs = this.$originalDefs[commodity];
	//old style definition found for the good. calculate it the old way
	if (oldDefs) {
		var market_base_price = oldDefs[2];
		var market_eco_adjust_price = oldDefs[3];
		var market_eco_adjust_quantity = oldDefs[4];
		var market_base_quantity = oldDefs[5];
		var market_mask_price = oldDefs[6];
		var market_mask_quantity = oldDefs[7];
		var market_rnd = Math.floor(Math.random() * 256);
		var economy = system.economy;
		var price = (market_base_price + (market_rnd & market_mask_price) + (economy * market_eco_adjust_price)) & 255;
		price *= 0.4;
		var quantity = (market_base_quantity + (market_rnd & market_mask_quantity) - (economy * market_eco_adjust_quantity)) & 255;
		if (quantity > 127) quantity = 0;
		quantity &= 63;
		goodDefinition.price = price * 10;
		goodDefinition.quantity = quantity;
	}
	//no definition found. nullify the goods.
	else {
		goodDefinition.price = 0;
		goodDefinition.quantity = 0;
	}
	return goodDefinition;
};
 | 
                
                    | Scripts/workcom.js | "use strict";
this.name      = "workcom"; 
this.author    = "eric walch"; 
this.copyright = "� 2008 eric walch."; 
this.description = "Code for a workcom"; 
this.version   = "1.00";
this.shipLaunchedFromStation = function ()
{
    // keep ship in system
	if (this.ship.primaryRole === "trader") 
    {
        this.comfactory = system.shipsWithPrimaryRole("comczgf")[0];
        if (!this.comfactory) this.comfactory = system.shipsWithPrimaryRole("comslapu")[0];
        if (!this.comfactory) this.comfactory = system.shipsWithRole("astromine")[0];
        if (!this.comfactory) this.ship.switchAI("route2sunskimAI.plist")
        else this.ship.switchAI("workcomAI.plist")
    }
}
this.findComfactory = function ()
{
    if (this.comfactory && this.comfactory.isValid) this.ship.target = this.comfactory
    else this.ship.target = system.mainStation
}
 |