1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-26 22:56:43 +02:00

new things

This commit is contained in:
MewMew 2019-08-06 03:04:35 +02:00
parent 602d9bfe9c
commit 8ad24de73b
9 changed files with 311 additions and 7 deletions

View File

@ -6,7 +6,7 @@ _DUMP_ENV = false
server_commands = require 'utils.server'
require "utils.server_commands"
require "utils.utils"
-- require "utils.corpse_util" --disable for hunger games
require "utils.corpse_util" --disable for hunger games
require "utils.color_data"
require "utils.session_data"
require "chatbot"
@ -22,7 +22,7 @@ require "modules.floaty_chat"
---- enable modules here ----
--require "tools.cheat_mode"
require "modules.the_floor_is_lava"
--require "modules.the_floor_is_lava"
--require "modules.autodecon_when_depleted"
--require "modules.biter_noms_you"
--require "modules.biters_avoid_damage"
@ -61,6 +61,7 @@ require "modules.the_floor_is_lava"
--require "maps.wave_of_death.WoD"
--require "maps.stone_maze.main"
--require "maps.cave_miner"
require "maps.rocky_waste"
--require "maps.labyrinth"
--require "maps.junkyard"
--require "maps.spooky_forest"

View File

@ -9,8 +9,6 @@ require "modules.biters_double_damage"
require "modules.spawners_contain_biters"
require "modules.splice_double"
local ore_spawn_raffle = {"iron-ore","iron-ore","iron-ore","iron-ore","copper-ore","copper-ore","copper-ore","coal","coal","coal","stone","uranium-ore","crude-oil"}
local function get_noise(name, pos)
local seed = game.surfaces[1].map_gen_settings.seed
local noise_seed_add = 25000

180
maps/rocky_waste.lua Normal file
View File

@ -0,0 +1,180 @@
local event = require 'utils.event'
local simplex_noise = require 'utils.simplex_noise'.d2
require "on_tick_schedule"
require "modules.satellite_score"
require "modules.biter_noms_you"
require "modules.dangerous_goods"
require "modules.biters_avoid_damage"
require "modules.dynamic_landfill"
require "modules.biters_double_damage"
require "modules.splice_double"
require "modules.spawners_contain_acid"
require "modules.spawners_contain_biters"
require "modules.rocks_broken_paint_tiles"
require "modules.rocks_heal_over_time"
require "modules.rocks_yield_ore_veins"
require "modules.rocks_yield_ore"
global.rock_yield_amount_modifier = 0.5
require "modules.manual_mining_booster"
require "modules.no_deconstruction_of_neutral_entities"
require "modules.no_robots"
require "modules.no_blueprint_library"
local function init_surface()
if game.surfaces["rocky_waste"] then return game.surfaces["rocky_waste"] end
local map_gen_settings = {}
map_gen_settings.water = "0.12"
map_gen_settings.starting_area = "0.5"
map_gen_settings.cliff_settings = {cliff_elevation_interval = 7, cliff_elevation_0 = 7}
map_gen_settings.autoplace_controls = {
["coal"] = {frequency = "0", size = "7", richness = "1"},
["stone"] = {frequency = "0", size = "2.0", richness = "0.5"},
["iron-ore"] = {frequency = "0", size = "2.0", richness = "0.5"},
["copper-ore"] = {frequency = "0", size = "2.0", richness = "0.5"},
["uranium-ore"] = {frequency = "0", size = "1", richness = "0.5"},
["crude-oil"] = {frequency = "5", size = "1", richness = "1"},
["trees"] = {frequency = "3", size = "0.85", richness = "0.1"},
["enemy-base"] = {frequency = "5", size = "3", richness = "1"}
}
game.difficulty_settings.technology_price_multiplier = 2
local surface = game.create_surface("rocky_waste", map_gen_settings)
surface.request_to_generate_chunks({x = 0, y = 0}, 3)
surface.force_generate_chunk_requests()
surface.daytime = 0.7
surface.ticks_per_day = surface.ticks_per_day * 2
surface.min_brightness = 0.1
game.forces["player"].set_spawn_position({0,0},game.surfaces["rocky_waste"])
return surface
end
local wastes = {"rock-big", "rock-big", "rock-big", "rock-big","rock-big","rock-big","rock-big","mineable-wreckage", "mineable-wreckage", "mineable-wreckage", "rock-huge"}
local function get_noise(name, pos)
local seed = game.surfaces[1].map_gen_settings.seed
local noise_seed_add = 25000
if name == 1 then
local noise = {}
noise[1] = simplex_noise(pos.x * 0.005, pos.y * 0.005, seed)
seed = seed + noise_seed_add
noise[2] = simplex_noise(pos.x * 0.01, pos.y * 0.01, seed)
seed = seed + noise_seed_add
noise[3] = simplex_noise(pos.x * 0.05, pos.y * 0.05, seed)
seed = seed + noise_seed_add
noise[4] = simplex_noise(pos.x * 0.1, pos.y * 0.1, seed)
local noise = noise[1] + noise[2] * 0.35 + noise[3] * 0.23 + noise[4] * 0.11
return noise
end
seed = seed + noise_seed_add * 5
if name == 2 then
local noise = {}
noise[1] = simplex_noise(pos.x * 0.01, pos.y * 0.01, seed)
seed = seed + noise_seed_add
noise[2] = simplex_noise(pos.x * 0.05, pos.y * 0.05, seed)
local noise = noise[1] + noise[2] * 0.1
return noise
end
end
local function process_tile(surface, pos)
local tile = surface.get_tile(pos)
if tile.collides_with("player-layer") then return end
local noise = get_noise(1, pos)
if noise < 0.09 and noise > -0.09 then
return
end
local noise_2 = get_noise(2, pos)
if noise_2 < 0.06 and noise_2 > -0.06 then
if math.random(1,6) ~= 1 then
surface.set_tiles({{name = "water", position = pos}})
if math.random(1,48) == 1 then
surface.create_entity({name = "fish", position = pos, force = "neutral"})
end
end
return
end
if math.random(1,6) ~= 1 then
surface.create_entity({name = "rock-big", position = pos, force = "neutral"})
end
end
local function clear_entities_around_position(surface, radius, position, entities)
local square_radius = radius ^ 2
for _, e in pairs(surface.find_entities_filtered({name = entities, area = {{position.x - radius, position.y - radius},{position.x + radius, position.y + radius}}})) do
local square_distance_to_center = ((e.position.x - position.x) ^ 2) + ((e.position.y - position.y) ^ 2)
if square_distance_to_center <= square_radius then
e.destroy()
end
end
end
local function on_chunk_generated(event)
local surface = event.surface
local left_top = event.area.left_top
for x = 0.5, 31.5, 1 do
for y = 0.5, 31.5, 1 do
local pos = {x = left_top.x + x, y = left_top.y + y}
process_tile(surface, pos)
end
end
for _, e in pairs(surface.find_entities_filtered({type = "unit-spawner", area = event.area})) do
clear_entities_around_position(surface, 7, e.position, {"rock-big"})
end
for _, e in pairs(surface.find_entities_filtered({type = "cliff", area = event.area})) do
clear_entities_around_position(surface, 2.25, e.position, {"rock-big"})
end
for _, e in pairs(surface.find_entities_filtered({type = "tree", area = event.area})) do
clear_entities_around_position(surface, 1, e.position, {"rock-big"})
end
if left_top.x == 128 and left_top.y == 128 then
clear_entities_around_position(surface, 5, {x = 0, y = 0}, {"rock-big"})
end
end
local function on_player_joined_game(event)
local surface = init_surface()
local player = game.players[event.player_index]
if player.online_time == 0 then
if not spawn_pos then spawn_pos = {x = 0, y = 0} end
game.forces.player.set_spawn_position(spawn_pos, surface)
player.teleport(spawn_pos, "rocky_waste")
player.insert({name = 'car', count = 1})
player.insert({name = 'pistol', count = 1})
player.insert({name = 'firearm-magazine', count = 16})
end
end
local unearthing_worm = require "functions.unearthing_worm"
local unearthing_biters = require "functions.unearthing_biters"
local function on_player_mined_entity(event)
local entity = event.entity
if not entity.valid then return end
if entity.force.name ~= "neutral" then return end
if math.random(1,256) == 1 then unearthing_worm(entity.surface, entity.position) return end
if math.random(1,256) == 1 then unearthing_biters(entity.surface, entity.position, math.random(4,16)) return end
end
local function on_init()
end
event.on_init(on_init)
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_mined_entity, on_player_mined_entity)

View File

@ -0,0 +1,31 @@
--manually mining continuously will speed it up
local event = require 'utils.event'
local function mining_speed_cooldown(p)
if not global.manual_mining_booster[p.index] then return end
if game.tick - global.manual_mining_booster[p.index] < 180 then return end
p.character.character_mining_speed_modifier = p.character.character_mining_speed_modifier - 1
if p.character.character_mining_speed_modifier <= 0 then p.character.character_mining_speed_modifier = 0 end
end
local function on_player_mined_entity(event)
local player = game.players[event.player_index]
player.character.character_mining_speed_modifier = player.character.character_mining_speed_modifier + (math.random(25, 50) * 0.01)
if player.character.character_mining_speed_modifier > 12 then player.character.character_mining_speed_modifier = 12 end
global.manual_mining_booster[event.player_index] = game.tick
end
local function tick()
for _, p in pairs(game.connected_players) do
mining_speed_cooldown(p)
end
end
local function on_init(event)
global.manual_mining_booster = {}
end
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
event.on_nth_tick(60, tick)
event.on_init(on_init)

View File

@ -0,0 +1,9 @@
local event = require 'utils.event'
local function on_player_joined_game(event)
game.permissions.get_group("Default").set_allows_action(defines.input_action.grab_blueprint_record, false)
game.permissions.get_group("Default").set_allows_action(defines.input_action.import_blueprint_string, false)
game.permissions.get_group("Default").set_allows_action(defines.input_action.import_blueprint, false)
end
event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -0,0 +1,8 @@
local event = require 'utils.event'
local function on_marked_for_deconstruction(event)
if event.entity.force.name ~= "neutral" then return end
event.entity.cancel_deconstruction(game.players[event.player_index].force.name)
end
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)

30
modules/no_robots.lua Normal file
View File

@ -0,0 +1,30 @@
local event = require 'utils.event'
local function on_player_joined_game(event)
game.forces["player"].technologies["logistic-system"].enabled = false
game.forces["player"].technologies["construction-robotics"].enabled = false
game.forces["player"].technologies["logistic-robotics"].enabled = false
game.forces["player"].technologies["robotics"].enabled = false
game.forces["player"].technologies["personal-roboport-equipment"].enabled = false
game.forces["player"].technologies["personal-roboport-mk2-equipment"].enabled = false
game.forces["player"].technologies["character-logistic-trash-slots-1"].enabled = false
game.forces["player"].technologies["character-logistic-trash-slots-2"].enabled = false
game.forces["player"].technologies["auto-character-logistic-trash-slots"].enabled = false
game.forces["player"].technologies["worker-robots-storage-1"].enabled = false
game.forces["player"].technologies["worker-robots-storage-2"].enabled = false
game.forces["player"].technologies["worker-robots-storage-3"].enabled = false
game.forces["player"].technologies["character-logistic-slots-1"].enabled = false
game.forces["player"].technologies["character-logistic-slots-2"].enabled = false
game.forces["player"].technologies["character-logistic-slots-3"].enabled = false
game.forces["player"].technologies["character-logistic-slots-4"].enabled = false
game.forces["player"].technologies["character-logistic-slots-5"].enabled = false
game.forces["player"].technologies["character-logistic-slots-6"].enabled = false
game.forces["player"].technologies["worker-robots-speed-1"].enabled = false
game.forces["player"].technologies["worker-robots-speed-2"].enabled = false
game.forces["player"].technologies["worker-robots-speed-3"].enabled = false
game.forces["player"].technologies["worker-robots-speed-4"].enabled = false
game.forces["player"].technologies["worker-robots-speed-5"].enabled = false
game.forces["player"].technologies["worker-robots-speed-6"].enabled = false
end
event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -23,6 +23,14 @@ local texts = {
["coal"] = {"Coal", {r = 0, g = 0, b = 0}},
["stone"] = {"Stone", {r = 200, g = 160, b = 30}},
}
local particles = {
["iron-ore"] = "iron-ore-particle",
["copper-ore"] = "copper-ore-particle",
["uranium-ore"] = "coal-particle",
["coal"] = "coal-particle",
["stone"] = "stone-particle"
}
local ore_raffle = {}
for _, t in pairs (rock_mining_chance_weights) do
@ -31,12 +39,46 @@ for _, t in pairs (rock_mining_chance_weights) do
end
end
local function create_particles(surface, name, position, amount, cause_position)
local math_random = math.random
local direction_mod = (-100 + math_random(0,200)) * 0.0004
local direction_mod_2 = (-100 + math_random(0,200)) * 0.0004
if cause_position then
direction_mod = (cause_position.x - position.x) * 0.025
direction_mod_2 = (cause_position.y - position.y) * 0.025
end
for i = 1, amount, 1 do
local m = math_random(4, 10)
local m2 = m * 0.005
surface.create_entity({
name = name,
position = position,
frame_speed = 1,
vertical_speed = 0.130,
height = 0,
movement = {
(m2 - (math_random(0, m) * 0.01)) + direction_mod,
(m2 - (math_random(0, m) * 0.01)) + direction_mod_2
}
})
end
end
local function get_amount(entity)
local distance_to_center = math.sqrt(entity.position.x^2 + entity.position.y^2)
local amount = 50 + (distance_to_center * 0.33)
if amount > 150 then amount = 150 end
amount = rock_yield[entity.name] * amount
amount = math.random(math.ceil(amount * 0.5), math.ceil(amount * 1.5))
if not global.rock_yield_amount_modifier then global.rock_yield_amount_modifier = 1 end
amount = amount * global.rock_yield_amount_modifier
amount = math.random(math.ceil(amount * 0.5), math.ceil(amount * 1.5))
return amount
end
@ -48,7 +90,8 @@ local function on_player_mined_entity(event)
local ore = ore_raffle[math.random(1, #ore_raffle)]
local amount = get_amount(entity)
local amount = get_amount(entity)
local amount_to_spill = math.ceil(amount * 0.5)
local amount_to_insert = math.floor(amount * 0.5)
@ -60,6 +103,9 @@ local function on_player_mined_entity(event)
--entity.surface.create_entity({name = "flying-text", position = entity.position, text = amount .. " " .. texts[ore][1], color = texts[ore][2]})
entity.surface.create_entity({name = "flying-text", position = entity.position, text = "+" .. amount .. " [img=item/" .. ore .. "]", color = {r = 200, g = 160, b = 30}})
create_particles(entity.surface, particles[ore], entity.position, 64, game.players[event.player_index].position)
end
end
@ -74,6 +120,7 @@ local function on_entity_died(event)
local pos = {entity.position.x, entity.position.y}
entity.destroy()
surface.spill_item_stack(pos,{name = ore, count = amount}, true)
create_particles(surface, particles[ore], pos, 16)
end
end

View File

@ -26,6 +26,6 @@ function cheat_mode()
--surface.freeze_daytime = 1
game.player.force.research_all_technologies()
game.forces["enemy"].evolution_factor = 0.1
local chart = 200
local chart = 128
game.forces["player"].chart(surface, {lefttop = {x = chart*-1, y = chart*-1}, rightbottom = {x = chart, y = chart}})
end