Auto-translated
Generally speaking, if that's what you need, you should use HoMM 3.5 WoG because previous versions don't support ERM scripts. I can't explain in a few words what you need to do. Check out here and read the documentation on the ERM script editor. Read it again so you have at least some idea, because there isn't a ready-made script for what you want – you need to connect it with something