Data Realms Fan Forums http://45.55.195.193/ |
|
Check a actors group with a weapon? http://45.55.195.193/viewtopic.php?f=73&t=26496 |
Page 1 of 1 |
Author: | ludsoe [ Wed Nov 23, 2011 4:52 am ] |
Post subject: | Check a actors group with a weapon? |
I'd like to know how i can locate a actor and check its group after killing it with a particle from a weapon or tool? I plan on attaching it to a diggerish tool. |
Author: | Asklar [ Thu Nov 24, 2011 12:11 am ] |
Post subject: | Re: Check a actors group with a weapon? |
Could you explain it a bit better? |
Author: | ludsoe [ Thu Nov 24, 2011 1:07 am ] |
Post subject: | Re: Check a actors group with a weapon? |
I need a lua that checks when a actor is killed by a weapon. Then im going to make it check the actors group. And if it gets a positive match for a target group it continues. *Groups as in AddToGroup = "Blah blah"* I just need the part that detects if the weapon killed a actor. |
Author: | Asklar [ Thu Nov 24, 2011 1:14 am ] |
Post subject: | Re: Check a actors group with a weapon? |
By an specific weapon, or any weapon? In the case it is a specific weapon, you can make the particles see which is the nearest actor, check how much life it has (0 or less) or if it is dead and then add it to a group. |
Author: | ludsoe [ Thu Nov 24, 2011 2:39 am ] |
Post subject: | Re: Check a actors group with a weapon? |
Asklar wrote: In the case it is a specific weapon, you can make the particles see which is the nearest actor, check how much life it has (0 or less) or if it is dead and then add it to a group. Not sure how to translate that into code..... |
Author: | Asklar [ Fri Nov 25, 2011 10:55 pm ] |
Post subject: | Re: Check a actors group with a weapon? |
This code would be set to the pixel or whatever you are using as the ammo. Code: function Create(self) KilledActorsOrSomethingLikeThis = 0 end function Update(self) for actor in MovableMan.Actors do self.Distance = SceneMan:ShortestDistance(self.Pos,actor.Pos,true).Magnitude if self.Distance <= 30 and actor.PresetName == "<Actor you specifically want to kill>" and actor.Health > 0 then actor.Health = actor.Health - 10 if actor.Health <= 0 or actor:IsDead() then KilledActorsOrSomethingLikeThis = KilledActorsOrSomethingLikeThis + 1 end end end end I highly doubt if it will work properly, but as a rough idea it could work. By the way, I just used a numeric variable instead of a table because I can't remember how to use tables, and because I suppose you just want to store the number of killed things. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |