My hero keeps on dying with more than 600 health, what can I do to solve this?
I would make sure that you wait to attack until your soldiers have already started the attack. This can be done by simply adjusting the time in your conditionals for when you start attacking.
Basically change self.now() <= 30 to 35 or 40.
You also might want to do some cleaving!
Also, your hero doesn’t seem to be collecting coins. I believe your problem is that you tell your hero to find the nearest item, but not to move to it. Do that, so you can get more soldiers.