local oldModBP = ModBlueprints 
function ModBlueprints(all_bps) 
   oldModBP(all_bps) 

	    for id,bp in all_bps.Unit do      	
			local capcosts
			if bp.Economy then 
				local energy, mass, enma
					mass = bp.Economy.BuildCostMass
					energy = bp.Economy.BuildCostEnergy / 100
					enma = energy + mass
					if enma < 35 then
						enma = 35
					end
					capcosts = math.pow( (enma - 25 ), 0.85 ) / 300
	  				if capcosts > 50 then 
	  					capcosts = 50
					end
					if capcosts < 0.15 then 
	  					capcosts = 0.15
					end
  					bp.General.CapCost = capcosts
			end
			
			for i, cat in bp.Categories do
				if cat == 'STRUCTURE' then
					bp.General.CapCost = capcosts / 2
				elseif cat == 'DEFENSE' or cat == 'STRATEGIC' or cat == 'ARTILLERY' or cat == 'EXPERIMENTAL' then
					bp.General.CapCost = capcosts
					break
				end	
			end
			for i, cat in bp.Categories do
				if cat == 'COMMAND' then
					bp.General.CapCost = 1
					break
				end	
			end
		end

end