mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Factorio: revamped location system (#1147)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{% from "macros.lua" import dict_to_recipe %}
|
||||
{% from "macros.lua" import dict_to_recipe, variable_to_lua %}
|
||||
-- this file gets written automatically by the Archipelago Randomizer and is in its raw form a Jinja2 Template
|
||||
require('lib')
|
||||
data.raw["rocket-silo"]["rocket-silo"].fluid_boxes = {
|
||||
@@ -50,16 +50,8 @@ data.raw["recipe"]["{{recipe_name}}"].ingredients = {{ dict_to_recipe(recipe.ing
|
||||
{%- endfor %}
|
||||
|
||||
local technologies = data.raw["technology"]
|
||||
local original_tech
|
||||
local new_tree_copy
|
||||
allowed_ingredients = {}
|
||||
{%- for tech_name, technology in custom_technologies.items() %}
|
||||
allowed_ingredients["{{ tech_name }}"] = {
|
||||
{%- for ingredient in technology.ingredients %}
|
||||
["{{ingredient}}"] = 1,
|
||||
{%- endfor %}
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
local template_tech = table.deepcopy(technologies["automation"])
|
||||
{#- ensure the copy unlocks nothing #}
|
||||
template_tech.unlocks = {}
|
||||
@@ -87,39 +79,6 @@ template_tech.prerequisites = {}
|
||||
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]
|
||||
if ingredient_filter ~= nil then
|
||||
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)
|
||||
-- Just in case an ingredient is being added to an existing tech. Found the root cause of the 9.223e+18 problem.
|
||||
-- Turns out science-not-invited was ultimately dividing by zero, due to it being unaware of there being added ingredients.
|
||||
old_tech.unit.ingredients = add_ingredients(old_tech.unit.ingredients, ingredient_filter)
|
||||
SNI.sendInvite(old_tech)
|
||||
-- SCIENCE-not-invited could potentially make tech cost 9.223e+18.
|
||||
old_tech.unit.count = math.min(100000, 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
|
||||
|
||||
function set_ap_icon(tech)
|
||||
tech.icon = "__{{ mod_name }}__/graphics/icons/ap.png"
|
||||
tech.icons = nil
|
||||
@@ -198,38 +157,40 @@ end
|
||||
data.raw["ammo"]["artillery-shell"].stack_size = 10
|
||||
|
||||
{# each randomized tech gets set to be invisible, with new nodes added that trigger those #}
|
||||
{%- for original_tech_name, item_name, receiving_player, advancement in locations %}
|
||||
original_tech = technologies["{{original_tech_name}}"]
|
||||
{%- for original_tech_name in base_tech_table -%}
|
||||
technologies["{{ original_tech_name }}"].hidden = true
|
||||
{% endfor %}
|
||||
{%- for location, item in locations %}
|
||||
{#- the tech researched by the local player #}
|
||||
new_tree_copy = table.deepcopy(template_tech)
|
||||
new_tree_copy.name = "ap-{{ tech_table[original_tech_name] }}-"{# use AP ID #}
|
||||
prep_copy(new_tree_copy, original_tech)
|
||||
{% if tech_cost_scale != 1 %}
|
||||
new_tree_copy.unit.count = math.max(1, math.floor(new_tree_copy.unit.count * {{ tech_cost_scale }}))
|
||||
{% endif %}
|
||||
{%- if (tech_tree_information == 2 or original_tech_name in static_nodes) and item_name in base_tech_table -%}
|
||||
{#- copy Factorio Technology Icon -#}
|
||||
copy_factorio_icon(new_tree_copy, "{{ item_name }}")
|
||||
{%- if original_tech_name == "rocket-silo" and original_tech_name in static_nodes %}
|
||||
new_tree_copy.name = "ap-{{ location.address }}-"{# use AP ID #}
|
||||
new_tree_copy.unit.count = {{ location.count }}
|
||||
new_tree_copy.unit.ingredients = {{ variable_to_lua(location.factorio_ingredients) }}
|
||||
|
||||
{%- if location.revealed and item.name in base_tech_table -%}
|
||||
{#- copy Factorio Technology Icon #}
|
||||
copy_factorio_icon(new_tree_copy, "{{ item.name }}")
|
||||
{%- if item.name == "rocket-silo" and item.player == location.player %}
|
||||
{%- for ingredient in custom_recipes["rocket-part"].ingredients %}
|
||||
table.insert(new_tree_copy.effects, {type = "nothing", effect_description = "Ingredient {{ loop.index }}: {{ ingredient }}"})
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
{%- elif (tech_tree_information == 2 or original_tech_name in static_nodes) and item_name in progressive_technology_table -%}
|
||||
copy_factorio_icon(new_tree_copy, "{{ progressive_technology_table[item_name][0] }}")
|
||||
{%- elif location.revealed and item.name in progressive_technology_table -%}
|
||||
copy_factorio_icon(new_tree_copy, "{{ progressive_technology_table[item.name][0] }}")
|
||||
{%- else -%}
|
||||
{#- use default AP icon if no Factorio graphics exist -#}
|
||||
{% if advancement or not tech_tree_information %}set_ap_icon(new_tree_copy){% else %}set_ap_unimportant_icon(new_tree_copy){% endif %}
|
||||
{% if item.advancement or not tech_tree_information %}set_ap_icon(new_tree_copy){% else %}set_ap_unimportant_icon(new_tree_copy){% endif %}
|
||||
{%- endif -%}
|
||||
{#- connect Technology #}
|
||||
{%- if original_tech_name in tech_tree_layout_prerequisites %}
|
||||
{%- for prerequisite in tech_tree_layout_prerequisites[original_tech_name] %}
|
||||
table.insert(new_tree_copy.prerequisites, "ap-{{ tech_table[prerequisite] }}-")
|
||||
{%- if location in tech_tree_layout_prerequisites %}
|
||||
{%- for prerequisite in tech_tree_layout_prerequisites[location] %}
|
||||
table.insert(new_tree_copy.prerequisites, "ap-{{ prerequisite.address }}-")
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{#- add new Technology to game #}
|
||||
data:extend{new_tree_copy}
|
||||
{% endfor %}
|
||||
{#- Recipe Rando #}
|
||||
{% if recipe_time_scale %}
|
||||
{%- for recipe_name, recipe in recipes.items() %}
|
||||
{%- if recipe.category not in ("basic-solid", "basic-fluid") %}
|
||||
|
||||
@@ -5,22 +5,22 @@ archipelago=Archipelago
|
||||
archipelago=World preset created by the Archipelago Randomizer. World may or may not contain actual archipelagos.
|
||||
|
||||
[technology-name]
|
||||
{% for original_tech_name, item_name, receiving_player, advancement in locations %}
|
||||
{%- if tech_tree_information == 2 or original_tech_name in static_nodes %}
|
||||
ap-{{ tech_table[original_tech_name] }}-={{ player_names[receiving_player] }}'s {{ item_name }}
|
||||
{% for location, item in locations %}
|
||||
{%- if location.revealed %}
|
||||
ap-{{ location.address }}-={{ player_names[item.player] }}'s {{ item.name }} ({{ location.name }})
|
||||
{%- else %}
|
||||
ap-{{ tech_table[original_tech_name] }}-=An Archipelago Sendable
|
||||
ap-{{ location.address }}-= {{location.name}}
|
||||
{%- endif -%}
|
||||
{% endfor %}
|
||||
|
||||
[technology-description]
|
||||
{% for original_tech_name, item_name, receiving_player, advancement in locations %}
|
||||
{%- if tech_tree_information == 2 or original_tech_name in static_nodes %}
|
||||
ap-{{ tech_table[original_tech_name] }}-=Researching this technology sends {{ item_name }} to {{ player_names[receiving_player] }}{% if advancement %}, which is considered a logical advancement{% endif %}.
|
||||
{%- elif tech_tree_information == 1 and advancement %}
|
||||
ap-{{ tech_table[original_tech_name] }}-=Researching this technology sends something to someone, which is considered a logical advancement. For purposes of hints, this location is called "{{ original_tech_name }}".
|
||||
{% for location, item in locations %}
|
||||
{%- if location.revealed %}
|
||||
ap-{{ location.address }}-=Researching this technology sends {{ item.name }} to {{ player_names[item.player] }}{% if item.advancement %}, which is considered a logical advancement{% elif item.useful %}, which is considered useful{% elif item.trap %}, which is considered fun{% endif %}.
|
||||
{%- elif tech_tree_information == 1 and item.advancement %}
|
||||
ap-{{ location.address }}-=Researching this technology sends something to someone, which is considered a logical advancement.
|
||||
{%- else %}
|
||||
ap-{{ tech_table[original_tech_name] }}-=Researching this technology sends something to someone. For purposes of hints, this location is called "{{ original_tech_name }}".
|
||||
ap-{{ location.address }}-=Researching this technology sends something to someone.
|
||||
{%- endif -%}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
["{{ key }}"] = {{ variable_to_lua(value) }}{% if not loop.last %},{% endif %}
|
||||
{% endfor -%}
|
||||
}
|
||||
{%- endmacro %}
|
||||
{% endmacro %}
|
||||
{% macro list_to_lua(list) -%}
|
||||
{
|
||||
{%- for key in list -%}
|
||||
|
||||
Reference in New Issue
Block a user