Tinkerer's Workshop - OXP tweaking for fun and profit!

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

Moderators: another_commander, winston

User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2555
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by spara »

Hello mohawk and welcome aboard,

There's a reason for additional planets to be like they are, but if you want to tweak and test different options here are a couple of tips that might work. Or not. No guarantees. These are 100% untested suggestions PMd to another enthusiastic tinkerer some time ago.

Make planets sun centric:

var planetPosition = directionV.multiply(distance).fromCoordinateSystem("psm");

->

var planetPosition = directionV.multiply(distance).fromCoordinateSystem("spm");

Spread the planets all around the spheres instead of the current umbrella like positioning:

var polar = Math.acos(1.4 * system.scrambledPseudoRandomNumber(galaxyNumber + 5 * (i + 1)) - 1);

->

var polar = Math.acos(2.0 * system.scrambledPseudoRandomNumber(galaxyNumber + 5 * (i + 1)) - 1);

Make sure the main planet is the closest to the sun

var baseOrbit = 5 * baseUnit;

->

var baseOrbit = system.mainPlanet.position.magnitude().fromCoordinateSystem("psm") + 5 * baseUnit;

Have fun :D .

User avatar
Day
---- E L I T E ----
---- E L I T E ----
Posts: 527
Joined: Tue Mar 03, 2015 11:35 am
Location: Paris

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by Day »

But as I said enough times already I am not a coder :(
You are now :)
Take it from a pro: you've scratched an itch, modified some code to your liking, tested it and made it work, then published it: you're a coder. Welcome :wink:

User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 13820
Joined: Sat Jul 04, 2009 9:31 pm
Location: Corke's Drift
Contact:

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by Cody »

Cookies are in the jar - welcome aboard, Commander!

mohawk
Competent
Competent
Posts: 46
Joined: Thu Feb 28, 2013 1:21 pm

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by mohawk »

Thank you all for the worm welcome, and for enhancing my Oolite experience with all those oxps! :D
There's a reason for additional planets to be like they are, but if you want to tweak and test different options here are a couple of tips that might work. Or not. No guarantees. These are 100% untested suggestions PMd to another enthusiastic tinkerer some time ago.
by reasons should I think cosmetic, or functional, like npc behaviour?
I thought that if I let the main planet in it's original position there shouldn't be much of a hassle to ban the rest of the planets in unreachable for the npcs positions (unless there is a way to give them taurus drives. this.ship.maxSpeed is writable from 1.82 version I heard :D )

anyway thank you for the tips, I will give them a try :D
Take it from a pro: you've scratched an itch, modified some code to your liking, tested it and made it work, then published it: you're a coder. Welcome :wink:
Well I guess you are right. Not a decent one, :oops: but a coder nevertheless :mrgreen:
Cookies are in the jar - welcome aboard, Commander!
I love cookies! 8) Thank you!

User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2555
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by spara »

mohawk wrote: by reasons should I think cosmetic, or functional, like npc behaviour?
Mainly cosmetic. Redspear and I spent quite some time testing what looks good and what doesn't. The main culprit is the sun, being too close and quite small. It was poison for immersion to put planets near sun or behind it. The distances were limited so that in an unmodified game the farthest planet should not be more than 10 mins away. Or was if 15... .

NPCs won't normally be visiting additional planets, they occupy the lanes.

mohawk
Competent
Competent
Posts: 46
Joined: Thu Feb 28, 2013 1:21 pm

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by mohawk »

And now that I started looking around may Addons folder, I remembered that I have changed the missile spoof to not automatically ECM when normal missiles are fired against me, because some large pirate groups would drive my energy level to the floor with their constant firing. Now all the missiles are treated equally and the flares give me enough time to press "e" when I see fit! 8)

missile-spoof.js

Code: Select all

this.shipAttackedWithMissile = function(missile, whom)
{
if(player.ship.fuel < 0.1 && player.ship.equipmentStatus("EQ_MISSILE_SPOOF") == "EQUIPMENT_OK")
    {
    if((player.ship.equipmentStatus("EQ_ECM") == "EQUIPMENT_OK"))
	{
	player.ship.fireECM();
	player.consoleMessage("Fuel exausted. Cannot produce flares.",5);
	}
    }
    else if(player.ship.fuel > 0.0 && player.ship.equipmentStatus("EQ_MISSILE_SPOOF") == "EQUIPMENT_OK")
	{
	player.ship.fuel -= 0.1;
	system.legacy_addShipsWithinRadius("spoof_flare_package", 1, "abs", player.ship.position.subtract(player.ship.orientation.vectorUp().multiply(20)), 10);
	}
}

this.playerBoughtEquipment = function(equipmentKey)
   {     
   if(equipmentKey == ("EQ_MISSILE_SPOOF_REMOVAL"))
      {
      player.ship.removeEquipment("EQ_MISSILE_SPOOF");
      player.ship.removeEquipment("EQ_MISSILE_SPOOF_REMOVAL");
      player.credits += 1000;
      }
	}

mohawk
Competent
Competent
Posts: 46
Joined: Thu Feb 28, 2013 1:21 pm

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by mohawk »

Mainly cosmetic. Redspear and I spent quite some time testing what looks good and what doesn't. The main culprit is the sun, being too close and quite small. It was poison for immersion to put planets near sun or behind it. The distances were limited so that in an unmodified game the farthest planet should not be more than 10 mins away. Or was if 15... .

NPCs won't normally be visiting additional planets, they occupy the lanes.
That's good to know! I think that if they are far away enough they won't look that bad. Actually the numbers I posted, make most of them almost not visible, but They "feel" more right to me :) You know having to fly behind the sun in order to visit a distant planet!

anyway I'll take a look at those formulas and maybe I end up to the same conclusion :)

mohawk
Competent
Competent
Posts: 46
Joined: Thu Feb 28, 2013 1:21 pm

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by mohawk »

In case anyone else is interested.
var planetPosition = directionV.multiply(distance).fromCoordinateSystem("spm");
This did work as expected. The planets are orbiting the sun now :D
var polar = Math.acos(2.0 * system.scrambledPseudoRandomNumber(galaxyNumber + 5 * (i + 1)) - 1);
This did work to spread the planets in a sphere but it kinda looked weird to me. Plus all the planets were in the opposite side of the sun from the main planet.
so after a lot of trial and error (not big news there!) I ended up with the following:

Code: Select all

var polar = (2.0 * Math.PI * system.scrambledPseudoRandomNumber(galaxyNumber + 5 * (i + 1)) - 1);

Code: Select all

var azimouth = 0;

This layout makes the planets orbit the sun and are spread all around, In the same plane and not a sphere which I think is more realistic.
Although I have to agree that it looks strange when the planets are close :| So I would suggest something like :
baseOrbit = 15 * baseUnit
orrbitDifference = 18 * baseUnit

Now I am satisfied with my system layout. the planets are barely visible, and visiting them feels like quite a journey. (endless without the taurus to sun oxp) The planetary systems are now more specious :) (wonders if he is getting claustrophobic :? )
var baseOrbit = system.mainPlanet.position.magnitude().fromCoordinateSystem("psm") + 5 * baseUnit;
This actually gave me an error saying system.mainPlanet.position.magnitude().fromCoordinateSystem is not a function or something, and I can not understand what I am doing wrong, But anyway I don't thing this is actually necessary because there is not enough room for a planet to fit between the main planet and the sun with the baseOrbit and orbitDifference values that I use. Not that I would mind because in my mind the closest to sun planet is not usually the one in the habitable zone.

The last thing that I need is reason to visit those planets, like some prices bargain, or a package delivery or something.
So far I think that that the only oxp that would send me to an other planet is the in system taxi.

User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2555
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by spara »

:D Glad you got it working, mohawk.
mohawk wrote:
var baseOrbit = system.mainPlanet.position.magnitude().fromCoordinateSystem("psm") + 5 * baseUnit;
This actually gave me an error saying system.mainPlanet.position.magnitude().fromCoordinateSystem is not a function...
Now that you mention it, of course it does :roll: . Magnitude gives a scalar and that naturally has no fromCoordinateSystem function. I think I meant it to be system.mainPlanet.position.fromCoordinateSystem("psm").magnitude().
mohawk wrote: The last thing that I need is reason to visit those planets, like some prices bargain, or a package delivery or something.
So far I think that that the only oxp that would send me to an other planet is the in system taxi.
A bit of a shameless plug, but Stations for Extra Planets oxp puts stations to those far away planets and prices will get wilder the farther they are from the main planet. And you'll love the variety of those stations :) .

mohawk
Competent
Competent
Posts: 46
Joined: Thu Feb 28, 2013 1:21 pm

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by mohawk »

A bit of a shameless plug, but Stations for Extra Planets oxp puts stations to those far away planets and prices will get wilder the farther they are from the main planet. And you'll love the variety of those stations
Well that's interesting!. I do have Stations for extra planets installed, but I didn't know that there is variation in prices with distance :oops:
This is actually exactly what I was talking about.
Good think you told me about it before I wend on looking for a way to do It myself and end up messing things up in my Addons folder :mrgreen:
It looks like you read my mind in advance :lol:

(note to self. Check that you need to modify before you fire up vim :roll: )

mohawk
Competent
Competent
Posts: 46
Joined: Thu Feb 28, 2013 1:21 pm

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by mohawk »

I have an other modification that I used a lot in the past, but I kind of lost all my home brew oxps during a system upgrade and I can't seem to be able to make it work again.
Something I am doing wrong and I can't remember what I did differently before.
I used to bypass the prime/activate equipment with n button restriction (It bothers me more than it should :| ) by using a mine that sends a script message to the equipment script to activate the equipment
This way I could have 3 - 4 equipment easily activated in my missile array 8)

but It does not work as expected. In Naval energy grid for example:

I made an AI for the mine
NG_switchAI.plist

Code: Select all

{
	"GO_BANG" = {
	ENTER = ("pauseAI: 0.2");
	EXIT = ();
	UPDATE = (becomeExplosion, "sendScriptMessage: activate");
	};
    
	GLOBAL = {
	ENTER = ("setStateTo: GO_BANG" ); 
	EXIT = (); 
	UPDATE = (); 
	}; 
}
I added the equipment in equipment.plist

Code: Select all

(
        2,
        1000,
        "Naval Energy Grid Activation Switch",
        "EQ_NG_SWITCH_MINE",
        "A switch that enables you to prime your Naval Energy Grid using your missile selection button.",
                {
                "available_to_all" = true;
                "available_to_npc" = false;
                "requires_equipment" = "EQ_NAVAL_GRID";
                "incompatible_with_equipment" = "EQ_NG_SWITCH_MINE";
		script = "milGrid_script.js";
                }
        ),
I made a shipdata.plist

Code: Select all

{


	"NG_switch" = {
		"ai_type" = "NG_switchAI.plist"; 
		"cargo_type" = "CARGO_NOT_CARGO"; 
		"energy_recharge_rate" = "0.0"; 
		"forward_weapon_type" = "WEAPON_NONE"; 
		"likely_cargo" = 0; 
		"max_cargo" = 0; 
		"max_energy" = 1; 
		"max_flight_pitch" = "0.5"; 
		"max_flight_roll" = "0.5"; 
		"max_flight_speed" = 0; 
		model = "alloy.dat"; 
		name = "Naval Energy Grid Activation Switch"; 
		roles = "EQ_NG_SWITCH_MINE"; 
		script = "milGrid_script.js"; 
		thrust = "0.0"; 
	}; 


}
and finally I added this in the bottom of the milGrid_script.js

Code: Select all

this.activate = function()
{
	player.ship.awardEquipment("EQ_NG_SWITCH_MINE");
	this.activated();
}
Now everything looks like it works,
the mine pops,
the script message is sent,
the mine is re awarded,
I get a message "energy transferred to shields" but nothing happens.

could someone help locate what I am doing wrong?

p.s the AI and shipdata.plist are copied and modified from Thargoid's Armoury oxp

Duggan
---- E L I T E ----
---- E L I T E ----
Posts: 490
Joined: Sat Dec 31, 2011 2:58 pm

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by Duggan »

Not an oxz tweak at all but if you'd like to give your cannons a bit more thump in Oolite 1.82.

In the ooliite app. open config, then open equipment, scroll to lasers and adjust (just a little upwards..or you will wreck your game completely) the range and/ or damage level. This in my current experience, humbles the more lethal foes quiet adequately.
Flying Python Class Cruiser, Chapter & Verse IV

Layne
---- E L I T E ----
---- E L I T E ----
Posts: 355
Joined: Sat Mar 28, 2015 11:14 pm

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by Layne »

I've had a couple of requests to post my modifications to HOopy Casinos and Your Ad Here that limits their appearance to Corporate systems only, thus making a de facto system OXP out of them in the same mode as Commies, Anarchies, Dictators, etc.

A couple of disclaimers: First, I'm using very very old versions of both OXP's because I'm trying to keep the retro look to my game. I cannot guarantee this modification will work with the current versions. Second, my change to YAH is designed only to populate the billboards at the Witchpoint and Navigation beacon, it does nothing to Constores themselves (personally I've removed them completely, as all I wanted was billboards).

In HOopy Casinos, you will need to edit hoopy_casino.js to change the script:

Code: Select all

this.tryAddingCasinoship = function () {
	if (system.techLevel >= 10 && system.pseudoRandom100 > 55 && system.government != 4 || system.info.description.indexOf('hoopy casinos') > -1) {
        // add in high tech level systems, but not in comunist systems. But, always in systems famous for their casinos.
		system.addShipsToRoute('casinoship', 1, 0.995); // near station
	}
into:

Code: Select all

this.tryAddingCasinoship = function () {
	if (system.techLevel >= 11 && system.government == 7) {
        // add in high tech level systems, but not in comunist systems. But, always in systems famous for their casinos.
		system.addShipsToRoute('casinoship', 1, 0.995); // near station
This is just a simple change that only spawns casinos in high-tech, corporate systems and nowhere else.

Secondly, the version of YAH I'm using populates billboards via the shipdata.plist in the config folder. Newer versions may use a script instead, in which case, you'd need to change that in the same way as HOopy, by setting the system.government type to 7, which is Corporate. If your version of YAH still uses the shipdata.plist, this is a sample for the billboards:

Code: Select all

<key>yah_set_A_01-navbeacon</key>
	<dict>
		<key>conditions</key>
		<array> 
			<string>systemGovernment_number equal 7</string> 
		</array>
There will be over twenty of these navbeacons that all have to have their systemGovernment _number changed to 7 in the same way.

Sorry if I'm not explaining this very well, but coding isn't my forte and this is very much a tinkering solution. Together this should only spawn casinos and billboards in Corporate systems, adding a little unique local color to those types. I personally call the result Panem et Circenses. There are a few other plugins for YAH, like the moving billboards or asteroid billboards. I am fairly sure this same idea can also limit those to the same system type, and will look into adding those in as well at some point-- just to keep the advertising saturation up for the good citizens of those Corporate systems!

Edit: Thinking about it, I did just download Thargoid's Your Ad Here Mobile and found it quite easy to make the same changes to both the shipdata.plist and script.js. This should add the ship-towed billboards as well!
Reports of my death have been greatly underestimated.

User avatar
phkb
Commodore
Commodore
Posts: 2529
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by phkb »

If you use the "Dangerous Square" or "Xolonium" fonts, you might have noticed that, occasionally, the columns on the contract screens don't line up. Here are some examples when using "Xolonium":

Image
Image
Image

To fix this, create a new folder in your addons called "ContractsFix.oxp", and a sub folder called "Scripts". Then, copy into it the oolite-contracts-cargo.js, oolite-contracts-passengers.js and oolite.contracts-parcels.js from the \oolite.app\resources\scripts folder.

(Note: if you're happy making these changes each time your main Oolite application is updated, you don't need to worry about the ContractsFix.oxp folder - just update the original files).

Next, make the following changes to each file:

oolite-contracts-cargo.js
Line 500 change from

Code: Select all

 		var columns = [10,16,21,26];
to

Code: Select all

 		var columns = [9,15,21,26];
Line 533 change from

Code: Select all

 				priceText = this.$helper._paddingText(priceText, 3.25)+priceText;
to

Code: Select all

 				priceText = this.$helper._paddingText(priceText, 3.5)+priceText;
Line 538 change from

Code: Select all

 				priceText = this.$helper._paddingText(priceText, 3.25)+priceText;
to

Code: Select all

 				priceText = this.$helper._paddingText(priceText, 3.5)+priceText;
oolite-contracts-parcels.js
Line 522 change from

Code: Select all

 		priceText = this.$helper._paddingText(priceText, 2.5)+priceText;
to

Code: Select all

 		priceText = this.$helper._paddingText(priceText, 3.5)+priceText;
oolite-contracts-passengers.js
Line 492 change from

Code: Select all

 	var columns = [12,18,23,28];
to

Code: Select all

 	var columns = [12,17.5,23,28];
Line 524 change from

Code: Select all

 		priceText = this.$helper._paddingText(priceText, 3)+priceText;
to

Code: Select all

 		priceText = this.$helper._paddingText(priceText, 3.5)+priceText;
Line 529 change from

Code: Select all

 		priceText = this.$helper._paddingText(priceText, 3)+priceText;
to

Code: Select all

 		priceText = this.$helper._paddingText(priceText, 3.5)+priceText;
And there you go! Nice, neat columns again.

User avatar
phkb
Commodore
Commodore
Posts: 2529
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by phkb »

I think it's kind of odd that a standard missile takes 15 minutes to install, but an ECM hardened mission takes over an hour. Why is that? I mean, it's getting put into the same slot.

If you think this seems odd too, then this little tweak is for you. From Oolite version 1.81 and onwards we can set the installation time of equipment. So, to give ECM missiles the same installation time as a standard missile, all you do is this.

1. Find the "equipment.plist" file in your oolite.app/Resources/Config folder
2. Find the ECM missile entry in the file
3. Add "installation_time = 900;" to the dataset, so it ends up looking like this:

Code: Select all

	( /* ecm hardened missile */
		9, 3500, "ECM Hardened Missile",
		"EQ_HARDENED_MISSILE",
		"Faulcon de Lacy HMX5 homing missile - hardened against ECM.",
		{
			condition_script = "oolite-conditions.js";
			available_to_all = true;
			"installation_time" = 900;
			/* NOTE: for reasons of backwards compatibility, this defaults to true for equipment whose key ends with MISSILE or MINE. */
			requires_empty_pylon = true;
			/* NOTE: this is always zero for pylon-mounted equipment */
			damage_probability = 0;
		}
	),
4. Save the file, and restart Oolite while holding the shift key down, and you're done.

Post Reply