Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

The Oolite Extended Project - Fork, no oxp

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post by Lestradae »

Thargoid wrote:
So I might just take OSE as it is now (or soon to be) and snip it back to being "RS+". But it's a shame as what it used to be is what I actually wanted, but it's gone a bit too M$ for me of late.
Hm, what about snipping the last OSE version (V0.7) to fit your tastes and then publish this too as a separate oxp?

It would be a smaller bundle with only ships in. And together with RS V4.0 (the purely repricing one) it would give you all functions you like?

I would help out with doing that, at least by offering box net space (but then I think you have that yourself?)

Sorry if it gets too unwieldy for you :( - but I really hope this is not Oo-M$, two differences at least:

1) I'm so not going to get rich. (Projected income for my work: 0.0€)

2) Really hoping that the crash coefficient of finished OE will be massively lower than M$'s ...
Screet wrote:
I guess it's best if we find the most common modifications which could arise and provide easy steps upon how to customize this project to the personal desires.
The problem I see with this is, this customisation option does already exist: The usual oxp system :wink:

Everyone can customise that one to their heart's content. "Oolite Extended" is thought for the players who have the space hardwarewise and also the wish to have every possible add-on in one go plus the RS/OSE options. That's why I want to provide the options unique to future OE as separate oxps also. That way, anyone who wants to customise but not miss their ship pricing and player stations along the way can then do so - the usual oxp route.

"Oolite Extended" is intended to be an alternative to the oxp system for all-inclusive gameplay, not as a replacement.

At least these are my 0.2Cr atm 8)

L
pmw57
---- E L I T E ----
---- E L I T E ----
Posts: 389
Joined: Sat Sep 26, 2009 2:14 pm
Location: Christchurch, New Zealand

Post by pmw57 »

Screet wrote:
Thargoid wrote:
Also whilst some people may like the Oobay stations and all the "unusual" player ships and things like that, I can't say personally that I do. I just want a nice mix of ships to look at, but relatively few are of interest to actually fly.
Removing oobay is as simple as commenting out a single line in the populator script ;)
Thanks - I'm glad that part worked out so well.

Here's a crazy idea that someone with some spare time may want to take and leap upon - an Oolite OXP builder where you pick and choose the ships and missions that you like, so that you can download a specially packaged version that is customised to your desires.
A trumble a day keeps the doctor away, and the tax man;
even the Grim Reaper keeps his distance.
-- Paul Wilkins
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post by Lestradae »

pmw57 wrote:
- an Oolite OXP builder where you pick and choose the ships and missions that you like, so that you can download a specially packaged version that is customised to your desires.
Cool idea, but I won't do it. I have my hands rather full with what I'm doing just now :wink: If someone else did it, why not? Perhaps this is something for the Suggestions forum?

But I have a question and request towards you I would point you at if I may :)

The playerstations still have a part in planetinfo.plist that might get java-scripted instead, it looks like this for example:

Code: Select all

<key>1 40</key>
        <dict>
                <key>script_actions</key>
                <array>
                        <string>checkForShips: playerfuelstation</string>
                        <dict>
                                <key>conditions</key>
                                <array>
                                        <string>mission_playerstation_BBB equal 1</string>
                                        <string>shipsFound_number lessthan 1</string>
                                </array>
                                <key>do</key>
                                <array>
                                        <string>addSystemShips: playerfuelstation 1 0.8</string>
                                </array>
                        </dict>
                </array>
        </dict>
Would it be possible to java script this instead, and would you do it if the answer was yes?

Second thing is, I did randomise the "fluctuating market" for the playerstations via equipment.plist. Thargoid criticised that the fluctuations were too fast and the result looked more buggy than a moving market to him - he suggested giving the player stations a random result every time a main station (where they can be bought) was entered. Could this be scripted too? Because I can't :oops: - otherwise it'd have to stay the "fast changing market" it is now ...

Cheers & looking forwards to getting this up to speed again :D

L
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Re: ..

Post by Thargoid »

Lestradae wrote:
Hm, what about snipping the last OSE version (V0.7) to fit your tastes and then publish this too as a separate oxp?

It would be a smaller bundle with only ships in. And together with RS V4.0 (the purely repricing one) it would give you all functions you like?

I would help out with doing that, at least by offering box net space (but then I think you have that yourself?)

Sorry if it gets too unwieldy for you :( - but I really hope this is not Oo-M$, two differences at least:

1) I'm so not going to get rich. (Projected income for my work: 0.0€)

2) Really hoping that the crash coefficient of finished OE will be massively lower than M$'s ...
It's quite possibly what I am going to do for my own personal usage. But there would be a few points:

  • It would only be done once a stable version of OSE/OE is released, as you lot still seem to be messing around with things (see the posts above).
  • Release to the masses if done would probably be a one-off and unsupported. I don't have the time nor the inclination to keep something so big and sprawling up to date. Things would only change if I happened to adjust my personal set-up, and that could easily be just zipped and uploaded.
  • Given your comments above about things still being all tangled up between various plists (equipment, planetinfo, shipdata etc) it's not ready for stripping back yet except for a few simple things by snipping out worldscripts (which I've already done on mine).
  • It would need a hell of a lot of work to know which player ships you've added, and which are in the original OXPs. So this version would probably not be faithful to either (some original OXP player ships may end up removed, and some non-original ones may slip through) hence another reason for it not getting too public an airing.
But yes, currently OSE is causing my systems significant pauses (a few seconds) on launch and witchspace entry, and I really dislike the appearance of the Oobay station with the grid of flashers (especially how they just appear at a certain distance). It's become too large and resource-using for my fairly basic system, hence it can't survive there in its current form.

Just a personal opinion, but perhaps a reality check that your ambitions stay grounded and don't outstrip what most people actually want.[/color][/list]
pmw57
---- E L I T E ----
---- E L I T E ----
Posts: 389
Joined: Sat Sep 26, 2009 2:14 pm
Location: Christchurch, New Zealand

Re: ..

Post by pmw57 »

Lestradae wrote:
The playerstations still have a part in planetinfo.plist that might get java-scripted instead

Would it be possible to java script this instead, and would you do it if the answer was yes?
I'll see what I can do.
Lestradae wrote:
Second thing is, I did randomise the "fluctuating market" for the playerstations via equipment.plist. Thargoid criticised that the fluctuations were too fast and the result looked more buggy than a moving market to him - he suggested giving the player stations a random result every time a main station (where they can be bought) was entered. Could this be scripted too? Because I can't :oops: - otherwise it'd have to stay the "fast changing market" it is now ...
According to theory that's possible, but it would take some investigation. I'll start checking it out tomorrow night.

Edit: update misconception
Last edited by pmw57 on Sun Nov 01, 2009 10:31 am, edited 1 time in total.
A trumble a day keeps the doctor away, and the tax man;
even the Grim Reaper keeps his distance.
-- Paul Wilkins
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Currently the available player stations change whenever you select the equipment screen (or even go from screen to screen within the same selection of equipment screen).

For me that looks terrible, as if something isn't there that I want, or is there but too expensive, all I need to do is press cursor left/right a few times until I get something that I want at a price I like.

Even if it's supposed to be a feature, it looks like a bug.
matthewfarmery
Dangerous
Dangerous
Posts: 100
Joined: Sat Oct 10, 2009 7:19 pm

Post by matthewfarmery »

sounds like an interesting idea, sorry I haven't been on much, but anyway, I do like the idea if it works well
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

...

Post by Lestradae »

Thanks, pmw57, for looking into it :D

@T: Perhaps the OE project is only the first of bundled meta-oxps. Actually it isn't even the first - there's the combined sounds opx for example that precedes OSE at least.

Nothing speaks against other bundles for other tastes and other hardware requirements :wink:

Of course it's a lot of hard and sometimes tedious work (I should know) but then, one of the things great about Oolite is that you can have basically everything you want to - but have to do it yourself.

Cheers everyone 8)

L
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post by Lestradae »

Today I created a proof-of-concept alternate loadscreen for Oolite Extended.

Have a look at it, please have mercy, it is the first time I tried my hand on something graphical like this and it might show :oops:

Image

At the moment Oolite's loadscreen is hardcoded and not oxp-able, but I have put up a request if that might be changed.

Let me know what you think of my first try 8)

L
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Re: ..

Post by Screet »

Lestradae wrote:
Let me know what you think of my first try 8)
Hmmm. I would not like it for the splash screen although it might well be in your post about this oxp and where it can be downloaded to show why someone may want it ;)

For a splash screen, it's big and I've played so much that I don't need to see all these things all the time. Something more subtle would be nicer, like the original Oolite splash with a slight addition like "with extended oxp" or such.

Anyway, I think the original splash part could do well with a position more to the center of it, as it's also the center around which this oxp (and thus the included ones) build ;)

Screet
User avatar
LittleBear
---- E L I T E ----
---- E L I T E ----
Posts: 2868
Joined: Tue Apr 04, 2006 7:02 pm
Location: On a survey mission for GalCop. Ship: Cobra Corvette: Hidden Dragon Rated: Deadly.

Post by LittleBear »

Definatley an add for the download page, but too big for a splash screen! :wink:
OXPS : The Assassins Guild, Asteroid Storm, The Bank of the Black Monks, Random Hits, The Galactic Almanac, Renegade Pirates can be downloaded from the Elite Wiki here.
pmw57
---- E L I T E ----
---- E L I T E ----
Posts: 389
Joined: Sat Sep 26, 2009 2:14 pm
Location: Christchurch, New Zealand

Re: ...

Post by pmw57 »

Lestradae wrote:
Thanks, pmw57, for looking into it :D
The player stations script is now updated.
playerStations.7z

The last several hours of entertainment has been spent troubleshooting a shipWillExitStation event, to much hair pulling.

Anyway, playerStations.js has been updated so that its events will run both when entering witchspace, and after loading a save game when launching from the station.

Here's the main guts of the code

Code: Select all

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);
		}
	}
};
The part that I initially added consisted of a lookup table that looked something like this:

Code: Select all

var stations = [
    {10: {code: 'AAA', name: 'playerrockhermit'}, 20: {code: 'ABA', name: 'playerrockhermit'},
    {30: {code: 'BAA', name: 'playerfuelstation'}, 40: {code: 'BBA', name: 'playerfuelstation'},
    ...
};
There was a lot of repetition in there though, so the code is now obtained from the system number, and the rule that defines the first character of the code, is used to pick the station too.

Generating the station code now is fairly straight forward:

Code: Select all

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;
};
The most entertaining part of this was when adding the Roo Bay station - I realised that all of the node placements are 0.2 away from each other, thus inspiring this arrow-shaped piece of code.

Code: Select all

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]);
			}
		}
	}
};
The playerStations.7z file includes the above code, and comes with world-scripts.plist and the dramatically trimmed planetinfo.plist
A trumble a day keeps the doctor away, and the tax man;
even the Grim Reaper keeps his distance.
-- Paul Wilkins
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

.

Post by Lestradae »

This is indeed dramatically reduced in length :shock:

I have a few questions, though, as I have already a half-working beta of the Extended idea on my harddrive and my worldscripts and planetinfo plists are not what they were :twisted:

Is the following correct?

1) The six scripts in the folder now do everything nescessary for the player stations, including placing them in systems if owned, yes? (Brilliant solution btw for the OoBay Auction Stations and the system numbers shortening trick :idea: )

2) I can take out all planetinfo.plist entries for the player stations, as the PlayerStations.js now does all its work?

3) Why exactly does the worldscripts.plist change? Did we still have a script that has disappeared now/become redundant?

Right On, Commander 8)

L

Edit: Short-ish bug report ...
[script.javaScript.exception.notFunction]: ***** JavaScript exception ("Oolite Shipyards Extension" 0.71): TypeError: this.setUpSystemShips is not a function
[script.javaScript.exception.notFunction]: ../AddOns/Oolite Extended Main Data V0.8.oxp/Scripts/OSE-populator.js, line 98.
And the OoBay Auction Stations have disappeared ... probably also all the other system ships, too? :(

Oolite "1.74" trunk, SVN 2717.
pmw57
---- E L I T E ----
---- E L I T E ----
Posts: 389
Joined: Sat Sep 26, 2009 2:14 pm
Location: Christchurch, New Zealand

Re: .

Post by pmw57 »

<rubs sleep from eyes>
Lestradae wrote:
1) The six scripts in the folder now do everything nescessary for the player stations, including placing them in systems if owned, yes?
I'll have a look around this evening and see what else there is to be found in the property lists.
Lestradae wrote:
2) I can take out all planetinfo.plist entries for the player stations, as the PlayerStations.js now does all its work?
Yes you can.
Lestradae wrote:
3) Why exactly does the worldscripts.plist change? Did we still have a script that has disappeared now/become redundant?
Nothing in worldscripts.plist was change on this occasion. It was included for completion, so that other people can take OSE 0.70 and drop in the code without needing to make any other changes.[/quote]
Lestradae wrote:
Edit: Short-ish bug report ...
[script.javaScript.exception.notFunction]: ***** JavaScript exception ("Oolite Shipyards Extension" 0.71): TypeError: this.setUpSystemShips is not a function
[script.javaScript.exception.notFunction]: ../AddOns/Oolite Extended Main Data V0.8.oxp/Scripts/OSE-populator.js, line 98.
And the OoBay Auction Stations have disappeared ... probably also all the other system ships, too? :(
Ahh, a historical bug. I must have had something strange in there before doing this most recent update.

If you would kindly provide me with your most recent playerStations.js file, I will work in to it my most recent changes from last night.
A trumble a day keeps the doctor away, and the tax man;
even the Grim Reaper keeps his distance.
-- Paul Wilkins
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

Re: .

Post by Lestradae »

pmw57 wrote:
Lestradae wrote:
1) The six scripts in the folder now do everything nescessary for the player stations, including placing them in systems if owned, yes?
I'll have a look around this evening and see what else there is to be found in the property lists.
Lestradae wrote:
2) I can take out all planetinfo.plist entries for the player stations, as the PlayerStations.js now does all its work?
Yes you can.
Lestradae wrote:
3) Why exactly does the worldscripts.plist change? Did we still have a script that has disappeared now/become redundant?
Nothing in worldscripts.plist was change on this occasion. It was included for completion, so that other people can take OSE 0.70 and drop in the code without needing to make any other changes.
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.
pmw57 wrote:
Lestradae wrote:
Edit: Short-ish bug report ...
[script.javaScript.exception.notFunction]: ***** JavaScript exception ("Oolite Shipyards Extension" 0.71): TypeError: this.setUpSystemShips is not a function
[script.javaScript.exception.notFunction]: ../AddOns/Oolite Extended Main Data V0.8.oxp/Scripts/OSE-populator.js, line 98.
And the OoBay Auction Stations have disappeared ... probably also all the other system ships, too? :(
Ahh, a historical bug. I must have had something strange in there before doing this most recent update.

If you would kindly provide me with your most recent playerStations.js file, I will work in to it my most recent changes from last night.
OK, then I will provide the playerStations.js and the OSE-populator.js currently residing on my harddrive:

playerStations.js:

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;
};
OSE-populator.js:

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]);
};
Post Reply