hedgewars/uAIAmmoTests.pas
changeset 6782 33009ac4de80
parent 6775 22b5fb7217db
child 6783 8d9160b85bdb
equal deleted inserted replaced
6781:23f627ba8ee9 6782:33009ac4de80
   646     inc(valueResult);
   646     inc(valueResult);
   647 TestBaseballBat:= valueResult;
   647 TestBaseballBat:= valueResult;
   648 end;
   648 end;
   649 
   649 
   650 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   650 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   651 var i, valueResult: LongInt;
   651 var i, val1, val2, t: LongInt;
   652     x, y: real;
   652     x, y: real;
   653 begin
   653 begin
   654 Level:= Level; // avoid compiler hint
   654 Level:= Level; // avoid compiler hint
   655 ap.ExplR:= 0;
   655 ap.ExplR:= 0;
   656 ap.Time:= 0;
   656 ap.Time:= 0;
   657 ap.Power:= 1;
   657 ap.Power:= 1;
   658 ap.Angle:= 0;
   658 ap.Angle:= hwSign(Me^.dX);
   659 x:= hwFloat2Float(Me^.X);
   659 x:= hwFloat2Float(Me^.X);
   660 y:= hwFloat2Float(Me^.Y);
   660 y:= hwFloat2Float(Me^.Y);
   661 if (Abs(trunc(x) - Targ.X) > 25)
   661 if (Abs(trunc(x) - Targ.X) > 25)
   662 or (Abs(trunc(y) - 50 - Targ.Y) > 50) then
   662 or (Abs(trunc(y) - 50 - Targ.Y) > 50) then
   663     begin
   663     begin
   664     if TestColl(trunc(x), trunc(y) - 16, 6)
   664 // TODO - find out WTH this works.
   665     and (RateShove(Me, trunc(x) + 10 * hwSign(Me^.dX), trunc(y) - 40, 30, 30, 40, hwSign(Me^.dX)*0.45, -0.9,  1) = 0) then
   665     if TestColl(trunc(x), trunc(y) - 16, 6) and 
   666         valueResult:= Succ(BadTurn)
   666        (RateShove(Me, trunc(x) + 10 * hwSign(Me^.dX), 
       
   667                       trunc(y) - 40, 30, 30, 40, hwSign(Me^.dX)*0.45, -0.9,  1) = 0) then
       
   668         val1:= Succ(BadTurn)
   667     else
   669     else
   668         valueResult:= BadTurn;
   670         val1:= BadTurn;
   669     exit(valueResult)
   671     exit(val1)
   670     end;
   672     end;
   671 
   673 (*
   672 valueResult:= 0;
   674 For some silly reason, having this enabled w/ the AI 
       
   675 val1:= 0;
   673 for i:= 0 to 4 do
   676 for i:= 0 to 4 do
   674     valueResult:= valueResult + RateShove(Me, trunc(x) + 10 * hwSign(Targ.X - x),
   677     begin
   675                                     trunc(y) - 20 * i - 5, 10, 30, 40, hwSign(Me^.dX)*0.45, -0.9, 1);
   678     t:= RateShove(Me, trunc(x) + 10 * hwSign(Targ.X - x), trunc(y) - 20 * i - 5, 10, 30, 40, hwSign(Me^.dX)*0.45, -0.9, 1);
   676 if valueResult <= 0 then
   679     if (val1 < 0) or (t < 0) then val1:= BadTurn
   677     valueResult:= BadTurn
   680     else if t > 0 then val1:= t;
   678 else
   681     end;
   679     inc(valueResult);
   682 
   680 
   683 val2:= 0;
   681 TestFirePunch:= valueResult;
   684 for i:= 0 to 4 do
       
   685     begin
       
   686     t:= RateShove(Me, trunc(x) + 10 * hwSign(Targ.X - x), trunc(y) - 20 * i - 5, 10, 30, 40, -hwSign(Me^.dX)*0.45, -0.9, 1);
       
   687     if (val2 < 0) or (t < 0) then val2:= BadTurn
       
   688     else if t > 0 then val2:= t;
       
   689     end;
       
   690 if (val1 > val2) and (val1 > 0) then 
       
   691     TestFirePunch:= val1
       
   692 else if (val2 > val1) and (val2 > 0) then
       
   693     begin
       
   694     ap.Angle:= -hwSign(Me^.dX);
       
   695     TestFirePunch:= val2
       
   696     end
       
   697 else TestFirePunch:= BadTurn;*)
   682 end;
   698 end;
   683 
   699 
   684 function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   700 function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   685 var i, valueResult: LongInt;
   701 var i, valueResult: LongInt;
   686     x, y: real;
   702     x, y: real;