Do not sync player projectiles as enemy projectiles

This commit is contained in:
IQuant 2024-05-15 14:23:40 +03:00
parent 5abb49ccc5
commit b8a2802f4f
2 changed files with 3 additions and 2 deletions

View file

@ -28,7 +28,7 @@ end
local function get_sync_entities()
local entities = EntityGetWithTag("enemy") -- TODO maybe only sync those close to players?
table_extend_filtered(entities, EntityGetWithTag("projectile"), function (ent)
return not EntityHasTag(ent, "projectile_player")
return not (EntityHasTag(ent, "ew_shot_by_player") or EntityHasTag(ent, "projectile_player"))
end)
return entities
end
@ -57,7 +57,7 @@ function enemy_sync.host_upload_entities()
if damage_model ~= nil then
ComponentSetValue2(damage_model, "wait_for_kill_flag_on_death", true)
if hp <= 0 then
ComponentSetValue2(damage_model, "kill_now", true)
ComponentSetValue2(damage_model, "kill_now", true) -- TODO this causes all kills to count as accidental
end
end

View file

@ -28,6 +28,7 @@ function OnProjectileFired(shooter_id, projectile_id, initial_rng, position_x, p
if not EntityHasTag(shooter_id, "player_unit") and not EntityHasTag(shooter_id, "ew_client") then
return -- Not fired by player, we don't care about it (for now?)
end
EntityAddTag(projectile_id, "ew_shot_by_player")
local projectileComponent = EntityGetFirstComponentIncludingDisabled(projectile_id, "ProjectileComponent")
local entity_that_shot = ComponentGetValue2(projectileComponent, "mEntityThatShot")