diff --git a/.luacheckrc b/.luacheckrc index 773cd8f7..bb7f6901 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1196,7 +1196,7 @@ stds.factorio_defines = { 'change_train_stop_station', 'change_train_wait_condition', 'change_train_wait_condition_data', - 'clean_cursor_stack', + 'clear_cursor_stack', 'clear_selected_blueprint', 'clear_selected_deconstruction_item', 'clear_selected_upgrade_item', diff --git a/maps/mountain_fortress_v3/balance.lua b/maps/mountain_fortress_v3/balance.lua index ddbcf294..cf90ec4b 100644 --- a/maps/mountain_fortress_v3/balance.lua +++ b/maps/mountain_fortress_v3/balance.lua @@ -40,7 +40,7 @@ local function enemy_weapon_damage() local e = game.forces.enemy local data = { - ['artillery-shell'] = 0.001, + ['artillery-shell'] = 0.05, ['biological'] = 0.08, ['bullet'] = 0.08, ['capsule'] = 0.08, diff --git a/maps/mountain_fortress_v3/icw/functions.lua b/maps/mountain_fortress_v3/icw/functions.lua index 15df4573..f7026486 100644 --- a/maps/mountain_fortress_v3/icw/functions.lua +++ b/maps/mountain_fortress_v3/icw/functions.lua @@ -221,13 +221,15 @@ local function output_cargo(wagon, passive_chest) if not passive_chest.valid then return end - local chest1 = passive_chest.get_inventory(defines.inventory.cargo_wagon) + local chest1 = passive_chest.get_inventory(defines.inventory.chest) local chest2 = wagon.entity.get_inventory(defines.inventory.cargo_wagon) - for k, v in pairs(chest1.get_contents()) do - local t = {name = k, count = v} - local c = chest2.insert(t) - if (c > 0) then - chest1.remove({name = k, count = c}) + for i = 1, #chest1 do + local t = chest1[i] + if t and t.valid then + local c = chest2.insert(t) + if (c > 0) then + chest1.remove(t) + end end end end @@ -427,14 +429,13 @@ function Public.create_wagon_room(icw, wagon) end end - for x = area.left_top.x, area.right_bottom.x - 1, 1 do + --[[ for x = area.left_top.x, area.right_bottom.x - 1, 1 do for y = area.left_top.y + 2, area.right_bottom.y - 3, 1 do if random(1, 16) == 1 then - fishes[#fishes + 1] = {name = 'mineable-wreckage', position = {x, y}} + fishes[#fishes + 1] = {name = crash_site[random(1, size_of_crash)], position = {x, y}, force = 'player'} end end - end - + end ]] surface.set_tiles(tiles, true) for _, fish in pairs(fishes) do diff --git a/maps/mountain_fortress_v3/terrain.lua b/maps/mountain_fortress_v3/terrain.lua index 88bf7a9c..bb3428cb 100644 --- a/maps/mountain_fortress_v3/terrain.lua +++ b/maps/mountain_fortress_v3/terrain.lua @@ -22,6 +22,7 @@ local wagon_raffle = { 'locomotive', 'fluid-wagon' } + local rock_raffle = { 'sand-rock-big', 'sand-rock-big', @@ -954,7 +955,7 @@ local function process_level_8_position(x, y, data, void_or_lab) } end if random(1, 5) > 1 then - entities[#entities + 1] = {name = 'mineable-wreckage', position = p} + entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p} end if random(1, 256) == 1 then entities[#entities + 1] = {name = 'land-mine', position = p, force = 'enemy'} diff --git a/modules/rpg/functions.lua b/modules/rpg/functions.lua index c41ff8a7..19eb505b 100644 --- a/modules/rpg/functions.lua +++ b/modules/rpg/functions.lua @@ -474,7 +474,7 @@ end --- Gives connected player some bonus xp if the map was preemptively shut down. -- amount (integer) -- 10 levels --- local Public = require 'modules.rpg_v2' Public.give_xp(512) +-- local Public = require 'modules.rpg.functions' Public.give_xp(512) function Public.give_xp(amount) for _, player in pairs(game.connected_players) do if not Public.validate_player(player) then diff --git a/utils/scenariohandler.lua b/utils/scenariohandler.lua new file mode 100644 index 00000000..7e14c377 --- /dev/null +++ b/utils/scenariohandler.lua @@ -0,0 +1,139 @@ +local Color = require 'utils.color_presets' +local Server = require 'utils.server' +local Global = require 'utils.globals' + +local mapkeeper = '[color=blue]Mapkeeper:[/color]' + +local Public = {} + +local this = { + scenarioname = '', + reset_are_you_sure = false, + restart = false, + soft_reset = false, + shutdown = false, + accepted_params = { + ['restart'] = true, + ['resetnow'] = true, + ['shutdown'] = true, + ['restartnow'] = true + } +} + +Global.register( + this, + function(t) + this = t + end +) + +commands.add_command( + 'scenario', + 'Usable only for admins - controls the scenario!', + function(cmd) + local p + local player = game.player + + if not player or not player.valid then + p = log + else + p = player.print + if not player.admin then + return + end + end + + local param = cmd.parameter + + if this.accepted_params[param] then + goto continue + else + p('[ERROR] Arguments was invalid.') + return + end + + ::continue:: + + if not this.reset_are_you_sure then + this.reset_are_you_sure = true + p( + '[WARNING] This command will disable the soft-reset feature, run this command again if you really want to do this!' + ) + return + end + + if param == 'restart' then + if this.restart then + this.reset_are_you_sure = nil + this.restart = false + this.soft_reset = true + p('[SUCCESS] Soft-reset is once again enabled.') + return + else + this.reset_are_you_sure = nil + this.restart = true + this.soft_reset = false + if this.shutdown then + this.shutdown = false + end + 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 + p(player.name .. ' restarted the game.') + Server.start_scenario(this.scenarioname) + return + elseif param == 'shutdown' then + if this.shutdown then + this.reset_are_you_sure = nil + this.shutdown = false + this.soft_reset = true + p('[SUCCESS] Soft-reset is once again enabled.') + return + else + this.reset_are_you_sure = nil + this.shutdown = true + this.soft_reset = false + if this.restart then + this.restart = false + end + p('[WARNING] Soft-reset is disabled! Server will shutdown. Most likely because of updates.') + 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}) + else + game.print(mapkeeper .. ' server, has reset the game!', {r = 0.98, g = 0.66, b = 0.22}) + end + reset_map() + p('[WARNING] Game has been reset!') + return + end + end +) + +function Public.map_reset_callback(data, callback) + if not data then + return + end + if not callback then + return + end + + if not string.find(callback, '%s') and not string.find(callback, 'return') then + callback = 'return ' .. callback + end + + if type(callback) == 'function' then + local success, err = pcall(callback, data) + return success, err + else + local success, err = pcall(loadstring(callback), data) + return success, err + end +end + +return Public