From 1d634aaa99a6c10d8e9c2b93a962437efc08fdd5 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Sat, 12 Dec 2015 17:51:48 +0100 Subject: [PATCH] [mobs/api] Put back calc_velocity --- mods/mobs/api.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mods/mobs/api.lua b/mods/mobs/api.lua index ec19c852..3ceb38c7 100755 --- a/mods/mobs/api.lua +++ b/mods/mobs/api.lua @@ -357,6 +357,17 @@ do_jump = function(self) end end +function calc_velocity(pos1, pos2, old_vel, power) + local vel = vector.direction(pos1, pos2) + vel = vector.normalize(vel) + vel = vector.multiply(vel, power) + local dist = vector.distance(pos1, pos2) + dist = math.max(dist, 1) + vel = vector.divide(vel, dist) + vel = vector.add(vel, old_vel) + return vel +end + -- blast damage to entities nearby (modified from TNT mod) function entity_physics(pos, radius, self) --/MFF (Crabman|06/23/2015)add self to use punch function