Path |
Scripts/CT_launcher.js |
"use strict";
this.name = "CT_Launcher";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Spawn Captured Thargons";
this.version = "1.00";
this.shipDied = function () {
if (missionVariables.CT_thargonCount > 0) {
player.consoleMessage("Robot fighters activated", 5);
this.ship.spawn("CT_thargon", missionVariables.CT_thargonCount);
}
delete this.shipDied;
} |
Scripts/CT_masterScript.js |
"use strict";
this.name = "CT_Script";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Captured Thargons - for 1.74+";
this.version = "2.01";
this.startUp = function () {
if (missionVariables.CT_thargonCount == null) {
missionVariables.CT_thargonCount = 0;
}
if (missionVariables.CT_thargonCargo == null) {
missionVariables.CT_thargonCargo = manifest.alien_items;
}
}
this.guiScreenChanged = function (to, from) {
if (to == "GUI_SCREEN_EQUIP_SHIP") {
missionVariables.CT_thargonCargo = manifest.alien_items;
}
}
this.playerBoughtEquipment = function (equipment) {
switch (equipment) {
case "EQ_CT_MINE":
{
missionVariables.CT_thargonCount = 5;
mission.runScreen({
title: "Captured Thargon Purchase",
messageKey: "CT_instructions",
model: "CT_thargon"
});
break;
}
case "EQ_MISSILE_REMOVAL":
{
if (missionVariables.CT_thargonCount > 0) { // Player gets 5000 back for the removal, but if <5 drones left deduct 1000 per drone
player.credits -= (1000 * (5 - missionVariables.CT_thargonCount));
missionVariables.CT_thargonCount = 0;
}
break;
}
case "EQ_CT_DRONE_1":
{
missionVariables.CT_thargonCount += 1;
player.ship.removeEquipment("EQ_CT_DRONE_1");
break;
}
case "EQ_CT_DRONE_2":
{
missionVariables.CT_thargonCount += 2;
player.ship.removeEquipment("EQ_CT_DRONE_2");
break;
}
case "EQ_CT_DRONE_3":
{
missionVariables.CT_thargonCount += 3;
player.ship.removeEquipment("EQ_CT_DRONE_3");
break;
}
case "EQ_CT_DRONE_4":
{
missionVariables.CT_thargonCount += 4;
player.ship.removeEquipment("EQ_CT_DRONE_4");
break;
}
case "EQ_CT_CONVERT":
{
if (manifest.alien_items > 0) {
manifest.alien_items--;
missionVariables.CT_thargonCount++;
missionVariables.CT_thargonCargo = manifest.alien_items;
player.ship.removeEquipment("EQ_CT_CONVERT");
}
break;
}
}
if (missionVariables.CT_thargonCount > 5) {
missionVariables.CT_thargonCount = 5;
}
} |
Scripts/CT_thargon.js |
"use strict";
this.name = "CT_thargon";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "AI-actions script for the captured thargon";
this.version = "2.0";
this.shipSpawned = function () {
missionVariables.CT_thargonCount -= 1;
}
this.shipWasScooped = function (scooper) {
if (scooper.isPlayer) {
missionVariables.CT_thargonCount += 1;
if (missionVariables.CT_thargonCount == 1) {
player.ship.awardEquipment("EQ_CT_MINE");
}
}
}
this.locatePlayer = function () {
this.playerArray = system.shipsWithPrimaryRole("player");
if (this.playerArray.length == 0) // where'd they go?
{
this.ship.remove(); // If no player, then we can remove the thargon.
} else {
this.ship.target = this.playerArray[0];
this.ship.reactToAIMessage("PLAYER_FOUND");
}
}
this.findPlayerHostiles = function () {
function isHostileToPlayer(entity) {
return (entity.isThargoid || (entity.isShip && entity.target && entity.target == player.ship && entity.hasHostileTarget));
}
if (this.ship.target == player.ship && player.ship.target && player.ship.target.bounty > 10) {
this.ship.target = player.ship.target;
this.ship.reactToAIMessage("HOSTILE_FOUND");
} else {
var targets = system.filteredEntities(this, isHostileToPlayer, this.ship, this.ship.scannerRange);
if (targets.length > 0) {
this.ship.target = targets[0];
this.ship.reactToAIMessage("HOSTILE_FOUND");
} else {
this.ship.reactToAIMessage("NO_HOSTILE_FOUND");
}
}
}
this.fireCheck = function () {
if ((this.ship.target.hasRole("CT_thargon")) || (player.ship.target == this.ship && this.ship.target.isPlayer)) {
this.ship.reactToAIMessage("FRIENDLY_FIRE");
} else {
this.ship.reactToAIMessage("ENEMY_FIRE");
}
}
this.shipTargetDestroyed = function (target) {
player.score += 1;
player.credits += target.bounty;
player.consoleMessage("Thargon kill - " + target.name + " : " + target.bounty + "₢ awarded.", 5);
log("Thargon kill - " + target.name + " : " + target.bounty);
if (target.primaryRole == "constrictor" && missionVariables.conhunt && missionVariables.conhunt == "STAGE_1") { // just in case a thargon kills the constrictor, let's not break the mission for the player...
missionVariables.conhunt = "CONSTRICTOR_DESTROYED";
}
}
this.shipDied = function (whom, why) {
if (whom && whom.isValid) {
player.consoleMessage("Contact lost with Thargon fighter", 5);
}
} |
Scripts/ams_activate.js |
"use strict";
this.name = "ams_activate.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script for manual activation of the anti-missile system";
this.version = "1.00";
this.activated = function () {
if (player.ship.equipmentStatus("EQ_AMS") !== "EQUIPMENT_OK") {
missionVariables.amActive = "INACTIVE";
return;
}
if (!worldScripts["ams_system"]) {
player.consoleMessage("AMS script error.");
log(this.name, "AMS script activation failed.");
return;
}
if (missionVariables.amActive && missionVariables.amActive === "ACTIVE") {
missionVariables.amActive = "INACTIVE";
player.consoleMessage("Anti-Missile System deactivated.");
} else {
missionVariables.amActive = "ACTIVE";
player.consoleMessage("Anti-Missile System activated.");
worldScripts["ams_system"].$scanForMissiles();
}
} |
Scripts/ams_dart.js |
"use strict";
this.name = "ams_dart";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Needle-dart interception script.";
this.version = "1.01";
this.shipIntercept = function () {
let chance = Math.random();
if (chance > 0.9) {
player.consoleMessage("AMS - Interception failed.", 6);
} else {
if (this.ship && this.ship.target) {
this.ship.target.explode();
}
}
} |
Scripts/ams_system.js |
"use strict";
this.name = "ams_system";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Needle-dart anti-missile system extension of the Missile Analyser, good for 6 uses before replacement.";
this.version = "2.12";
this.startUp = function () {
if (missionVariables.amCount === undefined || missionVariables.amCount === null) {
this.amCount = 6;
} else {
this.amCount = missionVariables.amCount;
}
if (missionVariables.amActive === undefined || missionVariables.amActive === null) {
missionVariables.amActive = "INACTIVE";
}
}
this.shipLaunchedFromStation = function () {
if (player.ship.equipmentStatus("EQ_AMS") === "EQUIPMENT_OK" && player.ship.equipmentStatus("EQ_MISSILE_ANALYSER") === "EQUIPMENT_OK") {
missionVariables.amActive = "ACTIVE";
switch (this.amCount) {
case 0:
{
player.consoleMessage("AMS - System offline, no darts loaded.", 5);
break;
}
case 1:
{
player.consoleMessage("AMS - System online, 1 dart loaded.", 5);
break;
}
default:
{
player.consoleMessage("AMS - System online, " + this.amCount + " darts loaded.", 5);
break;
}
}
}
}
this.$scanForMissiles = function () {
function missileArray(entity) {
return entity.isShip && entity.isMissile && entity.target && entity.target === player.ship;
};
let incomingMissiles = system.filteredEntities(this, missileArray, player.ship, 25600);
if (incomingMissiles.length > 0) {
this.shipAttackedWithMissile(incomingMissiles[0], null);
}
}
this.shipAttackedWithMissile = function (missile, whom) {
if (player.ship.equipmentStatus("EQ_AMS") === "EQUIPMENT_OK" && player.ship.equipmentStatus("EQ_MISSILE_ANALYSER") === "EQUIPMENT_OK" && missionVariables.amActive === "ACTIVE" && missile.name !== "Missile" && this.amCount > 0) {
player.consoleMessage("AMS - Dart " + (7 - this.amCount) + " launched.", 6);
let antiMissile = player.ship.spawnOne("ams_dart");
antiMissile.target = missile;
let amOrientation = player.ship.orientation;
let offsetVector = amOrientation.vectorUp(); // vector at right angles to the player, downwards
let spawnOffset = offsetVector.multiply(20); // set the offset to 20m downwards (for larger ships, increase 20).
antiMissile.orientation = amOrientation; // point the dart in the same direction as the player
antiMissile.position = player.ship.position.subtract(spawnOffset); // move the dart to it's correct start point.
if (--this.amCount < 1) {
player.consoleMessage("AMS - system exhausted, shutting down", 8);
}
missionVariables.amCount = this.amCount;
}
}
this.playerBoughtEquipment = function (equipment) {
switch (equipment) {
case "EQ_AMS":
{
missionVariables.amActive = "ACTIVE";
this.amCount = 6;
break;
}
case "EQ_AMS_1":
{
this.amCount += 1;
player.ship.removeEquipment("EQ_AMS_1");
break;
}
case "EQ_AMS_2":
{
this.amCount += 2;
player.ship.removeEquipment("EQ_AMS_2");
break;
}
case "EQ_AMS_3":
{
this.amCount += 3;
player.ship.removeEquipment("EQ_AMS_3");
break;
}
case "EQ_AMS_4":
{
this.amCount += 4;
player.ship.removeEquipment("EQ_AMS_4");
break;
}
case "EQ_AMS_5":
{
this.amCount += 5;
player.ship.removeEquipment("EQ_AMS_5");
break;
}
case "EQ_AMS_6":
{
this.amCount += 6;
player.ship.removeEquipment("EQ_AMS_6");
break;
}
case "EQ_AMS_REMOVAL":
{
player.ship.removeEquipment("EQ_AMS");
player.ship.removeEquipment("EQ_AMS_REMOVAL");
player.credits += (5000 + (this.amCount * 400));
this.amCount = 0;
delete missionVariables.amCount;
delete missionVariables.amActive;
break;
}
}
missionVariables.amCount = this.amCount;
} |
Scripts/armoury_conditions.js |
"use strict";
this.name = "Armoury_Conditions";
this.author = "phkb";
this.copyright = "2023 phkb";
this.description = "Condition script for equipment.";
this.licence = "CC BY-NC-SA 3.0";
this.allowAwardEquipment = function(equipment, ship, context) {
if (context === "scripted") return true;
switch (equipment) {
case "EQ_ARMOURY_CUTPURSE_MISSILE":
if (system.government < 2 && Math.random() < 0.5) return true;
break;
case "EQ_ARMOURY_INTERDICTOR_MINE":
if (system.government < 2 && Math.random() < 0.25) return true;
break;
case "EQ_CT_MINE":
if (missionVariables.CT_thargonCount == 0) return true;
break;
case "EQ_CT_DRONE_1":
if (missionVariables.CT_thargonCount == 4) return true;
break;
case "EQ_CT_DRONE_2":
if (missionVariables.CT_thargonCount == 3) return true;
break;
case "EQ_CT_DRONE_3":
if (missionVariables.CT_thargonCount == 2) return true;
break;
case "EQ_CT_DRONE_4":
if (missionVariables.CT_thargonCount == 1) return true;
break;
case "EQ_CT_CONVERT":
if (missionVariables.CT_thargonCount < 5 && missionVariables.CT_thargonCargo > 0) return true;
break;
case "EQ_AMS_1":
if (missionVariables.amCount == 5) return true;
break;
case "EQ_AMS_2":
if (missionVariables.amCount == 4) return true;
break;
case "EQ_AMS_3":
if (missionVariables.amCount == 3) return true;
break;
case "EQ_AMS_4":
if (missionVariables.amCount == 2) return true;
break;
case "EQ_AMS_5":
if (missionVariables.amCount == 1) return true;
break;
case "EQ_AMS_6":
if (missionVariables.amCount == 0) return true;
break;
}
return false;
} |
Scripts/armoury_cutpurseMissile.js |
"use strict";
this.name = "armoury_cutpurseMissile.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Ship script for the cutpurse missile";
this.version = "1.00";
this.performSteal = function () {
if (!this.ship.target || !this.ship.target.isValid || this.ship.target.isCargo || this.ship.target.isWeapon || this.ship.target.isRock || this.ship.target.isThargoid) {
return;
}
this.ship.target.script.$armoury_cpTimer = this.$armoury_cpTimer;
this.ship.target.script.$armoury_cpAction = this.$armoury_cpAction;
if (this.ship.target.isPlayer) {
this.ship.target.script.$armoury_cpPlayerDump = this.$armoury_cpPlayerDump;
}
this.ship.target.script.$armoury_cpTimer();
}
this.$armoury_cpTimer = function () {
if (this.$armoury_dumpTimer) {
return;
}
this.$timerDelay = Math.random() * 10;
this.$armoury_dumpTimer = new Timer(this, this.$armoury_cpAction, this.$timerDelay);
}
this.$armoury_cpAction = function () {
if (this.ship.isPlayer) {
player.consoleMessage("Emergency cargo dump triggered", 4);
this.$armoury_playerTimer = new Timer(this, this.$armoury_cpPlayerDump, 0, 0.51);
} else {
this.ship.setAI("armoury_ejectCargoAI.plist");
}
}
this.$armoury_cpPlayerDump = function () {
if (player.ship.cargoSpaceUsed === 0 || Math.random() < 0.1) {
this.$armoury_playerTimer.stop();
delete this.$armoury_dumpTimer;
delete this.$armoury_playerTimer;
delete this.$armoury_cpTimer;
delete this.$armoury_cpAction;
return;
} else {
player.ship.dumpCargo();
}
} |
Scripts/armoury_decoyMine.js |
"use strict";
this.name = "armoury_decoyMine.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Ship script for the decoy mine";
this.version = "1.00";
this.deployDecoys = function () {
this.decoyCount = Math.ceil((0.00001 + Math.random()) * 4);
this.decoyList = system.addShips("armoury_wftDecoy", this.decoyCount, this.ship.position, 500);
} |
Scripts/armoury_displacerMissile.js |
"use strict";
this.name = "armoury_displacerMissile.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Ship script for the displacer missile";
this.version = "1.00";
this.removeSelf = function () {
this.ship.remove();
}
this.performDisplace = function () {
if (!this.ship.target || !this.ship.target.isShip || !this.ship.target.isValid || this.ship.target.isCargo || this.ship.target.fuel == 0) { // displacement only for ships with fuel
this.ship.remove();
return;
}
this.ship.target.fuel *= Math.random(); // drain off some fuel to simulate the jump
if (this.ship.target.target) { // remove the displaced ship's target, if it has one
this.ship.target.target = null;
}
this.xDistance = ((Math.random() * 2) - 1) * 1024000;
this.yDistance = ((Math.random() * 2) - 1) * 1024000;
this.zDistance = ((Math.random() * 2) - 1) * 1024000;
this.ship.target.position = this.ship.target.position.add([this.xDistance, this.yDistance, this.zDistance]);
if (this.ship.target.isPlayer) {
player.consoleMessage("EMERGENCY - position changed by displacement weapon - compensating", 6);
}
this.ship.remove();
} |
Scripts/armoury_fieldMine.js |
"use strict";
this.name = "armoury_fieldMine.js";
this.author = "Thargoid";
this.copyright = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses - see readme.txt.";
this.description = "Ship script for field missile's mine.";
this.version = "1.0";
this.shipSpawned = function () {
// create an array with all possible target ships ("isShip" includes barrels and rock etc.)
this.fieldTimer = new Timer(this, this.findPrey, 0, 1);
}
this.findPrey = function () {
function targetShips(entity) {
return (entity.isShip && !entity.hasRole("armoury_fieldMissile") && !entity.hasRole("armoury_fieldMine"))
};
let prey = system.filteredEntities(this, targetShips, this.ship, 500);
if (prey.length > 0) {
this.stopTimer();
this.ship.AIState = "BANG";
}
}
this.stopTimer = function () {
if (this.fieldTimer && this.fieldTimer.isRunning) {
this.fieldTimer.stop();
delete this.fieldTimer;
}
} |
Scripts/armoury_fieldMissile.js |
"use strict";
this.name = "armoury_fieldMissile.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Ship script for the field missile";
this.version = "1.00";
this.dropMines = function () {
if (!this.ship.target || !this.ship.target.isValid) // if the missile doesn't have a proper target to spawn mines around
{
this.scatterMines();
return;
}
this.mineCount = Math.ceil(Math.random() * 11) + 19; // 20-30 mines to be thrown around target position (250m radius).
system.legacy_addShipsWithinRadius("armoury_fieldMine", this.mineCount, "abs", this.ship.target.position, 250);
}
this.scatterMines = function () {
this.mineCount = Math.ceil(Math.random() * 11) + 19; // 20-30 mines to be thrown around missile position (250m radius).
system.legacy_addShipsWithinRadius("armoury_fieldMine", this.mineCount, "abs", this.ship.position, 250);
} |
Scripts/armoury_generalScript.js |
"use strict";
this.name = "armoury_generalScript.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Ship script for Armoury OXP";
this.version = "1.11";
// functions for various bombs supplied in the OXP
this.detonate = function () {
if (!this.ship.owner.isValid) {
this.ship.explode();
return;
}
this.bomber = this.ship.owner;
this.totalBounty = 0;
this.energyAvailable = 64; // bombs own single energy bank.
this.bomberEnergy = this.bomber.energy - 64; // max energy possible to put into EMP broadcast (leave bomber at least 1 energy bank)
if (this.bomberEnergy > 0) {
this.energyTransfer = 0.25 + (Math.random() * 0.75); // between 25% and 100% transfer of available energy
this.energyDeduction = (this.bomberEnergy * this.energyTransfer); // how much energy we're going to transfer to the blast.
this.bomber.energy -= this.energyDeduction; // drain the bomber's energy banks accordingly
this.energyAvailable += this.energyDeduction; // add the bomber energy to the bomb's own energy bank
}
switch (this.ship.scriptInfo.bombType) // check which type of bomb has just gone off.
{
case "Bug bomb":
case "Buzz bomb":
{
this.generalBomb();
break;
}
case "Uni bomb":
case "Stun bomb":
{
this.effectBomb();
break;
}
}
}
this.tidyUp = function () {
if (this.totalBounty > 0 && this.bomber.isPlayer) {
player.consoleMessage("Total bomb bounty : " + this.totalBounty + " ₢.", 6);
player.credits += this.totalBounty;
}
if (!this.bomber.isPlayer && player.ship && this.bomber && this.bomber.position.distanceTo(player.ship.position) < 25600) {
player.consoleMessage(this.ship.scriptInfo.bombType + " detonation detected", 6);
}
this.ship.explode(); // get rid of the bomb entity
}
this.effectBomb = function () {
function isPowered(entity) {
return (entity.isShip && (this.ship.owner && entity != this.ship.owner) && (entity.isPlayer || (!entity.isMainStation && entity != this.bomber && entity.scanClass != "CLASS_CARGO" && entity.scanClass != "CLASS_ROCK"))); // ships who aren't cargo or rock.
}
var targetArray = system.filteredEntities(this, isPowered, this.ship, 25600);
if (targetArray.length > 0) {
var targetCounter = 0; // reset the counter
for (targetCounter = 0; targetCounter < targetArray.length; targetCounter++) {
this.distanceChance = 1 - ((this.ship.position.distanceTo(targetArray[targetCounter].position)) / 25600); // distance dependence
this.energyChance = this.energyAvailable / targetArray[targetCounter].energy; // energy dependence
if (Math.random() < (this.distanceChance * this.energyChance)) {
switch (this.ship.scriptInfo.bombType) // check which type of bomb has just gone off.
{
case "Uni bomb":
{
if (this.bomber.isPlayer) {
player.score += 1;
this.totalBounty += targetArray[targetCounter].bounty;
targetArray[targetCounter].explode();
} else {
if (targetArray[targetCounter].isPlayer) {
this.newEnergy = 32 + (Math.random() * 32);
if (player.ship.energy > this.newEnergy) {
player.ship.energy = this.newEnergy; // rather than nuking the player, set their energy very low
}
} else {
targetArray[targetCounter].explode();
}
}
break;
}
case "Stun bomb":
{
if (targetArray[targetCounter].isPlayer) {
player.ship.target = null;
this.newOrient = new Quaternion;
this.newOrient.w = (Math.random() * 2) - 1;
this.newOrient.x = (Math.random() * 2) - 1;
this.newOrient.y = (Math.random() * 2) - 1;
this.newOrient.z = (Math.random() * 2) - 1;
player.ship.orientation = this.newOrient; // as we can't stun the player, let's spin him about.
player.consoleMessage("Flight control restored.", 6);
} else {
targetArray[targetCounter].setAI("armoury_stunnedAI.plist");
}
break;
}
}
}
}
}
this.tidyUp();
}
this.generalBomb = function () {
function isPowered(entity) {
return (entity.isShip && entity != this.bomber && entity.scanClass != "CLASS_CARGO" && entity.scanClass != "CLASS_ROCK");
}
this.damageWeight = 0.5; // damage weighting reduction adjustable for gameplay
var targetArray = system.filteredEntities(this, isPowered, this.ship, 25600);
if (targetArray.length > 0) {
var targetCounter = 0; // reset the counter
for (targetCounter = 0; targetCounter < targetArray.length; targetCounter++) {
this.damageMultiplier = 1 - ((this.ship.position.distanceTo(targetArray[targetCounter].position)) / 25600); // distance dependence
this.damage = (this.energyAvailable * this.damageMultiplier);
if ((this.ship.scriptInfo.bombType) == "Bug bomb" && !targetArray[targetCounter].isThargoid) {
this.damage *= this.damageWeight;
}
if ((this.ship.scriptInfo.bombType) == "Buzz bomb" && targetArray[targetCounter].isThargoid) {
this.damage *= this.damageWeight;
}
if (this.damage > targetArray[targetCounter].energy) {
if (this.bomber.isPlayer) {
player.score += 1;
this.totalBounty += targetArray[targetCounter].bounty;
}
targetArray[targetCounter].explode();
} else {
targetArray[targetCounter].energy -= this.damage;
}
}
}
this.tidyUp();
} |
Scripts/armoury_interdictorMine.js |
"use strict";
this.name = "armoury_interdictorMine.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Ship script for the interdictor mine";
this.version = "1.13";
this.shipSpawned = function () {
this.ship.desiredSpeed = 0;
this.destructChance = -1;
this.messageFlag = "OFF";
this.autolockFlag = "NULL";
if (worldScripts["targetAutolock"] && missionVariables.targetAutolock === "TRUE") {
this.autolockFlag = "STOPPED";
missionVariables.targetAutolock = null;
}
this.policeArray = system.entitiesWithScanClass("CLASS_POLICE", this.ship, 25600)
if (this.policeArray.length > 0 && this.ship.owner && !this.ship.owner.isPolice) {
this.ship.owner.bounty += 20;
this.policeArray[0].reactToAIMessage("OFFENCE_COMMITTED");
}
this.interdictTimer = new Timer(this, this.performInterdict, 0, 0.5);
}
this.playerWillEnterWitchspace = this.shipDied = function () {
if (this.interdictTimer && this.interdictTimer.isRunning) {
this.interdictTimer.stop();
}
if (this.autolockFlag == "STOPPED") {
this.autolockFlag = "NULL";
missionVariables.targetAutolock = "TRUE";
}
}
this.performInterdict = function () {
if (!this.ship.isValid || !player.ship.isValid) {
this.shipDied();
return;
}
if (Math.random() < this.destructChance) // increasing chance that the mine's energy has run out and it self-destructs
{
this.ship.explode();
this.shipDied();
return;
} else {
this.destructChance += 0.01;
}
if (this.ship.position.distanceTo(player.ship.position) < 25600) {
if (this.messageFlag == "OFF") {
player.consoleMessage("Targetting system is being jammed by interdictor mine");
this.messageFlag = "ON";
}
} else {
this.messageFlag = "OFF";
if (this.autolockFlag == "STOPPED") {
this.autolockFlag = "NULL";
missionVariables.targetAutolock = "TRUE";
}
}
function isInterdictorTarget(entity) {
return (entity.isShip && entity.target && !entity.isThargoid && !entity.isPolice);
}
var targetArray = system.filteredEntities(this, isInterdictorTarget, this.ship, 25600)
if (targetArray.length > 0) {
var targetCounter = 0;
for (targetCounter = 0; targetCounter < targetArray.length; targetCounter++) {
if (!targetArray[targetCounter].isPlayer) {
targetArray[targetCounter].target = null;
} else {
player.ship.target = null;
this.messageFlag = "ON";
}
}
}
} |
Scripts/armoury_kickerMissile.js |
"use strict";
this.name = "armoury_kickerMissile.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Ship script for the kicker missile";
this.version = "1.00";
this.performKick = function () {
if (!this.ship.target || !this.ship.target.isValid) {
return;
}
this.ship.target.velocity = this.ship.target.velocity.add(this.ship.velocity.multiply(25 * (this.ship.mass / this.ship.target.mass)));
} |
Scripts/armoury_machineScript.js |
"use strict";
this.name = "armoury_machineScript.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "World script for Armoury OXP missile machine";
this.version = "1.00";
this.missileMachine = function () {
this.mountSound1 = new SoundSource;
this.mountSound1.sound = "armoury_missileMount1.ogg";
this.mountSound1.loop = false;
this.mountSound2 = new SoundSource;
this.mountSound2.sound = "armoury_missileMount2.ogg";
this.mountSound2.loop = false;
this.mountSound3 = new SoundSource;
this.mountSound3.sound = "armoury_missileMount3.ogg";
this.mountSound3.loop = false;
if (this.mmTimer && this.mmTimer.isRunning) {
player.consoleMessage("Missile machine already running - please wait", 6);
return;
}
if (player.ship.missiles.length == player.ship.missileCapacity) {
player.consoleMessage("No free missile pylons available - aborting", 6);
return;
}
if (player.ship.manifest["radioactives"] == 0 || player.ship.manifest["alloys"] == 0 || player.ship.fuel < 0.2) {
player.consoleMessage("Insufficient raw materials for manufacture - aborting", 6);
return;
}
player.ship.manifest["radioactives"] -= 1;
player.ship.manifest["alloys"] -= 1;
player.ship.fuel -= 0.1;
if (player.ship.manifest["computers"] > 0) {
missionVariables.armoury_MM = "EQ_ARMOURY_HARD_MISSILE";
player.ship.manifest["computers"] -= 1;
} else {
missionVariables.armoury_MM = "EQ_ARMOURY_STANDARD_MISSILE";
}
player.consoleMessage("Missile machine working - please wait", 6);
this.mmTimer = new Timer(this, this.awardWeapons, 60);
}
this.awardWeapons = function () {
this.mountCount = 0;
player.consoleMessage("Missile manufacture completed - mounting to pylons", 6);
this.canMount = player.ship.awardEquipment(missionVariables.armoury_MM);
if (this.canMount) {
this.mountCount++;
}
this.canMount = player.ship.awardEquipment(missionVariables.armoury_MM);
if (this.canMount) {
this.mountCount++;
}
this.canMount = player.ship.awardEquipment(missionVariables.armoury_MM);
if (this.canMount) {
this.mountCount++;
}
switch (this.mountCount) {
case 1:
{
this.mountSound1.play();
break;
}
case 2:
{
this.mountSound2.play();
break;
}
case 3:
{
this.mountSound3.play();
break;
}
}
}
this.shipWillDockWithStation = function () {
if (this.mmTimer && this.mmTimer.isRunning) {
this.mmTimer.stop();
this.awardWeapons();
}
}
this.shipDied = function () {
if (this.mmTimer && this.mmTimer.isRunning) {
this.mmTimer.stop();
}
} |
Scripts/armoury_missileMachine.js |
"use strict";
this.name = "armoury_missileMachine.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Ship script for missile machine";
this.version = "1.00";
this.startMachine = function () {
player.ship.awardEquipmentToCurrentPylon("EQ_ARMOURY_MISSILEMACHINE_MINE"); // put the HUD icon back
worldScripts["armoury_machineScript.js"].missileMachine();
this.ship.remove(); // get rid of the spawned evidence
} |
Scripts/armoury_screamerMine.js |
"use strict";
this.name = "armoury_screamerMine.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Ship script for the screamer mine";
this.version = "1.00";
this.shipSpawned = function () {
this.ship.desiredSpeed = 0;
this.destructChance = -0.5;
this.screamerTimer = new Timer(this, this.scream, 0, 2);
}
this.playerWillEnterWitchspace = this.shipDied = function () {
if (this.screamerTimer && this.screamerTimer.isRunning) {
this.screamerTimer.stop();
}
}
this.scream = function () {
if (!this.ship) {
this.shipDied();
return;
}
if (Math.random() < this.destructChance) // increasing chance that the mine's energy has run out and it self-destructs
{
this.ship.explode();
this.shipDied();
return;
} else {
this.destructChance += 0.01;
}
function isAlien(entity) {
return (entity.isShip && entity.target && entity.target != this.ship && (entity.isThargoid || entity.hasRole("thargoid") || entity.hasRole("thargon") || entity.hasRole("tharglet")));
}
var targetArray = system.filteredEntities(this, isAlien, this.ship, 25600)
if (targetArray.length > 0) {
var targetCounter = 0;
for (targetCounter = 0; targetCounter < targetArray.length; targetCounter++) {
if (Math.random() < 0.25) {
targetArray[targetCounter].reactToAIMessage("TARGET_LOST");
targetArray[targetCounter].target = this.ship;
targetArray[targetCounter].AIState = "ATTACK_SHIP";
}
}
}
} |
Scripts/armoury_trackerBeacon.js |
"use strict";
this.name = "armoury_trackerBeacon.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Beacon script for tracker missile.";
this.version = "1.00";
this.shipSpawned = function () {
if (!this.ship || !this.ship.target) {
return;
}
this.callbackID = addFrameCallback(this.positionTag.bind(this));
}
this.positionTag = function () {
if (!this.ship || !this.ship.isValid || !this.ship.target || !this.ship.target.isValid) {
if (this.callbackID) {
removeFrameCallback(this.callbackID);
}
delete this.callbackID;
this.ship.remove();
return;
}
this.ship.position = this.ship.target.position
};
this.shipDied = function (whom, why) { // in cases where the tag does manage to collide with the tracked entity, respawn the tag.
if (why && why === "scrape damage" && whom && this.ship && this.ship.target && whom === this.ship.target) {
var Tag = this.ship.spawnOne("armoury_trackerBeacon");
Tag.target = this.ship.target;
}
} |
Scripts/armoury_trackerMissile.js |
"use strict";
this.name = "armoury_trackerMissile.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Ship script for the tag missile";
this.version = "1.00";
this.tagShip = function () {
var Tag = this.ship.spawnOne("armoury_trackerBeacon");
if (this.ship && this.ship.target && this.ship.target.isValid) {
Tag.target = this.ship.target;
}
player.consoleMessage("Tracker deployed");
this.ship.remove();
} |
Scripts/armoury_trackerWorldScript.js |
"use strict";
this.name = "armoury_trackerWorldScript.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "World script for the tracker beacon";
this.version = "1.00";
this.compassTargetChanged = function (whom, mode) {
if (mode && mode === "COMPASS_MODE_BEACONS" && whom && whom.name === "Tracker Beacon") {
if (whom.target) {
player.consoleMessage("Tagged subject - " + whom.target.name);
}
}
} |
Scripts/armoury_voidBomb.js |
"use strict";
this.name = "armoury_voidBomb.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Ship script for the void bomb";
this.version = "1.00";
this.detonate = function () {
if (this.ship.subEntities.length > 0) {
this.ship.subEntities[0].explode();
}
this.ship.displayName = "Void Bomb Singularity";
this.voidTimer = new Timer(this, this.beginAttract, 0, 0.25);
}
this.playerWillEnterWitchspace = this.shipDied = this.stopTimer = function () {
if (this.voidTimer && this.voidTimer.isRunning) {
this.voidTimer.stop();
}
}
this.beginAttract = function () {
if (!this.ship) {
this.stopTimer();
return;
}
this.ship.velocity = [0, 0, 0];
function isTarget(entity) {
return (entity.isShip && entity.isValid);
}
var targetArray = system.filteredEntities(this, isTarget, this.ship, 25600)
if (targetArray.length > 0) {
var targetCounter = 0;
for (targetCounter = 0; targetCounter < targetArray.length; targetCounter++) {
this.targetRange = targetArray[targetCounter].position.distanceTo(this.ship.position);
this.targetVector = this.ship.position.subtract(targetArray[targetCounter].position).direction();
this.rangeFactor = (this.targetRange / 25600) * 0.8;
targetArray[targetCounter].velocity = targetArray[targetCounter].velocity.multiply(this.rangeFactor + 0.1).add(this.targetVector.multiply(25 * (1 - this.rangeFactor)));
}
}
}
this.shipTakingDamage = function (amount, fromEntity, damageType) {
this.ship.energy = this.ship.maxEnergy;
}
this.shipCollided = function (otherShip) {
if (this.ship.AIState === "VOID") {
otherShip.energy -= 64;
this.ship.energy = this.ship.maxEnergy;
}
}
/* Need to add dependence on mass perhaps? Also perhaps adjust the 10* multiplier for the applied velocity */ |
Scripts/armoury_wtfDecoy.js |
"use strict";
this.name = "armoury_wtfDecoy.js";
this.author = "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Ship script for the decoy";
this.version = "1.00";
this.shipSpawned = function () {
function allShips(entity) {
return entity.isShip && !entity.isRock && !entity.isCargo
};
let shipList = system.filteredEntities(this, allShips, this.ship, 25600);
if (shipList.length === 0) {
return;
}
var shipCounter = 0; // reset the counter
for (shipCounter = 0; shipCounter < shipList.length; shipCounter++) {
if (shipList[shipCounter].isPlayer) {
continue;
};
if (shipList[shipCounter].isPolice) {
shipList[shipCounter].target = this.ship;
shipList[shipCounter].reactToAIMessage("ATTACKED");
continue;
}
if (shipList[shipCounter].isTrader) {
shipList[shipCounter].target = this.ship;
shipList[shipCounter].reactToAIMessage("FLEE");
continue;
}
if (shipList[shipCounter].isPirate && Math.random() > 0.5) {
shipList[shipCounter].target = this.ship;
shipList[shipCounter].reactToAIMessage("ATTACKED");
continue;
}
}
} |
Scripts/drones_Launcher.js |
"use strict";
this.name = "drones_Launcher";
this.author = "Thargoid & Eric Walch";
this.copyright = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses - see readme.txt.";
this.description = "Spawn ship with target mother";
this.version = "2.0";
this.shipDied = function () {
let drone = this.ship.spawnOne(this.ship.scriptInfo.launch_name)
drone.master = this.ship.owner
if (this.ship.target) {
drone.target = this.ship.target
drone.position = this.ship.position
}
delete this.shipDied;
} |
Scripts/drones_Pickup.js |
"use strict";
this.name = "drones_Pickup";
this.author = "Thargoid & Eric Walsh";
this.copyright = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses - see readme.txt.";
this.description = "Pickup of a drone after combat, and check if it's reusable (T). New JS Scanning routine (EW). Updated for 1.74";
this.version = "2.01";
this.shipWasScooped = function (scooper) {
if (scooper.isPlayer) {
let choice = (Math.ceil(Math.random() * 3));
if (choice == 3) {
player.consoleMessage(this.ship.name + " circuits blown - only good for scrap machinery.", 6);
manifest["machinery"] += 1;
} else {
player.consoleMessage(this.ship.name + " recovered, recharged and ready for use.", 6);
player.ship.awardEquipment(this.ship.scriptInfo.DroneEquipment)
}
}
}
this.findMastersHostiles = function () {
function isHostileToMaster(entity) {
return (entity.isShip && (entity.isThargoid || (entity.target && entity.target == this.ship.master && entity.hasHostileTarget)));
}
let targets = system.filteredEntities(this, isHostileToMaster, this.ship, 25600)
if (targets.length > 0) {
this.ship.target = targets[0];
this.ship.reactToAIMessage("NEW_DRONE_TARGET");
if (this.ship.master && this.ship.master.isPlayer) player.commsMessage(this.ship.name + ": Attacking " + targets[0].displayName)
} else this.ship.reactToAIMessage("NOTHING_FOUND");
}
this.shipTargetDestroyed = function (target) {
if (this.ship.master && this.ship.master.isPlayer) {
player.score += 1;
player.credits += target.bounty;
player.consoleMessage("Drone kill - " + target.name + " : " + target.bounty + "? awarded.", 5);
}
log("Drone kill - " + target.name + " : " + target.bounty);
if (target.primaryRole == "constrictor" && missionVariables.conhunt && missionVariables.conhunt == "STAGE_1") { // just in case the drone kills the constrictor, let's not break the mission for the player...
missionVariables.conhunt = "CONSTRICTOR_DESTROYED";
}
} |
Scripts/missileRack_launcher.js |
"use strict";
this.name = "missileRack";
this.author = "Thargoid, with optimisation by Eric Walsh";
this.copyright = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses - see readme.txt.";
this.description = "Script for missile rack";
this.version = "1.0";
this.rackRefresh = function () {
this.launchRack = this.ship.scriptInfo.launchingRack;
switch (this.launchRack) {
case "EQ_IRACK_0_MISSILE":
case "EQ_NRACK_0_MISSILE":
case "EQ_HRACK_0_MISSILE":
case "EQ_SRACK_0_MISSILE":
{
player.consoleMessage("Missile rack empty - ejecting.", 6);
player.ship.spawnOne("missileRack_spentRack");
break;
}
default:
{
player.ship.awardEquipmentToCurrentPylon(this.launchRack);
break;
}
}
}
// functionality for stun missiles
this.performStun = function () {
if (!this.ship.target ||
!this.ship.target.isValid ||
!this.ship.target.isShip ||
this.ship.target.isPlayer ||
this.ship.target.isStation ||
this.ship.target.isRock ||
this.ship.target.isCargo) {
return;
} else {
this.ship.target.setAI("armoury_stunnedAI.plist");
}
} |
Scripts/probe_launcher.js |
"use strict";
this.name = "probeLaunch";
this.author = "Thargoid";
this.copyright = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses - see readme.txt.";
this.description = "Spawn probe with correct heading and AI";
this.version = "2.00";
this.shipDied = function () {
let probe = this.ship.spawnOne('probe_probeMissile');
let probeOrientation = this.ship.owner.orientation;
let offsetVector = probeOrientation.vectorUp(); // vector at right angles to the ship/probe, downwards
let spawnOffset = offsetVector.multiply(50); // set the offset to 50m downwards (for larger ships, increase 50).
probe.orientation = probeOrientation; // point the probe in the same direction as the player
probe.position = this.ship.position.subtract(spawnOffset); // move the probe to it's correct start point.
probe.switchAI('probe_probeMissileAI.plist'); // confirm it's using the correct AI after spawn (no autoAI).
delete this.shipDied;
} |
Scripts/probe_operation.js |
"use strict";
this.name = "probeMissile";
this.author = "Thargoid & Eric Walch";
this.copyright = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses - see readme.txt.";
this.description = "Operation and pick-up of probe missile.";
this.version = "2.0";
this.shipWasScooped = function (scooper) {
if (scooper.isPlayer) {
player.consoleMessage("Probe missile recovered, refuelled and ready for re-use.", 6);
player.ship.awardEquipment("EQ_PROBE_LAUNCHER_MINE")
}
}
this.doScan = function () {
// create an array with all ships ("isShip" includes barrels and rock etc.)
function allShips(entity) {
return entity.isShip
};
let anyShips = system.filteredEntities(this, allShips, this.ship, 25600);
// do neutral ships
function neutralShips(entity) {
return entity.scanClass == "CLASS_NEUTRAL"
};
this.neutralCount = anyShips.filter(neutralShips).length;
// do police/military ships
function policeShips(entity) {
return (entity.scanClass == "CLASS_POLICE" || entity.scanClass == "CLASS_MILITARY")
};
this.policeCount = anyShips.filter(policeShips).length;
// do thargoid ships
function thargoidShips(entity) {
return entity.scanClass == "CLASS_THARGOID"
};
this.thargoidCount = anyShips.filter(thargoidShips).length;
// do rocks
function rockShips(entity) {
return entity.scanClass == "CLASS_ROCK" && !entity.isStation
};
this.rockCount = anyShips.filter(rockShips).length;
// do stations
function stationShips(entity) {
return (entity.scanClass == "CLASS_STATION" || entity.isStation)
};
this.stationCount = anyShips.filter(stationShips).length;
// do cargo
function cargoShips(entity) {
return entity.scanClass == "CLASS_CARGO"
};
this.cargoCount = anyShips.filter(cargoShips).length;
// do trader ships
function isPirateVictim(entity) {
return entity.isPirateVictim
};
this.traderCount = anyShips.filter(isPirateVictim).length;
// do trader escorts
function isTraderEscort(entity) {
return entity.primaryRole == "escort" && entity.owner && entity.owner.isPirateVictim
};
this.traderEscortCount = anyShips.filter(isTraderEscort).length;
// do pirate ships
function isPirate(entity) {
return entity.isPirate
};
this.pirateCount = anyShips.filter(isPirate).length;
// do pirate escorts
function isPirateEscort(entity) {
return entity.primaryRole == "escort" && entity.owner && entity.owner.isPirate
};
this.pirateEscortCount = anyShips.filter(isPirateEscort).length;
this.totalCount = this.neutralCount + this.policeCount + this.thargoidCount + this.rockCount + this.stationCount + this.cargoCount;
if (this.totalCount == 0) {
player.commsMessage("Probe Missile - Nothing within scanner range.", 6);
} else {
player.commsMessage("Scan readout :", 6);
if (this.traderCount + this.traderEscortCount > 0) player.commsMessage("Traders - " + this.traderCount + " (with " + this.traderEscortCount + " escorts)", 6);
if (this.policeCount > 0) player.commsMessage("System vessels - " + this.policeCount, 6);
if (this.pirateCount + this.pirateEscortCount > 0) player.commsMessage("Pirates - " + this.pirateCount + " (with " + this.pirateEscortCount + " escorts)", 6);
if (this.thargoidCount > 0) player.commsMessage("Aliens - " + this.thargoidCount, 6);
if (this.rockCount > 0) player.commsMessage("Asteroids - " + this.rockCount, 6);
if (this.cargoCount > 0) player.commsMessage("Loose Cargo - " + this.cargoCount, 6);
if (this.stationCount > 0) player.commsMessage("Stations - " + this.stationCount, 6);
let otherShipsCount = this.neutralCount - this.pirateCount - this.pirateEscortCount - this.traderCount - this.traderEscortCount;
if (otherShipsCount > 0) player.commsMessage("Other ships - " + otherShipsCount, 6);
}
}
this.shipDied = function () {
player.consoleMessage("Contact lost with probe missile.", 6);
}
this.probeLaunched = function () {
player.consoleMessage("Probe missile launch successful.", 6);
}
this.setCoords = function () {
let dest = this.ship.orientation.vectorForward().multiply(50000);
this.ship.savedCoordinates = this.ship.position.add(dest);
}
this.probeReturning = function () {
player.commsMessage("Probe Missile - Returning, please slow for rendezvous.", 6);
}
this.probeLost = function () {
player.commsMessage("Probe Missile - Unable to reach ship for rendezvous, shutting down.", 6);
}
this.getPlayer = function () {
this.ship.target = player.ship;
} |