View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:53 am



Reply to topic  [ 4 posts ] 
 Insta gib not working 
Author Message
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post Insta gib not working
I have an insta-gib thrown weapon, but it isn't working. I think it has something to do with my distance finders. It won't gib anything. Could you point out the obvious problems I cannot seem to see? Thanks.

Code:
function Create(self)
   self.Parent = nil;
   self.PlayerTeam = Activity.TEAM_1;
   
   --Find out who threw it
   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 < 35 then
         self.Parent = actor;
      end
   end
end

function Destroy(self)

   --Find out if it hit someone
   for actor in MovableMan.Actors do
      if actor ~= self.Parent then
         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 < 35 then
            local victim = actor;
         end
      end
   end
   
   --Punish the victim
   if victim ~= nil then
      victim:GibThis();
   end
end


Sun Jul 18, 2010 3:54 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Insta gib not working
Try "ToActor(victim):GibThis()" instead of "victim:GibThis()".


Sun Jul 18, 2010 4:57 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Insta gib not working
Actually, victim is created locally, inside of the for loop, inside of an if inside of an if.
So either change local victim = actor to victim = actor, or change it to actor:GibThis()


Sun Jul 18, 2010 4:59 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Insta gib not working
Ew, global variables. You're better off doing the second thing mail said.


Sun Jul 18, 2010 5:01 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.042s | 13 Queries | GZIP : Off ]