hedgewars/uGears.pas
changeset 11700 ea1097d7bd27
parent 11532 bf86c6cb9341
child 11702 08cbd57ffb1a
equal deleted inserted replaced
11698:e86feecadced 11700:ea1097d7bd27
   743     ar: array[0..Pred(cMaxHHs)] of PHedgehog;
   743     ar: array[0..Pred(cMaxHHs)] of PHedgehog;
   744     Count: Longword;
   744     Count: Longword;
   745 begin
   745 begin
   746 if (GameFlags and gfPlaceHog) <> 0 then
   746 if (GameFlags and gfPlaceHog) <> 0 then
   747     PlacingHogs:= true;
   747     PlacingHogs:= true;
   748 if (ClansCount = 2) and ((GameFlags and gfDivideTeams) <> 0) then
   748 // in divided-teams mode, slice map into vertical stripes of identical length and spawn one clan in each slice
       
   749 if {((ClansCount = 2) or ((GameFlags and gfForts) <> 0)) and} ((GameFlags and gfDivideTeams) <> 0) then
   749     begin
   750     begin
   750     t:= 0;
   751     t:= 0;
   751     if checkFails(ClansCount = 2, 'More or less than 2 clans on map in divided teams mode!', true) then exit;
   752     for p:= 0 to (ClansCount - 1) do
   752     for p:= 0 to 1 do
       
   753         begin
   753         begin
   754         with ClansArray[p]^ do
   754         with ClansArray[p]^ do
   755             for j:= 0 to Pred(TeamsNumber) do
   755             for j:= 0 to Pred(TeamsNumber) do
   756                 with Teams[j]^ do
   756                 with Teams[j]^ do
   757                     for i:= 0 to cMaxHHIndex do
   757                     for i:= 0 to cMaxHHIndex do
   759                             if (Gear <> nil) and (Gear^.X.QWordValue = 0) then
   759                             if (Gear <> nil) and (Gear^.X.QWordValue = 0) then
   760                                 begin
   760                                 begin
   761                                 if PlacingHogs then
   761                                 if PlacingHogs then
   762                                     Unplaced:= true
   762                                     Unplaced:= true
   763                                 else
   763                                 else
   764                                     FindPlace(Gear, false, t, t + LAND_WIDTH div 2, true);// could make Gear == nil;
   764                                     FindPlace(Gear, false, t, t + LAND_WIDTH div ClansCount, true);// could make Gear == nil;
   765                                 if Gear <> nil then
   765                                 if Gear <> nil then
   766                                     begin
   766                                     begin
   767                                     Gear^.Pos:= GetRandom(49);
   767                                     Gear^.Pos:= GetRandom(49);
   768                                     Gear^.dX.isNegative:= p = 1;
   768                                     // unless the world is wrapping, make outter teams face to map center
       
   769                                     if (WorldEdge <> weWrap) and ((p = 0) or (p = ClansCount - 1)) then
       
   770                                         Gear^.dX.isNegative:= (p <> 0)
       
   771                                     else
       
   772                                         Gear^.dX.isNegative:= (GetRandom(2) = 1);
   769                                     end
   773                                     end
   770                                 end;
   774                                 end;
   771         t:= LAND_WIDTH div 2
   775         inc(t, LAND_WIDTH div ClansCount);
   772         end
   776         end
   773     end 
   777     end 
   774 else // mix hedgehogs
   778 else // mix hedgehogs
   775     begin
   779     begin
   776     Count:= 0;
   780     Count:= 0;