1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-04-11 11:21:54 +02:00

hunger_games things

This commit is contained in:
MewMew 2019-02-05 08:42:45 +01:00
parent 6b81ee2be7
commit 5992b8cdc1
13 changed files with 1007 additions and 286 deletions

View File

@ -8,7 +8,7 @@ require "antigrief_admin_panel"
require "group"
require "player_list"
require "poll"
require "score"
--require "score"
---- enable modules here ----
--require "maps.tools.map_pregen"
@ -18,13 +18,16 @@ require "score"
--require "maps.modules.rocket_launch_always_yields_science"
--require "maps.modules.launch_fish_to_win"
--require "maps.modules.satellite_score"
--require "maps.modules.dynamic_landfill"
--require "maps.modules.restrictive_fluid_mining"
--require "maps.modules.fluids_are_explosive"
--require "maps.modules.explosives_are_explosive"
--require "maps.modules.explosive_biters"
--require "maps.modules.teleporting_worms"
--require "maps.modules.railgun_enhancer"
--require "maps.modules.dynamic_landfill"
--require "maps.modules.custom_death_messages"
require "maps.hunger_games_map_intro"
require "maps.modules.hunger_games"
require "maps.modules.dynamic_player_spawn"
-----------------------------
---- enable maps here ----
@ -41,9 +44,9 @@ require "score"
--require "maps.anarchy"
--require "maps.railworld"
--require "maps.spaghettorio"
--require "maps.deep_jungle"
require "maps.deep_jungle"
--require "maps.lost_desert"
require "maps.empty_map"
--require "maps.empty_map"
--require "maps.custom_start"
-----------------------------
@ -55,6 +58,20 @@ local function on_player_created(event)
player.gui.left.style = 'slot_table_spacing_vertical_flow'
end
function generate_map(radius)
local surface = game.players[1].surface
if surface.is_chunk_generated({radius, radius}) then
game.print("Map is generated.")
return
end
surface.request_to_generate_chunks({0,0}, radius)
surface.force_generate_chunk_requests()
for _, player in pairs(game.connected_players) do
player.play_sound{path="utility/new_objective", volume_modifier=1}
end
game.print("Map is generated.")
end
function spaghetti()
game.forces["player"].technologies["logistic-system"].enabled = false
game.forces["player"].technologies["construction-robotics"].enabled = false

View File

@ -1,7 +1,7 @@
--anarchy mode map -- by mewmew --
require "maps.anarchy_map_intro"
require "maps.modules.anarchy_mode"
require "maps.hunger_games_map_intro"
require "maps.modules.hunger_games"
require "maps.modules.dynamic_player_spawn"
local simplex_noise = require 'utils.simplex_noise'
@ -27,25 +27,6 @@ local function on_player_joined_game(event)
end
end
local function on_built_entity(event)
local entity = event.created_entity
if not entity.valid then return end
local distance_to_center = math.sqrt(entity.position.x^2 + entity.position.y^2)
if distance_to_center > 96 then return end
local surface = entity.surface
surface.create_entity({name = "flying-text", position = entity.position, text = "Spawn is protected from building.", color = {r=0.88, g=0.1, b=0.1}})
local player = game.players[event.player_index]
player.insert({name = entity.name, count = 1})
if global.score then
if global.score[player.force.name] then
if global.score[player.force.name].players[player.name] then
global.score[player.force.name].players[player.name].built_entities = global.score[player.force.name].players[player.name].built_entities - 1
end
end
end
entity.destroy()
end
local function on_chunk_generated(event)
local surface = event.surface
local left_top = event.area.left_top
@ -95,13 +76,5 @@ local function on_chunk_generated(event)
end
end
local function on_player_respawned(event)
local player = game.players[event.player_index]
player.insert{name = 'iron-axe', count = 1}
player.insert{name = 'iron-plate', count = 32}
end
event.add(defines.events.on_player_respawned, on_player_respawned)
event.add(defines.events.on_built_entity, on_built_entity)
event.add(defines.events.on_player_joined_game, on_player_joined_game)
event.add(defines.events.on_chunk_generated, on_chunk_generated)

View File

@ -1,16 +1,95 @@
--deep jungle-- mewmew made this --
require "maps.modules.fluids_are_explosive"
require "maps.modules.explosives_are_explosive"
require "maps.modules.railgun_enhancer"
require "maps.modules.dynamic_landfill"
require "maps.modules.splice"
require "maps.modules.spawners_contain_biters"
require "maps.modules.biters_yield_coins"
require "maps.modules.rocks_yield_coins"
require "maps.modules.explosive_player_respawn"
local map_functions = require "maps.tools.map_functions"
local simplex_noise = require 'utils.simplex_noise'
simplex_noise = simplex_noise.d2
local event = require 'utils.event'
local math_random = math.random
local function treasure_chest(position)
local p = game.surfaces["deep_jungle"].find_non_colliding_position("wooden-chest",position, 2,0.5)
if not p then return end
local function shuffle(tbl)
local size = #tbl
for i = size, 1, -1 do
local rand = math.random(size)
tbl[i], tbl[rand] = tbl[rand], tbl[i]
end
return tbl
end
local function secret_shop(pos, surface)
local secret_market_items = {
{price = {{"coin", math_random(300,600)}}, offer = {type = 'give-item', item = 'combat-shotgun'}},
{price = {{"coin", math_random(400,600)}}, offer = {type = 'give-item', item = 'rocket-launcher'}},
{price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'piercing-rounds-magazine'}},
--{price = {{"coin", math_random(150,250)}}, offer = {type = 'give-item', item = 'uranium-rounds-magazine'}},
{price = {{"coin", math_random(15,30)}}, offer = {type = 'give-item', item = 'piercing-shotgun-shell'}},
{price = {{"coin", math_random(10,20)}}, offer = {type = 'give-item', item = 'rocket'}},
{price = {{"coin", math_random(20,30)}}, offer = {type = 'give-item', item = 'explosive-rocket'}},
{price = {{"coin", math_random(30,60)}}, offer = {type = 'give-item', item = 'cluster-grenade'}},
{price = {{"coin", math_random(8,16)}}, offer = {type = 'give-item', item = 'land-mine'}},
{price = {{"coin", math_random(200,300)}}, offer = {type = 'give-item', item = 'heavy-armor'}},
{price = {{"coin", math_random(400,800)}}, offer = {type = 'give-item', item = 'modular-armor'}},
{price = {{"coin", math_random(1000,2000)}}, offer = {type = 'give-item', item = 'power-armor'}},
{price = {{"coin", math_random(2500,5000)}}, offer = {type = 'give-item', item = 'fusion-reactor-equipment'}},
{price = {{"coin", math_random(200,400)}}, offer = {type = 'give-item', item = 'battery-equipment'}},
{price = {{"coin", math_random(150,250)}}, offer = {type = 'give-item', item = 'belt-immunity-equipment'}},
{price = {{"coin", math_random(100,200)}}, offer = {type = 'give-item', item = 'night-vision-equipment'}},
{price = {{"coin", math_random(400,800)}}, offer = {type = 'give-item', item = 'exoskeleton-equipment'}},
{price = {{"coin", math_random(200,300)}}, offer = {type = 'give-item', item = 'personal-roboport-equipment'}},
{price = {{"coin", math_random(25,50)}}, offer = {type = 'give-item', item = 'construction-robot'}},
-- {price = {{"coin", math_random(10000,20000)}}, offer = {type = 'give-item', item = 'energy-shield-equipment'}},
-- {price = {{"coin", math_random(5000,15000)}}, offer = {type = 'give-item', item = 'personal-laser-defense-equipment'}},
{price = {{"coin", math_random(1000,2000)}}, offer = {type = 'give-item', item = 'railgun'}},
{price = {{"coin", math_random(60,120)}}, offer = {type = 'give-item', item = 'railgun-dart', count = 1}},
{price = {{"coin", math_random(100,300)}}, offer = {type = 'give-item', item = 'loader'}},
{price = {{"coin", math_random(200,400)}}, offer = {type = 'give-item', item = 'fast-loader'}},
{price = {{"coin", math_random(300,500)}}, offer = {type = 'give-item', item = 'express-loader'}},
{price = {{"coin", math_random(150,300)}}, offer = {type = 'give-item', item = 'locomotive'}},
{price = {{"coin", math_random(100,200)}}, offer = {type = 'give-item', item = 'cargo-wagon'}},
{price = {{"coin", math_random(5,15)}}, offer = {type = 'give-item', item = 'grenade'}},
{price = {{"coin", math_random(4,8)}}, offer = {type = 'give-item', item = 'rail', count = 4}},
{price = {{"coin", math_random(20,30)}}, offer = {type = 'give-item', item = 'train-stop'}},
{price = {{"coin", math_random(4,12)}}, offer = {type = 'give-item', item = 'small-lamp'}},
{price = {{"coin", math_random(1,4)}}, offer = {type = 'give-item', item = 'firearm-magazine'}},
{price = {{"coin", math_random(60,150)}}, offer = {type = 'give-item', item = 'car', count = 1}},
{price = {{"coin", math_random(75,150)}}, offer = {type = 'give-item', item = 'gun-turret', count = 1}},
{price = {{"coin", math_random(500,750)}}, offer = {type = 'give-item', item = 'laser-turret', count = 1}},
{price = {{"coin", math_random(1000,2000)}}, offer = {type = 'give-item', item = 'artillery-turret', count = 1}},
{price = {{"coin", math_random(100,200)}}, offer = {type = 'give-item', item = 'artillery-shell', count = 1}},
{price = {{"coin", math_random(50,150)}}, offer = {type = 'give-item', item = 'artillery-targeting-remote', count = 1}},
{price = {{"coin", math_random(5,15)}}, offer = {type = 'give-item', item = 'shotgun-shell', count = 1}},
{price = {{"coin", math_random(8000,16000)}}, offer = {type = 'give-item', item = 'power-armor-mk2', count = 1}},
{price = {{"coin", math_random(80,160)}}, offer = {type = 'give-item', item = 'solar-panel-equipment', count = 1}},
{price = {{"coin", math_random(4,8)}}, offer = {type = 'give-item', item = 'raw-wood', count = 50}},
{price = {{"coin", math_random(4,8)}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}},
{price = {{"coin", math_random(4,8)}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}},
{price = {{"coin", math_random(4,8)}}, offer = {type = 'give-item', item = 'stone', count = 50}},
{price = {{"coin", math_random(4,8)}}, offer = {type = 'give-item', item = 'coal', count = 50}}
--{price = {{"coin", math_random(4,8)}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}
}
secret_market_items = shuffle(secret_market_items)
local market = surface.create_entity {name = "market", position = pos}
market.destructible = false
for i = 1, math.random(6, 10), 1 do
market.add_market_item(secret_market_items[i])
end
end
local function treasure_chest(position)
if not game.surfaces["deep_jungle"].can_place_entity({name="steel-chest",position=position, force="player"}) then return end
treasure_chest_raffle_table = {}
treasure_chest_loot_weights = {}
table.insert(treasure_chest_loot_weights, {{name = 'landfill', count = math_random(16,32)},20})
table.insert(treasure_chest_loot_weights, {{name = 'iron-gear-wheel', count = math_random(16,48)},10})
table.insert(treasure_chest_loot_weights, {{name = 'coal', count = math_random(16,48)},2})
table.insert(treasure_chest_loot_weights, {{name = 'copper-cable', count = math_random(64,128)},10})
@ -28,23 +107,19 @@ local function treasure_chest(position)
table.insert(treasure_chest_loot_weights, {{name = 'iron-stick', count = math_random(1,100)},8})
table.insert(treasure_chest_loot_weights, {{name = "small-electric-pole", count = math_random(8,32)},9})
table.insert(treasure_chest_loot_weights, {{name = "firearm-magazine", count = math_random(16,48)},8})
table.insert(treasure_chest_loot_weights, {{name = 'grenade', count = math_random(16,32)},5})
table.insert(treasure_chest_loot_weights, {{name = 'land-mine', count = math_random(24,48)},5})
table.insert(treasure_chest_loot_weights, {{name = 'grenade', count = math_random(8,16)},5})
table.insert(treasure_chest_loot_weights, {{name = 'land-mine', count = math_random(8,16)},5})
table.insert(treasure_chest_loot_weights, {{name = 'light-armor', count = 1},1})
table.insert(treasure_chest_loot_weights, {{name = 'heavy-armor', count = 1},2})
table.insert(treasure_chest_loot_weights, {{name = 'pipe', count = math_random(10,100)},6})
table.insert(treasure_chest_loot_weights, {{name = 'wooden-chest', count = 1},1})
table.insert(treasure_chest_loot_weights, {{name = 'burner-mining-drill', count = 1},1})
table.insert(treasure_chest_loot_weights, {{name = 'iron-axe', count = 1},1})
table.insert(treasure_chest_loot_weights, {{name = 'steel-axe', count = 1},3})
table.insert(treasure_chest_loot_weights, {{name = 'raw-wood', count = math_random(5,50)},2})
table.insert(treasure_chest_loot_weights, {{name = 'sulfur', count = math_random(20,50)},7})
table.insert(treasure_chest_loot_weights, {{name = 'explosives', count = math_random(20,50)},6})
table.insert(treasure_chest_loot_weights, {{name = 'explosives', count = math_random(40,50)},6})
table.insert(treasure_chest_loot_weights, {{name = 'shotgun', count = 1},2})
table.insert(treasure_chest_loot_weights, {{name = 'stone-brick', count = math_random(80,100)},4})
table.insert(treasure_chest_loot_weights, {{name = 'small-lamp', count = math_random(3,10)},4})
table.insert(treasure_chest_loot_weights, {{name = 'rail', count = math_random(32,100)},4})
table.insert(treasure_chest_loot_weights, {{name = 'coin', count = math_random(32,100)},1})
table.insert(treasure_chest_loot_weights, {{name = 'coin', count = math_random(32,320)},1})
table.insert(treasure_chest_loot_weights, {{name = 'assembling-machine-1', count = math_random(1,4)},2})
table.insert(treasure_chest_loot_weights, {{name = 'assembling-machine-2', count = math_random(1,3)},2})
table.insert(treasure_chest_loot_weights, {{name = 'assembling-machine-3', count = math_random(1,2)},1})
@ -54,8 +129,7 @@ local function treasure_chest(position)
end
end
local e = game.surfaces["deep_jungle"].create_entity {name="wooden-chest",position=p, force="player"}
local e = game.surfaces["deep_jungle"].create_entity {name="wooden-chest",position=position, force="player"}
e.minable = false
local i = e.get_inventory(defines.inventory.chest)
for x = 1, math_random(3,7), 1 do
@ -65,34 +139,30 @@ local function treasure_chest(position)
end
local function rare_treasure_chest(position)
local p = game.surfaces["deep_jungle"].find_non_colliding_position("steel-chest",position, 2,0.5)
if not p then return end
if not game.surfaces["deep_jungle"].can_place_entity({name="steel-chest",position=position, force="player"}) then return end
local rare_treasure_chest_raffle_table = {}
local rare_treasure_chest_loot_weights = {}
table.insert(rare_treasure_chest_loot_weights, {{name = 'combat-shotgun', count = 1},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'piercing-shotgun-shell', count = math_random(16,48)},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'piercing-shotgun-shell', count = math_random(8,16)},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'rocket-launcher', count = 1},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'rocket', count = math_random(16,48)},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'explosive-rocket', count = math_random(16,48)},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'rocket', count = math_random(8,16)},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'explosive-rocket', count = math_random(8,16)},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'modular-armor', count = 1},3})
table.insert(rare_treasure_chest_loot_weights, {{name = 'power-armor', count = 1},1})
table.insert(rare_treasure_chest_loot_weights, {{name = 'uranium-rounds-magazine', count = math_random(16,48)},3})
table.insert(rare_treasure_chest_loot_weights, {{name = 'piercing-rounds-magazine', count = math_random(64,128)},3})
table.insert(rare_treasure_chest_loot_weights, {{name = 'power-armor', count = 1},1})
table.insert(rare_treasure_chest_loot_weights, {{name = 'piercing-rounds-magazine', count = math_random(32,64)},3})
table.insert(rare_treasure_chest_loot_weights, {{name = 'railgun', count = 1},4})
table.insert(rare_treasure_chest_loot_weights, {{name = 'railgun-dart', count = math_random(16,48)},4})
table.insert(rare_treasure_chest_loot_weights, {{name = 'railgun-dart', count = math_random(4,8)},4})
table.insert(rare_treasure_chest_loot_weights, {{name = 'exoskeleton-equipment', count = 1},2})
table.insert(rare_treasure_chest_loot_weights, {{name = 'defender-capsule', count = math_random(8,16)},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'distractor-capsule', count = math_random(4,8)},4})
table.insert(rare_treasure_chest_loot_weights, {{name = 'destroyer-capsule', count = math_random(4,8)},3})
table.insert(rare_treasure_chest_loot_weights, {{name = 'atomic-bomb', count = 1},1})
table.insert(rare_treasure_chest_loot_weights, {{name = 'defender-capsule', count = math_random(6,12)},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'distractor-capsule', count = math_random(3,6)},4})
table.insert(rare_treasure_chest_loot_weights, {{name = 'destroyer-capsule', count = math_random(2,4)},3})
for _, t in pairs (rare_treasure_chest_loot_weights) do
for x = 1, t[2], 1 do
table.insert(rare_treasure_chest_raffle_table, t[1])
end
end
local e = game.surfaces["deep_jungle"].create_entity {name="steel-chest",position=p, force="player"}
local e = game.surfaces["deep_jungle"].create_entity {name="steel-chest",position=position, force="player"}
e.minable = false
local i = e.get_inventory(defines.inventory.chest)
for x = 1, math_random(2,3), 1 do
@ -104,66 +174,72 @@ end
local function get_noise(name, pos)
local seed = game.surfaces[1].map_gen_settings.seed
local noise_seed_add = 25000
seed = seed + noise_seed_add
if name == 1 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.1, pos.y * 0.1, seed)
local noise = noise[1] + noise[2] * 0.1
return noise
end
seed = seed + noise_seed_add
seed = seed + noise_seed_add
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.1, pos.y * 0.1, seed)
local noise = noise[1] + noise[2] * 0.1
return noise
end
seed = seed + noise_seed_add
seed = seed + noise_seed_add
if name == 3 then
local noise = {}
noise[1] = simplex_noise(pos.x * 0.001, pos.y * 0.001, seed)
seed = seed + noise_seed_add
noise[2] = simplex_noise(pos.x * 0.01, pos.y * 0.01, seed)
noise[2] = simplex_noise(pos.x * 0.01, pos.y * 0.01, seed + noise_seed_add)
local noise = noise[1] + noise[2] * 0.1
return noise
end
seed = seed + noise_seed_add
seed = seed + noise_seed_add
if name == 4 then
end
if name == 2 then
local noise = {}
noise[1] = simplex_noise(pos.x * 0.01, pos.y * 0.01, seed)
noise[1] = simplex_noise(pos.x * 0.015, pos.y * 0.015, seed)
seed = seed + noise_seed_add
noise[2] = simplex_noise(pos.x * 0.1, pos.y * 0.1, seed)
noise[2] = simplex_noise(pos.x * 0.15, pos.y * 0.15, seed + noise_seed_add)
local noise = noise[1] + noise[2] * 0.2
return noise
end
seed = seed + noise_seed_add
seed = seed + noise_seed_add
if name == 5 then
if name == 3 then
local noise = {}
noise[1] = simplex_noise(pos.x * 0.05, pos.y * 0.05, seed)
local noise = noise[1]
noise[1] = simplex_noise(pos.x * 0.025, pos.y * 0.025, seed)
seed = seed + noise_seed_add
noise[2] = simplex_noise(pos.x * 0.2, pos.y * 0.2, seed + noise_seed_add)
local noise = noise[1] + noise[2] * 0.2
return noise
end
seed = seed + noise_seed_add
seed = seed + noise_seed_add
if name == 6 then
if name == "greenwater" then
local noise = {}
noise[1] = simplex_noise(pos.x * 0.05, pos.y * 0.05, seed)
local noise = noise[1]
noise[1] = simplex_noise(pos.x * 0.003, pos.y * 0.003, seed)
seed = seed + noise_seed_add
noise[2] = simplex_noise(pos.x * 0.03, pos.y * 0.03, seed + noise_seed_add)
local noise = noise[1] + noise[2] * 0.1
return noise
end
end
local worm_raffle = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret"}
local rock_raffle = {"sand-rock-big","sand-rock-big","rock-big","rock-big","rock-big","rock-big","rock-huge"}
local function process_tile(pos)
local noise_1 = get_noise(1, pos)
if noise_1 > -0.03 and noise_1 < 0.03 then
return "deepwater"
end
if noise_1 > -0.05 and noise_1 < 0.05 then
return "water"
end
local noise_greenwater = get_noise("greenwater", pos)
if noise_greenwater > -0.035 and noise_greenwater < 0.035 then
return "water-green"
end
if noise_1 > -0.08 and noise_1 < 0.08 then
return false
end
local noise_2 = get_noise(2, pos)
if noise_2 > 0.37 or noise_2 < -0.37 then
local tree_raffle = {"tree-04", "tree-07", "tree-09", "tree-06", "tree-04", "tree-07", "tree-09", "tree-04"}
if math_random(1, 4) == 1 then return false, tree_raffle[math.ceil(math.abs(noise_1 * 8))] end
end
local noise_3 = get_noise(3, pos)
if noise_3 > 0.5 then
if math_random(1,3) == 1 then return false, rock_raffle[math_random(1,#rock_raffle)] end
end
return false
end
local function on_chunk_generated(event)
local surface = game.surfaces["deep_jungle"]
if event.surface.name ~= surface.name then return end
@ -172,168 +248,87 @@ local function on_chunk_generated(event)
local chunk_pos_y = event.area.left_top.y
local tiles = {}
local entities_to_place = {
rocks = {},
worms = {},
enemy_buildings = {},
trees = {},
fish = {},
treasure_chests = {},
rare_treasure_chests = {}
}
local decoratives = {}
local entities = surface.find_entities(event.area)
for _, e in pairs(entities) do
if e.type == "tree" or e.force.name == "enemy" then
e.destroy()
end
end
local entities_to_place = {}
local treasure_chests = {}
local rare_treasure_chests = {}
local secret_shops = {}
local tile_to_insert = false
for x = 0, 31, 1 do
for y = 0, 31, 1 do
local pos_x = chunk_pos_x + x
local pos_y = chunk_pos_y + y
local pos = {x = pos_x, y = pos_y}
tile_to_insert = false
local pos = {x = chunk_pos_x + x, y = chunk_pos_y + y}
local noise_3 = get_noise(3, pos)
if noise_3 > -0.1 and noise_3 < 0.1 then
if noise_3 > -0.05 and noise_3 < 0.05 then
tile_to_insert = "water"
if math_random(1,40) == 1 then table.insert(entities_to_place.fish, pos) end
end
if noise_3 > -0.03 and noise_3 < 0.03 then
tile_to_insert = "deepwater"
if math_random(1,40) == 1 then table.insert(entities_to_place.fish, pos) end
end
else
local tile_distance_to_center = pos_x^2 + pos_y^2
local noise_1 = get_noise(1, pos)
local noise_2 = get_noise(2, pos)
local noise_4 = get_noise(4, pos)
if tile_distance_to_center > 10000 then
if math_random(1,500) == 1 then table.insert(entities_to_place.worms, pos) end
if noise_4 > -0.1 and noise_4 < 0.1 and noise_1 > 0.3 and noise_2 > 0.3 then
if math_random(1,8) == 1 then table.insert(entities_to_place.rocks, pos) end
end
end
if noise_4 < -0.8 or noise_4 > 0.8 then tile_to_insert = "dirt-6" end
if noise_3 < -0.1 then
if noise_1 > 0.2 then
if math_random(1,4) == 1 then table.insert(entities_to_place.trees, {"tree-02", pos}) end
if math_random(1,7500) == 1 then table.insert(entities_to_place.rare_treasure_chests, pos) end
if math_random(1,1250) == 1 then table.insert(entities_to_place.treasure_chests, pos) end
if noise_1 > 0.8 and tile_distance_to_center > 8000 then
tile_to_insert = "water-green"
if math_random(1,24) == 1 then table.insert(entities_to_place.fish, pos) end
end
end
if noise_1 < -0.2 then
if math_random(1,4) == 1 then table.insert(entities_to_place.trees, {"tree-04", pos}) end
if math_random(1,7500) == 1 then table.insert(entities_to_place.rare_treasure_chests, pos) end
if math_random(1,1250) == 1 then table.insert(entities_to_place.treasure_chests, pos) end
if noise_1 < -0.75 and tile_distance_to_center > 8000 then
if math_random(1,36) == 1 then table.insert(entities_to_place.enemy_buildings, pos) end
end
end
else
if noise_2 > 0.2 then
if math_random(1,4) == 1 then table.insert(entities_to_place.trees, {"tree-07", pos}) end
if math_random(1,7500) == 1 then table.insert(entities_to_place.rare_treasure_chests, pos) end
if math_random(1,1250) == 1 then table.insert(entities_to_place.treasure_chests, pos) end
if noise_2 > 0.75 and tile_distance_to_center > 8000 then
if math_random(1,36) == 1 then table.insert(entities_to_place.enemy_buildings, pos) end
end
end
if noise_2 < -0.2 then
if math_random(1,4) == 1 then table.insert(entities_to_place.trees, {"tree-09", pos}) end
if math_random(1,7500) == 1 then table.insert(entities_to_place.rare_treasure_chests, pos) end
if math_random(1,1250) == 1 then table.insert(entities_to_place.treasure_chests, pos) end
if noise_2 < -0.8 and tile_distance_to_center > 8000 then
tile_to_insert = "water-green"
if math_random(1,24) == 1 then table.insert(entities_to_place.fish, pos) end
end
end
end
end
if tile_to_insert ~= "deepwater" and tile_to_insert ~= "water" and tile_to_insert ~= "water-green" then
if math_random(1,3) == 1 then
local noise = get_noise(5, pos)
if noise > 0.2 then
table.insert(decoratives, {name = "green-hairy-grass", position = pos, amount = 2})
end
if noise < -0.7 then
table.insert(decoratives, {name = "green-pita", position = pos, amount = 2})
end
local noise = get_noise(6, pos)
if noise > 0.7 then
table.insert(decoratives, {name = "green-croton", position = pos, amount = 3})
end
if noise < -0.2 then
table.insert(decoratives, {name = "green-asterisk", position = pos, amount = 2})
end
end
tile_to_insert, entity_to_place = process_tile(pos)
if entity_to_place then
table.insert(entities_to_place, {name = entity_to_place, position = pos, force = "player"})
end
if tile_to_insert == false then
table.insert(tiles, {name = "grass-1", position = {pos_x,pos_y}})
else
table.insert(tiles, {name = tile_to_insert, position = {pos_x,pos_y}})
end
end
end
surface.set_tiles(tiles,true)
surface.create_decoratives{check_collision=false, decoratives=decoratives}
for _, p in pairs(entities_to_place.enemy_buildings) do
if math_random(1,3) == 1 then
if surface.can_place_entity({name="spitter-spawner", position=p}) then surface.create_entity {name="spitter-spawner", position=p} end
else
if surface.can_place_entity({name="biter-spawner", position=p}) then surface.create_entity {name="biter-spawner", position=p} end
if tile_to_insert then
table.insert(tiles, {name = tile_to_insert, position = pos})
if math_random(1,40) == 1 and tile_to_insert == "deepwater" then surface.create_entity({name = "fish", position = pos}) end
end
if math_random(1,1250) == 1 then table.insert(treasure_chests, pos) end
if math_random(1,7500) == 1 then table.insert(rare_treasure_chests, pos) end
if math_random(1,8000) == 1 then table.insert(secret_shops, pos) end
end
end
for _, p in pairs(entities_to_place.worms) do
local e = worm_raffle[math_random(1,#worm_raffle)]
if surface.can_place_entity({name=e, position=p}) then surface.create_entity {name=e, position=p} end
surface.set_tiles(tiles,true)
for _, e in pairs(entities_to_place) do
if not surface.get_tile(e.position).collides_with("player-layer") then
surface.create_entity(e)
end
end
for _, p in pairs(treasure_chests) do
treasure_chest(p)
end
for _, p in pairs(rare_treasure_chests) do
rare_treasure_chest(p)
end
for _, p in pairs(entities_to_place.rocks) do
local e = rock_raffle[math_random(1,#rock_raffle)]
surface.create_entity {name=e, position=p}
for _, p in pairs(secret_shops) do
if not surface.get_tile(p).collides_with("player-layer") then
local area = {{p.x - 128, p.y - 128}, {p.x + 128, p.y + 128}}
if surface.count_entities_filtered({name = "market", area = area}) == 0 then
secret_shop(p, surface)
end
end
end
for _, p in pairs(entities_to_place.trees) do
if surface.can_place_entity({name=p[1], position=p[2]}) then surface.create_entity {name=p[1], position=p[2]} end
end
for _, p in pairs(entities_to_place.treasure_chests) do
treasure_chest(p)
end
local function on_chunk_charted(event)
if not global.chunks_charted then global.chunks_charted = {} end
local surface = game.surfaces[event.surface_index]
local position = event.position
if global.chunks_charted[tostring(position.x) .. tostring(position.y)] then return end
global.chunks_charted[tostring(position.x) .. tostring(position.y)] = true
local decorative_names = {}
for k,v in pairs(game.decorative_prototypes) do
if v.autoplace_specification then
decorative_names[#decorative_names+1] = k
end
end
for _, p in pairs(entities_to_place.rare_treasure_chests) do
rare_treasure_chest(p)
end
for _, p in pairs(entities_to_place.fish) do
surface.create_entity {name="fish",position=p}
end
surface.regenerate_decorative(decorative_names, {position})
if math_random(1,10) ~= 1 then return end
map_functions.draw_rainbow_patch({x = position.x * 32 + math_random(1,32), y = position.y * 32 + math_random(1,32)}, surface, math_random(14,26), 2000)
end
local function on_player_joined_game(event)
local player = game.players[event.player_index]
if not global.map_init_done then
game.forces["player"].technologies["flamethrower"].enabled = false
if not global.map_init_done then
local map_gen_settings = {}
map_gen_settings.water = "none"
map_gen_settings.cliff_settings = {cliff_elevation_interval = 4, cliff_elevation_0 = 0.1}
map_gen_settings.autoplace_controls = {
["coal"] = {frequency = "high", size = "big", richness = "normal"},
["stone"] = {frequency = "high", size = "big", richness = "normal"},
["copper-ore"] = {frequency = "high", size = "big", richness = "normal"},
["iron-ore"] = {frequency = "high", size = "big", richness = "normal"},
["crude-oil"] = {frequency = "high", size = "big", richness = "normal"},
["coal"] = {frequency = "none", size = "none", richness = "none"},
["stone"] = {frequency = "none", size = "none", richness = "none"},
["copper-ore"] = {frequency = "none", size = "none", richness = "none"},
["iron-ore"] = {frequency = "none", size = "none", richness = "none"},
["crude-oil"] = {frequency = "very-high", size = "big", richness = "normal"},
["trees"] = {frequency = "none", size = "none", richness = "none"},
["enemy-base"] = {frequency = "none", size = "none", richness = "none"},
["enemy-base"] = {frequency = "normal", size = "normal", richness = "normal"},
--["grass"] = {frequency = "none", size = "none", richness = "none"},
["sand"] = {frequency = "none", size = "none", richness = "none"},
["desert"] = {frequency = "none", size = "none", richness = "none"},
@ -352,13 +347,10 @@ local function on_player_joined_game(event)
player.teleport({0,0}, "deep_jungle")
end
end
if player.online_time < 10 then
player.insert {name = 'submachine-gun', count = 1}
player.insert {name = 'raw-fish', count = 12}
player.insert {name = 'firearm-magazine', count = 32}
player.insert {name = 'steel-axe', count = 1}
player.insert {name = 'light-armor', count = 1}
end
if player.online_time < 2 then
player.insert {name = 'iron-axe', count = 1}
player.insert {name = 'iron-plate', count = 32}
end
end
local function on_marked_for_deconstruction(event)
@ -368,36 +360,47 @@ local function on_marked_for_deconstruction(event)
end
local function on_entity_died(event)
if event.entity.type == "tree" then
if math_random(1,6) == 1 then
local surface = game.surfaces["deep_jungle"]
local surface = event.entity.surface
if event.entity.type == "tree" then
if math_random(1,4) == 1 then
local p = surface.find_non_colliding_position("small-biter" , event.entity.position, 2, 0.5)
if p then surface.create_entity {name="small-biter", position=event.entity.position} end
return
end
if math_random(1,8) == 1 then
local p = surface.find_non_colliding_position("medium-biter" , event.entity.position, 2, 0.5)
if p then surface.create_entity {name="medium-biter", position=event.entity.position} end
return
end
if math_random(1,16) == 1 then
local p = surface.find_non_colliding_position("big-biter" , event.entity.position, 2, 0.5)
if p then surface.create_entity {name="big-biter", position=event.entity.position} end
return
end
if math_random(1,256) == 1 then
local p = surface.find_non_colliding_position("behemoth-biter" , event.entity.position, 2, 0.5)
if p then surface.create_entity {name="behemoth-biter", position=event.entity.position} end
return
end
end
end
function cheat_mode()
local cheat_mode_enabed = true
if cheat_mode_enabed == true then
local surface = game.surfaces["deep_jungle"]
game.player.cheat_mode=true
game.players[1].insert({name="power-armor-mk2"})
game.players[1].insert({name="fusion-reactor-equipment", count=4})
game.players[1].insert({name="personal-laser-defense-equipment", count=8})
game.players[1].insert({name="rocket-launcher"})
game.players[1].insert({name="explosive-rocket", count=200})
game.speed = 2
surface.daytime = 1
game.player.force.research_all_technologies()
game.forces["enemy"].evolution_factor = 0.2
local chart = 300
local surface = game.surfaces["deep_jungle"]
game.forces["player"].chart(surface, {lefttop = {x = chart*-1, y = chart*-1}, rightbottom = {x = chart, y = chart}})
if event.entity.type == "simple-entity" then
if math_random(1,4) == 1 then
surface.create_entity {name="small-worm-turret", position=event.entity.position}
return
end
if math_random(1,8) == 1 then
surface.create_entity {name="medium-worm-turret", position=event.entity.position}
return
end
if math_random(1,16) == 1 then
surface.create_entity {name="big-worm-turret", position=event.entity.position}
return
end
end
end
event.add(defines.events.on_chunk_generated, on_chunk_generated)
event.add(defines.events.on_chunk_charted, on_chunk_charted)
event.add(defines.events.on_entity_died, on_entity_died)
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
event.add(defines.events.on_player_joined_game, on_player_joined_game)

415
maps/deep_jungle_old.lua Normal file
View File

@ -0,0 +1,415 @@
--deep jungle-- mewmew made this --
local map_functions = require "maps.tools.map_functions"
local simplex_noise = require 'utils.simplex_noise'
simplex_noise = simplex_noise.d2
local event = require 'utils.event'
local math_random = math.random
local function treasure_chest(position)
local p = game.surfaces["deep_jungle"].find_non_colliding_position("wooden-chest",position, 2,0.5)
if not p then return end
treasure_chest_raffle_table = {}
treasure_chest_loot_weights = {}
table.insert(treasure_chest_loot_weights, {{name = 'iron-gear-wheel', count = math_random(16,48)},10})
table.insert(treasure_chest_loot_weights, {{name = 'coal', count = math_random(16,48)},2})
table.insert(treasure_chest_loot_weights, {{name = 'copper-cable', count = math_random(64,128)},10})
table.insert(treasure_chest_loot_weights, {{name = 'inserter', count = math_random(8,16)},4})
table.insert(treasure_chest_loot_weights, {{name = 'fast-inserter', count = math_random(4,8)},3})
table.insert(treasure_chest_loot_weights, {{name = 'stack-filter-inserter', count = math_random(2,4)},1})
table.insert(treasure_chest_loot_weights, {{name = 'stack-inserter', count = math_random(2,4)},1})
table.insert(treasure_chest_loot_weights, {{name = 'burner-inserter', count = math_random(16,32)},6})
table.insert(treasure_chest_loot_weights, {{name = 'electric-engine-unit', count = math_random(1,16)},3})
table.insert(treasure_chest_loot_weights, {{name = 'engine-unit', count = math_random(1,16)},3})
table.insert(treasure_chest_loot_weights, {{name = 'rocket-fuel', count = math_random(1,5)},3})
table.insert(treasure_chest_loot_weights, {{name = 'empty-barrel', count = math_random(1,10)},7})
table.insert(treasure_chest_loot_weights, {{name = 'lubricant-barrel', count = math_random(1,10)},3})
table.insert(treasure_chest_loot_weights, {{name = 'crude-oil-barrel', count = math_random(1,10)},3})
table.insert(treasure_chest_loot_weights, {{name = 'iron-stick', count = math_random(1,100)},8})
table.insert(treasure_chest_loot_weights, {{name = "small-electric-pole", count = math_random(8,32)},9})
table.insert(treasure_chest_loot_weights, {{name = "firearm-magazine", count = math_random(16,48)},8})
table.insert(treasure_chest_loot_weights, {{name = 'grenade', count = math_random(16,32)},5})
table.insert(treasure_chest_loot_weights, {{name = 'land-mine', count = math_random(24,48)},5})
table.insert(treasure_chest_loot_weights, {{name = 'light-armor', count = 1},1})
table.insert(treasure_chest_loot_weights, {{name = 'heavy-armor', count = 1},2})
table.insert(treasure_chest_loot_weights, {{name = 'pipe', count = math_random(10,100)},6})
table.insert(treasure_chest_loot_weights, {{name = 'wooden-chest', count = 1},1})
table.insert(treasure_chest_loot_weights, {{name = 'burner-mining-drill', count = 1},1})
table.insert(treasure_chest_loot_weights, {{name = 'iron-axe', count = 1},1})
table.insert(treasure_chest_loot_weights, {{name = 'steel-axe', count = 1},3})
table.insert(treasure_chest_loot_weights, {{name = 'raw-wood', count = math_random(5,50)},2})
table.insert(treasure_chest_loot_weights, {{name = 'sulfur', count = math_random(20,50)},7})
table.insert(treasure_chest_loot_weights, {{name = 'explosives', count = math_random(20,50)},6})
table.insert(treasure_chest_loot_weights, {{name = 'shotgun', count = 1},2})
table.insert(treasure_chest_loot_weights, {{name = 'stone-brick', count = math_random(80,100)},4})
table.insert(treasure_chest_loot_weights, {{name = 'small-lamp', count = math_random(3,10)},4})
table.insert(treasure_chest_loot_weights, {{name = 'rail', count = math_random(32,100)},4})
table.insert(treasure_chest_loot_weights, {{name = 'coin', count = math_random(32,100)},1})
table.insert(treasure_chest_loot_weights, {{name = 'assembling-machine-1', count = math_random(1,4)},2})
table.insert(treasure_chest_loot_weights, {{name = 'assembling-machine-2', count = math_random(1,3)},2})
table.insert(treasure_chest_loot_weights, {{name = 'assembling-machine-3', count = math_random(1,2)},1})
for _, t in pairs (treasure_chest_loot_weights) do
for x = 1, t[2], 1 do
table.insert(treasure_chest_raffle_table, t[1])
end
end
local e = game.surfaces["deep_jungle"].create_entity {name="wooden-chest",position=p, force="player"}
e.minable = false
local i = e.get_inventory(defines.inventory.chest)
for x = 1, math_random(3,7), 1 do
local loot = treasure_chest_raffle_table[math_random(1,#treasure_chest_raffle_table)]
i.insert(loot)
end
end
local function rare_treasure_chest(position)
local p = game.surfaces["deep_jungle"].find_non_colliding_position("steel-chest",position, 2,0.5)
if not p then return end
local rare_treasure_chest_raffle_table = {}
local rare_treasure_chest_loot_weights = {}
table.insert(rare_treasure_chest_loot_weights, {{name = 'combat-shotgun', count = 1},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'piercing-shotgun-shell', count = math_random(16,48)},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'rocket-launcher', count = 1},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'rocket', count = math_random(16,48)},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'explosive-rocket', count = math_random(16,48)},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'modular-armor', count = 1},3})
table.insert(rare_treasure_chest_loot_weights, {{name = 'power-armor', count = 1},1})
table.insert(rare_treasure_chest_loot_weights, {{name = 'uranium-rounds-magazine', count = math_random(16,48)},3})
table.insert(rare_treasure_chest_loot_weights, {{name = 'piercing-rounds-magazine', count = math_random(64,128)},3})
table.insert(rare_treasure_chest_loot_weights, {{name = 'railgun', count = 1},4})
table.insert(rare_treasure_chest_loot_weights, {{name = 'railgun-dart', count = math_random(16,48)},4})
table.insert(rare_treasure_chest_loot_weights, {{name = 'exoskeleton-equipment', count = 1},2})
table.insert(rare_treasure_chest_loot_weights, {{name = 'defender-capsule', count = math_random(8,16)},5})
table.insert(rare_treasure_chest_loot_weights, {{name = 'distractor-capsule', count = math_random(4,8)},4})
table.insert(rare_treasure_chest_loot_weights, {{name = 'destroyer-capsule', count = math_random(4,8)},3})
table.insert(rare_treasure_chest_loot_weights, {{name = 'atomic-bomb', count = 1},1})
for _, t in pairs (rare_treasure_chest_loot_weights) do
for x = 1, t[2], 1 do
table.insert(rare_treasure_chest_raffle_table, t[1])
end
end
local e = game.surfaces["deep_jungle"].create_entity {name="steel-chest",position=p, force="player"}
e.minable = false
local i = e.get_inventory(defines.inventory.chest)
for x = 1, math_random(2,3), 1 do
local loot = rare_treasure_chest_raffle_table[math_random(1,#rare_treasure_chest_raffle_table)]
i.insert(loot)
end
end
local function get_noise(name, pos)
local seed = game.surfaces[1].map_gen_settings.seed
local noise_seed_add = 25000
seed = seed + noise_seed_add
if name == 1 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.1, pos.y * 0.1, seed)
local noise = noise[1] + noise[2] * 0.1
return noise
end
seed = seed + noise_seed_add
seed = seed + noise_seed_add
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.1, pos.y * 0.1, seed)
local noise = noise[1] + noise[2] * 0.1
return noise
end
seed = seed + noise_seed_add
seed = seed + noise_seed_add
if name == 3 then
local noise = {}
noise[1] = simplex_noise(pos.x * 0.001, pos.y * 0.001, seed)
seed = seed + noise_seed_add
noise[2] = simplex_noise(pos.x * 0.01, pos.y * 0.01, seed)
local noise = noise[1] + noise[2] * 0.1
return noise
end
seed = seed + noise_seed_add
seed = seed + noise_seed_add
if name == 4 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.1, pos.y * 0.1, seed)
local noise = noise[1] + noise[2] * 0.2
return noise
end
seed = seed + noise_seed_add
seed = seed + noise_seed_add
if name == 5 then
local noise = {}
noise[1] = simplex_noise(pos.x * 0.05, pos.y * 0.05, seed)
local noise = noise[1]
return noise
end
seed = seed + noise_seed_add
seed = seed + noise_seed_add
if name == 6 then
local noise = {}
noise[1] = simplex_noise(pos.x * 0.05, pos.y * 0.05, seed)
local noise = noise[1]
return noise
end
end
local worm_raffle = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret"}
local rock_raffle = {"sand-rock-big","sand-rock-big","rock-big","rock-big","rock-big","rock-big","rock-huge"}
local function on_chunk_generated(event)
local surface = game.surfaces["deep_jungle"]
if event.surface.name ~= surface.name then return end
local chunk_pos_x = event.area.left_top.x
local chunk_pos_y = event.area.left_top.y
local tiles = {}
local entities_to_place = {
rocks = {},
worms = {},
enemy_buildings = {},
trees = {},
fish = {},
treasure_chests = {},
rare_treasure_chests = {}
}
local decoratives = {}
local entities = surface.find_entities(event.area)
for _, e in pairs(entities) do
if e.type == "tree" or e.force.name == "enemy" then
e.destroy()
end
end
local tile_to_insert = false
for x = 0, 31, 1 do
for y = 0, 31, 1 do
local pos_x = chunk_pos_x + x
local pos_y = chunk_pos_y + y
local pos = {x = pos_x, y = pos_y}
tile_to_insert = false
local noise_3 = get_noise(3, pos)
if noise_3 > -0.1 and noise_3 < 0.1 then
if noise_3 > -0.05 and noise_3 < 0.05 then
tile_to_insert = "water"
if math_random(1,40) == 1 then table.insert(entities_to_place.fish, pos) end
end
if noise_3 > -0.03 and noise_3 < 0.03 then
tile_to_insert = "deepwater"
if math_random(1,40) == 1 then table.insert(entities_to_place.fish, pos) end
end
else
local tile_distance_to_center = pos_x^2 + pos_y^2
local noise_1 = get_noise(1, pos)
local noise_2 = get_noise(2, pos)
local noise_4 = get_noise(4, pos)
if tile_distance_to_center > 10000 then
if math_random(1,500) == 1 then table.insert(entities_to_place.worms, pos) end
if noise_4 > -0.1 and noise_4 < 0.1 and noise_1 > 0.3 and noise_2 > 0.3 then
if math_random(1,8) == 1 then table.insert(entities_to_place.rocks, pos) end
end
end
if noise_4 < -0.8 or noise_4 > 0.8 then tile_to_insert = "dirt-6" end
if noise_3 < -0.1 then
if noise_1 > 0.2 then
if math_random(1,4) == 1 then table.insert(entities_to_place.trees, {"tree-02", pos}) end
if math_random(1,7500) == 1 then table.insert(entities_to_place.rare_treasure_chests, pos) end
if math_random(1,1250) == 1 then table.insert(entities_to_place.treasure_chests, pos) end
if noise_1 > 0.8 and tile_distance_to_center > 8000 then
tile_to_insert = "water-green"
if math_random(1,24) == 1 then table.insert(entities_to_place.fish, pos) end
end
end
if noise_1 < -0.2 then
if math_random(1,4) == 1 then table.insert(entities_to_place.trees, {"tree-04", pos}) end
if math_random(1,7500) == 1 then table.insert(entities_to_place.rare_treasure_chests, pos) end
if math_random(1,1250) == 1 then table.insert(entities_to_place.treasure_chests, pos) end
if noise_1 < -0.75 and tile_distance_to_center > 8000 then
if math_random(1,36) == 1 then table.insert(entities_to_place.enemy_buildings, pos) end
end
end
else
if noise_2 > 0.2 then
if math_random(1,4) == 1 then table.insert(entities_to_place.trees, {"tree-07", pos}) end
if math_random(1,7500) == 1 then table.insert(entities_to_place.rare_treasure_chests, pos) end
if math_random(1,1250) == 1 then table.insert(entities_to_place.treasure_chests, pos) end
if noise_2 > 0.75 and tile_distance_to_center > 8000 then
if math_random(1,36) == 1 then table.insert(entities_to_place.enemy_buildings, pos) end
end
end
if noise_2 < -0.2 then
if math_random(1,4) == 1 then table.insert(entities_to_place.trees, {"tree-09", pos}) end
if math_random(1,7500) == 1 then table.insert(entities_to_place.rare_treasure_chests, pos) end
if math_random(1,1250) == 1 then table.insert(entities_to_place.treasure_chests, pos) end
if noise_2 < -0.8 and tile_distance_to_center > 8000 then
tile_to_insert = "water-green"
if math_random(1,24) == 1 then table.insert(entities_to_place.fish, pos) end
end
end
end
end
if tile_to_insert ~= "deepwater" and tile_to_insert ~= "water" and tile_to_insert ~= "water-green" then
if math_random(1,3) == 1 then
local noise = get_noise(5, pos)
if noise > 0.2 then
table.insert(decoratives, {name = "green-hairy-grass", position = pos, amount = 2})
end
if noise < -0.7 then
table.insert(decoratives, {name = "green-pita", position = pos, amount = 2})
end
local noise = get_noise(6, pos)
if noise > 0.7 then
table.insert(decoratives, {name = "green-croton", position = pos, amount = 3})
end
if noise < -0.2 then
table.insert(decoratives, {name = "green-asterisk", position = pos, amount = 2})
end
end
end
if tile_to_insert == false then
table.insert(tiles, {name = "grass-1", position = {pos_x,pos_y}})
else
table.insert(tiles, {name = tile_to_insert, position = {pos_x,pos_y}})
end
end
end
surface.set_tiles(tiles,true)
surface.create_decoratives{check_collision=false, decoratives=decoratives}
for _, p in pairs(entities_to_place.enemy_buildings) do
if math_random(1,3) == 1 then
if surface.can_place_entity({name="spitter-spawner", position=p}) then surface.create_entity {name="spitter-spawner", position=p} end
else
if surface.can_place_entity({name="biter-spawner", position=p}) then surface.create_entity {name="biter-spawner", position=p} end
end
end
for _, p in pairs(entities_to_place.worms) do
local e = worm_raffle[math_random(1,#worm_raffle)]
if surface.can_place_entity({name=e, position=p}) then surface.create_entity {name=e, position=p} end
end
for _, p in pairs(entities_to_place.rocks) do
local e = rock_raffle[math_random(1,#rock_raffle)]
surface.create_entity {name=e, position=p}
end
for _, p in pairs(entities_to_place.trees) do
if surface.can_place_entity({name=p[1], position=p[2]}) then surface.create_entity {name=p[1], position=p[2]} end
end
for _, p in pairs(entities_to_place.treasure_chests) do
treasure_chest(p)
end
for _, p in pairs(entities_to_place.rare_treasure_chests) do
rare_treasure_chest(p)
end
for _, p in pairs(entities_to_place.fish) do
surface.create_entity {name="fish",position=p}
end
end
local function on_chunk_charted(event)
if not global.chunks_charted then global.chunks_charted = {} end
local surface = game.surfaces[event.surface_index]
local position = event.position
if global.chunks_charted[tostring(position.x) .. tostring(position.y)] then return end
global.chunks_charted[tostring(position.x) .. tostring(position.y)] = true
local force = event.force
if math_random(1,12) ~= 1 then return end
map_functions.draw_rainbow_patch({x = position.x * 32 + math_random(1,32), y = position.y * 32 + math_random(1,32)}, surface, math_random(14,26), 2000)
end
local function on_player_joined_game(event)
local player = game.players[event.player_index]
if not global.map_init_done then
game.forces["player"].technologies["flamethrower"].enabled = false
local map_gen_settings = {}
map_gen_settings.water = "none"
map_gen_settings.cliff_settings = {cliff_elevation_interval = 4, cliff_elevation_0 = 0.1}
map_gen_settings.autoplace_controls = {
["coal"] = {frequency = "high", size = "big", richness = "normal"},
["stone"] = {frequency = "high", size = "big", richness = "normal"},
["copper-ore"] = {frequency = "high", size = "big", richness = "normal"},
["iron-ore"] = {frequency = "high", size = "big", richness = "normal"},
["crude-oil"] = {frequency = "high", size = "big", richness = "normal"},
["trees"] = {frequency = "none", size = "none", richness = "none"},
["enemy-base"] = {frequency = "none", size = "none", richness = "none"},
--["grass"] = {frequency = "none", size = "none", richness = "none"},
["sand"] = {frequency = "none", size = "none", richness = "none"},
["desert"] = {frequency = "none", size = "none", richness = "none"},
["dirt"] = {frequency = "none", size = "none", richness = "none"}
}
game.map_settings.pollution.pollution_restored_per_tree_damage = 0
game.create_surface("deep_jungle", map_gen_settings)
game.forces["player"].set_spawn_position({0,0},game.surfaces["deep_jungle"])
global.map_init_done = true
end
local surface = game.surfaces["deep_jungle"]
if player.online_time < 5 and surface.is_chunk_generated({0,0}) then
player.teleport(surface.find_non_colliding_position("player", {0,0}, 2, 1), "deep_jungle")
else
if player.online_time < 5 then
player.teleport({0,0}, "deep_jungle")
end
end
if player.online_time < 10 then
player.insert {name = 'submachine-gun', count = 1}
player.insert {name = 'raw-fish', count = 12}
player.insert {name = 'firearm-magazine', count = 32}
player.insert {name = 'steel-axe', count = 1}
player.insert {name = 'light-armor', count = 1}
end
end
local function on_marked_for_deconstruction(event)
if event.entity.name == "rock-huge" or event.entity.name == "rock-big" or event.entity.name == "sand-rock-big" or event.entity.name == "fish" or event.entity.type == "tree" then
event.entity.cancel_deconstruction(game.players[event.player_index].force.name)
end
end
local function on_entity_died(event)
if event.entity.type == "tree" then
if math_random(1,6) == 1 then
local surface = game.surfaces["deep_jungle"]
local p = surface.find_non_colliding_position("small-biter" , event.entity.position, 2, 0.5)
if p then surface.create_entity {name="small-biter", position=event.entity.position} end
end
end
end
function cheat_mode()
local cheat_mode_enabed = true
if cheat_mode_enabed == true then
local surface = game.surfaces["deep_jungle"]
game.player.cheat_mode=true
game.players[1].insert({name="power-armor-mk2"})
game.players[1].insert({name="fusion-reactor-equipment", count=4})
game.players[1].insert({name="personal-laser-defense-equipment", count=8})
game.players[1].insert({name="rocket-launcher"})
game.players[1].insert({name="explosive-rocket", count=200})
game.speed = 2
surface.daytime = 1
game.player.force.research_all_technologies()
game.forces["enemy"].evolution_factor = 0.2
local chart = 300
local surface = game.surfaces["deep_jungle"]
game.forces["player"].chart(surface, {lefttop = {x = chart*-1, y = chart*-1}, rightbottom = {x = chart, y = chart}})
end
end
event.add(defines.events.on_chunk_generated, on_chunk_generated)
event.add(defines.events.on_chunk_charted, on_chunk_charted)
event.add(defines.events.on_entity_died, on_entity_died)
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -56,11 +56,20 @@ local function on_chunk_generated(event)
table.insert(tiles, {name = "grass-1", position = pos})
end
end
surface.set_tiles(tiles,true)
surface.set_tiles(tiles,true)
end
local function on_chunk_charted(event)
if not global.chunks_charted then global.chunks_charted = {} end
local surface = game.surfaces[event.surface_index]
local position = event.position
if global.chunks_charted[tostring(position.x) .. tostring(position.y)] then return end
global.chunks_charted[tostring(position.x) .. tostring(position.y)] = true
local force = event.force
if chunk_pos_x % 96 ~= 0 then return end
if chunk_pos_y % 96 ~= 0 then return end
map_functions.draw_rainbow_patch({x = chunk_pos_x, y = chunk_pos_y}, surface, 28, 1000)
if position.x % 4 ~= 0 then return end
if position.y % 4 ~= 0 then return end
map_functions.draw_rainbow_patch({x = position.x * 32, y = position.y * 32}, surface, 28, 1000)
end
local function on_player_joined_game(event)
@ -108,4 +117,5 @@ local function on_player_joined_game(event)
end
event.add(defines.events.on_chunk_generated, on_chunk_generated)
event.add(defines.events.on_chunk_charted, on_chunk_charted)
event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -1,9 +1,9 @@
local event = require 'utils.event'
local main_caption = " --Anarchy-- "
local sub_caption = " finally.. freedum.. "
local main_caption = " --Hunger Games-- "
local sub_caption = "Deep in the meadow, hidden far away."
local info = [[
Join / Create a group to play!!
Create / Join a group to play!!
Use the [Group] button!
@ -22,13 +22,13 @@ local function create_map_intro(player)
local tt = t.add {type = "table", column_count = 3}
local l = tt.add {type = "label", caption = main_caption}
l.style.font = "default-frame"
l.style.font_color = {r=0.8, g=0.3, b=0.45}
l.style.font_color = {r=35, g=130, b=60}
l.style.top_padding = 6
l.style.bottom_padding = 6
local l = tt.add {type = "label", caption = sub_caption}
l.style.font = "default"
l.style.font_color = {r=0.9, g=0.9, b=0.2}
l.style.font_color = {r=0.75, g=0.75, b=0.2}
l.style.minimal_width = 280
local b = tt.add {type = "button", caption = "X", name = "close_map_intro_frame", align = "right"}

View File

@ -0,0 +1,56 @@
-- prints death messages to all forces with custom texts -- by mewmew
local event = require 'utils.event'
local math_random = math.random
local message_color = {r=0.85, g=0.0, b=0.0}
local messages = {
["small-biter"] = {" was nibbled to death.", " should not have played with the biters.", " is biter food."},
["medium-biter"] = {" lost their leg to hungry biter.", " is biter food.", " was a tasty biter treat."},
["big-biter"] = {" had their head chomped off.", " is biter food.", " was a tasty biter treat."},
["behemoth-biter"] = {" was devoured by a behemoth biter.", " was crushed by a behemoth biter.", " is biter food."},
["small-spitter"] = {" melted away by acid spit!", " couldn't dodge the spit in time."},
["medium-spitter"] = {" melted away by acid spit!", " couldn't dodge the spit in time."},
["big-spitter"] = {" melted away by acid spit!", " couldn't dodge the spit in time.", " got blasted away by a spitter."},
["behemoth-spitter"] = {" melted away by acid spit!", " couldn't dodge the spit in time.", " got blasted away by a spitter."},
["small-worm-turret"] = {" melted away by acid spit!", " couldn't dodge the spit in time."},
["medium-worm-turret"] = {" melted away by acid spit!", " couldn't dodge the spit in time.", " got blasted away by a medium worm turret."},
["big-worm-turret"] = {" melted away by acid spit!", " couldn't dodge the spit in time.", " got blasted away by a big worm turret."},
["gun-turret"] = {" was mowed down by a barrage from a gun turret."},
["laser-turret"] = {" was fatally enlightened by a laser beam."}
}
local function on_player_died(event)
local player = game.players[event.player_index]
if event.cause then
if not event.cause.name then
game.print(player.name .. " " .. player.tag .. " was killed." .. str, message_color)
return
end
if messages[event.cause.name] then
game.print(player.name .. messages[event.cause.name][math.random(1, #messages[event.cause.name])], message_color)
return
end
if event.cause.name == "player" then
game.print(player.name .. " " .. player.tag .. " was killed by " .. event.cause.player.name " " .. event.cause.player.tag .. ".", message_color)
return
end
if event.cause.name == "tank" then
local driver = event.cause.get_driver()
if driver.player then
game.print(player.name .. " " .. player.tag .. " was killed by " .. driver.player.name .. " " .. player.tag .. ".", message_color)
end
end
game.print(player.name .. " " .. player.tag .. " was killed by " .. event.cause.name .. ".", message_color)
return
end
if player.tag then
game.print(player.name .. " " .. player.tag .. " was killed.", message_color)
end
game.print(player.name .. " was killed.", message_color)
end
event.add(defines.events.on_player_died, on_player_died)

View File

@ -5,6 +5,7 @@ local event = require 'utils.event'
local valid_types = {"boiler", "container", "furnace", "generator", "logistic-container", "mining-drill", "offshore-pump", "lab", "assembling-machine"}
local function on_built_entity(event)
if not event.created_entity.valid then return end
local player = game.players[event.player_index]
local area = {{event.created_entity.position.x - 12, event.created_entity.position.y - 12}, {event.created_entity.position.x + 12, event.created_entity.position.y + 12}}
if player.surface.count_entities_filtered({area = area, force = player.force, type = valid_types}) > 12 then

View File

@ -0,0 +1,20 @@
-- clear the player respawn from enemies with a kaboom -- by mewmew
local event = require 'utils.event'
local function damage_entities_in_radius(surface, position, radius)
local entities_to_damage = surface.find_entities_filtered({area = {{position.x - radius, position.y - radius},{position.x + radius, position.y + radius}}})
for _, entity in pairs(entities_to_damage) do
if entity.health and entity.force.name == "enemy" then
entity.surface.create_entity({name = "big-explosion", position = entity.position})
entity.destroy()
end
end
end
local function on_player_respawned(event)
local player = game.players[event.player_index]
player.surface.create_entity({name = "big-artillery-explosion", position = player.position})
damage_entities_in_radius(player.surface, player.position, 12)
end
event.add(defines.events.on_player_respawned, on_player_respawned)

View File

@ -1,8 +1,11 @@
-- "Anarchy" mode - by mewmew
-- "Hunger Games" or "Anarchy" mode - by mewmew
-- create a tag group to form alliances
-- empty groups will be deleted
-- join or create a team to be able to play
require "maps.modules.custom_death_messages"
require "maps.modules.hunger_games_balance"
local event = require 'utils.event'
local message_color = {r=0.98, g=0.66, b=0.22}
@ -265,7 +268,8 @@ local function new_group(frame, player)
frame.frame2.group_table.new_group_description.text = "Description"
if not game.forces[new_group_name] then game.create_force(new_group_name) end
game.forces[new_group_name].share_chart = true
game.forces[new_group_name].share_chart = false
game.forces[new_group_name].technologies["landfill"].enabled = false
--game.forces[new_group_name].set_friend("spectator", true)
--game.forces["spectator"].set_friend(new_group_name, true)
@ -393,7 +397,8 @@ local function on_player_joined_game(event)
anarchy_gui_button(player)
if player.online_time == 0 then
if player.online_time == 0 then
player.force = game.forces.spectator
player.print("Join / Create a group to play!", message_color)
permission_group.add_player(player.name)
end
@ -403,7 +408,7 @@ end
----------share chat -------------------
local function on_console_chat(event)
if not event.message then return end
if not event.message then return end
if not event.player_index then return end
local player = game.players[event.player_index]
@ -427,6 +432,34 @@ local function on_console_chat(event)
end
end
local function on_player_respawned(event)
local player = game.players[event.player_index]
player.insert{name = 'iron-axe', count = 1}
player.insert{name = 'iron-plate', count = 32}
end
local function on_built_entity(event)
local entity = event.created_entity
if not entity.valid then return end
local distance_to_center = math.sqrt(entity.position.x^2 + entity.position.y^2)
if distance_to_center > 48 then return end
local surface = entity.surface
surface.create_entity({name = "flying-text", position = entity.position, text = "Spawn is protected from building.", color = {r=0.88, g=0.1, b=0.1}})
local player = game.players[event.player_index]
player.insert({name = entity.name, count = 1})
if global.score then
if global.score[player.force.name] then
if global.score[player.force.name].players[player.name] then
global.score[player.force.name].players[player.name].built_entities = global.score[player.force.name].players[player.name].built_entities - 1
end
end
end
entity.destroy()
end
event.add(defines.events.on_player_died, on_player_died)
event.add(defines.events.on_built_entity, on_built_entity)
event.add(defines.events.on_player_respawned, on_player_respawned)
event.add(defines.events.on_console_chat, on_console_chat)
event.add(defines.events.on_gui_click, on_gui_click)
event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -0,0 +1,179 @@
--Hunger games balance things by Gerkiz --
local event = require 'utils.event'
local player_ammo_starting_modifiers = {
['artillery-shell'] = -0.75,
['biological'] = -0.5,
['bullet'] = -0.25,
['cannon-shell'] = -0.75,
['capsule'] = -0.5,
['combat-robot-beam'] = -0.5,
['combat-robot-laser'] = -0.5,
['electric'] = -0.5,
['flamethrower'] = -0.75,
['grenade'] = -0.5,
['landmine'] = -0.33,
['laser-turret'] = -0.75,
['melee'] = 2,
['railgun'] = 1,
['rocket'] = -0.75,
['shotgun-shell'] = -0.20
}
local player_gun_speed_modifiers = {
['artillery-shell'] = -0.75,
['biological'] = -0.5,
['bullet'] = -0.55,
['cannon-shell'] = -0.75,
['capsule'] = -0.5,
['combat-robot-beam'] = -0.5,
['combat-robot-laser'] = -0.5,
['electric'] = -0.5,
['flamethrower'] = -0.75,
['grenade'] = -0.5,
['landmine'] = -0.33,
['laser-turret'] = -0.75,
['melee'] = 1,
['railgun'] = 0,
['rocket'] = -0.75,
['shotgun-shell'] = -0.50
}
local player_ammo_research_modifiers = {
['artillery-shell'] = -0.75,
['biological'] = -0.5,
['bullet'] = -0.5,
['cannon-shell'] = -0.85,
['capsule'] = -0.5,
['combat-robot-beam'] = -0.5,
['combat-robot-laser'] = -0.5,
['electric'] = -0.6,
['flamethrower'] = -0.75,
['grenade'] = -0.5,
['landmine'] = -0.5,
['laser-turret'] = -0.75,
['melee'] = -0.5,
['railgun'] = -0.5,
['rocket'] = -0.5,
['shotgun-shell'] = -0.20
}
local player_turrets_research_modifiers = {
['gun-turret'] = -0.75,
['laser-turret'] = -0.75,
['flamethrower-turret'] = -0.75
}
local enemy_ammo_starting_modifiers = {
['artillery-shell'] = 0,
['biological'] = 0,
['bullet'] = 0,
['cannon-shell'] = 0,
['capsule'] = 0,
['combat-robot-beam'] = 0,
['combat-robot-laser'] = 0,
['electric'] = 0,
['flamethrower'] = 0,
['grenade'] = 0,
['landmine'] = 0,
['laser-turret'] = 0,
['melee'] = 0,
['railgun'] = 0,
['rocket'] = 0,
['shotgun-shell'] = 0
}
local enemy_ammo_evolution_modifiers = {
['artillery-shell'] = 1,
['biological'] = 2,
['bullet'] = 1,
--['cannon-shell'] = 1,
--['capsule'] = 1,
--['combat-robot-beam'] = 1,
--['combat-robot-laser'] = 1,
--['electric'] = 1,
['flamethrower'] = 2,
--['grenade'] = 1,
--['landmine'] = 1,
['laser-turret'] = 2,
['melee'] = 2
--['railgun'] = 1,
--['rocket'] = 1,
--['shotgun-shell'] = 1
}
function init_player_weapon_damage(force)
for k, v in pairs(player_ammo_starting_modifiers) do
force.set_ammo_damage_modifier(k, v)
end
for k, v in pairs(player_gun_speed_modifiers) do
force.set_gun_speed_modifier(k, v)
end
end
function init_enemy_weapon_damage()
local e_force = game.forces["enemy"]
for k, v in pairs(enemy_ammo_starting_modifiers) do
e_force.set_ammo_damage_modifier(k, v)
end
end
local function enemy_weapon_damage()
local f = game.forces.enemy
local ef = f.evolution_factor
for k, v in pairs(enemy_ammo_evolution_modifiers) do
local base = enemy_ammo_starting_modifiers[k]
local new = base + v * ef
f.set_ammo_damage_modifier(k, new)
end
end
local function research_finished(event)
local r = event.research
local p_force = r.force
for _, e in ipairs(r.effects) do
local t = e.type
if t == 'ammo-damage' then
local category = e.ammo_category
local factor = player_ammo_research_modifiers[category]
if factor then
local current_m = p_force.get_ammo_damage_modifier(category)
local m = e.modifier
p_force.set_ammo_damage_modifier(category, current_m + factor * m)
end
elseif t == 'turret-attack' then
local category = e.turret_id
local factor = player_turrets_research_modifiers[category]
if factor then
local current_m = p_force.get_turret_attack_modifier(category)
local m = e.modifier
p_force.set_turret_attack_modifier(category, current_m + factor * m)
end
elseif t == 'gun-speed' then
local category = e.ammo_category
local factor = player_gun_speed_modifiers[category]
if factor then
local current_m = p_force.get_gun_speed_modifier(category)
local m = e.modifier
p_force.set_gun_speed_modifier(category, current_m + factor * m)
end
end
end
end
event.on_init(init_enemy_weapon_damage)
event.on_nth_tick(18000, enemy_weapon_damage)
event.add(defines.events.on_research_finished, research_finished)

View File

@ -0,0 +1,15 @@
local event = require 'utils.event'
local coin_yield = {
["rock-big"] = 3,
["rock-huge"] = 6,
["sand-rock-big"] = 3
}
local function on_player_mined_entity(event)
if coin_yield[event.entity.name] then
event.entity.surface.spill_item_stack(event.entity.position,{name = "coin", count = math.random(math.ceil(coin_yield[event.entity.name] * 0.5), math.ceil(coin_yield[event.entity.name] * 2))}, true)
end
end
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)

View File

@ -620,8 +620,7 @@ local function on_player_died(event)
if target_player.name ~= player.name then
player.print(player.name .. " was killed" .. str, { r=0.99, g=0.0, b=0.0})
end
end
end
end
----------share chat with player and spectator force-------------------