That's a daft limitation. I seem to remember that being a nuisance at some point though.
Code:
function Create(self)
self.table = {};
function self:PutActorList(pointer, Team)
for actor in MovableMan.Actors do
if actor.Team == Team then
table.insert(pointer,actor);
end
end
end
end
function Update(self)
for k,v in ipairs(self.table) do
if MoveableMan:ValidMO(v[1]) and v[3]:ElapsedSimTimeMS() < v[4] then --double safeguard.
if #v[2] == 0 then
v = nil;
else
v[1]:SetWhichMOToNotHit(table.remove(v[2]),-1);
end
else
v = nil;
end
end
for particle in MovableMan.Particles do
if particle.Age <= TimerMan.DeltaTimeMS then
--if that doesn't work, delete it and uncomment the following. Not sure when age is applied.
--[[if particle.PresetName ~= "FRIENDLY FIRE ON" then
particle.PresetName = "FRIENDLY FIRE ON"; ]]--
if particle.HitsMOs and particle.Lifetime > 60 then
local index = (math.random(1000000)); --it's only a temporary thing anyway
self.table[index] = {particle, {}, Timer(), particle.Lifetime};
local curdist = 50
local friendlyactor = "a"
local sd = SceneMan:ShortestDistance;
for actor in MovableMan.Actors do
local dist = sd(actor.Pos,particle.Pos,true);
if dist < curdist then
curdist = dist;
friendlyactor = actor;
end
end
if friendlyactor ~= "a" then
self:PutActorList(self.table[index][2],friendlyactor.Team);
end
end
end
end
end
not sure I can do that with indexes and particle pointers, considering how finicky CC's lua implementation is, but unless I've made some idiot typo like in the previous version (HitsMOs vs particle.HitsMOs) it
should work.
EDIT: hold on, reworking it, forgot to add a handler for when the particles don't exist anymore. *idiotidiotidiot*
EDIT2: done, hopefully ValidMO works for pointers. That should be a sufficient framework for someone to debug in any case.