NPC Energy Units OXP

From Elite Wiki
Revision as of 13:52, 2 December 2020 by Dybal (talk | contribs) (License)


NPC Energy Units OXP aims to make the energy units in NPC ships operational, enhancing the NPCs energy recharge rate.

For those NPC ships created with the energy units, this OXP will enable them by itself, for those ships whose energy units were granted by OXPs after the ship was spawned, this OXP makes available a function for the awarding OXP to call to enable the awarded energy unit.

This OXP also awards energy units (civilian and naval) to NPCs, based on their accuracy (the higher accuracy have greater probability of getting them) and recharge rate (the higher recharge rates have lesse probability of getting the energy units).

Notes for OXP developers

This OXP makes available the following functions:

  • worldScripts.NPC_Energy_Units.$getShipEnergyUnit(ship)
A convenience function that returns the equipment Key for any energy unit installed on the ship, or null if the ship has none.

  • worldScripts.NPC_Energy_Units.$setupEnergyUnits(ship)
Updates the ship's energy recharge rate to the factory value boosted by the energy unit installed, if it's not damaged.
Returns true if the ship's energy recharge was modified and false otherwise.

  • worldScripts.NPC_Energy_Units.$energyUnitDamaged(equipmentKey)
An event handler for damage to energy units, it MUST be called in the context ('this') of the ship's script, as in:
   worldScripts.NPC_Energy_Units.$, equipmentKey)
It restores the ship to its factory energy recharge rate if the equipmentKey is an energy unit and its status in the ship isn't EQUIPMENT_OK: it can be called after an energy unit is removed from the ship to reset its energy recharge rate, but that means that if the ship has a naval energy unit and this function is called with the key for an extra energy unit, the ship's energy recharge rate WILL be reset, rendering the naval energy unit non-functional.
This OXP includes this function in NPC Equipment Damage OXP list of equipment damage handlers if that OXP is installed.


This OXP is licensed under the CC-BY-SA 4.0.


This OXP is based on Ngalo's original NPC Energy Unit.

I would rather have updated the original OXP, but although it had a CC BY-NC-SA, it didn't specify the version, so I opted to write a new one to replace it just to be in safe licensing grounds.