mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-03 13:12:11 +02:00
update
This commit is contained in:
parent
127547efb7
commit
d9c5468f1e
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.admins_operate_biters"
|
||||
--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"
|
||||
--require "utils.one_dimensional_noise"
|
||||
-----------------------------
|
||||
|
||||
---- enable maps here ---- (maps higher up in the list may be more actually playable)
|
||||
require "maps.chronosphere.main"
|
||||
--require "maps.fish_defender.main"
|
||||
--require "maps.biter_battles_v2.main"
|
||||
--require "maps.native_war.main"
|
||||
--require "maps.mountain_fortress_v2.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.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"
|
||||
------
|
||||
|
||||
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)
|
@ -3,13 +3,13 @@ local Public = {}
|
||||
local market = {}
|
||||
|
||||
market.weapons = {
|
||||
["pistol"] = {value = 10, rarity = 1},
|
||||
--["pistol"] = {value = 10, rarity = 1},
|
||||
["submachine-gun"] = {value = 50, rarity = 2},
|
||||
["shotgun"] = {value = 40, rarity = 2},
|
||||
["combat-shotgun"] = {value = 400, rarity = 5},
|
||||
["rocket-launcher"] = {value = 250, rarity = 4},
|
||||
["flamethrower"] = {value = 750, rarity = 6},
|
||||
["land-mine"] = {value = 3, rarity = 5},
|
||||
["land-mine"] = {value = 100, rarity = 5},
|
||||
}
|
||||
|
||||
market.ammo = {
|
||||
@ -67,7 +67,7 @@ market.equipment = {
|
||||
["night-vision-equipment"] = {value = 250, rarity = 1},
|
||||
}
|
||||
|
||||
market.defense = {
|
||||
market.defense = {
|
||||
["stone-wall"] = {value = 4, rarity = 1},
|
||||
["gate"] = {value = 8, rarity = 1},
|
||||
["repair-pack"] = {value = 8, rarity = 1},
|
||||
@ -154,13 +154,13 @@ end
|
||||
|
||||
local function get_resource_market_sells()
|
||||
local sells = {
|
||||
{price = {{"coin", math.random(5,10)}}, offer = {type = 'give-item', item = 'wood', count = 50}},
|
||||
{price = {{"coin", math.random(5,10)}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}},
|
||||
{price = {{"coin", math.random(5,10)}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}},
|
||||
{price = {{"coin", math.random(5,10)}}, offer = {type = 'give-item', item = 'stone', count = 50}},
|
||||
{price = {{"coin", math.random(5,10)}}, offer = {type = 'give-item', item = 'coal', count = 50}},
|
||||
{price = {{"coin", math.random(8,16)}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}},
|
||||
{price = {{"coin", math.random(2,4)}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}},
|
||||
{price = {{"coin", math.random(25,50)}}, offer = {type = 'give-item', item = 'wood', count = 50}},
|
||||
{price = {{"coin", math.random(40,80)}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}},
|
||||
{price = {{"coin", math.random(40,80)}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}},
|
||||
{price = {{"coin", math.random(40,80)}}, offer = {type = 'give-item', item = 'stone', count = 50}},
|
||||
{price = {{"coin", math.random(40,80)}}, offer = {type = 'give-item', item = 'coal', count = 50}},
|
||||
{price = {{"coin", math.random(60,120)}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}},
|
||||
{price = {{"coin", math.random(20,40)}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}},
|
||||
}
|
||||
table.shuffle_table(sells)
|
||||
return sells
|
||||
@ -174,14 +174,14 @@ local function get_resource_market_buys()
|
||||
{price = {{'stone', math.random(10,12)}}, offer = {type = 'give-item', item = "coin"}},
|
||||
{price = {{'coal', math.random(10,12)}}, offer = {type = 'give-item', item = "coin"}},
|
||||
{price = {{'uranium-ore', math.random(8,10)}}, offer = {type = 'give-item', item = "coin"}},
|
||||
{price = {{'water-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(1,2)}},
|
||||
{price = {{'lubricant-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(3,6)}},
|
||||
{price = {{'water-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(2,5)}},
|
||||
{price = {{'lubricant-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(5,10)}},
|
||||
{price = {{'sulfuric-acid-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(4,8)}},
|
||||
{price = {{'light-oil-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(2,4)}},
|
||||
{price = {{'heavy-oil-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(2,4)}},
|
||||
{price = {{'petroleum-gas-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(3,5)}},
|
||||
{price = {{'light-oil-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(5,10)}},
|
||||
{price = {{'heavy-oil-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(5,10)}},
|
||||
{price = {{'petroleum-gas-barrel', 1}}, offer = {type = 'give-item', item = "coin", count = math.random(4,8)}},
|
||||
}
|
||||
table.shuffle_table(buys)
|
||||
table.shuffle_table(buys)
|
||||
return buys
|
||||
end
|
||||
|
||||
@ -225,17 +225,17 @@ function Public.mountain_market(surface, position, rarity)
|
||||
if not items[i] then break end
|
||||
market.add_market_item(items[i])
|
||||
end
|
||||
|
||||
|
||||
local sells = get_resource_market_sells()
|
||||
for i = 1, math.random(1, 3), 1 do
|
||||
market.add_market_item(sells[i])
|
||||
end
|
||||
|
||||
|
||||
local buys = get_resource_market_buys()
|
||||
for i = 1, math.random(1, 3), 1 do
|
||||
market.add_market_item(buys[i])
|
||||
end
|
||||
|
||||
|
||||
return market
|
||||
end
|
||||
|
||||
@ -246,23 +246,23 @@ function Public.super_market(surface, position, rarity)
|
||||
local market = surface.create_entity({name = "market", position = position, force="neutral"})
|
||||
market.minable = false
|
||||
market.destructible = false
|
||||
|
||||
|
||||
for i = 1, math.random(6, 12), 1 do
|
||||
if not items[i] then break end
|
||||
market.add_market_item(items[i])
|
||||
end
|
||||
|
||||
|
||||
local sells = get_resource_market_sells()
|
||||
for i = 1, math.random(1, 3), 1 do
|
||||
market.add_market_item(sells[i])
|
||||
end
|
||||
|
||||
|
||||
local buys = get_resource_market_buys()
|
||||
for i = 1, math.random(1, 3), 1 do
|
||||
market.add_market_item(buys[i])
|
||||
end
|
||||
|
||||
|
||||
return market
|
||||
end
|
||||
|
||||
return Public
|
||||
return Public
|
||||
|
@ -36,6 +36,7 @@ function Public_chrono.restart_settings()
|
||||
objective.waterupgradetier = 0
|
||||
objective.outupgradetier = 0
|
||||
objective.boxupgradetier = 0
|
||||
objective.pistolupgradetier = 0
|
||||
objective.poisondefense = 2
|
||||
objective.poisontimeout = 0
|
||||
objective.chronotimer = 0
|
||||
|
@ -296,4 +296,21 @@ function Public_event.mining_buffs()
|
||||
end
|
||||
end
|
||||
|
||||
function Public_event.pistol_buffs(event)
|
||||
if global.objective.pistolupgradetier == 0 then return end
|
||||
if not event.cause then return end
|
||||
if event.cause.name ~= "player" then return end
|
||||
if event.damage_type.name ~= "physical" then return end
|
||||
local player = event.cause
|
||||
if player.shooting_state.state == defines.shooting.not_shooting then return end
|
||||
local weapon = event.cause.get_inventory(defines.inventory.character_guns)[event.cause.selected_gun_index].name
|
||||
local ammo = event.cause.get_inventory(defines.inventory.character_ammo)[event.cause.selected_gun_index].name
|
||||
game.print(ammo)
|
||||
game.print(wapon)
|
||||
if weapon ~= "pistol" then return end
|
||||
if ammo ~= "firearm-magazine" and ammo ~= "piercing-rounds-magazine" and ammo ~= "uranium-rounds-magazine" then return end
|
||||
event.entity.damage(event.final_damage_amount * 4, player.force, "physical", player)
|
||||
end
|
||||
|
||||
|
||||
return Public_event
|
||||
|
@ -348,9 +348,9 @@ local function on_init()
|
||||
--if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end
|
||||
end
|
||||
|
||||
local function on_load()
|
||||
Chrono.init_setup()
|
||||
end
|
||||
-- local function on_load()
|
||||
-- Chrono.init_setup()
|
||||
-- end
|
||||
|
||||
local function protect_entity(event)
|
||||
if event.entity.force.index ~= 1 then return end --Player Force
|
||||
@ -378,6 +378,7 @@ local function on_entity_damaged(event)
|
||||
Event_functions.biters_chew_rocks_faster(event)
|
||||
if event.entity.force.name == "enemy" then
|
||||
Event_functions.biter_immunities(event)
|
||||
Event_functions.pistol_buffs(event)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -34,22 +34,22 @@ local function get_collapse_vectors(radius, seed)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local sorted_vectors = {}
|
||||
for _, vector in pairs(vectors) do
|
||||
local index = math_floor(math_sqrt(vector[1] ^ 2 + vector[2] ^ 2)) + 1
|
||||
if not sorted_vectors[index] then sorted_vectors[index] = {} end
|
||||
sorted_vectors[index][#sorted_vectors[index] + 1] = vector
|
||||
sorted_vectors[index][#sorted_vectors[index] + 1] = vector
|
||||
end
|
||||
|
||||
local final_list = {}
|
||||
|
||||
local final_list = {}
|
||||
for _, row in pairs(sorted_vectors) do
|
||||
table_shuffle_table(row)
|
||||
for _, tile in pairs(row) do
|
||||
table_insert(final_list, tile)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return final_list
|
||||
end
|
||||
|
||||
@ -61,7 +61,7 @@ local function set_y(surface)
|
||||
for _ = 1, 16, 1 do
|
||||
local area = {{x_left, map_collapse.last_position.y},{x_right, map_collapse.last_position.y + 1}}
|
||||
if surface.count_tiles_filtered({name = "out-of-map", area = area}) < level_width then
|
||||
return area
|
||||
return area
|
||||
end
|
||||
map_collapse.last_position.y = map_collapse.last_position.y - 1
|
||||
end
|
||||
@ -73,7 +73,7 @@ local function set_positions(surface)
|
||||
|
||||
local map_collapse = global.map_collapse
|
||||
map_collapse.positions = {}
|
||||
|
||||
|
||||
local i = 1
|
||||
for _, tile in pairs(surface.find_tiles_filtered({area = area})) do
|
||||
if tile.valid then
|
||||
@ -83,7 +83,7 @@ local function set_positions(surface)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if i == 1 then
|
||||
map_collapse.positions = nil
|
||||
return
|
||||
@ -96,7 +96,16 @@ local function set_collapse_tiles(surface, position, vectors)
|
||||
map_collapse.processing = {}
|
||||
local i = 1
|
||||
for _, vector in pairs(vectors) do
|
||||
local shifted_position = {x = position[1] + vector[1], y = position[2] + vector[2] - 60}
|
||||
local position = {x = position[1] + vector[1], y = position[2] + vector[2]}
|
||||
local rocks = surface.find_entities_filtered{position = shifted_position, radius = 2, type = {"simple-entity", "tree"}}
|
||||
if #rocks > 0 then
|
||||
for i = 1, #rocks, 1 do
|
||||
if rocks[i].valid then
|
||||
rocks[i].destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
local tile = surface.get_tile(position)
|
||||
if tile.valid and tile.name ~= "out-of-map" then
|
||||
map_collapse.processing[i] = tile
|
||||
@ -109,21 +118,21 @@ end
|
||||
|
||||
local function clean_positions(tbl)
|
||||
for k, tile in pairs(tbl) do
|
||||
if not tile.valid then
|
||||
if not tile.valid then
|
||||
table_remove(tbl, k)
|
||||
else
|
||||
if tile.name == "out-of-map" then
|
||||
if tile.name == "out-of-map" then
|
||||
table_remove(tbl, k)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function setup_next_collapse()
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
local map_collapse = global.map_collapse
|
||||
local map_collapse = global.map_collapse
|
||||
if not map_collapse.vector_list then
|
||||
map_collapse.vector_list = {}
|
||||
map_collapse.vector_list = {}
|
||||
for _ = 1, size_of_vector_list, 1 do
|
||||
table_insert(global.map_collapse.vector_list, get_collapse_vectors(math_random(24, 48), math_random(1, 9999999)))
|
||||
end
|
||||
@ -141,10 +150,10 @@ local function setup_next_collapse()
|
||||
if tile.name == "out-of-map" then clean_positions(map_collapse.positions) return end
|
||||
|
||||
local position = {tile.position.x, tile.position.y}
|
||||
|
||||
|
||||
local vectors = map_collapse.vector_list[math_random(1, size_of_vector_list)]
|
||||
set_collapse_tiles(surface, position, vectors)
|
||||
|
||||
|
||||
local last_position = global.map_collapse.last_position
|
||||
game.forces.player.chart(surface, {{last_position.x - chart_radius, last_position.y - chart_radius},{last_position.x + chart_radius, last_position.y + chart_radius}})
|
||||
global.map_collapse.last_position = {x = position[1], y = position[2]}
|
||||
@ -164,11 +173,11 @@ end
|
||||
local function process_tile(surface, tile, tiles_to_set)
|
||||
if not tile then return end
|
||||
if not tile.valid then return end
|
||||
|
||||
local conversion_tile = tile_conversion[tile.name]
|
||||
|
||||
local conversion_tile = tile_conversion[tile.name]
|
||||
if conversion_tile then
|
||||
table_insert(tiles_to_set, {name = conversion_tile, position = tile.position})
|
||||
surface.create_trivial_smoke({name="train-smoke", position = tile.position})
|
||||
surface.create_trivial_smoke({name="train-smoke", position = tile.position})
|
||||
else
|
||||
table_insert(tiles_to_set, {name = "out-of-map", position = tile.position})
|
||||
end
|
||||
@ -179,12 +188,12 @@ end
|
||||
function Public.process()
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
local map_collapse = global.map_collapse
|
||||
|
||||
|
||||
if map_collapse.processing_index >= map_collapse.size_of_processing then
|
||||
setup_next_collapse()
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local count = 0
|
||||
local tiles_to_set = {}
|
||||
for i = map_collapse.processing_index, map_collapse.size_of_processing, 1 do
|
||||
@ -194,7 +203,7 @@ function Public.process()
|
||||
end
|
||||
map_collapse.processing_index = map_collapse.processing_index + 1
|
||||
end
|
||||
|
||||
|
||||
if count > 1 then surface.set_tiles(tiles_to_set, true) end
|
||||
end
|
||||
|
||||
@ -204,11 +213,11 @@ function Public.init()
|
||||
["size_of_processing"] = 0,
|
||||
["processing"] = {},
|
||||
["last_position"] = {x = 0, y = 128},
|
||||
["speed"] = 2,
|
||||
["speed"] = 3,
|
||||
}
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.on_init(Public.init())
|
||||
|
||||
return Public
|
||||
return Public
|
||||
|
@ -4,17 +4,17 @@ local function on_research_finished(event)
|
||||
local force_name = research.force.name
|
||||
if research.name == "military" then
|
||||
if not global.flamethrower_damage then global.flamethrower_damage = {} end
|
||||
global.flamethrower_damage[force_name] = -0.50
|
||||
global.flamethrower_damage[force_name] = -0.75
|
||||
game.forces[force_name].set_turret_attack_modifier("flamethrower-turret", global.flamethrower_damage[force_name])
|
||||
game.forces[force_name].set_ammo_damage_modifier("flamethrower", global.flamethrower_damage[force_name])
|
||||
game.forces[force_name].set_ammo_damage_modifier("flamethrower", global.flamethrower_damage[force_name])
|
||||
end
|
||||
|
||||
|
||||
if string.sub(research.name, 0, 18) == "refined-flammables" then
|
||||
global.flamethrower_damage[force_name] = global.flamethrower_damage[force_name] + 0.10
|
||||
game.forces[force_name].set_turret_attack_modifier("flamethrower-turret", global.flamethrower_damage[force_name])
|
||||
game.forces[force_name].set_turret_attack_modifier("flamethrower-turret", global.flamethrower_damage[force_name])
|
||||
game.forces[force_name].set_ammo_damage_modifier("flamethrower", global.flamethrower_damage[force_name])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_research_finished, on_research_finished)
|
||||
event.add(defines.events.on_research_finished, on_research_finished)
|
||||
|
@ -6,22 +6,22 @@ function Public.locomotive_spawn(surface, position)
|
||||
end
|
||||
global.locomotive = surface.create_entity({name = "locomotive", position = {position.x, position.y + -3}, force = "player"})
|
||||
global.locomotive.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 100})
|
||||
|
||||
|
||||
global.locomotive_cargo = surface.create_entity({name = "cargo-wagon", position = {position.x, position.y + 3}, force = "player"})
|
||||
global.locomotive_cargo.get_inventory(defines.inventory.cargo_wagon).insert({name = "raw-fish", count = 1})
|
||||
|
||||
|
||||
rendering.draw_light({
|
||||
sprite = "utility/light_medium", scale = 5.5, intensity = 1, minimum_darkness = 0,
|
||||
oriented = true, color = {255,255,255}, target = global.locomotive,
|
||||
surface = surface, visible = true, only_in_alt_mode = false,
|
||||
})
|
||||
|
||||
|
||||
rendering.draw_light({
|
||||
sprite = "utility/light_medium", scale = 5.5, intensity = 1, minimum_darkness = 0,
|
||||
oriented = true, color = {255,255,255}, target = global.locomotive_cargo,
|
||||
surface = surface, visible = true, only_in_alt_mode = false,
|
||||
})
|
||||
|
||||
|
||||
global.locomotive.color = {0, 255, 0}
|
||||
global.locomotive.minable = false
|
||||
global.locomotive_cargo.minable = false
|
||||
@ -37,7 +37,7 @@ function Public.fish_tag()
|
||||
if global.locomotive_tag then
|
||||
if global.locomotive_tag.valid then
|
||||
if global.locomotive_tag.position.x == global.locomotive_cargo.position.x and global.locomotive_tag.position.y == global.locomotive_cargo.position.y then return end
|
||||
global.locomotive_tag.destroy()
|
||||
global.locomotive_tag.destroy()
|
||||
end
|
||||
end
|
||||
global.locomotive_tag = global.locomotive_cargo.force.add_chart_tag(
|
||||
@ -51,7 +51,7 @@ end
|
||||
local function accelerate()
|
||||
if not global.locomotive then return end
|
||||
if not global.locomotive.valid then return end
|
||||
if global.locomotive.get_driver() then return end
|
||||
if global.locomotive.get_driver() then return end
|
||||
global.locomotive_driver = global.locomotive.surface.create_entity({name = "character", position = global.locomotive.position, force = "player"})
|
||||
global.locomotive_driver.driving = true
|
||||
global.locomotive_driver.riding_state = {acceleration = defines.riding.acceleration.accelerating, direction = defines.riding.direction.straight}
|
||||
@ -66,14 +66,14 @@ end
|
||||
]]
|
||||
|
||||
local market_offers = {
|
||||
{price = {{'coin', 5}}, offer = {type = 'give-item', item = "raw-fish"}},
|
||||
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'wood', count = 50}},
|
||||
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}},
|
||||
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}},
|
||||
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'stone', count = 50}},
|
||||
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'coal', count = 50}},
|
||||
{price = {{"coin", 16}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}},
|
||||
{price = {{"coin", 5}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}},
|
||||
{price = {{'coin', 25}}, offer = {type = 'give-item', item = "raw-fish"}},
|
||||
{price = {{"coin", 50}}, offer = {type = 'give-item', item = 'wood', count = 50}},
|
||||
{price = {{"coin", 50}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}},
|
||||
{price = {{"coin", 50}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}},
|
||||
{price = {{"coin", 50}}, offer = {type = 'give-item', item = 'stone', count = 50}},
|
||||
{price = {{"coin", 50}}, offer = {type = 'give-item', item = 'coal', count = 50}},
|
||||
{price = {{"coin", 80}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}},
|
||||
{price = {{"coin", 25}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 1}},
|
||||
}
|
||||
|
||||
local function create_wagon_room()
|
||||
@ -97,7 +97,7 @@ local function create_wagon_room()
|
||||
surface.daytime = 0.1
|
||||
surface.request_to_generate_chunks({0,0}, 1)
|
||||
surface.force_generate_chunk_requests()
|
||||
|
||||
|
||||
for x = width * -0.5 + 1, width * 0.5, 1 do
|
||||
for y = height * -0.5, height * 0.5, 1 do
|
||||
surface.set_tiles({{name = "tutorial-grid", position = {x,y}}})
|
||||
@ -127,11 +127,11 @@ local function create_wagon_room()
|
||||
e.minable = false
|
||||
e.operable = false
|
||||
end
|
||||
|
||||
|
||||
local e = surface.create_entity({name = "big-biter", position = {width * -0.5 + 2, height * -0.5 + 2}, force = "player", create_build_effect_smoke = false})
|
||||
e.ai_settings.allow_destroy_when_commands_fail = false
|
||||
e.ai_settings.allow_try_return_to_spawner = false
|
||||
|
||||
|
||||
local positions = {}
|
||||
for x = width * -0.5 + 2, width * 0.5 - 1, 1 do
|
||||
for y = 4, height * 0.5 - 1, 1 do
|
||||
@ -139,7 +139,7 @@ local function create_wagon_room()
|
||||
end
|
||||
end
|
||||
table.shuffle_table(positions)
|
||||
|
||||
|
||||
local cargo_boxes = {
|
||||
{name = "grenade", count = math.random(2, 3)},
|
||||
{name = "submachine-gun", count = 1},
|
||||
@ -155,8 +155,8 @@ local function create_wagon_room()
|
||||
{name = "rail", count = math.random(16, 24)},
|
||||
{name = "rail", count = math.random(16, 24)},
|
||||
{name = "rail", count = math.random(16, 24)},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
local i = 1
|
||||
for _ = 1, 10, 1 do
|
||||
if not positions[i] then break end
|
||||
@ -165,13 +165,13 @@ local function create_wagon_room()
|
||||
inventory.insert({name = "raw-fish", count = math.random(2, 5)})
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
|
||||
for _ = 1, 24, 1 do
|
||||
if not positions[i] then break end
|
||||
local e = surface.create_entity({name = "wooden-chest", position = positions[i], force="player", create_build_effect_smoke = false})
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
|
||||
for loot_i = 1, #cargo_boxes, 1 do
|
||||
if not positions[i] then break end
|
||||
local e = surface.create_entity({name = "wooden-chest", position = positions[i], force="player", create_build_effect_smoke = false})
|
||||
@ -218,4 +218,4 @@ function Public.enter_cargo_wagon(player, vehicle)
|
||||
end
|
||||
end
|
||||
|
||||
return Public
|
||||
return Public
|
||||
|
@ -1,8 +1,9 @@
|
||||
-- Mountain digger fortress, protect the cargo wagon! -- by MewMew
|
||||
|
||||
--enable / disable collapsing of the map
|
||||
local collapse_enabled = false
|
||||
local darkness = true
|
||||
global.collapse_enabled = true
|
||||
global.offline_loot = true
|
||||
local darkness = false
|
||||
|
||||
require "player_modifiers"
|
||||
require "functions.soft_reset"
|
||||
@ -49,21 +50,25 @@ local function set_difficulty()
|
||||
|
||||
-- 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()
|
||||
for _,player in pairs(game.players) do
|
||||
if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end
|
||||
end
|
||||
local wave_defense_table = WD.get_table()
|
||||
global.chunk_queue = {}
|
||||
|
||||
global.offline_players = {}
|
||||
|
||||
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,
|
||||
@ -77,14 +82,14 @@ function Public.reset_map()
|
||||
["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])
|
||||
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
|
||||
@ -97,15 +102,15 @@ function Public.reset_map()
|
||||
|
||||
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.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.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
|
||||
@ -113,24 +118,27 @@ function Public.reset_map()
|
||||
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["land-mine"].enabled = false
|
||||
game.forces.player.technologies["landfill"].enabled = false
|
||||
game.forces.player.technologies["railway"].researched = true
|
||||
game.forces.player.recipes["pistol"].enabled = false
|
||||
game.forces.player.set_spawn_position({-2, 16}, surface)
|
||||
|
||||
game.forces.enemy.set_ammo_damage_modifier("bullet", 1)
|
||||
game.forces.enemy.set_turret_attack_modifier("gun-turret", 1)
|
||||
|
||||
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
|
||||
|
||||
@ -151,25 +159,25 @@ local function biters_chew_rocks_faster(event)
|
||||
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
|
||||
event.entity.health = event.entity.health - event.final_damage_amount * 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)
|
||||
|
||||
|
||||
BiterRolls.wave_defense_set_unit_raffle(d * 0.20)
|
||||
|
||||
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
|
||||
|
||||
if math_random(1, 64) == 1 then
|
||||
BiterHealthBooster.add_boss_unit(unit, m * 15 + 1, 0.38)
|
||||
else
|
||||
BiterHealthBooster.add_unit(unit, m * 2.5 + 1)
|
||||
@ -177,8 +185,8 @@ local function hidden_biter(entity)
|
||||
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})
|
||||
BiterRolls.wave_defense_set_worm_raffle(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.20)
|
||||
entity.surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = entity.position})
|
||||
end
|
||||
|
||||
local function hidden_biter_pet(event)
|
||||
@ -200,29 +208,29 @@ local function hidden_treasure(event)
|
||||
end
|
||||
|
||||
local projectiles = {"grenade", "explosive-rocket", "grenade", "explosive-rocket", "explosive-cannon-projectile"}
|
||||
local function angry_tree(entity, cause)
|
||||
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 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,
|
||||
max_range = 64,
|
||||
speed = 0.10
|
||||
})
|
||||
})
|
||||
end
|
||||
|
||||
local function give_coin(player)
|
||||
@ -230,12 +238,12 @@ local function give_coin(player)
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
if not event.entity.valid then return end
|
||||
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
|
||||
@ -245,17 +253,25 @@ local function on_player_mined_entity(event)
|
||||
return
|
||||
end
|
||||
hidden_biter_pet(event)
|
||||
hidden_treasure(event)
|
||||
hidden_treasure(event)
|
||||
end
|
||||
|
||||
|
||||
angry_tree(event.entity, game.players[event.player_index].character)
|
||||
end
|
||||
|
||||
local function on_pre_player_left_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end
|
||||
if player.character then
|
||||
global.offline_players[#global.offline_players + 1] = {index = event.player_index, tick = game.tick}
|
||||
end
|
||||
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!")
|
||||
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
|
||||
@ -268,27 +284,27 @@ local function on_entity_died(event)
|
||||
|
||||
if event.cause then
|
||||
if event.cause.valid then
|
||||
if event.cause.force.index == 2 or event.cause.force.index == 3 then return end
|
||||
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)
|
||||
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
|
||||
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)
|
||||
@ -306,29 +322,29 @@ local function on_player_joined_game(event)
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
@ -341,21 +357,89 @@ local function on_player_left_game(event)
|
||||
set_difficulty()
|
||||
end
|
||||
|
||||
local function offline_players()
|
||||
local current_tick = game.tick
|
||||
local players = global.offline_players
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
if #players > 0 then
|
||||
--log("nonzero offline players")
|
||||
local later = {}
|
||||
for i = 1, #players, 1 do
|
||||
if players[i] and game.players[players[i].index] and game.players[players[i].index].connected then
|
||||
--game.print("deleting already online character from list")
|
||||
players[i] = nil
|
||||
else
|
||||
if players[i] and players[i].tick < game.tick - 54000 then
|
||||
--log("spawning corpse")
|
||||
local player_inv = {}
|
||||
local items = {}
|
||||
player_inv[1] = game.players[players[i].index].get_inventory(defines.inventory.character_main)
|
||||
player_inv[2] = game.players[players[i].index].get_inventory(defines.inventory.character_armor)
|
||||
player_inv[3] = game.players[players[i].index].get_inventory(defines.inventory.character_guns)
|
||||
player_inv[4] = game.players[players[i].index].get_inventory(defines.inventory.character_ammo)
|
||||
player_inv[5] = game.players[players[i].index].get_inventory(defines.inventory.character_trash)
|
||||
local e = surface.create_entity({name = "character", position = game.forces.player.get_spawn_position(surface), force = "neutral"})
|
||||
local inv = e.get_inventory(defines.inventory.character_main)
|
||||
for ii = 1, 5, 1 do
|
||||
if player_inv[ii].valid then
|
||||
for iii = 1, #player_inv[ii], 1 do
|
||||
if player_inv[ii][iii].valid then
|
||||
items[#items + 1] = player_inv[ii][iii]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if #items > 0 then
|
||||
for item = 1, #items, 1 do
|
||||
if items[item].valid then
|
||||
inv.insert(items[item])
|
||||
end
|
||||
end
|
||||
game.print({"chronosphere.message_accident"}, {r=0.98, g=0.66, b=0.22})
|
||||
e.die("neutral")
|
||||
else
|
||||
e.destroy()
|
||||
end
|
||||
|
||||
for ii = 1, 5, 1 do
|
||||
if player_inv[ii].valid then
|
||||
player_inv[ii].clear()
|
||||
end
|
||||
end
|
||||
players[i] = nil
|
||||
else
|
||||
later[#later + 1] = players[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
players = {}
|
||||
if #later > 0 then
|
||||
for i = 1, #later, 1 do
|
||||
players[#players + 1] = later[i]
|
||||
end
|
||||
end
|
||||
global.offline_players = players
|
||||
end
|
||||
end
|
||||
|
||||
local function tick()
|
||||
local tick = game.tick
|
||||
if tick % 30 == 0 then
|
||||
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
|
||||
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
|
||||
-- if tick % 216000 == 0 then
|
||||
-- Collapse.delete_out_of_map_chunks(surface)
|
||||
-- end
|
||||
if global.offline_loot then
|
||||
offline_players()
|
||||
end
|
||||
end
|
||||
if global.game_reset_tick then
|
||||
if global.game_reset_tick < tick then
|
||||
@ -366,7 +450,7 @@ local function tick()
|
||||
end
|
||||
Locomotive.fish_tag()
|
||||
end
|
||||
if not collapse_enabled then return end
|
||||
if not global.collapse_enabled then return end
|
||||
Collapse.process()
|
||||
end
|
||||
|
||||
@ -378,16 +462,16 @@ local function on_init()
|
||||
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,
|
||||
["water-shallow"] = 1000,
|
||||
}
|
||||
|
||||
|
||||
Public.reset_map()
|
||||
end
|
||||
|
||||
@ -404,10 +488,11 @@ 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_pre_player_left_game, on_pre_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
|
||||
return Public
|
||||
|
@ -11,7 +11,7 @@ local spawner_raffle = {"biter-spawner", "biter-spawner", "biter-spawner", "spit
|
||||
local noises = {
|
||||
["no_rocks"] = {{modifier = 0.0033, weight = 1}, {modifier = 0.01, weight = 0.22}, {modifier = 0.05, weight = 0.05}, {modifier = 0.1, weight = 0.04}},
|
||||
["no_rocks_2"] = {{modifier = 0.013, weight = 1}, {modifier = 0.1, weight = 0.1}},
|
||||
["large_caves"] = {{modifier = 0.0033, weight = 1}, {modifier = 0.01, weight = 0.22}, {modifier = 0.05, weight = 0.05}, {modifier = 0.1, weight = 0.04}},
|
||||
["large_caves"] = {{modifier = 0.0033, weight = 1}, {modifier = 0.01, weight = 0.22}, {modifier = 0.05, weight = 0.05}, {modifier = 0.1, weight = 0.04}},
|
||||
["small_caves"] = {{modifier = 0.008, weight = 1}, {modifier = 0.03, weight = 0.15}, {modifier = 0.25, weight = 0.05}},
|
||||
["small_caves_2"] = {{modifier = 0.009, weight = 1}, {modifier = 0.05, weight = 0.25}, {modifier = 0.25, weight = 0.05}},
|
||||
["cave_ponds"] = {{modifier = 0.01, weight = 1}, {modifier = 0.1, weight = 0.06}},
|
||||
@ -21,7 +21,7 @@ local noises = {
|
||||
["cave_rivers_4"] = {{modifier = 0.001, weight = 1}, {modifier = 0.01, weight = 0.11}, {modifier = 0.05, weight = 0.01}},
|
||||
["scrapyard"] = {{modifier = 0.005, weight = 1}, {modifier = 0.01, weight = 0.35}, {modifier = 0.05, weight = 0.23}, {modifier = 0.1, weight = 0.11}},
|
||||
}
|
||||
local level_depth = 960
|
||||
local level_depth = 704
|
||||
local worm_level_modifier = 0.18
|
||||
|
||||
local function get_noise(name, pos, seed)
|
||||
@ -52,7 +52,7 @@ local function get_oil_amount(p)
|
||||
return (math_abs(p.y) * 200 + 10000) * math_random(75, 125) * 0.01
|
||||
end
|
||||
|
||||
local function process_level_10_position(p, seed, tiles, entities, markets, treasure)
|
||||
local function process_level_11_position(p, seed, tiles, entities, markets, treasure)
|
||||
local noise_1 = get_noise("small_caves", p, seed)
|
||||
local noise_2 = get_noise("no_rocks_2", p, seed + 10000)
|
||||
|
||||
@ -61,17 +61,17 @@ local function process_level_10_position(p, seed, tiles, entities, markets, trea
|
||||
if math_random(1,48) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if noise_1 < -0.72 then
|
||||
tiles[#tiles + 1] = {name = "lab-dark-1", position = p}
|
||||
entities[#entities + 1] = {name = "uranium-ore", position = p, amount = math_abs(p.y) + 1 * 3}
|
||||
return
|
||||
end
|
||||
|
||||
if noise_1 > -0.30 and noise_1 < 0.30 then
|
||||
if noise_1 > -0.30 and noise_1 < 0.30 then
|
||||
if noise_1 > -0.14 and noise_1 < 0.14 then
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,10) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,256) == 1 then treasure[#treasure + 1] = p end
|
||||
else
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
@ -79,36 +79,77 @@ local function process_level_10_position(p, seed, tiles, entities, markets, trea
|
||||
return
|
||||
end
|
||||
|
||||
if math_random(1,64) == 1 and noise_2 > 0.65 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end
|
||||
if math_random(1,64) == 1 and noise_2 > 0.65 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end
|
||||
if math_random(1,8192) == 1 then markets[#markets + 1] = p end
|
||||
if math_random(1,1024) == 1 then entities[#entities + 1] = {name = "crash-site-chest-" .. math_random(1,2), position = p, force = "neutral"} end
|
||||
|
||||
|
||||
tiles[#tiles + 1] = {name = "tutorial-grid", position = p}
|
||||
end
|
||||
|
||||
local function process_level_10_position(p, seed, tiles, entities, markets, treasure)
|
||||
local scrapyard = get_noise("scrapyard", p, seed)
|
||||
|
||||
if scrapyard < -0.70 or scrapyard > 0.70 then
|
||||
tiles[#tiles + 1] = {name = "grass-3", position = p}
|
||||
if math_random(1,40) == 1 then treasure[#treasure + 1] = p end
|
||||
return
|
||||
end
|
||||
|
||||
if scrapyard < -0.65 or scrapyard > 0.65 then
|
||||
tiles[#tiles + 1] = {name = "water-green", position = p}
|
||||
return
|
||||
end
|
||||
if math_abs(scrapyard) > 0.40 and math_abs(scrapyard) < 0.65 then
|
||||
if math_random(1,64) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
tiles[#tiles + 1] = {name = "water-mud", position = p}
|
||||
return
|
||||
end
|
||||
if math_abs(scrapyard) > 0.25 and math_abs(scrapyard) < 0.40 then
|
||||
if math_random(1,128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
tiles[#tiles + 1] = {name = "water-shallow", position = p}
|
||||
return
|
||||
end
|
||||
if scrapyard > -0.15 and scrapyard < 0.15 then
|
||||
if math_random(1,100) > 88 then
|
||||
entities[#entities + 1] = {name = "tree-0" .. math_random(1,9), position = p}
|
||||
else
|
||||
if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
end
|
||||
tiles[#tiles + 1] = {name = "dirt-6", position = p}
|
||||
return
|
||||
end
|
||||
tiles[#tiles + 1] = {name = "grass-2", position = p}
|
||||
end
|
||||
|
||||
local function process_level_9_position(p, seed, tiles, entities, markets, treasure)
|
||||
local maze_p = {x = math_floor(p.x - p.x % 10), y = math_floor(p.y - p.y % 10)}
|
||||
local maze_noise = get_noise("no_rocks_2", maze_p, seed)
|
||||
|
||||
|
||||
if maze_noise > -0.35 and maze_noise < 0.35 then
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
local no_rocks_2 = get_noise("no_rocks_2", p, seed)
|
||||
if math_random(1,4) > 1 and no_rocks_2 > -0.5 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,3) == 1 and no_rocks_2 > -0.5 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,1024) == 1 then treasure[#treasure + 1] = p end
|
||||
if math_random(1,256) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if maze_noise > 0 and maze_noise < 0.45 then
|
||||
if math_random(1,512) == 1 then markets[#markets + 1] = p end
|
||||
if math_random(1,256) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end
|
||||
if math_random(1,32) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end
|
||||
if math_random(1,32) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if maze_noise < -0.5 or maze_noise > 0.5 then
|
||||
tiles[#tiles + 1] = {name = "deepwater", position = p}
|
||||
if math_random(1,96) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
@ -127,7 +168,7 @@ local scrap_entities_index = #scrap_entities
|
||||
--SCRAPYARD
|
||||
local function process_level_8_position(p, seed, tiles, entities, markets, treasure)
|
||||
local scrapyard = get_noise("scrapyard", p, seed)
|
||||
|
||||
|
||||
--Chasms
|
||||
local noise_cave_ponds = get_noise("cave_ponds", p, seed)
|
||||
local small_caves = get_noise("small_caves", p, seed)
|
||||
@ -141,100 +182,100 @@ local function process_level_8_position(p, seed, tiles, entities, markets, treas
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if scrapyard < -0.25 or scrapyard > 0.25 then
|
||||
if math_random(1, 256) == 1 then
|
||||
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 math_random(1,5) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
return
|
||||
end
|
||||
if scrapyard < -0.28 or scrapyard > 0.28 then
|
||||
if math_random(1,128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), 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,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
|
||||
return
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local cave_ponds = get_noise("cave_ponds", p, seed)
|
||||
if cave_ponds < -0.6 and scrapyard > -0.2 and scrapyard < 0.2 then
|
||||
tiles[#tiles + 1] = {name = "deepwater-green", position = p}
|
||||
if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
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 < 3 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, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if math_random(1,64) == 1 and cave_ponds > 0.6 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end
|
||||
|
||||
|
||||
tiles[#tiles + 1] = {name = "stone-path", position = p}
|
||||
end
|
||||
|
||||
local function process_level_7_position(p, seed, tiles, entities, markets, treasure)
|
||||
local cave_rivers_3 = get_noise("cave_rivers_3", p, seed)
|
||||
local cave_rivers_4 = get_noise("cave_rivers_4", p, seed + 50000)
|
||||
local cave_rivers_4 = get_noise("cave_rivers_4", p, seed + 50000)
|
||||
local no_rocks_2 = get_noise("no_rocks_2", p, seed)
|
||||
|
||||
|
||||
if cave_rivers_3 > -0.025 and cave_rivers_3 < 0.025 and no_rocks_2 > -0.6 then
|
||||
tiles[#tiles + 1] = {name = "water", position = p}
|
||||
if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if cave_rivers_4 > -0.025 and cave_rivers_4 < 0.025 and no_rocks_2 > -0.6 then
|
||||
tiles[#tiles + 1] = {name = "water", position = p}
|
||||
if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local noise_ores = get_noise("no_rocks_2", p, seed + 25000)
|
||||
|
||||
|
||||
if cave_rivers_3 > -0.20 and cave_rivers_3 < 0.20 then
|
||||
tiles[#tiles + 1] = {name = "grass-" .. math_floor(cave_rivers_3 * 32) % 3 + 1, position = p}
|
||||
tiles[#tiles + 1] = {name = "grass-" .. math_floor(cave_rivers_3 * 32) % 3 + 1, position = p}
|
||||
if cave_rivers_3 > -0.10 and cave_rivers_3 < 0.10 then
|
||||
if math_random(1,12) == 1 and no_rocks_2 > -0.25 then entities[#entities + 1] = {name = "tree-01", position=p} end
|
||||
if math_random(1,8) == 1 and no_rocks_2 > -0.25 then entities[#entities + 1] = {name = "tree-01", position=p} end
|
||||
if math_random(1,2048) == 1 then markets[#markets + 1] = p end
|
||||
if noise_ores < -0.5 and no_rocks_2 > -0.6 then
|
||||
if cave_rivers_3 > 0 and cave_rivers_3 < 0.07 then
|
||||
entities[#entities + 1] = {name = "iron-ore", position=p, amount = math_abs(p.y) + 1}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if math_random(1,64) == 1 and no_rocks_2 > 0.7 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end
|
||||
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if cave_rivers_4 > -0.20 and cave_rivers_4 < 0.20 then
|
||||
tiles[#tiles + 1] = {name = "grass-" .. math_floor(cave_rivers_4 * 32) % 3 + 1, position = p}
|
||||
if cave_rivers_4 > -0.10 and cave_rivers_4 < 0.10 then
|
||||
if math_random(1,12) == 1 and no_rocks_2 > -0.25 then entities[#entities + 1] = {name = "tree-02", position=p} end
|
||||
if math_random(1,8) == 1 and no_rocks_2 > -0.25 then entities[#entities + 1] = {name = "tree-02", position=p} end
|
||||
if math_random(1,2048) == 1 then markets[#markets + 1] = p end
|
||||
if noise_ores < -0.5 and no_rocks_2 > -0.6 then
|
||||
if cave_rivers_4 > 0 and cave_rivers_4 < 0.07 then
|
||||
entities[#entities + 1] = {name = "copper-ore", position=p, amount = math_abs(p.y) + 1}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if math_random(1,64) == 1 and no_rocks_2 > 0.7 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end
|
||||
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--Chasms
|
||||
local noise_cave_ponds = get_noise("cave_ponds", p, seed)
|
||||
local small_caves = get_noise("small_caves", p, seed)
|
||||
@ -247,17 +288,17 @@ local function process_level_7_position(p, seed, tiles, entities, markets, treas
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,5) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,256) == 1 then treasure[#treasure + 1] = p end
|
||||
end
|
||||
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,256) == 1 then treasure[#treasure + 1] = p end
|
||||
end
|
||||
|
||||
local function process_level_6_position(p, seed, tiles, entities, markets, treasure)
|
||||
local large_caves = get_noise("large_caves", p, seed)
|
||||
local cave_rivers = get_noise("cave_rivers", p, seed)
|
||||
|
||||
|
||||
--Chasms
|
||||
local noise_cave_ponds = get_noise("cave_ponds", p, seed)
|
||||
local small_caves = get_noise("small_caves", p, seed)
|
||||
@ -271,77 +312,77 @@ local function process_level_6_position(p, seed, tiles, entities, markets, treas
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if large_caves > -0.03 and large_caves < 0.03 and cave_rivers < 0.25 then
|
||||
tiles[#tiles + 1] = {name = "water-green", position = p}
|
||||
if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
end
|
||||
|
||||
if cave_rivers > -0.05 and cave_rivers < 0.05 then
|
||||
if math_random(1,48) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end
|
||||
|
||||
if cave_rivers > -0.1 and cave_rivers < 0.1 then
|
||||
if math_random(1,36) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end
|
||||
if math_random(1,128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
else
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,8) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,512) == 1 then treasure[#treasure + 1] = p end
|
||||
if math_random(1,4096) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end
|
||||
if math_random(1,8096) == 1 then markets[#markets + 1] = p end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function process_level_5_position(p, seed, tiles, entities, markets, treasure)
|
||||
local small_caves = get_noise("small_caves", p, seed)
|
||||
local noise_cave_ponds = get_noise("cave_ponds", p, seed)
|
||||
|
||||
|
||||
if small_caves > -0.14 and small_caves < 0.14 then
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,768) == 1 then treasure[#treasure + 1] = p end
|
||||
if math_random(1,3) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,3) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if small_caves < -0.50 or small_caves > 0.50 then
|
||||
tiles[#tiles + 1] = {name = "deepwater-green", position = p}
|
||||
if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
if math_random(1,128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if small_caves > -0.30 and small_caves < 0.30 then
|
||||
if noise_cave_ponds > 0.35 then
|
||||
if noise_cave_ponds > 0.35 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_random(1, 4), position = p}
|
||||
if math_random(1,256) == 1 then treasure[#treasure + 1] = p end
|
||||
if math_random(1,256) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end
|
||||
return
|
||||
end
|
||||
if noise_cave_ponds > 0.25 then
|
||||
end
|
||||
if noise_cave_ponds > 0.25 then
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,512) == 1 then treasure[#treasure + 1] = p end
|
||||
if math_random(1,2) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,4) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
end
|
||||
|
||||
local function process_level_4_position(p, seed, tiles, entities, markets, treasure)
|
||||
local function process_level_4_position(p, seed, tiles, entities, markets, treasure)
|
||||
local noise_large_caves = get_noise("large_caves", p, seed)
|
||||
local noise_cave_ponds = get_noise("cave_ponds", p, seed)
|
||||
local small_caves = get_noise("small_caves", p, seed)
|
||||
|
||||
local small_caves = get_noise("small_caves", p, seed)
|
||||
|
||||
if math_abs(noise_large_caves) > 0.7 then
|
||||
tiles[#tiles + 1] = {name = "water", position = p}
|
||||
if math_random(1,16) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
end
|
||||
end
|
||||
if math_abs(noise_large_caves) > 0.6 then
|
||||
if math_random(1,16) == 1 then entities[#entities + 1] = {name="tree-02", position=p} end
|
||||
if math_random(1,32) == 1 then markets[#markets + 1] = p end
|
||||
@ -351,53 +392,53 @@ local function process_level_4_position(p, seed, tiles, entities, markets, treas
|
||||
if math_random(1,620) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end
|
||||
if math_random(1,384) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
if math_random(1, 1024) == 1 then treasure[#treasure + 1] = p end
|
||||
return
|
||||
end
|
||||
if math_abs(noise_large_caves) > 0.475 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, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,4) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--Chasms
|
||||
if noise_cave_ponds < 0.15 and noise_cave_ponds > -0.15 then
|
||||
if small_caves > 0.45 then
|
||||
if small_caves > 0.55 then
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
return
|
||||
end
|
||||
if small_caves < -0.45 then
|
||||
if small_caves < -0.55 then
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if small_caves > -0.15 and small_caves < 0.15 then
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,5) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,4) == 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1, 1024) == 1 then treasure[#treasure + 1] = p end
|
||||
return
|
||||
end
|
||||
|
||||
if noise_large_caves > -0.1 and noise_large_caves < 0.1 then
|
||||
|
||||
end
|
||||
|
||||
if noise_large_caves > -0.1 and noise_large_caves < 0.1 then
|
||||
|
||||
--Main Rock Terrain
|
||||
local no_rocks_2 = get_noise("no_rocks_2", p, seed + 75000)
|
||||
if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_floor(no_rocks_2 * 8) % 2 + 5, position = p}
|
||||
if math_random(1,512) == 1 then treasure[#treasure + 1] = p end
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,100) > 30 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,100) > 60 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
end
|
||||
|
||||
@ -406,12 +447,12 @@ local function process_level_3_position(p, seed, tiles, entities, markets, treas
|
||||
local small_caves_2 = get_noise("small_caves_2", p, seed + 70000)
|
||||
local noise_large_caves = get_noise("large_caves", p, seed + 60000)
|
||||
local noise_cave_ponds = get_noise("cave_ponds", p, seed)
|
||||
|
||||
--Market Spots
|
||||
if noise_cave_ponds < -0.77 then
|
||||
|
||||
--Market Spots
|
||||
if noise_cave_ponds < -0.77 then
|
||||
if noise_cave_ponds > -0.79 then
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p}
|
||||
entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p}
|
||||
else
|
||||
tiles[#tiles + 1] = {name = "grass-" .. math_floor(noise_cave_ponds * 32) % 3 + 1, position = p}
|
||||
if math_random(1,32) == 1 then markets[#markets + 1] = p end
|
||||
@ -427,51 +468,51 @@ local function process_level_3_position(p, seed, tiles, entities, markets, treas
|
||||
if math_random(1,16) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--Chasms
|
||||
if noise_cave_ponds < 0.12 and noise_cave_ponds > -0.12 then
|
||||
if small_caves > 0.55 then
|
||||
if small_caves > 0.65 then
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
return
|
||||
end
|
||||
if small_caves < -0.55 then
|
||||
if small_caves < -0.65 then
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--Rivers
|
||||
local cave_rivers = get_noise("cave_rivers", p, seed + 100000)
|
||||
if cave_rivers < 0.014 and cave_rivers > -0.014 then
|
||||
if cave_rivers < 0.024 and cave_rivers > -0.024 then
|
||||
if noise_cave_ponds > 0.2 then
|
||||
tiles[#tiles + 1] = {name = "water-shallow", position = p}
|
||||
if math_random(1,64) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
return
|
||||
end
|
||||
end
|
||||
local cave_rivers_2 = get_noise("cave_rivers_2", p, seed)
|
||||
if cave_rivers_2 < 0.024 and cave_rivers_2 > -0.024 then
|
||||
if noise_cave_ponds < 0.5 then
|
||||
if noise_cave_ponds < 0.4 then
|
||||
tiles[#tiles + 1] = {name = "water", position = p}
|
||||
if math_random(1,64) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if noise_cave_ponds > 0.775 then
|
||||
end
|
||||
|
||||
if noise_cave_ponds > 0.725 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_random(4, 6), position = p}
|
||||
return
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
local no_rocks = get_noise("no_rocks", p, seed + 25000)
|
||||
--Worm oil Zones
|
||||
if no_rocks < 0.15 and no_rocks > -0.15 then
|
||||
if no_rocks < 0.20 and no_rocks > -0.20 then
|
||||
if small_caves > 0.35 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_floor(noise_cave_ponds * 32) % 7 + 1, position = p}
|
||||
if math_random(1,320) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end
|
||||
if math_random(1,50) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
if math_random(1,512) == 1 then treasure[#treasure + 1] = p end
|
||||
if math_random(1,64) == 1 then entities[#entities + 1] = {name = "dead-tree-desert", position=p} end
|
||||
@ -484,26 +525,26 @@ local function process_level_3_position(p, seed, tiles, entities, markets, treas
|
||||
if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_floor(no_rocks_2 * 8) % 2 + 5, position = p}
|
||||
if math_random(1,512) == 1 then treasure[#treasure + 1] = p end
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,100) > 30 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,100) > 60 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
end
|
||||
|
||||
local function process_level_2_position(p, seed, tiles, entities, markets, treasure)
|
||||
local small_caves = get_noise("small_caves", p, seed)
|
||||
local small_caves = get_noise("small_caves", p, seed)
|
||||
local noise_large_caves = get_noise("large_caves", p, seed)
|
||||
|
||||
if noise_large_caves > -0.75 and noise_large_caves < 0.75 then
|
||||
|
||||
|
||||
if noise_large_caves > -0.75 and noise_large_caves < 0.75 then
|
||||
|
||||
local noise_cave_ponds = get_noise("cave_ponds", p, seed)
|
||||
|
||||
|
||||
--Chasms
|
||||
if noise_cave_ponds < 0.15 and noise_cave_ponds > -0.15 then
|
||||
if small_caves > 0.32 then
|
||||
@ -514,78 +555,78 @@ local function process_level_2_position(p, seed, tiles, entities, markets, treas
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--Green Water Ponds
|
||||
if noise_cave_ponds > 0.80 then
|
||||
tiles[#tiles + 1] = {name = "deepwater-green", position = p}
|
||||
if math_random(1,16) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--Rivers
|
||||
local cave_rivers = get_noise("cave_rivers", p, seed + 100000)
|
||||
if cave_rivers < 0.027 and cave_rivers > -0.027 then
|
||||
if cave_rivers < 0.037 and cave_rivers > -0.037 then
|
||||
if noise_cave_ponds < 0.1 then
|
||||
tiles[#tiles + 1] = {name = "water-shallow", position = p}
|
||||
if math_random(1,64) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if noise_cave_ponds > 0.76 then
|
||||
|
||||
if noise_cave_ponds > 0.66 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_random(4, 6), position = p}
|
||||
return
|
||||
end
|
||||
|
||||
--Market Spots
|
||||
return
|
||||
end
|
||||
|
||||
--Market Spots
|
||||
if noise_cave_ponds < -0.80 then
|
||||
tiles[#tiles + 1] = {name = "grass-" .. math_floor(noise_cave_ponds * 32) % 3 + 1, position = p}
|
||||
if math_random(1,32) == 1 then markets[#markets + 1] = p end
|
||||
if math_random(1,16) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local no_rocks = get_noise("no_rocks", p, seed + 25000)
|
||||
--Worm oil Zones
|
||||
if no_rocks < 0.15 and no_rocks > -0.15 then
|
||||
if small_caves > 0.35 then
|
||||
--Worm oil Zones
|
||||
if no_rocks < 0.20 and no_rocks > -0.20 then
|
||||
if small_caves > 0.30 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_floor(noise_cave_ponds * 32) % 7 + 1, position = p}
|
||||
if math_random(1,450) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end
|
||||
if math_random(1,64) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
if math_random(1,1024) == 1 then treasure[#treasure + 1] = p end
|
||||
if math_random(1,64) == 1 then entities[#entities + 1] = {name = "dead-tree-desert", position=p} end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--Main Rock Terrain
|
||||
local no_rocks_2 = get_noise("no_rocks_2", p, seed + 75000)
|
||||
if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_floor(no_rocks_2 * 8) % 2 + 5, position = p}
|
||||
if math_random(1,512) == 1 then treasure[#treasure + 1] = p end
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,100) > 30 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,100) > 55 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
end
|
||||
|
||||
local function process_level_1_position(p, seed, tiles, entities, markets, treasure)
|
||||
local small_caves = get_noise("small_caves", p, seed)
|
||||
local small_caves = get_noise("small_caves", p, seed)
|
||||
local noise_large_caves = get_noise("large_caves", p, seed)
|
||||
|
||||
local noise_cave_ponds = get_noise("cave_ponds", p, seed)
|
||||
|
||||
|
||||
--Chasms
|
||||
if noise_cave_ponds < 0.12 and noise_cave_ponds > -0.12 then
|
||||
if small_caves > 0.55 then
|
||||
@ -597,47 +638,47 @@ local function process_level_1_position(p, seed, tiles, entities, markets, treas
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--Green Water Ponds
|
||||
if noise_cave_ponds > 0.80 then
|
||||
tiles[#tiles + 1] = {name = "deepwater-green", position = p}
|
||||
if math_random(1,16) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--Rivers
|
||||
local cave_rivers = get_noise("cave_rivers", p, seed + 100000)
|
||||
if cave_rivers < 0.024 and cave_rivers > -0.024 then
|
||||
if cave_rivers < 0.044 and cave_rivers > -0.044 then
|
||||
if noise_cave_ponds > 0 then
|
||||
tiles[#tiles + 1] = {name = "water-shallow", position = p}
|
||||
if math_random(1,64) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if noise_cave_ponds > 0.76 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_random(4, 6), position = p}
|
||||
return
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
--Market Spots
|
||||
--Market Spots
|
||||
if noise_cave_ponds < -0.75 then
|
||||
tiles[#tiles + 1] = {name = "grass-" .. math_floor(noise_cave_ponds * 32) % 3 + 1, position = p}
|
||||
if math_random(1,32) == 1 then markets[#markets + 1] = p end
|
||||
if math_random(1,32) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local no_rocks = get_noise("no_rocks", p, seed + 25000)
|
||||
--Worm oil Zones
|
||||
if p.y < -64 + noise_cave_ponds * 10 then
|
||||
if no_rocks < 0.08 and no_rocks > -0.08 then
|
||||
if small_caves > 0.35 then
|
||||
if no_rocks < 0.12 and no_rocks > -0.12 then
|
||||
if small_caves > 0.30 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_floor(noise_cave_ponds * 32) % 7 + 1, position = p}
|
||||
if math_random(1,450) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = get_oil_amount(p)} end
|
||||
if math_random(1,96) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
if math_random(1,1024) == 1 then treasure[#treasure + 1] = p end
|
||||
if math_random(1,64) == 1 then entities[#entities + 1] = {name = "dead-tree-desert", position=p} end
|
||||
@ -645,19 +686,19 @@ local function process_level_1_position(p, seed, tiles, entities, markets, treas
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--Main Rock Terrain
|
||||
local no_rocks_2 = get_noise("no_rocks_2", p, seed + 75000)
|
||||
if no_rocks_2 > 0.70 or no_rocks_2 < -0.70 then
|
||||
if no_rocks_2 > 0.65 or no_rocks_2 < -0.65 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_floor(no_rocks_2 * 8) % 2 + 5, position = p}
|
||||
if math_random(1,32) == 1 then entities[#entities + 1] = {name = "dead-tree-desert", position=p} end
|
||||
if math_random(1,512) == 1 then treasure[#treasure + 1] = p end
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,100) > 30 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
if math_random(1,100) > 55 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
|
||||
end
|
||||
|
||||
local levels = {
|
||||
@ -671,18 +712,19 @@ local levels = {
|
||||
process_level_8_position,
|
||||
process_level_9_position,
|
||||
process_level_10_position,
|
||||
process_level_11_position,
|
||||
}
|
||||
|
||||
local entity_functions = {
|
||||
["turret"] = function(surface, entity) surface.create_entity(entity) end,
|
||||
["simple-entity"] = function(surface, entity) surface.create_entity(entity) end,
|
||||
["ammo-turret"] = function(surface, entity)
|
||||
["ammo-turret"] = function(surface, entity)
|
||||
local e = surface.create_entity(entity)
|
||||
e.insert({name = "uranium-rounds-magazine", count = math_random(16, 64)})
|
||||
end,
|
||||
["container"] = function(surface, entity)
|
||||
Treasure(surface, entity.position, entity.name)
|
||||
end,
|
||||
["container"] = function(surface, entity)
|
||||
Treasure(surface, entity.position, entity.name)
|
||||
end,
|
||||
}
|
||||
|
||||
local function rock_chunk(surface, left_top)
|
||||
@ -691,8 +733,8 @@ local function rock_chunk(surface, left_top)
|
||||
local markets = {}
|
||||
local treasure = {}
|
||||
local seed = surface.map_gen_settings.seed
|
||||
|
||||
local level_index = math_floor((math_abs(left_top.y / level_depth)) % 10) + 1
|
||||
|
||||
local level_index = math_floor((math_abs(left_top.y / level_depth)) % 11) + 1
|
||||
local process_level = levels[level_index]
|
||||
|
||||
for y = 0, 31, 1 do
|
||||
@ -710,13 +752,13 @@ local function rock_chunk(surface, left_top)
|
||||
market.destructible = false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
for _, p in pairs(treasure) do
|
||||
local name = "wooden-chest"
|
||||
if math_random(1, 6) == 1 then name = "iron-chest" end
|
||||
Treasure(surface, p, name)
|
||||
Treasure(surface, p, name)
|
||||
end
|
||||
|
||||
|
||||
for _, entity in pairs(entities) do
|
||||
if entity_functions[game.entity_prototypes[entity.name].type] then
|
||||
entity_functions[game.entity_prototypes[entity.name].type](surface, entity)
|
||||
@ -734,11 +776,11 @@ local function border_chunk(surface, left_top)
|
||||
for y = 5, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
if math_random(1, math.ceil(pos.y + pos.y) + 64) == 1 then
|
||||
surface.create_entity({name = trees[math_random(1, #trees)], position = pos})
|
||||
surface.create_entity({name = trees[math_random(1, #trees)], position = pos})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
@ -765,13 +807,13 @@ local function border_chunk(surface, left_top)
|
||||
{name = "rock-tiny", position = pos, amount = math_random(1, 1 + math.ceil(20 - y / 2))}
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
if math_random(1, math.ceil(pos.y + pos.y) + 2) == 1 then
|
||||
surface.create_entity({name = rock_raffle[math_random(1, size_of_rock_raffle)], position = pos})
|
||||
surface.create_entity({name = rock_raffle[math_random(1, size_of_rock_raffle)], position = pos})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
for _, e in pairs(surface.find_entities_filtered({area = {{left_top.x, left_top.y},{left_top.x + 32, left_top.y + 32}}, type = "cliff"})) do e.destroy() end
|
||||
end
|
||||
|
||||
@ -790,15 +832,15 @@ local function biter_chunk(surface, left_top)
|
||||
local e = surface.create_entity({name = spawner_raffle[math_random(1, #spawner_raffle)], position = position, force = "enemy"})
|
||||
e.destructible = false
|
||||
e.active = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
for i = 1, 3, 1 do
|
||||
local position = surface.find_non_colliding_position("big-worm-turret", tile_positions[math_random(1, #tile_positions)], 16, 2)
|
||||
if position then
|
||||
local e = surface.create_entity({name = "big-worm-turret", position = position, force = "enemy"})
|
||||
e.destructible = false
|
||||
end
|
||||
end
|
||||
end
|
||||
--for _, e in pairs(surface.find_entities_filtered({area = {{left_top.x, left_top.y},{left_top.x + 32, left_top.y + 32}}, type = "cliff"})) do e.destroy() end
|
||||
end
|
||||
@ -809,15 +851,15 @@ local function replace_water(surface, left_top)
|
||||
local p = {x = left_top.x + x, y = left_top.y + y}
|
||||
if surface.get_tile(p).collides_with("resource-layer") then
|
||||
surface.set_tiles({{name = get_replacement_tile(surface, p), position = p}}, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function out_of_map(surface, left_top)
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
surface.set_tiles({{name = "out-of-map", position = {x = left_top.x + x, y = left_top.y + y}}})
|
||||
surface.set_tiles({{name = "out-of-map", position = {x = left_top.x + x, y = left_top.y + y}}})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -827,7 +869,7 @@ local function wall(surface, left_top, seed)
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local p = {x = left_top.x + x, y = left_top.y + y}
|
||||
local small_caves = get_noise("small_caves", p, seed)
|
||||
local small_caves = get_noise("small_caves", p, seed)
|
||||
local cave_ponds = get_noise("cave_rivers", p, seed + 100000)
|
||||
if y > 9 + cave_ponds * 6 and y < 23 + small_caves * 6 then
|
||||
if small_caves > 0.05 or cave_ponds > 0.05 then
|
||||
@ -836,22 +878,22 @@ local function wall(surface, left_top, seed)
|
||||
if math_random(1,48) == 1 then surface.create_entity({name = "fish", position = p}) end
|
||||
else
|
||||
surface.set_tiles({{name = "dirt-7", position = p}})
|
||||
if math_random(1, 5) ~= 1 then
|
||||
if math_random(1, 2) == 1 then
|
||||
surface.create_entity({name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p})
|
||||
end
|
||||
end
|
||||
else
|
||||
surface.set_tiles({{name = "dirt-7", position = p}})
|
||||
|
||||
|
||||
if surface.can_place_entity({name = "stone-wall", position = p, force = "enemy"}) then
|
||||
if math_random(1,512) == 1 and y > 3 and y < 28 then
|
||||
if math_random(1, 2) == 1 then
|
||||
if math_random(1,512) == 1 and y > 3 and y < 28 then
|
||||
if math_random(1, 2) == 1 then
|
||||
Treasure(surface, p, "wooden-chest")
|
||||
else
|
||||
Treasure(surface, p, "iron-chest")
|
||||
end
|
||||
else
|
||||
|
||||
|
||||
if y < 5 or y > 26 then
|
||||
if y <= 15 then
|
||||
if math_random(1, y + 1) == 1 then
|
||||
@ -865,21 +907,23 @@ local function wall(surface, left_top, seed)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
if math_random(1, 16) == 1 then
|
||||
if surface.can_place_entity({name = "small-worm-turret", position = p, force = "enemy"}) then
|
||||
Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier)
|
||||
surface.create_entity({name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if math_random(1, 32) == 1 then
|
||||
if surface.can_place_entity({name = "gun-turret", position = p, force = "enemy"}) then
|
||||
local e = surface.create_entity({name = "gun-turret", position = p, force = "enemy"})
|
||||
if math_abs(p.y) < level_depth * 2.5 then
|
||||
e.insert({name = "firearm-magazine", count = math_random(64, 128)})
|
||||
elseif math_abs(p.y) < level_depth * 4.5 then
|
||||
e.insert({name = "piercing-rounds-magazine", count = math_random(64, 128)})
|
||||
else
|
||||
e.insert({name = "uranium-rounds-magazine", count = math_random(64, 128)})
|
||||
@ -896,11 +940,11 @@ local function process_chunk(surface, left_top)
|
||||
if not surface.valid then return end
|
||||
if left_top.x >= level_depth * 0.5 then return end
|
||||
if left_top.x < level_depth * -0.5 then return end
|
||||
|
||||
|
||||
if left_top.y % level_depth == 0 and left_top.y < 0 then wall(surface, left_top, surface.map_gen_settings.seed) return end
|
||||
|
||||
|
||||
if left_top.y >= 0 then replace_water(surface, left_top) end
|
||||
if left_top.y > 32 then game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}}) end
|
||||
if left_top.y > 32 then game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}}) end
|
||||
if left_top.y == -128 and left_top.x == -128 then
|
||||
local p = global.locomotive.position
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = {{p.x - 3, p.y - 4},{p.x + 3, p.y + 10}}, type = "simple-entity"})) do entity.destroy() end
|
||||
@ -919,4 +963,4 @@ end
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
|
||||
return level_depth
|
||||
return level_depth
|
||||
|
@ -3,12 +3,12 @@ local math_random = math.random
|
||||
local Public = {}
|
||||
|
||||
function Public.treasure_chest(surface, position, container_name)
|
||||
|
||||
|
||||
local chest_raffle = {}
|
||||
local chest_loot = {
|
||||
{{name = "submachine-gun", count = math_random(1,3)}, weight = 3, d_min = 0.0, d_max = 0.1},
|
||||
local chest_loot = {
|
||||
{{name = "submachine-gun", count = math_random(1,3)}, weight = 3, d_min = 0.0, d_max = 0.1},
|
||||
{{name = "slowdown-capsule", count = math_random(16,32)}, weight = 1, d_min = 0.3, d_max = 0.7},
|
||||
{{name = "poison-capsule", count = math_random(8,16)}, weight = 3, d_min = 0.3, d_max = 1},
|
||||
{{name = "poison-capsule", count = math_random(8,16)}, weight = 3, d_min = 0.3, d_max = 1},
|
||||
{{name = "uranium-cannon-shell", count = math_random(16,32)}, weight = 5, d_min = 0.6, d_max = 1},
|
||||
{{name = "cannon-shell", count = math_random(16,32)}, weight = 5, d_min = 0.4, d_max = 0.7},
|
||||
{{name = "explosive-uranium-cannon-shell", count = math_random(16,32)}, weight = 5, d_min = 0.6, d_max = 1},
|
||||
@ -20,7 +20,7 @@ function Public.treasure_chest(surface, position, container_name)
|
||||
{{name = "flamethrower", count = 1}, weight = 3, d_min = 0.3, d_max = 0.6},
|
||||
{{name = "flamethrower-ammo", count = math_random(16,32)}, weight = 5, d_min = 0.3, d_max = 1},
|
||||
{{name = "rocket-launcher", count = 1}, weight = 3, d_min = 0.2, d_max = 0.6},
|
||||
{{name = "rocket", count = math_random(16,32)}, weight = 5, d_min = 0.2, d_max = 0.7},
|
||||
{{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},
|
||||
@ -33,8 +33,8 @@ function Public.treasure_chest(surface, position, container_name)
|
||||
{{name = "defender-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.0, d_max = 0.7},
|
||||
{{name = "distractor-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.2, d_max = 1},
|
||||
{{name = "destroyer-capsule", count = math_random(8,16)}, weight = 2, d_min = 0.3, d_max = 1},
|
||||
{{name = "atomic-bomb", count = 1}, weight = 1, d_min = 0.8, d_max = 1},
|
||||
{{name = "light-armor", count = 1}, weight = 3, d_min = 0, d_max = 0.1},
|
||||
{{name = "atomic-bomb", count = 1}, weight = 1, d_min = 0.8, d_max = 1},
|
||||
{{name = "light-armor", count = 1}, weight = 3, d_min = 0, d_max = 0.1},
|
||||
{{name = "heavy-armor", count = 1}, weight = 3, d_min = 0.1, d_max = 0.3},
|
||||
{{name = "modular-armor", count = 1}, weight = 2, d_min = 0.2, d_max = 0.6},
|
||||
{{name = "power-armor", count = 1}, weight = 1, d_min = 0.4, d_max = 1},
|
||||
@ -50,12 +50,12 @@ function Public.treasure_chest(surface, position, container_name)
|
||||
--{{name = "fusion-reactor-equipment", count = 1}, weight = 1, d_min = 0.8, d_max = 1},
|
||||
{{name = "night-vision-equipment", count = 1}, weight = 1, d_min = 0.3, d_max = 0.8},
|
||||
{{name = "personal-laser-defense-equipment", count = 1}, weight = 1, d_min = 0.7, d_max = 1},
|
||||
|
||||
|
||||
{{name = "personal-roboport-equipment", count = math_random(1,2)}, weight = 3, d_min = 0.4, d_max = 1},
|
||||
--{{name = "personal-roboport-mk2-equipment", count = 1}, weight = 1, d_min = 0.9, d_max = 1},
|
||||
{{name = "logistic-robot", count = math_random(5,25)}, weight = 2, d_min = 0.5, d_max = 1},
|
||||
{{name = "construction-robot", count = math_random(5,25)}, weight = 5, d_min = 0.4, d_max = 1},
|
||||
|
||||
|
||||
{{name = "iron-gear-wheel", count = math_random(80,100)}, weight = 3, d_min = 0.0, d_max = 0.3},
|
||||
{{name = "copper-cable", count = math_random(100,200)}, weight = 3, d_min = 0.0, d_max = 0.3},
|
||||
{{name = "engine-unit", count = math_random(16,32)}, weight = 2, d_min = 0.1, d_max = 0.5},
|
||||
@ -68,11 +68,11 @@ function Public.treasure_chest(surface, position, container_name)
|
||||
{{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},
|
||||
|
||||
|
||||
{{name = "effectivity-module", count = math_random(1,4)}, weight = 2, d_min = 0.1, d_max = 1},
|
||||
{{name = "productivity-module", count = math_random(1,4)}, weight = 2, d_min = 0.1, d_max = 1},
|
||||
{{name = "speed-module", count = math_random(1,4)}, weight = 2, d_min = 0.1, d_max = 1},
|
||||
|
||||
|
||||
{{name = "automation-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.0, d_max = 0.2},
|
||||
{{name = "logistic-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.1, d_max = 0.5},
|
||||
{{name = "military-science-pack", count = math_random(16,64)}, weight = 3, d_min = 0.2, d_max = 1},
|
||||
@ -83,21 +83,21 @@ function Public.treasure_chest(surface, position, container_name)
|
||||
|
||||
{{name = "steel-plate", count = math_random(25,75)}, weight = 2, d_min = 0.1, d_max = 0.3},
|
||||
{{name = "nuclear-fuel", count = 1}, weight = 2, d_min = 0.7, d_max = 1},
|
||||
|
||||
|
||||
{{name = "burner-inserter", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.1},
|
||||
{{name = "inserter", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.4},
|
||||
{{name = "long-handed-inserter", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.4},
|
||||
{{name = "long-handed-inserter", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.4},
|
||||
{{name = "fast-inserter", count = math_random(8,16)}, weight = 3, d_min = 0.1, d_max = 1},
|
||||
{{name = "filter-inserter", count = math_random(8,16)}, weight = 1, d_min = 0.2, d_max = 1},
|
||||
{{name = "filter-inserter", count = math_random(8,16)}, weight = 1, d_min = 0.2, d_max = 1},
|
||||
{{name = "stack-filter-inserter", count = math_random(4,8)}, weight = 1, d_min = 0.4, d_max = 1},
|
||||
{{name = "stack-inserter", count = math_random(4,8)}, weight = 3, d_min = 0.3, d_max = 1},
|
||||
{{name = "stack-inserter", count = math_random(4,8)}, weight = 3, d_min = 0.3, d_max = 1},
|
||||
{{name = "small-electric-pole", count = math_random(16,24)}, weight = 3, d_min = 0.0, d_max = 0.3},
|
||||
{{name = "medium-electric-pole", count = math_random(8,16)}, weight = 3, d_min = 0.2, d_max = 1},
|
||||
{{name = "big-electric-pole", count = math_random(4,8)}, weight = 3, d_min = 0.3, d_max = 1},
|
||||
{{name = "substation", count = math_random(2,4)}, weight = 3, d_min = 0.5, d_max = 1},
|
||||
{{name = "wooden-chest", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.2},
|
||||
{{name = "iron-chest", count = math_random(8,16)}, weight = 3, d_min = 0.1, d_max = 0.4},
|
||||
{{name = "steel-chest", count = math_random(8,16)}, weight = 3, d_min = 0.3, d_max = 1},
|
||||
{{name = "steel-chest", count = math_random(8,16)}, weight = 3, d_min = 0.3, d_max = 1},
|
||||
{{name = "small-lamp", count = math_random(16,32)}, weight = 3, d_min = 0.1, d_max = 0.3},
|
||||
{{name = "rail", count = math_random(25,75)}, weight = 3, d_min = 0.1, d_max = 0.6},
|
||||
{{name = "assembling-machine-1", count = math_random(2,4)}, weight = 3, d_min = 0.0, d_max = 0.3},
|
||||
@ -116,22 +116,22 @@ function Public.treasure_chest(surface, position, container_name)
|
||||
{{name = "arithmetic-combinator", count = math_random(4,8)}, weight = 2, d_min = 0.1, d_max = 1},
|
||||
{{name = "constant-combinator", count = math_random(4,8)}, weight = 2, d_min = 0.1, d_max = 1},
|
||||
{{name = "decider-combinator", count = math_random(4,8)}, weight = 2, d_min = 0.1, d_max = 1},
|
||||
{{name = "power-switch", count = 1}, weight = 2, d_min = 0.1, d_max = 1},
|
||||
{{name = "power-switch", count = 1}, weight = 2, d_min = 0.1, d_max = 1},
|
||||
{{name = "programmable-speaker", count = math_random(2,4)}, weight = 1, d_min = 0.1, d_max = 1},
|
||||
{{name = "green-wire", count = math_random(50,99)}, weight = 4, d_min = 0.1, d_max = 1},
|
||||
{{name = "red-wire", count = math_random(50,99)}, weight = 4, d_min = 0.1, d_max = 1},
|
||||
{{name = "chemical-plant", count = math_random(1,3)}, weight = 3, d_min = 0.3, d_max = 1},
|
||||
{{name = "burner-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.0, d_max = 0.2},
|
||||
{{name = "electric-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.2, d_max = 1},
|
||||
{{name = "electric-mining-drill", count = math_random(2,4)}, weight = 3, d_min = 0.2, d_max = 1},
|
||||
{{name = "express-transport-belt", count = math_random(25,75)}, weight = 3, d_min = 0.5, d_max = 1},
|
||||
{{name = "express-underground-belt", count = math_random(4,8)}, weight = 3, d_min = 0.5, d_max = 1},
|
||||
{{name = "express-underground-belt", count = math_random(4,8)}, weight = 3, d_min = 0.5, d_max = 1},
|
||||
{{name = "express-splitter", count = math_random(1,4)}, weight = 3, d_min = 0.5, d_max = 1},
|
||||
{{name = "fast-transport-belt", count = math_random(25,75)}, weight = 3, d_min = 0.2, d_max = 0.7},
|
||||
{{name = "fast-underground-belt", count = math_random(4,8)}, weight = 3, d_min = 0.2, d_max = 0.7},
|
||||
{{name = "fast-splitter", count = math_random(1,4)}, weight = 3, d_min = 0.2, d_max = 0.3},
|
||||
{{name = "transport-belt", count = math_random(25,75)}, weight = 3, d_min = 0, d_max = 0.3},
|
||||
{{name = "underground-belt", count = math_random(4,8)}, weight = 3, d_min = 0, d_max = 0.3},
|
||||
{{name = "splitter", count = math_random(1,4)}, weight = 3, d_min = 0, d_max = 0.3},
|
||||
{{name = "splitter", count = math_random(1,4)}, weight = 3, d_min = 0, d_max = 0.3},
|
||||
--{{name = "oil-refinery", count = math_random(2,4)}, weight = 2, d_min = 0.3, d_max = 1},
|
||||
{{name = "pipe", count = math_random(30,50)}, weight = 3, d_min = 0.0, d_max = 0.3},
|
||||
{{name = "pipe-to-ground", count = math_random(4,8)}, weight = 1, d_min = 0.2, d_max = 0.5},
|
||||
@ -140,10 +140,10 @@ function Public.treasure_chest(surface, position, container_name)
|
||||
{{name = "solar-panel", count = math_random(3,6)}, weight = 3, d_min = 0.4, d_max = 0.9},
|
||||
{{name = "electric-furnace", count = math_random(2,4)}, weight = 3, d_min = 0.5, d_max = 1},
|
||||
{{name = "steel-furnace", count = math_random(4,8)}, weight = 3, d_min = 0.2, d_max = 0.7},
|
||||
{{name = "stone-furnace", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.2},
|
||||
{{name = "stone-furnace", count = math_random(8,16)}, weight = 3, d_min = 0.0, d_max = 0.2},
|
||||
{{name = "radar", count = math_random(1,2)}, weight = 1, d_min = 0.1, d_max = 0.4},
|
||||
{{name = "rail-signal", count = math_random(8,16)}, weight = 2, d_min = 0.2, d_max = 0.8},
|
||||
{{name = "rail-chain-signal", count = math_random(8,16)}, weight = 2, d_min = 0.2, d_max = 0.8},
|
||||
{{name = "rail-chain-signal", count = math_random(8,16)}, weight = 2, d_min = 0.2, d_max = 0.8},
|
||||
{{name = "stone-wall", count = math_random(33,99)}, weight = 3, d_min = 0.0, d_max = 0.7},
|
||||
{{name = "gate", count = math_random(16,32)}, weight = 3, d_min = 0.0, d_max = 0.7},
|
||||
{{name = "storage-tank", count = math_random(2,6)}, weight = 3, d_min = 0.3, d_max = 0.6},
|
||||
@ -151,25 +151,29 @@ function Public.treasure_chest(surface, position, container_name)
|
||||
{{name = "express-loader", count = math_random(1,2)}, weight = 1, d_min = 0.5, d_max = 1},
|
||||
{{name = "fast-loader", count = math_random(1,2)}, weight = 1, d_min = 0.2, d_max = 0.7},
|
||||
{{name = "loader", count = math_random(1,2)}, weight = 1, d_min = 0.0, d_max = 0.5},
|
||||
{{name = "lab", count = math_random(1,2)}, weight = 2, d_min = 0.0, d_max = 0.3},
|
||||
{{name = "lab", count = math_random(1,2)}, weight = 2, d_min = 0.0, d_max = 0.3},
|
||||
{{name = "roboport", count = 1}, weight = 2, d_min = 0.8, d_max = 1},
|
||||
{{name = "flamethrower-turret", count = 1}, weight = 3, d_min = 0.5, d_max = 1},
|
||||
{{name = "laser-turret", count = math_random(3,6)}, weight = 3, d_min = 0.5, d_max = 1},
|
||||
{{name = "flamethrower-turret", count = 1}, weight = 3, d_min = 0.5, d_max = 1},
|
||||
{{name = "laser-turret", count = math_random(3,6)}, weight = 3, d_min = 0.5, d_max = 1},
|
||||
{{name = "gun-turret", count = math_random(2,4)}, weight = 3, d_min = 0.2, d_max = 0.9},
|
||||
{{name = 'crude-oil-barrel', count = math_random(2,4)}, weight = 3, d_min = 0.1, d_max = 0.3},
|
||||
{{name = 'crude-oil-barrel', count = math_random(4,8)}, weight = 3, d_min = 0.2, d_max = 0.5},
|
||||
{{name = 'crude-oil-barrel', count = math_random(8,16)}, weight = 3, d_min = 0.4, d_max = 0.7},
|
||||
{{name = 'crude-oil-barrel', count = math_random(12,24)}, weight = 3, d_min = 0.6, d_max = 0.9},
|
||||
}
|
||||
|
||||
|
||||
local distance_to_center = (math.abs(position.y) + 1) * 0.0002
|
||||
if distance_to_center > 1 then distance_to_center = 1 end
|
||||
|
||||
|
||||
for _, t in pairs (chest_loot) do
|
||||
for x = 1, t.weight, 1 do
|
||||
if t.d_min <= distance_to_center and t.d_max >= distance_to_center then
|
||||
table.insert(chest_raffle, t[1])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local e = surface.create_entity({name = container_name, position=position, force="neutral", create_build_effect_smoke = false})
|
||||
|
||||
local e = surface.create_entity({name = container_name, position=position, force="neutral", create_build_effect_smoke = false})
|
||||
e.minable = false
|
||||
local i = e.get_inventory(defines.inventory.chest)
|
||||
for x = 1, math_random(2,6), 1 do
|
||||
@ -178,4 +182,4 @@ function Public.treasure_chest(surface, position, container_name)
|
||||
end
|
||||
end
|
||||
|
||||
return Public.treasure_chest
|
||||
return Public.treasure_chest
|
||||
|
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_entity({
|
||||
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}, 1, 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)
|
@ -3,6 +3,8 @@ local math_random = math.random
|
||||
local math_floor = math.floor
|
||||
global.biter_command = {}
|
||||
global.biter_command.active_unit_groups = {}
|
||||
global.biter_command.enabled = true
|
||||
global.biter_command.whitelist = {}
|
||||
global.biter_command.admin_mode = true --if only admins can see and use the panel
|
||||
global.biter_command.teleporting = false --if teleporting is allowed for non-admins
|
||||
|
||||
@ -105,7 +107,8 @@ local function move_to(position, distraction)
|
||||
local command = {
|
||||
type = defines.command.go_to_location,
|
||||
destination = position,
|
||||
distraction = distraction
|
||||
distraction = distraction,
|
||||
pathfind_flags = {allow_destroy_friendly_entities = true}
|
||||
}
|
||||
return command
|
||||
end
|
||||
@ -364,12 +367,23 @@ end
|
||||
----------------------------gui-----------------------
|
||||
|
||||
local function top_button(player)
|
||||
if player.gui.top["biter_commands"] then return end
|
||||
if player.gui.top["biter_commands"] then
|
||||
if global.biter_command.enabled or global.biter_command.whitelist[player.name] == true then
|
||||
player.gui.top["biter_commands"].visible = true
|
||||
return
|
||||
else
|
||||
--player.gui.top["biter_commands"].destroy()
|
||||
player.gui.top["biter_commands"].visible = false
|
||||
return
|
||||
end
|
||||
end
|
||||
if player.admin or not global.biter_command.admin_mode then
|
||||
local button = player.gui.top.add({type = "sprite-button", name = "biter_commands", sprite = "entity/medium-spitter"})
|
||||
button.style.minimal_height = 38
|
||||
button.style.minimal_width = 38
|
||||
button.style.padding = -2
|
||||
if global.biter_command.enabled or global.biter_command.whitelist[player.name] == true then
|
||||
local button = player.gui.top.add({type = "sprite-button", name = "biter_commands", sprite = "entity/medium-spitter"})
|
||||
button.style.minimal_height = 38
|
||||
button.style.minimal_width = 38
|
||||
button.style.padding = -2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -540,8 +554,18 @@ local function on_gui_click(event)
|
||||
if not event.element.valid then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
if event.element.name == "biter_commands" then --top button press
|
||||
biter_panel(player)
|
||||
return
|
||||
if global.biter_command.enabled or global.biter_command.whitelist[player.name] == true then
|
||||
biter_panel(player)
|
||||
return
|
||||
else
|
||||
top_button(player)
|
||||
player.print("Biter commander module is disabled.")
|
||||
return
|
||||
end
|
||||
else
|
||||
if global.biter_command.enabled or global.biter_command.whitelist[player.name] == true then
|
||||
top_button(player)
|
||||
end
|
||||
end
|
||||
if event.element.type ~= "button" and event.element.type ~= "sprite-button" then return end
|
||||
--if event.frame.name ~= "biter_panel" then return end
|
||||
|
@ -73,7 +73,7 @@ end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
if not event.cause then return end
|
||||
if event.cause.name ~= "player" then return end
|
||||
if event.cause.name ~= "character" then return end
|
||||
if event.damage_type.name ~= "physical" then return end
|
||||
if event.original_damage_amount ~= 100 then return end
|
||||
|
||||
|
@ -28,6 +28,21 @@ local function debug_print(msg)
|
||||
print("WaveDefense: " .. msg)
|
||||
end
|
||||
|
||||
local function is_closer(pos1, pos2, pos)
|
||||
return ((pos1.x - pos.x)^2 + (pos1.y - pos.y)^2) < ((pos2.x - pos.x)^2 + (pos2.y - pos.y)^2)
|
||||
end
|
||||
|
||||
local function shuffle_distance(tbl, position)
|
||||
local size = #tbl
|
||||
for i = size, 1, -1 do
|
||||
local rand = math_random(size)
|
||||
if is_closer(tbl[i].position, tbl[rand].position, position) and i > rand then
|
||||
tbl[i], tbl[rand] = tbl[rand], tbl[i]
|
||||
end
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
|
||||
local function is_unit_valid(biter)
|
||||
local wave_defense_table = WD.get_table()
|
||||
if not biter.entity then debug_print("is_unit_valid - unit destroyed - does no longer exist") return false end
|
||||
@ -104,12 +119,12 @@ local function set_main_target()
|
||||
if wave_defense_table.target then
|
||||
if wave_defense_table.target.valid then return end
|
||||
end
|
||||
|
||||
|
||||
local target = SideTargets.get_side_target()
|
||||
if not target then target = get_random_character(wave_defense_table) end
|
||||
if not target then return end
|
||||
|
||||
wave_defense_table.target = target
|
||||
|
||||
wave_defense_table.target = target
|
||||
debug_print("set_main_target -- New main target " .. target.name .. " at position x" .. target.position.x .. " y" .. target.position.y .. " selected.")
|
||||
end
|
||||
|
||||
@ -193,7 +208,7 @@ local function spawn_biter(surface, is_boss_biter)
|
||||
if not is_boss_biter then
|
||||
if not can_units_spawn() then return end
|
||||
end
|
||||
|
||||
|
||||
local name
|
||||
if math_random(1,100) > 73 then
|
||||
name = BiterRolls.wave_defense_roll_spitter_name()
|
||||
@ -215,17 +230,17 @@ end
|
||||
local function set_next_wave()
|
||||
local wave_defense_table = WD.get_table()
|
||||
wave_defense_table.wave_number = wave_defense_table.wave_number + 1
|
||||
|
||||
|
||||
local threat_gain = wave_defense_table.wave_number * wave_defense_table.threat_gain_multiplier
|
||||
if wave_defense_table.wave_number > 1000 then
|
||||
threat_gain = threat_gain * (wave_defense_table.wave_number * 0.001)
|
||||
end
|
||||
if wave_defense_table.wave_number % 25 == 0 then
|
||||
wave_defense_table.boss_wave = true
|
||||
threat_gain = threat_gain * 2
|
||||
threat_gain = threat_gain * 2
|
||||
end
|
||||
|
||||
wave_defense_table.threat = wave_defense_table.threat + math_floor(threat_gain)
|
||||
|
||||
wave_defense_table.threat = wave_defense_table.threat + math_floor(threat_gain)
|
||||
wave_defense_table.last_wave = wave_defense_table.next_wave
|
||||
wave_defense_table.next_wave = game.tick + wave_defense_table.wave_interval
|
||||
end
|
||||
@ -239,7 +254,6 @@ local function get_commmands(group)
|
||||
if math_random(1,2) == 1 then
|
||||
local side_target = SideTargets.get_side_target()
|
||||
if side_target then
|
||||
debug_print("get_side_target -- " .. side_target.name .. " at position x" .. side_target.position.x .. " y" .. side_target.position.y .. " selected.")
|
||||
local target_position = side_target.position
|
||||
local distance_to_target = math_floor(math_sqrt((target_position.x - group_position.x) ^ 2 + (target_position.y - group_position.y) ^ 2))
|
||||
local steps = math_floor(distance_to_target / step_length) + 1
|
||||
@ -252,16 +266,49 @@ local function get_commmands(group)
|
||||
end
|
||||
|
||||
for i = 1, steps, 1 do
|
||||
local old_position = group_position
|
||||
group_position.x = group_position.x + vector[1]
|
||||
group_position.y = group_position.y + vector[2]
|
||||
local position = group.surface.find_non_colliding_position("small-biter", group_position, step_length, 2)
|
||||
group_position.y = group_position.y + vector[2]
|
||||
local obstacles = group.surface.find_entities_filtered{position = old_position, radius = step_length, type = {"simple-entity", "tree"}, limit = 50}
|
||||
if obstacles then
|
||||
shuffle_distance(obstacles, old_position)
|
||||
for i = 1, #obstacles, 1 do
|
||||
if obstacles[i].valid then
|
||||
commands[#commands + 1] = {
|
||||
type = defines.command.attack,
|
||||
target = obstacles[i],
|
||||
distraction = defines.distraction.by_enemy
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
local position = group.surface.find_non_colliding_position("rocket-silo", group_position, step_length, 4)
|
||||
if position then
|
||||
-- commands[#commands + 1] = {
|
||||
-- type = defines.command.go_to_location,
|
||||
-- destination = {x = position.x, y = position.y},
|
||||
-- distraction = defines.distraction.by_anything
|
||||
-- }
|
||||
commands[#commands + 1] = {
|
||||
type = defines.command.attack_area,
|
||||
destination = {x = position.x, y = position.y},
|
||||
radius = 16,
|
||||
distraction = defines.distraction.by_anything
|
||||
}
|
||||
else
|
||||
local obstacles = group.surface.find_entities_filtered{position = group_position, radius = step_length, type = {"simple-entity", "tree"}, limit = 50}
|
||||
if obstacles then
|
||||
shuffle_distance(obstacles, old_position)
|
||||
for i = 1, #obstacles, 1 do
|
||||
if obstacles[i].valid then
|
||||
commands[#commands + 1] = {
|
||||
type = defines.command.attack,
|
||||
target = obstacles[i],
|
||||
distraction = defines.distraction.by_enemy
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -285,9 +332,23 @@ local function get_commmands(group)
|
||||
end
|
||||
|
||||
for i = 1, steps, 1 do
|
||||
local old_position = group_position
|
||||
group_position.x = group_position.x + vector[1]
|
||||
group_position.y = group_position.y + vector[2]
|
||||
local position = group.surface.find_non_colliding_position("small-biter", group_position, step_length, 1)
|
||||
local obstacles = group.surface.find_entities_filtered{position = old_position, radius = step_length / 2, type = {"simple-entity", "tree"}, limit = 50}
|
||||
if obstacles then
|
||||
shuffle_distance(obstacles, old_position)
|
||||
for i = 1, #obstacles, 1 do
|
||||
if obstacles[i].valid then
|
||||
commands[#commands + 1] = {
|
||||
type = defines.command.attack,
|
||||
target = obstacles[i],
|
||||
distraction = defines.distraction.by_enemy
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
local position = group.surface.find_non_colliding_position("rocket-silo", group_position, step_length, 1)
|
||||
if position then
|
||||
commands[#commands + 1] = {
|
||||
type = defines.command.attack_area,
|
||||
@ -320,15 +381,15 @@ local function command_unit_group(group)
|
||||
wave_defense_table.unit_group_last_command[group.group_number] = game.tick - (wave_defense_table.unit_group_command_delay + 1)
|
||||
end
|
||||
if wave_defense_table.unit_group_last_command[group.group_number] then
|
||||
if wave_defense_table.unit_group_last_command[group.group_number] + wave_defense_table.unit_group_command_delay > game.tick then return end
|
||||
if wave_defense_table.unit_group_last_command[group.group_number] + wave_defense_table.unit_group_command_delay > game.tick then return end
|
||||
end
|
||||
|
||||
|
||||
group.set_command({
|
||||
type = defines.command.compound,
|
||||
structure_type = defines.compound_command.return_last,
|
||||
commands = get_commmands(group)
|
||||
})
|
||||
|
||||
|
||||
wave_defense_table.unit_group_last_command[group.group_number] = game.tick
|
||||
end
|
||||
|
||||
@ -356,22 +417,22 @@ local function spawn_unit_group()
|
||||
set_group_spawn_position(surface)
|
||||
local pos = wave_defense_table.spawn_position
|
||||
if not surface.can_place_entity({name = "small-biter", position = pos}) then return end
|
||||
|
||||
|
||||
local radius = 10
|
||||
local area = {left_top = {pos.x - radius, pos.y - radius}, right_bottom = {pos.x + radius, pos.y + radius}}
|
||||
for k,v in pairs(surface.find_entities_filtered{area = area, name = "land-mine"}) do if v and v.valid then v.die() end end
|
||||
|
||||
|
||||
BiterRolls.wave_defense_set_unit_raffle(wave_defense_table.wave_number)
|
||||
|
||||
|
||||
debug_print("Spawning unit group at x" .. wave_defense_table.spawn_position.x .." y" .. wave_defense_table.spawn_position.y)
|
||||
local unit_group = surface.create_unit_group({position = wave_defense_table.spawn_position, force = "enemy"})
|
||||
local unit_group = surface.create_unit_group({position = wave_defense_table.spawn_position, force = "enemy"})
|
||||
local group_size = math_floor(wave_defense_table.average_unit_group_size * group_size_modifier_raffle[math_random(1, group_size_modifier_raffle_size)])
|
||||
for _ = 1, group_size, 1 do
|
||||
local biter = spawn_biter(surface)
|
||||
if not biter then break end
|
||||
unit_group.add_member(biter)
|
||||
end
|
||||
|
||||
|
||||
if wave_defense_table.boss_wave then
|
||||
local count = math_random(1, math_floor(wave_defense_table.wave_number * 0.01) + 2)
|
||||
if count > 8 then count = 8 end
|
||||
@ -383,7 +444,7 @@ local function spawn_unit_group()
|
||||
wave_defense_table.boss_wave = false
|
||||
end
|
||||
|
||||
table_insert(wave_defense_table.unit_groups, unit_group)
|
||||
table_insert(wave_defense_table.unit_groups, unit_group)
|
||||
return true
|
||||
end
|
||||
|
||||
@ -391,7 +452,7 @@ local function log_threat()
|
||||
local wave_defense_table = WD.get_table()
|
||||
wave_defense_table.threat_log_index = wave_defense_table.threat_log_index + 1
|
||||
wave_defense_table.threat_log[wave_defense_table.threat_log_index] = wave_defense_table.threat
|
||||
if wave_defense_table.threat_log_index > 900 then wave_defense_table.threat_log[wave_defense_table.threat_log_index - 901] = nil end
|
||||
if wave_defense_table.threat_log_index > 900 then wave_defense_table.threat_log[wave_defense_table.threat_log_index - 901] = nil end
|
||||
end
|
||||
|
||||
local tick_tasks = {
|
||||
@ -408,15 +469,15 @@ local tick_tasks = {
|
||||
local function on_tick()
|
||||
local wave_defense_table = WD.get_table()
|
||||
if wave_defense_table.game_lost then return end
|
||||
|
||||
|
||||
if game.tick > wave_defense_table.next_wave then set_next_wave() end
|
||||
|
||||
local t = game.tick % 300
|
||||
local t2 = game.tick % 18000
|
||||
|
||||
|
||||
if tick_tasks[t] then tick_tasks[t]() end
|
||||
if tick_tasks[t2] then tick_tasks[t2]() end
|
||||
|
||||
|
||||
if game.tick % 60 == 0 then log_threat() end
|
||||
for _, player in pairs(game.connected_players) do update_gui(player) end
|
||||
end
|
||||
@ -427,4 +488,4 @@ local function on_init()
|
||||
end
|
||||
|
||||
event.on_nth_tick(30, on_tick)
|
||||
return Public
|
||||
return Public
|
||||
|
@ -41,7 +41,7 @@ function Public.reset_wave_defense()
|
||||
wave_defense.threat_log_index = 0
|
||||
wave_defense.unit_groups = {}
|
||||
wave_defense.unit_group_command_delay = 3600 * 15
|
||||
wave_defense.unit_group_command_step_length = 80
|
||||
wave_defense.unit_group_command_step_length = 20
|
||||
wave_defense.unit_group_last_command = {}
|
||||
wave_defense.wave_interval = 3600
|
||||
wave_defense.wave_number = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user