Here's a quick, untested version.
function serverCmdWandColorArea( %cl )
{
%status = ( %cl.wandColorArea = !%cl.wandColorArea ? "enabled" : "disabled" );
messageClient( %cl, '', "\c6Bricks of the same color being affected by the Wand is now " @ %status @ "." );
}
function wandColorArea( %obj, %col, %color, %count )
{
if ( !%obj.client.wandColorArea || %count >= 500 )
{
return false;
}
%db = %col.getDataBlock();
%ai = %col.angleId;
%sz = %db.brickSizeZ;
if ( %ai % 2 == 1 )
{
%sx = %db.brickSizeY;
%sy = %db.brickSizeX;
}
else
{
%sx = %db.brickSizeX;
%sy = %db.brickSizeY;
}
%box = ( %sx * 0.5 + 0.6 ) SPC ( %sy * 0.5 + 0.6 ) SPC ( %sz * 0.2 + 0.3 );
%end = true;
initContainerBoxSearch( %col.getPosition(), %box, $TypeMasks::FxBrickAlwaysObjectType );
while ( isObject( %find = containerSearchNext() ) )
{
%trust = getTrustLevel( %obj.client, %find );
if ( %find.isPlanted() && %find.getColorID() == %color && %trust >= 2 )
{
if ( !wandColorArea( %obj, %find, %color, %count++ ) )
{
%end = false;
break;
}
}
}
%col.killBrick();
return %end;
}
package wand_color_area_package
{
function wandImage::onHitObject( %this, %obj, %slot, %col, %pos, %normal )
{
if ( %obj.client.wandColorArea && !wandColorArea( %obj, %col, %col.getColorID() ) )
{
%obj.client.centerPrint( "\c6Brick limit reached.", 2 );
}
if ( isObject( %col ) )
{
parent::onHitObject( %this, %obj, %slot, %col, %pos, %normal );
}
}
};
activatePackage( "wand_color_area_package" );