Data Realms Fan Forums
http://45.55.195.193/

Lua Question
http://45.55.195.193/viewtopic.php?f=1&t=15111
Page 1 of 1

Author:  Shapeshifters [ Mon Jun 01, 2009 4:05 am ]
Post subject:  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?

Author:  mail2345 [ Mon Jun 01, 2009 4:17 am ]
Post subject:  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.

Author:  Grif [ Mon Jun 01, 2009 5:00 am ]
Post subject:  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.

Author:  CrazyMLC [ Mon Jun 01, 2009 5:53 am ]
Post subject:  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.

Author:  Grif [ Mon Jun 01, 2009 5:58 am ]
Post subject:  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.

Author:  CrazyMLC [ Mon Jun 01, 2009 6:01 am ]
Post subject:  Re: Lua Question

Hm.
He wanted to code for that, and now so do I

Author:  piipu [ Mon Jun 01, 2009 8:18 am ]
Post subject:  Re: Lua Question

You could also use CastMORay to find out if the particle has collided with something and then gib that something.

Author:  Shapeshifters [ Tue Jun 02, 2009 12:53 am ]
Post subject:  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?

Author:  piipu [ Tue Jun 02, 2009 9:07 am ]
Post subject:  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

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