Add LuaEntity::unit_health_bonus modifier

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
cogito123
Inserter
Inserter
Posts: 37
Joined: Thu Feb 28, 2019 7:05 pm
Contact:

Add LuaEntity::unit_health_bonus modifier

Post by cogito123 »

TL;DR
Add unit_health_bonus modifier to unit entities, similar to LuaControler::character_health_bonus
What ?
The unit_health_bonus modifier multiplies biters health and by default is set to float 1.0 (no effect)
Why ?
In biter battles scenario, we implement "boss" mechanics. At the moment a global table is used to store "real" health value which is decreased on every on_entity_damaged event. Each time this event is handled we have to find a force of unit, find it's record and access global table, decide to update health or kill entity. As there are a lot of source of this events (hundreds of turrets and flamers) and multiple bosses, it has been identified as major bottleneck performance wise. This API could help us and others to implement features related to "boss"-like entities without performance hit in soft scenarios.

I figured that you might even have code for such API due to mentioned Quality health bonuses so from my perspective, maintenance of this API should play nicely long-term.
cogito123
Inserter
Inserter
Posts: 37
Joined: Thu Feb 28, 2019 7:05 pm
Contact:

Re: Add LuaEntity::unit_health_bonus modifier

Post by cogito123 »

bump, as still relevant
Rseding91
Factorio Staff
Factorio Staff
Posts: 14953
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Add LuaEntity::unit_health_bonus modifier

Post by Rseding91 »

I don't see this ever happening. Runtime changeable values on entities means they need more memory to store that value, and it must be included in the save file. Both of those have to happen regardless of base game using the values. In the case of characters it doesn't really matter because there's typically 1 of them. In the case of units there are thousands to hundreds of thousands.
If you want to get ahold of me I'm almost always on Discord.
cogito123
Inserter
Inserter
Posts: 37
Joined: Thu Feb 28, 2019 7:05 pm
Contact:

Re: Add LuaEntity::unit_health_bonus modifier

Post by cogito123 »

OK I see. How about more realistic approach with such modifier per force? In that way, you can have thousands of biters share single value. If you want to create a special unit, you assign it to specific force.
Post Reply

Return to “Modding interface requests”