56 uses uStore, uSound, uTeams, uRandom, uIO, uLandGraphics, |
56 uses uStore, uSound, uTeams, uRandom, uIO, uLandGraphics, |
57 {$IFDEF USE_TOUCH_INTERFACE}uTouch,{$ENDIF} |
57 {$IFDEF USE_TOUCH_INTERFACE}uTouch,{$ENDIF} |
58 uLocale, uAmmos, uStats, uVisualGears, uScript, uVariables, |
58 uLocale, uAmmos, uStats, uVisualGears, uScript, uVariables, |
59 uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, |
59 uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, |
60 uGearsHedgehog, uGearsUtils, uGearsList, uGearsHandlersRope |
60 uGearsHedgehog, uGearsUtils, uGearsList, uGearsHandlersRope |
61 , uVisualGearsList, uGearsHandlersMess, uAI; |
61 , uVisualGearsList, uGearsHandlersMess, uAI, SDLh; |
62 |
62 |
63 var skipFlag: boolean; |
63 var skipFlag: boolean; |
64 |
64 |
65 var delay: LongWord; |
65 var delay: LongWord; |
66 delay2: LongWord; |
66 delay2: LongWord; |
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); |
|
765 var i, x, y, swapIndex: LongInt; |
|
766 positions: array[0..1023] of TPoint; |
|
767 positionsCount, tries: LongInt; |
|
768 begin |
|
769 positionsCount := 0; |
|
770 tries := 2048; |
|
771 while (positionsCount < 1024) and (tries > 0) do |
|
772 begin |
|
773 x := leftX + cHHRadius + GetRandom(rightX - leftX - 2 * cHHRadius); |
|
774 y := cHHRadius; |
|
775 |
|
776 while y < cWaterLine do |
|
777 begin |
|
778 repeat |
|
779 inc(y, cHHRadius) |
|
780 until (y >= cWaterLine) or (CountLand(x, y, cHHRadius - 1, 1, lfAll, 0) = 0); |
|
781 |
|
782 if y < cWaterLine then |
|
783 begin |
|
784 repeat |
|
785 inc(y) |
|
786 until (y >= cWaterLine) or (CountLand(x, y, cHHRadius - 1, 1, lfAll, 0) <> 0); |
|
787 |
|
788 if y < cWaterLine then |
|
789 begin |
|
790 swapIndex := GetRandom(positionsCount + 1); |
|
791 if swapIndex = positionsCount then |
|
792 begin |
|
793 positions[positionsCount].X := x; |
|
794 positions[positionsCount].Y := y; |
|
795 end |
|
796 else |
|
797 begin |
|
798 positions[positionsCount].X := positions[swapIndex].X; |
|
799 positions[positionsCount].Y := positions[swapIndex].Y; |
|
800 positions[swapIndex].X := x; |
|
801 positions[swapIndex].Y := y; |
|
802 end; |
|
803 inc(positionsCount); |
|
804 if positionsCount >= 1024 then |
|
805 break; |
|
806 inc(y, cHHRadius * 2) |
|
807 end |
|
808 else |
|
809 dec(tries) |
|
810 end |
|
811 else |
|
812 dec(tries) |
|
813 end; |
|
814 end; |
|
815 |
|
816 for i := 0 to min(count, positionsCount) - 1 do |
|
817 AddGear(positions[i].X, positions[i].Y - cHHRadius, gtSentry, 0, _0, _0, 5000); |
|
818 end; |
|
819 |
764 procedure AddMiscGears; |
820 procedure AddMiscGears; |
765 var p,i,j,t,h,unplaced: Longword; |
821 var p,i,j,t,h,unplaced: Longword; |
766 rx, ry: LongInt; |
822 rx, ry: LongInt; |
767 rdx, rdy: hwFloat; |
823 rdx, rdy: hwFloat; |
768 Gear: PGear; |
824 Gear: PGear; |
861 p:= 1; |
917 p:= 1; |
862 inc(j) |
918 inc(j) |
863 end; |
919 end; |
864 if p <> 0 then DeleteGear(Gear); |
920 if p <> 0 then DeleteGear(Gear); |
865 |
921 |
866 i:= 0; |
922 AddSentries(cSentries); |
867 unplaced:= 0; |
|
868 while (i < cSentries) and (unplaced < 4) do |
|
869 begin |
|
870 Gear:= AddGear(0, 0, gtSentry, 0, _0, _0, 0); |
|
871 FindPlace(Gear, false, 0, LAND_WIDTH); |
|
872 |
|
873 if Gear = nil then |
|
874 inc(unplaced) |
|
875 else |
|
876 unplaced:= 0; |
|
877 |
|
878 inc(i) |
|
879 end; |
|
880 |
923 |
881 if (GameFlags and gfLowGravity) <> 0 then |
924 if (GameFlags and gfLowGravity) <> 0 then |
882 begin |
925 begin |
883 cGravity:= cMaxWindSpeed; |
926 cGravity:= cMaxWindSpeed; |
884 cGravityf:= 0.00025; |
927 cGravityf:= 0.00025; |