From 95e8f80f2cf50d0076f76492dd973544232b013a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 24 Jul 2017 19:36:04 +0200 Subject: [PATCH] Add more death messages --- mods/HUD/mcl_death_messages/init.lua | 21 +-------------------- mods/ITEMS/mcl_anvils/depends.txt | 1 + mods/ITEMS/mcl_anvils/falling_anvil.lua | 3 ++- mods/ITEMS/mcl_tnt/init.lua | 3 ++- mods/PLAYER/mcl_playerplus/init.lua | 4 +++- 5 files changed, 9 insertions(+), 23 deletions(-) diff --git a/mods/HUD/mcl_death_messages/init.lua b/mods/HUD/mcl_death_messages/init.lua index 65277a5e66..5959ad88c9 100644 --- a/mods/HUD/mcl_death_messages/init.lua +++ b/mods/HUD/mcl_death_messages/init.lua @@ -12,9 +12,6 @@ local msgs = { "%s died in the flames.", "%s died in a fire.", }, - ["explosion"] = { - "%s was caught in an explosion.", - }, ["lava"] = { "%s melted in lava.", "%s took a bath in a hot lava tub.", @@ -26,12 +23,6 @@ local msgs = { "%s drowned.", "%s ran out of oxygen.", }, - ["void"] = { - "%s fell into the endless void.", - }, - ["suffocation"] = { - "%s suffocated to death.", - }, ["starve"] = { "%s starved.", }, @@ -49,13 +40,6 @@ local msgs = { "A ghast scared %s to death.", "%s has been fireballed by a ghast.", }, - ["falling_anvil"] = { - "%s was smashed by a falling anvil!", - }, - ["falling_block"] = { - "%s was smashed by a falling block.", - "%s was buried under a falling block.", - }, ["fall_damage"] = { "%s fell from a high cliff.", "%s took fatal fall damage.", @@ -144,9 +128,6 @@ minetest.register_on_dieplayer(function(player) -- Fire elseif minetest.get_item_group(node.name, "fire") ~= 0 then msg = dmsg("fire", name) - -- Void - elseif node.name == "mcl_core:void" then - msg = dmsg("void", name) -- Other else -- Killed by entity @@ -227,7 +208,7 @@ minetest.register_on_punchplayer(function(player, hitter) start_damage_reset_countdown(player) end) --- To be called to notify this mod that a player has been damaged, with a custom death message if the player died +-- To be called BEFORE damaging a player. If the player died, then message will be used as the death message. function mcl_death_messages.player_damage(player, message) last_damages[player:get_player_name()] = { custom = true, message = message } start_damage_reset_countdown(player) diff --git a/mods/ITEMS/mcl_anvils/depends.txt b/mods/ITEMS/mcl_anvils/depends.txt index c7c5815f38..e2d61eb34a 100644 --- a/mods/ITEMS/mcl_anvils/depends.txt +++ b/mods/ITEMS/mcl_anvils/depends.txt @@ -1,3 +1,4 @@ mcl_sounds mcl_core mcl_hunger +mcl_death_messages diff --git a/mods/ITEMS/mcl_anvils/falling_anvil.lua b/mods/ITEMS/mcl_anvils/falling_anvil.lua index 95fca7ae48..5a31577941 100644 --- a/mods/ITEMS/mcl_anvils/falling_anvil.lua +++ b/mods/ITEMS/mcl_anvils/falling_anvil.lua @@ -35,10 +35,11 @@ local on_step_add = function(self, dtime) if hp < 0 then hp = 0 end - v:set_hp(hp) if v:is_player() then + mcl_death_messages.player_damage(v, string.format("%s was smashed by a falling anvil.", v:get_player_name())) mcl_hunger.exhaust(v:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) end + v:set_hp(hp) if hp == 0 then kill = true end diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index d444e8771b..b1eec4f493 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -24,7 +24,8 @@ local function do_tnt_physics(tnt_np,tntr) if v ~= nil then obj:setvelocity({x=(p.x - tnt_np.x) + (tntr / 4) + v.x, y=(p.y - tnt_np.y) + (tntr / 2) + v.y, z=(p.z - tnt_np.z) + (tntr / 4) + v.z}) else - if obj:is_player() ~= nil then + if obj:is_player() == true then + mcl_death_messages.player_damage(obj, string.format("%s was caught in an explosion.", obj:get_player_name())) obj:set_hp(obj:get_hp() - 1) mcl_hunger.exhaust(obj:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) end diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 4e7ee95467..4f03d2b0f6 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -156,6 +156,7 @@ minetest.register_globalstep(function(dtime) -- Check privilege, too and (not minetest.check_player_privs(name, {noclip = true})) then if player:get_hp() > 0 then + mcl_death_messages.player_damage(player, string.format("%s suffocated to death.", player:get_player_name())) player:set_hp(player:get_hp() - 1) end end @@ -168,7 +169,7 @@ minetest.register_globalstep(function(dtime) for _,object in pairs(minetest.get_objects_inside_radius(near, 1.1)) do if object:get_hp() > 0 then if object:is_player() then - mcl_death_messages.player_damage(object, string.format("%s was prickled by a cactus", object:get_player_name())) + mcl_death_messages.player_damage(object, string.format("%s was prickled by a cactus.", object:get_player_name())) mcl_hunger.exhaust(object:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) end object:set_hp(object:get_hp() - 1) @@ -189,6 +190,7 @@ minetest.register_globalstep(function(dtime) if void_deadly then -- Player is deep into the void, deal void damage if player:get_hp() > 0 then + mcl_death_messages.player_damage(player, string.format("%s fell into the endless void.", player:get_player_name())) player:set_hp(player:get_hp() - 4) end end