Integrate death messages

This commit is contained in:
Lizzy Fleckenstein 2021-04-25 16:42:38 +02:00
parent 6aecae6eea
commit 302175691a
24 changed files with 247 additions and 316 deletions

View File

@ -14,13 +14,14 @@ mcl_damage = {
cactus = {}, cactus = {},
fall = {bypasses_armor = true}, fall = {bypasses_armor = true},
fly_into_wall = {bypasses_armor = true}, -- unused fly_into_wall = {bypasses_armor = true}, -- unused
out_of_world = {bypasses_armor = true, bypasses_invulnerability = true}, out_of_world = {bypasses_armor = true, bypasses_magic = true, bypasses_invulnerability = true},
generic = {bypasses_armor = true}, generic = {bypasses_armor = true},
magic = {is_magic = true, bypasses_armor = true}, magic = {is_magic = true, bypasses_armor = true},
dragon_breath = {is_magic = true, bypasses_armor = true}, -- this is only used for dragon fireball; dragon fireball does not actually deal impact damage tho, so this is unreachable
wither = {bypasses_armor = true}, -- unused wither = {bypasses_armor = true}, -- unused
wither_skull = {is_magic = true, is_explosion = true}, -- this is non-MC but a workaround to get the proper death message
anvil = {}, anvil = {},
falling_node = {}, -- unused falling_node = {}, -- this is falling_block in MC
dragon_breath = {bypasses_armor = true}, -- unused
mob = {}, mob = {},
player = {}, player = {},
arrow = {is_projectile = true}, arrow = {is_projectile = true},
@ -29,7 +30,6 @@ mcl_damage = {
explosion = {is_explosion = true}, explosion = {is_explosion = true},
cramming = {bypasses_armor = true}, -- unused cramming = {bypasses_armor = true}, -- unused
fireworks = {is_explosion = true}, -- unused fireworks = {is_explosion = true}, -- unused
command = {bypasses_armor = true, bypasses_invulnerability = true, bypasses_magic = true},
} }
} }

View File

@ -12,7 +12,6 @@ under the LGPLv2.1 license.
mcl_explosions = {} mcl_explosions = {}
local mod_death_messages = minetest.get_modpath("mcl_death_messages") ~= nil
local mod_fire = minetest.get_modpath("mcl_fire") ~= nil local mod_fire = minetest.get_modpath("mcl_fire") ~= nil
local CONTENT_FIRE = minetest.get_content_id("mcl_fire:fire") local CONTENT_FIRE = minetest.get_content_id("mcl_fire:fire")
@ -333,9 +332,6 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc
sleep_formspec_doesnt_close_mt53 = true sleep_formspec_doesnt_close_mt53 = true
end end
end end
if mod_death_messages then
mcl_death_messages.player_damage(obj, S("@1 was caught in an explosion.", name))
end
end end
if sleep_formspec_doesnt_close_mt53 then if sleep_formspec_doesnt_close_mt53 then

View File

@ -516,3 +516,22 @@ function mcl_util.get_inventory(object, create)
return inventory return inventory
end end
end end
function mcl_util.get_wielded_item(object)
if object:is_player() then
return object:get_wielded_item()
else
-- ToDo: implement getting wielditems from mobs as soon as mobs have wielditems
return ItemStack()
end
end
function mcl_util.get_object_name(object)
if object:is_player() then
return object:get_player_name()
else
local luaentity = object:get_luaentity()
return luaentity.nametag and luaentity.nametag ~= "" and luaentity.nametag or luaentity.description or luaentity.name
end
end

View File

@ -35,7 +35,7 @@ function mcl_burning.get_touching_nodes(obj, nodenames, storage)
return nodes return nodes
end end
function mcl_burning.set_on_fire(obj, burn_time, reason) function mcl_burning.set_on_fire(obj, burn_time)
if obj:get_hp() < 0 then if obj:get_hp() < 0 then
return return
end end
@ -79,7 +79,6 @@ function mcl_burning.set_on_fire(obj, burn_time, reason)
}) })
end end
storage.burn_time = burn_time storage.burn_time = burn_time
storage.burn_reason = reason
storage.fire_damage_timer = 0 storage.fire_damage_timer = 0
local fire_entity = minetest.add_entity(obj:get_pos(), "mcl_burning:fire") local fire_entity = minetest.add_entity(obj:get_pos(), "mcl_burning:fire")
@ -120,7 +119,6 @@ function mcl_burning.extinguish(obj)
mcl_burning.storage[obj] = {} mcl_burning.storage[obj] = {}
else else
storage.burn_time = nil storage.burn_time = nil
storage.burn_reason = nil
storage.fire_damage_timer = nil storage.fire_damage_timer = nil
end end
end end
@ -147,13 +145,6 @@ function mcl_burning.tick(obj, dtime, storage)
if obj:is_player() then if obj:is_player() then
if mcl_potions.player_has_effect(obj, "fire_proof") then if mcl_potions.player_has_effect(obj, "fire_proof") then
do_damage = false do_damage = false
else
local name = obj:get_player_name()
local deathmsg = S("@1 burned to death.", name)
if storage.reason then
deathmsg = S("@1 was burned by @2.", name, storage.reason)
end
mcl_death_messages.player_damage(obj, deathmsg)
end end
elseif obj:get_luaentity().fire_damage_resistant then elseif obj:get_luaentity().fire_damage_resistant then
do_damage = false do_damage = false

View File

@ -1,5 +1,4 @@
local S = minetest.get_translator("mcl_falling_nodes") local S = minetest.get_translator("mcl_falling_nodes")
local dmes = minetest.get_modpath("mcl_death_messages") ~= nil
local has_mcl_armor = minetest.get_modpath("mcl_armor") local has_mcl_armor = minetest.get_modpath("mcl_armor")
local get_falling_depth = function(self) local get_falling_depth = function(self)
@ -41,12 +40,9 @@ local deal_falling_damage = function(self, dtime)
end end
local deathmsg, dmg_type local deathmsg, dmg_type
if minetest.get_item_group(self.node.name, "anvil") ~= 0 then if minetest.get_item_group(self.node.name, "anvil") ~= 0 then
deathmsg, dmg_type = "@1 was smashed by a falling anvil.", "anvil" dmg_type = "anvil"
else else
deathmsg, dmg_type = "@1 was smashed by a falling block.", "falling_node" dmg_type = "falling_node"
end
if obj:is_player() then
mcl_death_messages.player_damage(obj, S(deathmsg, obj:get_player_name()))
end end
mcl_util.deal_damage(obj, damage, {type = dmg_type}) mcl_util.deal_damage(obj, damage, {type = dmg_type})
end end

View File

@ -151,7 +151,7 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
-- Direct hit, no fire... just plenty of pain -- Direct hit, no fire... just plenty of pain
hit_player = function(self, player) hit_player = function(self, player)
mcl_burning.set_on_fire(player, 5, "blaze") mcl_burning.set_on_fire(player, 5)
player:punch(self.object, 1.0, { player:punch(self.object, 1.0, {
full_punch_interval = 1.0, full_punch_interval = 1.0,
damage_groups = {fleshy = 5}, damage_groups = {fleshy = 5},

View File

@ -11,7 +11,6 @@ of the license, or (at your option) any later version.
local S = minetest.get_translator("lightning") local S = minetest.get_translator("lightning")
local has_mcl_death_msg = minetest.get_modpath("mcl_death_messages")
local get_connected_players = minetest.get_connected_players local get_connected_players = minetest.get_connected_players
local line_of_sight = minetest.line_of_sight local line_of_sight = minetest.line_of_sight
local get_node = minetest.get_node local get_node = minetest.get_node
@ -171,9 +170,6 @@ lightning.strike = function(pos)
obj:set_yaw(rot) obj:set_yaw(rot)
-- Other objects: Just damage -- Other objects: Just damage
else else
if obj:is_player() and has_mcl_death_msg then
mcl_death_messages.player_damage(obj, S("@1 was struck by lightning.", obj:get_player_name()))
end
mcl_util.deal_damage(obj, 5, {type = "lightning_bolt"}) mcl_util.deal_damage(obj, 5, {type = "lightning_bolt"})
end end
end end

View File

@ -2,5 +2,4 @@ name = lightning
author = sofar author = sofar
description = A mod that adds thunder and lightning effects. description = A mod that adds thunder and lightning effects.
depends = mcl_fire depends = mcl_fire
optional_depends = mcl_death_messages

View File

@ -5,7 +5,6 @@ local pos_to_dim = mcl_worlds.pos_to_dimension
local dim_change = mcl_worlds.dimension_change local dim_change = mcl_worlds.dimension_change
local is_in_void = mcl_worlds.is_in_void local is_in_void = mcl_worlds.is_in_void
local get_spawn_pos = mcl_spawn.get_player_spawn_pos local get_spawn_pos = mcl_spawn.get_player_spawn_pos
local death_msg = mcl_death_messages.player_damage
local send_chat = minetest.chat_send_player local send_chat = minetest.chat_send_player
local get_connected = minetest.get_connected_players local get_connected = minetest.get_connected_players
@ -79,7 +78,6 @@ minetest.register_globalstep(function(dtime)
elseif enable_damage and not is_immortal then elseif enable_damage and not is_immortal then
-- Damage enabled, not immortal: Deal void damage (4 HP / 0.5 seconds) -- Damage enabled, not immortal: Deal void damage (4 HP / 0.5 seconds)
if player:get_hp() > 0 then if player:get_hp() > 0 then
death_msg(player, S("@1 fell into the endless void.", player:get_player_name()))
mcl_util.deal_damage(player, VOID_DAMAGE, {type = "out_of_world"}) mcl_util.deal_damage(player, VOID_DAMAGE, {type = "out_of_world"})
end end
end end

View File

@ -1,4 +1,4 @@
name = mcl_void_damage name = mcl_void_damage
author = Wuzzy author = Wuzzy
description = Deal damage to entities stuck in the deep void description = Deal damage to entities stuck in the deep void
depends = mcl_worlds, mcl_death_messages depends = mcl_worlds

View File

@ -1,81 +1,157 @@
local S = minetest.get_translator("mcl_death_messages") local S = minetest.get_translator("mcl_death_messages")
local N = function(s) return s end
local C = minetest.colorize
local color_skyblue = mcl_colors.AQUA mcl_death_messages = {
messages = {
local function get_tool_name(item) in_fire = {
local name = item:get_meta():get_string("name") _translator = S,
if name ~= "" then plain = "@1 went up in flames",
return name escape = "@1 walked into fire whilst fighting @2",
end },
local def = item:get_definition() lightning_bolt = {
return def._tt_original_description or def.description _translator = S,
end plain = "@1 was struck by lightning",
escape = "@1 was struck by lightning whilst fighting @2",
mcl_death_messages = {} },
on_fire = {
-- Death messages _translator = S,
local msgs = { plain = "@1 burned to death",
["arrow"] = { escape = "@1 was burnt to a crisp whilst fighting @2",
N("@1 was fatally hit by an arrow."), },
N("@1 has been killed by an arrow."), lava = {
_translator = S,
plain = "@1 tried to swim in lava",
escape = "@1 tried to swim in lava to escape @2"
},
hot_floor = {
_translator = S,
plain = "@1 discovered the floor was lava",
escape = "@1 walked into danger zone due to @2",
},
in_wall = {
_translator = S,
plain = "@1 suffocated in a wall",
escape = "@1 suffocated in a wall whilst fighting @2",
},
drown = {
_translator = S,
plain = "@1 drowned",
escape = "@1 drowned whilst trying to escape @2",
},
starve = {
_translator = S,
plain = "@1 starved to death",
escape = "@1 starved to death whilst fighting @2",
},
cactus = {
_translator = S,
plain = "@1 was pricked to death",
escape = "@1 walked into a cactus whilst trying to escape @2",
},
fall = {
_translator = S,
plain = "@1 hit the ground too hard",
escape = "@1 hit the ground too hard whilst trying to escape @2",
-- "@1 fell from a high place" -- for fall distance > 5 blocks
-- "@1 fell while climbing"
-- "@1 fell off some twisting vines"
-- "@1 fell off some weeping vines"
-- "@1 fell off some vines"
-- "@1 fell off scaffolding"
-- "@1 fell off a ladder"
},
fly_into_wall = {
_translator = S,
plain = "@1 experienced kinetic energy",
escape = "@1 experienced kinetic energy whilst trying to escape @2",
},
out_of_world = {
_translator = S,
plain = "@1 fell out of the world",
escape = "@1 didn't want to live in the same world as @2",
},
generic = {
_translator = S,
plain = "@1 died",
escape = "@1 died because of @2",
},
magic = {
_translator = S,
plain = "@1 was killed by magic",
escape = "@1 was killed by magic whilst trying to escape @2",
killer = "@1 was killed by @2 using magic",
item = "@1 was killed by @2 using @3",
},
dragon_breath = {
_translator = S,
plain = "@1 was roasted in dragon breath",
killer = "@1 was roasted in dragon breath by @2",
},
wither = {
_translator = S,
plain = "@1 withered away",
escape = "@1 withered away whilst fighting @2",
},
wither_skull = {
_translator = S,
plain = "@1 was killed by magic",
killer = "@1 was shot by a skull from @2",
},
anvil = {
_translator = S,
plain = "@1 was squashed by a falling anvil",
escape = "@1 was squashed by a falling anvil whilst fighting @2",
},
falling_node = {
_translator = S,
plain = "@1 was squashed by a falling block",
escape = "@1 was squashed by a falling block whilst fighting @2",
},
mob = {
_translator = S,
killer = "@1 was slain by @2",
item = "@1 was slain by @2 using @3",
},
player = {
_translator = S,
killer = "@1 was slain by @2",
item = "@1 was slain by @2 using @3"
},
arrow = {
_translator = S,
killer = "@1 was shot by @2",
item = "@1 was shot by @2 using @3",
},
fireball = {
_translator = S,
killer = "@1 was fireballed by @2",
item = "@1 was fireballed by @2 using @3",
},
thorns = {
_translator = S,
killer = "@1 was killed trying to hurt @2",
item = "@1 was killed by @3 trying to hurt @2", -- yes, the order is intentional: @1 @3 @2
},
explosion = {
_translator = S,
plain = "@1 blew up",
killer = "@1 was blown up by @2",
item = "@1 was blown up by @2 using @3",
-- "@1 was killed by [Intentional Game Design]" -- for exploding bed in nether or end
},
cramming = {
_translator = S,
plain = "@1 was squished too much",
escape = "@1 was squashed by @2", -- surprisingly "escape" is actually the correct subtype
},
fireworks = {
_translator = S,
plain = "@1 went off with a bang",
item = "@1 went off with a bang due to a firework fired from @3 by @2", -- order is intentional
},
-- Missing snowballs: The Minecraft wiki mentions them but the MC source code does not.
}, },
["arrow_name"] = {
N("@1 was shot by @2 using [@3]"),
},
["arrow_skeleton"] = {
N("@1 was shot by Skeleton."),
},
["arrow_stray"] = {
N("@1 was shot by Stray."),
},
["arrow_illusioner"] = {
N("@1 was shot by Illusioner."),
},
["arrow_mob"] = {
N("@1 was shot."),
},
["drown"] = {
N("@1 forgot to breathe."),
N("@1 drowned."),
N("@1 ran out of oxygen."),
},
["murder"] = {
N("@1 was slain by @2 using [@3]"),
},
["murder_hand"] = {
N("@1 was slain by @2"),
},
["murder_any"] = {
N("@1 was killed."),
},
["mob_kill"] = {
N("@1 was slain by a mob."),
},
["blaze_fireball"] = {
N("@1 was burned to death by a Blaze's fireball."),
N("@1 was fireballed by a Blaze"),
},
["fire_charge"] = {
N("@1 was burned by a fire charge."),
},
["ghast_fireball"] = {
N("A Ghast scared @1 to death."),
N("@1 has been fireballed by a Ghast."),
},
["fall"] = {
N("@1 fell from a high cliff."),
N("@1 took fatal fall damage."),
N("@1 fell victim to gravity."),
N("@1 hit the ground too hard.")
},
["other"] = {
N("@1 died."),
}
} }
--[[
local mobkills = { local mobkills = {
["mobs_mc:zombie"] = N("@1 was slain by Zombie."), ["mobs_mc:zombie"] = N("@1 was slain by Zombie."),
["mobs_mc:baby_zombie"] = N("@1 was slain by Baby Zombie."), ["mobs_mc:baby_zombie"] = N("@1 was slain by Baby Zombie."),
@ -117,191 +193,74 @@ local mobkills = {
["mobs_mc:pigman"] = N("@1 was slain by Zombie Pigman."), ["mobs_mc:pigman"] = N("@1 was slain by Zombie Pigman."),
["mobs_mc:baby_pigman"] = N("@1 was slain by Baby Zombie Pigman."), ["mobs_mc:baby_pigman"] = N("@1 was slain by Baby Zombie Pigman."),
} }
]]--
-- Select death message local function get_item_killer_message(obj, messages, reason)
local dmsg = function(mtype, ...) if messages.item then
local r = math.random(1, #msgs[mtype]) local wielded = mcl_util.get_wielded_item(reason.source)
return S(msgs[mtype][r], ...) local itemname = wielded:get_meta():get_string("name")
end if itemname ~= "" then
itemname = "[" .. itemname .. "]"
-- Select death message for death by mob if mcl_enchanting.is_enchanted(wielded:get_name()) then
local mmsg = function(mtype, ...) itemname = minetest.colorize(mcl_colors.AQUA, itemname)
if mobkills[mtype] then end
return S(mobkills[mtype], ...) return messages._translator(messages.item, mcl_util.get_object_name(obj), mcl_util.get_object_name(reason.source), itemname)
else end
return dmsg("mob_kill", ...)
end end
end end
local last_damages = { } local function get_plain_killer_message(obj, messages, reason)
return messages.killer and messages._translator(messages.killer, mcl_util.get_object_name(obj), mcl_util.get_object_name(reason.source))
end
minetest.register_on_dieplayer(function(player, reason) local function get_killer_message(obj, messages, reason)
-- Death message return reason.source and (get_item_killer_message(obj, messages, reason) or get_plain_killer_message(obj, messages, reason))
local message = minetest.settings:get_bool("mcl_showDeathMessages") --Maybe cache the setting? end
if message == nil then
message = true local function get_escaped_message(obj, messages, reason)
return nil -- ToDo
end
local function get_plain_message(obj, messages, reason)
if messages.plain then
return messages._translator(messages.plain, mcl_util.get_object_name(obj))
end end
if message then end
local name = player:get_player_name()
if not name then
return
end
local msg
if last_damages[name] then
-- custom message
msg = last_damages[name].message
elseif reason.type == "node_damage" then
local pos = player:get_pos()
-- Check multiple nodes because players occupy multiple nodes
-- (we add one additional node because the check may fail if the player was
-- just barely touching the node with the head)
local posses = { pos, {x=pos.x,y=pos.y+1,z=pos.z}, {x=pos.x,y=pos.y+2,z=pos.z}}
local highest_damage = 0
local highest_damage_def = nil
-- Show message for node that dealt the most damage
for p=1, #posses do
local def = minetest.registered_nodes[minetest.get_node(posses[p]).name]
local dmg = def.damage_per_second
if dmg and dmg > highest_damage then
highest_damage = dmg
highest_damage_def = def
end
end
if highest_damage_def and highest_damage_def._mcl_node_death_message then
local field = highest_damage_def._mcl_node_death_message
local field_msg
if type(field) == "table" then
field_msg = field[math.random(1, #field)]
else
field_msg = field
end
local textdomain
if highest_damage_def.mod_origin then
textdomain = highest_damage_def.mod_origin
else
textdomain = "mcl_death_messages"
end
-- We assume the textdomain of the death message in the node definition
-- equals the modname.
msg = minetest.translate(textdomain, field_msg, name)
end
elseif reason.type == "drown" then
msg = dmsg("drown", name)
elseif reason.type == "punch" then
-- Punches
local hitter = reason.object
-- Player was slain by potions local function get_fallback_message(obj, messages, reason)
if not hitter then return end return "mcl_death_messages.messages." .. reason.type .. " " .. mcl_util.get_object_name(obj)
end
local hittername, hittertype, hittersubtype, shooter local function fallback_translator(s)
local hitter_toolname = get_tool_name(hitter:get_wielded_item()) return s
end
-- Custom message mcl_damage.register_on_death(function(obj, reason)
if last_damages[name] then if not minetest.settings:get_bool("mcl_showDeathMessages", true) then
msg = last_damages[name].message return
-- Unknown hitter end
elseif hitter == nil then
msg = dmsg("murder_any", name) local send_to
-- Player
elseif hitter:is_player() then if obj:is_player() then
hittername = hitter:get_player_name() send_to = true
if hittername ~= nil then end -- ToDo: add mob death messages for owned mobs, only send to owner (sent_to = "player name")
if hitter_toolname == "" then
msg = dmsg("murder_hand", name, hittername)
else if send_to then
msg = dmsg("murder", name, hittername, C(color_skyblue, hitter_toolname)) local messages = mcl_death_messages.messages[reason.type] or {}
end messages._translator = messages._translator or fallback_translator
else
msg = dmsg("murder_any", name) local message =
end get_killer_message(obj, messages, reason) or
-- Mob (according to Common Mob Interface) get_escaped_message(obj, messages, reason) or
elseif hitter:get_luaentity()._cmi_is_mob then get_plain_message(obj, messages, reason) or
if hitter:get_luaentity().nametag and hitter:get_luaentity().nametag ~= "" then get_fallback_message(obj, messages, reason)
hittername = hitter:get_luaentity().nametag
end if send_to == true then
hittersubtype = hitter:get_luaentity().name minetest.chat_send_all(message)
if hittername then else
msg = dmsg("murder_hand", name, hittername) minetest.chat_send_player(send_to, message)
elseif hittersubtype ~= nil and hittersubtype ~= "" then
msg = mmsg(hittersubtype, name)
else
msg = dmsg("murder_any", name)
end
-- Arrow
elseif hitter:get_luaentity().name == "mcl_bows:arrow_entity" or hitter:get_luaentity().name == "mobs_mc:arrow_entity" and not killed_by_potion then
local shooter
if hitter:get_luaentity()._shooter then
shooter = hitter:get_luaentity()._shooter
end
local is_mob = false
local s_ent = shooter and shooter:get_luaentity()
if shooter == nil then
msg = dmsg("arrow", name)
elseif shooter:is_player() then
msg = dmsg("arrow_name", name, shooter:get_player_name(), C(color_skyblue, get_tool_name(shooter:get_wielded_item())))
elseif s_ent and s_ent._cmi_is_mob then
if s_ent.nametag ~= "" then
msg = dmsg("arrow_name", name, shooter:get_player_name(), get_tool_name(shooter:get_wielded_item()))
elseif s_ent.name == "mobs_mc:skeleton" then
msg = dmsg("arrow_skeleton", name)
elseif s_ent.name == "mobs_mc:stray" then
msg = dmsg("arrow_stray", name)
elseif s_ent.name == "mobs_mc:illusioner" then
msg = dmsg("arrow_illusioner", name)
else
msg = dmsg("arrow_mob", name)
end
else
msg = dmsg("arrow", name)
end
-- Blaze fireball
elseif hitter:get_luaentity().name == "mobs_mc:blaze_fireball" then
if hitter:get_luaentity()._shot_from_dispenser then
msg = dmsg("fire_charge", name)
else
msg = dmsg("blaze_fireball", name)
end
-- Ghast fireball
elseif hitter:get_luaentity().name == "mobs_monster:fireball" then
msg = dmsg("ghast_fireball", name)
end
-- Falling
elseif reason.type == "fall" then
msg = dmsg("fall", name)
-- Other
elseif reason.type == "set_hp" then
if last_damages[name] then
msg = last_damages[name].message
end
end end
if not msg then
msg = dmsg("other", name)
end
minetest.chat_send_all(msg)
last_damages[name] = nil
end end
end) end)
-- dmg_sequence_number is used to discard old damage events
local dmg_sequence_number = 0
local start_damage_reset_countdown = function (player, sequence_number)
minetest.after(1, function(playername, sequence_number)
if last_damages[playername] and last_damages[playername].sequence_number == sequence_number then
last_damages[playername] = nil
end
end, player:get_player_name(), sequence_number)
end
-- Send a custom death mesage when damaging a player via set_hp or punch.
-- To be called directly BEFORE damaging a player via set_hp or punch.
-- The next time the player dies due to a set_hp, the message will be shown.
-- The player must die via set_hp within 0.1 seconds, otherwise the message will be discarded.
function mcl_death_messages.player_damage(player, message)
last_damages[player:get_player_name()] = { message = message, sequence_number = dmg_sequence_number }
start_damage_reset_countdown(player, dmg_sequence_number)
dmg_sequence_number = dmg_sequence_number + 1
if dmg_sequence_number >= 65535 then
dmg_sequence_number = 0
end
end

View File

@ -80,8 +80,8 @@ mcl_damage.register_modifier(function(obj, damage, reason)
local thorns_damage = thorns_damage_regular + thorns_damage_irregular local thorns_damage = thorns_damage_regular + thorns_damage_irregular
if thorns_damage > 0 and reason.source ~= obj then if thorns_damage > 0 and reason.type ~= "thorns" and reason.source ~= obj then
mcl_util.deal_damage(reason.source, {type = "thorns", direct = obj, source = reason.source}) mcl_util.deal_damage(reason.source, {type = "thorns", direct = obj})
local thorns_item = thorns_pieces[math.random(#thorns_pieces)] local thorns_item = thorns_pieces[math.random(#thorns_pieces)]
mcl_util.use_item_durability(thorns_item.itemstack, 2) mcl_util.use_item_durability(thorns_item.itemstack, 2)

View File

@ -132,7 +132,7 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch,
if wielditem then if wielditem then
local fire_aspect_level = mcl_enchanting.get_enchantment(wielditem, "fire_aspect") local fire_aspect_level = mcl_enchanting.get_enchantment(wielditem, "fire_aspect")
if fire_aspect_level > 0 then if fire_aspect_level > 0 then
mcl_burning.set_on_fire(player, fire_aspect_level * 4, hitter:get_player_name()) mcl_burning.set_on_fire(player, fire_aspect_level * 4)
end end
end end
end end

View File

@ -1,6 +1,5 @@
local S = minetest.get_translator("mcl_nether") local S = minetest.get_translator("mcl_nether")
local mod_death_messages = minetest.get_modpath("mcl_death_messages")
local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil
local on_rotate local on_rotate
if mod_screwdriver then if mod_screwdriver then
@ -111,9 +110,6 @@ minetest.register_node("mcl_nether:magma", {
end end
-- Hurt players standing on top of this block -- Hurt players standing on top of this block
if player:get_hp() > 0 then if player:get_hp() > 0 then
if mod_death_messages then
mcl_death_messages.player_damage(player, S("@1 stood too long on a magma block.", player:get_player_name()))
end
mcl_util.deal_damage(player, 1, {type = "hot_floor"}) mcl_util.deal_damage(player, 1, {type = "hot_floor"})
end end
end, end,

View File

@ -1,3 +1,3 @@
name = mcl_nether name = mcl_nether
depends = mcl_core, mcl_sounds, mcl_util, walkover, doc_items, mcl_colors depends = mcl_core, mcl_sounds, mcl_util, walkover, doc_items, mcl_colors
optional_depends = mcl_death_messages, doc, screwdriver optional_depends = doc, screwdriver

View File

@ -1,3 +1,3 @@
name = mcl_tnt name = mcl_tnt
depends = mcl_explosions, mcl_particles depends = mcl_explosions, mcl_particles
optional_depends = mcl_sounds, mcl_mobitems, mcl_death_messages, doc_identifier, mesecons optional_depends = mcl_sounds, mcl_mobitems, doc_identifier, mesecons

View File

@ -1,5 +1,4 @@
local S = minetest.get_translator("mcl_commands") local S = minetest.get_translator("mcl_commands")
local mod_death_messages = minetest.get_modpath("mcl_death_messages")
local function handle_kill_command(suspect, victim) local function handle_kill_command(suspect, victim)
if minetest.settings:get_bool("enable_damage") == false then if minetest.settings:get_bool("enable_damage") == false then
@ -21,17 +20,8 @@ local function handle_kill_command(suspect, victim)
if wield:get_name() == "mobs_mc:totem" then if wield:get_name() == "mobs_mc:totem" then
victimref:set_wielded_item("") victimref:set_wielded_item("")
end 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! -- DIE!
victimref:set_hp(0, {_mcl_type = "command"}) victimref:set_hp(0, {_mcl_type = "out_of_world"})
-- Log -- Log
if not suspect == victim then if not suspect == victim then
minetest.log("action", string.format("%s killed %s using /kill", suspect, victim)) minetest.log("action", string.format("%s killed %s using /kill", suspect, victim))

View File

@ -1,4 +1,3 @@
name = mcl_commands name = mcl_commands
author = Wuzzy author = Wuzzy
description = MCL2 commands description = MCL2 commands
optional_depends = mcl_death_messages

View File

@ -1,5 +1,4 @@
local S = minetest.get_translator("mcl_hunger") local S = minetest.get_translator("mcl_hunger")
local mod_death_messages = minetest.get_modpath("mcl_death_messages")
-- wrapper for minetest.item_eat (this way we make sure other mods can't break this one) -- wrapper for minetest.item_eat (this way we make sure other mods can't break this one)
minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing) minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing)

View File

@ -1,5 +1,4 @@
local S = minetest.get_translator("mcl_hunger") local S = minetest.get_translator("mcl_hunger")
local mod_death_messages = minetest.get_modpath("mcl_death_messages")
mcl_hunger = {} mcl_hunger = {}
@ -159,9 +158,6 @@ minetest.register_globalstep(function(dtime)
-- Damage hungry player down to 1 HP -- Damage hungry player down to 1 HP
-- TODO: Allow starvation at higher difficulty levels -- TODO: Allow starvation at higher difficulty levels
if hp-1 > 0 then if hp-1 > 0 then
if mod_death_messages then
mcl_death_messages.player_damage(player, S("@1 starved to death.", name))
end
mcl_util.deal_damage(player, 1, {type = "starve"}) mcl_util.deal_damage(player, 1, {type = "starve"})
end end
end end

View File

@ -2,4 +2,3 @@ name = mcl_hunger
author = BlockMen author = BlockMen
description = Adds a simple hunger meachanic with satiation, food poisoning and different healing. description = Adds a simple hunger meachanic with satiation, food poisoning and different healing.
depends = hudbars depends = hudbars
optional_depends = mcl_death_messages

View File

@ -1,4 +1,4 @@
name = mcl_playerinfo name = mcl_playerinfo
author = TenPlus1 author = TenPlus1
description = This is a helper mod for other mod to query the nodes around the player. description = This is a helper mod for other mod to query the nodes around the player.
depends = mcl_init, mcl_core, mcl_particles, mcl_death_messages depends = mcl_init, mcl_core, mcl_particles

View File

@ -391,7 +391,6 @@ minetest.register_globalstep(function(dtime)
-- Check privilege, too -- Check privilege, too
and (not check_player_privs(name, {noclip = true})) then and (not check_player_privs(name, {noclip = true})) then
if player:get_hp() > 0 then if player:get_hp() > 0 then
mcl_death_messages.player_damage(player, S("@1 suffocated to death.", name))
mcl_util.deal_damage(player, 1, {type = "in_wall"}) mcl_util.deal_damage(player, 1, {type = "in_wall"})
end end
end end
@ -407,7 +406,6 @@ minetest.register_globalstep(function(dtime)
local dist_feet = vector.distance({x=pos.x, y=pos.y-1, z=pos.z}, near) local dist_feet = vector.distance({x=pos.x, y=pos.y-1, z=pos.z}, near)
if dist < 1.1 or dist_feet < 1.1 then if dist < 1.1 or dist_feet < 1.1 then
if player:get_hp() > 0 then if player:get_hp() > 0 then
mcl_death_messages.player_damage(player, S("@1 was prickled to death by a cactus.", name))
mcl_util.deal_damage(player, 1, {type = "cactus"}) mcl_util.deal_damage(player, 1, {type = "cactus"})
end end
end end

View File

@ -1,5 +1,5 @@
name = mcl_playerplus name = mcl_playerplus
author = TenPlus1 author = TenPlus1
description = Adds some simple player-related gameplay effects: Hurt by touching a cactus, suffocation and more. description = Adds some simple player-related gameplay effects: Hurt by touching a cactus, suffocation and more.
depends = mcl_init, mcl_core, mcl_particles, mcl_hunger, mcl_death_messages, playerphysics, mcl_playerinfo, mcl_weather, mcl_spawn, mcl_enchanting, mcl_damage depends = mcl_init, mcl_core, mcl_particles, mcl_hunger, playerphysics, mcl_playerinfo, mcl_weather, mcl_spawn, mcl_enchanting, mcl_damage