mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2024-12-30 23:17:53 +02:00
updates
This commit is contained in:
parent
05334b4478
commit
9537b77267
@ -67,7 +67,7 @@ local function select_units_around_spawner(spawner, force_name, biter_force_name
|
||||
local biters = spawner.surface.find_enemy_units(spawner.position, 160, force_name)
|
||||
if not biters[1] then return false end
|
||||
local valid_biters = {}
|
||||
local size = math_random(2, 4) * 0.1
|
||||
local size = math_random(2, 3) * 0.1
|
||||
local threat = global.bb_threat[biter_force_name] * size
|
||||
for _, biter in pairs(biters) do
|
||||
if biter.force.name == biter_force_name then
|
||||
@ -135,6 +135,25 @@ local function protect_silo(event)
|
||||
event.entity.health = event.entity.health + event.final_damage_amount
|
||||
end
|
||||
|
||||
--Prevent Players from doing direct pvp combat
|
||||
local function ignore_pvp(event)
|
||||
if not event.cause then return end
|
||||
if event.cause.force.name == "north" then
|
||||
if event.entity.force.name == "south" then
|
||||
if not event.entity.valid then return end
|
||||
event.entity.health = event.entity.health + event.final_damage_amount
|
||||
return
|
||||
end
|
||||
end
|
||||
if event.cause.force.name == "south" then
|
||||
if event.entity.force.name == "north" then
|
||||
if not event.entity.valid then return end
|
||||
event.entity.health = event.entity.health + event.final_damage_amount
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Biter Evasion
|
||||
local function evade(event)
|
||||
if not event.entity.valid then return end
|
||||
@ -146,6 +165,7 @@ end
|
||||
local function on_entity_damaged(event)
|
||||
evade(event)
|
||||
protect_silo(event)
|
||||
--ignore_pvp(event)
|
||||
end
|
||||
|
||||
--Biter Threat Value Substraction
|
||||
|
@ -21,22 +21,13 @@ local function spy_fish()
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
local function reveal_team(f)
|
||||
local m = 32
|
||||
if f == "north" then
|
||||
game.forces["south"].chart(
|
||||
game.surfaces["biter_battles"],
|
||||
{{x = global.force_area[f].x_top - m, y = global.force_area[f].y_top - m}, {x = global.force_area[f].x_bot + m, y = global.force_area[f].y_bot + m}}
|
||||
)
|
||||
else
|
||||
game.forces["north"].chart(
|
||||
game.surfaces["biter_battles"],
|
||||
{{x = global.force_area[f].x_top - m, y = global.force_area[f].y_top - m}, {x = global.force_area[f].x_bot + m, y = global.force_area[f].y_bot + m}}
|
||||
)
|
||||
end
|
||||
local function clear_corpses()
|
||||
for _, e in pairs(game.surfaces["biter_battles"].find_entities_filtered({type = "corpse"})) do
|
||||
if math.random(1, 3) == 1 then
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
]]
|
||||
|
||||
local function on_tick(event)
|
||||
if game.tick % 30 ~= 0 then return end
|
||||
@ -56,7 +47,10 @@ local function on_tick(event)
|
||||
if game.tick % 1800 ~= 0 then return end
|
||||
|
||||
ai.main_attack()
|
||||
ai.send_near_biters_to_silo()
|
||||
ai.send_near_biters_to_silo()
|
||||
|
||||
if game.tick % 3600 ~= 0 then return end
|
||||
clear_corpses()
|
||||
end
|
||||
|
||||
event.add(defines.events.on_tick, on_tick)
|
||||
|
@ -80,8 +80,8 @@ end
|
||||
local function generate_horizontal_river(surface, pos)
|
||||
if pos.y < -32 then return false end
|
||||
if pos.y > -5 and pos.x > -5 and pos.x < 5 then return false end
|
||||
if -13 < pos.y + (get_noise(1, pos) * 5) then return true end
|
||||
--if -12 < pos.y + (get_noise(3, pos) * 6) then return true end
|
||||
if -11 < pos.y + (get_noise(1, pos) * 5) then return true end
|
||||
--if -13 < pos.y + (get_noise(1, pos) * 5) then return true end
|
||||
return false
|
||||
end
|
||||
|
||||
|
@ -195,7 +195,7 @@ local function create_cave_miner_stats_gui(player)
|
||||
separators[2] = t.add { type = "label", caption = "|"}
|
||||
|
||||
captions[3] = t.add { type = "label", caption = "Efficiency" }
|
||||
local x = math.ceil(game.forces.player.manual_mining_speed_modifier * 100 + player_hunger_buff[global.player_hunger[player.name]] * 100, 0)
|
||||
local x = math.floor(game.forces.player.manual_mining_speed_modifier * 100 + player_hunger_buff[global.player_hunger[player.name]] * 100)
|
||||
local str = ""
|
||||
if x > 0 then str = str .. "+" end
|
||||
str = str .. tostring(x)
|
||||
@ -796,6 +796,8 @@ end
|
||||
|
||||
local function hunger_update(player, food_value)
|
||||
|
||||
if not player.character then return end
|
||||
|
||||
if food_value == -1 and player.character.driving == true then return end
|
||||
|
||||
local past_hunger = global.player_hunger[player.name]
|
||||
@ -891,7 +893,7 @@ Darkness is a hazard in the mines, stay near your lamps..
|
||||
|
||||
global.biter_spawn_schedule = {}
|
||||
|
||||
global.ore_spill_cap = 35
|
||||
global.ore_spill_cap = 60
|
||||
global.stats_rocks_broken = 0
|
||||
global.stats_ores_found = 0
|
||||
global.total_ores_mined = 0
|
||||
@ -1182,7 +1184,7 @@ local function pre_player_mined_item(event)
|
||||
if math_random(1,3) == 1 then hunger_update(player, -1) end
|
||||
|
||||
surface.spill_item_stack(player.position,{name = "raw-fish", count = math_random(3,4)},true)
|
||||
local bonus_amount = math.ceil((tile_distance_to_center - math.sqrt(spawn_dome_size)) * 0.10, 0)
|
||||
local bonus_amount = math.floor((tile_distance_to_center - math.sqrt(spawn_dome_size)) * 0.10, 0)
|
||||
if bonus_amount < 1 then bonus_amount = 0 end
|
||||
local amount = math_random(45,55) + bonus_amount
|
||||
if amount > 200 then amount = 200 end
|
||||
|
@ -268,7 +268,7 @@ local function place_random_scrap_entity(surface, position)
|
||||
end
|
||||
if r < 90 then
|
||||
local e = surface.create_entity({name = "gun-turret", position = position, force = "scrap_defense"})
|
||||
e.insert({name = "firearm-magazine", count = math.random(8, 128)})
|
||||
e.insert({name = "piercing-rounds-magazine", count = math.random(8, 128)})
|
||||
return
|
||||
end
|
||||
|
||||
@ -277,7 +277,7 @@ local function place_random_scrap_entity(surface, position)
|
||||
e.fluidbox[1] = {name = fluids[math.random(1, #fluids)], amount = math.random(15000, 25000)}
|
||||
create_entity_chain(surface, {name = "pipe", position = position, force = "player"}, math_random(6,8), 1)
|
||||
create_entity_chain(surface, {name = "pipe", position = position, force = "player"}, math_random(6,8), 1)
|
||||
create_entity_chain(surface, {name = "pipe", position = position, force = "player"}, math_random(20,40), 80)
|
||||
create_entity_chain(surface, {name = "pipe", position = position, force = "player"}, math_random(15,30), 80)
|
||||
end
|
||||
|
||||
local function create_inner_content(surface, pos, noise)
|
||||
|
@ -1,14 +1,5 @@
|
||||
local event = require 'utils.event'
|
||||
|
||||
--local function trigger_function(schedule)
|
||||
-- if not schedule.args then schedule.func() return end
|
||||
-- if not schedule.args[2] then schedule.func(schedule.args[1]) return end
|
||||
-- if not schedule.args[3] then schedule.func(schedule.args[1], schedule.args[2]) return end
|
||||
-- if not schedule.args[4] then schedule.func(schedule.args[1], schedule.args[2], schedule.args[3]) return end
|
||||
-- if not schedule.args[5] then schedule.func(schedule.args[1], schedule.args[2], schedule.args[3], schedule.args[4]) return end
|
||||
-- if schedule.args[5] then schedule.func(schedule.args[1], schedule.args[2], schedule.args[3], schedule.args[4], schedule.args[5]) return end
|
||||
--end
|
||||
|
||||
local function on_tick()
|
||||
if not global.on_tick_schedule[game.tick] then return end
|
||||
for _, schedule in pairs(global.on_tick_schedule[game.tick]) do
|
||||
|
@ -100,7 +100,7 @@ local function get_rank(player)
|
||||
|
||||
--52 ranks
|
||||
|
||||
local time_needed = 120 -- in minutes between rank upgrades
|
||||
local time_needed = 240 -- in minutes between rank upgrades
|
||||
m = m / time_needed
|
||||
m = math.floor(m)
|
||||
m = m + 1
|
||||
|
262
poll_old.lua
262
poll_old.lua
@ -1,262 +0,0 @@
|
||||
-- create polls for players to vote on
|
||||
-- by MewMew -- with some help from RedLabel, Klonan, Morcup, BrainClot
|
||||
|
||||
local event = require 'utils.event'
|
||||
local poll_duration_in_seconds = 99
|
||||
|
||||
local function create_poll_gui(player)
|
||||
if player.gui.top.poll then return end
|
||||
local button = player.gui.top.add { name = "poll", type = "sprite-button", sprite = "item/programmable-speaker", tooltip = "Show current poll" }
|
||||
button.style.font = "default-bold"
|
||||
button.style.minimal_height = 38
|
||||
button.style.minimal_width = 38
|
||||
button.style.top_padding = 2
|
||||
button.style.left_padding = 4
|
||||
button.style.right_padding = 4
|
||||
button.style.bottom_padding = 2
|
||||
end
|
||||
|
||||
local function poll_show(player)
|
||||
if player.gui.left["poll-panel"] then player.gui.left["poll-panel"].destroy() end
|
||||
|
||||
global.poll_panel_creation_times[player.index] = {player_index = player.index, tick = 5940}
|
||||
|
||||
local frame = player.gui.left.add { type = "frame", name = "poll-panel", direction = "vertical" }
|
||||
|
||||
local t = frame.add { type = "table", name = "poll_panel_table", column_count = 2 }
|
||||
|
||||
if global.poll_question ~= "" then
|
||||
|
||||
local str = "Poll #" .. global.score_total_polls_created .. ":"
|
||||
if global.score_total_polls_created > 1 then
|
||||
local x = game.tick
|
||||
x = ((x / 60) / 60) / 60
|
||||
x = global.score_total_polls_created / x
|
||||
x = math.round(x, 0)
|
||||
str = str .. " (Polls/hour: "
|
||||
str = str .. x
|
||||
str = str .. ")"
|
||||
end
|
||||
|
||||
t.add { type = "label", caption = str, single_line = false, name = "poll_number_label" }
|
||||
t.poll_number_label.style.font_color = { r=0.75, g=0.75, b=0.75}
|
||||
t.add { type = "label"}
|
||||
t.add { type = "label", caption = global.poll_question, name = "question_label" }
|
||||
t.question_label.style.maximal_width = 208
|
||||
t.question_label.style.maximal_height = 170
|
||||
t.question_label.style.font = "default-bold"
|
||||
t.question_label.style.font_color = { r=0.98, g=0.66, b=0.22}
|
||||
t.question_label.style.single_line = false
|
||||
t.add { type = "label" }
|
||||
end
|
||||
|
||||
for i = 1, 3, 1 do
|
||||
if global.poll_answers[i] ~= "" then
|
||||
local l = t.add({type = "label", caption = global.poll_answers[i], name = "answer_label_" .. tostring(i)})
|
||||
l.style.maximal_width = 208
|
||||
l.style.minimal_width = 208
|
||||
l.style.maximal_height = 165
|
||||
l.style.font = "default"
|
||||
l.style.single_line = false
|
||||
local b = t.add({type = "button", caption = global.poll_button_votes[i], name = "answer_button_" .. tostring(i)})
|
||||
b.style.font = "default-listbox"
|
||||
b.style.minimal_width = 32
|
||||
end
|
||||
end
|
||||
|
||||
local t = frame.add { type = "table", name = "poll_panel_button_table", column_count = 3 }
|
||||
|
||||
t.add { type = "button", caption = "New Poll", name = "new_poll_assembler_button" }
|
||||
|
||||
local str = "Hide (" .. poll_duration_in_seconds
|
||||
str = str .. ")"
|
||||
|
||||
t.add { type = "button", caption = str, name = "poll_hide_button" }
|
||||
|
||||
t.poll_hide_button.style.minimal_width = 70
|
||||
t.new_poll_assembler_button.style.font = "default-bold"
|
||||
t.new_poll_assembler_button.style.minimal_height = 38
|
||||
t.poll_hide_button.style.font = "default-bold"
|
||||
t.poll_hide_button.style.minimal_height = 38
|
||||
t.add { type = "checkbox", caption = "Show Polls", state = global.autoshow_polls_for_player[player.name], name = "auto_show_polls_checkbox" }
|
||||
end
|
||||
|
||||
local function poll(player)
|
||||
local frame = player.gui.left["poll-assembler"]
|
||||
frame = frame.table_poll_assembler
|
||||
|
||||
if frame.textfield_question.text == "" then return end
|
||||
if frame.textfield_answer_1.text == "" and frame.textfield_answer_2.text == "" and frame.textfield_answer_3.text == "" then return end
|
||||
|
||||
global.poll_question = frame.textfield_question.text
|
||||
global.poll_answers = {frame.textfield_answer_1.text, frame.textfield_answer_2.text, frame.textfield_answer_3.text}
|
||||
|
||||
local msg = player.name
|
||||
msg = msg .. " has created a new Poll!"
|
||||
|
||||
global.score_total_polls_created = global.score_total_polls_created + 1
|
||||
|
||||
player.gui.left["poll-assembler"].destroy()
|
||||
|
||||
global.poll_voted = {}
|
||||
global.poll_button_votes = {0,0,0}
|
||||
|
||||
for _, player in pairs(game.players) do
|
||||
if player.gui.left["poll-panel"] then
|
||||
player.gui.left["poll-panel"].destroy()
|
||||
end
|
||||
if global.autoshow_polls_for_player[player.name] == true then
|
||||
poll_show(player)
|
||||
end
|
||||
player.print(msg, { r=0.22, g=0.99, b=0.99})
|
||||
end
|
||||
end
|
||||
|
||||
local function poll_refresh()
|
||||
for _, player in pairs(game.players) do
|
||||
if player.gui.left["poll-panel"] then
|
||||
local frame = player.gui.left["poll-panel"]
|
||||
frame = frame.poll_panel_table
|
||||
if frame.answer_button_1 then frame.answer_button_1.caption = global.poll_button_votes[1] end
|
||||
if frame.answer_button_2 then frame.answer_button_2.caption = global.poll_button_votes[2] end
|
||||
if frame.answer_button_3 then frame.answer_button_3.caption = global.poll_button_votes[3] end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function poll_assembler(player)
|
||||
local frame = player.gui.left.add { type = "frame", name = "poll-assembler", caption = "" }
|
||||
local frame_table = frame.add { type = "table", name = "table_poll_assembler", column_count = 2 }
|
||||
frame_table.add { type = "label", caption = "Question:" }
|
||||
frame_table.add { type = "textfield", name = "textfield_question", text = "" }
|
||||
frame_table.add { type = "label", caption = "Answer #1:" }
|
||||
frame_table.add { type = "textfield", name = "textfield_answer_1", text = "" }
|
||||
frame_table.add { type = "label", caption = "Answer #2:" }
|
||||
frame_table.add { type = "textfield", name = "textfield_answer_2", text = "" }
|
||||
frame_table.add { type = "label", caption = "Answer #3:" }
|
||||
frame_table.add { type = "textfield", name = "textfield_answer_3", text = "" }
|
||||
frame_table.add { type = "label", caption = "" }
|
||||
frame_table.add { type = "button", name = "create_new_poll_button", caption = "Create" }
|
||||
end
|
||||
|
||||
function on_player_joined_game(event)
|
||||
if not global.poll_init_done then
|
||||
global.poll_panel_creation_times = {}
|
||||
global.poll_voted = {}
|
||||
global.poll_question = ""
|
||||
global.poll_answers = {"","",""}
|
||||
global.poll_button_votes = {0,0,0}
|
||||
global.poll_voted = {}
|
||||
global.autoshow_polls_for_player = {}
|
||||
global.score_total_polls_created = 0
|
||||
global.poll_init_done = true
|
||||
end
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
if not global.autoshow_polls_for_player[player.name] then global.autoshow_polls_for_player[player.name] = true end
|
||||
|
||||
create_poll_gui(player)
|
||||
|
||||
if global.poll_question == "" then return end
|
||||
|
||||
poll_show(player)
|
||||
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
|
||||
|
||||
local player = game.players[event.element.player_index]
|
||||
local name = event.element.name
|
||||
|
||||
if name == "poll" then
|
||||
global.poll_panel_creation_times[player.index] = nil
|
||||
|
||||
local frame = player.gui.left["poll-panel"]
|
||||
if frame then
|
||||
frame.destroy()
|
||||
else
|
||||
poll_show(player)
|
||||
end
|
||||
|
||||
local frame = player.gui.left["poll-assembler"]
|
||||
if frame then
|
||||
frame.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
if name == "new_poll_assembler_button" then
|
||||
local frame = player.gui.left["poll-assembler"]
|
||||
if (frame) then
|
||||
frame.destroy()
|
||||
else
|
||||
poll_assembler(player)
|
||||
end
|
||||
end
|
||||
|
||||
if name == "create_new_poll_button" then
|
||||
poll(player)
|
||||
end
|
||||
|
||||
if name == "poll_hide_button" then
|
||||
player.gui.left["poll-panel"].destroy()
|
||||
global.poll_panel_creation_times[player.index] = nil
|
||||
if player.gui.left["poll-assembler"] then
|
||||
player.gui.left["poll-assembler"].destroy()
|
||||
end
|
||||
end
|
||||
|
||||
if name == "auto_show_polls_checkbox" then
|
||||
global.autoshow_polls_for_player[player.name] = event.element.state
|
||||
end
|
||||
|
||||
if global.poll_voted[event.player_index] == nil then
|
||||
|
||||
if name == "answer_button_1" then
|
||||
global.poll_button_votes[1] = global.poll_button_votes[1] + 1
|
||||
global.poll_voted[event.player_index] = player.name
|
||||
poll_refresh()
|
||||
end
|
||||
|
||||
if name == "answer_button_2" then
|
||||
global.poll_button_votes[2] = global.poll_button_votes[2] + 1
|
||||
global.poll_voted[event.player_index] = player.name
|
||||
poll_refresh()
|
||||
end
|
||||
|
||||
if name == "answer_button_3" then
|
||||
global.poll_button_votes[3] = global.poll_button_votes[3] + 1
|
||||
global.poll_voted[event.player_index] = player.name
|
||||
poll_refresh()
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
local function process_timeout(creation_time)
|
||||
local player = game.players[creation_time.player_index]
|
||||
local frame = player.gui.left["poll-panel"]
|
||||
global.poll_panel_creation_times[player.index].tick = global.poll_panel_creation_times[player.index].tick - 60
|
||||
if global.poll_panel_creation_times[player.index].tick <= 0 then
|
||||
if frame then frame.destroy() end
|
||||
global.poll_panel_creation_times[player.index] = nil
|
||||
return
|
||||
else
|
||||
if frame then
|
||||
frame.poll_panel_button_table.poll_hide_button.caption = "Hide (" .. math.ceil(global.poll_panel_creation_times[player.index].tick / 60) .. ")"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_tick()
|
||||
if game.tick % 60 ~= 0 then return end
|
||||
for _, creation_time in pairs(global.poll_panel_creation_times) do
|
||||
process_timeout(creation_time)
|
||||
end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_tick, on_tick)
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
@ -86,7 +86,7 @@ f.draw_rainbow_patch_v2 = function(position, surface, radius, richness)
|
||||
if not surface then return end
|
||||
if not radius then return end
|
||||
if not richness then return end
|
||||
local modifier_1 = math_random(2,10)
|
||||
local modifier_1 = math_random(2,7)
|
||||
local modifier_2 = math_random(100,200) * 0.0002
|
||||
local modifier_3 = math_random(100,200) * 0.0015
|
||||
local modifier_4 = math_random(15,30) * 0.01
|
||||
|
Loading…
Reference in New Issue
Block a user