Page 1 of 1

Volcano projectiles originate from player

Posted: Sun Feb 19, 2012 11:25 am
by Burnstreet
I have an amulet with a chance to spawn Volcanos on hit. The projectiles of these volcanos seem to spawn at the position of my char instead of the volcano, which is weird.

Re: Volcano projectiles originate from player

Posted: Sun Feb 19, 2012 5:49 pm
by yufra
Can you describe the situation in more detail so that we can test it more easily? Are you far away from the Volcano and can see the projectiles leaving you instead of the Volcano for example?

Re: Volcano projectiles originate from player

Posted: Mon Feb 20, 2012 12:58 am
by lukep

Re: Volcano projectiles originate from player

Posted: Wed Feb 22, 2012 7:36 am
by Burnstreet
yufra wrote:Can you describe the situation in more detail so that we can test it more easily? Are you far away from the Volcano and can see the projectiles leaving you instead of the Volcano for example?
Exactly that.
I stand somewhere, shooting my alchemist bomb. All enemies are clustered in one direction from my pc.
Volcano procs and a volcano is created where one of the monsters was. Volcano projectiles start flying from my pc to the remaining monsters (even if my pc can not see them or the volcano).

Re: Volcano projectiles originate from player

Posted: Sun Feb 26, 2012 8:17 am
by tiger_eye
Aye, i confirmed that Volcano projectiles originate from the player. This occurs because the function "projectile(...)" is a function for actors, and so needs an actor to call it (in this case the actor that created the volcano, which hopefully still exists when the Volcano tries to do its thing :-P ). Unlike "project(...)", "projectile(...)" can't currently overwrite the location of origination with data from "typ" (i.e., tg, target_type, or Target:getType). Attached is a patch that does just that. I confirmed that it works for Volcano (as long as the source actor exists), although I can't promise it won't break something else ;)

Code: Select all

diff --git a/game/engines/default/engine/Projectile.lua b/game/engines/default/engine/Projectile.lua
index 2a9a822..aba5c85 100644
--- a/game/engines/default/engine/Projectile.lua
+++ b/game/engines/default/engine/Projectile.lua
@@ -258,7 +258,7 @@ function _M:makeProject(src, display, def, do_move, do_act, do_stop)
                travel_particle_args = display.particle_args,
                trail_particle = display.trail,
                src = src,
-               src_x = src.x, src_y = src.y,
+               src_x = def.start_x or src.x, src_y = def.start_y or src.y,
                project = {def=def},
                energy = {mod=speed},
                tmp_proj = {},
diff --git a/game/engines/default/engine/interface/ActorProject.lua b/game/engines/default/engine/interface/ActorProject.lua
index 73c02a9..90c0bac 100644
--- a/game/engines/default/engine/interface/ActorProject.lua
+++ b/game/engines/default/engine/interface/ActorProject.lua
@@ -270,12 +270,12 @@ function _M:projectile(t, x, y, damtype, dam, particles)
 --     if type(dam) == "number" and dam < 0 then return end
        local typ = Target:getType(t)
        typ.source_actor = self
-       typ.start_x = self.x
-       typ.start_y = self.y
+       typ.start_x = t.x or self.x
+       typ.start_y = t.y or self.y
        if self.lineFOV then
-               typ.line_function = self:lineFOV(x, y)
+               typ.line_function = self:lineFOV(x, y, nil, nil, t.x, t.y)
        else
-               typ.line_function = core.fov.line(self.x, self.y, x, y)
+               typ.line_function = core.fov.line(t.x or self.x, t.y or self.y, x, y)
        end
        local block_corner = typ.block_path and function(_, bx, by) local b, h, hr = typ:block_path(bx, by, true) ; return b and h and not hr end
                or function(_, bx, by) return false end