Auto-translated
As an alternative, you can write the following in the Barracks_build_ok function:
```
function Barracks_build_ok()
MessageBox("/Maps/SingleMissions/Time of Troubles1/Barracks_building1.txt");
SetObjectiveState("zadanie1", OBJECTIVE_ACTIVE,1);
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "QuestSword", nil)
startThread( _Barracks_build_mob_monitor);
end
```
And here is the _Barracks_build_mob_monitor function itself:
```
function _Barracks_build_mob_monitor ()
while 1 do
sleep(2);
if not Exists("Neutral") then
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "QuestSword", "Barracks_build_2");
break
end;
end;
end;
```
It checks in a separate thread whether the 'Neutral' unit exists (Exists("Neutral")). If it is defeated at some point, the trigger for the region changes to "Barracks_build_2" - a function with dialogue #2.
The completion of the quest depends on its type (kind). If it is OBJECTIVE_KIND_MANUAL, it can be completed with the following line:
```
SetObjectiveState('zadanie1', OBJECTIVE_COMPLETED);
```
Place it under the condition if not Exists("Neutral") then, before the trigger.
If it is not OBJECTIVE_KIND_MANUAL, but is set to destroy a unit, it should complete automatically.
I haven't encountered any issues with unlocking buildings, but SetTownBuildingLimitLevel will likely help in this case.