mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add module 'base:util' & fix attack
This commit is contained in:
parent
f095edda7a
commit
bc17abc8b3
3 changed files with 14 additions and 6 deletions
|
|
@ -1,3 +1,5 @@
|
|||
local base_util = require "util"
|
||||
|
||||
local DROP_FORCE = 8
|
||||
local DROP_INIT_VEL = {0, 3, 0}
|
||||
|
||||
|
|
@ -17,10 +19,7 @@ function on_hud_open()
|
|||
local pvel = {player.get_vel(pid)}
|
||||
local ppos = vec3.add({player.get_pos(pid)}, {0, 0.7, 0})
|
||||
local throw_force = vec3.mul(player.get_dir(pid), DROP_FORCE)
|
||||
local drop = entities.spawn("base:drop", ppos, {base__drop={
|
||||
id=itemid,
|
||||
count=1
|
||||
}})
|
||||
local drop = base_util.drop(ppos, itemid, 1)
|
||||
local velocity = vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL))
|
||||
drop.rigidbody:set_vel(velocity)
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue