1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-25 21:29:06 +02:00
This commit is contained in:
MewMew 2019-11-10 02:46:29 +01:00
parent c282923649
commit 7b1f2ca20e
4 changed files with 83 additions and 31 deletions

View File

@ -2,10 +2,10 @@ local Tabs = require 'comfy_panel.main'
local Map_score = require "modules.map_score"
local Terrain = require "maps.junkyard_pvp.terrain"
local Gui = require "maps.junkyard_pvp.gui"
require "maps.junkyard_pvp.surrounded_by_worms"
require "modules.rocks_heal_over_time"
require "maps.junkyard_pvp.share_chat"
require "modules.mineable_wreckage_yields_scrap"
require "modules.explosives"
local Team = require "maps.junkyard_pvp.team"
local Reset = require "functions.soft_reset"
local Map = require "modules.map_info"
@ -25,6 +25,16 @@ local map_gen_settings = {
},
}
local function set_player_colors()
for _, player in pairs(game.forces.west.players) do
player.color = {50, 255, 50}
end
for _, player in pairs(game.forces.east.players) do
player.color = {50, 50, 255}
end
end
function Public.reset_map()
Terrain.create_mirror_surface()
@ -56,6 +66,8 @@ function Public.reset_map()
for _, player in pairs(game.forces.spectator.players) do
Gui.rejoin_question(player)
end
set_player_colors()
end
local function on_entity_died(event)
@ -108,6 +120,7 @@ local function on_player_joined_game(event)
local player = game.players[event.player_index]
local surface = game.surfaces[global.active_surface_index]
set_player_colors()
Gui.spectate_button(player)
if player.surface.index ~= global.active_surface_index then
@ -118,7 +131,8 @@ local function on_player_joined_game(event)
end
Team.assign_force_to_player(player)
Team.teleport_player_to_active_surface(player)
Team.put_player_into_random_team(player)
Team.put_player_into_random_team(player)
set_player_colors()
end
end
@ -154,11 +168,15 @@ local function set_player_spawn_and_refill_fish()
end
end
local function on_console_command(event)
set_player_colors()
end
local function tick()
local game_tick = game.tick
if game_tick % 240 == 0 then
local surface = game.surfaces[global.active_surface_index]
local area = {{-320, -161}, {319, 160}}
local area = {{-256, -127}, {255, 128}}
game.forces.west.chart(surface, area)
game.forces.east.chart(surface, area)
end
@ -169,13 +187,13 @@ local function tick()
end
return
end
if game_tick % 900 == 0 then
if game_tick % 1800 == 0 then
set_player_spawn_and_refill_fish()
end
end
local function on_init()
game.difficulty_settings.technology_price_multiplier = 0.5
game.difficulty_settings.technology_price_multiplier = 0.25
game.map_settings.enemy_evolution.destroy_factor = 0
game.map_settings.enemy_evolution.pollution_factor = 0
game.map_settings.enemy_evolution.time_factor = 0
@ -194,22 +212,15 @@ local function on_init()
"\n",
"Destroy their cargo wagon to win the round!\n",
"\n",
"Sometimes you will encounter impassable dark chasms or ponds.\n",
"Some explosives may cause parts of the ceiling to crumble, filling the void, creating new ways.\n",
"All they need is a container and a well aimed shot.\n",
--"Sometimes you will encounter impassable dark chasms or ponds.\n",
--"Some explosives may cause parts of the ceiling to crumble, filling the void, creating new ways.\n",
--"All they need is a container and a well aimed shot.\n",
})
T.main_caption_color = {r = 150, g = 0, b = 255}
T.sub_caption_color = {r = 0, g = 250, b = 150}
global.explosion_cells_destructible_tiles = {
["out-of-map"] = 1500,
["water"] = 1000,
["water-green"] = 1000,
["deepwater-green"] = 1000,
["deepwater"] = 1000,
["water-shallow"] = 1000,
}
global.rocks_yield_ore_base_amount = 100
Team.create_forces()
Public.reset_map()
end
@ -217,6 +228,7 @@ end
local event = require 'utils.event'
event.on_init(on_init)
event.on_nth_tick(60, tick)
event.add(defines.events.on_console_command, on_console_command)
event.add(defines.events.on_entity_died, on_entity_died)
event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -0,0 +1,39 @@
local event = require 'utils.event'
local math_random = math.random
local turrets = {
[1] = "small-worm-turret",
[2] = "medium-worm-turret",
[3] = "big-worm-turret",
[4] = "behemoth-worm-turret"
}
local tile_coords = {}
for x = 0, 31, 1 do
for y = 0, 31, 1 do
tile_coords[#tile_coords + 1] = {x, y}
end
end
local function on_chunk_generated(event)
local surface = event.surface
if surface.name ~= "mirror_terrain" then return end
local starting_distance = surface.map_gen_settings.starting_area * 200
local left_top = event.area.left_top
local chunk_distance_to_center = math.sqrt(left_top.x ^ 2 + left_top.y ^ 2)
if starting_distance > chunk_distance_to_center then return end
local highest_worm_tier = math.floor((chunk_distance_to_center - starting_distance) * 0.0025) + 1
if highest_worm_tier > 4 then highest_worm_tier = 4 end
for a = 1, 4, 1 do
local coord_modifier = tile_coords[math_random(1, #tile_coords)]
local pos = {left_top.x + coord_modifier[1], left_top.y + coord_modifier[2]}
local name = turrets[math_random(1, highest_worm_tier)]
local position = surface.find_non_colliding_position("big-worm-turret", pos, 8, 1)
if position then
surface.create_entity({name = name, position = position, force = "enemy"})
end
end
end
event.add(defines.events.on_chunk_generated, on_chunk_generated)

View File

@ -37,10 +37,11 @@ end
local function create_objectives(surface)
local d = 6
for key, modifier in pairs({west = -1, east = 1}) do
for key, modifier in pairs({west = -1, east = 1}) do
for x = -6, 6, 2 do surface.create_entity({name = "straight-rail", position = {(cargo_wagon_position.x + x) * modifier, cargo_wagon_position.y}, force = key, direction = 2}) end
local e = surface.create_entity({name = "locomotive", position = {(cargo_wagon_position.x + 3) * modifier, cargo_wagon_position.y}, force = key, direction = d})
e.color = {0, 255, 0}
if key == "east" then e.color = {0, 0, 255} end
e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 50})
local e = surface.create_entity({name = "cargo-wagon", position = {(cargo_wagon_position.x - 3) * modifier, cargo_wagon_position.y}, force = key})
e.minable = false
@ -55,7 +56,7 @@ function Public.create_mirror_surface()
local map_gen_settings = {}
map_gen_settings.seed = math_random(1, 99999999)
map_gen_settings.water = 0.2
map_gen_settings.starting_area = 1
map_gen_settings.starting_area = 1.5
map_gen_settings.terrain_segmentation = 8
map_gen_settings.cliff_settings = {cliff_elevation_interval = 0, cliff_elevation_0 = 0}
map_gen_settings.autoplace_controls = {
@ -153,16 +154,16 @@ local function process_junk_position(p, seed, tiles, entities, markets, treasure
entities[#entities + 1] = {name="gun-turret", position=p, force = "enemy"}
end
tiles[#tiles + 1] = {name = "dirt-7", position = p}
if scrapyard < -0.55 or scrapyard > 0.55 then
if scrapyard < -0.65 or scrapyard > 0.65 then
if math_random(1,5) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end
return
end
if scrapyard < -0.28 or scrapyard > 0.28 then
if math_random(1,2048) == 1 then
entities[#entities + 1] = {name = "small-worm-turret", position = p, force = "enemy"}
end
--if math_random(1,2048) == 1 then
--entities[#entities + 1] = {name = "small-worm-turret", position = p, force = "enemy"}
--end
if math_random(1,96) == 1 then entities[#entities + 1] = {name = scrap_entities[math_random(1, scrap_entities_index)], position = p, force = "enemy"} end
if math_random(1,5) > 1 then entities[#entities + 1] = {name="mineable-wreckage", position=p} end
if math_random(1,3) > 1 then entities[#entities + 1] = {name="mineable-wreckage", position=p} end
return
end
return
@ -177,9 +178,9 @@ local function process_junk_position(p, seed, tiles, entities, markets, treasure
local large_caves = get_noise("large_caves", p, seed)
if scrapyard > -0.15 and scrapyard < 0.15 then
if math_floor(large_caves * 10) % 4 < 2 then
if math_floor(large_caves * 10) % 4 < 1 then
tiles[#tiles + 1] = {name = "dirt-7", position = p}
if math_random(1,3) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end
if math_random(1,2) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end
return
end
end

View File

@ -23,7 +23,7 @@ function Public.treasure_chest(surface, position, container_name)
{{name = "rocket", count = math_random(16,32)}, weight = 5, d_min = 0.2, d_max = 0.7},
{{name = "explosive-rocket", count = math_random(16,32)}, weight = 5, d_min = 0.3, d_max = 1},
{{name = "land-mine", count = math_random(16,32)}, weight = 5, d_min = 0.2, d_max = 0.7},
{{name = "grenade", count = math_random(16,32)}, weight = 5, d_min = 0.0, d_max = 0.5},
{{name = "grenade", count = math_random(8,16)}, weight = 5, d_min = 0.0, d_max = 0.5},
{{name = "cluster-grenade", count = math_random(8,16)}, weight = 5, d_min = 0.4, d_max = 1},
{{name = "firearm-magazine", count = math_random(32,128)}, weight = 5, d_min = 0, d_max = 0.3},
{{name = "piercing-rounds-magazine", count = math_random(32,128)}, weight = 5, d_min = 0.1, d_max = 0.8},
@ -64,7 +64,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(25,50)}, weight = 1, 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},
@ -158,7 +158,7 @@ function Public.treasure_chest(surface, position, container_name)
{{name = "gun-turret", count = math_random(2,4)}, weight = 3, d_min = 0.2, d_max = 0.9},
}
local distance_to_center = (math.abs(position.y) + 1) * 0.0002
local distance_to_center = (math.abs(position.x) + 1) * 0.0002
if distance_to_center > 1 then distance_to_center = 1 end
for _, t in pairs (chest_loot) do