Add bandages

This commit is contained in:
MinetestSam 2019-01-26 13:09:30 +05:30 committed by rubenwardy
parent 82fb96c168
commit 3e57880520
7 changed files with 45 additions and 1 deletions

View file

@ -0,0 +1,2 @@
default
ctf

View file

@ -0,0 +1 @@
Adds a bandage which heals team-mates if they are below 15 HP. The bandages heal 3-4 HP until the player reaches 15 HP.

View file

@ -0,0 +1,35 @@
--Inspired from Andrey's bandages mod
local healing_limit = 15
minetest.register_craftitem("ctf_bandages:bandage", {
description = "Bandage, heals teammates for 3-4 HP until HP is equal to "..healing_limit,
inventory_image = "ctf_bandages_bandage.png",
on_use = function(itemstack, player, pointed_thing)
if pointed_thing.type ~= "object" then
return
end
local object = pointed_thing.ref
if not object:is_player() then
return
end
local pname = object:get_player_name()
local name = player:get_player_name()
if ctf.player(pname).team == ctf.player(name).team then
local hp = object:get_hp()
if hp > 0 and hp < healing_limit then
hp = hp + math.random(3,4)
if hp > healing_limit then
hp = healing_limit
end
object:set_hp(hp)
itemstack:take_item()
return itemstack
else
minetest.chat_send_player(name, pname .. " has " .. hp .. " HP. You can't heal them.")
end
else
minetest.chat_send_player(name, pname.." isn't in your team!")
end
end,
})

View file

@ -0,0 +1,3 @@
name = ctf_bandages
description = Adds a bandage which heals team-mates if they are below 15 HP. The bandages heal 3-4 HP until the player reaches 15 HP.
depends = default,ctf

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -22,4 +22,6 @@ function ctf_treasure.register_default_treasures()
treasurer.register_treasure("shooter:machine_gun",0.02,2,1) treasurer.register_treasure("shooter:machine_gun",0.02,2,1)
treasurer.register_treasure("shooter:ammo",0.3,2,{1,10}) treasurer.register_treasure("shooter:ammo",0.3,2,{1,10})
treasurer.register_treasure("shooter:arrow_white",0.5,2,{2,18}) treasurer.register_treasure("shooter:arrow_white",0.5,2,{2,18})
treasurer.register_treasure("ctf_bandages:bandage",0.3,5,{1,6})
end end

View file

@ -66,7 +66,8 @@ function random_messages.read_messages()
"Trapping team mates on purpose is strictly against the rules and you will be kicked immediately.", "Trapping team mates on purpose is strictly against the rules and you will be kicked immediately.",
"Help your team claim victory by storing extra weapons in the team chest, and never taking more than you need.", "Help your team claim victory by storing extra weapons in the team chest, and never taking more than you need.",
"Excessive spawn-killing is a direct violation of the rules - appropriate punishments will be given.", "Excessive spawn-killing is a direct violation of the rules - appropriate punishments will be given.",
"Use /r to check your score and rank, and /rankings to see the league tables." "Use /r to check your score and rank, and /rankings to see the league tables.",
"Use bandages on team-mates to heal them by 3-4 HP if their health is below 15 HP."
} }
end end