Everything worked well, but when the dialogue ends, the other player's turn begins, and the mission fails.
Try replacing the function that checks for clerics in the hero's army with this one:
function CreatureShouldSurvive(hero, id)
while 1 do
sleep ( 10 );
if GetHeroCreatures(hero, id) == 0 then
SetObjectiveState("zadanie4", OBJECTIVE_FAILED);
sleep ( 10 );
Loose();
break
end;
end;
end;P.s. This is the skeleton of the function that checks for the presence of a dragon with Ilia in Lords of the Realm.
And as another option: move AddHeroCreatures("Mardigo", 10, 1); above startThread, i.e.:
AddHeroCreatures("Mardigo", 10, 1);
startThread(CreatureShouldSurvive, 'Mardigo', CREATURE_CLERIC)
AddHeroCreatures("Mardigo", 1, 40);
AddHeroCreatures("Mardigo", 5, 10);