hedgewars/uAIAmmoTests.pas
changeset 6992 b8f3d8991e92
parent 6990 40e5af28d026
child 7007 0ccdff4ae8e9
equal deleted inserted replaced
6991:1ec44dde5eb9 6992:b8f3d8991e92
   644 if (Targ.X) - trunc(x) >= 0 then
   644 if (Targ.X) - trunc(x) >= 0 then
   645     ap.Angle:=   cMaxAngle div 4
   645     ap.Angle:=   cMaxAngle div 4
   646 else
   646 else
   647     ap.Angle:= - cMaxAngle div 4;
   647     ap.Angle:= - cMaxAngle div 4;
   648 
   648 
   649 valueResult:= RateShove(Me, trunc(x) + 10 * hwSignf(Targ.X - x), trunc(y), 15, 30, 115, hwSign(Me^.dX)*0.353, -0.353, 1);
   649 valueResult:= RateShove(Me, trunc(x) + LongWord(10*hwSignf(Targ.X - x)), trunc(y), 15, 30, 115, hwSign(Me^.dX)*0.353, -0.353, 1);
   650 if valueResult <= 0 then
   650 if valueResult <= 0 then
   651     valueResult:= BadTurn
   651     valueResult:= BadTurn
   652 else
   652 else
   653     inc(valueResult);
   653     inc(valueResult);
   654 TestBaseballBat:= valueResult;
   654 TestBaseballBat:= valueResult;
   655 end;
   655 end;
   656 
   656 
   657 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   657 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   658 var i, val1, val2, t: LongInt;
   658 var val1: LongInt;
   659     x, y: real;
   659     x, y: real;
   660 begin
   660 begin
   661 Level:= Level; // avoid compiler hint
   661 Level:= Level; // avoid compiler hint
   662 ap.ExplR:= 0;
   662 ap.ExplR:= 0;
   663 ap.Time:= 0;
   663 ap.Time:= 0;
   668 if (Abs(trunc(x) - Targ.X) > 25)
   668 if (Abs(trunc(x) - Targ.X) > 25)
   669 or (Abs(trunc(y) - 50 - Targ.Y) > 50) then
   669 or (Abs(trunc(y) - 50 - Targ.Y) > 50) then
   670     begin
   670     begin
   671 // TODO - find out WTH this works.
   671 // TODO - find out WTH this works.
   672     if TestColl(trunc(x), trunc(y) - 16, 6) and 
   672     if TestColl(trunc(x), trunc(y) - 16, 6) and 
   673        (RateShove(Me, trunc(x) + 10 * hwSign(Me^.dX), 
   673        (RateShove(Me, trunc(x) + LongWord(10 * hwSign(Me^.dX)), 
   674                       trunc(y) - 40, 30, 30, 40, hwSign(Me^.dX)*0.45, -0.9,  1) = 0) then
   674                       trunc(y) - 40, 30, 30, 40, hwSign(Me^.dX)*0.45, -0.9,  1) = 0) then
   675         val1:= Succ(BadTurn)
   675         val1:= Succ(BadTurn)
   676     else
   676     else
   677         val1:= BadTurn;
   677         val1:= BadTurn;
   678     TestFirePunch:= val1;
   678     TestFirePunch:= val1;
   718 y:= hwFloat2Float(Me^.Y);
   718 y:= hwFloat2Float(Me^.Y);
   719 if (Abs(trunc(x) - Targ.X) > 25)
   719 if (Abs(trunc(x) - Targ.X) > 25)
   720 or (Abs(trunc(y) - 50 - Targ.Y) > 50) then
   720 or (Abs(trunc(y) - 50 - Targ.Y) > 50) then
   721     begin
   721     begin
   722     if TestColl(trunc(x), trunc(y) - 16, 6)
   722     if TestColl(trunc(x), trunc(y) - 16, 6)
   723     and (RateShove(Me, trunc(x) + 10 * hwSign(Me^.dX), trunc(y) - 40, 30, 30, 40, hwSign(Me^.dX), -0.8,  1) = 0) then
   723     and (RateShove(Me, trunc(x) + LongWord(10 * hwSign(Me^.dX)), trunc(y) - 40, 30, 30, 40, hwSign(Me^.dX), -0.8,  1) = 0) then
   724         valueResult:= Succ(BadTurn)
   724         valueResult:= Succ(BadTurn)
   725     else
   725     else
   726         valueResult:= BadTurn;
   726         valueResult:= BadTurn;
   727     TestWhip:= valueResult;
   727     TestWhip:= valueResult;
   728     exit;
   728     exit;
   729     end;
   729     end;
   730 
   730 
   731 valueResult:= 0;
   731 valueResult:= 0;
   732 for i:= 0 to 4 do
   732 for i:= 0 to 4 do
   733     valueResult:= valueResult + RateShove(Me, trunc(x) + 10 * hwSignf(Targ.X - x),
   733     valueResult:= valueResult + RateShove(Me, trunc(x) + LongWord(10 * hwSignf(Targ.X - x)),
   734                                     trunc(y) - 20 * i - 5, 10, 30, 40, hwSign(Me^.dX), -0.8, 1);
   734                                     trunc(y) - LongWord(20 * i) - 5, 10, 30, 40, hwSign(Me^.dX), -0.8, 1);
   735 if valueResult <= 0 then
   735 if valueResult <= 0 then
   736     valueResult:= BadTurn
   736     valueResult:= BadTurn
   737 else
   737 else
   738     inc(valueResult);
   738     inc(valueResult);
   739 
   739 
   798 
   798 
   799     for i:= 0 to 9 do
   799     for i:= 0 to 9 do
   800         if b[i] then
   800         if b[i] then
   801             begin
   801             begin
   802             fexit:= false;
   802             fexit:= false;
   803             if TestColl(trunc(X) + i * 30, trunc(Y), 4) then
   803             if TestColl(trunc(X) + LongWord(i * 30), trunc(Y), 4) then
   804                 begin
   804                 begin
   805                 b[i]:= false;
   805                 b[i]:= false;
   806                 dmg[i]:= RateExplosion(Me, trunc(X) + i * 30, trunc(Y), 58)
   806                 dmg[i]:= RateExplosion(Me, trunc(X) + LongWord(i * 30), trunc(Y), 58)
   807                 // 58 (instead of 60) for better prediction (hh moves after explosion of one of the rockets)
   807                 // 58 (instead of 60) for better prediction (hh moves after explosion of one of the rockets)
   808                 end
   808                 end
   809             end;
   809             end;
   810 until fexit or (Y > cWaterLine);
   810 until fexit or (Y > cWaterLine);
   811 
   811