Thanks, I got it already: There's your six java scripts and two of my own java scripts. The planetinfo.plist can be shortened, as it is no longer needed for the player stations. The worldscripts.plist doesn't change at all.
OK, then I will provide the playerStations.js and the OSE-populator.js currently residing on my harddrive:
Code: Select all
this.name = "Player Stations";
this.author = "Paul Wilkins";
this.copyright = "(C) 2009 Paul Wilkins";
this.description = "Converted from the 0.69 version of OSE-XML.plist";
this.version = "0.70";
this.startUp = function () {
if (oolite.compareVersion("1.73.4") > 0)
{
// Oolite version is older than 1.74.
log("script." + this.name, "This Player Stations script does not run under Oolite version " + oolite.versionString + ". Player Stations is disabled.");
delete this.shipExitedWitchspace;
} else {
this.reset();
}
};
this.reset = function () {
this.populate = true;
};
this.shipWillLaunchFromStation = function () {
if (this.populate === true) {
this.populate = false;
this.playerStations();
}
};
this.shipExitedWitchspace = function () {
this.playerStations();
};
this.guiScreenChanged = function (to, from) {
if (to === 'GUI_SCREEN_STATUS' || to === 'GUI_SCREEN_MANIFEST') {
this.setMissionInstructions();
}
};
this.playerStations = function () {
this.addPlayerStation();
this.processPlayerStations();
};
/**
* Add a player station to a system
*/
this.addPlayerStation = function () {
var ships = [
'playerrockhermit', 'playerfuelstation', 'playerhoopycasino', 'playerFTZ',
'playertradeoutpost', 'playerpiratecove', 'playercorporation', 'playeryakuza',
'playerSIRFYard', 'playerblackmonk', 'playeroobay', 'playersuperhub'
],
stationName = ships[Math.floor((system.ID - 10) / 20)],
playerStation = this.playerStationCode(galaxyNumber, system.ID);
if (!playerStation) {
return;
}
if (missionVariables['playerstation_' + playerStation] === 1 && system.countShipsWithRole(stationName) < 1) {
if (stationName === 'playerroobay') {
this.addRooBay();
} else {
system.legacy_addShips(stationName, 1, 0.8);
}
}
};
/**
* Create the player station code based on the galaxy number and the system id
*
* The first char is the station type A...L
* The second char is the station number A...B
* The third char is the galaxy number A...H
*/
this.playerStationCode = function (galaxy, system) {
if (system !== Math.floor(system / 10) * 10) {
return null;
}
// system.ID is now a multiple of 10
var stationChars = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L'],
galaxyChars = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'],
firstChar = stationChars[Math.floor((system - 10) / 20)], // 10 & 20 are 0, 30 & 40 are 1, 50 & 60 are 2, ...
secondChar = (system / 10) % 2 ? 'A' : 'B', // 10 is A, 20 is B, 30 is A, 40 is B, ...
thirdChar = galaxyChars[galaxy];
return firstChar + secondChar + thirdChar;
};
/**
* Add the Roo Bay and its many surrounding nodes
*/
this.addRooBay = function () {
var x, y, z, node;
for (x = -0.2; x <= 0.2; x += 0.2) {
for (y = -0.2; y <= 0.2; y += 0.2) {
for (z = -0.2; z <= 0.2; z += 0.2) {
node = 'node';
if (!x && !y && !z) {
node = '';
}
system.legacy_addShipsAtPrecisely('playeroobay' + node, 1, 'pwp', [1.8 + x, 2.2 + y, 3.6 + z]);
}
}
}
};
/**
* Regenerate the station mission descriptions
*/
this.setMissionInstructions = function () {
var i;
for (i = 1; i <= 5; i += 1) {
missionVariables['playerStationMission' + i] = null;
}
this.count = 0;
this.forEachPlayerStation(this.setMissionInstruction);
};
/**
* Process the weekly payments from stations on a per-day basis since the last payment
*/
this.processPlayerStations = function () {
var totalDays = Math.floor(clock.days),
dayPaid = missionVariables.playerStationDayPaid || 0,
daysToPay = totalDays - dayPaid;
if (dayPaid === 0) { // if payment has not ever been processed
daysToPay = 1;
}
while (daysToPay > 0) {
missionVariables.playerStationDayPaid = clock.days;
this.playerStationIncomeAndBounty();
daysToPay -= 1;
}
};
/**
* Start the income and bounty processing for each station
*/
this.playerStationIncomeAndBounty = function () {
this.totalBounty = 0;
this.forEachPlayerStation(this.checkPlayerStationIncomeAndBounty);
if (this.totalBounty < -player.bounty) {
this.totalBounty = -player.bounty;
}
player.bounty += this.totalBounty;
};
/**
* Generic loop that runs a function for each owned player station
* @param {Function} func The function to run for each station
*/
this.forEachPlayerStation = function (func) {
var types = 'ABCDEFGHIJKL',
stations = 'AB',
galaxies = 'ABCDEFGH',
i, j, k,
playerStation;
for (i = 0; i < types.length; i += 1) {
for (j = 0; j < stations.length; j += 1) {
for (k = 0; k < galaxies.length; k += 1) {
playerStation = types.charAt(i) + stations.charAt(j) + galaxies.charAt(k);
if (missionVariables['playerstation_' + playerStation] === 1) {
func.call(this, playerStation, i, j, k);
}
}
}
}
};
/**
* Set a playerStationMission+n variable with the station's description reference
* @param {String} playerStation The name of the station (eg. AAA)
* @param {Int} type 0...11 maps to A...L
* @param {Int} system 0...1 maps to A...B
* @param {Int} galaxy 0...7 maps to A...H
*/
this.setMissionInstruction = function (playerStation, type, system, galaxy) {
this.count += 1;
missionVariables['playerStationMission' + this.count] = 'Station_' + playerStation + '_owned';
};
/**
* Add credits for the station, and update the amount of bounty to be added
* @param {String} playerStation The name of the station (eg. AAA)
* @param {Int} type 0...11 maps to A...L
* @param {Int} system 0...1 maps to A...B
* @param {Int} galaxy 0...7 maps to A...H
*/
this.checkPlayerStationIncomeAndBounty = function (playerStation, type, system, galaxy) {
var stationBounty = [0, 0, 5, 20, -3, 40, -6, 70, 0, -12, -6, -6],
stationIncome;
stationIncome = this.playerStationIncome(type, galaxy);
player.credits += stationIncome;
this.totalBounty += stationBounty[type];
};
/**
* Calculate the amount of income for the station
*
* When the station is an a different galaxy, apply a 5% tax, and a further 3% per galaxy
* @param {Int} type 0...11 maps to A...L
* @param {Int} galaxy 0...7 maps to A...H
*/
this.playerStationIncome = function (type, galaxy) {
var stationIncomes = [4000, 8000, 12000, 21000, 20000, 36000, 40000, 75000, 100000, 130000, 250000, 500000],
projectedIncome = stationIncomes[type],
baseIncome = projectedIncome * 0.80,
variableIncome = projectedIncome * 0.40 * Math.random(),
stationIncome = baseIncome + variableIncome;
// adjust for courier travel from station galaxy to your galaxy
if (galaxyNumber !== galaxy) {
stationIncome -= stationIncome * 0.05;
}
while (galaxyNumber !== galaxy) {
stationIncome -= stationIncome * 0.03;
galaxy = (galaxy + 1) % 8;
}
return stationIncome;
};
Code: Select all
this.name = "Oolite Extended Populator";
this.author = "Paul Wilkins";
this.copyright = "(C) 2009 Paul Wilkins";
this.description = "Converted from the 0.70 version of ose.js to use proper ship loading techniques";
this.version = "0.71";
var ANARCHY = 0,
FEUDAL = 1,
MULTIGOVERNMENT = 2,
DICTATORSHIP = 3,
COMMUNIST = 4,
CONFEDERACY = 5,
DEMOCRACY = 6,
CORPORATESTATE = 7;
var RICHINDUSTIAL = 0,
AVERAGEINDUSTRIAL = 1,
POORINDUSTRIAL = 2,
MAINLYINDUSTRIAL = 3,
MAINLYAGRICULTURAL = 4,
RICHAGRICULTURAL = 5,
AVERAGEAGRICULTURAL = 6,
POORAGRICULTURAL = 7;
// startUp only runs once at startup before the demoscreen shows up.
this.startUp = function () {
this.reset(); // this.reset() fires not for a cmdr Jameson. When needed for a Jameson, call it here.
};
// this runs after loading in a saved game. missionVariables are read in at this point.
this.reset = function () {
if (oolite.compareVersion("1.73.4") > 0) {
log("script." + this.name, "This Oolite Shipyards Extension does not run under Oolite version " + oolite.versionString + ". Oolite Shipyards Extension is disabled.");
delete this.shipWillDockWithStation;
delete this.shipExitedWitchspace;
delete this.shipLaunchedFromStation;
} else {
this.mustPopulate = true;
}
/* used for adding ships after a first launch.
This way you don't have to time consuming check every launch if a ship was already there.
*/
};
this.shipDockedWithStation = function (station) {
// another eventhandler could have launched the ship already when it fires before this script.
if (player.ship.docked) {
this.freeTradeZoneDocking(station);
}
};
// Ships to be added to interstellar space
this.setupInterstellarShips = function () {
this.addDredgerShip();
this.addHardPirateShips();
this.addMissionaryShips();
this.addNavyPatrolShips();
this.pimpMySystem();
};
// Ships to be added to the system
this.setupSystemShips = function () {
this.addClipperShip();
this.addDredgerShip();
this.addExecutiveFlightShips();
this.addFreeTradeZone();
this.addFrogRickshawShip();
this.addHardPirateShips();
this.addInraPatrolShips();
this.addIxianShips();
this.addMissionaryShips();
this.addNavyPatrolShips();
this.addOoBayShips();
this.addPirateCove();
this.addSalezaShips();
this.addSIRFYardStation();
this.addSuperCobraShips();
this.pimpMySystem();
};
// add interstellar or system ships
this.setUpShips = function () {
if (system.isInterstellarSpace) {
this.setupInterstellarShips();
} else {
this.setupSystemShips();
}
};
this.shipExitedWitchspace = function () {
this.setUpShips();
};
this.shipLaunchedFromStation = function () {
/* The first launch after a restart the system must be populated after a launch.
The other times it happens after a WitchspaceJump */
if (this.mustPopulate) {
this.mustPopulate = false;
this.setUpSystemShips();
}
};
this.addClipperShip = function () {
if (system.techLevel >= 8 && Math.random() < 0.65) {
system.legacy_addSystemShips('clipper-rescueship', 1, 0.9);
}
};
this.addDredgerShip = function () {
if (system.techLevel >= 9 && Math.random() < 0.10) {
system.legacy_addShipsAt('dredger', 1, 'pwp', [0.3, 0.3, 3.5]);
system.legacy_addShipsAt('dredger', 1, 'pwp', [0, 0, 1.5]);
}
};
this.addExecutiveFlightShips = function () {
if (system.countShipsWithPrimaryRole('trident') === 0) {
if (system.government <= COMMUNIST && Math.random() < 0.25) {
system.legacy_addSystemShips('trident', 1, 0.5);
}
if (system.government >= CONFEDERACY && system.techLevel >= 7 && Math.random() < 0.75) {
system.legacy_addSystemShips('trident', 1, 0.4);
}
if (system.government >= CONFEDERACY && system.techLevel >= 10 && Math.random() < 0.20) {
system.legacy_addSystemShips('strelka', 1, 0.8);
}
}
};
this.addFreeTradeZone = function () {
if (system.government === MULTIGOVERNMENT) {
system.legacy_addShipsAt('free_trade_zone', 1, 'wpu', [0, 0, -0.3]);
system.legacy_addShipsAtPrecisely('ftzpirate', 2, 'wpu', [0, 0, -0.25]);
this.freetradezone_marked = false;
if (Math.random() < 0.25) {
system.legacy_addShipsAtPrecisely('pirate', 2, 'wpu', [0, 0, -0.25]);
}
if (Math.random() < 0.70) {
system.legacy_addShipsAtPrecisely('ftzpirate', 2, 'wpu', [0, 0, -0.2]);
}
if (Math.random() < 0.30) {
system.legacy_addShipsAtPrecisely('ftzpirate', 4, 'wpu', [0, 0, -0.15]);
}
if (Math.random() < 0.50) {
system.legacy_addShipsWithinRadius('ftzhauler', 1, 'wpu', [0, 0, -0.2], 5000);
}
if (Math.random() < 0.25) {
system.legacy_addShipsWithinRadius('ftzhauler', 1, 'wpu', [0, 0, -0.25], 5000);
}
if (Math.random() < 0.10) {
system.legacy_addShipsWithinRadius('police', 6, 'wpu', [0, 0, -0.3], 5000);
}
}
};
this.freeTradeZoneDocking = function (station) {
if (station.name === 'Free Trade Zone') {
if (this.freetradezone_marked !== true) {
player.bounty += 5;
this.freetradezone_marked = true;
}
}
};
this.addFrogRickshawShip = function () {
if (system.economy <= MAINLYINDUSTRIAL) {
system.legacy_addSystemShips('rickshaw', 1, 0.1);
system.legacy_addSystemShips('rickshaw', 1, 0.9);
}
};
this.addHardPirateShips = function () {
// Add a base level of pirate ships
if (system.government === ANARCHY) {
if (Math.random() < 0.30) {
system.legacy_addSystemShips('hardpirate', 4, 0.1);
}
if (Math.random() < 0.20) {
system.legacy_addSystemShips('hardpirate', 2, 0.4);
}
if (Math.random() < 0.10) {
system.legacy_addSystemShips('hardpirate', 6, 0.6);
}
if (Math.random() < 0.05) {
system.legacy_addSystemShips('hardpirate', 4, 0.8);
}
if (Math.random() < 0.04) {
system.legacy_addSystemShips('hardpirate', 4, 0.9);
}
}
if (system.government === FEUDAL) {
if (Math.random() < 0.25) {
system.legacy_addSystemShips('hardpirate', 2, 0.2);
}
if (Math.random() < 0.15) {
system.legacy_addSystemShips('hardpirate', 2, 0.1);
}
if (Math.random() < 0.10) {
system.legacy_addSystemShips('hardpirate', 4, 0.5);
}
if (Math.random() < 0.05) {
system.legacy_addSystemShips('hardpirate', 2, 0.8);
}
if (Math.random() < 0.03) {
system.legacy_addSystemShips('hardpirate', 4, 0.9);
}
}
if (system.government >= MULTIGOVERNMENT && system.government <= CONFEDERACY) {
if (Math.random() < 0.10) {
system.legacy_addSystemShips('hardpirate', 2, 0.1);
}
if (Math.random() < 0.08) {
system.legacy_addSystemShips('hardpirate', 4, 0.4);
}
if (Math.random() < 0.06) {
system.legacy_addSystemShips('hardpirate', 2, 0.3);
}
}
if (system.government === DEMOCRACY) {
if (Math.random() < 0.10) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.45, 0], 10000);
}
if (Math.random() < 0.05) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.30, 0], 10000);
}
if (Math.random() < 0.03) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.90, 0], 10000);
}
}
if (system.government === CORPORATESTATE) {
if (Math.random() < 0.05) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.55, 0], 10000);
}
if (Math.random() < 0.03) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.75, 0], 10000);
}
}
// Add additional pirate ships
if (system.government === ANARCHY && Math.random() < 0.30) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.3, 0], 10000);
}
if (system.government <= FEUDAL && Math.random() < 0.20) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.45, 0], 10000);
}
if (system.government <= MULTIGOVERNMENT && Math.random() < 0.10) {
system.legacy_addShipsWithinRadius('hardpirate', 4, 'swu', [0, 0.65, 0], 10000);
}
if (system.government <= COMMUNIST && Math.random() < 0.05) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.75, 0], 10000);
}
if (system.government <= CONFEDERACY && Math.random() < 0.03) {
system.legacy_addShipsWithinRadius('hardpirate', 4, 'swu', [0, 0.85, 0], 10000);
}
if (system.government >= DEMOCRACY && Math.random() < 0.04) {
system.legacy_addSystemShips('hardpirate', 2, 0.5);
}
if (system.government >= DEMOCRACY && Math.random() < 0.03) {
system.legacy_addSystemShips('hardpirate', 4, 0.3);
}
};
this.addInraPatrolShips = function () {
if (system.techLevel >= 15) {
system.legacy_addShipsAt('INRA', 1, 'pwu', [0, 0, 0.7]);
system.legacy_addShipsAt('INRA', 1, 'pwu', [0, 0, 0.3]);
}
};
this.addIxianShips = function () {
if (system.government >= FEUDAL) {
if (system.population < 30 && Math.random() < 0.20) {
system.legacy_addShipsAt('ixian_ship', 1, 'pwu', [0, 0, 0.75]);
}
if (system.population < 25 && Math.random() < 0.50) {
system.legacy_addShipsAt('ixian_ship', 1, 'pwu', [0, 0, 0.45]);
}
}
};
this.addMissionaryShips = function () {
if (player.ship.fuel >= 5 && Math.random() < 0.90) {
system.legacy_addSystemShips('missionary', 1, 0.3);
system.legacy_addSystemShips('missionary', 1, 0.7);
}
};
this.addNavyPatrolShips = function () {
system.legacy_addShipsAt('police', 2, 'pwu', [0, 0, 0.9]);
system.legacy_addShipsAt('militarybig', 2, 'pwu', [0, 0, 0.8]);
system.legacy_addShipsAt('interceptor', 2, 'pwu', [0, 0, 0.65]);
system.legacy_addShipsAt('militarycarrier', 2, 'pwu', [0, 0, 0.5]);
system.legacy_addShipsAt('militarymedium', 2, 'pwu', [0, 0, 0.2]);
system.legacy_addShipsAt('hunter', 2, 'pwu', [0, 0, 0.1]);
};
this.addOoBayShips = function () {
if (system.countShipsWithPrimaryRole('Auction-Station-Storage') <= 9) {
system.legacy_addShipsAtPrecisely('Auction-Station-Node1', 1, 'pwp', [0, 0, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node2', 1, 'pwp', [0, 0, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node3', 1, 'pwp', [0, 0, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node4', 1, 'pwp', [-0.2, 0, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node5', 1, 'pwp', [-0.2, 0, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node6', 1, 'pwp', [-0.2, 0, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node7', 1, 'pwp', [-0.4, 0, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node8', 1, 'pwp', [-0.4, 0, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node9', 1, 'pwp', [-0.4, 0, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node10', 1, 'pwp', [0, 0.2, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node11', 1, 'pwp', [0, 0.2, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node12', 1, 'pwp', [0, 0.2, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node13', 1, 'pwp', [-0.2, 0.2, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Beacon', 1, 'pwp', [-0.2, 0.2, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node14', 1, 'pwp', [-0.2, 0.2, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node15', 1, 'pwp', [-0.4, 0.2, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node16', 1, 'pwp', [-0.4, 0.2, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node17', 1, 'pwp', [-0.4, 0.2, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node18', 1, 'pwp', [0, 0.4, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node19', 1, 'pwp', [0, 0.4, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node20', 1, 'pwp', [0, 0.4, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node21', 1, 'pwp', [-0.2, 0.4, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node22', 1, 'pwp', [-0.2, 0.4, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node23', 1, 'pwp', [-0.2, 0.4, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node24', 1, 'pwp', [-0.4, 0.4, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node25', 1, 'pwp', [-0.4, 0.4, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node26', 1, 'pwp', [-0.4, 0.4, 1.8]);
}
};
this.addPirateCove = function () {
if (system.countShipsWithPrimaryRole('pirate') >= 10 && system.countShipsWithPrimaryRole('pirate-cove') === 0) {
system.legacy_addSystemShips('pirate-cove', 1, 0.12);
system.legacy_addSystemShips('asteroid', 8, 0.12);
}
};
this.addSalezaShips = function () {
if (system.government === CORPORATESTATE && system.techLevel <= 9 && Math.random() < 0.60) {
system.legacy_addSystemShips('rigel', 1, 0.3);
system.legacy_addSystemShips('saiph', 2, 0.6);
}
if (system.government >= CONFEDERACY && Math.random() < 0.30) {
system.legacy_addSystemShips('saiph', 1, 0.4);
}
if (system.government === DICTATORSHIP && system.techLevel >= 10 && Math.random() < 0.80) {
system.legacy_addSystemShips('rigel', 1, 0.4);
}
if (system.government === CORPORATESTATE && system.techLevel >= 10 && Math.random() < 0.60) {
system.legacy_addSystemShips('bellatrix', 1, 0.3);
}
};
this.addSIRFYardStation = function () {
if (system.techLevel >= 11) {
if (system.countShipsWithPrimaryRole('SIRF-YARD') === 0) {
system.legacy_addShipsAt('SIRF-YARD', 1, 'pwu', [1, 1, 3]);
}
}
};
this.addSuperCobraShips = function () {
system.legacy_addShipsAt('policesupercobra', 1, 'spu', [0, 0, 0.2]);
system.legacy_addShipsAt('supercobratraderminerhunter', 1, 'spu', [0, 0, 0.9]);
system.legacy_addShipsAt('militarysupercobra', 1, 'spu', [0, 0, 0.75]);
system.legacy_addShipsAt('piratesupercobra', 1, 'pwu', [0, 0, 0.4]);
};
this.pimpMySystem = function () {
system.legacy_addShipsAt('uber', 1, 'spu', [0, 0, 0.9]);
system.legacy_addShipsAt('uber', 1, 'wpu', [0, 0, 0.5]);
system.legacy_addShipsAt('uber', 1, 'wsu', [0, 0, 0.5]);
};