1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-08 00:39:30 +02:00
This commit is contained in:
MewMew 2019-03-17 21:39:05 +01:00
parent 4830fc2740
commit 9d8aa66ade
9 changed files with 86 additions and 30 deletions

View File

@ -39,11 +39,11 @@ require "score"
-----------------------------
---- enable maps here ----
require "maps.biter_battles_v2.biter_battles_v2"
--require "maps.biter_battles_v2.biter_battles_v2"
--require "maps.biter_battles.biter_battles"
--require "maps.cave_miner"
--require "maps.labyrinth"
--require "maps.junkyard"
require "maps.junkyard"
--require "maps.spooky_forest"
--require "maps.nightfall"
--require "maps.atoll"

View File

@ -95,14 +95,24 @@ local function init_forces()
for action_name, _ in pairs(defines.input_action) do
p.set_allows_action(defines.input_action[action_name], false)
end
p.set_allows_action(defines.input_action.write_to_console, true)
p.set_allows_action(defines.input_action.gui_click, true)
p.set_allows_action(defines.input_action.gui_selection_state_changed, true)
p.set_allows_action(defines.input_action.start_walking, true)
p.set_allows_action(defines.input_action.open_kills_gui, true)
p.set_allows_action(defines.input_action.open_character_gui, true)
p.set_allows_action(defines.input_action.edit_permission_group, true)
p.set_allows_action(defines.input_action.toggle_show_entity_info, true)
local defs = {
defines.input_action.write_to_console,
defines.input_action.gui_click,
defines.input_action.gui_selection_state_changed,
defines.input_action.gui_checked_state_changed ,
defines.input_action.gui_elem_changed,
defines.input_action.gui_text_changed,
defines.input_action.gui_value_changed,
defines.input_action.start_walking,
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
}
for _, d in pairs(defs) do p.set_allows_action(d, true) end
global.spectator_rejoin_delay = {}
global.spy_fish_timeout = {}
global.force_area = {}

View File

@ -20,7 +20,7 @@ local gui_values = {
["south"] = {force = "south", biter_force = "south_biters", c1 = "Team South", c2 = "JOIN SOUTH", n1 = "join_south_button",
t1 = "Evolution of the South side biters. Can go beyond 100% for endgame modifiers.",
t2 = "Threat causes biters to attack. Reduces when biters are slain.", color1 = {r = 0.99, g = 0.33, b = 0.33}, color2 = {r = 0.99, g = 0.44, b = 0.44}}
}
}
local function create_sprite_button(player)
if player.gui.top["bb_toggle_button"] then return end
@ -148,16 +148,17 @@ local function create_main_gui(player)
local l = t.add { type = "label", caption = "Evo:"}
--l.style.minimal_width = 25
l.tooltip = gui_value.t1
local l = t.add {type = "label", caption = tostring(math.ceil(100 * global.bb_evolution[gui_value.biter_force])) .. "%"}
local evo = math.floor(1000 * global.bb_evolution[gui_value.biter_force]) * 0.1
local l = t.add {type = "label", caption = evo .. "%"}
l.style.minimal_width = 38
l.style.font_color = gui_value.color2
l.style.font = "default-bold"
l.tooltip = gui_value.t1
local l = t.add { type = "label", caption = "Threat: "}
local l = t.add {type = "label", caption = "Threat: "}
l.style.minimal_width = 25
l.tooltip = gui_value.t2
local l = t.add { type = "label", caption = math.ceil(global.bb_threat[gui_value.biter_force])}
local l = t.add {type = "label", caption = math.floor(global.bb_threat[gui_value.biter_force])}
l.style.font_color = gui_value.color2
l.style.font = "default-bold"
l.style.minimal_width = 25
@ -207,8 +208,10 @@ local function join_team(player, force_name)
if force_name == "south" then enemy_team = "north" end
if #game.forces[force_name].connected_players > #game.forces[enemy_team].connected_players then
player.print("Team " .. force_name .. " has too many players currently.", {r = 0.98, g = 0.66, b = 0.22})
return
if not global.chosen_team[player.name] then
player.print("Team " .. force_name .. " has too many players currently.", {r = 0.98, g = 0.66, b = 0.22})
return
end
end
if global.chosen_team[player.name] then

View File

@ -79,9 +79,13 @@ local function process_entity(surface, entity)
global.rocket_silo["south"].minable = false
return
end
if entity.name == "player" then
if entity.name == "gun-turret" or entity.name == "stone-wall" then
surface.create_entity({name = entity.name, position = new_pos, force = "south", direction = direction_translation[entity.direction]})
return
end
if entity.name == "player" then
return
end
surface.create_entity({name = entity.name, position = new_pos, direction = direction_translation[entity.direction], force = entity.force.name})
end

View File

@ -5,6 +5,15 @@ local ai = require "maps.biter_battles_v2.ai"
local chunk_pregen = require "maps.biter_battles_v2.pregenerate_chunks"
local mirror_map = require "maps.biter_battles_v2.mirror_terrain"
local function reveal_players(f)
local r = 96
local surface = game.surfaces["biter_battles"]
for _, player in pairs(game.forces[f].connected_players) do
player.force.chart(surface, {{player.position.x - r, player.position.y - r}, {player.position.x + r, player.position.y + r}})
end
end
--[[
local function reveal_team(f)
local m = 32
if f == "north" then
@ -19,30 +28,31 @@ local function reveal_team(f)
)
end
end
]]
local function on_tick(event)
if game.tick % 30 ~= 15 then return end
if game.tick % 30 ~= 0 then return end
chunk_pregen()
mirror_map()
if game.tick % 60 ~= 15 then return end
if game.tick % 60 ~= 0 then return end
global.bb_threat["north_biters"] = global.bb_threat["north_biters"] + global.bb_threat_income["north_biters"]
global.bb_threat["south_biters"] = global.bb_threat["south_biters"] + global.bb_threat_income["south_biters"]
global.bb_threat["south_biters"] = global.bb_threat["south_biters"] + global.bb_threat_income["south_biters"]
gui()
if game.tick % 300 ~= 15 then return end
if game.tick % 300 ~= 0 then return end
if global.spy_fish_timeout["south"] - game.tick > 0 then
reveal_team("north")
reveal_players("north")
else
global.spy_fish_timeout["south"] = 0
end
if global.spy_fish_timeout["north"] - game.tick > 0 then
reveal_team("south")
reveal_players("south")
else
global.spy_fish_timeout["north"] = 0
end
if game.tick % 3600 ~= 15 then return end
if game.tick % 3600 ~= 0 then return end
if global.bb_game_won_by_team then return end
ai.main_attack()
ai.send_near_biters_to_silo()

View File

@ -33,7 +33,7 @@ local function spy_fish(player)
global.spy_fish_timeout[player.force.name] = global.spy_fish_timeout[player.force.name] + duration_per_unit
player.print(math.ceil((global.spy_fish_timeout[player.force.name] - game.tick) / 60) .. " seconds of enemy vision left.", { r=0.98, g=0.66, b=0.22})
else
get_border_cords(enemy_team)
--get_border_cords(enemy_team)
game.print(player.name .. " sent a fish to spy on " .. enemy_team .. " team!", {r=0.98, g=0.66, b=0.22})
global.spy_fish_timeout[player.force.name] = game.tick + duration_per_unit
end

View File

@ -27,7 +27,17 @@ local function get_noise(name, pos)
local noise = noise[1] + noise[2] * 0.1
--noise = noise * 0.5
return noise
end
end
if name == 2 then
local noise = {}
noise[1] = simplex_noise(pos.x * 0.01, pos.y * 0.01, seed)
seed = seed + noise_seed_add
noise[2] = simplex_noise(pos.x * 0.1, pos.y * 0.1, seed)
seed = seed + noise_seed_add
local noise = noise[1] + noise[2] * 0.15
--noise = noise * 0.5
return noise
end
end
local function draw_smoothed_out_ore_circle(position, name, surface, radius, richness)
@ -66,9 +76,9 @@ local function generate_horizontal_river(surface, pos)
end
local function generate_circle_spawn(event)
if event.area.left_top.y < -64 then return end
if event.area.left_top.x < -64 then return end
if event.area.left_top.x > 64 then return end
if event.area.left_top.y < -160 then return end
if event.area.left_top.x < -160 then return end
if event.area.left_top.x > 160 then return end
local surface = event.surface
local left_top_x = event.area.left_top.x
local left_top_y = event.area.left_top.y
@ -85,6 +95,22 @@ local function generate_circle_spawn(event)
if distance_to_center < 9.5 then tile = "refined-concrete" end
if distance_to_center < 7 then tile = "sand-1" end
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
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
if distance_to_center + noise < r - 4 and distance_to_center + noise > r - 6 then
if math_random(1,128) == 1 then
if surface.can_place_entity({name = "gun-turret", position = pos}) then
surface.create_entity({name = "gun-turret", position = pos, force = "north"})
end
end
end
end
end
end
end

View File

@ -38,6 +38,8 @@ local function on_player_changed_position(event)
end
end
if #positions == 0 then return end
if math.random(1,3) == 1 then
unearthing_biters(player.surface, positions[math.random(1, #positions)], math.random(3,9))
else

View File

@ -19,7 +19,8 @@ local biter_building_inhabitants = {
local function on_entity_died(event)
if not event.entity.valid then return end
if event.entity.type ~= "unit-spawner" then return end
local e = math.ceil(game.forces.enemy.evolution_factor*10, 0)
local e = math.ceil(game.forces.enemy.evolution_factor*10)
if e < 1 then e = 1 end
for _, t in pairs (biter_building_inhabitants[e]) do
for x = 1, math_random(t[2],t[3]), 1 do
local p = event.entity.surface.find_non_colliding_position(t[1] , event.entity.position, 6, 1)