mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-29 22:33:46 +01:00
More anvil smashing fixes
parent
c71bd9588d
commit
e4a1134d4f
@ -1,6 +1,10 @@
|
|||||||
|
local dmes = minetest.get_modpath("mcl_death_messages") ~= nil
|
||||||
|
local hung = minetest.get_modpath("mcl_hunger") ~= nil
|
||||||
|
|
||||||
local on_damage_step = function(self, dtime)
|
local on_damage_step = function(self, dtime)
|
||||||
-- Cause damage to everything it hits.
|
-- Cause damage to any player it hits.
|
||||||
-- Algorithm based on MC anvils.
|
-- Algorithm based on MC anvils.
|
||||||
|
-- TODO: Support smashing other objects, too.
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
if not self._startpos then
|
if not self._startpos then
|
||||||
self._startpos = pos
|
self._startpos = pos
|
||||||
@ -30,14 +34,19 @@ local on_damage_step = function(self, dtime)
|
|||||||
hp = 0
|
hp = 0
|
||||||
end
|
end
|
||||||
if v:is_player() then
|
if v:is_player() then
|
||||||
|
-- TODO: Reduce damage if wearing a helmet
|
||||||
local msg
|
local msg
|
||||||
if minetest.get_item_group(self.node.name, "anvil") ~= 0 then
|
if minetest.get_item_group(self.node.name, "anvil") ~= 0 then
|
||||||
msg = "%s was smashed by a falling anvil."
|
msg = "%s was smashed by a falling anvil."
|
||||||
else
|
else
|
||||||
msg = "%s was smashed by a falling block."
|
msg = "%s was smashed by a falling block."
|
||||||
end
|
end
|
||||||
mcl_death_messages.player_damage(v, string.format(msg, v:get_player_name()))
|
if dmes then
|
||||||
mcl_hunger.exhaust(v:get_player_name(), mcl_hunger.EXHAUST_DAMAGE)
|
mcl_death_messages.player_damage(v, string.format(msg, v:get_player_name()))
|
||||||
|
end
|
||||||
|
if hung then
|
||||||
|
mcl_hunger.exhaust(v:get_player_name(), mcl_hunger.EXHAUST_DAMAGE)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
v:set_hp(hp)
|
v:set_hp(hp)
|
||||||
end
|
end
|
||||||
|
@ -162,7 +162,7 @@ end)
|
|||||||
doc.sub.items.register_factoid("nodes", "gravity", function(itemstring, def)
|
doc.sub.items.register_factoid("nodes", "gravity", function(itemstring, def)
|
||||||
local s = ""
|
local s = ""
|
||||||
if minetest.get_item_group(itemstring, "crush_after_fall") == 1 then
|
if minetest.get_item_group(itemstring, "crush_after_fall") == 1 then
|
||||||
s = s .. "When this block falls deeper than 1 block, it causes damage to anything it hits. The damage dealt is B×2−2 hit points with B = number of blocks fallen. The damage can never be more than 40 HP."
|
s = s .. "When this block falls deeper than 1 block, it causes damage to any player it hits. The damage dealt is B×2−2 hit points with B = number of blocks fallen. The damage can never be more than 40 HP."
|
||||||
end
|
end
|
||||||
return s
|
return s
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user