
--Randomize findings for dirt sifting.
function HCSiftDirt(items, result, player)
    skill = player:getPerkLevel(Perks.PlantScavenging);

    rockLvl0 = 1024+(18.6*skill);
    rockLvl1 = 512+(18.6*skill);
    rockLvl2 = 256+(18.6*skill);
    rockLvl3 = 128+(18.6*skill);
    rockLvl4 = 64+(18.6*skill);
    rockLvl5 = 32+(18.6*skill);
    rockLvl6 = 16+(18.6*skill);
    rockLvl7 = 8+(18.6*skill);
    rockLvl8 = 4+(18.6*skill);
    rockLvl9 = 2+(18.6*skill);
    rockLvl10 = 1+(18.6*skill);
    nothing = 2048-(204.8*skill);
    chance = ZombRand(4096);
    secondChance = 0;
    if chance <= rockLvl10 then
        secondChance = ZombRand(5);
        if secondChance == 0 then
            player:getInventory():AddItem("Hydrocraft.HCGoldore");
        elseif secondChance == 1 then
            player:getInventory():AddItem("Hydrocraft.HCTrashlarge");
		elseif secondChance == 2 then
            player:getInventory():AddItem("Hydrocraft.HCUraniumore");
		elseif secondChance == 3 then
            player:getInventory():AddItem("Hydrocraft.HCMeteorite");
		elseif secondChance == 4 then
            player:getInventory():AddItem("Hydrocraft.HCTungstenore");		
        end
    elseif chance <= rockLvl9+rockLvl10 then
		secondChance = ZombRand(5);
		if secondChance == 0 then
			player:getInventory():AddItem("Hydrocraft.HCSilverore");
		elseif secondChance == 1 then
			player:getInventory():AddItem("Hydrocraft.HCLithiumore");
		elseif secondChance == 2 then
			player:getInventory():AddItem("Hydrocraft.HCStonearrowhead");
		elseif secondChance == 3 then
			player:getInventory():AddItem("Hydrocraft.HCTrashsmall");
		elseif secondChance == 4 then
			player:getInventory():AddItem("Hydrocraft.HCTitaniumore");				
		end
    elseif chance <= rockLvl8+rockLvl9+rockLvl10 then	
		secondChance = ZombRand(5);
        if secondChance == 0 then
            player:getInventory():AddItem("Hydrocraft.HCBauxiteore");
        elseif secondChance == 1 then
            player:getInventory():AddItem("Hydrocraft.HCCinnabar");
		elseif secondChance == 2 then
            player:getInventory():AddItem("Hydrocraft.HCMagnetite");
		elseif secondChance == 3 then
			player:getInventory():AddItem("Hydrocraft.HCZincore");	
		elseif secondChance == 4 then
			player:getInventory():AddItem("Hydrocraft.HCNickelore");			
        end
    elseif chance <= rockLvl7+rockLvl8+rockLvl9+rockLvl10 then
        secondChance = ZombRand(6);
        if secondChance == 0 then
            player:getInventory():AddItem("Hydrocraft.HCIronore");
        elseif secondChance == 1 then
            player:getInventory():AddItem("Hydrocraft.HCLeadore");
		elseif secondChance == 2 then
            player:getInventory():AddItem("Hydrocraft.HCSaltpeter");
        elseif secondChance == 3 then
            player:getInventory():AddItem("Hydrocraft.HCSulphur");
        elseif secondChance == 4 then
            player:getInventory():AddItem("Hydrocraft.HCJade");	
        elseif secondChance == 5 then
            player:getInventory():AddItem("Hydrocraft.HCAmethyst");				
        end
    elseif chance <= rockLvl6+rockLvl7+rockLvl8+rockLvl9+rockLvl10 then
        secondChance = ZombRand(3);
        if secondChance == 0 then
            player:getInventory():AddItem("Hydrocraft.HCCopperore");
        elseif secondChance == 1 then
			player:getInventory():AddItem("Hydrocraft.HCTinore");
		elseif secondChance == 2 then
            player:getInventory():AddItem("Hydrocraft.HCGypsum ");
        end
    elseif chance <= rockLvl5+rockLvl6+rockLvl7+rockLvl8+rockLvl9+rockLvl10 then
        secondChance = ZombRand(3)
        if secondChance == 0 then
            player:getInventory():AddItem("Hydrocraft.HCCoal");
        elseif secondChance == 1 then
            player:getInventory():AddItem("Hydrocraft.HCTar");
		elseif secondChance == 2 then
            player:getInventory():AddItem("Hydrocraft.HCGraphite");
        end
    elseif chance <= rockLvl4+rockLvl5+rockLvl6+rockLvl7+rockLvl8+rockLvl9+rockLvl10 then	
		secondChance = ZombRand(3);
        if secondChance == 0 then
            player:getInventory():AddItem("Hydrocraft.HCQuartz");
        elseif secondChance == 1 then
            player:getInventory():AddItem("Hydrocraft.HCBorax");
		elseif secondChance == 2 then
            player:getInventory():AddItem("Hydrocraft.HCFeldspar");
        end	
    elseif chance <= rockLvl3+rockLvl4+rockLvl5+rockLvl6+rockLvl7+rockLvl8+rockLvl9+rockLvl10 then
		secondChance = ZombRand(2);
        if secondChance == 0 then
            player:getInventory():AddItem("Hydrocraft.HCZombiebones");
        elseif secondChance == 1 then
            player:getInventory():AddItem("Hydrocraft.HCMarble");
        end			
    elseif chance <= rockLvl2+rockLvl3+rockLvl4+rockLvl5+rockLvl6+rockLvl7+rockLvl8+rockLvl9+rockLvl10 then
		secondChance = ZombRand(4);
        if secondChance == 0 then
            player:getInventory():AddItem("Base.Worm");
        elseif secondChance == 1 then
            player:getInventory():AddItem("Hydrocraft.HCSandstone");
		elseif secondChance == 2 then
            player:getInventory():AddItem("Hydrocraft.HCLimestone");
		elseif secondChance == 3 then
            player:getInventory():AddItem("Hydrocraft.HCChalkrock");
        end	
    elseif chance <= rockLvl1+rockLvl2+rockLvl3+rockLvl4+rockLvl5+rockLvl6+rockLvl7+rockLvl8+rockLvl9+rockLvl10 then
	    secondChance = ZombRand(2);
        if secondChance == 0 then
            player:getInventory():AddItem("Hydrocraft.HCRedclay");
        elseif secondChance == 1 then
            player:getInventory():AddItem("Hydrocraft.HCGreyclay");
        end	
    elseif chance <= rockLvl0+rockLvl1+rockLvl2+rockLvl3+rockLvl4+rockLvl5+rockLvl6+rockLvl7+rockLvl8+rockLvl9+rockLvl10 then
        secondChance = ZombRand(2);
        if secondChance == 0 then
            player:getInventory():AddItem("Base.SharpedStone");
        elseif secondChance == 1 then
            player:getInventory():AddItem("Base.Stone");
        end
    end
end
