mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-30 23:03:45 +01:00
Integrate death messages
This commit is contained in:
parent
6aecae6eea
commit
302175691a
@ -14,13 +14,14 @@ mcl_damage = {
|
||||
cactus = {},
|
||||
fall = {bypasses_armor = true},
|
||||
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},
|
||||
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_skull = {is_magic = true, is_explosion = true}, -- this is non-MC but a workaround to get the proper death message
|
||||
anvil = {},
|
||||
falling_node = {}, -- unused
|
||||
dragon_breath = {bypasses_armor = true}, -- unused
|
||||
falling_node = {}, -- this is falling_block in MC
|
||||
mob = {},
|
||||
player = {},
|
||||
arrow = {is_projectile = true},
|
||||
@ -29,7 +30,6 @@ mcl_damage = {
|
||||
explosion = {is_explosion = true},
|
||||
cramming = {bypasses_armor = true}, -- unused
|
||||
fireworks = {is_explosion = true}, -- unused
|
||||
command = {bypasses_armor = true, bypasses_invulnerability = true, bypasses_magic = true},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ under the LGPLv2.1 license.
|
||||
|
||||
mcl_explosions = {}
|
||||
|
||||
local mod_death_messages = minetest.get_modpath("mcl_death_messages") ~= nil
|
||||
local mod_fire = minetest.get_modpath("mcl_fire") ~= nil
|
||||
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
|
||||
end
|
||||
end
|
||||
if mod_death_messages then
|
||||
mcl_death_messages.player_damage(obj, S("@1 was caught in an explosion.", name))
|
||||
end
|
||||
end
|
||||
|
||||
if sleep_formspec_doesnt_close_mt53 then
|
||||
|
@ -516,3 +516,22 @@ function mcl_util.get_inventory(object, create)
|
||||
return inventory
|
||||
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
|
||||
|
@ -35,7 +35,7 @@ function mcl_burning.get_touching_nodes(obj, nodenames, storage)
|
||||
return nodes
|
||||
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
|
||||
return
|
||||
end
|
||||
@ -52,7 +52,7 @@ function mcl_burning.set_on_fire(obj, burn_time, reason)
|
||||
else
|
||||
local max_fire_prot_lvl = 0
|
||||
local inv = mcl_util.get_inventory(obj)
|
||||
local armor_list = inv and inv:get_list("armor")
|
||||
local armor_list = inv and inv:get_list("armor")
|
||||
|
||||
if armor_list then
|
||||
for _, stack in pairs(armor_list) do
|
||||
@ -79,7 +79,6 @@ function mcl_burning.set_on_fire(obj, burn_time, reason)
|
||||
})
|
||||
end
|
||||
storage.burn_time = burn_time
|
||||
storage.burn_reason = reason
|
||||
storage.fire_damage_timer = 0
|
||||
|
||||
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] = {}
|
||||
else
|
||||
storage.burn_time = nil
|
||||
storage.burn_reason = nil
|
||||
storage.fire_damage_timer = nil
|
||||
end
|
||||
end
|
||||
@ -140,20 +138,13 @@ function mcl_burning.tick(obj, dtime, storage)
|
||||
storage.fire_damage_timer = 0
|
||||
|
||||
local hp = mcl_util.get_hp(obj)
|
||||
|
||||
|
||||
if hp > 0 then
|
||||
local do_damage = true
|
||||
|
||||
if obj:is_player() then
|
||||
if mcl_potions.player_has_effect(obj, "fire_proof") then
|
||||
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
|
||||
elseif obj:get_luaentity().fire_damage_resistant then
|
||||
do_damage = false
|
||||
|
@ -1,5 +1,4 @@
|
||||
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 get_falling_depth = function(self)
|
||||
@ -41,12 +40,9 @@ local deal_falling_damage = function(self, dtime)
|
||||
end
|
||||
local deathmsg, dmg_type
|
||||
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
|
||||
deathmsg, dmg_type = "@1 was smashed by a falling block.", "falling_node"
|
||||
end
|
||||
if obj:is_player() then
|
||||
mcl_death_messages.player_damage(obj, S(deathmsg, obj:get_player_name()))
|
||||
dmg_type = "falling_node"
|
||||
end
|
||||
mcl_util.deal_damage(obj, damage, {type = dmg_type})
|
||||
end
|
||||
|
@ -151,7 +151,7 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
|
||||
|
||||
-- Direct hit, no fire... just plenty of pain
|
||||
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, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = 5},
|
||||
|
@ -11,7 +11,6 @@ of the license, or (at your option) any later version.
|
||||
|
||||
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 line_of_sight = minetest.line_of_sight
|
||||
local get_node = minetest.get_node
|
||||
@ -171,9 +170,6 @@ lightning.strike = function(pos)
|
||||
obj:set_yaw(rot)
|
||||
-- Other objects: Just damage
|
||||
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"})
|
||||
end
|
||||
end
|
||||
|
@ -2,5 +2,4 @@ name = lightning
|
||||
author = sofar
|
||||
description = A mod that adds thunder and lightning effects.
|
||||
depends = mcl_fire
|
||||
optional_depends = mcl_death_messages
|
||||
|
||||
|
@ -5,7 +5,6 @@ local pos_to_dim = mcl_worlds.pos_to_dimension
|
||||
local dim_change = mcl_worlds.dimension_change
|
||||
local is_in_void = mcl_worlds.is_in_void
|
||||
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 get_connected = minetest.get_connected_players
|
||||
|
||||
@ -79,7 +78,6 @@ minetest.register_globalstep(function(dtime)
|
||||
elseif enable_damage and not is_immortal then
|
||||
-- Damage enabled, not immortal: Deal void damage (4 HP / 0.5 seconds)
|
||||
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"})
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
name = mcl_void_damage
|
||||
author = Wuzzy
|
||||
description = Deal damage to entities stuck in the deep void
|
||||
depends = mcl_worlds, mcl_death_messages
|
||||
depends = mcl_worlds
|
||||
|
@ -1,81 +1,157 @@
|
||||
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
|
||||
|
||||
local function get_tool_name(item)
|
||||
local name = item:get_meta():get_string("name")
|
||||
if name ~= "" then
|
||||
return name
|
||||
end
|
||||
local def = item:get_definition()
|
||||
return def._tt_original_description or def.description
|
||||
end
|
||||
|
||||
mcl_death_messages = {}
|
||||
|
||||
-- Death messages
|
||||
local msgs = {
|
||||
["arrow"] = {
|
||||
N("@1 was fatally hit by an arrow."),
|
||||
N("@1 has been killed by an arrow."),
|
||||
mcl_death_messages = {
|
||||
messages = {
|
||||
in_fire = {
|
||||
_translator = S,
|
||||
plain = "@1 went up in flames",
|
||||
escape = "@1 walked into fire whilst fighting @2",
|
||||
},
|
||||
lightning_bolt = {
|
||||
_translator = S,
|
||||
plain = "@1 was struck by lightning",
|
||||
escape = "@1 was struck by lightning whilst fighting @2",
|
||||
},
|
||||
on_fire = {
|
||||
_translator = S,
|
||||
plain = "@1 burned to death",
|
||||
escape = "@1 was burnt to a crisp whilst fighting @2",
|
||||
},
|
||||
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 = {
|
||||
["mobs_mc:zombie"] = N("@1 was slain by 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:baby_pigman"] = N("@1 was slain by Baby Zombie Pigman."),
|
||||
}
|
||||
]]--
|
||||
|
||||
-- Select death message
|
||||
local dmsg = function(mtype, ...)
|
||||
local r = math.random(1, #msgs[mtype])
|
||||
return S(msgs[mtype][r], ...)
|
||||
end
|
||||
|
||||
-- Select death message for death by mob
|
||||
local mmsg = function(mtype, ...)
|
||||
if mobkills[mtype] then
|
||||
return S(mobkills[mtype], ...)
|
||||
else
|
||||
return dmsg("mob_kill", ...)
|
||||
local function get_item_killer_message(obj, messages, reason)
|
||||
if messages.item then
|
||||
local wielded = mcl_util.get_wielded_item(reason.source)
|
||||
local itemname = wielded:get_meta():get_string("name")
|
||||
if itemname ~= "" then
|
||||
itemname = "[" .. itemname .. "]"
|
||||
if mcl_enchanting.is_enchanted(wielded:get_name()) then
|
||||
itemname = minetest.colorize(mcl_colors.AQUA, itemname)
|
||||
end
|
||||
return messages._translator(messages.item, mcl_util.get_object_name(obj), mcl_util.get_object_name(reason.source), itemname)
|
||||
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)
|
||||
-- Death message
|
||||
local message = minetest.settings:get_bool("mcl_showDeathMessages") --Maybe cache the setting?
|
||||
if message == nil then
|
||||
message = true
|
||||
local function get_killer_message(obj, messages, reason)
|
||||
return reason.source and (get_item_killer_message(obj, messages, reason) or get_plain_killer_message(obj, messages, reason))
|
||||
end
|
||||
|
||||
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
|
||||
if message then
|
||||
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
|
||||
end
|
||||
|
||||
-- Player was slain by potions
|
||||
if not hitter then return end
|
||||
local function get_fallback_message(obj, messages, reason)
|
||||
return "mcl_death_messages.messages." .. reason.type .. " " .. mcl_util.get_object_name(obj)
|
||||
end
|
||||
|
||||
local hittername, hittertype, hittersubtype, shooter
|
||||
local hitter_toolname = get_tool_name(hitter:get_wielded_item())
|
||||
local function fallback_translator(s)
|
||||
return s
|
||||
end
|
||||
|
||||
-- Custom message
|
||||
if last_damages[name] then
|
||||
msg = last_damages[name].message
|
||||
-- Unknown hitter
|
||||
elseif hitter == nil then
|
||||
msg = dmsg("murder_any", name)
|
||||
-- Player
|
||||
elseif hitter:is_player() then
|
||||
hittername = hitter:get_player_name()
|
||||
if hittername ~= nil then
|
||||
if hitter_toolname == "" then
|
||||
msg = dmsg("murder_hand", name, hittername)
|
||||
else
|
||||
msg = dmsg("murder", name, hittername, C(color_skyblue, hitter_toolname))
|
||||
end
|
||||
else
|
||||
msg = dmsg("murder_any", name)
|
||||
end
|
||||
-- Mob (according to Common Mob Interface)
|
||||
elseif hitter:get_luaentity()._cmi_is_mob then
|
||||
if hitter:get_luaentity().nametag and hitter:get_luaentity().nametag ~= "" then
|
||||
hittername = hitter:get_luaentity().nametag
|
||||
end
|
||||
hittersubtype = hitter:get_luaentity().name
|
||||
if hittername then
|
||||
msg = dmsg("murder_hand", name, hittername)
|
||||
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
|
||||
mcl_damage.register_on_death(function(obj, reason)
|
||||
if not minetest.settings:get_bool("mcl_showDeathMessages", true) then
|
||||
return
|
||||
end
|
||||
|
||||
local send_to
|
||||
|
||||
if obj:is_player() then
|
||||
send_to = true
|
||||
end -- ToDo: add mob death messages for owned mobs, only send to owner (sent_to = "player name")
|
||||
|
||||
|
||||
if send_to then
|
||||
local messages = mcl_death_messages.messages[reason.type] or {}
|
||||
messages._translator = messages._translator or fallback_translator
|
||||
|
||||
local message =
|
||||
get_killer_message(obj, messages, reason) or
|
||||
get_escaped_message(obj, messages, reason) or
|
||||
get_plain_message(obj, messages, reason) or
|
||||
get_fallback_message(obj, messages, reason)
|
||||
|
||||
if send_to == true then
|
||||
minetest.chat_send_all(message)
|
||||
else
|
||||
minetest.chat_send_player(send_to, message)
|
||||
end
|
||||
if not msg then
|
||||
msg = dmsg("other", name)
|
||||
end
|
||||
minetest.chat_send_all(msg)
|
||||
last_damages[name] = nil
|
||||
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
|
||||
|
@ -80,8 +80,8 @@ mcl_damage.register_modifier(function(obj, damage, reason)
|
||||
|
||||
local thorns_damage = thorns_damage_regular + thorns_damage_irregular
|
||||
|
||||
if thorns_damage > 0 and reason.source ~= obj then
|
||||
mcl_util.deal_damage(reason.source, {type = "thorns", direct = obj, source = reason.source})
|
||||
if thorns_damage > 0 and reason.type ~= "thorns" and reason.source ~= obj then
|
||||
mcl_util.deal_damage(reason.source, {type = "thorns", direct = obj})
|
||||
|
||||
local thorns_item = thorns_pieces[math.random(#thorns_pieces)]
|
||||
mcl_util.use_item_durability(thorns_item.itemstack, 2)
|
||||
|
@ -132,7 +132,7 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch,
|
||||
if wielditem then
|
||||
local fire_aspect_level = mcl_enchanting.get_enchantment(wielditem, "fire_aspect")
|
||||
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
|
||||
|
@ -1,6 +1,5 @@
|
||||
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 on_rotate
|
||||
if mod_screwdriver then
|
||||
@ -111,9 +110,6 @@ minetest.register_node("mcl_nether:magma", {
|
||||
end
|
||||
-- Hurt players standing on top of this block
|
||||
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"})
|
||||
end
|
||||
end,
|
||||
|
@ -1,3 +1,3 @@
|
||||
name = mcl_nether
|
||||
depends = mcl_core, mcl_sounds, mcl_util, walkover, doc_items, mcl_colors
|
||||
optional_depends = mcl_death_messages, doc, screwdriver
|
||||
optional_depends = doc, screwdriver
|
||||
|
@ -1,3 +1,3 @@
|
||||
name = mcl_tnt
|
||||
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
|
||||
|
@ -1,5 +1,4 @@
|
||||
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
|
||||
@ -21,17 +20,8 @@ local function handle_kill_command(suspect, victim)
|
||||
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, {_mcl_type = "command"})
|
||||
victimref:set_hp(0, {_mcl_type = "out_of_world"})
|
||||
-- Log
|
||||
if not suspect == victim then
|
||||
minetest.log("action", string.format("%s killed %s using /kill", suspect, victim))
|
||||
|
@ -1,4 +1,3 @@
|
||||
name = mcl_commands
|
||||
author = Wuzzy
|
||||
description = MCL2 commands
|
||||
optional_depends = mcl_death_messages
|
||||
|
@ -1,5 +1,4 @@
|
||||
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)
|
||||
minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing)
|
||||
|
@ -1,5 +1,4 @@
|
||||
local S = minetest.get_translator("mcl_hunger")
|
||||
local mod_death_messages = minetest.get_modpath("mcl_death_messages")
|
||||
|
||||
mcl_hunger = {}
|
||||
|
||||
@ -159,9 +158,6 @@ minetest.register_globalstep(function(dtime)
|
||||
-- Damage hungry player down to 1 HP
|
||||
-- TODO: Allow starvation at higher difficulty levels
|
||||
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"})
|
||||
end
|
||||
end
|
||||
|
@ -2,4 +2,3 @@ name = mcl_hunger
|
||||
author = BlockMen
|
||||
description = Adds a simple hunger meachanic with satiation, food poisoning and different healing.
|
||||
depends = hudbars
|
||||
optional_depends = mcl_death_messages
|
||||
|
@ -1,4 +1,4 @@
|
||||
name = mcl_playerinfo
|
||||
author = TenPlus1
|
||||
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
|
||||
|
@ -391,7 +391,6 @@ minetest.register_globalstep(function(dtime)
|
||||
-- Check privilege, too
|
||||
and (not check_player_privs(name, {noclip = true})) 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"})
|
||||
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)
|
||||
if dist < 1.1 or dist_feet < 1.1 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"})
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
name = mcl_playerplus
|
||||
author = TenPlus1
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user