Skip to content
#1055
Auto-translated
SetObjectEnabled("garrison_name", nil);
Trigger(4, "garrison_name", "capture_gar");

function capture_gar(hero)
local a = {};
a[1], a[3], a[5], a[7], a[9], a[11], a[13] = GetObjectCreaturesTypes("garrison_name");
for i = 1, 7 do
if a[i*2-1] ~= 0 then
a[i*2] = 2 * GetObjectCreatures("garrison_name", a[i*2-1]);
end;
end;
SetObjectEnabled("garrison_name", 1);
Trigger(4, "garrison_name", nil);
MakeHeroInteractWithObject(hero, "garrison_name");
local i = GetLastSavedCombatIndex();
while i == GetLastSavedCombatIndex() do
sleep(1);
end;
if not IsHeroAlive(hero) then
SetObjectEnabled("garrison_name", nil);
Trigger(4, "garrison_name", "capture_gar");
return
end;
for i = 1, 7 do
if a[i*2] then
AddObjectCreatures("garrison_name", a[i*2-1], a[i*2]);
end;
end;
DenyGarrisonCreaturesTakeAway("garrison_name", 1);
end;


I can't get this script to work for multiple garrisons on the map.
I tried giving all the garrisons the same name, but it didn't work.
I also tried duplicating the script text and inserting a different name into each script, but that didn't work either.
And another question:
I made a mistake when creating the map; I chose single scenario instead of Multiplayer arena.
Is there any way to fix this?