| Config/script.js | 
this.name           = "QTHI Auxiliary Generators";
this.author         = "QCS";
this.copyright      = "(C) 2015 QCS.";
this.licence        = "CC-NC-by-SA 4.0";
this.description    = "Core script based on EnergyEquipment from Thargoid, content by QCS.";
this.version        = "0.1.1";
"use strict";
this.shipExitedWormhole = function()
{
  if(player.ship.equipmentStatus("EQ_QTHI_AuxEnergyGenerator") === "EQUIPMENT_OK")
  {
    this.auxGeneratorKey = "EQ_QTHI_AuxEnergyGenerator";
  }
  else if(player.ship.equipmentStatus("EQ_QTHI_AuxEnergyGeneratorHT") === "EQUIPMENT_OK")
  {
    this.auxGeneratorKey = "EQ_QTHI_AuxEnergyGeneratorHT";
  }
  else if(player.ship.equipmentStatus("EQ_QTHI_AuxEnergyGeneratorHT") === "EQUIPMENT_OK")
  {
    this.auxGeneratorKey = "EQ_QTHI_AuxEnergyGeneratorHT";
  }
  else if(player.ship.equipmentStatus("EQ_QTHI_AuxEnergyGeneratorHv") === "EQUIPMENT_OK")
  {
    this.auxGeneratorKey = "EQ_QTHI_AuxEnergyGeneratorHv";
  }
  else if(player.ship.equipmentStatus("EQ_QTHI_AuxEnergyGeneratorLt") === "EQUIPMENT_OK")
  {
    this.auxGeneratorKey = "EQ_QTHI_AuxEnergyGeneratorLt";
  }
  else
  {
    this.auxGeneratorKey = null;
  }
  if(this.auxGeneratorKey == null)
  {
    return;
  }
  if(player.ship.equipmentStatus(auxGeneratorKey) === "EQUIPMENT_OK")
  {
    if(this.auxEnergyCheckTimer)
    {
      this.auxEnergyCheckTimer.start()
    }
    else
    {
      this.auxEnergyCheckTimer = new Timer(this, this.auxEnergyCheck,0,1);
    }
  }
  if (this.auxGeneratorKey === "EQ_QTHI_AuxEnergyGeneratorHT" || this.auxGeneratorKey === "EQ_QTHI_AuxEnergyGeneratorLt" || this.auxGeneratorKey === "EQ_QTHI_AuxEnergyGeneratorHv")
  {
    if(this.auxHtEnergyCostTimer)
    {
      this.auxHtEnergyCostTimer.start()
    }
    else
    {
      this.auxHtEnergyCostTimer = new Timer(this, this.auxHtEnergyCost,0,1);
    }
  }
}
this.shipLaunchedFromStation = function(station)
{
  this.shipExitedWormhole();
}
this.auxHtEnergyCost = function()
{
  if (this.isGeneratorEnabled === true)
  {
    player.energy -= 2;
  }
}
this.auxEnergyCheck = function()
{
  if (this.auxEnergyGeneratorRunning === true)
  {
    return;
  }
  if (this.auxEnergyReloadTimer)
  {
    this.auxEnergyReloadTimer.stop();
  }
  if(player.ship.docked || player.ship.equipmentStatus(auxGeneratorKey) != "EQUIPMENT_OK")
  {
    this.auxEnergyCheckTimer.stop();
  }
  else
  {
    if(this.isGeneratorEnabled === true && player.ship.energy < player.ship.maxEnergy * this.kickInRatio && player.ship.fuel > 0)
    {
      this.auxEnergyGeneratorRunning = true;
      player.ship.fuel -= 0.1;
      player.consoleMessage("Firing up Auxiliary Energy Generator!",6);
      log(this.name, "Firing up Auxiliary Energy Generator!");
      this.auxEnergyReloadCount = 0;	
      this.auxEnergyReloadTimer = new Timer(this, this.auxEnergyReload, 0, 0.25);
    }
  }   	        
}
this.auxEnergyReload = function()
{
  if (this.auxEnergyReloadCount < 50)
  {
    player.ship.energy += 2;
    if (this.auxGeneratorKey === "EQ_QTHI_AuxEnergyGeneratorLt")
    {
      //only half the power from the Light generator
      player.ship.energy -= 1;
    }
    if (this.auxGeneratorKey === "EQ_QTHI_AuxEnergyGeneratorHv")
    {
      //twice the power from the Heavy generator
      player.ship.energy += 2;
    }
    this.auxEnergyReloadCount++;
    player.ship.temperature *= 1.01;
  }
  else 
    if (this.auxEnergyGeneratorRunning === true)
    {
      if (player.ship.energy < player.ship.maxEnergy * this.kickInRatio && player.ship.fuel > 0)
      {
	player.consoleMessage("Energy still critical: Keeping Auxiliary Energy Generator online");
	log(this.name, "Energy still critical: Keeping Auxiliary Energy Generator online");
	this.auxEnergyReloadCount = 0;
	player.ship.fuel -= 0.1;
      }
      else
      {
	player.consoleMessage("Auxiliary Energy Generator offline.");
	log(this.name, "Auxiliary Energy Generator offline.");
	this.auxEnergyGeneratorRunning = false;
      }
    }
}
this.shipDied = function()
{
  if(this.auxEnergyCheckTimer)
  {
    this.auxEnergyCheckTimer.stop()
  }
}
this.playerBoughtEquipment = function(equipmentKey)
{     
  if(equipmentKey == ("EQ_QTHI_AuxEnergyGenerator_Sell"))
  {
    player.ship.removeEquipment("EQ_QTHI_AuxEnergyGenerator");
    player.ship.removeEquipment("EQ_QTHI_AuxEnergyGenerator_Sell");
    player.credits += 500;
  }
  if(equipmentKey == ("EQ_QTHI_AuxEnergyGeneratorHT_Sell"))
  {
    player.ship.removeEquipment("EQ_QTHI_AuxEnergyGeneratorHT");
    player.ship.removeEquipment("EQ_QTHI_AuxEnergyGeneratorHT_Sell");
    player.credits += 800;
  }
  if(equipmentKey == ("EQ_QTHI_AuxEnergyGeneratorHv_Sell"))
  {
    player.ship.removeEquipment("EQ_QTHI_AuxEnergyGeneratorHv");
    player.ship.removeEquipment("EQ_QTHI_AuxEnergyGeneratorHv_Sell");
    player.credits += 1950;
  }
  //nothing special for EQ_QTHI_AuxEnergyGeneratorLt_Sell
}
this.playerStartedJumpCountdown = function(type)
{
  if (this.auxGeneratorKey === "EQ_QTHI_AuxEnergyGeneratorLt" && this.isGeneratorEnabled === true)
  {
    player.consoleMessage("Witchspace drive disabled");
    player.ship.cancelHyperspaceCountdown();
  }
} | 
                
                    | Scripts/EQ_QTHI_AuxEnergyGenerator.js | this.author      = "QCS"; 
this.copyright   = "� 2015 QCS."; 
this.licence = "CC-BY-SA 4.0";
this.version     = "0.1.1"; 
this.name           = "QTHI Auxiliary Generators Equipment";
this.author         = "QCS";
this.copyright      = "(C) 2015 QCS.";
this.licence        = "CC-NC-by-SA 4.0";
this.description    = "Equipment script for the Generator (Priming/Activation).";
this.version        = "0.1.1";
this.activated = function ()
{
  var genScript = worldScripts["QTHI Auxiliary Generators"];
  
  if (!genScript.isGeneratorEnabled)
  {
    genScript.isGeneratorEnabled = false;
  }
  
  genScript.isGeneratorEnabled = !genScript.isGeneratorEnabled;
  if (genScript.isGeneratorEnabled === false)
  {
     player.consoleMessage("Auxiliary Energy Generator disabled",6);
     if (genScript.auxGeneratorKey === "EQ_QTHI_AuxEnergyGeneratorLt")
     {
       player.consoleMessage("Witchspace engine enabled",6);
     }
  }
  else
  {
     player.consoleMessage("Auxiliary Energy Generator enabled",6);
     if (genScript.auxGeneratorKey === "EQ_QTHI_AuxEnergyGeneratorLt")
     {
       player.consoleMessage("Witchspace engine disabled",6);
     }
  } 
}
this.mode = function ()
{
  var genScript = worldScripts["QTHI Auxiliary Generators"];
  
  if (!genScript.kickInRatio)
  {
    genScript.kickInRatio = 0.2;
  }
  
  genScript.kickInRatio = genScript.kickInRatio + 0.2;
  if (genScript.kickInRatio > 1.0)
  {
    genScript.kickInRatio = 0.2;
  }
  player.consoleMessage("Auxiliary Energy Generator kicks in below " + Math.floor(genScript.kickInRatio * 100) + "% energy level",6);
}
 |