diff --git a/maps/mountain_fortress_v3/entities.lua b/maps/mountain_fortress_v3/entities.lua index dda86e40..1d573d12 100644 --- a/maps/mountain_fortress_v3/entities.lua +++ b/maps/mountain_fortress_v3/entities.lua @@ -289,7 +289,7 @@ local function protect_entities(data) local check_heavy_damage = Public.get('check_heavy_damage') if check_heavy_damage then - if entity.type == 'simple-entity' and dmg >= 500 then + if (entity.type == 'simple-entity' or entity.type == 'simple-entity-with-owner') and dmg >= 500 then entity.health = entity.health + dmg end end @@ -313,7 +313,7 @@ local function protect_entities(data) local carriages_numbers = Public.get('carriages_numbers') if is_protected(entity) then if (cause and cause.valid) then - if cause.force.index == 2 then + if Public.valid_enemy_forces[cause.force.name] then if carriages_numbers and carriages_numbers[entity.unit_number] then set_train_final_health(dmg, false) return @@ -323,7 +323,7 @@ local function protect_entities(data) end end elseif not (cause and cause.valid) then - if force and force.index == 2 then + if force and Public.valid_enemy_forces[force.name] then if carriages_numbers and carriages_numbers[entity.unit_number] then set_train_final_health(dmg, false) return @@ -743,7 +743,9 @@ local function on_player_mined_entity(event) give_coin(player) end else - give_coin(player) + if random(1, 6) == 1 then + give_coin(player) + end end if rpg_char.stone_path then entity.surface.set_tiles({{name = 'stone-path', position = entity.position}}, true) @@ -970,13 +972,14 @@ local function on_entity_died(event) on_entity_removed(d) local player + local valid_enemy_forces = Public.valid_enemy_forces if cause then if cause.valid then if (cause and cause.name == 'character' and cause.player) then player = cause.player end - if cause.force.index == 2 or cause.force.index == 3 then + if valid_enemy_forces[cause.force.name] or cause.force.index == 3 then entity.destroy() return end diff --git a/maps/mountain_fortress_v3/get_perlin.lua b/maps/mountain_fortress_v3/get_perlin.lua index 1bf0eb60..b3e2d963 100644 --- a/maps/mountain_fortress_v3/get_perlin.lua +++ b/maps/mountain_fortress_v3/get_perlin.lua @@ -4,102 +4,102 @@ local simplex_noise = require 'utils.simplex_noise'.d2 --add or use noise templates from here local noises = { ['bb_biterland'] = { - {modifier = 0.001, weight = 1}, - {modifier = 0.01, weight = 0.35}, - {modifier = 0.1, weight = 0.015} + {modifier = 0.0015, weight = 1.1}, + {modifier = 0.009, weight = 0.34}, + {modifier = 0.095, weight = 0.016} }, - ['bb_ore'] = {{modifier = 0.0042, weight = 1}, {modifier = 0.031, weight = 0.08}, {modifier = 0.1, weight = 0.025}}, - ['cave_ponds'] = {{modifier = 0.01, weight = 0.75}, {modifier = 0.15, weight = 0.08}}, - ['smol_areas'] = {{modifier = 0.005, weight = 0.85}, {modifier = 0.15, weight = 0.025}, {modifier = 0.15, weight = 0.035}}, - ['cave_worms'] = {{modifier = 0.001, weight = 1}, {modifier = 0.1, weight = 0.06}}, + ['bb_ore'] = {{modifier = 0.0046, weight = 0.95}, {modifier = 0.03, weight = 0.077}, {modifier = 0.09, weight = 0.023}}, + ['cave_ponds'] = {{modifier = 0.011, weight = 0.74}, {modifier = 0.14, weight = 0.079}}, + ['smol_areas'] = {{modifier = 0.0042, weight = 0.81}, {modifier = 0.129, weight = 0.021}, {modifier = 0.119, weight = 0.03}}, + ['cave_worms'] = {{modifier = 0.0011, weight = 0.99}, {modifier = 0.09, weight = 0.059}}, ['cave_rivers'] = { - {modifier = 0.007, weight = 0.75}, - {modifier = 0.0090, weight = 0.30}, - {modifier = 0.075, weight = 0.03} + {modifier = 0.0077, weight = 0.74}, + {modifier = 0.0089, weight = 0.29}, + {modifier = 0.072, weight = 0.028} }, ['cave_rivers_2'] = { - {modifier = 0.003, weight = 1}, - {modifier = 0.01, weight = 0.21}, - {modifier = 0.05, weight = 0.01} + {modifier = 0.0033, weight = 0.99}, + {modifier = 0.0099, weight = 0.2}, + {modifier = 0.049, weight = 0.009} }, ['cave_rivers_3'] = { - {modifier = 0.002, weight = 1}, - {modifier = 0.01, weight = 0.15}, - {modifier = 0.05, weight = 0.01} + {modifier = 0.0022, weight = 0.99}, + {modifier = 0.0099, weight = 0.14}, + {modifier = 0.049, weight = 0.009} }, ['cave_rivers_4'] = { - {modifier = 0.001, weight = 1}, - {modifier = 0.01, weight = 0.11}, - {modifier = 0.05, weight = 0.01} + {modifier = 0.0009, weight = 0.99}, + {modifier = 0.0099, weight = 0.1}, + {modifier = 0.049, weight = 0.009} }, - ['decoratives'] = {{modifier = 0.03, weight = 1}, {modifier = 0.05, weight = 0.25}, {modifier = 0.1, weight = 0.05}}, - ['dungeons'] = {{modifier = 0.003, weight = 1}, {modifier = 0.006, weight = 0.25}}, + ['decoratives'] = {{modifier = 0.031, weight = 1.05}, {modifier = 0.055, weight = 0.24}, {modifier = 0.11, weight = 0.055}}, + ['dungeons'] = {{modifier = 0.0033, weight = 1.05}, {modifier = 0.0066, weight = 0.24}}, ['dungeon_sewer'] = { - {modifier = 0.0005, weight = 1}, - {modifier = 0.005, weight = 0.015}, - {modifier = 0.025, weight = 0.0015} + {modifier = 0.00055, weight = 1.05}, + {modifier = 0.0055, weight = 0.014}, + {modifier = 0.0275, weight = 0.00135} }, ['large_caves'] = { - {modifier = 0.0033, weight = 1}, - {modifier = 0.01, weight = 0.22}, - {modifier = 0.05, weight = 0.05}, - {modifier = 0.1, weight = 0.04} + {modifier = 0.00363, weight = 1.05}, + {modifier = 0.01, weight = 0.23}, + {modifier = 0.055, weight = 0.045}, + {modifier = 0.11, weight = 0.042} }, - ['n1'] = {{modifier = 0.0001, weight = 1}}, - ['n2'] = {{modifier = 0.001, weight = 1}}, - ['n3'] = {{modifier = 0.01, weight = 1}}, - ['n4'] = {{modifier = 0.1, weight = 1}}, - ['n5'] = {{modifier = 0.07, weight = 1}}, + ['n1'] = {{modifier = 0.00011, weight = 1.1}}, + ['n2'] = {{modifier = 0.0011, weight = 1.1}}, + ['n3'] = {{modifier = 0.011, weight = 1.1}}, + ['n4'] = {{modifier = 0.11, weight = 1.1}}, + ['n5'] = {{modifier = 0.077, weight = 1.1}}, ['watery_world'] = { - {modifier = 0.0007, weight = 1}, - {modifier = 0.01, weight = 0.02}, - {modifier = 0.1, weight = 0.005} + {modifier = 0.00077, weight = 1.1}, + {modifier = 0.011, weight = 0.022}, + {modifier = 0.11, weight = 0.0055} }, ['no_rocks'] = { - {modifier = 0.0045, weight = 0.95}, - {modifier = 0.017, weight = 0.25}, - {modifier = 0.045, weight = 0.045}, - {modifier = 0.088, weight = 0.035} + {modifier = 0.00495, weight = 0.945}, + {modifier = 0.01665, weight = 0.2475}, + {modifier = 0.0435, weight = 0.0435}, + {modifier = 0.07968, weight = 0.0315} }, - ['no_rocks_2'] = {{modifier = 0.016, weight = 1.15}, {modifier = 0.13, weight = 0.095}}, + ['no_rocks_2'] = {{modifier = 0.0184, weight = 1.265}, {modifier = 0.143, weight = 0.1045}}, ['oasis'] = { - {modifier = 0.0015, weight = 1}, - {modifier = 0.0025, weight = 0.5}, - {modifier = 0.01, weight = 0.15}, - {modifier = 0.1, weight = 0.017} + {modifier = 0.00165, weight = 1.1}, + {modifier = 0.00275, weight = 0.55}, + {modifier = 0.011, weight = 0.165}, + {modifier = 0.11, weight = 0.0187} }, ['scrapyard'] = { - {modifier = 0.005, weight = 1}, - {modifier = 0.01, weight = 0.35}, - {modifier = 0.05, weight = 0.23}, - {modifier = 0.1, weight = 0.11} + {modifier = 0.0055, weight = 1.1}, + {modifier = 0.011, weight = 0.385}, + {modifier = 0.055, weight = 0.253}, + {modifier = 0.11, weight = 0.121} }, ['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} + {modifier = 0.0066, weight = 1.1}, + {modifier = 0.044, weight = 0.165}, + {modifier = 0.242, weight = 0.055}, + {modifier = 0.055, weight = 0.352} }, ['big_cave'] = { - {modifier = 0.003, weight = 1}, - {modifier = 0.02, weight = 0.05}, - {modifier = 0.15, weight = 0.02} + {modifier = 0.0033, weight = 1.1}, + {modifier = 0.022, weight = 0.055}, + {modifier = 0.165, weight = 0.022} }, ['small_caves'] = { - {modifier = 0.006, weight = 1}, - {modifier = 0.04, weight = 0.15}, - {modifier = 0.22, weight = 0.05} + {modifier = 0.0066, weight = 1.1}, + {modifier = 0.044, weight = 0.165}, + {modifier = 0.242, weight = 0.055} }, ['small_caves_2'] = { - {modifier = 0.009, weight = 1}, - {modifier = 0.05, weight = 0.25}, - {modifier = 0.25, weight = 0.05} + {modifier = 0.0099, weight = 1.1}, + {modifier = 0.055, weight = 0.275}, + {modifier = 0.275, weight = 0.055} }, ['forest_location'] = { - {modifier = 0.006, weight = 1}, - {modifier = 0.01, weight = 0.25}, - {modifier = 0.05, weight = 0.15}, - {modifier = 0.1, weight = 0.05} + {modifier = 0.0066, weight = 1.1}, + {modifier = 0.011, weight = 0.275}, + {modifier = 0.055, weight = 0.165}, + {modifier = 0.11, weight = 0.0825} }, ['forest_density'] = { {modifier = 0.01, weight = 1}, diff --git a/maps/mountain_fortress_v3/icw/functions.lua b/maps/mountain_fortress_v3/icw/functions.lua index eabf8730..2c732234 100644 --- a/maps/mountain_fortress_v3/icw/functions.lua +++ b/maps/mountain_fortress_v3/icw/functions.lua @@ -35,7 +35,7 @@ local reconstruct_all_trains = local function get_tile_name() -- local main_tile_name = 'tutorial-grid' - local main_tile_name = 'black-refined-concrete' + local main_tile_name = 'stone-path' return main_tile_name end diff --git a/maps/mountain_fortress_v3/locomotive.lua b/maps/mountain_fortress_v3/locomotive.lua index 85574855..5b6c0ea4 100644 --- a/maps/mountain_fortress_v3/locomotive.lua +++ b/maps/mountain_fortress_v3/locomotive.lua @@ -49,7 +49,7 @@ local function add_random_loot_to_main_market(rarity) end end - for k, v in pairs(items) do + for _, v in pairs(items) do local price = v.price[1][2] + random(1, 15) * rarity local value = v.price[1][1] local stack = 1 diff --git a/maps/mountain_fortress_v3/locomotive/spawn_locomotive.lua b/maps/mountain_fortress_v3/locomotive/spawn_locomotive.lua index 8779c80c..89c76004 100644 --- a/maps/mountain_fortress_v3/locomotive/spawn_locomotive.lua +++ b/maps/mountain_fortress_v3/locomotive/spawn_locomotive.lua @@ -8,35 +8,47 @@ local random = math.random local function initial_cargo_boxes() return { - {name = 'loader', count = 2}, + {name = 'loader', count = 1}, + {name = 'stone-furnace', count = 2}, {name = 'coal', count = random(32, 64)}, {name = 'coal', count = random(32, 64)}, + {name = 'loader', count = 1}, {name = 'iron-ore', count = random(32, 128)}, {name = 'copper-ore', count = random(32, 128)}, - {name = 'empty-barrel', count = random(16, 32)}, - {name = 'submachine-gun', count = 1}, + {name = 'submachine-gun', count = 1}, + {name = 'loader', count = 1}, {name = 'submachine-gun', count = 1}, {name = 'submachine-gun', count = 1}, + {name = 'stone-furnace', count = 2}, {name = 'submachine-gun', count = 1}, {name = 'submachine-gun', count = 1}, + {name = 'loader', count = 1}, {name = 'submachine-gun', count = 1}, + {name = 'automation-science-pack', count = random(4, 32)}, {name = 'submachine-gun', count = 1}, + {name = 'stone-wall', count = random(4, 32)}, {name = 'shotgun', count = 1}, {name = 'shotgun', count = 1}, {name = 'shotgun', count = 1}, + {name = 'stone-wall', count = random(4, 32)}, {name = 'gun-turret', count = 1}, {name = 'gun-turret', count = 1}, {name = 'gun-turret', count = 1}, + {name = 'gun-turret', count = 1}, + {name = 'stone-wall', count = random(4, 32)}, {name = 'shotgun-shell', count = random(4, 5)}, {name = 'shotgun-shell', count = random(4, 5)}, {name = 'shotgun-shell', count = random(4, 5)}, + {name = 'gun-turret', count = 1}, {name = 'land-mine', count = random(6, 18)}, {name = 'grenade', count = random(2, 7)}, {name = 'grenade', count = random(2, 8)}, + {name = 'gun-turret', count = 1}, {name = 'grenade', count = random(2, 7)}, {name = 'light-armor', count = random(2, 4)}, {name = 'iron-gear-wheel', count = random(7, 15)}, {name = 'iron-gear-wheel', count = random(7, 15)}, + {name = 'gun-turret', count = 1}, {name = 'iron-gear-wheel', count = random(7, 15)}, {name = 'iron-gear-wheel', count = random(7, 15)}, {name = 'iron-plate', count = random(15, 23)}, @@ -72,7 +84,7 @@ local set_loco_tiles = ---@diagnostic disable-next-line: count-down-loop for x = position.x - 5, 1, 3 do for y = 1, position.y + 5, 2 do - if random(1, 4) == 1 then + if random(1, 3) == 1 then p[#p + 1] = {x = x, y = y} end end @@ -94,10 +106,10 @@ local set_loco_tiles = if not p[i] then break end - local name = 'wooden-chest' + local name = 'crash-site-chest-1' if random(1, 3) == 1 then - name = 'iron-chest' + name = 'crash-site-chest-2' end if surface.can_place_entity({name = name, position = p[i]}) then local e = surface.create_entity({name = name, position = p[i], force = 'player', create_build_effect_smoke = false}) @@ -125,7 +137,7 @@ function Public.locomotive_spawn(surface, position) rendering.draw_light( { sprite = 'utility/light_medium', - scale = 5.5, + scale = 6.5, intensity = 1, minimum_darkness = 0, oriented = true, @@ -168,7 +180,7 @@ function Public.locomotive_spawn(surface, position) local scale = random(50, 100) * 0.01 rendering.draw_sprite( { - sprite = 'item/raw-fish', + sprite = 'entity/small-biter', orientation = random(0, 100) * 0.01, x_scale = scale, y_scale = scale, @@ -181,7 +193,7 @@ function Public.locomotive_spawn(surface, position) ) end - this.locomotive.color = {0, 255, random(60, 255)} + this.locomotive.color = {random(2, 255), random(60, 255), random(60, 255)} this.locomotive.minable = false this.locomotive_cargo.minable = false this.locomotive_cargo.operable = true diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index 88da13ed..9ae79e0c 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -52,7 +52,6 @@ local role_to_mention = Discord.role_mentions.mtn_fortress local floor = math.floor local remove = table.remove -local random = math.random RPG.disable_cooldowns_on_spells() local collapse_kill = { @@ -126,6 +125,8 @@ function Public.reset_map() Misc.set('creative_are_you_sure', false) Misc.set('creative_enabled', false) + Event.raise(WD.events.on_game_reset, {}) + this.active_surface_index = Public.create_surface() -- this.soft_reset_counter = Public.get_reset_counter() @@ -264,7 +265,6 @@ function Public.reset_map() WD.increase_average_unit_group_size(true) WD.increase_max_active_unit_groups(true) WD.enable_random_spawn_positions(true) - WD.set_pause_wave_in_ticks(random(18000, 54000)) Public.set_difficulty() Public.disable_creative() diff --git a/maps/mountain_fortress_v3/resource_generator.lua b/maps/mountain_fortress_v3/resource_generator.lua index 65999626..88724a3c 100644 --- a/maps/mountain_fortress_v3/resource_generator.lua +++ b/maps/mountain_fortress_v3/resource_generator.lua @@ -410,7 +410,7 @@ local testing_callback = { loot = testing_loot, weights = testing_weights, testing = true, - destructible = true + destructible = false } } @@ -419,7 +419,7 @@ local science_callback = { data = { loot = science_loot, weights = science_weights, - destructible = true + destructible = false } } @@ -428,7 +428,7 @@ local building_callback = { data = { loot = ammo_loot, weights = building_weights, - destructible = true + destructible = false } } @@ -437,7 +437,7 @@ local oil_callback = { data = { loot = oil_loot, weights = oil_weights, - destructible = true + destructible = false } } @@ -446,7 +446,7 @@ local oil_prod_callback = { data = { loot = oil_prod_loot, weights = oil_prod_weights, - destructible = true + destructible = false } } @@ -455,7 +455,7 @@ local resource_callback = { data = { loot = resource_loot, weights = resource_weights, - destructible = true + destructible = false } } @@ -464,7 +464,7 @@ local furnace_callback = { data = { loot = furnace_loot, weights = furnace_weights, - destructible = true + destructible = false } } diff --git a/maps/mountain_fortress_v3/table.lua b/maps/mountain_fortress_v3/table.lua index c39a78f8..11103a96 100644 --- a/maps/mountain_fortress_v3/table.lua +++ b/maps/mountain_fortress_v3/table.lua @@ -7,6 +7,7 @@ local this = { traps = {} } local Public = {} +local random = math.random Public.events = { reset_map = Event.generate_event_name('reset_map'), @@ -25,6 +26,12 @@ Public.zone_settings = { zone_width = 510 } +Public.valid_enemy_forces = { + ['enemy'] = true, + ['aggressors'] = true, + ['aggressors_frenzy'] = true +} + Public.pickaxe_upgrades = { 'Wood', 'Plastic', @@ -226,6 +233,7 @@ function Public.reset_main_table() this.check_afk_players = true this.winter_mode = false this.sent_to_discord = false + this.random_seed = random(23849829, 1283989182) this.difficulty = { multiply = 0.25, highest = 10, diff --git a/maps/mountain_fortress_v3/terrain.lua b/maps/mountain_fortress_v3/terrain.lua index f7d7dc10..528bf8fd 100644 --- a/maps/mountain_fortress_v3/terrain.lua +++ b/maps/mountain_fortress_v3/terrain.lua @@ -9,14 +9,21 @@ local ceil = math.ceil local zone_settings = Public.zone_settings local worm_level_modifier = 0.19 +local base_tile = 'grass-1' local start_ground_tiles = { - 'sand-1', - 'dirt-1', - 'dirt-2', + 'grass-1', + 'grass-1', + 'grass-2', 'sand-2', - 'dirt-3', - 'sand-3' + 'grass-1', + 'grass-4', + 'sand-2', + 'grass-3', + 'grass-4', + 'grass-2', + 'sand-3', + 'grass-4' } local wagon_raffle = { @@ -243,7 +250,7 @@ local function place_wagon(data, adjusted_zones) end for _, tile in pairs(location) do - tiles[#tiles + 1] = {name = 'nuclear-ground', position = tile.position} + tiles[#tiles + 1] = {name = base_tile, position = tile.position} if tile.position.y % 1 == 0 and tile.position.x % 1 == 0 then entities[#entities + 1] = { name = 'straight-rail', @@ -295,8 +302,8 @@ local function wall(p, data) local seed = data.seed local y = data.yv - local small_caves = Public.get_noise('small_caves', p, seed + 204000) - local cave_ponds = Public.get_noise('cave_rivers', p, seed + 120400) + local small_caves = Public.get_noise('small_caves', p, seed + seed) + local cave_ponds = Public.get_noise('cave_rivers', p, seed + seed) if y > 9 + cave_ponds * 6 and y < 23 + small_caves * 6 then if small_caves > 0.02 or cave_ponds > 0.02 then if small_caves > 0.005 then @@ -315,7 +322,7 @@ local function wall(p, data) entities[#entities + 1] = {name = 'fish', position = p} end else - tiles[#tiles + 1] = {name = 'nuclear-ground', position = p} + tiles[#tiles + 1] = {name = base_tile, position = p} if random(1, 5) ~= 1 then entities[#entities + 1] = {name = rock_raffle[random(1, #rock_raffle)], position = p} @@ -329,7 +336,7 @@ local function wall(p, data) end end else - tiles[#tiles + 1] = {name = 'nuclear-ground', position = p} + tiles[#tiles + 1] = {name = base_tile, position = p} if surface.can_place_entity( @@ -485,7 +492,7 @@ local function zone_14(x, y, data, _, adjusted_zones) local small_caves = Public.get_noise('small_caves', p, seed) local noise_cave_ponds = Public.get_noise('cave_ponds', p, seed) - local smol_areas = Public.get_noise('smol_areas', p, seed + 40000) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) --Resource Spots if smol_areas < -0.71 then @@ -565,7 +572,7 @@ local function zone_13(x, y, data, _, adjusted_zones) local small_caves = Public.get_noise('small_caves', p, seed) local noise_cave_ponds = Public.get_noise('cave_ponds', p, seed) - local smol_areas = Public.get_noise('smol_areas', p, seed + 70000) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) --Resource Spots if smol_areas < -0.72 then @@ -645,8 +652,8 @@ local function zone_12(x, y, data, void_or_lab, adjusted_zones) local treasure = data.treasure local noise_1 = Public.get_noise('small_caves', p, seed) - local noise_2 = Public.get_noise('no_rocks_2', p, seed + 20000) - local smol_areas = Public.get_noise('smol_areas', p, seed + 60000) + local noise_2 = Public.get_noise('no_rocks_2', p, seed + seed) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) --Resource Spots if smol_areas < -0.72 then @@ -731,8 +738,8 @@ local function zone_11(x, y, data, _, adjusted_zones) local treasure = data.treasure local noise_1 = Public.get_noise('small_caves', p, seed) - local noise_2 = Public.get_noise('no_rocks_2', p, seed + 10000) - local smol_areas = Public.get_noise('smol_areas', p, seed + 50000) + local noise_2 = Public.get_noise('no_rocks_2', p, seed + seed) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) if noise_1 > 0.7 then tiles[#tiles + 1] = {name = 'water', position = p} @@ -827,7 +834,7 @@ local function zone_10(x, y, data, _, adjusted_zones) data.forest_zone = true local scrapyard = Public.get_noise('scrapyard', p, seed) - local smol_areas = Public.get_noise('smol_areas', p, seed + 45000) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) if scrapyard < -0.70 or scrapyard > 0.70 then tiles[#tiles + 1] = {name = 'grass-3', position = p} @@ -943,7 +950,7 @@ local function zone_9(x, y, data, _, adjusted_zones) local maze_p = {x = floor(p.x - p.x % 10), y = floor(p.y - p.y % 10)} local maze_noise = Public.get_noise('no_rocks_2', maze_p, seed) - local smol_areas = Public.get_noise('smol_areas', p, seed + 40000) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) if maze_noise > -0.35 and maze_noise < 0.35 then tiles[#tiles + 1] = {name = 'dirt-7', position = p} @@ -1015,7 +1022,7 @@ local function zone_scrap_2(x, y, data, void_or_lab, adjusted_zones) data.scrap_zone = true local scrapyard_modified = Public.get_noise('scrapyard_modified', p, seed) - local cave_rivers = Public.get_noise('cave_rivers', p, seed + 65030) + local cave_rivers = Public.get_noise('cave_rivers', p, seed + seed) --Chasms local noise_cave_ponds = Public.get_noise('cave_ponds', p, seed) @@ -1127,7 +1134,7 @@ local function zone_scrap_2(x, y, data, void_or_lab, adjusted_zones) entities[#entities + 1] = {name = 'crude-oil', position = p, amount = get_oil_amount(p)} end - tiles[#tiles + 1] = {name = 'nuclear-ground', position = p} + tiles[#tiles + 1] = {name = base_tile, position = p} if random(1, 256) == 1 then entities[#entities + 1] = {name = 'land-mine', position = p, force = 'enemy'} end @@ -1144,7 +1151,7 @@ local function zone_scrap_1(x, y, data, void_or_lab, adjusted_zones) data.scrap_zone = true local scrapyard = Public.get_noise('scrapyard', p, seed) - local smol_areas = Public.get_noise('smol_areas', p, seed + 35000) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) --Chasms local noise_cave_ponds = Public.get_noise('cave_ponds', p, seed) @@ -1272,9 +1279,9 @@ local function zone_7(x, y, data, void_or_lab, adjusted_zones) local treasure = data.treasure local cave_rivers_3 = Public.get_noise('cave_rivers_3', p, seed) - local cave_rivers_4 = Public.get_noise('cave_rivers_4', p, seed + 50000) + local cave_rivers_4 = Public.get_noise('cave_rivers_4', p, seed + seed) local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed) - local smol_areas = Public.get_noise('smol_areas', p, seed + 30000) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) if cave_rivers_3 > -0.025 and cave_rivers_3 < 0.025 and no_rocks_2 > -0.6 then tiles[#tiles + 1] = {name = 'water', position = p} @@ -1292,7 +1299,7 @@ local function zone_7(x, y, data, void_or_lab, adjusted_zones) return end - local noise_ores = Public.get_noise('no_rocks_2', p, seed + 25000) + local noise_ores = Public.get_noise('no_rocks_2', p, seed + seed) if cave_rivers_3 > -0.20 and cave_rivers_3 < 0.20 then tiles[#tiles + 1] = {name = 'grass-' .. floor(cave_rivers_3 * 32) % 3 + 1, position = p} @@ -1391,7 +1398,7 @@ local function zone_forest_2(x, y, data, void_or_lab, adjusted_zones) local large_caves = Public.get_noise('large_caves', p, seed) local cave_rivers = Public.get_noise('cave_rivers', p, seed) - local smol_areas = Public.get_noise('smol_areas', p, seed + 25000) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) --Chasms local noise_cave_ponds = Public.get_noise('cave_ponds', p, seed) @@ -1525,7 +1532,7 @@ local function zone_5(x, y, data, void_or_lab, adjusted_zones) local small_caves = Public.get_noise('small_caves', p, seed) local noise_cave_ponds = Public.get_noise('cave_ponds', p, seed) - local smol_areas = Public.get_noise('smol_areas', p, seed + 20000) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) if small_caves > -0.24 and small_caves < 0.24 then tiles[#tiles + 1] = {name = 'dirt-7', position = p} @@ -1619,7 +1626,7 @@ local function zone_4(x, y, data, void_or_lab, adjusted_zones) local noise_large_caves = Public.get_noise('large_caves', p, seed) local noise_cave_ponds = Public.get_noise('cave_ponds', p, seed) local small_caves = Public.get_noise('dungeons', p, seed) - local smol_areas = Public.get_noise('smol_areas', p, seed + 15000) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) if abs(noise_large_caves) > 0.7 then tiles[#tiles + 1] = {name = 'water', position = p} @@ -1715,7 +1722,7 @@ local function zone_4(x, y, data, void_or_lab, adjusted_zones) if noise_large_caves > -0.2 and noise_large_caves < 0.2 then --Main Rock Terrain - local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed + 75000) + local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed + seed) if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then tiles[#tiles + 1] = {name = 'dirt-' .. floor(no_rocks_2 * 8) % 2 + 5, position = p} if random(1, 512) == 1 then @@ -1747,12 +1754,12 @@ local function zone_3(x, y, data, void_or_lab, adjusted_zones) local markets = data.markets local treasure = data.treasure - local small_caves = Public.get_noise('dungeons', p, seed + 50000) - local small_caves_2 = Public.get_noise('small_caves_2', p, seed + 70000) - local noise_large_caves = Public.get_noise('large_caves', p, seed + 60000) + local small_caves = Public.get_noise('dungeons', p, seed + seed) + local small_caves_2 = Public.get_noise('small_caves_2', p, seed + seed) + local noise_large_caves = Public.get_noise('large_caves', p, seed + seed) local noise_cave_ponds = Public.get_noise('cave_ponds', p, seed) local cave_miner = Public.get_noise('cave_miner_01', p, seed) - local smol_areas = Public.get_noise('smol_areas', p, seed + 60000) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) --Resource Spots if smol_areas < 0.055 and smol_areas > -0.025 then @@ -1815,7 +1822,7 @@ local function zone_3(x, y, data, void_or_lab, adjusted_zones) end --Rivers - local cave_rivers = Public.get_noise('cave_rivers', p, seed + 100000) + local cave_rivers = Public.get_noise('cave_rivers', p, seed + seed) if cave_rivers < 0.024 and cave_rivers > -0.024 then if noise_cave_ponds > 0.2 then tiles[#tiles + 1] = {name = 'water-shallow', position = p} @@ -1841,7 +1848,7 @@ local function zone_3(x, y, data, void_or_lab, adjusted_zones) return end - local no_rocks = Public.get_noise('no_rocks', p, seed + 25000) + local no_rocks = Public.get_noise('no_rocks', p, seed + seed) --Worm oil Zones if no_rocks < 0.20 and no_rocks > -0.20 then if small_caves > 0.35 then @@ -1873,7 +1880,7 @@ local function zone_3(x, y, data, void_or_lab, adjusted_zones) end --Main Rock Terrain - local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed + 75000) + local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed + seed) if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then local success = place_wagon(data, adjusted_zones) if success then @@ -1915,7 +1922,7 @@ local function zone_2(x, y, data, void_or_lab, adjusted_zones) local small_caves = Public.get_noise('dungeons', p, seed) local noise_large_caves = Public.get_noise('large_caves', p, seed) - local smol_areas = Public.get_noise('smol_areas', p, seed + 15000) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) --Resource Spots if smol_areas < 0.055 and smol_areas > -0.025 then @@ -1961,7 +1968,7 @@ local function zone_2(x, y, data, void_or_lab, adjusted_zones) end --Rivers - local cave_rivers = Public.get_noise('cave_rivers', p, seed + 100000) + local cave_rivers = Public.get_noise('cave_rivers', p, seed + seed) if cave_rivers < 0.037 and cave_rivers > -0.037 then if noise_cave_ponds < 0.1 then tiles[#tiles + 1] = {name = 'water-shallow', position = p} @@ -1989,7 +1996,7 @@ local function zone_2(x, y, data, void_or_lab, adjusted_zones) return end - local no_rocks = Public.get_noise('no_rocks', p, seed + 25000) + local no_rocks = Public.get_noise('no_rocks', p, seed + seed) --Worm oil Zones if no_rocks < 0.20 and no_rocks > -0.20 then if small_caves > 0.30 then @@ -2021,7 +2028,7 @@ local function zone_2(x, y, data, void_or_lab, adjusted_zones) end --Main Rock Terrain - local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed + 75000) + local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed + seed) if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then local success = place_wagon(data, adjusted_zones) if success then @@ -2058,9 +2065,9 @@ local function zone_forest_1(x, y, data, void_or_lab, adjusted_zones) local treasure = data.treasure data.forest_zone = true - local small_caves = Public.get_noise('dungeons', p, seed + 33322) + local small_caves = Public.get_noise('dungeons', p, seed + seed) local noise_cave_ponds = Public.get_noise('cave_ponds', p, seed) - local smol_areas = Public.get_noise('smol_areas', p, seed + 33333) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) --Resource Spots if smol_areas < 0.055 and smol_areas > -0.025 then @@ -2112,7 +2119,7 @@ local function zone_forest_1(x, y, data, void_or_lab, adjusted_zones) end --Rivers - local cave_rivers = Public.get_noise('cave_rivers', p, seed + 200000) + local cave_rivers = Public.get_noise('cave_rivers', p, seed + seed) if cave_rivers < 0.041 and cave_rivers > -0.042 then if noise_cave_ponds > 0 then tiles[#tiles + 1] = {name = 'water-shallow', position = p} @@ -2134,7 +2141,7 @@ local function zone_forest_1(x, y, data, void_or_lab, adjusted_zones) return end - local no_rocks = Public.get_noise('no_rocks', p, seed + 30000) + local no_rocks = Public.get_noise('no_rocks', p, seed + seed) --Worm oil Zones if p.y < -64 + noise_cave_ponds * 10 then if no_rocks < 0.11 and no_rocks > -0.11 then @@ -2165,13 +2172,13 @@ local function zone_forest_1(x, y, data, void_or_lab, adjusted_zones) end --Main Rock Terrain - local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed + 5000) + local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed + seed) if no_rocks_2 > 0.64 or no_rocks_2 < -0.64 then local success = place_wagon(data, adjusted_zones) if success then return end - tiles[#tiles + 1] = {name = 'nuclear-ground', position = p} + tiles[#tiles + 1] = {name = base_tile, position = p} if random(1, 32) == 1 then entities[#entities + 1] = {name = 'tree-0' .. random(1, 9), position = p} end @@ -2294,7 +2301,7 @@ local function zone_1(x, y, data, void_or_lab, adjusted_zones) end --Rivers - local cave_rivers = Public.get_noise('cave_rivers', p, seed + 300000) + local cave_rivers = Public.get_noise('cave_rivers', p, seed + seed) if cave_rivers < 0.042 and cave_rivers > -0.042 then if noise_cave_ponds > 0 then tiles[#tiles + 1] = {name = 'water-shallow', position = p} @@ -2316,7 +2323,7 @@ local function zone_1(x, y, data, void_or_lab, adjusted_zones) return end - local no_rocks = Public.get_noise('no_rocks', p, seed + 50000) + local no_rocks = Public.get_noise('no_rocks', p, seed + seed) --Worm oil Zones if p.y < -64 + noise_cave_ponds * 10 then if no_rocks < 0.12 and no_rocks > -0.12 then @@ -2347,13 +2354,13 @@ local function zone_1(x, y, data, void_or_lab, adjusted_zones) end --Main Rock Terrain - local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed + 75000) + local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed + seed) if no_rocks_2 > 0.66 or no_rocks_2 < -0.66 then local success = place_wagon(data, adjusted_zones) if success then return end - tiles[#tiles + 1] = {name = 'nuclear-ground', position = p} + tiles[#tiles + 1] = {name = base_tile, position = p} if random(1, 32) == 1 then entities[#entities + 1] = {name = 'tree-0' .. random(1, 9), position = p} end @@ -2371,7 +2378,7 @@ local function zone_1(x, y, data, void_or_lab, adjusted_zones) if random_tiles > 0.095 then if random_tiles > 0.6 then if random(1, 100) > 42 then - tiles[#tiles + 1] = {name = 'nuclear-ground', position = p} + tiles[#tiles + 1] = {name = base_tile, position = p} end else if random(1, 100) > 42 then @@ -2383,7 +2390,7 @@ local function zone_1(x, y, data, void_or_lab, adjusted_zones) if random_tiles < -0.095 then if random_tiles < -0.6 then if random(1, 100) > 42 then - tiles[#tiles + 1] = {name = 'nuclear-ground', position = p} + tiles[#tiles + 1] = {name = base_tile, position = p} end else if random(1, 100) > 42 then @@ -2405,10 +2412,10 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones) local markets = data.markets local treasure = data.treasure - local small_caves = Public.get_noise('dungeons', p, seed + 34883) - local noise_cave_ponds = Public.get_noise('cave_ponds', p, seed + 28939) - local smol_areas = Public.get_noise('smol_areas', p, seed + 3992) - local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed + 1922) + local small_caves = Public.get_noise('dungeons', p, seed + seed) + local noise_cave_ponds = Public.get_noise('cave_ponds', p, seed + seed) + local smol_areas = Public.get_noise('smol_areas', p, seed + seed) + local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed + seed) local cave_rivers = Public.get_noise('cave_rivers', p, seed) local no_rocks = Public.get_noise('no_rocks', p, seed) @@ -2514,7 +2521,7 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones) if success then return end - tiles[#tiles + 1] = {name = 'nuclear-ground', position = p} + tiles[#tiles + 1] = {name = base_tile, position = p} if random(1, 18) == 1 then entities[#entities + 1] = {name = 'tree-0' .. random(1, 9), position = p} end @@ -2528,7 +2535,7 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones) if random(1, 2048) == 1 then treasure[#treasure + 1] = {position = p, chest = 'iron-chest'} end - tiles[#tiles + 1] = {name = 'nuclear-ground', position = p} + tiles[#tiles + 1] = {name = base_tile, position = p} if random(1, 100) > 25 then entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p} end @@ -2650,8 +2657,8 @@ local function border_chunk(p, data) entities[#entities + 1] = {name = trees[random(1, #trees)], position = pos} end - local noise = Public.get_noise('dungeons', pos, data.seed) - local index = floor(noise * 32) % 4 + 1 + local noise = Public.get_noise('dungeon_sewer', pos, data.seed) + local index = floor(noise * 32) % 11 + 1 tiles[#tiles + 1] = {name = start_ground_tiles[index], position = pos} local scrap_mineable_entities, scrap_mineable_entities_index = get_scrap_mineable_entities() @@ -2738,7 +2745,7 @@ function Public.heavy_functions(data) end if not data.seed then - data.seed = surface.map_gen_settings.seed + data.seed = Public.get('random_seed') end if get_tile.valid and get_tile.name == 'out-of-map' then diff --git a/modules/biter_health_booster_v2.lua b/modules/biter_health_booster_v2.lua index bbc6fa67..24ee69fe 100644 --- a/modules/biter_health_booster_v2.lua +++ b/modules/biter_health_booster_v2.lua @@ -240,6 +240,9 @@ end local function set_boss_healthbar(health, max_health, healthbar_id) local m = health / max_health + if m < 0 then + return + end local x_scale = rendering.get_y_scale(healthbar_id) * 15 rendering.set_x_scale(healthbar_id, x_scale * m) rendering.set_color(healthbar_id, {floor(255 - 255 * m), floor(200 * m), 0}) diff --git a/modules/rpg/functions.lua b/modules/rpg/functions.lua index 25530771..ef14071f 100644 --- a/modules/rpg/functions.lua +++ b/modules/rpg/functions.lua @@ -166,7 +166,7 @@ local function level_up(player) Public.level_up_effects(player) end -local function has_health_boost(entity, damage, final_damage_amount, cause) +local function has_health_boost(entity, damage, final_damage_amount, cause, callback_func) local biter_health_boost = BiterHealthBooster.get('biter_health_boost') local biter_health_boost_units = BiterHealthBooster.get('biter_health_boost_units') @@ -194,7 +194,9 @@ local function has_health_boost(entity, damage, final_damage_amount, cause) if health_pool[1] <= 0 then local entity_number = entity.unit_number - entity.die(entity.force.name, cause) + if not callback_func then + entity.die(entity.force.name, cause) + end if biter_health_boost_units[entity_number] then biter_health_boost_units[entity_number] = nil @@ -204,7 +206,9 @@ local function has_health_boost(entity, damage, final_damage_amount, cause) entity.health = entity.health + final_damage_amount entity.health = entity.health - damage if entity.health <= 0 then - entity.die(cause.force.name, cause) + if not callback_func then + entity.die(cause.force.name, cause) + end end end else @@ -212,7 +216,9 @@ local function has_health_boost(entity, damage, final_damage_amount, cause) entity.health = entity.health + final_damage_amount entity.health = entity.health - damage if entity.health <= 0 then - entity.die(cause.force.name, cause) + if not callback_func then + entity.die(cause.force.name, cause) + end end end @@ -642,18 +648,18 @@ function Public.log_aoe_punch(callback) end --Melee damage modifier -function Public.aoe_punch(character, target, damage, get_health_pool) +function Public.aoe_punch(entity, target, damage, get_health_pool) if not (target and target.valid) then return end - local base_vector = {target.position.x - character.position.x, target.position.y - character.position.y} + local base_vector = {target.position.x - entity.position.x, target.position.y - entity.position.y} local vector = {base_vector[1], base_vector[2]} vector[1] = vector[1] * 1000 vector[2] = vector[2] * 1000 - character.surface.create_entity({name = 'blood-explosion-huge', position = target.position}) + entity.surface.create_entity({name = 'blood-explosion-huge', position = target.position}) if abs(vector[1]) > abs(vector[2]) then local d = abs(vector[1]) @@ -678,8 +684,8 @@ function Public.aoe_punch(character, target, damage, get_health_pool) local a = 0.20 - local cs = character.surface - local cp = character.position + local cs = entity.surface + local cp = entity.position for i = 1, 16, 1 do for x = i * -1 * a, i * a, 1 do @@ -690,7 +696,7 @@ function Public.aoe_punch(character, target, damage, get_health_pool) if e.valid then if e.health then if e.destructible and e.minable and e.force.index ~= 3 then - if e.force.index ~= character.force.index then + if e.force.index ~= entity.force.index then if get_health_pool then local max_unit_health = floor(get_health_pool * 0.00015) if max_unit_health <= 0 then @@ -700,15 +706,15 @@ function Public.aoe_punch(character, target, damage, get_health_pool) max_unit_health = 10 end local final = floor(damage * max_unit_health) - set_health_boost(e, final, character) + set_health_boost(e, final, entity) if e.valid and e.health <= 0 and get_health_pool <= 0 then - e.die(e.force.name, character) + e.die(e.force.name, entity) end else if e.valid then e.health = e.health - damage * 0.05 if e.health <= 0 then - e.die(e.force.name, character) + e.die(e.force.name, entity) end end end