From 0b096528d408afc7451c2489e232c0d4add2ba89 Mon Sep 17 00:00:00 2001 From: CaitSith2 Date: Mon, 8 Nov 2021 10:00:00 -0800 Subject: [PATCH] implement science-not-invited filtering/scaling if that mod is installed (Max count of research will be set to 10,000 * player_tech_cost) so as to not have an unreasonable amount. Also, other player installed mods, and even the infinite techs will have the max science pack level applied to them.) --- worlds/factorio/Mod.py | 9 +++++-- worlds/factorio/data/mod/info.json | 6 ++++- .../data/mod_template/data-final-fixes.lua | 26 ++++++++++++++++--- worlds/factorio/data/mod_template/data.lua | 18 +++++++++++++ 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/worlds/factorio/Mod.py b/worlds/factorio/Mod.py index 84c9da25..484ed626 100644 --- a/worlds/factorio/Mod.py +++ b/worlds/factorio/Mod.py @@ -29,7 +29,11 @@ base_info = { "author": "Berserker", "homepage": "https://archipelago.gg", "description": "Integration client for the Archipelago Randomizer", - "factorio_version": "1.1" + "factorio_version": "1.1", + "dependencies": [ + "base >= 1.1.0", + "? science-not-invited" + ] } recipe_time_scales = { @@ -95,7 +99,8 @@ def generate_mod(world, output_directory: str): "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()}, - "custom_recipes": world.custom_recipes} + "custom_recipes": world.custom_recipes, + "max_science_pack": multiworld.max_science_pack[player].value} for factorio_option in Options.factorio_options: template_data[factorio_option] = getattr(multiworld, factorio_option)[player].value diff --git a/worlds/factorio/data/mod/info.json b/worlds/factorio/data/mod/info.json index 2b6c428c..b93686d0 100644 --- a/worlds/factorio/data/mod/info.json +++ b/worlds/factorio/data/mod/info.json @@ -5,5 +5,9 @@ "author": "Berserker and Dewiniaid", "homepage": "https://archipelago.gg", "description": "Integration client for the Archipelago Randomizer", - "factorio_version": "1.1" + "factorio_version": "1.1", + "dependencies": [ + "base >= 1.1.0", + "? science-not-invited" + ] } diff --git a/worlds/factorio/data/mod_template/data-final-fixes.lua b/worlds/factorio/data/mod_template/data-final-fixes.lua index df911a18..4b2d67a2 100644 --- a/worlds/factorio/data/mod_template/data-final-fixes.lua +++ b/worlds/factorio/data/mod_template/data-final-fixes.lua @@ -26,11 +26,31 @@ template_tech.prerequisites = {} function prep_copy(new_copy, old_tech) old_tech.hidden = true - new_copy.unit = table.deepcopy(old_tech.unit) local ingredient_filter = allowed_ingredients[old_tech.name] if ingredient_filter ~= nil then - new_copy.unit.ingredients = filter_ingredients(new_copy.unit.ingredients, ingredient_filter) - new_copy.unit.ingredients = add_ingredients(new_copy.unit.ingredients, ingredient_filter) + if mods["science-not-invited"] then + local weights = { + ["automation-science-pack"] = 0, -- Red science + ["logistic-science-pack"] = 0, -- Green science + ["military-science-pack"] = 0, -- Black science + ["chemical-science-pack"] = 0, -- Blue science + ["production-science-pack"] = 0, -- Purple science + ["utility-science-pack"] = 0, -- Yellow science + ["space-science-pack"] = 0 -- Space science + } + for key, value in pairs(ingredient_filter) do + weights[key] = value + end + SNI.setWeights(weights) + SNI.sendInvite(old_tech) + -- SCIENCE-not-invited could potentially make tech cost 9.223e+18. + old_tech.unit.count = math.min(10000, old_tech.unit.count) + end + new_copy.unit = table.deepcopy(old_tech.unit) + new_copy.unit.ingredients = filter_ingredients(new_copy.unit.ingredients, ingredient_filter) + new_copy.unit.ingredients = add_ingredients(new_copy.unit.ingredients, ingredient_filter) + else + new_copy.unit = table.deepcopy(old_tech.unit) end end diff --git a/worlds/factorio/data/mod_template/data.lua b/worlds/factorio/data/mod_template/data.lua index bf10ee98..ef62f72a 100644 --- a/worlds/factorio/data/mod_template/data.lua +++ b/worlds/factorio/data/mod_template/data.lua @@ -1,2 +1,20 @@ {% from "macros.lua" import dict_to_lua %} data.raw["map-gen-presets"].default["archipelago"] = {{ dict_to_lua({"default": False, "order": "a", "basic_settings": world_gen["basic"], "advanced_settings": world_gen["advanced"]}) }} +if mods["science-not-invited"] then + local weights = { + ["automation-science-pack"] = 0, -- Red science + ["logistic-science-pack"] = 0, -- Green science + ["military-science-pack"] = 0, -- Black science + ["chemical-science-pack"] = 0, -- Blue science + ["production-science-pack"] = 0, -- Purple science + ["utility-science-pack"] = 0, -- Yellow science + ["space-science-pack"] = 0 -- Space science + } +{% if max_science_pack == 6 -%} + weights["space-science-pack"] = 1 +{%- endif %} +{% for key in allowed_science_packs -%} + weights["{{key}}"] = 1 +{% endfor %} + SNI.setWeights(weights) +end