More death messages, more reliable

This commit is contained in:
Wuzzy 2019-03-08 20:22:01 +01:00
parent db8d7af245
commit 20576431e1
12 changed files with 148 additions and 128 deletions

View file

@ -2,6 +2,8 @@ local minecraftaliases = true
local S = minetest.get_translator("mcl_commands")
local mod_death_messages = minetest.get_modpath("mcl_death_messages")
local function handle_kill_command(suspect, victim)
if minetest.settings:get_bool("enable_damage") == false then
return false, S("Players can't be killed right now, damage has been disabled.")
@ -16,17 +18,29 @@ local function handle_kill_command(suspect, victim)
return false, S("@1 is already dead", victim)
end
end
if not suspect == victim then
minetest.log("action", S("@1 killed @2", suspect, victim))
end
-- If player holds a totem of undying, destroy it before killing,
-- so it doesn't rescue the player.
local wield = victimref:get_wielded_item()
if wield:get_name() == "mobs_mc:totem" then
victimref:set_wielded_item("")
end
if mod_death_messages then
local msg
if suspect == victim then
msg = S("@1 committed suicide.", victim)
else
msg = S("@1 was killed by @2.", victim, suspect)
end
mcl_death_messages.player_damage(victimref, msg)
end
-- DIE!
victimref:set_hp(0)
-- Log
if not suspect == victim then
minetest.log("action", string.format("%s killed %s using /kill", suspect, victim))
else
minetest.log("action", string.format("%s committed suicide using /kill", victim))
end
return true
end