Skip to content

Commit 9f4ee9a

Browse files
committed
fix transmutation field duping
1 parent de950a0 commit 9f4ee9a

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
dofile_once("data/scripts/lib/utilities.lua")
2+
3+
local entity_id = GetUpdatedEntityID()
4+
local x, y = EntityGetTransform(entity_id)
5+
6+
local projectiles = EntityGetWithTag("projectile")
7+
8+
if #projectiles > 0 then
9+
for i, projectile_id in ipairs(projectiles) do
10+
local px, py = EntityGetTransform(projectile_id)
11+
12+
local distance = math.abs(x - px) + math.abs(y - py)
13+
14+
if (distance < 64) and (entity_id ~= projectile_id) then
15+
distance = math.sqrt((x - px) ^ 2 + (y - py) ^ 2)
16+
17+
if distance < 48 then
18+
local projectilecomponents = EntityGetComponent(projectile_id, "ProjectileComponent")
19+
20+
if projectilecomponents ~= nil then
21+
for j, comp_id in ipairs(projectilecomponents) do
22+
ComponentSetValue(comp_id, "on_death_explode", "0")
23+
ComponentSetValue(comp_id, "on_lifetime_out_explode", "0")
24+
end
25+
end
26+
27+
SetRandomSeed(px + 325, py - 235)
28+
local opts = { "duck", "sheep", "sheep_bat", "sheep_fly" }
29+
local rnd = Random(1, #opts)
30+
local opt = opts[rnd]
31+
32+
if CrossCall("ew_do_i_own", entity_id) then
33+
EntityLoad("data/entities/animals/" .. opt .. ".xml", px, py)
34+
end
35+
EntityLoad("data/entities/particles/image_emitters/transmutation_effect.xml", px, py)
36+
EntityKill(projectile_id)
37+
end
38+
end
39+
end
40+
end

quant.ew/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ function OnProjectileFired(
281281
or n == "data/entities/projectiles/deck/white_hole.xml"
282282
or n == "data/entities/projectiles/deck/white_hole_giga.xml"
283283
or n == "data/entities/projectiles/deck/orb_laseremitter_four.xml"
284+
or n == "data/entities/projectiles/deck/projectile_transmutation_field.xml"
284285
or EntityHasTag(projectile_id, "ew_projectile_position_sync")
285286
then
286287
local body = EntityGetFirstComponentIncludingDisabled(projectile_id, "PhysicsBody2Component")

0 commit comments

Comments
 (0)