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

Expansion Laser Cooler

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Turn off and on your hot weapons to attach the Cooler then fire until heat is dissipated. Need much energy, fuel and a ship over 130t mass. Turn off and on your hot weapons to attach the Cooler then fire until heat is dissipated. Need much energy, fuel and a ship over 130t mass.
Identifier oolite.oxp.Norby.Laser_Cooler oolite.oxp.Norby.Laser_Cooler
Title Laser Cooler Laser Cooler
Category Equipment Equipment
Author Norby Norby
Version 1.2 1.2
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Laser_Cooler n/a
Download URL https://wiki.alioth.net/img_auth.php/a/ab/Laser_Cooler_1.2.oxz n/a
License CC BY-NC-SA 4 CC BY-NC-SA 4
File Size n/a
Upload date 1610873407

Documentation

Also read http://wiki.alioth.net/index.php/Laser%20Cooler

Laser_Cooler_readme.txt

Laser Cooler


Turn off and on your weapons (press twice the underscore key) when overheated to attach the Cooler to the current laser, then fire until heat is dissipated.

Do not press the weapons key second time too fast after the first press, else the Cooler can not attach. Must spend about 1/4 sec without weapons to get the "Laser Cooler attached" message, then turn on your weapons again.

The cooler will automatically detach when finished or when 1.0 ly fuel remain only and your laser open fire instantly. Stop cooling when a friendly target is in your crosshairs to avoid accidental hits.

This equipment use very much energy and fuel for cooling and need a ship over 130t mass like a Cobra Mark III. Your cabin temperature will be higher due to the ship take over the heat from the laser.

Your cooler can be attached to one laser at the same time.

You can detach the cooler from your laser anytime by turning off and on your weapons.

The cooler can not start his work until the weapon is in overheat. Usually this is not a noticeable problem, except if you use Laser Cannons with high heat where you probably need to wait a bit or should start cooling one shot before overheat.


License:

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License version 4.0.
If you are re-using any piece of this OXP, please let me know by sending an e-mail to norbylite@gmail.com.

Changelog:
 2020.05.05. v1.2  Fixed integration issues with New Lasers, improved integration with XenonHUD.
 2015.08.01. v1.1  Fuel usage and cabin temp raising added, thanks to avder and Disembodied.
 2015.08.01. v1.0  First release.

Forum:
See this topic: http://bb.aegidian.org/viewtopic.php?f=4&t=17638

Equipment

Name Visible Cost [deci-credits] Tech-Level
Laser Cooler yes 50000 5+
Laser Cooler yes 0 16+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/laser_cooler.js
"use strict";
this.name	= "laser_cooler";
this.author	= "Norby";
this.copyright	= "2015 Norby";
this.description= "laser cooler";
this.licence	= "CC BY-NC-SA 4.0";

//Internal variables, should not touch
this.$FuelPart = 0;
this.$Heat = 0;
this.$Timer = null;
this.$View = null;
this.$WeaponKey = null;
this.$WeaponsOff = false;
this.$WeaponsOn = false;

//worldscript events
this.startUp = function() {
	if( !this.$Timer ) this.$Timer = new Timer(this, this.$Timed.bind(this), 0.25, 0.25);
}

this.shipWillDockWithStation = function() {
	this.$DetachCooler();
}

//Internal functions
this.$DetachCooler = function() {
	var lmss = worldScripts.LMSS_Core; // ** added
	if (lmss) lmss._switching = true;
	if( this.$WeaponKey ) player.ship.currentWeapon = this.$WeaponKey;
	var x = worldScripts.XenonHUD;
	if (x) x.weaponsSystemsToggled(true);
	if (lmss) lmss._switching = false;
	this.$Fuelpart = 0;
	this.$Heat = 0;
	this.$View = null;
	this.$WeaponKey = null;
	this.$WeaponsOff = false;
	this.$WeaponsOn = false;
}

this.$Timed = function() {
	var c = "EQ_WEAPON_LASER_COOLER";
	var p = player.ship;
	if( !p.isValid ) return;
	var k = p.currentWeapon.equipmentKey;
	if( !p.weaponsOnline ) {
		if( p.equipmentStatus("EQ_LASER_COOLER") == "EQUIPMENT_OK" && !this.$WeaponKey
			&& p.laserHeatLevel > 0.6 && k != c ) {
				if( p.fuel <= 1.0 ) {
					player.consoleMessage("Not enough fuel for Laser Cooler");
				} else {
					this.$Fuelpart = 0;
					this.$Heat = p.laserHeatLevel;
					this.$View = p.viewDirection;
					this.$WeaponKey = k;
					this.$WeaponsOff = false;
					this.$WeaponsOn = false;
					log(this.name, "setting " + this.$WeaponKey);
					p.currentWeapon = c;
					player.consoleMessage("Laser Cooler attached, press fire for cooling",5);
				}
		} else if( this.$WeaponKey && this.$WeaponsOn ) this.$WeaponsOff = true;
	} else {
		this.$WeaponsOn = true;
		if( this.$WeaponKey && k == c
			&& ( p.laserHeatLevel < 0.1 || this.$WeaponsOff || p.fuel <= 1.0 )
			&& this.$View == p.viewDirection ) {
				this.$DetachCooler();
				var f = "";
				if( p.fuel <= 1.0 ) f = " due to low fuel"
				player.consoleMessage("Laser Cooler detached"+f, 5);
		}
	}
	if( this.$View == p.viewDirection && k == c ) {
		if( this.$Heat > 0 && this.$Heat > p.laserHeatLevel + 0.01 ) { //detect fast cooling
			p.temperature += 0.035; //increase cabin temp
			this.$FuelPart++;
			if( this.$FuelPart >= 2 ) { //1 mean 0.4 ly/s, 2 mean 0.2 ly/s, 4 mean 0.1 ly/s
				this.$FuelPart = 0;
				p.fuel -= 0.1; //must be at least 0.1 and divisible by 0.1
			}
		}
		this.$Heat = p.laserHeatLevel;//save for the next timer call
	} else this.$Heat = 0;
}
Scripts/lasercooler-conditions.js
"use strict";
this.name	= "lasercooler-conditions";
this.author	= "Norby";
this.copyright   = "2013 Norbert Nagy";
this.licence     = "CC BY-NC-SA 4.0";
this.description = "This equipment is usable only for ships over 130t like the Cobra Mark III.";

this.allowAwardEquipment = function(equipment, ship, context)
{
	// OXP hook to allow stations to forbid specific equipment
	if (context == "purchase" && player.ship.dockedStation && player.ship.dockedStation.scriptInfo["oolite-barred-equipment"])
	{
		if (player.ship.dockedStation.scriptInfo["oolite-barred-equipment"].indexOf(equipment) != -1)
		{
			return false;
		}
	}

	// OXP hook to allow ships to forbid specific "available to all" equipment
	if (ship.scriptInfo && ship.scriptInfo["oolite-barred-equipment"] && ship.scriptInfo["oolite-barred-equipment"].indexOf(equipment) != -1)
	{
		return false;
	}

//	player.consoleMessage( eqKey+" "+ship+" "+context );//debug

	//for large ships only like Cobra Mark III
	if( ship.mass < 130000 ) {
		return false;
	}
	
//	if( equipment == "EQ_WEAPON_LASER_COOLER" && context != "scripted" ) return false;
//	if( equipment == "EQ_WEAPON_LASER_COOLER" ) {
//		log(this.name,  context +" "+equipment+" "+ship);
//		if( context != "scripted" ) return false;
//	}

	return true;
}