Altering projectile particles mid-flight
Moderator: Moderator
-
- Spiderkin
- Posts: 543
- Joined: Sat Feb 11, 2012 1:12 am
Altering projectile particles mid-flight
I've been working on a talent that causes projectiles to bounce off the user, and I've got it working with one minor issue - projectiles that use a tile as their graphic (arrows, earthen missiles and the like) don't have their facing updated, so they fly backwards toward the attacker, which makes it difficult to tell the difference between incoming and outgoing attacks. Is there a way to update the rotation of a projectile's graphic after it's been reflected? I've tried messing around with the projectile.__particles table a bit but haven't had any success.
Re: Altering projectile particles mid-flight
Despite having talents which redirect projectiles, I hadn't noticed any backwards flying arrows, so I don't know.
My feedback meter decays into coding. Give me feedback and I make mods.
-
- Spiderkin
- Posts: 543
- Joined: Sat Feb 11, 2012 1:12 am
Re: Altering projectile particles mid-flight
I'm not talking about the built-in projectile_evasion attribute, which hijacks the target as it's fired, but a talent that causes projectiles that strike the user to be reflected. Maybe I should post the code, from superload\engine\interface\ActorProject.lua
Code: Select all
local base_projectDoMove = _M.projectDoMove
function _M:projectDoMove(typ, tgtx, tgty, x, y, srcx, srcy)
--reference our projectile from its location
local projectile = game.level.map(x, y, game.level.map.PROJECTILE)
local src = projectile.src
--call the original function to see where we're going
local retx, rety, retact, retstop = base_projectDoMove(self, typ, tgtx, tgty, x, y, srcx, srcy)
--look for an actor in the space we're about to move, and deflect the projectile
local actor = game.level.map(retx, rety, game.level.map.ACTOR)
if actor and actor:attr("stoic_deflection") and src ~= actor then
game.logSeen(actor, "%s deflects the %s from %s!", actor.name:capitalize(), projectile.name:capitalize(), src.name:capitalize())
--update the projectile's source/actor coordinates and overwrite its line_function to match, so it flies in the correct direction
projectile.project.def.tg.act_exclude = {[actor.uid]=true} --make sure deflected aoes never hit the actor
projectile.project.def.x, projectile.project.def.y = src.x, src.y
projectile.project.def.start_x, projectile.project.def.start_y = actor.x, actor.y
if actor.lineFOV then
projectile.project.def.typ.line_function = actor:lineFOV(src.x, src.y, nil, nil, actor.x, actor.y)
else
projectile.project.def.typ.line_function = core.fov.line(actor.x, actor.y, src.x, src.y)
end
--actor still gets hit if they walk into it, this is covered in superload\engine\Projectile.lua on_move()
--send our new direction to the old function to get which way to move
retx, rety, retact, retstop = base_projectDoMove(self, projectile.project.def.typ, src.x, src.y, x, y, actor.x, actor.y)
end
return retx, rety, retact, retstop
end
Re: Altering projectile particles mid-flight
Yeah, I've got a talent that makes all nearby projectiles fly towards their source instead.
And then there is the Deflect Projectiles spike.
And then there is the Deflect Projectiles spike.
My feedback meter decays into coding. Give me feedback and I make mods.
Re: Altering projectile particles mid-flight
This issue also crops up with homing projectiles if they're slow enough. Temporal Bolt makes this obvious because it has a directional effect, can both be turned as much as 180 degrees by the caster teleporting, and can be slow enough to make it very obvious what's happening by stacking "slows incoming projectiles" effects.
Digitochracy
n. 1. technocracy. 2. government by the numbers. 3. rule by people with the longest fingers.
n. 1. technocracy. 2. government by the numbers. 3. rule by people with the longest fingers.
-
- Spiderkin
- Posts: 543
- Joined: Sat Feb 11, 2012 1:12 am
Re: Altering projectile particles mid-flight
I tested both Deflect Projectiles and your Rebound talent, they both cause projectiles to keep their original facing after being redirected, at least on my system.HousePet wrote:Yeah, I've got a talent that makes all nearby projectiles fly towards their source instead.
And then there is the Deflect Projectiles spike.
Re: Altering projectile particles mid-flight
Facing is a graphical issue not a code issue, I think?