Back to Index Page generated: Nov 12, 2024, 11:02:04 PM

Expansion Gatling Laser

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Fast laser with internal cooler to be usable soon after overheat. Hold down the fire button when overheated to force the built-in cooler to dissipate the heat as fast as possible. Range is 10km only and need a ship over 130t like Cobra Mark III. Fast laser with internal cooler to be usable soon after overheat. Hold down the fire button when overheated to force the built-in cooler to dissipate the heat as fast as possible. Range is 10km only and need a ship over 130t like Cobra Mark III.
Identifier oolite.oxp.Norby.Gatling_Laser oolite.oxp.Norby.Gatling_Laser
Title Gatling Laser Gatling Laser
Category Equipment Equipment
Author Norby Norby
Version 1.0 1.0
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Gatling_Laser n/a
Download URL https://wiki.alioth.net/img_auth.php/b/b2/Gatling_Laser_1.0.oxz n/a
License CC BY-NC-SA 4 CC BY-NC-SA 4
File Size n/a
Upload date 1610873446

Documentation

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

Equipment

Name Visible Cost [deci-credits] Tech-Level
Gatling Laser yes 250000 12+
Twin Gatling Laser yes 500000 12+
Battle Gatling Laser yes 750000 12+
Behemoth Gatling Laser yes 1000000 12+
Base Gatling Laser yes 1250000 12+
Gatling Laser Cooler yes 0 16+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/gatling_laser-conditions.js
"use strict";
this.name	= "gatling_laser-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_GATLING_LASER_2" && ship.mass < 400000 ) return false;
	if( equipment == "EQ_WEAPON_GATLING_LASER_3" && ship.mass < 800000 ) return false;
	if( equipment == "EQ_WEAPON_GATLING_LASER_4" && ship.mass < 8000000 ) return false;
	if( equipment == "EQ_WEAPON_GATLING_LASER_5" && ship.mass < 200000000 ) return false;
	
//	if( equipment == "EQ_WEAPON_GATLING_LASER_COOLER" && context != "scripted" ) return false;
//	if( equipment == "EQ_WEAPON_GATLING_LASER_COOLER" ) {
//		log(this.name,  context +" "+equipment+" "+ship);
//		if( context != "scripted" ) return false;
//	}

	return true;
}
Scripts/gatling_laser.js
"use strict";
this.name	= "gatling_laser";
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.$Heat = 0;
this.$LastView = null;
this.$Timer = null;
this.$WeaponKey = [];

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

this.startUpComplete = function() {
	var w = worldScripts.LMSS_Core;
	if( w && w._incompatible ) //for Laser Mount Switching System (LMSS)
		w._incompatible.push("EQ_WEAPON_GATLING_LASER_COOLER");
}

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

//Internal functions
this.$DetachCooler = function() {
	var w = this.$WeaponKey["VIEW_AFT"]; if( w ) player.ship.aftWeapon = w;
	w = this.$WeaponKey["VIEW_FORWARD"]; if( w ) player.ship.forwardWeapon = w;
	w = this.$WeaponKey["VIEW_PORT"]; if( w ) player.ship.portWeapon = w;
	w = this.$WeaponKey["VIEW_STARBOARD"]; if( w ) player.ship.starboardWeapon = w;
	this.$Heat = 0;
	this.$WeaponKey = [];
}

this.$Timed = function() {
	var p = player.ship; if( !p.isValid ) return;
	var c = "EQ_WEAPON_GATLING_LASER_COOLER";
	var k = p.currentWeapon.equipmentKey;
	var v = p.viewDirection;
	if( p.laserHeatLevel > 0.75 && k != c && !this.$WeaponKey[v]
		&& k.indexOf("EQ_WEAPON_GATLING_LASER_") == 0
		&& ( v == "VIEW_FORWARD" || v == "VIEW_AFT" //do not attach in external view
			|| v == "VIEW_PORT" || v == "VIEW_STARBOARD" ) ) {
		this.$Heat = p.laserHeatLevel;
		this.$WeaponKey[v] = k;
		p.currentWeapon = c;
//		player.consoleMessage("Gatling Cooler attached");
	} else if( this.$WeaponKey[v] && k == c
		&& ( p.laserHeatLevel < 0.1 || !p.weaponsOnline ) ) {
		p.currentWeapon = this.$WeaponKey[v];
		this.$Heat = 0;
		this.$WeaponKey[v] = null;
//		player.consoleMessage("Gatling Cooler detached");
	}
	if( this.$LastView == v && k == c ) { //detect fast cooling
		if( this.$Heat > 0 && this.$Heat > p.laserHeatLevel + 0.01 ) {
			p.temperature += 0.03; //increase cabin temp
		}
		this.$Heat = p.laserHeatLevel;//save for the next timer call
	} else this.$Heat = 0;
	this.$LastView = v;
}