1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-05-13 21:56:29 +02:00
- lava planet fires happen only when no pavement
- new planet
-if staying for too long, biters on next planets can evolve
This commit is contained in:
hanakocz 2020-02-19 15:15:16 +01:00 committed by GitHub
parent fe257962a5
commit 2ff8375efd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 307 additions and 70 deletions

View File

@ -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

View File

@ -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] = {

View File

@ -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"])])

View File

@ -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)))

View File

@ -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"]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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