From 2dfaa43d0ce677a991a2fa1541ac4a0df675a842 Mon Sep 17 00:00:00 2001 From: TWLTriston Date: Sun, 22 Oct 2017 22:07:32 -0400 Subject: [PATCH 1/7] Initial start of cleanup for swamp threaded --- locale/gen_combined/dagobah_swamp.lua | 636 +++++++++--------- .../grilledham_map_gen/presets/cage.lua | 13 + .../grilledham_map_gen/presets/goat.lua | 13 + .../grilledham_map_gen/presets/maori.lua | 13 + map_layout.lua | 5 + 5 files changed, 376 insertions(+), 304 deletions(-) create mode 100644 locale/gen_combined/grilledham_map_gen/presets/cage.lua create mode 100644 locale/gen_combined/grilledham_map_gen/presets/goat.lua create mode 100644 locale/gen_combined/grilledham_map_gen/presets/maori.lua diff --git a/locale/gen_combined/dagobah_swamp.lua b/locale/gen_combined/dagobah_swamp.lua index 368e32f1..2b187b5f 100644 --- a/locale/gen_combined/dagobah_swamp.lua +++ b/locale/gen_combined/dagobah_swamp.lua @@ -1,5 +1,5 @@ --Author: MewMew --- !! ATTENTION !! +-- !! ATTENTION !! -- Use water only in starting area as map setting!!! require "locale.gen_shared.perlin_noise" @@ -8,13 +8,13 @@ require "locale.gen_shared.perlin_noise" local function place_entities(surface, entity_list) - local directions = {defines.direction.north, defines.direction.east, defines.direction.south, defines.direction.west} - for _, entity in pairs(entity_list) do - local r = math.random(1,entity.chance) + local directions = {defines.direction.north, defines.direction.east, defines.direction.south, defines.direction.west} + for _, entity in pairs(entity_list) do + local r = math.random(1,entity.chance) if r == 1 then if not entity.force then entity.force = "player" end - local r = math.random(1,4) - if surface.can_place_entity {name=entity.name, position=entity.pos, direction=directions[r], force=entity.force} then + local r = math.random(1,4) + if surface.can_place_entity {name=entity.name, position=entity.pos, direction=directions[r], force=entity.force} then local e = surface.create_entity {name=entity.name, position=entity.pos, direction=directions[r], force=entity.force} if entity.health then if entity.health == "low" then e.health = ((e.health / 1000) * math.random(33,330)) end @@ -23,8 +23,8 @@ local function place_entities(surface, entity_list) if entity.health == "random" then e.health = ((e.health / 1000) * math.random(1,1000)) end end return true, e - end - end + end + end end return false end @@ -37,17 +37,17 @@ local function auto_place_entity_around_target(entity, scan_radius, mode, densit if not entity then return end if not mode then mode = "ball" end if not density then density = 1 end - - if surface.can_place_entity {name=entity.name, position={x,y}} then + + if surface.can_place_entity {name=entity.name, position={x,y}} then local e = surface.create_entity {name=entity.name, position={x,y}} return true, e end - + local i = 2 - local r = 1 - + local r = 1 + if mode == "ball" then - if math.random(1,2) == 1 then + if math.random(1,2) == 1 then density = density * -1 end r = math.random(1,4) @@ -67,156 +67,156 @@ local function auto_place_entity_around_target(entity, scan_radius, mode, densit if mode == "block" then r = 1 density = 1 - end - + end + if r == 1 then --start placing at -1,-1 while i <= scan_radius do - y = y - density - x = x - density - for a = 1, i, 1 do - if surface.can_place_entity {name=entity.name, position={x,y}} then - local e = surface.create_entity {name=entity.name, position={x,y}} - return true, e - end - x = x + density - end - for a = 1, i, 1 do - if surface.can_place_entity {name=entity.name, position={x,y}} then - local e = surface.create_entity {name=entity.name, position={x,y}} - return true, e - end - y = y + density - end - for a = 1, i, 1 do - if surface.can_place_entity {name=entity.name, position={x,y}} then - local e = surface.create_entity {name=entity.name, position={x,y}} - return true, e - end - x = x - density - end - for a = 1, i, 1 do - if surface.can_place_entity {name=entity.name, position={x,y}} then - local e = surface.create_entity {name=entity.name, position={x,y}} - return true, e - end - y = y - density - end - i = i + 2 - end - end - - if r == 2 then - --start placing at 0,-1 - while i <= scan_radius do - y = y - density + y = y - density x = x - density for a = 1, i, 1 do + if surface.can_place_entity {name=entity.name, position={x,y}} then + local e = surface.create_entity {name=entity.name, position={x,y}} + return true, e + end x = x + density - if surface.can_place_entity {name=entity.name, position={x,y}} then - local e = surface.create_entity {name=entity.name, position={x,y}} - return true, e - end - end + end for a = 1, i, 1 do - y = y + density - if surface.can_place_entity {name=entity.name, position={x,y}} then - local e = surface.create_entity {name=entity.name, position={x,y}} - return true, e - end - end - for a = 1, i, 1 do - x = x - density - if surface.can_place_entity {name=entity.name, position={x,y}} then - local e = surface.create_entity {name=entity.name, position={x,y}} - return true, e - end - end - for a = 1, i, 1 do - y = y - density - if surface.can_place_entity {name=entity.name, position={x,y}} then - local e = surface.create_entity {name=entity.name, position={x,y}} - return true, e - end - end - i = i + 2 - end - end - - if r == 3 then - --start placing at 1,-1 - while i <= scan_radius do - y = y - density - x = x + density - for a = 1, i, 1 do - if surface.can_place_entity {name=entity.name, position={x,y}} then + if surface.can_place_entity {name=entity.name, position={x,y}} then local e = surface.create_entity {name=entity.name, position={x,y}} return true, e end y = y + density - end - for a = 1, i, 1 do - if surface.can_place_entity {name=entity.name, position={x,y}} then + end + for a = 1, i, 1 do + if surface.can_place_entity {name=entity.name, position={x,y}} then local e = surface.create_entity {name=entity.name, position={x,y}} return true, e end x = x - density - end - for a = 1, i, 1 do - if surface.can_place_entity {name=entity.name, position={x,y}} then + end + for a = 1, i, 1 do + if surface.can_place_entity {name=entity.name, position={x,y}} then local e = surface.create_entity {name=entity.name, position={x,y}} return true, e end y = y - density end - for a = 1, i, 1 do - if surface.can_place_entity {name=entity.name, position={x,y}} then + i = i + 2 + end + end + + if r == 2 then + --start placing at 0,-1 + while i <= scan_radius do + y = y - density + x = x - density + for a = 1, i, 1 do + x = x + density + if surface.can_place_entity {name=entity.name, position={x,y}} then + local e = surface.create_entity {name=entity.name, position={x,y}} + return true, e + end + end + for a = 1, i, 1 do + y = y + density + if surface.can_place_entity {name=entity.name, position={x,y}} then + local e = surface.create_entity {name=entity.name, position={x,y}} + return true, e + end + end + for a = 1, i, 1 do + x = x - density + if surface.can_place_entity {name=entity.name, position={x,y}} then + local e = surface.create_entity {name=entity.name, position={x,y}} + return true, e + end + end + for a = 1, i, 1 do + y = y - density + if surface.can_place_entity {name=entity.name, position={x,y}} then + local e = surface.create_entity {name=entity.name, position={x,y}} + return true, e + end + end + i = i + 2 + end + end + + if r == 3 then + --start placing at 1,-1 + while i <= scan_radius do + y = y - density + x = x + density + for a = 1, i, 1 do + if surface.can_place_entity {name=entity.name, position={x,y}} then + local e = surface.create_entity {name=entity.name, position={x,y}} + return true, e + end + y = y + density + end + for a = 1, i, 1 do + if surface.can_place_entity {name=entity.name, position={x,y}} then + local e = surface.create_entity {name=entity.name, position={x,y}} + return true, e + end + x = x - density + end + for a = 1, i, 1 do + if surface.can_place_entity {name=entity.name, position={x,y}} then + local e = surface.create_entity {name=entity.name, position={x,y}} + return true, e + end + y = y - density + end + for a = 1, i, 1 do + if surface.can_place_entity {name=entity.name, position={x,y}} then local e = surface.create_entity {name=entity.name, position={x,y}} return true, e end x = x + density - end + end i = i + 2 end end - + if r == 4 then --start placing at 1,0 while i <= scan_radius do y = y - density - x = x + density + x = x + density for a = 1, i, 1 do y = y + density - if surface.can_place_entity {name=entity.name, position={x,y}} then + if surface.can_place_entity {name=entity.name, position={x,y}} then local e = surface.create_entity {name=entity.name, position={x,y}} return true, e end - end + end for a = 1, i, 1 do x = x - density - if surface.can_place_entity {name=entity.name, position={x,y}} then + if surface.can_place_entity {name=entity.name, position={x,y}} then local e = surface.create_entity {name=entity.name, position={x,y}} return true, e end - end + end for a = 1, i, 1 do y = y - density - if surface.can_place_entity {name=entity.name, position={x,y}} then + if surface.can_place_entity {name=entity.name, position={x,y}} then local e = surface.create_entity {name=entity.name, position={x,y}} return true, e end end for a = 1, i, 1 do x = x + density - if surface.can_place_entity {name=entity.name, position={x,y}} then + if surface.can_place_entity {name=entity.name, position={x,y}} then local e = surface.create_entity {name=entity.name, position={x,y}} return true, e end - end + end i = i + 2 end end - + return false end @@ -224,227 +224,255 @@ local function create_tree_cluster(pos, amount) if not pos then return false end if amount == nil then amount = 7 end local scan_radius = amount * 2 - --local mode = "line_down" + --local mode = "line_down" --if math.random(1,2) == 1 then mode = "line_up" end local mode = "ball" local entity = {} - entity.pos = pos + entity.pos = pos for i = 1, amount, 1 do entity.name = "tree-06" local density = 2 - if 1 == math.random(1,20) then entity.name = "tree-07" end + if 1 == math.random(1,20) then entity.name = "tree-07" end if 1 == math.random(1,70) then entity.name = "tree-09" end if 1 == math.random(1,10) then entity.name = "tree-04" end if 1 == math.random(1,9) then density = 1 end if 1 == math.random(1,3) then density = 3 end if 1 == math.random(1,3) then density = 4 end - + local b, e = auto_place_entity_around_target(entity, scan_radius, mode, density) if b == true then if 1 == math.random(1,3) then entity.pos = e.position - end + end end - end + end return b, e end +global.swamp_tiles_hold = {} +global.swamp_decoratives_hold = {} + +function run_swamp_rivers_init(params) + global.swamp_tiles_hold = {} + global.swamp_decoratives_hold = {} +end + +function run_swamp_place_tiles(params) + local surface = params.surface + surface.set_tiles(global.swamp_tiles_hold) + for _,deco in pairs(global.swamp_decoratives_hold) do + surface.create_decoratives{check_collision=false, decoratives={deco}} + end +end + +function run_swamp_river(params) + local area = params.area + local surface = params.surface + + local x = params.x + local pos_x = area.left_top.x + x + + for y = 0, 31, 1 do + local pos_y = area.left_top.y + y + local noise_terrain_1 = perlin:noise(((pos_x+seed)/150),((pos_y+seed)/150),0) + local noise_terrain_2 = perlin:noise(((pos_x+seed)/75),((pos_y+seed)/75),0) + local noise_terrain_3 = perlin:noise(((pos_x+seed)/50),((pos_y+seed)/50),0) + local noise_terrain_4 = perlin:noise(((pos_x+seed)/7),((pos_y+seed)/7),0) + local noise_terrain = noise_terrain_1 + (noise_terrain_2 * 0.2) + (noise_terrain_3 * 0.1) + (noise_terrain_4 * 0.02) + local tile_to_insert + if noise_terrain > -0.03 and noise_terrain < 0.03 then + tile_to_insert = "water-green" + local a = pos_x + 1 + table.insert(global.swamp_tiles_hold, {name = tile_to_insert, position = {a,pos_y}}) + local a = pos_y + 1 + table.insert(global.swamp_tiles_hold, {name = tile_to_insert, position = {pos_x,a}}) + local a = pos_x - 1 + table.insert(global.swamp_tiles_hold, {name = tile_to_insert, position = {a,pos_y}}) + local a = pos_y - 1 + table.insert(global.swamp_tiles_hold, {name = tile_to_insert, position = {pos_x,a}}) + table.insert(global.swamp_tiles_hold, {name = tile_to_insert, position = {pos_x,pos_y}}) + end + end +end + +function run_swamp_destroy_trees(params) + local entities = surface.find_entities(area) + for _, entity in pairs(entities) do + if entity.type == "simple-entity" or entity.type == "tree" then + if entity.name ~= "tree-09" and entity.name ~= "tree-07" and entity.name ~= "tree-06" then --and entity.name ~= "tree-04" + entity.destroy() + end + end + end +end function + function run_combined_module(event) -- Generate Rivers if not global.perlin_noise_seed then global.perlin_noise_seed = math.random(1000,1000000) end - local seed = global.perlin_noise_seed - local tiles = {} - for x = 0, 31, 1 do - for y = 0, 31, 1 do - local pos_x = event.area.left_top.x + x - local pos_y = event.area.left_top.y + y - local noise_terrain_1 = perlin:noise(((pos_x+seed)/150),((pos_y+seed)/150),0) - local noise_terrain_2 = perlin:noise(((pos_x+seed)/75),((pos_y+seed)/75),0) - local noise_terrain_3 = perlin:noise(((pos_x+seed)/50),((pos_y+seed)/50),0) - local noise_terrain_4 = perlin:noise(((pos_x+seed)/7),((pos_y+seed)/7),0) - local noise_terrain = noise_terrain_1 + (noise_terrain_2 * 0.2) + (noise_terrain_3 * 0.1) + (noise_terrain_4 * 0.02) - local tile_to_insert - if noise_terrain > -0.03 and noise_terrain < 0.03 then - tile_to_insert = "water-green" - local a = pos_x + 1 - table.insert(tiles, {name = tile_to_insert, position = {a,pos_y}}) - local a = pos_y + 1 - table.insert(tiles, {name = tile_to_insert, position = {pos_x,a}}) - local a = pos_x - 1 - table.insert(tiles, {name = tile_to_insert, position = {a,pos_y}}) - local a = pos_y - 1 - table.insert(tiles, {name = tile_to_insert, position = {pos_x,a}}) - table.insert(tiles, {name = tile_to_insert, position = {pos_x,pos_y}}) + + local seed = global.perlin_noise_seed + local tiles = {} + + Thread.queue_action("run_swamp_river_init", {} ) + for x = 0, 31, 1 do + Thread.queue_action("run_swamp_river", {area = event.area, surface = event.surface, x = x}) + end + Thread.queue_action("run_swamp_place_tiles", {} ) + + -- Generate other thingies + Thread.queue_action("run_swamp_destroy_trees", {area = event.area, surface = event.surface, x = x} ) + + + local forest_cluster = true + if math.random(1,4) == 1 then forest_cluster = false end +-- @TODO THread this + for x = 0, 31, 1 do + for y = 0, 31, 1 do + local pos_x = event.area.left_top.x + x + local pos_y = event.area.left_top.y + y + local pos = {x = pos_x,y = pos_y} + local tile = surface.get_tile(pos_x,pos_y) + local tile_to_insert = tile + local entity_placed = false + -- or tile.name == "grass-dry" + --if tile.name ~= "water" and tile.name ~= "deepwater" and tile.name ~= "water-green" then + if tile.name ~= "water-green" then + table.insert(tiles, {name = "grass", position = {pos_x,pos_y}}) + + local entity_list = {} + table.insert(entity_list, {name="big-ship-wreck-1", pos={pos_x,pos_y},chance = 65000, health="random"}) + table.insert(entity_list, {name="big-ship-wreck-2", pos={pos_x,pos_y},chance = 65000, health="random"}) + table.insert(entity_list, {name="big-ship-wreck-3", pos={pos_x,pos_y},chance = 65000, health="random"}) + local b, placed_entity = place_entities(surface, entity_list) + if b == true then + placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)]) + placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)]) + placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)]) + end + + local entity_list = {} + table.insert(entity_list, {name="tree-04", pos={pos_x,pos_y},chance = 400}) + table.insert(entity_list, {name="tree-09", pos={pos_x,pos_y},chance = 1000}) + table.insert(entity_list, {name="tree-07", pos={pos_x,pos_y},chance = 400}) + table.insert(entity_list, {name="tree-06", pos={pos_x,pos_y},chance = 150}) + table.insert(entity_list, {name="stone-rock", pos={pos_x,pos_y},chance = 400}) + table.insert(entity_list, {name="green-coral", pos={pos_x,pos_y},chance = 10000}) + table.insert(entity_list, {name="medium-ship-wreck", pos={pos_x,pos_y},chance = 25000, health="random"}) + table.insert(entity_list, {name="small-ship-wreck", pos={pos_x,pos_y},chance = 25000, health="random"}) + table.insert(entity_list, {name="car", pos={pos_x,pos_y},chance = 125000, health="low"}) + table.insert(entity_list, {name="stone-furnace", pos={pos_x,pos_y},chance = 100000, health="random", force="enemy"}) + local b, placed_entity = place_entities(surface, entity_list) + + if forest_cluster == true then + if math.random(1,800) == 1 then create_tree_cluster(pos, 120) end + end + + else + --if tile.name == "water" then tile_to_insert = "water" end + --if tile.name == "deepwater" then tile_to_insert = "deepwater" end + end + + end + end + surface.set_tiles(tiles,true) + + --check for existing chunk if you would overwrite decoratives + local for_start_x = 0 + local for_end_x = 31 + local for_start_y = 0 + local for_end_y = 31 + local testing_pos = event.area.left_top.x - 1 + local tile = surface.get_tile(testing_pos, event.area.left_top.y) + if tile.name then for_start_x = -1 end + local testing_pos = event.area.left_top.y - 1 + local tile = surface.get_tile(event.area.left_top.x, testing_pos) + if tile.name then for_start_y = -1 end + local testing_pos = event.area.right_bottom.x + local tile = surface.get_tile(testing_pos, event.area.right_bottom.y) + if tile.name then for_end_x = 32 end + local testing_pos = event.area.right_bottom.y + local tile = surface.get_tile(event.area.right_bottom.x, testing_pos) + if tile.name then for_end_y = 32 end + + for x = for_start_x, for_end_x, 1 do + for y = for_start_y, for_end_y, 1 do + local pos_x = event.area.left_top.x + x + local pos_y = event.area.left_top.y + y + local tile = surface.get_tile(pos_x, pos_y) + local decal_has_been_placed = false + + if tile.name == "grass" then + if decal_has_been_placed == false then + local r = math.random(1,3) + if r == 1 then + table.insert(decoratives, {name="green-carpet-grass", position={pos_x,pos_y}, amount=1}) + decal_has_been_placed = false + end + end + if decal_has_been_placed == false then + local r = math.random(1,7) + if r == 1 then + table.insert(decoratives, {name="green-hairy-grass", position={pos_x,pos_y}, amount=1}) + decal_has_been_placed = false + end + end + if decal_has_been_placed == false then + local r = math.random(1,10) + if r == 1 then + table.insert(decoratives, {name="green-bush-mini", position={pos_x,pos_y}, amount=1}) + decal_has_been_placed = false + end + end + if decal_has_been_placed == false then + local r = math.random(1,6) + if r == 1 then + table.insert(decoratives, {name="green-pita", position={pos_x,pos_y}, amount=1}) + decal_has_been_placed = false + end + end + if decal_has_been_placed == false then + local r = math.random(1,12) + if r == 1 then + table.insert(decoratives, {name="green-small-grass", position={pos_x,pos_y}, amount=1}) + decal_has_been_placed = false + end + end + if decal_has_been_placed == false then + local r = math.random(1,25) + if r == 1 then + table.insert(decoratives, {name="green-asterisk", position={pos_x,pos_y}, amount=1}) + decal_has_been_placed = false + end end end - end - event.surface.set_tiles(tiles,true) - - -- Generate other thingies - local area = event.area - local surface = event.surface - --local surface = game.surfaces[1] - local tiles = {} - local decoratives = {} - - local entities = surface.find_entities(area) - for _, entity in pairs(entities) do - if entity.type == "simple-entity" or entity.type == "tree" then - if entity.name ~= "tree-09" and entity.name ~= "tree-07" and entity.name ~= "tree-06" then --and entity.name ~= "tree-04" - entity.destroy() + if tile.name == "water" or tile.name == "water-green" then + + if decal_has_been_placed == false then + local r = math.random(1,18) + if r == 1 then + table.insert(decoratives, {name="green-carpet-grass", position={pos_x,pos_y}, amount=1}) + decal_has_been_placed = false + end + end + if decal_has_been_placed == false then + local r = math.random(1,950) + if r == 1 then + table.insert(decoratives, {name="green-small-grass", position={pos_x,pos_y}, amount=1}) + decal_has_been_placed = false + end + end + if decal_has_been_placed == false then + local r = math.random(1,150) + if r == 1 then + table.insert(decoratives, {name="green-bush-mini", position={pos_x,pos_y}, amount=1}) + decal_has_been_placed = false + end end end end - local forest_cluster = true - if math.random(1,4) == 1 then forest_cluster = false end - - for x = 0, 31, 1 do - for y = 0, 31, 1 do - local pos_x = event.area.left_top.x + x - local pos_y = event.area.left_top.y + y - local pos = {x = pos_x,y = pos_y} - local tile = surface.get_tile(pos_x,pos_y) - local tile_to_insert = tile - local entity_placed = false - -- or tile.name == "grass-dry" - --if tile.name ~= "water" and tile.name ~= "deepwater" and tile.name ~= "water-green" then - if tile.name ~= "water-green" then - table.insert(tiles, {name = "grass", position = {pos_x,pos_y}}) - - local entity_list = {} - table.insert(entity_list, {name="big-ship-wreck-1", pos={pos_x,pos_y},chance = 65000, health="random"}) - table.insert(entity_list, {name="big-ship-wreck-2", pos={pos_x,pos_y},chance = 65000, health="random"}) - table.insert(entity_list, {name="big-ship-wreck-3", pos={pos_x,pos_y},chance = 65000, health="random"}) - local b, placed_entity = place_entities(surface, entity_list) - if b == true then - placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)]) - placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)]) - placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)]) - end - - local entity_list = {} - table.insert(entity_list, {name="tree-04", pos={pos_x,pos_y},chance = 400}) - table.insert(entity_list, {name="tree-09", pos={pos_x,pos_y},chance = 1000}) - table.insert(entity_list, {name="tree-07", pos={pos_x,pos_y},chance = 400}) - table.insert(entity_list, {name="tree-06", pos={pos_x,pos_y},chance = 150}) - table.insert(entity_list, {name="stone-rock", pos={pos_x,pos_y},chance = 400}) - table.insert(entity_list, {name="green-coral", pos={pos_x,pos_y},chance = 10000}) - table.insert(entity_list, {name="medium-ship-wreck", pos={pos_x,pos_y},chance = 25000, health="random"}) - table.insert(entity_list, {name="small-ship-wreck", pos={pos_x,pos_y},chance = 25000, health="random"}) - table.insert(entity_list, {name="car", pos={pos_x,pos_y},chance = 125000, health="low"}) - table.insert(entity_list, {name="stone-furnace", pos={pos_x,pos_y},chance = 100000, health="random", force="enemy"}) - local b, placed_entity = place_entities(surface, entity_list) - - if forest_cluster == true then - if math.random(1,800) == 1 then create_tree_cluster(pos, 120) end - end - - else - --if tile.name == "water" then tile_to_insert = "water" end - --if tile.name == "deepwater" then tile_to_insert = "deepwater" end - end - - end - end - surface.set_tiles(tiles,true) - - --check for existing chunk if you would overwrite decoratives - local for_start_x = 0 - local for_end_x = 31 - local for_start_y = 0 - local for_end_y = 31 - local testing_pos = event.area.left_top.x - 1 - local tile = surface.get_tile(testing_pos, event.area.left_top.y) - if tile.name then for_start_x = -1 end - local testing_pos = event.area.left_top.y - 1 - local tile = surface.get_tile(event.area.left_top.x, testing_pos) - if tile.name then for_start_y = -1 end - local testing_pos = event.area.right_bottom.x - local tile = surface.get_tile(testing_pos, event.area.right_bottom.y) - if tile.name then for_end_x = 32 end - local testing_pos = event.area.right_bottom.y - local tile = surface.get_tile(event.area.right_bottom.x, testing_pos) - if tile.name then for_end_y = 32 end - - for x = for_start_x, for_end_x, 1 do - for y = for_start_y, for_end_y, 1 do - local pos_x = event.area.left_top.x + x - local pos_y = event.area.left_top.y + y - local tile = surface.get_tile(pos_x, pos_y) - local decal_has_been_placed = false - - if tile.name == "grass" then - if decal_has_been_placed == false then - local r = math.random(1,3) - if r == 1 then - table.insert(decoratives, {name="green-carpet-grass", position={pos_x,pos_y}, amount=1}) - decal_has_been_placed = false - end - end - if decal_has_been_placed == false then - local r = math.random(1,7) - if r == 1 then - table.insert(decoratives, {name="green-hairy-grass", position={pos_x,pos_y}, amount=1}) - decal_has_been_placed = false - end - end - if decal_has_been_placed == false then - local r = math.random(1,10) - if r == 1 then - table.insert(decoratives, {name="green-bush-mini", position={pos_x,pos_y}, amount=1}) - decal_has_been_placed = false - end - end - if decal_has_been_placed == false then - local r = math.random(1,6) - if r == 1 then - table.insert(decoratives, {name="green-pita", position={pos_x,pos_y}, amount=1}) - decal_has_been_placed = false - end - end - if decal_has_been_placed == false then - local r = math.random(1,12) - if r == 1 then - table.insert(decoratives, {name="green-small-grass", position={pos_x,pos_y}, amount=1}) - decal_has_been_placed = false - end - end - if decal_has_been_placed == false then - local r = math.random(1,25) - if r == 1 then - table.insert(decoratives, {name="green-asterisk", position={pos_x,pos_y}, amount=1}) - decal_has_been_placed = false - end - end - end - if tile.name == "water" or tile.name == "water-green" then - - if decal_has_been_placed == false then - local r = math.random(1,18) - if r == 1 then - table.insert(decoratives, {name="green-carpet-grass", position={pos_x,pos_y}, amount=1}) - decal_has_been_placed = false - end - end - if decal_has_been_placed == false then - local r = math.random(1,950) - if r == 1 then - table.insert(decoratives, {name="green-small-grass", position={pos_x,pos_y}, amount=1}) - decal_has_been_placed = false - end - end - if decal_has_been_placed == false then - local r = math.random(1,150) - if r == 1 then - table.insert(decoratives, {name="green-bush-mini", position={pos_x,pos_y}, amount=1}) - decal_has_been_placed = false - end - end - end - end - end - for _,deco in pairs(decoratives) do - surface.create_decoratives{check_collision=false, decoratives={deco}} - end + end + for _,deco in pairs(decoratives) do + surface.create_decoratives{check_collision=false, decoratives={deco}} + end end diff --git a/locale/gen_combined/grilledham_map_gen/presets/cage.lua b/locale/gen_combined/grilledham_map_gen/presets/cage.lua new file mode 100644 index 00000000..b05b8729 --- /dev/null +++ b/locale/gen_combined/grilledham_map_gen/presets/cage.lua @@ -0,0 +1,13 @@ +require "locale.gen_combined.grilledham_map_gen.map_gen" +require "locale.gen_combined.grilledham_map_gen.builders" + +local pic = require "locale.gen_combined.grilledham_map_gen.data.cage" + +local shape = picture_builder(pic.data, pic.width, pic.height) +shape = translate(shape, 10, -96) +shape = scale(shape,2,2) +--shape = rotate(shape, degrees(0)) + +-- shape = change_tile(shape, false, "deepwater") + +return shape diff --git a/locale/gen_combined/grilledham_map_gen/presets/goat.lua b/locale/gen_combined/grilledham_map_gen/presets/goat.lua new file mode 100644 index 00000000..ab33e266 --- /dev/null +++ b/locale/gen_combined/grilledham_map_gen/presets/goat.lua @@ -0,0 +1,13 @@ +require "locale.gen_combined.grilledham_map_gen.map_gen" +require "locale.gen_combined.grilledham_map_gen.builders" + +local pic = require "locale.gen_combined.grilledham_map_gen.data.goat" + +local shape = picture_builder(pic.data, pic.width, pic.height) +shape = translate(shape, 10, -96) +shape = scale(shape,2,2) +--shape = rotate(shape, degrees(0)) + +-- shape = change_tile(shape, false, "deepwater") + +return shape diff --git a/locale/gen_combined/grilledham_map_gen/presets/maori.lua b/locale/gen_combined/grilledham_map_gen/presets/maori.lua new file mode 100644 index 00000000..f61dced9 --- /dev/null +++ b/locale/gen_combined/grilledham_map_gen/presets/maori.lua @@ -0,0 +1,13 @@ +require "locale.gen_combined.grilledham_map_gen.map_gen" +require "locale.gen_combined.grilledham_map_gen.builders" + +local pic = require "locale.gen_combined.grilledham_map_gen.data.maori" + +local shape = picture_builder(pic.data, pic.width, pic.height) +shape = translate(shape, 10, -96) +shape = scale(shape,2,2) +--shape = rotate(shape, degrees(0)) + +-- shape = change_tile(shape, false, "deepwater") + +return shape diff --git a/map_layout.lua b/map_layout.lua index e5b45c18..78c262be 100644 --- a/map_layout.lua +++ b/map_layout.lua @@ -10,6 +10,7 @@ in this file and your run_*type*_module(event) function will be called. --require "locale.gen_combined.island_resort" --require "locale.gen_combined.red_planet_v2" --require "locale.gen_combined.borg_planet_v2" +require "locale.gen_combined.dagobah_swamp" --grilledham's maps --MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.mobius_strip" @@ -17,6 +18,10 @@ in this file and your run_*type*_module(event) function will be called. --MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.creation_of_adam" --MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.manhattan" --MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.mona_lisa" +--MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.cage" +--MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.maori" +--MAP_GEN = require "locale.gen_combined.grilledham_map_gen.presets.goat" + --shapes-- --require "locale.gen_shape.right" --require "locale.gen_shape.up" From ce54d23d5c1917759c48abfbff54f2c57911c369 Mon Sep 17 00:00:00 2001 From: TWLTriston Date: Mon, 23 Oct 2017 06:45:46 -0400 Subject: [PATCH 2/7] Threaded updates --- locale/gen_combined/dagobah_swamp.lua | 154 +++++++++++++++----------- 1 file changed, 92 insertions(+), 62 deletions(-) diff --git a/locale/gen_combined/dagobah_swamp.lua b/locale/gen_combined/dagobah_swamp.lua index 2b187b5f..c7c4f86a 100644 --- a/locale/gen_combined/dagobah_swamp.lua +++ b/locale/gen_combined/dagobah_swamp.lua @@ -1,8 +1,9 @@ --Author: MewMew +-- Threaded by Tris -- !! ATTENTION !! -- Use water only in starting area as map setting!!! require "locale.gen_shared.perlin_noise" - +local Thread = require "locale.utils.Thread" wreck_item_pool = {} wreck_item_pool = {{name="iron-gear-wheel", count=32},{name="iron-plate", count=64},{name="rocket-control-unit", count=1} ,{name="coal", count=4},{name="rocket-launcher", count=1},{name="rocket", count=32},{name="copper-cable", count=128},{name="land-mine", count=64},{name="railgun", count=1},{name="railgun-dart", count=128},{name="fast-inserter", count=8},{name="stack-filter-inserter", count=2},{name="belt-immunity-equipment", count=1},{name="fusion-reactor-equipment", count=1},{name="electric-engine-unit", count=8},{name="exoskeleton-equipment", count=1},{name="rocket-fuel", count=10},{name="used-up-uranium-fuel-cell", count=3},{name="uranium-fuel-cell", count=2}} @@ -252,7 +253,7 @@ end global.swamp_tiles_hold = {} global.swamp_decoratives_hold = {} -function run_swamp_rivers_init(params) +function run_swamp_init(params) global.swamp_tiles_hold = {} global.swamp_decoratives_hold = {} end @@ -271,6 +272,7 @@ function run_swamp_river(params) local x = params.x local pos_x = area.left_top.x + x + local seed = params.seed for y = 0, 31, 1 do local pos_y = area.left_top.y + y @@ -304,7 +306,62 @@ function run_swamp_destroy_trees(params) end end end -end function +end + +function run_swamp_entities(params) + local area = params.area + local surface = params.surface + + local x = params.x + local pos_x = area.left_top.x + x + local forest_cluster = params.forest_cluster + + for y = 0, 31, 1 do + local pos_y = area.left_top.y + y + local pos = {x = pos_x,y = pos_y} + local tile = surface.get_tile(pos_x,pos_y) + local tile_to_insert = tile + local entity_placed = false + -- or tile.name == "grass-dry" + --if tile.name ~= "water" and tile.name ~= "deepwater" and tile.name ~= "water-green" then + if tile.name ~= "water-green" then + table.insert(global.swamp_tiles_hold, {name = "grass", position = {pos_x,pos_y}}) + + local entity_list = {} + table.insert(entity_list, {name="big-ship-wreck-1", pos={pos_x,pos_y},chance = 65000, health="random"}) + table.insert(entity_list, {name="big-ship-wreck-2", pos={pos_x,pos_y},chance = 65000, health="random"}) + table.insert(entity_list, {name="big-ship-wreck-3", pos={pos_x,pos_y},chance = 65000, health="random"}) + local b, placed_entity = place_entities(surface, entity_list) + if b == true then + placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)]) + placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)]) + placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)]) + end + + local entity_list = {} + table.insert(entity_list, {name="tree-04", pos={pos_x,pos_y},chance = 400}) + table.insert(entity_list, {name="tree-09", pos={pos_x,pos_y},chance = 1000}) + table.insert(entity_list, {name="tree-07", pos={pos_x,pos_y},chance = 400}) + table.insert(entity_list, {name="tree-06", pos={pos_x,pos_y},chance = 150}) + table.insert(entity_list, {name="stone-rock", pos={pos_x,pos_y},chance = 400}) + table.insert(entity_list, {name="green-coral", pos={pos_x,pos_y},chance = 10000}) + table.insert(entity_list, {name="medium-ship-wreck", pos={pos_x,pos_y},chance = 25000, health="random"}) + table.insert(entity_list, {name="small-ship-wreck", pos={pos_x,pos_y},chance = 25000, health="random"}) + table.insert(entity_list, {name="car", pos={pos_x,pos_y},chance = 125000, health="low"}) + table.insert(entity_list, {name="stone-furnace", pos={pos_x,pos_y},chance = 100000, health="random", force="enemy"}) + local b, placed_entity = place_entities(surface, entity_list) + + if forest_cluster == true then + if math.random(1,800) == 1 then create_tree_cluster(pos, 120) end + end + + else + --if tile.name == "water" then tile_to_insert = "water" end + --if tile.name == "deepwater" then tile_to_insert = "deepwater" end + end + + end +end function run_combined_module(event) @@ -314,11 +371,11 @@ function run_combined_module(event) local seed = global.perlin_noise_seed local tiles = {} - Thread.queue_action("run_swamp_river_init", {} ) + Thread.queue_action("run_swamp_init", {} ) for x = 0, 31, 1 do - Thread.queue_action("run_swamp_river", {area = event.area, surface = event.surface, x = x}) + Thread.queue_action("run_swamp_river", {area = event.area, surface = event.surface, x = x, seed = seed}) end - Thread.queue_action("run_swamp_place_tiles", {} ) + Thread.queue_action("run_swamp_place_tiles", {surface = event.surface} ) -- Generate other thingies Thread.queue_action("run_swamp_destroy_trees", {area = event.area, surface = event.surface, x = x} ) @@ -326,79 +383,52 @@ function run_combined_module(event) local forest_cluster = true if math.random(1,4) == 1 then forest_cluster = false end + + Thread.queue_action("run_swamp_init", {} ) + -- @TODO THread this for x = 0, 31, 1 do - for y = 0, 31, 1 do - local pos_x = event.area.left_top.x + x - local pos_y = event.area.left_top.y + y - local pos = {x = pos_x,y = pos_y} - local tile = surface.get_tile(pos_x,pos_y) - local tile_to_insert = tile - local entity_placed = false - -- or tile.name == "grass-dry" - --if tile.name ~= "water" and tile.name ~= "deepwater" and tile.name ~= "water-green" then - if tile.name ~= "water-green" then - table.insert(tiles, {name = "grass", position = {pos_x,pos_y}}) - - local entity_list = {} - table.insert(entity_list, {name="big-ship-wreck-1", pos={pos_x,pos_y},chance = 65000, health="random"}) - table.insert(entity_list, {name="big-ship-wreck-2", pos={pos_x,pos_y},chance = 65000, health="random"}) - table.insert(entity_list, {name="big-ship-wreck-3", pos={pos_x,pos_y},chance = 65000, health="random"}) - local b, placed_entity = place_entities(surface, entity_list) - if b == true then - placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)]) - placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)]) - placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)]) - end - - local entity_list = {} - table.insert(entity_list, {name="tree-04", pos={pos_x,pos_y},chance = 400}) - table.insert(entity_list, {name="tree-09", pos={pos_x,pos_y},chance = 1000}) - table.insert(entity_list, {name="tree-07", pos={pos_x,pos_y},chance = 400}) - table.insert(entity_list, {name="tree-06", pos={pos_x,pos_y},chance = 150}) - table.insert(entity_list, {name="stone-rock", pos={pos_x,pos_y},chance = 400}) - table.insert(entity_list, {name="green-coral", pos={pos_x,pos_y},chance = 10000}) - table.insert(entity_list, {name="medium-ship-wreck", pos={pos_x,pos_y},chance = 25000, health="random"}) - table.insert(entity_list, {name="small-ship-wreck", pos={pos_x,pos_y},chance = 25000, health="random"}) - table.insert(entity_list, {name="car", pos={pos_x,pos_y},chance = 125000, health="low"}) - table.insert(entity_list, {name="stone-furnace", pos={pos_x,pos_y},chance = 100000, health="random", force="enemy"}) - local b, placed_entity = place_entities(surface, entity_list) - - if forest_cluster == true then - if math.random(1,800) == 1 then create_tree_cluster(pos, 120) end - end - - else - --if tile.name == "water" then tile_to_insert = "water" end - --if tile.name == "deepwater" then tile_to_insert = "deepwater" end - end - - end + Thread.queue_action("run_swamp_entities", {area = event.area, surface = event.surface, x = x, forest_cluster = forest_cluster}) end - surface.set_tiles(tiles,true) + Thread.queue_action("run_swamp_place_tiles", {surface = event.surface} ) + + Thread.queue_action("run_swamp_cleanup", {area = event.area, surface = event.surface} ) + + Thread.queue_action("run_chart_update", {area = event.area, surface = event.surface} ) +end + +function run_chart_update(params) + if game.forces.player.is_chunk_charted(params.surface, params.area) then + game.forces.player.chart(params.surface, params.area) + end +end + +function run_swamp_cleanup(params) + local area = params.area + local surface = params.surface --check for existing chunk if you would overwrite decoratives local for_start_x = 0 local for_end_x = 31 local for_start_y = 0 local for_end_y = 31 - local testing_pos = event.area.left_top.x - 1 - local tile = surface.get_tile(testing_pos, event.area.left_top.y) + local testing_pos = area.left_top.x - 1 + local tile = surface.get_tile(testing_pos, area.left_top.y) if tile.name then for_start_x = -1 end local testing_pos = event.area.left_top.y - 1 - local tile = surface.get_tile(event.area.left_top.x, testing_pos) + local tile = surface.get_tile(area.left_top.x, testing_pos) if tile.name then for_start_y = -1 end - local testing_pos = event.area.right_bottom.x - local tile = surface.get_tile(testing_pos, event.area.right_bottom.y) + local testing_pos = area.right_bottom.x + local tile = surface.get_tile(testing_pos, area.right_bottom.y) if tile.name then for_end_x = 32 end - local testing_pos = event.area.right_bottom.y - local tile = surface.get_tile(event.area.right_bottom.x, testing_pos) + local testing_pos = area.right_bottom.y + local tile = surface.get_tile(area.right_bottom.x, testing_pos) if tile.name then for_end_y = 32 end for x = for_start_x, for_end_x, 1 do for y = for_start_y, for_end_y, 1 do - local pos_x = event.area.left_top.x + x - local pos_y = event.area.left_top.y + y + local pos_x = area.left_top.x + x + local pos_y = area.left_top.y + y local tile = surface.get_tile(pos_x, pos_y) local decal_has_been_placed = false From 8f2ceaa383e68803df0ae86a3b0b892b2719b38a Mon Sep 17 00:00:00 2001 From: TWLTriston Date: Mon, 23 Oct 2017 07:24:05 -0400 Subject: [PATCH 3/7] Updates to allow threaded to run faster and fixed dagobah to be threaded --- fish_market.lua | 1 + locale/gen_combined/dagobah_swamp.lua | 9 ++++++--- locale/utils/Thread.lua | 16 +++++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/fish_market.lua b/fish_market.lua index ff200052..525bc57f 100644 --- a/fish_market.lua +++ b/fish_market.lua @@ -86,6 +86,7 @@ function spawn_market(cmd) market.add_market_item{price={{"raw-fish", 175}}, offer={type="give-item", item="fast-loader"}} market.add_market_item{price={{"raw-fish", 250}}, offer={type="give-item", item="express-loader"}} market.add_market_item{price={{"raw-fish", 1000}}, offer={type="give-item", item="belt-immunity-equipment"}} + market.add_market_item{price={{"raw-fish", 100}}, offer={type="give-item", item="night-vision-equipment"}} market.add_market_item{price={{"raw-fish", 200}}, offer={type="give-item", item="modular-armor"}} market.add_market_item{price={{"raw-fish", 500}}, offer={type="give-item", item="power-armor"}} market.add_market_item{price={{"raw-fish", 2000}}, offer={type="give-item", item="power-armor-mk2"}} diff --git a/locale/gen_combined/dagobah_swamp.lua b/locale/gen_combined/dagobah_swamp.lua index c7c4f86a..3111a6ab 100644 --- a/locale/gen_combined/dagobah_swamp.lua +++ b/locale/gen_combined/dagobah_swamp.lua @@ -364,7 +364,7 @@ function run_swamp_entities(params) end function run_combined_module(event) - + Thread.set_actions_per_tick(10) -- Generate Rivers if not global.perlin_noise_seed then global.perlin_noise_seed = math.random(1000,1000000) end @@ -398,8 +398,11 @@ function run_combined_module(event) end function run_chart_update(params) - if game.forces.player.is_chunk_charted(params.surface, params.area) then - game.forces.player.chart(params.surface, params.area) + local x = params.area.left_top.x / 32 + local y = params.area.left_top.y / 32 + if game.forces.player.is_chunk_charted(params.surface, {x,y} ) then + -- Don't use full area, otherwise adjacent chunks get charted + game.forces.player.chart(params.surface, {{ params.area.left_top.x, params.area.left_top.y}, { params.area.left_top.x+30, params.area.left_top.y+30} } ) end end diff --git a/locale/utils/Thread.lua b/locale/utils/Thread.lua index ba6eda00..9e326a5c 100644 --- a/locale/utils/Thread.lua +++ b/locale/utils/Thread.lua @@ -18,13 +18,15 @@ end global.callbacks = {} global.next_async_callback_time = -1 - +global.actions_per_tick = 1 local function on_tick() - if global.actions_queue[1] then - local callback = global.actions_queue[1] - pcall(_G[callback.action], callback.params) - table.remove(global.actions_queue, 1) + for action = 1, global.actions_per_tick do + if global.actions_queue[1] then + local callback = global.actions_queue[1] + pcall(_G[callback.action], callback.params) + table.remove(global.actions_queue, 1) + end end if game.tick == global.next_async_callback_time then for index, callback in pairs(global.callbacks) do @@ -41,6 +43,10 @@ local function on_tick() end end +function Thread.set_actions_per_tick(count) + global.actions_per_tick = count +end + function Thread.set_timeout_in_ticks(ticks, callback, params) local time = game.tick + ticks if global.next_async_callback_time == -1 or global.next_async_callback_time > time then From da7226667a12a9c7b219850f78e7f9ecf6256849 Mon Sep 17 00:00:00 2001 From: TWLTriston Date: Wed, 25 Oct 2017 07:11:45 -0400 Subject: [PATCH 4/7] Tweaking and debug for fish income improvements --- fish_market.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/fish_market.lua b/fish_market.lua index 525bc57f..c1474809 100644 --- a/fish_market.lua +++ b/fish_market.lua @@ -172,7 +172,19 @@ local function fish_drop_entity_died(event) if event.entity.force.name == "enemy" then -- global.score_biter_total_kills = global.score_biter_total_kills + 1 -- game.print(global.score_biter_total_kills) - if global.score_biter_total_kills % 150 == 0 then +game.print(serpent.block(event.cause)) +game.print("Type") +game.print(serpent.block(event.entity.type)) +game.print("Player") +game.print(serpent.block(event.player_index)) +game.print("Cause Entity Player") +game.print(serpent.block(event.cause.entity.player_index)) + if event.entity.type == "unit" then + end + if event.entity.type == "unit-spawner" then + + end + if global.score_biter_total_kills % 150 == 0 then local surface = event.entity.surface local x = math.random(1,2) surface.spill_item_stack(event.entity.position, { name = "raw-fish", count = x }, 1) @@ -371,7 +383,15 @@ function fish_built_entity (event) end +function fish_player_crafted_item(event) + local x = math.random(1,5) + if x == 1 then + fish_earned(event, 1) + end +end + Event.register(defines.events.on_preplayer_mined_item, preplayer_mined_item) Event.register(defines.events.on_entity_died, fish_drop_entity_died) Event.register(defines.events.on_market_item_purchased, market_item_purchased) Event.register(defines.events.on_built_entity, fish_built_entity) +Event.register(defines.events.on_player_crafted_item, fish_player_crafted_item) From 328122d265462dd7d9d2cf354aec7391f3fdfd04 Mon Sep 17 00:00:00 2001 From: TWLTriston Date: Wed, 25 Oct 2017 12:45:35 -0400 Subject: [PATCH 5/7] Fish market updates --- fish_market.lua | 103 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 30 deletions(-) diff --git a/fish_market.lua b/fish_market.lua index c1474809..49419de8 100644 --- a/fish_market.lua +++ b/fish_market.lua @@ -89,9 +89,7 @@ function spawn_market(cmd) market.add_market_item{price={{"raw-fish", 100}}, offer={type="give-item", item="night-vision-equipment"}} market.add_market_item{price={{"raw-fish", 200}}, offer={type="give-item", item="modular-armor"}} market.add_market_item{price={{"raw-fish", 500}}, offer={type="give-item", item="power-armor"}} - market.add_market_item{price={{"raw-fish", 2000}}, offer={type="give-item", item="power-armor-mk2"}} market.add_market_item{price={{"raw-fish", 150}}, offer={type="give-item", item="personal-roboport-equipment"}} - market.add_market_item{price={{"raw-fish", 1500}}, offer={type="give-item", item="personal-roboport-mk2-equipment"}} market.add_market_item{price={{"raw-fish", 50}}, offer={type="give-item", item="construction-robot", count=10}} market.add_market_item{price={{"raw-fish", 50}}, offer={type="give-item", item="solar-panel-equipment", count=1}} market.add_market_item{price={{"raw-fish", 50}}, offer={type="give-item", item="battery-equipment", count=1}} @@ -103,7 +101,8 @@ end local fish_market_message = {} -local fish_market_bonus_message = {"Why don’t fish like basketball? Cause they’re afraid of the net", "What do you get when you cross a banker with a fish? A Loan shark!", "How do you make an Octupus laugh? With ten-tickles", "What do you call a fish that needs help with his or her vocals? Autotuna", "What is the difference between a piano and a fish? You can tune a piano but you cannot tuna fish.", "What did the blind man say when he passed the fish market? Good morning ladies.", "Did you hear about the goldfish who went bankrupt? Now he’s a bronze fish.", "What happens when you put nutella on salmon? You get salmonella", "What do you call a fish with no eyes?…Fsh", "What kind of money do fishermen make?…Net profits", "What do you get if you cross a salmon, a bird’s leg and a hand?…Birdsthigh fish fingers", "Why is a fish easy to weigh?…Because it has its own scales", "Why are gold fish orange?…The water makes them rusty", "What was the Tsar of Russia’s favorite fish?…Tsardines", "Why did the dog jump into the sea?…He wanted to chase the catfish", "Which fish dresses the best?…The Swordfish – It always looks sharp", "What do you get if you cross an abbot with a trout?…Monkfish", "What do you call a big fish who makes you an offer you can’t refuse?…The Codfather", "Why is a swordfish’s nose 11 inches long?…If it were 12 inches long it would be a foot", "What do you get if you cross a trout with an apartment?…A flat fish", "Why are fish no good at tennis?…They don’t like to get too close to the net", "How do the fish get to school?…By octobus", "What fish make the best sandwich?…A peanut butter and jellyfish", "Man: Can I have a fly rod and reel for my son?…Fishing Shop Owner: Sorry sir we don’t do trades", "Where do fish keep their money?…In the river bank", "Why do fish like arcade games?…Because they are finball wizards", "What is a mermaid?…A deep-she fish", "What do you get if you cross a whale with rotten fish?…Moby Sick", "Why didn’t the lobster share his toys?…He was too shellfish", "What do fish use to make telephone calls?…a Shell phone", "Why don’t fish make very good tennis balls?…They keep getting caught in the net", "Electric eels and electric rays have enough electricity to kill a horse.", "Most fish have taste buds all over their body.", "Most brands of lipstick contain fish scales.", "A fish does not add new scales as it grows, but the scales it has increase in size. In this way, growth rings are formed and the rings reveal the age of a fish.", "An inflated porcupine fish can reach a diameter of up to 35 inches. It puffs up by swallowing water and then storing it in its stomach.", "Most fish cannot swim backwards. Those that can are mainly members of one of the eel families.", "The fastest fish is the sailfish. It can swim as fast as a car travels on the highway.","Some desert pupfish can live in hot springs that reach temperatures greater than 113° F.","Anableps, four-eyed fish, can see above and below water at the same time.","Catfish have over 27,000 taste buds. Humans have around 7,000.","One hagfish can make enough slime in one minute to fill a bucket.","A female sunfish can lay 300 million eggs each year.", "Fish feel pain and suffer stress just like mammals and birds.", "The Dwarf Seahorse is so slow you can’t see it move", "Some fish are as small as a grain of rice", "There's a species of fish called 'Slippery Dick'", "Herrings communicate through farts.", "One Puffer Fish contains enough poison to kill 30 medium-biters.", "When Anglerfish mate, they melt into each other and share their bodies forever.", "A koi fish named 'Hanako' lived for 225 years."} +local fish_market_bonus_message = {"Why don’t fish like basketball? Cause they’re afraid of the net", "What do you get when you cross a banker with a fish? A Loan shark!", "How do you make an Octupus laugh? With ten-tickles", "What do you call a fish that needs help with his or her vocals? Autotuna", "What is the difference between a piano and a fish? You can tune a piano but you cannot tuna fish.", "What did the blind man say when he passed the fish market? Good morning ladies.", "Did you hear about the goldfish who went bankrupt? Now he’s a bronze fish.", "What happens when you put nutella on salmon? You get salmonella", "What do you call a fish with no eyes?…Fsh", "What kind of money do fishermen make?…Net profits", "What do you get if you cross a salmon, a bird’s leg and a hand?…Birdsthigh fish fingers", "Why is a fish easy to weigh?…Because it has its own scales", "Why are gold fish orange?…The water makes them rusty", "What was the Tsar of Russia’s favorite fish?…Tsardines", "Why did the dog jump into the sea?…He wanted to chase the catfish", "Which fish dresses the best?…The Swordfish – It always looks sharp", "What do you get if you cross an abbot with a trout?…Monkfish", "What do you call a big fish who makes you an offer you can’t refuse?…The Codfather", "Why is a swordfish’s nose 11 inches long?…If it were 12 inches long it would be a foot", "What do you get if you cross a trout with an apartment?…A flat fish", "Why are fish no good at tennis?…They don’t like to get too close to the net", "How do the fish get to school?…By octobus", "What fish make the best sandwich?…A peanut butter and jellyfish", "Man: Can I have a fly rod and reel for my son?…Fishing Shop Owner: Sorry sir we don’t do trades", "Where do fish keep their money?…In the river bank", "Why do fish like arcade games?…Because they are finball wizards", "What is a mermaid?…A deep-she fish", "What do you get if you cross a whale with rotten fish?…Moby Sick", "Why didn’t the lobster share his toys?…He was too shellfish", "What do fish use to make telephone calls?…a Shell phone", "Why don’t fish make very good tennis balls?…They keep getting caught in the net", "Electric eels and electric rays have enough electricity to kill a horse.", "Most fish have taste buds all over their body.", "Most brands of lipstick contain fish scales.", "A fish does not add new scales as it grows, but the scales it has increase in size. In this way, growth rings are formed and the rings reveal the age of a fish.", "An inflated porcupine fish can reach a diameter of up to 35 inches. It puffs up by swallowing water and then storing it in its stomach.", "Most fish cannot swim backwards. Those that can are mainly members of one of the eel families.", "The fastest fish is the sailfish. It can swim as fast as a car travels on the highway.","Some desert pupfish can live in hot springs that reach temperatures greater than 113° F.","Anableps, four-eyed fish, can see above and below water at the same time.","Catfish have over 27,000 taste buds. Humans have around 7,000.","One hagfish can make enough slime in one minute to fill a bucket.","A female sunfish can lay 300 million eggs each year.", "Fish feel pain and suffer stress just like mammals and birds.", "The Dwarf Seahorse is so slow you can’t see it move", "Some fish are as small as a grain of rice", "There's a species of fish called 'Slippery Dick'", "Herrings communicate through farts.", "One Puffer Fish contains enough poison to kill 30 medium-biters.", "When Anglerfish mate, they melt into each other and share their bodies forever.", "A koi fish named 'Hanako' lived for 225 years.", "What did the fish say when he posted bail? I'm off the hook!","There was a sale at the fish market today. I went to see what was the catch.","There are over 25,000 identified species of fish on the earth." +} local total_fish_market_messages = #fish_market_message local total_fish_market_bonus_messages = #fish_market_bonus_message @@ -112,27 +111,29 @@ if not global.fish_market_fish_caught then global.fish_market_fish_caught = {} e if not global.fish_market_fish_spent then global.fish_market_fish_spent = {} end local function fish_earned(event, amount) + fish_earned_index( event.player_index, amount ) +end - local player = game.players[event.player_index] +local function fish_earned_index(player_index, amount) + local player = game.players[player_index] player.insert { name = "raw-fish", count = amount } - if global.fish_market_fish_caught[event.player_index] then - global.fish_market_fish_caught[event.player_index] = global.fish_market_fish_caught[event.player_index] + amount + if global.fish_market_fish_caught[player_index] then + global.fish_market_fish_caught[player_index] = global.fish_market_fish_caught[player_index] + amount else - global.fish_market_fish_caught[event.player_index] = amount + global.fish_market_fish_caught[player_index] = amount end - if global.fish_market_fish_caught[event.player_index] <= total_fish_market_messages then - local x = global.fish_market_fish_caught[event.player_index] + if global.fish_market_fish_caught[player_index] <= total_fish_market_messages then + local x = global.fish_market_fish_caught[player_index] player.print(fish_market_message[x]) end - local x = global.fish_market_fish_caught[event.player_index] % 7 + local x = global.fish_market_fish_caught[player_index] % 7 if x == 0 then local z = math.random(1,total_fish_market_bonus_messages) player.print(fish_market_bonus_message[z]) end - end local function preplayer_mined_item(event) @@ -140,12 +141,14 @@ local function preplayer_mined_item(event) -- game.print(event.entity.name) -- game.print(event.entity.type) +--[[ if event.entity.type == "resource" then local x = math.random(1,2) if x == 1 then fish_earned(event, 1) end end +--]] if event.entity.name == "stone-rock" then fish_earned(event, 10) @@ -168,28 +171,69 @@ local function preplayer_mined_item(event) end local function fish_drop_entity_died(event) + local give_fish_cause = false + local give_fish_unit = false + local fish_amount = 0 + local fish_chance = 0 -- Out of 100 - if event.entity.force.name == "enemy" then --- global.score_biter_total_kills = global.score_biter_total_kills + 1 --- game.print(global.score_biter_total_kills) -game.print(serpent.block(event.cause)) -game.print("Type") -game.print(serpent.block(event.entity.type)) -game.print("Player") -game.print(serpent.block(event.player_index)) -game.print("Cause Entity Player") -game.print(serpent.block(event.cause.entity.player_index)) + if event.entity.force.name == "enemy" then + if event.cause ~= nil then + if event.cause.name == "gun-turret" or event.cause.name == "flamethrower-turret" then + -- WHo's around to get free fish!? + give_fish_cause = true + elseif event.cause.type == "player" then + give_fish_cause = true + end + else + -- Unknown cause? Free fish! Worms have no cause + give_fish_cause = true + end if event.entity.type == "unit" then + fish_amount = 1 + fish_chance = 1 + give_fish_unit = true end if event.entity.type == "unit-spawner" then - + fish_amount = 10 + fish_chance = 100 + give_fish_unit = true end + if event.entity.type == "turret" then + if ( event.entity.name == "small-worm-turret" ) then + fish_amount = 10 + elseif ( event.entity.name == "medium-worm-turret" ) then + fish_amount = 20 + elseif ( event.entity.name == "big-worm-turret" ) then + fish_amount = 30 + end + + fish_chance = 100 + give_fish_unit = true + end + + if give_fish_unit and give_fish_cause then + local x = math.random(1,100) + if x <= fish_chance then + -- Find nearby players +/- 16 blocks of event + local block_size = 64 + area = {{event.entity.position.x - block_size, event.entity.position.y - block_size}, {event.entity.position.x + block_size, event.entity.position.y + block_size}} + player_entities = game.surfaces[1].find_entities_filtered( { area = area, type = "player", force = "player" } ) + + for _,entity in ipairs(player_entities) do + if entity.player.afk_time < 120 then + fish_earned_index(entity.player.index, fish_amount) + end + end + + end + end + if global.score_biter_total_kills % 150 == 0 then - local surface = event.entity.surface - local x = math.random(1,2) - surface.spill_item_stack(event.entity.position, { name = "raw-fish", count = x }, 1) - end - end + local surface = event.entity.surface + local x = math.random(1,2) + surface.spill_item_stack(event.entity.position, { name = "raw-fish", count = x }, 1) + end + end end @@ -363,8 +407,7 @@ function fish_built_entity (event) end -- player_index = event.player_index - - if entity.type == "furnace" then +--[[ if entity.type == "furnace" then local x = math.random(1,5) if x == 1 then fish_earned(event, 5) @@ -380,7 +423,7 @@ function fish_built_entity (event) fish_earned(event, 5) end end - +--]] end function fish_player_crafted_item(event) From 9d73fffd3a08509affedfb6e1298ff8060bb55ce Mon Sep 17 00:00:00 2001 From: TWLTriston Date: Wed, 25 Oct 2017 20:19:42 -0400 Subject: [PATCH 6/7] Fix #102 --- fish_market.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fish_market.lua b/fish_market.lua index 49419de8..0cb600c0 100644 --- a/fish_market.lua +++ b/fish_market.lua @@ -110,10 +110,6 @@ local total_fish_market_bonus_messages = #fish_market_bonus_message if not global.fish_market_fish_caught then global.fish_market_fish_caught = {} end if not global.fish_market_fish_spent then global.fish_market_fish_spent = {} end -local function fish_earned(event, amount) - fish_earned_index( event.player_index, amount ) -end - local function fish_earned_index(player_index, amount) local player = game.players[player_index] player.insert { name = "raw-fish", count = amount } @@ -136,6 +132,10 @@ local function fish_earned_index(player_index, amount) end end +local function fish_earned(event, amount) + fish_earned_index( event.player_index, amount ) +end + local function preplayer_mined_item(event) -- game.print(event.entity.name) From ccf34c51d1855cf2466b5f0d1c03079c24afe0b0 Mon Sep 17 00:00:00 2001 From: TWLTriston Date: Sat, 28 Oct 2017 05:07:41 -0400 Subject: [PATCH 7/7] Final tweaks to RSO based on playtesting --- locale/gen_ores/rso/rso_resource_config.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/gen_ores/rso/rso_resource_config.lua b/locale/gen_ores/rso/rso_resource_config.lua index 40fbcc91..65e10e9a 100644 --- a/locale/gen_ores/rso/rso_resource_config.lua +++ b/locale/gen_ores/rso/rso_resource_config.lua @@ -53,7 +53,7 @@ local function fillVanillaConfig() spawns_per_region={min=1, max=1}, size={min=15, max=25}, - richness=1300, + richness=13000, min_amount=500, starting={richness=6000, size=20, probability=1}, @@ -103,7 +103,7 @@ local function fillVanillaConfig() allotment=70, spawns_per_region={min=1, max=2}, richness={min=240000, max=400000}, -- richness per resource spawn - size={min=2, max=5}, + size={min=5, max=25}, starting={richness=400000, size=3, probability=1},