Fix ranged hit "ding" sound not playing

This commit is contained in:
Wuzzy 2024-01-10 17:29:05 +01:00
parent 6a683e8d0f
commit dffa790f21

View File

@ -153,6 +153,7 @@ local function register_simple_projectile(id, initial_properties, def)
for c=1, #moveresult.collisions do for c=1, #moveresult.collisions do
local collision = moveresult.collisions[c] local collision = moveresult.collisions[c]
if collision.type == "object" then if collision.type == "object" then
local armor = collision.object:get_armor_groups()
local dir = vector.direction(opos, collision.object:get_pos()) local dir = vector.direction(opos, collision.object:get_pos())
if self._punch_tool_properties then if self._punch_tool_properties then
collision.object:punch(self.object, math.huge, self._punch_tool_properties, dir) collision.object:punch(self.object, math.huge, self._punch_tool_properties, dir)
@ -168,7 +169,6 @@ local function register_simple_projectile(id, initial_properties, def)
minetest.sound_play(def.impact_sound, {pos=opos, max_hear_distance=12}, true) minetest.sound_play(def.impact_sound, {pos=opos, max_hear_distance=12}, true)
end end
if self._shooter then if self._shooter then
local armor = collision.object:get_armor_groups()
-- Play notify sound to shooter when hitting a shadow mob -- Play notify sound to shooter when hitting a shadow mob
if armor and armor.shadow_physical ~= nil and armor.shadow_physical ~= 0 then if armor and armor.shadow_physical ~= nil and armor.shadow_physical ~= 0 then
local shooter = minetest.get_player_by_name(self._shooter) local shooter = minetest.get_player_by_name(self._shooter)