Back to Index Page generated: May 8, 2024, 6:16:03 AM

Expansion Commies

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Adds Astro Mines, Factories, Production Units, Commuters & special police ships to Communist systems. Adds Astro Mines, Factories, Production Units, Commuters & special police ships to Communist systems.
Identifier oolite.oxp.DrNil.Commies oolite.oxp.DrNil.Commies
Title Commies Commies
Category Systems Systems
Author Amaranth, Dr. Nil, Eric Walch, Norby, phkb, GearsNSuch Amaranth, Dr. Nil, Eric Walch, Norby, phkb, GearsNSuch
Version 2.19 2.19
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Commies n/a
Download URL https://wiki.alioth.net/img_auth.php/d/dd/Commies_2.19.oxz n/a
License CC BY-NC-SA 3.0 CC BY-NC-SA 3.0
File Size n/a
Upload date 1693710644

Documentation

Also read http://wiki.alioth.net/index.php/Commies

README.txt

Commies for Giles William's Oolite

by Dr. Nil
2.19 August 2023
Cleaned up shipdata.plist. Added a new texture + normal map for the Astromine Penal Colony while we await GearsNSuch's updated model and textures. Added normal map to the Manta Ray carrier. Added extra shipyard.plist entry for player version of the Military Stingray. 

2.18 August 2019
Added improved graphics and updated shipdata.plist and shiplibrary.plist. Also removed some deprecated files from the Config folder. The models and textures for the Astromine Convict Pod, the Workers' Commuter, The Commissar Limousine, and the Ray (and derivatives) have been replaced with new, from-scratch graphics created by GearsNSuch with Blender (blender.org) and GIMP (gimp.org). Shipdata.plist has been updated and cleaned up to incorporate these graphical changes and add names to the different models of spacecraft. A shiplibrary.plist file has been added as well, with descriptions drawn from original material and the Oolite Wiki (wiki.alioth.net). All models and textures are licensed under the CC BY-NC-SA 3 license.

2.17
Fixed populator issues that were (a) preventing Commissar Limousines from being spawned, and (b) preventing Giant Ray's from being spawned in Intergalactic space. Also made it possible to save the game at Astro Factories and Collective SLAPU stations.

2.16 March 2017
Fixed semicolon problems in Mac, thanks to hoqllnq.

2.15 January 2017
Added code to utilize Station Validator, if installed.
Added improved texture files, courtesy of Keeper.

2.14 November 2016
Updated scripts and config for current version of Oolite (1.82 and onwards)

2.13 April 2016
Edited the quotes out of the name of Sun Ray to avoid the computer pronouncing them audibly when it's passing on the radio chatter.

2.12 April 2012
This amended readme refers to Amaranth's additional textures for Commies OXP. I have not modified the models and scripting in any way and this remains the work of Dr Nil.

I have created the textures from a number of sources

Initial texture design and ideas are based on Dr Nil's original, combined with textures found via a google image search.

The exceptions to this are the escape pod (incorporating photos I took of the Soyuz capsule in the Polish Military Museum, Warsaw) and parts of the docking bay, based on photos of mine of derelict buildings.
_____

This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
_____

Read Captain Hesperus' descriptions of commie systems and ships here: http://wiki.alioth.net/index.php/Powers_and_Organisations#Communist_States


* * * * *

2.11 mei 2010

Added reflection and illumination maps for some of the stations.

2.10 April 2010

Corrected the role for the ecm-proof-missiles. Has always been wrong resulting in launching plain missiles for some of the ships.

2.09 October 2009

Centered the stations so the are now centered in the players target-reticule.
Changed the addition distance for solar stations from a general distance into a value relative to the sun radius. Stations no longer explode because of being added to close near big suns. With smaller suns the distance is even closer to the sun now.

2.08 September 2009

Translated the main script into Java Script. (When used with Oolite 1.65 it will fall back on the old script)
Corrected an very old type flasher definition. (Still worked before but would be skipped with Oolite 1.73)
Launching workcoms now head for a commies station instead of docking at the same station (Oolite 1.72-) or "wormholing" away (Oolite 1.73+)
Removed comguardAI: Was wrong and unused.
Updated some AI based on Oolite 1.55 trader AI to that of 1.65 trader AI (Better avoidance of obstacles)
Removed a bug were ships without fuel-scoop scanned for debris. Although the AI never intended to scoop them, scanForRandomLoot never finds anything when there are no scoops.
Fixed bug with fuel_injection of comlim (typo)

2.07 March 2008

Corrected a typo in an AI spotted by Ahruman


2.06 Jan 2008

A bug in the shipdata squashed by honorary commissar Kaks


2.05 November 2007

Some more propaganda posters.


2.04 April 2007

4 new propaganda posters.

2.03 April 2007

Fixed an issue with the units for Gold, Platinum and Gems at some of the stations.

2.0 February 2007

New model for the Astromines.
Fixed commodities for SLAP-Us, CZGFs and Astromines.
4 new propaganda posters.


1.85 Jan 2007

A new ship for the Commissar Limousine (Party Liner): The Sturgeon. The Comissar Limousines now use Military Rays for escorts.


1.8 Dec 2006

Added Neuropol Info Service (AD-X screens from YOUR_AD_HERE.oxp fitted with communist messages) as Navigational Buoy in Rich Industrial commie systems.

Credits:
Propaganda Poster 1: johnsmith
Propaganda Poster 2: HueijRevisited


1.7 Dec 2006

Made the script a lot more compact and did a minor change in shipdata.plist


1.6 Nov 2006

Updated model for the CZGF + a  little detail work on some other models and textures.


1.5 Nov 2006

Giant Ray gunships for communist military added. (Used ballturrets and some AI from Behemoth.oxp).
Stopped Factories from appearing in interplanetary space.


1.4 Nov 2006

Added Astromine Penal Colonies.


1.31 Nov 2006

Increased Energy Recharge Rate of factories by 50% and gave them shieldEnhancement to stop them from exploding too often in systems with large suns. Also the script now decides the appearance of Commissar Limousines and Worker's Commuters one by one instead of in pairs.


1.3 Nov 2006

An additional factory model: Solar Laboratory and Production Unit (SLAP-U) and textures for the Worker's Commuter in less worn states.


1.2 Nov 2006

Added the new Collective Zero G Factory which appears in communist systems with tech level 7 or above and sell tech 10 equipment at affordable prices - look for F on your advanced space compass to find it.

Updated the script and AI for the political police.


1.1 Nov 2006

If you already installed 1.0 delete the following folders before installing:
Commie_vipers.oxp
Political Police.oxp
Worker's Commuter.oxp
Commissar Limousine.oxp

The Commies now come in a single folder: Commies.oxp

This version gives local communist police the new tough Ray MK-I crafts with built in scoops and there's a new model for the Worker's Commuter.


1.0 Oct 2006

Some ships scripted to appear in communist systems:

People's Vipers - Communist system now require Gal-Cop to have a certain percentage of local police in their ranks, to limit outside interference.

Political Police - Don't know what to think? Well you better not. These guys will tell you what to think. Criminals whose escape pods get scooped by these guys can look forward to decades in the Astromines.

Commissar Limousine and escorts - The hard working nomenclature likes to travel in style with lots of comfort and protection.

Workers' Commuter - These systems are the working critter's paradises and the governments provide the worker's with public transportation (only slightly used).

Stuff used for these cut and paste plus a little scripting OXPs:

Oolite by Giles Willams - Vipers and Political Police
Executive Spaceways OXP by Ramirez - Commissar Limousine and escorts
mPak OXP by Murgh - Workers' Commuter


***** Known crashing problems ******

Some combination of graphics card drivers and ships are crashing Oolite in shader mode, even when no shaders are used at all. When having crashes in shader mode but no crashes when turned off, it is a good sign you should update your drivers. In commies it is the "Collective ZGF" station that can crash some systems. When in doubt if it might affect your computer you should launch Oolite, press "N" and wait for the Collective ZGF station appearing. When it shows up without crashing your system is okay.

A nVidia GeForce 7950GT 512Mb PCI-E graphics card, with the 64-bit drivers version 178.13 is known to crash with commies and other oxps while driver version 191.07 works okay. It seems that turning "Threading Optimisation" off will also help for computers with these cards.

Solution would be to remove this oxp but than you might get other oxp's containing problem objects. So better update your drivers or leave "Threading Optimisation" off for Oolite in combination with this old GPU.

Equipment

This expansion declares no equipment.

Ships

Name
Astromine Penal Colony
Astromine Defender Ray
Collective Zero-G Factory
Manta Ray Carrier
GRC Dock
Sturgeon Commissar Limousine
Commissar Escape Capsule
Military Stingray
commilray-player
Convict Miner Minnow
Convict Miner Minnow (Escaping)
Convict Miner Ray
Turret
People's Police Ray
Navigation Buoy
comyah01
comyah02
comyah03
comyah04
comyah05
comyah06
comyah07
comyah08
comyah09
comyah10
comyah11
comyah12
Thought Police Ray
Collective SLAPU
Military Stingray
slapu-dock
Sunray
sunray-player
Orca Worker's Commuter
workcom_0
workcom_1

Models

This expansion declares no models.

Scripts

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
}