Custom bonuses

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Custom bonuses

Post by Mooncat »

Request: a way to add custom bonus that can be shown on the Bonuses UI. Probably also an API to set custom bonus level for forces.


First of all, thanks again for implementing my request of Customizable technology effect, Rseding. But a few days ago, I realized we will need to show the bonus on the Bonuses UI. So please allow me to make this request.

Here is my idea about the implementation. We will need a new prototype type. I'd call it "custom-bonus", and its structure will be like this:

Code: Select all

{
    type = "custom-bonus",
    name = "player-reach-distance-bonus",
    entities = {"player"}, -- an array of entities that this bonus will apply to. Their icons will be shown on the UI. Bonuses with the same targets will be grouped into the same grid.
    caption = {"reach-distance-bonus"}, -- caption of the bonus name with value, e.g. "Reach distance bonus: __VALUE__", where __VALUE__ will be replaced by the actual value.
    bonuses = {3, 3, 6, 12} -- bonus values of each level. They are accumulative, so Lv1 shows "3", Lv2 shows "6", Lv3 shows "12" and Lv4 shows "24".
}
Then, a new effect type in "technology" prototype:

Code: Select all

effects =
{
    {
        type = "custom-bonus",
        name = "player-reach-distance-bonus",
        level = 3
    }
}
As the result, once this technology is researched, the bonus will be shown on the Bonus UI, like this:
Image
By not implementing the "custom-bonus" directly as a new technology effect type, we will be able to give custom bonuses to forces by ways other than researching technology. E.g. we can give bonus after 1000000 enemies are killed. Tho we will need API for that. E.g. LuaForce::set_custom_bonus_level(name, level)

Code: Select all

name :: string: name of the custom bonus, e.g. "player-reach-distance-bonus"
level :: uint: desired level of the bonus. Setting it to 0 will remove such bonus from the force.
The implementation of the Customizable technology effect will not be wasted. It will still be needed to add bonus on the Technology UI. The request this time affects the Bonus UI only. ;)
(Or if you want to make things simpler, you can also make that "custom-bonus" shows the bonus on the Technology UI. But please keep the previous implementation, in case some technologies don't have bonus to be shown on the Bonuses UI.)

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Custom bonuses

Post by aubergine18 »

Partially related: Ability to define custom bonus equipment types: viewtopic.php?f=28&t=35324
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Post Reply

Return to “Modding interface requests”