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

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

Moderators: winston, another_commander

Post Reply
User avatar
mossfoot
---- E L I T E ----
---- E L I T E ----
Posts: 827
Joined: Fri May 30, 2014 4:07 pm
Contact:

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

Post by mossfoot » Tue Jul 08, 2014 12:21 am

Love it! Look forward to hearing some female chatter from traffic control!

Wonder if that same kind of gibberish could be applied to the Communications OXP, so that when someone sends a message you hear the garble as a kind of audial cue?
--
Image
Pilot: Mossfoot - Ship ID: Viaticus Rex (Cobra MKII)
Rank: Competent - Status: Clean

http://www.noahchinnbooks.com/

User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6310
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

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

Post by Diziet Sma » Tue Jul 08, 2014 3:03 am

Interesting idea! It would be a fair bit of work, but something like that ought to be within the current capabilities of Oolite.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied

User avatar
mossfoot
---- E L I T E ----
---- E L I T E ----
Posts: 827
Joined: Fri May 30, 2014 4:07 pm
Contact:

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

Post by mossfoot » Tue Jul 08, 2014 3:59 am

Hopefully someone can give an idea of how much work that would be. Hopefully not too much ;)
--
Image
Pilot: Mossfoot - Ship ID: Viaticus Rex (Cobra MKII)
Rank: Competent - Status: Clean

http://www.noahchinnbooks.com/

vsfc
Dangerous
Dangerous
Posts: 103
Joined: Wed Jul 10, 2013 12:39 am

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

Post by vsfc » Wed Jul 09, 2014 5:08 am

Hi Everyone!

Sorry if I missed the info, but how do I write a message into log, just for debug purpose?

Thanks,
vsfc

User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4018
Joined: Fri Nov 11, 2011 6:19 pm

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

Post by cim » Wed Jul 09, 2014 5:58 am

In JS, do log(this.name,"Log message");

Actually the first parameter can be any string but using the current script name makes it easier to tell where your messages are coming from once you've added lots of them...

vsfc
Dangerous
Dangerous
Posts: 103
Joined: Wed Jul 10, 2013 12:39 am

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

Post by vsfc » Thu Jul 10, 2014 1:55 am

Hi,

I updated my code to check and not to log when fuel is bought. At the moment more adjustment needed around selling equipment to adhere to all different variations from SELL, REFUND, _REMOVAL, etc. Will be nice if we could stick to some standard??? There are other cases need to be handled, which I do not want to be logged like use of saving anywhere OXP.

Code: Select all

this.playerBoughtEquipment = function(equip)
	{
        if(!equip.match("EQ_FUEL"))
        {
		    this.clockString = clock.days + ":" + clock.hoursComponent + ":" + clock.minutesComponent + ":" + clock.secondsComponent; 
    		this.dateArray.push(this.clockString);

            var equipInfo = EquipmentInfo.infoForKey(equip);

            log(this.name, equip);

            if(equip.match("_REMOVAL"))
            {
                this.textArray.push(equipInfo.name + " sold at " + system.name + " for " + (player.credits - this.oldCredits) + "cr");
            }
            else
            {
                this.textArray.push(equipInfo.name + " purchased at " + system.name + " for " + (this.oldCredits - player.credits) + "cr");
            }

    		this.trimArrays();
        }

  	    this.oldCredits = player.credits;	
	}
Cheers,
vsfc

User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6310
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

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

Post by Diziet Sma » Fri Jul 11, 2014 10:05 am

In response to a recent question of Cody's, I was finally motivated to patch RandomShipNames v1.4 to work with the expanded list of ship roles in 1.80.

According to cim, a more flexible approach is possible, but that will have to wait until Commander McLane has the opportunity to upgrade RSN. In the meantime, this is what needs to be done so that you don't see just "Krait" or "Mamba", for example, when you ID certain ships.

The relevant section of randomshipnames.js is the this.shipSpawned = function(ship) function, which can be found at lines 803-886.

The full listing of this function is as follows:

Code: Select all

this.shipSpawned = function(ship)
{
    // certain entities are excluded
    if(ship.isCargo || ship.isBoulder || ship.isThargoid || ship.scanClass === "CLASS_STATION" || ship.isWeapon || ship.isPlayer || (ship.scriptInfo.randomshipnames && ship.scriptInfo.randomshipnames === "no")) return;
    if(ship.primaryRole === "random_hits_patrol" || ship.hasRole("vector") || ship.hasRole("dredgers") || ship.primaryRole === "rescue_freighter" || ship.hasRole("vortex_NPC") || ship.hasRole("vortex_maelstrom_NPC") || ship.hasRole("aquatics_hammerHead") || ship.hasRole("liners_emerald") || ship.hasRole("liners_tigershark") || ship.hasRole("liners_smivs-liner") || ship.hasRole("TCAT_raptor") || ship.hasRole("generationship") || ship.hasRole("random_hits_markguard_weak") || ship.hasRole("random_hits_markguard_medium") || ship.hasRole("random_hits_markguard_strong") || ship.hasRole("stellarSerpent")) return;
    // ships which already have a separator which indicates an individual name are excluded
    if(ship.displayName.substr(0, 4) === "RRS " || ship.displayName.indexOf(":") !== -1 || ship.displayName.indexOf("~") !== -1 || ship.displayName.indexOf(" - ") !== -1) return;
    // the renegades.oxp ships and some assassins.oxp ships get a generic role together with their custom role
    if(ship.primaryRole === "hardpirate" || ship.primaryRole === "unlocked3" || ship.primaryRole === "unlocked8" || ship.primaryRole === "unlocked9" || ship.primaryRole === "unlocked10")
    {
        ship.primaryRole = "pirate";
    }
    // only ordinary pirates, hunters, traders, shuttles, scavengers, miners, police, military (and their escorts) and rock hermits are affected; this should exclude most special OXP ships
    // pirates and their escorts
    if(ship.isPirate || (ship.owner && ship.owner.isPirate) || ship.primaryRole === "ups-slavecobra" || ship.primaryRole === "taxi_pirate" || (ship.scriptInfo.randomshipnames && ship.scriptInfo.randomshipnames === "pirate"))
    {
        ship.displayName += ": " + this.$randomPirateName(ship);
        return;
    }
    // police and military
    if(ship.isPolice || ship.scanClass === "CLASS_MILITARY" || (ship.scriptInfo.randomshipnames && (ship.scriptInfo.randomshipnames === "police" || ship.scriptInfo.randomshipnames === "military")))
    {
        ship.displayName += ": " + this.$randomPoliceName(ship);
        return;
    }
    // hunters, defense ships, escorts, and some special ships
    if(ship.primaryRole === "hunter" || ship.primaryRole === "defense_ship" || ship.hasRole("vector_revenge") || ship.hasRole("togy-patrol") || (ship.owner && (ship.owner.isPirateVictim || ship.owner.primaryRole === "hunter" || ship.owner.hasRole("vector"))) || (ship.scriptInfo.randomshipnames && ship.scriptInfo.randomshipnames === "hunter"))
    {
        ship.displayName += ": " + this.$randomHunterName(ship);
        return;
    }
    // rock hermits
    if(ship.primaryRole === "rockhermit" || ship.primaryRole === "pirate-cove" || (ship.scriptInfo.randomshipnames && ship.scriptInfo.randomshipnames === "rockhermit"))
    {
        // if a rock hermit was named previously, its name is retrieved from a list of all rock hermit names in the current galaxy
        if(system.ID >= 0 && this.rockHermitList[system.ID].length > 0)
        {
            for(var i=0; i<rockHermitList[system.ID].length; i++)
            {
                // the already named rock hermits are identified by their position in the system
                var savedPosition = new Vector3D(this.rockHermitList[system.ID][i][0].x, this.rockHermitList[system.ID][i][0].y, this.rockHermitList[system.ID][i][0].z);
                // the following lines are only necessary for 1.77 and 1.78, because deep space
                // Rock Hermits' positions fluctuate wildly due to a bug in the populator
                // this is going to be fixed in 1.79
                if(0 < oolite.compareVersion("1.79"))
                {
                    var positionXY = new Vector3D(savedPosition.x, savedPosition.y, 0);
                    var distanceToWPLane = positionXY.magnitude();
                    var distanceToPSLane = savedPosition.toCoordinateSystem("psm");
                    distanceToPSLane.z = 0;
                    distanceToPSLane = distanceToPSLane.magnitude();
                    if(ship.position.subtract(savedPosition).magnitude() < 10 || (distanceToWPLane > 25600 && distanceToPSLane > 25600))
                    {
                        ship.displayName = this.rockHermitList[system.ID][i][1];
                        return;
                    }
                }
                // in 1.79, all Rock Hermit positions are permanently fixed, therefore
                // also deep space hermits can be identified by their position
                else
                {
                    if(ship.position.subtract(savedPosition).magnitude() < 10)
                    {
                        ship.displayName = this.rockHermitList[system.ID][i][1];
                        return;
                    }
                }
            }
        }
        ship.displayName += ": " + this.$randomRockhermitName(ship);
        // newly named rock hermits are added to the list
        if(system.ID >= 0)
        {
            var storedName = [ship.position, ship.displayName];
            this.rockHermitList[system.ID].push(storedName);
        }
        return;
    }
    // ordinary traders, scavengers, and miners
    if(ship.isPirateVictim || ship.primaryRole === "scavenger" || ship.primaryRole === "miner" || (ship.scriptInfo.randomshipnames && ship.scriptInfo.randomshipnames === "trader"))
    {
        ship.displayName += ": " + this.$randomTraderName(ship);
    }
}
Line 817 needs to be changed from:

Code: Select all

    if(ship.isPirate || (ship.owner && ship.owner.isPirate) || ship.primaryRole === "ups-slavecobra" || ship.primaryRole === "taxi_pirate" || (ship.scriptInfo.randomshipnames && ship.scriptInfo.randomshipnames === "pirate"))
to:

Code: Select all

    if(ship.isPirate || (ship.owner && ship.owner.isPirate) || ship.primaryRole === "pirate" || ship.primaryRole === "pirate-light-fighter" || ship.primaryRole === "pirate-medium-fighter" || ship.primaryRole === "pirate-heavy-fighter" || ship.primaryRole === "pirate-light-freighter" || ship.primaryRole === "pirate-medium-freighter" || ship.primaryRole === "pirate-heavy-freighter" || ship.primaryRole === "pirate-interceptor" || ship.primaryRole === "pirate-aegis-raider" || ship.primaryRole === "ups-slavecobra" || ship.primaryRole === "taxi_pirate" || (ship.scriptInfo.randomshipnames && ship.scriptInfo.randomshipnames === "pirate"))
Line 823 needs to be changed from:

Code: Select all

    if(ship.isPolice || ship.scanClass === "CLASS_MILITARY" || (ship.scriptInfo.randomshipnames && (ship.scriptInfo.randomshipnames === "police" || ship.scriptInfo.randomshipnames === "military")))
To:

Code: Select all

    if(ship.isPolice || ship.scanClass === "CLASS_MILITARY" || ship.primaryRole === "police" || ship.primaryRole === "interceptor" || ship.primaryRole === "wingman" || (ship.scriptInfo.randomshipnames && (ship.scriptInfo.randomshipnames === "police" || ship.scriptInfo.randomshipnames === "military")))
Line 829 need to be changed from:

Code: Select all

    if(ship.primaryRole === "hunter" || ship.primaryRole === "defense_ship" || ship.hasRole("vector_revenge") || ship.hasRole("togy-patrol") || (ship.owner && (ship.owner.isPirateVictim || ship.owner.primaryRole === "hunter" || ship.owner.hasRole("vector"))) || (ship.scriptInfo.randomshipnames && ship.scriptInfo.randomshipnames === "hunter"))
to:

Code: Select all

    if(ship.primaryRole === "hunter" || ship.primaryRole === "hunter-medium" || ship.primaryRole === "hunter-heavy" || ship.primaryRole === "escort" || ship.primaryRole === "escort-medium" || ship.primaryRole === "escort-heavy" || ship.primaryRole === "defense_ship" || ship.primaryRole === "assassin-light" || ship.primaryRole === "assassin-medium" || ship.primaryRole === "assassin-heavy" || ship.hasRole("vector_revenge") || ship.hasRole("togy-patrol") || (ship.owner && (ship.owner.isPirateVictim || ship.owner.primaryRole === "hunter" || ship.owner.hasRole("vector"))) || (ship.scriptInfo.randomshipnames && ship.scriptInfo.randomshipnames === "hunter"))
And line 882 needs to be changed from:

Code: Select all

    if(ship.isPirateVictim || ship.primaryRole === "scavenger" || ship.primaryRole === "miner" || (ship.scriptInfo.randomshipnames && ship.scriptInfo.randomshipnames === "trader"))
to:

Code: Select all

    if(ship.isPirateVictim || ship.primaryRole === "scavenger" || ship.primaryRole === "miner" || ship.primaryRole === "shuttle" || ship.primaryRole === "trader" || ship.primaryRole === "trader-courier" || ship.primaryRole === "trader-smuggler" || (ship.scriptInfo.randomshipnames && ship.scriptInfo.randomshipnames === "trader"))

For those who'd rather just have the patch than edit the OXP themselves, you can download a copy of the patched randomshipnames.js by clicking here.

Whichever method you use, don't forget to flush the cache by shift-starting Oolite when you're done!
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied

Neelix
---- E L I T E ----
---- E L I T E ----
Posts: 288
Joined: Sat May 31, 2014 9:02 pm
Location: Melbourne, Australia

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

Post by Neelix » Fri Jul 11, 2014 10:42 am

Cheers!

... Am almost tempted to add a few additional words to the words lists... :-) (but I have something else I really want to focus on)

- Neelix
Talaxian Enterprises: [wiki]Vacuum Pump[/wiki] [wiki]Waypoint Here[/wiki]

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

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

Post by Thargoid » Fri Jul 11, 2014 11:03 am

For some of them (for example lines 817, 829 and 882) it may be simpler and more elegant to use a string search (either search() or indexOf() ) rather than explicitly look for the specific new roles containing "pirate", "assassin", "escort" and "trader".

It would be more compact and would also semi future-proof things in case additional role variants on those four are introduced later.

User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6310
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

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

Post by Diziet Sma » Fri Jul 11, 2014 11:09 am

Neelix wrote:... Am almost tempted to add a few additional words to the words lists... :-) (but I have something else I really want to focus on)
Then perhaps you should just pass them along to Commander McLane for inclusion in the next version, instead.. :wink:
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied

User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6310
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

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

Post by Diziet Sma » Fri Jul 11, 2014 11:13 am

Thargoid wrote:For some of them (for example lines 817, 829 and 882) it may be simpler and more elegant to use a string search (either search() or indexOf() ) rather than explicitly look for the specific new roles containing "pirate", "assassin", "escort" and "trader".

It would be more compact and would also semi future-proof things in case additional role variants on those four are introduced later.
Well, cim has already suggested a method of future-proofing, which I presume McLane will do in his next upgrade.. this is only intended as an interim fix.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied

User avatar
CaptSolo
---- E L I T E ----
---- E L I T E ----
Posts: 888
Joined: Wed Feb 23, 2011 10:08 pm
Location: Hermit's Pipe
Contact:

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

Post by CaptSolo » Fri Jul 11, 2014 2:23 pm

Diziet Sma wrote:cim has already suggested a method of future-proofing[/url], which I presume McLane will do in his next upgrade.. this is only intended as an interim fix.
Until then, Diz, many thanks for this.

User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6310
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

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

Post by Diziet Sma » Fri Jul 11, 2014 5:04 pm

You're most welcome.. :D
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied

UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1103
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

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

Post by UK_Eliter » Fri Jul 11, 2014 11:23 pm

Diziet Sma: thanks. It's a great OXP.

User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Disunited Kingdom
Contact:

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

Post by Smivs » Mon Jul 14, 2014 1:19 pm

I have been chatting to Dizzie over at my 'OXPs and 1.80' thread and the subject of my test ship came up.
When you are testing it is sometimes helpful to be be to cover vast distances in a short time, so my Contractor test ship has Magic Fuel Tanks which re-fill after every witchjump, thus avoiding the need to waste time re-fuelling. This is accomplished with a simple script that some of you might find helpful.

Code: Select all

"use strict"

// Standard attributes 
this.name           = "fuelCheatScript.js"; 
this.author         = "Smivs"; 
this.copyright      = "This script is hereby placed in the public domain."; 
this.version        = "1.0"; 
this.description    = "Script for 'cheat' fuel refill.";

{
this.shipExitedWitchspace = function()
 {
  player.ship.fuel += 7.0;
 }
}
Simply name this 'script.js' (without the quote marks) and place it in your AddOns folder.
N.B. This is a testing tool, and not a cheat that should be used for normal gameplay. :wink:
Commander Smivs, the friendliest Gourd this side of Riedquat.

Post Reply