1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-26 03:52:22 +02:00

display of threat / minute

This commit is contained in:
MewMew 2019-10-28 13:29:15 +01:00
parent a569571a5a
commit 9db9d71c33
5 changed files with 53 additions and 12 deletions

View File

@ -28,7 +28,6 @@ require "modules.floaty_chat"
--require "on_tick_schedule"
---- enable modules here ----
--require "tools.cheat_mode"
--require "modules.the_floor_is_lava"
--require "modules.biters_landfill_on_death"
--require "modules.autodecon_when_depleted"

View File

@ -68,10 +68,10 @@ local function process_level_5_position(p, seed, tiles, entities, markets, treas
local small_caves = get_noise("small_caves", p, seed)
local noise_cave_ponds = get_noise("cave_ponds", p, seed)
if small_caves > -0.10 and small_caves < 0.10 then
if small_caves > -0.14 and small_caves < 0.14 then
tiles[#tiles + 1] = {name = "dirt-7", position = p}
if math_random(1,768) == 1 then treasure[#treasure + 1] = p end
if math_random(1,2) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end
if math_random(1,3) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end
return
end

View File

@ -95,7 +95,7 @@ function treasure_chest(surface, position)
{{name = "assembling-machine-3", count = math_random(2,4)}, weight = 3, evo_min = 0.5, evo_max = 1},
{{name = "accumulator", count = math_random(4,8)}, weight = 3, evo_min = 0.4, evo_max = 1},
{{name = "offshore-pump", count = math_random(1,3)}, weight = 2, evo_min = 0.0, evo_max = 0.2},
{{name = "beacon", count = 1}, weight = 3, evo_min = 0.7, evo_max = 1},
{{name = "beacon", count = 1}, weight = 2, evo_min = 0.7, evo_max = 1},
{{name = "boiler", count = math_random(3,6)}, weight = 3, evo_min = 0.0, evo_max = 0.3},
{{name = "steam-engine", count = math_random(2,4)}, weight = 3, evo_min = 0.0, evo_max = 0.5},
{{name = "steam-turbine", count = math_random(1,2)}, weight = 2, evo_min = 0.6, evo_max = 1},

View File

@ -18,14 +18,26 @@ local function create_gui(player)
local line = frame.add({type = "line", direction = "vertical"})
line.style.left_padding = 4
line.style.right_padding = 4
local label = frame.add({ type = "label", caption = " ", name = "threat", tooltip = "high threat may empower biters"})
label.style.font_color = {r=0.88, g=0.88, b=0.88}
label.style.font = "default-bold"
label.style.left_padding = 4
label.style.right_padding = 4
label.style.right_padding = 1
label.style.minimal_width = 10
label.style.font_color = {r=0.99, g=0.0, b=0.5}
label.style.font_color = {r = 150, g = 0, b = 255}
local label = frame.add({ type = "label", caption = " ", name = "threat_gains", tooltip = "gain / minute"})
label.style.font = "default"
label.style.left_padding = 1
label.style.right_padding = 1
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
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)
return gain
end
local function update_gui(player)
@ -34,7 +46,28 @@ local function update_gui(player)
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.threat.caption = "Threat: " .. math.floor(global.wave_defense.threat)
if global.wave_defense.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
if gain >= 0 then
player.gui.top.wave_defense.threat_gains.caption = " (+" .. gain .. ")"
local g = 255 - math.floor(gain / d)
if g < 0 then g = 0 end
player.gui.top.wave_defense.threat_gains.style.font_color = {255, g, 0}
else
player.gui.top.wave_defense.threat_gains.caption = " (" .. gain .. ")"
local r = 255 - math.floor(math.abs(gain) / d)
if r < 0 then r = 0 end
player.gui.top.wave_defense.threat_gains.style.font_color = {r, 255, 0}
end
end
return update_gui

View File

@ -400,6 +400,12 @@ local function spawn_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
end
local tick_tasks = {
[30] = set_main_target,
[60] = set_enemy_evolution,
@ -414,16 +420,17 @@ local tick_tasks = {
local function on_tick()
if global.wave_defense.game_lost then return end
for _, player in pairs(game.connected_players) do update_gui(player) end
if game.tick > global.wave_defense.next_wave then set_next_wave() end
local t = game.tick % 300
local t2 = game.tick % 18000
if tick_tasks[t] then tick_tasks[t]() end
if tick_tasks[t2] then tick_tasks[t2]() end
if game.tick % 60 == 0 then log_threat() end
for _, player in pairs(game.connected_players) do update_gui(player) end
end
function reset_wave_defense()
@ -448,6 +455,8 @@ function reset_wave_defense()
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,