Back to Index Page generated: May 17, 2025, 5:47:49 AM

Expansion Energy Containment Unit

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Energy Containment Unit enhancements to Standard Equipment available to buy. Energy Containment Unit enhancements to Standard Equipment available to buy.
Identifier oolite.oxp.mils32k.EnergyContainmentUnit oolite.oxp.mils32k.EnergyContainmentUnit
Title Energy Containment Unit Energy Containment Unit
Category Misc Misc
Author mlewissmith mlewissmith
Version 1.0.0 1.0.0
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL https://wiki.alioth.net/index.php/Energy_Containment_Unit_OXP n/a
Download URL https://wiki.alioth.net/img_auth.php/c/c1/Oolite.oxp.mils32k.EnergyContainmentUnit.oxz n/a
License UNLICENSE UNLICENSE
File Size n/a
Upload date 1741016457

Documentation

Also read http://wiki.alioth.net/index.php/Energy%20Containment%20Unit

README.md

# Energy Containment Unit OXP

Energy Containment Unit enhancements to
[Standard Equipment](https://wiki.alioth.net/index.php/Oolite_Equipment)
- Temporary invulnerability to lasers
- Temporary forward weapon cooling

## Overview

This OXP provides equipment
- **Shield Boosters ECU**
- **Shield Boosters ECU License**
- **Forward Weapon ECU**
- **Forward Weapon ECU License**

An experienced pilot with a clean licence, who has earned enough money to buy
standard [Shield Boosters](https://wiki.alioth.net/index.php/Shield_Boosters),
may also purchase an Energy Containment Unit addon. The **Shield Boosters ECU**
absorbs the energy of incoming laser fire and redistributes it to power the
shields. However, use of such equipment requires a licence and is a
one-time-only event, valid for one "flight" ie until next hyperspace jump or
next dock, after which the licence expires and must be re-purchased.

Similarly, the **Forward Weapon ECU** absorbs the heat energy of outgoing laser
fire and prevents the weapon from overheating. It applies only to the forward
weapon, and only to
[Pulse](https://wiki.alioth.net/index.php/Pulse_Laser) /
[Beam](https://wiki.alioth.net/index.php/Beam_Laser) /
[Mining](https://wiki.alioth.net/index.php/Mining_Laser) /
[Military](https://wiki.alioth.net/index.php/Military_Laser)
lasers. Again, in order to
purchase the ECU or license, the pilot must have a clean record, and the
activation is only valid until the next dock or jump.


## Availability

### **Shield Boosters ECU**
    Cost:      4,900 Cr
    Techlevel: 12
  - Requires clean status to purchase
  - Requires [Shield Boosters](https://wiki.alioth.net/index.php/Shield_Boosters) to purchase
  - Requires **Shield Boosters ECU Licence** to activate
  - Once activated, player's ship is **immune to lasers**. Energy from incoming laser fire is absorbed and used to charge ship's shields.

### **Shield Booster ECU Licence**
    Cost:      150 Cr
    Techlevel: 4
  - Requires clean status to purchase.
  - Required to activate **Shield Boosters ECU**.
  - Single use license: activation lasts
    - until next dock
    - until next hyperspace jump

### **Forward Weapon ECU**
    Cost:      2,000 Cr
    Techlevel: 12
  - Requires clean status to purchase.
  - Requires [Pulse Laser](https://wiki.alioth.net/index.php/Pulse_Laser) /
    [Beam Laser](https://wiki.alioth.net/index.php/Beam_Laser) /
    [Mining Laser](https://wiki.alioth.net/index.php/Mining_Laser) /
    [Military Laser](https://wiki.alioth.net/index.php/Military_Laser)
    mounted in forward position to purchase.
  - Requires **Forward Weapon ECU Licence** to activate.
  - Once activated, player's foward weapon **does not overheat**.
    Use of the ECU with any non-standard forward weapon will damage the ECU.

### **Forward Weapon ECU Licence**
    Cost:      250 Cr
    Techlevel: 4
  - Requires clean status to purchase.
  - Required to activate **Forward Weapon ECU**.
  - Single use license: activation lasts
    - until next dock
    - until next hyperspace jump

## Download
  - [EnergyContainmentUnit.oxz](https://wiki.alioth.net/img_auth.php/c/c1/Oolite.oxp.mils32k.EnergyContainmentUnit.oxz)
    from Oolite Wiki
  - [Releases](https://github.com/mlewissmith/oolite.oxp.mils32k.EnergyContainmentUnit/releases)
    from github

## Links
  - [BB thread](https://bb.oolite.space/viewtopic.php?t=21755)
  - Source, version archive, changelog on [github](https://github.com/mlewissmith/oolite.oxp.mils32k.EnergyContainmentUnit)
  - OXP wiki page: [Energy Containment Unit OXP](https://wiki.alioth.net/index.php/Energy_Containment_Unit_OXP)
  - OXZ file page: [File:Oolite.oxp.mils32k.EnergyContainmentUnit.oxz](https://wiki.alioth.net/index.php/File:Oolite.oxp.mils32k.EnergyContainmentUnit.oxz)

-------------------------------------------------------------------------------

Inspired by [invulnerability to lasers](https://bb.oolite.space/viewtopic.php?p=284994#p284994)
discussion referenced at https://wiki.alioth.net/index.php/Cheating

Equipment

Name Visible Cost [deci-credits] Tech-Level
Forward Weapon ECU yes 20000 12+
Forward Weapon ECU Licence yes 2500 4+
Remove Forward Weapon ECU no 0 12+
Shield Boosters ECU yes 49000 12+
Shield Boosters ECU Licence yes 1500 4+
Remove Shield Boosters ECU no 0 12+
ECU Enhanced Beam Laser yes 0 1+
ECU Enhanced Military Laser yes 0 1+
ECU Enhanced Mining Laser yes 0 1+
ECU Enhanced Pulse Laser yes 0 1+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/EQ_ECU_FORWARDWEAPON.conditions.js
// -*- javascript -*-
// https://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_Condition_scripts

"use strict";

this.name        = "oolite.oxp.mils32k.EnergyContainmentUnit:EQ_ECU_FORWARDWEAPON.conditions";
this.author      = "mlewissmith";
this.copyright   = "(C) 2024 mlewissmith";
this.licence     = "UNLICENSE";
this.description = "Energy Containment Unit enhancements to Standard Equipment available to buy.";
this.version     = "1.0.0";

////////////////////////////////////////////////////////////////////////////////
// Debuggery

this.$debug_enabled   = false;
this._log             = function(log_message) { log(this.name, log_message) }
this._debug           = function(debug_message) { if (this.$debug_enabled) this._log(debug_message) }

////////////////////////////////////////////////////////////////////////////////
// Internals

this.$worldscriptName = "oolite.oxp.mils32k.EnergyContainmentUnit:ForwardWeaponECU";
this.$worldscript     = worldScripts[this.$worldscriptName];

////////////////////////////////////////////////////////////////////////////////
// Event handlers

this.allowAwardEquipment = function(equipmentKey, ship, context) {
    var allowedContext = ( context == "purchase" || context == "scripted" );
    var validWeapon = this.$worldscript._forwardWeaponECU();
    if ( allowedContext && validWeapon ) {
        return true;
    }
    return false;
}
Scripts/EQ_ECU_FORWARDWEAPON_LICENCE.js
// -*- javascript -*-
// https://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_Equipment_scripts

"use strict";

this.name        = "oolite.oxp.mils32k.EnergyContainmentUnit:EQ_ECU_FORWARDWEAPON_LICENCE";
this.author      = "mlewissmith";
this.copyright   = "(C) 2024 mlewissmith";
this.licence     = "UNLICENSE";
this.description = "Energy Containment Unit enhancements to Standard Equipment available to buy.";
this.version     = "1.0.0";

////////////////////////////////////////////////////////////////////////////////
// Debuggery

this.$debug_enabled   = false;
this._log             = function(log_message) { log(this.name, log_message) }
this._debug           = function(debug_message) { if (this.$debug_enabled) this._log(debug_message) }

////////////////////////////////////////////////////////////////////////////////
// Internals

this.$worldscriptName = "oolite.oxp.mils32k.EnergyContainmentUnit:ForwardWeaponECU";
this.$worldscript     = worldScripts[this.$worldscriptName];

////////////////////////////////////////////////////////////////////////////////
// Event handlers

this.activated = function() {
    this.$worldscript._activateECU();
}

this.mode = function() {
    this._debug( "mode()" );
    this._debug( "name        : " + this.name );
    this._debug( "author      : " + this.author );
    this._debug( "copyright   : " + this.copyright );
    this._debug( "license     : " + this.license );
    this._debug( "description : " + this.description );
    this._debug( "version     : " + this.version );
    this._debug( "EQ_ECU_FORWARDWEAPON_LICENCE:" + (this.$worldscript.$active ? "ACTIVE" : "INACTIVE") );
}
Scripts/EQ_ECU_SHIELDBOOSTERS_LICENCE.js
// -*- javascript -*-
// https://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_Equipment_scripts

"use strict";

this.name        = "oolite.oxp.mils32k.EnergyContainmentUnit:EQ_ECU_SHIELDBOOSTERS_LICENCE";
this.author      = "mlewissmith";
this.copyright   = "(C) 2024 mlewissmith";
this.licence     = "UNLICENSE";
this.description = "Energy Containment Unit enhancements to Standard Equipment available to buy.";
this.version     = "1.0.0";

////////////////////////////////////////////////////////////////////////////////
// Debuggery

this.$debug_enabled   = false;
this._log             = function(log_message) { log(this.name, log_message) }
this._debug           = function(debug_message) { if (this.$debug_enabled) this._log(debug_message) }

////////////////////////////////////////////////////////////////////////////////
// Internals

this.$worldscriptName = "oolite.oxp.mils32k.EnergyContainmentUnit:ShieldBoostersECU";
this.$worldscript     = worldScripts[this.$worldscriptName];

////////////////////////////////////////////////////////////////////////////////
// Event handlers

this.activated = function() {
    this.$worldscript._activateECU();
}

this.mode = function() {
    this._debug( "mode()" );
    this._debug( "name        : " + this.name );
    this._debug( "author      : " + this.author );
    this._debug( "copyright   : " + this.copyright );
    this._debug( "license     : " + this.license );
    this._debug( "description : " + this.description );
    this._debug( "version     : " + this.version );
    this._debug( "EQ_ECU_SHIELDBOOSTERS_LICENCE:" + (this.$worldscript.$active ? "ACTIVE" : "INACTIVE") );
}
Scripts/EQ_WEAPON_ECU.conditions.js
// -*- javascript -*-
// https://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_Condition_scripts

"use strict";

this.name        = "oolite.oxp.mils32k.EnergyContainmentUnit:EQ_WEAPON_ECU.conditions";
this.author      = "mlewissmith";
this.copyright   = "(C) 2024 mlewissmith";
this.licence     = "UNLICENSE";
this.description = "Energy Containment Unit enhancements to Standard Equipment available to buy.";
this.version     = "1.0.0";

////////////////////////////////////////////////////////////////////////////////
// Debuggery

this.$debug_enabled   = false;
this._log             = function(log_message) { log(this.name, log_message) }
this._debug           = function(debug_message) { if (this.$debug_enabled) this._log(debug_message) }

////////////////////////////////////////////////////////////////////////////////
// Event handlers

this.allowAwardEquipment = function(equipmentKey, ship, context) {
    this._debug( "allowAwardEquipment(" + equipmentKey + "," + ship + "," + context + ")" );

    // equipment TL99 is deprecated
    // not fully sure what's going on here...
    // 'context' always seems to be 'purchase' despite call from script 'ForwardWeaponECU.js/_activateECU()'
    // ... anyway, we don't allow sale at _any_ stations.
    // EQ_WEAPON_ECU_XX_LASER must be swapped by activating EQ_ECU_FORWARDWEAPON
    return player.ship.dockedStation?false:true;
}
Scripts/ForwardWeaponECU.js
// -*- javascript -*-
// https://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_World_script_event_handlers

"use strict";

this.name        = "oolite.oxp.mils32k.EnergyContainmentUnit:ForwardWeaponECU";
this.author      = "mlewissmith";
this.copyright   = "(C) 2024 mlewissmith";
this.licence     = "UNLICENSE";
this.description = "Energy Containment Unit enhancements to Standard Equipment available to buy.";
this.version     = "1.0.0";

////////////////////////////////////////////////////////////////////////////////
// Debuggery

this.$debug_enabled = false;
this._log           = function(log_message) { log(this.name, log_message) }
this._debug         = function(debug_message) { if (this.$debug_enabled) this._log(debug_message) }

////////////////////////////////////////////////////////////////////////////////
// Internals

this.$active = false;
this.$forwardWeapon = null;

this._forwardWeaponECU = function() {
    var weaponTable = {
        "EQ_WEAPON_PULSE_LASER":"EQ_WEAPON_ECU_PULSE_LASER",
        "EQ_WEAPON_BEAM_LASER":"EQ_WEAPON_ECU_BEAM_LASER",
        "EQ_WEAPON_MINING_LASER":"EQ_WEAPON_ECU_MINING_LASER",
        "EQ_WEAPON_MILITARY_LASER":"EQ_WEAPON_ECU_MILITARY_LASER",
    }
    var forwardWeaponKey = player.ship.forwardWeapon.equipmentKey;
    var forwardWeaponECU = weaponTable[forwardWeaponKey];
    return forwardWeaponECU
}

this._activateECU = function() {
    if ( !this.$active ) {
        this._debug( "_activateECU()" );

        var forwardWeaponECU = this._forwardWeaponECU();
        if (forwardWeaponECU) {
            this.$forwardWeapon = player.ship.forwardWeapon.equipmentKey;
            player.ship.forwardWeapon = forwardWeaponECU;
            player.ship.crosshairs = "ForwardWeaponECU.crosshairs.plist";
            player.consoleMessage("Forward Weapon ECU: activated");
            this.$active = true;
        } else {
            player.ship.setEquipmentStatus("EQ_ECU_FORWARDWEAPON", "EQUIPMENT_DAMAGED");
            return false;
        }
    }
}

this._deactivateECU = function() {
    if ( this.$active ) {
        this._debug( "_deactivateECU()" );

        player.ship.forwardWeapon = this.$forwardWeapon;
        this.$forwardWeapon = null;
        player.ship.crosshairs = null;
        player.consoleMessage("Forward Weapon ECU: deactivated");
        this.$active = false;
    }
}

this._loseLicence = function() {
    player.ship.removeEquipment("EQ_ECU_FORWARDWEAPON_LICENCE");
}

this._expireActiveLicence = function() {
    if ( this.$active ) {
        this._deactivateECU();
        this._loseLicence();
        player.consoleMessage("Forward Weapon ECU: licence expired");
    }
}

////////////////////////////////////////////////////////////////////////////////
// Event handlers : startup

this.startUp = function() {
    this._debug( "startUp()" );
    this._debug( "name        : " + this.name );
    this._debug( "author      : " + this.author );
    this._debug( "copyright   : " + this.copyright );
    this._debug( "license     : " + this.license );
    this._debug( "description : " + this.description );
    this._debug( "version     : " + this.version );
}

this.startUpComplete = function() {
    this._debug( "startUpComplete()" );
}

////////////////////////////////////////////////////////////////////////////////
// Event handlers : end-of-flight

this.shipWillDockWithStation = function(station) {
    this._expireActiveLicence();
}

this.shipWillEnterWitchspace = function(cause, destination) { // API 1.81
    this._expireActiveLicence();
}

////////////////////////////////////////////////////////////////////////////////
// Event handlers : equipment add/remove

this.equipmentAdded = function(equipmentKey) { // API 1.81
    this._debug( "equipmentAdded(" + equipmentKey + ")" );
}

this.equipmentDamaged = function(equipmentKey) {
    this._debug( "equipmentDamaged(" + equipmentKey + ")" );

    if (equipmentKey == "EQ_ECU_FORWARDWEAPON") {
        this._expireActiveLicence();
        this._loseLicence();
    }
}

this.equipmentRemoved = function(equipmentKey) { // API 1.81
    this._debug( "equipmentRemoved(" + equipmentKey + ")" );
}

this.playerBoughtEquipment = function(equipment, paid) { // API 1.89
    this._debug( "playerBoughtEquipment(" + equipment + "," + paid + ")" );

    if (equipment == "EQ_ECU_FORWARDWEAPON_REMOVAL") {
        var credits = EquipmentInfo.infoForKey("EQ_ECU_FORWARDWEAPON").price * 0.1;
        var refundPc = 0.6;
        var refundCredits = credits * refundPc;

        this._loseLicence();
        player.ship.removeEquipment("EQ_ECU_MILITARY_LASER");
        player.ship.removeEquipment("EQ_ECU_MILITARY_LASER_REMOVAL");
        player.credits += refundCredits;
    }
}
Scripts/ShieldBoostersECU.js
// -*- javascript -*-
// https://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_World_script_event_handlers
//
// Inspired by discussion at https://bb.oolite.space/viewtopic.php?p=284994#p284994
// Original source released to public domain by 'hulo'

"use strict";

this.name        = "oolite.oxp.mils32k.EnergyContainmentUnit:ShieldBoostersECU";
this.author      = "mlewissmith";
this.copyright   = "(C) 2024 mlewissmith";
this.licence     = "UNLICENSE";
this.description = "Energy Containment Unit enhancements to Standard Equipment available to buy.";
this.version     = "1.0.0";

////////////////////////////////////////////////////////////////////////////////
// Debuggery

this.$debug_enabled = false;
this._log           = function(log_message) { log(this.name, log_message) }
this._debug         = function(debug_message) { if (this.$debug_enabled) this._log(debug_message) }

////////////////////////////////////////////////////////////////////////////////
// Internals

this.$active = false;

this._activateECU = function() {
    if ( !this.$active ) {
        this.$active = true;
        this._debug( "_activateECU()" );
        player.consoleMessage("Shield Boosters ECU: activated");
    }
}

this._deactivateECU = function() {
    if ( this.$active ) {
        this.$active = false;
        this._debug( "_deactivateECU()" );
        player.consoleMessage("Shield Boosters ECU: deactivated");
    }
}

this._loseLicence = function() {
    player.ship.removeEquipment("EQ_ECU_SHIELDBOOSTERS_LICENCE");
}

this._expireActiveLicence = function() {
    if ( this.$active ) {
        this._deactivateECU();
        this._loseLicence();
        player.consoleMessage("Shield Boosters ECU: licence expired");
    }
}

this._handleECU = function() {
    if ( this.$active ) {
        player.ship.aftShield     = player.ship.maxAftShield;
        player.ship.forwardShield = player.ship.maxForwardShield;
    }
}

////////////////////////////////////////////////////////////////////////////////
// Event handlers : startup

this.startUp = function() {
    this._debug( "startUp()" );
    this._debug( "name        : " + this.name );
    this._debug( "author      : " + this.author );
    this._debug( "copyright   : " + this.copyright );
    this._debug( "license     : " + this.license );
    this._debug( "description : " + this.description );
    this._debug( "version     : " + this.version );
}

this.startUpComplete = function() {
    this._debug( "startUpComplete()" );
}

////////////////////////////////////////////////////////////////////////////////
// Event handlers : combat

this.shipBeingAttacked = function(whom) {
    this._handleECU()
}

this.shipBeingAttackedByCloaked = function() {
    this._handleECU()
}

////////////////////////////////////////////////////////////////////////////////
// Event handlers : end-of-flight

this.shipWillDockWithStation = function(station) {
    this._expireActiveLicence();
}

this.shipWillEnterWitchspace = function(cause, destination) { // API 1.81
    this._expireActiveLicence();
}

////////////////////////////////////////////////////////////////////////////////
// Event handlers : equipment add/remove

this.equipmentAdded = function(equipmentKey) { // API 1.81
    this._debug( "equipmentAdded(" + equipmentKey + ")" );
}

this.equipmentDamaged = function(equipmentKey) {
    this._debug( "equipmentDamaged(" + equipmentKey + ")" );

    if (equipmentKey == "EQ_SHIELD_BOOSTER") {
        player.ship.setEquipmentStatus("EQ_ECU_SHIELDBOOSTERS", "EQUIPMENT_DAMAGED");
    }

    if (equipmentKey == "EQ_ECU_SHIELDBOOSTERS") {
        this._expireActiveLicence();
        this._loseLicence();
    }
}

this.equipmentRemoved = function(equipmentKey) { // API 1.81
    this._debug( "equipmentRemoved(" + equipmentKey + ")" );
}

this.playerBoughtEquipment = function(equipment, paid) { // API 1.89
    this._debug( "playerBoughtEquipment(" + equipment + "," + paid + ")" );

    if (equipment == "EQ_ECU_SHIELDBOOSTERS_REMOVAL") {
        var credits = EquipmentInfo.infoForKey("EQ_ECU_SHIELDBOOSTERS").price * 0.1;
        var refundPc = 0.6;
        var refundCredits = credits * refundPc;

        this._loseLicence();
        player.ship.removeEquipment("EQ_ECU_SHIELDBOOSTERS");
        player.ship.removeEquipment("EQ_ECU_SHIELDBOOSTERS_REMOVAL");
        player.credits += refundCredits;
    }
}