mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-17 20:58:13 +02:00
update
This commit is contained in:
parent
f4c5a315a6
commit
0d80cad631
@ -35,18 +35,18 @@ local function desert(surface, room)
|
||||
for key, tile in pairs(room.room_tiles) do
|
||||
surface.set_tiles({{name = "sand-3", position = tile.position}}, true)
|
||||
if math_random(1, 64) == 1 then
|
||||
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = math_random(250, 500) + global.dungeons.depth * 2})
|
||||
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = math_random(250, 500) + global.dungeons.depth * 3})
|
||||
else
|
||||
if math_random(1, 128) == 1 then
|
||||
surface.create_entity({name = trees[math_random(1, size_of_trees)], position = tile.position})
|
||||
end
|
||||
end
|
||||
if key % 128 == 0 and math_random(1, 3) == 1 then
|
||||
surface.create_entity({name = "biter-spawner", position = tile.position})
|
||||
surface.create_entity({name = "biter-spawner", position = tile.position, force = "enemy"})
|
||||
end
|
||||
if math_random(1, 128) == 1 then
|
||||
local turret_name = worms[math_random(1, size_of_worms)] .. "-worm-turret"
|
||||
surface.create_entity({name = turret_name, position = tile.position})
|
||||
surface.create_entity({name = turret_name, position = tile.position, force = "enemy"})
|
||||
end
|
||||
if math_random(1, 16) == 1 then
|
||||
surface.create_entity({name = "mineable-wreckage", position = tile.position})
|
||||
|
@ -32,18 +32,18 @@ local function dirtlands(surface, room)
|
||||
for key, tile in pairs(room.room_tiles) do
|
||||
surface.set_tiles({{name = "dirt-7", position = tile.position}}, true)
|
||||
if math_random(1, 64) == 1 then
|
||||
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = math_random(250, 500) + global.dungeons.depth * 2})
|
||||
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = math_random(250, 500) + global.dungeons.depth * 3})
|
||||
else
|
||||
if math_random(1, 128) == 1 then
|
||||
surface.create_entity({name = trees[math_random(1, size_of_trees)], position = tile.position})
|
||||
end
|
||||
end
|
||||
if key % 128 == 0 and math_random(1, 2) == 1 then
|
||||
surface.create_entity({name = "biter-spawner", position = tile.position})
|
||||
surface.create_entity({name = "biter-spawner", position = tile.position, force = "enemy"})
|
||||
end
|
||||
if math_random(1, 256) == 1 then
|
||||
if math_random(1, 320) == 1 then
|
||||
local turret_name = worms[math_random(1, size_of_worms)] .. "-worm-turret"
|
||||
surface.create_entity({name = turret_name, position = tile.position})
|
||||
surface.create_entity({name = turret_name, position = tile.position, force = "enemy"})
|
||||
end
|
||||
if math_random(1, 512) == 1 then
|
||||
surface.create_entity({name = "mineable-wreckage", position = tile.position})
|
||||
|
@ -25,7 +25,7 @@ local function grasslands(surface, room)
|
||||
for key, tile in pairs(room.room_tiles) do
|
||||
surface.set_tiles({{name = "grass-2", position = tile.position}}, true)
|
||||
if math_random(1, 64) == 1 then
|
||||
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = math_random(250, 500) + global.dungeons.depth * 2})
|
||||
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = math_random(250, 500) + global.dungeons.depth * 3})
|
||||
else
|
||||
if math_random(1, 24) == 1 then
|
||||
surface.create_entity({name = trees[math_random(1, size_of_trees)], position = tile.position})
|
||||
|
@ -31,11 +31,14 @@ local function red_desert(surface, room)
|
||||
surface.create_entity({name = trees[math_random(1, size_of_trees)], position = tile.position})
|
||||
end
|
||||
end
|
||||
if key % 16 == 0 and math_random(1, 32) == 1 then
|
||||
surface.create_entity({name = "biter-spawner", position = tile.position, force = "enemy"})
|
||||
end
|
||||
if math_random(1, 256) == 1 then
|
||||
local turret_name = worms[math_random(1, size_of_worms)] .. "-worm-turret"
|
||||
surface.create_entity({name = turret_name, position = tile.position})
|
||||
surface.create_entity({name = turret_name, position = tile.position, force = "enemy"})
|
||||
end
|
||||
if math_random(1, 5) == 1 then
|
||||
if math_random(1, 32) == 1 then
|
||||
surface.create_entity({name = "rock-huge", position = tile.position})
|
||||
end
|
||||
end
|
||||
@ -61,11 +64,19 @@ local function red_desert(surface, room)
|
||||
if key < 9 then
|
||||
surface.create_entity({name = "rock-big", position = tile.position})
|
||||
else
|
||||
if math_random(1, 8) == 1 then
|
||||
surface.create_entity({name = trees[math_random(1, size_of_trees)], position = tile.position})
|
||||
if math_random(1, 3) > 1 then
|
||||
surface.create_entity({name = "rock-huge", position = tile.position})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if room.entrance_tile then
|
||||
local p = room.entrance_tile.position
|
||||
local area = {{p.x - 0.5, p.y - 0.5}, {p.x + 0.5, p.y + 0.5}}
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = area})) do
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return red_desert
|
@ -1,8 +1,11 @@
|
||||
-- Deep dark dungeons by mewmew --
|
||||
|
||||
require "modules.mineable_wreckage_yields_scrap"
|
||||
require "modules.biters_yield_ore"
|
||||
require "modules.rpg"
|
||||
|
||||
local Room_generator = require "functions.room_generator"
|
||||
local BiterHealthBooster = require "modules.biter_health_booster"
|
||||
|
||||
local Biomes = {}
|
||||
Biomes.dirtlands = require "maps.dungeons.biome_dirtlands"
|
||||
@ -20,6 +23,7 @@ local table_insert = table.insert
|
||||
local table_remove = table.remove
|
||||
local math_random = math.random
|
||||
local math_abs = math.abs
|
||||
local math_floor = math.floor
|
||||
|
||||
local disabled_for_deconstruction = {
|
||||
["fish"] = true,
|
||||
@ -35,10 +39,10 @@ local function get_biome(position)
|
||||
|
||||
if Get_noise("dungeons", position, seed + seed_addition * 1) > 0.59 then return "glitch" end
|
||||
if Get_noise("dungeons", position, seed + seed_addition * 2) > 0.48 then return "doom" end
|
||||
if Get_noise("dungeons", position, seed + seed_addition * 3) > 0.35 then return "red_desert" end
|
||||
if Get_noise("dungeons", position, seed + seed_addition * 4) > 0.21 then return "grasslands" end
|
||||
if Get_noise("dungeons", position, seed + seed_addition * 3) > 0.21 then return "grasslands" end
|
||||
if Get_noise("dungeons", position, seed + seed_addition * 4) > 0.35 then return "red_desert" end
|
||||
if Get_noise("dungeons", position, seed + seed_addition * 5) > 0.25 then return "desert" end
|
||||
if Get_noise("dungeons", position, seed + seed_addition * 6) > 0.60 then return "concrete" end
|
||||
if Get_noise("dungeons", position, seed + seed_addition * 6) > 0.75 then return "concrete" end
|
||||
|
||||
return "dirtlands"
|
||||
end
|
||||
@ -104,6 +108,42 @@ local function on_chunk_generated(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_spawned(event)
|
||||
local spawner = event.spawner
|
||||
local unit = event.entity
|
||||
local unit_2 = spawner.surface.create_entity({name = unit.name, position = unit.position, force = "enemy"})
|
||||
unit_2.ai_settings.allow_try_return_to_spawner = true
|
||||
unit_2.ai_settings.allow_destroy_when_commands_fail = false
|
||||
|
||||
local spawner_tier = global.dungeons.spawner_tier
|
||||
if not spawner_tier[spawner.unit_number] then
|
||||
local tier = math_floor(global.dungeons.depth * 0.05 - math_random(1, 4))
|
||||
if tier < 1 then tier = 1 end
|
||||
spawner_tier[spawner.unit_number] = tier
|
||||
|
||||
rendering.draw_text{
|
||||
text = "-Tier " .. tier .. "-",
|
||||
surface = spawner.surface,
|
||||
target = spawner,
|
||||
target_offset = {0, -3.25},
|
||||
color = {25, 0, 100, 255},
|
||||
scale = 1.50,
|
||||
font = "default-game",
|
||||
alignment = "center",
|
||||
scale_with_zoom = false
|
||||
}
|
||||
end
|
||||
|
||||
local health_multiplier = (spawner_tier[spawner.unit_number] + 4) * 0.25
|
||||
|
||||
if math_random(1, 32) == 1 then
|
||||
BiterHealthBooster.add_boss_unit(unit, health_multiplier * 8, 0.25)
|
||||
else
|
||||
BiterHealthBooster.add_unit(unit, health_multiplier)
|
||||
end
|
||||
BiterHealthBooster.add_unit(unit_2, health_multiplier)
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
local surface = game.surfaces["dungeons"]
|
||||
@ -121,6 +161,15 @@ local function on_player_mined_entity(event)
|
||||
expand(entity.surface, entity.position)
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
|
||||
if entity.type == "unit" and entity.spawner then
|
||||
entity.spawner.damage(16, game.forces[1])
|
||||
end
|
||||
end
|
||||
|
||||
local function on_marked_for_deconstruction(event)
|
||||
if disabled_for_deconstruction[event.entity.name] then
|
||||
event.entity.cancel_deconstruction(game.players[event.player_index].force.name)
|
||||
@ -157,6 +206,10 @@ local function on_init()
|
||||
|
||||
global.dungeons = {}
|
||||
global.dungeons.depth = 0
|
||||
global.dungeons.spawner_tier = {}
|
||||
|
||||
global.rocks_yield_ore_base_amount = 50
|
||||
global.rocks_yield_ore_distance_modifier = 0.001
|
||||
end
|
||||
|
||||
local Event = require 'utils.event'
|
||||
@ -165,4 +218,8 @@ Event.add(defines.events.on_tick, on_tick)
|
||||
Event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
|
||||
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_chunk_generated, on_chunk_generated)
|
||||
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
Event.add(defines.events.on_entity_spawned, on_entity_spawned)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
|
||||
require "modules.rocks_yield_ore"
|
@ -1,5 +1,6 @@
|
||||
require "modules.sticky_landfill"
|
||||
require "modules.dynamic_player_spawn"
|
||||
require "modules.biters_yield_ore"
|
||||
|
||||
local math_random = math.random
|
||||
local math_floor = math.floor
|
||||
@ -11,41 +12,6 @@ local math_abs = math.abs
|
||||
|
||||
local map_height = 96
|
||||
|
||||
local drop_values = {
|
||||
["small-spitter"] = 8,
|
||||
["small-biter"] = 8,
|
||||
["medium-spitter"] = 16,
|
||||
["medium-biter"] = 16,
|
||||
["big-spitter"] = 32,
|
||||
["big-biter"] = 32,
|
||||
["behemoth-spitter"] = 96,
|
||||
["behemoth-biter"] = 96,
|
||||
["small-worm-turret"] = 128,
|
||||
["medium-worm-turret"] = 160,
|
||||
["big-worm-turret"] = 196,
|
||||
["behemoth-worm-turret"] = 256,
|
||||
["biter-spawner"] = 640,
|
||||
["spitter-spawner"] = 640
|
||||
}
|
||||
|
||||
local drop_raffle = {}
|
||||
for _ = 1, 64, 1 do table_insert(drop_raffle, "iron-ore") end
|
||||
for _ = 1, 40, 1 do table_insert(drop_raffle, "copper-ore") end
|
||||
for _ = 1, 32, 1 do table_insert(drop_raffle, "stone") end
|
||||
for _ = 1, 32, 1 do table_insert(drop_raffle, "coal") end
|
||||
for _ = 1, 6, 1 do table_insert(drop_raffle, "wood") end
|
||||
for _ = 1, 4, 1 do table_insert(drop_raffle, "landfill") end
|
||||
for _ = 1, 3, 1 do table_insert(drop_raffle, "uranium-ore") end
|
||||
local size_of_drop_raffle = #drop_raffle
|
||||
|
||||
local drop_vectors = {}
|
||||
for x = -2, 2, 0.1 do
|
||||
for y = -2, 2, 0.1 do
|
||||
table_insert(drop_vectors, {x, y})
|
||||
end
|
||||
end
|
||||
local size_of_drop_vectors = #drop_vectors
|
||||
|
||||
local infini_ores = {"iron-ore", "iron-ore", "copper-ore", "coal", "stone"}
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
@ -119,10 +85,7 @@ local function on_entity_died(event)
|
||||
|
||||
if entity.type == "unit" and entity.spawner then
|
||||
entity.spawner.damage(20, game.forces[1])
|
||||
end
|
||||
|
||||
if not drop_values[entity.name] then return end
|
||||
table_insert(global.drop_schedule, {{entity.position.x, entity.position.y}, drop_values[entity.name]})
|
||||
end
|
||||
end
|
||||
|
||||
local function is_out_of_map(p)
|
||||
@ -294,23 +257,7 @@ local function send_tick_wave()
|
||||
send_wave(spawners[math_random(1, #spawners)], search_radius)
|
||||
end
|
||||
|
||||
local function drop_schedule()
|
||||
local surface = game.surfaces["railway_troopers"]
|
||||
for key, entry in pairs(global.drop_schedule) do
|
||||
for _ = 1, 3, 1 do
|
||||
local vector = drop_vectors[math_random(1, size_of_drop_vectors)]
|
||||
surface.spill_item_stack({entry[1][1] + vector[1], entry[1][2] + vector[2]}, {name = drop_raffle[math_random(1, size_of_drop_raffle)], count = 1}, true)
|
||||
global.drop_schedule[key][2] = global.drop_schedule[key][2] - 1
|
||||
if global.drop_schedule[key][2] <= 0 then
|
||||
table_remove(global.drop_schedule, key)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_tick()
|
||||
drop_schedule()
|
||||
send_tick_wave()
|
||||
end
|
||||
|
||||
|
68
modules/biters_yield_ore.lua
Normal file
68
modules/biters_yield_ore.lua
Normal file
@ -0,0 +1,68 @@
|
||||
local table_insert = table.insert
|
||||
local table_remove = table.remove
|
||||
local math_random = math.random
|
||||
|
||||
local drop_raffle = {}
|
||||
for _ = 1, 64, 1 do table_insert(drop_raffle, "iron-ore") end
|
||||
for _ = 1, 40, 1 do table_insert(drop_raffle, "copper-ore") end
|
||||
for _ = 1, 32, 1 do table_insert(drop_raffle, "stone") end
|
||||
for _ = 1, 32, 1 do table_insert(drop_raffle, "coal") end
|
||||
for _ = 1, 6, 1 do table_insert(drop_raffle, "wood") end
|
||||
for _ = 1, 2, 1 do table_insert(drop_raffle, "landfill") end
|
||||
for _ = 1, 3, 1 do table_insert(drop_raffle, "uranium-ore") end
|
||||
local size_of_drop_raffle = #drop_raffle
|
||||
|
||||
local drop_vectors = {}
|
||||
for x = -2, 2, 0.1 do
|
||||
for y = -2, 2, 0.1 do
|
||||
table_insert(drop_vectors, {x, y})
|
||||
end
|
||||
end
|
||||
local size_of_drop_vectors = #drop_vectors
|
||||
|
||||
local drop_values = {
|
||||
["small-spitter"] = 8,
|
||||
["small-biter"] = 8,
|
||||
["medium-spitter"] = 16,
|
||||
["medium-biter"] = 16,
|
||||
["big-spitter"] = 32,
|
||||
["big-biter"] = 32,
|
||||
["behemoth-spitter"] = 96,
|
||||
["behemoth-biter"] = 96,
|
||||
["small-worm-turret"] = 128,
|
||||
["medium-worm-turret"] = 160,
|
||||
["big-worm-turret"] = 196,
|
||||
["behemoth-worm-turret"] = 256,
|
||||
["biter-spawner"] = 512,
|
||||
["spitter-spawner"] = 512
|
||||
}
|
||||
|
||||
local function on_tick()
|
||||
for key, entry in pairs(global.biters_drop_ore) do
|
||||
local surface = game.surfaces[entry[3]]
|
||||
for _ = 1, 3, 1 do
|
||||
local vector = drop_vectors[math_random(1, size_of_drop_vectors)]
|
||||
surface.spill_item_stack({entry[1][1] + vector[1], entry[1][2] + vector[2]}, {name = drop_raffle[math_random(1, size_of_drop_raffle)], count = 1}, true)
|
||||
global.biters_drop_ore[key][2] = global.biters_drop_ore[key][2] - 1
|
||||
if global.biters_drop_ore[key][2] <= 0 then
|
||||
table_remove(global.biters_drop_ore, key)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not drop_values[entity.name] then return end
|
||||
table_insert(global.biters_drop_ore, {{entity.position.x, entity.position.y}, drop_values[entity.name], entity.surface.index})
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
global.biters_drop_ore = {}
|
||||
end
|
||||
|
||||
local Event = require 'utils.event'
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_tick, on_tick)
|
Loading…
x
Reference in New Issue
Block a user