1
0
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:
Shadow_Man 2023-05-07 02:42:43 +02:00 committed by GitHub
commit 26f22e6eee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 845 additions and 345 deletions

View File

@ -41,6 +41,7 @@ require 'utils.gui.server_select'
require 'utils.freeplay'
---------------- !ENABLE MODULES HERE ----------------
--require 'modules.rpg.main'
--require 'modules.admins_operate_biters'
--require 'modules.the_floor_is_lava'
--require 'modules.biters_landfill_on_death'
@ -240,7 +241,6 @@ require 'utils.freeplay'
---------------- MORE MODULES HERE ----------------
--require 'modules.hidden_dimension.main'
--require 'modules.towny.main'
--require 'modules.rpg.main'
--require 'modules.rpg'
--require 'modules.trees_grow'
--require 'modules.trees_randomly_die'

View File

@ -50,6 +50,8 @@ hide_minimap=Hide locomotive minimap!
current_pickaxe_tier=The team currently has the __1__ pickaxe tier.\nBonus speed is: __2__%
map_on=Automatically show map ON
map_off=OFF
robotics_deployed=The locomotive defense is currently deployed.
robotics_standby=The locomotive defense is currently in standby-mode.
[locomotive]
upgrades=Upgrades:
@ -81,8 +83,10 @@ notify_full_inventory_2=Your inventory is full. Join the warrior club today! Pum
new_items_at_market=New items have been unlocked at the locomotive market!
discharge_unlocked=Discharge defense has now been unlocked at the market!
artillery_unlocked=Artillery has now been unlocked at the market!
crafting_bonus=__1__ unlocked the last missing piece for the mystical chest!\n[color=yellow]Crafting speed bonus has been applied for 15 minutes![/color]
mining_bonus=__1__ unlocked the last missing piece for the mystical chest!\n[color=yellow]Mining speed bonus has been applied for 15 minutes![/color]
mining_bonus_end=Mining speed bonus has ended!
crafting_bonus_end=Crafting speed bonus has ended!
movement_bonus=__1__ unlocked the last missing piece for the mystical chest!\n[color=yellow]Movement speed bonus has been applied for 15 minutes![/color]
movement_bonus_end=Movement speed bonus has ended!
coin_bonus=__1__ unlocked the last missing piece for the mystical chest!\n[color=yellow]Coins has been distributed![/color]

View File

@ -1,3 +1,3 @@
[wave_defense]
pause_waves=[color=blue][Wave Defense][/color] New waves will not spawn for 5 minutes!
pause_waves=[color=blue][Wave Defense][/color] New waves will not spawn for __1__ minutes!
start_waves=[color=blue][Wave Defense][/color] Waves will spawn normally again.

View File

@ -29,7 +29,7 @@ end
function Public.place_mixed_ore(event, journey)
if math_random(1, 192) ~= 1 then return end
local surface = event.surface
local surface = event.surface
local x = event.area.left_top.x + math_random(0, 31)
local y = event.area.left_top.y + math_random(0, 31)
local base_amount = 1000 + math_sqrt(x ^ 2 + y ^ 2) * 5
@ -45,11 +45,11 @@ local function place_teleporter(journey, surface, position)
table.insert(tiles, {name = Constants.teleporter_tile, position = position})
end
end
surface.set_tiles(tiles, false)
surface.set_tiles(tiles, false)
surface.create_entity({name = 'electric-beam-no-sound', position = position, source = {x = position.x - 1, y = position.y - 1}, target = {x = position.x + 1, y = position.y - 0.5}})
surface.create_entity({name = 'electric-beam-no-sound', position = position, source = {x = position.x + 1, y = position.y - 1}, target = {x = position.x + 1, y = position.y + 1.5}})
surface.create_entity({name = 'electric-beam-no-sound', position = position, source = {x = position.x + 1, y = position.y + 1}, target = {x = position.x - 1, y = position.y + 1.5}})
surface.create_entity({name = 'electric-beam-no-sound', position = position, source = {x = position.x - 1, y = position.y + 1}, target = {x = position.x - 1, y = position.y - 0.5}})
surface.create_entity({name = 'electric-beam-no-sound', position = position, source = {x = position.x - 1, y = position.y + 1}, target = {x = position.x - 1, y = position.y - 0.5}})
surface.destroy_decoratives({area = {{position.x - 1, position.y - 1}, {position.x + 1, position.y + 1}}})
end
@ -71,18 +71,18 @@ local function drop_player_items(player)
local character = player.character
if not character then return end
if not character.valid then return end
player.clear_cursor()
for i = 1, player.crafting_queue_size, 1 do
if player.crafting_queue_size > 0 then
player.cancel_crafting{index = 1, count = 99999999}
end
end
local surface = player.surface
local spill_blockage = surface.create_entity{name = "stone-furnace", position = player.position}
local spill_blockage = surface.create_entity{name = "stone-furnace", position = player.position}
for _, define in pairs({defines.inventory.character_main, defines.inventory.character_guns, defines.inventory.character_ammo, defines.inventory.character_armor, defines.inventory.character_vehicle, defines.inventory.character_trash}) do
local inventory = character.get_inventory(define)
if inventory and inventory.valid then
@ -90,12 +90,12 @@ local function drop_player_items(player)
local slot = inventory[i]
if slot.valid and slot.valid_for_read then
surface.spill_item_stack(player.position, slot, true, nil, false)
end
end
end
inventory.clear()
end
end
end
spill_blockage.destroy()
end
@ -105,8 +105,8 @@ function Public.clear_player(player)
if not character.valid then return end
player.character.destroy()
player.set_controller({type = defines.controllers.god})
player.create_character()
player.clear_items_inside()
player.create_character()
player.clear_items_inside()
end
local function remove_offline_players(maximum_age_in_hours)
@ -122,17 +122,17 @@ local function remove_offline_players(maximum_age_in_hours)
game.remove_offline_players(players_to_remove)
end
local function get_current_modifier_percentage(name, journey)
local function get_current_modifier_percentage(name, journey)
local mgs = game.surfaces.nauvis.map_gen_settings
for _, autoplace in pairs({"iron-ore", "copper-ore", "uranium-ore", "coal", "stone", "crude-oil", "stone", "trees", "enemy-base"}) do
if name == autoplace then return mgs.autoplace_controls[name].richness end
end
end
if name == "cliff_settings" then return 40 / mgs.cliff_settings.cliff_elevation_interval end
if name == "water" then return mgs.water end
if name == "water" then return mgs.water end
if name == "time_factor" then return game.map_settings.enemy_evolution.time_factor * 250000 end
if name == "destroy_factor" then return game.map_settings.enemy_evolution.destroy_factor * 500 end
if name == "pollution_factor" then return game.map_settings.enemy_evolution.pollution_factor * 1111000 end
if name == "expansion_cooldown" then return (game.map_settings.enemy_expansion.min_expansion_cooldown / 144) * 0.01 end
if name == "pollution_factor" then return game.map_settings.enemy_evolution.pollution_factor * 1111000 end
if name == "expansion_cooldown" then return (game.map_settings.enemy_expansion.min_expansion_cooldown / 144) * 0.01 end
if name == "technology_price_multiplier" then return game.difficulty_settings.technology_price_multiplier * 2 end
if name == "enemy_attack_pollution_consumption_modifier" then return game.map_settings.pollution.enemy_attack_pollution_consumption_modifier end
if name == "ageing" then return game.map_settings.pollution.ageing end
@ -143,24 +143,24 @@ local function get_current_modifier_percentage(name, journey)
end
local function delete_nauvis_chunks(journey)
local surface = game.surfaces.nauvis
local surface = game.surfaces.nauvis
if not journey.nauvis_chunk_positions then
journey.nauvis_chunk_positions = {}
for chunk in surface.get_chunks() do table.insert(journey.nauvis_chunk_positions, {chunk.x, chunk.y}) end
journey.size_of_nauvis_chunk_positions = #journey.nauvis_chunk_positions
for _, e in pairs(surface.find_entities_filtered{type = "radar"}) do e.destroy() end
for _, player in pairs(game.players) do
for _, player in pairs(game.players) do
local button = player.gui.top.add({type = "sprite-button", name = "chunk_progress", caption = ""})
button.style.font = "heading-1"
button.style.font_color = {222, 222, 222}
button.style.minimal_height = 38
button.style.minimal_width = 240
button.style.padding = -2
end
button.style.padding = -2
end
end
if journey.size_of_nauvis_chunk_positions == 0 then return end
for c = 1, 12, 1 do
local chunk_position = journey.nauvis_chunk_positions[journey.size_of_nauvis_chunk_positions]
if chunk_position then
@ -168,14 +168,14 @@ local function delete_nauvis_chunks(journey)
journey.size_of_nauvis_chunk_positions = journey.size_of_nauvis_chunk_positions - 1
else
break
end
end
end
end
local caption = "Deleting Chunks.. " .. journey.size_of_nauvis_chunk_positions
for _, player in pairs(game.connected_players) do
if player.gui.top.chunk_progress then player.gui.top.chunk_progress.caption = caption end
end
return true
return true
end
function Public.mothership_message_queue(journey)
@ -195,9 +195,9 @@ function Public.deny_building(event)
if entity.surface.name ~= "mothership" then return end
if Constants.build_type_whitelist[entity.type] then
entity.destructible = false
return
return
end
entity.die()
entity.die()
end
function Public.register_built_silo(event, journey)
@ -211,23 +211,23 @@ end
function Public.draw_gui(journey)
local surface = game.surfaces.nauvis
local mgs = surface.map_gen_settings
local caption = "World " .. journey.world_number .. " | " .. Constants.unique_world_traits[journey.world_trait][1]
local mgs = surface.map_gen_settings
local caption = "World " .. journey.world_number .. " | " .. Constants.unique_world_traits[journey.world_trait][1]
local tooltip = Constants.unique_world_traits[journey.world_trait][2] .. "\n\n"
for k, v in pairs(Constants.modifiers) do
tooltip = tooltip .. v[3] .. " - " .. math.round(get_current_modifier_percentage(k, journey) * 100, 1) .. "%\n"
end
tooltip = tooltip .. "\nCapsules:\n"
local c = 0
for k, v in pairs(journey.bonus_goods) do
tooltip = tooltip .. v .. "x " .. k .. " "
c = c + 1
if c % 2 == 0 then tooltip = tooltip .. "\n" end
if c % 2 == 0 then tooltip = tooltip .. "\n" end
end
for _, player in pairs(game.connected_players) do
for _, player in pairs(game.connected_players) do
if not player.gui.top.journey_button then
local element = player.gui.top.add({type = "sprite-button", name = "journey_button", caption = ""})
element.style.font = "heading-1"
@ -240,17 +240,17 @@ function Public.draw_gui(journey)
gui.caption = caption
gui.tooltip = tooltip
end
local fuel_requirement = journey.mothership_cargo_space["uranium-fuel-cell"]
local value
if fuel_requirement == 0 then
value = 1
else
value = journey.mothership_cargo["uranium-fuel-cell"] / fuel_requirement
end
end
local tooltip = "Fuel requirement to advance to next world:\n" .. fuel_requirement .. "\n\nNuclear Fuel Cells in Mothership Cargo:\n" .. journey.mothership_cargo["uranium-fuel-cell"]
for _, player in pairs(game.connected_players) do
for _, player in pairs(game.connected_players) do
if not player.gui.top.journey_fuel then
local frame = player.gui.top.add({type = 'frame', name = 'journey_fuel'})
frame.style.padding = 0
@ -261,7 +261,7 @@ function Public.draw_gui(journey)
element.style.maximal_height = 32
element.style.margin = 0
element.style.padding = 0
local element = frame.add({type = 'progressbar', name = 'journey_fuel_progressbar', value = 0})
local element = frame.add({type = 'progressbar', name = 'journey_fuel_progressbar', value = 0})
element.style.minimal_width = 100
element.style.maximal_width = 100
element.style.top_margin = 12
@ -275,12 +275,12 @@ function Public.draw_gui(journey)
gui.value = value
gui.tooltip = tooltip
end
local max_sattelites = journey.mothership_cargo_space["satellite"]
local value = journey.mothership_cargo["satellite"] / max_sattelites
local tooltip = "Room for satellites in Mothership cargo:\n" .. max_sattelites .. "\n\nSatellites stored:\n" .. journey.mothership_cargo["satellite"]
for _, player in pairs(game.connected_players) do
for _, player in pairs(game.connected_players) do
if not player.gui.top.journey_satellites then
local frame = player.gui.top.add({type = 'frame', name = 'journey_satellites'})
frame.style.left_margin = 4
@ -292,7 +292,7 @@ function Public.draw_gui(journey)
element.style.maximal_height = 32
element.style.margin = 0
element.style.padding = 0
local element = frame.add({type = 'progressbar', name = 'journey_satellites_progressbar', value = 0})
local element = frame.add({type = 'progressbar', name = 'journey_satellites_progressbar', value = 0})
element.style.minimal_width = 100
element.style.maximal_width = 100
element.style.top_margin = 12
@ -317,10 +317,10 @@ local function is_mothership(position)
local d = math.sqrt(p.x ^ 2 + p.y ^ 2)
if d < Constants.mothership_radius then
return true
end
end
end
function Public.on_mothership_chunk_generated(event)
function Public.on_mothership_chunk_generated(event)
local left_top = event.area.left_top
local surface = event.surface
local seed = surface.map_gen_settings.seed
@ -328,11 +328,11 @@ function Public.on_mothership_chunk_generated(event)
for x = 0, 31, 1 do
for y = 0, 31, 1 do
local position = {x = left_top.x + x, y = left_top.y + y}
if is_mothership(position) then
if is_mothership(position) then
table.insert(tiles, {name = "black-refined-concrete", position = position})
else
table.insert(tiles, {name = "out-of-map", position = position})
end
end
end
end
surface.set_tiles(tiles, true)
@ -342,9 +342,9 @@ function Public.hard_reset(journey)
if game.surfaces.mothership and game.surfaces.mothership.valid then
game.delete_surface(game.surfaces.mothership)
end
game.forces.enemy.character_inventory_slots_bonus = 9999
game.map_settings.enemy_expansion.enabled = true
game.map_settings.enemy_expansion.max_expansion_distance = 20
game.map_settings.enemy_expansion.settler_group_min_size = 5
@ -358,7 +358,7 @@ function Public.hard_reset(journey)
game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 1
game.map_settings.pollution.min_pollution_to_damage_trees = 60
game.map_settings.pollution.pollution_restored_per_tree_damage = 10
game.map_settings.unit_group.max_unit_group_size = 200
game.difficulty_settings.technology_price_multiplier = 0.5
@ -366,7 +366,7 @@ function Public.hard_reset(journey)
game.map_settings.enemy_evolution.time_factor = 0.000004
game.map_settings.enemy_evolution.destroy_factor = 0.002
game.map_settings.enemy_evolution.pollution_factor = 0.0000009
local surface = game.surfaces[1]
local mgs = surface.map_gen_settings
mgs.water = 1
@ -385,19 +385,19 @@ function Public.hard_reset(journey)
surface.map_gen_settings = mgs
surface.clear(true)
surface.daytime = math.random(1, 100) * 0.01
if journey.world_selectors and journey.world_selectors[1].border then
for k, world_selector in pairs(journey.world_selectors) do
for _, ID in pairs(world_selector.rectangles) do
rendering.destroy(ID)
end
rendering.destroy(world_selector.border)
end
end
end
journey.world_selectors = {}
journey.reroll_selector = {activation_level = 0}
for i = 1, 3, 1 do journey.world_selectors[i] = {activation_level = 0, texts = {}} end
for i = 1, 3, 1 do journey.world_selectors[i] = {activation_level = 0, texts = {}} end
journey.mothership_speed = 0.5
journey.characters_in_mothership = 0
journey.world_color_filters = {}
@ -411,7 +411,7 @@ function Public.hard_reset(journey)
["uranium-fuel-cell"] = 0,
}
journey.bonus_goods = {}
journey.nauvis_chunk_positions = nil
journey.nauvis_chunk_positions = nil
journey.world_number = 0
journey.world_trait = "lush"
journey.game_state = "create_mothership"
@ -427,7 +427,7 @@ end
function Public.draw_mothership(journey)
local surface = game.surfaces.mothership
local positions = {}
for x = Constants.mothership_radius * -1, Constants.mothership_radius, 1 do
for y = Constants.mothership_radius * -1, Constants.mothership_radius, 1 do
@ -435,10 +435,10 @@ function Public.draw_mothership(journey)
if is_mothership(position) then table.insert(positions, position) end
end
end
table.shuffle_table(positions)
for _, position in pairs(positions) do
for _, position in pairs(positions) do
if surface.count_tiles_filtered({area = {{position.x - 1, position.y - 1}, {position.x + 2, position.y + 2}}, name = "out-of-map"}) > 0 then
local e = surface.create_entity({name = "stone-wall", position = position, force = "player"})
e.destructible = false
@ -446,7 +446,7 @@ function Public.draw_mothership(journey)
end
if surface.count_tiles_filtered({area = {{position.x - 1, position.y - 1}, {position.x + 2, position.y + 2}}, name = "lab-dark-1"}) < 4 then
surface.set_tiles({{name = "lab-dark-1", position = position}}, true)
end
end
end
for _, tile in pairs(surface.find_tiles_filtered({area = {{Constants.mothership_teleporter_position.x - 2, Constants.mothership_teleporter_position.y - 2}, {Constants.mothership_teleporter_position.x + 2, Constants.mothership_teleporter_position.y + 2}}})) do
@ -454,7 +454,7 @@ function Public.draw_mothership(journey)
end
for k, area in pairs(Constants.world_selector_areas) do
journey.world_selectors[k].rectangles = {}
journey.world_selectors[k].rectangles = {}
local position = area.left_top
local rectangle = rendering.draw_rectangle {
width = 1,
@ -466,7 +466,7 @@ function Public.draw_mothership(journey)
draw_on_ground = true,
only_in_alt_mode = false
}
table.insert(journey.world_selectors[k].rectangles, rectangle)
table.insert(journey.world_selectors[k].rectangles, rectangle)
journey.world_selectors[k].border = rendering.draw_rectangle {
width = 8,
filled=false,
@ -498,7 +498,7 @@ function Public.draw_mothership(journey)
color = {r = 100, g = 100, b = 100, a = 255},
draw_on_ground = true,
only_in_alt_mode = false
}
}
for k, item_name in pairs({"arithmetic-combinator", "constant-combinator", "decider-combinator", "programmable-speaker", "red-wire", "green-wire", "small-lamp", "substation", "pipe", "gate", "stone-wall", "transport-belt"}) do
local e = surface.create_entity({name = 'infinity-chest', position = {-7 + k, Constants.mothership_radius - 3}, force = 'player'})
@ -511,20 +511,20 @@ function Public.draw_mothership(journey)
e.destructible = false
e.direction = 4
end
for m = -1, 1, 2 do
local e = surface.create_entity({name = "electric-energy-interface", position = {11 * m, Constants.mothership_radius - 4}, force = "player"})
local e = surface.create_entity({name = "electric-energy-interface", position = {11 * m, Constants.mothership_radius - 4}, force = "player"})
e.minable = false
e.destructible = false
local e = surface.create_entity({name = "substation", position = {9 * m, Constants.mothership_radius - 4}, force = "player"})
e.minable = false
e.destructible = false
end
for m = -1, 1, 2 do
local x = Constants.mothership_radius - 3
if m > 0 then x = x - 1 end
local y = Constants.mothership_radius * 0.5 - 7
local y = Constants.mothership_radius * 0.5 - 7
local e = surface.create_entity({name = "artillery-turret", position = {x * m, y}, force = "player"})
e.direction = 4
e.minable = false
@ -543,13 +543,13 @@ function Public.draw_mothership(journey)
e.destructible = false
e.operable = false
end
for _ = 1, 3, 1 do
local e = surface.create_entity({name = "compilatron", position = Constants.mothership_teleporter_position, force = "player"})
e.destructible = false
end
Public.draw_gui(journey)
Public.draw_gui(journey)
surface.daytime = 0.5
journey.game_state = "set_world_selectors"
@ -569,9 +569,9 @@ function Public.teleport_players_to_mothership(journey)
end
local function get_activation_level(surface, area)
local player_count_in_area = surface.count_entities_filtered({area = area, name = "character"})
local player_count_for_max_activation = #game.connected_players * 0.66
local level = player_count_in_area / player_count_for_max_activation
local player_count_in_area = surface.count_entities_filtered({area = area, name = "character"})
local player_count_for_max_activation = #game.connected_players * 0.66
local level = player_count_in_area / player_count_for_max_activation
level = math.round(level, 2)
return level
end
@ -588,7 +588,7 @@ local function animate_selectors(journey)
end
local activation_level = journey.reroll_selector.activation_level
if activation_level < 0.2 then activation_level = 0.2 end
if activation_level > 1 then activation_level = 1 end
if activation_level > 1 then activation_level = 1 end
local color = Constants.reroll_selector_area_color
rendering.set_color(journey.reroll_selector.rectangle, {r = color.r * activation_level, g = color.g * activation_level, b = color.b * activation_level, a = 255})
end
@ -612,22 +612,22 @@ local function draw_background(journey, surface)
local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)]
surface.create_entity({name = "uranium-cannon-projectile", position = position, target = {position[1], position[2] + Constants.mothership_radius * 2}, speed = speed})
end
if math.random(1, 32) == 1 then
if math.random(1, 32) == 1 then
local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)]
surface.create_entity({name = "explosive-uranium-cannon-projectile", position = position, target = {position[1], position[2] + Constants.mothership_radius * 3}, speed = speed})
end
if math.random(1, 90) == 1 then
surface.create_entity({name = "explosive-uranium-cannon-projectile", position = position, target = {position[1], position[2] + Constants.mothership_radius * 3}, speed = speed})
end
if math.random(1, 90) == 1 then
local position_x = math.random(64, 160)
local position_y = math.random(64, 160)
if math.random(1, 2) == 1 then position_x = position_x * -1 end
if math.random(1, 2) == 1 then position_y = position_y * -1 end
if math.random(1, 2) == 1 then position_y = position_y * -1 end
surface.create_entity({name = "big-worm-turret", position = {position_x, position_y}, force = "enemy"})
end
end
function Public.set_world_selectors(journey)
local surface = game.surfaces.mothership
local x = Constants.reroll_selector_area.left_top.x + 3.2
journey.reroll_selector.texts = {
rendering.draw_text{
@ -647,24 +647,24 @@ function Public.set_world_selectors(journey)
x_scale = 1.5,
target = {x + 1.6, Constants.reroll_selector_area.left_top.y - 1},
},
}
}
local modifier_names = {}
for k, _ in pairs(Constants.modifiers) do
table.insert(modifier_names, k)
end
local bonus_goods_keys = {}
for i = 1, #Constants.starter_goods_pool, 1 do
table.insert(bonus_goods_keys, i)
end
local unique_world_traits = {}
for k, _ in pairs(Constants.unique_world_traits) do
table.insert(unique_world_traits, k)
end
table.shuffle_table(unique_world_traits)
for k, world_selector in pairs(journey.world_selectors) do
table.shuffle_table(bonus_goods_keys)
table.shuffle_table(modifier_names)
@ -674,14 +674,14 @@ function Public.set_world_selectors(journey)
world_selector.fuel_requirement = math.random(25, 50)
local position = Constants.world_selector_areas[k].left_top
local texts = world_selector.texts
local modifiers = world_selector.modifiers
local modifiers = world_selector.modifiers
local bonus_goods = world_selector.bonus_goods
local y_modifier = -9.7
for i = 1, 8, 1 do
local modifier = modifier_names[i]
local v = math.random(Constants.modifiers[modifier][1], Constants.modifiers[modifier][2])
if i > 6 then v = v * -0.5 end
if i > 6 then v = v * -0.5 end
v = math.floor(v)
modifiers[i] = {modifier, v}
end
@ -695,22 +695,22 @@ function Public.set_world_selectors(journey)
font = "default-large-bold",
alignment = "center",
scale_with_zoom = false
})
})
for k2, modifier in pairs(modifiers) do
y_modifier = y_modifier + 0.8
local text = ""
if modifier[2] > 0 then text = text .. "+" end
text = text .. modifier[2] .. "% "
text = text .. Constants.modifiers[modifier[1]][3]
local color
if k2 < 7 then
color = {200, 0, 0, 255}
else
color = {0, 200, 0, 255}
end
end
table.insert(texts, rendering.draw_text{
text = text,
surface = surface,
@ -722,7 +722,7 @@ function Public.set_world_selectors(journey)
scale_with_zoom = false
})
end
y_modifier = y_modifier + 0.85
table.insert(texts, rendering.draw_text{
text = "Fuel requirement +" .. world_selector.fuel_requirement,
@ -738,16 +738,16 @@ function Public.set_world_selectors(journey)
sprite = "item/uranium-fuel-cell",
surface = surface,
target = {position.x + Constants.world_selector_width * 0.5 + 3.7, position.y + y_modifier + 0.5},
})
})
for i = 1, 3, 1 do
local key = bonus_goods_keys[i]
local bonus_good = Constants.starter_goods_pool[key]
bonus_goods[i] = {bonus_good[1], math.random(bonus_good[2], bonus_good[3])}
end
y_modifier = y_modifier + 1.1
local x_modifier = -0.5
local x_modifier = -0.5
for k2, good in pairs(world_selector.bonus_goods) do
local render_id = rendering.draw_text{
@ -761,8 +761,8 @@ function Public.set_world_selectors(journey)
scale_with_zoom = false
}
table.insert(texts, render_id)
x_modifier = x_modifier + 0.95
x_modifier = x_modifier + 0.95
if good[2] >= 10 then x_modifier = x_modifier + 0.18 end
if good[2] >= 100 then x_modifier = x_modifier + 0.18 end
@ -772,16 +772,16 @@ function Public.set_world_selectors(journey)
target = {position.x + x_modifier, position.y + 0.5 + y_modifier},
}
table.insert(texts, render_id)
x_modifier = x_modifier + 1.70
end
end
destroy_teleporter(journey, game.surfaces.nauvis, Constants.mothership_teleporter_position)
destroy_teleporter(journey, surface, Constants.mothership_teleporter_position)
Server.to_discord_embed("World " .. journey.world_number + 1 .. " selection has started!")
journey.game_state = "delete_nauvis_chunks"
end
@ -789,11 +789,11 @@ function Public.delete_nauvis_chunks(journey)
local surface = game.surfaces.mothership
Public.teleport_players_to_mothership(journey)
draw_background(journey, surface)
if delete_nauvis_chunks(journey) then return end
if delete_nauvis_chunks(journey) then return end
for _, player in pairs(game.players) do
if player.gui.top.chunk_progress then player.gui.top.chunk_progress.destroy() end
end
journey.game_state = "mothership_world_selection"
end
@ -801,13 +801,13 @@ function Public.reroll_worlds(journey)
local surface = game.surfaces.mothership
Public.teleport_players_to_mothership(journey)
draw_background(journey, surface)
animate_selectors(journey)
animate_selectors(journey)
local reroll_selector_activation_level = get_activation_level(surface, Constants.reroll_selector_area)
journey.reroll_selector.activation_level = reroll_selector_activation_level
for i = 1, 3, 1 do
local activation_level = get_activation_level(surface, Constants.world_selector_areas[i])
journey.world_selectors[i].activation_level = activation_level
end
end
if reroll_selector_activation_level > 1 then
journey.mothership_speed = journey.mothership_speed + 0.025
if journey.mothership_speed > 4 then
@ -818,12 +818,12 @@ function Public.reroll_worlds(journey)
table.insert(journey.mothership_messages, "New lands have been discovered!")
journey.game_state = "set_world_selectors"
end
else
else
journey.mothership_speed = journey.mothership_speed - 0.25
if journey.mothership_speed < 0.35 then
table.insert(journey.mothership_messages, "Aborting..")
journey.game_state = "mothership_world_selection"
journey.mothership_speed = 0.35
journey.mothership_speed = 0.35
end
end
end
@ -833,28 +833,28 @@ function Public.mothership_world_selection(journey)
local surface = game.surfaces.mothership
local daytime = surface.daytime
daytime = daytime - 0.025
daytime = daytime - 0.025
if daytime < 0 then daytime = 0 end
surface.daytime = daytime
local reroll_selector_activation_level = get_activation_level(surface, Constants.reroll_selector_area)
journey.reroll_selector.activation_level = reroll_selector_activation_level
journey.selected_world = false
for i = 1, 3, 1 do
local activation_level = get_activation_level(surface, Constants.world_selector_areas[i])
journey.world_selectors[i].activation_level = activation_level
if activation_level > 1 then
journey.selected_world = i
journey.selected_world = i
end
end
if reroll_selector_activation_level > 1 and journey.mothership_speed == 0.35 and journey.mothership_cargo.satellite > 0 then
journey.game_state = "reroll_worlds"
table.insert(journey.mothership_messages, "Dispatching satellite..")
return
end
if journey.selected_world then
if not journey.mothership_advancing_to_world then
table.insert(journey.mothership_messages, "Advancing to selected world.")
@ -869,47 +869,47 @@ function Public.mothership_world_selection(journey)
end
if seconds_left % 15 == 0 then table.insert(journey.mothership_messages, "Estimated arrival in " .. seconds_left .. " seconds.") end
end
journey.mothership_speed = journey.mothership_speed + 0.1
if journey.mothership_speed > 4 then journey.mothership_speed = 4 end
else
if journey.mothership_advancing_to_world then
table.insert(journey.mothership_messages, "Aborting travelling sequence.")
journey.mothership_advancing_to_world = false
end
end
journey.mothership_speed = journey.mothership_speed - 0.25
if journey.mothership_speed < 0.35 then journey.mothership_speed = 0.35 end
end
draw_background(journey, surface)
animate_selectors(journey)
end
function Public.mothership_arrives_at_world(journey)
local surface = game.surfaces.mothership
Public.teleport_players_to_mothership(journey)
if journey.mothership_speed == 0.15 then
for _ = 1, 16, 1 do table.insert(journey.mothership_messages, "") end
table.insert(journey.mothership_messages, "[img=item/uranium-fuel-cell] Fuel cells depleted ;_;")
for _ = 1, 16, 1 do table.insert(journey.mothership_messages, "") end
table.insert(journey.mothership_messages, "Refuel via supply rocket required!")
for i = 1, 3, 1 do
journey.world_selectors[i].activation_level = 0
end
animate_selectors(journey)
journey.game_state = "clear_modifiers"
else
journey.mothership_speed = journey.mothership_speed - 0.15
end
if journey.mothership_speed < 0.15 then
if journey.mothership_speed < 0.15 then
journey.mothership_speed = 0.15
end
draw_background(journey, surface)
end
@ -917,7 +917,7 @@ function Public.clear_modifiers(journey)
local unique_modifier = Unique_modifiers[journey.world_trait]
local clear = unique_modifier.clear
if clear then clear(journey) end
local force = game.forces.player
force.reset()
force.reset_technologies()
@ -932,7 +932,7 @@ function Public.create_the_world(journey)
mgs.seed = math.random(1, 4294967295)
mgs.terrain_segmentation = math.random(10, 20) * 0.1
mgs.peaceful_mode = false
local modifiers = journey.world_selectors[journey.selected_world].modifiers
for _, modifier in pairs(modifiers) do
local m = (100 + modifier[2]) * 0.01
@ -960,7 +960,7 @@ function Public.create_the_world(journey)
mgs.cliff_settings.cliff_elevation_interval = mgs.cliff_settings.cliff_elevation_interval * m2
mgs.cliff_settings.cliff_elevation_0 = mgs.cliff_settings.cliff_elevation_0 * m2
end
if name == "water" then
if name == "water" then
mgs.water = mgs.water * m
end
for _, evo in pairs({"time_factor", "destroy_factor", "pollution_factor"}) do
@ -969,17 +969,17 @@ function Public.create_the_world(journey)
break
end
end
if name == "expansion_cooldown" then
if name == "expansion_cooldown" then
game.map_settings.enemy_expansion.min_expansion_cooldown = game.map_settings.enemy_expansion.min_expansion_cooldown * m
game.map_settings.enemy_expansion.max_expansion_cooldown = game.map_settings.enemy_expansion.max_expansion_cooldown * m
end
if name == "technology_price_multiplier" then
if name == "technology_price_multiplier" then
game.difficulty_settings.technology_price_multiplier = game.difficulty_settings.technology_price_multiplier * m
end
if name == "enemy_attack_pollution_consumption_modifier" then
if name == "enemy_attack_pollution_consumption_modifier" then
game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = game.map_settings.pollution.enemy_attack_pollution_consumption_modifier * m
end
if name == "ageing" then
if name == "ageing" then
game.map_settings.pollution.ageing = game.map_settings.pollution.ageing * m
end
if name == "diffusion_ratio" then
@ -992,12 +992,12 @@ function Public.create_the_world(journey)
end
if name == "max_unit_group_size" then
game.map_settings.unit_group.max_unit_group_size = game.map_settings.unit_group.max_unit_group_size * m
end
end
end
surface.map_gen_settings = mgs
surface.clear(false)
journey.world_trait = journey.world_selectors[journey.selected_world].world_trait
journey.nauvis_chunk_positions = nil
journey.rocket_silos = {}
@ -1009,7 +1009,7 @@ function Public.create_the_world(journey)
end
journey.mothership_cargo_space["satellite"] = max_satellites
journey.mothership_cargo_space["uranium-fuel-cell"] = journey.mothership_cargo_space["uranium-fuel-cell"] + journey.world_selectors[journey.selected_world].fuel_requirement
game.forces.enemy.reset_evolution()
for _, good in pairs(journey.world_selectors[journey.selected_world].bonus_goods) do
@ -1017,7 +1017,7 @@ function Public.create_the_world(journey)
journey.bonus_goods[good[1]] = journey.bonus_goods[good[1]] + good[2]
else
journey.bonus_goods[good[1]] = good[2]
end
end
end
journey.goods_to_dispatch = {}
for k, v in pairs(journey.bonus_goods) do table.insert(journey.goods_to_dispatch, {k, v}) end
@ -1088,19 +1088,19 @@ function Public.make_it_night(journey)
local daytime = surface.daytime
daytime = daytime + 0.02
surface.daytime = daytime
if daytime > 0.5 then
clear_selectors(journey)
if daytime > 0.5 then
clear_selectors(journey)
game.reset_time_played()
place_teleporter(journey, surface, Constants.mothership_teleporter_position)
table.insert(journey.mothership_messages, "Teleporter deployed. [gps=" .. Constants.mothership_teleporter_position.x .. "," .. Constants.mothership_teleporter_position.y .. ",mothership]")
journey.game_state = "dispatch_goods"
table.insert(journey.mothership_messages, "Teleporter deployed. [gps=" .. Constants.mothership_teleporter_position.x .. "," .. Constants.mothership_teleporter_position.y .. ",mothership]")
journey.game_state = "dispatch_goods"
end
end
function Public.dispatch_goods(journey)
draw_background(journey, game.surfaces.mothership)
if journey.characters_in_mothership == #game.connected_players then return end
if journey.characters_in_mothership == #game.connected_players then return end
local goods_to_dispatch = journey.goods_to_dispatch
local size_of_goods_to_dispatch = #goods_to_dispatch
@ -1114,11 +1114,11 @@ function Public.dispatch_goods(journey)
end
if journey.dispatch_beacon and journey.dispatch_beacon.valid then return end
local surface = game.surfaces.nauvis
if journey.dispatch_beacon_position then
local good = goods_to_dispatch[journey.dispatch_key]
local good = goods_to_dispatch[journey.dispatch_key]
surface.spill_item_stack(journey.dispatch_beacon_position, {name = good[1], count = good[2]}, true, nil, false)
table.remove(journey.goods_to_dispatch, journey.dispatch_key)
journey.dispatch_beacon = nil
@ -1126,22 +1126,25 @@ function Public.dispatch_goods(journey)
journey.dispatch_key = nil
return
end
local chunk = surface.get_random_chunk()
if math.abs(chunk.x) > 4 or math.abs(chunk.y) > 4 then return end
local position = {x = chunk.x * 32 + math.random(0, 31), y = chunk.y * 32 + math.random(0, 31)}
position = surface.find_non_colliding_position("rocket-silo", position, 32, 1)
if not position then return end
journey.dispatch_beacon = surface.create_entity({name = "stone-wall", position = position, force = "neutral"})
journey.dispatch_beacon.minable = false
journey.dispatch_beacon_position = {x = position.x, y = position.y}
journey.dispatch_key = math.random(1, size_of_goods_to_dispatch)
local good = goods_to_dispatch[journey.dispatch_key]
local good = goods_to_dispatch[journey.dispatch_key]
table.insert(journey.mothership_messages, "Capsule containing " .. good[2] .. "x [img=item/" .. good[1] .. "] dispatched. [gps=" .. position.x .. "," .. position.y .. ",nauvis]")
if journey.announce_capsules then
Server.to_discord_embed("A capsule containing " .. good[2] .. "x " .. good[1] .. " was spotted at: x=" .. position.x .. ", y=" .. position.y .. "!")
end
surface.create_entity({name = "artillery-projectile", position = {x = position.x - 256 + math.random(0, 512), y = position.y - 256}, target = position, speed = 0.2})
end
@ -1154,8 +1157,8 @@ function Public.world(journey)
end
end
draw_background(journey, game.surfaces.mothership)
if game.tick % 1800 ~= 0 then return end
if game.tick % 1800 ~= 0 then return end
for k, silo in pairs(journey.rocket_silos) do
if not silo or not silo.valid then
table.remove(journey.rocket_silos, k)
@ -1165,14 +1168,14 @@ function Public.world(journey)
if inventory then
local fuel_cells_required = journey.mothership_cargo_space["uranium-fuel-cell"] - journey.mothership_cargo["uranium-fuel-cell"]
if fuel_cells_required > 50 then fuel_cells_required = 50 end
if inventory.get_item_count('satellite') == 1 or inventory.get_item_count('uranium-fuel-cell') >= fuel_cells_required then
if inventory.get_item_count('satellite') == 1 or inventory.get_item_count('uranium-fuel-cell') >= fuel_cells_required then
if silo.launch_rocket() then
table.insert(journey.mothership_messages, "Launching rocket [gps=" .. silo.position.x .. "," .. silo.position.y .. ",nauvis]")
end
end
end
end
end
end
end
end
function Public.mothership_waiting_for_players(journey)
if journey.characters_in_mothership > #game.connected_players * 0.5 then
@ -1191,10 +1194,10 @@ end
function Public.teleporters(journey, player)
if not player.character then return end
if not player.character.valid then return end
local surface = player.surface
local surface = player.surface
if surface.get_tile(player.position).name ~= Constants.teleporter_tile then return end
local base_position = {0,0}
if surface.index == 1 then
if surface.index == 1 then
drop_player_items(player)
local position = game.surfaces.mothership.find_non_colliding_position("character", base_position, 32, 0.5)
if position then
@ -1213,7 +1216,7 @@ function Public.teleporters(journey, player)
else
player.teleport(base_position, game.surfaces.nauvis)
end
journey.characters_in_mothership = journey.characters_in_mothership - 1
return
end

View File

@ -12,7 +12,10 @@ local Unique_modifiers = require 'maps.journey.unique_modifiers'
local Map = require 'modules.map_info'
local Global = require 'utils.global'
local journey = {}
local journey = {
announce_capsules = true
}
Global.register(
journey,
function(tbl)
@ -22,14 +25,14 @@ Global.register(
local function on_chunk_generated(event)
local surface = event.surface
if surface.index == 1 then
Functions.place_mixed_ore(event, journey)
local unique_modifier = Unique_modifiers[journey.world_trait]
if unique_modifier.on_chunk_generated then unique_modifier.on_chunk_generated(event, journey) end
return
end
if surface.name ~= "mothership" then return end
Functions.on_mothership_chunk_generated(event)
end
@ -59,7 +62,7 @@ local function on_player_joined_game(event)
if player.surface.name == "mothership" then
journey.characters_in_mothership = journey.characters_in_mothership + 1
end
if player.force.name == "enemy" then
Functions.clear_player(player)
player.force = game.forces.player
@ -69,13 +72,13 @@ local function on_player_joined_game(event)
else
player.teleport({0,0}, game.surfaces.nauvis)
end
end
end
end
local function on_player_left_game(event)
local player = game.players[event.player_index]
Functions.draw_gui(journey)
if player.surface.name == "mothership" then
journey.characters_in_mothership = journey.characters_in_mothership - 1
end
@ -129,11 +132,11 @@ local function on_rocket_launched(event)
if journey.mothership_cargo_space[slot.name] then
if journey.mothership_cargo[slot.name] > journey.mothership_cargo_space[slot.name] then
journey.mothership_cargo[slot.name] = journey.mothership_cargo_space[slot.name]
end
end
if slot.name == "uranium-fuel-cell" then
Server.to_discord_embed("Refueling progress: " .. journey.mothership_cargo[slot.name] .. "/" .. journey.mothership_cargo_space[slot.name])
end
end
end
end
Functions.draw_gui(journey)
end
@ -148,9 +151,9 @@ local function on_init()
T.localised_category = 'journey'
T.main_caption_color = {r = 100, g = 20, b = 255}
T.sub_caption_color = {r = 100, g = 100, b = 100}
game.permissions.get_group('Default').set_allows_action(defines.input_action.set_auto_launch_rocket, false)
Functions.hard_reset(journey)
end
@ -161,7 +164,7 @@ commands.add_command(
local player = game.player
if not (player and player.valid) then
return
end
end
if not player.admin then
player.print("You are not an admin!")
return
@ -178,7 +181,7 @@ commands.add_command(
local player = game.player
if not (player and player.valid) then
return
end
end
if not player.admin then
player.print("You are not an admin!")
return

View File

@ -138,6 +138,9 @@ local check_distance_between_player_and_locomotive = function(player)
if c_y - t_y <= gap_between_locomotive.neg_gap then
player.teleport({position.x, locomotive.position.y + gap_between_locomotive.neg_gap + 2}, surface)
player.print(({'breached_wall.hinder'}), Color.warning)
if player.driving then
player.driving = false
end
if player.character then
player.character.health = player.character.health - 5
player.character.surface.create_entity({name = 'water-splash', position = position})

View File

@ -12,7 +12,7 @@ Public.terrain = require 'maps.mountain_fortress_v3.terrain'
Public.generate = require 'maps.mountain_fortress_v3.generate'
Public.get_perlin = require 'maps.mountain_fortress_v3.get_perlin'
Public.gui = require 'maps.mountain_fortress_v3.gui'
-- Public.highscore = require 'maps.mountain_fortress_v3.highscore'
Public.highscore = require 'maps.mountain_fortress_v3.highscore'
Public.locomotive = require 'maps.mountain_fortress_v3.locomotive'
Public.loot = require 'maps.mountain_fortress_v3.loot'
Public.mining = require 'maps.mountain_fortress_v3.mining'

View File

@ -85,20 +85,20 @@ local reset_game =
function(data)
local this = data.this
if this.soft_reset then
-- Public.set_scores()
Public.set_scores()
this.game_reset_tick = nil
Public.reset_map()
return
end
if this.restart then
-- Public.set_scores()
Public.set_scores()
local message = ({'entity.reset_game'})
Server.to_discord_bold(message, true)
Server.start_scenario('Mountain_Fortress_v3')
return
end
if this.shutdown then
-- Public.set_scores()
Public.set_scores()
local message = ({'entity.shutdown_game'})
Server.to_discord_bold(message, true)
Server.stop_scenario()
@ -213,7 +213,7 @@ local function set_train_final_health(final_damage_amount, repair)
if not poison_deployed then
local carriages = Public.get('carriages')
if WD.get('wave_number') < 501 then
if WD.get('wave_number') <= 800 then
if carriages then
for i = 1, #carriages do
local entity = carriages[i]
@ -1149,8 +1149,9 @@ local function show_mvps(player)
miners_label_text.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
local sent_to_discord = Public.get('sent_to_discord')
local server_name_matches = Server.check_server_name('Mtn Fortress')
if not sent_to_discord then
if not sent_to_discord and server_name_matches then
local message = {
title = 'Game over',
description = 'Player statistics is below',
@ -1192,7 +1193,6 @@ local function show_mvps(player)
local upgrades = Public.get('upgrades')
local pick_tier = pickaxe_upgrades[upgrades.pickaxe_tier]
local server_name_matches = Server.check_server_name('Mtn Fortress')
if Public.get('prestige_system_enabled') then
RPG_Progression.save_all_players()
end

View File

@ -320,11 +320,11 @@ local function do_beams_away()
local difficulty_index = Difficulty.get('index')
local wave_nth = 9999
if difficulty_index == 1 then
wave_nth = 1000
elseif difficulty_index == 2 then
wave_nth = 500
elseif difficulty_index == 3 then
elseif difficulty_index == 2 then
wave_nth = 250
elseif difficulty_index == 3 then
wave_nth = 100
end
if wave_number % wave_nth == 0 then
@ -635,12 +635,16 @@ Public.magic_item_crafting_callback_weighted =
return
end
entity.minable = false
entity.destructible = false
entity.operable = false
local weights = callback_data.weights
local loot = callback_data.loot
local destructible = callback_data.destructible
if not destructible then
entity.destructible = false
end
entity.minable = false
entity.operable = false
local p = entity.position
@ -903,6 +907,8 @@ function Public.set_difficulty()
amount = difficulty.highest -- lowered from 20 to 10
end
local wave = WD.get('wave_number')
local threat_check = nil
if check_if_threat_below_zero then
@ -910,26 +916,27 @@ function Public.set_difficulty()
end
if Diff.index == 1 then
if player_count < 10 then
if wave < 100 then
wave_defense_table.wave_interval = 4500
else
wave_defense_table.wave_interval = 3600 - player_count * 60
end
if wave_defense_table.wave_interval < 2200 or threat_check then
wave_defense_table.wave_interval = 2200
if wave_defense_table.wave_interval < 2000 or threat_check then
wave_defense_table.wave_interval = 2000
end
elseif Diff.index == 2 then
if player_count < 10 then
if wave < 100 then
wave_defense_table.wave_interval = 3000
else
wave_defense_table.wave_interval = 2600 - player_count * 60
end
if wave_defense_table.wave_interval < 1900 or threat_check then
wave_defense_table.wave_interval = 1900
if wave_defense_table.wave_interval < 1800 or threat_check then
wave_defense_table.wave_interval = 1800
end
elseif Diff.index == 3 then
if player_count < 10 then
wave_defense_table.wave_interval = 2000
if wave < 100 then
wave_defense_table.wave_interval = 3000
else
wave_defense_table.wave_interval = 1600 - player_count * 60
end

View File

@ -154,6 +154,15 @@ local function create_main_frame(player)
label.style.font_color = {r = 0.88, g = 0.88, b = 0.88}
label.style.font = 'default-bold'
label.style.right_padding = 4
line = frame.add({type = 'line', direction = 'vertical'})
line.style.left_padding = 4
line.style.right_padding = 4
label = frame.add({type = 'label', caption = ' ', name = 'defense_enabled'})
label.style.font_color = {r = 0.88, g = 0.88, b = 0.88}
label.style.font = 'default-bold'
label.style.right_padding = 4
end
local function hide_all_gui(player)
@ -499,6 +508,16 @@ function Public.update_gui(player)
gui.chest_upgrades.caption = ' [img=entity.steel-chest]: ' .. format_number(upgrades.chests_outside_upgrades, true)
gui.chest_upgrades.tooltip = ({'gui.chest_placed'})
local robotics_deployed = Public.get('robotics_deployed')
if robotics_deployed then
gui.defense_enabled.caption = ' [img=item.destroyer-capsule]: Deployed'
gui.defense_enabled.tooltip = ({'gui.robotics_deployed'})
else
gui.defense_enabled.caption = ' [img=item.destroyer-capsule]: Standby'
gui.defense_enabled.tooltip = ({'gui.robotics_standby'})
end
end
Event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -42,6 +42,9 @@ local biters = {
local function get_lowest(tbl, column_name)
local t = {}
if not tbl then
return 100
end
for _, value in pairs(tbl) do
insert(t, value[column_name])
end
@ -60,6 +63,9 @@ end
local function get_highest(tbl, column_name)
local t = {}
if not tbl then
return 100
end
for _, value in pairs(tbl) do
insert(t, value[column_name])
end
@ -77,6 +83,10 @@ local function get_highest(tbl, column_name)
end
local function contains(tbl, key, string, rtn)
if not tbl then
return false
end
for index, value in pairs(tbl) do
if value[key] and value[key] == string then
if rtn then
@ -117,7 +127,7 @@ local function get_sorted_list(column_name, score_list)
return sl
end
local function get_mvps()
local function get_mvps(clear_state)
local new_score_table = Score.get_table().score_table
if not new_score_table['player'] then
return false
@ -125,7 +135,10 @@ local function get_mvps()
local old_score = this.score_table['player']
local score = new_score_table['player']
local score_list = {}
local mvp = old_score.players
local mvp = old_score.players or {}
if clear_state then
mvp = {}
end
for _, p in pairs(game.players) do
if score.players[p.name] then
@ -168,33 +181,38 @@ local function get_mvps()
if kill_list then
if not contains(mvp, 'name', kill_list.name) then
if kill_list.killscore >= lowest_k then
if death_list and death_list.deaths < highest_d then
insert(
mvp,
{
name = kill_list.name,
killscore = kill_list.killscore,
deaths = death_list.deaths
}
)
else
insert(
mvp,
{
name = kill_list.name,
killscore = kill_list.killscore
}
)
end
insert(
mvp,
{
name = kill_list.name,
killscore = kill_list.killscore,
mined_entities = kill_list.mined_entities,
built_entities = kill_list.built_entities,
deaths = kill_list.deaths
}
)
end
else
local index = contains(mvp, 'name', kill_list.name, true)
if index then
if mvp[index].killscore and kill_list.killscore > mvp[index].killscore then
mvp[index].killscore = kill_list.killscore
end
if death_list and mvp[index].deaths and death_list.deaths < mvp[index].deaths then
mvp[index].deaths = death_list.deaths
if mvp[index].mined_entities and kill_list.mined_entities > mvp[index].mined_entities then
mvp[index].mined_entities = kill_list.mined_entities
else
mvp[index].mined_entities = kill_list.mined_entities
end
if mvp[index].built_entities and kill_list.built_entities > mvp[index].built_entities then
mvp[index].built_entities = kill_list.built_entities
else
mvp[index].built_entities = kill_list.built_entities
end
if mvp[index].deaths and kill_list.deaths < mvp[index].deaths then
mvp[index].deaths = kill_list.deaths
else
mvp[index].deaths = kill_list.deaths
end
end
end
end
@ -202,33 +220,38 @@ local function get_mvps()
if mined_list then
if not contains(mvp, 'name', mined_list.name) then
if mined_list.mined_entities >= lowest_m then
if death_list and death_list.deaths < highest_d then
insert(
mvp,
{
name = mined_list.name,
mined_entities = mined_list.mined_entities,
deaths = death_list.deaths
}
)
else
insert(
mvp,
{
name = mined_list.name,
mined_entities = mined_list.mined_entities
}
)
end
insert(
mvp,
{
name = mined_list.name,
killscore = mined_list.killscore,
mined_entities = mined_list.mined_entities,
built_entities = mined_list.built_entities,
deaths = mined_list.deaths
}
)
end
else
local index = contains(mvp, 'name', mined_list.name, true)
if index then
if mvp[index].mined_entities and mined_list.mined_entities > mvp[index].mined_entities then
mvp[index].mined_entities = mined_list.mined_entities
end
if death_list and mvp[index].deaths and death_list.deaths < mvp[index].deaths then
mvp[index].deaths = death_list.deaths
if mvp[index].killscore and mined_list.killscore > mvp[index].killscore then
mvp[index].killscore = mined_list.killscore
else
mvp[index].killscore = mined_list.killscore
end
if mvp[index].built_entities and mined_list.built_entities > mvp[index].built_entities then
mvp[index].built_entities = mined_list.built_entities
else
mvp[index].built_entities = mined_list.built_entities
end
if mvp[index].deaths and mined_list.deaths < mvp[index].deaths then
mvp[index].deaths = mined_list.deaths
else
mvp[index].deaths = mined_list.deaths
end
end
end
end
@ -236,38 +259,82 @@ local function get_mvps()
if build_list then
if not contains(mvp, 'name', build_list.name) then
if build_list.built_entities >= lowest_b then
if death_list and death_list.deaths < highest_d then
insert(
mvp,
{
name = build_list.name,
built_entities = build_list.built_entities,
deaths = death_list.deaths
}
)
else
insert(
mvp,
{
name = build_list.name,
built_entities = build_list.built_entities
}
)
end
insert(
mvp,
{
name = build_list.name,
killscore = build_list.killscore,
mined_entities = build_list.mined_entities,
built_entities = build_list.built_entities,
deaths = build_list.deaths
}
)
end
else
local index = contains(mvp, 'name', build_list.name, true)
if index then
if mvp[index].built_entities and build_list.built_entities > mvp[index].built_entities then
mvp[index].built_entities = build_list.built_entities
end
if death_list and mvp[index].deaths and death_list.deaths < mvp[index].deaths then
mvp[index].deaths = death_list.deaths
if mvp[index].killscore and build_list.killscore > mvp[index].killscore then
mvp[index].killscore = build_list.killscore
else
mvp[index].killscore = build_list.killscore
end
if mvp[index].mined_entities and build_list.mined_entities > mvp[index].mined_entities then
mvp[index].mined_entities = build_list.mined_entities
else
mvp[index].mined_entities = build_list.mined_entities
end
if mvp[index].deaths and build_list.deaths < mvp[index].deaths then
mvp[index].deaths = build_list.deaths
else
mvp[index].deaths = build_list.deaths
end
end
end
end
end
if death_list then
if not contains(mvp, 'name', death_list.name) then
if death_list.deaths < highest_d then
insert(
mvp,
{
name = death_list.name,
killscore = death_list.killscore,
mined_entities = death_list.mined_entities,
built_entities = death_list.built_entities,
deaths = death_list.deaths
}
)
end
else
local index = contains(mvp, 'name', death_list.name, true)
if index then
if mvp[index].deaths and death_list.deaths < mvp[index].deaths then
mvp[index].deaths = death_list.deaths
if mvp[index].killscore and death_list.killscore > mvp[index].killscore then
mvp[index].killscore = death_list.killscore
else
mvp[index].killscore = death_list.killscore
end
if mvp[index].mined_entities and death_list.mined_entities > mvp[index].mined_entities then
mvp[index].mined_entities = death_list.mined_entities
else
mvp[index].mined_entities = death_list.mined_entities
end
if mvp[index].built_entities and death_list.built_entities > mvp[index].built_entities then
mvp[index].built_entities = death_list.built_entities
else
mvp[index].built_entities = death_list.built_entities
end
end
end
end
end
if mvp['GodGamer'] then
mvp['GodGamer'] = nil
end
@ -296,6 +363,7 @@ local function write_additional_stats(key, difficulty)
local new_rockets_launched = player.rockets_launched
local new_total_time = game.ticks_played
local t = this.score_table['player']
local clear_state = false
if this.score_table['player'] then
local old_wave = this.score_table['player'].wave_number
@ -304,48 +372,64 @@ local function write_additional_stats(key, difficulty)
local old_rockets_launched = this.score_table['player'].rockets_launched
local old_total_time = this.score_table['player'].total_time
local old_players = this.score_table['player'].players
if new_wave_number > old_wave then
t.wave_number = new_wave_number
else
t.wave_number = old_wave
if old_wave then
if new_wave_number > old_wave then
clear_state = true
t.wave_number = new_wave_number
else
t.wave_number = old_wave
end
end
if new_biters_killed > old_biters_killed then
t.biters_killed = new_biters_killed
else
t.biters_killed = old_biters_killed
if old_biters_killed then
if new_biters_killed > old_biters_killed then
t.biters_killed = new_biters_killed
else
t.biters_killed = old_biters_killed
end
end
if new_breached_zone > old_breached_zone then
t.breached_zone = new_breached_zone
else
t.breached_zone = old_breached_zone
if old_breached_zone then
if new_breached_zone > old_breached_zone then
t.breached_zone = new_breached_zone
else
t.breached_zone = old_breached_zone
end
end
if new_rockets_launched > old_rockets_launched then
t.rockets_launched = new_rockets_launched
else
t.rockets_launched = old_rockets_launched
if old_rockets_launched then
if new_rockets_launched > old_rockets_launched then
t.rockets_launched = new_rockets_launched
else
t.rockets_launched = old_rockets_launched
end
end
if new_total_time > old_total_time then
t.total_time = new_total_time
else
t.total_time = old_total_time
if old_total_time then
if new_total_time > old_total_time then
t.total_time = new_total_time
else
t.total_time = old_total_time
end
end
if difficulty then
t.difficulty = difficulty
end
local new_stats = get_mvps()
local new_stats = get_mvps(clear_state)
if new_stats then
t.players = new_stats
else
t.players = old_players
if old_players then
t.players = old_players
end
end
end
this.score_table['player'] = t
this.score_table['player'] = t
if key then
set_data(score_dataset, key, t)
if key then
set_data(score_dataset, key, t)
end
end
end
@ -370,6 +454,7 @@ function Public.get_scores()
end
end
-- local Core = require 'maps.mountain_fortress_v3.core' Core.set_scores()
function Public.set_scores(difficulty)
local secs = Server.get_current_time()
if not secs then
@ -614,6 +699,9 @@ local function on_gui_click(event)
end
local player = game.get_player(event.element.player_index)
if not player then
return
end
local frame = Gui.get_player_active_frame(player)
if not frame then

View File

@ -494,8 +494,8 @@ local function on_player_changed_surface(event)
return
end
local itemGhost = player.cursor_ghost
if itemGhost then
local item_ghost = player.cursor_ghost
if item_ghost then
player.cursor_ghost = nil
end

View File

@ -37,6 +37,10 @@ function Public.add_player_to_permission_group(player, group, forced)
end
limited_group.set_allows_action(defines.input_action.cancel_craft, false)
limited_group.set_allows_action(defines.input_action.drop_item, false)
-- limited_group.set_allows_action(defines.input_action.upgrade, false) -- fixes factorio base issue
-- limited_group.set_allows_action(defines.input_action.upgrade_opened_blueprint_by_item, false)
-- limited_group.set_allows_action(defines.input_action.upgrade_opened_blueprint_by_record, false)
-- limited_group.set_allows_action(defines.input_action.cancel_upgrade, false)
if allow_decon then
limited_group.set_allows_action(defines.input_action.deconstruct, true)
else

View File

@ -52,6 +52,7 @@ 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 = {
@ -260,6 +261,10 @@ function Public.reset_map()
WD.increase_boss_health_per_wave(true)
WD.increase_damage_per_wave(true)
WD.increase_health_per_wave(true)
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()
@ -270,10 +275,11 @@ function Public.reset_map()
end
game.forces.player.set_spawn_position({-27, 25}, surface)
game.speed = 1
Task.set_queue_speed(16)
-- Public.get_scores()
Public.get_scores()
this.chunk_load_tick = game.tick + 400
this.force_chunk = true
@ -326,18 +332,18 @@ local has_the_game_ended = function()
game.print(({'main.reset_in', cause_msg, this.game_reset_tick / 60}), {r = 0.22, g = 0.88, b = 0.22})
end
-- local diff_name = Difficulty.get('name')
local diff_name = Difficulty.get('name')
if this.soft_reset and this.game_reset_tick == 0 then
this.game_reset_tick = nil
-- Public.set_scores(diff_name)
Public.set_scores(diff_name)
Public.reset_map()
return
end
if this.restart and this.game_reset_tick == 0 then
if not this.announced_message then
-- Public.set_scores(diff_name)
Public.set_scores(diff_name)
game.print(({'entity.notify_restart'}), {r = 0.22, g = 0.88, b = 0.22})
local message = 'Soft-reset is disabled! Server will restart from scenario to load new changes.'
Server.to_discord_bold(table.concat {'*** ', message, ' ***'})
@ -348,7 +354,7 @@ local has_the_game_ended = function()
end
if this.shutdown and this.game_reset_tick == 0 then
if not this.announced_message then
-- Public.set_scores(diff_name)
Public.set_scores(diff_name)
game.print(({'entity.notify_shutdown'}), {r = 0.22, g = 0.88, b = 0.22})
local message = 'Soft-reset is disabled! Server will shutdown. Most likely because of updates.'
Server.to_discord_bold(table.concat {'*** ', message, ' ***'})

View File

@ -277,6 +277,20 @@ local restore_mining_speed_token =
end
)
local restore_crafting_speed_token =
Token.register(
function()
local mc_rewards = Public.get('mc_rewards')
local force = game.forces.player
if mc_rewards.temp_boosts.crafting then
force.manual_crafting_speed_modifier = force.manual_crafting_speed_modifier - 1
mc_rewards.temp_boosts.crafting = nil
local message = ({'locomotive.crafting_bonus_end'})
Alert.alert_all_players(10, message, nil, 'achievement/tech-maniac')
end
end
)
local restore_movement_speed_token =
Token.register(
function()
@ -371,13 +385,21 @@ local mc_random_rewards = {
512
},
{
name = 'Heal Locomotive',
name = 'Crafting speed bonus',
color = {r = 0.00, g = 0.00, b = 0.25},
tooltip = 'Selecting this will heal the main locomotive to full health!',
tooltip = 'Selecting this will grant all players 100% crafting bonus for 15 minutes!',
func = (function(player)
local locomotive_max_health = Public.get('locomotive_max_health')
Public.set('locomotive_health', locomotive_max_health)
local message = ({'locomotive.locomotive_health', player.name})
local mc_rewards = Public.get('mc_rewards')
local force = game.forces.player
if mc_rewards.temp_boosts.crafting then
return false, '[Rewards] Crafting bonus is already applied. Please choose another reward.'
end
mc_rewards.temp_boosts.crafting = true
Task.set_timeout_in_ticks(54000, restore_crafting_speed_token)
force.manual_crafting_speed_modifier = force.manual_crafting_speed_modifier + 1
local message = ({'locomotive.crafting_bonus', player.name})
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac')
return true
end),

View File

@ -409,7 +409,8 @@ local testing_callback = {
data = {
loot = testing_loot,
weights = testing_weights,
testing = true
testing = true,
destructible = true
}
}
@ -417,7 +418,8 @@ local science_callback = {
callback = Functions.magic_item_crafting_callback_weighted,
data = {
loot = science_loot,
weights = science_weights
weights = science_weights,
destructible = true
}
}
@ -425,7 +427,8 @@ local building_callback = {
callback = Functions.magic_item_crafting_callback_weighted,
data = {
loot = ammo_loot,
weights = building_weights
weights = building_weights,
destructible = true
}
}
@ -433,7 +436,8 @@ local oil_callback = {
callback = Functions.magic_item_crafting_callback_weighted,
data = {
loot = oil_loot,
weights = oil_weights
weights = oil_weights,
destructible = true
}
}
@ -441,7 +445,8 @@ local oil_prod_callback = {
callback = Functions.magic_item_crafting_callback_weighted,
data = {
loot = oil_prod_loot,
weights = oil_prod_weights
weights = oil_prod_weights,
destructible = true
}
}
@ -449,7 +454,8 @@ local resource_callback = {
callback = Functions.magic_item_crafting_callback_weighted,
data = {
loot = resource_loot,
weights = resource_weights
weights = resource_weights,
destructible = true
}
}
@ -457,7 +463,8 @@ local furnace_callback = {
callback = Functions.magic_item_crafting_callback_weighted,
data = {
loot = furnace_loot,
weights = furnace_weights
weights = furnace_weights,
destructible = true
}
}

View File

@ -246,7 +246,6 @@ function Public.reset_main_table()
this.adjusted_zones = {
scrap = {},
forest = {},
slow_movement = {},
size = nil,
shuffled_zones = nil
}

View File

@ -158,6 +158,16 @@ local function is_position_near(area, table_to_check)
end
local function place_wagon(data, adjusted_zones)
local x_min = (-zone_settings.zone_width / 2) + 10
local x_max = (zone_settings.zone_width / 2) - 10
if data.x < x_min then
return
end
if data.x > x_max then
return
end
local placed_trains_in_zone = Public.get('placed_trains_in_zone')
if not placed_trains_in_zone.randomized then
placed_trains_in_zone.limit = random(1, 2)

View File

@ -1,6 +1,7 @@
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
local Event = require 'utils.event'
local Balance = require 'maps.pirates.balance'
local _inspect = require 'utils.inspect'.inspect
local Memory = require 'maps.pirates.memory'
@ -24,6 +25,7 @@ local Classes = require 'maps.pirates.roles.classes'
local Token = require 'utils.token'
local Task = require 'utils.task'
local SurfacesCommon = require 'maps.pirates.surfaces.common'
local BottomFrame = require 'utils.gui.bottom_frame'
local Public = {}
local enum = {
@ -475,6 +477,7 @@ function Public.leave_crew(player, to_lobby, quiet)
player.teleport(surface.find_non_colliding_position('character', Common.lobby_spawnpoint, 32, 0.5) or Common.lobby_spawnpoint, surface)
player.force = 'player'
player.create_character()
Event.raise(BottomFrame.events.bottom_quickbar_respawn_raise, {player_index = player.index})
end
memory.crewplayerindices = Utils.ordered_table_with_values_removed(memory.crewplayerindices, player.index)
@ -1096,4 +1099,4 @@ function Public.disable_recipes(crew_force)
crew_force.recipes['speed-module-3'].enabled = false
end
return Public
return Public

View File

@ -1,16 +1,49 @@
local Event = require 'utils.event'
local ScenarioTable = require 'maps.scrap_towny_ffa.table'
local SoftReset = require 'functions.soft_reset'
local Server = require 'utils.server'
local Token = require 'utils.token'
local math_random = math.random
local table_shuffle = table.shuffle_table
local dataset = 'scenario_settings'
local dataset_key = 'scrap_towny_ffa'
local Public = {}
--local Server = require 'utils.server'
local map_width = 2560
local map_height = 2560
local set_victory_length_token =
Token.register(
function(data)
local this = ScenarioTable.get_table()
local settings = {}
if not data or not data.value then
if this.shuffle_random_victory_time and math.random(1, 32) == 1 then
this.required_time_to_win = 48
this.required_time_to_win_in_ticks = 10368000
end
else
local value = data.value
local required_time_to_win = value.required_time_to_win
if required_time_to_win == 48 then
this.required_time_to_win = 168
this.required_time_to_win_in_ticks = 36288000
else
this.required_time_to_win = 48
this.required_time_to_win_in_ticks = 10368000
end
end
settings.required_time_to_win = this.required_time_to_win
settings.required_time_to_win_in_ticks = this.required_time_to_win_in_ticks
Server.set_data(dataset, dataset_key, settings)
end
)
function Public.nuke(position)
local this = ScenarioTable.get_table()
local map_surface = game.get_surface(this.active_surface_index)
@ -140,10 +173,7 @@ function Public.initialize()
return
end
if this.shuffle_random_victory_time and math.random(1, 32) == 1 then
this.required_time_to_win = 48
this.required_time_to_win_in_ticks = 10368000
end
Server.try_get_data(dataset, dataset_key, set_victory_length_token)
surface.map_gen_settings = mgs
surface.peaceful_mode = false

View File

@ -42,11 +42,11 @@ local function warning()
Alert.alert_all_players(5, 'The world is ending!', Color.white, 'warning-white', 1.0)
end
local function armageddon()
if not get_victorious_force() then
Nauvis.armageddon()
end
end
-- local function armageddon()
-- if not get_victorious_force() then
-- Nauvis.armageddon()
-- end
-- end
local function do_soft_reset()
local this = ScenarioTable.get_table()
@ -163,9 +163,9 @@ local function on_tick()
if (tick + armageddon_duration + warning_duration) % game_duration == 0 then
warning()
end
if (tick + armageddon_duration) % game_duration == 0 then
armageddon()
end
-- if (tick + armageddon_duration) % game_duration == 0 then
-- armageddon()
-- end
if (tick + 1) % game_duration == 0 then
Nauvis.clear_nuke_schedule()
Team.reset_all_forces()

View File

@ -30,6 +30,11 @@ Global.register(
end
)
local bps_blacklist = {
['blueprint-book'] = true,
['blueprint'] = true
}
local function create_floaty_text(surface, position, name, count)
if this.floating_text_y_offsets[position.x .. '_' .. position.y] then
this.floating_text_y_offsets[position.x .. '_' .. position.y] = this.floating_text_y_offsets[position.x .. '_' .. position.y] - 0.5
@ -508,8 +513,7 @@ local function auto_stash(player, event)
end
local name = inventory[i].name
local is_resource = this.whitelist[name]
if not hotbar_items[name] then
if not hotbar_items[name] and not bps_blacklist[name] then
if ctrl and this.insert_into_furnace then
if button == defines.mouse_button_type.right then
if is_resource then

View File

@ -183,6 +183,20 @@ local function add_recipe_to_whitelist(item_whitelist, recipe)
for key, ingredient in pairs(recipe.ingredients) do
item_whitelist[ingredient.name] = true
end
--Adding "place_result" in case the inventory item can turn into a differently named entity after placement on the map.
for key, product in pairs(recipe.products) do
local p = game.item_prototypes[product.name]
if p and p.place_result then
item_whitelist[p.place_result.name] = true
end
end
for key, ingredient in pairs(recipe.ingredients) do
local p = game.item_prototypes[ingredient.name]
if p and p.place_result then
item_whitelist[p.place_result.name] = true
end
end
end
function Public.add_research_to_whitelist(force, effects)

View File

@ -726,6 +726,7 @@ function Public.draw_top_toggle_button(player)
button_flow.style.maximal_height = 38
button_flow.style.minimal_width = 40
button_flow.style.padding = -2
button_flow.style.font_color = {222, 222, 222}
end
function Public.open_recipe(element, player, button)

View File

@ -138,6 +138,10 @@ local function on_string_translated(event)
end
localised_string = localised_string[1]
if not localised_string then
return
end
localised_string = string.match(localised_string, '[^.]*$')
Functions.set_translated_data(player, result, localised_string)

View File

@ -42,18 +42,23 @@ local remove = table.remove
local speed = 0.06
--- Draws a new render.
---@return table
---@return table|nil
function Public:new_render()
local surface = game.get_surface(self.surface_id)
if not surface or not surface.valid then
return
end
self.render_id = rendering.draw_sprite {target = self.position, sprite = self.sprite, surface = surface}
return self
end
--- Sets a new target for a given render.
---@return table
---@return table
---@return table|nil, table|nil
function Public:new_target()
local surface = game.get_surface(self.surface_id)
if not surface or not surface.valid then
return
end
local position
local entities = surface.find_entities_filtered {type = this.valid_targets}
if entities and #entities > 0 then
@ -92,6 +97,7 @@ function Public:set_render_scalar_size()
}
)
end
--- Gets a random position.
---@return table
function Public:random_position()
@ -128,6 +134,9 @@ function Public:switch_position()
self.target_position = self:random_position()
else
local surface = game.get_surface(self.surface_id)
if not surface or not surface.valid then
return
end
local chunk = surface.get_random_chunk()
self.target_position = {x = (chunk.x + math.random()) * 32, y = (chunk.y + math.random()) * 32}
end
@ -138,6 +147,10 @@ function Public:notify_new_beam()
if not self.notify then
self.notify = true
local surface = game.get_surface(self.surface_id)
if not surface or not surface.valid then
return
end
game.print('[Orbital] A new orbital strike has been spotted at: [gps=' .. self.position.x .. ',' .. self.position.y .. ',' .. surface.name .. ']')
end
end
@ -149,6 +162,10 @@ function Public:render_chart()
end
local surface = game.get_surface(self.surface_id)
if not surface or not surface.valid then
return
end
self.chart =
game.forces[self.force].add_chart_tag(
surface,
@ -182,9 +199,19 @@ end
function Public:render_fire_damage()
if random(1, 15) == 1 then
local surface = game.get_surface(self.surface_id)
if not surface or not surface.valid then
return
end
surface.create_entity({name = 'fire-flame', position = {x = self.position.x, y = self.position.y + 5}})
if random(1, 5) == 1 then
surface.create_entity({name = 'medium-scorchmark', position = {x = self.position.x, y = self.position.y + 5}, force = 'neutral'})
surface.create_entity(
{
name = 'medium-scorchmark',
position = {x = self.position.x, y = self.position.y + 5},
force = 'neutral'
}
)
end
end
end
@ -193,8 +220,20 @@ end
function Public:damage_entities_nearby()
if random(1, 3) == 1 then
local surface = game.get_surface(self.surface_id)
if not surface or not surface.valid then
return
end
local damage = random(10, 15)
local entities = surface.find_entities_filtered({position = self.position, radius = 20, type = 'simple-entity', invert = true})
local entities =
surface.find_entities_filtered(
{
position = self.position,
radius = 20,
type = 'simple-entity',
invert = true
}
)
for _, entity in pairs(entities) do
if entity.valid then
if entity.health then

View File

@ -20,6 +20,12 @@ local floor = math.floor
local random = math.random
local abs = math.abs
local sub = string.sub
local angle_multipler = 2 * math.pi
local start_angle = -angle_multipler / 4
local update_rate = 4
local time_to_live = update_rate + 1
local draw_arc = rendering.draw_arc
--RPG Frames
local main_frame_name = Public.main_frame_name
@ -982,6 +988,51 @@ function Public.get_magicka(player)
return (rpg_t.magicka - 10) * 0.10
end
local show_cooldown
show_cooldown =
Token.register(
function(event)
local player_index = event.player_index
local player = game.get_player(player_index)
if not player or not player.valid then
return
end
local tick = event.tick
local now = game.tick
if now >= tick then
return
end
local fade = ((now - tick) / event.delay) + 1
if not player.character then
return
end
draw_arc(
{
color = {1 - fade, fade, 0},
max_radius = 0.5,
min_radius = 0.4,
start_angle = start_angle,
angle = fade * angle_multipler,
target = player.character,
target_offset = {x = 0, y = -2},
surface = player.surface,
time_to_live = time_to_live
}
)
Task.set_timeout_in_ticks(update_rate, show_cooldown, event)
end
)
Public.show_cooldown = show_cooldown
function Public.register_cooldown_for_player(player, spell)
Task.set_timeout_in_ticks(update_rate, show_cooldown, {player_index = player.index, tick = game.tick + spell.cooldown, delay = spell.cooldown})
end
--- Gives connected player some bonus xp if the map was preemptively shut down.
-- amount (integer) -- 10 levels
-- local Public = require 'modules.rpg.table' Public.give_xp(512)

View File

@ -980,6 +980,10 @@ local function on_player_used_capsule(event)
return
end
if spell.enforce_cooldown then
Public.register_cooldown_for_player(player, spell)
end
rpg_t.last_spawned = game.tick + spell.cooldown
Public.update_mana(player)
@ -1053,4 +1057,25 @@ Event.add(
end
)
if _DEBUG then
Public.disable_cooldowns_on_spells()
Event.on_init(
function()
Public.rpg_reset_all_players()
Public.enable_health_and_mana_bars(true)
Public.enable_wave_defense(true)
Public.enable_mana(true)
Public.personal_tax_rate(0.4)
Public.enable_stone_path(true)
Public.enable_aoe_punch(true)
Public.enable_aoe_punch_globally(false)
Public.enable_range_buffs(true)
Public.enable_auto_allocate(true)
Public.enable_explosive_bullets_globally(true)
Public.enable_explosive_bullets(false)
end
)
end
return Public

View File

@ -606,6 +606,30 @@ spells[#spells + 1] = {
return create_projectiles(data)
end
}
if _DEBUG then
spells[#spells + 1] = {
name = 'Kewl Nade',
entityName = 'cluster-grenade',
target = true,
amount = 20,
damage = true,
aoe = true,
force = 'player',
level = 1,
type = 'item',
mana_cost = -1,
cooldown = 0,
enabled = true,
log_spell = false,
sprite = 'recipe/cluster-grenade',
tooltip = 'Spawns a cluster nade where the mouse cursor is at',
callback = function(data)
local player = data.player
player.insert({name = 'raw-fish'})
return create_projectiles(data)
end
}
end
spells[#spells + 1] = {
name = {'item-name.cluster-grenade'},
entityName = 'cluster-grenade',

View File

@ -376,7 +376,9 @@ local function set_group_spawn_position(surface)
end
Public.set('spawn_position', {x = position.x, y = position.y})
local spawn_position = get_spawn_pos()
debug_print('set_group_spawn_position -- Changed position to x' .. spawn_position.x .. ' y' .. spawn_position.y .. '.')
if spawn_position then
debug_print('set_group_spawn_position -- Changed position to x' .. spawn_position.x .. ' y' .. spawn_position.y .. '.')
end
end
local function set_enemy_evolution()
@ -482,6 +484,16 @@ local function spawn_biter(surface, position, forceSpawn, is_boss_biter, unit_se
local old_position = position
local enable_random_spawn_positions = Public.get('enable_random_spawn_positions')
if enable_random_spawn_positions then
if random(1, 3) == 1 then
position = {x = (-1 * (position.x + random(1, 10))), y = (position.y + random(1, 10))}
else
position = {x = (position.x + random(1, 10)), y = (position.y + random(1, 10))}
end
end
position = surface.find_non_colliding_position('steel-chest', position, 3, 1)
if not position then
position = old_position
@ -587,6 +599,50 @@ local function increase_biters_health()
Public.set('modified_boss_unit_health').current_value = modified_boss_unit_health.current_value + modified_boss_unit_health.health_increase_per_boss_wave
end
local function increase_unit_group_size()
local increase_average_unit_group_size = Public.get('increase_average_unit_group_size')
if not increase_average_unit_group_size then
return
end
local boost_spawner_sizes_wave_is_above = Public.get('boost_spawner_sizes_wave_is_above')
local wave_number = Public.get('wave_number')
if (wave_number >= boost_spawner_sizes_wave_is_above) then
local average_unit_group_size = Public.get('average_unit_group_size')
local new_average_unit_group_size = average_unit_group_size + 1
if new_average_unit_group_size > 128 then
new_average_unit_group_size = 128
end
Public.set('average_unit_group_size', new_average_unit_group_size)
debug_print_health('average_unit_group_size - ' .. new_average_unit_group_size)
end
end
local function increase_max_active_unit_groups()
local _increase_max_active_unit_groups = Public.get('increase_max_active_unit_groups')
if not _increase_max_active_unit_groups then
return
end
local boost_spawner_sizes_wave_is_above = Public.get('boost_spawner_sizes_wave_is_above')
local wave_number = Public.get('wave_number')
if (wave_number >= boost_spawner_sizes_wave_is_above) then
local max_active_unit_groups = Public.get('max_active_unit_groups')
local new_max_active_unit_groups = max_active_unit_groups + 1
if new_max_active_unit_groups > 64 then
new_max_active_unit_groups = 64
end
Public.set('max_active_unit_groups', new_max_active_unit_groups)
debug_print_health('max_active_unit_groups - ' .. new_max_active_unit_groups)
end
end
local function set_next_wave()
local wave_number = Public.get('wave_number')
Public.set('wave_number', wave_number + 1)
@ -594,9 +650,17 @@ local function set_next_wave()
local threat_gain_multiplier = Public.get('threat_gain_multiplier')
local threat_gain = wave_number * threat_gain_multiplier
if wave_number > 1000 then
threat_gain = threat_gain * (wave_number * 0.001)
end
if wave_number % 50 == 0 then
increase_unit_group_size()
end
if wave_number % 200 == 0 then
increase_max_active_unit_groups()
end
if wave_number % 25 == 0 then
increase_biter_damage()
increase_biters_health()

View File

@ -11,6 +11,7 @@ local main_frame_name = Gui.uid_name()
local save_button_name = Gui.uid_name()
local discard_button_name = Gui.uid_name()
local random = math.random
local floor = math.floor
local random_greetings = {
'Dear defender',
@ -113,11 +114,14 @@ end
local function pause_waves_state(state)
if state then
local message = ({'wave_defense.pause_waves'})
Alert.alert_all_players(30, message, nil, 'achievement/tech-maniac', 0.75)
local pause_wave_in_ticks = Public.get('pause_wave_in_ticks')
Public.set('paused', true)
Public.set('last_pause', game.tick)
Public.set('paused_waves_for', game.tick + 18000)
Public.set('paused_waves_for', game.tick + pause_wave_in_ticks)
local pause_for = floor(pause_wave_in_ticks / 60 / 60)
local message = ({'wave_defense.pause_waves', pause_for})
Alert.alert_all_players(30, message, nil, 'achievement/tech-maniac', 0.75)
local next_wave = Public.get('next_wave')
Public.set('next_wave', next_wave + 18000)
@ -149,8 +153,9 @@ function Public.toggle_pause_wave_without_votes()
end
Public.set('pause_waves', {index = 0})
local pause_wave_in_ticks = Public.get('pause_wave_in_ticks')
pause_waves_state(true)
Task.set_timeout_in_ticks(18000, pause_waves_state_token, false) -- 5 minutes
Task.set_timeout_in_ticks(pause_wave_in_ticks, pause_waves_state_token, false) -- 5 minutes
end
Gui.on_click(

View File

@ -41,6 +41,7 @@ Public.group_size_modifier_raffle_size = #Public.group_size_modifier_raffle
function Public.reset_wave_defense()
this.boss_wave = false
this.boss_wave_warning = false
this.boost_spawner_sizes_wave_is_above = 1000
this.boost_units_when_wave_is_above = 200
this.boost_bosses_when_wave_is_above = 50
this.side_target_count = 0
@ -53,6 +54,7 @@ function Public.reset_wave_defense()
this.log_wave_to_discord = true
this.paused = false
this.pause_without_votes = true
this.pause_wave_in_ticks = 18000 -- 5 minutes
this.game_lost = false
this.get_random_close_spawner_attempts = 5
this.group_size = 2
@ -94,6 +96,7 @@ function Public.reset_wave_defense()
this.pause_waves = {
index = 0
}
this.enable_random_spawn_positions = false
this.enable_side_target = false
this.enable_threat_log = true
this.disable_threat_below_zero = false
@ -101,6 +104,8 @@ function Public.reset_wave_defense()
this.resolve_pathing = true
this.increase_damage_per_wave = false
this.increase_boss_health_per_wave = true
this.increase_average_unit_group_size = false
this.increase_max_active_unit_groups = false
this.increase_health_per_wave = false
this.fill_tiles_so_biter_can_path = true
this.modified_unit_health = {
@ -144,8 +149,8 @@ function Public.reset_wave_defense()
['artillery-turret'] = 0.25, -- not active as of now
['small-worm-turret'] = 0.8,
['medium-worm-turret'] = 0.6,
['big-worm-turret'] = 0.4,
['behemoth-worm-turret'] = 0.2
['big-worm-turret'] = 0.3,
['behemoth-worm-turret'] = 0.3
}
}
end
@ -252,6 +257,15 @@ function Public.enable_threat_log(boolean)
return this.enable_threat_log
end
--- This sets if random spawn positions should be enabled.
-- @param <boolean>
function Public.enable_random_spawn_positions(boolean)
if (boolean or boolean == false) then
this.enable_random_spawn_positions = boolean
end
return this.enable_random_spawn_positions
end
--- This sets if we should spawn the unit near collapse
-- That is, if collapse module is enabled
-- @param <boolean>
@ -280,6 +294,24 @@ function Public.increase_health_per_wave(boolean)
return this.increase_health_per_wave
end
--- This sets if the average unit group size should increase.
-- @param <boolean>
function Public.increase_average_unit_group_size(boolean)
if (boolean or boolean == false) then
this.increase_average_unit_group_size = boolean
end
return this.increase_average_unit_group_size
end
--- This sets if the max unit groups should increase.
-- @param <boolean>
function Public.increase_max_active_unit_groups(boolean)
if (boolean or boolean == false) then
this.increase_max_active_unit_groups = boolean
end
return this.increase_max_active_unit_groups
end
--- This sets if the bosses health should increase.
-- @param <boolean>
function Public.increase_boss_health_per_wave(boolean)
@ -346,6 +378,12 @@ function Public.set_tick_to_spawn_unit_groups(int)
this.tick_to_spawn_unit_groups = int or 200
end
--- Sets the pause length in ticks.
-- @param <int> in ticks
function Public.set_pause_wave_in_ticks(int)
this.pause_wave_in_ticks = int or 18000
end
--- Pauses the wave defense module
-- @param null
function Public.pause(boolean)

View File

@ -200,7 +200,7 @@ local functions = {
['vacant_toggle'] = function(event)
local vacant = is_loaded('modules.clear_vacant_players')
if not vacant then
log("Error: toggle related to clear_vacant_players was activated, but the module does not seem to be loaded.")
log('Error: toggle related to clear_vacant_players was activated, but the module does not seem to be loaded.')
return
end
@ -844,11 +844,11 @@ local function on_gui_switch_state_changed(event)
pirates_functions[event.element.name](event)
return
elseif is_loaded('utils.gui.poll') then
local is_spamming = SpamProtection.is_spamming(player, nil, 'Config Poll Elem')
if is_spamming then
return
end
if poll_function[event.element.name] then
local is_spamming = SpamProtection.is_spamming(player, nil, 'Config Poll Elem')
if is_spamming then
return
end
poll_function[event.element.name](event)
return
end

View File

@ -383,6 +383,22 @@ local kill_causes = {
end
return players
end,
['spider-vehicle'] = function(event)
local players = {}
local driver = event.cause.get_driver()
if driver then
if driver.player then
players[#players + 1] = driver.player
end
end
local passenger = event.cause.get_passenger()
if passenger then
if passenger.player then
players[#players + 1] = passenger.player
end
end
return players
end,
['locomotive'] = train_type_cause,
['cargo-wagon'] = train_type_cause,
['artillery-wagon'] = train_type_cause,

View File

@ -22,14 +22,14 @@ local function debug_text(str)
if not this.debug_text then
return
end
print(main_text .. str)
log(main_text .. str)
end
local function debug_spam(str)
if not this.debug_spam then
return
end
print(main_text .. str)
log(main_text .. str)
end
function Public.reset_spam_table()
@ -64,6 +64,10 @@ function Public.is_spamming(player, value_to_compare, text)
return false -- game is paused - shoo
end
if this.debug_spam then
log(serpent.block(debug.traceback()))
end
local tick = game.tick
local value = value_to_compare or this.default_tick
if this.prevent_spam[player.index] then
@ -105,6 +109,9 @@ Event.add(
defines.events.on_player_joined_game,
function(event)
local player = game.get_player(event.player_index)
if not player then
return
end
if not this.prevent_spam[player.index] then
this.prevent_spam[player.index] = game.tick