1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-26 22:56:43 +02:00
This commit is contained in:
MewMew 2020-10-10 15:30:30 +02:00
parent b53e2a147b
commit d51348fe1a
6 changed files with 275 additions and 86 deletions

View File

@ -18,9 +18,7 @@ require 'commands'
require 'antigrief'
require 'modules.corpse_markers'
require 'modules.floaty_chat'
require 'modules.autohotbar'
require 'modules.show_inventory'
require 'modules.ban_drop'
require 'utils.debug.command'
require 'comfy_panel.main'
@ -74,6 +72,7 @@ require 'modules.autostash'
--require 'modules.nuclear_landmines'
--require 'modules.crawl_into_pipes'
--require 'modules.no_acid_puddles'
--require 'modules.simple_tags'
---------------------------------------------------------------
@ -82,7 +81,7 @@ require 'modules.autostash'
--Remove the "--" in front of the line to enable.
--All lines with the "require" keyword are different maps.
--[[North VS South Survival PVP, where you feed the enemies biters with science flasks]]--
--[[North VS South Survival PVP, feed the opposing team's biters with science flasks. Disable Autostash, Group and Poll modules.]]--
--require 'maps.biter_battles_v2.main'
--require 'maps.biter_battles.biter_battles'
@ -148,15 +147,12 @@ require 'modules.autostash'
--[[A green maze]]--
--require 'maps.hedge_maze'
--[[Dangerous forest that with unique map revealing]]--
--[[Dangerous forest with unique map revealing]]--
--require 'maps.spooky_forest'
--[[Defeat the biters and unlock new areas]]--
--require 'maps.spiral_troopers'
--[[A green maze]]--
--require 'maps.hedge_maze'
--[[Railworld style terrains]]--
--require 'maps.mixed_railworld'
--require 'maps.scrap_railworld'
@ -204,6 +200,8 @@ require 'modules.autostash'
--require 'maps.nightfall'
--require 'maps.pitch_black.main'
--require 'maps.cube'
--require 'maps.mountain_race.main'
--require 'maps.cave_miner_v2.main'
--require 'maps.native_war.main'
---------------------------------------------------------------

View File

@ -7,4 +7,100 @@ Public.starting_items = {
["raw-fish"] = 8,
}
Public.spawn_market_items = {
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'rail', count = 4}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'rail-signal', count = 2}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'rail-chain-signal', count = 2}},
{price = {{"raw-fish", 10}}, offer = {type = 'give-item', item = 'train-stop'}},
{price = {{"raw-fish", 94}}, offer = {type = 'give-item', item = 'locomotive'}},
{price = {{"raw-fish", 35}}, offer = {type = 'give-item', item = 'cargo-wagon'}},
{price = {{"raw-fish", 1}}, offer = {type = 'give-item', item = 'red-wire', count = 1}},
{price = {{"raw-fish", 1}}, offer = {type = 'give-item', item = 'green-wire', count = 1}},
{price = {{"raw-fish", 4}}, offer = {type = 'give-item', item = 'decider-combinator'}},
{price = {{"raw-fish", 4}}, offer = {type = 'give-item', item = 'arithmetic-combinator'}},
{price = {{"raw-fish", 2}}, offer = {type = 'give-item', item = 'constant-combinator'}},
{price = {{"raw-fish", 4}}, offer = {type = 'give-item', item = 'programmable-speaker'}},
{price = {{"raw-fish", 2}}, offer = {type = 'give-item', item = 'small-lamp'}},
{price = {{"raw-fish", 2}}, offer = {type = 'give-item', item = 'firearm-magazine'}},
{price = {{"raw-fish", 4}}, offer = {type = 'give-item', item = 'piercing-rounds-magazine'}},
{price = {{"raw-fish", 3}}, offer = {type = 'give-item', item = 'grenade'}},
{price = {{"raw-fish", 2}}, offer = {type = 'give-item', item = 'land-mine'}},
{price = {{"raw-fish", 1}}, offer = {type = 'give-item', item = 'explosives', count = 2}},
{price = {{"raw-fish", 40}}, offer = {type = 'give-item', item = 'cliff-explosives'}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'wood', count = 25}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'iron-ore', count = 25}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'copper-ore', count = 25}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'stone', count = 25}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'coal', count = 25}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'uranium-ore', count = 20}},
{price = {{'wood', 25}}, offer = {type = 'give-item', item = "raw-fish", count = 2}},
{price = {{'iron-ore', 25}}, offer = {type = 'give-item', item = "raw-fish", count = 2}},
{price = {{'copper-ore', 25}}, offer = {type = 'give-item', item = "raw-fish", count = 2}},
{price = {{'stone', 25}}, offer = {type = 'give-item', item = "raw-fish", count = 2}},
{price = {{'coal', 25}}, offer = {type = 'give-item', item = "raw-fish", count = 2}},
{price = {{'uranium-ore', 20}}, offer = {type = 'give-item', item = "raw-fish", count = 2}}
}
Public.pickaxe_tiers = {
"Wood",
"Plastic",
"Bone",
"Alabaster",
"Lead",
"Zinc",
"Tin",
"Salt",
"Bauxite",
"Borax",
"Bismuth",
"Amber",
"Galena",
"Calcite",
"Aluminium",
"Silver",
"Gold",
"Copper",
"Marble",
"Brass",
"Flourite",
"Platinum",
"Nickel",
"Iron",
"Manganese",
"Apatite",
"Uraninite",
"Turquoise",
"Hematite",
"Glass",
"Magnetite",
"Concrete",
"Pyrite",
"Steel",
"Zircon",
"Titanium",
"Silicon",
"Quartz",
"Garnet",
"Flint",
"Tourmaline",
"Beryl",
"Topaz",
"Chrysoberyl",
"Chromium",
"Tungsten",
"Corundum",
"Tungsten",
"Diamond",
"Penumbrite",
"Meteorite",
"Crimtane",
"Obsidian",
"Demonite",
"Mythril",
"Adamantite",
"Chlorophyte",
"Densinium",
"Luminite",
}
return Public

View File

@ -1,7 +1,12 @@
local Constants = require 'maps.cave_miner_v2.constants'
local Public = {}
local Constants = require 'maps.cave_miner_v2.constants'
local BiterRaffle = require "functions.biter_raffle"
local LootRaffle = require "functions.loot_raffle"
local math_sqrt = math.sqrt
local math_random = math.random
function Public.spawn_player(player)
if not player.character then
player.create_character()
@ -19,8 +24,75 @@ function Public.spawn_player(player)
end
function Public.set_mining_speed(cave_miner, force)
force.manual_mining_speed_modifier = cave_miner.pickaxe_tier * 0.25
force.manual_mining_speed_modifier = -0.50 + cave_miner.pickaxe_tier * 0.25
return force.manual_mining_speed_modifier
end
function Public.place_worm(surface, position, multiplier)
local d = math_sqrt(position.x ^ 2 + position.y ^ 2)
surface.create_entity({name = BiterRaffle.roll("worm", d * 0.0001 * multiplier), position = position, force = "enemy"})
return
end
function Public.spawn_random_biter(surface, position, multiplier)
local d = math_sqrt(position.x ^ 2 + position.y ^ 2)
local name = BiterRaffle.roll("mixed", d * 0.0001 * multiplier)
local non_colliding_position = surface.find_non_colliding_position(name, position, 16, 1)
local unit
if non_colliding_position then
unit = surface.create_entity({name = name, position = non_colliding_position, force = "enemy"})
else
unit = surface.create_entity({name = name, position = position, force = "enemy"})
end
unit.ai_settings.allow_try_return_to_spawner = true
unit.ai_settings.allow_destroy_when_commands_fail = false
end
function Public.loot_crate(surface, position, multiplier, slots, container_name)
local d = math_sqrt(position.x ^ 2 + position.y ^ 2)
local item_stacks = LootRaffle.roll(d * multiplier, slots, loot_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
end
function Public.place_crude_oil(surface, position, multiplier)
if not surface.can_place_entity({name = "crude-oil", position = position, amount = 1}) then return end
local d = math_sqrt(position.x ^ 2 + position.y ^ 2)
local amount = math_random(100000, 200000) + d * 100 * multiplier
surface.create_entity({name = "crude-oil", position = position, amount = amount})
end
function Public.create_top_gui(player)
local frame = player.gui.top.cave_miner
if frame then return end
frame = player.gui.top.add({type = "frame", name = "cave_miner", direction = "horizontal"})
frame.style.maximal_height = 38
local label = frame.add({type = "label", caption = "Loading..."})
label.style.font = "heading-2"
label.style.font_color = {225, 225, 225}
label.style.margin = 0
label.style.padding = 0
local label = frame.add({type = "label", caption = "Loading..."})
label.style.font = "heading-2"
label.style.font_color = {225, 225, 225}
label.style.margin = 0
label.style.padding = 0
end
function Public.update_top_gui(cave_miner)
local pickaxe_tiers = Constants.pickaxe_tiers
for _, player in pairs(game.connected_players) do
local element = player.gui.top.cave_miner
if element and element.valid then
element.children[1].caption = "Tier: " .. pickaxe_tiers[cave_miner.pickaxe_tier] .. " | "
element.children[1].tooltip = "Mining speed " .. (1 + game.forces.player.manual_mining_speed_modifier) * 100 .. "%"
element.children[2].caption = "Rocks broken: " .. cave_miner.rocks_broken
end
end
end
return Public

View File

@ -7,6 +7,11 @@ local Market = require 'maps.cave_miner_v2.market'
local Server = require 'utils.server'
local Terrain = require 'maps.cave_miner_v2.terrain'
require 'modules.no_deconstruction_of_neutral_entities'
require "modules.rocks_broken_paint_tiles"
require "modules.rocks_heal_over_time"
require "modules.rocks_yield_ore_veins"
local math_floor = math.floor
local cave_miner = {}
@ -19,6 +24,10 @@ Global.register(
local function on_player_joined_game(event)
local player = game.players[event.player_index]
Functions.create_top_gui(player)
Functions.update_top_gui(cave_miner)
local tick = game.ticks_played
if tick == 0 then
if player.character and player.character.valid then
@ -55,6 +64,42 @@ local function on_market_item_purchased(event)
Market.offer_bought(event, cave_miner)
end
local function on_player_mined_entity(event)
local entity = event.entity
if not entity then return end
if not entity.valid then return end
local surface = entity.surface
local position = entity.position
if entity.type == "simple-entity" then
cave_miner.rocks_broken = cave_miner.rocks_broken + 1
if math.random(1, 16) == 1 then
Functions.spawn_random_biter(surface, position, 1)
end
end
end
local function on_entity_died(event)
local entity = event.entity
if not entity then return end
if not entity.valid then return end
local surface = entity.surface
local position = entity.position
if entity.type == "simple-entity" then
cave_miner.rocks_broken = cave_miner.rocks_broken + 1
if math.random(1, 2) == 1 then
Functions.spawn_random_biter(surface, position, 1)
end
end
end
local function on_entity_spawned(event)
local spawner = event.spawner
local unit = event.entity
local surface = spawner.surface
Functions.spawn_random_biter(surface, unit.position, 1)
unit.destroy()
end
local function init(cave_miner)
local tick = game.ticks_played
if tick % 60 ~= 0 then return end
@ -67,12 +112,15 @@ local function init(cave_miner)
surface.freeze_daytime = true
surface.solar_power_multiplier = 999
cave_miner.pickaxe_tier = 0
cave_miner.rocks_broken = 0
cave_miner.pickaxe_tier = 1
local force = game.forces.player
Functions.set_mining_speed(cave_miner, force)
Functions.set_mining_speed(cave_miner, force)
force.technologies["steel-axe"].enabled = false
force.technologies["landfill"].enabled = false
force.technologies["spidertron"].enabled = false
force.technologies["artillery"].enabled = false
cave_miner.gamestate = "spawn_players"
end
@ -91,6 +139,7 @@ end
local function game_in_progress(cave_miner)
local tick = game.ticks_played
if tick % 60 ~= 0 then return end
Functions.update_top_gui(cave_miner)
end
local gamestates = {
@ -107,6 +156,8 @@ local function on_init()
cave_miner.reset_counter = 0
cave_miner.gamestate = "init"
cave_miner.mining_speed_bonus = 100
cave_miner.pickaxe_tier = 1
cave_miner.rocks_broken = 0
global.rocks_yield_ore_maximum_amount = 256
global.rocks_yield_ore_base_amount = 32
@ -119,6 +170,10 @@ local function on_init()
Explosives.set_destructible_tile("deepwater", 1000)
Explosives.set_destructible_tile("water-shallow", 1000)
Explosives.set_destructible_tile("water-mud", 1000)
game.map_settings.enemy_evolution.destroy_factor = 0
game.map_settings.enemy_evolution.pollution_factor = 0
game.map_settings.enemy_evolution.time_factor = 0
end
Event.on_init(on_init)
@ -127,5 +182,8 @@ Event.add(defines.events.on_chunk_generated, on_chunk_generated)
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
Event.add(defines.events.on_player_changed_position, on_player_changed_position)
Event.add(defines.events.on_market_item_purchased, on_market_item_purchased)
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
Event.add(defines.events.on_entity_spawned, on_entity_spawned)
Event.add(defines.events.on_entity_died, on_entity_died)
require "modules.rocks_yield_ore"

View File

@ -1,68 +1,11 @@
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 pickaxe_tiers = {
"wood",
"plastic",
"bone",
"alabaster",
"lead",
"zinc",
"tin",
"salt",
"bauxite",
"borax",
"bismuth",
"amber",
"galena",
"calcite",
"aluminium",
"silver",
"gold",
"copper",
"marble",
"brass",
"flourite",
"platinum",
"nickel",
"iron",
"manganese",
"apatite",
"uraninite",
"turquoise",
"hematite",
"glass",
"magnetite",
"concrete",
"pyrite",
"steel",
"zircon",
"titanium",
"silicon",
"quartz",
"garnet",
"flint",
"tourmaline",
"beryl",
"topaz",
"chrysoberyl",
"chromium",
"tungsten",
"corundum",
"tungsten",
"diamond",
"penumbrite",
"meteorite",
"crimtane",
"obsidian",
"demonite",
"mythril",
"adamantite",
"chlorophyte",
"densinium",
"luminite",
local loot_blacklist = {
["landfill"] = true,
}
function Public.refresh_offers(market, cave_miner)
@ -72,15 +15,20 @@ function Public.refresh_offers(market, cave_miner)
break
end
end
local pickaxe_tiers = Constants.pickaxe_tiers
local tier = cave_miner.pickaxe_tier + 1
if not pickaxe_tiers[tier] then return end
local item_stacks = LootRaffle.roll(tier ^ 4 + 8, 8)
local price = {}
for _, item_stack in pairs(item_stacks) do
table.insert(price, {name = item_stack.name, amount = item_stack.count})
if pickaxe_tiers[tier] then
local item_stacks = LootRaffle.roll(tier ^ 4 + 8, 80, loot_blacklist)
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 tier to: ' .. pickaxe_tiers[tier]}})
market.add_market_item({price = {{name = "raw-fish", amount = tier * 2}}, offer = {type = 'nothing', effect_description = 'Reroll offer'}})
end
for _, item in pairs(Constants.spawn_market_items) do
market.add_market_item(item)
end
market.add_market_item({price = price, offer = {type = 'nothing', effect_description = 'Upgrade pickaxe tier to ' .. pickaxe_tiers[tier]}})
market.add_market_item({price = {{name = "raw-fish", amount = tier * 2}}, offer = {type = 'nothing', effect_description = 'reroll offers'}})
end
function Public.spawn(cave_miner)
@ -101,8 +49,9 @@ function Public.offer_bought(event, cave_miner)
if offer_index == 1 then
cave_miner.pickaxe_tier = cave_miner.pickaxe_tier + 1
local speed = Functions.set_mining_speed(cave_miner, player.force)
game.print("Pickaxe material has been upgraded to " .. pickaxe_tiers[cave_miner.pickaxe_tier] .. "!")
game.print("Pickaxe has been upgraded to: " .. Constants.pickaxe_tiers[cave_miner.pickaxe_tier] .. "!")
Public.refresh_offers(market, cave_miner)
Functions.update_top_gui(cave_miner)
return
end
if offer_index == 2 then

View File

@ -1,9 +1,15 @@
local Public = {}
local GetNoise = require "utils.get_noise"
local Functions = require 'maps.cave_miner_v2.functions'
local math_abs = math.abs
local math_random = math.random
local loot_blacklist = {
["landfill"] = true,
}
function Public.roll_source_surface()
local map_gen_settings = {
["water"] = 0,
@ -74,7 +80,7 @@ end
local function get_biome(surface, seed, position)
local d = position.x ^ 2 + position.y ^ 2
if d < 128 then return "spawn" end
if d < 32 then return "spawn" end
if d < 1024 then return "cave" end
local noise = GetNoise("smol_areas", position, seed)
@ -90,17 +96,23 @@ end
local biomes = {}
function biomes.worms(surface, seed, position)
if math_random(1, 16) == 1 then surface.create_entity({name = "small-worm-turret", position = position, force = "enemy"}) end
if math_random(1, 16) == 1 then Functions.place_worm(surface, position, 1) end
end
function biomes.nests(surface, seed, position)
if math_random(1, 32) == 1 then surface.create_entity({name = "biter-spawner", position = position, force = "enemy"}) end
end
function biomes.green(surface, seed, position, noise)
function biomes.green(surface, seed, position, noise)
if noise < 0.8 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, 32) == 1 and math_abs(noise_decoratives) > 0.07 then surface.create_entity({name = "tree-04", position = position}) end
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, 32) == 1 then Functions.place_crude_oil(surface, position, 1) end
return
end
@ -117,7 +129,7 @@ function biomes.cave(surface, seed, position)
local noise_cave_rivers2 = GetNoise("cave_rivers_3", position, seed + 100000)
if math_abs(noise_cave_rivers2) < 0.05 then surface.set_tiles({{name = "out-of-map", position = position}}, true) return end
if math_abs(noise_cave_rivers1) < 0.035 then
if math_abs(noise_cave_rivers1) < 0.025 then
surface.set_tiles({{name = "water", position = position}}, true)
if math_random(1, 16) == 1 then surface.create_entity({name = "fish", position = position}) end
return
@ -130,6 +142,10 @@ function biomes.cave(surface, seed, position)
local noise_rock_2 = GetNoise("decoratives", position, seed + 50000)
if math_random(1, 3) > 1 and math_abs(noise_rock_2) > 0.15 then surface.create_entity({name = "rock-big", position = position}) end
end
if math_random(1, 512) == 1 then Functions.loot_crate(surface, position, 1, 8, "wooden-chest") end
if math_random(1, 2048) == 2 then Functions.loot_crate(surface, position, 2, 8, "iron-chest") end
if math_random(1, 4096) == 4 then Functions.loot_crate(surface, position, 3, 8, "steel-chest") end
end
function Public.generate_cave(event)