This mod is part of my Mod Pack.
One of this mod's components requires LazyLib to operate. If you don't have LazyLib installed, do so before running this mod.This is a "utility" mod. It does not interfere with the base game in any significant way. It requires LazyLib.
What this does:
For modders, applying
custom damage events that can't be interfered with by others' code can be hard.
This code simplifies that task, by using a method that completely follows the game's core rules, rather than using CombatEngineAPI.applyDamage(), which does not properly interact with "exotic" ship defensive systems, etc., because it
does not have a callback in any mod-accessible code (at this time).
This can mean that one mod's "special defense" interferes with another mod's "special weapon". Naturally, this isn't ideal.
While this code doesn't address the one major case of the Starsector engine's hard-coded use of applyDamage()- to wit, the "flak" weapons that use an AOE hit-detector as well as applyDamage() under the hood, it will address these problems for any mod that wishes to implement their own AOE system (see Vacuum's source, SpecialShotBehaviors.java, for a good example of how to do this cheaply). The next version of the Rebalance Mod series will have a working example to replace the engine's AOE system entirely and an "opt-in", reasonably efficient AOE system available.
To use this code in your mods to address these problems, simply include the JAR in your project like any other JAR and call:
EZ_Damage.DamageThis(ShipAPI owner, WeaponAPI weapon, CombatEntityAPI target, CombatEngineAPI engine, DamageType damageType, Vector2f point, float damage, float emp);You don't need to worry about angles, etc., but you need to provide a point, no further than 200 SU from the object you'd like to damage. A simple example can now be found in Explorer Society's
PlasmaOnHitEffect.java, showing how to do randomized points around the target.
Performance Note: Because of some weird limitations of the engine at this time, EMP requires a separate DamagingProjectileAPI to get created for every 50 points of damage you want to inflict. Generally speaking, you don't want to use this for huge amounts of EMP damage, although the performance hit is relatively modest, as the projectiles last only a couple of gameframes.