mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-17 20:58:13 +02:00
refactor mtn fortress
This commit is contained in:
parent
31db1ba9b6
commit
9c6a2476b7
@ -100,6 +100,14 @@ local compare_player_pos = function(player)
|
||||
end
|
||||
|
||||
local compare_player_and_train = function(player, entity)
|
||||
if not player.driving then
|
||||
return
|
||||
end
|
||||
|
||||
if not (entity and entity.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
local position = player.position
|
||||
local locomotive = WPT.get('locomotive')
|
||||
if not locomotive or not locomotive.valid then
|
||||
@ -187,21 +195,21 @@ local function distance(player)
|
||||
if breached_wall % 2 == 0 then
|
||||
local blood_moon = WPT.get('blood_moon')
|
||||
local t = game.tick
|
||||
local s = player.surface
|
||||
local surface = player.surface
|
||||
if not blood_moon then
|
||||
BM.set_daytime(s, t, true)
|
||||
BM.set_daytime(surface, t, true)
|
||||
WPT.set('blood_moon', true)
|
||||
end
|
||||
else
|
||||
local s = player.surface
|
||||
s.brightness_visual_weights = {
|
||||
local surface = player.surface
|
||||
surface.brightness_visual_weights = {
|
||||
a = 1,
|
||||
b = 0,
|
||||
g = 0,
|
||||
r = 0
|
||||
}
|
||||
s.daytime = 0.7
|
||||
s.freeze_daytime = false
|
||||
surface.daytime = 0.7
|
||||
surface.freeze_daytime = false
|
||||
end
|
||||
|
||||
local data = {
|
||||
|
@ -662,7 +662,7 @@ local function on_player_mined_entity(event)
|
||||
|
||||
local mined_scrap = WPT.get('mined_scrap')
|
||||
|
||||
if entity.type == 'simple-entity' or entity.type == 'tree' then
|
||||
if entity.type == 'simple-entity' or entity.type == 'simple-entity-with-owner' or entity.type == 'tree' then
|
||||
WPT.set().mined_scrap = mined_scrap + 1
|
||||
Mining.on_player_mined_entity(event)
|
||||
if entity.type == 'tree' then
|
||||
|
@ -3,6 +3,13 @@ local Task = require 'utils.task'
|
||||
local ICW = require 'maps.mountain_fortress_v3.icw.main'
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local Alert = require 'utils.alert'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local Collapse = require 'modules.collapse'
|
||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
|
||||
local math2d = require 'math2d'
|
||||
|
||||
local this = {
|
||||
power_sources = {index = 1},
|
||||
@ -13,6 +20,8 @@ local this = {
|
||||
surface_cleared = false
|
||||
}
|
||||
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16, ['wood'] = 16, ['explosives'] = 32}
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(t)
|
||||
@ -21,11 +30,14 @@ Global.register(
|
||||
)
|
||||
|
||||
local Public = {}
|
||||
|
||||
local random = math.random
|
||||
local floor = math.floor
|
||||
local remove = table.remove
|
||||
local sqrt = math.sqrt
|
||||
local magic_crafters_per_tick = 3
|
||||
local magic_fluid_crafters_per_tick = 8
|
||||
local tile_damage = 50
|
||||
|
||||
local artillery_target_entities = {
|
||||
'character',
|
||||
@ -38,6 +50,35 @@ local artillery_target_entities = {
|
||||
'artillery-wagon'
|
||||
}
|
||||
|
||||
local function get_player_data(player, remove_user_data)
|
||||
local players = WPT.get('players')
|
||||
if remove_user_data then
|
||||
if players[player.index] then
|
||||
players[player.index] = nil
|
||||
end
|
||||
end
|
||||
if not players[player.index] then
|
||||
players[player.index] = {}
|
||||
end
|
||||
return players[player.index]
|
||||
end
|
||||
|
||||
local function debug_str(msg)
|
||||
local debug = WPT.get('debug')
|
||||
if not debug then
|
||||
return
|
||||
end
|
||||
print('Mtn: ' .. msg)
|
||||
end
|
||||
|
||||
local function show_text(msg, pos, color, surface)
|
||||
if color == nil then
|
||||
surface.create_entity({name = 'flying-text', position = pos, text = msg})
|
||||
else
|
||||
surface.create_entity({name = 'flying-text', position = pos, text = msg, color = color})
|
||||
end
|
||||
end
|
||||
|
||||
local function fast_remove(tbl, index)
|
||||
local count = #tbl
|
||||
if index > count then
|
||||
@ -447,11 +488,24 @@ Public.magic_item_crafting_callback =
|
||||
Token.register(
|
||||
function(entity, data)
|
||||
local callback_data = data.callback_data
|
||||
if not (entity and entity.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
entity.minable = false
|
||||
entity.destructible = false
|
||||
entity.operable = false
|
||||
|
||||
local force = game.forces.player
|
||||
|
||||
local tech = callback_data.tech
|
||||
if tech then
|
||||
if not force.technologies[tech].researched then
|
||||
entity.destroy()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local recipe = callback_data.recipe
|
||||
if recipe then
|
||||
entity.set_recipe(recipe)
|
||||
@ -487,6 +541,9 @@ Public.magic_item_crafting_callback_weighted =
|
||||
Token.register(
|
||||
function(entity, data)
|
||||
local callback_data = data.callback_data
|
||||
if not (entity and entity.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
entity.minable = false
|
||||
entity.destructible = false
|
||||
@ -509,6 +566,16 @@ Public.magic_item_crafting_callback_weighted =
|
||||
return
|
||||
end
|
||||
|
||||
local force = game.forces.player
|
||||
|
||||
local tech = stack.tech
|
||||
if tech then
|
||||
if not force.technologies[tech].researched then
|
||||
entity.destroy()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local recipe = stack.recipe
|
||||
if recipe then
|
||||
entity.set_recipe(recipe)
|
||||
@ -589,6 +656,586 @@ function Public.do_random_loot(entity, weights, loot)
|
||||
entity.insert {name = stack.name, count = count}
|
||||
end
|
||||
|
||||
function Public.remove_offline_players()
|
||||
local offline_players_enabled = WPT.get('offline_players_enabled')
|
||||
if not offline_players_enabled then
|
||||
return
|
||||
end
|
||||
local offline_players = WPT.get('offline_players')
|
||||
local active_surface_index = WPT.get('active_surface_index')
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
local player_inv = {}
|
||||
local items = {}
|
||||
if #offline_players > 0 then
|
||||
local later = {}
|
||||
for i = 1, #offline_players, 1 do
|
||||
if offline_players[i] and game.players[offline_players[i].index] and game.players[offline_players[i].index].connected then
|
||||
offline_players[i] = nil
|
||||
else
|
||||
if offline_players[i] and offline_players[i].tick < game.tick - 34000 then
|
||||
local name = offline_players[i].name
|
||||
player_inv[1] = game.players[offline_players[i].index].get_inventory(defines.inventory.character_main)
|
||||
player_inv[2] = game.players[offline_players[i].index].get_inventory(defines.inventory.character_armor)
|
||||
player_inv[3] = game.players[offline_players[i].index].get_inventory(defines.inventory.character_guns)
|
||||
player_inv[4] = game.players[offline_players[i].index].get_inventory(defines.inventory.character_ammo)
|
||||
player_inv[5] = game.players[offline_players[i].index].get_inventory(defines.inventory.character_trash)
|
||||
local pos = game.forces.player.get_spawn_position(surface)
|
||||
local e =
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'character',
|
||||
position = pos,
|
||||
force = 'neutral'
|
||||
}
|
||||
)
|
||||
local inv = e.get_inventory(defines.inventory.character_main)
|
||||
for ii = 1, 5, 1 do
|
||||
if player_inv[ii].valid then
|
||||
for iii = 1, #player_inv[ii], 1 do
|
||||
if player_inv[ii][iii].valid then
|
||||
items[#items + 1] = player_inv[ii][iii]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if #items > 0 then
|
||||
for item = 1, #items, 1 do
|
||||
if items[item].valid then
|
||||
inv.insert(items[item])
|
||||
end
|
||||
end
|
||||
|
||||
local message = ({'main.cleaner', name})
|
||||
local data = {
|
||||
position = pos
|
||||
}
|
||||
Alert.alert_all_players_location(data, message)
|
||||
|
||||
e.die('neutral')
|
||||
else
|
||||
e.destroy()
|
||||
end
|
||||
|
||||
for ii = 1, 5, 1 do
|
||||
if player_inv[ii].valid then
|
||||
player_inv[ii].clear()
|
||||
end
|
||||
end
|
||||
offline_players[i] = nil
|
||||
else
|
||||
later[#later + 1] = offline_players[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
for k, _ in pairs(offline_players) do
|
||||
offline_players[k] = nil
|
||||
end
|
||||
if #later > 0 then
|
||||
for i = 1, #later, 1 do
|
||||
offline_players[#offline_players + 1] = later[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.set_difficulty()
|
||||
local Diff = Difficulty.get()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local collapse_amount = WPT.get('collapse_amount')
|
||||
local player_count = #game.connected_players
|
||||
if not Diff.difficulty_vote_value then
|
||||
Diff.difficulty_vote_value = 0.1
|
||||
end
|
||||
|
||||
wave_defense_table.max_active_biters = 768 + player_count * (90 * Diff.difficulty_vote_value)
|
||||
|
||||
if wave_defense_table.max_active_biters >= 2500 then
|
||||
wave_defense_table.max_active_biters = 2500
|
||||
end
|
||||
|
||||
-- threat gain / wave
|
||||
wave_defense_table.threat_gain_multiplier = 1.2 + player_count * Diff.difficulty_vote_value * 0.1
|
||||
|
||||
local amount = player_count * 0.25 + 2
|
||||
amount = floor(amount)
|
||||
if amount > 6 then
|
||||
amount = 6
|
||||
end
|
||||
|
||||
if wave_defense_table.threat <= 0 then
|
||||
wave_defense_table.wave_interval = 1000
|
||||
end
|
||||
|
||||
wave_defense_table.wave_interval = 3600 - player_count * 60
|
||||
if wave_defense_table.wave_interval < 1800 then
|
||||
wave_defense_table.wave_interval = 1800
|
||||
end
|
||||
|
||||
local gap_between_zones = WPT.get('gap_between_zones')
|
||||
if gap_between_zones.set then
|
||||
return
|
||||
end
|
||||
|
||||
if collapse_amount then
|
||||
Collapse.set_amount(collapse_amount)
|
||||
else
|
||||
Collapse.set_amount(amount)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.render_direction(surface)
|
||||
local counter = WPT.get('soft_reset_counter')
|
||||
if counter then
|
||||
rendering.draw_text {
|
||||
text = 'Welcome to Mountain Fortress v3!\nRun: ' .. counter,
|
||||
surface = surface,
|
||||
target = {-0, 10},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
else
|
||||
rendering.draw_text {
|
||||
text = 'Welcome to Mountain Fortress v3!',
|
||||
surface = surface,
|
||||
target = {-0, 10},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
end
|
||||
|
||||
rendering.draw_text {
|
||||
text = '▼',
|
||||
surface = surface,
|
||||
target = {-0, 20},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
|
||||
rendering.draw_text {
|
||||
text = '▼',
|
||||
surface = surface,
|
||||
target = {-0, 30},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
rendering.draw_text {
|
||||
text = '▼',
|
||||
surface = surface,
|
||||
target = {-0, 40},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
rendering.draw_text {
|
||||
text = '▼',
|
||||
surface = surface,
|
||||
target = {-0, 50},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
rendering.draw_text {
|
||||
text = '▼',
|
||||
surface = surface,
|
||||
target = {-0, 60},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
rendering.draw_text {
|
||||
text = 'Biters will attack this area.',
|
||||
surface = surface,
|
||||
target = {-0, 70},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
|
||||
local x_min = -WPT.level_width / 2
|
||||
local x_max = WPT.level_width / 2
|
||||
|
||||
surface.create_entity({name = 'electric-beam', position = {x_min, 74}, source = {x_min, 74}, target = {x_max, 74}})
|
||||
surface.create_entity({name = 'electric-beam', position = {x_min, 74}, source = {x_min, 74}, target = {x_max, 74}})
|
||||
end
|
||||
|
||||
function Public.boost_difficulty()
|
||||
local difficulty_set = WPT.get('difficulty_set')
|
||||
if difficulty_set then
|
||||
return
|
||||
end
|
||||
|
||||
local breached_wall = WPT.get('breached_wall')
|
||||
|
||||
local difficulty = Difficulty.get()
|
||||
local name = difficulty.difficulties[difficulty.difficulty_vote_index].name
|
||||
|
||||
if game.tick < difficulty.difficulty_poll_closing_timeout and breached_wall <= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
Difficulty.get().name = name
|
||||
Difficulty.get().difficulty_poll_closing_timeout = game.tick
|
||||
|
||||
Difficulty.get().button_tooltip = difficulty.tooltip[difficulty.difficulty_vote_index]
|
||||
Difficulty.difficulty_gui()
|
||||
|
||||
local message = ({'main.diff_set', name})
|
||||
local data = {
|
||||
position = WPT.get('locomotive').position
|
||||
}
|
||||
Alert.alert_all_players_location(data, message)
|
||||
|
||||
local force = game.forces.player
|
||||
|
||||
if name == "I'm too young to die" then
|
||||
-- rpg_extra.difficulty = 1
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.5
|
||||
force.character_running_speed_modifier = 0.15
|
||||
force.manual_crafting_speed_modifier = 0.15
|
||||
WPT.set().coin_amount = 1
|
||||
WPT.set('upgrades').flame_turret.limit = 12
|
||||
WPT.set('upgrades').landmine.limit = 50
|
||||
WPT.set().locomotive_health = 10000
|
||||
WPT.set().locomotive_max_health = 10000
|
||||
WPT.set().bonus_xp_on_join = 500
|
||||
WD.set().next_wave = game.tick + 3600 * 15
|
||||
WPT.set().spidertron_unlocked_at_wave = 14
|
||||
WPT.set().difficulty_set = true
|
||||
WD.set_biter_health_boost(1.50)
|
||||
elseif name == 'Hurt me plenty' then
|
||||
-- rpg_extra.difficulty = 0.5
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.25
|
||||
force.character_running_speed_modifier = 0.1
|
||||
force.manual_crafting_speed_modifier = 0.1
|
||||
WPT.set().coin_amount = 1
|
||||
WPT.set('upgrades').flame_turret.limit = 10
|
||||
WPT.set('upgrades').landmine.limit = 50
|
||||
WPT.set().locomotive_health = 7000
|
||||
WPT.set().locomotive_max_health = 7000
|
||||
WPT.set().bonus_xp_on_join = 300
|
||||
WD.set().next_wave = game.tick + 3600 * 10
|
||||
WPT.set().spidertron_unlocked_at_wave = 16
|
||||
WPT.set().difficulty_set = true
|
||||
WD.set_biter_health_boost(2)
|
||||
elseif name == 'Ultra-violence' then
|
||||
-- rpg_extra.difficulty = 0
|
||||
force.character_running_speed_modifier = 0
|
||||
force.manual_crafting_speed_modifier = 0
|
||||
WPT.set().coin_amount = 1
|
||||
WPT.set('upgrades').flame_turret.limit = 3
|
||||
WPT.set('upgrades').landmine.limit = 10
|
||||
WPT.set().locomotive_health = 5000
|
||||
WPT.set().locomotive_max_health = 5000
|
||||
WPT.set().bonus_xp_on_join = 50
|
||||
WD.set().next_wave = game.tick + 3600 * 5
|
||||
WPT.set().spidertron_unlocked_at_wave = 18
|
||||
WPT.set().difficulty_set = true
|
||||
WD.set_biter_health_boost(3)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.set_spawn_position()
|
||||
local collapse_pos = Collapse.get_position()
|
||||
local locomotive = WPT.get('locomotive')
|
||||
if not locomotive or not locomotive.valid then
|
||||
return
|
||||
end
|
||||
local l = locomotive.position
|
||||
|
||||
local retries = 0
|
||||
|
||||
local function check_tile(surface, tile, tbl, inc)
|
||||
if not (surface and surface.valid) then
|
||||
return false
|
||||
end
|
||||
if not tile then
|
||||
return false
|
||||
end
|
||||
local get_tile = surface.get_tile(tile)
|
||||
if get_tile.valid and get_tile.name == 'out-of-map' then
|
||||
remove(tbl.tbl, inc - inc + 1)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
::retry::
|
||||
|
||||
local locomotive_positions = WPT.get('locomotive_pos')
|
||||
local total_pos = #locomotive_positions.tbl
|
||||
|
||||
local active_surface_index = WPT.get('active_surface_index')
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
if not (surface and surface.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
local spawn_near_collapse = WPT.get('spawn_near_collapse')
|
||||
|
||||
if spawn_near_collapse.active then
|
||||
local collapse_position = surface.find_non_colliding_position('small-biter', collapse_pos, 32, 2)
|
||||
local sizeof = locomotive_positions.tbl[total_pos - total_pos + 1]
|
||||
if check_tile(surface, sizeof, locomotive_positions.tbl, total_pos) then
|
||||
retries = retries + 1
|
||||
if retries == 2 then
|
||||
goto continue
|
||||
end
|
||||
goto retry
|
||||
end
|
||||
|
||||
local locomotive_position = surface.find_non_colliding_position('small-biter', sizeof, 128, 1)
|
||||
local distance_from = floor(math2d.position.distance(locomotive_position, locomotive.position))
|
||||
local l_y = l.y
|
||||
local t_y = locomotive_position.y
|
||||
local c_y = collapse_pos.y
|
||||
if total_pos > spawn_near_collapse.total_pos then
|
||||
if l_y - t_y <= spawn_near_collapse.compare then
|
||||
if locomotive_position then
|
||||
if check_tile(surface, sizeof, locomotive_positions.tbl, total_pos) then
|
||||
debug_str('total_pos was higher - found oom')
|
||||
retries = retries + 1
|
||||
if retries == 2 then
|
||||
goto continue
|
||||
end
|
||||
goto retry
|
||||
end
|
||||
debug_str('total_pos was higher - spawning at locomotive_position')
|
||||
WD.set_spawn_position(locomotive_position)
|
||||
end
|
||||
elseif c_y - t_y <= spawn_near_collapse.compare_next then
|
||||
if distance_from >= spawn_near_collapse.distance_from then
|
||||
local success = check_tile(surface, locomotive_position, locomotive_positions.tbl, total_pos)
|
||||
if success then
|
||||
debug_str('distance_from was higher - found oom')
|
||||
return
|
||||
end
|
||||
debug_str('distance_from was higher - spawning at locomotive_position')
|
||||
WD.set_spawn_position({x = locomotive_position.x, y = collapse_pos.y - 20})
|
||||
else
|
||||
debug_str('distance_from was lower - spawning at locomotive_position')
|
||||
WD.set_spawn_position({x = locomotive_position.x, y = collapse_pos.y - 20})
|
||||
end
|
||||
else
|
||||
if collapse_position then
|
||||
debug_str('total_pos was higher - spawning at collapse_position')
|
||||
WD.set_spawn_position(collapse_position)
|
||||
end
|
||||
end
|
||||
else
|
||||
if collapse_position then
|
||||
debug_str('total_pos was lower - spawning at collapse_position')
|
||||
WD.set_spawn_position(collapse_position)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
::continue::
|
||||
end
|
||||
|
||||
function Public.on_player_joined_game(event)
|
||||
local active_surface_index = WPT.get('active_surface_index')
|
||||
local player = game.players[event.player_index]
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
|
||||
Public.set_difficulty()
|
||||
|
||||
ICW_Func.is_minimap_valid(player, surface)
|
||||
|
||||
local player_data = get_player_data(player)
|
||||
|
||||
if not player_data.first_join then
|
||||
local message = ({'main.greeting', player.name})
|
||||
Alert.alert_player(player, 15, message)
|
||||
for item, amount in pairs(starting_items) do
|
||||
player.insert({name = item, count = amount})
|
||||
end
|
||||
player_data.first_join = true
|
||||
end
|
||||
|
||||
if player.surface.index ~= active_surface_index then
|
||||
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
|
||||
else
|
||||
local p = {x = player.position.x, y = player.position.y}
|
||||
local get_tile = surface.get_tile(p)
|
||||
if get_tile.valid and get_tile.name == 'out-of-map' then
|
||||
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
|
||||
end
|
||||
end
|
||||
|
||||
local locomotive = WPT.get('locomotive')
|
||||
|
||||
if not locomotive or not locomotive.valid then
|
||||
return
|
||||
end
|
||||
if player.position.y > locomotive.position.y then
|
||||
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.on_player_left_game()
|
||||
Public.set_difficulty()
|
||||
end
|
||||
|
||||
function Public.on_pre_player_left_game(event)
|
||||
local offline_players_enabled = WPT.get('offline_players_enabled')
|
||||
if not offline_players_enabled then
|
||||
return
|
||||
end
|
||||
|
||||
local offline_players = WPT.get('offline_players')
|
||||
local player = game.players[event.player_index]
|
||||
local ticker = game.tick
|
||||
if player.character then
|
||||
offline_players[#offline_players + 1] = {
|
||||
index = event.player_index,
|
||||
name = player.name,
|
||||
tick = ticker
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function Public.on_player_respawned(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if not (player and player.valid) then
|
||||
return
|
||||
end
|
||||
local player_data = get_player_data(player)
|
||||
if player_data.died then
|
||||
player_data.died = nil
|
||||
end
|
||||
end
|
||||
|
||||
function Public.on_player_died(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if not (player and player.valid) then
|
||||
return
|
||||
end
|
||||
local player_data = get_player_data(player)
|
||||
player_data.died = true
|
||||
end
|
||||
|
||||
function Public.on_player_changed_position(event)
|
||||
local active_surface_index = WPT.get('active_surface_index')
|
||||
if not active_surface_index then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
local map_name = 'mountain_fortress_v3'
|
||||
|
||||
if string.sub(player.surface.name, 0, #map_name) ~= map_name then
|
||||
return
|
||||
end
|
||||
|
||||
local position = player.position
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
|
||||
local p = {x = player.position.x, y = player.position.y}
|
||||
local get_tile = surface.get_tile(p)
|
||||
local config_tile = WPT.get('void_or_tile')
|
||||
if config_tile == 'lab-dark-2' then
|
||||
if get_tile.valid and get_tile.name == 'lab-dark-2' then
|
||||
if random(1, 2) == 1 then
|
||||
if random(1, 2) == 1 then
|
||||
show_text('This path is not for players!', p, {r = 0.98, g = 0.66, b = 0.22}, surface)
|
||||
end
|
||||
player.surface.create_entity({name = 'fire-flame', position = player.position})
|
||||
player.character.health = player.character.health - tile_damage
|
||||
if player.character.health == 0 then
|
||||
player.character.die()
|
||||
local message = ({'main.death_message_' .. random(1, 7), player.name})
|
||||
game.print(message, {r = 0.98, g = 0.66, b = 0.22})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if position.y >= 74 then
|
||||
player.teleport({position.x, position.y - 1}, surface)
|
||||
player.print(({'main.forcefield'}), {r = 0.98, g = 0.66, b = 0.22})
|
||||
if player.character then
|
||||
player.character.health = player.character.health - 5
|
||||
player.character.surface.create_entity({name = 'water-splash', position = position})
|
||||
if player.character.health <= 0 then
|
||||
player.character.die('enemy')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local disable_recipes = function()
|
||||
local force = game.forces.player
|
||||
force.recipes['cargo-wagon'].enabled = false
|
||||
force.recipes['fluid-wagon'].enabled = false
|
||||
force.recipes['car'].enabled = false
|
||||
force.recipes['tank'].enabled = false
|
||||
force.recipes['artillery-wagon'].enabled = false
|
||||
force.recipes['locomotive'].enabled = false
|
||||
force.recipes['pistol'].enabled = false
|
||||
end
|
||||
|
||||
function Public.disable_tech()
|
||||
game.forces.player.technologies['landfill'].enabled = false
|
||||
game.forces.player.technologies['spidertron'].enabled = false
|
||||
game.forces.player.technologies['spidertron'].researched = false
|
||||
game.forces.player.technologies['optics'].researched = true
|
||||
game.forces.player.technologies['railway'].researched = true
|
||||
game.forces.player.technologies['land-mine'].enabled = false
|
||||
disable_recipes()
|
||||
end
|
||||
|
||||
local disable_tech = Public.disable_tech
|
||||
|
||||
function Public.on_research_finished(event)
|
||||
disable_tech()
|
||||
|
||||
local research = event.research
|
||||
|
||||
research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 50 -- +5 Slots /
|
||||
|
||||
if research.name == 'steel-axe' then
|
||||
local msg = 'Steel-axe technology has been researched, 100% has been applied.\nBuy Pickaxe-upgrades in the market to boost it even more!'
|
||||
Alert.alert_all_players(30, msg, nil, 'achievement/tech-maniac', 0.6)
|
||||
end -- +50% speed for steel-axe research
|
||||
|
||||
local force_name = research.force.name
|
||||
if not force_name then
|
||||
return
|
||||
end
|
||||
local flamethrower_damage = WPT.get('flamethrower_damage')
|
||||
flamethrower_damage[force_name] = -0.85
|
||||
if research.name == 'military' then
|
||||
game.forces[force_name].set_turret_attack_modifier('flamethrower-turret', flamethrower_damage[force_name])
|
||||
game.forces[force_name].set_ammo_damage_modifier('flamethrower', flamethrower_damage[force_name])
|
||||
end
|
||||
|
||||
if string.sub(research.name, 0, 18) == 'refined-flammables' then
|
||||
flamethrower_damage[force_name] = flamethrower_damage[force_name] + 0.10
|
||||
game.forces[force_name].set_turret_attack_modifier('flamethrower-turret', flamethrower_damage[force_name])
|
||||
game.forces[force_name].set_ammo_damage_modifier('flamethrower', flamethrower_damage[force_name])
|
||||
end
|
||||
end
|
||||
|
||||
Public.firearm_magazine_ammo = {name = 'firearm-magazine', count = 200}
|
||||
Public.piercing_rounds_magazine_ammo = {name = 'piercing-rounds-magazine', count = 200}
|
||||
Public.uranium_rounds_magazine_ammo = {name = 'uranium-rounds-magazine', count = 200}
|
||||
@ -603,9 +1250,22 @@ function Public.reset_table()
|
||||
this.magic_fluid_crafters = {index = 1}
|
||||
end
|
||||
|
||||
local on_player_joined_game = Public.on_player_joined_game
|
||||
local on_player_left_game = Public.on_player_left_game
|
||||
local on_player_respawned = Public.on_player_respawned
|
||||
local on_player_died = Public.on_player_died
|
||||
local on_research_finished = Public.on_research_finished
|
||||
local on_player_changed_position = Public.on_player_changed_position
|
||||
local on_pre_player_left_game = Public.on_pre_player_left_game
|
||||
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_player_left_game, on_player_left_game)
|
||||
Event.add(defines.events.on_player_respawned, on_player_respawned)
|
||||
Event.add(defines.events.on_player_died, on_player_died)
|
||||
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_pre_player_left_game, on_pre_player_left_game)
|
||||
Event.on_nth_tick(10, tick)
|
||||
Event.on_nth_tick(5, do_turret_energy)
|
||||
--Event.add(defines.events.on_tick, tick)
|
||||
-- Event.add(defines.events.on_entity_died, turret_died)
|
||||
|
||||
return Public
|
||||
|
@ -271,10 +271,11 @@ local function on_player_changed_surface(event)
|
||||
if charging and not charging.visible then
|
||||
charging.visible = true
|
||||
end
|
||||
|
||||
info.tooltip = ({'gui.info_tooltip'})
|
||||
info.sprite = 'item/dummy-steel-axe'
|
||||
info.visible = true
|
||||
if info then
|
||||
info.tooltip = ({'gui.info_tooltip'})
|
||||
info.sprite = 'item/dummy-steel-axe'
|
||||
info.visible = true
|
||||
end
|
||||
elseif player.surface == wagon_surface then
|
||||
if wd then
|
||||
wd.visible = false
|
||||
@ -355,13 +356,11 @@ function Public.update_gui(player)
|
||||
gui.biters_killed.caption = ' [img=entity.small-biter]: ' .. format_number(biters_killed, true)
|
||||
gui.biters_killed.tooltip = ({'gui.biters_killed'})
|
||||
|
||||
gui.landmine.caption =
|
||||
' [img=entity.land-mine]: ' .. format_number(upgrades.landmine.built, true) .. ' / ' .. format_number(upgrades.landmine.limit, true)
|
||||
gui.landmine.caption = ' [img=entity.land-mine]: ' .. format_number(upgrades.landmine.built, true) .. ' / ' .. format_number(upgrades.landmine.limit, true)
|
||||
gui.landmine.tooltip = ({'gui.land_mine_placed'})
|
||||
|
||||
gui.flame_turret.caption =
|
||||
' [img=entity.flamethrower-turret]: ' ..
|
||||
format_number(upgrades.flame_turret.built, true) .. ' / ' .. format_number(upgrades.flame_turret.limit, true)
|
||||
' [img=entity.flamethrower-turret]: ' .. format_number(upgrades.flame_turret.built, true) .. ' / ' .. format_number(upgrades.flame_turret.limit, true)
|
||||
gui.flame_turret.tooltip = ({'gui.flamethrowers_placed'})
|
||||
|
||||
gui.train_upgrades.caption = ' [img=entity.locomotive]: ' .. format_number(train_upgrades, true)
|
||||
|
@ -490,14 +490,7 @@ local function construct_doors(ic, car)
|
||||
local surface = car.surface
|
||||
|
||||
for _, x in pairs({area.left_top.x - 1.5, area.right_bottom.x + 1.5}) do
|
||||
local p
|
||||
if car.name == 'car' then
|
||||
p = {x = x, y = area.left_top.y + 10}
|
||||
elseif car.name == 'tank' then
|
||||
p = {x = x, y = area.left_top.y + 20}
|
||||
elseif car.name == 'spidertron' then
|
||||
p = {x = x, y = area.left_top.y + 30}
|
||||
end
|
||||
local p = {x = x, y = area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)}
|
||||
if p.x < 0 then
|
||||
surface.set_tiles({{name = main_tile_name, position = {x = p.x + 0.5, y = p.y}}}, true)
|
||||
else
|
||||
|
@ -2,7 +2,7 @@ local Public = {}
|
||||
|
||||
local ICW = require 'maps.mountain_fortress_v3.icw.table'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local main_tile_name = 'black-refined-concrete'
|
||||
local main_tile_name = 'tutorial-grid'
|
||||
|
||||
function Public.request_reconstruction(icw)
|
||||
icw.rebuild_tick = game.tick + 30
|
||||
@ -274,7 +274,7 @@ local function construct_wagon_doors(icw, wagon)
|
||||
local surface = wagon.surface
|
||||
|
||||
for _, x in pairs({area.left_top.x - 1.5, area.right_bottom.x + 1.5}) do
|
||||
local p = {x = x, y = area.left_top.y + 30}
|
||||
local p = {x = x, y = area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)}
|
||||
if p.x < 0 then
|
||||
surface.set_tiles({{name = main_tile_name, position = {x = p.x + 0.5, y = p.y}}}, true)
|
||||
else
|
||||
@ -933,4 +933,26 @@ function Public.toggle_minimap(icw, event)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.on_player_or_robot_built_tile(event)
|
||||
local surface = game.surfaces[event.surface_index]
|
||||
|
||||
local map_name = 'mountain_fortress_v3'
|
||||
|
||||
if string.sub(surface.name, 0, #map_name) == map_name then
|
||||
return
|
||||
end
|
||||
|
||||
local tiles = event.tiles
|
||||
if not tiles then
|
||||
return
|
||||
end
|
||||
|
||||
for k, v in pairs(tiles) do
|
||||
local old_tile = v.old_tile
|
||||
if old_tile.name == 'water' then
|
||||
surface.set_tiles({{name = 'water', position = v.position}}, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Public
|
||||
|
@ -121,6 +121,8 @@ function Public.register_wagon(wagon_entity)
|
||||
return Functions.create_wagon(icw, wagon_entity)
|
||||
end
|
||||
|
||||
local on_player_or_robot_built_tile = Functions.on_player_or_robot_built_tile
|
||||
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_tick, on_tick)
|
||||
Event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state)
|
||||
@ -131,13 +133,7 @@ Event.add(defines.events.on_player_died, on_player_died)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
Event.add(defines.events.on_gui_closed, on_gui_closed)
|
||||
Event.add(defines.events.on_gui_opened, on_gui_opened)
|
||||
Event.add(
|
||||
defines.events.on_built_entity,
|
||||
function(event)
|
||||
local created_entity = event.created_entity
|
||||
local icw = ICW.get()
|
||||
Functions.create_wagon(icw, created_entity)
|
||||
end
|
||||
)
|
||||
Event.add(defines.events.on_player_built_tile, on_player_or_robot_built_tile)
|
||||
Event.add(defines.events.on_robot_built_tile, on_player_or_robot_built_tile)
|
||||
|
||||
return Public
|
||||
|
@ -36,10 +36,10 @@ function Public.reset()
|
||||
}
|
||||
|
||||
this.wagon_areas = {
|
||||
['cargo-wagon'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}},
|
||||
['artillery-wagon'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}},
|
||||
['fluid-wagon'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}},
|
||||
['locomotive'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 60}}
|
||||
['cargo-wagon'] = {left_top = {x = -30, y = 0}, right_bottom = {x = 30, y = 80}},
|
||||
['artillery-wagon'] = {left_top = {x = -30, y = 0}, right_bottom = {x = 30, y = 80}},
|
||||
['fluid-wagon'] = {left_top = {x = -30, y = 0}, right_bottom = {x = 30, y = 80}},
|
||||
['locomotive'] = {left_top = {x = -30, y = 0}, right_bottom = {x = 30, y = 80}}
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -141,7 +141,7 @@ local set_loco_tiles =
|
||||
end
|
||||
end
|
||||
|
||||
MapFunctions.draw_noise_tile_circle(position, 'stone-path', surface, 15)
|
||||
MapFunctions.draw_noise_tile_circle(position, 'blue-refined-concrete', surface, 15)
|
||||
|
||||
for i = 1, #cargo_boxes, 1 do
|
||||
if not p[i] then
|
||||
@ -149,6 +149,7 @@ local set_loco_tiles =
|
||||
end
|
||||
if surface.can_place_entity({name = 'wooden-chest', position = p[i]}) then
|
||||
local e = surface.create_entity({name = 'wooden-chest', position = p[i], force = 'player', create_build_effect_smoke = false})
|
||||
e.minable = false
|
||||
local inventory = e.get_inventory(defines.inventory.chest)
|
||||
inventory.insert(cargo_boxes[i])
|
||||
end
|
||||
@ -723,7 +724,7 @@ local function slider_changed(event)
|
||||
end
|
||||
slider_value = ceil(slider_value)
|
||||
if players[player.index] and players[player.index].data and players[player.index].data.text_input then
|
||||
players[player.index].data.text_input.text = slider_value
|
||||
players[player.index].data.text_input.text = tostring(slider_value)
|
||||
redraw_market_items(players[player.index].data.item_frame, player, players[player.index].data.search_text)
|
||||
end
|
||||
end
|
||||
@ -767,7 +768,7 @@ local function text_changed(event)
|
||||
value = 1
|
||||
end
|
||||
|
||||
data.slider.slider_value = value
|
||||
data.slider.slider_value = tostring(value)
|
||||
|
||||
redraw_market_items(data.item_frame, player, data.search_text)
|
||||
end
|
||||
|
@ -1,19 +1,8 @@
|
||||
require 'maps.mountain_fortress_v3.generate'
|
||||
require 'maps.mountain_fortress_v3.commands'
|
||||
require 'maps.mountain_fortress_v3.breached_wall'
|
||||
require 'maps.mountain_fortress_v3.ic.main'
|
||||
require 'maps.mountain_fortress_v3.biters_yield_coins'
|
||||
|
||||
require 'modules.rpg.main'
|
||||
require 'modules.shotgun_buff'
|
||||
require 'modules.no_deconstruction_of_neutral_entities'
|
||||
require 'modules.rocks_yield_ore_veins'
|
||||
require 'modules.spawners_contain_biters'
|
||||
require 'modules.wave_defense.main'
|
||||
require 'modules.charging_station'
|
||||
|
||||
local Functions = require 'maps.mountain_fortress_v3.functions'
|
||||
local BuriedEnemies = require 'maps.mountain_fortress_v3.buried_enemies'
|
||||
local math2d = require 'math2d'
|
||||
|
||||
-- local HS = require 'maps.mountain_fortress_v3.highscore'
|
||||
local IC = require 'maps.mountain_fortress_v3.ic.table'
|
||||
local Autostash = require 'modules.autostash'
|
||||
@ -26,13 +15,11 @@ local Balance = require 'maps.mountain_fortress_v3.balance'
|
||||
local Entities = require 'maps.mountain_fortress_v3.entities'
|
||||
local Gui_mf = require 'maps.mountain_fortress_v3.gui'
|
||||
local ICW = require 'maps.mountain_fortress_v3.icw.main'
|
||||
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local Map = require 'modules.map_info'
|
||||
local RPG_Settings = require 'modules.rpg.table'
|
||||
local RPG_Func = require 'modules.rpg.functions'
|
||||
local Terrain = require 'maps.mountain_fortress_v3.terrain'
|
||||
local Functions = require 'maps.mountain_fortress_v3.functions'
|
||||
local Event = require 'utils.event'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local Locomotive = require 'maps.mountain_fortress_v3.locomotive'
|
||||
@ -45,13 +32,22 @@ local Token = require 'utils.token'
|
||||
local Alert = require 'utils.alert'
|
||||
local AntiGrief = require 'antigrief'
|
||||
|
||||
require 'maps.mountain_fortress_v3.generate'
|
||||
require 'maps.mountain_fortress_v3.commands'
|
||||
require 'maps.mountain_fortress_v3.breached_wall'
|
||||
require 'maps.mountain_fortress_v3.ic.main'
|
||||
require 'maps.mountain_fortress_v3.biters_yield_coins'
|
||||
|
||||
require 'modules.shotgun_buff'
|
||||
require 'modules.no_deconstruction_of_neutral_entities'
|
||||
require 'modules.rocks_yield_ore_veins'
|
||||
require 'modules.spawners_contain_biters'
|
||||
require 'modules.wave_defense.main'
|
||||
require 'modules.charging_station'
|
||||
|
||||
local Public = {}
|
||||
local floor = math.floor
|
||||
local random = math.random
|
||||
local remove = table.remove
|
||||
local tile_damage = 50
|
||||
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16, ['wood'] = 16, ['explosives'] = 32}
|
||||
|
||||
local collapse_kill = {
|
||||
entities = {
|
||||
@ -72,46 +68,6 @@ local collapse_kill = {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
local function debug_str(msg)
|
||||
local debug = WPT.get('debug')
|
||||
if not debug then
|
||||
return
|
||||
end
|
||||
print('Mtn: ' .. msg)
|
||||
end
|
||||
|
||||
local function get_player_data(player, remove_user_data)
|
||||
local players = WPT.get('players')
|
||||
if remove_user_data then
|
||||
if players[player.index] then
|
||||
players[player.index] = nil
|
||||
end
|
||||
end
|
||||
if not players[player.index] then
|
||||
players[player.index] = {}
|
||||
end
|
||||
return players[player.index]
|
||||
end
|
||||
|
||||
local disable_recipes = function()
|
||||
local force = game.forces.player
|
||||
force.recipes['cargo-wagon'].enabled = false
|
||||
force.recipes['fluid-wagon'].enabled = false
|
||||
force.recipes['car'].enabled = false
|
||||
force.recipes['tank'].enabled = false
|
||||
force.recipes['artillery-wagon'].enabled = false
|
||||
force.recipes['locomotive'].enabled = false
|
||||
force.recipes['pistol'].enabled = false
|
||||
end
|
||||
|
||||
local show_text = function(msg, pos, color, surface)
|
||||
if color == nil then
|
||||
surface.create_entity({name = 'flying-text', position = pos, text = msg})
|
||||
else
|
||||
surface.create_entity({name = 'flying-text', position = pos, text = msg, color = color})
|
||||
end
|
||||
end
|
||||
|
||||
local init_new_force = function()
|
||||
local new_force = game.forces.protectors
|
||||
local enemy = game.forces.enemy
|
||||
@ -122,16 +78,6 @@ local init_new_force = function()
|
||||
enemy.set_friend('protectors', true)
|
||||
end
|
||||
|
||||
local disable_tech = function()
|
||||
game.forces.player.technologies['landfill'].enabled = false
|
||||
game.forces.player.technologies['spidertron'].enabled = false
|
||||
game.forces.player.technologies['spidertron'].researched = false
|
||||
game.forces.player.technologies['optics'].researched = true
|
||||
game.forces.player.technologies['railway'].researched = true
|
||||
game.forces.player.technologies['land-mine'].enabled = false
|
||||
disable_recipes()
|
||||
end
|
||||
|
||||
local is_position_near_tbl = function(position, tbl)
|
||||
local status = false
|
||||
local function inside(pos)
|
||||
@ -147,151 +93,6 @@ local is_position_near_tbl = function(position, tbl)
|
||||
return status
|
||||
end
|
||||
|
||||
local set_difficulty = function()
|
||||
local Diff = Difficulty.get()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local collapse_amount = WPT.get('collapse_amount')
|
||||
local player_count = #game.connected_players
|
||||
if not Diff.difficulty_vote_value then
|
||||
Diff.difficulty_vote_value = 0.1
|
||||
end
|
||||
|
||||
wave_defense_table.max_active_biters = 888 + player_count * (90 * Diff.difficulty_vote_value)
|
||||
|
||||
if wave_defense_table.max_active_biters >= 1600 then
|
||||
wave_defense_table.max_active_biters = 1600
|
||||
end
|
||||
|
||||
-- threat gain / wave
|
||||
wave_defense_table.threat_gain_multiplier = 1.2 + player_count * Diff.difficulty_vote_value * 0.1
|
||||
|
||||
local amount = player_count * 0.05
|
||||
amount = floor(amount)
|
||||
if amount <= 0 then
|
||||
amount = 1
|
||||
end
|
||||
if amount > 3 then
|
||||
amount = 3
|
||||
end
|
||||
|
||||
if wave_defense_table.threat <= 0 then
|
||||
wave_defense_table.wave_interval = 1000
|
||||
end
|
||||
|
||||
wave_defense_table.wave_interval = 3600 - player_count * 60
|
||||
if wave_defense_table.wave_interval < 1800 then
|
||||
wave_defense_table.wave_interval = 1800
|
||||
end
|
||||
|
||||
local gap_between_zones = WPT.get('gap_between_zones')
|
||||
if gap_between_zones.set then
|
||||
return
|
||||
end
|
||||
|
||||
if collapse_amount then
|
||||
Collapse.set_amount(collapse_amount)
|
||||
else
|
||||
Collapse.set_amount(amount)
|
||||
end
|
||||
|
||||
Collapse.set_speed(1)
|
||||
end
|
||||
|
||||
local render_direction = function(surface)
|
||||
local counter = WPT.get('soft_reset_counter')
|
||||
if counter then
|
||||
rendering.draw_text {
|
||||
text = 'Welcome to Mountain Fortress v3!\nRun: ' .. counter,
|
||||
surface = surface,
|
||||
target = {-0, 10},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
else
|
||||
rendering.draw_text {
|
||||
text = 'Welcome to Mountain Fortress v3!',
|
||||
surface = surface,
|
||||
target = {-0, 10},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
end
|
||||
|
||||
rendering.draw_text {
|
||||
text = '▼',
|
||||
surface = surface,
|
||||
target = {-0, 20},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
|
||||
rendering.draw_text {
|
||||
text = '▼',
|
||||
surface = surface,
|
||||
target = {-0, 30},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
rendering.draw_text {
|
||||
text = '▼',
|
||||
surface = surface,
|
||||
target = {-0, 40},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
rendering.draw_text {
|
||||
text = '▼',
|
||||
surface = surface,
|
||||
target = {-0, 50},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
rendering.draw_text {
|
||||
text = '▼',
|
||||
surface = surface,
|
||||
target = {-0, 60},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
rendering.draw_text {
|
||||
text = 'Biters will attack this area.',
|
||||
surface = surface,
|
||||
target = {-0, 70},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
|
||||
local x_min = -Terrain.level_width / 2
|
||||
local x_max = Terrain.level_width / 2
|
||||
|
||||
surface.create_entity({name = 'electric-beam', position = {x_min, 74}, source = {x_min, 74}, target = {x_max, 74}})
|
||||
surface.create_entity({name = 'electric-beam', position = {x_min, 74}, source = {x_min, 74}, target = {x_max, 74}})
|
||||
end
|
||||
|
||||
function Public.reset_map()
|
||||
local Diff = Difficulty.get()
|
||||
local this = WPT.get()
|
||||
@ -327,7 +128,7 @@ function Public.reset_map()
|
||||
Group.reset_groups()
|
||||
Group.alphanumeric_only(false)
|
||||
|
||||
disable_tech()
|
||||
Functions.disable_tech()
|
||||
init_new_force()
|
||||
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
@ -362,7 +163,7 @@ function Public.reset_map()
|
||||
Collapse.set_kill_specific_entities(collapse_kill)
|
||||
Collapse.set_speed(8)
|
||||
Collapse.set_amount(1)
|
||||
Collapse.set_max_line_size(Terrain.level_width)
|
||||
Collapse.set_max_line_size(WPT.level_width)
|
||||
Collapse.set_surface(surface)
|
||||
Collapse.set_position({0, 130})
|
||||
Collapse.set_direction('north')
|
||||
@ -373,7 +174,7 @@ function Public.reset_map()
|
||||
|
||||
Locomotive.locomotive_spawn(surface, {x = -18, y = 25})
|
||||
Locomotive.render_train_hp()
|
||||
render_direction(surface)
|
||||
Functions.render_direction(surface)
|
||||
|
||||
WD.reset_wave_defense()
|
||||
wave_defense_table.surface_index = this.active_surface_index
|
||||
@ -388,7 +189,7 @@ function Public.reset_map()
|
||||
WD.check_collapse_position(true)
|
||||
WD.set_disable_threat_below_zero(true)
|
||||
|
||||
set_difficulty()
|
||||
Functions.set_difficulty()
|
||||
|
||||
if not surface.is_chunk_generated({-20, 22}) then
|
||||
surface.request_to_generate_chunks({-20, 22}, 0.1)
|
||||
@ -404,147 +205,6 @@ function Public.reset_map()
|
||||
this.game_lost = false
|
||||
end
|
||||
|
||||
local on_player_changed_position = function(event)
|
||||
local active_surface_index = WPT.get('active_surface_index')
|
||||
if not active_surface_index then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
local map_name = 'mountain_fortress_v3'
|
||||
|
||||
if string.sub(player.surface.name, 0, #map_name) ~= map_name then
|
||||
return
|
||||
end
|
||||
|
||||
local position = player.position
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
|
||||
local p = {x = player.position.x, y = player.position.y}
|
||||
local get_tile = surface.get_tile(p)
|
||||
local config_tile = WPT.get('void_or_tile')
|
||||
if config_tile == 'lab-dark-2' then
|
||||
if get_tile.valid and get_tile.name == 'lab-dark-2' then
|
||||
if random(1, 2) == 1 then
|
||||
if random(1, 2) == 1 then
|
||||
show_text('This path is not for players!', p, {r = 0.98, g = 0.66, b = 0.22}, surface)
|
||||
end
|
||||
player.surface.create_entity({name = 'fire-flame', position = player.position})
|
||||
player.character.health = player.character.health - tile_damage
|
||||
if player.character.health == 0 then
|
||||
player.character.die()
|
||||
local message = ({'main.death_message_' .. random(1, 7), player.name})
|
||||
game.print(message, {r = 0.98, g = 0.66, b = 0.22})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if position.y >= 74 then
|
||||
player.teleport({position.x, position.y - 1}, surface)
|
||||
player.print(({'main.forcefield'}), {r = 0.98, g = 0.66, b = 0.22})
|
||||
if player.character then
|
||||
player.character.health = player.character.health - 5
|
||||
player.character.surface.create_entity({name = 'water-splash', position = position})
|
||||
if player.character.health <= 0 then
|
||||
player.character.die('enemy')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local on_player_joined_game = function(event)
|
||||
local active_surface_index = WPT.get('active_surface_index')
|
||||
local player = game.players[event.player_index]
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
|
||||
set_difficulty()
|
||||
|
||||
ICW_Func.is_minimap_valid(player, surface)
|
||||
|
||||
local player_data = get_player_data(player)
|
||||
|
||||
if not player_data.first_join then
|
||||
local message = ({'main.greeting', player.name})
|
||||
Alert.alert_player(player, 15, message)
|
||||
for item, amount in pairs(starting_items) do
|
||||
player.insert({name = item, count = amount})
|
||||
end
|
||||
player_data.first_join = true
|
||||
end
|
||||
|
||||
if player.surface.index ~= active_surface_index then
|
||||
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
|
||||
else
|
||||
local p = {x = player.position.x, y = player.position.y}
|
||||
local get_tile = surface.get_tile(p)
|
||||
if get_tile.valid and get_tile.name == 'out-of-map' then
|
||||
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
|
||||
end
|
||||
end
|
||||
|
||||
local locomotive = WPT.get('locomotive')
|
||||
|
||||
if not locomotive or not locomotive.valid then
|
||||
return
|
||||
end
|
||||
if player.position.y > locomotive.position.y then
|
||||
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
|
||||
end
|
||||
end
|
||||
|
||||
local on_player_left_game = function()
|
||||
set_difficulty()
|
||||
end
|
||||
|
||||
local on_player_respawned = function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if not (player and player.valid) then
|
||||
return
|
||||
end
|
||||
local player_data = get_player_data(player)
|
||||
if player_data.died then
|
||||
player_data.died = nil
|
||||
end
|
||||
end
|
||||
|
||||
local on_player_died = function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if not (player and player.valid) then
|
||||
return
|
||||
end
|
||||
local player_data = get_player_data(player)
|
||||
player_data.died = true
|
||||
end
|
||||
|
||||
local on_research_finished = function(event)
|
||||
disable_tech()
|
||||
local research = event.research
|
||||
|
||||
research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 50 -- +5 Slots /
|
||||
|
||||
if research.name == 'steel-axe' then
|
||||
local msg = 'Steel-axe technology has been researched, 100% has been applied.\nBuy Pickaxe-upgrades in the market to boost it even more!'
|
||||
Alert.alert_all_players(30, msg, nil, 'achievement/tech-maniac', 0.6)
|
||||
end -- +50% speed for steel-axe research
|
||||
|
||||
local force_name = research.force.name
|
||||
if not force_name then
|
||||
return
|
||||
end
|
||||
local flamethrower_damage = WPT.get('flamethrower_damage')
|
||||
flamethrower_damage[force_name] = -0.85
|
||||
if research.name == 'military' then
|
||||
game.forces[force_name].set_turret_attack_modifier('flamethrower-turret', flamethrower_damage[force_name])
|
||||
game.forces[force_name].set_ammo_damage_modifier('flamethrower', flamethrower_damage[force_name])
|
||||
end
|
||||
|
||||
if string.sub(research.name, 0, 18) == 'refined-flammables' then
|
||||
flamethrower_damage[force_name] = flamethrower_damage[force_name] + 0.10
|
||||
game.forces[force_name].set_turret_attack_modifier('flamethrower-turret', flamethrower_damage[force_name])
|
||||
game.forces[force_name].set_ammo_damage_modifier('flamethrower', flamethrower_damage[force_name])
|
||||
end
|
||||
end
|
||||
|
||||
local is_locomotive_valid = function()
|
||||
local locomotive = WPT.get('locomotive')
|
||||
if not locomotive.valid then
|
||||
@ -557,7 +217,7 @@ local is_player_valid = function()
|
||||
for _, player in pairs(players) do
|
||||
if player.connected and not player.character or not player.character.valid then
|
||||
if not player.admin then
|
||||
local player_data = get_player_data(player)
|
||||
local player_data = Functions.get_player_data(player)
|
||||
if player_data.died then
|
||||
return
|
||||
end
|
||||
@ -620,82 +280,6 @@ local has_the_game_ended = function()
|
||||
end
|
||||
end
|
||||
|
||||
local boost_difficulty = function()
|
||||
local difficulty_set = WPT.get('difficulty_set')
|
||||
if difficulty_set then
|
||||
return
|
||||
end
|
||||
|
||||
local breached_wall = WPT.get('breached_wall')
|
||||
|
||||
local difficulty = Difficulty.get()
|
||||
local name = difficulty.difficulties[difficulty.difficulty_vote_index].name
|
||||
|
||||
if game.tick < difficulty.difficulty_poll_closing_timeout and breached_wall <= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
Difficulty.get().name = name
|
||||
Difficulty.get().difficulty_poll_closing_timeout = game.tick
|
||||
|
||||
Difficulty.get().button_tooltip = difficulty.tooltip[difficulty.difficulty_vote_index]
|
||||
Difficulty.difficulty_gui()
|
||||
|
||||
local message = ({'main.diff_set', name})
|
||||
local data = {
|
||||
position = WPT.get('locomotive').position
|
||||
}
|
||||
Alert.alert_all_players_location(data, message)
|
||||
|
||||
local force = game.forces.player
|
||||
|
||||
if name == "I'm too young to die" then
|
||||
-- rpg_extra.difficulty = 1
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.5
|
||||
force.character_running_speed_modifier = 0.15
|
||||
force.manual_crafting_speed_modifier = 0.15
|
||||
WPT.set().coin_amount = 1
|
||||
WPT.set('upgrades').flame_turret.limit = 12
|
||||
WPT.set('upgrades').landmine.limit = 50
|
||||
WPT.set().locomotive_health = 10000
|
||||
WPT.set().locomotive_max_health = 10000
|
||||
WPT.set().bonus_xp_on_join = 500
|
||||
WD.set().next_wave = game.tick + 3600 * 15
|
||||
WPT.set().spidertron_unlocked_at_wave = 14
|
||||
WPT.set().difficulty_set = true
|
||||
WD.set_biter_health_boost(1.50)
|
||||
elseif name == 'Hurt me plenty' then
|
||||
-- rpg_extra.difficulty = 0.5
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.25
|
||||
force.character_running_speed_modifier = 0.1
|
||||
force.manual_crafting_speed_modifier = 0.1
|
||||
WPT.set().coin_amount = 1
|
||||
WPT.set('upgrades').flame_turret.limit = 10
|
||||
WPT.set('upgrades').landmine.limit = 50
|
||||
WPT.set().locomotive_health = 7000
|
||||
WPT.set().locomotive_max_health = 7000
|
||||
WPT.set().bonus_xp_on_join = 300
|
||||
WD.set().next_wave = game.tick + 3600 * 10
|
||||
WPT.set().spidertron_unlocked_at_wave = 16
|
||||
WPT.set().difficulty_set = true
|
||||
WD.set_biter_health_boost(2)
|
||||
elseif name == 'Ultra-violence' then
|
||||
-- rpg_extra.difficulty = 0
|
||||
force.character_running_speed_modifier = 0
|
||||
force.manual_crafting_speed_modifier = 0
|
||||
WPT.set().coin_amount = 1
|
||||
WPT.set('upgrades').flame_turret.limit = 3
|
||||
WPT.set('upgrades').landmine.limit = 10
|
||||
WPT.set().locomotive_health = 5000
|
||||
WPT.set().locomotive_max_health = 5000
|
||||
WPT.set().bonus_xp_on_join = 50
|
||||
WD.set().next_wave = game.tick + 3600 * 5
|
||||
WPT.set().spidertron_unlocked_at_wave = 18
|
||||
WPT.set().difficulty_set = true
|
||||
WD.set_biter_health_boost(3)
|
||||
end
|
||||
end
|
||||
|
||||
local chunk_load = function()
|
||||
local chunk_load_tick = WPT.get('chunk_load_tick')
|
||||
if chunk_load_tick then
|
||||
@ -737,105 +321,6 @@ local lock_locomotive_positions = function()
|
||||
end
|
||||
end
|
||||
|
||||
local set_spawn_position = function()
|
||||
local collapse_pos = Collapse.get_position()
|
||||
local locomotive = WPT.get('locomotive')
|
||||
if not locomotive or not locomotive.valid then
|
||||
return
|
||||
end
|
||||
local l = locomotive.position
|
||||
|
||||
local retries = 0
|
||||
|
||||
local function check_tile(surface, tile, tbl, inc)
|
||||
if not (surface and surface.valid) then
|
||||
return false
|
||||
end
|
||||
if not tile then
|
||||
return false
|
||||
end
|
||||
local get_tile = surface.get_tile(tile)
|
||||
if get_tile.valid and get_tile.name == 'out-of-map' then
|
||||
remove(tbl.tbl, inc - inc + 1)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
::retry::
|
||||
|
||||
local locomotive_positions = WPT.get('locomotive_pos')
|
||||
local total_pos = #locomotive_positions.tbl
|
||||
|
||||
local active_surface_index = WPT.get('active_surface_index')
|
||||
local surface = game.surfaces[active_surface_index]
|
||||
if not (surface and surface.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
local spawn_near_collapse = WPT.get('spawn_near_collapse')
|
||||
|
||||
if spawn_near_collapse.active then
|
||||
local collapse_position = surface.find_non_colliding_position('small-biter', collapse_pos, 32, 2)
|
||||
local sizeof = locomotive_positions.tbl[total_pos - total_pos + 1]
|
||||
if check_tile(surface, sizeof, locomotive_positions.tbl, total_pos) then
|
||||
retries = retries + 1
|
||||
if retries == 2 then
|
||||
goto continue
|
||||
end
|
||||
goto retry
|
||||
end
|
||||
|
||||
local locomotive_position = surface.find_non_colliding_position('small-biter', sizeof, 128, 1)
|
||||
local distance_from = floor(math2d.position.distance(locomotive_position, locomotive.position))
|
||||
local l_y = l.y
|
||||
local t_y = locomotive_position.y
|
||||
local c_y = collapse_pos.y
|
||||
if total_pos > spawn_near_collapse.total_pos then
|
||||
if l_y - t_y <= spawn_near_collapse.compare then
|
||||
if locomotive_position then
|
||||
if check_tile(surface, sizeof, locomotive_positions.tbl, total_pos) then
|
||||
debug_str('total_pos was higher - found oom')
|
||||
retries = retries + 1
|
||||
if retries == 2 then
|
||||
goto continue
|
||||
end
|
||||
goto retry
|
||||
end
|
||||
debug_str('total_pos was higher - spawning at locomotive_position')
|
||||
WD.set_spawn_position(locomotive_position)
|
||||
end
|
||||
elseif c_y - t_y <= spawn_near_collapse.compare_next then
|
||||
if distance_from >= spawn_near_collapse.distance_from then
|
||||
local success = check_tile(surface, locomotive_position, locomotive_positions.tbl, total_pos)
|
||||
if success then
|
||||
debug_str('distance_from was higher - found oom')
|
||||
return
|
||||
end
|
||||
debug_str('distance_from was higher - spawning at locomotive_position')
|
||||
WD.set_spawn_position({x = locomotive_position.x, y = collapse_pos.y - 20})
|
||||
else
|
||||
debug_str('distance_from was lower - spawning at locomotive_position')
|
||||
WD.set_spawn_position({x = locomotive_position.x, y = collapse_pos.y - 20})
|
||||
end
|
||||
else
|
||||
if collapse_position then
|
||||
debug_str('total_pos was higher - spawning at collapse_position')
|
||||
WD.set_spawn_position(collapse_position)
|
||||
end
|
||||
end
|
||||
else
|
||||
if collapse_position then
|
||||
debug_str('total_pos was lower - spawning at collapse_position')
|
||||
WD.set_spawn_position(collapse_position)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
::continue::
|
||||
end
|
||||
|
||||
local compare_collapse_and_train = function()
|
||||
local collapse_pos = Collapse.get_position()
|
||||
local locomotive = WPT.get('locomotive')
|
||||
@ -855,7 +340,7 @@ local compare_collapse_and_train = function()
|
||||
|
||||
if c_y - t_y <= gap_between_zones.gap then
|
||||
if gap_between_zones.set then
|
||||
set_difficulty()
|
||||
Functions.set_difficulty()
|
||||
gap_between_zones.set = false
|
||||
end
|
||||
return
|
||||
@ -904,13 +389,14 @@ local on_tick = function()
|
||||
|
||||
if tick % 250 == 0 then
|
||||
compare_collapse_and_train()
|
||||
set_spawn_position()
|
||||
boost_difficulty()
|
||||
Functions.set_spawn_position()
|
||||
Functions.boost_difficulty()
|
||||
end
|
||||
|
||||
if tick % 1000 == 0 then
|
||||
collapse_after_wave_100()
|
||||
set_difficulty()
|
||||
Functions.remove_offline_players()
|
||||
Functions.set_difficulty()
|
||||
end
|
||||
end
|
||||
|
||||
@ -951,11 +437,5 @@ end
|
||||
|
||||
Event.on_nth_tick(10, on_tick)
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_player_left_game, on_player_left_game)
|
||||
Event.add(defines.events.on_player_respawned, on_player_respawned)
|
||||
Event.add(defines.events.on_player_died, on_player_died)
|
||||
Event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
Event.add(defines.events.on_research_finished, on_research_finished)
|
||||
|
||||
return Public
|
||||
|
@ -133,6 +133,15 @@ local valid_trees = {
|
||||
['tree-08-brown'] = true
|
||||
}
|
||||
|
||||
local valid_scrap = {
|
||||
['crash-site-spaceship-wreck-small-1'] = true,
|
||||
['crash-site-spaceship-wreck-small-2'] = true,
|
||||
['crash-site-spaceship-wreck-small-3'] = true,
|
||||
['crash-site-spaceship-wreck-small-4'] = true,
|
||||
['crash-site-spaceship-wreck-small-5'] = true,
|
||||
['crash-site-spaceship-wreck-small-6'] = true
|
||||
}
|
||||
|
||||
local reward_wood = {
|
||||
['dead-tree-desert'] = true,
|
||||
['dead-dry-hairy-tree'] = true,
|
||||
@ -406,7 +415,13 @@ function Public.on_player_mined_entity(event)
|
||||
return
|
||||
end
|
||||
|
||||
if valid_rocks[entity.name] or valid_trees[entity.name] then
|
||||
local is_scrap = false
|
||||
|
||||
if valid_scrap[entity.name] then
|
||||
is_scrap = true
|
||||
end
|
||||
|
||||
if valid_rocks[entity.name] or valid_trees[entity.name] or is_scrap then
|
||||
event.buffer.clear()
|
||||
|
||||
local data = {
|
||||
@ -417,7 +432,7 @@ function Public.on_player_mined_entity(event)
|
||||
local index = player.index
|
||||
|
||||
local scrap_zone = RPG_Settings.get_value_from_player(index, 'scrap_zone')
|
||||
if scrap_zone then
|
||||
if scrap_zone or is_scrap then
|
||||
randomness_scrap(data)
|
||||
else
|
||||
randomness(data)
|
||||
|
@ -19,6 +19,7 @@ local science_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'logistic-science-pack',
|
||||
tech = 'logistic-science-pack',
|
||||
output = {item = 'logistic-science-pack', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 15 / 60 / 512}
|
||||
},
|
||||
weight = 2
|
||||
@ -29,6 +30,7 @@ local ammo_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'piercing-rounds-magazine',
|
||||
tech = 'military-2',
|
||||
output = {item = 'piercing-rounds-magazine', min_rate = 1 / 2 / 60, distance_factor = 1 / 10 / 60 / 512}
|
||||
},
|
||||
weight = 1
|
||||
@ -50,6 +52,7 @@ local ammo_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'uranium-rounds-magazine',
|
||||
tech = 'uranium-ammo',
|
||||
output = {item = 'uranium-rounds-magazine', min_rate = 0.1 / 8 / 60, distance_factor = 1 / 25 / 60 / 512}
|
||||
},
|
||||
weight = 0.25
|
||||
@ -60,6 +63,7 @@ local oil_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'basic-oil-processing',
|
||||
tech = 'oil-processing',
|
||||
output = {
|
||||
min_rate = 1 / 60,
|
||||
distance_factor = 1 / 10 / 60 / 512,
|
||||
@ -72,6 +76,7 @@ local oil_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'advanced-oil-processing',
|
||||
tech = 'advanced-oil-processing',
|
||||
output = {
|
||||
{min_rate = 0.7 / 60, distance_factor = 3.125 / 60 / 512, item = 'heavy-oil', fluidbox_index = 3},
|
||||
{min_rate = 0.82 / 60, distance_factor = 5.625 / 60 / 512, item = 'light-oil', fluidbox_index = 4},
|
||||
@ -86,6 +91,7 @@ local oil_prod_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'lubricant',
|
||||
tech = 'lubricant',
|
||||
output = {
|
||||
item = 'lubricant',
|
||||
min_rate = 0.7 / 60,
|
||||
@ -98,6 +104,7 @@ local oil_prod_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'solid-fuel-from-light-oil',
|
||||
tech = 'oil-processing',
|
||||
output = {
|
||||
item = 'solid-fuel',
|
||||
min_rate = 0.7 / 60,
|
||||
@ -109,6 +116,7 @@ local oil_prod_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'sulfuric-acid',
|
||||
tech = 'sulfur-processing',
|
||||
output = {
|
||||
item = 'sulfuric-acid',
|
||||
min_rate = 0.8 / 60,
|
||||
@ -121,6 +129,7 @@ local oil_prod_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'battery',
|
||||
tech = 'battery',
|
||||
output = {
|
||||
item = 'battery',
|
||||
min_rate = 0.6 / 60,
|
||||
@ -132,6 +141,7 @@ local oil_prod_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'sulfur',
|
||||
tech = 'sulfur-processing',
|
||||
output = {
|
||||
item = 'sulfur',
|
||||
min_rate = 0.8 / 60,
|
||||
@ -143,6 +153,7 @@ local oil_prod_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'plastic-bar',
|
||||
tech = 'plastics',
|
||||
output = {
|
||||
item = 'plastic-bar',
|
||||
min_rate = 0.8 / 60,
|
||||
@ -157,10 +168,19 @@ local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'stone-wall',
|
||||
tech = 'stone-wall',
|
||||
output = {item = 'stone-wall', min_rate = 0.6 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
},
|
||||
weight = 10
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'concrete',
|
||||
tech = 'concrete',
|
||||
output = {item = 'concrete', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
},
|
||||
weight = 6
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'iron-gear-wheel',
|
||||
@ -175,6 +195,37 @@ local resource_loot = {
|
||||
},
|
||||
weight = 12
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'fast-inserter',
|
||||
tech = 'fast-inserter',
|
||||
output = {item = 'fast-inserter', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
},
|
||||
weight = 4
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'electronic-circuit',
|
||||
output = {item = 'electronic-circuit', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
},
|
||||
weight = 2
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'advanced-circuit',
|
||||
tech = 'advanced-electronics',
|
||||
output = {item = 'advanced-circuit', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
},
|
||||
weight = 1
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'processing-unit',
|
||||
tech = 'advanced-electronics-2',
|
||||
output = {item = 'processing-unit', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 2
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'transport-belt',
|
||||
@ -199,6 +250,7 @@ local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'fast-transport-belt',
|
||||
tech = 'logistics-2',
|
||||
output = {item = 'fast-transport-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 5
|
||||
@ -206,6 +258,7 @@ local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'fast-underground-belt',
|
||||
tech = 'logistics-2',
|
||||
output = {item = 'fast-underground-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 5
|
||||
@ -213,6 +266,7 @@ local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'solar-panel',
|
||||
tech = 'solar-energy',
|
||||
output = {item = 'solar-panel', min_rate = 1 / 6 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 3
|
||||
@ -220,6 +274,7 @@ local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'productivity-module',
|
||||
tech = 'productivity-module',
|
||||
output = {item = 'productivity-module', min_rate = 1 / 6 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 0.9
|
||||
@ -227,6 +282,7 @@ local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'effectivity-module',
|
||||
tech = 'effectivity-module',
|
||||
output = {item = 'effectivity-module', min_rate = 1 / 6 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 0.9
|
||||
@ -234,6 +290,7 @@ local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'speed-module',
|
||||
tech = 'speed-module',
|
||||
output = {item = 'speed-module', min_rate = 1 / 6 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 0.8
|
||||
@ -241,6 +298,7 @@ local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'productivity-module-2',
|
||||
tech = 'productivity-module-2',
|
||||
output = {item = 'productivity-module-2', min_rate = 1 / 8 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 0.5
|
||||
@ -248,6 +306,7 @@ local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'effectivity-module-2',
|
||||
tech = 'effectivity-module-2',
|
||||
output = {item = 'effectivity-module-2', min_rate = 1 / 8 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 0.5
|
||||
@ -255,6 +314,7 @@ local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'speed-module-2',
|
||||
tech = 'speed-module-2',
|
||||
output = {item = 'speed-module-2', min_rate = 1 / 8 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 0.5
|
||||
@ -262,6 +322,7 @@ local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'productivity-module-3',
|
||||
tech = 'productivity-module-3',
|
||||
output = {item = 'productivity-module-3', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 0.25
|
||||
@ -269,6 +330,7 @@ local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'effectivity-module-3',
|
||||
tech = 'effectivity-module-3',
|
||||
output = {item = 'effectivity-module-3', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 0.25
|
||||
@ -276,6 +338,7 @@ local resource_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'speed-module-3',
|
||||
tech = 'speed-module-3',
|
||||
output = {item = 'speed-module-3', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 0.10
|
||||
@ -300,6 +363,7 @@ local furnace_loot = {
|
||||
{
|
||||
stack = {
|
||||
furance_item = 'steel-plate',
|
||||
tech = 'steel-processing',
|
||||
output = {item = 'steel-plate', min_rate = 1.0 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
},
|
||||
weight = 1
|
||||
@ -394,66 +458,78 @@ local furnace_list = {
|
||||
}
|
||||
|
||||
local function spawn_science_buildings(entities, p, probability)
|
||||
local callback = science_list[probability].callback
|
||||
|
||||
entities[#entities + 1] = {
|
||||
name = science_list[probability].name,
|
||||
position = p,
|
||||
force = 'neutral',
|
||||
callback = science_list[probability].callback,
|
||||
callback = callback,
|
||||
collision = true,
|
||||
e_type = types
|
||||
}
|
||||
end
|
||||
|
||||
local function spawn_ammo_building(entities, p, probability)
|
||||
local callback = ammo_list[probability].callback
|
||||
|
||||
entities[#entities + 1] = {
|
||||
name = ammo_list[probability].name,
|
||||
position = p,
|
||||
force = 'neutral',
|
||||
callback = ammo_list[probability].callback,
|
||||
callback = callback,
|
||||
collision = true,
|
||||
e_type = types
|
||||
}
|
||||
end
|
||||
|
||||
local function spawn_oil_buildings(entities, p)
|
||||
local callback = oil_list[1].callback
|
||||
|
||||
entities[#entities + 1] = {
|
||||
name = oil_list[1].name,
|
||||
position = p,
|
||||
force = 'neutral',
|
||||
callback = oil_list[1].callback,
|
||||
callback = callback,
|
||||
collision = true,
|
||||
e_type = types
|
||||
}
|
||||
end
|
||||
|
||||
local function spawn_oil_prod_buildings(entities, p)
|
||||
local callback = oil_prod_list[1].callback
|
||||
|
||||
entities[#entities + 1] = {
|
||||
name = oil_prod_list[1].name,
|
||||
position = p,
|
||||
force = 'neutral',
|
||||
callback = oil_prod_list[1].callback,
|
||||
callback = callback,
|
||||
collision = true,
|
||||
e_type = types
|
||||
}
|
||||
end
|
||||
|
||||
local function spawn_resource_building(entities, p, probability)
|
||||
local callback = resource_list[probability].callback
|
||||
|
||||
entities[#entities + 1] = {
|
||||
name = resource_list[probability].name,
|
||||
position = p,
|
||||
force = 'neutral',
|
||||
callback = resource_list[probability].callback,
|
||||
callback = callback,
|
||||
collision = true,
|
||||
e_type = types
|
||||
}
|
||||
end
|
||||
|
||||
local function spawn_furnace_building(entities, p, probability)
|
||||
local callback = furnace_list[probability].callback
|
||||
|
||||
entities[#entities + 1] = {
|
||||
name = furnace_list[probability].name,
|
||||
position = p,
|
||||
force = 'neutral',
|
||||
callback = furnace_list[probability].callback,
|
||||
callback = callback,
|
||||
collision = true,
|
||||
e_type = types
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
local Global = require 'utils.global'
|
||||
local surface_name = 'mountain_fortress_v3'
|
||||
local level_width = require 'maps.mountain_fortress_v3.terrain'.level_width
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local Reset = require 'maps.mountain_fortress_v3.soft_reset'
|
||||
|
||||
local Public = {}
|
||||
@ -22,7 +22,7 @@ local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16
|
||||
function Public.create_surface()
|
||||
local map_gen_settings = {
|
||||
['seed'] = math.random(10000, 99999),
|
||||
['width'] = level_width,
|
||||
['width'] = WPT.level_width,
|
||||
['water'] = 0.001,
|
||||
['starting_area'] = 1,
|
||||
['cliff_settings'] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
|
||||
@ -57,8 +57,7 @@ function Public.create_surface()
|
||||
if not this.active_surface_index then
|
||||
this.active_surface_index = game.create_surface(surface_name, map_gen_settings).index
|
||||
else
|
||||
this.active_surface_index =
|
||||
Reset.soft_reset_map(game.surfaces[this.active_surface_index], map_gen_settings, starting_items).index
|
||||
this.active_surface_index = Reset.soft_reset_map(game.surfaces[this.active_surface_index], map_gen_settings, starting_items).index
|
||||
end
|
||||
|
||||
if not this.cleared_nauvis then
|
||||
|
@ -16,6 +16,7 @@ Global.register(
|
||||
)
|
||||
|
||||
Public.level_depth = 704
|
||||
Public.level_width = 512
|
||||
|
||||
Public.pickaxe_upgrades = {
|
||||
'Wood',
|
||||
@ -177,6 +178,8 @@ function Public.reset_table()
|
||||
this.explosive_bullets = false
|
||||
this.locomotive_biter = nil
|
||||
this.disconnect_wagon = false
|
||||
this.offline_players_enabled = true
|
||||
this.offline_players = {}
|
||||
this.spawn_near_collapse = {
|
||||
active = true,
|
||||
total_pos = 35,
|
||||
|
@ -12,7 +12,7 @@ local floor = math.floor
|
||||
local ceil = math.ceil
|
||||
|
||||
Public.level_depth = WPT.level_depth
|
||||
Public.level_width = 512
|
||||
Public.level_width = WPT.level_width
|
||||
local worm_level_modifier = 0.19
|
||||
|
||||
local wagon_raffle = {
|
||||
@ -48,6 +48,22 @@ local tree_raffle = {
|
||||
}
|
||||
local size_of_tree_raffle = #tree_raffle
|
||||
|
||||
local scrap_mineable_entities = {
|
||||
'crash-site-spaceship-wreck-small-1',
|
||||
'crash-site-spaceship-wreck-small-1',
|
||||
'crash-site-spaceship-wreck-small-2',
|
||||
'crash-site-spaceship-wreck-small-2',
|
||||
'crash-site-spaceship-wreck-small-3',
|
||||
'crash-site-spaceship-wreck-small-3',
|
||||
'crash-site-spaceship-wreck-small-4',
|
||||
'crash-site-spaceship-wreck-small-4',
|
||||
'crash-site-spaceship-wreck-small-5',
|
||||
'crash-site-spaceship-wreck-small-5',
|
||||
'crash-site-spaceship-wreck-small-6'
|
||||
}
|
||||
|
||||
local scrap_mineable_entities_index = #scrap_mineable_entities
|
||||
|
||||
local scrap_entities = {
|
||||
'medium-ship-wreck',
|
||||
'small-ship-wreck',
|
||||
@ -948,7 +964,7 @@ local function process_level_8_position(x, y, data, void_or_lab)
|
||||
}
|
||||
end
|
||||
if random(1, 5) > 1 then
|
||||
entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p}
|
||||
entities[#entities + 1] = {name = scrap_mineable_entities[random(1, scrap_mineable_entities_index)], position = p}
|
||||
end
|
||||
if random(1, 256) == 1 then
|
||||
entities[#entities + 1] = {name = 'land-mine', position = p, force = 'enemy'}
|
||||
@ -2098,7 +2114,7 @@ local function process_level_0_position(x, y, data, void_or_lab)
|
||||
local no_rocks = get_perlin('no_rocks', p, seed)
|
||||
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
end
|
||||
@ -2277,7 +2293,7 @@ local function border_chunk(data)
|
||||
end
|
||||
if not is_out_of_map(pos) then
|
||||
if random(1, ceil(pos.y + pos.y) + 32) == 1 then
|
||||
entities[#entities + 1] = {name = rock_raffle[random(1, #rock_raffle)], position = pos}
|
||||
entities[#entities + 1] = {name = scrap_mineable_entities[random(1, scrap_mineable_entities_index)], position = pos, force = 'neutral'}
|
||||
end
|
||||
if random(1, pos.y + 2) == 1 then
|
||||
decoratives[#decoratives + 1] = {
|
||||
@ -2413,9 +2429,7 @@ Event.add(
|
||||
|
||||
if left_top.y == -128 and left_top.x == -128 then
|
||||
local pl = WPT.get().locomotive.position
|
||||
for _, entity in pairs(
|
||||
surface.find_entities_filtered({area = {{pl.x - 5, pl.y - 6}, {pl.x + 5, pl.y + 10}}, type = 'simple-entity'})
|
||||
) do
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = {{pl.x - 5, pl.y - 6}, {pl.x + 5, pl.y + 10}}, type = 'simple-entity'})) do
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user