M1 Shields
Updated for the OSP Faction Update! Please report bugs to @M1 Abrams on the Discord
===================================
This mod comes with the M1 Shield Generator component to demo some of the features. Simply subscribe to this workshop page and you can use it right away in game! Meant for capital ships, it uses 4000 kW that can’t be turned off, takes up a C4 mount, and can absorb 7200 damage with a 10 minute recharge time. (Damage is a combination of armor pen and component damage.) Plasma cannons from OSP deal 5x damage. Modeled by @Eomdor
===================================
This mod contains a script to create your own shield generators to add to the game. Put M1Mods.dll and 0Harmony.dll into your Unity project to use ShieldComponent. There are several options to choose from. You can have the shields recharge, decay, take damage to "shield capacity" (health pool) or take damage to the module itself. Supply your own particle effect that will shoot off like a ricochet would when your shield is hit.
If you make the component a mount, you will see the shield capacity as a cooldown bar just like with jammers, etc. You can choose between having a cooldown cycle or just reaching a minimum of 0 HP and then recharging from there. Be warned, cooldown cycles are slightly bugged in-game: after a cycle, the green bar might not match the true HP of your shield anymore.
But wait, there’s more. Each of the shield’s stats introduces a new stat into the game that you can use to make buffing/nerfing modules. shieldgenerator-shieldcapacity, shieldgenerator-rechargetime, and shieldgenerator-cooldown. [Currently might not work]
Advanced:
In addition, you can supply your own functions for the damage and recharge to override the default behavior. There are two static dictionaries, func_TakeDamage and func_GetRecharge. Use your part’s unique partKey as the key for the dictionary. Supply a Func for the value. You can set these functions in the PostLoad() part of your mod (remember to put this mod higher in the load order).
To set your own damage, use a Func<MunitionHitInfo, IDamageDealer, float>, where the return float is the amount of damage to deal to the shield (and the module itself if you checked that box true). You’re given the data about how the projectile hit your shield and the IDamageDealer that caused the damage. The default damage function is (armor pen ^ 0.25) * (component damage ^ 0.75).
To set the recharge/decay, use a Func<float,float>. Your function is given the value Time.deltaTime, the time taken since the last frame. Return a float that will be added to the shield capacity. The default implementation is the Eve Online shield formula.