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
Tricky
---- E L I T E ----
---- E L I T E ----
Posts: 821
Joined: Sun May 13, 2012 11:12 pm
Location: Bradford, UK. (Anarchic)

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

Post by Tricky »

Cody wrote:
A thought, Tricky - would that sun_distance_modifier override an OXP's sun_distance_modifier, or possibly clash with it, causing a very distant sun?
Maybe. Forgot to mention, if you have an OXP that modifies sun distance then remove that line. You might want to play with ambient_level too, the interstellar value of 0.1 maybe too dark for some.
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16052
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

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

Post by Cody »

Tricky wrote:
Maybe. Forgot to mention, if you have an OXP that modifies sun distance then remove that line.
<nods> Yeah, I've had that happen before, I think - it looked cool, but made the sunward trip very time consuming.
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
SirArian
Dangerous
Dangerous
Posts: 104
Joined: Fri Feb 28, 2014 3:18 am
Location: Diqudi in chart 3

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

Post by SirArian »

Okay then, here's what I did.

For the Taxi Galactica, open "taxi_galactica_main.js" in the scripts folder. Take out what is on lines 211 through 269:

Code: Select all

	// Random chance (%) for pirate encounters:
	this._piraterandomnumber = Math.floor(Math.random() * (100 - 1 + 1) + 1);
	// If current contract is Easy difficulty then 20% chance pirates will be spawned:
	if (missionVariables.taxi_diff === 0)
	{
		if (system.ID === missionVariables.taxi_dest)
		{
			// If current system is contract destination spawn 3 pirates:
			if (this._piraterandomnumber > 80) system.addShipsToRoute("taxi_pirate", 3, null, "wp");
		}
		else
		{
			// If current system is not contract destination spawn 1 pirate:
			if (this._piraterandomnumber > 80) system.addShipsToRoute("taxi_pirate", 1, null, "wp");
		}
	}
	// If current contract is Medium difficulty then 40% chance pirates will be spawned:
	else if (missionVariables.taxi_diff === 1)
	{
		if (system.ID === missionVariables.taxi_dest)
		{
			// If current system is contract destination spawn 4 pirates:
			if (this._piraterandomnumber > 60) system.addShipsToRoute("taxi_pirate", 4, null, "wp");
		}
		else
		{
			// If current system is not contract destination spawn 2 pirates:
			if (this._piraterandomnumber > 60) system.addShipsToRoute("taxi_pirate", 2, null, "wp");
		}
	}
	// If current contract is Hard difficulty then 60% chance pirates will be spawned:
	else if (missionVariables.taxi_diff === 2)
	{
		if (system.ID === missionVariables.taxi_dest)
		{
			// If current system is contract destination spawn 5 pirates:
			if (this._piraterandomnumber > 40) system.addShipsToRoute("taxi_pirate", 5, null, "wp");
		}
		else
		{
			// If current system is contract destination spawn 3 pirates:
			if (this._piraterandomnumber > 40) system.addShipsToRoute("taxi_pirate", 3, null, "wp");
		}
	}
	// If on special mission #1 then separatist ships might be spawned:
	else if (missionVariables.taxi_diff === 3)
	{
		// If current system is mission destination spawn 8 separatist fighters:
		if (system.ID === missionVariables.taxi_dest)
		{
			system.addShipsToRoute("taxi_separatist", 8, null, "wp");
		}
		// If current system is not mission destination there is 70% chance to spawn 4 separatist fighters:
		else
		{
			if (this._piraterandomnumber > 30) system.addShipsToRoute("taxi_separatist", 4, null, "wp");
		}
	}
}
and replace it with:

Code: Select all

	// Check to make sure that the player is carrying a passenger.
		if (missionVariables.taxistatus === "ON_THE_JOB")
		{
		// Random chance (%) for pirate encounters:
		this._piraterandomnumber = Math.floor(Math.random() * (100 - 1 + 1) + 1);
		// If current contract is Easy difficulty then 20% chance pirates will be spawned:
		if (missionVariables.taxi_diff === 0)
		{
			if (system.ID === missionVariables.taxi_dest)
			{
				// If current system is contract destination spawn 3 pirates:
				if (this._piraterandomnumber > 80) system.addShipsToRoute("taxi_pirate", 3, null, "wp");
			}
			else
			{
				// If current system is not contract destination spawn 1 pirate:
				if (this._piraterandomnumber > 80) system.addShipsToRoute("taxi_pirate", 1, null, "wp");
			}
		}
		// If current contract is Medium difficulty then 40% chance pirates will be spawned:
		else if (missionVariables.taxi_diff === 1)
		{
			if (system.ID === missionVariables.taxi_dest)
			{
				// If current system is contract destination spawn 4 pirates:
				if (this._piraterandomnumber > 60) system.addShipsToRoute("taxi_pirate", 4, null, "wp");
			}
			else
			{
				// If current system is not contract destination spawn 2 pirates:
				if (this._piraterandomnumber > 60) system.addShipsToRoute("taxi_pirate", 2, null, "wp");
			}
		}
		// If current contract is Hard difficulty then 60% chance pirates will be spawned:
		else if (missionVariables.taxi_diff === 2)
		{
			if (system.ID === missionVariables.taxi_dest)
			{
				// If current system is contract destination spawn 5 pirates:
				if (this._piraterandomnumber > 40) system.addShipsToRoute("taxi_pirate", 5, null, "wp");
			}
			else
			{
				// If current system is contract destination spawn 3 pirates:
				if (this._piraterandomnumber > 40) system.addShipsToRoute("taxi_pirate", 3, null, "wp");
			}
		}
		// If on special mission #1 then separatist ships might be spawned:
		else if (missionVariables.taxi_diff === 3)
		{
			// If current system is mission destination spawn 8 separatist fighters:
			if (system.ID === missionVariables.taxi_dest)
			{
				system.addShipsToRoute("taxi_separatist", 8, null, "wp");
			}
			// If current system is not mission destination there is 70% chance to spawn 4 separatist fighters:
			else
			{
				if (this._piraterandomnumber > 30) system.addShipsToRoute("taxi_separatist", 4, null, "wp");
			}
		}
	}
}
And for the laser booster (which is actually what was put in earlier for the cargo spotter), open the "laserBooster_worldScript.js" and take what is on 14-20:

Code: Select all

	{
	missionVariables.laserBooster = "INACTIVE"; 
	this.callCount = 0;
	this.laserTemp = 2;
	this.findLaser();
	this.callbackID = addFrameCallback(this.checkTemp.bind(this));
	}
and replace it with

Code: Select all

	{
	if(player.ship.equipmentStatus("EQ_LASERBOOSTER") == "EQUIPMENT_OK")
		{
		missionVariables.laserBooster = "ACTIVE"; 
		this.callCount = 0;
		this.laserTemp = 2;
		this.findLaser();
		this.callbackID = addFrameCallback(this.checkTemp.bind(this));
		}
		else
		{
		missionVariables.laserBooster = "INACTIVE"; 
		this.callCount = 0;
		this.laserTemp = 2;
		this.findLaser();
		this.callbackID = addFrameCallback(this.checkTemp.bind(this));
		}
	}
There may be a better way to do either, or probably both of these, but, as far as I have seen, will work.

(By the way, this seems to make it so that the laser breaks more often... I'm not sure if it has a timer that it uses to decide how likely it is to break that counts up starting when it is turned on, but that seems to be the case. Once I had my fore and aft lasers break within five minutes, and while I was fighting five or seven pirates.)

We need spoiler tags to hide these long strings of code until someone is ready to see it...
"May Duralium ever stand between you and the Vacuum."
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6547
Joined: Wed Feb 28, 2007 7:54 am

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

Post by another_commander »

Stickied since it contains useful tips and can inspire people to play with OXP and core game code. But we should probably unstickify something else from this subforum; there are just way too many sticky threads here.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

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

Post by cim »

"Orphaned OXPs" and "1.77 for OXPers" can probably go, I think.
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2020
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

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

Post by maik »

"Where are the expansion packs..." is redundant with information in the wiki and could go IMHO.
User avatar
Venator Dha
---- E L I T E ----
---- E L I T E ----
Posts: 329
Joined: Sun Feb 23, 2014 11:26 am
Location: Sweden

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

Post by Venator Dha »

I think this is a great thread, and have adopted some of the changes already mentioned, so I'll add some of my own small changes to Random Hits -which I think is a great OXP but found that the Seedy Space Bar a little unbalancing to the game.

Similar to the post that started this thread,
I changed line 763 in oolite-randomHits.js

Code: Select all

if (system.government === 0){
to

Code: Select all

if (system.government === 0 && Math.random() < 0.50){
Thus giving a 50% chance of a space bar in any anarchy system.

in shipdata.plist changed line 1637 to

Code: Select all

has_shipyard = 0.75; // changed to 75% has shipyard
to reduce the chance of a ship yard at the bar - which I found a little strange anyway.
I also changed some details in each space bar to make them more varied in equipment price and tech level. I disliked that you could access high tech in any anarchy system, now you have to be lucky, and you will pay more if it's there
e.g.
a high quality bar

Code: Select all

"random_hits_griff_spacebar38" = {
		"display_name" = "The Raxxla Ritz Hotel";
		"equipment_price_factor" = "1.18";
		"equivalent_tech_level" = 13;
to

Code: Select all

"random_hits_griff_spacebar38" = {
		"display_name" = "The Raxxla Ritz Hotel";
		"equipment_price_factor" = "2.00";
		"equivalent_tech_level" = 15;
and a low quality bar

Code: Select all

"random_hits_griff_spacebar16" = {
		"display_name" = "Joe's Bar and Grill";
		"equipment_price_factor" = "1.12";
		"equivalent_tech_level" = 12;
to

Code: Select all

"random_hits_griff_spacebar16" = {
		"display_name" = "Joe's Bar and Grill";
		"equipment_price_factor" = "1.05";
		"equivalent_tech_level" = 4;
I also modified the commodities.plist to make the pricing less extreme.

Code: Select all

{
   random_hits_spacebar = (
      ("Food", 0, 0, 19, -1, -1, 250, 5, 5, 0), // modified reduced price
      ("Textiles", 0, 0, 18, -1, 0, 250, 5, 10, 0),
      ("Radioactives", 0, 0, 53, -2, -3, 0, 7, 15, 0),
      ("Slaves", 0, 0, 40, -5, -1, 0, 15, 15, 0), // modified price & quantity
      ("Liquor/Wines", 0, 0, 83, -2, -1, 250, 10, 5, 0), // modified reduced price
      ("Luxuries", 0, 0, 190, 8, -1, 250, 9, 21, 0),
      ("Narcotics", 0, 0, 30, -2, 20, -4, 100, 30, 0), // modified price & quantity
      ("Computers", 0, 0, 150, 14, -1, 250, 3, 21, 0),
      ("Machinery", 0, 0, 120, 6, 1, 250, 31, 10, 0),
      ("Alloys", 0, 0, 68, 2, 1, 5, 31, 10, 0), // modified price & quantity
      ("Firearms", 0, 0, 100, 13, 0, 0, 63, 0, 0),
      ("Furs", 0, 0, 176, -9, -9, 220, 63, 63, 0), // modified price & quantity = main station algorithm
      ("Minerals", 0, 0, 25, -1, -1, 25, 5, 3, 0), // modified reduced price & quantity
      ("Gold", 0, 0, 100, 0, 0, 0, 4, 0, 1),
      ("Platinum", 0, 0, 181, 0, 0, 0, 21, 0, 1),
      ("Gem-Stones", 0, 0, 50, 0, 0, 0, 10, 0, 2),
      ("Alien Items", 0, 0, 125, 1, 0, 0, 31, 0, 0)
   );
}
Taurus Driving through the galaxy since... .
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

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

Post by spara »

Venator Dha wrote:
I changed line 763 in oolite-randomHits.js

Code: Select all

if (system.government === 0){
to

Code: Select all

if (system.government === 0 && Math.random() < 0.50){
Thus giving a 50% chance of a space bar in any anarchy system.
To keep things persistent, I suggest using system.scrambledPseudoRandomNumber("salt") rather than Math.random(). That way the space bar will still be there the next you visit the system.
User avatar
Venator Dha
---- E L I T E ----
---- E L I T E ----
Posts: 329
Joined: Sun Feb 23, 2014 11:26 am
Location: Sweden

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

Post by Venator Dha »

Thanks Spara,
that's the other good thing with this thread, great advice on code that's beyond my understanding :lol:

I'll give it a try, although I kind of like that the bar can disappear, I see it as the criminals who attack the bar as having won and destroyed it. :(
Taurus Driving through the galaxy since... .
User avatar
Keeper
---- E L I T E ----
---- E L I T E ----
Posts: 273
Joined: Fri Feb 01, 2013 7:44 am
Location: Indian Hills, Nevada, USA

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

Post by Keeper »

spara wrote:
To keep things persistent, I suggest using system.scrambledPseudoRandomNumber("salt") rather than Math.random(). That way the space bar will still be there the next you visit the system.
Hmm, perhaps something like this can make constores persistent, instead of changing brands every jump...?
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

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

Post by cim »

Keeper wrote:
Hmm, perhaps something like this can make constores persistent, instead of changing brands every jump...?
The tricky thing about that is that the constore brands are stored in separate OXPs which may or may not be installed. Something like:

Code: Select all

constoreTypes = Ship.keysForRole("constore");
currentConstoreType = Math.floor(system.scrambledPseudoRandomNumber(31514)*constoreTypes.length);
system.addShips("["+constoreTypes[currentConstoreType]+"]", ...);
should do it by building a list of which constores are available, and then deterministically picking one from that list. If the list length changes, almost all of them get rebranded, but the entrance or exit of a big corporation into the market would do that.

The catch is that Ship.keysForRole is 1.79-only. In previous versions you'd probably need to put a small script into each of the ad packs so that the main script could detect it, and build the list of available roles up that way.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

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

Post by spara »

cim wrote:

Code: Select all

constoreTypes = Ship.keysForRole("constore");
currentConstoreType = Math.floor(system.scrambledPseudoRandomNumber(31514)*constoreTypes.length);
system.addShips("["+constoreTypes[currentConstoreType]+"]", ...);
Does the result of keysForRole remain the same over time? If not, then the array should be sorted before selecting.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

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

Post by spara »

Here's a way to make constores persistent in 1.77.1

* From YAH main oxp, open the file your_ad_here.js from the Scripts folder
* line 42 looks like this:

Code: Select all

   var ships=system.addShips(role, count, offset,radius); 
* replace it with this:

Code: Select all

   if (role === "constore") {
		var conStores = ["constore-A", "constore-B", "constore-C", "constore-D", "constore-E", "constore-F", "constore-G"];
		var ships = null;
		while (ships === null && conStores.length !== 0) {
			var storeRole = conStores.splice(Math.floor(system.scrambledPseudoRandomNumber() * conStores.length), 1);
			ships = system.addShips(storeRole, count, offset,radius);
		}
	}
	else 
		var ships = system.addShips(role, count, offset, radius);
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

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

Post by cim »

spara wrote:
Does the result of keysForRole remain the same over time?
In practice, yes, so long as you don't change operating system, OXP list, or Oolite build. Sorting the list before using it is probably a good idea.
User avatar
CaptSolo
---- E L I T E ----
---- E L I T E ----
Posts: 909
Joined: Wed Feb 23, 2011 10:08 pm
Location: Preying Manta
Contact:

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

Post by CaptSolo »

Random Hits 1.4.18:
Reason for tweak: Did not want Seedy Space Bars spawned at every anarchy system.

Code: Select all

this.setupShips = function ()
{
    if (system.isInterstellarSpace) return;
    
    if (system.government === 0 && system.economy === 2) // only spawn at poor industrial systems
    {
        var barNumber = Math.floor(system.ID/16); // generates 0...15 (bar number 1...16) // max of 16 unique bar names
        var barPosition = new Vector3D(this.spacebarPositions[this.modulo(barNumber,5)]); // generates 0...4
        barPosition = system.mainPlanet.position.subtract(barPosition); // translate pwu into wpu
        barNumber++;
        this.setupSpacebar(barNumber, barPosition);

        // Random Bar Attacks
        if (Math.random() < 0.15)
        {
            system.addGroup("random_hits_big_boss", this.anyInt(3,6), barPosition, 10000);
            system.addGroup("random_hits_big_boss_fighter", 6, barPosition, 10000);
        }
    }
}
HyperRadio 1.26:
Reason for tweak: Did not like podMusic quiting with condition Red Alert (i.e. I like radio blasting during battle).

Code: Select all

this.alertConditionChanged = function(condition)
{
    if(this.doInit) this.doInit();
    if(this.hyperRadio)
    {
        if(condition===4) this.failPlay(); // There is no alert condition 4
        else if(!player.ship.docked && !system.isInterstellarSpace && !this.tempDisabled) this.canPlay = true;
    }
};
Post Reply