1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-22 03:38:48 +02:00

Merge pull request #186 from hanakocz/master

MultiDungeons
This commit is contained in:
Gerkiz 2020-07-31 23:35:27 +02:00 committed by GitHub
commit 586ad177b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 1602 additions and 264 deletions

View File

@ -80,6 +80,7 @@ require 'modules.autostash'
--require 'maps.mountain_fortress_v2.main'
--require 'maps.lumberjack.main'
--require 'maps.dungeons.main'
--require 'maps.dungeons.tiered_dungeon'
--require 'maps.expanse.main'
--require 'maps.island_troopers.main'
--require 'maps.biter_hatchery.main'

View File

@ -63,6 +63,35 @@ boss_message=Boss Wave __1__ - - __2__
map_info_main_caption=D U N G E O N S
map_info_sub_caption= ~You put your robe and wizard hat on. You are still in a dungeon.~
map_info_text=Expand into the depths for treasure.\nEverytime a new room is discovered, the depth-meter in your left top will increase.\n\nEnemies get more chonky.\nResources yield more ore.\nLoot gets more shiny.\n\nYou can use the green smelly dungeon sewers for long range transports.\n\nHow far can you make it?
depth=~ Depth __1__ ~
depth_tooltip=Evolution: __1__%\nEnemy Health: __2__%\nEnemy Damage: __3__%
[dungeons_tiered]
map_info_main_caption=D U N G E O N S
map_info_sub_caption= ~You put your robe and wizard hat on. You are still in a dungeon.~
map_info_text=Expand into the depths for treasure.\nEverytime a new room is discovered, the depth-meter in your left top will increase.\n\nEnemies get more chonky.\nResources yield more ore.\nLoot gets more shiny.\n\nBut for real challenge and real shinies, you need to go also deeper.\nUse arrow buttons on top to change floors!\n\nHow far can you make it?
descend=Descend to lower floor.\nEach floor has stronger enemies and better treasure.\nRIGHT-CLICK: Descend 5 floors.\nSHIFT-CLICK: Desscend to lowest accessible Floor.
ascend=Ascend to higher floor.\nRIGHT-CLICK: Ascend 5 floors.\nSHIFT-CLICK: Ascend to Floor 0.
depth=~ Floor __1__ | Depth __2__ ~
depth_tooltip=Evolution: __1__%\nEnemy Health: __2__%\nEnemy Damage: __3__%\nLoot Value: __4__\nTreasure rooms found: __5__ / 5\nHidden Technologies: __6__
max_depth=You are on deepest level already!
min_depth=You are on highest level already!
only_on_spawn=You can change floors only on spawn.
level_required=You need level __1__ for travelling to next floor!
floor_size_required=You need to explore at least 60 rooms on this floor to access next floor!
travel_down=You have descended to deeper part of dungeon.
travel_up=You have ascended to previous part of dungeon.
first_visit=__1__ [lvl __2__] was first to reach Floor __3__!
too_small=The dungeon needs to be bigger for continuing in this direction.
treasure_room=Treasure room was found on Floor __1__!
tech_unlock=__1__ unlock was found on Floor __2__!
boss_arena=!!Dungeon Bosses!!\nRequires level 5 to join.\n\nCurrent boss level: __1__\nBoss bonus HP: __2__%\nBoss bonus damage: __3__%\nRewards: cca __4__ XP\n\nUp to four players can fight at once.
arena_occupied=Arena is in use! Wait for previous player to end his fight!
arena_level_needed=You need level 5 to join the arena!
robots_following=You cannot enter arena with robots following you!
arena_level_max=You defeated all the bosses already!
player_lost=[ARENA]: __1__ lost his battle to Boss lvl __2__!
player_won=[ARENA]: __1__ defeated the Boss lvl __2__!
[mountain_fortress]
map_info_main_caption=M O U N T A I N F O R T R E S S

View File

@ -12,36 +12,36 @@ local math_floor = math.floor
local function add_enemy_units(surface, room)
for _, tile in pairs(room.room_tiles) do
if math_random(1, 2) == 1 then
local name = BiterRaffle.roll("spitter", Functions.get_dungeon_evolution_factor() * 1.5)
local unit = surface.create_entity({name = name, position = tile.position, force = "enemy"})
local name = BiterRaffle.roll("spitter", Functions.get_dungeon_evolution_factor(surface.index) * 1.5)
local unit = surface.create_entity({name = name, position = tile.position, force = global.enemy_forces[surface.index]})
end
end
end
end
local function acid_zone(surface, room)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "concrete", position = tile.position}}, true)
end
if not room.room_border_tiles[1] then return end
table_shuffle_table(room.room_tiles)
for key, tile in pairs(room.room_tiles) do
surface.set_tiles({{name = "green-refined-concrete", position = tile.position}}, true)
if math_random(1, 16) == 1 then
surface.create_entity({name = "uranium-ore", position = tile.position, amount = Functions.get_common_resource_amount()})
surface.create_entity({name = "uranium-ore", position = tile.position, amount = Functions.get_common_resource_amount(surface.index)})
end
if math_random(1, 96) == 1 then
surface.create_entity({name = Functions.roll_worm_name(), position = tile.position})
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
end
if math_random(1, 128) == 1 then
Functions.crash_site_chest(surface, tile.position)
end
end
if key % 128 == 1 and math_random(1, 3) == 1 then
Functions.set_spawner_tier(surface.create_entity({name = "spitter-spawner", position = tile.position, force = "enemy"}))
Functions.set_spawner_tier(surface.create_entity({name = "spitter-spawner", position = tile.position, force = global.enemy_forces[surface.index]}), surface.index)
end
end
if room.center then
if math_random(1, 4) == 1 then
local r = math_floor(math_sqrt(#room.room_tiles) * 0.125) + 1
@ -54,21 +54,21 @@ local function acid_zone(surface, room)
end
end
end
end
end
end
table_shuffle_table(room.room_border_tiles)
for key, tile in pairs(room.room_border_tiles) do
surface.set_tiles({{name = "refined-hazard-concrete-left", position = tile.position}}, true)
end
for key, tile in pairs(room.room_border_tiles) do
if key % 8 == 1 then
Functions.place_border_rock(surface, tile.position)
end
end
add_enemy_units(surface, room)
end
return acid_zone
return acid_zone

View File

@ -12,38 +12,38 @@ local math_floor = math.floor
local function add_enemy_units(surface, room)
for _, tile in pairs(room.room_tiles) do
if math_random(1, 2) == 1 then
local name = BiterRaffle.roll("biter", Functions.get_dungeon_evolution_factor() * 1.5)
local unit = surface.create_entity({name = name, position = tile.position, force = "enemy"})
local name = BiterRaffle.roll("biter", Functions.get_dungeon_evolution_factor(surface.index) * 1.5)
local unit = surface.create_entity({name = name, position = tile.position, force = global.enemy_forces[surface.index]})
end
end
end
end
local function concrete(surface, room)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "concrete", position = tile.position}}, true)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "concrete", position = tile.position}}, true)
end
if not room.room_border_tiles[1] then return end
table_shuffle_table(room.room_tiles)
for key, tile in pairs(room.room_tiles) do
surface.set_tiles({{name = "stone-path", position = tile.position}}, true)
if math_random(1, 16) == 1 then
surface.create_entity({name = "iron-ore", position = tile.position, amount = Functions.get_common_resource_amount()})
surface.create_entity({name = "iron-ore", position = tile.position, amount = Functions.get_common_resource_amount(surface.index)})
end
if math_random(1, 128) == 1 then
Functions.crash_site_chest(surface, tile.position)
end
if key % 128 == 1 and math_random(1, 3) == 1 then
Functions.set_spawner_tier(surface.create_entity({name = "biter-spawner", position = tile.position, force = "enemy"}))
Functions.set_spawner_tier(surface.create_entity({name = "biter-spawner", position = tile.position, force = global.enemy_forces[surface.index]}), surface.index)
end
end
table_shuffle_table(room.room_border_tiles)
for key, tile in pairs(room.room_border_tiles) do
surface.set_tiles({{name = "refined-concrete", position = tile.position}}, true)
end
for key, tile in pairs(room.room_border_tiles) do
if key % 8 == 1 then
Functions.place_border_rock(surface, tile.position)
@ -51,7 +51,7 @@ local function concrete(surface, room)
surface.create_entity({name = "stone-wall", position = tile.position, force = "dungeon"})
end
end
if room.entrance_tile then
local p = room.entrance_tile.position
local area = {{p.x - 1, p.y - 1}, {p.x + 1.5, p.y + 1.5}}
@ -59,8 +59,8 @@ local function concrete(surface, room)
entity.destroy()
end
end
add_enemy_units(surface, room)
end
return concrete
return concrete

View File

@ -13,10 +13,10 @@ local function horizontal_water_barrier(surface, room)
local a = room.radius * 2
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
local center_position = room.center
for x = 0, a , 1 do
for y = 0, a, 1 do
local p = {x = left_top.x + x, y = left_top.y + y}
local p = {x = left_top.x + x, y = left_top.y + y}
if math_abs(p.y - center_position.y) < room.radius * 0.4 then
surface.set_tiles({{name = "water", position = p}})
if math_random(1, 16) == 1 then surface.create_entity({name = "fish", position = p}) end
@ -29,10 +29,10 @@ local function vertical_water_barrier(surface, room)
local a = room.radius * 2
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
local center_position = room.center
for x = 0, a , 1 do
for y = 0, a, 1 do
local p = {x = left_top.x + x, y = left_top.y + y}
local p = {x = left_top.x + x, y = left_top.y + y}
if math_abs(p.x - center_position.x) < room.radius * 0.4 then
surface.set_tiles({{name = "water", position = p}})
if math_random(1, 16) == 1 then surface.create_entity({name = "fish", position = p}) end
@ -45,10 +45,10 @@ local function vertical_bridge(surface, room)
local a = room.radius * 2
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
local center_position = room.center
for x = 0, a , 1 do
for y = 0, a, 1 do
local p = {x = left_top.x + x, y = left_top.y + y}
local p = {x = left_top.x + x, y = left_top.y + y}
if math_abs(p.x - center_position.x) > room.radius * 0.4 then
surface.set_tiles({{name = "water", position = p}})
if math_random(1, 16) == 1 then surface.create_entity({name = "fish", position = p}) end
@ -61,10 +61,10 @@ local function horizontal_bridge(surface, room)
local a = room.radius * 2
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
local center_position = room.center
for x = 0, a , 1 do
for y = 0, a, 1 do
local p = {x = left_top.x + x, y = left_top.y + y}
local p = {x = left_top.x + x, y = left_top.y + y}
if math_abs(p.y - center_position.y) > room.radius * 0.4 then
surface.set_tiles({{name = "water", position = p}})
if math_random(1, 16) == 1 then surface.create_entity({name = "fish", position = p}) end
@ -77,10 +77,10 @@ local function island(surface, room)
local a = room.radius * 2
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
local center_position = room.center
for x = 0, a , 1 do
for y = 0, a, 1 do
local p = {x = left_top.x + x, y = left_top.y + y}
local p = {x = left_top.x + x, y = left_top.y + y}
if math_abs(p.x - center_position.x) < room.radius * 0.6 and math_abs(p.y - center_position.y) < room.radius * 0.6 then
else
surface.set_tiles({{name = "water", position = p}})
@ -94,10 +94,10 @@ local function cross(surface, room)
local a = room.radius * 2
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
local center_position = room.center
for x = 0, a , 1 do
for y = 0, a, 1 do
local p = {x = left_top.x + x, y = left_top.y + y}
local p = {x = left_top.x + x, y = left_top.y + y}
if math_abs(p.x - center_position.x) > room.radius * 0.33 and math_abs(p.y - center_position.y) > room.radius * 0.33 then
surface.set_tiles({{name = "water", position = p}})
if math_random(1, 16) == 1 then surface.create_entity({name = "fish", position = p}) end
@ -110,10 +110,10 @@ local function cross_inverted(surface, room)
local a = room.radius * 2
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
local center_position = room.center
for x = 0, a , 1 do
for y = 0, a, 1 do
local p = {x = left_top.x + x, y = left_top.y + y}
local p = {x = left_top.x + x, y = left_top.y + y}
if math_abs(p.x - center_position.x) > room.radius * 0.33 and math_abs(p.y - center_position.y) > room.radius * 0.33 then
else
surface.set_tiles({{name = "water", position = p}})
@ -127,15 +127,15 @@ local function squares(surface, room)
local r_min = 0
local r_max = room.radius * 2
local center_position = room.center
local tiles = {}
for _, tile in pairs(room.room_border_tiles) do table_insert(tiles, tile) end
for _, tile in pairs(room.room_tiles) do table_insert(tiles, tile) end
for _ = 1, math_random(1, 6), 1 do
local a = math_random(r_min, r_max)
local b = math_random(r_min, r_max)
local square_left_top = tiles[math_random(1, #tiles)].position
local square_left_top = tiles[math_random(1, #tiles)].position
for x = 0, a , 1 do
for y = 0, b, 1 do
local p = {x = square_left_top.x + x, y = square_left_top.y + y}
@ -144,7 +144,7 @@ local function squares(surface, room)
surface.set_tiles({{name = "water", position = p}})
else
surface.set_tiles({{name = "deepwater", position = p}})
end
end
if math_random(1, 16) == 1 then surface.create_entity({name = "fish", position = p}) end
end
end
@ -167,39 +167,39 @@ local function biome(surface, room)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "concrete", position = tile.position}}, true)
end
if not room.room_border_tiles[1] then return end
table_shuffle_table(room.room_tiles)
for key, tile in pairs(room.room_tiles) do
surface.set_tiles({{name = "blue-refined-concrete", position = tile.position}}, true)
end
table_shuffle_table(room.room_border_tiles)
for key, tile in pairs(room.room_border_tiles) do
surface.set_tiles({{name = "cyan-refined-concrete", position = tile.position}}, true)
end
water_shapes[math_random(1, #water_shapes)](surface, room)
for key, tile in pairs(room.room_tiles) do
local tile = surface.get_tile(tile.position)
if not tile.collides_with("resource-layer") then
if not tile.collides_with("resource-layer") then
if math_random(1, 10) == 1 then
surface.create_entity({name = "stone", position = tile.position, amount = Functions.get_common_resource_amount()})
surface.create_entity({name = "stone", position = tile.position, amount = Functions.get_common_resource_amount(surface.index)})
end
if math_random(1, 320) == 1 then
Functions.crash_site_chest(surface, tile.position)
end
end
if key % 64 == 1 and math_random(1, 2) == 1 then
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = "enemy"}))
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = global.enemy_forces[surface.index]}), surface.index)
end
if math_random(1, 64) == 1 then
surface.create_entity({name = Functions.roll_worm_name(), position = tile.position})
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
end
end
end
for key, tile in pairs(room.room_border_tiles) do
if key % 8 == 1 then
Functions.place_border_rock(surface, tile.position)
@ -207,4 +207,4 @@ local function biome(surface, room)
end
end
return biome
return biome

View File

@ -22,7 +22,7 @@ local function draw_deco(surface, position, decorative_name, seed)
end
local function draw_room_decoratives(surface, room)
local seed = game.surfaces[1].map_gen_settings.seed + math_random(1, 1000000)
local seed = game.surfaces[surface.index].map_gen_settings.seed + math_random(1, 1000000)
local decorative_name = decoratives[math_random(1, #decoratives)]
for _, tile in pairs(room.path_tiles) do draw_deco(surface, tile.position, decorative_name, seed) end
for _, tile in pairs(room.room_border_tiles) do draw_deco(surface, tile.position, decorative_name, seed) end
@ -38,35 +38,35 @@ local function desert(surface, room)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "sand-2", position = tile.position}}, true)
end
if not room.room_tiles[1] then draw_room_decoratives(surface, room) return end
table_shuffle_table(room.room_border_tiles)
for key, tile in pairs(room.room_border_tiles) do
surface.set_tiles({{name = "sand-1", position = tile.position}}, true)
end
local seed = game.surfaces[1].map_gen_settings.seed + math_random(1, 1000000)
local seed = game.surfaces[surface.index].map_gen_settings.seed + math_random(1, 1000000)
local decorative_name = decoratives[math_random(1, #decoratives)]
table_shuffle_table(room.room_tiles)
for key, tile in pairs(room.room_tiles) do
surface.set_tiles({{name = "sand-3", position = tile.position}}, true)
if math_random(1, 16) == 1 and Get_noise("n3", tile.position, seed) > 0.1 then
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = Functions.get_common_resource_amount()})
if math_random(1, 16) == 1 and Get_noise("n3", tile.position, seed) > 0.1 then
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = Functions.get_common_resource_amount(surface.index)})
else
if math_random(1, 320) == 1 then
surface.create_entity({name = "crude-oil", position = tile.position, amount = Functions.get_crude_oil_amount()})
surface.create_entity({name = "crude-oil", position = tile.position, amount = Functions.get_crude_oil_amount(surface.index)})
end
if math_random(1, 64) == 1 then
surface.create_entity({name = trees[math_random(1, size_of_trees)], position = tile.position})
end
end
if key % 128 == 1 and math_random(1, 3) == 1 then
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = "enemy"}))
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = global.enemy_forces[surface.index]}), surface.index)
end
if math_random(1, 160) == 1 then
surface.create_entity({name = Functions.roll_worm_name(), position = tile.position, force = "enemy"})
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
end
local noise = Get_noise("decoratives", tile.position, seed)
if math_random(1, 3) > 1 and math_abs(noise) > 0.52 then
@ -76,9 +76,9 @@ local function desert(surface, room)
surface.create_entity({name = "rock-huge", position = tile.position})
end
end
Functions.add_room_loot_crates(surface, room)
if room.center then
if math_random(1, 64) == 1 then
for x = -1, 1, 1 do
@ -90,17 +90,17 @@ local function desert(surface, room)
end
end
end
end
end
end
for key, tile in pairs(room.room_border_tiles) do
if key % 8 == 1 then
Functions.place_border_rock(surface, tile.position)
end
end
draw_room_decoratives(surface, room)
add_enemy_units(surface, room)
end
return desert
return desert

View File

@ -22,7 +22,7 @@ local function draw_deco(surface, position, decorative_name, seed)
end
local function draw_room_decoratives(surface, room)
local seed = game.surfaces[1].map_gen_settings.seed + math_random(1, 1000000)
local seed = game.surfaces[surface.index].map_gen_settings.seed + math_random(1, 1000000)
local decorative_name = decoratives[math_random(1, #decoratives)]
for _, tile in pairs(room.path_tiles) do draw_deco(surface, tile.position, decorative_name, seed) end
for _, tile in pairs(room.room_border_tiles) do draw_deco(surface, tile.position, decorative_name, seed) end
@ -39,27 +39,27 @@ local function dirtlands(surface, room)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = path_tile, position = tile.position}}, true)
end
if not room.room_border_tiles[1] then draw_room_decoratives(surface, room) return end
table_shuffle_table(room.room_tiles)
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 = Functions.get_common_resource_amount()})
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = Functions.get_common_resource_amount(surface.index)})
else
if math_random(1, 2048) == 1 then
surface.create_entity({name = "crude-oil", position = tile.position, amount = Functions.get_crude_oil_amount()})
surface.create_entity({name = "crude-oil", position = tile.position, amount = Functions.get_crude_oil_amount(surface.index)})
end
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 == 1 and math_random(1, 2) == 1 and global.dungeons.depth > 8 then
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = "enemy"}))
end
if math_random(1, 320) == 1 and global.dungeons.depth > 8 then
surface.create_entity({name = Functions.roll_worm_name(), position = tile.position, force = "enemy"})
if key % 128 == 1 and math_random(1, 2) == 1 and global.dungeons.depth[surface.index] > 8 then
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = global.enemy_forces[surface.index]}), surface.index)
end
if math_random(1, 320) == 1 and global.dungeons.depth[surface.index] > 8 then
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
end
if math_random(1, 512) == 1 then
surface.create_entity({name = "mineable-wreckage", position = tile.position})
@ -68,9 +68,9 @@ local function dirtlands(surface, room)
surface.create_entity({name = "rock-huge", position = tile.position})
end
end
Functions.add_room_loot_crates(surface, room)
if room.center then
if math_random(1, 16) == 1 then
for x = -1, 1, 1 do
@ -82,23 +82,23 @@ local function dirtlands(surface, room)
end
end
end
end
end
end
table_shuffle_table(room.room_border_tiles)
for key, tile in pairs(room.room_border_tiles) do
surface.set_tiles({{name = "dirt-4", position = tile.position}}, true)
end
for key, tile in pairs(room.room_border_tiles) do
if key % 8 == 1 then
Functions.place_border_rock(surface, tile.position)
end
end
draw_room_decoratives(surface, room)
draw_room_decoratives(surface, room)
add_enemy_units(surface, room)
end
return dirtlands
return dirtlands

View File

@ -17,15 +17,15 @@ local function doom(surface, room)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "refined-concrete", position = tile.position}}, true)
end
if #room.room_tiles > 1 then table_shuffle_table(room.room_tiles) end
for key, tile in pairs(room.room_tiles) do
surface.set_tiles({{name = "red-refined-concrete", position = tile.position}}, true)
if math_random(1, 16) == 1 then
surface.create_entity({name = "copper-ore", position = tile.position, amount = Functions.get_common_resource_amount()})
surface.create_entity({name = "copper-ore", position = tile.position, amount = Functions.get_common_resource_amount(surface.index)})
end
if math_random(1, 16) == 1 then
surface.create_entity({name = Functions.roll_worm_name(), position = tile.position})
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
end
if math_random(1, 320) == 1 then
Functions.rare_loot_crate(surface, tile.position)
@ -33,12 +33,12 @@ local function doom(surface, room)
if math_random(1, 640) == 1 then
Functions.epic_loot_crate(surface, tile.position)
end
end
end
if key % 12 == 1 and math_random(1, 2) == 1 then
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = "enemy"}))
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = global.enemy_forces[surface.index]}), surface.index)
end
end
if room.center then
if math_random(1, 5) == 1 then
local r = math_floor(math_sqrt(#room.room_tiles) * 0.15) + 1
@ -51,21 +51,21 @@ local function doom(surface, room)
end
end
end
end
end
end
if #room.room_border_tiles > 1 then table_shuffle_table(room.room_border_tiles) end
for key, tile in pairs(room.room_border_tiles) do
surface.set_tiles({{name = "black-refined-concrete", position = tile.position}}, true)
end
for key, tile in pairs(room.room_border_tiles) do
if key % 8 == 1 then
Functions.place_border_rock(surface, tile.position)
end
end
add_enemy_units(surface, room)
end
return doom
return doom

View File

@ -9,20 +9,20 @@ local math_abs = math.abs
local ores = {"iron-ore", "copper-ore", "coal", "stone"}
local function glitch(surface, room)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "lab-white", position = tile.position}}, true)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "lab-white", position = tile.position}}, true)
end
if not room.room_border_tiles[1] then return end
table_shuffle_table(room.room_tiles)
for key, tile in pairs(room.room_tiles) do
surface.set_tiles({{name = "lab-dark-1", position = tile.position}}, true)
if math_random(1, 3) == 1 then
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = Functions.get_common_resource_amount()})
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = Functions.get_common_resource_amount(surface.index)})
end
if math_random(1, 12) == 1 then
surface.create_entity({name = Functions.roll_worm_name(), position = tile.position})
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
end
if math_random(1, 96) == 1 then
Functions.common_loot_crate(surface, tile.position)
@ -30,9 +30,9 @@ local function glitch(surface, room)
if math_random(1, 160) == 1 then
Functions.uncommon_loot_crate(surface, tile.position)
end
end
end
end
if room.center then
if math_random(1, 8) == 1 then
for x = -1, 1, 1 do
@ -48,16 +48,16 @@ local function glitch(surface, room)
end
else
if math_random(1, 4) == 1 then
surface.create_entity({name = "crude-oil", position = room.center, amount = Functions.get_crude_oil_amount()})
surface.create_entity({name = "crude-oil", position = room.center, amount = Functions.get_crude_oil_amount(surface.index)})
end
end
end
end
table_shuffle_table(room.room_border_tiles)
for key, tile in pairs(room.room_border_tiles) do
surface.set_tiles({{name = "lab-dark-2", position = tile.position}}, true)
end
for key, tile in pairs(room.room_border_tiles) do
if key % 8 == 1 then
Functions.place_border_rock(surface, tile.position)
@ -65,4 +65,4 @@ local function glitch(surface, room)
end
end
return glitch
return glitch

View File

@ -24,7 +24,7 @@ local function draw_deco(surface, position, decorative_name, seed)
end
local function draw_room_decoratives(surface, room)
local seed = game.surfaces[1].map_gen_settings.seed + math_random(1, 1000000)
local seed = game.surfaces[surface.index].map_gen_settings.seed + math_random(1, 1000000)
local decorative_name = decoratives[math_random(1, #decoratives)]
for _, tile in pairs(room.path_tiles) do draw_deco(surface, tile.position, decorative_name, seed) end
for _, tile in pairs(room.room_border_tiles) do draw_deco(surface, tile.position, decorative_name, seed) end
@ -40,36 +40,36 @@ local function grasslands(surface, room)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "grass-1", position = tile.position}}, true)
end
if not room.room_tiles[1] then draw_room_decoratives(surface, room) return end
local seed = game.surfaces[1].map_gen_settings.seed + math_random(1, 1000000)
local seed = game.surfaces[surface.index].map_gen_settings.seed + math_random(1, 1000000)
local tree_name = trees[math_random(1, size_of_trees)]
table_shuffle_table(room.room_tiles)
for key, tile in pairs(room.room_tiles) do
surface.set_tiles({{name = "grass-2", position = tile.position}}, true)
if math_random(1, 16) == 1 and Get_noise("n3", tile.position, seed) > 0.1 then
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = Functions.get_common_resource_amount()})
if math_random(1, 16) == 1 and Get_noise("n3", tile.position, seed) > 0.1 then
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = Functions.get_common_resource_amount(surface.index)})
else
if math_random(1, math_random(2, 20)) == 1 and math_abs(Get_noise("decoratives", tile.position, seed + 100000)) > 0.2 then
surface.create_entity({name = tree_name, position = tile.position})
end
end
if key % 128 == 1 and math_random(1, 3) == 1 then
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = "enemy"}))
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = global.enemy_forces[surface.index]}), surface.index)
end
if math_random(1, 320) == 1 then
surface.create_entity({name = Functions.roll_worm_name(), position = tile.position})
end
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
end
if math_random(1, 1024) == 1 then
surface.create_entity({name = "rock-huge", position = tile.position})
end
end
end
Functions.add_room_loot_crates(surface, room)
if math_random(1, 4) == 1 then
local r_max = math_floor(room.radius * 0.75)
local r = math_random(1, r_max)
@ -82,23 +82,23 @@ local function grasslands(surface, room)
end
end
end
end
end
table_shuffle_table(room.room_border_tiles)
for key, tile in pairs(room.room_border_tiles) do
surface.set_tiles({{name = "grass-3", position = tile.position}}, true)
end
for key, tile in pairs(room.room_border_tiles) do
if key % 8 == 1 then
Functions.place_border_rock(surface, tile.position)
end
end
draw_room_decoratives(surface, room)
draw_room_decoratives(surface, room)
add_enemy_units(surface, room)
end
return grasslands
return grasslands

View File

@ -0,0 +1,49 @@
local Functions = require "maps.dungeons.functions"
local BiterRaffle = require "functions.biter_raffle"
local Get_noise = require "utils.get_noise"
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
local table_remove = table.remove
local math_random = math.random
local math_abs = math.abs
local math_sqrt = math.sqrt
local math_floor = math.floor
local rainbow_tiles = {
"yellow-refined-concrete", "blue-refined-concrete",
}
local function market(surface, room)
local tiles = {}
for _, tile in pairs(room.path_tiles) do table_insert(tiles, tile) end
for _, tile in pairs(room.room_border_tiles) do table_insert(tiles, tile) end
for _, tile in pairs(room.room_tiles) do table_insert(tiles, tile) end
local seed = game.surfaces[surface.index].map_gen_settings.seed + math_random(1, 1000000)
for _, tile in pairs(tiles) do
surface.set_tiles({{name = rainbow_tiles[math_random(1, 2)], position = tile.position}}, true)
end
if not room.room_border_tiles[1] then return end
table_shuffle_table(room.room_tiles)
for key, tile in pairs(room.room_tiles) do
if key == 1 then
Functions.market(surface, tile.position)
else
if math_random(1, 128) == 1 then
Functions.rare_loot_crate(surface, tile.position, true)
end
end
end
table_shuffle_table(room.room_border_tiles)
for key, tile in pairs(room.room_border_tiles) do
if key % 8 == 1 then
Functions.place_border_rock(surface, tile.position)
end
end
end
return market

View File

@ -24,20 +24,20 @@ local function rainbow(surface, room)
for _, tile in pairs(room.path_tiles) do table_insert(tiles, tile) end
for _, tile in pairs(room.room_border_tiles) do table_insert(tiles, tile) end
for _, tile in pairs(room.room_tiles) do table_insert(tiles, tile) end
local seed = game.surfaces[1].map_gen_settings.seed + math_random(1, 1000000)
local seed = game.surfaces[surface.index].map_gen_settings.seed + math_random(1, 1000000)
for _, tile in pairs(tiles) do
local noise = Get_noise("n3", tile.position, seed)
local index = math_floor(noise * 32) % 8 + 1
surface.set_tiles({{name = rainbow_tiles[index], position = tile.position}}, true)
if math_random(1, 2) == 1 and index % 2 == 0 then
surface.create_entity({name = ores[index * 0.5], position = tile.position, amount = Functions.get_common_resource_amount()})
surface.create_entity({name = ores[index * 0.5], position = tile.position, amount = Functions.get_common_resource_amount(surface.index)})
end
end
if not room.room_border_tiles[1] then return end
table_shuffle_table(room.room_tiles)
for key, tile in pairs(room.room_tiles) do
if math_random(1, 512) == 1 or key == 1 then
@ -48,7 +48,7 @@ local function rainbow(surface, room)
end
end
end
table_shuffle_table(room.room_border_tiles)
for key, tile in pairs(room.room_border_tiles) do
if key % 8 == 1 then
@ -57,4 +57,4 @@ local function rainbow(surface, room)
end
end
return rainbow
return rainbow

View File

@ -21,30 +21,30 @@ local function red_desert(surface, room)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "red-desert-0", position = tile.position}}, true)
end
if #room.room_tiles > 1 then table_shuffle_table(room.room_tiles) end
for key, tile in pairs(room.room_tiles) do
surface.set_tiles({{name = "dry-dirt", position = tile.position}}, true)
if math_random(1, 32) == 1 then
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = Functions.get_common_resource_amount()})
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = Functions.get_common_resource_amount(surface.index)})
else
if math_random(1, 4) == 1 and surface.can_place_entity({name = trees[math_random(1, size_of_trees)], position = tile.position}) then
if math_random(1, 4) == 1 and surface.can_place_entity({name = trees[math_random(1, size_of_trees)], position = tile.position}) then
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
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = "enemy"}))
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = global.enemy_forces[surface.index]}), surface.index)
end
if math_random(1, 256) == 1 then
surface.create_entity({name = Functions.roll_worm_name(), position = tile.position, force = "enemy"})
end
if math_random(1, 32) == 1 then
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
end
if math_random(1, 32) == 1 then
surface.create_entity({name = "rock-huge", position = tile.position})
end
end
Functions.add_room_loot_crates(surface, room)
if room.center then
if math_random(1, 8) == 1 then
local r = math_floor(math_sqrt(#room.room_tiles) * 0.15) + 1
@ -57,14 +57,14 @@ local function red_desert(surface, room)
end
end
end
end
end
end
if #room.room_border_tiles > 1 then table_shuffle_table(room.room_border_tiles) end
for key, tile in pairs(room.room_border_tiles) do
surface.set_tiles({{name = "red-desert-1", position = tile.position}}, true)
end
for key, tile in pairs(room.room_border_tiles) do
if key % 8 == 1 then
Functions.place_border_rock(surface, tile.position)
@ -74,7 +74,7 @@ local function red_desert(surface, room)
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}}
@ -82,8 +82,8 @@ local function red_desert(surface, room)
entity.destroy()
end
end
add_enemy_units(surface, room)
end
return red_desert
return red_desert

View File

@ -0,0 +1,57 @@
local Functions = require "maps.dungeons.functions"
local BiterRaffle = require "functions.biter_raffle"
local Get_noise = require "utils.get_noise"
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
local table_remove = table.remove
local math_random = math.random
local math_abs = math.abs
local math_sqrt = math.sqrt
local math_floor = math.floor
local rainbow_tiles = {
"cyan-refined-concrete", "purple-refined-concrete",
}
local ores = {
"copper-ore", "iron-ore", "iron-ore", "iron-ore", "coal", "stone"
}
local function treasure(surface, room)
local tiles = {}
for _, tile in pairs(room.path_tiles) do table_insert(tiles, tile) end
for _, tile in pairs(room.room_border_tiles) do table_insert(tiles, tile) end
for _, tile in pairs(room.room_tiles) do table_insert(tiles, tile) end
local seed = game.surfaces[surface.index].map_gen_settings.seed + math_random(1, 1000000)
for _, tile in pairs(tiles) do
surface.set_tiles({{name = rainbow_tiles[math_random(1, 2)], position = tile.position}}, true)
if math_random(1, 3) == 1 then
surface.create_entity({name = ores[math_random(1, 6)], position = tile.position, amount = Functions.get_common_resource_amount(surface.index) * 5})
end
end
if not room.room_border_tiles[1] then return end
table_shuffle_table(room.room_tiles)
for key, tile in pairs(room.room_tiles) do
if math_random(1, 256) == 1 or key == 1 then
Functions.epic_loot_crate(surface, tile.position, true)
else
if math_random(1, 128) == 1 then
Functions.rare_loot_crate(surface, tile.position, true)
end
end
end
table_shuffle_table(room.room_border_tiles)
for key, tile in pairs(room.room_border_tiles) do
if key % 8 == 1 then
Functions.place_border_rock(surface, tile.position)
end
end
end
return treasure

View File

@ -0,0 +1,372 @@
local RPG_F = require "modules.rpg.functions"
local RPG_T = require "modules.rpg.table"
--local RPG_S = require "modules.rpg.settings"
local BiterHealthBooster = require "modules.biter_health_booster"
local Alert = require 'utils.alert'
local math_floor = math.floor
local math_min = math.min
local arena_areas = {
[1] = {area = {{54,54}, {74,74}}, center = {64,64}, player = {69,64}, boss = {59,64}},
[2] = {area = {{-74,54}, {-54, 74}}, center = {-64,64}, player = {-59,64}, boss = {-69,64}},
[3] = {area = {{54,-74}, {74,-54}}, center = {64,-64}, player = {69,-64}, boss = {59,-64}},
[4] = {area = {{-74, -74}, {-54,-54}}, center = {-64,-64}, player = {-59,-64}, boss = {-69,-64}}
}
local function create_arena(arena)
local surface = game.surfaces["nauvis"]
local area = arena_areas[arena].area
surface.request_to_generate_chunks(arena_areas[arena].center, 2)
surface.force_generate_chunk_requests()
local tiles = {}
local entities = {}
for x = area[1][1], area[2][1], 1 do
for y = area[1][2], area[2][2], 1 do
tiles[#tiles + 1] = {name = "landfill", position = {x = x, y = y}}
if x == area[1][1] or x == area[2][1] or y == area[1][2] or y == area[2][2] then
entities[#entities + 1] = {name = "stone-wall", force = "neutral", position = {x = x, y = y}}
end
end
end
surface.set_tiles(tiles)
for _,entity in pairs(entities) do
local e = surface.create_entity(entity)
e.destructible = false
e.minable = false
end
global.arena.created[arena] = true
end
local function reset_arena(arena)
local surface = game.surfaces["nauvis"]
local area = arena_areas[arena].area
local acids = surface.find_entities_filtered{area = {{area[1][1] - 5, area[1][2] - 5}, {area[2][1] + 5,area[2][2] + 5}}, type = "fire"}
for _,acid in pairs(acids) do
acid.destroy()
end
local robots = surface.find_entities_filtered{area = {{area[1][1] - 15, area[1][2] - 15}, {area[2][1] + 15,area[2][2] + 15}}, force = {"enemy", "player"}}
for _,robot in pairs(robots) do
robot.destroy()
end
end
local function calculate_xp(level)
local xp_gains = {
['behemoth-biter'] = 16,
['behemoth-spitter'] = 16,
['big-biter'] = 8,
['big-spitter'] = 8,
['medium-biter'] = 4,
['medium-spitter'] = 4,
['small-biter'] = 1,
['small-spitter'] = 1
}
local biter_names = {{"small-biter", "small-spitter"}, {"medium-biter", "medium-spitter"}, {"big-biter", "big-spitter"}, {"behemoth-biter", "behemoth-spitter"}}
local biter = biter_names[math_min(1 + math_floor(level / 20), 4)][1 + level % 2]
return xp_gains[biter] * 8 * (2 + 0.2 * level - 1 * math_floor(level / 20))
end
local function calculate_hp(level)
return 2 + 0.2 * level - 1 * math_floor(level / 20)
end
local function calculate_dmg(level)
if level >= 80 then level = level * 2 end
return 1 + 0.1 * level - 1 * math_floor(level / 20)
end
local function draw_boss_gui()
for _, player in pairs(game.connected_players) do
if not player.gui.top.boss_arena then
local level = global.arena.bosses[player.index] or 0
local tooltip = {"dungeons_tiered.boss_arena", level, calculate_hp(level)*100, calculate_dmg(level)*100, math_floor(4 + level + calculate_xp(level))}
player.gui.top.add({type = "sprite-button", name = "boss_arena", sprite = "entity/behemoth-biter", tooltip = tooltip})
end
end
end
local function update_boss_gui(player)
if not player.gui.top.boss_arena then draw_boss_gui() end
local level = global.arena.bosses[player.index] or 0
local tooltip = {"dungeons_tiered.boss_arena", level, calculate_hp(level)*100, calculate_dmg(level)*100, math_floor(4 + level + calculate_xp(level))}
player.gui.top.boss_arena.tooltip = tooltip
end
local function arena_occupied(arena)
if global.arena.active_player[arena] then return true end
if global.arena.active_boss[arena] then return true end
return false
end
local function spawn_boss(arena, biter, level)
local surface = game.surfaces["nauvis"]
local force = game.forces[global.arena.enemies[arena].index]
global.biter_health_boost_forces[force.index] = calculate_hp(level)
force.set_ammo_damage_modifier("melee", calculate_dmg(level))
force.set_ammo_damage_modifier("biological", calculate_dmg(level))
local boss = surface.create_entity({name = biter, position = arena_areas[arena].boss, force = force})
boss.ai_settings.allow_try_return_to_spawner = false
global.arena.active_boss[arena] = boss
rendering.draw_text{
text = "Boss lvl " .. level,
surface = surface,
target = boss,
target_offset = {0, -2.5},
color = {r = 1, g = 0, b = 0},
scale = 1.40,
font = "default-game",
alignment = "center",
scale_with_zoom = false
}
BiterHealthBooster.add_boss_unit(boss, global.biter_health_boost_forces[force.index] * 8, 0.25)
end
local function hide_rpg(player, show)
local rpg_button = RPG_T.draw_main_frame_name
local rpg_frame = RPG_T.main_frame_name
local rpg_settings = RPG_T.settings_frame_name
local rpg_b = player.gui.top[rpg_button]
local rpg_f = player.gui.left[rpg_frame]
local rpg_s = player.gui.screen[rpg_settings]
if show then
if rpg_b then rpg_b.visible = true end
else
if rpg_b then rpg_b.visible = false end
if rpg_f then rpg_f.destroy() end
if rpg_s then rpg_s.destroy() end
end
end
local function teleport_player_out(arena, player)
local surface = global.arena.previous_position[arena].surface
local position = global.arena.previous_position[arena].position
local rpg = RPG_T.get("rpg_t")
rpg[player.index].one_punch = true
hide_rpg(player, true)
player.teleport(surface.find_non_colliding_position("character", position, 20, 0.5), surface)
global.arena.previous_position[arena].position = nil
global.arena.previous_position[arena].surface = nil
reset_arena(arena)
local group = game.permissions.get_group('Default')
group.add_player(player)
end
local function teleport_player_in(arena, player)
local surface = game.surfaces["nauvis"]
global.arena.previous_position[arena].position = player.position
global.arena.previous_position[arena].surface = player.surface
global.arena.timer[arena] = game.tick
local rpg = RPG_T.get("rpg_t")
rpg[player.index].one_punch = false
hide_rpg(player, false)
player.teleport(surface.find_non_colliding_position("character", arena_areas[arena].player, 20, 0.5), surface)
global.arena.active_player[arena] = player
local group = game.permissions.get_group('Arena')
group.add_player(player)
end
local function player_died(arena, player)
global.arena.active_player[arena] = nil
global.arena.active_boss[arena].destroy()
global.arena.active_boss[arena] = nil
teleport_player_out(arena, player)
player.character.health = 5
local level = global.arena.bosses[player.index]
--game.print({"dungeons_tiered.player_lost", player.name, global.arena.bosses[player.index]})
if level % 10 == 0 and level > 0 then
Alert.alert_all_players(15, {"dungeons_tiered.player_lost", player.name, global.arena.bosses[player.index]}, {r=0.8,g=0.2,b=0},"entity/behemoth-biter", 0.7)
else
Alert.alert_player(player, 15, {"dungeons_tiered.player_lost", player.name, global.arena.bosses[player.index]}, {r=0.8,g=0.2,b=0},"entity/behemoth-biter", 0.7)
end
end
local function boss_died(arena)
global.arena.active_boss[arena] = nil
local player = global.arena.active_player[arena]
local level = global.arena.bosses[player.index]
teleport_player_out(arena, player)
RPG_F.gain_xp(player, 4 + level, true)
if level % 10 == 0 and level > 0 then
Alert.alert_all_players(15, {"dungeons_tiered.player_won", player.name, global.arena.bosses[player.index]}, {r=0.8,g=0.2,b=0},"entity/behemoth-biter", 0.7)
else
Alert.alert_player(player, 15, {"dungeons_tiered.player_won", player.name, global.arena.bosses[player.index]}, {r=0.8,g=0.2,b=0},"entity/behemoth-biter", 0.7)
end
--game.print({"dungeons_tiered.player_won", player.name, global.arena.bosses[player.index]})
global.arena.bosses[player.index] = global.arena.bosses[player.index] + 1
global.arena.active_player[arena] = nil
update_boss_gui(player)
end
local function choose_arena()
for i = 1, 4, 1 do
if not global.arena.created[i] then create_arena(i) end
if not arena_occupied(i) then return i end
end
return nil
end
local function enter_arena(player)
if not player.character then return end
if player.surface.name == "nauvis" then return end
local chosen_arena = choose_arena()
if not chosen_arena then
Alert.alert_player_warning(player, 15, {"dungeons_tiered.arena_occupied"})
-- player.print({"dungeons_tiered.arena_occupied"})
return
end
local rpg_t = RPG_T.get("rpg_t")
if rpg_t[player.index].level < 5 then
Alert.alert_player_warning(player, 15, {"dungeons_tiered.arena_level_needed"})
return
end
if #player.character.following_robots > 0 then
Alert.alert_player_warning(player, 15, {"dungeons_tiered.robots_following"})
return
end
local level = global.arena.bosses[player.index]
if level > 100 then
Alert.alert_player_warning(player, 15, {"dungeons_tiered.arena_level_max"})
return
end
local biter_names = {{"small-biter", "small-spitter"}, {"medium-biter", "medium-spitter"}, {"big-biter", "big-spitter"}, {"behemoth-biter", "behemoth-spitter"}}
local biter = biter_names[math_min(1 + math_floor(level / 20), 4)][1 + level % 2]
spawn_boss(chosen_arena, biter, level)
teleport_player_in(chosen_arena, player)
end
local function on_player_joined_game(event)
draw_boss_gui()
if not global.arena.bosses[event.player_index] then global.arena.bosses[event.player_index] = 0 end
end
local function on_gui_click(event)
if not event then return end
if not event.element then return end
if not event.element.valid then return end
local player = game.players[event.element.player_index]
if event.element.name == "boss_arena" then
enter_arena(player)
return
end
end
local function on_pre_player_died(event)
local player = game.players[event.player_index]
if not player.valid then return end
for i = 1, 4, 1 do
if player == global.arena.active_player[i] then
player_died(i, player)
end
end
end
local function on_pre_player_left_game(event)
local player = game.players[event.player_index]
if not player.valid then return end
for i = 1, 4, 1 do
if player == global.arena.active_player[i] then
player_died(i, player)
end
end
end
local function on_entity_died(event)
local entity = event.entity
if not entity.valid then return end
for i = 1, 4, 1 do
if entity == global.arena.active_boss[i] then
boss_died(i)
end
end
end
local function shoot(surface, biter, player)
surface.create_entity({name = "destroyer-capsule", position = biter.position, target = player.character, source = biter, speed = 1, force = "enemy"})
end
local function slow(surface, biter, player)
surface.create_entity({name = "slowdown-capsule", position = biter.position, target = player.character, source = biter, speed = 1, max_range = 100})
end
local function boss_attacks(i)
if not global.arena.active_boss[i] then return end
if not global.arena.active_player[i] then return end
local biter = global.arena.active_boss[i]
local player = global.arena.active_player[i]
local surface = game.surfaces["nauvis"]
if not biter.valid or not player.valid or not player.character or not player.character.valid then return end
if global.arena.bosses[player.index] >= 80 then
slow(surface, biter, player)
--shoot(surface, biter, player)
end
if global.arena.timer[i] + 3600 < game.tick and game.tick %120 == 0 then slow(surface, biter, player) end
if global.arena.timer[i] + 7200 < game.tick and game.tick %120 == 0 then shoot(surface, biter, player) end
if biter.name == "small-spitter" then
surface.create_entity({name = "acid-stream-spitter-small", position = biter.position, target = player.character, source = biter})
surface.create_entity({name = "acid-stream-spitter-small", position = biter.position, target = player.character, source = biter})
elseif biter.name == "medium-spitter" then
surface.create_entity({name = "acid-stream-spitter-medium", position = biter.position, target = player.character, source = biter})
surface.create_entity({name = "acid-stream-spitter-medium", position = biter.position, target = player.character, source = biter})
elseif biter.name == "big-spitter" then
surface.create_entity({name = "acid-stream-spitter-big", position = biter.position, target = player.character, source = biter})
surface.create_entity({name = "acid-stream-spitter-big", position = biter.position, target = player.character, source = biter})
elseif biter.name == "behemoth-spitter" then
surface.create_entity({name = "acid-stream-spitter-behemoth", position = biter.position, target = player.character, source = biter})
surface.create_entity({name = "acid-stream-spitter-behemoth", position = biter.position, target = player.character, source = biter})
end
end
local function tick()
for i = 1, 4, 1 do
boss_attacks(i)
end
end
local function on_init()
global.arena = {}
global.arena.bosses = {}
global.arena.created = {[1] = false, [2] = false, [3] = false, [4] = false}
global.arena.active_player = {[1] = nil, [2] = nil, [3] = nil, [4] = nil}
global.arena.active_boss = {[1] = nil, [2] = nil, [3] = nil, [4] = nil}
global.arena.enemies = {[1] = nil, [2] = nil, [3] = nil, [4] = nil}
global.arena.timer = {[1] = 0, [2] = 0, [3] = 0, [4] = 0}
global.arena.previous_position = {[1] = {position = nil, surface = nil}, [2] = {position = nil, surface = nil}, [3] = {position = nil, surface = nil}, [4] = {position = nil, surface = nil}}
local arena = game.permissions.create_group('Arena')
arena.set_allows_action(defines.input_action.cancel_craft, false)
arena.set_allows_action(defines.input_action.edit_permission_group, false)
arena.set_allows_action(defines.input_action.import_permissions_string, false)
arena.set_allows_action(defines.input_action.delete_permission_group, false)
arena.set_allows_action(defines.input_action.add_permission_group, false)
arena.set_allows_action(defines.input_action.activate_paste, false)
arena.set_allows_action(defines.input_action.activate_cut, false)
arena.set_allows_action(defines.input_action.activate_copy, false)
arena.set_allows_action(defines.input_action.alternative_copy, false)
arena.set_allows_action(defines.input_action.begin_mining, false)
arena.set_allows_action(defines.input_action.begin_mining_terrain, false)
arena.set_allows_action(defines.input_action.build_item, false)
arena.set_allows_action(defines.input_action.build_rail, false)
arena.set_allows_action(defines.input_action.build_terrain, false)
arena.set_allows_action(defines.input_action.copy, false)
arena.set_allows_action(defines.input_action.deconstruct, false)
arena.set_allows_action(defines.input_action.drop_item, false)
for i = 1, 4, 1 do
local force = game.create_force("arena" .. i)
global.arena.enemies[i] = force
force.maximum_following_robot_count = 100
force.following_robots_lifetime_modifier = 600
force.set_ammo_damage_modifier("combat-robot-beam", 1)
force.set_gun_speed_modifier("biological", 2)
end
end
local Event = require 'utils.event'
Event.on_init(on_init)
Event.on_nth_tick(60, tick)
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
Event.add(defines.events.on_gui_click, on_gui_click)
Event.add(defines.events.on_entity_died, on_entity_died)
Event.add(defines.events.on_pre_player_died, on_pre_player_died)
Event.add(defines.events.on_pre_player_left_game, on_pre_player_left_game)

View File

@ -11,11 +11,53 @@ local math_random = math.random
local math_abs = math.abs
local math_floor = math.floor
function Public.get_dungeon_evolution_factor()
local e = global.dungeons.depth * 0.0005
function Public.get_dungeon_evolution_factor(surface_index)
local e = global.dungeons.depth[surface_index] * 0.0005
if global.dungeons.tiered then
e = math.min(e, surface_index * 0.05 - 0.05)
end
return e
end
local function blacklist(surface_index, special)
local evolution_factor = Public.get_dungeon_evolution_factor(surface_index)
local blacklist = {}
--general unused items on dungeons
blacklist["cliff-explosives"] = true
--items that would trivialize stuff if dropped too early
if global.dungeons.item_blacklist and not special then
if evolution_factor < 0.9 then
blacklist["discharge-defense-equipment"] = true
blacklist["power-armor-mk2"] = true
blacklist["fusion-reactor-equipment"] = true
blacklist["rocket-silo"] = true
blacklist["discharge-defense-remote"] = true
end
if evolution_factor < 0.7 then
blacklist["energy-shield-mk2-equipment"] = true
blacklist["personal-laser-defense-equipment"] = true
blacklist["personal-roboport-mk2-equipment"] = true
blacklist["battery-mk2-equipment"] = true
blacklist["nuclear-reactor"] = true
blacklist["artillery-turret"] = true
blacklist["artillery-wagon"] = true
blacklist["power-armor"] = true
end
if evolution_factor < 0.4 then
blacklist["steam-turbine"] = true
blacklist["heat-exchanger"] = true
blacklist["heat-pipe"] = true
blacklist["express-loader"] = true
blacklist["modular-armor"] = true
blacklist["solar-panel-equipment"] = true
blacklist["energy-shield-equipment"] = true
blacklist["battery-equipment"] = true
blacklist["solar-panel-equipment"] = true
end
end
return blacklist
end
function Public.roll_spawner_name()
if math_random(1, 3) == 1 then
return "spitter-spawner"
@ -23,20 +65,24 @@ function Public.roll_spawner_name()
return "biter-spawner"
end
function Public.roll_worm_name()
return BiterRaffle.roll("worm", Public.get_dungeon_evolution_factor())
function Public.roll_worm_name(surface_index)
return BiterRaffle.roll("worm", Public.get_dungeon_evolution_factor(surface_index))
end
function Public.get_crude_oil_amount()
return math_random(200000, 400000) + global.dungeons.depth * 500
function Public.get_crude_oil_amount(surface_index)
local amount = math_random(200000, 400000) + Public.get_dungeon_evolution_factor(surface_index) * 500000
if global.dungeons.tiered then amount = amount / 4 end
return amount
end
function Public.get_common_resource_amount()
return math_random(350, 700) + global.dungeons.depth * 8
function Public.get_common_resource_amount(surface_index)
local amount = math_random(350, 700) + Public.get_dungeon_evolution_factor(surface_index) * 16000
if global.dungeons.tiered then amount = amount / 4 end
return amount
end
function Public.common_loot_crate(surface, position)
local item_stacks = LootRaffle.roll(global.dungeons.depth * 2 + math_random(8, 16), 16)
function Public.common_loot_crate(surface, position, special)
local item_stacks = LootRaffle.roll(Public.get_dungeon_evolution_factor(surface.index) * 4000 + math_random(8, 16), 16, blacklist(surface.index, special))
local container = surface.create_entity({name = "wooden-chest", position = position, force = "neutral"})
for _, item_stack in pairs(item_stacks) do
container.insert(item_stack)
@ -44,8 +90,8 @@ function Public.common_loot_crate(surface, position)
container.minable = false
end
function Public.uncommon_loot_crate(surface, position)
local item_stacks = LootRaffle.roll(global.dungeons.depth * 4 + math_random(32, 64), 16)
function Public.uncommon_loot_crate(surface, position, special)
local item_stacks = LootRaffle.roll(Public.get_dungeon_evolution_factor(surface.index) * 8000 + math_random(32, 64), 16, blacklist(surface.index, special))
local container = surface.create_entity({name = "iron-chest", position = position, force = "neutral"})
for _, item_stack in pairs(item_stacks) do
container.insert(item_stack)
@ -53,8 +99,8 @@ function Public.uncommon_loot_crate(surface, position)
container.minable = false
end
function Public.rare_loot_crate(surface, position)
local item_stacks = LootRaffle.roll(global.dungeons.depth * 8 + math_random(128, 256), 32)
function Public.rare_loot_crate(surface, position, special)
local item_stacks = LootRaffle.roll(Public.get_dungeon_evolution_factor(surface.index) * 16000 + math_random(128, 256), 32, blacklist(surface.index, special))
local container = surface.create_entity({name = "steel-chest", position = position, force = "neutral"})
for _, item_stack in pairs(item_stacks) do
container.insert(item_stack)
@ -62,8 +108,8 @@ function Public.rare_loot_crate(surface, position)
container.minable = false
end
function Public.epic_loot_crate(surface, position)
local item_stacks = LootRaffle.roll(global.dungeons.depth * 16 + math_random(512, 1024), 48)
function Public.epic_loot_crate(surface, position, special)
local item_stacks = LootRaffle.roll(Public.get_dungeon_evolution_factor(surface.index) * 32000 + math_random(512, 1024), 48, blacklist(surface.index, special))
local container = surface.create_entity({name = "steel-chest", position = position, force = "neutral"})
for _, item_stack in pairs(item_stacks) do
container.insert(item_stack)
@ -71,14 +117,58 @@ function Public.epic_loot_crate(surface, position)
container.minable = false
end
function Public.crash_site_chest(surface, position)
local item_stacks = LootRaffle.roll(global.dungeons.depth * 6 + math_random(160, 320), 48)
function Public.crash_site_chest(surface, position, special)
local item_stacks = LootRaffle.roll(Public.get_dungeon_evolution_factor(surface.index) * 12000 + math_random(160, 320), 48, blacklist(surface.index, special))
local container = surface.create_entity({name = "crash-site-chest-" .. math_random(1, 2), position = position, force = "neutral"})
for _, item_stack in pairs(item_stacks) do
container.insert(item_stack)
end
end
function Public.market(surface, position)
local offers = {
{price = {{'pistol', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(1,4)}},
{price = {{'submachine-gun', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(5,20)}},
{price = {{'shotgun', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(5,18)}},
{price = {{'combat-shotgun', 1}}, offer = {type = 'give-item', item = "steel-plate", count = math_random(3,10)}},
{price = {{'rocket-launcher', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(4,10)}},
{price = {{'flamethrower', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(5,18)}},
{price = {{'light-armor', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(5,20)}},
{price = {{'heavy-armor', 1}}, offer = {type = 'give-item', item = "steel-plate", count = math_random(5,20)}},
{price = {{'modular-armor', 1}}, offer = {type = 'give-item', item = "advanced-circuit", count = math_random(10,20)}},
{price = {{'night-vision-equipment', 1}}, offer = {type = 'give-item', item = "steel-plate", count = math_random(1,4)}},
{price = {{'solar-panel-equipment', 1}}, offer = {type = 'give-item', item = "copper-plate", count = math_random(10,25)}},
{price = {{'red-wire', 100}}, offer = {type = 'give-item', item = "copper-cable", count = math_random(50,100)}},
{price = {{'green-wire', 100}}, offer = {type = 'give-item', item = "copper-cable", count = math_random(50,100)}},
{price = {{'empty-barrel', 10}}, offer = {type = 'give-item', item = "steel-plate", count = math_random(4,8)}},
{price = {{'arithmetic-combinator', 10}}, offer = {type = 'give-item', item = "electronic-circuit", count = math_random(10,25)}},
{price = {{'decider-combinator', 10}}, offer = {type = 'give-item', item = "electronic-circuit", count = math_random(10,25)}},
{price = {{'constant-combinator', 10}}, offer = {type = 'give-item', item = "electronic-circuit", count = math_random(3,12)}},
{price = {{'power-switch', 10}}, offer = {type = 'give-item', item = "electronic-circuit", count = math_random(3,12)}},
{price = {{'programmable-speaker', 10}}, offer = {type = 'give-item', item = "electronic-circuit", count = math_random(8,30)}},
{price = {{'belt-immunity-equipment', 1}}, offer = {type = 'give-item', item = "advanced-circuit", count = math_random(1,3)}},
{price = {{'discharge-defense-remote', 1}}, offer = {type = 'give-item', item = "electronic-circuit", count = 1}},
{price = {{'rail-signal', 10}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(20,40)}},
{price = {{'rail-chain-signal', 10}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(20,40)}},
{price = {{'train-stop', 10}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(50,100)}},
{price = {{'locomotive', 1}}, offer = {type = 'give-item', item = "steel-plate", count = math_random(20,40)}},
{price = {{'cargo-wagon', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(20,40)}},
{price = {{'fluid-wagon', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(20,40)}},
{price = {{'car', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(10,20)}},
{price = {{'radar', 10}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(10,20)}},
{price = {{'cannon-shell', 10}}, offer = {type = 'give-item', item = "steel-plate", count = math_random(5,10)}},
{price = {{'uranium-cannon-shell', 10}}, offer = {type = 'give-item', item = "uranium-238", count = math_random(5,10)}},
}
table.shuffle_table(offers)
local market = surface.create_entity({name = "market", position = position, force = "neutral"})
market.destructible = false
market.minable = false
for i = 1, math.random(6, 10), 1 do
market.add_market_item(offers[i])
end
end
function Public.add_room_loot_crates(surface, room)
if not room.room_border_tiles[1] then return end
for key, tile in pairs(room.room_tiles) do
@ -96,13 +186,13 @@ function Public.add_room_loot_crates(surface, room)
end
end
end
end
end
end
end
end
function Public.set_spawner_tier(spawner)
local tier = math_floor(Public.get_dungeon_evolution_factor() * 8 - math_random(0, 8)) + 1
if tier < 1 then tier = 1 end
function Public.set_spawner_tier(spawner, surface_index)
local tier = math_floor(Public.get_dungeon_evolution_factor(surface_index) * 8 - math_random(0, 8)) + 1
if tier < 1 then tier = 1 end
global.dungeons.spawner_tier[spawner.unit_number] = tier
--[[
rendering.draw_text{
@ -120,14 +210,14 @@ function Public.set_spawner_tier(spawner)
end
function Public.spawn_random_biter(surface, position)
local name = BiterRaffle.roll("mixed", Public.get_dungeon_evolution_factor())
local name = BiterRaffle.roll("mixed", Public.get_dungeon_evolution_factor(surface.index))
local non_colliding_position = surface.find_non_colliding_position(name, position, 16, 1)
local unit
if non_colliding_position then
unit = surface.create_entity({name = name, position = non_colliding_position, force = "enemy"})
unit = surface.create_entity({name = name, position = non_colliding_position, force = global.enemy_forces[surface.index]})
else
unit = surface.create_entity({name = name, position = position, force = "enemy"})
end
unit = surface.create_entity({name = name, position = position, force = global.enemy_forces[surface.index]})
end
unit.ai_settings.allow_try_return_to_spawner = false
unit.ai_settings.allow_destroy_when_commands_fail = false
end
@ -142,11 +232,11 @@ function Public.place_border_rock(surface, position)
key = k
break
end
end
end
local pos = {x = position.x + 0.5, y = position.y + 0.5}
if key then
pos = {pos.x + vectors[key][1] * 0.45, pos.y + vectors[key][2] * 0.45}
end
end
surface.create_entity({name = "rock-big", position = pos})
end
@ -164,7 +254,7 @@ function Public.draw_spawn(surface)
for _, e in pairs(surface.find_entities({{spawn_size * -1, spawn_size * -1}, {spawn_size, spawn_size}})) do
e.destroy()
end
local tiles = {}
local i = 1
for x = spawn_size * -1, spawn_size, 1 do
@ -175,10 +265,10 @@ function Public.draw_spawn(surface)
i = i + 1
tiles[i] = {name = "stone-path", position = position}
i = i + 1
else
else
tiles[i] = {name = "dirt-7", position = position}
i = i + 1
end
end
end
end
surface.set_tiles(tiles, true)
@ -194,23 +284,25 @@ function Public.draw_spawn(surface)
else
tiles[i] = {name = "purple-refined-concrete", position = position}
i = i + 1
end
end
end
end
surface.set_tiles(tiles, true)
local tiles = {}
local i = 1
for x = spawn_size * -1, spawn_size, 1 do
for y = spawn_size * -1, spawn_size, 1 do
local position = {x = x, y = y}
local r = math.sqrt(position.x ^ 2 + position.y ^ 2)
local r = math.sqrt(position.x ^ 2 + position.y ^ 2)
if r < 2 then
tiles[i] = {name = "purple-refined-concrete", position = position}
--tiles[i] = {name = "water-mud", position = position}
i = i + 1
else
if r < 2.5 then
tiles[i] = {name = "black-refined-concrete", position = position}
--tiles[i] = {name = "water-shallow", position = position}
i = i + 1
else
if r < 4.5 then
@ -220,29 +312,29 @@ function Public.draw_spawn(surface)
i = i + 1
end
end
end
end
end
end
surface.set_tiles(tiles, true)
local decoratives = {"brown-hairy-grass", "brown-asterisk", "brown-fluff", "brown-fluff-dry", "brown-asterisk", "brown-fluff", "brown-fluff-dry"}
local a = spawn_size * -1 + 1
local b = spawn_size - 1
for _, decorative_name in pairs(decoratives) do
local seed = game.surfaces[1].map_gen_settings.seed + math_random(1, 1000000)
local seed = game.surfaces[surface.index].map_gen_settings.seed + math_random(1, 1000000)
for x = a, b, 1 do
for y = a, b, 1 do
local position = {x = x + 0.5, y = y + 0.5}
if surface.get_tile(position).name == "dirt-7" or math_random(1, 5) == 1 then
if surface.get_tile(position).name == "dirt-7" or math_random(1, 5) == 1 then
local noise = Get_noise("decoratives", position, seed)
if math_abs(noise) > 0.37 then
surface.create_decoratives{check_collision = false, decoratives = {{name = decorative_name, position = position, amount = math.floor(math.abs(noise * 3)) + 1}}}
end
end
end
end
end
end
local entities = {}
local i = 1
for x = spawn_size * -1 - 16, spawn_size + 16, 1 do
@ -264,11 +356,45 @@ function Public.draw_spawn(surface)
end
end
end
for k, e in pairs(entities) do
if k % 3 > 0 then surface.create_entity(e) end
end
if global.dungeons.tiered then
if surface.index > 2 then
table.insert(global.dungeons.transport_surfaces, surface.index)
global.dungeons.transport_chests_inputs[surface.index] = {}
for i = 1, 2, 1 do
local chest = surface.create_entity({name = "blue-chest", position = {-12 + i * 8, -4}, force = "player"})
global.dungeons.transport_chests_inputs[surface.index][i] = chest
chest.destructible = false
chest.minable = false
end
global.dungeons.transport_poles_outputs[surface.index] = {}
for i = 1, 2, 1 do
local pole = surface.create_entity({name = "constant-combinator", position = {-15 + i * 10, -5}, force = "player"})
global.dungeons.transport_poles_outputs[surface.index][i] = pole
pole.destructible = false
pole.minable = false
end
end
global.dungeons.transport_chests_outputs[surface.index] = {}
for i = 1, 2, 1 do
local chest = surface.create_entity({name = "red-chest", position = {-12 + i * 8, 4}, force = "player"})
global.dungeons.transport_chests_outputs[surface.index][i] = chest
chest.destructible = false
chest.minable = false
end
global.dungeons.transport_poles_inputs[surface.index] = {}
for i = 1, 2, 1 do
local pole = surface.create_entity({name = "medium-electric-pole", position = {-15 + i * 10, 5}, force = "player"})
global.dungeons.transport_poles_inputs[surface.index][i] = pole
pole.destructible = false
pole.minable = false
end
end
local trees = { "dead-grey-trunk", "dead-tree-desert", "dry-hairy-tree", "dry-tree", "tree-04"}
local size_of_trees = #trees
local r = 4
@ -280,16 +406,16 @@ function Public.draw_spawn(surface)
end
if position.x <= -4 and position.y <= -4 and math_random(1, r) == 1 then
surface.create_entity({name = trees[math_random(1, size_of_trees)], position = position})
end
end
if position.x > 5 and position.y <= -4 and math_random(1, r) == 1 then
surface.create_entity({name = trees[math_random(1, size_of_trees)], position = position})
end
end
if position.x <= -4 and position.y > 5 and math_random(1, r) == 1 then
surface.create_entity({name = trees[math_random(1, size_of_trees)], position = position})
end
end
end
end
surface.set_tiles(tiles, true)
end
return Public
return Public

View File

@ -44,9 +44,9 @@ local function get_biome(position)
if position.x ^ 2 + position.y ^ 2 < 6400 then return "dirtlands" end
local seed = game.surfaces[1].map_gen_settings.seed
local seed_addition = 100000
local a = 1
local seed_addition = 100000
local a = 1
if Get_noise("dungeons", position, seed + seed_addition * a) > 0.66 then return "glitch" end
a = a + 1
if Get_noise("dungeons", position, seed + seed_addition * a) > 0.60 then return "doom" end
@ -64,19 +64,23 @@ local function get_biome(position)
if Get_noise("dungeons", position, seed + seed_addition * a) > 0.22 then return "desert" end
a = a + 1
if Get_noise("dungeons", position, seed + seed_addition * a) > 0.22 then return "red_desert" end
return "dirtlands"
end
local function draw_depth_gui()
for _, player in pairs(game.connected_players) do
local surface = player.surface
if player.gui.top.dungeon_depth then player.gui.top.dungeon_depth.destroy() end
local element = player.gui.top.add({type = "sprite-button", name = "dungeon_depth", caption = "~ Depth " .. global.dungeons.depth .. " ~"})
element.tooltip = "Evolution: " .. Functions.get_dungeon_evolution_factor() * 100 .. "%"
element.tooltip = element.tooltip .. "\nEnemy Health: " .. global.biter_health_boost * 100 .. "%"
element.tooltip = element.tooltip .. "\nEnemy Damage: " .. math_round(game.forces.enemy.get_ammo_damage_modifier("melee") * 100 + 100, 1) .. "%"
local element = player.gui.top.add({type = "sprite-button", name = "dungeon_depth"})
element.caption = {"dungeons.depth", global.dungeons.depth[surface.index]}
element.tooltip = {
"dungeons.depth_tooltip",
Functions.get_dungeon_evolution_factor(surface.index) * 100,
global.biter_health_boost * 100,
math_round(game.forces.enemy.get_ammo_damage_modifier("melee") * 100 + 100, 1)
}
local style = element.style
style.minimal_height = 38
style.maximal_height = 38
@ -95,21 +99,21 @@ local function expand(surface, position)
if not room then return end
local name = get_biome(position)
Biomes[name](surface, room)
if not room.room_tiles[1] then return end
local a = 2000
global.dungeons.depth = global.dungeons.depth + 1
local evo = Functions.get_dungeon_evolution_factor()
global.dungeons.depth[surface.index] = global.dungeons.depth[surface.index] + 1
local evo = Functions.get_dungeon_evolution_factor(surface.index)
local force = game.forces.enemy
force.evolution_factor = evo
if evo > 1 then
global.biter_health_boost = 2 + ((evo - 1) * 2)
local damage_mod = (evo - 1) * 0.35
local damage_mod = (evo - 1) * 0.35
force.set_ammo_damage_modifier("melee", damage_mod)
force.set_ammo_damage_modifier("biological", damage_mod)
force.set_ammo_damage_modifier("artillery-shell", damage_mod)
@ -118,9 +122,9 @@ local function expand(surface, position)
else
global.biter_health_boost = 1 + evo
end
global.biter_health_boost = math_round(global.biter_health_boost, 2)
draw_depth_gui()
end
@ -132,10 +136,10 @@ local function init_player(player)
player.set_controller({type=defines.controllers.god})
player.create_character()
local surface = game.surfaces["dungeons"]
player.teleport(surface.find_non_colliding_position("character", {0, 0}, 50, 0.5), surface)
player.insert({name = "raw-fish", count = 8})
player.insert({name = "raw-fish", count = 8})
player.set_quick_bar_slot(1, "raw-fish")
player.insert({name = "pistol", count = 1})
player.insert({name = "firearm-magazine", count = 16})
@ -148,10 +152,10 @@ local function on_entity_spawned(event)
local spawner_tier = global.dungeons.spawner_tier
if not spawner_tier[spawner.unit_number] then
Functions.set_spawner_tier(spawner)
Functions.set_spawner_tier(spawner, surface.index)
end
local e = Functions.get_dungeon_evolution_factor()
local e = Functions.get_dungeon_evolution_factor(surface.index)
for _ = 1, spawner_tier[spawner.unit_number], 1 do
local name = BiterRaffle.roll("mixed", e)
local non_colliding_position = surface.find_non_colliding_position(name, unit.position, 16, 1)
@ -160,15 +164,15 @@ local function on_entity_spawned(event)
bonus_unit = surface.create_entity({name = name, position = non_colliding_position, force = "enemy"})
else
bonus_unit = surface.create_entity({name = name, position = unit.position, force = "enemy"})
end
end
bonus_unit.ai_settings.allow_try_return_to_spawner = true
bonus_unit.ai_settings.allow_destroy_when_commands_fail = true
if math_random(1, 256) == 1 then
BiterHealthBooster.add_boss_unit(bonus_unit, global.biter_health_boost * 8, 0.25)
end
end
if math_random(1, 256) == 1 then
BiterHealthBooster.add_boss_unit(unit, global.biter_health_boost * 8, 0.25)
end
@ -177,14 +181,14 @@ end
local function on_chunk_generated(event)
local surface = event.surface
if surface.name ~= "dungeons" then return end
local left_top = event.area.left_top
local tiles = {}
local i = 1
for x = 0, 31, 1 do
for y = 0, 31, 1 do
local position = {x = left_top.x + x, y = left_top.y + y}
local position = {x = left_top.x + x, y = left_top.y + y}
tiles[i] = {name = "out-of-map", position = position}
i = i + 1
end
@ -215,16 +219,16 @@ local function on_chunk_generated(event)
if math_random(1, 64) == 1 then
surface.create_entity({name = "fish", position = position})
end
end
end
end
end
end
end
end
end
end
for _, p in pairs(rock_positions) do Functions.place_border_rock(surface, p) end
if left_top.x == 160 and left_top.y == 160 then
if left_top.x == 160 and left_top.y == 160 then
Functions.draw_spawn(surface)
for _, p in pairs(game.connected_players) do init_player(p) end
game.forces.player.chart(surface, {{-256, -256}, {256, 256}})
@ -237,21 +241,21 @@ local function on_player_joined_game(event)
local player = game.players[event.player_index]
if player.online_time == 0 then
init_player(player)
end
end
end
local function spawner_death(entity)
local tier = global.dungeons.spawner_tier[entity.unit_number]
if not tier then
Functions.set_spawner_tier(entity)
Functions.set_spawner_tier(entity, entity.surface.index)
tier = global.dungeons.spawner_tier[entity.unit_number]
end
for _ = 1, tier * 2, 1 do
Functions.spawn_random_biter(entity.surface, entity.position)
end
global.dungeons.spawner_tier[entity.unit_number] = nil
end
@ -280,7 +284,7 @@ end
local function on_entity_died(event)
local entity = event.entity
if not entity.valid then return end
if not entity.valid then return end
if entity.type == "unit-spawner" then
spawner_death(entity)
end
@ -288,7 +292,7 @@ local function on_entity_died(event)
expand(entity.surface, entity.position)
end
local function on_marked_for_deconstruction(event)
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)
end
@ -311,22 +315,22 @@ local function on_init()
},
}
local surface = game.create_surface("dungeons", map_gen_settings)
surface.request_to_generate_chunks({0,0}, 8)
surface.force_generate_chunk_requests()
surface.daytime = 0.30
local surface = game.surfaces[1]
local map_gen_settings = surface.map_gen_settings
map_gen_settings.height = 3
map_gen_settings.width = 3
surface.map_gen_settings = map_gen_settings
for chunk in surface.get_chunks() do
surface.delete_chunk({chunk.x, chunk.y})
for chunk in surface.get_chunks() do
surface.delete_chunk({chunk.x, chunk.y})
end
game.forces.player.manual_mining_speed_modifier = 0.5
game.map_settings.enemy_evolution.destroy_factor = 0
game.map_settings.enemy_evolution.pollution_factor = 0
game.map_settings.enemy_evolution.time_factor = 0
@ -337,15 +341,20 @@ local function on_init()
game.map_settings.enemy_expansion.settler_group_min_size = 16
game.map_settings.enemy_expansion.max_expansion_distance = 16
game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.50
global.dungeons = {}
global.dungeons.depth = 0
global.dungeons.tiered = false
global.dungeons.depth = {}
global.dungeons.depth[1] = 0
global.dungeons.depth[game.surfaces["dungeons"].index] = 0
global.dungeons.spawn_size = 42
global.dungeons.spawner_tier = {}
global.enemy_forces = {}
global.enemy_forces[game.surfaces["dungeons"].index] = game.forces.enemy
global.rocks_yield_ore_base_amount = 100
global.rocks_yield_ore_distance_modifier = 0.001
local T = MapInfo.Pop_info()
T.localised_category = "dungeons"
T.main_caption_color = {r = 0, g = 0, b = 0}
@ -354,23 +363,23 @@ end
--[[
local function on_tick()
if game.tick % 4 ~= 0 then return end
local surface = game.surfaces["dungeons"]
local entities = surface.find_entities_filtered({name = "rock-big"})
if not entities[1] then return end
local entity = entities[math_random(1, #entities)]
surface.request_to_generate_chunks(entity.position, 3)
surface.force_generate_chunk_requests()
game.forces.player.chart(surface, {{entity.position.x - 32, entity.position.y - 32}, {entity.position.x + 32, entity.position.y + 32}})
entity.die()
end
]]
local Event = require 'utils.event'
local Event = require 'utils.event'
Event.on_init(on_init)
--Event.add(defines.events.on_tick, on_tick)
Event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
@ -381,4 +390,4 @@ Event.add(defines.events.on_entity_spawned, on_entity_spawned)
Event.add(defines.events.on_entity_died, on_entity_died)
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
require "modules.rocks_yield_ore"
require "modules.rocks_yield_ore"

View File

@ -0,0 +1,695 @@
-- Deep dark dungeons by mewmew --
require "modules.mineable_wreckage_yields_scrap"
require "modules.satellite_score"
require 'modules.charging_station'
local MapInfo = require "modules.map_info"
local Room_generator = require "functions.room_generator"
require "modules.rpg.main"
local RPG_F = require "modules.rpg.functions"
local RPG_T = require 'modules.rpg.table'
local BiterHealthBooster = require "modules.biter_health_booster"
local BiterRaffle = require "functions.biter_raffle"
local Functions = require "maps.dungeons.functions"
local Get_noise = require "utils.get_noise"
local Alert = require 'utils.alert'
require 'maps.dungeons.boss_arena'
local Biomes = {}
Biomes.dirtlands = require "maps.dungeons.biome_dirtlands"
Biomes.desert = require "maps.dungeons.biome_desert"
Biomes.red_desert = require "maps.dungeons.biome_red_desert"
Biomes.grasslands = require "maps.dungeons.biome_grasslands"
Biomes.concrete = require "maps.dungeons.biome_concrete"
Biomes.doom = require "maps.dungeons.biome_doom"
Biomes.deepblue = require "maps.dungeons.biome_deepblue"
Biomes.glitch = require "maps.dungeons.biome_glitch"
Biomes.acid_zone = require "maps.dungeons.biome_acid_zone"
Biomes.rainbow = require "maps.dungeons.biome_rainbow"
Biomes.treasure = require "maps.dungeons.biome_treasure"
Biomes.market = require "maps.dungeons.biome_market"
local table_shuffle_table = table.shuffle_table
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 math_round = math.round
local disabled_for_deconstruction = {
["fish"] = true,
["rock-huge"] = true,
["rock-big"] = true,
["sand-rock-big"] = true,
["mineable-wreckage"] = true
}
local function get_biome(position, surface_index)
--if not a then return "concrete" end
if position.x ^ 2 + position.y ^ 2 < 6400 then return "dirtlands" end
local seed = game.surfaces[surface_index].map_gen_settings.seed
local seed_addition = 100000
local a = 1
if Get_noise("dungeons", position, seed + seed_addition * a) > 0.66 then return "glitch" end
a = a + 1
if Get_noise("dungeons", position, seed + seed_addition * a) > 0.60 then return "doom" end
a = a + 1
if Get_noise("dungeons", position, seed + seed_addition * a) > 0.62 then return "acid_zone" end
a = a + 1
if Get_noise("dungeons", position, seed + seed_addition * a) > 0.60 then return "concrete" end
a = a + 1
if Get_noise("dungeons", position, seed + seed_addition * a) > 0.71 then return "rainbow" end
a = a + 1
if Get_noise("dungeons", position, seed + seed_addition * a) > 0.53 then return "deepblue" end
a = a + 1
if Get_noise("dungeons", position, seed + seed_addition * a) > 0.22 then return "grasslands" end
a = a + 1
if Get_noise("dungeons", position, seed + seed_addition * a) > 0.22 then return "desert" end
a = a + 1
if Get_noise("dungeons", position, seed + seed_addition * a) > 0.22 then return "red_desert" end
return "dirtlands"
end
local locked_researches = {
[2] = "steel-axe",
[3] = "heavy-armor",
[4] = "military-2",
[5] = "physical-projectile-damage-2",
[6] = "oil-processing",
[7] = "stronger-explosives-2",
[8] = "military-science-pack",
[9] = "rocketry",
[10] = "chemical-science-pack",
[11] = "military-3",
[12] = "flamethrower",
[13] = "combat-robotics-2",
[14] = "laser",
[15] = "laser-turret-speed-3",
[16] = "power-armor",
[17] = "nuclear-power",
[18] = "production-science-pack",
[19] = "energy-weapons-damage-3",
[20] = "utility-science-pack",
[21] = "kovarex-enrichment-process",
[22] = "power-armor-mk2",
[24] = "fusion-reactor-equipment",
[26] = "discharge-defense-equipment",
[30] = "atomic-bomb"
}
local function draw_arrows_gui()
for _, player in pairs(game.connected_players) do
if not player.gui.top.dungeon_down then
player.gui.top.add({type = "sprite-button", name = "dungeon_down", sprite = "utility/editor_speed_down", tooltip = {"dungeons_tiered.descend"}})
end
if not player.gui.top.dungeon_up then
player.gui.top.add({type = "sprite-button", name = "dungeon_up", sprite = "utility/editor_speed_up", tooltip = {"dungeons_tiered.ascend"}})
end
end
end
local function draw_depth_gui()
for _, player in pairs(game.connected_players) do
local surface = player.surface
local techs = 0
if locked_researches[surface.index] and game.forces.player.technologies[locked_researches[surface.index]].enabled == false then techs = 1 end
local enemy_force = global.enemy_forces[surface.index]
if player.gui.top.dungeon_depth then player.gui.top.dungeon_depth.destroy() end
local element = player.gui.top.add({type = "sprite-button", name = "dungeon_depth"})
element.caption = {"dungeons_tiered.depth", surface.index - 2, global.dungeons.depth[surface.index]}
element.tooltip = {
"dungeons_tiered.depth_tooltip",
Functions.get_dungeon_evolution_factor(surface.index) * 100,
global.biter_health_boost_forces[enemy_force.index] * 100,
math_round(enemy_force.get_ammo_damage_modifier("melee") * 100 + 100, 1),
Functions.get_dungeon_evolution_factor(surface.index) * 2000,
global.dungeons.treasures[surface.index],
techs
}
local style = element.style
style.minimal_height = 38
style.maximal_height = 38
style.minimal_width = 236
style.top_padding = 2
style.left_padding = 4
style.right_padding = 4
style.bottom_padding = 2
style.font_color = {r = 0, g = 0, b = 0}
style.font = "default-large-bold"
end
end
local function unlock_researches(surface_index)
local tech = game.forces.player.technologies
if locked_researches[surface_index] and tech[locked_researches[surface_index]].enabled == false then
tech[locked_researches[surface_index]].enabled = true
game.print({"dungeons_tiered.tech_unlock", "[technology=" .. locked_researches[surface_index] .. "]", surface_index - 2})
end
end
local function expand(surface, position)
local room = Room_generator.get_room(surface, position)
if not room then return end
if global.dungeons.treasures[surface.index] < 5 and global.dungeons.surface_size[surface.index] >= 225 and math.random(1,50) == 1 then
Biomes["treasure"](surface, room)
if room.room_tiles[1] then
global.dungeons.treasures[surface.index] = global.dungeons.treasures[surface.index] + 1
game.print({"dungeons_tiered.treasure_room", surface.index - 2}, {r = 0.88, g = 0.22, b = 0})
end
elseif math_random(1,256) == 1 then
Biomes["market"](surface, room)
else
local name = get_biome(position, surface.index)
Biomes[name](surface, room)
end
if not room.room_tiles[1] then return end
global.dungeons.depth[surface.index] = global.dungeons.depth[surface.index] + 1
global.dungeons.surface_size[surface.index] = 200 + (global.dungeons.depth[surface.index] - 100 * (surface.index - 2)) / 4
if global.dungeons.surface_size[surface.index] >= 225 and math.random(1,50) == 1 then unlock_researches(surface.index) end
local evo = Functions.get_dungeon_evolution_factor(surface.index)
local force = global.enemy_forces[surface.index]
force.evolution_factor = evo
if evo > 1 then
global.biter_health_boost_forces[force.index] = 3 + ((evo - 1) * 4)
local damage_mod = (evo - 1) * 0.35
force.set_ammo_damage_modifier("melee", damage_mod)
force.set_ammo_damage_modifier("biological", damage_mod)
force.set_ammo_damage_modifier("artillery-shell", damage_mod)
force.set_ammo_damage_modifier("flamethrower", damage_mod)
force.set_ammo_damage_modifier("laser-turret", damage_mod)
else
global.biter_health_boost_forces[force.index] = 1 + evo * 2
end
global.biter_health_boost_forces[force.index] = math_round(global.biter_health_boost_forces[force.index], 2)
draw_depth_gui()
end
local function init_player(player, surface)
if surface == game.surfaces["dungeons_floor0"] then
if player.character then
player.disassociate_character(player.character)
player.character.destroy()
end
player.set_controller({type=defines.controllers.god})
player.create_character()
player.teleport(surface.find_non_colliding_position("character", {0, 0}, 50, 0.5), surface)
player.insert({name = "raw-fish", count = 8})
player.set_quick_bar_slot(1, "raw-fish")
player.insert({name = "pistol", count = 1})
player.insert({name = "firearm-magazine", count = 16})
else
if player.surface == surface then
player.teleport(surface.find_non_colliding_position("character", {0,0}, 50, 0.5), surface)
end
end
end
local function on_entity_spawned(event)
local spawner = event.spawner
local unit = event.entity
local surface = spawner.surface
local force = unit.force
local spawner_tier = global.dungeons.spawner_tier
if not spawner_tier[spawner.unit_number] then
Functions.set_spawner_tier(spawner, surface.index)
end
local e = Functions.get_dungeon_evolution_factor(surface.index)
for _ = 1, spawner_tier[spawner.unit_number], 1 do
local name = BiterRaffle.roll("mixed", e)
local non_colliding_position = surface.find_non_colliding_position(name, unit.position, 16, 1)
local bonus_unit
if non_colliding_position then
bonus_unit = surface.create_entity({name = name, position = non_colliding_position, force = force})
else
bonus_unit = surface.create_entity({name = name, position = unit.position, force = force})
end
bonus_unit.ai_settings.allow_try_return_to_spawner = true
bonus_unit.ai_settings.allow_destroy_when_commands_fail = true
if math_random(1, 256) == 1 then
BiterHealthBooster.add_boss_unit(bonus_unit, global.biter_health_boost_forces[force.index] * 8, 0.25)
end
end
if math_random(1, 256) == 1 then
BiterHealthBooster.add_boss_unit(unit, global.biter_health_boost_forces[force.index] * 8, 0.25)
end
end
local function on_chunk_generated(event)
local surface = event.surface
if surface.name == "nauvis" then return end
local left_top = event.area.left_top
local tiles = {}
local i = 1
for x = 0, 31, 1 do
for y = 0, 31, 1 do
local position = {x = left_top.x + x, y = left_top.y + y}
tiles[i] = {name = "out-of-map", position = position}
i = i + 1
end
end
surface.set_tiles(tiles, true)
local rock_positions = {}
local set_tiles = surface.set_tiles
local nauvis_seed = game.surfaces[surface.index].map_gen_settings.seed
local s = math_floor(nauvis_seed * 0.1) + 100
-- for a = 1, 7, 1 do
-- local b = a * s
-- local c = 0.0035 + a * 0.0035
-- local d = c * 0.5
-- local seed = nauvis_seed + b
-- if math_abs(Get_noise("dungeon_sewer", {x = left_top.x + 16, y = left_top.y + 16}, seed)) < 0.12 then
-- for x = 0, 31, 1 do
-- for y = 0, 31, 1 do
-- local position = {x = left_top.x + x, y = left_top.y + y}
-- local noise = math_abs(Get_noise("dungeon_sewer", position, seed))
-- if noise < c then
-- local tile_name = surface.get_tile(position).name
-- if noise > d and tile_name ~= "deepwater-green" then
-- set_tiles({{name = "water-green", position = position}}, true)
-- if math_random(1, 320) == 1 and noise > c - 0.001 then table_insert(rock_positions, position) end
-- else
-- set_tiles({{name = "deepwater-green", position = position}}, true)
-- if math_random(1, 64) == 1 then
-- surface.create_entity({name = "fish", position = position})
-- end
-- end
-- end
-- end
-- end
-- end
-- end
for _, p in pairs(rock_positions) do Functions.place_border_rock(surface, p) end
if left_top.x == 32 and left_top.y == 32 then
Functions.draw_spawn(surface)
for _, p in pairs(game.connected_players) do init_player(p, surface) end
game.forces.player.chart(surface, {{-128, -128}, {128, 128}})
end
end
local function on_player_joined_game(event)
draw_arrows_gui()
draw_depth_gui()
if game.tick == 0 then return end
local player = game.players[event.player_index]
if player.online_time == 0 then
init_player(player, game.surfaces["dungeons_floor0"])
end
end
local function spawner_death(entity)
local tier = global.dungeons.spawner_tier[entity.unit_number]
if not tier then
Functions.set_spawner_tier(entity, entity.surface.index)
tier = global.dungeons.spawner_tier[entity.unit_number]
end
for _ = 1, tier * 2, 1 do
Functions.spawn_random_biter(entity.surface, entity.position)
end
global.dungeons.spawner_tier[entity.unit_number] = nil
end
--make expansion rocks very durable against biters
local function on_entity_damaged(event)
local entity = event.entity
if not entity.valid then return end
if entity.surface.name == "nauvis" then return end
local size = global.dungeons.surface_size[entity.surface.index]
if size < math.abs(entity.position.y) or size < math.abs(entity.position.x) then
if entity.name == "rock-big" then
entity.health = entity.health + event.final_damage_amount
end
return
end
if entity.force.index ~= 3 then return end --Neutral Force
if not event.cause then return end
if not event.cause.valid then return end
if event.cause.force.index ~= 2 then return end --Enemy Force
if math_random(1, 256) == 1 then return end
if entity.name ~= "rock-big" then return end
entity.health = entity.health + event.final_damage_amount
end
local function on_player_mined_entity(event)
local entity = event.entity
if not entity.valid then return end
local player = game.players[event.player_index]
if entity.name == "rock-big" then
local size = global.dungeons.surface_size[entity.surface.index]
if size < math.abs(entity.position.y) or size < math.abs(entity.position.x) then
entity.surface.create_entity({name = entity.name, position = entity.position})
entity.destroy()
RPG_F.gain_xp(player, -10)
Alert.alert_player_warning(player, 30, {"dungeons_tiered.too_small"}, {r=0.98,g=0.22,b=0})
event.buffer.clear()
return
end
end
if entity.type == "simple-entity" then
Functions.mining_events(entity)
end
if entity.name ~= "rock-big" then return end
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-spawner" then
spawner_death(entity)
end
if entity.name ~= "rock-big" then return end
expand(entity.surface, entity.position)
end
local function on_marked_for_deconstruction(event)
if event.entity and event.entity.valid then
if disabled_for_deconstruction[event.entity.name] then
event.entity.cancel_deconstruction(game.players[event.player_index].force.name)
end
end
end
local function map_gen_settings()
local map_gen_settings = {
["seed"] = math_random(1, 1000000),
["water"] = 0,
["starting_area"] = 1,
["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
["default_enable_all_autoplace_controls"] = false,
["autoplace_settings"] = {
["entity"] = {treat_missing_as_default = false},
["tile"] = {treat_missing_as_default = false},
["decorative"] = {treat_missing_as_default = false},
},
}
return map_gen_settings
end
local function get_lowest_safe_floor(player)
local rpg = RPG_T.get("rpg_t")
local level = rpg[player.index].level
local sizes = global.dungeons.surface_size
local safe = 2
for key, size in pairs(sizes) do
if size > 215 and level >= key * 10 - 10 and game.surfaces[key + 1] then
safe = key + 1
else
break
end
end
if safe >= 52 then safe = 52 end
return safe
end
local function descend(player, button, shift)
local rpg = RPG_T.get("rpg_t")
if player.surface.index >= 52 then
player.print({"dungeons_tiered.max_depth"})
return
end
if player.position.x^2 + player.position.y^2 > 400 then
player.print({"dungeons_tiered.only_on_spawn"})
return
end
if rpg[player.index].level < player.surface.index * 10 - 10 then
player.print({"dungeons_tiered.level_required", player.surface.index * 10 - 10})
return
end
local surface = game.surfaces[player.surface.index + 1]
if not surface then
if global.dungeons.surface_size[player.surface.index] < 215 then
player.print({"dungeons_tiered.floor_size_required"})
return
end
surface = game.create_surface("dungeons_floor" .. player.surface.index - 1, map_gen_settings())
if surface.index % 5 == 2 then global.dungeons.spawn_size = 60 else global.dungeons.spawn_size = 42 end
surface.request_to_generate_chunks({0,0}, 2)
surface.force_generate_chunk_requests()
surface.daytime = 0.25 + 0.30 * (surface.index / 52)
surface.freeze_daytime = true
surface.min_brightness = 0
surface.brightness_visual_weights = {1, 1, 1}
global.dungeons.surface_size[surface.index] = 200
global.dungeons.treasures[surface.index] = 0
game.print({"dungeons_tiered.first_visit", player.name, rpg[player.index].level, surface.index - 2}, {r = 0.8, g = 0.5, b = 0})
--Alert.alert_all_players(15, {"dungeons_tiered.first_visit", player.name, rpg[player.index].level, surface.index - 2}, {r=0.8,g=0.2,b=0},"recipe/artillery-targeting-remote", 0.7)
end
if button == defines.mouse_button_type.right then surface = game.surfaces[math.min(get_lowest_safe_floor(player), player.surface.index + 5)] end
if shift then surface = game.surfaces[get_lowest_safe_floor(player)] end
player.teleport(surface.find_non_colliding_position("character", {0, 0}, 50, 0.5), surface)
--player.print({"dungeons_tiered.travel_down"})
end
local function ascend(player, button, shift)
if player.surface.index <= 2 then
player.print({"dungeons_tiered.min_depth"})
return
end
if player.position.x^2 + player.position.y^2 > 400 then
player.print({"dungeons_tiered.only_on_spawn"})
return
end
local surface = game.surfaces[player.surface.index - 1]
if button == defines.mouse_button_type.right then surface = game.surfaces[math.max(2, player.surface.index - 5)] end
if shift then surface = game.surfaces[2] end
player.teleport(surface.find_non_colliding_position("character", {0, 0}, 50, 0.5), surface)
--player.print({"dungeons_tiered.travel_up"})
end
local function on_gui_click(event)
if not event then return end
if not event.element then return end
if not event.element.valid then return end
local button = event.button
local shift = event.shift
local player = game.players[event.element.player_index]
if event.element.name == "dungeon_down" then
descend(player, button, shift)
return
elseif event.element.name == "dungeon_up" then
ascend(player, button, shift)
return
end
end
local function on_surface_created(event)
local force = game.create_force("enemy" .. event.surface_index)
global.enemy_forces[event.surface_index] = force
global.biter_health_boost_forces[force.index] = 1
global.dungeons.depth[event.surface_index] = 100 * event.surface_index - 200
end
local function on_player_changed_surface(event)
draw_depth_gui()
end
-- local function on_player_changed_position(event)
-- local player = game.players[event.player_index]
-- local position = player.position
-- local surface = player.surface
-- if surface.index < 2 then return end
-- local size = global.dungeons.surface_size[surface.index]
-- if (size >= math.abs(player.position.y) and size < math.abs(player.position.y) + 1) or (size >= math.abs(player.position.x) and size < math.abs(player.position.x) + 1) then
-- Alert.alert_player_warning(player, 30, {"dungeons_tiered.too_small"}, {r=0.98,g=0.22,b=0})
-- end
-- end
local function transfer_items(surface_index)
if surface_index > 2 then
local inputs = global.dungeons.transport_chests_inputs[surface_index]
local outputs = global.dungeons.transport_chests_outputs[surface_index - 1]
for i = 1, 2, 1 do
if inputs[i].valid and outputs[i].valid then
local input_inventory = inputs[i].get_inventory(defines.inventory.chest)
local output_inventory = outputs[i].get_inventory(defines.inventory.chest)
input_inventory.sort_and_merge()
output_inventory.sort_and_merge()
for ii = 1, #input_inventory, 1 do
if input_inventory[ii].valid_for_read then
local count = output_inventory.insert(input_inventory[ii])
input_inventory[ii].count = input_inventory[ii].count - count
end
end
end
end
end
end
local function transfer_signals(surface_index)
if surface_index > 2 then
local inputs = global.dungeons.transport_poles_inputs[surface_index - 1]
local outputs = global.dungeons.transport_poles_outputs[surface_index]
for i = 1, 2, 1 do
if inputs[i].valid and outputs[i].valid then
local signals = inputs[i].get_merged_signals(defines.circuit_connector_id.electric_pole)
local combi = outputs[i].get_or_create_control_behavior()
for ii = 1, 15, 1 do
if signals and signals[ii] then
combi.set_signal(ii, signals[ii])
else
combi.set_signal(ii, nil)
end
end
end
end
end
end
-- local function setup_magic()
-- local rpg_spells = RPG_T.get("rpg_spells")
-- end
local function on_init()
local force = game.create_force("dungeon")
force.set_friend("enemy", false)
force.set_friend("player", false)
local surface = game.create_surface("dungeons_floor0", map_gen_settings())
surface.request_to_generate_chunks({0,0}, 2)
surface.force_generate_chunk_requests()
surface.daytime = 0.25
surface.freeze_daytime = true
local nauvis = game.surfaces[1]
nauvis.daytime = 0.25
nauvis.freeze_daytime = true
local map_gen_settings = nauvis.map_gen_settings
map_gen_settings.height = 3
map_gen_settings.width = 3
nauvis.map_gen_settings = map_gen_settings
for chunk in nauvis.get_chunks() do
nauvis.delete_chunk({chunk.x, chunk.y})
end
game.forces.player.manual_mining_speed_modifier = 0.5
game.map_settings.enemy_evolution.destroy_factor = 0
game.map_settings.enemy_evolution.pollution_factor = 0
game.map_settings.enemy_evolution.time_factor = 0
game.map_settings.enemy_expansion.enabled = true
game.map_settings.enemy_expansion.max_expansion_cooldown = 18000
game.map_settings.enemy_expansion.min_expansion_cooldown = 3600
game.map_settings.enemy_expansion.settler_group_max_size = 128
game.map_settings.enemy_expansion.settler_group_min_size = 16
game.map_settings.enemy_expansion.max_expansion_distance = 16
game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.50
game.difficulty_settings.technology_price_multiplier = 3
global.dungeons = {}
global.dungeons.tiered = true
global.dungeons.depth = {}
global.dungeons.depth[surface.index] = 0
global.dungeons.depth[nauvis.index] = 0
global.dungeons.spawn_size = 42
global.dungeons.spawner_tier = {}
global.dungeons.transport_chests_inputs = {}
global.dungeons.transport_chests_outputs = {}
global.dungeons.transport_poles_inputs = {}
global.dungeons.transport_poles_outputs = {}
global.dungeons.transport_surfaces = {}
global.dungeons.surface_size = {}
global.dungeons.surface_size[surface.index] = 200
global.dungeons.treasures = {}
global.dungeons.treasures[surface.index] = 0
global.dungeons.item_blacklist = true
global.enemy_forces = {}
global.enemy_forces[nauvis.index] = game.forces.enemy
global.enemy_forces[surface.index] = game.create_force("enemy" .. surface.index)
global.biter_health_boost_forces[game.forces.enemy.index] = 1
global.biter_health_boost_forces[global.enemy_forces[surface.index].index] = 1
global.rocks_yield_ore_base_amount = 100
global.rocks_yield_ore_distance_modifier = 0.001
game.forces.player.technologies["land-mine"].enabled = false
game.forces.player.technologies["landfill"].enabled = false
game.forces.player.technologies["cliff-explosives"].enabled = false
--recipes to be unlocked through playing--
for _, tech in pairs(locked_researches) do
game.forces.player.technologies[tech].enabled = false
end
RPG_T.set_surface_name("dungeons_floor")
local rpg_table = RPG_T.get("rpg_extra")
rpg_table.personal_tax_rate = 0
-- rpg_table.enable_mana = true
-- setup_magic()
local T = MapInfo.Pop_info()
T.localised_category = "dungeons_tiered"
T.main_caption_color = {r = 0, g = 0, b = 0}
T.sub_caption_color = {r = 150, g = 0, b = 20}
end
local function on_tick()
if game.tick % 60 == 0 then
if #global.dungeons.transport_surfaces > 0 then
for _,surface_index in pairs(global.dungeons.transport_surfaces) do
transfer_items(surface_index)
transfer_signals(surface_index)
end
end
end
--[[
if game.tick % 4 ~= 0 then return end
local surface = game.surfaces["dungeons"]
local entities = surface.find_entities_filtered({name = "rock-big"})
if not entities[1] then return end
local entity = entities[math_random(1, #entities)]
surface.request_to_generate_chunks(entity.position, 3)
surface.force_generate_chunk_requests()
game.forces.player.chart(surface, {{entity.position.x - 32, entity.position.y - 32}, {entity.position.x + 32, entity.position.y + 32}})
entity.die()
]]
end
local Event = require 'utils.event'
Event.on_init(on_init)
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_player_changed_position, on_player_changed_position)
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)
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
Event.add(defines.events.on_surface_created, on_surface_created)
Event.add(defines.events.on_gui_click, on_gui_click)
Event.add(defines.events.on_player_changed_surface, on_player_changed_surface)
require "modules.rocks_yield_ore"