From 2bc071887e6aa14e9691e45a39fe780d81e62106 Mon Sep 17 00:00:00 2001 From: Peter Date: Tue, 15 Jan 2019 20:48:17 +0800 Subject: [PATCH] -payload victory requirement, +space science tech, -some bugs --- 017_science/control.lua | 130 ++++++++++++++++-- 017_science/data-updates.lua | 37 +++-- 017_science/info.json | 2 +- 017_science/locale/en/base.cfg | 15 +- .../2019-01-13_017_science_0.0.12.lua | 26 ---- 017_science/settings.lua | 25 +++- 017_science/technology.lua | 56 ++++---- 7 files changed, 215 insertions(+), 76 deletions(-) delete mode 100644 017_science/migrations/2019-01-13_017_science_0.0.12.lua diff --git a/017_science/control.lua b/017_science/control.lua index 3fe6f3a..405d1d9 100644 --- a/017_science/control.lua +++ b/017_science/control.lua @@ -1,15 +1,21 @@ -if settings.startup["017-axe"].value then - local function generate_axes() - -- game.print("gen_ax") - global.axe_techs = {} - for _, axe in pairs(game.item_prototypes) do - if axe.attack_range then - global.axe_techs[#global.axe_techs+1] = {axe.name,axe.speed} - end +local function disable_silo_script() + if remote.interfaces["silo_script"] then + remote.call("silo_script","set_finish_on_launch", false) + remote.call("silo_script","set_show_launched_without_satellite", false) + end +end +local function generate_axes() + -- game.print("gen_ax") + global.axe_techs = {} + for _, axe in pairs(game.item_prototypes) do + if axe.attack_range then + global.axe_techs[#global.axe_techs+1] = {axe.name,axe.speed} end end +end +if settings.startup["017-axe"].value then local function ax_gen() if global.axe_techs == nil then generate_axes() @@ -76,11 +82,6 @@ if settings.startup["017-axe"].value then end end - script.on_init(function() - global.axe_techs = {} - generate_axes() - end) - -- init_game -- script.on_configuration_changed(function() configuration_changed = 1 game.print("changed") end) @@ -154,3 +155,106 @@ if settings.startup["017-axe"].value then -- end) end + +if settings.startup["017-rocket-victory"].value then + script.on_event(defines.events.on_rocket_launched, function(event) + if game.active_mods["SpaceMod"] then + -- game.print("SpaceMod installed: not enabling victory") + else + game.set_game_state{game_finished = true, player_won = true, can_continue = true} + end + end) +end + + +local function initialize() + if settings.startup["017-axe"].value then + global.axe_techs = {} + generate_axes() + end + if settings.startup["017-rocket-victory"].value then + disable_silo_script() + end +end + +script.on_configuration_changed(function() + initialize() + if settings.startup["017-rocket-victory"].value and not settings.startup["017-techtree"].value then + for i, force in pairs(game.forces) do + if force.technologies["rocket-silo"].researched == true then + force.recipes["satellite"].enabled = true + end + end + end + if settings.startup["017-rocket-victory"].value and settings.startup["017-techtree"].value then + for i, force in pairs(game.forces) do + local get_input_count = force.item_production_statistics.get_input_count + if get_input_count("space-science-pack") > 0 then + force.recipes["satellite"].enabled = true + force.technologies["space-science-pack"].researched = true + force.print("force: " .. force.name .. " | space-science-pack tech unlocked | total produced for force: " .. get_input_count("space-science-pack")) + else + force.recipes["satellite"].enabled = false + force.technologies["space-science-pack"].researched = false + force.print("No space science produced by this force: keeping technology locked.") + end + end + end + if settings.startup["017-techtree"].value then + for i, force in pairs(game.forces) do + local get_input_count = force.item_production_statistics.get_input_count + if get_input_count("science-pack-2") > 0 then + force.recipes["science-pack-2"].enabled = true + force.technologies["logistics-science-pack"].researched = true + force.print("force: " .. force.name .. " | logistics-science-pack tech unlocked | total produced for force: " .. get_input_count("science-pack-2")) + else + force.recipes["science-pack-2"].enabled = false + force.technologies["logistics-science-pack"].researched = false + force.print("No logistics science produced by this force: keeping technology locked.") + end + + if get_input_count("science-pack-3") > 0 then + force.recipes["science-pack-3"].enabled = true + force.recipes["17-chemical-science-pack"].enabled = true + force.technologies["chemical-science-pack"].researched = true + force.print("force: " .. force.name .. " | chemical-science-pack tech unlocked | total produced for force: " .. get_input_count("science-pack-3")) + else + force.recipes["science-pack-3"].enabled = false + force.recipes["17-chemical-science-pack"].enabled = false + force.technologies["chemical-science-pack"].researched = false + force.print("No chemical science produced by this force: keeping technology locked.") + end + + if get_input_count("production-science-pack") > 0 then + force.recipes["production-science-pack"].enabled = true + force.recipes["17-production-science-pack"].enabled = true + force.technologies["production-science-pack"].researched = true + force.print("force: " .. force.name .. " | production-science-pack tech unlocked | total produced for force: " .. get_input_count("production-science-pack")) + else + force.recipes["production-science-pack"].enabled = false + force.recipes["17-production-science-pack"].enabled = false + force.technologies["production-science-pack"].researched = false + force.print("No production science produced by this force: keeping technology locked.") + end + + if get_input_count("high-tech-science-pack") > 0 then + force.recipes["high-tech-science-pack"].enabled = true + force.recipes["17-utility-science-pack"].enabled = true + force.technologies["utility-science-pack"].researched = true + force.print("force: " .. force.name .. " | high-tech-science-pack tech unlocked | total produced for force: " .. get_input_count("high-tech-science-pack")) + else + force.recipes["high-tech-science-pack"].enabled = false + force.recipes["17-utility-science-pack"].enabled = false + force.technologies["utility-science-pack"].researched = false + force.print("No utility science produced by this force: keeping technology locked.") + end + end + end + for i, force in pairs(game.forces) do + force.reset_recipes() + end + for i, force in pairs(game.forces) do + force.reset_technologies() + end +end) +script.on_init(initialize) \ No newline at end of file diff --git a/017_science/data-updates.lua b/017_science/data-updates.lua index 0020eb5..69a32b1 100644 --- a/017_science/data-updates.lua +++ b/017_science/data-updates.lua @@ -60,6 +60,10 @@ local r_effects = data.raw["technology"]["rocket-silo"].effects --remove the dup for _=1, #r_effects do if r_effects[_].type == "unlock-recipe" and (r_effects[_].recipe == "low-density-structure" or r_effects[_].recipe == "rocket-fuel" or r_effects[_].recipe == "rocket-control-unit") then r_effects[_] = nil + elseif settings.startup["017-techtree"].value and settings.startup["017-rocket-victory"].value then + if r_effects[_].type == "unlock-recipe" and r_effects[_].recipe == "satellite" then + r_effects[_] = nil + end end end @@ -159,13 +163,13 @@ if settings.startup["017-techtree"].value then end for _, tech in pairs(data.raw["technology"]) do - if tech.name ~= ("logistics-science-pack" or "chemical-science-pack" or "production-science-pack" or "utility-science-pack") then + if tech.name ~= ("logistics-science-pack" or "chemical-science-pack" or "production-science-pack" or "utility-science-pack" or "space-science-pack") then if tech.effects then if #tech.effects ~= 0 then - for i=1, #tech.effects do - if tech.effects[i] then - if tech.effects[i].type then - if tech.effects[i].type == "unlock-recipe" then + for i, effect in pairs(tech.effects) do + if effect then + if effect.type then + if effect.type == "unlock-recipe" then whitelisted = true break else @@ -175,14 +179,31 @@ if settings.startup["017-techtree"].value then end end end + if settings.startup["017-rocket-victory"].value then + if whitelisted == false then + if tech.unit then + if tech.unit.ingredients then + for j, nasa in pairs(tech.unit.ingredients) do + if nasa[1] == "space-science-pack" then + compare(tech, "space-science-pack", "space-science-pack") + break + else + whitelisted = false + end + end + end + end + end + end if whitelisted == true then local valid = compare(tech, "logistics-science-pack", "science-pack-2") if valid == false then - local valid = compare(tech, "chemical-science-pack", "science-pack-3") end + local valid = compare(tech, "chemical-science-pack", "science-pack-3") end if valid == false then - local valid = compare(tech, "production-science-pack", "production-science-pack") end + local valid = compare(tech, "production-science-pack", "production-science-pack") end if valid == false then - local valid = compare(tech, "utility-science-pack", "high-tech-science-pack") end + compare(tech, "utility-science-pack", "high-tech-science-pack") + end end end end diff --git a/017_science/info.json b/017_science/info.json index 4a7205e..2a95467 100644 --- a/017_science/info.json +++ b/017_science/info.json @@ -1,6 +1,6 @@ { "name": "017_science", - "version": "0.0.16", + "version": "0.0.17", "factorio_version": "0.16", "title": "0.17 science conversion", "author": "npc_strider(morley376)", diff --git a/017_science/locale/en/base.cfg b/017_science/locale/en/base.cfg index 1a5151f..0e45c70 100644 --- a/017_science/locale/en/base.cfg +++ b/017_science/locale/en/base.cfg @@ -4,6 +4,7 @@ logistics-science-pack=Logistics science pack chemical-science-pack=Chemical science pack production-science-pack=Production science pack utility-science-pack=Utility science pack +space-science-pack=Space science pack [item-name] science-pack-1=Automation science pack @@ -26,14 +27,17 @@ high-tech-science-pack=Utility science pack 017-pack-type-rebalancing=Science pack type rebalancing 017-techtree=Science-pack technologies and techtree 017-nuclear-reprocessing-discount=nuclear-fuel-reprocessing technology discount +017-rocket-victory=No-rocket victory 017-green-cost=Logistics science pack technology cost 017-chem-cost=Chemical science pack technology cost 017-purple-cost=Production science pack technology cost 017-gold-cost=Utility science pack technology cost +017-nasa-cost=Space science pack technology cost 017-green-energy=Logistics science pack technology time-per-unit 017-chem-energy=Chemical science pack technology time-per-unit 017-purple-energy=Production science pack technology time-per-unit 017-gold-energy=Utility science pack technology time-per-unit +017-nasa-energy=Space science pack technology time-per-unit [mod-setting-description] 017-drill=(Default enabled) Toggle FFF-266 mining changes (removed hardness). This mod makes all vanilla ore hardness = 1 and makes the burner-mining-drill mining_power = 3, which may break modded ore gating. @@ -48,12 +52,15 @@ high-tech-science-pack=Utility science pack 017-lds-num=(Default 5, Min 1, Max 32) When steel-plate is not present in vanilla 'high tech' equipment recipes, the cost is determined by the number of "processing-unit"s. math.ceil(n("processing-unit")/thissetting) 017-pack-type-rebalancing=(Default enabled) Enable the rebalancing of high-end technologies into production/utility 'categories' (FFF-275). For example, level-3 modules no longer use utility science and will use production science instead as they increase production. 017-techtree=(Default enabled) Enable the 0.17 techtree. Science packs are now unlocked by dedicated technologies and the rocket-silo no longer requires rocket-speed-5 as a prerequisite (FFF-275 & FFF-245). NOTE: Technologies are dynamically assigned a 'science pack technology' as a prerequisite through script (to work with mods). This may not reflect release tech paths. +017-rocket-victory=(Default enabled) The victory condition for the game no longer requires a payload (satellite) (FFF-275). 017-nuclear-reprocessing-discount=(Default 1000, Min 0, Max 1400) This number is subtracted from the current cost of nuclear-fuel-reprocessing technology (1500). FFF-275 hints at a major discount to this technology ("The Nuclear fuel cell reprocessing is also drastically cheaper") but does not specify an amount. -017-green-cost=(Default 50, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. -017-chem-cost=(Default 200, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. -017-purple-cost=(Default 250, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. -017-gold-cost=(Default 250, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. +017-green-cost=(Default 50, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. Default based off steel-processing difficulty +017-chem-cost=(Default 200, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. Default based off advanced-electronics difficulty +017-purple-cost=(Default 250, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. Default based off advanced-material-processing-2 difficulty. +017-gold-cost=(Default 250, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. Default based off advanced-electronics-2 difficulty. +017-nasa-cost=(Default 5000, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. Default based off atomic-bomb technology difficulty. 017-green-energy=(Default 5, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. Amount of time to research one unit of this technology. 017-chem-energy=(Default 15, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. Amount of time to research one unit of this technology. 017-purple-energy=(Default 30, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. Amount of time to research one unit of this technology. 017-gold-energy=(Default 30, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. Amount of time to research one unit of this technology. +017-nasa-energy=(Default 60, Min 0, Max INF.) This value is NOT official and is an estimate based on the difficulty of similar technologies. Amount of time to research one unit of this technology. diff --git a/017_science/migrations/2019-01-13_017_science_0.0.12.lua b/017_science/migrations/2019-01-13_017_science_0.0.12.lua deleted file mode 100644 index 70ba959..0000000 --- a/017_science/migrations/2019-01-13_017_science_0.0.12.lua +++ /dev/null @@ -1,26 +0,0 @@ -for i, force in pairs(game.forces) do - local get_input_count = force.item_production_statistics.get_input_count - if get_input_count("science-pack-2") > 0 then - force.recipes["science-pack-2"].enabled = true - force.technologies["logistics-science-pack"].researched = true - -- game.print(force.name .. " | " .. "science-pack-2" .. " | " .. get_input_count("science-pack-2")) - end - if get_input_count("science-pack-3") > 0 then - force.recipes["science-pack-3"].enabled = true - force.recipes["17-chemical-science-pack"].enabled = true - force.technologies["chemical-science-pack"].researched = true - -- game.print(force.name .. " | " .. "science-pack-3" .. " | " .. get_input_count("science-pack-3")) - end - if get_input_count("production-science-pack") > 0 then - force.recipes["production-science-pack"].enabled = true - force.recipes["17-production-science-pack"].enabled = true - force.technologies["production-science-pack"].researched = true - -- game.print(force.name .. " | " .. "production-science-pack" .. " | " .. get_input_count("production-science-pack")) - end - if get_input_count("high-tech-science-pack") > 0 then - force.recipes["high-tech-science-pack"].enabled = true - force.recipes["17-utility-science-pack"].enabled = true - force.technologies["utility-science-pack"].researched = true - -- game.print(force.name .. " | " .. "high-tech-science-pack" .. " | " .. get_input_count("high-tech-science-pack")) - end -end \ No newline at end of file diff --git a/017_science/settings.lua b/017_science/settings.lua index f2ccc6a..c249f0b 100644 --- a/017_science/settings.lua +++ b/017_science/settings.lua @@ -94,6 +94,13 @@ data:extend( setting_type = "startup", default_value = true, order = "npc-m" + }, + { + type = "bool-setting", + name = "017-rocket-victory", + setting_type = "startup", + default_value = true, + order = "npc-me" }, { type = "int-setting", @@ -126,6 +133,14 @@ data:extend( minimum_value = 0, default_value = 250, order = "npc-nd" + }, + { + type = "int-setting", + name = "017-nasa-cost", + setting_type = "startup", + minimum_value = 0, + default_value = 5000, + order = "npc-ne" }, { type = "int-setting", @@ -157,6 +172,14 @@ data:extend( setting_type = "startup", minimum_value = 0, default_value = 30, + order = "npc-od" + }, + { + type = "int-setting", + name = "017-nasa-energy", + setting_type = "startup", + minimum_value = 0, + default_value = 60, order = "npc-oe" - } + } }) \ No newline at end of file diff --git a/017_science/technology.lua b/017_science/technology.lua index 9b53b86..d4ee3d6 100644 --- a/017_science/technology.lua +++ b/017_science/technology.lua @@ -91,28 +91,38 @@ data:extend( time = settings.startup["017-gold-energy"].value }, order = "e-e-e" - }--, (NEXT UPDATE! SPACE SCIENCE + SATELLITE REBALANCING) - -- { - -- type = "technology", - -- name = "space-science-pack", - -- icon_size = 128, - -- icon = "__017_science__/graphics/technology/white.png", - -- effects = - -- { - -- {type = "unlock-recipe", recipe = "17-utility-science-pack"} - -- }, - -- unit = - -- { - -- count = 250, - -- ingredients = - -- { - -- {"science-pack-1", 1}, - -- {"science-pack-2", 1}, - -- {"science-pack-3", 1}, - -- }, - -- time = 15 - -- }, - -- order = "a-d-b-a" - -- } + } +}) +end + +if settings.startup["017-techtree"].value and settings.startup["017-rocket-victory"].value then +data:extend( +{ + { + type = "technology", + name = "space-science-pack", + icon_size = 128, + icon = "__017_science__/graphics/technology/white.png", + effects = + { + {type = "unlock-recipe", recipe = "satellite"} + }, + prerequisites = {"rocket-silo"}, + unit = + { + count = settings.startup["017-nasa-cost"].value, + ingredients = + { + {"science-pack-1", 1}, + {"science-pack-2", 1}, + {"science-pack-3", 1}, + {"military-science-pack", 1}, + {"production-science-pack", 1}, + {"high-tech-science-pack", 1} + }, + time = settings.startup["017-nasa-energy"].value, + }, + order = "k-b" + } }) end \ No newline at end of file