This is the script that's currently in the neocaduceus download.
Code: Select all
this.name = "Caduceus Damage Control Node";
this.author = "Modified Thargoid's repair bots for Caduceus, by Wyvern";
this.copyright = "2009";
this.description = "Nanite autorepair node for Caduceus class bioships. Simulates an AI controlled self-healing nanoforge and damage control teams to repair kit over time.";
this.version = "0.3";
this.shipLaunchedFromStation = function() {
if (player.ship.hasEquipment("EQ_DCN")) {
if (this.damageControlTimer) {
this.damageControlTimer.start();
} else {
this.damageControlTimer = new Timer(this, this.repairShip, 60, 300);
}
}
};
this.shipExitedWitchspace = function() {
if (player.ship.hasEquipment("EQ_DCN")) {
if (this.damageControlTimer) {
this.damageControlTimer.start();
} else {
this.damageControlTimer = new Timer(this, this.repairShip, 60, 300);
}
}
};
this.equipmentDamaged = this.equipmentDestroyed = function(equipment) {
if (equipment == "EQ_DCN") {
if(this.damageControlTimer) {
this.damageControlTimer.stop();
delete this.damageControlTimer;
}
if(this.damageNodeTimer) {
this.damageNodeTimer.start();
} else {
this.damageNodeTimer = new Timer(this, this.restoreNode, 0, 60);
}
}
};
this.playerWillEnterWitchspace = function() {
if (this.damageControlTimer) {
this.damageControlTimer.stop();
delete this.damageControlTimer;
}
if (this.damageNodeTimer) {
this.damageNodeTimer.stop();
delete this.damageNodeTimer;
}
};
this.shipDockedWithStation = function()
{
if(this.damageControlTimer) {
this.damageControlTimer.stop();
delete this.damageControlTimer;
}
}
this.shipDied = function()
{
if(this.damageControlTimer) {
this.damageControlTimer.stop();
delete this.damageControlTimer;
}
if(this.damageNodeTimer) {
this.damageNodeTimer.stop();
delete this.damageNodeTimer;
}
}
this.repairShip = function()
{
if (0 < oolite.compareVersion("1.72"))
{
// 1.71.x or earlier
this.thePlayerShip = player;
}
else
{
// 1.72 or later
this.thePlayerShip = player.ship;
}
this.damagedList = ["EQ_UPS_IDCLEANER_DAMAGED", "EQ_UPS_UNIVERSAL_SCANNER_DAMAGED", "EQ_UPS_POLICE_SCANNER_DAMAGED", "EQ_ECM_DAMAGED", "EQ_FUEL_SCOOPS_DAMAGED", "EQ_ESCAPE_POD_DAMAGED", "EQ_ENERGY_BOMB_DAMAGED", "EQ_ENERGY_UNIT_DAMAGED", "EQ_NAVAL_ENERGY_UNIT_DAMAGED", "EQ_GAL_DRIVE_DAMAGED", "EQ_CLOAKING_DEVICE_DAMAGED", "EQ_FUEL_INJECTION_DAMAGED", "EQ_SCANNER_SHOW_MISSILE_TARGET_DAMAGED", "EQ_MULTI_TARGET_DAMAGED", "EQ_ADVANCED_COMPASS_DAMAGED", "EQ_ADVANCED_NAVIGATIONAL_ARRAY_DAMAGED", "EQ_TARGET_MEMORY_DAMAGED", "EQ_SHIELD_BOOSTER_DAMAGED", "EQ_NAVAL_SHIELD_BOOSTER_DAMAGED", "EQ_FRAME_FUEL_COLLECTOR_DAMAGED", "EQ_FRAME_BOUNTY_SCANNER_DAMAGED", "EQ_EEU_DAMAGED", "EQ_MISSILE_ANALYSER_DAMAGED", "EQ_AMS_DAMAGED", "EQ_DUMMY" ];
this.screenList = ["Pirate ID Cleaner", "Universal Scanner", "GalCop Scanner", "E.C.M.", "Fuel Scoops", "Escape Pod", "Energy Bomb", "Extra Energy Enit", "Naval Energy Unit", "Galactic Hyperdrive", "Cloaking Device", "Witchdrive Fuel Injectors", "Scanner Targeting Enhancement", "Multi-Targeting System", "Advanced Space Compass", "Advanced Navigational Array", "Target System Memory Expansion", "Shield Boosters", "Naval Shield Enhancement", "Fuel Collector", "Bounty Scanner", "Emergency Energy Unit", "Missile Analyser", "Anti-Missile System", "Nothing could be" ];
this.eqChance = [60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 100]; // percentage chance of equipment being fixed, for tech <9 chance = 100%, dropping 10% per level above 8.
this.damListLength = this.damagedList.length - 1;
this.screenListLength = this.screenList.length - 1;
this.playerDamagedList = []; // reset the list for each new usage of the repair bots.
this.playerDamagedItem = []; // array of locations within the above list.
let eqCounter = 0 ; // reset the counter
for(eqCounter = 0;eqCounter<=this.damListLength;eqCounter++)
{
this.checkItem = this.damagedList[eqCounter];
if(this.thePlayerShip.hasEquipment(this.checkItem))
{
this.playerDamagedList.push(this.checkItem) // if it's broke, add it to the list.
this.playerDamagedItem.push(eqCounter) // keep a note of where in the list it is.
}
}
this.plistlength = this.playerDamagedList.length;
if(this.plistlength == 0)
{
player.consoleMessage("All systems nominal.",5)
}
else
{
let damagedEquipment = Math.floor(Math.random() * this.plistlength); // pick a random element from the list...
this.damagedItem = this.playerDamagedList[damagedEquipment]; // ...define the item...
this.damagedItemNumber = this.playerDamagedItem[damagedEquipment]; // where the item to be repaired is in the list
this.fixedItem = this.damagedItem.substring(0,this.damagedItem.length-8);
this.fixedName = this.screenList[this.damagedItemNumber]; // define it's screen name
this.fixChance = this.eqChance[this.damagedItemNumber]; // for tech <9 chance = 100%, dropping 10% per level above 8.
this.fixTry = Math.random() * 100;
if(this.fixTry < this.fixChance)
{
this.fixItem();
}
else
{
player.consoleMessage(this.fixedName + " is still offlined, Captain. We shall try again soon.",5);
}
}
}
this.restoreNode = function()
{
if (0 < oolite.compareVersion("1.72"))
{
// 1.71.x or earlier
this.thePlayerShip = player;
}
else
{
// 1.72 or later
this.thePlayerShip = player.ship;
}
this.damagedList = ["EQ_DCN_DAMAGED", "EQ_DUMMY" ];
this.screenList = ["Damage Control Node", "Nothing could be" ];
this.eqChance = [75, 100]; // percentage chance of equipment being fixed, for tech <9 chance = 100%, dropping 10% per level above 8.
this.damListLength = this.damagedList.length - 1;
this.screenListLength = this.screenList.length - 1;
this.playerDamagedList = []; // reset the list for each new usage of the repair bots.
this.playerDamagedItem = []; // array of locations within the above list.
let eqCounter = 0 ; // reset the counter
for(eqCounter = 0;eqCounter<=this.damListLength;eqCounter++)
{
this.checkItem = this.damagedList[eqCounter];
if(this.thePlayerShip.hasEquipment(this.checkItem))
{
this.playerDamagedList.push(this.checkItem) // if it's broke, add it to the list.
this.playerDamagedItem.push(eqCounter) // keep a note of where in the list it is.
}
}
this.plistlength = this.playerDamagedList.length;
if(this.plistlength == 0) {
player.consoleMessage("Damage Control Node regenerated! Repairs resuming.",5)
if(this.damageNodeTimer) {
this.damageNodeTimer.stop();
delete this.damageNodeTimer;
}
if(this.damageControlTimer) {
this.damageControlTimer.start();
} else {
this.damageControlTimer = new Timer(this, this.repairNode, 60, 300)
}
} else {
let damagedEquipment = Math.floor(Math.random() * this.plistlength); // pick a random element from the list...
this.damagedItem = this.playerDamagedList[damagedEquipment]; // ...define the item...
this.damagedItemNumber = this.playerDamagedItem[damagedEquipment]; // where the item to be repaired is in the list
this.fixedItem = this.damagedItem.substring(0,this.damagedItem.length-8);
this.fixedName = this.screenList[this.damagedItemNumber]; // define it's screen name
this.fixChance = this.eqChance[this.damagedItemNumber]; // for tech <9 chance = 100%, dropping 10% per level above 8.
this.fixTry = Math.random() * 100;
if(this.fixTry < this.fixChance)
{
this.fixItem();
}
else
{
player.consoleMessage(this.fixedName + " is regenerating. Stand by.",5);
}
}
}
this.fixItem = function()
{
this.thePlayerShip.setEquipmentStatus(this.fixedItem,"EQUIPMENT_OK"); // and actually fix the thing!
player.consoleMessage(this.fixedName + " repaired and online.", 5)
switch(this.fixedItem) // specific OXP equipment which need rebooting after fixing, or have other issues.
{
case "EQ_FRAME_FUEL_COLLECTOR":
{
if(worldScripts["Fuel Collector"])
{
worldScripts["Fuel Collector"].shipLaunchedFromStation(); // restart the timers in it's world script
}
}
break;
case "EQ_FRAME_BOUNTY_SCANNER":
{
if(worldScripts["Bounty Scanner"])
{
worldScripts["Bounty Scanner"].shipLaunchedFromStation(); // restart the timers in it's world script
}
}
break;
case "EQ_EEU":
{
if(worldScripts["Emergency Energy Unit"])
{
worldScripts["Emergency Energy Unit"].shipLaunchedFromStation(); // restart the timers in it's world script
}
}
break;
}
}
You'll notice a few things here.
- Non combat-essential and non-irreplaceable items removed.
. MASC is
, not by the devs or by me, and shouldn't be in the hands of the player IMHO. I'll bet the devs are wishing the bloody thing was never coded. Is Kaks twitching again? No, there