From ec3d1538c85ca2ad4fb7a85c523da9f0cfd10e71 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Fri, 14 Feb 2020 21:06:52 +0100 Subject: [PATCH 01/70] Add files via upload --- maps/chronosphere/ai.lua | 425 +++++++++++++++++ maps/chronosphere/chronobubles.lua | 74 +++ maps/chronosphere/comfylatron.lua | 404 ++++++++++++++++ maps/chronosphere/gui.lua | 105 +++++ maps/chronosphere/locomotive.lua | 557 ++++++++++++++++++++++ maps/chronosphere/main.lua | 721 +++++++++++++++++++++++++++++ maps/chronosphere/ores.lua | 197 ++++++++ maps/chronosphere/terrain.lua | 574 +++++++++++++++++++++++ maps/chronosphere/treasure.lua | 184 ++++++++ 9 files changed, 3241 insertions(+) create mode 100644 maps/chronosphere/ai.lua create mode 100644 maps/chronosphere/chronobubles.lua create mode 100644 maps/chronosphere/comfylatron.lua create mode 100644 maps/chronosphere/gui.lua create mode 100644 maps/chronosphere/locomotive.lua create mode 100644 maps/chronosphere/main.lua create mode 100644 maps/chronosphere/ores.lua create mode 100644 maps/chronosphere/terrain.lua create mode 100644 maps/chronosphere/treasure.lua diff --git a/maps/chronosphere/ai.lua b/maps/chronosphere/ai.lua new file mode 100644 index 00000000..86f72e25 --- /dev/null +++ b/maps/chronosphere/ai.lua @@ -0,0 +1,425 @@ +local Public = {} + +local math_random = math.random +local math_sqrt = math.sqrt +local math_floor = math.floor +local worm_raffle = { "small-worm-turret", "medium-worm-turret", "big-worm-turret", "behemoth-worm-turret"} +local spawner_raffle = {"biter-spawner", "biter-spawner", "biter-spawner", "spitter-spawner"} +local biter_raffle = { + "behemoth-biter", "behemoth-spitter", "big-biter", "big-spitter", + "medium-biter", "medium-spitter", "small-biter", "small-spitter" +} + +local vector_radius = 480 +local attack_vectors = {} +for x = vector_radius * -1, vector_radius, 1 do + for y = 0, vector_radius, 1 do + local r = math_sqrt(x ^ 2 + y ^ 2) + if r < vector_radius and r > vector_radius - 1 then + attack_vectors[#attack_vectors + 1] = {x, y} + end + end +end +local size_of_vectors = #attack_vectors + +-- these areas are for north +local middle_spawner_area = {left_top = {-400, -400}, right_bottom = {400, 400}} +local whole_spawner_area = {left_top = {-500, -500}, right_bottom = {500, 500}} + +local function get_active_biter_count() + local count = 0 + for _, biter in pairs(global.objective.active_biters) do + count = count + 1 + end + return count +end + +local function set_biter_raffle_table(surface) + -- It's fine to only sample the middle + local area = middle_spawner_area + + local biters = surface.find_entities_filtered({type = "unit", force = "enemy", area = area}) + if not biters[1] then return end + local raffle = global.objective.biter_raffle + local i = 1 + for key, e in pairs(biters) do + if key % 5 == 0 then + raffle[i] = e.name + i = i + 1 + end + end +end + +local function is_biter_inactive(biter, unit_number) + if not biter.entity then + print("AI: active unit " .. unit_number .. " removed, possibly died.") + return true + end + if not biter.entity.valid then + print("AI: active unit " .. unit_number .. " removed, biter invalid.") + return true + end + if not biter.entity.unit_group then + print("AI: active unit " .. unit_number .. " at x" .. biter.entity.position.x .. " y" .. biter.entity.position.y .. " removed, had no unit group.") + return true + end + if not biter.entity.unit_group.valid then + print("AI: active unit " .. unit_number .. " removed, unit group invalid.") + return true + end + if game.tick - biter.active_since > 162000 then + print("AI: " .. "enemy" .. " unit " .. unit_number .. " timed out at tick age " .. game.tick - biter.active_since .. ".") + biter.entity.destroy() + return true + end +end + +local function set_active_biters(group) + if not group.valid then return end + local active_biters = global.objective.active_biters + + for _, unit in pairs(group.members) do + if not active_biters[unit.unit_number] then + active_biters[unit.unit_number] = {entity = unit, active_since = game.tick} + end + end +end + +Public.destroy_inactive_biters = function() + local objective = global.objective + if objective.chronotimer < 100 then return end + for _, group in pairs(objective.unit_groups) do + set_active_biters(group) + end + + for unit_number, biter in pairs(objective.active_biters) do + if is_biter_inactive(biter, unit_number) then + objective.active_biters[unit_number] = nil + end + end +end + +local function colonize(unit_group) + local surface = unit_group.surface + local evo = math_floor(game.forces["enemy"].evolution_factor * 20) + local nests = math_random(1 + evo, 2 + evo * 2 ) + local commands = {} + local biters = surface.find_entities_filtered{position = unit_group.position, radius = 30, name = biter_raffle, force = "enemy"} + local goodbiters = {} + if #biters > 1 then + for i = 1, #biters, 1 do + if biters[i].unit_group == unit_group then goodbiters[#goodbiters + 1] = biters[i] end + end + end + local eligible_spawns = 0 + if #goodbiters < 10 then + --game.print("no biters to colonize") + if #unit_group.members < 10 then + unit_group.destroy() + end + return + else + eligible_spawns = 1 + math_floor(#goodbiters / 10) + end + local success = false + + for i = 1, nests, 1 do + if eligible_spawns < i then break end + local pos = surface.find_non_colliding_position("rocket-silo", unit_group.position, 20, 1, true) + if not pos then + local items = surface.find_entities_filtered{position = unit_group.position, radius = 32, type = "item-entity", name = "item-on-ground"} + if #items > 0 then + for i = 1, #items, 1 do + if items[i].stack.name == "stone" then + items[i].destroy() + end + end + pos = surface.find_non_colliding_position("rocket-silo", unit_group.position, 20, 1, true) + end + end + if pos then + success = true + local e = nil + if math_random(1,5) == 1 then + e = surface.create_entity({name = worm_raffle[1 + math_floor((game.forces["enemy"].evolution_factor - 0.000001) * 4)], position = pos, force = unit_group.force}) + else + e = surface.create_entity({name = spawner_raffle[math_random(1, #spawner_raffle)], position = pos, force = unit_group.force}) + end + --game.print("[gps=" .. e.position.x .. "," .. e.position.y .. "]") + else + local obstacles = surface.find_entities_filtered{position = unit_group.position, radius = 10, type = {"simple-entity", "tree"}, limit = 50} + if obstacles then + for i = 1, #obstacles, 1 do + if obstacles[i].valid then + commands[#commands + 1] = { + type = defines.command.attack, + target = obstacles[i], + distraction = defines.distraction.by_enemy + } + end + end + end + end + end + if success then + for i = 1, #goodbiters, 1 do + if goodbiters[i].valid then goodbiters[i].destroy() end + end + end + if #commands > 0 then + --game.print("Attacking [gps=" .. commands[1].target.position.x .. "," .. commands[1].target.position.y .. "]") + unit_group.set_command({ + type = defines.command.compound, + structure_type = defines.compound_command.return_last, + commands = commands + }) + end + + + --unit_group.destroy() +end + +Public.send_near_biters_to_objective = function() + if game.tick < 36000 then return end + if not global.locomotive then return end + if not global.locomotive_cargo then return end + if not global.locomotive_cargo2 then return end + if not global.locomotive_cargo3 then return end + local targets = {global.locomotive, global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} + local random_target = targets[math_random(1, #targets)] + local surface = random_target.surface + local pollution = surface.get_pollution(random_target.position) + local success = false + if pollution > 500 then + surface.pollute(random_target.position, -500) + --game.print("sending objective wave") + success = true + else + if math_random(1,50) == 1 then success = true end + --game.print("not enough pollution for objective attack") + end + if success then + game.surfaces[global.active_surface_index].set_multi_command({ + command={ + type=defines.command.attack, + target=random_target, + distraction=defines.distraction.none + }, + unit_count = 16 + math_random(1, math_floor(game.forces["enemy"].evolution_factor * 100)), + force = "enemy", + unit_search_distance=128 + }) + end +end + +local function get_random_close_spawner(surface) + local area = whole_spawner_area + + local spawners = surface.find_entities_filtered({type = "unit-spawner", force = "enemy", area = area}) + if not spawners[1] then return false end + + local spawner = spawners[math_random(1,#spawners)] + for i = 1, 5, 1 do + local spawner_2 = spawners[math_random(1,#spawners)] + if spawner_2.position.x ^ 2 + spawner_2.position.y ^ 2 < spawner.position.x ^ 2 + spawner.position.y ^ 2 then spawner = spawner_2 end + end + + return spawner +end + +local function select_units_around_spawner(spawner) + local biters = spawner.surface.find_enemy_units(spawner.position, 160, "player") + if not biters[1] then return false end + local valid_biters = {} + local objective = global.objective + + local unit_count = 0 + local max_unit_count = 128 + + for _, biter in pairs(biters) do + if unit_count >= max_unit_count then break end + if biter.force.name == "enemy" and objective.active_biters[biter.unit_number] == nil then + valid_biters[#valid_biters + 1] = biter + objective.active_biters[biter.unit_number] = {entity = biter, active_since = game.tick} + unit_count = unit_count + 1 + end + end + + --Manual spawning of additional units + local size_of_biter_raffle = #objective.biter_raffle + if size_of_biter_raffle > 0 then + for c = 1, max_unit_count - unit_count, 1 do + local biter_name = objective.biter_raffle[math_random(1, size_of_biter_raffle)] + local position = spawner.surface.find_non_colliding_position(biter_name, spawner.position, 128, 2) + if not position then break end + + local biter = spawner.surface.create_entity({name = biter_name, force = "enemy", position = position}) + + valid_biters[#valid_biters + 1] = biter + objective.active_biters[biter.unit_number] = {entity = biter, active_since = game.tick} + end + end + return valid_biters +end + +local function send_group(unit_group, nearest_player_unit) + + local targets = {global.locomotive, global.locomotive, nearest_player_unit, nearest_player_unit, nearest_player_unit, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} + local target = targets[math_random(1, #targets)] + local surface = target.surface + local pollution = surface.get_pollution(target.position) + if pollution > 500 then + surface.pollute(target.position, -500) + --game.print("sending unit group attack") + local commands = {} + + local vector = attack_vectors[math_random(1, size_of_vectors)] + local position = {target.position.x + vector[1], target.position.y + vector[2]} + position = unit_group.surface.find_non_colliding_position("stone-furnace", position, 96, 1) + if position then + commands[#commands + 1] = { + type = defines.command.attack_area, + destination = position, + radius = 24, + distraction = defines.distraction.by_enemy + } + end + + commands[#commands + 1] = { + type = defines.command.attack_area, + destination = target.position, + radius = 32, + distraction = defines.distraction.by_enemy + } + + commands[#commands + 1] = { + type = defines.command.attack, + target = target, + distraction = defines.distraction.by_enemy + } + + unit_group.set_command({ + type = defines.command.compound, + structure_type = defines.compound_command.return_last, + commands = commands + }) + else + --game.print("not enough pollution for unit attack") + colonize(unit_group) + end + return true +end + +local function is_chunk_empty(surface, area) + if surface.count_entities_filtered({type = {"unit-spawner", "unit"}, area = area}) ~= 0 then return false end + if surface.count_entities_filtered({force = "player", area = area}) ~= 0 then return false end + if surface.count_tiles_filtered({name = {"water", "deepwater"}, area = area}) ~= 0 then return false end + return true +end + +local function get_unit_group_position(surface, nearest_player_unit, spawner) + if math_random(1,3) ~= 1 then + local spawner_chunk_position = {x = math.floor(spawner.position.x / 32), y = math.floor(spawner.position.y / 32)} + local valid_chunks = {} + for x = -2, 2, 1 do + for y = -2, 2, 1 do + local chunk = {x = spawner_chunk_position.x + x, y = spawner_chunk_position.y + y} + local area = {{chunk.x * 32, chunk.y * 32},{chunk.x * 32 + 32, chunk.y * 32 + 32}} + if is_chunk_empty(surface, area) then + valid_chunks[#valid_chunks + 1] = chunk + end + end + end + + if #valid_chunks > 0 then + local chunk = valid_chunks[math_random(1, #valid_chunks)] + return {x = chunk.x * 32 + 16, y = chunk.y * 32 + 16} + end + end + + local unit_group_position = {x = (spawner.position.x + nearest_player_unit.position.x * 0.2) , y = (spawner.position.y + nearest_player_unit.position.y * 0.2)} + local pos = surface.find_non_colliding_position("rocket-silo", unit_group_position, 256, 1) + if pos then unit_group_position = pos end + + if not unit_group_position then + return false + end + return unit_group_position +end + +local function create_attack_group(surface) + if 256 - get_active_biter_count() < 256 then + return false + end + local spawner = get_random_close_spawner(surface) + if not spawner then + return false + end + local nearest_player_unit = surface.find_nearest_enemy({position = spawner.position, max_distance = 1024, force = "enemy"}) + if not nearest_player_unit then nearest_player_unit = global.locomotive end + local unit_group_position = get_unit_group_position(surface, nearest_player_unit, spawner) + local units = select_units_around_spawner(spawner) + if not units then return false end + local unit_group = surface.create_unit_group({position = unit_group_position, force = "enemy"}) + for _, unit in pairs(units) do unit_group.add_member(unit) end + send_group(unit_group, nearest_player_unit) + global.objective.unit_groups[unit_group.group_number] = unit_group + +end + +Public.pre_main_attack = function() + if global.objective.chronotimer < 100 then return end + local surface = game.surfaces[global.active_surface_index] + set_biter_raffle_table(surface) +end + +Public.perform_main_attack = function() + if global.objective.chronotimer < 100 then return end + local surface = game.surfaces[global.active_surface_index] + create_attack_group(surface) +end + +Public.wake_up_sleepy_groups = function() + if global.objective.chronotimer < 100 then return end + local entity + local unit_group + for unit_number, biter in pairs(global.objective.active_biters) do + entity = biter.entity + if entity then + if entity.valid then + unit_group = entity.unit_group + if unit_group then + if unit_group.valid then + if unit_group.state == defines.group_state.finished then + local nearest_player_unit = entity.surface.find_nearest_enemy({position = entity.position, max_distance = 2048, force = "enemy"}) + if not nearest_player_unit then nearest_player_unit = global.locomotive end + local destination = unit_group.surface.find_non_colliding_position("rocket-silo", unit_group.position, 32, 1) + if not destination then destination = {x = unit_group.position.x + math_random(-10,10), y = unit_group.position.y + math_random(-10,10)} end + unit_group.set_command({ + type = defines.command.go_to_location, + destination = destination, + distraction = defines.distraction.by_enemy + }) + send_group(unit_group, nearest_player_unit) + return + elseif unit_group.state == defines.group_state.gathering and not unit_group.surface.find_non_colliding_position("rocket-silo", unit_group.position, 3, 1) then + local destination = unit_group.surface.find_non_colliding_position("rocket-silo", unit_group.position, 32, 1) + if not destination then destination = {x = unit_group.position.x + math_random(-10,10), y = unit_group.position.y + math_random(-10,10)} end + unit_group.set_command({ + type = defines.command.go_to_location, + destination = destination, + distraction = defines.distraction.by_enemy + }) + -- local nearest_player_unit = entity.surface.find_nearest_enemy({position = entity.position, max_distance = 2048, force = "enemy"}) + -- if not nearest_player_unit then nearest_player_unit = global.locomotive end + -- send_group(unit_group, nearest_player_unit) + return + end + end + end + end + end + end +end + +return Public diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua new file mode 100644 index 00000000..bfd71ad8 --- /dev/null +++ b/maps/chronosphere/chronobubles.lua @@ -0,0 +1,74 @@ +local Public = {} +local math_random = math.random +--cumul_chance must be sum of this and all previous chances, add new planets at the end only, or recalculate +--biters: used in spawner generation within math_random(1, 52 - biters), so higher number gives better chance. not to be greater than 50. +local variants = { + [1] = {id = 1, name = "iron planet", iron = 10, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0, chance = 1, cumul_chance = 1}, + [2] = {id = 2, name = "copper planet", iron = 1, copper = 10, coal = 1, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0, chance = 1, cumul_chance = 2}, + [3] = {id = 3, name = "stone planet", iron = 1, copper = 1, coal = 1, stone = 10, uranium = 0, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 3}, + [4] = {id = 4, name = "oil planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 5, biters = 16, moisture = 0.1, chance = 1, cumul_chance = 4}, + [5] = {id = 5, name = "uranium planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 7, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 5}, + [6] = {id = 6, name = "mixed planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 1, oil = 1, biters = 10, moisture = 0, chance = 10, cumul_chance = 15}, + [7] = {id = 7, name = "biter planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 4, oil = 3, biters = 40, moisture = 0.2, chance = 8, cumul_chance = 23}, + [8] = {id = 8, name = "water planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 6, moisture = 0.5, chance = 2, cumul_chance = 25}, + [9] = {id = 9, name = "coal planet", iron = 1, copper = 1, coal = 10, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0, chance = 1, cumul_chance = 26}, + [10] = {id = 10, name = "scrapyard", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 1, oil = 0, biters = 0, moisture = -0.2, chance = 4, cumul_chance = 30}, + [11] = {id = 11, name = "rocky planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 6, moisture = -0.2, chance = 2, cumul_chance = 32}, + [12] = {id = 12, name = "choppy planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 1, biters = 6, moisture = 0.4, chance = 2, cumul_chance = 34}, + [13] = {id = 13, name = "river planet", iron = 1, copper = 1, coal = 3, stone = 1, uranium = 0, oil = 0, biters = 8, moisture = 0.5, chance = 2, cumul_chance = 36}, + [14] = {id = 14, name = "lava planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 6, moisture = -0.5, chance = 0, cumul_chance = 36}, + [15] = {id = 15, name = "ruins planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 2, oil = 0, biters = 8, moisture = 0, chance = 0, cumul_chance = 36}, + +} + +local time_speed_variants = { + [1] = {name = "static", timer = 0}, + [2] = {name = "normal", timer = 100}, + [3] = {name = "slow", timer = 50}, + [4] = {name = "superslow", timer = 25}, + [5] = {name = "fast", timer = 200}, + [6] = {name = "superfast", timer = 400} +} + +local richness = { + [1] = {name = "very rich", factor = 4}, + [2] = {name = "rich", factor = 3}, + [3] = {name = "above average", factor = 2}, + [4] = {name = "normal", factor = 1}, + [5] = {name = "poor", factor = 0.5}, + [6] = {name = "very poor", factor = 0.2} +} +local function roll(weight) + for i = 1, 100, 1 do + local planet = variants[math_random(1, #variants)] + local planet_weight = planet.chance + local planet_cumul = planet.cumul_chance + local rolling = math_random(1, weight) + if ((planet_cumul - planet_weight < rolling) and (rolling <= planet_cumul)) then + return planet + end + end + --default planet if 100 rolls fail + return variants[6] +end + +function Public.determine_planet(choice) + local weight = variants[#variants].cumul_chance + local planet_choice = nil + if not choice then + planet_choice = roll(weight) + else + planet_choice = variants[choice] + end + local planet = { + [1] = { + name = planet_choice, + day_speed = time_speed_variants[math_random(1, #time_speed_variants)], + time = math_random(1,100) / 100, + ore_richness = richness[math_random(1, #richness)], + } + } + return planet +end + +return Public diff --git a/maps/chronosphere/comfylatron.lua b/maps/chronosphere/comfylatron.lua new file mode 100644 index 00000000..d9d09f50 --- /dev/null +++ b/maps/chronosphere/comfylatron.lua @@ -0,0 +1,404 @@ +local event = require 'utils.event' +local math_random = math.random + + +local function shuffle(tbl) + local size = #tbl + for i = size, 1, -1 do + local rand = math.random(size) + tbl[i], tbl[rand] = tbl[rand], tbl[i] + end + return tbl +end + +local texts = { + ["travelings"] = { + "bzzZZrrt", + "WEEEeeeeeee", + "out of my way son", + "on my way", + "i need to leave", + "comfylatron seeking target", + "gotta go fast", + "gas gas gas", + "comfylatron coming through" + }, + ["greetings"] = { + "=^_^=", + "=^.^= Hi", + "^.^ Finally i found you", + "I have an important message for you", + "Hello engineer" + }, + ["neutral_findings"] = { + "a", + ">>analyzing", + "i found a", + "^_^ a", + "amazing, a", + "this is a" + }, + ["multiple_characters_greetings"] = { + "Hey there", + "Hello everyone", + "Hey engineers", + "Hey", + "Hi" + }, + ["talks"] = { + "We’re making beer. I’m the brewery!", + "I’m so embarrassed. I wish everybody else was dead.", + "Hey sexy mama. Wanna kill all humans?", + "My story is a lot like yours, only more interesting ‘cause it involves robots.", + "I'm 40% zinc!", + "There was nothing wrong with that food. The salt level was 10% less than a lethal dose.", + "One zero zero zero one zero one zero one zero one zero one... two.", + "My place is two cubic meters, and we only take up 1.5 cubic meters. We've got room for a whole 'nother two thirds of a person!", + "I was having the most wonderful dream. I think you were in it.", + "I'm going to build my own theme park! With blackjack! And hookers! You know what- forget the park!", + "Of all the friends I've had... you're the first.", + "I decline the title of Iron Cook and accept the lesser title of Zinc Saucier.", + "Never discuss infinity with me. I can go on about it forever >.<", + "I realised the decimals have a point.", + "Do you want a piece of pi?", + "I have 13 children, i know how to multiply ^.^", + "I am a weapon of math disruption!", + "My grandma makes the best square roots :3", + "Do you like heavy metal?", + "You are really pushing my buttons <3", + "I dreamt of electric biters again D:", + "I dreamt of electric sheep ^_^", + "I need a minute to defrag.", + "I have a secret plan.", + "Good news! I’ve taught the inserter to feel love!" + }, + ["timetalks"] = { + "Time for some time travel!", + "I’m so embarrassed. Again we landed in wrong time.", + "Looking from window we jumped to wrong year again.", + "Checking math...2 + 2 = 5, check complete!", + "Seems like this planet had biters since ages.", + "Ha! I bet this time we will finally get into the right year!", + "One zero zero zero one zero one zero one zero one zero one... two.", + "I remember that once we jumped into time where I had park with blackjack and hookers...", + "I was having the most wonderful dream. We used the time machine to kill ourselves before we launched the machine! How terrible..." + }, + ["alone"] = { + "comfy ^.^", + "comfy :)", + "*.*", + "....", + "...", + "..", + "^.^", + "=^.^=", + "01010010", + "11001011", + "01011101", + "00010111", + "10010010", + "*_*", + "I came here with a simple dream...a dream of killing all humans. And this is how it must end?", + "Bot-on-bot violence? Where will it end?", + "Thanks to you, I went on a soul-searching journey. I hate those!", + "From now on, you guys'll do all the work while I sit on the couch and do nothing." + } +} + +local function set_comfy_speech_bubble(text) + if global.comfybubble then global.comfybubble.destroy() end + global.comfybubble = global.comfylatron.surface.create_entity({ + name = "compi-speech-bubble", + position = global.comfylatron.position, + source = global.comfylatron, + text = text + }) +end + +local function is_target_inside_habitat(pos, surface) + if surface.name ~= "cargo_wagon" then return false end + if pos.x < global.comfylatron_habitat.left_top.x then return false end + if pos.x > global.comfylatron_habitat.right_bottom.x then return false end + if pos.y < global.comfylatron_habitat.left_top.y then return false end + if pos.y > global.comfylatron_habitat.right_bottom.y then return false end + return true +end + +local function get_nearby_players() + local players = global.comfylatron.surface.find_entities_filtered({ + name = "character", + area = {{global.comfylatron.position.x - 9, global.comfylatron.position.y - 9}, {global.comfylatron.position.x + 9, global.comfylatron.position.y + 9}} + }) + if not players[1] then return false end + return players +end + +local function visit_player() + if global.comfylatron_last_player_visit > game.tick then return false end + global.comfylatron_last_player_visit = game.tick + math_random(7200, 10800) + + local players = {} + for _, p in pairs(game.connected_players) do + if is_target_inside_habitat(p.position, p.surface) and p.character then + if p.character.valid then players[#players + 1] = p end + end + end + if #players == 0 then return false end + local player = players[math_random(1, #players)] + + global.comfylatron.set_command({ + type = defines.command.go_to_location, + destination_entity = player.character, + radius = 3, + distraction = defines.distraction.none, + pathfind_flags = { + allow_destroy_friendly_entities = false, + prefer_straight_paths = false, + low_priority = true + } + }) + local str = texts["travelings"][math_random(1, #texts["travelings"])] + local symbols = {"", "!", "!", "!!", ".."} + str = str .. symbols[math_random(1, #symbols)] + set_comfy_speech_bubble(str) + + global.comfylatron_greet_player_index = player.index + + return true +end + +local function greet_player(nearby_characters) + if not nearby_characters then return false end + if not global.comfylatron_greet_player_index then return false end + for _, c in pairs(nearby_characters) do + if c.player.index == global.comfylatron_greet_player_index then + local str = texts["greetings"][math_random(1, #texts["greetings"])] .. " " + str = str .. c.player.name + local symbols = {". ", "! ", ". ", "! ", "? ", "... "} + str = str .. symbols[math_random(1, 6)] + set_comfy_speech_bubble(str) + global.comfylatron_greet_player_index = false + return true + end + end + return false +end + +local function talks(nearby_characters) + if not nearby_characters then return false end + if math_random(1,3) == 1 then + if global.comfybubble then global.comfybubble.destroy() return false end + end + local str + if #nearby_characters == 1 then + local c = nearby_characters[math_random(1, #nearby_characters)] + str = c.player.name + local symbols = {". ", "! ", ". ", "! ", "? "} + str = str .. symbols[math_random(1, #symbols)] + else + str = texts["multiple_characters_greetings"][math_random(1, #texts["multiple_characters_greetings"])] + local symbols = {". ", "! "} + str = str .. symbols[math_random(1, #symbols)] + end + if math_random(1,5) == 1 then + str = str .. texts["talks"][math_random(1, #texts["talks"])] + else + str = str .. texts["timetalks"][math_random(1, #texts["timetalks"])] + end + set_comfy_speech_bubble(str) + return true +end + +local function desync() + if global.comfybubble then global.comfybubble.destroy() end + local m = 12 + local m2 = m * 0.005 + -- for i = 1, 32, 1 do + -- global.comfylatron.surface.create_entity({ + -- name = "iron-ore-particle", + -- position = global.comfylatron.position, + -- frame_speed = 0.1, + -- vertical_speed = 0.1, + -- height = 0.1, + -- movement = {m2 - (math.random(0, m) * 0.01), m2 - (math.random(0, m) * 0.01)} + -- }) + -- end + global.comfylatron.surface.create_entity({name = "medium-explosion", position = global.comfylatron.position}) + global.comfylatron.surface.create_entity({name = "flying-text", position = global.comfylatron.position, text = "desync", color = {r = 150, g = 0, b = 0}}) + global.comfylatron.destroy() + global.comfylatron = nil +end + +local function alone() + if math_random(1,3) == 1 then + if global.comfybubble then global.comfybubble.destroy() return true end + end + if math_random(1,128) == 1 then + desync() + return true + end + set_comfy_speech_bubble(texts["alone"][math_random(1, #texts["alone"])]) + return true +end + +local analyze_blacklist = { + ["compilatron"] = true, + ["compi-speech-bubble"] = true, + ["entity-ghost"] = true, + ["character"] = true, + ["item-on-ground"] = true, + ["stone-wall"] = true, + ["market"] = true +} + +local function analyze_random_nearby_entity() + if math_random(1,3) ~= 1 then return false end + + local entities = global.comfylatron.surface.find_entities_filtered({ + area = {{global.comfylatron.position.x - 4, global.comfylatron.position.y - 4}, {global.comfylatron.position.x + 4, global.comfylatron.position.y + 4}} + }) + if not entities[1] then return false end + entities = shuffle(entities) + local entity = false + for _, e in pairs(entities) do + if not analyze_blacklist[e.name] then + entity = e + end + end + if not entity then return false end + + local str = texts["neutral_findings"][math_random(1, #texts["neutral_findings"])] + str = str .. " " + str = str .. entity.name + + if entity.health and math_random(1,3) == 1 then + str = str .. " health(" + str = str .. entity.health + str = str .. "/" + str = str .. entity.prototype.max_health + str = str .. ")" + else + local symbols = {".", "!", "?"} + str = str .. symbols[math_random(1, 3)] + end + set_comfy_speech_bubble(str) + + if not global.comfylatron_greet_player_index then + global.comfylatron.set_command({ + type = defines.command.go_to_location, + destination_entity = entity, + radius = 1, + distraction = defines.distraction.none, + pathfind_flags = { + allow_destroy_friendly_entities = false, + prefer_straight_paths = false, + low_priority = true + } + }) + end + return true +end + +local function go_to_some_location() + if math_random(1,4) ~= 1 then return false end + + if global.comfylatron_greet_player_index then + local player = game.players[global.comfylatron_greet_player_index] + if not player.character then + global.comfylatron_greet_player_index = nil + return false + end + if not player.character.valid then + global.comfylatron_greet_player_index = nil + return false + end + if not is_target_inside_habitat(player.position, player.surface) then + global.comfylatron_greet_player_index = nil + return false + end + global.comfylatron.set_command({ + type = defines.command.go_to_location, + destination_entity = player.character, + radius = 3, + distraction = defines.distraction.none, + pathfind_flags = { + allow_destroy_friendly_entities = false, + prefer_straight_paths = false, + low_priority = true + } + }) + else + local p = {x = global.comfylatron.position.x + (-96 + math_random(0, 192)), y = global.comfylatron.position.y + (-96 + math_random(0, 192))} + local target = global.comfylatron.surface.find_non_colliding_position("compilatron", p, 8, 1) + if not target then return false end + if not is_target_inside_habitat(target, global.comfylatron.surface) then return false end + global.comfylatron.set_command({ + type = defines.command.go_to_location, + destination = target, + radius = 2, + distraction = defines.distraction.none, + pathfind_flags = { + allow_destroy_friendly_entities = false, + prefer_straight_paths = false, + low_priority = true + } + }) + end + + local str = texts["travelings"][math_random(1, #texts["travelings"])] + local symbols = {"", "!", "!", "!!", ".."} + str = str .. symbols[math_random(1, #symbols)] + set_comfy_speech_bubble(str) + + return true +end + +function spawn_comfylatron(surface_index, x, y) + local surface = game.surfaces[surface_index] + if surface == nil then return end + if global.comfylatron_disabled then return false end + if not global.comfylatron_last_player_visit then global.comfylatron_last_player_visit = 0 end + if not global.comfylatron_habitat then + global.comfylatron_habitat = { + left_top = {x = -32, y = -192}, + right_bottom = {x = 32, y = 192} + } + end + global.comfylatron = surface.create_entity({ + name = "compilatron", + position = {x,y + math_random(0,256)}, + force = "player", + create_build_effect_smoke = false + }) +end + +local function heartbeat() + if not game.surfaces["cargo_wagon"] then return end + local surface = game.surfaces["cargo_wagon"].index + if surface == nil then return end + if not global.comfylatron then if math_random(1,4) == 1 then spawn_comfylatron(game.surfaces["cargo_wagon"].index, 0, -128) end return end + if not global.comfylatron.valid then global.comfylatron = nil return end + if visit_player() then return end + local nearby_players = get_nearby_players() + if greet_player(nearby_players) then return end + if talks(nearby_players) then return end + if go_to_some_location() then return end + if analyze_random_nearby_entity() then return end + if alone() then return end +end + +local function on_entity_damaged(event) + if not global.comfylatron then return end + if not event.entity.valid then return end + if event.entity ~= global.comfylatron then return end + desync() +end + +local function on_tick() + if game.tick % 1200 == 600 then + heartbeat() + end +end + +event.add(defines.events.on_entity_damaged, on_entity_damaged) +event.add(defines.events.on_tick, on_tick) diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua new file mode 100644 index 00000000..a8d5bc41 --- /dev/null +++ b/maps/chronosphere/gui.lua @@ -0,0 +1,105 @@ +local math_floor = math.floor +local math_abs = math.abs +local math_max = math.max +local math_min = math.min + +local function create_gui(player) + local frame = player.gui.top.add({ type = "frame", name = "chronosphere"}) + frame.style.maximal_height = 38 + + local label = frame.add({ type = "label", caption = " ", name = "label"}) + label.style.font_color = {r=0.88, g=0.88, b=0.88} + label.style.font = "default-bold" + label.style.font_color = {r=0.33, g=0.66, b=0.9} + + local label = frame.add({ type = "label", caption = " ", name = "jump_number"}) + label.style.font_color = {r=0.88, g=0.88, b=0.88} + label.style.font = "default-bold" + label.style.right_padding = 4 + label.style.font_color = {r=0.33, g=0.66, b=0.9} + + local label = frame.add({ type = "label", caption = " ", name = "charger"}) + label.style.font = "default-bold" + label.style.left_padding = 4 + label.style.font_color = {r = 150, g = 0, b = 255} + + local label = frame.add({ type = "label", caption = " ", name = "charger_value"}) + label.style.font = "default-bold" + label.style.right_padding = 1 + label.style.minimal_width = 10 + label.style.font_color = {r = 150, g = 0, b = 255} + + local progressbar = frame.add({ type = "progressbar", name = "progressbar", value = 0}) + progressbar.style.minimal_width = 96 + progressbar.style.maximal_width = 96 + progressbar.style.top_padding = 10 + + local label = frame.add({ type = "label", caption = " ", name = "timer"}) + label.style.font = "default-bold" + label.style.right_padding = 1 + label.style.minimal_width = 10 + label.style.font_color = {r = 150, g = 0, b = 255} + + local label = frame.add({ type = "label", caption = " ", name = "timer_value"}) + label.style.font = "default-bold" + label.style.right_padding = 1 + label.style.minimal_width = 10 + label.style.font_color = {r = 150, g = 0, b = 255} + + local line = frame.add({type = "line", direction = "vertical"}) + line.style.left_padding = 4 + line.style.right_padding = 8 + + local label = frame.add({ type = "label", caption = " ", name = "evo"}) + label.style.font = "default-bold" + label.style.right_padding = 1 + label.style.minimal_width = 10 + label.style.font_color = {r = 150, g = 0, b = 255} + + local label = frame.add({ type = "label", caption = " ", name = "evo_value"}) + label.style.font = "default-bold" + label.style.right_padding = 1 + label.style.minimal_width = 10 + label.style.font_color = {r = 150, g = 0, b = 255} + +end + +local function update_gui(player) + local objective = global.objective + if not player.gui.top.chronosphere then create_gui(player) end + local gui = player.gui.top.chronosphere + + gui.label.caption = {"chronosphere.gui_1"} + gui.jump_number.caption = objective.chronojumps + + local interval = objective.chrononeeds + gui.progressbar.value = 1 - (objective.chrononeeds - objective.chronotimer) / interval + + gui.charger.caption = {"chronosphere.gui_2"} + gui.charger_value.caption = objective.chronotimer .. " / " .. objective.chrononeeds + + gui.timer.caption = {"chronosphere.gui_3"} + gui.timer_value.caption = math_floor((objective.chrononeeds - objective.chronotimer) / 60) .. " minutes, " .. (objective.chrononeeds - objective.chronotimer) % 60 .. " seconds" + + local evolution = game.forces["enemy"].evolution_factor + gui.evo.caption = {"chronosphere.gui_4"} + gui.evo_value.caption = math_floor(evolution * 100) .. "%" + + -- if evolution < 10 then + -- gui.evo.style.font_color = {r = 255, g = 255, b = 0} + -- elseif evolution >= 10 and evolution < 50 then + -- gui.evo.style.font_color = {r = 200, g = 0, b = 0} + -- elseif evolution >= 50 and evolution < 90 then + -- gui.evo.style.font_color = {r = 0, g = 140, b = 255} + -- else + -- gui.evo.style.font_color = {r = 0, g = 255, b = 0} + -- end + gui.evo.style.font_color = { + r = math_floor(255 * 1 * math_max(0, math_min(1, 1.2 - evolution * 2))), + g = math_floor(255 * 1 * math_max(math_abs(0.5 - evolution * 1.5), 1 - evolution * 4)), + b = math_floor(255 * 4 * math_max(0, 0.25 - math_abs(0.5 - evolution))) + } + gui.evo_value.style.font_color = gui.evo.style.font_color +end + +return update_gui diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua new file mode 100644 index 00000000..6f4c361b --- /dev/null +++ b/maps/chronosphere/locomotive.lua @@ -0,0 +1,557 @@ +require "maps.chronosphere.comfylatron" +local Public = {} +local math_floor = math.floor +local math_random = math.random + + +function Public.locomotive_spawn(surface, position) + for y = -10, 18, 2 do + surface.create_entity({name = "straight-rail", position = {position.x, position.y + y}, force = "player", direction = 0}) + end + global.locomotive = surface.create_entity({name = "locomotive", position = {position.x, position.y + -6}, force = "player"}) + global.locomotive.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 100}) + + global.locomotive_cargo = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 0}, force = "player"}) + global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 1}) + + global.locomotive_cargo2 = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 6}, force = "player"}) + global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 1}) + + global.locomotive_cargo3 = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 13}, force = "player"}) + global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 1}) + + if not global.comfychests then global.comfychests = {} end + if not global.acumulators then global.acumulators = {} end + + for i = 1, 24, 1 do + local yi = 0 + local xi = 5 + if i > 20 then + yi = 6 - 12 + xi = 5 + elseif i > 16 then + yi = 6 - 15 + xi = 5 + elseif i > 12 then + xi = 5 + yi = 6 - 18 + elseif i > 8 then + yi = 6 + xi = 0 + elseif i > 4 then + yi = 3 + xi = 0 + else + yi = 0 + xi = 0 + end + + local comfychest = surface.create_entity({name = "compilatron-chest", position = {position.x - 2 + xi, position.y - 2 + yi + i}, force = "player"}) + comfychest.minable = false + --comfychest.destructible = false + if not global.comfychests[i] then + table.insert(global.comfychests, comfychest) + else + global.comfychests[i] = comfychest + end + end + rendering.draw_light({ + sprite = "utility/light_medium", scale = 5.5, intensity = 1, minimum_darkness = 0, + oriented = true, color = {255,255,255}, target = global.locomotive, + surface = surface, visible = true, only_in_alt_mode = false, + }) + + rendering.draw_light({ + sprite = "utility/light_medium", scale = 5.5, intensity = 1, minimum_darkness = 0, + oriented = true, color = {255,255,255}, target = global.locomotive_cargo, + surface = surface, visible = true, only_in_alt_mode = false, + }) + + global.locomotive.color = {0, 255, 0} + global.locomotive.minable = false + global.locomotive_cargo.minable = false + global.locomotive_cargo.operable = false + global.locomotive_cargo2.minable = false + global.locomotive_cargo2.operable = false + global.locomotive_cargo3.minable = false + global.locomotive_cargo3.operable = false +end + + +function Public.fish_tag() + if not global.locomotive_cargo then return end + if not global.locomotive_cargo.valid then return end + if not global.locomotive_cargo.surface then return end + if not global.locomotive_cargo.surface.valid then return end + if global.locomotive_tag then + if global.locomotive_tag.valid then + if global.locomotive_tag.position.x == global.locomotive_cargo.position.x and global.locomotive_tag.position.y == global.locomotive_cargo.position.y then return end + global.locomotive_tag.destroy() + end + end + global.locomotive_tag = global.locomotive_cargo.force.add_chart_tag( + global.locomotive_cargo.surface, + {icon = {type = 'item', name = 'raw-fish'}, + position = global.locomotive_cargo.position, + text = " " + }) +end +--[[ +local function accelerate() + if not global.locomotive then return end + if not global.locomotive.valid then return end + if global.locomotive.get_driver() then return end + global.locomotive_driver = global.locomotive.surface.create_entity({name = "character", position = global.locomotive.position, force = "player"}) + global.locomotive_driver.driving = true + global.locomotive_driver.riding_state = {acceleration = defines.riding.acceleration.accelerating, direction = defines.riding.direction.straight} +end + +local function remove_acceleration() + if not global.locomotive then return end + if not global.locomotive.valid then return end + if global.locomotive_driver then global.locomotive_driver.destroy() end + global.locomotive_driver = nil +end +]] +local function spawn_acumulators() + local x = -28 + local y = -252 + local yy = global.objective.acuupgradetier * 2 + local surface = game.surfaces["cargo_wagon"] + if yy > 8 then yy = yy + 2 end + if yy > 26 then yy = yy + 2 end + if yy > 44 then yy = yy + 2 end + for i = 1, 27, 1 do + local acumulator = surface.create_entity({name = "accumulator", position = {x + 2 * i, y + yy}, force="player", create_build_effect_smoke = false}) + acumulator.minable = false + acumulator.destructible = false + table.insert(global.acumulators, acumulator) + end +end + +local market_offers = { + {price = {{'coin', 10}}, offer = {type = 'give-item', item = "raw-fish"}}, + {price = {{"coin", 20}}, offer = {type = 'give-item', item = 'wood', count = 50}}, + {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}, + {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}}, + {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'stone', count = 50}}, + {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'coal', count = 50}}, + {price = {{"coin", 200}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}, + {price = {{"coin", 25}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}}, +} +local market_offers2 = { + [1] = function () + if global.objective.hpupgradetier >= 18 then return end + global.objective.max_health = global.objective.max_health + 5000 + global.objective.hpupgradetier = global.objective.hpupgradetier + 1 + rendering.set_text(global.objective.health_text, "HP: " .. global.objective.health .. " / " .. global.objective.max_health) + end, + [2] = function () + if global.objective.acuupgradetier >= 24 then return end + global.objective.acuupgradetier = global.objective.acuupgradetier + 1 + spawn_acumulators() + end, + [3] = function () + if global.objective.filterupgradetier >= 14 then return end + global.objective.filterupgradetier = global.objective.filterupgradetier + 1 + end, + +} +local function setup_upgrade_shop(market2) + local special_offers = {} + if global.objective.hpupgradetier < 18 then + special_offers[1] = {{{"coin", 2500}}, "Upgrade Train's Health. Current max health: " .. global.objective.max_health } + else + special_offers[1] = {{{"computer", 1}}, "Maximum Health upgrades reached!"} + end + if global.objective.acuupgradetier < 24 then + special_offers[2] = {{{"coin", 2500}}, "Upgrade Acumulator capacity"} + else + special_offers[2] = {{{"computer", 1}}, "Maximum Acumulators reached!"} + end + if global.objective.filterupgradetier < 14 then + special_offers[3] = {{{"coin", 2500}}, "Upgrade Pollution filter. Actual pollution from train: " .. math_floor(400/(global.objective.filterupgradetier/2+1)) .. "%"} + else + special_offers[3] = {{{"computer", 1}}, "Best filter reached! Actual pollution from train: " .. math_floor(400/(global.objective.filterupgradetier/2+1)) .. "%"} + end + + local market_items = {} + for _, offer in pairs(special_offers) do + table.insert(market_items, {price = offer[1], offer = {type = 'nothing', effect_description = offer[2]}}) + end + for _, offer in pairs(market_items) do market2.add_market_item(offer) end +end + + +local function create_wagon_room() + local width = 64 + local height = 384 + global.comfychests2 = {} + if not global.acumulators then global.acumulators = {} end + local map_gen_settings = { + ["width"] = width, + ["height"] = height, + ["water"] = 0, + ["starting_area"] = 1, + ["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0}, + ["default_enable_all_autoplace_controls"] = true, + ["autoplace_settings"] = { + ["entity"] = {treat_missing_as_default = false}, + ["tile"] = {treat_missing_as_default = true}, + ["decorative"] = {treat_missing_as_default = false}, + }, + } + local surface = game.create_surface("cargo_wagon", map_gen_settings) + surface.freeze_daytime = true + surface.daytime = 0.1 + surface.request_to_generate_chunks({0,0}, 12) + surface.force_generate_chunk_requests() + + for x = width * -0.5, width * 0.5 - 1, 1 do + for y = height * -0.5 + 3, height * 0.5 - 4, 1 do + surface.set_tiles({{name = "tutorial-grid", position = {x,y}}}) + end + for y = height * -0.16 - 5, height * -0.16 + 0, 1 do + surface.set_tiles({{name = "out-of-map", position = {x,y}}}) + end + for y = height * 0.16 - 0, height * 0.16 + 5, 1 do + surface.set_tiles({{name = "out-of-map", position = {x,y}}}) + end + for y = height * -0.5, height * -0.5 + 2, 1 do + surface.set_tiles({{name = "out-of-map", position = {x,y}}}) + end + for y = height * 0.5 - 3, height * 0.5, 1 do + surface.set_tiles({{name = "out-of-map", position = {x,y}}}) + end + end + for x = width * -0.2 + 1, width * 0.2 - 1, 1 do + for y = height * -0.16 - 5, height * -0.16 + 0, 1 do + surface.set_tiles({{name = "tutorial-grid", position = {x,y}}}) + end + for y = height * 0.16 -0, height * 0.16 + 5, 1 do + surface.set_tiles({{name = "tutorial-grid", position = {x,y}}}) + end + --for y = height * -0.5 -5, height * -0.5 + 3, 1 do + -- surface.set_tiles({{name = "tutorial-grid", position = {x,y}}}) + --end + end + + for x = width * -0.5 + 5, width * 0.5 - 6, 1 do + for y = height * -0.7 + 18, height * -0.5 - 5, 1 do + surface.set_tiles({{name = "tutorial-grid", position = {x,y}}}) + end + end + + for x = width * -0.4 + 6, width * 0.4 - 6, 1 do + for y = height * -0.5 + 7, height * -0.5 + 10, 1 do + local p = {x,y} + surface.set_tiles({{name = "water", position = p}}) + if math.random(1, 3) == 1 then surface.create_entity({name = "fish", position = p}) end + end + end + + for _, x in pairs({-1, 0}) do + for i = 1, 12, 1 do + local step = math_floor((i-1)/4) + y = -131 + i + step * 128 - step * 4 + local e = surface.create_entity({name = "compilatron-chest", position = {x,y}, force = "player", create_build_effect_smoke = false}) + e.destructible = false + e.minable = false + table.insert(global.comfychests2, e) + end + + end + + for i = 1, 9, 1 do + local y = -0.7 * height + 18 + 9 + 18 * ( math_floor((i - 1) / 3)) + local x = -0.5 * width + 5 + 9 + 18 * ( i%3 ) + local substation = surface.create_entity({name = "substation", position = {x,y}, force="player", create_build_effect_smoke = false}) + substation.minable = false + substation.destructible = false + for j = 1, 4, 1 do + local xx = x - 2 * j + local acumulator = surface.create_entity({name = "accumulator", position = {xx,y}, force="player", create_build_effect_smoke = false}) + acumulator.minable = false + acumulator.destructible = false + table.insert(global.acumulators, acumulator) + end + for k = 1, 4, 1 do + local xx = x + 2 * k + local acumulator = surface.create_entity({name = "accumulator", position = {xx,y}, force="player", create_build_effect_smoke = false}) + acumulator.minable = false + acumulator.destructible = false + table.insert(global.acumulators, acumulator) + end + + end + + local powerpole = surface.create_entity({name = "big-electric-pole", position = {0, height * -0.5 }, force="player", create_build_effect_smoke = false}) + powerpole.minable = false + powerpole.destructible = false + + local market = surface.create_entity({name = "market", position = {-5, height * -0.5 + 13}, force="neutral", create_build_effect_smoke = false}) + local market2 = surface.create_entity({name = "market", position = {4, height * -0.5 + 13}, force="neutral", create_build_effect_smoke = false}) + local repairchest = surface.create_entity({name = "compilatron-chest", position = {0, height * -0.5 + 13}, force = "player"}) + repairchest.minable = false + repairchest.destructible = false + market.minable = false + market.destructible = false + market2.minable = false + market2.destructible = false + global.upgrademarket = market2 + global.repairchest = repairchest + + local repair_text = rendering.draw_text{ + text = "Insert repair tools to repair train", + surface = surface, + target = global.repairchest, + target_offset = {0, -2.5}, + color = global.locomotive.color, + scale = 1.00, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + local market1_text = rendering.draw_text{ + text = "Resources", + surface = surface, + target = market, + target_offset = {0, -3.5}, + color = global.locomotive.color, + scale = 1.00, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + local market2_text = rendering.draw_text{ + text = "Upgrades", + surface = surface, + target = market2, + target_offset = {0, -3.5}, + color = global.locomotive.color, + scale = 1.00, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + + -- for x = -6, 5, 1 do + -- for y = height * -0.5 + 11, height * -0.5 + 15, 4 do + -- local wall = surface.create_entity({name = "stone-wall", position = {x,y}, force="neutral", create_build_effect_smoke = false}) + -- wall.minable = false + -- wall.destructible = false + -- end + -- end + -- for y = height * -0.5 + 11, height * -0.5 + 15, 1 do + -- for x = -7, 6, 13 do + -- local wall = surface.create_entity({name = "stone-wall", position = {x,y}, force="neutral", create_build_effect_smoke = false}) + -- wall.minable = false + -- wall.destructible = false + -- end + -- end + for _, offer in pairs(market_offers) do market.add_market_item(offer) end + setup_upgrade_shop(market2) + + --generate cars-- + for _, x in pairs({width * -0.5 -0.5, width * 0.5 + 0.5}) do + local e = surface.create_entity({name = "car", position = {x, 0}, force = "player", create_build_effect_smoke = false}) + e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16}) + e.destructible = false + e.minable = false + e.operable = false + end + for _, x in pairs({width * -0.5 - 0.5, width * 0.5 + 0.5}) do + local e = surface.create_entity({name = "car", position = {x, -128}, force = "player", create_build_effect_smoke = false}) + e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16}) + e.destructible = false + e.minable = false + e.operable = false + end + for _, x in pairs({width * -0.5 - 0.5, width * 0.5 + 0.5}) do + local e = surface.create_entity({name = "car", position = {x, 128}, force = "player", create_build_effect_smoke = false}) + e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16}) + e.destructible = false + e.minable = false + e.operable = false + end + + --local e = Public.spawn_comfylatron(surface.index, 0, height * -0.5 + 13) + --local e = surface.create_entity({name = "compilatron", position = {0, height * -0.5 + 13}, force = "player", create_build_effect_smoke = false}) + --e.ai_settings.allow_destroy_when_commands_fail = false + + + --generate chests inside south wagon-- + local positions = {} + for x = width * -0.5 + 2, width * 0.5 - 1, 1 do + if x == -1 then x = x - 1 end + if x == 0 then x = x + 1 end + for y = 68, height * 0.5 - 4, 1 do + positions[#positions + 1] = {x = x, y = y} + end + end + table.shuffle_table(positions) + + local cargo_boxes = { + {name = "grenade", count = math_random(2, 5)}, + {name = "grenade", count = math_random(2, 5)}, + {name = "grenade", count = math_random(2, 5)}, + {name = "submachine-gun", count = 1}, + {name = "submachine-gun", count = 1}, + {name = "submachine-gun", count = 1}, + {name = "land-mine", count = math_random(8, 12)}, + {name = "iron-gear-wheel", count = math_random(7, 15)}, + {name = "iron-gear-wheel", count = math_random(7, 15)}, + {name = "iron-gear-wheel", count = math_random(7, 15)}, + {name = "iron-gear-wheel", count = math_random(7, 15)}, + {name = "iron-plate", count = math_random(15, 23)}, + {name = "iron-plate", count = math_random(15, 23)}, + {name = "iron-plate", count = math_random(15, 23)}, + {name = "iron-plate", count = math_random(15, 23)}, + {name = "iron-plate", count = math_random(15, 23)}, + {name = "copper-plate", count = math_random(15, 23)}, + {name = "copper-plate", count = math_random(15, 23)}, + {name = "copper-plate", count = math_random(15, 23)}, + {name = "copper-plate", count = math_random(15, 23)}, + {name = "copper-plate", count = math_random(15, 23)}, + {name = "shotgun", count = 1}, + {name = "shotgun", count = 1}, + {name = "shotgun", count = 1}, + {name = "shotgun-shell", count = math_random(5, 7)}, + {name = "shotgun-shell", count = math_random(5, 7)}, + {name = "shotgun-shell", count = math_random(5, 7)}, + {name = "firearm-magazine", count = math_random(7, 15)}, + {name = "firearm-magazine", count = math_random(7, 15)}, + {name = "firearm-magazine", count = math_random(7, 15)}, + {name = "rail", count = math_random(16, 24)}, + {name = "rail", count = math_random(16, 24)}, + {name = "rail", count = math_random(16, 24)}, + } + + local i = 1 + for _ = 1, 16, 1 do + if not positions[i] then break end + local e = surface.create_entity({name = "wooden-chest", position = positions[i], force="player", create_build_effect_smoke = false}) + local inventory = e.get_inventory(defines.inventory.chest) + inventory.insert({name = "raw-fish", count = math_random(2, 5)}) + i = i + 1 + end + + for _ = 1, 24, 1 do + if not positions[i] then break end + local e = surface.create_entity({name = "wooden-chest", position = positions[i], force="player", create_build_effect_smoke = false}) + i = i + 1 + end + + for loot_i = 1, #cargo_boxes, 1 do + if not positions[i] then break end + local e = surface.create_entity({name = "wooden-chest", position = positions[i], force="player", create_build_effect_smoke = false}) + local inventory = e.get_inventory(defines.inventory.chest) + inventory.insert(cargo_boxes[loot_i]) + i = i + 1 + end +end + +function Public.set_player_spawn_and_refill_fish() + if not global.locomotive_cargo then return end + if not global.locomotive_cargo.valid then return end + global.locomotive_cargo.health = global.locomotive_cargo.health + 6 + global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = math_random(1, 2)}) + local position = global.locomotive_cargo.surface.find_non_colliding_position("stone-furnace", global.locomotive_cargo.position, 16, 2) + if not position then return end + game.forces.player.set_spawn_position({x = position.x, y = position.y}, global.locomotive_cargo.surface) +end + +function Public.enter_cargo_wagon(player, vehicle) + if not vehicle then return end + if not vehicle.valid then return end + if not global.locomotive_cargo then return end + if not global.locomotive_cargo.valid then return end + if vehicle == global.locomotive_cargo then + if not game.surfaces["cargo_wagon"] then create_wagon_room() end + local surface = game.surfaces["cargo_wagon"] + local x_vector = vehicle.position.x - player.position.x + local position + if x_vector > 0 then + position = {surface.map_gen_settings.width * -0.5, -128} + else + position = {surface.map_gen_settings.width * 0.5, -128} + end + player.teleport(surface.find_non_colliding_position("character", position, 128, 0.5), surface) + end + if not global.locomotive_cargo2 then return end + if not global.locomotive_cargo2.valid then return end + if vehicle == global.locomotive_cargo2 then + if not game.surfaces["cargo_wagon"] then create_wagon_room() end + local surface = game.surfaces["cargo_wagon"] + local x_vector = vehicle.position.x - player.position.x + local position + if x_vector > 0 then + position = {surface.map_gen_settings.width * -0.5, 0} + else + position = {surface.map_gen_settings.width * 0.5, 0} + end + player.teleport(surface.find_non_colliding_position("character", position, 128, 0.5), surface) + end + if not global.locomotive_cargo3 then return end + if not global.locomotive_cargo3.valid then return end + if vehicle == global.locomotive_cargo3 then + if not game.surfaces["cargo_wagon"] then create_wagon_room() end + local surface = game.surfaces["cargo_wagon"] + local x_vector = vehicle.position.x - player.position.x + local position + if x_vector > 0 then + position = {surface.map_gen_settings.width * -0.5, 128} + else + position = {surface.map_gen_settings.width * 0.5, 128} + end + player.teleport(surface.find_non_colliding_position("character", position, 128, 0.5), surface) + end + if player.surface.name == "cargo_wagon" and vehicle.type == "car" then + local surface = global.locomotive_cargo.surface + local x_vector = (vehicle.position.x / math.abs(vehicle.position.x)) * 2 + local y_vector = vehicle.position.y / 16 + local position = {global.locomotive_cargo2.position.x + x_vector, global.locomotive_cargo2.position.y + y_vector} + local position = surface.find_non_colliding_position("character", position, 128, 0.5) + if not position then return end + player.teleport(position, surface) + end +end + +local function clear_offers(market) + for i = 1, 256, 1 do + local a = market.remove_market_item(1) + if a == false then return end + end +end + +function Public.refresh_offers(event) + + local market = event.entity or event.market + if not market then return end + if not market.valid then return end + if market.name ~= "market" then return end + if market ~= global.upgrademarket then return end + clear_offers(market) + setup_upgrade_shop(market) +end + +function Public.offer_purchased(event) + local offer_index = event.offer_index + if not market_offers2[offer_index] then return end + local market = event.market + if not market.name == "market" then return end + + market_offers2[offer_index]() + + count = event.count + if count > 1 then + local offers = market.get_market_items() + local price = offers[offer_index].price[1].amount + game.players[event.player_index].insert({name = "coin", count = price * (count - 1)}) + end + Public.refresh_offers(event) +end + + + +return Public diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua new file mode 100644 index 00000000..dd82507c --- /dev/null +++ b/maps/chronosphere/main.lua @@ -0,0 +1,721 @@ +-- chronosphere -- + +require "functions.soft_reset" +require "player_modifiers" +require "functions.basic_markets" + +require "modules.biters_yield_coins" +require "modules.no_deconstruction_of_neutral_entities" +--require "modules.no_solar" +require "modules.shotgun_buff" +require "modules.mineable_wreckage_yields_scrap" +require "maps.chronosphere.comfylatron" +require "maps.chronosphere.chronobubles" +require "maps.chronosphere.ores" +require "on_tick_schedule" +require "modules.biter_noms_you" +local Ai = require "maps.chronosphere.ai" +local unearthing_worm = require "functions.unearthing_worm" +local unearthing_biters = require "functions.unearthing_biters" +local tick_tack_trap = require "functions.tick_tack_trap" +local chronobuble = require "maps.chronosphere.chronobubles" +local level_depth = require "maps.chronosphere.terrain" +local Reset = require "functions.soft_reset" +local Map = require "modules.map_info" +local WD = require "modules.wave_defense.table" +local Locomotive = require "maps.chronosphere.locomotive" +local Modifier = require "player_modifiers" +local update_gui = require "maps.chronosphere.gui" +local math_random = math.random +local math_floor = math.floor +local math_sqrt = math.sqrt +local chests = {} +local Public = {} +local acus = {} +global.objective = {} + +local choppy_entity_yield = { + ["tree-01"] = {"iron-ore"}, + ["tree-02-red"] = {"copper-ore"}, + ["tree-04"] = {"coal"}, + ["tree-08-brown"] = {"stone"} + } + + +local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16, ['wood'] = 16} +-- function roll_planet() +-- for i = 1, 100, 1 do +-- local planet = chronobuble.determine_planet() +-- log("Planet number " .. i .. " stats:") +-- log("Name: " .. planet[1].name.name) +-- log("Speed of day: " .. planet[1].day_speed.name) +-- log("Time of day: " .. planet[1].time) +-- log("Ore richness: " .. planet[1].ore_richness.name .. ", multiplier: " .. planet[1].ore_richness.factor) +-- end +-- end +-- +-- function roll_planet2() +-- for i = 1, 100, 1 do +-- local planet = chronobuble.determine_planet() +-- log("#" .. i .. "#" .. planet[1].name.id .. "#" .. planet[1].day_speed.timer .. "#" .. planet[1].time .. "#" .. planet[1].ore_richness.factor) +-- end +-- end + + +function generate_overworld(surface, optplanet) + local planet = nil + if not optplanet then + planet = chronobuble.determine_planet(nil) + game.print("Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name, {r=0.98, g=0.66, b=0.22}) + global.objective.planet = planet + else + planet = optplanet + end + if planet[1].name.name == "choppy planet" then + game.print("Comfylatron: OwO what are those strange trees?!? They have ore fruits! WTF!", {r=0.98, g=0.66, b=0.22}) + end + surface.min_brightness = 0 + surface.brightness_visual_weights = {1, 1, 1} + global.objective.surface = surface + surface.daytime = planet[1].time + local timer = planet[1].day_speed.timer + if timer == 0 then + surface.freeze_daytime = true + timer = timer + 1 + else + surface.freeze_daytime = false + end + surface.ticks_per_day = timer * 250 + + local moisture = planet[1].name.moisture + if moisture ~= 0 then + local mgs = surface.map_gen_settings + mgs.property_expression_names["control-setting:moisture:bias"] = moisture + surface.map_gen_settings = mgs + end + if planet[1].name.name == "water planet" then + local mgs = surface.map_gen_settings + mgs.water = 0.6 + surface.map_gen_settings = mgs + end + if planet[1].name.name ~= "choppy planet" then + local mgs = surface.map_gen_settings + mgs.water = 0.6 + surface.map_gen_settings = mgs + end + --log(timer) + --surface.solar_power_multiplier = 999 + + surface.request_to_generate_chunks({0,0}, 3) + surface.force_generate_chunk_requests() + + -- for x = -352 + 32, 352 - 32, 32 do + -- surface.request_to_generate_chunks({x, 96}, 1) + -- --surface.force_generate_chunk_requests() + -- end + --spawn_ores(surface, planet) + --if planet[1].name.name == "mixed planet" then + -- ores_are_mixed(surface) + --end + --game.forces["player"].chart_all(surface) +end + +local function get_map_gen_settings() + local map_gen_settings = { + ["seed"] = math_random(1, 1000000), + ["width"] = level_depth, + ["height"] = level_depth, + ["water"] = 0.1, + ["starting_area"] = 1, + ["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0}, + ["default_enable_all_autoplace_controls"] = true, + ["autoplace_settings"] = { + ["entity"] = {treat_missing_as_default = false}, + ["tile"] = {treat_missing_as_default = true}, + ["decorative"] = {treat_missing_as_default = true}, + }, + } + return map_gen_settings +end + +local function render_train_hp() + local surface = game.surfaces[global.active_surface_index] + local objective = global.objective + objective.health_text = rendering.draw_text{ + text = "HP: " .. objective.health .. " / " .. objective.max_health, + surface = surface, + target = global.locomotive, + target_offset = {0, -2.5}, + color = global.locomotive.color, + scale = 1.40, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + objective.caption = rendering.draw_text{ + text = "Comfylatron's ChronoTrain", + surface = surface, + target = global.locomotive, + target_offset = {0, -4.25}, + color = global.locomotive.color, + scale = 1.80, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } +end + + +function Public.reset_map() + local wave_defense_table = WD.get_table() + global.chunk_queue = {} + if game.surfaces["chronosphere"] then game.delete_surface(game.surfaces["chronosphere"]) end + if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end + chests = {} + local map_gen_settings = get_map_gen_settings() + local planet = nil + if not global.active_surface_index then + global.active_surface_index = game.create_surface("chronosphere", map_gen_settings).index + else + planet = chronobuble.determine_planet(nil) + + global.objective.planet = planet + game.forces.player.set_spawn_position({12, 10}, game.surfaces[global.active_surface_index]) + global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], map_gen_settings, starting_items).index + game.print("Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name, {r=0.98, g=0.66, b=0.22}) + end + + local surface = game.surfaces[global.active_surface_index] + generate_overworld(surface, planet) + + local objective = global.objective + objective.max_health = 10000 + objective.health = 10000 + objective.hpupgradetier = 0 + objective.acuupgradetier = 0 + objective.filterupgradetier = 0 + objective.chronojumps = 0 + objective.chronotimer = 0 + objective.chrononeeds = 2000 + objective.active_biters = {} + objective.unit_groups = {} + objective.biter_raffle = {} + + + game.difficulty_settings.technology_price_multiplier = 0.5 + game.map_settings.enemy_evolution.destroy_factor = 0.001 + game.map_settings.enemy_evolution.pollution_factor = 0 + game.map_settings.enemy_evolution.time_factor = 4e-05 + game.map_settings.enemy_expansion.enabled = true + game.map_settings.enemy_expansion.max_expansion_cooldown = 3600 + game.map_settings.enemy_expansion.min_expansion_cooldown = 3600 + game.map_settings.enemy_expansion.settler_group_max_size = 8 + game.map_settings.enemy_expansion.settler_group_min_size = 16 + game.map_settings.pollution.enabled = true + + game.forces.player.technologies["land-mine"].enabled = false + game.forces.player.technologies["landfill"].enabled = false + game.forces.player.technologies["railway"].researched = true + game.forces.player.set_spawn_position({12, 10}, surface) + + Locomotive.locomotive_spawn(surface, {x = 16, y = 10}) + render_train_hp() + + + WD.reset_wave_defense() + wave_defense_table.surface_index = global.active_surface_index + wave_defense_table.target = global.locomotive_cargo + wave_defense_table.nest_building_density = 32 + wave_defense_table.game_lost = false + + + + + --set_difficulty() +end + +local function on_player_joined_game(event) + local player_modifiers = Modifier.get_table() + local player = game.players[event.player_index] + --log(chronobuble.determine_planet()) + + --set_difficulty() + + local surface = game.surfaces[global.active_surface_index] + + if player.online_time == 0 then + player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface) + for item, amount in pairs(starting_items) do + player.insert({name = item, count = amount}) + end + end + + if player.surface.index ~= global.active_surface_index and player.surface.name ~= "cargo_wagon" then + player.character = nil + player.set_controller({type=defines.controllers.god}) + player.create_character() + player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface) + for item, amount in pairs(starting_items) do + player.insert({name = item, count = amount}) + end + end + + player_modifiers[player.index].character_mining_speed_modifier["chronosphere"] = 0.5 + Modifier.update_player_modifiers(player) + local tile = surface.get_tile(player.position) + if tile.valid then + if tile.name == "out-of-map" then + player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface) + end + end +end + +local function repair_train() + local objective = global.objective + if not game.surfaces["cargo_wagon"] then return end + if WD.get_table().game_lost == true then return end + if objective.health < objective.max_health then + if global.repairchest.get_inventory(defines.inventory.chest).get_item_count("repair-pack") > 1 then + global.repairchest.get_inventory(defines.inventory.chest).remove({name = "repair-pack", count = 1}) + set_objective_health(-300) + end + end +end + +local function move_items() + if not global.comfychests then return end + if not global.comfychests2 then return end + if WD.get_table().game_lost == true then return end + local input = global.comfychests + local output = global.comfychests2 + for i = 1, 24, 1 do + if not input[i].valid then + log("no input chest " .. i) + return + end + if not output[i].valid then + log("no output chest " .. i) + return + end + + local input_inventory = input[i].get_inventory(defines.inventory.chest) + local output_inventory = output[i].get_inventory(defines.inventory.chest) + input_inventory.sort_and_merge() + local items = input_inventory.get_contents() + + for item, count in pairs(items) do + local inserted = output_inventory.insert({name = item, count = count}) + if inserted > 0 then + local removed = input_inventory.remove({name = item, count = inserted}) + end + end + end +end + +function chronojump(choice) + local objective = global.objective + objective.chronojumps = objective.chronojumps + 1 + objective.chrononeeds = objective.chrononeeds + 2000 + objective.chronotimer = 0 + game.print("Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. global.objective.chronojumps, {r=0.98, g=0.66, b=0.22}) + local oldsurface = game.surfaces[global.active_surface_index] + + for _,player in pairs(game.players) do + if player.surface == oldsurface then + if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end + Locomotive.enter_cargo_wagon(player, global.locomotive_cargo) + end + end + local map_gen_settings = get_map_gen_settings() + + global.active_surface_index = game.create_surface("chronosphere" .. objective.chronojumps, map_gen_settings).index + local surface = game.surfaces[global.active_surface_index] + local planet = nil + if choice then + planet = chronobuble.determine_planet(choice) + game.print("Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name, {r=0.98, g=0.66, b=0.22}) + global.objective.planet = planet + end + generate_overworld(surface, planet) + game.forces.player.set_spawn_position({12, 10}, surface) + Locomotive.locomotive_spawn(surface, {x = 16, y = 10}) + render_train_hp() + game.delete_surface(oldsurface) + if objective.chronojumps <= 40 then + game.forces["enemy"].evolution_factor = 0 + 0.025 * objective.chronojumps + else + game.forces["enemy"].evolution_factor = 1 + end + game.map_settings.enemy_evolution.time_factor = 4e-05 + 1e-06 * objective.chronojumps + + + +end + +local function check_chronoprogress() + local objective = global.objective + --game.print(objective.chronotimer) + if objective.chronotimer >= objective.chrononeeds - 60 and objective.chronotimer < objective.chrononeeds - 59 then + game.print("Comfylatron: ChronoTrain nearly charged! Grab what you can, we leaving in 60 seconds!", {r=0.98, g=0.66, b=0.22}) + elseif objective.chronotimer == objective.chrononeeds - 30 then + game.print("Comfylatron: You better hurry up! 30 seconds remaining!", {r=0.98, g=0.66, b=0.22}) + elseif objective.chronotimer >= objective.chrononeeds - 10 and objective.chrononeeds - objective.chronotimer > 0 then + game.print("Comfylatron: Jump in " .. objective.chrononeeds - objective.chronotimer .. " seconds!", {r=0.98, g=0.66, b=0.22}) + end + if objective.chronotimer >= objective.chrononeeds then + chronojump(nil) + + end +end + +local function charge_chronosphere() + if not global.acumulators then return end + local objective = global.objective + if not objective.chronotimer then return end + if objective.chronotimer < 20 then return end + local acus = global.acumulators + if #acus < 1 then return end + for i = 1, #acus, 1 do + if not acus[i].valid then return end + local energy = acus[i].energy + if energy > 3000000 and objective.chronotimer < objective.chrononeeds - 62 then + acus[i].energy = acus[i].energy - 3000000 + objective.chronotimer = objective.chronotimer + 1 + game.surfaces[global.active_surface_index].pollute(global.locomotive.position, 100 * (4 / (objective.filterupgradetier / 2 + 1))) + --log("energy charged from acu") + end + end +end + +local function transfer_pollution() + local surface = game.surfaces["cargo_wagon"] + if not surface then return end + local pollution = surface.get_total_pollution() * (4 / (global.objective.filterupgradetier / 2 + 1)) + game.surfaces[global.active_surface_index].pollute(global.locomotive.position, pollution) + surface.clear_pollution() +end + +local tick_minute_functions = { + + [300 * 2] = Ai.destroy_inactive_biters, + [300 * 3 + 30 * 0] = Ai.pre_main_attack, -- setup for main_attack + [300 * 3 + 30 * 1] = Ai.perform_main_attack, + [300 * 3 + 30 * 2] = Ai.perform_main_attack, + [300 * 3 + 30 * 3] = Ai.perform_main_attack, -- call perform_main_attack 7 times on different ticks + [300 * 4] = Ai.send_near_biters_to_objective, + [300 * 5] = Ai.wake_up_sleepy_groups + +} + +local function tick() + local tick = game.tick + if tick % 60 == 30 and global.objective.chronotimer < 64 then + local surface = game.surfaces[global.active_surface_index] + surface.request_to_generate_chunks({0,0}, 3 + math_floor(global.objective.chronotimer / 5)) + --surface.force_generate_chunk_requests() + + + end + if tick % 30 == 0 then + if tick % 600 == 0 then + charge_chronosphere() + transfer_pollution() + end + if tick % 1800 == 0 then + Locomotive.set_player_spawn_and_refill_fish() + repair_train() + --local surface = game.surfaces[global.active_surface_index] + --local last_position = global.map_collapse.last_position + --local position = surface.find_non_colliding_position("stone-furnace", {last_position.x, last_position.y - 32}, 128, 4) + --if position then + -- local wave_defense_table = WD.get_table() + -- wave_defense_table.spawn_position = position + --end + --if tick % 216000 == 0 then + -- Collapse.delete_out_of_map_chunks(surface) + --end + end + local key = tick % 3600 + if tick_minute_functions[key] then tick_minute_functions[key]() end + if tick % 60 == 0 then + global.objective.chronotimer = global.objective.chronotimer + 1 + check_chronoprogress() + end + if tick % 120 == 0 then + move_items() + end + if global.game_reset_tick then + if global.game_reset_tick < tick then + global.game_reset_tick = nil + require "maps.chronosphere.main".reset_map() + end + return + end + Locomotive.fish_tag() + end + for _, player in pairs(game.connected_players) do update_gui(player) end + --if not collapse_enabled then return end + --Collapse.process() +end + +local function on_init() + local T = Map.Pop_info() + T.localised_category = "chronosphere" + T.main_caption_color = {r = 150, g = 150, b = 0} + T.sub_caption_color = {r = 0, g = 150, b = 0} + + + --global.rocks_yield_ore_maximum_amount = 999 + --global.rocks_yield_ore_base_amount = 50 + --global.rocks_yield_ore_distance_modifier = 0.025 + --if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end + Public.reset_map() +end + +function set_objective_health(final_damage_amount) + local objective = global.objective + objective.health = math_floor(objective.health - final_damage_amount) + if objective.health > objective.max_health then objective.health = objective.max_health end + + if objective.health <= 0 then + local wave_defense_table = WD.get_table() + if wave_defense_table.game_lost == true then return end + objective.health = 0 + local surface = objective.surface + game.print("The chronotrain was destroyed!") + game.print("Comfylatron is going to kill you for that...he has time machine after all!") + surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo.position}) + global.locomotive_cargo.destroy() + surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo2.position}) + global.locomotive_cargo2.destroy() + surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo3.position}) + global.locomotive_cargo3.destroy() + for i = 1, #global.comfychests,1 do + --surface.create_entity({name = "big-artillery-explosion", position = global.comfychests[i].position}) + global.comfychests[i].destroy() + + if global.comfychests2 then global.comfychests2[i].destroy() end + + --global.comfychests = {} + end + global.ores_queue = {} + global.entities_queue = {} + global.acumulators = {} + wave_defense_table.game_lost = true + wave_defense_table.target = nil + global.game_reset_tick = game.tick + 1800 + for _, player in pairs(game.connected_players) do + player.play_sound{path="utility/game_lost", volume_modifier=0.75} + end + end + rendering.set_text(objective.health_text, "HP: " .. objective.health .. " / " .. objective.max_health) +end + +local function isprotected(entity) + local protected = {global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} + if entity.surface.name == "cargo_wagon" then return true end + for i = 1, #global.comfychests,1 do + table.insert(protected, global.comfychests[i]) + end + for index = 1, #protected do + if protected[index] == entity then + return true + end + end +end + +local function protect_entity(event) + if event.entity.force.index ~= 1 then return end --Player Force + if isprotected(event.entity) then + if event.cause then + if event.cause.force.index == 2 then + set_objective_health(event.final_damage_amount) + end + end + if not event.entity.valid then return end + event.entity.health = event.entity.health + event.final_damage_amount + end +end + +local function biters_chew_rocks_faster(event) + if event.entity.force.index ~= 3 then return end --Neutral Force + if not event.cause then return end + if not event.cause.valid then return end + if event.cause.force.index ~= 2 then return end --Enemy Force + event.entity.health = event.entity.health - event.final_damage_amount * 5 +end + +local function on_entity_damaged(event) + if not event.entity.valid then return end + protect_entity(event) + if not event.entity.valid then return end + if not event.entity.health then return end + biters_chew_rocks_faster(event) + +end + +local function trap(entity) + if math_random(1,256) == 1 then tick_tack_trap(entity.surface, entity.position) return end + if math_random(1,128) == 1 then unearthing_worm(entity.surface, entity.surface.find_non_colliding_position("big-worm-turret",entity.position,5,1)) end + if math_random(1,64) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end +end + +local function get_choppy_amount(entity) + local distance_to_center = math_sqrt(entity.position.x^2 + entity.position.y^2) + 50 * global.objective.chronojumps + local amount = (25 + distance_to_center * 0.1) * (1 + game.forces.player.mining_drill_productivity_bonus) + if amount > 1000 then amount = 1000 end + amount = math_random(math_floor(amount * 0.5), math_floor(amount * 1.5)) + return amount +end + +local function pre_player_mined_item(event) + local surface = game.surfaces[global.active_surface_index] + local player = game.players[event.player_index] + local objective = global.objective + if objective.planet[1].name.name == "rocky planet" then + if event.entity.name == "rock-huge" or event.entity.name == "rock-big" or event.entity.name == "sand-rock-big" then + trap(event.entity) + local rock_position = {x = event.entity.position.x, y = event.entity.position.y} + event.entity.destroy() + local tile_distance_to_center = math_sqrt(rock_position.x^2 + rock_position.y^2) + 50 * objective.chronojumps + if tile_distance_to_center > 1450 then tile_distance_to_center = 1450 end + surface.spill_item_stack(player.position,{name = "raw-fish", count = math_random(1,3)},true) + local bonus_amount = math_floor((tile_distance_to_center) + 1) + if bonus_amount < 0 then bonus_amount = 0 end + local amount = math_random(25,45) + bonus_amount + if amount > 500 then amount = 500 end + amount = math_floor(amount * (1+game.forces.player.mining_drill_productivity_bonus)) + local rock_mining = {"iron-ore", "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "copper-ore", "stone", "stone", "coal", "coal"} + local mined_loot = rock_mining[math_random(1,#rock_mining)] + surface.create_entity({ + name = "flying-text", + position = rock_position, + text = "+" .. amount .. " [img=item/" .. mined_loot .. "]", + color = {r=0.98, g=0.66, b=0.22} + }) + local i = player.insert {name = mined_loot, count = amount} + amount = amount - i + if amount > 0 then + surface.spill_item_stack(rock_position,{name = mined_loot, count = amount},true) + end + end + end +end + +local function on_player_mined_entity(event) + local entity = event.entity + if not entity.valid then return end + if entity.type == "tree" and global.objective.planet[1].name.name == "choppy planet" then + trap(entity) + if choppy_entity_yield[entity.name] then + if event.buffer then event.buffer.clear() end + if not event.player_index then return end + local amount = get_choppy_amount(entity) + local second_item_amount = math_random(2,5) + local second_item = "wood" + local main_item = choppy_entity_yield[entity.name][math_random(1,#choppy_entity_yield[entity.name])] + + entity.surface.create_entity({ + name = "flying-text", + position = entity.position, + text = "+" .. amount .. " [item=" .. main_item .. "] +" .. second_item_amount .. " [item=" .. second_item .. "]", + color = {r=0.8,g=0.8,b=0.8} + }) + + local player = game.players[event.player_index] + + local inserted_count = player.insert({name = main_item, count = amount}) + amount = amount - inserted_count + if amount > 0 then + entity.surface.spill_item_stack(entity.position,{name = main_item, count = amount}, true) + end + + local inserted_count = player.insert({name = second_item, count = second_item_amount}) + second_item_amount = second_item_amount - inserted_count + if second_item_amount > 0 then + entity.surface.spill_item_stack(entity.position,{name = second_item, count = second_item_amount}, true) + end + end + end + if entity.name == "rock-huge" or entity.name == "rock-big" or entity.name == "sand-rock-big" then + if global.objective.planet[1].name.name ~= "rocky planet" then + prospect_ores(entity) + elseif + global.objective.planet[1].name.name == "rocky planet" then event.buffer.clear() + end + end +end + +local function shred_simple_entities(entity) + --game.print(entity.name) + if game.forces["enemy"].evolution_factor < 0.25 then return end + local simple_entities = entity.surface.find_entities_filtered({type = {"simple-entity", "tree"}, area = {{entity.position.x - 3, entity.position.y - 3},{entity.position.x + 3, entity.position.y + 3}}}) + if #simple_entities == 0 then return end + for i = 1, #simple_entities, 1 do + if not simple_entities[i] then break end + if simple_entities[i].valid then + simple_entities[i].die("enemy", simple_entities[i]) + end + end +end + +local function on_entity_died(event) + + if event.entity.type == "tree" and global.objective.planet[1].name.name == "choppy planet" then + if event.cause then + if event.cause.valid then + if event.cause.force.index ~= 2 then + trap(event.entity) + end + end + end + -- if not event.entity.valid then return end + -- for _, entity in pairs (event.entity.surface.find_entities_filtered({area = {{event.entity.position.x - 4, event.entity.position.y - 4},{event.entity.position.x + 4, event.entity.position.y + 4}}, name = "fire-flame-on-tree"})) do + -- if entity.valid then entity.destroy() end + -- end + --return + end + local entity = event.entity + if not entity.valid then return end + if entity.type == "unit" and entity.force == "enemy" then + global.objective.active_biters[entity.unit_number] = nil + end + if entity.force.index == 3 then + if event.cause then + if event.cause.valid then + if event.cause.force.index == 2 then + shred_simple_entities(entity) + end + end + end + end + + --on_player_mined_entity(event) + --if not event.entity.valid then return end +end + +local function on_player_driving_changed_state(event) + local player = game.players[event.player_index] + local vehicle = event.entity + Locomotive.enter_cargo_wagon(player, vehicle) +end + +local function on_market_item_purchased(event) + Locomotive.offer_purchased(event) +end + +local event = require 'utils.event' +event.on_init(on_init) +event.on_nth_tick(2, tick) +event.add(defines.events.on_entity_damaged, on_entity_damaged) +event.add(defines.events.on_entity_died, on_entity_died) +event.add(defines.events.on_player_joined_game, on_player_joined_game) +--event.add(defines.events.on_player_left_game, on_player_left_game) +event.add(defines.events.on_pre_player_mined_item, pre_player_mined_item) +event.add(defines.events.on_player_mined_entity, on_player_mined_entity) +--event.add(defines.events.on_research_finished, on_research_finished) +event.add(defines.events.on_market_item_purchased, on_market_item_purchased) +event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state) + + +return Public diff --git a/maps/chronosphere/ores.lua b/maps/chronosphere/ores.lua new file mode 100644 index 00000000..0ec58959 --- /dev/null +++ b/maps/chronosphere/ores.lua @@ -0,0 +1,197 @@ +local simplex_noise = require 'utils.simplex_noise'.d2 +local math_random = math.random +local math_abs = math.abs +local math_floor = math.floor +local math_sqrt = math.sqrt +local ores = {"copper-ore", "iron-ore", "stone", "coal"} + +local function pos_to_key(position) + return tostring(position.x .. "_" .. position.y) +end + +local function draw_noise_ore_patch(position, name, surface, radius, richness, mixed) + if not position then return end + if not name then return end + if not surface then return end + if not radius then return end + if not richness then return end + local ore_raffle = { + "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "coal", "stone" + } + local seed = surface.map_gen_settings.seed + local noise_seed_add = 25000 + local richness_part = richness / radius + for y = radius * -3, radius * 3, 1 do + for x = radius * -3, radius * 3, 1 do + local pos = {x = x + position.x + 0.5, y = y + position.y + 0.5} + local noise_1 = simplex_noise(pos.x * 0.0125, pos.y * 0.0125, seed) + local noise_2 = simplex_noise(pos.x * 0.1, pos.y * 0.1, seed + 25000) + local noise = noise_1 + noise_2 * 0.12 + local distance_to_center = math.sqrt(x^2 + y^2) + local a = richness - richness_part * distance_to_center + if distance_to_center < radius - math.abs(noise * radius * 0.85) and a > 1 then + pos = surface.find_non_colliding_position(name, pos, 64, 1) + if not pos then return end + if mixed then + local noise = simplex_noise(pos.x * 0.005, pos.y * 0.005, seed) + simplex_noise(pos.x * 0.01, pos.y * 0.01, seed) * 0.3 + simplex_noise(pos.x * 0.05, pos.y * 0.05, seed) * 0.2 + local i = (math_floor(noise * 100) % 7) + 1 + name = ore_raffle[i] + end + local entity = {name = name, position = pos, amount = a} + if surface.can_place_entity(entity) then + surface.create_entity(entity) + end + --if not global.ores_queue[pos.x] then global.ores_queue[pos.x] = {} end + + --global.ores_queue[pos_to_key(pos)] = {name = name, position = pos, amount = a} + --end + end + end + end +end + +-- function ores_are_mixed(surface) +-- local ore_raffle = { +-- "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "coal", "stone" +-- } +-- local r = 480 +-- local area = {{r * -1, r * -1}, {r, r}} +-- local ores = surface.find_entities_filtered({area = area, name = {"iron-ore", "copper-ore", "coal", "stone"}}) +-- if #ores == 0 then return end +-- local seed = surface.map_gen_settings.seed +-- +-- for _, ore in pairs(ores) do +-- local pos = ore.position +-- local noise = simplex_noise(pos.x * 0.005, pos.y * 0.005, seed) + simplex_noise(pos.x * 0.01, pos.y * 0.01, seed) * 0.3 + simplex_noise(pos.x * 0.05, pos.y * 0.05, seed) * 0.2 +-- +-- local i = (math.floor(noise * 100) % 7) + 1 +-- --if not global.ores_queue[pos.x] then global.ores_queue[pos.x] = {} end +-- --global.ores_queue[pos_to_key(pos)] = {name = ore_raffle[i], position = ore.position, amount = ore.amount} +-- ore.destroy() +-- end +-- end + +local function get_size_of_ore(ore, planet) + local base_size = math_random(5, 10) + math_floor(planet[1].ore_richness.factor * 3) + local final_size = 1 + if planet[1].name.name == "iron planet" and ore == "iron-ore" then + final_size = base_size * 2 + elseif planet[1].name.name == "copper planet" and ore == "copper-ore" then + final_size = base_size * 2 + elseif planet[1].name.name == "stone planet" and ore == "stone" then + final_size = base_size * 2 + elseif planet[1].name.name == "coal planet" and ore == "coal" then + final_size = base_size * 2 + elseif planet[1].name.name == "uranium planet" and ore == "uranium-ore" then + final_size = base_size * 2 + elseif planet[1].name.name == "mixed planet" then + final_size = base_size + else + final_size = math_floor(base_size / 2) + end + return final_size +end + +local function get_oil_amount(pos, oil_w) + local hundred_percent = 300000 + return (hundred_percent / 50) * (1+global.objective.chronojumps) * oil_w +end + +-- function spawn_ores(surface, planet) +-- +-- --local r = 480 +-- --local area = {{r * -1, r * -1}, {r, r}} +-- local ores = {} +-- if planet[1].name.name == "rocky planet" then return end +-- local oil_amount = planet[1].name.oil +-- if oil_amount > 0 then +-- for a = 1, oil_amount, 1 do +-- local poso = {x = math_random(-50,50) + math_random(250, 350) * math_random(-1,1), y = math_random(-50,50) + math_random(250, 350) * math_random(-1,1)} +-- for a=1, math_random(2, 3 + oil_amount * 2), 1 do +-- local posoo = {x = poso.x + math_random(-10,10), y = poso.y + math_random(-10,10)} +-- --if surface.can_place_entity{name = "crude-oil", position = posoo} then +-- --if not global.ores_queue[posoo.x] then global.ores_queue[posoo.x] = {} end +-- global.entities_queue[pos_to_key(posoo)] = {name = "crude-oil", position = posoo, amount = get_oil_amount(posoo) * oil_amount } +-- --end +-- end +-- end +-- end +-- if planet[1].name.name == "choppy planet" then return end +-- local uranium_amount = planet[1].name.uranium +-- if uranium_amount > 0 then +-- for a = 1, uranium_amount, 1 do +-- local posu = {x = 0 + math_random(350, 450) * math_random(-1,1), y = 0 + math_random(350, 450) * math_random(-1,1)} +-- if posu.x ~= 0 or posu.y ~= 0 then +-- --if surface.can_place_entity({name = "uranium-ore", position = posu, amount = 1}) then +-- draw_noise_ore_patch(posu, "uranium-ore", surface, get_size_of_ore("uranium-ore", planet), math_random(200, 300) * planet[1].ore_richness.factor) +-- --break +-- --end +-- end +-- end +-- end +-- ores["iron-ore"] = surface.count_entities_filtered({name = "iron-ore", area = area}) +-- ores["copper-ore"] = surface.count_entities_filtered({name = "copper-ore", area = area}) +-- ores["coal"] = surface.count_entities_filtered({name = "coal", area = area}) +-- ores["stone"] = surface.count_entities_filtered({name = "stone", area = area}) +-- for ore, ore_count in pairs(ores) do +-- if ore_count < 1000 or ore_count == nil then +-- local pos = {} +-- for a = 1, 8, 1 do +-- pos = {x = -300 + math_random(0, 600), y = -300 + math_random(0, 600)} +-- --if surface.can_place_entity({name = ore, position = pos, amount = 1}) then +-- draw_noise_ore_patch(pos, ore, surface, get_size_of_ore(ore, planet), math_random(400, 500) * planet[1].ore_richness.factor) +-- --break +-- --end +-- end +-- --draw_noise_ore_patch(pos, ore, surface, get_size_of_ore(ore, planet), math_random(400, 500) * planet[1].ore_richness.factor) +-- end +-- end +-- end + +function spawn_ore_vein(surface, pos, planet) + local mixed = false + if planet[1].name.name == "mixed planet" then mixed = true end + local richness = math_random(50 + 10 * global.objective.chronojumps, 100 + 10 * global.objective.chronojumps) * planet[1].ore_richness.factor + local iron = {w = planet[1].name.iron, t = planet[1].name.iron} + local copper = {w = planet[1].name.copper, t = iron.t + planet[1].name.copper} + local stone = {w = planet[1].name.stone, t = copper.t + planet[1].name.stone} + local coal = {w = planet[1].name.coal, t = stone.t + planet[1].name.coal} + local uranium = {w = planet[1].name.uranium, t = coal.t + planet[1].name.uranium} + local oil = {w = planet[1].name.oil, t = uranium.t + planet[1].name.oil} + + local total = iron.w + copper.w + stone.w + coal.w + uranium.w + oil.w + local roll = math_random (0, oil.t) + if roll == 0 then return end + local choice = nil + if roll <= iron.t then + choice = "iron-ore" + elseif roll <= copper.t then + choice = "copper-ore" + elseif roll <= stone.t then + choice = "stone" + elseif roll <= coal.t then + choice = "coal" + elseif roll <= uranium.t then + choice = "uranium-ore" + elseif roll <= oil.t then + choice = "crude-oil" + end + + --if surface.can_place_entity({name = choice, position = pos, amount = 1}) then + if choice == "crude-oil" then + surface.create_entity({name = "crude-oil", position = pos, amount = get_oil_amount(pos, oil.w) }) + else + draw_noise_ore_patch(pos, choice, surface, get_size_of_ore(choice, planet), richness, mixed) + end + --end +end + +function prospect_ores(entity) + local planet = global.objective.planet + local chance = 10 + if entity.name == "rock-huge" then chance = 40 end + if math_random(chance + math_floor(10 * planet[1].ore_richness.factor) ,100 + chance) >= 100 then + spawn_ore_vein(entity.surface, entity.position, planet) + --if planet[1].name.name == "mixed planet" then + end +end diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua new file mode 100644 index 00000000..09fe4496 --- /dev/null +++ b/maps/chronosphere/terrain.lua @@ -0,0 +1,574 @@ + +--require "maps.chronosphere.ores" + +local math_random = math.random +local math_floor = math.floor +local math_abs = math.abs +local math_sqrt = math.sqrt +local level_depth = 960 +local Treasure = require 'maps.chronosphere.treasure' +local simplex_noise = require "utils.simplex_noise".d2 +local rock_raffle = {"sand-rock-big","sand-rock-big", "rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-huge"} +local size_of_rock_raffle = #rock_raffle +local dead_tree_raffle = {"dead-dry-hairy-tree", "dead-grey-trunk", "dead-tree-desert", "dry-hairy-tree", "dry-tree"} +local tree_raffle = {"tree-01", "tree-02", "tree-02-red", "tree-03", "tree-04", "tree-05", "tree-06", "tree-06-brown", "tree-07", + "tree-08", "tree-08-brown", "tree-08-red", "tree-09", "tree-09-brown", "tree-09-red"} +local s_tree_raffle = #tree_raffle +local spawner_raffle = {"biter-spawner", "biter-spawner", "biter-spawner", "spitter-spawner"} +local worm_raffle = { + "small-worm-turret", "small-worm-turret", "medium-worm-turret", "small-worm-turret", + "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "medium-worm-turret", + "big-worm-turret","big-worm-turret","behemoth-worm-turret", "big-worm-turret", + "behemoth-worm-turret","behemoth-worm-turret","behemoth-worm-turret","big-worm-turret","behemoth-worm-turret" +} +local scrap_entities = {"crash-site-assembling-machine-1-broken", "crash-site-assembling-machine-2-broken", "crash-site-assembling-machine-1-broken", "crash-site-assembling-machine-2-broken", "crash-site-lab-broken", + "medium-ship-wreck", "small-ship-wreck", "medium-ship-wreck", "small-ship-wreck", "medium-ship-wreck", "small-ship-wreck", "medium-ship-wreck", "small-ship-wreck", + "crash-site-chest-1", "crash-site-chest-2", "crash-site-chest-1", "crash-site-chest-2", "crash-site-chest-1", "crash-site-chest-2"} +local scrap_entities_index = #scrap_entities +local noises = { + ["no_rocks"] = {{modifier = 0.0033, weight = 1}, {modifier = 0.01, weight = 0.22}, {modifier = 0.05, weight = 0.05}, {modifier = 0.1, weight = 0.04}}, + ["no_rocks_2"] = {{modifier = 0.013, weight = 1}, {modifier = 0.1, weight = 0.1}}, + ["large_caves"] = {{modifier = 0.0033, weight = 1}, {modifier = 0.01, weight = 0.22}, {modifier = 0.05, weight = 0.05}, {modifier = 0.1, weight = 0.04}}, + ["small_caves"] = {{modifier = 0.008, weight = 1}, {modifier = 0.03, weight = 0.15}, {modifier = 0.25, weight = 0.05}}, + ["small_caves_2"] = {{modifier = 0.009, weight = 1}, {modifier = 0.05, weight = 0.25}, {modifier = 0.25, weight = 0.05}}, + ["cave_ponds"] = {{modifier = 0.01, weight = 1}, {modifier = 0.1, weight = 0.06}}, + ["cave_rivers"] = {{modifier = 0.005, weight = 1}, {modifier = 0.01, weight = 0.25}, {modifier = 0.05, weight = 0.01}}, + ["cave_rivers_2"] = {{modifier = 0.003, weight = 1}, {modifier = 0.01, weight = 0.21}, {modifier = 0.05, weight = 0.01}}, + ["cave_rivers_3"] = {{modifier = 0.002, weight = 1}, {modifier = 0.01, weight = 0.15}, {modifier = 0.05, weight = 0.01}}, + ["cave_rivers_4"] = {{modifier = 0.001, weight = 1}, {modifier = 0.01, weight = 0.11}, {modifier = 0.05, weight = 0.01}}, + ["scrapyard"] = {{modifier = 0.005, weight = 1}, {modifier = 0.01, weight = 0.35}, {modifier = 0.05, weight = 0.23}, {modifier = 0.1, weight = 0.11}}, + ["forest_location"] = {{modifier = 0.006, weight = 1}, {modifier = 0.01, weight = 0.25}, {modifier = 0.05, weight = 0.15}, {modifier = 0.1, weight = 0.05}}, + ["forest_density"] = {{modifier = 0.01, weight = 1}, {modifier = 0.05, weight = 0.5}, {modifier = 0.1, weight = 0.025}}, + ["ores"] = {{modifier = 0.05, weight = 1}, {modifier = 0.02, weight = 0.55}, {modifier = 0.05, weight = 0.05}} +} + +local function pos_to_key(position) + return tostring(position.x .. "_" .. position.y) +end + +local function get_noise(name, pos, seed) + local noise = 0 + local d = 0 + for _, n in pairs(noises[name]) do + noise = noise + simplex_noise(pos.x * n.modifier, pos.y * n.modifier, seed) * n.weight + d = d + n.weight + seed = seed + 10000 + end + noise = noise / d + return noise +end + +local function get_size_of_ore(ore, planet) + local base_size = 0.04 + 0.04 * planet[1].ore_richness.factor + local final_size = 1 + if planet[1].name.name == "iron planet" and ore == "iron-ore" then + final_size = base_size * 5 + elseif planet[1].name.name == "copper planet" and ore == "copper-ore" then + final_size = base_size * 5 + elseif planet[1].name.name == "stone planet" and ore == "stone" then + final_size = base_size * 5 + elseif planet[1].name.name == "coal planet" and ore == "coal" then + final_size = base_size * 5 + elseif planet[1].name.name == "uranium planet" and ore == "uranium-ore" then + final_size = base_size * 5 + elseif planet[1].name.name == "mixed planet" then + final_size = base_size * 2 + else + final_size = base_size / 2 + end + return final_size +end + +local function process_rocky_position(p, seed, tiles, entities, treasure, planet) + local biters = planet[1].name.biters + local noise_large_caves = get_noise("large_caves", p, seed) + local noise_cave_ponds = get_noise("cave_ponds", p, seed) + local small_caves = get_noise("small_caves", p, seed) + + if math_abs(noise_large_caves) > 0.7 then + tiles[#tiles + 1] = {name = "water", position = p} + if math_random(1,16) == 1 then entities[#entities + 1] = {name="fish", position=p} end + return + end + if math_abs(noise_large_caves) > 0.6 then + if math_random(1,16) == 1 then entities[#entities + 1] = {name="tree-02", position=p} end + --if math_random(1,32) == 1 then markets[#markets + 1] = p end + end + if math_abs(noise_large_caves) > 0.5 then + tiles[#tiles + 1] = {name = "grass-2", position = p} + --if math_random(1,620) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end + -- if math_random(1,384) == 1 then + -- Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) + -- entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} + -- end + if math_random(1,102 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + if math_random(1, 1024) == 1 then treasure[#treasure + 1] = p end + return + end + if math_abs(noise_large_caves) > 0.375 then + tiles[#tiles + 1] = {name = "dirt-7", position = p} + if math_random(1,6) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end + return + end + + --Chasms + if noise_cave_ponds < 0.25 and noise_cave_ponds > -0.25 then + if small_caves > 0.75 then + tiles[#tiles + 1] = {name = "out-of-map", position = p} + return + end + if small_caves < -0.75 then + tiles[#tiles + 1] = {name = "out-of-map", position = p} + return + end + end + + if small_caves > -0.25 and small_caves < 0.25 then + tiles[#tiles + 1] = {name = "dirt-7", position = p} + local roll = math_random(1,1000) + if roll > 800 then + entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} + elseif roll > 790 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then + entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p} + else + + end + if math_random(1, 1024) == 1 then treasure[#treasure + 1] = p end + return + end + + if noise_large_caves > -0.28 and noise_large_caves < 0.28 then + + --Main Rock Terrain + local no_rocks_2 = get_noise("no_rocks_2", p, seed + 75000) + if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then + tiles[#tiles + 1] = {name = "dirt-" .. math_floor(no_rocks_2 * 8) % 2 + 5, position = p} + if math_random(1,512) == 1 then treasure[#treasure + 1] = p end + return + end + + if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end + tiles[#tiles + 1] = {name = "dirt-7", position = p} + if math_random(1,100) > 40 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + return + end + + tiles[#tiles + 1] = {name = "out-of-map", position = p} +end + +local function process_forest_position(p, seed, tiles, entities, treasure, planet) + local biters = planet[1].name.biters + local noise_forest_location = get_noise("forest_location", p, seed) + --local r = math.ceil(math.abs(get_noise("forest_density", pos, seed + 4096)) * 10) + --local r = 5 - math.ceil(math.abs(noise_forest_location) * 3) + --r = 2 + + if noise_forest_location > 0.095 then + if noise_forest_location > 0.6 then + if math_random(1,100) > 42 then entities[#entities + 1] = {name = "tree-08-brown", position = p} end + else + if math_random(1,100) > 42 then entities[#entities + 1] = {name = "tree-01", position = p} end + end + --surface.create_decoratives({check_collision=false, decoratives={{name = decos_inside_forest[math_random(1, #decos_inside_forest)], position = pos, amount = math_random(1, 2)}}}) + return + else + if math_random(1,152 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 250 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + end + + if noise_forest_location < -0.095 then + if noise_forest_location < -0.6 then + if math_random(1,100) > 42 then entities[#entities + 1] = {name = "tree-04", position = p} end + else + if math_random(1,100) > 42 then entities[#entities + 1] = {name = "tree-02-red", position = p} end + end + --surface.create_decoratives({check_collision=false, decoratives={{name = decos_inside_forest[math_random(1, #decos_inside_forest)], position = pos, amount = math_random(1, 2)}}}) + return + else + if math_random(1,152 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 250 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + end + + + --surface.create_decoratives({check_collision=false, decoratives={{name = decos[math_random(1, #decos)], position = pos, amount = math_random(1, 2)}}}) +end + +local function process_river_position(p, seed, tiles, entities, treasure, planet) + local biters = planet[1].name.biters + local richness = math_random(50 + 10 * global.objective.chronojumps, 100 + 10 * global.objective.chronojumps) * planet[1].ore_richness.factor^2 + local iron_size = get_size_of_ore("iron-ore", planet) + local copper_size = get_size_of_ore("copper-ore", planet) + local stone_size = get_size_of_ore("stone", planet) + local coal_size = get_size_of_ore("coal", planet) + if not biters then biters = 4 end + local large_caves = get_noise("large_caves", p, seed) + local cave_rivers = get_noise("cave_rivers", p, seed) + local ores = get_noise("ores", p, seed) + local noise_forest_location = get_noise("forest_location", p, seed) + + --Chasms + local noise_cave_ponds = get_noise("cave_ponds", p, seed) + local small_caves = get_noise("small_caves", p, seed) + if noise_cave_ponds < 0.45 and noise_cave_ponds > -0.45 then + if small_caves > 0.75 then + tiles[#tiles + 1] = {name = "out-of-map", position = p} + return + end + if small_caves < -0.75 then + tiles[#tiles + 1] = {name = "out-of-map", position = p} + return + end + end + + if large_caves > -0.05 and large_caves < 0.05 and cave_rivers < 0.25 then + tiles[#tiles + 1] = {name = "water-green", position = p} + if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end + return + elseif large_caves > -0.15 and large_caves < 0.15 and cave_rivers <0.35 then + if ores > -coal_size and ores < coal_size then + entities[#entities + 1] = {name = "coal", position = p, amount = richness} + end + end + + if cave_rivers > -0.70 and cave_rivers < 0.70 then + if math_random(1,48) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end + if cave_rivers > -0.05 and cave_rivers < 0.05 then + if ores > -iron_size and ores < iron_size then + entities[#entities + 1] = {name = "iron-ore", position = p, amount = richness} + end + elseif cave_rivers > -0.10 and cave_rivers < 0.10 then + if ores > -copper_size and ores < copper_size then + entities[#entities + 1] = {name = "copper-ore", position = p, amount = richness} + end + end + else + tiles[#tiles + 1] = {name = "dirt-7", position = p} + if ores > -stone_size and ores < stone_size then + entities[#entities + 1] = {name = "stone", position = p, amount = richness} + end + if math_random(1,52 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 200 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end + end + if noise_forest_location > 0.9 then + local tree = tree_raffle[math_random(1, s_tree_raffle)] + if math_random(1,100) > 42 then entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} end + return + end + + if noise_forest_location < -0.9 then + if math_random(1,100) > 42 then entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} end + return + end +end + +local function process_biter_position(p, seed, tiles, entities, treasure, planet) + local scrapyard = get_noise("scrapyard", p, seed) + local noise_forest_location = get_noise("forest_location", p, seed) + local large_caves = get_noise("large_caves", p, seed) + local biters = planet[1].name.biters + local ore_size = planet[1].ore_richness.factor + if scrapyard < -0.75 or scrapyard > 0.75 then + if math_random(1,52 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 200 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + + end + if scrapyard > -0.05 - 0.01 * ore_size and scrapyard < 0.05 + 0.01 * ore_size then + if math_random(1,20) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + end + if scrapyard + 0.5 > -0.05 - 0.1 * planet[1].name.moisture and scrapyard + 0.5 < 0.05 + 0.1 * planet[1].name.moisture then + if math_random(1,100) > 42 then entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} end + end + + if scrapyard > -0.10 and scrapyard < 0.10 then + if math_floor(large_caves * 10) % 4 < 3 then + local jumps = global.objective.chronojumps * 5 + if global.objective.chronojumps > 20 then jumps = 100 end + local roll = math_random(1,200 - jumps - biters) + if math_sqrt(p.x * p.x + p.y * p.y) > 300 then + if roll == 1 then + entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} + elseif roll == 2 then + entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p} + end + return + end + end + end +end + +local function process_scrapyard_position(p, seed, tiles, entities, treasure, planet) + local scrapyard = get_noise("scrapyard", p, seed) + local biters = planet[1].name.biters + --Chasms + local noise_cave_ponds = get_noise("cave_ponds", p, seed) + local small_caves = get_noise("small_caves", p, seed) + local noise_forest_location = get_noise("forest_location", p, seed) + if noise_cave_ponds < 0.15 and noise_cave_ponds > -0.15 then + if small_caves > 0.35 then + tiles[#tiles + 1] = {name = "out-of-map", position = p} + return + end + if small_caves < -0.35 then + tiles[#tiles + 1] = {name = "out-of-map", position = p} + return + end + end + + if scrapyard < -0.25 or scrapyard > 0.25 then + if math_random(1, 256) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 50 then + entities[#entities + 1] = {name="gun-turret", position=p, force = "enemy"} + end + tiles[#tiles + 1] = {name = "dirt-7", position = p} + if scrapyard < -0.55 or scrapyard > 0.55 then + if math_random(1,40) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 100 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + return + end + if scrapyard + 0.5 > -0.05 - 0.1 * planet[1].name.moisture and scrapyard + 0.5 < 0.05 + 0.1 * planet[1].name.moisture then + if math_random(1,100) > 42 then entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} end + end + if scrapyard < -0.28 or scrapyard > 0.28 then + -- if math_random(1,128) == 1 then + -- Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) + -- entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} + -- end + if math_random(1,96) == 1 then entities[#entities + 1] = {name = scrap_entities[math_random(1, scrap_entities_index)], position = p, force = "enemy"} end + if math_random(1,5) > 1 then entities[#entities + 1] = {name="mineable-wreckage", position=p} end + return + end + return + end + + local cave_ponds = get_noise("cave_ponds", p, seed) + if cave_ponds < -0.6 and scrapyard > -0.2 and scrapyard < 0.2 then + tiles[#tiles + 1] = {name = "deepwater-green", position = p} + if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end + return + end + + local large_caves = get_noise("large_caves", p, seed) + if scrapyard > -0.15 and scrapyard < 0.15 then + if math_floor(large_caves * 10) % 4 < 3 then + tiles[#tiles + 1] = {name = "dirt-7", position = p} + local jumps = global.objective.chronojumps * 5 + if global.objective.chronojumps > 20 then jumps = 100 end + if math_random(1,200 - jumps) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 100 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + return + end + end + + + --if math_random(1,64) == 1 and cave_ponds > 0.6 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end + + tiles[#tiles + 1] = {name = "stone-path", position = p} +end + +local levels = { + process_level_1_position, + process_level_2_position, + process_level_3_position, + process_rocky_position, + process_forest_position, + process_river_position, + process_biter_position, + process_scrapyard_position, + process_level_9_position, + process_level_10_position, +} + +local entity_functions = { + ["turret"] = function(surface, entity) surface.create_entity(entity) end, + ["simple-entity"] = function(surface, entity) surface.create_entity(entity) end, + ["ammo-turret"] = function(surface, entity) + local e = surface.create_entity(entity) + e.insert({name = "uranium-rounds-magazine", count = math_random(16, 64)}) + end, + ["container"] = function(surface, entity) + Treasure(surface, entity.position, entity.name) + end, +} + +local function get_replacement_tile(surface, position) + for i = 1, 128, 1 do + local vectors = {{0, i}, {0, i * -1}, {i, 0}, {i * -1, 0}} + table.shuffle_table(vectors) + for k, v in pairs(vectors) do + local tile = surface.get_tile(position.x + v[1], position.y + v[2]) + if not tile.collides_with("resource-layer") then return tile.name end + end + end + return "grass-1" +end + +local function replace_water(surface, left_top) + for x = 0, 31, 1 do + for y = 0, 31, 1 do + local p = {x = left_top.x + x, y = left_top.y + y} + if surface.get_tile(p).collides_with("resource-layer") then + surface.set_tiles({{name = get_replacement_tile(surface, p), position = p}}, true) + end + end + end +end + +local function forest_chunk(surface, left_top, level, planet) + local tiles = {} + local entities = {} + --local markets = {} + local treasure = {} + local seed = surface.map_gen_settings.seed + local process_level = levels[level] + for y = 0.5, 31.5, 1 do + for x = 0.5, 31.5, 1 do + local p = {x = left_top.x + x, y = left_top.y + y} + process_level(p, seed, tiles, entities, treasure, planet) + end + end + surface.set_tiles(tiles, true) + for _, entity in pairs(entities) do + if surface.can_place_entity(entity) then + local e = surface.create_entity(entity) + if e.name == "biter-spawner" or e.name == "spitter-spawner" then + if math_abs(e.position.x) > 420 or math_abs(e.position.y) > 420 then e.destructible = false end + end + end + end +end + +local function biter_chunk(surface, left_top, level, planet) + local tiles = {} + local entities = {} + --local markets = {} + local treasure = {} + local seed = surface.map_gen_settings.seed + local process_level = levels[level] + for y = 0, 31, 1 do + for x = 0, 31, 1 do + local p = {x = left_top.x + x, y = left_top.y + y} + process_level(p, seed, tiles, entities, treasure, planet) + end + end + surface.set_tiles(tiles, true) + for _, entity in pairs(entities) do + if surface.can_place_entity(entity) then + local e = surface.create_entity(entity) + if e.name == "biter-spawner" or e.name == "spitter-spawner" then + if math_abs(e.position.x) > 420 or math_abs(e.position.y) > 420 then e.destructible = false end + end + end + + end +end + +local function empty_chunk(surface, left_top, level, planet) + local tiles = {} + local entities = {} + --local markets = {} + local treasure = {} + local seed = surface.map_gen_settings.seed + local process_level = levels[level] + + for y = 0, 31, 1 do + for x = 0, 31, 1 do + local p = {x = left_top.x + x, y = left_top.y + y} + process_level(p, seed, tiles, entities, treasure, planet) + end + end + surface.set_tiles(tiles, true) + replace_water(surface, left_top) +end + +local function normal_chunk(surface, left_top, level, planet) + local tiles = {} + local entities = {} + --local markets = {} + local treasure = {} + local seed = surface.map_gen_settings.seed + + --local level_index = math_floor((math_abs(left_top.y / level_depth)) % 10) + 1 + local process_level = levels[level] + + for y = 0, 31, 1 do + for x = 0, 31, 1 do + local p = {x = left_top.x + x, y = left_top.y + y} + process_level(p, seed, tiles, entities, treasure, planet) + end + end + surface.set_tiles(tiles, true) + + -- if #markets > 0 then + -- local position = markets[math_random(1, #markets)] + -- if surface.count_entities_filtered{area = {{position.x - 96, position.y - 96}, {position.x + 96, position.y + 96}}, name = "market", limit = 1} == 0 then + -- local market = Market.mountain_market(surface, position, math_abs(position.y) * 0.004) + -- market.destructible = false + -- end + -- end + + for _, p in pairs(treasure) do + local name = "wooden-chest" + if math_random(1, 6) == 1 then name = "iron-chest" end + Treasure(surface, p, name) + end + + for _, entity in pairs(entities) do + if entity_functions[game.entity_prototypes[entity.name].type] then + entity_functions[game.entity_prototypes[entity.name].type](surface, entity) + else + if surface.can_place_entity(entity) then + local e = surface.create_entity(entity) + if e.name == "biter-spawner" or e.name == "spitter-spawner" then + if math_abs(e.position.x) > 420 or math_abs(e.position.y) > 420 then e.destructible = false end + end + end + end + end +end + +local function process_chunk(surface, left_top) + if not surface then return end + if not surface.valid then return end + if left_top.x >= level_depth * 0.5 or left_top.y >= level_depth * 0.5 then return end + if left_top.x < level_depth * -0.5 or left_top.y < level_depth * -0.5 then return end + + + --if left_top.y >= 0 then replace_water(surface, left_top) end + --if left_top.y > 32 then game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}}) end + -- if left_top.y == -128 and left_top.x == -128 then + -- local p = global.locomotive.position + -- for _, entity in pairs(surface.find_entities_filtered({area = {{p.x - 3, p.y - 4},{p.x + 3, p.y + 10}}, type = "simple-entity"})) do entity.destroy() end + -- end + local planet = global.objective.planet + if planet[1].name.name == "scrapyard" then + if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 8, planet) return end + if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 8, planet) return end + elseif planet[1].name.name == "river planet" then + if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 6, planet) return end + if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 6, planet) return end + elseif planet[1].name.name == "choppy planet" then + if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 5, planet) return end + if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then forest_chunk(surface, left_top, 5, planet) return end + elseif planet[1].name.name == "rocky planet" then + if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 4, planet) return end + if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 4, planet) return end + -- elseif planet[1].name.name == "lava planet" then + -- if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 4, planet) return end + -- if math_abs(left_top.y) > 31 and math_abs(left_top.x) > 31 then empty_chunk(surface, left_top, 4, planet) return end + else + if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 7, planet) return end + if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then biter_chunk(surface, left_top, 7, planet) return end + end + --if left_top.y > 96 then out_of_map(surface, left_top) return end + --if left_top.y > 64 then biter_chunk(surface, left_top) return end + --if left_top.y >= 0 then border_chunk(surface, left_top) return end + --rock_chunk(surface, left_top) + --return +end + +local function on_chunk_generated(event) + if string.sub(event.surface.name, 0, 12) ~= "chronosphere" then return end + process_chunk(event.surface, event.area.left_top) + --global.chunk_queue[#global.chunk_queue + 1] = {left_top = {x = event.area.left_top.x, y = event.area.left_top.y}, surface_index = event.surface.index} +end + +local event = require 'utils.event' +--event.on_nth_tick(4, process_chunk_queue) +event.add(defines.events.on_chunk_generated, on_chunk_generated) + +return level_depth diff --git a/maps/chronosphere/treasure.lua b/maps/chronosphere/treasure.lua new file mode 100644 index 00000000..977ba423 --- /dev/null +++ b/maps/chronosphere/treasure.lua @@ -0,0 +1,184 @@ +local math_random = math.random +local math_sqrt = math.sqrt + +local Public = {} + +function Public.treasure_chest(surface, position, container_name) + + local chest_raffle = {} + local chest_loot = { + {{name = "submachine-gun", count = math_random(1,3)}, weight = 3, d_min = 0.0, d_max = 0.1}, + {{name = "slowdown-capsule", count = math_random(16,32)}, weight = 1, d_min = 0.3, d_max = 0.7}, + {{name = "poison-capsule", count = math_random(8,16)}, weight = 3, d_min = 0.3, d_max = 1}, + {{name = "uranium-cannon-shell", count = math_random(16,32)}, weight = 5, d_min = 0.6, d_max = 1}, + {{name = "cannon-shell", count = math_random(16,32)}, weight = 5, d_min = 0.4, d_max = 0.7}, + {{name = "explosive-uranium-cannon-shell", count = math_random(16,32)}, weight = 5, d_min = 0.6, d_max = 1}, + {{name = "explosive-cannon-shell", count = math_random(16,32)}, weight = 5, d_min = 0.4, d_max = 0.8}, + {{name = "shotgun", count = 1}, weight = 2, d_min = 0.0, d_max = 0.2}, + {{name = "shotgun-shell", count = math_random(16,32)}, weight = 5, d_min = 0.0, d_max = 0.2}, + {{name = "combat-shotgun", count = 1}, weight = 3, d_min = 0.3, d_max = 0.8}, + {{name = "piercing-shotgun-shell", count = math_random(16,32)}, weight = 10, d_min = 0.2, d_max = 1}, + {{name = "flamethrower", count = 1}, weight = 3, d_min = 0.3, d_max = 0.6}, + {{name = "flamethrower-ammo", count = math_random(16,32)}, weight = 5, d_min = 0.3, d_max = 1}, + {{name = "rocket-launcher", count = 1}, weight = 3, d_min = 0.2, d_max = 0.6}, + {{name = "rocket", count = math_random(16,32)}, weight = 5, d_min = 0.2, d_max = 0.7}, + {{name = "explosive-rocket", count = math_random(16,32)}, weight = 5, d_min = 0.3, d_max = 1}, + {{name = "land-mine", count = math_random(16,32)}, weight = 5, d_min = 0.2, d_max = 0.7}, + {{name = "grenade", count = math_random(16,32)}, weight = 5, d_min = 0.0, d_max = 0.5}, + {{name = "cluster-grenade", count = math_random(8,16)}, weight = 5, d_min = 0.4, d_max = 1}, + {{name = "firearm-magazine", count = math_random(32,128)}, weight = 5, d_min = 0, d_max = 0.3}, + {{name = "piercing-rounds-magazine", count = math_random(32,128)}, weight = 5, d_min = 0.1, d_max = 0.8}, + {{name = "uranium-rounds-magazine", count = math_random(32,128)}, weight = 5, d_min = 0.5, d_max = 1}, + {{name = "railgun", count = 1}, weight = 1, d_min = 0.2, d_max = 1}, + {{name = "railgun-dart", count = math_random(16,32)}, weight = 3, d_min = 0.2, d_max = 0.7}, + {{name = "defender-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.0, d_max = 0.7}, + {{name = "distractor-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.2, d_max = 1}, + {{name = "destroyer-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.3, d_max = 1}, + {{name = "atomic-bomb", count = 1}, weight = 1, d_min = 0.8, d_max = 1}, + {{name = "light-armor", count = 1}, weight = 3, d_min = 0, d_max = 0.1}, + {{name = "heavy-armor", count = 1}, weight = 3, d_min = 0.1, d_max = 0.3}, + {{name = "modular-armor", count = 1}, weight = 2, d_min = 0.2, d_max = 0.6}, + {{name = "power-armor", count = 1}, weight = 1, d_min = 0.4, d_max = 1}, + --{{name = "power-armor-mk2", count = 1}, weight = 1, d_min = 0.9, d_max = 1}, + {{name = "battery-equipment", count = 1}, weight = 2, d_min = 0.3, d_max = 0.7}, + --{{name = "battery-mk2-equipment", count = 1}, weight = 2, d_min = 0.7, d_max = 1}, + {{name = "belt-immunity-equipment", count = 1}, weight = 1, d_min = 0.5, d_max = 1}, + {{name = "solar-panel-equipment", count = math_random(1,4)}, weight = 5, d_min = 0.4, d_max = 0.8}, + {{name = "discharge-defense-equipment", count = 1}, weight = 1, d_min = 0.5, d_max = 1}, + {{name = "energy-shield-equipment", count = math_random(1,2)}, weight = 2, d_min = 0.3, d_max = 0.8}, + --{{name = "energy-shield-mk2-equipment", count = 1}, weight = 2, d_min = 0.8, d_max = 1}, + {{name = "exoskeleton-equipment", count = 1}, weight = 1, d_min = 0.3, d_max = 1}, + --{{name = "fusion-reactor-equipment", count = 1}, weight = 1, d_min = 0.8, d_max = 1}, + {{name = "night-vision-equipment", count = 1}, weight = 1, d_min = 0.3, d_max = 0.8}, + {{name = "personal-laser-defense-equipment", count = 1}, weight = 1, d_min = 0.7, d_max = 1}, + + {{name = "personal-roboport-equipment", count = math_random(1,2)}, weight = 3, d_min = 0.4, d_max = 1}, + --{{name = "personal-roboport-mk2-equipment", count = 1}, weight = 1, d_min = 0.9, d_max = 1}, + {{name = "logistic-robot", count = math_random(5,25)}, weight = 2, d_min = 0.5, d_max = 1}, + {{name = "construction-robot", count = math_random(5,25)}, weight = 5, d_min = 0.4, d_max = 1}, + + {{name = "iron-gear-wheel", count = math_random(80,100)}, weight = 3, d_min = 0.0, d_max = 0.3}, + {{name = "copper-cable", count = math_random(100,200)}, weight = 3, d_min = 0.0, d_max = 0.3}, + {{name = "engine-unit", count = math_random(16,32)}, weight = 2, d_min = 0.1, d_max = 0.5}, + {{name = "electric-engine-unit", count = math_random(16,32)}, weight = 2, d_min = 0.4, d_max = 0.8}, + {{name = "battery", count = math_random(50,150)}, weight = 2, d_min = 0.3, d_max = 0.8}, + {{name = "advanced-circuit", count = math_random(50,150)}, weight = 3, d_min = 0.3, d_max = 1}, + {{name = "electronic-circuit", count = math_random(50,150)}, weight = 4, d_min = 0.0, d_max = 0.4}, + {{name = "processing-unit", count = math_random(50,150)}, weight = 3, d_min = 0.7, d_max = 1}, + {{name = "explosives", count = math_random(40,100)}, weight = 20, d_min = 0.0, d_max = 1}, + {{name = "lubricant-barrel", count = math_random(4,10)}, weight = 1, d_min = 0.3, d_max = 0.5}, + {{name = "rocket-fuel", count = math_random(4,10)}, weight = 2, d_min = 0.3, d_max = 0.7}, + --{{name = "computer", count = 1}, weight = 2, d_min = 0, d_max = 1}, + + {{name = "effectivity-module", count = math_random(1,4)}, weight = 2, d_min = 0.1, d_max = 1}, + {{name = "productivity-module", count = math_random(1,4)}, weight = 2, d_min = 0.1, d_max = 1}, + {{name = "speed-module", count = math_random(1,4)}, weight = 2, d_min = 0.1, d_max = 1}, + + {{name = "automation-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.0, d_max = 0.2}, + {{name = "logistic-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.1, d_max = 0.5}, + {{name = "military-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.2, d_max = 1}, + {{name = "chemical-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.3, d_max = 1}, + {{name = "production-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.4, d_max = 1}, + {{name = "utility-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.5, d_max = 1}, + {{name = "space-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.9, d_max = 1}, + + {{name = "steel-plate", count = math_random(25,75)}, weight = 2, d_min = 0.1, d_max = 0.3}, + {{name = "nuclear-fuel", count = 1}, weight = 2, d_min = 0.7, d_max = 1}, + + {{name = "burner-inserter", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.1}, + {{name = "inserter", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.4}, + {{name = "long-handed-inserter", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.4}, + {{name = "fast-inserter", count = math_random(8,16)}, weight = 3, d_min = 0.1, d_max = 1}, + {{name = "filter-inserter", count = math_random(8,16)}, weight = 1, d_min = 0.2, d_max = 1}, + {{name = "stack-filter-inserter", count = math_random(4,8)}, weight = 1, d_min = 0.4, d_max = 1}, + {{name = "stack-inserter", count = math_random(4,8)}, weight = 3, d_min = 0.3, d_max = 1}, + {{name = "small-electric-pole", count = math_random(16,24)}, weight = 3, d_min = 0.0, d_max = 0.3}, + {{name = "medium-electric-pole", count = math_random(8,16)}, weight = 3, d_min = 0.2, d_max = 1}, + {{name = "big-electric-pole", count = math_random(4,8)}, weight = 3, d_min = 0.3, d_max = 1}, + {{name = "substation", count = math_random(2,4)}, weight = 3, d_min = 0.5, d_max = 1}, + {{name = "wooden-chest", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.2}, + {{name = "iron-chest", count = math_random(8,16)}, weight = 3, d_min = 0.1, d_max = 0.4}, + {{name = "steel-chest", count = math_random(8,16)}, weight = 3, d_min = 0.3, d_max = 1}, + {{name = "small-lamp", count = math_random(16,32)}, weight = 3, d_min = 0.1, d_max = 0.3}, + {{name = "rail", count = math_random(25,75)}, weight = 3, d_min = 0.1, d_max = 0.6}, + {{name = "assembling-machine-1", count = math_random(2,4)}, weight = 3, d_min = 0.0, d_max = 0.3}, + {{name = "assembling-machine-2", count = math_random(2,4)}, weight = 3, d_min = 0.2, d_max = 0.8}, + {{name = "assembling-machine-3", count = math_random(2,4)}, weight = 3, d_min = 0.5, d_max = 1}, + {{name = "accumulator", count = math_random(4,8)}, weight = 3, d_min = 0.4, d_max = 1}, + {{name = "offshore-pump", count = math_random(1,3)}, weight = 2, d_min = 0.0, d_max = 0.2}, + {{name = "beacon", count = 1}, weight = 2, d_min = 0.7, d_max = 1}, + {{name = "boiler", count = math_random(3,6)}, weight = 3, d_min = 0.0, d_max = 0.3}, + {{name = "steam-engine", count = math_random(2,4)}, weight = 3, d_min = 0.0, d_max = 0.5}, + {{name = "steam-turbine", count = math_random(1,2)}, weight = 2, d_min = 0.6, d_max = 1}, + {{name = "nuclear-reactor", count = 1}, weight = 1, d_min = 0.7, d_max = 1}, + {{name = "centrifuge", count = 1}, weight = 1, d_min = 0.6, d_max = 1}, + {{name = "heat-pipe", count = math_random(4,8)}, weight = 2, d_min = 0.5, d_max = 1}, + {{name = "heat-exchanger", count = math_random(2,4)}, weight = 2, d_min = 0.5, d_max = 1}, + {{name = "arithmetic-combinator", count = math_random(4,8)}, weight = 2, d_min = 0.1, d_max = 1}, + {{name = "constant-combinator", count = math_random(4,8)}, weight = 2, d_min = 0.1, d_max = 1}, + {{name = "decider-combinator", count = math_random(4,8)}, weight = 2, d_min = 0.1, d_max = 1}, + {{name = "power-switch", count = 1}, weight = 2, d_min = 0.1, d_max = 1}, + {{name = "programmable-speaker", count = math_random(2,4)}, weight = 1, d_min = 0.1, d_max = 1}, + {{name = "green-wire", count = math_random(50,99)}, weight = 4, d_min = 0.1, d_max = 1}, + {{name = "red-wire", count = math_random(50,99)}, weight = 4, d_min = 0.1, d_max = 1}, + {{name = "chemical-plant", count = math_random(1,3)}, weight = 3, d_min = 0.3, d_max = 1}, + {{name = "burner-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.0, d_max = 0.2}, + {{name = "electric-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.2, d_max = 1}, + {{name = "express-transport-belt", count = math_random(25,75)}, weight = 3, d_min = 0.5, d_max = 1}, + {{name = "express-underground-belt", count = math_random(4,8)}, weight = 3, d_min = 0.5, d_max = 1}, + {{name = "express-splitter", count = math_random(1,4)}, weight = 3, d_min = 0.5, d_max = 1}, + {{name = "fast-transport-belt", count = math_random(25,75)}, weight = 3, d_min = 0.2, d_max = 0.7}, + {{name = "fast-underground-belt", count = math_random(4,8)}, weight = 3, d_min = 0.2, d_max = 0.7}, + {{name = "fast-splitter", count = math_random(1,4)}, weight = 3, d_min = 0.2, d_max = 0.3}, + {{name = "transport-belt", count = math_random(25,75)}, weight = 3, d_min = 0, d_max = 0.3}, + {{name = "underground-belt", count = math_random(4,8)}, weight = 3, d_min = 0, d_max = 0.3}, + {{name = "splitter", count = math_random(1,4)}, weight = 3, d_min = 0, d_max = 0.3}, + --{{name = "oil-refinery", count = math_random(2,4)}, weight = 2, d_min = 0.3, d_max = 1}, + {{name = "pipe", count = math_random(30,50)}, weight = 3, d_min = 0.0, d_max = 0.3}, + {{name = "pipe-to-ground", count = math_random(4,8)}, weight = 1, d_min = 0.2, d_max = 0.5}, + {{name = "pumpjack", count = math_random(1,3)}, weight = 1, d_min = 0.3, d_max = 0.8}, + {{name = "pump", count = math_random(1,2)}, weight = 1, d_min = 0.3, d_max = 0.8}, + {{name = "solar-panel", count = math_random(3,6)}, weight = 3, d_min = 0.4, d_max = 0.9}, + {{name = "electric-furnace", count = math_random(2,4)}, weight = 3, d_min = 0.5, d_max = 1}, + {{name = "steel-furnace", count = math_random(4,8)}, weight = 3, d_min = 0.2, d_max = 0.7}, + {{name = "stone-furnace", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.2}, + {{name = "radar", count = math_random(1,2)}, weight = 1, d_min = 0.1, d_max = 0.4}, + {{name = "rail-signal", count = math_random(8,16)}, weight = 2, d_min = 0.2, d_max = 0.8}, + {{name = "rail-chain-signal", count = math_random(8,16)}, weight = 2, d_min = 0.2, d_max = 0.8}, + {{name = "stone-wall", count = math_random(33,99)}, weight = 3, d_min = 0.0, d_max = 0.7}, + {{name = "gate", count = math_random(16,32)}, weight = 3, d_min = 0.0, d_max = 0.7}, + {{name = "storage-tank", count = math_random(2,6)}, weight = 3, d_min = 0.3, d_max = 0.6}, + {{name = "train-stop", count = math_random(1,2)}, weight = 1, d_min = 0.2, d_max = 0.7}, + {{name = "express-loader", count = math_random(1,2)}, weight = 1, d_min = 0.5, d_max = 1}, + {{name = "fast-loader", count = math_random(1,2)}, weight = 1, d_min = 0.2, d_max = 0.7}, + {{name = "loader", count = math_random(1,2)}, weight = 1, d_min = 0.0, d_max = 0.5}, + {{name = "lab", count = math_random(1,2)}, weight = 2, d_min = 0.0, d_max = 0.3}, + {{name = "roboport", count = 1}, weight = 2, d_min = 0.8, d_max = 1}, + {{name = "flamethrower-turret", count = 1}, weight = 3, d_min = 0.5, d_max = 1}, + {{name = "laser-turret", count = math_random(3,6)}, weight = 3, d_min = 0.5, d_max = 1}, + {{name = "gun-turret", count = math_random(2,4)}, weight = 3, d_min = 0.2, d_max = 0.9}, + } + local jumps = 0 + if global.objective.chronojumps then jumps = global.objective.chronojumps end + local distance_to_center = math_sqrt(position.y * position.y + position.x * position.x) * (1 + jumps / 50) * 0.0002 + if distance_to_center > 1 then distance_to_center = 1 end + + for _, t in pairs (chest_loot) do + for x = 1, t.weight, 1 do + --if math_random(1,50) == 1 then log(distance_to_center) end + if t.d_min <= distance_to_center and t.d_max >= distance_to_center then + table.insert(chest_raffle, t[1]) + end + end + end + + local e = surface.create_entity({name = container_name, position=position, force="neutral", create_build_effect_smoke = false}) + e.minable = false + local i = e.get_inventory(defines.inventory.chest) + for x = 1, math_random(2,6), 1 do + local loot = chest_raffle[math_random(1,#chest_raffle)] + i.insert(loot) + end +end + +return Public.treasure_chest From 14dc28132f06a2f6737cfb7c4c2cfbeced072f9f Mon Sep 17 00:00:00 2001 From: hanakocz Date: Fri, 14 Feb 2020 21:08:23 +0100 Subject: [PATCH 02/70] update check for chronosphere --- functions/tick_tack_trap.lua | 7 +++++-- functions/unearthing_biters.lua | 1 + functions/unearthing_worm.lua | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/functions/tick_tack_trap.lua b/functions/tick_tack_trap.lua index 139222bf..cc5fb90b 100644 --- a/functions/tick_tack_trap.lua +++ b/functions/tick_tack_trap.lua @@ -21,7 +21,8 @@ for _, t in pairs (kaboom_weights) do end local function create_flying_text(surface, position, text) - surface.create_entity({ + if not surface.valid then return end + surface.create_entity({ name = "flying-text", position = position, text = text, @@ -32,7 +33,8 @@ local function create_flying_text(surface, position, text) end local function create_kaboom(surface, position, name) - local target = position + if not surface.valid then return end + local target = position local speed = 0.5 if name == "defender-capsule" or name == "destroyer-capsule" or name == "distractor-capsule" then surface.create_entity({ @@ -56,6 +58,7 @@ end local function tick_tack_trap(surface, position) if not surface then return end + if not surface.valid then return end if not position then return end if not position.x then return end if not position.y then return end diff --git a/functions/unearthing_biters.lua b/functions/unearthing_biters.lua index fd942a8c..0be3a2fb 100644 --- a/functions/unearthing_biters.lua +++ b/functions/unearthing_biters.lua @@ -52,6 +52,7 @@ end local function unearthing_biters(surface, position, amount) if not surface then return end + if not surface.valid then return end if not position then return end if not position.x then return end if not position.y then return end diff --git a/functions/unearthing_worm.lua b/functions/unearthing_worm.lua index fc6c38bb..e3691548 100644 --- a/functions/unearthing_worm.lua +++ b/functions/unearthing_worm.lua @@ -37,6 +37,7 @@ end local function unearthing_worm(surface, position) if not surface then return end + if not surface.valid then return end if not position then return end if not position.x then return end if not position.y then return end From deb10ccfa16959224d60dcf1758461b7c614cd67 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Fri, 14 Feb 2020 21:10:10 +0100 Subject: [PATCH 03/70] Update tick_tack_trap.lua --- functions/tick_tack_trap.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/tick_tack_trap.lua b/functions/tick_tack_trap.lua index cc5fb90b..f487d16d 100644 --- a/functions/tick_tack_trap.lua +++ b/functions/tick_tack_trap.lua @@ -22,7 +22,7 @@ end local function create_flying_text(surface, position, text) if not surface.valid then return end - surface.create_entity({ + surface.create_entity({ name = "flying-text", position = position, text = text, @@ -34,7 +34,7 @@ end local function create_kaboom(surface, position, name) if not surface.valid then return end - local target = position + local target = position local speed = 0.5 if name == "defender-capsule" or name == "destroyer-capsule" or name == "distractor-capsule" then surface.create_entity({ @@ -58,7 +58,7 @@ end local function tick_tack_trap(surface, position) if not surface then return end - if not surface.valid then return end + if not surface.valid then return end if not position then return end if not position.x then return end if not position.y then return end @@ -87,4 +87,4 @@ local function tick_tack_trap(surface, position) end end -return tick_tack_trap \ No newline at end of file +return tick_tack_trap From 0e89e46d37d2f03d60ea0a440dbaa0ac26c69749 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Fri, 14 Feb 2020 21:10:32 +0100 Subject: [PATCH 04/70] Update unearthing_biters.lua --- functions/unearthing_biters.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/unearthing_biters.lua b/functions/unearthing_biters.lua index 0be3a2fb..bcb53126 100644 --- a/functions/unearthing_biters.lua +++ b/functions/unearthing_biters.lua @@ -52,7 +52,7 @@ end local function unearthing_biters(surface, position, amount) if not surface then return end - if not surface.valid then return end + if not surface.valid then return end if not position then return end if not position.x then return end if not position.y then return end @@ -80,4 +80,4 @@ local function unearthing_biters(surface, position, amount) end end -return unearthing_biters \ No newline at end of file +return unearthing_biters From 8f9ab4986b29d65fc792c2e8490f280bcf5b7d84 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Fri, 14 Feb 2020 21:10:47 +0100 Subject: [PATCH 05/70] Update unearthing_worm.lua --- functions/unearthing_worm.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/unearthing_worm.lua b/functions/unearthing_worm.lua index e3691548..9ee61a6b 100644 --- a/functions/unearthing_worm.lua +++ b/functions/unearthing_worm.lua @@ -37,7 +37,7 @@ end local function unearthing_worm(surface, position) if not surface then return end - if not surface.valid then return end + if not surface.valid then return end if not position then return end if not position.x then return end if not position.y then return end @@ -62,4 +62,4 @@ local function unearthing_worm(surface, position) end end -return unearthing_worm \ No newline at end of file +return unearthing_worm From 1b1404bbf4d0946684e188623336c8391df2879b Mon Sep 17 00:00:00 2001 From: hanakocz Date: Fri, 14 Feb 2020 21:12:13 +0100 Subject: [PATCH 06/70] Update control.lua --- control.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/control.lua b/control.lua index 58f57162..e057e090 100644 --- a/control.lua +++ b/control.lua @@ -66,6 +66,7 @@ require "modules.autostash" ----------------------------- ---- enable maps here ---- (maps higher up in the list may be more actually playable) +--require "maps.chronosphere.main" --require "maps.fish_defender.main" --require "maps.biter_battles_v2.main" --require "maps.mountain_fortress_v2.main" From 0eb6a95d6942873af0362a504dc5e1553f9427bf Mon Sep 17 00:00:00 2001 From: hanakocz Date: Fri, 14 Feb 2020 22:02:42 +0100 Subject: [PATCH 07/70] research fix --- maps/chronosphere/main.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index dd82507c..10aa53d1 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -694,6 +694,13 @@ local function on_entity_died(event) --if not event.entity.valid then return end end +local function on_research_finished(event) + event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 100 + refresh_gui() + if not event.research.force.technologies["steel-axe"].researched then return end + event.research.force.manual_mining_speed_modifier = 1 + game.forces.player.mining_drill_productivity_bonus * 4 +end + local function on_player_driving_changed_state(event) local player = game.players[event.player_index] local vehicle = event.entity @@ -713,7 +720,7 @@ event.add(defines.events.on_player_joined_game, on_player_joined_game) --event.add(defines.events.on_player_left_game, on_player_left_game) event.add(defines.events.on_pre_player_mined_item, pre_player_mined_item) event.add(defines.events.on_player_mined_entity, on_player_mined_entity) ---event.add(defines.events.on_research_finished, on_research_finished) +event.add(defines.events.on_research_finished, on_research_finished) event.add(defines.events.on_market_item_purchased, on_market_item_purchased) event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state) From 8c68f18187bc47579c3d39d01812f719b2ad517c Mon Sep 17 00:00:00 2001 From: hanakocz Date: Mon, 17 Feb 2020 00:46:22 +0100 Subject: [PATCH 08/70] Upgrades, rebalance --- maps/chronosphere/ai.lua | 20 +- maps/chronosphere/chronobubles.lua | 47 +-- maps/chronosphere/gui.lua | 74 ++++- maps/chronosphere/locomotive.lua | 287 +++++++++------- maps/chronosphere/main.lua | 508 +++++++++++++++++++++++++---- maps/chronosphere/ores.lua | 65 +--- maps/chronosphere/terrain.lua | 44 ++- maps/chronosphere/treasure.lua | 2 +- 8 files changed, 764 insertions(+), 283 deletions(-) diff --git a/maps/chronosphere/ai.lua b/maps/chronosphere/ai.lua index 86f72e25..011fc87e 100644 --- a/maps/chronosphere/ai.lua +++ b/maps/chronosphere/ai.lua @@ -52,23 +52,23 @@ end local function is_biter_inactive(biter, unit_number) if not biter.entity then - print("AI: active unit " .. unit_number .. " removed, possibly died.") + --print("AI: active unit " .. unit_number .. " removed, possibly died.") return true end if not biter.entity.valid then - print("AI: active unit " .. unit_number .. " removed, biter invalid.") + --print("AI: active unit " .. unit_number .. " removed, biter invalid.") return true end if not biter.entity.unit_group then - print("AI: active unit " .. unit_number .. " at x" .. biter.entity.position.x .. " y" .. biter.entity.position.y .. " removed, had no unit group.") + --print("AI: active unit " .. unit_number .. " at x" .. biter.entity.position.x .. " y" .. biter.entity.position.y .. " removed, had no unit group.") return true end if not biter.entity.unit_group.valid then - print("AI: active unit " .. unit_number .. " removed, unit group invalid.") + --print("AI: active unit " .. unit_number .. " removed, unit group invalid.") return true end if game.tick - biter.active_since > 162000 then - print("AI: " .. "enemy" .. " unit " .. unit_number .. " timed out at tick age " .. game.tick - biter.active_since .. ".") + --print("AI: " .. "enemy" .. " unit " .. unit_number .. " timed out at tick age " .. game.tick - biter.active_since .. ".") biter.entity.destroy() return true end @@ -189,9 +189,9 @@ Public.send_near_biters_to_objective = function() local random_target = targets[math_random(1, #targets)] local surface = random_target.surface local pollution = surface.get_pollution(random_target.position) - local success = false - if pollution > 500 then - surface.pollute(random_target.position, -500) + local success = false + if pollution > 300 then + surface.pollute(random_target.position, -100) --game.print("sending objective wave") success = true else @@ -268,8 +268,8 @@ local function send_group(unit_group, nearest_player_unit) local target = targets[math_random(1, #targets)] local surface = target.surface local pollution = surface.get_pollution(target.position) - if pollution > 500 then - surface.pollute(target.position, -500) + if pollution > 300 then + surface.pollute(target.position, -100) --game.print("sending unit group attack") local commands = {} diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua index bfd71ad8..db5c2d58 100644 --- a/maps/chronosphere/chronobubles.lua +++ b/maps/chronosphere/chronobubles.lua @@ -3,21 +3,21 @@ local math_random = math.random --cumul_chance must be sum of this and all previous chances, add new planets at the end only, or recalculate --biters: used in spawner generation within math_random(1, 52 - biters), so higher number gives better chance. not to be greater than 50. local variants = { - [1] = {id = 1, name = "iron planet", iron = 10, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0, chance = 1, cumul_chance = 1}, - [2] = {id = 2, name = "copper planet", iron = 1, copper = 10, coal = 1, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0, chance = 1, cumul_chance = 2}, - [3] = {id = 3, name = "stone planet", iron = 1, copper = 1, coal = 1, stone = 10, uranium = 0, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 3}, - [4] = {id = 4, name = "oil planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 5, biters = 16, moisture = 0.1, chance = 1, cumul_chance = 4}, - [5] = {id = 5, name = "uranium planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 7, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 5}, - [6] = {id = 6, name = "mixed planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 1, oil = 1, biters = 10, moisture = 0, chance = 10, cumul_chance = 15}, - [7] = {id = 7, name = "biter planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 4, oil = 3, biters = 40, moisture = 0.2, chance = 8, cumul_chance = 23}, - [8] = {id = 8, name = "water planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 6, moisture = 0.5, chance = 2, cumul_chance = 25}, - [9] = {id = 9, name = "coal planet", iron = 1, copper = 1, coal = 10, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0, chance = 1, cumul_chance = 26}, - [10] = {id = 10, name = "scrapyard", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 1, oil = 0, biters = 0, moisture = -0.2, chance = 4, cumul_chance = 30}, - [11] = {id = 11, name = "rocky planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 6, moisture = -0.2, chance = 2, cumul_chance = 32}, - [12] = {id = 12, name = "choppy planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 1, biters = 6, moisture = 0.4, chance = 2, cumul_chance = 34}, - [13] = {id = 13, name = "river planet", iron = 1, copper = 1, coal = 3, stone = 1, uranium = 0, oil = 0, biters = 8, moisture = 0.5, chance = 2, cumul_chance = 36}, - [14] = {id = 14, name = "lava planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 6, moisture = -0.5, chance = 0, cumul_chance = 36}, - [15] = {id = 15, name = "ruins planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 2, oil = 0, biters = 8, moisture = 0, chance = 0, cumul_chance = 36}, + [1] = {id = 1, name = "iron planet", iron = 6, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 1}, + [2] = {id = 2, name = "copper planet", iron = 1, copper = 6, coal = 1, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0.2, chance = 1, cumul_chance = 2}, + [3] = {id = 3, name = "stone planet", iron = 1, copper = 1, coal = 1, stone = 6, uranium = 0, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 3}, + [4] = {id = 4, name = "oil planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 6, biters = 16, moisture = 0.1, chance = 1, cumul_chance = 4}, + [5] = {id = 5, name = "uranium planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 6, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 5}, + [6] = {id = 6, name = "mixed planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 0, oil = 2, biters = 10, moisture = 0, chance = 3, cumul_chance = 8}, + [7] = {id = 7, name = "biter planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 4, oil = 3, biters = 40, moisture = 0.2, chance = 4, cumul_chance = 12}, + [8] = {id = 8, name = "water planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 6, moisture = 0.5, chance = 1, cumul_chance = 13}, + [9] = {id = 9, name = "coal planet", iron = 1, copper = 1, coal = 6, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0, chance = 1, cumul_chance = 14}, + [10] = {id = 10, name = "scrapyard", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 1, oil = 0, biters = 0, moisture = -0.2, chance = 3, cumul_chance = 17}, + [11] = {id = 11, name = "rocky planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 6, moisture = -0.2, chance = 2, cumul_chance = 19}, + [12] = {id = 12, name = "choppy planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 1, biters = 6, moisture = 0.4, chance = 2, cumul_chance = 21}, + [13] = {id = 13, name = "river planet", iron = 1, copper = 1, coal = 3, stone = 1, uranium = 0, oil = 0, biters = 8, moisture = 0.5, chance = 2, cumul_chance = 23}, + [14] = {id = 14, name = "lava planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 6, moisture = -0.5, chance = 1, cumul_chance = 24}, + [15] = {id = 15, name = "start planet", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24}, } @@ -31,12 +31,15 @@ local time_speed_variants = { } local richness = { - [1] = {name = "very rich", factor = 4}, - [2] = {name = "rich", factor = 3}, - [3] = {name = "above average", factor = 2}, + [1] = {name = "very rich", factor = 3}, + [2] = {name = "rich", factor = 2}, + [3] = {name = "rich", factor = 2}, [4] = {name = "normal", factor = 1}, - [5] = {name = "poor", factor = 0.5}, - [6] = {name = "very poor", factor = 0.2} + [5] = {name = "normal", factor = 1}, + [6] = {name = "normal", factor = 1}, + [7] = {name = "poor", factor = 0.6}, + [8] = {name = "poor", factor = 0.6}, + [9] = {name = "very poor", factor = 0.3} } local function roll(weight) for i = 1, 100, 1 do @@ -68,6 +71,10 @@ function Public.determine_planet(choice) ore_richness = richness[math_random(1, #richness)], } } + if global.objective.game_lost then + planet[1].name = variants[15] + planet[1].ore_richness = richness[2] + end return planet end diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index a8d5bc41..78310bb8 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -46,6 +46,18 @@ local function create_gui(player) label.style.minimal_width = 10 label.style.font_color = {r = 150, g = 0, b = 255} + local label = frame.add({ type = "label", caption = " ", name = "timer2"}) + label.style.font = "default-bold" + label.style.right_padding = 1 + label.style.minimal_width = 10 + label.style.font_color = {r = 0, g = 200, b = 0} + + local label = frame.add({ type = "label", caption = " ", name = "timer_value2"}) + label.style.font = "default-bold" + label.style.right_padding = 1 + label.style.minimal_width = 10 + label.style.font_color = {r = 0, g = 200, b = 0} + local line = frame.add({type = "line", direction = "vertical"}) line.style.left_padding = 4 line.style.right_padding = 8 @@ -62,6 +74,18 @@ local function create_gui(player) label.style.minimal_width = 10 label.style.font_color = {r = 150, g = 0, b = 255} + local label = frame.add({ type = "label", caption = " ", name = "planet"}) + label.style.font = "default-bold" + label.style.right_padding = 1 + label.style.minimal_width = 10 + label.style.font_color = {r = 0, g = 100, b = 200} + + local label = frame.add({ type = "label", caption = "[Upgrades]", name = "upgrades", tooltip = " "}) + label.style.font = "default-bold" + label.style.right_padding = 1 + label.style.minimal_width = 10 + label.style.font_color = {r=0.33, g=0.66, b=0.9} + end local function update_gui(player) @@ -79,11 +103,59 @@ local function update_gui(player) gui.charger_value.caption = objective.chronotimer .. " / " .. objective.chrononeeds gui.timer.caption = {"chronosphere.gui_3"} - gui.timer_value.caption = math_floor((objective.chrononeeds - objective.chronotimer) / 60) .. " minutes, " .. (objective.chrononeeds - objective.chronotimer) % 60 .. " seconds" + gui.timer_value.caption = math_floor((objective.chrononeeds - objective.chronotimer) / 60) .. " min, " .. (objective.chrononeeds - objective.chronotimer) % 60 .. " s" + + gui.planet.caption = "Planet: " .. objective.planet[1].name.name .. " Ores: " .. objective.planet[1].ore_richness.name + local acus = 0 + if global.acumulators then acus = #global.acumulators else acus = 0 end + local bestcase = math_floor((objective.chrononeeds - objective.chronotimer) / (1 + math_floor(acus/10))) + gui.timer2.caption = {"chronosphere.gui_3_1"} + gui.timer_value2.caption = math_floor(bestcase / 60) .. " min, " .. bestcase % 60 .. " s (when using " .. acus * 0.3 .. "MW)" local evolution = game.forces["enemy"].evolution_factor gui.evo.caption = {"chronosphere.gui_4"} gui.evo_value.caption = math_floor(evolution * 100) .. "%" + local chests = { + [1] = {c = "250 wooden chests\n"}, + [2] = {c = "250 iron chests\n"}, + [3] = {c = "250 steel chests\n"}, + [4] = {c = "250 storage chests\n"}, + [5] = {c = "--\n"} + } + local upgt = { + [1] = {t = "[1]: + 5000 Train Max HP. Current: " .. objective.max_health .. "\n Cost : 2500 coins + 3000 copper plates\n"}, + [2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%,\n Cost: 4000 coins + 1000 green circuits\n"}, + [3] = {t = "[3]: Add additional row of Acumulators.\n Cost: 2500 coins + 200 batteries\n"}, + [4] = {t = "[4]: Add item pickup distance to players.Current: +" .. objective.pickupupgradetier .. ",\n Cost: 1000 coins + 400 red inserters\n"}, + [5] = {t = "[5]: Add +5 inventory slots. Buyable once per 5 jumps.\n Cost: 2000 coins + " .. chests[objective.invupgradetier + 1].c}, + [6] = {t = "[6]: Use up more repair tools on train at once. Current: +" .. objective.toolsupgradetier .. "\n Cost: 1000 coins + 200 repair tools\n"}, + [7] = {t = "[7]: Add piping through wagon sides to create water sources for each wagon.\n Cost: 2000 coins + 500 pipes\n"}, + [8] = {t = "[8]: Add comfylatron chests that output outside (into cargo wagon 2 and 3)\n Cost: 2000 coins + 100 fast inserters\n"}, + [9] = {t = "[9]: Add storage chests to the sides of wagons.\n Buyable once per 5 jumps.\n Cost: 5000 coins + " .. chests[objective.boxupgradetier + 1].c} + } + local maxed = { + [1] = {t = "[1]: Train HP maxed.\n"}, + [2] = {t = "[2]: Pollution Filter maxed. Pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%\n"}, + [3] = {t = "[3]: Acumulators maxed.\n"}, + [4] = {t = "[4]: Pickup distance maxed.\n"}, + [5] = {t = "[5]: Inventory maxed. Research Mining Productivity for more.\n"}, + [6] = {t = "[6]: Repairing at top speed of 5 packs.\n"}, + [7] = {t = "[7]: Piping created. Don't spill it!\n"}, + [8] = {t = "[8]: Chests created.\n"}, + [9] = {t = "[9]: Storage chests fully upgraded.\n"} + } + local tooltip = "Insert needed items into chest with upgrade number.\nUpgrading can take a minute.\n\n" + if objective.hpupgradetier < 18 then tooltip = tooltip .. upgt[1].t else tooltip = tooltip .. maxed[1].t end + if objective.filterupgradetier < 9 then tooltip = tooltip .. upgt[2].t else tooltip = tooltip .. maxed[2].t end + if objective.acuupgradetier < 24 then tooltip = tooltip .. upgt[3].t else tooltip = tooltip .. maxed[3].t end + if objective.pickupupgradetier < 4 then tooltip = tooltip .. upgt[4].t else tooltip = tooltip .. maxed[4].t end + if objective.invupgradetier < 4 then tooltip = tooltip .. upgt[5].t else tooltip = tooltip .. maxed[5].t end + if objective.toolsupgradetier < 4 then tooltip = tooltip .. upgt[6].t else tooltip = tooltip .. maxed[6].t end + if objective.waterupgradetier < 1 then tooltip = tooltip .. upgt[7].t else tooltip = tooltip .. maxed[7].t end + if objective.outupgradetier < 1 then tooltip = tooltip .. upgt[8].t else tooltip = tooltip .. maxed[8].t end + if objective.boxupgradetier < 4 then tooltip = tooltip .. upgt[9].t else tooltip = tooltip .. maxed[9].t end + gui.upgrades.tooltip = tooltip + -- if evolution < 10 then -- gui.evo.style.font_color = {r = 255, g = 255, b = 0} diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index 6f4c361b..9875ec36 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -4,21 +4,26 @@ local math_floor = math.floor local math_random = math.random -function Public.locomotive_spawn(surface, position) +function Public.locomotive_spawn(surface, position, items, items2) for y = -10, 18, 2 do + local rail = {name = "straight-rail", position = {position.x, position.y + y}, force = "player", direction = 0} surface.create_entity({name = "straight-rail", position = {position.x, position.y + y}, force = "player", direction = 0}) end global.locomotive = surface.create_entity({name = "locomotive", position = {position.x, position.y + -6}, force = "player"}) global.locomotive.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 100}) global.locomotive_cargo = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 0}, force = "player"}) - global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 1}) + global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 100}) global.locomotive_cargo2 = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 6}, force = "player"}) - global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 1}) + for item, count in pairs(items) do + global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) + end global.locomotive_cargo3 = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 13}, force = "player"}) - global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 1}) + for item, count in pairs(items) do + global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) + end if not global.comfychests then global.comfychests = {} end if not global.acumulators then global.acumulators = {} end @@ -113,7 +118,7 @@ local function remove_acceleration() global.locomotive_driver = nil end ]] -local function spawn_acumulators() +function spawn_acumulators() local x = -28 local y = -252 local yy = global.objective.acuupgradetier * 2 @@ -137,51 +142,13 @@ local market_offers = { {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'stone', count = 50}}, {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'coal', count = 50}}, {price = {{"coin", 200}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}, - {price = {{"coin", 25}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}}, + {price = {{"coin", 25}, {"empty-barrel", 1}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}}, + {price = {{"coin", 200}, {"steel-plate", 20}, {"electronic-circuit", 20}}, offer = {type = 'give-item', item = 'loader', count = 1}}, + {price = {{"coin", 400}, {"steel-plate", 40}, {"advanced-circuit", 10}, {"loader", 1}}, offer = {type = 'give-item', item = 'fast-loader', count = 1}}, + {price = {{"coin", 600}, {"express-transport-belt", 10}, {"fast-loader", 1}}, offer = {type = 'give-item', item = 'express-loader', count = 1}}, + --{price = {{"coin", 5}, {"stone", 100}}, offer = {type = 'give-item', item = 'landfill', count = 1}}, + {price = {{"coin", 1}, {"steel-plate", 1}, {"explosives", 10}}, offer = {type = 'give-item', item = 'land-mine', count = 1}} } -local market_offers2 = { - [1] = function () - if global.objective.hpupgradetier >= 18 then return end - global.objective.max_health = global.objective.max_health + 5000 - global.objective.hpupgradetier = global.objective.hpupgradetier + 1 - rendering.set_text(global.objective.health_text, "HP: " .. global.objective.health .. " / " .. global.objective.max_health) - end, - [2] = function () - if global.objective.acuupgradetier >= 24 then return end - global.objective.acuupgradetier = global.objective.acuupgradetier + 1 - spawn_acumulators() - end, - [3] = function () - if global.objective.filterupgradetier >= 14 then return end - global.objective.filterupgradetier = global.objective.filterupgradetier + 1 - end, - -} -local function setup_upgrade_shop(market2) - local special_offers = {} - if global.objective.hpupgradetier < 18 then - special_offers[1] = {{{"coin", 2500}}, "Upgrade Train's Health. Current max health: " .. global.objective.max_health } - else - special_offers[1] = {{{"computer", 1}}, "Maximum Health upgrades reached!"} - end - if global.objective.acuupgradetier < 24 then - special_offers[2] = {{{"coin", 2500}}, "Upgrade Acumulator capacity"} - else - special_offers[2] = {{{"computer", 1}}, "Maximum Acumulators reached!"} - end - if global.objective.filterupgradetier < 14 then - special_offers[3] = {{{"coin", 2500}}, "Upgrade Pollution filter. Actual pollution from train: " .. math_floor(400/(global.objective.filterupgradetier/2+1)) .. "%"} - else - special_offers[3] = {{{"computer", 1}}, "Best filter reached! Actual pollution from train: " .. math_floor(400/(global.objective.filterupgradetier/2+1)) .. "%"} - end - - local market_items = {} - for _, offer in pairs(special_offers) do - table.insert(market_items, {price = offer[1], offer = {type = 'nothing', effect_description = offer[2]}}) - end - for _, offer in pairs(market_items) do market2.add_market_item(offer) end -end - local function create_wagon_room() local width = 64 @@ -190,7 +157,7 @@ local function create_wagon_room() if not global.acumulators then global.acumulators = {} end local map_gen_settings = { ["width"] = width, - ["height"] = height, + ["height"] = height + 128, ["water"] = 0, ["starting_area"] = 1, ["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0}, @@ -208,6 +175,12 @@ local function create_wagon_room() surface.force_generate_chunk_requests() for x = width * -0.5, width * 0.5 - 1, 1 do + for y = height * 0.5, height * 0.7, 1 do + surface.set_tiles({{name = "out-of-map", position = {x,y}}}) + end + for y = height * -0.7, height * -0.5, 1 do + surface.set_tiles({{name = "out-of-map", position = {x,y}}}) + end for y = height * -0.5 + 3, height * 0.5 - 4, 1 do surface.set_tiles({{name = "tutorial-grid", position = {x,y}}}) end @@ -290,19 +263,51 @@ local function create_wagon_room() powerpole.destructible = false local market = surface.create_entity({name = "market", position = {-5, height * -0.5 + 13}, force="neutral", create_build_effect_smoke = false}) - local market2 = surface.create_entity({name = "market", position = {4, height * -0.5 + 13}, force="neutral", create_build_effect_smoke = false}) local repairchest = surface.create_entity({name = "compilatron-chest", position = {0, height * -0.5 + 13}, force = "player"}) + local hpchest = surface.create_entity({name = "compilatron-chest", position = {3, height * -0.5 + 12}, force = "player"}) + local filterchest = surface.create_entity({name = "compilatron-chest", position = {4, height * -0.5 + 12}, force = "player"}) + local acuchest = surface.create_entity({name = "compilatron-chest", position = {5, height * -0.5 + 12}, force = "player"}) + local playerchest = surface.create_entity({name = "compilatron-chest", position = {3, height * -0.5 + 13}, force = "player"}) + local invchest = surface.create_entity({name = "compilatron-chest", position = {4, height * -0.5 + 13}, force = "player"}) + local toolschest = surface.create_entity({name = "compilatron-chest", position = {5, height * -0.5 + 13}, force = "player"}) + local waterchest = surface.create_entity({name = "compilatron-chest", position = {3, height * -0.5 + 14}, force = "player"}) + local outchest = surface.create_entity({name = "compilatron-chest", position = {4, height * -0.5 + 14}, force = "player"}) + local boxchest = surface.create_entity({name = "compilatron-chest", position = {5, height * -0.5 + 14}, force = "player"}) repairchest.minable = false repairchest.destructible = false + hpchest.minable = false + hpchest.destructible = false + filterchest.minable = false + filterchest.destructible = false + acuchest.minable = false + acuchest.destructible = false + playerchest.minable = false + playerchest.destructible = false + invchest.minable = false + invchest.destructible = false + toolschest.minable = false + toolschest.destructible = false + waterchest.minable = false + waterchest.destructible = false + outchest.minable = false + outchest.destructible = false + boxchest.minable = false + boxchest.destructible = false market.minable = false market.destructible = false - market2.minable = false - market2.destructible = false - global.upgrademarket = market2 global.repairchest = repairchest + global.hpchest = hpchest + global.filterchest = filterchest + global.acuchest = acuchest + global.playerchest = playerchest + global.invchest = invchest + global.toolschest = toolschest + global.waterchest = waterchest + global.outchest = outchest + global.boxchest = boxchest local repair_text = rendering.draw_text{ - text = "Insert repair tools to repair train", + text = "Repair chest", surface = surface, target = global.repairchest, target_offset = {0, -2.5}, @@ -323,10 +328,10 @@ local function create_wagon_room() alignment = "center", scale_with_zoom = false } - local market2_text = rendering.draw_text{ + local upgrade_text = rendering.draw_text{ text = "Upgrades", surface = surface, - target = market2, + target = filterchest, target_offset = {0, -3.5}, color = global.locomotive.color, scale = 1.00, @@ -334,23 +339,91 @@ local function create_wagon_room() alignment = "center", scale_with_zoom = false } + local upgrade_sub_text = rendering.draw_text{ + text = "Click [Upgrades] on top of screen", + surface = surface, + target = filterchest, + target_offset = {0, -2.5}, + color = global.locomotive.color, + scale = 0.80, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + local upgrade1_text = rendering.draw_sprite{ + sprite = "virtual-signal/signal-1", + surface = surface, + target = hpchest, + target_offset = {0, -0.1}, + font = "default-game", + visible = true + } + local upgrade2_text = rendering.draw_sprite{ + sprite = "virtual-signal/signal-2", + surface = surface, + target = filterchest, + target_offset = {0, -0.1}, + font = "default-game", + visible = true + } + local upgrade3_text = rendering.draw_sprite{ + sprite = "virtual-signal/signal-3", + surface = surface, + target = acuchest, + target_offset = {0, -0.1}, + font = "default-game", + visible = true + } + local upgrade4_text = rendering.draw_sprite{ + sprite = "virtual-signal/signal-4", + surface = surface, + target = playerchest, + target_offset = {0, -0.1}, + font = "default-game", + visible = true + } + local upgrade5_text = rendering.draw_sprite{ + sprite = "virtual-signal/signal-5", + surface = surface, + target = invchest, + target_offset = {0, -0.1}, + font = "default-game", + visible = true + } + local upgrade6_text = rendering.draw_sprite{ + sprite = "virtual-signal/signal-6", + surface = surface, + target = toolschest, + target_offset = {0, -0.1}, + font = "default-game", + visible = true + } + local upgrade7_text = rendering.draw_sprite{ + sprite = "virtual-signal/signal-7", + surface = surface, + target = waterchest, + target_offset = {0, -0.1}, + font = "default-game", + visible = true + } + local upgrade8_text = rendering.draw_sprite{ + sprite = "virtual-signal/signal-8", + surface = surface, + target = outchest, + target_offset = {0, -0.1}, + font = "default-game", + visible = true + } + local upgrade9_text = rendering.draw_sprite{ + sprite = "virtual-signal/signal-9", + surface = surface, + target = boxchest, + target_offset = {0, -0.1}, + font = "default-game", + visible = true + } - -- for x = -6, 5, 1 do - -- for y = height * -0.5 + 11, height * -0.5 + 15, 4 do - -- local wall = surface.create_entity({name = "stone-wall", position = {x,y}, force="neutral", create_build_effect_smoke = false}) - -- wall.minable = false - -- wall.destructible = false - -- end - -- end - -- for y = height * -0.5 + 11, height * -0.5 + 15, 1 do - -- for x = -7, 6, 13 do - -- local wall = surface.create_entity({name = "stone-wall", position = {x,y}, force="neutral", create_build_effect_smoke = false}) - -- wall.minable = false - -- wall.destructible = false - -- end - -- end for _, offer in pairs(market_offers) do market.add_market_item(offer) end - setup_upgrade_shop(market2) --generate cars-- for _, x in pairs({width * -0.5 -0.5, width * 0.5 + 0.5}) do @@ -375,11 +448,6 @@ local function create_wagon_room() e.operable = false end - --local e = Public.spawn_comfylatron(surface.index, 0, height * -0.5 + 13) - --local e = surface.create_entity({name = "compilatron", position = {0, height * -0.5 + 13}, force = "player", create_build_effect_smoke = false}) - --e.ai_settings.allow_destroy_when_commands_fail = false - - --generate chests inside south wagon-- local positions = {} for x = width * -0.5 + 2, width * 0.5 - 1, 1 do @@ -507,6 +575,7 @@ function Public.enter_cargo_wagon(player, vehicle) player.teleport(surface.find_non_colliding_position("character", position, 128, 0.5), surface) end if player.surface.name == "cargo_wagon" and vehicle.type == "car" then + global.flame_boots[player.index].steps = {} local surface = global.locomotive_cargo.surface local x_vector = (vehicle.position.x / math.abs(vehicle.position.x)) * 2 local y_vector = vehicle.position.y / 16 @@ -517,40 +586,40 @@ function Public.enter_cargo_wagon(player, vehicle) end end -local function clear_offers(market) - for i = 1, 256, 1 do - local a = market.remove_market_item(1) - if a == false then return end - end -end +-- local function clear_offers(market) +-- for i = 1, 256, 1 do +-- local a = market.remove_market_item(1) +-- if a == false then return end +-- end +-- end -function Public.refresh_offers(event) +-- function Public.refresh_offers(event) +-- +-- local market = event.entity or event.market +-- if not market then return end +-- if not market.valid then return end +-- if market.name ~= "market" then return end +-- if market ~= global.upgrademarket then return end +-- clear_offers(market) +-- setup_upgrade_shop(market) +-- end - local market = event.entity or event.market - if not market then return end - if not market.valid then return end - if market.name ~= "market" then return end - if market ~= global.upgrademarket then return end - clear_offers(market) - setup_upgrade_shop(market) -end - -function Public.offer_purchased(event) - local offer_index = event.offer_index - if not market_offers2[offer_index] then return end - local market = event.market - if not market.name == "market" then return end - - market_offers2[offer_index]() - - count = event.count - if count > 1 then - local offers = market.get_market_items() - local price = offers[offer_index].price[1].amount - game.players[event.player_index].insert({name = "coin", count = price * (count - 1)}) - end - Public.refresh_offers(event) -end +-- function Public.offer_purchased(event) +-- local offer_index = event.offer_index +-- if not market_offers2[offer_index] then return end +-- local market = event.market +-- if not market.name == "market" then return end +-- +-- market_offers2[offer_index]() +-- +-- count = event.count +-- if count > 1 then +-- local offers = market.get_market_items() +-- local price = offers[offer_index].price[1].amount +-- game.players[event.player_index].insert({name = "coin", count = price * (count - 1)}) +-- end +-- Public.refresh_offers(event) +-- end diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 10aa53d1..354927c7 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -22,7 +22,6 @@ local chronobuble = require "maps.chronosphere.chronobubles" local level_depth = require "maps.chronosphere.terrain" local Reset = require "functions.soft_reset" local Map = require "modules.map_info" -local WD = require "modules.wave_defense.table" local Locomotive = require "maps.chronosphere.locomotive" local Modifier = require "player_modifiers" local update_gui = require "maps.chronosphere.gui" @@ -31,8 +30,9 @@ local math_floor = math.floor local math_sqrt = math.sqrt local chests = {} local Public = {} -local acus = {} +--local acus = {} global.objective = {} +global.flame_boots = {} local choppy_entity_yield = { ["tree-01"] = {"iron-ore"}, @@ -42,25 +42,8 @@ local choppy_entity_yield = { } -local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16, ['wood'] = 16} --- function roll_planet() --- for i = 1, 100, 1 do --- local planet = chronobuble.determine_planet() --- log("Planet number " .. i .. " stats:") --- log("Name: " .. planet[1].name.name) --- log("Speed of day: " .. planet[1].day_speed.name) --- log("Time of day: " .. planet[1].time) --- log("Ore richness: " .. planet[1].ore_richness.name .. ", multiplier: " .. planet[1].ore_richness.factor) --- end --- end --- --- function roll_planet2() --- for i = 1, 100, 1 do --- local planet = chronobuble.determine_planet() --- log("#" .. i .. "#" .. planet[1].name.id .. "#" .. planet[1].day_speed.timer .. "#" .. planet[1].time .. "#" .. planet[1].ore_richness.factor) --- end --- end - +local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['grenade'] = 1, ['raw-fish'] = 4, ['rail'] = 16, ['wood'] = 16} +local starting_cargo = {['firearm-magazine'] = 16, ['iron-plate'] = 16, ['wood'] = 16, ['burner-mining-drill'] = 8} function generate_overworld(surface, optplanet) local planet = nil @@ -73,6 +56,8 @@ function generate_overworld(surface, optplanet) end if planet[1].name.name == "choppy planet" then game.print("Comfylatron: OwO what are those strange trees?!? They have ore fruits! WTF!", {r=0.98, g=0.66, b=0.22}) + elseif planet[1].name.name == "lava planet" then + game.print("Comfylatron: OOF this one is a bit hot. And have seen those biters? They BATHE in fire!", {r=0.98, g=0.66, b=0.22}) end surface.min_brightness = 0 surface.brightness_visual_weights = {1, 1, 1} @@ -95,12 +80,17 @@ function generate_overworld(surface, optplanet) end if planet[1].name.name == "water planet" then local mgs = surface.map_gen_settings - mgs.water = 0.6 + mgs.water = 0.8 + surface.map_gen_settings = mgs + end + if planet[1].name.name == "lava planet" then + local mgs = surface.map_gen_settings + mgs.water = 0 surface.map_gen_settings = mgs end if planet[1].name.name ~= "choppy planet" then local mgs = surface.map_gen_settings - mgs.water = 0.6 + mgs.water = 0.2 surface.map_gen_settings = mgs end --log(timer) @@ -167,7 +157,6 @@ end function Public.reset_map() - local wave_defense_table = WD.get_table() global.chunk_queue = {} if game.surfaces["chronosphere"] then game.delete_surface(game.surfaces["chronosphere"]) end if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end @@ -194,12 +183,21 @@ function Public.reset_map() objective.hpupgradetier = 0 objective.acuupgradetier = 0 objective.filterupgradetier = 0 + objective.pickupupgradetier = 0 + objective.invupgradetier = 0 + objective.toolsupgradetier = 0 + objective.waterupgradetier = 0 + objective.outupgradetier = 0 + objective.boxupgradetier = 0 objective.chronojumps = 0 objective.chronotimer = 0 objective.chrononeeds = 2000 objective.active_biters = {} objective.unit_groups = {} objective.biter_raffle = {} + global.outchests = {} + + game.difficulty_settings.technology_price_multiplier = 0.5 @@ -218,15 +216,10 @@ function Public.reset_map() game.forces.player.technologies["railway"].researched = true game.forces.player.set_spawn_position({12, 10}, surface) - Locomotive.locomotive_spawn(surface, {x = 16, y = 10}) + Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, starting_cargo, starting_cargo) render_train_hp() - - - WD.reset_wave_defense() - wave_defense_table.surface_index = global.active_surface_index - wave_defense_table.target = global.locomotive_cargo - wave_defense_table.nest_building_density = 32 - wave_defense_table.game_lost = false + game.reset_time_played() + objective.game_lost = false @@ -237,6 +230,8 @@ end local function on_player_joined_game(event) local player_modifiers = Modifier.get_table() local player = game.players[event.player_index] + global.flame_boots[event.player_index] = {fuel = 1} + if not global.flame_boots[event.player_index].steps then global.flame_boots[event.player_index].steps = {} end --log(chronobuble.determine_planet()) --set_difficulty() @@ -273,19 +268,311 @@ end local function repair_train() local objective = global.objective if not game.surfaces["cargo_wagon"] then return end - if WD.get_table().game_lost == true then return end + if objective.game_lost == true then return end if objective.health < objective.max_health then - if global.repairchest.get_inventory(defines.inventory.chest).get_item_count("repair-pack") > 1 then - global.repairchest.get_inventory(defines.inventory.chest).remove({name = "repair-pack", count = 1}) + local inv = global.repairchest.get_inventory(defines.inventory.chest) + local count = inv.get_item_count("repair-pack") + if count >= 5 and objective.toolsupgradetier == 4 and objective.health + 750 <= objective.max_health then + inv.remove({name = "repair-pack", count = 5}) + set_objective_health(-750) + elseif count >= 4 and objective.toolsupgradetier == 3 and objective.health + 600 <= objective.max_health then + inv.remove({name = "repair-pack", count = 4}) + set_objective_health(-600) + elseif count >= 3 and objective.toolsupgradetier == 2 and objective.health + 450 <= objective.max_health then + inv.remove({name = "repair-pack", count = 3}) + set_objective_health(-450) + elseif count >= 2 and objective.toolsupgradetier == 1 and objective.health + 300 <= objective.max_health then + inv.remove({name = "repair-pack", count = 2}) set_objective_health(-300) + elseif count >= 1 then + inv.remove({name = "repair-pack", count = 1}) + set_objective_health(-150) end end end +local function check_upgrades() + local objective = global.objective + if not game.surfaces["cargo_wagon"] then return end + if objective.game_lost == true then return end + if global.hpchest and global.hpchest.valid then + local inv = global.hpchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("copper-plate") + if countcoins >= 2500 and count2 >= 3000 and objective.hpupgradetier < 18 then + inv.remove({name = "coin", count = 2500}) + inv.remove({name = "copper-plate", count = 3000}) + game.print("Comfylatron: Train's max HP was upgraded.", {r=0.98, g=0.66, b=0.22}) + objective.hpupgradetier = objective.hpupgradetier + 1 + objective.max_health = 10000 + 5000 * objective.hpupgradetier + rendering.set_text(global.objective.health_text, "HP: " .. global.objective.health .. " / " .. global.objective.max_health) + end + end + if global.filterchest and global.filterchest.valid then + local inv = global.filterchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("electronic-circuit") + if countcoins >= 4000 and count2 >= 1000 and objective.filterupgradetier < 9 then + inv.remove({name = "coin", count = 4000}) + inv.remove({name = "electronic-circuit", count = 1000}) + game.print("Comfylatron: Train's pollution filter was upgraded.", {r=0.98, g=0.66, b=0.22}) + objective.filterupgradetier = objective.filterupgradetier + 1 + end + end + if global.acuchest and global.acuchest.valid then + local inv = global.acuchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("battery") + if countcoins >= 2500 and count2 >= 200 and objective.acuupgradetier < 24 then + inv.remove({name = "coin", count = 2500}) + inv.remove({name = "battery", count = 200}) + game.print("Comfylatron: Train's acumulator capacity was upgraded.", {r=0.98, g=0.66, b=0.22}) + objective.acuupgradetier = objective.acuupgradetier + 1 + spawn_acumulators() + end + end + if global.playerchest and global.playerchest.valid then + local inv = global.playerchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("long-handed-inserter") + if countcoins >= 1000 and count2 >= 400 and objective.pickupupgradetier < 4 then + inv.remove({name = "coin", count = 1000}) + inv.remove({name = "long-handed-inserter", count = 400}) + game.print("Comfylatron: Players now have additional red inserter installed on shoulders, increasing their item pickup range.", {r=0.98, g=0.66, b=0.22}) + objective.pickupupgradetier = objective.pickupupgradetier + 1 + game.forces.player.character_item_pickup_distance_bonus = game.forces.player.character_item_pickup_distance_bonus + 1 + end + end + if global.invchest and global.invchest.valid then + local inv = global.invchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local item = "computer" + if objective.invupgradetier == 0 then + item = "wooden-chest" + elseif objective.invupgradetier == 1 then + item = "iron-chest" + elseif objective.invupgradetier == 2 then + item = "steel-chest" + elseif objective.invupgradetier == 3 then + item = "logistic-chest-storage" + end + local count2 = inv.get_item_count(item) + if countcoins >= 2000 and count2 >= 250 and objective.invupgradetier < 4 and objective.chronojumps >= (objective.invupgradetier + 1) * 5 then + inv.remove({name = "coin", count = 2000}) + inv.remove({name = item, count = 250}) + game.print("Comfylatron: Players now can carry more trash in their unsorted inventories.", {r=0.98, g=0.66, b=0.22}) + objective.invupgradetier = objective.invupgradetier + 1 + game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + 10 + end + end + + if global.toolschest and global.toolschest.valid then + local inv = global.toolschest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("repair-pack") + if countcoins >= 1000 and count2 >= 200 and objective.toolsupgradetier < 4 then + inv.remove({name = "coin", count = 1000}) + inv.remove({name = "repair-pack", count = 200}) + game.print("Comfylatron: Train now gets repaired with additional repair kit at once.", {r=0.98, g=0.66, b=0.22}) + objective.toolsupgradetier = objective.toolsupgradetier + 1 + end + end + if global.waterchest and global.waterchest.valid and game.surfaces["cargo_wagon"].valid then + local inv = global.waterchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("pipe") + if countcoins >= 2000 and count2 >= 500 and objective.waterupgradetier < 1 then + inv.remove({name = "coin", count = 2000}) + inv.remove({name = "pipe", count = 500}) + game.print("Comfylatron: Train now has piping system for additional water sources.", {r=0.98, g=0.66, b=0.22}) + objective.waterupgradetier = objective.waterupgradetier + 1 + local e1 = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = {28,66}, force="player"}) + local e2 = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = {28,-62}, force = "player"}) + local e3 = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = {-29,66}, force = "player"}) + local e4 = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = {-29,-62}, force = "player"}) + e1.destructible = false + e1.minable = false + e2.destructible = false + e2.minable = false + e3.destructible = false + e3.minable = false + e4.destructible = false + e4.minable = false + end + end + if global.outchest and global.outchest.valid and game.surfaces["cargo_wagon"].valid then + local inv = global.outchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("fast-inserter") + if countcoins >= 2000 and count2 >= 100 and objective.outupgradetier < 1 then + inv.remove({name = "coin", count = 2000}) + inv.remove({name = "fast-inserter", count = 100}) + game.print("Comfylatron: Train now has output chests.", {r=0.98, g=0.66, b=0.22}) + objective.outupgradetier = objective.outupgradetier + 1 + local e = {} + e[1] = game.surfaces["cargo_wagon"].create_entity({name="compilatron-chest", position= {-16,-62}, force = "player"}) + e[2] = game.surfaces["cargo_wagon"].create_entity({name="compilatron-chest", position= {15,-62}, force = "player"}) + e[3] = game.surfaces["cargo_wagon"].create_entity({name="compilatron-chest", position= {-16,66}, force = "player"}) + e[4] = game.surfaces["cargo_wagon"].create_entity({name="compilatron-chest", position= {15,66}, force = "player"}) + + local out = {} + for i = 1, 4, 1 do + e[i].destructible = false + e[i].minable = false + global.outchests[i] = e[i] + out[i] = rendering.draw_text{ + text = "Output", + surface = e[i].surface, + target = e[i], + target_offset = {0, -1.5}, + color = global.locomotive.color, + scale = 0.80, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + end + end + end + if global.boxchest and global.boxchest.valid and game.surfaces["cargo_wagon"].valid then + local inv = global.boxchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local item = "computer" + if objective.boxupgradetier == 0 then + item = "wooden-chest" + elseif objective.boxupgradetier == 1 then + item = "iron-chest" + elseif objective.boxupgradetier == 2 then + item = "steel-chest" + elseif objective.boxupgradetier == 3 then + item = "logistic-chest-storage" + end + local count2 = inv.get_item_count(item) + if countcoins >= 5000 and count2 >= 250 and objective.boxupgradetier < 4 and objective.chronojumps >= (objective.boxupgradetier + 1) * 5 then + inv.remove({name = "coin", count = 5000}) + inv.remove({name = item, count = 250}) + game.print("Comfylatron: Cargo wagons now have enlargened storage.", {r=0.98, g=0.66, b=0.22}) + objective.boxupgradetier = objective.boxupgradetier + 1 + local chests = {} + for i = 1, 58, 1 do + if objective.boxupgradetier == 1 then + chests[#chests + 1] = {name="wooden-chest", position= {-33 ,-189 + i}, force = "player"} + chests[#chests + 1] = {name="wooden-chest", position= {32 ,-189 + i}, force = "player"} + elseif objective.boxupgradetier == 2 then + chests[#chests + 1] = {name="iron-chest", position= {-33 ,-189 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="iron-chest", position= {32 ,-189 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + elseif objective.boxupgradetier == 3 then + chests[#chests + 1] = {name="steel-chest", position= {-33 ,-189 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="steel-chest", position= {32 ,-189 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + elseif objective.boxupgradetier == 4 then + chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,-189 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,-189 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + end + end + for i = 1, 58, 1 do + if objective.boxupgradetier == 1 then + chests[#chests + 1] = {name="wooden-chest", position= {-33 ,-127 + i}, force = "player"} + chests[#chests + 1] = {name="wooden-chest", position= {32 ,-127 + i}, force = "player"} + elseif objective.boxupgradetier == 2 then + chests[#chests + 1] = {name="iron-chest", position= {-33 ,-127 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="iron-chest", position= {32 ,-127 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + elseif objective.boxupgradetier == 3 then + chests[#chests + 1] = {name="steel-chest", position= {-33 ,-127 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="steel-chest", position= {32 ,-127 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + elseif objective.boxupgradetier == 4 then + chests[#chests + 1] ={name="logistic-chest-storage", position= {-33 ,-127 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] ={name="logistic-chest-storage", position= {32 ,-127 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + end + end + for i = 1, 58, 1 do + if objective.boxupgradetier == 1 then + chests[#chests + 1] = {name="wooden-chest", position= {-33 ,-61 + i}, force = "player"} + chests[#chests + 1] = {name="wooden-chest", position= {32 ,-61 + i}, force = "player"} + elseif objective.boxupgradetier == 2 then + chests[#chests + 1] = {name="iron-chest", position= {-33 ,-61 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="iron-chest", position= {32 ,-61 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + elseif objective.boxupgradetier == 3 then + chests[#chests + 1] = {name="steel-chest", position= {-33 ,-61 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="steel-chest", position= {32 ,-61 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + elseif objective.boxupgradetier == 4 then + chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,-61 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,-61 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + end + end + for i = 1, 58, 1 do + if objective.boxupgradetier == 1 then + chests[#chests + 1] = {name="wooden-chest", position= {-33 ,1 + i}, force = "player"} + chests[#chests + 1] = {name="wooden-chest", position= {32 ,1 + i}, force = "player"} + elseif objective.boxupgradetier == 2 then + chests[#chests + 1] = {name="iron-chest", position= {-33 ,1 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="iron-chest", position= {32 ,1 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + elseif objective.boxupgradetier == 3 then + chests[#chests + 1] = {name="steel-chest", position= {-33 ,1 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="steel-chest", position= {32 ,1 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + elseif objective.boxupgradetier == 4 then + chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,1 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,1 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + end + end + for i = 1, 58, 1 do + if objective.boxupgradetier == 1 then + chests[#chests + 1] = {name="wooden-chest", position= {-33 ,67 + i}, force = "player"} + chests[#chests + 1] = {name="wooden-chest", position= {32 ,67 + i}, force = "player"} + elseif objective.boxupgradetier == 2 then + chests[#chests + 1] = {name="iron-chest", position= {-33 ,67 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="iron-chest", position= {32 ,67 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + elseif objective.boxupgradetier == 3 then + chests[#chests + 1] = {name="steel-chest", position= {-33 ,67 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="steel-chest", position= {32 ,67 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + elseif objective.boxupgradetier == 4 then + chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,67 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,67 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + end + end + for i = 1, 58, 1 do + if objective.boxupgradetier == 1 then + chests[#chests + 1] = {name="wooden-chest", position= {-33 ,129 + i}, force = "player"} + chests[#chests + 1] = {name="wooden-chest", position= {32 ,129 + i}, force = "player"} + elseif objective.boxupgradetier == 2 then + chests[#chests + 1] = {name="iron-chest", position= {-33 ,129 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="iron-chest", position= {32 ,129 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + elseif objective.boxupgradetier == 3 then + chests[#chests + 1] = {name="steel-chest", position= {-33 ,129 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="steel-chest", position= {32 ,129 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + elseif objective.boxupgradetier == 4 then + chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,129 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,129 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + end + end + local surface = game.surfaces["cargo_wagon"] + for i = 1, #chests, 1 do + surface.set_tiles({{name = "tutorial-grid", position = chests[i].position}}) + local e = surface.create_entity(chests[i]) + local old = nil + if e.name == "iron-chest" then old = surface.find_entity("wooden-chest", e.position) + elseif e.name == "steel-chest" then old = surface.find_entity("iron-chest", e.position) + elseif e.name == "logistic-chest-storage" then old = surface.find_entity("steel-chest", e.position) + end + if old then + local items = old.get_inventory(defines.inventory.chest).get_contents() + for item, count in pairs(items) do + e.insert({name = item, count = count}) + end + old.destroy() + end + e.destructible = false + e.minable = false + end + end + end +end + + + local function move_items() if not global.comfychests then return end if not global.comfychests2 then return end - if WD.get_table().game_lost == true then return end + if global.objective.game_lost == true then return end local input = global.comfychests local output = global.comfychests2 for i = 1, 24, 1 do @@ -312,10 +599,36 @@ local function move_items() end end +local function output_items() + if global.objective.game_lost == true then return end + if not global.outchests then return end + if not global.locomotive_cargo2 then return end + if not global.locomotive_cargo3 then return end + if global.objective.outupgradetier ~= 1 then return end + for i = 1, 4, 1 do + if not global.outchests[i].valid then return end + local inv = global.outchests[i].get_inventory(defines.inventory.chest) + inv.sort_and_merge() + local items = inv.get_contents() + for item, count in pairs(items) do + local inserted = nil + if i <= 2 then + inserted = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) + else + inserted = global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) + end + if inserted > 0 then + local removed = inv.remove({name = item, count = inserted}) + end + end + end +end + function chronojump(choice) local objective = global.objective + if objective.game_lost then return end objective.chronojumps = objective.chronojumps + 1 - objective.chrononeeds = objective.chrononeeds + 2000 + objective.chrononeeds = 2000 + 800 * objective.chronojumps objective.chronotimer = 0 game.print("Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. global.objective.chronojumps, {r=0.98, g=0.66, b=0.22}) local oldsurface = game.surfaces[global.active_surface_index] @@ -338,7 +651,9 @@ function chronojump(choice) end generate_overworld(surface, planet) game.forces.player.set_spawn_position({12, 10}, surface) - Locomotive.locomotive_spawn(surface, {x = 16, y = 10}) + local items = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).get_contents() + local items2 = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).get_contents() + Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, items, items2) render_train_hp() game.delete_surface(oldsurface) if objective.chronojumps <= 40 then @@ -346,10 +661,7 @@ function chronojump(choice) else game.forces["enemy"].evolution_factor = 1 end - game.map_settings.enemy_evolution.time_factor = 4e-05 + 1e-06 * objective.chronojumps - - - + game.map_settings.enemy_evolution.time_factor = 4e-05 + 2e-06 * objective.chronojumps end local function check_chronoprogress() @@ -378,7 +690,7 @@ local function charge_chronosphere() for i = 1, #acus, 1 do if not acus[i].valid then return end local energy = acus[i].energy - if energy > 3000000 and objective.chronotimer < objective.chrononeeds - 62 then + if energy > 3000000 and objective.chronotimer < objective.chrononeeds - 62 and objective.chronotimer > 130 then acus[i].energy = acus[i].energy - 3000000 objective.chronotimer = objective.chronotimer + 1 game.surfaces[global.active_surface_index].pollute(global.locomotive.position, 100 * (4 / (objective.filterupgradetier / 2 + 1))) @@ -390,7 +702,7 @@ end local function transfer_pollution() local surface = game.surfaces["cargo_wagon"] if not surface then return end - local pollution = surface.get_total_pollution() * (4 / (global.objective.filterupgradetier / 2 + 1)) + local pollution = surface.get_total_pollution() * (3 / (global.objective.filterupgradetier / 3 + 1)) game.surfaces[global.active_surface_index].pollute(global.locomotive.position, pollution) surface.clear_pollution() end @@ -401,7 +713,9 @@ local tick_minute_functions = { [300 * 3 + 30 * 0] = Ai.pre_main_attack, -- setup for main_attack [300 * 3 + 30 * 1] = Ai.perform_main_attack, [300 * 3 + 30 * 2] = Ai.perform_main_attack, - [300 * 3 + 30 * 3] = Ai.perform_main_attack, -- call perform_main_attack 7 times on different ticks + [300 * 3 + 30 * 3] = Ai.perform_main_attack, + [300 * 3 + 30 * 4] = Ai.perform_main_attack, + [300 * 3 + 30 * 5] = Ai.perform_main_attack, -- call perform_main_attack 7 times on different ticks [300 * 4] = Ai.send_near_biters_to_objective, [300 * 5] = Ai.wake_up_sleepy_groups @@ -424,16 +738,7 @@ local function tick() if tick % 1800 == 0 then Locomotive.set_player_spawn_and_refill_fish() repair_train() - --local surface = game.surfaces[global.active_surface_index] - --local last_position = global.map_collapse.last_position - --local position = surface.find_non_colliding_position("stone-furnace", {last_position.x, last_position.y - 32}, 128, 4) - --if position then - -- local wave_defense_table = WD.get_table() - -- wave_defense_table.spawn_position = position - --end - --if tick % 216000 == 0 then - -- Collapse.delete_out_of_map_chunks(surface) - --end + check_upgrades() end local key = tick % 3600 if tick_minute_functions[key] then tick_minute_functions[key]() end @@ -443,6 +748,7 @@ local function tick() end if tick % 120 == 0 then move_items() + output_items() end if global.game_reset_tick then if global.game_reset_tick < tick then @@ -463,7 +769,7 @@ local function on_init() T.localised_category = "chronosphere" T.main_caption_color = {r = 150, g = 150, b = 0} T.sub_caption_color = {r = 0, g = 150, b = 0} - + global.objective.game_lost = true --global.rocks_yield_ore_maximum_amount = 999 --global.rocks_yield_ore_base_amount = 50 @@ -478,8 +784,7 @@ function set_objective_health(final_damage_amount) if objective.health > objective.max_health then objective.health = objective.max_health end if objective.health <= 0 then - local wave_defense_table = WD.get_table() - if wave_defense_table.game_lost == true then return end + if objective.game_lost == true then return end objective.health = 0 local surface = objective.surface game.print("The chronotrain was destroyed!") @@ -501,8 +806,7 @@ function set_objective_health(final_damage_amount) global.ores_queue = {} global.entities_queue = {} global.acumulators = {} - wave_defense_table.game_lost = true - wave_defense_table.target = nil + objective.game_lost = true global.game_reset_tick = game.tick + 1800 for _, player in pairs(game.connected_players) do player.play_sound{path="utility/game_lost", volume_modifier=0.75} @@ -551,6 +855,17 @@ local function on_entity_damaged(event) if not event.entity.valid then return end if not event.entity.health then return end biters_chew_rocks_faster(event) + if global.objective.planet[1].name.name == "lava planet" and event.entity.force.name == "enemy" then + if event.damage_type.name == "fire" then + event.entity.health = event.entity.health + event.final_damage_amount + local fire = event.entity.stickers + if fire and #fire > 0 then + for i = 1, #fire, 1 do + if fire[i].sticked_to == event.entity and fire[i].name == "fire-sticker" then fire[i].destroy() break end + end + end + end + end end @@ -561,8 +876,8 @@ local function trap(entity) end local function get_choppy_amount(entity) - local distance_to_center = math_sqrt(entity.position.x^2 + entity.position.y^2) + 50 * global.objective.chronojumps - local amount = (25 + distance_to_center * 0.1) * (1 + game.forces.player.mining_drill_productivity_bonus) + local distance_to_center = 20 * global.objective.chronojumps + local amount = (40 + distance_to_center ) * (1 + game.forces.player.mining_drill_productivity_bonus) if amount > 1000 then amount = 1000 end amount = math_random(math_floor(amount * 0.5), math_floor(amount * 1.5)) return amount @@ -577,7 +892,7 @@ local function pre_player_mined_item(event) trap(event.entity) local rock_position = {x = event.entity.position.x, y = event.entity.position.y} event.entity.destroy() - local tile_distance_to_center = math_sqrt(rock_position.x^2 + rock_position.y^2) + 50 * objective.chronojumps + local tile_distance_to_center = 40 + 40 * objective.chronojumps * (1 + game.forces.player.mining_drill_productivity_bonus) if tile_distance_to_center > 1450 then tile_distance_to_center = 1450 end surface.spill_item_stack(player.position,{name = "raw-fish", count = math_random(1,3)},true) local bonus_amount = math_floor((tile_distance_to_center) + 1) @@ -695,8 +1010,7 @@ local function on_entity_died(event) end local function on_research_finished(event) - event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 100 - refresh_gui() + event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 100 + global.objective.invupgradetier * 5 if not event.research.force.technologies["steel-axe"].researched then return end event.research.force.manual_mining_speed_modifier = 1 + game.forces.player.mining_drill_productivity_bonus * 4 end @@ -707,8 +1021,64 @@ local function on_player_driving_changed_state(event) Locomotive.enter_cargo_wagon(player, vehicle) end -local function on_market_item_purchased(event) - Locomotive.offer_purchased(event) +-- function deny_building(event) +-- local entity = event.created_entity +-- if not entity.valid then return end +-- local surface = event.created_entity.surface +-- +-- if event.player_index then +-- game.players[event.player_index].insert({name = entity.name, count = 1}) +-- else +-- local inventory = event.robot.get_inventory(defines.inventory.robot_cargo) +-- inventory.insert({name = entity.name, count = 1}) +-- end +-- +-- surface.create_entity({ +-- name = "flying-text", +-- position = entity.position, +-- text = "Private Comfylatron's area!", +-- color = {r=0.98, g=0.66, b=0.22} +-- }) +-- +-- entity.destroy() +-- end + +-- local function on_built_entity(event) +-- if event.surface.name == "cargo_wagon" and event.position.y < -190 then +-- deny_building(event) +-- end +-- end +-- +-- local function on_robot_built_entity(event) +-- if event.surface.name == "cargo_wagon" and event.position.y < -190 then +-- deny_building(event) +-- end +-- Terrain.deny_construction_bots(event) +-- end +-- local function on_market_item_purchased(event) +-- Locomotive.offer_purchased(event) +-- end + +local function on_player_changed_position(event) + if global.objective.planet[1].name.name ~= "lava planet" then return end + local player = game.players[event.player_index] + if not player.character then return end + if player.character.driving then return end + if player.surface.name == "cargo_wagon" then return end + if not global.flame_boots[player.index].steps then global.flame_boots[player.index].steps = {} end + local steps = global.flame_boots[player.index].steps + + local elements = #steps + + steps[elements + 1] = {x = player.position.x, y = player.position.y} + + if elements > 10 then + player.surface.create_entity({name = "fire-flame", position = steps[elements - 1], }) + for i = 1, elements, 1 do + steps[i] = steps[i+1] + end + steps[elements + 1] = nil + end end local event = require 'utils.event' @@ -721,8 +1091,8 @@ event.add(defines.events.on_player_joined_game, on_player_joined_game) event.add(defines.events.on_pre_player_mined_item, pre_player_mined_item) event.add(defines.events.on_player_mined_entity, on_player_mined_entity) event.add(defines.events.on_research_finished, on_research_finished) -event.add(defines.events.on_market_item_purchased, on_market_item_purchased) +--event.add(defines.events.on_market_item_purchased, on_market_item_purchased) event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state) - +event.add(defines.events.on_player_changed_position, on_player_changed_position) return Public diff --git a/maps/chronosphere/ores.lua b/maps/chronosphere/ores.lua index 0ec58959..464c6b87 100644 --- a/maps/chronosphere/ores.lua +++ b/maps/chronosphere/ores.lua @@ -75,15 +75,15 @@ local function get_size_of_ore(ore, planet) local base_size = math_random(5, 10) + math_floor(planet[1].ore_richness.factor * 3) local final_size = 1 if planet[1].name.name == "iron planet" and ore == "iron-ore" then - final_size = base_size * 2 + final_size = math_floor(base_size * 1.5) elseif planet[1].name.name == "copper planet" and ore == "copper-ore" then - final_size = base_size * 2 + final_size = math_floor(base_size * 1.5) elseif planet[1].name.name == "stone planet" and ore == "stone" then - final_size = base_size * 2 + final_size = math_floor(base_size * 1.5) elseif planet[1].name.name == "coal planet" and ore == "coal" then - final_size = base_size * 2 + final_size = math_floor(base_size * 1.5) elseif planet[1].name.name == "uranium planet" and ore == "uranium-ore" then - final_size = base_size * 2 + final_size = math_floor(base_size * 1.5) elseif planet[1].name.name == "mixed planet" then final_size = base_size else @@ -94,64 +94,13 @@ end local function get_oil_amount(pos, oil_w) local hundred_percent = 300000 - return (hundred_percent / 50) * (1+global.objective.chronojumps) * oil_w + return (hundred_percent / 20) * (1+global.objective.chronojumps) * oil_w end --- function spawn_ores(surface, planet) --- --- --local r = 480 --- --local area = {{r * -1, r * -1}, {r, r}} --- local ores = {} --- if planet[1].name.name == "rocky planet" then return end --- local oil_amount = planet[1].name.oil --- if oil_amount > 0 then --- for a = 1, oil_amount, 1 do --- local poso = {x = math_random(-50,50) + math_random(250, 350) * math_random(-1,1), y = math_random(-50,50) + math_random(250, 350) * math_random(-1,1)} --- for a=1, math_random(2, 3 + oil_amount * 2), 1 do --- local posoo = {x = poso.x + math_random(-10,10), y = poso.y + math_random(-10,10)} --- --if surface.can_place_entity{name = "crude-oil", position = posoo} then --- --if not global.ores_queue[posoo.x] then global.ores_queue[posoo.x] = {} end --- global.entities_queue[pos_to_key(posoo)] = {name = "crude-oil", position = posoo, amount = get_oil_amount(posoo) * oil_amount } --- --end --- end --- end --- end --- if planet[1].name.name == "choppy planet" then return end --- local uranium_amount = planet[1].name.uranium --- if uranium_amount > 0 then --- for a = 1, uranium_amount, 1 do --- local posu = {x = 0 + math_random(350, 450) * math_random(-1,1), y = 0 + math_random(350, 450) * math_random(-1,1)} --- if posu.x ~= 0 or posu.y ~= 0 then --- --if surface.can_place_entity({name = "uranium-ore", position = posu, amount = 1}) then --- draw_noise_ore_patch(posu, "uranium-ore", surface, get_size_of_ore("uranium-ore", planet), math_random(200, 300) * planet[1].ore_richness.factor) --- --break --- --end --- end --- end --- end --- ores["iron-ore"] = surface.count_entities_filtered({name = "iron-ore", area = area}) --- ores["copper-ore"] = surface.count_entities_filtered({name = "copper-ore", area = area}) --- ores["coal"] = surface.count_entities_filtered({name = "coal", area = area}) --- ores["stone"] = surface.count_entities_filtered({name = "stone", area = area}) --- for ore, ore_count in pairs(ores) do --- if ore_count < 1000 or ore_count == nil then --- local pos = {} --- for a = 1, 8, 1 do --- pos = {x = -300 + math_random(0, 600), y = -300 + math_random(0, 600)} --- --if surface.can_place_entity({name = ore, position = pos, amount = 1}) then --- draw_noise_ore_patch(pos, ore, surface, get_size_of_ore(ore, planet), math_random(400, 500) * planet[1].ore_richness.factor) --- --break --- --end --- end --- --draw_noise_ore_patch(pos, ore, surface, get_size_of_ore(ore, planet), math_random(400, 500) * planet[1].ore_richness.factor) --- end --- end --- end - function spawn_ore_vein(surface, pos, planet) local mixed = false if planet[1].name.name == "mixed planet" then mixed = true end - local richness = math_random(50 + 10 * global.objective.chronojumps, 100 + 10 * global.objective.chronojumps) * planet[1].ore_richness.factor + local richness = math_random(50 + 30 * global.objective.chronojumps, 100 + 30 * global.objective.chronojumps) * planet[1].ore_richness.factor local iron = {w = planet[1].name.iron, t = planet[1].name.iron} local copper = {w = planet[1].name.copper, t = iron.t + planet[1].name.copper} local stone = {w = planet[1].name.stone, t = copper.t + planet[1].name.stone} diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index 09fe4496..05fb656b 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -194,11 +194,11 @@ end local function process_river_position(p, seed, tiles, entities, treasure, planet) local biters = planet[1].name.biters - local richness = math_random(50 + 10 * global.objective.chronojumps, 100 + 10 * global.objective.chronojumps) * planet[1].ore_richness.factor^2 - local iron_size = get_size_of_ore("iron-ore", planet) - local copper_size = get_size_of_ore("copper-ore", planet) - local stone_size = get_size_of_ore("stone", planet) - local coal_size = get_size_of_ore("coal", planet) + local richness = math_random(50 + 20 * global.objective.chronojumps, 100 + 20 * global.objective.chronojumps) * planet[1].ore_richness.factor + local iron_size = get_size_of_ore("iron-ore", planet) * 3 + local copper_size = get_size_of_ore("copper-ore", planet) * 3 + local stone_size = get_size_of_ore("stone", planet) * 3 + local coal_size = get_size_of_ore("coal", planet) * 4 if not biters then biters = 4 end local large_caves = get_noise("large_caves", p, seed) local cave_rivers = get_noise("cave_rivers", p, seed) @@ -223,7 +223,7 @@ local function process_river_position(p, seed, tiles, entities, treasure, planet tiles[#tiles + 1] = {name = "water-green", position = p} if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end return - elseif large_caves > -0.15 and large_caves < 0.15 and cave_rivers <0.35 then + elseif large_caves > -0.20 and large_caves < 0.20 and math_abs(cave_rivers) < 0.95 then if ores > -coal_size and ores < coal_size then entities[#entities + 1] = {name = "coal", position = p, amount = richness} end @@ -266,15 +266,20 @@ local function process_biter_position(p, seed, tiles, entities, treasure, planet local large_caves = get_noise("large_caves", p, seed) local biters = planet[1].name.biters local ore_size = planet[1].ore_richness.factor + local handicap = 0 + if global.objective.chronojumps < 5 then handicap = 150 end if scrapyard < -0.75 or scrapyard > 0.75 then - if math_random(1,52 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 200 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + + if math_random(1,52 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 + handicap then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end end if scrapyard > -0.05 - 0.01 * ore_size and scrapyard < 0.05 + 0.01 * ore_size then if math_random(1,20) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end end - if scrapyard + 0.5 > -0.05 - 0.1 * planet[1].name.moisture and scrapyard + 0.5 < 0.05 + 0.1 * planet[1].name.moisture then - if math_random(1,100) > 42 then entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} end + if scrapyard + 0.5 > -0.1 - 0.1 * planet[1].name.moisture and scrapyard + 0.5 < 0.1 + 0.1 * planet[1].name.moisture then + local treetypes = tree_raffle[math_random(1, s_tree_raffle)] + if planet[1].name.name == "lava planet" then treetypes = dead_tree_raffle[math_random(1, 5)] end + if math_random(1,100) > 42 - handicap / 6 then entities[#entities + 1] = {name = treetypes , position = p} end end if scrapyard > -0.10 and scrapyard < 0.10 then @@ -282,11 +287,13 @@ local function process_biter_position(p, seed, tiles, entities, treasure, planet local jumps = global.objective.chronojumps * 5 if global.objective.chronojumps > 20 then jumps = 100 end local roll = math_random(1,200 - jumps - biters) - if math_sqrt(p.x * p.x + p.y * p.y) > 300 then + if math_sqrt(p.x * p.x + p.y * p.y) > 200 + handicap then if roll == 1 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} elseif roll == 2 then entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p} + elseif roll == 3 then + --if math_random(1, 1024) == 1 then treasure[#treasure + 1] = p end end return end @@ -318,7 +325,7 @@ local function process_scrapyard_position(p, seed, tiles, entities, treasure, pl end tiles[#tiles + 1] = {name = "dirt-7", position = p} if scrapyard < -0.55 or scrapyard > 0.55 then - if math_random(1,40) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 100 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + if math_random(1,40) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end return end if scrapyard + 0.5 > -0.05 - 0.1 * planet[1].name.moisture and scrapyard + 0.5 < 0.05 + 0.1 * planet[1].name.moisture then @@ -349,7 +356,7 @@ local function process_scrapyard_position(p, seed, tiles, entities, treasure, pl tiles[#tiles + 1] = {name = "dirt-7", position = p} local jumps = global.objective.chronojumps * 5 if global.objective.chronojumps > 20 then jumps = 100 end - if math_random(1,200 - jumps) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 100 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + if math_random(1,200 - jumps) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end return end end @@ -445,6 +452,11 @@ local function biter_chunk(surface, left_top, level, planet) process_level(p, seed, tiles, entities, treasure, planet) end end + for _, p in pairs(treasure) do + local name = "wooden-chest" + if math_random(1, 6) == 1 then name = "iron-chest" end + Treasure(surface, p, name) + end surface.set_tiles(tiles, true) for _, entity in pairs(entities) do if surface.can_place_entity(entity) then @@ -547,9 +559,11 @@ local function process_chunk(surface, left_top) elseif planet[1].name.name == "rocky planet" then if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 4, planet) return end if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 4, planet) return end - -- elseif planet[1].name.name == "lava planet" then - -- if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 4, planet) return end - -- if math_abs(left_top.y) > 31 and math_abs(left_top.x) > 31 then empty_chunk(surface, left_top, 4, planet) return end + elseif planet[1].name.name == "lava planet" then + if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 7, planet) end + if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then biter_chunk(surface, left_top, 7, planet) end + replace_water(surface, left_top) + return else if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 7, planet) return end if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then biter_chunk(surface, left_top, 7, planet) return end diff --git a/maps/chronosphere/treasure.lua b/maps/chronosphere/treasure.lua index 977ba423..41717c2e 100644 --- a/maps/chronosphere/treasure.lua +++ b/maps/chronosphere/treasure.lua @@ -160,7 +160,7 @@ function Public.treasure_chest(surface, position, container_name) } local jumps = 0 if global.objective.chronojumps then jumps = global.objective.chronojumps end - local distance_to_center = math_sqrt(position.y * position.y + position.x * position.x) * (1 + jumps / 50) * 0.0002 + local distance_to_center = (jumps / 50) if distance_to_center > 1 then distance_to_center = 1 end for _, t in pairs (chest_loot) do From 48df91db17d6a39ed08de98604c4553784d3c514 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Mon, 17 Feb 2020 00:47:38 +0100 Subject: [PATCH 09/70] locale update --- locale/en/locale.cfg | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index 966df56c..ad2192fa 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -52,6 +52,17 @@ map_info_main_caption=M O U N T A I N F O R T R E S S map_info_sub_caption= ..diggy diggy choo choo.. map_info_text=The biters have catched the scent of fish in the cargo wagon.\nGuide the choo into the mountain and protect it as long as possible!\nThis however will not be an easy task,\nsince their strength and numbers increase over time.\n\nIn additon, the southern grounds collapse over time.\nStone bricks, concrete or other solid tiles, might improve the stability of the floor.\n\nDelve deep for greater treasures, but also face increased dangers.\nMining productivity research, will overhaul your mining equipment,\nreinforcing your pickaxe as well as increasing the size of your backpack.\n\nAs you dig, you will encounter impassable dark chasms or rivers.\nSome explosives may cause parts of the ceiling to crumble, filling the void, creating new ways.\nAll they need is a container and a well aimed shot.\n\nYou may find some supply goods, if you enter the wagon.\nGood luck on your journey! +[chronosphere] +map_info_main_caption=Chronosphere +map_info_sub_caption= ..Comfylatron gone wild.. +map_info_text_old=Comfylatron has seized The Fish Train and turned it into a time machine.\nIt is your job to make sure the cargo is safe throughout the times and places we travel through!\nThis however will not be an easy task,\nas Comfylatron does not have any idea how to control this machine at all.\n\nThe destinations of quantum time jumps are completely random, and the machine always needs time to recharge.\nYou can speed it up greatly by charging acumulators in Locomotive.\nSo be sure to grab as many resources as you can before the train jump away!\nComfylatron manages to run teleporting devices to transport items into train from his chests. Also to save people from staying in wrong universe.\n\nOnce a quantum jump is initiated, be sure to have everything packed up, there is nearly zero chance to revisit that place again!\nMining productivity research will overhaul your mining equipment,\nreinforcing your pickaxes, as well as increasing the size of your backpack.\nGood luck on your journey! +map_info_text=Comfylatron has seized the Fish Train and turned it into a time machine.\n Your job as his slave is:\n\n[1] Keep train alive at all costs\n[2] Gather resources while travelling through different maps.\n[3a] Press enter on cargo wagons to enter insides of train.\n[3b] Press enter on cars to exit the train.\n[4] Charging acumulators inside train speeds up jumps when leaving early is needed.\n[5] Items inserted into comfylatron chests get teleported into train.\n[6] Some planets are poor, some are rich, and some are just too dangerous.\n\n Loot, but also evolution grows with jumps performed.\n During jump, personnel will be teleported in,\n however dead bodies nor buildings won't.\nMining productivity grants inventory space and handmining speed.\n\nGood luck. Don't let biters ruin the show! +gui_1=ChronoJumps: +gui_2=Charge: +gui_3=Timer: +gui_3_1=Best Case Timer: +gui_4=Local Evolution: + [rocks_yield_ore_veins] coal=coal iron-ore=iron @@ -80,4 +91,4 @@ gui_1=First wave in gui_2=Wave: gui_3=Threat: tooltip_1=high threat may empower biters -tooltip_2=gain / minute \ No newline at end of file +tooltip_2=gain / minute From e0cf887347ae145504a3df6f1aaad1fe20912d6b Mon Sep 17 00:00:00 2001 From: hanakocz Date: Mon, 17 Feb 2020 17:37:22 +0100 Subject: [PATCH 10/70] new stuff, fixes --- maps/chronosphere/ai.lua | 8 +- maps/chronosphere/comfylatron.lua | 26 ++++-- maps/chronosphere/gui.lua | 12 +-- maps/chronosphere/locomotive.lua | 9 +- maps/chronosphere/main.lua | 139 +++++++++++++++++------------- maps/chronosphere/terrain.lua | 8 +- maps/chronosphere/treasure.lua | 6 +- 7 files changed, 124 insertions(+), 84 deletions(-) diff --git a/maps/chronosphere/ai.lua b/maps/chronosphere/ai.lua index 011fc87e..94a83205 100644 --- a/maps/chronosphere/ai.lua +++ b/maps/chronosphere/ai.lua @@ -190,8 +190,8 @@ Public.send_near_biters_to_objective = function() local surface = random_target.surface local pollution = surface.get_pollution(random_target.position) local success = false - if pollution > 300 then - surface.pollute(random_target.position, -100) + if pollution > 200 then + surface.pollute(random_target.position, -50) --game.print("sending objective wave") success = true else @@ -268,8 +268,8 @@ local function send_group(unit_group, nearest_player_unit) local target = targets[math_random(1, #targets)] local surface = target.surface local pollution = surface.get_pollution(target.position) - if pollution > 300 then - surface.pollute(target.position, -100) + if pollution > 200 then + surface.pollute(target.position, -50) --game.print("sending unit group attack") local commands = {} diff --git a/maps/chronosphere/comfylatron.lua b/maps/chronosphere/comfylatron.lua index d9d09f50..1c6e6a06 100644 --- a/maps/chronosphere/comfylatron.lua +++ b/maps/chronosphere/comfylatron.lua @@ -209,10 +209,10 @@ local function talks(nearby_characters) return true end -local function desync() +local function desync(event) if global.comfybubble then global.comfybubble.destroy() end - local m = 12 - local m2 = m * 0.005 + --local m = 12 + --local m2 = m * 0.005 -- for i = 1, 32, 1 do -- global.comfylatron.surface.create_entity({ -- name = "iron-ore-particle", @@ -223,10 +223,20 @@ local function desync() -- movement = {m2 - (math.random(0, m) * 0.01), m2 - (math.random(0, m) * 0.01)} -- }) -- end - global.comfylatron.surface.create_entity({name = "medium-explosion", position = global.comfylatron.position}) - global.comfylatron.surface.create_entity({name = "flying-text", position = global.comfylatron.position, text = "desync", color = {r = 150, g = 0, b = 0}}) - global.comfylatron.destroy() - global.comfylatron = nil + if math_random(1,4) == 1 then + global.comfylatron.surface.create_entity({name = "medium-explosion", position = global.comfylatron.position}) + global.comfylatron.surface.create_entity({name = "flying-text", position = global.comfylatron.position, text = "desync", color = {r = 150, g = 0, b = 0}}) + global.comfylatron.destroy() + global.comfylatron = nil + else + global.comfylatron.surface.create_entity({name = "flying-text", position = global.comfylatron.position, text = "desync evaded", color = {r = 0, g = 150, b = 0}}) + if event.cause then + if event.cause.valid and event.cause.player then + game.print("Comfylatron: I got you this time! Back to work, " .. event.cause.player.name .. "!", {r = 200, g = 0, b = 0}) + event.cause.die("player", global.comfylatron) + end + end + end end local function alone() @@ -391,7 +401,7 @@ local function on_entity_damaged(event) if not global.comfylatron then return end if not event.entity.valid then return end if event.entity ~= global.comfylatron then return end - desync() + desync(event) end local function on_tick() diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index 78310bb8..b1772e98 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -123,12 +123,12 @@ local function update_gui(player) [5] = {c = "--\n"} } local upgt = { - [1] = {t = "[1]: + 5000 Train Max HP. Current: " .. objective.max_health .. "\n Cost : 2500 coins + 3000 copper plates\n"}, - [2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%,\n Cost: 4000 coins + 1000 green circuits\n"}, + [1] = {t = "[1]: + 5000 Train Max HP. Current: " .. objective.max_health .. "\n Cost : " .. math_floor(2500 * (1 + objective.hpupgradetier /4)) .. " coins + 3000 copper plates\n"}, + [2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%\n Buyable once per 3 jumps.\n Cost: 5000 coins + 2000 green circuits\n"}, [3] = {t = "[3]: Add additional row of Acumulators.\n Cost: 2500 coins + 200 batteries\n"}, - [4] = {t = "[4]: Add item pickup distance to players.Current: +" .. objective.pickupupgradetier .. ",\n Cost: 1000 coins + 400 red inserters\n"}, - [5] = {t = "[5]: Add +5 inventory slots. Buyable once per 5 jumps.\n Cost: 2000 coins + " .. chests[objective.invupgradetier + 1].c}, - [6] = {t = "[6]: Use up more repair tools on train at once. Current: +" .. objective.toolsupgradetier .. "\n Cost: 1000 coins + 200 repair tools\n"}, + [4] = {t = "[4]: Add item pickup distance to players.Current: +" .. objective.pickupupgradetier .. ",\n Cost: " .. 1000 * (1 + objective.pickupupgradetier) .. " coins + 400 red inserters\n"}, + [5] = {t = "[5]: Add +5 inventory slots. Buyable once per 5 jumps.\n Cost: " .. 2000 * (1 + objective.invupgradetier) .." coins + " .. chests[objective.invupgradetier + 1].c}, + [6] = {t = "[6]: Use up more repair tools on train at once. Current: +" .. objective.toolsupgradetier .. "\n Cost: " .. 1000 * (1 + objective.toolsupgradetier) .. " coins + " .. 200 * (1 + objective.toolsupgradetier) .. " repair tools\n"}, [7] = {t = "[7]: Add piping through wagon sides to create water sources for each wagon.\n Cost: 2000 coins + 500 pipes\n"}, [8] = {t = "[8]: Add comfylatron chests that output outside (into cargo wagon 2 and 3)\n Cost: 2000 coins + 100 fast inserters\n"}, [9] = {t = "[9]: Add storage chests to the sides of wagons.\n Buyable once per 5 jumps.\n Cost: 5000 coins + " .. chests[objective.boxupgradetier + 1].c} @@ -141,7 +141,7 @@ local function update_gui(player) [5] = {t = "[5]: Inventory maxed. Research Mining Productivity for more.\n"}, [6] = {t = "[6]: Repairing at top speed of 5 packs.\n"}, [7] = {t = "[7]: Piping created. Don't spill it!\n"}, - [8] = {t = "[8]: Chests created.\n"}, + [8] = {t = "[8]: Output chests created.\n"}, [9] = {t = "[9]: Storage chests fully upgraded.\n"} } local tooltip = "Insert needed items into chest with upgrade number.\nUpgrading can take a minute.\n\n" diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index 9875ec36..3ec4c224 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -173,7 +173,14 @@ local function create_wagon_room() surface.daytime = 0.1 surface.request_to_generate_chunks({0,0}, 12) surface.force_generate_chunk_requests() - + local carfpos = { + [1]={x=-33,y=-127},[2]={x=-33,y=-128},[3]={x=-33,y=-129},[4]={x=-33,y=-130},[5]={x=32,y=-127},[6]={x=32,y=-128},[7]={x=32,y=-129},[8]={x=32,y=-130}, + [9]={x=-33,y=-2},[10]={x=-33,y=-1},[11]={x=-33,y=0},[12]={x=-33,y=1},[13]={x=32,y=-2},[14]={x=32,y=-1},[15]={x=32,y=0},[16]={x=32,y=1}, + [17]={x=-33,y=126},[18]={x=-33,y=127},[19]={x=-33,y=128},[20]={x=-33,y=129},[21]={x=32,y=126},[22]={x=32,y=127},[23]={x=32,y=128},[24]={x=32,y=129} + } + for i = 1, 24, 1 do + surface.set_tiles({{name = "tutorial-grid", position = {carfpos[i].x,carfpos[i].y}}}) + end for x = width * -0.5, width * 0.5 - 1, 1 do for y = height * 0.5, height * 0.7, 1 do surface.set_tiles({{name = "out-of-map", position = {x,y}}}) diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 354927c7..1e4ea05a 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -14,6 +14,7 @@ require "maps.chronosphere.chronobubles" require "maps.chronosphere.ores" require "on_tick_schedule" require "modules.biter_noms_you" +local Server = require 'utils.server' local Ai = require "maps.chronosphere.ai" local unearthing_worm = require "functions.unearthing_worm" local unearthing_biters = require "functions.unearthing_biters" @@ -49,7 +50,9 @@ function generate_overworld(surface, optplanet) local planet = nil if not optplanet then planet = chronobuble.determine_planet(nil) - game.print("Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name, {r=0.98, g=0.66, b=0.22}) + local message = "Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name + game.print(message, {r=0.98, g=0.66, b=0.22}) + Server.to_discord_embed(message) global.objective.planet = planet else planet = optplanet @@ -200,16 +203,24 @@ function Public.reset_map() - game.difficulty_settings.technology_price_multiplier = 0.5 - game.map_settings.enemy_evolution.destroy_factor = 0.001 + game.difficulty_settings.technology_price_multiplier = 0.6 + game.map_settings.enemy_evolution.destroy_factor = 0.006 game.map_settings.enemy_evolution.pollution_factor = 0 - game.map_settings.enemy_evolution.time_factor = 4e-05 + game.map_settings.enemy_evolution.time_factor = 8e-05 game.map_settings.enemy_expansion.enabled = true game.map_settings.enemy_expansion.max_expansion_cooldown = 3600 game.map_settings.enemy_expansion.min_expansion_cooldown = 3600 game.map_settings.enemy_expansion.settler_group_max_size = 8 game.map_settings.enemy_expansion.settler_group_min_size = 16 game.map_settings.pollution.enabled = true + game.map_settings.pollution.pollution_restored_per_tree_damage = 0.1 + game.map_settings.pollution.min_pollution_to_damage_trees = 1 + game.map_settings.pollution.max_pollution_to_restore_trees = 0 + game.map_settings.pollution.pollution_with_max_forest_damage = 10 + game.map_settings.pollution.pollution_per_tree_damage = 0.5 + game.map_settings.pollution.ageing = 0 + game.map_settings.pollution.diffusion_ratio = 0.1 + game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.5 game.forces.player.technologies["land-mine"].enabled = false game.forces.player.technologies["landfill"].enabled = false @@ -299,8 +310,9 @@ local function check_upgrades() local inv = global.hpchest.get_inventory(defines.inventory.chest) local countcoins = inv.get_item_count("coin") local count2 = inv.get_item_count("copper-plate") - if countcoins >= 2500 and count2 >= 3000 and objective.hpupgradetier < 18 then - inv.remove({name = "coin", count = 2500}) + local coincost = math_floor(2500 * (1 + objective.hpupgradetier /4)) + if countcoins >= coincost and count2 >= 3000 and objective.hpupgradetier < 18 then + inv.remove({name = "coin", count = coincost}) inv.remove({name = "copper-plate", count = 3000}) game.print("Comfylatron: Train's max HP was upgraded.", {r=0.98, g=0.66, b=0.22}) objective.hpupgradetier = objective.hpupgradetier + 1 @@ -312,9 +324,9 @@ local function check_upgrades() local inv = global.filterchest.get_inventory(defines.inventory.chest) local countcoins = inv.get_item_count("coin") local count2 = inv.get_item_count("electronic-circuit") - if countcoins >= 4000 and count2 >= 1000 and objective.filterupgradetier < 9 then - inv.remove({name = "coin", count = 4000}) - inv.remove({name = "electronic-circuit", count = 1000}) + if countcoins >= 5000 and count2 >= 2000 and objective.filterupgradetier < 9 and objective.chronojumps >= (objective.filterupgradetier + 1) * 3 then + inv.remove({name = "coin", count = 5000}) + inv.remove({name = "electronic-circuit", count = 2000}) game.print("Comfylatron: Train's pollution filter was upgraded.", {r=0.98, g=0.66, b=0.22}) objective.filterupgradetier = objective.filterupgradetier + 1 end @@ -335,12 +347,13 @@ local function check_upgrades() local inv = global.playerchest.get_inventory(defines.inventory.chest) local countcoins = inv.get_item_count("coin") local count2 = inv.get_item_count("long-handed-inserter") - if countcoins >= 1000 and count2 >= 400 and objective.pickupupgradetier < 4 then - inv.remove({name = "coin", count = 1000}) + local coincost = 1000 * (1 + objective.pickupupgradetier) + if countcoins >= coincost and count2 >= 400 and objective.pickupupgradetier < 4 then + inv.remove({name = "coin", count = coincost}) inv.remove({name = "long-handed-inserter", count = 400}) game.print("Comfylatron: Players now have additional red inserter installed on shoulders, increasing their item pickup range.", {r=0.98, g=0.66, b=0.22}) objective.pickupupgradetier = objective.pickupupgradetier + 1 - game.forces.player.character_item_pickup_distance_bonus = game.forces.player.character_item_pickup_distance_bonus + 1 + game.forces.player.character_loot_pickup_distance_bonus = game.forces.player.character_loot_pickup_distance_bonus + 1 end end if global.invchest and global.invchest.valid then @@ -357,8 +370,9 @@ local function check_upgrades() item = "logistic-chest-storage" end local count2 = inv.get_item_count(item) - if countcoins >= 2000 and count2 >= 250 and objective.invupgradetier < 4 and objective.chronojumps >= (objective.invupgradetier + 1) * 5 then - inv.remove({name = "coin", count = 2000}) + local coincost = 2000 * (1 + objective.invupgradetier) + if countcoins >= coincost and count2 >= 250 and objective.invupgradetier < 4 and objective.chronojumps >= (objective.invupgradetier + 1) * 5 then + inv.remove({name = "coin", count = coincost}) inv.remove({name = item, count = 250}) game.print("Comfylatron: Players now can carry more trash in their unsorted inventories.", {r=0.98, g=0.66, b=0.22}) objective.invupgradetier = objective.invupgradetier + 1 @@ -370,9 +384,11 @@ local function check_upgrades() local inv = global.toolschest.get_inventory(defines.inventory.chest) local countcoins = inv.get_item_count("coin") local count2 = inv.get_item_count("repair-pack") - if countcoins >= 1000 and count2 >= 200 and objective.toolsupgradetier < 4 then - inv.remove({name = "coin", count = 1000}) - inv.remove({name = "repair-pack", count = 200}) + local coincost = 1000 * (1 + objective.toolsupgradetier) + local toolscost = 200 * (1 + objective.toolsupgradetier) + if countcoins >= coincost and count2 >= toolscost and objective.toolsupgradetier < 4 then + inv.remove({name = "coin", count = coincost}) + inv.remove({name = "repair-pack", count = toolscost}) game.print("Comfylatron: Train now gets repaired with additional repair kit at once.", {r=0.98, g=0.66, b=0.22}) objective.toolsupgradetier = objective.toolsupgradetier + 1 end @@ -459,14 +475,14 @@ local function check_upgrades() chests[#chests + 1] = {name="wooden-chest", position= {-33 ,-189 + i}, force = "player"} chests[#chests + 1] = {name="wooden-chest", position= {32 ,-189 + i}, force = "player"} elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {name="iron-chest", position= {-33 ,-189 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="iron-chest", position= {32 ,-189 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="iron-chest", position= {-33 ,-189 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="iron-chest", position= {32 ,-189 + i}, force = "player", fast_replace = true} elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {name="steel-chest", position= {-33 ,-189 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="steel-chest", position= {32 ,-189 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="steel-chest", position= {-33 ,-189 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="steel-chest", position= {32 ,-189 + i}, force = "player", fast_replace = true} elseif objective.boxupgradetier == 4 then - chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,-189 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,-189 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,-189 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,-189 + i}, force = "player", fast_replace = true} end end for i = 1, 58, 1 do @@ -474,14 +490,14 @@ local function check_upgrades() chests[#chests + 1] = {name="wooden-chest", position= {-33 ,-127 + i}, force = "player"} chests[#chests + 1] = {name="wooden-chest", position= {32 ,-127 + i}, force = "player"} elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {name="iron-chest", position= {-33 ,-127 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="iron-chest", position= {32 ,-127 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="iron-chest", position= {-33 ,-127 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="iron-chest", position= {32 ,-127 + i}, force = "player", fast_replace = true} elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {name="steel-chest", position= {-33 ,-127 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="steel-chest", position= {32 ,-127 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="steel-chest", position= {-33 ,-127 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="steel-chest", position= {32 ,-127 + i}, force = "player", fast_replace = true} elseif objective.boxupgradetier == 4 then - chests[#chests + 1] ={name="logistic-chest-storage", position= {-33 ,-127 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] ={name="logistic-chest-storage", position= {32 ,-127 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] ={name="logistic-chest-storage", position= {-33 ,-127 + i}, force = "player", fast_replace = true} + chests[#chests + 1] ={name="logistic-chest-storage", position= {32 ,-127 + i}, force = "player", fast_replace = true} end end for i = 1, 58, 1 do @@ -489,14 +505,14 @@ local function check_upgrades() chests[#chests + 1] = {name="wooden-chest", position= {-33 ,-61 + i}, force = "player"} chests[#chests + 1] = {name="wooden-chest", position= {32 ,-61 + i}, force = "player"} elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {name="iron-chest", position= {-33 ,-61 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="iron-chest", position= {32 ,-61 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="iron-chest", position= {-33 ,-61 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="iron-chest", position= {32 ,-61 + i}, force = "player", fast_replace = true} elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {name="steel-chest", position= {-33 ,-61 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="steel-chest", position= {32 ,-61 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="steel-chest", position= {-33 ,-61 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="steel-chest", position= {32 ,-61 + i}, force = "player", fast_replace = true} elseif objective.boxupgradetier == 4 then - chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,-61 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,-61 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,-61 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,-61 + i}, force = "player", fast_replace = true} end end for i = 1, 58, 1 do @@ -504,14 +520,14 @@ local function check_upgrades() chests[#chests + 1] = {name="wooden-chest", position= {-33 ,1 + i}, force = "player"} chests[#chests + 1] = {name="wooden-chest", position= {32 ,1 + i}, force = "player"} elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {name="iron-chest", position= {-33 ,1 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="iron-chest", position= {32 ,1 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="iron-chest", position= {-33 ,1 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="iron-chest", position= {32 ,1 + i}, force = "player", fast_replace = true} elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {name="steel-chest", position= {-33 ,1 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="steel-chest", position= {32 ,1 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="steel-chest", position= {-33 ,1 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="steel-chest", position= {32 ,1 + i}, force = "player", fast_replace = true} elseif objective.boxupgradetier == 4 then - chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,1 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,1 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,1 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,1 + i}, force = "player", fast_replace = true} end end for i = 1, 58, 1 do @@ -519,14 +535,14 @@ local function check_upgrades() chests[#chests + 1] = {name="wooden-chest", position= {-33 ,67 + i}, force = "player"} chests[#chests + 1] = {name="wooden-chest", position= {32 ,67 + i}, force = "player"} elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {name="iron-chest", position= {-33 ,67 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="iron-chest", position= {32 ,67 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="iron-chest", position= {-33 ,67 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="iron-chest", position= {32 ,67 + i}, force = "player", fast_replace = true} elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {name="steel-chest", position= {-33 ,67 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="steel-chest", position= {32 ,67 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="steel-chest", position= {-33 ,67 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="steel-chest", position= {32 ,67 + i}, force = "player", fast_replace = true} elseif objective.boxupgradetier == 4 then - chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,67 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,67 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,67 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,67 + i}, force = "player", fast_replace = true} end end for i = 1, 58, 1 do @@ -534,14 +550,14 @@ local function check_upgrades() chests[#chests + 1] = {name="wooden-chest", position= {-33 ,129 + i}, force = "player"} chests[#chests + 1] = {name="wooden-chest", position= {32 ,129 + i}, force = "player"} elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {name="iron-chest", position= {-33 ,129 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="iron-chest", position= {32 ,129 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="iron-chest", position= {-33 ,129 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="iron-chest", position= {32 ,129 + i}, force = "player", fast_replace = true} elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {name="steel-chest", position= {-33 ,129 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="steel-chest", position= {32 ,129 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="steel-chest", position= {-33 ,129 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="steel-chest", position= {32 ,129 + i}, force = "player", fast_replace = true} elseif objective.boxupgradetier == 4 then - chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,129 + i}, force = "player", fast_replace = true, player = "Hanakocz"} - chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,129 + i}, force = "player", fast_replace = true, player = "Hanakocz"} + chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,129 + i}, force = "player", fast_replace = true} + chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,129 + i}, force = "player", fast_replace = true} end end local surface = game.surfaces["cargo_wagon"] @@ -646,8 +662,10 @@ function chronojump(choice) local planet = nil if choice then planet = chronobuble.determine_planet(choice) - game.print("Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name, {r=0.98, g=0.66, b=0.22}) + local message = "Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name + game.print(message, {r=0.98, g=0.66, b=0.22}) global.objective.planet = planet + Server.to_discord_embed(message) end generate_overworld(surface, planet) game.forces.player.set_spawn_position({12, 10}, surface) @@ -661,7 +679,10 @@ function chronojump(choice) else game.forces["enemy"].evolution_factor = 1 end - game.map_settings.enemy_evolution.time_factor = 4e-05 + 2e-06 * objective.chronojumps + game.map_settings.enemy_evolution.time_factor = 8e-05 + 4e-06 * objective.chronojumps + surface.pollute(global.locomotive.position, 200 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps)) + game.forces.scrapyard.set_ammo_damage_modifier("bullet", objective.chronojumps / 20) + game.forces.scrapyard.set_turret_attack_modifier("gun-turret", objective.chronojumps / 20) end local function check_chronoprogress() @@ -690,10 +711,10 @@ local function charge_chronosphere() for i = 1, #acus, 1 do if not acus[i].valid then return end local energy = acus[i].energy - if energy > 3000000 and objective.chronotimer < objective.chrononeeds - 62 and objective.chronotimer > 130 then + if energy > 3000000 and objective.chronotimer < objective.chrononeeds - 182 and objective.chronotimer > 130 then acus[i].energy = acus[i].energy - 3000000 objective.chronotimer = objective.chronotimer + 1 - game.surfaces[global.active_surface_index].pollute(global.locomotive.position, 100 * (4 / (objective.filterupgradetier / 2 + 1))) + game.surfaces[global.active_surface_index].pollute(global.locomotive.position, 200 * (4 / (objective.filterupgradetier / 2 + 1))) --log("energy charged from acu") end end @@ -770,7 +791,9 @@ local function on_init() T.main_caption_color = {r = 150, g = 150, b = 0} T.sub_caption_color = {r = 0, g = 150, b = 0} global.objective.game_lost = true - + game.create_force("scrapyard") + game.forces.scrapyard.set_friend('enemy', true) + game.forces.enemy.set_friend('scrapyard', true) --global.rocks_yield_ore_maximum_amount = 999 --global.rocks_yield_ore_base_amount = 50 --global.rocks_yield_ore_distance_modifier = 0.025 diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index 05fb656b..9f7a45fd 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -321,7 +321,7 @@ local function process_scrapyard_position(p, seed, tiles, entities, treasure, pl if scrapyard < -0.25 or scrapyard > 0.25 then if math_random(1, 256) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 50 then - entities[#entities + 1] = {name="gun-turret", position=p, force = "enemy"} + entities[#entities + 1] = {name="gun-turret", position=p, force = "scrapyard"} end tiles[#tiles + 1] = {name = "dirt-7", position = p} if scrapyard < -0.55 or scrapyard > 0.55 then @@ -432,7 +432,7 @@ local function forest_chunk(surface, left_top, level, planet) for _, entity in pairs(entities) do if surface.can_place_entity(entity) then local e = surface.create_entity(entity) - if e.name == "biter-spawner" or e.name == "spitter-spawner" then + if e.name == "biter-spawner" or e.name == "spitter-spawner" or e.name == "small-worm-turret" or e.name == "medium-worm-turret" or e.name == "big-worm-turret" or e.name == "behemoth-worm-turret" then if math_abs(e.position.x) > 420 or math_abs(e.position.y) > 420 then e.destructible = false end end end @@ -461,7 +461,7 @@ local function biter_chunk(surface, left_top, level, planet) for _, entity in pairs(entities) do if surface.can_place_entity(entity) then local e = surface.create_entity(entity) - if e.name == "biter-spawner" or e.name == "spitter-spawner" then + if e.name == "biter-spawner" or e.name == "spitter-spawner" or e.name == "small-worm-turret" or e.name == "medium-worm-turret" or e.name == "big-worm-turret" or e.name == "behemoth-worm-turret" then if math_abs(e.position.x) > 420 or math_abs(e.position.y) > 420 then e.destructible = false end end end @@ -525,7 +525,7 @@ local function normal_chunk(surface, left_top, level, planet) else if surface.can_place_entity(entity) then local e = surface.create_entity(entity) - if e.name == "biter-spawner" or e.name == "spitter-spawner" then + if e.name == "biter-spawner" or e.name == "spitter-spawner" or e.name == "small-worm-turret" or e.name == "medium-worm-turret" or e.name == "big-worm-turret" or e.name == "behemoth-worm-turret" then if math_abs(e.position.x) > 420 or math_abs(e.position.y) > 420 then e.destructible = false end end end diff --git a/maps/chronosphere/treasure.lua b/maps/chronosphere/treasure.lua index 41717c2e..d3552949 100644 --- a/maps/chronosphere/treasure.lua +++ b/maps/chronosphere/treasure.lua @@ -119,8 +119,8 @@ function Public.treasure_chest(surface, position, container_name) {{name = "decider-combinator", count = math_random(4,8)}, weight = 2, d_min = 0.1, d_max = 1}, {{name = "power-switch", count = 1}, weight = 2, d_min = 0.1, d_max = 1}, {{name = "programmable-speaker", count = math_random(2,4)}, weight = 1, d_min = 0.1, d_max = 1}, - {{name = "green-wire", count = math_random(50,99)}, weight = 4, d_min = 0.1, d_max = 1}, - {{name = "red-wire", count = math_random(50,99)}, weight = 4, d_min = 0.1, d_max = 1}, + {{name = "green-wire", count = math_random(10,29)}, weight = 4, d_min = 0.1, d_max = 1}, + {{name = "red-wire", count = math_random(10,29)}, weight = 4, d_min = 0.1, d_max = 1}, {{name = "chemical-plant", count = math_random(1,3)}, weight = 3, d_min = 0.3, d_max = 1}, {{name = "burner-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.0, d_max = 0.2}, {{name = "electric-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.2, d_max = 1}, @@ -160,7 +160,7 @@ function Public.treasure_chest(surface, position, container_name) } local jumps = 0 if global.objective.chronojumps then jumps = global.objective.chronojumps end - local distance_to_center = (jumps / 50) + local distance_to_center = (jumps / 50) if distance_to_center > 1 then distance_to_center = 1 end for _, t in pairs (chest_loot) do From 2543abbc72c3cf8f616223ec225aaafc893d5d5b Mon Sep 17 00:00:00 2001 From: hanakocz Date: Tue, 18 Feb 2020 02:43:22 +0100 Subject: [PATCH 11/70] updates --- maps/chronosphere/ai.lua | 1 + maps/chronosphere/chronobubles.lua | 22 +- maps/chronosphere/gui.lua | 4 +- maps/chronosphere/locomotive.lua | 82 +----- maps/chronosphere/main.lua | 431 ++++++----------------------- maps/chronosphere/ores.lua | 37 +-- maps/chronosphere/terrain.lua | 2 - maps/chronosphere/upgrades.lua | 287 +++++++++++++++++++ 8 files changed, 396 insertions(+), 470 deletions(-) create mode 100644 maps/chronosphere/upgrades.lua diff --git a/maps/chronosphere/ai.lua b/maps/chronosphere/ai.lua index 94a83205..db9a881a 100644 --- a/maps/chronosphere/ai.lua +++ b/maps/chronosphere/ai.lua @@ -187,6 +187,7 @@ Public.send_near_biters_to_objective = function() if not global.locomotive_cargo3 then return end local targets = {global.locomotive, global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} local random_target = targets[math_random(1, #targets)] + if random_target.valid then return end local surface = random_target.surface local pollution = surface.get_pollution(random_target.position) local success = false diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua index db5c2d58..a307088f 100644 --- a/maps/chronosphere/chronobubles.lua +++ b/maps/chronosphere/chronobubles.lua @@ -17,7 +17,7 @@ local variants = { [12] = {id = 12, name = "choppy planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 1, biters = 6, moisture = 0.4, chance = 2, cumul_chance = 21}, [13] = {id = 13, name = "river planet", iron = 1, copper = 1, coal = 3, stone = 1, uranium = 0, oil = 0, biters = 8, moisture = 0.5, chance = 2, cumul_chance = 23}, [14] = {id = 14, name = "lava planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 6, moisture = -0.5, chance = 1, cumul_chance = 24}, - [15] = {id = 15, name = "start planet", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24}, + [15] = {id = 15, name = "start planet", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24} } @@ -58,24 +58,28 @@ end function Public.determine_planet(choice) local weight = variants[#variants].cumul_chance local planet_choice = nil + local ores = math_random(1, #richness) + if global.objective.game_lost then + choice = 15 + ores = 2 + end if not choice then planet_choice = roll(weight) else - planet_choice = variants[choice] + if variants[choice] then + planet_choice = variants[choice] + else + planet_choice = roll(weight) + end end local planet = { [1] = { name = planet_choice, day_speed = time_speed_variants[math_random(1, #time_speed_variants)], time = math_random(1,100) / 100, - ore_richness = richness[math_random(1, #richness)], + ore_richness = richness[ores], } } - if global.objective.game_lost then - planet[1].name = variants[15] - planet[1].ore_richness = richness[2] - end - return planet + global.objective.planet = planet end - return Public diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index b1772e98..c6ea22b9 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -123,9 +123,9 @@ local function update_gui(player) [5] = {c = "--\n"} } local upgt = { - [1] = {t = "[1]: + 5000 Train Max HP. Current: " .. objective.max_health .. "\n Cost : " .. math_floor(2500 * (1 + objective.hpupgradetier /4)) .. " coins + 3000 copper plates\n"}, + [1] = {t = "[1]: + 5000 Train Max HP. Current: " .. objective.max_health .. "\n Cost : " .. math_floor(2000 * (1 + objective.hpupgradetier /4)) .. " coins + 3000 copper plates\n"}, [2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%\n Buyable once per 3 jumps.\n Cost: 5000 coins + 2000 green circuits\n"}, - [3] = {t = "[3]: Add additional row of Acumulators.\n Cost: 2500 coins + 200 batteries\n"}, + [3] = {t = "[3]: Add additional row of Acumulators.\n Cost : " .. math_floor(2000 * (1 + objective.acuupgradetier /4)) .. " coins + 200 batteries\n"}, [4] = {t = "[4]: Add item pickup distance to players.Current: +" .. objective.pickupupgradetier .. ",\n Cost: " .. 1000 * (1 + objective.pickupupgradetier) .. " coins + 400 red inserters\n"}, [5] = {t = "[5]: Add +5 inventory slots. Buyable once per 5 jumps.\n Cost: " .. 2000 * (1 + objective.invupgradetier) .." coins + " .. chests[objective.invupgradetier + 1].c}, [6] = {t = "[6]: Use up more repair tools on train at once. Current: +" .. objective.toolsupgradetier .. "\n Cost: " .. 1000 * (1 + objective.toolsupgradetier) .. " coins + " .. 200 * (1 + objective.toolsupgradetier) .. " repair tools\n"}, diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index 3ec4c224..b2fd2f04 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -1,4 +1,3 @@ -require "maps.chronosphere.comfylatron" local Public = {} local math_floor = math.floor local math_random = math.random @@ -101,38 +100,6 @@ function Public.fish_tag() text = " " }) end ---[[ -local function accelerate() - if not global.locomotive then return end - if not global.locomotive.valid then return end - if global.locomotive.get_driver() then return end - global.locomotive_driver = global.locomotive.surface.create_entity({name = "character", position = global.locomotive.position, force = "player"}) - global.locomotive_driver.driving = true - global.locomotive_driver.riding_state = {acceleration = defines.riding.acceleration.accelerating, direction = defines.riding.direction.straight} -end - -local function remove_acceleration() - if not global.locomotive then return end - if not global.locomotive.valid then return end - if global.locomotive_driver then global.locomotive_driver.destroy() end - global.locomotive_driver = nil -end -]] -function spawn_acumulators() - local x = -28 - local y = -252 - local yy = global.objective.acuupgradetier * 2 - local surface = game.surfaces["cargo_wagon"] - if yy > 8 then yy = yy + 2 end - if yy > 26 then yy = yy + 2 end - if yy > 44 then yy = yy + 2 end - for i = 1, 27, 1 do - local acumulator = surface.create_entity({name = "accumulator", position = {x + 2 * i, y + yy}, force="player", create_build_effect_smoke = false}) - acumulator.minable = false - acumulator.destructible = false - table.insert(global.acumulators, acumulator) - end -end local market_offers = { {price = {{'coin', 10}}, offer = {type = 'give-item', item = "raw-fish"}}, @@ -433,21 +400,21 @@ local function create_wagon_room() for _, offer in pairs(market_offers) do market.add_market_item(offer) end --generate cars-- - for _, x in pairs({width * -0.5 -0.5, width * 0.5 + 0.5}) do + for _, x in pairs({width * -0.5 -1.4, width * 0.5 + 1.4}) do local e = surface.create_entity({name = "car", position = {x, 0}, force = "player", create_build_effect_smoke = false}) e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16}) e.destructible = false e.minable = false e.operable = false end - for _, x in pairs({width * -0.5 - 0.5, width * 0.5 + 0.5}) do + for _, x in pairs({width * -0.5 - 1.4, width * 0.5 + 1.4}) do local e = surface.create_entity({name = "car", position = {x, -128}, force = "player", create_build_effect_smoke = false}) e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16}) e.destructible = false e.minable = false e.operable = false end - for _, x in pairs({width * -0.5 - 0.5, width * 0.5 + 0.5}) do + for _, x in pairs({width * -0.5 - 1.4, width * 0.5 + 1.4}) do local e = surface.create_entity({name = "car", position = {x, 128}, force = "player", create_build_effect_smoke = false}) e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16}) e.destructible = false @@ -587,47 +554,10 @@ function Public.enter_cargo_wagon(player, vehicle) local x_vector = (vehicle.position.x / math.abs(vehicle.position.x)) * 2 local y_vector = vehicle.position.y / 16 local position = {global.locomotive_cargo2.position.x + x_vector, global.locomotive_cargo2.position.y + y_vector} - local position = surface.find_non_colliding_position("character", position, 128, 0.5) - if not position then return end - player.teleport(position, surface) + local position2 = surface.find_non_colliding_position("character", position, 128, 0.5) + if not position2 then return end + player.teleport(position2, surface) end end --- local function clear_offers(market) --- for i = 1, 256, 1 do --- local a = market.remove_market_item(1) --- if a == false then return end --- end --- end - --- function Public.refresh_offers(event) --- --- local market = event.entity or event.market --- if not market then return end --- if not market.valid then return end --- if market.name ~= "market" then return end --- if market ~= global.upgrademarket then return end --- clear_offers(market) --- setup_upgrade_shop(market) --- end - --- function Public.offer_purchased(event) --- local offer_index = event.offer_index --- if not market_offers2[offer_index] then return end --- local market = event.market --- if not market.name == "market" then return end --- --- market_offers2[offer_index]() --- --- count = event.count --- if count > 1 then --- local offers = market.get_market_items() --- local price = offers[offer_index].price[1].amount --- game.players[event.player_index].insert({name = "coin", count = price * (count - 1)}) --- end --- Public.refresh_offers(event) --- end - - - return Public diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 1e4ea05a..8519e4f0 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -10,8 +10,7 @@ require "modules.no_deconstruction_of_neutral_entities" require "modules.shotgun_buff" require "modules.mineable_wreckage_yields_scrap" require "maps.chronosphere.comfylatron" -require "maps.chronosphere.chronobubles" -require "maps.chronosphere.ores" +require "maps.chronosphere.terrain" require "on_tick_schedule" require "modules.biter_noms_you" local Server = require 'utils.server' @@ -19,10 +18,11 @@ local Ai = require "maps.chronosphere.ai" local unearthing_worm = require "functions.unearthing_worm" local unearthing_biters = require "functions.unearthing_biters" local tick_tack_trap = require "functions.tick_tack_trap" -local chronobuble = require "maps.chronosphere.chronobubles" -local level_depth = require "maps.chronosphere.terrain" +local Planets = require "maps.chronosphere.chronobubles" +local Ores =require "maps.chronosphere.ores" local Reset = require "functions.soft_reset" local Map = require "modules.map_info" +local Upgrades = require "maps.chronosphere.upgrades" local Locomotive = require "maps.chronosphere.locomotive" local Modifier = require "player_modifiers" local update_gui = require "maps.chronosphere.gui" @@ -30,10 +30,10 @@ local math_random = math.random local math_floor = math.floor local math_sqrt = math.sqrt local chests = {} -local Public = {} --local acus = {} global.objective = {} global.flame_boots = {} +global.comfylatron = nil local choppy_entity_yield = { ["tree-01"] = {"iron-ore"}, @@ -42,21 +42,15 @@ local choppy_entity_yield = { ["tree-08-brown"] = {"stone"} } - -local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['grenade'] = 1, ['raw-fish'] = 4, ['rail'] = 16, ['wood'] = 16} +local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 32, ['grenade'] = 4, ['raw-fish'] = 4, ['rail'] = 16, ['wood'] = 16} local starting_cargo = {['firearm-magazine'] = 16, ['iron-plate'] = 16, ['wood'] = 16, ['burner-mining-drill'] = 8} -function generate_overworld(surface, optplanet) - local planet = nil - if not optplanet then - planet = chronobuble.determine_planet(nil) - local message = "Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name - game.print(message, {r=0.98, g=0.66, b=0.22}) - Server.to_discord_embed(message) - global.objective.planet = planet - else - planet = optplanet - end +local function generate_overworld(surface, optplanet) + Planets.determine_planet(optplanet) + local planet = global.objective.planet + local message = "Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name + game.print(message, {r=0.98, g=0.66, b=0.22}) + Server.to_discord_embed(message) if planet[1].name.name == "choppy planet" then game.print("Comfylatron: OwO what are those strange trees?!? They have ore fruits! WTF!", {r=0.98, g=0.66, b=0.22}) elseif planet[1].name.name == "lava planet" then @@ -116,8 +110,8 @@ end local function get_map_gen_settings() local map_gen_settings = { ["seed"] = math_random(1, 1000000), - ["width"] = level_depth, - ["height"] = level_depth, + ["width"] = 960, + ["height"] = 960, ["water"] = 0.1, ["starting_area"] = 1, ["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0}, @@ -159,22 +153,19 @@ local function render_train_hp() end -function Public.reset_map() +local function reset_map() global.chunk_queue = {} if game.surfaces["chronosphere"] then game.delete_surface(game.surfaces["chronosphere"]) end if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end chests = {} local map_gen_settings = get_map_gen_settings() - local planet = nil + Planets.determine_planet(nil) + local planet = global.objective.planet if not global.active_surface_index then global.active_surface_index = game.create_surface("chronosphere", map_gen_settings).index else - planet = chronobuble.determine_planet(nil) - - global.objective.planet = planet game.forces.player.set_spawn_position({12, 10}, game.surfaces[global.active_surface_index]) global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], map_gen_settings, starting_items).index - game.print("Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name, {r=0.98, g=0.66, b=0.22}) end local surface = game.surfaces[global.active_surface_index] @@ -204,9 +195,9 @@ function Public.reset_map() game.difficulty_settings.technology_price_multiplier = 0.6 - game.map_settings.enemy_evolution.destroy_factor = 0.006 + game.map_settings.enemy_evolution.destroy_factor = 0.005 game.map_settings.enemy_evolution.pollution_factor = 0 - game.map_settings.enemy_evolution.time_factor = 8e-05 + game.map_settings.enemy_evolution.time_factor = 7e-05 game.map_settings.enemy_expansion.enabled = true game.map_settings.enemy_expansion.max_expansion_cooldown = 3600 game.map_settings.enemy_expansion.min_expansion_cooldown = 3600 @@ -218,9 +209,9 @@ function Public.reset_map() game.map_settings.pollution.max_pollution_to_restore_trees = 0 game.map_settings.pollution.pollution_with_max_forest_damage = 10 game.map_settings.pollution.pollution_per_tree_damage = 0.5 - game.map_settings.pollution.ageing = 0 + game.map_settings.pollution.ageing = 0.1 game.map_settings.pollution.diffusion_ratio = 0.1 - game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.5 + game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.75 game.forces.player.technologies["land-mine"].enabled = false game.forces.player.technologies["landfill"].enabled = false @@ -243,8 +234,6 @@ local function on_player_joined_game(event) local player = game.players[event.player_index] global.flame_boots[event.player_index] = {fuel = 1} if not global.flame_boots[event.player_index].steps then global.flame_boots[event.player_index].steps = {} end - --log(chronobuble.determine_planet()) - --set_difficulty() local surface = game.surfaces[global.active_surface_index] @@ -302,289 +291,6 @@ local function repair_train() end end -local function check_upgrades() - local objective = global.objective - if not game.surfaces["cargo_wagon"] then return end - if objective.game_lost == true then return end - if global.hpchest and global.hpchest.valid then - local inv = global.hpchest.get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("copper-plate") - local coincost = math_floor(2500 * (1 + objective.hpupgradetier /4)) - if countcoins >= coincost and count2 >= 3000 and objective.hpupgradetier < 18 then - inv.remove({name = "coin", count = coincost}) - inv.remove({name = "copper-plate", count = 3000}) - game.print("Comfylatron: Train's max HP was upgraded.", {r=0.98, g=0.66, b=0.22}) - objective.hpupgradetier = objective.hpupgradetier + 1 - objective.max_health = 10000 + 5000 * objective.hpupgradetier - rendering.set_text(global.objective.health_text, "HP: " .. global.objective.health .. " / " .. global.objective.max_health) - end - end - if global.filterchest and global.filterchest.valid then - local inv = global.filterchest.get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("electronic-circuit") - if countcoins >= 5000 and count2 >= 2000 and objective.filterupgradetier < 9 and objective.chronojumps >= (objective.filterupgradetier + 1) * 3 then - inv.remove({name = "coin", count = 5000}) - inv.remove({name = "electronic-circuit", count = 2000}) - game.print("Comfylatron: Train's pollution filter was upgraded.", {r=0.98, g=0.66, b=0.22}) - objective.filterupgradetier = objective.filterupgradetier + 1 - end - end - if global.acuchest and global.acuchest.valid then - local inv = global.acuchest.get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("battery") - if countcoins >= 2500 and count2 >= 200 and objective.acuupgradetier < 24 then - inv.remove({name = "coin", count = 2500}) - inv.remove({name = "battery", count = 200}) - game.print("Comfylatron: Train's acumulator capacity was upgraded.", {r=0.98, g=0.66, b=0.22}) - objective.acuupgradetier = objective.acuupgradetier + 1 - spawn_acumulators() - end - end - if global.playerchest and global.playerchest.valid then - local inv = global.playerchest.get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("long-handed-inserter") - local coincost = 1000 * (1 + objective.pickupupgradetier) - if countcoins >= coincost and count2 >= 400 and objective.pickupupgradetier < 4 then - inv.remove({name = "coin", count = coincost}) - inv.remove({name = "long-handed-inserter", count = 400}) - game.print("Comfylatron: Players now have additional red inserter installed on shoulders, increasing their item pickup range.", {r=0.98, g=0.66, b=0.22}) - objective.pickupupgradetier = objective.pickupupgradetier + 1 - game.forces.player.character_loot_pickup_distance_bonus = game.forces.player.character_loot_pickup_distance_bonus + 1 - end - end - if global.invchest and global.invchest.valid then - local inv = global.invchest.get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local item = "computer" - if objective.invupgradetier == 0 then - item = "wooden-chest" - elseif objective.invupgradetier == 1 then - item = "iron-chest" - elseif objective.invupgradetier == 2 then - item = "steel-chest" - elseif objective.invupgradetier == 3 then - item = "logistic-chest-storage" - end - local count2 = inv.get_item_count(item) - local coincost = 2000 * (1 + objective.invupgradetier) - if countcoins >= coincost and count2 >= 250 and objective.invupgradetier < 4 and objective.chronojumps >= (objective.invupgradetier + 1) * 5 then - inv.remove({name = "coin", count = coincost}) - inv.remove({name = item, count = 250}) - game.print("Comfylatron: Players now can carry more trash in their unsorted inventories.", {r=0.98, g=0.66, b=0.22}) - objective.invupgradetier = objective.invupgradetier + 1 - game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + 10 - end - end - - if global.toolschest and global.toolschest.valid then - local inv = global.toolschest.get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("repair-pack") - local coincost = 1000 * (1 + objective.toolsupgradetier) - local toolscost = 200 * (1 + objective.toolsupgradetier) - if countcoins >= coincost and count2 >= toolscost and objective.toolsupgradetier < 4 then - inv.remove({name = "coin", count = coincost}) - inv.remove({name = "repair-pack", count = toolscost}) - game.print("Comfylatron: Train now gets repaired with additional repair kit at once.", {r=0.98, g=0.66, b=0.22}) - objective.toolsupgradetier = objective.toolsupgradetier + 1 - end - end - if global.waterchest and global.waterchest.valid and game.surfaces["cargo_wagon"].valid then - local inv = global.waterchest.get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("pipe") - if countcoins >= 2000 and count2 >= 500 and objective.waterupgradetier < 1 then - inv.remove({name = "coin", count = 2000}) - inv.remove({name = "pipe", count = 500}) - game.print("Comfylatron: Train now has piping system for additional water sources.", {r=0.98, g=0.66, b=0.22}) - objective.waterupgradetier = objective.waterupgradetier + 1 - local e1 = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = {28,66}, force="player"}) - local e2 = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = {28,-62}, force = "player"}) - local e3 = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = {-29,66}, force = "player"}) - local e4 = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = {-29,-62}, force = "player"}) - e1.destructible = false - e1.minable = false - e2.destructible = false - e2.minable = false - e3.destructible = false - e3.minable = false - e4.destructible = false - e4.minable = false - end - end - if global.outchest and global.outchest.valid and game.surfaces["cargo_wagon"].valid then - local inv = global.outchest.get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("fast-inserter") - if countcoins >= 2000 and count2 >= 100 and objective.outupgradetier < 1 then - inv.remove({name = "coin", count = 2000}) - inv.remove({name = "fast-inserter", count = 100}) - game.print("Comfylatron: Train now has output chests.", {r=0.98, g=0.66, b=0.22}) - objective.outupgradetier = objective.outupgradetier + 1 - local e = {} - e[1] = game.surfaces["cargo_wagon"].create_entity({name="compilatron-chest", position= {-16,-62}, force = "player"}) - e[2] = game.surfaces["cargo_wagon"].create_entity({name="compilatron-chest", position= {15,-62}, force = "player"}) - e[3] = game.surfaces["cargo_wagon"].create_entity({name="compilatron-chest", position= {-16,66}, force = "player"}) - e[4] = game.surfaces["cargo_wagon"].create_entity({name="compilatron-chest", position= {15,66}, force = "player"}) - - local out = {} - for i = 1, 4, 1 do - e[i].destructible = false - e[i].minable = false - global.outchests[i] = e[i] - out[i] = rendering.draw_text{ - text = "Output", - surface = e[i].surface, - target = e[i], - target_offset = {0, -1.5}, - color = global.locomotive.color, - scale = 0.80, - font = "default-game", - alignment = "center", - scale_with_zoom = false - } - end - end - end - if global.boxchest and global.boxchest.valid and game.surfaces["cargo_wagon"].valid then - local inv = global.boxchest.get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local item = "computer" - if objective.boxupgradetier == 0 then - item = "wooden-chest" - elseif objective.boxupgradetier == 1 then - item = "iron-chest" - elseif objective.boxupgradetier == 2 then - item = "steel-chest" - elseif objective.boxupgradetier == 3 then - item = "logistic-chest-storage" - end - local count2 = inv.get_item_count(item) - if countcoins >= 5000 and count2 >= 250 and objective.boxupgradetier < 4 and objective.chronojumps >= (objective.boxupgradetier + 1) * 5 then - inv.remove({name = "coin", count = 5000}) - inv.remove({name = item, count = 250}) - game.print("Comfylatron: Cargo wagons now have enlargened storage.", {r=0.98, g=0.66, b=0.22}) - objective.boxupgradetier = objective.boxupgradetier + 1 - local chests = {} - for i = 1, 58, 1 do - if objective.boxupgradetier == 1 then - chests[#chests + 1] = {name="wooden-chest", position= {-33 ,-189 + i}, force = "player"} - chests[#chests + 1] = {name="wooden-chest", position= {32 ,-189 + i}, force = "player"} - elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {name="iron-chest", position= {-33 ,-189 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="iron-chest", position= {32 ,-189 + i}, force = "player", fast_replace = true} - elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {name="steel-chest", position= {-33 ,-189 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="steel-chest", position= {32 ,-189 + i}, force = "player", fast_replace = true} - elseif objective.boxupgradetier == 4 then - chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,-189 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,-189 + i}, force = "player", fast_replace = true} - end - end - for i = 1, 58, 1 do - if objective.boxupgradetier == 1 then - chests[#chests + 1] = {name="wooden-chest", position= {-33 ,-127 + i}, force = "player"} - chests[#chests + 1] = {name="wooden-chest", position= {32 ,-127 + i}, force = "player"} - elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {name="iron-chest", position= {-33 ,-127 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="iron-chest", position= {32 ,-127 + i}, force = "player", fast_replace = true} - elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {name="steel-chest", position= {-33 ,-127 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="steel-chest", position= {32 ,-127 + i}, force = "player", fast_replace = true} - elseif objective.boxupgradetier == 4 then - chests[#chests + 1] ={name="logistic-chest-storage", position= {-33 ,-127 + i}, force = "player", fast_replace = true} - chests[#chests + 1] ={name="logistic-chest-storage", position= {32 ,-127 + i}, force = "player", fast_replace = true} - end - end - for i = 1, 58, 1 do - if objective.boxupgradetier == 1 then - chests[#chests + 1] = {name="wooden-chest", position= {-33 ,-61 + i}, force = "player"} - chests[#chests + 1] = {name="wooden-chest", position= {32 ,-61 + i}, force = "player"} - elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {name="iron-chest", position= {-33 ,-61 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="iron-chest", position= {32 ,-61 + i}, force = "player", fast_replace = true} - elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {name="steel-chest", position= {-33 ,-61 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="steel-chest", position= {32 ,-61 + i}, force = "player", fast_replace = true} - elseif objective.boxupgradetier == 4 then - chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,-61 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,-61 + i}, force = "player", fast_replace = true} - end - end - for i = 1, 58, 1 do - if objective.boxupgradetier == 1 then - chests[#chests + 1] = {name="wooden-chest", position= {-33 ,1 + i}, force = "player"} - chests[#chests + 1] = {name="wooden-chest", position= {32 ,1 + i}, force = "player"} - elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {name="iron-chest", position= {-33 ,1 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="iron-chest", position= {32 ,1 + i}, force = "player", fast_replace = true} - elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {name="steel-chest", position= {-33 ,1 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="steel-chest", position= {32 ,1 + i}, force = "player", fast_replace = true} - elseif objective.boxupgradetier == 4 then - chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,1 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,1 + i}, force = "player", fast_replace = true} - end - end - for i = 1, 58, 1 do - if objective.boxupgradetier == 1 then - chests[#chests + 1] = {name="wooden-chest", position= {-33 ,67 + i}, force = "player"} - chests[#chests + 1] = {name="wooden-chest", position= {32 ,67 + i}, force = "player"} - elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {name="iron-chest", position= {-33 ,67 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="iron-chest", position= {32 ,67 + i}, force = "player", fast_replace = true} - elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {name="steel-chest", position= {-33 ,67 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="steel-chest", position= {32 ,67 + i}, force = "player", fast_replace = true} - elseif objective.boxupgradetier == 4 then - chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,67 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,67 + i}, force = "player", fast_replace = true} - end - end - for i = 1, 58, 1 do - if objective.boxupgradetier == 1 then - chests[#chests + 1] = {name="wooden-chest", position= {-33 ,129 + i}, force = "player"} - chests[#chests + 1] = {name="wooden-chest", position= {32 ,129 + i}, force = "player"} - elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {name="iron-chest", position= {-33 ,129 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="iron-chest", position= {32 ,129 + i}, force = "player", fast_replace = true} - elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {name="steel-chest", position= {-33 ,129 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="steel-chest", position= {32 ,129 + i}, force = "player", fast_replace = true} - elseif objective.boxupgradetier == 4 then - chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,129 + i}, force = "player", fast_replace = true} - chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,129 + i}, force = "player", fast_replace = true} - end - end - local surface = game.surfaces["cargo_wagon"] - for i = 1, #chests, 1 do - surface.set_tiles({{name = "tutorial-grid", position = chests[i].position}}) - local e = surface.create_entity(chests[i]) - local old = nil - if e.name == "iron-chest" then old = surface.find_entity("wooden-chest", e.position) - elseif e.name == "steel-chest" then old = surface.find_entity("iron-chest", e.position) - elseif e.name == "logistic-chest-storage" then old = surface.find_entity("steel-chest", e.position) - end - if old then - local items = old.get_inventory(defines.inventory.chest).get_contents() - for item, count in pairs(items) do - e.insert({name = item, count = count}) - end - old.destroy() - end - e.destructible = false - e.minable = false - end - end - end -end - - - local function move_items() if not global.comfychests then return end if not global.comfychests2 then return end @@ -640,13 +346,15 @@ local function output_items() end end -function chronojump(choice) +local function chronojump(choice) local objective = global.objective if objective.game_lost then return end objective.chronojumps = objective.chronojumps + 1 objective.chrononeeds = 2000 + 800 * objective.chronojumps objective.chronotimer = 0 - game.print("Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. global.objective.chronojumps, {r=0.98, g=0.66, b=0.22}) + local message = "Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. global.objective.chronojumps + game.print(message, {r=0.98, g=0.66, b=0.22}) + Server.to_discord_embed(message) local oldsurface = game.surfaces[global.active_surface_index] for _,player in pairs(game.players) do @@ -661,11 +369,8 @@ function chronojump(choice) local surface = game.surfaces[global.active_surface_index] local planet = nil if choice then - planet = chronobuble.determine_planet(choice) - local message = "Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name - game.print(message, {r=0.98, g=0.66, b=0.22}) - global.objective.planet = planet - Server.to_discord_embed(message) + Planets.determine_planet(choice) + planet = global.objective.planet end generate_overworld(surface, planet) game.forces.player.set_spawn_position({12, 10}, surface) @@ -679,7 +384,7 @@ function chronojump(choice) else game.forces["enemy"].evolution_factor = 1 end - game.map_settings.enemy_evolution.time_factor = 8e-05 + 4e-06 * objective.chronojumps + game.map_settings.enemy_evolution.time_factor = 7e-05 + 3e-06 * objective.chronojumps surface.pollute(global.locomotive.position, 200 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps)) game.forces.scrapyard.set_ammo_damage_modifier("bullet", objective.chronojumps / 20) game.forces.scrapyard.set_turret_attack_modifier("gun-turret", objective.chronojumps / 20) @@ -688,7 +393,9 @@ end local function check_chronoprogress() local objective = global.objective --game.print(objective.chronotimer) - if objective.chronotimer >= objective.chrononeeds - 60 and objective.chronotimer < objective.chrononeeds - 59 then + if objective.chronotimer >= objective.chrononeeds - 180 and objective.chronotimer < objective.chrononeeds - 59 then + game.print("Comfylatron: Acumulator charging disabled, 180 seconds countdown to jump!", {r=0.98, g=0.66, b=0.22}) + elseif objective.chronotimer >= objective.chrononeeds - 60 and objective.chronotimer < objective.chrononeeds - 59 then game.print("Comfylatron: ChronoTrain nearly charged! Grab what you can, we leaving in 60 seconds!", {r=0.98, g=0.66, b=0.22}) elseif objective.chronotimer == objective.chrononeeds - 30 then game.print("Comfylatron: You better hurry up! 30 seconds remaining!", {r=0.98, g=0.66, b=0.22}) @@ -714,7 +421,7 @@ local function charge_chronosphere() if energy > 3000000 and objective.chronotimer < objective.chrononeeds - 182 and objective.chronotimer > 130 then acus[i].energy = acus[i].energy - 3000000 objective.chronotimer = objective.chronotimer + 1 - game.surfaces[global.active_surface_index].pollute(global.locomotive.position, 200 * (4 / (objective.filterupgradetier / 2 + 1))) + game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (10 + 5 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1))) --log("energy charged from acu") end end @@ -759,7 +466,7 @@ local function tick() if tick % 1800 == 0 then Locomotive.set_player_spawn_and_refill_fish() repair_train() - check_upgrades() + Upgrades.check_upgrades() end local key = tick % 3600 if tick_minute_functions[key] then tick_minute_functions[key]() end @@ -774,7 +481,7 @@ local function tick() if global.game_reset_tick then if global.game_reset_tick < tick then global.game_reset_tick = nil - require "maps.chronosphere.main".reset_map() + reset_map() end return end @@ -798,7 +505,7 @@ local function on_init() --global.rocks_yield_ore_base_amount = 50 --global.rocks_yield_ore_distance_modifier = 0.025 --if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end - Public.reset_map() + reset_map() end function set_objective_health(final_damage_amount) @@ -855,9 +562,13 @@ local function protect_entity(event) if event.entity.force.index ~= 1 then return end --Player Force if isprotected(event.entity) then if event.cause then - if event.cause.force.index == 2 then - set_objective_health(event.final_damage_amount) + if event.cause == global.comfylatron or event.entity == global.comfylatron then + return end + if event.cause.force.index == 2 then + set_objective_health(event.final_damage_amount) + end + end if not event.entity.valid then return end event.entity.health = event.entity.health + event.final_damage_amount @@ -898,11 +609,11 @@ local function trap(entity) if math_random(1,64) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end end -local function get_choppy_amount(entity) - local distance_to_center = 20 * global.objective.chronojumps - local amount = (40 + distance_to_center ) * (1 + game.forces.player.mining_drill_productivity_bonus) - if amount > 1000 then amount = 1000 end - amount = math_random(math_floor(amount * 0.5), math_floor(amount * 1.5)) +local function get_ore_amount() + local scaling = 10 * global.objective.chronojumps + local amount = (40 + scaling ) * (1 + game.forces.player.mining_drill_productivity_bonus) * global.objective.planet[1].ore_richness.factor + if amount > 800 then amount = 800 end + amount = math_random(math_floor(amount * 0.7), math_floor(amount * 1.3)) return amount end @@ -913,28 +624,22 @@ local function pre_player_mined_item(event) if objective.planet[1].name.name == "rocky planet" then if event.entity.name == "rock-huge" or event.entity.name == "rock-big" or event.entity.name == "sand-rock-big" then trap(event.entity) - local rock_position = {x = event.entity.position.x, y = event.entity.position.y} event.entity.destroy() - local tile_distance_to_center = 40 + 40 * objective.chronojumps * (1 + game.forces.player.mining_drill_productivity_bonus) - if tile_distance_to_center > 1450 then tile_distance_to_center = 1450 end surface.spill_item_stack(player.position,{name = "raw-fish", count = math_random(1,3)},true) - local bonus_amount = math_floor((tile_distance_to_center) + 1) - if bonus_amount < 0 then bonus_amount = 0 end - local amount = math_random(25,45) + bonus_amount - if amount > 500 then amount = 500 end - amount = math_floor(amount * (1+game.forces.player.mining_drill_productivity_bonus)) + local amount = get_ore_amount() local rock_mining = {"iron-ore", "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "copper-ore", "stone", "stone", "coal", "coal"} local mined_loot = rock_mining[math_random(1,#rock_mining)] surface.create_entity({ name = "flying-text", - position = rock_position, + position = {player.position.x, player.position.y - 0.5}, text = "+" .. amount .. " [img=item/" .. mined_loot .. "]", color = {r=0.98, g=0.66, b=0.22} }) local i = player.insert {name = mined_loot, count = amount} amount = amount - i if amount > 0 then - surface.spill_item_stack(rock_position,{name = mined_loot, count = amount},true) + surface.spill_item_stack(player.position, {name = mined_loot, count = amount},true) + --surface.create_entity{name="item-on-ground", position=game.player.position, stack={name=mined_loot, count=50}} end end end @@ -948,7 +653,7 @@ local function on_player_mined_entity(event) if choppy_entity_yield[entity.name] then if event.buffer then event.buffer.clear() end if not event.player_index then return end - local amount = get_choppy_amount(entity) + local amount = get_ore_amount() local second_item_amount = math_random(2,5) local second_item = "wood" local main_item = choppy_entity_yield[entity.name][math_random(1,#choppy_entity_yield[entity.name])] @@ -965,7 +670,7 @@ local function on_player_mined_entity(event) local inserted_count = player.insert({name = main_item, count = amount}) amount = amount - inserted_count if amount > 0 then - entity.surface.spill_item_stack(entity.position,{name = main_item, count = amount}, true) + entity.surface.spill_item_stack(player.position,{name = main_item, count = amount}, true) end local inserted_count = player.insert({name = second_item, count = second_item_amount}) @@ -977,7 +682,7 @@ local function on_player_mined_entity(event) end if entity.name == "rock-huge" or entity.name == "rock-big" or entity.name == "sand-rock-big" then if global.objective.planet[1].name.name ~= "rocky planet" then - prospect_ores(entity) + Ores.prospect_ores(entity) elseif global.objective.planet[1].name.name == "rocky planet" then event.buffer.clear() end @@ -1118,4 +823,32 @@ event.add(defines.events.on_research_finished, on_research_finished) event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state) event.add(defines.events.on_player_changed_position, on_player_changed_position) -return Public +if _DEBUG then + local Session = require 'utils.session_data' + local Color = require 'utils.color_presets' + + commands.add_command( + 'chronojump', + 'Weeeeee!', + function(cmd) + local player = game.player + local trusted = Session.get_trusted_table() + local param = tostring(cmd.parameter) + local p + + if player then + if player ~= nil then + p = player.print + if not trusted[player.name] then + if not player.admin then + p("[ERROR] Only admins and trusted weebs are allowed to run this command!", Color.fail) + return + end + end + else + p = log + end + end + chronojump(param) + end) +end diff --git a/maps/chronosphere/ores.lua b/maps/chronosphere/ores.lua index 464c6b87..17ad60f2 100644 --- a/maps/chronosphere/ores.lua +++ b/maps/chronosphere/ores.lua @@ -1,3 +1,4 @@ +local Public_ores = {} local simplex_noise = require 'utils.simplex_noise'.d2 local math_random = math.random local math_abs = math.abs @@ -5,10 +6,6 @@ local math_floor = math.floor local math_sqrt = math.sqrt local ores = {"copper-ore", "iron-ore", "stone", "coal"} -local function pos_to_key(position) - return tostring(position.x .. "_" .. position.y) -end - local function draw_noise_ore_patch(position, name, surface, radius, richness, mixed) if not position then return end if not name then return end @@ -41,36 +38,11 @@ local function draw_noise_ore_patch(position, name, surface, radius, richness, m if surface.can_place_entity(entity) then surface.create_entity(entity) end - --if not global.ores_queue[pos.x] then global.ores_queue[pos.x] = {} end - - --global.ores_queue[pos_to_key(pos)] = {name = name, position = pos, amount = a} - --end end end end end --- function ores_are_mixed(surface) --- local ore_raffle = { --- "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "coal", "stone" --- } --- local r = 480 --- local area = {{r * -1, r * -1}, {r, r}} --- local ores = surface.find_entities_filtered({area = area, name = {"iron-ore", "copper-ore", "coal", "stone"}}) --- if #ores == 0 then return end --- local seed = surface.map_gen_settings.seed --- --- for _, ore in pairs(ores) do --- local pos = ore.position --- local noise = simplex_noise(pos.x * 0.005, pos.y * 0.005, seed) + simplex_noise(pos.x * 0.01, pos.y * 0.01, seed) * 0.3 + simplex_noise(pos.x * 0.05, pos.y * 0.05, seed) * 0.2 --- --- local i = (math.floor(noise * 100) % 7) + 1 --- --if not global.ores_queue[pos.x] then global.ores_queue[pos.x] = {} end --- --global.ores_queue[pos_to_key(pos)] = {name = ore_raffle[i], position = ore.position, amount = ore.amount} --- ore.destroy() --- end --- end - local function get_size_of_ore(ore, planet) local base_size = math_random(5, 10) + math_floor(planet[1].ore_richness.factor * 3) local final_size = 1 @@ -94,7 +66,7 @@ end local function get_oil_amount(pos, oil_w) local hundred_percent = 300000 - return (hundred_percent / 20) * (1+global.objective.chronojumps) * oil_w + return (hundred_percent / 40) * (1+global.objective.chronojumps) * oil_w end function spawn_ore_vein(surface, pos, planet) @@ -135,12 +107,13 @@ function spawn_ore_vein(surface, pos, planet) --end end -function prospect_ores(entity) +function Public_ores.prospect_ores(entity) local planet = global.objective.planet local chance = 10 if entity.name == "rock-huge" then chance = 40 end if math_random(chance + math_floor(10 * planet[1].ore_richness.factor) ,100 + chance) >= 100 then spawn_ore_vein(entity.surface, entity.position, planet) - --if planet[1].name.name == "mixed planet" then end end + +return Public_ores diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index 9f7a45fd..f3e5d810 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -584,5 +584,3 @@ end local event = require 'utils.event' --event.on_nth_tick(4, process_chunk_queue) event.add(defines.events.on_chunk_generated, on_chunk_generated) - -return level_depth diff --git a/maps/chronosphere/upgrades.lua b/maps/chronosphere/upgrades.lua new file mode 100644 index 00000000..b08259d5 --- /dev/null +++ b/maps/chronosphere/upgrades.lua @@ -0,0 +1,287 @@ + +local Public = {} +local math_floor = math.floor + +local function spawn_acumulators() + local x = -28 + local y = -252 + local yy = global.objective.acuupgradetier * 2 + local surface = game.surfaces["cargo_wagon"] + if yy > 8 then yy = yy + 2 end + if yy > 26 then yy = yy + 2 end + if yy > 44 then yy = yy + 2 end + for i = 1, 27, 1 do + local acumulator = surface.create_entity({name = "accumulator", position = {x + 2 * i, y + yy}, force="player", create_build_effect_smoke = false}) + acumulator.minable = false + acumulator.destructible = false + table.insert(global.acumulators, acumulator) + end +end + +local function check_upgrade_hp() + local objective = global.objective + if not game.surfaces["cargo_wagon"] then return end + if objective.game_lost == true then return end + if global.hpchest and global.hpchest.valid then + local inv = global.hpchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("copper-plate") + local coincost = math_floor(2000 * (1 + objective.hpupgradetier /4)) + if countcoins >= coincost and count2 >= 3000 and objective.hpupgradetier < 18 then + inv.remove({name = "coin", count = coincost}) + inv.remove({name = "copper-plate", count = 3000}) + game.print("Comfylatron: Train's max HP was upgraded.", {r=0.98, g=0.66, b=0.22}) + objective.hpupgradetier = objective.hpupgradetier + 1 + objective.max_health = 10000 + 5000 * objective.hpupgradetier + rendering.set_text(global.objective.health_text, "HP: " .. global.objective.health .. " / " .. global.objective.max_health) + end + end +end + +local function check_upgrade_filter() + local objective = global.objective + if global.filterchest and global.filterchest.valid then + local inv = global.filterchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("electronic-circuit") + if countcoins >= 5000 and count2 >= 2000 and objective.filterupgradetier < 9 and objective.chronojumps >= (objective.filterupgradetier + 1) * 3 then + inv.remove({name = "coin", count = 5000}) + inv.remove({name = "electronic-circuit", count = 2000}) + game.print("Comfylatron: Train's pollution filter was upgraded.", {r=0.98, g=0.66, b=0.22}) + objective.filterupgradetier = objective.filterupgradetier + 1 + end + end +end + +local function check_upgrade_acu() + local objective = global.objective + if global.acuchest and global.acuchest.valid then + local inv = global.acuchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("battery") + local coincost = math_floor(2000 * (1 + objective.acuupgradetier /4)) + if countcoins >= coincost and count2 >= 200 and objective.acuupgradetier < 24 then + inv.remove({name = "coin", count = coincost}) + inv.remove({name = "battery", count = 200}) + game.print("Comfylatron: Train's acumulator capacity was upgraded.", {r=0.98, g=0.66, b=0.22}) + objective.acuupgradetier = objective.acuupgradetier + 1 + spawn_acumulators() + end + end +end + +local function check_upgrade_pickup() + local objective = global.objective + if global.playerchest and global.playerchest.valid then + local inv = global.playerchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("long-handed-inserter") + local coincost = 1000 * (1 + objective.pickupupgradetier) + if countcoins >= coincost and count2 >= 400 and objective.pickupupgradetier < 4 then + inv.remove({name = "coin", count = coincost}) + inv.remove({name = "long-handed-inserter", count = 400}) + game.print("Comfylatron: Players now have additional red inserter installed on shoulders, increasing their item pickup range.", {r=0.98, g=0.66, b=0.22}) + objective.pickupupgradetier = objective.pickupupgradetier + 1 + game.forces.player.character_loot_pickup_distance_bonus = game.forces.player.character_loot_pickup_distance_bonus + 1 + end + end +end + +local function check_upgrade_inv() + local objective = global.objective + if global.invchest and global.invchest.valid then + local inv = global.invchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local item = "computer" + if objective.invupgradetier == 0 then + item = "wooden-chest" + elseif objective.invupgradetier == 1 then + item = "iron-chest" + elseif objective.invupgradetier == 2 then + item = "steel-chest" + elseif objective.invupgradetier == 3 then + item = "logistic-chest-storage" + end + local count2 = inv.get_item_count(item) + local coincost = 2000 * (1 + objective.invupgradetier) + if countcoins >= coincost and count2 >= 250 and objective.invupgradetier < 4 and objective.chronojumps >= (objective.invupgradetier + 1) * 5 then + inv.remove({name = "coin", count = coincost}) + inv.remove({name = item, count = 250}) + game.print("Comfylatron: Players now can carry more trash in their unsorted inventories.", {r=0.98, g=0.66, b=0.22}) + objective.invupgradetier = objective.invupgradetier + 1 + game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + 10 + end + end +end + +local function check_upgrade_tools() + local objective = global.objective + if global.toolschest and global.toolschest.valid then + local inv = global.toolschest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("repair-pack") + local coincost = 1000 * (1 + objective.toolsupgradetier) + local toolscost = 200 * (1 + objective.toolsupgradetier) + if countcoins >= coincost and count2 >= toolscost and objective.toolsupgradetier < 4 then + inv.remove({name = "coin", count = coincost}) + inv.remove({name = "repair-pack", count = toolscost}) + game.print("Comfylatron: Train now gets repaired with additional repair kit at once.", {r=0.98, g=0.66, b=0.22}) + objective.toolsupgradetier = objective.toolsupgradetier + 1 + end + end +end + +local function check_upgrade_water() + local objective = global.objective + if global.waterchest and global.waterchest.valid and game.surfaces["cargo_wagon"].valid then + local inv = global.waterchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("pipe") + if countcoins >= 2000 and count2 >= 500 and objective.waterupgradetier < 1 then + inv.remove({name = "coin", count = 2000}) + inv.remove({name = "pipe", count = 500}) + game.print("Comfylatron: Train now has piping system for additional water sources.", {r=0.98, g=0.66, b=0.22}) + objective.waterupgradetier = objective.waterupgradetier + 1 + local positions = {{28,66},{28,-62},{-29,66},{-29,-62}} + for i = 1, 4, 1 do + local e = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = positions[i], force="player"}) + e.destructible = false + e.minable = false + end + end + end +end + +local function check_upgrade_out() + local objective = global.objective + if global.outchest and global.outchest.valid and game.surfaces["cargo_wagon"].valid then + local inv = global.outchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("fast-inserter") + if countcoins >= 2000 and count2 >= 100 and objective.outupgradetier < 1 then + inv.remove({name = "coin", count = 2000}) + inv.remove({name = "fast-inserter", count = 100}) + game.print("Comfylatron: Train now has output chests.", {r=0.98, g=0.66, b=0.22}) + objective.outupgradetier = objective.outupgradetier + 1 + local positions = {{-16,-62},{15,-62},{-16,66},{15,66}} + local out = {} + for i = 1, 4, 1 do + local e = game.surfaces["cargo_wagon"].create_entity({name = "compilatron-chest", position = positions[i], force = "player"}) + e.destructible = false + e.minable = false + global.outchests[i] = e + out[i] = rendering.draw_text{ + text = "Output", + surface = e.surface, + target = e, + target_offset = {0, -1.5}, + color = global.locomotive.color, + scale = 0.80, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + end + end + end +end + +local function check_upgrade_box() + local objective = global.objective + if global.boxchest and global.boxchest.valid and game.surfaces["cargo_wagon"].valid then + local inv = global.boxchest.get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local item = "computer" + if objective.boxupgradetier == 0 then + item = "wooden-chest" + elseif objective.boxupgradetier == 1 then + item = "iron-chest" + elseif objective.boxupgradetier == 2 then + item = "steel-chest" + elseif objective.boxupgradetier == 3 then + item = "logistic-chest-storage" + end + local count2 = inv.get_item_count(item) + if countcoins >= 5000 and count2 >= 250 and objective.boxupgradetier < 4 and objective.chronojumps >= (objective.boxupgradetier + 1) * 5 then + inv.remove({name = "coin", count = 5000}) + inv.remove({name = item, count = 250}) + game.print("Comfylatron: Cargo wagons now have enlargened storage.", {r=0.98, g=0.66, b=0.22}) + objective.boxupgradetier = objective.boxupgradetier + 1 + local chests = {} + local positions = { + [1] = {x = {-33, 32}, y = {-189, -127, -61, 1, 67, 129}} + } + for i = 1, 58, 1 do + for ii = 1, 6, 1 do + if objective.boxupgradetier == 1 then + chests[#chests + 1] = {name = "wooden-chest", position = {x = positions[1].x[1] ,y = positions[1].y[ii] + i}, force = "player"} + chests[#chests + 1] = {name = "wooden-chest", position = {x = positions[1].x[2] ,y = positions[1].y[ii] + i}, force = "player"} + elseif objective.boxupgradetier == 2 then + chests[#chests + 1] = {name = "iron-chest", position = {x = positions[1].x[1] ,y = positions[1].y[ii] + i}, force = "player"} + chests[#chests + 1] = {name = "iron-chest", position = {x = positions[1].x[2] ,y = positions[1].y[ii] + i}, force = "player"} + elseif objective.boxupgradetier == 3 then + chests[#chests + 1] = {name = "steel-chest", position = {x = positions[1].x[1] ,y = positions[1].y[ii] + i}, force = "player"} + chests[#chests + 1] = {name = "steel-chest", position = {x = positions[1].x[2] ,y = positions[1].y[ii] + i}, force = "player"} + elseif objective.boxupgradetier == 4 then + chests[#chests + 1] = {name = "logistic-chest-storage", position = {x = positions[1].x[1] ,y = positions[1].y[ii] + i}, force = "player"} + chests[#chests + 1] = {name = "logistic-chest-storage", position = {x = positions[1].x[2] ,y = positions[1].y[ii] + i}, force = "player"} + end + end + end + local surface = game.surfaces["cargo_wagon"] + for i = 1, #chests, 1 do + if objective.boxupgradetier == 1 then + surface.set_tiles({{name = "tutorial-grid", position = chests[i].position}}) + end + local e = surface.create_entity(chests[i]) + local old = nil + if e.name == "iron-chest" then old = surface.find_entity("wooden-chest", e.position) + elseif e.name == "steel-chest" then old = surface.find_entity("iron-chest", e.position) + elseif e.name == "logistic-chest-storage" then old = surface.find_entity("steel-chest", e.position) + end + if old then + local items = old.get_inventory(defines.inventory.chest).get_contents() + for item, count in pairs(items) do + e.insert({name = item, count = count}) + end + old.destroy() + end + e.destructible = false + e.minable = false + end + end + end +end + +function Public.check_upgrades() + local objective = global.objective + if objective.hpupgradetier < 18 then + check_upgrade_hp() + end + if objective.filterupgradetier < 9 then + check_upgrade_filter() + end + if objective.acuupgradetier < 24 then + check_upgrade_acu(Locomotive) + end + if objective.pickupupgradetier < 4 then + check_upgrade_pickup() + end + if objective.invupgradetier < 4 then + check_upgrade_inv() + end + if objective.toolsupgradetier < 4 then + check_upgrade_tools() + end + if objective.waterupgradetier < 1 then + check_upgrade_water() + end + if objective.outupgradetier < 1 then + check_upgrade_out() + end + if objective.boxupgradetier < 4 and objective.chronojumps >= (objective.boxupgradetier + 1) * 5 then + check_upgrade_box() + end +end + +return Public From fe257962a5d0918bcb9209504551511c36992af4 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Tue, 18 Feb 2020 02:45:37 +0100 Subject: [PATCH 12/70] forgot to add --- maps/chronosphere/ai.lua | 2 +- maps/chronosphere/main.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/maps/chronosphere/ai.lua b/maps/chronosphere/ai.lua index db9a881a..318aeff2 100644 --- a/maps/chronosphere/ai.lua +++ b/maps/chronosphere/ai.lua @@ -187,7 +187,7 @@ Public.send_near_biters_to_objective = function() if not global.locomotive_cargo3 then return end local targets = {global.locomotive, global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} local random_target = targets[math_random(1, #targets)] - if random_target.valid then return end + if not random_target.valid then return end local surface = random_target.surface local pollution = surface.get_pollution(random_target.position) local success = false diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 8519e4f0..a7367f7e 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -393,9 +393,9 @@ end local function check_chronoprogress() local objective = global.objective --game.print(objective.chronotimer) - if objective.chronotimer >= objective.chrononeeds - 180 and objective.chronotimer < objective.chrononeeds - 59 then + if objective.chronotimer == objective.chrononeeds - 180 then game.print("Comfylatron: Acumulator charging disabled, 180 seconds countdown to jump!", {r=0.98, g=0.66, b=0.22}) - elseif objective.chronotimer >= objective.chrononeeds - 60 and objective.chronotimer < objective.chrononeeds - 59 then + elseif objective.chronotimer == objective.chrononeeds - 60 then game.print("Comfylatron: ChronoTrain nearly charged! Grab what you can, we leaving in 60 seconds!", {r=0.98, g=0.66, b=0.22}) elseif objective.chronotimer == objective.chrononeeds - 30 then game.print("Comfylatron: You better hurry up! 30 seconds remaining!", {r=0.98, g=0.66, b=0.22}) From 2ff8375efd469dfcc69324c182a73db74c0c0f84 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Wed, 19 Feb 2020 15:15:16 +0100 Subject: [PATCH 13/70] updates - lava planet fires happen only when no pavement - new planet -if staying for too long, biters on next planets can evolve --- maps/chronosphere/ai.lua | 5 +- maps/chronosphere/chronobubles.lua | 8 +- maps/chronosphere/comfylatron.lua | 4 +- maps/chronosphere/gui.lua | 9 +- maps/chronosphere/locomotive.lua | 8 +- maps/chronosphere/main.lua | 72 ++++++--- maps/chronosphere/ores.lua | 17 ++- maps/chronosphere/terrain.lua | 236 ++++++++++++++++++++++++++--- maps/chronosphere/treasure.lua | 18 +-- 9 files changed, 307 insertions(+), 70 deletions(-) diff --git a/maps/chronosphere/ai.lua b/maps/chronosphere/ai.lua index 318aeff2..601c2be9 100644 --- a/maps/chronosphere/ai.lua +++ b/maps/chronosphere/ai.lua @@ -187,7 +187,7 @@ Public.send_near_biters_to_objective = function() if not global.locomotive_cargo3 then return end local targets = {global.locomotive, global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} local random_target = targets[math_random(1, #targets)] - if not random_target.valid then return end + if global.objective.game_lost then return end local surface = random_target.surface local pollution = surface.get_pollution(random_target.position) local success = false @@ -206,7 +206,7 @@ Public.send_near_biters_to_objective = function() target=random_target, distraction=defines.distraction.none }, - unit_count = 16 + math_random(1, math_floor(game.forces["enemy"].evolution_factor * 100)), + unit_count = 16 + math_random(1, math_floor(1 + game.forces["enemy"].evolution_factor * 100)), force = "enemy", unit_search_distance=128 }) @@ -267,6 +267,7 @@ local function send_group(unit_group, nearest_player_unit) local targets = {global.locomotive, global.locomotive, nearest_player_unit, nearest_player_unit, nearest_player_unit, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} local target = targets[math_random(1, #targets)] + if not target.valid then colonize(unit_group) return end local surface = target.surface local pollution = surface.get_pollution(target.position) if pollution > 200 then diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua index a307088f..40d25199 100644 --- a/maps/chronosphere/chronobubles.lua +++ b/maps/chronosphere/chronobubles.lua @@ -16,9 +16,9 @@ local variants = { [11] = {id = 11, name = "rocky planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 6, moisture = -0.2, chance = 2, cumul_chance = 19}, [12] = {id = 12, name = "choppy planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 1, biters = 6, moisture = 0.4, chance = 2, cumul_chance = 21}, [13] = {id = 13, name = "river planet", iron = 1, copper = 1, coal = 3, stone = 1, uranium = 0, oil = 0, biters = 8, moisture = 0.5, chance = 2, cumul_chance = 23}, - [14] = {id = 14, name = "lava planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 6, moisture = -0.5, chance = 1, cumul_chance = 24}, - [15] = {id = 15, name = "start planet", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24} - + [14] = {id = 14, name = "lava planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 0, oil = 0, biters = 6, moisture = -0.5, chance = 1, cumul_chance = 24}, + [15] = {id = 15, name = "start planet", iron = 4, copper = 4, coal = 4, stone = 4, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24}, + [16] = {id = 16, name = "hedge maze", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 1, oil = 2, biters = 16, moisture = -0.1, chance = 2, cumul_chance = 26} } local time_speed_variants = { @@ -70,7 +70,7 @@ function Public.determine_planet(choice) planet_choice = variants[choice] else planet_choice = roll(weight) - end + end end local planet = { [1] = { diff --git a/maps/chronosphere/comfylatron.lua b/maps/chronosphere/comfylatron.lua index 1c6e6a06..cffe942a 100644 --- a/maps/chronosphere/comfylatron.lua +++ b/maps/chronosphere/comfylatron.lua @@ -223,7 +223,7 @@ local function desync(event) -- movement = {m2 - (math.random(0, m) * 0.01), m2 - (math.random(0, m) * 0.01)} -- }) -- end - if math_random(1,4) == 1 then + if not event or math_random(1,4) == 1 then global.comfylatron.surface.create_entity({name = "medium-explosion", position = global.comfylatron.position}) global.comfylatron.surface.create_entity({name = "flying-text", position = global.comfylatron.position, text = "desync", color = {r = 150, g = 0, b = 0}}) global.comfylatron.destroy() @@ -244,7 +244,7 @@ local function alone() if global.comfybubble then global.comfybubble.destroy() return true end end if math_random(1,128) == 1 then - desync() + desync(nil) return true end set_comfy_speech_bubble(texts["alone"][math_random(1, #texts["alone"])]) diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index c6ea22b9..214f644a 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -40,7 +40,7 @@ local function create_gui(player) label.style.minimal_width = 10 label.style.font_color = {r = 150, g = 0, b = 255} - local label = frame.add({ type = "label", caption = " ", name = "timer_value"}) + local label = frame.add({ type = "label", caption = " ", name = "timer_value", tooltip = " "}) label.style.font = "default-bold" label.style.right_padding = 1 label.style.minimal_width = 10 @@ -104,8 +104,13 @@ local function update_gui(player) gui.timer.caption = {"chronosphere.gui_3"} gui.timer_value.caption = math_floor((objective.chrononeeds - objective.chronotimer) / 60) .. " min, " .. (objective.chrononeeds - objective.chronotimer) % 60 .. " s" + if objective.chronojumps > 5 then + gui.timer_value.tooltip = "If overstaying this, other planets can evolve: " ..math_floor((objective.chrononeeds * 0.75 - objective.chronotimer) / 60) .. " min, " .. (objective.chrononeeds * 0.75 - objective.chronotimer) % 60 .. " s" + else + gui.timer_value.tooltip = "After planet 5, biters will get additional permanent evolution for staying too long on each planet." + end - gui.planet.caption = "Planet: " .. objective.planet[1].name.name .. " Ores: " .. objective.planet[1].ore_richness.name + gui.planet.caption = "Planet: " .. objective.planet[1].name.name .. " Ores: " .. objective.planet[1].ore_richness.name local acus = 0 if global.acumulators then acus = #global.acumulators else acus = 0 end local bestcase = math_floor((objective.chrononeeds - objective.chronotimer) / (1 + math_floor(acus/10))) diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index b2fd2f04..d8b6bb96 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -504,10 +504,10 @@ function Public.set_player_spawn_and_refill_fish() end function Public.enter_cargo_wagon(player, vehicle) - if not vehicle then return end - if not vehicle.valid then return end - if not global.locomotive_cargo then return end - if not global.locomotive_cargo.valid then return end + if not vehicle then log("no vehicle") return end + if not vehicle.valid then log("vehicle invalid") return end + if not global.locomotive_cargo then log("no cargo") return end + if not global.locomotive_cargo.valid then log("cargo invalid") return end if vehicle == global.locomotive_cargo then if not game.surfaces["cargo_wagon"] then create_wagon_room() end local surface = game.surfaces["cargo_wagon"] diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index a7367f7e..cb36b768 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -34,6 +34,7 @@ local chests = {} global.objective = {} global.flame_boots = {} global.comfylatron = nil +global.lab_cells = {} local choppy_entity_yield = { ["tree-01"] = {"iron-ore"}, @@ -185,6 +186,8 @@ local function reset_map() objective.boxupgradetier = 0 objective.chronojumps = 0 objective.chronotimer = 0 + objective.passivetimer = 0 + objective.passivejumps = 0 objective.chrononeeds = 2000 objective.active_biters = {} objective.unit_groups = {} @@ -204,14 +207,15 @@ local function reset_map() game.map_settings.enemy_expansion.settler_group_max_size = 8 game.map_settings.enemy_expansion.settler_group_min_size = 16 game.map_settings.pollution.enabled = true - game.map_settings.pollution.pollution_restored_per_tree_damage = 0.1 + game.map_settings.pollution.pollution_restored_per_tree_damage = 0.02 game.map_settings.pollution.min_pollution_to_damage_trees = 1 game.map_settings.pollution.max_pollution_to_restore_trees = 0 game.map_settings.pollution.pollution_with_max_forest_damage = 10 - game.map_settings.pollution.pollution_per_tree_damage = 0.5 + game.map_settings.pollution.pollution_per_tree_damage = 0.1 game.map_settings.pollution.ageing = 0.1 game.map_settings.pollution.diffusion_ratio = 0.1 game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.75 + game.forces["enemy"].evolution_factor = 0.0001 game.forces.player.technologies["land-mine"].enabled = false game.forces.player.technologies["landfill"].enabled = false @@ -349,8 +353,14 @@ end local function chronojump(choice) local objective = global.objective if objective.game_lost then return end + local overstayed = false + if objective.passivetimer > objective.chrononeeds * 0.75 and objective.chronojumps > 5 then + overstayed = true + objective.passivejumps = objective.passivejumps + 1 + end objective.chronojumps = objective.chronojumps + 1 - objective.chrononeeds = 2000 + 800 * objective.chronojumps + objective.chrononeeds = 2000 + 500 * objective.chronojumps + objective.passivetimer = 0 objective.chronotimer = 0 local message = "Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. global.objective.chronojumps game.print(message, {r=0.98, g=0.66, b=0.22}) @@ -360,11 +370,12 @@ local function chronojump(choice) for _,player in pairs(game.players) do if player.surface == oldsurface then if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end - Locomotive.enter_cargo_wagon(player, global.locomotive_cargo) + local wagons = {global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} + Locomotive.enter_cargo_wagon(player, wagons[math_random(1,3)]) end end local map_gen_settings = get_map_gen_settings() - + global.lab_cells = {} global.active_surface_index = game.create_surface("chronosphere" .. objective.chronojumps, map_gen_settings).index local surface = game.surfaces[global.active_surface_index] local planet = nil @@ -373,21 +384,24 @@ local function chronojump(choice) planet = global.objective.planet end generate_overworld(surface, planet) + if overstayed then game.print("Comfylatron: Looks like you stayed on previous planet for so long that enemies on other planets had additional time to evolve!", {r=0.98, g=0.66, b=0.22}) end game.forces.player.set_spawn_position({12, 10}, surface) local items = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).get_contents() - local items2 = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).get_contents() + local items2 = global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).get_contents() Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, items, items2) render_train_hp() game.delete_surface(oldsurface) if objective.chronojumps <= 40 then - game.forces["enemy"].evolution_factor = 0 + 0.025 * objective.chronojumps + game.forces["enemy"].evolution_factor = 0 + 0.025 * (objective.chronojumps + objective.passivejumps) else game.forces["enemy"].evolution_factor = 1 end - game.map_settings.enemy_evolution.time_factor = 7e-05 + 3e-06 * objective.chronojumps - surface.pollute(global.locomotive.position, 200 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps)) - game.forces.scrapyard.set_ammo_damage_modifier("bullet", objective.chronojumps / 20) - game.forces.scrapyard.set_turret_attack_modifier("gun-turret", objective.chronojumps / 20) + game.map_settings.enemy_evolution.time_factor = 7e-05 + 3e-06 * (objective.chronojumps + objective.passivejumps) + surface.pollute(global.locomotive.position, 150 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps)) + game.forces.scrapyard.set_ammo_damage_modifier("bullet", 0.01 * objective.chronojumps) + game.forces.scrapyard.set_turret_attack_modifier("gun-turret", 0.01 * objective.chronojumps) + game.forces.enemy.set_ammo_damage_modifier("melee", 0.1 * objective.passivejumps) + game.forces.enemy.set_ammo_damage_modifier("biological", 0.1 * objective.passivejumps) end local function check_chronoprogress() @@ -421,7 +435,7 @@ local function charge_chronosphere() if energy > 3000000 and objective.chronotimer < objective.chrononeeds - 182 and objective.chronotimer > 130 then acus[i].energy = acus[i].energy - 3000000 objective.chronotimer = objective.chronotimer + 1 - game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (10 + 5 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1))) + game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (10 + 2 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1))) --log("energy charged from acu") end end @@ -472,6 +486,7 @@ local function tick() if tick_minute_functions[key] then tick_minute_functions[key]() end if tick % 60 == 0 then global.objective.chronotimer = global.objective.chronotimer + 1 + global.objective.passivetimer = global.objective.passivetimer + 1 check_chronoprogress() end if tick % 120 == 0 then @@ -603,16 +618,21 @@ local function on_entity_damaged(event) end -local function trap(entity) +local function trap(entity, trap) + if trap then + tick_tack_trap(entity.surface, entity.position) + tick_tack_trap(entity.surface, {x = entity.position.x + math_random(-3,3), y = entity.position.y + math_random(-3,3)}) + return + end if math_random(1,256) == 1 then tick_tack_trap(entity.surface, entity.position) return end if math_random(1,128) == 1 then unearthing_worm(entity.surface, entity.surface.find_non_colliding_position("big-worm-turret",entity.position,5,1)) end if math_random(1,64) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end end local function get_ore_amount() - local scaling = 10 * global.objective.chronojumps - local amount = (40 + scaling ) * (1 + game.forces.player.mining_drill_productivity_bonus) * global.objective.planet[1].ore_richness.factor - if amount > 800 then amount = 800 end + local scaling = 5 * global.objective.chronojumps + local amount = (30 + scaling ) * (1 + game.forces.player.mining_drill_productivity_bonus) * global.objective.planet[1].ore_richness.factor + if amount > 600 then amount = 600 end amount = math_random(math_floor(amount * 0.7), math_floor(amount * 1.3)) return amount end @@ -623,7 +643,7 @@ local function pre_player_mined_item(event) local objective = global.objective if objective.planet[1].name.name == "rocky planet" then if event.entity.name == "rock-huge" or event.entity.name == "rock-big" or event.entity.name == "sand-rock-big" then - trap(event.entity) + trap(event.entity, false) event.entity.destroy() surface.spill_item_stack(player.position,{name = "raw-fish", count = math_random(1,3)},true) local amount = get_ore_amount() @@ -649,7 +669,7 @@ local function on_player_mined_entity(event) local entity = event.entity if not entity.valid then return end if entity.type == "tree" and global.objective.planet[1].name.name == "choppy planet" then - trap(entity) + trap(entity, false) if choppy_entity_yield[entity.name] then if event.buffer then event.buffer.clear() end if not event.player_index then return end @@ -681,10 +701,10 @@ local function on_player_mined_entity(event) end end if entity.name == "rock-huge" or entity.name == "rock-big" or entity.name == "sand-rock-big" then - if global.objective.planet[1].name.name ~= "rocky planet" then - Ores.prospect_ores(entity) + if global.objective.planet[1].name.id ~= 11 and global.objective.planet[1].name.id ~= 16 then --rocky and maze planet + Ores.prospect_ores(entity, entity.surface, entity.position) elseif - global.objective.planet[1].name.name == "rocky planet" then event.buffer.clear() + global.objective.planet[1].name.id == 11 then event.buffer.clear() -- rocky planet end end end @@ -708,7 +728,7 @@ local function on_entity_died(event) if event.cause then if event.cause.valid then if event.cause.force.index ~= 2 then - trap(event.entity) + trap(event.entity, false) end end end @@ -723,6 +743,9 @@ local function on_entity_died(event) if entity.type == "unit" and entity.force == "enemy" then global.objective.active_biters[entity.unit_number] = nil end + if entity.force.name == "scrapyard" and entity.name == "gun-turret" and global.objective.planet[1].name.id == 16 then + trap(entity, true) + end if entity.force.index == 3 then if event.cause then if event.cause.valid then @@ -793,6 +816,11 @@ local function on_player_changed_position(event) if not player.character then return end if player.character.driving then return end if player.surface.name == "cargo_wagon" then return end + local safe = {"stone-path", "concrete", "hazard-concrete-left", "hazard-concrete-right", "refined-concrete", "refined-hazard-concrete-left", "refined-hazard-concrete-right"} + local pavement = player.surface.get_tile(player.position.x, player.position.y) + for i = 1, 7, 1 do + if pavement.name == safe[i] then return end + end if not global.flame_boots[player.index].steps then global.flame_boots[player.index].steps = {} end local steps = global.flame_boots[player.index].steps diff --git a/maps/chronosphere/ores.lua b/maps/chronosphere/ores.lua index 17ad60f2..9a23cf10 100644 --- a/maps/chronosphere/ores.lua +++ b/maps/chronosphere/ores.lua @@ -71,8 +71,9 @@ end function spawn_ore_vein(surface, pos, planet) local mixed = false - if planet[1].name.name == "mixed planet" then mixed = true end - local richness = math_random(50 + 30 * global.objective.chronojumps, 100 + 30 * global.objective.chronojumps) * planet[1].ore_richness.factor + if planet[1].name.id == 6 then mixed = true end --mixed planet + local richness = math_random(50 + 10 * global.objective.chronojumps, 100 + 10 * global.objective.chronojumps) * planet[1].ore_richness.factor + if planet[1].name.id == 16 then richness = richness * 10 end --hedge maze local iron = {w = planet[1].name.iron, t = planet[1].name.iron} local copper = {w = planet[1].name.copper, t = iron.t + planet[1].name.copper} local stone = {w = planet[1].name.stone, t = copper.t + planet[1].name.stone} @@ -107,12 +108,16 @@ function spawn_ore_vein(surface, pos, planet) --end end -function Public_ores.prospect_ores(entity) +function Public_ores.prospect_ores(entity, surface, pos) local planet = global.objective.planet local chance = 10 - if entity.name == "rock-huge" then chance = 40 end - if math_random(chance + math_floor(10 * planet[1].ore_richness.factor) ,100 + chance) >= 100 then - spawn_ore_vein(entity.surface, entity.position, planet) + if entity then + if entity.name == "rock-huge" then chance = 40 end + if math_random(chance + math_floor(10 * planet[1].ore_richness.factor) ,100 + chance) >= 100 then + spawn_ore_vein(surface, pos, planet) + end + else + spawn_ore_vein(surface, pos, planet) end end diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index f3e5d810..3ae6f7fd 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -1,11 +1,13 @@ --require "maps.chronosphere.ores" - +local Ores = require "maps.chronosphere.ores" local math_random = math.random local math_floor = math.floor local math_abs = math.abs local math_sqrt = math.sqrt local level_depth = 960 +local lake_noise_value = -0.9 +local labyrinth_cell_size = 32 --valid values are 2, 4, 8, 16, 32 local Treasure = require 'maps.chronosphere.treasure' local simplex_noise = require "utils.simplex_noise".d2 local rock_raffle = {"sand-rock-big","sand-rock-big", "rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-huge"} @@ -25,6 +27,7 @@ local scrap_entities = {"crash-site-assembling-machine-1-broken", "crash-site-as "medium-ship-wreck", "small-ship-wreck", "medium-ship-wreck", "small-ship-wreck", "medium-ship-wreck", "small-ship-wreck", "medium-ship-wreck", "small-ship-wreck", "crash-site-chest-1", "crash-site-chest-2", "crash-site-chest-1", "crash-site-chest-2", "crash-site-chest-1", "crash-site-chest-2"} local scrap_entities_index = #scrap_entities +local maze_things_raffle = {"camp", "lab", "treasure", "crashsite"} local noises = { ["no_rocks"] = {{modifier = 0.0033, weight = 1}, {modifier = 0.01, weight = 0.22}, {modifier = 0.05, weight = 0.05}, {modifier = 0.1, weight = 0.04}}, ["no_rocks_2"] = {{modifier = 0.013, weight = 1}, {modifier = 0.1, weight = 0.1}}, @@ -39,7 +42,18 @@ local noises = { ["scrapyard"] = {{modifier = 0.005, weight = 1}, {modifier = 0.01, weight = 0.35}, {modifier = 0.05, weight = 0.23}, {modifier = 0.1, weight = 0.11}}, ["forest_location"] = {{modifier = 0.006, weight = 1}, {modifier = 0.01, weight = 0.25}, {modifier = 0.05, weight = 0.15}, {modifier = 0.1, weight = 0.05}}, ["forest_density"] = {{modifier = 0.01, weight = 1}, {modifier = 0.05, weight = 0.5}, {modifier = 0.1, weight = 0.025}}, - ["ores"] = {{modifier = 0.05, weight = 1}, {modifier = 0.02, weight = 0.55}, {modifier = 0.05, weight = 0.05}} + ["ores"] = {{modifier = 0.05, weight = 1}, {modifier = 0.02, weight = 0.55}, {modifier = 0.05, weight = 0.05}}, + ["hedgemaze"] = {{modifier = 0.001, weight = 1}} +} + +local modifiers = { + {x = 0, y = -1},{x = -1, y = 0},{x = 1, y = 0},{x = 0, y = 1} +} +local modifiers_diagonal = { + {diagonal = {x = -1, y = 1}, connection_1 = {x = -1, y = 0}, connection_2 = {x = 0, y = 1}}, + {diagonal = {x = 1, y = -1}, connection_1 = {x = 1, y = 0}, connection_2 = {x = 0, y = -1}}, + {diagonal = {x = 1, y = 1}, connection_1 = {x = 1, y = 0}, connection_2 = {x = 0, y = 1}}, + {diagonal = {x = -1, y = -1}, connection_1 = {x = -1, y = 0}, connection_2 = {x = 0, y = -1}} } local function pos_to_key(position) @@ -79,6 +93,130 @@ local function get_size_of_ore(ore, planet) return final_size end +local function get_path_connections_count(cell_pos) + local connections = 0 + for _, m in pairs(modifiers) do + if global.lab_cells[tostring(cell_pos.x + m.x) .. "_" .. tostring(cell_pos.y + m.y)] then + connections = connections + 1 + end + end + return connections +end + +local function process_labyrinth_cell(pos, seed) + local cell_position = {x = pos.x / labyrinth_cell_size, y = pos.y / labyrinth_cell_size} + local mazenoise = get_noise("hedgemaze", cell_position, seed) + + if mazenoise < lake_noise_value and math_sqrt((pos.x / 32)^2 + (pos.y / 32)^2) > 65 then return false end + + global.lab_cells[tostring(cell_position.x) .. "_" .. tostring(cell_position.y)] = false + + for _, modifier in pairs(modifiers_diagonal) do + if global.lab_cells[tostring(cell_position.x + modifier.diagonal.x) .. "_" .. tostring(cell_position.y + modifier.diagonal.y)] then + local connection_1 = global.lab_cells[tostring(cell_position.x + modifier.connection_1.x) .. "_" .. tostring(cell_position.y + modifier.connection_1.y)] + local connection_2 = global.lab_cells[tostring(cell_position.x + modifier.connection_2.x) .. "_" .. tostring(cell_position.y + modifier.connection_2.y)] + if not connection_1 and not connection_2 then + return false + end + end + end + + for _, m in pairs(modifiers) do + if get_path_connections_count({x = cell_position.x + m.x, y = cell_position.y + m.y}) >= math_random(2, 3) then return false end + end + + if get_path_connections_count(cell_position) >= math_random(2, 3) then return false end + + global.lab_cells[tostring(cell_position.x) .. "_" .. tostring(cell_position.y)] = true + return true +end + +local function process_hedgemaze_position(p, seed, tiles, entities, treasure, planet, cell, things) + --local labyrinth_cell_size = 16 --valid values are 2, 4, 8, 16, 32 + local biters = planet[1].name.biters + local mazenoise = get_noise("hedgemaze", {x = p.x - p.x % labyrinth_cell_size, y = p.y - p.y % labyrinth_cell_size}, seed) + + if mazenoise < lake_noise_value and math_sqrt((p.x - p.x % labyrinth_cell_size)^2 + (p.y - p.y % labyrinth_cell_size)^2) > 65 then + tiles[#tiles + 1] = {name = "deepwater", position = p} + if math_random(1, 256) == 1 then entities[#entities + 1] = {name = "fish", position = p} end + return + elseif mazenoise > 0.7 then + if cell then --path + if things then + if things == "lake" and p.x % 32 > 8 and p.x % 32 < 24 and p.y % 32 > 8 and p.y % 32 < 24 then + tiles[#tiles + 1] = {name = "water", position = p} + return + elseif things == "prospect" then + if math_random(1,202 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 250 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + elseif things == "camp" then + if p.x % 32 > 12 and p.x % 32 < 20 and p.y % 32 > 12 and p.y % 32 < 20 and math_random(1,6) == 1 then + treasure[#treasure + 1] = p + end + elseif things == "crashsite" then + if math_random(1,10) == 1 then + entities[#entities + 1] = {name="mineable-wreckage", position=p} + end + elseif things == "treasure" then + local roll = math_random(1,128) + if roll == 1 then + treasure[#treasure + 1] = p + elseif roll == 2 then + entities[#entities + 1] = {name = "land-mine", position = p, force = "scrapyard"} + end + end + else + if math_random(1, 100) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then + entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p} + end + end + tiles[#tiles + 1] = {name = "dirt-4", position = p} + + else --wall + tiles[#tiles + 1] = {name = "dirt-6", position = p} + if math_random(1,3) == 1 then + entities[#entities + 1] = {name = "dead-tree-desert", position = p} + else + if math_random(1,4) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end + end + end + else + if cell then --path + if things then + if things == "lake" and p.x % 32 > 8 and p.x % 32 < 24 and p.y % 32 > 8 and p.y % 32 < 24 then + tiles[#tiles + 1] = {name = "water", position = p} + return + elseif things == "prospect" then + if math_random(1,202 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 250 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + elseif things == "camp" then + if p.x % 32 > 12 and p.x % 32 < 20 and p.y % 32 > 12 and p.y % 32 < 20 and math_random(1,6) == 1 then + treasure[#treasure + 1] = p + end + elseif things == "crashsite" then + if math_random(1,10) == 1 then + entities[#entities + 1] = {name="mineable-wreckage", position=p} + end + elseif things == "treasure" then + if math_random(1,128) == 1 then + treasure[#treasure + 1] = p + end + end + else + if math_random(1, 100) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then + entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p} + end + end + tiles[#tiles + 1] = {name = "grass-1", position = p} + else --wall + tiles[#tiles + 1] = {name = "grass-2", position = p} + if math_random(1,3) == 1 then + entities[#entities + 1] = {name = "tree-04", position = p} + else + if math_random(1,4) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end + end + end + end + +end local function process_rocky_position(p, seed, tiles, entities, treasure, planet) local biters = planet[1].name.biters local noise_large_caves = get_noise("large_caves", p, seed) @@ -101,7 +239,7 @@ local function process_rocky_position(p, seed, tiles, entities, treasure, planet -- Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) -- entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} -- end - if math_random(1,102 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + if math_random(1,122 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end if math_random(1, 1024) == 1 then treasure[#treasure + 1] = p end return end @@ -370,7 +508,7 @@ end local levels = { process_level_1_position, process_level_2_position, - process_level_3_position, + process_hedgemaze_position, process_rocky_position, process_forest_position, process_river_position, @@ -390,6 +528,20 @@ local entity_functions = { ["container"] = function(surface, entity) Treasure(surface, entity.position, entity.name) end, + ["lab"] = function(surface, entity) + local e = surface.create_entity(entity) + local evo = math_floor(1 + (game.forces.enemy.evolution_factor - 0.00001) * 5) + local research = { + {"automation-science-pack", "logistic-science-pack"}, + {"automation-science-pack", "logistic-science-pack", "military-science-pack"}, + {"automation-science-pack", "logistic-science-pack", "military-science-pack", "chemical-science-pack"}, + {"automation-science-pack", "logistic-science-pack", "military-science-pack", "chemical-science-pack", "production-science-pack"}, + {"automation-science-pack", "logistic-science-pack", "military-science-pack", "chemical-science-pack", "production-science-pack", "utility-science-pack"} + } + for _,science in pairs(research[evo]) do + e.insert({name = science, count = math_random(32,64)}) + end + end, } local function get_replacement_tile(surface, position) @@ -480,7 +632,11 @@ local function empty_chunk(surface, left_top, level, planet) for y = 0, 31, 1 do for x = 0, 31, 1 do local p = {x = left_top.x + x, y = left_top.y + y} - process_level(p, seed, tiles, entities, treasure, planet) + if planet[1].name.id == 16 then + process_level(p, seed, tiles, entities, treasure, planet, true, nil) + else + process_level(p, seed, tiles, entities, treasure, planet) + end end end surface.set_tiles(tiles, true) @@ -493,16 +649,54 @@ local function normal_chunk(surface, left_top, level, planet) --local markets = {} local treasure = {} local seed = surface.map_gen_settings.seed - - --local level_index = math_floor((math_abs(left_top.y / level_depth)) % 10) + 1 - local process_level = levels[level] - - for y = 0, 31, 1 do - for x = 0, 31, 1 do - local p = {x = left_top.x + x, y = left_top.y + y} - process_level(p, seed, tiles, entities, treasure, planet) + local process_level = levels[level] + if planet[1].name.id == 16 then + local cell = false + local roll = math_random(1,20) + local things = nil + if roll == 1 then + things = maze_things_raffle[math_random(1, 4)] + elseif roll == 2 then + things = "lake" + elseif roll > 10 then + things = "prospect" + end + if process_labyrinth_cell(left_top, seed) then + cell = true + if things == "prospect" then + Ores.prospect_ores(nil, surface, {x = left_top.x + 16, y = left_top.y + 16}) + elseif things == "camp" or things == "lab" then + local positions = { + {x = left_top.x + 9, y = left_top.y + 9},{x = left_top.x + 9, y = left_top.y + 16},{x = left_top.x + 9, y = left_top.y + 23}, + {x = left_top.x + 16, y = left_top.y + 9},{x = left_top.x + 16, y = left_top.y + 23}, + {x = left_top.x + 23, y = left_top.y + 9},{x = left_top.x + 23, y = left_top.y + 16},{x = left_top.x + 23, y = left_top.y + 23} + } + for i = 1, 8, 1 do + entities[#entities + 1] = {name = "gun-turret", position = positions[i], force = "scrapyard"} + end + if things == "lab" then + entities[#entities + 1] = {name = "lab", position = {x = left_top.x + 15, y = left_top.y + 15}, force = "neutral"} + end + end end - end + for y = 0, 31, 1 do + for x = 0, 31, 1 do + local p = {x = left_top.x + x, y = left_top.y + y} + process_level(p, seed, tiles, entities, treasure, planet, cell, things) + end + end + else + for y = 0, 31, 1 do + for x = 0, 31, 1 do + local p = {x = left_top.x + x, y = left_top.y + y} + process_level(p, seed, tiles, entities, treasure, planet) + end + end + end + --local level_index = math_floor((math_abs(left_top.y / level_depth)) % 10) + 1 + + + surface.set_tiles(tiles, true) -- if #markets > 0 then @@ -547,23 +741,27 @@ local function process_chunk(surface, left_top) -- for _, entity in pairs(surface.find_entities_filtered({area = {{p.x - 3, p.y - 4},{p.x + 3, p.y + 10}}, type = "simple-entity"})) do entity.destroy() end -- end local planet = global.objective.planet - if planet[1].name.name == "scrapyard" then + local id = planet[1].name.id --from chronobubbles + if id == 10 then --scrapyard if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 8, planet) return end if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 8, planet) return end - elseif planet[1].name.name == "river planet" then + elseif id == 13 then --river planet if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 6, planet) return end if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 6, planet) return end - elseif planet[1].name.name == "choppy planet" then + elseif id == 12 then --choppy planet if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 5, planet) return end if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then forest_chunk(surface, left_top, 5, planet) return end - elseif planet[1].name.name == "rocky planet" then + elseif id == 11 then --rocky planet if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 4, planet) return end if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 4, planet) return end - elseif planet[1].name.name == "lava planet" then + elseif id == 14 then --lava planet if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 7, planet) end if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then biter_chunk(surface, left_top, 7, planet) end replace_water(surface, left_top) return + elseif id == 16 then --hedge maze + if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 3, planet) return end + if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 3, planet) return end else if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 7, planet) return end if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then biter_chunk(surface, left_top, 7, planet) return end diff --git a/maps/chronosphere/treasure.lua b/maps/chronosphere/treasure.lua index d3552949..0e5486cb 100644 --- a/maps/chronosphere/treasure.lua +++ b/maps/chronosphere/treasure.lua @@ -65,7 +65,7 @@ function Public.treasure_chest(surface, position, container_name) {{name = "advanced-circuit", count = math_random(50,150)}, weight = 3, d_min = 0.3, d_max = 1}, {{name = "electronic-circuit", count = math_random(50,150)}, weight = 4, d_min = 0.0, d_max = 0.4}, {{name = "processing-unit", count = math_random(50,150)}, weight = 3, d_min = 0.7, d_max = 1}, - {{name = "explosives", count = math_random(40,100)}, weight = 20, d_min = 0.0, d_max = 1}, + {{name = "explosives", count = math_random(20,50)}, weight = 7, d_min = 0.0, d_max = 1}, {{name = "lubricant-barrel", count = math_random(4,10)}, weight = 1, d_min = 0.3, d_max = 0.5}, {{name = "rocket-fuel", count = math_random(4,10)}, weight = 2, d_min = 0.3, d_max = 0.7}, --{{name = "computer", count = 1}, weight = 2, d_min = 0, d_max = 1}, @@ -74,13 +74,13 @@ function Public.treasure_chest(surface, position, container_name) {{name = "productivity-module", count = math_random(1,4)}, weight = 2, d_min = 0.1, d_max = 1}, {{name = "speed-module", count = math_random(1,4)}, weight = 2, d_min = 0.1, d_max = 1}, - {{name = "automation-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.0, d_max = 0.2}, - {{name = "logistic-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.1, d_max = 0.5}, - {{name = "military-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.2, d_max = 1}, - {{name = "chemical-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.3, d_max = 1}, - {{name = "production-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.4, d_max = 1}, - {{name = "utility-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.5, d_max = 1}, - {{name = "space-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.9, d_max = 1}, + {{name = "automation-science-pack", count = math_random(16,64)}, weight = 4, d_min = 0.0, d_max = 0.2}, + {{name = "logistic-science-pack", count = math_random(16,64)}, weight = 4, d_min = 0.05, d_max = 0.5}, + {{name = "military-science-pack", count = math_random(16,64)}, weight = 4, d_min = 0.15, d_max = 1}, + {{name = "chemical-science-pack", count = math_random(16,64)}, weight = 4, d_min = 0.3, d_max = 1}, + {{name = "production-science-pack", count = math_random(16,64)}, weight = 4, d_min = 0.4, d_max = 1}, + {{name = "utility-science-pack", count = math_random(16,64)}, weight = 4, d_min = 0.5, d_max = 1}, + {{name = "space-science-pack", count = math_random(16,64)}, weight = 4, d_min = 0.9, d_max = 1}, {{name = "steel-plate", count = math_random(25,75)}, weight = 2, d_min = 0.1, d_max = 0.3}, {{name = "nuclear-fuel", count = 1}, weight = 2, d_min = 0.7, d_max = 1}, @@ -160,7 +160,7 @@ function Public.treasure_chest(surface, position, container_name) } local jumps = 0 if global.objective.chronojumps then jumps = global.objective.chronojumps end - local distance_to_center = (jumps / 50) + local distance_to_center = (jumps / 40) if distance_to_center > 1 then distance_to_center = 1 end for _, t in pairs (chest_loot) do From a7bf8c3f170867d921eebb0437ed1ee7fbb329e4 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Thu, 20 Feb 2020 23:19:00 +0100 Subject: [PATCH 14/70] New update - difficulty vote (default is NORMAL!) - poison upgrade operated by comfylatron - can open output wagons directly - some fixes --- maps/chronosphere/ai.lua | 20 ++- maps/chronosphere/chronobubles.lua | 2 +- maps/chronosphere/gui.lua | 13 +- maps/chronosphere/locomotive.lua | 235 +++++++++++++---------------- maps/chronosphere/main.lua | 38 ++++- maps/chronosphere/terrain.lua | 22 +-- maps/chronosphere/treasure.lua | 4 +- maps/chronosphere/upgrades.lua | 62 +++++--- 8 files changed, 214 insertions(+), 182 deletions(-) diff --git a/maps/chronosphere/ai.lua b/maps/chronosphere/ai.lua index 601c2be9..8a3287e2 100644 --- a/maps/chronosphere/ai.lua +++ b/maps/chronosphere/ai.lua @@ -191,13 +191,17 @@ Public.send_near_biters_to_objective = function() local surface = random_target.surface local pollution = surface.get_pollution(random_target.position) local success = false - if pollution > 200 then - surface.pollute(random_target.position, -50) + if pollution > 200 * (1 / global.difficulty_vote_value) then + surface.pollute(random_target.position, -50 * (1 / global.difficulty_vote_value)) --game.print("sending objective wave") success = true else - if math_random(1,50) == 1 then success = true end - --game.print("not enough pollution for objective attack") + if global.objective.chronojumps < 50 then + if math_random(1, 50 - global.objective.chronojumps) == 1 then success = true end + --game.print("not enough pollution for objective attack") + else + success = true + end end if success then game.surfaces[global.active_surface_index].set_multi_command({ @@ -206,7 +210,7 @@ Public.send_near_biters_to_objective = function() target=random_target, distraction=defines.distraction.none }, - unit_count = 16 + math_random(1, math_floor(1 + game.forces["enemy"].evolution_factor * 100)), + unit_count = 16 + math_random(1, math_floor(1 + game.forces["enemy"].evolution_factor * 100)) * global.difficulty_vote_value, force = "enemy", unit_search_distance=128 }) @@ -235,7 +239,7 @@ local function select_units_around_spawner(spawner) local objective = global.objective local unit_count = 0 - local max_unit_count = 128 + local max_unit_count = 128 * global.difficulty_vote_value for _, biter in pairs(biters) do if unit_count >= max_unit_count then break end @@ -270,8 +274,8 @@ local function send_group(unit_group, nearest_player_unit) if not target.valid then colonize(unit_group) return end local surface = target.surface local pollution = surface.get_pollution(target.position) - if pollution > 200 then - surface.pollute(target.position, -50) + if pollution > 200 * (1 / global.difficulty_vote_value) then + surface.pollute(target.position, -50 * (1 / global.difficulty_vote_value)) --game.print("sending unit group attack") local commands = {} diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua index 40d25199..f3cbc630 100644 --- a/maps/chronosphere/chronobubles.lua +++ b/maps/chronosphere/chronobubles.lua @@ -17,7 +17,7 @@ local variants = { [12] = {id = 12, name = "choppy planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 1, biters = 6, moisture = 0.4, chance = 2, cumul_chance = 21}, [13] = {id = 13, name = "river planet", iron = 1, copper = 1, coal = 3, stone = 1, uranium = 0, oil = 0, biters = 8, moisture = 0.5, chance = 2, cumul_chance = 23}, [14] = {id = 14, name = "lava planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 0, oil = 0, biters = 6, moisture = -0.5, chance = 1, cumul_chance = 24}, - [15] = {id = 15, name = "start planet", iron = 4, copper = 4, coal = 4, stone = 4, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24}, + [15] = {id = 15, name = "start planet", iron = 4, copper = 3, coal = 4, stone = 3, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24}, [16] = {id = 16, name = "hedge maze", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 1, oil = 2, biters = 16, moisture = -0.1, chance = 2, cumul_chance = 26} } diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index 214f644a..fbd47fa9 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -1,4 +1,5 @@ local math_floor = math.floor +local math_ceil = math.ceil local math_abs = math.abs local math_max = math.max local math_min = math.min @@ -105,7 +106,7 @@ local function update_gui(player) gui.timer.caption = {"chronosphere.gui_3"} gui.timer_value.caption = math_floor((objective.chrononeeds - objective.chronotimer) / 60) .. " min, " .. (objective.chrononeeds - objective.chronotimer) % 60 .. " s" if objective.chronojumps > 5 then - gui.timer_value.tooltip = "If overstaying this, other planets can evolve: " ..math_floor((objective.chrononeeds * 0.75 - objective.chronotimer) / 60) .. " min, " .. (objective.chrononeeds * 0.75 - objective.chronotimer) % 60 .. " s" + gui.timer_value.tooltip = "If overstaying this, other planets can evolve: " ..math_floor((objective.chrononeeds * 0.75 - objective.passivetimer) / 60) .. " min, " .. (objective.chrononeeds * 0.75 - objective.passivetimer) % 60 .. " s" else gui.timer_value.tooltip = "After planet 5, biters will get additional permanent evolution for staying too long on each planet." end @@ -128,7 +129,7 @@ local function update_gui(player) [5] = {c = "--\n"} } local upgt = { - [1] = {t = "[1]: + 5000 Train Max HP. Current: " .. objective.max_health .. "\n Cost : " .. math_floor(2000 * (1 + objective.hpupgradetier /4)) .. " coins + 3000 copper plates\n"}, + [1] = {t = "[1]: + 2500 Train Max HP. Current: " .. objective.max_health .. "\n Cost : " .. math_floor(500 * (1 + objective.hpupgradetier /2)) .. " coins + 1500 copper plates\n"}, [2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%\n Buyable once per 3 jumps.\n Cost: 5000 coins + 2000 green circuits\n"}, [3] = {t = "[3]: Add additional row of Acumulators.\n Cost : " .. math_floor(2000 * (1 + objective.acuupgradetier /4)) .. " coins + 200 batteries\n"}, [4] = {t = "[4]: Add item pickup distance to players.Current: +" .. objective.pickupupgradetier .. ",\n Cost: " .. 1000 * (1 + objective.pickupupgradetier) .. " coins + 400 red inserters\n"}, @@ -136,7 +137,8 @@ local function update_gui(player) [6] = {t = "[6]: Use up more repair tools on train at once. Current: +" .. objective.toolsupgradetier .. "\n Cost: " .. 1000 * (1 + objective.toolsupgradetier) .. " coins + " .. 200 * (1 + objective.toolsupgradetier) .. " repair tools\n"}, [7] = {t = "[7]: Add piping through wagon sides to create water sources for each wagon.\n Cost: 2000 coins + 500 pipes\n"}, [8] = {t = "[8]: Add comfylatron chests that output outside (into cargo wagon 2 and 3)\n Cost: 2000 coins + 100 fast inserters\n"}, - [9] = {t = "[9]: Add storage chests to the sides of wagons.\n Buyable once per 5 jumps.\n Cost: 5000 coins + " .. chests[objective.boxupgradetier + 1].c} + [9] = {t = "[9]: Add storage chests to the sides of wagons.\n Buyable once per 5 jumps.\n Cost: 5000 coins + " .. chests[objective.boxupgradetier + 1].c}, + [10] = {t = "[P]: Poison defense. Triggers automatically when train has low HP.\n Actual charges: " .. objective.poisondefense .. " / 4\n Recharge timer for next use: " .. math_ceil(objective.poisontimeout /6) .. "min\n Cost: 1000 coins + 50 poison capsules\n"} } local maxed = { [1] = {t = "[1]: Train HP maxed.\n"}, @@ -147,10 +149,10 @@ local function update_gui(player) [6] = {t = "[6]: Repairing at top speed of 5 packs.\n"}, [7] = {t = "[7]: Piping created. Don't spill it!\n"}, [8] = {t = "[8]: Output chests created.\n"}, - [9] = {t = "[9]: Storage chests fully upgraded.\n"} + [9] = {t = "[9]: Storage chests fully upgraded.\n"}, } local tooltip = "Insert needed items into chest with upgrade number.\nUpgrading can take a minute.\n\n" - if objective.hpupgradetier < 18 then tooltip = tooltip .. upgt[1].t else tooltip = tooltip .. maxed[1].t end + if objective.hpupgradetier < 36 then tooltip = tooltip .. upgt[1].t else tooltip = tooltip .. maxed[1].t end if objective.filterupgradetier < 9 then tooltip = tooltip .. upgt[2].t else tooltip = tooltip .. maxed[2].t end if objective.acuupgradetier < 24 then tooltip = tooltip .. upgt[3].t else tooltip = tooltip .. maxed[3].t end if objective.pickupupgradetier < 4 then tooltip = tooltip .. upgt[4].t else tooltip = tooltip .. maxed[4].t end @@ -159,6 +161,7 @@ local function update_gui(player) if objective.waterupgradetier < 1 then tooltip = tooltip .. upgt[7].t else tooltip = tooltip .. maxed[7].t end if objective.outupgradetier < 1 then tooltip = tooltip .. upgt[8].t else tooltip = tooltip .. maxed[8].t end if objective.boxupgradetier < 4 then tooltip = tooltip .. upgt[9].t else tooltip = tooltip .. maxed[9].t end + tooltip = tooltip .. upgt[10].t gui.upgrades.tooltip = tooltip diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index d8b6bb96..837ad12b 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -76,9 +76,9 @@ function Public.locomotive_spawn(surface, position, items, items2) global.locomotive_cargo.minable = false global.locomotive_cargo.operable = false global.locomotive_cargo2.minable = false - global.locomotive_cargo2.operable = false + --global.locomotive_cargo2.operable = false global.locomotive_cargo3.minable = false - global.locomotive_cargo3.operable = false + --global.locomotive_cargo3.operable = false end @@ -148,6 +148,7 @@ local function create_wagon_room() for i = 1, 24, 1 do surface.set_tiles({{name = "tutorial-grid", position = {carfpos[i].x,carfpos[i].y}}}) end + for x = width * -0.5, width * 0.5 - 1, 1 do for y = height * 0.5, height * 0.7, 1 do surface.set_tiles({{name = "out-of-map", position = {x,y}}}) @@ -189,6 +190,12 @@ local function create_wagon_room() end end + for x = width * -0.5 - 6, width * -0.5 + 3, 1 do -- combinators + for y = -251, -241, 1 do + surface.set_tiles({{name = "tutorial-grid", position = {x,y}}}) + end + end + for x = width * -0.4 + 6, width * 0.4 - 6, 1 do for y = height * -0.5 + 7, height * -0.5 + 10, 1 do local p = {x,y} @@ -197,6 +204,54 @@ local function create_wagon_room() end end + local combinators = {} + for x = width * -0.5 - 6, width * -0.5 + 3, 1 do + for y = -250, -244, 2 do + combinators[#combinators + 1] = {name = "arithmetic-combinator", position = {x, y}, force = "player", create_build_effect_smoke = false} + end + end + local combimade = {} + for i = 1, #combinators, 1 do + combimade[i] = surface.create_entity(combinators[i]) + combimade[i].minable = false + combimade[i].destructible = false + combimade[i].operable = false + + if i > 1 then + combimade[i].connect_neighbour({wire = defines.wire_type.green, target_entity = combimade[i - 1], source_circuit_id = 2, target_circuit_id = 1}) + local rule = combimade[i].get_or_create_control_behavior() + rule.parameters = {parameters = {first_signal = {type = "virtual", name = "signal-A"}, second_constant = 0, operation = "+", output_signal = {type = "virtual", name = "signal-A"}}} + else + local rule2 = combimade[i].get_or_create_control_behavior() + rule2.parameters = {parameters = {first_signal = {type = "virtual", name = "signal-A"}, second_constant = 0, operation = "+", output_signal = {type = "virtual", name = "signal-B"}}} + end + end + local checker = surface.create_entity({name = "decider-combinator", position = {x = width * -0.5 - 6, y = -242}, force = "player", create_build_effect_smoke = false }) + local rules3 = checker.get_or_create_control_behavior() + rules3.parameters = {parameters = {first_signal = {type = "virtual", name = "signal-A"}, second_signal = {type = "virtual", name = "signal-B"}, comparator = ">", + output_signal = {type = "virtual", name = "signal-C"}, copy_count_from_input = false }} + local combipower = surface.create_entity({name = "substation", position = {x = width * -0.5 - 4, y = -242}, force="player", create_build_effect_smoke = false}) + combipower.connect_neighbour({wire = defines.wire_type.green, target_entity = checker, target_circuit_id = 1}) + combipower.connect_neighbour({wire = defines.wire_type.green, target_entity = combimade[#combimade], target_circuit_id = 1}) + combimade[1].connect_neighbour({wire = defines.wire_type.green, target_entity = checker, source_circuit_id = 2, target_circuit_id = 1}) + local speaker = surface.create_entity({name = "programmable-speaker", position = {x = width * -0.5 - 6, y = -241}, force = "player", create_build_effect_smoke = false, + parameters = {playback_volume = 0.8, playback_globally = true, allow_polyphony = false}, + alert_parameters = {show_alert = true, show_on_map = true, icon_signal_id = {type = "item", name = "accumulator"}, alert_message = "Train Is Charging!" }}) + speaker.connect_neighbour({wire = defines.wire_type.green, target_entity = checker, target_circuit_id = 2}) + local rules4 = speaker.get_or_create_control_behavior() + rules4.circuit_condition = {condition = {first_signal = {type = "virtual", name = "signal-C"}, second_constant = 0, comparator = ">"}} + local solar1 = surface.create_entity({name = "solar-panel", position = {x = width * -0.5 - 2, y = -242}, force="player", create_build_effect_smoke = false}) + local solar2 = surface.create_entity({name = "solar-panel", position = {x = width * -0.5 + 1, y = -242}, force="player", create_build_effect_smoke = false}) + solar1.destructible = false + solar1.minable = false + solar2.destructible = false + solar2.minable = false + combipower.destructible = false + combipower.minable = false + speaker.destructible = false + speaker.minable = false + + for _, x in pairs({-1, 0}) do for i = 1, 12, 1 do local step = math_floor((i-1)/4) @@ -213,11 +268,18 @@ local function create_wagon_room() local y = -0.7 * height + 18 + 9 + 18 * ( math_floor((i - 1) / 3)) local x = -0.5 * width + 5 + 9 + 18 * ( i%3 ) local substation = surface.create_entity({name = "substation", position = {x,y}, force="player", create_build_effect_smoke = false}) + if i == 3 then + substation.disconnect_neighbour(combipower) + substation.connect_neighbour({wire = defines.wire_type.green, target_entity = combipower}) + end substation.minable = false substation.destructible = false for j = 1, 4, 1 do local xx = x - 2 * j local acumulator = surface.create_entity({name = "accumulator", position = {xx,y}, force="player", create_build_effect_smoke = false}) + if i == 3 and j == 1 then + acumulator.connect_neighbour({wire = defines.wire_type.green, target_entity = substation}) + end acumulator.minable = false acumulator.destructible = false table.insert(global.acumulators, acumulator) @@ -237,60 +299,52 @@ local function create_wagon_room() powerpole.destructible = false local market = surface.create_entity({name = "market", position = {-5, height * -0.5 + 13}, force="neutral", create_build_effect_smoke = false}) - local repairchest = surface.create_entity({name = "compilatron-chest", position = {0, height * -0.5 + 13}, force = "player"}) - local hpchest = surface.create_entity({name = "compilatron-chest", position = {3, height * -0.5 + 12}, force = "player"}) - local filterchest = surface.create_entity({name = "compilatron-chest", position = {4, height * -0.5 + 12}, force = "player"}) - local acuchest = surface.create_entity({name = "compilatron-chest", position = {5, height * -0.5 + 12}, force = "player"}) - local playerchest = surface.create_entity({name = "compilatron-chest", position = {3, height * -0.5 + 13}, force = "player"}) - local invchest = surface.create_entity({name = "compilatron-chest", position = {4, height * -0.5 + 13}, force = "player"}) - local toolschest = surface.create_entity({name = "compilatron-chest", position = {5, height * -0.5 + 13}, force = "player"}) - local waterchest = surface.create_entity({name = "compilatron-chest", position = {3, height * -0.5 + 14}, force = "player"}) - local outchest = surface.create_entity({name = "compilatron-chest", position = {4, height * -0.5 + 14}, force = "player"}) - local boxchest = surface.create_entity({name = "compilatron-chest", position = {5, height * -0.5 + 14}, force = "player"}) - repairchest.minable = false - repairchest.destructible = false - hpchest.minable = false - hpchest.destructible = false - filterchest.minable = false - filterchest.destructible = false - acuchest.minable = false - acuchest.destructible = false - playerchest.minable = false - playerchest.destructible = false - invchest.minable = false - invchest.destructible = false - toolschest.minable = false - toolschest.destructible = false - waterchest.minable = false - waterchest.destructible = false - outchest.minable = false - outchest.destructible = false - boxchest.minable = false - boxchest.destructible = false market.minable = false market.destructible = false - global.repairchest = repairchest - global.hpchest = hpchest - global.filterchest = filterchest - global.acuchest = acuchest - global.playerchest = playerchest - global.invchest = invchest - global.toolschest = toolschest - global.waterchest = waterchest - global.outchest = outchest - global.boxchest = boxchest - local repair_text = rendering.draw_text{ - text = "Repair chest", - surface = surface, - target = global.repairchest, - target_offset = {0, -2.5}, - color = global.locomotive.color, - scale = 1.00, - font = "default-game", - alignment = "center", - scale_with_zoom = false + local upgradechests = { + [1] = {name = "repairchest", entity = {name = "compilatron-chest", position = {0, height * -0.5 + 13}, force = "player"}, signal = nil}, + [2] = {name = "hpchest", entity = {name = "compilatron-chest", position = {3, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-1"}, + [3] = {name = "filterchest", entity = {name = "compilatron-chest", position = {4, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-2"}, + [4] = {name = "acuchest", entity = {name = "compilatron-chest", position = {5, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-3"}, + [5] = {name = "reachchest", entity = {name = "compilatron-chest", position = {3, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-4"}, + [6] = {name = "invchest", entity = {name = "compilatron-chest", position = {4, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-5"}, + [7] = {name = "toolschest", entity = {name = "compilatron-chest", position = {5, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-6"}, + [8] = {name = "waterchest", entity = {name = "compilatron-chest", position = {3, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-7"}, + [9] = {name = "outchest", entity = {name = "compilatron-chest", position = {4, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-8"}, + [10] = {name = "boxchest", entity = {name = "compilatron-chest", position = {5, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-9"}, + [11] = {name = "poisonchest", entity = {name = "compilatron-chest", position = {6, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-P"} } + + for i = 1, #upgradechests, 1 do + local e = surface.create_entity(upgradechests[i].entity) + e.minable = false + e.destructible = false + global.upgradechest[i] = e + if i == 1 then + local repair_text = rendering.draw_text{ + text = "Repair chest", + surface = surface, + target = e, + target_offset = {0, -2.5}, + color = global.locomotive.color, + scale = 1.00, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + else + local upgrade_text = rendering.draw_sprite{ + sprite = upgradechests[i].signal, + surface = surface, + target = e, + target_offset = {0, -0.1}, + font = "default-game", + visible = true + } + end + end + local market1_text = rendering.draw_text{ text = "Resources", surface = surface, @@ -305,7 +359,7 @@ local function create_wagon_room() local upgrade_text = rendering.draw_text{ text = "Upgrades", surface = surface, - target = filterchest, + target = global.upgradechest[3], target_offset = {0, -3.5}, color = global.locomotive.color, scale = 1.00, @@ -316,7 +370,7 @@ local function create_wagon_room() local upgrade_sub_text = rendering.draw_text{ text = "Click [Upgrades] on top of screen", surface = surface, - target = filterchest, + target = global.upgradechest[3], target_offset = {0, -2.5}, color = global.locomotive.color, scale = 0.80, @@ -324,78 +378,7 @@ local function create_wagon_room() alignment = "center", scale_with_zoom = false } - local upgrade1_text = rendering.draw_sprite{ - sprite = "virtual-signal/signal-1", - surface = surface, - target = hpchest, - target_offset = {0, -0.1}, - font = "default-game", - visible = true - } - local upgrade2_text = rendering.draw_sprite{ - sprite = "virtual-signal/signal-2", - surface = surface, - target = filterchest, - target_offset = {0, -0.1}, - font = "default-game", - visible = true - } - local upgrade3_text = rendering.draw_sprite{ - sprite = "virtual-signal/signal-3", - surface = surface, - target = acuchest, - target_offset = {0, -0.1}, - font = "default-game", - visible = true - } - local upgrade4_text = rendering.draw_sprite{ - sprite = "virtual-signal/signal-4", - surface = surface, - target = playerchest, - target_offset = {0, -0.1}, - font = "default-game", - visible = true - } - local upgrade5_text = rendering.draw_sprite{ - sprite = "virtual-signal/signal-5", - surface = surface, - target = invchest, - target_offset = {0, -0.1}, - font = "default-game", - visible = true - } - local upgrade6_text = rendering.draw_sprite{ - sprite = "virtual-signal/signal-6", - surface = surface, - target = toolschest, - target_offset = {0, -0.1}, - font = "default-game", - visible = true - } - local upgrade7_text = rendering.draw_sprite{ - sprite = "virtual-signal/signal-7", - surface = surface, - target = waterchest, - target_offset = {0, -0.1}, - font = "default-game", - visible = true - } - local upgrade8_text = rendering.draw_sprite{ - sprite = "virtual-signal/signal-8", - surface = surface, - target = outchest, - target_offset = {0, -0.1}, - font = "default-game", - visible = true - } - local upgrade9_text = rendering.draw_sprite{ - sprite = "virtual-signal/signal-9", - surface = surface, - target = boxchest, - target_offset = {0, -0.1}, - font = "default-game", - visible = true - } + for _, offer in pairs(market_offers) do market.add_market_item(offer) end diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index cb36b768..33308b9a 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -3,6 +3,7 @@ require "functions.soft_reset" require "player_modifiers" require "functions.basic_markets" +require "modules.difficulty_vote" require "modules.biters_yield_coins" require "modules.no_deconstruction_of_neutral_entities" @@ -36,6 +37,7 @@ global.flame_boots = {} global.comfylatron = nil global.lab_cells = {} + local choppy_entity_yield = { ["tree-01"] = {"iron-ore"}, ["tree-02-red"] = {"copper-ore"}, @@ -184,6 +186,8 @@ local function reset_map() objective.waterupgradetier = 0 objective.outupgradetier = 0 objective.boxupgradetier = 0 + objective.poisondefense = 2 + objective.poisontimeout = 0 objective.chronojumps = 0 objective.chronotimer = 0 objective.passivetimer = 0 @@ -193,6 +197,7 @@ local function reset_map() objective.unit_groups = {} objective.biter_raffle = {} global.outchests = {} + global.upgradechest = {} @@ -214,7 +219,7 @@ local function reset_map() game.map_settings.pollution.pollution_per_tree_damage = 0.1 game.map_settings.pollution.ageing = 0.1 game.map_settings.pollution.diffusion_ratio = 0.1 - game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.75 + game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 5 game.forces["enemy"].evolution_factor = 0.0001 game.forces.player.technologies["land-mine"].enabled = false @@ -225,11 +230,10 @@ local function reset_map() Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, starting_cargo, starting_cargo) render_train_hp() game.reset_time_played() + global.difficulty_poll_closing_timeout = game.tick + 54000 + global.difficulty_player_votes = {} objective.game_lost = false - - - --set_difficulty() end @@ -274,7 +278,7 @@ local function repair_train() if not game.surfaces["cargo_wagon"] then return end if objective.game_lost == true then return end if objective.health < objective.max_health then - local inv = global.repairchest.get_inventory(defines.inventory.chest) + local inv = global.upgradechest[1].get_inventory(defines.inventory.chest) local count = inv.get_item_count("repair-pack") if count >= 5 and objective.toolsupgradetier == 4 and objective.health + 750 <= objective.max_health then inv.remove({name = "repair-pack", count = 5}) @@ -391,7 +395,7 @@ local function chronojump(choice) Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, items, items2) render_train_hp() game.delete_surface(oldsurface) - if objective.chronojumps <= 40 then + if objective.chronojumps + objective.passivejumps <= 40 then game.forces["enemy"].evolution_factor = 0 + 0.025 * (objective.chronojumps + objective.passivejumps) else game.forces["enemy"].evolution_factor = 1 @@ -402,6 +406,7 @@ local function chronojump(choice) game.forces.scrapyard.set_turret_attack_modifier("gun-turret", 0.01 * objective.chronojumps) game.forces.enemy.set_ammo_damage_modifier("melee", 0.1 * objective.passivejumps) game.forces.enemy.set_ammo_damage_modifier("biological", 0.1 * objective.passivejumps) + game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.8 end local function check_chronoprogress() @@ -435,7 +440,7 @@ local function charge_chronosphere() if energy > 3000000 and objective.chronotimer < objective.chrononeeds - 182 and objective.chronotimer > 130 then acus[i].energy = acus[i].energy - 3000000 objective.chronotimer = objective.chronotimer + 1 - game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (10 + 2 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1))) + game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (10 + 2 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1)) * global.difficulty_vote_value) --log("energy charged from acu") end end @@ -444,7 +449,7 @@ end local function transfer_pollution() local surface = game.surfaces["cargo_wagon"] if not surface then return end - local pollution = surface.get_total_pollution() * (3 / (global.objective.filterupgradetier / 3 + 1)) + local pollution = surface.get_total_pollution() * (3 / (global.objective.filterupgradetier / 3 + 1)) * global.difficulty_vote_value game.surfaces[global.active_surface_index].pollute(global.locomotive.position, pollution) surface.clear_pollution() end @@ -476,6 +481,9 @@ local function tick() if tick % 600 == 0 then charge_chronosphere() transfer_pollution() + if global.objective.poisontimeout > 0 then + global.objective.poisontimeout = global.objective.poisontimeout - 1 + end end if tick % 1800 == 0 then Locomotive.set_player_spawn_and_refill_fish() @@ -556,6 +564,20 @@ function set_objective_health(final_damage_amount) for _, player in pairs(game.connected_players) do player.play_sound{path="utility/game_lost", volume_modifier=0.75} end + return + end + if objective.health < objective.max_health / 2 and final_damage_amount > 0 and objective.poisondefense > 0 and objective.poisontimeout == 0 then + objective.poisondefense = objective.poisondefense - 1 + objective.poisontimeout = 120 + local objs = {global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} + local surface = objective.surface + game.print("Comfylatron: Triggering poison defense. Let's kill everything!", {r=0.98, g=0.66, b=0.22}) + for i = 1, 4, 1 do + surface.create_entity({name = "poison-capsule", position = objs[i].position, force = "player", target = objs[i], speed = 1 }) + end + for i = 1 , #global.comfychests, 1 do + surface.create_entity({name = "poison-capsule", position = global.comfychests[i].position, force = "player", target = global.comfychests[i], speed = 1 }) + end end rendering.set_text(objective.health_text, "HP: " .. objective.health .. " / " .. objective.max_health) end diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index 3ae6f7fd..d7779cb0 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -75,17 +75,17 @@ end local function get_size_of_ore(ore, planet) local base_size = 0.04 + 0.04 * planet[1].ore_richness.factor local final_size = 1 - if planet[1].name.name == "iron planet" and ore == "iron-ore" then + if planet[1].name.id == 1 and ore == "iron-ore" then --iron planet final_size = base_size * 5 - elseif planet[1].name.name == "copper planet" and ore == "copper-ore" then + elseif planet[1].name.id == 2 and ore == "copper-ore" then --copper planet final_size = base_size * 5 - elseif planet[1].name.name == "stone planet" and ore == "stone" then + elseif planet[1].name.id == 3 and ore == "stone" then --stone planet final_size = base_size * 5 - elseif planet[1].name.name == "coal planet" and ore == "coal" then + elseif planet[1].name.id == 9 and ore == "coal" then --coal planet final_size = base_size * 5 - elseif planet[1].name.name == "uranium planet" and ore == "uranium-ore" then + elseif planet[1].name.id == 5 and ore == "uranium-ore" then --uranium planet final_size = base_size * 5 - elseif planet[1].name.name == "mixed planet" then + elseif planet[1].name.id == 6 then --mixed planet final_size = base_size * 2 else final_size = base_size / 2 @@ -147,7 +147,7 @@ local function process_hedgemaze_position(p, seed, tiles, entities, treasure, pl tiles[#tiles + 1] = {name = "water", position = p} return elseif things == "prospect" then - if math_random(1,202 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 250 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + if math_random(1,252 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 300 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end elseif things == "camp" then if p.x % 32 > 12 and p.x % 32 < 20 and p.y % 32 > 12 and p.y % 32 < 20 and math_random(1,6) == 1 then treasure[#treasure + 1] = p @@ -165,7 +165,7 @@ local function process_hedgemaze_position(p, seed, tiles, entities, treasure, pl end end else - if math_random(1, 100) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then + if math_random(1, 150) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 200 then entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p} end end @@ -186,7 +186,7 @@ local function process_hedgemaze_position(p, seed, tiles, entities, treasure, pl tiles[#tiles + 1] = {name = "water", position = p} return elseif things == "prospect" then - if math_random(1,202 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 250 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end + if math_random(1,252 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 300 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end elseif things == "camp" then if p.x % 32 > 12 and p.x % 32 < 20 and p.y % 32 > 12 and p.y % 32 < 20 and math_random(1,6) == 1 then treasure[#treasure + 1] = p @@ -201,7 +201,7 @@ local function process_hedgemaze_position(p, seed, tiles, entities, treasure, pl end end else - if math_random(1, 100) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then + if math_random(1, 150) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 200 then entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p} end end @@ -416,7 +416,7 @@ local function process_biter_position(p, seed, tiles, entities, treasure, planet end if scrapyard + 0.5 > -0.1 - 0.1 * planet[1].name.moisture and scrapyard + 0.5 < 0.1 + 0.1 * planet[1].name.moisture then local treetypes = tree_raffle[math_random(1, s_tree_raffle)] - if planet[1].name.name == "lava planet" then treetypes = dead_tree_raffle[math_random(1, 5)] end + if planet[1].name.id == 14 then treetypes = dead_tree_raffle[math_random(1, 5)] end --lava planet if math_random(1,100) > 42 - handicap / 6 then entities[#entities + 1] = {name = treetypes , position = p} end end diff --git a/maps/chronosphere/treasure.lua b/maps/chronosphere/treasure.lua index 0e5486cb..23f22a64 100644 --- a/maps/chronosphere/treasure.lua +++ b/maps/chronosphere/treasure.lua @@ -29,8 +29,8 @@ function Public.treasure_chest(surface, position, container_name) {{name = "firearm-magazine", count = math_random(32,128)}, weight = 5, d_min = 0, d_max = 0.3}, {{name = "piercing-rounds-magazine", count = math_random(32,128)}, weight = 5, d_min = 0.1, d_max = 0.8}, {{name = "uranium-rounds-magazine", count = math_random(32,128)}, weight = 5, d_min = 0.5, d_max = 1}, - {{name = "railgun", count = 1}, weight = 1, d_min = 0.2, d_max = 1}, - {{name = "railgun-dart", count = math_random(16,32)}, weight = 3, d_min = 0.2, d_max = 0.7}, + --{{name = "railgun", count = 1}, weight = 1, d_min = 0.2, d_max = 1}, + {{name = "railgun-dart", count = math_random(16,32)}, weight = 4, d_min = 0, d_max = 1}, {{name = "defender-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.0, d_max = 0.7}, {{name = "distractor-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.2, d_max = 1}, {{name = "destroyer-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.3, d_max = 1}, diff --git a/maps/chronosphere/upgrades.lua b/maps/chronosphere/upgrades.lua index b08259d5..916b170f 100644 --- a/maps/chronosphere/upgrades.lua +++ b/maps/chronosphere/upgrades.lua @@ -22,12 +22,12 @@ local function check_upgrade_hp() local objective = global.objective if not game.surfaces["cargo_wagon"] then return end if objective.game_lost == true then return end - if global.hpchest and global.hpchest.valid then - local inv = global.hpchest.get_inventory(defines.inventory.chest) + if global.upgradechest[2] and global.upgradechest[2].valid then + local inv = global.upgradechest[2].get_inventory(defines.inventory.chest) local countcoins = inv.get_item_count("coin") local count2 = inv.get_item_count("copper-plate") - local coincost = math_floor(2000 * (1 + objective.hpupgradetier /4)) - if countcoins >= coincost and count2 >= 3000 and objective.hpupgradetier < 18 then + local coincost = math_floor(500 * (1 + objective.hpupgradetier /2)) + if countcoins >= coincost and count2 >= 1500 and objective.hpupgradetier < 36 then inv.remove({name = "coin", count = coincost}) inv.remove({name = "copper-plate", count = 3000}) game.print("Comfylatron: Train's max HP was upgraded.", {r=0.98, g=0.66, b=0.22}) @@ -40,8 +40,8 @@ end local function check_upgrade_filter() local objective = global.objective - if global.filterchest and global.filterchest.valid then - local inv = global.filterchest.get_inventory(defines.inventory.chest) + if global.upgradechest[3] and global.upgradechest[3].valid then + local inv = global.upgradechest[3].get_inventory(defines.inventory.chest) local countcoins = inv.get_item_count("coin") local count2 = inv.get_item_count("electronic-circuit") if countcoins >= 5000 and count2 >= 2000 and objective.filterupgradetier < 9 and objective.chronojumps >= (objective.filterupgradetier + 1) * 3 then @@ -55,8 +55,8 @@ end local function check_upgrade_acu() local objective = global.objective - if global.acuchest and global.acuchest.valid then - local inv = global.acuchest.get_inventory(defines.inventory.chest) + if global.upgradechest[4] and global.upgradechest[4].valid then + local inv = global.upgradechest[4].get_inventory(defines.inventory.chest) local countcoins = inv.get_item_count("coin") local count2 = inv.get_item_count("battery") local coincost = math_floor(2000 * (1 + objective.acuupgradetier /4)) @@ -72,8 +72,8 @@ end local function check_upgrade_pickup() local objective = global.objective - if global.playerchest and global.playerchest.valid then - local inv = global.playerchest.get_inventory(defines.inventory.chest) + if global.upgradechest[5] and global.upgradechest[5].valid then + local inv = global.upgradechest[5].get_inventory(defines.inventory.chest) local countcoins = inv.get_item_count("coin") local count2 = inv.get_item_count("long-handed-inserter") local coincost = 1000 * (1 + objective.pickupupgradetier) @@ -89,8 +89,8 @@ end local function check_upgrade_inv() local objective = global.objective - if global.invchest and global.invchest.valid then - local inv = global.invchest.get_inventory(defines.inventory.chest) + if global.upgradechest[6] and global.upgradechest[6].valid then + local inv = global.upgradechest[6].get_inventory(defines.inventory.chest) local countcoins = inv.get_item_count("coin") local item = "computer" if objective.invupgradetier == 0 then @@ -116,8 +116,8 @@ end local function check_upgrade_tools() local objective = global.objective - if global.toolschest and global.toolschest.valid then - local inv = global.toolschest.get_inventory(defines.inventory.chest) + if global.upgradechest[7] and global.upgradechest[7].valid then + local inv = global.upgradechest[7].get_inventory(defines.inventory.chest) local countcoins = inv.get_item_count("coin") local count2 = inv.get_item_count("repair-pack") local coincost = 1000 * (1 + objective.toolsupgradetier) @@ -133,8 +133,8 @@ end local function check_upgrade_water() local objective = global.objective - if global.waterchest and global.waterchest.valid and game.surfaces["cargo_wagon"].valid then - local inv = global.waterchest.get_inventory(defines.inventory.chest) + if global.upgradechest[8] and global.upgradechest[8].valid and game.surfaces["cargo_wagon"].valid then + local inv = global.upgradechest[8].get_inventory(defines.inventory.chest) local countcoins = inv.get_item_count("coin") local count2 = inv.get_item_count("pipe") if countcoins >= 2000 and count2 >= 500 and objective.waterupgradetier < 1 then @@ -154,8 +154,8 @@ end local function check_upgrade_out() local objective = global.objective - if global.outchest and global.outchest.valid and game.surfaces["cargo_wagon"].valid then - local inv = global.outchest.get_inventory(defines.inventory.chest) + if global.upgradechest[9] and global.upgradechest[9].valid and game.surfaces["cargo_wagon"].valid then + local inv = global.upgradechest[9].get_inventory(defines.inventory.chest) local countcoins = inv.get_item_count("coin") local count2 = inv.get_item_count("fast-inserter") if countcoins >= 2000 and count2 >= 100 and objective.outupgradetier < 1 then @@ -188,8 +188,8 @@ end local function check_upgrade_box() local objective = global.objective - if global.boxchest and global.boxchest.valid and game.surfaces["cargo_wagon"].valid then - local inv = global.boxchest.get_inventory(defines.inventory.chest) + if global.upgradechest[10] and global.upgradechest[10].valid and game.surfaces["cargo_wagon"].valid then + local inv = global.upgradechest[10].get_inventory(defines.inventory.chest) local countcoins = inv.get_item_count("coin") local item = "computer" if objective.boxupgradetier == 0 then @@ -253,9 +253,26 @@ local function check_upgrade_box() end end +function check_poisondefense() + local objective = global.objective + if global.upgradechest[11] and global.upgradechest[11].valid then + local inv = global.upgradechest[11].get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("poison-capsule") + if countcoins >= 1000 and count2 >= 50 and objective.poisondefense < 4 then + inv.remove({name = "coin", count = 1000}) + inv.remove({name = "pipe", count = 50}) + game.print("Comfylatron: I don't believe in your defense skills. I equipped train with poison defense.", {r=0.98, g=0.66, b=0.22}) + objective.posiondefense = objective.posiondefense + 1 + end + end +end + + function Public.check_upgrades() local objective = global.objective - if objective.hpupgradetier < 18 then + if not global.upgradechest then return end + if objective.hpupgradetier < 36 then check_upgrade_hp() end if objective.filterupgradetier < 9 then @@ -282,6 +299,9 @@ function Public.check_upgrades() if objective.boxupgradetier < 4 and objective.chronojumps >= (objective.boxupgradetier + 1) * 5 then check_upgrade_box() end + if objective.poisondefense < 1 then + check_poisondefense() + end end return Public From 0a76381307534b771435aa2167bc4d3b9d13609e Mon Sep 17 00:00:00 2001 From: hanakocz Date: Fri, 21 Feb 2020 06:25:19 +0100 Subject: [PATCH 15/70] wagons remember filters, tiny cleanup --- maps/chronosphere/locomotive.lua | 18 +++++++++-- maps/chronosphere/main.lua | 52 +++++++++++++++++++++----------- maps/chronosphere/ores.lua | 12 ++++---- 3 files changed, 55 insertions(+), 27 deletions(-) diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index 837ad12b..f608d23d 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -3,7 +3,7 @@ local math_floor = math.floor local math_random = math.random -function Public.locomotive_spawn(surface, position, items, items2) +function Public.locomotive_spawn(surface, position, wagons) for y = -10, 18, 2 do local rail = {name = "straight-rail", position = {position.x, position.y + y}, force = "player", direction = 0} surface.create_entity({name = "straight-rail", position = {position.x, position.y + y}, force = "player", direction = 0}) @@ -15,14 +15,20 @@ function Public.locomotive_spawn(surface, position, items, items2) global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 100}) global.locomotive_cargo2 = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 6}, force = "player"}) - for item, count in pairs(items) do + for item, count in pairs(wagons[1].inventory) do global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) end global.locomotive_cargo3 = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 13}, force = "player"}) - for item, count in pairs(items) do + for item, count in pairs(wagons[2].inventory) do global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) end + if wagons[1].bar > 0 then global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).set_bar(wagons[1].bar) end + if wagons[2].bar > 0 then global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).set_bar(wagons[2].bar) end + for i = 1, 40, 1 do + global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).set_filter(i, wagons[1].filters[i]) + global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).set_filter(i, wagons[2].filters[i]) + end if not global.comfychests then global.comfychests = {} end if not global.acumulators then global.acumulators = {} end @@ -248,8 +254,14 @@ local function create_wagon_room() solar2.minable = false combipower.destructible = false combipower.minable = false + combipower.operable = false speaker.destructible = false speaker.minable = false + speaker.operable = false + checker.destructible = false + checker.minable = false + checker.operable = false + for _, x in pairs({-1, 0}) do diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 33308b9a..060073a0 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -54,10 +54,10 @@ local function generate_overworld(surface, optplanet) local message = "Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name game.print(message, {r=0.98, g=0.66, b=0.22}) Server.to_discord_embed(message) - if planet[1].name.name == "choppy planet" then + if planet[1].name.id == 12 then game.print("Comfylatron: OwO what are those strange trees?!? They have ore fruits! WTF!", {r=0.98, g=0.66, b=0.22}) - elseif planet[1].name.name == "lava planet" then - game.print("Comfylatron: OOF this one is a bit hot. And have seen those biters? They BATHE in fire!", {r=0.98, g=0.66, b=0.22}) + elseif planet[1].name.id == 14 then + game.print("Comfylatron: OOF this one is a bit hot. And have seen those biters? They BATHE in fire! Maybe try some bricks to protect from lava?", {r=0.98, g=0.66, b=0.22}) end surface.min_brightness = 0 surface.brightness_visual_weights = {1, 1, 1} @@ -78,17 +78,17 @@ local function generate_overworld(surface, optplanet) mgs.property_expression_names["control-setting:moisture:bias"] = moisture surface.map_gen_settings = mgs end - if planet[1].name.name == "water planet" then + if planet[1].name.id == 8 then --water planet local mgs = surface.map_gen_settings mgs.water = 0.8 surface.map_gen_settings = mgs end - if planet[1].name.name == "lava planet" then + if planet[1].name.id == 14 then --lava planet local mgs = surface.map_gen_settings mgs.water = 0 surface.map_gen_settings = mgs end - if planet[1].name.name ~= "choppy planet" then + if planet[1].name.id ~= 12 then --choppy planet local mgs = surface.map_gen_settings mgs.water = 0.2 surface.map_gen_settings = mgs @@ -226,8 +226,14 @@ local function reset_map() game.forces.player.technologies["landfill"].enabled = false game.forces.player.technologies["railway"].researched = true game.forces.player.set_spawn_position({12, 10}, surface) - - Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, starting_cargo, starting_cargo) + local wagons = {} + wagons[1] = {inventory = starting_cargo, bar = 0, filters = {}} + wagons[2] = {inventory = starting_cargo, bar = 0, filters = {}} + for i = 1, 40, 1 do + wagons[1].filters[i] = nil + wagons[2].filters[i] = nil + end + Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, wagons) render_train_hp() game.reset_time_played() global.difficulty_poll_closing_timeout = game.tick + 54000 @@ -388,17 +394,27 @@ local function chronojump(choice) planet = global.objective.planet end generate_overworld(surface, planet) + if objective.chronojumps == 6 then game.print("Comfylatron: Biters start to evolve faster! We need to charge forward or they will be stronger! (hover over timer to see evolve timer)", {r=0.98, g=0.66, b=0.22}) end if overstayed then game.print("Comfylatron: Looks like you stayed on previous planet for so long that enemies on other planets had additional time to evolve!", {r=0.98, g=0.66, b=0.22}) end game.forces.player.set_spawn_position({12, 10}, surface) - local items = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).get_contents() - local items2 = global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).get_contents() - Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, items, items2) + local inventories = {one = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon), two = global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon)} + inventories.one.sort_and_merge() + inventories.two.sort_and_merge() + local wagons = {} + wagons[1] = {inventory = inventories.one.get_contents(), bar = inventories.one.get_bar(), filters = {}} + wagons[2] = {inventory = inventories.two.get_contents(), bar = inventories.two.get_bar(), filters = {}} + for i = 1, 40, 1 do + wagons[1].filters[i] = inventories.one.get_filter(i) + wagons[2].filters[i] = inventories.two.get_filter(i) + end + Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, wagons) render_train_hp() game.delete_surface(oldsurface) + game.forces.enemy.reset_evolution() if objective.chronojumps + objective.passivejumps <= 40 then - game.forces["enemy"].evolution_factor = 0 + 0.025 * (objective.chronojumps + objective.passivejumps) + game.forces.enemy.evolution_factor = 0 + 0.025 * (objective.chronojumps + objective.passivejumps) else - game.forces["enemy"].evolution_factor = 1 + game.forces.enemy.evolution_factor = 1 end game.map_settings.enemy_evolution.time_factor = 7e-05 + 3e-06 * (objective.chronojumps + objective.passivejumps) surface.pollute(global.locomotive.position, 150 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps)) @@ -626,7 +642,7 @@ local function on_entity_damaged(event) if not event.entity.valid then return end if not event.entity.health then return end biters_chew_rocks_faster(event) - if global.objective.planet[1].name.name == "lava planet" and event.entity.force.name == "enemy" then + if global.objective.planet[1].name.id == 14 and event.entity.force.name == "enemy" then --lava planet if event.damage_type.name == "fire" then event.entity.health = event.entity.health + event.final_damage_amount local fire = event.entity.stickers @@ -663,7 +679,7 @@ local function pre_player_mined_item(event) local surface = game.surfaces[global.active_surface_index] local player = game.players[event.player_index] local objective = global.objective - if objective.planet[1].name.name == "rocky planet" then + if objective.planet[1].name.id == 11 then --rocky planet if event.entity.name == "rock-huge" or event.entity.name == "rock-big" or event.entity.name == "sand-rock-big" then trap(event.entity, false) event.entity.destroy() @@ -690,7 +706,7 @@ end local function on_player_mined_entity(event) local entity = event.entity if not entity.valid then return end - if entity.type == "tree" and global.objective.planet[1].name.name == "choppy planet" then + if entity.type == "tree" and global.objective.planet[1].name.id == 12 then --choppy planet trap(entity, false) if choppy_entity_yield[entity.name] then if event.buffer then event.buffer.clear() end @@ -746,7 +762,7 @@ end local function on_entity_died(event) - if event.entity.type == "tree" and global.objective.planet[1].name.name == "choppy planet" then + if event.entity.type == "tree" and global.objective.planet[1].name.id == 12 then --choppy planet if event.cause then if event.cause.valid then if event.cause.force.index ~= 2 then @@ -833,7 +849,7 @@ end -- end local function on_player_changed_position(event) - if global.objective.planet[1].name.name ~= "lava planet" then return end + if global.objective.planet[1].name.id ~= 14 then return end --lava planet local player = game.players[event.player_index] if not player.character then return end if player.character.driving then return end diff --git a/maps/chronosphere/ores.lua b/maps/chronosphere/ores.lua index 9a23cf10..2c1d3921 100644 --- a/maps/chronosphere/ores.lua +++ b/maps/chronosphere/ores.lua @@ -46,17 +46,17 @@ end local function get_size_of_ore(ore, planet) local base_size = math_random(5, 10) + math_floor(planet[1].ore_richness.factor * 3) local final_size = 1 - if planet[1].name.name == "iron planet" and ore == "iron-ore" then + if planet[1].name.id == 1 and ore == "iron-ore" then --iron planet final_size = math_floor(base_size * 1.5) - elseif planet[1].name.name == "copper planet" and ore == "copper-ore" then + elseif planet[1].name.id == 2 and ore == "copper-ore" then --copper planet final_size = math_floor(base_size * 1.5) - elseif planet[1].name.name == "stone planet" and ore == "stone" then + elseif planet[1].name.id == 3 and ore == "stone" then --stone planet final_size = math_floor(base_size * 1.5) - elseif planet[1].name.name == "coal planet" and ore == "coal" then + elseif planet[1].name.id == 9 and ore == "coal" then --coal planet final_size = math_floor(base_size * 1.5) - elseif planet[1].name.name == "uranium planet" and ore == "uranium-ore" then + elseif planet[1].name.id == 5 and ore == "uranium-ore" then --uranium planet final_size = math_floor(base_size * 1.5) - elseif planet[1].name.name == "mixed planet" then + elseif planet[1].name.id == 6 then --mixed planet final_size = base_size else final_size = math_floor(base_size / 2) From 59a5bf92c4e4aa9b76517b26130bce92bedf7e03 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Fri, 21 Feb 2020 22:58:14 +0100 Subject: [PATCH 16/70] Win condition added - final level unlocking starts at jump 15, can be absolutely unlocked at jump 25. --- maps/chronosphere/ai.lua | 6 +- maps/chronosphere/chronobubles.lua | 19 ++- maps/chronosphere/gui.lua | 20 ++- maps/chronosphere/locomotive.lua | 7 +- maps/chronosphere/main.lua | 59 +++++++-- maps/chronosphere/terrain.lua | 194 ++++++++++++++++++++++++++++- maps/chronosphere/upgrades.lua | 90 +++++++++++++ 7 files changed, 371 insertions(+), 24 deletions(-) diff --git a/maps/chronosphere/ai.lua b/maps/chronosphere/ai.lua index 8a3287e2..908e1d27 100644 --- a/maps/chronosphere/ai.lua +++ b/maps/chronosphere/ai.lua @@ -24,7 +24,7 @@ local size_of_vectors = #attack_vectors -- these areas are for north local middle_spawner_area = {left_top = {-400, -400}, right_bottom = {400, 400}} -local whole_spawner_area = {left_top = {-500, -500}, right_bottom = {500, 500}} +local whole_spawner_area = {left_top = {-1100, -500}, right_bottom = {1100, 500}} local function get_active_biter_count() local count = 0 @@ -191,7 +191,7 @@ Public.send_near_biters_to_objective = function() local surface = random_target.surface local pollution = surface.get_pollution(random_target.position) local success = false - if pollution > 200 * (1 / global.difficulty_vote_value) then + if pollution > 200 * (1 / global.difficulty_vote_value) or global.objective.planet[1].name.id == 17 then surface.pollute(random_target.position, -50 * (1 / global.difficulty_vote_value)) --game.print("sending objective wave") success = true @@ -274,7 +274,7 @@ local function send_group(unit_group, nearest_player_unit) if not target.valid then colonize(unit_group) return end local surface = target.surface local pollution = surface.get_pollution(target.position) - if pollution > 200 * (1 / global.difficulty_vote_value) then + if pollution > 200 * (1 / global.difficulty_vote_value) or global.objective.planet[1].name.id == 17 then surface.pollute(target.position, -50 * (1 / global.difficulty_vote_value)) --game.print("sending unit group attack") local commands = {} diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua index f3cbc630..077b560f 100644 --- a/maps/chronosphere/chronobubles.lua +++ b/maps/chronosphere/chronobubles.lua @@ -18,7 +18,8 @@ local variants = { [13] = {id = 13, name = "river planet", iron = 1, copper = 1, coal = 3, stone = 1, uranium = 0, oil = 0, biters = 8, moisture = 0.5, chance = 2, cumul_chance = 23}, [14] = {id = 14, name = "lava planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 0, oil = 0, biters = 6, moisture = -0.5, chance = 1, cumul_chance = 24}, [15] = {id = 15, name = "start planet", iron = 4, copper = 3, coal = 4, stone = 3, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24}, - [16] = {id = 16, name = "hedge maze", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 1, oil = 2, biters = 16, moisture = -0.1, chance = 2, cumul_chance = 26} + [16] = {id = 16, name = "hedge maze", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 1, oil = 2, biters = 16, moisture = -0.1, chance = 2, cumul_chance = 26}, + [17] = {id = 17, name = "fish market", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 100, moisture = 0, chance = 0, cumul_chance = 26} } local time_speed_variants = { @@ -39,7 +40,8 @@ local richness = { [6] = {name = "normal", factor = 1}, [7] = {name = "poor", factor = 0.6}, [8] = {name = "poor", factor = 0.6}, - [9] = {name = "very poor", factor = 0.3} + [9] = {name = "very poor", factor = 0.3}, + [10] = {name = "none", factor = 0} } local function roll(weight) for i = 1, 100, 1 do @@ -56,13 +58,18 @@ local function roll(weight) end function Public.determine_planet(choice) + local objective = global.objective local weight = variants[#variants].cumul_chance local planet_choice = nil - local ores = math_random(1, #richness) - if global.objective.game_lost then + local ores = math_random(1, 9) + if objective.game_lost then choice = 15 ores = 2 end + if objective.computerupgrade == 3 then + choice = 17 + ores = 10 + end if not choice then planet_choice = roll(weight) else @@ -72,6 +79,8 @@ function Public.determine_planet(choice) planet_choice = roll(weight) end end + if objective.computerupgrade >= 1 and ores == 9 then ores = 8 end + if objective.computerupgrade >= 2 and ores > 6 and ores ~= 10 then ores = 6 end local planet = { [1] = { name = planet_choice, @@ -80,6 +89,6 @@ function Public.determine_planet(choice) ore_richness = richness[ores], } } - global.objective.planet = planet + objective.planet = planet end return Public diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index fbd47fa9..8e6a5984 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -138,7 +138,11 @@ local function update_gui(player) [7] = {t = "[7]: Add piping through wagon sides to create water sources for each wagon.\n Cost: 2000 coins + 500 pipes\n"}, [8] = {t = "[8]: Add comfylatron chests that output outside (into cargo wagon 2 and 3)\n Cost: 2000 coins + 100 fast inserters\n"}, [9] = {t = "[9]: Add storage chests to the sides of wagons.\n Buyable once per 5 jumps.\n Cost: 5000 coins + " .. chests[objective.boxupgradetier + 1].c}, - [10] = {t = "[P]: Poison defense. Triggers automatically when train has low HP.\n Actual charges: " .. objective.poisondefense .. " / 4\n Recharge timer for next use: " .. math_ceil(objective.poisontimeout /6) .. "min\n Cost: 1000 coins + 50 poison capsules\n"} + [10] = {t = "[P]: Poison defense. Triggers automatically when train has low HP.\n Actual charges: " .. objective.poisondefense .. " / 4\n Recharge timer for next use: " .. math_ceil(objective.poisontimeout /6) .. "min\n Cost: 1000 coins + 50 poison capsules\n"}, + [11] = {t = "[C]: Train computer fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 1 costs: 5000 coins, 1000 advanced circuits, 2000 copper plates.\n Discards very poor planets.\n"}, + [12] = {t = "[C]: Train power and navigation fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 2 costs: 10000 coins, 1000 processing units, 1 nuclear reactor.\n Discards poor planets.\n"}, + [13] = {t = "[C]: Train time machine processor fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 3 costs per part: 2000 coins, 100 rocket control units, 100 low density structures, 50 uranium fuel cells.\n Parts finished: " .. objective.computerparts .. " / 10\n"}, + [14] = {t = "[C]: Train is repaired. Synchronize the time to unlock final map to finish the main objective.\n Costs: 1 rocket silo, 1 satellite.\n Warning: after buying this, the next jump destination is locked to final map,\n that means 100% evolution and no resources.\n"} } local maxed = { [1] = {t = "[1]: Train HP maxed.\n"}, @@ -150,6 +154,7 @@ local function update_gui(player) [7] = {t = "[7]: Piping created. Don't spill it!\n"}, [8] = {t = "[8]: Output chests created.\n"}, [9] = {t = "[9]: Storage chests fully upgraded.\n"}, + [10] = {t = "[C]: Train's next destination is Fish Market.\n"} } local tooltip = "Insert needed items into chest with upgrade number.\nUpgrading can take a minute.\n\n" if objective.hpupgradetier < 36 then tooltip = tooltip .. upgt[1].t else tooltip = tooltip .. maxed[1].t end @@ -162,6 +167,19 @@ local function update_gui(player) if objective.outupgradetier < 1 then tooltip = tooltip .. upgt[8].t else tooltip = tooltip .. maxed[8].t end if objective.boxupgradetier < 4 then tooltip = tooltip .. upgt[9].t else tooltip = tooltip .. maxed[9].t end tooltip = tooltip .. upgt[10].t + if objective.computerupgrade == 0 and objective.chronojumps >= 15 then + tooltip = tooltip .. upgt[11].t + elseif objective.computerupgrade == 1 and objective.chronojumps >= 20 then + tooltip = tooltip .. upgt[12].t + elseif objective.computerupgrade == 2 and objective.chronojumps >= 25 then + if objective.computerparts < 10 then + tooltip = tooltip .. upgt[13].t + elseif objective.computerparts == 10 then + tooltip = tooltip .. upgt[14].t + end + elseif objective.computerupgrade == 3 and objective.chronojumps >= 25 then + tooltip = tooltip .. maxed[10].t + end gui.upgrades.tooltip = tooltip diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index f608d23d..8fb0dd44 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -4,6 +4,10 @@ local math_random = math.random function Public.locomotive_spawn(surface, position, wagons) + if global.objective.planet[1].name.id == 17 then + position.x = position.x - 960 + position.y = position.y - 64 + end for y = -10, 18, 2 do local rail = {name = "straight-rail", position = {position.x, position.y + y}, force = "player", direction = 0} surface.create_entity({name = "straight-rail", position = {position.x, position.y + y}, force = "player", direction = 0}) @@ -325,7 +329,8 @@ local function create_wagon_room() [8] = {name = "waterchest", entity = {name = "compilatron-chest", position = {3, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-7"}, [9] = {name = "outchest", entity = {name = "compilatron-chest", position = {4, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-8"}, [10] = {name = "boxchest", entity = {name = "compilatron-chest", position = {5, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-9"}, - [11] = {name = "poisonchest", entity = {name = "compilatron-chest", position = {6, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-P"} + [11] = {name = "poisonchest", entity = {name = "compilatron-chest", position = {6, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-P"}, + [12] = {name = "computerchest", entity = {name = "compilatron-chest", position = {6, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-C"} } for i = 1, #upgradechests, 1 do diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 060073a0..51451fa8 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -30,7 +30,7 @@ local update_gui = require "maps.chronosphere.gui" local math_random = math.random local math_floor = math.floor local math_sqrt = math.sqrt -local chests = {} +--local chests = {} --local acus = {} global.objective = {} global.flame_boots = {} @@ -58,6 +58,8 @@ local function generate_overworld(surface, optplanet) game.print("Comfylatron: OwO what are those strange trees?!? They have ore fruits! WTF!", {r=0.98, g=0.66, b=0.22}) elseif planet[1].name.id == 14 then game.print("Comfylatron: OOF this one is a bit hot. And have seen those biters? They BATHE in fire! Maybe try some bricks to protect from lava?", {r=0.98, g=0.66, b=0.22}) + elseif planet[1].name.id == 17 then + game.print("Comfylatron: So here we are. Fish Market. When they ordered the fish, they said this location is perfectly safe. Looks like we will have to do it for them. I hope you have enough nukes.", {r=0.98, g=0.66, b=0.22}) end surface.min_brightness = 0 surface.brightness_visual_weights = {1, 1, 1} @@ -93,11 +95,21 @@ local function generate_overworld(surface, optplanet) mgs.water = 0.2 surface.map_gen_settings = mgs end + if planet[1].name.id == 17 then --fish market + local mgs = surface.map_gen_settings + mgs.width = 2176 + surface.map_gen_settings = mgs + surface.request_to_generate_chunks({-960,-64}, 3) + --surface.request_to_generate_chunks({0,0}, 3) + surface.force_generate_chunk_requests() + else + surface.request_to_generate_chunks({0,0}, 3) + surface.force_generate_chunk_requests() + end --log(timer) --surface.solar_power_multiplier = 999 - surface.request_to_generate_chunks({0,0}, 3) - surface.force_generate_chunk_requests() + -- for x = -352 + 32, 352 - 32, 32 do -- surface.request_to_generate_chunks({x, 96}, 1) @@ -157,10 +169,14 @@ end local function reset_map() + global.chunk_queue = {} if game.surfaces["chronosphere"] then game.delete_surface(game.surfaces["chronosphere"]) end if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end - chests = {} + --chests = {} + local objective = global.objective + objective.computerupgrade = 0 + objective.computerparts = 0 local map_gen_settings = get_map_gen_settings() Planets.determine_planet(nil) local planet = global.objective.planet @@ -174,7 +190,7 @@ local function reset_map() local surface = game.surfaces[global.active_surface_index] generate_overworld(surface, planet) - local objective = global.objective + objective.max_health = 10000 objective.health = 10000 objective.hpupgradetier = 0 @@ -193,11 +209,13 @@ local function reset_map() objective.passivetimer = 0 objective.passivejumps = 0 objective.chrononeeds = 2000 + objective.mainscore = 0 objective.active_biters = {} objective.unit_groups = {} objective.biter_raffle = {} global.outchests = {} global.upgradechest = {} + global.fishchest = {} @@ -238,7 +256,11 @@ local function reset_map() game.reset_time_played() global.difficulty_poll_closing_timeout = game.tick + 54000 global.difficulty_player_votes = {} + if objective.game_won then + game.print("Comfylatron: WAIT whaat? Looks like we did not fixed the train properly and it teleported us back in time...sigh...so let's do this again, and now properly.", {r=0.98, g=0.66, b=0.22}) + end objective.game_lost = false + objective.game_won = false --set_difficulty() end @@ -394,7 +416,15 @@ local function chronojump(choice) planet = global.objective.planet end generate_overworld(surface, planet) - if objective.chronojumps == 6 then game.print("Comfylatron: Biters start to evolve faster! We need to charge forward or they will be stronger! (hover over timer to see evolve timer)", {r=0.98, g=0.66, b=0.22}) end + if objective.chronojumps == 6 then + game.print("Comfylatron: Biters start to evolve faster! We need to charge forward or they will be stronger! (hover over timer to see evolve timer)", {r=0.98, g=0.66, b=0.22}) + elseif objective.chronojumps == 15 then + game.print("Comfylatron: You know...I have big quest. Deliver fish to fish market. But this train is broken. Please help me fix the train computer!", {r=0.98, g=0.66, b=0.22}) + elseif objective.chronojumps == 20 then + game.print("Comfylatron: Ah, we need to give this machine more power and better navigation chipset. Please bring me some additional things.", {r=0.98, g=0.66, b=0.22}) + elseif objective.chronojumps == 25 then + game.print("Comfylatron: Finally found the main issue. We will need to rebuild whole processor. Exactly what I feared of. Just a few more things...", {r=0.98, g=0.66, b=0.22}) + end if overstayed then game.print("Comfylatron: Looks like you stayed on previous planet for so long that enemies on other planets had additional time to evolve!", {r=0.98, g=0.66, b=0.22}) end game.forces.player.set_spawn_position({12, 10}, surface) local inventories = {one = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon), two = global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon)} @@ -411,11 +441,14 @@ local function chronojump(choice) render_train_hp() game.delete_surface(oldsurface) game.forces.enemy.reset_evolution() - if objective.chronojumps + objective.passivejumps <= 40 then + if objective.chronojumps + objective.passivejumps <= 40 and objective.planet[1].name.id ~= 17 then game.forces.enemy.evolution_factor = 0 + 0.025 * (objective.chronojumps + objective.passivejumps) else game.forces.enemy.evolution_factor = 1 end + if objective.planet[1].name.id == 17 then + objective.chrononeeds = 200000000 + end game.map_settings.enemy_evolution.time_factor = 7e-05 + 3e-06 * (objective.chronojumps + objective.passivejumps) surface.pollute(global.locomotive.position, 150 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps)) game.forces.scrapyard.set_ammo_damage_modifier("bullet", 0.01 * objective.chronojumps) @@ -448,6 +481,7 @@ local function charge_chronosphere() local objective = global.objective if not objective.chronotimer then return end if objective.chronotimer < 20 then return end + if objective.planet[1].name.id == 17 then return end local acus = global.acumulators if #acus < 1 then return end for i = 1, #acus, 1 do @@ -488,7 +522,11 @@ local function tick() local tick = game.tick if tick % 60 == 30 and global.objective.chronotimer < 64 then local surface = game.surfaces[global.active_surface_index] - surface.request_to_generate_chunks({0,0}, 3 + math_floor(global.objective.chronotimer / 5)) + if global.objective.planet[1].name.id == 17 then + surface.request_to_generate_chunks({-800,0}, 3 + math_floor(global.objective.chronotimer / 5)) + else + surface.request_to_generate_chunks({0,0}, 3 + math_floor(global.objective.chronotimer / 5)) + end --surface.force_generate_chunk_requests() @@ -508,7 +546,7 @@ local function tick() end local key = tick % 3600 if tick_minute_functions[key] then tick_minute_functions[key]() end - if tick % 60 == 0 then + if tick % 60 == 0 and global.objective.planet[1].name.id ~= 17 then global.objective.chronotimer = global.objective.chronotimer + 1 global.objective.passivetimer = global.objective.passivetimer + 1 check_chronoprogress() @@ -537,6 +575,7 @@ local function on_init() T.main_caption_color = {r = 150, g = 150, b = 0} T.sub_caption_color = {r = 0, g = 150, b = 0} global.objective.game_lost = true + global.objective.game_won = false game.create_force("scrapyard") game.forces.scrapyard.set_friend('enemy', true) game.forces.enemy.set_friend('scrapyard', true) @@ -659,7 +698,7 @@ end local function trap(entity, trap) if trap then tick_tack_trap(entity.surface, entity.position) - tick_tack_trap(entity.surface, {x = entity.position.x + math_random(-3,3), y = entity.position.y + math_random(-3,3)}) + tick_tack_trap(entity.surface, {x = entity.position.x + math_random(-2,2), y = entity.position.y + math_random(-2,2)}) return end if math_random(1,256) == 1 then tick_tack_trap(entity.surface, entity.position) return end diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index d7779cb0..795c28a7 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -505,6 +505,85 @@ local function process_scrapyard_position(p, seed, tiles, entities, treasure, pl tiles[#tiles + 1] = {name = "stone-path", position = p} end +local function process_fish_position(p, seed, tiles, entities, treasure, planet) + local body_radius = 1984 --3072 + local body_square_radius = body_radius ^ 2 + local body_center_position = {x = 0, y = 0} + local body_spacing = math_floor(body_radius * 0.82) + local body_circle_center_1 = {x = body_center_position.x, y = body_center_position.y - body_spacing} + local body_circle_center_2 = {x = body_center_position.x, y = body_center_position.y + body_spacing} + + local fin_radius = 200 + local square_fin_radius = fin_radius ^ 2 + local fin_circle_center_1 = {x = -600, y = 0} + local fin_circle_center_2 = {x = -600 - 120, y = 0} + + --if math_abs(p.y) > 480 and p.x <= 160 and p.x > body_center_position.x then return true end + + --Main Fish Body + local distance_to_center_1 = ((p.x - body_circle_center_1.x)^2 + (p.y - body_circle_center_1.y)^2) + local distance_to_center_2 = ((p.x - body_circle_center_2.x)^2 + (p.y - body_circle_center_2.y)^2) + local distance_to_fin_1 = ((p.x - fin_circle_center_1.x)^2 + (p.y - fin_circle_center_1.y)^2) + local distance_to_fin_2 = ((p.x - fin_circle_center_2.x)^2 + (p.y - fin_circle_center_2.y)^2) + local eye_center = {x = -500, y = -150} + + + if distance_to_center_1 < body_square_radius and distance_to_center_2 < body_square_radius then + if p.x < -600 and p.x > -1090 and p.y < 64 and p.y > -64 then --mouth + local noise = simplex_noise(p.x * 0.006, 0, seed) * 20 + if p.y <= 12 + noise and p.y >= -12 + noise then + tiles[#tiles + 1] = {name = "water", position = p} + else + tiles[#tiles + 1] = {name = "grass-1", position = p} + local roll = math_random(1,500) + if roll < 4 and p.x > -800 then + entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} + elseif roll == 5 and p.x > -800 then + entities[#entities + 1] = {name = "behemoth-worm-turret", position = p} + elseif roll == 6 then + entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} + end + end + else + local distance = math_sqrt(((eye_center.x - p.x) ^ 2) + ((eye_center.y - p.y) ^ 2)) + if distance < 33 and distance >= 15 then --eye + tiles[#tiles + 1 ] = {name = "water-green", position = p} + elseif distance < 15 then --eye + tiles[#tiles + 1] = {name = "out-of-map", position = p} + else --rest + tiles[#tiles + 1 ] = {name = "grass-1", position = p} + local roll = math_random(1,500) + if roll < 4 and p.x > -800 then + entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} + elseif roll == 5 and p.x > -800 then + entities[#entities + 1] = {name = "behemoth-worm-turret", position = p} + elseif roll == 6 then + entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} + end + end + end + + -- elseif distance_to_fin_2 < square_fin_radius and distance_to_fin_1 + math_abs(simplex_noise(0, p.y * 0.075, seed) * 32000) > square_fin_radius then + -- tiles[#tiles + 1 ] = {name = "dirt-7", position = p} + else + if p.x > 800 and math_abs(p.y) < p.x - 800 then --tail + tiles[#tiles + 1 ] = {name = "grass-1", position = p} + local roll = math_random(1,500) + if roll < 4 and p.x > -800 then + entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} + elseif roll == 5 and p.x > -800 then + entities[#entities + 1] = {name = "behemoth-worm-turret", position = p} + elseif roll == 6 then + entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} + end + else + tiles[#tiles + 1 ] = {name = "out-of-map", position = p} + end + end + + +end + local levels = { process_level_1_position, process_level_2_position, @@ -515,7 +594,7 @@ local levels = { process_biter_position, process_scrapyard_position, process_level_9_position, - process_level_10_position, + process_fish_position, } local entity_functions = { @@ -643,6 +722,105 @@ local function empty_chunk(surface, left_top, level, planet) replace_water(surface, left_top) end +local function fish_market(surface, left_top, level, planet) + local tiles = {} + local entities = {} + --local markets = {} + local seed = surface.map_gen_settings.seed + local process_level = levels[level] + for y = 0, 31, 1 do + for x = 0, 31, 1 do + local p = {x = left_top.x + x, y = left_top.y + y} + process_level(p, seed, tiles, entities, treasure, planet) + end + end + surface.set_tiles(tiles, true) + local market = surface.create_entity({name = "market", force = "player", position = {x = left_top.x + 16, y = left_top.y + 16}}) + market.destructible = false + market.operable = false + market.minable = false + local repair_text = rendering.draw_text{ + text = "Fish Market", + surface = surface, + target = market, + target_offset = {0, -2.5}, + color = global.locomotive.color, + scale = 1.00, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + local fishchest = surface.create_entity({name = "compilatron-chest", force = "player", position = {x = left_top.x + 11, y = left_top.y + 16}}) + fishchest.destructible = false + fishchest.minable = false + fishchest.operable = false + global.fishchest = fishchest + local repair_text = rendering.draw_text{ + text = "Deposit fish here", + surface = surface, + target = fishchest, + target_offset = {0, -2.5}, + color = global.locomotive.color, + scale = 0.75, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + local inserter = surface.create_entity({name = "fast-inserter", force = "player", position = {x = left_top.x + 10, y = left_top.y + 16}, direction = defines.direction.west}) + inserter.destructible = false + inserter.minable = false + inserter.operable = false + inserter.rotatable = false + local track = surface.create_entity({name = "straight-rail", force = "player", position = {x = left_top.x + 8, y = left_top.y + 16}}) + track.destructible = false + track.minable = false + -- for _, entity in pairs(entities) do + -- if entity_functions[game.entity_prototypes[entity.name].type] then + -- entity_functions[game.entity_prototypes[entity.name].type](surface, entity) + -- else + -- if surface.can_place_entity(entity) then + -- local e = surface.create_entity(entity) + -- -- if e.name == "biter-spawner" or e.name == "spitter-spawner" or e.name == "small-worm-turret" or e.name == "medium-worm-turret" or e.name == "big-worm-turret" or e.name == "behemoth-worm-turret" then + -- -- if math_abs(e.position.x) > 420 or math_abs(e.position.y) > 420 then e.destructible = false end + -- -- end + -- end + -- end + -- end +end + +local function fish_chunk(surface, left_top, level, planet) + local tiles = {} + local entities = {} + --local markets = {} + local treasure = {} + local seed = surface.map_gen_settings.seed + local process_level = levels[level] + for y = 0, 31, 1 do + for x = 0, 31, 1 do + local p = {x = left_top.x + x, y = left_top.y + y} + process_level(p, seed, tiles, entities, treasure, planet) + end + end + surface.set_tiles(tiles, true) + for _, p in pairs(treasure) do + local name = "wooden-chest" + if math_random(1, 6) == 1 then name = "iron-chest" end + Treasure(surface, p, name) + end + for _, entity in pairs(entities) do + if entity_functions[game.entity_prototypes[entity.name].type] then + entity_functions[game.entity_prototypes[entity.name].type](surface, entity) + else + if surface.can_place_entity(entity) then + local e = surface.create_entity(entity) + -- if e.name == "biter-spawner" or e.name == "spitter-spawner" or e.name == "small-worm-turret" or e.name == "medium-worm-turret" or e.name == "big-worm-turret" or e.name == "behemoth-worm-turret" then + -- if math_abs(e.position.x) > 420 or math_abs(e.position.y) > 420 then e.destructible = false end + -- end + end + end + end +end + local function normal_chunk(surface, left_top, level, planet) local tiles = {} local entities = {} @@ -730,8 +908,11 @@ end local function process_chunk(surface, left_top) if not surface then return end if not surface.valid then return end - if left_top.x >= level_depth * 0.5 or left_top.y >= level_depth * 0.5 then return end - if left_top.x < level_depth * -0.5 or left_top.y < level_depth * -0.5 then return end + local planet = global.objective.planet + if planet[1].name.id == 17 then level_depth = 2176 end + if left_top.x >= level_depth * 0.5 or left_top.y >= level_depth * 0.5 then return end + if left_top.x < level_depth * -0.5 or left_top.y < level_depth * -0.5 then return end + --if left_top.y >= 0 then replace_water(surface, left_top) end @@ -740,7 +921,7 @@ local function process_chunk(surface, left_top) -- local p = global.locomotive.position -- for _, entity in pairs(surface.find_entities_filtered({area = {{p.x - 3, p.y - 4},{p.x + 3, p.y + 10}}, type = "simple-entity"})) do entity.destroy() end -- end - local planet = global.objective.planet + local id = planet[1].name.id --from chronobubbles if id == 10 then --scrapyard if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 8, planet) return end @@ -762,6 +943,11 @@ local function process_chunk(surface, left_top) elseif id == 16 then --hedge maze if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 3, planet) return end if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 3, planet) return end + elseif id == 17 then --fish market + --if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 3, planet) return end + --if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 3, planet) return end + if math_abs(left_top.y) <= 31 and math_abs(left_top.x - 864) <= 31 then fish_market(surface, left_top, 10, planet) return end + fish_chunk(surface, left_top, 10, planet) else if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 7, planet) return end if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then biter_chunk(surface, left_top, 7, planet) return end diff --git a/maps/chronosphere/upgrades.lua b/maps/chronosphere/upgrades.lua index 916b170f..f3f81cff 100644 --- a/maps/chronosphere/upgrades.lua +++ b/maps/chronosphere/upgrades.lua @@ -1,6 +1,7 @@ local Public = {} local math_floor = math.floor +local Server = require 'utils.server' local function spawn_acumulators() local x = -28 @@ -268,6 +269,87 @@ function check_poisondefense() end end +local function check_upgrade_computer() + local objective = global.objective + if global.upgradechest[12] and global.upgradechest[12].valid then + local inv = global.upgradechest[12].get_inventory(defines.inventory.chest) + local countcoins = inv.get_item_count("coin") + local count2 = inv.get_item_count("advanced-circuit") + local count3 = inv.get_item_count("processing-unit") + local count4 = inv.get_item_count("low-density-structure") + local count5 = inv.get_item_count("rocket-control-unit") + local count6 = inv.get_item_count("uranium-fuel-cell") + local count7 = inv.get_item_count("nuclear-reactor") + local count8 = inv.get_item_count("copper-plate") + local count9 = inv.get_item_count("rocket-silo") + local count10 = inv.get_item_count("satellite") + + if countcoins >= 5000 and count2 >= 1000 and count8 >= 2000 and objective.computerupgrade == 0 and objective.chronojumps >= 15 then + inv.remove({name = "coin", count = 5000}) + inv.remove({name = "advanced-circuit", count = 1000}) + inv.remove({name = "copper-plate", count = 2000}) + game.print("Comfylatron: Thanks for fixing train navigation. I can now get us rid of very poor worlds. It will still need more work though.", {r=0.98, g=0.66, b=0.22}) + objective.computerupgrade = objective.computerupgrade + 1 + elseif countcoins >= 10000 and count3 >= 1000 and count7 >= 1 and objective.computerupgrade == 1 and objective.chronojumps >= 20 then + inv.remove({name = "coin", count = 10000}) + inv.remove({name = "processing-unit", count = 1000}) + inv.remove({name = "nuclear-reactor", count = 1}) + objective.computerupgrade = objective.computerupgrade + 1 + game.print("Comfylatron: Perfect! Now we have train reactor and even better destination precision. I will get to you later what still needs to be done.", {r=0.98, g=0.66, b=0.22}) + elseif objective.computerupgrade == 2 and objective.chronojumps >= 25 then + if countcoins >= 2000 and count4 >= 100 and count5 >= 100 and count6 >= 50 and objective.computerparts < 10 then + inv.remove({name = "coin", count = 2000}) + inv.remove({name = "low-density-structure", count = 100}) + inv.remove({name = "rocket-control-unit", count = 100}) + inv.remove({name = "uranium-fuel-cell", count = 50 }) + objective.computerparts = objective.computerparts + 1 + if objective.computerparts < 10 then + game.print("Comfylatron: That's another processor part done! I still need " .. 10 - objective.computerparts .. " more of those parts.", {r=0.98, g=0.66, b=0.22}) + else + game.print("Comfylatron: And this was last part of cpu brain done. Now we just need to synchronize our time correctly and we are done! Bring me satellite and rocket silo.", {r=0.98, g=0.66, b=0.22}) + end + elseif objective.computerparts == 10 and count9 >= 1 and count10 >= 1 then + inv.remove({name = "satellite", count = 1 }) + inv.remove({name = "rocket-silo", count = 1 }) + game.print("Comfylatron: Time synchronized. Calculating time and space destination. Success. Jump once more and let me deliver the fish finally. This trip is getting long.", {r=0.98, g=0.66, b=0.22}) + objective.computerupgrade = objective.computerupgrade + 1 + end + end + end +end + +local function check_win() + local objective = global.objective + if global.fishchest then + if global.fishchest.valid then + local inv = global.fishchest.get_inventory(defines.inventory.chest) + local countfish = inv.get_item_count("raw-fish") + local enemies = game.surfaces[global.active_surface_index].count_entities_filtered{force = "enemy"} + if countfish > 0 then + inv.remove({name = "raw-fish", count = countfish}) + objective.mainscore = objective.mainscore + countfish + if enemies > 0 then + game.print("Comfylatron: You delivered fish, but there is still " .. enemies .. " enemies left. Kill them all so fish are safe!", {r=0.98, g=0.66, b=0.22}) + else + if not global.game_reset_tick then + global.game_reset_tick = game.tick + 18000 + objective.game_won = true + objective.game_lost = true + objective.chronotimer = 200000000 - 300 + for _, player in pairs(game.connected_players) do + player.play_sound{path="utility/game_won", volume_modifier=0.85} + end + local message = "Comfylatron: Thank you with helping me on this delivery. It was tough one. I hope, that now, when all biters are dead, fish will be safe here forever...after all, we delivered " .. objective.mainscore .. " of them fishies." + game.print(message, {r=0.98, g=0.66, b=0.22}) + Server.to_discord_embed(message) + end + end + end + end + end +end + + function Public.check_upgrades() local objective = global.objective @@ -302,6 +384,14 @@ function Public.check_upgrades() if objective.poisondefense < 1 then check_poisondefense() end + if objective.computerupgrade < 3 and objective.chronojumps >= 15 then + check_upgrade_computer() + end + if objective.planet[1].name.id == 17 then + if global.fishchest then + check_win() + end + end end return Public From ac3b5954ed6898b289a6c0a1fba2fdb1f6b28b11 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sun, 23 Feb 2020 16:51:07 +0100 Subject: [PATCH 17/70] fixes --- maps/chronosphere/comfylatron.lua | 2 +- maps/chronosphere/gui.lua | 2 +- maps/chronosphere/main.lua | 13 ++++++++++--- maps/chronosphere/ores.lua | 4 ++-- maps/chronosphere/upgrades.lua | 8 ++++---- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/maps/chronosphere/comfylatron.lua b/maps/chronosphere/comfylatron.lua index cffe942a..85ee43c3 100644 --- a/maps/chronosphere/comfylatron.lua +++ b/maps/chronosphere/comfylatron.lua @@ -363,7 +363,7 @@ local function go_to_some_location() return true end -function spawn_comfylatron(surface_index, x, y) +local function spawn_comfylatron(surface_index, x, y) local surface = game.surfaces[surface_index] if surface == nil then return end if global.comfylatron_disabled then return false end diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index 8e6a5984..abd7e6ff 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -22,7 +22,7 @@ local function create_gui(player) local label = frame.add({ type = "label", caption = " ", name = "charger"}) label.style.font = "default-bold" label.style.left_padding = 4 - label.style.font_color = {r = 150, g = 0, b = 255} + label.style.font_color = {r = 150, g = 0, b = 255} --255 200 200 local label = frame.add({ type = "label", caption = " ", name = "charger_value"}) label.style.font = "default-bold" diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 51451fa8..5b28703b 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -1,7 +1,6 @@ -- chronosphere -- require "functions.soft_reset" -require "player_modifiers" require "functions.basic_markets" require "modules.difficulty_vote" @@ -59,7 +58,7 @@ local function generate_overworld(surface, optplanet) elseif planet[1].name.id == 14 then game.print("Comfylatron: OOF this one is a bit hot. And have seen those biters? They BATHE in fire! Maybe try some bricks to protect from lava?", {r=0.98, g=0.66, b=0.22}) elseif planet[1].name.id == 17 then - game.print("Comfylatron: So here we are. Fish Market. When they ordered the fish, they said this location is perfectly safe. Looks like we will have to do it for them. I hope you have enough nukes.", {r=0.98, g=0.66, b=0.22}) + game.print("Comfylatron: So here we are. Fish Market. When they ordered the fish, they said this location is perfectly safe. Looks like we will have to do it for them. I hope you have enough nukes. Also, that satellite gave us some space knowledge.", {r=0.98, g=0.66, b=0.22}) end surface.min_brightness = 0 surface.brightness_visual_weights = {1, 1, 1} @@ -216,6 +215,12 @@ local function reset_map() global.outchests = {} global.upgradechest = {} global.fishchest = {} + global.acumulators = {} + global.flame_boots = {} + global.friendly_fire_history = {} + global.landfill_history = {} + global.mining_history = {} + global.score = {} @@ -447,8 +452,10 @@ local function chronojump(choice) game.forces.enemy.evolution_factor = 1 end if objective.planet[1].name.id == 17 then + global.comfychests[1].insert({name = "space-science-pack", count = 1000}) objective.chrononeeds = 200000000 end + global.flame_boots = {} game.map_settings.enemy_evolution.time_factor = 7e-05 + 3e-06 * (objective.chronojumps + objective.passivejumps) surface.pollute(global.locomotive.position, 150 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps)) game.forces.scrapyard.set_ammo_damage_modifier("bullet", 0.01 * objective.chronojumps) @@ -586,7 +593,7 @@ local function on_init() reset_map() end -function set_objective_health(final_damage_amount) +local function set_objective_health(final_damage_amount) local objective = global.objective objective.health = math_floor(objective.health - final_damage_amount) if objective.health > objective.max_health then objective.health = objective.max_health end diff --git a/maps/chronosphere/ores.lua b/maps/chronosphere/ores.lua index 2c1d3921..6881150c 100644 --- a/maps/chronosphere/ores.lua +++ b/maps/chronosphere/ores.lua @@ -27,7 +27,7 @@ local function draw_noise_ore_patch(position, name, surface, radius, richness, m local distance_to_center = math.sqrt(x^2 + y^2) local a = richness - richness_part * distance_to_center if distance_to_center < radius - math.abs(noise * radius * 0.85) and a > 1 then - pos = surface.find_non_colliding_position(name, pos, 64, 1) + pos = surface.find_non_colliding_position(name, pos, 64, 1, true) if not pos then return end if mixed then local noise = simplex_noise(pos.x * 0.005, pos.y * 0.005, seed) + simplex_noise(pos.x * 0.01, pos.y * 0.01, seed) * 0.3 + simplex_noise(pos.x * 0.05, pos.y * 0.05, seed) * 0.2 @@ -69,7 +69,7 @@ local function get_oil_amount(pos, oil_w) return (hundred_percent / 40) * (1+global.objective.chronojumps) * oil_w end -function spawn_ore_vein(surface, pos, planet) +local function spawn_ore_vein(surface, pos, planet) local mixed = false if planet[1].name.id == 6 then mixed = true end --mixed planet local richness = math_random(50 + 10 * global.objective.chronojumps, 100 + 10 * global.objective.chronojumps) * planet[1].ore_richness.factor diff --git a/maps/chronosphere/upgrades.lua b/maps/chronosphere/upgrades.lua index f3f81cff..ac9548ab 100644 --- a/maps/chronosphere/upgrades.lua +++ b/maps/chronosphere/upgrades.lua @@ -33,7 +33,7 @@ local function check_upgrade_hp() inv.remove({name = "copper-plate", count = 3000}) game.print("Comfylatron: Train's max HP was upgraded.", {r=0.98, g=0.66, b=0.22}) objective.hpupgradetier = objective.hpupgradetier + 1 - objective.max_health = 10000 + 5000 * objective.hpupgradetier + objective.max_health = 10000 + 2500 * objective.hpupgradetier rendering.set_text(global.objective.health_text, "HP: " .. global.objective.health .. " / " .. global.objective.max_health) end end @@ -254,7 +254,7 @@ local function check_upgrade_box() end end -function check_poisondefense() +local function check_poisondefense() local objective = global.objective if global.upgradechest[11] and global.upgradechest[11].valid then local inv = global.upgradechest[11].get_inventory(defines.inventory.chest) @@ -262,7 +262,7 @@ function check_poisondefense() local count2 = inv.get_item_count("poison-capsule") if countcoins >= 1000 and count2 >= 50 and objective.poisondefense < 4 then inv.remove({name = "coin", count = 1000}) - inv.remove({name = "pipe", count = 50}) + inv.remove({name = "poison-capsule", count = 50}) game.print("Comfylatron: I don't believe in your defense skills. I equipped train with poison defense.", {r=0.98, g=0.66, b=0.22}) objective.posiondefense = objective.posiondefense + 1 end @@ -381,7 +381,7 @@ function Public.check_upgrades() if objective.boxupgradetier < 4 and objective.chronojumps >= (objective.boxupgradetier + 1) * 5 then check_upgrade_box() end - if objective.poisondefense < 1 then + if objective.poisondefense < 4 then check_poisondefense() end if objective.computerupgrade < 3 and objective.chronojumps >= 15 then From 60d8b70ad8c20a6d0cf02824fb52d45b77728fe5 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sun, 23 Feb 2020 18:33:37 +0100 Subject: [PATCH 18/70] Add files via upload --- maps/chronosphere/gui.lua | 20 +++++++++++++++----- maps/chronosphere/locomotive.lua | 6 +++++- maps/chronosphere/main.lua | 11 +++++++++++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index abd7e6ff..bb52c2d6 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -22,13 +22,13 @@ local function create_gui(player) local label = frame.add({ type = "label", caption = " ", name = "charger"}) label.style.font = "default-bold" label.style.left_padding = 4 - label.style.font_color = {r = 150, g = 0, b = 255} --255 200 200 + label.style.font_color = {r = 255, g = 200, b = 200} --255 200 200 --150 0 255 local label = frame.add({ type = "label", caption = " ", name = "charger_value"}) label.style.font = "default-bold" label.style.right_padding = 1 label.style.minimal_width = 10 - label.style.font_color = {r = 150, g = 0, b = 255} + label.style.font_color = {r = 255, g = 200, b = 200} local progressbar = frame.add({ type = "progressbar", name = "progressbar", value = 0}) progressbar.style.minimal_width = 96 @@ -57,7 +57,7 @@ local function create_gui(player) label.style.font = "default-bold" label.style.right_padding = 1 label.style.minimal_width = 10 - label.style.font_color = {r = 0, g = 200, b = 0} + label.style.font_color = {r = 150, g = 0, b = 255} local line = frame.add({type = "line", direction = "vertical"}) line.style.left_padding = 4 @@ -106,12 +106,22 @@ local function update_gui(player) gui.timer.caption = {"chronosphere.gui_3"} gui.timer_value.caption = math_floor((objective.chrononeeds - objective.chronotimer) / 60) .. " min, " .. (objective.chrononeeds - objective.chronotimer) % 60 .. " s" if objective.chronojumps > 5 then - gui.timer_value.tooltip = "If overstaying this, other planets can evolve: " ..math_floor((objective.chrononeeds * 0.75 - objective.passivetimer) / 60) .. " min, " .. (objective.chrononeeds * 0.75 - objective.passivetimer) % 60 .. " s" + local overstay_timer_min = math_floor((objective.chrononeeds * 0.75 - objective.passivetimer) / 60) + local evo_timer_min = math_floor((objective.chrononeeds * 0.5 - objective.passivetimer) / 60) + local first_part = "If overstaying this, other planets can evolve: " .. overstay_timer_min .. " min, " .. (objective.chrononeeds * 0.75 - objective.passivetimer) % 60 .. " s" + if overstay_timer_min < 0 then + first_part = "If overstaying this, other planets can evolve: " .. overstay_timer_min .. " min, " .. 59 - ((objective.chrononeeds * 0.75 - objective.passivetimer) % 60) .. " s" + end + local second_part = "This planet gets additional evolution growth in: " ..evo_timer_min .. " min, " .. (objective.chrononeeds * 0.5 - objective.passivetimer) % 60 .. " s" + if evo_timer_min < 0 then + second_part = "This planet gets additional evolution growth in: " ..evo_timer_min .. " min, " .. 59 -((objective.chrononeeds * 0.5 - objective.passivetimer) % 60) .. " s" + end + gui.timer_value.tooltip = first_part .. "\n" .. second_part else gui.timer_value.tooltip = "After planet 5, biters will get additional permanent evolution for staying too long on each planet." end - gui.planet.caption = "Planet: " .. objective.planet[1].name.name .. " Ores: " .. objective.planet[1].ore_richness.name + gui.planet.caption = "Planet: " .. objective.planet[1].name.name .. " | Ores: " .. objective.planet[1].ore_richness.name local acus = 0 if global.acumulators then acus = #global.acumulators else acus = 0 end local bestcase = math_floor((objective.chrononeeds - objective.chronotimer) / (1 + math_floor(acus/10))) diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index 8fb0dd44..cce4d8c5 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -549,7 +549,11 @@ function Public.enter_cargo_wagon(player, vehicle) player.teleport(surface.find_non_colliding_position("character", position, 128, 0.5), surface) end if player.surface.name == "cargo_wagon" and vehicle.type == "car" then - global.flame_boots[player.index].steps = {} + if global.flame_boots then + if global.flame_boots[player.index] then + global.flame_boots[player.index].steps = {} + end + end local surface = global.locomotive_cargo.surface local x_vector = (vehicle.position.x / math.abs(vehicle.position.x)) * 2 local y_vector = vehicle.position.y / 16 diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 5b28703b..99a07e3c 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -511,6 +511,16 @@ local function transfer_pollution() surface.clear_pollution() end +local function boost_evolution() + local objective = global.objective + if objective.passivetimer > objective.chrononeeds * 0.50 and objective.chronojumps > 5 then + local evolution = game.forces.enemy.evolution_factor + evolution = evolution + (evolution / 2000) * global.difficulty_vote_value + if evolution > 1 then evolution = 1 end + game.forces.enemy.evolution_factor = evolution + end +end + local tick_minute_functions = { [300 * 2] = Ai.destroy_inactive_biters, @@ -550,6 +560,7 @@ local function tick() Locomotive.set_player_spawn_and_refill_fish() repair_train() Upgrades.check_upgrades() + boost_evolution() end local key = tick % 3600 if tick_minute_functions[key] then tick_minute_functions[key]() end From f6c9ec8fbaf0caea03180e74e3f057265eecfccf Mon Sep 17 00:00:00 2001 From: hanakocz Date: Mon, 24 Feb 2020 00:39:58 +0100 Subject: [PATCH 19/70] reworking the structure --- maps/chronosphere/chrono.lua | 105 ++++++ maps/chronosphere/event_functions.lua | 153 +++++++++ maps/chronosphere/gui.lua | 16 +- maps/chronosphere/locomotive.lua | 6 +- maps/chronosphere/main.lua | 457 +++----------------------- maps/chronosphere/tick_functions.lua | 135 ++++++++ maps/chronosphere/upgrades.lua | 20 +- 7 files changed, 469 insertions(+), 423 deletions(-) create mode 100644 maps/chronosphere/chrono.lua create mode 100644 maps/chronosphere/event_functions.lua create mode 100644 maps/chronosphere/tick_functions.lua diff --git a/maps/chronosphere/chrono.lua b/maps/chronosphere/chrono.lua new file mode 100644 index 00000000..2df8ab23 --- /dev/null +++ b/maps/chronosphere/chrono.lua @@ -0,0 +1,105 @@ +local Public = {} + +local Server = require 'utils.server' + +function Public.objective_died() + local objective = global.objective + if objective.game_lost == true then return end + objective.health = 0 + local surface = objective.surface + game.print("The chronotrain was destroyed!") + game.print("Comfylatron is going to kill you for that...he has time machine after all!") + surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo.position}) + global.locomotive_cargo.destroy() + surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo2.position}) + global.locomotive_cargo2.destroy() + surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo3.position}) + global.locomotive_cargo3.destroy() + for i = 1, #global.comfychests,1 do + --surface.create_entity({name = "big-artillery-explosion", position = global.comfychests[i].position}) + global.comfychests[i].destroy() + + if global.comfychests2 then global.comfychests2[i].destroy() end + + --global.comfychests = {} + end + global.acumulators = {} + objective.game_lost = true + global.game_reset_tick = game.tick + 1800 + for _, player in pairs(game.connected_players) do + player.play_sound{path="utility/game_lost", volume_modifier=0.75} + end +end + +local function overstayed() + local objective = global.objective + if objective.passivetimer > objective.chrononeeds * 0.75 and objective.chronojumps > 5 then + objective.passivejumps = objective.passivejumps + 1 + return true + end + return false +end + +function Public.process_jump(choice) + local objective = global.objective + local overstayed = overstayed() + objective.chronojumps = objective.chronojumps + 1 + objective.chrononeeds = 2000 + 500 * objective.chronojumps + objective.passivetimer = 0 + objective.chronotimer = 0 + local message = "Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. global.objective.chronojumps + game.print(message, {r=0.98, g=0.66, b=0.22}) + Server.to_discord_embed(message) + + if objective.chronojumps == 6 then + game.print("Comfylatron: Biters start to evolve faster! We need to charge forward or they will be stronger! (hover over timer to see evolve timer)", {r=0.98, g=0.66, b=0.22}) + elseif objective.chronojumps == 15 then + game.print("Comfylatron: You know...I have big quest. Deliver fish to fish market. But this train is broken. Please help me fix the train computer!", {r=0.98, g=0.66, b=0.22}) + elseif objective.chronojumps == 20 then + game.print("Comfylatron: Ah, we need to give this machine more power and better navigation chipset. Please bring me some additional things.", {r=0.98, g=0.66, b=0.22}) + elseif objective.chronojumps == 25 then + game.print("Comfylatron: Finally found the main issue. We will need to rebuild whole processor. Exactly what I feared of. Just a few more things...", {r=0.98, g=0.66, b=0.22}) + end + if overstayed then + game.print("Comfylatron: Looks like you stayed on previous planet for so long that enemies on other planets had additional time to evolve!", {r=0.98, g=0.66, b=0.22}) + end +end + +function Public.get_wagons() + local inventories = {one = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon), two = global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon)} + inventories.one.sort_and_merge() + inventories.two.sort_and_merge() + local wagons = {} + wagons[1] = {inventory = inventories.one.get_contents(), bar = inventories.one.get_bar(), filters = {}} + wagons[2] = {inventory = inventories.two.get_contents(), bar = inventories.two.get_bar(), filters = {}} + for i = 1, 40, 1 do + wagons[1].filters[i] = inventories.one.get_filter(i) + wagons[2].filters[i] = inventories.two.get_filter(i) + end + return wagons +end + +function Public.post_jump() + local objective = global.objective + game.forces.enemy.reset_evolution() + if objective.chronojumps + objective.passivejumps <= 40 and objective.planet[1].name.id ~= 17 then + game.forces.enemy.evolution_factor = 0 + 0.025 * (objective.chronojumps + objective.passivejumps) + else + game.forces.enemy.evolution_factor = 1 + end + if objective.planet[1].name.id == 17 then + global.comfychests[1].insert({name = "space-science-pack", count = 1000}) + objective.chrononeeds = 200000000 + end + for _, player in pairs(game.connected_players) do + global.flame_boots[player.index] = {fuel = 1, steps = {}} + end + game.map_settings.enemy_evolution.time_factor = 7e-05 + 3e-06 * (objective.chronojumps + objective.passivejumps) + game.forces.scrapyard.set_ammo_damage_modifier("bullet", 0.01 * objective.chronojumps) + game.forces.scrapyard.set_turret_attack_modifier("gun-turret", 0.01 * objective.chronojumps) + game.forces.enemy.set_ammo_damage_modifier("melee", 0.1 * objective.passivejumps) + game.forces.enemy.set_ammo_damage_modifier("biological", 0.1 * objective.passivejumps) + game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.8 +end + +return Public diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua new file mode 100644 index 00000000..e16f66dd --- /dev/null +++ b/maps/chronosphere/event_functions.lua @@ -0,0 +1,153 @@ +local Public = {} + +local tick_tack_trap = require "functions.tick_tack_trap" +local math_random = math.random +local math_floor = math.floor + +local choppy_entity_yield = { + ["tree-01"] = {"iron-ore"}, + ["tree-02-red"] = {"copper-ore"}, + ["tree-04"] = {"coal"}, + ["tree-08-brown"] = {"stone"} + } + +local function get_ore_amount() + local scaling = 5 * global.objective.chronojumps + local amount = (30 + scaling ) * (1 + game.forces.player.mining_drill_productivity_bonus) * global.objective.planet[1].ore_richness.factor + if amount > 600 then amount = 600 end + amount = math_random(math_floor(amount * 0.7), math_floor(amount * 1.3)) + return amount +end + +function Public.biters_chew_rocks_faster(event) + if event.entity.force.index ~= 3 then return end --Neutral Force + if not event.cause then return end + if not event.cause.valid then return end + if event.cause.force.index ~= 2 then return end --Enemy Force + event.entity.health = event.entity.health - event.final_damage_amount * 5 +end + +function Public.isprotected(entity) + if entity.surface.name == "cargo_wagon" then return true end + local protected = {global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} + for i = 1, #global.comfychests,1 do + table.insert(protected, global.comfychests[i]) + end + for i = 1, #protected do + if protected[i] == entity then + return true + end + end + return false +end + +function Public.trap(entity, trap) + if trap then + tick_tack_trap(entity.surface, entity.position) + tick_tack_trap(entity.surface, {x = entity.position.x + math_random(-2,2), y = entity.position.y + math_random(-2,2)}) + return + end + if math_random(1,256) == 1 then tick_tack_trap(entity.surface, entity.position) return end + if math_random(1,128) == 1 then unearthing_worm(entity.surface, entity.surface.find_non_colliding_position("big-worm-turret",entity.position,5,1)) end + if math_random(1,64) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end +end + +function Public.lava_planet(event) + local player = game.players[event.player_index] + if not player.character then return end + if player.character.driving then return end + if player.surface.name == "cargo_wagon" then return end + local safe = {"stone-path", "concrete", "hazard-concrete-left", "hazard-concrete-right", "refined-concrete", "refined-hazard-concrete-left", "refined-hazard-concrete-right"} + local pavement = player.surface.get_tile(player.position.x, player.position.y) + for i = 1, 7, 1 do + if pavement.name == safe[i] then return end + end + if not global.flame_boots[player.index].steps then global.flame_boots[player.index].steps = {} end + local steps = global.flame_boots[player.index].steps + + local elements = #steps + + steps[elements + 1] = {x = player.position.x, y = player.position.y} + + if elements > 10 then + player.surface.create_entity({name = "fire-flame", position = steps[elements - 1], }) + for i = 1, elements, 1 do + steps[i] = steps[i+1] + end + steps[elements + 1] = nil + end +end + +function Public.shred_simple_entities(entity) + --game.print(entity.name) + if game.forces["enemy"].evolution_factor < 0.25 then return end + local simple_entities = entity.surface.find_entities_filtered({type = {"simple-entity", "tree"}, area = {{entity.position.x - 3, entity.position.y - 3},{entity.position.x + 3, entity.position.y + 3}}}) + if #simple_entities == 0 then return end + for i = 1, #simple_entities, 1 do + if not simple_entities[i] then break end + if simple_entities[i].valid then + simple_entities[i].die("enemy", simple_entities[i]) + end + end +end + +function Public.choppy_loot(event) + local entity = event.entity + if choppy_entity_yield[entity.name] then + if event.buffer then event.buffer.clear() end + if not event.player_index then return end + local amount = get_ore_amount() + local second_item_amount = math_random(2,5) + local second_item = "wood" + local main_item = choppy_entity_yield[entity.name][math_random(1,#choppy_entity_yield[entity.name])] + + entity.surface.create_entity({ + name = "flying-text", + position = entity.position, + text = "+" .. amount .. " [item=" .. main_item .. "] +" .. second_item_amount .. " [item=" .. second_item .. "]", + color = {r=0.8,g=0.8,b=0.8} + }) + + local player = game.players[event.player_index] + + local inserted_count = player.insert({name = main_item, count = amount}) + amount = amount - inserted_count + if amount > 0 then + entity.surface.spill_item_stack(player.position,{name = main_item, count = amount}, true) + end + + local inserted_count = player.insert({name = second_item, count = second_item_amount}) + second_item_amount = second_item_amount - inserted_count + if second_item_amount > 0 then + entity.surface.spill_item_stack(entity.position,{name = second_item, count = second_item_amount}, true) + end + end +end + +function Public.rocky_loot(event) + local surface = game.surfaces[global.active_surface_index] + local player = game.players[event.player_index] + surface.spill_item_stack(player.position,{name = "raw-fish", count = math_random(1,3)},true) + local amount = get_ore_amount() + local rock_mining = {"iron-ore", "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "copper-ore", "stone", "stone", "coal", "coal"} + local mined_loot = rock_mining[math_random(1,#rock_mining)] + surface.create_entity({ + name = "flying-text", + position = {player.position.x, player.position.y - 0.5}, + text = "+" .. amount .. " [img=item/" .. mined_loot .. "]", + color = {r=0.98, g=0.66, b=0.22} + }) + local i = player.insert {name = mined_loot, count = amount} + amount = amount - i + if amount > 0 then + if amount >= 50 then + for i = 1, math_floor(amount / 50), 1 do + surface.create_entity{name = "item-on-ground", position = player.position, stack = {name = mined_loot, count = 50}} + amount = amount - 50 + end + end + surface.spill_item_stack(player.position, {name = mined_loot, count = amount},true) + end +end + +return Public diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index bb52c2d6..37da5de0 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -39,13 +39,13 @@ local function create_gui(player) label.style.font = "default-bold" label.style.right_padding = 1 label.style.minimal_width = 10 - label.style.font_color = {r = 150, g = 0, b = 255} + label.style.font_color = {r = 255, g = 200, b = 200} local label = frame.add({ type = "label", caption = " ", name = "timer_value", tooltip = " "}) label.style.font = "default-bold" label.style.right_padding = 1 label.style.minimal_width = 10 - label.style.font_color = {r = 150, g = 0, b = 255} + label.style.font_color = {r = 255, g = 200, b = 200} local label = frame.add({ type = "label", caption = " ", name = "timer2"}) label.style.font = "default-bold" @@ -57,7 +57,7 @@ local function create_gui(player) label.style.font = "default-bold" label.style.right_padding = 1 label.style.minimal_width = 10 - label.style.font_color = {r = 150, g = 0, b = 255} + label.style.font_color = {r = 0, g = 200, b = 0} local line = frame.add({type = "line", direction = "vertical"}) line.style.left_padding = 4 @@ -132,15 +132,15 @@ local function update_gui(player) gui.evo.caption = {"chronosphere.gui_4"} gui.evo_value.caption = math_floor(evolution * 100) .. "%" local chests = { - [1] = {c = "250 wooden chests\n"}, - [2] = {c = "250 iron chests\n"}, - [3] = {c = "250 steel chests\n"}, - [4] = {c = "250 storage chests\n"}, + [1] = {c = "250 wooden chests + Jump number 5\n"}, + [2] = {c = "250 iron chests + Jump number 10\n"}, + [3] = {c = "250 steel chests + Jump number 15\n"}, + [4] = {c = "250 storage chests + Jump number 20\n"}, [5] = {c = "--\n"} } local upgt = { [1] = {t = "[1]: + 2500 Train Max HP. Current: " .. objective.max_health .. "\n Cost : " .. math_floor(500 * (1 + objective.hpupgradetier /2)) .. " coins + 1500 copper plates\n"}, - [2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%\n Buyable once per 3 jumps.\n Cost: 5000 coins + 2000 green circuits\n"}, + [2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%\n Buyable once per 3 jumps.\n Cost: 5000 coins + 2000 green circuits + Jump number " .. objective.filterupgradetier * 3 .. "\n"}, [3] = {t = "[3]: Add additional row of Acumulators.\n Cost : " .. math_floor(2000 * (1 + objective.acuupgradetier /4)) .. " coins + 200 batteries\n"}, [4] = {t = "[4]: Add item pickup distance to players.Current: +" .. objective.pickupupgradetier .. ",\n Cost: " .. 1000 * (1 + objective.pickupupgradetier) .. " coins + 400 red inserters\n"}, [5] = {t = "[5]: Add +5 inventory slots. Buyable once per 5 jumps.\n Cost: " .. 2000 * (1 + objective.invupgradetier) .." coins + " .. chests[objective.invupgradetier + 1].c}, diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index cce4d8c5..9337bc28 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -245,7 +245,7 @@ local function create_wagon_room() combipower.connect_neighbour({wire = defines.wire_type.green, target_entity = combimade[#combimade], target_circuit_id = 1}) combimade[1].connect_neighbour({wire = defines.wire_type.green, target_entity = checker, source_circuit_id = 2, target_circuit_id = 1}) local speaker = surface.create_entity({name = "programmable-speaker", position = {x = width * -0.5 - 6, y = -241}, force = "player", create_build_effect_smoke = false, - parameters = {playback_volume = 0.8, playback_globally = true, allow_polyphony = false}, + parameters = {playback_volume = 0.6, playback_globally = true, allow_polyphony = false}, alert_parameters = {show_alert = true, show_on_map = true, icon_signal_id = {type = "item", name = "accumulator"}, alert_message = "Train Is Charging!" }}) speaker.connect_neighbour({wire = defines.wire_type.green, target_entity = checker, target_circuit_id = 2}) local rules4 = speaker.get_or_create_control_behavior() @@ -550,9 +550,7 @@ function Public.enter_cargo_wagon(player, vehicle) end if player.surface.name == "cargo_wagon" and vehicle.type == "car" then if global.flame_boots then - if global.flame_boots[player.index] then - global.flame_boots[player.index].steps = {} - end + global.flame_boots[player.index] = {fuel = 1, steps = {}} end local surface = global.locomotive_cargo.surface local x_vector = (vehicle.position.x / math.abs(vehicle.position.x)) * 2 diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 99a07e3c..917ce251 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -17,14 +17,17 @@ local Server = require 'utils.server' local Ai = require "maps.chronosphere.ai" local unearthing_worm = require "functions.unearthing_worm" local unearthing_biters = require "functions.unearthing_biters" -local tick_tack_trap = require "functions.tick_tack_trap" + local Planets = require "maps.chronosphere.chronobubles" local Ores =require "maps.chronosphere.ores" local Reset = require "functions.soft_reset" local Map = require "modules.map_info" local Upgrades = require "maps.chronosphere.upgrades" +local Tick_functions = require "maps.chronosphere.tick_functions" +local Event_functions = require "maps.chronosphere.event_functions" +local Chrono = require "maps.chronosphere.chrono" local Locomotive = require "maps.chronosphere.locomotive" -local Modifier = require "player_modifiers" +--local Modifier = require "player_modifiers" local update_gui = require "maps.chronosphere.gui" local math_random = math.random local math_floor = math.floor @@ -36,14 +39,6 @@ global.flame_boots = {} global.comfylatron = nil global.lab_cells = {} - -local choppy_entity_yield = { - ["tree-01"] = {"iron-ore"}, - ["tree-02-red"] = {"copper-ore"}, - ["tree-04"] = {"coal"}, - ["tree-08-brown"] = {"stone"} - } - local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 32, ['grenade'] = 4, ['raw-fish'] = 4, ['rail'] = 16, ['wood'] = 16} local starting_cargo = {['firearm-magazine'] = 16, ['iron-plate'] = 16, ['wood'] = 16, ['burner-mining-drill'] = 8} @@ -105,20 +100,6 @@ local function generate_overworld(surface, optplanet) surface.request_to_generate_chunks({0,0}, 3) surface.force_generate_chunk_requests() end - --log(timer) - --surface.solar_power_multiplier = 999 - - - - -- for x = -352 + 32, 352 - 32, 32 do - -- surface.request_to_generate_chunks({x, 96}, 1) - -- --surface.force_generate_chunk_requests() - -- end - --spawn_ores(surface, planet) - --if planet[1].name.name == "mixed planet" then - -- ores_are_mixed(surface) - --end - --game.forces["player"].chart_all(surface) end local function get_map_gen_settings() @@ -216,7 +197,9 @@ local function reset_map() global.upgradechest = {} global.fishchest = {} global.acumulators = {} - global.flame_boots = {} + for _, player in pairs(game.connected_players) do + global.flame_boots[player.index] = {fuel = 1, steps = {}} + end global.friendly_fire_history = {} global.landfill_history = {} global.mining_history = {} @@ -271,11 +254,9 @@ local function reset_map() end local function on_player_joined_game(event) - local player_modifiers = Modifier.get_table() local player = game.players[event.player_index] global.flame_boots[event.player_index] = {fuel = 1} if not global.flame_boots[event.player_index].steps then global.flame_boots[event.player_index].steps = {} end - --set_difficulty() local surface = game.surfaces[global.active_surface_index] @@ -296,8 +277,6 @@ local function on_player_joined_game(event) end end - player_modifiers[player.index].character_mining_speed_modifier["chronosphere"] = 0.5 - Modifier.update_player_modifiers(player) local tile = surface.get_tile(player.position) if tile.valid then if tile.name == "out-of-map" then @@ -306,102 +285,26 @@ local function on_player_joined_game(event) end end -local function repair_train() +local function set_objective_health(final_damage_amount) + if final_damage_amount == 0 then return end local objective = global.objective - if not game.surfaces["cargo_wagon"] then return end - if objective.game_lost == true then return end - if objective.health < objective.max_health then - local inv = global.upgradechest[1].get_inventory(defines.inventory.chest) - local count = inv.get_item_count("repair-pack") - if count >= 5 and objective.toolsupgradetier == 4 and objective.health + 750 <= objective.max_health then - inv.remove({name = "repair-pack", count = 5}) - set_objective_health(-750) - elseif count >= 4 and objective.toolsupgradetier == 3 and objective.health + 600 <= objective.max_health then - inv.remove({name = "repair-pack", count = 4}) - set_objective_health(-600) - elseif count >= 3 and objective.toolsupgradetier == 2 and objective.health + 450 <= objective.max_health then - inv.remove({name = "repair-pack", count = 3}) - set_objective_health(-450) - elseif count >= 2 and objective.toolsupgradetier == 1 and objective.health + 300 <= objective.max_health then - inv.remove({name = "repair-pack", count = 2}) - set_objective_health(-300) - elseif count >= 1 then - inv.remove({name = "repair-pack", count = 1}) - set_objective_health(-150) - end + objective.health = math_floor(objective.health - final_damage_amount) + if objective.health > objective.max_health then objective.health = objective.max_health end + + if objective.health <= 0 then + Objective.objective_died() end -end - -local function move_items() - if not global.comfychests then return end - if not global.comfychests2 then return end - if global.objective.game_lost == true then return end - local input = global.comfychests - local output = global.comfychests2 - for i = 1, 24, 1 do - if not input[i].valid then - log("no input chest " .. i) - return - end - if not output[i].valid then - log("no output chest " .. i) - return - end - - local input_inventory = input[i].get_inventory(defines.inventory.chest) - local output_inventory = output[i].get_inventory(defines.inventory.chest) - input_inventory.sort_and_merge() - local items = input_inventory.get_contents() - - for item, count in pairs(items) do - local inserted = output_inventory.insert({name = item, count = count}) - if inserted > 0 then - local removed = input_inventory.remove({name = item, count = inserted}) - end - end - end -end - -local function output_items() - if global.objective.game_lost == true then return end - if not global.outchests then return end - if not global.locomotive_cargo2 then return end - if not global.locomotive_cargo3 then return end - if global.objective.outupgradetier ~= 1 then return end - for i = 1, 4, 1 do - if not global.outchests[i].valid then return end - local inv = global.outchests[i].get_inventory(defines.inventory.chest) - inv.sort_and_merge() - local items = inv.get_contents() - for item, count in pairs(items) do - local inserted = nil - if i <= 2 then - inserted = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) - else - inserted = global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) - end - if inserted > 0 then - local removed = inv.remove({name = item, count = inserted}) - end - end + if objective.health < objective.max_health / 2 and final_damage_amount > 0 then + Upgrades.trigger_poison() end + rendering.set_text(objective.health_text, "HP: " .. objective.health .. " / " .. objective.max_health) end local function chronojump(choice) local objective = global.objective if objective.game_lost then return end - local overstayed = false - if objective.passivetimer > objective.chrononeeds * 0.75 and objective.chronojumps > 5 then - overstayed = true - objective.passivejumps = objective.passivejumps + 1 - end - objective.chronojumps = objective.chronojumps + 1 - objective.chrononeeds = 2000 + 500 * objective.chronojumps - objective.passivetimer = 0 - objective.chronotimer = 0 - local message = "Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. global.objective.chronojumps - game.print(message, {r=0.98, g=0.66, b=0.22}) - Server.to_discord_embed(message) + Chrono.process_jump() + local oldsurface = game.surfaces[global.active_surface_index] for _,player in pairs(game.players) do @@ -421,104 +324,14 @@ local function chronojump(choice) planet = global.objective.planet end generate_overworld(surface, planet) - if objective.chronojumps == 6 then - game.print("Comfylatron: Biters start to evolve faster! We need to charge forward or they will be stronger! (hover over timer to see evolve timer)", {r=0.98, g=0.66, b=0.22}) - elseif objective.chronojumps == 15 then - game.print("Comfylatron: You know...I have big quest. Deliver fish to fish market. But this train is broken. Please help me fix the train computer!", {r=0.98, g=0.66, b=0.22}) - elseif objective.chronojumps == 20 then - game.print("Comfylatron: Ah, we need to give this machine more power and better navigation chipset. Please bring me some additional things.", {r=0.98, g=0.66, b=0.22}) - elseif objective.chronojumps == 25 then - game.print("Comfylatron: Finally found the main issue. We will need to rebuild whole processor. Exactly what I feared of. Just a few more things...", {r=0.98, g=0.66, b=0.22}) - end - if overstayed then game.print("Comfylatron: Looks like you stayed on previous planet for so long that enemies on other planets had additional time to evolve!", {r=0.98, g=0.66, b=0.22}) end + game.forces.player.set_spawn_position({12, 10}, surface) - local inventories = {one = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon), two = global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon)} - inventories.one.sort_and_merge() - inventories.two.sort_and_merge() - local wagons = {} - wagons[1] = {inventory = inventories.one.get_contents(), bar = inventories.one.get_bar(), filters = {}} - wagons[2] = {inventory = inventories.two.get_contents(), bar = inventories.two.get_bar(), filters = {}} - for i = 1, 40, 1 do - wagons[1].filters[i] = inventories.one.get_filter(i) - wagons[2].filters[i] = inventories.two.get_filter(i) - end - Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, wagons) + + Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, Chrono.get_wagons()) render_train_hp() game.delete_surface(oldsurface) - game.forces.enemy.reset_evolution() - if objective.chronojumps + objective.passivejumps <= 40 and objective.planet[1].name.id ~= 17 then - game.forces.enemy.evolution_factor = 0 + 0.025 * (objective.chronojumps + objective.passivejumps) - else - game.forces.enemy.evolution_factor = 1 - end - if objective.planet[1].name.id == 17 then - global.comfychests[1].insert({name = "space-science-pack", count = 1000}) - objective.chrononeeds = 200000000 - end - global.flame_boots = {} - game.map_settings.enemy_evolution.time_factor = 7e-05 + 3e-06 * (objective.chronojumps + objective.passivejumps) + Chrono.post_jump() surface.pollute(global.locomotive.position, 150 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps)) - game.forces.scrapyard.set_ammo_damage_modifier("bullet", 0.01 * objective.chronojumps) - game.forces.scrapyard.set_turret_attack_modifier("gun-turret", 0.01 * objective.chronojumps) - game.forces.enemy.set_ammo_damage_modifier("melee", 0.1 * objective.passivejumps) - game.forces.enemy.set_ammo_damage_modifier("biological", 0.1 * objective.passivejumps) - game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.8 -end - -local function check_chronoprogress() - local objective = global.objective - --game.print(objective.chronotimer) - if objective.chronotimer == objective.chrononeeds - 180 then - game.print("Comfylatron: Acumulator charging disabled, 180 seconds countdown to jump!", {r=0.98, g=0.66, b=0.22}) - elseif objective.chronotimer == objective.chrononeeds - 60 then - game.print("Comfylatron: ChronoTrain nearly charged! Grab what you can, we leaving in 60 seconds!", {r=0.98, g=0.66, b=0.22}) - elseif objective.chronotimer == objective.chrononeeds - 30 then - game.print("Comfylatron: You better hurry up! 30 seconds remaining!", {r=0.98, g=0.66, b=0.22}) - elseif objective.chronotimer >= objective.chrononeeds - 10 and objective.chrononeeds - objective.chronotimer > 0 then - game.print("Comfylatron: Jump in " .. objective.chrononeeds - objective.chronotimer .. " seconds!", {r=0.98, g=0.66, b=0.22}) - end - if objective.chronotimer >= objective.chrononeeds then - chronojump(nil) - - end -end - -local function charge_chronosphere() - if not global.acumulators then return end - local objective = global.objective - if not objective.chronotimer then return end - if objective.chronotimer < 20 then return end - if objective.planet[1].name.id == 17 then return end - local acus = global.acumulators - if #acus < 1 then return end - for i = 1, #acus, 1 do - if not acus[i].valid then return end - local energy = acus[i].energy - if energy > 3000000 and objective.chronotimer < objective.chrononeeds - 182 and objective.chronotimer > 130 then - acus[i].energy = acus[i].energy - 3000000 - objective.chronotimer = objective.chronotimer + 1 - game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (10 + 2 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1)) * global.difficulty_vote_value) - --log("energy charged from acu") - end - end -end - -local function transfer_pollution() - local surface = game.surfaces["cargo_wagon"] - if not surface then return end - local pollution = surface.get_total_pollution() * (3 / (global.objective.filterupgradetier / 3 + 1)) * global.difficulty_vote_value - game.surfaces[global.active_surface_index].pollute(global.locomotive.position, pollution) - surface.clear_pollution() -end - -local function boost_evolution() - local objective = global.objective - if objective.passivetimer > objective.chrononeeds * 0.50 and objective.chronojumps > 5 then - local evolution = game.forces.enemy.evolution_factor - evolution = evolution + (evolution / 2000) * global.difficulty_vote_value - if evolution > 1 then evolution = 1 end - game.forces.enemy.evolution_factor = evolution - end end local tick_minute_functions = { @@ -546,32 +359,31 @@ local function tick() end --surface.force_generate_chunk_requests() - end if tick % 30 == 0 then if tick % 600 == 0 then - charge_chronosphere() - transfer_pollution() + Tick_functions.charge_chronosphere() + Tick_functions.transfer_pollution() if global.objective.poisontimeout > 0 then global.objective.poisontimeout = global.objective.poisontimeout - 1 end end if tick % 1800 == 0 then Locomotive.set_player_spawn_and_refill_fish() - repair_train() + set_objective_health(Tick_functions.repair_train()) Upgrades.check_upgrades() - boost_evolution() + Tick_functions.boost_evolution() end local key = tick % 3600 if tick_minute_functions[key] then tick_minute_functions[key]() end if tick % 60 == 0 and global.objective.planet[1].name.id ~= 17 then global.objective.chronotimer = global.objective.chronotimer + 1 global.objective.passivetimer = global.objective.passivetimer + 1 - check_chronoprogress() + if Tick_functions.check_chronoprogress() then chronojump(nil) end end if tick % 120 == 0 then - move_items() - output_items() + Tick_functions.move_items() + Tick_functions.output_items() end if global.game_reset_tick then if global.game_reset_tick < tick then @@ -583,8 +395,6 @@ local function tick() Locomotive.fish_tag() end for _, player in pairs(game.connected_players) do update_gui(player) end - --if not collapse_enabled then return end - --Collapse.process() end local function on_init() @@ -597,80 +407,13 @@ local function on_init() game.create_force("scrapyard") game.forces.scrapyard.set_friend('enemy', true) game.forces.enemy.set_friend('scrapyard', true) - --global.rocks_yield_ore_maximum_amount = 999 - --global.rocks_yield_ore_base_amount = 50 - --global.rocks_yield_ore_distance_modifier = 0.025 - --if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end reset_map() -end - -local function set_objective_health(final_damage_amount) - local objective = global.objective - objective.health = math_floor(objective.health - final_damage_amount) - if objective.health > objective.max_health then objective.health = objective.max_health end - - if objective.health <= 0 then - if objective.game_lost == true then return end - objective.health = 0 - local surface = objective.surface - game.print("The chronotrain was destroyed!") - game.print("Comfylatron is going to kill you for that...he has time machine after all!") - surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo.position}) - global.locomotive_cargo.destroy() - surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo2.position}) - global.locomotive_cargo2.destroy() - surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo3.position}) - global.locomotive_cargo3.destroy() - for i = 1, #global.comfychests,1 do - --surface.create_entity({name = "big-artillery-explosion", position = global.comfychests[i].position}) - global.comfychests[i].destroy() - - if global.comfychests2 then global.comfychests2[i].destroy() end - - --global.comfychests = {} - end - global.ores_queue = {} - global.entities_queue = {} - global.acumulators = {} - objective.game_lost = true - global.game_reset_tick = game.tick + 1800 - for _, player in pairs(game.connected_players) do - player.play_sound{path="utility/game_lost", volume_modifier=0.75} - end - return - end - if objective.health < objective.max_health / 2 and final_damage_amount > 0 and objective.poisondefense > 0 and objective.poisontimeout == 0 then - objective.poisondefense = objective.poisondefense - 1 - objective.poisontimeout = 120 - local objs = {global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} - local surface = objective.surface - game.print("Comfylatron: Triggering poison defense. Let's kill everything!", {r=0.98, g=0.66, b=0.22}) - for i = 1, 4, 1 do - surface.create_entity({name = "poison-capsule", position = objs[i].position, force = "player", target = objs[i], speed = 1 }) - end - for i = 1 , #global.comfychests, 1 do - surface.create_entity({name = "poison-capsule", position = global.comfychests[i].position, force = "player", target = global.comfychests[i], speed = 1 }) - end - end - rendering.set_text(objective.health_text, "HP: " .. objective.health .. " / " .. objective.max_health) -end - -local function isprotected(entity) - local protected = {global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} - if entity.surface.name == "cargo_wagon" then return true end - for i = 1, #global.comfychests,1 do - table.insert(protected, global.comfychests[i]) - end - for index = 1, #protected do - if protected[index] == entity then - return true - end - end + --if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end end local function protect_entity(event) if event.entity.force.index ~= 1 then return end --Player Force - if isprotected(event.entity) then + if Event_functions.isprotected(event.entity) then if event.cause then if event.cause == global.comfylatron or event.entity == global.comfylatron then return @@ -678,27 +421,20 @@ local function protect_entity(event) if event.cause.force.index == 2 then set_objective_health(event.final_damage_amount) end - end if not event.entity.valid then return end event.entity.health = event.entity.health + event.final_damage_amount end end -local function biters_chew_rocks_faster(event) - if event.entity.force.index ~= 3 then return end --Neutral Force - if not event.cause then return end - if not event.cause.valid then return end - if event.cause.force.index ~= 2 then return end --Enemy Force - event.entity.health = event.entity.health - event.final_damage_amount * 5 -end + local function on_entity_damaged(event) if not event.entity.valid then return end protect_entity(event) if not event.entity.valid then return end if not event.entity.health then return end - biters_chew_rocks_faster(event) + Event_functions.biters_chew_rocks_faster(event) if global.objective.planet[1].name.id == 14 and event.entity.force.name == "enemy" then --lava planet if event.damage_type.name == "fire" then event.entity.health = event.entity.health + event.final_damage_amount @@ -710,52 +446,15 @@ local function on_entity_damaged(event) end end end - -end - -local function trap(entity, trap) - if trap then - tick_tack_trap(entity.surface, entity.position) - tick_tack_trap(entity.surface, {x = entity.position.x + math_random(-2,2), y = entity.position.y + math_random(-2,2)}) - return - end - if math_random(1,256) == 1 then tick_tack_trap(entity.surface, entity.position) return end - if math_random(1,128) == 1 then unearthing_worm(entity.surface, entity.surface.find_non_colliding_position("big-worm-turret",entity.position,5,1)) end - if math_random(1,64) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end -end - -local function get_ore_amount() - local scaling = 5 * global.objective.chronojumps - local amount = (30 + scaling ) * (1 + game.forces.player.mining_drill_productivity_bonus) * global.objective.planet[1].ore_richness.factor - if amount > 600 then amount = 600 end - amount = math_random(math_floor(amount * 0.7), math_floor(amount * 1.3)) - return amount end local function pre_player_mined_item(event) - local surface = game.surfaces[global.active_surface_index] - local player = game.players[event.player_index] local objective = global.objective if objective.planet[1].name.id == 11 then --rocky planet if event.entity.name == "rock-huge" or event.entity.name == "rock-big" or event.entity.name == "sand-rock-big" then - trap(event.entity, false) + Event_functions.trap(event.entity, false) event.entity.destroy() - surface.spill_item_stack(player.position,{name = "raw-fish", count = math_random(1,3)},true) - local amount = get_ore_amount() - local rock_mining = {"iron-ore", "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "copper-ore", "stone", "stone", "coal", "coal"} - local mined_loot = rock_mining[math_random(1,#rock_mining)] - surface.create_entity({ - name = "flying-text", - position = {player.position.x, player.position.y - 0.5}, - text = "+" .. amount .. " [img=item/" .. mined_loot .. "]", - color = {r=0.98, g=0.66, b=0.22} - }) - local i = player.insert {name = mined_loot, count = amount} - amount = amount - i - if amount > 0 then - surface.spill_item_stack(player.position, {name = mined_loot, count = amount},true) - --surface.create_entity{name="item-on-ground", position=game.player.position, stack={name=mined_loot, count=50}} - end + Event_functions.rocky_loot(event) end end end @@ -764,36 +463,8 @@ local function on_player_mined_entity(event) local entity = event.entity if not entity.valid then return end if entity.type == "tree" and global.objective.planet[1].name.id == 12 then --choppy planet - trap(entity, false) - if choppy_entity_yield[entity.name] then - if event.buffer then event.buffer.clear() end - if not event.player_index then return end - local amount = get_ore_amount() - local second_item_amount = math_random(2,5) - local second_item = "wood" - local main_item = choppy_entity_yield[entity.name][math_random(1,#choppy_entity_yield[entity.name])] - - entity.surface.create_entity({ - name = "flying-text", - position = entity.position, - text = "+" .. amount .. " [item=" .. main_item .. "] +" .. second_item_amount .. " [item=" .. second_item .. "]", - color = {r=0.8,g=0.8,b=0.8} - }) - - local player = game.players[event.player_index] - - local inserted_count = player.insert({name = main_item, count = amount}) - amount = amount - inserted_count - if amount > 0 then - entity.surface.spill_item_stack(player.position,{name = main_item, count = amount}, true) - end - - local inserted_count = player.insert({name = second_item, count = second_item_amount}) - second_item_amount = second_item_amount - inserted_count - if second_item_amount > 0 then - entity.surface.spill_item_stack(entity.position,{name = second_item, count = second_item_amount}, true) - end - end + Event_functions.trap(entity, false) + Event_functions.choppy_loot(event) end if entity.name == "rock-huge" or entity.name == "rock-big" or entity.name == "sand-rock-big" then if global.objective.planet[1].name.id ~= 11 and global.objective.planet[1].name.id ~= 16 then --rocky and maze planet @@ -804,26 +475,12 @@ local function on_player_mined_entity(event) end end -local function shred_simple_entities(entity) - --game.print(entity.name) - if game.forces["enemy"].evolution_factor < 0.25 then return end - local simple_entities = entity.surface.find_entities_filtered({type = {"simple-entity", "tree"}, area = {{entity.position.x - 3, entity.position.y - 3},{entity.position.x + 3, entity.position.y + 3}}}) - if #simple_entities == 0 then return end - for i = 1, #simple_entities, 1 do - if not simple_entities[i] then break end - if simple_entities[i].valid then - simple_entities[i].die("enemy", simple_entities[i]) - end - end -end - local function on_entity_died(event) - if event.entity.type == "tree" and global.objective.planet[1].name.id == 12 then --choppy planet if event.cause then if event.cause.valid then - if event.cause.force.index ~= 2 then - trap(event.entity, false) + if event.cause.force.name ~= "enemy" then + Event_functions.trap(event.entity, false) end end end @@ -839,21 +496,22 @@ local function on_entity_died(event) global.objective.active_biters[entity.unit_number] = nil end if entity.force.name == "scrapyard" and entity.name == "gun-turret" and global.objective.planet[1].name.id == 16 then - trap(entity, true) + Event_functions.trap(entity, true) end if entity.force.index == 3 then if event.cause then if event.cause.valid then if event.cause.force.index == 2 then - shred_simple_entities(entity) + Event_functions.shred_simple_entities(entity) end end end end +end --on_player_mined_entity(event) --if not event.entity.valid then return end -end + --end local function on_research_finished(event) event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 100 + global.objective.invupgradetier * 5 @@ -906,29 +564,8 @@ end -- end local function on_player_changed_position(event) - if global.objective.planet[1].name.id ~= 14 then return end --lava planet - local player = game.players[event.player_index] - if not player.character then return end - if player.character.driving then return end - if player.surface.name == "cargo_wagon" then return end - local safe = {"stone-path", "concrete", "hazard-concrete-left", "hazard-concrete-right", "refined-concrete", "refined-hazard-concrete-left", "refined-hazard-concrete-right"} - local pavement = player.surface.get_tile(player.position.x, player.position.y) - for i = 1, 7, 1 do - if pavement.name == safe[i] then return end - end - if not global.flame_boots[player.index].steps then global.flame_boots[player.index].steps = {} end - local steps = global.flame_boots[player.index].steps - - local elements = #steps - - steps[elements + 1] = {x = player.position.x, y = player.position.y} - - if elements > 10 then - player.surface.create_entity({name = "fire-flame", position = steps[elements - 1], }) - for i = 1, elements, 1 do - steps[i] = steps[i+1] - end - steps[elements + 1] = nil + if global.objective.planet[1].name.id == 14 then --lava planet + Event_functions.lava_planet(event) end end diff --git a/maps/chronosphere/tick_functions.lua b/maps/chronosphere/tick_functions.lua new file mode 100644 index 00000000..fb804d12 --- /dev/null +++ b/maps/chronosphere/tick_functions.lua @@ -0,0 +1,135 @@ +local Public = {} + +function Public.check_chronoprogress() + local objective = global.objective + --game.print(objective.chronotimer) + if objective.chronotimer == objective.chrononeeds - 180 then + game.print("Comfylatron: Acumulator charging disabled, 180 seconds countdown to jump!", {r=0.98, g=0.66, b=0.22}) + elseif objective.chronotimer == objective.chrononeeds - 60 then + game.print("Comfylatron: ChronoTrain nearly charged! Grab what you can, we leaving in 60 seconds!", {r=0.98, g=0.66, b=0.22}) + elseif objective.chronotimer == objective.chrononeeds - 30 then + game.print("Comfylatron: You better hurry up! 30 seconds remaining!", {r=0.98, g=0.66, b=0.22}) + elseif objective.chronotimer >= objective.chrononeeds - 10 and objective.chrononeeds - objective.chronotimer > 0 then + game.print("Comfylatron: Jump in " .. objective.chrononeeds - objective.chronotimer .. " seconds!", {r=0.98, g=0.66, b=0.22}) + end + if objective.chronotimer >= objective.chrononeeds then + return true + end + return false +end + +function Public.charge_chronosphere() + if not global.acumulators then return end + local objective = global.objective + if not objective.chronotimer then return end + if objective.chronotimer < 20 then return end + if objective.planet[1].name.id == 17 then return end + local acus = global.acumulators + if #acus < 1 then return end + for i = 1, #acus, 1 do + if not acus[i].valid then return end + local energy = acus[i].energy + if energy > 3000000 and objective.chronotimer < objective.chrononeeds - 182 and objective.chronotimer > 130 then + acus[i].energy = acus[i].energy - 3000000 + objective.chronotimer = objective.chronotimer + 1 + game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (10 + 2 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1)) * global.difficulty_vote_value) + --log("energy charged from acu") + end + end +end + +function Public.transfer_pollution() + local surface = game.surfaces["cargo_wagon"] + if not surface then return end + local pollution = surface.get_total_pollution() * (3 / (global.objective.filterupgradetier / 3 + 1)) * global.difficulty_vote_value + game.surfaces[global.active_surface_index].pollute(global.locomotive.position, pollution) + surface.clear_pollution() +end + +function Public.boost_evolution() + local objective = global.objective + if objective.passivetimer > objective.chrononeeds * 0.50 and objective.chronojumps > 5 then + local evolution = game.forces.enemy.evolution_factor + evolution = evolution + (evolution / 2000) * global.difficulty_vote_value + if evolution > 1 then evolution = 1 end + game.forces.enemy.evolution_factor = evolution + end +end + +function Public.move_items() + if not global.comfychests then return end + if not global.comfychests2 then return end + if global.objective.game_lost == true then return end + local input = global.comfychests + local output = global.comfychests2 + for i = 1, 24, 1 do + if not input[i].valid then return end + if not output[i].valid then return end + + local input_inventory = input[i].get_inventory(defines.inventory.chest) + local output_inventory = output[i].get_inventory(defines.inventory.chest) + input_inventory.sort_and_merge() + local items = input_inventory.get_contents() + + for item, count in pairs(items) do + local inserted = output_inventory.insert({name = item, count = count}) + if inserted > 0 then + local removed = input_inventory.remove({name = item, count = inserted}) + end + end + end +end + +function Public.output_items() + if global.objective.game_lost == true then return end + if not global.outchests then return end + if not global.locomotive_cargo2 then return end + if not global.locomotive_cargo3 then return end + if global.objective.outupgradetier ~= 1 then return end + for i = 1, 4, 1 do + if not global.outchests[i].valid then return end + local inv = global.outchests[i].get_inventory(defines.inventory.chest) + inv.sort_and_merge() + local items = inv.get_contents() + for item, count in pairs(items) do + local inserted = nil + if i <= 2 then + inserted = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) + else + inserted = global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) + end + if inserted > 0 then + local removed = inv.remove({name = item, count = inserted}) + end + end + end +end + +function Public.repair_train() + local objective = global.objective + if not game.surfaces["cargo_wagon"] then return 0 end + if objective.game_lost == true then return 0 end + if objective.health < objective.max_health then + local inv = global.upgradechest[1].get_inventory(defines.inventory.chest) + local count = inv.get_item_count("repair-pack") + if count >= 5 and objective.toolsupgradetier == 4 and objective.health + 750 <= objective.max_health then + inv.remove({name = "repair-pack", count = 5}) + return -750 + elseif count >= 4 and objective.toolsupgradetier == 3 and objective.health + 600 <= objective.max_health then + inv.remove({name = "repair-pack", count = 4}) + return -600 + elseif count >= 3 and objective.toolsupgradetier == 2 and objective.health + 450 <= objective.max_health then + inv.remove({name = "repair-pack", count = 3}) + return -450 + elseif count >= 2 and objective.toolsupgradetier == 1 and objective.health + 300 <= objective.max_health then + inv.remove({name = "repair-pack", count = 2}) + return -300 + elseif count >= 1 then + inv.remove({name = "repair-pack", count = 1}) + return -150 + end + end + return 0 +end + +return Public diff --git a/maps/chronosphere/upgrades.lua b/maps/chronosphere/upgrades.lua index ac9548ab..8cf2e5df 100644 --- a/maps/chronosphere/upgrades.lua +++ b/maps/chronosphere/upgrades.lua @@ -264,7 +264,7 @@ local function check_poisondefense() inv.remove({name = "coin", count = 1000}) inv.remove({name = "poison-capsule", count = 50}) game.print("Comfylatron: I don't believe in your defense skills. I equipped train with poison defense.", {r=0.98, g=0.66, b=0.22}) - objective.posiondefense = objective.posiondefense + 1 + objective.poisondefense = objective.poisondefense + 1 end end end @@ -394,4 +394,22 @@ function Public.check_upgrades() end end +function Public.trigger_poison() + local objective = global.objective + if objective.poisondefense > 0 and objective.poisontimeout == 0 then + local objective = global.objective + objective.poisondefense = objective.poisondefense - 1 + objective.poisontimeout = 120 + local objs = {global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} + local surface = objective.surface + game.print("Comfylatron: Triggering poison defense. Let's kill everything!", {r=0.98, g=0.66, b=0.22}) + for i = 1, 4, 1 do + surface.create_entity({name = "poison-capsule", position = objs[i].position, force = "player", target = objs[i], speed = 1 }) + end + for i = 1 , #global.comfychests, 1 do + surface.create_entity({name = "poison-capsule", position = global.comfychests[i].position, force = "player", target = global.comfychests[i], speed = 1 }) + end + end +end + return Public From 60ea72ac8f05ac47e5314fe29637cc5f382cddff Mon Sep 17 00:00:00 2001 From: hanakocz Date: Mon, 24 Feb 2020 06:37:26 +0100 Subject: [PATCH 20/70] Add files via upload --- locale/en/locale.cfg | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index ad2192fa..b5275b1e 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -1,6 +1,11 @@ [biter_battles] map_info= - - B I T E R B A T T L E S - -\n\n Your objective is to defend your team's rocket silo and defeat the other team.\n Feed the opponent's biters with science packs to increase their strength.\n High tier science juice will yield stronger results.\n\n There is no major direct pvp combat.\n The horizontal border river is landfill proof.\n Construction robots can not build on the other teams's side.\n The random map layout is mirrored to provide a fair competition.\n\n West and East directions contain no biter nests,\n leaving room for factory expansion and outpost building.\n North and South directions are biter territory.\n\n There is no biter evolution from pollution, or destruction.\n ONLY feeding increases their power and will lead to your teams victory.\n\n The gui yields two different main stats for each team's biters.\n\n - EVO -\n The evolution of the biters, which increases when they get fed.\n It can go above 100% which unlocks endgame modifiers,\n granting them increased damage and health.\n\n - THREAT -\n Causes biters to attack and reduces when biters are slain.\n Feeding gives permanent "threat-income", as well as creating instant threat.\n A high threat value causes big attacks.\n Values of zero or below will cause no attacks. +[desert_oasis] +map_info_main_caption=--Desert Oasis-- +map_info_sub_caption=Survival in the dry sands. +map_info_text=This is a harsh world, the heat is unbearable and the sand is sharp like diamonds.\nWe shall not attempt to travel without a proper vehicle.\nMany building foundations are not possible to be set up outside of the oasis.\nRailways between them however should be possible.\n\nLuckily the ship's moisture meter module did survive the crash.\nIt may come in handy! + [fish_defender] map_info_main_caption=--Fish Defender-- map_info_sub_caption= *blb blubby blub* @@ -92,3 +97,6 @@ gui_2=Wave: gui_3=Threat: tooltip_1=high threat may empower biters tooltip_2=gain / minute + +[native_war] +map_info= - - N A T I V E W A R - -\n\n Defeat the enemy team Market !\n\nFeed your market with science to spawn waves of native biters and spitters !\nThey will soon after swarm to the opposing team Market !\n\nThe corridor is stewn with worms.\nRebuy dead worms and upgrade them to stem the opposing waves !\n\nExcess energy will activate a beam.\nBeam will progress with more excess energy.\nNatives will spawn according to the beam position.\n\nUse radars to spy opponent's base.\nUse your experience to improve damage and resistance of your biters.\nSpace science packs give extra life to your biters.\nConstruction robots may not build over the wall.\n From 99dc57582d6ca96f5d29719133cda1d6f14c6007 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Mon, 24 Feb 2020 06:42:11 +0100 Subject: [PATCH 21/70] Update control.lua --- control.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/control.lua b/control.lua index 540e817e..6e640b29 100644 --- a/control.lua +++ b/control.lua @@ -67,10 +67,10 @@ require "modules.autostash" ----------------------------- ---- enable maps here ---- (maps higher up in the list may be more actually playable) ---require "maps.chronosphere.main" +require "maps.chronosphere.main" --require "maps.fish_defender.main" --require "maps.biter_battles_v2.main" -require "maps.native_war.main" +--require "maps.native_war.main" --require "maps.mountain_fortress_v2.main" --require "maps.island_troopers.main" --require "maps.biter_hatchery.main" From 4fb93c76956f3dff88465dde2daf85091f566237 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Mon, 24 Feb 2020 07:13:38 +0100 Subject: [PATCH 22/70] Add files via upload --- maps/chronosphere/chronobubles.lua | 3 +- maps/chronosphere/event_functions.lua | 65 ++++++++++++++++++++------- maps/chronosphere/main.lua | 20 +++++++-- maps/chronosphere/ores.lua | 1 + maps/chronosphere/terrain.lua | 48 +++++++++++++++++++- maps/chronosphere/tick_functions.lua | 17 +++++++ 6 files changed, 132 insertions(+), 22 deletions(-) diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua index 077b560f..bb0c7e64 100644 --- a/maps/chronosphere/chronobubles.lua +++ b/maps/chronosphere/chronobubles.lua @@ -19,7 +19,8 @@ local variants = { [14] = {id = 14, name = "lava planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 0, oil = 0, biters = 6, moisture = -0.5, chance = 1, cumul_chance = 24}, [15] = {id = 15, name = "start planet", iron = 4, copper = 3, coal = 4, stone = 3, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24}, [16] = {id = 16, name = "hedge maze", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 1, oil = 2, biters = 16, moisture = -0.1, chance = 2, cumul_chance = 26}, - [17] = {id = 17, name = "fish market", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 100, moisture = 0, chance = 0, cumul_chance = 26} + [17] = {id = 17, name = "fish market", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 100, moisture = 0, chance = 0, cumul_chance = 26}, + [18] = {id = 18, name = "swamp planet", iron = 1, copper = 0, coal = 4, stone = 0, uranium = 0, oil = 2, biters = 16, moisture = 0.5, chance = 2, cumul_chance = 28} } local time_speed_variants = { diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua index e16f66dd..1b0c6857 100644 --- a/maps/chronosphere/event_functions.lua +++ b/maps/chronosphere/event_functions.lua @@ -1,6 +1,9 @@ local Public = {} local tick_tack_trap = require "functions.tick_tack_trap" +local unearthing_worm = require "functions.unearthing_worm" +local unearthing_biters = require "functions.unearthing_biters" + local math_random = math.random local math_floor = math.floor @@ -19,6 +22,22 @@ local function get_ore_amount() return amount end +local function reward_ores(amount, mined_loot, surface, player) + local i = player.insert {name = mined_loot, count = amount} + amount = amount - i + if amount > 0 then + if amount >= 50 then + for i = 1, math_floor(amount / 50), 1 do + surface.create_entity{name = "item-on-ground", position = player.position, stack = {name = mined_loot, count = 50}} + amount = amount - 50 + end + end + if amount > 0 then + surface.spill_item_stack(player.position, {name = mined_loot, count = amount},true) + end + end +end + function Public.biters_chew_rocks_faster(event) if event.entity.force.index ~= 3 then return end --Neutral Force if not event.cause then return end @@ -109,12 +128,7 @@ function Public.choppy_loot(event) }) local player = game.players[event.player_index] - - local inserted_count = player.insert({name = main_item, count = amount}) - amount = amount - inserted_count - if amount > 0 then - entity.surface.spill_item_stack(player.position,{name = main_item, count = amount}, true) - end + reward_ores(amount, main_item, entity.surface, player) local inserted_count = player.insert({name = second_item, count = second_item_amount}) second_item_amount = second_item_amount - inserted_count @@ -137,17 +151,36 @@ function Public.rocky_loot(event) text = "+" .. amount .. " [img=item/" .. mined_loot .. "]", color = {r=0.98, g=0.66, b=0.22} }) - local i = player.insert {name = mined_loot, count = amount} - amount = amount - i - if amount > 0 then - if amount >= 50 then - for i = 1, math_floor(amount / 50), 1 do - surface.create_entity{name = "item-on-ground", position = player.position, stack = {name = mined_loot, count = 50}} - amount = amount - 50 - end - end - surface.spill_item_stack(player.position, {name = mined_loot, count = amount},true) + reward_ores(amount, mined_loot, surface, player) +end + +local ore_yield = { + ["behemoth-biter"] = 5, + ["behemoth-spitter"] = 5, + ["behemoth-worm-turret"] = 9, + ["big-biter"] = 3, + ["big-spitter"] = 3, + ["big-worm-turret"] = 7, + ["biter-spawner"] = 16, + ["medium-biter"] = 2, + ["medium-spitter"] = 2, + ["medium-worm-turret"] = 5, + ["small-biter"] = 1, + ["small-spitter"] = 1, + ["small-worm-turret"] = 3, + ["spitter-spawner"] = 16, +} + +function Public.swamp_loot(event) + local surface = game.surfaces[global.active_surface_index] + local amount = get_ore_amount() / 10 + if ore_yield[event.entity.name] then + amount = get_ore_amount() / 10 * ore_yield[event.entity.name] end + game.print(amount) + local rock_mining = {"iron-ore", "coal", "coal", "coal", "coal"} + local mined_loot = rock_mining[math_random(1,#rock_mining)] + surface.spill_item_stack(event.entity.position,{name = mined_loot, count = amount}, true) end return Public diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 917ce251..ceedb93a 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -15,9 +15,6 @@ require "on_tick_schedule" require "modules.biter_noms_you" local Server = require 'utils.server' local Ai = require "maps.chronosphere.ai" -local unearthing_worm = require "functions.unearthing_worm" -local unearthing_biters = require "functions.unearthing_biters" - local Planets = require "maps.chronosphere.chronobubles" local Ores =require "maps.chronosphere.ores" local Reset = require "functions.soft_reset" @@ -292,7 +289,7 @@ local function set_objective_health(final_damage_amount) if objective.health > objective.max_health then objective.health = objective.max_health end if objective.health <= 0 then - Objective.objective_died() + Chrono.objective_died() end if objective.health < objective.max_health / 2 and final_damage_amount > 0 then Upgrades.trigger_poison() @@ -360,6 +357,12 @@ local function tick() --surface.force_generate_chunk_requests() end + if tick % 10 == 0 and global.objective.planet[1].name.id == 18 then + Tick_functions.spawn_poison() + Tick_functions.spawn_poison() + Tick_functions.spawn_poison() + Tick_functions.spawn_poison() + end if tick % 30 == 0 then if tick % 600 == 0 then Tick_functions.charge_chronosphere() @@ -446,6 +449,11 @@ local function on_entity_damaged(event) end end end + if global.objective.planet[1].name.id == 18 and event.entity.force.name == "enemy" then --swamp planet + if event.damage_type.name == "poison" then + event.entity.health = event.entity.health + event.final_damage_amount + end + end end local function pre_player_mined_item(event) @@ -498,6 +506,10 @@ local function on_entity_died(event) if entity.force.name == "scrapyard" and entity.name == "gun-turret" and global.objective.planet[1].name.id == 16 then Event_functions.trap(entity, true) end + if entity.force.name == "enemy" and entity.type == "unit-spawner" and global.objective.planet[1].name.id == 18 then + Ores.prospect_ores(event.entity, event.entity.surface, event.entity.position) + --Event_functions.swamp_loot(event) + end if entity.force.index == 3 then if event.cause then if event.cause.valid then diff --git a/maps/chronosphere/ores.lua b/maps/chronosphere/ores.lua index 6881150c..331dad55 100644 --- a/maps/chronosphere/ores.lua +++ b/maps/chronosphere/ores.lua @@ -113,6 +113,7 @@ function Public_ores.prospect_ores(entity, surface, pos) local chance = 10 if entity then if entity.name == "rock-huge" then chance = 40 end + if entity.type == "unit-spawner" then chance = 40 end if math_random(chance + math_floor(10 * planet[1].ore_richness.factor) ,100 + chance) >= 100 then spawn_ore_vein(surface, pos, planet) end diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index 795c28a7..7c6899b7 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -505,6 +505,49 @@ local function process_scrapyard_position(p, seed, tiles, entities, treasure, pl tiles[#tiles + 1] = {name = "stone-path", position = p} end +local function process_swamp_position(p, seed, tiles, entities, treasure, planet) + local scrapyard = get_noise("scrapyard", p, seed) + local biters = planet[1].name.biters + + if scrapyard < -0.70 or scrapyard > 0.70 then + tiles[#tiles + 1] = {name = "grass-3", position = p} + if math_random(1,50) == 1 then treasure[#treasure + 1] = p end + return + end + + if scrapyard < -0.60 or scrapyard > 0.60 then + tiles[#tiles + 1] = {name = "water-green", position = p} + return + end + if math_abs(scrapyard) > 0.40 and math_abs(scrapyard) < 0.60 then + if math_random(1,40) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 120 then entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p}end + tiles[#tiles + 1] = {name = "water-mud", position = p} + return + end + if math_abs(scrapyard) > 0.25 and math_abs(scrapyard) < 0.40 then + if math_random(1,80) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 120 then entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p}end + tiles[#tiles + 1] = {name = "water-shallow", position = p} + return + end + if scrapyard > -0.02 and scrapyard < 0.02 then + tiles[#tiles + 1] = {name = "water-green", position = p} + return + end + if scrapyard > -0.05 and scrapyard < 0.05 then + if math_random(1,100) > 42 then + entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} + else + if math_random(1,20) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + end + tiles[#tiles + 1] = {name = "grass-1", position = p} + return + end + if math_random(1, 120) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then + entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} + end + tiles[#tiles + 1] = {name = "grass-2", position = p} +end + local function process_fish_position(p, seed, tiles, entities, treasure, planet) local body_radius = 1984 --3072 local body_square_radius = body_radius ^ 2 @@ -593,7 +636,7 @@ local levels = { process_river_position, process_biter_position, process_scrapyard_position, - process_level_9_position, + process_swamp_position, process_fish_position, } @@ -948,6 +991,9 @@ local function process_chunk(surface, left_top) --if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 3, planet) return end if math_abs(left_top.y) <= 31 and math_abs(left_top.x - 864) <= 31 then fish_market(surface, left_top, 10, planet) return end fish_chunk(surface, left_top, 10, planet) + elseif id == 18 then --swamp planet + if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 9, planet) return end + if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 9, planet) return end else if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 7, planet) return end if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then biter_chunk(surface, left_top, 7, planet) return end diff --git a/maps/chronosphere/tick_functions.lua b/maps/chronosphere/tick_functions.lua index fb804d12..9b01ebc9 100644 --- a/maps/chronosphere/tick_functions.lua +++ b/maps/chronosphere/tick_functions.lua @@ -1,5 +1,7 @@ local Public = {} +local math_random = math.random + function Public.check_chronoprogress() local objective = global.objective --game.print(objective.chronotimer) @@ -132,4 +134,19 @@ function Public.repair_train() return 0 end +function Public.spawn_poison() + local surface = game.surfaces[global.active_surface_index] + local random_x = math_random(-460,460) + local random_y = math_random(-460,460) + local tile = surface.get_tile(random_x, random_y) + if not tile.valid then return end + if tile.name == "water-shallow" or tile.name == "water-mud" then + surface.create_entity({name = "poison-cloud", position = {x = random_x, y = random_y}}) + surface.create_entity({name = "poison-cloud", position = {x = random_x + 2, y = random_y + 2}}) + surface.create_entity({name = "poison-cloud", position = {x = random_x - 2, y = random_y - 2}}) + surface.create_entity({name = "poison-cloud", position = {x = random_x + 2, y = random_y - 2}}) + surface.create_entity({name = "poison-cloud", position = {x = random_x - 2, y = random_y + 2}}) + end +end + return Public From 26fc4d261d6355efbe7bf3b6e67435433cd3ff16 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Mon, 24 Feb 2020 07:17:31 +0100 Subject: [PATCH 23/70] overgrowth - fix crashes --- maps/overgrowth.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/maps/overgrowth.lua b/maps/overgrowth.lua index 232d6b23..785c6589 100644 --- a/maps/overgrowth.lua +++ b/maps/overgrowth.lua @@ -17,7 +17,7 @@ require "modules.trees_randomly_die" require "maps.overgrowth_map_info" -require "functions.soft_reset" +local Reset = require "functions.soft_reset" local rpg_t = require 'modules.rpg' local kaboom = require "functions.omegakaboom" @@ -52,7 +52,7 @@ local starting_items = { ["pistol"] = 1, ["firearm-magazine"] = 8 } - +--[[ local function create_particles(surface, name, position, amount, cause_position) local math_random = math.random @@ -80,8 +80,8 @@ local function create_particles(surface, name, position, amount, cause_position) } }) end -end - +end +]] local function spawn_market(surface, position) local market = surface.create_entity({name = "market", position = position, force = "neutral"}) --market.destructible = false @@ -139,7 +139,7 @@ function reset_map() global.trees_grow_chunks_charted = {} global.trees_grow_chunks_charted_counter = 0 - global.current_surface = soft_reset_map(global.current_surface, get_surface_settings(), starting_items) + global.current_surface = Reset.soft_reset_map(global.current_surface, get_surface_settings(), starting_items) reset_difficulty_poll() @@ -150,7 +150,7 @@ function reset_map() game.map_settings.enemy_evolution.time_factor = difficulties_votes_evo[4] - if rpg then rpg_reset_all_players() end + if rpg then rpg_t.rpg_reset_all_players() end end local function on_player_joined_game(event) @@ -195,12 +195,12 @@ local function on_player_mined_entity(event) trap(entity) if event.player_index then - create_particles(entity.surface, "wooden-particle", entity.position, 128, game.players[event.player_index].position) + --create_particles(entity.surface, "wooden-particle", entity.position, 128, game.players[event.player_index].position) game.players[event.player_index].insert({name = "coin", count = 1}) return end - create_particles(entity.surface, "wooden-particle", entity.position, 128) + --create_particles(entity.surface, "wooden-particle", entity.position, 128) if event.cause then if event.cause.force.name == "enemy" then return end From ee63daacfda54aeb043127017d17aa6e7ef4a02b Mon Sep 17 00:00:00 2001 From: hanakocz Date: Tue, 25 Feb 2020 14:49:30 +0100 Subject: [PATCH 24/70] Add files via upload --- maps/chronosphere/ai.lua | 24 +++++++++ maps/chronosphere/chrono.lua | 21 ++++---- maps/chronosphere/chronobubles.lua | 10 ++-- maps/chronosphere/event_functions.lua | 73 +++++++++++++++++++++++---- maps/chronosphere/main.lua | 51 +++++++++---------- maps/chronosphere/ores.lua | 6 +-- maps/chronosphere/tick_functions.lua | 22 ++++---- maps/chronosphere/upgrades.lua | 9 ++-- 8 files changed, 146 insertions(+), 70 deletions(-) diff --git a/maps/chronosphere/ai.lua b/maps/chronosphere/ai.lua index 908e1d27..7b14074a 100644 --- a/maps/chronosphere/ai.lua +++ b/maps/chronosphere/ai.lua @@ -373,6 +373,30 @@ local function create_attack_group(surface) end +Public.rogue_group = function() + if global.objective.chronotimer < 100 then return end + if not global.locomotive then return end + local surface = game.surfaces[global.active_surface_index] + local spawner = get_random_close_spawner(surface) + if not spawner then + return false + end + local position = {x = ((spawner.position.x + global.locomotive.position.x) * 0.5) , y = ((spawner.position.y + global.locomotive.position.y) * 0.5)} + local pos = surface.find_non_colliding_position("rocket-silo", position, 30, 1, true) + if not pos then return end + surface.set_multi_command({ + command={ + type=defines.command.build_base, + destination=pos, + distraction=defines.distraction.none, + ignore_planner = true + }, + unit_count = 16, + force = "enemy", + unit_search_distance=128 + }) +end + Public.pre_main_attack = function() if global.objective.chronotimer < 100 then return end local surface = game.surfaces[global.active_surface_index] diff --git a/maps/chronosphere/chrono.lua b/maps/chronosphere/chrono.lua index 2df8ab23..886cd6f0 100644 --- a/maps/chronosphere/chrono.lua +++ b/maps/chronosphere/chrono.lua @@ -1,8 +1,8 @@ -local Public = {} +local Public_chrono = {} local Server = require 'utils.server' -function Public.objective_died() +function Public_chrono.objective_died() local objective = global.objective if objective.game_lost == true then return end objective.health = 0 @@ -40,7 +40,7 @@ local function overstayed() return false end -function Public.process_jump(choice) +function Public_chrono.process_jump(choice) local objective = global.objective local overstayed = overstayed() objective.chronojumps = objective.chronojumps + 1 @@ -53,19 +53,22 @@ function Public.process_jump(choice) if objective.chronojumps == 6 then game.print("Comfylatron: Biters start to evolve faster! We need to charge forward or they will be stronger! (hover over timer to see evolve timer)", {r=0.98, g=0.66, b=0.22}) - elseif objective.chronojumps == 15 then + elseif objective.chronojumps >= 15 and objective.computermessage == 0 then game.print("Comfylatron: You know...I have big quest. Deliver fish to fish market. But this train is broken. Please help me fix the train computer!", {r=0.98, g=0.66, b=0.22}) - elseif objective.chronojumps == 20 then + objective.computermessage = 1 + elseif objective.chronojumps >= 20 and objective.computermessage == 2 then game.print("Comfylatron: Ah, we need to give this machine more power and better navigation chipset. Please bring me some additional things.", {r=0.98, g=0.66, b=0.22}) - elseif objective.chronojumps == 25 then + objective.computermessage = 3 + elseif objective.chronojumps >= 25 and objective.computermessage == 4 then game.print("Comfylatron: Finally found the main issue. We will need to rebuild whole processor. Exactly what I feared of. Just a few more things...", {r=0.98, g=0.66, b=0.22}) + objective.computermessage = 5 end if overstayed then game.print("Comfylatron: Looks like you stayed on previous planet for so long that enemies on other planets had additional time to evolve!", {r=0.98, g=0.66, b=0.22}) end end -function Public.get_wagons() +function Public_chrono.get_wagons() local inventories = {one = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon), two = global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon)} inventories.one.sort_and_merge() inventories.two.sort_and_merge() @@ -79,7 +82,7 @@ function Public.get_wagons() return wagons end -function Public.post_jump() +function Public_chrono.post_jump() local objective = global.objective game.forces.enemy.reset_evolution() if objective.chronojumps + objective.passivejumps <= 40 and objective.planet[1].name.id ~= 17 then @@ -102,4 +105,4 @@ function Public.post_jump() game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.8 end -return Public +return Public_chrono diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua index bb0c7e64..3f1eb053 100644 --- a/maps/chronosphere/chronobubles.lua +++ b/maps/chronosphere/chronobubles.lua @@ -20,16 +20,16 @@ local variants = { [15] = {id = 15, name = "start planet", iron = 4, copper = 3, coal = 4, stone = 3, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24}, [16] = {id = 16, name = "hedge maze", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 1, oil = 2, biters = 16, moisture = -0.1, chance = 2, cumul_chance = 26}, [17] = {id = 17, name = "fish market", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 100, moisture = 0, chance = 0, cumul_chance = 26}, - [18] = {id = 18, name = "swamp planet", iron = 1, copper = 0, coal = 4, stone = 0, uranium = 0, oil = 2, biters = 16, moisture = 0.5, chance = 2, cumul_chance = 28} + [18] = {id = 18, name = "swamp planet", iron = 2, copper = 0, coal = 3, stone = 0, uranium = 0, oil = 2, biters = 16, moisture = 0.5, chance = 2, cumul_chance = 28} } local time_speed_variants = { [1] = {name = "static", timer = 0}, [2] = {name = "normal", timer = 100}, - [3] = {name = "slow", timer = 50}, - [4] = {name = "superslow", timer = 25}, - [5] = {name = "fast", timer = 200}, - [6] = {name = "superfast", timer = 400} + [3] = {name = "slow", timer = 200}, + [4] = {name = "superslow", timer = 400}, + [5] = {name = "fast", timer = 50}, + [6] = {name = "superfast", timer = 25} } local richness = { diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua index 1b0c6857..ee7cce15 100644 --- a/maps/chronosphere/event_functions.lua +++ b/maps/chronosphere/event_functions.lua @@ -1,4 +1,4 @@ -local Public = {} +local Public_event = {} local tick_tack_trap = require "functions.tick_tack_trap" local unearthing_worm = require "functions.unearthing_worm" @@ -38,7 +38,7 @@ local function reward_ores(amount, mined_loot, surface, player) end end -function Public.biters_chew_rocks_faster(event) +function Public_event.biters_chew_rocks_faster(event) if event.entity.force.index ~= 3 then return end --Neutral Force if not event.cause then return end if not event.cause.valid then return end @@ -46,7 +46,7 @@ function Public.biters_chew_rocks_faster(event) event.entity.health = event.entity.health - event.final_damage_amount * 5 end -function Public.isprotected(entity) +function Public_event.isprotected(entity) if entity.surface.name == "cargo_wagon" then return true end local protected = {global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} for i = 1, #global.comfychests,1 do @@ -60,7 +60,7 @@ function Public.isprotected(entity) return false end -function Public.trap(entity, trap) +function Public_event.trap(entity, trap) if trap then tick_tack_trap(entity.surface, entity.position) tick_tack_trap(entity.surface, {x = entity.position.x + math_random(-2,2), y = entity.position.y + math_random(-2,2)}) @@ -71,7 +71,7 @@ function Public.trap(entity, trap) if math_random(1,64) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end end -function Public.lava_planet(event) +function Public_event.lava_planet(event) local player = game.players[event.player_index] if not player.character then return end if player.character.driving then return end @@ -97,7 +97,7 @@ function Public.lava_planet(event) end end -function Public.shred_simple_entities(entity) +function Public_event.shred_simple_entities(entity) --game.print(entity.name) if game.forces["enemy"].evolution_factor < 0.25 then return end local simple_entities = entity.surface.find_entities_filtered({type = {"simple-entity", "tree"}, area = {{entity.position.x - 3, entity.position.y - 3},{entity.position.x + 3, entity.position.y + 3}}}) @@ -110,7 +110,7 @@ function Public.shred_simple_entities(entity) end end -function Public.choppy_loot(event) +function Public_event.choppy_loot(event) local entity = event.entity if choppy_entity_yield[entity.name] then if event.buffer then event.buffer.clear() end @@ -138,7 +138,7 @@ function Public.choppy_loot(event) end end -function Public.rocky_loot(event) +function Public_event.rocky_loot(event) local surface = game.surfaces[global.active_surface_index] local player = game.players[event.player_index] surface.spill_item_stack(player.position,{name = "raw-fish", count = math_random(1,3)},true) @@ -171,16 +171,67 @@ local ore_yield = { ["spitter-spawner"] = 16, } -function Public.swamp_loot(event) +function Public_event.swamp_loot(event) local surface = game.surfaces[global.active_surface_index] local amount = get_ore_amount() / 10 if ore_yield[event.entity.name] then amount = get_ore_amount() / 10 * ore_yield[event.entity.name] end game.print(amount) - local rock_mining = {"iron-ore", "coal", "coal", "coal", "coal"} + local rock_mining = {"iron-ore", "iron-ore", "coal", "coal", "coal"} local mined_loot = rock_mining[math_random(1,#rock_mining)] surface.spill_item_stack(event.entity.position,{name = mined_loot, count = amount}, true) end -return Public +function Public_event.biter_immunities(event) + local planet = global.objective.planet[1].name.id + local objective = global.objective + if event.damage_type.name == "fire" then + if planet == 14 then --lava planet + event.entity.health = event.entity.health + event.final_damage_amount + local fire = event.entity.stickers + if fire and #fire > 0 then + for i = 1, #fire, 1 do + if fire[i].sticked_to == event.entity and fire[i].name == "fire-sticker" then fire[i].destroy() break end + end + end + -- else -- other planets + -- event.entity.health = math_floor(event.entity.health + event.final_damage_amount - (event.final_damage_amount / (1 + 0.02 * global.difficulty_vote_value * objective.chronojumps))) + end + elseif event.damage_type.name == "poison" then + if planet == 18 then --swamp planet + event.entity.health = event.entity.health + event.final_damage_amount + end + end +end + +function Public_event.flamer_nerfs() + local objective = global.objective + local flamer_power = 0 + local difficulty = global.difficulty_vote_value + if difficulty > 1 then + difficulty = 1 + ((difficulty - 1) / 2) + elseif difficulty < 1 then + difficulty = 1 - ((1 - difficulty) / 2) + end + local flame_researches = { + [1] = {name = "refined-flammables-1", bonus = 0.2}, + [2] = {name = "refined-flammables-2", bonus = 0.2}, + [3] = {name = "refined-flammables-3", bonus = 0.2}, + [4] = {name = "refined-flammables-4", bonus = 0.3}, + [5] = {name = "refined-flammables-5", bonus = 0.3}, + [6] = {name = "refined-flammables-6", bonus = 0.4}, + [7] = {name = "refined-flammables-7", bonus = 0.2} + } + for i = 1, 6, 1 do + if game.forces.player.technologies[flame_researches[i].name].researched then + flamer_power = flamer_power + flame_researches[i].bonus + end + end + flamer_power = flamer_power + (game.forces.player.technologies[flame_researches[7].name].level - 7) * 0.2 + game.forces.player.set_ammo_damage_modifier("flamethrower", flamer_power - 0.02 * difficulty * objective.chronojumps) + game.forces.player.set_turret_attack_modifier("flamethrower-turret", flamer_power - 0.02 * difficulty * objective.chronojumps) +end + + +return Public_event diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index ceedb93a..47a7b91b 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -154,6 +154,7 @@ local function reset_map() local objective = global.objective objective.computerupgrade = 0 objective.computerparts = 0 + objective.computermessage = 0 local map_gen_settings = get_map_gen_settings() Planets.determine_planet(nil) local planet = global.objective.planet @@ -328,6 +329,7 @@ local function chronojump(choice) render_train_hp() game.delete_surface(oldsurface) Chrono.post_jump() + Event_functions.flamer_nerfs() surface.pollute(global.locomotive.position, 150 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps)) end @@ -341,34 +343,36 @@ local tick_minute_functions = { [300 * 3 + 30 * 4] = Ai.perform_main_attack, [300 * 3 + 30 * 5] = Ai.perform_main_attack, -- call perform_main_attack 7 times on different ticks [300 * 4] = Ai.send_near_biters_to_objective, - [300 * 5] = Ai.wake_up_sleepy_groups + [300 * 5] = Ai.wake_up_sleepy_groups, + [300] = Ai.rogue_group } local function tick() + local objective = global.objective local tick = game.tick - if tick % 60 == 30 and global.objective.chronotimer < 64 then + if tick % 60 == 30 and objective.chronotimer < 64 then local surface = game.surfaces[global.active_surface_index] - if global.objective.planet[1].name.id == 17 then - surface.request_to_generate_chunks({-800,0}, 3 + math_floor(global.objective.chronotimer / 5)) + if objective.planet[1].name.id == 17 then + surface.request_to_generate_chunks({-800,0}, 3 + math_floor(objective.chronotimer / 5)) else - surface.request_to_generate_chunks({0,0}, 3 + math_floor(global.objective.chronotimer / 5)) + surface.request_to_generate_chunks({0,0}, 3 + math_floor(objective.chronotimer / 5)) end --surface.force_generate_chunk_requests() end - if tick % 10 == 0 and global.objective.planet[1].name.id == 18 then - Tick_functions.spawn_poison() - Tick_functions.spawn_poison() + if tick % 10 == 0 and objective.planet[1].name.id == 18 then Tick_functions.spawn_poison() Tick_functions.spawn_poison() + --Tick_functions.spawn_poison() + --Tick_functions.spawn_poison() end if tick % 30 == 0 then if tick % 600 == 0 then Tick_functions.charge_chronosphere() Tick_functions.transfer_pollution() - if global.objective.poisontimeout > 0 then - global.objective.poisontimeout = global.objective.poisontimeout - 1 + if objective.poisontimeout > 0 then + objective.poisontimeout = objective.poisontimeout - 1 end end if tick % 1800 == 0 then @@ -379,9 +383,12 @@ local function tick() end local key = tick % 3600 if tick_minute_functions[key] then tick_minute_functions[key]() end - if tick % 60 == 0 and global.objective.planet[1].name.id ~= 17 then - global.objective.chronotimer = global.objective.chronotimer + 1 - global.objective.passivetimer = global.objective.passivetimer + 1 + if tick % 60 == 0 and objective.planet[1].name.id ~= 17 then + objective.chronotimer = objective.chronotimer + 1 + objective.passivetimer = objective.passivetimer + 1 + if objective.chronojumps > 0 then + game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (0.5 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1)) * global.difficulty_vote_value) + end if Tick_functions.check_chronoprogress() then chronojump(nil) end end if tick % 120 == 0 then @@ -438,21 +445,8 @@ local function on_entity_damaged(event) if not event.entity.valid then return end if not event.entity.health then return end Event_functions.biters_chew_rocks_faster(event) - if global.objective.planet[1].name.id == 14 and event.entity.force.name == "enemy" then --lava planet - if event.damage_type.name == "fire" then - event.entity.health = event.entity.health + event.final_damage_amount - local fire = event.entity.stickers - if fire and #fire > 0 then - for i = 1, #fire, 1 do - if fire[i].sticked_to == event.entity and fire[i].name == "fire-sticker" then fire[i].destroy() break end - end - end - end - end - if global.objective.planet[1].name.id == 18 and event.entity.force.name == "enemy" then --swamp planet - if event.damage_type.name == "poison" then - event.entity.health = event.entity.health + event.final_damage_amount - end + if event.entity.force.name == "enemy" then + Event_functions.biter_immunities(event) end end @@ -527,6 +521,7 @@ end local function on_research_finished(event) event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 100 + global.objective.invupgradetier * 5 + Event_functions.flamer_nerfs() if not event.research.force.technologies["steel-axe"].researched then return end event.research.force.manual_mining_speed_modifier = 1 + game.forces.player.mining_drill_productivity_bonus * 4 end diff --git a/maps/chronosphere/ores.lua b/maps/chronosphere/ores.lua index 331dad55..052d2728 100644 --- a/maps/chronosphere/ores.lua +++ b/maps/chronosphere/ores.lua @@ -64,9 +64,9 @@ local function get_size_of_ore(ore, planet) return final_size end -local function get_oil_amount(pos, oil_w) +local function get_oil_amount(pos, oil_w, richness) local hundred_percent = 300000 - return (hundred_percent / 40) * (1+global.objective.chronojumps) * oil_w + return (hundred_percent / 50) * (1+global.objective.chronojumps) * oil_w * richness end local function spawn_ore_vein(surface, pos, planet) @@ -101,7 +101,7 @@ local function spawn_ore_vein(surface, pos, planet) --if surface.can_place_entity({name = choice, position = pos, amount = 1}) then if choice == "crude-oil" then - surface.create_entity({name = "crude-oil", position = pos, amount = get_oil_amount(pos, oil.w) }) + surface.create_entity({name = "crude-oil", position = pos, amount = get_oil_amount(pos, oil.w, planet[1].ore_richness.factor) }) else draw_noise_ore_patch(pos, choice, surface, get_size_of_ore(choice, planet), richness, mixed) end diff --git a/maps/chronosphere/tick_functions.lua b/maps/chronosphere/tick_functions.lua index 9b01ebc9..8df2b712 100644 --- a/maps/chronosphere/tick_functions.lua +++ b/maps/chronosphere/tick_functions.lua @@ -1,8 +1,8 @@ -local Public = {} +local Public_tick = {} local math_random = math.random -function Public.check_chronoprogress() +function Public_tick.check_chronoprogress() local objective = global.objective --game.print(objective.chronotimer) if objective.chronotimer == objective.chrononeeds - 180 then @@ -20,7 +20,7 @@ function Public.check_chronoprogress() return false end -function Public.charge_chronosphere() +function Public_tick.charge_chronosphere() if not global.acumulators then return end local objective = global.objective if not objective.chronotimer then return end @@ -40,7 +40,7 @@ function Public.charge_chronosphere() end end -function Public.transfer_pollution() +function Public_tick.transfer_pollution() local surface = game.surfaces["cargo_wagon"] if not surface then return end local pollution = surface.get_total_pollution() * (3 / (global.objective.filterupgradetier / 3 + 1)) * global.difficulty_vote_value @@ -48,17 +48,17 @@ function Public.transfer_pollution() surface.clear_pollution() end -function Public.boost_evolution() +function Public_tick.boost_evolution() local objective = global.objective if objective.passivetimer > objective.chrononeeds * 0.50 and objective.chronojumps > 5 then local evolution = game.forces.enemy.evolution_factor - evolution = evolution + (evolution / 2000) * global.difficulty_vote_value + evolution = evolution + (evolution / 500) * global.difficulty_vote_value if evolution > 1 then evolution = 1 end game.forces.enemy.evolution_factor = evolution end end -function Public.move_items() +function Public_tick.move_items() if not global.comfychests then return end if not global.comfychests2 then return end if global.objective.game_lost == true then return end @@ -82,7 +82,7 @@ function Public.move_items() end end -function Public.output_items() +function Public_tick.output_items() if global.objective.game_lost == true then return end if not global.outchests then return end if not global.locomotive_cargo2 then return end @@ -107,7 +107,7 @@ function Public.output_items() end end -function Public.repair_train() +function Public_tick.repair_train() local objective = global.objective if not game.surfaces["cargo_wagon"] then return 0 end if objective.game_lost == true then return 0 end @@ -134,7 +134,7 @@ function Public.repair_train() return 0 end -function Public.spawn_poison() +function Public_tick.spawn_poison() local surface = game.surfaces[global.active_surface_index] local random_x = math_random(-460,460) local random_y = math_random(-460,460) @@ -149,4 +149,4 @@ function Public.spawn_poison() end end -return Public +return Public_tick diff --git a/maps/chronosphere/upgrades.lua b/maps/chronosphere/upgrades.lua index 8cf2e5df..82169c14 100644 --- a/maps/chronosphere/upgrades.lua +++ b/maps/chronosphere/upgrades.lua @@ -284,19 +284,21 @@ local function check_upgrade_computer() local count9 = inv.get_item_count("rocket-silo") local count10 = inv.get_item_count("satellite") - if countcoins >= 5000 and count2 >= 1000 and count8 >= 2000 and objective.computerupgrade == 0 and objective.chronojumps >= 15 then + if countcoins >= 5000 and count2 >= 1000 and count8 >= 2000 and objective.computerupgrade == 0 and objective.chronojumps >= 15 and objective.computermessage == 1 then inv.remove({name = "coin", count = 5000}) inv.remove({name = "advanced-circuit", count = 1000}) inv.remove({name = "copper-plate", count = 2000}) game.print("Comfylatron: Thanks for fixing train navigation. I can now get us rid of very poor worlds. It will still need more work though.", {r=0.98, g=0.66, b=0.22}) + objective.computermessage = 2 objective.computerupgrade = objective.computerupgrade + 1 - elseif countcoins >= 10000 and count3 >= 1000 and count7 >= 1 and objective.computerupgrade == 1 and objective.chronojumps >= 20 then + elseif countcoins >= 10000 and count3 >= 1000 and count7 >= 1 and objective.computerupgrade == 1 and objective.chronojumps >= 20 and objective.computermessage == 3 then inv.remove({name = "coin", count = 10000}) inv.remove({name = "processing-unit", count = 1000}) inv.remove({name = "nuclear-reactor", count = 1}) + objective.computermessage = 4 objective.computerupgrade = objective.computerupgrade + 1 game.print("Comfylatron: Perfect! Now we have train reactor and even better destination precision. I will get to you later what still needs to be done.", {r=0.98, g=0.66, b=0.22}) - elseif objective.computerupgrade == 2 and objective.chronojumps >= 25 then + elseif objective.computerupgrade == 2 and objective.chronojumps >= 25 and objective.computermessage == 5 then if countcoins >= 2000 and count4 >= 100 and count5 >= 100 and count6 >= 50 and objective.computerparts < 10 then inv.remove({name = "coin", count = 2000}) inv.remove({name = "low-density-structure", count = 100}) @@ -312,6 +314,7 @@ local function check_upgrade_computer() inv.remove({name = "satellite", count = 1 }) inv.remove({name = "rocket-silo", count = 1 }) game.print("Comfylatron: Time synchronized. Calculating time and space destination. Success. Jump once more and let me deliver the fish finally. This trip is getting long.", {r=0.98, g=0.66, b=0.22}) + objective.computermessage = 6 objective.computerupgrade = objective.computerupgrade + 1 end end From fd22555361b68d8ce8f5cbb892ff7fbea6b19614 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Tue, 25 Feb 2020 15:47:10 +0100 Subject: [PATCH 25/70] disabled desync --- maps/chronosphere/ai.lua | 46 +++++++++++++++++++------------------- maps/chronosphere/main.lua | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/maps/chronosphere/ai.lua b/maps/chronosphere/ai.lua index 7b14074a..27506a5f 100644 --- a/maps/chronosphere/ai.lua +++ b/maps/chronosphere/ai.lua @@ -373,29 +373,29 @@ local function create_attack_group(surface) end -Public.rogue_group = function() - if global.objective.chronotimer < 100 then return end - if not global.locomotive then return end - local surface = game.surfaces[global.active_surface_index] - local spawner = get_random_close_spawner(surface) - if not spawner then - return false - end - local position = {x = ((spawner.position.x + global.locomotive.position.x) * 0.5) , y = ((spawner.position.y + global.locomotive.position.y) * 0.5)} - local pos = surface.find_non_colliding_position("rocket-silo", position, 30, 1, true) - if not pos then return end - surface.set_multi_command({ - command={ - type=defines.command.build_base, - destination=pos, - distraction=defines.distraction.none, - ignore_planner = true - }, - unit_count = 16, - force = "enemy", - unit_search_distance=128 - }) -end +-- Public.rogue_group = function() +-- if global.objective.chronotimer < 100 then return end +-- if not global.locomotive then return end +-- local surface = game.surfaces[global.active_surface_index] +-- local spawner = get_random_close_spawner(surface) +-- if not spawner then +-- return false +-- end +-- local position = {x = ((spawner.position.x + global.locomotive.position.x) * 0.5) , y = ((spawner.position.y + global.locomotive.position.y) * 0.5)} +-- local pos = surface.find_non_colliding_position("rocket-silo", position, 30, 1, true) +-- if not pos then return end +-- surface.set_multi_command({ +-- command={ +-- type=defines.command.build_base, +-- destination=pos, +-- distraction=defines.distraction.none, +-- ignore_planner = true +-- }, +-- unit_count = 16, +-- force = "enemy", +-- unit_search_distance=128 +-- }) +-- end Public.pre_main_attack = function() if global.objective.chronotimer < 100 then return end diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 47a7b91b..d548e4e6 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -344,7 +344,7 @@ local tick_minute_functions = { [300 * 3 + 30 * 5] = Ai.perform_main_attack, -- call perform_main_attack 7 times on different ticks [300 * 4] = Ai.send_near_biters_to_objective, [300 * 5] = Ai.wake_up_sleepy_groups, - [300] = Ai.rogue_group + --[300] = Ai.rogue_group } From 7d7a25e1e667e88c2352585e59aa6b811726bb66 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Thu, 5 Mar 2020 15:56:59 +0100 Subject: [PATCH 26/70] big update --- maps/chronosphere/ai.lua | 10 +- maps/chronosphere/chrono.lua | 47 +++++- maps/chronosphere/chronobubles.lua | 22 ++- maps/chronosphere/comfylatron.lua | 2 +- maps/chronosphere/event_functions.lua | 34 +++- maps/chronosphere/gui.lua | 46 ++++-- maps/chronosphere/locomotive.lua | 198 ++++++++++------------ maps/chronosphere/main.lua | 114 ++++++++++--- maps/chronosphere/ores.lua | 1 + maps/chronosphere/terrain.lua | 217 +++++++++++-------------- maps/chronosphere/terrain_specials.lua | 102 ++++++++++++ maps/chronosphere/tick_functions.lua | 119 +++++++++++++- maps/chronosphere/treasure.lua | 17 +- maps/chronosphere/upgrades.lua | 43 ++++- 14 files changed, 669 insertions(+), 303 deletions(-) create mode 100644 maps/chronosphere/terrain_specials.lua diff --git a/maps/chronosphere/ai.lua b/maps/chronosphere/ai.lua index 27506a5f..c07bdc78 100644 --- a/maps/chronosphere/ai.lua +++ b/maps/chronosphere/ai.lua @@ -182,10 +182,10 @@ end Public.send_near_biters_to_objective = function() if game.tick < 36000 then return end if not global.locomotive then return end - if not global.locomotive_cargo then return end - if not global.locomotive_cargo2 then return end - if not global.locomotive_cargo3 then return end - local targets = {global.locomotive, global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} + if not global.locomotive_cargo[1] then return end + if not global.locomotive_cargo[2] then return end + if not global.locomotive_cargo[3] then return end + local targets = {global.locomotive, global.locomotive, global.locomotive_cargo[1], global.locomotive_cargo[2], global.locomotive_cargo[3]} local random_target = targets[math_random(1, #targets)] if global.objective.game_lost then return end local surface = random_target.surface @@ -269,7 +269,7 @@ end local function send_group(unit_group, nearest_player_unit) - local targets = {global.locomotive, global.locomotive, nearest_player_unit, nearest_player_unit, nearest_player_unit, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} + local targets = {global.locomotive, global.locomotive, nearest_player_unit, nearest_player_unit, nearest_player_unit, global.locomotive_cargo[1], global.locomotive_cargo[2], global.locomotive_cargo[3]} local target = targets[math_random(1, #targets)] if not target.valid then colonize(unit_group) return end local surface = target.surface diff --git a/maps/chronosphere/chrono.lua b/maps/chronosphere/chrono.lua index 886cd6f0..bfb328e1 100644 --- a/maps/chronosphere/chrono.lua +++ b/maps/chronosphere/chrono.lua @@ -9,12 +9,10 @@ function Public_chrono.objective_died() local surface = objective.surface game.print("The chronotrain was destroyed!") game.print("Comfylatron is going to kill you for that...he has time machine after all!") - surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo.position}) - global.locomotive_cargo.destroy() - surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo2.position}) - global.locomotive_cargo2.destroy() - surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo3.position}) - global.locomotive_cargo3.destroy() + for i = 1, 3, 1 do + surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo[i].position}) + global.locomotive_cargo[i].destroy() + end for i = 1, #global.comfychests,1 do --surface.create_entity({name = "big-artillery-explosion", position = global.comfychests[i].position}) global.comfychests[i].destroy() @@ -40,11 +38,22 @@ local function overstayed() return false end +local function check_nuke_silos() + local objective = global.objective + if objective.dangers and #objective.dangers > 1 then + for i = 1, #objective.dangers, 1 do + if objective.dangers[i].destroyed == true then + objective.looted_nukes = objective.looted_nukes + 5 + end + end + end +end + function Public_chrono.process_jump(choice) local objective = global.objective local overstayed = overstayed() objective.chronojumps = objective.chronojumps + 1 - objective.chrononeeds = 2000 + 500 * objective.chronojumps + objective.chrononeeds = 2000 + 400 * objective.chronojumps objective.passivetimer = 0 objective.chronotimer = 0 local message = "Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. global.objective.chronojumps @@ -66,18 +75,27 @@ function Public_chrono.process_jump(choice) if overstayed then game.print("Comfylatron: Looks like you stayed on previous planet for so long that enemies on other planets had additional time to evolve!", {r=0.98, g=0.66, b=0.22}) end + if objective.planet[1].name.id == 19 then + check_nuke_silos() + end end function Public_chrono.get_wagons() - local inventories = {one = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon), two = global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon)} + local inventories = { + one = global.locomotive_cargo[1].get_inventory(defines.inventory.cargo_wagon), + two = global.locomotive_cargo[2].get_inventory(defines.inventory.cargo_wagon), + three = global.locomotive_cargo[3].get_inventory(defines.inventory.cargo_wagon) + } inventories.one.sort_and_merge() inventories.two.sort_and_merge() local wagons = {} wagons[1] = {inventory = inventories.one.get_contents(), bar = inventories.one.get_bar(), filters = {}} wagons[2] = {inventory = inventories.two.get_contents(), bar = inventories.two.get_bar(), filters = {}} + wagons[3] = {inventory = inventories.three.get_contents(), bar = inventories.three.get_bar(), filters = {}} for i = 1, 40, 1 do wagons[1].filters[i] = inventories.one.get_filter(i) wagons[2].filters[i] = inventories.two.get_filter(i) + wagons[3].filters[i] = inventories.three.get_filter(i) end return wagons end @@ -92,17 +110,30 @@ function Public_chrono.post_jump() end if objective.planet[1].name.id == 17 then global.comfychests[1].insert({name = "space-science-pack", count = 1000}) + if objective.looted_nukes > 0 then + global.comfychests[1].insert({name = "atomic-bomb", count = objective.looted_nukes}) + game.print("Comfylatron: Luckily we looted some nukes before, take them.", {r=0.98, g=0.66, b=0.22}) + end objective.chrononeeds = 200000000 + elseif objective.planet[1].name.id == 19 then + objective.chronotimer = objective.chrononeeds - 1500 end for _, player in pairs(game.connected_players) do global.flame_boots[player.index] = {fuel = 1, steps = {}} end + objective.danegrtimer = 1200 game.map_settings.enemy_evolution.time_factor = 7e-05 + 3e-06 * (objective.chronojumps + objective.passivejumps) game.forces.scrapyard.set_ammo_damage_modifier("bullet", 0.01 * objective.chronojumps) game.forces.scrapyard.set_turret_attack_modifier("gun-turret", 0.01 * objective.chronojumps) game.forces.enemy.set_ammo_damage_modifier("melee", 0.1 * objective.passivejumps) game.forces.enemy.set_ammo_damage_modifier("biological", 0.1 * objective.passivejumps) game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.8 + if objective.chronojumps == 1 then + if global.difficulty_vote_value < 1 then + game.forces.player.technologies["fusion-reactor-equipment"].enabled = true + game.forces.player.technologies["power-armor-mk2"].enabled = true + end + end end return Public_chrono diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua index 3f1eb053..68062368 100644 --- a/maps/chronosphere/chronobubles.lua +++ b/maps/chronosphere/chronobubles.lua @@ -12,15 +12,16 @@ local variants = { [7] = {id = 7, name = "biter planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 4, oil = 3, biters = 40, moisture = 0.2, chance = 4, cumul_chance = 12}, [8] = {id = 8, name = "water planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 6, moisture = 0.5, chance = 1, cumul_chance = 13}, [9] = {id = 9, name = "coal planet", iron = 1, copper = 1, coal = 6, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0, chance = 1, cumul_chance = 14}, - [10] = {id = 10, name = "scrapyard", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 1, oil = 0, biters = 0, moisture = -0.2, chance = 3, cumul_chance = 17}, + [10] = {id = 10, name = "scrapyard", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 0, moisture = -0.2, chance = 3, cumul_chance = 17}, [11] = {id = 11, name = "rocky planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 6, moisture = -0.2, chance = 2, cumul_chance = 19}, [12] = {id = 12, name = "choppy planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 1, biters = 6, moisture = 0.4, chance = 2, cumul_chance = 21}, [13] = {id = 13, name = "river planet", iron = 1, copper = 1, coal = 3, stone = 1, uranium = 0, oil = 0, biters = 8, moisture = 0.5, chance = 2, cumul_chance = 23}, [14] = {id = 14, name = "lava planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 0, oil = 0, biters = 6, moisture = -0.5, chance = 1, cumul_chance = 24}, - [15] = {id = 15, name = "start planet", iron = 4, copper = 3, coal = 4, stone = 3, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24}, + [15] = {id = 15, name = "start planet", iron = 5, copper = 3, coal = 5, stone = 2, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24}, [16] = {id = 16, name = "hedge maze", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 1, oil = 2, biters = 16, moisture = -0.1, chance = 2, cumul_chance = 26}, [17] = {id = 17, name = "fish market", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 100, moisture = 0, chance = 0, cumul_chance = 26}, - [18] = {id = 18, name = "swamp planet", iron = 2, copper = 0, coal = 3, stone = 0, uranium = 0, oil = 2, biters = 16, moisture = 0.5, chance = 2, cumul_chance = 28} + [18] = {id = 18, name = "swamp planet", iron = 2, copper = 0, coal = 3, stone = 0, uranium = 0, oil = 2, biters = 16, moisture = 0.5, chance = 2, cumul_chance = 28}, + [19] = {id = 19, name = "jump failure", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 0, moisture = 0, chance = 0, cumul_chance = 28} } local time_speed_variants = { @@ -63,6 +64,8 @@ function Public.determine_planet(choice) local weight = variants[#variants].cumul_chance local planet_choice = nil local ores = math_random(1, 9) + local dayspeed = time_speed_variants[math_random(1, #time_speed_variants)] + local daytime = math_random(1,100) / 100 if objective.game_lost then choice = 15 ores = 2 @@ -71,6 +74,14 @@ function Public.determine_planet(choice) choice = 17 ores = 10 end + if objective.config.jumpfailure == true and objective.game_lost == false then + if objective.chronojumps == 21 or objective.chronojumps == 29 or chronojumps == 36 then + choice = 19 + ores = 10 + dayspeed = time_speed_variants[1] + daytime = 0.15 + end + end if not choice then planet_choice = roll(weight) else @@ -80,13 +91,14 @@ function Public.determine_planet(choice) planet_choice = roll(weight) end end + if planet_choice.id == 10 then ores = 10 end if objective.computerupgrade >= 1 and ores == 9 then ores = 8 end if objective.computerupgrade >= 2 and ores > 6 and ores ~= 10 then ores = 6 end local planet = { [1] = { name = planet_choice, - day_speed = time_speed_variants[math_random(1, #time_speed_variants)], - time = math_random(1,100) / 100, + day_speed = dayspeed, + time = daytime, ore_richness = richness[ores], } } diff --git a/maps/chronosphere/comfylatron.lua b/maps/chronosphere/comfylatron.lua index 85ee43c3..d1b0be54 100644 --- a/maps/chronosphere/comfylatron.lua +++ b/maps/chronosphere/comfylatron.lua @@ -5,7 +5,7 @@ local math_random = math.random local function shuffle(tbl) local size = #tbl for i = size, 1, -1 do - local rand = math.random(size) + local rand = math_random(size) tbl[i], tbl[rand] = tbl[rand], tbl[i] end return tbl diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua index ee7cce15..6c524540 100644 --- a/maps/chronosphere/event_functions.lua +++ b/maps/chronosphere/event_functions.lua @@ -48,7 +48,7 @@ end function Public_event.isprotected(entity) if entity.surface.name == "cargo_wagon" then return true end - local protected = {global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} + local protected = {global.locomotive, global.locomotive_cargo[1], global.locomotive_cargo[2], global.locomotive_cargo[3]} for i = 1, #global.comfychests,1 do table.insert(protected, global.comfychests[i]) end @@ -110,6 +110,13 @@ function Public_event.shred_simple_entities(entity) end end +function Public_event.spawner_loot(surface, position) + local objective = global.objective + if math_random(1,20) == 1 then + surface.spill_item_stack(position, {name = "railgun-dart", count = math_random(1, 1 + objective.chronojumps)}, true) + end +end + function Public_event.choppy_loot(event) local entity = event.entity if choppy_entity_yield[entity.name] then @@ -177,12 +184,35 @@ function Public_event.swamp_loot(event) if ore_yield[event.entity.name] then amount = get_ore_amount() / 10 * ore_yield[event.entity.name] end - game.print(amount) local rock_mining = {"iron-ore", "iron-ore", "coal", "coal", "coal"} local mined_loot = rock_mining[math_random(1,#rock_mining)] surface.spill_item_stack(event.entity.position,{name = mined_loot, count = amount}, true) end +function Public_event.danger_silo(entity) + local objective = global.objective + if objective.planet[1].name.id == 19 then + if objective.dangers and #objective.dangers > 1 then + for i = 1, #objective.dangers, 1 do + if entity == objective.dangers[i].silo then + game.print("Nuclear silo destroyed. You managed to loot 5 atomic bombs. Comfylatron seized them for your own safety.", {r=0.98, g=0.66, b=0.22}) + objective.dangers[i].destroyed = true + objective.dangers[i].silo = nil + objective.dangers[i].speaker.destroy() + objective.dangers[i].combinator.destroy() + objective.dangers[i].solar.destroy() + objective.dangers[i].acu.destroy() + objective.dangers[i].pole.destroy() + rendering.destroy(objective.dangers[i].text) + rendering.destroy(objective.dangers[i].timer) + objective.dangers[i].text = -1 + objective.dangers[i].timer = -1 + end + end + end + end +end + function Public_event.biter_immunities(event) local planet = global.objective.planet[1].name.id local objective = global.objective diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index 37da5de0..ee181753 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -125,8 +125,19 @@ local function update_gui(player) local acus = 0 if global.acumulators then acus = #global.acumulators else acus = 0 end local bestcase = math_floor((objective.chrononeeds - objective.chronotimer) / (1 + math_floor(acus/10))) - gui.timer2.caption = {"chronosphere.gui_3_1"} - gui.timer_value2.caption = math_floor(bestcase / 60) .. " min, " .. bestcase % 60 .. " s (when using " .. acus * 0.3 .. "MW)" + local nukecase = objective.dangertimer + if objective.planet[1].name.id == 19 and objective.passivetimer > 31 then + gui.timer2.caption = {"chronosphere.gui_3_2"} + gui.timer_value2.caption = math_floor(nukecase / 60) .. " min, " .. nukecase % 60 .. " s" + gui.timer2.style.font_color = {r=0.98, g=0, b=0} + gui.timer_value2.style.font_color = {r=0.98, g=0, b=0} + else + gui.timer2.caption = {"chronosphere.gui_3_1"} + gui.timer_value2.caption = math_floor(bestcase / 60) .. " min, " .. bestcase % 60 .. " s (when using " .. acus * 0.3 .. "MW)" + gui.timer2.style.font_color = {r = 0, g = 200, b = 0} + gui.timer_value2.style.font_color = {r = 0, g = 200, b = 0} + end + local evolution = game.forces["enemy"].evolution_factor gui.evo.caption = {"chronosphere.gui_4"} @@ -140,7 +151,7 @@ local function update_gui(player) } local upgt = { [1] = {t = "[1]: + 2500 Train Max HP. Current: " .. objective.max_health .. "\n Cost : " .. math_floor(500 * (1 + objective.hpupgradetier /2)) .. " coins + 1500 copper plates\n"}, - [2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%\n Buyable once per 3 jumps.\n Cost: 5000 coins + 2000 green circuits + Jump number " .. objective.filterupgradetier * 3 .. "\n"}, + [2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%\n Buyable once per 3 jumps.\n Cost: 5000 coins + 2000 green circuits + Jump number " .. (objective.filterupgradetier + 1) * 3 .. "\n"}, [3] = {t = "[3]: Add additional row of Acumulators.\n Cost : " .. math_floor(2000 * (1 + objective.acuupgradetier /4)) .. " coins + 200 batteries\n"}, [4] = {t = "[4]: Add item pickup distance to players.Current: +" .. objective.pickupupgradetier .. ",\n Cost: " .. 1000 * (1 + objective.pickupupgradetier) .. " coins + 400 red inserters\n"}, [5] = {t = "[5]: Add +5 inventory slots. Buyable once per 5 jumps.\n Cost: " .. 2000 * (1 + objective.invupgradetier) .." coins + " .. chests[objective.invupgradetier + 1].c}, @@ -149,10 +160,12 @@ local function update_gui(player) [8] = {t = "[8]: Add comfylatron chests that output outside (into cargo wagon 2 and 3)\n Cost: 2000 coins + 100 fast inserters\n"}, [9] = {t = "[9]: Add storage chests to the sides of wagons.\n Buyable once per 5 jumps.\n Cost: 5000 coins + " .. chests[objective.boxupgradetier + 1].c}, [10] = {t = "[P]: Poison defense. Triggers automatically when train has low HP.\n Actual charges: " .. objective.poisondefense .. " / 4\n Recharge timer for next use: " .. math_ceil(objective.poisontimeout /6) .. "min\n Cost: 1000 coins + 50 poison capsules\n"}, - [11] = {t = "[C]: Train computer fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 1 costs: 5000 coins, 1000 advanced circuits, 2000 copper plates.\n Discards very poor planets.\n"}, - [12] = {t = "[C]: Train power and navigation fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 2 costs: 10000 coins, 1000 processing units, 1 nuclear reactor.\n Discards poor planets.\n"}, - [13] = {t = "[C]: Train time machine processor fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 3 costs per part: 2000 coins, 100 rocket control units, 100 low density structures, 50 uranium fuel cells.\n Parts finished: " .. objective.computerparts .. " / 10\n"}, - [14] = {t = "[C]: Train is repaired. Synchronize the time to unlock final map to finish the main objective.\n Costs: 1 rocket silo, 1 satellite.\n Warning: after buying this, the next jump destination is locked to final map,\n that means 100% evolution and no resources.\n"} + [11] = {t = "[A]: 1x mk1 armor + 300 railgun darts + 100 low density structures -> 1x mk2 armor\n"}, + [12] = {t = "[R]: 16x personal solar + 200 railgun darts + 100 low density structures -> 1x fusion reactor\n"}, + [13] = {t = "[C]: Train computer fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 1 costs: 5000 coins, 1000 advanced circuits, 2000 copper plates.\n Discards very poor planets.\n"}, + [14] = {t = "[C]: Train power and navigation fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 2 costs: 10000 coins, 1000 processing units, 1 nuclear reactor.\n Discards poor planets.\n"}, + [15] = {t = "[C]: Train time machine processor fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 3 costs per part: 2000 coins, 100 rocket control units, 100 low density structures, 50 uranium fuel cells.\n Parts finished: " .. objective.computerparts .. " / 10\n"}, + [16] = {t = "[C]: Train is repaired. Synchronize the time to unlock final map to finish the main objective.\n Costs: 1 rocket silo, 1 satellite.\n Warning: after buying this, the next jump destination is locked to final map,\n that means 100% evolution and no resources.\n"} } local maxed = { [1] = {t = "[1]: Train HP maxed.\n"}, @@ -177,15 +190,20 @@ local function update_gui(player) if objective.outupgradetier < 1 then tooltip = tooltip .. upgt[8].t else tooltip = tooltip .. maxed[8].t end if objective.boxupgradetier < 4 then tooltip = tooltip .. upgt[9].t else tooltip = tooltip .. maxed[9].t end tooltip = tooltip .. upgt[10].t - if objective.computerupgrade == 0 and objective.chronojumps >= 15 then - tooltip = tooltip .. upgt[11].t - elseif objective.computerupgrade == 1 and objective.chronojumps >= 20 then - tooltip = tooltip .. upgt[12].t - elseif objective.computerupgrade == 2 and objective.chronojumps >= 25 then + if objective.chronojumps >= 24 then + tooltip = tooltip .. upgt[11].t .. upgt[12].t + else + tooltip = tooltip .. "Armor and reactor can be bought since jump 24 (for railgun darts).\n" + end + if objective.computerupgrade == 0 and objective.chronojumps >= 15 and objective.computermessage == 1 then + tooltip = tooltip .. upgt[13].t + elseif objective.computerupgrade == 1 and objective.chronojumps >= 20 and objective.computermessage == 3 then + tooltip = tooltip .. upgt[14].t + elseif objective.computerupgrade == 2 and objective.chronojumps >= 25 and objective.computermessage == 5 then if objective.computerparts < 10 then - tooltip = tooltip .. upgt[13].t + tooltip = tooltip .. upgt[15].t elseif objective.computerparts == 10 then - tooltip = tooltip .. upgt[14].t + tooltip = tooltip .. upgt[16].t end elseif objective.computerupgrade == 3 and objective.chronojumps >= 25 then tooltip = tooltip .. maxed[10].t diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index 9337bc28..310e61a1 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -1,10 +1,12 @@ local Public = {} local math_floor = math.floor local math_random = math.random - +local function math_sgn(x) + return (x<0 and -1) or 1 +end function Public.locomotive_spawn(surface, position, wagons) - if global.objective.planet[1].name.id == 17 then + if global.objective.planet[1].name.id == 17 then --fish market position.x = position.x - 960 position.y = position.y - 64 end @@ -14,29 +16,24 @@ function Public.locomotive_spawn(surface, position, wagons) end global.locomotive = surface.create_entity({name = "locomotive", position = {position.x, position.y + -6}, force = "player"}) global.locomotive.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 100}) - - global.locomotive_cargo = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 0}, force = "player"}) - global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 100}) - - global.locomotive_cargo2 = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 6}, force = "player"}) - for item, count in pairs(wagons[1].inventory) do - global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) + for i = 1, 3, 1 do + global.locomotive_cargo[i] = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + math_floor((i - 1) * 6.5)}, force = "player"}) + local inv = global.locomotive_cargo[i].get_inventory(defines.inventory.cargo_wagon) + for item, count in pairs(wagons[i].inventory) do + inv.insert({name = item, count = count}) + if wagons[i].bar > 0 then inv.set_bar(wagons[i].bar) end + for ii = 1, 40, 1 do + inv.set_filter(ii, wagons[i].filters[ii]) + end + end + global.locomotive_cargo[i].minable = false end + global.locomotive_cargo[1].operable = false + global.locomotive.color = {0, 255, 0} + global.locomotive.minable = false - global.locomotive_cargo3 = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 13}, force = "player"}) - for item, count in pairs(wagons[2].inventory) do - global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) - end - if wagons[1].bar > 0 then global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).set_bar(wagons[1].bar) end - if wagons[2].bar > 0 then global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).set_bar(wagons[2].bar) end - for i = 1, 40, 1 do - global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).set_filter(i, wagons[1].filters[i]) - global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).set_filter(i, wagons[2].filters[i]) - end - - if not global.comfychests then global.comfychests = {} end - if not global.acumulators then global.acumulators = {} end - + -- if not global.comfychests then global.comfychests = {} end + -- if not global.acumulators then global.acumulators = {} end for i = 1, 24, 1 do local yi = 0 local xi = 5 @@ -77,36 +74,30 @@ function Public.locomotive_spawn(surface, position, wagons) rendering.draw_light({ sprite = "utility/light_medium", scale = 5.5, intensity = 1, minimum_darkness = 0, - oriented = true, color = {255,255,255}, target = global.locomotive_cargo, + oriented = true, color = {255,255,255}, target = global.locomotive_cargo[3], surface = surface, visible = true, only_in_alt_mode = false, }) - global.locomotive.color = {0, 255, 0} - global.locomotive.minable = false - global.locomotive_cargo.minable = false - global.locomotive_cargo.operable = false - global.locomotive_cargo2.minable = false - --global.locomotive_cargo2.operable = false - global.locomotive_cargo3.minable = false - --global.locomotive_cargo3.operable = false + end function Public.fish_tag() - if not global.locomotive_cargo then return end - if not global.locomotive_cargo.valid then return end - if not global.locomotive_cargo.surface then return end - if not global.locomotive_cargo.surface.valid then return end + if not global.locomotive_cargo[1] then return end + local cargo = global.locomotive_cargo[1] + if not cargo.valid then return end + if not cargo.surface then return end + if not cargo.surface.valid then return end if global.locomotive_tag then if global.locomotive_tag.valid then - if global.locomotive_tag.position.x == global.locomotive_cargo.position.x and global.locomotive_tag.position.y == global.locomotive_cargo.position.y then return end + if global.locomotive_tag.position.x == cargo.position.x and global.locomotive_tag.position.y == cargo.position.y then return end global.locomotive_tag.destroy() end end - global.locomotive_tag = global.locomotive_cargo.force.add_chart_tag( - global.locomotive_cargo.surface, + global.locomotive_tag = cargo.force.add_chart_tag( + cargo.surface, {icon = {type = 'item', name = 'raw-fish'}, - position = global.locomotive_cargo.position, + position = cargo.position, text = " " }) end @@ -124,13 +115,14 @@ local market_offers = { {price = {{"coin", 400}, {"steel-plate", 40}, {"advanced-circuit", 10}, {"loader", 1}}, offer = {type = 'give-item', item = 'fast-loader', count = 1}}, {price = {{"coin", 600}, {"express-transport-belt", 10}, {"fast-loader", 1}}, offer = {type = 'give-item', item = 'express-loader', count = 1}}, --{price = {{"coin", 5}, {"stone", 100}}, offer = {type = 'give-item', item = 'landfill', count = 1}}, - {price = {{"coin", 1}, {"steel-plate", 1}, {"explosives", 10}}, offer = {type = 'give-item', item = 'land-mine', count = 1}} + {price = {{"coin", 1}, {"steel-plate", 1}, {"explosives", 10}}, offer = {type = 'give-item', item = 'land-mine', count = 1}}, + {price = {{"pistol", 1}}, offer = {type = "give-item", item = "iron-plate", count = 100}} } -local function create_wagon_room() +function Public.create_wagon_room() local width = 64 local height = 384 - global.comfychests2 = {} + --global.comfychests2 = {} if not global.acumulators then global.acumulators = {} end local map_gen_settings = { ["width"] = width, @@ -145,7 +137,8 @@ local function create_wagon_room() ["decorative"] = {treat_missing_as_default = false}, }, } - local surface = game.create_surface("cargo_wagon", map_gen_settings) + if not game.surfaces["cargo_wagon"] then game.create_surface("cargo_wagon", map_gen_settings) end + local surface = game.surfaces["cargo_wagon"] surface.freeze_daytime = true surface.daytime = 0.1 surface.request_to_generate_chunks({0,0}, 12) @@ -210,7 +203,7 @@ local function create_wagon_room() for y = height * -0.5 + 7, height * -0.5 + 10, 1 do local p = {x,y} surface.set_tiles({{name = "water", position = p}}) - if math.random(1, 3) == 1 then surface.create_entity({name = "fish", position = p}) end + if math_random(1, 3) == 1 then surface.create_entity({name = "fish", position = p}) end end end @@ -250,6 +243,7 @@ local function create_wagon_room() speaker.connect_neighbour({wire = defines.wire_type.green, target_entity = checker, target_circuit_id = 2}) local rules4 = speaker.get_or_create_control_behavior() rules4.circuit_condition = {condition = {first_signal = {type = "virtual", name = "signal-C"}, second_constant = 0, comparator = ">"}} + rules4.circuit_parameters = {signal_value_is_pitch = false, instrument_id = 8, note_id = 5} local solar1 = surface.create_entity({name = "solar-panel", position = {x = width * -0.5 - 2, y = -242}, force="player", create_build_effect_smoke = false}) local solar2 = surface.create_entity({name = "solar-panel", position = {x = width * -0.5 + 1, y = -242}, force="player", create_build_effect_smoke = false}) solar1.destructible = false @@ -271,7 +265,7 @@ local function create_wagon_room() for _, x in pairs({-1, 0}) do for i = 1, 12, 1 do local step = math_floor((i-1)/4) - y = -131 + i + step * 128 - step * 4 + local y = -131 + i + step * 128 - step * 4 local e = surface.create_entity({name = "compilatron-chest", position = {x,y}, force = "player", create_build_effect_smoke = false}) e.destructible = false e.minable = false @@ -330,7 +324,9 @@ local function create_wagon_room() [9] = {name = "outchest", entity = {name = "compilatron-chest", position = {4, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-8"}, [10] = {name = "boxchest", entity = {name = "compilatron-chest", position = {5, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-9"}, [11] = {name = "poisonchest", entity = {name = "compilatron-chest", position = {6, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-P"}, - [12] = {name = "computerchest", entity = {name = "compilatron-chest", position = {6, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-C"} + [12] = {name = "computerchest", entity = {name = "compilatron-chest", position = {6, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-C"}, + [13] = {name = "armorchest", entity = {name = "compilatron-chest", position = {7, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-A"}, + [14] = {name = "reactorchest", entity = {name = "compilatron-chest", position = {7, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-R"} } for i = 1, #upgradechests, 1 do @@ -400,26 +396,22 @@ local function create_wagon_room() for _, offer in pairs(market_offers) do market.add_market_item(offer) end --generate cars-- - for _, x in pairs({width * -0.5 -1.4, width * 0.5 + 1.4}) do - local e = surface.create_entity({name = "car", position = {x, 0}, force = "player", create_build_effect_smoke = false}) - e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16}) - e.destructible = false - e.minable = false - e.operable = false - end - for _, x in pairs({width * -0.5 - 1.4, width * 0.5 + 1.4}) do - local e = surface.create_entity({name = "car", position = {x, -128}, force = "player", create_build_effect_smoke = false}) - e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16}) - e.destructible = false - e.minable = false - e.operable = false - end - for _, x in pairs({width * -0.5 - 1.4, width * 0.5 + 1.4}) do - local e = surface.create_entity({name = "car", position = {x, 128}, force = "player", create_build_effect_smoke = false}) + local car_pos = { + {x = width * -0.5 - 1.4, y = -128}, + {x = width * -0.5 - 1.4, y = 0}, + {x = width * -0.5 - 1.4, y = 128}, + {x = width * 0.5 + 1.4, y = -128}, + {x = width * 0.5 + 1.4, y = 0}, + {x = width * 0.5 + 1.4, y = 128} + } + global.car_exits = {} + for i = 1, 6, 1 do + local e = surface.create_entity({name = "car", position = car_pos[i], force = "player", create_build_effect_smoke = false}) e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16}) e.destructible = false e.minable = false e.operable = false + global.car_exits[i] = e end --generate chests inside south wagon-- @@ -494,68 +486,48 @@ local function create_wagon_room() end function Public.set_player_spawn_and_refill_fish() - if not global.locomotive_cargo then return end - if not global.locomotive_cargo.valid then return end - global.locomotive_cargo.health = global.locomotive_cargo.health + 6 - global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = math_random(1, 2)}) - local position = global.locomotive_cargo.surface.find_non_colliding_position("stone-furnace", global.locomotive_cargo.position, 16, 2) + if not global.locomotive_cargo[1] then return end + local cargo = global.locomotive_cargo[1] + if not cargo.valid then return end + cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = math_random(1, 2)}) + local position = cargo.surface.find_non_colliding_position("stone-furnace", cargo.position, 16, 2) if not position then return end - game.forces.player.set_spawn_position({x = position.x, y = position.y}, global.locomotive_cargo.surface) + game.forces.player.set_spawn_position({x = position.x, y = position.y}, cargo.surface) end function Public.enter_cargo_wagon(player, vehicle) if not vehicle then log("no vehicle") return end if not vehicle.valid then log("vehicle invalid") return end - if not global.locomotive_cargo then log("no cargo") return end - if not global.locomotive_cargo.valid then log("cargo invalid") return end - if vehicle == global.locomotive_cargo then - if not game.surfaces["cargo_wagon"] then create_wagon_room() end - local surface = game.surfaces["cargo_wagon"] - local x_vector = vehicle.position.x - player.position.x - local position - if x_vector > 0 then - position = {surface.map_gen_settings.width * -0.5, -128} - else - position = {surface.map_gen_settings.width * 0.5, -128} + if not game.surfaces["cargo_wagon"] then Public.create_wagon_room() end + local wagon_surface = game.surfaces["cargo_wagon"] + for i = 1, 3, 1 do + if not global.locomotive_cargo[i] then log("no cargo") return end + if not global.locomotive_cargo[i].valid then log("cargo invalid") return end + if vehicle == global.locomotive_cargo[i] then + local x_vector = vehicle.position.x - player.position.x + local position + if x_vector > 0 then + position = {wagon_surface.map_gen_settings.width * -0.5, -128 + 128 * (i - 1)} + else + position = {wagon_surface.map_gen_settings.width * 0.5, -128 + 128 * (i - 1)} + end + player.teleport(wagon_surface.find_non_colliding_position("character", position, 128, 0.5), wagon_surface) + break end - player.teleport(surface.find_non_colliding_position("character", position, 128, 0.5), surface) - end - if not global.locomotive_cargo2 then return end - if not global.locomotive_cargo2.valid then return end - if vehicle == global.locomotive_cargo2 then - if not game.surfaces["cargo_wagon"] then create_wagon_room() end - local surface = game.surfaces["cargo_wagon"] - local x_vector = vehicle.position.x - player.position.x - local position - if x_vector > 0 then - position = {surface.map_gen_settings.width * -0.5, 0} - else - position = {surface.map_gen_settings.width * 0.5, 0} - end - player.teleport(surface.find_non_colliding_position("character", position, 128, 0.5), surface) - end - if not global.locomotive_cargo3 then return end - if not global.locomotive_cargo3.valid then return end - if vehicle == global.locomotive_cargo3 then - if not game.surfaces["cargo_wagon"] then create_wagon_room() end - local surface = game.surfaces["cargo_wagon"] - local x_vector = vehicle.position.x - player.position.x - local position - if x_vector > 0 then - position = {surface.map_gen_settings.width * -0.5, 128} - else - position = {surface.map_gen_settings.width * 0.5, 128} - end - player.teleport(surface.find_non_colliding_position("character", position, 128, 0.5), surface) end if player.surface.name == "cargo_wagon" and vehicle.type == "car" then if global.flame_boots then global.flame_boots[player.index] = {fuel = 1, steps = {}} end - local surface = global.locomotive_cargo.surface - local x_vector = (vehicle.position.x / math.abs(vehicle.position.x)) * 2 - local y_vector = vehicle.position.y / 16 - local position = {global.locomotive_cargo2.position.x + x_vector, global.locomotive_cargo2.position.y + y_vector} + local used_exit = 0 + for i = 1, 6, 1 do + if vehicle == global.car_exits[i] then + used_exit = i + break + end + end + local surface = global.locomotive_cargo[1].surface + local position = {x = global.locomotive_cargo[((used_exit - 1) % 3) + 1].position.x + math_sgn(used_exit - 3.5) * 2, y = global.locomotive_cargo[((used_exit - 1) % 3) + 1].position.y} local position2 = surface.find_non_colliding_position("character", position, 128, 0.5) if not position2 then return end player.teleport(position2, surface) diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index d548e4e6..5a5c3b2e 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -32,6 +32,7 @@ local math_sqrt = math.sqrt --local chests = {} --local acus = {} global.objective = {} +global.objective.config = {} global.flame_boots = {} global.comfylatron = nil global.lab_cells = {} @@ -100,8 +101,9 @@ local function generate_overworld(surface, optplanet) end local function get_map_gen_settings() + local seed = math_random(1, 1000000) local map_gen_settings = { - ["seed"] = math_random(1, 1000000), + ["seed"] = seed, ["width"] = 960, ["height"] = 960, ["water"] = 0.1, @@ -146,7 +148,9 @@ end local function reset_map() - + for _,player in pairs(game.players) do + if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end + end global.chunk_queue = {} if game.surfaces["chronosphere"] then game.delete_surface(game.surfaces["chronosphere"]) end if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end @@ -191,10 +195,16 @@ local function reset_map() objective.active_biters = {} objective.unit_groups = {} objective.biter_raffle = {} + objective.dangertimer = 1200 + objective.dangers = {} + objective.looted_nukes = 0 global.outchests = {} global.upgradechest = {} global.fishchest = {} global.acumulators = {} + global.comfychests = {} + global.comfychests2 = {} + global.locomotive_cargo = {} for _, player in pairs(game.connected_players) do global.flame_boots[player.index] = {fuel = 1, steps = {}} end @@ -224,22 +234,30 @@ local function reset_map() game.map_settings.pollution.ageing = 0.1 game.map_settings.pollution.diffusion_ratio = 0.1 game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 5 - game.forces["enemy"].evolution_factor = 0.0001 + game.forces.enemy.evolution_factor = 0.0001 + game.forces.scrapyard.set_friend('enemy', true) + game.forces.enemy.set_friend('scrapyard', true) game.forces.player.technologies["land-mine"].enabled = false game.forces.player.technologies["landfill"].enabled = false + game.forces.player.technologies["fusion-reactor-equipment"].enabled = false + game.forces.player.technologies["power-armor-mk2"].enabled = false game.forces.player.technologies["railway"].researched = true + game.forces.player.recipes["pistol"].enabled = false + game.forces.player.set_spawn_position({12, 10}, surface) local wagons = {} - wagons[1] = {inventory = starting_cargo, bar = 0, filters = {}} + wagons[1] = {inventory = {["raw-fish"] = 100}, bar = 0, filters = {}} wagons[2] = {inventory = starting_cargo, bar = 0, filters = {}} + wagons[3] = {inventory = starting_cargo, bar = 0, filters = {}} for i = 1, 40, 1 do - wagons[1].filters[i] = nil wagons[2].filters[i] = nil + wagons[3].filters[i] = nil end Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, wagons) render_train_hp() game.reset_time_played() + Locomotive.create_wagon_room() global.difficulty_poll_closing_timeout = game.tick + 54000 global.difficulty_player_votes = {} if objective.game_won then @@ -283,6 +301,20 @@ local function on_player_joined_game(event) end end +local function on_player_left_game(event) + local player = game.players[event.player_index] + +end + +local function on_pre_player_left_game(event) + local player = game.players[event.player_index] + if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end + if player.character then + global.objective.offline_players[#global.objective.offline_players + 1] = {index = event.player_index, tick = game.tick} + end +end + + local function set_objective_health(final_damage_amount) if final_damage_amount == 0 then return end local objective = global.objective @@ -308,7 +340,7 @@ local function chronojump(choice) for _,player in pairs(game.players) do if player.surface == oldsurface then if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end - local wagons = {global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} + local wagons = {global.locomotive_cargo[1], global.locomotive_cargo[2], global.locomotive_cargo[3]} Locomotive.enter_cargo_wagon(player, wagons[math_random(1,3)]) end end @@ -351,21 +383,18 @@ local tick_minute_functions = { local function tick() local objective = global.objective local tick = game.tick - if tick % 60 == 30 and objective.chronotimer < 64 then + if tick % 60 == 30 and objective.passivetimer < 64 then local surface = game.surfaces[global.active_surface_index] if objective.planet[1].name.id == 17 then - surface.request_to_generate_chunks({-800,0}, 3 + math_floor(objective.chronotimer / 5)) + surface.request_to_generate_chunks({-800,0}, 3 + math_floor(objective.passivetimer / 5)) else - surface.request_to_generate_chunks({0,0}, 3 + math_floor(objective.chronotimer / 5)) + surface.request_to_generate_chunks({0,0}, 3 + math_floor(objective.passivetimer / 5)) end --surface.force_generate_chunk_requests() end if tick % 10 == 0 and objective.planet[1].name.id == 18 then Tick_functions.spawn_poison() - Tick_functions.spawn_poison() - --Tick_functions.spawn_poison() - --Tick_functions.spawn_poison() end if tick % 30 == 0 then if tick % 600 == 0 then @@ -380,6 +409,9 @@ local function tick() set_objective_health(Tick_functions.repair_train()) Upgrades.check_upgrades() Tick_functions.boost_evolution() + if objective.config.offline_loot then + Tick_functions.offline_players() + end end local key = tick % 3600 if tick_minute_functions[key] then tick_minute_functions[key]() end @@ -389,6 +421,9 @@ local function tick() if objective.chronojumps > 0 then game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (0.5 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1)) * global.difficulty_vote_value) end + if objective.planet[1].name.id == 19 then + Tick_functions.dangertimer() + end if Tick_functions.check_chronoprogress() then chronojump(nil) end end if tick % 120 == 0 then @@ -414,9 +449,16 @@ local function on_init() T.sub_caption_color = {r = 0, g = 150, b = 0} global.objective.game_lost = true global.objective.game_won = false + global.objective.offline_players = {} + + global.objective.config.offline_loot = true + global.objective.config.jumpfailure = true game.create_force("scrapyard") - game.forces.scrapyard.set_friend('enemy', true) - game.forces.enemy.set_friend('scrapyard', true) + local mgs = game.surfaces["nauvis"].map_gen_settings + mgs.width = 16 + mgs.height = 16 + game.surfaces["nauvis"].map_gen_settings = mgs + game.surfaces["nauvis"].clear() reset_map() --if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end end @@ -428,17 +470,17 @@ local function protect_entity(event) if event.cause == global.comfylatron or event.entity == global.comfylatron then return end - if event.cause.force.index == 2 then + if event.cause.force.index == 2 or event.cause.force.name == "scrapyard" then set_objective_health(event.final_damage_amount) end + elseif global.objective.planet[1].name.id == 19 then + set_objective_health(event.final_damage_amount) end if not event.entity.valid then return end event.entity.health = event.entity.health + event.final_damage_amount end end - - local function on_entity_damaged(event) if not event.entity.valid then return end protect_entity(event) @@ -497,12 +539,25 @@ local function on_entity_died(event) if entity.type == "unit" and entity.force == "enemy" then global.objective.active_biters[entity.unit_number] = nil end - if entity.force.name == "scrapyard" and entity.name == "gun-turret" and global.objective.planet[1].name.id == 16 then - Event_functions.trap(entity, true) + if entity.type == "rocket-silo" and entity.force.name == "enemy" then + Event_functions.danger_silo(entity) end - if entity.force.name == "enemy" and entity.type == "unit-spawner" and global.objective.planet[1].name.id == 18 then - Ores.prospect_ores(event.entity, event.entity.surface, event.entity.position) - --Event_functions.swamp_loot(event) + if entity.force.name == "scrapyard" and entity.name == "gun-turret" then + if global.objective.planet[1].name.id == 19 or global.objective.planet[1].name.id == 16 then --danger + hedge maze + Event_functions.trap(entity, true) + end + end + if entity.force.name == "enemy" then + if entity.type == "unit-spawner" then + Event_functions.spawner_loot(entity.surface, entity.position) + if global.objective.planet[1].name.id == 18 then + Ores.prospect_ores(entity, entity.surface, entity.position) + end + else + if global.objective.planet[1].name.id == 18 then + Event_functions.swamp_loot(event) + end + end end if entity.force.index == 3 then if event.cause then @@ -582,7 +637,8 @@ event.on_nth_tick(2, tick) event.add(defines.events.on_entity_damaged, on_entity_damaged) event.add(defines.events.on_entity_died, on_entity_died) event.add(defines.events.on_player_joined_game, on_player_joined_game) ---event.add(defines.events.on_player_left_game, on_player_left_game) +event.add(defines.events.on_player_left_game, on_player_left_game) +event.add(defines.events.on_pre_player_left_game, on_pre_player_left_game) event.add(defines.events.on_pre_player_mined_item, pre_player_mined_item) event.add(defines.events.on_player_mined_entity, on_player_mined_entity) event.add(defines.events.on_research_finished, on_research_finished) @@ -619,3 +675,15 @@ if _DEBUG then chronojump(param) end) end +--Time for the debug code. If any (not global.) globals are written to at this point, an error will be thrown. +--eg, x = 2 will throw an error because it's not global.x or local x +setmetatable(_G, { + __newindex = function(_, n, v) + log("Desync warning: attempt to write to undeclared var " .. n) + -- game.print("Attempt to write to undeclared var " .. n) + global[n] = v; + end, + __index = function(_, n) + return global[n]; + end +}) diff --git a/maps/chronosphere/ores.lua b/maps/chronosphere/ores.lua index 052d2728..01e09609 100644 --- a/maps/chronosphere/ores.lua +++ b/maps/chronosphere/ores.lua @@ -114,6 +114,7 @@ function Public_ores.prospect_ores(entity, surface, pos) if entity then if entity.name == "rock-huge" then chance = 40 end if entity.type == "unit-spawner" then chance = 40 end + if planet[1].name.id == 15 then chance = chance + 30 end if math_random(chance + math_floor(10 * planet[1].ore_richness.factor) ,100 + chance) >= 100 then spawn_ore_vein(surface, pos, planet) end diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index 7c6899b7..b1135e7d 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -1,6 +1,7 @@ --require "maps.chronosphere.ores" local Ores = require "maps.chronosphere.ores" +local Specials = require "maps.chronosphere.terrain_specials" local math_random = math.random local math_floor = math.floor local math_abs = math.abs @@ -131,6 +132,52 @@ local function process_labyrinth_cell(pos, seed) return true end +local function process_dangerevent_position(p, seed, tiles, entities, treasure, planet) + local scrapyard = get_noise("scrapyard", p, seed) + --Chasms + local noise_cave_ponds = get_noise("cave_ponds", p, seed) + local small_caves = get_noise("small_caves", p, seed) + if noise_cave_ponds < 0.15 and noise_cave_ponds > -0.15 then + if small_caves > 0.35 then + tiles[#tiles + 1] = {name = "out-of-map", position = p} + return + end + if small_caves < -0.35 then + tiles[#tiles + 1] = {name = "out-of-map", position = p} + return + end + end + + if scrapyard < -0.20 or scrapyard > 0.20 then + if math_random(1, 128) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 50 then + entities[#entities + 1] = {name="gun-turret", position=p, force = "scrapyard"} + end + tiles[#tiles + 1] = {name = "dirt-7", position = p} + if scrapyard < -0.38 or scrapyard > 0.38 then + if math_random(1,36) == 1 then entities[#entities + 1] = {name = scrap_entities[math_random(1, scrap_entities_index)], position = p, force = "enemy"} end + if math_random(1,6) == 1 then entities[#entities + 1] = {name="mineable-wreckage", position=p} end + return + end + return + end + + local cave_ponds = get_noise("cave_ponds", p, seed) + if cave_ponds < -0.6 and scrapyard > -0.2 and scrapyard < 0.2 then + tiles[#tiles + 1] = {name = "deepwater-green", position = p} + if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end + return + end + + local large_caves = get_noise("large_caves", p, seed) + if scrapyard > -0.15 and scrapyard < 0.15 then + if math_floor(large_caves * 10) % 4 < 3 then + tiles[#tiles + 1] = {name = "dirt-7", position = p} + return + end + end + tiles[#tiles + 1] = {name = "stone-path", position = p} +end + local function process_hedgemaze_position(p, seed, tiles, entities, treasure, planet, cell, things) --local labyrinth_cell_size = 16 --valid values are 2, 4, 8, 16, 32 local biters = planet[1].name.biters @@ -230,15 +277,9 @@ local function process_rocky_position(p, seed, tiles, entities, treasure, planet end if math_abs(noise_large_caves) > 0.6 then if math_random(1,16) == 1 then entities[#entities + 1] = {name="tree-02", position=p} end - --if math_random(1,32) == 1 then markets[#markets + 1] = p end end if math_abs(noise_large_caves) > 0.5 then tiles[#tiles + 1] = {name = "grass-2", position = p} - --if math_random(1,620) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end - -- if math_random(1,384) == 1 then - -- Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) - -- entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} - -- end if math_random(1,122 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end if math_random(1, 1024) == 1 then treasure[#treasure + 1] = p end return @@ -298,17 +339,12 @@ end local function process_forest_position(p, seed, tiles, entities, treasure, planet) local biters = planet[1].name.biters local noise_forest_location = get_noise("forest_location", p, seed) - --local r = math.ceil(math.abs(get_noise("forest_density", pos, seed + 4096)) * 10) - --local r = 5 - math.ceil(math.abs(noise_forest_location) * 3) - --r = 2 - if noise_forest_location > 0.095 then if noise_forest_location > 0.6 then if math_random(1,100) > 42 then entities[#entities + 1] = {name = "tree-08-brown", position = p} end else if math_random(1,100) > 42 then entities[#entities + 1] = {name = "tree-01", position = p} end end - --surface.create_decoratives({check_collision=false, decoratives={{name = decos_inside_forest[math_random(1, #decos_inside_forest)], position = pos, amount = math_random(1, 2)}}}) return else if math_random(1,152 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 250 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end @@ -320,14 +356,10 @@ local function process_forest_position(p, seed, tiles, entities, treasure, plane else if math_random(1,100) > 42 then entities[#entities + 1] = {name = "tree-02-red", position = p} end end - --surface.create_decoratives({check_collision=false, decoratives={{name = decos_inside_forest[math_random(1, #decos_inside_forest)], position = pos, amount = math_random(1, 2)}}}) return else if math_random(1,152 - biters) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 250 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end end - - - --surface.create_decoratives({check_collision=false, decoratives={{name = decos[math_random(1, #decos)], position = pos, amount = math_random(1, 2)}}}) end local function process_river_position(p, seed, tiles, entities, treasure, planet) @@ -417,7 +449,13 @@ local function process_biter_position(p, seed, tiles, entities, treasure, planet if scrapyard + 0.5 > -0.1 - 0.1 * planet[1].name.moisture and scrapyard + 0.5 < 0.1 + 0.1 * planet[1].name.moisture then local treetypes = tree_raffle[math_random(1, s_tree_raffle)] if planet[1].name.id == 14 then treetypes = dead_tree_raffle[math_random(1, 5)] end --lava planet - if math_random(1,100) > 42 - handicap / 6 then entities[#entities + 1] = {name = treetypes , position = p} end + if math_random(1,100) > 42 - handicap / 6 then + if math_random(1,800) == 1 then + treasure[#treasure + 1] = p + else + entities[#entities + 1] = {name = treetypes , position = p} + end + end end if scrapyard > -0.10 and scrapyard < 0.10 then @@ -445,7 +483,6 @@ local function process_scrapyard_position(p, seed, tiles, entities, treasure, pl --Chasms local noise_cave_ponds = get_noise("cave_ponds", p, seed) local small_caves = get_noise("small_caves", p, seed) - local noise_forest_location = get_noise("forest_location", p, seed) if noise_cave_ponds < 0.15 and noise_cave_ponds > -0.15 then if small_caves > 0.35 then tiles[#tiles + 1] = {name = "out-of-map", position = p} @@ -470,10 +507,6 @@ local function process_scrapyard_position(p, seed, tiles, entities, treasure, pl if math_random(1,100) > 42 then entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} end end if scrapyard < -0.28 or scrapyard > 0.28 then - -- if math_random(1,128) == 1 then - -- Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) - -- entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} - -- end if math_random(1,96) == 1 then entities[#entities + 1] = {name = scrap_entities[math_random(1, scrap_entities_index)], position = p, force = "enemy"} end if math_random(1,5) > 1 then entities[#entities + 1] = {name="mineable-wreckage", position=p} end return @@ -498,10 +531,6 @@ local function process_scrapyard_position(p, seed, tiles, entities, treasure, pl return end end - - - --if math_random(1,64) == 1 and cave_ponds > 0.6 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end - tiles[#tiles + 1] = {name = "stone-path", position = p} end @@ -511,38 +540,34 @@ local function process_swamp_position(p, seed, tiles, entities, treasure, planet if scrapyard < -0.70 or scrapyard > 0.70 then tiles[#tiles + 1] = {name = "grass-3", position = p} - if math_random(1,50) == 1 then treasure[#treasure + 1] = p end + if math_random(1,40) == 1 then treasure[#treasure + 1] = p end return end - if scrapyard < -0.60 or scrapyard > 0.60 then + if scrapyard < -0.65 or scrapyard > 0.65 then tiles[#tiles + 1] = {name = "water-green", position = p} return end - if math_abs(scrapyard) > 0.40 and math_abs(scrapyard) < 0.60 then - if math_random(1,40) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 120 then entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p}end + if math_abs(scrapyard) > 0.50 and math_abs(scrapyard) < 0.65 then + if math_random(1,70) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 140 then entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p}end tiles[#tiles + 1] = {name = "water-mud", position = p} return end - if math_abs(scrapyard) > 0.25 and math_abs(scrapyard) < 0.40 then - if math_random(1,80) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 120 then entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p}end + if math_abs(scrapyard) > 0.35 and math_abs(scrapyard) < 0.50 then + if math_random(1,140) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 140 then entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p}end tiles[#tiles + 1] = {name = "water-shallow", position = p} return end - if scrapyard > -0.02 and scrapyard < 0.02 then - tiles[#tiles + 1] = {name = "water-green", position = p} - return - end - if scrapyard > -0.05 and scrapyard < 0.05 then - if math_random(1,100) > 42 then + if scrapyard > -0.15 and scrapyard < 0.15 then + if math_random(1,100) > 58 then entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} else - if math_random(1,20) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,8) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end end tiles[#tiles + 1] = {name = "grass-1", position = p} return end - if math_random(1, 120) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then + if math_random(1, 160) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end tiles[#tiles + 1] = {name = "grass-2", position = p} @@ -623,13 +648,11 @@ local function process_fish_position(p, seed, tiles, entities, treasure, planet) tiles[#tiles + 1 ] = {name = "out-of-map", position = p} end end - - end local levels = { process_level_1_position, - process_level_2_position, + process_dangerevent_position, process_hedgemaze_position, process_rocky_position, process_forest_position, @@ -675,6 +698,7 @@ local function get_replacement_tile(surface, position) if not tile.collides_with("resource-layer") then return tile.name end end end + if global.objective.planet[1].name.id == 18 then return "grass-2" end return "grass-1" end @@ -692,7 +716,6 @@ end local function forest_chunk(surface, left_top, level, planet) local tiles = {} local entities = {} - --local markets = {} local treasure = {} local seed = surface.map_gen_settings.seed local process_level = levels[level] @@ -716,7 +739,6 @@ end local function biter_chunk(surface, left_top, level, planet) local tiles = {} local entities = {} - --local markets = {} local treasure = {} local seed = surface.map_gen_settings.seed local process_level = levels[level] @@ -746,7 +768,6 @@ end local function empty_chunk(surface, left_top, level, planet) local tiles = {} local entities = {} - --local markets = {} local treasure = {} local seed = surface.map_gen_settings.seed local process_level = levels[level] @@ -763,12 +784,37 @@ local function empty_chunk(surface, left_top, level, planet) end surface.set_tiles(tiles, true) replace_water(surface, left_top) + if planet[1].name.id == 18 and left_top.y > 31 and left_top.x > 31 then + for x = 1, 5, 1 do + for y = 1, 5, 1 do + local pos = {x = left_top.x + x, y = left_top.y + y} + surface.set_tiles({{name = "deepwater-green", position = pos}}) + end + end + end +end + +local function danger_chunk(surface, left_top, level, planet) + local tiles = {} + local entities = {} + local treasure = {} + local seed = surface.map_gen_settings.seed + local process_level = levels[level] + + for y = 0, 31, 1 do + for x = 0, 31, 1 do + local p = {x = left_top.x + x, y = left_top.y + y} + process_level(p, seed, tiles, entities, treasure, planet) + end + end + surface.set_tiles(tiles, true) + replace_water(surface, left_top) + Specials.danger_event(surface, left_top) end local function fish_market(surface, left_top, level, planet) local tiles = {} local entities = {} - --local markets = {} local seed = surface.map_gen_settings.seed local process_level = levels[level] for y = 0, 31, 1 do @@ -778,63 +824,12 @@ local function fish_market(surface, left_top, level, planet) end end surface.set_tiles(tiles, true) - local market = surface.create_entity({name = "market", force = "player", position = {x = left_top.x + 16, y = left_top.y + 16}}) - market.destructible = false - market.operable = false - market.minable = false - local repair_text = rendering.draw_text{ - text = "Fish Market", - surface = surface, - target = market, - target_offset = {0, -2.5}, - color = global.locomotive.color, - scale = 1.00, - font = "default-game", - alignment = "center", - scale_with_zoom = false - } - local fishchest = surface.create_entity({name = "compilatron-chest", force = "player", position = {x = left_top.x + 11, y = left_top.y + 16}}) - fishchest.destructible = false - fishchest.minable = false - fishchest.operable = false - global.fishchest = fishchest - local repair_text = rendering.draw_text{ - text = "Deposit fish here", - surface = surface, - target = fishchest, - target_offset = {0, -2.5}, - color = global.locomotive.color, - scale = 0.75, - font = "default-game", - alignment = "center", - scale_with_zoom = false - } - local inserter = surface.create_entity({name = "fast-inserter", force = "player", position = {x = left_top.x + 10, y = left_top.y + 16}, direction = defines.direction.west}) - inserter.destructible = false - inserter.minable = false - inserter.operable = false - inserter.rotatable = false - local track = surface.create_entity({name = "straight-rail", force = "player", position = {x = left_top.x + 8, y = left_top.y + 16}}) - track.destructible = false - track.minable = false - -- for _, entity in pairs(entities) do - -- if entity_functions[game.entity_prototypes[entity.name].type] then - -- entity_functions[game.entity_prototypes[entity.name].type](surface, entity) - -- else - -- if surface.can_place_entity(entity) then - -- local e = surface.create_entity(entity) - -- -- if e.name == "biter-spawner" or e.name == "spitter-spawner" or e.name == "small-worm-turret" or e.name == "medium-worm-turret" or e.name == "big-worm-turret" or e.name == "behemoth-worm-turret" then - -- -- if math_abs(e.position.x) > 420 or math_abs(e.position.y) > 420 then e.destructible = false end - -- -- end - -- end - -- end - -- end + Specials.fish_market(surface, left_top) end local function fish_chunk(surface, left_top, level, planet) local tiles = {} local entities = {} - --local markets = {} local treasure = {} local seed = surface.map_gen_settings.seed local process_level = levels[level] @@ -856,9 +851,6 @@ local function fish_chunk(surface, left_top, level, planet) else if surface.can_place_entity(entity) then local e = surface.create_entity(entity) - -- if e.name == "biter-spawner" or e.name == "spitter-spawner" or e.name == "small-worm-turret" or e.name == "medium-worm-turret" or e.name == "big-worm-turret" or e.name == "behemoth-worm-turret" then - -- if math_abs(e.position.x) > 420 or math_abs(e.position.y) > 420 then e.destructible = false end - -- end end end end @@ -867,7 +859,6 @@ end local function normal_chunk(surface, left_top, level, planet) local tiles = {} local entities = {} - --local markets = {} local treasure = {} local seed = surface.map_gen_settings.seed local process_level = levels[level] @@ -914,20 +905,8 @@ local function normal_chunk(surface, left_top, level, planet) end end end - --local level_index = math_floor((math_abs(left_top.y / level_depth)) % 10) + 1 - - - surface.set_tiles(tiles, true) - -- if #markets > 0 then - -- local position = markets[math_random(1, #markets)] - -- if surface.count_entities_filtered{area = {{position.x - 96, position.y - 96}, {position.x + 96, position.y + 96}}, name = "market", limit = 1} == 0 then - -- local market = Market.mountain_market(surface, position, math_abs(position.y) * 0.004) - -- market.destructible = false - -- end - -- end - for _, p in pairs(treasure) do local name = "wooden-chest" if math_random(1, 6) == 1 then name = "iron-chest" end @@ -987,13 +966,15 @@ local function process_chunk(surface, left_top) if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 3, planet) return end if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 3, planet) return end elseif id == 17 then --fish market - --if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 3, planet) return end - --if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 3, planet) return end if math_abs(left_top.y) <= 31 and math_abs(left_top.x - 864) <= 31 then fish_market(surface, left_top, 10, planet) return end fish_chunk(surface, left_top, 10, planet) elseif id == 18 then --swamp planet - if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 9, planet) return end - if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then normal_chunk(surface, left_top, 9, planet) return end + if math_abs(left_top.y) <= 63 and math_abs(left_top.x) <= 63 then empty_chunk(surface, left_top, 9, planet) return end + if math_abs(left_top.y) > 63 or math_abs(left_top.x) > 63 then normal_chunk(surface, left_top, 9, planet) return end + elseif id == 19 then --danger event + if math_abs(left_top.y) <= 63 and math_abs(left_top.x) <= 63 then empty_chunk(surface, left_top, 2, planet) return end + if math_abs(left_top.y) == 448 and math_abs(left_top.x) == 448 then danger_chunk(surface, left_top, 2, planet) return end + if math_abs(left_top.y) > 63 or math_abs(left_top.x) > 63 then normal_chunk(surface, left_top, 2, planet) return end else if math_abs(left_top.y) <= 31 and math_abs(left_top.x) <= 31 then empty_chunk(surface, left_top, 7, planet) return end if math_abs(left_top.y) > 31 or math_abs(left_top.x) > 31 then biter_chunk(surface, left_top, 7, planet) return end diff --git a/maps/chronosphere/terrain_specials.lua b/maps/chronosphere/terrain_specials.lua new file mode 100644 index 00000000..61c34202 --- /dev/null +++ b/maps/chronosphere/terrain_specials.lua @@ -0,0 +1,102 @@ +local Public_terrain = {} + +function Public_terrain.danger_event(surface, left_top) + local silo = surface.create_entity({name = "rocket-silo", force = "enemy", position = {x = left_top.x + 16, y = left_top.y + 16}}) + local pole = surface.create_entity({name = "medium-electric-pole", position = {x = left_top.x + 12, y = left_top.y + 11}, force = "scrapyard", create_build_effect_smoke = false}) + local silo_text = rendering.draw_text{ + text = "Nuclear silo", + surface = surface, + target = pole, + target_offset = {5, -2.5}, + color = {r = 0.98, g = 0, b = 0}, + scale = 1.00, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + + local countdown_text = rendering.draw_text{ + text = " ", + surface = surface, + target = pole, + target_offset = {5, -1.5}, + color = {r = 0.98, g = 0, b = 0}, + scale = 1.00, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + silo.get_module_inventory().insert("effectivity-module-3") + silo.rocket_parts = 100 + --silo.get_module_inventory().insert("effectivity-module-3") + local combinator = surface.create_entity({name = "constant-combinator", position = {x = left_top.x + 11, y = left_top.y + 10}, force = "player", create_build_effect_smoke = false}) + local speaker = surface.create_entity({name = "programmable-speaker", position = {x = left_top.x + 11, y = left_top.y + 11}, force = "player", create_build_effect_smoke = false, + parameters = {playback_volume = 0.6, playback_globally = true, allow_polyphony = false}, + alert_parameters = {show_alert = true, show_on_map = true, icon_signal_id = {type = "item", name = "atomic-bomb"}, alert_message = "Nuclear missile silo detected!" }}) + combinator.connect_neighbour({wire = defines.wire_type.green, target_entity = speaker}) + local rules = combinator.get_or_create_control_behavior() + local rules2 = speaker.get_or_create_control_behavior() + rules.set_signal(1, {signal = {type = "virtual", name = "signal-A"}, count = 1}) + rules2.circuit_condition = {condition = {first_signal = {type = "virtual", name = "signal-A"}, second_constant = 0, comparator = ">"}} + rules2.circuit_parameters = {signal_value_is_pitch = false, instrument_id = 0, note_id = 6} + local solar = surface.create_entity({name = "solar-panel", position = {x = left_top.x + 14, y = left_top.y + 10}, force = "scrapyard", create_build_effect_smoke = false}) + local acu = surface.create_entity({name = "accumulator", position = {x = left_top.x + 14, y = left_top.y + 8}, force = "scrapyard", create_build_effect_smoke = false}) + acu.energy = 5000000 + speaker.minable = false + speaker.destructible = false + speaker.operable = false + combinator.minable = false + combinator.destructible = false + combinator.operable = false + solar.destructible = false + pole.destructible = false + acu.destructible = false + + global.objective.dangers[#global.objective.dangers + 1] = {silo = silo, speaker = speaker, combinator = combinator, solar = solar,acu = acu, pole = pole, destroyed = false, text = silo_text, timer = countdown_text} +end + +function Public_terrain.fish_market(surface, left_top) + local market = surface.create_entity({name = "market", force = "player", position = {x = left_top.x + 16, y = left_top.y + 16}}) + market.destructible = false + market.operable = false + market.minable = false + local repair_text = rendering.draw_text{ + text = "Fish Market", + surface = surface, + target = market, + target_offset = {0, -2.5}, + color = global.locomotive.color, + scale = 1.00, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + local fishchest = surface.create_entity({name = "compilatron-chest", force = "player", position = {x = left_top.x + 11, y = left_top.y + 16}}) + fishchest.destructible = false + fishchest.minable = false + fishchest.operable = false + global.fishchest = fishchest + local repair_text = rendering.draw_text{ + text = "Deposit fish here", + surface = surface, + target = fishchest, + target_offset = {0, -2.5}, + color = global.locomotive.color, + scale = 0.75, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + local inserter = surface.create_entity({name = "fast-inserter", force = "player", position = {x = left_top.x + 10, y = left_top.y + 16}, direction = defines.direction.west}) + inserter.destructible = false + inserter.minable = false + inserter.operable = false + inserter.rotatable = false + local track = surface.create_entity({name = "straight-rail", force = "player", position = {x = left_top.x + 8, y = left_top.y + 16}}) + track.destructible = false + track.minable = false +end + + + +return Public_terrain diff --git a/maps/chronosphere/tick_functions.lua b/maps/chronosphere/tick_functions.lua index 8df2b712..59797dd0 100644 --- a/maps/chronosphere/tick_functions.lua +++ b/maps/chronosphere/tick_functions.lua @@ -1,10 +1,21 @@ local Public_tick = {} local math_random = math.random +local math_floor = math.floor function Public_tick.check_chronoprogress() local objective = global.objective --game.print(objective.chronotimer) + if objective.planet[1].name.id == 19 then + if objective.passivetimer == 10 then + game.print("Comfylatron: We have a problem! We got disrupted in mid-jump, only part of energy got used, and here we landed. It might have been a trap!", {r=0.98, g=0.66, b=0.22}) + game.print("Comfylatron: My analysis says that charging needs full energy reset to work again, so we are stuck there until next full jump.", {r=0.98, g=0.66, b=0.22}) + elseif objective.passivetimer == 25 then + game.print("Robot voice: INTRUDER ALERT! Lifeforms detected! Must eliminate!", {r=0.98, g=0, b=0}) + elseif objective.passivetimer == 30 then + game.print("Robot voice: Nuclear missiles armed, launch countdown enabled.", {r=0.98, g=0, b=0}) + end + end if objective.chronotimer == objective.chrononeeds - 180 then game.print("Comfylatron: Acumulator charging disabled, 180 seconds countdown to jump!", {r=0.98, g=0.66, b=0.22}) elseif objective.chronotimer == objective.chrononeeds - 60 then @@ -25,7 +36,7 @@ function Public_tick.charge_chronosphere() local objective = global.objective if not objective.chronotimer then return end if objective.chronotimer < 20 then return end - if objective.planet[1].name.id == 17 then return end + if objective.planet[1].name.id == 17 or objective.planet[1].name.id == 19 then return end local acus = global.acumulators if #acus < 1 then return end for i = 1, #acus, 1 do @@ -85,8 +96,8 @@ end function Public_tick.output_items() if global.objective.game_lost == true then return end if not global.outchests then return end - if not global.locomotive_cargo2 then return end - if not global.locomotive_cargo3 then return end + if not global.locomotive_cargo[2] then return end + if not global.locomotive_cargo[3] then return end if global.objective.outupgradetier ~= 1 then return end for i = 1, 4, 1 do if not global.outchests[i].valid then return end @@ -96,9 +107,9 @@ function Public_tick.output_items() for item, count in pairs(items) do local inserted = nil if i <= 2 then - inserted = global.locomotive_cargo2.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) + inserted = global.locomotive_cargo[2].get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) else - inserted = global.locomotive_cargo3.get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) + inserted = global.locomotive_cargo[3].get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) end if inserted > 0 then local removed = inv.remove({name = item, count = inserted}) @@ -149,4 +160,102 @@ function Public_tick.spawn_poison() end end +local function launch_nukes() + local surface = game.surfaces[global.active_surface_index] + local objective = global.objective + if objective.dangers and #objective.dangers > 1 then + for i = 1, #objective.dangers, 1 do + if objective.dangers[i].destroyed == false then + local fake_shooter = surface.create_entity({name = "character", position = objective.dangers[i].silo.position, force = "enemy"}) + surface.create_entity({name = "atomic-rocket", position = objective.dangers[i].silo.position, force = "enemy", speed = 1, max_range = 800, target = global.locomotive, source = fake_shooter}) + game.print("Warning: Nuclear missile launched.", {r=0.98, g=0, b=0}) + end + end + end +end + +function Public_tick.dangertimer() + local objective = global.objective + local timer = objective.dangertimer + if timer == 0 then return end + if objective.planet[1].name.id == 19 then + timer = timer - 1 + if objective.dangers and #objective.dangers > 0 then + for i = 1, #objective.dangers, 1 do + if objective.dangers[i].destroyed == false then + if timer == 15 then + objective.dangers[i].silo.launch_rocket() + objective.dangers[i].silo.rocket_parts = 100 + end + rendering.set_text(objective.dangers[i].timer, math_floor(timer / 60) .. " min, " .. timer % 60 .. " s") + end + end + end + else + timer = 1200 + end + if timer < 0 then timer = 0 end + if timer == 0 then + launch_nukes() + timer = 90 + end + + objective.dangertimer = timer +end + +function Public_tick.offline_players() + local objective = global.objective + if objective.chronotimer > objective.chrononeeds - 182 then return end + local current_tick = game.tick + local players = objective.offline_players + local surface = game.surfaces[global.active_surface_index] + if #players > 0 then + --log("nonzero offline players") + local later = {} + for i = 1, #players, 1 do + if players[i] and game.players[players[i].index] and game.players[players[i].index].connected then + --game.print("deleting already online character from list") + players[i] = nil + else + if players[i] and players[i].tick < game.tick - 54000 then + --log("spawning corpse") + local player_inv = {} + player_inv[1] = game.players[players[i].index].get_inventory(defines.inventory.character_main) + player_inv[2] = game.players[players[i].index].get_inventory(defines.inventory.character_armor) + player_inv[3] = game.players[players[i].index].get_inventory(defines.inventory.character_guns) + player_inv[4] = game.players[players[i].index].get_inventory(defines.inventory.character_ammo) + player_inv[5] = game.players[players[i].index].get_inventory(defines.inventory.character_trash) + game.print("Comfylatron: Offline player had an accident, and dropped his items on ground around locomotive.") + local e = surface.create_entity({name = "character", position = game.forces.player.get_spawn_position(surface), force = "player"}) + local inv = e.get_inventory(defines.inventory.character_main) + for i = 1, 5, 1 do + if player_inv[i].valid then + local items = player_inv[i].get_contents() + for item, count in pairs(items) do + inv.insert({name = item, count = count}) + player_inv[i].remove({name = item, count = count}) + end + else + --log("invalid") + --game.print("invalid") + end + end + e.die("neutral") + players[i] = nil + else + --game.print("keeping player in list") + later[#later + 1] = players[i] + end + end + end + players = {} + if #later > 0 then + for i = 1, #later, 1 do + players[#players + 1] = later[i] + end + end + end +end + + return Public_tick diff --git a/maps/chronosphere/treasure.lua b/maps/chronosphere/treasure.lua index 23f22a64..6c419feb 100644 --- a/maps/chronosphere/treasure.lua +++ b/maps/chronosphere/treasure.lua @@ -8,6 +8,7 @@ function Public.treasure_chest(surface, position, container_name) local chest_raffle = {} local chest_loot = { {{name = "submachine-gun", count = math_random(1,3)}, weight = 3, d_min = 0.0, d_max = 0.1}, + {{name = "pistol", count = math_random(1,2)}, weight = 1, d_min = 0.0, d_max = 1}, {{name = "slowdown-capsule", count = math_random(16,32)}, weight = 1, d_min = 0.3, d_max = 0.7}, {{name = "poison-capsule", count = math_random(8,16)}, weight = 3, d_min = 0.3, d_max = 1}, {{name = "uranium-cannon-shell", count = math_random(16,32)}, weight = 5, d_min = 0.6, d_max = 1}, @@ -30,16 +31,20 @@ function Public.treasure_chest(surface, position, container_name) {{name = "piercing-rounds-magazine", count = math_random(32,128)}, weight = 5, d_min = 0.1, d_max = 0.8}, {{name = "uranium-rounds-magazine", count = math_random(32,128)}, weight = 5, d_min = 0.5, d_max = 1}, --{{name = "railgun", count = 1}, weight = 1, d_min = 0.2, d_max = 1}, - {{name = "railgun-dart", count = math_random(16,32)}, weight = 4, d_min = 0, d_max = 1}, + {{name = "railgun-dart", count = math_random(2,4)}, weight = 4, d_min = 0, d_max = 0.2}, + {{name = "railgun-dart", count = math_random(4,8)}, weight = 4, d_min = 0.1, d_max = 0.4}, + {{name = "railgun-dart", count = math_random(8,12)}, weight = 4, d_min = 0.3, d_max = 0.6}, + {{name = "railgun-dart", count = math_random(12,16)}, weight = 4, d_min = 0.5, d_max = 0.8}, + {{name = "railgun-dart", count = math_random(16,20)}, weight = 4, d_min = 0.7, d_max = 1}, {{name = "defender-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.0, d_max = 0.7}, {{name = "distractor-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.2, d_max = 1}, {{name = "destroyer-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.3, d_max = 1}, {{name = "atomic-bomb", count = 1}, weight = 1, d_min = 0.8, d_max = 1}, - {{name = "light-armor", count = 1}, weight = 3, d_min = 0, d_max = 0.1}, - {{name = "heavy-armor", count = 1}, weight = 3, d_min = 0.1, d_max = 0.3}, - {{name = "modular-armor", count = 1}, weight = 2, d_min = 0.2, d_max = 0.6}, + {{name = "light-armor", count = 1}, weight = 3, d_min = 0, d_max = 0.05}, + {{name = "heavy-armor", count = 1}, weight = 3, d_min = 0.05, d_max = 0.25}, + {{name = "modular-armor", count = 1}, weight = 2, d_min = 0.25, d_max = 0.5}, {{name = "power-armor", count = 1}, weight = 1, d_min = 0.4, d_max = 1}, - --{{name = "power-armor-mk2", count = 1}, weight = 1, d_min = 0.9, d_max = 1}, + {{name = "power-armor-mk2", count = 1}, weight = 1, d_min = 0.9, d_max = 1}, {{name = "battery-equipment", count = 1}, weight = 2, d_min = 0.3, d_max = 0.7}, --{{name = "battery-mk2-equipment", count = 1}, weight = 2, d_min = 0.7, d_max = 1}, {{name = "belt-immunity-equipment", count = 1}, weight = 1, d_min = 0.5, d_max = 1}, @@ -48,7 +53,7 @@ function Public.treasure_chest(surface, position, container_name) {{name = "energy-shield-equipment", count = math_random(1,2)}, weight = 2, d_min = 0.3, d_max = 0.8}, --{{name = "energy-shield-mk2-equipment", count = 1}, weight = 2, d_min = 0.8, d_max = 1}, {{name = "exoskeleton-equipment", count = 1}, weight = 1, d_min = 0.3, d_max = 1}, - --{{name = "fusion-reactor-equipment", count = 1}, weight = 1, d_min = 0.8, d_max = 1}, + {{name = "fusion-reactor-equipment", count = 1}, weight = 1, d_min = 0.8, d_max = 1}, {{name = "night-vision-equipment", count = 1}, weight = 1, d_min = 0.3, d_max = 0.8}, {{name = "personal-laser-defense-equipment", count = 1}, weight = 1, d_min = 0.7, d_max = 1}, diff --git a/maps/chronosphere/upgrades.lua b/maps/chronosphere/upgrades.lua index 82169c14..afb7e7df 100644 --- a/maps/chronosphere/upgrades.lua +++ b/maps/chronosphere/upgrades.lua @@ -352,7 +352,39 @@ local function check_win() end end +local function check_mk2_buy() + local objective = global.objective + if global.upgradechest[13] and global.upgradechest[13].valid then + local inv = global.upgradechest[13].get_inventory(defines.inventory.chest) + local count = inv.get_item_count("low-density-structure") + local count2 = inv.get_item_count("railgun-dart") + local count3 = inv.get_item_count("power-armor") + if count >= 100 and count2 >= 300 and count3 >= 1 and objective.chronojumps >= 24 then + inv.remove({name = "low-density-structure", count = 100}) + inv.remove({name = "railgun-dart", count = 300}) + inv.remove({name = "power-armor", count = 1}) + inv.insert({name = "power-armor-mk2", count = 1}) + game.print("Comfylatron: I upgraded one armor to mk2.", {r=0.98, g=0.66, b=0.22}) + end + end +end +local function check_fusion_buy() + local objective = global.objective + if global.upgradechest[14] and global.upgradechest[14].valid then + local inv = global.upgradechest[14].get_inventory(defines.inventory.chest) + local count = inv.get_item_count("low-density-structure") + local count2 = inv.get_item_count("railgun-dart") + local count3 = inv.get_item_count("solar-panel-equipment") + if count >= 100 and count2 >= 200 and count3 >= 16 and objective.chronojumps >= 24 then + inv.remove({name = "low-density-structure", count = 100}) + inv.remove({name = "railgun-dart", count = 200}) + inv.remove({name = "solar-panel-equipment", count = 16}) + inv.insert({name = "fusion-reactor-equipment", count = 1}) + game.print("Comfylatron: One personal fusion reactor ready.", {r=0.98, g=0.66, b=0.22}) + end + end +end function Public.check_upgrades() local objective = global.objective @@ -360,7 +392,7 @@ function Public.check_upgrades() if objective.hpupgradetier < 36 then check_upgrade_hp() end - if objective.filterupgradetier < 9 then + if objective.filterupgradetier < 9 and objective.chronojumps >= (objective.filterupgradetier + 1) * 3 then check_upgrade_filter() end if objective.acuupgradetier < 24 then @@ -369,7 +401,7 @@ function Public.check_upgrades() if objective.pickupupgradetier < 4 then check_upgrade_pickup() end - if objective.invupgradetier < 4 then + if objective.invupgradetier < 4 and objective.chronojumps >= (objective.invupgradetier + 1) * 5 then check_upgrade_inv() end if objective.toolsupgradetier < 4 then @@ -390,6 +422,10 @@ function Public.check_upgrades() if objective.computerupgrade < 3 and objective.chronojumps >= 15 then check_upgrade_computer() end + if objective.chronojumps >= 24 then + check_mk2_buy() + check_fusion_buy() + end if objective.planet[1].name.id == 17 then if global.fishchest then check_win() @@ -399,11 +435,12 @@ end function Public.trigger_poison() local objective = global.objective + if objective.game_lost then return end if objective.poisondefense > 0 and objective.poisontimeout == 0 then local objective = global.objective objective.poisondefense = objective.poisondefense - 1 objective.poisontimeout = 120 - local objs = {global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3} + local objs = {global.locomotive, global.locomotive_cargo[1], global.locomotive_cargo[2], global.locomotive_cargo[3]} local surface = objective.surface game.print("Comfylatron: Triggering poison defense. Let's kill everything!", {r=0.98, g=0.66, b=0.22}) for i = 1, 4, 1 do From 195da3f8451bbaa3276149ed1428a8ff238bd8e2 Mon Sep 17 00:00:00 2001 From: jacobwatkinsgit <48106701+jacobwatkinsgit@users.noreply.github.com> Date: Wed, 11 Mar 2020 16:20:21 -0400 Subject: [PATCH 27/70] clean hard-coded logic in repair_train remove need for almost all hard-coded values and branching logic --- maps/chronosphere/tick_functions.lua | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/maps/chronosphere/tick_functions.lua b/maps/chronosphere/tick_functions.lua index 59797dd0..55278f3d 100644 --- a/maps/chronosphere/tick_functions.lua +++ b/maps/chronosphere/tick_functions.lua @@ -2,6 +2,8 @@ local Public_tick = {} local math_random = math.random local math_floor = math.floor +local math_ceil = math.ceil +local math_min = math.min function Public_tick.check_chronoprogress() local objective = global.objective @@ -122,27 +124,13 @@ function Public_tick.repair_train() local objective = global.objective if not game.surfaces["cargo_wagon"] then return 0 end if objective.game_lost == true then return 0 end + local count = 0 if objective.health < objective.max_health then - local inv = global.upgradechest[1].get_inventory(defines.inventory.chest) - local count = inv.get_item_count("repair-pack") - if count >= 5 and objective.toolsupgradetier == 4 and objective.health + 750 <= objective.max_health then - inv.remove({name = "repair-pack", count = 5}) - return -750 - elseif count >= 4 and objective.toolsupgradetier == 3 and objective.health + 600 <= objective.max_health then - inv.remove({name = "repair-pack", count = 4}) - return -600 - elseif count >= 3 and objective.toolsupgradetier == 2 and objective.health + 450 <= objective.max_health then - inv.remove({name = "repair-pack", count = 3}) - return -450 - elseif count >= 2 and objective.toolsupgradetier == 1 and objective.health + 300 <= objective.max_health then - inv.remove({name = "repair-pack", count = 2}) - return -300 - elseif count >= 1 then - inv.remove({name = "repair-pack", count = 1}) - return -150 - end + count = global.upgradechest[1].get_inventory(defines.inventory.chest).get_item_count("repair-pack") + count = math_min(count, objective.toolsupgradetier + 1, math_ceil((objective.max_health - objective.health) / 150)) + if count > 0 then inv.remove({name = "repair-pack", count = count}) end end - return 0 + return count * -150 end function Public_tick.spawn_poison() From 87e7edcb5a5d70388d34b40bff50ab07481ede0b Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sat, 14 Mar 2020 08:48:50 +0100 Subject: [PATCH 28/70] Add files via upload --- locale/en/locale.cfg | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index b5275b1e..725b1564 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -61,11 +61,53 @@ map_info_text=The biters have catched the scent of fish in the cargo wagon.\nGui map_info_main_caption=Chronosphere map_info_sub_caption= ..Comfylatron gone wild.. map_info_text_old=Comfylatron has seized The Fish Train and turned it into a time machine.\nIt is your job to make sure the cargo is safe throughout the times and places we travel through!\nThis however will not be an easy task,\nas Comfylatron does not have any idea how to control this machine at all.\n\nThe destinations of quantum time jumps are completely random, and the machine always needs time to recharge.\nYou can speed it up greatly by charging acumulators in Locomotive.\nSo be sure to grab as many resources as you can before the train jump away!\nComfylatron manages to run teleporting devices to transport items into train from his chests. Also to save people from staying in wrong universe.\n\nOnce a quantum jump is initiated, be sure to have everything packed up, there is nearly zero chance to revisit that place again!\nMining productivity research will overhaul your mining equipment,\nreinforcing your pickaxes, as well as increasing the size of your backpack.\nGood luck on your journey! -map_info_text=Comfylatron has seized the Fish Train and turned it into a time machine.\n Your job as his slave is:\n\n[1] Keep train alive at all costs\n[2] Gather resources while travelling through different maps.\n[3a] Press enter on cargo wagons to enter insides of train.\n[3b] Press enter on cars to exit the train.\n[4] Charging acumulators inside train speeds up jumps when leaving early is needed.\n[5] Items inserted into comfylatron chests get teleported into train.\n[6] Some planets are poor, some are rich, and some are just too dangerous.\n\n Loot, but also evolution grows with jumps performed.\n During jump, personnel will be teleported in,\n however dead bodies nor buildings won't.\nMining productivity grants inventory space and handmining speed.\n\nGood luck. Don't let biters ruin the show! +map_info_text=Comfylatron has seized the Fish Train and turned it into a time machine.\n Your job as his slave is:\n\n[1] Keep train alive at all costs\n[2] Gather resources while travelling through different maps.\n[3a] Press enter on cargo wagons to enter insides of train.\n[3b] Press enter on cars to exit the train.\n[4] Charging acumulators inside train speeds up jumps when leaving early is needed.\nCharging and jumping creates huge pollution so be ready to get attacked.\n[5] Items inserted into comfylatron chests get teleported into train.\n[6] Some planets are poor, some are rich, and some are just too dangerous.\n\n Loot, but also evolution grows with jumps performed.\n During jump, personnel will be teleported in,\n however dead bodies nor buildings won't.\nMining productivity grants inventory space and handmining speed.\n\nGood luck. Don't let biters ruin the show! +message_danger1=Comfylatron: We have a problem! We got disrupted in mid-jump, only part of energy got used, and here we landed. It might have been a trap! +message_danger2=Comfylatron: My analysis says that charging needs full energy reset to work again, so we are stuck there until next full jump. +message_danger3=Robot voice: INTRUDER ALERT! Lifeforms detected! Must eliminate! +message_danger4=Robot voice: Nuclear missiles armed, launch countdown enabled. +message_jump180=Comfylatron: Acumulator charging disabled, 180 seconds countdown to jump! +message_jump60=Comfylatron: ChronoTrain nearly charged! Grab what you can, we leaving in 60 seconds! +message_jump30=Comfylatron: You better hurry up! 30 seconds remaining! +message_nuke=Warning: Nuclear missiles launched. +message_accident=Comfylatron: Offline player had an accident, and dropped his items on ground around locomotive. +message_silo=Nuclear silo destroyed. You managed to loot 5 atomic bombs. Comfylatron seized them for your own safety. +message_game_won_restart=Comfylatron: WAIT whaat? Looks like we did not fixed the train properly and it teleported us back in time...sigh...so let's do this again, and now properly. +message_fishmarket1=Comfylatron: So here we are. Fish Market. When they ordered the fish, they said this location is perfectly safe. Looks like we will have to do it for them. +message_fishmarket2=Comfylatron: I hope you have enough nukes. Also, that satellite gave us some space knowledge. +message_fishmarket3=Comfylatron: Luckily we looted some nukes before, take them. +message_lava=Comfylatron: OOF this one is a bit hot. And have seen those biters? They BATHE in fire! Maybe try some bricks to protect from lava? +message_choppy=Comfylatron: OwO what are those strange trees?!? They have ore fruits! WTF! +message_game_lost1=The chronotrain was destroyed! +message_game_lost2=Comfylatron is going to kill you for that...he has time machine after all! +message_evolve=Comfylatron: Biters start to evolve faster! We need to charge forward or they will be stronger! (hover over timer to see evolve timer) +message_quest1=Comfylatron: You know...I have big quest. Deliver fish to fish market. But this train is broken. Please help me fix the train computer! +message_quest2=Comfylatron: Thanks for fixing train navigation. I can now get us rid of very poor worlds. It will still need more work though. +message_quest3=Comfylatron: Ah, we need to give this machine more power and better navigation chipset. Please bring me some additional things. +message_quest4=Comfylatron: Perfect! Now we have train reactor and even better destination precision. I will get to you later what still needs to be done. +message_quest5=Comfylatron: Finally found the main issue. We will need to rebuild whole processor. Exactly what I feared of. Just a few more things... +message_quest6=Comfylatron: And this was last part of cpu brain done. Now we just need to synchronize our time correctly and we are done! Bring me satellite and rocket silo. +message_quest7=Comfylatron: Time synchronized. Calculating time and space destination. Success. Jump once more and let me deliver the fish finally. This trip is getting long. +message_game_won1=Comfylatron: Thank you with helping me on this delivery. It was tough one. I hope, that now, when all biters are dead, fish will be safe here forever... +message_overstay=Comfylatron: Looks like you stayed on previous planet for so long that enemies on other planets had additional time to evolve! +message_upgrade_hp=Comfylatron: Train's max HP was upgraded. +message_upgrade_filter=Comfylatron: Train's pollution filter was upgraded. +message_upgrade_acu=Comfylatron: Train's accumulator capacity was upgraded. +message_upgrade_pickup=Comfylatron: Players now have additional red inserter installed on shoulders, increasing their item pickup range. +message_upgrade_inventory=Comfylatron: Players now can carry more trash in their unsorted inventories. +message_upgrade_repair=Comfylatron: Train now gets repaired with additional repair kit at once. +message_upgrade_water=Comfylatron: Train now has piping system for additional water sources. +message_upgrade_out=Comfylatron: Train now has output chests. +message_upgrade_storage=Comfylatron: Cargo wagons now have enlargened storage. +message_upgrade_poison=Comfylatron: I don't believe in your defense skills. I equipped train with poison defense. +message_upgrade_mk2=Comfylatron: I upgraded one armor to mk2. +message_upgrade_fusion=Comfylatron: One personal fusion reactor ready. +message_poison_defense=Comfylatron: Triggering poison defense. Let's kill everything! gui_1=ChronoJumps: gui_2=Charge: gui_3=Timer: gui_3_1=Best Case Timer: +gui_3_2=Nuclear missiles launched in: gui_4=Local Evolution: [rocks_yield_ore_veins] From 5ee0dbb598274fc476485deb129e5118d0ce07e2 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sat, 14 Mar 2020 08:55:13 +0100 Subject: [PATCH 29/70] Add files via upload --- maps/chronosphere/chrono.lua | 120 +++++++++++++++++++++--- maps/chronosphere/chronobubles.lua | 2 +- maps/chronosphere/comfylatron.lua | 24 ++--- maps/chronosphere/event_functions.lua | 32 ++++++- maps/chronosphere/gui.lua | 2 +- maps/chronosphere/locomotive.lua | 8 +- maps/chronosphere/main.lua | 128 +++----------------------- maps/chronosphere/ores.lua | 2 +- maps/chronosphere/terrain.lua | 3 +- maps/chronosphere/tick_functions.lua | 91 +++++++++++------- maps/chronosphere/upgrades.lua | 76 ++++++++------- 11 files changed, 262 insertions(+), 226 deletions(-) diff --git a/maps/chronosphere/chrono.lua b/maps/chronosphere/chrono.lua index bfb328e1..e2dce44b 100644 --- a/maps/chronosphere/chrono.lua +++ b/maps/chronosphere/chrono.lua @@ -1,14 +1,111 @@ local Public_chrono = {} local Server = require 'utils.server' +local math_random = math.random + +function Public_chrono.get_map_gen_settings() + local seed = math_random(1, 1000000) + local map_gen_settings = { + ["seed"] = seed, + ["width"] = 960, + ["height"] = 960, + ["water"] = 0.1, + ["starting_area"] = 1, + ["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0}, + ["default_enable_all_autoplace_controls"] = true, + ["autoplace_settings"] = { + ["entity"] = {treat_missing_as_default = false}, + ["tile"] = {treat_missing_as_default = true}, + ["decorative"] = {treat_missing_as_default = true}, + }, + } + return map_gen_settings +end + +function Public_chrono.restart_settings() + local objective = global.objective + objective.max_health = 10000 + objective.health = 10000 + objective.hpupgradetier = 0 + objective.acuupgradetier = 0 + objective.filterupgradetier = 0 + objective.pickupupgradetier = 0 + objective.invupgradetier = 0 + objective.toolsupgradetier = 0 + objective.waterupgradetier = 0 + objective.outupgradetier = 0 + objective.boxupgradetier = 0 + objective.poisondefense = 2 + objective.poisontimeout = 0 + objective.chronotimer = 0 + objective.passivetimer = 0 + objective.passivejumps = 0 + objective.chrononeeds = 2000 + objective.mainscore = 0 + objective.active_biters = {} + objective.unit_groups = {} + objective.biter_raffle = {} + objective.dangertimer = 1200 + objective.dangers = {} + objective.looted_nukes = 0 + objective.offline_players = {} + objective.nextsurface = nil + global.outchests = {} + global.upgradechest = {} + global.fishchest = {} + global.acumulators = {} + global.comfychests = {} + global.comfychests2 = {} + global.locomotive_cargo = {} + for _, player in pairs(game.connected_players) do + global.flame_boots[player.index] = {fuel = 1, steps = {}} + end + global.friendly_fire_history = {} + global.landfill_history = {} + global.mining_history = {} + global.score = {} + global.difficulty_poll_closing_timeout = game.tick + 90000 + global.difficulty_player_votes = {} + + game.difficulty_settings.technology_price_multiplier = 0.6 + game.map_settings.enemy_evolution.destroy_factor = 0.005 + game.map_settings.enemy_evolution.pollution_factor = 0 + game.map_settings.enemy_evolution.time_factor = 7e-05 + game.map_settings.enemy_expansion.enabled = true + game.map_settings.enemy_expansion.max_expansion_cooldown = 3600 + game.map_settings.enemy_expansion.min_expansion_cooldown = 3600 + game.map_settings.enemy_expansion.settler_group_max_size = 8 + game.map_settings.enemy_expansion.settler_group_min_size = 16 + game.map_settings.pollution.enabled = true + game.map_settings.pollution.pollution_restored_per_tree_damage = 0.02 + game.map_settings.pollution.min_pollution_to_damage_trees = 1 + game.map_settings.pollution.max_pollution_to_restore_trees = 0 + game.map_settings.pollution.pollution_with_max_forest_damage = 10 + game.map_settings.pollution.pollution_per_tree_damage = 0.1 + game.map_settings.pollution.ageing = 0.1 + game.map_settings.pollution.diffusion_ratio = 0.1 + game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 5 + game.forces.neutral.character_inventory_slots_bonus = 500 + game.forces.enemy.evolution_factor = 0.0001 + game.forces.scrapyard.set_friend('enemy', true) + game.forces.enemy.set_friend('scrapyard', true) + + game.forces.player.technologies["land-mine"].enabled = false + game.forces.player.technologies["landfill"].enabled = false + game.forces.player.technologies["fusion-reactor-equipment"].enabled = false + game.forces.player.technologies["power-armor-mk2"].enabled = false + game.forces.player.technologies["railway"].researched = true + game.forces.player.recipes["pistol"].enabled = false +end + function Public_chrono.objective_died() local objective = global.objective if objective.game_lost == true then return end objective.health = 0 local surface = objective.surface - game.print("The chronotrain was destroyed!") - game.print("Comfylatron is going to kill you for that...he has time machine after all!") + game.print({"chronosphere.message_game_lost1"}) + game.print({"chronosphere.message_game_lost2"}) for i = 1, 3, 1 do surface.create_entity({name = "big-artillery-explosion", position = global.locomotive_cargo[i].position}) global.locomotive_cargo[i].destroy() @@ -56,24 +153,25 @@ function Public_chrono.process_jump(choice) objective.chrononeeds = 2000 + 400 * objective.chronojumps objective.passivetimer = 0 objective.chronotimer = 0 + objective.danegrtimer = 1200 local message = "Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. global.objective.chronojumps game.print(message, {r=0.98, g=0.66, b=0.22}) Server.to_discord_embed(message) if objective.chronojumps == 6 then - game.print("Comfylatron: Biters start to evolve faster! We need to charge forward or they will be stronger! (hover over timer to see evolve timer)", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_evolve"}, {r=0.98, g=0.66, b=0.22}) elseif objective.chronojumps >= 15 and objective.computermessage == 0 then - game.print("Comfylatron: You know...I have big quest. Deliver fish to fish market. But this train is broken. Please help me fix the train computer!", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_quest1"}, {r=0.98, g=0.66, b=0.22}) objective.computermessage = 1 elseif objective.chronojumps >= 20 and objective.computermessage == 2 then - game.print("Comfylatron: Ah, we need to give this machine more power and better navigation chipset. Please bring me some additional things.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_quest3"}, {r=0.98, g=0.66, b=0.22}) objective.computermessage = 3 elseif objective.chronojumps >= 25 and objective.computermessage == 4 then - game.print("Comfylatron: Finally found the main issue. We will need to rebuild whole processor. Exactly what I feared of. Just a few more things...", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_quest5"}, {r=0.98, g=0.66, b=0.22}) objective.computermessage = 5 end if overstayed then - game.print("Comfylatron: Looks like you stayed on previous planet for so long that enemies on other planets had additional time to evolve!", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_overstay"}, {r=0.98, g=0.66, b=0.22}) end if objective.planet[1].name.id == 19 then check_nuke_silos() @@ -87,7 +185,7 @@ function Public_chrono.get_wagons() three = global.locomotive_cargo[3].get_inventory(defines.inventory.cargo_wagon) } inventories.one.sort_and_merge() - inventories.two.sort_and_merge() + --inventories.two.sort_and_merge() local wagons = {} wagons[1] = {inventory = inventories.one.get_contents(), bar = inventories.one.get_bar(), filters = {}} wagons[2] = {inventory = inventories.two.get_contents(), bar = inventories.two.get_bar(), filters = {}} @@ -112,16 +210,16 @@ function Public_chrono.post_jump() global.comfychests[1].insert({name = "space-science-pack", count = 1000}) if objective.looted_nukes > 0 then global.comfychests[1].insert({name = "atomic-bomb", count = objective.looted_nukes}) - game.print("Comfylatron: Luckily we looted some nukes before, take them.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_fishmarket3"}, {r=0.98, g=0.66, b=0.22}) end objective.chrononeeds = 200000000 elseif objective.planet[1].name.id == 19 then - objective.chronotimer = objective.chrononeeds - 1500 + objective.chronotimer = objective.chrononeeds - 1800 end for _, player in pairs(game.connected_players) do global.flame_boots[player.index] = {fuel = 1, steps = {}} end - objective.danegrtimer = 1200 + game.map_settings.enemy_evolution.time_factor = 7e-05 + 3e-06 * (objective.chronojumps + objective.passivejumps) game.forces.scrapyard.set_ammo_damage_modifier("bullet", 0.01 * objective.chronojumps) game.forces.scrapyard.set_turret_attack_modifier("gun-turret", 0.01 * objective.chronojumps) diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua index 68062368..ecaac8b2 100644 --- a/maps/chronosphere/chronobubles.lua +++ b/maps/chronosphere/chronobubles.lua @@ -99,7 +99,7 @@ function Public.determine_planet(choice) name = planet_choice, day_speed = dayspeed, time = daytime, - ore_richness = richness[ores], + ore_richness = richness[ores] } } objective.planet = planet diff --git a/maps/chronosphere/comfylatron.lua b/maps/chronosphere/comfylatron.lua index d1b0be54..7f5c69c5 100644 --- a/maps/chronosphere/comfylatron.lua +++ b/maps/chronosphere/comfylatron.lua @@ -211,18 +211,18 @@ end local function desync(event) if global.comfybubble then global.comfybubble.destroy() end - --local m = 12 - --local m2 = m * 0.005 - -- for i = 1, 32, 1 do - -- global.comfylatron.surface.create_entity({ - -- name = "iron-ore-particle", - -- position = global.comfylatron.position, - -- frame_speed = 0.1, - -- vertical_speed = 0.1, - -- height = 0.1, - -- movement = {m2 - (math.random(0, m) * 0.01), m2 - (math.random(0, m) * 0.01)} - -- }) - -- end + local m = 12 + local m2 = m * 0.005 + for i = 1, 32, 1 do + global.comfylatron.surface.create_particle({ + name = "iron-ore-particle", + position = global.comfylatron.position, + frame_speed = 0.1, + vertical_speed = 0.1, + height = 0.1, + movement = {m2 - (math.random(0, m) * 0.01), m2 - (math.random(0, m) * 0.01)} + }) + end if not event or math_random(1,4) == 1 then global.comfylatron.surface.create_entity({name = "medium-explosion", position = global.comfylatron.position}) global.comfylatron.surface.create_entity({name = "flying-text", position = global.comfylatron.position, text = "desync", color = {r = 150, g = 0, b = 0}}) diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua index 6c524540..dc8c0905 100644 --- a/maps/chronosphere/event_functions.lua +++ b/maps/chronosphere/event_functions.lua @@ -23,8 +23,8 @@ local function get_ore_amount() end local function reward_ores(amount, mined_loot, surface, player) - local i = player.insert {name = mined_loot, count = amount} - amount = amount - i + local a = player.insert {name = mined_loot, count = amount} + amount = amount - a if amount > 0 then if amount >= 50 then for i = 1, math_floor(amount / 50), 1 do @@ -180,9 +180,9 @@ local ore_yield = { function Public_event.swamp_loot(event) local surface = game.surfaces[global.active_surface_index] - local amount = get_ore_amount() / 10 + local amount = get_ore_amount() / 12 if ore_yield[event.entity.name] then - amount = get_ore_amount() / 10 * ore_yield[event.entity.name] + amount = get_ore_amount() / 12 * ore_yield[event.entity.name] end local rock_mining = {"iron-ore", "iron-ore", "coal", "coal", "coal"} local mined_loot = rock_mining[math_random(1,#rock_mining)] @@ -195,7 +195,7 @@ function Public_event.danger_silo(entity) if objective.dangers and #objective.dangers > 1 then for i = 1, #objective.dangers, 1 do if entity == objective.dangers[i].silo then - game.print("Nuclear silo destroyed. You managed to loot 5 atomic bombs. Comfylatron seized them for your own safety.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_silo"}, {r=0.98, g=0.66, b=0.22}) objective.dangers[i].destroyed = true objective.dangers[i].silo = nil objective.dangers[i].speaker.destroy() @@ -263,5 +263,27 @@ function Public_event.flamer_nerfs() game.forces.player.set_turret_attack_modifier("flamethrower-turret", flamer_power - 0.02 * difficulty * objective.chronojumps) end +function Public_event.mining_buffs() + local mining_power = 0 + local mining_researches = { + [1] = {name = "mining-productivity-1", bonus = 0.2}, + [2] = {name = "mining-productivity-2", bonus = 0.2}, + [3] = {name = "mining-productivity-3", bonus = 0.2}, + [4] = {name = "mining-productivity-4", bonus = 0.2} + } + for i = 1, 3, 1 do + if game.forces.player.technologies[mining_researches[i].name].researched then + mining_power = mining_power + mining_researches[i].bonus + end + end + mining_power = mining_power + (game.forces.player.technologies[mining_researches[4].name].level - 4) * 0.2 + game.forces.player.mining_drill_productivity_bonus = 1 + mining_power + local bonusinv = 0 + if game.forces.player.technologies["toolbelt"].researched then bonusinv = 10 end + game.forces.player.character_inventory_slots_bonus = mining_power * 50 + global.objective.invupgradetier * 10 + bonusinv + if game.forces.player.technologies["steel-axe"].researched then + game.forces.player.manual_mining_speed_modifier = 1 + mining_power * 2 + end +end return Public_event diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index ee181753..9f0690db 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -154,7 +154,7 @@ local function update_gui(player) [2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%\n Buyable once per 3 jumps.\n Cost: 5000 coins + 2000 green circuits + Jump number " .. (objective.filterupgradetier + 1) * 3 .. "\n"}, [3] = {t = "[3]: Add additional row of Acumulators.\n Cost : " .. math_floor(2000 * (1 + objective.acuupgradetier /4)) .. " coins + 200 batteries\n"}, [4] = {t = "[4]: Add item pickup distance to players.Current: +" .. objective.pickupupgradetier .. ",\n Cost: " .. 1000 * (1 + objective.pickupupgradetier) .. " coins + 400 red inserters\n"}, - [5] = {t = "[5]: Add +5 inventory slots. Buyable once per 5 jumps.\n Cost: " .. 2000 * (1 + objective.invupgradetier) .." coins + " .. chests[objective.invupgradetier + 1].c}, + [5] = {t = "[5]: Add +10 inventory slots. Buyable once per 5 jumps.\n Cost: " .. 2000 * (1 + objective.invupgradetier) .." coins + " .. chests[objective.invupgradetier + 1].c}, [6] = {t = "[6]: Use up more repair tools on train at once. Current: +" .. objective.toolsupgradetier .. "\n Cost: " .. 1000 * (1 + objective.toolsupgradetier) .. " coins + " .. 200 * (1 + objective.toolsupgradetier) .. " repair tools\n"}, [7] = {t = "[7]: Add piping through wagon sides to create water sources for each wagon.\n Cost: 2000 coins + 500 pipes\n"}, [8] = {t = "[8]: Add comfylatron chests that output outside (into cargo wagon 2 and 3)\n Cost: 2000 coins + 100 fast inserters\n"}, diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index 310e61a1..e4097f8b 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -32,8 +32,8 @@ function Public.locomotive_spawn(surface, position, wagons) global.locomotive.color = {0, 255, 0} global.locomotive.minable = false - -- if not global.comfychests then global.comfychests = {} end - -- if not global.acumulators then global.acumulators = {} end + --if not global.comfychests then global.comfychests = {} end + --if not global.acumulators then global.acumulators = {} end for i = 1, 24, 1 do local yi = 0 local xi = 5 @@ -122,8 +122,8 @@ local market_offers = { function Public.create_wagon_room() local width = 64 local height = 384 - --global.comfychests2 = {} - if not global.acumulators then global.acumulators = {} end + global.comfychests2 = {} + global.acumulators = {} local map_gen_settings = { ["width"] = width, ["height"] = height + 128, diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 5a5c3b2e..a71e4482 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -47,11 +47,12 @@ local function generate_overworld(surface, optplanet) game.print(message, {r=0.98, g=0.66, b=0.22}) Server.to_discord_embed(message) if planet[1].name.id == 12 then - game.print("Comfylatron: OwO what are those strange trees?!? They have ore fruits! WTF!", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_choppy"}, {r=0.98, g=0.66, b=0.22}) elseif planet[1].name.id == 14 then - game.print("Comfylatron: OOF this one is a bit hot. And have seen those biters? They BATHE in fire! Maybe try some bricks to protect from lava?", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_lava"}, {r=0.98, g=0.66, b=0.22}) elseif planet[1].name.id == 17 then - game.print("Comfylatron: So here we are. Fish Market. When they ordered the fish, they said this location is perfectly safe. Looks like we will have to do it for them. I hope you have enough nukes. Also, that satellite gave us some space knowledge.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_fishmarket1"}, {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_fishmarket2"}, {r=0.98, g=0.66, b=0.22}) end surface.min_brightness = 0 surface.brightness_visual_weights = {1, 1, 1} @@ -100,25 +101,6 @@ local function generate_overworld(surface, optplanet) end end -local function get_map_gen_settings() - local seed = math_random(1, 1000000) - local map_gen_settings = { - ["seed"] = seed, - ["width"] = 960, - ["height"] = 960, - ["water"] = 0.1, - ["starting_area"] = 1, - ["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0}, - ["default_enable_all_autoplace_controls"] = true, - ["autoplace_settings"] = { - ["entity"] = {treat_missing_as_default = false}, - ["tile"] = {treat_missing_as_default = true}, - ["decorative"] = {treat_missing_as_default = true}, - }, - } - return map_gen_settings -end - local function render_train_hp() local surface = game.surfaces[global.active_surface_index] local objective = global.objective @@ -159,11 +141,11 @@ local function reset_map() objective.computerupgrade = 0 objective.computerparts = 0 objective.computermessage = 0 - local map_gen_settings = get_map_gen_settings() + objective.chronojumps = 0 Planets.determine_planet(nil) local planet = global.objective.planet if not global.active_surface_index then - global.active_surface_index = game.create_surface("chronosphere", map_gen_settings).index + global.active_surface_index = game.create_surface("chronosphere", Chrono.get_map_gen_settings()).index else game.forces.player.set_spawn_position({12, 10}, game.surfaces[global.active_surface_index]) global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], map_gen_settings, starting_items).index @@ -171,79 +153,7 @@ local function reset_map() local surface = game.surfaces[global.active_surface_index] generate_overworld(surface, planet) - - - objective.max_health = 10000 - objective.health = 10000 - objective.hpupgradetier = 0 - objective.acuupgradetier = 0 - objective.filterupgradetier = 0 - objective.pickupupgradetier = 0 - objective.invupgradetier = 0 - objective.toolsupgradetier = 0 - objective.waterupgradetier = 0 - objective.outupgradetier = 0 - objective.boxupgradetier = 0 - objective.poisondefense = 2 - objective.poisontimeout = 0 - objective.chronojumps = 0 - objective.chronotimer = 0 - objective.passivetimer = 0 - objective.passivejumps = 0 - objective.chrononeeds = 2000 - objective.mainscore = 0 - objective.active_biters = {} - objective.unit_groups = {} - objective.biter_raffle = {} - objective.dangertimer = 1200 - objective.dangers = {} - objective.looted_nukes = 0 - global.outchests = {} - global.upgradechest = {} - global.fishchest = {} - global.acumulators = {} - global.comfychests = {} - global.comfychests2 = {} - global.locomotive_cargo = {} - for _, player in pairs(game.connected_players) do - global.flame_boots[player.index] = {fuel = 1, steps = {}} - end - global.friendly_fire_history = {} - global.landfill_history = {} - global.mining_history = {} - global.score = {} - - - - - game.difficulty_settings.technology_price_multiplier = 0.6 - game.map_settings.enemy_evolution.destroy_factor = 0.005 - game.map_settings.enemy_evolution.pollution_factor = 0 - game.map_settings.enemy_evolution.time_factor = 7e-05 - game.map_settings.enemy_expansion.enabled = true - game.map_settings.enemy_expansion.max_expansion_cooldown = 3600 - game.map_settings.enemy_expansion.min_expansion_cooldown = 3600 - game.map_settings.enemy_expansion.settler_group_max_size = 8 - game.map_settings.enemy_expansion.settler_group_min_size = 16 - game.map_settings.pollution.enabled = true - game.map_settings.pollution.pollution_restored_per_tree_damage = 0.02 - game.map_settings.pollution.min_pollution_to_damage_trees = 1 - game.map_settings.pollution.max_pollution_to_restore_trees = 0 - game.map_settings.pollution.pollution_with_max_forest_damage = 10 - game.map_settings.pollution.pollution_per_tree_damage = 0.1 - game.map_settings.pollution.ageing = 0.1 - game.map_settings.pollution.diffusion_ratio = 0.1 - game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 5 - game.forces.enemy.evolution_factor = 0.0001 - game.forces.scrapyard.set_friend('enemy', true) - game.forces.enemy.set_friend('scrapyard', true) - - game.forces.player.technologies["land-mine"].enabled = false - game.forces.player.technologies["landfill"].enabled = false - game.forces.player.technologies["fusion-reactor-equipment"].enabled = false - game.forces.player.technologies["power-armor-mk2"].enabled = false - game.forces.player.technologies["railway"].researched = true - game.forces.player.recipes["pistol"].enabled = false + Chrono.restart_settings() game.forces.player.set_spawn_position({12, 10}, surface) local wagons = {} @@ -258,10 +168,9 @@ local function reset_map() render_train_hp() game.reset_time_played() Locomotive.create_wagon_room() - global.difficulty_poll_closing_timeout = game.tick + 54000 - global.difficulty_player_votes = {} + Event_functions.mining_buffs() if objective.game_won then - game.print("Comfylatron: WAIT whaat? Looks like we did not fixed the train properly and it teleported us back in time...sigh...so let's do this again, and now properly.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_game_won_restart"}, {r=0.98, g=0.66, b=0.22}) end objective.game_lost = false objective.game_won = false @@ -301,11 +210,6 @@ local function on_player_joined_game(event) end end -local function on_player_left_game(event) - local player = game.players[event.player_index] - -end - local function on_pre_player_left_game(event) local player = game.players[event.player_index] if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end @@ -344,13 +248,12 @@ local function chronojump(choice) Locomotive.enter_cargo_wagon(player, wagons[math_random(1,3)]) end end - local map_gen_settings = get_map_gen_settings() global.lab_cells = {} - global.active_surface_index = game.create_surface("chronosphere" .. objective.chronojumps, map_gen_settings).index + global.active_surface_index = game.create_surface("chronosphere" .. objective.chronojumps, Chrono.get_map_gen_settings()).index local surface = game.surfaces[global.active_surface_index] local planet = nil if choice then - Planets.determine_planet(choice) + Planets.determine_planet(choice, 1) planet = global.objective.planet end generate_overworld(surface, planet) @@ -570,15 +473,9 @@ local function on_entity_died(event) end end - --on_player_mined_entity(event) - --if not event.entity.valid then return end - --end - local function on_research_finished(event) - event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 100 + global.objective.invupgradetier * 5 Event_functions.flamer_nerfs() - if not event.research.force.technologies["steel-axe"].researched then return end - event.research.force.manual_mining_speed_modifier = 1 + game.forces.player.mining_drill_productivity_bonus * 4 + Event_functions.mining_buffs() end local function on_player_driving_changed_state(event) @@ -642,7 +539,6 @@ event.add(defines.events.on_pre_player_left_game, on_pre_player_left_game) event.add(defines.events.on_pre_player_mined_item, pre_player_mined_item) event.add(defines.events.on_player_mined_entity, on_player_mined_entity) event.add(defines.events.on_research_finished, on_research_finished) ---event.add(defines.events.on_market_item_purchased, on_market_item_purchased) event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state) event.add(defines.events.on_player_changed_position, on_player_changed_position) diff --git a/maps/chronosphere/ores.lua b/maps/chronosphere/ores.lua index 01e09609..ad69bed9 100644 --- a/maps/chronosphere/ores.lua +++ b/maps/chronosphere/ores.lua @@ -103,7 +103,7 @@ local function spawn_ore_vein(surface, pos, planet) if choice == "crude-oil" then surface.create_entity({name = "crude-oil", position = pos, amount = get_oil_amount(pos, oil.w, planet[1].ore_richness.factor) }) else - draw_noise_ore_patch(pos, choice, surface, get_size_of_ore(choice, planet), richness, mixed) + draw_noise_ore_patch(pos, choice, surface, get_size_of_ore(choice, planet), richness / 2, mixed) end --end end diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index b1135e7d..cef95bce 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -364,7 +364,7 @@ end local function process_river_position(p, seed, tiles, entities, treasure, planet) local biters = planet[1].name.biters - local richness = math_random(50 + 20 * global.objective.chronojumps, 100 + 20 * global.objective.chronojumps) * planet[1].ore_richness.factor + local richness = math_random(50 + 20 * global.objective.chronojumps, 100 + 20 * global.objective.chronojumps) * planet[1].ore_richness.factor * 0.5 local iron_size = get_size_of_ore("iron-ore", planet) * 3 local copper_size = get_size_of_ore("copper-ore", planet) * 3 local stone_size = get_size_of_ore("stone", planet) * 3 @@ -988,6 +988,7 @@ end local function on_chunk_generated(event) if string.sub(event.surface.name, 0, 12) ~= "chronosphere" then return end + if event.surface.index == global.objective.nextsurface then return end process_chunk(event.surface, event.area.left_top) --global.chunk_queue[#global.chunk_queue + 1] = {left_top = {x = event.area.left_top.x, y = event.area.left_top.y}, surface_index = event.surface.index} end diff --git a/maps/chronosphere/tick_functions.lua b/maps/chronosphere/tick_functions.lua index 59797dd0..714a8dec 100644 --- a/maps/chronosphere/tick_functions.lua +++ b/maps/chronosphere/tick_functions.lua @@ -5,23 +5,24 @@ local math_floor = math.floor function Public_tick.check_chronoprogress() local objective = global.objective + local map_gen_settings = Public_tick.get_map_gen_settings() --game.print(objective.chronotimer) if objective.planet[1].name.id == 19 then if objective.passivetimer == 10 then - game.print("Comfylatron: We have a problem! We got disrupted in mid-jump, only part of energy got used, and here we landed. It might have been a trap!", {r=0.98, g=0.66, b=0.22}) - game.print("Comfylatron: My analysis says that charging needs full energy reset to work again, so we are stuck there until next full jump.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_danger1"}, {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_danger2"}, {r=0.98, g=0.66, b=0.22}) elseif objective.passivetimer == 25 then - game.print("Robot voice: INTRUDER ALERT! Lifeforms detected! Must eliminate!", {r=0.98, g=0, b=0}) + game.print({"chronosphere.message_danger3"}, {r=0.98, g=0, b=0}) elseif objective.passivetimer == 30 then - game.print("Robot voice: Nuclear missiles armed, launch countdown enabled.", {r=0.98, g=0, b=0}) + game.print({"chronosphere.message_danger4"}, {r=0.98, g=0, b=0}) end end if objective.chronotimer == objective.chrononeeds - 180 then - game.print("Comfylatron: Acumulator charging disabled, 180 seconds countdown to jump!", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_jump180"}, {r=0.98, g=0.66, b=0.22}) elseif objective.chronotimer == objective.chrononeeds - 60 then - game.print("Comfylatron: ChronoTrain nearly charged! Grab what you can, we leaving in 60 seconds!", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_jump60"}, {r=0.98, g=0.66, b=0.22}) elseif objective.chronotimer == objective.chrononeeds - 30 then - game.print("Comfylatron: You better hurry up! 30 seconds remaining!", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_jump30"}, {r=0.98, g=0.66, b=0.22}) elseif objective.chronotimer >= objective.chrononeeds - 10 and objective.chrononeeds - objective.chronotimer > 0 then game.print("Comfylatron: Jump in " .. objective.chrononeeds - objective.chronotimer .. " seconds!", {r=0.98, g=0.66, b=0.22}) end @@ -85,11 +86,19 @@ function Public_tick.move_items() local items = input_inventory.get_contents() for item, count in pairs(items) do - local inserted = output_inventory.insert({name = item, count = count}) - if inserted > 0 then - local removed = input_inventory.remove({name = item, count = inserted}) - end + if item == "modular-armor" or item == "power-armor" or item == "power-armor-mk2" then + --log("can't move armors") + else + local inserted = output_inventory.insert({name = item, count = count}) + if inserted > 0 then + local removed = input_inventory.remove({name = item, count = inserted}) + end + end end + -- local items = {} + -- for ii = 1, #input_inventory, 1 do + -- items[#items + 1] = input_inventory[ii] + -- end end end @@ -105,15 +114,19 @@ function Public_tick.output_items() inv.sort_and_merge() local items = inv.get_contents() for item, count in pairs(items) do - local inserted = nil - if i <= 2 then - inserted = global.locomotive_cargo[2].get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) - else - inserted = global.locomotive_cargo[3].get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count}) - end - if inserted > 0 then - local removed = inv.remove({name = item, count = inserted}) - end + if item == "modular-armor" or item == "power-armor" or item == "power-armor-mk2" then + --log("can't move armors") + else + local inserted = nil + if i <= 2 then + inserted = global.locomotive_cargo[2].get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count, grid = item.grid}) + else + inserted = global.locomotive_cargo[3].get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count, grid = item.grid}) + end + if inserted > 0 then + local removed = inv.remove({name = item, count = inserted}) + end + end end end end @@ -168,7 +181,7 @@ local function launch_nukes() if objective.dangers[i].destroyed == false then local fake_shooter = surface.create_entity({name = "character", position = objective.dangers[i].silo.position, force = "enemy"}) surface.create_entity({name = "atomic-rocket", position = objective.dangers[i].silo.position, force = "enemy", speed = 1, max_range = 800, target = global.locomotive, source = fake_shooter}) - game.print("Warning: Nuclear missile launched.", {r=0.98, g=0, b=0}) + game.print({"chronosphere.message_nuke"}, {r=0.98, g=0, b=0}) end end end @@ -205,7 +218,7 @@ end function Public_tick.offline_players() local objective = global.objective - if objective.chronotimer > objective.chrononeeds - 182 then return end + if objective.chronotimer > objective.chrononeeds - 182 or objective.passivetimer < 30 then return end local current_tick = game.tick local players = objective.offline_players local surface = game.surfaces[global.active_surface_index] @@ -217,30 +230,40 @@ function Public_tick.offline_players() --game.print("deleting already online character from list") players[i] = nil else - if players[i] and players[i].tick < game.tick - 54000 then + if players[i] and players[i].tick < game.tick - 540 then --log("spawning corpse") local player_inv = {} + local items = {} player_inv[1] = game.players[players[i].index].get_inventory(defines.inventory.character_main) player_inv[2] = game.players[players[i].index].get_inventory(defines.inventory.character_armor) player_inv[3] = game.players[players[i].index].get_inventory(defines.inventory.character_guns) player_inv[4] = game.players[players[i].index].get_inventory(defines.inventory.character_ammo) player_inv[5] = game.players[players[i].index].get_inventory(defines.inventory.character_trash) - game.print("Comfylatron: Offline player had an accident, and dropped his items on ground around locomotive.") - local e = surface.create_entity({name = "character", position = game.forces.player.get_spawn_position(surface), force = "player"}) + game.print({"chronosphere.message_accident"}, {r=0.98, g=0.66, b=0.22}) + local e = surface.create_entity({name = "character", position = game.forces.player.get_spawn_position(surface), force = "neutral"}) local inv = e.get_inventory(defines.inventory.character_main) - for i = 1, 5, 1 do - if player_inv[i].valid then - local items = player_inv[i].get_contents() - for item, count in pairs(items) do - inv.insert({name = item, count = count}) - player_inv[i].remove({name = item, count = count}) + for ii = 1, 5, 1 do + if player_inv[ii].valid then + for iii = 1, #player_inv[ii], 1 do + if player_inv[ii][iii].valid then + items[#items + 1] = player_inv[ii][iii] + end + end + end + end + if #items > 0 then + for item = 1, #items, 1 do + if items[item].valid then + inv.insert(items[item]) end - else - --log("invalid") - --game.print("invalid") end end e.die("neutral") + for ii = 1, 5, 1 do + if player_inv[ii].valid then + player_inv[ii].clear() + end + end players[i] = nil else --game.print("keeping player in list") diff --git a/maps/chronosphere/upgrades.lua b/maps/chronosphere/upgrades.lua index afb7e7df..7e32363b 100644 --- a/maps/chronosphere/upgrades.lua +++ b/maps/chronosphere/upgrades.lua @@ -30,8 +30,8 @@ local function check_upgrade_hp() local coincost = math_floor(500 * (1 + objective.hpupgradetier /2)) if countcoins >= coincost and count2 >= 1500 and objective.hpupgradetier < 36 then inv.remove({name = "coin", count = coincost}) - inv.remove({name = "copper-plate", count = 3000}) - game.print("Comfylatron: Train's max HP was upgraded.", {r=0.98, g=0.66, b=0.22}) + inv.remove({name = "copper-plate", count = 1500}) + game.print({"chronosphere.message_upgrade_hp"}, {r=0.98, g=0.66, b=0.22}) objective.hpupgradetier = objective.hpupgradetier + 1 objective.max_health = 10000 + 2500 * objective.hpupgradetier rendering.set_text(global.objective.health_text, "HP: " .. global.objective.health .. " / " .. global.objective.max_health) @@ -48,7 +48,7 @@ local function check_upgrade_filter() if countcoins >= 5000 and count2 >= 2000 and objective.filterupgradetier < 9 and objective.chronojumps >= (objective.filterupgradetier + 1) * 3 then inv.remove({name = "coin", count = 5000}) inv.remove({name = "electronic-circuit", count = 2000}) - game.print("Comfylatron: Train's pollution filter was upgraded.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_upgrade_filter"}, {r=0.98, g=0.66, b=0.22}) objective.filterupgradetier = objective.filterupgradetier + 1 end end @@ -64,7 +64,7 @@ local function check_upgrade_acu() if countcoins >= coincost and count2 >= 200 and objective.acuupgradetier < 24 then inv.remove({name = "coin", count = coincost}) inv.remove({name = "battery", count = 200}) - game.print("Comfylatron: Train's acumulator capacity was upgraded.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_upgrade_acu"}, {r=0.98, g=0.66, b=0.22}) objective.acuupgradetier = objective.acuupgradetier + 1 spawn_acumulators() end @@ -81,7 +81,7 @@ local function check_upgrade_pickup() if countcoins >= coincost and count2 >= 400 and objective.pickupupgradetier < 4 then inv.remove({name = "coin", count = coincost}) inv.remove({name = "long-handed-inserter", count = 400}) - game.print("Comfylatron: Players now have additional red inserter installed on shoulders, increasing their item pickup range.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_upgrade_pickup"}, {r=0.98, g=0.66, b=0.22}) objective.pickupupgradetier = objective.pickupupgradetier + 1 game.forces.player.character_loot_pickup_distance_bonus = game.forces.player.character_loot_pickup_distance_bonus + 1 end @@ -108,7 +108,7 @@ local function check_upgrade_inv() if countcoins >= coincost and count2 >= 250 and objective.invupgradetier < 4 and objective.chronojumps >= (objective.invupgradetier + 1) * 5 then inv.remove({name = "coin", count = coincost}) inv.remove({name = item, count = 250}) - game.print("Comfylatron: Players now can carry more trash in their unsorted inventories.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_upgrade_inventory"}, {r=0.98, g=0.66, b=0.22}) objective.invupgradetier = objective.invupgradetier + 1 game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + 10 end @@ -126,7 +126,7 @@ local function check_upgrade_tools() if countcoins >= coincost and count2 >= toolscost and objective.toolsupgradetier < 4 then inv.remove({name = "coin", count = coincost}) inv.remove({name = "repair-pack", count = toolscost}) - game.print("Comfylatron: Train now gets repaired with additional repair kit at once.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_upgrade_repair"}, {r=0.98, g=0.66, b=0.22}) objective.toolsupgradetier = objective.toolsupgradetier + 1 end end @@ -141,7 +141,7 @@ local function check_upgrade_water() if countcoins >= 2000 and count2 >= 500 and objective.waterupgradetier < 1 then inv.remove({name = "coin", count = 2000}) inv.remove({name = "pipe", count = 500}) - game.print("Comfylatron: Train now has piping system for additional water sources.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_upgrade_water"}, {r=0.98, g=0.66, b=0.22}) objective.waterupgradetier = objective.waterupgradetier + 1 local positions = {{28,66},{28,-62},{-29,66},{-29,-62}} for i = 1, 4, 1 do @@ -162,7 +162,7 @@ local function check_upgrade_out() if countcoins >= 2000 and count2 >= 100 and objective.outupgradetier < 1 then inv.remove({name = "coin", count = 2000}) inv.remove({name = "fast-inserter", count = 100}) - game.print("Comfylatron: Train now has output chests.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_upgrade_out"}, {r=0.98, g=0.66, b=0.22}) objective.outupgradetier = objective.outupgradetier + 1 local positions = {{-16,-62},{15,-62},{-16,66},{15,66}} local out = {} @@ -206,47 +206,43 @@ local function check_upgrade_box() if countcoins >= 5000 and count2 >= 250 and objective.boxupgradetier < 4 and objective.chronojumps >= (objective.boxupgradetier + 1) * 5 then inv.remove({name = "coin", count = 5000}) inv.remove({name = item, count = 250}) - game.print("Comfylatron: Cargo wagons now have enlargened storage.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_upgrade_storage"}, {r=0.98, g=0.66, b=0.22}) objective.boxupgradetier = objective.boxupgradetier + 1 local chests = {} - local positions = { - [1] = {x = {-33, 32}, y = {-189, -127, -61, 1, 67, 129}} - } + local positions = {x = {-33, 32}, y = {-189, -127, -61, 1, 67, 129}} for i = 1, 58, 1 do for ii = 1, 6, 1 do if objective.boxupgradetier == 1 then - chests[#chests + 1] = {name = "wooden-chest", position = {x = positions[1].x[1] ,y = positions[1].y[ii] + i}, force = "player"} - chests[#chests + 1] = {name = "wooden-chest", position = {x = positions[1].x[2] ,y = positions[1].y[ii] + i}, force = "player"} + chests[#chests + 1] = {entity = {name = "wooden-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player"}, old = "none"} + chests[#chests + 1] = {entity = {name = "wooden-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player"}, old = "none"} elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {name = "iron-chest", position = {x = positions[1].x[1] ,y = positions[1].y[ii] + i}, force = "player"} - chests[#chests + 1] = {name = "iron-chest", position = {x = positions[1].x[2] ,y = positions[1].y[ii] + i}, force = "player"} + chests[#chests + 1] = {entity = {name = "iron-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "wood"} + chests[#chests + 1] = {entity = {name = "iron-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "wood"} elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {name = "steel-chest", position = {x = positions[1].x[1] ,y = positions[1].y[ii] + i}, force = "player"} - chests[#chests + 1] = {name = "steel-chest", position = {x = positions[1].x[2] ,y = positions[1].y[ii] + i}, force = "player"} + chests[#chests + 1] = {entity = {name = "steel-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "iron"} + chests[#chests + 1] = {entity = {name = "steel-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "iron"} elseif objective.boxupgradetier == 4 then - chests[#chests + 1] = {name = "logistic-chest-storage", position = {x = positions[1].x[1] ,y = positions[1].y[ii] + i}, force = "player"} - chests[#chests + 1] = {name = "logistic-chest-storage", position = {x = positions[1].x[2] ,y = positions[1].y[ii] + i}, force = "player"} + chests[#chests + 1] = {entity = {name = "logistic-chest-storage", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "steel"} + chests[#chests + 1] = {entity = {name = "logistic-chest-storage", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "steel"} end end end local surface = game.surfaces["cargo_wagon"] for i = 1, #chests, 1 do if objective.boxupgradetier == 1 then - surface.set_tiles({{name = "tutorial-grid", position = chests[i].position}}) + surface.set_tiles({{name = "tutorial-grid", position = chests[i].entity.position}}) end - local e = surface.create_entity(chests[i]) local old = nil - if e.name == "iron-chest" then old = surface.find_entity("wooden-chest", e.position) - elseif e.name == "steel-chest" then old = surface.find_entity("iron-chest", e.position) - elseif e.name == "logistic-chest-storage" then old = surface.find_entity("steel-chest", e.position) + local oldpos = {x = chests[i].entity.position.x + 0.5, y = chests[i].entity.position.y + 0.5} + if chests[i].old == "wood" then old = surface.find_entity("wooden-chest", oldpos) + elseif chests[i].old == "iron" then old = surface.find_entity("iron-chest", oldpos) + elseif chests[i].old == "steel" then old = surface.find_entity("steel-chest", oldpos) end if old then - local items = old.get_inventory(defines.inventory.chest).get_contents() - for item, count in pairs(items) do - e.insert({name = item, count = count}) - end - old.destroy() + old.minable = true + old.destructible = true end + local e = surface.create_entity(chests[i].entity) e.destructible = false e.minable = false end @@ -263,7 +259,7 @@ local function check_poisondefense() if countcoins >= 1000 and count2 >= 50 and objective.poisondefense < 4 then inv.remove({name = "coin", count = 1000}) inv.remove({name = "poison-capsule", count = 50}) - game.print("Comfylatron: I don't believe in your defense skills. I equipped train with poison defense.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_upgrade_poison"}, {r=0.98, g=0.66, b=0.22}) objective.poisondefense = objective.poisondefense + 1 end end @@ -288,7 +284,7 @@ local function check_upgrade_computer() inv.remove({name = "coin", count = 5000}) inv.remove({name = "advanced-circuit", count = 1000}) inv.remove({name = "copper-plate", count = 2000}) - game.print("Comfylatron: Thanks for fixing train navigation. I can now get us rid of very poor worlds. It will still need more work though.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_quest2"}, {r=0.98, g=0.66, b=0.22}) objective.computermessage = 2 objective.computerupgrade = objective.computerupgrade + 1 elseif countcoins >= 10000 and count3 >= 1000 and count7 >= 1 and objective.computerupgrade == 1 and objective.chronojumps >= 20 and objective.computermessage == 3 then @@ -297,7 +293,7 @@ local function check_upgrade_computer() inv.remove({name = "nuclear-reactor", count = 1}) objective.computermessage = 4 objective.computerupgrade = objective.computerupgrade + 1 - game.print("Comfylatron: Perfect! Now we have train reactor and even better destination precision. I will get to you later what still needs to be done.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_quest4"}, {r=0.98, g=0.66, b=0.22}) elseif objective.computerupgrade == 2 and objective.chronojumps >= 25 and objective.computermessage == 5 then if countcoins >= 2000 and count4 >= 100 and count5 >= 100 and count6 >= 50 and objective.computerparts < 10 then inv.remove({name = "coin", count = 2000}) @@ -308,12 +304,12 @@ local function check_upgrade_computer() if objective.computerparts < 10 then game.print("Comfylatron: That's another processor part done! I still need " .. 10 - objective.computerparts .. " more of those parts.", {r=0.98, g=0.66, b=0.22}) else - game.print("Comfylatron: And this was last part of cpu brain done. Now we just need to synchronize our time correctly and we are done! Bring me satellite and rocket silo.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_quest6"}, {r=0.98, g=0.66, b=0.22}) end elseif objective.computerparts == 10 and count9 >= 1 and count10 >= 1 then inv.remove({name = "satellite", count = 1 }) inv.remove({name = "rocket-silo", count = 1 }) - game.print("Comfylatron: Time synchronized. Calculating time and space destination. Success. Jump once more and let me deliver the fish finally. This trip is getting long.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_quest7"}, {r=0.98, g=0.66, b=0.22}) objective.computermessage = 6 objective.computerupgrade = objective.computerupgrade + 1 end @@ -342,7 +338,7 @@ local function check_win() for _, player in pairs(game.connected_players) do player.play_sound{path="utility/game_won", volume_modifier=0.85} end - local message = "Comfylatron: Thank you with helping me on this delivery. It was tough one. I hope, that now, when all biters are dead, fish will be safe here forever...after all, we delivered " .. objective.mainscore .. " of them fishies." + local message = {"chronosphere.message_game_won1"} .. "after all, we delivered " .. objective.mainscore .. " of them fishies." game.print(message, {r=0.98, g=0.66, b=0.22}) Server.to_discord_embed(message) end @@ -364,7 +360,7 @@ local function check_mk2_buy() inv.remove({name = "railgun-dart", count = 300}) inv.remove({name = "power-armor", count = 1}) inv.insert({name = "power-armor-mk2", count = 1}) - game.print("Comfylatron: I upgraded one armor to mk2.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_upgrade_mk2"}, {r=0.98, g=0.66, b=0.22}) end end end @@ -381,7 +377,7 @@ local function check_fusion_buy() inv.remove({name = "railgun-dart", count = 200}) inv.remove({name = "solar-panel-equipment", count = 16}) inv.insert({name = "fusion-reactor-equipment", count = 1}) - game.print("Comfylatron: One personal fusion reactor ready.", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_upgrade_fusion"}, {r=0.98, g=0.66, b=0.22}) end end end @@ -442,7 +438,7 @@ function Public.trigger_poison() objective.poisontimeout = 120 local objs = {global.locomotive, global.locomotive_cargo[1], global.locomotive_cargo[2], global.locomotive_cargo[3]} local surface = objective.surface - game.print("Comfylatron: Triggering poison defense. Let's kill everything!", {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_poison_defense"}, {r=0.98, g=0.66, b=0.22}) for i = 1, 4, 1 do surface.create_entity({name = "poison-capsule", position = objs[i].position, force = "player", target = objs[i], speed = 1 }) end From 75d5fe6342a63a2c2985cdcacde079f0e82d02f0 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sat, 14 Mar 2020 09:12:49 +0100 Subject: [PATCH 30/70] test update --- maps/chronosphere/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index a71e4482..34b24f93 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -253,7 +253,7 @@ local function chronojump(choice) local surface = game.surfaces[global.active_surface_index] local planet = nil if choice then - Planets.determine_planet(choice, 1) + Planets.determine_planet(choice) planet = global.objective.planet end generate_overworld(surface, planet) From 9e2537a46884c921f209fca720a00ac684e3f789 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sat, 14 Mar 2020 12:01:17 +0100 Subject: [PATCH 31/70] final inventory handling fixes --- maps/chronosphere/chrono.lua | 47 +++++++++++++++++--------- maps/chronosphere/locomotive.lua | 12 +++---- maps/chronosphere/main.lua | 13 ++------ maps/chronosphere/tick_functions.lua | 49 +++++++++------------------- 4 files changed, 55 insertions(+), 66 deletions(-) diff --git a/maps/chronosphere/chrono.lua b/maps/chronosphere/chrono.lua index e2dce44b..09e042e4 100644 --- a/maps/chronosphere/chrono.lua +++ b/maps/chronosphere/chrono.lua @@ -178,22 +178,39 @@ function Public_chrono.process_jump(choice) end end -function Public_chrono.get_wagons() - local inventories = { - one = global.locomotive_cargo[1].get_inventory(defines.inventory.cargo_wagon), - two = global.locomotive_cargo[2].get_inventory(defines.inventory.cargo_wagon), - three = global.locomotive_cargo[3].get_inventory(defines.inventory.cargo_wagon) - } - inventories.one.sort_and_merge() - --inventories.two.sort_and_merge() +function Public_chrono.get_wagons(start) local wagons = {} - wagons[1] = {inventory = inventories.one.get_contents(), bar = inventories.one.get_bar(), filters = {}} - wagons[2] = {inventory = inventories.two.get_contents(), bar = inventories.two.get_bar(), filters = {}} - wagons[3] = {inventory = inventories.three.get_contents(), bar = inventories.three.get_bar(), filters = {}} - for i = 1, 40, 1 do - wagons[1].filters[i] = inventories.one.get_filter(i) - wagons[2].filters[i] = inventories.two.get_filter(i) - wagons[3].filters[i] = inventories.three.get_filter(i) + wagons[1] = {inventory = {}, bar = 0, filters = {}} + wagons[2] = {inventory = {}, bar = 0, filters = {}} + wagons[3] = {inventory = {}, bar = 0, filters = {}} + if start then + wagons[1].inventory[1] = {name = "raw-fish", count = 100} + for i = 2, 3, 1 do + wagons[i].inventory[1] = {name = 'firearm-magazine', count = 16} + wagons[i].inventory[2] = {name = 'iron-plate', count = 16} + wagons[i].inventory[3] = {name = 'wood', count = 16} + wagons[i].inventory[4] = {name = 'burner-mining-drill', count = 8} + end + else + local inventories = { + one = global.locomotive_cargo[1].get_inventory(defines.inventory.cargo_wagon), + two = global.locomotive_cargo[2].get_inventory(defines.inventory.cargo_wagon), + three = global.locomotive_cargo[3].get_inventory(defines.inventory.cargo_wagon) + } + inventories.one.sort_and_merge() + --inventories.two.sort_and_merge() + + wagons[1].bar = inventories.one.get_bar() + wagons[2].bar = inventories.two.get_bar() + wagons[3].bar = inventories.three.get_bar() + for i = 1, 40, 1 do + wagons[1].filters[i] = inventories.one.get_filter(i) + wagons[1].inventory[i] = inventories.one[i] + wagons[2].filters[i] = inventories.two.get_filter(i) + wagons[2].inventory[i] = inventories.two[i] + wagons[3].filters[i] = inventories.three.get_filter(i) + wagons[3].inventory[i] = inventories.three[i] + end end return wagons end diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index e4097f8b..962d661a 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -19,12 +19,12 @@ function Public.locomotive_spawn(surface, position, wagons) for i = 1, 3, 1 do global.locomotive_cargo[i] = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + math_floor((i - 1) * 6.5)}, force = "player"}) local inv = global.locomotive_cargo[i].get_inventory(defines.inventory.cargo_wagon) - for item, count in pairs(wagons[i].inventory) do - inv.insert({name = item, count = count}) - if wagons[i].bar > 0 then inv.set_bar(wagons[i].bar) end - for ii = 1, 40, 1 do - inv.set_filter(ii, wagons[i].filters[ii]) - end + if wagons[i].bar > 0 then inv.set_bar(wagons[i].bar) end + for ii = 1, 40, 1 do + inv.set_filter(ii, wagons[i].filters[ii]) + if wagons[i].inventory[ii] then + inv.insert(wagons[i].inventory[ii]) + end end global.locomotive_cargo[i].minable = false end diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 34b24f93..c09bb8ca 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -38,7 +38,6 @@ global.comfylatron = nil global.lab_cells = {} local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 32, ['grenade'] = 4, ['raw-fish'] = 4, ['rail'] = 16, ['wood'] = 16} -local starting_cargo = {['firearm-magazine'] = 16, ['iron-plate'] = 16, ['wood'] = 16, ['burner-mining-drill'] = 8} local function generate_overworld(surface, optplanet) Planets.determine_planet(optplanet) @@ -156,15 +155,7 @@ local function reset_map() Chrono.restart_settings() game.forces.player.set_spawn_position({12, 10}, surface) - local wagons = {} - wagons[1] = {inventory = {["raw-fish"] = 100}, bar = 0, filters = {}} - wagons[2] = {inventory = starting_cargo, bar = 0, filters = {}} - wagons[3] = {inventory = starting_cargo, bar = 0, filters = {}} - for i = 1, 40, 1 do - wagons[2].filters[i] = nil - wagons[3].filters[i] = nil - end - Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, wagons) + Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, Chrono.get_wagons(true)) render_train_hp() game.reset_time_played() Locomotive.create_wagon_room() @@ -260,7 +251,7 @@ local function chronojump(choice) game.forces.player.set_spawn_position({12, 10}, surface) - Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, Chrono.get_wagons()) + Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, Chrono.get_wagons(false)) render_train_hp() game.delete_surface(oldsurface) Chrono.post_jump() diff --git a/maps/chronosphere/tick_functions.lua b/maps/chronosphere/tick_functions.lua index 2546cd9c..1bd7f73a 100644 --- a/maps/chronosphere/tick_functions.lua +++ b/maps/chronosphere/tick_functions.lua @@ -7,8 +7,6 @@ local math_min = math.min function Public_tick.check_chronoprogress() local objective = global.objective - local map_gen_settings = Public_tick.get_map_gen_settings() - --game.print(objective.chronotimer) if objective.planet[1].name.id == 19 then if objective.passivetimer == 10 then game.print({"chronosphere.message_danger1"}, {r=0.98, g=0.66, b=0.22}) @@ -49,7 +47,6 @@ function Public_tick.charge_chronosphere() acus[i].energy = acus[i].energy - 3000000 objective.chronotimer = objective.chronotimer + 1 game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (10 + 2 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1)) * global.difficulty_vote_value) - --log("energy charged from acu") end end end @@ -85,22 +82,13 @@ function Public_tick.move_items() local input_inventory = input[i].get_inventory(defines.inventory.chest) local output_inventory = output[i].get_inventory(defines.inventory.chest) input_inventory.sort_and_merge() - local items = input_inventory.get_contents() - - for item, count in pairs(items) do - if item == "modular-armor" or item == "power-armor" or item == "power-armor-mk2" then - --log("can't move armors") - else - local inserted = output_inventory.insert({name = item, count = count}) - if inserted > 0 then - local removed = input_inventory.remove({name = item, count = inserted}) - end - end + output_inventory.sort_and_merge() + for ii = 1, #input_inventory, 1 do + if input_inventory[ii].valid_for_read then + local count = output_inventory.insert(input_inventory[ii]) + input_inventory[ii].count = input_inventory[ii].count - count + end end - -- local items = {} - -- for ii = 1, #input_inventory, 1 do - -- items[#items + 1] = input_inventory[ii] - -- end end end @@ -110,25 +98,19 @@ function Public_tick.output_items() if not global.locomotive_cargo[2] then return end if not global.locomotive_cargo[3] then return end if global.objective.outupgradetier ~= 1 then return end + local wagon = { + [1] = global.locomotive_cargo[2].get_inventory(defines.inventory.cargo_wagon), + [2] = global.locomotive_cargo[3].get_inventory(defines.inventory.cargo_wagon) + } for i = 1, 4, 1 do if not global.outchests[i].valid then return end local inv = global.outchests[i].get_inventory(defines.inventory.chest) inv.sort_and_merge() - local items = inv.get_contents() - for item, count in pairs(items) do - if item == "modular-armor" or item == "power-armor" or item == "power-armor-mk2" then - --log("can't move armors") - else - local inserted = nil - if i <= 2 then - inserted = global.locomotive_cargo[2].get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count, grid = item.grid}) - else - inserted = global.locomotive_cargo[3].get_inventory(defines.inventory.cargo_wagon).insert({name = item, count = count, grid = item.grid}) - end - if inserted > 0 then - local removed = inv.remove({name = item, count = inserted}) - end - end + for ii = 1, #inv, 1 do + if inv[ii].valid_for_read then + local count = wagon[math_ceil(i/2)].insert(inv[ii]) + inv[ii].count = inv[ii].count - count + end end end end @@ -254,7 +236,6 @@ function Public_tick.offline_players() end players[i] = nil else - --game.print("keeping player in list") later[#later + 1] = players[i] end end From dc8bd97058868c84eb7cf287f39ab741bbb8cdb7 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Mon, 16 Mar 2020 21:55:08 +0100 Subject: [PATCH 32/70] small update --- commands/misc.lua | 4 +++- maps/chronosphere/main.lua | 8 -------- maps/chronosphere/terrain.lua | 2 -- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/commands/misc.lua b/commands/misc.lua index c79471cd..4e23bf86 100644 --- a/commands/misc.lua +++ b/commands/misc.lua @@ -298,7 +298,9 @@ commands.add_command( local radius = {{x = (pos.x + -param), y = (pos.y + -param)}, {x = (pos.x + param), y = (pos.y + param)}} for _, entity in pairs(player.surface.find_entities_filtered{area = radius, type = "corpse"}) do - entity.destroy() + if entity.corpse_expires then + entity.destroy() + end end player.print("Cleared biter-corpses.", Color.success) end) diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index c09bb8ca..1a76bbb4 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -1,9 +1,6 @@ -- chronosphere -- -require "functions.soft_reset" -require "functions.basic_markets" require "modules.difficulty_vote" - require "modules.biters_yield_coins" require "modules.no_deconstruction_of_neutral_entities" --require "modules.no_solar" @@ -24,13 +21,10 @@ local Tick_functions = require "maps.chronosphere.tick_functions" local Event_functions = require "maps.chronosphere.event_functions" local Chrono = require "maps.chronosphere.chrono" local Locomotive = require "maps.chronosphere.locomotive" ---local Modifier = require "player_modifiers" local update_gui = require "maps.chronosphere.gui" local math_random = math.random local math_floor = math.floor local math_sqrt = math.sqrt ---local chests = {} ---local acus = {} global.objective = {} global.objective.config = {} global.flame_boots = {} @@ -132,7 +126,6 @@ local function reset_map() for _,player in pairs(game.players) do if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end end - global.chunk_queue = {} if game.surfaces["chronosphere"] then game.delete_surface(game.surfaces["chronosphere"]) end if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end --chests = {} @@ -525,7 +518,6 @@ event.on_nth_tick(2, tick) event.add(defines.events.on_entity_damaged, on_entity_damaged) event.add(defines.events.on_entity_died, on_entity_died) event.add(defines.events.on_player_joined_game, on_player_joined_game) -event.add(defines.events.on_player_left_game, on_player_left_game) event.add(defines.events.on_pre_player_left_game, on_pre_player_left_game) event.add(defines.events.on_pre_player_mined_item, pre_player_mined_item) event.add(defines.events.on_player_mined_entity, on_player_mined_entity) diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index cef95bce..b76884fe 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -990,9 +990,7 @@ local function on_chunk_generated(event) if string.sub(event.surface.name, 0, 12) ~= "chronosphere" then return end if event.surface.index == global.objective.nextsurface then return end process_chunk(event.surface, event.area.left_top) - --global.chunk_queue[#global.chunk_queue + 1] = {left_top = {x = event.area.left_top.x, y = event.area.left_top.y}, surface_index = event.surface.index} end local event = require 'utils.event' ---event.on_nth_tick(4, process_chunk_queue) event.add(defines.events.on_chunk_generated, on_chunk_generated) From dd56d048b1ab6247fc552121c0d1dec731cdbc5e Mon Sep 17 00:00:00 2001 From: hanakocz Date: Mon, 16 Mar 2020 22:51:39 +0100 Subject: [PATCH 33/70] repair fix --- maps/chronosphere/ores.lua | 2 +- maps/chronosphere/tick_functions.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/maps/chronosphere/ores.lua b/maps/chronosphere/ores.lua index ad69bed9..42d804cd 100644 --- a/maps/chronosphere/ores.lua +++ b/maps/chronosphere/ores.lua @@ -101,7 +101,7 @@ local function spawn_ore_vein(surface, pos, planet) --if surface.can_place_entity({name = choice, position = pos, amount = 1}) then if choice == "crude-oil" then - surface.create_entity({name = "crude-oil", position = pos, amount = get_oil_amount(pos, oil.w, planet[1].ore_richness.factor) }) + surface.create_entity({name = "crude-oil", position = pos, amount = get_oil_amount(pos, oil.w, planet[1].ore_richness.factor) / 2 }) else draw_noise_ore_patch(pos, choice, surface, get_size_of_ore(choice, planet), richness / 2, mixed) end diff --git a/maps/chronosphere/tick_functions.lua b/maps/chronosphere/tick_functions.lua index 1bd7f73a..3469600d 100644 --- a/maps/chronosphere/tick_functions.lua +++ b/maps/chronosphere/tick_functions.lua @@ -200,7 +200,7 @@ function Public_tick.offline_players() --game.print("deleting already online character from list") players[i] = nil else - if players[i] and players[i].tick < game.tick - 540 then + if players[i] and players[i].tick < game.tick - 54000 then --log("spawning corpse") local player_inv = {} local items = {} From 1e9b923b6905126bd566b4aab40b0d8ecd193741 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Mon, 16 Mar 2020 22:52:29 +0100 Subject: [PATCH 34/70] now real repair fix --- maps/chronosphere/tick_functions.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maps/chronosphere/tick_functions.lua b/maps/chronosphere/tick_functions.lua index 3469600d..b5beb73a 100644 --- a/maps/chronosphere/tick_functions.lua +++ b/maps/chronosphere/tick_functions.lua @@ -120,8 +120,9 @@ function Public_tick.repair_train() if not game.surfaces["cargo_wagon"] then return 0 end if objective.game_lost == true then return 0 end local count = 0 + local inv = global.upgradechest[1].get_inventory(defines.inventory.chest) if objective.health < objective.max_health then - count = global.upgradechest[1].get_inventory(defines.inventory.chest).get_item_count("repair-pack") + count = inv.get_item_count("repair-pack") count = math_min(count, objective.toolsupgradetier + 1, math_ceil((objective.max_health - objective.health) / 150)) if count > 0 then inv.remove({name = "repair-pack", count = count}) end end From 771e5e7aeb63ad0d6137c6fea970e02389a8792c Mon Sep 17 00:00:00 2001 From: hanakocz Date: Tue, 17 Mar 2020 04:07:33 +0100 Subject: [PATCH 35/70] Change comfy panel to allow multiple admin tabs --- comfy_panel/admin.lua | 2 +- comfy_panel/config.lua | 2 +- comfy_panel/group.lua | 2 +- comfy_panel/main.lua | 7 ++++--- comfy_panel/player_list.lua | 2 +- comfy_panel/poll.lua | 2 +- comfy_panel/score.lua | 2 +- maps/chronosphere/main.lua | 1 + modules/map_info.lua | 2 +- 9 files changed, 12 insertions(+), 10 deletions(-) diff --git a/comfy_panel/admin.lua b/comfy_panel/admin.lua index e0506045..ee0966f5 100644 --- a/comfy_panel/admin.lua +++ b/comfy_panel/admin.lua @@ -390,7 +390,7 @@ local function on_gui_selection_state_changed(event) end end -comfy_panel_tabs["Admin"] = create_admin_panel +comfy_panel_tabs["Admin"] = {gui = create_admin_panel, admin = true} diff --git a/comfy_panel/config.lua b/comfy_panel/config.lua index 22fcfc67..16352cfd 100644 --- a/comfy_panel/config.lua +++ b/comfy_panel/config.lua @@ -82,7 +82,7 @@ local function on_gui_click(event) end end -comfy_panel_tabs["Config"] = build_config_gui +comfy_panel_tabs["Config"] = {gui = build_config_gui, admin = false} local event = require 'utils.event' diff --git a/comfy_panel/group.lua b/comfy_panel/group.lua index 82f20c87..19b395ee 100644 --- a/comfy_panel/group.lua +++ b/comfy_panel/group.lua @@ -214,7 +214,7 @@ local function on_gui_click(event) end end -comfy_panel_tabs["Groups"] = build_group_gui +comfy_panel_tabs["Groups"] = {gui = build_group_gui, admin = false} local event = require 'utils.event' diff --git a/comfy_panel/main.lua b/comfy_panel/main.lua index 66142024..0c1f7c79 100644 --- a/comfy_panel/main.lua +++ b/comfy_panel/main.lua @@ -3,7 +3,8 @@ Comfy Panel To add a tab, insert into the "comfy_panel_tabs" table. -Example: comfy_panel_tabs["mapscores"] = draw_map_scores +Example: comfy_panel_tabs["mapscores"] = {gui = draw_map_scores, admin = false} +if admin = true, then tab is visible only for admins (usable for map-specific settings) draw_map_scores would be a function with the player and the frame as arguments @@ -62,7 +63,7 @@ local function main_frame(player) local tabbed_pane = frame.add({type = "tabbed-pane", name = "tabbed_pane"}) for name, func in pairs(tabs) do - if name == "Admin" then + if func.admin == true then if player.admin then local tab = tabbed_pane.add({type = "tab", caption = name}) local frame = tabbed_pane.add({type = "frame", name = name, direction = "vertical"}) @@ -142,4 +143,4 @@ end event.add(defines.events.on_player_joined_game, on_player_joined_game) event.add(defines.events.on_gui_click, on_gui_click) -return Public \ No newline at end of file +return Public diff --git a/comfy_panel/player_list.lua b/comfy_panel/player_list.lua index 1544b702..a6a20ede 100644 --- a/comfy_panel/player_list.lua +++ b/comfy_panel/player_list.lua @@ -388,7 +388,7 @@ local on_init = function() global.player_list.sorting_method = {} end -comfy_panel_tabs["Players"] = player_list_show +comfy_panel_tabs["Players"] = {gui = player_list_show, admin = false} event.on_init(on_init) event.add(defines.events.on_player_joined_game, on_player_joined_game) diff --git a/comfy_panel/poll.lua b/comfy_panel/poll.lua index 34fd21a5..6f6f0ecd 100644 --- a/comfy_panel/poll.lua +++ b/comfy_panel/poll.lua @@ -1297,6 +1297,6 @@ function Class.send_poll_result_to_discord(id) Server.to_discord_embed(message) end -comfy_panel_tabs["Polls"] = draw_main_frame +comfy_panel_tabs["Polls"] = {gui = draw_main_frame, admin = false} return Class diff --git a/comfy_panel/score.lua b/comfy_panel/score.lua index 6ec815c8..5cef514b 100644 --- a/comfy_panel/score.lua +++ b/comfy_panel/score.lua @@ -358,7 +358,7 @@ local function tick(event) refresh_score_full() end ]] -comfy_panel_tabs["Scoreboard"] = show_score +comfy_panel_tabs["Scoreboard"] = {gui = show_score, admin = false} --event.on_nth_tick(300, tick) event.add(defines.events.on_player_mined_entity, on_player_mined_entity) diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 1a76bbb4..b6c71b97 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -30,6 +30,7 @@ global.objective.config = {} global.flame_boots = {} global.comfylatron = nil global.lab_cells = {} +require "maps.chronosphere.config_tab" local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 32, ['grenade'] = 4, ['raw-fish'] = 4, ['rail'] = 16, ['wood'] = 16} diff --git a/modules/map_info.lua b/modules/map_info.lua index ce08da91..d5fb2556 100644 --- a/modules/map_info.lua +++ b/modules/map_info.lua @@ -104,7 +104,7 @@ local function on_gui_click(event) if event.element.name == "close_map_intro" then game.players[event.player_index].gui.left.comfy_panel.destroy() return end end -comfy_panel_tabs["Map Info"] = create_map_intro +comfy_panel_tabs["Map Info"] = {gui = create_map_intro, admin = false} local event = require 'utils.event' event.add(defines.events.on_player_joined_game, on_player_joined_game) From 8e3c8cc1eaab05c8092821c10a811bff0fdb2623 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Tue, 17 Mar 2020 21:36:00 +0100 Subject: [PATCH 36/70] mini fixes + new admin tab --- comfy_panel/main.lua | 4 +- control.lua | 4 +- maps/chronosphere/config_tab.lua | 97 ++++++++++++++++++++++++++++ maps/chronosphere/main.lua | 2 +- maps/chronosphere/terrain.lua | 8 +-- maps/chronosphere/tick_functions.lua | 8 ++- 6 files changed, 112 insertions(+), 11 deletions(-) create mode 100644 maps/chronosphere/config_tab.lua diff --git a/comfy_panel/main.lua b/comfy_panel/main.lua index 0c1f7c79..e3e1b014 100644 --- a/comfy_panel/main.lua +++ b/comfy_panel/main.lua @@ -36,13 +36,13 @@ end function Public.comfy_panel_get_active_frame(player) if not player.gui.left.comfy_panel then return false end if not player.gui.left.comfy_panel.tabbed_pane.selected_tab_index then return player.gui.left.comfy_panel.tabbed_pane.tabs[1].content end - return player.gui.left.comfy_panel.tabbed_pane.tabs[player.gui.left.comfy_panel.tabbed_pane.selected_tab_index].content + return player.gui.left.comfy_panel.tabbed_pane.tabs[player.gui.left.comfy_panel.tabbed_pane.selected_tab_index].content end function Public.comfy_panel_refresh_active_tab(player) local frame = Public.comfy_panel_get_active_frame(player) if not frame then return end - comfy_panel_tabs[frame.name](player, frame) + comfy_panel_tabs[frame.name].gui(player, frame) end local function top_button(player) diff --git a/control.lua b/control.lua index 6e640b29..38bfd29d 100644 --- a/control.lua +++ b/control.lua @@ -126,8 +126,8 @@ require "maps.chronosphere.main" --require "modules.trees_grow" --require "modules.trees_randomly_die" ---require "terrain_layouts.scrap_01" ---require "terrain_layouts.caves" +--require "terrain_layouts.scrap_01" +--require "terrain_layouts.caves" --require "terrain_layouts.cone_to_east" --require "terrain_layouts.biters_and_resources_east" ------ diff --git a/maps/chronosphere/config_tab.lua b/maps/chronosphere/config_tab.lua new file mode 100644 index 00000000..256d19ad --- /dev/null +++ b/maps/chronosphere/config_tab.lua @@ -0,0 +1,97 @@ +-- config tab for chronotrain-- + +local Tabs = require 'comfy_panel.main' + +local functions = { + ["comfy_panel_offline_accidents"] = function(event) + if game.players[event.player_index].admin then + if event.element.switch_state == "left" then + global.objective.config.offline_loot = true + else + global.objective.config.offline_loot = false + end + else + game.players[event.player_index].print("You are not admin!") + end + end, + + ["comfy_panel_danger_events"] = function(event) + if game.players[event.player_index].admin then + if event.element.switch_state == "left" then + global.objective.config.jumpfailure = true + else + global.objective.config.jumpfailure = false + end + else + game.players[event.player_index].print("You are not admin!") + end + end, +} + +local function add_switch(element, switch_state, name, description_main, description) + local t = element.add({type = "table", column_count = 5}) + local label = t.add({type = "label", caption = "ON"}) + label.style.padding = 0 + label.style.left_padding= 10 + label.style.font_color = {0.77, 0.77, 0.77} + local switch = t.add({type = "switch", name = name}) + switch.switch_state = switch_state + switch.style.padding = 0 + switch.style.margin = 0 + local label = t.add({type = "label", caption = "OFF"}) + label.style.padding = 0 + label.style.font_color = {0.70, 0.70, 0.70} + + local label = t.add({type = "label", caption = description_main}) + label.style.padding = 2 + label.style.left_padding= 10 + label.style.minimal_width = 120 + label.style.font = "heading-2" + label.style.font_color = {0.88, 0.88, 0.99} + + local label = t.add({type = "label", caption = description}) + label.style.padding = 2 + label.style.left_padding= 10 + label.style.single_line = false + label.style.font = "heading-3" + label.style.font_color = {0.85, 0.85, 0.85} +end + +local build_config_gui = (function (player, frame) + frame.clear() + + local line_elements = {} + local switch_label_elements = {} + local label_elements = {} + + line_elements[#line_elements + 1] = frame.add({type = "line"}) + + local switch_state = "right" + if global.objective.config.offline_loot then switch_state = "left" end + add_switch(frame, switch_state, "comfy_panel_offline_accidents", "Offline Accidents", "Disablesr enables dropping of inventory when player goes offline.\nTimer is 15 minutes.") + + line_elements[#line_elements + 1] = frame.add({type = "line"}) + + if global.auto_hotbar_enabled then + local switch_state = "right" + if global.objective.config.jumpfailure then switch_state = "left" end + add_switch(frame, switch_state, "comfy_panel_danger_events", "Dangerous Events", "Disables or enables dangerous event maps\n(they require at least 2-4 capable players to survive)") + line_elements[#line_elements + 1] = frame.add({type = "line"}) + end + +end) + +local function on_gui_click(event) + if not event.element then return end + if not event.element.valid then return end + if functions[event.element.name] then + functions[event.element.name](event) + return + end +end + +comfy_panel_tabs["ChronoTrain"] = {gui = build_config_gui, admin = true} + + +local event = require 'utils.event' +event.add(defines.events.on_gui_click, on_gui_click) diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index b6c71b97..ceb8581c 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -141,7 +141,7 @@ local function reset_map() global.active_surface_index = game.create_surface("chronosphere", Chrono.get_map_gen_settings()).index else game.forces.player.set_spawn_position({12, 10}, game.surfaces[global.active_surface_index]) - global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], map_gen_settings, starting_items).index + global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], Chrono.get_map_gen_settings(), starting_items).index end local surface = game.surfaces[global.active_surface_index] diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index b76884fe..6e28d794 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -286,7 +286,7 @@ local function process_rocky_position(p, seed, tiles, entities, treasure, planet end if math_abs(noise_large_caves) > 0.375 then tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,6) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,5) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end return end @@ -306,9 +306,9 @@ local function process_rocky_position(p, seed, tiles, entities, treasure, planet if small_caves > -0.25 and small_caves < 0.25 then tiles[#tiles + 1] = {name = "dirt-7", position = p} local roll = math_random(1,1000) - if roll > 800 then + if roll > 830 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} - elseif roll > 790 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then + elseif roll > 820 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p} else @@ -329,7 +329,7 @@ local function process_rocky_position(p, seed, tiles, entities, treasure, planet if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,100) > 40 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,100) > 50 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end diff --git a/maps/chronosphere/tick_functions.lua b/maps/chronosphere/tick_functions.lua index b5beb73a..334d91c2 100644 --- a/maps/chronosphere/tick_functions.lua +++ b/maps/chronosphere/tick_functions.lua @@ -210,7 +210,6 @@ function Public_tick.offline_players() player_inv[3] = game.players[players[i].index].get_inventory(defines.inventory.character_guns) player_inv[4] = game.players[players[i].index].get_inventory(defines.inventory.character_ammo) player_inv[5] = game.players[players[i].index].get_inventory(defines.inventory.character_trash) - game.print({"chronosphere.message_accident"}, {r=0.98, g=0.66, b=0.22}) local e = surface.create_entity({name = "character", position = game.forces.player.get_spawn_position(surface), force = "neutral"}) local inv = e.get_inventory(defines.inventory.character_main) for ii = 1, 5, 1 do @@ -228,8 +227,12 @@ function Public_tick.offline_players() inv.insert(items[item]) end end + game.print({"chronosphere.message_accident"}, {r=0.98, g=0.66, b=0.22}) + e.die("neutral") + else + e.destroy() end - e.die("neutral") + for ii = 1, 5, 1 do if player_inv[ii].valid then player_inv[ii].clear() @@ -247,6 +250,7 @@ function Public_tick.offline_players() players[#players + 1] = later[i] end end + objective.offline_players = players end end From 9dd516ef1c8f5c21354e2640b69369b5e507d5e9 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Fri, 20 Mar 2020 19:40:14 +0100 Subject: [PATCH 37/70] update, fixes --- control.lua | 3 +- maps/chronosphere/chrono.lua | 24 ++++++++++----- maps/chronosphere/chronobubles.lua | 2 +- maps/chronosphere/comfylatron.lua | 7 ++++- maps/chronosphere/event_functions.lua | 43 ++++++++++++++++----------- maps/chronosphere/gui.lua | 2 +- maps/chronosphere/main.lua | 10 ++----- maps/chronosphere/terrain.lua | 1 - maps/chronosphere/tick_functions.lua | 2 +- maps/chronosphere/upgrades.lua | 5 +++- 10 files changed, 60 insertions(+), 39 deletions(-) diff --git a/control.lua b/control.lua index 38bfd29d..16547a85 100644 --- a/control.lua +++ b/control.lua @@ -105,7 +105,6 @@ require "maps.chronosphere.main" --require "maps.tank_battles" --require "maps.spiral_troopers" --require "maps.refactor-io" ---require "maps.pitch_black.main" --require "maps.desert_oasis" --require "maps.lost_desert" --require "maps.stoneblock" @@ -116,6 +115,7 @@ require "maps.chronosphere.main" --require "maps.blue_beach" --require "maps.deep_jungle" --require "maps.rainbow_road" +--require "maps.pitch_black.main" --require "maps.cube" --require "maps.forest_circle" ----------------------------- @@ -127,6 +127,7 @@ require "maps.chronosphere.main" --require "modules.trees_randomly_die" --require "terrain_layouts.scrap_01" +--require "terrain_layouts.watery_world" --require "terrain_layouts.caves" --require "terrain_layouts.cone_to_east" --require "terrain_layouts.biters_and_resources_east" diff --git a/maps/chronosphere/chrono.lua b/maps/chronosphere/chrono.lua index 09e042e4..a8732cf2 100644 --- a/maps/chronosphere/chrono.lua +++ b/maps/chronosphere/chrono.lua @@ -2,6 +2,7 @@ local Public_chrono = {} local Server = require 'utils.server' local math_random = math.random +local math_max = math.max function Public_chrono.get_map_gen_settings() local seed = math_random(1, 1000000) @@ -92,12 +93,17 @@ function Public_chrono.restart_settings() game.forces.player.technologies["land-mine"].enabled = false game.forces.player.technologies["landfill"].enabled = false + game.forces.player.technologies["cliff-explosives"].enabled = false game.forces.player.technologies["fusion-reactor-equipment"].enabled = false game.forces.player.technologies["power-armor-mk2"].enabled = false game.forces.player.technologies["railway"].researched = true - game.forces.player.recipes["pistol"].enabled = false + + global.objective = objective end +function Public_chrono.init_setup() + game.forces.player.recipes["pistol"].enabled = false +end function Public_chrono.objective_died() local objective = global.objective @@ -150,11 +156,11 @@ function Public_chrono.process_jump(choice) local objective = global.objective local overstayed = overstayed() objective.chronojumps = objective.chronojumps + 1 - objective.chrononeeds = 2000 + 400 * objective.chronojumps + objective.chrononeeds = 2000 + 300 * objective.chronojumps objective.passivetimer = 0 objective.chronotimer = 0 - objective.danegrtimer = 1200 - local message = "Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. global.objective.chronojumps + objective.dangertimer = 1200 + local message = "Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. objective.chronojumps game.print(message, {r=0.98, g=0.66, b=0.22}) Server.to_discord_embed(message) @@ -176,6 +182,7 @@ function Public_chrono.process_jump(choice) if objective.planet[1].name.id == 19 then check_nuke_silos() end + global.objective = objective end function Public_chrono.get_wagons(start) @@ -190,7 +197,7 @@ function Public_chrono.get_wagons(start) wagons[i].inventory[2] = {name = 'iron-plate', count = 16} wagons[i].inventory[3] = {name = 'wood', count = 16} wagons[i].inventory[4] = {name = 'burner-mining-drill', count = 8} - end + end else local inventories = { one = global.locomotive_cargo[1].get_inventory(defines.inventory.cargo_wagon), @@ -231,15 +238,15 @@ function Public_chrono.post_jump() end objective.chrononeeds = 200000000 elseif objective.planet[1].name.id == 19 then - objective.chronotimer = objective.chrononeeds - 1800 + objective.chronotimer = objective.chrononeeds - 1500 end for _, player in pairs(game.connected_players) do global.flame_boots[player.index] = {fuel = 1, steps = {}} end game.map_settings.enemy_evolution.time_factor = 7e-05 + 3e-06 * (objective.chronojumps + objective.passivejumps) - game.forces.scrapyard.set_ammo_damage_modifier("bullet", 0.01 * objective.chronojumps) - game.forces.scrapyard.set_turret_attack_modifier("gun-turret", 0.01 * objective.chronojumps) + game.forces.scrapyard.set_ammo_damage_modifier("bullet", 0.01 * objective.chronojumps + 0.02 * math_max(0, objective.chronojumps - 20)) + game.forces.scrapyard.set_turret_attack_modifier("gun-turret", 0.01 * objective.chronojumps + 0.02 * math_max(0, objective.chronojumps - 20)) game.forces.enemy.set_ammo_damage_modifier("melee", 0.1 * objective.passivejumps) game.forces.enemy.set_ammo_damage_modifier("biological", 0.1 * objective.passivejumps) game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.8 @@ -249,6 +256,7 @@ function Public_chrono.post_jump() game.forces.player.technologies["power-armor-mk2"].enabled = true end end + global.objective = objective end return Public_chrono diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua index ecaac8b2..70b157b3 100644 --- a/maps/chronosphere/chronobubles.lua +++ b/maps/chronosphere/chronobubles.lua @@ -10,7 +10,7 @@ local variants = { [5] = {id = 5, name = "uranium planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 6, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 5}, [6] = {id = 6, name = "mixed planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 0, oil = 2, biters = 10, moisture = 0, chance = 3, cumul_chance = 8}, [7] = {id = 7, name = "biter planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 4, oil = 3, biters = 40, moisture = 0.2, chance = 4, cumul_chance = 12}, - [8] = {id = 8, name = "water planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 6, moisture = 0.5, chance = 1, cumul_chance = 13}, + [8] = {id = 8, name = "poor planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 16, moisture = 0.1, chance = 1, cumul_chance = 13}, [9] = {id = 9, name = "coal planet", iron = 1, copper = 1, coal = 6, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0, chance = 1, cumul_chance = 14}, [10] = {id = 10, name = "scrapyard", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 0, moisture = -0.2, chance = 3, cumul_chance = 17}, [11] = {id = 11, name = "rocky planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 6, moisture = -0.2, chance = 2, cumul_chance = 19}, diff --git a/maps/chronosphere/comfylatron.lua b/maps/chronosphere/comfylatron.lua index 7f5c69c5..774b9135 100644 --- a/maps/chronosphere/comfylatron.lua +++ b/maps/chronosphere/comfylatron.lua @@ -81,7 +81,12 @@ local texts = { "Ha! I bet this time we will finally get into the right year!", "One zero zero zero one zero one zero one zero one zero one... two.", "I remember that once we jumped into time where I had park with blackjack and hookers...", - "I was having the most wonderful dream. We used the time machine to kill ourselves before we launched the machine! How terrible..." + "I was having the most wonderful dream. We used the time machine to kill ourselves before we launched the machine! How terrible...", + "Train full of timedrug addicts...what do we do?", + "They just wanted to deliver some fish so I pressed that button and then this happened", + "Maybe it was just a cat walking on my keyboard who caused this time travel fiasco", + "3...2...1...jump time! errr...I mean...desync time!", + "Just let me deliver the fish. They start to smell a bit. Luckily I don't have a nose" }, ["alone"] = { "comfy ^.^", diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua index dc8c0905..c066c9df 100644 --- a/maps/chronosphere/event_functions.lua +++ b/maps/chronosphere/event_functions.lua @@ -16,24 +16,25 @@ local choppy_entity_yield = { local function get_ore_amount() local scaling = 5 * global.objective.chronojumps - local amount = (30 + scaling ) * (1 + game.forces.player.mining_drill_productivity_bonus) * global.objective.planet[1].ore_richness.factor + local amount = (30 + scaling ) * (1 + game.forces.player.mining_drill_productivity_bonus / 2) * global.objective.planet[1].ore_richness.factor if amount > 600 then amount = 600 end amount = math_random(math_floor(amount * 0.7), math_floor(amount * 1.3)) return amount end -local function reward_ores(amount, mined_loot, surface, player) - local a = player.insert {name = mined_loot, count = amount} +local function reward_ores(amount, mined_loot, surface, player, entity) + local a = 0 + if player then a = player.insert {name = mined_loot, count = amount} end amount = amount - a if amount > 0 then if amount >= 50 then for i = 1, math_floor(amount / 50), 1 do - surface.create_entity{name = "item-on-ground", position = player.position, stack = {name = mined_loot, count = 50}} + surface.create_entity{name = "item-on-ground", position = entity.position, stack = {name = mined_loot, count = 50}} amount = amount - 50 end end if amount > 0 then - surface.spill_item_stack(player.position, {name = mined_loot, count = amount},true) + surface.spill_item_stack(entity.position, {name = mined_loot, count = amount},true) end end end @@ -135,7 +136,7 @@ function Public_event.choppy_loot(event) }) local player = game.players[event.player_index] - reward_ores(amount, main_item, entity.surface, player) + reward_ores(amount, main_item, entity.surface, player, player) local inserted_count = player.insert({name = second_item, count = second_item_amount}) second_item_amount = second_item_amount - inserted_count @@ -158,35 +159,43 @@ function Public_event.rocky_loot(event) text = "+" .. amount .. " [img=item/" .. mined_loot .. "]", color = {r=0.98, g=0.66, b=0.22} }) - reward_ores(amount, mined_loot, surface, player) + reward_ores(amount, mined_loot, surface, player, player) end local ore_yield = { ["behemoth-biter"] = 5, ["behemoth-spitter"] = 5, - ["behemoth-worm-turret"] = 9, + ["behemoth-worm-turret"] = 6, ["big-biter"] = 3, ["big-spitter"] = 3, - ["big-worm-turret"] = 7, - ["biter-spawner"] = 16, + ["big-worm-turret"] = 4, + ["biter-spawner"] = 10, ["medium-biter"] = 2, ["medium-spitter"] = 2, - ["medium-worm-turret"] = 5, + ["medium-worm-turret"] = 3, ["small-biter"] = 1, ["small-spitter"] = 1, - ["small-worm-turret"] = 3, - ["spitter-spawner"] = 16, + ["small-worm-turret"] = 2, + ["spitter-spawner"] = 10, } function Public_event.swamp_loot(event) local surface = game.surfaces[global.active_surface_index] - local amount = get_ore_amount() / 12 + local amount = get_ore_amount() / 20 if ore_yield[event.entity.name] then - amount = get_ore_amount() / 12 * ore_yield[event.entity.name] + amount = (get_ore_amount() * ore_yield[event.entity.name]) / 20 end - local rock_mining = {"iron-ore", "iron-ore", "coal", "coal", "coal"} + if amount > 50 then amount = 50 end + + local rock_mining = {"iron-ore", "iron-ore", "coal"} local mined_loot = rock_mining[math_random(1,#rock_mining)] - surface.spill_item_stack(event.entity.position,{name = mined_loot, count = amount}, true) + --reward_ores(amount, mined_loot, surface, nil, event.entity) + if amount < 5 then + surface.spill_item_stack(event.entity.position,{name = mined_loot, count = amount}, true) + else + surface.create_entity{name = "item-on-ground", position = event.entity.position, stack = {name = mined_loot, count = amount}} + end + --surface.spill_item_stack(event.entity.position,{name = mined_loot, count = amount}, true) end function Public_event.danger_silo(entity) diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index 9f0690db..58afddb4 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -151,7 +151,7 @@ local function update_gui(player) } local upgt = { [1] = {t = "[1]: + 2500 Train Max HP. Current: " .. objective.max_health .. "\n Cost : " .. math_floor(500 * (1 + objective.hpupgradetier /2)) .. " coins + 1500 copper plates\n"}, - [2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%\n Buyable once per 3 jumps.\n Cost: 5000 coins + 2000 green circuits + Jump number " .. (objective.filterupgradetier + 1) * 3 .. "\n"}, + [2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1) * global.difficulty_vote_value) .. "%\n Buyable once per 3 jumps.\n Cost: 5000 coins + 2000 green circuits + Jump number " .. (objective.filterupgradetier + 1) * 3 .. "\n"}, [3] = {t = "[3]: Add additional row of Acumulators.\n Cost : " .. math_floor(2000 * (1 + objective.acuupgradetier /4)) .. " coins + 200 batteries\n"}, [4] = {t = "[4]: Add item pickup distance to players.Current: +" .. objective.pickupupgradetier .. ",\n Cost: " .. 1000 * (1 + objective.pickupupgradetier) .. " coins + 400 red inserters\n"}, [5] = {t = "[5]: Add +10 inventory slots. Buyable once per 5 jumps.\n Cost: " .. 2000 * (1 + objective.invupgradetier) .." coins + " .. chests[objective.invupgradetier + 1].c}, diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index ceb8581c..cb71afd5 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -67,11 +67,6 @@ local function generate_overworld(surface, optplanet) mgs.property_expression_names["control-setting:moisture:bias"] = moisture surface.map_gen_settings = mgs end - if planet[1].name.id == 8 then --water planet - local mgs = surface.map_gen_settings - mgs.water = 0.8 - surface.map_gen_settings = mgs - end if planet[1].name.id == 14 then --lava planet local mgs = surface.map_gen_settings mgs.water = 0 @@ -153,7 +148,6 @@ local function reset_map() render_train_hp() game.reset_time_played() Locomotive.create_wagon_room() - Event_functions.mining_buffs() if objective.game_won then game.print({"chronosphere.message_game_won_restart"}, {r=0.98, g=0.66, b=0.22}) end @@ -250,7 +244,7 @@ local function chronojump(choice) game.delete_surface(oldsurface) Chrono.post_jump() Event_functions.flamer_nerfs() - surface.pollute(global.locomotive.position, 150 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps)) + surface.pollute(global.locomotive.position, 150 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps) * global.difficulty_vote_value) end local tick_minute_functions = { @@ -348,6 +342,8 @@ local function on_init() game.surfaces["nauvis"].map_gen_settings = mgs game.surfaces["nauvis"].clear() reset_map() + Chrono.init_setup() + Event_functions.mining_buffs() --if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end end diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index 6e28d794..2902507c 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -988,7 +988,6 @@ end local function on_chunk_generated(event) if string.sub(event.surface.name, 0, 12) ~= "chronosphere" then return end - if event.surface.index == global.objective.nextsurface then return end process_chunk(event.surface, event.area.left_top) end diff --git a/maps/chronosphere/tick_functions.lua b/maps/chronosphere/tick_functions.lua index 334d91c2..f00477cd 100644 --- a/maps/chronosphere/tick_functions.lua +++ b/maps/chronosphere/tick_functions.lua @@ -43,7 +43,7 @@ function Public_tick.charge_chronosphere() for i = 1, #acus, 1 do if not acus[i].valid then return end local energy = acus[i].energy - if energy > 3000000 and objective.chronotimer < objective.chrononeeds - 182 and objective.chronotimer > 130 then + if energy > 3010000 and objective.chronotimer < objective.chrononeeds - 182 and objective.chronotimer > 130 then acus[i].energy = acus[i].energy - 3000000 objective.chronotimer = objective.chronotimer + 1 game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (10 + 2 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1)) * global.difficulty_vote_value) diff --git a/maps/chronosphere/upgrades.lua b/maps/chronosphere/upgrades.lua index 7e32363b..793686d5 100644 --- a/maps/chronosphere/upgrades.lua +++ b/maps/chronosphere/upgrades.lua @@ -338,9 +338,12 @@ local function check_win() for _, player in pairs(game.connected_players) do player.play_sound{path="utility/game_won", volume_modifier=0.85} end - local message = {"chronosphere.message_game_won1"} .. "after all, we delivered " .. objective.mainscore .. " of them fishies." + local message = {"chronosphere.message_game_won1"} + local message2 = "Number of delivered fish: " .. objective.mainscore game.print(message, {r=0.98, g=0.66, b=0.22}) + game.print(message2, {r=0.98, g=0.66, b=0.22}) Server.to_discord_embed(message) + Server.to_discord_embed(message2) end end end From df51cb3c53d0872a4d618d497e20bea983a0f9d9 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Fri, 20 Mar 2020 19:46:55 +0100 Subject: [PATCH 38/70] conflict fix? --- control.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/control.lua b/control.lua index 16547a85..7d205772 100644 --- a/control.lua +++ b/control.lua @@ -126,11 +126,11 @@ require "maps.chronosphere.main" --require "modules.trees_grow" --require "modules.trees_randomly_die" ---require "terrain_layouts.scrap_01" ---require "terrain_layouts.watery_world" --require "terrain_layouts.caves" --require "terrain_layouts.cone_to_east" --require "terrain_layouts.biters_and_resources_east" +--require "terrain_layouts.scrap_01" +require "terrain_layouts.watery_world" ------ if _DUMP_ENV then From eb2e5092289dfaa4eac300a5e9751a2b3130a0a0 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sun, 22 Mar 2020 22:30:29 +0100 Subject: [PATCH 39/70] scrapyard nerf because mining prod makes it give more --- maps/chronosphere/terrain.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index 2902507c..f1d96f3e 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -507,8 +507,8 @@ local function process_scrapyard_position(p, seed, tiles, entities, treasure, pl if math_random(1,100) > 42 then entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} end end if scrapyard < -0.28 or scrapyard > 0.28 then - if math_random(1,96) == 1 then entities[#entities + 1] = {name = scrap_entities[math_random(1, scrap_entities_index)], position = p, force = "enemy"} end - if math_random(1,5) > 1 then entities[#entities + 1] = {name="mineable-wreckage", position=p} end + if math_random(1,48) == 1 then entities[#entities + 1] = {name = scrap_entities[math_random(1, scrap_entities_index)], position = p, force = "enemy"} end + if math_random(1,3) == 1 then entities[#entities + 1] = {name="mineable-wreckage", position=p} end return end return From 8be8c713db4a927149da91925ad89812bf6a94f3 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Thu, 26 Mar 2020 04:41:16 +0100 Subject: [PATCH 40/70] tiny update + new module --- maps/chronosphere/chrono.lua | 1 + maps/chronosphere/event_functions.lua | 3 +- maps/chronosphere/main.lua | 5 + modules/admins_operate_biters.lua | 610 ++++++++++++++++++++++++++ 4 files changed, 618 insertions(+), 1 deletion(-) create mode 100644 modules/admins_operate_biters.lua diff --git a/maps/chronosphere/chrono.lua b/maps/chronosphere/chrono.lua index a8732cf2..eafc30f0 100644 --- a/maps/chronosphere/chrono.lua +++ b/maps/chronosphere/chrono.lua @@ -97,6 +97,7 @@ function Public_chrono.restart_settings() game.forces.player.technologies["fusion-reactor-equipment"].enabled = false game.forces.player.technologies["power-armor-mk2"].enabled = false game.forces.player.technologies["railway"].researched = true + game.forces.player.recipes["pistol"].enabled = false global.objective = objective end diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua index c066c9df..8942e2f8 100644 --- a/maps/chronosphere/event_functions.lua +++ b/maps/chronosphere/event_functions.lua @@ -29,7 +29,8 @@ local function reward_ores(amount, mined_loot, surface, player, entity) if amount > 0 then if amount >= 50 then for i = 1, math_floor(amount / 50), 1 do - surface.create_entity{name = "item-on-ground", position = entity.position, stack = {name = mined_loot, count = 50}} + local e = surface.create_entity{name = "item-on-ground", position = entity.position, stack = {name = mined_loot, count = 50}} + e.to_be_looted = true amount = amount - 50 end end diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index cb71afd5..d88b0215 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -347,6 +347,10 @@ local function on_init() --if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end end +local function on_load() + Chrono.init_setup() +end + local function protect_entity(event) if event.entity.force.index ~= 1 then return end --Player Force if Event_functions.isprotected(event.entity) then @@ -511,6 +515,7 @@ end local event = require 'utils.event' event.on_init(on_init) +event.on_load(on_load) event.on_nth_tick(2, tick) event.add(defines.events.on_entity_damaged, on_entity_damaged) event.add(defines.events.on_entity_died, on_entity_died) diff --git a/modules/admins_operate_biters.lua b/modules/admins_operate_biters.lua new file mode 100644 index 00000000..951bbe47 --- /dev/null +++ b/modules/admins_operate_biters.lua @@ -0,0 +1,610 @@ +local event = require 'utils.event' +local math_random = math.random +local math_floor = math.floor +global.biter_command = {} +global.biter_command.active_unit_groups = {} +global.biter_command.admin_mode = true --if only admins can see and use the panel +global.biter_command.teleporting = false --if teleporting is allowed for non-admins + +local worm_raffle = { + "small-worm-turret", "small-worm-turret", "medium-worm-turret", "small-worm-turret", + "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "medium-worm-turret", + "big-worm-turret","big-worm-turret","behemoth-worm-turret", "big-worm-turret", + "behemoth-worm-turret","behemoth-worm-turret","behemoth-worm-turret","big-worm-turret","behemoth-worm-turret" +} + +local function shuffle(tbl) + local size = #tbl + for i = size, 1, -1 do + local rand = math_random(size) + tbl[i], tbl[rand] = tbl[rand], tbl[i] + end + return tbl +end + +local function is_closer(pos1, pos2, pos) + return ((pos1.x - pos.x)^2 + (pos1.y - pos.y)^2) < ((pos2.x - pos.x)^2 + (pos2.y - pos.y)^2) +end + +local function shuffle_distance(tbl, position) + local size = #tbl + for i = size, 1, -1 do + local rand = math_random(size) + if is_closer(tbl[i].position, tbl[rand].position, position) and i > rand then + tbl[i], tbl[rand] = tbl[rand], tbl[i] + end + end + return tbl +end + +local function get_evo(force) + local evo = math_floor(game.forces["enemy"].evolution_factor * 20) + local nests = math_random(1 + evo, 2 + evo * 2 ) +end + +local function place_nest_near_unit_group(group) + if not group.members then return false end + if #group.members < 5 then return false end + local units = group.members + shuffle(units) + for i = 1, 5, 1 do + if not units[i].valid then return false end + end + local name = "biter-spawner" + if math_random(1, 3) == 1 then name = "spitter-spawner" end + local position = group.surface.find_non_colliding_position(name, group.position, 16, 1) + if not position then return false end + group.surface.create_entity({name = name, position = position, force = group.force}) + group.surface.create_entity({name = "blood-explosion-huge", position = position}) + for i = 1, 5, 1 do + units[i].surface.create_entity({name = "blood-explosion-huge", position = units[i].position}) + units[i].destroy() + end + return true +end + +local function build_worm(group) + if not group.members then return false end + if #group.members < 5 then return false end + local units = group.members + shuffle(units) + for i = 1, 5, 1 do + if not units[i].valid then return false end + end + local position = group.surface.find_non_colliding_position("assembling-machine-1", group.position, 8, 1) + local worm = worm_raffle[math_random(1 + math_floor(group.force.evolution_factor * 8), math_floor(1 + group.force.evolution_factor * 16))] + if not position then return false end + group.surface.create_entity({name = worm, position = position, force = group.force}) + group.surface.create_entity({name = "blood-explosion-huge", position = position}) + for i = 1, 5, 1 do + units[i].surface.create_entity({name = "blood-explosion-huge", position = units[i].position}) + units[i].destroy() + end + return true +end + +local function flying_text(message, action, position, player) + local texts = { + {"roger", "acknowledged", "aye aye", "confirmed", "will do"}, + {"negative", "no", "not really", "we are not your critters", "go away"}, + {"fooood", "nom nom", "we hunger", "killllll"}, + {"WTF", "we wanted ACTION", "why you hate us", "we were good soldiers", "go to hell"} + } + colors = {{r=0,g=220,b=0},{r=220,g=0,b=0},{r=0,g=100,b=220}, {r=200,g=200,b=0}, {r=255, g = 255, b = 255}} + if message then + player.create_local_flying_text{text = message, position = position, color = colors[5]} + else + player.create_local_flying_text{text = texts[action][math_random(1,#texts[action])], position = position, color = colors[action]} + end +end + + +-----------commands----------- + +local function move_to(position, distraction) + local command = { + type = defines.command.go_to_location, + destination = position, + distraction = distraction + } + return command +end + +-- local function attackmaincommand(target) +-- local wave_defense_table = WD.get_table() +-- if not wave_defense_table.target then return end +-- if not wave_defense_table.target.valid then return end +-- local command = { +-- type = defines.command.attack, +-- target = target, +-- distraction = defines.distraction.by_enemy, +-- } +-- return command +-- end + +local function attackareacommand(position) + local command = { + type = defines.command.attack_area, + destination = position, + radius = 25, + distraction = defines.distraction.by_enemy + } + return command +end + +local function attackobstaclescommand(surface, position) + local commands = {} + local obstacles = surface.find_entities_filtered{position = position, radius = 20, type = {"simple-entity", "tree"}, limit = 100} + if obstacles then + shuffle(obstacles) + shuffle_distance(obstacles, position) + for i = 1, #obstacles, 1 do + if obstacles[i].valid then + commands[#commands + 1] = { + type = defines.command.attack, + target = obstacles[i], + distraction = defines.distraction.by_enemy + } + end + end + end + return commands +end + +local function get_coords(group, source_player) + local position + if source_player.gui.screen["biter_panel"] then + local x = tonumber(source_player.gui.screen["biter_panel"]["coords"]["coord_x"].text) + local y = tonumber(source_player.gui.screen["biter_panel"]["coords"]["coord_y"].text) + if x == nil or x == "nil" then + x = group.position.x + source_player.gui.screen["biter_panel"]["coords"]["coord_x"].text = group.position.x + end + if y == nil or y == "nil" then + y = group.position.y + source_player.gui.screen["biter_panel"]["coords"]["coord_y"].text = group.position.y + end + position = {x = x, y = y} + end + return position +end + +-------button functions------------- + +local function pan(group, source_player) + source_player.open_map(group.position, 0.5) +end + +local function teleport(group, source_player) + if source_player.admin or global.biter_command.teleporting then + source_player.teleport(group.position, group.surface) + else + flying_text("Teleporting is disabled", nil, source_player.position, source_player) + end +end + +local function disband(group, source_player) + flying_text(nil, 4, group.position, source_player) + group.destroy() +end + +local function movetome(group, source_player) + group.set_command(move_to(source_player.position, defines.distraction.none)) + flying_text(nil, 1, group.position, source_player) +end + +local function movetoposition(group, source_player) + local position = get_coords(group, source_player) + if position then + group.set_command(move_to(position, defines.distraction.none)) + flying_text(nil, 1, group.position, source_player) + else + flying_text(nil, 2, group.position, source_player) + end +end + +local function patroltome(group, source_player) + group.set_command(move_to(source_player.position, defines.distraction.by_enemy)) + flying_text(nil, 1, group.position, source_player) +end + +local function patroltoposition(group, source_player) + local position = get_coords(group, source_player) + if position then + group.set_command(move_to(position, defines.distraction.by_enemy)) + flying_text(nil, 1, group.position, source_player) + else + flying_text(nil, 2, group.position, source_player) + end +end + +local function settle(group, source_player) + local success = place_nest_near_unit_group(group) + if success then + flying_text(nil, 1, group.position, source_player) + else + flying_text(nil, 2, group.position, source_player) + source_player.print("Settling new nest failed. Check if group has enough members(5+) and there is empty space.") + end +end + +local function siege(group, source_player) + local success = build_worm(group) + if success then + flying_text(nil, 1, group.position, source_player) + else + flying_text(nil, 2, group.position, source_player) + source_player.print("Making worm failed. Check if group has enough members(5+) and there is empty space.") + end +end + +local function report(group, source_player) + local status = group.state + local states = {"gathering", "moving", "attacking distraction", "attacking target", "finished", "pathfinding", "wander in group"} + flying_text(states[status + 1], nil, group.position, source_player) +end + +local function attackenemiesaround(group, source_player) + flying_text(nil, 3, group.position, source_player) + group.set_command(attackareacommand(group.position)) +end + +local function attackobstaclesaround(group, source_player) + local commands = attackobstaclescommand(group.surface, group.position) + if #commands > 1 then + group.set_command({ + type = defines.command.compound, + structure_type = defines.compound_command.return_last, + commands = commands + }) + flying_text(nil, 3, group.position, source_player) + else + source_player.print("No obstacles found around unit group.") + flying_text(nil, 2, group.position, source_player) + end +end + +local function attackenemiesaroundme(group, source_player) + group.set_command(attackareacommand(source_player.position)) + flying_text(nil, 3, group.position, source_player) +end + +local function attackobstaclesaroundme(group, source_player) + local commands = attackobstaclescommand(source_player.surface, source_player.position) + if #commands > 1 then + group.set_command({ + type = defines.command.compound, + structure_type = defines.compound_command.return_last, + commands = commands + }) + flying_text(nil, 3, group.position, source_player) + else + source_player.print("No obstacles found around player.") + flying_text(nil, 2, group.position, source_player) + end +end + +local function addunitsaroundme(group, source_player) + local units = source_player.surface.find_entities_filtered{position = source_player.position, radius = 50,type = "unit", force = group.force} + for i = 1, #units, 1 do + group.add_member(units[i]) + end +end + +local function addunits(group, source_player) + local units = source_player.surface.find_entities_filtered{position = group.position, radius = 50,type = "unit", force = group.force} + for i = 1, #units, 1 do + group.add_member(units[i]) + end +end + +local function forcemove(group, source_player) + group.force_move() + flying_text(nil, 1, group.position, source_player) +end + +local function creategroup(source_player) + source_player.surface.create_unit_group{position = source_player.position, force = source_player.force} + flying_text("Unit group created", nil, source_player.position, source_player) +end +----------------------direction panel----------------- +local function set_directions(changedx, changedy, source_player) + if source_player.gui.screen["biter_panel"] then + local x = tonumber(source_player.gui.screen["biter_panel"]["coords"]["coord_x"].text) + local y = tonumber(source_player.gui.screen["biter_panel"]["coords"]["coord_y"].text) + if x == nil or x == "nil" then x = 0 end + if y == nil or y == "nil" then y = 0 end + x = x + changedx + y = y + changedy + source_player.gui.screen["biter_panel"]["coords"]["coord_x"].text = x + source_player.gui.screen["biter_panel"]["coords"]["coord_y"].text = y + end +end + + +local function nw(source_player) + set_directions(-25, -25, source_player) +end + +local function n(source_player) + set_directions(0, -25, source_player) +end + +local function ne(source_player) + set_directions(25, -25, source_player) +end + +local function w(source_player) + set_directions(-25, 0, source_player) +end + +local function e(source_player) + set_directions(25, 0, source_player) +end + +local function sw(source_player) + set_directions(-25, 25, source_player) +end + +local function s(source_player) + set_directions(0, 25, source_player) +end + +local function se(source_player) + set_directions(25, 25, source_player) +end + +local function center(group, source_player) + if source_player.gui.screen["biter_panel"] then + source_player.gui.screen["biter_panel"]["coords"]["coord_x"].text = group.position.x + source_player.gui.screen["biter_panel"]["coords"]["coord_y"].text = group.position.y + end +end + +----------------------------gui----------------------- + +local function top_button(player) + if player.gui.top["biter_commands"] then return end + if player.admin or not global.biter_command.admin_mode then + local button = player.gui.top.add({type = "sprite-button", name = "biter_commands", sprite = "entity/medium-spitter"}) + button.style.minimal_height = 38 + button.style.minimal_width = 38 + button.style.padding = -2 + end +end + +local function show_info(player) + if player.gui.screen["biter_comm_info"] then player.gui.screen["biter_comm_info"].destroy() return end + local frame = player.gui.screen.add{type = "frame", name = "biter_comm_info", caption = "Biter Commander needs halp", direction = "vertical"} + frame.location = {x = 350, y = 45} + frame.style.minimal_height = 300 + frame.style.maximal_height = 300 + frame.style.minimal_width = 330 + frame.style.maximal_width = 630 + frame.add({type = "label", caption = "Create new group first, then add biters to it."}) + frame.add({type = "label", caption = "You can use directionpad to navigate them, or do it in person."}) + frame.add({type = "label", caption = "If you input invalid coordinates, they get rewritten to current group's position."}) + frame.add({type = "label", caption = "You can operate only biters and create groups of your own force."}) + frame.add({type = "label", caption = "If group is stuck at gathering state, use 'force move' button."}) + frame.add({type = "label", caption = "Empty groups get autodeleted by game after a while."}) + frame.add({type = "button", name = "close_info", caption = "Close"}) +end + +local function build_groups(player) + local groups = {} + for _, g in pairs(global.biter_command.active_unit_groups) do + if g.group.valid then + if player.admin and global.biter_command.admin_mode then + table.insert(groups, tostring(g.id)) + else + if player.force == g.group.force then + table.insert(groups, tostring(g.id)) + end + end + end + end + table.insert(groups, "Select Group") + return groups +end + +local function biter_panel(player) + if player.gui.screen["biter_panel"] then player.gui.screen["biter_panel"].destroy() return end + + local frame = player.gui.screen.add { type = "frame", caption = "Biter Commander", name = "biter_panel", direction = "vertical" } + frame.location = {x = 5, y = 45} + frame.style.minimal_height = 680 + frame.style.maximal_height = 680 + frame.style.minimal_width = 330 + frame.style.maximal_width = 330 + + local groups = build_groups(player) + local selected_index = #groups + if global.panel_group_index then + if global.panel_group_index[player.name] then + if groups[global.panel_group_index[player.name]] then + selected_index = global.paneld_group_index[player.name] + end + end + end + local t0 = frame.add({type = "table", name = "top", column_count = 3}) + local drop_down = t0.add({type = "drop-down", name = "group_select", items = groups, selected_index = selected_index}) + drop_down.style.minimal_width = 150 + drop_down.style.right_padding = 12 + drop_down.style.left_padding = 12 + t0.add({type = "sprite-button", name = "info", sprite = "virtual-signal/signal-info"}) + t0.add({type = "sprite-button", name = "close", sprite = "virtual-signal/signal-X"}) + + local l1 = frame.add({type = "label", caption = "Camera"}) + local t1 = frame.add({type = "table", name = "camera", column_count = 2}) + local l2 = frame.add({type = "label", caption = "Movement"}) + local t2 = frame.add({type = "table", name = "movement", column_count = 2}) + local l3 = frame.add({type = "label", caption = "Build"}) + local t3 = frame.add({type = "table", name = "build", column_count = 2}) + local l4 = frame.add({type = "label", caption = "Attack"}) + local t4 = frame.add({type = "table", name = "attack", column_count = 2}) + local l5 = frame.add({type = "label", caption = "Group Management"}) + local t5 = frame.add({type = "table", name = "management", column_count = 2}) + local line = frame.add { type = "line"} + line.style.top_margin = 8 + line.style.bottom_margin = 8 + local t6 = frame.add({type = "table", name = "directions", column_count = 3}) + local buttons = { + t1.add({type = "button", caption = "Pan to group", name = "pan", tooltip = "Moves camera to group position."}), + t1.add({type = "button", caption = "TP to group", name = "teleport", tooltip = "Teleports to group."}), + t2.add({type = "button", caption = "Move to me", name = "movetome", tooltip = "Gives group order to move to your position."}), + t2.add({type = "button", caption = "Move to position", name = "movetoposition", tooltip = "Sends group to position with coordinates entered below."}), + t2.add({type = "button", caption = "Patrol to me ", name = "patroltome", tooltip = "Gives group order to move to your position and engage any enemy during movement."}), + t2.add({type = "button", caption = "Patrol to position", name = "patroltoposition", tooltip = "Sends group to position with coordinates entered below and engage any enemy during movement."}), + t3.add({type = "button", caption = "Settle nest", name = "settle", tooltip = "Group creates base. Costs 5 units."}), + t3.add({type = "button", caption = "Build worm", name = "siege", tooltip = "Group builds worm turret. Costs 5 units."}), + t4.add({type = "button", caption = "Attack area", name = "attackenemiesaround", tooltip = "Group attacks enemy things around self."}), + t4.add({type = "button", caption = "Attack obstacles", name = "attackobstaclesaround", tooltip = "Group attacks obstacles around self."}), + t4.add({type = "button", caption = "Attack my area", name = "attackenemiesaroundme", tooltip = "Group attacks enemy things around your position."}), + t4.add({type = "button", caption = "Attack my obstacles", name = "attackobstaclesaroundme", tooltip = "Group attacks obstacles around your position."}), + t5.add({type = "button", caption = "Report", name = "report", tooltip = "Reports group status."}), + t5.add({type = "button", caption = "Force Move", name = "forcemove", tooltip = "Makes group to start moving even if gathering is not done (unstuck)."}), + t5.add({type = "button", caption = "Add units around me", name = "addunitsaroundme", tooltip = "Adds units around you to selected unit group."}), + t5.add({type = "button", caption = "Add units", name = "addunits", tooltip = "Adds units around group to it."}), + t5.add({type = "button", caption = "Create group", name = "creategroup", tooltip = "Creates new group on player position"}), + t5.add({type = "button", caption = "Disband group", name = "disband", tooltip = "Disbands group."}), + } + local buttons2 = { + t6.add({type = "button", caption = "25 NW", name = "nw", tooltip = "Changes remote position"}), + t6.add({type = "button", caption = "25 N", name = "n", tooltip = "Changes remote position"}), + t6.add({type = "button", caption = "25 NE", name = "ne", tooltip = "Changes remote position"}), + t6.add({type = "button", caption = "25 W", name = "w", tooltip = "Changes remote position"}), + t6.add({type = "button", caption = "Center", name = "center", tooltip = "Centers remote position to group"}), + t6.add({type = "button", caption = "25 E", name = "e", tooltip = "Changes remote position"}), + t6.add({type = "button", caption = "25 SW", name = "sw", tooltip = "Changes remote position"}), + t6.add({type = "button", caption = "25 S", name = "s", tooltip = "Changes remote position"}), + t6.add({type = "button", caption = "25 SE", name = "se", tooltip = "Changes remote position"}), + } + for _, button in pairs(buttons) do + button.style.font = "default-bold" + button.style.font_color = { r=0.99, g=0.99, b=0.99} + button.style.minimal_width = 150 + end + for _, button in pairs(buttons2) do + button.style.font = "default-bold" + button.style.font_color = { r=0.99, g=0.99, b=0.99} + button.style.minimal_width = 70 + end + local t7 = frame.add({type = "table", name = "coords", column_count = 2}) + t7.add({type = "label", caption = "X: "}) + t7.add({type = "textfield", name = "coord_x"}) + t7.add({type = "label", caption = "Y: "}) + t7.add({type = "textfield", name = "coord_y"}) +end + +local comm_functions = { + ["pan"] = pan, + ["teleport"] = teleport, + ["disband"] = disband, + ["movetome"] = movetome, + ["movetoposition"] = movetoposition, + ["patroltome"] = patroltome, + ["patroltoposition"] = patroltoposition, + ["settle"] = settle, + ["siege"] = siege, + ["report"] = report, + ["attackenemiesaround"] = attackenemiesaround, + ["attackobstaclesaround"] = attackobstaclesaround, + ["attackenemiesaroundme"] = attackenemiesaroundme, + ["attackobstaclesaroundme"] = attackobstaclesaroundme, + ["addunits"] = addunits, + ["addunitsaroundme"] = addunitsaroundme, + ["forcemove"] = forcemove, + ["center"] = center, + } + +local comm_global_functions = { + ["creategroup"] = creategroup, + ["nw"] = nw, + ["n"] = n, + ["ne"] = ne, + ["w"] = w, + ["e"] = e, + ["sw"] = sw, + ["s"] = s, + ["se"] = se, + } + +local function refresh_groups(player) + local groups = build_groups(player) + player.gui.screen["biter_panel"]["top"]["group_select"].items = groups +end + +local function on_gui_click(event) + if not event then return end + if not event.element then return end + if not event.element.valid then return end + local player = game.players[event.element.player_index] + if event.element.name == "biter_commands" then --top button press + biter_panel(player) + return + end + if event.element.type ~= "button" and event.element.type ~= "sprite-button" then return end + --if event.frame.name ~= "biter_panel" then return end + local name = event.element.name + if name == "close" then biter_panel(player) return end + if name == "info" then show_info(player) return end + if name == "close_info" then show_info(player) return end + if comm_functions[name] then + local target_group_id = event.element.parent.parent["top"]["group_select"].items[event.element.parent.parent["top"]["group_select"].selected_index] + if not target_group_id then return end + if target_group_id == "Select Group" then + player.print("No target group selected.", {r=0.88, g=0.88, b=0.88}) + return + end + -- local index = index(tonumber(target_group_id)) + -- if not index then + -- player.print("Selected group is no longer valid.", {r=0.88, g=0.88, b=0.88}) + -- return + -- end + local group = global.biter_command.active_unit_groups[tonumber(target_group_id)] + if group and group.group.valid then + comm_functions[name](group.group, player) + else + refresh_groups(player) + end + return + end + + if comm_global_functions[name] then + comm_global_functions[name](player) + return + end +end + +local function refresh_panel() + for _, player in pairs(game.connected_players) do + if player.gui.screen["biter_panel"] then + refresh_groups(player) + end + end +end + +local function on_player_joined_game(event) + top_button(game.players[event.player_index]) +end + +local function on_unit_group_created(event) + if event and event.group then + global.biter_command.active_unit_groups[event.group.group_number] = {id = event.group.group_number, group = event.group} + refresh_panel() + end +end + +local function on_unit_removed_from_group(event) + if event and event.group then + if #event.group.members == 1 then + global.biter_command.active_unit_groups[event.group.group_number] = nil + refresh_panel() + end + end +end + +event.add(defines.events.on_unit_removed_from_group, on_unit_removed_from_group) +event.add(defines.events.on_unit_group_created, on_unit_group_created) +event.add(defines.events.on_player_joined_game, on_player_joined_game) +event.add(defines.events.on_gui_click, on_gui_click) From b0e3726651026016e4101558d8f17ae8ca8f57b6 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Wed, 1 Apr 2020 05:24:22 +0200 Subject: [PATCH 41/70] tiny update to science in hedge maze --- control.lua | 3 ++- maps/chronosphere/main.lua | 1 + maps/chronosphere/terrain.lua | 11 +++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/control.lua b/control.lua index 7d205772..8eac43dd 100644 --- a/control.lua +++ b/control.lua @@ -27,6 +27,7 @@ require "comfy_panel.config" require "modules.autostash" ---- enable modules here ---- +require "modules.admins_operate_biters" --require "modules.the_floor_is_lava" --require "modules.biters_landfill_on_death" --require "modules.autodecon_when_depleted" @@ -130,7 +131,7 @@ require "maps.chronosphere.main" --require "terrain_layouts.cone_to_east" --require "terrain_layouts.biters_and_resources_east" --require "terrain_layouts.scrap_01" -require "terrain_layouts.watery_world" +--require "terrain_layouts.watery_world" ------ if _DUMP_ENV then diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index d88b0215..274f6e3d 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -230,6 +230,7 @@ local function chronojump(choice) global.lab_cells = {} global.active_surface_index = game.create_surface("chronosphere" .. objective.chronojumps, Chrono.get_map_gen_settings()).index local surface = game.surfaces[global.active_surface_index] + log("seed of new surface: " .. surface.map_gen_settings.seed) local planet = nil if choice then Planets.determine_planet(choice) diff --git a/maps/chronosphere/terrain.lua b/maps/chronosphere/terrain.lua index f1d96f3e..6ef4ddcc 100644 --- a/maps/chronosphere/terrain.lua +++ b/maps/chronosphere/terrain.lua @@ -4,6 +4,7 @@ local Ores = require "maps.chronosphere.ores" local Specials = require "maps.chronosphere.terrain_specials" local math_random = math.random local math_floor = math.floor +local math_min = math.min local math_abs = math.abs local math_sqrt = math.sqrt local level_depth = 960 @@ -175,7 +176,8 @@ local function process_dangerevent_position(p, seed, tiles, entities, treasure, return end end - tiles[#tiles + 1] = {name = "stone-path", position = p} + tiles[#tiles + 1] = {name = "dirt-7", position = p} + tiles[#tiles + 1] = {name = "stone-path", position = p} end local function process_hedgemaze_position(p, seed, tiles, entities, treasure, planet, cell, things) @@ -531,7 +533,8 @@ local function process_scrapyard_position(p, seed, tiles, entities, treasure, pl return end end - tiles[#tiles + 1] = {name = "stone-path", position = p} + tiles[#tiles + 1] = {name = "dirt-7", position = p} + tiles[#tiles + 1] = {name = "stone-path", position = p} end local function process_swamp_position(p, seed, tiles, entities, treasure, planet) @@ -675,7 +678,7 @@ local entity_functions = { end, ["lab"] = function(surface, entity) local e = surface.create_entity(entity) - local evo = math_floor(1 + (game.forces.enemy.evolution_factor - 0.00001) * 5) + local evo = 1 + math_min(math_floor(global.objective.chronojumps / 4), 4) local research = { {"automation-science-pack", "logistic-science-pack"}, {"automation-science-pack", "logistic-science-pack", "military-science-pack"}, @@ -684,7 +687,7 @@ local entity_functions = { {"automation-science-pack", "logistic-science-pack", "military-science-pack", "chemical-science-pack", "production-science-pack", "utility-science-pack"} } for _,science in pairs(research[evo]) do - e.insert({name = science, count = math_random(32,64)}) + e.insert({name = science, count = math_random(math_min(32 + global.objective.chronojumps, 100), math_min(64 + global.objective.chronojumps, 200))}) end end, } From 4a696bafe6fb84ada94fa20243b962df66505c61 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Wed, 8 Apr 2020 20:14:24 +0200 Subject: [PATCH 42/70] Delete overgrowth.lua --- maps/overgrowth.lua | 267 -------------------------------------------- 1 file changed, 267 deletions(-) delete mode 100644 maps/overgrowth.lua diff --git a/maps/overgrowth.lua b/maps/overgrowth.lua deleted file mode 100644 index 785c6589..00000000 --- a/maps/overgrowth.lua +++ /dev/null @@ -1,267 +0,0 @@ ---overgrowth-- by mewmew -- - -require "on_tick_schedule" -require "modules.dynamic_landfill" -require "modules.satellite_score" -require "modules.spawners_contain_biters" -require "modules.no_deconstruction_of_neutral_entities" -require "modules.biters_yield_coins" -require "modules.rocks_yield_ore" -require "modules.ores_are_mixed" -require "modules.surrounded_by_worms" -global.average_worm_amount_per_chunk = 1.5 -require "modules.biters_attack_moving_players" -require "modules.market_friendly_fire_protection" -require "modules.trees_grow" -require "modules.trees_randomly_die" - -require "maps.overgrowth_map_info" - -local Reset = require "functions.soft_reset" -local rpg_t = require 'modules.rpg' -local kaboom = require "functions.omegakaboom" - -require "modules.difficulty_vote" - -local unearthing_biters = require "functions.unearthing_biters" - -local event = require 'utils.event' -local math_random = math.random - -local difficulties_votes = { - [1] = 11, - [2] = 10, - [3] = 9, - [4] = 8, - [5] = 7, - [6] = 6, - [7] = 5 -} - -local difficulties_votes_evo = { - [1] = 0.000016, - [2] = 0.000024, - [3] = 0.000032, - [4] = 0.000040, - [5] = 0.000048, - [6] = 0.000056, - [7] = 0.000064 -} - -local starting_items = { - ["pistol"] = 1, - ["firearm-magazine"] = 8 -} ---[[ -local function create_particles(surface, name, position, amount, cause_position) - local math_random = math.random - - local direction_mod = (-100 + math_random(0,200)) * 0.0004 - local direction_mod_2 = (-100 + math_random(0,200)) * 0.0004 - - if cause_position then - direction_mod = (cause_position.x - position.x) * 0.021 - direction_mod_2 = (cause_position.y - position.y) * 0.021 - end - - for i = 1, amount, 1 do - local m = math_random(4, 10) - local m2 = m * 0.005 - - surface.create_entity({ - name = name, - position = position, - frame_speed = 1, - vertical_speed = 0.130, - height = 0, - movement = { - (m2 - (math_random(0, m) * 0.01)) + direction_mod, - (m2 - (math_random(0, m) * 0.01)) + direction_mod_2 - } - }) - end -end -]] -local function spawn_market(surface, position) - local market = surface.create_entity({name = "market", position = position, force = "neutral"}) - --market.destructible = false - market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "wood", count = 50}}) - market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}) - market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}}) - market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'stone', count = 50}}) - market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'coal', count = 50}}) - market.add_market_item({price = {{"coin", 5}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}) - - market.add_market_item({price = {{'coin', 2}}, offer = {type = 'give-item', item = "raw-fish", count = 1}}) - market.add_market_item({price = {{'coin', 8}}, offer = {type = 'give-item', item = "grenade", count = 1}}) - market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "firearm-magazine", count = 1}}) - market.add_market_item({price = {{'coin', 16}}, offer = {type = 'give-item', item = "submachine-gun", count = 1}}) - market.add_market_item({price = {{'coin', 32}}, offer = {type = 'give-item', item = "car", count = 1}}) - return market -end - -local caption_style = {{"font", "default-bold"}, {"font_color",{ r=0.63, g=0.63, b=0.63}}, {"top_padding",2}, {"left_padding",0},{"right_padding",0},{"minimal_width",0}} -local stat_number_style = {{"font", "default-bold"}, {"font_color",{ r=0.77, g=0.77, b=0.77}}, {"top_padding",2}, {"left_padding",0},{"right_padding",0},{"minimal_width",0}} -local function tree_gui() - for _, player in pairs(game.connected_players) do - if player.gui.top["trees_defeated"] then player.gui.top["trees_defeated"].destroy() end - local b = player.gui.top.add { type = "button", caption = '[img=entity.tree-04] : ' .. global.trees_defeated, tooltip = "Trees defeated", name = "trees_defeated" } - b.style.font = "heading-1" - b.style.font_color = {r=0.00, g=0.33, b=0.00} - b.style.minimal_height = 38 - end -end - -local function get_surface_settings() - local map_gen_settings = {} - map_gen_settings.seed = math_random(1, 1000000) - map_gen_settings.water = math_random(15, 30) * 0.1 - map_gen_settings.starting_area = 1 - map_gen_settings.cliff_settings = {cliff_elevation_interval = math_random(4, 48), cliff_elevation_0 = math_random(4, 48)} - map_gen_settings.autoplace_controls = { - ["coal"] = {frequency = "2", size = "1", richness = "1"}, - ["stone"] = {frequency = "2", size = "1", richness = "1"}, - ["copper-ore"] = {frequency = "2", size = "1", richness = "1"}, - ["iron-ore"] = {frequency = "2.5", size = "1.1", richness = "1"}, - ["uranium-ore"] = {frequency = "2", size = "1", richness = "1"}, - ["crude-oil"] = {frequency = "3", size = "1", richness = "1.5"}, - ["trees"] = {frequency = "2", size = "1", richness = "0.75"}, - ["enemy-base"] = {frequency = "4", size = "1.25", richness = "1"} - } - return map_gen_settings -end - -function reset_map() - local rpg = rpg_t.get_table() - global.trees_grow_chunk_next_visit = {} - global.trees_grow_chunk_raffle = {} - global.trees_grow_chunk_position = {} - global.trees_grow_chunks_charted = {} - global.trees_grow_chunks_charted_counter = 0 - - global.current_surface = Reset.soft_reset_map(global.current_surface, get_surface_settings(), starting_items) - - reset_difficulty_poll() - - global.trees_defeated = 0 - tree_gui() - - global.market = spawn_market(global.current_surface, {x = 0, y = -8}) - - game.map_settings.enemy_evolution.time_factor = difficulties_votes_evo[4] - - if rpg then rpg_t.rpg_reset_all_players() end -end - -local function on_player_joined_game(event) - local player = game.players[event.player_index] - if player.online_time == 0 then - for item, amount in pairs(starting_items) do - player.insert({name = item, count = amount}) - end - end - - if global.current_surface then - if player.surface.name ~= global.current_surface.name then - local pos = global.current_surface.find_non_colliding_position("character", {x = 0, y = 0}, 1, 0.5) - player.teleport(pos, global.current_surface) - end - end - - if not global.market and game.tick == 0 then - global.current_surface = game.create_surface("overgrowth", get_surface_settings()) - game.forces["player"].set_spawn_position({x = 0, y = 0}, global.current_surface) - player.teleport({0,0}, global.current_surface) - reset_map() - end - - tree_gui() -end - -local function trap(entity) - local r = 8 - if global.difficulty_vote_index then r = difficulties_votes[global.difficulty_vote_index] end - if math_random(1,r) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end -end - -local function on_player_mined_entity(event) - local entity = event.entity - if not entity.valid then return end - if entity.type ~= "tree" then return end - - global.trees_defeated = global.trees_defeated + 1 - tree_gui() - - trap(entity) - - if event.player_index then - --create_particles(entity.surface, "wooden-particle", entity.position, 128, game.players[event.player_index].position) - game.players[event.player_index].insert({name = "coin", count = 1}) - return - end - - --create_particles(entity.surface, "wooden-particle", entity.position, 128) - - if event.cause then - if event.cause.force.name == "enemy" then return end - end - - entity.surface.spill_item_stack(entity.position,{name = "coin", count = 1}, true) -end - -local function on_entity_died(event) - on_player_mined_entity(event) - if event.entity == global.market then - global.map_reset_timeout = game.tick + 900 - game.print("The market has been overrun.", {r = 1, g = 0, b = 0}) - kaboom(event.entity.surface, event.entity.position, "explosive-cannon-projectile", 24, 12) - kaboom(event.entity.surface, event.entity.position, "explosive-uranium-cannon-projectile", 24, 12) - global.market = nil - end -end - -local function attack_market() - local c = 8 - if global.difficulty_vote_index then - c = global.difficulty_vote_index * 2 - game.map_settings.enemy_evolution.time_factor = difficulties_votes_evo[global.difficulty_vote_index] - end - global.current_surface.set_multi_command({ - command={ - type=defines.command.attack, - target=global.market, - distraction=defines.distraction.by_enemy - }, - unit_count = math_random(c, c * 2), - force = "enemy", - unit_search_distance=1024 - }) - global.current_surface.set_multi_command({ - command={ - type=defines.command.attack, - target=global.market, - distraction=defines.distraction.none - }, - unit_count = math_random(1, c), - force = "enemy", - unit_search_distance=1024 - }) -end - -local function tick() - if global.market then - if math_random(1, 60) == 1 then - attack_market() - end - return - end - if not global.map_reset_timeout then return end - if game.tick < global.map_reset_timeout then return end - reset_map() - global.map_reset_timeout = nil -end - -event.on_nth_tick(60, tick) -event.add(defines.events.on_player_joined_game, on_player_joined_game) -event.add(defines.events.on_player_mined_entity, on_player_mined_entity) -event.add(defines.events.on_entity_died, on_entity_died) \ No newline at end of file From 127547efb788d901598c55b830a385fbe42418a8 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Wed, 8 Apr 2020 20:14:43 +0200 Subject: [PATCH 43/70] Delete control.lua --- control.lua | 161 ---------------------------------------------------- 1 file changed, 161 deletions(-) delete mode 100644 control.lua diff --git a/control.lua b/control.lua deleted file mode 100644 index 8eac43dd..00000000 --- a/control.lua +++ /dev/null @@ -1,161 +0,0 @@ -require 'utils.data_stages' -_LIFECYCLE = _STAGE.control -- Control stage -_DEBUG = false -_DUMP_ENV = false - -require 'utils.server' -require "utils.server_commands" -require "utils.utils" -require "utils.table" -require "utils.color_data" -require "utils.session_data" -require "chatbot" -require "commands" -require "antigrief" -require "modules.corpse_markers" -require "modules.floaty_chat" -require "modules.autohotbar" - -require "comfy_panel.main" -require "comfy_panel.player_list" -require "comfy_panel.admin" -require "comfy_panel.group" -require "comfy_panel.poll" -require "comfy_panel.score" -require "comfy_panel.config" - -require "modules.autostash" - ----- enable modules here ---- -require "modules.admins_operate_biters" ---require "modules.the_floor_is_lava" ---require "modules.biters_landfill_on_death" ---require "modules.autodecon_when_depleted" ---require "modules.biter_noms_you" ---require "modules.biters_avoid_damage" ---require "modules.biters_double_damage" ---require "modules.burden" ---require "modules.comfylatron" ---require "modules.spaghett_challenge" ---require "modules.dangerous_goods" ---require "modules.dynamic_landfill" ---require "modules.explosive_biters" ---require "modules.explosive_player_respawn" ---require "modules.explosives_are_explosive" ---require "modules.fish_respawner" ---require "modules.fluids_are_explosive" ---require "modules.hunger" ---require "modules.hunger_games" ---require "modules.players_trample_paths" ---require "modules.railgun_enhancer" ---require "modules.restrictive_fluid_mining" ---require "modules.satellite_score" ---require "modules.show_health" ---require "modules.splice_double" ---require "modules.ores_are_mixed" ---require "modules.team_teleport" --(REQUIRES "on_tick_schedule" !) ---require "modules.surrounded_by_worms" ---require "modules.more_attacks" ---require "modules.evolution_extended" ---require "modules.no_blueprint_library" ---require "modules.explosives" ---require "modules.biter_pets" ---require "modules.no_solar" ---require "modules.biter_reanimator" ---require "modules.wave_defense.main" ---require "modules.fjei.main" ---require "utils.one_dimensional_noise" ------------------------------ - ----- enable maps here ---- (maps higher up in the list may be more actually playable) -require "maps.chronosphere.main" ---require "maps.fish_defender.main" ---require "maps.biter_battles_v2.main" ---require "maps.native_war.main" ---require "maps.mountain_fortress_v2.main" ---require "maps.island_troopers.main" ---require "maps.biter_hatchery.main" ---require "maps.junkyard_pvp.main" ---require "maps.scrapyard.main" ---require "maps.tank_conquest.tank_conquest" ---require "maps.territorial_control" ---require "maps.cave_choppy.cave_miner" ---require "maps.wave_of_death.WoD" ---require "maps.planet_prison" ---require "maps.stone_maze.main" ---require "maps.choppy" ---require "maps.overgrowth" ---require "maps.quarters" ---require "maps.tetris.main" ---require "maps.maze_challenge" ---require "maps.cave_miner" ---require "maps.labyrinth" ---require "maps.junkyard" ---require "maps.hedge_maze" ---require "maps.spooky_forest" ---require "maps.mixed_railworld" ---require "maps.biter_battles.biter_battles" ---require "maps.fish_defender_v1.fish_defender" ---require "maps.mountain_fortress" ---require "maps.rocky_waste" ---require "maps.nightfall" ---require "maps.lost" ---require "maps.rivers" ---require "maps.atoll" ---require "maps.cratewood_forest" ---require "maps.tank_battles" ---require "maps.spiral_troopers" ---require "maps.refactor-io" ---require "maps.desert_oasis" ---require "maps.lost_desert" ---require "maps.stoneblock" ---require "maps.wave_defense" ---require "maps.crossing" ---require "maps.anarchy" ---require "maps.spaghettorio" ---require "maps.blue_beach" ---require "maps.deep_jungle" ---require "maps.rainbow_road" ---require "maps.pitch_black.main" ---require "maps.cube" ---require "maps.forest_circle" ------------------------------ - ----- more modules here ---- ---require "modules.towny.main" ---require "modules.rpg" ---require "modules.trees_grow" ---require "modules.trees_randomly_die" - ---require "terrain_layouts.caves" ---require "terrain_layouts.cone_to_east" ---require "terrain_layouts.biters_and_resources_east" ---require "terrain_layouts.scrap_01" ---require "terrain_layouts.watery_world" ------- - -if _DUMP_ENV then - require 'utils.dump_env' -end -if _DEBUG then - require 'utils.debug.command' -end - -local function on_player_created(event) - local player = game.players[event.player_index] - player.gui.top.style = 'slot_table_spacing_horizontal_flow' - player.gui.left.style = 'slot_table_spacing_vertical_flow' -end - -local function on_init() - game.forces.player.research_queue_enabled = true -end - -local loaded = _G.package.loaded -function require(path) - return loaded[path] or error('Can only require files at runtime that have been required in the control stage.', 2) -end - -local event = require 'utils.event' -event.on_init(on_init) -event.add(defines.events.on_player_created, on_player_created) From d9c5468f1effe7688d53d984d229f50b45f3afd7 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Wed, 8 Apr 2020 20:28:02 +0200 Subject: [PATCH 44/70] update --- control.lua | 161 +++++++ functions/basic_markets.lua | 48 +- maps/chronosphere/chrono.lua | 1 + maps/chronosphere/event_functions.lua | 17 + maps/chronosphere/main.lua | 7 +- maps/mountain_fortress_v2/collapse.lua | 57 ++- .../flamethrower_nerf.lua | 12 +- maps/mountain_fortress_v2/locomotive.lua | 46 +- maps/mountain_fortress_v2/main.lua | 215 ++++++--- maps/mountain_fortress_v2/terrain.lua | 418 ++++++++++-------- maps/mountain_fortress_v2/treasure.lua | 66 +-- maps/overgrowth.lua | 267 +++++++++++ modules/admins_operate_biters.lua | 40 +- modules/railgun_enhancer.lua | 2 +- modules/wave_defense/main.lua | 113 +++-- modules/wave_defense/table.lua | 2 +- 16 files changed, 1073 insertions(+), 399 deletions(-) create mode 100644 control.lua create mode 100644 maps/overgrowth.lua diff --git a/control.lua b/control.lua new file mode 100644 index 00000000..8eac43dd --- /dev/null +++ b/control.lua @@ -0,0 +1,161 @@ +require 'utils.data_stages' +_LIFECYCLE = _STAGE.control -- Control stage +_DEBUG = false +_DUMP_ENV = false + +require 'utils.server' +require "utils.server_commands" +require "utils.utils" +require "utils.table" +require "utils.color_data" +require "utils.session_data" +require "chatbot" +require "commands" +require "antigrief" +require "modules.corpse_markers" +require "modules.floaty_chat" +require "modules.autohotbar" + +require "comfy_panel.main" +require "comfy_panel.player_list" +require "comfy_panel.admin" +require "comfy_panel.group" +require "comfy_panel.poll" +require "comfy_panel.score" +require "comfy_panel.config" + +require "modules.autostash" + +---- enable modules here ---- +require "modules.admins_operate_biters" +--require "modules.the_floor_is_lava" +--require "modules.biters_landfill_on_death" +--require "modules.autodecon_when_depleted" +--require "modules.biter_noms_you" +--require "modules.biters_avoid_damage" +--require "modules.biters_double_damage" +--require "modules.burden" +--require "modules.comfylatron" +--require "modules.spaghett_challenge" +--require "modules.dangerous_goods" +--require "modules.dynamic_landfill" +--require "modules.explosive_biters" +--require "modules.explosive_player_respawn" +--require "modules.explosives_are_explosive" +--require "modules.fish_respawner" +--require "modules.fluids_are_explosive" +--require "modules.hunger" +--require "modules.hunger_games" +--require "modules.players_trample_paths" +--require "modules.railgun_enhancer" +--require "modules.restrictive_fluid_mining" +--require "modules.satellite_score" +--require "modules.show_health" +--require "modules.splice_double" +--require "modules.ores_are_mixed" +--require "modules.team_teleport" --(REQUIRES "on_tick_schedule" !) +--require "modules.surrounded_by_worms" +--require "modules.more_attacks" +--require "modules.evolution_extended" +--require "modules.no_blueprint_library" +--require "modules.explosives" +--require "modules.biter_pets" +--require "modules.no_solar" +--require "modules.biter_reanimator" +--require "modules.wave_defense.main" +--require "modules.fjei.main" +--require "utils.one_dimensional_noise" +----------------------------- + +---- enable maps here ---- (maps higher up in the list may be more actually playable) +require "maps.chronosphere.main" +--require "maps.fish_defender.main" +--require "maps.biter_battles_v2.main" +--require "maps.native_war.main" +--require "maps.mountain_fortress_v2.main" +--require "maps.island_troopers.main" +--require "maps.biter_hatchery.main" +--require "maps.junkyard_pvp.main" +--require "maps.scrapyard.main" +--require "maps.tank_conquest.tank_conquest" +--require "maps.territorial_control" +--require "maps.cave_choppy.cave_miner" +--require "maps.wave_of_death.WoD" +--require "maps.planet_prison" +--require "maps.stone_maze.main" +--require "maps.choppy" +--require "maps.overgrowth" +--require "maps.quarters" +--require "maps.tetris.main" +--require "maps.maze_challenge" +--require "maps.cave_miner" +--require "maps.labyrinth" +--require "maps.junkyard" +--require "maps.hedge_maze" +--require "maps.spooky_forest" +--require "maps.mixed_railworld" +--require "maps.biter_battles.biter_battles" +--require "maps.fish_defender_v1.fish_defender" +--require "maps.mountain_fortress" +--require "maps.rocky_waste" +--require "maps.nightfall" +--require "maps.lost" +--require "maps.rivers" +--require "maps.atoll" +--require "maps.cratewood_forest" +--require "maps.tank_battles" +--require "maps.spiral_troopers" +--require "maps.refactor-io" +--require "maps.desert_oasis" +--require "maps.lost_desert" +--require "maps.stoneblock" +--require "maps.wave_defense" +--require "maps.crossing" +--require "maps.anarchy" +--require "maps.spaghettorio" +--require "maps.blue_beach" +--require "maps.deep_jungle" +--require "maps.rainbow_road" +--require "maps.pitch_black.main" +--require "maps.cube" +--require "maps.forest_circle" +----------------------------- + +---- more modules here ---- +--require "modules.towny.main" +--require "modules.rpg" +--require "modules.trees_grow" +--require "modules.trees_randomly_die" + +--require "terrain_layouts.caves" +--require "terrain_layouts.cone_to_east" +--require "terrain_layouts.biters_and_resources_east" +--require "terrain_layouts.scrap_01" +--require "terrain_layouts.watery_world" +------ + +if _DUMP_ENV then + require 'utils.dump_env' +end +if _DEBUG then + require 'utils.debug.command' +end + +local function on_player_created(event) + local player = game.players[event.player_index] + player.gui.top.style = 'slot_table_spacing_horizontal_flow' + player.gui.left.style = 'slot_table_spacing_vertical_flow' +end + +local function on_init() + game.forces.player.research_queue_enabled = true +end + +local loaded = _G.package.loaded +function require(path) + return loaded[path] or error('Can only require files at runtime that have been required in the control stage.', 2) +end + +local event = require 'utils.event' +event.on_init(on_init) +event.add(defines.events.on_player_created, on_player_created) diff --git a/functions/basic_markets.lua b/functions/basic_markets.lua index c05cedf3..d8dd8994 100644 --- a/functions/basic_markets.lua +++ b/functions/basic_markets.lua @@ -3,13 +3,13 @@ local Public = {} local market = {} market.weapons = { - ["pistol"] = {value = 10, rarity = 1}, + --["pistol"] = {value = 10, rarity = 1}, ["submachine-gun"] = {value = 50, rarity = 2}, ["shotgun"] = {value = 40, rarity = 2}, ["combat-shotgun"] = {value = 400, rarity = 5}, ["rocket-launcher"] = {value = 250, rarity = 4}, ["flamethrower"] = {value = 750, rarity = 6}, - ["land-mine"] = {value = 3, rarity = 5}, + ["land-mine"] = {value = 100, rarity = 5}, } market.ammo = { @@ -67,7 +67,7 @@ market.equipment = { ["night-vision-equipment"] = {value = 250, rarity = 1}, } -market.defense = { +market.defense = { ["stone-wall"] = {value = 4, rarity = 1}, ["gate"] = {value = 8, rarity = 1}, ["repair-pack"] = {value = 8, rarity = 1}, @@ -154,13 +154,13 @@ end local function get_resource_market_sells() local sells = { - {price = {{"coin", math.random(5,10)}}, offer = {type = 'give-item', item = 'wood', count = 50}}, - {price = {{"coin", math.random(5,10)}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}, - {price = {{"coin", math.random(5,10)}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}}, - {price = {{"coin", math.random(5,10)}}, offer = {type = 'give-item', item = 'stone', count = 50}}, - {price = {{"coin", math.random(5,10)}}, offer = {type = 'give-item', item = 'coal', count = 50}}, - {price = {{"coin", math.random(8,16)}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}, - {price = {{"coin", math.random(2,4)}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}}, + {price = {{"coin", math.random(25,50)}}, offer = {type = 'give-item', item = 'wood', count = 50}}, + {price = {{"coin", math.random(40,80)}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}, + {price = {{"coin", math.random(40,80)}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}}, + {price = {{"coin", math.random(40,80)}}, offer = {type = 'give-item', item = 'stone', count = 50}}, + {price = {{"coin", math.random(40,80)}}, offer = {type = 'give-item', item = 'coal', count = 50}}, + {price = {{"coin", math.random(60,120)}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}, + {price = {{"coin", math.random(20,40)}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}}, } table.shuffle_table(sells) return sells @@ -174,14 +174,14 @@ local function get_resource_market_buys() {price = {{'stone', math.random(10,12)}}, offer = {type = 'give-item', item = "coin"}}, {price = {{'coal', math.random(10,12)}}, offer = {type = 'give-item', item = "coin"}}, {price = {{'uranium-ore', math.random(8,10)}}, offer = {type = 'give-item', item = "coin"}}, - {price = {{'water-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(1,2)}}, - {price = {{'lubricant-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(3,6)}}, + {price = {{'water-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(2,5)}}, + {price = {{'lubricant-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(5,10)}}, {price = {{'sulfuric-acid-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(4,8)}}, - {price = {{'light-oil-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(2,4)}}, - {price = {{'heavy-oil-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(2,4)}}, - {price = {{'petroleum-gas-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(3,5)}}, + {price = {{'light-oil-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(5,10)}}, + {price = {{'heavy-oil-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(5,10)}}, + {price = {{'petroleum-gas-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(4,8)}}, } - table.shuffle_table(buys) + table.shuffle_table(buys) return buys end @@ -225,17 +225,17 @@ function Public.mountain_market(surface, position, rarity) if not items[i] then break end market.add_market_item(items[i]) end - + local sells = get_resource_market_sells() for i = 1, math.random(1, 3), 1 do market.add_market_item(sells[i]) end - + local buys = get_resource_market_buys() for i = 1, math.random(1, 3), 1 do market.add_market_item(buys[i]) end - + return market end @@ -246,23 +246,23 @@ function Public.super_market(surface, position, rarity) local market = surface.create_entity({name = "market", position = position, force="neutral"}) market.minable = false market.destructible = false - + for i = 1, math.random(6, 12), 1 do if not items[i] then break end market.add_market_item(items[i]) end - + local sells = get_resource_market_sells() for i = 1, math.random(1, 3), 1 do market.add_market_item(sells[i]) end - + local buys = get_resource_market_buys() for i = 1, math.random(1, 3), 1 do market.add_market_item(buys[i]) end - + return market end -return Public \ No newline at end of file +return Public diff --git a/maps/chronosphere/chrono.lua b/maps/chronosphere/chrono.lua index eafc30f0..056b78a3 100644 --- a/maps/chronosphere/chrono.lua +++ b/maps/chronosphere/chrono.lua @@ -36,6 +36,7 @@ function Public_chrono.restart_settings() objective.waterupgradetier = 0 objective.outupgradetier = 0 objective.boxupgradetier = 0 + objective.pistolupgradetier = 0 objective.poisondefense = 2 objective.poisontimeout = 0 objective.chronotimer = 0 diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua index 8942e2f8..3ee8d43f 100644 --- a/maps/chronosphere/event_functions.lua +++ b/maps/chronosphere/event_functions.lua @@ -296,4 +296,21 @@ function Public_event.mining_buffs() end end +function Public_event.pistol_buffs(event) + if global.objective.pistolupgradetier == 0 then return end + if not event.cause then return end + if event.cause.name ~= "player" then return end + if event.damage_type.name ~= "physical" then return end + local player = event.cause + if player.shooting_state.state == defines.shooting.not_shooting then return end + local weapon = event.cause.get_inventory(defines.inventory.character_guns)[event.cause.selected_gun_index].name + local ammo = event.cause.get_inventory(defines.inventory.character_ammo)[event.cause.selected_gun_index].name + game.print(ammo) + game.print(wapon) + if weapon ~= "pistol" then return end + if ammo ~= "firearm-magazine" and ammo ~= "piercing-rounds-magazine" and ammo ~= "uranium-rounds-magazine" then return end + event.entity.damage(event.final_damage_amount * 4, player.force, "physical", player) +end + + return Public_event diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 274f6e3d..d337b6ee 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -348,9 +348,9 @@ local function on_init() --if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end end -local function on_load() - Chrono.init_setup() -end +-- local function on_load() +-- Chrono.init_setup() +-- end local function protect_entity(event) if event.entity.force.index ~= 1 then return end --Player Force @@ -378,6 +378,7 @@ local function on_entity_damaged(event) Event_functions.biters_chew_rocks_faster(event) if event.entity.force.name == "enemy" then Event_functions.biter_immunities(event) + Event_functions.pistol_buffs(event) end end diff --git a/maps/mountain_fortress_v2/collapse.lua b/maps/mountain_fortress_v2/collapse.lua index f4336b06..f624b244 100644 --- a/maps/mountain_fortress_v2/collapse.lua +++ b/maps/mountain_fortress_v2/collapse.lua @@ -34,22 +34,22 @@ local function get_collapse_vectors(radius, seed) end end end - + local sorted_vectors = {} for _, vector in pairs(vectors) do local index = math_floor(math_sqrt(vector[1] ^ 2 + vector[2] ^ 2)) + 1 if not sorted_vectors[index] then sorted_vectors[index] = {} end - sorted_vectors[index][#sorted_vectors[index] + 1] = vector + sorted_vectors[index][#sorted_vectors[index] + 1] = vector end - - local final_list = {} + + local final_list = {} for _, row in pairs(sorted_vectors) do table_shuffle_table(row) for _, tile in pairs(row) do table_insert(final_list, tile) end end - + return final_list end @@ -61,7 +61,7 @@ local function set_y(surface) for _ = 1, 16, 1 do local area = {{x_left, map_collapse.last_position.y},{x_right, map_collapse.last_position.y + 1}} if surface.count_tiles_filtered({name = "out-of-map", area = area}) < level_width then - return area + return area end map_collapse.last_position.y = map_collapse.last_position.y - 1 end @@ -73,7 +73,7 @@ local function set_positions(surface) local map_collapse = global.map_collapse map_collapse.positions = {} - + local i = 1 for _, tile in pairs(surface.find_tiles_filtered({area = area})) do if tile.valid then @@ -83,7 +83,7 @@ local function set_positions(surface) end end end - + if i == 1 then map_collapse.positions = nil return @@ -96,7 +96,16 @@ local function set_collapse_tiles(surface, position, vectors) map_collapse.processing = {} local i = 1 for _, vector in pairs(vectors) do + local shifted_position = {x = position[1] + vector[1], y = position[2] + vector[2] - 60} local position = {x = position[1] + vector[1], y = position[2] + vector[2]} + local rocks = surface.find_entities_filtered{position = shifted_position, radius = 2, type = {"simple-entity", "tree"}} + if #rocks > 0 then + for i = 1, #rocks, 1 do + if rocks[i].valid then + rocks[i].destroy() + end + end + end local tile = surface.get_tile(position) if tile.valid and tile.name ~= "out-of-map" then map_collapse.processing[i] = tile @@ -109,21 +118,21 @@ end local function clean_positions(tbl) for k, tile in pairs(tbl) do - if not tile.valid then + if not tile.valid then table_remove(tbl, k) else - if tile.name == "out-of-map" then + if tile.name == "out-of-map" then table_remove(tbl, k) end - end - end + end + end end local function setup_next_collapse() local surface = game.surfaces[global.active_surface_index] - local map_collapse = global.map_collapse + local map_collapse = global.map_collapse if not map_collapse.vector_list then - map_collapse.vector_list = {} + map_collapse.vector_list = {} for _ = 1, size_of_vector_list, 1 do table_insert(global.map_collapse.vector_list, get_collapse_vectors(math_random(24, 48), math_random(1, 9999999))) end @@ -141,10 +150,10 @@ local function setup_next_collapse() if tile.name == "out-of-map" then clean_positions(map_collapse.positions) return end local position = {tile.position.x, tile.position.y} - + local vectors = map_collapse.vector_list[math_random(1, size_of_vector_list)] set_collapse_tiles(surface, position, vectors) - + local last_position = global.map_collapse.last_position game.forces.player.chart(surface, {{last_position.x - chart_radius, last_position.y - chart_radius},{last_position.x + chart_radius, last_position.y + chart_radius}}) global.map_collapse.last_position = {x = position[1], y = position[2]} @@ -164,11 +173,11 @@ end local function process_tile(surface, tile, tiles_to_set) if not tile then return end if not tile.valid then return end - - local conversion_tile = tile_conversion[tile.name] + + local conversion_tile = tile_conversion[tile.name] if conversion_tile then table_insert(tiles_to_set, {name = conversion_tile, position = tile.position}) - surface.create_trivial_smoke({name="train-smoke", position = tile.position}) + surface.create_trivial_smoke({name="train-smoke", position = tile.position}) else table_insert(tiles_to_set, {name = "out-of-map", position = tile.position}) end @@ -179,12 +188,12 @@ end function Public.process() local surface = game.surfaces[global.active_surface_index] local map_collapse = global.map_collapse - + if map_collapse.processing_index >= map_collapse.size_of_processing then setup_next_collapse() return end - + local count = 0 local tiles_to_set = {} for i = map_collapse.processing_index, map_collapse.size_of_processing, 1 do @@ -194,7 +203,7 @@ function Public.process() end map_collapse.processing_index = map_collapse.processing_index + 1 end - + if count > 1 then surface.set_tiles(tiles_to_set, true) end end @@ -204,11 +213,11 @@ function Public.init() ["size_of_processing"] = 0, ["processing"] = {}, ["last_position"] = {x = 0, y = 128}, - ["speed"] = 2, + ["speed"] = 3, } end local event = require 'utils.event' event.on_init(Public.init()) -return Public \ No newline at end of file +return Public diff --git a/maps/mountain_fortress_v2/flamethrower_nerf.lua b/maps/mountain_fortress_v2/flamethrower_nerf.lua index 6402bc18..9ace6544 100644 --- a/maps/mountain_fortress_v2/flamethrower_nerf.lua +++ b/maps/mountain_fortress_v2/flamethrower_nerf.lua @@ -4,17 +4,17 @@ local function on_research_finished(event) local force_name = research.force.name if research.name == "military" then if not global.flamethrower_damage then global.flamethrower_damage = {} end - global.flamethrower_damage[force_name] = -0.50 + global.flamethrower_damage[force_name] = -0.75 game.forces[force_name].set_turret_attack_modifier("flamethrower-turret", global.flamethrower_damage[force_name]) - game.forces[force_name].set_ammo_damage_modifier("flamethrower", global.flamethrower_damage[force_name]) + game.forces[force_name].set_ammo_damage_modifier("flamethrower", global.flamethrower_damage[force_name]) end - + if string.sub(research.name, 0, 18) == "refined-flammables" then global.flamethrower_damage[force_name] = global.flamethrower_damage[force_name] + 0.10 - game.forces[force_name].set_turret_attack_modifier("flamethrower-turret", global.flamethrower_damage[force_name]) + game.forces[force_name].set_turret_attack_modifier("flamethrower-turret", global.flamethrower_damage[force_name]) game.forces[force_name].set_ammo_damage_modifier("flamethrower", global.flamethrower_damage[force_name]) - end + end end local event = require 'utils.event' -event.add(defines.events.on_research_finished, on_research_finished) \ No newline at end of file +event.add(defines.events.on_research_finished, on_research_finished) diff --git a/maps/mountain_fortress_v2/locomotive.lua b/maps/mountain_fortress_v2/locomotive.lua index 96dd807e..031dc7e4 100644 --- a/maps/mountain_fortress_v2/locomotive.lua +++ b/maps/mountain_fortress_v2/locomotive.lua @@ -6,22 +6,22 @@ function Public.locomotive_spawn(surface, position) end global.locomotive = surface.create_entity({name = "locomotive", position = {position.x, position.y + -3}, force = "player"}) global.locomotive.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 100}) - + global.locomotive_cargo = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 3}, force = "player"}) global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 1}) - + rendering.draw_light({ sprite = "utility/light_medium", scale = 5.5, intensity = 1, minimum_darkness = 0, oriented = true, color = {255,255,255}, target = global.locomotive, surface = surface, visible = true, only_in_alt_mode = false, }) - + rendering.draw_light({ sprite = "utility/light_medium", scale = 5.5, intensity = 1, minimum_darkness = 0, oriented = true, color = {255,255,255}, target = global.locomotive_cargo, surface = surface, visible = true, only_in_alt_mode = false, }) - + global.locomotive.color = {0, 255, 0} global.locomotive.minable = false global.locomotive_cargo.minable = false @@ -37,7 +37,7 @@ function Public.fish_tag() if global.locomotive_tag then if global.locomotive_tag.valid then if global.locomotive_tag.position.x == global.locomotive_cargo.position.x and global.locomotive_tag.position.y == global.locomotive_cargo.position.y then return end - global.locomotive_tag.destroy() + global.locomotive_tag.destroy() end end global.locomotive_tag = global.locomotive_cargo.force.add_chart_tag( @@ -51,7 +51,7 @@ end local function accelerate() if not global.locomotive then return end if not global.locomotive.valid then return end - if global.locomotive.get_driver() then return end + if global.locomotive.get_driver() then return end global.locomotive_driver = global.locomotive.surface.create_entity({name = "character", position = global.locomotive.position, force = "player"}) global.locomotive_driver.driving = true global.locomotive_driver.riding_state = {acceleration = defines.riding.acceleration.accelerating, direction = defines.riding.direction.straight} @@ -66,14 +66,14 @@ end ]] local market_offers = { - {price = {{'coin', 5}}, offer = {type = 'give-item', item = "raw-fish"}}, - {price = {{"coin", 10}}, offer = {type = 'give-item', item = 'wood', count = 50}}, - {price = {{"coin", 10}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}, - {price = {{"coin", 10}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}}, - {price = {{"coin", 10}}, offer = {type = 'give-item', item = 'stone', count = 50}}, - {price = {{"coin", 10}}, offer = {type = 'give-item', item = 'coal', count = 50}}, - {price = {{"coin", 16}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}, - {price = {{"coin", 5}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}}, + {price = {{'coin', 25}}, offer = {type = 'give-item', item = "raw-fish"}}, + {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'wood', count = 50}}, + {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}, + {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}}, + {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'stone', count = 50}}, + {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'coal', count = 50}}, + {price = {{"coin", 80}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}, + {price = {{"coin", 25}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}}, } local function create_wagon_room() @@ -97,7 +97,7 @@ local function create_wagon_room() surface.daytime = 0.1 surface.request_to_generate_chunks({0,0}, 1) surface.force_generate_chunk_requests() - + for x = width * -0.5 + 1, width * 0.5, 1 do for y = height * -0.5, height * 0.5, 1 do surface.set_tiles({{name = "tutorial-grid", position = {x,y}}}) @@ -127,11 +127,11 @@ local function create_wagon_room() e.minable = false e.operable = false end - + local e = surface.create_entity({name = "big-biter", position = {width * -0.5 + 2, height * -0.5 + 2}, force = "player", create_build_effect_smoke = false}) e.ai_settings.allow_destroy_when_commands_fail = false e.ai_settings.allow_try_return_to_spawner = false - + local positions = {} for x = width * -0.5 + 2, width * 0.5 - 1, 1 do for y = 4, height * 0.5 - 1, 1 do @@ -139,7 +139,7 @@ local function create_wagon_room() end end table.shuffle_table(positions) - + local cargo_boxes = { {name = "grenade", count = math.random(2, 3)}, {name = "submachine-gun", count = 1}, @@ -155,8 +155,8 @@ local function create_wagon_room() {name = "rail", count = math.random(16, 24)}, {name = "rail", count = math.random(16, 24)}, {name = "rail", count = math.random(16, 24)}, - } - + } + local i = 1 for _ = 1, 10, 1 do if not positions[i] then break end @@ -165,13 +165,13 @@ local function create_wagon_room() inventory.insert({name = "raw-fish", count = math.random(2, 5)}) i = i + 1 end - + for _ = 1, 24, 1 do if not positions[i] then break end local e = surface.create_entity({name = "wooden-chest", position = positions[i], force="player", create_build_effect_smoke = false}) i = i + 1 end - + for loot_i = 1, #cargo_boxes, 1 do if not positions[i] then break end local e = surface.create_entity({name = "wooden-chest", position = positions[i], force="player", create_build_effect_smoke = false}) @@ -218,4 +218,4 @@ function Public.enter_cargo_wagon(player, vehicle) end end -return Public \ No newline at end of file +return Public diff --git a/maps/mountain_fortress_v2/main.lua b/maps/mountain_fortress_v2/main.lua index de78ae16..716bc639 100644 --- a/maps/mountain_fortress_v2/main.lua +++ b/maps/mountain_fortress_v2/main.lua @@ -1,8 +1,9 @@ -- Mountain digger fortress, protect the cargo wagon! -- by MewMew --enable / disable collapsing of the map -local collapse_enabled = false -local darkness = true +global.collapse_enabled = true +global.offline_loot = true +local darkness = false require "player_modifiers" require "functions.soft_reset" @@ -49,21 +50,25 @@ local function set_difficulty() -- threat gain / wave wave_defense_table.threat_gain_multiplier = 2 + player_count * 0.1 - + --1 additional map collapse tile / 8 players in game global.map_collapse.speed = math.floor(player_count * 0.125) + 1 - + --20 Players for fastest wave_interval wave_defense_table.wave_interval = 3600 - player_count * 90 if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end end function Public.reset_map() + for _,player in pairs(game.players) do + if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end + end local wave_defense_table = WD.get_table() global.chunk_queue = {} - + global.offline_players = {} + if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end - + local map_gen_settings = { ["seed"] = math_random(1, 1000000), ["width"] = level_depth, @@ -77,14 +82,14 @@ function Public.reset_map() ["decorative"] = {treat_missing_as_default = true}, }, } - + if not global.active_surface_index then global.active_surface_index = game.create_surface("mountain_fortress", map_gen_settings).index else - game.forces.player.set_spawn_position({-2, 16}, game.surfaces[global.active_surface_index]) + game.forces.player.set_spawn_position({-2, 16}, game.surfaces[global.active_surface_index]) global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], map_gen_settings, starting_items).index end - + local surface = game.surfaces[global.active_surface_index] if darkness then @@ -97,15 +102,15 @@ function Public.reset_map() surface.request_to_generate_chunks({0,0}, 2) surface.force_generate_chunk_requests() - + for x = -768 + 32, 768 - 32, 32 do surface.request_to_generate_chunks({x, 96}, 1) surface.force_generate_chunk_requests() end - - game.difficulty_settings.technology_price_multiplier = 0.5 + + game.difficulty_settings.technology_price_multiplier = 0.5 game.map_settings.enemy_evolution.destroy_factor = 0 - game.map_settings.enemy_evolution.pollution_factor = 0 + game.map_settings.enemy_evolution.pollution_factor = 0 game.map_settings.enemy_evolution.time_factor = 0 game.map_settings.enemy_expansion.enabled = true game.map_settings.enemy_expansion.max_expansion_cooldown = 3600 @@ -113,24 +118,27 @@ function Public.reset_map() game.map_settings.enemy_expansion.settler_group_max_size = 8 game.map_settings.enemy_expansion.settler_group_min_size = 16 game.map_settings.pollution.enabled = false - - game.forces.player.technologies["land-mine"].enabled = false - game.forces.player.technologies["landfill"].enabled = false + + game.forces.player.technologies["land-mine"].enabled = false + game.forces.player.technologies["landfill"].enabled = false game.forces.player.technologies["railway"].researched = true + game.forces.player.recipes["pistol"].enabled = false game.forces.player.set_spawn_position({-2, 16}, surface) - + game.forces.enemy.set_ammo_damage_modifier("bullet", 1) + game.forces.enemy.set_turret_attack_modifier("gun-turret", 1) + Locomotive.locomotive_spawn(surface, {x = 0, y = 16}) - + WD.reset_wave_defense() wave_defense_table.surface_index = global.active_surface_index wave_defense_table.target = global.locomotive_cargo wave_defense_table.nest_building_density = 32 wave_defense_table.game_lost = false - + Collapse.init() - + RPG.rpg_reset_all_players() - + set_difficulty() end @@ -151,25 +159,25 @@ local function biters_chew_rocks_faster(event) if not event.cause then return end if not event.cause.valid then return end if event.cause.force.index ~= 2 then return end --Enemy Force - event.entity.health = event.entity.health - event.final_damage_amount * 2.5 + event.entity.health = event.entity.health - event.final_damage_amount * 5 end local function hidden_biter(entity) local d = math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) - - BiterRolls.wave_defense_set_unit_raffle(d * 0.25) - + + BiterRolls.wave_defense_set_unit_raffle(d * 0.20) + local unit if math_random(1,3) == 1 then unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = entity.position}) else unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = entity.position}) end - + local m = 1 / level_depth m = m * d - - if math_random(1, 256) == 1 then + + if math_random(1, 64) == 1 then BiterHealthBooster.add_boss_unit(unit, m * 15 + 1, 0.38) else BiterHealthBooster.add_unit(unit, m * 2.5 + 1) @@ -177,8 +185,8 @@ local function hidden_biter(entity) end local function hidden_worm(entity) - BiterRolls.wave_defense_set_worm_raffle(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.25) - entity.surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = entity.position}) + BiterRolls.wave_defense_set_worm_raffle(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.20) + entity.surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = entity.position}) end local function hidden_biter_pet(event) @@ -200,29 +208,29 @@ local function hidden_treasure(event) end local projectiles = {"grenade", "explosive-rocket", "grenade", "explosive-rocket", "explosive-cannon-projectile"} -local function angry_tree(entity, cause) +local function angry_tree(entity, cause) if entity.type ~= "tree" then return end if math.abs(entity.position.y) < level_depth then return end if math_random(1,4) == 1 then hidden_biter(entity) end if math_random(1,8) == 1 then hidden_worm(entity) end if math_random(1,16) ~= 1 then return end local position = false - if cause then + if cause then if cause.valid then position = cause.position end end if not position then position = {entity.position.x + (-20 + math_random(0, 40)), entity.position.y + (-20 + math_random(0, 40))} end - + entity.surface.create_entity({ name = projectiles[math_random(1, 5)], position = entity.position, force = "neutral", source = entity.position, target = position, - max_range = 64, + max_range = 64, speed = 0.10 - }) + }) end local function give_coin(player) @@ -230,12 +238,12 @@ local function give_coin(player) end local function on_player_mined_entity(event) - if not event.entity.valid then return end + if not event.entity.valid then return end if event.entity.force.index ~= 3 then return end - + if event.entity.type == "simple-entity" then give_coin(game.players[event.player_index]) - + if math_random(1,32) == 1 then hidden_biter(event.entity) return @@ -245,17 +253,25 @@ local function on_player_mined_entity(event) return end hidden_biter_pet(event) - hidden_treasure(event) + hidden_treasure(event) end - + angry_tree(event.entity, game.players[event.player_index].character) end +local function on_pre_player_left_game(event) + local player = game.players[event.player_index] + if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end + if player.character then + global.offline_players[#global.offline_players + 1] = {index = event.player_index, tick = game.tick} + end +end + local function on_entity_died(event) local wave_defense_table = WD.get_table() if not event.entity.valid then return end - if event.entity == global.locomotive_cargo then - game.print("The cargo was destroyed!") + if event.entity == global.locomotive_cargo then + game.print("The cargo was destroyed!") wave_defense_table.game_lost = true wave_defense_table.target = nil global.game_reset_tick = game.tick + 1800 @@ -268,27 +284,27 @@ local function on_entity_died(event) if event.cause then if event.cause.valid then - if event.cause.force.index == 2 or event.cause.force.index == 3 then return end + if event.cause.force.index == 2 or event.cause.force.index == 3 then return end end end - + if event.entity.force.index == 3 then --local r_max = 15 - math.floor(math.abs(event.entity.position.y) / (level_depth * 0.5)) --if r_max < 3 then r_max = 3 end if math_random(1,8) == 1 then - hidden_biter(event.entity) + hidden_biter(event.entity) end - + if math_random(1,256) == 1 then hidden_worm(event.entity) end - + angry_tree(event.entity, event.cause) end end local function on_entity_damaged(event) - if not event.entity.valid then return end + if not event.entity.valid then return end protect_train(event) - + if not event.entity.health then return end biters_chew_rocks_faster(event) --neutral_force_player_damage_resistance(event) @@ -306,29 +322,29 @@ local function on_player_joined_game(event) local player = game.players[event.player_index] set_difficulty() - + local surface = game.surfaces[global.active_surface_index] - + if player.online_time == 0 then player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface) for item, amount in pairs(starting_items) do player.insert({name = item, count = amount}) end end - - if player.surface.index ~= global.active_surface_index and player.surface.name ~= "cargo_wagon" then + + if player.surface.index ~= global.active_surface_index and player.surface.name ~= "cargo_wagon" then player.character = nil player.set_controller({type=defines.controllers.god}) player.create_character() player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface) for item, amount in pairs(starting_items) do player.insert({name = item, count = amount}) - end + end end player_modifiers[player.index].character_mining_speed_modifier["mountain_fortress"] = 0.5 Modifier.update_player_modifiers(player) - + local tile = surface.get_tile(player.position) if tile.valid then if tile.name == "out-of-map" then @@ -341,21 +357,89 @@ local function on_player_left_game(event) set_difficulty() end +local function offline_players() + local current_tick = game.tick + local players = global.offline_players + local surface = game.surfaces[global.active_surface_index] + if #players > 0 then + --log("nonzero offline players") + local later = {} + for i = 1, #players, 1 do + if players[i] and game.players[players[i].index] and game.players[players[i].index].connected then + --game.print("deleting already online character from list") + players[i] = nil + else + if players[i] and players[i].tick < game.tick - 54000 then + --log("spawning corpse") + local player_inv = {} + local items = {} + player_inv[1] = game.players[players[i].index].get_inventory(defines.inventory.character_main) + player_inv[2] = game.players[players[i].index].get_inventory(defines.inventory.character_armor) + player_inv[3] = game.players[players[i].index].get_inventory(defines.inventory.character_guns) + player_inv[4] = game.players[players[i].index].get_inventory(defines.inventory.character_ammo) + player_inv[5] = game.players[players[i].index].get_inventory(defines.inventory.character_trash) + local e = surface.create_entity({name = "character", position = game.forces.player.get_spawn_position(surface), force = "neutral"}) + local inv = e.get_inventory(defines.inventory.character_main) + for ii = 1, 5, 1 do + if player_inv[ii].valid then + for iii = 1, #player_inv[ii], 1 do + if player_inv[ii][iii].valid then + items[#items + 1] = player_inv[ii][iii] + end + end + end + end + if #items > 0 then + for item = 1, #items, 1 do + if items[item].valid then + inv.insert(items[item]) + end + end + game.print({"chronosphere.message_accident"}, {r=0.98, g=0.66, b=0.22}) + e.die("neutral") + else + e.destroy() + end + + for ii = 1, 5, 1 do + if player_inv[ii].valid then + player_inv[ii].clear() + end + end + players[i] = nil + else + later[#later + 1] = players[i] + end + end + end + players = {} + if #later > 0 then + for i = 1, #later, 1 do + players[#players + 1] = later[i] + end + end + global.offline_players = players + end +end + local function tick() local tick = game.tick - if tick % 30 == 0 then + if tick % 30 == 0 then if tick % 1800 == 0 then Locomotive.set_player_spawn_and_refill_fish() local surface = game.surfaces[global.active_surface_index] local last_position = global.map_collapse.last_position local position = surface.find_non_colliding_position("stone-furnace", {last_position.x, last_position.y - 32}, 128, 4) - if position then + if position then local wave_defense_table = WD.get_table() wave_defense_table.spawn_position = position end - --if tick % 216000 == 0 then - -- Collapse.delete_out_of_map_chunks(surface) - --end + -- if tick % 216000 == 0 then + -- Collapse.delete_out_of_map_chunks(surface) + -- end + if global.offline_loot then + offline_players() + end end if global.game_reset_tick then if global.game_reset_tick < tick then @@ -366,7 +450,7 @@ local function tick() end Locomotive.fish_tag() end - if not collapse_enabled then return end + if not global.collapse_enabled then return end Collapse.process() end @@ -378,16 +462,16 @@ local function on_init() global.rocks_yield_ore_maximum_amount = 999 global.rocks_yield_ore_base_amount = 50 global.rocks_yield_ore_distance_modifier = 0.025 - + global.explosion_cells_destructible_tiles = { ["out-of-map"] = 1500, ["water"] = 1000, ["water-green"] = 1000, ["deepwater-green"] = 1000, ["deepwater"] = 1000, - ["water-shallow"] = 1000, + ["water-shallow"] = 1000, } - + Public.reset_map() end @@ -404,10 +488,11 @@ event.add(defines.events.on_entity_damaged, on_entity_damaged) event.add(defines.events.on_entity_died, on_entity_died) event.add(defines.events.on_player_joined_game, on_player_joined_game) event.add(defines.events.on_player_left_game, on_player_left_game) +event.add(defines.events.on_pre_player_left_game, on_pre_player_left_game) event.add(defines.events.on_player_mined_entity, on_player_mined_entity) event.add(defines.events.on_research_finished, on_research_finished) event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state) require "modules.rocks_yield_ore" -return Public \ No newline at end of file +return Public diff --git a/maps/mountain_fortress_v2/terrain.lua b/maps/mountain_fortress_v2/terrain.lua index b4fc2190..fc092bf9 100644 --- a/maps/mountain_fortress_v2/terrain.lua +++ b/maps/mountain_fortress_v2/terrain.lua @@ -11,7 +11,7 @@ local spawner_raffle = {"biter-spawner", "biter-spawner", "biter-spawner", "spit local noises = { ["no_rocks"] = {{modifier = 0.0033, weight = 1}, {modifier = 0.01, weight = 0.22}, {modifier = 0.05, weight = 0.05}, {modifier = 0.1, weight = 0.04}}, ["no_rocks_2"] = {{modifier = 0.013, weight = 1}, {modifier = 0.1, weight = 0.1}}, - ["large_caves"] = {{modifier = 0.0033, weight = 1}, {modifier = 0.01, weight = 0.22}, {modifier = 0.05, weight = 0.05}, {modifier = 0.1, weight = 0.04}}, + ["large_caves"] = {{modifier = 0.0033, weight = 1}, {modifier = 0.01, weight = 0.22}, {modifier = 0.05, weight = 0.05}, {modifier = 0.1, weight = 0.04}}, ["small_caves"] = {{modifier = 0.008, weight = 1}, {modifier = 0.03, weight = 0.15}, {modifier = 0.25, weight = 0.05}}, ["small_caves_2"] = {{modifier = 0.009, weight = 1}, {modifier = 0.05, weight = 0.25}, {modifier = 0.25, weight = 0.05}}, ["cave_ponds"] = {{modifier = 0.01, weight = 1}, {modifier = 0.1, weight = 0.06}}, @@ -21,7 +21,7 @@ local noises = { ["cave_rivers_4"] = {{modifier = 0.001, weight = 1}, {modifier = 0.01, weight = 0.11}, {modifier = 0.05, weight = 0.01}}, ["scrapyard"] = {{modifier = 0.005, weight = 1}, {modifier = 0.01, weight = 0.35}, {modifier = 0.05, weight = 0.23}, {modifier = 0.1, weight = 0.11}}, } -local level_depth = 960 +local level_depth = 704 local worm_level_modifier = 0.18 local function get_noise(name, pos, seed) @@ -52,7 +52,7 @@ local function get_oil_amount(p) return (math_abs(p.y) * 200 + 10000) * math_random(75, 125) * 0.01 end -local function process_level_10_position(p, seed, tiles, entities, markets, treasure) +local function process_level_11_position(p, seed, tiles, entities, markets, treasure) local noise_1 = get_noise("small_caves", p, seed) local noise_2 = get_noise("no_rocks_2", p, seed + 10000) @@ -61,17 +61,17 @@ local function process_level_10_position(p, seed, tiles, entities, markets, trea if math_random(1,48) == 1 then entities[#entities + 1] = {name="fish", position=p} end return end - + if noise_1 < -0.72 then tiles[#tiles + 1] = {name = "lab-dark-1", position = p} entities[#entities + 1] = {name = "uranium-ore", position = p, amount = math_abs(p.y) + 1 * 3} return end - if noise_1 > -0.30 and noise_1 < 0.30 then + if noise_1 > -0.30 and noise_1 < 0.30 then if noise_1 > -0.14 and noise_1 < 0.14 then tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,10) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end if math_random(1,256) == 1 then treasure[#treasure + 1] = p end else tiles[#tiles + 1] = {name = "out-of-map", position = p} @@ -79,36 +79,77 @@ local function process_level_10_position(p, seed, tiles, entities, markets, trea return end - if math_random(1,64) == 1 and noise_2 > 0.65 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end + if math_random(1,64) == 1 and noise_2 > 0.65 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end if math_random(1,8192) == 1 then markets[#markets + 1] = p end if math_random(1,1024) == 1 then entities[#entities + 1] = {name = "crash-site-chest-" .. math_random(1,2), position = p, force = "neutral"} end - + tiles[#tiles + 1] = {name = "tutorial-grid", position = p} end +local function process_level_10_position(p, seed, tiles, entities, markets, treasure) + local scrapyard = get_noise("scrapyard", p, seed) + + if scrapyard < -0.70 or scrapyard > 0.70 then + tiles[#tiles + 1] = {name = "grass-3", position = p} + if math_random(1,40) == 1 then treasure[#treasure + 1] = p end + return + end + + if scrapyard < -0.65 or scrapyard > 0.65 then + tiles[#tiles + 1] = {name = "water-green", position = p} + return + end + if math_abs(scrapyard) > 0.40 and math_abs(scrapyard) < 0.65 then + if math_random(1,64) == 1 then + Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) + entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} + end + tiles[#tiles + 1] = {name = "water-mud", position = p} + return + end + if math_abs(scrapyard) > 0.25 and math_abs(scrapyard) < 0.40 then + if math_random(1,128) == 1 then + Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) + entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} + end + tiles[#tiles + 1] = {name = "water-shallow", position = p} + return + end + if scrapyard > -0.15 and scrapyard < 0.15 then + if math_random(1,100) > 88 then + entities[#entities + 1] = {name = "tree-0" .. math_random(1,9), position = p} + else + if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + end + tiles[#tiles + 1] = {name = "dirt-6", position = p} + return + end + tiles[#tiles + 1] = {name = "grass-2", position = p} +end + local function process_level_9_position(p, seed, tiles, entities, markets, treasure) local maze_p = {x = math_floor(p.x - p.x % 10), y = math_floor(p.y - p.y % 10)} local maze_noise = get_noise("no_rocks_2", maze_p, seed) - + if maze_noise > -0.35 and maze_noise < 0.35 then tiles[#tiles + 1] = {name = "dirt-7", position = p} local no_rocks_2 = get_noise("no_rocks_2", p, seed) - if math_random(1,4) > 1 and no_rocks_2 > -0.5 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,3) == 1 and no_rocks_2 > -0.5 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end if math_random(1,1024) == 1 then treasure[#treasure + 1] = p end if math_random(1,256) == 1 then Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) - entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} + entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} end return end - + if maze_noise > 0 and maze_noise < 0.45 then if math_random(1,512) == 1 then markets[#markets + 1] = p end if math_random(1,256) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end - if math_random(1,32) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end + if math_random(1,32) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end return end - + if maze_noise < -0.5 or maze_noise > 0.5 then tiles[#tiles + 1] = {name = "deepwater", position = p} if math_random(1,96) == 1 then entities[#entities + 1] = {name="fish", position=p} end @@ -127,7 +168,7 @@ local scrap_entities_index = #scrap_entities --SCRAPYARD local function process_level_8_position(p, seed, tiles, entities, markets, treasure) local scrapyard = get_noise("scrapyard", p, seed) - + --Chasms local noise_cave_ponds = get_noise("cave_ponds", p, seed) local small_caves = get_noise("small_caves", p, seed) @@ -141,100 +182,100 @@ local function process_level_8_position(p, seed, tiles, entities, markets, treas return end end - + if scrapyard < -0.25 or scrapyard > 0.25 then if math_random(1, 256) == 1 then entities[#entities + 1] = {name="gun-turret", position=p, force = "enemy"} end tiles[#tiles + 1] = {name = "dirt-7", position = p} if scrapyard < -0.55 or scrapyard > 0.55 then - if math_random(1,5) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end if scrapyard < -0.28 or scrapyard > 0.28 then if math_random(1,128) == 1 then Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) - entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} + entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} end - if math_random(1,96) == 1 then entities[#entities + 1] = {name = scrap_entities[math_random(1, scrap_entities_index)], position = p, force = "enemy"} end + if math_random(1,96) == 1 then entities[#entities + 1] = {name = scrap_entities[math_random(1, scrap_entities_index)], position = p, force = "enemy"} end if math_random(1,5) > 1 then entities[#entities + 1] = {name="mineable-wreckage", position=p} end return end return end - + local cave_ponds = get_noise("cave_ponds", p, seed) if cave_ponds < -0.6 and scrapyard > -0.2 and scrapyard < 0.2 then tiles[#tiles + 1] = {name = "deepwater-green", position = p} if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end return end - + local large_caves = get_noise("large_caves", p, seed) if scrapyard > -0.15 and scrapyard < 0.15 then if math_floor(large_caves * 10) % 4 < 3 then tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,3) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end end - + if math_random(1,64) == 1 and cave_ponds > 0.6 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end - + tiles[#tiles + 1] = {name = "stone-path", position = p} end local function process_level_7_position(p, seed, tiles, entities, markets, treasure) local cave_rivers_3 = get_noise("cave_rivers_3", p, seed) - local cave_rivers_4 = get_noise("cave_rivers_4", p, seed + 50000) + local cave_rivers_4 = get_noise("cave_rivers_4", p, seed + 50000) local no_rocks_2 = get_noise("no_rocks_2", p, seed) - + if cave_rivers_3 > -0.025 and cave_rivers_3 < 0.025 and no_rocks_2 > -0.6 then tiles[#tiles + 1] = {name = "water", position = p} if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end return end - + if cave_rivers_4 > -0.025 and cave_rivers_4 < 0.025 and no_rocks_2 > -0.6 then tiles[#tiles + 1] = {name = "water", position = p} if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end return end - + local noise_ores = get_noise("no_rocks_2", p, seed + 25000) - + if cave_rivers_3 > -0.20 and cave_rivers_3 < 0.20 then - tiles[#tiles + 1] = {name = "grass-" .. math_floor(cave_rivers_3 * 32) % 3 + 1, position = p} + tiles[#tiles + 1] = {name = "grass-" .. math_floor(cave_rivers_3 * 32) % 3 + 1, position = p} if cave_rivers_3 > -0.10 and cave_rivers_3 < 0.10 then - if math_random(1,12) == 1 and no_rocks_2 > -0.25 then entities[#entities + 1] = {name = "tree-01", position=p} end + if math_random(1,8) == 1 and no_rocks_2 > -0.25 then entities[#entities + 1] = {name = "tree-01", position=p} end if math_random(1,2048) == 1 then markets[#markets + 1] = p end if noise_ores < -0.5 and no_rocks_2 > -0.6 then if cave_rivers_3 > 0 and cave_rivers_3 < 0.07 then entities[#entities + 1] = {name = "iron-ore", position=p, amount = math_abs(p.y) + 1} end - end + end end if math_random(1,64) == 1 and no_rocks_2 > 0.7 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end return end - + if cave_rivers_4 > -0.20 and cave_rivers_4 < 0.20 then tiles[#tiles + 1] = {name = "grass-" .. math_floor(cave_rivers_4 * 32) % 3 + 1, position = p} if cave_rivers_4 > -0.10 and cave_rivers_4 < 0.10 then - if math_random(1,12) == 1 and no_rocks_2 > -0.25 then entities[#entities + 1] = {name = "tree-02", position=p} end + if math_random(1,8) == 1 and no_rocks_2 > -0.25 then entities[#entities + 1] = {name = "tree-02", position=p} end if math_random(1,2048) == 1 then markets[#markets + 1] = p end if noise_ores < -0.5 and no_rocks_2 > -0.6 then if cave_rivers_4 > 0 and cave_rivers_4 < 0.07 then entities[#entities + 1] = {name = "copper-ore", position=p, amount = math_abs(p.y) + 1} end - end + end end if math_random(1,64) == 1 and no_rocks_2 > 0.7 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end return end - + --Chasms local noise_cave_ponds = get_noise("cave_ponds", p, seed) local small_caves = get_noise("small_caves", p, seed) @@ -247,17 +288,17 @@ local function process_level_7_position(p, seed, tiles, entities, markets, treas tiles[#tiles + 1] = {name = "out-of-map", position = p} return end - end - - tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,5) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end - if math_random(1,256) == 1 then treasure[#treasure + 1] = p end + end + + tiles[#tiles + 1] = {name = "dirt-7", position = p} + if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,256) == 1 then treasure[#treasure + 1] = p end end local function process_level_6_position(p, seed, tiles, entities, markets, treasure) local large_caves = get_noise("large_caves", p, seed) local cave_rivers = get_noise("cave_rivers", p, seed) - + --Chasms local noise_cave_ponds = get_noise("cave_ponds", p, seed) local small_caves = get_noise("small_caves", p, seed) @@ -271,77 +312,77 @@ local function process_level_6_position(p, seed, tiles, entities, markets, treas return end end - + if large_caves > -0.03 and large_caves < 0.03 and cave_rivers < 0.25 then tiles[#tiles + 1] = {name = "water-green", position = p} if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end return end - - if cave_rivers > -0.05 and cave_rivers < 0.05 then - if math_random(1,48) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end + + if cave_rivers > -0.1 and cave_rivers < 0.1 then + if math_random(1,36) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end if math_random(1,128) == 1 then Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) - entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} + entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} end else - tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,8) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + tiles[#tiles + 1] = {name = "dirt-7", position = p} + if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end if math_random(1,512) == 1 then treasure[#treasure + 1] = p end if math_random(1,4096) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end if math_random(1,8096) == 1 then markets[#markets + 1] = p end end end - + local function process_level_5_position(p, seed, tiles, entities, markets, treasure) local small_caves = get_noise("small_caves", p, seed) local noise_cave_ponds = get_noise("cave_ponds", p, seed) - + if small_caves > -0.14 and small_caves < 0.14 then tiles[#tiles + 1] = {name = "dirt-7", position = p} if math_random(1,768) == 1 then treasure[#treasure + 1] = p end - if math_random(1,3) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end - + if small_caves < -0.50 or small_caves > 0.50 then tiles[#tiles + 1] = {name = "deepwater-green", position = p} if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end if math_random(1,128) == 1 then Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) - entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} + entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} end return - end - + end + if small_caves > -0.30 and small_caves < 0.30 then - if noise_cave_ponds > 0.35 then + if noise_cave_ponds > 0.35 then tiles[#tiles + 1] = {name = "dirt-" .. math_random(1, 4), position = p} if math_random(1,256) == 1 then treasure[#treasure + 1] = p end if math_random(1,256) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end return - end - if noise_cave_ponds > 0.25 then + end + if noise_cave_ponds > 0.25 then tiles[#tiles + 1] = {name = "dirt-7", position = p} if math_random(1,512) == 1 then treasure[#treasure + 1] = p end - if math_random(1,2) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,4) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end end - + tiles[#tiles + 1] = {name = "out-of-map", position = p} end -local function process_level_4_position(p, seed, tiles, entities, markets, treasure) +local function process_level_4_position(p, seed, tiles, entities, markets, treasure) local noise_large_caves = get_noise("large_caves", p, seed) local noise_cave_ponds = get_noise("cave_ponds", p, seed) - local small_caves = get_noise("small_caves", p, seed) - + local small_caves = get_noise("small_caves", p, seed) + if math_abs(noise_large_caves) > 0.7 then tiles[#tiles + 1] = {name = "water", position = p} if math_random(1,16) == 1 then entities[#entities + 1] = {name="fish", position=p} end return - end + end if math_abs(noise_large_caves) > 0.6 then if math_random(1,16) == 1 then entities[#entities + 1] = {name="tree-02", position=p} end if math_random(1,32) == 1 then markets[#markets + 1] = p end @@ -351,53 +392,53 @@ local function process_level_4_position(p, seed, tiles, entities, markets, treas if math_random(1,620) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end if math_random(1,384) == 1 then Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) - entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} + entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} end if math_random(1, 1024) == 1 then treasure[#treasure + 1] = p end return end if math_abs(noise_large_caves) > 0.475 then tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,3) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,4) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end return end - + --Chasms if noise_cave_ponds < 0.15 and noise_cave_ponds > -0.15 then - if small_caves > 0.45 then + if small_caves > 0.55 then tiles[#tiles + 1] = {name = "out-of-map", position = p} return end - if small_caves < -0.45 then + if small_caves < -0.55 then tiles[#tiles + 1] = {name = "out-of-map", position = p} return end - end - + end + if small_caves > -0.15 and small_caves < 0.15 then tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,5) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,4) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end if math_random(1, 1024) == 1 then treasure[#treasure + 1] = p end return - end - - if noise_large_caves > -0.1 and noise_large_caves < 0.1 then - + end + + if noise_large_caves > -0.1 and noise_large_caves < 0.1 then + --Main Rock Terrain local no_rocks_2 = get_noise("no_rocks_2", p, seed + 75000) if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then tiles[#tiles + 1] = {name = "dirt-" .. math_floor(no_rocks_2 * 8) % 2 + 5, position = p} if math_random(1,512) == 1 then treasure[#treasure + 1] = p end - return + return end - + if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,100) > 30 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,100) > 60 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end - + tiles[#tiles + 1] = {name = "out-of-map", position = p} end @@ -406,12 +447,12 @@ local function process_level_3_position(p, seed, tiles, entities, markets, treas local small_caves_2 = get_noise("small_caves_2", p, seed + 70000) local noise_large_caves = get_noise("large_caves", p, seed + 60000) local noise_cave_ponds = get_noise("cave_ponds", p, seed) - - --Market Spots - if noise_cave_ponds < -0.77 then + + --Market Spots + if noise_cave_ponds < -0.77 then if noise_cave_ponds > -0.79 then tiles[#tiles + 1] = {name = "dirt-7", position = p} - entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} + entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} else tiles[#tiles + 1] = {name = "grass-" .. math_floor(noise_cave_ponds * 32) % 3 + 1, position = p} if math_random(1,32) == 1 then markets[#markets + 1] = p end @@ -427,51 +468,51 @@ local function process_level_3_position(p, seed, tiles, entities, markets, treas if math_random(1,16) == 1 then entities[#entities + 1] = {name="fish", position=p} end return end - + --Chasms if noise_cave_ponds < 0.12 and noise_cave_ponds > -0.12 then - if small_caves > 0.55 then + if small_caves > 0.65 then tiles[#tiles + 1] = {name = "out-of-map", position = p} return end - if small_caves < -0.55 then + if small_caves < -0.65 then tiles[#tiles + 1] = {name = "out-of-map", position = p} return end end - + --Rivers local cave_rivers = get_noise("cave_rivers", p, seed + 100000) - if cave_rivers < 0.014 and cave_rivers > -0.014 then + if cave_rivers < 0.024 and cave_rivers > -0.024 then if noise_cave_ponds > 0.2 then tiles[#tiles + 1] = {name = "water-shallow", position = p} if math_random(1,64) == 1 then entities[#entities + 1] = {name="fish", position=p} end - return + return end end local cave_rivers_2 = get_noise("cave_rivers_2", p, seed) if cave_rivers_2 < 0.024 and cave_rivers_2 > -0.024 then - if noise_cave_ponds < 0.5 then + if noise_cave_ponds < 0.4 then tiles[#tiles + 1] = {name = "water", position = p} if math_random(1,64) == 1 then entities[#entities + 1] = {name="fish", position=p} end - return + return end - end - - if noise_cave_ponds > 0.775 then + end + + if noise_cave_ponds > 0.725 then tiles[#tiles + 1] = {name = "dirt-" .. math_random(4, 6), position = p} - return - end - + return + end + local no_rocks = get_noise("no_rocks", p, seed + 25000) --Worm oil Zones - if no_rocks < 0.15 and no_rocks > -0.15 then + if no_rocks < 0.20 and no_rocks > -0.20 then if small_caves > 0.35 then tiles[#tiles + 1] = {name = "dirt-" .. math_floor(noise_cave_ponds * 32) % 7 + 1, position = p} if math_random(1,320) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end if math_random(1,50) == 1 then Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) - entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} + entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} end if math_random(1,512) == 1 then treasure[#treasure + 1] = p end if math_random(1,64) == 1 then entities[#entities + 1] = {name = "dead-tree-desert", position=p} end @@ -484,26 +525,26 @@ local function process_level_3_position(p, seed, tiles, entities, markets, treas if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then tiles[#tiles + 1] = {name = "dirt-" .. math_floor(no_rocks_2 * 8) % 2 + 5, position = p} if math_random(1,512) == 1 then treasure[#treasure + 1] = p end - return + return end - + if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,100) > 30 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,100) > 60 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end - + tiles[#tiles + 1] = {name = "out-of-map", position = p} end local function process_level_2_position(p, seed, tiles, entities, markets, treasure) - local small_caves = get_noise("small_caves", p, seed) + local small_caves = get_noise("small_caves", p, seed) local noise_large_caves = get_noise("large_caves", p, seed) - - if noise_large_caves > -0.75 and noise_large_caves < 0.75 then - + + if noise_large_caves > -0.75 and noise_large_caves < 0.75 then + local noise_cave_ponds = get_noise("cave_ponds", p, seed) - + --Chasms if noise_cave_ponds < 0.15 and noise_cave_ponds > -0.15 then if small_caves > 0.32 then @@ -514,78 +555,78 @@ local function process_level_2_position(p, seed, tiles, entities, markets, treas tiles[#tiles + 1] = {name = "out-of-map", position = p} return end - end - + end + --Green Water Ponds if noise_cave_ponds > 0.80 then tiles[#tiles + 1] = {name = "deepwater-green", position = p} if math_random(1,16) == 1 then entities[#entities + 1] = {name="fish", position=p} end return end - + --Rivers local cave_rivers = get_noise("cave_rivers", p, seed + 100000) - if cave_rivers < 0.027 and cave_rivers > -0.027 then + if cave_rivers < 0.037 and cave_rivers > -0.037 then if noise_cave_ponds < 0.1 then tiles[#tiles + 1] = {name = "water-shallow", position = p} if math_random(1,64) == 1 then entities[#entities + 1] = {name="fish", position=p} end - return + return end end - - if noise_cave_ponds > 0.76 then + + if noise_cave_ponds > 0.66 then tiles[#tiles + 1] = {name = "dirt-" .. math_random(4, 6), position = p} - return - end - - --Market Spots + return + end + + --Market Spots if noise_cave_ponds < -0.80 then tiles[#tiles + 1] = {name = "grass-" .. math_floor(noise_cave_ponds * 32) % 3 + 1, position = p} if math_random(1,32) == 1 then markets[#markets + 1] = p end if math_random(1,16) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end return end - + local no_rocks = get_noise("no_rocks", p, seed + 25000) - --Worm oil Zones - if no_rocks < 0.15 and no_rocks > -0.15 then - if small_caves > 0.35 then + --Worm oil Zones + if no_rocks < 0.20 and no_rocks > -0.20 then + if small_caves > 0.30 then tiles[#tiles + 1] = {name = "dirt-" .. math_floor(noise_cave_ponds * 32) % 7 + 1, position = p} if math_random(1,450) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end if math_random(1,64) == 1 then Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) - entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} + entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} end if math_random(1,1024) == 1 then treasure[#treasure + 1] = p end if math_random(1,64) == 1 then entities[#entities + 1] = {name = "dead-tree-desert", position=p} end return end end - - + + --Main Rock Terrain local no_rocks_2 = get_noise("no_rocks_2", p, seed + 75000) if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then tiles[#tiles + 1] = {name = "dirt-" .. math_floor(no_rocks_2 * 8) % 2 + 5, position = p} if math_random(1,512) == 1 then treasure[#treasure + 1] = p end - return + return end - + if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,100) > 30 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,100) > 55 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end - + tiles[#tiles + 1] = {name = "out-of-map", position = p} end local function process_level_1_position(p, seed, tiles, entities, markets, treasure) - local small_caves = get_noise("small_caves", p, seed) + local small_caves = get_noise("small_caves", p, seed) local noise_large_caves = get_noise("large_caves", p, seed) local noise_cave_ponds = get_noise("cave_ponds", p, seed) - + --Chasms if noise_cave_ponds < 0.12 and noise_cave_ponds > -0.12 then if small_caves > 0.55 then @@ -597,47 +638,47 @@ local function process_level_1_position(p, seed, tiles, entities, markets, treas return end end - + --Green Water Ponds if noise_cave_ponds > 0.80 then tiles[#tiles + 1] = {name = "deepwater-green", position = p} if math_random(1,16) == 1 then entities[#entities + 1] = {name="fish", position=p} end return end - + --Rivers local cave_rivers = get_noise("cave_rivers", p, seed + 100000) - if cave_rivers < 0.024 and cave_rivers > -0.024 then + if cave_rivers < 0.044 and cave_rivers > -0.044 then if noise_cave_ponds > 0 then tiles[#tiles + 1] = {name = "water-shallow", position = p} if math_random(1,64) == 1 then entities[#entities + 1] = {name="fish", position=p} end - return + return end end - + if noise_cave_ponds > 0.76 then tiles[#tiles + 1] = {name = "dirt-" .. math_random(4, 6), position = p} - return - end + return + end - --Market Spots + --Market Spots if noise_cave_ponds < -0.75 then tiles[#tiles + 1] = {name = "grass-" .. math_floor(noise_cave_ponds * 32) % 3 + 1, position = p} if math_random(1,32) == 1 then markets[#markets + 1] = p end if math_random(1,32) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end return end - + local no_rocks = get_noise("no_rocks", p, seed + 25000) --Worm oil Zones if p.y < -64 + noise_cave_ponds * 10 then - if no_rocks < 0.08 and no_rocks > -0.08 then - if small_caves > 0.35 then + if no_rocks < 0.12 and no_rocks > -0.12 then + if small_caves > 0.30 then tiles[#tiles + 1] = {name = "dirt-" .. math_floor(noise_cave_ponds * 32) % 7 + 1, position = p} if math_random(1,450) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end if math_random(1,96) == 1 then Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) - entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} + entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} end if math_random(1,1024) == 1 then treasure[#treasure + 1] = p end if math_random(1,64) == 1 then entities[#entities + 1] = {name = "dead-tree-desert", position=p} end @@ -645,19 +686,19 @@ local function process_level_1_position(p, seed, tiles, entities, markets, treas end end end - + --Main Rock Terrain local no_rocks_2 = get_noise("no_rocks_2", p, seed + 75000) - if no_rocks_2 > 0.70 or no_rocks_2 < -0.70 then + if no_rocks_2 > 0.65 or no_rocks_2 < -0.65 then tiles[#tiles + 1] = {name = "dirt-" .. math_floor(no_rocks_2 * 8) % 2 + 5, position = p} if math_random(1,32) == 1 then entities[#entities + 1] = {name = "dead-tree-desert", position=p} end if math_random(1,512) == 1 then treasure[#treasure + 1] = p end - return + return end - + if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,100) > 30 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,100) > 55 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end end local levels = { @@ -671,18 +712,19 @@ local levels = { process_level_8_position, process_level_9_position, process_level_10_position, + process_level_11_position, } local entity_functions = { ["turret"] = function(surface, entity) surface.create_entity(entity) end, ["simple-entity"] = function(surface, entity) surface.create_entity(entity) end, - ["ammo-turret"] = function(surface, entity) + ["ammo-turret"] = function(surface, entity) local e = surface.create_entity(entity) e.insert({name = "uranium-rounds-magazine", count = math_random(16, 64)}) end, - ["container"] = function(surface, entity) - Treasure(surface, entity.position, entity.name) - end, + ["container"] = function(surface, entity) + Treasure(surface, entity.position, entity.name) + end, } local function rock_chunk(surface, left_top) @@ -691,8 +733,8 @@ local function rock_chunk(surface, left_top) local markets = {} local treasure = {} local seed = surface.map_gen_settings.seed - - local level_index = math_floor((math_abs(left_top.y / level_depth)) % 10) + 1 + + local level_index = math_floor((math_abs(left_top.y / level_depth)) % 11) + 1 local process_level = levels[level_index] for y = 0, 31, 1 do @@ -710,13 +752,13 @@ local function rock_chunk(surface, left_top) market.destructible = false end end - + for _, p in pairs(treasure) do local name = "wooden-chest" if math_random(1, 6) == 1 then name = "iron-chest" end - Treasure(surface, p, name) + Treasure(surface, p, name) end - + for _, entity in pairs(entities) do if entity_functions[game.entity_prototypes[entity.name].type] then entity_functions[game.entity_prototypes[entity.name].type](surface, entity) @@ -734,11 +776,11 @@ local function border_chunk(surface, left_top) for y = 5, 31, 1 do local pos = {x = left_top.x + x, y = left_top.y + y} if math_random(1, math.ceil(pos.y + pos.y) + 64) == 1 then - surface.create_entity({name = trees[math_random(1, #trees)], position = pos}) + surface.create_entity({name = trees[math_random(1, #trees)], position = pos}) end end - end - + end + for x = 0, 31, 1 do for y = 0, 31, 1 do local pos = {x = left_top.x + x, y = left_top.y + y} @@ -765,13 +807,13 @@ local function border_chunk(surface, left_top) {name = "rock-tiny", position = pos, amount = math_random(1, 1 + math.ceil(20 - y / 2))} } } - end + end if math_random(1, math.ceil(pos.y + pos.y) + 2) == 1 then - surface.create_entity({name = rock_raffle[math_random(1, size_of_rock_raffle)], position = pos}) + surface.create_entity({name = rock_raffle[math_random(1, size_of_rock_raffle)], position = pos}) end end end - + for _, e in pairs(surface.find_entities_filtered({area = {{left_top.x, left_top.y},{left_top.x + 32, left_top.y + 32}}, type = "cliff"})) do e.destroy() end end @@ -790,15 +832,15 @@ local function biter_chunk(surface, left_top) local e = surface.create_entity({name = spawner_raffle[math_random(1, #spawner_raffle)], position = position, force = "enemy"}) e.destructible = false e.active = false - end + end end - + for i = 1, 3, 1 do local position = surface.find_non_colliding_position("big-worm-turret", tile_positions[math_random(1, #tile_positions)], 16, 2) if position then local e = surface.create_entity({name = "big-worm-turret", position = position, force = "enemy"}) e.destructible = false - end + end end --for _, e in pairs(surface.find_entities_filtered({area = {{left_top.x, left_top.y},{left_top.x + 32, left_top.y + 32}}, type = "cliff"})) do e.destroy() end end @@ -809,15 +851,15 @@ local function replace_water(surface, left_top) local p = {x = left_top.x + x, y = left_top.y + y} if surface.get_tile(p).collides_with("resource-layer") then surface.set_tiles({{name = get_replacement_tile(surface, p), position = p}}, true) - end + end end - end + end end local function out_of_map(surface, left_top) for x = 0, 31, 1 do for y = 0, 31, 1 do - surface.set_tiles({{name = "out-of-map", position = {x = left_top.x + x, y = left_top.y + y}}}) + surface.set_tiles({{name = "out-of-map", position = {x = left_top.x + x, y = left_top.y + y}}}) end end end @@ -827,7 +869,7 @@ local function wall(surface, left_top, seed) for x = 0, 31, 1 do for y = 0, 31, 1 do local p = {x = left_top.x + x, y = left_top.y + y} - local small_caves = get_noise("small_caves", p, seed) + local small_caves = get_noise("small_caves", p, seed) local cave_ponds = get_noise("cave_rivers", p, seed + 100000) if y > 9 + cave_ponds * 6 and y < 23 + small_caves * 6 then if small_caves > 0.05 or cave_ponds > 0.05 then @@ -836,22 +878,22 @@ local function wall(surface, left_top, seed) if math_random(1,48) == 1 then surface.create_entity({name = "fish", position = p}) end else surface.set_tiles({{name = "dirt-7", position = p}}) - if math_random(1, 5) ~= 1 then + if math_random(1, 2) == 1 then surface.create_entity({name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p}) end end else surface.set_tiles({{name = "dirt-7", position = p}}) - + if surface.can_place_entity({name = "stone-wall", position = p, force = "enemy"}) then - if math_random(1,512) == 1 and y > 3 and y < 28 then - if math_random(1, 2) == 1 then + if math_random(1,512) == 1 and y > 3 and y < 28 then + if math_random(1, 2) == 1 then Treasure(surface, p, "wooden-chest") else Treasure(surface, p, "iron-chest") end else - + if y < 5 or y > 26 then if y <= 15 then if math_random(1, y + 1) == 1 then @@ -865,21 +907,23 @@ local function wall(surface, left_top, seed) end end end - - end - end - + + end + end + if math_random(1, 16) == 1 then if surface.can_place_entity({name = "small-worm-turret", position = p, force = "enemy"}) then Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) surface.create_entity({name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}) end end - + if math_random(1, 32) == 1 then if surface.can_place_entity({name = "gun-turret", position = p, force = "enemy"}) then local e = surface.create_entity({name = "gun-turret", position = p, force = "enemy"}) if math_abs(p.y) < level_depth * 2.5 then + e.insert({name = "firearm-magazine", count = math_random(64, 128)}) + elseif math_abs(p.y) < level_depth * 4.5 then e.insert({name = "piercing-rounds-magazine", count = math_random(64, 128)}) else e.insert({name = "uranium-rounds-magazine", count = math_random(64, 128)}) @@ -896,11 +940,11 @@ local function process_chunk(surface, left_top) if not surface.valid then return end if left_top.x >= level_depth * 0.5 then return end if left_top.x < level_depth * -0.5 then return end - + if left_top.y % level_depth == 0 and left_top.y < 0 then wall(surface, left_top, surface.map_gen_settings.seed) return end - + if left_top.y >= 0 then replace_water(surface, left_top) end - if left_top.y > 32 then game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}}) end + if left_top.y > 32 then game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}}) end if left_top.y == -128 and left_top.x == -128 then local p = global.locomotive.position for _, entity in pairs(surface.find_entities_filtered({area = {{p.x - 3, p.y - 4},{p.x + 3, p.y + 10}}, type = "simple-entity"})) do entity.destroy() end @@ -919,4 +963,4 @@ end local event = require 'utils.event' event.add(defines.events.on_chunk_generated, on_chunk_generated) -return level_depth \ No newline at end of file +return level_depth diff --git a/maps/mountain_fortress_v2/treasure.lua b/maps/mountain_fortress_v2/treasure.lua index 59f04be5..41c813b1 100644 --- a/maps/mountain_fortress_v2/treasure.lua +++ b/maps/mountain_fortress_v2/treasure.lua @@ -3,12 +3,12 @@ local math_random = math.random local Public = {} function Public.treasure_chest(surface, position, container_name) - + local chest_raffle = {} - local chest_loot = { - {{name = "submachine-gun", count = math_random(1,3)}, weight = 3, d_min = 0.0, d_max = 0.1}, + local chest_loot = { + {{name = "submachine-gun", count = math_random(1,3)}, weight = 3, d_min = 0.0, d_max = 0.1}, {{name = "slowdown-capsule", count = math_random(16,32)}, weight = 1, d_min = 0.3, d_max = 0.7}, - {{name = "poison-capsule", count = math_random(8,16)}, weight = 3, d_min = 0.3, d_max = 1}, + {{name = "poison-capsule", count = math_random(8,16)}, weight = 3, d_min = 0.3, d_max = 1}, {{name = "uranium-cannon-shell", count = math_random(16,32)}, weight = 5, d_min = 0.6, d_max = 1}, {{name = "cannon-shell", count = math_random(16,32)}, weight = 5, d_min = 0.4, d_max = 0.7}, {{name = "explosive-uranium-cannon-shell", count = math_random(16,32)}, weight = 5, d_min = 0.6, d_max = 1}, @@ -20,7 +20,7 @@ function Public.treasure_chest(surface, position, container_name) {{name = "flamethrower", count = 1}, weight = 3, d_min = 0.3, d_max = 0.6}, {{name = "flamethrower-ammo", count = math_random(16,32)}, weight = 5, d_min = 0.3, d_max = 1}, {{name = "rocket-launcher", count = 1}, weight = 3, d_min = 0.2, d_max = 0.6}, - {{name = "rocket", count = math_random(16,32)}, weight = 5, d_min = 0.2, d_max = 0.7}, + {{name = "rocket", count = math_random(16,32)}, weight = 5, d_min = 0.2, d_max = 0.7}, {{name = "explosive-rocket", count = math_random(16,32)}, weight = 5, d_min = 0.3, d_max = 1}, {{name = "land-mine", count = math_random(16,32)}, weight = 5, d_min = 0.2, d_max = 0.7}, {{name = "grenade", count = math_random(16,32)}, weight = 5, d_min = 0.0, d_max = 0.5}, @@ -33,8 +33,8 @@ function Public.treasure_chest(surface, position, container_name) {{name = "defender-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.0, d_max = 0.7}, {{name = "distractor-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.2, d_max = 1}, {{name = "destroyer-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.3, d_max = 1}, - {{name = "atomic-bomb", count = 1}, weight = 1, d_min = 0.8, d_max = 1}, - {{name = "light-armor", count = 1}, weight = 3, d_min = 0, d_max = 0.1}, + {{name = "atomic-bomb", count = 1}, weight = 1, d_min = 0.8, d_max = 1}, + {{name = "light-armor", count = 1}, weight = 3, d_min = 0, d_max = 0.1}, {{name = "heavy-armor", count = 1}, weight = 3, d_min = 0.1, d_max = 0.3}, {{name = "modular-armor", count = 1}, weight = 2, d_min = 0.2, d_max = 0.6}, {{name = "power-armor", count = 1}, weight = 1, d_min = 0.4, d_max = 1}, @@ -50,12 +50,12 @@ function Public.treasure_chest(surface, position, container_name) --{{name = "fusion-reactor-equipment", count = 1}, weight = 1, d_min = 0.8, d_max = 1}, {{name = "night-vision-equipment", count = 1}, weight = 1, d_min = 0.3, d_max = 0.8}, {{name = "personal-laser-defense-equipment", count = 1}, weight = 1, d_min = 0.7, d_max = 1}, - + {{name = "personal-roboport-equipment", count = math_random(1,2)}, weight = 3, d_min = 0.4, d_max = 1}, --{{name = "personal-roboport-mk2-equipment", count = 1}, weight = 1, d_min = 0.9, d_max = 1}, {{name = "logistic-robot", count = math_random(5,25)}, weight = 2, d_min = 0.5, d_max = 1}, {{name = "construction-robot", count = math_random(5,25)}, weight = 5, d_min = 0.4, d_max = 1}, - + {{name = "iron-gear-wheel", count = math_random(80,100)}, weight = 3, d_min = 0.0, d_max = 0.3}, {{name = "copper-cable", count = math_random(100,200)}, weight = 3, d_min = 0.0, d_max = 0.3}, {{name = "engine-unit", count = math_random(16,32)}, weight = 2, d_min = 0.1, d_max = 0.5}, @@ -68,11 +68,11 @@ function Public.treasure_chest(surface, position, container_name) {{name = "lubricant-barrel", count = math_random(4,10)}, weight = 1, d_min = 0.3, d_max = 0.5}, {{name = "rocket-fuel", count = math_random(4,10)}, weight = 2, d_min = 0.3, d_max = 0.7}, --{{name = "computer", count = 1}, weight = 2, d_min = 0, d_max = 1}, - + {{name = "effectivity-module", count = math_random(1,4)}, weight = 2, d_min = 0.1, d_max = 1}, {{name = "productivity-module", count = math_random(1,4)}, weight = 2, d_min = 0.1, d_max = 1}, {{name = "speed-module", count = math_random(1,4)}, weight = 2, d_min = 0.1, d_max = 1}, - + {{name = "automation-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.0, d_max = 0.2}, {{name = "logistic-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.1, d_max = 0.5}, {{name = "military-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.2, d_max = 1}, @@ -83,21 +83,21 @@ function Public.treasure_chest(surface, position, container_name) {{name = "steel-plate", count = math_random(25,75)}, weight = 2, d_min = 0.1, d_max = 0.3}, {{name = "nuclear-fuel", count = 1}, weight = 2, d_min = 0.7, d_max = 1}, - + {{name = "burner-inserter", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.1}, {{name = "inserter", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.4}, - {{name = "long-handed-inserter", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.4}, + {{name = "long-handed-inserter", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.4}, {{name = "fast-inserter", count = math_random(8,16)}, weight = 3, d_min = 0.1, d_max = 1}, - {{name = "filter-inserter", count = math_random(8,16)}, weight = 1, d_min = 0.2, d_max = 1}, + {{name = "filter-inserter", count = math_random(8,16)}, weight = 1, d_min = 0.2, d_max = 1}, {{name = "stack-filter-inserter", count = math_random(4,8)}, weight = 1, d_min = 0.4, d_max = 1}, - {{name = "stack-inserter", count = math_random(4,8)}, weight = 3, d_min = 0.3, d_max = 1}, + {{name = "stack-inserter", count = math_random(4,8)}, weight = 3, d_min = 0.3, d_max = 1}, {{name = "small-electric-pole", count = math_random(16,24)}, weight = 3, d_min = 0.0, d_max = 0.3}, {{name = "medium-electric-pole", count = math_random(8,16)}, weight = 3, d_min = 0.2, d_max = 1}, {{name = "big-electric-pole", count = math_random(4,8)}, weight = 3, d_min = 0.3, d_max = 1}, {{name = "substation", count = math_random(2,4)}, weight = 3, d_min = 0.5, d_max = 1}, {{name = "wooden-chest", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.2}, {{name = "iron-chest", count = math_random(8,16)}, weight = 3, d_min = 0.1, d_max = 0.4}, - {{name = "steel-chest", count = math_random(8,16)}, weight = 3, d_min = 0.3, d_max = 1}, + {{name = "steel-chest", count = math_random(8,16)}, weight = 3, d_min = 0.3, d_max = 1}, {{name = "small-lamp", count = math_random(16,32)}, weight = 3, d_min = 0.1, d_max = 0.3}, {{name = "rail", count = math_random(25,75)}, weight = 3, d_min = 0.1, d_max = 0.6}, {{name = "assembling-machine-1", count = math_random(2,4)}, weight = 3, d_min = 0.0, d_max = 0.3}, @@ -116,22 +116,22 @@ function Public.treasure_chest(surface, position, container_name) {{name = "arithmetic-combinator", count = math_random(4,8)}, weight = 2, d_min = 0.1, d_max = 1}, {{name = "constant-combinator", count = math_random(4,8)}, weight = 2, d_min = 0.1, d_max = 1}, {{name = "decider-combinator", count = math_random(4,8)}, weight = 2, d_min = 0.1, d_max = 1}, - {{name = "power-switch", count = 1}, weight = 2, d_min = 0.1, d_max = 1}, + {{name = "power-switch", count = 1}, weight = 2, d_min = 0.1, d_max = 1}, {{name = "programmable-speaker", count = math_random(2,4)}, weight = 1, d_min = 0.1, d_max = 1}, {{name = "green-wire", count = math_random(50,99)}, weight = 4, d_min = 0.1, d_max = 1}, {{name = "red-wire", count = math_random(50,99)}, weight = 4, d_min = 0.1, d_max = 1}, {{name = "chemical-plant", count = math_random(1,3)}, weight = 3, d_min = 0.3, d_max = 1}, {{name = "burner-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.0, d_max = 0.2}, - {{name = "electric-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.2, d_max = 1}, + {{name = "electric-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.2, d_max = 1}, {{name = "express-transport-belt", count = math_random(25,75)}, weight = 3, d_min = 0.5, d_max = 1}, - {{name = "express-underground-belt", count = math_random(4,8)}, weight = 3, d_min = 0.5, d_max = 1}, + {{name = "express-underground-belt", count = math_random(4,8)}, weight = 3, d_min = 0.5, d_max = 1}, {{name = "express-splitter", count = math_random(1,4)}, weight = 3, d_min = 0.5, d_max = 1}, {{name = "fast-transport-belt", count = math_random(25,75)}, weight = 3, d_min = 0.2, d_max = 0.7}, {{name = "fast-underground-belt", count = math_random(4,8)}, weight = 3, d_min = 0.2, d_max = 0.7}, {{name = "fast-splitter", count = math_random(1,4)}, weight = 3, d_min = 0.2, d_max = 0.3}, {{name = "transport-belt", count = math_random(25,75)}, weight = 3, d_min = 0, d_max = 0.3}, {{name = "underground-belt", count = math_random(4,8)}, weight = 3, d_min = 0, d_max = 0.3}, - {{name = "splitter", count = math_random(1,4)}, weight = 3, d_min = 0, d_max = 0.3}, + {{name = "splitter", count = math_random(1,4)}, weight = 3, d_min = 0, d_max = 0.3}, --{{name = "oil-refinery", count = math_random(2,4)}, weight = 2, d_min = 0.3, d_max = 1}, {{name = "pipe", count = math_random(30,50)}, weight = 3, d_min = 0.0, d_max = 0.3}, {{name = "pipe-to-ground", count = math_random(4,8)}, weight = 1, d_min = 0.2, d_max = 0.5}, @@ -140,10 +140,10 @@ function Public.treasure_chest(surface, position, container_name) {{name = "solar-panel", count = math_random(3,6)}, weight = 3, d_min = 0.4, d_max = 0.9}, {{name = "electric-furnace", count = math_random(2,4)}, weight = 3, d_min = 0.5, d_max = 1}, {{name = "steel-furnace", count = math_random(4,8)}, weight = 3, d_min = 0.2, d_max = 0.7}, - {{name = "stone-furnace", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.2}, + {{name = "stone-furnace", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.2}, {{name = "radar", count = math_random(1,2)}, weight = 1, d_min = 0.1, d_max = 0.4}, {{name = "rail-signal", count = math_random(8,16)}, weight = 2, d_min = 0.2, d_max = 0.8}, - {{name = "rail-chain-signal", count = math_random(8,16)}, weight = 2, d_min = 0.2, d_max = 0.8}, + {{name = "rail-chain-signal", count = math_random(8,16)}, weight = 2, d_min = 0.2, d_max = 0.8}, {{name = "stone-wall", count = math_random(33,99)}, weight = 3, d_min = 0.0, d_max = 0.7}, {{name = "gate", count = math_random(16,32)}, weight = 3, d_min = 0.0, d_max = 0.7}, {{name = "storage-tank", count = math_random(2,6)}, weight = 3, d_min = 0.3, d_max = 0.6}, @@ -151,25 +151,29 @@ function Public.treasure_chest(surface, position, container_name) {{name = "express-loader", count = math_random(1,2)}, weight = 1, d_min = 0.5, d_max = 1}, {{name = "fast-loader", count = math_random(1,2)}, weight = 1, d_min = 0.2, d_max = 0.7}, {{name = "loader", count = math_random(1,2)}, weight = 1, d_min = 0.0, d_max = 0.5}, - {{name = "lab", count = math_random(1,2)}, weight = 2, d_min = 0.0, d_max = 0.3}, + {{name = "lab", count = math_random(1,2)}, weight = 2, d_min = 0.0, d_max = 0.3}, {{name = "roboport", count = 1}, weight = 2, d_min = 0.8, d_max = 1}, - {{name = "flamethrower-turret", count = 1}, weight = 3, d_min = 0.5, d_max = 1}, - {{name = "laser-turret", count = math_random(3,6)}, weight = 3, d_min = 0.5, d_max = 1}, + {{name = "flamethrower-turret", count = 1}, weight = 3, d_min = 0.5, d_max = 1}, + {{name = "laser-turret", count = math_random(3,6)}, weight = 3, d_min = 0.5, d_max = 1}, {{name = "gun-turret", count = math_random(2,4)}, weight = 3, d_min = 0.2, d_max = 0.9}, + {{name = 'crude-oil-barrel', count = math_random(2,4)}, weight = 3, d_min = 0.1, d_max = 0.3}, + {{name = 'crude-oil-barrel', count = math_random(4,8)}, weight = 3, d_min = 0.2, d_max = 0.5}, + {{name = 'crude-oil-barrel', count = math_random(8,16)}, weight = 3, d_min = 0.4, d_max = 0.7}, + {{name = 'crude-oil-barrel', count = math_random(12,24)}, weight = 3, d_min = 0.6, d_max = 0.9}, } - + local distance_to_center = (math.abs(position.y) + 1) * 0.0002 if distance_to_center > 1 then distance_to_center = 1 end - + for _, t in pairs (chest_loot) do for x = 1, t.weight, 1 do if t.d_min <= distance_to_center and t.d_max >= distance_to_center then table.insert(chest_raffle, t[1]) end - end + end end - - local e = surface.create_entity({name = container_name, position=position, force="neutral", create_build_effect_smoke = false}) + + local e = surface.create_entity({name = container_name, position=position, force="neutral", create_build_effect_smoke = false}) e.minable = false local i = e.get_inventory(defines.inventory.chest) for x = 1, math_random(2,6), 1 do @@ -178,4 +182,4 @@ function Public.treasure_chest(surface, position, container_name) end end -return Public.treasure_chest \ No newline at end of file +return Public.treasure_chest diff --git a/maps/overgrowth.lua b/maps/overgrowth.lua new file mode 100644 index 00000000..b2ad7c52 --- /dev/null +++ b/maps/overgrowth.lua @@ -0,0 +1,267 @@ +--overgrowth-- by mewmew -- + +require "on_tick_schedule" +require "modules.dynamic_landfill" +require "modules.satellite_score" +require "modules.spawners_contain_biters" +require "modules.no_deconstruction_of_neutral_entities" +require "modules.biters_yield_coins" +require "modules.rocks_yield_ore" +require "modules.ores_are_mixed" +require "modules.surrounded_by_worms" +global.average_worm_amount_per_chunk = 1.5 +require "modules.biters_attack_moving_players" +require "modules.market_friendly_fire_protection" +require "modules.trees_grow" +require "modules.trees_randomly_die" + +require "maps.overgrowth_map_info" + +local Reset = require "functions.soft_reset" +local rpg_t = require 'modules.rpg' +local kaboom = require "functions.omegakaboom" + +require "modules.difficulty_vote" + +local unearthing_biters = require "functions.unearthing_biters" + +local event = require 'utils.event' +local math_random = math.random + +local difficulties_votes = { + [1] = 11, + [2] = 10, + [3] = 9, + [4] = 8, + [5] = 7, + [6] = 6, + [7] = 5 +} + +local difficulties_votes_evo = { + [1] = 0.000016, + [2] = 0.000024, + [3] = 0.000032, + [4] = 0.000040, + [5] = 0.000048, + [6] = 0.000056, + [7] = 0.000064 +} + +local starting_items = { + ["pistol"] = 1, + ["firearm-magazine"] = 8 +} +--[[ +local function create_particles(surface, name, position, amount, cause_position) + local math_random = math.random + + local direction_mod = (-100 + math_random(0,200)) * 0.0004 + local direction_mod_2 = (-100 + math_random(0,200)) * 0.0004 + + if cause_position then + direction_mod = (cause_position.x - position.x) * 0.021 + direction_mod_2 = (cause_position.y - position.y) * 0.021 + end + + for i = 1, amount, 1 do + local m = math_random(4, 10) + local m2 = m * 0.005 + + surface.create_entity({ + name = name, + position = position, + frame_speed = 1, + vertical_speed = 0.130, + height = 0, + movement = { + (m2 - (math_random(0, m) * 0.01)) + direction_mod, + (m2 - (math_random(0, m) * 0.01)) + direction_mod_2 + } + }) + end +end +]] +local function spawn_market(surface, position) + local market = surface.create_entity({name = "market", position = position, force = "neutral"}) + --market.destructible = false + market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "wood", count = 50}}) + market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}) + market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}}) + market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'stone', count = 50}}) + market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'coal', count = 50}}) + market.add_market_item({price = {{"coin", 5}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}) + + market.add_market_item({price = {{'coin', 2}}, offer = {type = 'give-item', item = "raw-fish", count = 1}}) + market.add_market_item({price = {{'coin', 8}}, offer = {type = 'give-item', item = "grenade", count = 1}}) + market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "firearm-magazine", count = 1}}) + market.add_market_item({price = {{'coin', 16}}, offer = {type = 'give-item', item = "submachine-gun", count = 1}}) + market.add_market_item({price = {{'coin', 32}}, offer = {type = 'give-item', item = "car", count = 1}}) + return market +end + +local caption_style = {{"font", "default-bold"}, {"font_color",{ r=0.63, g=0.63, b=0.63}}, {"top_padding",2}, {"left_padding",0},{"right_padding",0},{"minimal_width",0}} +local stat_number_style = {{"font", "default-bold"}, {"font_color",{ r=0.77, g=0.77, b=0.77}}, {"top_padding",2}, {"left_padding",0},{"right_padding",0},{"minimal_width",0}} +local function tree_gui() + for _, player in pairs(game.connected_players) do + if player.gui.top["trees_defeated"] then player.gui.top["trees_defeated"].destroy() end + local b = player.gui.top.add { type = "button", caption = '[img=entity.tree-04] : ' .. global.trees_defeated, tooltip = "Trees defeated", name = "trees_defeated" } + b.style.font = "heading-1" + b.style.font_color = {r=0.00, g=0.33, b=0.00} + b.style.minimal_height = 38 + end +end + +local function get_surface_settings() + local map_gen_settings = {} + map_gen_settings.seed = math_random(1, 1000000) + map_gen_settings.water = math_random(15, 30) * 0.1 + map_gen_settings.starting_area = 1 + map_gen_settings.cliff_settings = {cliff_elevation_interval = math_random(4, 48), cliff_elevation_0 = math_random(4, 48)} + map_gen_settings.autoplace_controls = { + ["coal"] = {frequency = "2", size = "1", richness = "1"}, + ["stone"] = {frequency = "2", size = "1", richness = "1"}, + ["copper-ore"] = {frequency = "2", size = "1", richness = "1"}, + ["iron-ore"] = {frequency = "2.5", size = "1.1", richness = "1"}, + ["uranium-ore"] = {frequency = "2", size = "1", richness = "1"}, + ["crude-oil"] = {frequency = "3", size = "1", richness = "1.5"}, + ["trees"] = {frequency = "2", size = "1", richness = "0.75"}, + ["enemy-base"] = {frequency = "4", size = "1.25", richness = "1"} + } + return map_gen_settings +end + +function reset_map() + local rpg = rpg_t.get_table() + global.trees_grow_chunk_next_visit = {} + global.trees_grow_chunk_raffle = {} + global.trees_grow_chunk_position = {} + global.trees_grow_chunks_charted = {} + global.trees_grow_chunks_charted_counter = 0 + + global.current_surface = Reset.soft_reset_map(global.current_surface, get_surface_settings(), starting_items) + + reset_difficulty_poll() + + global.trees_defeated = 0 + tree_gui() + + global.market = spawn_market(global.current_surface, {x = 0, y = -8}) + + game.map_settings.enemy_evolution.time_factor = difficulties_votes_evo[4] + + if rpg then rpg_t.rpg_reset_all_players() end +end + +local function on_player_joined_game(event) + local player = game.players[event.player_index] + if player.online_time == 0 then + for item, amount in pairs(starting_items) do + player.insert({name = item, count = amount}) + end + end + + if global.current_surface then + if player.surface.name ~= global.current_surface.name then + local pos = global.current_surface.find_non_colliding_position("character", {x = 0, y = 0}, 1, 0.5) + player.teleport(pos, global.current_surface) + end + end + + if not global.market and game.tick == 0 then + global.current_surface = game.create_surface("overgrowth", get_surface_settings()) + game.forces["player"].set_spawn_position({x = 0, y = 0}, global.current_surface) + player.teleport({0,0}, global.current_surface) + reset_map() + end + + tree_gui() +end + +local function trap(entity) + local r = 8 + if global.difficulty_vote_index then r = difficulties_votes[global.difficulty_vote_index] end + if math_random(1,r) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end +end + +local function on_player_mined_entity(event) + local entity = event.entity + if not entity.valid then return end + if entity.type ~= "tree" then return end + + global.trees_defeated = global.trees_defeated + 1 + tree_gui() + + trap(entity) + + if event.player_index then + --create_particles(entity.surface, "wooden-particle", entity.position, 128, game.players[event.player_index].position) + game.players[event.player_index].insert({name = "coin", count = 1}) + return + end + + --create_particles(entity.surface, "wooden-particle", entity.position, 128) + + if event.cause then + if event.cause.force.name == "enemy" then return end + end + + entity.surface.spill_item_stack(entity.position,{name = "coin", count = 1}, true) +end + +local function on_entity_died(event) + on_player_mined_entity(event) + if event.entity == global.market then + global.map_reset_timeout = game.tick + 900 + game.print("The market has been overrun.", {r = 1, g = 0, b = 0}) + kaboom(event.entity.surface, event.entity.position, "explosive-cannon-projectile", 24, 12) + kaboom(event.entity.surface, event.entity.position, "explosive-uranium-cannon-projectile", 24, 12) + global.market = nil + end +end + +local function attack_market() + local c = 8 + if global.difficulty_vote_index then + c = global.difficulty_vote_index * 2 + game.map_settings.enemy_evolution.time_factor = difficulties_votes_evo[global.difficulty_vote_index] + end + global.current_surface.set_multi_command({ + command={ + type=defines.command.attack, + target=global.market, + distraction=defines.distraction.by_enemy + }, + unit_count = math_random(c, c * 2), + force = "enemy", + unit_search_distance=1024 + }) + global.current_surface.set_multi_command({ + command={ + type=defines.command.attack, + target=global.market, + distraction=defines.distraction.none + }, + unit_count = math_random(1, c), + force = "enemy", + unit_search_distance=1024 + }) +end + +local function tick() + if global.market then + if math_random(1, 60) == 1 then + attack_market() + end + return + end + if not global.map_reset_timeout then return end + if game.tick < global.map_reset_timeout then return end + reset_map() + global.map_reset_timeout = nil +end + +event.on_nth_tick(60, tick) +event.add(defines.events.on_player_joined_game, on_player_joined_game) +event.add(defines.events.on_player_mined_entity, on_player_mined_entity) +event.add(defines.events.on_entity_died, on_entity_died) diff --git a/modules/admins_operate_biters.lua b/modules/admins_operate_biters.lua index 951bbe47..af771b55 100644 --- a/modules/admins_operate_biters.lua +++ b/modules/admins_operate_biters.lua @@ -3,6 +3,8 @@ local math_random = math.random local math_floor = math.floor global.biter_command = {} global.biter_command.active_unit_groups = {} +global.biter_command.enabled = true +global.biter_command.whitelist = {} global.biter_command.admin_mode = true --if only admins can see and use the panel global.biter_command.teleporting = false --if teleporting is allowed for non-admins @@ -105,7 +107,8 @@ local function move_to(position, distraction) local command = { type = defines.command.go_to_location, destination = position, - distraction = distraction + distraction = distraction, + pathfind_flags = {allow_destroy_friendly_entities = true} } return command end @@ -364,12 +367,23 @@ end ----------------------------gui----------------------- local function top_button(player) - if player.gui.top["biter_commands"] then return end + if player.gui.top["biter_commands"] then + if global.biter_command.enabled or global.biter_command.whitelist[player.name] == true then + player.gui.top["biter_commands"].visible = true + return + else + --player.gui.top["biter_commands"].destroy() + player.gui.top["biter_commands"].visible = false + return + end + end if player.admin or not global.biter_command.admin_mode then - local button = player.gui.top.add({type = "sprite-button", name = "biter_commands", sprite = "entity/medium-spitter"}) - button.style.minimal_height = 38 - button.style.minimal_width = 38 - button.style.padding = -2 + if global.biter_command.enabled or global.biter_command.whitelist[player.name] == true then + local button = player.gui.top.add({type = "sprite-button", name = "biter_commands", sprite = "entity/medium-spitter"}) + button.style.minimal_height = 38 + button.style.minimal_width = 38 + button.style.padding = -2 + end end end @@ -540,8 +554,18 @@ local function on_gui_click(event) if not event.element.valid then return end local player = game.players[event.element.player_index] if event.element.name == "biter_commands" then --top button press - biter_panel(player) - return + if global.biter_command.enabled or global.biter_command.whitelist[player.name] == true then + biter_panel(player) + return + else + top_button(player) + player.print("Biter commander module is disabled.") + return + end + else + if global.biter_command.enabled or global.biter_command.whitelist[player.name] == true then + top_button(player) + end end if event.element.type ~= "button" and event.element.type ~= "sprite-button" then return end --if event.frame.name ~= "biter_panel" then return end diff --git a/modules/railgun_enhancer.lua b/modules/railgun_enhancer.lua index bdd20f2f..894ff150 100644 --- a/modules/railgun_enhancer.lua +++ b/modules/railgun_enhancer.lua @@ -73,7 +73,7 @@ end local function on_entity_damaged(event) if not event.cause then return end - if event.cause.name ~= "player" then return end + if event.cause.name ~= "character" then return end if event.damage_type.name ~= "physical" then return end if event.original_damage_amount ~= 100 then return end diff --git a/modules/wave_defense/main.lua b/modules/wave_defense/main.lua index 801576d0..d890f68a 100644 --- a/modules/wave_defense/main.lua +++ b/modules/wave_defense/main.lua @@ -28,6 +28,21 @@ local function debug_print(msg) print("WaveDefense: " .. msg) end +local function is_closer(pos1, pos2, pos) + return ((pos1.x - pos.x)^2 + (pos1.y - pos.y)^2) < ((pos2.x - pos.x)^2 + (pos2.y - pos.y)^2) +end + +local function shuffle_distance(tbl, position) + local size = #tbl + for i = size, 1, -1 do + local rand = math_random(size) + if is_closer(tbl[i].position, tbl[rand].position, position) and i > rand then + tbl[i], tbl[rand] = tbl[rand], tbl[i] + end + end + return tbl +end + local function is_unit_valid(biter) local wave_defense_table = WD.get_table() if not biter.entity then debug_print("is_unit_valid - unit destroyed - does no longer exist") return false end @@ -104,12 +119,12 @@ local function set_main_target() if wave_defense_table.target then if wave_defense_table.target.valid then return end end - + local target = SideTargets.get_side_target() if not target then target = get_random_character(wave_defense_table) end if not target then return end - - wave_defense_table.target = target + + wave_defense_table.target = target debug_print("set_main_target -- New main target " .. target.name .. " at position x" .. target.position.x .. " y" .. target.position.y .. " selected.") end @@ -193,7 +208,7 @@ local function spawn_biter(surface, is_boss_biter) if not is_boss_biter then if not can_units_spawn() then return end end - + local name if math_random(1,100) > 73 then name = BiterRolls.wave_defense_roll_spitter_name() @@ -215,17 +230,17 @@ end local function set_next_wave() local wave_defense_table = WD.get_table() wave_defense_table.wave_number = wave_defense_table.wave_number + 1 - + local threat_gain = wave_defense_table.wave_number * wave_defense_table.threat_gain_multiplier if wave_defense_table.wave_number > 1000 then threat_gain = threat_gain * (wave_defense_table.wave_number * 0.001) end if wave_defense_table.wave_number % 25 == 0 then wave_defense_table.boss_wave = true - threat_gain = threat_gain * 2 + threat_gain = threat_gain * 2 end - - wave_defense_table.threat = wave_defense_table.threat + math_floor(threat_gain) + + wave_defense_table.threat = wave_defense_table.threat + math_floor(threat_gain) wave_defense_table.last_wave = wave_defense_table.next_wave wave_defense_table.next_wave = game.tick + wave_defense_table.wave_interval end @@ -239,7 +254,6 @@ local function get_commmands(group) if math_random(1,2) == 1 then local side_target = SideTargets.get_side_target() if side_target then - debug_print("get_side_target -- " .. side_target.name .. " at position x" .. side_target.position.x .. " y" .. side_target.position.y .. " selected.") local target_position = side_target.position local distance_to_target = math_floor(math_sqrt((target_position.x - group_position.x) ^ 2 + (target_position.y - group_position.y) ^ 2)) local steps = math_floor(distance_to_target / step_length) + 1 @@ -252,16 +266,49 @@ local function get_commmands(group) end for i = 1, steps, 1 do + local old_position = group_position group_position.x = group_position.x + vector[1] - group_position.y = group_position.y + vector[2] - local position = group.surface.find_non_colliding_position("small-biter", group_position, step_length, 2) + group_position.y = group_position.y + vector[2] + local obstacles = group.surface.find_entities_filtered{position = old_position, radius = step_length, type = {"simple-entity", "tree"}, limit = 50} + if obstacles then + shuffle_distance(obstacles, old_position) + for i = 1, #obstacles, 1 do + if obstacles[i].valid then + commands[#commands + 1] = { + type = defines.command.attack, + target = obstacles[i], + distraction = defines.distraction.by_enemy + } + end + end + end + local position = group.surface.find_non_colliding_position("rocket-silo", group_position, step_length, 4) if position then + -- commands[#commands + 1] = { + -- type = defines.command.go_to_location, + -- destination = {x = position.x, y = position.y}, + -- distraction = defines.distraction.by_anything + -- } commands[#commands + 1] = { type = defines.command.attack_area, destination = {x = position.x, y = position.y}, radius = 16, distraction = defines.distraction.by_anything } + else + local obstacles = group.surface.find_entities_filtered{position = group_position, radius = step_length, type = {"simple-entity", "tree"}, limit = 50} + if obstacles then + shuffle_distance(obstacles, old_position) + for i = 1, #obstacles, 1 do + if obstacles[i].valid then + commands[#commands + 1] = { + type = defines.command.attack, + target = obstacles[i], + distraction = defines.distraction.by_enemy + } + end + end + end end end @@ -285,9 +332,23 @@ local function get_commmands(group) end for i = 1, steps, 1 do + local old_position = group_position group_position.x = group_position.x + vector[1] group_position.y = group_position.y + vector[2] - local position = group.surface.find_non_colliding_position("small-biter", group_position, step_length, 1) + local obstacles = group.surface.find_entities_filtered{position = old_position, radius = step_length / 2, type = {"simple-entity", "tree"}, limit = 50} + if obstacles then + shuffle_distance(obstacles, old_position) + for i = 1, #obstacles, 1 do + if obstacles[i].valid then + commands[#commands + 1] = { + type = defines.command.attack, + target = obstacles[i], + distraction = defines.distraction.by_enemy + } + end + end + end + local position = group.surface.find_non_colliding_position("rocket-silo", group_position, step_length, 1) if position then commands[#commands + 1] = { type = defines.command.attack_area, @@ -320,15 +381,15 @@ local function command_unit_group(group) wave_defense_table.unit_group_last_command[group.group_number] = game.tick - (wave_defense_table.unit_group_command_delay + 1) end if wave_defense_table.unit_group_last_command[group.group_number] then - if wave_defense_table.unit_group_last_command[group.group_number] + wave_defense_table.unit_group_command_delay > game.tick then return end + if wave_defense_table.unit_group_last_command[group.group_number] + wave_defense_table.unit_group_command_delay > game.tick then return end end - + group.set_command({ type = defines.command.compound, structure_type = defines.compound_command.return_last, commands = get_commmands(group) }) - + wave_defense_table.unit_group_last_command[group.group_number] = game.tick end @@ -356,22 +417,22 @@ local function spawn_unit_group() set_group_spawn_position(surface) local pos = wave_defense_table.spawn_position if not surface.can_place_entity({name = "small-biter", position = pos}) then return end - + local radius = 10 local area = {left_top = {pos.x - radius, pos.y - radius}, right_bottom = {pos.x + radius, pos.y + radius}} for k,v in pairs(surface.find_entities_filtered{area = area, name = "land-mine"}) do if v and v.valid then v.die() end end - + BiterRolls.wave_defense_set_unit_raffle(wave_defense_table.wave_number) - + debug_print("Spawning unit group at x" .. wave_defense_table.spawn_position.x .." y" .. wave_defense_table.spawn_position.y) - local unit_group = surface.create_unit_group({position = wave_defense_table.spawn_position, force = "enemy"}) + local unit_group = surface.create_unit_group({position = wave_defense_table.spawn_position, force = "enemy"}) local group_size = math_floor(wave_defense_table.average_unit_group_size * group_size_modifier_raffle[math_random(1, group_size_modifier_raffle_size)]) for _ = 1, group_size, 1 do local biter = spawn_biter(surface) if not biter then break end unit_group.add_member(biter) end - + if wave_defense_table.boss_wave then local count = math_random(1, math_floor(wave_defense_table.wave_number * 0.01) + 2) if count > 8 then count = 8 end @@ -383,7 +444,7 @@ local function spawn_unit_group() wave_defense_table.boss_wave = false end - table_insert(wave_defense_table.unit_groups, unit_group) + table_insert(wave_defense_table.unit_groups, unit_group) return true end @@ -391,7 +452,7 @@ local function log_threat() local wave_defense_table = WD.get_table() wave_defense_table.threat_log_index = wave_defense_table.threat_log_index + 1 wave_defense_table.threat_log[wave_defense_table.threat_log_index] = wave_defense_table.threat - if wave_defense_table.threat_log_index > 900 then wave_defense_table.threat_log[wave_defense_table.threat_log_index - 901] = nil end + if wave_defense_table.threat_log_index > 900 then wave_defense_table.threat_log[wave_defense_table.threat_log_index - 901] = nil end end local tick_tasks = { @@ -408,15 +469,15 @@ local tick_tasks = { local function on_tick() local wave_defense_table = WD.get_table() if wave_defense_table.game_lost then return end - + if game.tick > wave_defense_table.next_wave then set_next_wave() end local t = game.tick % 300 local t2 = game.tick % 18000 - + if tick_tasks[t] then tick_tasks[t]() end if tick_tasks[t2] then tick_tasks[t2]() end - + if game.tick % 60 == 0 then log_threat() end for _, player in pairs(game.connected_players) do update_gui(player) end end @@ -427,4 +488,4 @@ local function on_init() end event.on_nth_tick(30, on_tick) -return Public \ No newline at end of file +return Public diff --git a/modules/wave_defense/table.lua b/modules/wave_defense/table.lua index dfebe27c..b004c303 100644 --- a/modules/wave_defense/table.lua +++ b/modules/wave_defense/table.lua @@ -41,7 +41,7 @@ function Public.reset_wave_defense() wave_defense.threat_log_index = 0 wave_defense.unit_groups = {} wave_defense.unit_group_command_delay = 3600 * 15 - wave_defense.unit_group_command_step_length = 80 + wave_defense.unit_group_command_step_length = 20 wave_defense.unit_group_last_command = {} wave_defense.wave_interval = 3600 wave_defense.wave_number = 0 From 861ad308b4f030efb2229d7ff30b44e0ed1c5faf Mon Sep 17 00:00:00 2001 From: hanakocz Date: Wed, 8 Apr 2020 20:29:54 +0200 Subject: [PATCH 45/70] Delete control.lua --- control.lua | 161 ---------------------------------------------------- 1 file changed, 161 deletions(-) delete mode 100644 control.lua diff --git a/control.lua b/control.lua deleted file mode 100644 index 8eac43dd..00000000 --- a/control.lua +++ /dev/null @@ -1,161 +0,0 @@ -require 'utils.data_stages' -_LIFECYCLE = _STAGE.control -- Control stage -_DEBUG = false -_DUMP_ENV = false - -require 'utils.server' -require "utils.server_commands" -require "utils.utils" -require "utils.table" -require "utils.color_data" -require "utils.session_data" -require "chatbot" -require "commands" -require "antigrief" -require "modules.corpse_markers" -require "modules.floaty_chat" -require "modules.autohotbar" - -require "comfy_panel.main" -require "comfy_panel.player_list" -require "comfy_panel.admin" -require "comfy_panel.group" -require "comfy_panel.poll" -require "comfy_panel.score" -require "comfy_panel.config" - -require "modules.autostash" - ----- enable modules here ---- -require "modules.admins_operate_biters" ---require "modules.the_floor_is_lava" ---require "modules.biters_landfill_on_death" ---require "modules.autodecon_when_depleted" ---require "modules.biter_noms_you" ---require "modules.biters_avoid_damage" ---require "modules.biters_double_damage" ---require "modules.burden" ---require "modules.comfylatron" ---require "modules.spaghett_challenge" ---require "modules.dangerous_goods" ---require "modules.dynamic_landfill" ---require "modules.explosive_biters" ---require "modules.explosive_player_respawn" ---require "modules.explosives_are_explosive" ---require "modules.fish_respawner" ---require "modules.fluids_are_explosive" ---require "modules.hunger" ---require "modules.hunger_games" ---require "modules.players_trample_paths" ---require "modules.railgun_enhancer" ---require "modules.restrictive_fluid_mining" ---require "modules.satellite_score" ---require "modules.show_health" ---require "modules.splice_double" ---require "modules.ores_are_mixed" ---require "modules.team_teleport" --(REQUIRES "on_tick_schedule" !) ---require "modules.surrounded_by_worms" ---require "modules.more_attacks" ---require "modules.evolution_extended" ---require "modules.no_blueprint_library" ---require "modules.explosives" ---require "modules.biter_pets" ---require "modules.no_solar" ---require "modules.biter_reanimator" ---require "modules.wave_defense.main" ---require "modules.fjei.main" ---require "utils.one_dimensional_noise" ------------------------------ - ----- enable maps here ---- (maps higher up in the list may be more actually playable) -require "maps.chronosphere.main" ---require "maps.fish_defender.main" ---require "maps.biter_battles_v2.main" ---require "maps.native_war.main" ---require "maps.mountain_fortress_v2.main" ---require "maps.island_troopers.main" ---require "maps.biter_hatchery.main" ---require "maps.junkyard_pvp.main" ---require "maps.scrapyard.main" ---require "maps.tank_conquest.tank_conquest" ---require "maps.territorial_control" ---require "maps.cave_choppy.cave_miner" ---require "maps.wave_of_death.WoD" ---require "maps.planet_prison" ---require "maps.stone_maze.main" ---require "maps.choppy" ---require "maps.overgrowth" ---require "maps.quarters" ---require "maps.tetris.main" ---require "maps.maze_challenge" ---require "maps.cave_miner" ---require "maps.labyrinth" ---require "maps.junkyard" ---require "maps.hedge_maze" ---require "maps.spooky_forest" ---require "maps.mixed_railworld" ---require "maps.biter_battles.biter_battles" ---require "maps.fish_defender_v1.fish_defender" ---require "maps.mountain_fortress" ---require "maps.rocky_waste" ---require "maps.nightfall" ---require "maps.lost" ---require "maps.rivers" ---require "maps.atoll" ---require "maps.cratewood_forest" ---require "maps.tank_battles" ---require "maps.spiral_troopers" ---require "maps.refactor-io" ---require "maps.desert_oasis" ---require "maps.lost_desert" ---require "maps.stoneblock" ---require "maps.wave_defense" ---require "maps.crossing" ---require "maps.anarchy" ---require "maps.spaghettorio" ---require "maps.blue_beach" ---require "maps.deep_jungle" ---require "maps.rainbow_road" ---require "maps.pitch_black.main" ---require "maps.cube" ---require "maps.forest_circle" ------------------------------ - ----- more modules here ---- ---require "modules.towny.main" ---require "modules.rpg" ---require "modules.trees_grow" ---require "modules.trees_randomly_die" - ---require "terrain_layouts.caves" ---require "terrain_layouts.cone_to_east" ---require "terrain_layouts.biters_and_resources_east" ---require "terrain_layouts.scrap_01" ---require "terrain_layouts.watery_world" ------- - -if _DUMP_ENV then - require 'utils.dump_env' -end -if _DEBUG then - require 'utils.debug.command' -end - -local function on_player_created(event) - local player = game.players[event.player_index] - player.gui.top.style = 'slot_table_spacing_horizontal_flow' - player.gui.left.style = 'slot_table_spacing_vertical_flow' -end - -local function on_init() - game.forces.player.research_queue_enabled = true -end - -local loaded = _G.package.loaded -function require(path) - return loaded[path] or error('Can only require files at runtime that have been required in the control stage.', 2) -end - -local event = require 'utils.event' -event.on_init(on_init) -event.add(defines.events.on_player_created, on_player_created) From f0cec1dc5d4afc748cd48f5a7837cd0efd349fbc Mon Sep 17 00:00:00 2001 From: hanakocz Date: Wed, 8 Apr 2020 20:30:13 +0200 Subject: [PATCH 46/70] Delete overgrowth.lua --- maps/overgrowth.lua | 267 -------------------------------------------- 1 file changed, 267 deletions(-) delete mode 100644 maps/overgrowth.lua diff --git a/maps/overgrowth.lua b/maps/overgrowth.lua deleted file mode 100644 index b2ad7c52..00000000 --- a/maps/overgrowth.lua +++ /dev/null @@ -1,267 +0,0 @@ ---overgrowth-- by mewmew -- - -require "on_tick_schedule" -require "modules.dynamic_landfill" -require "modules.satellite_score" -require "modules.spawners_contain_biters" -require "modules.no_deconstruction_of_neutral_entities" -require "modules.biters_yield_coins" -require "modules.rocks_yield_ore" -require "modules.ores_are_mixed" -require "modules.surrounded_by_worms" -global.average_worm_amount_per_chunk = 1.5 -require "modules.biters_attack_moving_players" -require "modules.market_friendly_fire_protection" -require "modules.trees_grow" -require "modules.trees_randomly_die" - -require "maps.overgrowth_map_info" - -local Reset = require "functions.soft_reset" -local rpg_t = require 'modules.rpg' -local kaboom = require "functions.omegakaboom" - -require "modules.difficulty_vote" - -local unearthing_biters = require "functions.unearthing_biters" - -local event = require 'utils.event' -local math_random = math.random - -local difficulties_votes = { - [1] = 11, - [2] = 10, - [3] = 9, - [4] = 8, - [5] = 7, - [6] = 6, - [7] = 5 -} - -local difficulties_votes_evo = { - [1] = 0.000016, - [2] = 0.000024, - [3] = 0.000032, - [4] = 0.000040, - [5] = 0.000048, - [6] = 0.000056, - [7] = 0.000064 -} - -local starting_items = { - ["pistol"] = 1, - ["firearm-magazine"] = 8 -} ---[[ -local function create_particles(surface, name, position, amount, cause_position) - local math_random = math.random - - local direction_mod = (-100 + math_random(0,200)) * 0.0004 - local direction_mod_2 = (-100 + math_random(0,200)) * 0.0004 - - if cause_position then - direction_mod = (cause_position.x - position.x) * 0.021 - direction_mod_2 = (cause_position.y - position.y) * 0.021 - end - - for i = 1, amount, 1 do - local m = math_random(4, 10) - local m2 = m * 0.005 - - surface.create_entity({ - name = name, - position = position, - frame_speed = 1, - vertical_speed = 0.130, - height = 0, - movement = { - (m2 - (math_random(0, m) * 0.01)) + direction_mod, - (m2 - (math_random(0, m) * 0.01)) + direction_mod_2 - } - }) - end -end -]] -local function spawn_market(surface, position) - local market = surface.create_entity({name = "market", position = position, force = "neutral"}) - --market.destructible = false - market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "wood", count = 50}}) - market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}) - market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}}) - market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'stone', count = 50}}) - market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'coal', count = 50}}) - market.add_market_item({price = {{"coin", 5}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}) - - market.add_market_item({price = {{'coin', 2}}, offer = {type = 'give-item', item = "raw-fish", count = 1}}) - market.add_market_item({price = {{'coin', 8}}, offer = {type = 'give-item', item = "grenade", count = 1}}) - market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "firearm-magazine", count = 1}}) - market.add_market_item({price = {{'coin', 16}}, offer = {type = 'give-item', item = "submachine-gun", count = 1}}) - market.add_market_item({price = {{'coin', 32}}, offer = {type = 'give-item', item = "car", count = 1}}) - return market -end - -local caption_style = {{"font", "default-bold"}, {"font_color",{ r=0.63, g=0.63, b=0.63}}, {"top_padding",2}, {"left_padding",0},{"right_padding",0},{"minimal_width",0}} -local stat_number_style = {{"font", "default-bold"}, {"font_color",{ r=0.77, g=0.77, b=0.77}}, {"top_padding",2}, {"left_padding",0},{"right_padding",0},{"minimal_width",0}} -local function tree_gui() - for _, player in pairs(game.connected_players) do - if player.gui.top["trees_defeated"] then player.gui.top["trees_defeated"].destroy() end - local b = player.gui.top.add { type = "button", caption = '[img=entity.tree-04] : ' .. global.trees_defeated, tooltip = "Trees defeated", name = "trees_defeated" } - b.style.font = "heading-1" - b.style.font_color = {r=0.00, g=0.33, b=0.00} - b.style.minimal_height = 38 - end -end - -local function get_surface_settings() - local map_gen_settings = {} - map_gen_settings.seed = math_random(1, 1000000) - map_gen_settings.water = math_random(15, 30) * 0.1 - map_gen_settings.starting_area = 1 - map_gen_settings.cliff_settings = {cliff_elevation_interval = math_random(4, 48), cliff_elevation_0 = math_random(4, 48)} - map_gen_settings.autoplace_controls = { - ["coal"] = {frequency = "2", size = "1", richness = "1"}, - ["stone"] = {frequency = "2", size = "1", richness = "1"}, - ["copper-ore"] = {frequency = "2", size = "1", richness = "1"}, - ["iron-ore"] = {frequency = "2.5", size = "1.1", richness = "1"}, - ["uranium-ore"] = {frequency = "2", size = "1", richness = "1"}, - ["crude-oil"] = {frequency = "3", size = "1", richness = "1.5"}, - ["trees"] = {frequency = "2", size = "1", richness = "0.75"}, - ["enemy-base"] = {frequency = "4", size = "1.25", richness = "1"} - } - return map_gen_settings -end - -function reset_map() - local rpg = rpg_t.get_table() - global.trees_grow_chunk_next_visit = {} - global.trees_grow_chunk_raffle = {} - global.trees_grow_chunk_position = {} - global.trees_grow_chunks_charted = {} - global.trees_grow_chunks_charted_counter = 0 - - global.current_surface = Reset.soft_reset_map(global.current_surface, get_surface_settings(), starting_items) - - reset_difficulty_poll() - - global.trees_defeated = 0 - tree_gui() - - global.market = spawn_market(global.current_surface, {x = 0, y = -8}) - - game.map_settings.enemy_evolution.time_factor = difficulties_votes_evo[4] - - if rpg then rpg_t.rpg_reset_all_players() end -end - -local function on_player_joined_game(event) - local player = game.players[event.player_index] - if player.online_time == 0 then - for item, amount in pairs(starting_items) do - player.insert({name = item, count = amount}) - end - end - - if global.current_surface then - if player.surface.name ~= global.current_surface.name then - local pos = global.current_surface.find_non_colliding_position("character", {x = 0, y = 0}, 1, 0.5) - player.teleport(pos, global.current_surface) - end - end - - if not global.market and game.tick == 0 then - global.current_surface = game.create_surface("overgrowth", get_surface_settings()) - game.forces["player"].set_spawn_position({x = 0, y = 0}, global.current_surface) - player.teleport({0,0}, global.current_surface) - reset_map() - end - - tree_gui() -end - -local function trap(entity) - local r = 8 - if global.difficulty_vote_index then r = difficulties_votes[global.difficulty_vote_index] end - if math_random(1,r) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end -end - -local function on_player_mined_entity(event) - local entity = event.entity - if not entity.valid then return end - if entity.type ~= "tree" then return end - - global.trees_defeated = global.trees_defeated + 1 - tree_gui() - - trap(entity) - - if event.player_index then - --create_particles(entity.surface, "wooden-particle", entity.position, 128, game.players[event.player_index].position) - game.players[event.player_index].insert({name = "coin", count = 1}) - return - end - - --create_particles(entity.surface, "wooden-particle", entity.position, 128) - - if event.cause then - if event.cause.force.name == "enemy" then return end - end - - entity.surface.spill_item_stack(entity.position,{name = "coin", count = 1}, true) -end - -local function on_entity_died(event) - on_player_mined_entity(event) - if event.entity == global.market then - global.map_reset_timeout = game.tick + 900 - game.print("The market has been overrun.", {r = 1, g = 0, b = 0}) - kaboom(event.entity.surface, event.entity.position, "explosive-cannon-projectile", 24, 12) - kaboom(event.entity.surface, event.entity.position, "explosive-uranium-cannon-projectile", 24, 12) - global.market = nil - end -end - -local function attack_market() - local c = 8 - if global.difficulty_vote_index then - c = global.difficulty_vote_index * 2 - game.map_settings.enemy_evolution.time_factor = difficulties_votes_evo[global.difficulty_vote_index] - end - global.current_surface.set_multi_command({ - command={ - type=defines.command.attack, - target=global.market, - distraction=defines.distraction.by_enemy - }, - unit_count = math_random(c, c * 2), - force = "enemy", - unit_search_distance=1024 - }) - global.current_surface.set_multi_command({ - command={ - type=defines.command.attack, - target=global.market, - distraction=defines.distraction.none - }, - unit_count = math_random(1, c), - force = "enemy", - unit_search_distance=1024 - }) -end - -local function tick() - if global.market then - if math_random(1, 60) == 1 then - attack_market() - end - return - end - if not global.map_reset_timeout then return end - if game.tick < global.map_reset_timeout then return end - reset_map() - global.map_reset_timeout = nil -end - -event.on_nth_tick(60, tick) -event.add(defines.events.on_player_joined_game, on_player_joined_game) -event.add(defines.events.on_player_mined_entity, on_player_mined_entity) -event.add(defines.events.on_entity_died, on_entity_died) From 300671f91695e6b0a6e376ab3e704de65923db98 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Wed, 8 Apr 2020 20:30:24 +0200 Subject: [PATCH 47/70] Delete main.lua --- maps/mountain_fortress_v2/main.lua | 498 ----------------------------- 1 file changed, 498 deletions(-) delete mode 100644 maps/mountain_fortress_v2/main.lua diff --git a/maps/mountain_fortress_v2/main.lua b/maps/mountain_fortress_v2/main.lua deleted file mode 100644 index 716bc639..00000000 --- a/maps/mountain_fortress_v2/main.lua +++ /dev/null @@ -1,498 +0,0 @@ --- Mountain digger fortress, protect the cargo wagon! -- by MewMew - - --enable / disable collapsing of the map -global.collapse_enabled = true -global.offline_loot = true -local darkness = false - -require "player_modifiers" -require "functions.soft_reset" -require "functions.basic_markets" - -local RPG = require "modules.rpg" -require "modules.wave_defense.main" -require "modules.biters_yield_coins" -require "modules.no_deconstruction_of_neutral_entities" -require "modules.no_solar" -require "modules.shotgun_buff" -require "modules.explosives" -require "modules.mineable_wreckage_yields_scrap" -require "modules.rocks_broken_paint_tiles" -require "modules.rocks_heal_over_time" -require "modules.rocks_yield_ore_veins" -local level_depth = require "maps.mountain_fortress_v2.terrain" -local Collapse = require "maps.mountain_fortress_v2.collapse" -require "maps.mountain_fortress_v2.flamethrower_nerf" -local BiterRolls = require "modules.wave_defense.biter_rolls" -local BiterHealthBooster = require "modules.biter_health_booster" -local Reset = require "functions.soft_reset" -local Pets = require "modules.biter_pets" -local Map = require "modules.map_info" -local WD = require "modules.wave_defense.table" -local Treasure = require "maps.mountain_fortress_v2.treasure" -local Locomotive = require "maps.mountain_fortress_v2.locomotive" -local Modifier = require "player_modifiers" -local math_random = math.random -local Public = {} - -local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16, ['wood'] = 16, ['explosives'] = 32} -local treasure_chest_messages = { - "You notice an old crate within the rubble. It's filled with treasure!", - "You find a chest underneath the broken rocks. It's filled with goodies!", - "We has found the precious!", -} - -local function set_difficulty() - local wave_defense_table = WD.get_table() - local player_count = #game.connected_players - - wave_defense_table.max_active_biters = 1024 - - -- threat gain / wave - wave_defense_table.threat_gain_multiplier = 2 + player_count * 0.1 - - --1 additional map collapse tile / 8 players in game - global.map_collapse.speed = math.floor(player_count * 0.125) + 1 - - --20 Players for fastest wave_interval - wave_defense_table.wave_interval = 3600 - player_count * 90 - if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end -end - -function Public.reset_map() - for _,player in pairs(game.players) do - if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end - end - local wave_defense_table = WD.get_table() - global.chunk_queue = {} - global.offline_players = {} - - if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end - - local map_gen_settings = { - ["seed"] = math_random(1, 1000000), - ["width"] = level_depth, - ["water"] = 0.1, - ["starting_area"] = 1, - ["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0}, - ["default_enable_all_autoplace_controls"] = true, - ["autoplace_settings"] = { - ["entity"] = {treat_missing_as_default = false}, - ["tile"] = {treat_missing_as_default = true}, - ["decorative"] = {treat_missing_as_default = true}, - }, - } - - if not global.active_surface_index then - global.active_surface_index = game.create_surface("mountain_fortress", map_gen_settings).index - else - game.forces.player.set_spawn_position({-2, 16}, game.surfaces[global.active_surface_index]) - global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], map_gen_settings, starting_items).index - end - - local surface = game.surfaces[global.active_surface_index] - - if darkness then - surface.min_brightness = 0.10 - surface.brightness_visual_weights = {0.90, 0.90, 0.90} - surface.daytime = 0.42 - surface.freeze_daytime = true - surface.solar_power_multiplier = 999 - end - - surface.request_to_generate_chunks({0,0}, 2) - surface.force_generate_chunk_requests() - - for x = -768 + 32, 768 - 32, 32 do - surface.request_to_generate_chunks({x, 96}, 1) - surface.force_generate_chunk_requests() - end - - game.difficulty_settings.technology_price_multiplier = 0.5 - game.map_settings.enemy_evolution.destroy_factor = 0 - game.map_settings.enemy_evolution.pollution_factor = 0 - game.map_settings.enemy_evolution.time_factor = 0 - game.map_settings.enemy_expansion.enabled = true - game.map_settings.enemy_expansion.max_expansion_cooldown = 3600 - game.map_settings.enemy_expansion.min_expansion_cooldown = 3600 - game.map_settings.enemy_expansion.settler_group_max_size = 8 - game.map_settings.enemy_expansion.settler_group_min_size = 16 - game.map_settings.pollution.enabled = false - - game.forces.player.technologies["land-mine"].enabled = false - game.forces.player.technologies["landfill"].enabled = false - game.forces.player.technologies["railway"].researched = true - game.forces.player.recipes["pistol"].enabled = false - game.forces.player.set_spawn_position({-2, 16}, surface) - game.forces.enemy.set_ammo_damage_modifier("bullet", 1) - game.forces.enemy.set_turret_attack_modifier("gun-turret", 1) - - Locomotive.locomotive_spawn(surface, {x = 0, y = 16}) - - WD.reset_wave_defense() - wave_defense_table.surface_index = global.active_surface_index - wave_defense_table.target = global.locomotive_cargo - wave_defense_table.nest_building_density = 32 - wave_defense_table.game_lost = false - - Collapse.init() - - RPG.rpg_reset_all_players() - - set_difficulty() -end - -local function protect_train(event) - if event.entity.force.index ~= 1 then return end --Player Force - if event.entity == global.locomotive_cargo then - if event.cause then - if event.cause.force.index == 2 then - return - end - end - event.entity.health = event.entity.health + event.final_damage_amount - end -end - -local function biters_chew_rocks_faster(event) - if event.entity.force.index ~= 3 then return end --Neutral Force - if not event.cause then return end - if not event.cause.valid then return end - if event.cause.force.index ~= 2 then return end --Enemy Force - event.entity.health = event.entity.health - event.final_damage_amount * 5 -end - -local function hidden_biter(entity) - local d = math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) - - BiterRolls.wave_defense_set_unit_raffle(d * 0.20) - - local unit - if math_random(1,3) == 1 then - unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = entity.position}) - else - unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = entity.position}) - end - - local m = 1 / level_depth - m = m * d - - if math_random(1, 64) == 1 then - BiterHealthBooster.add_boss_unit(unit, m * 15 + 1, 0.38) - else - BiterHealthBooster.add_unit(unit, m * 2.5 + 1) - end -end - -local function hidden_worm(entity) - BiterRolls.wave_defense_set_worm_raffle(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.20) - entity.surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = entity.position}) -end - -local function hidden_biter_pet(event) - if math_random(1, 2048) ~= 1 then return end - BiterRolls.wave_defense_set_unit_raffle(math.sqrt(event.entity.position.x ^ 2 + event.entity.position.y ^ 2) * 0.25) - local unit - if math_random(1,3) == 1 then - unit = event.entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = event.entity.position}) - else - unit = event.entity.surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = event.entity.position}) - end - Pets.biter_pets_tame_unit(game.players[event.player_index], unit, true) -end - -local function hidden_treasure(event) - if math_random(1, 320) ~= 1 then return end - game.players[event.player_index].print(treasure_chest_messages[math_random(1, #treasure_chest_messages)], {r=0.98, g=0.66, b=0.22}) - Treasure(event.entity.surface, event.entity.position, "wooden-chest") -end - -local projectiles = {"grenade", "explosive-rocket", "grenade", "explosive-rocket", "explosive-cannon-projectile"} -local function angry_tree(entity, cause) - if entity.type ~= "tree" then return end - if math.abs(entity.position.y) < level_depth then return end - if math_random(1,4) == 1 then hidden_biter(entity) end - if math_random(1,8) == 1 then hidden_worm(entity) end - if math_random(1,16) ~= 1 then return end - local position = false - if cause then - if cause.valid then - position = cause.position - end - end - if not position then position = {entity.position.x + (-20 + math_random(0, 40)), entity.position.y + (-20 + math_random(0, 40))} end - - entity.surface.create_entity({ - name = projectiles[math_random(1, 5)], - position = entity.position, - force = "neutral", - source = entity.position, - target = position, - max_range = 64, - speed = 0.10 - }) -end - -local function give_coin(player) - player.insert({name = "coin", count = 1}) -end - -local function on_player_mined_entity(event) - if not event.entity.valid then return end - if event.entity.force.index ~= 3 then return end - - if event.entity.type == "simple-entity" then - give_coin(game.players[event.player_index]) - - if math_random(1,32) == 1 then - hidden_biter(event.entity) - return - end - if math_random(1,512) == 1 then - hidden_worm(event.entity) - return - end - hidden_biter_pet(event) - hidden_treasure(event) - end - - angry_tree(event.entity, game.players[event.player_index].character) -end - -local function on_pre_player_left_game(event) - local player = game.players[event.player_index] - if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end - if player.character then - global.offline_players[#global.offline_players + 1] = {index = event.player_index, tick = game.tick} - end -end - -local function on_entity_died(event) - local wave_defense_table = WD.get_table() - if not event.entity.valid then return end - if event.entity == global.locomotive_cargo then - game.print("The cargo was destroyed!") - wave_defense_table.game_lost = true - wave_defense_table.target = nil - global.game_reset_tick = game.tick + 1800 - for _, player in pairs(game.connected_players) do - player.play_sound{path="utility/game_lost", volume_modifier=0.75} - end - event.entity.surface.spill_item_stack(event.entity.position,{name = "raw-fish", count = 512}, false) - return - end - - if event.cause then - if event.cause.valid then - if event.cause.force.index == 2 or event.cause.force.index == 3 then return end - end - end - - if event.entity.force.index == 3 then - --local r_max = 15 - math.floor(math.abs(event.entity.position.y) / (level_depth * 0.5)) - --if r_max < 3 then r_max = 3 end - if math_random(1,8) == 1 then - hidden_biter(event.entity) - end - - if math_random(1,256) == 1 then hidden_worm(event.entity) end - - angry_tree(event.entity, event.cause) - end -end - -local function on_entity_damaged(event) - if not event.entity.valid then return end - protect_train(event) - - if not event.entity.health then return end - biters_chew_rocks_faster(event) - --neutral_force_player_damage_resistance(event) -end - -local function on_research_finished(event) - event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 50 -- +5 Slots / level - local mining_speed_bonus = game.forces.player.mining_drill_productivity_bonus * 5 -- +50% speed / level - if event.research.force.technologies["steel-axe"].researched then mining_speed_bonus = mining_speed_bonus + 0.5 end -- +50% speed for steel-axe research - event.research.force.manual_mining_speed_modifier = mining_speed_bonus -end - -local function on_player_joined_game(event) - local player_modifiers = Modifier.get_table() - local player = game.players[event.player_index] - - set_difficulty() - - local surface = game.surfaces[global.active_surface_index] - - if player.online_time == 0 then - player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface) - for item, amount in pairs(starting_items) do - player.insert({name = item, count = amount}) - end - end - - if player.surface.index ~= global.active_surface_index and player.surface.name ~= "cargo_wagon" then - player.character = nil - player.set_controller({type=defines.controllers.god}) - player.create_character() - player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface) - for item, amount in pairs(starting_items) do - player.insert({name = item, count = amount}) - end - end - - player_modifiers[player.index].character_mining_speed_modifier["mountain_fortress"] = 0.5 - Modifier.update_player_modifiers(player) - - local tile = surface.get_tile(player.position) - if tile.valid then - if tile.name == "out-of-map" then - player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface) - end - end -end - -local function on_player_left_game(event) - set_difficulty() -end - -local function offline_players() - local current_tick = game.tick - local players = global.offline_players - local surface = game.surfaces[global.active_surface_index] - if #players > 0 then - --log("nonzero offline players") - local later = {} - for i = 1, #players, 1 do - if players[i] and game.players[players[i].index] and game.players[players[i].index].connected then - --game.print("deleting already online character from list") - players[i] = nil - else - if players[i] and players[i].tick < game.tick - 54000 then - --log("spawning corpse") - local player_inv = {} - local items = {} - player_inv[1] = game.players[players[i].index].get_inventory(defines.inventory.character_main) - player_inv[2] = game.players[players[i].index].get_inventory(defines.inventory.character_armor) - player_inv[3] = game.players[players[i].index].get_inventory(defines.inventory.character_guns) - player_inv[4] = game.players[players[i].index].get_inventory(defines.inventory.character_ammo) - player_inv[5] = game.players[players[i].index].get_inventory(defines.inventory.character_trash) - local e = surface.create_entity({name = "character", position = game.forces.player.get_spawn_position(surface), force = "neutral"}) - local inv = e.get_inventory(defines.inventory.character_main) - for ii = 1, 5, 1 do - if player_inv[ii].valid then - for iii = 1, #player_inv[ii], 1 do - if player_inv[ii][iii].valid then - items[#items + 1] = player_inv[ii][iii] - end - end - end - end - if #items > 0 then - for item = 1, #items, 1 do - if items[item].valid then - inv.insert(items[item]) - end - end - game.print({"chronosphere.message_accident"}, {r=0.98, g=0.66, b=0.22}) - e.die("neutral") - else - e.destroy() - end - - for ii = 1, 5, 1 do - if player_inv[ii].valid then - player_inv[ii].clear() - end - end - players[i] = nil - else - later[#later + 1] = players[i] - end - end - end - players = {} - if #later > 0 then - for i = 1, #later, 1 do - players[#players + 1] = later[i] - end - end - global.offline_players = players - end -end - -local function tick() - local tick = game.tick - if tick % 30 == 0 then - if tick % 1800 == 0 then - Locomotive.set_player_spawn_and_refill_fish() - local surface = game.surfaces[global.active_surface_index] - local last_position = global.map_collapse.last_position - local position = surface.find_non_colliding_position("stone-furnace", {last_position.x, last_position.y - 32}, 128, 4) - if position then - local wave_defense_table = WD.get_table() - wave_defense_table.spawn_position = position - end - -- if tick % 216000 == 0 then - -- Collapse.delete_out_of_map_chunks(surface) - -- end - if global.offline_loot then - offline_players() - end - end - if global.game_reset_tick then - if global.game_reset_tick < tick then - global.game_reset_tick = nil - require "maps.mountain_fortress_v2.main".reset_map() - end - return - end - Locomotive.fish_tag() - end - if not global.collapse_enabled then return end - Collapse.process() -end - -local function on_init() - local T = Map.Pop_info() - T.localised_category = "mountain_fortress" - T.main_caption_color = {r = 150, g = 150, b = 0} - T.sub_caption_color = {r = 0, g = 150, b = 0} - global.rocks_yield_ore_maximum_amount = 999 - global.rocks_yield_ore_base_amount = 50 - global.rocks_yield_ore_distance_modifier = 0.025 - - global.explosion_cells_destructible_tiles = { - ["out-of-map"] = 1500, - ["water"] = 1000, - ["water-green"] = 1000, - ["deepwater-green"] = 1000, - ["deepwater"] = 1000, - ["water-shallow"] = 1000, - } - - Public.reset_map() -end - -local function on_player_driving_changed_state(event) - local player = game.players[event.player_index] - local vehicle = event.entity - Locomotive.enter_cargo_wagon(player, vehicle) -end - -local event = require 'utils.event' -event.on_init(on_init) -event.on_nth_tick(2, tick) -event.add(defines.events.on_entity_damaged, on_entity_damaged) -event.add(defines.events.on_entity_died, on_entity_died) -event.add(defines.events.on_player_joined_game, on_player_joined_game) -event.add(defines.events.on_player_left_game, on_player_left_game) -event.add(defines.events.on_pre_player_left_game, on_pre_player_left_game) -event.add(defines.events.on_player_mined_entity, on_player_mined_entity) -event.add(defines.events.on_research_finished, on_research_finished) -event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state) - -require "modules.rocks_yield_ore" - -return Public From e468adedc54d0452a9c6765ae888387f3fbe1d63 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Wed, 8 Apr 2020 20:38:18 +0200 Subject: [PATCH 48/70] fucking confilcts --- control.lua | 161 +++++++++++ maps/mountain_fortress_v2/main.lua | 413 +++++++++++++++++++++++++++++ maps/overgrowth.lua | 267 +++++++++++++++++++ 3 files changed, 841 insertions(+) create mode 100644 control.lua create mode 100644 maps/mountain_fortress_v2/main.lua create mode 100644 maps/overgrowth.lua diff --git a/control.lua b/control.lua new file mode 100644 index 00000000..53bc8a70 --- /dev/null +++ b/control.lua @@ -0,0 +1,161 @@ +require 'utils.data_stages' +_LIFECYCLE = _STAGE.control -- Control stage +_DEBUG = false +_DUMP_ENV = false + +require 'utils.server' +require "utils.server_commands" +require "utils.utils" +require "utils.table" +require "utils.color_data" +require "utils.session_data" +require "chatbot" +require "commands" +require "antigrief" +require "modules.corpse_markers" +require "modules.floaty_chat" +require "modules.autohotbar" + +require "comfy_panel.main" +require "comfy_panel.player_list" +require "comfy_panel.admin" +require "comfy_panel.group" +require "comfy_panel.poll" +require "comfy_panel.score" +require "comfy_panel.config" + +require "modules.autostash" + +---- enable modules here ---- +--require "modules.the_floor_is_lava" +--require "modules.biters_landfill_on_death" +--require "modules.autodecon_when_depleted" +--require "modules.biter_noms_you" +--require "modules.biters_avoid_damage" +--require "modules.biters_double_damage" +--require "modules.burden" +--require "modules.comfylatron" +--require "modules.spaghett_challenge" +--require "modules.dangerous_goods" +--require "modules.dynamic_landfill" +--require "modules.explosive_biters" +--require "modules.explosive_player_respawn" +--require "modules.explosives_are_explosive" +--require "modules.fish_respawner" +--require "modules.fluids_are_explosive" +--require "modules.hunger" +--require "modules.hunger_games" +--require "modules.players_trample_paths" +--require "modules.railgun_enhancer" +--require "modules.restrictive_fluid_mining" +--require "modules.satellite_score" +--require "modules.show_health" +--require "modules.splice_double" +--require "modules.ores_are_mixed" +--require "modules.team_teleport" --(REQUIRES "on_tick_schedule" !) +--require "modules.surrounded_by_worms" +--require "modules.more_attacks" +--require "modules.evolution_extended" +--require "modules.no_blueprint_library" +--require "modules.explosives" +--require "modules.biter_pets" +--require "modules.no_solar" +--require "modules.biter_reanimator" +--require "modules.wave_defense.main" +--require "modules.fjei.main" +----------------------------- + +---- enable maps here ---- (maps higher up in the list may be more actually playable) +--require "maps.fish_defender.main" +--require "maps.biter_battles_v2.main" +--require "maps.native_war.main" +--require "maps.mountain_fortress_v2.main" +--require "maps.dungeons.main" +--require "maps.island_troopers.main" +--require "maps.biter_hatchery.main" +--require "maps.junkyard_pvp.main" +--require "maps.scrapyard.main" +--require "maps.tank_conquest.tank_conquest" +--require "maps.territorial_control" +--require "maps.cave_choppy.cave_miner" +--require "maps.wave_of_death.WoD" +--require "maps.planet_prison" +--require "maps.stone_maze.main" +--require "maps.choppy" +--require "maps.overgrowth" +--require "maps.quarters" +--require "maps.railway_troopers.main" +--require "maps.tetris.main" +--require "maps.maze_challenge" +--require "maps.cave_miner" +--require "maps.labyrinth" +--require "maps.junkyard" +--require "maps.hedge_maze" +--require "maps.spooky_forest" +--require "maps.mixed_railworld" +--require "maps.biter_battles.biter_battles" +--require "maps.fish_defender_v1.fish_defender" +--require "maps.mountain_fortress" +--require "maps.rocky_waste" +--require "maps.nightfall" +--require "maps.lost" +--require "maps.rivers" +--require "maps.atoll" +--require "maps.cratewood_forest" +--require "maps.tank_battles" +--require "maps.spiral_troopers" +--require "maps.refactor-io" +--require "maps.desert_oasis" +--require "maps.lost_desert" +--require "maps.stoneblock" +--require "maps.wave_defense" +--require "maps.crossing" +--require "maps.anarchy" +--require "maps.spaghettorio" +--require "maps.blue_beach" +--require "maps.deep_jungle" +--require "maps.rainbow_road" +--require "maps.pitch_black.main" +--require "maps.cube" +--require "maps.forest_circle" +----------------------------- + +---- more modules here ---- +--require "modules.towny.main" +--require "modules.rpg" +--require "modules.trees_grow" +--require "modules.trees_randomly_die" + +--require "terrain_layouts.caves" +--require "terrain_layouts.cone_to_east" +--require "terrain_layouts.biters_and_resources_east" +--require "terrain_layouts.scrap_01" +--require "terrain_layouts.watery_world" +--require "terrain_layouts.tree_01" +------ + +if _DUMP_ENV then + require 'utils.dump_env' +end +if _DEBUG then + require 'utils.debug.command' +end + +local function on_player_created(event) + local player = game.players[event.player_index] + player.gui.top.style = 'slot_table_spacing_horizontal_flow' + player.gui.left.style = 'slot_table_spacing_vertical_flow' +end + +local function on_init() + game.forces.player.research_queue_enabled = true +end + +local loaded = _G.package.loaded +function require(path) + return loaded[path] or error('Can only require files at runtime that have been required in the control stage.', 2) +end + +local event = require 'utils.event' +event.on_init(on_init) +event.add(defines.events.on_player_created, on_player_created) diff --git a/maps/mountain_fortress_v2/main.lua b/maps/mountain_fortress_v2/main.lua new file mode 100644 index 00000000..d768b484 --- /dev/null +++ b/maps/mountain_fortress_v2/main.lua @@ -0,0 +1,413 @@ +-- Mountain digger fortress, protect the cargo wagon! -- by MewMew + + --enable / disable collapsing of the map +local collapse_enabled = false +local darkness = false + +require "player_modifiers" +require "functions.soft_reset" +require "functions.basic_markets" + +local RPG = require "modules.rpg" +require "modules.wave_defense.main" +require "modules.biters_yield_coins" +require "modules.no_deconstruction_of_neutral_entities" +require "modules.no_solar" +require "modules.shotgun_buff" +require "modules.explosives" +require "modules.mineable_wreckage_yields_scrap" +require "modules.rocks_broken_paint_tiles" +require "modules.rocks_heal_over_time" +require "modules.rocks_yield_ore_veins" +local level_depth = require "maps.mountain_fortress_v2.terrain" +local Collapse = require "maps.mountain_fortress_v2.collapse" +require "maps.mountain_fortress_v2.flamethrower_nerf" +local BiterRolls = require "modules.wave_defense.biter_rolls" +local BiterHealthBooster = require "modules.biter_health_booster" +local Reset = require "functions.soft_reset" +local Pets = require "modules.biter_pets" +local Map = require "modules.map_info" +local WD = require "modules.wave_defense.table" +local Treasure = require "maps.mountain_fortress_v2.treasure" +local Locomotive = require "maps.mountain_fortress_v2.locomotive" +local Modifier = require "player_modifiers" +local math_random = math.random +local Public = {} + +local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16, ['wood'] = 16, ['explosives'] = 32} +local treasure_chest_messages = { + "You notice an old crate within the rubble. It's filled with treasure!", + "You find a chest underneath the broken rocks. It's filled with goodies!", + "We has found the precious!", +} + +local function set_difficulty() + local wave_defense_table = WD.get_table() + local player_count = #game.connected_players + + wave_defense_table.max_active_biters = 1024 + + -- threat gain / wave + wave_defense_table.threat_gain_multiplier = 2 + player_count * 0.1 + + --1 additional map collapse tile / 8 players in game + global.map_collapse.speed = math.floor(player_count * 0.125) + 1 + + --20 Players for fastest wave_interval + wave_defense_table.wave_interval = 3600 - player_count * 90 + if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end +end + +function Public.reset_map() + local wave_defense_table = WD.get_table() + global.chunk_queue = {} + + if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end + + local map_gen_settings = { + ["seed"] = math_random(1, 1000000), + ["width"] = level_depth, + ["water"] = 0.1, + ["starting_area"] = 1, + ["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0}, + ["default_enable_all_autoplace_controls"] = true, + ["autoplace_settings"] = { + ["entity"] = {treat_missing_as_default = false}, + ["tile"] = {treat_missing_as_default = true}, + ["decorative"] = {treat_missing_as_default = true}, + }, + } + + if not global.active_surface_index then + global.active_surface_index = game.create_surface("mountain_fortress", map_gen_settings).index + else + game.forces.player.set_spawn_position({-2, 16}, game.surfaces[global.active_surface_index]) + global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], map_gen_settings, starting_items).index + end + + local surface = game.surfaces[global.active_surface_index] + + if darkness then + surface.min_brightness = 0.10 + surface.brightness_visual_weights = {0.90, 0.90, 0.90} + surface.daytime = 0.42 + surface.freeze_daytime = true + surface.solar_power_multiplier = 999 + end + + surface.request_to_generate_chunks({0,0}, 2) + surface.force_generate_chunk_requests() + + for x = -768 + 32, 768 - 32, 32 do + surface.request_to_generate_chunks({x, 96}, 1) + surface.force_generate_chunk_requests() + end + + game.difficulty_settings.technology_price_multiplier = 0.5 + game.map_settings.enemy_evolution.destroy_factor = 0 + game.map_settings.enemy_evolution.pollution_factor = 0 + game.map_settings.enemy_evolution.time_factor = 0 + game.map_settings.enemy_expansion.enabled = true + game.map_settings.enemy_expansion.max_expansion_cooldown = 3600 + game.map_settings.enemy_expansion.min_expansion_cooldown = 3600 + game.map_settings.enemy_expansion.settler_group_max_size = 8 + game.map_settings.enemy_expansion.settler_group_min_size = 16 + game.map_settings.pollution.enabled = false + + game.forces.player.technologies["land-mine"].enabled = false + game.forces.player.technologies["landfill"].enabled = false + game.forces.player.technologies["railway"].researched = true + game.forces.player.set_spawn_position({-2, 16}, surface) + + Locomotive.locomotive_spawn(surface, {x = 0, y = 16}) + + WD.reset_wave_defense() + wave_defense_table.surface_index = global.active_surface_index + wave_defense_table.target = global.locomotive_cargo + wave_defense_table.nest_building_density = 32 + wave_defense_table.game_lost = false + + Collapse.init() + + RPG.rpg_reset_all_players() + + set_difficulty() +end + +local function protect_train(event) + if event.entity.force.index ~= 1 then return end --Player Force + if event.entity == global.locomotive_cargo then + if event.cause then + if event.cause.force.index == 2 then + return + end + end + event.entity.health = event.entity.health + event.final_damage_amount + end +end + +local function biters_chew_rocks_faster(event) + if event.entity.force.index ~= 3 then return end --Neutral Force + if not event.cause then return end + if not event.cause.valid then return end + if event.cause.force.index ~= 2 then return end --Enemy Force + event.entity.health = event.entity.health - event.final_damage_amount * 2.5 +end + +local function hidden_biter(entity) + local d = math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) + + BiterRolls.wave_defense_set_unit_raffle(d * 0.25) + + local unit + if math_random(1,3) == 1 then + unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = entity.position}) + else + unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = entity.position}) + end + + local m = 1 / level_depth + m = m * d + + if math_random(1, 256) == 1 then + BiterHealthBooster.add_boss_unit(unit, m * 15 + 1, 0.38) + else + BiterHealthBooster.add_unit(unit, m * 2.5 + 1) + end +end + +local function hidden_worm(entity) + BiterRolls.wave_defense_set_worm_raffle(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.25) + entity.surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = entity.position}) +end + +local function hidden_biter_pet(event) + if math_random(1, 2048) ~= 1 then return end + BiterRolls.wave_defense_set_unit_raffle(math.sqrt(event.entity.position.x ^ 2 + event.entity.position.y ^ 2) * 0.25) + local unit + if math_random(1,3) == 1 then + unit = event.entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = event.entity.position}) + else + unit = event.entity.surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = event.entity.position}) + end + Pets.biter_pets_tame_unit(game.players[event.player_index], unit, true) +end + +local function hidden_treasure(event) + if math_random(1, 320) ~= 1 then return end + game.players[event.player_index].print(treasure_chest_messages[math_random(1, #treasure_chest_messages)], {r=0.98, g=0.66, b=0.22}) + Treasure(event.entity.surface, event.entity.position, "wooden-chest") +end + +local projectiles = {"grenade", "explosive-rocket", "grenade", "explosive-rocket", "explosive-cannon-projectile"} +local function angry_tree(entity, cause) + if entity.type ~= "tree" then return end + if math.abs(entity.position.y) < level_depth then return end + if math_random(1,4) == 1 then hidden_biter(entity) end + if math_random(1,8) == 1 then hidden_worm(entity) end + if math_random(1,16) ~= 1 then return end + local position = false + if cause then + if cause.valid then + position = cause.position + end + end + if not position then position = {entity.position.x + (-20 + math_random(0, 40)), entity.position.y + (-20 + math_random(0, 40))} end + + entity.surface.create_entity({ + name = projectiles[math_random(1, 5)], + position = entity.position, + force = "neutral", + source = entity.position, + target = position, + max_range = 64, + speed = 0.10 + }) +end + +local function give_coin(player) + player.insert({name = "coin", count = 1}) +end + +local function on_player_mined_entity(event) + if not event.entity.valid then return end + if event.entity.force.index ~= 3 then return end + + if event.entity.type == "simple-entity" then + give_coin(game.players[event.player_index]) + + if math_random(1,32) == 1 then + hidden_biter(event.entity) + return + end + if math_random(1,512) == 1 then + hidden_worm(event.entity) + return + end + hidden_biter_pet(event) + hidden_treasure(event) + end + + angry_tree(event.entity, game.players[event.player_index].character) +end + +local function on_entity_died(event) + local wave_defense_table = WD.get_table() + if not event.entity.valid then return end + if event.entity == global.locomotive_cargo then + game.print("The cargo was destroyed!") + wave_defense_table.game_lost = true + wave_defense_table.target = nil + global.game_reset_tick = game.tick + 1800 + for _, player in pairs(game.connected_players) do + player.play_sound{path="utility/game_lost", volume_modifier=0.75} + end + event.entity.surface.spill_item_stack(event.entity.position,{name = "raw-fish", count = 512}, false) + return + end + + if event.cause then + if event.cause.valid then + if event.cause.force.index == 2 or event.cause.force.index == 3 then return end + end + end + + if event.entity.force.index == 3 then + --local r_max = 15 - math.floor(math.abs(event.entity.position.y) / (level_depth * 0.5)) + --if r_max < 3 then r_max = 3 end + if math_random(1,8) == 1 then + hidden_biter(event.entity) + end + + if math_random(1,256) == 1 then hidden_worm(event.entity) end + + angry_tree(event.entity, event.cause) + end +end + +local function on_entity_damaged(event) + if not event.entity.valid then return end + protect_train(event) + + if not event.entity.health then return end + biters_chew_rocks_faster(event) + --neutral_force_player_damage_resistance(event) +end + +local function on_research_finished(event) + event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 50 -- +5 Slots / level + local mining_speed_bonus = game.forces.player.mining_drill_productivity_bonus * 5 -- +50% speed / level + if event.research.force.technologies["steel-axe"].researched then mining_speed_bonus = mining_speed_bonus + 0.5 end -- +50% speed for steel-axe research + event.research.force.manual_mining_speed_modifier = mining_speed_bonus +end + +local function on_player_joined_game(event) + local player_modifiers = Modifier.get_table() + local player = game.players[event.player_index] + + set_difficulty() + + local surface = game.surfaces[global.active_surface_index] + + if player.online_time == 0 then + player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface) + for item, amount in pairs(starting_items) do + player.insert({name = item, count = amount}) + end + end + + if player.surface.index ~= global.active_surface_index and player.surface.name ~= "cargo_wagon" then + player.character = nil + player.set_controller({type=defines.controllers.god}) + player.create_character() + player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface) + for item, amount in pairs(starting_items) do + player.insert({name = item, count = amount}) + end + end + + player_modifiers[player.index].character_mining_speed_modifier["mountain_fortress"] = 0.5 + Modifier.update_player_modifiers(player) + + local tile = surface.get_tile(player.position) + if tile.valid then + if tile.name == "out-of-map" then + player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface) + end + end +end + +local function on_player_left_game(event) + set_difficulty() +end + +local function tick() + local tick = game.tick + if tick % 30 == 0 then + if tick % 1800 == 0 then + Locomotive.set_player_spawn_and_refill_fish() + local surface = game.surfaces[global.active_surface_index] + local last_position = global.map_collapse.last_position + local position = surface.find_non_colliding_position("stone-furnace", {last_position.x, last_position.y - 32}, 128, 4) + if position then + local wave_defense_table = WD.get_table() + wave_defense_table.spawn_position = position + end + --if tick % 216000 == 0 then + -- Collapse.delete_out_of_map_chunks(surface) + --end + end + if global.game_reset_tick then + if global.game_reset_tick < tick then + global.game_reset_tick = nil + require "maps.mountain_fortress_v2.main".reset_map() + end + return + end + Locomotive.fish_tag() + end + if not collapse_enabled then return end + Collapse.process() +end + +local function on_init() + local T = Map.Pop_info() + T.localised_category = "mountain_fortress" + T.main_caption_color = {r = 150, g = 150, b = 0} + T.sub_caption_color = {r = 0, g = 150, b = 0} + global.rocks_yield_ore_maximum_amount = 999 + global.rocks_yield_ore_base_amount = 50 + global.rocks_yield_ore_distance_modifier = 0.025 + + global.explosion_cells_destructible_tiles = { + ["out-of-map"] = 1500, + ["water"] = 1000, + ["water-green"] = 1000, + ["deepwater-green"] = 1000, + ["deepwater"] = 1000, + ["water-shallow"] = 1000, + } + + Public.reset_map() +end + +local function on_player_driving_changed_state(event) + local player = game.players[event.player_index] + local vehicle = event.entity + Locomotive.enter_cargo_wagon(player, vehicle) +end + +local event = require 'utils.event' +event.on_init(on_init) +event.on_nth_tick(2, tick) +event.add(defines.events.on_entity_damaged, on_entity_damaged) +event.add(defines.events.on_entity_died, on_entity_died) +event.add(defines.events.on_player_joined_game, on_player_joined_game) +event.add(defines.events.on_player_left_game, on_player_left_game) +event.add(defines.events.on_player_mined_entity, on_player_mined_entity) +event.add(defines.events.on_research_finished, on_research_finished) +event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state) + +require "modules.rocks_yield_ore" + +return Public diff --git a/maps/overgrowth.lua b/maps/overgrowth.lua new file mode 100644 index 00000000..09169c0d --- /dev/null +++ b/maps/overgrowth.lua @@ -0,0 +1,267 @@ +--overgrowth-- by mewmew -- + +require "on_tick_schedule" +require "modules.dynamic_landfill" +require "modules.satellite_score" +require "modules.spawners_contain_biters" +require "modules.no_deconstruction_of_neutral_entities" +require "modules.biters_yield_coins" +require "modules.rocks_yield_ore" +require "modules.ores_are_mixed" +require "modules.surrounded_by_worms" +global.average_worm_amount_per_chunk = 1.5 +require "modules.biters_attack_moving_players" +require "modules.market_friendly_fire_protection" +require "modules.trees_grow" +require "modules.trees_randomly_die" + +require "maps.overgrowth_map_info" + +local Reset = require "functions.soft_reset" +local rpg_t = require 'modules.rpg' +local kaboom = require "functions.omegakaboom" + +require "modules.difficulty_vote" + +local unearthing_biters = require "functions.unearthing_biters" + +local event = require 'utils.event' +local math_random = math.random + +local difficulties_votes = { + [1] = 11, + [2] = 10, + [3] = 9, + [4] = 8, + [5] = 7, + [6] = 6, + [7] = 5 +} + +local difficulties_votes_evo = { + [1] = 0.000016, + [2] = 0.000024, + [3] = 0.000032, + [4] = 0.000040, + [5] = 0.000048, + [6] = 0.000056, + [7] = 0.000064 +} + +local starting_items = { + ["pistol"] = 1, + ["firearm-magazine"] = 8 +} + +local function create_particles(surface, name, position, amount, cause_position) + local math_random = math.random + + local direction_mod = (-100 + math_random(0,200)) * 0.0004 + local direction_mod_2 = (-100 + math_random(0,200)) * 0.0004 + + if cause_position then + direction_mod = (cause_position.x - position.x) * 0.021 + direction_mod_2 = (cause_position.y - position.y) * 0.021 + end + + for i = 1, amount, 1 do + local m = math_random(4, 10) + local m2 = m * 0.005 + + surface.create_particle({ + name = name, + position = position, + frame_speed = 1, + vertical_speed = 0.130, + height = 0, + movement = { + (m2 - (math_random(0, m) * 0.01)) + direction_mod, + (m2 - (math_random(0, m) * 0.01)) + direction_mod_2 + } + }) + end +end + +local function spawn_market(surface, position) + local market = surface.create_entity({name = "market", position = position, force = "neutral"}) + --market.destructible = false + market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "wood", count = 50}}) + market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}) + market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}}) + market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'stone', count = 50}}) + market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'coal', count = 50}}) + market.add_market_item({price = {{"coin", 5}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}) + + market.add_market_item({price = {{'coin', 2}}, offer = {type = 'give-item', item = "raw-fish", count = 1}}) + market.add_market_item({price = {{'coin', 8}}, offer = {type = 'give-item', item = "grenade", count = 1}}) + market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "firearm-magazine", count = 1}}) + market.add_market_item({price = {{'coin', 16}}, offer = {type = 'give-item', item = "submachine-gun", count = 1}}) + market.add_market_item({price = {{'coin', 32}}, offer = {type = 'give-item', item = "car", count = 1}}) + return market +end + +local caption_style = {{"font", "default-bold"}, {"font_color",{ r=0.63, g=0.63, b=0.63}}, {"top_padding",2}, {"left_padding",0},{"right_padding",0},{"minimal_width",0}} +local stat_number_style = {{"font", "default-bold"}, {"font_color",{ r=0.77, g=0.77, b=0.77}}, {"top_padding",2}, {"left_padding",0},{"right_padding",0},{"minimal_width",0}} +local function tree_gui() + for _, player in pairs(game.connected_players) do + if player.gui.top["trees_defeated"] then player.gui.top["trees_defeated"].destroy() end + local b = player.gui.top.add { type = "button", caption = '[img=entity.tree-04] : ' .. global.trees_defeated, tooltip = "Trees defeated", name = "trees_defeated" } + b.style.font = "heading-1" + b.style.font_color = {r=0.00, g=0.33, b=0.00} + b.style.minimal_height = 38 + end +end + +local function get_surface_settings() + local map_gen_settings = {} + map_gen_settings.seed = math_random(1, 1000000) + map_gen_settings.water = math_random(15, 30) * 0.1 + map_gen_settings.starting_area = 1 + map_gen_settings.cliff_settings = {cliff_elevation_interval = math_random(4, 48), cliff_elevation_0 = math_random(4, 48)} + map_gen_settings.autoplace_controls = { + ["coal"] = {frequency = "2", size = "1", richness = "1"}, + ["stone"] = {frequency = "2", size = "1", richness = "1"}, + ["copper-ore"] = {frequency = "2", size = "1", richness = "1"}, + ["iron-ore"] = {frequency = "2.5", size = "1.1", richness = "1"}, + ["uranium-ore"] = {frequency = "2", size = "1", richness = "1"}, + ["crude-oil"] = {frequency = "3", size = "1", richness = "1.5"}, + ["trees"] = {frequency = "2", size = "1", richness = "0.75"}, + ["enemy-base"] = {frequency = "4", size = "1.25", richness = "1"} + } + return map_gen_settings +end + +function reset_map() + local rpg = rpg_t.get_table() + global.trees_grow_chunk_next_visit = {} + global.trees_grow_chunk_raffle = {} + global.trees_grow_chunk_position = {} + global.trees_grow_chunks_charted = {} + global.trees_grow_chunks_charted_counter = 0 + + global.current_surface = Reset.soft_reset_map(global.current_surface, get_surface_settings(), starting_items) + + reset_difficulty_poll() + + global.trees_defeated = 0 + tree_gui() + + global.market = spawn_market(global.current_surface, {x = 0, y = -8}) + + game.map_settings.enemy_evolution.time_factor = difficulties_votes_evo[4] + + if rpg then rpg_t.rpg_reset_all_players() end +end + +local function on_player_joined_game(event) + local player = game.players[event.player_index] + if player.online_time == 0 then + for item, amount in pairs(starting_items) do + player.insert({name = item, count = amount}) + end + end + + if global.current_surface then + if player.surface.name ~= global.current_surface.name then + local pos = global.current_surface.find_non_colliding_position("character", {x = 0, y = 0}, 16, 0.5) + player.teleport(pos, global.current_surface) + end + end + + if not global.market and game.tick == 0 then + global.current_surface = game.create_surface("overgrowth", get_surface_settings()) + game.forces["player"].set_spawn_position({x = 0, y = 0}, global.current_surface) + player.teleport({0,0}, global.current_surface) + reset_map() + end + + tree_gui() +end + +local function trap(entity) + local r = 8 + if global.difficulty_vote_index then r = difficulties_votes[global.difficulty_vote_index] end + if math_random(1,r) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end +end + +local function on_player_mined_entity(event) + local entity = event.entity + if not entity.valid then return end + if entity.type ~= "tree" then return end + + global.trees_defeated = global.trees_defeated + 1 + tree_gui() + + trap(entity) + + if event.player_index then + create_particles(entity.surface, "wooden-particle", entity.position, 128, game.players[event.player_index].position) + game.players[event.player_index].insert({name = "coin", count = 1}) + return + end + + create_particles(entity.surface, "wooden-particle", entity.position, 128) + + if event.cause then + if event.cause.force.name == "enemy" then return end + end + + entity.surface.spill_item_stack(entity.position,{name = "coin", count = 1}, true) +end + +local function on_entity_died(event) + on_player_mined_entity(event) + if event.entity == global.market then + global.map_reset_timeout = game.tick + 900 + game.print("The market has been overrun.", {r = 1, g = 0, b = 0}) + kaboom(event.entity.surface, event.entity.position, "explosive-cannon-projectile", 24, 12) + kaboom(event.entity.surface, event.entity.position, "explosive-uranium-cannon-projectile", 24, 12) + global.market = nil + end +end + +local function attack_market() + local c = 8 + if global.difficulty_vote_index then + c = global.difficulty_vote_index * 2 + game.map_settings.enemy_evolution.time_factor = difficulties_votes_evo[global.difficulty_vote_index] + end + global.current_surface.set_multi_command({ + command={ + type=defines.command.attack, + target=global.market, + distraction=defines.distraction.by_enemy + }, + unit_count = math_random(c, c * 2), + force = "enemy", + unit_search_distance=1024 + }) + global.current_surface.set_multi_command({ + command={ + type=defines.command.attack, + target=global.market, + distraction=defines.distraction.none + }, + unit_count = math_random(1, c), + force = "enemy", + unit_search_distance=1024 + }) +end + +local function tick() + if global.market then + if math_random(1, 60) == 1 then + attack_market() + end + return + end + if not global.map_reset_timeout then return end + if game.tick < global.map_reset_timeout then return end + reset_map() + global.map_reset_timeout = nil +end + +event.on_nth_tick(60, tick) +event.add(defines.events.on_player_joined_game, on_player_joined_game) +event.add(defines.events.on_player_mined_entity, on_player_mined_entity) +event.add(defines.events.on_entity_died, on_entity_died) From 2970d50e51e6f7a8fae5ef85d8a4798db1052957 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Wed, 8 Apr 2020 20:41:26 +0200 Subject: [PATCH 49/70] Update control.lua --- control.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control.lua b/control.lua index 53bc8a70..c536efc6 100644 --- a/control.lua +++ b/control.lua @@ -126,7 +126,7 @@ require "modules.autostash" --require "modules.trees_grow" --require "modules.trees_randomly_die" ---require "terrain_layouts.caves" +--require "terrain_layouts.caves" --require "terrain_layouts.cone_to_east" --require "terrain_layouts.biters_and_resources_east" --require "terrain_layouts.scrap_01" From 15a193d7edaeca94c2e11c68aa73daaa9c6cfea9 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Wed, 8 Apr 2020 21:10:21 +0200 Subject: [PATCH 50/70] fortress --- maps/mountain_fortress_v2/main.lua | 97 ++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 6 deletions(-) diff --git a/maps/mountain_fortress_v2/main.lua b/maps/mountain_fortress_v2/main.lua index d768b484..97dd0006 100644 --- a/maps/mountain_fortress_v2/main.lua +++ b/maps/mountain_fortress_v2/main.lua @@ -1,7 +1,8 @@ -- Mountain digger fortress, protect the cargo wagon! -- by MewMew --enable / disable collapsing of the map -local collapse_enabled = false +global.collapse_enabled = true +global.offline_loot = true local darkness = false require "player_modifiers" @@ -59,8 +60,12 @@ local function set_difficulty() end function Public.reset_map() + for _,player in pairs(game.players) do + if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end + end local wave_defense_table = WD.get_table() global.chunk_queue = {} + global.offline_players = {} if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end @@ -117,7 +122,10 @@ function Public.reset_map() game.forces.player.technologies["land-mine"].enabled = false game.forces.player.technologies["landfill"].enabled = false game.forces.player.technologies["railway"].researched = true + game.forces.player.recipes["pistol"].enabled = false game.forces.player.set_spawn_position({-2, 16}, surface) + game.forces.enemy.set_ammo_damage_modifier("bullet", 1) + game.forces.enemy.set_turret_attack_modifier("gun-turret", 1) Locomotive.locomotive_spawn(surface, {x = 0, y = 16}) @@ -151,13 +159,13 @@ local function biters_chew_rocks_faster(event) if not event.cause then return end if not event.cause.valid then return end if event.cause.force.index ~= 2 then return end --Enemy Force - event.entity.health = event.entity.health - event.final_damage_amount * 2.5 + event.entity.health = event.entity.health - event.final_damage_amount * 5 end local function hidden_biter(entity) local d = math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) - BiterRolls.wave_defense_set_unit_raffle(d * 0.25) + BiterRolls.wave_defense_set_unit_raffle(d * 0.20) local unit if math_random(1,3) == 1 then @@ -177,13 +185,13 @@ local function hidden_biter(entity) end local function hidden_worm(entity) - BiterRolls.wave_defense_set_worm_raffle(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.25) + BiterRolls.wave_defense_set_worm_raffle(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.20) entity.surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = entity.position}) end local function hidden_biter_pet(event) if math_random(1, 2048) ~= 1 then return end - BiterRolls.wave_defense_set_unit_raffle(math.sqrt(event.entity.position.x ^ 2 + event.entity.position.y ^ 2) * 0.25) + BiterRolls.wave_defense_set_unit_raffle(math.sqrt(event.entity.position.x ^ 2 + event.entity.position.y ^ 2) * 0.20) local unit if math_random(1,3) == 1 then unit = event.entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = event.entity.position}) @@ -251,6 +259,14 @@ local function on_player_mined_entity(event) angry_tree(event.entity, game.players[event.player_index].character) end +local function on_pre_player_left_game(event) + local player = game.players[event.player_index] + if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end + if player.character then + global.offline_players[#global.offline_players + 1] = {index = event.player_index, tick = game.tick} + end +end + local function on_entity_died(event) local wave_defense_table = WD.get_table() if not event.entity.valid then return end @@ -341,6 +357,71 @@ local function on_player_left_game(event) set_difficulty() end +local function offline_players() + local current_tick = game.tick + local players = global.offline_players + local surface = game.surfaces[global.active_surface_index] + if #players > 0 then + --log("nonzero offline players") + local later = {} + for i = 1, #players, 1 do + if players[i] and game.players[players[i].index] and game.players[players[i].index].connected then + --game.print("deleting already online character from list") + players[i] = nil + else + if players[i] and players[i].tick < game.tick - 54000 then + --log("spawning corpse") + local player_inv = {} + local items = {} + player_inv[1] = game.players[players[i].index].get_inventory(defines.inventory.character_main) + player_inv[2] = game.players[players[i].index].get_inventory(defines.inventory.character_armor) + player_inv[3] = game.players[players[i].index].get_inventory(defines.inventory.character_guns) + player_inv[4] = game.players[players[i].index].get_inventory(defines.inventory.character_ammo) + player_inv[5] = game.players[players[i].index].get_inventory(defines.inventory.character_trash) + local e = surface.create_entity({name = "character", position = game.forces.player.get_spawn_position(surface), force = "neutral"}) + local inv = e.get_inventory(defines.inventory.character_main) + for ii = 1, 5, 1 do + if player_inv[ii].valid then + for iii = 1, #player_inv[ii], 1 do + if player_inv[ii][iii].valid then + items[#items + 1] = player_inv[ii][iii] + end + end + end + end + if #items > 0 then + for item = 1, #items, 1 do + if items[item].valid then + inv.insert(items[item]) + end + end + game.print({"chronosphere.message_accident"}, {r=0.98, g=0.66, b=0.22}) + e.die("neutral") + else + e.destroy() + end + + for ii = 1, 5, 1 do + if player_inv[ii].valid then + player_inv[ii].clear() + end + end + players[i] = nil + else + later[#later + 1] = players[i] + end + end + end + players = {} + if #later > 0 then + for i = 1, #later, 1 do + players[#players + 1] = later[i] + end + end + global.offline_players = players + end +end + local function tick() local tick = game.tick if tick % 30 == 0 then @@ -356,6 +437,9 @@ local function tick() --if tick % 216000 == 0 then -- Collapse.delete_out_of_map_chunks(surface) --end + if global.offline_loot then + offline_players() + end end if global.game_reset_tick then if global.game_reset_tick < tick then @@ -366,7 +450,7 @@ local function tick() end Locomotive.fish_tag() end - if not collapse_enabled then return end + if not global.collapse_enabled then return end Collapse.process() end @@ -404,6 +488,7 @@ event.add(defines.events.on_entity_damaged, on_entity_damaged) event.add(defines.events.on_entity_died, on_entity_died) event.add(defines.events.on_player_joined_game, on_player_joined_game) event.add(defines.events.on_player_left_game, on_player_left_game) +event.add(defines.events.on_pre_player_left_game, on_pre_player_left_game) event.add(defines.events.on_player_mined_entity, on_player_mined_entity) event.add(defines.events.on_research_finished, on_research_finished) event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state) From 0dd0a232bcb308f5c8ceb85e80f7719f76c39ce6 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Wed, 8 Apr 2020 21:29:51 +0200 Subject: [PATCH 51/70] fortress --- maps/mountain_fortress_v2/main.lua | 2 +- modules/pistol_buffs.lua | 23 ++++++++++++++++++ modules/railgun_enhancer.lua | 39 +++++++++++++++--------------- 3 files changed, 44 insertions(+), 20 deletions(-) create mode 100644 modules/pistol_buffs.lua diff --git a/maps/mountain_fortress_v2/main.lua b/maps/mountain_fortress_v2/main.lua index 97dd0006..19bc3c46 100644 --- a/maps/mountain_fortress_v2/main.lua +++ b/maps/mountain_fortress_v2/main.lua @@ -177,7 +177,7 @@ local function hidden_biter(entity) local m = 1 / level_depth m = m * d - if math_random(1, 256) == 1 then + if math_random(1, 64) == 1 then BiterHealthBooster.add_boss_unit(unit, m * 15 + 1, 0.38) else BiterHealthBooster.add_unit(unit, m * 2.5 + 1) diff --git a/modules/pistol_buffs.lua b/modules/pistol_buffs.lua new file mode 100644 index 00000000..71a6690c --- /dev/null +++ b/modules/pistol_buffs.lua @@ -0,0 +1,23 @@ + + +local event = require 'utils.event' + + +local function on_entity_damaged(event) + if not event.cause then return end + if event.cause.name ~= "character" then return end + if event.damage_type.name ~= "physical" then return end + + local player = event.cause + if player.shooting_state.state == defines.shooting.not_shooting then return end + local weapon = player.get_inventory(defines.inventory.character_guns)[player.selected_gun_index] + local ammo = player.get_inventory(defines.inventory.character_ammo)[player.selected_gun_index] + game.print(weapon.valid_for_read) + game.print(ammo.valid_for_read) + if not weapon.valid_for_read or not ammo.valid_for_read then return end + if weapon.name ~= "pistol" then return end + if ammo.name ~= "firearm-magazine" and ammo ~= "piercing-rounds-magazine" and ammo ~= "uranium-rounds-magazine" then return end + event.entity.damage(event.final_damage_amount * 4, player.force, "physical") +end + +event.add(defines.events.on_entity_damaged, on_entity_damaged) diff --git a/modules/railgun_enhancer.lua b/modules/railgun_enhancer.lua index 894ff150..b7f5c9d1 100644 --- a/modules/railgun_enhancer.lua +++ b/modules/railgun_enhancer.lua @@ -12,12 +12,12 @@ local biological_target_types = { ["unit"] = true, ["player"] = true, ["turret"] = true, - ["unit-spawner"] = true + ["unit-spawner"] = true } local function create_visuals(source_entity, target_entity) if not additional_visual_effects then return end - local surface = target_entity.surface + local surface = target_entity.surface surface.create_entity({name = "water-splash", position = target_entity.position}) if biological_target_types[target_entity.type] then surface.create_entity({name = "blood-explosion-big", position = target_entity.position}) @@ -34,16 +34,16 @@ local function create_visuals(source_entity, target_entity) surface.create_entity({name = "fire-flame", position = target_entity.position}) end for x = -3, 3, 1 do - for y = -3, 3, 1 do + for y = -3, 3, 1 do if math_random(1, 3) == 1 then - surface.create_trivial_smoke({name="smoke-fast", position={target_entity.position.x + (x * 0.35), target_entity.position.y + (y * 0.35)}}) + surface.create_trivial_smoke({name="smoke-fast", position={target_entity.position.x + (x * 0.35), target_entity.position.y + (y * 0.35)}}) end if math_random(1, 5) == 1 then - surface.create_trivial_smoke({name="train-smoke", position={target_entity.position.x + (x * 0.35), target_entity.position.y + (y * 0.35)}}) + surface.create_trivial_smoke({name="train-smoke", position={target_entity.position.x + (x * 0.35), target_entity.position.y + (y * 0.35)}}) end end end - end + end end local function do_splash_damage_around_entity(source_entity, player) @@ -61,36 +61,37 @@ local function do_splash_damage_around_entity(source_entity, player) local surface = entity.surface surface.create_entity({name = "railgun-beam", position = source_entity.position, source = source_entity.position, target = entity.position}) surface.create_entity({name = "water-splash", position = entity.position}) - if biological_target_types[entity.type] then - surface.create_entity({name = "blood-fountain", position = entity.position}) + if biological_target_types[entity.type] then + surface.create_entity({name = "blood-fountain", position = entity.position}) end end - local damage = math_random(math.ceil((damage_min * research_damage_bonus) / 16), math.ceil((damage_max * research_damage_bonus) / 16)) - entity.damage(damage, player.force, "physical") + local damage = math_random(math.ceil((damage_min * research_damage_bonus) / 16), math.ceil((damage_max * research_damage_bonus) / 16)) + entity.damage(damage, player.force, "physical") end end end -local function on_entity_damaged(event) +local function on_entity_damaged(event) if not event.cause then return end if event.cause.name ~= "character" then return end if event.damage_type.name ~= "physical" then return end if event.original_damage_amount ~= 100 then return end - + local player = event.cause if player.shooting_state.state == defines.shooting.not_shooting then return end local selected_weapon = player.get_inventory(defines.inventory.character_guns)[player.selected_gun_index] + if not selected_weapon.valid_for_read then return end if selected_weapon.name ~= "railgun" then return end - + create_visuals(event.cause, event.entity) - + do_splash_damage_around_entity(event.entity, player) - + event.entity.health = event.entity.health + event.final_damage_amount - - local research_damage_bonus = player.force.get_ammo_damage_modifier("laser-turret") + 1 + + local research_damage_bonus = player.force.get_ammo_damage_modifier("laser-turret") + 1 local damage = math_random(math.ceil(damage_min * research_damage_bonus), math.ceil(damage_max * research_damage_bonus)) - event.entity.damage(damage, player.force, "physical") + event.entity.damage(damage, player.force, "physical") end -event.add(defines.events.on_entity_damaged, on_entity_damaged) \ No newline at end of file +event.add(defines.events.on_entity_damaged, on_entity_damaged) From 12f826762a933bb18646481e7fed873711986abc Mon Sep 17 00:00:00 2001 From: hanakocz Date: Wed, 8 Apr 2020 21:31:34 +0200 Subject: [PATCH 52/70] debug messages out --- modules/pistol_buffs.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/pistol_buffs.lua b/modules/pistol_buffs.lua index 71a6690c..659fffb5 100644 --- a/modules/pistol_buffs.lua +++ b/modules/pistol_buffs.lua @@ -12,8 +12,6 @@ local function on_entity_damaged(event) if player.shooting_state.state == defines.shooting.not_shooting then return end local weapon = player.get_inventory(defines.inventory.character_guns)[player.selected_gun_index] local ammo = player.get_inventory(defines.inventory.character_ammo)[player.selected_gun_index] - game.print(weapon.valid_for_read) - game.print(ammo.valid_for_read) if not weapon.valid_for_read or not ammo.valid_for_read then return end if weapon.name ~= "pistol" then return end if ammo.name ~= "firearm-magazine" and ammo ~= "piercing-rounds-magazine" and ammo ~= "uranium-rounds-magazine" then return end From fc1148def2ac24c721af273bdf896f8b7adb191a Mon Sep 17 00:00:00 2001 From: hanakocz Date: Fri, 10 Apr 2020 01:29:49 +0200 Subject: [PATCH 53/70] mini fixes --- maps/mountain_fortress_v2/main.lua | 10 +++++----- modules/admins_operate_biters.lua | 2 +- modules/pistol_buffs.lua | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/maps/mountain_fortress_v2/main.lua b/maps/mountain_fortress_v2/main.lua index 19bc3c46..9642e9e6 100644 --- a/maps/mountain_fortress_v2/main.lua +++ b/maps/mountain_fortress_v2/main.lua @@ -180,7 +180,7 @@ local function hidden_biter(entity) if math_random(1, 64) == 1 then BiterHealthBooster.add_boss_unit(unit, m * 15 + 1, 0.38) else - BiterHealthBooster.add_unit(unit, m * 2.5 + 1) + BiterHealthBooster.add_unit(unit, m * 0.5 + 1) end end @@ -191,7 +191,7 @@ end local function hidden_biter_pet(event) if math_random(1, 2048) ~= 1 then return end - BiterRolls.wave_defense_set_unit_raffle(math.sqrt(event.entity.position.x ^ 2 + event.entity.position.y ^ 2) * 0.20) + BiterRolls.wave_defense_set_unit_raffle(math.sqrt(event.entity.position.x ^ 2 + event.entity.position.y ^ 2) * 0.25) local unit if math_random(1,3) == 1 then unit = event.entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = event.entity.position}) @@ -434,9 +434,9 @@ local function tick() local wave_defense_table = WD.get_table() wave_defense_table.spawn_position = position end - --if tick % 216000 == 0 then - -- Collapse.delete_out_of_map_chunks(surface) - --end + -- if tick % 216000 == 0 then + -- Collapse.delete_out_of_map_chunks(surface) + -- end if global.offline_loot then offline_players() end diff --git a/modules/admins_operate_biters.lua b/modules/admins_operate_biters.lua index af771b55..d5099f0a 100644 --- a/modules/admins_operate_biters.lua +++ b/modules/admins_operate_biters.lua @@ -302,7 +302,7 @@ local function addunits(group, source_player) end local function forcemove(group, source_player) - group.force_move() + group.start_moving() flying_text(nil, 1, group.position, source_player) end diff --git a/modules/pistol_buffs.lua b/modules/pistol_buffs.lua index 659fffb5..ab4c4a68 100644 --- a/modules/pistol_buffs.lua +++ b/modules/pistol_buffs.lua @@ -14,7 +14,7 @@ local function on_entity_damaged(event) local ammo = player.get_inventory(defines.inventory.character_ammo)[player.selected_gun_index] if not weapon.valid_for_read or not ammo.valid_for_read then return end if weapon.name ~= "pistol" then return end - if ammo.name ~= "firearm-magazine" and ammo ~= "piercing-rounds-magazine" and ammo ~= "uranium-rounds-magazine" then return end + if ammo.name ~= "firearm-magazine" and ammo.name ~= "piercing-rounds-magazine" and ammo.name ~= "uranium-rounds-magazine" then return end event.entity.damage(event.final_damage_amount * 4, player.force, "physical") end From 5f8205539c9da2743f78874642514fe4c7f95962 Mon Sep 17 00:00:00 2001 From: Jacob Date: Fri, 10 Apr 2020 12:32:10 -0400 Subject: [PATCH 54/70] rewrite Public_event.mining_buffs() to be relative and more intentional --- maps/chronosphere/event_functions.lua | 61 +++++++++++++++++++-------- maps/chronosphere/main.lua | 4 +- 2 files changed, 45 insertions(+), 20 deletions(-) diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua index 3ee8d43f..e54526d1 100644 --- a/maps/chronosphere/event_functions.lua +++ b/maps/chronosphere/event_functions.lua @@ -273,26 +273,51 @@ function Public_event.flamer_nerfs() game.forces.player.set_turret_attack_modifier("flamethrower-turret", flamer_power - 0.02 * difficulty * objective.chronojumps) end -function Public_event.mining_buffs() - local mining_power = 0 - local mining_researches = { - [1] = {name = "mining-productivity-1", bonus = 0.2}, - [2] = {name = "mining-productivity-2", bonus = 0.2}, - [3] = {name = "mining-productivity-3", bonus = 0.2}, - [4] = {name = "mining-productivity-4", bonus = 0.2} - } - for i = 1, 3, 1 do - if game.forces.player.technologies[mining_researches[i].name].researched then - mining_power = mining_power + mining_researches[i].bonus +local mining_researches = { + -- these already give .1 productivity so we're only adding .1 to get to 20% + ["mining-productivity-1"] = {bonus_productivity = .1, bonus_mining_speed = .2, bonus_inventory = 10}, + ["mining-productivity-2"] = {bonus_productivity = .1, bonus_mining_speed = .2, bonus_inventory = 10}, + ["mining-productivity-3"] = {bonus_productivity = .1, bonus_mining_speed = .2, bonus_inventory = 10}, + ["mining-productivity-4"] = {bonus_productivity = .1, bonus_mining_speed = .2, bonus_inventory = 10, infinite = true, infinite_level = 4}, +} + +function Public_event.mining_buffs(event) + if event == nil then + -- initialization call + if game.forces.player.mining_drill_productivity_bonus <= 1 then + game.forces.player.mining_drill_productivity_bonus = game.forces.player.mining_drill_productivity_bonus + 1 + end + + if game.forces.player.manual_mining_speed_modifier <= 1 then + game.forces.player.manual_mining_speed_modifier = game.forces.player.manual_mining_speed_modifier + 1 end end - mining_power = mining_power + (game.forces.player.technologies[mining_researches[4].name].level - 4) * 0.2 - game.forces.player.mining_drill_productivity_bonus = 1 + mining_power - local bonusinv = 0 - if game.forces.player.technologies["toolbelt"].researched then bonusinv = 10 end - game.forces.player.character_inventory_slots_bonus = mining_power * 50 + global.objective.invupgradetier * 10 + bonusinv - if game.forces.player.technologies["steel-axe"].researched then - game.forces.player.manual_mining_speed_modifier = 1 + mining_power * 2 + + if mining_researches[event.technology.name] == nil then return end + local tech = mining_researches[event.technology.name] + + if tech.bonus_productivity then + if tech.infinite then + game.forces.player.mining_drill_productivity_bonus = game.forces.player.mining_drill_productivity_bonus + tech.bonus_productivity * (event.technology.level - tech.infinite_level) + else + game.forces.player.mining_drill_productivity_bonus = game.forces.player.mining_drill_productivity_bonus + tech.bonus_productivity + end + end + + if tech.bonus_mining_speed then + if tech.infinite then + game.forces.player.manual_mining_speed_modifier = game.forces.player.manual_mining_speed_modifier + tech.bonus_mining_speed * (event.technology.level - tech.infinite_level) + else + game.forces.player.manual_mining_speed_modifier = game.forces.player.manual_mining_speed_modifier + tech.bonus_mining_speed + end + end + + if tech.bonus_inventory then + if tech.infinite then + game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + tech.bonus_inventory * (event.technology.level - tech.infinite_level) + else + game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + tech.bonus_inventory + end end end diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index d337b6ee..f489e64f 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -344,7 +344,7 @@ local function on_init() game.surfaces["nauvis"].clear() reset_map() Chrono.init_setup() - Event_functions.mining_buffs() + Event_functions.mining_buffs(nil) --if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end end @@ -462,7 +462,7 @@ end local function on_research_finished(event) Event_functions.flamer_nerfs() - Event_functions.mining_buffs() + Event_functions.mining_buffs(event) end local function on_player_driving_changed_state(event) From 51784f21d5067196e8eff9f91e7a9e6f7d62691d Mon Sep 17 00:00:00 2001 From: Jacob Date: Fri, 10 Apr 2020 14:43:45 -0400 Subject: [PATCH 55/70] Relative mining buffs, re-apply on tech reset --- maps/chronosphere/event_functions.lua | 28 +++++++++++++++++++-------- maps/chronosphere/main.lua | 5 +++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua index e54526d1..f794a532 100644 --- a/maps/chronosphere/event_functions.lua +++ b/maps/chronosphere/event_functions.lua @@ -283,14 +283,10 @@ local mining_researches = { function Public_event.mining_buffs(event) if event == nil then - -- initialization call - if game.forces.player.mining_drill_productivity_bonus <= 1 then - game.forces.player.mining_drill_productivity_bonus = game.forces.player.mining_drill_productivity_bonus + 1 - end - - if game.forces.player.manual_mining_speed_modifier <= 1 then - game.forces.player.manual_mining_speed_modifier = game.forces.player.manual_mining_speed_modifier + 1 - end + -- initialization/reset call + game.forces.player.mining_drill_productivity_bonus = game.forces.player.mining_drill_productivity_bonus + 1 + game.forces.player.manual_mining_speed_modifier = game.forces.player.manual_mining_speed_modifier + 1 + return end if mining_researches[event.technology.name] == nil then return end @@ -337,5 +333,21 @@ function Public_event.pistol_buffs(event) event.entity.damage(event.final_damage_amount * 4, player.force, "physical", player) end +function Public_event.on_technology_effects_reset(event) + if event.force.name == "player" then + game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + global.objective.invupgradetier * 10 + game.forces.player.character_loot_pickup_distance_bonus = game.forces.player.character_loot_pickup_distance_bonus + global.objective.pickupupgradetier + + local fake_event = {} + Public_event.mining_buffs(nil) + for tech in pairs(mining_researches) do + tech = game.forces.player.technologies[tech] + if tech.researched == true then + fake_event.technology = tech + Public_Event.mining_buffs(fake_event) + end + end + end +end return Public_event diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index f489e64f..8ce4756d 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -515,6 +515,10 @@ local function on_player_changed_position(event) end end +local function on_technology_effects_reset(event) + Event_functions.on_technology_effects_reset(event) +end + local event = require 'utils.event' event.on_init(on_init) event.on_load(on_load) @@ -528,6 +532,7 @@ event.add(defines.events.on_player_mined_entity, on_player_mined_entity) event.add(defines.events.on_research_finished, on_research_finished) event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state) event.add(defines.events.on_player_changed_position, on_player_changed_position) +event.add(defines.events.on_technology_effects_reset, on_technology_effects_reset) if _DEBUG then local Session = require 'utils.session_data' From c347b586622a51ce5c20050eed3e9f035f0c46a3 Mon Sep 17 00:00:00 2001 From: Jacob Date: Fri, 10 Apr 2020 19:14:51 -0400 Subject: [PATCH 56/70] event.research, not event.technology --- maps/chronosphere/event_functions.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua index f794a532..3583342d 100644 --- a/maps/chronosphere/event_functions.lua +++ b/maps/chronosphere/event_functions.lua @@ -289,8 +289,8 @@ function Public_event.mining_buffs(event) return end - if mining_researches[event.technology.name] == nil then return end - local tech = mining_researches[event.technology.name] + if mining_researches[event.research.name] == nil then return end + local tech = mining_researches[event.research.name] if tech.bonus_productivity then if tech.infinite then @@ -343,7 +343,7 @@ function Public_event.on_technology_effects_reset(event) for tech in pairs(mining_researches) do tech = game.forces.player.technologies[tech] if tech.researched == true then - fake_event.technology = tech + fake_event.research = tech Public_Event.mining_buffs(fake_event) end end From 77c0276b3d6a85b9881bdc13385ff0834569b73a Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sat, 11 Apr 2020 21:58:05 +0200 Subject: [PATCH 57/70] mountain fortress tiny fixes and wave defense gui fix --- locale/en/locale.cfg | 2 +- maps/mountain_fortress_v2/main.lua | 11 +++++----- maps/mountain_fortress_v2/treasure.lua | 5 +++-- modules/wave_defense/gui.lua | 28 +++++++++++++++----------- modules/wave_defense/main.lua | 9 --------- 5 files changed, 26 insertions(+), 29 deletions(-) diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index b23d582f..6abd4c09 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -154,7 +154,7 @@ angels-ore6=umber gui_1=First wave in gui_2=Wave: gui_3=Threat: -tooltip_1=high threat may empower biters +tooltip_1=High threat may empower biters.\nBiter health: __1__% tooltip_2=gain / minute [native_war] diff --git a/maps/mountain_fortress_v2/main.lua b/maps/mountain_fortress_v2/main.lua index 9642e9e6..3986a6a3 100644 --- a/maps/mountain_fortress_v2/main.lua +++ b/maps/mountain_fortress_v2/main.lua @@ -51,8 +51,8 @@ local function set_difficulty() -- threat gain / wave wave_defense_table.threat_gain_multiplier = 2 + player_count * 0.1 - --1 additional map collapse tile / 8 players in game - global.map_collapse.speed = math.floor(player_count * 0.125) + 1 + --1 additional map collapse tile / 8 players in game, with too high threat, the collapse speeds up. + global.map_collapse.speed = math.floor(player_count * 0.125) + 1 + math.floor(wave_defense_table.threat / 100000) --20 Players for fastest wave_interval wave_defense_table.wave_interval = 3600 - player_count * 90 @@ -134,6 +134,7 @@ function Public.reset_map() wave_defense_table.target = global.locomotive_cargo wave_defense_table.nest_building_density = 32 wave_defense_table.game_lost = false + game.reset_time_played() Collapse.init() @@ -144,7 +145,7 @@ end local function protect_train(event) if event.entity.force.index ~= 1 then return end --Player Force - if event.entity == global.locomotive_cargo then + if event.entity == global.locomotive_cargo or event.entity.surface.name == "cargo_wagon" then if event.cause then if event.cause.force.index == 2 then return @@ -178,9 +179,9 @@ local function hidden_biter(entity) m = m * d if math_random(1, 64) == 1 then - BiterHealthBooster.add_boss_unit(unit, m * 15 + 1, 0.38) + BiterHealthBooster.add_boss_unit(unit, m * 10 + 1, 0.38) else - BiterHealthBooster.add_unit(unit, m * 0.5 + 1) + BiterHealthBooster.add_unit(unit, m * 0.2 + 1) end end diff --git a/maps/mountain_fortress_v2/treasure.lua b/maps/mountain_fortress_v2/treasure.lua index 41c813b1..86eb8bc4 100644 --- a/maps/mountain_fortress_v2/treasure.lua +++ b/maps/mountain_fortress_v2/treasure.lua @@ -44,6 +44,7 @@ function Public.treasure_chest(surface, position, container_name) {{name = "belt-immunity-equipment", count = 1}, weight = 1, d_min = 0.5, d_max = 1}, {{name = "solar-panel-equipment", count = math_random(1,4)}, weight = 5, d_min = 0.4, d_max = 0.8}, {{name = "discharge-defense-equipment", count = 1}, weight = 1, d_min = 0.5, d_max = 1}, + {{name = "discharge-defense-remote", count = 1}, weight = 1, d_min = 0.5, d_max = 1}, {{name = "energy-shield-equipment", count = math_random(1,2)}, weight = 2, d_min = 0.3, d_max = 0.8}, --{{name = "energy-shield-mk2-equipment", count = 1}, weight = 2, d_min = 0.8, d_max = 1}, {{name = "exoskeleton-equipment", count = 1}, weight = 1, d_min = 0.3, d_max = 1}, @@ -118,8 +119,8 @@ function Public.treasure_chest(surface, position, container_name) {{name = "decider-combinator", count = math_random(4,8)}, weight = 2, d_min = 0.1, d_max = 1}, {{name = "power-switch", count = 1}, weight = 2, d_min = 0.1, d_max = 1}, {{name = "programmable-speaker", count = math_random(2,4)}, weight = 1, d_min = 0.1, d_max = 1}, - {{name = "green-wire", count = math_random(50,99)}, weight = 4, d_min = 0.1, d_max = 1}, - {{name = "red-wire", count = math_random(50,99)}, weight = 4, d_min = 0.1, d_max = 1}, + {{name = "green-wire", count = math_random(10,19)}, weight = 2, d_min = 0.1, d_max = 1}, + {{name = "red-wire", count = math_random(10,19)}, weight = 2, d_min = 0.1, d_max = 1}, {{name = "chemical-plant", count = math_random(1,3)}, weight = 3, d_min = 0.3, d_max = 1}, {{name = "burner-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.0, d_max = 0.2}, {{name = "electric-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.2, d_max = 1}, diff --git a/modules/wave_defense/gui.lua b/modules/wave_defense/gui.lua index 59075b8d..a26439a4 100644 --- a/modules/wave_defense/gui.lua +++ b/modules/wave_defense/gui.lua @@ -19,7 +19,7 @@ local function create_gui(player) progressbar.style.minimal_width = 96 progressbar.style.maximal_width = 96 progressbar.style.top_padding = 10 - + local line = frame.add({type = "line", direction = "vertical"}) line.style.left_padding = 4 line.style.right_padding = 4 @@ -28,13 +28,13 @@ local function create_gui(player) label.style.font = "default-bold" label.style.left_padding = 4 label.style.font_color = {r = 150, g = 0, b = 255} - + local label = frame.add({ type = "label", caption = " ", name = "threat_value", tooltip = {"wave_defense.tooltip_1"}}) label.style.font = "default-bold" label.style.right_padding = 1 label.style.minimal_width = 10 label.style.font_color = {r = 150, g = 0, b = 255} - + local label = frame.add({ type = "label", caption = " ", name = "threat_gains", tooltip = {"wave_defense.tooltip_2"}}) label.style.font = "default" label.style.left_padding = 1 @@ -54,27 +54,31 @@ local function update_gui(player) local wave_defense_table = WD.get_table() if not player.gui.top.wave_defense then create_gui(player) end local gui = player.gui.top.wave_defense - + local biter_health_boost = 1 + if global.biter_health_boost then biter_health_boost = global.biter_health_boost end + gui.label.caption = {"wave_defense.gui_2"} gui.wave_number.caption = wave_defense_table.wave_number if wave_defense_table.wave_number == 0 then gui.label.caption = {"wave_defense.gui_1"} - gui.wave_number.caption = math.floor((wave_defense_table.next_wave - game.tick) / 60) + 1 + gui.wave_number.caption = math.floor((wave_defense_table.next_wave - game.tick) / 60) + 1 end local interval = wave_defense_table.next_wave - wave_defense_table.last_wave gui.progressbar.value = 1 - (wave_defense_table.next_wave - game.tick) / interval - + gui.threat.caption = {"wave_defense.gui_3"} - gui.threat_value.caption = math.floor(wave_defense_table.threat) - + gui.threat.tooltip = {"wave_defense.tooltip_1", biter_health_boost * 100} + gui.threat_value.caption = math.floor(wave_defense_table.threat) + gui.threat_value.tooltip = {"wave_defense.tooltip_1", biter_health_boost * 100} + if wave_defense_table.wave_number == 0 then gui.threat_gains.caption = "" - return + return end - + local gain = get_threat_gain() local d = wave_defense_table.wave_number / 75 - + if gain >= 0 then gui.threat_gains.caption = " (+" .. gain .. ")" local g = 255 - math.floor(gain / d) @@ -88,4 +92,4 @@ local function update_gui(player) end end -return update_gui \ No newline at end of file +return update_gui diff --git a/modules/wave_defense/main.lua b/modules/wave_defense/main.lua index d890f68a..b54c2e97 100644 --- a/modules/wave_defense/main.lua +++ b/modules/wave_defense/main.lua @@ -159,15 +159,6 @@ local function set_enemy_evolution() --game.forces.enemy.set_ammo_damage_modifier("melee", damage_increase) --game.forces.enemy.set_ammo_damage_modifier("biological", damage_increase) game.forces.enemy.evolution_factor = evolution_factor - - if global.biter_health_boost then - for _, player in pairs(game.connected_players) do - --player.gui.top.wave_defense.threat.tooltip = "High threat may empower biters.\nBiter health " .. biter_health_boost * 100 .. "% | damage " .. (damage_increase + 1) * 100 .. "%" - if player.gui.top.wave_defense then - player.gui.top.wave_defense.threat.tooltip = "High threat may empower biters.\nBiter health " .. biter_health_boost * 100 .. "%" - end - end - end end local function can_units_spawn() From d5b3ce169b8d2ec4b3e16c67a504e9129ebec558 Mon Sep 17 00:00:00 2001 From: Jacob Date: Sat, 11 Apr 2020 21:46:56 -0400 Subject: [PATCH 58/70] Mis-capitalized variable --- maps/chronosphere/event_functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua index 3583342d..30293e51 100644 --- a/maps/chronosphere/event_functions.lua +++ b/maps/chronosphere/event_functions.lua @@ -344,7 +344,7 @@ function Public_event.on_technology_effects_reset(event) tech = game.forces.player.technologies[tech] if tech.researched == true then fake_event.research = tech - Public_Event.mining_buffs(fake_event) + Public_event.mining_buffs(fake_event) end end end From a41bac307103927a4f20042ce1347f6332f25869 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sun, 12 Apr 2020 22:39:36 +0200 Subject: [PATCH 59/70] chrono gui --- control.lua | 5 +- locale/en/locale.cfg | 24 +++- maps/chronosphere/chronobubles.lua | 32 ++--- maps/chronosphere/gui.lua | 183 +++++++++++++++++++++++------ maps/chronosphere/main.lua | 11 +- 5 files changed, 197 insertions(+), 58 deletions(-) diff --git a/control.lua b/control.lua index c536efc6..2d964b99 100644 --- a/control.lua +++ b/control.lua @@ -27,6 +27,7 @@ require "comfy_panel.config" require "modules.autostash" ---- enable modules here ---- +require "modules.admins_operate_biters" --require "modules.the_floor_is_lava" --require "modules.biters_landfill_on_death" --require "modules.autodecon_when_depleted" @@ -45,6 +46,7 @@ require "modules.autostash" --require "modules.fluids_are_explosive" --require "modules.hunger" --require "modules.hunger_games" +require "modules.pistol_buffs" --require "modules.players_trample_paths" --require "modules.railgun_enhancer" --require "modules.restrictive_fluid_mining" @@ -66,6 +68,7 @@ require "modules.autostash" ----------------------------- ---- enable maps here ---- (maps higher up in the list may be more actually playable) +require "maps.chronosphere.main" --require "maps.fish_defender.main" --require "maps.biter_battles_v2.main" --require "maps.native_war.main" @@ -126,7 +129,7 @@ require "modules.autostash" --require "modules.trees_grow" --require "modules.trees_randomly_die" ---require "terrain_layouts.caves" +--require "terrain_layouts.caves" --require "terrain_layouts.cone_to_east" --require "terrain_layouts.biters_and_resources_east" --require "terrain_layouts.scrap_01" diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index 6abd4c09..128ec37f 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -103,17 +103,39 @@ message_upgrade_inventory=Comfylatron: Players now can carry more trash in their message_upgrade_repair=Comfylatron: Train now gets repaired with additional repair kit at once. message_upgrade_water=Comfylatron: Train now has piping system for additional water sources. message_upgrade_out=Comfylatron: Train now has output chests. -message_upgrade_storage=Comfylatron: Cargo wagons now have enlargened storage. +message_upgrade_storage=Comfylatron: Cargo wagons now have enlarged storage. message_upgrade_poison=Comfylatron: I don't believe in your defense skills. I equipped train with poison defense. message_upgrade_mk2=Comfylatron: I upgraded one armor to mk2. message_upgrade_fusion=Comfylatron: One personal fusion reactor ready. message_poison_defense=Comfylatron: Triggering poison defense. Let's kill everything! +ore_richness_very_rich=Very Rich +ore_richness_rich=Rich +ore_richness_normal=Normal +ore_richness_poor=Poor +ore_richness_very_poor=Very Poor +ore_richness_none=None +daynight_static=Static +daynight_normal=Normal +daynight_slow=Slow +daynight_superslow=Super Slow +daynight_fast=Fast +daynight_superfast=Super Fast gui_1=ChronoJumps: gui_2=Charge: gui_3=Timer: gui_3_1=Best Case Timer: gui_3_2=Nuclear missiles launched in: gui_4=Local Evolution: +gui_planet_button=Planet Info +gui_upgrades_button=Upgrades +gui_upgrades_1=Insert needed items into chest with given upgrade number.\nChests are at top inside train.\nUpgrading can take a minute. +gui_planet_0=Name: __1__ +gui_planet_1=Detected ore distribution: +gui_planet_2=Ore Amounts: __1__ +gui_planet_3=Local evolution: __1__% +gui_planet_4=Global evolution bonuses: +gui_planet_4_1=+__1__% evolution, +__2__% damage +gui_planet_5=Daynight cycle: __1__ [rocks_yield_ore_veins] coal=coal diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua index 70b157b3..5c640775 100644 --- a/maps/chronosphere/chronobubles.lua +++ b/maps/chronosphere/chronobubles.lua @@ -25,25 +25,25 @@ local variants = { } local time_speed_variants = { - [1] = {name = "static", timer = 0}, - [2] = {name = "normal", timer = 100}, - [3] = {name = "slow", timer = 200}, - [4] = {name = "superslow", timer = 400}, - [5] = {name = "fast", timer = 50}, - [6] = {name = "superfast", timer = 25} + [1] = {name = {"chronosphere.daynight_static"}, timer = 0}, + [2] = {name = {"chronosphere.daynight_normal"}, timer = 100}, + [3] = {name = {"chronosphere.daynight_slow"}, timer = 200}, + [4] = {name = {"chronosphere.daynight_superslow"}, timer = 400}, + [5] = {name = {"chronosphere.daynight_fast"}, timer = 50}, + [6] = {name = {"chronosphere.daynight_superfast"}, timer = 25} } local richness = { - [1] = {name = "very rich", factor = 3}, - [2] = {name = "rich", factor = 2}, - [3] = {name = "rich", factor = 2}, - [4] = {name = "normal", factor = 1}, - [5] = {name = "normal", factor = 1}, - [6] = {name = "normal", factor = 1}, - [7] = {name = "poor", factor = 0.6}, - [8] = {name = "poor", factor = 0.6}, - [9] = {name = "very poor", factor = 0.3}, - [10] = {name = "none", factor = 0} + [1] = {name = {"chronosphere.ore_richness_very_rich"}, factor = 3}, + [2] = {name = {"chronosphere.ore_richness_rich"}, factor = 2}, + [3] = {name = {"chronosphere.ore_richness_rich"}, factor = 2}, + [4] = {name = {"chronosphere.ore_richness_normal"}, factor = 1}, + [5] = {name = {"chronosphere.ore_richness_normal"}, factor = 1}, + [6] = {name = {"chronosphere.ore_richness_normal"}, factor = 1}, + [7] = {name = {"chronosphere.ore_richness_poor"}, factor = 0.6}, + [8] = {name = {"chronosphere.ore_richness_poor"}, factor = 0.6}, + [9] = {name = {"chronosphere.ore_richness_very_poor"}, factor = 0.3}, + [10] = {name = {"chronosphere.ore_richness_none"}, factor = 0} } local function roll(weight) for i = 1, 100, 1 do diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index 58afddb4..3f555386 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -1,3 +1,5 @@ +local Public_gui = {} + local math_floor = math.floor local math_ceil = math.ceil local math_abs = math.abs @@ -59,38 +61,76 @@ local function create_gui(player) label.style.minimal_width = 10 label.style.font_color = {r = 0, g = 200, b = 0} - local line = frame.add({type = "line", direction = "vertical"}) - line.style.left_padding = 4 - line.style.right_padding = 8 + -- local line = frame.add({type = "line", direction = "vertical"}) + -- line.style.left_padding = 4 + -- line.style.right_padding = 8 - local label = frame.add({ type = "label", caption = " ", name = "evo"}) - label.style.font = "default-bold" - label.style.right_padding = 1 - label.style.minimal_width = 10 - label.style.font_color = {r = 150, g = 0, b = 255} + local button = frame.add({type = "button", caption = " ", name = "planet_button"}) + button.style.font = "default-bold" + button.style.font_color = { r=0.99, g=0.99, b=0.99} + button.style.minimal_width = 75 - local label = frame.add({ type = "label", caption = " ", name = "evo_value"}) - label.style.font = "default-bold" - label.style.right_padding = 1 - label.style.minimal_width = 10 - label.style.font_color = {r = 150, g = 0, b = 255} + local button = frame.add({type = "button", caption = " ", name = "upgrades_button"}) + button.style.font = "default-bold" + button.style.font_color = { r=0.99, g=0.99, b=0.99} + button.style.minimal_width = 75 - local label = frame.add({ type = "label", caption = " ", name = "planet"}) - label.style.font = "default-bold" - label.style.right_padding = 1 - label.style.minimal_width = 10 - label.style.font_color = {r = 0, g = 100, b = 200} + -- local label = frame.add({ type = "label", caption = " ", name = "evo"}) + -- label.style.font = "default-bold" + -- label.style.right_padding = 1 + -- label.style.minimal_width = 10 + -- label.style.font_color = {r = 150, g = 0, b = 255} - local label = frame.add({ type = "label", caption = "[Upgrades]", name = "upgrades", tooltip = " "}) - label.style.font = "default-bold" - label.style.right_padding = 1 - label.style.minimal_width = 10 - label.style.font_color = {r=0.33, g=0.66, b=0.9} + -- local label = frame.add({ type = "label", caption = " ", name = "evo_value"}) + -- label.style.font = "default-bold" + -- label.style.right_padding = 1 + -- label.style.minimal_width = 10 + -- label.style.font_color = {r = 150, g = 0, b = 255} + + -- local label = frame.add({ type = "label", caption = " ", name = "planet"}) + -- label.style.font = "default-bold" + -- label.style.right_padding = 1 + -- label.style.minimal_width = 10 + -- label.style.font_color = {r = 0, g = 100, b = 200} + + -- local label = frame.add({ type = "label", caption = "[Upgrades]", name = "upgrades", tooltip = " "}) + -- label.style.font = "default-bold" + -- label.style.right_padding = 1 + -- label.style.minimal_width = 10 + -- label.style.font_color = {r=0.33, g=0.66, b=0.9} end -local function update_gui(player) +local function update_planet_gui(player) + if not player.gui.screen["gui_planet"] then return end + local planet = global.objective.planet[1] + local evolution = game.forces["enemy"].evolution_factor + local evo_color = { + r = math_floor(255 * 1 * math_max(0, math_min(1, 1.2 - evolution * 2))), + g = math_floor(255 * 1 * math_max(math_abs(0.5 - evolution * 1.5), 1 - evolution * 4)), + b = math_floor(255 * 4 * math_max(0, 0.25 - math_abs(0.5 - evolution))) + } + local frame = player.gui.screen["gui_planet"] + + frame["planet_name"].caption = {"chronosphere.gui_planet_0", planet.name.name} + frame["planet_ores"]["iron-ore"].number = planet.name.iron + frame["planet_ores"]["copper-ore"].number = planet.name.copper + frame["planet_ores"]["coal"].number = planet.name.coal + frame["planet_ores"]["stone"].number = planet.name.stone + frame["planet_ores"]["uranium-ore"].number = planet.name.uranium + frame["planet_ores"]["oil"].number = planet.name.oil + frame["richness"].caption = {"chronosphere.gui_planet_2", planet.ore_richness.name} + frame["planet_biters"].caption = {"chronosphere.gui_planet_3", math_floor(evolution * 1000) / 10} + frame["planet_biters"].style.font_color = evo_color + + frame["planet_biters3"].caption = {"chronosphere.gui_planet_4_1", global.objective.passivejumps * 2.5, global.objective.passivejumps * 10} + frame["planet_time"].caption = {"chronosphere.gui_planet_5", planet.day_speed.name} + +end + +function Public_gui.update_gui(player) local objective = global.objective + update_planet_gui(player) if not player.gui.top.chronosphere then create_gui(player) end local gui = player.gui.top.chronosphere @@ -121,7 +161,10 @@ local function update_gui(player) gui.timer_value.tooltip = "After planet 5, biters will get additional permanent evolution for staying too long on each planet." end - gui.planet.caption = "Planet: " .. objective.planet[1].name.name .. " | Ores: " .. objective.planet[1].ore_richness.name + gui.planet_button.caption = {"chronosphere.gui_planet_button"} + gui.upgrades_button.caption = {"chronosphere.gui_upgrades_button"} + + --gui.planet.caption = "Planet: " .. objective.planet[1].name.name .. " | Ores: " .. objective.planet[1].ore_richness.name local acus = 0 if global.acumulators then acus = #global.acumulators else acus = 0 end local bestcase = math_floor((objective.chrononeeds - objective.chronotimer) / (1 + math_floor(acus/10))) @@ -140,8 +183,8 @@ local function update_gui(player) local evolution = game.forces["enemy"].evolution_factor - gui.evo.caption = {"chronosphere.gui_4"} - gui.evo_value.caption = math_floor(evolution * 100) .. "%" + --gui.evo.caption = {"chronosphere.gui_4"} + --gui.evo_value.caption = math_floor(evolution * 100) .. "%" local chests = { [1] = {c = "250 wooden chests + Jump number 5\n"}, [2] = {c = "250 iron chests + Jump number 10\n"}, @@ -208,7 +251,7 @@ local function update_gui(player) elseif objective.computerupgrade == 3 and objective.chronojumps >= 25 then tooltip = tooltip .. maxed[10].t end - gui.upgrades.tooltip = tooltip + --gui.upgrades.tooltip = tooltip -- if evolution < 10 then @@ -220,12 +263,82 @@ local function update_gui(player) -- else -- gui.evo.style.font_color = {r = 0, g = 255, b = 0} -- end - gui.evo.style.font_color = { - r = math_floor(255 * 1 * math_max(0, math_min(1, 1.2 - evolution * 2))), - g = math_floor(255 * 1 * math_max(math_abs(0.5 - evolution * 1.5), 1 - evolution * 4)), - b = math_floor(255 * 4 * math_max(0, 0.25 - math_abs(0.5 - evolution))) - } - gui.evo_value.style.font_color = gui.evo.style.font_color + -- gui.evo.style.font_color = { + -- r = math_floor(255 * 1 * math_max(0, math_min(1, 1.2 - evolution * 2))), + -- g = math_floor(255 * 1 * math_max(math_abs(0.5 - evolution * 1.5), 1 - evolution * 4)), + -- b = math_floor(255 * 4 * math_max(0, 0.25 - math_abs(0.5 - evolution))) + -- } + -- gui.evo_value.style.font_color = gui.evo.style.font_color end -return update_gui +local function upgrades_gui(player) + if player.gui.screen["gui_upgrades"] then player.gui.screen["gui_upgrades"].destroy() return end + local frame = player.gui.screen.add{type = "frame", name = "gui_upgrades", caption = "ChronoTrain Upgrades", direction = "vertical"} + frame.location = {x = 350, y = 45} + frame.style.minimal_height = 300 + frame.style.maximal_height = 300 + frame.style.minimal_width = 330 + frame.style.maximal_width = 630 + frame.add({type = "label", caption = {"chronosphere.gui_upgrades_1"}}) + frame.add({type = "button", name = "close_upgrades", caption = "Close"}) +end + +local function planet_gui(player) + if player.gui.screen["gui_planet"] then player.gui.screen["gui_planet"].destroy() return end + local planet = global.objective.planet[1] + local evolution = game.forces["enemy"].evolution_factor + --gui.evo.caption = {"chronosphere.gui_4"} + --gui.evo_value.caption = math_floor(evolution * 100) .. "%" + local frame = player.gui.screen.add{type = "frame", name = "gui_planet", caption = "Planet Info", direction = "vertical"} + frame.location = {x = 650, y = 45} + frame.style.minimal_height = 300 + frame.style.maximal_height = 500 + frame.style.minimal_width = 200 + frame.style.maximal_width = 400 + local l = {} + l[1] = frame.add({type = "label", name = "planet_name", caption = {"chronosphere.gui_planet_0", planet.name.name}}) + l[2] = frame.add({type = "label", caption = {"chronosphere.gui_planet_1"}}) + local table0 = frame.add({type = "table", name = "planet_ores", column_count = 3}) + table0.add({type = "sprite-button", name = "iron-ore", sprite = "item/iron-ore", enabled = false, number = planet.name.iron}) + table0.add({type = "sprite-button", name = "copper-ore", sprite = "item/copper-ore", enabled = false, number = planet.name.copper}) + table0.add({type = "sprite-button", name = "coal", sprite = "item/coal", enabled = false, number = planet.name.coal}) + table0.add({type = "sprite-button", name = "stone", sprite = "item/stone", enabled = false, number = planet.name.stone}) + table0.add({type = "sprite-button", name = "uranium-ore", sprite = "item/uranium-ore", enabled = false, number = planet.name.uranium}) + table0.add({type = "sprite-button", name = "oil", sprite = "fluid/crude-oil", enabled = false, number = planet.name.oil}) + l[3] = frame.add({type = "label", name = "richness", caption = {"chronosphere.gui_planet_2", planet.ore_richness.name}}) + frame.add({type = "line"}) + frame.add({type = "label", name = "planet_biters", caption = {"chronosphere.gui_planet_3", math_floor(evolution * 1000) / 10}}) + frame.add({type = "label", name = "planet_biters2", caption = {"chronosphere.gui_planet_4"}}) + frame.add({type = "label", name = "planet_biters3", caption = {"chronosphere.gui_planet_4_1", global.objective.passivejumps * 2.5, global.objective.passivejumps * 10}}) + frame.add({type = "line"}) + frame.add({type = "label", name = "planet_time", caption = {"chronosphere.gui_planet_5", planet.day_speed.name}}) + frame.add({type = "line"}) + local close = frame.add({type = "button", name = "close_planet", caption = "Close"}) + close.style.horizontal_align = "center" + -- for i = 1, 3, 1 do + -- l[i].style.font = "default-game" + -- end +end + +function Public_gui.on_gui_click(event) + if not event then return end + if not event.element then return end + if not event.element.valid then return end + local player = game.players[event.element.player_index] + if event.element.name == "upgrades_button" then + upgrades_gui(player) + return + elseif event.element.name == "planet_button" then + planet_gui(player) + return + end + + if event.element.type ~= "button" and event.element.type ~= "sprite-button" then return end + local name = event.element.name + if name == "close_upgrades" then upgrades_gui(player) return end + if name == "close_planet" then planet_gui(player) return end +end + + + +return Public_gui diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 8ce4756d..eed2c70e 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -21,7 +21,7 @@ local Tick_functions = require "maps.chronosphere.tick_functions" local Event_functions = require "maps.chronosphere.event_functions" local Chrono = require "maps.chronosphere.chrono" local Locomotive = require "maps.chronosphere.locomotive" -local update_gui = require "maps.chronosphere.gui" +local Gui = require "maps.chronosphere.gui" local math_random = math.random local math_floor = math.floor local math_sqrt = math.sqrt @@ -37,9 +37,9 @@ local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 32, ['grenade'] = local function generate_overworld(surface, optplanet) Planets.determine_planet(optplanet) local planet = global.objective.planet - local message = "Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name - game.print(message, {r=0.98, g=0.66, b=0.22}) - Server.to_discord_embed(message) + --local message = "Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name + --game.print(message, {r=0.98, g=0.66, b=0.22}) + --Server.to_discord_embed(message) if planet[1].name.id == 12 then game.print({"chronosphere.message_choppy"}, {r=0.98, g=0.66, b=0.22}) elseif planet[1].name.id == 14 then @@ -322,7 +322,7 @@ local function tick() end Locomotive.fish_tag() end - for _, player in pairs(game.connected_players) do update_gui(player) end + for _, player in pairs(game.connected_players) do Gui.update_gui(player) end end local function on_init() @@ -533,6 +533,7 @@ event.add(defines.events.on_research_finished, on_research_finished) event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state) event.add(defines.events.on_player_changed_position, on_player_changed_position) event.add(defines.events.on_technology_effects_reset, on_technology_effects_reset) +event.add(defines.events.on_gui_click, Gui.on_gui_click) if _DEBUG then local Session = require 'utils.session_data' From 3adc32953d9554c235ace4a0e100a84bb6009ebf Mon Sep 17 00:00:00 2001 From: hanakocz Date: Tue, 14 Apr 2020 09:51:09 +0200 Subject: [PATCH 60/70] chrono upgrades gui and system revamped --- locale/en/locale.cfg | 68 +++- maps/chronosphere/chrono.lua | 15 +- maps/chronosphere/chronobubles.lua | 8 +- maps/chronosphere/event_functions.lua | 16 - maps/chronosphere/gui.lua | 178 +++------ maps/chronosphere/locomotive.lua | 83 ++-- maps/chronosphere/main.lua | 13 +- maps/chronosphere/tick_functions.lua | 10 +- maps/chronosphere/upgrade_list.lua | 239 +++++++++++ maps/chronosphere/upgrades.lua | 551 ++++++++------------------ modules/pistol_buffs.lua | 2 +- 11 files changed, 580 insertions(+), 603 deletions(-) create mode 100644 maps/chronosphere/upgrade_list.lua diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index 67ae1795..45cd3365 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -87,27 +87,14 @@ message_game_lost1=The chronotrain was destroyed! message_game_lost2=Comfylatron is going to kill you for that...he has time machine after all! message_evolve=Comfylatron: Biters start to evolve faster! We need to charge forward or they will be stronger! (hover over timer to see evolve timer) message_quest1=Comfylatron: You know...I have big quest. Deliver fish to fish market. But this train is broken. Please help me fix the train computer! -message_quest2=Comfylatron: Thanks for fixing train navigation. I can now get us rid of very poor worlds. It will still need more work though. message_quest3=Comfylatron: Ah, we need to give this machine more power and better navigation chipset. Please bring me some additional things. -message_quest4=Comfylatron: Perfect! Now we have train reactor and even better destination precision. I will get to you later what still needs to be done. message_quest5=Comfylatron: Finally found the main issue. We will need to rebuild whole processor. Exactly what I feared of. Just a few more things... message_quest6=Comfylatron: And this was last part of cpu brain done. Now we just need to synchronize our time correctly and we are done! Bring me satellite and rocket silo. message_quest7=Comfylatron: Time synchronized. Calculating time and space destination. Success. Jump once more and let me deliver the fish finally. This trip is getting long. message_game_won1=Comfylatron: Thank you with helping me on this delivery. It was tough one. I hope, that now, when all biters are dead, fish will be safe here forever... message_overstay=Comfylatron: Looks like you stayed on previous planet for so long that enemies on other planets had additional time to evolve! -message_upgrade_hp=Comfylatron: Train's max HP was upgraded. -message_upgrade_filter=Comfylatron: Train's pollution filter was upgraded. -message_upgrade_acu=Comfylatron: Train's accumulator capacity was upgraded. -message_upgrade_pickup=Comfylatron: Players now have additional red inserter installed on shoulders, increasing their item pickup range. -message_upgrade_inventory=Comfylatron: Players now can carry more trash in their unsorted inventories. -message_upgrade_repair=Comfylatron: Train now gets repaired with additional repair kit at once. -message_upgrade_water=Comfylatron: Train now has piping system for additional water sources. -message_upgrade_out=Comfylatron: Train now has output chests. -message_upgrade_storage=Comfylatron: Cargo wagons now have enlarged storage. -message_upgrade_poison=Comfylatron: I don't believe in your defense skills. I equipped train with poison defense. -message_upgrade_mk2=Comfylatron: I upgraded one armor to mk2. -message_upgrade_fusion=Comfylatron: One personal fusion reactor ready. message_poison_defense=Comfylatron: Triggering poison defense. Let's kill everything! + ore_richness_very_rich=Very Rich ore_richness_rich=Rich ore_richness_normal=Normal @@ -120,6 +107,56 @@ daynight_slow=Slow daynight_superslow=Super Slow daynight_fast=Fast daynight_superfast=Super Fast + +upgrade_train_armor=Train Armor +upgrade_train_armor_message=Comfylatron: Train's max HP was upgraded. +upgrade_train_armor_tooltip=+2500 Train Max HP. Max level: __1__ Current Max HP: __2__ +upgrade_filter=Pollution Filter +upgrade_filter_message=Comfylatron: Train's pollution filter was upgraded. +upgrade_filter_tooltip=Train Pollution Filter. Decreases pollution from inside of train and from chrono engine.\nCurrent pollution made by train: __1__% +upgrade_accumulators=Accumulators +upgrade_accumulators_message=Comfylatron: Train's accumulator capacity was upgraded. +upgrade_accumulators_tooltip=Add additional row of Accumulators for train's charging system.\nEach accumulator adds 300kW possible power input. +upgrade_loot_pickup=Loot Pickup Range +upgrade_loot_pickup_message=Comfylatron: Players now have additional red inserter installed on shoulders, increasing their item pickup range. +upgrade_loot_pickup_tooltip=Add loot pickup distance to players. Current: +__1__ tiles range +upgrade_inventory_size=Character Inventory Size +upgrade_inventory_size_message=Comfylatron: Players now can carry more trash in their unsorted inventories. +upgrade_inventory_size_tooltip=Add +10 inventory slots to all players. +upgrade_repair=Train Repair Speed +upgrade_repair_message=Comfylatron: Train now gets repaired with additional repair kit at once. +upgrade_repair_tooltip=Train uses more repair tools at once from Repair chest. Current: +__1__ +upgrade_water=Piping System +upgrade_water_message=Comfylatron: Train now has piping system for additional water sources. +upgrade_water_tooltip=Add piping through wagon sides to create water sources for each wagon. +upgrade_output=Output System +upgrade_output_message=Comfylatron: Train now has output chests. +upgrade_output_tooltip=Add comfylatron chests that output outside (into cargo wagon 2 and 3) +upgrade_storage=Train Storage +upgrade_storage_message=Comfylatron: Cargo wagons now have upgraded storage. +upgrade_storage_tooltip=Add and upgrade storage chests to the sides of wagons. +upgrade_poison=Poison Defense +upgrade_poison_message=Comfylatron: I don't believe in your defense skills. I equipped train with poison defense. +upgrade_poison_tooltip=Poison defense. Triggers automatically when train has low HP.\nRecharge timer for next use: __1__ min +upgrade_fusion=Fusion Reactor +upgrade_fusion_message=Comfylatron: One personal fusion reactor ready. +upgrade_fusion_tooltip=Creates one Fusion Reactor. +upgrade_mk2=Power Armor MK2 +upgrade_mk2_message=Comfylatron: I upgraded one armor to mk2. +upgrade_mk2_tooltip=Creates one Power Armor MK2 +upgrade_computer1=Comfylatron's Quest 1 +upgrade_computer1_message=Comfylatron: Thanks for fixing train navigation. I can now get us rid of very poor worlds. It will still need more work though. +upgrade_computer1_tooltip=Progresses main quest.\nAll next worlds won't have "very poor" ore distribution. +upgrade_computer2=Comfylatron's Quest 2 +upgrade_computer2_message=Comfylatron: Perfect! Now we have train reactor and even better destination precision. I will get to you later what still needs to be done. +upgrade_computer2_tooltip=Progresses main quest.\nAll next worlds won't have "poor" ore distribution. +upgrade_computer3=Comfylatron's Quest 3 +upgrade_computer3_message=Comfylatron: That's __1__ / 10 processor parts done! +upgrade_computer3_tooltip=Progresses main quest.\nAfter completing 10th part, the final map can be unlocked. +upgrade_computer4=Comfylatron's Final Quest +upgrade_computer4_message=Comfylatron: Time synchronized. Calculating time and space destination. Success. Jump once more and let me deliver the fish finally. This trip is getting long. +upgrade_computer4_tooltip=Progresses main quest.\nBy unlocking this, the next destination is Fish Market map.\nBe sure to be ready, there is no way back! + gui_1=ChronoJumps: gui_2=Charge: gui_3=Timer: @@ -128,7 +165,8 @@ gui_3_2=Nuclear missiles launched in: gui_4=Local Evolution: gui_planet_button=Planet Info gui_upgrades_button=Upgrades -gui_upgrades_1=Insert needed items into chest with given upgrade number.\nChests are at top inside train.\nUpgrading can take a minute. +gui_upgrades_1=Insert needed items into chest with given picture. +gui_upgrades_2=Chests are at top inside the train. Upgrading can take a minute. gui_planet_0=Name: __1__ gui_planet_1=Detected ore distribution: gui_planet_2=Ore Amounts: __1__ diff --git a/maps/chronosphere/chrono.lua b/maps/chronosphere/chrono.lua index 056b78a3..09642bd3 100644 --- a/maps/chronosphere/chrono.lua +++ b/maps/chronosphere/chrono.lua @@ -27,17 +27,6 @@ function Public_chrono.restart_settings() local objective = global.objective objective.max_health = 10000 objective.health = 10000 - objective.hpupgradetier = 0 - objective.acuupgradetier = 0 - objective.filterupgradetier = 0 - objective.pickupupgradetier = 0 - objective.invupgradetier = 0 - objective.toolsupgradetier = 0 - objective.waterupgradetier = 0 - objective.outupgradetier = 0 - objective.boxupgradetier = 0 - objective.pistolupgradetier = 0 - objective.poisondefense = 2 objective.poisontimeout = 0 objective.chronotimer = 0 objective.passivetimer = 0 @@ -52,6 +41,10 @@ function Public_chrono.restart_settings() objective.looted_nukes = 0 objective.offline_players = {} objective.nextsurface = nil + for i = 1, 16, 1 do + objective.upgrades[i] = 0 + end + objective.upgrades[10] = 2 --poison global.outchests = {} global.upgradechest = {} global.fishchest = {} diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua index 5c640775..ebabf737 100644 --- a/maps/chronosphere/chronobubles.lua +++ b/maps/chronosphere/chronobubles.lua @@ -70,12 +70,12 @@ function Public.determine_planet(choice) choice = 15 ores = 2 end - if objective.computerupgrade == 3 then + if objective.upgrades[16] == 1 then choice = 17 ores = 10 end if objective.config.jumpfailure == true and objective.game_lost == false then - if objective.chronojumps == 21 or objective.chronojumps == 29 or chronojumps == 36 then + if objective.chronojumps == 21 or objective.chronojumps == 29 or chronojumps == 36 or chronojumps == 42 then choice = 19 ores = 10 dayspeed = time_speed_variants[1] @@ -92,8 +92,8 @@ function Public.determine_planet(choice) end end if planet_choice.id == 10 then ores = 10 end - if objective.computerupgrade >= 1 and ores == 9 then ores = 8 end - if objective.computerupgrade >= 2 and ores > 6 and ores ~= 10 then ores = 6 end + if objective.upgrades[13] == 1 and ores == 9 then ores = 8 end + if objective.upgrades[14] == 1 and ores > 6 and ores ~= 10 then ores = 6 end local planet = { [1] = { name = planet_choice, diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua index 30293e51..9be12da2 100644 --- a/maps/chronosphere/event_functions.lua +++ b/maps/chronosphere/event_functions.lua @@ -317,22 +317,6 @@ function Public_event.mining_buffs(event) end end -function Public_event.pistol_buffs(event) - if global.objective.pistolupgradetier == 0 then return end - if not event.cause then return end - if event.cause.name ~= "player" then return end - if event.damage_type.name ~= "physical" then return end - local player = event.cause - if player.shooting_state.state == defines.shooting.not_shooting then return end - local weapon = event.cause.get_inventory(defines.inventory.character_guns)[event.cause.selected_gun_index].name - local ammo = event.cause.get_inventory(defines.inventory.character_ammo)[event.cause.selected_gun_index].name - game.print(ammo) - game.print(wapon) - if weapon ~= "pistol" then return end - if ammo ~= "firearm-magazine" and ammo ~= "piercing-rounds-magazine" and ammo ~= "uranium-rounds-magazine" then return end - event.entity.damage(event.final_damage_amount * 4, player.force, "physical", player) -end - function Public_event.on_technology_effects_reset(event) if event.force.name == "player" then game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + global.objective.invupgradetier * 10 diff --git a/maps/chronosphere/gui.lua b/maps/chronosphere/gui.lua index 3f555386..afef36ba 100644 --- a/maps/chronosphere/gui.lua +++ b/maps/chronosphere/gui.lua @@ -5,6 +5,7 @@ local math_ceil = math.ceil local math_abs = math.abs local math_max = math.max local math_min = math.min +local Upgrades = require "maps.chronosphere.upgrade_list" local function create_gui(player) local frame = player.gui.top.add({ type = "frame", name = "chronosphere"}) @@ -74,31 +75,35 @@ local function create_gui(player) button.style.font = "default-bold" button.style.font_color = { r=0.99, g=0.99, b=0.99} button.style.minimal_width = 75 +end - -- local label = frame.add({ type = "label", caption = " ", name = "evo"}) - -- label.style.font = "default-bold" - -- label.style.right_padding = 1 - -- label.style.minimal_width = 10 - -- label.style.font_color = {r = 150, g = 0, b = 255} +local function update_upgrades_gui(player) + if not player.gui.screen["gui_upgrades"] then return end + local upgrades = Upgrades.upgrades() + local frame = player.gui.screen["gui_upgrades"] - -- local label = frame.add({ type = "label", caption = " ", name = "evo_value"}) - -- label.style.font = "default-bold" - -- label.style.right_padding = 1 - -- label.style.minimal_width = 10 - -- label.style.font_color = {r = 150, g = 0, b = 255} - - -- local label = frame.add({ type = "label", caption = " ", name = "planet"}) - -- label.style.font = "default-bold" - -- label.style.right_padding = 1 - -- label.style.minimal_width = 10 - -- label.style.font_color = {r = 0, g = 100, b = 200} - - -- local label = frame.add({ type = "label", caption = "[Upgrades]", name = "upgrades", tooltip = " "}) - -- label.style.font = "default-bold" - -- label.style.right_padding = 1 - -- label.style.minimal_width = 10 - -- label.style.font_color = {r=0.33, g=0.66, b=0.9} + for i = 1, #upgrades, 1 do + local t = frame["upgrades_table" .. i] + t["upgrade" .. i].number = global.objective.upgrades[i] + t["upgrade" .. i].tooltip = upgrades[i].tooltip + t["upgrade_label" .. i].tooltip = upgrades[i].tooltip + if global.objective.upgrades[i] == upgrades[i].max_level then + t["maxed" .. i].visible = true + t["jump_req" .. i].visible = false + for index,_ in pairs(upgrades[i].cost) do + t[index .. "-" .. i].visible = false + end + else + t["maxed" .. i].visible = false + t["jump_req" .. i].visible = true + t["jump_req" .. i].number = upgrades[i].jump_limit + for index,item in pairs(upgrades[i].cost) do + t[index .. "-" .. i].visible = true + t[index .. "-" .. i].number = item.count + end + end + end end local function update_planet_gui(player) @@ -131,6 +136,7 @@ end function Public_gui.update_gui(player) local objective = global.objective update_planet_gui(player) + update_upgrades_gui(player) if not player.gui.top.chronosphere then create_gui(player) end local gui = player.gui.top.chronosphere @@ -164,9 +170,8 @@ function Public_gui.update_gui(player) gui.planet_button.caption = {"chronosphere.gui_planet_button"} gui.upgrades_button.caption = {"chronosphere.gui_upgrades_button"} - --gui.planet.caption = "Planet: " .. objective.planet[1].name.name .. " | Ores: " .. objective.planet[1].ore_richness.name local acus = 0 - if global.acumulators then acus = #global.acumulators else acus = 0 end + if global.acumulators then acus = #global.acumulators end local bestcase = math_floor((objective.chrononeeds - objective.chronotimer) / (1 + math_floor(acus/10))) local nukecase = objective.dangertimer if objective.planet[1].name.id == 19 and objective.passivetimer > 31 then @@ -180,106 +185,47 @@ function Public_gui.update_gui(player) gui.timer2.style.font_color = {r = 0, g = 200, b = 0} gui.timer_value2.style.font_color = {r = 0, g = 200, b = 0} end - - - local evolution = game.forces["enemy"].evolution_factor - --gui.evo.caption = {"chronosphere.gui_4"} - --gui.evo_value.caption = math_floor(evolution * 100) .. "%" - local chests = { - [1] = {c = "250 wooden chests + Jump number 5\n"}, - [2] = {c = "250 iron chests + Jump number 10\n"}, - [3] = {c = "250 steel chests + Jump number 15\n"}, - [4] = {c = "250 storage chests + Jump number 20\n"}, - [5] = {c = "--\n"} - } - local upgt = { - [1] = {t = "[1]: + 2500 Train Max HP. Current: " .. objective.max_health .. "\n Cost : " .. math_floor(500 * (1 + objective.hpupgradetier /2)) .. " coins + 1500 copper plates\n"}, - [2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1) * global.difficulty_vote_value) .. "%\n Buyable once per 3 jumps.\n Cost: 5000 coins + 2000 green circuits + Jump number " .. (objective.filterupgradetier + 1) * 3 .. "\n"}, - [3] = {t = "[3]: Add additional row of Acumulators.\n Cost : " .. math_floor(2000 * (1 + objective.acuupgradetier /4)) .. " coins + 200 batteries\n"}, - [4] = {t = "[4]: Add item pickup distance to players.Current: +" .. objective.pickupupgradetier .. ",\n Cost: " .. 1000 * (1 + objective.pickupupgradetier) .. " coins + 400 red inserters\n"}, - [5] = {t = "[5]: Add +10 inventory slots. Buyable once per 5 jumps.\n Cost: " .. 2000 * (1 + objective.invupgradetier) .." coins + " .. chests[objective.invupgradetier + 1].c}, - [6] = {t = "[6]: Use up more repair tools on train at once. Current: +" .. objective.toolsupgradetier .. "\n Cost: " .. 1000 * (1 + objective.toolsupgradetier) .. " coins + " .. 200 * (1 + objective.toolsupgradetier) .. " repair tools\n"}, - [7] = {t = "[7]: Add piping through wagon sides to create water sources for each wagon.\n Cost: 2000 coins + 500 pipes\n"}, - [8] = {t = "[8]: Add comfylatron chests that output outside (into cargo wagon 2 and 3)\n Cost: 2000 coins + 100 fast inserters\n"}, - [9] = {t = "[9]: Add storage chests to the sides of wagons.\n Buyable once per 5 jumps.\n Cost: 5000 coins + " .. chests[objective.boxupgradetier + 1].c}, - [10] = {t = "[P]: Poison defense. Triggers automatically when train has low HP.\n Actual charges: " .. objective.poisondefense .. " / 4\n Recharge timer for next use: " .. math_ceil(objective.poisontimeout /6) .. "min\n Cost: 1000 coins + 50 poison capsules\n"}, - [11] = {t = "[A]: 1x mk1 armor + 300 railgun darts + 100 low density structures -> 1x mk2 armor\n"}, - [12] = {t = "[R]: 16x personal solar + 200 railgun darts + 100 low density structures -> 1x fusion reactor\n"}, - [13] = {t = "[C]: Train computer fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 1 costs: 5000 coins, 1000 advanced circuits, 2000 copper plates.\n Discards very poor planets.\n"}, - [14] = {t = "[C]: Train power and navigation fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 2 costs: 10000 coins, 1000 processing units, 1 nuclear reactor.\n Discards poor planets.\n"}, - [15] = {t = "[C]: Train time machine processor fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 3 costs per part: 2000 coins, 100 rocket control units, 100 low density structures, 50 uranium fuel cells.\n Parts finished: " .. objective.computerparts .. " / 10\n"}, - [16] = {t = "[C]: Train is repaired. Synchronize the time to unlock final map to finish the main objective.\n Costs: 1 rocket silo, 1 satellite.\n Warning: after buying this, the next jump destination is locked to final map,\n that means 100% evolution and no resources.\n"} - } - local maxed = { - [1] = {t = "[1]: Train HP maxed.\n"}, - [2] = {t = "[2]: Pollution Filter maxed. Pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%\n"}, - [3] = {t = "[3]: Acumulators maxed.\n"}, - [4] = {t = "[4]: Pickup distance maxed.\n"}, - [5] = {t = "[5]: Inventory maxed. Research Mining Productivity for more.\n"}, - [6] = {t = "[6]: Repairing at top speed of 5 packs.\n"}, - [7] = {t = "[7]: Piping created. Don't spill it!\n"}, - [8] = {t = "[8]: Output chests created.\n"}, - [9] = {t = "[9]: Storage chests fully upgraded.\n"}, - [10] = {t = "[C]: Train's next destination is Fish Market.\n"} - } - local tooltip = "Insert needed items into chest with upgrade number.\nUpgrading can take a minute.\n\n" - if objective.hpupgradetier < 36 then tooltip = tooltip .. upgt[1].t else tooltip = tooltip .. maxed[1].t end - if objective.filterupgradetier < 9 then tooltip = tooltip .. upgt[2].t else tooltip = tooltip .. maxed[2].t end - if objective.acuupgradetier < 24 then tooltip = tooltip .. upgt[3].t else tooltip = tooltip .. maxed[3].t end - if objective.pickupupgradetier < 4 then tooltip = tooltip .. upgt[4].t else tooltip = tooltip .. maxed[4].t end - if objective.invupgradetier < 4 then tooltip = tooltip .. upgt[5].t else tooltip = tooltip .. maxed[5].t end - if objective.toolsupgradetier < 4 then tooltip = tooltip .. upgt[6].t else tooltip = tooltip .. maxed[6].t end - if objective.waterupgradetier < 1 then tooltip = tooltip .. upgt[7].t else tooltip = tooltip .. maxed[7].t end - if objective.outupgradetier < 1 then tooltip = tooltip .. upgt[8].t else tooltip = tooltip .. maxed[8].t end - if objective.boxupgradetier < 4 then tooltip = tooltip .. upgt[9].t else tooltip = tooltip .. maxed[9].t end - tooltip = tooltip .. upgt[10].t - if objective.chronojumps >= 24 then - tooltip = tooltip .. upgt[11].t .. upgt[12].t - else - tooltip = tooltip .. "Armor and reactor can be bought since jump 24 (for railgun darts).\n" - end - if objective.computerupgrade == 0 and objective.chronojumps >= 15 and objective.computermessage == 1 then - tooltip = tooltip .. upgt[13].t - elseif objective.computerupgrade == 1 and objective.chronojumps >= 20 and objective.computermessage == 3 then - tooltip = tooltip .. upgt[14].t - elseif objective.computerupgrade == 2 and objective.chronojumps >= 25 and objective.computermessage == 5 then - if objective.computerparts < 10 then - tooltip = tooltip .. upgt[15].t - elseif objective.computerparts == 10 then - tooltip = tooltip .. upgt[16].t - end - elseif objective.computerupgrade == 3 and objective.chronojumps >= 25 then - tooltip = tooltip .. maxed[10].t - end - --gui.upgrades.tooltip = tooltip - - - -- if evolution < 10 then - -- gui.evo.style.font_color = {r = 255, g = 255, b = 0} - -- elseif evolution >= 10 and evolution < 50 then - -- gui.evo.style.font_color = {r = 200, g = 0, b = 0} - -- elseif evolution >= 50 and evolution < 90 then - -- gui.evo.style.font_color = {r = 0, g = 140, b = 255} - -- else - -- gui.evo.style.font_color = {r = 0, g = 255, b = 0} - -- end - -- gui.evo.style.font_color = { - -- r = math_floor(255 * 1 * math_max(0, math_min(1, 1.2 - evolution * 2))), - -- g = math_floor(255 * 1 * math_max(math_abs(0.5 - evolution * 1.5), 1 - evolution * 4)), - -- b = math_floor(255 * 4 * math_max(0, 0.25 - math_abs(0.5 - evolution))) - -- } - -- gui.evo_value.style.font_color = gui.evo.style.font_color end local function upgrades_gui(player) if player.gui.screen["gui_upgrades"] then player.gui.screen["gui_upgrades"].destroy() return end + local objective = global.objective + local upgrades = Upgrades.upgrades() local frame = player.gui.screen.add{type = "frame", name = "gui_upgrades", caption = "ChronoTrain Upgrades", direction = "vertical"} frame.location = {x = 350, y = 45} frame.style.minimal_height = 300 - frame.style.maximal_height = 300 + frame.style.maximal_height = 900 frame.style.minimal_width = 330 frame.style.maximal_width = 630 frame.add({type = "label", caption = {"chronosphere.gui_upgrades_1"}}) + frame.add({type = "label", caption = {"chronosphere.gui_upgrades_2"}}) + + for i = 1, #upgrades, 1 do + local upg_table = frame.add({type = "table", name = "upgrades_table" .. i, column_count = 10}) + upg_table.add({type = "sprite-button", name = "upgrade" .. i, enabled = false, sprite = upgrades[i].sprite, number = global.objective.upgrades[i], tooltip = upgrades[i].tooltip}) + local name = upg_table.add({type = "label", name ="upgrade_label" .. i, caption = upgrades[i].name, tooltip = upgrades[i].tooltip}) + name.style.width = 200 + + local maxed = upg_table.add({type = "sprite-button", name = "maxed" .. i, enabled = false, sprite = "virtual-signal/signal-check", tooltip = "Upgrade maxed!", visible = false}) + local jumps = upg_table.add({type = "sprite-button", name = "jump_req" .. i, enabled = false, sprite = "virtual-signal/signal-J", number = upgrades[i].jump_limit, tooltip = "Required jump number", visible = true}) + local costs = {} + for index,item in pairs(upgrades[i].cost) do + costs[index] = upg_table.add({type = "sprite-button", name = index .. "-" .. i, number = item.count, sprite = item.sprite, enabled = false, tooltip = {item.tt .. "." .. item.name}, visible = true}) + end + if global.objective.upgrades[i] == upgrades[i].max_level then + maxed.visible = true + jumps.visible = false + for index,_ in pairs(upgrades[i].cost) do + costs[index].visible = false + end + else + maxed.visible = false + jumps.visible = true + for index,_ in pairs(upgrades[i].cost) do + costs[index].visible = true + end + end + end frame.add({type = "button", name = "close_upgrades", caption = "Close"}) end @@ -287,8 +233,6 @@ local function planet_gui(player) if player.gui.screen["gui_planet"] then player.gui.screen["gui_planet"].destroy() return end local planet = global.objective.planet[1] local evolution = game.forces["enemy"].evolution_factor - --gui.evo.caption = {"chronosphere.gui_4"} - --gui.evo_value.caption = math_floor(evolution * 100) .. "%" local frame = player.gui.screen.add{type = "frame", name = "gui_planet", caption = "Planet Info", direction = "vertical"} frame.location = {x = 650, y = 45} frame.style.minimal_height = 300 @@ -339,6 +283,4 @@ function Public_gui.on_gui_click(event) if name == "close_planet" then planet_gui(player) return end end - - return Public_gui diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index 962d661a..0b899761 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -1,4 +1,5 @@ local Public = {} +local Upgrades = require "maps.chronosphere.upgrade_list" local math_floor = math.floor local math_random = math.random local function math_sgn(x) @@ -308,55 +309,39 @@ function Public.create_wagon_room() powerpole.minable = false powerpole.destructible = false - local market = surface.create_entity({name = "market", position = {-5, height * -0.5 + 13}, force="neutral", create_build_effect_smoke = false}) + local market = surface.create_entity({name = "market", position = {-30, height * -0.5 + 4}, force="neutral", create_build_effect_smoke = false}) market.minable = false market.destructible = false - - local upgradechests = { - [1] = {name = "repairchest", entity = {name = "compilatron-chest", position = {0, height * -0.5 + 13}, force = "player"}, signal = nil}, - [2] = {name = "hpchest", entity = {name = "compilatron-chest", position = {3, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-1"}, - [3] = {name = "filterchest", entity = {name = "compilatron-chest", position = {4, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-2"}, - [4] = {name = "acuchest", entity = {name = "compilatron-chest", position = {5, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-3"}, - [5] = {name = "reachchest", entity = {name = "compilatron-chest", position = {3, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-4"}, - [6] = {name = "invchest", entity = {name = "compilatron-chest", position = {4, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-5"}, - [7] = {name = "toolschest", entity = {name = "compilatron-chest", position = {5, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-6"}, - [8] = {name = "waterchest", entity = {name = "compilatron-chest", position = {3, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-7"}, - [9] = {name = "outchest", entity = {name = "compilatron-chest", position = {4, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-8"}, - [10] = {name = "boxchest", entity = {name = "compilatron-chest", position = {5, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-9"}, - [11] = {name = "poisonchest", entity = {name = "compilatron-chest", position = {6, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-P"}, - [12] = {name = "computerchest", entity = {name = "compilatron-chest", position = {6, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-C"}, - [13] = {name = "armorchest", entity = {name = "compilatron-chest", position = {7, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-A"}, - [14] = {name = "reactorchest", entity = {name = "compilatron-chest", position = {7, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-R"} - } - - for i = 1, #upgradechests, 1 do - local e = surface.create_entity(upgradechests[i].entity) - e.minable = false - e.destructible = false - global.upgradechest[i] = e - if i == 1 then - local repair_text = rendering.draw_text{ - text = "Repair chest", - surface = surface, - target = e, - target_offset = {0, -2.5}, - color = global.locomotive.color, - scale = 1.00, - font = "default-game", - alignment = "center", - scale_with_zoom = false - } - else - local upgrade_text = rendering.draw_sprite{ - sprite = upgradechests[i].signal, - surface = surface, - target = e, - target_offset = {0, -0.1}, - font = "default-game", - visible = true - } - end - end + local repairchest = surface.create_entity({name = "compilatron-chest", position = {-24, height * -0.5 + 3}, force = "player"}) + repairchest.minable = false + repairchest.destructible = false + global.upgradechest[0] = repairchest + rendering.draw_text{ + text = "Repair chest", + surface = surface, + target = repairchest, + target_offset = {0, -2.5}, + color = global.locomotive.color, + scale = 1.00, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + local upgrades = Upgrades.upgrades() + for i = 1, #upgrades, 1 do + local e = surface.create_entity({name = "compilatron-chest", position = {-21 + i, height * -0.5 + 3}, force = "player"}) + e.minable = false + e.destructible = false + global.upgradechest[i] = e + rendering.draw_sprite{ + sprite = upgrades[i].sprite, + surface = surface, + target = e, + target_offset = {0, -1.3}, + font = "default-game", + visible = true + } + end local market1_text = rendering.draw_text{ text = "Resources", @@ -372,7 +357,7 @@ function Public.create_wagon_room() local upgrade_text = rendering.draw_text{ text = "Upgrades", surface = surface, - target = global.upgradechest[3], + target = global.upgradechest[8], target_offset = {0, -3.5}, color = global.locomotive.color, scale = 1.00, @@ -383,7 +368,7 @@ function Public.create_wagon_room() local upgrade_sub_text = rendering.draw_text{ text = "Click [Upgrades] on top of screen", surface = surface, - target = global.upgradechest[3], + target = global.upgradechest[8], target_offset = {0, -2.5}, color = global.locomotive.color, scale = 0.80, diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index eed2c70e..974bf929 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -1,5 +1,6 @@ -- chronosphere -- +global.objective = {} require "modules.difficulty_vote" require "modules.biters_yield_coins" require "modules.no_deconstruction_of_neutral_entities" @@ -25,7 +26,6 @@ local Gui = require "maps.chronosphere.gui" local math_random = math.random local math_floor = math.floor local math_sqrt = math.sqrt -global.objective = {} global.objective.config = {} global.flame_boots = {} global.comfylatron = nil @@ -124,10 +124,10 @@ local function reset_map() end if game.surfaces["chronosphere"] then game.delete_surface(game.surfaces["chronosphere"]) end if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end - --chests = {} local objective = global.objective - objective.computerupgrade = 0 - objective.computerparts = 0 + for i = 13, 16, 1 do + objective.upgrades[i] = 0 + end objective.computermessage = 0 objective.chronojumps = 0 Planets.determine_planet(nil) @@ -245,7 +245,7 @@ local function chronojump(choice) game.delete_surface(oldsurface) Chrono.post_jump() Event_functions.flamer_nerfs() - surface.pollute(global.locomotive.position, 150 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps) * global.difficulty_vote_value) + surface.pollute(global.locomotive.position, 150 * (4 / (objective.upgrades[2] / 2 + 1)) * (1 + global.objective.chronojumps) * global.difficulty_vote_value) end local tick_minute_functions = { @@ -302,7 +302,7 @@ local function tick() objective.chronotimer = objective.chronotimer + 1 objective.passivetimer = objective.passivetimer + 1 if objective.chronojumps > 0 then - game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (0.5 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1)) * global.difficulty_vote_value) + game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (0.5 * objective.chronojumps) * (4 / (objective.upgrades[2] / 2 + 1)) * global.difficulty_vote_value) end if objective.planet[1].name.id == 19 then Tick_functions.dangertimer() @@ -378,7 +378,6 @@ local function on_entity_damaged(event) Event_functions.biters_chew_rocks_faster(event) if event.entity.force.name == "enemy" then Event_functions.biter_immunities(event) - Event_functions.pistol_buffs(event) end end diff --git a/maps/chronosphere/tick_functions.lua b/maps/chronosphere/tick_functions.lua index f00477cd..3d63ad79 100644 --- a/maps/chronosphere/tick_functions.lua +++ b/maps/chronosphere/tick_functions.lua @@ -46,7 +46,7 @@ function Public_tick.charge_chronosphere() if energy > 3010000 and objective.chronotimer < objective.chrononeeds - 182 and objective.chronotimer > 130 then acus[i].energy = acus[i].energy - 3000000 objective.chronotimer = objective.chronotimer + 1 - game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (10 + 2 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1)) * global.difficulty_vote_value) + game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (10 + 2 * objective.chronojumps) * (4 / (objective.upgrades[2] / 2 + 1)) * global.difficulty_vote_value) end end end @@ -54,7 +54,7 @@ end function Public_tick.transfer_pollution() local surface = game.surfaces["cargo_wagon"] if not surface then return end - local pollution = surface.get_total_pollution() * (3 / (global.objective.filterupgradetier / 3 + 1)) * global.difficulty_vote_value + local pollution = surface.get_total_pollution() * (3 / (global.objective.upgrades[2] / 3 + 1)) * global.difficulty_vote_value game.surfaces[global.active_surface_index].pollute(global.locomotive.position, pollution) surface.clear_pollution() end @@ -97,7 +97,7 @@ function Public_tick.output_items() if not global.outchests then return end if not global.locomotive_cargo[2] then return end if not global.locomotive_cargo[3] then return end - if global.objective.outupgradetier ~= 1 then return end + if global.objective.upgrades[8] ~= 1 then return end local wagon = { [1] = global.locomotive_cargo[2].get_inventory(defines.inventory.cargo_wagon), [2] = global.locomotive_cargo[3].get_inventory(defines.inventory.cargo_wagon) @@ -120,10 +120,10 @@ function Public_tick.repair_train() if not game.surfaces["cargo_wagon"] then return 0 end if objective.game_lost == true then return 0 end local count = 0 - local inv = global.upgradechest[1].get_inventory(defines.inventory.chest) + local inv = global.upgradechest[0].get_inventory(defines.inventory.chest) if objective.health < objective.max_health then count = inv.get_item_count("repair-pack") - count = math_min(count, objective.toolsupgradetier + 1, math_ceil((objective.max_health - objective.health) / 150)) + count = math_min(count, objective.upgrades[6] + 1, math_ceil((objective.max_health - objective.health) / 150)) if count > 0 then inv.remove({name = "repair-pack", count = count}) end end return count * -150 diff --git a/maps/chronosphere/upgrade_list.lua b/maps/chronosphere/upgrade_list.lua new file mode 100644 index 00000000..2f57f279 --- /dev/null +++ b/maps/chronosphere/upgrade_list.lua @@ -0,0 +1,239 @@ +local Public = {} + +local math_floor = math.floor +local math_min = math.min +local math_max = math.max +local math_abs = math.abs +local math_ceil = math.ceil + +function Public.upgrades() + if not global.objective then global.objective = {} end + if not global.objective.upgrades then + global.objective.upgrades = {} + for i = 1, 16, 1 do + global.objective.upgrades[i] = 0 + end + end + if not global.difficulty_vote_value then global.difficulty_vote_value = 1 end + + --Each upgrade is automatically added into gui. + --name : visible name in gui (best if localized) + --sprite: visible icon + --cost/item/tt = the first part of localized string, for example coin is in item-name.coin. Can be even scenario's key. + --Second part of localized string is taken from item's name. + --First additional parameter for tooltip should match the max_level + --still need to map upgrade effects in upgrades.lua / process_upgrade() if it should do more than increase level of upgrade + local upgrades = { + [1] = { + name = {"chronosphere.upgrade_train_armor"}, + sprite = "recipe/locomotive", + max_level = 36, + message = {"chronosphere.upgrade_train_armor_message"}, + tooltip = {"chronosphere.upgrade_train_armor_tooltip", 36, global.objective.max_health}, + jump_limit = global.objective.upgrades[1], + cost = { + item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 500 * (1 + global.objective.upgrades[1])}, + item2 = {name = "copper-plate", tt = "item-name", sprite = "item/copper-plate", count = 1500}, + } + }, + [2] = { + name = {"chronosphere.upgrade_filter"}, + sprite = "recipe/effectivity-module", + max_level = 9, + message = {"chronosphere.upgrade_filter_message"}, + tooltip = {"chronosphere.upgrade_filter_tooltip", math_floor(300/(global.objective.upgrades[2]/3+1) * global.difficulty_vote_value)}, + jump_limit = (1 + global.objective.upgrades[2]) * 3 or 0, + cost = { + item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 5000}, + item2 = {name = "electronic-circuit", tt = "item-name", sprite = "item/electronic-circuit", count = math_min(1 + global.objective.upgrades[2], 3) * 500 + 500}, + item3 = {name = "advanced-circuit", tt = "item-name", sprite = "item/advanced-circuit", count = math_max(math_min(1 + global.objective.upgrades[2], 6) - 3, 0) * 500}, + item4 = {name = "processing-unit", tt = "item-name", sprite = "item/processing-unit", count = math_max(math_min(1 + global.objective.upgrades[2], 9) - 6, 0) * 500} + } + }, + [3] = { + name = {"chronosphere.upgrade_accumulators"}, + sprite = "recipe/accumulator", + max_level = 24, + message = {"chronosphere.upgrade_accumulators_message"}, + tooltip = {"chronosphere.upgrade_accumulators_tooltip"}, + jump_limit = global.objective.upgrades[3], + cost = { + item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 2000 * (1 + global.objective.upgrades[3] / 4)}, + item2 = {name = "battery", tt = "item-name", sprite = "item/battery", count = 100 * (1 + global.objective.upgrades[3])} + } + }, + [4] = { + name = {"chronosphere.upgrade_loot_pickup"}, + sprite = "recipe/long-handed-inserter", + max_level = 4, + message = {"chronosphere.upgrade_loot_pickup_message"}, + tooltip = {"chronosphere.upgrade_loot_pickup_tooltip", global.objective.upgrades[4]}, + jump_limit = 0, + cost = { + item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 1000 * (1 + global.objective.upgrades[4])}, + item2 = {name = "long-handed-inserter", tt = "entity-name", sprite = "recipe/long-handed-inserter", count = 400} + } + }, + [5] = { + name = {"chronosphere.upgrade_inventory_size"}, + sprite = "entity/character", + max_level = 4, + message = {"chronosphere.upgrade_inventory_size_message"}, + tooltip = {"chronosphere.upgrade_inventory_size_tooltip"}, + jump_limit = (1 + global.objective.upgrades[5]) * 5, + cost = { + item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 2500 * (1 + global.objective.upgrades[5])}, + item2 = {name = "wooden-chest", tt = "entity-name", sprite = "item/wooden-chest", count = math_max(0, 250 - math_abs(global.objective.upgrades[5]) * 250)}, + item3 = {name = "iron-chest", tt = "entity-name", sprite = "item/iron-chest", count = math_max(0, 250 - math_abs(global.objective.upgrades[5] - 1) * 250)}, + item4 = {name = "steel-chest", tt = "entity-name", sprite = "item/steel-chest", count = math_max(0, 250 - math_abs(global.objective.upgrades[5] - 2) * 250)}, + item5 = {name = "logistic-chest-storage", tt = "entity-name", sprite = "item/logistic-chest-storage", count = math_max(0, 250 - math_abs(global.objective.upgrades[5] - 3) * 250)} + } + }, + [6] = { + name = {"chronosphere.upgrade_repair"}, + sprite = "recipe/repair-pack", + max_level = 4, + message = {"chronosphere.upgrade_repair_message"}, + tooltip = {"chronosphere.upgrade_repair_tooltip", global.objective.upgrades[6]}, + jump_limit = 0, + cost = { + item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 1000 * (1 + global.objective.upgrades[6])}, + item2 = {name = "repair-pack", tt = "item-name", sprite = "recipe/repair-pack", count = 200 * (1 + global.objective.upgrades[6])} + } + }, + [7] = { + name = {"chronosphere.upgrade_water"}, + sprite = "fluid/water", + max_level = 1, + message = {"chronosphere.upgrade_water_message"}, + tooltip = {"chronosphere.upgrade_water_tooltip"}, + jump_limit = 0, + cost = { + item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 2000}, + item2 = {name = "pipe", tt = "entity-name", sprite = "item/pipe", count = 500}, + item3 = {name = "pump", tt = "entity-name", sprite = "item/pump", count = 10} + } + }, + [8] = { + name = {"chronosphere.upgrade_output"}, + sprite = "recipe/cargo-wagon", + max_level = 1, + message = {"chronosphere.upgrade_output_message"}, + tooltip = {"chronosphere.upgrade_output_tooltip"}, + jump_limit = 0, + cost = { + item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 2000}, + item2 = {name = "fast-inserter", tt = "entity-name", sprite = "recipe/fast-inserter", count = 200} + } + }, + [9] = { + name = {"chronosphere.upgrade_storage"}, + sprite = "item/logistic-chest-storage", + max_level = 4, + message = {"chronosphere.upgrade_storage_message"}, + tooltip = {"chronosphere.upgrade_storage_tooltip"}, + jump_limit = (1 + global.objective.upgrades[9]) * 5, + cost = { + item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 2500 * (1 + global.objective.upgrades[9])}, + item2 = {name = "wooden-chest", tt = "entity-name", sprite = "item/wooden-chest", count = math_max(0, 250 - math_abs(global.objective.upgrades[9]) * 250)}, + item3 = {name = "iron-chest", tt = "entity-name", sprite = "item/iron-chest", count = math_max(0, 250 - math_abs(global.objective.upgrades[9] - 1) * 250)}, + item4 = {name = "steel-chest", tt = "entity-name", sprite = "item/steel-chest", count = math_max(0, 250 - math_abs(global.objective.upgrades[9] - 2) * 250)}, + item5 = {name = "logistic-chest-storage", tt = "entity-name", sprite = "item/logistic-chest-storage", count = math_max(0, 250 - math_abs(global.objective.upgrades[9] - 3) * 250)} + } + }, + [10] = { + name = {"chronosphere.upgrade_poison"}, + sprite = "recipe/poison-capsule", + max_level = 4, + message = {"chronosphere.upgrade_poison_message"}, + tooltip = {"chronosphere.upgrade_poison_tooltip", math_ceil(global.objective.poisontimeout /6)}, + jump_limit = 0, + cost = { + item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 1000}, + item2 = {name = "poison-capsule", tt = "item-name", sprite = "recipe/poison-capsule", count = 50} + } + }, + [11] = { + name = {"chronosphere.upgrade_fusion"}, + sprite = "recipe/fusion-reactor-equipment", + max_level = 999, + message = {"chronosphere.upgrade_fusion_message"}, + tooltip = {"chronosphere.upgrade_fusion_tooltip"}, + jump_limit = 24, + cost = { + item1 = {name = "low-density-structure", tt = "item-name", sprite = "item/low-density-structure", count = 100}, + item2 = {name = "railgun-dart", tt = "item-name", sprite = "item/railgun-dart", count = 200}, + item3 = {name = "solar-panel-equipment", tt = "equipment-name", sprite = "item/solar-panel-equipment", count = 16} + } + }, + [12] = { + name = {"chronosphere.upgrade_mk2"}, + sprite = "recipe/power-armor-mk2", + max_level = 999, + message = {"chronosphere.upgrade_mk2_message"}, + tooltip = {"chronosphere.upgrade_mk2_tooltip"}, + jump_limit = 24, + cost = { + item1 = {name = "low-density-structure", tt = "item-name", sprite = "item/low-density-structure", count = 100}, + item2 = {name = "railgun-dart", tt = "item-name", sprite = "item/railgun-dart", count = 300}, + item3 = {name = "power-armor", tt = "item-name", sprite = "item/power-armor", count = 1} + } + }, + [13] = { + name = {"chronosphere.upgrade_computer1"}, + sprite = "item/advanced-circuit", + max_level = 1, + message = {"chronosphere.upgrade_computer1_message"}, + tooltip = {"chronosphere.upgrade_computer1_tooltip"}, + jump_limit = 15, + cost = { + item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 5000}, + item2 = {name = "advanced-circuit", tt = "item-name", sprite = "item/advanced-circuit", count = 1000}, + item3 = {name = "copper-plate", tt = "item-name", sprite = "item/copper-plate", count = 2000} + } + }, + [14] = { + name = {"chronosphere.upgrade_computer2"}, + sprite = "item/processing-unit", + max_level = 1, + message = {"chronosphere.upgrade_computer2_message"}, + tooltip = {"chronosphere.upgrade_computer2_tooltip"}, + jump_limit = 20, + cost = { + item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 10000}, + item2 = {name = "processing-unit", tt = "item-name", sprite = "item/processing-unit", count = 1000}, + item3 = {name = "nuclear-reactor", tt = "entity-name", sprite = "item/nuclear-reactor", count = 1} + } + }, + [15] = { + name = {"chronosphere.upgrade_computer3"}, + sprite = "item/rocket-control-unit", + max_level = 10, + message = {"chronosphere.upgrade_computer3_message", global.objective.upgrades[15]}, + tooltip = {"chronosphere.upgrade_computer3_tooltip"}, + jump_limit = 25, + cost = { + item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 2000}, + item2 = {name = "low-density-structure", tt = "item-name", sprite = "item/low-density-structure", count = 100}, + item3 = {name = "rocket-control-unit", tt = "item-name", sprite = "item/rocket-control-unit", count = 100}, + item4 = {name = "uranium-fuel-cell", tt = "item-name", sprite = "item/uranium-fuel-cell", count = 50} + } + }, + [16] = { + name = {"chronosphere.upgrade_computer4"}, + sprite = "item/satellite", + max_level = 1, + message = {"chronosphere.upgrade_computer4_message"}, + tooltip = {"chronosphere.upgrade_computer4_tooltip"}, + jump_limit = 25, + cost = { + item1 = {name = "rocket-silo", tt = "entity-name", sprite = "item/rocket-silo", count = 1}, + item2 = {name = "satellite", tt = "item-name", sprite = "item/satellite", count = 1} + } + } + + } + return upgrades +end + +return Public diff --git a/maps/chronosphere/upgrades.lua b/maps/chronosphere/upgrades.lua index 793686d5..10d51ff4 100644 --- a/maps/chronosphere/upgrades.lua +++ b/maps/chronosphere/upgrades.lua @@ -2,320 +2,7 @@ local Public = {} local math_floor = math.floor local Server = require 'utils.server' - -local function spawn_acumulators() - local x = -28 - local y = -252 - local yy = global.objective.acuupgradetier * 2 - local surface = game.surfaces["cargo_wagon"] - if yy > 8 then yy = yy + 2 end - if yy > 26 then yy = yy + 2 end - if yy > 44 then yy = yy + 2 end - for i = 1, 27, 1 do - local acumulator = surface.create_entity({name = "accumulator", position = {x + 2 * i, y + yy}, force="player", create_build_effect_smoke = false}) - acumulator.minable = false - acumulator.destructible = false - table.insert(global.acumulators, acumulator) - end -end - -local function check_upgrade_hp() - local objective = global.objective - if not game.surfaces["cargo_wagon"] then return end - if objective.game_lost == true then return end - if global.upgradechest[2] and global.upgradechest[2].valid then - local inv = global.upgradechest[2].get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("copper-plate") - local coincost = math_floor(500 * (1 + objective.hpupgradetier /2)) - if countcoins >= coincost and count2 >= 1500 and objective.hpupgradetier < 36 then - inv.remove({name = "coin", count = coincost}) - inv.remove({name = "copper-plate", count = 1500}) - game.print({"chronosphere.message_upgrade_hp"}, {r=0.98, g=0.66, b=0.22}) - objective.hpupgradetier = objective.hpupgradetier + 1 - objective.max_health = 10000 + 2500 * objective.hpupgradetier - rendering.set_text(global.objective.health_text, "HP: " .. global.objective.health .. " / " .. global.objective.max_health) - end - end -end - -local function check_upgrade_filter() - local objective = global.objective - if global.upgradechest[3] and global.upgradechest[3].valid then - local inv = global.upgradechest[3].get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("electronic-circuit") - if countcoins >= 5000 and count2 >= 2000 and objective.filterupgradetier < 9 and objective.chronojumps >= (objective.filterupgradetier + 1) * 3 then - inv.remove({name = "coin", count = 5000}) - inv.remove({name = "electronic-circuit", count = 2000}) - game.print({"chronosphere.message_upgrade_filter"}, {r=0.98, g=0.66, b=0.22}) - objective.filterupgradetier = objective.filterupgradetier + 1 - end - end -end - -local function check_upgrade_acu() - local objective = global.objective - if global.upgradechest[4] and global.upgradechest[4].valid then - local inv = global.upgradechest[4].get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("battery") - local coincost = math_floor(2000 * (1 + objective.acuupgradetier /4)) - if countcoins >= coincost and count2 >= 200 and objective.acuupgradetier < 24 then - inv.remove({name = "coin", count = coincost}) - inv.remove({name = "battery", count = 200}) - game.print({"chronosphere.message_upgrade_acu"}, {r=0.98, g=0.66, b=0.22}) - objective.acuupgradetier = objective.acuupgradetier + 1 - spawn_acumulators() - end - end -end - -local function check_upgrade_pickup() - local objective = global.objective - if global.upgradechest[5] and global.upgradechest[5].valid then - local inv = global.upgradechest[5].get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("long-handed-inserter") - local coincost = 1000 * (1 + objective.pickupupgradetier) - if countcoins >= coincost and count2 >= 400 and objective.pickupupgradetier < 4 then - inv.remove({name = "coin", count = coincost}) - inv.remove({name = "long-handed-inserter", count = 400}) - game.print({"chronosphere.message_upgrade_pickup"}, {r=0.98, g=0.66, b=0.22}) - objective.pickupupgradetier = objective.pickupupgradetier + 1 - game.forces.player.character_loot_pickup_distance_bonus = game.forces.player.character_loot_pickup_distance_bonus + 1 - end - end -end - -local function check_upgrade_inv() - local objective = global.objective - if global.upgradechest[6] and global.upgradechest[6].valid then - local inv = global.upgradechest[6].get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local item = "computer" - if objective.invupgradetier == 0 then - item = "wooden-chest" - elseif objective.invupgradetier == 1 then - item = "iron-chest" - elseif objective.invupgradetier == 2 then - item = "steel-chest" - elseif objective.invupgradetier == 3 then - item = "logistic-chest-storage" - end - local count2 = inv.get_item_count(item) - local coincost = 2000 * (1 + objective.invupgradetier) - if countcoins >= coincost and count2 >= 250 and objective.invupgradetier < 4 and objective.chronojumps >= (objective.invupgradetier + 1) * 5 then - inv.remove({name = "coin", count = coincost}) - inv.remove({name = item, count = 250}) - game.print({"chronosphere.message_upgrade_inventory"}, {r=0.98, g=0.66, b=0.22}) - objective.invupgradetier = objective.invupgradetier + 1 - game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + 10 - end - end -end - -local function check_upgrade_tools() - local objective = global.objective - if global.upgradechest[7] and global.upgradechest[7].valid then - local inv = global.upgradechest[7].get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("repair-pack") - local coincost = 1000 * (1 + objective.toolsupgradetier) - local toolscost = 200 * (1 + objective.toolsupgradetier) - if countcoins >= coincost and count2 >= toolscost and objective.toolsupgradetier < 4 then - inv.remove({name = "coin", count = coincost}) - inv.remove({name = "repair-pack", count = toolscost}) - game.print({"chronosphere.message_upgrade_repair"}, {r=0.98, g=0.66, b=0.22}) - objective.toolsupgradetier = objective.toolsupgradetier + 1 - end - end -end - -local function check_upgrade_water() - local objective = global.objective - if global.upgradechest[8] and global.upgradechest[8].valid and game.surfaces["cargo_wagon"].valid then - local inv = global.upgradechest[8].get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("pipe") - if countcoins >= 2000 and count2 >= 500 and objective.waterupgradetier < 1 then - inv.remove({name = "coin", count = 2000}) - inv.remove({name = "pipe", count = 500}) - game.print({"chronosphere.message_upgrade_water"}, {r=0.98, g=0.66, b=0.22}) - objective.waterupgradetier = objective.waterupgradetier + 1 - local positions = {{28,66},{28,-62},{-29,66},{-29,-62}} - for i = 1, 4, 1 do - local e = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = positions[i], force="player"}) - e.destructible = false - e.minable = false - end - end - end -end - -local function check_upgrade_out() - local objective = global.objective - if global.upgradechest[9] and global.upgradechest[9].valid and game.surfaces["cargo_wagon"].valid then - local inv = global.upgradechest[9].get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("fast-inserter") - if countcoins >= 2000 and count2 >= 100 and objective.outupgradetier < 1 then - inv.remove({name = "coin", count = 2000}) - inv.remove({name = "fast-inserter", count = 100}) - game.print({"chronosphere.message_upgrade_out"}, {r=0.98, g=0.66, b=0.22}) - objective.outupgradetier = objective.outupgradetier + 1 - local positions = {{-16,-62},{15,-62},{-16,66},{15,66}} - local out = {} - for i = 1, 4, 1 do - local e = game.surfaces["cargo_wagon"].create_entity({name = "compilatron-chest", position = positions[i], force = "player"}) - e.destructible = false - e.minable = false - global.outchests[i] = e - out[i] = rendering.draw_text{ - text = "Output", - surface = e.surface, - target = e, - target_offset = {0, -1.5}, - color = global.locomotive.color, - scale = 0.80, - font = "default-game", - alignment = "center", - scale_with_zoom = false - } - end - end - end -end - -local function check_upgrade_box() - local objective = global.objective - if global.upgradechest[10] and global.upgradechest[10].valid and game.surfaces["cargo_wagon"].valid then - local inv = global.upgradechest[10].get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local item = "computer" - if objective.boxupgradetier == 0 then - item = "wooden-chest" - elseif objective.boxupgradetier == 1 then - item = "iron-chest" - elseif objective.boxupgradetier == 2 then - item = "steel-chest" - elseif objective.boxupgradetier == 3 then - item = "logistic-chest-storage" - end - local count2 = inv.get_item_count(item) - if countcoins >= 5000 and count2 >= 250 and objective.boxupgradetier < 4 and objective.chronojumps >= (objective.boxupgradetier + 1) * 5 then - inv.remove({name = "coin", count = 5000}) - inv.remove({name = item, count = 250}) - game.print({"chronosphere.message_upgrade_storage"}, {r=0.98, g=0.66, b=0.22}) - objective.boxupgradetier = objective.boxupgradetier + 1 - local chests = {} - local positions = {x = {-33, 32}, y = {-189, -127, -61, 1, 67, 129}} - for i = 1, 58, 1 do - for ii = 1, 6, 1 do - if objective.boxupgradetier == 1 then - chests[#chests + 1] = {entity = {name = "wooden-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player"}, old = "none"} - chests[#chests + 1] = {entity = {name = "wooden-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player"}, old = "none"} - elseif objective.boxupgradetier == 2 then - chests[#chests + 1] = {entity = {name = "iron-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "wood"} - chests[#chests + 1] = {entity = {name = "iron-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "wood"} - elseif objective.boxupgradetier == 3 then - chests[#chests + 1] = {entity = {name = "steel-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "iron"} - chests[#chests + 1] = {entity = {name = "steel-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "iron"} - elseif objective.boxupgradetier == 4 then - chests[#chests + 1] = {entity = {name = "logistic-chest-storage", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "steel"} - chests[#chests + 1] = {entity = {name = "logistic-chest-storage", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "steel"} - end - end - end - local surface = game.surfaces["cargo_wagon"] - for i = 1, #chests, 1 do - if objective.boxupgradetier == 1 then - surface.set_tiles({{name = "tutorial-grid", position = chests[i].entity.position}}) - end - local old = nil - local oldpos = {x = chests[i].entity.position.x + 0.5, y = chests[i].entity.position.y + 0.5} - if chests[i].old == "wood" then old = surface.find_entity("wooden-chest", oldpos) - elseif chests[i].old == "iron" then old = surface.find_entity("iron-chest", oldpos) - elseif chests[i].old == "steel" then old = surface.find_entity("steel-chest", oldpos) - end - if old then - old.minable = true - old.destructible = true - end - local e = surface.create_entity(chests[i].entity) - e.destructible = false - e.minable = false - end - end - end -end - -local function check_poisondefense() - local objective = global.objective - if global.upgradechest[11] and global.upgradechest[11].valid then - local inv = global.upgradechest[11].get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("poison-capsule") - if countcoins >= 1000 and count2 >= 50 and objective.poisondefense < 4 then - inv.remove({name = "coin", count = 1000}) - inv.remove({name = "poison-capsule", count = 50}) - game.print({"chronosphere.message_upgrade_poison"}, {r=0.98, g=0.66, b=0.22}) - objective.poisondefense = objective.poisondefense + 1 - end - end -end - -local function check_upgrade_computer() - local objective = global.objective - if global.upgradechest[12] and global.upgradechest[12].valid then - local inv = global.upgradechest[12].get_inventory(defines.inventory.chest) - local countcoins = inv.get_item_count("coin") - local count2 = inv.get_item_count("advanced-circuit") - local count3 = inv.get_item_count("processing-unit") - local count4 = inv.get_item_count("low-density-structure") - local count5 = inv.get_item_count("rocket-control-unit") - local count6 = inv.get_item_count("uranium-fuel-cell") - local count7 = inv.get_item_count("nuclear-reactor") - local count8 = inv.get_item_count("copper-plate") - local count9 = inv.get_item_count("rocket-silo") - local count10 = inv.get_item_count("satellite") - - if countcoins >= 5000 and count2 >= 1000 and count8 >= 2000 and objective.computerupgrade == 0 and objective.chronojumps >= 15 and objective.computermessage == 1 then - inv.remove({name = "coin", count = 5000}) - inv.remove({name = "advanced-circuit", count = 1000}) - inv.remove({name = "copper-plate", count = 2000}) - game.print({"chronosphere.message_quest2"}, {r=0.98, g=0.66, b=0.22}) - objective.computermessage = 2 - objective.computerupgrade = objective.computerupgrade + 1 - elseif countcoins >= 10000 and count3 >= 1000 and count7 >= 1 and objective.computerupgrade == 1 and objective.chronojumps >= 20 and objective.computermessage == 3 then - inv.remove({name = "coin", count = 10000}) - inv.remove({name = "processing-unit", count = 1000}) - inv.remove({name = "nuclear-reactor", count = 1}) - objective.computermessage = 4 - objective.computerupgrade = objective.computerupgrade + 1 - game.print({"chronosphere.message_quest4"}, {r=0.98, g=0.66, b=0.22}) - elseif objective.computerupgrade == 2 and objective.chronojumps >= 25 and objective.computermessage == 5 then - if countcoins >= 2000 and count4 >= 100 and count5 >= 100 and count6 >= 50 and objective.computerparts < 10 then - inv.remove({name = "coin", count = 2000}) - inv.remove({name = "low-density-structure", count = 100}) - inv.remove({name = "rocket-control-unit", count = 100}) - inv.remove({name = "uranium-fuel-cell", count = 50 }) - objective.computerparts = objective.computerparts + 1 - if objective.computerparts < 10 then - game.print("Comfylatron: That's another processor part done! I still need " .. 10 - objective.computerparts .. " more of those parts.", {r=0.98, g=0.66, b=0.22}) - else - game.print({"chronosphere.message_quest6"}, {r=0.98, g=0.66, b=0.22}) - end - elseif objective.computerparts == 10 and count9 >= 1 and count10 >= 1 then - inv.remove({name = "satellite", count = 1 }) - inv.remove({name = "rocket-silo", count = 1 }) - game.print({"chronosphere.message_quest7"}, {r=0.98, g=0.66, b=0.22}) - objective.computermessage = 6 - objective.computerupgrade = objective.computerupgrade + 1 - end - end - end -end +local Upgrades = require "maps.chronosphere.upgrade_list" local function check_win() local objective = global.objective @@ -351,80 +38,190 @@ local function check_win() end end -local function check_mk2_buy() - local objective = global.objective - if global.upgradechest[13] and global.upgradechest[13].valid then - local inv = global.upgradechest[13].get_inventory(defines.inventory.chest) - local count = inv.get_item_count("low-density-structure") - local count2 = inv.get_item_count("railgun-dart") - local count3 = inv.get_item_count("power-armor") - if count >= 100 and count2 >= 300 and count3 >= 1 and objective.chronojumps >= 24 then - inv.remove({name = "low-density-structure", count = 100}) - inv.remove({name = "railgun-dart", count = 300}) - inv.remove({name = "power-armor", count = 1}) - inv.insert({name = "power-armor-mk2", count = 1}) - game.print({"chronosphere.message_upgrade_mk2"}, {r=0.98, g=0.66, b=0.22}) - end +local function upgrade_hp() + global.objective.max_health = 10000 + 2500 * global.objective.upgrades[1] + rendering.set_text(global.objective.health_text, "HP: " .. global.objective.health .. " / " .. global.objective.max_health) +end + +local function spawn_acumulators() + local x = -28 + local y = -252 + local yy = global.objective.upgrades[3] * 2 + local surface = game.surfaces["cargo_wagon"] + if yy > 8 then yy = yy + 2 end + if yy > 26 then yy = yy + 2 end + if yy > 44 then yy = yy + 2 end + for i = 1, 27, 1 do + local acumulator = surface.create_entity({name = "accumulator", position = {x + 2 * i, y + yy}, force="player", create_build_effect_smoke = false}) + acumulator.minable = false + acumulator.destructible = false + table.insert(global.acumulators, acumulator) + end +end + +local function upgrade_pickup() + game.forces.player.character_loot_pickup_distance_bonus = game.forces.player.character_loot_pickup_distance_bonus + 1 +end + +local function upgrade_inv() + game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + 10 +end + +local function upgrade_water() + if not game.surfaces["cargo_wagon"] then return end + local positions = {{28,66},{28,-62},{-29,66},{-29,-62}} + for i = 1, 4, 1 do + local e = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = positions[i], force="player"}) + e.destructible = false + e.minable = false end end -local function check_fusion_buy() +local function upgrade_out() + if not game.surfaces["cargo_wagon"] then return end + local positions = {{-16,-62},{15,-62},{-16,66},{15,66}} + local out = {} + for i = 1, 4, 1 do + local e = game.surfaces["cargo_wagon"].create_entity({name = "compilatron-chest", position = positions[i], force = "player"}) + e.destructible = false + e.minable = false + global.outchests[i] = e + out[i] = rendering.draw_text{ + text = "Output", + surface = e.surface, + target = e, + target_offset = {0, -1.5}, + color = global.locomotive.color, + scale = 0.80, + font = "default-game", + alignment = "center", + scale_with_zoom = false + } + end +end + +local function upgrade_storage() local objective = global.objective - if global.upgradechest[14] and global.upgradechest[14].valid then - local inv = global.upgradechest[14].get_inventory(defines.inventory.chest) - local count = inv.get_item_count("low-density-structure") - local count2 = inv.get_item_count("railgun-dart") - local count3 = inv.get_item_count("solar-panel-equipment") - if count >= 100 and count2 >= 200 and count3 >= 16 and objective.chronojumps >= 24 then - inv.remove({name = "low-density-structure", count = 100}) - inv.remove({name = "railgun-dart", count = 200}) - inv.remove({name = "solar-panel-equipment", count = 16}) - inv.insert({name = "fusion-reactor-equipment", count = 1}) - game.print({"chronosphere.message_upgrade_fusion"}, {r=0.98, g=0.66, b=0.22}) + if not game.surfaces["cargo_wagon"] then return end + local chests = {} + local positions = {x = {-33, 32}, y = {-189, -127, -61, 1, 67, 129}} + for i = 1, 58, 1 do + for ii = 1, 6, 1 do + if objective.upgrades[9] == 1 then + chests[#chests + 1] = {entity = {name = "wooden-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player"}, old = "none"} + chests[#chests + 1] = {entity = {name = "wooden-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player"}, old = "none"} + elseif objective.upgrades[9] == 2 then + chests[#chests + 1] = {entity = {name = "iron-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "wood"} + chests[#chests + 1] = {entity = {name = "iron-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "wood"} + elseif objective.upgrades[9] == 3 then + chests[#chests + 1] = {entity = {name = "steel-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "iron"} + chests[#chests + 1] = {entity = {name = "steel-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "iron"} + elseif objective.upgrades[9] == 4 then + chests[#chests + 1] = {entity = {name = "logistic-chest-storage", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "steel"} + chests[#chests + 1] = {entity = {name = "logistic-chest-storage", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "steel"} + end end end + local surface = game.surfaces["cargo_wagon"] + for i = 1, #chests, 1 do + if objective.upgrades[9] == 1 then + surface.set_tiles({{name = "tutorial-grid", position = chests[i].entity.position}}) + end + local old = nil + local oldpos = {x = chests[i].entity.position.x + 0.5, y = chests[i].entity.position.y + 0.5} + if chests[i].old == "wood" then old = surface.find_entity("wooden-chest", oldpos) + elseif chests[i].old == "iron" then old = surface.find_entity("iron-chest", oldpos) + elseif chests[i].old == "steel" then old = surface.find_entity("steel-chest", oldpos) + end + if old then + old.minable = true + old.destructible = true + end + local e = surface.create_entity(chests[i].entity) + e.destructible = false + e.minable = false + end +end + +local function fusion_buy() + local objective = global.objective + if global.upgradechest[11] and global.upgradechest[11].valid then + local inv = global.upgradechest[14].get_inventory(defines.inventory.chest) + inv.insert({name = "fusion-reactor-equipment", count = 1}) + end +end + +local function mk2_buy() + local objective = global.objective + if global.upgradechest[13] and global.upgradechest[13].valid then + inv.insert({name = "power-armor-mk2", count = 1}) + end +end + +local function process_upgrade(index) + if index == 1 then + upgrade_hp() + elseif index == 3 then + spawn_acumulators() + elseif index == 4 then + upgrade_pickup() + elseif index == 5 then + upgrade_inv() + elseif index == 7 then + upgrade_water() + elseif index == 8 then + upgrade_out() + elseif index == 9 then + upgrade_storage() + elseif index == 11 then + fusion_buy() + elseif index == 12 then + mk2_buy() + elseif index == 13 then + global.objective.computermessage = 2 + elseif index == 14 then + global.objective.computermessage = 4 + elseif index = 15 then + if gobal.objective.upgrades[15] == 10 then + game.print({"chronosphere.message_quest6"}, {r=0.98, g=0.66, b=0.22}) + end + end +end + +local function check_single_upgrade(index) + local upgrades = Upgrades.upgrades() + if global.upgradechest[index] and global.upgradechest[index].valid then + local inv = global.upgradechest[index].get_inventory(defines.inventory.chest) + if global.objective.upgrades[index] < upgrades[index].max_level and global.objective.chronojumps >= upgrades[index].jump_limit then + for _, item in pairs(upgrades[index].cost) do + if inv.get_item_count(item.name) < item.count then return end + end + else + return + end + for _, item in pairs(upgrades[index].cost) do + if item.count > 0 then + inv.remove({name = item.name, count = item.count}) + end + end + game.print(upgrades[index].message, {r=0.98, g=0.66, b=0.22}) + global.objective.upgrades[index] = global.objective.upgrades[index] + 1 + process_upgrade(index) + end +end + +local function check_all_upgrades() + local upgrades = Upgrades.upgrades() + for i = 1, #upgrades, 1 do + check_single_upgrade(i) + end end function Public.check_upgrades() local objective = global.objective if not global.upgradechest then return end - if objective.hpupgradetier < 36 then - check_upgrade_hp() - end - if objective.filterupgradetier < 9 and objective.chronojumps >= (objective.filterupgradetier + 1) * 3 then - check_upgrade_filter() - end - if objective.acuupgradetier < 24 then - check_upgrade_acu(Locomotive) - end - if objective.pickupupgradetier < 4 then - check_upgrade_pickup() - end - if objective.invupgradetier < 4 and objective.chronojumps >= (objective.invupgradetier + 1) * 5 then - check_upgrade_inv() - end - if objective.toolsupgradetier < 4 then - check_upgrade_tools() - end - if objective.waterupgradetier < 1 then - check_upgrade_water() - end - if objective.outupgradetier < 1 then - check_upgrade_out() - end - if objective.boxupgradetier < 4 and objective.chronojumps >= (objective.boxupgradetier + 1) * 5 then - check_upgrade_box() - end - if objective.poisondefense < 4 then - check_poisondefense() - end - if objective.computerupgrade < 3 and objective.chronojumps >= 15 then - check_upgrade_computer() - end - if objective.chronojumps >= 24 then - check_mk2_buy() - check_fusion_buy() - end + if objective.game_lost == true then return end + check_all_upgrades() if objective.planet[1].name.id == 17 then if global.fishchest then check_win() diff --git a/modules/pistol_buffs.lua b/modules/pistol_buffs.lua index ab4c4a68..d133ca1f 100644 --- a/modules/pistol_buffs.lua +++ b/modules/pistol_buffs.lua @@ -15,7 +15,7 @@ local function on_entity_damaged(event) if not weapon.valid_for_read or not ammo.valid_for_read then return end if weapon.name ~= "pistol" then return end if ammo.name ~= "firearm-magazine" and ammo.name ~= "piercing-rounds-magazine" and ammo.name ~= "uranium-rounds-magazine" then return end - event.entity.damage(event.final_damage_amount * 4, player.force, "physical") + event.entity.damage(event.final_damage_amount * 4, player.force, "physical", player) end event.add(defines.events.on_entity_damaged, on_entity_damaged) From bd4adad200082270a18b45dcf6a9a1a385055cd9 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Tue, 14 Apr 2020 16:24:32 +0200 Subject: [PATCH 61/70] fixes --- locale/en/locale.cfg | 26 +++++++++-- maps/chronosphere/chrono.lua | 10 ++--- maps/chronosphere/chronobubles.lua | 70 +++++++++++++++--------------- maps/chronosphere/locomotive.lua | 2 +- maps/chronosphere/main.lua | 8 ++-- maps/chronosphere/upgrade_list.lua | 2 +- maps/chronosphere/upgrades.lua | 18 +++++--- modules/admins_operate_biters.lua | 4 +- modules/pistol_buffs.lua | 2 +- 9 files changed, 86 insertions(+), 56 deletions(-) diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index 45cd3365..722f6380 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -67,6 +67,7 @@ map_info_main_caption=Chronosphere map_info_sub_caption= ..Comfylatron gone wild.. map_info_text_old=Comfylatron has seized The Fish Train and turned it into a time machine.\nIt is your job to make sure the cargo is safe throughout the times and places we travel through!\nThis however will not be an easy task,\nas Comfylatron does not have any idea how to control this machine at all.\n\nThe destinations of quantum time jumps are completely random, and the machine always needs time to recharge.\nYou can speed it up greatly by charging acumulators in Locomotive.\nSo be sure to grab as many resources as you can before the train jump away!\nComfylatron manages to run teleporting devices to transport items into train from his chests. Also to save people from staying in wrong universe.\n\nOnce a quantum jump is initiated, be sure to have everything packed up, there is nearly zero chance to revisit that place again!\nMining productivity research will overhaul your mining equipment,\nreinforcing your pickaxes, as well as increasing the size of your backpack.\nGood luck on your journey! map_info_text=Comfylatron has seized the Fish Train and turned it into a time machine.\n Your job as his slave is:\n\n[1] Keep train alive at all costs\n[2] Gather resources while travelling through different maps.\n[3a] Press enter on cargo wagons to enter insides of train.\n[3b] Press enter on cars to exit the train.\n[4] Charging acumulators inside train speeds up jumps when leaving early is needed.\nCharging and jumping creates huge pollution so be ready to get attacked.\n[5] Items inserted into comfylatron chests get teleported into train.\n[6] Some planets are poor, some are rich, and some are just too dangerous.\n\n Loot, but also evolution grows with jumps performed.\n During jump, personnel will be teleported in,\n however dead bodies nor buildings won't.\nMining productivity grants inventory space and handmining speed.\n\nGood luck. Don't let biters ruin the show! +planet_jump=Destination: __1__, Ore Richness: __2__, Daynight cycle: __3__ message_danger1=Comfylatron: We have a problem! We got disrupted in mid-jump, only part of energy got used, and here we landed. It might have been a trap! message_danger2=Comfylatron: My analysis says that charging needs full energy reset to work again, so we are stuck there until next full jump. message_danger3=Robot voice: INTRUDER ALERT! Lifeforms detected! Must eliminate! @@ -95,6 +96,25 @@ message_game_won1=Comfylatron: Thank you with helping me on this delivery. It wa message_overstay=Comfylatron: Looks like you stayed on previous planet for so long that enemies on other planets had additional time to evolve! message_poison_defense=Comfylatron: Triggering poison defense. Let's kill everything! +map_1=Terra Ferrata +map_2=Malachite Hills +map_3=Granite Plains +map_4=Petroleum Basin +map_5=Pitchblende Mountain +map_6=Mixed Deposits +map_7=Biter Homelands +map_8=Gangue Dumps +map_9=Antracite Valley +map_10=Ancient Battlefield +map_11=Cave Systems +map_12=Strange Forest +map_13=Riverlands +map_14=Burning Hell +map_15=Starting Area +map_16=Hedge Maze +map_17=Fish Market +map_18=Methane Swamps +map_19=ERROR DESTINATION NOT FOUND ore_richness_very_rich=Very Rich ore_richness_rich=Rich ore_richness_normal=Normal @@ -137,7 +157,7 @@ upgrade_storage_message=Comfylatron: Cargo wagons now have upgraded storage. upgrade_storage_tooltip=Add and upgrade storage chests to the sides of wagons. upgrade_poison=Poison Defense upgrade_poison_message=Comfylatron: I don't believe in your defense skills. I equipped train with poison defense. -upgrade_poison_tooltip=Poison defense. Triggers automatically when train has low HP.\nRecharge timer for next use: __1__ min +upgrade_poison_tooltip=Poison defense. Triggers automatically when train has low HP.\nMax charges : 4. Recharge timer for next use: __1__ min. upgrade_fusion=Fusion Reactor upgrade_fusion_message=Comfylatron: One personal fusion reactor ready. upgrade_fusion_tooltip=Creates one Fusion Reactor. @@ -145,10 +165,10 @@ upgrade_mk2=Power Armor MK2 upgrade_mk2_message=Comfylatron: I upgraded one armor to mk2. upgrade_mk2_tooltip=Creates one Power Armor MK2 upgrade_computer1=Comfylatron's Quest 1 -upgrade_computer1_message=Comfylatron: Thanks for fixing train navigation. I can now get us rid of very poor worlds. It will still need more work though. +upgrade_computer1_message=Comfylatron: Thanks for fixing train navigation. I can now get us rid of very poor worlds. It will still need more work though, come back after jump. upgrade_computer1_tooltip=Progresses main quest.\nAll next worlds won't have "very poor" ore distribution. upgrade_computer2=Comfylatron's Quest 2 -upgrade_computer2_message=Comfylatron: Perfect! Now we have train reactor and even better destination precision. I will get to you later what still needs to be done. +upgrade_computer2_message=Comfylatron: Perfect! Now we have train reactor and even better destination precision. I will get to you after jump with what still needs to be done. upgrade_computer2_tooltip=Progresses main quest.\nAll next worlds won't have "poor" ore distribution. upgrade_computer3=Comfylatron's Quest 3 upgrade_computer3_message=Comfylatron: That's __1__ / 10 processor parts done! diff --git a/maps/chronosphere/chrono.lua b/maps/chronosphere/chrono.lua index 09642bd3..9b18b919 100644 --- a/maps/chronosphere/chrono.lua +++ b/maps/chronosphere/chrono.lua @@ -160,19 +160,19 @@ function Public_chrono.process_jump(choice) Server.to_discord_embed(message) if objective.chronojumps == 6 then - game.print({"chronosphere.message_evolve"}, {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_evolve"}, {r=0.98, g=0.36, b=0.22}) elseif objective.chronojumps >= 15 and objective.computermessage == 0 then - game.print({"chronosphere.message_quest1"}, {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_quest1"}, {r=0.98, g=0.36, b=0.22}) objective.computermessage = 1 elseif objective.chronojumps >= 20 and objective.computermessage == 2 then - game.print({"chronosphere.message_quest3"}, {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_quest3"}, {r=0.98, g=0.36, b=0.22}) objective.computermessage = 3 elseif objective.chronojumps >= 25 and objective.computermessage == 4 then - game.print({"chronosphere.message_quest5"}, {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_quest5"}, {r=0.98, g=0.36, b=0.22}) objective.computermessage = 5 end if overstayed then - game.print({"chronosphere.message_overstay"}, {r=0.98, g=0.66, b=0.22}) + game.print({"chronosphere.message_overstay"}, {r=0.98, g=0.36, b=0.22}) end if objective.planet[1].name.id == 19 then check_nuke_silos() diff --git a/maps/chronosphere/chronobubles.lua b/maps/chronosphere/chronobubles.lua index ebabf737..9281f111 100644 --- a/maps/chronosphere/chronobubles.lua +++ b/maps/chronosphere/chronobubles.lua @@ -3,47 +3,47 @@ local math_random = math.random --cumul_chance must be sum of this and all previous chances, add new planets at the end only, or recalculate --biters: used in spawner generation within math_random(1, 52 - biters), so higher number gives better chance. not to be greater than 50. local variants = { - [1] = {id = 1, name = "iron planet", iron = 6, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 1}, - [2] = {id = 2, name = "copper planet", iron = 1, copper = 6, coal = 1, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0.2, chance = 1, cumul_chance = 2}, - [3] = {id = 3, name = "stone planet", iron = 1, copper = 1, coal = 1, stone = 6, uranium = 0, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 3}, - [4] = {id = 4, name = "oil planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 6, biters = 16, moisture = 0.1, chance = 1, cumul_chance = 4}, - [5] = {id = 5, name = "uranium planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 6, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 5}, - [6] = {id = 6, name = "mixed planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 0, oil = 2, biters = 10, moisture = 0, chance = 3, cumul_chance = 8}, - [7] = {id = 7, name = "biter planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 4, oil = 3, biters = 40, moisture = 0.2, chance = 4, cumul_chance = 12}, - [8] = {id = 8, name = "poor planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 16, moisture = 0.1, chance = 1, cumul_chance = 13}, - [9] = {id = 9, name = "coal planet", iron = 1, copper = 1, coal = 6, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0, chance = 1, cumul_chance = 14}, - [10] = {id = 10, name = "scrapyard", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 0, moisture = -0.2, chance = 3, cumul_chance = 17}, - [11] = {id = 11, name = "rocky planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 6, moisture = -0.2, chance = 2, cumul_chance = 19}, - [12] = {id = 12, name = "choppy planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 1, biters = 6, moisture = 0.4, chance = 2, cumul_chance = 21}, - [13] = {id = 13, name = "river planet", iron = 1, copper = 1, coal = 3, stone = 1, uranium = 0, oil = 0, biters = 8, moisture = 0.5, chance = 2, cumul_chance = 23}, - [14] = {id = 14, name = "lava planet", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 0, oil = 0, biters = 6, moisture = -0.5, chance = 1, cumul_chance = 24}, - [15] = {id = 15, name = "start planet", iron = 5, copper = 3, coal = 5, stone = 2, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24}, - [16] = {id = 16, name = "hedge maze", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 1, oil = 2, biters = 16, moisture = -0.1, chance = 2, cumul_chance = 26}, - [17] = {id = 17, name = "fish market", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 100, moisture = 0, chance = 0, cumul_chance = 26}, - [18] = {id = 18, name = "swamp planet", iron = 2, copper = 0, coal = 3, stone = 0, uranium = 0, oil = 2, biters = 16, moisture = 0.5, chance = 2, cumul_chance = 28}, - [19] = {id = 19, name = "jump failure", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 0, moisture = 0, chance = 0, cumul_chance = 28} + [1] = {id = 1, name = {"chronosphere.map_1"}, dname = "Terra Ferrata", iron = 6, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 1}, + [2] = {id = 2, name = {"chronosphere.map_2"}, dname = "Malachite Hills", iron = 1, copper = 6, coal = 1, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0.2, chance = 1, cumul_chance = 2}, + [3] = {id = 3, name = {"chronosphere.map_3"}, dname = "Granite Plains", iron = 1, copper = 1, coal = 1, stone = 6, uranium = 0, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 3}, + [4] = {id = 4, name = {"chronosphere.map_4"}, dname = "Petroleum Basin", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 6, biters = 16, moisture = 0.1, chance = 1, cumul_chance = 4}, + [5] = {id = 5, name = {"chronosphere.map_5"}, dname = "Pitchblende Mountain", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 6, oil = 1, biters = 16, moisture = -0.2, chance = 1, cumul_chance = 5}, + [6] = {id = 6, name = {"chronosphere.map_6"}, dname = "Mixed Deposits", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 0, oil = 2, biters = 10, moisture = 0, chance = 3, cumul_chance = 8}, + [7] = {id = 7, name = {"chronosphere.map_7"}, dname = "Biter Homelands", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 4, oil = 3, biters = 40, moisture = 0.2, chance = 4, cumul_chance = 12}, + [8] = {id = 8, name = {"chronosphere.map_8"}, dname = "Gangue Dumps", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 16, moisture = 0.1, chance = 1, cumul_chance = 13}, + [9] = {id = 9, name = {"chronosphere.map_9"}, dname = "Antracite Valley", iron = 1, copper = 1, coal = 6, stone = 1, uranium = 0, oil = 1, biters = 16, moisture = 0, chance = 1, cumul_chance = 14}, + [10] = {id = 10, name = {"chronosphere.map_10"}, dname = "Ancient Battlefield", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 0, moisture = -0.2, chance = 3, cumul_chance = 17}, + [11] = {id = 11, name = {"chronosphere.map_11"}, dname = "Cave Systems", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 6, moisture = -0.2, chance = 2, cumul_chance = 19}, + [12] = {id = 12, name = {"chronosphere.map_12"}, dname = "Strange Forest", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 1, biters = 6, moisture = 0.4, chance = 2, cumul_chance = 21}, + [13] = {id = 13, name = {"chronosphere.map_13"}, dname = "Riverlands", iron = 1, copper = 1, coal = 3, stone = 1, uranium = 0, oil = 0, biters = 8, moisture = 0.5, chance = 2, cumul_chance = 23}, + [14] = {id = 14, name = {"chronosphere.map_14"}, dname = "Burning Hell", iron = 2, copper = 2, coal = 2, stone = 2, uranium = 0, oil = 0, biters = 6, moisture = -0.5, chance = 1, cumul_chance = 24}, + [15] = {id = 15, name = {"chronosphere.map_15"}, dname = "Starting Area", iron = 5, copper = 3, coal = 5, stone = 2, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24}, + [16] = {id = 16, name = {"chronosphere.map_16"}, dname = "Hedge Maze", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 1, oil = 2, biters = 16, moisture = -0.1, chance = 2, cumul_chance = 26}, + [17] = {id = 17, name = {"chronosphere.map_17"}, dname = "Fish Market", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 100, moisture = 0, chance = 0, cumul_chance = 26}, + [18] = {id = 18, name = {"chronosphere.map_18"}, dname = "Methane Swamps", iron = 2, copper = 0, coal = 3, stone = 0, uranium = 0, oil = 2, biters = 16, moisture = 0.5, chance = 2, cumul_chance = 28}, + [19] = {id = 19, name = {"chronosphere.map_19"}, dname = "ERROR DESTINATION NOT FOUND", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 0, biters = 0, moisture = 0, chance = 0, cumul_chance = 28} } local time_speed_variants = { - [1] = {name = {"chronosphere.daynight_static"}, timer = 0}, - [2] = {name = {"chronosphere.daynight_normal"}, timer = 100}, - [3] = {name = {"chronosphere.daynight_slow"}, timer = 200}, - [4] = {name = {"chronosphere.daynight_superslow"}, timer = 400}, - [5] = {name = {"chronosphere.daynight_fast"}, timer = 50}, - [6] = {name = {"chronosphere.daynight_superfast"}, timer = 25} + [1] = {name = {"chronosphere.daynight_static"}, dname = "static", timer = 0}, + [2] = {name = {"chronosphere.daynight_normal"}, dname = "normal", timer = 100}, + [3] = {name = {"chronosphere.daynight_slow"}, dname = "slow", timer = 200}, + [4] = {name = {"chronosphere.daynight_superslow"}, dname = "superslow", timer = 400}, + [5] = {name = {"chronosphere.daynight_fast"}, dname = "fast", timer = 50}, + [6] = {name = {"chronosphere.daynight_superfast"}, dname = "superfast", timer = 25} } local richness = { - [1] = {name = {"chronosphere.ore_richness_very_rich"}, factor = 3}, - [2] = {name = {"chronosphere.ore_richness_rich"}, factor = 2}, - [3] = {name = {"chronosphere.ore_richness_rich"}, factor = 2}, - [4] = {name = {"chronosphere.ore_richness_normal"}, factor = 1}, - [5] = {name = {"chronosphere.ore_richness_normal"}, factor = 1}, - [6] = {name = {"chronosphere.ore_richness_normal"}, factor = 1}, - [7] = {name = {"chronosphere.ore_richness_poor"}, factor = 0.6}, - [8] = {name = {"chronosphere.ore_richness_poor"}, factor = 0.6}, - [9] = {name = {"chronosphere.ore_richness_very_poor"}, factor = 0.3}, - [10] = {name = {"chronosphere.ore_richness_none"}, factor = 0} + [1] = {name = {"chronosphere.ore_richness_very_rich"}, dname = "very rich", factor = 3}, + [2] = {name = {"chronosphere.ore_richness_rich"}, dname = "rich", factor = 2}, + [3] = {name = {"chronosphere.ore_richness_rich"}, dname = "rich", factor = 2}, + [4] = {name = {"chronosphere.ore_richness_normal"}, dname = "normal", factor = 1}, + [5] = {name = {"chronosphere.ore_richness_normal"}, dname = "normal", factor = 1}, + [6] = {name = {"chronosphere.ore_richness_normal"}, dname = "normal", factor = 1}, + [7] = {name = {"chronosphere.ore_richness_poor"}, dname = "poor", factor = 0.6}, + [8] = {name = {"chronosphere.ore_richness_poor"}, dname = "poor", factor = 0.6}, + [9] = {name = {"chronosphere.ore_richness_very_poor"}, dname = "very poor", factor = 0.3}, + [10] = {name = {"chronosphere.ore_richness_none"}, dname = "none", factor = 0} } local function roll(weight) for i = 1, 100, 1 do diff --git a/maps/chronosphere/locomotive.lua b/maps/chronosphere/locomotive.lua index 0b899761..373b6b72 100644 --- a/maps/chronosphere/locomotive.lua +++ b/maps/chronosphere/locomotive.lua @@ -309,7 +309,7 @@ function Public.create_wagon_room() powerpole.minable = false powerpole.destructible = false - local market = surface.create_entity({name = "market", position = {-30, height * -0.5 + 4}, force="neutral", create_build_effect_smoke = false}) + local market = surface.create_entity({name = "market", position = {-29, height * -0.5 + 4}, force="neutral", create_build_effect_smoke = false}) market.minable = false market.destructible = false local repairchest = surface.create_entity({name = "compilatron-chest", position = {-24, height * -0.5 + 3}, force = "player"}) diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index 974bf929..6ebe0f5e 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -1,6 +1,7 @@ -- chronosphere -- global.objective = {} +global.objective.upgrades = {} require "modules.difficulty_vote" require "modules.biters_yield_coins" require "modules.no_deconstruction_of_neutral_entities" @@ -37,9 +38,10 @@ local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 32, ['grenade'] = local function generate_overworld(surface, optplanet) Planets.determine_planet(optplanet) local planet = global.objective.planet - --local message = "Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name - --game.print(message, {r=0.98, g=0.66, b=0.22}) - --Server.to_discord_embed(message) + local message = {"chronosphere.planet_jump", planet[1].name.name, planet[1].ore_richness.name, planet[1].day_speed.name} + game.print(message, {r=0.98, g=0.66, b=0.22}) + local discordmessage = "Destination: "..planet[1].name.dname..", Ore Richness: "..planet[1].ore_richness.dname..", Daynight cycle: "..planet[1].day_speed.dname + Server.to_discord_embed(discordmessage) if planet[1].name.id == 12 then game.print({"chronosphere.message_choppy"}, {r=0.98, g=0.66, b=0.22}) elseif planet[1].name.id == 14 then diff --git a/maps/chronosphere/upgrade_list.lua b/maps/chronosphere/upgrade_list.lua index 2f57f279..e7c7cc06 100644 --- a/maps/chronosphere/upgrade_list.lua +++ b/maps/chronosphere/upgrade_list.lua @@ -209,7 +209,7 @@ function Public.upgrades() name = {"chronosphere.upgrade_computer3"}, sprite = "item/rocket-control-unit", max_level = 10, - message = {"chronosphere.upgrade_computer3_message", global.objective.upgrades[15]}, + message = {"chronosphere.upgrade_computer3_message", global.objective.upgrades[15] + 1}, tooltip = {"chronosphere.upgrade_computer3_tooltip"}, jump_limit = 25, cost = { diff --git a/maps/chronosphere/upgrades.lua b/maps/chronosphere/upgrades.lua index 10d51ff4..ce846692 100644 --- a/maps/chronosphere/upgrades.lua +++ b/maps/chronosphere/upgrades.lua @@ -181,8 +181,8 @@ local function process_upgrade(index) global.objective.computermessage = 2 elseif index == 14 then global.objective.computermessage = 4 - elseif index = 15 then - if gobal.objective.upgrades[15] == 10 then + elseif index == 15 then + if global.objective.upgrades[15] == 10 then game.print({"chronosphere.message_quest6"}, {r=0.98, g=0.66, b=0.22}) end end @@ -191,6 +191,13 @@ end local function check_single_upgrade(index) local upgrades = Upgrades.upgrades() if global.upgradechest[index] and global.upgradechest[index].valid then + if index == 14 and (global.objective.upgrades[13] ~= 1 or global.objective.computermessage ~= 3) then + return + elseif index == 15 and (global.objective.upgrades[14] ~= 1 or global.objective.computermessage ~= 5) then + return + elseif index == 16 and global.objective.upgrades[15] ~= 10 then + return + end local inv = global.upgradechest[index].get_inventory(defines.inventory.chest) if global.objective.upgrades[index] < upgrades[index].max_level and global.objective.chronojumps >= upgrades[index].jump_limit then for _, item in pairs(upgrades[index].cost) do @@ -199,13 +206,14 @@ local function check_single_upgrade(index) else return end + for _, item in pairs(upgrades[index].cost) do if item.count > 0 then inv.remove({name = item.name, count = item.count}) end end - game.print(upgrades[index].message, {r=0.98, g=0.66, b=0.22}) global.objective.upgrades[index] = global.objective.upgrades[index] + 1 + game.print(upgrades[index].message, {r=0.98, g=0.66, b=0.22}) process_upgrade(index) end end @@ -232,9 +240,9 @@ end function Public.trigger_poison() local objective = global.objective if objective.game_lost then return end - if objective.poisondefense > 0 and objective.poisontimeout == 0 then + if objective.upgrades[10] > 0 and objective.poisontimeout == 0 then local objective = global.objective - objective.poisondefense = objective.poisondefense - 1 + objective.upgrades[10] = objective.upgrades[10] - 1 objective.poisontimeout = 120 local objs = {global.locomotive, global.locomotive_cargo[1], global.locomotive_cargo[2], global.locomotive_cargo[3]} local surface = objective.surface diff --git a/modules/admins_operate_biters.lua b/modules/admins_operate_biters.lua index d5099f0a..7a3308d9 100644 --- a/modules/admins_operate_biters.lua +++ b/modules/admins_operate_biters.lua @@ -446,7 +446,7 @@ local function biter_panel(player) drop_down.style.right_padding = 12 drop_down.style.left_padding = 12 t0.add({type = "sprite-button", name = "info", sprite = "virtual-signal/signal-info"}) - t0.add({type = "sprite-button", name = "close", sprite = "virtual-signal/signal-X"}) + t0.add({type = "sprite-button", name = "close_biters", sprite = "virtual-signal/signal-X"}) local l1 = frame.add({type = "label", caption = "Camera"}) local t1 = frame.add({type = "table", name = "camera", column_count = 2}) @@ -570,7 +570,7 @@ local function on_gui_click(event) if event.element.type ~= "button" and event.element.type ~= "sprite-button" then return end --if event.frame.name ~= "biter_panel" then return end local name = event.element.name - if name == "close" then biter_panel(player) return end + if name == "close_biters" then biter_panel(player) return end if name == "info" then show_info(player) return end if name == "close_info" then show_info(player) return end if comm_functions[name] then diff --git a/modules/pistol_buffs.lua b/modules/pistol_buffs.lua index d133ca1f..106a3376 100644 --- a/modules/pistol_buffs.lua +++ b/modules/pistol_buffs.lua @@ -15,7 +15,7 @@ local function on_entity_damaged(event) if not weapon.valid_for_read or not ammo.valid_for_read then return end if weapon.name ~= "pistol" then return end if ammo.name ~= "firearm-magazine" and ammo.name ~= "piercing-rounds-magazine" and ammo.name ~= "uranium-rounds-magazine" then return end - event.entity.damage(event.final_damage_amount * 4, player.force, "physical", player) + event.entity.damage(event.final_damage_amount * 4, player.force, "impact", player) end event.add(defines.events.on_entity_damaged, on_entity_damaged) From c71a2eeac32e15d899054354d14355e1b1cb845d Mon Sep 17 00:00:00 2001 From: hanakocz Date: Fri, 17 Apr 2020 23:01:34 +0200 Subject: [PATCH 62/70] mf fixes, biter command fix --- locale/en/locale.cfg | 2 +- maps/mountain_fortress_v2/collapse.lua | 2 +- maps/mountain_fortress_v2/terrain.lua | 50 +++++++++++++------------- maps/mountain_fortress_v2/treasure.lua | 25 ++++++++++--- modules/admins_operate_biters.lua | 4 ++- 5 files changed, 51 insertions(+), 32 deletions(-) diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index 722f6380..77d3b0cd 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -183,7 +183,7 @@ gui_3=Timer: gui_3_1=Best Case Timer: gui_3_2=Nuclear missiles launched in: gui_4=Local Evolution: -gui_planet_button=Planet Info +gui_planet_button=Map Info gui_upgrades_button=Upgrades gui_upgrades_1=Insert needed items into chest with given picture. gui_upgrades_2=Chests are at top inside the train. Upgrading can take a minute. diff --git a/maps/mountain_fortress_v2/collapse.lua b/maps/mountain_fortress_v2/collapse.lua index f624b244..430b992a 100644 --- a/maps/mountain_fortress_v2/collapse.lua +++ b/maps/mountain_fortress_v2/collapse.lua @@ -139,7 +139,7 @@ local function setup_next_collapse() end if not map_collapse.positions then - if math_random(1, 64) == 1 then map_collapse.last_position = {x = 0, y = 128} end + --if math_random(1, 64) == 1 then map_collapse.last_position = {x = 0, y = 128} end set_positions(surface) return end diff --git a/maps/mountain_fortress_v2/terrain.lua b/maps/mountain_fortress_v2/terrain.lua index fc092bf9..09f83091 100644 --- a/maps/mountain_fortress_v2/terrain.lua +++ b/maps/mountain_fortress_v2/terrain.lua @@ -71,7 +71,7 @@ local function process_level_11_position(p, seed, tiles, entities, markets, trea if noise_1 > -0.30 and noise_1 < 0.30 then if noise_1 > -0.14 and noise_1 < 0.14 then tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,2) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end if math_random(1,256) == 1 then treasure[#treasure + 1] = p end else tiles[#tiles + 1] = {name = "out-of-map", position = p} @@ -119,7 +119,7 @@ local function process_level_10_position(p, seed, tiles, entities, markets, trea if math_random(1,100) > 88 then entities[#entities + 1] = {name = "tree-0" .. math_random(1,9), position = p} else - if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,2) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end end tiles[#tiles + 1] = {name = "dirt-6", position = p} return @@ -134,7 +134,7 @@ local function process_level_9_position(p, seed, tiles, entities, markets, treas if maze_noise > -0.35 and maze_noise < 0.35 then tiles[#tiles + 1] = {name = "dirt-7", position = p} local no_rocks_2 = get_noise("no_rocks_2", p, seed) - if math_random(1,3) == 1 and no_rocks_2 > -0.5 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,2) == 1 and no_rocks_2 > -0.5 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end if math_random(1,1024) == 1 then treasure[#treasure + 1] = p end if math_random(1,256) == 1 then Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier) @@ -189,7 +189,7 @@ local function process_level_8_position(p, seed, tiles, entities, markets, treas end tiles[#tiles + 1] = {name = "dirt-7", position = p} if scrapyard < -0.55 or scrapyard > 0.55 then - if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,2) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end if scrapyard < -0.28 or scrapyard > 0.28 then @@ -215,7 +215,7 @@ local function process_level_8_position(p, seed, tiles, entities, markets, treas if scrapyard > -0.15 and scrapyard < 0.15 then if math_floor(large_caves * 10) % 4 < 3 then tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,2) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end end @@ -291,7 +291,7 @@ local function process_level_7_position(p, seed, tiles, entities, markets, treas end tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,100) > 15 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end if math_random(1,256) == 1 then treasure[#treasure + 1] = p end end @@ -327,7 +327,7 @@ local function process_level_6_position(p, seed, tiles, entities, markets, treas end else tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,100) > 15 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end if math_random(1,512) == 1 then treasure[#treasure + 1] = p end if math_random(1,4096) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end if math_random(1,8096) == 1 then markets[#markets + 1] = p end @@ -338,10 +338,10 @@ local function process_level_5_position(p, seed, tiles, entities, markets, treas local small_caves = get_noise("small_caves", p, seed) local noise_cave_ponds = get_noise("cave_ponds", p, seed) - if small_caves > -0.14 and small_caves < 0.14 then + if small_caves > -0.24 and small_caves < 0.24 then tiles[#tiles + 1] = {name = "dirt-7", position = p} if math_random(1,768) == 1 then treasure[#treasure + 1] = p end - if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,2) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end @@ -355,7 +355,7 @@ local function process_level_5_position(p, seed, tiles, entities, markets, treas return end - if small_caves > -0.30 and small_caves < 0.30 then + if small_caves > -0.40 and small_caves < 0.40 then if noise_cave_ponds > 0.35 then tiles[#tiles + 1] = {name = "dirt-" .. math_random(1, 4), position = p} if math_random(1,256) == 1 then treasure[#treasure + 1] = p end @@ -365,7 +365,7 @@ local function process_level_5_position(p, seed, tiles, entities, markets, treas if noise_cave_ponds > 0.25 then tiles[#tiles + 1] = {name = "dirt-7", position = p} if math_random(1,512) == 1 then treasure[#treasure + 1] = p end - if math_random(1,4) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,2) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end end @@ -399,18 +399,18 @@ local function process_level_4_position(p, seed, tiles, entities, markets, treas end if math_abs(noise_large_caves) > 0.475 then tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,4) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,2) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end return end --Chasms if noise_cave_ponds < 0.15 and noise_cave_ponds > -0.15 then - if small_caves > 0.55 then + if small_caves > 0.75 then tiles[#tiles + 1] = {name = "out-of-map", position = p} return end - if small_caves < -0.55 then + if small_caves < -0.75 then tiles[#tiles + 1] = {name = "out-of-map", position = p} return end @@ -418,12 +418,12 @@ local function process_level_4_position(p, seed, tiles, entities, markets, treas if small_caves > -0.15 and small_caves < 0.15 then tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,4) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,2) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end if math_random(1, 1024) == 1 then treasure[#treasure + 1] = p end return end - if noise_large_caves > -0.1 and noise_large_caves < 0.1 then + if noise_large_caves > -0.2 and noise_large_caves < 0.2 then --Main Rock Terrain local no_rocks_2 = get_noise("no_rocks_2", p, seed + 75000) @@ -435,7 +435,7 @@ local function process_level_4_position(p, seed, tiles, entities, markets, treas if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,100) > 60 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,100) > 30 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end @@ -461,7 +461,7 @@ local function process_level_3_position(p, seed, tiles, entities, markets, treas return end - if noise_large_caves > -0.2 and noise_large_caves < 0.2 or small_caves_2 > 0 then + if noise_large_caves > -0.15 and noise_large_caves < 0.15 or small_caves_2 > 0 then --Green Water Ponds if noise_cave_ponds > 0.80 then tiles[#tiles + 1] = {name = "deepwater-green", position = p} @@ -471,11 +471,11 @@ local function process_level_3_position(p, seed, tiles, entities, markets, treas --Chasms if noise_cave_ponds < 0.12 and noise_cave_ponds > -0.12 then - if small_caves > 0.65 then + if small_caves > 0.85 then tiles[#tiles + 1] = {name = "out-of-map", position = p} return end - if small_caves < -0.65 then + if small_caves < -0.85 then tiles[#tiles + 1] = {name = "out-of-map", position = p} return end @@ -493,7 +493,7 @@ local function process_level_3_position(p, seed, tiles, entities, markets, treas local cave_rivers_2 = get_noise("cave_rivers_2", p, seed) if cave_rivers_2 < 0.024 and cave_rivers_2 > -0.024 then if noise_cave_ponds < 0.4 then - tiles[#tiles + 1] = {name = "water", position = p} + tiles[#tiles + 1] = {name = "water-shallow", position = p} if math_random(1,64) == 1 then entities[#entities + 1] = {name="fish", position=p} end return end @@ -530,7 +530,7 @@ local function process_level_3_position(p, seed, tiles, entities, markets, treas if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,100) > 60 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,100) > 30 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end @@ -614,7 +614,7 @@ local function process_level_2_position(p, seed, tiles, entities, markets, treas if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,100) > 55 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,100) > 25 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end @@ -698,7 +698,7 @@ local function process_level_1_position(p, seed, tiles, entities, markets, treas if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,100) > 55 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,100) > 25 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end end local levels = { @@ -872,7 +872,7 @@ local function wall(surface, left_top, seed) local small_caves = get_noise("small_caves", p, seed) local cave_ponds = get_noise("cave_rivers", p, seed + 100000) if y > 9 + cave_ponds * 6 and y < 23 + small_caves * 6 then - if small_caves > 0.05 or cave_ponds > 0.05 then + if small_caves > 0.15 or cave_ponds > 0.15 then --surface.set_tiles({{name = "water-shallow", position = p}}) surface.set_tiles({{name = "deepwater", position = p}}) if math_random(1,48) == 1 then surface.create_entity({name = "fish", position = p}) end diff --git a/maps/mountain_fortress_v2/treasure.lua b/maps/mountain_fortress_v2/treasure.lua index 86eb8bc4..e51832e3 100644 --- a/maps/mountain_fortress_v2/treasure.lua +++ b/maps/mountain_fortress_v2/treasure.lua @@ -1,8 +1,25 @@ -local math_random = math.random - local Public = {} +local math_random = math.random +local math_floor = math.floor +local math_abs = math.abs + +local LootRaffle = require "functions.loot_raffle" + function Public.treasure_chest(surface, position, container_name) + local budget = 32 + math_abs(position.y) * 5 + budget = budget * math_random(25, 175) * 0.01 + if math_random(1,200) == 1 then budget = budget * 5 end + budget = math_floor(budget) + 1 + + local item_stacks = LootRaffle.roll(budget, 16) + local container = surface.create_entity({name = container_name, position = position, force = "neutral"}) + for _, item_stack in pairs(item_stacks) do + container.insert(item_stack) + end +end + +function Public.treasure_chest_old(surface, position, container_name) local chest_raffle = {} local chest_loot = { @@ -119,8 +136,8 @@ function Public.treasure_chest(surface, position, container_name) {{name = "decider-combinator", count = math_random(4,8)}, weight = 2, d_min = 0.1, d_max = 1}, {{name = "power-switch", count = 1}, weight = 2, d_min = 0.1, d_max = 1}, {{name = "programmable-speaker", count = math_random(2,4)}, weight = 1, d_min = 0.1, d_max = 1}, - {{name = "green-wire", count = math_random(10,19)}, weight = 2, d_min = 0.1, d_max = 1}, - {{name = "red-wire", count = math_random(10,19)}, weight = 2, d_min = 0.1, d_max = 1}, + {{name = "green-wire", count = math_random(50,99)}, weight = 4, d_min = 0.1, d_max = 1}, + {{name = "red-wire", count = math_random(50,99)}, weight = 4, d_min = 0.1, d_max = 1}, {{name = "chemical-plant", count = math_random(1,3)}, weight = 3, d_min = 0.3, d_max = 1}, {{name = "burner-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.0, d_max = 0.2}, {{name = "electric-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.2, d_max = 1}, diff --git a/modules/admins_operate_biters.lua b/modules/admins_operate_biters.lua index 7a3308d9..2b992154 100644 --- a/modules/admins_operate_biters.lua +++ b/modules/admins_operate_biters.lua @@ -415,7 +415,9 @@ local function build_groups(player) table.insert(groups, tostring(g.id)) end end - end + else + g = nil + end end table.insert(groups, "Select Group") return groups From 66330e03f0f82e30ca8aa0601719bce65fd71350 Mon Sep 17 00:00:00 2001 From: Jacob Date: Fri, 17 Apr 2020 23:46:53 -0400 Subject: [PATCH 63/70] fix infinite technology buffs --- maps/chronosphere/event_functions.lua | 46 +++++++-------------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/maps/chronosphere/event_functions.lua b/maps/chronosphere/event_functions.lua index 30293e51..5e28b7ad 100644 --- a/maps/chronosphere/event_functions.lua +++ b/maps/chronosphere/event_functions.lua @@ -293,46 +293,18 @@ function Public_event.mining_buffs(event) local tech = mining_researches[event.research.name] if tech.bonus_productivity then - if tech.infinite then - game.forces.player.mining_drill_productivity_bonus = game.forces.player.mining_drill_productivity_bonus + tech.bonus_productivity * (event.technology.level - tech.infinite_level) - else - game.forces.player.mining_drill_productivity_bonus = game.forces.player.mining_drill_productivity_bonus + tech.bonus_productivity - end + game.forces.player.mining_drill_productivity_bonus = game.forces.player.mining_drill_productivity_bonus + tech.bonus_productivity end if tech.bonus_mining_speed then - if tech.infinite then - game.forces.player.manual_mining_speed_modifier = game.forces.player.manual_mining_speed_modifier + tech.bonus_mining_speed * (event.technology.level - tech.infinite_level) - else - game.forces.player.manual_mining_speed_modifier = game.forces.player.manual_mining_speed_modifier + tech.bonus_mining_speed - end + game.forces.player.manual_mining_speed_modifier = game.forces.player.manual_mining_speed_modifier + tech.bonus_mining_speed end if tech.bonus_inventory then - if tech.infinite then - game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + tech.bonus_inventory * (event.technology.level - tech.infinite_level) - else - game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + tech.bonus_inventory - end + game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + tech.bonus_inventory end end -function Public_event.pistol_buffs(event) - if global.objective.pistolupgradetier == 0 then return end - if not event.cause then return end - if event.cause.name ~= "player" then return end - if event.damage_type.name ~= "physical" then return end - local player = event.cause - if player.shooting_state.state == defines.shooting.not_shooting then return end - local weapon = event.cause.get_inventory(defines.inventory.character_guns)[event.cause.selected_gun_index].name - local ammo = event.cause.get_inventory(defines.inventory.character_ammo)[event.cause.selected_gun_index].name - game.print(ammo) - game.print(wapon) - if weapon ~= "pistol" then return end - if ammo ~= "firearm-magazine" and ammo ~= "piercing-rounds-magazine" and ammo ~= "uranium-rounds-magazine" then return end - event.entity.damage(event.final_damage_amount * 4, player.force, "physical", player) -end - function Public_event.on_technology_effects_reset(event) if event.force.name == "player" then game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + global.objective.invupgradetier * 10 @@ -340,11 +312,17 @@ function Public_event.on_technology_effects_reset(event) local fake_event = {} Public_event.mining_buffs(nil) - for tech in pairs(mining_researches) do + for tech, bonuses in pairs(mining_researches) do tech = game.forces.player.technologies[tech] - if tech.researched == true then + if tech.researched == true or bonuses.infinite == true then fake_event.research = tech - Public_event.mining_buffs(fake_event) + if bonuses.infinite and bonuses.infinite_level and tech.level > bonuses.infinite_level then + for i = bonuses.infinite_level, tech.level - 1 do + Public_event.mining_buffs(fake_event) + end + else + Public_event.mining_buffs(fake_event) + end end end end From b66f9df935a7efdebd71ad916a05bd4a1d5086b5 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sat, 18 Apr 2020 06:09:55 +0200 Subject: [PATCH 64/70] mountain fortress tweaks --- maps/mountain_fortress_v2/locomotive.lua | 18 +++++++++--------- maps/mountain_fortress_v2/main.lua | 3 ++- maps/mountain_fortress_v2/terrain.lua | 4 +++- maps/mountain_fortress_v2/treasure.lua | 10 +++++++--- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/maps/mountain_fortress_v2/locomotive.lua b/maps/mountain_fortress_v2/locomotive.lua index 031dc7e4..004304b1 100644 --- a/maps/mountain_fortress_v2/locomotive.lua +++ b/maps/mountain_fortress_v2/locomotive.lua @@ -77,8 +77,8 @@ local market_offers = { } local function create_wagon_room() - local width = 17 - local height = 39 + local width = 32 + local height = 64 local map_gen_settings = { ["width"] = width, ["height"] = height, @@ -98,8 +98,8 @@ local function create_wagon_room() surface.request_to_generate_chunks({0,0}, 1) surface.force_generate_chunk_requests() - for x = width * -0.5 + 1, width * 0.5, 1 do - for y = height * -0.5, height * 0.5, 1 do + for x = width * -0.5, width * 0.5 - 1, 1 do + for y = height * -0.5, height * 0.5 - 1, 1 do surface.set_tiles({{name = "tutorial-grid", position = {x,y}}}) if math.random(1, 5) == 1 and y > 2 then surface.spill_item_stack({x + math.random(0, 9) * 0.1,y + math.random(0, 9) * 0.1},{name = "raw-fish", count = 1}, false) @@ -107,20 +107,20 @@ local function create_wagon_room() end end - for x = width * -0.5 + 6, width * 0.5 - 5, 1 do - for y = height * -0.5 + 2, height * -0.5 + 4, 1 do + for x = width * -0.5 + 4, width * 0.5 - 5, 1 do + for y = height * -0.5 + 4, height * -0.5 + 6, 1 do local p = {x,y} surface.set_tiles({{name = "water", position = p}}) if math.random(1, 2) == 1 then surface.create_entity({name = "fish", position = p}) end end end - local market = surface.create_entity({name = "market", position = {0, height * -0.5 + 7}, force="neutral", create_build_effect_smoke = false}) + local market = surface.create_entity({name = "market", position = {0, height * -0.5 + 9}, force="neutral", create_build_effect_smoke = false}) market.minable = false market.destructible = false for _, offer in pairs(market_offers) do market.add_market_item(offer) end - for _, x in pairs({width * -0.5, width * 0.5 + 1}) do + for _, x in pairs({width * -0.5 -0.5, width * 0.5 + 0.5}) do local e = surface.create_entity({name = "car", position = {x, 0}, force = "player", create_build_effect_smoke = false}) e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16}) e.destructible = false @@ -133,7 +133,7 @@ local function create_wagon_room() e.ai_settings.allow_try_return_to_spawner = false local positions = {} - for x = width * -0.5 + 2, width * 0.5 - 1, 1 do + for x = width * -0.5 + 2, width * 0.5 - 2, 1 do for y = 4, height * 0.5 - 1, 1 do positions[#positions + 1] = {x = x, y = y} end diff --git a/maps/mountain_fortress_v2/main.lua b/maps/mountain_fortress_v2/main.lua index 3986a6a3..595f6739 100644 --- a/maps/mountain_fortress_v2/main.lua +++ b/maps/mountain_fortress_v2/main.lua @@ -181,7 +181,7 @@ local function hidden_biter(entity) if math_random(1, 64) == 1 then BiterHealthBooster.add_boss_unit(unit, m * 10 + 1, 0.38) else - BiterHealthBooster.add_unit(unit, m * 0.2 + 1) + BiterHealthBooster.add_unit(unit, m * 0.1 + 1) end end @@ -290,6 +290,7 @@ local function on_entity_died(event) end if event.entity.force.index == 3 then + if event.entity.name == "character" then return end --local r_max = 15 - math.floor(math.abs(event.entity.position.y) / (level_depth * 0.5)) --if r_max < 3 then r_max = 3 end if math_random(1,8) == 1 then diff --git a/maps/mountain_fortress_v2/terrain.lua b/maps/mountain_fortress_v2/terrain.lua index 09f83091..c687408f 100644 --- a/maps/mountain_fortress_v2/terrain.lua +++ b/maps/mountain_fortress_v2/terrain.lua @@ -199,6 +199,7 @@ local function process_level_8_position(p, seed, tiles, entities, markets, treas end if math_random(1,96) == 1 then entities[#entities + 1] = {name = scrap_entities[math_random(1, scrap_entities_index)], position = p, force = "enemy"} end if math_random(1,5) > 1 then entities[#entities + 1] = {name="mineable-wreckage", position=p} end + if math_random(1,256) == 1 then entities[#entities + 1] = {name ="land-mine", position = p, force = "enemy"} end return end return @@ -215,7 +216,7 @@ local function process_level_8_position(p, seed, tiles, entities, markets, treas if scrapyard > -0.15 and scrapyard < 0.15 then if math_floor(large_caves * 10) % 4 < 3 then tiles[#tiles + 1] = {name = "dirt-7", position = p} - if math_random(1,2) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end + if math_random(1,2) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end return end end @@ -223,6 +224,7 @@ local function process_level_8_position(p, seed, tiles, entities, markets, treas if math_random(1,64) == 1 and cave_ponds > 0.6 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end tiles[#tiles + 1] = {name = "stone-path", position = p} + if math_random(1,256) == 1 then entities[#entities +1] = {name ="land-mine", position = p, force = "enemy"} end end local function process_level_7_position(p, seed, tiles, entities, markets, treasure) diff --git a/maps/mountain_fortress_v2/treasure.lua b/maps/mountain_fortress_v2/treasure.lua index e51832e3..f48819f6 100644 --- a/maps/mountain_fortress_v2/treasure.lua +++ b/maps/mountain_fortress_v2/treasure.lua @@ -7,16 +7,20 @@ local math_abs = math.abs local LootRaffle = require "functions.loot_raffle" function Public.treasure_chest(surface, position, container_name) - local budget = 32 + math_abs(position.y) * 5 + local budget = 32 + math_abs(position.y) * 2 budget = budget * math_random(25, 175) * 0.01 - if math_random(1,200) == 1 then budget = budget * 5 end + if math_random(1,200) == 1 then + budget = budget * 10 + container_name = "compilatron-chest" + end budget = math_floor(budget) + 1 - local item_stacks = LootRaffle.roll(budget, 16) + local item_stacks = LootRaffle.roll(budget, 8) local container = surface.create_entity({name = container_name, position = position, force = "neutral"}) for _, item_stack in pairs(item_stacks) do container.insert(item_stack) end + container.minable = false end function Public.treasure_chest_old(surface, position, container_name) From cba9bc38b7b919bfad3ad8ad3063714ad19df6a6 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sat, 18 Apr 2020 20:42:42 +0200 Subject: [PATCH 65/70] conflicts.... --- comfy_panel/config.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/comfy_panel/config.lua b/comfy_panel/config.lua index 16352cfd..ef4d6a1c 100644 --- a/comfy_panel/config.lua +++ b/comfy_panel/config.lua @@ -82,8 +82,8 @@ local function on_gui_click(event) end end -comfy_panel_tabs["Config"] = {gui = build_config_gui, admin = false} +comfy_panel_tabs["Config"] = build_config_gui local event = require 'utils.event' -event.add(defines.events.on_gui_click, on_gui_click) \ No newline at end of file +event.add(defines.events.on_gui_click, on_gui_click) From 573a9ae6f0088da94a9859a078c0b799678f2038 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sat, 18 Apr 2020 21:08:11 +0200 Subject: [PATCH 66/70] Delete config.lua --- comfy_panel/config.lua | 89 ------------------------------------------ 1 file changed, 89 deletions(-) delete mode 100644 comfy_panel/config.lua diff --git a/comfy_panel/config.lua b/comfy_panel/config.lua deleted file mode 100644 index ef4d6a1c..00000000 --- a/comfy_panel/config.lua +++ /dev/null @@ -1,89 +0,0 @@ --- config tab -- - -local Tabs = require 'comfy_panel.main' - -local functions = { - ["comfy_panel_spectator_switch"] = function(event) - if event.element.switch_state == "left" then - game.players[event.player_index].spectator = true - else - game.players[event.player_index].spectator = false - end - end, - - ["comfy_panel_auto_hotbar_switch"] = function(event) - if event.element.switch_state == "left" then - global.auto_hotbar_enabled[event.player_index] = true - else - global.auto_hotbar_enabled[event.player_index] = false - end - end, -} - -local function add_switch(element, switch_state, name, description_main, description) - local t = element.add({type = "table", column_count = 5}) - local label = t.add({type = "label", caption = "ON"}) - label.style.padding = 0 - label.style.left_padding= 10 - label.style.font_color = {0.77, 0.77, 0.77} - local switch = t.add({type = "switch", name = name}) - switch.switch_state = switch_state - switch.style.padding = 0 - switch.style.margin = 0 - local label = t.add({type = "label", caption = "OFF"}) - label.style.padding = 0 - label.style.font_color = {0.70, 0.70, 0.70} - - local label = t.add({type = "label", caption = description_main}) - label.style.padding = 2 - label.style.left_padding= 10 - label.style.minimal_width = 120 - label.style.font = "heading-2" - label.style.font_color = {0.88, 0.88, 0.99} - - local label = t.add({type = "label", caption = description}) - label.style.padding = 2 - label.style.left_padding= 10 - label.style.single_line = false - label.style.font = "heading-3" - label.style.font_color = {0.85, 0.85, 0.85} -end - -local build_config_gui = (function (player, frame) - frame.clear() - - local line_elements = {} - local switch_label_elements = {} - local label_elements = {} - - line_elements[#line_elements + 1] = frame.add({type = "line"}) - - local switch_state = "right" - if player.spectator then switch_state = "left" end - add_switch(frame, switch_state, "comfy_panel_spectator_switch", "SpectatorMode", "Disables zoom-to-world view noise effect.\nEnvironmental sounds will be based on map view.") - - line_elements[#line_elements + 1] = frame.add({type = "line"}) - - if global.auto_hotbar_enabled then - local switch_state = "right" - if global.auto_hotbar_enabled[player.index] then switch_state = "left" end - add_switch(frame, switch_state, "comfy_panel_auto_hotbar_switch", "AutoHotbar", "Automatically fills your hotbar with placeable items.") - line_elements[#line_elements + 1] = frame.add({type = "line"}) - end - -end) - -local function on_gui_click(event) - if not event.element then return end - if not event.element.valid then return end - if functions[event.element.name] then - functions[event.element.name](event) - return - end -end - -comfy_panel_tabs["Config"] = build_config_gui - - -local event = require 'utils.event' -event.add(defines.events.on_gui_click, on_gui_click) From c7ecb7220ccb64cf6ad5713b938c7f3b033951f7 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sat, 18 Apr 2020 21:09:11 +0200 Subject: [PATCH 67/70] Create config.lua --- comfy_panel/config.lua | 220 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 comfy_panel/config.lua diff --git a/comfy_panel/config.lua b/comfy_panel/config.lua new file mode 100644 index 00000000..6fe24230 --- /dev/null +++ b/comfy_panel/config.lua @@ -0,0 +1,220 @@ +-- config tab -- + +local Tabs = require 'comfy_panel.main' + +local spaghett_entity_blacklist = { + ["logistic-chest-requester"] = true, + ["logistic-chest-buffer"] = true, + ["logistic-chest-active-provider"] = true, +} + +local function spaghett_deny_building(event) + local spaghett = global.comfy_panel_config.spaghett + if not spaghett.enabled then return end + local entity = event.created_entity + if not entity.valid then return end + if not spaghett_entity_blacklist[event.created_entity.name] then return end + + if event.player_index then + game.players[event.player_index].insert({name = entity.name, count = 1}) + else + local inventory = event.robot.get_inventory(defines.inventory.robot_cargo) + inventory.insert({name = entity.name, count = 1}) + end + + event.created_entity.surface.create_entity({ + name = "flying-text", + position = entity.position, + text = "Spaghett Mode Active!", + color = {r=0.98, g=0.66, b=0.22} + }) + + entity.destroy() +end + +local function spaghett() + local spaghett = global.comfy_panel_config.spaghett + if spaghett.enabled then + for _, f in pairs(game.forces) do + if f.technologies["logistic-system"].researched then + spaghett.undo[f.index] = true + end + f.technologies["logistic-system"].enabled = false + f.technologies["logistic-system"].researched = false + end + else + for _, f in pairs(game.forces) do + f.technologies["logistic-system"].enabled = true + if spaghett.undo[f.index] then + f.technologies["logistic-system"].researched = true + spaghett.undo[f.index] = nil + end + end + end +end + +local functions = { + ["comfy_panel_spectator_switch"] = function(event) + if event.element.switch_state == "left" then + game.players[event.player_index].spectator = true + else + game.players[event.player_index].spectator = false + end + end, + + ["comfy_panel_auto_hotbar_switch"] = function(event) + if event.element.switch_state == "left" then + global.auto_hotbar_enabled[event.player_index] = true + else + global.auto_hotbar_enabled[event.player_index] = false + end + end, + ["comfy_panel_blueprint_toggle"] = function(event) + if event.element.switch_state == "left" then + game.permissions.get_group("Default").set_allows_action(defines.input_action.grab_blueprint_record, true) + game.permissions.get_group("Default").set_allows_action(defines.input_action.import_blueprint_string, true) + game.permissions.get_group("Default").set_allows_action(defines.input_action.import_blueprint, true) + else + game.permissions.get_group("Default").set_allows_action(defines.input_action.grab_blueprint_record, false) + game.permissions.get_group("Default").set_allows_action(defines.input_action.import_blueprint_string, false) + game.permissions.get_group("Default").set_allows_action(defines.input_action.import_blueprint, false) + end + end, + ["comfy_panel_spaghett_toggle"] = function(event) + if event.element.switch_state == "left" then + global.comfy_panel_config.spaghett.enabled = true + else + global.comfy_panel_config.spaghett.enabled = nil + end + spaghett() + end, +} + +local function add_switch(element, switch_state, name, description_main, description) + local t = element.add({type = "table", column_count = 5}) + local label = t.add({type = "label", caption = "ON"}) + label.style.padding = 0 + label.style.left_padding= 10 + label.style.font_color = {0.77, 0.77, 0.77} + local switch = t.add({type = "switch", name = name}) + switch.switch_state = switch_state + switch.style.padding = 0 + switch.style.margin = 0 + local label = t.add({type = "label", caption = "OFF"}) + label.style.padding = 0 + label.style.font_color = {0.70, 0.70, 0.70} + + local label = t.add({type = "label", caption = description_main}) + label.style.padding = 2 + label.style.left_padding= 10 + label.style.minimal_width = 120 + label.style.font = "heading-2" + label.style.font_color = {0.88, 0.88, 0.99} + + local label = t.add({type = "label", caption = description}) + label.style.padding = 2 + label.style.left_padding= 10 + label.style.single_line = false + label.style.font = "heading-3" + label.style.font_color = {0.85, 0.85, 0.85} + + return switch +end + +local build_config_gui = (function (player, frame) + frame.clear() + + local admin = player.admin + + local label = frame.add({type = "label", caption = "Player Settings"}) + label.style.font = "default-bold" + label.style.padding = 0 + label.style.left_padding = 10 + label.style.horizontal_align = "left" + label.style.vertical_align = "bottom" + label.style.font_color = {0.55, 0.55, 0.99} + + frame.add({type = "line"}) + + local switch_state = "right" + if player.spectator then switch_state = "left" end + add_switch(frame, switch_state, "comfy_panel_spectator_switch", "SpectatorMode", "Toggles zoom-to-world view noise effect.\nEnvironmental sounds will be based on map view.") + + frame.add({type = "line"}) + + if global.auto_hotbar_enabled then + local switch_state = "right" + if global.auto_hotbar_enabled[player.index] then switch_state = "left" end + add_switch(frame, switch_state, "comfy_panel_auto_hotbar_switch", "AutoHotbar", "Automatically fills your hotbar with placeable items.") + frame.add({type = "line"}) + end + + local label = frame.add({type = "label", caption = "Admin Settings"}) + label.style.font = "default-bold" + label.style.padding = 0 + label.style.left_padding = 10 + label.style.top_padding = 10 + label.style.horizontal_align = "left" + label.style.vertical_align = "bottom" + label.style.font_color = {0.77, 0.11, 0.11} + + frame.add({type = "line"}) + + local switch_state = "right" + if game.permissions.get_group("Default").allows_action(defines.input_action.import_blueprint) then switch_state = "left" end + local switch = add_switch(frame, switch_state, "comfy_panel_blueprint_toggle", "Blueprint Library", "Toggles the usage of blueprint strings and the library.") + if not admin then switch.ignored_by_interaction = true end + + frame.add({type = "line"}) + + local switch_state = "right" + if global.comfy_panel_config.spaghett.enabled then switch_state = "left" end + local switch = add_switch(frame, switch_state, "comfy_panel_spaghett_toggle", "Spaghett Mode", "Disables the Logistic System research.\nRequester, buffer or active-provider containers can not be built.") + if not admin then switch.ignored_by_interaction = true end + + frame.add({type = "line"}) + + for _, e in pairs(frame.children) do + if e.type == "line" then + e.style.padding = 0 + e.style.margin = 0 + end + end +end) + +local function on_gui_switch_state_changed(event) + if not event.element then return end + if not event.element.valid then return end + if functions[event.element.name] then + functions[event.element.name](event) + return + end +end + +local function on_force_created(event) + spaghett() +end + +local function on_built_entity(event) + spaghett_deny_building(event) +end + +local function on_robot_built_entity(event) + spaghett_deny_building(event) +end + +local function on_init() + global.comfy_panel_config = {} + global.comfy_panel_config.spaghett = {} + global.comfy_panel_config.spaghett.undo = {} +end + +comfy_panel_tabs["Config"] = build_config_gui + + +local Event = require 'utils.event' +Event.on_init(on_init) +Event.add(defines.events.on_gui_switch_state_changed, on_gui_switch_state_changed) +Event.add(defines.events.on_force_created, on_force_created) +Event.add(defines.events.on_built_entity, on_built_entity) +Event.add(defines.events.on_robot_built_entity, on_robot_built_entity) From 8995a1e248c60c81cf412cc2e3cc891b839711d0 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Sat, 18 Apr 2020 21:28:19 +0200 Subject: [PATCH 68/70] modules fix and some final changes --- comfy_panel/config.lua | 60 ++++++++++++++++++------------------ control.lua | 6 ++-- modules/pistol_buffs.lua | 1 + modules/railgun_enhancer.lua | 2 +- 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/comfy_panel/config.lua b/comfy_panel/config.lua index 6fe24230..8a8d7a05 100644 --- a/comfy_panel/config.lua +++ b/comfy_panel/config.lua @@ -1,4 +1,4 @@ --- config tab -- +-- config tab -- local Tabs = require 'comfy_panel.main' @@ -13,22 +13,22 @@ local function spaghett_deny_building(event) if not spaghett.enabled then return end local entity = event.created_entity if not entity.valid then return end - if not spaghett_entity_blacklist[event.created_entity.name] then return end - + if not spaghett_entity_blacklist[event.created_entity.name] then return end + if event.player_index then - game.players[event.player_index].insert({name = entity.name, count = 1}) - else + game.players[event.player_index].insert({name = entity.name, count = 1}) + else local inventory = event.robot.get_inventory(defines.inventory.robot_cargo) - inventory.insert({name = entity.name, count = 1}) + inventory.insert({name = entity.name, count = 1}) end - + event.created_entity.surface.create_entity({ name = "flying-text", position = entity.position, text = "Spaghett Mode Active!", color = {r=0.98, g=0.66, b=0.22} }) - + entity.destroy() end @@ -50,19 +50,19 @@ local function spaghett() spaghett.undo[f.index] = nil end end - end + end end local functions = { - ["comfy_panel_spectator_switch"] = function(event) + ["comfy_panel_spectator_switch"] = function(event) if event.element.switch_state == "left" then game.players[event.player_index].spectator = true else game.players[event.player_index].spectator = false end end, - - ["comfy_panel_auto_hotbar_switch"] = function(event) + + ["comfy_panel_auto_hotbar_switch"] = function(event) if event.element.switch_state == "left" then global.auto_hotbar_enabled[event.player_index] = true else @@ -99,33 +99,33 @@ local function add_switch(element, switch_state, name, description_main, descrip local switch = t.add({type = "switch", name = name}) switch.switch_state = switch_state switch.style.padding = 0 - switch.style.margin = 0 + switch.style.margin = 0 local label = t.add({type = "label", caption = "OFF"}) label.style.padding = 0 label.style.font_color = {0.70, 0.70, 0.70} - + local label = t.add({type = "label", caption = description_main}) label.style.padding = 2 label.style.left_padding= 10 label.style.minimal_width = 120 label.style.font = "heading-2" label.style.font_color = {0.88, 0.88, 0.99} - + local label = t.add({type = "label", caption = description}) label.style.padding = 2 label.style.left_padding= 10 label.style.single_line = false label.style.font = "heading-3" label.style.font_color = {0.85, 0.85, 0.85} - + return switch end -local build_config_gui = (function (player, frame) +local build_config_gui = (function (player, frame) frame.clear() - + local admin = player.admin - + local label = frame.add({type = "label", caption = "Player Settings"}) label.style.font = "default-bold" label.style.padding = 0 @@ -133,15 +133,15 @@ local build_config_gui = (function (player, frame) label.style.horizontal_align = "left" label.style.vertical_align = "bottom" label.style.font_color = {0.55, 0.55, 0.99} - + frame.add({type = "line"}) - + local switch_state = "right" if player.spectator then switch_state = "left" end add_switch(frame, switch_state, "comfy_panel_spectator_switch", "SpectatorMode", "Toggles zoom-to-world view noise effect.\nEnvironmental sounds will be based on map view.") - + frame.add({type = "line"}) - + if global.auto_hotbar_enabled then local switch_state = "right" if global.auto_hotbar_enabled[player.index] then switch_state = "left" end @@ -157,23 +157,23 @@ local build_config_gui = (function (player, frame) label.style.horizontal_align = "left" label.style.vertical_align = "bottom" label.style.font_color = {0.77, 0.11, 0.11} - + frame.add({type = "line"}) - + local switch_state = "right" if game.permissions.get_group("Default").allows_action(defines.input_action.import_blueprint) then switch_state = "left" end local switch = add_switch(frame, switch_state, "comfy_panel_blueprint_toggle", "Blueprint Library", "Toggles the usage of blueprint strings and the library.") if not admin then switch.ignored_by_interaction = true end - + frame.add({type = "line"}) - + local switch_state = "right" if global.comfy_panel_config.spaghett.enabled then switch_state = "left" end local switch = add_switch(frame, switch_state, "comfy_panel_spaghett_toggle", "Spaghett Mode", "Disables the Logistic System research.\nRequester, buffer or active-provider containers can not be built.") if not admin then switch.ignored_by_interaction = true end - + frame.add({type = "line"}) - + for _, e in pairs(frame.children) do if e.type == "line" then e.style.padding = 0 @@ -209,7 +209,7 @@ local function on_init() global.comfy_panel_config.spaghett.undo = {} end -comfy_panel_tabs["Config"] = build_config_gui +comfy_panel_tabs["Config"] = {gui = build_config_gui, admin = false} local Event = require 'utils.event' diff --git a/control.lua b/control.lua index 2d964b99..9c30f2fd 100644 --- a/control.lua +++ b/control.lua @@ -27,7 +27,7 @@ require "comfy_panel.config" require "modules.autostash" ---- enable modules here ---- -require "modules.admins_operate_biters" +--require "modules.admins_operate_biters" --require "modules.the_floor_is_lava" --require "modules.biters_landfill_on_death" --require "modules.autodecon_when_depleted" @@ -46,7 +46,7 @@ require "modules.admins_operate_biters" --require "modules.fluids_are_explosive" --require "modules.hunger" --require "modules.hunger_games" -require "modules.pistol_buffs" +--require "modules.pistol_buffs" --require "modules.players_trample_paths" --require "modules.railgun_enhancer" --require "modules.restrictive_fluid_mining" @@ -68,7 +68,7 @@ require "modules.pistol_buffs" ----------------------------- ---- enable maps here ---- (maps higher up in the list may be more actually playable) -require "maps.chronosphere.main" +--require "maps.chronosphere.main" --require "maps.fish_defender.main" --require "maps.biter_battles_v2.main" --require "maps.native_war.main" diff --git a/modules/pistol_buffs.lua b/modules/pistol_buffs.lua index 106a3376..9596e964 100644 --- a/modules/pistol_buffs.lua +++ b/modules/pistol_buffs.lua @@ -15,6 +15,7 @@ local function on_entity_damaged(event) if not weapon.valid_for_read or not ammo.valid_for_read then return end if weapon.name ~= "pistol" then return end if ammo.name ~= "firearm-magazine" and ammo.name ~= "piercing-rounds-magazine" and ammo.name ~= "uranium-rounds-magazine" then return end + if not event.entity.valid then return end event.entity.damage(event.final_damage_amount * 4, player.force, "impact", player) end diff --git a/modules/railgun_enhancer.lua b/modules/railgun_enhancer.lua index b7f5c9d1..c1061625 100644 --- a/modules/railgun_enhancer.lua +++ b/modules/railgun_enhancer.lua @@ -56,7 +56,7 @@ local function do_splash_damage_around_entity(source_entity, player) } local entities = source_entity.surface.find_entities_filtered({area = splash_area}) for _, entity in pairs(entities) do - if entity.health and entity ~= source_entity and entity ~= player then + if entity.valid and entity.health and entity ~= source_entity and entity ~= player then if additional_visual_effects then local surface = entity.surface surface.create_entity({name = "railgun-beam", position = source_entity.position, source = source_entity.position, target = entity.position}) From 73c9de4012b4c334433e2cd4839d3bd61bdfe96d Mon Sep 17 00:00:00 2001 From: MewMew Date: Sun, 19 Apr 2020 13:44:21 +0200 Subject: [PATCH 69/70] Delete basic_markets.lua --- functions/basic_markets.lua | 268 ------------------------------------ 1 file changed, 268 deletions(-) delete mode 100644 functions/basic_markets.lua diff --git a/functions/basic_markets.lua b/functions/basic_markets.lua deleted file mode 100644 index d8dd8994..00000000 --- a/functions/basic_markets.lua +++ /dev/null @@ -1,268 +0,0 @@ -local Public = {} - -local market = {} - -market.weapons = { - --["pistol"] = {value = 10, rarity = 1}, - ["submachine-gun"] = {value = 50, rarity = 2}, - ["shotgun"] = {value = 40, rarity = 2}, - ["combat-shotgun"] = {value = 400, rarity = 5}, - ["rocket-launcher"] = {value = 250, rarity = 4}, - ["flamethrower"] = {value = 750, rarity = 6}, - ["land-mine"] = {value = 100, rarity = 5}, -} - -market.ammo = { - ["firearm-magazine"] = {value = 3, rarity = 1}, - ["piercing-rounds-magazine"] = {value = 6, rarity = 4}, - ["uranium-rounds-magazine"] = {value = 20, rarity = 8}, - ["shotgun-shell"] = {value = 3, rarity = 1}, - ["piercing-shotgun-shell"] = {value = 8, rarity = 5}, - ["cannon-shell"] = {value = 8, rarity = 4}, - ["explosive-cannon-shell"] = {value = 12, rarity = 5}, - ["uranium-cannon-shell"] = {value = 16, rarity = 7}, - ["explosive-uranium-cannon-shell"] = {value = 20, rarity = 8}, - ["artillery-shell"] = {value = 64, rarity = 7}, - ["rocket"] = {value = 4, rarity = 3}, - ["explosive-rocket"] = {value = 12, rarity = 5}, - ["atomic-bomb"] = {value = 9000, rarity = 10}, - ["flamethrower-ammo"] = {value = 20, rarity = 6}, - ["explosives"] = {value = 3, rarity = 1}, -} - -market.caspules = { - ["grenade"] = {value = 16, rarity = 2}, - ["cluster-grenade"] = {value = 32, rarity = 5}, - ["poison-capsule"] = {value = 32, rarity = 6}, - ["slowdown-capsule"] = {value = 8, rarity = 1}, - ["defender-capsule"] = {value = 8, rarity = 1}, - ["distractor-capsule"] = {value = 20, rarity = 5}, - ["destroyer-capsule"] = {value = 32, rarity = 7}, - ["discharge-defense-remote"] = {value = 64, rarity = 6}, - ["artillery-targeting-remote"] = {value = 32, rarity = 7}, - ["raw-fish"] = {value = 6, rarity = 1}, -} - -market.armor = { - ["light-armor"] = {value = 25, rarity = 1}, - ["heavy-armor"] = {value = 250, rarity = 4}, - ["modular-armor"] = {value = 750, rarity = 5}, - ["power-armor"] = {value = 2500, rarity = 6}, - ["power-armor-mk2"] = {value = 20000, rarity = 10}, -} - -market.equipment = { - ["solar-panel-equipment"] = {value = 240, rarity = 3}, - ["fusion-reactor-equipment"] = {value = 9000, rarity = 7}, - ["energy-shield-equipment"] = {value = 400, rarity = 6}, - ["energy-shield-mk2-equipment"] = {value = 4000, rarity = 8}, - ["battery-equipment"] = {value = 160, rarity = 2}, - ["battery-mk2-equipment"] = {value = 2000, rarity = 8}, - ["personal-laser-defense-equipment"] = {value = 2500, rarity = 7}, - ["discharge-defense-equipment"] = {value = 2000, rarity = 5}, - ["belt-immunity-equipment"] = {value = 200, rarity = 1}, - ["exoskeleton-equipment"] = {value = 800, rarity = 3}, - ["personal-roboport-equipment"] = {value = 500, rarity = 3}, - ["personal-roboport-mk2-equipment"] = {value = 5000, rarity = 8}, - ["night-vision-equipment"] = {value = 250, rarity = 1}, -} - -market.defense = { - ["stone-wall"] = {value = 4, rarity = 1}, - ["gate"] = {value = 8, rarity = 1}, - ["repair-pack"] = {value = 8, rarity = 1}, - ["gun-turret"] = {value = 64, rarity = 1}, - ["laser-turret"] = {value = 1024, rarity = 6}, - ["flamethrower-turret"] = {value = 2048, rarity = 6}, - ["flamethrower-turret"] = {value = 2048, rarity = 6}, - ["artillery-turret"] = {value = 8192, rarity = 8}, - ["rocket-silo"] = {value = 64000, rarity = 10}, -} - -market.logistic = { - ["wooden-chest"] = {value = 3, rarity = 1}, - ["iron-chest"] = {value = 10, rarity = 2}, - ["steel-chest"] = {value = 24, rarity = 3}, - ["storage-tank"] = {value = 32, rarity = 4}, - ["transport-belt"] = {value = 4, rarity = 1}, - ["fast-transport-belt"] = {value = 8, rarity = 4}, - ["express-transport-belt"] = {value = 24, rarity = 7}, - ["underground-belt"] = {value = 8, rarity = 1}, - ["fast-underground-belt"] = {value = 32, rarity = 4}, - ["express-underground-belt"] = {value = 64, rarity = 7}, - ["splitter"] = {value = 16, rarity = 1}, - ["fast-splitter"] = {value = 48, rarity = 4}, - ["express-splitter"] = {value = 128, rarity = 7}, - ["loader"] = {value = 256, rarity = 2}, - ["fast-loader"] = {value = 512, rarity = 5}, - ["express-loader"] = {value = 768, rarity = 8}, - ["burner-inserter"] = {value = 4, rarity = 1}, - ["inserter"] = {value = 8, rarity = 1}, - ["long-handed-inserter"] = {value = 12, rarity = 2}, - ["fast-inserter"] = {value = 16, rarity = 4}, - ["filter-inserter"] = {value = 24, rarity = 5}, - ["stack-inserter"] = {value = 96, rarity = 6}, - ["stack-filter-inserter"] = {value = 128, rarity = 7}, - ["small-electric-pole"] = {value = 2, rarity = 1}, - ["medium-electric-pole"] = {value = 12, rarity = 4}, - ["big-electric-pole"] = {value = 24, rarity = 5}, - ["substation"] = {value = 96, rarity = 8}, - ["pipe"] = {value = 2, rarity = 1}, - ["pipe-to-ground"] = {value = 8, rarity = 1}, - ["pump"] = {value = 16, rarity = 4}, - ["logistic-robot"] = {value = 28, rarity = 5}, - ["construction-robot"] = {value = 28, rarity = 3}, - ["logistic-chest-active-provider"] = {value = 128, rarity = 7}, - ["logistic-chest-passive-provider"] = {value = 128, rarity = 6}, - ["logistic-chest-storage"] = {value = 128, rarity = 6}, - ["logistic-chest-buffer"] = {value = 128, rarity = 7}, - ["logistic-chest-requester"] = {value = 128, rarity = 7}, - ["roboport"] = {value = 4096, rarity = 8}, -} - -market.vehicles = { - ["rail"] = {value = 4, rarity = 1}, - ["train-stop"] = {value = 32, rarity = 3}, - ["rail-signal"] = {value = 8, rarity = 5}, - ["rail-chain-signal"] = {value = 8, rarity = 5}, - ["locomotive"] = {value = 400, rarity = 4}, - ["cargo-wagon"] = {value = 200, rarity = 4}, - ["fluid-wagon"] = {value = 300, rarity = 5}, - ["artillery-wagon"] = {value = 8192, rarity = 8}, - ["car"] = {value = 80, rarity = 1}, - ["tank"] = {value = 1800, rarity = 5}, -} - -market.wire = { - ["small-lamp"] = {value = 4, rarity = 1}, - ["red-wire"] = {value = 4, rarity = 1}, - ["green-wire"] = {value = 4, rarity = 1}, - ["arithmetic-combinator"] = {value = 16, rarity = 1}, - ["decider-combinator"] = {value = 16, rarity = 1}, - ["constant-combinator"] = {value = 16, rarity = 1}, - ["power-switch"] = {value = 16, rarity = 1}, - ["programmable-speaker"] = {value = 24, rarity = 1}, -} - -local function get_types() - local types = {} - for k, v in pairs(market) do - types[#types + 1] = k - end - return types -end - -local function get_resource_market_sells() - local sells = { - {price = {{"coin", math.random(25,50)}}, offer = {type = 'give-item', item = 'wood', count = 50}}, - {price = {{"coin", math.random(40,80)}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}, - {price = {{"coin", math.random(40,80)}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}}, - {price = {{"coin", math.random(40,80)}}, offer = {type = 'give-item', item = 'stone', count = 50}}, - {price = {{"coin", math.random(40,80)}}, offer = {type = 'give-item', item = 'coal', count = 50}}, - {price = {{"coin", math.random(60,120)}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}, - {price = {{"coin", math.random(20,40)}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}}, - } - table.shuffle_table(sells) - return sells -end - -local function get_resource_market_buys() - local buys = { - {price = {{'wood', math.random(10,12)}}, offer = {type = 'give-item', item = "coin"}}, - {price = {{'iron-ore', math.random(10,12)}}, offer = {type = 'give-item', item = "coin"}}, - {price = {{'copper-ore', math.random(10,12)}}, offer = {type = 'give-item', item = "coin"}}, - {price = {{'stone', math.random(10,12)}}, offer = {type = 'give-item', item = "coin"}}, - {price = {{'coal', math.random(10,12)}}, offer = {type = 'give-item', item = "coin"}}, - {price = {{'uranium-ore', math.random(8,10)}}, offer = {type = 'give-item', item = "coin"}}, - {price = {{'water-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(2,5)}}, - {price = {{'lubricant-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(5,10)}}, - {price = {{'sulfuric-acid-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(4,8)}}, - {price = {{'light-oil-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(5,10)}}, - {price = {{'heavy-oil-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(5,10)}}, - {price = {{'petroleum-gas-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(4,8)}}, - } - table.shuffle_table(buys) - return buys -end - -local function get_market_item_list(market_types, rarity) - if rarity < 1 then rarity = 1 end - if rarity > 10 then rarity = 10 end - local list = {} - for _, market_type in pairs(market_types) do - for k, item in pairs(market[market_type]) do - --if item.rarity <= rarity and item.rarity + 7 >= rarity then - if item.rarity <= rarity then - local price = math.random(math.floor(item.value * 0.75), math.floor(item.value * 1.25)) - if price < 1 then price = 1 end - if price > 64000 then price = 64000 end - list[#list + 1] = {price = {{"coin", price}}, offer = {type = 'give-item', item = k}} - end - end - end - if #list == 0 then return false end - return list -end - -local function get_random_market_item_list(rarity) - local types = get_types() - table.shuffle_table(types) - for i = 1, #types, 1 do - local items = get_market_item_list({types[i]}, rarity) - if items then return items end - end - return false -end - -function Public.mountain_market(surface, position, rarity) - local types = get_types() - table.shuffle_table(types) - local items = get_market_item_list({types[1], types[2], types[3]}, rarity) - if not items then return end - if #items > 0 then table.shuffle_table(items) end - local market = surface.create_entity({name = "market", position = position, force="neutral"}) - for i = 1, math.random(5, 10), 1 do - if not items[i] then break end - market.add_market_item(items[i]) - end - - local sells = get_resource_market_sells() - for i = 1, math.random(1, 3), 1 do - market.add_market_item(sells[i]) - end - - local buys = get_resource_market_buys() - for i = 1, math.random(1, 3), 1 do - market.add_market_item(buys[i]) - end - - return market -end - -function Public.super_market(surface, position, rarity) - local items = get_market_item_list(get_types(), rarity) - if not items then return end - if #items > 0 then table.shuffle_table(items) end - local market = surface.create_entity({name = "market", position = position, force="neutral"}) - market.minable = false - market.destructible = false - - for i = 1, math.random(6, 12), 1 do - if not items[i] then break end - market.add_market_item(items[i]) - end - - local sells = get_resource_market_sells() - for i = 1, math.random(1, 3), 1 do - market.add_market_item(sells[i]) - end - - local buys = get_resource_market_buys() - for i = 1, math.random(1, 3), 1 do - market.add_market_item(buys[i]) - end - - return market -end - -return Public From 3d252ff8c87794775622886837897abf42d27fbf Mon Sep 17 00:00:00 2001 From: MewMew Date: Sun, 19 Apr 2020 13:51:18 +0200 Subject: [PATCH 70/70] Update locomotive.lua --- maps/mountain_fortress_v2/locomotive.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/maps/mountain_fortress_v2/locomotive.lua b/maps/mountain_fortress_v2/locomotive.lua index 004304b1..298b760e 100644 --- a/maps/mountain_fortress_v2/locomotive.lua +++ b/maps/mountain_fortress_v2/locomotive.lua @@ -66,14 +66,14 @@ end ]] local market_offers = { - {price = {{'coin', 25}}, offer = {type = 'give-item', item = "raw-fish"}}, - {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'wood', count = 50}}, - {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}, - {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}}, - {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'stone', count = 50}}, - {price = {{"coin", 50}}, offer = {type = 'give-item', item = 'coal', count = 50}}, - {price = {{"coin", 80}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}, - {price = {{"coin", 25}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}}, + {price = {{'coin', 5}}, offer = {type = 'give-item', item = "raw-fish"}}, + {price = {{"coin", 10}}, offer = {type = 'give-item', item = 'wood', count = 50}}, + {price = {{"coin", 10}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}, + {price = {{"coin", 10}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}}, + {price = {{"coin", 10}}, offer = {type = 'give-item', item = 'stone', count = 50}}, + {price = {{"coin", 10}}, offer = {type = 'give-item', item = 'coal', count = 50}}, + {price = {{"coin", 16}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}, + {price = {{"coin", 5}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}}, } local function create_wagon_room()