Factorio: add chaos recipe time and use random.triangular distribution

This commit is contained in:
Fabian Dill 2021-06-06 21:38:53 +02:00
parent 403ddd603f
commit 46bb2d1367
4 changed files with 15 additions and 4 deletions

View File

@ -334,6 +334,7 @@ class RecipeTime(Choice):
option_fast = 1 option_fast = 1
option_normal = 2 option_normal = 2
option_slow = 4 option_slow = 4
option_chaos = 5
class FactorioStartItems(OptionDict): class FactorioStartItems(OptionDict):
default = {"burner-mining-drill": 19, "stone-furnace": 19} default = {"burner-mining-drill": 19, "stone-furnace": 19}

View File

@ -85,8 +85,8 @@ table.insert(new_tree_copy.prerequisites, "ap-{{ tech_table[prerequesite] }}-")
{#- add new Technology to game #} {#- add new Technology to game #}
data:extend{new_tree_copy} data:extend{new_tree_copy}
{% endfor %} {% endfor %}
{% if recipe_time %} {% if recipe_time_scale %}
{%- for recipe in recipes %} {%- for recipe in recipes %}
adjust_energy("{{ recipe }}", {{ 0.01 * random.randint(recipe_time*25, recipe_time*100) }}) adjust_energy("{{ recipe }}", {{ random.triangular(*recipe_time_scale) }})
{%- endfor -%} {%- endfor -%}
{% endif %} {% endif %}

View File

@ -55,11 +55,12 @@ tech_tree_layout:
small_funnels: 1 small_funnels: 1
medium_funnels: 1 medium_funnels: 1
large_funnels: 1 large_funnels: 1
recipe_time: recipe_time: # randomize the time it takes for any recipe to craft, this includes smelting, chemical lab, hand crafting etc.
vanilla: 1 vanilla: 1
fast: 0 # 25% to 100% of original time fast: 0 # 25% to 100% of original time
normal: 0 # 50 % to 200% of original time normal: 0 # 50 % to 200% of original time
slow: 0 # 100% to 400% of original time slow: 0 # 100% to 400% of original time
chaos: 0 # 25% to 400% of original time
max_science_pack: max_science_pack:
automation_science_pack: 0 automation_science_pack: 0
logistic_science_pack: 0 logistic_science_pack: 0

View File

@ -30,6 +30,14 @@ base_info = {
"factorio_version": "1.1" "factorio_version": "1.1"
} }
recipe_time_scales = {
# using random.triangular
Options.RecipeTime.option_fast: (0.25, 1),
Options.RecipeTime.option_normal: (0.5, 2, 1),
Options.RecipeTime.option_slow: (1, 4),
Options.RecipeTime.option_chaos: (0.25, 4, 1),
Options.RecipeTime.option_vanilla: None
}
def generate_mod(world: MultiWorld, player: int): def generate_mod(world: MultiWorld, player: int):
global template, locale_template, control_template global template, locale_template, control_template
@ -63,7 +71,8 @@ def generate_mod(world: MultiWorld, player: int):
"rocket_recipe" : rocket_recipes[world.max_science_pack[player].value], "rocket_recipe" : rocket_recipes[world.max_science_pack[player].value],
"slot_name": world.player_names[player][0], "seed_name": world.seed_name, "slot_name": world.player_names[player][0], "seed_name": world.seed_name,
"starting_items": world.starting_items[player], "recipes": recipes, "starting_items": world.starting_items[player], "recipes": recipes,
"recipe_time": world.recipe_time[player], "random": world.random} "random": world.random,
"recipe_time_scale": recipe_time_scales[world.recipe_time[player].value]}
for factorio_option in Options.factorio_options: for factorio_option in Options.factorio_options:
template_data[factorio_option] = getattr(world, factorio_option)[player].value template_data[factorio_option] = getattr(world, factorio_option)[player].value