Mixed 2 conditions into 1.

This commit is contained in:
CyberMango 2023-01-06 01:13:39 +02:00
parent a1d98c080f
commit 06435e0f4c
1 changed files with 11 additions and 12 deletions

View File

@ -231,8 +231,8 @@ mcl_damage.register_on_death(function(obj, reason)
end) end)
mcl_damage.register_on_damage(function(obj, damage, reason) mcl_damage.register_on_damage(function(obj, damage, reason)
if obj:get_hp() - damage > 0 then if (obj:get_hp() - damage > 0) and reason.source and
if reason.source and (reason.source:is_player() or obj:get_luaentity()) then (reason.source:is_player() or obj:get_luaentity()) then
-- To avoid timing issues we cancel the previous job before adding a new one. -- To avoid timing issues we cancel the previous job before adding a new one.
if mcl_death_messages.assist[obj] then if mcl_death_messages.assist[obj] then
mcl_death_messages.assist[obj].job:cancel() mcl_death_messages.assist[obj].job:cancel()
@ -244,5 +244,4 @@ mcl_damage.register_on_damage(function(obj, damage, reason)
end) end)
mcl_death_messages.assist[obj] = {name = mcl_util.get_object_name(reason.source), job = new_job} mcl_death_messages.assist[obj] = {name = mcl_util.get_object_name(reason.source), job = new_job}
end end
end
end) end)