Author |
Message |
Shapeshifters
Joined: Thu Jun 12, 2008 10:06 pm Posts: 68 Location: Texas
|
Lua Question
I am not very well in the lua codes, and I was wondering if it was actually possible to make things happen when a particle damages an actor.
Example: Lets say when bullet hits actor it causes the actor to gib.
I need to know if its possible or not. If it is, can you please give me a copy of the code for it?
|
Mon Jun 01, 2009 4:05 am |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
Re: Lua Question
Check if the health changes?
Better yet, have the wounds spawn particles that communitcate with the nearest actor with the right PresetName.
|
Mon Jun 01, 2009 4:17 am |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Lua Question
On destroy have the nearest actor gib if it's on an enemy team?
Really there's tons of ways to do it.
|
Mon Jun 01, 2009 5:00 am |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Lua Question
Hes using an example to find out how to do something, and he means when the... sigh.
Actor A shoots actor B Actor B has code to make it so that when he is shot he explodes. Boom.
not
Actor A shoots actor B Actor B has code to make it so that when he is shot the shooter explodes. Boom.
|
Mon Jun 01, 2009 5:53 am |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Lua Question
That's what my code would do?
On the destroy function of a PARTICLE find the nearest actor and if it's within a certain distance gib it.
|
Mon Jun 01, 2009 5:58 am |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Lua Question
Hm. He wanted to code for that, and now so do I
|
Mon Jun 01, 2009 6:01 am |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
Re: Lua Question
You could also use CastMORay to find out if the particle has collided with something and then gib that something.
|
Mon Jun 01, 2009 8:18 am |
|
|
Shapeshifters
Joined: Thu Jun 12, 2008 10:06 pm Posts: 68 Location: Texas
|
Re: Lua Question
Grif wrote: That's what my code would do?
On the destroy function of a PARTICLE find the nearest actor and if it's within a certain distance gib it. Grif, could you post some code please. So you could gib it, or do whatever you wanted with it right?
|
Tue Jun 02, 2009 12:53 am |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
Re: Lua Question
Code: function Update(self) self.atarget = (SceneMan:CastMORay(Vector(self.Pos.X - self.Vel.X,self.Pos.Y - self.Vel.Y),Vector(self.Vel.X,self.Vel.Y),0,0,true,5)) --check if self is colliding with any MO. If yes, returns MOID of that MO. self.target = MovableMan:GetMOFromID(MovableMan:GetRootMOID(self.atarget)) --get the root MO from the MOID if self.target ~= nil then --if collision happened --do stuff to the MO self.target:GibThis() end end
|
Tue Jun 02, 2009 9:07 am |
|
|
|