Add more death messages

This commit is contained in:
Wuzzy 2017-07-24 19:36:04 +02:00
parent 8970bd16ef
commit 95e8f80f2c
5 changed files with 9 additions and 23 deletions

@ -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)

@ -1,3 +1,4 @@
mcl_sounds
mcl_core
mcl_hunger
mcl_death_messages

@ -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

@ -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

@ -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