[WIP] NPC Energy Units

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

Post Reply
Ngalo
Competent
Competent
Posts: 58
Joined: Mon Mar 02, 2015 2:08 pm
Location: drifting in remLock mask near Vezadi Station

[WIP] NPC Energy Units

Post by Ngalo »

Having made N-Shields, I realised it's a bit unfair to give NPCs proper Military Shield Enhancers without any chance of an Extra or Naval Energy Unit.

Download this OXZ to fix that.

Energy units are allocated based on accuracy and equipment; you shouldn't see anyone with a Naval Energy Unit unless you also have Skilled NPCs OXP.

Note that exclusion of ships which already have 'simulated' EEUs or NEUs in their shipdata depends on a list in the script. Currently this list is:

Code: Select all

this._alreadyGotOne = {
			"cobramk1-alt": "EQ_NPC_ENERGY_UNIT",
			"jaguar_company_patrol": "EQ_NPC_NAVAL_ENERGY_UNIT",
			"jaguar_company_patrol_scuffed": "EQ_NPC_NAVAL_ENERGY_UNIT",
			"jaguar_company_ship_splinter": "EQ_NPC_NAVAL_ENERGY_UNIT"
			}
If you know of any other shipdata keys which need to be on this list, please post them here.
Equal Rights for NPCs!
Rustem
Deadly
Deadly
Posts: 170
Joined: Mon May 25, 2015 5:23 pm
Location: Russia

Re: [WIP] NPC Energy Units

Post by Rustem »

Hi!

1. This ships has single energy unit or simulated the Extra Energy Unit(EEU) or may be awarded NPC-EEU?:
contractor-pirate : 7
...
caduceus-alpha : 5.8
caduceus-omega : 5.8
...
kirin-hunter : 6.0
kirin-m-hunter : 6.0
kirin-xm-pirate : 6.0
kirin-cv : 5.5
...
rhs_big_boss_supercobra_spacelane_shipset : 7
rhs_big_boss_supercobra_spacelane_AP_shipset : 7
kirin-m-police : 6.0
...
viper-interceptor : 6
griff_viper_interceptor_alt : 6
The format of data: shipKey : energy_recharge_rate

2. This code working?:

Code: Select all

this.NPC_energy_equipmentDamaged = function(equipment) {...}
It is experimental OXP?: worldScripts.NPC_Equipment_Damage.
dybal
---- E L I T E ----
---- E L I T E ----
Posts: 466
Joined: Mon Feb 10, 2020 12:47 pm

[RELEASE] NPC Energy Units v1.0

Post by dybal »

[EliteWiki] NPC Energy Units OXP v1.0 is avalibale on the Expansion Manager an here.

NPC Energy Units
v1.0, by Dybal

NPC Energy Units makes the Extra Energy Units and Naval Energy Units installed in NPCs functional, enhancing their 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.


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.


License

This work is released under the Creative Commons Attribution - Non-Commercial - Share Alike 4.0 (CC BY-NC-SA 4.0)
(https://creativecommons.org/licenses/by-nc-sa/4.0/)


Version History


Version 1.0 (november/2020):

* Initial version
dybal
---- E L I T E ----
---- E L I T E ----
Posts: 466
Joined: Mon Feb 10, 2020 12:47 pm

[RELEASE] NPC Energy Units OXP, v1.0.1

Post by dybal »

[EliteWiki] NPC Energy Units OXP v1.0.1 is available on the Expansion Manager and here.

Changes
  • 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, thanks to montana05 for the heads up!).
  • Changes parameters for granting NEU and EEU to reduce probability of granting to ships with recharge rate above 6.
Players tha play fugitive, beware: since the police has higher than average accuracy (which makes sense, being pros), many of them will have EEU and even NEU, so the Vipers will be much thougher with this OXP - there will be plenty of Viper Interceptors with energy recharge rate in the 10 ballpark...
Post Reply