0
0
Fork 0

Add throwing sound

This commit is contained in:
Wuzzy 2020-12-07 00:02:32 +01:00
parent e49e75ece2
commit 5bd3ebda17
5 changed files with 15 additions and 2 deletions

View File

@ -108,6 +108,7 @@ function mcl_potions.register_lingering(name, descr, color, def)
local velocity = 10 local velocity = 10
local dir = placer:get_look_dir(); local dir = placer:get_look_dir();
local pos = placer:getpos(); local pos = placer:getpos();
minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true)
local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying")
obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity})
obj:setacceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3}) obj:setacceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3})
@ -120,7 +121,9 @@ function mcl_potions.register_lingering(name, descr, color, def)
stack_max = 1, stack_max = 1,
_on_dispense = function(stack, dispenserpos, droppos, dropnode, dropdir) _on_dispense = function(stack, dispenserpos, droppos, dropnode, dropdir)
local s_pos = vector.add(dispenserpos, vector.multiply(dropdir, 0.51)) local s_pos = vector.add(dispenserpos, vector.multiply(dropdir, 0.51))
local obj = minetest.add_entity({x=s_pos.x+dropdir.x,y=s_pos.y+dropdir.y,z=s_pos.z+dropdir.z}, id.."_flying") local pos = {x=s_pos.x+dropdir.x,y=s_pos.y+dropdir.y,z=s_pos.z+dropdir.z}
minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true)
local obj = minetest.add_entity(pos, id.."_flying")
local velocity = 22 local velocity = 22
obj:set_velocity({x=dropdir.x*velocity,y=dropdir.y*velocity,z=dropdir.z*velocity}) obj:set_velocity({x=dropdir.x*velocity,y=dropdir.y*velocity,z=dropdir.z*velocity})
obj:set_acceleration({x=dropdir.x*-3, y=-9.8, z=dropdir.z*-3}) obj:set_acceleration({x=dropdir.x*-3, y=-9.8, z=dropdir.z*-3})

View File

@ -30,6 +30,7 @@ function mcl_potions.register_splash(name, descr, color, def)
local velocity = 10 local velocity = 10
local dir = placer:get_look_dir(); local dir = placer:get_look_dir();
local pos = placer:get_pos(); local pos = placer:get_pos();
minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true)
local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying")
obj:set_velocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) obj:set_velocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity})
obj:set_acceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3}) obj:set_acceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3})
@ -42,7 +43,9 @@ function mcl_potions.register_splash(name, descr, color, def)
stack_max = 1, stack_max = 1,
_on_dispense = function(stack, dispenserpos, droppos, dropnode, dropdir) _on_dispense = function(stack, dispenserpos, droppos, dropnode, dropdir)
local s_pos = vector.add(dispenserpos, vector.multiply(dropdir, 0.51)) local s_pos = vector.add(dispenserpos, vector.multiply(dropdir, 0.51))
local obj = minetest.add_entity({x=s_pos.x+dropdir.x,y=s_pos.y+dropdir.y,z=s_pos.z+dropdir.z}, id.."_flying") local pos = {x=s_pos.x+dropdir.x,y=s_pos.y+dropdir.y,z=s_pos.z+dropdir.z}
minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true)
local obj = minetest.add_entity(pos, id.."_flying")
local velocity = 22 local velocity = 22
obj:set_velocity({x=dropdir.x*velocity,y=dropdir.y*velocity,z=dropdir.z*velocity}) obj:set_velocity({x=dropdir.x*velocity,y=dropdir.y*velocity,z=dropdir.z*velocity})
obj:set_acceleration({x=dropdir.x*-3, y=-9.8, z=dropdir.z*-3}) obj:set_acceleration({x=dropdir.x*-3, y=-9.8, z=dropdir.z*-3})

View File

@ -23,4 +23,10 @@ It's a MineClone 2 mod containing throwable items like snowballs.
- Author: dav0r (freesound.org) - Author: dav0r (freesound.org)
- Source: <https://freesound.org/people/dav0r/sounds/176760/> - Source: <https://freesound.org/people/dav0r/sounds/176760/>
- Original title: `d0_step_on_egg_04` (file was edited) - Original title: `d0_step_on_egg_04` (file was edited)
- `mcl_throwing_throw.ogg`:
- License: CC0
- Author: kretopi (freesound.org)
- Source: <https://freesound.org/people/kretopi/sounds/406405/>
- Original title: `Arrow002.wav` (file was edited)
- Everything else: See MineClone 2 license infos - Everything else: See MineClone 2 license infos

View File

@ -31,6 +31,7 @@ mcl_throwing.throw = function(throw_item, pos, dir, velocity, thrower)
if velocity == nil then if velocity == nil then
velocity = 22 velocity = 22
end end
minetest.sound_play("mcl_throwing_throw", {pos=pos, gain=0.4, max_hear_distance=16}, true)
local itemstring = ItemStack(throw_item):get_name() local itemstring = ItemStack(throw_item):get_name()
local obj = minetest.add_entity(pos, entity_mapping[itemstring]) local obj = minetest.add_entity(pos, entity_mapping[itemstring])

Binary file not shown.