1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-26 03:52:22 +02:00
randomized markets
another mining event
pond biome
This commit is contained in:
MewMew 2020-10-28 04:38:20 +01:00
parent 7a66e25d72
commit 673f068b92
5 changed files with 144 additions and 25 deletions

View File

@ -37,7 +37,7 @@ local item_worths = {
["filter-inserter"] = 40,
["stack-inserter"] = 128,
["stack-filter-inserter"] = 160,
["small-electric-pole"] = 4,
["small-electric-pole"] = 2,
["medium-electric-pole"] = 32,
["big-electric-pole"] = 64,
["substation"] = 256,
@ -62,7 +62,7 @@ local item_worths = {
["logistic-chest-buffer"] = 512,
["logistic-chest-requester"] = 512,
["roboport"] = 2048,
["small-lamp"] = 16,
["small-lamp"] = 8,
["red-wire"] = 4,
["green-wire"] = 4,
["arithmetic-combinator"] = 16,
@ -301,6 +301,7 @@ local tech_tier_list = {
"pumpjack",
"oil-refinery",
"chemical-plant",
"solid-fuel",
"storage-tank",
"pump",
"empty-barrel",
@ -511,4 +512,9 @@ function Public.get_tech_blacklist(tier)
return blacklist
end
function Public.get_item_value(item)
local value = item_worths[item]
return value
end
return Public

View File

@ -356,6 +356,15 @@ Public.mining_events = {
surface.create_entity({name = "compilatron", position = position, force = "enemy"})
end, 128, "Enemy Compilatron"},
{function(cave_miner, entity, player_index)
local position = entity.position
local surface = entity.surface
surface.create_entity({name = "car", position = position, force = "player"})
Public.unstuck_player(player_index)
local player = game.players[player_index]
game.print(player.name .. " has finally found their car!!")
end, 32, "Car"},
{function(cave_miner, entity, player_index)
local position = entity.position
local surface = entity.surface

View File

@ -3,25 +3,29 @@ local Public = {}
local Constants = require 'maps.cave_miner_v2.constants'
local Functions = require 'maps.cave_miner_v2.functions'
local LootRaffle = require "functions.loot_raffle"
local math_floor = math.floor
local math_random = math.random
local loot_blacklist = {
["discharge-defense-remote"] = true,
["express-loader"] = true,
["fast-loader"] = true,
["landfill"] = true,
["loader"] = true,
["railgun"] = true,
["railgun-dart"] = true,
["raw-fish"] = true,
["wood"] = true,
}
local function get_item_blacklist(tier)
local blacklist = LootRaffle.get_tech_blacklist(tier * 0.05)
blacklist["discharge-defense-remote"] = true
blacklist["express-loader"] = true
blacklist["fast-loader"] = true
blacklist["landfill"] = true
blacklist["loader"] = true
blacklist["railgun"] = true
blacklist["railgun-dart"] = true
blacklist["raw-fish"] = true
blacklist["wood"] = true
return blacklist
end
local special_slots = {
[1] = function(market, cave_miner)
local pickaxe_tiers = Constants.pickaxe_tiers
local tier = cave_miner.pickaxe_tier + 1
if pickaxe_tiers[tier] then
local item_stacks = LootRaffle.roll(math.floor(tier ^ 3.65) + 8, 100, loot_blacklist)
local item_stacks = LootRaffle.roll(math.floor(tier ^ 3.65) + 8, 100, get_item_blacklist(tier))
local price = {}
for _, item_stack in pairs(item_stacks) do table.insert(price, {name = item_stack.name, amount = item_stack.count}) end
market.add_market_item({price = price, offer = {type = 'nothing', effect_description = 'Upgrade pickaxe to tier ' .. tier .. ': ' .. pickaxe_tiers[tier]}})
@ -31,7 +35,7 @@ local special_slots = {
end,
[2] = function(market, cave_miner)
local tier = (market.force.character_inventory_slots_bonus + 2) * 0.5
local item_stacks = LootRaffle.roll(math.floor(tier ^ 3.50) + 8, 100, loot_blacklist)
local item_stacks = LootRaffle.roll(math.floor(tier ^ 3.50) + 8, 100, get_item_blacklist(tier))
local price = {}
for _, item_stack in pairs(item_stacks) do table.insert(price, {name = item_stack.name, amount = item_stack.count}) end
market.add_market_item({price = price, offer = {type = 'nothing', effect_description = 'Upgrade backpack to tier ' .. tier}})
@ -114,4 +118,69 @@ function Public.offer_bought(event, cave_miner)
end
end
function Public.spawn_random_cave_market(surface, position)
if surface.count_entities_filtered({name = "market", area = {{position.x - 32, position.y - 32}, {position.x + 32, position.y + 32}}}) > 0 then return end
local difficulty_modifier = Functions.get_difficulty_modifier(position)
local market = surface.create_entity({name = "market", position = position, force = "player"})
local worth = math_floor(difficulty_modifier * 10000) + 256
local blacklist = LootRaffle.get_tech_blacklist(difficulty_modifier + 0.20)
blacklist["discharge-defense-remote"] = true
blacklist["express-loader"] = true
blacklist["fast-loader"] = true
blacklist["landfill"] = true
blacklist["loader"] = true
blacklist["copper-cable"] = true
blacklist["iron-stick"] = true
blacklist["railgun"] = true
blacklist["railgun-dart"] = true
blacklist["raw-fish"] = true
blacklist["wood"] = true
local items = {}
for _ = 1, 2, 1 do
local item_sells = LootRaffle.roll(worth, 3, blacklist)
for _, item_stack in pairs(item_sells) do
items[item_stack.name] = LootRaffle.get_item_value(item_stack.name)
end
end
for name, value in pairs(items) do
local value = value * math_random(15, 30) * 0.01
local count = 1
if value < 1 then
count = math_floor(1 / value)
value = 1
end
value = math_floor(value)
market.add_market_item({price = {{"raw-fish", value}}, offer = {type = 'give-item', item = name, count = count}})
end
local items = {}
for _ = 1, 2, 1 do
local item_buys = LootRaffle.roll(worth, 3, blacklist)
for _, item_stack in pairs(item_buys) do
items[item_stack.name] = LootRaffle.get_item_value(item_stack.name)
end
end
for name, value in pairs(items) do
local value = value * math_random(8, 14) * 0.01
local count = 1
if value < 1 then
count = math_floor(1 / value)
value = 1
end
value = math_floor(value)
market.add_market_item({price = {{name, count}}, offer = {type = 'give-item', item = "raw-fish", count = value}})
end
rendering.draw_light({
sprite = "utility/light_medium", scale = 3, intensity = 0.8, minimum_darkness = 0,
oriented = true, color = {255,255,255}, target = market,
surface = surface, visible = true, only_in_alt_mode = false,
})
market.destructible = false
market.minable = false
end
return Public

View File

@ -2,6 +2,7 @@ local Public = {}
local GetNoise = require "utils.get_noise"
local Functions = require 'maps.cave_miner_v2.functions'
local Market = require 'maps.cave_miner_v2.market'
local math_abs = math.abs
local math_random = math.random
@ -57,27 +58,59 @@ end
local biomes = {}
function biomes.oasis(surface, seed, position, square_distance, noise)
if noise < 0.79 then
if noise > 0.83 then
surface.set_tiles({{name = "deepwater", position = position}}, true)
if math_random(1, 16) == 1 then surface.create_entity({name = "fish", position = position}) end
return
end
local noise_decoratives = GetNoise("decoratives", position, seed + 50000)
surface.set_tiles({{name = "grass-1", position = position}}, true)
if math_random(1, 48) == 1 and math_abs(noise_decoratives) > 0.07 then surface.create_entity({name = "tree-04", position = position}) end
if math_random(1, 48) == 1 then Functions.place_crude_oil(surface, position, 1) end
return
if math_random(1, 16) == 1 and math_abs(noise_decoratives) > 0.17 then surface.create_entity({name = "tree-04", position = position}) end
if math_random(1, 128) == 1 then Functions.place_crude_oil(surface, position, 1) end
if noise < 0.73 then
local a = (-49 + math_random(0, 98)) * 0.01
local b = (-49 + math_random(0, 98)) * 0.01
surface.create_entity({name = rock_raffle[math_random(1, size_of_rock_raffle)], position = {position.x + a, position.y + b}})
end
end
function biomes.void(surface, seed, position)
surface.set_tiles({{name = "out-of-map", position = position}}, false, false, false, false)
end
function biomes.pond_cave(surface, seed, position, square_distance, noise)
local noise_2 = GetNoise("cm_ponds", position, seed)
if math_abs(noise_2) > 0.60 then
surface.set_tiles({{name = "water", position = position}}, true, false, false, false)
if math_random(1, 16) == 1 then surface.create_entity({name = "fish", position = position}) end
return
end
if math_abs(noise_2) > 0.25 and math_random(1, 2) > 1 then
local a = (-49 + math_random(0, 98)) * 0.01
local b = (-49 + math_random(0, 98)) * 0.01
surface.create_entity({name = rock_raffle[math_random(1, size_of_rock_raffle)], position = {position.x + a, position.y + b}})
return
end
if noise > -0.53 then
local a = (-49 + math_random(0, 98)) * 0.01
local b = (-49 + math_random(0, 98)) * 0.01
surface.create_entity({name = rock_raffle[math_random(1, size_of_rock_raffle)], position = {position.x + a, position.y + b}})
else
if math_random(1, 128) == 1 then
Market.spawn_random_cave_market(surface, position)
end
end
end
function biomes.spawn(surface, seed, position, square_distance)
if square_distance < 32 then return end
local noise = GetNoise("decoratives", position, seed)
if math_abs(noise) > 0.60 and square_distance > 1250 then
if math_abs(noise) > 0.60 and square_distance < 1250 then
surface.set_tiles({{name = "water", position = position}}, true, false, false, false)
if math_random(1, 16) == 1 then surface.create_entity({name = "fish", position = position}) end
return
@ -120,7 +153,7 @@ function biomes.cave(surface, seed, position, square_distance, noise)
if math_abs(noise_cave_rivers1) < 0.025 then
local noise_cave_rivers2 = GetNoise("cave_rivers_3", position, seed + 200000)
if noise_cave_rivers2 > 0 then
surface.set_tiles({{name = "water", position = position}}, true, false, false, false)
surface.set_tiles({{name = "water-shallow", position = position}}, true, false, false, false)
if math_random(1, 16) == 1 then surface.create_entity({name = "fish", position = position}) end
return
end
@ -138,13 +171,13 @@ function biomes.cave(surface, seed, position, square_distance, noise)
end
if math_random(1, 2048) == 1 then Functions.loot_crate(surface, position, "wooden-chest") return end
if math_random(1, 4096) == 1 then Functions.loot_crate(surface, position, "iron-chest") return end
if math_random(1, 8192) == 1 then Functions.loot_crate(surface, position, "steel-chest") return end
return
end
if square_distance < 4096 then return end
if math_random(1, 48) == 1 then surface.create_entity({name = "biter-spawner", position = position, force = "enemy"}) end
if math_random(1, 48) == 1 then Functions.place_worm(surface, position, 1) end
if math_random(1, 4096) == 1 then Market.spawn_random_cave_market(surface, position) return end
if math_random(1, 64) == 1 then surface.create_entity({name = "biter-spawner", position = position, force = "enemy"}) return end
if math_random(1, 64) == 1 then Functions.place_worm(surface, position, 1) return end
end
local function get_biome(surface, seed, position)
@ -157,7 +190,8 @@ local function get_biome(surface, seed, position)
if abs_noise > 0.25 then
local noise = GetNoise("cave_rivers", position, seed)
if noise > 0.72 then return biomes.oasis, d, noise end
if noise > 0.72 then return biomes.oasis, d, noise end
if noise < -0.5 then return biomes.pond_cave, d, noise end
end
local noise = GetNoise("cm_ocean", position, seed + 100000)

View File

@ -110,6 +110,7 @@ local noises = {
{modifier = 0.02, weight = 0.15},
{modifier = 0.25, weight = 0.025}
},
['cm_ponds'] = {{modifier = 0.025, weight = 1}, {modifier = 0.05, weight = 0.25}, {modifier = 0.1, weight = 0.05}},
['cm_ocean'] = {
{modifier = 0.002, weight = 1},
{modifier = 0.004, weight = 1},