diff --git a/Options.py b/Options.py index ca653bd3..e362f471 100644 --- a/Options.py +++ b/Options.py @@ -329,6 +329,11 @@ class Visibility(Choice): option_sending = 1 default = 1 +class RecipeTime(Choice): + option_vanilla = 0 + option_fast = 1 + option_normal = 2 + option_slow = 4 class FactorioStartItems(OptionDict): default = {"burner-mining-drill": 19, "stone-furnace": 19} @@ -340,7 +345,8 @@ factorio_options: typing.Dict[str, type(Option)] = {"max_science_pack": MaxScien "free_samples": FreeSamples, "visibility": Visibility, "random_tech_ingredients": Toggle, - "starting_items": FactorioStartItems} + "starting_items": FactorioStartItems, + "recipe_time": RecipeTime} class AdvancementGoal(Choice): diff --git a/data/factorio/mod_template/data-final-fixes.lua b/data/factorio/mod_template/data-final-fixes.lua index b46a43af..75464b35 100644 --- a/data/factorio/mod_template/data-final-fixes.lua +++ b/data/factorio/mod_template/data-final-fixes.lua @@ -49,6 +49,14 @@ function copy_factorio_icon(tech, tech_source) tech.icon_size = table.deepcopy(technologies[tech_source].icon_size) end +function adjust_energy(recipe_name, factor) + local energy = data.raw.recipe[recipe_name].energy_required + if (energy == nil) then + energy = 1 + end + data.raw.recipe[recipe_name].energy_required = energy * factor +end + table.insert(data.raw["assembling-machine"]["assembling-machine-1"].crafting_categories, "crafting-with-fluid") {# each randomized tech gets set to be invisible, with new nodes added that trigger those #} @@ -76,5 +84,9 @@ table.insert(new_tree_copy.prerequisites, "ap-{{ tech_table[prerequesite] }}-") {% endif -%} {#- add new Technology to game #} data:extend{new_tree_copy} - -{% endfor %} \ No newline at end of file +{% endfor %} +{% if recipe_time %} +{%- for recipe in recipes %} +adjust_energy("{{ recipe }}", {{ 0.01 * random.randint(recipe_time*25, recipe_time*100) }}) +{%- endfor -%} +{% endif %} \ No newline at end of file diff --git a/playerSettings.yaml b/playerSettings.yaml index 7ad7c495..9567866e 100644 --- a/playerSettings.yaml +++ b/playerSettings.yaml @@ -55,6 +55,11 @@ tech_tree_layout: small_funnels: 1 medium_funnels: 1 large_funnels: 1 +recipe_time: + vanilla: 1 + fast: 0 # 25% to 100% of original time + normal: 0 # 50 % to 200% of original time + slow: 0 # 100% to 400% of original time max_science_pack: automation_science_pack: 0 logistic_science_pack: 0 diff --git a/worlds/factorio/Mod.py b/worlds/factorio/Mod.py index 6d7a73e7..5b13dfda 100644 --- a/worlds/factorio/Mod.py +++ b/worlds/factorio/Mod.py @@ -11,7 +11,7 @@ import Utils import shutil import Options from BaseClasses import MultiWorld -from .Technologies import tech_table, rocket_recipes +from .Technologies import tech_table, rocket_recipes, recipes template_env: Optional[jinja2.Environment] = None @@ -62,7 +62,8 @@ def generate_mod(world: MultiWorld, player: int): "tech_tree_layout_prerequisites": world.tech_tree_layout_prerequisites[player], "rocket_recipe" : rocket_recipes[world.max_science_pack[player].value], "slot_name": world.player_names[player][0], "seed_name": world.seed_name, - "starting_items": world.starting_items[player]} + "starting_items": world.starting_items[player], "recipes": recipes, + "recipe_time": world.recipe_time[player], "random": world.random} for factorio_option in Options.factorio_options: template_data[factorio_option] = getattr(world, factorio_option)[player].value diff --git a/worlds/factorio/Technologies.py b/worlds/factorio/Technologies.py index e782c43b..013ace35 100644 --- a/worlds/factorio/Technologies.py +++ b/worlds/factorio/Technologies.py @@ -117,13 +117,14 @@ for technology, data in raw.items(): del (raw) lookup_id_to_name: Dict[int, str] = {item_id: item_name for item_name, item_id in tech_table.items()} - +recipes = {} all_product_sources: Dict[str, Set[Recipe]] = {"character": set()} for recipe_name, recipe_data in raw_recipes.items(): # example: # "accumulator":{"ingredients":["iron-plate","battery"],"products":["accumulator"],"category":"crafting"} recipe = Recipe(recipe_name, recipe_data["category"], set(recipe_data["ingredients"]), set(recipe_data["products"])) + recipes[recipe_name] = Recipe if recipe.products.isdisjoint(recipe.ingredients) and "empty-barrel" not in recipe.products: # prevents loop recipes like uranium centrifuging for product_name in recipe.products: all_product_sources.setdefault(product_name, set()).add(recipe)