Posted: Wed Oct 07, 2009 1:09 pm
... and OpenStep in itself is so much easier to read than XML, as far as scripts are concerned.
For information and discussion about Oolite.
https://bb.oolite.space/
It's from neocaduceus oxp - and I don't know of any changes to that one.Lestradae wrote:1) With caduceus oxp in
2) With caduceus oxp and OSE in
3) Only OSE in
4) OSE in, but delete the shipyard-overrides.plist
5) With caduceus oxp in and OSE with deleted shipyard.plist
PS: Thought of something else ... Screet, did you buy that Caduceus with the old caduceus oxp, the one ClymAngus wanted changed?
Code: Select all
this.name = "Oolite Shipyards Extension";
this.author = "Paul Wilkins";
this.copyright = "(C) 2009 Paul Wilkins";
this.description = "Converted from the 0.70 version of ose.js to use proper ship loading techniques";
this.version = "0.71";
var ANARCHY = 0,
FEUDAL = 1,
MULTIGOVERNMENT = 2,
DICTATORSHIP = 3,
COMMUNIST = 4,
CONFEDERACY = 5,
DEMOCRACY = 6,
CORPORATESTATE = 7;
var RICHINDUSTIAL = 0,
AVERAGEINDUSTRIAL = 1,
POORINDUSTRIAL = 2,
MAINLYINDUSTRIAL = 3,
MAINLYAGRICULTURAL = 4,
RICHAGRICULTURAL = 5,
AVERAGEAGRICULTURAL = 6,
POORAGRICULTURAL = 7;
// startUp only runs once at startup before the demoscreen shows up.
this.startUp = function()
{
this.reset(); // this.reset() fires not for a cmdr Jameson. When needed for a Jameson, call it here.
}
// this runs after loading in a saved game. missionVariables are read in at this point.
this.reset = function()
{
if (oolite.compareVersion("1.73.4") > 0) {
log("script." + this.name, "This Oolite Shipyards Extension does not run under Oolite version " + oolite.versionString + ". Oolite Shipyards Extension is disabled.");
delete this.shipWillDockWithStation;
delete this.shipExitedWitchspace;
delete this.shipLaunchedFromStation;
} else {
this.mustPopulate = true;
}
/* used for adding ships after a first launch.
This way you don't have to time consuming check every launch if a ship was already there.
*/
}
this.shipDockedWithStation = function(station) {
// another eventhandler could have launched the ship already when it fires before this script.
if (player.ship.docked) {
this.freeTradeZoneDocking(station);
}
}
// Ships that are added to the system, and to interstellar space
this.setUpGlobalShips = function()
{
this.addNavyPatrolShips();
this.addMissionaryShips();
this.addDredgerShip();
this.addHardPirateShips();
this.pimpMySystem();
}
// Ships to be added to the system
this.setUpSystemShips = function()
{
this.addOoBayShips();
this.addInraPatrolShips();
this.addSIRFYardStation();
this.addFrogRickshawShip();
this.addMissionaryShips();
this.addClipperShip();
this.addDredgerShip();
this.addExecutiveFlightShips();
this.addSalezaShips();
this.addSuperCobraShips();
this.addIxianShips();
this.addHardPirateShips();
this.addFreeTradeZone();
this.addPirateCove();
this.pimpMySystem();
}
// add global and system ships
this.setUpShips = function () {
this.setUpGlobalShips();
if (system.isInterstellarSpace) {
return;
}
this.setUpSystemShips();
};
this.shipExitedWitchspace = function()
{
this.setUpShips();
}
this.shipLaunchedFromStation = function()
{
/* The first launch after a restart the system must be populated after a launch.
The other times it happens after a WitchspaceJump */
if (this.mustPopulate) {
this.mustPopulate = false;
this.setUpSystemShips();
}
}
this.addOoBayShips = function () {
if (system.countShipsWithPrimaryRole('Auction-Station-Storage') <= 9) {
system.legacy_addShipsAtPrecisely('Auction-Station-Node1', 1, 'pwp', [0, 0, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node2', 1, 'pwp', [0, 0, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node3', 1, 'pwp', [0, 0, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node4', 1, 'pwp', [-0.2, 0, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node5', 1, 'pwp', [-0.2, 0, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node6', 1, 'pwp', [-0.2, 0, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node7', 1, 'pwp', [-0.4, 0, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node8', 1, 'pwp', [-0.4, 0, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node9', 1, 'pwp', [-0.4, 0, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node10', 1, 'pwp', [0, 0.2, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node11', 1, 'pwp', [0, 0.2, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node12', 1, 'pwp', [0, 0.2, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node13', 1, 'pwp', [-0.2, 0.2, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Beacon', 1, 'pwp', [-0.2, 0.2, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node14', 1, 'pwp', [-0.2, 0.2, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node15', 1, 'pwp', [-0.4, 0.2, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node16', 1, 'pwp', [-0.4, 0.2, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node17', 1, 'pwp', [-0.4, 0.2, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node18', 1, 'pwp', [0, 0.4, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node19', 1, 'pwp', [0, 0.4, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node20', 1, 'pwp', [0, 0.4, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node21', 1, 'pwp', [-0.2, 0.4, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node22', 1, 'pwp', [-0.2, 0.4, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node23', 1, 'pwp', [-0.2, 0.4, 1.8]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node24', 1, 'pwp', [-0.4, 0.4, 1.4]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node25', 1, 'pwp', [-0.4, 0.4, 1.6]);
system.legacy_addShipsAtPrecisely('Auction-Station-Node26', 1, 'pwp', [-0.4, 0.4, 1.8]);
}
};
this.addInraPatrolShips = function () {
if (system.techLevel >= 15) {
system.legacy_addShipsAt('INRA', 1, 'pwu', [0, 0, 0.7]);
system.legacy_addShipsAt('INRA', 1, 'pwu', [0, 0, 0.3]);
}
};
this.addNavyPatrolShips = function () {
system.legacy_addShipsAt('police', 2, 'pwu', [0, 0, 0.9]);
system.legacy_addShipsAt('militarybig', 2, 'pwu', [0, 0, 0.8]);
system.legacy_addShipsAt('interceptor', 2, 'pwu', [0, 0, 0.65]);
system.legacy_addShipsAt('militarycarrier', 2, 'pwu', [0, 0, 0.5]);
system.legacy_addShipsAt('militarymedium', 2, 'pwu', [0, 0, 0.2]);
system.legacy_addShipsAt('hunter', 2, 'pwu', [0, 0, 0.1]);
};
this.addSIRFYardStation = function () {
if (system.techLevel >= 11) {
if (system.countShipsWithPrimaryRole('SIRF-YARD') === 0) {
system.legacy_addShipsAt('SIRF-YARD', 1, 'pwu', [1, 1, 3]);
}
}
};
this.addFrogRickshawShip = function () {
if (system.economy <= MAINLYINDUSTRIAL) {
system.legacy_addSystemShips('rickshaw', 1, 0.1);
system.legacy_addSystemShips('rickshaw', 1, 0.9);
}
};
this.addMissionaryShips = function () {
if (player.ship.fuel >= 5 && Math.random() < 0.90) {
system.legacy_addSystemShips('missionary', 1, 0.3);
system.legacy_addSystemShips('missionary', 1, 0.7);
}
};
this.addClipperShip = function () {
if (system.techLevel >= 8 && Math.random() < 0.65) {
system.legacy_addSystemShips('clipper-rescueship', 1, 0.9);
}
};
this.addDredgerShip = function () {
if (system.techLevel >= 9 && Math.random() < 0.10) {
system.legacy_addShipsAt('dredger', 1, 'pwp', [0.3, 0.3, 3.5]);
system.legacy_addShipsAt('dredger', 1, 'pwp', [0, 0, 1.5]);
}
};
this.addExecutiveFlightShips = function () {
if (system.countShipsWithPrimaryRole('trident') === 0) {
if (system.government <= COMMUNIST && Math.random() < 0.25) {
system.legacy_addSystemShips('trident', 1, 0.5);
}
if (system.government >= CONFEDERACY && system.techLevel >= 7 && Math.random() < 0.75) {
system.legacy_addSystemShips('trident', 1, 0.4);
}
if (system.government >= CONFEDERACY && system.techLevel >= 10 && Math.random() < 0.20) {
system.legacy_addSystemShips('strelka', 1, 0.8);
}
}
};
this.addSalezaShips = function () {
if (system.government === CORPORATESTATE && system.techLevel <= 9 && Math.random() < 0.60) {
system.legacy_addSystemShips('rigel', 1, 0.3);
system.legacy_addSystemShips('saiph', 2, 0.6);
}
if (system.government >= CONFEDERACY && Math.random() < 0.30) {
system.legacy_addSystemShips('saiph', 1, 0.4);
}
if (system.government === DICTATORSHIP && system.techLevel >= 10 && Math.random() < 0.80) {
system.legacy_addSystemShips('rigel', 1, 0.4);
}
if (system.government === CORPORATESTATE && system.techLevel >= 10 && Math.random() < 0.60) {
system.legacy_addSystemShips('bellatrix', 1, 0.3);
}
};
this.addSuperCobraShips = function () {
system.legacy_addShipsAt('policesupercobra', 1, 'spu', [0, 0, 0.2]);
system.legacy_addShipsAt('supercobratraderminerhunter', 1, 'spu', [0, 0, 0.9]);
system.legacy_addShipsAt('militarysupercobra', 1, 'spu', [0, 0, 0.75]);
system.legacy_addShipsAt('piratesupercobra', 1, 'pwu', [0, 0, 0.4]);
};
this.addIxianShips = function () {
if (system.government >= FEUDAL) {
if (system.population < 30 && Math.random() < 0.20) {
system.legacy_addShipsAt('ixian_ship', 1, 'pwu', [0, 0, 0.75]);
}
if (system.population < 25 && Math.random() < 0.50) {
system.legacy_addShipsAt('ixian_ship', 1, 'pwu', [0, 0, 0.45]);
}
}
};
this.addHardPirateShips = function () {
// Add a base level of pirate ships
if (system.government === ANARCHY) {
if (Math.random() < 0.30) {
system.legacy_addSystemShips('hardpirate', 4, 0.1);
}
if (Math.random() < 0.20) {
system.legacy_addSystemShips('hardpirate', 2, 0.4);
}
if (Math.random() < 0.10) {
system.legacy_addSystemShips('hardpirate', 6, 0.6);
}
if (Math.random() < 0.05) {
system.legacy_addSystemShips('hardpirate', 4, 0.8);
}
if (Math.random() < 0.04) {
system.legacy_addSystemShips('hardpirate', 4, 0.9);
}
}
if (system.government === FEUDAL) {
if (Math.random() < 0.25) {
system.legacy_addSystemShips('hardpirate', 2, 0.2);
}
if (Math.random() < 0.15) {
system.legacy_addSystemShips('hardpirate', 2, 0.1);
}
if (Math.random() < 0.10) {
system.legacy_addSystemShips('hardpirate', 4, 0.5);
}
if (Math.random() < 0.05) {
system.legacy_addSystemShips('hardpirate', 2, 0.8);
}
if (Math.random() < 0.03) {
system.legacy_addSystemShips('hardpirate', 4, 0.9);
}
}
if (system.government >= MULTIGOVERNMENT && system.government <= CONFEDERACY) {
if (Math.random() < 0.10) {
system.legacy_addSystemShips('hardpirate', 2, 0.1);
}
if (Math.random() < 0.08) {
system.legacy_addSystemShips('hardpirate', 4, 0.4);
}
if (Math.random() < 0.06) {
system.legacy_addSystemShips('hardpirate', 2, 0.3);
}
}
if (system.government === DEMOCRACY) {
if (Math.random() < 0.10) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.45, 0], 10000);
}
if (Math.random() < 0.05) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.30, 0], 10000);
}
if (Math.random() < 0.03) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.90, 0], 10000);
}
}
if (system.government === CORPORATESTATE) {
if (Math.random() < 0.05) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.55, 0], 10000);
}
if (Math.random() < 0.03) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.75, 0], 10000);
}
}
// Add additional pirate ships
if (system.government === ANARCHY && Math.random() < 0.30) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.3, 0], 10000);
}
if (system.government <= FEUDAL && Math.random() < 0.20) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.45, 0], 10000);
}
if (system.government <= MULTIGOVERNMENT && Math.random() < 0.10) {
system.legacy_addShipsWithinRadius('hardpirate', 4, 'swu', [0, 0.65, 0], 10000);
}
if (system.government <= COMMUNIST && Math.random() < 0.05) {
system.legacy_addShipsWithinRadius('hardpirate', 2, 'swu', [0, 0.75, 0], 10000);
}
if (system.government <= CONFEDERACY && Math.random() < 0.03) {
system.legacy_addShipsWithinRadius('hardpirate', 4, 'swu', [0, 0.85, 0], 10000);
}
if (system.government >= DEMOCRACY && Math.random() < 0.04) {
system.legacy_addSystemShips('hardpirate', 2, 0.5);
}
if (system.government >= DEMOCRACY && Math.random() < 0.03) {
system.legacy_addSystemShips('hardpirate', 4, 0.3);
}
};
this.addFreeTradeZone = function () {
if (system.government === MULTIGOVERNMENT) {
system.legacy_addShipsAt('free_trade_zone', 1, 'wpu', [0, 0, -0.3]);
system.legacy_addShipsAtPrecisely('ftzpirate', 2, 'wpu', [0, 0, -0.25]);
this.freetradezone_marked = false;
if (Math.random() < 0.25) {
system.legacy_addShipsAtPrecisely('pirate', 2, 'wpu', [0, 0, -0.25]);
}
if (Math.random() < 0.70) {
system.legacy_addShipsAtPrecisely('ftzpirate', 2, 'wpu', [0, 0, -0.2]);
}
if (Math.random() < 0.30) {
system.legacy_addShipsAtPrecisely('ftzpirate', 4, 'wpu', [0, 0, -0.15]);
}
if (Math.random() < 0.50) {
system.legacy_addShipsWithinRadius('ftzhauler', 1, 'wpu', [0, 0, -0.2], 5000);
}
if (Math.random() < 0.25) {
system.legacy_addShipsWithinRadius('ftzhauler', 1, 'wpu', [0, 0, -0.25], 5000);
}
if (Math.random() < 0.10) {
system.legacy_addShipsWithinRadius('police', 6, 'wpu', [0, 0, -0.3], 5000);
}
}
};
this.freeTradeZoneDocking = function (station) {
if (station.name === 'Free Trade Zone') {
if (this.freetradezone_marked !== true) {
player.bounty += 5;
this.freetradezone_marked = true;
}
}
};
this.addPirateCove = function () {
if (system.countShipsWithPrimaryRole('pirate') >= 10 && system.countShipsWithPrimaryRole('pirate-cove') === 0) {
system.legacy_addSystemShips('pirate-cove', 1, 0.12);
system.legacy_addSystemShips('asteroid', 8, 0.12);
}
};
this.pimpMySystem = function () {
system.legacy_addShipsAt('uber', 1, 'spu', [0, 0, 0.9]);
system.legacy_addShipsAt('uber', 1, 'wpu', [0, 0, 0.5]);
system.legacy_addShipsAt('uber', 1, 'wsu', [0, 0, 0.5]);
};
One known problem is in the included file "frame_fuel_collector.js" in the scripts subfolder. Somehow that code did work with previous oolite versions, but newer ones now do crashmatthewfarmery wrote:Im getting radom crashing with OSE, with RS, or Oolite by itself, the game doesn't crash, but with OSE, it crashing a lot, and random, docking at a station or dog fighting, or being near a battle zone
Code: Select all
if(this.theplayer.position.distanceTo(pl_target) < 301)
{
log("Fuel Collector", "distance below 301")
let isRunning = false
if(this.DerelictCheckTimer)
{
log("Fuel Collector", "this.DerelictCheckTimer is " + this.DerelictCheckTimer)
if(this.DerelictCheckTimer.isRunning)
isRunning = true
}
If it still crashes, try to disable OSE-XML.plist by adding .disabled next.matthewfarmery wrote:Hi I will test out the frame_fuel_collector.js fix you have said, as for OS, windows 7 64bit and windows XP 32bit, I tried the latter first then I thought I would try it in 7 and got the same thing, but will try the fix and let you know the outcome, haven't tried any of the trunk builds, only 1.73.4 and OSE from the link from the first page in Lestradae post, anyway going to try the fix and report back if it works or not
Code: Select all
this.name = "rmb-law-missile-script";
this.author = "Ramirez";
this.copyright = "January 2009";
this.description = "Prevents an Orange Tear lawmaker missile from being used against stations and other stationary objects";
this.version = "1.0";
this.checkTargetVulnerability = function()
{
if(!this.ship.target || (this.ship.target.isStation && this.ship.target.maxSpeed == 0) || this.ship.target.scanClass == "CLASS_ROCK") return
if(this.ship.target.isPlayer) return
if(this.ship.target.AI == "rmb-stunnedAI.plist") {
log("RMB-LAW-MISSILE-SCRIPT.JS","Target already stunned, aborting.");
} else {
log("RMB-LAW-MISSILE-SCRIPT.JS","Stunning target.");
this.ship.target.setAI("rmb-stunnedAI.plist")
}
}
Code: Select all
this.name = "rmb-override-missile-script";
this.author = "Ramirez";
this.copyright = "January 2009";
this.description = "Prevents a Violet Flax override missile from being effective against stations and other stationary objects. If player is the target, a random piece of equipment is damaged";
this.version = "2.0";
this.damageSystems = function()
{
if(!this.ship.target || (this.ship.target.isStation && this.ship.target.maxSpeed == 0) || this.ship.target.scanClass == "CLASS_ROCK") return
if(this.ship.target.isPlayer)
{
var list = ["EQ_ADVANCED_COMPASS", "EQ_DOCK_COMP", "EQ_ECM", "EQ_FUEL_INJECTION", "EQ_TARGET_MEMORY", "EQ_SCANNER_SHOW_MISSILE_TARGET"]
let equipment = list[Math.floor(Math.random() * list.length)]
if(player.ship.hasEquipment(equipment))
{
player.ship.setEquipmentStatus(equipment, "EQUIPMENT_DAMAGED")
player.commsMessage("Warning: Missile detonation caused failure of " + EquipmentInfo.infoForKey(equipment).name, 5)
this.ship.reactToAIMessage("DETONATE");
}
}
else
{
if(this.ship.target.AI == "rmb-overrideAI.plist") {
log("RMB-OVERRIDE-MISSILE-SCRIPT.JS","Target already affected, aborting.");
} else {
log("RMB-OVERRIDE-MISSILE-SCRIPT.JS","Overriding target.");
this.ship.target.setAI("rmb-overrideAI.plist")
}
}
}
Code: Select all
if(this.theplayer.position.distanceTo(pl_target) < 301)
{
log("Fuel Collector", "distance below 301")
let isRunning = false
if(this.DerelictCheckTimer)
{
log("Fuel Collector", "this.DerelictCheckTimer is " + this.DerelictCheckTimer)
if(this.DerelictCheckTimer.isRunning)
isRunning = true
}
Code: Select all
this.trapship.switchAI("dumbAI.plist")