Separate death mods & add cactus/magma block msgs
parent
6f309da747
commit
1ddb89a86c
|
@ -1,5 +1,6 @@
|
||||||
mcl_sounds
|
mcl_sounds
|
||||||
mcl_util
|
mcl_util
|
||||||
walkover
|
walkover
|
||||||
|
mcl_death_messages
|
||||||
doc_items
|
doc_items
|
||||||
doc?
|
doc?
|
||||||
|
|
|
@ -60,7 +60,10 @@ minetest.register_node("mcl_nether:magma", {
|
||||||
-- From walkover mod
|
-- From walkover mod
|
||||||
on_walk_over = function(loc, nodeiamon, player)
|
on_walk_over = function(loc, nodeiamon, player)
|
||||||
-- Hurt players standing on top of this block
|
-- Hurt players standing on top of this block
|
||||||
|
if player:get_hp() > 0 then
|
||||||
|
mcl_death_messages.player_damage(player, string.format("%s stood too long on a magma block.", player:get_player_name()))
|
||||||
player:set_hp(player:get_hp() - 1)
|
player:set_hp(player:get_hp() - 1)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
_mcl_blast_resistance = 2.5,
|
_mcl_blast_resistance = 2.5,
|
||||||
_mcl_hardness = 0.5,
|
_mcl_hardness = 0.5,
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
name = mcl_death
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
minetest.register_on_dieplayer(function(player)
|
||||||
|
local keep = minetest.setting_getbool("mcl_keepInventory") or false
|
||||||
|
if keep == false then
|
||||||
|
-- Drop inventory, crafting grid and armor
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
local pos = player:getpos()
|
||||||
|
local name, player_armor_inv, armor_armor_inv, pos = armor:get_valid_player(player, "[on_dieplayer]")
|
||||||
|
local lists = {
|
||||||
|
{ inv = inv, listname = "main", drop = true },
|
||||||
|
{ inv = inv, listname = "craft", drop = true },
|
||||||
|
{ inv = player_armor_inv, listname = "armor", drop = true },
|
||||||
|
{ inv = armor_armor_inv, listname = "armor", drop = false },
|
||||||
|
}
|
||||||
|
for l=1,#lists do
|
||||||
|
local inv = lists[l].inv
|
||||||
|
local listname = lists[l].listname
|
||||||
|
local drop = lists[l].drop
|
||||||
|
if inv ~= nil then
|
||||||
|
for i, stack in ipairs(inv:get_list(listname)) do
|
||||||
|
local x = math.random(0, 9)/3
|
||||||
|
local z = math.random(0, 9)/3
|
||||||
|
pos.x = pos.x + x
|
||||||
|
pos.z = pos.z + z
|
||||||
|
if drop then
|
||||||
|
minetest.add_item(pos, stack)
|
||||||
|
end
|
||||||
|
stack:clear()
|
||||||
|
inv:set_stack(listname, i, stack)
|
||||||
|
pos.x = pos.x - x
|
||||||
|
pos.z = pos.z - z
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
armor:set_player_armor(player)
|
||||||
|
armor:update_inventory(player)
|
||||||
|
end
|
||||||
|
end)
|
|
@ -0,0 +1 @@
|
||||||
|
name = mcl_death_drop
|
|
@ -0,0 +1 @@
|
||||||
|
Shows messages in chat when a player dies.
|
|
@ -1,13 +1,11 @@
|
||||||
|
mcl_death_messages = {}
|
||||||
|
|
||||||
-- Death messages
|
-- Death messages
|
||||||
local msgs = {
|
local msgs = {
|
||||||
["arrow"] = {
|
["arrow"] = {
|
||||||
"%s was fatally hit by an arrow.",
|
"%s was fatally hit by an arrow.",
|
||||||
"%s has been killed with an arrow.",
|
"%s has been killed with an arrow.",
|
||||||
},
|
},
|
||||||
["cactus"] = {
|
|
||||||
"%s was killed by a cactus.",
|
|
||||||
"%s was pricked to death.",
|
|
||||||
},
|
|
||||||
["fire"] = {
|
["fire"] = {
|
||||||
"%s has been cooked crisp.",
|
"%s has been cooked crisp.",
|
||||||
"%s felt the burn.",
|
"%s felt the burn.",
|
||||||
|
@ -123,45 +121,9 @@ local mmsg = function(mtype, ...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local last_punches = { }
|
local last_damages = { }
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function(player)
|
minetest.register_on_dieplayer(function(player)
|
||||||
local keep = minetest.setting_getbool("mcl_keepInventory") or false
|
|
||||||
if keep == false then
|
|
||||||
-- Drop inventory, crafting grid and armor
|
|
||||||
local inv = player:get_inventory()
|
|
||||||
local pos = player:getpos()
|
|
||||||
local name, player_armor_inv, armor_armor_inv, pos = armor:get_valid_player(player, "[on_dieplayer]")
|
|
||||||
local lists = {
|
|
||||||
{ inv = inv, listname = "main", drop = true },
|
|
||||||
{ inv = inv, listname = "craft", drop = true },
|
|
||||||
{ inv = player_armor_inv, listname = "armor", drop = true },
|
|
||||||
{ inv = armor_armor_inv, listname = "armor", drop = false },
|
|
||||||
}
|
|
||||||
for l=1,#lists do
|
|
||||||
local inv = lists[l].inv
|
|
||||||
local listname = lists[l].listname
|
|
||||||
local drop = lists[l].drop
|
|
||||||
if inv ~= nil then
|
|
||||||
for i, stack in ipairs(inv:get_list(listname)) do
|
|
||||||
local x = math.random(0, 9)/3
|
|
||||||
local z = math.random(0, 9)/3
|
|
||||||
pos.x = pos.x + x
|
|
||||||
pos.z = pos.z + z
|
|
||||||
if drop then
|
|
||||||
minetest.add_item(pos, stack)
|
|
||||||
end
|
|
||||||
stack:clear()
|
|
||||||
inv:set_stack(listname, i, stack)
|
|
||||||
pos.x = pos.x - x
|
|
||||||
pos.z = pos.z - z
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
armor:set_player_armor(player)
|
|
||||||
armor:update_inventory(player)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Death message
|
-- Death message
|
||||||
local message = minetest.setting_getbool("mcl_showDeathMessages")
|
local message = minetest.setting_getbool("mcl_showDeathMessages")
|
||||||
if message == nil then message = true end
|
if message == nil then message = true end
|
||||||
|
@ -185,31 +147,31 @@ minetest.register_on_dieplayer(function(player)
|
||||||
-- Void
|
-- Void
|
||||||
elseif node.name == "mcl_core:void" then
|
elseif node.name == "mcl_core:void" then
|
||||||
msg = dmsg("void", name)
|
msg = dmsg("void", name)
|
||||||
-- Cactus
|
|
||||||
elseif node.name == "mcl_core:cactus" then
|
|
||||||
msg = dmsg("cactus", name)
|
|
||||||
-- Other
|
-- Other
|
||||||
else
|
else
|
||||||
-- Killed by entity
|
-- Killed by entity
|
||||||
if last_punches[name] then
|
if last_damages[name] then
|
||||||
-- Mob
|
-- Mob
|
||||||
if last_punches[name].hittertype == "mob" then
|
if last_damages[name].hittertype == "mob" then
|
||||||
if last_punches[name].hittername then
|
if last_damages[name].hittername then
|
||||||
msg = dmsg("murder", name, last_punches[name].hittername)
|
msg = dmsg("murder", name, last_damages[name].hittername)
|
||||||
else
|
else
|
||||||
msg = mmsg(last_punches[name].hittersubtype, name)
|
msg = mmsg(last_damages[name].hittersubtype, name)
|
||||||
end
|
end
|
||||||
-- Player
|
-- Player
|
||||||
elseif last_punches[name].hittertype == "player" then
|
elseif last_damages[name].hittertype == "player" then
|
||||||
msg = dmsg("murder", name, last_punches[name].hittername)
|
msg = dmsg("murder", name, last_damages[name].hittername)
|
||||||
-- Arrow
|
-- Arrow
|
||||||
elseif last_punches[name].hittertype == "arrow" then
|
elseif last_damages[name].hittertype == "arrow" then
|
||||||
msg = dmsg("arrow", name)
|
msg = dmsg("arrow", name)
|
||||||
-- Fireball
|
-- Fireball
|
||||||
elseif last_punches[name].hittertype == "blaze_fireball" then
|
elseif last_damages[name].hittertype == "blaze_fireball" then
|
||||||
msg = dmsg("blaze_fireball", name)
|
msg = dmsg("blaze_fireball", name)
|
||||||
elseif last_punches[name].hittertype == "ghast_fireball" then
|
elseif last_damages[name].hittertype == "ghast_fireball" then
|
||||||
msg = dmsg("ghast_fireball", name)
|
msg = dmsg("ghast_fireball", name)
|
||||||
|
-- Custom death message
|
||||||
|
elseif last_damages[name].custom then
|
||||||
|
msg = last_damages[name].message
|
||||||
end
|
end
|
||||||
-- Other reason
|
-- Other reason
|
||||||
else
|
else
|
||||||
|
@ -222,6 +184,11 @@ minetest.register_on_dieplayer(function(player)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local start_damage_reset_countdown = function (player)
|
||||||
|
minetest.after(1, function(playername)
|
||||||
|
last_damages[playername] = nil
|
||||||
|
end, player:get_player_name())
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_on_punchplayer(function(player, hitter)
|
minetest.register_on_punchplayer(function(player, hitter)
|
||||||
if not player or not player:is_player() or not hitter then
|
if not player or not player:is_player() or not hitter then
|
||||||
|
@ -256,8 +223,12 @@ minetest.register_on_punchplayer(function(player, hitter)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
last_punches[player:get_player_name()] = { shooter = shooter, hittername = hittername, hittertype = hittertype, hittersubtype = hittersubtype }
|
last_damages[player:get_player_name()] = { shooter = shooter, hittername = hittername, hittertype = hittertype, hittersubtype = hittersubtype }
|
||||||
minetest.after(1, function(playername)
|
start_damage_reset_countdown(player)
|
||||||
last_punches[playername] = nil
|
|
||||||
end, player:get_player_name())
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- To be called to notify this mod that a player has been damaged, with a custom death message if the player died
|
||||||
|
function mcl_death_messages.player_damage(player, message)
|
||||||
|
last_damages[player:get_player_name()] = { custom = true, message = message }
|
||||||
|
start_damage_reset_countdown(player)
|
||||||
|
end
|
|
@ -0,0 +1 @@
|
||||||
|
name = mcl_death_messages
|
|
@ -3,4 +3,5 @@ mcl_util
|
||||||
mcl_core
|
mcl_core
|
||||||
mcl_particles
|
mcl_particles
|
||||||
mcl_hunger
|
mcl_hunger
|
||||||
|
mcl_death_messages
|
||||||
3d_armor?
|
3d_armor?
|
||||||
|
|
|
@ -167,10 +167,11 @@ minetest.register_globalstep(function(dtime)
|
||||||
-- am I touching the cactus? if so it hurts
|
-- am I touching the cactus? if so it hurts
|
||||||
for _,object in pairs(minetest.get_objects_inside_radius(near, 1.1)) do
|
for _,object in pairs(minetest.get_objects_inside_radius(near, 1.1)) do
|
||||||
if object:get_hp() > 0 then
|
if object:get_hp() > 0 then
|
||||||
object:set_hp(object:get_hp() - 1)
|
|
||||||
if object:is_player() 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_hunger.exhaust(object:get_player_name(), mcl_hunger.EXHAUST_DAMAGE)
|
mcl_hunger.exhaust(object:get_player_name(), mcl_hunger.EXHAUST_DAMAGE)
|
||||||
end
|
end
|
||||||
|
object:set_hp(object:get_hp() - 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue