1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-30 23:17:53 +02:00

Updates to Mountain Fortress

Removed rerolls
Removed Nightmare diff
Fixes by perfectwill
This commit is contained in:
Gerkiz 2020-12-02 22:59:39 +01:00
parent 9f4890c218
commit 31db1ba9b6
6 changed files with 138 additions and 279 deletions

View File

@ -2,28 +2,33 @@ local Session = require 'utils.datastore.session_data'
local Modifiers = require 'player_modifiers'
local Server = require 'utils.server'
local Color = require 'utils.color_presets'
local Event = require 'utils.event'
local Global = require 'utils.global'
local this = {}
Global.register(
this,
function(t)
this = t
end
)
commands.add_command(
'spaghetti',
'Does spaghett.',
function(cmd)
local p_modifer = Modifiers.get_table()
local player = game.player
local _a = p_modifer
local param = tostring(cmd.parameter)
local force = game.forces['player']
local p
if player then
if player ~= nil then
p = player.print
if not player.admin then
p("[ERROR] You're not admin!", Color.fail)
return
end
else
p = log
end
if not (player and player.valid) then
return
end
local p = player.print
if not player.admin then
p("[ERROR] You're not admin!", Color.fail)
return
end
if param == nil then
@ -31,12 +36,12 @@ commands.add_command(
return
end
if param == 'true' then
if not _a.spaghetti_are_you_sure then
_a.spaghetti_are_you_sure = true
if not this.spaghetti_are_you_sure then
this.spaghetti_are_you_sure = true
player.print('Spaghetti is not enabled, run this command again to enable spaghett', Color.yellow)
return
end
if _a.spaghetti_enabled == true then
if this.spaghetti_enabled then
player.print('Spaghetti is already enabled.', Color.yellow)
return
end
@ -65,9 +70,9 @@ commands.add_command(
force.technologies['worker-robots-speed-4'].enabled = false
force.technologies['worker-robots-speed-5'].enabled = false
force.technologies['worker-robots-speed-6'].enabled = false
_a.spaghetti_enabled = true
this.spaghetti_enabled = true
elseif param == 'false' then
if _a.spaghetti_enabled == false or _a.spaghetti_enabled == nil then
if this.spaghetti_enabled == false or this.spaghetti_enabled == nil then
player.print('Spaghetti is already disabled.', Color.yellow)
return
end
@ -96,7 +101,7 @@ commands.add_command(
force.technologies['worker-robots-speed-4'].enabled = true
force.technologies['worker-robots-speed-5'].enabled = true
force.technologies['worker-robots-speed-6'].enabled = true
_a.spaghetti_enabled = false
this.spaghetti_enabled = false
end
end
)
@ -105,22 +110,17 @@ commands.add_command(
'generate_map',
'Pregenerates map.',
function(cmd)
local p_modifer = Modifiers.get_table()
local _a = p_modifer
local player = game.player
local param = tonumber(cmd.parameter)
local p
if player then
if player ~= nil then
p = player.print
if not player.admin then
p("[ERROR] You're not admin!", Color.fail)
return
end
else
p = log
end
if not (player and player.valid) then
return
end
local p = player.print
if not player.admin then
p("[ERROR] You're not admin!", Color.fail)
return
end
if param == nil then
player.print('[ERROR] Must specify radius!', Color.fail)
@ -131,19 +131,16 @@ commands.add_command(
return
end
if not _a.generate_map then
_a.generate_map = true
player.print(
'[WARNING] This command will make the server LAG, run this command again if you really want to do this!',
Color.yellow
)
if not this.generate_map then
this.generate_map = true
player.print('[WARNING] This command will make the server LAG, run this command again if you really want to do this!', Color.yellow)
return
end
local radius = param
local surface = game.players[1].surface
if surface.is_chunk_generated({radius, radius}) then
game.print('Map generation done!', Color.success)
_a.generate_map = nil
this.generate_map = nil
return
end
surface.request_to_generate_chunks({0, 0}, radius)
@ -152,7 +149,7 @@ commands.add_command(
pl.play_sound {path = 'utility/new_objective', volume_modifier = 1}
end
game.print('Map generation done!', Color.success)
_a.generate_map = nil
this.generate_map = nil
end
)
@ -160,28 +157,20 @@ commands.add_command(
'dump_layout',
'Dump the current map-layout.',
function()
local p_modifer = Modifiers.get_table()
local _a = p_modifer
local player = game.player
local p
if player then
if player ~= nil then
p = player.print
if not player.admin then
p("[ERROR] You're not admin!", Color.warning)
return
end
else
p = log
end
if not (player and player.valid) then
return
end
if not _a.dump_layout then
_a.dump_layout = true
player.print(
'[WARNING] This command will make the server LAG, run this command again if you really want to do this!',
Color.yellow
)
local p = player.print
if not player.admin then
p("[ERROR] You're not admin!", Color.warning)
return
end
if not this.dump_layout then
this.dump_layout = true
player.print('[WARNING] This command will make the server LAG, run this command again if you really want to do this!', Color.yellow)
return
end
local surface = game.players[1].surface
@ -225,7 +214,7 @@ commands.add_command(
game.write_file('layout.lua', str .. '\n', true)
player.print('Dumped layout as file: layout.lua', Color.success)
end
_a.dump_layout = false
this.dump_layout = false
end
)
@ -233,31 +222,22 @@ commands.add_command(
'creative',
'Enables creative_mode.',
function()
local p_modifer = Modifiers.get_table()
local _a = p_modifer
local player = game.player
local p
if player then
if player ~= nil then
p = player.print
if not player.admin then
p("[ERROR] You're not admin!", Color.fail)
return
end
else
p = log
end
end
if not _a.creative_are_you_sure then
_a.creative_are_you_sure = true
player.print(
'[WARNING] This command will enable creative/cheat-mode for all connected players, run this command again if you really want to do this!',
Color.yellow
)
if not (player and player.valid) then
return
end
if _a.creative_enabled == true then
local p = player.print
if not player.admin then
p("[ERROR] You're not admin!", Color.fail)
return
end
if not this.creative_are_you_sure then
this.creative_are_you_sure = true
player.print('[WARNING] This command will enable creative/cheat-mode for all connected players, run this command again if you really want to do this!', Color.yellow)
return
end
if this.creative_enabled then
player.print('[ERROR] Creative/cheat-mode is already active!', Color.fail)
return
end
@ -291,14 +271,15 @@ commands.add_command(
end
local item = game.item_prototypes
local i = 0
local p_modifer = Modifiers.get_table()
for _k, _v in pairs(item) do
i = i + 1
if _k and _v.type ~= 'mining-tool' then
_a[k].character_inventory_slots_bonus['creative'] = tonumber(i)
v.character_inventory_slots_bonus = _a[k].character_inventory_slots_bonus['creative']
p_modifer[k].character_inventory_slots_bonus['creative'] = tonumber(i)
v.character_inventory_slots_bonus = p_modifer[k].character_inventory_slots_bonus['creative']
v.insert {name = _k, count = _v.stack_size}
v.print('Inserted all base items.', Color.success)
_a.creative_enabled = true
p_modifer.creative_enabled = true
end
end
end
@ -311,17 +292,14 @@ commands.add_command(
'Deletes all chunks that are not charted. Can reduce filesize of the savegame. May be unsafe to use in certain custom maps.',
function()
local player = game.player
local p
if player then
if player ~= nil then
p = player.print
if not player.admin then
p("[ERROR] You're not admin!", Color.fail)
return
end
else
p = log
end
if not (player and player.valid) then
return
end
local p = player.print
if not player.admin then
p("[ERROR] You're not admin!", Color.fail)
return
end
local forces = {}
@ -396,3 +374,48 @@ commands.add_command(
player.print('Cleared biter-corpses.', Color.success)
end
)
local on_player_joined_game = function(event)
local player = game.players[event.player_index]
if this.creative_enabled then
player.cheat_mode = true
if player.character ~= nil then
if player.get_inventory(defines.inventory.character_armor) then
player.get_inventory(defines.inventory.character_armor).clear()
end
player.insert {name = 'power-armor-mk2', count = 1}
local p_armor = player.get_inventory(5)[1].grid
if p_armor and p_armor.valid then
p_armor.put({name = 'fusion-reactor-equipment'})
p_armor.put({name = 'fusion-reactor-equipment'})
p_armor.put({name = 'fusion-reactor-equipment'})
p_armor.put({name = 'exoskeleton-equipment'})
p_armor.put({name = 'exoskeleton-equipment'})
p_armor.put({name = 'exoskeleton-equipment'})
p_armor.put({name = 'energy-shield-mk2-equipment'})
p_armor.put({name = 'energy-shield-mk2-equipment'})
p_armor.put({name = 'energy-shield-mk2-equipment'})
p_armor.put({name = 'energy-shield-mk2-equipment'})
p_armor.put({name = 'personal-roboport-mk2-equipment'})
p_armor.put({name = 'night-vision-equipment'})
p_armor.put({name = 'battery-mk2-equipment'})
p_armor.put({name = 'battery-mk2-equipment'})
end
local item = game.item_prototypes
local i = 0
local p_modifer = Modifiers.get_table()
for _k, _v in pairs(item) do
i = i + 1
if _k and _v.type ~= 'mining-tool' then
p_modifer[player.index].character_inventory_slots_bonus['creative'] = tonumber(i)
player.character_inventory_slots_bonus = p_modifer[player.index].character_inventory_slots_bonus['creative']
player.insert {name = _k, count = _v.stack_size}
player.print('[CREATIVE] Inserted all base items.', Color.success)
end
end
end
end
end
Event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -76,34 +76,6 @@ local function do_refill_turrets()
end
end
-- local function turret_died(event)
-- local entity = event.entity
-- if not entity or not entity.valid then
-- return
-- end
-- local number = entity.unit_number
-- if not number then
-- return
-- end
-- local power_sources = this.power_sources
-- local ps_data = power_sources[number]
-- if ps_data then
-- power_sources[number] = nil
-- --[[ local ps_entity = ps_data.entity
-- local ps_pole = ps_data.pole ]]
-- if ps_data and ps_data.valid then
-- ps_data.destroy()
-- end
-- --[[ if ps_pole and ps_pole.valid then
-- ps_pole.destroy()
-- end ]]
-- end
-- end
local function do_turret_energy()
local power_sources = this.power_sources
@ -465,21 +437,8 @@ Public.refill_liquid_turret_callback =
Public.power_source_callback =
Token.register(
function(turret, data)
function(turret)
local power_sources = this.power_sources
-- local callback_data = data.callback_data
--[[ local power_source = turret.surface.create_entity {name = 'hidden-electric-energy-interface', position = turret.position}
power_source.electric_buffer_size = callback_data.buffer_size
power_source.power_production = callback_data.power_production
power_source.destructible = false
local power_pole =
turret.surface.create_entity {
name = 'small-electric-pole',
position = {x = turret.position.x, y = turret.position.y}
}
power_pole.destructible = false
power_pole.disconnect_neighbour() ]]
power_sources[#power_sources + 1] = turret
end
)

View File

@ -148,8 +148,7 @@ local set_loco_tiles =
break
end
if surface.can_place_entity({name = 'wooden-chest', position = p[i]}) then
local e =
surface.create_entity({name = 'wooden-chest', position = p[i], force = 'player', create_build_effect_smoke = false})
local e = surface.create_entity({name = 'wooden-chest', position = p[i], force = 'player', create_build_effect_smoke = false})
local inventory = e.get_inventory(defines.inventory.chest)
inventory.insert(cargo_boxes[i])
end
@ -939,27 +938,6 @@ local function gui_click(event)
local cost = (item.price * slider_value)
local item_count = item.stack * slider_value
if name == 'reroll_market_items' then
player.remove_item({name = item.value, count = item.price})
local message = ({'locomotive.reroll_bought_info', shopkeeper, player.name, format_number(item.price, true)})
Alert.alert_all_players(5, message)
Server.to_discord_bold(
table.concat {
player.name .. ' has rerolled the market items for ' .. format_number(item.price, true) .. ' coins.'
}
)
local breached_wall = WPT.get('breached_wall')
add_random_loot_to_main_market(breached_wall + random(1, 3))
Public.get_items(true)
redraw_market_items(data.item_frame, player, data.search_text)
redraw_coins_left(data.coins_left, player)
return
end
local this = WPT.get()
if name == 'upgrade_pickaxe' then
player.remove_item({name = item.value, count = item.price})
@ -1157,8 +1135,7 @@ local function gui_click(event)
Alert.alert_all_players(5, message)
Server.to_discord_bold(
table.concat {
player.name ..
' has bought ' .. item.stack .. ' flamethrower-turret slots for ' .. format_number(item.price, true) .. ' coins.'
player.name .. ' has bought ' .. item.stack .. ' flamethrower-turret slots for ' .. format_number(item.price, true) .. ' coins.'
}
)
end
@ -1186,8 +1163,7 @@ local function gui_click(event)
if item.price >= 1000 then
Server.to_discord_bold(
table.concat {
player.name ..
' has bought ' .. item.stack .. ' landmine slots for ' .. format_number(item.price, true) .. ' coins.'
player.name .. ' has bought ' .. item.stack .. ' landmine slots for ' .. format_number(item.price, true) .. ' coins.'
}
)
end
@ -1320,8 +1296,7 @@ local function spawn_biter()
if not position then
return
end
this.locomotive_biter =
loco_surface.create_entity({name = biters[random(1, 4)], position = position, force = 'player', create_build_effect_smoke = false})
this.locomotive_biter = loco_surface.create_entity({name = biters[random(1, 4)], position = position, force = 'player', create_build_effect_smoke = false})
this.locomotive_biter.ai_settings.allow_destroy_when_commands_fail = false
this.locomotive_biter.ai_settings.allow_try_return_to_spawner = false
@ -1911,7 +1886,7 @@ function Public.locomotive_spawn(surface, position)
game.forces.player.set_spawn_position({0, 19}, locomotive.surface)
end
function Public.get_items(reroll)
function Public.get_items()
local chest_limit_outside_upgrades = WPT.get('chest_limit_outside_upgrades')
local health_upgrades = WPT.get('health_upgrades')
local pickaxe_tier = WPT.get('pickaxe_tier')
@ -1925,7 +1900,6 @@ function Public.get_items(reroll)
local chest_limit_cost = round(fixed_prices.chest_limit_cost * (1 + chest_limit_outside_upgrades))
local health_cost = round(fixed_prices.health_cost * (1 + health_upgrades))
local pickaxe_cost = round(fixed_prices.pickaxe_cost * (0.1 + pickaxe_tier / 2))
local reroll_cost = round(fixed_prices.reroll_cost)
local aura_cost = round(fixed_prices.aura_cost * (1 + aura_upgrades))
local xp_point_boost_cost = round(fixed_prices.xp_point_boost_cost * (1 + xp_points_upgrade))
local explosive_bullets_cost = round(fixed_prices.explosive_bullets_cost)
@ -1933,40 +1907,6 @@ function Public.get_items(reroll)
local land_mine_cost = round(fixed_prices.land_mine_cost * (1 + landmine))
local skill_reset_cost = round(fixed_prices.skill_reset_cost)
if reroll then
fixed_prices.chest_limit_cost = round(random(2000, 3000) * (1 + chest_limit_outside_upgrades))
fixed_prices.health_cost = round(random(7000, 10000) * (1 + health_upgrades))
fixed_prices.pickaxe_cost = round(random(3500, 8000))
fixed_prices.reroll_cost = round(random(2000, 3000))
fixed_prices.aura_cost = round(random(3000, 6000) * (1 + aura_upgrades))
fixed_prices.xp_point_boost_cost = round(random(4000, 6000) * (1 + xp_points_upgrade))
fixed_prices.explosive_bullets_cost = round(random(18000, 21000))
fixed_prices.flamethrower_turrets_cost = round(random(2500, 4000) * (1 + flame_turret))
fixed_prices.land_mine_cost = round(random(1, 8) * (1 + landmine))
fixed_prices.skill_reset_cost = round(random(90000, 110000))
if main_market_items['spidertron'] then
local rng = round(random(70000, 120000))
main_market_items['spidertron'] = {
stack = 1,
value = 'coin',
price = rng,
tooltip = 'Chonk Spidertron',
upgrade = false,
static = true
}
end
end
main_market_items['reroll_market_items'] = {
stack = 1,
value = 'coin',
price = reroll_cost,
tooltip = ({'main_market.reroll_market_items'}),
sprite = 'achievement/logistic-network-embargo',
enabled = true,
upgrade = true,
static = true
}
local pickaxe_tiers = WPT.pickaxe_upgrades
local tier = WPT.get('pickaxe_tier')
local offer = pickaxe_tiers[tier]

View File

@ -174,28 +174,13 @@ local set_difficulty = function()
amount = 3
end
local difficulty = Difficulty.get()
local name = difficulty.difficulties[difficulty.difficulty_vote_index].name
if name ~= 'Nightmare' then
local zone = WPT.get('breached_wall')
if zone >= 5 then
WPT.set().coin_amount = random(1, 2)
elseif zone >= 10 then
WPT.set().coin_amount = random(1, 3)
end
end
if wave_defense_table.threat <= 0 then
wave_defense_table.wave_interval = 1000
end
if name == 'Nightmare' then
wave_defense_table.wave_interval = 3600 - player_count * 60
if wave_defense_table.wave_interval < 1800 then
wave_defense_table.wave_interval = 1800
else
wave_defense_table.wave_interval = 3600 - player_count * 60
if wave_defense_table.wave_interval < 1800 then
wave_defense_table.wave_interval = 1800
end
end
local gap_between_zones = WPT.get('gap_between_zones')
@ -203,9 +188,7 @@ local set_difficulty = function()
return
end
if name == 'Nightmare' then
Collapse.set_amount(10)
elseif collapse_amount then
if collapse_amount then
Collapse.set_amount(collapse_amount)
else
Collapse.set_amount(amount)
@ -710,20 +693,6 @@ local boost_difficulty = function()
WPT.set().spidertron_unlocked_at_wave = 18
WPT.set().difficulty_set = true
WD.set_biter_health_boost(3)
elseif name == 'Nightmare' then
-- rpg_extra.difficulty = 0
force.character_running_speed_modifier = 0
force.manual_crafting_speed_modifier = 0
WPT.set().coin_amount = 1
WPT.set('upgrades').flame_turret.limit = 0
WPT.set('upgrades').landmine.limit = 0
WPT.set().locomotive_health = 1000
WPT.set().locomotive_max_health = 1000
WPT.set().bonus_xp_on_join = 0
WD.set().next_wave = game.tick + 3600 * 2
WPT.set().spidertron_unlocked_at_wave = 22
WPT.set().difficulty_set = true
WD.set_biter_health_boost(4)
end
end
@ -905,17 +874,10 @@ local collapse_after_wave_100 = function()
if Collapse.start_now() then
return
end
local difficulty = Difficulty.get()
local name = difficulty.difficulties[difficulty.difficulty_vote_index].name
local difficulty_set = WPT.get('difficulty_set')
if not difficulty_set and name == 'Nightmare' then
return
end
local wave_number = WD.get_wave()
if wave_number >= 100 or name == 'Nightmare' then
if wave_number >= 100 then
Collapse.start_now(true)
local data = {
position = Collapse.get_position()
@ -959,8 +921,7 @@ local on_init = function()
local tooltip = {
[1] = ({'main.diff_tooltip', '0', '0.5', '0.2', '0.4', '1', '12', '50', '10000', '100%', '15', '14'}),
[2] = ({'main.diff_tooltip', '0', '0.25', '0.1', '0.1', '1', '10', '50', '7000', '75%', '10', '16'}),
[3] = ({'main.diff_tooltip', '0', '0', '0', '0', '1', '3', '10', '5000', '50%', '10', '18'}),
[4] = ({'main.diff_tooltip', '0', '0', '0', '0', '1', '0', '0', '1000', '25%', '5', '22'})
[3] = ({'main.diff_tooltip', '0', '0', '0', '0', '1', '3', '10', '5000', '50%', '10', '18'})
}
Difficulty.set_tooltip(tooltip)

View File

@ -166,7 +166,6 @@ function Public.reset_table()
chest_limit_cost = 3000,
health_cost = 10000,
pickaxe_cost = 3000,
reroll_cost = 5000,
aura_cost = 4000,
xp_point_boost_cost = 5000,
explosive_bullets_cost = 20000,

View File

@ -36,30 +36,16 @@ local this = {
count = 0,
strength_modifier = 1.75,
boss_modifier = 8.0
},
[4] = {
name = 'Nightmare',
index = 4,
value = 3,
color = {r = 255, g = 0.00, b = 0.00},
print_color = {r = 255, g = 0.0, b = 0.00},
count = 0,
strength_modifier = 2.50,
boss_modifier = 9.0
}
},
tooltip = {
[1] = '',
[2] = '',
[3] = '',
[4] = '',
[5] = '',
[6] = '',
[7] = ''
[3] = ''
},
difficulty_vote_value = 1,
difficulty_vote_index = 1,
fair_vote = true,
fair_vote = false,
difficulty_poll_closing_timeout = 54000,
difficulty_player_votes = {},
gui_width = 108,
@ -84,8 +70,7 @@ function Public.difficulty_gui()
if player.gui.top['difficulty_gui'] then
player.gui.top['difficulty_gui'].caption = this.difficulties[this.difficulty_vote_index].name
player.gui.top['difficulty_gui'].tooltip = this.button_tooltip or tooltip
player.gui.top['difficulty_gui'].style.font_color =
this.difficulties[this.difficulty_vote_index].print_color
player.gui.top['difficulty_gui'].style.font_color = this.difficulties[this.difficulty_vote_index].print_color
else
local b =
player.gui.top.add {
@ -181,8 +166,7 @@ local function poll_difficulty(player)
{
type = 'button',
name = 'close',
caption = 'Close (' ..
math.floor((this.difficulty_poll_closing_timeout - game.tick) / 3600) .. ' minutes left)'
caption = 'Close (' .. math.floor((this.difficulty_poll_closing_timeout - game.tick) / 3600) .. ' minutes left)'
}
)
b.style.font_color = {r = 0.66, g = 0.0, b = 0.66}
@ -194,8 +178,7 @@ local function set_difficulty()
local index = highest_count(this.difficulties)
if this.difficulty_vote_index ~= index then
local message =
table.concat({'>> Map difficulty has changed to ', this.difficulties[index].name, ' difficulty!'})
local message = table.concat({'>> Map difficulty has changed to ', this.difficulties[index].name, ' difficulty!'})
game.print(message, this.difficulties[index].print_color)
Server.to_discord_embed(message)
end
@ -304,10 +287,7 @@ local function on_gui_click(event)
local i = tonumber(event.element.name)
if this.difficulty_player_votes[player.name] and this.difficulty_player_votes[player.name].index == i then
player.print(
'You have already voted for ' .. this.difficulties[i].name .. '.',
this.difficulties[i].print_color
)
player.print('You have already voted for ' .. this.difficulties[i].name .. '.', this.difficulties[i].print_color)
return event.element.parent.destroy()
end
@ -325,10 +305,7 @@ local function on_gui_click(event)
set_difficulty()
Public.difficulty_gui()
event.element.parent.destroy()
game.print(
player.name .. ' has voted for ' .. this.difficulties[i].name .. ' difficulty!',
this.difficulties[i].print_color
)
game.print(player.name .. ' has voted for ' .. this.difficulties[i].name .. ' difficulty!', this.difficulties[i].print_color)
end
function Public.set_tooltip(...)