Data Realms Fan Forums
http://45.55.195.193/

About attachables
http://45.55.195.193/viewtopic.php?f=73&t=22722
Page 1 of 1

Author:  Asklar [ Sun Apr 17, 2011 10:03 pm ]
Post subject:  About attachables

Is it possible to check if an actor has an attachable attached to it?

Author:  Xery [ Sun Apr 17, 2011 11:03 pm ]
Post subject:  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.

Author:  Asklar [ Mon Apr 18, 2011 1:38 am ]
Post subject:  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?

Author:  zoidberg [ Mon Apr 18, 2011 6:43 am ]
Post subject:  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

Author:  Asklar [ Tue Apr 19, 2011 7:42 pm ]
Post subject:  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?

Author:  zoidberg [ Tue Apr 19, 2011 8:40 pm ]
Post subject:  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?

Author:  Asklar [ Wed Apr 20, 2011 8:04 pm ]
Post subject:  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?

Author:  zoidberg [ Wed Apr 20, 2011 8:44 pm ]
Post subject:  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)

Author:  carriontrooper [ Fri Apr 22, 2011 6:49 am ]
Post subject:  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.

Author:  Asklar [ Fri Apr 22, 2011 6:58 am ]
Post subject:  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!!!!!!!!!!!!

Author:  zoidberg [ Fri Apr 22, 2011 12:58 pm ]
Post subject:  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

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/