mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-05-13 21:56:29 +02:00
fucking confilcts
This commit is contained in:
parent
300671f916
commit
e468adedc5
161
control.lua
Normal file
161
control.lua
Normal file
@ -0,0 +1,161 @@
|
||||
require 'utils.data_stages'
|
||||
_LIFECYCLE = _STAGE.control -- Control stage
|
||||
_DEBUG = false
|
||||
_DUMP_ENV = false
|
||||
|
||||
require 'utils.server'
|
||||
require "utils.server_commands"
|
||||
require "utils.utils"
|
||||
require "utils.table"
|
||||
require "utils.color_data"
|
||||
require "utils.session_data"
|
||||
require "chatbot"
|
||||
require "commands"
|
||||
require "antigrief"
|
||||
require "modules.corpse_markers"
|
||||
require "modules.floaty_chat"
|
||||
require "modules.autohotbar"
|
||||
|
||||
require "comfy_panel.main"
|
||||
require "comfy_panel.player_list"
|
||||
require "comfy_panel.admin"
|
||||
require "comfy_panel.group"
|
||||
require "comfy_panel.poll"
|
||||
require "comfy_panel.score"
|
||||
require "comfy_panel.config"
|
||||
|
||||
require "modules.autostash"
|
||||
|
||||
---- enable modules here ----
|
||||
--require "modules.the_floor_is_lava"
|
||||
--require "modules.biters_landfill_on_death"
|
||||
--require "modules.autodecon_when_depleted"
|
||||
--require "modules.biter_noms_you"
|
||||
--require "modules.biters_avoid_damage"
|
||||
--require "modules.biters_double_damage"
|
||||
--require "modules.burden"
|
||||
--require "modules.comfylatron"
|
||||
--require "modules.spaghett_challenge"
|
||||
--require "modules.dangerous_goods"
|
||||
--require "modules.dynamic_landfill"
|
||||
--require "modules.explosive_biters"
|
||||
--require "modules.explosive_player_respawn"
|
||||
--require "modules.explosives_are_explosive"
|
||||
--require "modules.fish_respawner"
|
||||
--require "modules.fluids_are_explosive"
|
||||
--require "modules.hunger"
|
||||
--require "modules.hunger_games"
|
||||
--require "modules.players_trample_paths"
|
||||
--require "modules.railgun_enhancer"
|
||||
--require "modules.restrictive_fluid_mining"
|
||||
--require "modules.satellite_score"
|
||||
--require "modules.show_health"
|
||||
--require "modules.splice_double"
|
||||
--require "modules.ores_are_mixed"
|
||||
--require "modules.team_teleport" --(REQUIRES "on_tick_schedule" !)
|
||||
--require "modules.surrounded_by_worms"
|
||||
--require "modules.more_attacks"
|
||||
--require "modules.evolution_extended"
|
||||
--require "modules.no_blueprint_library"
|
||||
--require "modules.explosives"
|
||||
--require "modules.biter_pets"
|
||||
--require "modules.no_solar"
|
||||
--require "modules.biter_reanimator"
|
||||
--require "modules.wave_defense.main"
|
||||
--require "modules.fjei.main"
|
||||
-----------------------------
|
||||
|
||||
---- enable maps here ---- (maps higher up in the list may be more actually playable)
|
||||
--require "maps.fish_defender.main"
|
||||
--require "maps.biter_battles_v2.main"
|
||||
--require "maps.native_war.main"
|
||||
--require "maps.mountain_fortress_v2.main"
|
||||
--require "maps.dungeons.main"
|
||||
--require "maps.island_troopers.main"
|
||||
--require "maps.biter_hatchery.main"
|
||||
--require "maps.junkyard_pvp.main"
|
||||
--require "maps.scrapyard.main"
|
||||
--require "maps.tank_conquest.tank_conquest"
|
||||
--require "maps.territorial_control"
|
||||
--require "maps.cave_choppy.cave_miner"
|
||||
--require "maps.wave_of_death.WoD"
|
||||
--require "maps.planet_prison"
|
||||
--require "maps.stone_maze.main"
|
||||
--require "maps.choppy"
|
||||
--require "maps.overgrowth"
|
||||
--require "maps.quarters"
|
||||
--require "maps.railway_troopers.main"
|
||||
--require "maps.tetris.main"
|
||||
--require "maps.maze_challenge"
|
||||
--require "maps.cave_miner"
|
||||
--require "maps.labyrinth"
|
||||
--require "maps.junkyard"
|
||||
--require "maps.hedge_maze"
|
||||
--require "maps.spooky_forest"
|
||||
--require "maps.mixed_railworld"
|
||||
--require "maps.biter_battles.biter_battles"
|
||||
--require "maps.fish_defender_v1.fish_defender"
|
||||
--require "maps.mountain_fortress"
|
||||
--require "maps.rocky_waste"
|
||||
--require "maps.nightfall"
|
||||
--require "maps.lost"
|
||||
--require "maps.rivers"
|
||||
--require "maps.atoll"
|
||||
--require "maps.cratewood_forest"
|
||||
--require "maps.tank_battles"
|
||||
--require "maps.spiral_troopers"
|
||||
--require "maps.refactor-io"
|
||||
--require "maps.desert_oasis"
|
||||
--require "maps.lost_desert"
|
||||
--require "maps.stoneblock"
|
||||
--require "maps.wave_defense"
|
||||
--require "maps.crossing"
|
||||
--require "maps.anarchy"
|
||||
--require "maps.spaghettorio"
|
||||
--require "maps.blue_beach"
|
||||
--require "maps.deep_jungle"
|
||||
--require "maps.rainbow_road"
|
||||
--require "maps.pitch_black.main"
|
||||
--require "maps.cube"
|
||||
--require "maps.forest_circle"
|
||||
-----------------------------
|
||||
|
||||
---- more modules here ----
|
||||
--require "modules.towny.main"
|
||||
--require "modules.rpg"
|
||||
--require "modules.trees_grow"
|
||||
--require "modules.trees_randomly_die"
|
||||
|
||||
--require "terrain_layouts.caves"
|
||||
--require "terrain_layouts.cone_to_east"
|
||||
--require "terrain_layouts.biters_and_resources_east"
|
||||
--require "terrain_layouts.scrap_01"
|
||||
--require "terrain_layouts.watery_world"
|
||||
--require "terrain_layouts.tree_01"
|
||||
------
|
||||
|
||||
if _DUMP_ENV then
|
||||
require 'utils.dump_env'
|
||||
end
|
||||
if _DEBUG then
|
||||
require 'utils.debug.command'
|
||||
end
|
||||
|
||||
local function on_player_created(event)
|
||||
local player = game.players[event.player_index]
|
||||
player.gui.top.style = 'slot_table_spacing_horizontal_flow'
|
||||
player.gui.left.style = 'slot_table_spacing_vertical_flow'
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
game.forces.player.research_queue_enabled = true
|
||||
end
|
||||
|
||||
local loaded = _G.package.loaded
|
||||
function require(path)
|
||||
return loaded[path] or error('Can only require files at runtime that have been required in the control stage.', 2)
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_player_created, on_player_created)
|
413
maps/mountain_fortress_v2/main.lua
Normal file
413
maps/mountain_fortress_v2/main.lua
Normal file
@ -0,0 +1,413 @@
|
||||
-- Mountain digger fortress, protect the cargo wagon! -- by MewMew
|
||||
|
||||
--enable / disable collapsing of the map
|
||||
local collapse_enabled = false
|
||||
local darkness = false
|
||||
|
||||
require "player_modifiers"
|
||||
require "functions.soft_reset"
|
||||
require "functions.basic_markets"
|
||||
|
||||
local RPG = require "modules.rpg"
|
||||
require "modules.wave_defense.main"
|
||||
require "modules.biters_yield_coins"
|
||||
require "modules.no_deconstruction_of_neutral_entities"
|
||||
require "modules.no_solar"
|
||||
require "modules.shotgun_buff"
|
||||
require "modules.explosives"
|
||||
require "modules.mineable_wreckage_yields_scrap"
|
||||
require "modules.rocks_broken_paint_tiles"
|
||||
require "modules.rocks_heal_over_time"
|
||||
require "modules.rocks_yield_ore_veins"
|
||||
local level_depth = require "maps.mountain_fortress_v2.terrain"
|
||||
local Collapse = require "maps.mountain_fortress_v2.collapse"
|
||||
require "maps.mountain_fortress_v2.flamethrower_nerf"
|
||||
local BiterRolls = require "modules.wave_defense.biter_rolls"
|
||||
local BiterHealthBooster = require "modules.biter_health_booster"
|
||||
local Reset = require "functions.soft_reset"
|
||||
local Pets = require "modules.biter_pets"
|
||||
local Map = require "modules.map_info"
|
||||
local WD = require "modules.wave_defense.table"
|
||||
local Treasure = require "maps.mountain_fortress_v2.treasure"
|
||||
local Locomotive = require "maps.mountain_fortress_v2.locomotive"
|
||||
local Modifier = require "player_modifiers"
|
||||
local math_random = math.random
|
||||
local Public = {}
|
||||
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16, ['wood'] = 16, ['explosives'] = 32}
|
||||
local treasure_chest_messages = {
|
||||
"You notice an old crate within the rubble. It's filled with treasure!",
|
||||
"You find a chest underneath the broken rocks. It's filled with goodies!",
|
||||
"We has found the precious!",
|
||||
}
|
||||
|
||||
local function set_difficulty()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local player_count = #game.connected_players
|
||||
|
||||
wave_defense_table.max_active_biters = 1024
|
||||
|
||||
-- threat gain / wave
|
||||
wave_defense_table.threat_gain_multiplier = 2 + player_count * 0.1
|
||||
|
||||
--1 additional map collapse tile / 8 players in game
|
||||
global.map_collapse.speed = math.floor(player_count * 0.125) + 1
|
||||
|
||||
--20 Players for fastest wave_interval
|
||||
wave_defense_table.wave_interval = 3600 - player_count * 90
|
||||
if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end
|
||||
end
|
||||
|
||||
function Public.reset_map()
|
||||
local wave_defense_table = WD.get_table()
|
||||
global.chunk_queue = {}
|
||||
|
||||
if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end
|
||||
|
||||
local map_gen_settings = {
|
||||
["seed"] = math_random(1, 1000000),
|
||||
["width"] = level_depth,
|
||||
["water"] = 0.1,
|
||||
["starting_area"] = 1,
|
||||
["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
|
||||
["default_enable_all_autoplace_controls"] = true,
|
||||
["autoplace_settings"] = {
|
||||
["entity"] = {treat_missing_as_default = false},
|
||||
["tile"] = {treat_missing_as_default = true},
|
||||
["decorative"] = {treat_missing_as_default = true},
|
||||
},
|
||||
}
|
||||
|
||||
if not global.active_surface_index then
|
||||
global.active_surface_index = game.create_surface("mountain_fortress", map_gen_settings).index
|
||||
else
|
||||
game.forces.player.set_spawn_position({-2, 16}, game.surfaces[global.active_surface_index])
|
||||
global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], map_gen_settings, starting_items).index
|
||||
end
|
||||
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
|
||||
if darkness then
|
||||
surface.min_brightness = 0.10
|
||||
surface.brightness_visual_weights = {0.90, 0.90, 0.90}
|
||||
surface.daytime = 0.42
|
||||
surface.freeze_daytime = true
|
||||
surface.solar_power_multiplier = 999
|
||||
end
|
||||
|
||||
surface.request_to_generate_chunks({0,0}, 2)
|
||||
surface.force_generate_chunk_requests()
|
||||
|
||||
for x = -768 + 32, 768 - 32, 32 do
|
||||
surface.request_to_generate_chunks({x, 96}, 1)
|
||||
surface.force_generate_chunk_requests()
|
||||
end
|
||||
|
||||
game.difficulty_settings.technology_price_multiplier = 0.5
|
||||
game.map_settings.enemy_evolution.destroy_factor = 0
|
||||
game.map_settings.enemy_evolution.pollution_factor = 0
|
||||
game.map_settings.enemy_evolution.time_factor = 0
|
||||
game.map_settings.enemy_expansion.enabled = true
|
||||
game.map_settings.enemy_expansion.max_expansion_cooldown = 3600
|
||||
game.map_settings.enemy_expansion.min_expansion_cooldown = 3600
|
||||
game.map_settings.enemy_expansion.settler_group_max_size = 8
|
||||
game.map_settings.enemy_expansion.settler_group_min_size = 16
|
||||
game.map_settings.pollution.enabled = false
|
||||
|
||||
game.forces.player.technologies["land-mine"].enabled = false
|
||||
game.forces.player.technologies["landfill"].enabled = false
|
||||
game.forces.player.technologies["railway"].researched = true
|
||||
game.forces.player.set_spawn_position({-2, 16}, surface)
|
||||
|
||||
Locomotive.locomotive_spawn(surface, {x = 0, y = 16})
|
||||
|
||||
WD.reset_wave_defense()
|
||||
wave_defense_table.surface_index = global.active_surface_index
|
||||
wave_defense_table.target = global.locomotive_cargo
|
||||
wave_defense_table.nest_building_density = 32
|
||||
wave_defense_table.game_lost = false
|
||||
|
||||
Collapse.init()
|
||||
|
||||
RPG.rpg_reset_all_players()
|
||||
|
||||
set_difficulty()
|
||||
end
|
||||
|
||||
local function protect_train(event)
|
||||
if event.entity.force.index ~= 1 then return end --Player Force
|
||||
if event.entity == global.locomotive_cargo then
|
||||
if event.cause then
|
||||
if event.cause.force.index == 2 then
|
||||
return
|
||||
end
|
||||
end
|
||||
event.entity.health = event.entity.health + event.final_damage_amount
|
||||
end
|
||||
end
|
||||
|
||||
local function biters_chew_rocks_faster(event)
|
||||
if event.entity.force.index ~= 3 then return end --Neutral Force
|
||||
if not event.cause then return end
|
||||
if not event.cause.valid then return end
|
||||
if event.cause.force.index ~= 2 then return end --Enemy Force
|
||||
event.entity.health = event.entity.health - event.final_damage_amount * 2.5
|
||||
end
|
||||
|
||||
local function hidden_biter(entity)
|
||||
local d = math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2)
|
||||
|
||||
BiterRolls.wave_defense_set_unit_raffle(d * 0.25)
|
||||
|
||||
local unit
|
||||
if math_random(1,3) == 1 then
|
||||
unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = entity.position})
|
||||
else
|
||||
unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = entity.position})
|
||||
end
|
||||
|
||||
local m = 1 / level_depth
|
||||
m = m * d
|
||||
|
||||
if math_random(1, 256) == 1 then
|
||||
BiterHealthBooster.add_boss_unit(unit, m * 15 + 1, 0.38)
|
||||
else
|
||||
BiterHealthBooster.add_unit(unit, m * 2.5 + 1)
|
||||
end
|
||||
end
|
||||
|
||||
local function hidden_worm(entity)
|
||||
BiterRolls.wave_defense_set_worm_raffle(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.25)
|
||||
entity.surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = entity.position})
|
||||
end
|
||||
|
||||
local function hidden_biter_pet(event)
|
||||
if math_random(1, 2048) ~= 1 then return end
|
||||
BiterRolls.wave_defense_set_unit_raffle(math.sqrt(event.entity.position.x ^ 2 + event.entity.position.y ^ 2) * 0.25)
|
||||
local unit
|
||||
if math_random(1,3) == 1 then
|
||||
unit = event.entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = event.entity.position})
|
||||
else
|
||||
unit = event.entity.surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = event.entity.position})
|
||||
end
|
||||
Pets.biter_pets_tame_unit(game.players[event.player_index], unit, true)
|
||||
end
|
||||
|
||||
local function hidden_treasure(event)
|
||||
if math_random(1, 320) ~= 1 then return end
|
||||
game.players[event.player_index].print(treasure_chest_messages[math_random(1, #treasure_chest_messages)], {r=0.98, g=0.66, b=0.22})
|
||||
Treasure(event.entity.surface, event.entity.position, "wooden-chest")
|
||||
end
|
||||
|
||||
local projectiles = {"grenade", "explosive-rocket", "grenade", "explosive-rocket", "explosive-cannon-projectile"}
|
||||
local function angry_tree(entity, cause)
|
||||
if entity.type ~= "tree" then return end
|
||||
if math.abs(entity.position.y) < level_depth then return end
|
||||
if math_random(1,4) == 1 then hidden_biter(entity) end
|
||||
if math_random(1,8) == 1 then hidden_worm(entity) end
|
||||
if math_random(1,16) ~= 1 then return end
|
||||
local position = false
|
||||
if cause then
|
||||
if cause.valid then
|
||||
position = cause.position
|
||||
end
|
||||
end
|
||||
if not position then position = {entity.position.x + (-20 + math_random(0, 40)), entity.position.y + (-20 + math_random(0, 40))} end
|
||||
|
||||
entity.surface.create_entity({
|
||||
name = projectiles[math_random(1, 5)],
|
||||
position = entity.position,
|
||||
force = "neutral",
|
||||
source = entity.position,
|
||||
target = position,
|
||||
max_range = 64,
|
||||
speed = 0.10
|
||||
})
|
||||
end
|
||||
|
||||
local function give_coin(player)
|
||||
player.insert({name = "coin", count = 1})
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
if not event.entity.valid then return end
|
||||
if event.entity.force.index ~= 3 then return end
|
||||
|
||||
if event.entity.type == "simple-entity" then
|
||||
give_coin(game.players[event.player_index])
|
||||
|
||||
if math_random(1,32) == 1 then
|
||||
hidden_biter(event.entity)
|
||||
return
|
||||
end
|
||||
if math_random(1,512) == 1 then
|
||||
hidden_worm(event.entity)
|
||||
return
|
||||
end
|
||||
hidden_biter_pet(event)
|
||||
hidden_treasure(event)
|
||||
end
|
||||
|
||||
angry_tree(event.entity, game.players[event.player_index].character)
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local wave_defense_table = WD.get_table()
|
||||
if not event.entity.valid then return end
|
||||
if event.entity == global.locomotive_cargo then
|
||||
game.print("The cargo was destroyed!")
|
||||
wave_defense_table.game_lost = true
|
||||
wave_defense_table.target = nil
|
||||
global.game_reset_tick = game.tick + 1800
|
||||
for _, player in pairs(game.connected_players) do
|
||||
player.play_sound{path="utility/game_lost", volume_modifier=0.75}
|
||||
end
|
||||
event.entity.surface.spill_item_stack(event.entity.position,{name = "raw-fish", count = 512}, false)
|
||||
return
|
||||
end
|
||||
|
||||
if event.cause then
|
||||
if event.cause.valid then
|
||||
if event.cause.force.index == 2 or event.cause.force.index == 3 then return end
|
||||
end
|
||||
end
|
||||
|
||||
if event.entity.force.index == 3 then
|
||||
--local r_max = 15 - math.floor(math.abs(event.entity.position.y) / (level_depth * 0.5))
|
||||
--if r_max < 3 then r_max = 3 end
|
||||
if math_random(1,8) == 1 then
|
||||
hidden_biter(event.entity)
|
||||
end
|
||||
|
||||
if math_random(1,256) == 1 then hidden_worm(event.entity) end
|
||||
|
||||
angry_tree(event.entity, event.cause)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
if not event.entity.valid then return end
|
||||
protect_train(event)
|
||||
|
||||
if not event.entity.health then return end
|
||||
biters_chew_rocks_faster(event)
|
||||
--neutral_force_player_damage_resistance(event)
|
||||
end
|
||||
|
||||
local function on_research_finished(event)
|
||||
event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 50 -- +5 Slots / level
|
||||
local mining_speed_bonus = game.forces.player.mining_drill_productivity_bonus * 5 -- +50% speed / level
|
||||
if event.research.force.technologies["steel-axe"].researched then mining_speed_bonus = mining_speed_bonus + 0.5 end -- +50% speed for steel-axe research
|
||||
event.research.force.manual_mining_speed_modifier = mining_speed_bonus
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player_modifiers = Modifier.get_table()
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
set_difficulty()
|
||||
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
|
||||
if player.online_time == 0 then
|
||||
player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface)
|
||||
for item, amount in pairs(starting_items) do
|
||||
player.insert({name = item, count = amount})
|
||||
end
|
||||
end
|
||||
|
||||
if player.surface.index ~= global.active_surface_index and player.surface.name ~= "cargo_wagon" then
|
||||
player.character = nil
|
||||
player.set_controller({type=defines.controllers.god})
|
||||
player.create_character()
|
||||
player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface)
|
||||
for item, amount in pairs(starting_items) do
|
||||
player.insert({name = item, count = amount})
|
||||
end
|
||||
end
|
||||
|
||||
player_modifiers[player.index].character_mining_speed_modifier["mountain_fortress"] = 0.5
|
||||
Modifier.update_player_modifiers(player)
|
||||
|
||||
local tile = surface.get_tile(player.position)
|
||||
if tile.valid then
|
||||
if tile.name == "out-of-map" then
|
||||
player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_left_game(event)
|
||||
set_difficulty()
|
||||
end
|
||||
|
||||
local function tick()
|
||||
local tick = game.tick
|
||||
if tick % 30 == 0 then
|
||||
if tick % 1800 == 0 then
|
||||
Locomotive.set_player_spawn_and_refill_fish()
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
local last_position = global.map_collapse.last_position
|
||||
local position = surface.find_non_colliding_position("stone-furnace", {last_position.x, last_position.y - 32}, 128, 4)
|
||||
if position then
|
||||
local wave_defense_table = WD.get_table()
|
||||
wave_defense_table.spawn_position = position
|
||||
end
|
||||
--if tick % 216000 == 0 then
|
||||
-- Collapse.delete_out_of_map_chunks(surface)
|
||||
--end
|
||||
end
|
||||
if global.game_reset_tick then
|
||||
if global.game_reset_tick < tick then
|
||||
global.game_reset_tick = nil
|
||||
require "maps.mountain_fortress_v2.main".reset_map()
|
||||
end
|
||||
return
|
||||
end
|
||||
Locomotive.fish_tag()
|
||||
end
|
||||
if not collapse_enabled then return end
|
||||
Collapse.process()
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
local T = Map.Pop_info()
|
||||
T.localised_category = "mountain_fortress"
|
||||
T.main_caption_color = {r = 150, g = 150, b = 0}
|
||||
T.sub_caption_color = {r = 0, g = 150, b = 0}
|
||||
global.rocks_yield_ore_maximum_amount = 999
|
||||
global.rocks_yield_ore_base_amount = 50
|
||||
global.rocks_yield_ore_distance_modifier = 0.025
|
||||
|
||||
global.explosion_cells_destructible_tiles = {
|
||||
["out-of-map"] = 1500,
|
||||
["water"] = 1000,
|
||||
["water-green"] = 1000,
|
||||
["deepwater-green"] = 1000,
|
||||
["deepwater"] = 1000,
|
||||
["water-shallow"] = 1000,
|
||||
}
|
||||
|
||||
Public.reset_map()
|
||||
end
|
||||
|
||||
local function on_player_driving_changed_state(event)
|
||||
local player = game.players[event.player_index]
|
||||
local vehicle = event.entity
|
||||
Locomotive.enter_cargo_wagon(player, vehicle)
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.on_init(on_init)
|
||||
event.on_nth_tick(2, tick)
|
||||
event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
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_player_mined_entity, on_player_mined_entity)
|
||||
event.add(defines.events.on_research_finished, on_research_finished)
|
||||
event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state)
|
||||
|
||||
require "modules.rocks_yield_ore"
|
||||
|
||||
return Public
|
267
maps/overgrowth.lua
Normal file
267
maps/overgrowth.lua
Normal file
@ -0,0 +1,267 @@
|
||||
--overgrowth-- by mewmew --
|
||||
|
||||
require "on_tick_schedule"
|
||||
require "modules.dynamic_landfill"
|
||||
require "modules.satellite_score"
|
||||
require "modules.spawners_contain_biters"
|
||||
require "modules.no_deconstruction_of_neutral_entities"
|
||||
require "modules.biters_yield_coins"
|
||||
require "modules.rocks_yield_ore"
|
||||
require "modules.ores_are_mixed"
|
||||
require "modules.surrounded_by_worms"
|
||||
global.average_worm_amount_per_chunk = 1.5
|
||||
require "modules.biters_attack_moving_players"
|
||||
require "modules.market_friendly_fire_protection"
|
||||
require "modules.trees_grow"
|
||||
require "modules.trees_randomly_die"
|
||||
|
||||
require "maps.overgrowth_map_info"
|
||||
|
||||
local Reset = require "functions.soft_reset"
|
||||
local rpg_t = require 'modules.rpg'
|
||||
local kaboom = require "functions.omegakaboom"
|
||||
|
||||
require "modules.difficulty_vote"
|
||||
|
||||
local unearthing_biters = require "functions.unearthing_biters"
|
||||
|
||||
local event = require 'utils.event'
|
||||
local math_random = math.random
|
||||
|
||||
local difficulties_votes = {
|
||||
[1] = 11,
|
||||
[2] = 10,
|
||||
[3] = 9,
|
||||
[4] = 8,
|
||||
[5] = 7,
|
||||
[6] = 6,
|
||||
[7] = 5
|
||||
}
|
||||
|
||||
local difficulties_votes_evo = {
|
||||
[1] = 0.000016,
|
||||
[2] = 0.000024,
|
||||
[3] = 0.000032,
|
||||
[4] = 0.000040,
|
||||
[5] = 0.000048,
|
||||
[6] = 0.000056,
|
||||
[7] = 0.000064
|
||||
}
|
||||
|
||||
local starting_items = {
|
||||
["pistol"] = 1,
|
||||
["firearm-magazine"] = 8
|
||||
}
|
||||
|
||||
local function create_particles(surface, name, position, amount, cause_position)
|
||||
local math_random = math.random
|
||||
|
||||
local direction_mod = (-100 + math_random(0,200)) * 0.0004
|
||||
local direction_mod_2 = (-100 + math_random(0,200)) * 0.0004
|
||||
|
||||
if cause_position then
|
||||
direction_mod = (cause_position.x - position.x) * 0.021
|
||||
direction_mod_2 = (cause_position.y - position.y) * 0.021
|
||||
end
|
||||
|
||||
for i = 1, amount, 1 do
|
||||
local m = math_random(4, 10)
|
||||
local m2 = m * 0.005
|
||||
|
||||
surface.create_particle({
|
||||
name = name,
|
||||
position = position,
|
||||
frame_speed = 1,
|
||||
vertical_speed = 0.130,
|
||||
height = 0,
|
||||
movement = {
|
||||
(m2 - (math_random(0, m) * 0.01)) + direction_mod,
|
||||
(m2 - (math_random(0, m) * 0.01)) + direction_mod_2
|
||||
}
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local function spawn_market(surface, position)
|
||||
local market = surface.create_entity({name = "market", position = position, force = "neutral"})
|
||||
--market.destructible = false
|
||||
market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "wood", count = 50}})
|
||||
market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}})
|
||||
market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}})
|
||||
market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'stone', count = 50}})
|
||||
market.add_market_item({price = {{"coin", 3}}, offer = {type = 'give-item', item = 'coal', count = 50}})
|
||||
market.add_market_item({price = {{"coin", 5}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}})
|
||||
|
||||
market.add_market_item({price = {{'coin', 2}}, offer = {type = 'give-item', item = "raw-fish", count = 1}})
|
||||
market.add_market_item({price = {{'coin', 8}}, offer = {type = 'give-item', item = "grenade", count = 1}})
|
||||
market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "firearm-magazine", count = 1}})
|
||||
market.add_market_item({price = {{'coin', 16}}, offer = {type = 'give-item', item = "submachine-gun", count = 1}})
|
||||
market.add_market_item({price = {{'coin', 32}}, offer = {type = 'give-item', item = "car", count = 1}})
|
||||
return market
|
||||
end
|
||||
|
||||
local caption_style = {{"font", "default-bold"}, {"font_color",{ r=0.63, g=0.63, b=0.63}}, {"top_padding",2}, {"left_padding",0},{"right_padding",0},{"minimal_width",0}}
|
||||
local stat_number_style = {{"font", "default-bold"}, {"font_color",{ r=0.77, g=0.77, b=0.77}}, {"top_padding",2}, {"left_padding",0},{"right_padding",0},{"minimal_width",0}}
|
||||
local function tree_gui()
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if player.gui.top["trees_defeated"] then player.gui.top["trees_defeated"].destroy() end
|
||||
local b = player.gui.top.add { type = "button", caption = '[img=entity.tree-04] : ' .. global.trees_defeated, tooltip = "Trees defeated", name = "trees_defeated" }
|
||||
b.style.font = "heading-1"
|
||||
b.style.font_color = {r=0.00, g=0.33, b=0.00}
|
||||
b.style.minimal_height = 38
|
||||
end
|
||||
end
|
||||
|
||||
local function get_surface_settings()
|
||||
local map_gen_settings = {}
|
||||
map_gen_settings.seed = math_random(1, 1000000)
|
||||
map_gen_settings.water = math_random(15, 30) * 0.1
|
||||
map_gen_settings.starting_area = 1
|
||||
map_gen_settings.cliff_settings = {cliff_elevation_interval = math_random(4, 48), cliff_elevation_0 = math_random(4, 48)}
|
||||
map_gen_settings.autoplace_controls = {
|
||||
["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.5", size = "1.1", richness = "1"},
|
||||
["uranium-ore"] = {frequency = "2", size = "1", richness = "1"},
|
||||
["crude-oil"] = {frequency = "3", size = "1", richness = "1.5"},
|
||||
["trees"] = {frequency = "2", size = "1", richness = "0.75"},
|
||||
["enemy-base"] = {frequency = "4", size = "1.25", richness = "1"}
|
||||
}
|
||||
return map_gen_settings
|
||||
end
|
||||
|
||||
function reset_map()
|
||||
local rpg = rpg_t.get_table()
|
||||
global.trees_grow_chunk_next_visit = {}
|
||||
global.trees_grow_chunk_raffle = {}
|
||||
global.trees_grow_chunk_position = {}
|
||||
global.trees_grow_chunks_charted = {}
|
||||
global.trees_grow_chunks_charted_counter = 0
|
||||
|
||||
global.current_surface = Reset.soft_reset_map(global.current_surface, get_surface_settings(), starting_items)
|
||||
|
||||
reset_difficulty_poll()
|
||||
|
||||
global.trees_defeated = 0
|
||||
tree_gui()
|
||||
|
||||
global.market = spawn_market(global.current_surface, {x = 0, y = -8})
|
||||
|
||||
game.map_settings.enemy_evolution.time_factor = difficulties_votes_evo[4]
|
||||
|
||||
if rpg then rpg_t.rpg_reset_all_players() end
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if player.online_time == 0 then
|
||||
for item, amount in pairs(starting_items) do
|
||||
player.insert({name = item, count = amount})
|
||||
end
|
||||
end
|
||||
|
||||
if global.current_surface then
|
||||
if player.surface.name ~= global.current_surface.name then
|
||||
local pos = global.current_surface.find_non_colliding_position("character", {x = 0, y = 0}, 16, 0.5)
|
||||
player.teleport(pos, global.current_surface)
|
||||
end
|
||||
end
|
||||
|
||||
if not global.market and game.tick == 0 then
|
||||
global.current_surface = game.create_surface("overgrowth", get_surface_settings())
|
||||
game.forces["player"].set_spawn_position({x = 0, y = 0}, global.current_surface)
|
||||
player.teleport({0,0}, global.current_surface)
|
||||
reset_map()
|
||||
end
|
||||
|
||||
tree_gui()
|
||||
end
|
||||
|
||||
local function trap(entity)
|
||||
local r = 8
|
||||
if global.difficulty_vote_index then r = difficulties_votes[global.difficulty_vote_index] end
|
||||
if math_random(1,r) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
if entity.type ~= "tree" then return end
|
||||
|
||||
global.trees_defeated = global.trees_defeated + 1
|
||||
tree_gui()
|
||||
|
||||
trap(entity)
|
||||
|
||||
if event.player_index then
|
||||
create_particles(entity.surface, "wooden-particle", entity.position, 128, game.players[event.player_index].position)
|
||||
game.players[event.player_index].insert({name = "coin", count = 1})
|
||||
return
|
||||
end
|
||||
|
||||
create_particles(entity.surface, "wooden-particle", entity.position, 128)
|
||||
|
||||
if event.cause then
|
||||
if event.cause.force.name == "enemy" then return end
|
||||
end
|
||||
|
||||
entity.surface.spill_item_stack(entity.position,{name = "coin", count = 1}, true)
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
on_player_mined_entity(event)
|
||||
if event.entity == global.market then
|
||||
global.map_reset_timeout = game.tick + 900
|
||||
game.print("The market has been overrun.", {r = 1, g = 0, b = 0})
|
||||
kaboom(event.entity.surface, event.entity.position, "explosive-cannon-projectile", 24, 12)
|
||||
kaboom(event.entity.surface, event.entity.position, "explosive-uranium-cannon-projectile", 24, 12)
|
||||
global.market = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function attack_market()
|
||||
local c = 8
|
||||
if global.difficulty_vote_index then
|
||||
c = global.difficulty_vote_index * 2
|
||||
game.map_settings.enemy_evolution.time_factor = difficulties_votes_evo[global.difficulty_vote_index]
|
||||
end
|
||||
global.current_surface.set_multi_command({
|
||||
command={
|
||||
type=defines.command.attack,
|
||||
target=global.market,
|
||||
distraction=defines.distraction.by_enemy
|
||||
},
|
||||
unit_count = math_random(c, c * 2),
|
||||
force = "enemy",
|
||||
unit_search_distance=1024
|
||||
})
|
||||
global.current_surface.set_multi_command({
|
||||
command={
|
||||
type=defines.command.attack,
|
||||
target=global.market,
|
||||
distraction=defines.distraction.none
|
||||
},
|
||||
unit_count = math_random(1, c),
|
||||
force = "enemy",
|
||||
unit_search_distance=1024
|
||||
})
|
||||
end
|
||||
|
||||
local function tick()
|
||||
if global.market then
|
||||
if math_random(1, 60) == 1 then
|
||||
attack_market()
|
||||
end
|
||||
return
|
||||
end
|
||||
if not global.map_reset_timeout then return end
|
||||
if game.tick < global.map_reset_timeout then return end
|
||||
reset_map()
|
||||
global.map_reset_timeout = nil
|
||||
end
|
||||
|
||||
event.on_nth_tick(60, tick)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
Loading…
x
Reference in New Issue
Block a user