Fix up and re-add kill assists (#782)
* Add kill assists * Fix bug * Move to seperate mod * Fix bugs and improve code some more Co-authored-by: LoneWolfHT <lonewolf04361@gmail.com>
This commit is contained in:
parent
c9c2f6c7e0
commit
f8cb85be9f
11 changed files with 138 additions and 39 deletions
|
@ -1,7 +1,7 @@
|
|||
--Inspired from Andrey's bandages mod
|
||||
|
||||
ctf_bandages = {}
|
||||
ctf_bandages.heal_percent = 0.75 --Percentage of total HP to be healed
|
||||
ctf_bandages.heal_percent = 0.75 -- Percentage of total HP to be healed
|
||||
|
||||
minetest.register_craftitem("ctf_bandages:bandage", {
|
||||
description = "Bandage\n\n" ..
|
||||
|
@ -10,26 +10,31 @@ minetest.register_craftitem("ctf_bandages:bandage", {
|
|||
inventory_image = "ctf_bandages_bandage.png",
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, player, pointed_thing)
|
||||
if pointed_thing.type ~= "object" then
|
||||
return
|
||||
end
|
||||
if pointed_thing.type ~= "object" then return end
|
||||
|
||||
local object = pointed_thing.ref
|
||||
if not object:is_player() then
|
||||
return
|
||||
end
|
||||
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()
|
||||
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
|
||||
hp = hp + math.random(3,4)
|
||||
local hp_add = math.random(3,4)
|
||||
|
||||
kill_assist.add_heal_assist(pname, hp_add)
|
||||
hp = hp + hp_add
|
||||
|
||||
if hp > limit then
|
||||
hp = limit
|
||||
end
|
||||
|
||||
object:set_hp(hp)
|
||||
minetest.chat_send_player(pname, minetest.colorize("#C1FF44", name .. " has healed you!"))
|
||||
|
||||
return itemstack
|
||||
else
|
||||
minetest.chat_send_player(name, pname .. " has " .. hp .. " HP. You can't heal them.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue