Page 1 of 1

Custom bonuses

Posted: Sat Jan 28, 2017 9:00 pm
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.)

Re: Custom bonuses

Posted: Wed Feb 01, 2017 10:17 pm
by aubergine18
Partially related: Ability to define custom bonus equipment types: viewtopic.php?f=28&t=35324