From 39ff471772d5507aec7e51a38f46cc19d776c8ab Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 23 Nov 2021 19:10:26 +0100 Subject: [PATCH] Factorio: add new Recipe Time randomize options --- worlds/factorio/Mod.py | 9 ++++++++- worlds/factorio/Options.py | 14 ++++++++++++- .../data/mod_template/data-final-fixes.lua | 20 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/worlds/factorio/Mod.py b/worlds/factorio/Mod.py index ef9893cb..b47d7ed4 100644 --- a/worlds/factorio/Mod.py +++ b/worlds/factorio/Mod.py @@ -47,6 +47,12 @@ recipe_time_scales = { Options.RecipeTime.option_vanilla: None } +recipe_time_ranges = { + Options.RecipeTime.option_new_fast: (0.25, 2), + Options.RecipeTime.option_new_normal: (0.25, 10), + Options.RecipeTime.option_slow: (5, 10) +} + def generate_mod(world, output_directory: str): player = world.player multiworld = world.world @@ -95,7 +101,8 @@ def generate_mod(world, output_directory: str): "starting_items": multiworld.starting_items[player], "recipes": recipes, "random": random, "flop_random": flop_random, "static_nodes": multiworld.worlds[player].static_nodes, - "recipe_time_scale": recipe_time_scales[multiworld.recipe_time[player].value], + "recipe_time_scale": recipe_time_scales.get(multiworld.recipe_time[player].value, None), + "recipe_time_range": recipe_time_ranges.get(multiworld.recipe_time[player].value, None), "free_sample_blacklist": {item : 1 for item in free_sample_blacklist}, "progressive_technology_table": {tech.name : tech.progressive for tech in progressive_technology_table.values()}, diff --git a/worlds/factorio/Options.py b/worlds/factorio/Options.py index a3ef1162..abce73c5 100644 --- a/worlds/factorio/Options.py +++ b/worlds/factorio/Options.py @@ -99,13 +99,25 @@ class TechTreeInformation(Choice): class RecipeTime(Choice): - """randomize the time it takes for any recipe to craft, this includes smelting, chemical lab, hand crafting etc.""" + """Randomize the time it takes for any recipe to craft, this includes smelting, chemical lab, hand crafting etc. + Fast: 0.25X - 1X + Normal: 0.5X - 2X + Slow: 1X - 4X + Chaos: 0.25X - 4X + New category: ignores vanilla recipe time and rolls new one + New Fast: 0.25 - 2 seconds + New Normal: 0.25 - 10 seconds + New Slow: 5 - 10 seconds + """ displayname = "Recipe Time" option_vanilla = 0 option_fast = 1 option_normal = 2 option_slow = 4 option_chaos = 5 + option_new_fast = 6 + option_new_normal = 7 + option_new_slow = 8 class Progressive(Choice): diff --git a/worlds/factorio/data/mod_template/data-final-fixes.lua b/worlds/factorio/data/mod_template/data-final-fixes.lua index 4b2d67a2..be55d2dc 100644 --- a/worlds/factorio/data/mod_template/data-final-fixes.lua +++ b/worlds/factorio/data/mod_template/data-final-fixes.lua @@ -100,6 +100,20 @@ function adjust_energy(recipe_name, factor) end end +function set_energy(recipe_name, energy) + local recipe = data.raw.recipe[recipe_name] + + if (recipe.normal ~= nil) then + recipe.normal.energy_required = energy + end + if (recipe.expensive ~= nil) then + recipe.expensive.energy_required = energy + end + if (recipe.expensive == nil and recipe.normal == nil) then + recipe.energy_required = energy + end +end + data.raw["assembling-machine"]["assembling-machine-1"].crafting_categories = table.deepcopy(data.raw["assembling-machine"]["assembling-machine-3"].crafting_categories) data.raw["assembling-machine"]["assembling-machine-2"].crafting_categories = table.deepcopy(data.raw["assembling-machine"]["assembling-machine-3"].crafting_categories) data.raw["assembling-machine"]["assembling-machine-1"].fluid_boxes = table.deepcopy(data.raw["assembling-machine"]["assembling-machine-2"].fluid_boxes) @@ -144,6 +158,12 @@ data:extend{new_tree_copy} adjust_energy("{{ recipe_name }}", {{ flop_random(*recipe_time_scale) }}) {%- endif %} {%- endfor -%} +{% elif recipe_time_range %} +{%- for recipe_name, recipe in recipes.items() %} +{%- if recipe.category != "mining" %} +set_energy("{{ recipe_name }}", {{ flop_random(*recipe_time_range) }}) +{%- endif %} +{%- endfor -%} {% endif %} {%- if silo==2 %}