mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-03 13:12:11 +02:00
commit
8a18e6ef8a
43
maps/dungeons/biome_laboratory.lua
Normal file
43
maps/dungeons/biome_laboratory.lua
Normal file
@ -0,0 +1,43 @@
|
||||
local Functions = require "maps.dungeons.functions"
|
||||
|
||||
local table_shuffle_table = table.shuffle_table
|
||||
local table_insert = table.insert
|
||||
local math_random = math.random
|
||||
|
||||
local rainbow_tiles = {
|
||||
"orange-refined-concrete", "purple-refined-concrete",
|
||||
}
|
||||
|
||||
local function laboratory(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.laboratory(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 laboratory
|
@ -185,7 +185,9 @@ end
|
||||
local function player_died(arena, player)
|
||||
wipedown_arena(arena)
|
||||
global.arena.active_player[arena] = nil
|
||||
global.arena.active_boss[arena].destroy()
|
||||
if global.arena.active_boss[arena] and global.arena.active_boss[arena].valid then
|
||||
global.arena.active_boss[arena].destroy()
|
||||
end
|
||||
global.arena.active_boss[arena] = nil
|
||||
global.arena.timer[arena] = -100
|
||||
|
||||
@ -310,13 +312,27 @@ local function on_entity_died(event)
|
||||
end
|
||||
|
||||
local function shoot(surface, biter, player)
|
||||
if player.surface ~= surface then return end
|
||||
surface.create_entity({name = "destroyer-capsule", position = biter.position, target = player.character, source = biter, speed = 1, force = biter.force})
|
||||
end
|
||||
|
||||
local function slow(surface, biter, player)
|
||||
if player.surface ~= surface then return end
|
||||
surface.create_entity({name = "slowdown-capsule", position = biter.position, target = player.character, source = biter, speed = 1, max_range = 100})
|
||||
end
|
||||
|
||||
local function acid_spit(surface, biter, player, tier)
|
||||
if player.surface ~= surface then return end
|
||||
local acids = {
|
||||
"acid-stream-spitter-small",
|
||||
"acid-stream-spitter-medium",
|
||||
"acid-stream-spitter-big",
|
||||
"acid-stream-spitter-behemoth"
|
||||
}
|
||||
surface.create_entity({name = acids[tier], position = biter.position, target = player.character, source = biter})
|
||||
surface.create_entity({name = acids[tier], position = biter.position, target = player.character, source = biter})
|
||||
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
|
||||
@ -332,17 +348,13 @@ local function boss_attacks(i)
|
||||
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})
|
||||
acid_spit(surface, biter, player, 1)
|
||||
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})
|
||||
acid_spit(surface, biter, player, 2)
|
||||
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})
|
||||
acid_spit(surface, biter, player, 3)
|
||||
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})
|
||||
acid_spit(surface, biter, player, 4)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -77,7 +77,7 @@ end
|
||||
|
||||
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
|
||||
if global.dungeons.tiered then amount = amount / 8 end
|
||||
return amount
|
||||
end
|
||||
|
||||
@ -127,46 +127,64 @@ 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 = {{'pistol', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(3,4)}},
|
||||
{price = {{'submachine-gun', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(15,20)}},
|
||||
{price = {{'shotgun', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(12,18)}},
|
||||
{price = {{'combat-shotgun', 1}}, offer = {type = 'give-item', item = "steel-plate", count = math_random(7,10)}},
|
||||
{price = {{'rocket-launcher', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(7,10)}},
|
||||
{price = {{'flamethrower', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(12,18)}},
|
||||
{price = {{'light-armor', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(15,20)}},
|
||||
{price = {{'heavy-armor', 1}}, offer = {type = 'give-item', item = "steel-plate", count = math_random(15,20)}},
|
||||
{price = {{'modular-armor', 1}}, offer = {type = 'give-item', item = "advanced-circuit", count = math_random(15,20)}},
|
||||
{price = {{'night-vision-equipment', 1}}, offer = {type = 'give-item', item = "steel-plate", count = math_random(3,4)}},
|
||||
{price = {{'solar-panel-equipment', 1}}, offer = {type = 'give-item', item = "copper-plate", count = math_random(15,25)}},
|
||||
{price = {{'red-wire', 100}}, offer = {type = 'give-item', item = "copper-cable", count = math_random(75,100)}},
|
||||
{price = {{'green-wire', 100}}, offer = {type = 'give-item', item = "copper-cable", count = math_random(75,100)}},
|
||||
{price = {{'empty-barrel', 10}}, offer = {type = 'give-item', item = "steel-plate", count = math_random(6,8)}},
|
||||
{price = {{'arithmetic-combinator', 10}}, offer = {type = 'give-item', item = "electronic-circuit", count = math_random(15,25)}},
|
||||
{price = {{'decider-combinator', 10}}, offer = {type = 'give-item', item = "electronic-circuit", count = math_random(15,25)}},
|
||||
{price = {{'constant-combinator', 10}}, offer = {type = 'give-item', item = "electronic-circuit", count = math_random(9,12)}},
|
||||
{price = {{'power-switch', 10}}, offer = {type = 'give-item', item = "electronic-circuit", count = math_random(9,12)}},
|
||||
{price = {{'programmable-speaker', 10}}, offer = {type = 'give-item', item = "electronic-circuit", count = math_random(20,30)}},
|
||||
{price = {{'belt-immunity-equipment', 1}}, offer = {type = 'give-item', item = "advanced-circuit", count = math_random(2,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)}},
|
||||
{price = {{'rail-signal', 10}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(30,40)}},
|
||||
{price = {{'rail-chain-signal', 10}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(30,40)}},
|
||||
{price = {{'train-stop', 10}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(75,100)}},
|
||||
{price = {{'locomotive', 1}}, offer = {type = 'give-item', item = "steel-plate", count = math_random(30,40)}},
|
||||
{price = {{'cargo-wagon', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(30,40)}},
|
||||
{price = {{'fluid-wagon', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(30,40)}},
|
||||
{price = {{'car', 1}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(15,20)}},
|
||||
{price = {{'radar', 10}}, offer = {type = 'give-item', item = "iron-plate", count = math_random(15,20)}},
|
||||
{price = {{'cannon-shell', 10}}, offer = {type = 'give-item', item = "steel-plate", count = math_random(7,10)}},
|
||||
{price = {{'uranium-cannon-shell', 10}}, offer = {type = 'give-item', item = "uranium-238", count = math_random(7,10)}},
|
||||
|
||||
}
|
||||
table.shuffle_table(offers)
|
||||
local market = surface.create_entity({name = "market", position = position, force = "neutral"})
|
||||
market.destructible = false
|
||||
market.minable = false
|
||||
local text = "Buys: "
|
||||
for i = 1, math.random(6, 10), 1 do
|
||||
market.add_market_item(offers[i])
|
||||
text = text .. "[item=" .. offers[i].price[1][1] .. "],"
|
||||
end
|
||||
game.forces.player.add_chart_tag(surface, {position = position, text = text})
|
||||
end
|
||||
|
||||
function Public.laboratory(surface, position)
|
||||
local lab = surface.create_entity({name = "lab", position = position, force = "neutral"})
|
||||
lab.destructible = false
|
||||
lab.minable = false
|
||||
local evo = Public.get_dungeon_evolution_factor(surface.index)
|
||||
local amount = math.min(200, math_floor(evo * 100))
|
||||
lab.insert({name = "automation-science-pack", count = math.min(200, math_floor(amount * 5))})
|
||||
if evo >= 0.1 then lab.insert({name = "logistic-science-pack", count = math.min(200, math_floor(amount * 4))}) end
|
||||
if evo >= 0.2 then lab.insert({name = "military-science-pack", count = math.min(200, math_floor(amount * 3))}) end
|
||||
if evo >= 0.4 then lab.insert({name = "chemical-science-pack", count = math.min(200, math_floor(amount * 2))}) end
|
||||
if evo >= 0.6 then lab.insert({name = "production-science-pack", count = amount}) end
|
||||
if evo >= 0.8 then lab.insert({name = "utility-science-pack", count = amount}) end
|
||||
if evo >= 1 then lab.insert({name = "space-science-pack", count = amount}) end
|
||||
end
|
||||
|
||||
function Public.add_room_loot_crates(surface, room)
|
||||
|
@ -29,6 +29,7 @@ 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"
|
||||
Biomes.laboratory = require "maps.dungeons.biome_laboratory"
|
||||
|
||||
local table_shuffle_table = table.shuffle_table
|
||||
local table_insert = table.insert
|
||||
@ -155,7 +156,7 @@ local function unlock_researches(surface_index)
|
||||
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 - 2})
|
||||
game.print({"dungeons_tiered.tech_unlock", "[technology=" .. get_surface_research(surface_index) .. "]", surface_index - global.dungeons.original_surface_index})
|
||||
end
|
||||
end
|
||||
|
||||
@ -180,6 +181,11 @@ local function expand(surface, position)
|
||||
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})
|
||||
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
|
||||
Biomes["laboratory"](surface, room)
|
||||
if room.room_tiles[1] then
|
||||
unlock_researches(surface.index)
|
||||
end
|
||||
elseif math_random(1,256) == 1 then
|
||||
Biomes["market"](surface, room)
|
||||
else
|
||||
@ -191,7 +197,6 @@ local function expand(surface, position)
|
||||
|
||||
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
|
||||
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)
|
||||
|
||||
@ -455,7 +460,7 @@ local function get_lowest_safe_floor(player)
|
||||
local sizes = global.dungeons.surface_size
|
||||
local safe = global.dungeons.original_surface_index
|
||||
for key, size in pairs(sizes) do
|
||||
if size > 215 and level >= key * 10 - 10 and game.surfaces[key + 1] then
|
||||
if size > 215 and level >= (key + 1 - global.dungeons.original_surface_index) * 10 and game.surfaces[key + 1] then
|
||||
safe = key + 1
|
||||
else
|
||||
break
|
||||
@ -684,7 +689,7 @@ local function on_init()
|
||||
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_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
|
||||
|
@ -35,6 +35,7 @@ local function discharge_accumulators(surface, position, force, power_needs)
|
||||
end
|
||||
|
||||
local function charge(player)
|
||||
if not player.character then return end
|
||||
local armor_inventory = player.get_inventory(defines.inventory.character_armor)
|
||||
if not armor_inventory.valid then return end
|
||||
local armor = armor_inventory[1]
|
||||
|
Loading…
x
Reference in New Issue
Block a user