Skip to content
#1100
Auto-translated
I'm sorry, but I don't understand programming, and I naturally didn't understand anything.
Could you help me?
garrisons={'G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'G9'}
garrisons_army={}
for j, gar in garrisons do
Trigger(5, gar, 'capture_gar')
for i = 0, 6 do
local t, n = GetObjectArmySlotCreature(gar, i)
garrisons_army[gar]= {t, n}
end
end

function capture_gar(oldowner, newowner, hero, gar)
for i = 0, 6 do
if garrisons_army[gar][1] ~= 0 then
AddObjectCreatures(gar, garrisons_army[gar][1], garrisons_army[gar][2]*2)
end
end
DenyGarrisonCreaturesTakeAway(gar, 1)
Trigger(5, gar, nil)
end
To be honest, I'm not sure if it will work. I'm just not sure if the variable will be initialized correctly as a three-dimensional array. And yes, it might be better to use a less elegant but more formal method that is guaranteed to work. To do this, we need to avoid using three-dimensional arrays, and two-dimensional arrays are also not desirable. But this is only if we can't create a working version of the "beautiful" option.

Statistics

Welcome our newest member: Emil