Data Realms Fan Forums
http://45.55.195.193/

problem with smoke-spawning bullet lua (solved via workaroun
http://45.55.195.193/viewtopic.php?f=73&t=46263
Page 1 of 1

Author:  Hoovytaurus [ Fri Apr 06, 2018 12:59 pm ]
Post subject:  problem with smoke-spawning bullet lua (solved via workaroun

Code:
function Create(self)

   local Effect
   local Offset = self.Vel*(20*TimerMan.DeltaTimeSecs)   -- the effect will be created the next frame so move it one frame backwards towards the barrel
   
   for i = 1, 2 do
      Effect = CreateMOSParticle("Tiny Smoke Ball 1", "Base.rte")
      if Effect then
         Effect.Pos = self.Pos - Offset
         Effect.Vel = (self.Vel + Vector(RangeRand(-20,20), RangeRand(-20,20))) / 30
         MovableMan:AddParticle(Effect)
      end
   end
   
   if PosRand() < 0.5 then
      Effect = CreateMOSParticle("Side Thruster Blast Ball 1", "Base.rte")
      if Effect then
         Effect.Pos = self.Pos - Offset
         Effect.Vel = self.Vel / 10
         MovableMan:AddParticle(Effect)
      end
   end
end


this code works fine until you come too close to an entity that deletes (absorbs, gets hit by) the bullet before it has travelled a frame's worth. this then spawns the smoke way behind.

when it comes to walls and other terrain being shot, it spawns the smoke at its current position if you are too close to the wall (shooting into it). that is, too far forward.

one fix would be to somehow detect the origin weapon and use its muzzle position. is it possible to do that with a reliable method, i.e. not closest-weapon or anything like that?

another would be to somehow run the code on the very creation. is that possible or will it always be one frame too late?

EDIT: solved by just spawning smoke from the weapon's code. took a while to convert everything but it works.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/