1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-07 13:31:40 +02:00

dungeons fixes (should work on 1.1+ now) + glob table

This commit is contained in:
hanakocz 2021-03-09 02:58:52 +01:00
parent c369f1e01b
commit da93894188
16 changed files with 546 additions and 264 deletions

View File

@ -1,5 +1,6 @@
local Functions = require "maps.dungeons.functions"
local BiterRaffle = require "functions.biter_raffle"
local DungeonsTable = require 'maps.dungeons.table'
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
@ -10,15 +11,17 @@ local math_sqrt = math.sqrt
local math_floor = math.floor
local function add_enemy_units(surface, room)
local dungeontable = DungeonsTable.get_dungeontable()
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(surface.index) * 1.5)
local unit = surface.create_entity({name = name, position = tile.position, force = global.enemy_forces[surface.index]})
local unit = surface.create_entity({name = name, position = tile.position, force = dungeontable.enemy_forces[surface.index]})
end
end
end
local function acid_zone(surface, room)
local dungeontable = DungeonsTable.get_dungeontable()
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "concrete", position = tile.position}}, true)
end
@ -32,13 +35,13 @@ local function acid_zone(surface, room)
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(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = dungeontable.enemy_forces[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 = "spitter-spawner", position = tile.position, force = global.enemy_forces[surface.index]}), surface.index)
Functions.set_spawner_tier(surface.create_entity({name = "spitter-spawner", position = tile.position, force = dungeontable.enemy_forces[surface.index]}), surface.index)
end
end

View File

@ -1,5 +1,6 @@
local Functions = require "maps.dungeons.functions"
local BiterRaffle = require "functions.biter_raffle"
local DungeonsTable = require 'maps.dungeons.table'
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
@ -10,15 +11,17 @@ local math_sqrt = math.sqrt
local math_floor = math.floor
local function add_enemy_units(surface, room)
local dungeontable = DungeonsTable.get_dungeontable()
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(surface.index) * 1.5)
local unit = surface.create_entity({name = name, position = tile.position, force = global.enemy_forces[surface.index]})
local unit = surface.create_entity({name = name, position = tile.position, force = dungeontable.enemy_forces[surface.index]})
end
end
end
local function concrete(surface, room)
local dungeontable = DungeonsTable.get_dungeontable()
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "concrete", position = tile.position}}, true)
end
@ -35,7 +38,7 @@ local function concrete(surface, room)
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 = global.enemy_forces[surface.index]}), surface.index)
Functions.set_spawner_tier(surface.create_entity({name = "biter-spawner", position = tile.position, force = dungeontable.enemy_forces[surface.index]}), surface.index)
end
end

View File

@ -1,5 +1,6 @@
local Functions = require "maps.dungeons.functions"
local BiterRaffle = require "functions.biter_raffle"
local DungeonsTable = require 'maps.dungeons.table'
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
@ -164,6 +165,7 @@ local water_shapes = {
for _ = 1, 16, 1 do table_insert(water_shapes, squares) end
local function biome(surface, room)
local dungeontable = DungeonsTable.get_dungeontable()
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "concrete", position = tile.position}}, true)
end
@ -192,10 +194,10 @@ local function biome(surface, room)
Functions.crash_site_chest(surface, tile.position)
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 = global.enemy_forces[surface.index]}), surface.index)
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = dungeontable.enemy_forces[surface.index]}), surface.index)
end
if math_random(1, 64) == 1 then
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = dungeontable.enemy_forces[surface.index]})
end
end
end

View File

@ -1,5 +1,6 @@
local Functions = require "maps.dungeons.functions"
local Get_noise = require "utils.get_noise"
local DungeonsTable = require 'maps.dungeons.table'
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
@ -35,6 +36,7 @@ local function add_enemy_units(surface, room)
end
local function desert(surface, room)
local dungeontable = DungeonsTable.get_dungeontable()
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "sand-2", position = tile.position}}, true)
end
@ -63,14 +65,14 @@ local function desert(surface, room)
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 = global.enemy_forces[surface.index]}), surface.index)
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = dungeontable.enemy_forces[surface.index]}), surface.index)
end
if math_random(1, 160) == 1 then
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = dungeontable.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
surface.create_entity({name = "mineable-wreckage", position = tile.position})
Functions.create_scrap(surface, tile.position)
end
if math_random(1, 128) == 1 then
surface.create_entity({name = "rock-huge", position = tile.position})

View File

@ -1,5 +1,6 @@
local Functions = require "maps.dungeons.functions"
local Get_noise = require "utils.get_noise"
local DungeonsTable = require 'maps.dungeons.table'
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
@ -35,6 +36,7 @@ local function add_enemy_units(surface, room)
end
local function dirtlands(surface, room)
local dungeontable = DungeonsTable.get_dungeontable()
local path_tile = "dirt-" .. math_random(1, 3)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = path_tile, position = tile.position}}, true)
@ -55,14 +57,14 @@ local function dirtlands(surface, room)
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[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)
if key % 128 == 1 and math_random(1, 2) == 1 and dungeontable.depth[surface.index] > 8 then
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = dungeontable.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]})
if math_random(1, 320) == 1 and dungeontable.depth[surface.index] > 8 then
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = dungeontable.enemy_forces[surface.index]})
end
if math_random(1, 512) == 1 then
surface.create_entity({name = "mineable-wreckage", position = tile.position})
Functions.create_scrap(surface, tile.position)
end
if math_random(1, 256) == 1 then
surface.create_entity({name = "rock-huge", position = tile.position})

View File

@ -1,4 +1,5 @@
local Functions = require "maps.dungeons.functions"
local DungeonsTable = require 'maps.dungeons.table'
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
@ -14,6 +15,7 @@ local function add_enemy_units(surface, room)
end
local function doom(surface, room)
local dungeontable = DungeonsTable.get_dungeontable()
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "refined-concrete", position = tile.position}}, true)
end
@ -25,7 +27,7 @@ local function doom(surface, room)
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(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = dungeontable.enemy_forces[surface.index]})
end
if math_random(1, 320) == 1 then
Functions.rare_loot_crate(surface, tile.position)
@ -35,7 +37,7 @@ local function doom(surface, room)
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 = global.enemy_forces[surface.index]}), surface.index)
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = dungeontable.enemy_forces[surface.index]}), surface.index)
end
end

View File

@ -1,4 +1,5 @@
local Functions = require "maps.dungeons.functions"
local DungeonsTable = require 'maps.dungeons.table'
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
@ -9,6 +10,7 @@ local math_abs = math.abs
local ores = {"iron-ore", "copper-ore", "coal", "stone"}
local function glitch(surface, room)
local dungeontable = DungeonsTable.get_dungeontable()
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "lab-white", position = tile.position}}, true)
end
@ -22,7 +24,7 @@ local function glitch(surface, room)
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(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = dungeontable.enemy_forces[surface.index]})
end
if math_random(1, 96) == 1 then
Functions.common_loot_crate(surface, tile.position)

View File

@ -1,5 +1,6 @@
local Functions = require "maps.dungeons.functions"
local Get_noise = require "utils.get_noise"
local DungeonsTable = require 'maps.dungeons.table'
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
@ -37,6 +38,7 @@ local function add_enemy_units(surface, room)
end
local function grasslands(surface, room)
local dungeontable = DungeonsTable.get_dungeontable()
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "grass-1", position = tile.position}}, true)
end
@ -57,10 +59,10 @@ local function grasslands(surface, room)
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 = global.enemy_forces[surface.index]}), surface.index)
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = dungeontable.enemy_forces[surface.index]}), surface.index)
end
if math_random(1, 320) == 1 then
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = dungeontable.enemy_forces[surface.index]})
end
if math_random(1, 1024) == 1 then
surface.create_entity({name = "rock-huge", position = tile.position})

View File

@ -1,4 +1,5 @@
local Functions = require "maps.dungeons.functions"
local DungeonsTable = require 'maps.dungeons.table'
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
@ -18,6 +19,7 @@ local function add_enemy_units(surface, room)
end
local function red_desert(surface, room)
local dungeontable = DungeonsTable.get_dungeontable()
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "red-desert-0", position = tile.position}}, true)
end
@ -33,10 +35,10 @@ local function red_desert(surface, room)
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 = global.enemy_forces[surface.index]}), surface.index)
Functions.set_spawner_tier(surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = dungeontable.enemy_forces[surface.index]}), surface.index)
end
if math_random(1, 256) == 1 then
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = global.enemy_forces[surface.index]})
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = dungeontable.enemy_forces[surface.index]})
end
if math_random(1, 32) == 1 then
surface.create_entity({name = "rock-huge", position = tile.position})

View File

@ -1,8 +1,9 @@
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 BiterHealthBooster = require 'modules.biter_health_booster_v2'
local Alert = require 'utils.alert'
local DungeonsTable = require 'maps.dungeons.table'
local math_floor = math.floor
local math_min = math.min
local math_random = math.random
@ -14,7 +15,8 @@ local arena_areas = {
[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 arenatable = DungeonsTable.get_arenatable()
local surface = game.surfaces['dungeons_floor_arena']
local area = arena_areas[arena].area
surface.request_to_generate_chunks(arena_areas[arena].center, 2)
surface.force_generate_chunk_requests()
@ -34,17 +36,19 @@ local function create_arena(arena)
e.destructible = false
e.minable = false
end
global.arena.created[arena] = true
arenatable.created[arena] = true
end
local function reset_arena(arena)
global.arena.timer[arena] = -100
global.arena.active_player[arena] = nil
local arenatable = DungeonsTable.get_arenatable()
arenatable.timer[arena] = -100
arenatable.active_player[arena] = nil
end
local function wipedown_arena(arena)
local player = global.arena.active_player[arena]
local surface = game.surfaces['nauvis']
local arenatable = DungeonsTable.get_arenatable()
local player = arenatable.active_player[arena]
local surface = game.surfaces['dungeons_floor_arena']
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'}
@ -94,9 +98,10 @@ local function calculate_dmg(level)
end
local function draw_boss_gui()
local arenatable = DungeonsTable.get_arenatable()
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 level = arenatable.bosses[player.index] or 0
local tooltip = {
'dungeons_tiered.boss_arena',
level,
@ -110,10 +115,11 @@ local function draw_boss_gui()
end
local function update_boss_gui(player)
local arenatable = DungeonsTable.get_arenatable()
if not player.gui.top.boss_arena then
draw_boss_gui()
end
local level = global.arena.bosses[player.index] or 0
local level = arenatable.bosses[player.index] or 0
local tooltip = {
'dungeons_tiered.boss_arena',
level,
@ -125,19 +131,22 @@ local function update_boss_gui(player)
end
local function arena_occupied(arena)
if global.arena.active_player[arena] then
local arenatable = DungeonsTable.get_arenatable()
if arenatable.active_player[arena] then
return true
end
if global.arena.active_boss[arena] then
if arenatable.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)
local forceshp = BiterHealthBooster.get('biter_health_boost_forces')
local arenatable = DungeonsTable.get_arenatable()
local surface = game.surfaces['dungeons_floor_arena']
local force = game.forces[arenatable.enemies[arena].index]
forceshp[force.index] = calculate_hp(level)
force.set_ammo_damage_modifier('melee', calculate_dmg(level))
force.set_ammo_damage_modifier('biological', calculate_dmg(level))
local pos = {x = arena_areas[arena].center[1], y = arena_areas[arena].center[2]}
@ -145,7 +154,7 @@ local function spawn_boss(arena, biter, level)
pos.y = pos.y - 6 + math_random(0, 12)
local boss = surface.create_entity({name = biter, position = pos, force = force})
boss.ai_settings.allow_try_return_to_spawner = false
global.arena.active_boss[arena] = boss
arenatable.active_boss[arena] = boss
rendering.draw_text {
text = 'Boss lvl ' .. level,
surface = surface,
@ -157,7 +166,7 @@ local function spawn_boss(arena, biter, level)
alignment = 'center',
scale_with_zoom = false
}
BiterHealthBooster.add_boss_unit(boss, global.biter_health_boost_forces[force.index] * 8, 0.25)
BiterHealthBooster.add_boss_unit(boss, forceshp[force.index] * 8, 0.25)
end
local function hide_rpg(player, show)
@ -187,26 +196,29 @@ local function hide_rpg(player, show)
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 arenatable = DungeonsTable.get_arenatable()
local surface = arenatable.previous_position[arena].surface
local position = arenatable.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
arenatable.previous_position[arena].position = nil
arenatable.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 arenatable = DungeonsTable.get_arenatable()
local surface = game.surfaces['dungeons_floor_arena']
arenatable.previous_position[arena].position = player.position
arenatable.previous_position[arena].surface = player.surface
arenatable.timer[arena] = game.tick
local rpg = RPG_T.get('rpg_t')
rpg[player.index].one_punch = false
rpg[player.index].enable_entity_spawn = false
hide_rpg(player, false)
local pos = {x = arena_areas[arena].center[1], y = arena_areas[arena].center[2]}
@ -214,30 +226,31 @@ local function teleport_player_in(arena, player)
pos.y = pos.y - 6 + math_random(0, 12)
player.teleport(surface.find_non_colliding_position('character', pos, 20, 0.5), surface)
global.arena.active_player[arena] = player
arenatable.active_player[arena] = player
local group = game.permissions.get_group('Arena')
group.add_player(player)
end
local function player_died(arena, player)
local arenatable = DungeonsTable.get_arenatable()
wipedown_arena(arena)
global.arena.active_player[arena] = nil
if global.arena.active_boss[arena] and global.arena.active_boss[arena].valid then
global.arena.active_boss[arena].destroy()
arenatable.active_player[arena] = nil
if arenatable.active_boss[arena] and arenatable.active_boss[arena].valid then
arenatable.active_boss[arena].destroy()
end
global.arena.active_boss[arena] = nil
global.arena.timer[arena] = -100
arenatable.active_boss[arena] = nil
arenatable.timer[arena] = -100
teleport_player_out(arena, player)
player.character.health = 5
if not global.arena.won[arena] then --incase of death after victory
local level = global.arena.bosses[player.index]
--game.print({"dungeons_tiered.player_lost", player.name, global.arena.bosses[player.index]})
if not arenatable.won[arena] then --incase of death after victory
local level = arenatable.bosses[player.index]
--game.print({"dungeons_tiered.player_lost", player.name, arenatable.bosses[player.index]})
if level % 10 == 0 and level > 0 then
Alert.alert_all_players(
8,
{'dungeons_tiered.player_lost', player.name, global.arena.bosses[player.index]},
{'dungeons_tiered.player_lost', player.name, arenatable.bosses[player.index]},
{r = 0.8, g = 0.2, b = 0},
'entity/behemoth-biter',
0.7
@ -246,7 +259,7 @@ local function player_died(arena, player)
Alert.alert_player(
player,
8,
{'dungeons_tiered.player_lost', player.name, global.arena.bosses[player.index]},
{'dungeons_tiered.player_lost', player.name, arenatable.bosses[player.index]},
{r = 0.8, g = 0.2, b = 0},
'entity/behemoth-biter',
0.7
@ -256,18 +269,19 @@ local function player_died(arena, player)
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]
local arenatable = DungeonsTable.get_arenatable()
arenatable.active_boss[arena] = nil
local player = arenatable.active_player[arena]
local level = arenatable.bosses[player.index]
wipedown_arena(arena)
global.arena.won[arena] = true
global.arena.timer[arena] = game.tick - 30
arenatable.won[arena] = true
arenatable.timer[arena] = game.tick - 30
--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(
8,
{'dungeons_tiered.player_won', player.name, global.arena.bosses[player.index]},
{'dungeons_tiered.player_won', player.name, arenatable.bosses[player.index]},
{r = 0.8, g = 0.2, b = 0},
'entity/behemoth-biter',
0.7
@ -276,22 +290,23 @@ local function boss_died(arena)
Alert.alert_player(
player,
8,
{'dungeons_tiered.player_won', player.name, global.arena.bosses[player.index]},
{'dungeons_tiered.player_won', player.name, arenatable.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
--global.arena.timer[arena] = -100
--game.print({"dungeons_tiered.player_won", player.name, arenatable.bosses[player.index]})
arenatable.bosses[player.index] = arenatable.bosses[player.index] + 1
--arenatable.active_player[arena] = nil
--arenatable.timer[arena] = -100
update_boss_gui(player)
end
local function choose_arena()
local arenatable = DungeonsTable.get_arenatable()
for i = 1, 4, 1 do
if not global.arena.created[i] then
if not arenatable.created[i] then
create_arena(i)
end
if not arena_occupied(i) then
@ -302,10 +317,11 @@ local function choose_arena()
end
local function enter_arena(player)
local arenatable = DungeonsTable.get_arenatable()
if not player.character then
return
end
if player.surface.name == 'nauvis' then
if player.surface.name == 'dungeons_floor_arena' then
return
end
local chosen_arena = choose_arena()
@ -324,7 +340,7 @@ local function enter_arena(player)
return
end
local level = global.arena.bosses[player.index]
local level = arenatable.bosses[player.index]
if level > 100 then
Alert.alert_player_warning(player, 8, {'dungeons_tiered.arena_level_max'})
return
@ -332,14 +348,15 @@ local function enter_arena(player)
--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)
global.arena.won[chosen_arena] = false
arenatable.won[chosen_arena] = false
teleport_player_in(chosen_arena, player)
end
local function on_player_joined_game(event)
local arenatable = DungeonsTable.get_arenatable()
draw_boss_gui()
if not global.arena.bosses[event.player_index] then
global.arena.bosses[event.player_index] = 0
if not arenatable.bosses[event.player_index] then
arenatable.bosses[event.player_index] = 0
end
end
@ -361,36 +378,39 @@ local function on_gui_click(event)
end
local function on_pre_player_died(event)
local arenatable = DungeonsTable.get_arenatable()
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
if player == arenatable.active_player[i] then
player_died(i, player)
end
end
end
local function on_pre_player_left_game(event)
local arenatable = DungeonsTable.get_arenatable()
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
if player == arenatable.active_player[i] then
player_died(i, player)
end
end
end
local function on_entity_died(event)
local arenatable = DungeonsTable.get_arenatable()
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
if entity == arenatable.active_boss[i] then
boss_died(i)
end
end
@ -429,27 +449,28 @@ local function acid_spit(surface, biter, player, tier)
end
local function boss_attacks(i)
if not global.arena.active_boss[i] then
local arenatable = DungeonsTable.get_arenatable()
if not arenatable.active_boss[i] then
return
end
if not global.arena.active_player[i] then
if not arenatable.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']
local biter = arenatable.active_boss[i]
local player = arenatable.active_player[i]
local surface = game.surfaces['dungeons_floor_arena']
--if not biter.valid or not player.valid or not player.character or not player.character.valid then return end
if not biter or not player or not player.character then
return
end
if global.arena.bosses[player.index] >= 80 then
if arenatable.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
if arenatable.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
if arenatable.timer[i] + 7200 < game.tick and game.tick % 120 == 0 then
shoot(surface, biter, player)
end
if biter.name == 'small-spitter' then
@ -470,17 +491,18 @@ local function tick()
end
local function arena_ticker()
local arenatable = DungeonsTable.get_arenatable()
for i = 1, 4, 1 do
if global.arena.timer[i] == game.tick - 90 then
if arenatable.timer[i] == game.tick - 90 then
--game.print("I did a delay")
local player = global.arena.active_player[i]
local player = arenatable.active_player[i]
if player.valid then
if global.arena.won[i] then
if arenatable.won[i] then
--game.print("You won, now get lost")
teleport_player_out(i, player)
else
local level = global.arena.bosses[player.index]
local level = arenatable.bosses[player.index]
local biter_names = {
{'small-biter', 'small-spitter'},
@ -497,21 +519,13 @@ local function arena_ticker()
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] = -100, [2] = -100, [3] = -100, [4] = -100}
global.arena.won = {[1] = false, [2] = false, [3] = false, [4] = false}
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 arenatable = DungeonsTable.get_arenatable()
local arena = game.permissions.create_group('Arena')
local arena_surface = game.create_surface('dungeons_floor_arena')
local map_gen_settings = arena_surface.map_gen_settings
map_gen_settings.height = 3
map_gen_settings.width = 3
arena_surface.map_gen_settings = map_gen_settings
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)
@ -523,7 +537,7 @@ local function on_init()
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, 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)
@ -531,7 +545,7 @@ local function on_init()
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
arenatable.enemies[i] = force
force.maximum_following_robot_count = 100
force.following_robots_lifetime_modifier = 600
force.set_ammo_damage_modifier('beam', 1)

View File

@ -3,6 +3,8 @@ local Public = {}
local BiterRaffle = require "functions.biter_raffle"
local LootRaffle = require "functions.loot_raffle"
local Get_noise = require "utils.get_noise"
local DungeonsTable = require 'maps.dungeons.table'
local RPG_T = require 'modules.rpg.table'
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
@ -12,20 +14,22 @@ local math_abs = math.abs
local math_floor = math.floor
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 - global.dungeons.original_surface_index) * 0.05 + 0.05)
local dungeontable = DungeonsTable.get_dungeontable()
local e = dungeontable.depth[surface_index] * 0.0005
if dungeontable.tiered then
e = math.min(e, (surface_index - dungeontable.original_surface_index) * 0.05 + 0.05)
end
return e
end
local function blacklist(surface_index, special)
local dungeontable = DungeonsTable.get_dungeontable()
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 dungeontable.item_blacklist and not special then
if evolution_factor < 0.9 then
blacklist["discharge-defense-equipment"] = true
blacklist["power-armor-mk2"] = true
@ -58,6 +62,21 @@ local function blacklist(surface_index, special)
return blacklist
end
local function special_loot(value)
local items = {
[1] = {item = 'tank-machine-gun', value = 16384},
[2] = {item = 'tank-cannon', value = 32728},
[3] = {item = 'artillery-wagon-cannon', value = 65536}
}
if math_random(1, 20) == 1 then
local roll = math_random(1, #items)
if items[roll].value < value then
return {loot = {name = items[roll].item, count = 1}, value = value - items[roll].value}
end
end
return {loot = nil, value = value}
end
function Public.roll_spawner_name()
if math_random(1, 3) == 1 then
return "spitter-spawner"
@ -70,19 +89,26 @@ function Public.roll_worm_name(surface_index)
end
function Public.get_crude_oil_amount(surface_index)
local dungeontable = DungeonsTable.get_dungeontable()
local amount = math_random(200000, 400000) + Public.get_dungeon_evolution_factor(surface_index) * 500000
if global.dungeons.tiered then amount = amount / 4 end
if dungeontable.tiered then amount = amount / 4 end
return amount
end
function Public.get_common_resource_amount(surface_index)
local dungeontable = DungeonsTable.get_dungeontable()
local amount = math_random(350, 700) + Public.get_dungeon_evolution_factor(surface_index) * 16000
if global.dungeons.tiered then amount = amount / 8 end
if dungeontable.tiered then amount = amount / 8 end
return amount
end
local function get_loot_value(surface_index, multiplier)
local value = Public.get_dungeon_evolution_factor(surface_index) * 4000 * multiplier
return value
end
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 item_stacks = LootRaffle.roll(get_loot_value(surface.index, 1) + 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)
@ -91,7 +117,7 @@ function Public.common_loot_crate(surface, position, special)
end
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 item_stacks = LootRaffle.roll(get_loot_value(surface.index, 2) + 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)
@ -100,7 +126,7 @@ function Public.uncommon_loot_crate(surface, position, special)
end
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 item_stacks = LootRaffle.roll(get_loot_value(surface.index, 4) + 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)
@ -109,8 +135,19 @@ function Public.rare_loot_crate(surface, position, special)
end
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"})
local dungeontable = DungeonsTable.get_dungeontable()
local loot_value = get_loot_value(surface.index, 8) + math_random(512, 1024)
local bonus_loot = nil
if dungeontable.tiered and loot_value > 32000 and Public.get_dungeon_evolution_factor(surface_index) > 1 then
local bonus = special_loot(loot_value)
bonus_loot = bonus.loot
loot_value = loot_value - bonus.value
end
local item_stacks = LootRaffle.roll(loot_value, 48, blacklist(surface.index, special))
local container = surface.create_entity({name = "blue-chest", position = position, force = "neutral"})
if bonus_loot then
container.insert(bonus_loot)
end
for _, item_stack in pairs(item_stacks) do
container.insert(item_stack)
end
@ -118,7 +155,7 @@ function Public.epic_loot_crate(surface, position, special)
end
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 item_stacks = LootRaffle.roll(get_loot_value(surface.index, 3) + 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)
@ -209,9 +246,10 @@ function Public.add_room_loot_crates(surface, room)
end
function Public.set_spawner_tier(spawner, surface_index)
local dungeontable = DungeonsTable.get_dungeontable()
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
dungeontable.spawner_tier[spawner.unit_number] = tier
--[[
rendering.draw_text{
text = "-Tier " .. tier .. "-",
@ -228,13 +266,14 @@ function Public.set_spawner_tier(spawner, surface_index)
end
function Public.spawn_random_biter(surface, position)
local dungeontable = DungeonsTable.get_dungeontable()
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 = global.enemy_forces[surface.index]})
unit = surface.create_entity({name = name, position = non_colliding_position, force = dungeontable.enemy_forces[surface.index]})
else
unit = surface.create_entity({name = name, position = position, force = global.enemy_forces[surface.index]})
unit = surface.create_entity({name = name, position = position, force = dungeontable.enemy_forces[surface.index]})
end
unit.ai_settings.allow_try_return_to_spawner = false
unit.ai_settings.allow_destroy_when_commands_fail = false
@ -258,6 +297,83 @@ function Public.place_border_rock(surface, position)
surface.create_entity({name = "rock-big", position = pos})
end
function Public.create_scrap(surface, position)
local scraps = {
"crash-site-spaceship-wreck-small-1",
"crash-site-spaceship-wreck-small-1",
"crash-site-spaceship-wreck-small-2",
"crash-site-spaceship-wreck-small-2",
"crash-site-spaceship-wreck-small-3",
"crash-site-spaceship-wreck-small-3",
"crash-site-spaceship-wreck-small-4",
"crash-site-spaceship-wreck-small-4",
"crash-site-spaceship-wreck-small-5",
"crash-site-spaceship-wreck-small-5",
"crash-site-spaceship-wreck-small-6"
}
surface.create_entity({name = scraps[math_random(1, #scraps)], position = position, force = "neutral"})
end
local function get_ore_amount(surface_index)
local dungeontable = DungeonsTable.get_dungeontable()
local scaling = game.forces.player.mining_drill_productivity_bonus
local amount = 5000 * Public.get_dungeon_evolution_factor(surface_index) * (1 + scaling)
if amount > 500 then amount = 500 end
amount = math_random(math_floor(amount * 0.7), math_floor(amount * 1.3))
if amount < 1 then amount = 1 end
return amount
end
local function reward_ores(amount, mined_loot, surface, player, entity)
local a = 0
if player then a = player.insert {name = mined_loot, count = amount} end
amount = amount - a
if amount > 0 then
if amount >= 50 then
for i = 1, math_floor(amount / 50), 1 do
local e = surface.create_entity{name = "item-on-ground", position = entity.position, stack = {name = mined_loot, count = 50}}
if e and e.valid then e.to_be_looted = true end
amount = amount - 50
end
end
if amount > 0 then
if amount < 5 then
surface.spill_item_stack(entity.position,{name = mined_loot, count = amount}, true)
else
local e = surface.create_entity{name = "item-on-ground", position = entity.position, stack = {name = mined_loot, count = amount}}
if e and e.valid then e.to_be_looted = true end
end
end
end
end
local function flying_text(surface, position, text, color)
surface.create_entity({
name = "flying-text",
position = {position.x, position.y - 0.5},
text = text,
color = color
})
end
function Public.rocky_loot(event)
if not event.entity or not event.entity.valid then return end
local allowed = {
["rock-big"] = true,
["rock-huge"] = true,
["sand-rock-big"] = true
}
if not allowed[event.entity.name] then return end
local player = game.players[event.player_index]
local amount = math.ceil(get_ore_amount(player.surface.index))
local rock_mining = {"iron-ore", "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "copper-ore", "stone", "stone", "coal", "coal"}
local mined_loot = rock_mining[math_random(1,#rock_mining)]
local text = "+" .. amount .. " [item=" .. mined_loot .. "]"
flying_text(player.surface, player.position, text, {r = 0.98, g = 0.66, b = 0.22})
reward_ores(amount, mined_loot, player.surface, player, player)
event.buffer.clear()
end
function Public.mining_events(entity)
if math_random(1, 16) == 1 then Public.spawn_random_biter(entity.surface, entity.position) return end
if math_random(1, 24) == 1 then Public.common_loot_crate(entity.surface, entity.position) return end
@ -267,7 +383,8 @@ function Public.mining_events(entity)
end
function Public.draw_spawn(surface)
local spawn_size = global.dungeons.spawn_size
local dungeontable = DungeonsTable.get_dungeontable()
local spawn_size = dungeontable.spawn_size
for _, e in pairs(surface.find_entities({{spawn_size * -1, spawn_size * -1}, {spawn_size, spawn_size}})) do
e.destroy()
@ -379,35 +496,35 @@ function Public.draw_spawn(surface)
if k % 3 > 0 then surface.create_entity(e) end
end
if global.dungeons.tiered then
if surface.index > global.dungeons.original_surface_index then
table.insert(global.dungeons.transport_surfaces, surface.index)
global.dungeons.transport_chests_inputs[surface.index] = {}
if dungeontable.tiered then
if surface.index > dungeontable.original_surface_index then
table.insert(dungeontable.transport_surfaces, surface.index)
dungeontable.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
dungeontable.transport_chests_inputs[surface.index][i] = chest
chest.destructible = false
chest.minable = false
end
global.dungeons.transport_poles_outputs[surface.index] = {}
dungeontable.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
dungeontable.transport_poles_outputs[surface.index][i] = pole
pole.destructible = false
pole.minable = false
end
end
global.dungeons.transport_chests_outputs[surface.index] = {}
dungeontable.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
dungeontable.transport_chests_outputs[surface.index][i] = chest
chest.destructible = false
chest.minable = false
end
global.dungeons.transport_poles_inputs[surface.index] = {}
dungeontable.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
dungeontable.transport_poles_inputs[surface.index][i] = pole
pole.destructible = false
pole.minable = false
end

View File

@ -10,6 +10,7 @@ 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 DungeonsTable = require 'maps.dungeons.table'
local Biomes = {}
Biomes.dirtlands = require "maps.dungeons.biome_dirtlands"
@ -36,7 +37,12 @@ local disabled_for_deconstruction = {
["rock-huge"] = true,
["rock-big"] = true,
["sand-rock-big"] = true,
["mineable-wreckage"] = true
["crash-site-spaceship-wreck-small-1"] = true,
["crash-site-spaceship-wreck-small-2"] = true,
["crash-site-spaceship-wreck-small-3"] = true,
["crash-site-spaceship-wreck-small-4"] = true,
["crash-site-spaceship-wreck-small-5"] = true,
["crash-site-spaceship-wreck-small-6"] = true
}
local function get_biome(position)
@ -69,12 +75,13 @@ local function get_biome(position)
end
local function draw_depth_gui()
local dungeontable = DungeonsTable.get_dungeontable()
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
if surface.name == "gulag" then return end
local element = player.gui.top.add({type = "sprite-button", name = "dungeon_depth"})
element.caption = {"dungeons.depth", global.dungeons.depth[surface.index]}
element.caption = {"dungeons.depth", dungeontable.depth[surface.index]}
element.tooltip = {
"dungeons.depth_tooltip",
Functions.get_dungeon_evolution_factor(surface.index) * 100,
@ -96,6 +103,7 @@ local function draw_depth_gui()
end
local function expand(surface, position)
local dungeontable = DungeonsTable.get_dungeontable()
local room = Room_generator.get_room(surface, position)
if not room then return end
local name = get_biome(position)
@ -105,7 +113,7 @@ local function expand(surface, position)
local a = 2000
global.dungeons.depth[surface.index] = global.dungeons.depth[surface.index] + 1
dungeontable.depth[surface.index] = dungeontable.depth[surface.index] + 1
local evo = Functions.get_dungeon_evolution_factor(surface.index)
@ -147,11 +155,12 @@ local function init_player(player)
end
local function on_entity_spawned(event)
local dungeontable = DungeonsTable.get_dungeontable()
local spawner = event.spawner
local unit = event.entity
local surface = spawner.surface
local spawner_tier = global.dungeons.spawner_tier
local spawner_tier = dungeontable.spawner_tier
if not spawner_tier[spawner.unit_number] then
Functions.set_spawner_tier(spawner, surface.index)
end
@ -246,18 +255,19 @@ local function on_player_joined_game(event)
end
local function spawner_death(entity)
local tier = global.dungeons.spawner_tier[entity.unit_number]
local dungeontable = DungeonsTable.get_dungeontable()
local tier = dungeontable.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]
tier = dungeontable.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
dungeontable.spawner_tier[entity.unit_number] = nil
end
--make expansion rocks very durable against biters
@ -300,6 +310,7 @@ local function on_marked_for_deconstruction(event)
end
local function on_init()
local dungeontable = DungeonsTable.get_dungeontable()
local force = game.create_force("dungeon")
force.set_friend("enemy", false)
force.set_friend("player", false)
@ -343,15 +354,10 @@ local function on_init()
game.map_settings.enemy_expansion.max_expansion_distance = 16
game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.50
global.dungeons = {}
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
dungeontable.tiered = false
dungeontable.depth[1] = 0
dungeontable.depth[game.surfaces["dungeons"].index] = 0
dungeontable.enemy_forces[game.surfaces["dungeons"].index] = game.forces.enemy
global.rocks_yield_ore_base_amount = 100
global.rocks_yield_ore_distance_modifier = 0.001

77
maps/dungeons/table.lua Normal file
View File

@ -0,0 +1,77 @@
-- one table to rule them all!
local Global = require 'utils.global'
local Event = require 'utils.event'
local dungeontable = {}
local arenatable = {}
local Public = {}
Global.register(
dungeontable,
function(tbl)
dungeontable = tbl
end
)
Global.register(
arenatable,
function(tbl)
arenatable = tbl
end
)
function Public.reset_arenatable()
for k, _ in pairs(arenatable) do
arenatable[k] = nil
end
arenatable.bosses = {}
arenatable.created = {[1] = false, [2] = false, [3] = false, [4] = false}
arenatable.active_player = {[1] = nil, [2] = nil, [3] = nil, [4] = nil}
arenatable.active_boss = {[1] = nil, [2] = nil, [3] = nil, [4] = nil}
arenatable.enemies = {[1] = nil, [2] = nil, [3] = nil, [4] = nil}
arenatable.timer = {[1] = -100, [2] = -100, [3] = -100, [4] = -100}
arenatable.won = {[1] = false, [2] = false, [3] = false, [4] = false}
arenatable.previous_position = {
[1] = {position = nil, surface = nil},
[2] = {position = nil, surface = nil},
[3] = {position = nil, surface = nil},
[4] = {position = nil, surface = nil}
}
end
function Public.reset_dungeontable()
for k, _ in pairs(dungeontable) do
dungeontable[k] = nil
end
dungeontable.tiered = false
dungeontable.depth = {}
dungeontable.spawn_size = 42
dungeontable.spawner_tier = {}
dungeontable.transport_chests_inputs = {}
dungeontable.transport_chests_outputs = {}
dungeontable.transport_poles_inputs = {}
dungeontable.transport_poles_outputs = {}
dungeontable.transport_surfaces = {}
dungeontable.surface_size = {}
dungeontable.treasures = {}
dungeontable.mage_towers = {0, 0, 0, 0, 0, 0, 0, 0}
dungeontable.item_blacklist = false
dungeontable.original_surface_index = 1
dungeontable.enemy_forces = {}
end
function Public.get_arenatable()
return arenatable
end
function Public.get_dungeontable()
return dungeontable
end
local function on_init()
Public.reset_arenatable()
Public.reset_dungeontable()
end
Event.on_init(on_init)
return Public

View File

@ -9,11 +9,12 @@ 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 BiterHealthBooster = require "modules.biter_health_booster_v2"
local BiterRaffle = require "functions.biter_raffle"
local Functions = require "maps.dungeons.functions"
local Get_noise = require "utils.get_noise"
local Alert = require 'utils.alert'
local DungeonsTable = require 'maps.dungeons.table'
require 'maps.dungeons.boss_arena'
local Biomes = {}
@ -44,7 +45,12 @@ local disabled_for_deconstruction = {
["rock-huge"] = true,
["rock-big"] = true,
["sand-rock-big"] = true,
["mineable-wreckage"] = true
["crash-site-spaceship-wreck-small-1"] = true,
["crash-site-spaceship-wreck-small-2"] = true,
["crash-site-spaceship-wreck-small-3"] = true,
["crash-site-spaceship-wreck-small-4"] = true,
["crash-site-spaceship-wreck-small-5"] = true,
["crash-site-spaceship-wreck-small-6"] = true
}
local function get_biome(position, surface_index)
@ -116,26 +122,29 @@ local function draw_arrows_gui()
end
local function get_surface_research(index)
return locked_researches[index - global.dungeons.original_surface_index]
local dungeontable = DungeonsTable.get_dungeontable()
return locked_researches[index - dungeontable.original_surface_index]
end
local function draw_depth_gui()
local dungeontable = DungeonsTable.get_dungeontable()
local forceshp = BiterHealthBooster.get("biter_health_boost_forces")
for _, player in pairs(game.connected_players) do
local surface = player.surface
local techs = 0
if get_surface_research(surface.index) and game.forces.player.technologies[get_surface_research(surface.index)].enabled == false then techs = 1 end
local enemy_force = global.enemy_forces[surface.index]
local enemy_force = dungeontable.enemy_forces[surface.index]
if player.gui.top.dungeon_depth then player.gui.top.dungeon_depth.destroy() end
if surface.name == "gulag" or surface.name == "nauvis" then return end
if surface.name == "gulag" or surface.name == "nauvis" or surface.name == "dungeons_floor_arena" then return end
local element = player.gui.top.add({type = "sprite-button", name = "dungeon_depth"})
element.caption = {"dungeons_tiered.depth", surface.index - global.dungeons.original_surface_index, global.dungeons.depth[surface.index]}
element.caption = {"dungeons_tiered.depth", surface.index - dungeontable.original_surface_index, dungeontable.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,
forceshp[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],
dungeontable.treasures[surface.index],
techs
}
@ -153,14 +162,17 @@ local function draw_depth_gui()
end
local function unlock_researches(surface_index)
local dungeontable = DungeonsTable.get_dungeontable()
local tech = game.forces.player.technologies
if get_surface_research(surface_index) and tech[get_surface_research(surface_index)].enabled == false then
tech[get_surface_research(surface_index)].enabled = true
game.print({"dungeons_tiered.tech_unlock", "[technology=" .. get_surface_research(surface_index) .. "]", surface_index - global.dungeons.original_surface_index})
game.print({"dungeons_tiered.tech_unlock", "[technology=" .. get_surface_research(surface_index) .. "]", surface_index - dungeontable.original_surface_index})
end
end
local function expand(surface, position)
local dungeontable = DungeonsTable.get_dungeontable()
local forceshp = BiterHealthBooster.get("biter_health_boost_forces")
local room
local roll = math_random(1,100)
if roll > 96 then
@ -175,13 +187,13 @@ local function expand(surface, position)
room = Room_generator.get_room(surface, position, "square")
end
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
if dungeontable.treasures[surface.index] < 5 and dungeontable.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 - global.dungeons.original_surface_index}, {r = 0.88, g = 0.22, b = 0})
dungeontable.treasures[surface.index] = dungeontable.treasures[surface.index] + 1
game.print({"dungeons_tiered.treasure_room", surface.index - dungeontable.original_surface_index}, {r = 0.88, g = 0.22, b = 0})
end
elseif global.dungeons.surface_size[surface.index] >= 225 and math.random(1,50) == 1 and get_surface_research(surface.index) and game.forces.player.technologies[get_surface_research(surface.index)].enabled == false then
elseif dungeontable.surface_size[surface.index] >= 225 and math.random(1,50) == 1 and get_surface_research(surface.index) and game.forces.player.technologies[get_surface_research(surface.index)].enabled == false then
Biomes["laboratory"](surface, room)
if room.room_tiles[1] then
unlock_researches(surface.index)
@ -195,16 +207,16 @@ local function expand(surface, position)
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 - global.dungeons.original_surface_index)) / 4
dungeontable.depth[surface.index] = dungeontable.depth[surface.index] + 1
dungeontable.surface_size[surface.index] = 200 + (dungeontable.depth[surface.index] - 100 * (surface.index - dungeontable.original_surface_index)) / 4
local evo = Functions.get_dungeon_evolution_factor(surface.index)
local force = global.enemy_forces[surface.index]
local force = dungeontable.enemy_forces[surface.index]
force.evolution_factor = evo
if evo > 1 then
global.biter_health_boost_forces[force.index] = 3 + ((evo - 1) * 4)
forceshp[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)
@ -212,10 +224,10 @@ local function expand(surface, position)
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
forceshp[force.index] = 1 + evo * 2
end
global.biter_health_boost_forces[force.index] = math_round(global.biter_health_boost_forces[force.index], 2)
forceshp[force.index] = math_round(forceshp[force.index], 2)
draw_depth_gui()
end
@ -261,12 +273,14 @@ local function init_player(player, surface)
end
local function on_entity_spawned(event)
local dungeontable = DungeonsTable.get_dungeontable()
local forceshp = BiterHealthBooster.get("biter_health_boost_forces")
local spawner = event.spawner
local unit = event.entity
local surface = spawner.surface
local force = unit.force
local spawner_tier = global.dungeons.spawner_tier
local spawner_tier = dungeontable.spawner_tier
if not spawner_tier[spawner.unit_number] then
Functions.set_spawner_tier(spawner, surface.index)
end
@ -285,18 +299,18 @@ local function on_entity_spawned(event)
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)
BiterHealthBooster.add_boss_unit(bonus_unit, forceshp[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)
BiterHealthBooster.add_boss_unit(unit, forceshp[force.index] * 8, 0.25)
end
end
local function on_chunk_generated(event)
local surface = event.surface
if surface.name == "nauvis" or surface.name == "gulag" then return end
if surface.name == "nauvis" or surface.name == "gulag" or surface.name == "dungeons_floor_arena" then return end
local left_top = event.area.left_top
@ -363,26 +377,28 @@ local function on_player_joined_game(event)
end
local function spawner_death(entity)
local tier = global.dungeons.spawner_tier[entity.unit_number]
local dungeontable = DungeonsTable.get_dungeontable()
local tier = dungeontable.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]
tier = dungeontable.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
dungeontable.spawner_tier[entity.unit_number] = nil
end
--make expansion rocks very durable against biters
local function on_entity_damaged(event)
local dungeontable = DungeonsTable.get_dungeontable()
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 entity.surface.name == "nauvis" or entity.surface.name == "dungeons_floor_arena" then return end
local size = dungeontable.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
@ -399,11 +415,12 @@ local function on_entity_damaged(event)
end
local function on_player_mined_entity(event)
local dungeontable = DungeonsTable.get_dungeontable()
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]
local size = dungeontable.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()
@ -415,12 +432,15 @@ local function on_player_mined_entity(event)
end
if entity.type == "simple-entity" then
Functions.mining_events(entity)
Functions.rocky_loot(event)
end
if entity.name ~= "rock-big" then return end
expand(entity.surface, entity.position)
end
local function on_entity_died(event)
local rpg_extra = RPG_T.get("rpg_extra")
local hp_units = BiterHealthBooster.get('biter_health_boost_units')
local entity = event.entity
if not entity.valid then return end
if entity.type == "unit-spawner" then
@ -455,24 +475,26 @@ local function map_gen_settings()
end
local function get_lowest_safe_floor(player)
local dungeontable = DungeonsTable.get_dungeontable()
local rpg = RPG_T.get("rpg_t")
local level = rpg[player.index].level
local sizes = global.dungeons.surface_size
local safe = global.dungeons.original_surface_index
local sizes = dungeontable.surface_size
local safe = dungeontable.original_surface_index
for key, size in pairs(sizes) do
if size > 215 and level >= (key + 1 - global.dungeons.original_surface_index) * 10 and game.surfaces[key + 1] then
if size > 215 and level >= (key + 1 - dungeontable.original_surface_index) * 10 and game.surfaces[key + 1] then
safe = key + 1
else
break
end
end
if safe >= global.dungeons.original_surface_index + 50 then safe = global.dungeons.original_surface_index + 50 end
if safe >= dungeontable.original_surface_index + 50 then safe = dungeontable.original_surface_index + 50 end
return safe
end
local function descend(player, button, shift)
local dungeontable = DungeonsTable.get_dungeontable()
local rpg = RPG_T.get("rpg_t")
if player.surface.index >= global.dungeons.original_surface_index + 50 then
if player.surface.index >= dungeontable.original_surface_index + 50 then
player.print({"dungeons_tiered.max_depth"})
return
end
@ -480,27 +502,27 @@ local function descend(player, button, shift)
player.print({"dungeons_tiered.only_on_spawn"})
return
end
if rpg[player.index].level < (player.surface.index - global.dungeons.original_surface_index) * 10 + 10 then
player.print({"dungeons_tiered.level_required", (player.surface.index - global.dungeons.original_surface_index) * 10 + 10})
if rpg[player.index].level < (player.surface.index - dungeontable.original_surface_index) * 10 + 10 then
player.print({"dungeons_tiered.level_required", (player.surface.index - dungeontable.original_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
if dungeontable.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 - global.dungeons.original_surface_index + 1, map_gen_settings())
if surface.index % 5 == global.dungeons.original_surface_index then global.dungeons.spawn_size = 60 else global.dungeons.spawn_size = 42 end
surface = game.create_surface("dungeons_floor" .. player.surface.index - dungeontable.original_surface_index + 1, map_gen_settings())
if surface.index % 5 == dungeontable.original_surface_index then dungeontable.spawn_size = 60 else dungeontable.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 / (global.dungeons.original_surface_index + 50))
surface.daytime = 0.25 + 0.30 * (surface.index / (dungeontable.original_surface_index + 50))
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 - global.dungeons.original_surface_index}, {r = 0.8, g = 0.5, b = 0})
dungeontable.surface_size[surface.index] = 200
dungeontable.treasures[surface.index] = 0
game.print({"dungeons_tiered.first_visit", player.name, rpg[player.index].level, surface.index - dungeontable.original_surface_index}, {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
@ -511,7 +533,8 @@ local function descend(player, button, shift)
end
local function ascend(player, button, shift)
if player.surface.index <= global.dungeons.original_surface_index then
local dungeontable = DungeonsTable.get_dungeontable()
if player.surface.index <= dungeontable.original_surface_index then
player.print({"dungeons_tiered.min_depth"})
return
end
@ -520,21 +543,27 @@ local function ascend(player, button, shift)
return
end
local surface = game.surfaces[player.surface.index - 1]
if button == defines.mouse_button_type.right then surface = game.surfaces[math.max(global.dungeons.original_surface_index, player.surface.index - 5)] end
if shift then surface = game.surfaces[global.dungeons.original_surface_index] end
if button == defines.mouse_button_type.right then surface = game.surfaces[math.max(dungeontable.original_surface_index, player.surface.index - 5)] end
if shift then surface = game.surfaces[dungeontable.original_surface_index] 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_built_entity(event)
local dungeontable = DungeonsTable.get_dungeontable()
local entity = event.created_entity
if not entity or not entity.valid then return end
if entity.name == "spidertron" then
if entity.surface.index < global.dungeons.original_surface_index + 20 then
entity.destroy()
if entity.surface.index < dungeontable.original_surface_index + 20 then
local player = game.players[event.player_index]
local try_mine = player.mine_entity(entity, true)
if not try_mine then
if entity.valid then
entity.destroy()
player.insert({name = "spidertron", count = 1})
end
end
Alert.alert_player_warning(player, 8, {"dungeons_tiered.spidertron_not_allowed"})
player.insert({name = "spidertron", count = 1})
end
end
end
@ -556,10 +585,12 @@ local function on_gui_click(event)
end
local function on_surface_created(event)
local dungeontable = DungeonsTable.get_dungeontable()
local forceshp = BiterHealthBooster.get("biter_health_boost_forces")
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 - (global.dungeons.original_surface_index * 100)
dungeontable.enemy_forces[event.surface_index] = force
forceshp[force.index] = 1
dungeontable.depth[event.surface_index] = 100 * event.surface_index - (dungeontable.original_surface_index * 100)
end
local function on_player_changed_surface(event)
@ -576,16 +607,17 @@ end
-- local position = player.position
-- local surface = player.surface
-- if surface.index < 2 then return end
-- local size = global.dungeons.surface_size[surface.index]
-- local size = dungeontable.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 > global.dungeons.original_surface_index then
local inputs = global.dungeons.transport_chests_inputs[surface_index]
local outputs = global.dungeons.transport_chests_outputs[surface_index - 1]
local dungeontable = DungeonsTable.get_dungeontable()
if surface_index > dungeontable.original_surface_index then
local inputs = dungeontable.transport_chests_inputs[surface_index]
local outputs = dungeontable.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)
@ -604,9 +636,10 @@ local function transfer_items(surface_index)
end
local function transfer_signals(surface_index)
if surface_index > global.dungeons.original_surface_index then
local inputs = global.dungeons.transport_poles_inputs[surface_index - 1]
local outputs = global.dungeons.transport_poles_outputs[surface_index]
local dungeontable = DungeonsTable.get_dungeontable()
if surface_index > dungeontable.original_surface_index then
local inputs = dungeontable.transport_poles_inputs[surface_index - 1]
local outputs = dungeontable.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)
@ -629,6 +662,8 @@ end
local function on_init()
local dungeontable = DungeonsTable.get_dungeontable()
local forceshp = BiterHealthBooster.get("biter_health_boost_forces")
local force = game.create_force("dungeon")
force.set_friend("enemy", false)
force.set_friend("player", false)
@ -665,32 +700,18 @@ local function on_init()
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.dungeons.original_surface_index = surface.index
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
dungeontable.tiered = true
dungeontable.depth[surface.index] = 0
dungeontable.depth[nauvis.index] = 0
dungeontable.surface_size[surface.index] = 200
dungeontable.treasures[surface.index] = 0
dungeontable.item_blacklist = true
dungeontable.original_surface_index = surface.index
dungeontable.enemy_forces[nauvis.index] = game.forces.enemy
dungeontable.enemy_forces[surface.index] = game.create_force("enemy" .. surface.index)
forceshp[game.forces.enemy.index] = 1
forceshp[dungeontable.enemy_forces[surface.index].index] = 1
global.rocks_yield_ore_base_amount = 50
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
@ -710,14 +731,12 @@ local function on_init()
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
local dungeontable = DungeonsTable.get_dungeontable()
if #dungeontable.transport_surfaces > 0 then
for _,surface_index in pairs(dungeontable.transport_surfaces) do
transfer_items(surface_index)
transfer_signals(surface_index)
end
end
--[[
@ -741,7 +760,7 @@ end
local Event = require 'utils.event'
Event.on_init(on_init)
Event.add(defines.events.on_tick, on_tick)
Event.on_nth_tick(60, 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)
@ -755,5 +774,3 @@ 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)
Event.add(defines.events.on_player_respawned, on_player_respawned)
require "modules.rocks_yield_ore"

View File

@ -26,6 +26,7 @@ local this = {
biter_health_boost_count = 0,
make_normal_unit_mini_bosses = false,
active_surface = 'nauvis',
active_surfaces = {},
acid_lines_delay = {},
acid_nova = false,
boss_spawns_projectiles = false,
@ -181,6 +182,15 @@ local function clean_table()
end
end
for name, enabled in pairs(this.active_surfaces) do
local surface = game.surfaces[name]
if surface and surface.valid and enabled then
for _, unit in pairs(surface.find_entities_filtered({type = validTypes})) do
units_to_delete[unit.unit_number] = nil
end
end
end
local surface = game.surfaces[this.active_surface]
for _, unit in pairs(surface.find_entities_filtered({type = validTypes})) do
@ -371,6 +381,7 @@ function Public.reset_table()
this.biter_health_boost_count = 0
this.make_normal_unit_mini_bosses = false
this.active_surface = 'nauvis'
this.active_surfaces = {}
this.check_on_entity_died = false
this.acid_lines_delay = {}
this.acid_nova = false
@ -413,14 +424,25 @@ function Public.add_boss_unit(unit, health_multiplier, health_bar_size)
end
--- This sets the active surface that we check and have the script active.
--- This deletes the list of surfaces if we use multiple, so use it only before setting more of them.
---@param string
function Public.set_active_surface(str)
if str and type(str) == 'string' then
this.active_surfaces = {}
this.active_surface = str
end
return this.active_surface
end
--- This sets if this surface is active, when we using multiple surfaces. The default active surface does not need to be added again
---@param string, boolean
function Public.set_surface_activity(name, value)
if name and type(name) == 'string' and type(value) == 'boolean' then
this.active_surfaces[name] = value
end
return this.active_surfaces
end
--- Enables that biter bosses (units with health bars) spawns acid on death.
---@param boolean
function Public.acid_nova(boolean)

View File

@ -2,9 +2,9 @@
local mining_chance_weights = {
{name = "iron-plate", chance = 1000},
{name = "iron-gear-wheel", chance = 750},
{name = "iron-gear-wheel", chance = 750},
{name = "copper-plate", chance = 750},
{name = "copper-cable", chance = 500},
{name = "copper-cable", chance = 500},
{name = "electronic-circuit", chance = 300},
{name = "steel-plate", chance = 200},
{name = "solid-fuel", chance = 150},
@ -30,15 +30,15 @@ local mining_chance_weights = {
{name = "used-up-uranium-fuel-cell", chance = 1},
{name = "uranium-fuel-cell", chance = 1},
{name = "rocket-fuel", chance = 3},
{name = "rocket-control-unit", chance = 1},
{name = "low-density-structure", chance = 1},
{name = "rocket-control-unit", chance = 1},
{name = "low-density-structure", chance = 1},
{name = "heat-pipe", chance = 1},
{name = "engine-unit", chance = 4},
{name = "electric-engine-unit", chance = 2},
{name = "logistic-robot", chance = 1},
{name = "construction-robot", chance = 1},
{name = "land-mine", chance = 3},
{name = "land-mine", chance = 3},
{name = "grenade", chance = 10},
{name = "rocket", chance = 3},
{name = "explosive-rocket", chance = 3},
@ -90,7 +90,7 @@ local scrap_yield_amounts = {
["electric-engine-unit"] = 2,
["logistic-robot"] = 0.3,
["construction-robot"] = 0.3,
["land-mine"] = 1,
["grenade"] = 2,
["rocket"] = 2,
@ -105,45 +105,54 @@ local scrap_yield_amounts = {
["destroyer-capsule"] = 0.3,
["distractor-capsule"] = 0.3
}
local scrap_raffle = {}
local scrap_raffle = {}
for _, t in pairs (mining_chance_weights) do
for x = 1, t.chance, 1 do
table.insert(scrap_raffle, t.name)
end
end
end
local size_of_scrap_raffle = #scrap_raffle
local function on_player_mined_entity(event)
local scraps = {
["crash-site-spaceship-wreck-small-1"] = true,
["crash-site-spaceship-wreck-small-2"] = true,
["crash-site-spaceship-wreck-small-3"] = true,
["crash-site-spaceship-wreck-small-4"] = true,
["crash-site-spaceship-wreck-small-5"] = true,
["crash-site-spaceship-wreck-small-6"] = true,
["mineable-wreckage"] = true
}
local entity = event.entity
if not entity.valid then return end
if entity.name ~= "mineable-wreckage" then return end
if not scraps[entity.name] then return end
event.buffer.clear()
local scrap = scrap_raffle[math.random(1, size_of_scrap_raffle)]
local amount_bonus = (game.forces.enemy.evolution_factor * 2) + (game.forces.player.mining_drill_productivity_bonus * 2)
local r1 = math.ceil(scrap_yield_amounts[scrap] * (0.3 + (amount_bonus * 0.3)))
local r2 = math.ceil(scrap_yield_amounts[scrap] * (1.7 + (amount_bonus * 1.7)))
local r2 = math.ceil(scrap_yield_amounts[scrap] * (1.7 + (amount_bonus * 1.7)))
local amount = math.random(r1, r2)
local player = game.players[event.player_index]
local player = game.players[event.player_index]
local inserted_count = player.insert({name = scrap, count = amount})
if inserted_count ~= amount then
local amount_to_spill = amount - inserted_count
local amount_to_spill = amount - inserted_count
entity.surface.spill_item_stack(entity.position,{name = scrap, count = amount_to_spill}, true)
end
entity.surface.create_entity({
name = "flying-text",
position = entity.position,
text = "+" .. amount .. " [img=item/" .. scrap .. "]",
color = {r=0.98, g=0.66, b=0.22}
})
})
end
local Event = require 'utils.event'
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)