mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2024-12-26 22:56:43 +02:00
new module system and removal from _G
This commit is contained in:
parent
9db9d71c33
commit
eb299b4421
@ -5,6 +5,7 @@
|
||||
|
||||
local event = require 'utils.event'
|
||||
local session = require 'utils.session_data'
|
||||
local Server = require 'utils.server'
|
||||
|
||||
--[[
|
||||
local function create_admin_button(player)
|
||||
@ -73,7 +74,7 @@ local function on_player_ammo_inventory_changed(event)
|
||||
if nukes > 0 then
|
||||
player.surface.spill_item_stack(player.position, {name = "atomic-bomb", count = nukes}, false)
|
||||
player.print("You have not grown accustomed to this technology yet.", {r=0.22, g=0.99, b=0.99})
|
||||
server_commands.to_discord_bold(table.concat{'[Nuke] ' .. player.name .. ' tried to equip nukes but was not trusted.'})
|
||||
Server.to_discord_bold(table.concat{'[Nuke] ' .. player.name .. ' tried to equip nukes but was not trusted.'})
|
||||
player.character.health = 0
|
||||
end
|
||||
end
|
||||
@ -230,7 +231,7 @@ local function on_gui_opened(event)
|
||||
if corpse_owner.force.name ~= player.force.name then return end
|
||||
if player.name ~= corpse_owner.name then
|
||||
game.print(player.name .. " is looting " .. corpse_owner.name .. "´s body.", { r=0.85, g=0.85, b=0.85})
|
||||
server_commands.to_discord_bold(table.concat{'[Corpse] ' .. player.name .. " is looting " .. corpse_owner.name .. "´s body."})
|
||||
Server.to_discord_bold(table.concat{'[Corpse] ' .. player.name .. " is looting " .. corpse_owner.name .. "´s body."})
|
||||
end
|
||||
end
|
||||
|
||||
@ -242,7 +243,7 @@ local function on_pre_player_mined_item(event)
|
||||
if corpse_owner.force.name ~= player.force.name then return end
|
||||
if player.name ~= corpse_owner.name then
|
||||
game.print(player.name .. " has looted " .. corpse_owner.name .. "´s body.", { r=0.85, g=0.85, b=0.85})
|
||||
server_commands.to_discord_bold(table.concat{'[Corpse] ' .. player.name .. " has looted " .. corpse_owner.name .. "´s body."})
|
||||
Server.to_discord_bold(table.concat{'[Corpse] ' .. player.name .. " has looted " .. corpse_owner.name .. "´s body."})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
--antigrief things made by mewmew
|
||||
|
||||
local event = require 'utils.event'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
|
||||
local function admin_only_message(str)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
@ -169,7 +170,7 @@ local function create_mini_camera_gui(player, caption, position)
|
||||
camera.style.minimal_height = 480
|
||||
end
|
||||
|
||||
local function create_admin_panel(player, frame)
|
||||
local create_admin_panel = (function (player, frame)
|
||||
frame.clear()
|
||||
|
||||
local player_names = {}
|
||||
@ -272,7 +273,7 @@ local function create_admin_panel(player, frame)
|
||||
scroll_pane.add({type = "label", caption = history_index[history][i], tooltip = "Click to open mini camera."})
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
local admin_functions = {
|
||||
["jail"] = jail,
|
||||
@ -328,7 +329,7 @@ end
|
||||
|
||||
local function on_gui_click(event)
|
||||
local player = game.players[event.player_index]
|
||||
local frame = comfy_panel_get_active_frame(player)
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
if not frame then return end
|
||||
if frame.name ~= "Admin" then return end
|
||||
|
||||
@ -381,7 +382,7 @@ local function on_gui_selection_state_changed(event)
|
||||
if not global.admin_panel_selected_history_index then global.admin_panel_selected_history_index = {} end
|
||||
global.admin_panel_selected_history_index[player.name] = event.element.selected_index
|
||||
|
||||
local frame = comfy_panel_get_active_frame(player)
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
if not frame then return end
|
||||
if frame.name ~= "Admin" then return end
|
||||
|
||||
@ -391,5 +392,7 @@ end
|
||||
|
||||
comfy_panel_tabs["Admin"] = create_admin_panel
|
||||
|
||||
|
||||
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
||||
event.add(defines.events.on_gui_selection_state_changed, on_gui_selection_state_changed)
|
@ -1,6 +1,8 @@
|
||||
-- this script adds a group button to create groups for your players --
|
||||
|
||||
local function build_group_gui(player, frame)
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
|
||||
local build_group_gui = (function (player, frame)
|
||||
local group_name_width = 150
|
||||
local description_width = 240
|
||||
local members_width = 90
|
||||
@ -99,13 +101,13 @@ local function build_group_gui(player, frame)
|
||||
b.style.minimal_width = 150
|
||||
b.style.font = "default-bold"
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
||||
local function refresh_gui()
|
||||
for _, p in pairs(game.connected_players) do
|
||||
local frame = comfy_panel_get_active_frame(p)
|
||||
local frame = Tabs.comfy_panel_get_active_frame(p)
|
||||
if frame then
|
||||
if frame.name == "Groups" then
|
||||
local new_group_name = frame.frame2.group_table.new_group_name.text
|
||||
@ -113,7 +115,7 @@ local function refresh_gui()
|
||||
|
||||
build_group_gui(p, frame)
|
||||
|
||||
local frame = comfy_panel_get_active_frame(p)
|
||||
local frame = Tabs.comfy_panel_get_active_frame(p)
|
||||
frame.frame2.group_table.new_group_name.text = new_group_name
|
||||
frame.frame2.group_table.new_group_description.text = new_group_description
|
||||
end
|
||||
@ -137,7 +139,7 @@ local function on_gui_click(event)
|
||||
|
||||
local player = game.players[event.element.player_index]
|
||||
local name = event.element.name
|
||||
local frame = comfy_panel_get_active_frame(player)
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
if not frame then return end
|
||||
if frame.name ~= "Groups" then return end
|
||||
|
||||
@ -214,6 +216,7 @@ end
|
||||
|
||||
comfy_panel_tabs["Groups"] = build_group_gui
|
||||
|
||||
local event = require 'utils.event'
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
@ -4,26 +4,37 @@ Comfy Panel
|
||||
To add a tab, insert into the "comfy_panel_tabs" table.
|
||||
|
||||
Example: comfy_panel_tabs["mapscores"] = draw_map_scores
|
||||
|
||||
draw_map_scores would be a function with the player and the frame as arguments
|
||||
|
||||
]]
|
||||
|
||||
local event = require 'utils.event'
|
||||
|
||||
comfy_panel_tabs = {}
|
||||
|
||||
function comfy_panel_clear_left_gui(player)
|
||||
|
||||
local Public = {}
|
||||
|
||||
function Public.get_tabs(data)
|
||||
return comfy_panel_tabs
|
||||
end
|
||||
|
||||
|
||||
function Public.comfy_panel_clear_left_gui(player)
|
||||
for _, child in pairs(player.gui.left.children) do
|
||||
child.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
function comfy_panel_get_active_frame(player)
|
||||
function Public.comfy_panel_get_active_frame(player)
|
||||
if not player.gui.left.comfy_panel then return false end
|
||||
if not player.gui.left.comfy_panel.tabbed_pane.selected_tab_index then return player.gui.left.comfy_panel.tabbed_pane.tabs[1].content end
|
||||
return player.gui.left.comfy_panel.tabbed_pane.tabs[player.gui.left.comfy_panel.tabbed_pane.selected_tab_index].content
|
||||
end
|
||||
|
||||
function comfy_panel_refresh_active_tab(player)
|
||||
local frame = comfy_panel_get_active_frame(player)
|
||||
function Public.comfy_panel_refresh_active_tab(player)
|
||||
local frame = Public.comfy_panel_get_active_frame(player)
|
||||
if not frame then return end
|
||||
comfy_panel_tabs[frame.name](player, frame)
|
||||
end
|
||||
@ -33,18 +44,19 @@ local function top_button(player)
|
||||
local button = player.gui.top.add({type = "sprite-button", name = "comfy_panel_top_button", sprite = "item/raw-fish"})
|
||||
button.style.minimal_height = 38
|
||||
button.style.minimal_width = 38
|
||||
button.style.padding = -2
|
||||
button.style.padding = -2
|
||||
end
|
||||
|
||||
local function main_frame(player)
|
||||
comfy_panel_clear_left_gui(player)
|
||||
|
||||
local tabs = comfy_panel_tabs
|
||||
Public.comfy_panel_clear_left_gui(player)
|
||||
|
||||
local frame = player.gui.left.add({type = "frame", name = "comfy_panel"})
|
||||
frame.style.margin = 6
|
||||
|
||||
|
||||
local tabbed_pane = frame.add({type = "tabbed-pane", name = "tabbed_pane"})
|
||||
|
||||
for name, func in pairs(comfy_panel_tabs) do
|
||||
|
||||
for name, func in pairs(tabs) do
|
||||
if name == "Admin" then
|
||||
if player.admin then
|
||||
local tab = tabbed_pane.add({type = "tab", caption = name})
|
||||
@ -65,29 +77,29 @@ local function main_frame(player)
|
||||
tabbed_pane.add_tab(tab, frame)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local tab = tabbed_pane.add({type = "tab", name = "comfy_panel_close", caption = "X"})
|
||||
tab.style.maximal_width = 32
|
||||
local frame = tabbed_pane.add({type = "frame", name = name, direction = "vertical"})
|
||||
tabbed_pane.add_tab(tab, frame)
|
||||
|
||||
|
||||
for _, child in pairs(tabbed_pane.children) do
|
||||
child.style.padding = 8
|
||||
child.style.left_padding = 2
|
||||
child.style.right_padding = 2
|
||||
end
|
||||
|
||||
comfy_panel_refresh_active_tab(player)
|
||||
|
||||
Public.comfy_panel_refresh_active_tab(player)
|
||||
end
|
||||
|
||||
function comfy_panel_call_tab(player, name)
|
||||
function Public.comfy_panel_call_tab(player, name)
|
||||
main_frame(player)
|
||||
local tabbed_pane = player.gui.left.comfy_panel.tabbed_pane
|
||||
for key, v in pairs(tabbed_pane.tabs) do
|
||||
if v.tab.caption == name then
|
||||
tabbed_pane.selected_tab_index = key
|
||||
comfy_panel_refresh_active_tab(player)
|
||||
end
|
||||
Public.comfy_panel_refresh_active_tab(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -99,7 +111,7 @@ local function on_gui_click(event)
|
||||
if not event.element then return end
|
||||
if not event.element.valid then return end
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
|
||||
if event.element.name == "comfy_panel_top_button" then
|
||||
if player.gui.left.comfy_panel then
|
||||
player.gui.left.comfy_panel.destroy()
|
||||
@ -107,19 +119,20 @@ local function on_gui_click(event)
|
||||
else
|
||||
main_frame(player)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if event.element.caption == "X" and event.element.name == "comfy_panel_close" then
|
||||
player.gui.left.comfy_panel.destroy()
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if not event.element.caption then return end
|
||||
if event.element.type ~= "tab" then return end
|
||||
comfy_panel_refresh_active_tab(player)
|
||||
Public.comfy_panel_refresh_active_tab(player)
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
||||
|
||||
return Public
|
@ -15,6 +15,7 @@ Minor changes by ~~~Gerkiz~~~
|
||||
|
||||
local event = require 'utils.event'
|
||||
local play_time = require 'utils.session_data'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
|
||||
local symbol_asc = "▲"
|
||||
local symbol_desc = "▼"
|
||||
@ -167,7 +168,7 @@ local function get_sorted_list(sort_by)
|
||||
return player_list
|
||||
end
|
||||
|
||||
local column_widths = {40, 250, 250, 150, 100}
|
||||
|
||||
|
||||
local function player_list_show(player, frame, sort_by)
|
||||
-- Frame management
|
||||
@ -176,6 +177,7 @@ local function player_list_show(player, frame, sort_by)
|
||||
|
||||
-- Header management
|
||||
local t = frame.add { type = "table", name = "player_list_panel_header_table", column_count = 5 }
|
||||
local column_widths = {tonumber(40), tonumber(250), tonumber(250), tonumber(150), tonumber(100)}
|
||||
for _, w in ipairs(column_widths) do
|
||||
local label = t.add { type = "label", caption = "" }
|
||||
label.style.minimal_width = w
|
||||
@ -293,7 +295,7 @@ local function on_gui_click(event)
|
||||
if not event.element.name then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
|
||||
local frame = comfy_panel_get_active_frame(player)
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
if not frame then return end
|
||||
if frame.name ~= "Players" then return end
|
||||
|
||||
@ -367,21 +369,21 @@ local function on_player_joined_game(event)
|
||||
global.player_list.last_poke_tick[event.player_index] = 0
|
||||
end
|
||||
|
||||
local frame = comfy_panel_get_active_frame(player)
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
if not frame then return end
|
||||
if frame.name ~= "Players" then return end
|
||||
|
||||
player_list_show(player, frame, "total_time_played_desc")
|
||||
end
|
||||
|
||||
comfy_panel_tabs["Players"] = player_list_show
|
||||
|
||||
local function on_init()
|
||||
local on_init = function()
|
||||
global.player_list = {}
|
||||
global.player_list.last_poke_tick = {}
|
||||
global.player_list.pokes = {}
|
||||
end
|
||||
|
||||
comfy_panel_tabs["Players"] = player_list_show
|
||||
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
@ -1,8 +1,10 @@
|
||||
local Gui = require 'utils.gui'
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
local Game = require 'utils.game'
|
||||
local session = require 'utils.session_data'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
|
||||
local insert = table.insert
|
||||
|
||||
@ -148,7 +150,7 @@ local function send_poll_result_to_discord(poll)
|
||||
end
|
||||
|
||||
local message = table.concat(result)
|
||||
server_commands.to_discord_embed(message)
|
||||
Server.to_discord_embed(message)
|
||||
end
|
||||
|
||||
local function redraw_poll_viewer_content(data)
|
||||
@ -425,7 +427,7 @@ local function toggle(event)
|
||||
if main_frame then
|
||||
remove_main_frame(main_frame, left, event.player)
|
||||
else
|
||||
comfy_panel_call_tab(p, "Polls")
|
||||
Tabs.comfy_panel_call_tab(p, "Polls")
|
||||
end
|
||||
end
|
||||
|
||||
@ -637,7 +639,7 @@ local function show_new_poll(poll_data)
|
||||
if block_notify[p.index] then
|
||||
p.print(message)
|
||||
else
|
||||
local frame = comfy_panel_call_tab(p, "Polls")
|
||||
local frame = Tabs.comfy_panel_call_tab(p, "Polls")
|
||||
p.print(message)
|
||||
if frame and frame.valid then
|
||||
local data = Gui.get_data(frame)
|
||||
@ -645,7 +647,7 @@ local function show_new_poll(poll_data)
|
||||
update_poll_viewer(data)
|
||||
else
|
||||
player_poll_index[p.index] = nil
|
||||
comfy_panel_call_tab(p, "Polls")
|
||||
Tabs.comfy_panel_call_tab(p, "Polls")
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -801,16 +803,20 @@ end
|
||||
local function tick()
|
||||
for _, p in pairs(game.connected_players) do
|
||||
if p.gui.left.comfy_panel ~= nil then
|
||||
local frame = p.gui.left.comfy_panel.tabbed_pane.Polls[main_frame_name]
|
||||
if frame and frame.valid then
|
||||
local data = Gui.get_data(frame)
|
||||
local poll = polls[data.poll_index]
|
||||
if poll then
|
||||
local poll_enabled = do_remaining_time(poll, data.remaining_time_label)
|
||||
if p.gui.left.comfy_panel.tabbed_pane ~= nil then
|
||||
if p.gui.left.comfy_panel.tabbed_pane.Polls ~= nil then
|
||||
local frame = p.gui.left.comfy_panel.tabbed_pane.Polls[main_frame_name]
|
||||
if frame and frame.valid then
|
||||
local data = Gui.get_data(frame)
|
||||
local poll = polls[data.poll_index]
|
||||
if poll then
|
||||
local poll_enabled = do_remaining_time(poll, data.remaining_time_label)
|
||||
|
||||
if not poll_enabled then
|
||||
for _, v in pairs(data.vote_buttons) do
|
||||
v.enabled = poll_enabled
|
||||
if not poll_enabled then
|
||||
for _, v in pairs(data.vote_buttons) do
|
||||
v.enabled = poll_enabled
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1094,7 +1100,7 @@ Gui.on_click(
|
||||
main_frame_data.poll_index = poll_index
|
||||
update_poll_viewer(main_frame_data)
|
||||
else
|
||||
comfy_panel_call_tab(p, "Polls")
|
||||
Tabs.comfy_panel_call_tab(p, "Polls")
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1276,7 +1282,7 @@ end
|
||||
|
||||
function Class.send_poll_result_to_discord(id)
|
||||
if type(id) ~= 'number' then
|
||||
server_commands.to_discord_embed('poll-id must be a number')
|
||||
Server.to_discord_embed('poll-id must be a number')
|
||||
return
|
||||
end
|
||||
|
||||
@ -1288,7 +1294,7 @@ function Class.send_poll_result_to_discord(id)
|
||||
end
|
||||
|
||||
local message = table.concat {'poll #', id, ' not found'}
|
||||
server_commands.to_discord_embed(message)
|
||||
Server.to_discord_embed(message)
|
||||
end
|
||||
|
||||
comfy_panel_tabs["Polls"] = draw_main_frame
|
||||
|
@ -1,6 +1,8 @@
|
||||
--scoreboard by mewmew
|
||||
|
||||
local event = require 'utils.event'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
|
||||
local sorting_symbol = {ascending = "▲", descending = "▼"}
|
||||
local building_and_mining_blacklist = {
|
||||
["tile-ghost"] = true,
|
||||
@ -74,7 +76,7 @@ local function add_global_stats(frame, player)
|
||||
l.style.font_color = { r=0.8, g=0.8, b=0.8}
|
||||
end
|
||||
|
||||
local function show_score(player, frame)
|
||||
local show_score = (function (player, frame)
|
||||
frame.clear()
|
||||
|
||||
-- Global stats : rockets, biters kills
|
||||
@ -162,10 +164,11 @@ local function show_score(player, frame)
|
||||
end -- foreach column
|
||||
end -- foreach entry
|
||||
end -- show_score
|
||||
)
|
||||
|
||||
local function refresh_score_full()
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local frame = comfy_panel_get_active_frame(player)
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
if frame then
|
||||
if frame.name == "Scoreboard" then
|
||||
show_score(player, frame)
|
||||
@ -184,7 +187,7 @@ local function init_player_table(player)
|
||||
deaths = 0,
|
||||
killscore = 0,
|
||||
mined_entities = 0,
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@ -206,7 +209,7 @@ local function on_gui_click(event)
|
||||
if not event.element.valid then return end
|
||||
|
||||
local player = game.players[event.element.player_index]
|
||||
local frame = comfy_panel_get_active_frame(player)
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
if not frame then return end
|
||||
if frame.name ~= "Scoreboard" then return end
|
||||
|
||||
|
@ -208,8 +208,8 @@ commands.add_command(
|
||||
for k, v in pairs(item) do
|
||||
i = i + 1
|
||||
if k and v.type ~= "mining-tool" then
|
||||
game.player.character_inventory_slots_bonus = tonumber(i)
|
||||
game.player.insert{name=k, count=v.stack_size}
|
||||
player.force.character_inventory_slots_bonus = tonumber(i)
|
||||
player.insert{name=k, count=v.stack_size}
|
||||
end
|
||||
end
|
||||
end)
|
@ -1,3 +1,5 @@
|
||||
local Public = {}
|
||||
|
||||
local market = {}
|
||||
|
||||
market.weapons = {
|
||||
@ -212,7 +214,7 @@ local function get_random_market_item_list(rarity)
|
||||
return false
|
||||
end
|
||||
|
||||
function mountain_market(surface, position, rarity)
|
||||
function Public.mountain_market(surface, position, rarity)
|
||||
local types = get_types()
|
||||
table.shuffle_table(types)
|
||||
local items = get_market_item_list({types[1], types[2], types[3]}, rarity)
|
||||
@ -237,7 +239,7 @@ function mountain_market(surface, position, rarity)
|
||||
return market
|
||||
end
|
||||
|
||||
function super_market(surface, position, rarity)
|
||||
function Public.super_market(surface, position, rarity)
|
||||
local items = get_market_item_list(get_types(), rarity)
|
||||
if not items then return end
|
||||
if #items > 0 then table.shuffle_table(items) end
|
||||
@ -262,3 +264,5 @@ function super_market(surface, position, rarity)
|
||||
|
||||
return market
|
||||
end
|
||||
|
||||
return Public
|
@ -1,3 +1,7 @@
|
||||
local Server = require 'utils.server'
|
||||
|
||||
local Public = {}
|
||||
|
||||
local function reset_forces(new_surface, old_surface)
|
||||
for _, f in pairs(game.forces) do
|
||||
local spawn = {x = game.forces.player.get_spawn_position(old_surface).x, y = game.forces.player.get_spawn_position(old_surface).y}
|
||||
@ -33,7 +37,7 @@ local function equip_players(player_starting_items)
|
||||
end
|
||||
end
|
||||
|
||||
function soft_reset_map(old_surface, map_gen_settings, player_starting_items)
|
||||
function Public.soft_reset_map(old_surface, map_gen_settings, player_starting_items)
|
||||
if not global.soft_reset_counter then global.soft_reset_counter = 0 end
|
||||
if not global.original_surface_name then global.original_surface_name = old_surface.name end
|
||||
global.soft_reset_counter = global.soft_reset_counter + 1
|
||||
@ -53,7 +57,9 @@ function soft_reset_map(old_surface, map_gen_settings, player_starting_items)
|
||||
message = table.concat({">> The world has been reshaped, welcome to ", global.original_surface_name, " number ", tostring(global.soft_reset_counter), "!"})
|
||||
end
|
||||
game.print(message, {r=0.98, g=0.66, b=0.22})
|
||||
server_commands.to_discord_embed(message)
|
||||
Server.to_discord_embed(message)
|
||||
|
||||
return new_surface
|
||||
end
|
||||
end
|
||||
|
||||
return Public
|
@ -1,5 +1,6 @@
|
||||
-- Biter Battles -- mewmew made this --
|
||||
|
||||
local Server = require 'utils.server'
|
||||
require "on_tick_schedule"
|
||||
require "modules.splice_double"
|
||||
require "modules.explosive_biters"
|
||||
@ -150,7 +151,7 @@ local function show_mvps(player)
|
||||
insert(result, 'MVP Deaths: \\n')
|
||||
insert(result, mvp.deaths.name .. " died " .. mvp.deaths.score .. " times" )
|
||||
local message = table.concat(result)
|
||||
server_commands.to_discord_embed(message)
|
||||
Server.to_discord_embed(message)
|
||||
global.results_sent_north = true
|
||||
end
|
||||
end
|
||||
@ -195,7 +196,7 @@ local function show_mvps(player)
|
||||
insert(result, 'MVP Deaths: \\n')
|
||||
insert(result, mvp.deaths.name .. " died " .. mvp.deaths.score .. " times" )
|
||||
local message = table.concat(result)
|
||||
server_commands.to_discord_embed(message)
|
||||
Server.to_discord_embed(message)
|
||||
global.results_sent_south = true
|
||||
end
|
||||
end
|
||||
@ -1193,8 +1194,8 @@ local function on_tick(event)
|
||||
global.game_restart_timer_completed = true
|
||||
game.print("Map is restarting!", { r=0.22, g=0.88, b=0.22})
|
||||
local message = 'Map is restarting! '
|
||||
server_commands.to_discord_bold(table.concat{'*** ', message, ' ***'})
|
||||
server_commands.start_scenario('Biter_Battles')
|
||||
Server.to_discord_bold(table.concat{'*** ', message, ' ***'})
|
||||
Server.start_scenario('Biter_Battles')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
local event = require 'utils.event'
|
||||
local event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
|
||||
local difficulties = {
|
||||
[1] = {name = "Peaceful", str = "25%", value = 0.25, color = {r=0.00, g=0.45, b=0.00}, print_color = {r=0.00, g=0.9, b=0.00}},
|
||||
@ -70,7 +71,7 @@ local function set_difficulty()
|
||||
if global.difficulty_vote_index ~= new_index then
|
||||
local message = table.concat({">> Map difficulty has changed to ", difficulties[new_index].name, " difficulty!"})
|
||||
game.print(message, difficulties[new_index].print_color)
|
||||
server_commands.to_discord_embed(message)
|
||||
Server.to_discord_embed(message)
|
||||
end
|
||||
global.difficulty_vote_index = new_index
|
||||
global.difficulty_vote_value = difficulties[new_index].value
|
||||
|
@ -1,4 +1,5 @@
|
||||
local event = require 'utils.event'
|
||||
local event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
|
||||
local gui_values = {
|
||||
["north"] = {c1 = "Team North", color1 = {r = 0.55, g = 0.55, b = 0.99}},
|
||||
@ -235,7 +236,7 @@ local function show_mvps(player)
|
||||
table.insert(result, 'MVP Deaths: \\n')
|
||||
table.insert(result, mvp.deaths.name .. " died " .. mvp.deaths.score .. " times" )
|
||||
local message = table.concat(result)
|
||||
server_commands.to_discord_embed(message)
|
||||
Server.to_discord_embed(message)
|
||||
global.results_sent_north = true
|
||||
end
|
||||
end
|
||||
@ -280,7 +281,7 @@ local function show_mvps(player)
|
||||
table.insert(result, 'MVP Deaths: \\n')
|
||||
table.insert(result, mvp.deaths.name .. " died " .. mvp.deaths.score .. " times" )
|
||||
local message = table.concat(result)
|
||||
server_commands.to_discord_embed(message)
|
||||
Server.to_discord_embed(message)
|
||||
global.results_sent_south = true
|
||||
end
|
||||
end
|
||||
@ -298,8 +299,8 @@ local function server_restart()
|
||||
if global.server_restart_timer == 0 then
|
||||
game.print("Map is restarting!", {r=0.22, g=0.88, b=0.22})
|
||||
local message = 'Map is restarting! '
|
||||
server_commands.to_discord_bold(table.concat{'*** ', message, ' ***'})
|
||||
server_commands.start_scenario('Biter_Battles')
|
||||
Server.to_discord_bold(table.concat{'*** ', message, ' ***'})
|
||||
Server.start_scenario('Biter_Battles')
|
||||
global.server_restart_timer = nil
|
||||
return
|
||||
end
|
||||
@ -346,8 +347,8 @@ local function on_entity_died(event)
|
||||
local c = gui_values[global.bb_game_won_by_team].c1
|
||||
if global.tm_custom_name[global.bb_game_won_by_team] then c = global.tm_custom_name[global.bb_game_won_by_team] end
|
||||
|
||||
server_commands.to_discord_embed(c .. " has won!")
|
||||
server_commands.to_discord_embed(global.victory_time)
|
||||
Server.to_discord_embed(c .. " has won!")
|
||||
Server.to_discord_embed(global.victory_time)
|
||||
|
||||
fireworks(event.entity.surface)
|
||||
annihilate_base_v2(event.entity.position, event.entity.surface, event.entity.force.name)
|
||||
|
@ -1,4 +1,5 @@
|
||||
local event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
|
||||
local gui = require "maps.biter_battles_v2.gui"
|
||||
local ai = require "maps.biter_battles_v2.ai"
|
||||
@ -44,7 +45,7 @@ local function restart_idle_map()
|
||||
if not global.restart_idle_map_countdown then global.restart_idle_map_countdown = 2 end
|
||||
global.restart_idle_map_countdown = global.restart_idle_map_countdown - 1
|
||||
if global.restart_idle_map_countdown ~= 0 then return end
|
||||
server_commands.start_scenario('Biter_Battles')
|
||||
Server.start_scenario('Biter_Battles')
|
||||
end
|
||||
|
||||
local function on_tick(event)
|
||||
|
@ -1,4 +1,5 @@
|
||||
local event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
local math_random = math.random
|
||||
local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
local create_tile_chain = require "functions.create_tile_chain"
|
||||
@ -516,7 +517,7 @@ end
|
||||
local function on_init(surface)
|
||||
local surface = game.surfaces["biter_battles"]
|
||||
if bb_config.on_init_pregen then
|
||||
server_commands.to_discord_embed("Generating chunks...")
|
||||
Server.to_discord_embed("Generating chunks...")
|
||||
print("Generating chunks...")
|
||||
surface.request_to_generate_chunks({x = 0, y = -512}, 16)
|
||||
surface.request_to_generate_chunks({x = 1024, y = -512}, 16)
|
||||
|
@ -7,8 +7,8 @@ require "modules.dynamic_player_spawn"
|
||||
require "modules.no_deconstruction_of_neutral_entities"
|
||||
require "modules.biter_pets"
|
||||
require "modules.biter_evasion_hp_increaser"
|
||||
require "modules.wave_defense.main"
|
||||
|
||||
local WD = require "modules.wave_defense.main"
|
||||
local event = require 'utils.event'
|
||||
local math_random = math.random
|
||||
local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
@ -144,6 +144,7 @@ local function on_chunk_generated(event)
|
||||
end
|
||||
|
||||
local function init_surface()
|
||||
local wave_defense_table = WD.get_table()
|
||||
if game.surfaces["blue_beach"] then return game.surfaces["blue_beach"] end
|
||||
|
||||
local map_gen_settings = {}
|
||||
@ -181,18 +182,19 @@ local function init_surface()
|
||||
|
||||
global.average_worm_amount_per_chunk = 4
|
||||
|
||||
global.wave_defense.surface_index = surface.index
|
||||
wave_defense_table.surface_index = surface.index
|
||||
|
||||
return surface
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local wave_defense_table = WD.get_table()
|
||||
local surface = init_surface()
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
--20 Players for maximum difficulty
|
||||
global.wave_defense.wave_interval = 3600 - #game.connected_players * 180
|
||||
if global.wave_defense.wave_interval < 1800 then global.wave_defense.wave_interval = 1800 end
|
||||
wave_defense_table.wave_interval = 3600 - #game.connected_players * 180
|
||||
if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end
|
||||
|
||||
if player.online_time == 0 then
|
||||
local spawn = game.forces["player"].get_spawn_position(game.surfaces["blue_beach"])
|
||||
|
@ -4,28 +4,7 @@ require "on_tick_schedule"
|
||||
require "modules.dynamic_landfill"
|
||||
require "modules.satellite_score"
|
||||
require "modules.spawners_contain_biters"
|
||||
require "modules.map_info"
|
||||
map_info = {}
|
||||
map_info.main_caption = "Choppy"
|
||||
map_info.sub_caption = ""
|
||||
map_info.text = [[
|
||||
You are a lumberjack with a passion to chop.
|
||||
|
||||
Different kinds of trees, yield different kinds of ore and wood.
|
||||
Yes, they seem to draw minerals out of the ground and manifesting it as "fruit".
|
||||
Their yield increases with distance. Mining Productivity Research will increase chopping speed and backpack size.
|
||||
|
||||
Beware, sometimes there are some bugs hiding underneath the trees.
|
||||
Even dangerous traps have been encountered before.
|
||||
|
||||
Also, these mysterious ore trees don't burn very well, so do not worry if some of them catch on fire.
|
||||
|
||||
Choppy Choppy Wood
|
||||
]]
|
||||
|
||||
map_info.main_caption_color = {r = 0, g = 120, b = 0}
|
||||
map_info.sub_caption_color = {r = 255, g = 0, b = 255}
|
||||
|
||||
local Map = require "modules.map_info"
|
||||
local unearthing_worm = require "functions.unearthing_worm"
|
||||
local unearthing_biters = require "functions.unearthing_biters"
|
||||
local tick_tack_trap = require "functions.tick_tack_trap"
|
||||
@ -351,7 +330,31 @@ local function on_entity_died(event)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local on_init = function()
|
||||
local T = Map.Pop_info()
|
||||
T.main_caption = "Choppy"
|
||||
T.sub_caption = ""
|
||||
T.text = [[
|
||||
You are a lumberjack with a passion to chop.
|
||||
|
||||
Different kinds of trees, yield different kinds of ore and wood.
|
||||
Yes, they seem to draw minerals out of the ground and manifesting it as "fruit".
|
||||
Their yield increases with distance. Mining Productivity Research will increase chopping speed and backpack size.
|
||||
|
||||
Beware, sometimes there are some bugs hiding underneath the trees.
|
||||
Even dangerous traps have been encountered before.
|
||||
|
||||
Also, these mysterious ore trees don't burn very well, so do not worry if some of them catch on fire.
|
||||
|
||||
Choppy Choppy Wood
|
||||
]]
|
||||
|
||||
T.main_caption_color = {r = 0, g = 120, b = 0}
|
||||
T.sub_caption_color = {r = 255, g = 0, b = 255}
|
||||
end
|
||||
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_research_finished, on_research_finished)
|
||||
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
|
@ -17,6 +17,7 @@ require "modules.rocks_yield_ore"
|
||||
require "modules.rpg"
|
||||
|
||||
local event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
local boss_biter = require "maps.fish_defender.boss_biters"
|
||||
require "functions.boss_unit"
|
||||
local math_random = math.random
|
||||
@ -743,7 +744,7 @@ local function is_game_lost()
|
||||
insert(result, 'MVP Deaths: \\n')
|
||||
insert(result, mvp.deaths.name .. " died " .. mvp.deaths.score .. " times" )
|
||||
local message = table.concat(result)
|
||||
server_commands.to_discord_embed(message)
|
||||
Server.to_discord_embed(message)
|
||||
global.results_sent = true
|
||||
end
|
||||
end
|
||||
@ -968,8 +969,8 @@ local function on_tick()
|
||||
--game.write_file("commandPipe", ":loadscenario --force", false, 0)
|
||||
|
||||
local message = 'Map is restarting! '
|
||||
server_commands.to_discord_bold(table.concat{'*** ', message, ' ***'})
|
||||
server_commands.start_scenario('Fish_Defender')
|
||||
Server.to_discord_bold(table.concat{'*** ', message, ' ***'})
|
||||
Server.start_scenario('Fish_Defender')
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -6,6 +6,7 @@ require 'maps.fish_defender.vehicle_nanobots'
|
||||
require 'maps.fish_defender.laser_pointer'
|
||||
|
||||
local event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
|
||||
local slot_upgrade_offers = {
|
||||
[1] = {"gun-turret", "gun turret"},
|
||||
@ -166,7 +167,7 @@ local function slot_upgrade(player, offer_index)
|
||||
|
||||
global.entity_limits[slot_upgrade_offers[offer_index][1]].limit = global.entity_limits[slot_upgrade_offers[offer_index][1]].limit + gain
|
||||
game.print(player.name .. " has bought a " .. slot_upgrade_offers[offer_index][2] .. " slot for " .. price .. " coins!", {r = 0.22, g = 0.77, b = 0.44})
|
||||
server_commands.to_discord_bold(table.concat{player.name .. " has bought a " .. slot_upgrade_offers[offer_index][2] .. " slot for " .. price .. " coins!"})
|
||||
Server.to_discord_bold(table.concat{player.name .. " has bought a " .. slot_upgrade_offers[offer_index][2] .. " slot for " .. price .. " coins!"})
|
||||
refresh_market_offers()
|
||||
end
|
||||
|
||||
|
@ -14,6 +14,7 @@ require "modules.custom_death_messages"
|
||||
require "modules.biter_evasion_hp_increaser"
|
||||
|
||||
local event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
local boss_biter = require "maps.fish_defender.boss_biters"
|
||||
require "functions.boss_unit"
|
||||
local map_functions = require "tools.map_functions"
|
||||
@ -840,7 +841,7 @@ local function is_game_lost()
|
||||
insert(result, 'MVP Deaths: \\n')
|
||||
insert(result, mvp.deaths.name .. " died " .. mvp.deaths.score .. " times" )
|
||||
local message = table.concat(result)
|
||||
server_commands.to_discord_embed(message)
|
||||
Server.to_discord_embed(message)
|
||||
global.results_sent = true
|
||||
end
|
||||
end
|
||||
@ -1371,8 +1372,8 @@ local function on_tick()
|
||||
--game.write_file("commandPipe", ":loadscenario --force", false, 0)
|
||||
|
||||
local message = 'Map is restarting! '
|
||||
server_commands.to_discord_bold(table.concat{'*** ', message, ' ***'})
|
||||
server_commands.start_scenario('Fish_Defender')
|
||||
Server.to_discord_bold(table.concat{'*** ', message, ' ***'})
|
||||
Server.start_scenario('Fish_Defender')
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -6,6 +6,7 @@ require 'maps.fish_defender.vehicle_nanobots'
|
||||
require 'maps.fish_defender.laser_pointer'
|
||||
|
||||
local event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
|
||||
local slot_upgrade_offers = {
|
||||
[1] = {"gun-turret", "gun turret"},
|
||||
@ -166,7 +167,7 @@ local function slot_upgrade(player, offer_index)
|
||||
|
||||
global.entity_limits[slot_upgrade_offers[offer_index][1]].limit = global.entity_limits[slot_upgrade_offers[offer_index][1]].limit + gain
|
||||
game.print(player.name .. " has bought a " .. slot_upgrade_offers[offer_index][2] .. " slot for " .. price .. " coins!", {r = 0.22, g = 0.77, b = 0.44})
|
||||
server_commands.to_discord_bold(table.concat{player.name .. " has bought a " .. slot_upgrade_offers[offer_index][2] .. " slot for " .. price .. " coins!"})
|
||||
Server.to_discord_bold(table.concat{player.name .. " has bought a " .. slot_upgrade_offers[offer_index][2] .. " slot for " .. price .. " coins!"})
|
||||
refresh_market_offers()
|
||||
end
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
function locomotive_spawn(surface, position)
|
||||
local Public = {}
|
||||
|
||||
function Public.locomotive_spawn(surface, position)
|
||||
for y = -6, 6, 2 do
|
||||
surface.create_entity({name = "straight-rail", position = {position.x, position.y + y}, force = "player", direction = 0})
|
||||
end
|
||||
@ -77,6 +79,7 @@ local function set_player_spawn_and_refill_fish()
|
||||
end
|
||||
|
||||
local function tick()
|
||||
local Reset = require "maps.mountain_fortress_v2.main".reset_map
|
||||
if game.tick % 30 == 0 then
|
||||
if game.tick % 1800 == 0 then
|
||||
set_player_spawn_and_refill_fish()
|
||||
@ -84,7 +87,7 @@ local function tick()
|
||||
if global.game_reset_tick then
|
||||
if global.game_reset_tick < game.tick then
|
||||
global.game_reset_tick = nil
|
||||
reset_map()
|
||||
Reset()
|
||||
end
|
||||
return
|
||||
end
|
||||
@ -97,4 +100,6 @@ local function tick()
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.on_nth_tick(5, tick)
|
||||
event.on_nth_tick(5, tick)
|
||||
|
||||
return Public
|
@ -6,7 +6,6 @@ require "functions.basic_markets"
|
||||
require "modules.wave_defense.main"
|
||||
require "modules.rpg"
|
||||
require "modules.biters_yield_coins"
|
||||
require "modules.biter_pets"
|
||||
require "modules.no_deconstruction_of_neutral_entities"
|
||||
require "modules.shotgun_buff"
|
||||
require "modules.explosives"
|
||||
@ -14,32 +13,21 @@ require "modules.rocks_broken_paint_tiles"
|
||||
require "modules.rocks_heal_over_time"
|
||||
require "modules.rocks_yield_ore_veins"
|
||||
require "modules.spawners_contain_biters"
|
||||
require "modules.map_info"
|
||||
map_info = {}
|
||||
map_info.main_caption = "M O U N T A I N F O R T R E S S"
|
||||
map_info.sub_caption = " ..diggy diggy choo choo.."
|
||||
map_info.text = table.concat({
|
||||
"The biters have catched the scent of fish in the cargo wagon.\n",
|
||||
"Guide the choo into the mountain and protect it as long as possible!\n",
|
||||
"This however will not be an easy task,\n",
|
||||
"since their strength and resistance increases constantly over time.\n",
|
||||
"\n",
|
||||
"Delve deep for greater treasures, but also face increased dangers.\n",
|
||||
"Mining productivity research, will overhaul your mining equipment,\n",
|
||||
"reinforcing your pickaxe as well as increasing the size of your backpack.\n",
|
||||
"\n",
|
||||
"As you dig, you will encounter impassable dark chasms or rivers.\n",
|
||||
"Some explosives may cause parts of the ceiling to crumble, filling the void, creating new ways.\n",
|
||||
"All they need is a container and a well aimed shot.\n",
|
||||
})
|
||||
map_info.main_caption_color = {r = 150, g = 150, b = 0}
|
||||
map_info.sub_caption_color = {r = 0, g = 150, b = 0}
|
||||
|
||||
require "maps.mountain_fortress_v2.market"
|
||||
require "maps.mountain_fortress_v2.treasure"
|
||||
require "modules.rpg"
|
||||
require "modules.wave_defense.main"
|
||||
require "maps.mountain_fortress_v2.terrain"
|
||||
require "maps.mountain_fortress_v2.locomotive"
|
||||
require "maps.mountain_fortress_v2.flamethrower_nerf"
|
||||
local BiterRolls = require "modules.wave_defense.biter_rolls"
|
||||
local Reset = require "functions.soft_reset"
|
||||
local Pets = require "modules.biter_pets"
|
||||
local Map = require "modules.map_info"
|
||||
local WD = require "modules.wave_defense.table"
|
||||
local Treasure = require "maps.mountain_fortress_v2.treasure"
|
||||
local Locomotive = require "maps.mountain_fortress_v2.locomotive".locomotive_spawn
|
||||
local Modifier = require "player_modifiers"
|
||||
|
||||
local Public = {}
|
||||
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16, ['wood'] = 16, ['explosives'] = 32}
|
||||
local treasure_chest_messages = {
|
||||
@ -48,7 +36,8 @@ local treasure_chest_messages = {
|
||||
"We has found the precious!",
|
||||
}
|
||||
|
||||
function reset_map()
|
||||
function Public.reset_map()
|
||||
local wave_defense_table = WD.get_table()
|
||||
global.chunk_queue = {}
|
||||
|
||||
local map_gen_settings = {
|
||||
@ -70,7 +59,7 @@ function reset_map()
|
||||
global.active_surface_index = game.create_surface("mountain_fortress", map_gen_settings).index
|
||||
else
|
||||
game.forces.player.set_spawn_position({-2, 16}, game.surfaces[global.active_surface_index])
|
||||
global.active_surface_index = soft_reset_map(game.surfaces[global.active_surface_index], map_gen_settings, starting_items).index
|
||||
global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], map_gen_settings, starting_items).index
|
||||
end
|
||||
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
@ -99,16 +88,16 @@ function reset_map()
|
||||
game.forces.player.technologies["railway"].researched = true
|
||||
game.forces.player.set_spawn_position({-2, 16}, surface)
|
||||
|
||||
locomotive_spawn(surface, {x = 0, y = 16})
|
||||
Locomotive(surface, {x = 0, y = 16})
|
||||
|
||||
reset_wave_defense()
|
||||
global.wave_defense.surface_index = global.active_surface_index
|
||||
global.wave_defense.target = global.locomotive_cargo
|
||||
global.wave_defense.side_target_search_radius = 512
|
||||
global.wave_defense.unit_group_command_step_length = 64
|
||||
global.wave_defense.nest_building_density = 48
|
||||
global.wave_defense.threat_gain_multiplier = 3
|
||||
global.wave_defense.game_lost = false
|
||||
WD.reset_wave_defense()
|
||||
wave_defense_table.surface_index = global.active_surface_index
|
||||
wave_defense_table.target = global.locomotive_cargo
|
||||
wave_defense_table.side_target_search_radius = 768
|
||||
wave_defense_table.unit_group_command_step_length = 32
|
||||
wave_defense_table.nest_building_density = 32
|
||||
wave_defense_table.threat_gain_multiplier = 3
|
||||
wave_defense_table.game_lost = false
|
||||
|
||||
--for _, p in pairs(game.connected_players) do
|
||||
-- if p.character then p.character.disable_flashlight() end
|
||||
@ -148,35 +137,35 @@ local function biters_chew_rocks_faster(event)
|
||||
if not event.cause then return end
|
||||
if not event.cause.valid then return end
|
||||
if event.cause.force.index ~= 2 then return end --Enemy Force
|
||||
--local bonus_damage = event.final_damage_amount * math.abs(global.wave_defense.threat) * 0.0002
|
||||
--local bonus_damage = event.final_damage_amount * math.abs(wave_defense_table.threat) * 0.0002
|
||||
event.entity.health = event.entity.health - event.final_damage_amount * 2.5
|
||||
end
|
||||
|
||||
local function hidden_biter(entity)
|
||||
wave_defense_set_unit_raffle(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.33)
|
||||
BiterRolls.wave_defense_set_unit_raffle(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.33)
|
||||
if math.random(1,3) == 1 then
|
||||
entity.surface.create_entity({name = wave_defense_roll_spitter_name(), position = entity.position})
|
||||
entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = entity.position})
|
||||
else
|
||||
entity.surface.create_entity({name = wave_defense_roll_biter_name(), position = entity.position})
|
||||
entity.surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = entity.position})
|
||||
end
|
||||
end
|
||||
|
||||
local function hidden_biter_pet(event)
|
||||
if math.random(1, 2048) ~= 1 then return end
|
||||
wave_defense_set_unit_raffle(math.sqrt(event.entity.position.x ^ 2 + event.entity.position.y ^ 2) * 0.33)
|
||||
BiterRolls.wave_defense_set_unit_raffle(math.sqrt(event.entity.position.x ^ 2 + event.entity.position.y ^ 2) * 0.33)
|
||||
local unit
|
||||
if math.random(1,3) == 1 then
|
||||
unit = event.entity.surface.create_entity({name = wave_defense_roll_spitter_name(), position = event.entity.position})
|
||||
unit = event.entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = event.entity.position})
|
||||
else
|
||||
unit = event.entity.surface.create_entity({name = wave_defense_roll_biter_name(), position = event.entity.position})
|
||||
end
|
||||
biter_pets_tame_unit(game.players[event.player_index], unit, true)
|
||||
unit = event.entity.surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = event.entity.position})
|
||||
end
|
||||
Pets.biter_pets_tame_unit(game.players[event.player_index], unit, true)
|
||||
end
|
||||
|
||||
local function hidden_treasure(event)
|
||||
if math.random(1, 320) ~= 1 then return end
|
||||
game.players[event.player_index].print(treasure_chest_messages[math.random(1, #treasure_chest_messages)], {r=0.98, g=0.66, b=0.22})
|
||||
treasure_chest(event.entity.surface, event.entity.position)
|
||||
Treasure(event.entity.surface, event.entity.position)
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
@ -186,17 +175,19 @@ local function on_player_mined_entity(event)
|
||||
if math.random(1,32) == 1 then
|
||||
hidden_biter(event.entity)
|
||||
return
|
||||
end
|
||||
end
|
||||
hidden_biter_pet(event)
|
||||
hidden_treasure(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local wave_defense_table = WD.get_table()
|
||||
if not event.entity.valid then return end
|
||||
if event.entity == global.locomotive_cargo then
|
||||
game.print("The cargo was destroyed!")
|
||||
global.wave_defense.game_lost = true
|
||||
wave_defense_table.game_lost = true
|
||||
wave_defense_table.target = nil
|
||||
global.game_reset_tick = game.tick + 1800
|
||||
for _, player in pairs(game.connected_players) do
|
||||
player.play_sound{path="utility/game_lost", volume_modifier=0.75}
|
||||
@ -205,7 +196,7 @@ local function on_entity_died(event)
|
||||
--rpg_reset_all_players()
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if event.cause then
|
||||
if event.cause.valid then
|
||||
if event.cause.force.index == 2 or event.cause.force.index == 3 then return end
|
||||
@ -235,9 +226,10 @@ local function on_research_finished(event)
|
||||
end
|
||||
|
||||
local function set_difficulty()
|
||||
local wave_defense_table = WD.get_table()
|
||||
--20 Players for maximum difficulty
|
||||
global.wave_defense.wave_interval = 3600 - #game.connected_players * 90
|
||||
if global.wave_defense.wave_interval < 1800 then global.wave_defense.wave_interval = 1800 end
|
||||
wave_defense_table.wave_interval = 3600 - #game.connected_players * 90
|
||||
if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
@ -266,7 +258,7 @@ local function on_player_joined_game(event)
|
||||
end
|
||||
|
||||
global.player_modifiers[player.index].character_mining_speed_modifier["mountain_fortress"] = 0.5
|
||||
update_player_modifiers(player)
|
||||
Modifier.update_player_modifiers(player)
|
||||
end
|
||||
--[[
|
||||
local function on_player_respawned(event)
|
||||
@ -275,7 +267,26 @@ local function on_player_respawned(event)
|
||||
end
|
||||
]]
|
||||
|
||||
local function on_init(surface)
|
||||
local function on_init()
|
||||
local T = Map.Pop_info()
|
||||
T.main_caption = "M O U N T A I N F O R T R E S S"
|
||||
T.sub_caption = " ..diggy diggy choo choo.."
|
||||
T.text = table.concat({
|
||||
"The biters have catched the scent of fish in the cargo wagon.\n",
|
||||
"Guide the choo into the mountain and protect it as long as possible!\n",
|
||||
"This however will not be an easy task,\n",
|
||||
"since their strength and resistance increases constantly over time.\n",
|
||||
"\n",
|
||||
"Delve deep for greater treasures, but also face increased dangers.\n",
|
||||
"Mining productivity research, will overhaul your mining equipment,\n",
|
||||
"reinforcing your pickaxe as well as increasing the size of your backpack.\n",
|
||||
"\n",
|
||||
"As you dig, you will encounter impassable dark chasms or rivers.\n",
|
||||
"Some explosives may cause parts of the ceiling to crumble, filling the void, creating new ways.\n",
|
||||
"All they need is a container and a well aimed shot.\n",
|
||||
})
|
||||
T.main_caption_color = {r = 150, g = 150, b = 0}
|
||||
T.sub_caption_color = {r = 0, g = 150, b = 0}
|
||||
global.rocks_yield_ore_maximum_amount = 999
|
||||
global.rocks_yield_ore_base_amount = 50
|
||||
global.rocks_yield_ore_distance_modifier = 0.025
|
||||
@ -289,7 +300,7 @@ local function on_init(surface)
|
||||
["water-shallow"] = 1000,
|
||||
}
|
||||
|
||||
reset_map()
|
||||
Public.reset_map()
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
@ -301,4 +312,6 @@ event.add(defines.events.on_research_finished, on_research_finished)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
--event.add(defines.events.on_player_respawned, on_player_respawned)
|
||||
|
||||
require "modules.rocks_yield_ore"
|
||||
require "modules.rocks_yield_ore"
|
||||
|
||||
return Public
|
@ -1,6 +1,9 @@
|
||||
local math_random = math.random
|
||||
|
||||
function secret_shop(pos, surface)
|
||||
local Public = {}
|
||||
|
||||
|
||||
function Public.secret_shop(pos, surface)
|
||||
if surface.count_entities_filtered{area={{pos.x - 128, pos.y - 128}, {pos.x + 128, pos.y + 128}}, name="market", limit=1} > 0 then return end
|
||||
local secret_market_items = {
|
||||
{price = {{"coin", math_random(8,16)}}, offer = {type = 'give-item', item = 'grenade'}},
|
||||
@ -48,4 +51,6 @@ function secret_shop(pos, surface)
|
||||
for i = 1, math_random(6, 8), 1 do
|
||||
market.add_market_item(secret_market_items[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Public.secret_shop
|
@ -1,3 +1,6 @@
|
||||
local Biters = require 'modules.wave_defense.biter_rolls'
|
||||
local Treasure = require 'maps.mountain_fortress_v2.treasure'
|
||||
local Market = require 'functions.basic_markets'
|
||||
local math_random = math.random
|
||||
local simplex_noise = require "utils.simplex_noise".d2
|
||||
local rock_raffle = {"sand-rock-big","sand-rock-big", "rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-huge"}
|
||||
@ -52,8 +55,8 @@ local function process_level_6_position(p, seed, tiles, entities, markets, treas
|
||||
if cave_rivers > -0.05 and cave_rivers < 0.05 then
|
||||
if math_random(1,48) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end
|
||||
if math_random(1,768) == 1 then
|
||||
wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
Biters.wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
else
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
@ -79,8 +82,8 @@ local function process_level_5_position(p, seed, tiles, entities, markets, treas
|
||||
tiles[#tiles + 1] = {name = "deepwater-green", position = p}
|
||||
if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
if math_random(1,128) == 1 then
|
||||
wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
Biters.wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
return
|
||||
end
|
||||
@ -121,8 +124,8 @@ local function process_level_4_position(p, seed, tiles, entities, markets, treas
|
||||
tiles[#tiles + 1] = {name = "grass-2", position = p}
|
||||
if math_random(1,620) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = math.abs(p.y) * 500} end
|
||||
if math_random(1,384) == 1 then
|
||||
wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
Biters.wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
if math_random(1, 1024) == 1 then treasure[#treasure + 1] = p end
|
||||
return
|
||||
@ -241,8 +244,8 @@ local function process_level_3_position(p, seed, tiles, entities, markets, treas
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math.floor(noise_cave_ponds * 32) % 7 + 1, position = p}
|
||||
if math_random(1,320) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = math.abs(p.y) * 500} end
|
||||
if math_random(1,50) == 1 then
|
||||
wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
Biters.wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
if math_random(1,512) == 1 then treasure[#treasure + 1] = p end
|
||||
if math_random(1,64) == 1 then entities[#entities + 1] = {name = "dead-tree-desert", position=p} end
|
||||
@ -324,8 +327,8 @@ local function process_level_2_position(p, seed, tiles, entities, markets, treas
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math.floor(noise_cave_ponds * 32) % 7 + 1, position = p}
|
||||
if math_random(1,450) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = math.abs(p.y) * 500} end
|
||||
if math_random(1,64) == 1 then
|
||||
wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
Biters.wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
if math_random(1,1024) == 1 then treasure[#treasure + 1] = p end
|
||||
if math_random(1,64) == 1 then entities[#entities + 1] = {name = "dead-tree-desert", position=p} end
|
||||
@ -407,8 +410,8 @@ local function process_level_1_position(p, seed, tiles, entities, markets, treas
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math.floor(noise_cave_ponds * 32) % 7 + 1, position = p}
|
||||
if math_random(1,450) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = math.abs(p.y) * 500} end
|
||||
if math_random(1,96) == 1 then
|
||||
wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
Biters.wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
|
||||
end
|
||||
if math_random(1,1024) == 1 then treasure[#treasure + 1] = p end
|
||||
if math_random(1,64) == 1 then entities[#entities + 1] = {name = "dead-tree-desert", position=p} end
|
||||
@ -459,12 +462,12 @@ local function rock_chunk(surface, left_top)
|
||||
if #markets > 0 then
|
||||
local position = markets[math_random(1, #markets)]
|
||||
if surface.count_entities_filtered{area = {{position.x - 96, position.y - 96}, {position.x + 96, position.y + 96}}, name = "market", limit = 1} == 0 then
|
||||
local market = mountain_market(surface, position, math.abs(position.y) * 0.004)
|
||||
local market = Market.mountain_market(surface, position, math.abs(position.y) * 0.004)
|
||||
market.destructible = false
|
||||
end
|
||||
end
|
||||
|
||||
for _, p in pairs(treasure) do treasure_chest(surface, p) end
|
||||
for _, p in pairs(treasure) do Treasure(surface, p) end
|
||||
|
||||
for _, e in pairs(entities) do
|
||||
if game.entity_prototypes[e.name].type == "simple-entity" or game.entity_prototypes[e.name].type == "turret" then
|
||||
@ -585,7 +588,7 @@ local function wall(surface, left_top, seed)
|
||||
|
||||
if surface.can_place_entity({name = "stone-wall", position = p, force = "enemy"}) then
|
||||
if math_random(1,512) == 1 and y > 3 and y < 28 then
|
||||
treasure_chest(surface, p)
|
||||
Treasure(surface, p)
|
||||
else
|
||||
|
||||
if y < 5 or y > 26 then
|
||||
@ -607,8 +610,8 @@ local function wall(surface, left_top, seed)
|
||||
|
||||
if math_random(1, 16) == 1 then
|
||||
if surface.can_place_entity({name = "small-worm-turret", position = p, force = "enemy"}) then
|
||||
wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
surface.create_entity({name = wave_defense_roll_worm_name(), position = p, force = "enemy"})
|
||||
Biters.wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
|
||||
surface.create_entity({name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
local math_random = math.random
|
||||
|
||||
function treasure_chest(surface, position)
|
||||
local Public = {}
|
||||
|
||||
function Public.treasure_chest(surface, position)
|
||||
|
||||
local chest_raffle = {}
|
||||
local chest_loot = {
|
||||
@ -170,4 +172,6 @@ function treasure_chest(surface, position)
|
||||
local loot = chest_raffle[math_random(1,#chest_raffle)]
|
||||
i.insert(loot)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Public.treasure_chest
|
@ -1,18 +1,6 @@
|
||||
require "modules.mineable_wreckage_yields_scrap"
|
||||
require "modules.wave_defense.main"
|
||||
require "modules.map_info"
|
||||
map_info = {}
|
||||
map_info.main_caption = "4 Quarters"
|
||||
map_info.sub_caption = "coal ++ iron ++ copper ++ stone"
|
||||
map_info.text = table.concat({
|
||||
"Green energy ore may be found in the stone area.\n",
|
||||
"Oil may be found in the coal area.\n",
|
||||
"\n",
|
||||
"Hold the door as long as possible.\n",
|
||||
"Don't let them in!\n",
|
||||
})
|
||||
map_info.main_caption_color = {r = 0, g = 120, b = 0}
|
||||
map_info.sub_caption_color = {r = 255, g = 0, b = 255}
|
||||
local Map = require "modules.map_info"
|
||||
|
||||
--require "modules.biters_attack_moving_players"
|
||||
--[[
|
||||
@ -26,6 +14,7 @@ local difficulties_votes = {
|
||||
[7] = {tick_increase = 2700, amount_modifier = 1.48, strength_modifier = 2.50, boss_modifier = 9.0}
|
||||
}
|
||||
]]
|
||||
local WD = require "modules.wave_defense.main"
|
||||
local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
local spawn_size = 96
|
||||
local wall_thickness = 3
|
||||
@ -210,9 +199,10 @@ local function on_chunk_generated(event)
|
||||
end
|
||||
|
||||
local function set_difficulty()
|
||||
local wave_defense_table = WD.get_table()
|
||||
--20 Players for maximum difficulty
|
||||
global.wave_defense.wave_interval = 7200 - #game.connected_players * 270
|
||||
if global.wave_defense.wave_interval < 1800 then global.wave_defense.wave_interval = 1800 end
|
||||
wave_defense_table.wave_interval = 7200 - #game.connected_players * 270
|
||||
if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
@ -270,6 +260,18 @@ end
|
||||
]]
|
||||
|
||||
local function on_init()
|
||||
local T = Map.Pop_info()
|
||||
T.main_caption = "4 Quarters"
|
||||
T.sub_caption = "coal ++ iron ++ copper ++ stone"
|
||||
T.text = table.concat({
|
||||
"Green energy ore may be found in the stone area.\n",
|
||||
"Oil may be found in the coal area.\n",
|
||||
"\n",
|
||||
"Hold the door as long as possible.\n",
|
||||
"Don't let them in!\n",
|
||||
})
|
||||
T.main_caption_color = {r = 0, g = 120, b = 0}
|
||||
T.sub_caption_color = {r = 255, g = 0, b = 255}
|
||||
for i, quarter in pairs({"coal", "iron-ore", "stone", "copper-ore"}) do
|
||||
local map_gen_settings = {}
|
||||
map_gen_settings.seed = math.random(1, 999999999)
|
||||
@ -322,7 +324,7 @@ local event = require 'utils.event'
|
||||
--event.on_nth_tick(60, tick)
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
--event.add(defines.events.on_entity_died, on_entity_died)
|
||||
--event.add(defines.events.on_research_finished, on_research_finished)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_player_left_game, on_player_left_game)
|
||||
|
@ -1,26 +1,15 @@
|
||||
--vanilla with wave_defense
|
||||
|
||||
require "modules.wave_defense.main"
|
||||
require "modules.map_info"
|
||||
map_info = {}
|
||||
map_info.main_caption = "Wave Defense"
|
||||
map_info.sub_caption = "~~~~~~"
|
||||
map_info.text = table.concat({
|
||||
"Survive\n",
|
||||
"as\n",
|
||||
"long\n",
|
||||
"as\n",
|
||||
"possible.\n",
|
||||
})
|
||||
map_info.main_caption_color = {r = 150, g = 0, b = 150}
|
||||
map_info.sub_caption_color = {r = 100, g = 150, b = 0}
|
||||
local WD = require "modules.wave_defense.main"
|
||||
local Map = require "modules.map_info"
|
||||
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['iron-plate'] = 16, ['iron-gear-wheel'] = 8, ['raw-fish'] = 3,}
|
||||
|
||||
local function set_difficulty()
|
||||
local wave_defense_table = WD.get_table()
|
||||
--20 Players for maximum difficulty
|
||||
global.wave_defense.wave_interval = 7200 - #game.connected_players * 270
|
||||
if global.wave_defense.wave_interval < 1800 then global.wave_defense.wave_interval = 1800 end
|
||||
wave_defense_table.wave_interval = 7200 - #game.connected_players * 270
|
||||
if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
@ -38,7 +27,19 @@ local function on_player_left_game(event)
|
||||
set_difficulty()
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
local function on_init()
|
||||
local T = Map.Pop_info()
|
||||
T.main_caption = "Wave Defense"
|
||||
T.sub_caption = "~~~~~~"
|
||||
T.text = table.concat({
|
||||
"Survive\n",
|
||||
"as\n",
|
||||
"long\n",
|
||||
"as\n",
|
||||
"possible.\n",
|
||||
})
|
||||
T.main_caption_color = {r = 150, g = 0, b = 150}
|
||||
T.sub_caption_color = {r = 100, g = 150, b = 0}
|
||||
game.surfaces[1].request_to_generate_chunks({0,0}, 16)
|
||||
game.surfaces[1].force_generate_chunk_requests()
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
local game_status = {}
|
||||
local Server = require 'utils.server'
|
||||
|
||||
local function create_victory_gui(winning_lane)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
@ -16,8 +17,8 @@ game_status.restart_server = function()
|
||||
if global.server_restart_timer == 0 then
|
||||
game.print("Map is restarting!", {r=0.22, g=0.88, b=0.22})
|
||||
local message = 'Map is restarting! '
|
||||
server_commands.to_discord_bold(table.concat{'*** ', message, ' ***'})
|
||||
server_commands.start_scenario('wave_of_death')
|
||||
Server.to_discord_bold(table.concat{'*** ', message, ' ***'})
|
||||
Server.start_scenario('wave_of_death')
|
||||
global.server_restart_timer = nil
|
||||
return
|
||||
end
|
||||
|
@ -1,6 +1,8 @@
|
||||
local math_random = math.random
|
||||
local nom_msg = {"munch", "munch", "yum"}
|
||||
|
||||
local Public = {}
|
||||
|
||||
local function feed_floaty_text(unit)
|
||||
unit.surface.create_entity({name = "flying-text", position = unit.position, text = nom_msg[math_random(1, #nom_msg)], color = {math_random(50, 100), 0, 255}})
|
||||
end
|
||||
@ -48,7 +50,7 @@ local function feed_pet(unit)
|
||||
return true
|
||||
end
|
||||
|
||||
function biter_pets_tame_unit(player, unit, forced)
|
||||
function Public.biter_pets_tame_unit(player, unit, forced)
|
||||
if global.biter_pets[player.index] then return false end
|
||||
if not forced then
|
||||
if math_random(1, math.floor(unit.prototype.max_health * 0.01) + 1) ~= 1 then
|
||||
@ -91,7 +93,7 @@ local function on_player_dropped_item(event)
|
||||
if event.entity.stack.name ~= "raw-fish" then return end
|
||||
local unit = find_unit(player, event.entity)
|
||||
if not unit then return end
|
||||
if biter_pets_tame_unit(player, unit, false) then event.entity.destroy() return end
|
||||
if Public.biter_pets_tame_unit(player, unit, false) then event.entity.destroy() return end
|
||||
if unit.force.index == player.force.index then feed_pet(unit) end
|
||||
end
|
||||
|
||||
@ -102,4 +104,6 @@ end
|
||||
local event = require 'utils.event'
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_player_dropped_item, on_player_dropped_item)
|
||||
event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
|
||||
return Public
|
@ -1,4 +1,5 @@
|
||||
local event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
|
||||
local difficulties = {
|
||||
[1] = {name = "Peaceful", value = 0.25, color = {r=0.00, g=0.45, b=0.00}, print_color = {r=0.00, g=0.8, b=0.00}},
|
||||
@ -70,7 +71,7 @@ local function set_difficulty()
|
||||
if global.difficulty_vote_index ~= new_index then
|
||||
local message = table.concat({">> Map difficulty has changed to ", difficulties[new_index].name, " difficulty!"})
|
||||
game.print(message, difficulties[new_index].print_color)
|
||||
server_commands.to_discord_embed(message)
|
||||
Server.to_discord_embed(message)
|
||||
end
|
||||
global.difficulty_vote_index = new_index
|
||||
global.difficulty_vote_value = difficulties[new_index].value
|
||||
|
@ -1,6 +1,7 @@
|
||||
-- hunger module by mewmew --
|
||||
|
||||
local math_random = math.random
|
||||
local P = require "player_modifiers"
|
||||
|
||||
local starve_messages = {" ran out of foodstamps.", " starved.", " should not have skipped breakfast today."}
|
||||
|
||||
@ -121,7 +122,7 @@ function hunger_update(player, food_value)
|
||||
global.player_modifiers[player.index].character_running_speed_modifier["hunger"] = player_hunger_buff[global.player_hunger[player.name]] * 0.15
|
||||
end
|
||||
global.player_modifiers[player.index].character_mining_speed_modifier["hunger"] = player_hunger_buff[global.player_hunger[player.name]]
|
||||
update_player_modifiers(player)
|
||||
P.update_player_modifiers(player)
|
||||
|
||||
update_hunger_gui(player)
|
||||
end
|
||||
|
@ -1,71 +1,89 @@
|
||||
map_info = {}
|
||||
map_info.main_caption = "Insert Main Caption"
|
||||
map_info.main_caption_color = {r=0.6, g=0.3, b=0.99}
|
||||
map_info.sub_caption = "Insert Sub Caption"
|
||||
map_info.sub_caption_color = {r=0.2, g=0.9, b=0.2}
|
||||
map_info.text = [[
|
||||
Add info text to map_info.
|
||||
]]
|
||||
local Global = require 'utils.global'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
|
||||
local function create_map_intro(player, frame)
|
||||
local map_info = {
|
||||
main_caption = "Insert Main Caption",
|
||||
main_caption_color = {r=0.6, g=0.3, b=0.99},
|
||||
sub_caption = "Insert Sub Caption",
|
||||
sub_caption_color = {r=0.2, g=0.9, b=0.2},
|
||||
text = [[
|
||||
Add info text to map_info.
|
||||
]]
|
||||
}
|
||||
|
||||
Global.register(
|
||||
map_info,
|
||||
function(tbl)
|
||||
map_info = tbl
|
||||
end
|
||||
)
|
||||
|
||||
local Public = {}
|
||||
|
||||
function Public.Pop_info()
|
||||
return map_info
|
||||
end
|
||||
|
||||
local create_map_intro = (function (player, frame)
|
||||
frame.clear()
|
||||
frame.style.padding = 4
|
||||
frame.style.margin = 0
|
||||
|
||||
|
||||
local t = frame.add {type = "table", column_count = 1}
|
||||
|
||||
|
||||
local line = t.add { type = "line"}
|
||||
line.style.top_margin = 4
|
||||
line.style.bottom_margin = 4
|
||||
|
||||
|
||||
local l = t.add {type = "label", caption = map_info.main_caption}
|
||||
l.style.font = "heading-1"
|
||||
l.style.font_color = map_info.main_caption_color
|
||||
l.style.minimal_width = 780
|
||||
l.style.horizontal_align = "center"
|
||||
l.style.vertical_align = "center"
|
||||
|
||||
local l = t.add {type = "label", caption = map_info.sub_caption}
|
||||
l.style.font = "heading-2"
|
||||
l.style.font_color = map_info.sub_caption_color
|
||||
l.style.minimal_width = 780
|
||||
l.style.horizontal_align = "center"
|
||||
l.style.horizontal_align = "center"
|
||||
l.style.vertical_align = "center"
|
||||
|
||||
local line = t.add { type = "line"}
|
||||
line.style.top_margin = 4
|
||||
line.style.bottom_margin = 4
|
||||
|
||||
|
||||
local l_2 = t.add {type = "label", caption = map_info.sub_caption}
|
||||
l_2.style.font = "heading-2"
|
||||
l_2.style.font_color = map_info.sub_caption_color
|
||||
l_2.style.minimal_width = 780
|
||||
l_2.style.horizontal_align = "center"
|
||||
l_2.style.vertical_align = "center"
|
||||
|
||||
local line_2 = t.add { type = "line"}
|
||||
line_2.style.top_margin = 4
|
||||
line_2.style.bottom_margin = 4
|
||||
|
||||
local scroll_pane = frame.add { type = "scroll-pane", name = "scroll_pane", direction = "vertical", horizontal_scroll_policy = "never", vertical_scroll_policy = "auto"}
|
||||
scroll_pane.style.maximal_height = 320
|
||||
scroll_pane.style.minimal_height = 320
|
||||
|
||||
local l = scroll_pane.add {type = "label", caption = map_info.text}
|
||||
l.style.font = "heading-2"
|
||||
l.style.single_line = false
|
||||
l.style.font_color = {r=0.85, g=0.85, b=0.88}
|
||||
l.style.minimal_width = 780
|
||||
l.style.horizontal_align = "center"
|
||||
l.style.vertical_align = "center"
|
||||
|
||||
|
||||
local l_3 = scroll_pane.add {type = "label", caption = map_info.text}
|
||||
l_3.style.font = "heading-2"
|
||||
l_3.style.single_line = false
|
||||
l_3.style.font_color = {r=0.85, g=0.85, b=0.88}
|
||||
l_3.style.minimal_width = 780
|
||||
l_3.style.horizontal_align = "center"
|
||||
l_3.style.vertical_align = "center"
|
||||
|
||||
local b = frame.add {type = "button", caption = "CLOSE", name = "close_map_intro"}
|
||||
b.style.font = "heading-2"
|
||||
b.style.padding = 2
|
||||
b.style.top_margin = 3
|
||||
b.style.left_margin = 333
|
||||
b.style.horizontal_align = "center"
|
||||
b.style.horizontal_align = "center"
|
||||
b.style.vertical_align = "center"
|
||||
end
|
||||
)
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if player.online_time == 0 then comfy_panel_call_tab(player, "Map Info") end
|
||||
if player.online_time == 0 then Tabs.comfy_panel_call_tab(player, "Map Info") end
|
||||
end
|
||||
|
||||
local function on_gui_click(event)
|
||||
if not event then return end
|
||||
if not event.element then return end
|
||||
if not event.element.valid then return end
|
||||
if not event.element.valid then return end
|
||||
if event.element.name == "close_map_intro" then game.players[event.player_index].gui.left.comfy_panel.destroy() return end
|
||||
end
|
||||
|
||||
@ -73,4 +91,6 @@ comfy_panel_tabs["Map Info"] = create_map_intro
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
||||
|
||||
return Public
|
@ -12,6 +12,8 @@ VITALITY > character_health_bonus
|
||||
]]
|
||||
|
||||
local math_random = math.random
|
||||
local Tabs = require "comfy_panel.main"
|
||||
local P = require "player_modifiers"
|
||||
local visuals_delay = 1800
|
||||
local level_up_floating_text_color = {0, 205, 0}
|
||||
local xp_floating_text_color = {157, 157, 157}
|
||||
@ -21,6 +23,8 @@ for a = 1, 9999, 1 do
|
||||
end
|
||||
local gain_info_tooltip = "XP gain from mining, building, moving, crafting, repairing and combat."
|
||||
|
||||
local Public = {}
|
||||
|
||||
local classes = {
|
||||
["engineer"] = "ENGINEER",
|
||||
["strength"] = "MINER",
|
||||
@ -91,7 +95,7 @@ local function update_player_stats(player)
|
||||
|
||||
global.player_modifiers[player.index].character_health_bonus["rpg"] = math.round((global.rpg[player.index].vitality - 10) * 6, 3)
|
||||
|
||||
update_player_modifiers(player)
|
||||
P.update_player_modifiers(player)
|
||||
end
|
||||
|
||||
local function get_class(player)
|
||||
@ -168,7 +172,7 @@ local function draw_gui(player, forced)
|
||||
if global.rpg[player.index].gui_refresh_delay > game.tick then return end
|
||||
end
|
||||
|
||||
comfy_panel_clear_left_gui(player)
|
||||
Tabs.comfy_panel_clear_left_gui(player)
|
||||
|
||||
if player.gui.left.rpg then player.gui.left.rpg.destroy() end
|
||||
if not player.character then return end
|
||||
@ -425,7 +429,7 @@ local function gain_xp(player, amount)
|
||||
global.rpg[player.index].last_floaty_text = game.tick + visuals_delay
|
||||
end
|
||||
|
||||
function rpg_reset_player(player)
|
||||
function Public.rpg_reset_player(player)
|
||||
if player.gui.left.rpg then player.gui.left.rpg.destroy() end
|
||||
if not player.character then
|
||||
player.set_controller({type=defines.controllers.god})
|
||||
@ -442,12 +446,12 @@ function rpg_reset_player(player)
|
||||
update_player_stats(player)
|
||||
end
|
||||
|
||||
function rpg_reset_all_players()
|
||||
function Public.rpg_reset_all_players()
|
||||
for _, p in pairs(game.players) do
|
||||
global.rpg[p.index] = nil
|
||||
end
|
||||
for _, p in pairs(game.connected_players) do
|
||||
rpg_reset_player(p)
|
||||
Public.rpg_reset_player(p)
|
||||
end
|
||||
end
|
||||
|
||||
@ -556,14 +560,9 @@ local get_cause_player = {
|
||||
local function on_entity_died(event)
|
||||
if not event.entity.valid then return end
|
||||
|
||||
--Grant XP for detonated land mines
|
||||
--Grant XP for hand placed land mines
|
||||
if event.entity.last_user then
|
||||
if event.entity.type == "land-mine" then
|
||||
if event.cause then
|
||||
if event.cause.valid then
|
||||
if event.cause.force.index == event.entity.force.index then return end
|
||||
end
|
||||
end
|
||||
if event.entity.type == "land-mine" then
|
||||
gain_xp(event.entity.last_user, 1)
|
||||
return
|
||||
end
|
||||
@ -776,14 +775,14 @@ end
|
||||
|
||||
local function on_player_respawned(event)
|
||||
local player = game.players[event.player_index]
|
||||
if not global.rpg[player.index] then rpg_reset_player(player) return end
|
||||
if not global.rpg[player.index] then Public.rpg_reset_player(player) return end
|
||||
update_player_stats(player)
|
||||
draw_level_text(player)
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if not global.rpg[player.index] then rpg_reset_player(player) end
|
||||
if not global.rpg[player.index] then Public.rpg_reset_player(player) end
|
||||
for _, p in pairs(game.connected_players) do
|
||||
draw_level_text(p)
|
||||
end
|
||||
@ -814,4 +813,6 @@ event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_player_repaired_entity, on_player_repaired_entity)
|
||||
event.add(defines.events.on_player_respawned, on_player_respawned)
|
||||
event.add(defines.events.on_player_rotated_entity, on_player_rotated_entity)
|
||||
event.add(defines.events.on_pre_player_mined_item, on_pre_player_mined_item)
|
||||
event.add(defines.events.on_pre_player_mined_item, on_pre_player_mined_item)
|
||||
|
||||
return Public
|
@ -1,6 +1,7 @@
|
||||
-- level up ranks with launching satellites -- by mewmew
|
||||
|
||||
local event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
|
||||
local function get_rank()
|
||||
for i = #global.satellite_score, 1, -1 do
|
||||
@ -83,7 +84,7 @@ local function on_rocket_launched(event)
|
||||
if (global.satellites_in_space < 10) or ((global.satellites_in_space < 50) and ((global.satellites_in_space % 5) == 0)) or ((global.satellites_in_space % 25) == 0) then
|
||||
local message = 'A satellite has been launched! Total count: ' .. global.satellites_in_space
|
||||
game.print(message)
|
||||
server_commands.to_discord_embed(message)
|
||||
Server.to_discord_embed(message)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,94 +1,105 @@
|
||||
function wave_defense_roll_biter_name()
|
||||
local WD = require "modules.wave_defense.table"
|
||||
|
||||
local Public = {}
|
||||
|
||||
function Public.wave_defense_roll_biter_name()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local max_chance = 0
|
||||
for k, v in pairs(global.wave_defense.biter_raffle) do
|
||||
for k, v in pairs(wave_defense_table.biter_raffle) do
|
||||
max_chance = max_chance + v
|
||||
end
|
||||
local r = math.random(0, math.floor(max_chance))
|
||||
local current_chance = 0
|
||||
for k, v in pairs(global.wave_defense.biter_raffle) do
|
||||
for k, v in pairs(wave_defense_table.biter_raffle) do
|
||||
current_chance = current_chance + v
|
||||
if r <= current_chance then return k end
|
||||
end
|
||||
end
|
||||
|
||||
function wave_defense_roll_spitter_name()
|
||||
function Public.wave_defense_roll_spitter_name()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local max_chance = 0
|
||||
for k, v in pairs(global.wave_defense.spitter_raffle) do
|
||||
for k, v in pairs(wave_defense_table.spitter_raffle) do
|
||||
max_chance = max_chance + v
|
||||
end
|
||||
local r = math.random(0, math.floor(max_chance))
|
||||
local current_chance = 0
|
||||
for k, v in pairs(global.wave_defense.spitter_raffle) do
|
||||
for k, v in pairs(wave_defense_table.spitter_raffle) do
|
||||
current_chance = current_chance + v
|
||||
if r <= current_chance then return k end
|
||||
end
|
||||
end
|
||||
|
||||
function wave_defense_set_unit_raffle(level)
|
||||
global.wave_defense.biter_raffle = {
|
||||
function Public.wave_defense_set_unit_raffle(level)
|
||||
local wave_defense_table = WD.get_table()
|
||||
wave_defense_table.biter_raffle = {
|
||||
["small-biter"] = 1000 - level * 1.75,
|
||||
["medium-biter"] = level,
|
||||
["big-biter"] = 0,
|
||||
["behemoth-biter"] = 0,
|
||||
}
|
||||
global.wave_defense.spitter_raffle = {
|
||||
wave_defense_table.spitter_raffle = {
|
||||
["small-spitter"] = 1000 - level * 1.75,
|
||||
["medium-spitter"] = level,
|
||||
["big-spitter"] = 0,
|
||||
["behemoth-spitter"] = 0,
|
||||
}
|
||||
if level > 500 then
|
||||
global.wave_defense.biter_raffle["medium-biter"] = 500 - (level - 500)
|
||||
global.wave_defense.spitter_raffle["medium-spitter"] = 500 - (level - 500)
|
||||
global.wave_defense.biter_raffle["big-biter"] = (level - 500) * 2
|
||||
global.wave_defense.spitter_raffle["big-spitter"] = (level - 500) * 2
|
||||
wave_defense_table.biter_raffle["medium-biter"] = 500 - (level - 500)
|
||||
wave_defense_table.spitter_raffle["medium-spitter"] = 500 - (level - 500)
|
||||
wave_defense_table.biter_raffle["big-biter"] = (level - 500) * 2
|
||||
wave_defense_table.spitter_raffle["big-spitter"] = (level - 500) * 2
|
||||
end
|
||||
if level > 800 then
|
||||
global.wave_defense.biter_raffle["behemoth-biter"] = (level - 800) * 3
|
||||
global.wave_defense.spitter_raffle["behemoth-spitter"] = (level - 800) * 3
|
||||
wave_defense_table.biter_raffle["behemoth-biter"] = (level - 800) * 3
|
||||
wave_defense_table.spitter_raffle["behemoth-spitter"] = (level - 800) * 3
|
||||
end
|
||||
for k, v in pairs(global.wave_defense.biter_raffle) do
|
||||
if global.wave_defense.biter_raffle[k] < 0 then global.wave_defense.biter_raffle[k] = 0 end
|
||||
for k, v in pairs(wave_defense_table.biter_raffle) do
|
||||
if wave_defense_table.biter_raffle[k] < 0 then wave_defense_table.biter_raffle[k] = 0 end
|
||||
end
|
||||
for k, v in pairs(global.wave_defense.spitter_raffle) do
|
||||
if global.wave_defense.spitter_raffle[k] < 0 then global.wave_defense.spitter_raffle[k] = 0 end
|
||||
for k, v in pairs(wave_defense_table.spitter_raffle) do
|
||||
if wave_defense_table.spitter_raffle[k] < 0 then wave_defense_table.spitter_raffle[k] = 0 end
|
||||
end
|
||||
end
|
||||
|
||||
function wave_defense_roll_worm_name()
|
||||
function Public.wave_defense_roll_worm_name()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local max_chance = 0
|
||||
for k, v in pairs(global.wave_defense.worm_raffle) do
|
||||
for k, v in pairs(wave_defense_table.worm_raffle) do
|
||||
max_chance = max_chance + v
|
||||
end
|
||||
local r = math.random(0, math.floor(max_chance))
|
||||
local current_chance = 0
|
||||
for k, v in pairs(global.wave_defense.worm_raffle) do
|
||||
for k, v in pairs(wave_defense_table.worm_raffle) do
|
||||
current_chance = current_chance + v
|
||||
if r <= current_chance then return k end
|
||||
end
|
||||
end
|
||||
|
||||
function wave_defense_set_worm_raffle(level)
|
||||
global.wave_defense.worm_raffle = {
|
||||
function Public.wave_defense_set_worm_raffle(level)
|
||||
local wave_defense_table = WD.get_table()
|
||||
wave_defense_table.worm_raffle = {
|
||||
["small-worm-turret"] = 1000 - level * 1.75,
|
||||
["medium-worm-turret"] = level,
|
||||
["big-worm-turret"] = 0,
|
||||
["behemoth-worm-turret"] = 0,
|
||||
}
|
||||
if level > 500 then
|
||||
global.wave_defense.worm_raffle["medium-worm-turret"] = 500 - (level - 500)
|
||||
global.wave_defense.worm_raffle["big-worm-turret"] = (level - 500) * 2
|
||||
wave_defense_table.worm_raffle["medium-worm-turret"] = 500 - (level - 500)
|
||||
wave_defense_table.worm_raffle["big-worm-turret"] = (level - 500) * 2
|
||||
end
|
||||
if level > 800 then
|
||||
global.wave_defense.worm_raffle["behemoth-worm-turret"] = (level - 800) * 3
|
||||
wave_defense_table.worm_raffle["behemoth-worm-turret"] = (level - 800) * 3
|
||||
end
|
||||
for k, v in pairs(global.wave_defense.worm_raffle) do
|
||||
if global.wave_defense.worm_raffle[k] < 0 then global.wave_defense.worm_raffle[k] = 0 end
|
||||
for k, v in pairs(wave_defense_table.worm_raffle) do
|
||||
if wave_defense_table.worm_raffle[k] < 0 then wave_defense_table.worm_raffle[k] = 0 end
|
||||
end
|
||||
end
|
||||
|
||||
function wave_defense_print_chances(tbl)
|
||||
function Public.wave_defense_print_chances(tbl)
|
||||
for k, v in pairs(tbl) do
|
||||
game.print(k .. " chance = " .. v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Public
|
@ -1,3 +1,5 @@
|
||||
local WD = require "modules.wave_defense.table"
|
||||
|
||||
local function create_gui(player)
|
||||
local frame = player.gui.top.add({ type = "frame", name = "wave_defense"})
|
||||
frame.style.maximal_height = 38
|
||||
@ -34,28 +36,30 @@ end
|
||||
|
||||
--display threat gain/loss per minute during last 15 minutes
|
||||
local function get_threat_gain()
|
||||
local past_index = global.wave_defense.threat_log_index - 900
|
||||
local wave_defense_table = WD.get_table()
|
||||
local past_index = wave_defense_table.threat_log_index - 900
|
||||
if past_index < 1 then past_index = 1 end
|
||||
local gain = math.floor((global.wave_defense.threat_log[global.wave_defense.threat_log_index] - global.wave_defense.threat_log[past_index]) / 15)
|
||||
local gain = math.floor((wave_defense_table.threat_log[wave_defense_table.threat_log_index] - wave_defense_table.threat_log[past_index]) / 15)
|
||||
return gain
|
||||
end
|
||||
|
||||
local function update_gui(player)
|
||||
local wave_defense_table = WD.get_table()
|
||||
if not player.gui.top.wave_defense then create_gui(player) end
|
||||
player.gui.top.wave_defense.label.caption = "Wave: " .. global.wave_defense.wave_number
|
||||
if global.wave_defense.wave_number == 0 then player.gui.top.wave_defense.label.caption = "First wave in " .. math.floor((global.wave_defense.next_wave - game.tick) / 60) + 1 end
|
||||
local interval = global.wave_defense.next_wave - global.wave_defense.last_wave
|
||||
player.gui.top.wave_defense.progressbar.value = 1 - (global.wave_defense.next_wave - game.tick) / interval
|
||||
player.gui.top.wave_defense.label.caption = "Wave: " .. wave_defense_table.wave_number
|
||||
if wave_defense_table.wave_number == 0 then player.gui.top.wave_defense.label.caption = "First wave in " .. math.floor((wave_defense_table.next_wave - game.tick) / 60) + 1 end
|
||||
local interval = wave_defense_table.next_wave - wave_defense_table.last_wave
|
||||
player.gui.top.wave_defense.progressbar.value = 1 - (wave_defense_table.next_wave - game.tick) / interval
|
||||
|
||||
player.gui.top.wave_defense.threat.caption = "Threat: " .. math.floor(global.wave_defense.threat)
|
||||
player.gui.top.wave_defense.threat.caption = "Threat: " .. math.floor(wave_defense_table.threat)
|
||||
|
||||
if global.wave_defense.wave_number == 0 then
|
||||
if wave_defense_table.wave_number == 0 then
|
||||
player.gui.top.wave_defense.threat_gains.caption = ""
|
||||
return
|
||||
end
|
||||
|
||||
local gain = get_threat_gain()
|
||||
local d = global.wave_defense.wave_number / 75
|
||||
local d = wave_defense_table.wave_number / 75
|
||||
|
||||
if gain >= 0 then
|
||||
player.gui.top.wave_defense.threat_gains.caption = " (+" .. gain .. ")"
|
||||
|
@ -1,102 +1,112 @@
|
||||
require "modules.biter_health_booster"
|
||||
require "modules.wave_defense.biter_rolls"
|
||||
require "modules.wave_defense.threat_events"
|
||||
local BiterRolls = require "modules.wave_defense.biter_rolls"
|
||||
local ThreatEvent = require "modules.wave_defense.threat_events"
|
||||
local update_gui = require "modules.wave_defense.gui"
|
||||
local threat_values = require "modules.wave_defense.threat_values"
|
||||
local math_random = math.random
|
||||
local WD = require "modules.wave_defense.table"
|
||||
local event = require 'utils.event'
|
||||
local side_target_types = {"accumulator", "assembling-machine", "beacon", "boiler", "container", "furnace", "lamp", "lab", "logistic-container", "mining-drill", "container", "pump", "radar", "reactor", "roboport", "rocket-silo", "solar-panel", "storage-tank",}
|
||||
--local side_target_types = {"assembling-machine", "electric-pole", "furnace", "mining-drill", "pump", "radar", "reactor", "roboport"}
|
||||
|
||||
local Public = {}
|
||||
|
||||
local function debug_print(msg)
|
||||
if not global.wave_defense.debug then return end
|
||||
print("WaveDefense: " .. msg)
|
||||
local wave_defense_table = WD.get_table()
|
||||
if not wave_defense_table.debug then return end
|
||||
print("WaveDefense: " .. msg)
|
||||
end
|
||||
|
||||
local function is_unit_valid(biter)
|
||||
local wave_defense_table = WD.get_table()
|
||||
if not biter.entity then debug_print("is_unit_valid - unit destroyed - does no longer exist") return false end
|
||||
if not biter.entity.valid then debug_print("is_unit_valid - unit destroyed - invalid") return false end
|
||||
if not biter.entity.unit_group then debug_print("is_unit_valid - unit destroyed - no unitgroup") return false end
|
||||
if biter.spawn_tick + global.wave_defense.max_biter_age < game.tick then debug_print("is_unit_valid - unit destroyed - timed out") return false end
|
||||
if biter.spawn_tick + wave_defense_table.max_biter_age < game.tick then debug_print("is_unit_valid - unit destroyed - timed out") return false end
|
||||
return true
|
||||
end
|
||||
|
||||
local function refresh_active_unit_threat()
|
||||
debug_print("refresh_active_unit_threat - current value " .. global.wave_defense.active_biter_threat)
|
||||
local wave_defense_table = WD.get_table()
|
||||
debug_print("refresh_active_unit_threat - current value " .. wave_defense_table.active_biter_threat)
|
||||
local active_biter_threat = 0
|
||||
for k, biter in pairs(global.wave_defense.active_biters) do
|
||||
for k, biter in pairs(wave_defense_table.active_biters) do
|
||||
if biter.entity then
|
||||
if biter.entity.valid then
|
||||
active_biter_threat = active_biter_threat + threat_values[biter.entity.name]
|
||||
end
|
||||
end
|
||||
end
|
||||
global.wave_defense.active_biter_threat = math.round(active_biter_threat * global.biter_health_boost, 2)
|
||||
debug_print("refresh_active_unit_threat - new value " .. global.wave_defense.active_biter_threat)
|
||||
wave_defense_table.active_biter_threat = math.round(active_biter_threat * global.biter_health_boost, 2)
|
||||
debug_print("refresh_active_unit_threat - new value " .. wave_defense_table.active_biter_threat)
|
||||
end
|
||||
|
||||
local function time_out_biters()
|
||||
for k, biter in pairs(global.wave_defense.active_biters) do
|
||||
local wave_defense_table = WD.get_table()
|
||||
for k, biter in pairs(wave_defense_table.active_biters) do
|
||||
if not is_unit_valid(biter) then
|
||||
global.wave_defense.active_biter_count = global.wave_defense.active_biter_count - 1
|
||||
wave_defense_table.active_biter_count = wave_defense_table.active_biter_count - 1
|
||||
if biter.entity then
|
||||
if biter.entity.valid then
|
||||
global.wave_defense.active_biter_threat = global.wave_defense.active_biter_threat - math.round(threat_values[biter.entity.name] * global.biter_health_boost, 2)
|
||||
wave_defense_table.active_biter_threat = wave_defense_table.active_biter_threat - math.round(threat_values[biter.entity.name] * global.biter_health_boost, 2)
|
||||
if biter.entity.force.index == 2 then
|
||||
biter.entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
global.wave_defense.active_biters[k] = nil
|
||||
wave_defense_table.active_biters[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function get_random_close_spawner(surface)
|
||||
local spawners = surface.find_entities_filtered({type = "unit-spawner"})
|
||||
local wave_defense_table = WD.get_table()
|
||||
local spawners = surface.find_entities_filtered({type = "unit-spawner"})
|
||||
if not spawners[1] then return false end
|
||||
local center = global.wave_defense.target.position
|
||||
local spawner = spawners[math_random(1,#spawners)]
|
||||
for i = 1, global.wave_defense.get_random_close_spawner_attempts, 1 do
|
||||
local spawner_2 = spawners[math_random(1,#spawners)]
|
||||
if (center.x - spawner_2.position.x) ^ 2 + (center.y - spawner_2.position.y) ^ 2 < (center.x - spawner.position.x) ^ 2 + (center.y - spawner.position.y) ^ 2 then spawner = spawner_2 end
|
||||
end
|
||||
local center = wave_defense_table.target.position
|
||||
local spawner = spawners[math.random(1,#spawners)]
|
||||
for i = 1, wave_defense_table.get_random_close_spawner_attempts, 1 do
|
||||
local spawner_2 = spawners[math.random(1,#spawners)]
|
||||
if (center.x - spawner_2.position.x) ^ 2 + (center.y - spawner_2.position.y) ^ 2 < (center.x - spawner.position.x) ^ 2 + (center.y - spawner.position.y) ^ 2 then spawner = spawner_2 end
|
||||
end
|
||||
debug_print("get_random_close_spawner - Found at x" .. spawner.position.x .. " y" .. spawner.position.y)
|
||||
return spawner
|
||||
end
|
||||
|
||||
local function set_side_target_list()
|
||||
local surface = game.surfaces[global.wave_defense.surface_index]
|
||||
local wave_defense_table = WD.get_table()
|
||||
local surface = game.surfaces[wave_defense_table.surface_index]
|
||||
local position = false
|
||||
local force = false
|
||||
|
||||
if global.wave_defense.target then
|
||||
if global.wave_defense.target.valid then
|
||||
position = global.wave_defense.target.position
|
||||
force = global.wave_defense.target.force
|
||||
|
||||
if wave_defense_table.target then
|
||||
if wave_defense_table.target.valid then
|
||||
position = wave_defense_table.target.position
|
||||
force = wave_defense_table.target.force
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if not position then
|
||||
local r = math_random(1, #game.connected_players)
|
||||
local r = math.random(1, #game.connected_players)
|
||||
position = {x = game.connected_players[r].position.x, y = game.connected_players[r].position.y}
|
||||
force = game.connected_players[r].force
|
||||
end
|
||||
|
||||
global.wave_defense.side_targets = surface.find_entities_filtered({
|
||||
|
||||
wave_defense_table.side_targets = surface.find_entities_filtered({
|
||||
area = {
|
||||
{position.x - global.wave_defense.side_target_search_radius, position.y - global.wave_defense.side_target_search_radius},
|
||||
{position.x + global.wave_defense.side_target_search_radius, position.y + global.wave_defense.side_target_search_radius}
|
||||
{position.x - wave_defense_table.side_target_search_radius, position.y - wave_defense_table.side_target_search_radius},
|
||||
{position.x + wave_defense_table.side_target_search_radius, position.y + wave_defense_table.side_target_search_radius}
|
||||
},
|
||||
force = force,
|
||||
type = side_target_types,
|
||||
})
|
||||
|
||||
debug_print("set_side_target_list -- " .. #global.wave_defense.side_targets .. " targets around position x" .. position.x .. " y" .. position.y .. " saved.")
|
||||
|
||||
debug_print("set_side_target_list -- " .. #wave_defense_table.side_targets .. " targets around position x" .. position.x .. " y" .. position.y .. " saved.")
|
||||
end
|
||||
|
||||
local function get_side_target()
|
||||
local wave_defense_table = WD.get_table()
|
||||
if math.random(1, 2) == 1 then
|
||||
local surface = game.surfaces[global.wave_defense.surface_index]
|
||||
local surface = game.surfaces[wave_defense_table.surface_index]
|
||||
local characters = surface.find_entities_filtered({name = "character"})
|
||||
if not characters[1] then return false end
|
||||
local character = characters[math.random(1, #characters)]
|
||||
@ -104,20 +114,20 @@ local function get_side_target()
|
||||
return character
|
||||
end
|
||||
|
||||
if not global.wave_defense.side_targets then return false end
|
||||
if #global.wave_defense.side_targets < 2 then return false end
|
||||
local side_target = global.wave_defense.side_targets[math_random(1,#global.wave_defense.side_targets)]
|
||||
if not wave_defense_table.side_targets then return false end
|
||||
if #wave_defense_table.side_targets < 2 then return false end
|
||||
local side_target = wave_defense_table.side_targets[math_random(1,#wave_defense_table.side_targets)]
|
||||
if not side_target then return false end
|
||||
if not side_target.valid then return false end
|
||||
for _ = 1, 4, 1 do
|
||||
local new_target = global.wave_defense.side_targets[math_random(1,#global.wave_defense.side_targets)]
|
||||
local new_target = wave_defense_table.side_targets[math.random(1,#wave_defense_table.side_targets)]
|
||||
if new_target then
|
||||
if new_target.valid then
|
||||
local side_target_distance = (global.wave_defense.target.position.x - side_target.position.x) ^ 2 + (global.wave_defense.target.position.y - side_target.position.y) ^ 2
|
||||
local new_target_distance = (global.wave_defense.target.position.x - new_target.position.x) ^ 2 + (global.wave_defense.target.position.y - new_target.position.y) ^ 2
|
||||
if new_target_distance > side_target_distance then side_target = new_target end
|
||||
end
|
||||
end
|
||||
local side_target_distance = (wave_defense_table.target.position.x - side_target.position.x) ^ 2 + (wave_defense_table.target.position.y - side_target.position.y) ^ 2
|
||||
local new_target_distance = (wave_defense_table.target.position.x - new_target.position.x) ^ 2 + (wave_defense_table.target.position.y - new_target.position.y) ^ 2
|
||||
if new_target_distance > side_target_distance then side_target = new_target end
|
||||
end
|
||||
end
|
||||
end
|
||||
debug_print("get_side_target -- " .. side_target.name .. " at position x" .. side_target.position.x .. " y" .. side_target.position.y .. " selected.")
|
||||
return side_target
|
||||
@ -125,94 +135,101 @@ end
|
||||
|
||||
--[[
|
||||
local function set_main_target()
|
||||
if global.wave_defense.target then
|
||||
if global.wave_defense.target.valid then return end
|
||||
if wave_defense_table.target then
|
||||
if wave_defense_table.target.valid then return end
|
||||
end
|
||||
local characters = {}
|
||||
for i = 1, #game.connected_players, 1 do
|
||||
if game.connected_players[i].character then
|
||||
if game.connected_players[i].character.valid then
|
||||
if game.connected_players[i].surface.index == global.wave_defense.surface_index then
|
||||
if game.connected_players[i].surface.index == wave_defense_table.surface_index then
|
||||
characters[#characters + 1] = game.connected_players[i].character
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if #characters == 0 then return end
|
||||
global.wave_defense.target = characters[math_random(1, #characters)]
|
||||
if #characters == 0 then return end
|
||||
wave_defense_table.target = characters[math.random(1, #characters)]
|
||||
end
|
||||
]]
|
||||
|
||||
local function set_main_target()
|
||||
if global.wave_defense.target then
|
||||
if global.wave_defense.target.valid then return end
|
||||
local wave_defense_table = WD.get_table()
|
||||
if wave_defense_table.target then
|
||||
if wave_defense_table.target.valid then return end
|
||||
end
|
||||
if not global.wave_defense.side_targets then return end
|
||||
if #global.wave_defense.side_targets == 0 then return end
|
||||
local target = global.wave_defense.side_targets[math_random(1, #global.wave_defense.side_targets)]
|
||||
if not wave_defense_table.side_targets then return end
|
||||
if #wave_defense_table.side_targets == 0 then return end
|
||||
local target = wave_defense_table.side_targets[math.random(1, #wave_defense_table.side_targets)]
|
||||
if not target then return end
|
||||
if not target.valid then return end
|
||||
global.wave_defense.target = target
|
||||
if not target.valid then return end
|
||||
wave_defense_table.target = target
|
||||
debug_print("set_main_target -- New main target " .. target.name .. " at position x" .. target.position.x .. " y" .. target.position.y .. " selected.")
|
||||
end
|
||||
|
||||
local function set_group_spawn_position(surface)
|
||||
local wave_defense_table = WD.get_table()
|
||||
local spawner = get_random_close_spawner(surface)
|
||||
if not spawner then return end
|
||||
local position = surface.find_non_colliding_position("rocket-silo", spawner.position, 48, 1)
|
||||
if not position then return end
|
||||
global.wave_defense.spawn_position = {x = math.floor(position.x), y = math.floor(position.y)}
|
||||
debug_print("set_group_spawn_position -- Changed position to x" .. global.wave_defense.spawn_position.x .. " y" .. global.wave_defense.spawn_position.y .. ".")
|
||||
if not position then return end
|
||||
wave_defense_table.spawn_position = {x = math.floor(position.x), y = math.floor(position.y)}
|
||||
debug_print("set_group_spawn_position -- Changed position to x" .. wave_defense_table.spawn_position.x .. " y" .. wave_defense_table.spawn_position.y .. ".")
|
||||
end
|
||||
|
||||
local function set_enemy_evolution()
|
||||
local evolution_factor = global.wave_defense.wave_number * 0.001
|
||||
local wave_defense_table = WD.get_table()
|
||||
local evolution_factor = wave_defense_table.wave_number * 0.001
|
||||
local biter_health_boost = 1
|
||||
--local damage_increase = 0
|
||||
|
||||
|
||||
if evolution_factor > 1 then
|
||||
--damage_increase = damage_increase + (evolution_factor - 1)
|
||||
--biter_health_boost = biter_health_boost + (evolution_factor - 1) * 2
|
||||
evolution_factor = 1
|
||||
end
|
||||
|
||||
if global.wave_defense.threat > 0 then
|
||||
biter_health_boost = math.round(biter_health_boost + global.wave_defense.threat * 0.00005, 3)
|
||||
--damage_increase = math.round(damage_increase + global.wave_defense.threat * 0.0000025, 3)
|
||||
if wave_defense_table.threat > 0 then
|
||||
biter_health_boost = math.round(biter_health_boost + wave_defense_table.threat * 0.00005, 3)
|
||||
--damage_increase = math.round(damage_increase + wave_defense_table.threat * 0.0000025, 3)
|
||||
end
|
||||
|
||||
global.biter_health_boost = biter_health_boost
|
||||
--game.forces.enemy.set_ammo_damage_modifier("melee", damage_increase)
|
||||
--game.forces.enemy.set_ammo_damage_modifier("biological", damage_increase)
|
||||
game.forces.enemy.evolution_factor = evolution_factor
|
||||
|
||||
|
||||
if global.biter_health_boost then
|
||||
for _, player in pairs(game.connected_players) do
|
||||
for _, player in pairs(game.connected_players) do
|
||||
--player.gui.top.wave_defense.threat.tooltip = "High threat may empower biters.\nBiter health " .. biter_health_boost * 100 .. "% | damage " .. (damage_increase + 1) * 100 .. "%"
|
||||
player.gui.top.wave_defense.threat.tooltip = "High threat may empower biters.\nBiter health " .. biter_health_boost * 100 .. "%"
|
||||
if player.gui.top.wave_defense then
|
||||
player.gui.top.wave_defense.threat.tooltip = "High threat may empower biters.\nBiter health " .. biter_health_boost * 100 .. "%"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function can_units_spawn()
|
||||
if global.wave_defense.threat <= 0 then
|
||||
local wave_defense_table = WD.get_table()
|
||||
if wave_defense_table.threat <= 0 then
|
||||
debug_print("can_units_spawn - threat too low")
|
||||
return false
|
||||
return false
|
||||
end
|
||||
if global.wave_defense.active_biter_count >= global.wave_defense.max_active_biters then
|
||||
if wave_defense_table.active_biter_count >= wave_defense_table.max_active_biters then
|
||||
debug_print("can_units_spawn - active biter count too high")
|
||||
return false
|
||||
return false
|
||||
end
|
||||
if global.wave_defense.active_biter_threat >= global.wave_defense.threat then
|
||||
debug_print("can_units_spawn - active biter threat too high (" .. global.wave_defense.active_biter_threat .. ")")
|
||||
return false
|
||||
if wave_defense_table.active_biter_threat >= wave_defense_table.threat then
|
||||
debug_print("can_units_spawn - active biter threat too high (" .. wave_defense_table.active_biter_threat .. ")")
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function get_active_unit_groups_count()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local count = 0
|
||||
for _, g in pairs(global.wave_defense.unit_groups) do
|
||||
for _, g in pairs(wave_defense_table.unit_groups) do
|
||||
if g.valid then
|
||||
if #g.members > 0 then
|
||||
count = count + 1
|
||||
@ -226,57 +243,60 @@ local function get_active_unit_groups_count()
|
||||
end
|
||||
|
||||
local function spawn_biter(surface)
|
||||
local wave_defense_table = WD.get_table()
|
||||
if not can_units_spawn() then return end
|
||||
|
||||
|
||||
local name
|
||||
if math.random(1,100) > 73 then
|
||||
name = wave_defense_roll_spitter_name()
|
||||
name = BiterRolls.wave_defense_roll_spitter_name()
|
||||
else
|
||||
name = wave_defense_roll_biter_name()
|
||||
name = BiterRolls.wave_defense_roll_biter_name()
|
||||
end
|
||||
local position = surface.find_non_colliding_position(name, global.wave_defense.spawn_position, 48, 2)
|
||||
local position = surface.find_non_colliding_position(name, wave_defense_table.spawn_position, 48, 2)
|
||||
if not position then return false end
|
||||
local biter = surface.create_entity({name = name, position = position, force = "enemy"})
|
||||
biter.ai_settings.allow_destroy_when_commands_fail = false
|
||||
biter.ai_settings.allow_try_return_to_spawner = false
|
||||
global.wave_defense.active_biters[biter.unit_number] = {entity = biter, spawn_tick = game.tick}
|
||||
global.wave_defense.active_biter_count = global.wave_defense.active_biter_count + 1
|
||||
global.wave_defense.active_biter_threat = global.wave_defense.active_biter_threat + math.round(threat_values[name] * global.biter_health_boost, 2)
|
||||
wave_defense_table.active_biters[biter.unit_number] = {entity = biter, spawn_tick = game.tick}
|
||||
wave_defense_table.active_biter_count = wave_defense_table.active_biter_count + 1
|
||||
wave_defense_table.active_biter_threat = wave_defense_table.active_biter_threat + math.round(threat_values[name] * global.biter_health_boost, 2)
|
||||
return biter
|
||||
end
|
||||
|
||||
local function set_next_wave()
|
||||
global.wave_defense.wave_number = global.wave_defense.wave_number + 1
|
||||
global.wave_defense.group_size = global.wave_defense.wave_number * 2
|
||||
if global.wave_defense.group_size > global.wave_defense.max_group_size then global.wave_defense.group_size = global.wave_defense.max_group_size end
|
||||
global.wave_defense.threat = global.wave_defense.threat + math.floor(global.wave_defense.wave_number * global.wave_defense.threat_gain_multiplier)
|
||||
global.wave_defense.last_wave = global.wave_defense.next_wave
|
||||
global.wave_defense.next_wave = game.tick + global.wave_defense.wave_interval
|
||||
local wave_defense_table = WD.get_table()
|
||||
wave_defense_table.wave_number = wave_defense_table.wave_number + 1
|
||||
wave_defense_table.group_size = wave_defense_table.wave_number * 2
|
||||
if wave_defense_table.group_size > wave_defense_table.max_group_size then wave_defense_table.group_size = wave_defense_table.max_group_size end
|
||||
wave_defense_table.threat = wave_defense_table.threat + math.floor(wave_defense_table.wave_number * wave_defense_table.threat_gain_multiplier)
|
||||
wave_defense_table.last_wave = wave_defense_table.next_wave
|
||||
wave_defense_table.next_wave = game.tick + wave_defense_table.wave_interval
|
||||
end
|
||||
|
||||
local function get_commmands(group)
|
||||
local wave_defense_table = WD.get_table()
|
||||
local commands = {}
|
||||
local group_position = {x = group.position.x, y = group.position.y}
|
||||
local step_length = global.wave_defense.unit_group_command_step_length
|
||||
|
||||
if math_random(1,3) ~= 1 then
|
||||
local step_length = wave_defense_table.unit_group_command_step_length
|
||||
|
||||
if math.random(1,3) ~= 1 then
|
||||
local side_target = false
|
||||
for _ = 1, 3, 1 do
|
||||
side_target = get_side_target()
|
||||
if side_target then break end
|
||||
end
|
||||
if side_target then
|
||||
local target_position = side_target.position
|
||||
local target_position = side_target.position
|
||||
local distance_to_target = math.floor(math.sqrt((target_position.x - group_position.x) ^ 2 + (target_position.y - group_position.y) ^ 2))
|
||||
local steps = math.floor(distance_to_target / step_length) + 1
|
||||
local vector = {math.round((target_position.x - group_position.x) / steps, 3), math.round((target_position.y - group_position.y) / steps, 3)}
|
||||
|
||||
if global.wave_defense.debug then
|
||||
|
||||
if wave_defense_table.debug then
|
||||
debug_print("get_commmands - to side_target x" .. side_target.position.x .. " y" .. side_target.position.y)
|
||||
debug_print("get_commmands - distance_to_target:" .. distance_to_target .. " steps:" .. steps)
|
||||
debug_print("get_commmands - vector " .. vector[1] .. "_" .. vector[2])
|
||||
end
|
||||
|
||||
|
||||
for i = 1, steps, 1 do
|
||||
group_position.x = group_position.x + vector[1]
|
||||
group_position.y = group_position.y + vector[2]
|
||||
@ -288,31 +308,31 @@ local function get_commmands(group)
|
||||
radius = 16,
|
||||
distraction = defines.distraction.by_anything
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
commands[#commands + 1] = {
|
||||
type = defines.command.attack,
|
||||
target = side_target,
|
||||
distraction = defines.distraction.by_enemy,
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local target_position = global.wave_defense.target.position
|
||||
|
||||
local target_position = wave_defense_table.target.position
|
||||
local distance_to_target = math.floor(math.sqrt((target_position.x - group_position.x) ^ 2 + (target_position.y - group_position.y) ^ 2))
|
||||
local steps = math.floor(distance_to_target / step_length) + 1
|
||||
local vector = {math.round((target_position.x - group_position.x) / steps, 3), math.round((target_position.y - group_position.y) / steps, 3)}
|
||||
|
||||
if global.wave_defense.debug then
|
||||
|
||||
if wave_defense_table.debug then
|
||||
debug_print("get_commmands - to main target x" .. target_position.x .. " y" .. target_position.y)
|
||||
debug_print("get_commmands - distance_to_target:" .. distance_to_target .. " steps:" .. steps)
|
||||
debug_print("get_commmands - vector " .. vector[1] .. "_" .. vector[2])
|
||||
end
|
||||
|
||||
|
||||
for i = 1, steps, 1 do
|
||||
group_position.x = group_position.x + vector[1]
|
||||
group_position.y = group_position.y + vector[2]
|
||||
group_position.y = group_position.y + vector[2]
|
||||
local position = group.surface.find_non_colliding_position("small-biter", group_position, step_length, 1)
|
||||
if position then
|
||||
commands[#commands + 1] = {
|
||||
@ -321,28 +341,32 @@ local function get_commmands(group)
|
||||
radius = 16,
|
||||
distraction = defines.distraction.by_anything
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
commands[#commands + 1] = {
|
||||
type = defines.command.attack_area,
|
||||
destination = {x = target_position.x, y = target_position.y},
|
||||
radius = 8,
|
||||
distraction = defines.distraction.by_enemy
|
||||
}
|
||||
|
||||
|
||||
commands[#commands + 1] = {
|
||||
type = defines.command.attack,
|
||||
target = global.wave_defense.target,
|
||||
target = wave_defense_table.target,
|
||||
distraction = defines.distraction.by_enemy,
|
||||
}
|
||||
|
||||
|
||||
return commands
|
||||
end
|
||||
|
||||
local function command_unit_group(group)
|
||||
if global.wave_defense.unit_group_last_command[group.group_number] then
|
||||
if global.wave_defense.unit_group_last_command[group.group_number] + global.wave_defense.unit_group_command_delay > game.tick then return end
|
||||
local wave_defense_table = WD.get_table()
|
||||
if not wave_defense_table.unit_group_last_command[group.group_number] then
|
||||
wave_defense_table.unit_group_last_command[group.group_number] = game.tick - (wave_defense_table.unit_group_command_delay + 1)
|
||||
end
|
||||
if wave_defense_table.unit_group_last_command[group.group_number] then
|
||||
if wave_defense_table.unit_group_last_command[group.group_number] + wave_defense_table.unit_group_command_delay > game.tick then return end
|
||||
end
|
||||
|
||||
group.set_command({
|
||||
@ -351,59 +375,62 @@ local function command_unit_group(group)
|
||||
commands = get_commmands(group)
|
||||
})
|
||||
|
||||
global.wave_defense.unit_group_last_command[group.group_number] = game.tick
|
||||
wave_defense_table.unit_group_last_command[group.group_number] = game.tick
|
||||
end
|
||||
|
||||
local function give_commands_to_unit_groups()
|
||||
if #global.wave_defense.unit_groups == 0 then return end
|
||||
if not global.wave_defense.target then return end
|
||||
if not global.wave_defense.target.valid then return end
|
||||
for k, group in pairs(global.wave_defense.unit_groups) do
|
||||
local wave_defense_table = WD.get_table()
|
||||
if #wave_defense_table.unit_groups == 0 then return end
|
||||
if not wave_defense_table.target then return end
|
||||
if not wave_defense_table.target.valid then return end
|
||||
for k, group in pairs(wave_defense_table.unit_groups) do
|
||||
if group.valid then
|
||||
command_unit_group(group)
|
||||
else
|
||||
table.remove(global.wave_defense.unit_groups, k)
|
||||
--global.wave_defense.unit_groups[k] = nil
|
||||
table.remove(wave_defense_table.unit_groups, k)
|
||||
--wave_defense_table.unit_groups[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function spawn_unit_group()
|
||||
local wave_defense_table = WD.get_table()
|
||||
if not can_units_spawn() then return end
|
||||
if not global.wave_defense.target then return end
|
||||
if not global.wave_defense.target.valid then return end
|
||||
if get_active_unit_groups_count() >= global.wave_defense.max_active_unit_groups then return end
|
||||
if not wave_defense_table.target then return end
|
||||
if not wave_defense_table.target.valid then return end
|
||||
if get_active_unit_groups_count() >= wave_defense_table.max_active_unit_groups then return end
|
||||
|
||||
wave_defense_set_unit_raffle(global.wave_defense.wave_number)
|
||||
BiterRolls.wave_defense_set_unit_raffle(wave_defense_table.wave_number)
|
||||
|
||||
local surface = game.surfaces[global.wave_defense.surface_index]
|
||||
local surface = game.surfaces[wave_defense_table.surface_index]
|
||||
set_group_spawn_position(surface)
|
||||
debug_print("Spawning unit group at x" .. global.wave_defense.spawn_position.x .." y" .. global.wave_defense.spawn_position.y)
|
||||
local unit_group = surface.create_unit_group({position = global.wave_defense.spawn_position, force = "enemy"})
|
||||
for a = 1, global.wave_defense.group_size, 1 do
|
||||
debug_print("Spawning unit group at x" .. wave_defense_table.spawn_position.x .." y" .. wave_defense_table.spawn_position.y)
|
||||
local unit_group = surface.create_unit_group({position = wave_defense_table.spawn_position, force = "enemy"})
|
||||
for a = 1, wave_defense_table.group_size, 1 do
|
||||
local biter = spawn_biter(surface)
|
||||
if not biter then break end
|
||||
unit_group.add_member(biter)
|
||||
end
|
||||
--command_unit_group(unit_group)
|
||||
|
||||
table.insert(global.wave_defense.unit_groups, unit_group)
|
||||
table.insert(wave_defense_table.unit_groups, unit_group)
|
||||
--[[
|
||||
for i = 1, #global.wave_defense.unit_groups, 1 do
|
||||
if not global.wave_defense.unit_groups[i] then
|
||||
global.wave_defense.unit_groups[i] = unit_group
|
||||
for i = 1, #wave_defense_table.unit_groups, 1 do
|
||||
if not wave_defense_table.unit_groups[i] then
|
||||
wave_defense_table.unit_groups[i] = unit_group
|
||||
return true
|
||||
end
|
||||
end
|
||||
global.wave_defense.unit_groups[#global.wave_defense.unit_groups + 1] = unit_group
|
||||
wave_defense_table.unit_groups[#wave_defense_table.unit_groups + 1] = unit_group
|
||||
]]
|
||||
return true
|
||||
end
|
||||
|
||||
local function log_threat()
|
||||
global.wave_defense.threat_log_index = global.wave_defense.threat_log_index + 1
|
||||
global.wave_defense.threat_log[global.wave_defense.threat_log_index] = global.wave_defense.threat
|
||||
if global.wave_defense.threat_log_index > 900 then global.wave_defense.threat_log[global.wave_defense.threat_log_index - 901] = nil end
|
||||
local wave_defense_table = WD.get_table()
|
||||
wave_defense_table.threat_log_index = wave_defense_table.threat_log_index + 1
|
||||
wave_defense_table.threat_log[wave_defense_table.threat_log_index] = wave_defense_table.threat
|
||||
if wave_defense_table.threat_log_index > 900 then wave_defense_table.threat_log[wave_defense_table.threat_log_index - 901] = nil end
|
||||
end
|
||||
|
||||
local tick_tasks = {
|
||||
@ -411,17 +438,18 @@ local tick_tasks = {
|
||||
[60] = set_enemy_evolution,
|
||||
[90] = spawn_unit_group,
|
||||
[120] = give_commands_to_unit_groups,
|
||||
[150] = build_nest,
|
||||
[180] = build_worm,
|
||||
[150] = ThreatEvent.build_nest,
|
||||
[180] = ThreatEvent.build_worm,
|
||||
[1800] = set_side_target_list,
|
||||
[3600] = time_out_biters,
|
||||
[7200] = refresh_active_unit_threat,
|
||||
}
|
||||
|
||||
local function on_tick()
|
||||
if global.wave_defense.game_lost then return end
|
||||
local wave_defense_table = WD.get_table()
|
||||
if wave_defense_table.game_lost then return end
|
||||
|
||||
if game.tick > global.wave_defense.next_wave then set_next_wave() end
|
||||
if game.tick > wave_defense_table.next_wave then set_next_wave() end
|
||||
|
||||
local t = game.tick % 300
|
||||
local t2 = game.tick % 18000
|
||||
@ -433,46 +461,10 @@ local function on_tick()
|
||||
for _, player in pairs(game.connected_players) do update_gui(player) end
|
||||
end
|
||||
|
||||
function reset_wave_defense()
|
||||
global.wave_defense = {
|
||||
active_biter_count = 0,
|
||||
active_biter_threat = 0,
|
||||
active_biters = {},
|
||||
debug = false,
|
||||
game_lost = false,
|
||||
get_random_close_spawner_attempts = 5,
|
||||
group_size = 2,
|
||||
last_wave = game.tick,
|
||||
max_active_biters = 1024,
|
||||
max_active_unit_groups = 6,
|
||||
max_biter_age = 3600 * 60,
|
||||
max_group_size = 192,
|
||||
nest_building_chance = 4, --high value = less chance
|
||||
nest_building_density = 64, --lower values = more dense building
|
||||
next_wave = game.tick + 3600 * 15,
|
||||
side_target_search_radius = 768,
|
||||
simple_entity_shredding_cost_modifier = 0.01, --threat cost for one health
|
||||
spawn_position = {x = 0, y = 64},
|
||||
surface_index = 1,
|
||||
threat = 0,
|
||||
threat_log = {},
|
||||
threat_log_index = 0,
|
||||
threat_gain_multiplier = 2,
|
||||
unit_group_command_delay = 3600 * 15,
|
||||
unit_group_command_step_length = 64,
|
||||
unit_group_last_command = {},
|
||||
unit_groups = {},
|
||||
wave_interval = 3600,
|
||||
wave_number = 0,
|
||||
worm_building_chance = 3, --high value = less chance
|
||||
worm_building_density = 16, --lower values = more dense building
|
||||
}
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
reset_wave_defense()
|
||||
local wave_defense_table = WD.get_table()
|
||||
wave_defense_table.reset_wave_defense()
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.on_nth_tick(30, on_tick)
|
||||
event.on_init(on_init)
|
||||
return Public
|
63
modules/wave_defense/table.lua
Normal file
63
modules/wave_defense/table.lua
Normal file
@ -0,0 +1,63 @@
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
|
||||
local wave_defense = {}
|
||||
local Public = {}
|
||||
|
||||
Global.register(
|
||||
wave_defense,
|
||||
function(tbl)
|
||||
wave_defense = tbl
|
||||
end
|
||||
)
|
||||
|
||||
function Public.reset_wave_defense()
|
||||
wave_defense.active_biter_count = 0
|
||||
wave_defense.active_biter_threat = 0
|
||||
wave_defense.active_biters = {}
|
||||
wave_defense.biter_raffle = {}
|
||||
wave_defense.debug = false
|
||||
wave_defense.game_lost = false
|
||||
wave_defense.get_random_close_spawner_attempts = 5
|
||||
wave_defense.group_size = 2
|
||||
wave_defense.last_wave = game.tick
|
||||
wave_defense.max_active_biters = 1024
|
||||
wave_defense.max_active_unit_groups = 6
|
||||
wave_defense.max_biter_age = 3600 * 60
|
||||
wave_defense.max_group_size = 192
|
||||
wave_defense.nest_building_chance = 4
|
||||
wave_defense.nest_building_density = 64
|
||||
wave_defense.next_wave = game.tick + 3600 * 15
|
||||
wave_defense.side_targets = {}
|
||||
wave_defense.side_target_search_radius = 768
|
||||
wave_defense.simple_entity_shredding_cost_modifier = 0.01
|
||||
wave_defense.spawn_position = {x = 0, y = 64}
|
||||
wave_defense.spitter_raffle = {}
|
||||
wave_defense.surface_index = 1
|
||||
wave_defense.target = nil
|
||||
wave_defense.threat = 0
|
||||
wave_defense.threat_log = {}
|
||||
wave_defense.threat_log_index = 0
|
||||
wave_defense.threat_gain_multiplier = 2
|
||||
wave_defense.unit_group_command_delay = 3600 * 15
|
||||
wave_defense.unit_group_command_step_length = 32
|
||||
wave_defense.unit_group_last_command = {}
|
||||
wave_defense.unit_groups = {}
|
||||
wave_defense.wave_interval = 3600
|
||||
wave_defense.wave_number = 0
|
||||
wave_defense.worm_building_chance = 3
|
||||
wave_defense.worm_building_density = 16
|
||||
wave_defense.worm_raffle = {}
|
||||
end
|
||||
|
||||
function Public.get_table()
|
||||
return wave_defense
|
||||
end
|
||||
|
||||
local on_init = function ()
|
||||
Public.reset_wave_defense()
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
|
||||
return Public
|
@ -1,18 +1,24 @@
|
||||
local WD = require "modules.wave_defense.table"
|
||||
local threat_values = require "modules.wave_defense.threat_values"
|
||||
local BiterRolls = require 'modules.wave_defense.biter_rolls'
|
||||
local math_random = math.random
|
||||
|
||||
local Public = {}
|
||||
|
||||
local function remove_unit(entity)
|
||||
if not global.wave_defense.active_biters[entity.unit_number] then return end
|
||||
global.wave_defense.active_biter_threat = global.wave_defense.active_biter_threat - math.round(threat_values[entity.name] * global.biter_health_boost, 2)
|
||||
global.wave_defense.active_biter_count = global.wave_defense.active_biter_count - 1
|
||||
global.wave_defense.active_biters[entity.unit_number] = nil
|
||||
local wave_defense_table = WD.get_table()
|
||||
if not wave_defense_table.active_biters[entity.unit_number] then return end
|
||||
wave_defense_table.active_biter_threat = wave_defense_table.active_biter_threat - math.round(threat_values[entity.name] * global.biter_health_boost, 2)
|
||||
wave_defense_table.active_biter_count = wave_defense_table.active_biter_count - 1
|
||||
wave_defense_table.active_biters[entity.unit_number] = nil
|
||||
end
|
||||
|
||||
function build_nest()
|
||||
if global.wave_defense.threat < 1000 then return end
|
||||
if math_random(1, global.wave_defense.nest_building_chance) ~= 1 then return end
|
||||
if #global.wave_defense.unit_groups == 0 then return end
|
||||
local group = global.wave_defense.unit_groups[math_random(1, #global.wave_defense.unit_groups)]
|
||||
function Public.build_nest()
|
||||
local wave_defense_table = WD.get_table()
|
||||
if wave_defense_table.threat < 1000 then return end
|
||||
if math_random(1, wave_defense_table.nest_building_chance) ~= 1 then return end
|
||||
if #wave_defense_table.unit_groups == 0 then return end
|
||||
local group = wave_defense_table.unit_groups[math_random(1, #wave_defense_table.unit_groups)]
|
||||
if not group then return end
|
||||
if not group.valid then return end
|
||||
if not group.members then return end
|
||||
@ -21,39 +27,39 @@ function build_nest()
|
||||
if not unit.valid then return end
|
||||
local position = unit.surface.find_non_colliding_position("biter-spawner", unit.position, 16, 1)
|
||||
if not position then return end
|
||||
local r = global.wave_defense.nest_building_density
|
||||
local r = wave_defense_table.nest_building_density
|
||||
if unit.surface.count_entities_filtered({type = "unit-spawner", area = {{position.x - r, position.y - r},{position.x + r, position.y + r}}}) > 0 then return end
|
||||
unit.surface.create_entity({name = "biter-spawner", position = position, force = unit.force})
|
||||
unit.surface.create_entity({name = "blood-explosion-huge", position = position})
|
||||
unit.surface.create_entity({name = "blood-explosion-huge", position = unit.position})
|
||||
remove_unit(unit)
|
||||
unit.destroy()
|
||||
global.wave_defense.threat = global.wave_defense.threat - 500
|
||||
wave_defense_table.threat = wave_defense_table.threat - 500
|
||||
end
|
||||
|
||||
function build_worm()
|
||||
if global.wave_defense.threat < 1000 then return end
|
||||
if math_random(1, global.wave_defense.worm_building_chance) ~= 1 then return end
|
||||
if #global.wave_defense.unit_groups == 0 then return end
|
||||
local group = global.wave_defense.unit_groups[math_random(1, #global.wave_defense.unit_groups)]
|
||||
function Public.build_worm()
|
||||
local wave_defense_table = WD.get_table()
|
||||
if wave_defense_table.threat < 1000 then return end
|
||||
if math_random(1, wave_defense_table.worm_building_chance) ~= 1 then return end
|
||||
if #wave_defense_table.unit_groups == 0 then return end
|
||||
local group = wave_defense_table.unit_groups[math_random(1, #wave_defense_table.unit_groups)]
|
||||
if not group then return end
|
||||
if not group.valid then return end
|
||||
if not group.members then return end
|
||||
if not group.members[1] then return end
|
||||
local unit = group.members[math_random(1, #group.members)]
|
||||
if not unit.valid then return end
|
||||
wave_defense_set_worm_raffle(global.wave_defense.wave_number)
|
||||
local worm = wave_defense_roll_worm_name()
|
||||
local position = unit.surface.find_non_colliding_position("assembling-machine-1", unit.position, 8, 1)
|
||||
local worm = BiterRolls.wave_defense_roll_worm_name()
|
||||
if not position then return end
|
||||
local r = global.wave_defense.worm_building_density
|
||||
local r = wave_defense_table.worm_building_density
|
||||
if unit.surface.count_entities_filtered({type = "turret", area = {{position.x - r, position.y - r},{position.x + r, position.y + r}}}) > 0 then return end
|
||||
unit.surface.create_entity({name = worm, position = position, force = unit.force})
|
||||
unit.surface.create_entity({name = "blood-explosion-huge", position = position})
|
||||
unit.surface.create_entity({name = "blood-explosion-huge", position = unit.position})
|
||||
remove_unit(unit)
|
||||
unit.destroy()
|
||||
global.wave_defense.threat = global.wave_defense.threat - threat_values[worm]
|
||||
wave_defense_table.threat = wave_defense_table.threat - threat_values[worm]
|
||||
end
|
||||
|
||||
local function get_circle_vectors(radius)
|
||||
@ -76,9 +82,9 @@ local acid_nova_entities = {
|
||||
}
|
||||
|
||||
local function acid_nova(entity)
|
||||
local wave_defense_table = WD.get_table()
|
||||
if not acid_nova_entities[entity.name] then return end
|
||||
if global.wave_defense.threat < 1000000 then return end
|
||||
if math_random(1, 32) ~= 1 then return end
|
||||
if wave_defense_table.threat < 100000 then return end
|
||||
for _ = 1, acid_nova_entities[entity.name].amount, 1 do
|
||||
local i = math_random(1, #acid_nova_entities[entity.name].vectors)
|
||||
entity.surface.create_entity({
|
||||
@ -91,16 +97,17 @@ local function acid_nova(entity)
|
||||
speed = 0.001
|
||||
})
|
||||
end
|
||||
global.wave_defense.threat = global.wave_defense.threat - acid_nova_entities[entity.name].threat_cost
|
||||
wave_defense_table.threat = wave_defense_table.threat - acid_nova_entities[entity.name].threat_cost
|
||||
return true
|
||||
end
|
||||
|
||||
local function shred_simple_entities(entity)
|
||||
if global.wave_defense.threat < 25000 then return end
|
||||
local wave_defense_table = WD.get_table()
|
||||
if wave_defense_table.threat < 25000 then return end
|
||||
local simple_entities = entity.surface.find_entities_filtered({type = "simple-entity", area = {{entity.position.x - 3, entity.position.y - 3},{entity.position.x + 3, entity.position.y + 3}}})
|
||||
if #simple_entities == 0 then return end
|
||||
if #simple_entities > 1 then table.shuffle_table(simple_entities) end
|
||||
local r = math.floor(global.wave_defense.threat * 0.00004)
|
||||
local r = math.floor(wave_defense_table.threat * 0.00004)
|
||||
if r < 1 then r = 1 end
|
||||
local count = math.random(1, r)
|
||||
--local count = 1
|
||||
@ -115,24 +122,25 @@ local function shred_simple_entities(entity)
|
||||
end
|
||||
end
|
||||
if damage_dealt == 0 then return end
|
||||
local threat_cost = math.floor(damage_dealt * global.wave_defense.simple_entity_shredding_cost_modifier)
|
||||
local threat_cost = math.floor(damage_dealt * wave_defense_table.simple_entity_shredding_cost_modifier)
|
||||
if threat_cost < 1 then threat_cost = 1 end
|
||||
global.wave_defense.threat = global.wave_defense.threat - threat_cost
|
||||
wave_defense_table.threat = wave_defense_table.threat - threat_cost
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local wave_defense_table = WD.get_table()
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
|
||||
if entity.type == "unit" then
|
||||
global.wave_defense.threat = math.round(global.wave_defense.threat - threat_values[entity.name] * global.biter_health_boost, 2)
|
||||
wave_defense_table.threat = math.round(wave_defense_table.threat - threat_values[entity.name] * global.biter_health_boost, 2)
|
||||
remove_unit(entity)
|
||||
acid_nova(entity)
|
||||
else
|
||||
if entity.force.index == 2 then
|
||||
if entity.health then
|
||||
if threat_values[entity.name] then
|
||||
global.wave_defense.threat = global.wave_defense.threat - threat_values[entity.name]
|
||||
wave_defense_table.threat = wave_defense_table.threat - threat_values[entity.name]
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -150,4 +158,6 @@ local function on_entity_died(event)
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
|
||||
return Public
|
@ -9,9 +9,9 @@ local t = {
|
||||
["medium-spitter"] = 4,
|
||||
["small-biter"] = 1,
|
||||
["small-spitter"] = 1,
|
||||
["small-worm-turret"] = 16,
|
||||
["medium-worm-turret"] = 32,
|
||||
["big-worm-turret"] = 48,
|
||||
["small-worm-turret"] = 16,
|
||||
["medium-worm-turret"] = 32,
|
||||
["big-worm-turret"] = 48,
|
||||
["behemoth-worm-turret"] = 64,
|
||||
}
|
||||
return t
|
@ -1,5 +1,7 @@
|
||||
--Central to add all player modifiers together.
|
||||
|
||||
local Public = {}
|
||||
|
||||
local modifiers = {
|
||||
"character_build_distance_bonus",
|
||||
"character_crafting_speed_modifier",
|
||||
@ -14,7 +16,7 @@ local modifiers = {
|
||||
"character_running_speed_modifier",
|
||||
}
|
||||
|
||||
function update_player_modifiers(player)
|
||||
function Public.update_player_modifiers(player)
|
||||
for _, modifier in pairs(modifiers) do
|
||||
local sum_value = 0
|
||||
for _, value in pairs(global.player_modifiers[player.index][modifier]) do
|
||||
@ -40,4 +42,6 @@ end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
|
||||
return Public
|
@ -1,6 +1,7 @@
|
||||
-- Dependencies
|
||||
local Game = require 'utils.game'
|
||||
local Color = require 'utils.color_presets'
|
||||
local Server = require 'utils.server'
|
||||
|
||||
-- localized functions
|
||||
local random = math.random
|
||||
@ -59,7 +60,7 @@ function Module.print_admins(msg, source)
|
||||
chat_color = source.chat_color
|
||||
end
|
||||
else
|
||||
source_name = 'server_commands'
|
||||
source_name = 'Server'
|
||||
chat_color = Color.yellow
|
||||
end
|
||||
local formatted_msg = {'utils_core.print_admins',prefix, source_name, msg}
|
||||
@ -76,7 +77,7 @@ function Module.get_actor()
|
||||
if game.player then
|
||||
return game.player.name
|
||||
end
|
||||
return '<server_commands>'
|
||||
return '<server>'
|
||||
end
|
||||
|
||||
function Module.cast_bool(var)
|
||||
@ -205,7 +206,7 @@ function Module.action_warning(warning_prefix, msg)
|
||||
game.print(prefix .. msg, Color.yellow)
|
||||
msg = format('%s %s', warning_prefix, msg)
|
||||
log(msg)
|
||||
server_commands_commands.to_discord_bold(msg)
|
||||
Server.to_discord_bold(msg)
|
||||
end
|
||||
|
||||
--- Takes msg and prints it to all players except provided player. Also prints to the log and discord
|
||||
@ -216,7 +217,7 @@ function Module.silent_action_warning(warning_prefix, msg, player)
|
||||
Module.print_except(prefix .. msg, player, Color.yellow)
|
||||
msg = format('%s %s', warning_prefix, msg)
|
||||
log(msg)
|
||||
server_commands.to_discord_bold(msg)
|
||||
Server.to_discord_bold(msg)
|
||||
end
|
||||
|
||||
-- add utility functions that exist in base factorio/util
|
||||
|
@ -130,7 +130,7 @@ local function draw_element_headers(element_panel, values, selected_index)
|
||||
ele_name = gui_name
|
||||
end
|
||||
|
||||
if ele_name:match('%d* %- features/gui/debug') then
|
||||
if ele_name:match('%d* %- utils/debug') then
|
||||
goto continue
|
||||
end
|
||||
|
||||
|
@ -71,6 +71,7 @@ local function inspect_process(item)
|
||||
return concat(luaEntity)
|
||||
elseif obj_type == 'LuaGuiElement' then
|
||||
local name = item.name
|
||||
if gui_names == nil then return end
|
||||
luaGuiElement[2] = gui_names[name] or name or 'nil'
|
||||
|
||||
return concat(luaGuiElement)
|
||||
|
Loading…
Reference in New Issue
Block a user