648 function TestWatermelon(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
648 function TestWatermelon(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
649 const tDelta = 24; |
649 const tDelta = 24; |
650 var Vx, Vy, r: real; |
650 var Vx, Vy, r: real; |
651 Score, EX, EY, valueResult: LongInt; |
651 Score, EX, EY, valueResult: LongInt; |
652 TestTime: Longword; |
652 TestTime: Longword; |
653 x, y, dY, meX, meY: real; |
653 targXWrap, x, y, dY, meX, meY: real; |
654 t: LongInt; |
654 t: LongInt; |
655 begin |
655 begin |
656 valueResult:= BadTurn; |
656 valueResult:= BadTurn; |
657 TestTime:= 500; |
657 TestTime:= 500; |
658 ap.ExplR:= 0; |
658 ap.ExplR:= 0; |
659 meX:= hwFloat2Float(Me^.X); |
659 meX:= hwFloat2Float(Me^.X); |
660 meY:= hwFloat2Float(Me^.Y); |
660 meY:= hwFloat2Float(Me^.Y); |
|
661 if (WorldEdge = weWrap) then |
|
662 if (Targ.Point.X < meX) then |
|
663 targXWrap:= Targ.Point.X + (RightX-LeftX) |
|
664 else targXWrap:= Targ.Point.X - (RightX-LeftX); |
661 repeat |
665 repeat |
662 inc(TestTime, 900); |
666 inc(TestTime, 900); |
663 Vx:= (Targ.Point.X - meX) / (TestTime + tDelta); |
667 if (WorldEdge = weWrap) and (random(2)=0) then |
|
668 Vx:= (targXWrap - meX) / (TestTime + tDelta) |
|
669 else Vx:= (Targ.Point.X - meX) / (TestTime + tDelta); |
664 Vy:= cGravityf * ((TestTime + tDelta) div 2) - ((Targ.Point.Y-50) - meY) / (TestTime + tDelta); |
670 Vy:= cGravityf * ((TestTime + tDelta) div 2) - ((Targ.Point.Y-50) - meY) / (TestTime + tDelta); |
665 r:= sqr(Vx)+sqr(Vy); |
671 r:= sqr(Vx)+sqr(Vy); |
666 if not (r > 1) then |
672 if not (r > 1) then |
667 begin |
673 begin |
668 x:= meX; |
674 x:= meX; |
669 y:= meY; |
675 y:= meY; |
670 dY:= -Vy; |
676 dY:= -Vy; |
671 t:= TestTime; |
677 t:= TestTime; |
672 repeat |
678 repeat |
|
679 x:= CheckWrap(x); |
673 x:= x + Vx; |
680 x:= x + Vx; |
674 y:= y + dY; |
681 y:= y + dY; |
675 dY:= dY + cGravityf; |
682 dY:= dY + cGravityf; |
676 dec(t) |
683 dec(t) |
677 until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or |
684 until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or |