Somehow make a shield upgrade research possible

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
AngledLuffa
Fast Inserter
Fast Inserter
Posts: 187
Joined: Fri Jan 05, 2018 5:18 pm
Contact:

Somehow make a shield upgrade research possible

Post by AngledLuffa »

I'm looking at various options for how to add a shield upgrade research mod to factorio. With help of some other commenters, I can think of a few possibilities. Each of them has a limitation which stops it from being used, though. I'd love to have a modding interface change which allows one of more of these possibilities.

- Change the value of existing shield items. The problem here is that items are not modifiable once they are created. So, for example, I can't change energy-shield-mk2-equipment to have a shield value of 165 instead of 150 after finishing one level of the upgrade research. Adding a new bonus for the shield values would make the mod super easy to code. This would probably be the most user friendly, since it would also make it easy to have the new bonus show up in a tooltip.
- Add a new shield item with higher shield values. The limitation here is it can't possibly be made infinite, since you can't dynamically create a new item when a new research is complete. (Adding this functionality would solve my problem.) So I could make energy-shield-mk2-bonus1-equipment, energy-shield-mk2-bonus2-equipment, etc, but eventually the user will run out of research room.
- Calculate how much shielding an armor has and update it using the shield bonus whenever a grid is changed. The issue here is that LuaEquipment and LuaEquipmentGrid have max_shield values which are read-only.

https://lua-api.factorio.com/latest/LuaEquipment.html
https://lua-api.factorio.com/latest/Lua ... tGrid.html

Adding a way to postprocess the total shields on a grid would make it so the armor can be adjusted after on_player_placed_equipment
etc events. Presumably the armor tooltip would show the new maximum value, although the individual shields probably wouldn't using this paradigm.
- Give the damaged entity a "rebate" after taking damage with the on_entity_damaged event. The problem here is I believe it is impossible to tell how much damage was soaked by the shield vs how much went to the entity. For example, if a target takes 200 damage, and you look at the entity and see it has 0 shields left and 100 damage marked on it, you can't tell if it started at max health and the shields soaked 100, leaving 100 to go through the shields, or if the entity started with 50 damage marked on it and the shields had soaked 150. If the on_entity_damaged event had a breakdown of how much damage was soaked by shields, that would make it possible to code this mod. It may also be the simplest change to make to the modding interface, for what it's worth.

TL;DR. Request for one of the following, some of which are probably easier than others:

- built in shield bonus similar to the laser bonus, bullet bonus, etc
- ability to dynamically create a new item, such as energy-shield-mk2-bonusXYZ-equipment
- grid's max_shield field be read/write instead of just read
- on_entity_damaged event reports how much damage was soaked by shields vs. went to the entity

Post Reply

Return to “Modding interface requests”