function WORitching(player, moodleLevel)
    
    if moodleLevel == 1 then 
        if ZombRand(10) == 0 then 
            WORscratchEmote(player)
        end
    elseif moodleLevel == 2 then 
        if ZombRand(7) == 0 then 
            WORscratchEmote(player)
        end
    elseif moodleLevel == 3 then
        if ZombRand(5) == 0 then 
            WORscratchEmote(player)
        end
    elseif moodleLevel == 4 then
        if ZombRand(3) == 0 then 
            WORscratchEmote(player)
        end
    end
end

function WORscratchEmote(player)
    local itchingBodyParts = {"Neck", "ForeArm_L", "UpperArm_L", "Hand_L", "ForeArm_R", "UpperArm_R", "Hand_R", "UpperLeg_L", "LowerLeg_L", "UpperLeg_R", "LowerLeg_R"}
    local randNumber = ZombRand(1, #itchingBodyParts + 1)
	local randomBodyPart = itchingBodyParts[randNumber]
    --print("randomBodyPart: " .. randomBodyPart)
    if randomBodyPart == "ForeArm_L" or randomBodyPart == "UpperArm_L" then
        player:playEmote("woritchingleftarm")
        WORscratchPain(player, "ForeArm_L", ZombRand(10))
        WORscratchPain(player, "UpperArm_L", ZombRand(10))
    elseif randomBodyPart == "ForeArm_R" or randomBodyPart == "UpperArm_R" then
        player:playEmote("woritchingrightarm")
        WORscratchPain(player, "ForeArm_R", ZombRand(10))
        WORscratchPain(player, "UpperArm_R", ZombRand(10))
    elseif randomBodyPart == "LowerLeg_L" or randomBodyPart == "UpperLeg_L" then
        player:playEmote("woritchingleftleg")
        WORscratchPain(player, "LowerLeg_L", ZombRand(10))
        WORscratchPain(player, "UpperLeg_L", ZombRand(10))
    elseif randomBodyPart == "LowerLeg_R" or randomBodyPart == "UpperLeg_R" then
        player:playEmote("woritchingrightleg")
        WORscratchPain(player, "LowerLeg_R", ZombRand(10))
        WORscratchPain(player, "UpperLeg_R", ZombRand(10))
    elseif randomBodyPart == "Hand_L" then
        player:playEmote("woritchinglefthand")
        WORscratchPain(player, "Hand_L", ZombRand(10))
    elseif randomBodyPart == "Hand_R" then
        player:playEmote("woritchingrighthand")
        WORscratchPain(player, "Hand_R", ZombRand(10))
    elseif randomBodyPart == "Neck" then
        player:playEmote("woritchingneck")
        WORscratchPain(player, "Neck", ZombRand(10))
    end
end

function WORscratchPain(player, bodyPart, pain)
    --print("running WORscratchPain function")
    local bodyDamage = player:getBodyDamage()
    local playerBodyPart = WORgetPlayerBodyPartFromString(bodyDamage, bodyPart)
    local currentPain = playerBodyPart:getPain()
    playerBodyPart:setAdditionalPain(currentPain + pain)
    if playerBodyPart:getPain() > 100 then
        playerBodyPart:setAdditionalPain(100)
    end
end