1
0
mirror of https://gitlab.com/echoes91/spears.git synced 2025-06-29 22:20:24 +02:00
This commit is contained in:
Andrea Plati
2015-10-13 21:44:45 +02:00
parent 510ab936b8
commit 4826788d02
4 changed files with 23 additions and 134 deletions

View File

@ -1,12 +1,13 @@
function spears_shot (itemstack, player)
local spear = itemstack:get_name() .. '_entity'
local playerpos = player:getpos()
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, spear)
local dir = player:get_look_dir()
obj:setvelocity({x=dir.x*14, y=dir.y*14, z=dir.z*14})
obj:setacceleration({x=-dir.x*.5, y=-9.8, z=-dir.z*.5})
local sp = .14
local dr = 0-- .2
local gravity = 0--9.8
obj:setvelocity({x=dir.x*sp, y=dir.y*sp, z=dir.z*sp})
obj:setacceleration({x=-dir.x*dr, y=-gravity, z=-dir.z*dr})
obj:setyaw(player:get_look_yaw()+math.pi)
minetest.sound_play("spears_sound", {pos=playerpos})
obj:get_luaentity().wear = itemstack:get_wear()