Page 7 of 29

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

Posted: Tue Jul 08, 2014 12:21 am
by mossfoot
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?

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

Posted: Tue Jul 08, 2014 3:03 am
by Diziet Sma
Interesting idea! It would be a fair bit of work, but something like that ought to be within the current capabilities of Oolite.

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

Posted: Tue Jul 08, 2014 3:59 am
by mossfoot
Hopefully someone can give an idea of how much work that would be. Hopefully not too much ;)

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

Posted: Wed Jul 09, 2014 5:08 am
by vsfc
Hi Everyone!

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

Thanks,
vsfc

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

Posted: Wed Jul 09, 2014 5:58 am
by cim
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...

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

Posted: Thu Jul 10, 2014 1:55 am
by vsfc
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

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

Posted: Fri Jul 11, 2014 10:05 am
by Diziet Sma
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!

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

Posted: Fri Jul 11, 2014 10:42 am
by Neelix
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

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

Posted: Fri Jul 11, 2014 11:03 am
by Thargoid
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.

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

Posted: Fri Jul 11, 2014 11:09 am
by Diziet Sma
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:

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

Posted: Fri Jul 11, 2014 11:13 am
by Diziet Sma
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.

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

Posted: Fri Jul 11, 2014 2:23 pm
by CaptSolo
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.

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

Posted: Fri Jul 11, 2014 5:04 pm
by Diziet Sma
You're most welcome.. :D

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

Posted: Fri Jul 11, 2014 11:23 pm
by UK_Eliter
Diziet Sma: thanks. It's a great OXP.

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

Posted: Mon Jul 14, 2014 1:19 pm
by Smivs
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: