View unanswered posts | View active topics It is currently Fri Apr 19, 2024 11:06 am



Reply to topic  [ 8 posts ] 
 Check if an actor is dying/dead nearby? 
Author Message

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post 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".


Sat Jun 13, 2009 6:45 pm
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1359
Location: USA
Reply with quote
Post 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       


Sat Jun 13, 2009 6:50 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post 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


Sat Jun 13, 2009 7:05 pm
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1359
Location: USA
Reply with quote
Post 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.


Sat Jun 13, 2009 7:10 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post 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.


Sat Jun 13, 2009 7:17 pm
Profile

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: Check if an actor is dying/dead nearby?
Thanks, that worked mail2345! :D


Sat Jun 13, 2009 8:24 pm
Profile

Joined: Thu Apr 23, 2009 11:28 pm
Posts: 21
Reply with quote
Post Re: Check if an actor is dying/dead nearby?
Do I smell a revival mod? That'd be a pretty neat use for it.


Sun Jun 14, 2009 3:13 am
Profile

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post 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.


Sun Jun 14, 2009 3:26 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.064s | 15 Queries | GZIP : Off ]