View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:09 am



Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
 TDExplosives that collide with actors 
Author Message

Joined: Fri Dec 30, 2011 3:33 am
Posts: 276
Reply with quote
Post Re: TDExplosives that collide with actors
Instantly replace the TDExplosive with a MOSRotating with the same vel, angularvel, etc.


Fri Jul 27, 2012 2:22 pm
Profile
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post Re: TDExplosives that collide with actors
Just forget about it. I just wanted for the TDExplosive itself to collide, because I wanted it to be up-pickable. I guess I'll have to do it the same way as the Ronin impact explosive, then.


Fri Jul 27, 2012 2:32 pm
Profile

Joined: Fri Dec 30, 2011 3:33 am
Posts: 276
Reply with quote
Post Re: TDExplosives that collide with actors
If you want it to be pick-upable, that's no biggie; convert it back when it's at slow velocities.

You can pick up the Blue Bombs that the Zombies throw even when the fuses are burning, so long as they're at rest.


Fri Jul 27, 2012 2:34 pm
Profile
User avatar

Joined: Sat Jul 31, 2010 10:01 pm
Posts: 42
Reply with quote
Post Re: TDExplosives that collide with actors
First note: I wasn't sure if you were after the bounce specifically, or if you wanted them to impact as well. As it stands, this script will make them bounce off, but will not impact. You can probably re-tool it to... apply forces, or wounds, or gib itself on contact. Who knows. But anyway, this at least will bounce off, as tested with the ronin stone and pineapple grenade. I'd expand it myself if I hadn't spent the better part of a day just mucking through it.

If someone better at lua than me wants to go through and make this not horrible and kludgey, go ahead.

Just put this into your favourite text editor, save it as <<Something>>.lua (insert name, I used NadeCollide.lua, but what ever) in an appropriate .rte folder, and add ScriptPath = Path/To/Script/<<Something>>.lua to your TDExplosive.

Code:
function Create(self)
   self.checking = 0;
   self.bounceloss = 0.3; -- Velocity is negatively multiplied by this, so a stone going right at a velocity of 15 u/s would end up going left at a velocity of 4.5 u/s (using the value of 0.3 for bounceloss).
   self.kludge = Vector();
   self.usekludge = false;
end

function Update(self)
   if self.checking <= 0 then
      for actor in MovableMan.Actors do
         local distcheck = SceneMan:ShortestDistance(self.Pos,actor.Pos,true).Magnitude
         if distcheck < 50 then
            local actorAhead = SceneMan:CastObstacleRay(self.Pos, self.Vel, self.kludge, Vector(), self.ID, self.Team, 128, 0);
            if actorAhead > 0 then
               self.checking = 2;
               if actorAhead < self.Vel.Magnitude / 2 then self.usekludge = true end;
               break
            end
         end
      end
   elseif self.checking > 1 then
      self.checking = self.checking - 1;
      if self.kludge == true then
         self.Pos = self.Pos + self.kludge;
      end
   else
      if self.Vel.Magnitude >= 1 then
         if math.abs(self.Vel.X) - math.abs(self.Vel.Y) > 2 then
            self.Vel.X = self.Vel.X * -self.bounceloss;
         elseif math.abs(self.Vel.X) - math.abs(self.Vel.Y) < 2 then
            self.Vel.Y = self.Vel.Y * -self.bounceloss;
         else
            self.Vel = self.Vel * -self.bounceloss;
         end
      end
      self.checking = 0;
   end
end


Sun Jul 29, 2012 5:38 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 19 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: No registered users


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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.047s | 13 Queries | GZIP : Off ]