From 763edf00f24eb64ee4ed4ab184b4085ab1bee12d Mon Sep 17 00:00:00 2001 From: CaitSith2 Date: Tue, 30 Nov 2021 23:18:17 -0800 Subject: [PATCH] Satellite now a possible goal for ALL science pack levels, chosen by option. Satellite unlocks by respective science pack (or by automation in the case of automation science pack) --- worlds/factorio/Mod.py | 3 ++- worlds/factorio/Options.py | 9 +++++++++ worlds/factorio/__init__.py | 4 ++-- worlds/factorio/data/mod_template/control.lua | 3 ++- .../data/mod_template/data-final-fixes.lua | 20 +++++++++++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/worlds/factorio/Mod.py b/worlds/factorio/Mod.py index 46d0a455..6fae00e4 100644 --- a/worlds/factorio/Mod.py +++ b/worlds/factorio/Mod.py @@ -109,7 +109,8 @@ def generate_mod(world, output_directory: str): progressive_technology_table.values()}, "custom_recipes": world.custom_recipes, "max_science_pack": multiworld.max_science_pack[player].value, - "liquids": liquids} + "liquids": liquids, + "goal": multiworld.goal[player].value} for factorio_option in Options.factorio_options: template_data[factorio_option] = getattr(multiworld, factorio_option)[player].value diff --git a/worlds/factorio/Options.py b/worlds/factorio/Options.py index abce73c5..66d7a0be 100644 --- a/worlds/factorio/Options.py +++ b/worlds/factorio/Options.py @@ -33,6 +33,14 @@ class MaxSciencePack(Choice): return self.get_ordered_science_packs()[self.value].replace("_", "-") +class Goal(Choice): + """Goal required to complete the game.""" + displayname = "Goal" + option_rocket = 0 + option_satellite = 1 + default = 0 + + class TechCost(Choice): """How expensive are the technologies.""" displayname = "Technology Cost Scale" @@ -306,6 +314,7 @@ class ImportedBlueprint(DefaultOnToggle): factorio_options: typing.Dict[str, type(Option)] = { "max_science_pack": MaxSciencePack, + "goal": Goal, "tech_tree_layout": TechTreeLayout, "tech_cost": TechCost, "silo": Silo, diff --git a/worlds/factorio/__init__.py b/worlds/factorio/__init__.py index 54a8e953..ec2a5766 100644 --- a/worlds/factorio/__init__.py +++ b/worlds/factorio/__init__.py @@ -11,7 +11,7 @@ from .Technologies import base_tech_table, recipe_sources, base_technology_table liquids from .Shapes import get_shapes from .Mod import generate_mod -from .Options import factorio_options, MaxSciencePack, Silo, Satellite, TechTreeInformation +from .Options import factorio_options, MaxSciencePack, Silo, Satellite, TechTreeInformation, Goal import logging @@ -146,7 +146,7 @@ class Factorio(World): else self.custom_recipes["rocket-silo"] if "rocket-silo" in self.custom_recipes \ else next(iter(all_product_sources.get("rocket-silo"))) part_recipe = self.custom_recipes["rocket-part"] - satellite_recipe = None if self.world.max_science_pack[self.player].value != MaxSciencePack.option_space_science_pack \ + satellite_recipe = None if self.world.goal[self.player].value != Goal.option_rocket \ else self.custom_recipes["satellite"] if "satellite" in self.custom_recipes \ else next(iter(all_product_sources.get("satellite"))) victory_tech_names = get_rocket_requirements(silo_recipe, part_recipe, satellite_recipe) diff --git a/worlds/factorio/data/mod_template/control.lua b/worlds/factorio/data/mod_template/control.lua index d53a0b9c..4ef722cf 100644 --- a/worlds/factorio/data/mod_template/control.lua +++ b/worlds/factorio/data/mod_template/control.lua @@ -9,6 +9,7 @@ SEED_NAME = "{{ seed_name }}" FREE_SAMPLE_BLACKLIST = {{ dict_to_lua(free_sample_blacklist) }} TRAP_EVO_FACTOR = {{ evolution_trap_increase }} / 100 MAX_SCIENCE_PACK = {{ max_science_pack }} +GOAL = {{ goal }} ARCHIPELAGO_DEATH_LINK_SETTING = "archipelago-death-link-{{ slot_player }}-{{ seed_name }}" if settings.global[ARCHIPELAGO_DEATH_LINK_SETTING].value then @@ -136,7 +137,7 @@ script.on_event(defines.events.on_player_removed, on_player_removed) function on_rocket_launched(event) if event.rocket and event.rocket.valid and global.forcedata[event.rocket.force.name]['victory'] == 0 then - if event.rocket.get_item_count("satellite") > 0 or MAX_SCIENCE_PACK < 6 then + if event.rocket.get_item_count("satellite") > 0 or GOAL == 0 then global.forcedata[event.rocket.force.name]['victory'] = 1 dumpInfo(event.rocket.force) game.set_game_state diff --git a/worlds/factorio/data/mod_template/data-final-fixes.lua b/worlds/factorio/data/mod_template/data-final-fixes.lua index 83765380..d9b16bf5 100644 --- a/worlds/factorio/data/mod_template/data-final-fixes.lua +++ b/worlds/factorio/data/mod_template/data-final-fixes.lua @@ -25,6 +25,26 @@ template_tech.upgrade = false template_tech.effects = {} template_tech.prerequisites = {} +{%- if max_science_pack < 6 %} + technologies["space-science-pack"].effects = {} + {%- if max_science_pack == 0 %} + table.insert (technologies["automation"].effects, {type = "unlock-recipe", recipe = "satellite"}) + {%- elif max_science_pack == 1 %} + table.insert (technologies["logistic-science-pack"].effects, {type = "unlock-recipe", recipe = "satellite"}) + {%- elif max_science_pack == 2 %} + table.insert (technologies["military-science-pack"].effects, {type = "unlock-recipe", recipe = "satellite"}) + {%- elif max_science_pack == 3 %} + table.insert (technologies["chemical-science-pack"].effects, {type = "unlock-recipe", recipe = "satellite"}) + {%- elif max_science_pack == 4 %} + table.insert (technologies["production-science-pack"].effects, {type = "unlock-recipe", recipe = "satellite"}) + {%- elif max_science_pack == 5 %} + table.insert (technologies["utility-science-pack"].effects, {type = "unlock-recipe", recipe = "satellite"}) + {% endif %} +{% endif %} +{%- if silo == 2 %} + data.raw["recipe"]["rocket-silo"].enabled = true +{% endif %} + function prep_copy(new_copy, old_tech) old_tech.hidden = true local ingredient_filter = allowed_ingredients[old_tech.name]