mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 13:53:45 +01:00
Generalize node damage death message
This commit is contained in:
parent
20576431e1
commit
049c632276
@ -11,18 +11,6 @@ local msgs = {
|
|||||||
["arrow_name"] = {
|
["arrow_name"] = {
|
||||||
S("%s was shot by an arrow from %s."),
|
S("%s was shot by an arrow from %s."),
|
||||||
},
|
},
|
||||||
["fire"] = {
|
|
||||||
S("%s has been cooked crisp."),
|
|
||||||
S("%s felt the burn."),
|
|
||||||
S("%s died in the flames."),
|
|
||||||
S("%s died in a fire."),
|
|
||||||
},
|
|
||||||
["lava"] = {
|
|
||||||
S("%s melted in lava."),
|
|
||||||
S("%s took a bath in a hot lava tub."),
|
|
||||||
S("%s died in lava."),
|
|
||||||
S("%s could not survive in lava."),
|
|
||||||
},
|
|
||||||
["drown"] = {
|
["drown"] = {
|
||||||
S("%s forgot to breathe."),
|
S("%s forgot to breathe."),
|
||||||
S("%s drowned."),
|
S("%s drowned."),
|
||||||
@ -132,18 +120,27 @@ minetest.register_on_dieplayer(function(player, reason)
|
|||||||
-- (we add one additional node because the check may fail if the player was
|
-- (we add one additional node because the check may fail if the player was
|
||||||
-- just barely touching the node with the head)
|
-- 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 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
|
for p=1, #posses do
|
||||||
local node = minetest.registered_nodes[minetest.get_node(posses[p]).name]
|
local def = minetest.registered_nodes[minetest.get_node(posses[p]).name]
|
||||||
-- Lava
|
local dmg = def.damage_per_second
|
||||||
if minetest.get_item_group(node.name, "lava") ~= 0 then
|
if dmg and dmg > highest_damage then
|
||||||
msg = dmsg("lava", name)
|
highest_damage = dmg
|
||||||
break
|
highest_damage_def = def
|
||||||
-- Fire
|
|
||||||
elseif minetest.get_item_group(node.name, "fire") ~= 0 then
|
|
||||||
msg = dmsg("fire", name)
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
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
|
||||||
|
msg = string.format(field_msg, name)
|
||||||
|
end
|
||||||
elseif reason.type == "drown" then
|
elseif reason.type == "drown" then
|
||||||
msg = dmsg("drown", name)
|
msg = dmsg("drown", name)
|
||||||
elseif reason.type == "punch" then
|
elseif reason.type == "punch" then
|
||||||
@ -235,3 +232,4 @@ function mcl_death_messages.player_damage(player, message)
|
|||||||
last_damages[player:get_player_name()] = { custom = true, message = message }
|
last_damages[player:get_player_name()] = { custom = true, message = message }
|
||||||
start_damage_reset_countdown(player)
|
start_damage_reset_countdown(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,6 +6,13 @@ local WATER_ALPHA = 179
|
|||||||
local WATER_VISC = 1
|
local WATER_VISC = 1
|
||||||
local LAVA_VISC = 7
|
local LAVA_VISC = 7
|
||||||
|
|
||||||
|
local lava_death_messages = {
|
||||||
|
S("%s melted in lava."),
|
||||||
|
S("%s took a bath in a hot lava tub."),
|
||||||
|
S("%s died in lava."),
|
||||||
|
S("%s could not survive in lava."),
|
||||||
|
}
|
||||||
|
|
||||||
minetest.register_node("mcl_core:water_flowing", {
|
minetest.register_node("mcl_core:water_flowing", {
|
||||||
description = S("Flowing Water"),
|
description = S("Flowing Water"),
|
||||||
_doc_items_create_entry = false,
|
_doc_items_create_entry = false,
|
||||||
@ -129,6 +136,7 @@ minetest.register_node("mcl_core:lava_flowing", {
|
|||||||
liquid_renewable = false,
|
liquid_renewable = false,
|
||||||
liquid_range = 3,
|
liquid_range = 3,
|
||||||
damage_per_second = 4*2,
|
damage_per_second = 4*2,
|
||||||
|
_mcl_node_death_message = lava_death_messages,
|
||||||
post_effect_color = {a=255, r=208, g=73, b=10},
|
post_effect_color = {a=255, r=208, g=73, b=10},
|
||||||
groups = { lava=3, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1},
|
groups = { lava=3, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1},
|
||||||
_mcl_blast_resistance = 500,
|
_mcl_blast_resistance = 500,
|
||||||
@ -175,6 +183,7 @@ S([[Lava interacts with water various ways:
|
|||||||
liquid_renewable = false,
|
liquid_renewable = false,
|
||||||
liquid_range = 3,
|
liquid_range = 3,
|
||||||
damage_per_second = 4*2,
|
damage_per_second = 4*2,
|
||||||
|
_mcl_node_death_message = lava_death_messages,
|
||||||
post_effect_color = {a=255, r=208, g=73, b=10},
|
post_effect_color = {a=255, r=208, g=73, b=10},
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
groups = { lava=3, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1},
|
groups = { lava=3, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1},
|
||||||
|
@ -12,6 +12,12 @@ local S = minetest.get_translator("mcl_fire")
|
|||||||
|
|
||||||
local fire_help = S("Fire is a damaging and destructive but short-lived kind of block. It will destroy and spread towards near flammable blocks, but fire will disappear when there is nothing to burn left. It will be extinguished by nearby water and rain. Fire can be destroyed safely by punching it, but it is hurtful if you stand directly in it. If a fire is started above netherrack or a magma block, it will immediately turn into an eternal fire.")
|
local fire_help = S("Fire is a damaging and destructive but short-lived kind of block. It will destroy and spread towards near flammable blocks, but fire will disappear when there is nothing to burn left. It will be extinguished by nearby water and rain. Fire can be destroyed safely by punching it, but it is hurtful if you stand directly in it. If a fire is started above netherrack or a magma block, it will immediately turn into an eternal fire.")
|
||||||
local eternal_fire_help = S("Eternal fire is a damaging and destructive block. It will create fire around it when flammable blocks are nearby. Eternal fire can be extinguished by punches and nearby water blocks. Other than (normal) fire, eternal fire does not get extinguished on its own and also continues to burn under rain. Punching eternal fire is safe, but it hurts if you stand inside.")
|
local eternal_fire_help = S("Eternal fire is a damaging and destructive block. It will create fire around it when flammable blocks are nearby. Eternal fire can be extinguished by punches and nearby water blocks. Other than (normal) fire, eternal fire does not get extinguished on its own and also continues to burn under rain. Punching eternal fire is safe, but it hurts if you stand inside.")
|
||||||
|
local fire_death_messages = {
|
||||||
|
S("%s has been cooked crisp."),
|
||||||
|
S("%s felt the burn."),
|
||||||
|
S("%s died in the flames."),
|
||||||
|
S("%s died in a fire."),
|
||||||
|
}
|
||||||
|
|
||||||
minetest.register_node("mcl_fire:fire", {
|
minetest.register_node("mcl_fire:fire", {
|
||||||
description = S("Fire"),
|
description = S("Fire"),
|
||||||
@ -36,6 +42,7 @@ minetest.register_node("mcl_fire:fire", {
|
|||||||
buildable_to = true,
|
buildable_to = true,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
damage_per_second = 1,
|
damage_per_second = 1,
|
||||||
|
_mcl_node_death_message = fire_death_messages,
|
||||||
groups = {fire = 1, dig_immediate = 3, not_in_creative_inventory = 1, dig_by_piston=1, destroys_items=1 },
|
groups = {fire = 1, dig_immediate = 3, not_in_creative_inventory = 1, dig_by_piston=1, destroys_items=1 },
|
||||||
floodable = true,
|
floodable = true,
|
||||||
on_flood = function(pos, oldnode, newnode)
|
on_flood = function(pos, oldnode, newnode)
|
||||||
@ -115,6 +122,7 @@ minetest.register_node("mcl_fire:eternal_fire", {
|
|||||||
buildable_to = true,
|
buildable_to = true,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
damage_per_second = 1,
|
damage_per_second = 1,
|
||||||
|
_mcl_node_death_message = fire_death_messages,
|
||||||
groups = {fire = 1, dig_immediate = 3, not_in_creative_inventory = 1, dig_by_piston = 1, destroys_items = 1},
|
groups = {fire = 1, dig_immediate = 3, not_in_creative_inventory = 1, dig_by_piston = 1, destroys_items = 1},
|
||||||
floodable = true,
|
floodable = true,
|
||||||
on_flood = function(pos, oldnode, newnode)
|
on_flood = function(pos, oldnode, newnode)
|
||||||
|
Loading…
Reference in New Issue
Block a user