Compare commits
2 commits
16c31aa273
...
cd355bc9cd
Author | SHA1 | Date | |
---|---|---|---|
|
cd355bc9cd | ||
|
87f7212f43 |
9 changed files with 106 additions and 34 deletions
|
@ -22,7 +22,19 @@ minetest.register_craftitem("ctf_bandages:bandage", {
|
||||||
local hp = object:get_hp()
|
local hp = object:get_hp()
|
||||||
local limit = ctf_bandages.heal_percent * object:get_properties().hp_max
|
local limit = ctf_bandages.heal_percent * object:get_properties().hp_max
|
||||||
|
|
||||||
if hp > 0 and hp < limit then
|
if hp <= 0 then
|
||||||
|
hud_event.new(name, {
|
||||||
|
name = "ctf_bandages:dead",
|
||||||
|
color = "warning",
|
||||||
|
value = pname .. " is dead!",
|
||||||
|
})
|
||||||
|
elseif hp >= limit then
|
||||||
|
hud_event.new(name, {
|
||||||
|
name = "ctf_bandages:limit",
|
||||||
|
color = "warning",
|
||||||
|
value = pname .. " already has " .. limit .. " HP!",
|
||||||
|
})
|
||||||
|
else
|
||||||
local hp_add = math.random(3,4)
|
local hp_add = math.random(3,4)
|
||||||
|
|
||||||
kill_assist.add_heal_assist(pname, hp_add)
|
kill_assist.add_heal_assist(pname, hp_add)
|
||||||
|
@ -33,14 +45,18 @@ minetest.register_craftitem("ctf_bandages:bandage", {
|
||||||
end
|
end
|
||||||
|
|
||||||
object:set_hp(hp)
|
object:set_hp(hp)
|
||||||
minetest.chat_send_player(pname, minetest.colorize("#C1FF44", name .. " has healed you!"))
|
hud_event.new(pname, {
|
||||||
|
name = "ctf_bandages:heal",
|
||||||
return itemstack
|
color = 0xC1FF44,
|
||||||
else
|
value = name .. " healed you!",
|
||||||
minetest.chat_send_player(name, pname .. " has " .. hp .. " HP. You can't heal them.")
|
})
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, pname.." isn't in your team!")
|
hud_event.new(name, {
|
||||||
|
name = "ctf_bandages:team",
|
||||||
|
color = "warning",
|
||||||
|
value = pname .. " isn't in your team!",
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
@ -148,6 +148,15 @@ local function isdiggable(name)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function paxel_stop(pname, reason)
|
||||||
|
hud_event.new(pname, {
|
||||||
|
name = "ctf_classes:paxel_stop",
|
||||||
|
color = "success",
|
||||||
|
value = table.concat({"Pillar digging stopped", reason, "- wait " .. DIG_COOLDOWN .. "s"}, " "),
|
||||||
|
})
|
||||||
|
diggers[pname] = minetest.after(DIG_COOLDOWN, function() diggers[pname] = nil end)
|
||||||
|
end
|
||||||
|
|
||||||
local function remove_pillar(pos, pname)
|
local function remove_pillar(pos, pname)
|
||||||
local name = minetest.get_node(pos).name
|
local name = minetest.get_node(pos).name
|
||||||
|
|
||||||
|
@ -161,13 +170,11 @@ local function remove_pillar(pos, pname)
|
||||||
pos.y = pos.y + 1
|
pos.y = pos.y + 1
|
||||||
minetest.after(DIG_SPEED, remove_pillar, pos, pname)
|
minetest.after(DIG_SPEED, remove_pillar, pos, pname)
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(pname, "Pillar digging stopped, too far away from digging pos. Can activate again in "..DIG_COOLDOWN.." seconds")
|
paxel_stop(pname, "at too far away node")
|
||||||
diggers[pname] = minetest.after(DIG_COOLDOWN, function() diggers[pname] = nil end)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(pname, "Pillar digging stopped at undiggable node. Can activate again in "..DIG_COOLDOWN.." seconds")
|
paxel_stop(pname, "at undiggable node")
|
||||||
diggers[pname] = minetest.after(DIG_COOLDOWN, function() diggers[pname] = nil end)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -191,20 +198,39 @@ minetest.register_tool("ctf_classes:paxel_bronze", {
|
||||||
if pointed_thing.type == "node" then
|
if pointed_thing.type == "node" then
|
||||||
local pname = placer:get_player_name()
|
local pname = placer:get_player_name()
|
||||||
|
|
||||||
if not isdiggable(minetest.get_node(pointed_thing.under).name) or ctf_match.is_in_build_time() then
|
if not isdiggable(minetest.get_node(pointed_thing.under).name) then
|
||||||
minetest.chat_send_player(pname, "Can't dig node or build time active")
|
hud_event.new(pname, {
|
||||||
|
name = "ctf_classes:paxel_undiggable",
|
||||||
|
color = "warning",
|
||||||
|
value = "Can't paxel node!",
|
||||||
|
})
|
||||||
|
return minetest.item_place(itemstack, placer, pointed_thing)
|
||||||
|
end
|
||||||
|
if ctf_match.is_in_build_time() then
|
||||||
|
hud_event.new(pname, {
|
||||||
|
name = "ctf_classes:paxel_build_time",
|
||||||
|
color = "warning",
|
||||||
|
value = "Build time active!",
|
||||||
|
})
|
||||||
return minetest.item_place(itemstack, placer, pointed_thing)
|
return minetest.item_place(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not diggers[pname] then
|
if not diggers[pname] then
|
||||||
minetest.chat_send_player(pname, "Pillar digging started")
|
hud_event.new(pname, {
|
||||||
|
name = "ctf_classes:paxel_start",
|
||||||
|
color = "primary",
|
||||||
|
value = "Pillar digging started",
|
||||||
|
})
|
||||||
diggers[pname] = true
|
diggers[pname] = true
|
||||||
remove_pillar(pointed_thing.under, pname)
|
remove_pillar(pointed_thing.under, pname)
|
||||||
elseif type(diggers[pname]) ~= "table" then
|
elseif type(diggers[pname]) ~= "table" then
|
||||||
minetest.chat_send_player(pname, "Pillar digging stopped. Can activate again in "..DIG_COOLDOWN.." seconds")
|
paxel_stop(pname)
|
||||||
diggers[pname] = minetest.after(DIG_COOLDOWN, function() diggers[pname] = nil end)
|
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(pname, "You can't activate yet")
|
hud_event.new(pname, {
|
||||||
|
name = "ctf_classes:paxel_timer",
|
||||||
|
color = "warning",
|
||||||
|
value = "You can't activate yet!",
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -216,8 +242,7 @@ minetest.register_tool("ctf_classes:paxel_bronze", {
|
||||||
minetest.after(2, function()
|
minetest.after(2, function()
|
||||||
if user and user:get_player_control().RMB then
|
if user and user:get_player_control().RMB then
|
||||||
if diggers[pname] and type(diggers[pname]) ~= "table" then
|
if diggers[pname] and type(diggers[pname]) ~= "table" then
|
||||||
minetest.chat_send_player(pname, "Pillar digging stopped. Can activate again in "..DIG_COOLDOWN.." seconds")
|
paxel_stop(pname)
|
||||||
diggers[pname] = minetest.after(DIG_COOLDOWN, function() diggers[pname] = nil end)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -84,8 +84,11 @@ function minetest.is_protected(pos, name, ...)
|
||||||
|
|
||||||
local flag, distSQ = ctf_flag.get_nearest(pos)
|
local flag, distSQ = ctf_flag.get_nearest(pos)
|
||||||
if flag and pos.y >= flag.y - 1 and distSQ < rs then
|
if flag and pos.y >= flag.y - 1 and distSQ < rs then
|
||||||
minetest.chat_send_player(name,
|
hud_event.new(name, {
|
||||||
"Too close to the flag to build! Leave at least " .. r .. " blocks around the flag.")
|
name = "ctf_bandages:team",
|
||||||
|
color = "warning",
|
||||||
|
value = "Too close to the flag to build (< " .. r .. " nodes) !",
|
||||||
|
})
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return old_is_protected(pos, name, ...)
|
return old_is_protected(pos, name, ...)
|
||||||
|
|
|
@ -66,7 +66,11 @@ local old_can_attack = ctf.can_attack
|
||||||
function ctf.can_attack(player, hitter, ...)
|
function ctf.can_attack(player, hitter, ...)
|
||||||
if ctf_match.is_in_build_time() then
|
if ctf_match.is_in_build_time() then
|
||||||
if hitter:is_player() then
|
if hitter:is_player() then
|
||||||
minetest.chat_send_player(hitter:get_player_name(), "Match hasn't started yet!")
|
hud_event.new(hitter:get_player_name(), {
|
||||||
|
name = "ctf_match:buildtime_hit",
|
||||||
|
color = "warning",
|
||||||
|
value = "Match hasn't started yet!",
|
||||||
|
})
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,14 +44,20 @@ function ctf.can_attack(player, hitter, ...)
|
||||||
local hname = hitter:get_player_name()
|
local hname = hitter:get_player_name()
|
||||||
|
|
||||||
if ctf_respawn_immunity.is_immune(player) then
|
if ctf_respawn_immunity.is_immune(player) then
|
||||||
minetest.chat_send_player(hname, minetest.colorize("#EE8822", pname ..
|
hud_event.new(hname, {
|
||||||
" just respawned or joined," .. " and is immune to attacks!"))
|
name = "ctf_respawn_immunity:hit",
|
||||||
|
color = 0xEE8822,
|
||||||
|
value = pname .. " has respawn immunity!",
|
||||||
|
})
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if ctf_respawn_immunity.is_immune(hitter) then
|
if ctf_respawn_immunity.is_immune(hitter) then
|
||||||
minetest.chat_send_player(hname, minetest.colorize("#FF8C00",
|
hud_event.new(hname, {
|
||||||
"Your immunity has ended because you attacked a player"))
|
name = "ctf_respawn_immunity:end",
|
||||||
|
color = 0xFF8C00,
|
||||||
|
value = "Your immunity has ended!",
|
||||||
|
})
|
||||||
immune_players[hname] = nil
|
immune_players[hname] = nil
|
||||||
ctf_respawn_immunity.update_effects(hitter)
|
ctf_respawn_immunity.update_effects(hitter)
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,18 @@ local players = {}
|
||||||
local duration = 7
|
local duration = 7
|
||||||
local max = 3
|
local max = 3
|
||||||
local next_check = 10000000
|
local next_check = 10000000
|
||||||
|
-- Bootstrap 5 palette
|
||||||
|
local colors = {
|
||||||
|
primary = 0x0D6EFD,
|
||||||
|
secondary = 0x6C757D,
|
||||||
|
success = 0x198754,
|
||||||
|
info = 0x0DCAF0,
|
||||||
|
warning = 0xFFC107,
|
||||||
|
danger = 0xDC3545,
|
||||||
|
light = 0xF8F9FA,
|
||||||
|
dark = 0x212529,
|
||||||
|
}
|
||||||
|
hud_event.colors = colors
|
||||||
|
|
||||||
local function update(name)
|
local function update(name)
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
|
@ -52,6 +64,8 @@ function hud_event.new(name, def)
|
||||||
error("hud_event: Invalid HUD event element definition", 2)
|
error("hud_event: Invalid HUD event element definition", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def.color = colors[def.color] or def.color
|
||||||
|
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
if not player then
|
if not player then
|
||||||
return
|
return
|
||||||
|
|
|
@ -71,8 +71,11 @@ local function stop_healing(player, interrupted)
|
||||||
|
|
||||||
players[name] = nil
|
players[name] = nil
|
||||||
if interrupted then
|
if interrupted then
|
||||||
minetest.chat_send_player(name, minetest.colorize("#FF4444",
|
hud_event.new(name, {
|
||||||
"Your healing was interrupted"..reason_handler(interrupted)))
|
name = "medkits:interrupt",
|
||||||
|
color = 0xFF4444,
|
||||||
|
value = "Your healing was interrupted" .. reason_handler(interrupted),
|
||||||
|
})
|
||||||
player:set_hp(info.hp)
|
player:set_hp(info.hp)
|
||||||
player:get_inventory():add_item("main", ItemStack("medkits:medkit 1"))
|
player:get_inventory():add_item("main", ItemStack("medkits:medkit 1"))
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
local players = {}
|
local players = {}
|
||||||
local blocks_per_second = 5
|
local blocks_per_second = 5
|
||||||
local resend_notification_seconds = 10
|
local resend_notification_seconds = 10
|
||||||
-- Bootstrap 4 "warning" color
|
|
||||||
local warning_color = 0xFFC107
|
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
-- player has to wait after join before they can place a node
|
-- player has to wait after join before they can place a node
|
||||||
|
@ -22,7 +20,7 @@ minetest.register_on_placenode(function(pos, _newnode, placer, oldnode, _itemsta
|
||||||
-- This should happen rarely
|
-- This should happen rarely
|
||||||
hud_event.new(name, {
|
hud_event.new(name, {
|
||||||
name = "place_limit:unpointable",
|
name = "place_limit:unpointable",
|
||||||
color = warning_color,
|
color = "warning",
|
||||||
value = "Block not pointable (dug/replaced)!",
|
value = "Block not pointable (dug/replaced)!",
|
||||||
})
|
})
|
||||||
minetest.set_node(pos, oldnode)
|
minetest.set_node(pos, oldnode)
|
||||||
|
@ -39,7 +37,7 @@ minetest.register_on_placenode(function(pos, _newnode, placer, oldnode, _itemsta
|
||||||
if (time - placements.last_notification_sent) / 1e6 >= resend_notification_seconds then
|
if (time - placements.last_notification_sent) / 1e6 >= resend_notification_seconds then
|
||||||
hud_event.new(name, {
|
hud_event.new(name, {
|
||||||
name = "place_limit:speed",
|
name = "place_limit:speed",
|
||||||
color = warning_color,
|
color = "warning",
|
||||||
value = "Placing too fast!",
|
value = "Placing too fast!",
|
||||||
})
|
})
|
||||||
placements.last_notification_sent = time
|
placements.last_notification_sent = time
|
||||||
|
|
|
@ -163,8 +163,11 @@ function minetest.is_protected(pos, name, info, ...)
|
||||||
|
|
||||||
local flag, distSQ = ctf_flag.get_nearest(pos)
|
local flag, distSQ = ctf_flag.get_nearest(pos)
|
||||||
if flag and pos.y >= flag.y - 1 and distSQ < rs then
|
if flag and pos.y >= flag.y - 1 and distSQ < rs then
|
||||||
minetest.chat_send_player(name,
|
hud_event.new(name, {
|
||||||
"You can't shoot blocks within "..r.." nodes of a flag!")
|
name = "sniper_rifles:hit_base",
|
||||||
|
color = "warning",
|
||||||
|
value = "You can't shoot blocks within " .. r .. " nodes of a flag!",
|
||||||
|
})
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return old_is_protected(pos, name, info, ...)
|
return old_is_protected(pos, name, info, ...)
|
||||||
|
|
Loading…
Reference in a new issue