hedgewars/uAIAmmoTests.pas
changeset 7760 ccc8bd5205ff
parent 7752 65bacd3ba69e
child 7789 838d2e06c377
equal deleted inserted replaced
7759:b64afd109cf7 7760:ccc8bd5205ff
   600 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   600 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   601 var Vx, Vy, x, y, t, dmgMod: real;
   601 var Vx, Vy, x, y, t, dmgMod: real;
   602     d: Longword;
   602     d: Longword;
   603     fallDmg, valueResult: LongInt;
   603     fallDmg, valueResult: LongInt;
   604 begin
   604 begin
   605 if Level > 3 then exit(BadTurn);
   605 if Level > 4 then exit(BadTurn);
   606 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent;
   606 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent;
   607 Level:= Level; // avoid compiler hint
   607 Level:= Level; // avoid compiler hint
   608 ap.ExplR:= 0;
   608 ap.ExplR:= 0;
   609 ap.Time:= 0;
   609 ap.Time:= 0;
   610 ap.Power:= 1;
   610 ap.Power:= 1;
   611 
   611 
   612 x:= hwFloat2Float(Me^.X);
   612 x:= hwFloat2Float(Me^.X);
   613 y:= hwFloat2Float(Me^.Y);
   613 y:= hwFloat2Float(Me^.Y);
   614 
   614 
   615 if Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) < 40 then
   615 if Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) < 20 then
   616     exit(BadTurn);
   616     exit(BadTurn);
   617 
   617 
   618 t:= 2 / sqrt(sqr(Targ.X - x)+sqr(Targ.Y-y));
   618 t:= 2 / sqrt(sqr(Targ.X - x)+sqr(Targ.Y-y));
   619 Vx:= (Targ.X - x) * t;
   619 Vx:= (Targ.X - x) * t;
   620 Vy:= (Targ.Y - y) * t;
   620 Vy:= (Targ.Y - y) * t;
   630 until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 5)
   630 until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 5)
   631     or (x < 0)
   631     or (x < 0)
   632     or (y < 0)
   632     or (y < 0)
   633     or (trunc(x) > LAND_WIDTH)
   633     or (trunc(x) > LAND_WIDTH)
   634     or (trunc(y) > LAND_HEIGHT)
   634     or (trunc(y) > LAND_HEIGHT)
   635     or (d > 50);
   635     or (d > 48);
   636 
   636 
   637 if Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 5 then
   637 if Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 5 then
   638     begin
   638     begin
   639     fallDmg:= TraceShoveFall(Targ.X, Targ.Y, vX * 0.00125 * 20, vY * 0.00125 * 20);
   639     fallDmg:= TraceShoveFall(Targ.X, Targ.Y, vX * 0.00125 * 20, vY * 0.00125 * 20);
   640     if fallDmg < 0 then
   640     if fallDmg < 0 then
   641         valueResult:= 204800
   641         valueResult:= 204800
   642     else valueResult:= Max(0, (4 - d div 50) * trunc((7+fallDmg)*dmgMod) * 1024)
   642     else valueResult:= Max(0, (4 - d div 12) * trunc((7 + fallDmg) * dmgMod) * 1024)
   643     end
   643     end
   644 else
   644 else
   645     valueResult:= BadTurn;
   645     valueResult:= BadTurn;
   646 TestDesertEagle:= valueResult
   646 TestDesertEagle:= valueResult
   647 end;
   647 end;