Fix client dying on host before shared health is depleted.

This commit is contained in:
IQuant 2024-05-24 11:11:04 +03:00
parent 94432c21e1
commit c08db2bad2

View file

@ -10,4 +10,14 @@ function damage_received(damage, message, entity_thats_responsible, is_fatal, pr
return return
end end
ComponentSetValue2(host_damageModelComponent, "hp", health - damage) ComponentSetValue2(host_damageModelComponent, "hp", health - damage)
-- Change our health back
local entity_id = GetUpdatedEntityID();
local damageModelComponent = EntityGetFirstComponentIncludingDisabled( entity_id, "DamageModelComponent" )
if damageModelComponent ~= nil then
local health = ComponentGetValue2( damageModelComponent, "hp" )
if health then
ComponentSetValue2( damageModelComponent, "hp", health + damage )
end
end
end end