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