1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-05-13 21:56:29 +02:00

map update

This commit is contained in:
Gerkiz 2020-04-17 20:52:52 +02:00
parent a63cfecc12
commit 1aa764a5d5
3 changed files with 136 additions and 231 deletions

View File

@ -106,3 +106,8 @@ tooltip_2=gain / minute
[native_war] [native_war]
map_info= - - N A T I V E W A R - -\n\n Defeat the enemy team Market !\n\nFeed your market with science to spawn waves of native biters and spitters !\nThey will soon after swarm to the opposing team Market !\n\nThe corridor is stewn with worms.\nRebuy dead worms and upgrade them to stem the opposing waves !\n\nExcess energy will activate a beam.\nBeam will progress with more excess energy.\nNatives will spawn according to the beam position.\n\nUse radars to spy opponent's base.\nUse your experience to improve damage and resistance of your biters.\nSpace science packs give extra life to your biters.\nConstruction robots may not build over the wall.\n map_info= - - N A T I V E W A R - -\n\n Defeat the enemy team Market !\n\nFeed your market with science to spawn waves of native biters and spitters !\nThey will soon after swarm to the opposing team Market !\n\nThe corridor is stewn with worms.\nRebuy dead worms and upgrade them to stem the opposing waves !\n\nExcess energy will activate a beam.\nBeam will progress with more excess energy.\nNatives will spawn according to the beam position.\n\nUse radars to spy opponent's base.\nUse your experience to improve damage and resistance of your biters.\nSpace science packs give extra life to your biters.\nConstruction robots may not build over the wall.\n
[territorial_control]
map_info_main_caption=T E R R I T O R I A L C O N T R O L
map_info_sub_caption= ..alone in the darkness..
map_info_text=Citizen Log #468-2A-3287, Freelancer Trent. \n\nTo whoever is reading this message, \nAny natural resources are rare and the ones worth while are too hard for me to reach. \nLuckily, the wrecks yield all kinds of useful scraps, but also various dangers. \nAlmost lost half a leg some days ago while digging out some scrap. \nThe wildlife is extremely aggressive, especially at the time of night. \nMost of these insect appearing like creatures seem to live underground. \nStay near your light sources, if you want to have a chance of surviving here! \n\n###Log End###]

View File

@ -1,6 +1,6 @@
-- territorial control by Gerkiz -- territorial control by Gerkiz
require "territorial_control_intro" local Map = require "modules.map_info"
require "on_tick_schedule" require "on_tick_schedule"
require "modules.fish_respawner" require "modules.fish_respawner"
global.fish_respawner_water_tiles_per_fish = 16 global.fish_respawner_water_tiles_per_fish = 16
@ -16,13 +16,10 @@ require "modules.biters_yield_coins"
require "modules.mineable_wreckage_yields_scrap" require "modules.mineable_wreckage_yields_scrap"
local shapes = require "tools.shapes" local shapes = require "tools.shapes"
local event = require 'utils.event' local Event = require 'utils.event'
local map_functions = require "tools.map_functions"
local unearthing_worm = require "functions.unearthing_worm" local unearthing_worm = require "functions.unearthing_worm"
local unearthing_biters = require "functions.unearthing_biters" local unearthing_biters = require "functions.unearthing_biters"
local tick_tack_trap = require "functions.tick_tack_trap" local tick_tack_trap = require "functions.tick_tack_trap"
local create_entity_chain = require "functions.create_entity_chain"
local create_tile_chain = require "functions.create_tile_chain"
local map_functions = require "tools.map_functions" local map_functions = require "tools.map_functions"
local simplex_noise = require 'utils.simplex_noise' local simplex_noise = require 'utils.simplex_noise'
simplex_noise = simplex_noise.d2 simplex_noise = simplex_noise.d2
@ -76,7 +73,6 @@ local biters_in_the_void = {
[20] = {"behemoth-biter","behemoth-biter","behemoth-biter","behemoth-biter","behemoth-spitter","behemoth-spitter"} [20] = {"behemoth-biter","behemoth-biter","behemoth-biter","behemoth-biter","behemoth-spitter","behemoth-spitter"}
} }
local ore_spill_raffle = {"iron-ore","iron-ore","iron-ore","iron-ore","copper-ore","copper-ore","copper-ore","coal","coal"}
local ore_spawn_raffle = { local ore_spawn_raffle = {
"iron-ore","iron-ore","iron-ore","iron-ore", "iron-ore","iron-ore","iron-ore","iron-ore", "iron-ore","iron-ore", "iron-ore","iron-ore","iron-ore","iron-ore", "iron-ore","iron-ore","iron-ore","iron-ore", "iron-ore","iron-ore",
"copper-ore","copper-ore","copper-ore", "copper-ore","copper-ore","copper-ore", "copper-ore", "copper-ore","copper-ore","copper-ore", "copper-ore","copper-ore","copper-ore", "copper-ore",
@ -123,8 +119,6 @@ local function secret_shop(pos, surface)
{price = {{"coin", math_random(15,35)}}, offer = {type = 'give-item', item = 'cargo-wagon'}}, {price = {{"coin", math_random(15,35)}}, offer = {type = 'give-item', item = 'cargo-wagon'}},
{price = {{"coin", math_random(1,4)}}, offer = {type = 'give-item', item = 'grenade'}}, {price = {{"coin", math_random(1,4)}}, offer = {type = 'give-item', item = 'grenade'}},
{price = {{"coin", 1}}, offer = {type = 'give-item', item = 'rail', count = 4}}, {price = {{"coin", 1}}, offer = {type = 'give-item', item = 'rail', count = 4}},
-- {price = {{"coin", 1}}, offer = {type = 'give-item', item = 'rail-signal', count = 2}},
-- {price = {{"coin", 1}}, offer = {type = 'give-item', item = 'rail-chain-signal', count = 2}},
{price = {{"coin", 5}}, offer = {type = 'give-item', item = 'train-stop'}}, {price = {{"coin", 5}}, offer = {type = 'give-item', item = 'train-stop'}},
{price = {{"coin", 1}}, offer = {type = 'give-item', item = 'small-lamp'}}, {price = {{"coin", 1}}, offer = {type = 'give-item', item = 'small-lamp'}},
{price = {{"coin", 2}}, offer = {type = 'give-item', item = 'firearm-magazine'}}, {price = {{"coin", 2}}, offer = {type = 'give-item', item = 'firearm-magazine'}},
@ -136,7 +130,6 @@ local function secret_shop(pos, surface)
{price = {{"coin", 1}}, offer = {type = 'give-item', item = 'uranium-ore', count = math_random(25,75)}} {price = {{"coin", 1}}, offer = {type = 'give-item', item = 'uranium-ore', count = math_random(25,75)}}
} }
secret_market_items = shuffle(secret_market_items) secret_market_items = shuffle(secret_market_items)
local market = surface.create_entity {name = "market", position = pos} local market = surface.create_entity {name = "market", position = pos}
market.destructible = false market.destructible = false
@ -163,31 +156,26 @@ local function get_noise(name, pos)
noise[1] = simplex_noise(pos.x * 0.02, pos.y * 0.02, seed) noise[1] = simplex_noise(pos.x * 0.02, pos.y * 0.02, seed)
seed = seed + noise_seed_add seed = seed + noise_seed_add
noise[2] = simplex_noise(pos.x * 0.1, pos.y * 0.1, seed) noise[2] = simplex_noise(pos.x * 0.1, pos.y * 0.1, seed)
seed = seed + noise_seed_add local value = noise[1] + noise[2] * 0.2
local noise = noise[1] + noise[2] * 0.2 return value
return noise
end end
seed = seed + noise_seed_add seed = seed + noise_seed_add
if name == "dirt" then if name == "dirt" then
--noise[1] = simplex_noise(pos.x * 0.1, pos.y * 0.1, seed)
noise[1] = simplex_noise(pos.x * 0.08, pos.y * 0.08, seed) noise[1] = simplex_noise(pos.x * 0.08, pos.y * 0.08, seed)
seed = seed + noise_seed_add local value = noise[1]
local noise = noise[1] return value
return noise
end end
seed = seed + noise_seed_add seed = seed + noise_seed_add
if name == "trees" then if name == "trees" then
noise[1] = simplex_noise(pos.x * 0.045, pos.y * 0.045, seed) noise[1] = simplex_noise(pos.x * 0.045, pos.y * 0.045, seed)
seed = seed + noise_seed_add local value = noise[1]
local noise = noise[1] return value
return noise
end end
seed = seed + noise_seed_add seed = seed + noise_seed_add
if name == "spawners" then if name == "spawners" then
noise[1] = simplex_noise(pos.x * 0.02, pos.y * 0.02, seed) noise[1] = simplex_noise(pos.x * 0.02, pos.y * 0.02, seed)
seed = seed + noise_seed_add local value = noise[1]
local noise = noise[1] return value
return noise
end end
end end
@ -250,10 +238,10 @@ local function get_noise_tile(position)
tile_name = "dirt-7" tile_name = "dirt-7"
end end
local noise = get_noise("water", position) local noise_2 = get_noise("water", position)
if noise > 0.71 then if noise_2 > 0.71 then
tile_name = "water" tile_name = "water"
if noise > 0.78 then if noise_2 > 0.78 then
tile_name = "deepwater" tile_name = "deepwater"
end end
end end
@ -265,29 +253,14 @@ local function get_noise_tile(position)
return tile_name return tile_name
end end
local function get_chunk_position(position)
local chunk_position = {}
position.x = math.floor(position.x, 0)
position.y = math.floor(position.y, 0)
for x = 0, 31, 1 do
if (position.x - x) % 32 == 0 then chunk_position.x = (position.x - x) / 32 end
end
for y = 0, 31, 1 do
if (position.y - y) % 32 == 0 then chunk_position.y = (position.y - y) / 32 end
end
return chunk_position
end
local function uncover_map(surface, position, radius_min, radius_max) local function uncover_map(surface, position, radius_min, radius_max)
local circles = shapes.circles local circles = shapes.circles
local tiles = {} local tiles = {}
local fishes = {} local fishes = {}
local regenerate_decoratives = false
for r = radius_min, radius_max, 1 do for r = radius_min, radius_max, 1 do
for _, position_modifier in pairs(circles[r]) do for _, position_modifier in pairs(circles[r]) do
local pos = {x = position.x + position_modifier.x, y = position.y + position_modifier.y} local pos = {x = position.x + position_modifier.x, y = position.y + position_modifier.y}
if surface.get_tile(pos).name == "out-of-map" then if surface.get_tile(pos).name == "out-of-map" then
regenerate_decoratives = true
local tile_name = get_noise_tile(pos) local tile_name = get_noise_tile(pos)
insert(tiles, {name = tile_name, position = pos}) insert(tiles, {name = tile_name, position = pos})
if tile_name == "water" or tile_name == "deepwater" then if tile_name == "water" or tile_name == "deepwater" then
@ -330,12 +303,10 @@ local function uncover_map_for_player(player)
local tiles = {} local tiles = {}
local fishes = {} local fishes = {}
local uncover_map_schedule = {} local uncover_map_schedule = {}
local regenerate_decoratives = false
for r = uncover_radius - 1, uncover_radius, 1 do for r = uncover_radius - 1, uncover_radius, 1 do
for _, position_modifier in pairs(circles[r]) do for _, position_modifier in pairs(circles[r]) do
local pos = {x = position.x + position_modifier.x, y = position.y + position_modifier.y} local pos = {x = position.x + position_modifier.x, y = position.y + position_modifier.y}
if surface.get_tile(pos).name == "out-of-map" then if surface.get_tile(pos).name == "out-of-map" then
regenerate_decoratives = true
local tile_name = get_noise_tile(pos) local tile_name = get_noise_tile(pos)
insert(tiles, {name = tile_name, position = pos}) insert(tiles, {name = tile_name, position = pos})
if tile_name == "water" or tile_name == "deepwater" then if tile_name == "water" or tile_name == "deepwater" then
@ -459,16 +430,13 @@ local function generate_spawn_area(position_left_top)
local surface = game.surfaces["territorial_control"] local surface = game.surfaces["territorial_control"]
local entities = {} local entities = {}
local tiles = {} local tiles = {}
for x = 0, 31, 1 do for x = 0, 31, 1 do
for y = 0, 31, 1 do for y = 0, 31, 1 do
local tile_to_insert = false local tile_to_insert = false
local pos = {x = position_left_top.x + x, y = position_left_top.y + y} local pos = {x = position_left_top.x + x, y = position_left_top.y + y}
if pos.x > -9 and pos.x < 9 and pos.y > -9 and pos.y < 9 then if pos.x > -9 and pos.x < 9 and pos.y > -9 and pos.y < 9 then
tile_to_insert = get_noise_tile(pos) tile_to_insert = get_noise_tile(pos)
--if math_random(1, 4) == 1 then
tile_to_insert = "stone-path" tile_to_insert = "stone-path"
--end
if pos.x <= -7 or pos.x >= 7 or pos.y <= -7 or pos.y >= 7 then if pos.x <= -7 or pos.x >= 7 or pos.y <= -7 or pos.y >= 7 then
if math_random(1, 3) ~= 1 then if math_random(1, 3) ~= 1 then
table.insert(entities, {name = "stone-wall", position = {x = pos.x, y = pos.y}, force = "player"}) table.insert(entities, {name = "stone-wall", position = {x = pos.x, y = pos.y}, force = "player"})
@ -586,7 +554,7 @@ local function on_marked_for_deconstruction(event)
end end
end end
local function on_research_finished(event) local function on_research_finished()
game.forces.player.recipes["flamethrower-turret"].enabled = false game.forces.player.recipes["flamethrower-turret"].enabled = false
end end
@ -605,11 +573,22 @@ local function on_tick()
end end
end end
event.add(defines.events.on_tick, on_tick) local function on_init()
event.add(defines.events.on_research_finished, on_research_finished) local T = Map.Pop_info()
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction) T.localised_category = "territorial_control"
event.add(defines.events.on_player_mined_entity, on_player_mined_entity) T.main_caption_color = {r = 150, g = 150, b = 0}
event.add(defines.events.on_entity_died, on_entity_died) T.sub_caption_color = {r = 0, g = 150, b = 0}
event.add(defines.events.on_chunk_generated, on_chunk_generated) global.rocks_yield_ore_maximum_amount = 999
event.add(defines.events.on_player_changed_position, on_player_changed_position) global.rocks_yield_ore_base_amount = 50
event.add(defines.events.on_player_joined_game, on_player_joined_game) global.rocks_yield_ore_distance_modifier = 0.025
end
Event.on_init(on_init)
Event.add(defines.events.on_tick, on_tick)
Event.add(defines.events.on_research_finished, on_research_finished)
Event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
Event.add(defines.events.on_entity_died, on_entity_died)
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
Event.add(defines.events.on_player_changed_position, on_player_changed_position)
Event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -1,79 +0,0 @@
local event = require 'utils.event'
local info = [[
Citizen Log #468-2A-3287, Freelancer Trent
To whoever is reading this message,
Any natural resources are rare and the ones worth while are too hard for me to reach.
Luckily, the wrecks yield all kinds of useful scraps, but also various dangers.
Almost lost half a leg some days ago while digging out some scrap.
The wildlife is extremely aggressive, especially at the time of night.
Most of these insect appearing like creatures seem to live underground.
Stay near your light sources, if you want to have a chance of surviving here!
###Log End###
]]
local function create_map_intro_button(player)
if player.gui.top["map_intro_button"] then return end
local b = player.gui.top.add({type = "sprite-button", caption = "?", name = "map_intro_button", tooltip = "Map Info"})
b.style.font_color = {r = 0.8, g = 0.8, b = 0.8}
b.style.font = "heading-1"
b.style.minimal_height = 38
b.style.minimal_width = 38
b.style.top_padding = 2
b.style.left_padding = 4
b.style.right_padding = 4
b.style.bottom_padding = 2
end
local function create_map_intro(player)
if player.gui.left["map_intro_frame"] then player.gui.left["map_intro_frame"].destroy() end
local frame = player.gui.left.add {type = "frame", name = "map_intro_frame", direction = "vertical"}
local t = frame.add {type = "table", column_count = 1}
local b = frame.add {type = "button", caption = "Close", name = "close_map_intro_frame", align = "right"}
b.style.font = "default"
b.style.minimal_height = 30
b.style.minimal_width = 30
b.style.top_padding = 2
b.style.left_padding = 4
b.style.right_padding = 4
b.style.bottom_padding = 2
local frame = t.add {type = "frame"}
local l = frame.add {type = "label", caption = info}
l.style.single_line = false
l.style.font = "heading-3"
l.style.font_color = {r=0.95, g=0.95, b=0.95}
end
local function on_player_joined_game(event)
local player = game.players[event.player_index]
create_map_intro_button(player)
if player.online_time == 0 then
create_map_intro(player)
end
end
local function on_gui_click(event)
if not event then return end
if not event.element then return end
if not event.element.valid then return end
local player = game.players[event.element.player_index]
if event.element.name == "close_map_intro_frame" then player.gui.left["map_intro_frame"].destroy() return end
if event.element.name == "map_intro_button" then
if player.gui.left["map_intro_frame"] then
player.gui.left["map_intro_frame"].destroy()
else
create_map_intro(player)
end
return
end
end
event.add(defines.events.on_player_joined_game, on_player_joined_game)
event.add(defines.events.on_gui_click, on_gui_click)