656 j:= 0; |
656 j:= 0; |
657 p:= 0; // 0 searching, 1 bad position, 2 added. |
657 p:= 0; // 0 searching, 1 bad position, 2 added. |
658 unplaced:= 0; |
658 unplaced:= 0; |
659 if cAirMines > 0 then |
659 if cAirMines > 0 then |
660 Gear:= AddGear(0, 0, gtAirMine, 0, _0, _0, 0); |
660 Gear:= AddGear(0, 0, gtAirMine, 0, _0, _0, 0); |
661 while (i < cAirMines) and (j < 1000*cAirMines) do |
661 while (i < cAirMines) and (j < 1000*cAirMines) do |
662 begin |
662 begin |
663 p:= 0; |
663 p:= 0; |
664 if hasBorder then |
664 if hasBorder then |
665 begin |
665 begin |
666 rx:= leftX+GetRandom(rightX-leftX-16)+8; |
666 rx:= leftX+GetRandom(rightX-leftX-16)+8; |
667 ry:= topY+GetRandom(LAND_HEIGHT-topY-16)+8 |
667 ry:= topY+GetRandom(LAND_HEIGHT-topY-16)+8 |
668 end |
668 end |
669 else |
669 else |
670 begin |
670 begin |
671 rx:= leftX+GetRandom(rightX-leftX+400)-200; |
671 rx:= leftX+GetRandom(rightX-leftX+400)-200; |
672 ry:= topY+GetRandom(LAND_HEIGHT-topY+400)-200 |
672 ry:= topY+GetRandom(LAND_HEIGHT-topY+400)-200 |
673 end; |
673 end; |
674 Gear^.X:= int2hwFloat(CalcWorldWrap(rx,Gear^.Radius)); |
674 Gear^.X:= int2hwFloat(CalcWorldWrap(rx,Gear^.Radius)); |
675 Gear^.Y:= int2hwFloat(ry); |
675 Gear^.Y:= int2hwFloat(ry); |
676 if CheckLandValue(rx, ry, $FFFF) and |
676 if CheckLandValue(rx, ry, $FFFF) and |
677 (TestCollisionYwithGear(Gear,-1) = 0) and |
677 (TestCollisionYwithGear(Gear,-1) = 0) and |
678 (TestCollisionXwithGear(Gear, 1) = 0) and |
678 (TestCollisionXwithGear(Gear, 1) = 0) and |
679 (TestCollisionXwithGear(Gear,-1) = 0) and |
679 (TestCollisionXwithGear(Gear,-1) = 0) and |
680 (TestCollisionYwithGear(Gear, 1) = 0) then |
680 (TestCollisionYwithGear(Gear, 1) = 0) then |
681 begin |
681 begin |
682 t:= 0; |
682 t:= 0; |
683 while (t < TeamsCount) and (p = 0) do |
683 while (t < TeamsCount) and (p = 0) do |
684 begin |
684 begin |
685 h:= 0; |
685 h:= 0; |
686 with TeamsArray[t]^ do |
686 with TeamsArray[t]^ do |
687 while (h < cMaxHHIndex) and (p = 0) do |
687 while (h < cMaxHHIndex) and (p = 0) do |
688 begin |
|
689 if (Hedgehogs[h].Gear <> nil) then |
|
690 begin |
688 begin |
691 rdx:=Gear^.X-Hedgehogs[h].Gear^.X; |
689 if (Hedgehogs[h].Gear <> nil) then |
692 rdy:=Gear^.Y-Hedgehogs[h].Gear^.Y; |
|
693 if (Gear^.Angle < $FFFFFFFF) and |
|
694 ((rdx.Round+rdy.Round < Gear^.Angle) and |
|
695 (hwRound(hwSqr(rdx) + hwSqr(rdy)) < sqr(Gear^.Angle))) then |
|
696 begin |
690 begin |
697 // Debug line. Remove later |
691 rdx:=Gear^.X-Hedgehogs[h].Gear^.X; |
698 // AddFileLog('Too Close to Hog @ (' + inttostr(rx) + ',' + inttostr(ry) + ')'); |
692 rdy:=Gear^.Y-Hedgehogs[h].Gear^.Y; |
699 |
693 if (Gear^.Angle < $FFFFFFFF) and |
700 p:= 1 |
694 ((rdx.Round+rdy.Round < Gear^.Angle) and |
701 end |
695 (hwRound(hwSqr(rdx) + hwSqr(rdy)) < sqr(Gear^.Angle))) then |
|
696 begin |
|
697 // Debug line. Remove later |
|
698 // AddFileLog('Too Close to Hog @ (' + inttostr(rx) + ',' + inttostr(ry) + ')'); |
|
699 |
|
700 p:= 1 |
|
701 end |
|
702 end; |
|
703 inc(h) |
702 end; |
704 end; |
703 inc(h) |
705 inc(t) |
704 end; |
706 end; |
705 inc(t) |
707 if p = 0 then |
706 end; |
708 begin |
707 if p = 0 then |
709 inc(i); |
708 begin |
710 AddFileLog('Placed Air Mine @ (' + inttostr(rx) + ',' + inttostr(ry) + ')'); |
709 inc(i); |
711 if i < cAirMines then |
710 AddFileLog('Placed Air Mine @ (' + inttostr(rx) + ',' + inttostr(ry) + ')'); |
712 Gear:= AddGear(0, 0, gtAirMine, 0, _0, _0, 0) |
711 if i < cAirMines then |
713 end |
712 Gear:= AddGear(0, 0, gtAirMine, 0, _0, _0, 0) |
714 end; |
713 end |
715 inc(j) |
714 end; |
716 end; |
715 inc(j) |
|
716 end; |
|
717 if p <> 0 then DeleteGear(Gear); |
717 if p <> 0 then DeleteGear(Gear); |
718 |
718 |
719 if (GameFlags and gfLowGravity) <> 0 then |
719 if (GameFlags and gfLowGravity) <> 0 then |
720 begin |
720 begin |
721 cGravity:= cMaxWindSpeed; |
721 cGravity:= cMaxWindSpeed; |