Back to Index Page generated: May 8, 2024, 6:16:03 AM

Expansion QTHI Auxiliary Energy Generators

Content

Warnings

  1. Replaced equipment 'EQ_QTHI_AuxEnergyGeneratorHT_Sell'

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Different auxiliary energy generators for those who often run short on Energy, but have plenty Witchspace fuel. Different auxiliary energy generators for those who often run short on Energy, but have plenty Witchspace fuel.
Identifier oolite.oxp.QCS.QTHI_AuxEnergyGenerators oolite.oxp.QCS.QTHI_AuxEnergyGenerators
Title QTHI Auxiliary Energy Generators QTHI Auxiliary Energy Generators
Category Equipment Equipment
Author QCS QCS
Version 0.1.1 0.1.1
Tags equipment equipment
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Energy_Equipment_OXP n/a
Download URL https://wiki.alioth.net/img_auth.php/e/e9/Oolite.oxp.QCS.QTHI_AuxEnergyGenerators_0.1.1.oxz n/a
License Creative Commons Attribution - Non-Commercial - Share Alike 4.0 license Creative Commons Attribution - Non-Commercial - Share Alike 4.0 license
File Size n/a
Upload date 1610873504

Documentation

Also read http://wiki.alioth.net/index.php/QTHI%20Auxiliary%20Energy%20Generators

Equipment

Name Visible Cost [deci-credits] Tech-Level
Auxiliary Energy Generator yes 8500 6+
High-Tech Auxiliary Energy Generator yes 12500 8+
Sell High-Tech Auxiliary Energy Generator yes 0 8+
Heavy Auxiliary Energy Generator yes 25000 8+
Light Auxiliary Energy Generator yes 25000 8+
Uninstall High-Tech Light Auxiliary Energy Generator yes 5000 8+
Sell Auxiliary Energy Generator yes 0 6+

Ships

This expansion declares no ships. This may be related to warnings.

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
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);
}