View unanswered posts | View active topics It is currently Thu Dec 26, 2024 5:47 pm



Reply to topic  [ 11 posts ] 
 About attachables 
Author Message
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 About attachables
Is it possible to check if an actor has an attachable attached to it?


Sun Apr 17, 2011 10:03 pm
Profile
User avatar

Joined: Sat Feb 26, 2011 10:29 am
Posts: 163
Reply with quote
Post Re: About attachables
Asklar wrote:
Is it possible to check if an actor has an attachable attached to it?


Search "luaguns", I remeber there's a gun can just/only take arms and legs away from body. If so, the lua shall can check attachables.


Sun Apr 17, 2011 11:03 pm
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: About attachables
I think that what I want to do is a bit more complex (I think).

I made some particles that damage actors with lua, and I made an actor that is resistant to that particles.
I made a helmet to it, that it's like a gas mask, so someone gave me the idea to make the particles damage the actor if it's helmet was blown off.

Aside from being laggy (it will probably be, considering it's quite laggy right now), is something like this possible?


Mon Apr 18, 2011 1:38 am
Profile

Joined: Fri Feb 25, 2011 3:52 pm
Posts: 39
Reply with quote
Post Re: About attachables
yes, you can

imagine that your particle already has a pointer to the actor, which you want to check for wearing helmet

self.actor is a pointer
"helmet" - is a word to search for, while cycling through actor attachables
you can search for exact preset as snown in commented line
it will make the particle to ignore collisions with "self.actor" if it has any att's with "helmet" in presetname
Code:
   for i = 1, MovableMan:GetMOIDCount() - 1 do
      if MovableMan:GetMOFromID(i).RootID == self.actor.ID and i ~= self.actor.ID then
         local att = MovableMan:GetMOFromID(i)
         if string.find(string.lower(att.PresetName), "helmet") then
--         if att.PresetName == "helmet"
            self:SetWhichMOToNotHit(self.actor, -1)
         end
      end
   end


Mon Apr 18, 2011 6:43 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: About attachables
Excuse me, but I plainly didn't get the code.

I mean, I read it and I can't get much of it.
And a question, would it lag much?


Tue Apr 19, 2011 7:42 pm
Profile

Joined: Fri Feb 25, 2011 3:52 pm
Posts: 39
Reply with quote
Post Re: About attachables
Code:
function Update(self)
   local actor
   for actor in MovableMan.Actors do -- cycle through all actors
      if (actor.Pos-self.Pos).Magnitude < 100 then -- look for the closest one
         for i = 1, MovableMan:GetMOIDCount() - 1 do -- cycle through all moids
            if MovableMan:GetMOFromID(i).RootID == actor.ID and i ~= actor.ID then -- find only selected actor's children
               local att = MovableMan:GetMOFromID(i) -- get the attachable from it's id
               if string.find(string.lower(att.PresetName), "helmet") then -- find the word "helmet" in attachable's presetname
--            if att.PresetName == "helmet" -- or search for exact preset
                  self:SetWhichMOToNotHit(actor, -1) -- apply some code here (currently it forces itself to ignore any collisions with actor)
               end
            end
         end
      end
   end
end


^ this is gas particle script
i don't think it would be laggy

you understand me now?


Tue Apr 19, 2011 8:40 pm
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: About attachables
Code:
function Update(self)
   local actor
   for actor in MovableMan.Actors do
      if (actor.Pos-self.Pos).Magnitude < 100 then
         for i = 1, MovableMan:GetMOIDCount() - 1 do
            if MovableMan:GetMOFromID(i).RootID == actor.ID and i ~= actor.ID then
               local att = MovableMan:GetMOFromID(i)
                    if att.PresetName ~= "Gas Mask" then
                   actor.Health = actor.Health - 1
               end
            end
         end
      end
   end
end



Got it. Did some slight modifications, would it work?


Wed Apr 20, 2011 8:04 pm
Profile

Joined: Fri Feb 25, 2011 3:52 pm
Posts: 39
Reply with quote
Post Re: About attachables
yeah, i think it's right code
still, you'd better test it and post the results (cause i don't want to do it >:3)


Wed Apr 20, 2011 8:44 pm
Profile
User avatar

Joined: Mon Apr 13, 2009 12:27 pm
Posts: 813
Location: Yogyakarta, Indonesia. A slice o' paradise.
Reply with quote
Post Re: About attachables
Somehow I get a feeling that script's gonna go and deduct 1 HP for every non-gas mask attachable attached to the actor.

What if you check if the actor has a gas mask or not, then applying damage to the actors not wearing gas mask?

So it'll go like this:
-check if there's an actor within 100 pix
-check if actor do not have any attachables with 'gas mask' in its name
-if actor does not have gas mask then do damage

test your code first. I think it will do wonky stuff.


Fri Apr 22, 2011 6:49 am
Profile YIM WWW
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: About attachables
FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU-
I don't know how or when, my mod got deleted!!!
I'll have to check if I have any back-ups on my mail or something.
CRAAAAAAAAAAAAAP!!!!!!!!!!!!


Fri Apr 22, 2011 6:58 am
Profile

Joined: Fri Feb 25, 2011 3:52 pm
Posts: 39
Reply with quote
Post Re: About attachables
Code:
function Update(self)
   local actor
   for actor in MovableMan.Actors do
      if (actor.Pos-self.Pos).Magnitude < 100 then
         local check = false
         for i = 1, MovableMan:GetMOIDCount() - 1 do
            if MovableMan:GetMOFromID(i).RootID == actor.ID and i ~= actor.ID then
               local att = MovableMan:GetMOFromID(i)
               if att.PresetName == "Gas Mask" then
                   check = true
               end
            end
         end
         if not check then
            actor:AddHealth(-1)
         end
      end
   end
end


^ that should work good

carriontrooper, thanks


Fri Apr 22, 2011 12:58 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 11 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.078s | 13 Queries | GZIP : Off ]