Data Realms Fan Forums http://45.55.195.193/ |
|
Check if an actor is dying/dead nearby? http://45.55.195.193/viewtopic.php?f=73&t=15354 |
Page 1 of 1 |
Author: | numgun [ Sat Jun 13, 2009 6:45 pm ] |
Post subject: | Check if an actor is dying/dead nearby? |
I need some help with this, the point is that the script is supposed to check for an actor nearby that is dead or dying. heres a part of the code I made: Code: for actor in MovableMan.Actors do local avgx = actor.Pos.X - self.Pos.X; local avgy = actor.Pos.Y - self.Pos.Y; local dist = math.sqrt(avgx ^ 2 + avgy ^ 2); if dist < curdist and actor.Status > 2 then So it checks for any guy within the range and checks if he's dying. It seems the "actor.Status > 2" statement is not right, then what is? Lua console says "trying to compare number with nil". |
Author: | Mind [ Sat Jun 13, 2009 6:50 pm ] |
Post subject: | Re: Check if an actor is dying/dead nearby? |
actor.Health is HP. You would do Code: for actor in MovableMan.Actors do local avgx = actor.Pos.X - self.Pos.X; local avgy = actor.Pos.Y - self.Pos.Y; local dist = math.sqrt(avgx ^ 2 + avgy ^ 2); if dist < "insert youe distance here" and actor.Health < "Health here"then "do whatever you want here" end end |
Author: | mail2345 [ Sat Jun 13, 2009 7:05 pm ] |
Post subject: | Re: Check if an actor is dying/dead nearby? |
Code: for actor in MovableMan.Actors do local avgx = actor.Pos.X - self.Pos.X; local avgy = actor.Pos.Y - self.Pos.Y; local dist = math.sqrt(avgx ^ 2 + avgy ^ 2); if dist < curdist and actor.Status > 2 then I don't think status works. I would do something like Code: if dist < curdist and (actor:IsDead() or actor.Health <= 0) then |
Author: | Mind [ Sat Jun 13, 2009 7:10 pm ] |
Post subject: | Re: Check if an actor is dying/dead nearby? |
mail2345 wrote: Code: for actor in MovableMan.Actors do local avgx = actor.Pos.X - self.Pos.X; local avgy = actor.Pos.Y - self.Pos.Y; local dist = math.sqrt(avgx ^ 2 + avgy ^ 2); if dist < curdist and actor.Status > 2 then I don't think status works. I would do something like Code: if dist < curdist and (actor:IsDead() or actor.Health <= 0) then Bad thing is i'm pretty sure checking if actors are dead can be buggy. |
Author: | mail2345 [ Sat Jun 13, 2009 7:17 pm ] |
Post subject: | Re: Check if an actor is dying/dead nearby? |
This little nesting thing might help: [ Entity [Scene Objects[Movable Objects [MOPixels] [MOSprites [ MOSRotatings [Actors [actor types... [dead actors] ] ] [Attachables [HeldDevice[ThrownDevice[TDExplosive]] [HDFirearm] ] [AEmitters] ] ] ] ] ] Dead actors that have not settled or gibbed are still actors. Gibbed actors parts belong in MOSRotating. Settled actors are terrain, and not on the little diagram. |
Author: | numgun [ Sat Jun 13, 2009 8:24 pm ] |
Post subject: | Re: Check if an actor is dying/dead nearby? |
Thanks, that worked mail2345! |
Author: | Polymorph [ Sun Jun 14, 2009 3:13 am ] |
Post subject: | Re: Check if an actor is dying/dead nearby? |
Do I smell a revival mod? That'd be a pretty neat use for it. |
Author: | numgun [ Sun Jun 14, 2009 3:26 am ] |
Post subject: | Re: Check if an actor is dying/dead nearby? |
Polymorph wrote: Do I smell a revival mod? That'd be a pretty neat use for it. Nope. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |