Prevent medics from healing players damaged by drowning/lava (#695)
* Prevent medics from healing players damaged by drowning/lava * Fix oopsie Co-authored-by: David Leal <halfpacho@gmail.com> * Update medic.lua Co-authored-by: David Leal <halfpacho@gmail.com>
This commit is contained in:
parent
9c48ad2c7c
commit
cb131d1065
1 changed files with 20 additions and 2 deletions
|
@ -64,6 +64,21 @@ minetest.register_globalstep(function(delta)
|
||||||
regen_update()
|
regen_update()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local dont_heal = {}
|
||||||
|
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
|
||||||
|
if reason.type == "drown" or reason.type == "mode_damage" then
|
||||||
|
dont_heal[name] = true
|
||||||
|
elseif dont_heal[name] then
|
||||||
|
dont_heal[name] = nil
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
dont_heal[player:get_player_name()] = nil
|
||||||
|
end)
|
||||||
|
|
||||||
local bandage_on_use = minetest.registered_items["ctf_bandages:bandage"].on_use
|
local bandage_on_use = minetest.registered_items["ctf_bandages:bandage"].on_use
|
||||||
minetest.override_item("ctf_bandages:bandage", {
|
minetest.override_item("ctf_bandages:bandage", {
|
||||||
on_use = function(stack, user, pointed_thing)
|
on_use = function(stack, user, pointed_thing)
|
||||||
|
@ -79,8 +94,9 @@ minetest.override_item("ctf_bandages:bandage", {
|
||||||
local pname = object:get_player_name()
|
local pname = object:get_player_name()
|
||||||
local name = user:get_player_name()
|
local name = user:get_player_name()
|
||||||
if ctf.player(pname).team == ctf.player(name).team then
|
if ctf.player(pname).team == ctf.player(name).team then
|
||||||
if minetest.get_node(object:get_pos()).name:find("lava") then
|
local nodename = minetest.get_node(object:get_pos()).name
|
||||||
return -- Can't heal players in lava
|
if dont_heal[pname] or nodename:find("lava") or nodename:find("water") then
|
||||||
|
return -- Can't heal players in lava/water
|
||||||
end
|
end
|
||||||
|
|
||||||
local hp = object:get_hp()
|
local hp = object:get_hp()
|
||||||
|
@ -91,7 +107,9 @@ minetest.override_item("ctf_bandages:bandage", {
|
||||||
|
|
||||||
if main and match then
|
if main and match then
|
||||||
local reward = 3
|
local reward = 3
|
||||||
|
|
||||||
if ctf_flag.has_flag(pname) then reward = 6 end
|
if ctf_flag.has_flag(pname) then reward = 6 end
|
||||||
|
|
||||||
main.score = main.score + reward
|
main.score = main.score + reward
|
||||||
match.score = match.score + reward
|
match.score = match.score + reward
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue