diff --git a/LICENSE.txt b/LICENSE.txt index a6ab12c..0cc4900 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -543,6 +543,12 @@ GNU Lesser General Public License v2.1 or later - x_bows_quiver.8.ogg - x_bows_quiver.9.ogg +**CC0-1.0, Kinoton**, https://freesound.org/people/Kinoton/sounds/427979/ + +- x_bows_arrow_flyby.1.ogg +- x_bows_arrow_flyby.2.ogg +- x_bows_arrow_flyby.3.ogg + ### Models **CC-BY-SA-4.0, by SaKeL** diff --git a/api.lua b/api.lua index 3376b8e..89e6d2f 100644 --- a/api.lua +++ b/api.lua @@ -924,6 +924,9 @@ function XBowsEntityDef.on_activate(self, selfObj, staticdata, dtime_s) selfObj._arrow_particle_effect = x_bows_registered_arrow_def.custom.particle_effect selfObj._arrow_particle_effect_crit = x_bows_registered_arrow_def.custom.particle_effect_crit selfObj._arrow_particle_effect_fast = x_bows_registered_arrow_def.custom.particle_effect_fast + selfObj._flyby_sound_played = { + ['player_name'] = true + } ---Bow Def local x_bows_registered_bow_def = self.registered_bows[selfObj._bow_name] @@ -994,7 +997,7 @@ function XBowsEntityDef.on_activate(self, selfObj, staticdata, dtime_s) ---idle animation if x_bows_registered_entity_def and x_bows_registered_entity_def._custom.animations.idle then - selfObj.object:set_animation(unpack(x_bows_registered_entity_def._custom.animations.idle)--[[@as table]] ) + selfObj.object:set_animation(unpack(x_bows_registered_entity_def._custom.animations.idle)--[[@as table]]) end ---counter, e.g. for initial values set `on_step` @@ -1119,6 +1122,28 @@ function XBowsEntityDef.on_step(self, selfObj, dtime) local in_pos = pointed_thing.intersection_normal selfObj.pointed_thing = pointed_thing + if not selfObj._attached then + for _, object in ipairs(minetest.get_objects_inside_radius(selfObj.object:get_pos(), 5)) do + if object:is_player() + and object:get_hp() > 0 + and object:get_player_name() ~= selfObj._user:get_player_name() + and not selfObj._flyby_sound_played[object:get_player_name()] + then + selfObj._flyby_sound_played[object:get_player_name()] = true + + local p1 = selfObj.object:get_pos() + local p2 = object:get_pos() + local distance = math.round(vector.distance(p1, p2)) + local gain = 1 / distance + + minetest.sound_play('x_bows_arrow_flyby', { + to_player = object:get_player_name(), + gain = gain + }, true) + end + end + end + if pointed_thing.type == 'object' and pointed_thing.ref ~= selfObj.object and pointed_thing.ref:get_hp() > 0 diff --git a/sounds/x_bows_arrow_flyby.1.ogg b/sounds/x_bows_arrow_flyby.1.ogg new file mode 100644 index 0000000..45a99d3 Binary files /dev/null and b/sounds/x_bows_arrow_flyby.1.ogg differ diff --git a/sounds/x_bows_arrow_flyby.2.ogg b/sounds/x_bows_arrow_flyby.2.ogg new file mode 100644 index 0000000..779948a Binary files /dev/null and b/sounds/x_bows_arrow_flyby.2.ogg differ diff --git a/sounds/x_bows_arrow_flyby.3.ogg b/sounds/x_bows_arrow_flyby.3.ogg new file mode 100644 index 0000000..8af73ca Binary files /dev/null and b/sounds/x_bows_arrow_flyby.3.ogg differ