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