Here is a working script:
CreateCaravan('random_caravan_1',PLAYER_2,GROUND,2,2,GROUND,2,3)
for i=1,3 do
creature=random(115)+1
count=random(99)+1
CreateMonster('monster'..i,creature,count,4,4,GROUND,MONSTER_MOOD_AGGRESSIVE,MONSTER_COURAGE_CAN_FLEE_JOIN)
AddObjectCreatures('random_caravan_1',creature,count)
SetObjectEnabled('monster'..i,nil)
SetDisabledObjectMode('monster'..i,DISABLED_INTERACT)
SetObjectPosition('monster'..i,(96+i/3),96,GROUND)
Trigger(OBJECT_TOUCH_TRIGGER,'monster'..i,'fight_caravan_1')
end
function fight_caravan_1(hero)
for i=1,3 do
RemoveObject('monster'..i)
end
MakeHeroInteractWithObject(hero,'random_caravan_1')
end
It looks a bit strange because the coordinates in SetObjectPosition('monster'..i,(96+i/3),96,GROUND) cause two monsters to appear in the same place, and they overlap. You can, of course, arrange them as you like, in a square, or in a line, but just not in one point (it won't work). You can avoid the hassle of arranging the units and simply place the caravan filled with random monsters at the desired coordinates.
I suspect that there is a way to attach a combat script and arrange the random monsters on the battlefield, but in any case, the main question is how to display a composite unit on the adventure map.
And yes, if anyone doesn't understand how this script works, feel free to ask, I'll explain it line by line