From 647d52859ce66eb52cdffd0befefe268bc2999bf Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Sat, 11 Jul 2020 09:32:36 +0200 Subject: [PATCH] minor changes to fishy and mtn --- antigrief.lua | 72 +++++++++++++++++---- comfy_panel/player_list.lua | 4 +- maps/fish_defender/main.lua | 21 +----- maps/fish_defender/terrain.lua | 4 +- maps/mountain_fortress_v3/icw/functions.lua | 8 +-- maps/mountain_fortress_v3/icw/table.lua | 5 +- maps/mountain_fortress_v3/main.lua | 16 +++-- 7 files changed, 83 insertions(+), 47 deletions(-) diff --git a/antigrief.lua b/antigrief.lua index aae79023..08a02351 100644 --- a/antigrief.lua +++ b/antigrief.lua @@ -1,5 +1,5 @@ --antigrief things made by mewmew ---modified by gerkiz-- +--rewritten by gerkiz-- --as an admin, write either /trust or /untrust and the players name in the chat to grant/revoke immunity from protection local Event = require 'utils.event' @@ -26,7 +26,7 @@ local this = { players_warned = {}, log_tree_harvest = false, do_not_check_trusted = true, - protect_entities = false, + protect_entities = true, enable_autokick = true, enable_autoban = false } @@ -53,10 +53,50 @@ local ammo_names = { ['rocket'] = true } -local not_protected = { - ['wall'] = true, - ['container'] = true, - ['logistic-container'] = true +local protected = { + ['reactor'] = true, + ['roboport'] = true, + ['rocket-silo'] = true, + ['solar-panel'] = true, + ['generator'] = true, + ['splitter'] = true, + ['transport-belt'] = true, + ['underground-belt'] = true, + ['assembling-machine'] = true, + ['storage-tank'] = true, + ['pump'] = true, + ['mining-drill'] = true, + ['market'] = true, + ['accumulator'] = true, + ['ammo-turret'] = true, + ['artillery-turret'] = true, + ['artillery-wagon'] = true, + ['beacon'] = true, + ['boiler'] = true, + ['burner-generator'] = true, + ['car'] = true, + ['cargo-wagon'] = true, + ['constant-combinator'] = true, + ['straight-rail'] = true, + ['curved-rail'] = true, + ['decider-combinator'] = true, + ['electric-pole'] = true, + ['electric-turret'] = true, + ['fluid-turret'] = true, + ['fluid-wagon'] = true, + ['furnace'] = true, + ['gate'] = true, + ['heat-interface'] = true, + ['heat-pipe'] = true, + ['inserter'] = true, + ['lab'] = true, + ['lamp'] = true, + ['loader'] = true, + ['locomotive'] = true, + ['logistic-robot'] = true, + ['offshore-pump'] = true, + ['pipe-to-ground'] = true, + ['pipe'] = true } Global.register( @@ -637,11 +677,11 @@ local function protect_entities(event) local entity = event.entity local function is_protected(e) - if not_protected[e.type] then - return false + if protected[e.type] then + return true end - return true + return false end if is_protected(entity) then @@ -649,20 +689,28 @@ local function protect_entities(event) end end +--- Protect entities from the player force +---@param event local function on_entity_damaged(event) + if not this.protect_entities then + return + end + local entity = event.entity if not entity or not entity.valid then return end + if event.force.index ~= 1 then + return + end + if entity.force.index ~= 1 then return end - if this.protect_entities then - protect_entities(event) - end + protect_entities(event) end --- Enabling this will protect all entities except for those in the not_protected table. diff --git a/comfy_panel/player_list.lua b/comfy_panel/player_list.lua index 56b152f6..3fa48e7d 100644 --- a/comfy_panel/player_list.lua +++ b/comfy_panel/player_list.lua @@ -478,10 +478,10 @@ local function player_list_show(player, frame, sort_by) tooltip = 'This player is an admin of this server.' elseif play_table[player_list[i].name] then trusted = '[color=#008000][T][/color]' - tooltip = 'This player trusted.' + tooltip = 'This player is trusted.' else trusted = '[color=#ffff00][U][/color]' - tooltip = 'This player not trusted.' + tooltip = 'This player is not trusted.' end -- Name diff --git a/maps/fish_defender/main.lua b/maps/fish_defender/main.lua index a8a26031..90fcb96f 100644 --- a/maps/fish_defender/main.lua +++ b/maps/fish_defender/main.lua @@ -1040,10 +1040,6 @@ local function on_player_joined_game(event) return end - if player.gui.left['fish_defense_game_lost'] then - player.gui.left['fish_defense_game_lost'].destroy() - end - if player.online_time == 0 then for item, amount in pairs(starting_items) do player.insert({name = item, count = amount}) @@ -1058,7 +1054,7 @@ local function on_player_joined_game(event) local pos = surface.find_non_colliding_position('character', spawn, 3, 0.5) if not pos and player.online_time < 2 then - player.teleport(game.forces['player'].get_spawn_position(surface), surface) + player.teleport(spawn, surface) elseif player.online_time < 2 or player.surface.index ~= this.active_surface_index then player.teleport(pos, surface) end @@ -1434,6 +1430,8 @@ function Public.reset_game() global.chunk_queue = {} + Terrain.fish_eye(surface, {x = -2150, y = -300}) + game.map_settings.enemy_expansion.enabled = false game.map_settings.enemy_evolution.destroy_factor = 0 game.map_settings.enemy_evolution.time_factor = 0 @@ -1533,17 +1531,4 @@ Event.add(defines.events.on_robot_mined_entity, on_robot_mined_entity) Event.add(defines.events.on_tick, on_tick) Event.on_init(on_init) -local gmeta = getmetatable(_ENV) -if not gmeta then - gmeta = {} - setmetatable(_ENV, gmeta) -end -gmeta.__newindex = function(_, n, v) - log('Desync warning: attempt to write to undeclared var ' .. n) - global[n] = v -end -gmeta.__index = function(_, n) - return global[n] -end - return Public diff --git a/maps/fish_defender/terrain.lua b/maps/fish_defender/terrain.lua index b394d9a9..b0ac800b 100644 --- a/maps/fish_defender/terrain.lua +++ b/maps/fish_defender/terrain.lua @@ -330,6 +330,7 @@ local function process_chunk_queue() if chunks <= 0 then return end + for k, left_top in pairs(global.chunk_queue) do process_chunk(left_top) global.chunk_queue[k] = nil @@ -480,8 +481,6 @@ function Public.generate_spawn_area(this, surface) render_market_hp() - Public.fish_eye(surface, {x = -2150, y = -300}) - local r = 16 for _, entity in pairs( surface.find_entities_filtered( @@ -544,6 +543,7 @@ end function Public.fish_eye(surface, position) surface.request_to_generate_chunks(position, 2) + surface.force_generate_chunk_requests() for x = -48, 48, 1 do for y = -48, 48, 1 do local p = {x = position.x + x, y = position.y + y} diff --git a/maps/mountain_fortress_v3/icw/functions.lua b/maps/mountain_fortress_v3/icw/functions.lua index 57fee61d..4e08b70a 100644 --- a/maps/mountain_fortress_v3/icw/functions.lua +++ b/maps/mountain_fortress_v3/icw/functions.lua @@ -434,10 +434,10 @@ function Public.create_wagon_room(icw, wagon) local multiple_chests = ICW.get('multiple_chests') local wagon_areas = ICW.get('wagon_areas') local cargo_wagon = wagon_areas['cargo-wagon'] - local position1 = {cargo_wagon.left_top.x + 7, cargo_wagon.left_top.y + 1} - local position2 = {cargo_wagon.right_bottom.x - 8, cargo_wagon.left_top.y + 1} - local position3 = {cargo_wagon.left_top.x + 7, cargo_wagon.right_bottom.y - 2} - local position4 = {cargo_wagon.right_bottom.x - 8, cargo_wagon.right_bottom.y - 2} + local position1 = {cargo_wagon.left_top.x + 4, cargo_wagon.left_top.y + 1} + local position2 = {cargo_wagon.right_bottom.x - 5, cargo_wagon.left_top.y + 1} + local position3 = {cargo_wagon.left_top.x + 4, cargo_wagon.right_bottom.y - 2} + local position4 = {cargo_wagon.right_bottom.x - 5, cargo_wagon.right_bottom.y - 2} if multiple_chests then local e1 = diff --git a/maps/mountain_fortress_v3/icw/table.lua b/maps/mountain_fortress_v3/icw/table.lua index 36114dc6..045fb6de 100644 --- a/maps/mountain_fortress_v3/icw/table.lua +++ b/maps/mountain_fortress_v3/icw/table.lua @@ -51,12 +51,11 @@ function Public.get(key) end function Public.set_wagon_area(tbl) - local arg = tbl - if not arg then + if not tbl then return end - this.wagon_areas = arg + this.wagon_areas = tbl end return Public diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index b1c3818b..e04ca01d 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -244,8 +244,14 @@ function Public.reset_map() Entities.set_scores() AntiGrief.log_tree_harvest(true) AntiGrief.whitelist_types('tree', true) - AntiGrief.protect_entities(true) - get_score.score_table = {} + --AntiGrief.protect_entities(true) + + local players = game.connected_players + for i = 1, #players do + local player = players[i] + Score.init_player_table(player) + end + Difficulty.reset_difficulty_poll({difficulty_poll_closing_timeout = game.tick + 36000}) Diff.gui_width = 20 @@ -259,7 +265,7 @@ function Public.reset_map() Collapse.set_direction('north') Collapse.start_now(false) - local x_value = rng(15, 25) + --[[ local x_value = rng(15, 25) local y_value = rng(50, 60) local data = { @@ -268,9 +274,7 @@ function Public.reset_map() ['fluid-wagon'] = {left_top = {x = -x_value, y = 0}, right_bottom = {x = x_value, y = y_value}}, ['locomotive'] = {left_top = {x = -x_value, y = 0}, right_bottom = {x = x_value, y = y_value}} } - - ICT.set_wagon_area(data) - + ICT.set_wagon_area(data) ]] this.locomotive_health = 10000 this.locomotive_max_health = 10000