Path |
Scripts/cargoWreckBarrel.js |
"use strict";
this.name = "cargoWreckBarrel";
this.author = "Arexack Heretic (oxp) & Eric Walch (js script)";
this.copyright = "Share alike";
this.description = "Code for a generic pod";
this.version = "1.7.2";
/*
"this.shipSpawned" is in rare occasions skipped in Oolite 1.73 or older, because in some occasions
the splinter is scooped before the this.shipSpawned is triggered. (This could for example happen when
the player rams the target to death and barrels fly directly into the scoop.
But, once scooped, "this.shipSpawned" will never trigger again! (fixed in Oolite 1.74)
Initialising on scooping now, to also have less code to execute during the explosion itself.
*/
this.initialise = function ()
{
this.message = this.ship.scriptInfo.message;
this.cargotype = this.ship.scriptInfo.cargotype;
this.quantity = parseInt(this.ship.scriptInfo.quantity);
// use parseInt for open step plists or you will be awarding wrong quantities.
if (isNaN(this.quantity)) {this.quantity = 1; log(this.name, "Detected a NaN quantity for: "+this.cargotype)};
if (this.quantity < 0) this.quantity = Math.ceil(Math.random()*(-this.quantity));
if (this.quantity > 1) this.message = this.message.replace("gram ", "grams ");
if (this.quantity > 0 && this.cargotype) this.ship.setCargo(this.cargotype, this.quantity);
this.message = this.quantity + " " + expandDescription(this.message);
this.init = true;
};
this.shipWasScooped = function (scooper)
{
if (!this.init) this.initialise();
if (scooper.isPlayer)
{
player.consoleMessage(this.message);
}
};
|
Scripts/cargoWreckFuel.js |
"use strict";
this.name = "cargoWreckFuel";
this.author = "Arexack Heretic (oxp) & Eric Walch (js script)";
this.copyright = "Share alike";
this.description = "fuel pod";
this.version = "1.7";
this.shipDied = function ()
{
delete this.shipDied;
this.ship.AIState = "EXPLODE"; // make sure the ship explodes with doing damage, even when collided or shot at.
}
this.shipWasScooped = function (scooper)
{
var hasFuel = this.ship.scriptInfo.awardFuel;
if (hasFuel === "NO") hasFuel = false; // test needed in case the code is in open-step plist. "NO" is interpreted as true by js.
if (scooper.isPlayer)
{
if (hasFuel)
{
if(player.ship.fuel <= 6)
{
player.ship.fuel += 1;
player.consoleMessage("1.0 LY Fuel Transfered!");
}
else
{
var fuel = Math.round(70 - player.ship.fuel*10)/10;
player.consoleMessage(fuel+" LY Fuel Transfered!");
player.ship.fuel += fuel;
}
}
else
{
player.ship.fuel += 1;
player.consoleMessage("FuelPod Failure!");
player.ship.fuelLeakRate = 2.5;
}
}
else // NPC ship scooped pod
{
if (hasFuel)
{
scooper.fuel += 1;
}
else
{
// scooper becomes a q-bomb when scooping up a bad fuelpod.
scooper.commsMessage(expandDescription("[ah_last-words]"));
scooper.switchAI("explosiveCWreckAI.plist");
scooper.AIState = "DETONATE";
}
}
}
|
Scripts/cargoWreckMissile.js |
"use strict";
this.name = "cargoWreckMissile";
this.author = "Arexack Heretic (oxp) & Eric Walch (js script)";
this.copyright = "Share alike";
this.description = "firearms pod";
this.version = "1.7";
this.shipWasScooped = function (scooper)
{
if (scooper.missiles.length < scooper.missileCapacity)
{
var missile = Math.random()>0.1 ? "EQ_MISSILE" : "EQ_HARDENED_MISSILE";
scooper.awardEquipment(missile);
this.ship.displayName = "A free missile";
}
else
{
// no check for free storage as scooping success already means there was 1 ton of free cargo space.
this.ship.setCargo("firearms");
}
delete this.shipWasScooped; // we don't want to run this script again when it is scooped a second time.
}
this.shipDied = function ()
{
delete this.shipDied; // prefent recursion.
this.ship.switchAI("missileAI.plist");
this.ship.AIState = "DETONATE";
} |
Scripts/cargoWreckTeaser.js |
/*
cargoWreckTeaser
Copyright © 2006-2009 Arexack Heretic and contributors
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
For a copy of the GNU General Public License write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
"use strict";
this.name = "Cargo_Wreck_Teaser";
this.author = "Arexack Heretic (oxp) & Eric Walch (js script)";
this.copyright = "Share alike";
this.description = "WorldScript for cargo_wreck_teaser";
this.version = "1.7.1";
this.shipExitedWitchspace = function ()
{
if(!system.isInterstellarSpace && system.government < 4 && Math.random() < 0.15 && system.countShipsWithPrimaryRole("rockhermit") > 1)
{
this.addPirateStash();
}
}
this.addPirateStash = function ()
{
/*
Just transform a plain asteroid into a stash. This avoids the problem of the treasuroid
being completely different than other asteroids when asteroid replacing oxps are used.
*/
var stash = system.addGroupToRoute("asteroid", 9).ships[0];
stash.displayName = "Treasuroid";
stash.setScript("cargoWreckTreasuroid.js");
} |
Scripts/cargoWreckTreasuroid.js |
"use strict";
this.name = "cargoWreckTreasuroid";
this.author = "Arexack Heretic (oxp) & Eric Walch (js script)";
this.copyright = "Share alike";
this.description = "Treasuroid asteroid";
this.version = "1.7";
// this script is attached to a selected asteroid by the worldScript.
this.shipDied = function ()
{
var stashGroup = new ShipGroup("Treasuroid Group");
var asteroids = this.ship.group.ships;
for (var i = 0; i<asteroids.length; i++)
{
var pirate = asteroids[i].spawnOne("pirate");
stashGroup.addShip(pirate);
pirate.group = stashGroup;
if (asteroids[i] == this.ship)
{
pirate.commsMessage(expandDescription("[ah_stash-message]"));
}
else
{
asteroids[i].explode(true);
}
}
delete this.shipDied;
} |
Scripts/cargoWreckTrumble.js |
"use strict";
this.name = "cargoWreckTrumble";
this.author = "Arexack Heretic (oxp) & Eric Walch (js script)";
this.copyright = "Share alike";
this.description = "trumble pod";
this.version = "1.7.2";
this.shipWasScooped = function (scooper)
{
if (!this.message) this.message = expandDescription("1 ton [ah_trumble-furs]")
if (scooper.isPlayer)
{
// only give player trumbles when he already did the trumblemission in the past.
if (missionVariables.trumbles === "TRUMBLE_BOUGHT" && (Math.random() < 0.25 || player.trumbleCount > 0))
{
if (player.trumbleCount === 0)
{
scooper.awardEquipment("EQ_TRUMBLE");
player.consoleMessage(this.message);
}
else
{
if (player.trumbleCount === 1) player.consoleMessage("Your trumble is exited about a scooped friend.", 6);
else player.consoleMessage("Your trumbles are exited about a scooped mate.", 6);
}
}
else
{
player.consoleMessage(this.message);
this.ship.setCargo("furs");
}
}
else // scooped by npc
{
this.ship.setCargo("furs");
}
//delete this.shipWasScooped;
} |