759 tt:= tt^.NextGear; |
759 tt:= tt^.NextGear; |
760 Dispose(t) |
760 Dispose(t) |
761 end; |
761 end; |
762 end; |
762 end; |
763 |
763 |
764 procedure AddSentries(count: LongWord); |
764 procedure AddLandSentries(count: LongWord); |
765 var i, x, y, swapIndex: LongInt; |
765 var i, x, y, swapIndex: LongInt; |
766 positions: array[0..1023] of TPoint; |
766 positions: array[0..1023] of TPoint; |
767 positionsCount, tries: LongInt; |
767 positionsCount, tries: LongInt; |
768 begin |
768 begin |
769 positionsCount := 0; |
769 positionsCount := 0; |
813 end; |
813 end; |
814 end; |
814 end; |
815 |
815 |
816 for i := 0 to min(count, positionsCount) - 1 do |
816 for i := 0 to min(count, positionsCount) - 1 do |
817 AddGear(positions[i].X, positions[i].Y - cHHRadius, gtSentry, 0, _0, _0, 0); |
817 AddGear(positions[i].X, positions[i].Y - cHHRadius, gtSentry, 0, _0, _0, 0); |
|
818 end; |
|
819 |
|
820 function AddWaterSentries(count: Longword): Longword; |
|
821 var i, x, y: LongInt; |
|
822 positions: array[0..255] of TPoint; |
|
823 positionsCount, tries: LongInt; |
|
824 begin |
|
825 AddWaterSentries := 0; |
|
826 positionsCount := 0; |
|
827 tries := 512; |
|
828 |
|
829 while (positionsCount < 256) and (tries > 0) do |
|
830 begin |
|
831 x := leftX + cHHRadius + GetRandom(rightX - leftX - 2 * cHHRadius); |
|
832 y := cWaterLine - 3 * cHHRadius; |
|
833 if (CountLand(x, y, cHHRadius - 1, 1, lfAll, 0) = 0) then |
|
834 begin |
|
835 positions[positionsCount].X := x; |
|
836 positions[positionsCount].Y := y; |
|
837 inc(positionsCount); |
|
838 if positionsCount >= 256 then |
|
839 break; |
|
840 end; |
|
841 end; |
|
842 |
|
843 for i := 0 to min(count, positionsCount) - 1 do |
|
844 begin |
|
845 AddGear(positions[i].X, positions[i].Y - cHHRadius, gtSentry, 0, _0, _0, 0); |
|
846 inc(AddWaterSentries); |
|
847 end; |
818 end; |
848 end; |
819 |
849 |
820 procedure AddMiscGears; |
850 procedure AddMiscGears; |
821 var p,i,j,t,h,unplaced: Longword; |
851 var p,i,j,t,h,unplaced: Longword; |
822 rx, ry: LongInt; |
852 rx, ry: LongInt; |
917 p:= 1; |
947 p:= 1; |
918 inc(j) |
948 inc(j) |
919 end; |
949 end; |
920 if p <> 0 then DeleteGear(Gear); |
950 if p <> 0 then DeleteGear(Gear); |
921 |
951 |
922 AddSentries(cSentries); |
952 if cSentries > 10 then |
|
953 AddLandSentries(cSentries - AddWaterSentries(cSentries div 10)) |
|
954 else |
|
955 AddLandSentries(cSentries); |
923 |
956 |
924 if (GameFlags and gfLowGravity) <> 0 then |
957 if (GameFlags and gfLowGravity) <> 0 then |
925 begin |
958 begin |
926 cGravity:= cMaxWindSpeed; |
959 cGravity:= cMaxWindSpeed; |
927 cGravityf:= 0.00025; |
960 cGravityf:= 0.00025; |