Include military science pack in all techs military or higher.
This does mean you have to get military science online to research your silo.
This commit is contained in:
parent
e4564abe41
commit
17ed957c6b
|
@ -84,11 +84,17 @@ class CustomTechnology(Technology):
|
||||||
|
|
||||||
def __init__(self, origin: Technology, world, allowed_packs: Set[str], player: int):
|
def __init__(self, origin: Technology, world, allowed_packs: Set[str], player: int):
|
||||||
ingredients = origin.ingredients & allowed_packs
|
ingredients = origin.ingredients & allowed_packs
|
||||||
|
military_allowed = "military-science-pack" in allowed_packs \
|
||||||
|
and (ingredients & {"chemical-science-pack", "production-science-pack", "utility-science-pack"})
|
||||||
self.player = player
|
self.player = player
|
||||||
if origin.name not in world.worlds[player].static_nodes:
|
if origin.name not in world.worlds[player].static_nodes:
|
||||||
|
if military_allowed:
|
||||||
|
ingredients.add("military-science-pack")
|
||||||
ingredients = list(ingredients)
|
ingredients = list(ingredients)
|
||||||
ingredients.sort() # deterministic sample
|
ingredients.sort() # deterministic sample
|
||||||
ingredients = world.random.sample(ingredients, world.random.randint(1, len(ingredients)))
|
ingredients = world.random.sample(ingredients, world.random.randint(1, len(ingredients)))
|
||||||
|
elif origin.name == "rocket-silo" and military_allowed:
|
||||||
|
ingredients.add("military-science-pack")
|
||||||
super(CustomTechnology, self).__init__(origin.name, ingredients, origin.factorio_id)
|
super(CustomTechnology, self).__init__(origin.name, ingredients, origin.factorio_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,24 @@ function filter_ingredients(ingredients, ingredient_filter)
|
||||||
return new_ingredient_list
|
return new_ingredient_list
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function add_ingredients(ingredients, added_ingredients)
|
||||||
|
local new_ingredient_list = table.deepcopy(ingredients)
|
||||||
|
for new_ingredient, count in pairs(added_ingredients) do
|
||||||
|
local found = false
|
||||||
|
for _, old_ingredient in pairs(ingredients) do
|
||||||
|
if old_ingredient[1] == new_ingredient then
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not found then
|
||||||
|
table.insert(new_ingredient_list, {new_ingredient, count})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return new_ingredient_list
|
||||||
|
end
|
||||||
|
|
||||||
function get_any_stack_size(name)
|
function get_any_stack_size(name)
|
||||||
local item = game.item_prototypes[name]
|
local item = game.item_prototypes[name]
|
||||||
if item ~= nil then
|
if item ~= nil then
|
||||||
|
|
|
@ -30,6 +30,7 @@ function prep_copy(new_copy, old_tech)
|
||||||
local ingredient_filter = allowed_ingredients[old_tech.name]
|
local ingredient_filter = allowed_ingredients[old_tech.name]
|
||||||
if ingredient_filter ~= nil then
|
if ingredient_filter ~= nil then
|
||||||
new_copy.unit.ingredients = filter_ingredients(new_copy.unit.ingredients, ingredient_filter)
|
new_copy.unit.ingredients = filter_ingredients(new_copy.unit.ingredients, ingredient_filter)
|
||||||
|
new_copy.unit.ingredients = add_ingredients(new_copy.unit.ingredients, ingredient_filter)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue