Change the losing condition to losing a hero, instead of complicating the map with checks through ERM.
Using variables below index 10 is dangerous; the game might overwrite its own data, so it's better to be safe.
New here? I'm Roha — want a quick tour?