mirror of
https://git.minetest.land/Mineclonia/Mineclonia.git
synced 2024-11-24 14:25:10 +00:00
Slow down arrows in liquids
This is a rought first implementation, very basic.
This commit is contained in:
parent
32f612469f
commit
fb8c5300cd
1 changed files with 15 additions and 0 deletions
|
@ -135,6 +135,21 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
|||
minetest.add_item(self._lastpos, 'mcl_bows:arrow')
|
||||
end
|
||||
self.object:remove()
|
||||
elseif (def and def.liquidtype ~= "none") then
|
||||
-- Slow down arrow in liquids
|
||||
local v = def.liquid_viscosity
|
||||
if not v then
|
||||
v = 0
|
||||
end
|
||||
local vpenalty = math.max(0.1, 0.98 - 0.1 * v)
|
||||
local vel = self.object:get_velocity()
|
||||
if math.abs(vel.x) > 0.001 then
|
||||
vel.x = vel.x * vpenalty
|
||||
end
|
||||
if math.abs(vel.z) > 0.001 then
|
||||
vel.z = vel.z * vpenalty
|
||||
end
|
||||
self.object:set_velocity(vel)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue