mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-07 13:31:40 +02:00
Merge branch 'develop' into develop
This commit is contained in:
commit
815eac9ee7
@ -15,6 +15,7 @@ require 'utils.datastore.color_data'
|
||||
require 'utils.datastore.session_data'
|
||||
require 'utils.datastore.jail_data'
|
||||
require 'utils.datastore.quickbar_data'
|
||||
require 'utils.datastore.warning_on_join_data'
|
||||
require 'utils.datastore.message_on_join_data'
|
||||
require 'utils.datastore.player_tag_data'
|
||||
require 'utils.datastore.supporters'
|
||||
|
@ -9,17 +9,17 @@ local random = math.random
|
||||
local coin_yield = {
|
||||
['behemoth-biter'] = 5,
|
||||
['behemoth-spitter'] = 5,
|
||||
['behemoth-worm-turret'] = 20,
|
||||
['behemoth-worm-turret'] = 10,
|
||||
['big-biter'] = 3,
|
||||
['big-spitter'] = 3,
|
||||
['big-worm-turret'] = 16,
|
||||
['biter-spawner'] = 32,
|
||||
['medium-biter'] = 2,
|
||||
['medium-spitter'] = 2,
|
||||
['medium-worm-turret'] = 12,
|
||||
['medium-worm-turret'] = 4,
|
||||
['small-biter'] = 1,
|
||||
['small-spitter'] = 1,
|
||||
['small-worm-turret'] = 8,
|
||||
['small-worm-turret'] = 2,
|
||||
['spitter-spawner'] = 32
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ local function on_entity_died(event)
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
if entity.force.index ~= 2 then
|
||||
if not Public.valid_enemy_forces[entity.force.name] then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -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
|
||||
@ -742,6 +742,10 @@ local function on_player_mined_entity(event)
|
||||
if random(1, 3) == 1 then
|
||||
give_coin(player)
|
||||
end
|
||||
elseif entity.type == 'simple-entity-with-owner' then
|
||||
if random(1, 6) == 1 then
|
||||
give_coin(player)
|
||||
end
|
||||
else
|
||||
give_coin(player)
|
||||
end
|
||||
@ -970,13 +974,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
|
||||
|
@ -853,6 +853,18 @@ local boost_movement_speed_on_respawn =
|
||||
end
|
||||
)
|
||||
|
||||
local function on_wave_created(event)
|
||||
if not event or not event.wave_number then
|
||||
return
|
||||
end
|
||||
|
||||
local wave_number = event.wave_number
|
||||
|
||||
if wave_number % 50 == 0 then
|
||||
WD.set_pause_wave_in_ticks(random(18000, 54000))
|
||||
end
|
||||
end
|
||||
|
||||
function Public.set_difficulty()
|
||||
local game_lost = Public.get('game_lost')
|
||||
if game_lost then
|
||||
@ -1698,5 +1710,6 @@ Event.add(defines.events.on_research_finished, on_research_finished)
|
||||
Event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
Event.add(defines.events.on_player_respawned, on_player_respawned)
|
||||
Event.on_nth_tick(10, tick)
|
||||
Event.add(WD.events.on_wave_created, on_wave_created)
|
||||
|
||||
return Public
|
||||
|
@ -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},
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 = {
|
||||
@ -74,16 +73,6 @@ local collapse_kill = {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
local init_protectors_force = function()
|
||||
local protectors = game.forces.protectors
|
||||
local enemy = game.forces.enemy
|
||||
if not protectors then
|
||||
protectors = game.create_force('protectors')
|
||||
end
|
||||
protectors.set_friend('enemy', true)
|
||||
enemy.set_friend('protectors', true)
|
||||
end
|
||||
|
||||
local init_bonus_drill_force = function()
|
||||
local bonus_drill = game.forces.bonus_drill
|
||||
local player = game.forces.player
|
||||
@ -126,6 +115,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()
|
||||
|
||||
@ -171,7 +162,6 @@ function Public.reset_map()
|
||||
Group.alphanumeric_only(false)
|
||||
|
||||
Public.disable_tech()
|
||||
init_protectors_force()
|
||||
init_bonus_drill_force()
|
||||
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
@ -264,7 +254,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()
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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})
|
||||
|
@ -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
|
||||
|
@ -519,7 +519,7 @@ local function on_entity_damaged(event)
|
||||
)
|
||||
end
|
||||
|
||||
local get_health_pool = Public.has_health_boost(entity, damage, final_damage_amount, cause)
|
||||
local get_health_pool = Public.has_health_boost(entity, damage, final_damage_amount, cause, true)
|
||||
|
||||
--Cause a one punch.
|
||||
if enable_aoe_punch then
|
||||
|
@ -710,6 +710,7 @@ function Public.extra_settings(player)
|
||||
Gui.set_data(save_button, data)
|
||||
|
||||
player.opened = main_frame
|
||||
main_frame.auto_center = true
|
||||
end
|
||||
|
||||
function Public.settings_tooltip(player)
|
||||
|
@ -59,6 +59,7 @@ end
|
||||
local function spawn_biters(data)
|
||||
local surface = data.surface
|
||||
local position = data.position
|
||||
local entity_name = data.entity_name
|
||||
local h = floor(abs(position.y))
|
||||
|
||||
if not position then
|
||||
@ -77,6 +78,10 @@ local function spawn_biters(data)
|
||||
unit_to_create = Public.wave_defense_roll_biter_name()
|
||||
end
|
||||
|
||||
if entity_name then
|
||||
unit_to_create = entity_name
|
||||
end
|
||||
|
||||
local modified_unit_health = Public.get('modified_unit_health')
|
||||
local modified_boss_unit_health = Public.get('modified_boss_unit_health')
|
||||
|
||||
@ -119,7 +124,7 @@ local function spawn_worms(data)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.buried_biter(surface, position, max)
|
||||
function Public.buried_biter(surface, position, max, entity_name)
|
||||
if not surface then
|
||||
return
|
||||
end
|
||||
@ -137,6 +142,7 @@ function Public.buried_biter(surface, position, max)
|
||||
end
|
||||
|
||||
local amount = 8
|
||||
|
||||
local a = 0
|
||||
max = max or random(4, 6)
|
||||
|
||||
@ -157,7 +163,7 @@ function Public.buried_biter(surface, position, max)
|
||||
a = a + 1
|
||||
this[game.tick + t][#this[game.tick + t] + 1] = {
|
||||
callback = 'spawn_biters',
|
||||
data = {surface = surface, position = {x = position.x, y = position.y}}
|
||||
data = {surface = surface, position = {x = position.x, y = position.y}, entity_name = entity_name}
|
||||
}
|
||||
if a >= max then
|
||||
break
|
||||
|
@ -1,43 +1,74 @@
|
||||
local Public = require 'modules.wave_defense.table'
|
||||
local module_name = '[WD]'
|
||||
|
||||
commands.add_command(
|
||||
'wd_debug_module',
|
||||
'',
|
||||
function(cmd)
|
||||
local p
|
||||
local player = game.player
|
||||
|
||||
if not player or not player.valid then
|
||||
p = print
|
||||
else
|
||||
p = player.print
|
||||
if not player.admin then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local param = tostring(cmd.parameter)
|
||||
if param == nil then
|
||||
return
|
||||
end
|
||||
|
||||
if not (player and player.valid) then
|
||||
if param == 'skip' then
|
||||
Public.get('enable_grace_time').enabled = false
|
||||
p(module_name .. ' grace skipped!')
|
||||
return
|
||||
end
|
||||
|
||||
if not player.admin then
|
||||
if param == 'toggle_es' then
|
||||
Public.set_module_status()
|
||||
p(module_name .. ' ES has been toggled!')
|
||||
return
|
||||
end
|
||||
|
||||
if param == 'spawn_wave' then
|
||||
return Public.spawn_unit_group(true, true)
|
||||
Public.spawn_unit_group(true, true)
|
||||
p(module_name .. ' wave spawned!')
|
||||
return
|
||||
end
|
||||
|
||||
if param == 'set_next_wave' then
|
||||
for _ = 1, 100 do
|
||||
if param == 'next_wave' then
|
||||
Public.set_next_wave()
|
||||
Public.spawn_unit_group(true, true)
|
||||
p(module_name .. ' wave spawned!')
|
||||
return
|
||||
end
|
||||
|
||||
if param == 'set_next_50' then
|
||||
for _ = 1, 50 do
|
||||
Public.set_next_wave()
|
||||
end
|
||||
return Public.spawn_unit_group(true, true)
|
||||
Public.spawn_unit_group(true, true)
|
||||
p(module_name .. ' wave spawned!')
|
||||
return
|
||||
end
|
||||
|
||||
if param == 'set_wave_1500' then
|
||||
for _ = 1, 1500 do
|
||||
Public.set_next_wave()
|
||||
end
|
||||
return Public.spawn_unit_group(true, true)
|
||||
Public.spawn_unit_group(true, true)
|
||||
p(module_name .. ' wave spawned!')
|
||||
return
|
||||
end
|
||||
|
||||
if param == 'log_all' then
|
||||
return Public.toggle_debug()
|
||||
Public.toggle_debug()
|
||||
p(module_name .. ' debug toggled!')
|
||||
return
|
||||
end
|
||||
|
||||
if param == 'debug_health' then
|
||||
@ -49,6 +80,7 @@ commands.add_command(
|
||||
this.wave_interval = 200
|
||||
this.wave_enforced = true
|
||||
this.debug_only_on_wave_500 = true
|
||||
p(module_name .. ' debug health toggled!')
|
||||
end
|
||||
end
|
||||
)
|
||||
|
@ -1,5 +1,8 @@
|
||||
local Public = require 'modules.wave_defense.table'
|
||||
|
||||
local Enemy_states = require 'modules.wave_defense.enemy_states'
|
||||
Public.enemy_states = Enemy_states
|
||||
|
||||
local Biter_Rolls = require 'modules.wave_defense.biter_rolls'
|
||||
Public.biter_rolls = Biter_Rolls
|
||||
|
||||
|
1056
modules/wave_defense/enemy_states.lua
Normal file
1056
modules/wave_defense/enemy_states.lua
Normal file
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,7 @@ local random = math.random
|
||||
local floor = math.floor
|
||||
local sqrt = math.sqrt
|
||||
local round = math.round
|
||||
local raise = Event.raise
|
||||
|
||||
local function debug_print(msg)
|
||||
local debug = Public.get('debug')
|
||||
@ -62,8 +63,8 @@ local function find_initial_spot(surface, position)
|
||||
if random(1, 2) == 1 then
|
||||
local random_pos = {
|
||||
{x = pos.x - 10, y = pos.y - 5},
|
||||
{x = pos.x + 10, y = pos.y + 5},
|
||||
{x = pos.x - 10, y = pos.y + 5},
|
||||
{x = pos.x + 10, y = pos.y - 5},
|
||||
{x = pos.x - 10, y = pos.y - 5},
|
||||
{x = pos.x + 10, y = pos.y - 5}
|
||||
}
|
||||
local actual_pos = shuffle(random_pos)
|
||||
@ -183,6 +184,12 @@ local function get_spawn_pos()
|
||||
|
||||
local initial_position = Public.get('spawn_position')
|
||||
|
||||
if random(1, 2) == 1 then
|
||||
initial_position = {x = initial_position.x, y = initial_position.y - 30}
|
||||
else
|
||||
initial_position = {x = initial_position.x, y = initial_position.y - 20}
|
||||
end
|
||||
|
||||
local located_position = find_initial_spot(surface, initial_position)
|
||||
local valid_position = surface.find_non_colliding_position('stone-furnace', located_position, 32, 1)
|
||||
local debug = Public.get('debug')
|
||||
@ -228,10 +235,6 @@ local function is_unit_valid(biter)
|
||||
debug_print('is_unit_valid - unit destroyed - invalid')
|
||||
return false
|
||||
end
|
||||
if not biter.entity.unit_group then
|
||||
debug_print('is_unit_valid - unit destroyed - no unitgroup')
|
||||
return false
|
||||
end
|
||||
if biter.spawn_tick + max_biter_age < game.tick then
|
||||
debug_print('is_unit_valid - unit destroyed - timed out')
|
||||
return false
|
||||
@ -264,6 +267,7 @@ local function time_out_biters()
|
||||
local generated_units = Public.get('generated_units')
|
||||
local active_biter_count = Public.get('active_biter_count')
|
||||
local active_biter_threat = Public.get('active_biter_threat')
|
||||
local valid_enemy_forces = Public.get('valid_enemy_forces')
|
||||
|
||||
if active_biter_count >= 100 and #generated_units.active_biters <= 10 then
|
||||
Public.set('active_biter_count', 50)
|
||||
@ -274,15 +278,14 @@ local function time_out_biters()
|
||||
for k, biter in pairs(generated_units.active_biters) do
|
||||
if not is_unit_valid(biter) then
|
||||
Public.set('active_biter_count', active_biter_count - 1)
|
||||
if biter.entity then
|
||||
if biter.entity.valid then
|
||||
Public.set('active_biter_threat', active_biter_threat - round(Public.threat_values[biter.entity.name] * biter_health_boost, 2))
|
||||
if biter.entity.force.index == 2 then
|
||||
biter.entity.destroy()
|
||||
end
|
||||
debug_print('time_out_biters: ' .. k .. ' got deleted.')
|
||||
local entity = biter.entity
|
||||
if entity and entity.valid then
|
||||
Public.set('active_biter_threat', active_biter_threat - round(Public.threat_values[entity.name] * biter_health_boost, 2))
|
||||
if valid_enemy_forces[entity.force.name] then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
debug_print('time_out_biters: ' .. k .. ' got deleted.')
|
||||
generated_units.active_biters[k] = nil
|
||||
end
|
||||
end
|
||||
@ -343,6 +346,7 @@ local function set_main_target()
|
||||
local target = Public.get('target')
|
||||
if target then
|
||||
if target.valid then
|
||||
raise(Public.events.on_target_aquired, {target = target})
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -358,10 +362,12 @@ local function set_main_target()
|
||||
sec_target = get_random_character()
|
||||
end
|
||||
if not sec_target then
|
||||
raise(Public.events.on_target_aquired, {target = target})
|
||||
return
|
||||
end
|
||||
|
||||
Public.set('target', sec_target)
|
||||
raise(Public.events.on_target_aquired, {target = target})
|
||||
debug_print('set_main_target -- New main target ' .. sec_target.name .. ' at position x' .. sec_target.position.x .. ' y' .. sec_target.position.y .. ' selected.')
|
||||
end
|
||||
|
||||
@ -408,6 +414,7 @@ local function set_enemy_evolution()
|
||||
end
|
||||
|
||||
enemy.evolution_factor = evolution_factor
|
||||
raise(Public.events.on_evolution_factor_changed, {evolution_factor = evolution_factor})
|
||||
end
|
||||
|
||||
local function can_units_spawn()
|
||||
@ -519,14 +526,18 @@ local function spawn_biter(surface, position, forceSpawn, is_boss_biter, unit_se
|
||||
BiterHealthBooster.add_unit(biter, final_health)
|
||||
end
|
||||
|
||||
if is_boss_biter and (wave_number >= boost_bosses_when_wave_is_above) then
|
||||
local increase_boss_health_per_wave = Public.get('increase_boss_health_per_wave')
|
||||
if increase_boss_health_per_wave then
|
||||
local modified_boss_unit_health = Public.get('modified_boss_unit_health')
|
||||
BiterHealthBooster.add_boss_unit(biter, modified_boss_unit_health.current_value, 0.55)
|
||||
if is_boss_biter then
|
||||
if (wave_number >= boost_bosses_when_wave_is_above) then
|
||||
local increase_boss_health_per_wave = Public.get('increase_boss_health_per_wave')
|
||||
if increase_boss_health_per_wave then
|
||||
local modified_boss_unit_health = Public.get('modified_boss_unit_health')
|
||||
BiterHealthBooster.add_boss_unit(biter, modified_boss_unit_health.current_value, 0.55)
|
||||
else
|
||||
local sum = boosted_health * 5
|
||||
BiterHealthBooster.add_boss_unit(biter, sum, 0.55)
|
||||
end
|
||||
else
|
||||
local sum = boosted_health * 5
|
||||
debug_print('Boss Health Boosted: ' .. sum)
|
||||
BiterHealthBooster.add_boss_unit(biter, sum, 0.55)
|
||||
end
|
||||
end
|
||||
@ -567,9 +578,6 @@ local function increase_biters_health()
|
||||
return
|
||||
end
|
||||
|
||||
-- local boosted_health = BiterHealthBooster.get('biter_health_boost')
|
||||
-- local wave_number = Public.get('wave_number')
|
||||
|
||||
-- this sets normal units health
|
||||
local modified_unit_health = Public.get('modified_unit_health')
|
||||
if modified_unit_health.current_value > modified_unit_health.limit_value then
|
||||
@ -578,18 +586,6 @@ local function increase_biters_health()
|
||||
debug_print_health('modified_unit_health.current_value: ' .. modified_unit_health.current_value)
|
||||
Public.set('modified_unit_health').current_value = modified_unit_health.current_value + modified_unit_health.health_increase_per_boss_wave
|
||||
|
||||
-- this sets boss units health
|
||||
-- if boosted_health == 1 then
|
||||
-- boosted_health = 1.25
|
||||
-- end
|
||||
|
||||
-- boosted_health = round(boosted_health * (wave_number * 0.04), 3)
|
||||
-- debug_print_health('boosted_health: ' .. boosted_health)
|
||||
-- if boosted_health >= 300 then
|
||||
-- boosted_health = 300
|
||||
-- end
|
||||
-- Public.set('modified_boss_unit_health', boosted_health)
|
||||
|
||||
-- this sets boss units health
|
||||
local modified_boss_unit_health = Public.get('modified_boss_unit_health')
|
||||
if modified_boss_unit_health.current_value > modified_boss_unit_health.limit_value then
|
||||
@ -648,6 +644,8 @@ local function set_next_wave()
|
||||
Public.set('wave_number', wave_number + 1)
|
||||
wave_number = Public.get('wave_number')
|
||||
|
||||
local event_data = {}
|
||||
|
||||
local threat_gain_multiplier = Public.get('threat_gain_multiplier')
|
||||
local threat_gain = wave_number * threat_gain_multiplier
|
||||
|
||||
@ -661,10 +659,13 @@ local function set_next_wave()
|
||||
increase_max_active_unit_groups()
|
||||
end
|
||||
|
||||
if wave_number % 25 == 0 then
|
||||
event_data.wave_number = wave_number
|
||||
|
||||
if wave_number % 50 == 0 then
|
||||
increase_biter_damage()
|
||||
increase_biters_health()
|
||||
Public.set('boss_wave', true)
|
||||
event_data.boss_wave = true
|
||||
Public.set('boss_wave_warning', true)
|
||||
local alert_boss_wave = Public.get('alert_boss_wave')
|
||||
local spawn_position = get_spawn_pos()
|
||||
@ -695,10 +696,15 @@ local function set_next_wave()
|
||||
local wave_enforced = Public.get('wave_enforced')
|
||||
local next_wave = Public.get('next_wave')
|
||||
local wave_interval = Public.get('wave_interval')
|
||||
event_data.next_wave = next_wave
|
||||
event_data.wave_interval = wave_interval
|
||||
event_data.threat_gain = threat_gain
|
||||
if not wave_enforced then
|
||||
Public.set('last_wave', next_wave)
|
||||
Public.set('next_wave', game.tick + wave_interval)
|
||||
end
|
||||
|
||||
raise(Public.events.on_wave_created, event_data)
|
||||
end
|
||||
|
||||
local function reform_group(group)
|
||||
@ -746,6 +752,9 @@ local function get_side_targets(group)
|
||||
local step_length = unit_group_command_step_length
|
||||
|
||||
local side_target = Public.get_side_target()
|
||||
if not side_target then
|
||||
return
|
||||
end
|
||||
local target_position = side_target.position
|
||||
local distance_to_target = floor(sqrt((target_position.x - group_position.x) ^ 2 + (target_position.y - group_position.y) ^ 2))
|
||||
local steps = floor(distance_to_target / step_length) + 1
|
||||
@ -929,6 +938,9 @@ local function command_to_side_target(group)
|
||||
end
|
||||
|
||||
local commands = get_side_targets(group)
|
||||
if not commands then
|
||||
return
|
||||
end
|
||||
|
||||
group.set_command(
|
||||
{
|
||||
@ -1042,14 +1054,26 @@ local function spawn_unit_group(fs, only_bosses)
|
||||
|
||||
debug_print('Spawning unit group at x' .. spawn_position.x .. ' y' .. spawn_position.y)
|
||||
|
||||
local event_data = {}
|
||||
|
||||
local generated_units = Public.get('generated_units')
|
||||
local unit_group = surface.create_unit_group({position = spawn_position, force = 'enemy'})
|
||||
|
||||
event_data.unit_group = unit_group
|
||||
|
||||
generated_units.unit_group_pos.index = generated_units.unit_group_pos.index + 1
|
||||
generated_units.unit_group_pos.positions[unit_group.group_number] = {position = unit_group.position, index = 0}
|
||||
local average_unit_group_size = Public.get('average_unit_group_size')
|
||||
local unit_settings = Public.get('unit_settings')
|
||||
event_data.unit_settings = unit_settings
|
||||
|
||||
local group_size = floor(average_unit_group_size * Public.group_size_modifier_raffle[random(1, Public.group_size_modifier_raffle_size)])
|
||||
if not only_bosses then
|
||||
|
||||
event_data.group_size = group_size
|
||||
event_data.boss_wave = false
|
||||
|
||||
local boss_wave = Public.get('boss_wave')
|
||||
if not boss_wave and not only_bosses then
|
||||
for _ = 1, group_size, 1 do
|
||||
local biter = spawn_biter(surface, spawn_position, fs, false, unit_settings)
|
||||
if not biter then
|
||||
@ -1058,26 +1082,29 @@ local function spawn_unit_group(fs, only_bosses)
|
||||
end
|
||||
unit_group.add_member(biter)
|
||||
|
||||
raise(Public.events.on_entity_created, {entity = biter, boss_unit = false, target = target})
|
||||
-- command_to_side_target(unit_group)
|
||||
end
|
||||
end
|
||||
|
||||
local boss_wave = Public.get('boss_wave')
|
||||
if boss_wave or only_bosses then
|
||||
event_data.boss_wave = true
|
||||
local count = random(1, floor(wave_number * 0.01) + 2)
|
||||
if count > 16 then
|
||||
count = 16
|
||||
end
|
||||
if count <= 1 then
|
||||
if count <= 4 then
|
||||
count = 4
|
||||
end
|
||||
event_data.spawn_count = count
|
||||
for _ = 1, count, 1 do
|
||||
local biter = spawn_biter(surface, spawn_position, fs, true, unit_settings)
|
||||
if not biter then
|
||||
debug_print('spawn_unit_group - No biters were found?')
|
||||
debug_print('spawn_unit_group - No biter was found?')
|
||||
break
|
||||
end
|
||||
unit_group.add_member(biter)
|
||||
raise(Public.events.on_entity_created, {entity = biter, boss_unit = true, target = target})
|
||||
end
|
||||
Public.set('boss_wave', false)
|
||||
end
|
||||
@ -1089,10 +1116,16 @@ local function spawn_unit_group(fs, only_bosses)
|
||||
Public.set('random_group', unit_group)
|
||||
end
|
||||
Public.set('spot', 'nil')
|
||||
raise(Public.events.on_unit_group_created, event_data)
|
||||
return true
|
||||
end
|
||||
|
||||
local function check_group_positions()
|
||||
local resolve_pathing = Public.get('resolve_pathing')
|
||||
if not resolve_pathing then
|
||||
return
|
||||
end
|
||||
|
||||
local generated_units = Public.get('generated_units')
|
||||
local target = Public.get('target')
|
||||
if not valid(target) then
|
||||
@ -1126,6 +1159,11 @@ local function check_group_positions()
|
||||
end
|
||||
|
||||
local function log_threat()
|
||||
local enable_threat_log = Public.get('enable_threat_log')
|
||||
if not enable_threat_log then
|
||||
return
|
||||
end
|
||||
|
||||
local threat_log_index = Public.get('threat_log_index')
|
||||
Public.set('threat_log_index', threat_log_index + 1)
|
||||
local threat_log = Public.get('threat_log')
|
||||
@ -1140,9 +1178,14 @@ end
|
||||
local tick_tasks = {
|
||||
[30] = set_main_target,
|
||||
[60] = set_enemy_evolution,
|
||||
[90] = check_group_positions,
|
||||
[120] = give_main_command_to_group,
|
||||
[150] = Public.build_nest,
|
||||
[180] = Public.build_worm,
|
||||
[150] = log_threat,
|
||||
[180] = Public.build_nest,
|
||||
[210] = Public.build_worm
|
||||
}
|
||||
|
||||
local tick_tasks_t2 = {
|
||||
[1200] = give_side_commands_to_group,
|
||||
[3600] = time_out_biters,
|
||||
[7200] = refresh_active_unit_threat
|
||||
@ -1187,23 +1230,11 @@ Event.on_nth_tick(
|
||||
if tick_tasks[t] then
|
||||
tick_tasks[t]()
|
||||
end
|
||||
if tick_tasks[t2] then
|
||||
tick_tasks[t2]()
|
||||
|
||||
if tick_tasks_t2[t2] then
|
||||
tick_tasks_t2[t2]()
|
||||
end
|
||||
|
||||
local resolve_pathing = Public.get('resolve_pathing')
|
||||
if resolve_pathing then
|
||||
if tick % 60 == 0 then
|
||||
check_group_positions()
|
||||
end
|
||||
end
|
||||
|
||||
local enable_threat_log = Public.get('enable_threat_log')
|
||||
if enable_threat_log then
|
||||
if tick % 60 == 0 then
|
||||
log_threat()
|
||||
end
|
||||
end
|
||||
local players = game.connected_players
|
||||
for _, player in pairs(players) do
|
||||
Public.update_gui(player)
|
||||
|
@ -3,6 +3,14 @@ local Event = require 'utils.event'
|
||||
|
||||
local this = {}
|
||||
local Public = {}
|
||||
Public.events = {
|
||||
on_wave_created = Event.generate_event_name('on_wave_created'),
|
||||
on_unit_group_created = Event.generate_event_name('on_unit_group_created'),
|
||||
on_evolution_factor_changed = Event.generate_event_name('on_evolution_factor_changed'),
|
||||
on_game_reset = Event.generate_event_name('on_game_reset'),
|
||||
on_target_aquired = Event.generate_event_name('on_target_aquired'),
|
||||
on_entity_created = Event.generate_event_name('on_entity_created')
|
||||
}
|
||||
local insert = table.insert
|
||||
|
||||
Global.register(
|
||||
@ -153,6 +161,11 @@ function Public.reset_wave_defense()
|
||||
['behemoth-worm-turret'] = 0.3
|
||||
}
|
||||
}
|
||||
this.valid_enemy_forces = {
|
||||
['enemy'] = true,
|
||||
['aggressors'] = true,
|
||||
['aggressors_frenzy'] = true
|
||||
}
|
||||
end
|
||||
|
||||
--- This gets values from our table
|
||||
|
@ -20,6 +20,9 @@ local immunity_spawner =
|
||||
local function is_boss(entity)
|
||||
local unit_number = entity.unit_number
|
||||
local biter_health_boost_units = BiterHealthBooster.get('biter_health_boost_units')
|
||||
if not biter_health_boost_units then
|
||||
return
|
||||
end
|
||||
local unit = biter_health_boost_units[unit_number]
|
||||
if unit and unit[3] and unit[3].healthbar_id then
|
||||
return true
|
||||
@ -36,6 +39,10 @@ local function remove_unit(entity)
|
||||
end
|
||||
local m = 1
|
||||
local biter_health_boost_units = BiterHealthBooster.get('biter_health_boost_units')
|
||||
if not biter_health_boost_units then
|
||||
return
|
||||
end
|
||||
|
||||
if biter_health_boost_units[unit_number] then
|
||||
m = 1 / biter_health_boost_units[unit_number][2]
|
||||
end
|
||||
@ -144,7 +151,8 @@ function Public.build_worm()
|
||||
if threat < 512 then
|
||||
return
|
||||
end
|
||||
local worm_building_chance = Public.get('worm_building_chance')
|
||||
local worm_building_chance = Public.get('worm_building_chance') --[[@as integer]]
|
||||
|
||||
if math_random(1, worm_building_chance) ~= 1 then
|
||||
return
|
||||
end
|
||||
@ -296,10 +304,28 @@ local function on_entity_died(event)
|
||||
end
|
||||
|
||||
local disable_threat_below_zero = Public.get('disable_threat_below_zero')
|
||||
local biter_health_boost = BiterHealthBooster.get('biter_health_boost')
|
||||
local valid_enemy_forces = Public.get('valid_enemy_forces')
|
||||
if not valid_enemy_forces then
|
||||
return
|
||||
end
|
||||
|
||||
local modified_unit_health = Public.get('modified_unit_health')
|
||||
if not modified_unit_health then
|
||||
return
|
||||
end
|
||||
local modified_boss_unit_health = Public.get('modified_boss_unit_health')
|
||||
if not modified_boss_unit_health then
|
||||
return
|
||||
end
|
||||
|
||||
local boss = is_boss(entity)
|
||||
|
||||
local boost_value = modified_unit_health.current_value
|
||||
if boss then
|
||||
boost_value = modified_boss_unit_health.current_value / 2
|
||||
end
|
||||
|
||||
if entity.type == 'unit' then
|
||||
--acid_nova(entity)
|
||||
if not Public.threat_values[entity.name] then
|
||||
return
|
||||
end
|
||||
@ -310,19 +336,19 @@ local function on_entity_died(event)
|
||||
remove_unit(entity)
|
||||
return
|
||||
end
|
||||
Public.set('threat', math.round(threat - Public.threat_values[entity.name] * biter_health_boost, 2))
|
||||
Public.set('threat', math.round(threat - Public.threat_values[entity.name] * boost_value, 2))
|
||||
remove_unit(entity)
|
||||
else
|
||||
local threat = Public.get('threat')
|
||||
Public.set('threat', math.round(threat - Public.threat_values[entity.name] * biter_health_boost, 2))
|
||||
Public.set('threat', math.round(threat - Public.threat_values[entity.name] * boost_value, 2))
|
||||
remove_unit(entity)
|
||||
end
|
||||
else
|
||||
if entity.force.index == 2 then
|
||||
if valid_enemy_forces[entity.force.name] then
|
||||
if entity.health then
|
||||
if Public.threat_values[entity.name] then
|
||||
local threat = Public.get('threat')
|
||||
Public.set('threat', math.round(threat - Public.threat_values[entity.name] * biter_health_boost, 2))
|
||||
Public.set('threat', math.round(threat - Public.threat_values[entity.name] * boost_value, 2))
|
||||
end
|
||||
spawn_unit_spawner_inhabitants(entity)
|
||||
end
|
||||
|
143
utils/datastore/warning_on_join_data.lua
Normal file
143
utils/datastore/warning_on_join_data.lua
Normal file
@ -0,0 +1,143 @@
|
||||
local Token = require 'utils.token'
|
||||
local Server = require 'utils.server'
|
||||
local Event = require 'utils.event'
|
||||
local Gui = require 'utils.gui'
|
||||
|
||||
local dataset = 'warnings'
|
||||
local set_data = Server.set_data
|
||||
local try_get_data = Server.try_get_data
|
||||
local warning_frame_name = Gui.uid_name()
|
||||
local discard_button_name = Gui.uid_name()
|
||||
|
||||
local Public = {}
|
||||
|
||||
local function draw_warning_frame(player, message)
|
||||
local main_frame, inside_table = Gui.add_main_frame_with_toolbar(player, 'screen', warning_frame_name, nil, nil, 'Warning', true, 2)
|
||||
|
||||
if not main_frame or not inside_table then
|
||||
return
|
||||
end
|
||||
|
||||
local main_frame_style = main_frame.style
|
||||
main_frame_style.width = 400
|
||||
main_frame.auto_center = true
|
||||
|
||||
local content_flow = inside_table.add {type = 'flow', direction = 'horizontal'}
|
||||
content_flow.style.top_padding = 16
|
||||
content_flow.style.bottom_padding = 16
|
||||
content_flow.style.left_padding = 24
|
||||
content_flow.style.right_padding = 24
|
||||
content_flow.style.horizontally_stretchable = false
|
||||
|
||||
local sprite_flow = content_flow.add {type = 'flow'}
|
||||
sprite_flow.style.vertical_align = 'center'
|
||||
sprite_flow.style.vertically_stretchable = false
|
||||
|
||||
sprite_flow.add {type = 'sprite', sprite = 'utility/warning_icon'}
|
||||
|
||||
local label_flow = content_flow.add {type = 'flow'}
|
||||
label_flow.style.horizontal_align = 'left'
|
||||
label_flow.style.top_padding = 10
|
||||
label_flow.style.left_padding = 24
|
||||
|
||||
local warning_message = '[font=heading-2]Message from Comfy to: ' .. player.name .. '[/font]\n' .. message
|
||||
|
||||
label_flow.style.horizontally_stretchable = false
|
||||
local label = label_flow.add {type = 'label', caption = warning_message}
|
||||
label.style.single_line = false
|
||||
|
||||
local bottom_flow = main_frame.add({type = 'flow', direction = 'horizontal'})
|
||||
|
||||
local left_flow = bottom_flow.add({type = 'flow'})
|
||||
left_flow.style.horizontal_align = 'left'
|
||||
left_flow.style.horizontally_stretchable = true
|
||||
|
||||
local close_button = left_flow.add({type = 'button', name = discard_button_name, caption = 'Understood'})
|
||||
close_button.style = 'back_button'
|
||||
|
||||
player.opened = main_frame
|
||||
end
|
||||
|
||||
local fetch =
|
||||
Token.register(
|
||||
function(data)
|
||||
local key = data.key
|
||||
if not key then
|
||||
return
|
||||
end
|
||||
|
||||
local value = data.value
|
||||
if not value then
|
||||
return
|
||||
end
|
||||
|
||||
local player = game.get_player(key)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
draw_warning_frame(player, value)
|
||||
end
|
||||
)
|
||||
|
||||
--- Tries to get data from the webpanel and applies the value to the player.
|
||||
-- @param data_set player token
|
||||
function Public.fetch(key)
|
||||
local secs = Server.get_current_time()
|
||||
if not secs then
|
||||
local player = game.players[key]
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
return
|
||||
else
|
||||
try_get_data(dataset, key, fetch)
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_joined_game,
|
||||
function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
Public.fetch(player.name)
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
discard_button_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
local screen = player.gui.screen
|
||||
local frame = screen[warning_frame_name]
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if frame and frame.valid then
|
||||
frame.destroy()
|
||||
set_data(dataset, player.name)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Server.on_data_set_changed(
|
||||
dataset,
|
||||
function(data)
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
|
||||
local key = data.key
|
||||
local value = data.value
|
||||
local player = game.get_player(key)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
draw_warning_frame(player, value)
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
@ -112,6 +112,7 @@ local raise_event = script.raise_event
|
||||
local script_on_event = script.on_event
|
||||
local script_on_nth_tick = script.on_nth_tick
|
||||
local generate_event_name = script.generate_event_name
|
||||
local get_event_filter = script.get_event_filter
|
||||
|
||||
local function_table = function_table
|
||||
local function_nth_tick_table = function_nth_tick_table
|
||||
@ -162,13 +163,12 @@ end
|
||||
-- See documentation at top of file for details on using events.
|
||||
-- @param event_name<number>
|
||||
-- @param handler<function>
|
||||
-- @optional param filters<table>
|
||||
function Event.add(event_name, handler, filters)
|
||||
function Event.add(event_name, handler)
|
||||
if _LIFECYCLE == 8 then
|
||||
error('Calling Event.add after on_init() or on_load() has run is a desync risk.', 2)
|
||||
end
|
||||
|
||||
core_add(event_name, handler, filters)
|
||||
core_add(event_name, handler)
|
||||
end
|
||||
|
||||
--- Register a handler for the script.on_init event.
|
||||
@ -528,7 +528,7 @@ function Event.generate_event_name(name)
|
||||
end
|
||||
|
||||
function Event.add_event_filter(event, filter)
|
||||
local current_filters = script.get_event_filter(event)
|
||||
local current_filters = get_event_filter(event)
|
||||
|
||||
if not current_filters then
|
||||
current_filters = {filter}
|
||||
@ -550,7 +550,7 @@ local function add_handlers()
|
||||
for event_name, tokens in pairs(token_handlers) do
|
||||
for i = 1, #tokens do
|
||||
local handler = Token.get(tokens[i])
|
||||
core_add(event_name, handler)
|
||||
core_add(event_name, handler.data, handler.filter)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -12,15 +12,6 @@ local event_handlers = {}
|
||||
-- map of nth_tick to handlers[]
|
||||
local on_nth_tick_event_handlers = {}
|
||||
|
||||
--[[ local interface = {
|
||||
get_handler = function()
|
||||
return event_handlers
|
||||
end
|
||||
}
|
||||
|
||||
if not remote.interfaces['interface'] then
|
||||
remote.add_interface('interface', interface)
|
||||
end ]]
|
||||
local xpcall = xpcall
|
||||
local trace = debug.traceback
|
||||
local log = log
|
||||
@ -33,13 +24,11 @@ local function handler_error(err)
|
||||
end
|
||||
|
||||
local function call_handlers(handlers, event)
|
||||
if _DEBUG then
|
||||
for i = 1, #handlers do
|
||||
for i = 1, #handlers do
|
||||
if _DEBUG then
|
||||
local handler = handlers[i]
|
||||
handler(event)
|
||||
end
|
||||
else
|
||||
for i = 1, #handlers do
|
||||
else
|
||||
xpcall(handlers[i], handler_error, event)
|
||||
end
|
||||
end
|
||||
@ -91,23 +80,16 @@ local function on_nth_tick_event(event)
|
||||
end
|
||||
|
||||
--- Do not use this function, use Event.add instead as it has safety checks.
|
||||
function Public.add(event_name, handler, filters)
|
||||
function Public.add(event_name, handler)
|
||||
local handlers = event_handlers[event_name]
|
||||
|
||||
if not handlers then
|
||||
event_handlers[event_name] = {handler}
|
||||
if filters then
|
||||
script_on_event(event_name, on_event, filters)
|
||||
else
|
||||
script_on_event(event_name, on_event)
|
||||
end
|
||||
script_on_event(event_name, on_event)
|
||||
else
|
||||
table.insert(handlers, handler)
|
||||
if #handlers == 1 then
|
||||
if filters then
|
||||
script_on_event(event_name, on_event, filters)
|
||||
else
|
||||
script_on_event(event_name, on_event)
|
||||
end
|
||||
script_on_event(event_name, on_event)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user