From 92ab90fd1b028d76735443201b374ee6b961bc2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20=C3=85str=C3=B6m?= Date: Sat, 18 Apr 2020 12:19:18 +0200 Subject: [PATCH] Add knockback for mobs --- mods/CORE/mcl_explosions/init.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mods/CORE/mcl_explosions/init.lua b/mods/CORE/mcl_explosions/init.lua index 225c2e770..e0a71bf6d 100644 --- a/mods/CORE/mcl_explosions/init.lua +++ b/mods/CORE/mcl_explosions/init.lua @@ -322,17 +322,18 @@ local function trace_explode(pos, strength, raydirs, radius, drop_chance) -- Punch entity with damage depending on explosion exposure and -- distance to explosion local exposure = count / N_EXPOSURE_RAYS - local punch_vec = vector.subtract(pos, opos) + local punch_vec = vector.subtract(opos, pos) local punch_dir = vector.normalize(punch_vec) local impact = (1 - vector.length(punch_vec) / punch_radius) * exposure if impact < 0 then impact = 0 end local damage = math.floor((impact * impact + impact) * 7 * strength + 1) - obj:punch(obj, nil, { damage_groups = { fleshy = damage } }, punch_dir) + obj:punch(obj, 10, { damage_groups = { full_punch_interval = 1, + fleshy = damage, knockback = impact * 20.0 } }, punch_dir) if obj:is_player() then - obj:add_player_velocity(vector.multiply(punch_dir, -exposure * 20)) + obj:add_player_velocity(vector.multiply(punch_dir, impact * 20)) end end end