Back to Index Page generated: Jun 13, 2026, 7:54:51 PM

Expansion Witch-Charger

Content

Warnings

  1. http://wiki.alioth.net/index.php/Witch-Charger -> 404 Not Found
  2. Low hanging fuit: Information URL exists...

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description This emergency capacitor conducts potential energy from the Witchdrive to shore up shield resistance and prevent equipment damage when hull integrity is critical. If the ship remains under fire, the unit's last-ditch replenishing action will finally drain all fuel. This emergency capacitor conducts potential energy from the Witchdrive to shore up shield resistance and prevent equipment damage when hull integrity is critical. If the ship remains under fire, the unit's last-ditch replenishing action will finally drain all fuel.
Identifier oolite.oxp.Reval.Witch-Charger oolite.oxp.Reval.Witch-Charger
Title Witch-Charger Witch-Charger
Category Equipment Equipment
Author Reval Reval
Version 1.1 1.1
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL https://wiki.alioth.net/index.php/Witch-Charger_OXZ n/a
Download URL https://wiki.alioth.net/img_auth.php/b/b5/Witch-Charger.oxz https://wiki.alioth.net/img_auth.php/b/b5/Witch-Charger.oxz
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1780643267

Relationships Diagram

Documentation

ReadMe.txt

== Life Saving Capacitor ==

A ship's Witchdrive with its Quirium fuel represents a vast reserve of potential energy, essential for forming the brief wormhole that allows entry into Witchspace and transit to another planetary system.

In a recent communiqué, Galcop has reported development and final testing of a means to harness this potential energy for a different purpose. 

Channeled through a Black Labs-designed conduit and capacitor unit, their new defensive asset will shore up shield strength when an enforcement vessel comes under intensive and prolonged laser fire. They have dubbed the new piece of equipment Witch-Charger.

The Witch-Charger unit continuously monitors the ship's hull, shields, and energy status, actuating when one of these enters critical condition. Shield resistance is maintained and shored up during a potentially losing combat situation, but at the expense of the vessel's fuel. 

Eventually the Quirium will deplete itself but, in typical cases, well before the hostile's lasers penetrate the hull.

It has been called by newly-appointed Galcop DCC Dor Reval "a simple trade-off between short-term mobility and survival. In light of our Police Corps' current manpower predicament, this innovation has arrived not a moment too soon."

Equipment

Name Visible Cost [deci-credits] Tech-Level
Witch-Charger yes 7000 3+
Remove Witch-Charger yes 0 1+

Ships

This expansion declares no ships. This may be related to warnings.

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
Scripts/wc_equipment_conditions.js
"use strict";

this.allowAwardEquipment = function(equipment, ship, context) {
	// Remove Auto-SOS conditions
	if (equipment == "EQ_WITCH_CHARGER_REM") 
		if (player.ship.equipmentStatus ("EQ_WITCH_CHARGER") === "EQUIPMENT_OK")
			return true; else return false;

	return true;
}
Scripts/wc_script.js
"use strict";
this.name = "Witch-Charger";
this.author = "Reval";
this.license = "CC-BY-NC-SA 4.0";
this.version = "1.1";
this.description = "This emergency capacitor conducts potential energy from the Witchdrive to shore up shield resistance and prevent equipment damage when hull integrity is critical. If the ship remains under fire, the unit's last-ditch replenishing action will finally drain all fuel.";

// OPTION: Log Witch-Charger quantity stats for each viable 'hit'
this.$log = false;
// OPTION: adjust fuel cost multiplier (default: 0.01)
this.$wcFuelCostMultiplier = 0.01;
// OPTION: adjust shield re-charge factor (default: 1.2)
this.$wcShieldRechargeFactor = 1.2;
// OPTION: adjust energy recharge factor (default: 10.0)
this.$wcEnergyRechargeFactor = 10.0;

/*
	Version 1.1
		In addition to shoring up shields, Charger feeds sufficient energy to prevent core equipment damage.

	Version 1.0
		Added anunciator for cumulative Witchdrive fuel drain.
		Added adjustable W.C. factors / multipliers as options.
		Added witch-drive capacitor 'drain and flow' sound.
		Added use-requirement that player must be 'clean'. 
		Added check for presence of equipment.
		Added check for clean legal record before purchase. 
		Added saving-cutoff for a shield if at full capacity.
		Global flag for status of Witch Charge capacitor (viable or drained)
*/


this.shipTakingDamage = function(amount, whom, type) {
    // Shields absorbed it, no drain needed
    if (amount <= 0) return;
    
	// Proceed only if player's legal status is unsullied
	if (player.legalStatus!=="Clean") return;
    
	// Actuate if unit is installed and not already depleted
    if (!this.$hasWitchCharger || this.$witchChargerEmpty) return;

    var ship = player.ship;
    // Tuned: 0.02 fuel per 1 hull damage
    var fuelCost = amount * this.$wcFuelCostMultiplier; 

    if (ship.fuel >= fuelCost) {
        // THE CONDUIT OPENS
        ship.fuel -= fuelCost; 
        
        // THE CAPACITOR DISCHARGES INTO SHIELDS
        var restoreAmount = amount * this.$wcShieldRechargeFactor; 
        
        // Only restore shields that are below maximum
        if (ship.forwardShield < ship.maxForwardShield) {
            ship.forwardShield = Math.min(ship.forwardShield + restoreAmount, ship.maxForwardShield);
        }
        if (ship.aftShield < ship.maxAftShield) {
            ship.aftShield = Math.min(ship.aftShield + restoreAmount, ship.maxAftShield);
        }
        
		// Restore a fraction of ENERGY (try 10 units per activation)
        ship.energy = Math.min(ship.energy + this.$wcEnergyRechargeFactor, ship.maxEnergy);
    
		// track Witch Charge reserve state
		this.$witchChargerEmpty = (ship.fuel <= 0.0);
		
		// track total cumulative capacitor drain
        this.$wcTFCD += fuelCost;
        
		// drain annunciator
        player.consoleMessage("Witch Charge capacitor drain: "+this.$wcTFCD.toFixed(3), 2);
        
		// sound to reflect capacitor's witch-fuel flow and drain
		this.$witchChargerSound.playSound("breakpattern.ogg");
		
        // log quantities
        this._wcChargeStatus(amount, fuelCost, restoreAmount, this.$wcTFCD);
    
    } else {
        // CAPACITOR EMPTY
        this.$witchChargerEmpty = true;
        player.commsMessage("WITCH CHARGER: RESERVE DEPLETED.");
    }
};   


this._wcChargeStatus = function(damage, cost, restore, drain) {
	var ps = player.ship;
	if (this.$log) {
		this._log("Witch Charger - damage: "+damage);
		this._log("Witch Charger - fuel:   "+ps.fuel);
		this._log("Witch Charger - fuel cost:   "+cost);
		this._log("Witch Charger - total drain:   "+drain);
		this._log("Witch Charger - restored:   "+restore);
		this._log("Witch Charger - energy: "+ps.energy);
		this._log("Witch Charger - f-shield: "+ps.forwardShield);
		this._log("Witch Charger - a-shield: "+ps.aftShield);
		this._log(" "); // section break
	}
}


// Witch-Charger feeds sufficient energy to prevent core equipment damage
this.equipmentDamaged = function(equipmentKey) {
    // A: Repair ONLY the specific item that was just hit (Efficient)
    player.ship.setEquipmentStatus(equipmentKey, "EQUIPMENT_OK");
    
    // B: Loop through ALL equipment and repair anything damaged (Comprehensive)
    // Use only to catch items that might have been damaged in the same hit but didn't trigger the event separately
    /*
    var allEq = player.ship.allEquipment;
    for (var i = 0; i < allEq.length; i++) {
        var eqKey = allEq[i];
        // Check status; if not OK, repair it
        if (player.ship.equipmentStatus(eqKey) !== "EQUIPMENT_OK") {
            player.ship.setEquipmentStatus(eqKey, "EQUIPMENT_OK");
        }
    }
    */
};

   
this.shipWillLaunchFromStation = function() {
	var ps = player.ship;
	this.$hasWitchCharger = (ps.equipmentStatus ("EQ_WITCH_CHARGER") === "EQUIPMENT_OK");
	// re-set key W.C. quantities and flags
	this.$witchChargerEmpty = false;
	this.$wsTFCD = 0.0;
}


this.playerBoughtEquipment = function(equipment, paid) {
	var pc = player.consoleMessage;
	if (equipment == "EQ_WITCH_CHARGER") {		
		pc("Witch Charge capacitor installed. Monitoring.",9);
	} else
	// Service cancellation removal and refund
	if (equipment == "EQ_WITCH_CHARGER_REM") {
		player.ship.removeEquipment("EQ_WITCH_CHARGER");
		player.ship.removeEquipment("EQ_WITCH_CHARGER_REM");
		pc("Witch Charger removed. No refund.",9);
	}
}



// Reset status if player explicitly sells the item via other means
this.playerSoldEquipment = function(equipment) {
    if (equipment.equipmentKey == "EQ_WITCH_CHARGER") {
        this.hasWitchCharger = false;
    }
};


// echo to Oolite log for this script only
this._log = function(msg) {
	log(this.name+".debug", msg);
}


this.startUp = function() {
	// flag to track if the unit is active/installed
	this.$hasWitchCharger = false;
	// flag to track W.C. capacitor state
	this.$witchChargerEmpty = false;
    // Create the SoundSource once
    this.$witchChargerSound = new SoundSource();
	// cumulative capacitor drain
    this.$wcTFCD = 0.0; 
};