|
| 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 |
0 commit comments