Difference between revisions of "NPC equipment damage OXP"
Cholmondely (talk | contribs) (Page Created) |
Cholmondely (talk | contribs) m (Tidied page) |
||
Line 1: | Line 1: | ||
− | NPC Equipment Damage 0.2.1 | + | NPC Equipment Damage 0.2.1 by [[User:Ngalo|Ngalo]] |
− | by [[User:Ngalo|Ngalo]] | ||
Does what it says on the tin: allows NPC equipment to get damaged in combat, as much like the core player damage handling as I can manage. | Does what it says on the tin: allows NPC equipment to get damaged in combat, as much like the core player damage handling as I can manage. | ||
+ | |||
Also damages NPC cargo, because Oolite does both with the same code for the player. | Also damages NPC cargo, because Oolite does both with the same code for the player. | ||
Line 8: | Line 8: | ||
Note that such handlers will be called as if they were in the damaged ship's script, not your worldScript. | Note that such handlers will be called as if they were in the damaged ship's script, not your worldScript. | ||
+ | |||
A simple example handler from my NPC Energy Units OXP: | A simple example handler from my NPC Energy Units OXP: | ||
this.NPC_energy_equipmentDamaged = function(equipment) | this.NPC_energy_equipmentDamaged = function(equipment) | ||
− | { | + | |
+ | [blockquote]{ | ||
+ | |||
if (equipment == "EQ_NPC_NAVAL_ENERGY_UNIT") this.ship.energyRechargeRate /= worldScripts.NPC_Energy_Units.NEU_multiplier; | if (equipment == "EQ_NPC_NAVAL_ENERGY_UNIT") this.ship.energyRechargeRate /= worldScripts.NPC_Energy_Units.NEU_multiplier; | ||
+ | |||
if (equipment == "EQ_NPC_ENERGY_UNIT") this.ship.energyRechargeRate /= worldScripts.NPC_Energy_Units.EEU_multiplier; | if (equipment == "EQ_NPC_ENERGY_UNIT") this.ship.energyRechargeRate /= worldScripts.NPC_Energy_Units.EEU_multiplier; | ||
− | |||
− | License | + | }[/blockquote] |
+ | |||
+ | == License == | ||
You may use, adapt, distribute etc. this Oolite Expansion Pack as permitted by the Creative Commons Attribution-NonCommercial-ShareAlike License (CC-BY-NC-SA). | You may use, adapt, distribute etc. this Oolite Expansion Pack as permitted by the Creative Commons Attribution-NonCommercial-ShareAlike License (CC-BY-NC-SA). | ||
− | Version history | + | == Version history == |
− | 0.2.1 Added a small fix which prevents time-wasting if the damaged ship is about to die anyway. | + | *0.2.1 Added a small fix which prevents time-wasting if the damaged ship is about to die anyway. |
− | 0.2 Made use of compatibility improvements in Ship Configuration OXP. | + | *0.2 Made use of compatibility improvements in Ship Configuration OXP. |
− | + | **Prevented the script from trying to damage equipment which is already damaged, or which can't be damaged at all. | |
− | + | *0.1.1 Fixed 'quantity is not defined' bug in cargo damage code | |
− | 0.1.1 Fixed 'quantity is not defined' bug in cargo damage code | + | *0.1 Initial WIP release |
− | 0.1 Initial WIP release |
Revision as of 20:43, 9 December 2020
NPC Equipment Damage 0.2.1 by Ngalo
Does what it says on the tin: allows NPC equipment to get damaged in combat, as much like the core player damage handling as I can manage.
Also damages NPC cargo, because Oolite does both with the same code for the player.
OXP equipment which needs to be disabled by script when damaged can push a handler onto the worldScripts.NPC_Equipment_Damage.NPC_equipmentDamagedHandlers array.
Note that such handlers will be called as if they were in the damaged ship's script, not your worldScript.
A simple example handler from my NPC Energy Units OXP:
this.NPC_energy_equipmentDamaged = function(equipment)
[blockquote]{
if (equipment == "EQ_NPC_NAVAL_ENERGY_UNIT") this.ship.energyRechargeRate /= worldScripts.NPC_Energy_Units.NEU_multiplier;
if (equipment == "EQ_NPC_ENERGY_UNIT") this.ship.energyRechargeRate /= worldScripts.NPC_Energy_Units.EEU_multiplier;
}[/blockquote]
License
You may use, adapt, distribute etc. this Oolite Expansion Pack as permitted by the Creative Commons Attribution-NonCommercial-ShareAlike License (CC-BY-NC-SA).
Version history
- 0.2.1 Added a small fix which prevents time-wasting if the damaged ship is about to die anyway.
- 0.2 Made use of compatibility improvements in Ship Configuration OXP.
- Prevented the script from trying to damage equipment which is already damaged, or which can't be damaged at all.
- 0.1.1 Fixed 'quantity is not defined' bug in cargo damage code
- 0.1 Initial WIP release