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