| Scripts/quirium-bomb-equipment.js |
"use strict";
this.author = "phkb";
this.copyright = "2025 phkb";
this.licence = "CC-BY-NC-SA 3.0";
this.name = "quirium-bomb-equipment";
this.activated = function () {
if (!player.ship.weaponsOnline) {
return;
}
if (oolite.compareVersion("1.91") > 0) {
var m = player.ship.missiles;
var removed = "";
if (m.length == player.ship.missileCapacity) {
// make a note of the last item in the missile Array
removed = m[m.length - 1].equipmentKey;
player.ship.removeEquipment(removed);
}
player.ship.awardEquipment("EQ_QC_MINE");
// you need a target in order to fire a missile
var tgt = player.ship.target;
var useTemp = false;
if (!tgt) {
useTemp = true;
var temp = system.addShips("[qc_dummy_target]", 1, player.ship.position.add(player.ship.vectorUp.multiply(300)))[0];
player.ship.target = temp;
}
var qc = player.ship.fireMissile("EQ_QC_MINE");
if (removed != "") player.ship.awardEquipment(removed) // put back the missile we removed
// make the mine stop, otherwise it will shoot off like a missile
qc.velocity = [0, 0, 0];
qc.thrust = 0;
qc.maxSpeed = 0;
if (useTemp) temp.remove(true);
} else {
var qc = player.ship.spawn("EQ_QC_MINE")[0];
}
qc.AIScript.shipWasDumped();
player.ship.removeEquipment("EQ_QC_BOMB_ITEM");
player.consoleMessage(expandDescription("[energy-bomb-activated]"), 4.5);
var sound = new SoundSource;
sound.sound = "[energy-bomb-fired]";
sound.play();
}
this.allowAwardEquipment = function(equipment, ship, context) {
if (context == "scripted") return true;
if (oolite.compareVersion("1.91") > 0) {
// if we're in v1.90, and we don't have any missile capacity, we can't use this equipment
if (player.ship.missileCapacity == 0) return false;
}
return true;
} |