mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-17 20:58:13 +02:00
mtn v3 -make terrain randomized
This commit is contained in:
parent
73c0c7f2be
commit
03d681e29c
@ -1,5 +1,4 @@
|
||||
local Collapse = require 'modules.collapse'
|
||||
local Terrain = require 'maps.mountain_fortress_v3.terrain'
|
||||
local Balance = require 'maps.mountain_fortress_v3.balance'
|
||||
local RPG = require 'modules.rpg.main'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
@ -15,21 +14,7 @@ local abs = math.abs
|
||||
local random = math.random
|
||||
local sub = string.sub
|
||||
local sqrt = math.sqrt
|
||||
local level_depth = WPT.level_depth
|
||||
|
||||
local forest = {
|
||||
[2] = true,
|
||||
[10] = true,
|
||||
[13] = true,
|
||||
[17] = true,
|
||||
[19] = true,
|
||||
[21] = true
|
||||
}
|
||||
|
||||
local scrap = {
|
||||
[5] = true,
|
||||
[15] = true
|
||||
}
|
||||
local zone_settings = WPT.zone_settings
|
||||
|
||||
local clear_breach_text_and_render = function()
|
||||
local beam1 = WPT.get('zone1_beam1')
|
||||
@ -140,8 +125,10 @@ end
|
||||
local compare_player_pos = function(player)
|
||||
local p = player.position
|
||||
local index = player.index
|
||||
local zone = floor((abs(p.y / level_depth)) % 22)
|
||||
if scrap[zone] then
|
||||
local zone = floor((abs(p.y / zone_settings.zone_depth)) % zone_settings.size) + 1
|
||||
local adjusted_zones = WPT.get('adjusted_zones')
|
||||
|
||||
if adjusted_zones.scrap[zone] then
|
||||
RPG.set_value_to_player(index, 'scrap_zone', true)
|
||||
else
|
||||
local has_scrap = RPG.get_value_from_player(index, 'scrap_zone')
|
||||
@ -150,7 +137,7 @@ local compare_player_pos = function(player)
|
||||
end
|
||||
end
|
||||
|
||||
if forest[zone] then
|
||||
if adjusted_zones.forest[zone] then
|
||||
RPG.set_value_to_player(index, 'forest_zone', true)
|
||||
else
|
||||
local is_in_forest = RPG.get_value_from_player(index, 'forest_zone')
|
||||
@ -189,7 +176,7 @@ local compare_player_and_train = function(player, entity)
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = position,
|
||||
text = 'Warning!!! You are too far from the train!!!',
|
||||
text = 'Warning! You are too far away from the main locomotive!',
|
||||
color = {r = 0.9, g = 0.0, b = 0.0}
|
||||
}
|
||||
)
|
||||
@ -228,14 +215,14 @@ local function distance(player)
|
||||
|
||||
compare_player_pos(player)
|
||||
|
||||
local distance_to_center = floor(sqrt(p.x ^ 2 + p.y ^ 2))
|
||||
local distance_to_center = floor(sqrt(p.y ^ 2))
|
||||
local location = distance_to_center
|
||||
if location < Terrain.level_depth * bonus - 10 then
|
||||
if location < zone_settings.zone_depth * bonus - 10 then
|
||||
return
|
||||
end
|
||||
|
||||
local max = Terrain.level_depth * bonus
|
||||
local breach_max = Terrain.level_depth * breached_wall
|
||||
local max = zone_settings.zone_depth * bonus
|
||||
local breach_max = zone_settings.zone_depth * breached_wall
|
||||
local breach_max_times = location >= breach_max
|
||||
local max_times = location >= max
|
||||
if max_times then
|
||||
@ -245,10 +232,8 @@ local function distance(player)
|
||||
rpg_extra.breached_walls = rpg_extra.breached_walls + 1
|
||||
rpg_extra.reward_new_players = bonus_xp_on_join * rpg_extra.breached_walls
|
||||
WPT.set('breached_wall', breached_wall + 1)
|
||||
placed_trains_in_zone.placed = 0
|
||||
biters.amount = 0
|
||||
placed_trains_in_zone.randomized = false
|
||||
placed_trains_in_zone.positions = {}
|
||||
raise_event(Balance.events.breached_wall, {})
|
||||
if WPT.get('breached_wall') == WPT.get('spidertron_unlocked_at_zone') then
|
||||
local main_market_items = WPT.get('main_market_items')
|
||||
@ -258,7 +243,7 @@ local function distance(player)
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = rng,
|
||||
tooltip = 'Chonk Spidertron',
|
||||
tooltip = 'BiterStunner 9000',
|
||||
upgrade = false,
|
||||
static = true
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ local Loot = require 'maps.mountain_fortress_v3.loot'
|
||||
local RPG = require 'modules.rpg.main'
|
||||
local Callbacks = require 'maps.mountain_fortress_v3.functions'
|
||||
local Mining = require 'maps.mountain_fortress_v3.mining'
|
||||
local Terrain = require 'maps.mountain_fortress_v3.terrain'
|
||||
local Traps = require 'maps.mountain_fortress_v3.traps'
|
||||
local Locomotive = require 'maps.mountain_fortress_v3.locomotive'
|
||||
local DefenseSystem = require 'maps.mountain_fortress_v3.locomotive.defense_system'
|
||||
@ -26,6 +25,7 @@ local RPG_Progression = require 'utils.datastore.rpg_data'
|
||||
-- tables
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local zone_settings = WPT.zone_settings
|
||||
|
||||
-- module
|
||||
local Public = {}
|
||||
@ -394,7 +394,7 @@ local function angry_tree(entity, cause, player)
|
||||
return
|
||||
end
|
||||
|
||||
if abs(entity.position.y) < Terrain.level_depth then
|
||||
if abs(entity.position.y) < zone_settings.zone_depth then
|
||||
return
|
||||
end
|
||||
if random(1, 6) == 1 then
|
||||
|
@ -13,6 +13,7 @@ local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
|
||||
local math2d = require 'math2d'
|
||||
local Misc = require 'utils.commands.misc'
|
||||
local zone_settings = WPT.zone_settings
|
||||
|
||||
local this = {
|
||||
power_sources = {index = 1},
|
||||
@ -1094,8 +1095,8 @@ function Public.render_direction(surface)
|
||||
scale_with_zoom = false
|
||||
}
|
||||
|
||||
local x_min = -WPT.level_width / 2
|
||||
local x_max = WPT.level_width / 2
|
||||
local x_min = -zone_settings.zone_width / 2
|
||||
local x_max = zone_settings.zone_width / 2
|
||||
|
||||
surface.create_entity({name = 'electric-beam', position = {x_min, 74}, source = {x_min, 74}, target = {x_max, 74}})
|
||||
surface.create_entity({name = 'electric-beam', position = {x_min, 74}, source = {x_min, 74}, target = {x_max, 74}})
|
||||
|
@ -19,6 +19,7 @@ local tiles_per_call = 8
|
||||
local total_calls = ceil(1024 / tiles_per_call)
|
||||
local regen_decoratives = false
|
||||
local generate_map = Terrain.heavy_functions
|
||||
local winter_mode = false
|
||||
local wintery_type = {
|
||||
['simple-entity'] = true,
|
||||
['tree'] = true,
|
||||
@ -299,7 +300,6 @@ local function do_place_buildings(data)
|
||||
end
|
||||
|
||||
local function wintery(ent, extra_lights)
|
||||
local winter_mode = WPT.get('winter_mode')
|
||||
if not winter_mode then
|
||||
return false
|
||||
end
|
||||
|
@ -73,6 +73,12 @@ local noises = {
|
||||
{modifier = 0.05, weight = 0.23},
|
||||
{modifier = 0.1, weight = 0.11}
|
||||
},
|
||||
['scrapyard_modified'] = {
|
||||
{modifier = 0.006, weight = 1},
|
||||
{modifier = 0.04, weight = 0.15},
|
||||
{modifier = 0.22, weight = 0.05},
|
||||
{modifier = 0.05, weight = 0.32}
|
||||
},
|
||||
['big_cave'] = {
|
||||
{modifier = 0.003, weight = 1},
|
||||
{modifier = 0.02, weight = 0.05},
|
||||
|
@ -252,7 +252,7 @@ function Public.reset_map()
|
||||
Collapse.set_kill_specific_entities(collapse_kill)
|
||||
Collapse.set_speed(8)
|
||||
Collapse.set_amount(1)
|
||||
-- Collapse.set_max_line_size(WPT.level_width)
|
||||
-- Collapse.set_max_line_size(zone_settings.zone_width)
|
||||
Collapse.set_max_line_size(540)
|
||||
Collapse.set_surface(surface)
|
||||
Collapse.set_position({0, 130})
|
||||
|
@ -2,6 +2,7 @@ local Global = require 'utils.global'
|
||||
local surface_name = 'mountain_fortress_v3'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local Reset = require 'maps.mountain_fortress_v3.soft_reset'
|
||||
local zone_settings = WPT.zone_settings
|
||||
|
||||
local Public = {}
|
||||
|
||||
@ -22,7 +23,7 @@ local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16
|
||||
function Public.create_surface()
|
||||
local map_gen_settings = {
|
||||
['seed'] = math.random(10000, 99999),
|
||||
['width'] = WPT.level_width,
|
||||
['width'] = zone_settings.zone_width,
|
||||
['water'] = 0.001,
|
||||
['starting_area'] = 1,
|
||||
['cliff_settings'] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
|
||||
|
@ -17,8 +17,11 @@ Global.register(
|
||||
end
|
||||
)
|
||||
|
||||
Public.level_depth = 704
|
||||
Public.level_width = 510
|
||||
Public.zone_settings = {
|
||||
zone_depth = 704,
|
||||
zone_width = 510,
|
||||
size = nil
|
||||
}
|
||||
|
||||
Public.pickaxe_upgrades = {
|
||||
'Wood',
|
||||
@ -167,10 +170,9 @@ function Public.reset_table()
|
||||
this.chests_linked_to = {}
|
||||
this.chest_limit_outside_upgrades = 1
|
||||
this.placed_trains_in_zone = {
|
||||
placed = 0,
|
||||
positions = {},
|
||||
limit = 2,
|
||||
randomized = false
|
||||
randomized = false,
|
||||
zones = {}
|
||||
}
|
||||
this.marked_fixed_prices = {
|
||||
chest_limit_cost = 3000,
|
||||
@ -226,6 +228,10 @@ function Public.reset_table()
|
||||
current = {},
|
||||
temp_boosts = {}
|
||||
}
|
||||
this.adjusted_zones = {
|
||||
scrap = {},
|
||||
forest = {}
|
||||
}
|
||||
this.alert_zone_1 = false -- alert the players
|
||||
|
||||
for k, _ in pairs(this.players) do
|
||||
|
@ -11,17 +11,9 @@ local abs = math.abs
|
||||
local floor = math.floor
|
||||
local ceil = math.ceil
|
||||
|
||||
Public.level_depth = WPT.level_depth
|
||||
Public.level_width = WPT.level_width
|
||||
local zone_settings = WPT.zone_settings
|
||||
local worm_level_modifier = 0.19
|
||||
|
||||
-- local start_ground_tiles = {
|
||||
-- 'dirt-1',
|
||||
-- 'grass-1',
|
||||
-- 'grass-2',
|
||||
-- 'dirt-2'
|
||||
-- }
|
||||
|
||||
local wagon_raffle = {
|
||||
'cargo-wagon',
|
||||
'cargo-wagon',
|
||||
@ -133,6 +125,15 @@ local function get_scrap_mineable_entities()
|
||||
return scrap_mineable_entities, scrap_mineable_entities_index
|
||||
end
|
||||
|
||||
local function shuffle(tbl)
|
||||
local size = #tbl
|
||||
for i = size, 1, -1 do
|
||||
local rand = random(size)
|
||||
tbl[i], tbl[rand] = tbl[rand], tbl[i]
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
|
||||
local function is_position_near(area, table_to_check)
|
||||
local status = false
|
||||
local function inside(pos)
|
||||
@ -159,7 +160,33 @@ local function place_wagon(data)
|
||||
placed_trains_in_zone = WPT.get('placed_trains_in_zone')
|
||||
end
|
||||
|
||||
if placed_trains_in_zone.placed >= placed_trains_in_zone.limit then
|
||||
if not data.new_zone then
|
||||
data.new_zone = 1
|
||||
end
|
||||
|
||||
if data.new_zone == zone_settings.size then
|
||||
data.new_zone = 1
|
||||
end
|
||||
|
||||
if data.current_zone == zone_settings.size then
|
||||
local new_zone = placed_trains_in_zone.zones[data.new_zone]
|
||||
if new_zone then
|
||||
new_zone.placed = 0
|
||||
new_zone.positions = {}
|
||||
data.new_zone = data.new_zone + 1
|
||||
end
|
||||
end
|
||||
|
||||
local zone = placed_trains_in_zone.zones[data.current_zone]
|
||||
if not zone then
|
||||
placed_trains_in_zone.zones[data.current_zone] = {
|
||||
placed = 0,
|
||||
positions = {}
|
||||
}
|
||||
zone = placed_trains_in_zone.zones[data.current_zone]
|
||||
end
|
||||
|
||||
if zone.placed >= placed_trains_in_zone.limit then
|
||||
return
|
||||
end
|
||||
|
||||
@ -182,7 +209,7 @@ local function place_wagon(data)
|
||||
right_bottom = {x = position.x + radius, y = position.y + radius}
|
||||
}
|
||||
|
||||
if is_position_near(area, placed_trains_in_zone.positions) then
|
||||
if is_position_near(area, zone.positions) then
|
||||
return
|
||||
end
|
||||
|
||||
@ -217,8 +244,9 @@ local function place_wagon(data)
|
||||
force = 'player',
|
||||
callback = wagon_mineable
|
||||
}
|
||||
placed_trains_in_zone.placed = placed_trains_in_zone.placed + 1
|
||||
placed_trains_in_zone.positions[#placed_trains_in_zone.positions + 1] = position
|
||||
|
||||
zone.placed = zone.placed + 1
|
||||
zone.positions[#zone.positions + 1] = position
|
||||
|
||||
return true
|
||||
end
|
||||
@ -313,8 +341,8 @@ local function wall(p, data)
|
||||
callback = stone_wall
|
||||
}
|
||||
if not alert_zone_1 then
|
||||
local x_min = -WPT.level_width / 2
|
||||
local x_max = WPT.level_width / 2
|
||||
local x_min = -zone_settings.zone_width / 2
|
||||
local x_max = zone_settings.zone_width / 2
|
||||
WPT.set('zone1_beam1', surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}}))
|
||||
WPT.set('zone1_beam2', surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}}))
|
||||
WPT.set('alert_zone_1', true)
|
||||
@ -393,36 +421,36 @@ local function wall(p, data)
|
||||
end
|
||||
|
||||
if random(1, 25) == 1 then
|
||||
if abs(p.y) < Public.level_depth * 1.5 then
|
||||
if abs(p.y) < zone_settings.zone_depth * 1.5 then
|
||||
if random(1, 16) == 1 then
|
||||
spawn_turret(entities, p, 1)
|
||||
else
|
||||
spawn_turret(entities, p, 2)
|
||||
end
|
||||
elseif abs(p.y) < Public.level_depth * 2.5 then
|
||||
elseif abs(p.y) < zone_settings.zone_depth * 2.5 then
|
||||
if random(1, 8) == 1 then
|
||||
spawn_turret(entities, p, 3)
|
||||
end
|
||||
elseif abs(p.y) < Public.level_depth * 3.5 then
|
||||
elseif abs(p.y) < zone_settings.zone_depth * 3.5 then
|
||||
if random(1, 4) == 1 then
|
||||
spawn_turret(entities, p, 4)
|
||||
else
|
||||
spawn_turret(entities, p, 3)
|
||||
end
|
||||
elseif abs(p.y) < Public.level_depth * 4.5 then
|
||||
elseif abs(p.y) < zone_settings.zone_depth * 4.5 then
|
||||
if random(1, 4) == 1 then
|
||||
spawn_turret(entities, p, 4)
|
||||
else
|
||||
spawn_turret(entities, p, 5)
|
||||
end
|
||||
elseif abs(p.y) < Public.level_depth * 5.5 then
|
||||
elseif abs(p.y) < zone_settings.zone_depth * 5.5 then
|
||||
if random(1, 4) == 1 then
|
||||
spawn_turret(entities, p, 4)
|
||||
elseif random(1, 2) == 1 then
|
||||
spawn_turret(entities, p, 5)
|
||||
end
|
||||
end
|
||||
elseif abs(p.y) > Public.level_depth * 5.5 then
|
||||
elseif abs(p.y) > zone_settings.zone_depth * 5.5 then
|
||||
if random(1, 15) == 1 then
|
||||
spawn_turret(entities, p, random(3, enable_arties))
|
||||
end
|
||||
@ -430,7 +458,7 @@ local function wall(p, data)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_14_position(x, y, data)
|
||||
local function generate_zone_14(x, y, data)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -445,7 +473,7 @@ local function process_level_14_position(x, y, data)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.71 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -510,7 +538,7 @@ local function process_level_14_position(x, y, data)
|
||||
tiles[#tiles + 1] = {name = 'water-shallow', position = p}
|
||||
end
|
||||
|
||||
local function process_level_13_position(x, y, data)
|
||||
local function generate_zone_13(x, y, data)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -525,7 +553,7 @@ local function process_level_13_position(x, y, data)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -590,7 +618,7 @@ local function process_level_13_position(x, y, data)
|
||||
tiles[#tiles + 1] = {name = 'water-shallow', position = p}
|
||||
end
|
||||
|
||||
local function process_level_12_position(x, y, data, void_or_lab)
|
||||
local function generate_zone_12(x, y, data, void_or_lab)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -606,7 +634,7 @@ local function process_level_12_position(x, y, data, void_or_lab)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -676,7 +704,7 @@ local function process_level_12_position(x, y, data, void_or_lab)
|
||||
tiles[#tiles + 1] = {name = 'tutorial-grid', position = p}
|
||||
end
|
||||
|
||||
local function process_level_11_position(x, y, data)
|
||||
local function generate_zone_11(x, y, data)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -700,7 +728,7 @@ local function process_level_11_position(x, y, data)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -772,7 +800,7 @@ local function process_level_11_position(x, y, data)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_10_position(x, y, data)
|
||||
local function generate_zone_10(x, y, data)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -798,7 +826,7 @@ local function process_level_10_position(x, y, data)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -886,7 +914,7 @@ local function process_level_10_position(x, y, data)
|
||||
tiles[#tiles + 1] = {name = 'grass-2', position = p}
|
||||
end
|
||||
|
||||
local function process_level_9_position(x, y, data)
|
||||
local function generate_zone_9(x, y, data)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -940,7 +968,7 @@ local function process_level_9_position(x, y, data)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -959,13 +987,143 @@ local function process_level_9_position(x, y, data)
|
||||
end
|
||||
|
||||
--SCRAPYARD
|
||||
local function process_scrap_zone_1(x, y, data, void_or_lab)
|
||||
local function process_zone_scrap_2(x, y, data, void_or_lab)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
local entities = data.entities
|
||||
local buildings = data.buildings
|
||||
local treasure = data.treasure
|
||||
data.scrap_zone = true
|
||||
|
||||
local scrapyard_modified = get_perlin('scrapyard_modified', p, seed)
|
||||
local cave_rivers = get_perlin('cave_rivers', p, seed + 65030)
|
||||
|
||||
--Chasms
|
||||
local noise_cave_ponds = get_perlin('cave_ponds', p, seed)
|
||||
local small_caves = get_perlin('small_caves', p, seed)
|
||||
if noise_cave_ponds < 0.15 and noise_cave_ponds > -0.15 then
|
||||
if small_caves > 0.35 then
|
||||
tiles[#tiles + 1] = {name = void_or_lab, position = p}
|
||||
return
|
||||
end
|
||||
|
||||
if small_caves < -0.35 then
|
||||
tiles[#tiles + 1] = {name = void_or_lab, position = p}
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if scrapyard_modified < -0.25 or scrapyard_modified > 0.25 then
|
||||
if random(1, 256) == 1 then
|
||||
if random(1, 8) == 1 then
|
||||
spawn_turret(entities, p, 3)
|
||||
else
|
||||
spawn_turret(entities, p, 4)
|
||||
end
|
||||
if random(1, 2048) == 1 then
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
end
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
if scrapyard_modified < -0.55 or scrapyard_modified > 0.55 then
|
||||
if random(1, 2) == 1 then
|
||||
entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p}
|
||||
end
|
||||
return
|
||||
end
|
||||
if scrapyard_modified < -0.28 or scrapyard_modified > 0.28 then
|
||||
local success = place_wagon(data)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {
|
||||
name = Biters.wave_defense_roll_worm_name(),
|
||||
position = p,
|
||||
force = 'enemy',
|
||||
note = true
|
||||
}
|
||||
end
|
||||
if random(1, 96) == 1 then
|
||||
entities[#entities + 1] = {
|
||||
name = scrap_entities[random(1, scrap_entities_index)],
|
||||
position = p,
|
||||
force = 'enemy'
|
||||
}
|
||||
end
|
||||
if random(1, 96) == 1 then
|
||||
entities[#entities + 1] = {
|
||||
name = scrap_entities_friendly[random(1, scrap_entities_friendly_index)],
|
||||
position = p,
|
||||
force = 'neutral'
|
||||
}
|
||||
end
|
||||
|
||||
local scrap_mineable_entities, scrap_mineable_entities_index = get_scrap_mineable_entities()
|
||||
|
||||
if random(1, 5) > 1 then
|
||||
entities[#entities + 1] = {name = scrap_mineable_entities[random(1, scrap_mineable_entities_index)], position = p, force = 'neutral'}
|
||||
end
|
||||
|
||||
if random(1, 256) == 1 then
|
||||
entities[#entities + 1] = {name = 'land-mine', position = p, force = 'enemy'}
|
||||
end
|
||||
return
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local cave_ponds = get_perlin('cave_ponds', p, seed)
|
||||
if cave_ponds < -0.6 and scrapyard_modified > -0.2 and scrapyard_modified < 0.2 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 128) == 1 then
|
||||
entities[#entities + 1] = {name = 'fish', position = p}
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
--Resource Spots
|
||||
if cave_rivers < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
local large_caves = get_perlin('large_caves', p, seed)
|
||||
if scrapyard_modified > -0.15 and scrapyard_modified < 0.15 then
|
||||
if floor(large_caves * 10) % 4 < 3 then
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
if random(1, 2) == 1 then
|
||||
entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p}
|
||||
end
|
||||
if random(1, 2048) == 1 then
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if random(1, 64) == 1 and cave_ponds > 0.6 then
|
||||
entities[#entities + 1] = {name = 'crude-oil', position = p, amount = get_oil_amount(p)}
|
||||
end
|
||||
|
||||
tiles[#tiles + 1] = {name = 'nuclear-ground', position = p}
|
||||
if random(1, 256) == 1 then
|
||||
entities[#entities + 1] = {name = 'land-mine', position = p, force = 'enemy'}
|
||||
end
|
||||
end
|
||||
|
||||
--SCRAPYARD
|
||||
local function process_zone_scrap_1(x, y, data, void_or_lab)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
local entities = data.entities
|
||||
local buildings = data.buildings
|
||||
local treasure = data.treasure
|
||||
data.scrap_zone = true
|
||||
|
||||
local scrapyard = get_perlin('scrapyard', p, seed)
|
||||
local smol_areas = get_perlin('smol_areas', p, seed + 35000)
|
||||
@ -1028,7 +1186,7 @@ local function process_scrap_zone_1(x, y, data, void_or_lab)
|
||||
entities[#entities + 1] = {
|
||||
name = scrap_entities_friendly[random(1, scrap_entities_friendly_index)],
|
||||
position = p,
|
||||
force = 'player'
|
||||
force = 'neutral'
|
||||
}
|
||||
end
|
||||
|
||||
@ -1058,7 +1216,7 @@ local function process_scrap_zone_1(x, y, data, void_or_lab)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1086,7 +1244,7 @@ local function process_scrap_zone_1(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_7_position(x, y, data, void_or_lab)
|
||||
local function generate_zone_7(x, y, data, void_or_lab)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -1190,7 +1348,7 @@ local function process_level_7_position(x, y, data, void_or_lab)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1203,7 +1361,7 @@ local function process_level_7_position(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_forest_zone_2(x, y, data, void_or_lab)
|
||||
local function generate_zone_forest_2(x, y, data, void_or_lab)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -1211,6 +1369,7 @@ local function process_forest_zone_2(x, y, data, void_or_lab)
|
||||
local buildings = data.buildings
|
||||
local markets = data.markets
|
||||
local treasure = data.treasure
|
||||
data.forest_zone = true
|
||||
|
||||
local large_caves = get_perlin('large_caves', p, seed)
|
||||
local cave_rivers = get_perlin('cave_rivers', p, seed)
|
||||
@ -1243,7 +1402,7 @@ local function process_forest_zone_2(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -1338,7 +1497,7 @@ local function process_forest_zone_2(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_5_position(x, y, data, void_or_lab)
|
||||
local function generate_zone_5(x, y, data, void_or_lab)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -1385,7 +1544,7 @@ local function process_level_5_position(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -1430,7 +1589,7 @@ local function process_level_5_position(x, y, data, void_or_lab)
|
||||
tiles[#tiles + 1] = {name = void_or_lab, position = p}
|
||||
end
|
||||
|
||||
local function process_level_4_position(x, y, data, void_or_lab)
|
||||
local function generate_zone_4(x, y, data, void_or_lab)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -1521,7 +1680,7 @@ local function process_level_4_position(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -1561,7 +1720,7 @@ local function process_level_4_position(x, y, data, void_or_lab)
|
||||
tiles[#tiles + 1] = {name = void_or_lab, position = p}
|
||||
end
|
||||
|
||||
local function process_level_3_position(x, y, data, void_or_lab)
|
||||
local function generate_zone_3(x, y, data, void_or_lab)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -1581,7 +1740,7 @@ local function process_level_3_position(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -1727,7 +1886,7 @@ local function process_level_3_position(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_2_position(x, y, data, void_or_lab)
|
||||
local function generate_zone_2(x, y, data, void_or_lab)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -1744,7 +1903,7 @@ local function process_level_2_position(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -1871,7 +2030,7 @@ local function process_level_2_position(x, y, data, void_or_lab)
|
||||
tiles[#tiles + 1] = {name = void_or_lab, position = p}
|
||||
end
|
||||
|
||||
local function process_forest_zone_1(x, y, data, void_or_lab)
|
||||
local function generate_zone_forest_1(x, y, data, void_or_lab)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local buildings = data.buildings
|
||||
@ -1879,6 +2038,7 @@ local function process_forest_zone_1(x, y, data, void_or_lab)
|
||||
local entities = data.entities
|
||||
local markets = data.markets
|
||||
local treasure = data.treasure
|
||||
data.forest_zone = true
|
||||
|
||||
local small_caves = get_perlin('dungeons', p, seed + 33322)
|
||||
local noise_cave_ponds = get_perlin('cave_ponds', p, seed)
|
||||
@ -1888,7 +2048,7 @@ local function process_forest_zone_1(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -2054,7 +2214,7 @@ local function process_forest_zone_1(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_1_position(x, y, data, void_or_lab)
|
||||
local function generate_zone_1(x, y, data, void_or_lab)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local buildings = data.buildings
|
||||
@ -2070,7 +2230,7 @@ local function process_level_1_position(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 32) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -2218,7 +2378,7 @@ local function process_level_1_position(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_0_position(x, y, data, void_or_lab)
|
||||
local function starting_zone(x, y, data, void_or_lab)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local buildings = data.buildings
|
||||
@ -2237,7 +2397,7 @@ local function process_level_0_position(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -2356,31 +2516,88 @@ local function process_level_0_position(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
Public.levels = {
|
||||
process_level_0_position,
|
||||
process_level_1_position,
|
||||
process_forest_zone_1, -- zone 3
|
||||
process_level_3_position,
|
||||
process_level_5_position,
|
||||
process_scrap_zone_1, -- zone 6
|
||||
process_level_9_position,
|
||||
process_level_4_position,
|
||||
process_level_2_position,
|
||||
process_level_3_position,
|
||||
process_forest_zone_2, -- zone 11
|
||||
process_level_4_position,
|
||||
process_level_5_position,
|
||||
process_forest_zone_2, -- zone 14
|
||||
process_level_7_position,
|
||||
process_scrap_zone_1, -- zone 16
|
||||
process_level_9_position,
|
||||
process_level_10_position,
|
||||
process_level_11_position,
|
||||
process_level_12_position,
|
||||
process_level_13_position,
|
||||
process_level_14_position
|
||||
local zones = {
|
||||
generate_zone_1,
|
||||
generate_zone_forest_1,
|
||||
generate_zone_3,
|
||||
generate_zone_5,
|
||||
generate_zone_11,
|
||||
generate_zone_forest_2,
|
||||
process_zone_scrap_1,
|
||||
process_zone_scrap_2,
|
||||
generate_zone_9,
|
||||
generate_zone_4,
|
||||
process_zone_scrap_1,
|
||||
generate_zone_2,
|
||||
generate_zone_3,
|
||||
process_zone_scrap_2,
|
||||
generate_zone_3,
|
||||
generate_zone_forest_2,
|
||||
generate_zone_4,
|
||||
generate_zone_forest_1,
|
||||
generate_zone_forest_2,
|
||||
generate_zone_2,
|
||||
generate_zone_4,
|
||||
process_zone_scrap_2,
|
||||
generate_zone_5,
|
||||
generate_zone_1,
|
||||
generate_zone_forest_2,
|
||||
generate_zone_7,
|
||||
process_zone_scrap_1,
|
||||
generate_zone_9,
|
||||
generate_zone_10,
|
||||
generate_zone_11,
|
||||
generate_zone_12,
|
||||
generate_zone_forest_2,
|
||||
process_zone_scrap_2,
|
||||
process_zone_scrap_1,
|
||||
generate_zone_11,
|
||||
generate_zone_12,
|
||||
process_zone_scrap_1,
|
||||
generate_zone_13,
|
||||
generate_zone_14,
|
||||
process_zone_scrap_1,
|
||||
generate_zone_forest_1,
|
||||
generate_zone_14,
|
||||
process_zone_scrap_2
|
||||
}
|
||||
|
||||
--[[ local zones_non_raffled = {
|
||||
generate_zone_1,
|
||||
generate_zone_2,
|
||||
generate_zone_3,
|
||||
generate_zone_4,
|
||||
generate_zone_5,
|
||||
generate_zone_forest_1,
|
||||
generate_zone_forest_2,
|
||||
process_zone_scrap_1,
|
||||
process_zone_scrap_2,
|
||||
generate_zone_7,
|
||||
generate_zone_9,
|
||||
generate_zone_11,
|
||||
generate_zone_10,
|
||||
generate_zone_11,
|
||||
generate_zone_12,
|
||||
generate_zone_13,
|
||||
generate_zone_14
|
||||
} ]]
|
||||
|
||||
zone_settings.size = #zones
|
||||
|
||||
local function shuffle_terrains(new_zone)
|
||||
local adjusted_zones = WPT.get('adjusted_zones')
|
||||
|
||||
if not adjusted_zones.shuffled_terrains then
|
||||
shuffle(zones)
|
||||
adjusted_zones.shuffled_terrains = new_zone
|
||||
end
|
||||
|
||||
-- if adjusted_zones.shuffled_terrains and adjusted_zones.shuffled_terrains ~= new_zone then
|
||||
-- table.shuffle_table(zones)
|
||||
-- adjusted_zones.shuffled_terrains = new_zone
|
||||
-- end
|
||||
end
|
||||
|
||||
local function is_out_of_map(p)
|
||||
if p.x < 480 and p.x >= -480 then
|
||||
return
|
||||
@ -2389,12 +2606,30 @@ local function is_out_of_map(p)
|
||||
end
|
||||
|
||||
local function process_bits(p, data)
|
||||
local levels = Public.levels
|
||||
local left_top_y = data.area.left_top.y
|
||||
local index = floor((abs(left_top_y / Public.level_depth)) % 22) + 1
|
||||
local process_level = levels[index]
|
||||
if not process_level then
|
||||
process_level = levels[#levels]
|
||||
local index = floor((abs(left_top_y / zone_settings.zone_depth)) % zone_settings.size) + 1
|
||||
shuffle_terrains(index)
|
||||
|
||||
local generate_zone
|
||||
if left_top_y >= -zone_settings.zone_depth then
|
||||
generate_zone = starting_zone
|
||||
else
|
||||
generate_zone = zones[index]
|
||||
if not generate_zone then
|
||||
generate_zone = zones[zone_settings.size]
|
||||
end
|
||||
end
|
||||
|
||||
data.current_zone = index
|
||||
|
||||
local adjusted_zones = WPT.get('adjusted_zones')
|
||||
|
||||
if data.forest_zone and not adjusted_zones.forest[index] then
|
||||
adjusted_zones.forest[index] = true
|
||||
end
|
||||
|
||||
if data.scrap_zone and not adjusted_zones.scrap[index] then
|
||||
adjusted_zones.scrap[index] = true
|
||||
end
|
||||
|
||||
local void_or_tile = WPT.get('void_or_tile')
|
||||
@ -2402,7 +2637,7 @@ local function process_bits(p, data)
|
||||
local x = p.x
|
||||
local y = p.y
|
||||
|
||||
process_level(x, y, data, void_or_tile)
|
||||
generate_zone(x, y, data, void_or_tile)
|
||||
end
|
||||
|
||||
local function border_chunk(p, data)
|
||||
@ -2508,8 +2743,8 @@ function Public.heavy_functions(data)
|
||||
return
|
||||
end
|
||||
|
||||
if top_y % Public.level_depth == 0 and top_y < 0 then
|
||||
WPT.set().left_top = data.left_top
|
||||
if top_y % zone_settings.zone_depth == 0 and top_y < 0 then
|
||||
WPT.set('left_top', data.left_top)
|
||||
return wall(p, data)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user