1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-06 00:23:49 +02:00
This commit is contained in:
MewMew 2019-10-17 00:06:18 +02:00
parent 398416770d
commit 47477431b9
10 changed files with 127 additions and 17 deletions

View File

@ -237,5 +237,27 @@ function mountain_market(surface, position, rarity)
end
function super_market(surface, position, rarity)
local items = get_market_item_list(get_types(), rarity)
if not items then return end
if #items > 0 then table.shuffle_table(items) end
local market = surface.create_entity({name = "market", position = position, force="neutral"})
market.minable = false
market.destructible = false
for i = 1, math.random(6, 12), 1 do
if not items[i] then break end
market.add_market_item(items[i])
end
local sells = get_resource_market_sells()
for i = 1, math.random(1, 3), 1 do
market.add_market_item(sells[i])
end
local buys = get_resource_market_buys()
for i = 1, math.random(1, 3), 1 do
market.add_market_item(buys[i])
end
return market
end

View File

@ -17,6 +17,8 @@ end
local function fish_tag()
if not global.locomotive_cargo then return end
if not global.locomotive_cargo.valid then return end
if not global.locomotive_cargo.surface then return end
if not global.locomotive_cargo.surface.valid then return end
if global.locomotive_tag then
if global.locomotive_tag.valid then
if global.locomotive_tag.position.x == global.locomotive_cargo.position.x and global.locomotive_tag.position.y == global.locomotive_cargo.position.y then return end

View File

@ -176,7 +176,7 @@ local function on_entity_died(event)
player.play_sound{path="utility/game_lost", volume_modifier=0.75}
end
event.entity.surface.spill_item_stack(event.entity.position,{name = "raw-fish", count = 512}, false)
rpg_reset_all_players()
--rpg_reset_all_players()
return
end
@ -204,7 +204,7 @@ end
local function on_research_finished(event)
event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 50 -- +5 Slots / level
local mining_speed_bonus = game.forces.player.mining_drill_productivity_bonus * 5 -- +50% speed / level
if event.research.force.technologies["steel-axe"].researched then mining_speed_bonus = mining_speed_bonus + 1 end -- +100% speed for steel-axe research
if event.research.force.technologies["steel-axe"].researched then mining_speed_bonus = mining_speed_bonus + 0.5 end -- +50% speed for steel-axe research
event.research.force.manual_mining_speed_modifier = mining_speed_bonus
end
@ -212,6 +212,9 @@ local function on_player_joined_game(event)
local player = game.players[event.player_index]
local surface = game.surfaces[global.active_surface_index]
global.player_modifiers[player.index].character_mining_speed_modifier["mountain_fortress"] = 0.5
update_player_modifiers(player)
--20 Players for maximum difficulty
global.wave_defense.wave_interval = 3600 - #game.connected_players * 180
if global.wave_defense.wave_interval < 1800 then global.wave_defense.wave_interval = 1800 end
@ -224,7 +227,13 @@ local function on_player_joined_game(event)
end
if player.surface.index ~= global.active_surface_index then
player.character = nil
player.set_controller({type=defines.controllers.god})
player.create_character()
player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 3, 0.5), surface)
for item, amount in pairs(starting_items) do
player.insert({name = item, count = amount})
end
end
end

View File

@ -275,15 +275,66 @@ local function out_of_map(surface, left_top)
end
end
end
--[[
local function wall(surface, left_top, seed)
local entities = {}
for x = 0, 31, 1 do
for y = 0, 31, 1 do
local p = {x = left_top.x + x, y = left_top.y + y}
local small_caves = get_noise("small_caves", p, seed)
local cave_ponds = get_noise("cave_rivers", p, seed + 100000)
if y > 9 + cave_ponds * 6 and y < 23 + small_caves * 6 then
if small_caves > 0.35 or cave_ponds > 0.35 then
surface.set_tiles({{name = "water-shallow", position = p}})
else
surface.set_tiles({{name = "dirt-7", position = p}})
if math_random(1, 5) ~= 1 then
surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = p})
end
end
else
surface.set_tiles({{name = "dirt-7", position = p}})
if surface.can_place_entity({name = "stone-wall", position = p, force = "enemy"}) then
if math_random(1,512) == 1 and y > 3 and y < 28 then
treasure_chest(surface, p)
else
if y < 7 or y > 23 then
if y <= 15 then
if math_random(1, y + 1) == 1 then
surface.create_entity({name = "stone-wall", position = p, force = "enemy"})
end
else
if math_random(1, 32 - y) == 1 then
surface.create_entity({name = "stone-wall", position = p, force = "enemy"})
end
end
end
end
end
if math_random(1, 32) == 1 then
if surface.can_place_entity({name = "small-worm-turret", position = p, force = "enemy"}) then
wave_defense_set_worm_raffle(math.abs(p.y) * 0.5)
surface.create_entity({name = wave_defense_roll_worm_name(), position = p, force = "enemy"})
end
end
end
end
end
end
]]
local function process_chunk(surface, left_top)
if not surface then return end
if not surface.valid then return end
if left_top.x >= 768 then return end
if left_top.x < -768 then return end
--if left_top.y % 1024 == 0 then wall(surface, left_top, surface.map_gen_settings.seed) return end
if left_top.y >= 0 then replace_water(surface, left_top) end
if left_top.y > 32 then game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}}) end
if left_top.y == 64 and left_top.x == 64 then
if left_top.y == -128 and left_top.x == -128 then
local p = global.locomotive.position
for _, entity in pairs(surface.find_entities_filtered({area = {{p.x - 3, p.y - 4},{p.x + 3, p.y + 10}}, type = "simple-entity"})) do entity.destroy() end
end
@ -301,7 +352,7 @@ local function process_chunk_queue()
return
end
end
]]
local function process_chunk_queue()
local chunk = global.chunk_queue[#global.chunk_queue]
@ -309,6 +360,7 @@ local function process_chunk_queue()
process_chunk(game.surfaces[chunk.surface_index], chunk.left_top)
global.chunk_queue[#global.chunk_queue] = nil
end
]]
local function on_chunk_generated(event)
if event.surface.index == 1 then return end

View File

@ -194,6 +194,12 @@ end
room.three_rocks = function(surface, cell_left_top, direction)
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
if math.random(1,2) == 1 then
local position = surface.find_non_colliding_position("market", {x = left_top.x + grid_size * 0.5, y = left_top.y + grid_size * 0.5}, grid_size * 0.5, 1)
if position then super_market(surface, position, math.floor(global.maze_depth * 0.01) + 1) end
end
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.2, left_top.y + grid_size * 0.8}, force = "neutral"})
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.8, left_top.y + grid_size * 0.8}, force = "neutral"})
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.5, left_top.y + grid_size * 0.2}, force = "neutral"})
@ -202,6 +208,12 @@ end
room.quad_rocks = function(surface, cell_left_top, direction)
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
if math.random(1,2) == 1 then
local position = surface.find_non_colliding_position("market", {x = left_top.x + grid_size * 0.5, y = left_top.y + grid_size * 0.5}, grid_size * 0.5, 1)
if position then super_market(surface, position, math.floor(global.maze_depth * 0.01) + 1) end
end
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.15, left_top.y + grid_size * 0.15}, force = "neutral"})
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.15, left_top.y + grid_size * 0.85}, force = "neutral"})
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.85, left_top.y + grid_size * 0.15}, force = "neutral"})
@ -300,8 +312,8 @@ local room_weights = {
{func = room.tons_of_trees, weight = 15},
{func = room.tons_of_rocks, weight = 35},
{func = room.quad_rocks, weight = 8},
{func = room.three_rocks, weight = 3},
{func = room.quad_rocks, weight = 10},
{func = room.three_rocks, weight = 5},
{func = room.single_rock, weight = 8},
{func = room.checkerboard_ore, weight = 7},

View File

@ -205,7 +205,10 @@ room.circle_pond_with_trees = function(surface, cell_left_top, direction)
map_functions.draw_noise_tile_circle({x = left_top.x + grid_size, y = left_top.y + grid_size}, "grass-2", surface, grid_size * 0.75)
map_functions.draw_noise_tile_circle({x = left_top.x + grid_size, y = left_top.y + grid_size}, "water", surface, grid_size * 0.5)
local position = surface.find_non_colliding_position("market", center_pos, grid_size, 1)
if position then super_market(surface, position, math.floor(global.maze_depth * 0.01) + 1) end
for x = math.floor(grid_size * 2 * 0.1), math.floor(grid_size * 2 * 0.9), 1 do
for y = math.floor(grid_size * 2 * 0.1), math.floor(grid_size * 2 * 0.9), 1 do
local pos = {x = left_top.x + x, y = left_top.y + y}
@ -308,7 +311,7 @@ room.maze = function(surface, cell_left_top, direction)
end
local room_weights = {
{func = room.circle_pond_with_trees, weight = 10},
{func = room.circle_pond_with_trees, weight = 20},
{func = room.scrapyard, weight = 9},
{func = room.stone_block, weight = 12},
{func = room.tons_of_rocks, weight = 12},

View File

@ -225,6 +225,7 @@ end
function spawn_market(surface, position)
local market = surface.create_entity({name = "market", position = position, force = "neutral"})
market.destructible = false
--[[
market.add_market_item({price = {{"coin", 5}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}})
market.add_market_item({price = {{"coin", 5}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}})
market.add_market_item({price = {{"coin", 5}}, offer = {type = 'give-item', item = 'stone', count = 50}})
@ -234,12 +235,13 @@ function spawn_market(surface, position)
market.add_market_item({price = {{'copper-ore', 50}}, offer = {type = 'give-item', item = "coin", count = 5}})
market.add_market_item({price = {{'stone', 50}}, offer = {type = 'give-item', item = "coin", count = 5}})
market.add_market_item({price = {{'coal', 50}}, offer = {type = 'give-item', item = "coin", count = 5}})
market.add_market_item({price = {{"uranium-ore", 25}}, offer = {type = 'give-item', item = 'coin', count = 5}})
market.add_market_item({price = {{"uranium-ore", 25}}, offer = {type = 'give-item', item = 'coin', count = 5}})
market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "wood", count = 50}})
market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "raw-fish", count = 1}})
market.add_market_item({price = {{'coin', 8}}, offer = {type = 'give-item', item = "grenade", count = 1}})
]]
market.add_market_item({price = {{'coin', 2}}, offer = {type = 'give-item', item = "raw-fish", count = 1}})
market.add_market_item({price = {{'coin', 10}}, offer = {type = 'give-item', item = "grenade", count = 1}})
market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "firearm-magazine", count = 1}})
market.add_market_item({price = {{'coin', 16}}, offer = {type = 'give-item', item = "submachine-gun", count = 1}})
market.add_market_item({price = {{'coin', 32}}, offer = {type = 'give-item', item = "car", count = 1}})
market.add_market_item({price = {{'coin', 64}}, offer = {type = 'give-item', item = "car", count = 1}})
end

View File

@ -5,9 +5,11 @@ require "modules.spawners_contain_biters"
--require "modules.manual_mining_booster"
require "modules.rpg"
require "modules.hunger"
require "modules.no_turrets"
--essentials
require "functions.maze"
require "functions.basic_markets"
require "modules.biters_yield_coins"
require "modules.rocks_yield_ore"
require "modules.mineable_wreckage_yields_scrap"

View File

@ -11,7 +11,11 @@ local function is_tag_valid(tag)
end
local function get_corpse_force(corpse)
if corpse.character_corpse_player_index then return game.players[corpse.character_corpse_player_index].force end
if corpse.character_corpse_player_index then
if game.players[corpse.character_corpse_player_index] then
return game.players[corpse.character_corpse_player_index].force
end
end
return game.forces.neutral
end

View File

@ -20,7 +20,9 @@ function update_player_modifiers(player)
for _, value in pairs(global.player_modifiers[player.index][modifier]) do
sum_value = sum_value + value
end
player[modifier] = sum_value
if player.character then
player[modifier] = sum_value
end
end
end