1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-01 13:08:05 +02:00

Mtn v3 - minor fixes

This commit is contained in:
Gerkiz 2024-01-03 00:15:53 +01:00
parent cfb2bc67ad
commit d9e862e138
4 changed files with 126 additions and 7 deletions

View File

@ -4,8 +4,9 @@ local Task = require 'utils.task'
local Server = require 'utils.server'
local Collapse = require 'modules.collapse'
local WD = require 'modules.wave_defense.table'
local Discord = require 'utils.discord_handler'
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
local scenario_name = 'Mtn Fortress'
commands.add_command(
'scenario',
@ -47,6 +48,7 @@ commands.add_command(
this.restart = false
this.soft_reset = true
p('[SUCCESS] Soft-reset is enabled.')
Discord.send_notification_raw(scenario_name, player.name .. ' has enabled soft-reset!')
return
else
this.reset_are_you_sure = nil
@ -55,12 +57,14 @@ commands.add_command(
if this.shutdown then
this.shutdown = false
end
Discord.send_notification_raw(scenario_name, player.name .. ' has disabled soft-reset! Restart will happen from scenario.')
p('[WARNING] Soft-reset is disabled! Server will restart from scenario to load new changes.')
return
end
elseif param == 'restartnow' then
this.reset_are_you_sure = nil
Server.start_scenario('Mountain_Fortress_v3')
Discord.send_notification_raw(scenario_name, player.name .. ' restarted the scenario.')
return
elseif param == 'shutdown' then
if this.shutdown then
@ -68,6 +72,7 @@ commands.add_command(
this.shutdown = false
this.soft_reset = true
p('[SUCCESS] Soft-reset is enabled.')
Discord.send_notification_raw(scenario_name, player.name .. ' has enabled soft-reset. Server will NOT shutdown!')
return
else
this.reset_are_you_sure = nil
@ -77,14 +82,17 @@ commands.add_command(
this.restart = false
end
p('[WARNING] Soft-reset is disabled! Server will shutdown. Most likely because of updates.')
Discord.send_notification_raw(scenario_name, player.name .. ' has disabled soft-reset. Server will shutdown!')
return
end
elseif param == 'reset' then
this.reset_are_you_sure = nil
if player and player.valid then
game.print(mapkeeper .. ' ' .. player.name .. ', has reset the game!', {r = 0.98, g = 0.66, b = 0.22})
Discord.send_notification_raw(scenario_name, player.name .. ' has reset the game!')
else
game.print(mapkeeper .. ' server, has reset the game!', {r = 0.98, g = 0.66, b = 0.22})
Discord.send_notification_raw(scenario_name, 'Server has reset the game!')
end
Public.reset_map()
p('[WARNING] Game has been reset!')
@ -108,6 +116,7 @@ commands.add_command(
if not param then
return
end
Discord.send_notification_raw(scenario_name, player.name .. ' set the queue speed to: ' .. param)
player.print('Queue speed set to: ' .. param)
Task.set_queue_speed(param)
else
@ -117,6 +126,45 @@ commands.add_command(
end
)
commands.add_command(
'complete_quests',
'Usable only for admins - sets the queue speed of this map!',
function()
local player = game.player
if player and player.valid then
if not player.admin then
player.print("[ERROR] You're not admin!", Color.fail)
return
end
local this = Public.get()
if not this.reset_are_you_sure then
this.reset_are_you_sure = true
player.print('[WARNING] This command will break the current run and complete all quests, run this command again if you really want to do this!', Color.warning)
return
end
this.reset_are_you_sure = nil
Discord.send_notification_raw(scenario_name, player.name .. ' completed all the quest via command.')
Public.stateful.set_stateful('objectives_completed_count', 5)
game.print(mapkeeper .. player.name .. ', has forced completed all quests!', {r = 0.98, g = 0.66, b = 0.22})
else
local this = Public.get()
if not this.reset_are_you_sure then
this.reset_are_you_sure = true
log('[WARNING] This command will break the current run and complete all quests, run this command again if you really want to do this!')
return
end
this.reset_are_you_sure = nil
log('Quests completed.')
Discord.send_notification_raw(scenario_name, 'Server completed all the quest via command')
Public.stateful.set_stateful('objectives_completed_count', 5)
end
end
)
commands.add_command(
'disable_biters',
'Usable only for admins - disables wave defense!',
@ -141,9 +189,11 @@ commands.add_command(
end
if not tbl.game_lost then
Discord.send_notification_raw(scenario_name, player.name .. ' disabled the wave defense module.')
game.print(mapkeeper .. ' ' .. player.name .. ', has disabled the wave_defense module!', {r = 0.98, g = 0.66, b = 0.22})
tbl.game_lost = true
else
Discord.send_notification_raw(scenario_name, player.name .. ' enabled the wave defense module.')
game.print(mapkeeper .. ' ' .. player.name .. ', has enabled the wave_defense module!', {r = 0.98, g = 0.66, b = 0.22})
tbl.game_lost = false
end
@ -174,9 +224,11 @@ commands.add_command(
end
if this.orbital_strikes.enabled then
Discord.send_notification_raw(scenario_name, player.name .. ' disabled the orbital strike module.')
game.print(mapkeeper .. ' ' .. player.name .. ', has disabled the orbital_strikes module!', {r = 0.98, g = 0.66, b = 0.22})
this.orbital_strikes.enabled = false
else
Discord.send_notification_raw(scenario_name, player.name .. ' enabled the orbital strike module.')
game.print(mapkeeper .. ' ' .. player.name .. ', has enabled the orbital_strikes module!', {r = 0.98, g = 0.66, b = 0.22})
this.orbital_strikes.enabled = true
end
@ -206,6 +258,7 @@ commands.add_command(
return
end
Discord.send_notification_raw(scenario_name, player.name .. ' toggled the end game.')
Public.stateful.set_stateful('final_battle', true)
Public.set('final_battle', true)
@ -249,19 +302,23 @@ commands.add_command(
end
if Collapse.get_disable_state() then
Collapse.disable_collapse(false)
Discord.send_notification_raw(scenario_name, player.name .. ' has enabled collapse.')
game.print(mapkeeper .. ' ' .. player.name .. ', has enabled collapse!', {r = 0.98, g = 0.66, b = 0.22})
log(player.name .. ', has enabled collapse!')
else
Collapse.disable_collapse(true)
Discord.send_notification_raw(scenario_name, player.name .. ' has disabled collapse.')
game.print(mapkeeper .. ' ' .. player.name .. ', has disabled collapse!', {r = 0.98, g = 0.66, b = 0.22})
log(player.name .. ', has disabled collapse!')
end
else
if Collapse.get_disable_state() then
Collapse.disable_collapse(false)
Discord.send_notification_raw(scenario_name, 'Server has enabled collapse.')
log('Collapse has started.')
else
Collapse.disable_collapse(true)
Discord.send_notification_raw(scenario_name, 'Server has disabled collapse.')
log('Collapse has stopped.')
end
end

View File

@ -123,7 +123,7 @@ local function notify_won_to_discord(buff)
},
field7 = {
text1 = 'Buff granted:',
text2 = buff.name,
text2 = buff.discord,
inline = 'false'
}
}
@ -547,7 +547,7 @@ main_frame = function(player)
buffs = buffs .. 'Force buffs:\n'
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 == 'character_health_bonus' then
if name == 'xp_level' or name == 'xp_bonus' or name == 'character_health_bonus' then
buffs = buffs .. Stateful.buff_to_string[name] .. ': ' .. buff_data.count
else
buffs = buffs .. Stateful.buff_to_string[name] .. ': ' .. (buff_data.count * 100) .. '%'

View File

@ -79,7 +79,7 @@ local buff_to_string = {
['character_reach_distance_bonus'] = 'Reach',
['distance'] = 'All distance modifiers',
['manual_crafting_speed_modifier'] = 'Crafting',
['xp_bonus'] = 'XP Bonus',
['xp_bonus'] = 'XP Points',
['xp_level'] = 'XP Level'
}
@ -87,72 +87,86 @@ local function get_random_buff()
local buffs = {
{
name = 'character_running_speed_modifier',
discord = 'Running speed modifier',
modifier = 'force',
state = 0.05
},
{
name = 'manual_mining_speed_modifier',
discord = 'Mining speed modifier',
modifier = 'force',
state = 0.15
},
{
name = 'laboratory_speed_modifier',
discord = 'Laboratory speed modifier',
modifier = 'force',
state = 0.15
},
{
name = 'laboratory_productivity_bonus',
discord = 'Productivity bonus',
modifier = 'force',
state = 0.15
},
{
name = 'worker_robots_storage_bonus',
discord = 'Robot storage bonus',
modifier = 'force',
state = 0.05
},
{
name = 'worker_robots_battery_modifier',
discord = 'Robot battery bonus',
modifier = 'force',
state = 0.05
},
{
name = 'worker_robots_speed_modifier',
discord = 'Robot speed modifier',
modifier = 'force',
state = 0.05
},
{
name = 'mining_drill_productivity_bonus',
discord = 'Drill productivity bonus',
modifier = 'force',
state = 0.05
},
{
name = 'character_health_bonus',
discord = 'Character health bonus',
modifier = 'force',
state = 250
},
{
name = 'distance',
discord = 'RPG reach distance bonus',
modifier = 'rpg_distance',
modifiers = {'character_resource_reach_distance_bonus', 'character_item_pickup_distance_bonus', 'character_loot_pickup_distance_bonus', 'character_reach_distance_bonus'},
state = 0.05
},
{
name = 'manual_crafting_speed_modifier',
discord = 'Crafting speed modifier',
modifier = 'force',
state = 0.12
},
{
name = 'xp_bonus',
discord = 'RPG XP point bonus',
modifier = 'rpg',
state = 0.12
},
{
name = 'xp_level',
discord = 'RPG XP level bonus',
modifier = 'rpg',
state = 20
},
{
name = 'supplies',
discord = 'Starting items supplies',
modifier = 'starting_items',
limit = nil,
items = {
@ -162,6 +176,7 @@ local function get_random_buff()
},
{
name = 'supplies_1',
discord = 'Starting items supplies',
modifier = 'starting_items',
limit = nil,
replaces = 'supplies',
@ -172,6 +187,7 @@ local function get_random_buff()
},
{
name = 'supplies_2',
discord = 'Starting items supplies',
modifier = 'starting_items_1',
limit = nil,
replaces = 'supplies',
@ -182,6 +198,7 @@ local function get_random_buff()
},
{
name = 'defense',
discord = 'Defense starting supplies',
modifier = 'starting_items',
limit = nil,
items = {
@ -191,6 +208,7 @@ local function get_random_buff()
},
{
name = 'defense_2',
discord = 'Defense starting supplies',
modifier = 'starting_items',
limit = nil,
replaces = 'defense',
@ -201,6 +219,7 @@ local function get_random_buff()
},
{
name = 'defense_3',
discord = 'Defense starting supplies',
modifier = 'starting_items',
replaces = 'defense_2',
limit = nil,
@ -211,6 +230,7 @@ local function get_random_buff()
},
{
name = 'armor',
discord = 'Armor starting supplies',
modifier = 'starting_items',
limit = 1,
items = {
@ -220,6 +240,7 @@ local function get_random_buff()
},
{
name = 'production',
discord = 'Production starting supplies',
modifier = 'starting_items',
limit = nil,
items = {
@ -229,6 +250,7 @@ local function get_random_buff()
},
{
name = 'production_1',
discord = 'Production starting supplies',
modifier = 'starting_items',
limit = nil,
replaces = 'production',
@ -239,6 +261,7 @@ local function get_random_buff()
},
{
name = 'fast_startup',
discord = 'Assemling starting supplies',
modifier = 'starting_items',
limit = nil,
items = {
@ -247,6 +270,7 @@ local function get_random_buff()
},
{
name = 'fast_startup_1',
discord = 'Assemling starting supplies',
modifier = 'starting_items',
limit = nil,
replaces = 'fast_startup',
@ -256,6 +280,7 @@ local function get_random_buff()
},
{
name = 'fast_startup_2',
discord = 'Assemling starting supplies',
modifier = 'starting_items',
limit = nil,
replaces = 'fast_startup_2',
@ -265,6 +290,7 @@ local function get_random_buff()
},
{
name = 'heal-thy-buildings',
discord = 'Repair starting supplies',
modifier = 'starting_items',
limit = nil,
items = {
@ -273,6 +299,7 @@ local function get_random_buff()
},
{
name = 'extra_wagons',
discord = 'Extra wagon at start',
modifier = 'locomotive',
state = 1
}

View File

@ -1178,7 +1178,11 @@ local function zone_scrap_2(x, y, data, void_or_lab, adjusted_zones)
local scrap_mineable_entities, scrap_mineable_entities_index = get_scrap_mineable_entities()
if random(1, 5) > 1 then
entities[#entities + 1] = {name = scrap_mineable_entities[random(1, scrap_mineable_entities_index)], position = p, force = 'neutral'}
entities[#entities + 1] = {
name = scrap_mineable_entities[random(1, scrap_mineable_entities_index)],
position = p,
force = 'neutral'
}
end
if random(1, 256) == 1 then
@ -1307,7 +1311,11 @@ local function zone_scrap_1(x, y, data, void_or_lab, adjusted_zones)
local scrap_mineable_entities, scrap_mineable_entities_index = get_scrap_mineable_entities()
if random(1, 5) > 1 then
entities[#entities + 1] = {name = scrap_mineable_entities[random(1, scrap_mineable_entities_index)], position = p, force = 'neutral'}
entities[#entities + 1] = {
name = scrap_mineable_entities[random(1, scrap_mineable_entities_index)],
position = p,
force = 'neutral'
}
end
if random(1, 256) == 1 then
@ -2754,7 +2762,11 @@ local function border_chunk(p, data)
if not is_out_of_map(pos) then
if random(1, ceil(pos.y + pos.y) + 32) == 1 then
entities[#entities + 1] = {name = scrap_mineable_entities[random(1, scrap_mineable_entities_index)], position = pos, force = 'neutral'}
entities[#entities + 1] = {
name = scrap_mineable_entities[random(1, scrap_mineable_entities_index)],
position = pos,
force = 'neutral'
}
end
if random(1, pos.y + 2) == 1 then
@ -2858,6 +2870,20 @@ function Public.heavy_functions(data)
end
end
local chunk_tile_vectors = {}
for x = 0, 31, 1 do
for y = 0, 31, 1 do
chunk_tile_vectors[#chunk_tile_vectors + 1] = {x, y}
end
end
local loading_chunk_vectors = {}
for _, v in pairs(chunk_tile_vectors) do
if v[2] == 16 or v[2] == 17 then
table.insert(loading_chunk_vectors, v)
end
end
Event.add(
defines.events.on_chunk_generated,
function(e)
@ -2905,6 +2931,15 @@ Event.add(
if left_top.y < -32 then
game.forces.player.chart(surface, {{left_top.x, left_top.y}, {left_top.x + 31, left_top.y + 31}})
end
local tiles = {}
if math.abs(left_top.y) > 128 then
for k, v in pairs(loading_chunk_vectors) do
tiles[k] = {name = 'out-of-map', position = {left_top.x + v[1], left_top.y + v[2]}}
end
end
surface.set_tiles(tiles, false)
end
)