1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-09 13:37:02 +02:00

biter_battles_v2 update

This commit is contained in:
MewMew 2019-03-18 03:24:13 +01:00
parent 8cd1cfebf4
commit 35733d037f
7 changed files with 17 additions and 211 deletions

View File

@ -18,7 +18,7 @@ local function init_surface()
["iron-ore"] = {frequency = "2", size = "1", richness = "1"},
["uranium-ore"] = {frequency = "2", size = "1", richness = "1"},
["crude-oil"] = {frequency = "3", size = "1", richness = "1"},
["trees"] = {frequency = "0.5", size = "0.7", richness = "0.7"},
["trees"] = {frequency = "1", size = "0.5", richness = "0.7"},
["enemy-base"] = {frequency = "2", size = "3", richness = "1"}
}
game.create_surface("biter_battles", map_gen_settings)
@ -73,8 +73,8 @@ local function init_forces()
f.share_chart = false
local f = game.forces["spectator"]
f.technologies["toolbelt"].researched=true
f.set_spawn_position({0,0},surface)
f.technologies["toolbelt"].researched=true
f.set_friend("north_biters", true)
f.set_friend("south_biters", true)
f.set_friend("north", true)
@ -83,16 +83,14 @@ local function init_forces()
f.share_chart = true
local f = game.forces["player"]
f.set_spawn_position({0,0},surface)
f.set_cease_fire('spectator', true)
f.set_friend("north_biters", true)
f.set_friend("south_biters", true)
f.set_cease_fire('north', true)
f.set_cease_fire('south', true)
f.share_chart = false
game.forces["north"].set_friend("player", true)
f.set_spawn_position({0,0},surface)
local p = game.permissions.create_group("spectator")
for action_name, _ in pairs(defines.input_action) do
p.set_allows_action(defines.input_action[action_name], false)
@ -110,7 +108,9 @@ local function init_forces()
defines.input_action.open_kills_gui,
defines.input_action.open_character_gui,
defines.input_action.edit_permission_group,
defines.input_action.toggle_show_entity_info
defines.input_action.toggle_show_entity_info,
defines.input_action.rotate_entity,
defines.input_action.start_research
}
for _, d in pairs(defs) do p.set_allows_action(d, true) end

View File

@ -65,7 +65,6 @@ local function feed_biters(player, food)
---SET EVOLUTION
local e = (game.forces[biter_force_name].evolution_factor * 100) + 1
--local diminishing_modifier = 1 / (10 ^ (e * 0.032))
local diminishing_modifier = (1 / (10 ^ (e * 0.014))) / (e * 0.5)
global.bb_evolution[biter_force_name] = global.bb_evolution[biter_force_name] + (food_values[food].value * diminishing_modifier)
if global.bb_evolution[biter_force_name] < 1 then

View File

@ -275,11 +275,12 @@ local function on_entity_died(event)
game.forces["north"].set_friend("north_biters", true)
game.forces["south_biters"].set_friend("south", true)
game.forces["south"].set_friend("south_biters", true)
global.spy_fish_timeout["north"] = game.tick + 999999
global.spy_fish_timeout["south"] = game.tick + 999999
global.server_restart_timer = 180
fireworks(event.entity.surface)
annihilate_base(event.entity.position, event.entity.surface, event.entity.force.name)
global.server_restart_timer = 180
annihilate_base(event.entity.position, event.entity.surface, event.entity.force.name)
end
end

View File

@ -27,7 +27,7 @@ local function draw_gui()
if global.map_generation_complete then
if player.gui.left["map_pregen"] then player.gui.left["map_pregen"].destroy() end
else
local caption = "Map is generating... " .. #global.chunk_gen_coords .. " chunks left."
local caption = "Map is generating... " .. #global.chunk_gen_coords .. " chunks left. Please get comfy."
if player.gui.left["map_pregen"] then
player.gui.left["map_pregen"].caption = caption
else
@ -36,8 +36,8 @@ local function draw_gui()
caption = caption,
name = "map_pregen"
})
frame.style.font_color = {r = 100, g = 100, b = 250}
frame.style.font = "heading-2"
frame.style.font_color = {r = 150, g = 100, b = 255}
frame.style.font = "heading-1"
frame.style.maximal_height = 36
end
end
@ -46,7 +46,7 @@ end
local function process_chunk(surface)
if global.map_generation_complete then return end
if game.tick < 600 then return end
if game.tick < 300 then return end
if not global.chunk_gen_coords then set_chunk_coords(32) end
if #global.chunk_gen_coords == 0 then
global.map_generation_complete = true

View File

@ -1,111 +0,0 @@
local event = require 'utils.event'
local function get_chunk_coords(radius)
local coords = {}
for r = radius, 1, -1 do
for x = r * -1, r - 1, 1 do
local pos = {x = x, y = r * -1}
if math.sqrt(pos.x ^ 2 + pos.y ^ 2) <= radius then table.insert(coords, pos) end
end
for y = r * -1, r - 1, 1 do
local pos = {x = r, y = y}
if math.sqrt(pos.x ^ 2 + pos.y ^ 2) <= radius then table.insert(coords, pos) end
end
for x = r, r * -1 + 1, -1 do
local pos = {x = x, y = r}
if math.sqrt(pos.x ^ 2 + pos.y ^ 2) <= radius then table.insert(coords, pos) end
end
for y = r, r * -1 + 1, -1 do
local pos = {x = r * -1, y = y}
if math.sqrt(pos.x ^ 2 + pos.y ^ 2) <= radius then table.insert(coords, pos) end
end
end
return coords
end
local function draw_gui(chunks_left, g)
for _, player in pairs(connected_players) do
local caption = "Map is generating... " .. chunks_left .. " chunks left."
if player.gui.left["map_pregen"] then
player.gui.left["map_pregen"].caption = caption
else
local frame = player.gui.left.add({
type = "frame",
caption = caption,
name = "map_pregen"
})
frame.style.font_color = {r = 100, g = 100, b = 250}
frame.style.font = "heading-2"
frame.style.maximal_height = 36
end
end
end
local function kill_gui(connected_players)
for _, player in pairs(connected_players) do
if player.gui.left["map_pregen"] then player.gui.left["map_pregen"].destroy() end
end
end
local function print_progress(str, p)
p(str, {r = 100, g = 100, b = 250})
end
local function process_chunk(surface, coord)
if surface.is_chunk_generated(coord) then return end
surface.request_to_generate_chunks({x = (coord.x * 32) - 16, y = (coord.y * 32) - 16}, 1)
surface.force_generate_chunk_requests()
end
local function create_schedule(radius)
local coords = get_chunk_coords(radius)
local speed = 10
for t = speed, #coords * speed + speed, speed do
if not global.on_tick_schedule[game.tick + t] then global.on_tick_schedule[game.tick + t] = {} end
if coords[1] then
global.on_tick_schedule[game.tick + t][#global.on_tick_schedule[game.tick + t] + 1] = {
func = process_chunk,
args = {game.surfaces["biter_battles"], {x = coords[#coords].x, y = coords[#coords].y}, game}
}
if #coords % 500 == 0 then
local str = "Map is generating... " .. tostring(#coords)
str = str .. " chunks left."
global.on_tick_schedule[game.tick + t][#global.on_tick_schedule[game.tick + t] + 1] = {
func = game.print,
args = {str, {r = 100, g = 100, b = 250}}
}
end
--global.on_tick_schedule[game.tick + t][#global.on_tick_schedule[game.tick + t] + 1] = {
-- func = draw_gui,
-- args = {#coords, game}
--}
else
local str = "Map is generation complete!"
global.on_tick_schedule[game.tick + t][#global.on_tick_schedule[game.tick + t] + 1] = {
func = game.print,
args = {str, {r = 100, g = 100, b = 250}}
}
--global.on_tick_schedule[game.tick + t][#global.on_tick_schedule[game.tick + t] + 1] = {
-- func = kill_gui,
-- args = {game}
--}
end
coords[#coords] = nil
end
end
local function on_player_joined_game(event)
if not global.map_generation_complete then
create_schedule(32)
global.map_generation_complete = true
end
local player = game.players[event.player_index]
if player.gui.left["map_pregen"] then player.gui.left["map_pregen"].destroy() end
end
event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -1,83 +0,0 @@
local event = require 'utils.event'
local function set_chunk_coords(radius)
global.chunk_gen_coords = {}
for r = radius, 1, -1 do
for x = r * -1, r - 1, 1 do
local pos = {x = x, y = r * -1}
if math.sqrt(pos.x ^ 2 + pos.y ^ 2) <= radius then table.insert(global.chunk_gen_coords, pos) end
end
for y = r * -1, r - 1, 1 do
local pos = {x = r, y = y}
if math.sqrt(pos.x ^ 2 + pos.y ^ 2) <= radius then table.insert(global.chunk_gen_coords, pos) end
end
for x = r, r * -1 + 1, -1 do
local pos = {x = x, y = r}
if math.sqrt(pos.x ^ 2 + pos.y ^ 2) <= radius then table.insert(global.chunk_gen_coords, pos) end
end
for y = r, r * -1 + 1, -1 do
local pos = {x = r * -1, y = y}
if math.sqrt(pos.x ^ 2 + pos.y ^ 2) <= radius then table.insert(global.chunk_gen_coords, pos) end
end
end
end
local function draw_gui()
for _, player in pairs(game.connected_players) do
if global.map_generation_complete then
if player.gui.left["map_pregen"] then player.gui.left["map_pregen"].destroy() end
else
local caption = "Map is generating... " .. #global.chunk_gen_coords .. " chunks left."
if player.gui.left["map_pregen"] then
player.gui.left["map_pregen"].caption = caption
else
local frame = player.gui.left.add({
type = "frame",
caption = caption,
name = "map_pregen"
})
frame.style.font_color = {r = 100, g = 100, b = 250}
frame.style.font = "heading-2"
frame.style.maximal_height = 36
end
end
end
end
local function process_chunk(surface)
if global.map_generation_complete then return end
if #global.chunk_gen_coords == 0 then
global.map_generation_complete = true
draw_gui()
return
end
for i = #global.chunk_gen_coords, 1, -1 do
if surface.is_chunk_generated(global.chunk_gen_coords[i]) then
global.chunk_gen_coords[i] = nil
else
surface.request_to_generate_chunks({x = (global.chunk_gen_coords[i].x * 32) - 16, y = (global.chunk_gen_coords[i].y * 32) - 16}, 1)
surface.force_generate_chunk_requests()
global.chunk_gen_coords[i] = nil
break
end
end
draw_gui()
end
local function create_schedule(radius)
set_chunk_coords(radius)
for t = 15, #global.chunk_gen_coords * 15 + 15, 15 do
if not global.on_tick_schedule[game.tick + t] then global.on_tick_schedule[game.tick + t] = {} end
global.on_tick_schedule[game.tick + t][#global.on_tick_schedule[game.tick + t] + 1] = {
func = process_chunk,
args = {game.surfaces["biter_battles"]}
}
end
end
local function on_player_joined_game(event)
if not global.chunk_gen_coords then create_schedule(32) end
end
event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -97,8 +97,8 @@ local function generate_circle_spawn(event)
if tile then surface.set_tiles({{name = tile, position = pos}}, true) end
if surface.can_place_entity({name = "stone-wall", position = pos}) then
local noise = get_noise(2, pos) * 12
local r = 110
local noise = get_noise(2, pos) * 15
local r = 115
if distance_to_center + noise < r and distance_to_center + noise > r - 1.5 then
surface.create_entity({name = "stone-wall", position = pos, force = "north"})
end