The echos print out fine, but it does not seem to register %BadCount >= 1. So is the problem in onAdd or in the for loop?
new SimSet(BadBrickTracker);
package BadBricks
{
function brick1x1x5Data::onAdd(%this)
{
BadBrickTracker.add(%this);
parent::onAdd(%this);
}
function ProjectileData_tez::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);
echo("===> tez 1: beginning onCollision");
if(%col.getClassName() $= "fxDTSBrick")
{
echo("===> tez 2: hit a brick");
%brick = %col;
%Owner = %brick.client;
%OwnerID = %brick.client.bl_id;
if(%OwnerID != %obj.client.bl_id) //don't want them to do this to their own bricks
{
echo("===> tez 3: brick not hit by owner");
%count = BadBrickTracker.getCount();
for(%i = 0; %i < %count; %i++)
{
if(BadBrickTracker.getObject(%i).getGroup().BL_ID == %ownerID)
%BadCount++;
}
if(%BadCount >= 1)
{
%BadBrick = %col.getdatablock().getID();
if(%BadBrick == brick1x1x5Data.getID())
%brick.delete();
}
}
}
}
};
activatePackage(BadBricks);