play sounds when you hit someone or get hit yourself

This commit is contained in:
whosit 2024-11-23 20:23:59 +03:00
parent fcc5a83098
commit 5ff3d371c9

View File

@ -190,11 +190,26 @@ local SNOWBALL_DEF = {
spawn_snow_puff(intersection_point, intersection_normal)
self.object:remove()
--ballistics.on_hit_node_hit_sound_play(self, node_pos, node, above_pos, intersection_point, intersection_normal, box_id)
--ballistics.on_hit_object_hit_sound_play(self, target, intersection_point, intersection_normal, box_id)
if target:is_player() then
local target_name = target:get_player_name()
-- TODO or check if opted-out here?
yl_snowball.snowgame.register_hit(self._source_player_name, target_name)
local source = self._source_obj
if futil.is_player(source) then
local sound_name = "y_bows_arrow_successful_hit"
core.sound_play({ name = sound_name }, {
gain = 0.7,
to_player = source:get_player_name(),
})
local take_hit_sound_name = "default_snow_footstep"
core.sound_play({ name = take_hit_sound_name }, {
gain = 0.7,
to_player = target_name,
})
end
end
return true
end
}