Rewrite the two conditions as 

if viUnrevealedColor <>0 AND piItem_flags = 0