Page 1 of 1

Add LuaEntity::unit_health_bonus modifier

Posted: Tue Oct 31, 2023 5:28 pm
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.

Re: Add LuaEntity::unit_health_bonus modifier

Posted: Sun Jan 26, 2025 11:40 am
by cogito123
bump, as still relevant

Re: Add LuaEntity::unit_health_bonus modifier

Posted: Sun Jan 26, 2025 12:54 pm
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.

Re: Add LuaEntity::unit_health_bonus modifier

Posted: Sun Jan 26, 2025 3:15 pm
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.