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

Expansion Energy Rebalance SCC

Content

Warnings

  1. No version in dependency reference to oolite.oxp.stranger.EnergyRebalance:null
  2. No version in dependency reference to oolite.oxp.Lone_Wolf.ShieldCycler:null
  3. No version in dependency reference to oolite.oxp.Lone_Wolf.ShieldCyclerNext:null
  4. No version in dependency reference to oolite.oxp.CommonSenseOTB.ShieldEqualizer+Capacitors:null
  5. Conflict Expansions mismatch between OXP Manifest and Expansion Manager at character position 0069 (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. Version compatible with Ship Configuration. 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. Version compatible with Ship Configuration.
Identifier oolite.oxp.stranger.EnergyRebalance_SCC oolite.oxp.stranger.EnergyRebalance_SCC
Title Energy Rebalance SCC Energy Rebalance SCC
Category Mechanics Mechanics
Author stranger & phkb stranger & phkb
Version 0.2.0 0.2.0
Tags shields, energy, damage shields, energy, damage
Required Oolite Version
Maximum Oolite Version
Required Expansions
  • oolite.oxp.phkb.ShipConfiguration:1.2.3
  • oolite.oxp.phkb.ShipConfiguration:1.2.3
  • Optional Expansions
    Conflict Expansions
  • oolite.oxp.stranger.EnergyRebalance:0
  • oolite.oxp.Lone_Wolf.ShieldCycler:0
  • oolite.oxp.Lone_Wolf.ShieldCyclerNext:0
  • oolite.oxp.CommonSenseOTB.ShieldEqualizer+Capacitors:0
  • oolite.oxp.stranger.EnergyRebalance:
  • oolite.oxp.Lone_Wolf.ShieldCycler:
  • oolite.oxp.Lone_Wolf.ShieldCyclerNext:
  • oolite.oxp.CommonSenseOTB.ShieldEqualizer+Capacitors:
  • Information URL http://aegidian.org/bb/viewtopic.php?f=4&t=19567 n/a
    Download URL https://wiki.alioth.net/img_auth.php/4/47/EnergyRebalance_SCC.oxz n/a
    License CC-BY-NC-SA 3.0 CC-BY-NC-SA 3.0
    File Size n/a
    Upload date 1610873289

    Documentation

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

    ReadMe & License.txt

    Energy Rebalance SCC (Ship Configuration Compatible) OXP by Stranger & phkb
    
    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. Then forward/aft shield level dropped below 25% of max capacity under fire, energy from banks is transferred directly onto shield in question until energy banks are drained 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.
    Energy Rebalance SCC is version of original Energy Rebalance, adopted by phkb to provide compatibility with Ship Configuration.
    
    Dependencies:
    
    Energy Rebalance SCC OXP requires Ship Configuration (author phkb).
    
    Conflicts:
    
    Energy Rebalance OXP is incompatible with Shield Equaliser+Capacitors (author CommonSense OTB) and with Shield Cycler / Shield Cycler Next (author Lone_Wolf).
    
    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.04.2019 - Version 0.2.0	Added energy transfer from shields to depleted energy banks.
    				Converted to OXZ 
    12.04.2018 - Version 0.1	Reworked version based on original Energy Rebalance
    
    

    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_sc.js
    "use strict";
    // Standard attributes 
    this.name           = "Energy Rebalance SCC"; 
    this.author         = "Stranger & phkb"; 
    this.copyright      = "Stranger";
    this.licence        = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0";
    this.version        = "0.2"; 
    this.description    = "Simple rebalance of default energy distribution between shields and energy banks. Version compatible with Ship Configuration."; 
    
    // this part of original script from Energy Rebalance was modified by phkb to provide compatibility with Ship Configuration
    this.shipLaunchedFromStation = function(station) 
        {
        if(worldScripts.ShipConfiguration_Core)
            {
            var sc = worldScripts.ShipConfiguration_Core;
            var p = player.ship;
            this.$aftShieldID = sc.$equipmentItemInUse("aftshields", p);
            this.$foreShieldID = sc.$equipmentItemInUse("frontshields", p);
            this.$energyUnitID = sc.$equipmentItemInUse("energy", p);
            }
        }
    // original script
    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;
                    }            
                }
            }
    	}