--antigrief things made by mewmew --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' local session = require 'utils.session_data' local Global = require 'utils.global' local Utils = require 'utils.core' local Color = require 'utils.color_presets' local Server = require 'utils.server' local Public = {} local match = string.match local capsule_bomb_threshold = 8 local format = string.format local this = { landfill_history = {}, capsule_history = {}, friendly_fire_history = {}, mining_history = {}, corpse_history = {}, cancel_crafting_history = {}, whitelist_types = {}, players_warned = {}, log_tree_harvest = false, do_not_check_trusted = true, protect_entities = true, enable_autokick = true, enable_autoban = false } local blacklisted_types = { ['transport-belt'] = true, ['wall'] = true, ['underground-belt'] = true, ['inserter'] = true, ['land-mine'] = true, ['gate'] = true, ['lamp'] = true, ['mining-drill'] = true, ['splitter'] = true } local ammo_names = { ['artillery-targeting-remote'] = true, ['poison-capsule'] = true, ['cluster-grenade'] = true, ['grenade'] = true, ['atomic-bomb'] = true, ['cliff-explosives'] = true, ['rocket'] = 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( this, function(t) this = t end ) local function increment(t, k, v) t[k][#t[k] + 1] = (v or 1) end local function get_entities(item_name, entities) local set = {} for i = 1, #entities do local e = entities[i] local name = e.name if name ~= item_name and name ~= 'entity-ghost' then local count = set[name] if count then set[name] = count + 1 else set[name] = 1 end end end local list = {} local i = 1 for k, v in pairs(set) do list[i] = v i = i + 1 list[i] = ' ' i = i + 1 list[i] = k i = i + 1 list[i] = ', ' i = i + 1 end list[i - 1] = nil return table.concat(list) end local function damage_player(player, kill) local msg = ' tried to destroy our base, but it backfired!' if player.character then if kill then player.character.die('enemy') game.print(player.name .. msg, Color.yellow) return end player.character.health = player.character.health - math.random(50, 100) player.character.surface.create_entity({name = 'water-splash', position = player.position}) local messages = { 'Ouch.. That hurt! Better be careful now.', 'Just a fleshwound.', 'Better keep those hands to yourself or you might loose them.' } player.print(messages[math.random(1, #messages)], Color.yellow) if player.character.health <= 0 then player.character.die('enemy') game.print(player.name .. msg, Color.yellow) return end end end local function on_marked_for_deconstruction(event) local tracker = session.get_session_table() local trusted = session.get_trusted_table() if not event.player_index then return end local player = game.players[event.player_index] if player.admin then return end if trusted[player.name] and this.do_not_check_trusted then return end local playtime = player.online_time if tracker[player.name] then playtime = player.online_time + tracker[player.name] end if playtime < 2592000 then event.entity.cancel_deconstruction(game.players[event.player_index].force.name) player.print('You have not grown accustomed to this technology yet.', {r = 0.22, g = 0.99, b = 0.99}) end end local function on_player_ammo_inventory_changed(event) local tracker = session.get_session_table() local trusted = session.get_trusted_table() local player = game.players[event.player_index] if player.admin then return end if trusted[player.name] and this.do_not_check_trusted then return end local playtime = player.online_time if tracker[player.name] then playtime = player.online_time + tracker[player.name] end if playtime < 1296000 then local nukes = player.remove_item({name = 'atomic-bomb', count = 1000}) if nukes > 0 then Utils.action_warning('{Nuke}', player.name .. ' tried to equip nukes but was not trusted.') damage_player(player) end end end local function on_player_joined_game(event) local player = game.players[event.player_index] if match(player.name, '^[Ili1|]+$') then Server.ban_sync(player.name, '', '