View unanswered posts | View active topics It is currently Tue Apr 16, 2024 5:31 pm



Reply to topic  [ 6 posts ] 
 Check a actors group with a weapon? 
Author Message
User avatar

Joined: Tue Jan 18, 2011 7:50 am
Posts: 170
Location: 2 Miles underground on some planet in a vault.
Reply with quote
Post 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.


Wed Nov 23, 2011 4:52 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Check a actors group with a weapon?
Could you explain it a bit better?


Thu Nov 24, 2011 12:11 am
Profile
User avatar

Joined: Tue Jan 18, 2011 7:50 am
Posts: 170
Location: 2 Miles underground on some planet in a vault.
Reply with quote
Post 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.


Thu Nov 24, 2011 1:07 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post 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.


Thu Nov 24, 2011 1:14 am
Profile
User avatar

Joined: Tue Jan 18, 2011 7:50 am
Posts: 170
Location: 2 Miles underground on some planet in a vault.
Reply with quote
Post 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.....


Thu Nov 24, 2011 2:39 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post 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.


Fri Nov 25, 2011 10:55 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 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.084s | 15 Queries | GZIP : Off ]