1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-08 00:39:30 +02:00
ComfyFactorio/maps/biter_battles_v2/biter_battles_v2.lua

198 lines
6.8 KiB
Lua
Raw Normal View History

2019-03-13 18:09:06 +02:00
-- Biter Battles v2 -- by MewMew
2019-03-17 19:19:40 +02:00
require "on_tick_schedule"
require "maps.biter_battles_v2.config"
2019-03-16 21:25:21 +02:00
require "modules.dynamic_landfill"
2019-03-18 15:23:12 +02:00
require "modules.spawners_contain_biters"
2019-07-13 19:12:18 +02:00
require "modules.mineable_wreckage_yields_scrap"
2019-03-16 21:25:21 +02:00
2019-03-17 03:35:58 +02:00
local event = require 'utils.event'
2019-03-13 18:09:06 +02:00
2019-03-17 19:19:40 +02:00
local function init_surface()
2019-03-13 18:09:06 +02:00
local map_gen_settings = {}
2019-07-23 17:15:32 +02:00
map_gen_settings.water = "0.2"
map_gen_settings.starting_area = "2.5"
--map_gen_settings.cliff_settings = {cliff_elevation_interval = 12, cliff_elevation_0 = 32}
2019-07-23 17:15:32 +02:00
map_gen_settings.cliff_settings = {cliff_elevation_interval = 38, cliff_elevation_0 = 38}
2019-03-13 18:09:06 +02:00
map_gen_settings.autoplace_controls = {
2019-07-14 21:37:12 +02:00
["coal"] = {frequency = "2", size = "1", richness = "1"},
["stone"] = {frequency = "2", size = "1", richness = "1"},
["copper-ore"] = {frequency = "2", size = "1", richness = "1"},
["iron-ore"] = {frequency = "2", size = "1", richness = "1"},
2019-03-14 23:50:09 +02:00
["uranium-ore"] = {frequency = "2", size = "1", richness = "1"},
2019-07-14 21:37:12 +02:00
["crude-oil"] = {frequency = "2.5", size = "1", richness = "1.5"},
2019-07-13 19:12:18 +02:00
["trees"] = {frequency = "1.25", size = "0.6", richness = "0.5"},
2019-07-18 15:41:17 +02:00
["enemy-base"] = {frequency = "128", size = "1", richness = "1"}
2019-03-13 18:09:06 +02:00
}
2019-03-14 05:25:54 +02:00
game.create_surface("biter_battles", map_gen_settings)
game.map_settings.enemy_evolution.time_factor = 0
game.map_settings.enemy_evolution.destroy_factor = 0
game.map_settings.enemy_evolution.pollution_factor = 0
game.map_settings.pollution.enabled = false
2019-03-16 21:25:21 +02:00
game.map_settings.enemy_expansion.enabled = true
game.map_settings.enemy_expansion.settler_group_min_size = 8
game.map_settings.enemy_expansion.settler_group_max_size = 16
game.map_settings.enemy_expansion.min_expansion_cooldown = 54000
game.map_settings.enemy_expansion.max_expansion_cooldown = 108000
2019-03-14 05:25:54 +02:00
end
2019-03-17 19:19:40 +02:00
local function init_forces()
local surface = game.surfaces["biter_battles"]
2019-03-14 19:06:39 +02:00
game.create_force("north")
game.create_force("north_biters")
game.create_force("south")
game.create_force("south_biters")
2019-03-14 05:25:54 +02:00
game.create_force("spectator")
local f = game.forces["north"]
f.set_spawn_position({0, -32}, surface)
2019-03-16 21:25:21 +02:00
f.set_cease_fire('player', true)
2019-03-14 05:25:54 +02:00
f.set_friend("spectator", true)
2019-03-14 19:06:39 +02:00
f.set_friend("south_biters", true)
2019-03-16 21:25:21 +02:00
f.share_chart = true
2019-03-14 19:06:39 +02:00
2019-03-14 05:25:54 +02:00
local f = game.forces["south"]
f.set_spawn_position({0, 32}, surface)
2019-03-16 21:25:21 +02:00
f.set_cease_fire('player', true)
2019-03-14 05:25:54 +02:00
f.set_friend("spectator", true)
2019-03-16 21:25:21 +02:00
f.set_friend("north_biters", true)
2019-03-14 05:25:54 +02:00
f.share_chart = true
2019-03-16 21:25:21 +02:00
local f = game.forces["north_biters"]
f.set_friend("south_biters", true)
f.set_friend("south", true)
f.set_friend("player", true)
2019-07-14 21:37:12 +02:00
--f.set_friend("enemy", true)
2019-03-16 21:25:21 +02:00
f.set_friend("spectator", true)
f.share_chart = false
2019-03-14 19:06:39 +02:00
local f = game.forces["south_biters"]
f.set_friend("north_biters", true)
f.set_friend("north", true)
f.set_friend("player", true)
2019-07-14 21:37:12 +02:00
--f.set_friend("enemy", true)
f.set_friend("spectator", true)
2019-03-16 21:25:21 +02:00
f.share_chart = false
2019-03-14 19:06:39 +02:00
2019-07-14 21:37:12 +02:00
--local f = game.forces["enemy"]
--f.set_friend("spectator", true)
--f.set_friend("player", true)
--f.set_friend("north_biters", true)
--f.set_friend("south_biters", true)
2019-03-14 05:25:54 +02:00
local f = game.forces["spectator"]
f.set_spawn_position({0,0},surface)
2019-03-18 04:24:13 +02:00
f.technologies["toolbelt"].researched=true
2019-03-18 05:47:27 +02:00
f.set_cease_fire("north_biters", true)
f.set_cease_fire("south_biters", true)
2019-03-14 05:25:54 +02:00
f.set_friend("north", true)
f.set_friend("south", true)
2019-03-18 02:30:41 +02:00
f.set_cease_fire("player", true)
2019-03-16 21:25:21 +02:00
f.share_chart = true
2019-03-14 02:00:20 +02:00
2019-03-14 05:25:54 +02:00
local f = game.forces["player"]
2019-03-18 04:24:13 +02:00
f.set_spawn_position({0,0},surface)
2019-03-16 21:25:21 +02:00
f.set_cease_fire('spectator', true)
2019-03-18 05:47:27 +02:00
f.set_cease_fire("north_biters", true)
f.set_cease_fire("south_biters", true)
2019-03-16 21:25:21 +02:00
f.set_cease_fire('north', true)
f.set_cease_fire('south', true)
f.share_chart = false
2019-03-27 04:58:22 +02:00
if not bb_config.blueprint_library_importing then
game.permissions.get_group("Default").set_allows_action(defines.input_action.grab_blueprint_record, false)
end
if not bb_config.blueprint_string_importing then
game.permissions.get_group("Default").set_allows_action(defines.input_action.import_blueprint_string, false)
game.permissions.get_group("Default").set_allows_action(defines.input_action.import_blueprint, false)
end
2019-03-27 04:58:22 +02:00
2019-03-15 02:39:49 +02:00
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)
end
2019-03-17 22:39:05 +02:00
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,
2019-03-18 04:24:13 +02:00
defines.input_action.toggle_show_entity_info,
defines.input_action.rotate_entity,
2019-03-27 04:58:22 +02:00
defines.input_action.start_research
2019-03-19 05:05:32 +02:00
}
2019-03-17 22:39:05 +02:00
for _, d in pairs(defs) do p.set_allows_action(d, true) end
2019-03-19 05:05:32 +02:00
global.rocket_silo = {}
2019-03-15 02:39:49 +02:00
global.spectator_rejoin_delay = {}
2019-03-15 04:59:43 +02:00
global.spy_fish_timeout = {}
global.force_area = {}
global.active_biters = {}
2019-03-15 22:50:49 +02:00
global.bb_evolution = {}
global.bb_evasion = {}
global.bb_threat_income = {}
global.bb_threat = {}
2019-03-17 19:19:40 +02:00
global.chunks_to_mirror = {}
2019-03-19 22:00:30 +02:00
global.map_pregen_message_counter = {}
2019-03-15 02:39:49 +02:00
2019-03-14 05:25:54 +02:00
for _, force in pairs(game.forces) do
game.forces[force.name].technologies["artillery"].enabled = false
game.forces[force.name].technologies["artillery-shell-range-1"].enabled = false
game.forces[force.name].technologies["artillery-shell-speed-1"].enabled = false
game.forces[force.name].technologies["atomic-bomb"].enabled = false
game.forces[force.name].set_ammo_damage_modifier("shotgun-shell", 1)
2019-03-15 02:39:49 +02:00
game.forces[force.name].research_queue_enabled = true
2019-03-15 04:59:43 +02:00
global.spy_fish_timeout[force.name] = 0
global.active_biters[force.name] = {}
2019-03-15 22:50:49 +02:00
global.bb_evolution[force.name] = 0
2019-04-21 02:45:24 +02:00
global.bb_evasion[force.name] = false
2019-03-15 22:50:49 +02:00
global.bb_threat_income[force.name] = 0
global.bb_threat[force.name] = 0
2019-03-14 23:50:09 +02:00
end
global.game_lobby_active = true
2019-03-13 18:09:06 +02:00
end
2019-03-27 04:58:22 +02:00
local function on_player_joined_game(event)
2019-03-17 03:35:58 +02:00
local surface = game.surfaces["biter_battles"]
2019-03-14 23:50:09 +02:00
local player = game.players[event.player_index]
if player.gui.left["map_pregen"] then player.gui.left["map_pregen"].destroy() end
2019-03-14 05:25:54 +02:00
if player.online_time == 0 then
if surface.is_chunk_generated({0,0}) then
player.teleport(surface.find_non_colliding_position("character", {0,0}, 3, 0.5), surface)
2019-03-14 05:25:54 +02:00
else
2019-03-14 23:50:09 +02:00
player.teleport({0,0}, surface)
2019-03-14 05:25:54 +02:00
end
player.character.destructible = false
game.permissions.get_group("spectator").add_player(player)
2019-03-14 05:25:54 +02:00
end
2019-03-13 18:09:06 +02:00
end
2019-03-17 19:19:40 +02:00
local function on_init(surface)
if game.surfaces["biter_battles"] then return end
init_surface()
init_forces()
global.bb_debug = false
2019-03-17 19:19:40 +02:00
end
event.on_init(on_init)
2019-03-13 18:09:06 +02:00
event.add(defines.events.on_player_joined_game, on_player_joined_game)
2019-03-14 05:25:54 +02:00
2019-03-17 19:19:40 +02:00
require "maps.biter_battles_v2.on_tick"
2019-03-14 05:25:54 +02:00
require "maps.biter_battles_v2.terrain"
2019-03-25 01:49:02 +02:00
require "maps.biter_battles_v2.no_turret_creep"
2019-03-18 06:51:32 +02:00
require "maps.biter_battles_v2.chat"
2019-03-18 15:23:12 +02:00
require "maps.biter_battles_v2.bb_map_intro"
require "modules.custom_death_messages"