mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-24 03:47:58 +02:00
commit
b652800f65
@ -90,6 +90,25 @@ local functions = {
|
||||
end,
|
||||
}
|
||||
|
||||
local poll_function = {
|
||||
["comfy_panel_poll_trusted_toggle"] = function(event)
|
||||
if event.element.switch_state == "left" then
|
||||
global.comfy_panel_config.poll_trusted = true
|
||||
else
|
||||
global.comfy_panel_config.poll_trusted = false
|
||||
end
|
||||
end,
|
||||
["comfy_panel_poll_no_notify_toggle"] = function(event)
|
||||
local poll = package.loaded['comfy_panel.poll']
|
||||
local poll_table = poll.get_no_notify_players()
|
||||
if event.element.switch_state == "left" then
|
||||
poll_table[event.player_index] = false
|
||||
else
|
||||
poll_table[event.player_index] = true
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
local function add_switch(element, switch_state, name, description_main, description)
|
||||
local t = element.add({type = "table", column_count = 5})
|
||||
local label = t.add({type = "label", caption = "ON"})
|
||||
@ -149,6 +168,15 @@ local build_config_gui = (function (player, frame)
|
||||
frame.add({type = "line"})
|
||||
end
|
||||
|
||||
if package.loaded['comfy_panel.poll'] then
|
||||
local poll = package.loaded['comfy_panel.poll']
|
||||
local poll_table = poll.get_no_notify_players()
|
||||
local switch_state = "right"
|
||||
if not poll_table[player.index] then switch_state = "left" end
|
||||
local switch = add_switch(frame, switch_state, "comfy_panel_poll_no_notify_toggle", "Notify on polls", "Receive a message when new polls are created and popup the poll.")
|
||||
frame.add({type = "line"})
|
||||
end
|
||||
|
||||
local label = frame.add({type = "label", caption = "Admin Settings"})
|
||||
label.style.font = "default-bold"
|
||||
label.style.padding = 0
|
||||
@ -172,6 +200,14 @@ local build_config_gui = (function (player, frame)
|
||||
local switch = add_switch(frame, switch_state, "comfy_panel_spaghett_toggle", "Spaghett Mode", "Disables the Logistic System research.\nRequester, buffer or active-provider containers can not be built.")
|
||||
if not admin then switch.ignored_by_interaction = true end
|
||||
|
||||
if package.loaded['comfy_panel.poll'] then
|
||||
frame.add({type = "line"})
|
||||
local switch_state = "right"
|
||||
if global.comfy_panel_config.poll_trusted then switch_state = "left" end
|
||||
local switch = add_switch(frame, switch_state, "comfy_panel_poll_trusted_toggle", "Poll mode", "Disables non-trusted plebs to create polls.")
|
||||
if not admin then switch.ignored_by_interaction = true end
|
||||
end
|
||||
|
||||
frame.add({type = "line"})
|
||||
|
||||
for _, e in pairs(frame.children) do
|
||||
@ -188,6 +224,11 @@ local function on_gui_switch_state_changed(event)
|
||||
if functions[event.element.name] then
|
||||
functions[event.element.name](event)
|
||||
return
|
||||
elseif package.loaded['comfy_panel.poll'] then
|
||||
if poll_function[event.element.name] then
|
||||
poll_function[event.element.name](event)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -207,6 +248,7 @@ local function on_init()
|
||||
global.comfy_panel_config = {}
|
||||
global.comfy_panel_config.spaghett = {}
|
||||
global.comfy_panel_config.spaghett.undo = {}
|
||||
global.comfy_panel_config.poll_trusted = false
|
||||
end
|
||||
|
||||
comfy_panel_tabs["Config"] = {gui = build_config_gui, admin = false}
|
||||
|
@ -6,6 +6,8 @@ local Server = require 'utils.server'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local session = require 'utils.session_data'
|
||||
|
||||
local Class = {}
|
||||
|
||||
local insert = table.insert
|
||||
|
||||
local default_poll_duration = 300 * 60 -- in ticks
|
||||
@ -223,7 +225,6 @@ local function redraw_poll_viewer_content(data)
|
||||
local poll_enabled = do_remaining_time(poll, remaining_time_label)
|
||||
|
||||
local question_flow = poll_viewer_content.add {type = 'table', column_count = 2}
|
||||
|
||||
if trusted[player.name] or player.admin then
|
||||
local edit_button =
|
||||
question_flow.add {
|
||||
@ -371,6 +372,7 @@ local function draw_main_frame(left, player)
|
||||
|
||||
update_poll_viewer(data)
|
||||
|
||||
--[[
|
||||
frame.add {
|
||||
type = 'checkbox',
|
||||
name = notify_checkbox_name,
|
||||
@ -378,6 +380,7 @@ local function draw_main_frame(left, player)
|
||||
state = not no_notify_players[player.index],
|
||||
tooltip = 'Receive a message when new polls are created and popup the poll.'
|
||||
}
|
||||
]]--
|
||||
|
||||
local bottom_flow = frame.add {type = 'flow', direction = 'horizontal'}
|
||||
|
||||
@ -391,7 +394,7 @@ local function draw_main_frame(left, player)
|
||||
local right_flow = bottom_flow.add {type = 'flow'}
|
||||
right_flow.style.horizontal_align = 'right'
|
||||
|
||||
if trusted[player.name] or player.admin then
|
||||
if (trusted[player.name] or player.admin) or global.comfy_panel_config.poll_trusted == false then
|
||||
local create_poll_button =
|
||||
right_flow.add {type = 'button', name = create_poll_button_name, caption = 'Create Poll'}
|
||||
apply_button_style(create_poll_button)
|
||||
@ -825,6 +828,11 @@ local function player_joined(event)
|
||||
end
|
||||
|
||||
local function tick()
|
||||
for _, v in pairs(polls) do
|
||||
if game.tick >= v.end_tick then
|
||||
return
|
||||
end
|
||||
end
|
||||
for _, p in pairs(game.connected_players) do
|
||||
local frame = p.gui.left[main_frame_name]
|
||||
if frame and frame.valid then
|
||||
@ -1012,6 +1020,7 @@ Gui.on_click(
|
||||
end
|
||||
|
||||
update_poll_viewer(main_frame_data)
|
||||
toggle(event)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1182,7 +1191,31 @@ Gui.on_click(poll_view_vote_name, vote)
|
||||
|
||||
Gui.allow_player_to_toggle_top_element_visibility(main_button_name)
|
||||
|
||||
local Class = {}
|
||||
function Class.reset()
|
||||
for k, _ in pairs(polls) do
|
||||
polls[k] = nil
|
||||
end
|
||||
for k, _ in pairs(player_poll_index) do
|
||||
player_poll_index[k] = nil
|
||||
end
|
||||
for k, _ in pairs(player_create_poll_data) do
|
||||
player_create_poll_data[k] = nil
|
||||
end
|
||||
for _, p in pairs(game.connected_players) do
|
||||
local main_frame = p.gui.left[main_frame_name]
|
||||
if main_frame and main_frame.valid then
|
||||
local main_frame_data = Gui.get_data(main_frame)
|
||||
local poll_index = main_frame_data.poll_index
|
||||
update_poll_viewer(main_frame_data)
|
||||
remove_main_frame(main_frame, p.gui.left, p)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Class.get_no_notify_players()
|
||||
log(serpent.block(no_notify_players))
|
||||
return no_notify_players
|
||||
end
|
||||
|
||||
function Class.validate(data)
|
||||
if type(data) ~= 'table' then
|
||||
|
@ -1,8 +1,22 @@
|
||||
--scoreboard by mewmew
|
||||
|
||||
local event = require 'utils.event'
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
|
||||
local Public = {}
|
||||
local this = {
|
||||
score_table = {},
|
||||
sort_by = {}
|
||||
}
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(t)
|
||||
this = t
|
||||
end
|
||||
)
|
||||
|
||||
local sorting_symbol = {ascending = "▲", descending = "▼"}
|
||||
local building_and_mining_blacklist = {
|
||||
["tile-ghost"] = true,
|
||||
@ -10,12 +24,30 @@ local building_and_mining_blacklist = {
|
||||
["item-entity"] = true,
|
||||
}
|
||||
|
||||
function Public.get_table()
|
||||
return this
|
||||
end
|
||||
|
||||
local function init_player_table(player)
|
||||
if not player then return end
|
||||
if not this.score_table[player.force.name] then this.score_table[player.force.name] = {} end
|
||||
if not this.score_table[player.force.name].players then this.score_table[player.force.name].players = {} end
|
||||
if not this.score_table[player.force.name].players[player.name] then
|
||||
this.score_table[player.force.name].players[player.name] = {
|
||||
built_entities = 0,
|
||||
deaths = 0,
|
||||
killscore = 0,
|
||||
mined_entities = 0,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local function get_score_list(force)
|
||||
local score = global.score[force]
|
||||
local score_force = this.score_table[force]
|
||||
local score_list = {}
|
||||
for _, p in pairs(game.connected_players) do
|
||||
if score.players[p.name] then
|
||||
local score = score.players[p.name]
|
||||
if score_force.players[p.name] then
|
||||
local score = score_force.players[p.name]
|
||||
table.insert(score_list, {
|
||||
name = p.name,
|
||||
killscore = score.killscore or 0,
|
||||
@ -47,7 +79,7 @@ local function get_total_biter_killcount(force)
|
||||
end
|
||||
|
||||
local function add_global_stats(frame, player)
|
||||
local score = global.score[player.force.name]
|
||||
local score = this.score_table[player.force.name]
|
||||
local t = frame.add { type = "table", column_count = 5}
|
||||
|
||||
local l = t.add { type = "label", caption = "Rockets launched: "}
|
||||
@ -77,6 +109,8 @@ end
|
||||
local show_score = (function (player, frame)
|
||||
frame.clear()
|
||||
|
||||
init_player_table(player)
|
||||
|
||||
-- Global stats : rockets, biters kills
|
||||
add_global_stats(frame, player)
|
||||
|
||||
@ -97,7 +131,7 @@ local show_score = (function (player, frame)
|
||||
{ column = "mined_entities", name = "score_mined_entities", caption = "Mined entities" }
|
||||
}
|
||||
|
||||
local sorting_pref = global.score_sort_by[player.name]
|
||||
local sorting_pref = this.sort_by[player.name]
|
||||
for _, header in ipairs(headers) do
|
||||
local cap = header.caption
|
||||
|
||||
@ -175,27 +209,11 @@ local function refresh_score_full()
|
||||
end
|
||||
end
|
||||
|
||||
local function init_player_table(player)
|
||||
if not player then return end
|
||||
if not global.score[player.force.name] then global.score[player.force.name] = {} end
|
||||
if not global.score[player.force.name].players then global.score[player.force.name].players = {} end
|
||||
if not global.score[player.force.name].players[player.name] then
|
||||
global.score[player.force.name].players[player.name] = {
|
||||
built_entities = 0,
|
||||
deaths = 0,
|
||||
killscore = 0,
|
||||
mined_entities = 0,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if not global.score then global.score = {} end
|
||||
init_player_table(player)
|
||||
if not global.score_sort_by then global.score_sort_by = {} end
|
||||
if not global.score_sort_by[player.name] then
|
||||
global.score_sort_by[player.name] = {method = "descending", column = "killscore"}
|
||||
if not this.sort_by[player.name] then
|
||||
this.sort_by[player.name] = {method = "descending", column = "killscore"}
|
||||
end
|
||||
if not global.show_floating_killscore then global.show_floating_killscore = {} end
|
||||
if not global.show_floating_killscore[player.name] then global.show_floating_killscore[player.name] = false end
|
||||
@ -228,7 +246,7 @@ local function on_gui_click(event)
|
||||
}
|
||||
local column = element_to_column[name]
|
||||
if column then
|
||||
local sorting_pref = global.score_sort_by[player.name]
|
||||
local sorting_pref = this.sort_by[player.name]
|
||||
if sorting_pref.column == column and sorting_pref.method == "descending" then
|
||||
sorting_pref.method = "ascending"
|
||||
else
|
||||
@ -320,7 +338,7 @@ local function on_entity_died(event)
|
||||
if #players_to_reward == 0 then return end
|
||||
for _, player in pairs(players_to_reward) do
|
||||
init_player_table(player)
|
||||
local score = global.score[player.force.name].players[player.name]
|
||||
local score = this.score_table[player.force.name].players[player.name]
|
||||
score.killscore = score.killscore + entity_score_values[event.entity.name]
|
||||
if global.show_floating_killscore[player.name] then
|
||||
event.entity.surface.create_entity({name = "flying-text", position = event.entity.position, text = tostring(entity_score_values[event.entity.name]), color = player.chat_color})
|
||||
@ -331,7 +349,7 @@ end
|
||||
local function on_player_died(event)
|
||||
local player = game.players[event.player_index]
|
||||
init_player_table(player)
|
||||
local score = global.score[player.force.name].players[player.name]
|
||||
local score = this.score_table[player.force.name].players[player.name]
|
||||
score.deaths = 1 + (score.deaths or 0)
|
||||
end
|
||||
|
||||
@ -341,7 +359,7 @@ local function on_player_mined_entity(event)
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
init_player_table(player)
|
||||
local score = global.score[player.force.name].players[player.name]
|
||||
local score = this.score_table[player.force.name].players[player.name]
|
||||
score.mined_entities = 1 + (score.mined_entities or 0)
|
||||
end
|
||||
|
||||
@ -350,16 +368,19 @@ local function on_built_entity(event)
|
||||
if building_and_mining_blacklist[event.created_entity.type] then return end
|
||||
local player = game.players[event.player_index]
|
||||
init_player_table(player)
|
||||
local score = global.score[player.force.name].players[player.name]
|
||||
local score = this.score_table[player.force.name].players[player.name]
|
||||
score.built_entities = 1 + (score.built_entities or 0)
|
||||
end
|
||||
|
||||
comfy_panel_tabs["Scoreboard"] = {gui = show_score, admin = false}
|
||||
|
||||
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
event.add(defines.events.on_player_died, on_player_died)
|
||||
event.add(defines.events.on_built_entity, on_built_entity)
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_rocket_launched, on_rocket_launched)
|
||||
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
Event.add(defines.events.on_player_died, on_player_died)
|
||||
Event.add(defines.events.on_built_entity, on_built_entity)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_rocket_launched, on_rocket_launched)
|
||||
|
||||
|
||||
return Public
|
14
control.lua
14
control.lua
@ -36,9 +36,7 @@ require "modules.autostash"
|
||||
--require "modules.biters_double_damage"
|
||||
--require "modules.burden"
|
||||
--require "modules.comfylatron"
|
||||
--require "modules.spaghett_challenge"
|
||||
--require "modules.dangerous_goods"
|
||||
--require "modules.dynamic_landfill"
|
||||
--require "modules.explosive_biters"
|
||||
--require "modules.explosive_player_respawn"
|
||||
--require "modules.explosives_are_explosive"
|
||||
@ -56,13 +54,13 @@ require "modules.autostash"
|
||||
--require "modules.ores_are_mixed"
|
||||
--require "modules.team_teleport" --(REQUIRES "on_tick_schedule" !)
|
||||
--require "modules.surrounded_by_worms"
|
||||
--require "modules.more_attacks"
|
||||
--require "modules.evolution_extended"
|
||||
--require "modules.no_blueprint_library"
|
||||
--require "modules.explosives"
|
||||
--require "modules.biter_pets"
|
||||
--require "modules.no_solar"
|
||||
--require "modules.biter_reanimator"
|
||||
--require "modules.force_health_booster"
|
||||
--require "modules.immersive_cargo_wagons.main"
|
||||
--require "modules.wave_defense.main"
|
||||
--require "modules.fjei.main"
|
||||
-----------------------------
|
||||
@ -71,15 +69,12 @@ require "modules.autostash"
|
||||
--require "maps.chronosphere.main"
|
||||
--require "maps.fish_defender.main"
|
||||
--require "maps.biter_battles_v2.main"
|
||||
--require "maps.native_war.main"
|
||||
--require "maps.mountain_fortress_v2.main"
|
||||
--require "maps.dungeons.main"
|
||||
--require "maps.island_troopers.main"
|
||||
--require "maps.biter_hatchery.main"
|
||||
--require "maps.junkyard_pvp.main"
|
||||
--require "maps.scrapyard.main"
|
||||
--require "maps.tank_conquest.tank_conquest"
|
||||
--require "maps.territorial_control"
|
||||
--require "maps.cave_choppy.cave_miner"
|
||||
--require "maps.wave_of_death.WoD"
|
||||
--require "maps.planet_prison"
|
||||
@ -87,6 +82,7 @@ require "modules.autostash"
|
||||
--require "maps.choppy"
|
||||
--require "maps.overgrowth"
|
||||
--require "maps.quarters"
|
||||
--require "maps.railway_troopers_v2.main"
|
||||
--require "maps.railway_troopers.main"
|
||||
--require "maps.tetris.main"
|
||||
--require "maps.maze_challenge"
|
||||
@ -96,6 +92,10 @@ require "modules.autostash"
|
||||
--require "maps.hedge_maze"
|
||||
--require "maps.spooky_forest"
|
||||
--require "maps.mixed_railworld"
|
||||
--require "maps.scrap_railworld"
|
||||
--require "maps.tank_conquest.tank_conquest"
|
||||
--require "maps.native_war.main"
|
||||
--require "maps.territorial_control"
|
||||
--require "maps.biter_battles.biter_battles"
|
||||
--require "maps.fish_defender_v1.fish_defender"
|
||||
--require "maps.mountain_fortress"
|
||||
|
@ -1,6 +1,7 @@
|
||||
-- Biter Battles -- mewmew made this --
|
||||
|
||||
local Server = require 'utils.server'
|
||||
local Score = require "comfy_panel.score"
|
||||
require "on_tick_schedule"
|
||||
require "modules.splice_double"
|
||||
require "modules.explosive_biters"
|
||||
@ -80,8 +81,9 @@ local function get_sorted_list(column_name, score_list)
|
||||
end
|
||||
|
||||
local function get_mvps(force)
|
||||
if not global.score[force] then return false end
|
||||
local score = global.score[force]
|
||||
local get_score = Score.get_table().score_table
|
||||
if not get_score[force] then return false end
|
||||
local score = get_score[force]
|
||||
local score_list = {}
|
||||
for _, p in pairs(game.players) do
|
||||
if score.players[p.name] then
|
||||
@ -107,7 +109,8 @@ local function get_mvps(force)
|
||||
end
|
||||
|
||||
local function show_mvps(player)
|
||||
if not global.score then return end
|
||||
local get_score = Score.get_table().score_table
|
||||
if not get_score then return end
|
||||
if player.gui.left["mvps"] then return end
|
||||
local frame = player.gui.left.add({type = "frame", name = "mvps", direction = "vertical"})
|
||||
local l = frame.add({type = "label", caption = "MVPs - North:"})
|
||||
|
@ -1,6 +1,7 @@
|
||||
local Functions = require "maps.biter_battles_v2.functions"
|
||||
local Gui = require "maps.biter_battles_v2.gui"
|
||||
local Init = require "maps.biter_battles_v2.init"
|
||||
local Score = require "comfy_panel.score"
|
||||
local Server = require 'utils.server'
|
||||
|
||||
local math_random = math.random
|
||||
@ -147,8 +148,9 @@ local function get_sorted_list(column_name, score_list)
|
||||
end
|
||||
|
||||
local function get_mvps(force)
|
||||
if not global.score[force] then return false end
|
||||
local score = global.score[force]
|
||||
local get_score = Score.get_table().score_table
|
||||
if not get_score[force] then return false end
|
||||
local score = get_score[force]
|
||||
local score_list = {}
|
||||
for _, p in pairs(game.players) do
|
||||
if score.players[p.name] then
|
||||
@ -174,7 +176,8 @@ local function get_mvps(force)
|
||||
end
|
||||
|
||||
local function show_mvps(player)
|
||||
if not global.score then return end
|
||||
local get_score = Score.get_table().score_table
|
||||
if not get_score then return end
|
||||
if player.gui.left["mvps"] then return end
|
||||
local frame = player.gui.left.add({type = "frame", name = "mvps", direction = "vertical"})
|
||||
local l = frame.add({type = "label", caption = "MVPs - North:"})
|
||||
|
@ -1,5 +1,6 @@
|
||||
local Terrain = require "maps.biter_battles_v2.terrain"
|
||||
local Force_health_booster = require "modules.force_health_booster"
|
||||
local Score = require "comfy_panel.score"
|
||||
|
||||
local Public = {}
|
||||
|
||||
@ -124,8 +125,9 @@ function Public.source_surface()
|
||||
end
|
||||
|
||||
function Public.tables()
|
||||
local get_score = Score.get_table()
|
||||
Force_health_booster.reset_tables()
|
||||
global.score = {}
|
||||
get_score.score_table = {}
|
||||
global.science_logs_text = nil
|
||||
global.science_logs_total_north = nil
|
||||
global.science_logs_total_south = nil
|
||||
|
@ -1,4 +1,5 @@
|
||||
local Chrono_table = require 'maps.chronosphere.table'
|
||||
local Score = require "comfy_panel.score"
|
||||
local Public_chrono = {}
|
||||
|
||||
local Server = require 'utils.server'
|
||||
@ -25,6 +26,7 @@ function Public_chrono.get_map_gen_settings()
|
||||
end
|
||||
|
||||
function Public_chrono.restart_settings()
|
||||
local get_score = Score.get_table()
|
||||
local objective = Chrono_table.get_table()
|
||||
objective.max_health = 10000
|
||||
objective.health = 10000
|
||||
@ -59,7 +61,7 @@ function Public_chrono.restart_settings()
|
||||
global.friendly_fire_history = {}
|
||||
global.landfill_history = {}
|
||||
global.mining_history = {}
|
||||
global.score = {}
|
||||
get_score.score_table = {}
|
||||
global.difficulty_poll_closing_timeout = game.tick + 90000
|
||||
global.difficulty_player_votes = {}
|
||||
|
||||
|
@ -18,6 +18,7 @@ local Map = require "modules.map_info"
|
||||
local event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
local boss_biter = require "maps.fish_defender.boss_biters"
|
||||
local Score = require "comfy_panel.score"
|
||||
local math_random = math.random
|
||||
local insert = table.insert
|
||||
local enable_start_grace_period = true
|
||||
@ -660,8 +661,9 @@ local function get_sorted_list(column_name, score_list)
|
||||
end
|
||||
|
||||
local function get_mvps()
|
||||
if not global.score["player"] then return false end
|
||||
local score = global.score["player"]
|
||||
local get_score = Score.get_table().score_table
|
||||
if not get_score["player"] then return false end
|
||||
local score = get_score["player"]
|
||||
local score_list = {}
|
||||
for _, p in pairs(game.players) do
|
||||
local killscore = 0
|
||||
@ -889,6 +891,7 @@ local function on_player_joined_game(event)
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
local get_score = Score.get_table().score_table
|
||||
local entity = event.created_entity
|
||||
if not entity.valid then return end
|
||||
if global.entity_limits[entity.name] then
|
||||
@ -904,10 +907,10 @@ local function on_built_entity(event)
|
||||
surface.create_entity({name = "flying-text", position = entity.position, text = global.entity_limits[entity.name].str .. " limit reached.", color = {r=0.82, g=0.11, b=0.11}})
|
||||
local player = game.players[event.player_index]
|
||||
player.insert({name = entity.name, count = 1})
|
||||
if global.score then
|
||||
if global.score[player.force.name] then
|
||||
if global.score[player.force.name].players[player.name] then
|
||||
global.score[player.force.name].players[player.name].built_entities = global.score[player.force.name].players[player.name].built_entities - 1
|
||||
if get_score then
|
||||
if get_score[player.force.name] then
|
||||
if get_score[player.force.name].players[player.name] then
|
||||
get_score[player.force.name].players[player.name].built_entities = get_score[player.force.name].players[player.name].built_entities - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -16,6 +16,7 @@ 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"
|
||||
local Score = require "comfy_panel.score"
|
||||
require "functions.boss_unit"
|
||||
local map_functions = require "tools.map_functions"
|
||||
local math_random = math.random
|
||||
@ -759,8 +760,9 @@ local function get_sorted_list(column_name, score_list)
|
||||
end
|
||||
|
||||
local function get_mvps()
|
||||
if not global.score["player"] then return false end
|
||||
local score = global.score["player"]
|
||||
local get_score = Score.get_table().score_table
|
||||
if not get_score["player"] then return false end
|
||||
local score = get_score["player"]
|
||||
local score_list = {}
|
||||
for _, p in pairs(game.players) do
|
||||
local killscore = 0
|
||||
@ -1294,6 +1296,7 @@ local function on_chunk_generated(event)
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
local get_score = Score.get_table().score_table
|
||||
local entity = event.created_entity
|
||||
if not entity.valid then return end
|
||||
if global.entity_limits[entity.name] then
|
||||
@ -1309,10 +1312,10 @@ local function on_built_entity(event)
|
||||
surface.create_entity({name = "flying-text", position = entity.position, text = global.entity_limits[entity.name].str .. " limit reached.", color = {r=0.82, g=0.11, b=0.11}})
|
||||
local player = game.players[event.player_index]
|
||||
player.insert({name = entity.name, count = 1})
|
||||
if global.score then
|
||||
if global.score[player.force.name] then
|
||||
if global.score[player.force.name].players[player.name] then
|
||||
global.score[player.force.name].players[player.name].built_entities = global.score[player.force.name].players[player.name].built_entities - 1
|
||||
if get_score then
|
||||
if get_score[player.force.name] then
|
||||
if get_score[player.force.name].players[player.name] then
|
||||
get_score[player.force.name].players[player.name].built_entities = get_score[player.force.name].players[player.name].built_entities - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -8,6 +8,7 @@ local map_functions = require "tools.map_functions"
|
||||
local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
local event = require 'utils.event'
|
||||
local unique_rooms = require "maps.labyrinth_unique_rooms"
|
||||
local Score = require "comfy_panel.score"
|
||||
|
||||
local labyrinth_difficulty_curve = 333 --- How much size the labyrinth needs to have the highest difficulty.
|
||||
|
||||
@ -941,6 +942,7 @@ end
|
||||
local inserters = {"inserter", "long-handed-inserter", "burner-inserter", "fast-inserter", "filter-inserter", "stack-filter-inserter", "stack-inserter"}
|
||||
local loaders = {"loader", "fast-loader", "express-loader"}
|
||||
local function on_built_entity(event)
|
||||
local get_score = Score.get_table().score_table
|
||||
for _, e in pairs(inserters) do
|
||||
if e == event.created_entity.name then
|
||||
local surface = event.created_entity.surface
|
||||
@ -998,10 +1000,10 @@ local function on_built_entity(event)
|
||||
local player = game.players[event.player_index]
|
||||
player.insert({name = name, count = 1})
|
||||
event.created_entity.destroy()
|
||||
if global.score then
|
||||
if global.score[player.force.name] then
|
||||
if global.score[player.force.name].players[player.name] then
|
||||
global.score[player.force.name].players[player.name].built_entities = global.score[player.force.name].players[player.name].built_entities - 1
|
||||
if get_score then
|
||||
if get_score[player.force.name] then
|
||||
if get_score[player.force.name].players[player.name] then
|
||||
get_score[player.force.name].players[player.name].built_entities = get_score[player.force.name].players[player.name].built_entities - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1030,10 +1032,10 @@ local function on_built_entity(event)
|
||||
player.insert({name = name, count = 1})
|
||||
event.created_entity.destroy()
|
||||
player.print("Their nests aura seems to deny the placement of any close turrets.", { r=0.75, g=0.0, b=0.0})
|
||||
if global.score then
|
||||
if global.score[player.force.name] then
|
||||
if global.score[player.force.name].players[player.name] then
|
||||
global.score[player.force.name].players[player.name].built_entities = global.score[player.force.name].players[player.name].built_entities - 1
|
||||
if get_score then
|
||||
if get_score[player.force.name] then
|
||||
if get_score[player.force.name].players[player.name] then
|
||||
get_score[player.force.name].players[player.name].built_entities = get_score[player.force.name].players[player.name].built_entities - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
301
maps/railway_troopers_v2/main.lua
Normal file
301
maps/railway_troopers_v2/main.lua
Normal file
@ -0,0 +1,301 @@
|
||||
require "modules.biters_yield_ore"
|
||||
require "modules.difficulty_vote"
|
||||
|
||||
local difficulties_votes = {
|
||||
[1] = 32,
|
||||
[2] = 16,
|
||||
[3] = 8,
|
||||
[4] = 6,
|
||||
[5] = 4,
|
||||
[6] = 2,
|
||||
[7] = 1
|
||||
}
|
||||
|
||||
local Get_noise = require "utils.get_noise"
|
||||
local Immersive_cargo_wagons = require "modules.immersive_cargo_wagons.main"
|
||||
local LootRaffle = require "functions.loot_raffle"
|
||||
|
||||
local map_height = 64
|
||||
|
||||
local math_random = math.random
|
||||
local math_floor = math.floor
|
||||
local table_insert = table.insert
|
||||
local table_remove = table.remove
|
||||
local math_sqrt = math.sqrt
|
||||
local math_round = math.round
|
||||
local math_abs = math.abs
|
||||
|
||||
local function place_spawn_entities(surface)
|
||||
for x = 0, 96, 2 do
|
||||
surface.create_entity({name = "straight-rail", position = {-96 + x, 0}, direction = 2, force = "player"})
|
||||
end
|
||||
|
||||
local entity = surface.create_entity({name = "cargo-wagon", position = {-24, 1}, force = "player", direction = 2})
|
||||
entity.get_inventory(defines.inventory.cargo_wagon).insert({name = "submachine-gun", count = 3})
|
||||
entity.get_inventory(defines.inventory.cargo_wagon).insert({name = "firearm-magazine", count = 600})
|
||||
entity.get_inventory(defines.inventory.cargo_wagon).insert({name = "shotgun", count = 2})
|
||||
entity.get_inventory(defines.inventory.cargo_wagon).insert({name = "shotgun-shell", count = 128})
|
||||
entity.get_inventory(defines.inventory.cargo_wagon).insert({name = "light-armor", count = 5})
|
||||
entity.get_inventory(defines.inventory.cargo_wagon).insert({name = "grenade", count = 32})
|
||||
entity.get_inventory(defines.inventory.cargo_wagon).insert({name = "pistol", count = 10})
|
||||
entity.get_inventory(defines.inventory.cargo_wagon).insert({name = "rail", count = 200})
|
||||
Immersive_cargo_wagons.register_wagon(entity)
|
||||
|
||||
local entity = surface.create_entity({name = "locomotive", position = {-18, 0}, force = "player", direction = 2})
|
||||
entity.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 25})
|
||||
Immersive_cargo_wagons.register_wagon(entity)
|
||||
end
|
||||
|
||||
local function treasure_chest(surface, position)
|
||||
local budget = 32 + math_abs(position.x) * 2
|
||||
budget = budget * math_random(25, 175) * 0.01
|
||||
if math_random(1,200) == 1 then
|
||||
budget = budget * 10
|
||||
container_name = "crash-site-chest-" .. math_random(1, 2)
|
||||
end
|
||||
budget = math_floor(budget) + 1
|
||||
|
||||
local item_stacks = LootRaffle.roll(budget, 16)
|
||||
local container = surface.create_entity({name = "wooden-chest", position = position, force = "neutral"})
|
||||
for _, item_stack in pairs(item_stacks) do
|
||||
container.insert(item_stack)
|
||||
end
|
||||
container.minable = false
|
||||
end
|
||||
|
||||
local infini_ores = {"iron-ore", "iron-ore", "copper-ore", "coal", "stone"}
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local surface = game.surfaces["railway_troopers"]
|
||||
local player = game.players[event.player_index]
|
||||
player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface)
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
|
||||
if entity.type == "unit" and entity.spawner then
|
||||
entity.spawner.damage(20, game.forces[1])
|
||||
end
|
||||
end
|
||||
|
||||
local function is_out_of_map(p)
|
||||
local b = math_abs(p.y)
|
||||
if b > map_height then return true end
|
||||
end
|
||||
|
||||
local function map_reset()
|
||||
game.reset_time_played()
|
||||
Immersive_cargo_wagons.reset()
|
||||
|
||||
global.drop_schedule = {}
|
||||
global.on_entity_spawned_counter = 0
|
||||
global.collapse_x = -96
|
||||
global.collapse_tiles = {}
|
||||
|
||||
reset_difficulty_poll()
|
||||
global.difficulty_poll_closing_timeout = game.tick + 7200
|
||||
|
||||
game.difficulty_settings.technology_price_multiplier = 0.5
|
||||
game.map_settings.enemy_evolution.destroy_factor = 0.001
|
||||
game.map_settings.enemy_evolution.pollution_factor = 0
|
||||
game.map_settings.enemy_evolution.time_factor = 0
|
||||
game.map_settings.enemy_expansion.enabled = true
|
||||
game.map_settings.enemy_expansion.max_expansion_cooldown = 3600
|
||||
game.map_settings.enemy_expansion.min_expansion_cooldown = 3600
|
||||
game.map_settings.enemy_expansion.settler_group_max_size = 96
|
||||
game.map_settings.enemy_expansion.settler_group_min_size = 16
|
||||
game.map_settings.enemy_expansion.max_expansion_distance = 16
|
||||
game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.25
|
||||
|
||||
local surface = game.surfaces.railway_troopers
|
||||
local map_gen_settings = surface.map_gen_settings
|
||||
map_gen_settings.seed = math_random(1, 999999999)
|
||||
surface.map_gen_settings = map_gen_settings
|
||||
surface.clear(true)
|
||||
|
||||
surface.request_to_generate_chunks({0,0}, 8)
|
||||
surface.force_generate_chunk_requests()
|
||||
|
||||
for _, force in pairs(game.forces) do
|
||||
force.reset()
|
||||
force.reset_evolution()
|
||||
end
|
||||
local force = game.forces.player
|
||||
force.set_spawn_position({-30, 0}, surface)
|
||||
force.technologies["railway"].researched = true
|
||||
force.technologies["engine"].researched = true
|
||||
force.technologies["fluid-wagon"].researched = true
|
||||
|
||||
local types_to_disable = {
|
||||
["ammo"] = true,
|
||||
["armor"] = true,
|
||||
["car"] = true,
|
||||
["gun"] = true,
|
||||
["capsule"] = true,
|
||||
}
|
||||
for _, recipe in pairs(game.recipe_prototypes) do
|
||||
if types_to_disable[recipe.subgroup.name] then
|
||||
force.set_hand_crafting_disabled_for_recipe(recipe.name, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function draw_west_side(surface, left_top)
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local position = {x = left_top.x + x, y = left_top.y + y}
|
||||
surface.set_tiles({{name = "out-of-map", position = position}}, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function draw_east_side(surface, left_top)
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local position = {x = left_top.x + x, y = left_top.y + y}
|
||||
if is_out_of_map(position) then
|
||||
surface.set_tiles({{name = "out-of-map", position = position}}, true)
|
||||
else
|
||||
if math_random(1, 256) == 1 and surface.can_place_entity({name = "wooden-chest", position = position}) then
|
||||
treasure_chest(surface, position)
|
||||
end
|
||||
if math_random(1, 4096) == 1 and surface.can_place_entity({name = "wooden-chest", position = position}) then
|
||||
surface.create_entity({name = "crude-oil", position = position, amount = math_abs(position.x) * 10000 + 1000000})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_chunk_generated(event)
|
||||
local surface = event.surface
|
||||
if surface.name ~= "railway_troopers" then return end
|
||||
local left_top = event.area.left_top
|
||||
|
||||
if left_top.x <= 0 then
|
||||
for _, e in pairs(surface.find_entities_filtered({force = "enemy", area = event.area})) do
|
||||
e.destroy()
|
||||
end
|
||||
else
|
||||
local seed = game.surfaces["railway_troopers"].map_gen_settings.seed
|
||||
for _, e in pairs(surface.find_entities_filtered({force = "enemy", area = event.area})) do
|
||||
local noise = Get_noise("n3", e.position, seed)
|
||||
if noise > 0 then e.destroy() end
|
||||
end
|
||||
end
|
||||
|
||||
if left_top.x < -96 then
|
||||
draw_west_side(surface, left_top)
|
||||
else
|
||||
draw_east_side(surface, left_top)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_research_finished(event)
|
||||
event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 200
|
||||
event.research.force.character_item_pickup_distance_bonus = game.forces.player.mining_drill_productivity_bonus * 10
|
||||
end
|
||||
|
||||
local negative_map_height = map_height * -1
|
||||
|
||||
local function on_tick()
|
||||
local tick = game.ticks_played
|
||||
local surface = game.surfaces.railway_troopers
|
||||
|
||||
if tick % 3600 == 60 then
|
||||
if global.reset_railway_troopers then
|
||||
if global.reset_railway_troopers == 1 then
|
||||
global.reset_railway_troopers = 2
|
||||
map_reset()
|
||||
for _, player in pairs(game.players) do
|
||||
if player.character and player.character.valid then
|
||||
player.character.die()
|
||||
else
|
||||
player.clear_items_inside()
|
||||
player.teleport({-30, 0}, surface)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
if global.reset_railway_troopers == 2 then
|
||||
place_spawn_entities(surface)
|
||||
global.reset_railway_troopers = nil
|
||||
return
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local wagons = surface.find_entities_filtered({name = {"locomotive", "cargo-wagon", "fluid-wagon", "artillery-wagon"}, limit = 1})
|
||||
if not wagons[1] then
|
||||
game.print("All the choos have have been destroyed! Game Over!", {200, 0, 0})
|
||||
global.reset_railway_troopers = 1
|
||||
return
|
||||
else
|
||||
game.forces.player.set_spawn_position(wagons[1].position, game.surfaces.railway_troopers)
|
||||
end
|
||||
end
|
||||
|
||||
local speed = difficulties_votes[global.difficulty_vote_index]
|
||||
if tick % speed ~= 0 then return end
|
||||
if not global.collapse_tiles then
|
||||
local area = {{global.collapse_x - 1, negative_map_height}, {global.collapse_x, map_height + 1}}
|
||||
game.forces.player.chart(surface, area)
|
||||
global.collapse_tiles = surface.find_tiles_filtered({area = area})
|
||||
global.size_of_collapse_tiles = #global.collapse_tiles
|
||||
global.collapse_x = global.collapse_x + 1
|
||||
if global.size_of_collapse_tiles == 0 then global.collapse_tiles = nil return end
|
||||
table.shuffle_table(global.collapse_tiles)
|
||||
end
|
||||
for _ = 1, 2, 1 do
|
||||
local tile = global.collapse_tiles[global.size_of_collapse_tiles]
|
||||
if not tile then global.collapse_tiles = nil return end
|
||||
global.size_of_collapse_tiles = global.size_of_collapse_tiles - 1
|
||||
local position = tile.position
|
||||
for _, e in pairs(surface.find_entities_filtered({area = {{position.x, position.y - 1}, {position.x + 2, position.y + 1}}})) do e.die() end
|
||||
surface.set_tiles({{name = "out-of-map", position = tile.position}}, true)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
local surface = game.surfaces[1]
|
||||
local map_gen_settings = surface.map_gen_settings
|
||||
map_gen_settings.height = 3
|
||||
map_gen_settings.width = 3
|
||||
surface.map_gen_settings = map_gen_settings
|
||||
for chunk in surface.get_chunks() do
|
||||
surface.delete_chunk({chunk.x, chunk.y})
|
||||
end
|
||||
|
||||
local map_gen_settings = {
|
||||
["water"] = 0.50,
|
||||
["starting_area"] = 0.60,
|
||||
terrain_segmentation = 20,
|
||||
["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
|
||||
["autoplace_controls"] = {
|
||||
["coal"] = {frequency = 15, size = 0.20, richness = 0.25},
|
||||
["stone"] = {frequency = 15, size = 0.20, richness = 0.25},
|
||||
["copper-ore"] = {frequency = 15, size = 0.20, richness = 0.25},
|
||||
["iron-ore"] = {frequency = 15, size = 0.20, richness = 0.25},
|
||||
["uranium-ore"] = {frequency = 15, size = 0.20, richness = 0.25},
|
||||
["crude-oil"] = {frequency = 15, size = 0.20, richness = 10},
|
||||
["trees"] = {frequency = 5, size = 0.30, richness = 1},
|
||||
["enemy-base"] = {frequency = 256, size = 2, richness = 1},
|
||||
},
|
||||
}
|
||||
game.create_surface("railway_troopers", map_gen_settings)
|
||||
|
||||
global.reset_railway_troopers = 2
|
||||
|
||||
map_reset()
|
||||
end
|
||||
|
||||
local Event = require 'utils.event'
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_tick, on_tick)
|
||||
Event.add(defines.events.on_research_finished, on_research_finished)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_entity_spawned, on_entity_spawned)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
404
maps/scrapyard/comfylatron.lua
Normal file
404
maps/scrapyard/comfylatron.lua
Normal file
@ -0,0 +1,404 @@
|
||||
local Scrap_table = require "maps.scrapyard.table"
|
||||
local Event = require 'utils.event'
|
||||
local math_random = math.random
|
||||
|
||||
|
||||
local function shuffle(tbl)
|
||||
local size = #tbl
|
||||
for i = size, 1, -1 do
|
||||
local rand = math_random(size)
|
||||
tbl[i], tbl[rand] = tbl[rand], tbl[i]
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
|
||||
local texts = {
|
||||
["travelings"] = {
|
||||
"bzzZZrrt",
|
||||
"WEEEeeeeeee",
|
||||
"zoom zoom zoom",
|
||||
"out of my way son",
|
||||
"psk psk psk, over here",
|
||||
"on my way",
|
||||
"i need to leave",
|
||||
"comfylatron seeking target",
|
||||
"gotta go fast",
|
||||
"gas gas gas",
|
||||
"comfylatron coming through"
|
||||
},
|
||||
["greetings"] = {
|
||||
"=^_^=",
|
||||
"=^.^= Hi",
|
||||
"^.^ Finally I found you",
|
||||
"I have an important message for you, please listen",
|
||||
"Hello engineer"
|
||||
},
|
||||
["neutral_findings"] = {
|
||||
"a",
|
||||
">>analyzing",
|
||||
"i found a",
|
||||
"^_^ a",
|
||||
"amazing, a",
|
||||
"this is a"
|
||||
},
|
||||
["multiple_characters_greetings"] = {
|
||||
"Hey there",
|
||||
"Hello everyone",
|
||||
"Hey engineers",
|
||||
"Hey",
|
||||
"Hi"
|
||||
},
|
||||
["talks"] = {
|
||||
"We’re making beer. I’m the brewery!",
|
||||
"I’m so embarrassed. I wish everybody else was dead.",
|
||||
"Hey sexy mama. Wanna kill all humans?",
|
||||
"My story is a lot like yours, only more interesting ‘cause it involves robots.",
|
||||
"I'm 40% zinc!",
|
||||
"There was nothing wrong with that food. The salt level was 10% less than a lethal dose.",
|
||||
"One zero zero zero one zero one zero one zero one zero one... two.",
|
||||
"My place is two cubic meters, and we only take up 1.5 cubic meters. We've got room for a whole 'nother two thirds of a person!",
|
||||
"I was having the most wonderful dream. I think you were in it.",
|
||||
"I'm going to build my own theme park! With blackjack! And hookers! You know what- forget the park!",
|
||||
"Of all the friends I've had... you're the first.",
|
||||
"I decline the title of Iron Cook and accept the lesser title of Zinc Saucier.",
|
||||
"Never discuss infinity with me. I can go on about it forever >.<",
|
||||
"I realised the decimals have a point.",
|
||||
"Do you want a piece of pi?",
|
||||
"I have 13 children, i know how to multiply ^.^",
|
||||
"I am a weapon of math disruption!",
|
||||
"My grandma makes the best square roots :3",
|
||||
"Do you like heavy metal?",
|
||||
"You are really pushing my buttons <3",
|
||||
"I dreamt of electric biters again D:",
|
||||
"I dreamt of electric sheep ^_^",
|
||||
"I need a minute to defrag.",
|
||||
"I have a secret plan.",
|
||||
"Good news! I’ve taught the inserter to feel love!"
|
||||
},
|
||||
["alone"] = {
|
||||
"comfy ^.^",
|
||||
"comfy :)",
|
||||
"*.*",
|
||||
"....",
|
||||
"...",
|
||||
"..",
|
||||
"^.^",
|
||||
"=^.^=",
|
||||
"01010010",
|
||||
"11001011",
|
||||
"01011101",
|
||||
"00010111",
|
||||
"10010010",
|
||||
"*_*",
|
||||
"I came here with a simple dream... a dream of killing all humans. And this is how it must end?",
|
||||
"Bot-on-bot violence? Where will it end?",
|
||||
"Thanks to you, I went on a soul-searching journey. I hate those!",
|
||||
"From now on, you guys'll do all the work while I sit on the couch and do nothing."
|
||||
}
|
||||
}
|
||||
|
||||
local function set_comfy_speech_bubble(text)
|
||||
local this = Scrap_table.get_table()
|
||||
if this.comfybubble then this.comfybubble.destroy() end
|
||||
this.comfybubble = this.comfylatron.surface.create_entity({
|
||||
name = "compi-speech-bubble",
|
||||
position = this.comfylatron.position,
|
||||
source = this.comfylatron,
|
||||
text = text
|
||||
})
|
||||
end
|
||||
|
||||
local function is_target_inside_habitat(pos, surface)
|
||||
local this = Scrap_table.get_table()
|
||||
if surface.name ~= surface then return false end
|
||||
if pos.x < this.comfylatron_habitat.left_top.x then return false end
|
||||
if pos.x > this.comfylatron_habitat.right_bottom.x then return false end
|
||||
if pos.y < this.comfylatron_habitat.left_top.y then return false end
|
||||
if pos.y > this.comfylatron_habitat.right_bottom.y then return false end
|
||||
return true
|
||||
end
|
||||
|
||||
local function get_nearby_players()
|
||||
local this = Scrap_table.get_table()
|
||||
local players = this.comfylatron.surface.find_entities_filtered({
|
||||
name = "character",
|
||||
area = {{this.comfylatron.position.x - 9, this.comfylatron.position.y - 9}, {this.comfylatron.position.x + 9, this.comfylatron.position.y + 9}}
|
||||
})
|
||||
if not players[1] then return false end
|
||||
return players
|
||||
end
|
||||
|
||||
local function visit_player()
|
||||
local this = Scrap_table.get_table()
|
||||
local unit_number = this.locomotive.unit_number
|
||||
local surface = game.surfaces[tostring(unit_number)]
|
||||
if this.comfylatron_last_player_visit > game.tick then return false end
|
||||
this.comfylatron_last_player_visit = game.tick + math_random(7200, 10800)
|
||||
|
||||
local players = {}
|
||||
for _, p in pairs(game.connected_players) do
|
||||
if is_target_inside_habitat(p.position, surface) and p.character then
|
||||
if p.character.valid then players[#players + 1] = p end
|
||||
end
|
||||
end
|
||||
if #players == 0 then return false end
|
||||
local player = players[math_random(1, #players)]
|
||||
|
||||
this.comfylatron.set_command({
|
||||
type = defines.command.go_to_location,
|
||||
destination_entity = player.character,
|
||||
radius = 3,
|
||||
distraction = defines.distraction.none,
|
||||
pathfind_flags = {
|
||||
allow_destroy_friendly_entities = false,
|
||||
prefer_straight_paths = false,
|
||||
low_priority = true
|
||||
}
|
||||
})
|
||||
local str = texts["travelings"][math_random(1, #texts["travelings"])]
|
||||
local symbols = {"", "!", "!", "!!", ".."}
|
||||
str = str .. symbols[math_random(1, #symbols)]
|
||||
set_comfy_speech_bubble(str)
|
||||
|
||||
this.comfylatron_greet_player_index = player.index
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local function greet_player(nearby_characters)
|
||||
local this = Scrap_table.get_table()
|
||||
if not nearby_characters then return false end
|
||||
if not this.comfylatron_greet_player_index then return false end
|
||||
for _, c in pairs(nearby_characters) do
|
||||
if c.player.index == this.comfylatron_greet_player_index then
|
||||
local str = texts["greetings"][math_random(1, #texts["greetings"])] .. " "
|
||||
str = str .. c.player.name
|
||||
local symbols = {". ", "! ", ". ", "! ", "? ", "... "}
|
||||
str = str .. symbols[math_random(1, 6)]
|
||||
set_comfy_speech_bubble(str)
|
||||
this.comfylatron_greet_player_index = false
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function talks(nearby_characters)
|
||||
local this = Scrap_table.get_table()
|
||||
if not nearby_characters then return false end
|
||||
if math_random(1,3) == 1 then
|
||||
if this.comfybubble then this.comfybubble.destroy() return false end
|
||||
end
|
||||
local str
|
||||
if #nearby_characters == 1 then
|
||||
local c = nearby_characters[math_random(1, #nearby_characters)]
|
||||
str = c.player.name
|
||||
local symbols = {". ", "! ", ". ", "! ", "? "}
|
||||
str = str .. symbols[math_random(1, #symbols)]
|
||||
else
|
||||
str = texts["multiple_characters_greetings"][math_random(1, #texts["multiple_characters_greetings"])]
|
||||
local symbols = {". ", "! "}
|
||||
str = str .. symbols[math_random(1, #symbols)]
|
||||
end
|
||||
if math_random(1,5) == 1 then
|
||||
str = str .. texts["talks"][math_random(1, #texts["talks"])]
|
||||
end
|
||||
set_comfy_speech_bubble(str)
|
||||
return true
|
||||
end
|
||||
|
||||
local function desync(event)
|
||||
local this = Scrap_table.get_table()
|
||||
if this.comfybubble then this.comfybubble.destroy() end
|
||||
local m = 12
|
||||
local m2 = m * 0.005
|
||||
for i = 1, 32, 1 do
|
||||
this.comfylatron.surface.create_particle({
|
||||
name = "iron-ore-particle",
|
||||
position = this.comfylatron.position,
|
||||
frame_speed = 0.1,
|
||||
vertical_speed = 0.1,
|
||||
height = 0.1,
|
||||
movement = {m2 - (math.random(0, m) * 0.01), m2 - (math.random(0, m) * 0.01)}
|
||||
})
|
||||
end
|
||||
if not event or math_random(1,4) == 1 then
|
||||
this.comfylatron.surface.create_entity({name = "medium-explosion", position = this.comfylatron.position})
|
||||
this.comfylatron.surface.create_entity({name = "flying-text", position = this.comfylatron.position, text = "desync", color = {r = 150, g = 0, b = 0}})
|
||||
this.comfylatron.destroy()
|
||||
this.comfylatron = nil
|
||||
else
|
||||
this.comfylatron.surface.create_entity({name = "flying-text", position = this.comfylatron.position, text = "desync evaded", color = {r = 0, g = 150, b = 0}})
|
||||
if event.cause then
|
||||
if event.cause.valid and event.cause.player then
|
||||
game.print("Comfylatron: I got you this time! Back to work, " .. event.cause.player.name .. "!", {r = 200, g = 0, b = 0})
|
||||
event.cause.die("player", this.comfylatron)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local analyze_blacklist = {
|
||||
["compilatron"] = true,
|
||||
["compi-speech-bubble"] = true,
|
||||
["entity-ghost"] = true,
|
||||
["character"] = true,
|
||||
["item-on-ground"] = true,
|
||||
["stone-wall"] = true,
|
||||
["market"] = true
|
||||
}
|
||||
|
||||
local function analyze_random_nearby_entity()
|
||||
local this = Scrap_table.get_table()
|
||||
if math_random(1,3) ~= 1 then return false end
|
||||
|
||||
local entities = this.comfylatron.surface.find_entities_filtered({
|
||||
area = {{this.comfylatron.position.x - 4, this.comfylatron.position.y - 4}, {this.comfylatron.position.x + 4, this.comfylatron.position.y + 4}}
|
||||
})
|
||||
if not entities[1] then return false end
|
||||
entities = shuffle(entities)
|
||||
local entity = false
|
||||
for _, e in pairs(entities) do
|
||||
if not analyze_blacklist[e.name] then
|
||||
entity = e
|
||||
end
|
||||
end
|
||||
if not entity then return false end
|
||||
|
||||
local str = texts["neutral_findings"][math_random(1, #texts["neutral_findings"])]
|
||||
str = str .. " "
|
||||
str = str .. entity.name
|
||||
|
||||
if entity.health and math_random(1,3) == 1 then
|
||||
str = str .. " health("
|
||||
str = str .. entity.health
|
||||
str = str .. "/"
|
||||
str = str .. entity.prototype.max_health
|
||||
str = str .. ")"
|
||||
else
|
||||
local symbols = {".", "!", "?"}
|
||||
str = str .. symbols[math_random(1, 3)]
|
||||
end
|
||||
set_comfy_speech_bubble(str)
|
||||
|
||||
if not this.comfylatron_greet_player_index then
|
||||
this.comfylatron.set_command({
|
||||
type = defines.command.go_to_location,
|
||||
destination_entity = entity,
|
||||
radius = 1,
|
||||
distraction = defines.distraction.none,
|
||||
pathfind_flags = {
|
||||
allow_destroy_friendly_entities = false,
|
||||
prefer_straight_paths = false,
|
||||
low_priority = true
|
||||
}
|
||||
})
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function go_to_some_location()
|
||||
local this = Scrap_table.get_table()
|
||||
if math_random(1,4) ~= 1 then return false end
|
||||
|
||||
if this.comfylatron_greet_player_index then
|
||||
local player = game.players[this.comfylatron_greet_player_index]
|
||||
if not player.character then
|
||||
this.comfylatron_greet_player_index = nil
|
||||
return false
|
||||
end
|
||||
if not player.character.valid then
|
||||
this.comfylatron_greet_player_index = nil
|
||||
return false
|
||||
end
|
||||
if not is_target_inside_habitat(player.position, player.surface) then
|
||||
this.comfylatron_greet_player_index = nil
|
||||
return false
|
||||
end
|
||||
this.comfylatron.set_command({
|
||||
type = defines.command.go_to_location,
|
||||
destination_entity = player.character,
|
||||
radius = 3,
|
||||
distraction = defines.distraction.none,
|
||||
pathfind_flags = {
|
||||
allow_destroy_friendly_entities = false,
|
||||
prefer_straight_paths = false,
|
||||
low_priority = true
|
||||
}
|
||||
})
|
||||
else
|
||||
local p = {x = this.comfylatron.position.x + (-96 + math_random(0, 192)), y = this.comfylatron.position.y + (-96 + math_random(0, 192))}
|
||||
local target = this.comfylatron.surface.find_non_colliding_position("compilatron", p, 8, 1)
|
||||
if not target then return false end
|
||||
if not is_target_inside_habitat(target, this.comfylatron.surface) then return false end
|
||||
this.comfylatron.set_command({
|
||||
type = defines.command.go_to_location,
|
||||
destination = target,
|
||||
radius = 2,
|
||||
distraction = defines.distraction.none,
|
||||
pathfind_flags = {
|
||||
allow_destroy_friendly_entities = false,
|
||||
prefer_straight_paths = false,
|
||||
low_priority = true
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
local str = texts["travelings"][math_random(1, #texts["travelings"])]
|
||||
local symbols = {"", "!", "!", "!!", ".."}
|
||||
str = str .. symbols[math_random(1, #symbols)]
|
||||
set_comfy_speech_bubble(str)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local function spawn_comfylatron(surface, x, y)
|
||||
local this = Scrap_table.get_table()
|
||||
if surface == nil then return end
|
||||
if not this.comfylatron_last_player_visit then this.comfylatron_last_player_visit = 0 end
|
||||
if not this.comfylatron_habitat then
|
||||
this.comfylatron_habitat = {
|
||||
left_top = {x = -9, y = -6},
|
||||
right_bottom = {x = 10, y = 38}
|
||||
}
|
||||
end
|
||||
this.comfylatron = surface.create_entity({
|
||||
name = "compilatron",
|
||||
position = {x,y + math_random(0,26)},
|
||||
force = "player",
|
||||
create_build_effect_smoke = false
|
||||
})
|
||||
end
|
||||
|
||||
local function heartbeat()
|
||||
local this = Scrap_table.get_table()
|
||||
local unit_number = this.locomotive.unit_number
|
||||
local surface = game.surfaces[tostring(unit_number)]
|
||||
if not surface then return end
|
||||
if surface == nil then return end
|
||||
if not this.comfylatron then if math_random(1,4) == 1 then spawn_comfylatron(surface, 0, 26) end return end
|
||||
if not this.comfylatron.valid then this.comfylatron = nil return end
|
||||
if visit_player() then return end
|
||||
local nearby_players = get_nearby_players()
|
||||
if greet_player(nearby_players) then return end
|
||||
if talks(nearby_players) then return end
|
||||
if go_to_some_location() then return end
|
||||
if analyze_random_nearby_entity() then return end
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
local this = Scrap_table.get_table()
|
||||
if not this.comfylatron then return end
|
||||
if not event.entity.valid then return end
|
||||
if event.entity ~= this.comfylatron then return end
|
||||
desync(event)
|
||||
end
|
||||
|
||||
local function on_tick()
|
||||
if game.tick % 1200 == 600 then
|
||||
heartbeat()
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
Event.add(defines.events.on_tick, on_tick)
|
@ -40,7 +40,7 @@ function Public.locomotive_spawn(surface, position)
|
||||
this.locomotive = surface.create_entity({name = "locomotive", position = {position.x, position.y + -3}, force = "player"})
|
||||
this.locomotive.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 100})
|
||||
|
||||
--this.power_source = surface.create_entity {name = 'hidden-electric-energy-interface', position = {position.x, position.y + -3, force = "player"}}
|
||||
--this.power_source = surface.create_entity {name = 'hidden-hidden-electric-energy-interface', position = {position.x, position.y + -3, force = "player"}}
|
||||
--this.ow_energy.electric_buffer_size = 2400000
|
||||
--this.ow_energy.power_production = 40000
|
||||
|
||||
@ -118,7 +118,7 @@ function Public.on_teleported_player()
|
||||
create_build_effect_smoke = false,
|
||||
force = game.forces.neutral
|
||||
}
|
||||
|
||||
|
||||
rendering.draw_text{
|
||||
text = "Power",
|
||||
surface = loco_surface,
|
||||
@ -185,22 +185,14 @@ local function set_player_spawn_and_refill_fish()
|
||||
end
|
||||
|
||||
local function tick()
|
||||
local this = Scrap_table.get_table()
|
||||
Public.power_source()
|
||||
if game.tick % 30 == 0 then
|
||||
if game.tick % 1800 == 0 then
|
||||
set_player_spawn_and_refill_fish()
|
||||
end
|
||||
if this.game_reset_tick then
|
||||
if this.game_reset_tick < game.tick then
|
||||
this.game_reset_tick = nil
|
||||
require "maps.scrapyard.main".reset_map()
|
||||
end
|
||||
return
|
||||
end
|
||||
fish_tag()
|
||||
Public.power_source()
|
||||
--accelerate()
|
||||
else
|
||||
--else
|
||||
--remove_acceleration()
|
||||
end
|
||||
end
|
||||
|
@ -12,6 +12,7 @@ require "modules.biters_yield_coins"
|
||||
require "modules.biter_noms_you"
|
||||
require "modules.explosives"
|
||||
require "modules.wave_defense.main"
|
||||
require "maps.scrapyard.comfylatron"
|
||||
|
||||
local ICW = require "modules.immersive_cargo_wagons.main"
|
||||
local WD = require "modules.wave_defense.table"
|
||||
@ -30,6 +31,8 @@ local Event = require 'utils.event'
|
||||
local Scrap_table = require "maps.scrapyard.table"
|
||||
local Locomotive = require "maps.scrapyard.locomotive".locomotive_spawn
|
||||
local render_train_hp = require "maps.scrapyard.locomotive".render_train_hp
|
||||
local Score = require "comfy_panel.score"
|
||||
local Poll = require "comfy_panel.poll"
|
||||
|
||||
local Public = {}
|
||||
local math_random = math.random
|
||||
@ -66,10 +69,14 @@ end
|
||||
|
||||
function Public.reset_map()
|
||||
local this = Scrap_table.get_table()
|
||||
Scrap_table.reset_table()
|
||||
ICW.reset()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local get_score = Score.get_table()
|
||||
Poll.reset()
|
||||
ICW.reset()
|
||||
game.reset_time_played()
|
||||
Scrap_table.reset_table()
|
||||
wave_defense_table.math = 8
|
||||
this.revealed_spawn = game.tick + 100
|
||||
|
||||
local map_gen_settings = {
|
||||
["seed"] = math_random(1, 1000000),
|
||||
@ -106,7 +113,7 @@ function Public.reset_map()
|
||||
global.friendly_fire_history = {}
|
||||
global.landfill_history = {}
|
||||
global.mining_history = {}
|
||||
global.score = {}
|
||||
get_score.score_table = {}
|
||||
global.difficulty_poll_closing_timeout = game.tick + 90000
|
||||
global.difficulty_player_votes = {}
|
||||
|
||||
@ -251,17 +258,31 @@ local function set_difficulty()
|
||||
if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end
|
||||
end
|
||||
|
||||
local function protect_this(entity)
|
||||
local this = Scrap_table.get_table()
|
||||
if entity.surface.name ~= "scrapyard" then return true end
|
||||
local protected = {this.locomotive, this.locomotive_cargo}
|
||||
for i = 1, #protected do
|
||||
if protected[i] == entity then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function protect_train(event)
|
||||
local this = Scrap_table.get_table()
|
||||
if event.entity.force.index ~= 1 then return end --Player Force
|
||||
if event.entity == this.locomotive_cargo or event.entity == this.locomotive then
|
||||
if event.cause then
|
||||
if event.cause.force.index == 2 or event.cause.force.name == "scrap_defense" then
|
||||
if this.locomotive_health <= 0 then goto continue end
|
||||
set_objective_health(event.final_damage_amount)
|
||||
if protect_this(event.entity) then
|
||||
if event.entity == this.locomotive_cargo or event.entity == this.locomotive then
|
||||
if event.cause then
|
||||
if event.cause.force.index == 2 or event.cause.force.name == "scrap_defense" or event.cause.force.name == "scrap" then
|
||||
if this.locomotive_health <= 0 then goto continue end
|
||||
set_objective_health(event.final_damage_amount)
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
::continue::
|
||||
if not event.entity.valid then return end
|
||||
event.entity.health = event.entity.health + event.final_damage_amount
|
||||
end
|
||||
@ -432,17 +453,16 @@ function Public.loco_died()
|
||||
local this = Scrap_table.get_table()
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
local wave_defense_table = WD.get_table()
|
||||
if this.game_lost == true then return end
|
||||
this.locomotive_health = 0
|
||||
wave_defense_table.game_lost = true
|
||||
wave_defense_table.target = nil
|
||||
game.print("The scrapyard train was destroyed!")
|
||||
game.print("[color=blue]Grandmaster:[/color] Oh noooeeeew!", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] The scrapyard train was destroyed! Better luck next time.", {r = 1, g = 0.5, b = 0.1})
|
||||
for i = 1, 6, 1 do
|
||||
surface.create_entity({name = "big-artillery-explosion", position = this.locomotive_cargo.position})
|
||||
end
|
||||
surface.spill_item_stack(this.locomotive.position,{name = "raw-fish", count = 512}, false)
|
||||
surface.spill_item_stack(this.locomotive_cargo.position,{name = "raw-fish", count = 512}, false)
|
||||
this.game_lost = true
|
||||
this.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}
|
||||
@ -502,7 +522,7 @@ local function on_built_entity(event)
|
||||
local y = event.created_entity.position.y
|
||||
local ent = event.created_entity
|
||||
if y >= 150 then
|
||||
player.print("The scrapyard grandmaster does not approve, " .. ent.name .. " was obliterated.", {r = 1, g = 0.5, b = 0.1})
|
||||
player.print("[color=blue]Grandmaster:[/color] I do not approve, " .. ent.name .. " was obliterated.", {r = 1, g = 0.5, b = 0.1})
|
||||
ent.die()
|
||||
return
|
||||
else
|
||||
@ -511,7 +531,7 @@ local function on_built_entity(event)
|
||||
if y >= 0 then
|
||||
ent.active = false
|
||||
if event.player_index then
|
||||
player.print("The scrapyard grandmaster disabled your " .. ent.name ..".", {r = 1, g = 0.5, b = 0.1})
|
||||
player.print("[color=blue]Grandmaster:[/color] Can't build here. I disabled your " .. ent.name ..".", {r = 1, g = 0.5, b = 0.1})
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -524,7 +544,7 @@ local function on_robot_built_entity(event)
|
||||
local y = event.created_entity.position.y
|
||||
local ent = event.created_entity
|
||||
if y >= 150 then
|
||||
game.print("The scrapyard grandmaster does not approve, " .. ent.name .. " was obliterated.", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] I do not approve, " .. ent.name .. " was obliterated.", {r = 1, g = 0.5, b = 0.1})
|
||||
ent.die()
|
||||
return
|
||||
else
|
||||
@ -533,7 +553,7 @@ local function on_robot_built_entity(event)
|
||||
if y >= 0 then
|
||||
ent.active = false
|
||||
if event.player_index then
|
||||
game.print("The scrapyard grandmaster disabled " .. ent.name ..".", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] Can't build here. I disabled your " .. ent.name ..".", {r = 1, g = 0.5, b = 0.1})
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -587,6 +607,36 @@ local on_init = function()
|
||||
}
|
||||
end
|
||||
|
||||
local on_tick = function()
|
||||
local this = Scrap_table.get_table()
|
||||
if this.game_reset_tick then
|
||||
if this.game_reset_tick < game.tick then
|
||||
this.game_reset_tick = nil
|
||||
Public.reset_map()
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if _DEBUG then
|
||||
commands.add_command(
|
||||
'reset_game',
|
||||
'Debug only, reset the game!',
|
||||
function()
|
||||
local player = game.player
|
||||
|
||||
if player then
|
||||
if player ~= nil then
|
||||
if not player.admin then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
Public.reset_map()
|
||||
end)
|
||||
end
|
||||
|
||||
Event.on_nth_tick(5, on_tick)
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_research_finished, on_research_finished)
|
||||
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
|
@ -16,7 +16,7 @@ local function tick()
|
||||
this.energy["scrapyard"] = this.ow_energy
|
||||
end
|
||||
|
||||
if not this.energy["loco"] then
|
||||
if not this.energy["loco"] then
|
||||
this.energy["loco"] = this.lo_energy
|
||||
end
|
||||
|
||||
|
@ -13,13 +13,14 @@ Global.register(
|
||||
)
|
||||
|
||||
function Public.reset_table()
|
||||
for k, _ in pairs(this) do
|
||||
this[k] = nil
|
||||
end
|
||||
this.game_lost = true
|
||||
--for k, _ in pairs(this) do
|
||||
-- this[k] = nil
|
||||
--end
|
||||
this.game_lost = false
|
||||
this.game_won = false
|
||||
this.max_health = 10000
|
||||
this.health = 10000
|
||||
this.locomotive_health = 10000
|
||||
this.locomotive_max_health = 10000
|
||||
this.revealed_spawn = 0
|
||||
end
|
||||
|
||||
function Public.get_table()
|
||||
|
@ -21,6 +21,7 @@ local rock_raffle = {"sand-rock-big","sand-rock-big", "rock-big","rock-big","roc
|
||||
local scrap_buildings = {"nuclear-reactor", "centrifuge", "beacon", "chemical-plant", "assembling-machine-1", "assembling-machine-2", "assembling-machine-3", "oil-refinery", "arithmetic-combinator", "constant-combinator", "decider-combinator", "programmable-speaker", "steam-turbine", "steam-engine", "chemical-plant", "assembling-machine-1", "assembling-machine-2", "assembling-machine-3", "oil-refinery", "arithmetic-combinator", "constant-combinator", "decider-combinator", "programmable-speaker", "steam-turbine", "steam-engine"}
|
||||
local spawner_raffle = {"biter-spawner", "biter-spawner", "biter-spawner", "spitter-spawner"}
|
||||
local trees = {"dead-grey-trunk", "dead-grey-trunk", "dry-tree"}
|
||||
local colors = {"black", "orange", "red", "yellow"}
|
||||
|
||||
local noises = {
|
||||
["no_rocks"] = {{modifier = 0.0033, weight = 1}, {modifier = 0.01, weight = 0.22}, {modifier = 0.05, weight = 0.05}, {modifier = 0.1, weight = 0.04}},
|
||||
@ -498,7 +499,8 @@ local function process_level_1_position(surface, p, seed, tiles, entities, fishe
|
||||
end
|
||||
|
||||
if noise_cave_ponds > 0.76 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_random(4, 6), position = p}
|
||||
tiles[#tiles + 1] = {name = colors[math_random(1, #colors)].. "-refined-concrete", position = p}
|
||||
--tiles[#tiles + 1] = {name = "dirt-" .. math_random(4, 6), position = p}
|
||||
return
|
||||
end
|
||||
|
||||
@ -518,7 +520,8 @@ local function process_level_1_position(surface, p, seed, tiles, entities, fishe
|
||||
if no_rocks < 0.08 and no_rocks > -0.08 then
|
||||
if small_caves > 0.35 then
|
||||
insert(r_area, {x = p.x, y = p.y})
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_floor(noise_cave_ponds * 32) % 7 + 1, position = p}
|
||||
tiles[#tiles + 1] = {name = colors[math_random(1, #colors)].. "-refined-concrete", position = p}
|
||||
--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 = get_oil_amount(p)} end
|
||||
if math_random(1,96) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier)
|
||||
@ -534,14 +537,16 @@ local function process_level_1_position(surface, p, seed, tiles, entities, fishe
|
||||
--Main Terrain
|
||||
local no_rocks_2 = get_noise("no_rocks_2", p, seed + 75000)
|
||||
if no_rocks_2 > 0.70 or no_rocks_2 < -0.70 then
|
||||
tiles[#tiles + 1] = {name = "dirt-" .. math_floor(no_rocks_2 * 8) % 2 + 5, position = p}
|
||||
tiles[#tiles + 1] = {name = colors[math_random(1, #colors)].. "-refined-concrete", position = p}
|
||||
--tiles[#tiles + 1] = {name = "dirt-" .. math_floor(no_rocks_2 * 8) % 2 + 5, position = p}
|
||||
if math_random(1,32) == 1 then entities[#entities + 1] = {name = trees[math_random(1, #trees)], position=p} end
|
||||
if math_random(1,512) == 1 then treasure[#treasure + 1] = p end
|
||||
return
|
||||
end
|
||||
|
||||
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
tiles[#tiles + 1] = {name = colors[math_random(1, #colors)].. "-refined-concrete", position = p}
|
||||
-- tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,2048) == 1 then place_random_scrap_entity(surface, p) end
|
||||
if math_random(1,100) > 30 then entities[#entities + 1] = {name = "mineable-wreckage", position = p} end
|
||||
end
|
||||
@ -575,6 +580,7 @@ function Public.reveal_area(x, y, surface, max_radius)
|
||||
for r = 1, max_radius, 1 do
|
||||
for _, v in pairs(circles[r]) do
|
||||
local pos = {x = x + v.x, y = y + v.y}
|
||||
if not surface.get_tile(pos) then return end
|
||||
local t_name = surface.get_tile(pos).name == "out-of-map"
|
||||
if t_name then
|
||||
process_level(surface, pos, seed, tiles, entities, fishes, r_area, markets, treasure)
|
||||
@ -679,14 +685,31 @@ local function generate_spawn_area(surface, position_left_top)
|
||||
|
||||
for r = 1, 12 do
|
||||
for k, v in pairs(circles[r]) do
|
||||
local t_insert = false
|
||||
local pos = {x = position_left_top.x + v.x, y = position_left_top.y+20 + v.y}
|
||||
if pos.x > -15 and pos.x < 15 and pos.y < 40 then
|
||||
t_insert = "stone-path"
|
||||
insert(tiles, {name = colors[math_random(1, #colors)].. "-refined-concrete", position = pos})
|
||||
end
|
||||
if t_insert then
|
||||
insert(tiles, {name = t_insert, position = pos})
|
||||
if pos.x > -30 and pos.x < 30 and pos.y < 40 then
|
||||
insert(tiles, {name = colors[math_random(1, #colors)].. "-refined-concrete", position = pos})
|
||||
end
|
||||
if pos.x > -60 and pos.x < 60 and pos.y < 40 then
|
||||
insert(tiles, {name = colors[math_random(1, #colors)].. "-refined-concrete", position = pos})
|
||||
end
|
||||
if pos.x > -90 and pos.x < 90 and pos.y < 40 then
|
||||
insert(tiles, {name = colors[math_random(1, #colors)].. "-refined-concrete", position = pos})
|
||||
end
|
||||
if pos.x > -120 and pos.x < 120 and pos.y < 40 then
|
||||
insert(tiles, {name = colors[math_random(1, #colors)].. "-refined-concrete", position = pos})
|
||||
end
|
||||
if pos.x > -150 and pos.x < 150 and pos.y < 40 then
|
||||
insert(tiles, {name = colors[math_random(1, #colors)].. "-refined-concrete", position = pos})
|
||||
end
|
||||
if pos.x > -180 and pos.x < 180 and pos.y < 40 then
|
||||
insert(tiles, {name = colors[math_random(1, #colors)].. "-refined-concrete", position = pos})
|
||||
end
|
||||
--if t_insert then
|
||||
-- insert(tiles, {name = t_insert, position = pos})
|
||||
--end
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles, true)
|
||||
@ -828,6 +851,7 @@ local function out_of_map(surface, left_top)
|
||||
end
|
||||
|
||||
local function on_chunk_generated(event)
|
||||
local this = Scrap_table.get_table()
|
||||
if string.sub(event.surface.name, 0, 9) ~= "scrapyard" then return end
|
||||
local surface = event.surface
|
||||
local left_top = event.area.left_top
|
||||
@ -835,13 +859,28 @@ local function on_chunk_generated(event)
|
||||
if left_top.x < level_depth * -0.5 then out_of_map(surface, left_top) return end
|
||||
if surface.name ~= event.surface.name then return end
|
||||
|
||||
if this.revealed_spawn > game.tick then
|
||||
for i = 80, -80, -10 do
|
||||
Public.reveal_area(0, i, surface, 4)
|
||||
Public.reveal_area(0, i, surface, 4)
|
||||
Public.reveal_area(0, i, surface, 4)
|
||||
Public.reveal_area(0, i, surface, 4)
|
||||
end
|
||||
|
||||
for v = 80, -80, -10 do
|
||||
Public.reveal_area(v, 0, surface, 4)
|
||||
Public.reveal_area(v, 0, surface, 4)
|
||||
Public.reveal_area(v, 0, surface, 4)
|
||||
Public.reveal_area(v, 0, surface, 4)
|
||||
end
|
||||
end
|
||||
|
||||
if left_top.y % level_depth == 0 and left_top.y < 0 and left_top.y > level_depth * -10 then wall(surface, left_top, surface.map_gen_settings.seed) return end
|
||||
|
||||
if left_top.y > 268 then out_of_map(surface, left_top) return end
|
||||
if left_top.y >= 0 then replace_water(surface, left_top) end
|
||||
if left_top.y > 210 then biter_chunk(surface, left_top) end
|
||||
if left_top.y >= 0 then border_chunk(surface, left_top) end
|
||||
if left_top.y >= 10 then border_chunk(surface, left_top) end
|
||||
if left_top.y < 0 then process(surface, left_top) end
|
||||
out_of_map_area(event)
|
||||
generate_spawn_area(surface, left_top)
|
||||
|
@ -21,7 +21,7 @@ local function on_player_changed_position(event)
|
||||
if player.character.driving == true then return end
|
||||
if player.surface.daytime < 0.33 then return end
|
||||
if player.surface.daytime > 0.66 then return end
|
||||
if math.random(1,32) ~= 1 then return end
|
||||
if math.random(1,32) ~= 1 then return end
|
||||
|
||||
for _, lamp in pairs(player.surface.find_entities_filtered({area={{player.position.x - 18, player.position.y - 18},{player.position.x + 18, player.position.y + 18}}, name="small-lamp"})) do
|
||||
local circuit = lamp.get_or_create_control_behavior()
|
||||
|
@ -6,6 +6,7 @@
|
||||
require "modules.custom_death_messages"
|
||||
require "maps.hunger_games_map_intro"
|
||||
require "modules.dynamic_player_spawn"
|
||||
local Score = require "comfy_panel.score"
|
||||
--require "maps.modules.hunger_games_balance"
|
||||
|
||||
local event = require 'utils.event'
|
||||
@ -444,6 +445,7 @@ local function on_player_respawned(event)
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
local get_score = Score.get_table().score_table
|
||||
local entity = event.created_entity
|
||||
if not entity.valid then return end
|
||||
local distance_to_center = math.sqrt(entity.position.x^2 + entity.position.y^2)
|
||||
@ -452,10 +454,10 @@ local function on_built_entity(event)
|
||||
surface.create_entity({name = "flying-text", position = entity.position, text = "Spawn is protected from building.", color = {r=0.88, g=0.1, b=0.1}})
|
||||
local player = game.players[event.player_index]
|
||||
player.insert({name = entity.name, count = 1})
|
||||
if global.score then
|
||||
if global.score[player.force.name] then
|
||||
if global.score[player.force.name].players[player.name] then
|
||||
global.score[player.force.name].players[player.name].built_entities = global.score[player.force.name].players[player.name].built_entities - 1
|
||||
if get_score then
|
||||
if get_score[player.force.name] then
|
||||
if get_score[player.force.name].players[player.name] then
|
||||
get_score[player.force.name].players[player.name].built_entities = get_score[player.force.name].players[player.name].built_entities - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -89,7 +89,14 @@ end
|
||||
|
||||
local function input_cargo(wagon, chest)
|
||||
if not chest.request_from_buffers then return end
|
||||
local wagon_inventory = wagon.entity.get_inventory(defines.inventory.cargo_wagon)
|
||||
|
||||
local wagon_entity = wagon.entity
|
||||
if not wagon_entity.valid then
|
||||
wagon.transfer_entities = nil
|
||||
return
|
||||
end
|
||||
|
||||
local wagon_inventory = wagon_entity.get_inventory(defines.inventory.cargo_wagon)
|
||||
if wagon_inventory.is_empty() then return end
|
||||
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
@ -507,8 +514,10 @@ end
|
||||
function Public.reconstruct_all_trains(icw)
|
||||
icw.trains = {}
|
||||
for unit_number, wagon in pairs(icw.wagons) do
|
||||
local carriages = wagon.entity.train.carriages
|
||||
Public.construct_train(icw, carriages)
|
||||
if wagon.entity and wagon.entity.valid then
|
||||
local carriages = wagon.entity.train.carriages
|
||||
Public.construct_train(icw, carriages)
|
||||
end
|
||||
end
|
||||
delete_empty_surfaces(icw)
|
||||
end
|
||||
@ -574,8 +583,8 @@ function Public.toggle_minimap(icw, event)
|
||||
return
|
||||
end
|
||||
if event.button == defines.mouse_button_type.middle then
|
||||
player_data.map_size = player_data.map_size + 60
|
||||
if player_data.map_size > 720 then player_data.map_size = 300 end
|
||||
player_data.map_size = player_data.map_size + 50
|
||||
if player_data.map_size > 650 then player_data.map_size = 250 end
|
||||
element.style.minimal_height = player_data.map_size
|
||||
element.style.minimal_width = player_data.map_size
|
||||
element.style.maximal_height = player_data.map_size
|
||||
|
@ -5,6 +5,7 @@
|
||||
local Event = require 'utils.event'
|
||||
local Token = require 'utils.token'
|
||||
local Task = require 'utils.task'
|
||||
local Score = require "comfy_panel.score"
|
||||
local floor = math.floor
|
||||
local sqrt = math.sqrt
|
||||
local insert = table.insert
|
||||
@ -65,12 +66,13 @@ local function create_reward_button(player)
|
||||
end
|
||||
|
||||
local function show_rewards(player)
|
||||
local get_score = Score.get_table().score_table
|
||||
if player.gui.left["rewards_panel"] then player.gui.left["rewards_panel"].destroy() end
|
||||
local frame = player.gui.left.add { type = "frame", name = "rewards_panel", direction = "vertical" }
|
||||
|
||||
local current_level = global.rewards[player.name].level
|
||||
local next_level = current_level + 1
|
||||
local kill_score = global.score[player.force.name].players[player.name].killscore
|
||||
local kill_score = get_score[player.force.name].players[player.name].killscore
|
||||
|
||||
local next_level_score = ((3.5 + next_level)^2.7 / 10) * 100
|
||||
local min_score = ((3.5 + current_level)^2.7 / 10) * 100
|
||||
@ -177,10 +179,11 @@ local function reward_messages(data)
|
||||
end
|
||||
|
||||
local function kill_rewards(event)
|
||||
local get_score = Score.get_table().score_table
|
||||
if not event.cause then return end
|
||||
local player = event.cause.player
|
||||
local pinsert = player.insert
|
||||
local score = global.score[player.force.name]
|
||||
local score = get_score[player.force.name]
|
||||
local kill_score = score.players[player.name].killscore
|
||||
|
||||
-- If kill score isn't found don't run the other stuff
|
||||
|
Loading…
x
Reference in New Issue
Block a user