Are the karmic consequenses in any way affected if the doer of some evil is in fact mentally ill or mentally disturbed?
—Magnus ReuterswÃ¤rd, Sweden
This is a very serious question that can be answered in general but difficult to answer specifically to a person. Each person in this situation would need to feel out for themselves what their karma would be by going inside (as best as they can) calling to God and Guru to help with an answer.
Generally speaking, the person affected mentally has karma already to work out because of having this condition. They are not immune by being in that state of mental disorder and would then create more karma by any action that would harm another or be considered evil.
You might be interested in reading the book Karma and Reincarnation by Paramhansa Yogananda. Yogananda brings to light what karma is and how it works.
What Yogananda does is bring light into a dark situation so that one feels that their situation is not hopeless and can be overcome, freeing one from all karma in the end.