local Event = require 'utils.event' local Rank = require 'features.rank_system' local Utils = require 'utils.core' local Task = require 'utils.task' local Token = require 'utils.token' local Global = require 'utils.global' local Server = require 'features.server' local Report = require 'features.report' local Popup = require 'features.gui.popup' local Ranks = require 'resources.ranks' local format = string.format local match = string.match local players_warned = {} local entities_allowed_to_bomb = { ['stone-wall'] = true, ['transport-belt'] = true, ['fast-transport-belt'] = true, ['express-transport-belt'] = true, ['construction-robot'] = true, ['character'] = true, ['gun-turret'] = true, ['laser-turret'] = true, ['flamethrower-turret'] = true, ['rail'] = true, ['rail-chain-signal'] = true, ['rail-signal'] = true, ['tile-ghost'] = true, ['entity-ghost'] = true, ['gate'] = true, ['electric-pole'] = true, ['small-electric-pole'] = true, ['medium-electric-pole'] = true, ['big-electric-pole'] = true, ['logistic-robot'] = true, ['defender'] = true, ['destroyer'] = true, ['distractor'] = true } Global.register( { players_warned = players_warned, entities_allowed_to_bomb = entities_allowed_to_bomb }, function(tbl) players_warned = tbl.players_warned entities_allowed_to_bomb = tbl.entities_allowed_to_bomb end ) local function is_trusted(player) return Rank.equal_or_greater_than(player.name, Ranks.auto_trusted) end local function ammo_changed(event) local player = game.get_player(event.player_index) if is_trusted(player) then return end local nukes = player.remove_item({name = 'atomic-bomb', count = 1000}) if nukes > 0 then Utils.action_warning('[Nuke]', player.name .. ' tried to use a nuke, but instead dropped it on his foot.') local character = player.character if character and character.valid then for _, p in ipairs(game.connected_players) do if p ~= player then p.add_custom_alert(character, {type = 'item', name = 'atomic-bomb'}, player.name, true) end end end player.character.health = 0 end end local function on_player_deconstructed_area(event) local player = game.get_player(event.player_index) if is_trusted(player) then return end player.remove_item({name = 'deconstruction-planner', count = 1000}) --Make them think they arent noticed Utils.silent_action_warning('[Deconstruct]', player.name .. ' tried to deconstruct something, but instead deconstructed themself.', player) player.print('Only regulars can mark things for deconstruction, if you want to deconstruct something you may ask an admin to promote you.') local character = player.character if character and character.valid then for _, p in ipairs(game.connected_players) do if p ~= player then p.add_custom_alert(character, {type = 'item', name = 'deconstruction-planner'}, player.name, true) end end end character.health = 0 local area = event.area local left_top, right_bottom = area.left_top, area.right_bottom if left_top.x == right_bottom.x and left_top.y == right_bottom.y then return end local entities = player.surface.find_entities_filtered {area = area, force = player.force} if #entities > 1000 then Utils.print_admins('Warning! ' .. player.name .. ' just tried to deconstruct ' .. tostring(#entities) .. ' entities!', nil) end for _, entity in pairs(entities) do if entity.valid and entity.to_be_deconstructed(game.get_player(event.player_index).force) then entity.cancel_deconstruction(game.get_player(event.player_index).force) end end end local function item_not_sanctioned(item) local name = item.name return (name:find('capsule') or name == 'cliff-explosives' or name == 'raw-fish' or name == 'discharge-defense-remote') end local function entity_allowed_to_bomb(entity) return entities_allowed_to_bomb[entity.name] end local function on_capsule_used(event) local item = event.item local player = game.get_player(event.player_index) if not player or not player.valid then return end if item.name == 'artillery-targeting-remote' then player.surface.create_entity { name = 'flying-text', text = player.name, color = player.color, position = event.position } end local nuke_control = global.config.nuke_control if not nuke_control.enable_autokick and not nuke_control.enable_autoban then return end if item_not_sanctioned(item) then return end if not is_trusted(player) then local area = {{event.position.x - 5, event.position.y - 5}, {event.position.x + 5, event.position.y + 5}} local count = 0 local entities = player.surface.find_entities_filtered {force = player.force, area = area} for _, e in pairs(entities) do if not entity_allowed_to_bomb(e) then count = count + 1 end end if count > 8 then if players_warned[event.player_index] then if nuke_control.enable_autoban then Server.ban_sync(player.name, format('Damaged %i entities with %s. This action was performed automatically. If you want to contest this ban please visit redmew.com/discord.', count, item.name), '