From 636ff60c682a4733a8b9a175db03065115afb840 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 8 Mar 2019 22:31:26 +0100 Subject: [PATCH] Don't re-damage object with arrow if already dead --- mods/ITEMS/mcl_bows/arrow.lua | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 9561fea0d..0b41a282e 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -184,26 +184,28 @@ ARROW_ENTITY.on_step = function(self, dtime) local is_player = obj:is_player() local lua = obj:get_luaentity() if obj ~= self._shooter and (is_player or (lua and lua._cmi_is_mob)) then - obj:punch(self.object, 1.0, { - full_punch_interval=1.0, - damage_groups={fleshy=self._damage}, - }, nil) + if obj:get_hp() > 0 then + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=self._damage}, + }, nil) - if is_player then - if self._shooter and self._shooter:is_player() then - -- “Ding” sound for hitting another player - minetest.sound_play({name="mcl_bows_hit_player", gain=0.1}, {to_player=self._shooter}) + if is_player then + if self._shooter and self._shooter:is_player() then + -- “Ding” sound for hitting another player + minetest.sound_play({name="mcl_bows_hit_player", gain=0.1}, {to_player=self._shooter}) + end end - end - if lua then - local entity_name = lua.name - -- Achievement for hitting skeleton, wither skeleton or stray (TODO) with an arrow at least 50 meters away - -- NOTE: Range has been reduced because mobs unload much earlier than that ... >_> - -- TODO: This achievement should be given for the kill, not just a hit - if self._shooter and self._shooter:is_player() and vector.distance(pos, self._startpos) >= 20 then - if mod_awards and (entity_name == "mobs_mc:skeleton" or entity_name == "mobs_mc:stray" or entity_name == "mobs_mc:witherskeleton") then - awards.unlock(self._shooter:get_player_name(), "mcl:snipeSkeleton") + if lua then + local entity_name = lua.name + -- Achievement for hitting skeleton, wither skeleton or stray (TODO) with an arrow at least 50 meters away + -- NOTE: Range has been reduced because mobs unload much earlier than that ... >_> + -- TODO: This achievement should be given for the kill, not just a hit + if self._shooter and self._shooter:is_player() and vector.distance(pos, self._startpos) >= 20 then + if mod_awards and (entity_name == "mobs_mc:skeleton" or entity_name == "mobs_mc:stray" or entity_name == "mobs_mc:witherskeleton") then + awards.unlock(self._shooter:get_player_name(), "mcl:snipeSkeleton") + end end end end