mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-24 03:47:58 +02:00
Merge branch 'develop' into develop
This commit is contained in:
commit
d5f21ada90
@ -16,7 +16,7 @@ local sub = string.sub
|
||||
local sqrt = math.sqrt
|
||||
local zone_settings = Public.zone_settings
|
||||
|
||||
local clear_breach_text_and_render = function()
|
||||
local clear_breach_text_and_render = function ()
|
||||
local beam1 = Public.get('zone1_beam1')
|
||||
if beam1 and beam1.valid then
|
||||
beam1.destroy()
|
||||
@ -45,81 +45,81 @@ end
|
||||
|
||||
local collapse_message =
|
||||
Task.register(
|
||||
function(data)
|
||||
local pos = data.position
|
||||
local message = ({'breached_wall.collapse_start'})
|
||||
local collapse_position = {
|
||||
position = pos
|
||||
}
|
||||
Alert.alert_all_players_location(collapse_position, message)
|
||||
end
|
||||
)
|
||||
function (data)
|
||||
local pos = data.position
|
||||
local message = ({ 'breached_wall.collapse_start' })
|
||||
local collapse_position = {
|
||||
position = pos
|
||||
}
|
||||
Alert.alert_all_players_location(collapse_position, message)
|
||||
end
|
||||
)
|
||||
|
||||
local driving_state_changed_token =
|
||||
Task.register(
|
||||
function(event)
|
||||
local player_index = event.player_index
|
||||
local player = game.get_player(player_index)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
function (event)
|
||||
local player_index = event.player_index
|
||||
local player = game.get_player(player_index)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local entity = event.entity
|
||||
if not (entity and entity.valid) then
|
||||
return
|
||||
end
|
||||
local entity = event.entity
|
||||
if not (entity and entity.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
local s = Public.get('validate_spider')
|
||||
if entity.name == 'spidertron' then
|
||||
if player.driving then
|
||||
if not s[player.index] then
|
||||
s[player.index] = entity
|
||||
end
|
||||
else
|
||||
if s[player.index] then
|
||||
s[player.index] = nil
|
||||
local s = Public.get('validate_spider')
|
||||
if entity.name == 'spidertron' then
|
||||
if player.driving then
|
||||
if not s[player.index] then
|
||||
s[player.index] = entity
|
||||
end
|
||||
else
|
||||
if s[player.index] then
|
||||
s[player.index] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
local spidertron_unlocked =
|
||||
Task.register(
|
||||
function(event)
|
||||
if event then
|
||||
local message = ({'breached_wall.spidertron_unlocked'})
|
||||
if event.bw then
|
||||
message = ({'breached_wall.spidertron_unlocked_bw'})
|
||||
function (event)
|
||||
if event then
|
||||
local message = ({ 'breached_wall.spidertron_unlocked' })
|
||||
if event.bw then
|
||||
message = ({ 'breached_wall.spidertron_unlocked_bw' })
|
||||
end
|
||||
Alert.alert_all_players(30, message, nil, 'achievement/tech-maniac', 0.1)
|
||||
end
|
||||
Alert.alert_all_players(30, message, nil, 'achievement/tech-maniac', 0.1)
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
local first_player_to_zone =
|
||||
Task.register(
|
||||
function(data)
|
||||
local player = data.player
|
||||
if not player or not player.valid then
|
||||
return
|
||||
function (data)
|
||||
local player = data.player
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
local breached_wall = data.breached_wall
|
||||
local message = ({ 'breached_wall.first_to_reach', player.name, breached_wall })
|
||||
Alert.alert_all_players(10, message)
|
||||
Public.shuffle_prices()
|
||||
end
|
||||
local breached_wall = data.breached_wall
|
||||
local message = ({'breached_wall.first_to_reach', player.name, breached_wall})
|
||||
Alert.alert_all_players(10, message)
|
||||
Public.shuffle_prices()
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
local artillery_warning =
|
||||
Task.register(
|
||||
function()
|
||||
local message = ({'breached_wall.artillery_warning'})
|
||||
Alert.alert_all_players(10, message)
|
||||
end
|
||||
)
|
||||
function ()
|
||||
local message = ({ 'breached_wall.artillery_warning' })
|
||||
Alert.alert_all_players(10, message)
|
||||
end
|
||||
)
|
||||
|
||||
local breach_wall_warning_teleport = function(player, check_trusted)
|
||||
local breach_wall_warning_teleport = function (player, check_trusted)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
@ -130,10 +130,10 @@ local breach_wall_warning_teleport = function(player, check_trusted)
|
||||
end
|
||||
|
||||
if not check_trusted then
|
||||
local message = ({'breached_wall.warning_teleport', player.name})
|
||||
local message = ({ 'breached_wall.warning_teleport', player.name })
|
||||
Alert.alert_all_players(40, message)
|
||||
else
|
||||
local message = ({'breached_wall.warning_not_trusted_teleport', player.name})
|
||||
local message = ({ 'breached_wall.warning_not_trusted_teleport', player.name })
|
||||
Alert.alert_all_players(40, message)
|
||||
end
|
||||
local pos = player.surface.find_non_colliding_position('character', player.force.get_spawn_position(player.surface), 3, 0)
|
||||
@ -148,14 +148,14 @@ end
|
||||
|
||||
local spidertron_too_far =
|
||||
Task.register(
|
||||
function(data)
|
||||
local player = data.player
|
||||
local message = ({'breached_wall.cheating_through', player.name})
|
||||
Alert.alert_all_players(30, message)
|
||||
end
|
||||
)
|
||||
function (data)
|
||||
local player = data.player
|
||||
local message = ({ 'breached_wall.cheating_through', player.name })
|
||||
Alert.alert_all_players(30, message)
|
||||
end
|
||||
)
|
||||
|
||||
local check_distance_between_player_and_locomotive = function(player)
|
||||
local check_distance_between_player_and_locomotive = function (player)
|
||||
local surface = player.surface
|
||||
local position = player.position
|
||||
local locomotive = Public.get('locomotive')
|
||||
@ -182,44 +182,44 @@ local check_distance_between_player_and_locomotive = function(player)
|
||||
|
||||
if locomotive_distance_too_far then
|
||||
if adjusted_zones.reversed then
|
||||
player.teleport({position.x, t_y + gap_between_locomotive.neg_gap - 4}, surface)
|
||||
player.teleport({ position.x, t_y + gap_between_locomotive.neg_gap - 4 }, surface)
|
||||
else
|
||||
player.teleport({position.x, (t_y + gap_between_locomotive.neg_gap - 4) * -1}, surface)
|
||||
player.teleport({ position.x, (t_y + gap_between_locomotive.neg_gap - 4) * -1 }, surface)
|
||||
end
|
||||
|
||||
player.print(({'breached_wall.hinder'}), Color.warning)
|
||||
player.print(({ 'breached_wall.hinder' }), Color.warning)
|
||||
if player.driving then
|
||||
player.driving = false
|
||||
end
|
||||
if player.character then
|
||||
player.character.health = player.character.health - 5
|
||||
player.character.surface.create_entity({name = 'water-splash', position = position})
|
||||
player.character.surface.create_entity({ name = 'water-splash', position = position })
|
||||
if player.character.health <= 0 then
|
||||
player.character.die('enemy')
|
||||
end
|
||||
end
|
||||
-- elseif collapse_distance_too_far then
|
||||
-- if adjusted_zones.reversed then
|
||||
-- player.teleport({position.x, t_y + gap_between_locomotive.neg_gap_collapse - 4}, surface)
|
||||
-- else
|
||||
-- player.teleport({position.x, (t_y + gap_between_locomotive.neg_gap_collapse - 4) * -1}, surface)
|
||||
-- end
|
||||
-- elseif collapse_distance_too_far then
|
||||
-- if adjusted_zones.reversed then
|
||||
-- player.teleport({position.x, t_y + gap_between_locomotive.neg_gap_collapse - 4}, surface)
|
||||
-- else
|
||||
-- player.teleport({position.x, (t_y + gap_between_locomotive.neg_gap_collapse - 4) * -1}, surface)
|
||||
-- end
|
||||
|
||||
-- player.print(({'breached_wall.hinder_collapse'}), Color.warning)
|
||||
-- if player.driving then
|
||||
-- player.driving = false
|
||||
-- end
|
||||
-- if player.character then
|
||||
-- player.character.health = player.character.health - 5
|
||||
-- player.character.surface.create_entity({name = 'water-splash', position = position})
|
||||
-- if player.character.health <= 0 then
|
||||
-- player.character.die('enemy')
|
||||
-- end
|
||||
-- end
|
||||
-- player.print(({'breached_wall.hinder_collapse'}), Color.warning)
|
||||
-- if player.driving then
|
||||
-- player.driving = false
|
||||
-- end
|
||||
-- if player.character then
|
||||
-- player.character.health = player.character.health - 5
|
||||
-- player.character.surface.create_entity({name = 'water-splash', position = position})
|
||||
-- if player.character.health <= 0 then
|
||||
-- player.character.die('enemy')
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
end
|
||||
|
||||
local compare_player_pos = function(player)
|
||||
local compare_player_pos = function (player)
|
||||
local p = player.position
|
||||
local index = player.index
|
||||
local adjusted_zones = Public.get('adjusted_zones')
|
||||
@ -251,7 +251,7 @@ local compare_player_pos = function(player)
|
||||
end
|
||||
end
|
||||
|
||||
local compare_player_and_train = function(player, entity)
|
||||
local compare_player_and_train = function (player, entity)
|
||||
if not player.driving then
|
||||
return
|
||||
end
|
||||
@ -277,17 +277,33 @@ local compare_player_and_train = function(player, entity)
|
||||
|
||||
local spidertron_warning_position = gap_between_zones.neg_gap + 50
|
||||
local locomotive_distance_too_far = c_y - t_y > spidertron_warning_position
|
||||
local spidertron_warning_position_pre_warning = spidertron_warning_position - 100
|
||||
local locomotive_distance_too_far_pre_warning = c_y - t_y > spidertron_warning_position_pre_warning
|
||||
local surface = player.surface
|
||||
|
||||
if locomotive_distance_too_far then
|
||||
local surface = player.surface
|
||||
local color = Color.yellow
|
||||
if locomotive_distance_too_far_pre_warning and not locomotive_distance_too_far then
|
||||
local msg = 'Warning! You are getting too far away from the train!'
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = position,
|
||||
text = 'Warning! You are too far away from the main locomotive!',
|
||||
color = {r = 0.9, g = 0.0, b = 0.0}
|
||||
text = msg,
|
||||
color = color
|
||||
}
|
||||
)
|
||||
player.print(msg, color)
|
||||
elseif locomotive_distance_too_far then
|
||||
local msg = 'Warning! You are too far away from the train! TURN BACK!'
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = position,
|
||||
text = msg,
|
||||
color = color
|
||||
}
|
||||
)
|
||||
player.print(msg, color)
|
||||
if entity.health then
|
||||
if car and car.health_pool and car.health_pool.health then
|
||||
car.health_pool.health = car.health_pool.health - 500
|
||||
@ -296,7 +312,7 @@ local compare_player_and_train = function(player, entity)
|
||||
entity.health = entity.health - 500
|
||||
if entity.health <= 0 then
|
||||
entity.die('enemy')
|
||||
Task.set_timeout_in_ticks(30, spidertron_too_far, {player = player})
|
||||
Task.set_timeout_in_ticks(30, spidertron_too_far, { player = player })
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -388,7 +404,7 @@ local function distance(player)
|
||||
upgrade = false,
|
||||
static = true
|
||||
}
|
||||
Task.set_timeout_in_ticks(150, spidertron_unlocked, {bw = bw})
|
||||
Task.set_timeout_in_ticks(150, spidertron_unlocked, { bw = bw })
|
||||
end
|
||||
end
|
||||
|
||||
@ -478,7 +494,7 @@ local function on_player_driving_changed_state(event)
|
||||
return
|
||||
end
|
||||
|
||||
Task.set_timeout_in_ticks(15, driving_state_changed_token, {player_index = player.index, entity = entity})
|
||||
Task.set_timeout_in_ticks(15, driving_state_changed_token, { player_index = player.index, entity = entity })
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
|
@ -154,7 +154,7 @@ local pause_waves_custom_callback_token =
|
||||
local wave_number = WD.get_wave()
|
||||
if wave_number >= 200 then
|
||||
Collapse.start_now(event.start, not event.start)
|
||||
local status_str = event.start and 'has stopped!' or 'is active once again!'
|
||||
local status_str = event.start and 'is active once again!' or 'has stopped!'
|
||||
Alert.alert_all_players(30, 'Collapse ' .. status_str, nil, 'achievement/tech-maniac', 0.6)
|
||||
end
|
||||
end
|
||||
|
@ -490,7 +490,7 @@ local compare_collapse_and_train = function ()
|
||||
if reverse_result > 200 then
|
||||
Collapse.reverse_start_now(true, false)
|
||||
Collapse.set_speed(1)
|
||||
Collapse.set_amount(10)
|
||||
Collapse.set_amount(40)
|
||||
else
|
||||
if Collapse.has_reverse_collapse_started() then
|
||||
Collapse.reverse_start_now(false, true)
|
||||
@ -502,7 +502,7 @@ local compare_collapse_and_train = function ()
|
||||
if result > 200 then
|
||||
Collapse.start_now(true, false)
|
||||
Collapse.set_speed(1)
|
||||
Collapse.set_amount(10)
|
||||
Collapse.set_amount(40)
|
||||
else
|
||||
if Collapse.has_collapse_started() then
|
||||
Collapse.start_now(false, true)
|
||||
|
@ -240,7 +240,7 @@ local function init_price_check(locomotive, mystical_chest)
|
||||
|
||||
local price = {}
|
||||
for k, v in pairs(item_stacks) do
|
||||
insert(price, {name = k, count = v})
|
||||
insert(price, { name = k, count = v })
|
||||
end
|
||||
|
||||
mystical_chest.price = price
|
||||
@ -265,55 +265,55 @@ end
|
||||
|
||||
local restore_mining_speed_token =
|
||||
Task.register(
|
||||
function()
|
||||
local mc_rewards = Public.get('mc_rewards')
|
||||
local force = game.forces.player
|
||||
if mc_rewards.temp_boosts.mining then
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier - 0.5
|
||||
mc_rewards.temp_boosts.mining = nil
|
||||
local message = ({'locomotive.mining_bonus_end'})
|
||||
Alert.alert_all_players(10, message, nil, 'achievement/tech-maniac')
|
||||
function ()
|
||||
local mc_rewards = Public.get('mc_rewards')
|
||||
local force = game.forces.player
|
||||
if mc_rewards.temp_boosts.mining then
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier - 0.5
|
||||
mc_rewards.temp_boosts.mining = nil
|
||||
local message = ({ 'locomotive.mining_bonus_end' })
|
||||
Alert.alert_all_players(10, message, nil, 'achievement/tech-maniac')
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
local restore_crafting_speed_token =
|
||||
Task.register(
|
||||
function()
|
||||
local mc_rewards = Public.get('mc_rewards')
|
||||
local force = game.forces.player
|
||||
if mc_rewards.temp_boosts.crafting then
|
||||
force.manual_crafting_speed_modifier = force.manual_crafting_speed_modifier - 1
|
||||
mc_rewards.temp_boosts.crafting = nil
|
||||
local message = ({'locomotive.crafting_bonus_end'})
|
||||
Alert.alert_all_players(10, message, nil, 'achievement/tech-maniac')
|
||||
function ()
|
||||
local mc_rewards = Public.get('mc_rewards')
|
||||
local force = game.forces.player
|
||||
if mc_rewards.temp_boosts.crafting then
|
||||
force.manual_crafting_speed_modifier = force.manual_crafting_speed_modifier - 1
|
||||
mc_rewards.temp_boosts.crafting = nil
|
||||
local message = ({ 'locomotive.crafting_bonus_end' })
|
||||
Alert.alert_all_players(10, message, nil, 'achievement/tech-maniac')
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
local restore_movement_speed_token =
|
||||
Task.register(
|
||||
function()
|
||||
local mc_rewards = Public.get('mc_rewards')
|
||||
local force = game.forces.player
|
||||
if mc_rewards.temp_boosts.movement then
|
||||
force.character_running_speed_modifier = force.character_running_speed_modifier - 0.2
|
||||
mc_rewards.temp_boosts.movement = nil
|
||||
local message = ({'locomotive.movement_bonus_end'})
|
||||
Alert.alert_all_players(10, message, nil, 'achievement/tech-maniac')
|
||||
function (event)
|
||||
local mc_rewards = Public.get('mc_rewards')
|
||||
local force = game.forces.player
|
||||
if mc_rewards.temp_boosts.movement then
|
||||
force.character_running_speed_modifier = event.speed
|
||||
mc_rewards.temp_boosts.movement = nil
|
||||
local message = ({ 'locomotive.movement_bonus_end' })
|
||||
Alert.alert_all_players(10, message, nil, 'achievement/tech-maniac')
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
local mc_random_rewards = {
|
||||
{
|
||||
name = 'XP',
|
||||
color = {r = 0.00, g = 0.45, b = 0.00},
|
||||
color = { r = 0.00, g = 0.45, b = 0.00 },
|
||||
tooltip = 'Selecting this will insert random XP onto the global xp pool!',
|
||||
func = (function(player)
|
||||
func = (function (player)
|
||||
local rng = random(2048, 10240)
|
||||
RPG.add_to_global_pool(rng)
|
||||
local message = ({'locomotive.xp_bonus', player.name})
|
||||
local message = ({ 'locomotive.xp_bonus', player.name })
|
||||
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac')
|
||||
return true
|
||||
end),
|
||||
@ -321,21 +321,21 @@ local mc_random_rewards = {
|
||||
},
|
||||
{
|
||||
name = 'Coins',
|
||||
color = {r = 0.00, g = 0.35, b = 0.00},
|
||||
color = { r = 0.00, g = 0.35, b = 0.00 },
|
||||
tooltip = 'Selecting this will grant each player some coins!',
|
||||
func = (function(p)
|
||||
func = (function (p)
|
||||
local rng = random(512, 2048)
|
||||
local players = game.connected_players
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
if player and player.valid then
|
||||
if player.can_insert({name = 'coin', count = rng}) then
|
||||
player.insert({name = 'coin', count = rng})
|
||||
if player.can_insert({ name = 'coin', count = rng }) then
|
||||
player.insert({ name = 'coin', count = rng })
|
||||
StatData.get_data(player):increase('coins', rng)
|
||||
end
|
||||
end
|
||||
end
|
||||
local message = ({'locomotive.coin_bonus', p.name})
|
||||
local message = ({ 'locomotive.coin_bonus', p.name })
|
||||
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac')
|
||||
return true
|
||||
end),
|
||||
@ -344,9 +344,9 @@ local mc_random_rewards = {
|
||||
{
|
||||
name = 'Movement bonus',
|
||||
str = 'movement',
|
||||
color = {r = 0.00, g = 0.25, b = 0.00},
|
||||
color = { r = 0.00, g = 0.25, b = 0.00 },
|
||||
tooltip = 'Selecting this will grant the team a bonus movement speed for 15 minutes!',
|
||||
func = (function(player)
|
||||
func = (function (player)
|
||||
local mc_rewards = Public.get('mc_rewards')
|
||||
local force = game.forces.player
|
||||
if mc_rewards.temp_boosts.movement then
|
||||
@ -355,9 +355,9 @@ local mc_random_rewards = {
|
||||
|
||||
mc_rewards.temp_boosts.movement = true
|
||||
|
||||
Task.set_timeout_in_ticks(54000, restore_movement_speed_token)
|
||||
Task.set_timeout_in_ticks(54000, restore_movement_speed_token, { speed = force.character_running_speed_modifier })
|
||||
force.character_running_speed_modifier = force.character_running_speed_modifier + 0.6
|
||||
local message = ({'locomotive.movement_bonus', player.name})
|
||||
local message = ({ 'locomotive.movement_bonus', player.name })
|
||||
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac')
|
||||
return true
|
||||
end),
|
||||
@ -366,9 +366,9 @@ local mc_random_rewards = {
|
||||
{
|
||||
name = 'Mining bonus',
|
||||
str = 'mining',
|
||||
color = {r = 0.00, g = 0.00, b = 0.25},
|
||||
color = { r = 0.00, g = 0.00, b = 0.25 },
|
||||
tooltip = 'Selecting this will grant the team a bonus mining speed for 15 minutes!',
|
||||
func = (function(player)
|
||||
func = (function (player)
|
||||
local mc_rewards = Public.get('mc_rewards')
|
||||
local force = game.forces.player
|
||||
if mc_rewards.temp_boosts.mining then
|
||||
@ -379,7 +379,7 @@ local mc_random_rewards = {
|
||||
|
||||
Task.set_timeout_in_ticks(54000, restore_mining_speed_token)
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 1
|
||||
local message = ({'locomotive.mining_bonus', player.name})
|
||||
local message = ({ 'locomotive.mining_bonus', player.name })
|
||||
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac')
|
||||
return true
|
||||
end),
|
||||
@ -387,9 +387,9 @@ local mc_random_rewards = {
|
||||
},
|
||||
{
|
||||
name = 'Crafting speed bonus',
|
||||
color = {r = 0.00, g = 0.00, b = 0.25},
|
||||
color = { r = 0.00, g = 0.00, b = 0.25 },
|
||||
tooltip = 'Selecting this will grant all players 100% crafting bonus for 15 minutes!',
|
||||
func = (function(player)
|
||||
func = (function (player)
|
||||
local mc_rewards = Public.get('mc_rewards')
|
||||
local force = game.forces.player
|
||||
if mc_rewards.temp_boosts.crafting then
|
||||
@ -400,7 +400,7 @@ local mc_random_rewards = {
|
||||
|
||||
Task.set_timeout_in_ticks(54000, restore_crafting_speed_token)
|
||||
force.manual_crafting_speed_modifier = force.manual_crafting_speed_modifier + 2
|
||||
local message = ({'locomotive.crafting_bonus', player.name})
|
||||
local message = ({ 'locomotive.crafting_bonus', player.name })
|
||||
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac')
|
||||
return true
|
||||
end),
|
||||
@ -414,9 +414,9 @@ local function mystical_chest_reward(player)
|
||||
return
|
||||
end
|
||||
|
||||
local frame = player.gui.screen.add {type = 'frame', caption = 'Mystical Reward:', name = 'reward_system', direction = 'vertical'}
|
||||
local frame = player.gui.screen.add { type = 'frame', caption = 'Mystical Reward:', name = 'reward_system', direction = 'vertical' }
|
||||
frame.auto_center = true
|
||||
frame = frame.add {type = 'frame', name = 'reward_system_1', direction = 'vertical', style = 'inside_shallow_frame'}
|
||||
frame = frame.add { type = 'frame', name = 'reward_system_1', direction = 'vertical', style = 'inside_shallow_frame' }
|
||||
frame.style.padding = 4
|
||||
|
||||
local mc_rewards = Public.get('mc_rewards')
|
||||
@ -429,7 +429,7 @@ local function mystical_chest_reward(player)
|
||||
id = i,
|
||||
name = d.name
|
||||
}
|
||||
local b = frame.add({type = 'button', name = tostring(i), caption = d.name})
|
||||
local b = frame.add({ type = 'button', name = tostring(i), caption = d.name })
|
||||
b.style.font_color = d.color
|
||||
b.style.font = 'heading-2'
|
||||
b.style.minimal_width = 180
|
||||
@ -555,7 +555,7 @@ function Public.roll_item_stack(remaining_budget, blacklist)
|
||||
end
|
||||
end
|
||||
|
||||
return {name = item_name, count = item_count}
|
||||
return { name = item_name, count = item_count }
|
||||
end
|
||||
|
||||
function Public.roll(budget, max_slots, blacklist)
|
||||
|
@ -197,7 +197,7 @@ Event.add(
|
||||
return
|
||||
end
|
||||
|
||||
launch_item.actual = launch_item.actual + slot.count
|
||||
launch_item.actual = launch_item.actual + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -43,7 +43,7 @@ Global.register(
|
||||
end
|
||||
)
|
||||
|
||||
local damage_types = { 'physical', 'electric', 'poison', 'laser' }
|
||||
local damage_types = { 'physical', 'explosion', 'laser' }
|
||||
|
||||
local buff_to_string = {
|
||||
['starting_items'] = 'Starting items',
|
||||
@ -87,9 +87,17 @@ local function notify_season_over_to_discord()
|
||||
for name, buff_data in pairs(stateful.buffs_collected) do
|
||||
if type(buff_data.amount) ~= 'table' and name ~= 'starting_items' then
|
||||
if name == 'xp_level' or name == 'xp_bonus' or name == 'character_health_bonus' then
|
||||
buffs = buffs .. buff_to_string[name] .. ': ' .. buff_data.count
|
||||
if buff_data.count and buff_to_string[name] then
|
||||
buffs = buffs .. buff_to_string[name] .. ': ' .. buff_data.count
|
||||
else
|
||||
buffs = buffs .. name .. ': Active'
|
||||
end
|
||||
else
|
||||
buffs = buffs .. buff_to_string[name] .. ': ' .. (buff_data.count * 100) .. '%'
|
||||
if buff_data.count and buff_to_string[name] then
|
||||
buffs = buffs .. buff_to_string[name] .. ': ' .. (buff_data.count * 100) .. '%'
|
||||
else
|
||||
buffs = buffs .. name .. ': Active'
|
||||
end
|
||||
end
|
||||
buffs = buffs .. '\n'
|
||||
end
|
||||
@ -874,24 +882,24 @@ end
|
||||
|
||||
local function get_random_spell()
|
||||
local items = {
|
||||
{ 'small-biter', scale(1000, 10000) },
|
||||
{ 'small-spitter', scale(1000, 60000) },
|
||||
{ 'medium-biter', scale(1000, 200000) },
|
||||
{ 'medium-spitter', scale(1000, 100000) },
|
||||
{ 'shotgun-shell', scale(1000, 100000) },
|
||||
{ 'grenade', scale(1000, 80000) },
|
||||
{ 'cluster-grenade', scale(1000, 50000) },
|
||||
{ 'cannon-shell', scale(1000, 100000) },
|
||||
{ 'explosive-cannon-shell', scale(1000, 50000) },
|
||||
{ 'uranium-cannon-shell', scale(1000, 100000) },
|
||||
{ 'rocket', scale(1000, 100000) },
|
||||
{ 'acid-stream-spitter-big', scale(1000, 200000) },
|
||||
{ 'explosives', scale(5000, 100000) },
|
||||
{ 'distractor-capsule', scale(5000, 100000) },
|
||||
{ 'defender-capsule', scale(5000, 100000) },
|
||||
{ 'destroyer-capsule', scale(5000, 100000) },
|
||||
{ 'warp-gate', scale(5000, 500000) },
|
||||
{ 'haste', scale(5000, 500000) }
|
||||
{ 'small-biter', scale(100, 2500) },
|
||||
{ 'small-spitter', scale(100, 2500) },
|
||||
{ 'medium-biter', scale(100, 2500) },
|
||||
{ 'medium-spitter', scale(100, 2500) },
|
||||
{ 'shotgun-shell', scale(100, 2500) },
|
||||
{ 'grenade', scale(100, 2500) },
|
||||
{ 'cluster-grenade', scale(100, 2500) },
|
||||
{ 'cannon-shell', scale(100, 2500) },
|
||||
{ 'explosive-cannon-shell', scale(100, 2500) },
|
||||
{ 'uranium-cannon-shell', scale(100, 2500) },
|
||||
{ 'rocket', scale(100, 2500) },
|
||||
{ 'acid-stream-spitter-big', scale(100, 2500) },
|
||||
{ 'explosives', scale(100, 2500) },
|
||||
{ 'distractor-capsule', scale(100, 2500) },
|
||||
{ 'defender-capsule', scale(100, 2500) },
|
||||
{ 'destroyer-capsule', scale(100, 2500) },
|
||||
{ 'warp-gate', scale(100, 2500) },
|
||||
{ 'haste', scale(100, 2500) }
|
||||
}
|
||||
|
||||
shuffle(items)
|
||||
@ -918,7 +926,7 @@ local function get_random_research_recipe()
|
||||
return { name = research_level_list[1], count = 1, research_count = 0 }
|
||||
end
|
||||
|
||||
return { name = research_level_list[1], count = scale(2, 11, 1.03), research_count = 0 }
|
||||
return { name = research_level_list[1], count = scale(2, 9, 1.03), research_count = 0 }
|
||||
end
|
||||
|
||||
local function get_random_objectives()
|
||||
@ -1551,7 +1559,7 @@ function Public.reset_stateful(refresh_gui, clear_buffs)
|
||||
if not this.objectives.cast_spell_any or (this.objectives_completed ~= nil and this.objectives_completed.cast_spell_any) then
|
||||
this.objectives.cast_spell_any = {
|
||||
actual = 0,
|
||||
expected = scale(1000, 4000000),
|
||||
expected = scale(100, 1000),
|
||||
name = 'Any'
|
||||
}
|
||||
end
|
||||
@ -1559,7 +1567,7 @@ function Public.reset_stateful(refresh_gui, clear_buffs)
|
||||
local item = get_random_handcrafted_item()
|
||||
this.objectives.launch_item = {
|
||||
actual = 0,
|
||||
expected = scale(10, 700),
|
||||
expected = scale(1, 50),
|
||||
name = item.name
|
||||
}
|
||||
end
|
||||
|
@ -1531,58 +1531,61 @@ local function event_on_player_joined_game(event)
|
||||
Common.ensure_chunks_at(surface, spawnpoint, 5)
|
||||
end
|
||||
|
||||
Common.notify_player_expected(player, {'pirates.player_join_game_info'})
|
||||
Common.notify_player_expected(player, { 'pirates.player_join_game_info' })
|
||||
|
||||
player.force = Common.lobby_force_name
|
||||
|
||||
|
||||
-- It was suggested to always spawn players in lobby, in hopes that they may want to create their crew increasing the popularity of scenario.
|
||||
|
||||
-- Auto-join the oldest crew:
|
||||
local ages = {}
|
||||
for _, memory in pairs(global_memory.crew_memories) do
|
||||
if Common.is_id_valid(memory.id)
|
||||
and (not memory.run_is_private)
|
||||
and memory.crewstatus == Crew.enum.ADVENTURING
|
||||
and memory.capacity
|
||||
and memory.crewplayerindices
|
||||
and #memory.crewplayerindices < memory.capacity
|
||||
and (not (memory.tempbanned_from_joining_data
|
||||
and memory.tempbanned_from_joining_data[player.index]
|
||||
and game.tick < memory.tempbanned_from_joining_data[player.index] + Common.ban_from_rejoining_crew_ticks)) then
|
||||
ages[#ages+1] = {id = memory.id, age = memory.age, large = (memory.capacity >= Common.minimum_run_capacity_to_enforce_space_for)}
|
||||
end
|
||||
end
|
||||
table.sort(
|
||||
ages,
|
||||
function(a, b) --true if a should be to the left of b
|
||||
if a.large and (not b.large) then
|
||||
return true
|
||||
elseif (not a.large) and b.large then
|
||||
return false
|
||||
else
|
||||
return a.age > b.age
|
||||
end
|
||||
end
|
||||
)
|
||||
if ages[1] then
|
||||
Crew.join_crew(player)
|
||||
-- local ages = {}
|
||||
-- for _, memory in pairs(global_memory.crew_memories) do
|
||||
-- if Common.is_id_valid(memory.id)
|
||||
-- and (not memory.run_is_private)
|
||||
-- and memory.crewstatus == Crew.enum.ADVENTURING
|
||||
-- and memory.capacity
|
||||
-- and memory.crewplayerindices
|
||||
-- and #memory.crewplayerindices < memory.capacity
|
||||
-- and (not (memory.tempbanned_from_joining_data
|
||||
-- and memory.tempbanned_from_joining_data[player.index]
|
||||
-- and game.tick < memory.tempbanned_from_joining_data[player.index] + Common.ban_from_rejoining_crew_ticks)) then
|
||||
-- ages[#ages+1] = {id = memory.id, age = memory.age, large = (memory.capacity >= Common.minimum_run_capacity_to_enforce_space_for)}
|
||||
-- end
|
||||
-- end
|
||||
-- table.sort(
|
||||
-- ages,
|
||||
-- function(a, b) --true if a should be to the left of b
|
||||
-- if a.large and (not b.large) then
|
||||
-- return true
|
||||
-- elseif (not a.large) and b.large then
|
||||
-- return false
|
||||
-- else
|
||||
-- return a.age > b.age
|
||||
-- end
|
||||
-- end
|
||||
-- )
|
||||
-- if ages[1] then
|
||||
-- Crew.join_crew(player)
|
||||
|
||||
local memory = global_memory.crew_memories[ages[1].id]
|
||||
if (not memory.run_is_protected) and #memory.crewplayerindices <= 1 then
|
||||
Roles.make_captain(player)
|
||||
end
|
||||
-- local memory = global_memory.crew_memories[ages[1].id]
|
||||
-- if (not memory.run_is_protected) and #memory.crewplayerindices <= 1 then
|
||||
-- Roles.make_captain(player)
|
||||
-- end
|
||||
|
||||
if ages[2] then
|
||||
if ages[1].large and (not ages[#ages].large) then
|
||||
Common.notify_player_announce(player, {'pirates.goto_oldest_crew_with_large_capacity'})
|
||||
else
|
||||
Common.notify_player_announce(player, {'pirates.goto_oldest_crew'})
|
||||
end
|
||||
end
|
||||
-- if ages[2] then
|
||||
-- if ages[1].large and (not ages[#ages].large) then
|
||||
-- Common.notify_player_announce(player, {'pirates.goto_oldest_crew_with_large_capacity'})
|
||||
-- else
|
||||
-- Common.notify_player_announce(player, {'pirates.goto_oldest_crew'})
|
||||
-- end
|
||||
-- end
|
||||
|
||||
if memory.run_is_protected and (not Roles.captain_exists()) then
|
||||
Common.notify_player_expected(player, {'pirates.player_joins_protected_run_with_no_captain'})
|
||||
Common.notify_player_expected(player, {'pirates.create_new_crew_tip'})
|
||||
end
|
||||
end
|
||||
-- if memory.run_is_protected and (not Roles.captain_exists()) then
|
||||
-- Common.notify_player_expected(player, {'pirates.player_joins_protected_run_with_no_captain'})
|
||||
-- Common.notify_player_expected(player, {'pirates.create_new_crew_tip'})
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
if not _DEBUG then
|
||||
|
@ -80,7 +80,13 @@ function Public:new_target()
|
||||
local chunk = surface.get_random_chunk()
|
||||
local random_position = { x = (chunk.x + random()) * 32, y = (chunk.y + random()) * 32 }
|
||||
if not position then
|
||||
return random_position, random_position
|
||||
entities = surface.find_entities_filtered { type = 'character', force = 'player' }
|
||||
if entities and #entities > 0 then
|
||||
position = entities[random(#entities)].position
|
||||
end
|
||||
if not position then
|
||||
return random_position, random_position
|
||||
end
|
||||
end
|
||||
|
||||
return position, random_position
|
||||
|
@ -1393,6 +1393,36 @@ Event.add(
|
||||
end
|
||||
)
|
||||
|
||||
---@param event EventData.on_console_chat
|
||||
Event.add(defines.events.on_console_chat, function (event)
|
||||
if not event.player_index then
|
||||
return
|
||||
end
|
||||
local player = game.get_player(event.player_index)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local secs = Server.get_current_time()
|
||||
if not secs then
|
||||
return
|
||||
end
|
||||
local p_data = get_player_data(player)
|
||||
if jailed[player.name] and p_data and p_data.locked then
|
||||
p_data.ping = p_data.ping or 0
|
||||
if string.match(event.message, "gps") ~= nil then
|
||||
p_data.ping = p_data.ping + 1
|
||||
if p_data.ping == 3 then
|
||||
local gulag = get_super_gulag_permission_group()
|
||||
gulag.add_player(player)
|
||||
Utils.print_to(nil, module_name .. player.name .. ' tried to spammy spammy from the gulag but the warden denied their request.')
|
||||
p_data.ping = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Gui.on_text_changed(
|
||||
placeholder_jail_text_box,
|
||||
function (event)
|
||||
|
@ -38,7 +38,7 @@ local this = {
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(t)
|
||||
function (t)
|
||||
this = t
|
||||
end
|
||||
)
|
||||
@ -55,51 +55,51 @@ local function get_header(tbl, name)
|
||||
end
|
||||
|
||||
local header_modifier = {
|
||||
['username_asc'] = function(tbl)
|
||||
['username_asc'] = function (tbl)
|
||||
local setting = get_header(tbl, 'username')
|
||||
setting.name = setting.name .. '[color=yellow]' .. symbol_asc .. '[/color]'
|
||||
end,
|
||||
['username_desc'] = function(tbl)
|
||||
['username_desc'] = function (tbl)
|
||||
local setting = get_header(tbl, 'username')
|
||||
setting.name = setting.name .. '[color=yellow]' .. symbol_desc .. '[/color]'
|
||||
end,
|
||||
['rpg_asc'] = function(tbl)
|
||||
['rpg_asc'] = function (tbl)
|
||||
local setting = get_header(tbl, 'rpg')
|
||||
setting.name = setting.name .. '[color=yellow]' .. symbol_asc .. '[/color]'
|
||||
end,
|
||||
['rpg_desc'] = function(tbl)
|
||||
['rpg_desc'] = function (tbl)
|
||||
local setting = get_header(tbl, 'rpg')
|
||||
setting.name = setting.name .. '[color=yellow]' .. symbol_desc .. '[/color]'
|
||||
end,
|
||||
['coins_asc'] = function(tbl)
|
||||
['coins_asc'] = function (tbl)
|
||||
local setting = get_header(tbl, 'coins')
|
||||
setting.name = setting.name .. '[color=yellow]' .. symbol_asc .. '[/color]'
|
||||
end,
|
||||
['coins_desc'] = function(tbl)
|
||||
['coins_desc'] = function (tbl)
|
||||
local setting = get_header(tbl, 'coins')
|
||||
setting.name = setting.name .. '[color=yellow]' .. symbol_desc .. '[/color]'
|
||||
end,
|
||||
['total_time_asc'] = function(tbl)
|
||||
['total_time_asc'] = function (tbl)
|
||||
local setting = get_header(tbl, 'total_time')
|
||||
setting.name = setting.name .. '[color=yellow]' .. symbol_asc .. '[/color]'
|
||||
end,
|
||||
['total_time_desc'] = function(tbl)
|
||||
['total_time_desc'] = function (tbl)
|
||||
local setting = get_header(tbl, 'total_time')
|
||||
setting.name = setting.name .. '[color=yellow]' .. symbol_desc .. '[/color]'
|
||||
end,
|
||||
['current_time_asc'] = function(tbl)
|
||||
['current_time_asc'] = function (tbl)
|
||||
local setting = get_header(tbl, 'current_time')
|
||||
setting.name = setting.name .. '[color=yellow]' .. symbol_asc .. '[/color]'
|
||||
end,
|
||||
['current_time_desc'] = function(tbl)
|
||||
['current_time_desc'] = function (tbl)
|
||||
local setting = get_header(tbl, 'current_time')
|
||||
setting.name = setting.name .. '[color=yellow]' .. symbol_desc .. '[/color]'
|
||||
end,
|
||||
['poke_asc'] = function(tbl)
|
||||
['poke_asc'] = function (tbl)
|
||||
local setting = get_header(tbl, 'poke')
|
||||
setting.name = setting.name .. '[color=yellow]' .. symbol_asc .. '[/color]'
|
||||
end,
|
||||
['poke_desc'] = function(tbl)
|
||||
['poke_desc'] = function (tbl)
|
||||
local setting = get_header(tbl, 'poke')
|
||||
setting.name = setting.name .. '[color=yellow]' .. symbol_desc .. '[/color]'
|
||||
end
|
||||
@ -132,7 +132,7 @@ local function get_sorted_list(sort_by)
|
||||
local session_table = Session.get_session_table()
|
||||
local player_list = {}
|
||||
Core.iter_connected_players(
|
||||
function(player, index)
|
||||
function (player, index)
|
||||
local player_data = player_list[index] or {}
|
||||
player_data.rank = get_rank(player)
|
||||
player_data.name = player.name
|
||||
@ -187,14 +187,16 @@ local function player_list_show(data)
|
||||
|
||||
local gui_data =
|
||||
Vars.gui_data(
|
||||
{
|
||||
header_label_name = header_label_name,
|
||||
show_roles_in_list = this.show_roles_in_list,
|
||||
locate_player_frame_name = locate_player_frame_name,
|
||||
rpg_enabled = this.rpg_enabled,
|
||||
poke_player_frame_name = poke_player_frame_name
|
||||
}
|
||||
)
|
||||
{
|
||||
header_label_name = header_label_name,
|
||||
show_roles_in_list = this.show_roles_in_list,
|
||||
locate_player_frame_name = locate_player_frame_name,
|
||||
rpg_enabled = this.rpg_enabled,
|
||||
poke_player_frame_name = poke_player_frame_name
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
if sort_by then
|
||||
this.player_list.sorting_method[data.player.index] = sort_by
|
||||
@ -202,16 +204,20 @@ local function player_list_show(data)
|
||||
sort_by = this.player_list.sorting_method[data.player.index]
|
||||
end
|
||||
|
||||
if this.player_list.sorting_method[data.player.index] == '_desc' or this.player_list.sorting_method[data.player.index] == '_asc' then
|
||||
this.player_list.sorting_method[data.player.index] = 'total_time_desc'
|
||||
end
|
||||
|
||||
if not sort_by then
|
||||
sort_by = 'total_time_desc'
|
||||
end
|
||||
|
||||
header_modifier[sort_by](gui_data)
|
||||
|
||||
local player_tbl = frame.add {type = 'table', column_count = #gui_data}
|
||||
local player_tbl = frame.add { type = 'table', column_count = #gui_data }
|
||||
|
||||
for _, setting in pairs(gui_data) do
|
||||
local label = player_tbl.add {type = 'label', caption = ''}
|
||||
local label = player_tbl.add { type = 'label', caption = '' }
|
||||
label.style.minimal_width = setting.header_width
|
||||
label.style.maximal_width = setting.header_width
|
||||
end
|
||||
@ -223,15 +229,15 @@ local function player_list_show(data)
|
||||
-- List management
|
||||
local player_list_panel_table =
|
||||
frame.add {
|
||||
type = 'scroll-pane',
|
||||
name = 'scroll_pane',
|
||||
direction = 'vertical',
|
||||
horizontal_scroll_policy = 'never',
|
||||
vertical_scroll_policy = 'auto'
|
||||
}
|
||||
type = 'scroll-pane',
|
||||
name = 'scroll_pane',
|
||||
direction = 'vertical',
|
||||
horizontal_scroll_policy = 'never',
|
||||
vertical_scroll_policy = 'auto'
|
||||
}
|
||||
player_list_panel_table.style.maximal_height = 400
|
||||
|
||||
player_list_panel_table = player_list_panel_table.add {type = 'table', name = 'player_list_panel_table', column_count = #gui_data}
|
||||
player_list_panel_table = player_list_panel_table.add { type = 'table', name = 'player_list_panel_table', column_count = #gui_data }
|
||||
|
||||
local player_list = get_sorted_list(sort_by)
|
||||
for i = 1, #player_list, 1 do
|
||||
@ -246,7 +252,7 @@ local player_list_show_token = Token.register(player_list_show)
|
||||
|
||||
Gui.on_click(
|
||||
locate_player_frame_name,
|
||||
function(event)
|
||||
function (event)
|
||||
local player = event.player
|
||||
local element = event.element
|
||||
|
||||
@ -284,7 +290,7 @@ Gui.on_click(
|
||||
|
||||
Gui.on_click(
|
||||
poke_player_frame_name,
|
||||
function(event)
|
||||
function (event)
|
||||
local player = event.player
|
||||
local element = event.element
|
||||
|
||||
@ -321,7 +327,7 @@ local function refresh()
|
||||
if frame.name ~= tag then
|
||||
return
|
||||
end
|
||||
local data = {player = player, frame = frame, sort_by = this.player_list.sorting_method[player.index]}
|
||||
local data = { player = player, frame = frame, sort_by = this.player_list.sorting_method[player.index] }
|
||||
player_list_show(data)
|
||||
end
|
||||
end
|
||||
@ -354,11 +360,11 @@ function Public.rpg_enabled(value)
|
||||
return this.rpg_enabled
|
||||
end
|
||||
|
||||
Gui.add_tab_to_gui({name = module_name, caption = tag, id = player_list_show_token, admin = false})
|
||||
Gui.add_tab_to_gui({ name = module_name, caption = tag, id = player_list_show_token, admin = false })
|
||||
|
||||
Gui.on_click(
|
||||
module_name,
|
||||
function(event)
|
||||
function (event)
|
||||
local player = event.player
|
||||
Gui.reload_active_tab(player)
|
||||
end
|
||||
@ -366,7 +372,7 @@ Gui.on_click(
|
||||
|
||||
Gui.on_click(
|
||||
header_label_name,
|
||||
function(event)
|
||||
function (event)
|
||||
local player = event.player
|
||||
local element = event.element
|
||||
if not element or not element.valid then
|
||||
@ -387,10 +393,10 @@ Gui.on_click(
|
||||
end
|
||||
|
||||
if string.find(element.caption, symbol_desc) then
|
||||
local data = {player = player, frame = frame, sort_by = parent.name .. '_asc'}
|
||||
local data = { player = player, frame = frame, sort_by = parent.name and parent.name:len() > 0 and parent.name .. '_asc' or nil }
|
||||
player_list_show(data)
|
||||
else
|
||||
local data = {player = player, frame = frame, sort_by = parent.name .. '_desc'}
|
||||
local data = { player = player, frame = frame, sort_by = parent.name and parent.name:len() > 0 and parent.name .. '_desc' or nil }
|
||||
player_list_show(data)
|
||||
end
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'PlayerList Gui Click')
|
||||
|
Loading…
x
Reference in New Issue
Block a user