diff --git a/functions/soft_reset.lua b/functions/soft_reset.lua index ac51997f..80186beb 100644 --- a/functions/soft_reset.lua +++ b/functions/soft_reset.lua @@ -19,7 +19,7 @@ local function teleport_players(surface) surface.request_to_generate_chunks(spawn, 2) surface.force_generate_chunk_requests() end - local pos = surface.find_non_colliding_position("character", spawn, 1, 0.5) + local pos = surface.find_non_colliding_position("character", spawn, 3, 0.5) player.teleport(pos, surface) end end diff --git a/maps/fish_defender/crumbly_walls.lua b/maps/fish_defender/crumbly_walls.lua index 14d979a1..bc39db91 100644 --- a/maps/fish_defender/crumbly_walls.lua +++ b/maps/fish_defender/crumbly_walls.lua @@ -8,7 +8,7 @@ local function on_entity_died(event) local entity = event.entity if not entity.valid then return end if entity.name ~= "stone-wall" then return end - if math_random(1,3) == 1 then return end + if math_random(1,4) == 1 then return end entity.surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = entity.position, force = "player"}) end diff --git a/maps/fish_defender/fish_defender.lua b/maps/fish_defender/fish_defender.lua index 1d8a213b..3e1006f1 100644 --- a/maps/fish_defender/fish_defender.lua +++ b/maps/fish_defender/fish_defender.lua @@ -859,13 +859,15 @@ end local function damage_entities_in_radius(surface, position, radius, damage) local entities_to_damage = surface.find_entities_filtered({area = {{position.x - radius, position.y - radius},{position.x + radius, position.y + radius}}}) for _, entity in pairs(entities_to_damage) do - if entity.health and entity.name ~= "land-mine" then - if entity.force.name ~= "enemy" then - if entity.name == "character" then - entity.damage(damage, "enemy") - else - entity.health = entity.health - damage - if entity.health <= 0 then entity.die("enemy") end + if entity.valid then + if entity.health and entity.name ~= "land-mine" then + if entity.force.name ~= "enemy" then + if entity.name == "character" then + entity.damage(damage, "enemy") + else + entity.health = entity.health - damage + if entity.health <= 0 then entity.die("enemy") end + end end end end @@ -959,6 +961,7 @@ local function on_player_joined_game(event) ["stone"] = {frequency = "3", size = "2", richness = "1"}, ["copper-ore"] = {frequency = "3", size = "2", richness = "1"}, ["iron-ore"] = {frequency = "3", size = "2", richness = "1"}, + ["uranium-ore"] = {frequency = "2", size = "1", richness = "1"}, ["crude-oil"] = {frequency = "4", size = "1", richness = "1"}, ["trees"] = {frequency = "1.5", size = "1.5", richness = "1"}, ["enemy-base"] = {frequency = "none", size = "none", richness = "none"} @@ -1148,9 +1151,8 @@ local function on_chunk_generated(event) map_functions.draw_oil_circle(ore_positions[5], "crude-oil", surface, 8, 200000) local pos = surface.find_non_colliding_position("market",{spawn_position_x, 0}, 50, 1) - global.market = surface.create_entity({name = "market", position = pos, force = "player"}) - global.market.minable = false - + global.market = place_fish_market(surface, pos) + local pos = surface.find_non_colliding_position("gun-turret",{spawn_position_x + 5, 1}, 50, 1) local turret = surface.create_entity({name = "gun-turret", position = pos, force = "player"}) turret.insert({name = "firearm-magazine", count = 32}) @@ -1335,6 +1337,18 @@ local function on_robot_built_entity(event) end end +local function market_light() + if not global.market_light then return end + local color = rendering.get_color(global.market_light) + for k, c in pairs(color) do + color[k] = color[k] + ((-1 + math_random(0, 2)) * 0.01) + if color[k] < 0 then color[k] = 0 end + if color[k] > 1 then color[k] = 1 end + end + color.a = 1 + rendering.set_color(global.market_light, color) +end + local function on_tick() if game.tick % 30 == 0 then if global.market then @@ -1373,6 +1387,8 @@ local function on_tick() end end end + + market_light() end if game.tick % global.wave_interval == global.wave_interval - 1 then diff --git a/maps/mixed_railworld.lua b/maps/mixed_railworld.lua index ae4cd57e..b7155b74 100644 --- a/maps/mixed_railworld.lua +++ b/maps/mixed_railworld.lua @@ -16,7 +16,7 @@ local function init_surface() map_gen_settings.starting_area = "2.5" map_gen_settings.cliff_settings = {cliff_elevation_interval = 40, cliff_elevation_0 = 40} map_gen_settings.autoplace_controls = { - ["coal"] = {frequency = "10", size = "7", richness = "1"}, + ["coal"] = {frequency = "8", size = "4", richness = "1"}, ["stone"] = {frequency = "0.3", size = "2.0", richness = "0.5"}, ["iron-ore"] = {frequency = "0.3", size = "2.0", richness = "0.5"}, ["copper-ore"] = {frequency = "0.3", size = "2.0", richness = "0.5"}, diff --git a/modules/comfylatron.lua b/modules/comfylatron.lua index 7fdf1f5e..5e90b5a2 100644 --- a/modules/comfylatron.lua +++ b/modules/comfylatron.lua @@ -399,7 +399,7 @@ local function on_entity_damaged(event) end local function on_tick() - if game.tick % 900 == 450 then + if game.tick % 1200 == 600 then heartbeat() end end diff --git a/modules/difficulty_vote.lua b/modules/difficulty_vote.lua index 141a9289..7be70cd0 100644 --- a/modules/difficulty_vote.lua +++ b/modules/difficulty_vote.lua @@ -56,6 +56,7 @@ local function set_difficulty() a = a + d vote_count = vote_count + 1 end + if vote_count == 0 then return end a = a / vote_count local new_index = math.round(a, 0) if global.difficulty_vote_index ~= new_index then @@ -81,15 +82,25 @@ end local function on_player_joined_game(event) local player = game.players[event.player_index] - if player.online_time == 0 then - poll_difficulty(player) - end if not global.difficulty_vote_value then global.difficulty_vote_value = 1 end if not global.difficulty_vote_index then global.difficulty_vote_index = 4 end if not global.difficulty_player_votes then global.difficulty_player_votes = {} end + if game.tick < global.difficulty_poll_closing_timeout then + if not global.difficulty_player_votes[player.name] then + poll_difficulty(player) + end + end difficulty_gui() end +local function on_player_left_game(event) + if game.tick > global.difficulty_poll_closing_timeout then return end + local player = game.players[event.player_index] + if not global.difficulty_player_votes[player.name] then return end + global.difficulty_player_votes[player.name] = nil + set_difficulty() +end + local function on_gui_click(event) if not event then return end if not event.element then return end @@ -110,5 +121,6 @@ local function on_gui_click(event) event.element.parent.destroy() end -event.add(defines.events.on_gui_click, on_gui_click) -event.add(defines.events.on_player_joined_game, on_player_joined_game) \ No newline at end of file +event.add(defines.events.on_player_joined_game, on_player_joined_game) +event.add(defines.events.on_player_left_game, on_player_left_game) +event.add(defines.events.on_gui_click, on_gui_click) \ No newline at end of file