From 9f4ee9a6fcb16f79e2c6f28dab3a174a79cc22e0 Mon Sep 17 00:00:00 2001 From: bgkillas Date: Sun, 2 Feb 2025 12:33:47 -0500 Subject: [PATCH] fix transmutation field duping --- .../projectiles/projectile_transmutation.lua | 40 +++++++++++++++++++ quant.ew/init.lua | 1 + 2 files changed, 41 insertions(+) create mode 100644 quant.ew/data/scripts/projectiles/projectile_transmutation.lua diff --git a/quant.ew/data/scripts/projectiles/projectile_transmutation.lua b/quant.ew/data/scripts/projectiles/projectile_transmutation.lua new file mode 100644 index 00000000..6dbfca80 --- /dev/null +++ b/quant.ew/data/scripts/projectiles/projectile_transmutation.lua @@ -0,0 +1,40 @@ +dofile_once("data/scripts/lib/utilities.lua") + +local entity_id = GetUpdatedEntityID() +local x, y = EntityGetTransform(entity_id) + +local projectiles = EntityGetWithTag("projectile") + +if #projectiles > 0 then + for i, projectile_id in ipairs(projectiles) do + local px, py = EntityGetTransform(projectile_id) + + local distance = math.abs(x - px) + math.abs(y - py) + + if (distance < 64) and (entity_id ~= projectile_id) then + distance = math.sqrt((x - px) ^ 2 + (y - py) ^ 2) + + if distance < 48 then + local projectilecomponents = EntityGetComponent(projectile_id, "ProjectileComponent") + + if projectilecomponents ~= nil then + for j, comp_id in ipairs(projectilecomponents) do + ComponentSetValue(comp_id, "on_death_explode", "0") + ComponentSetValue(comp_id, "on_lifetime_out_explode", "0") + end + end + + SetRandomSeed(px + 325, py - 235) + local opts = { "duck", "sheep", "sheep_bat", "sheep_fly" } + local rnd = Random(1, #opts) + local opt = opts[rnd] + + if CrossCall("ew_do_i_own", entity_id) then + EntityLoad("data/entities/animals/" .. opt .. ".xml", px, py) + end + EntityLoad("data/entities/particles/image_emitters/transmutation_effect.xml", px, py) + EntityKill(projectile_id) + end + end + end +end diff --git a/quant.ew/init.lua b/quant.ew/init.lua index 87f87567..7a3412e7 100755 --- a/quant.ew/init.lua +++ b/quant.ew/init.lua @@ -281,6 +281,7 @@ function OnProjectileFired( or n == "data/entities/projectiles/deck/white_hole.xml" or n == "data/entities/projectiles/deck/white_hole_giga.xml" or n == "data/entities/projectiles/deck/orb_laseremitter_four.xml" + or n == "data/entities/projectiles/deck/projectile_transmutation_field.xml" or EntityHasTag(projectile_id, "ew_projectile_position_sync") then local body = EntityGetFirstComponentIncludingDisabled(projectile_id, "PhysicsBody2Component")