NPC Energy Units OXP

From Elite Wiki
(Redirected from NPC Energy Units)

Description

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.$energyUnitDamaged.call(ship.script, 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.

License

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

Aknowledgements

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.

Downloads

The latest version is available on the Expansion Manager and here: NPC Energy Units v1.0.2

Version History

Version 1.0.2 (july/2022):

  • Fixes damage handler exported to NPC Equipment Damage OXP (it's called for any equipment damaged ina NPC, not only energy units, as it formerly expected).
  • Removes some redundant logging messages.
  • Don not award energy units to NPX of low accuracy (less than 0), since they are too green/incompetent to afford them.
  • Reduces the probablities for awarding Naval Energy Units (they should be rare), making sure high recharging rate ships (7 or greater) do not get them.


Version 1.0.1 (december/2020):

  • Adds _alreadyGotOne array (with ships that have high energy recharge rate to emulate an energy unit) for backwards compatibility with Ngalo's version (and used by Military Shields OXP).
  • Changes parameters for granting NEU and EEU to reduce probability of granting to ships with recharge rate above 6.


Version 1.0 (november/2020):

  • Initial version

Quick Facts

Levelindicator5.png
5-{{{2}}}

Minimum Oolite versionCPU usage lowMemory usage lowGPU usage lowisAPIisDocumented

Version Released License Features Category Author(s) Feedback
1.0.2 2022-07-03 CC-BY-SA 4.0 Enables the NPCs energy units Mechanics OXPs Dybal Oolite BB

Gameplay and Balance indicator

Tag-colour-red.png