Back to Index Page generated: Dec 20, 2024, 7:22:09 AM

Expansion Q-Charger

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Provides a boost in speed when at maximum throttle at the cost of some fuel and energy. Provides a boost in speed when at maximum throttle at the cost of some fuel and energy.
Identifier oolite.oxp.CommonSenseOTB.Q-Charger oolite.oxp.CommonSenseOTB.Q-Charger
Title Q-Charger Q-Charger
Category Equipment Equipment
Author CommonSenseOTB, Norby CommonSenseOTB, Norby
Version 1.25 1.25
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Q-Charger n/a
Download URL https://wiki.alioth.net/img_auth.php/6/60/Q-Charger_1.25.oxz n/a
License CC BY-NC-SA 3 CC BY-NC-SA 3
File Size n/a
Upload date 1610873314

Documentation

Also read http://wiki.alioth.net/index.php/Q-Charger

Readme Q-Chargerv1.25.txt

USER CUSTOMIZABILITY:

You now have the option of going to the startUp function of the Q-Chargerv1 script
and setting the toggle to "OFF" if you don't want the sounds effects.
Toggles must be set to either "ON" or "OFF", default is "ON".


COMPATIBILITY:
Oolite version 1.75.3
NUMERIC HUDV1.3.oxp now displays Q-Charger's top speed correctly.

Changelog:
May.23, 2014 v1.25 - Smooth speed levels when throttle is between 95% and 100%.
May.8, 2014 v1.24 - Primeable Q-Charger to disable it and a bugfix without ShipVersion.
                    Small ships under 30t mass can not use it anymore.
Dec.13, 2013 v1.23 - Some NPCs use Q-Charger without ShipVersion OXP also.
Okt.30, 2013 v1.22 - Small bugfix after player ejected.
Apr.8, 2013 v1.21 - Modified to awardable for NPC ships to make compatible with ShipVersion OXP by Norby.
Aug.22, 2011 v1.2 -Added 3 missing toggle checks to prevent problems when the sound is toggled "OFF".
Aug.7, 2011 v1.1 -Attenuated the high frequencies of the sound effects by putting them through a low-pass filter.					   

Q-Chargerv1.2.oxp

Q-RaceTech is proud to present an innovation in Main Drive boosting technology. 
The Q-Charger uses new understanding of the principles governing Main Drives and Quirium Fuel 
to boost the top speed of any ship by 2x. The Q-Charger kicks in when the throttle is set 
over 95% maximum. The speed will be maintained at a steady 2x ship max speed until it is 
kicked off by lowering the throttle below 95% maximum. The Q-Charger requires fuel injection 
be installed before buying and requires both fuel injection and either an extra energy unit 
or a naval energy unit for operation. The Q-Charger will automatically cut out when either 
fuel drops below 0.1 ly or energy drops below 32.
 
WARNING: Serious damage may result to the Q-Charger if either the fuel injection or 
energy unit is damaged while in operation. Additionally, the Q-Charger is particularily 
vulnerable when it is damaged directly. Proper safeguards prevent main drive damage however. 
It uses 0.1 ly of Quirium fuel per 30 seconds of use and 4 units of energy per second. 
Q-Chargers sell for 10000 credits at any tech level 10 system. 

Remember, things go better with Q.

You can disable Q-Charger by priming (Shift+N) and activating (n) if you want save your fuel sometimes.
Small ships under 30t mass like an Adder can not equip it due to the space requirement.

Author: CommonSenseOTB
Completed: July 25, 2011

This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0
Unported License. To view a copy of this license, visit "http://creativecommons.org/licenses/by-
nc-sa/3.0/'' or send a letter to Creative Commons, 171 Second Street, Suite 300, San
Francisco, California, 94105, USA.


The Q-Charger sound effects courtesy of  � 1998-2011 GRSites.com. All Rights Reserved. Freeware for private and commercial use.
Sound effect aircraft048.wav  95.7 kb  Hawkeye E-2C powering-up/edited for use by CommonSenseOTB in Q-Chargerv1.oxp.

Equipment

Name Visible Cost [deci-credits] Tech-Level
Q-Charger yes 100000 10+
There's a real 'Q-Mess' in the engine room yes 0 100+
Clean up the 'Q-Mess' in the engine room yes 5000 10+
Sell Q-Charger yes 0 10+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/Q-Charger.js
/*

Q-Charger.js

Script for a Q-Charger for your ship.


Oolite
Copyright � 2003-2010 Giles C Williams and contributors

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.


Q-Chargerv1.24.oxp
Copyright � 2011 "CommonSenseOTB"
updated by Norby

This work is licensed under the Creative Commons
Attribution-Noncommercial-Share Alike 3.0 Unported License.

To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter
to Creative Commons, 171 Second Street, Suite 300, San Francisco,
California, 94105, USA.

*/

this.name               = "Q-Charger";
this.author               = "CommonSenseOTB";
this.copyright            = "Copyright 2011 by CommonSenseOTB CC-NC-by-SA 3.0";
this.description         = "Provides a Q-Charger for your ship.";
this.version            = "1.25";


this.startUp = function()
   {
   // You may toggle the sound here
   // Developers may have their hud script toggle these remotely
   //
   //
   //
   // YOU MAY TOUCH THESE
   //
   this.togglesoundfx1 = "ON";// default "ON", change to "OFF" to turn off soundfx1(Q-Charger,power up and power down)(1,2,3,4,5)
   //
   //
   //
   // DO NOT TOUCH THESE PLEASE
   //
   this.qchargerenabled = true;// player can disable/enable by priming and activating Q-Charger 
   this.qchargercondition = "OFF";// player OFF and ON
   this.qchargerfuelcounter = 0.0;// default for save anywhere do not prime Q-Charger with fuel first
   this.qchargerfuelcounters = [];// array hold fuelcounters to all NPC ships equipped with Q-Charger
   this.qchargerpercent = 0; //current speed bonus provided by q-charger to player, 1 mean +100%, read by NumericHUD
   this.qchargerships = [];// array hold all NPC ships equipped with Q-Charger
   this.qchargercounterpowerup = 0.0;// default is off
   this.qchargercounterpowerdown = 0.0;// default is off
   this.mySound1 = new SoundSource;
   this.mySound1.sound = "Q-Charger.ogg";
   this.mySound1.loop = true;
   this.mySound2 = new SoundSource;
   this.mySound2.sound = "Q-Charger Power Up.ogg";
   this.mySound2.loop = false;
   this.mySound3 = new SoundSource;
   this.mySound3.sound = "Q-Charger Power Down.ogg";
   this.mySound3.loop = false;
   this.mySound4 = new SoundSource;
   this.mySound4.sound = "Q-Charger Half Power Up.ogg";
   this.mySound4.loop = false;
   this.mySound5 = new SoundSource;
   this.mySound5.sound = "Q-Charger Half Power Down.ogg";
   this.mySound5.loop = false;
   }

this.awardQCharger = function(ship) //call worldScripts["Q-Charger"].awardQCharger(ship); to give Q-Charger to an NPC ship
   {
   if(!ship || !ship.isValid || ship.isStation || ship === player.ship) return; //for sure
   if(this.qchargerships.indexOf(ship) >= 0) {
	   //player.consoleMessage(ship.displayName+" Q-Charger already awarded");//debug
	   return;
   }
   if(ship.equipmentStatus("EQ_Q-CHARGER")!="EQUIPMENT_OK")
      ship.awardEquipment("EQ_Q-CHARGER");//not enough, must be in the qchargerships array also
   this.qchargerships[this.qchargerships.length] = ship;//store the ship, will not work without this
   this.qchargerfuelcounters[this.qchargerfuelcounters.length] = 60.0;//and this
   if(ship.equipmentStatus("EQ_ENERGY_UNIT")!="EQUIPMENT_OK")
      ship.awardEquipment("EQ_ENERGY_UNIT");//some other awards to make usable the Q-Charger
   if(ship.equipmentStatus("EQ_FUEL_INJECTION")!="EQUIPMENT_OK")
      ship.awardEquipment("EQ_FUEL_INJECTION");
   ship.fuel = 7.0;
   }

this.shipSpawned = function(ship)
   {
   if(!ship || !ship.isValid || ship.isStation || ship === player.ship) return; //for sure
   if(ship.equipmentStatus("EQ_Q-CHARGER")=="EQUIPMENT_OK") 
      {
      //player.consoleMessage(ship.displayName+" spawned with Q-Charger");//debug
      this.awardQCharger(ship);
      } else { //Award Q-Charger to NPCs without ShipVersion OXP
      if( ship.mass >= 30000 && Math.floor( ship.entityPersonality / 328 ) + 1 >= 60 ) ///exactly as in ShipVersion OXP
         {
	 this.awardQCharger(ship);
   	 }
      }
   }

this.playerBoughtEquipment = function(equipmentKey)
   {     
   if(equipmentKey === ("EQ_Q-CHARGER_REMOVAL"))
      {
      player.ship.removeEquipment("EQ_Q-CHARGER");
      player.ship.removeEquipment("EQ_Q-CHARGER_REMOVAL");
      player.credits += 6500;
      }
   if(equipmentKey === ("EQ_Q-CHARGER_MESS_REMOVAL"))
      {
      player.ship.removeEquipment("EQ_Q-CHARGER_MESS");
      player.ship.removeEquipment("EQ_Q-CHARGER_MESS_REMOVAL");
      }
   }

this.equipmentDamaged = this.equipmentDestroyed = function(equipment)
   { // if fuel injection or energy units damaged while in use, damage the Q-Charger
   if((equipment === "EQ_FUEL_INJECTION") || (equipment === "EQ_ENERGY_UNIT") || (equipment === "EQ_NAVAL_ENERGY_UNIT"))
      {
	  if((player.ship.equipmentStatus("EQ_Q-CHARGER") === "EQUIPMENT_OK") && (this.qchargercondition === "ON"))
	     {
	     player.ship.setEquipmentStatus("EQ_Q-CHARGER","EQUIPMENT_DAMAGED");
	     if(this.mySound1.isPlaying)//shutdown sequence
            {
            this.mySound1.stop();
            }
         if(this.mySound2.isPlaying)
            {
            this.mySound2.stop();
            }
         if(this.mySound3.isPlaying)
            {
            this.mySound3.stop();
            }
         if(this.mySound4.isPlaying)
            {
            this.mySound4.stop();
            }
         if(this.mySound5.isPlaying)
            {
            this.mySound5.stop();
            }
         this.qchargercondition = "OFF";
         }			
      }
   if(equipment === "EQ_Q-CHARGER")
      {
	  if(this.qchargercondition === "ON")// direct hit while in use is disastrous
	     {
		 player.ship.removeEquipment("EQ_Q-CHARGER");
		 player.ship.awardEquipment("EQ_Q-CHARGER_MESS");
	     if(this.mySound1.isPlaying)//shutdown sequence
            {
            this.mySound1.stop();
            }
         if(this.mySound2.isPlaying)
            {
            this.mySound2.stop();
            }
         if(this.mySound3.isPlaying)
            {
            this.mySound3.stop();
            }
         if(this.mySound4.isPlaying)
            {
            this.mySound4.stop();
            }
         if(this.mySound5.isPlaying)
            {
            this.mySound5.stop();
            }// play bad sounds here if required
         this.qchargercondition = "OFF";
         }		
      }
   }
  
this.shipLaunchedFromStation = function()
   {
   if((missionVariables.framesave !== "MoveToOxpStation") && (missionVariables.framesave !== "MoveToMainStation"))//prevent priming Q-Charger when loading/saving Save Anywhere Savegame
	  {
	  this.qchargerfuelcounter = 120.0;// default at launch prime Q-Charger with fuel first
      }   
   if(this.qchargerCheckTimer)
      {
      this.qchargerCheckTimer.start();
      }
   else
      {
      this.qchargerCheckTimer = new Timer(this, this.qchargerCheck,0,0.25);// check Q-Charger every 0.25 seconds
      }
   }

this.qchargerCheck = function()
   {
   var wdet = worldScripts["detectors"];
   for(var i = 0; i < this.qchargerships.length; i++) //check all NPCs with Q-Charger
      {
      var ship = this.qchargerships[i];
      if(ship.script) ship.script.$Detectors_QC = false;//this turn off the flag after use
      if(ship.isValid && !ship.docked && ship.equipmentStatus("EQ_Q-CHARGER") === "EQUIPMENT_OK" && ship.equipmentStatus("EQ_FUEL_INJECTION") === "EQUIPMENT_OK" && (ship.equipmentStatus("EQ_ENERGY_UNIT") === "EQUIPMENT_OK" || ship.equipmentStatus("EQ_NAVAL_ENERGY_UNIT") === "EQUIPMENT_OK") && ship.fuel >= 0.1 && ship.energy >= 32 && (!ship.script || ship.script.name !== "rocketships" || ship.script.$RocketShips_RDPause || ship.script.$RocketShips_RDPause <= 0) ) 
         {
	 if(ship.speed > ship.maxSpeed * 0.95 && ship.speed <= ship.maxSpeed) 
	    {
	    ship.velocity = ship.thrustVector;
	    this.qchargerfuelcounters[i] += 1.0;
	    if(this.qchargerfuelcounters[i] > 120.0)// use 0.1 ly of fuel every 30 seconds and at launch to prime the Q-Charger
	       {
               //player.consoleMessage(ship.script.$Detectors_Origname+" Q-Charger ON");
	       this.qchargerfuelcounters[i] = 1.0;
	       ship.fuel -= 0.1;
	       }
	    ship.energy -= 1.0;// use 4 energy per second
            ship.velocity = ship.velocity.add(ship.vectorForward.multiply(ship.maxSpeed));
	    if(ship.isVisible && wdet && player.ship && player.ship.isValid
			&& player.ship.position.distanceTo(ship.position) < 25600)
	          ship.script.$Detectors_QC = true; //inform the player from the usage
//          log("QC",ship.displayName+" "+ship.speed+" "+ship.maxSpeed);
	    }
         }
      }
   
   if(player.ship.docked)
      {
	  if(this.qchargerCheckTimer)
         {
         this.qchargerCheckTimer.stop()
         }
      if(this.qchargercondition === "ON")//shutdown sequence
	     {
	     if(this.mySound1.isPlaying)
            {
            this.mySound1.stop();
            }
         if(this.mySound2.isPlaying)
            {
            this.mySound2.stop();
            }
         if(this.mySound3.isPlaying)
            {
            this.mySound3.stop();
            }
         if(this.mySound4.isPlaying)
            {
            this.mySound4.stop();
            }
         if(this.mySound5.isPlaying)
            {
            this.mySound5.stop();
            }
         if(player.ship.equipmentStatus("EQ_Q-CHARGER") === "EQUIPMENT_OK")
            {
			if(this.togglesoundfx1 === "ON")
               {
		       this.mySound3.play();//v1.2 added toggle check here
		       }
			}
         this.qchargercondition = "OFF";
         }
      }
   else
      { // main script functions
	  if((player.ship.equipmentStatus("EQ_Q-CHARGER") === "EQUIPMENT_OK") && (player.ship.equipmentStatus("EQ_FUEL_INJECTION") === "EQUIPMENT_OK") && ((player.ship.equipmentStatus("EQ_ENERGY_UNIT") === "EQUIPMENT_OK") || (player.ship.equipmentStatus("EQ_NAVAL_ENERGY_UNIT") === "EQUIPMENT_OK")) && (player.ship.fuel >= 0.1) && (player.ship.energy >= 32) && (!player.ship.script || player.ship.script.name !== "rocketships" || player.ship.script.$RocketShips_RDPause || player.ship.script.$RocketShips_RDPause <= 0))
         {		 
         this.qchargerdecision();
	     this.qchargeroperation();
		 return;
		 }
      if(this.qchargercondition === "ON")// shutdown sequence
	     {
	     if(this.mySound1.isPlaying)
            {
            this.mySound1.stop();
            }
         if(this.mySound2.isPlaying)
            {
            this.mySound2.stop();
            }
         if(this.mySound3.isPlaying)
            {
            this.mySound3.stop();
            }
         if(this.mySound4.isPlaying)
            {
            this.mySound4.stop();
            }
         if(this.mySound5.isPlaying)
            {
            this.mySound5.stop();
            }
         if(player.ship.equipmentStatus("EQ_Q-CHARGER") === "EQUIPMENT_OK")
            {
			if(this.togglesoundfx1 === "ON")
               {
		       this.mySound3.play();//v1.2 added toggle check here
		       }
			}
         this.qchargercondition = "OFF";
         }		 
      }
   }

this.shipWillEnterWitchspace = function()
   {
   if(this.qchargerCheckTimer)
      {
      this.qchargerCheckTimer.stop()
      }
   if(this.qchargercondition === "ON")
      {
      if(this.mySound1.isPlaying)
         {
         this.mySound1.stop();
         }
      }
   delete this.qchargerfuelcounters;// start new arrays in the new system
   delete this.qchargerships;
   this.qchargerfuelcounters = [];// array hold fuelcounters to all NPC ships equipped with Q-Charger
   this.qchargerships = [];// array hold all NPC ships equipped with Q-Charger
   }

this.shipExitedWitchspace = function()
   {
   if(this.qchargercondition === "ON")
      {
	  if(this.togglesoundfx1 === "ON")
         {
         this.mySound1.play();//v1.2 added toggle check here
         }
      }		 
   if(this.qchargerCheckTimer)
      {
      this.qchargerCheckTimer.start();
      }
   else
      {
      this.qchargerCheckTimer = new Timer(this, this.qchargerCheck,0,0.25);// check Q-Charger every 0.25 seconds
      }
   }   
   
this.qchargerdecision = function()
   {
   if(this.qchargerenabled && (player.ship.speed > (player.ship.maxSpeed * 0.95)) && (player.ship.speed <= (player.ship.maxSpeed)))
      {
	  if(this.qchargercondition === "OFF")
	     {
		 if(this.togglesoundfx1 === "ON")
            {
			if(!this.mySound1.isPlaying)
			   {
		       this.mySound2.play();
			   this.qchargercounterpowerup = 1.0;
			   }
			if(this.mySound1.isPlaying)
			   {
		       this.mySound4.play();
			   this.qchargercounterpowerup = 0.0;
			   }
		    if(this.mySound3.isPlaying)
               {
               this.mySound3.stop();
			   this.qchargercounterpowerdown = 0.0;			   
               }
			if(this.mySound5.isPlaying)
               {
               this.mySound5.stop();
			   this.qchargercounterpowerdown = 0.0;			   
               }
            }			   
		 }
	  this.qchargercondition = "ON";
	  }
   else
      {
	  if(this.qchargercondition === "ON")
	     {
		 if(this.togglesoundfx1 === "ON")
            {
			if(this.mySound1.isPlaying)
			   {
		       this.mySound3.play();
			   this.qchargercounterpowerdown = 1.0;
			   }
			if(!this.mySound1.isPlaying)
			   {
		       this.mySound5.play();
			   this.qchargercounterpowerdown = 0.0;
			   }
		    if(this.mySound2.isPlaying)
               {
               this.mySound2.stop();
			   this.qchargercounterpowerup = 0.0;
               }
			if(this.mySound4.isPlaying)
               {
               this.mySound4.stop();
			   this.qchargercounterpowerup = 0.0;
               }
            }			   
		 }
	  this.qchargercondition = "OFF";
	  }
   }   
   
this.qchargeroperation = function()
   {
   if(this.qchargercounterpowerup >= 1.0)
      {
	  this.qchargercounterpowerup += 1.0;
	  }
   if(this.qchargercounterpowerdown >= 1.0)
      {
	  this.qchargercounterpowerdown += 1.0;
	  }
   player.ship.velocity = player.ship.thrustVector;
   if(this.qchargercondition === "OFF")
      {
	  if(this.mySound1.isPlaying)
         {
		 if(this.qchargercounterpowerdown >= 12.0)// timing of sound overlap
            {
            this.mySound1.stop();
			this.qchargercounterpowerdown = 0.0;
			}
         }  
	  return;
	  }
   if(this.qchargercondition === "ON")
      {
	  var p = 20 * ( player.ship.speed - 0.95 * player.ship.maxSpeed ) / player.ship.maxSpeed;
	  if( p > 0.9999 ) p = 1; //+100 percent speed at max. throttle
	  else if( p < 0 ) p = 0; //+0 percent speed below 95% throttle
	  this.qchargerpercent = p; //save to NumericHUD
	  this.qchargerfuelcounter += p;
	  if(this.qchargerfuelcounter > 120.0)// use 0.1 ly of fuel every 30 seconds and at launch to prime the Q-Charger
	     {
		 this.qchargerfuelcounter = 1.0;
		 player.ship.fuel -= 0.1;
		 }
	  player.ship.energy -= p;// use 4 energy per second at max. throttle
      player.ship.velocity = player.ship.velocity.add(player.ship.vectorForward.multiply(player.ship.maxSpeed * p));
	  if(this.togglesoundfx1 === "ON")
         {
         if(!this.mySound1.isPlaying)
		    {
			if(this.qchargercounterpowerup >= 24.0)// timing of sound overlap
               {
               this.mySound1.play();
			   this.qchargercounterpowerup = 0.0;
			   }
            }
         }
	  }
   }
 
this.shipDied = function()
   {
   if(this.qchargerCheckTimer)
      {
      this.qchargerCheckTimer.stop()
      }
   if(this.mySound1.isPlaying)
      {
      this.mySound1.stop();
      }
   if(this.mySound2.isPlaying)
      {
      this.mySound2.stop();
      }
   if(this.mySound3.isPlaying)
      {
      this.mySound3.stop();
      }
   if(this.mySound4.isPlaying)
      {
      this.mySound4.stop();
      }
   if(this.mySound5.isPlaying)
      {
      this.mySound5.stop();
      }
   this.qchargercondition = "OFF";
   delete this.qchargerfuelcounters;// start new arrays
   delete this.qchargerships;
   this.qchargerfuelcounters = [];// array hold fuelcounters to all NPC ships equipped with Q-Charger
   this.qchargerships = [];// array hold all NPC ships equipped with Q-Charger
   }	
Scripts/Q-Charger_eq.js
"use strict";
this.name        = "Q-Charger_eq";
this.author      = "Norby";
this.copyright   = "2014 Norbert Nagy";
this.licence     = "CC BY-NC-SA 3.0";
this.description = "Disable Q-Charger";
this.version     = "1.0";

//equipment events
this.activated = function() {
	var w = worldScripts["Q-Charger"];
	if( w.qchargerenabled ) {
		w.qchargerenabled = false;
		player.consoleMessage("Q-Charger disabled.");
	} else { 
		w.qchargerenabled = true;
		player.consoleMessage("Q-Charger enabled!");
	}
}

this.mode = function() {
	//unused
}
Scripts/notforsmall.js
"use strict";
this.name        = "notforsmall";
this.author      = "Norby";
this.copyright   = "2013 Norbert Nagy";
this.licence     = "CC BY-NC-SA 3.0";
this.description = "This equipment can not fit into small ships like the Rocket Fighter.";
this.version     = "1.0";

this.allowAwardEquipment = function(eqKey, ship, context)
{
//bugfix for eqs with conditions scripts: need double replaceShip() to work!
//player.replaceShip(shipname, pers); player.replaceShip(shipname, pers);
//call twice! the first always got false for allow without run this script.
//Proof: if you uncomment the following line, only the 2nd call will write into the log.
//log("notforsmall", eqKey+" "+ship.name+" "+ship.mass+" "+context );

	if( ship.mass >= 30000 ) return true;
	else return false;
}