For me it ended up being the logic board faulty, to be specific the power management IC chip on the logic board was for some reason getting too hot, probably something connected to it was short circuited making it heat up.
The most you can do is reflash firmware / factory reset the phone and try another battery. If it's still no good then the only possible way to fix this is changing the logic board.
Personally I don't find it worth changing logic board as the phone has dropped so much in worth. I think you can get a second hand s4 for around $100.