mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-03 13:12:11 +02:00
more mining things
This commit is contained in:
parent
6d791ed221
commit
c3cc9cb031
@ -4,58 +4,72 @@ Public.treasures = {
|
||||
["wooden-chest"] = {
|
||||
tech_bonus = 0.1,
|
||||
amount_multiplier = 1,
|
||||
description = "an old crate, containing some useful goods.",
|
||||
},
|
||||
["iron-chest"] = {
|
||||
tech_bonus = 0.15,
|
||||
amount_multiplier = 1.5,
|
||||
amount_multiplier = 1.5,
|
||||
description = "an iron crate, filled with goodies.",
|
||||
},
|
||||
["steel-chest"] = {
|
||||
tech_bonus = 0.2,
|
||||
amount_multiplier = 2,
|
||||
amount_multiplier = 2,
|
||||
description = "a shiny metal box filled with treasure!",
|
||||
},
|
||||
["crash-site-spaceship-wreck-medium-1"] = {
|
||||
tech_bonus = 0.25,
|
||||
amount_multiplier = 2.5,
|
||||
amount_multiplier = 2.5,
|
||||
description = "a spaceship wreck piece, containing some shiny scrap!",
|
||||
},
|
||||
["crash-site-spaceship-wreck-medium-2"] = {
|
||||
tech_bonus = 0.25,
|
||||
amount_multiplier = 2.5,
|
||||
description = "a space station wreck piece, containing some prescious scrap!",
|
||||
},
|
||||
["crash-site-spaceship-wreck-medium-3"] = {
|
||||
tech_bonus = 0.25,
|
||||
amount_multiplier = 2.5,
|
||||
amount_multiplier = 2.5,
|
||||
description = "a wreck piece, filled with rare scrap!",
|
||||
},
|
||||
["crash-site-spaceship-wreck-big-1"] = {
|
||||
tech_bonus = 0.30,
|
||||
amount_multiplier = 3,
|
||||
amount_multiplier = 3,
|
||||
description = "a big wreck piece, filled with items!",
|
||||
},
|
||||
["crash-site-spaceship-wreck-big-2"] = {
|
||||
tech_bonus = 0.30,
|
||||
amount_multiplier = 3,
|
||||
amount_multiplier = 3,
|
||||
description = "a station wreck piece, containing some useful items!",
|
||||
},
|
||||
["big-ship-wreck-1"] = {
|
||||
tech_bonus = 0.35,
|
||||
amount_multiplier = 3.5,
|
||||
amount_multiplier = 3.5,
|
||||
description = "a crashed space ship! There are some goodies in the cargo!",
|
||||
},
|
||||
["big-ship-wreck-2"] = {
|
||||
tech_bonus = 0.35,
|
||||
amount_multiplier = 3.5,
|
||||
amount_multiplier = 3.5,
|
||||
description = "a crashed space ship! There are some goodies in the cargo!",
|
||||
},
|
||||
["big-ship-wreck-3"] = {
|
||||
tech_bonus = 0.35,
|
||||
amount_multiplier = 3.5,
|
||||
amount_multiplier = 3.5,
|
||||
description = "a crashed starship! The cargo is still intact!",
|
||||
},
|
||||
["crash-site-chest-1"] = {
|
||||
tech_bonus = 0.40,
|
||||
amount_multiplier = 4,
|
||||
amount_multiplier = 4,
|
||||
description = "a drop pod capsule! It is filled with useful loot!",
|
||||
},
|
||||
["crash-site-chest-2"] = {
|
||||
tech_bonus = 0.40,
|
||||
amount_multiplier = 4,
|
||||
amount_multiplier = 4,
|
||||
description = "a cargo pod capsule! It is filled with nice things!",
|
||||
},
|
||||
["crash-site-spaceship"] = {
|
||||
tech_bonus = 0.5,
|
||||
amount_multiplier = 5,
|
||||
amount_multiplier = 5,
|
||||
description = "a big crashed spaceship! There are treasures inside..",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -117,19 +117,29 @@ function Public.rock_spawns_biters(cave_miner, position)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.loot_crate(surface, position, container_name)
|
||||
function Public.loot_crate(surface, position, container_name, player_index)
|
||||
local amount_multiplier = Constants.treasures[container_name].amount_multiplier
|
||||
local base_amount = 16 * amount_multiplier
|
||||
local difficulty_modifier = Public.get_difficulty_modifier(position)
|
||||
local slots = game.entity_prototypes[container_name].item_slot_count
|
||||
local slots = game.entity_prototypes[container_name].get_inventory_size(defines.inventory.chest)
|
||||
local tech_bonus = Constants.treasures[container_name].tech_bonus
|
||||
local description = Constants.treasures[container_name].description
|
||||
|
||||
local blacklist = LootRaffle.get_tech_blacklist(difficulty_modifier + tech_bonus)
|
||||
blacklist["landfill"] = true
|
||||
|
||||
local item_stacks = LootRaffle.roll(difficulty_modifier * amount_multiplier, slots, blacklist)
|
||||
local item_stacks = LootRaffle.roll(base_amount + difficulty_modifier * amount_multiplier * 5000, slots, blacklist)
|
||||
local container = surface.create_entity({name = container_name, position = position, force = "neutral"})
|
||||
for _, item_stack in pairs(item_stacks) do container.insert(item_stack) end
|
||||
container.minable = false
|
||||
|
||||
if not player_index then return end
|
||||
local player = game.players[player_index]
|
||||
if math_random(1, 2) == 1 then
|
||||
game.print(player.name .. " found " .. description, {200, 200, 200})
|
||||
else
|
||||
game.print(player.name .. " uncovered " .. description, {200, 200, 200})
|
||||
end
|
||||
end
|
||||
|
||||
function Public.place_crude_oil(surface, position, multiplier)
|
||||
@ -232,73 +242,91 @@ function Public.darkness(cave_miner)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Public.mining_events = {
|
||||
{function(cave_miner, entity, player_index)
|
||||
end, 20000, "Nothing"},
|
||||
end, 300000, "Nothing"},
|
||||
|
||||
{function(cave_miner, entity, player_index)
|
||||
Public.rock_spawns_biters(cave_miner, entity.position)
|
||||
end, 2048, "Biters"},
|
||||
end, 20000, "Biters"},
|
||||
|
||||
{function(cave_miner, entity, player_index)
|
||||
local position = entity.position
|
||||
local surface = entity.surface
|
||||
Public.loot_crate(surface, position, "wooden-chest")
|
||||
end, 1024, "Treasuer_Tier_1"},
|
||||
Public.loot_crate(surface, position, "wooden-chest", player_index)
|
||||
end, 4096, "Treasure_Tier_1"},
|
||||
|
||||
{function(cave_miner, entity, player_index)
|
||||
local position = entity.position
|
||||
local surface = entity.surface
|
||||
Public.loot_crate(surface, position, "iron-chest")
|
||||
end, 512, "Treasuer_Tier_2"},
|
||||
Public.loot_crate(surface, position, "iron-chest", player_index)
|
||||
end, 2048, "Treasure_Tier_2"},
|
||||
|
||||
{function(cave_miner, entity, player_index)
|
||||
local position = entity.position
|
||||
local surface = entity.surface
|
||||
Public.loot_crate(surface, position, "steel-chest")
|
||||
end, 256, "Treasuer_Tier_3"},
|
||||
Public.loot_crate(surface, position, "steel-chest", player_index)
|
||||
end, 1024, "Treasure_Tier_3"},
|
||||
|
||||
{function(cave_miner, entity, player_index)
|
||||
local position = entity.position
|
||||
local surface = entity.surface
|
||||
Public.loot_crate(surface, position, "crash-site-spaceship-wreck-medium-" .. math_random(1,3))
|
||||
end, 128, "Treasuer_Tier_4"},
|
||||
Public.loot_crate(surface, position, "crash-site-spaceship-wreck-medium-" .. math_random(1,3), player_index)
|
||||
end, 512, "Treasure_Tier_4"},
|
||||
|
||||
{function(cave_miner, entity, player_index)
|
||||
local position = entity.position
|
||||
local surface = entity.surface
|
||||
Public.loot_crate(surface, position, "crash-site-spaceship-wreck-big-" .. math_random(1,2))
|
||||
end, 64, "Treasuer_Tier_5"},
|
||||
Public.loot_crate(surface, position, "crash-site-spaceship-wreck-big-" .. math_random(1,2), player_index)
|
||||
end, 256, "Treasure_Tier_5"},
|
||||
|
||||
{function(cave_miner, entity, player_index)
|
||||
local position = entity.position
|
||||
local surface = entity.surface
|
||||
Public.loot_crate(surface, position, "big-ship-wreck-" .. math_random(1,3))
|
||||
end, 32, "Treasuer_Tier_6"},
|
||||
Public.loot_crate(surface, position, "big-ship-wreck-" .. math_random(1,3), player_index)
|
||||
end, 128, "Treasure_Tier_6"},
|
||||
|
||||
{function(cave_miner, entity, player_index)
|
||||
local position = entity.position
|
||||
local surface = entity.surface
|
||||
Public.loot_crate(surface, position, "crash-site-chest-" .. math_random(1,2))
|
||||
end, 16, "Treasuer_Tier_7"},
|
||||
Public.loot_crate(surface, position, "crash-site-chest-" .. math_random(1,2), player_index)
|
||||
end, 64, "Treasure_Tier_7"},
|
||||
|
||||
{function(cave_miner, entity, player_index)
|
||||
local position = entity.position
|
||||
local surface = entity.surface
|
||||
Public.loot_crate(surface, position, "crash-site-spaceship")
|
||||
end, 8, "Treasuer_Tier_8"},
|
||||
Public.loot_crate(surface, position, "crash-site-spaceship", player_index)
|
||||
local player = game.players[player_index]
|
||||
local position_2 = surface.find_non_colliding_position("character", position, 16, 0.5)
|
||||
if not position_2 then return end
|
||||
player.teleport(position_2, surface)
|
||||
end, 32, "Treasure_Tier_8"},
|
||||
|
||||
{function(cave_miner, entity, player_index)
|
||||
local position = entity.position
|
||||
local surface = entity.surface
|
||||
local unit = Public.spawn_random_biter(surface, position, 2)
|
||||
Pets.biter_pets_tame_unit(game.players[player_index], unit, true)
|
||||
end, 64, "Pet"},
|
||||
end, 256, "Pet"},
|
||||
|
||||
{function(cave_miner, entity, player_index)
|
||||
local position = entity.position
|
||||
local surface = entity.surface
|
||||
local tick = game.tick
|
||||
|
||||
local trees = {}
|
||||
for k, prototype in pairs(game.entity_prototypes) do
|
||||
if prototype.type == "tree" then table.insert(trees, k) end
|
||||
end
|
||||
table.shuffle_table(trees)
|
||||
local tree = game.entity_prototypes[trees[1]].name
|
||||
|
||||
for c = 1, math_random(4, 128), 1 do
|
||||
Esq.add_to_queue(tick + c * 5, surface, {name = tree, position = position, force = "neutral"}, 64)
|
||||
end
|
||||
local player = game.players[player_index]
|
||||
game.print(player.name .. " found a whole forest!")
|
||||
end, 128, "Forest"},
|
||||
}
|
||||
|
||||
Public.on_entity_died = {
|
||||
|
@ -27,6 +27,9 @@ Global.register(
|
||||
)
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
--print mining chances
|
||||
--for k, v in pairs(table.get_random_weighted_chances(Functions.mining_events)) do game.print(Functions.mining_events[k][3] .. " | " .. math.round(v, 4) .. " | 1 in " .. math_floor(1 / v)) end
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
Functions.create_top_gui(player)
|
||||
@ -79,9 +82,6 @@ local function on_player_mined_entity(event)
|
||||
cave_miner.rocks_broken = cave_miner.rocks_broken + 1
|
||||
local f = table.get_random_weighted(Functions.mining_events)
|
||||
f(cave_miner, entity, event.player_index)
|
||||
|
||||
--print chances
|
||||
--for k, v in pairs(table.get_random_weighted_chances(Functions.mining_events)) do game.print(Functions.mining_events[k][3] .. " | " .. math.round(v, 4) .. " | 1 in " .. math_floor(1 / v)) end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -153,7 +153,7 @@ local function get_biome(surface, seed, position)
|
||||
|
||||
local noise = GetNoise("cave_miner_01", position, seed)
|
||||
local abs_noise = math_abs(noise)
|
||||
if abs_noise < 0.09 then return biomes.cave, d, noise end
|
||||
if abs_noise < 0.088 then return biomes.cave, d, noise end
|
||||
|
||||
if abs_noise > 0.25 then
|
||||
local noise = GetNoise("cave_rivers", position, seed)
|
||||
|
Loading…
x
Reference in New Issue
Block a user