mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-17 08:31:08 +01:00
Make vl_projectile use mcl_util.deal_damage
This commit is contained in:
parent
4731ae64f0
commit
bc3e2ebd72
2 changed files with 11 additions and 1 deletions
|
@ -731,3 +731,13 @@ function mcl_util.get_entity_id(entity)
|
||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function mcl_util.get_entity_from_id(id)
|
||||||
|
local player = minetest.get_player_by_name(id)
|
||||||
|
if player then return player end
|
||||||
|
|
||||||
|
for i,le in pairs(minetest.luaentities) do
|
||||||
|
if le._uuid == id then return le.object end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
|
@ -491,7 +491,7 @@ local function handle_entity_collision(self, entity_def, projectile_def, object)
|
||||||
dmg = dmg(self, entity_def, projectile_def, object)
|
dmg = dmg(self, entity_def, projectile_def, object)
|
||||||
end
|
end
|
||||||
|
|
||||||
object:punch(self.object, 1.0, projectile_def.tool or { full_punch_interval = 1.0, damage_groups = dmg }, dir )
|
mcl_util.deal_damage(object, dmg.fleshy, {type = projectile_def.damage_type or "arrow", source = mcl_util.get_entity_from_id(self._owner), direct = self.object})
|
||||||
|
|
||||||
-- Guard against crashes when projectiles get destroyed in response to what it punched
|
-- Guard against crashes when projectiles get destroyed in response to what it punched
|
||||||
if not self.object:get_pos() then return true end
|
if not self.object:get_pos() then return true end
|
||||||
|
|
Loading…
Reference in a new issue