Factorio: implement random recipe times
This commit is contained in:
parent
7907838c24
commit
403ddd603f
|
@ -329,6 +329,11 @@ class Visibility(Choice):
|
||||||
option_sending = 1
|
option_sending = 1
|
||||||
default = 1
|
default = 1
|
||||||
|
|
||||||
|
class RecipeTime(Choice):
|
||||||
|
option_vanilla = 0
|
||||||
|
option_fast = 1
|
||||||
|
option_normal = 2
|
||||||
|
option_slow = 4
|
||||||
|
|
||||||
class FactorioStartItems(OptionDict):
|
class FactorioStartItems(OptionDict):
|
||||||
default = {"burner-mining-drill": 19, "stone-furnace": 19}
|
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,
|
"free_samples": FreeSamples,
|
||||||
"visibility": Visibility,
|
"visibility": Visibility,
|
||||||
"random_tech_ingredients": Toggle,
|
"random_tech_ingredients": Toggle,
|
||||||
"starting_items": FactorioStartItems}
|
"starting_items": FactorioStartItems,
|
||||||
|
"recipe_time": RecipeTime}
|
||||||
|
|
||||||
|
|
||||||
class AdvancementGoal(Choice):
|
class AdvancementGoal(Choice):
|
||||||
|
|
|
@ -49,6 +49,14 @@ function copy_factorio_icon(tech, tech_source)
|
||||||
tech.icon_size = table.deepcopy(technologies[tech_source].icon_size)
|
tech.icon_size = table.deepcopy(technologies[tech_source].icon_size)
|
||||||
end
|
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")
|
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 #}
|
{# 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 -%}
|
{% endif -%}
|
||||||
{#- 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 %}
|
||||||
|
{%- for recipe in recipes %}
|
||||||
|
adjust_energy("{{ recipe }}", {{ 0.01 * random.randint(recipe_time*25, recipe_time*100) }})
|
||||||
|
{%- endfor -%}
|
||||||
|
{% endif %}
|
|
@ -55,6 +55,11 @@ tech_tree_layout:
|
||||||
small_funnels: 1
|
small_funnels: 1
|
||||||
medium_funnels: 1
|
medium_funnels: 1
|
||||||
large_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:
|
max_science_pack:
|
||||||
automation_science_pack: 0
|
automation_science_pack: 0
|
||||||
logistic_science_pack: 0
|
logistic_science_pack: 0
|
||||||
|
|
|
@ -11,7 +11,7 @@ import Utils
|
||||||
import shutil
|
import shutil
|
||||||
import Options
|
import Options
|
||||||
from BaseClasses import MultiWorld
|
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
|
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],
|
"tech_tree_layout_prerequisites": world.tech_tree_layout_prerequisites[player],
|
||||||
"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]}
|
"starting_items": world.starting_items[player], "recipes": recipes,
|
||||||
|
"recipe_time": world.recipe_time[player], "random": world.random}
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -117,13 +117,14 @@ for technology, data in raw.items():
|
||||||
|
|
||||||
del (raw)
|
del (raw)
|
||||||
lookup_id_to_name: Dict[int, str] = {item_id: item_name for item_name, item_id in tech_table.items()}
|
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()}
|
all_product_sources: Dict[str, Set[Recipe]] = {"character": set()}
|
||||||
for recipe_name, recipe_data in raw_recipes.items():
|
for recipe_name, recipe_data in raw_recipes.items():
|
||||||
# example:
|
# example:
|
||||||
# "accumulator":{"ingredients":["iron-plate","battery"],"products":["accumulator"],"category":"crafting"}
|
# "accumulator":{"ingredients":["iron-plate","battery"],"products":["accumulator"],"category":"crafting"}
|
||||||
|
|
||||||
recipe = Recipe(recipe_name, recipe_data["category"], set(recipe_data["ingredients"]), set(recipe_data["products"]))
|
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
|
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:
|
for product_name in recipe.products:
|
||||||
all_product_sources.setdefault(product_name, set()).add(recipe)
|
all_product_sources.setdefault(product_name, set()).add(recipe)
|
||||||
|
|
Loading…
Reference in New Issue