1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-11-06 09:09:26 +02:00

Merge pull request #377 from Valansch/dev_diggy_antigrief

fixed report desyncs
This commit is contained in:
Lynn
2018-11-18 13:22:18 +01:00
committed by GitHub
4 changed files with 93 additions and 28 deletions

View File

@@ -518,12 +518,12 @@ local function jail_player(cmd)
return
end
-- Check if the target is valid
local target = cmd['parameter']
if target == nil then
local target_name = cmd['parameter']
if not target_name then
Game.player_print('Usage: /jail <player>')
return
end
local target = game.players[cmd['parameter']]
local target = game.players[target_name]
Report.jail(target, player)
end

View File

@@ -93,13 +93,12 @@ function Module.report(reporting_player, reported_player, message)
if reporting_player then
player_index = reporting_player.index
end
table.insert(global.reports, {reporting_player_index = reporting_player, reported_player_index = reported_player.index, message = message, tick = game.tick})
table.insert(global.reports, {reporting_player_index = player_index, reported_player_index = reported_player.index, message = message, tick = game.tick})
local notified = false
for _,p in pairs(game.players) do
if p.admin and p.connected then
p.play_sound{path='utility/tutorial_notice', volume_modifier = 1}
--p.print("Did you hear that too? " .. tostring(game.is_valid_sound_path('utility/wire_connect_pole'))) --Debugging the sound_path
Module.show_reports(p)
if p.afk_time < 3600 then notified = true end
end
@@ -164,7 +163,7 @@ function Module.jail(target_player, player)
end
if target_player.permission_group == permission_group then
print('The player ' .. target_player.name .. ' is already in jail.')
print('Player ' .. target_player.name .. ' is already in jail.')
return
end
@@ -188,7 +187,7 @@ function Module.jail(target_player, player)
-- Check that it worked
if target_player.permission_group == permission_group then
-- Let admin know it worked, let target know what's going on.
print(target .. ' has been jailed. They have been advised of this.')
print(target_player.name .. ' has been jailed. They have been advised of this.')
target_player.print(prefix)
target_player.print('You have been placed in jail by ' .. jailed_by .. '. The only action avaliable to you is chatting.')
target_player.print('Please respond to inquiries from the admins.', {r = 1, g = 1, b = 0, a = 1})

View File

@@ -18,7 +18,7 @@ local Config = {
-- initial starting position size, higher values are not recommended
starting_size = 8,
},
-- controls the Daylight (Default diggy: enabled = true)
NightTime = {
enabled = true, -- true = No Daylight, false = Day/night circle (Solar panels work)
@@ -168,15 +168,15 @@ local Config = {
{name = 'dirt', min = 0.39, max = 0.53},
},
},
-- responsible for resource spawning
ScatteredResources = {
enabled = true,
-- determines how distance is measured
distance = function (x, y) return math.abs(x) + math.abs(y) end,
distance = function (x, y) return math.abs(x) + math.abs(y) end,
--distance = function (x, y) return math.sqrt(x * x + y * y) end,
-- defines the weights of which resource_richness_value to spawn
resource_richness_weights = {
['scarce'] = 440,
@@ -196,51 +196,51 @@ local Config = {
['plenty'] = {1201, 2000},
['jackpot'] = {2001, 5000},
},
-- increases the amount of resources by flat multiplication to initial amount
-- highly suggested to use for fluids so their yield is reasonable
resource_type_scalar = {
['crude-oil'] = 1500,
['uranium-ore'] = 1.25,
},
-- ==============
-- Debug settings
-- ==============
-- shows the ore locations, only use when debugging (compound_cluster_mode)
display_ore_clusters = false,
-- =======================
-- Scattered mode settings
-- =======================
-- creates scattered ore (single tiles) at random locations
scattered_mode = false,
-- defines the increased chance of spawning resources
-- calculated_probability = resource_probability + ((distance / scattered_distance_probability_modifier) / 100)
-- this means the chance increases by 1% every DISTANCE tiles up to the max_probability
scattered_distance_probability_modifier = 10,
-- min percentage of chance that resources will spawn after mining
scattered_min_probability = 0.01,
-- max chance of spawning resources based on resource_probability + calculated scattered_distance_probability_modifier
scattered_max_probability = 0.10,
-- percentage of resource added to the sum. 100 tiles means
-- 10% more resources with a distance_richness_modifier of 10
-- 20% more resources with a distance_richness_modifier of 5
scattered_distance_richness_modifier = 7,
-- multiplies probability only if cluster mode is enabled
scattered_cluster_probability_multiplier = 0.5,
-- multiplies yield only if cluster mode is enabled
scattered_cluster_yield_multiplier = 1.7,
-- weights per resource of spawning
-- weights per resource of spawning
scattered_resource_weights = {
['coal'] = 160,
['copper-ore'] = 215,
@@ -259,18 +259,18 @@ local Config = {
['uranium-ore'] = 86,
['crude-oil'] = 57,
},
-- ==============================
-- Compound cluster mode settings
-- ==============================
-- creates compound clusters of ores defined by a layered ore-gen
cluster_mode = true,
-- location of file to find the cluster definition file
cluster_file_location = 'map_gen.Diggy.Orepattern.Tendrils',
--cluster_file_location = 'map_gen.Diggy.Orepattern.Clusters',
},
-- controls the alien spawning mechanic
@@ -353,6 +353,15 @@ local Config = {
start_stone = 50, -- Diggy default 50. This sets the price for the first level.
cost_precision = 2, -- Diggy default 2. This sets the precision of the stone requirements to level up. E.g. 1234 becomes 1200 with precision 2 and 1230 with precision 3.
},
--Tracks players causing collapses
Antigrief = {
enabled = true,
autojail = true,
allowed_collapses_first_hour = 4
}
},
}

View File

@@ -0,0 +1,57 @@
--[[-- info
Provides the ability to setup a player when first joined.
]]
-- dependencies
local Event = require 'utils.event'
local Global = require 'utils.global'
local CaveCollapse = require 'map_gen.Diggy.Feature.DiggyCaveCollapse'
local Game = require 'utils.game'
local Report = require 'features.report'
-- this
local Antigrief = {}
global.Antigrief = {
autojail = false,
jailed_players = {},
last_collapse = 0
}
local allowed_collapses_first_hour = 0
local player_collapses = {}
Global.register({
cave_collapse_disabled = cave_collapse_disabled
}, function(tbl)
cave_collapse_disabled = tbl.cave_collapse_disabled
end)
--[[--
Registers all event handlers.
]]
function Antigrief.register(config)
global.Antigrief.autojail = config.autojail
allowed_collapses_first_hour = config.allowed_collapses_first_hour
end
Event.add(CaveCollapse.events.on_collapse, function(event)
local player_index = event.player_index
if player_index and global.Antigrief.last_collapse ~= game.tick then
global.Antigrief.last_collapse = game.tick
local count = player_collapses[player_index] or 0
count = count + 1
player_collapses[player_index] = count
local player = Game.get_player_by_index(player_index)
if global.Antigrief.autojail and count > allowed_collapses_first_hour and player.online_time < 216000 and not global.Antigrief.jailed_players[player_index] then
Report.jail(player)
Report.report(nil, player, string.format("Caused %d collapses in the first hour", count))
global.Antigrief.jailed_players[player_index] = true
end
end
end)
return Antigrief