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!