ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Wed Sep 19, 2018 2:39 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Tue May 12, 2015 12:58 am 
Offline
Spiderkin

Joined: Sat Feb 11, 2012 1:12 am
Posts: 543
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.


Top
 Profile  
 
PostPosted: Tue May 12, 2015 4:30 am 
Offline
Perspiring Physicist

Joined: Sun Sep 09, 2012 7:43 am
Posts: 5752
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.


Top
 Profile  
 
PostPosted: Tue May 12, 2015 5:03 am 
Offline
Spiderkin

Joined: Sat Feb 11, 2012 1:12 am
Posts: 543
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:
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


Top
 Profile  
 
PostPosted: Tue May 12, 2015 6:35 am 
Offline
Perspiring Physicist

Joined: Sun Sep 09, 2012 7:43 am
Posts: 5752
Yeah, I've got a talent that makes all nearby projectiles fly towards their source instead.
And then there is the Deflect Projectiles spike.

_________________
My feedback meter decays into coding. Give me feedback and I make mods.


Top
 Profile  
 
PostPosted: Wed May 13, 2015 1:29 am 
Offline
Sher'Tul Godslayer

Joined: Sat Apr 26, 2003 7:38 pm
Posts: 1970
Location: GMT-8:00
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.


Top
 Profile  
 
PostPosted: Wed May 13, 2015 2:25 am 
Offline
Spiderkin

Joined: Sat Feb 11, 2012 1:12 am
Posts: 543
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.

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.


Top
 Profile  
 
PostPosted: Thu May 14, 2015 7:00 pm 
Offline
Archmage

Joined: Tue Jun 18, 2013 7:24 pm
Posts: 449
Facing is a graphical issue not a code issue, I think?

_________________
Working on a T-Engine game
Veins of the Earth

Veins of the Earth ModDB page


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group