Stellaris

Stellaris

Choosable Repeatables [3.1]
TheFlyingPotato  [developer] 15 May, 2021 @ 5:55am
Modders guide to add compatibility
Welcome! There are 2 parts: first adding code in events (and on_actions) to make the repatables displayed in the config menu and track their levels, and then add the ai weights modifiers in the technologies files.

You can find it in the mod files as "steam_discussion.txt"

First part:
Add the country events (in different files if you want, change the namespaces if needed ofc):
country_event = { id = some_namespace_registration.207 #replace is_triggered_only = yes hide_window = yes immediate = { choosable_repeatables_register_repeatable = { CR_NAME = choosable_repeatable.repeatable.207 # replace by the localisation key holding how your repeatable should be displayed at (name + very small description for example) CR_FLAG = tech_repeatable_weapon_type_kinetic_damage # replace by a UNIQUE flag for that repeatable (1 per repeatable you add) CR_AREA = engineering # the area (physics/society/engineering) CR_DEFAULT_WEIGHT = 1 # the default weight, can be omitted, BUT has to be either (0 to 10, 15, 20, 25, 50, 100) } } } country_event = { id = some_namespace_notify_level_increase.207 #replace is_triggered_only = yes hide_window = yes trigger = { last_increased_tech = tech_repeatable_weapon_type_kinetic_damage # the name of the tech } immediate = { choosable_repeatables_notify_level_increase = { CR_FLAG = tech_repeatable_weapon_type_kinetic_damage # the UNIQUE flag for that repeatable you set above } } } # Here make sure NOT TO FIRE AN INTERMEDIARY EVENT (as this scripted effect needs the FROM) country_event = { id = some_namespace_apply_weights.207 #replace is_triggered_only = yes hide_window = yes trigger = { from = { has_leader_flag = tech_repeatable_weapon_type_kinetic_damage # the UNIQUE flag for that repeatable you set above } } immediate = { choosable_repeatables_apply_weights = { CR_WEIGHT_NAME = tech_repeatable_weapon_type_kinetic_damage_weight # a UNIQUE variable name that will old the weight (you can set it to the same as the flag if you want too) } } }

Now in the on_actions file, you need to subscribe these events to the correct on_actions:
choosable_repeatables_register_repeatable = { events = { some_namespace_registration.207 } } on_tech_increased = { events = { some_namespace_notify_level_increase.207 } } choosable_repeatables_apply_weights = { events = { some_namespace_apply_weights.207 } }

And finally, to add the ai weights in the technology file:
ai_weight = { factor = 1 # or whatever it was modifier = { weight = 0 has_country_flag = choosable_repeatables_initialized check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight # replace each by the UNIQUE variable name you set previously value = 0 } } modifier = { weight = 100 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 1 } } modifier = { weight = 200 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 2 } } modifier = { weight = 300 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 3 } } modifier = { weight = 400 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 4 } } modifier = { weight = 500 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 5 } } modifier = { weight = 600 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 6 } } modifier = { weight = 700 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 7 } } modifier = { weight = 800 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 8 } } modifier = { weight = 900 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 9 } } modifier = { weight = 1000 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 10 } } modifier = { weight = 1500 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 15 } } modifier = { weight = 2000 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 20 } } modifier = { weight = 2500 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 25 } } modifier = { weight = 5000 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 50 } } modifier = { weight = 10000 check_variable = { which = tech_repeatable_weapon_type_kinetic_fire_rate_weight value = 100 } } }

There! Done!
Last edited by TheFlyingPotato; 15 May, 2021 @ 5:56am