forked from VoxeLibre/VoxeLibre
Add tnt_knockback flag for entities
When set to true, entities will be knocked back when affected by TNT explosions. Also ignore '__builtin:item' entities to reduce lag, and replace tabs with spaces in 'mcl_explosions/init.lua'.
This commit is contained in:
parent
cdea2eeabf
commit
b4ea2afe77
|
@ -253,16 +253,17 @@ local function trace_explode(pos, strength, raydirs, radius, drop_chance)
|
||||||
|
|
||||||
-- Trace rays for entity damage
|
-- Trace rays for entity damage
|
||||||
for _, obj in pairs(objs) do
|
for _, obj in pairs(objs) do
|
||||||
-- Object position and direction to explosion center
|
local ent = obj:get_luaentity()
|
||||||
local opos = obj:get_pos()
|
|
||||||
|
|
||||||
if obj:get_luaentity() ~= nil or obj:is_player() then
|
-- Ignore items to lower lag
|
||||||
|
if obj:is_player() or (ent and ent.name ~= '__builtin.item') then
|
||||||
|
local opos = obj:get_pos()
|
||||||
local collisionbox = nil
|
local collisionbox = nil
|
||||||
|
|
||||||
if obj:is_player() then
|
if obj:is_player() then
|
||||||
collisionbox = { -0.3, 0.0, -0.3, 0.3, 1.77, 0.3 }
|
collisionbox = { -0.3, 0.0, -0.3, 0.3, 1.77, 0.3 }
|
||||||
elseif obj:get_luaentity().name then
|
elseif ent.name then
|
||||||
local def = minetest.registered_entities[obj:get_luaentity().name]
|
local def = minetest.registered_entities[ent.name]
|
||||||
collisionbox = def.collisionbox
|
collisionbox = def.collisionbox
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -334,6 +335,8 @@ local function trace_explode(pos, strength, raydirs, radius, drop_chance)
|
||||||
|
|
||||||
if obj:is_player() then
|
if obj:is_player() then
|
||||||
obj:add_player_velocity(vector.multiply(punch_dir, impact * 20))
|
obj:add_player_velocity(vector.multiply(punch_dir, impact * 20))
|
||||||
|
elseif ent.tnt_knockback then
|
||||||
|
obj:add_velocity(vector.multiply(punch_dir, impact * 20))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue