Skip to content

Commit

Permalink
fix transmutation field duping
Browse files Browse the repository at this point in the history
  • Loading branch information
bgkillas committed Feb 2, 2025
1 parent de950a0 commit 9f4ee9a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
40 changes: 40 additions & 0 deletions quant.ew/data/scripts/projectiles/projectile_transmutation.lua
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions quant.ew/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 9f4ee9a

Please sign in to comment.