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

Expansion Energy Rebalance

Content

Warnings

  1. No version in dependency reference to oolite.oxp.Lone_Wolf.ShieldCycler:null
  2. No version in dependency reference to oolite.oxp.Lone_Wolf.ShieldCyclerNext:null
  3. No version in dependency reference to oolite.oxp.CommonSenseOTB.ShieldEqualizer+Capacitors:null
  4. No version in dependency reference to oolite.oxp.phkb.ShipConfiguration:null
  5. Conflict Expansions mismatch between OXP Manifest and Expansion Manager at character position 0067 (DIGIT ZERO vs LATIN SMALL LETTER N)

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description This OXP rebalances energy between shields and energy banks. If forward/aft shield level dropped below 25% of max capacity, energy from banks is transferred onto shield in question, preventing damage of equipment and cargo. If energy level drops below critical 32 unit level, energy transfer switches back from remaining shields to energy bank. This OXP rebalances energy between shields and energy banks. If forward/aft shield level dropped below 25% of max capacity, energy from banks is transferred onto shield in question, preventing damage of equipment and cargo. If energy level drops below critical 32 unit level, energy transfer switches back from remaining shields to energy bank.
Identifier oolite.oxp.stranger.EnergyRebalance oolite.oxp.stranger.EnergyRebalance
Title Energy Rebalance Energy Rebalance
Category Mechanics Mechanics
Author stranger stranger
Version 0.3.0 0.3.0
Tags shields, energy, damage shields, energy, damage
Required Oolite Version
Maximum Oolite Version
Required Expansions
  • oolite.oxp.CaptMurphy.BreakableEnergyUnit:1.1
  • oolite.oxp.CaptMurphy.BreakableShieldGenerators:1.2
  • oolite.oxp.CaptMurphy.BreakableEnergyUnit:1.1
  • oolite.oxp.CaptMurphy.BreakableShieldGenerators:1.2
  • Optional Expansions
    Conflict Expansions
  • oolite.oxp.Lone_Wolf.ShieldCycler:0
  • oolite.oxp.Lone_Wolf.ShieldCyclerNext:0
  • oolite.oxp.CommonSenseOTB.ShieldEqualizer+Capacitors:0
  • oolite.oxp.phkb.ShipConfiguration:0
  • oolite.oxp.Lone_Wolf.ShieldCycler:
  • oolite.oxp.Lone_Wolf.ShieldCyclerNext:
  • oolite.oxp.CommonSenseOTB.ShieldEqualizer+Capacitors:
  • oolite.oxp.phkb.ShipConfiguration:
  • Information URL http://aegidian.org/bb/viewtopic.php?f=4&t=19567 n/a
    Download URL https://wiki.alioth.net/img_auth.php/d/d6/EnergyRebalance.oxz n/a
    License CC-BY-NC-SA 3.0 CC-BY-NC-SA 3.0
    File Size n/a
    Upload date 1703108124

    Documentation

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

    ReadMe & License.txt

    Energy Rebalance OXP by Stranger
    
    This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license.
    You are free to use and distribute this OXP on non-commercial basis. 
    Rebundling of this OXP within another distribution is permitted as long as it is unchanged.
    Any mods/derivatives of this OXP must be distributed under another names.
    The license information (either as this file or merged into a larger one) must be included in the OXP.
    
    --------------------------------------------------------------
    
    This OXP rebalances energy between shields and energy banks.
    If forward/aft shield level drops below 25% of max capacity under fire, energy from banks transfers directly onto shield in question until energy banks drains under 64 units, preventing damage of equipment and cargo.
    If energy level drops below critical 32 unit level, energy transfer switches back from remaining shields to energy bank.
    Energy Rebalance looks as extremely simplified and fully automated "lite� version of Shield Cycler, but it is not equipment upgrade. It is redefined game mechanics.
    
    Dependencies:
    
    Energy Rebalance OXP requires Breakable Shield Generators & Breakable Energy Unit (author Capt Murphy).
    
    Conflicts:
    
    Energy Rebalance OXP is incompatible with Shield Equaliser+Capacitors (author CommonSense OTB) and with Shield Cycler / Shield Cycler Next (author Lone_Wolf).
    It is also incompatible with Ship Configuration (author phkb).
    
    Installation:
    
    To install package unzip archive, and then move the folder "Energy Rebalance.oxp" to the AddOns directory of your Oolite installation. Then start the game up.
    
    Credits:
    
    Shield Cycler / Shield Cycler Next (Lone_Wolf) - clear formulation of problem with energy damage and working way for fixing it.
    IronHide (Thargoid) - some code tricks (not included onto final code, but very helpful in testing of some ideas).
    
    --------------------------------------------------------------
    
    Version history:
    
    28.02.2019 - Version 0.3.0	Added energy transfer from shields to depleted energy banks.
    				Converted to OXZ.
    10.04.2018 - Version 0.2.1	manifest.plist added
    17.11.2017 - Version 0.2	Breakable Energy Unit dependence added
    04.11.2017 - Version 0.1	Initial release.
    

    Equipment

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

    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/energy_rebalance.js
    "use strict";
    // Standard attributes 
    this.name           = "Energy Rebalance"; 
    this.author         = "Stranger"; 
    this.copyright      = "Stranger";
    this.licence        = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
    this.version        = "0.3.0"; 
    this.description    = "Simple rebalance of default energy distribution between shields and energobanks."; 
    
    this.startUpComplete = this.playerBoughtNewShip = function()
        {
        if(worldScripts["Breakable_Shield_Generators"])
            {
            this.$aftShieldID = worldScripts["Breakable_Shield_Generators"].aftShieldEQ;
            this.$foreShieldID = worldScripts["Breakable_Shield_Generators"].foreShieldEQ;
            }
        if(worldScripts["Breakable_Energy_Unit"])
            {
            this.$energyUnitID = worldScripts["Breakable_Energy_Unit"].energyUnitEQ;
            }
        }
    
    this.shipTakingDamage = function(amount, fromEntity, damageType)	
    	{
        var p = player.ship;
        if(p.equipmentStatus(this.$energyUnitID) !== "EQUIPMENT_OK") return; // needs breakable energy unit
        if(p.fuel == 0) return;   // fuel empty - shields switch to auxiliary battery
        if(p.energy >= 64)      // transfer energy to shields
            {
            var aftShieldDelta;
            var foreShieldDelta;
            if(p.equipmentStatus(this.$aftShieldID) === "EQUIPMENT_OK" && p.aftShield < 0.25 * p.maxAftShield)
                {
                aftShieldDelta = 0.25 * p.maxAftShield - p.aftShield;
                if(aftShieldDelta > 16)
                    {
                    aftShieldDelta = 16;
                    }
                p.aftShield += aftShieldDelta;
                p.energy -= aftShieldDelta;
                }
            if(p.equipmentStatus(this.$foreShieldID) === "EQUIPMENT_OK" && p.forwardShield < 0.25 * p.maxForwardShield)
                {
                foreShieldDelta = 0.25 * p.maxForwardShield - p.forwardShield;
                if(foreShieldDelta > 16)
                    {
                    foreShieldDelta = 16;
                    }        
                p.forwardShield += foreShieldDelta;
                p.energy -= foreShieldDelta;
                }
            }
        else                    // transfer energy from shields
            {
            if(p.energy >= 32) return;
            if(p.aftShield == 0 && p.forwardShield == 0) return;  // both shields completely depleted
            var energyDelta;
            if(p.aftShield >= p.forwardShield)                  // transfer energy from aft shield
                {
                energyDelta = p.aftShield;
                    {                
                    if(energyDelta > 16)
                        {
                        energyDelta = 16;
                        }
                    p.aftShield -= energyDelta;
                    p.energy += energyDelta;
                    }
                }
            else                                                // transfer energy from fore shield
                {
                energyDelta = p.forwardShield;
                    {                
                    if(energyDelta > 16)
                        {
                        energyDelta = 16;
                        }
                    p.forwardShield -= energyDelta;
                    p.energy += energyDelta;
                    }            
                }
            }
    	}