But then again, a character might be helping them out of self-interest; he might simply want to increase his own reputation/prestige, and revel in their adulation of him, like so many celebrities and politicians do. He might also help them because he expects to be paid, or because the people attacking the town are his own enemies as well. There's simply no fool-proof way of handling karma in a computer game, unless there's a system where you can input your character's motivation for doing something.
Have you watched the tv-series "Firefly"? Jayne is the http://www.youtube.com/watch?v=8omJvCrwRdY, yet it wouldn't make sense for him to have gained any karma for his 'heroic' deeds as he acted purely out of greed, and the positive consequences were incidental.
Well this brings the whole concept of karma into the question.
When you do good acts, do you do them because you have a moral fiber and desire to be good, or is that "comes around goes around" little extra creating the incentive?
The entire philosophy is flawed in that sense. You might be doing good deeds to better yourself, but as long as the deeds are good, the more selfish you can be.
I like karma though (in real life too) I'm just trying to point out that this examination of karma is going to become too big.