This commit is contained in:
philipmi 2021-02-21 18:21:41 +01:00
commit 55f833c68b
7 changed files with 28 additions and 67 deletions

View file

@ -99,6 +99,7 @@ minetest.override_item("ctf_bandages:bandage", {
if ctf.player(pname).team == ctf.player(name).team then
local nodename = minetest.get_node(object:get_pos()).name
if ctf_classes.dont_heal[pname] or nodename:find("lava") or nodename:find("water") or nodename:find("trap") then
minetest.chat_send_player(name, "You can't heal player in lava, water or spikes!")
return -- Can't heal players in lava/water/spikes
end
@ -153,11 +154,6 @@ local function remove_pillar(pos, pname)
if name:find("default") and isdiggable(name) then
local player = minetest.get_player_by_name(pname)
if minetest.get_modpath("antisabotage") then
-- Fix paxel being capable of mining blocks under teammates
if antisabotage.is_sabotage(pos, minetest.get_node(pos), player) then return end
end
minetest.dig_node(pos)
if player and diggers[pname] and type(diggers[pname]) ~= "table" then

View file

@ -2,23 +2,12 @@ if not minetest.create_metric then
return
end
local storage = minetest.get_mod_storage()
local function counter(name, help)
local metric = minetest.create_metric("counter", name, help)
metric:increment(tonumber(storage:get(name) or 0))
return {
get = function()
return metric:get()
end,
increment = function(_, value)
metric:increment(value)
storage:set_string(name, tostring(metric:get()))
end,
}
local function counter(...)
return minetest.create_metric("counter", ...)
end
local function gauge(name, help)
return minetest.create_metric("gauge", name, help)
local function gauge(...)
return minetest.create_metric("gauge", ...)
end
@ -54,15 +43,35 @@ minetest.register_on_placenode(function()
end)
--
-- Gauges
--
local class_gauges = {}
for _, class in ipairs(ctf_classes.__classes_ordered) do
class_gauges[class.name] = gauge("ctf_class_players", "Player count for class", {
class = class.name
})
end
local online_score = gauge("ctf_online_score", "Total score of online players")
local match_time = gauge("ctf_match_play_time", "Current time in match")
minetest.register_globalstep(function()
local sum = 0
local class_counts = {}
for _, player in pairs(minetest.get_connected_players()) do
local total, _ = ctf_stats.player(player:get_player_name())
sum = sum + total.score
end
online_score:set(sum)
local class = ctf_classes.get(player)
class_counts[class.name] = (class_counts[class.name] or 0) + 1
end
online_score:set(sum)
match_time:set(ctf_match.get_match_duration() or 0)
for _, class in ipairs(ctf_classes.__classes_ordered) do
class_gauges[class.name]:set(class_counts[class.name] or 0)
end
end)

View file

@ -1,2 +1,2 @@
name = ctf_metrics
depends = ctf, ctf_stats
depends = ctf, ctf_stats, ctf_classes

View file

@ -1,32 +0,0 @@
-- Code by Apelta. Mutelated by Lone_Wolf. Mutelated again by Apelta.
antisabotage = {}
function antisabotage.is_sabotage(pos, oldnode, digger) -- used for paxel
local dname = digger:get_player_name()
for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
if name ~= dname and ctf.players[name].team == ctf.players[dname].team then
local player_pos = player:get_pos()
if math.floor(player_pos.y) == pos.y and vector.distance(player_pos, pos) <= 1.5 then
minetest.set_node(pos, oldnode)
-- Remove all node drops
for _, item in pairs(minetest.get_node_drops(oldnode)) do
digger:get_inventory():remove_item("main", ItemStack(item))
end
minetest.chat_send_player(dname, "You can't mine blocks under your teammates!")
return true
end
end
end
end
minetest.register_on_dignode(function(pos, oldnode, digger)
if not digger:is_player() then return end
antisabotage.is_sabotage(pos, oldnode, digger)
end)

View file

@ -1,7 +0,0 @@
Copyright 2020 Apelta
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,2 +0,0 @@
name = antisabotage
depends = ctf

View file

@ -1,3 +0,0 @@
# Anti Sabotage
A simple mod that prevents players from sabotaging their teammates by digging blocks out from underneath them