mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Fix: damage sync not causing death
Newline Gameprint
This commit is contained in:
parent
c08db2bad2
commit
72c6e15f9f
1 changed files with 19 additions and 16 deletions
|
@ -1,23 +1,26 @@
|
|||
-- Called on host when clients get damage and redirects it straight to the host's hp, ignoring any resists.
|
||||
function damage_received(damage, message, entity_thats_responsible, is_fatal, projectile_thats_responsible)
|
||||
local host_entity_id = EntityGetWithTag("ew_host")[1]
|
||||
local host_damageModelComponent = EntityGetFirstComponentIncludingDisabled(host_entity_id, "DamageModelComponent")
|
||||
if not host_damageModelComponent then
|
||||
function inflict_direct_damage(entity_id, damage)
|
||||
local damageModelComponent = EntityGetFirstComponentIncludingDisabled(entity_id, "DamageModelComponent")
|
||||
if not damageModelComponent then
|
||||
return
|
||||
end
|
||||
local health = ComponentGetValue2(host_damageModelComponent, "hp")
|
||||
local health = ComponentGetValue2(damageModelComponent, "hp")
|
||||
if not health then
|
||||
return
|
||||
end
|
||||
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
|
||||
new_health = health - damage
|
||||
ComponentSetValue2(damageModelComponent, "hp", new_health)
|
||||
if new_health <= 0 then
|
||||
EntityKill(entity_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Called on host when clients get damage and redirects it straight to the host's hp, ignoring any resists.
|
||||
function damage_received(damage, message, entity_thats_responsible, is_fatal, projectile_thats_responsible)
|
||||
-- Damage the host
|
||||
local host_entity_id = EntityGetWithTag("ew_host")[1]
|
||||
inflict_direct_damage(host_entity_id, damage)
|
||||
-- Return the health to the client
|
||||
local client_entity_id = GetUpdatedEntityID(client_entity_id, -damage)
|
||||
inflict_direct_damage(client_entity_id, -damage)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue