View unanswered posts | View active topics It is currently Tue Apr 16, 2024 2:46 pm



Reply to topic  [ 4 posts ] 
 Conditional gibs 
Author Message
User avatar

Joined: Sun Oct 29, 2006 4:26 am
Posts: 298
Reply with quote
Post Conditional gibs
This is probably covered already, but I was at work and I had a thought - is there a function to add gibs only if a certain condition is met? In this case its if a MOSRotating hits a certain frame, but it could be anything I suppose.

Edit
To clarify I mean something that adds gibs to the parent rather than cause extra gibs to fly out. I mean like if you blow it up before whatever frame, it gibs x, but if you blow it up after that it gibs x + whatever else.


Fri Aug 03, 2012 4:20 pm
Profile YIM WWW
User avatar

Joined: Wed May 20, 2009 3:10 pm
Posts: 366
Location: Århus, Denmark
Reply with quote
Post Re: Conditional gibs
Djinn wrote:
This is probably covered already, but I was at work and I had a thought - is there a function to add gibs only if a certain condition is met? In this case its if a MOSRotating hits a certain frame, but it could be anything I suppose.

Edit
To clarify I mean something that adds gibs to the parent rather than cause extra gibs to fly out. I mean like if you blow it up before whatever frame, it gibs x, but if you blow it up after that it gibs x + whatever else.


Use lua,

Make a function "function Destroy(self)", and generate the gibs with the CreateMOSRotating or whatever you need

Code:
function Destroy(self)
  if self.Frame == whateverFrame then
    local Gib = CreateMOSRotating("Your gib");
    Gib.Pos = self.Pos + self:RotateOffset(Vector(X-offset, Y-offset));
    Gib.Vel = self.Vel + Vector(math.random(-maxspeed,maxspeed),math.random(-maxspeed,maxspeed));
    Gib.RotAngle = self.RotAngle;
    Gib.AngularVel = self.AngularVel + math.random(-maxAngularVel,maxAngularVel);
    Gib.HFlipped = self.HFlipped;
    MovableMan:AddParticle(Gib);
  end
end


Fri Aug 03, 2012 4:59 pm
Profile
User avatar

Joined: Sun Oct 29, 2006 4:26 am
Posts: 298
Reply with quote
Post Re: Conditional gibs
So if I wanted to have multiple different occassions of gibs being added all I would have to do is add some elseif self.frame = x and add them through that. The only other thing I'd have to do is create more local variables for the gibs, correct?


Fri Aug 03, 2012 5:26 pm
Profile YIM WWW
User avatar

Joined: Wed May 20, 2009 3:10 pm
Posts: 366
Location: Århus, Denmark
Reply with quote
Post Re: Conditional gibs
Djinn wrote:
So if I wanted to have multiple different occassions of gibs being added all I would have to do is add some elseif self.frame = x and add them through that. The only other thing I'd have to do is create more local variables for the gibs, correct?


Yup

Oh and a small thing

add this around the script

if ((self.Pos.Y > 0 and self.Pos.Y < SceneMan.SceneHeight) or SceneMan.SceneWrapsY) and ((self.Pos.X > 0 and self.Pos.X < SceneMan.SceneWidth) or SceneMan.SceneWrapsX) then

end

so it looks like this

Code:
function Destroy(self)
  if ((self.Pos.Y > 0 and self.Pos.Y < SceneMan.SceneHeight) or SceneMan.SceneWrapsY) and ((self.Pos.X > 0 and self.Pos.X < SceneMan.SceneWidth) or SceneMan.SceneWrapsX) then
    if self.Frame == whateverFrame then

      --Repeat for each gib
      local Gib = CreateMOSRotating("Your gib");
      Gib.Pos = self.Pos + self:RotateOffset(Vector(X-offset, Y-offset));
      Gib.Vel = self.Vel + Vector(math.random(-maxspeed,maxspeed),math.random(-maxspeed,maxspeed));
      Gib.RotAngle = self.RotAngle;
      Gib.AngularVel = self.AngularVel + math.random(-maxAngularVel,maxAngularVel);
      Gib.HFlipped = self.HFlipped;
      MovableMan:AddParticle(Gib);
    end
  end
end


Fri Aug 03, 2012 5:34 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

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.045s | 15 Queries | GZIP : Off ]