context: //note - the ci pngs in the same folder as this are unused. they would have been put in the hud where "KEY" is now, but bitmaps eat a lot of character space.
  
  package GameModeDeathMatchKeys
  {
  	function messageClient(%client, %msg, %a, %slot, %item, %b, %c, %d, %e, %f, %g, %h, %i, %j)
  	{
  		if(isObject(%client) && %client.minigame == $DefaultMinigame)
  		{
  			if(%item == redKeyItem.getID()) //these should add a client var instead of giving you the keys
  			{
  				%client.player.tool[%slot] = 0;
  				%client.DMHasKey_Red = true;
  				return;
  			}
  			if(%item == yellowKeyItem.getID())
  			{
  				%client.player.tool[%slot] = 0;
  				%client.DMHasKey_Yellow = true;
  				return;
  			}
  			if(%item == greenKeyItem.getID())
  			{
  				%client.player.tool[%slot] = 0;
  				%client.DMHasKey_Green = true;
  				return;
  			}
  			if(%item == blueKeyItem.getID())
  			{
  				%client.player.tool[%slot] = 0;
  				%client.DMHasKey_Blue = true;
  				return;
  			}
  		}
  		
  		Parent::messageClient(%client, %msg, %a, %slot, %item, %b, %c, %d, %e, %f, %g, %h, %i, %j);
  	}
  	
  	function Player::ActivateStuff(%this) //this should allow you to utilise the client vars to trigger key matches
  	{
  		%client = %this.client;
  		%keyHas = %client.DMHasKey_Red + %client.DMHasKey_Yellow + %client.DMHasKey_Green + %client.DMHasKey_Blue;
  		
  		if(%keyHas >= 0)
  		{
  			%target = ContainerRayCast(%eye = %this.getEyePoint(), vectorAdd(%eye, vectorScale(%this.getEyeVector(),5)), $TypeMasks::FxBrickObjectType, %this);
  			if(%target)
  			{
  				%target = %target.getID();
  				
  				//edit of key code
  				if(%target.getType() & $TypeMasks::FxBrickAlwaysObjectType)
  				{
  					//determine if color matches or not via hue comparison
  
  					//get brick color
  					%brickRGBA = getColorIDTable(%target.getColorId());
  					%r = getWord(%brickRGBA, 0);
  					%g = getWord(%brickRGBA, 1);
  					%b = getWord(%brickRGBA, 2);
  					%brickH = getWord(RGBtoHSV(%r,%g,%b), 0);
  
  					%brickRGB = %r SPC %g SPC %b;
  					%brickRGB = vectorNormalize(%brickRGB);
  
  					if(%client.DMHasKey_Red)
  					{
  						//get red key color
  						%redKeyRGBA = redKeyImage.colorShiftColor;
  						%r = getWord(%redKeyRGBA, 0);
  						%g = getWord(%redKeyRGBA, 1);
  						%b = getWord(%redKeyRGBA, 2);
  						%redKeyH = getWord(RGBtoHSV(%r,%g,%b), 0);
  
  						%redKeyRGB = %r SPC %g SPC %b;
  						%redKeyRGB = vectorNormalize(%redKeyRGB);
  
  						//compare
  						%redhDiff = mAbs(%redKeyH - %brickH);
  						if(%redhDiff > 0.5)
  							%redhDiff = 1 - %redhDiff;
  
  						%redKeyMatch = 1;
  						if(%redhDiff > 0.1 || (%redKeyH >= 0 && %brickH < 0) || (%redKeyH < 0 && %brickH >= 0))
  							%redKeyMatch = 0;
  					}
  
  					if(%client.DMHasKey_Yellow)
  					{
  						//get yellow key color
  						%yellowKeyRGBA = yellowKeyImage.colorShiftColor;
  						%r = getWord(%yellowKeyRGBA, 0);
  						%g = getWord(%yellowKeyRGBA, 1);
  						%b = getWord(%yellowKeyRGBA, 2);
  						%yellowKeyH = getWord(RGBtoHSV(%r,%g,%b), 0);
  
  						%yellowKeyRGB = %r SPC %g SPC %b;
  						%yellowKeyRGB = vectorNormalize(%yellowKeyRGB);
  
  						//compare
  						%yellowhDiff = mAbs(%yellowKeyH - %brickH);
  						if(%yellowhDiff > 0.5)
  							%yellowhDiff = 1 - %yellowhDiff;
  
  						%yellowKeyMatch = 1;
  						if(%yellowhDiff > 0.1 || (%yellowKeyH >= 0 && %brickH < 0) || (%yellowKeyH < 0 && %brickH >= 0))
  							%yellowKeyMatch = 0;
  					}
  
  					if(%client.DMHasKey_Green)
  					{
  						//get green key color
  						%greenKeyRGBA = greenKeyImage.colorShiftColor;
  						%r = getWord(%greenKeyRGBA, 0);
  						%g = getWord(%greenKeyRGBA, 1);
  						%b = getWord(%greenKeyRGBA, 2);
  						%greenKeyH = getWord(RGBtoHSV(%r,%g,%b), 0);
  
  						%greenKeyRGB = %r SPC %g SPC %b;
  						%greenKeyRGB = vectorNormalize(%greenKeyRGB);
  
  						//compare
  						%greenhDiff = mAbs(%greenKeyH - %brickH);
  						if(%greenhDiff > 0.5)
  							%greenhDiff = 1 - %greenhDiff;
  
  						%greenKeyMatch = 1;
  						if(%greenhDiff > 0.1 || (%greenKeyH >= 0 && %brickH < 0) || (%greenKeyH < 0 && %brickH >= 0))
  							%greenKeyMatch = 0;
  					}
  
  					if(%client.DMHasKey_Blue)
  					{
  						//get blue key color
  						%blueKeyRGBA = blueKeyImage.colorShiftColor;
  						%r = getWord(%blueKeyRGBA, 0);
  						%g = getWord(%blueKeyRGBA, 1);
  						%b = getWord(%blueKeyRGBA, 2);
  						%blueKeyH = getWord(RGBtoHSV(%r,%g,%b), 0);
  
  						%blueKeyRGB = %r SPC %g SPC %b;
  						%blueKeyRGB = vectorNormalize(%blueKeyRGB);
  
  						//compare
  						%bluehDiff = mAbs(%blueKeyH - %brickH);
  						if(%bluehDiff > 0.5)
  							%bluehDiff = 1 - %bluehDiff;
  
  						%blueKeyMatch = 1;
  						if(%bluehDiff > 0.1 || (%blueKeyH >= 0 && %brickH < 0) || (%blueKeyH < 0 && %brickH >= 0))
  							%blueKeyMatch = 0;
  					}
  					
  					%keyMatch = %redKeyMatch + %yellowKeyMatch + %greenKeyMatch + %blueKeyMatch;
  					
  					if(%keyMatch >= 1)
  						%target.onKeyMatch(%this);
  					else
  						%target.onKeyMismatch(%this);
  				}
  			}
  		}
  		
  		Parent::ActivateStuff(%this);
  	}
  	
  	function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
  	{
  		if(%col.canPickup && isObject(%obj.client))
  		{
  			if(%col.dataBlock $= "redKeyItem")
  			{
  				%obj.client.DMHasKey_Red = true;
  				centerPrint(%obj.client, "<just:right>\c0Picked up a red key.", 5);
  			}
  			else if(%col.dataBlock $= "yellowKeyItem")
  			{
  				%obj.client.DMHasKey_Yellow = true;
  				centerPrint(%obj.client, "<just:right>\c3Picked up a yellow key.", 5);
  			}
  			else if(%col.dataBlock $= "greenKeyItem")
  			{
  				%obj.client.DMHasKey_Green = true;
  				centerPrint(%obj.client, "<just:right>\c2Picked up a green key.", 5);
  			}
  			else if(%col.dataBlock $= "blueKeyItem")
  			{
  				%obj.client.DMHasKey_Blue = true;
  				centerPrint(%obj.client, "<just:right>\c1Picked up a blue key.", 5);
  			}
  			else
  			{
  				Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
  				return;
  			}
  			
  			serverPlay3D(Beep_Key_Sound, %obj.getPosition());
  			if(isObject(%col.spawnbrick))
  			{
  				%col.fadeOut();
  				%col.schedule(%col.spawnbrick.itemrespawntime, "fadeIn");
  			}
  			else
  				%col.schedule(10, delete);
  			
  			%this.onPickup(%obj, %player);
  			return;
  		}
  		
  
gt: 		Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);