hedgewars/uAIAmmoTests.pas
changeset 15679 b64f96d43f1f
parent 15678 e933b1dc302d
child 15680 3224d0d970ac
equal deleted inserted replaced
15678:e933b1dc302d 15679:b64f96d43f1f
  1806 function TestPiano(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
  1806 function TestPiano(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
  1807 const BOUNCES = 5;
  1807 const BOUNCES = 5;
  1808 var X, Y: real;
  1808 var X, Y: real;
  1809     dmg: array[0..BOUNCES-1] of LongInt;
  1809     dmg: array[0..BOUNCES-1] of LongInt;
  1810     i, e, rate, valueResult, targetY: LongInt;
  1810     i, e, rate, valueResult, targetY: LongInt;
  1811     firstHit: boolean;
  1811     firstHit, solidBounce: boolean;
  1812 begin
  1812 begin
  1813 Flags:= Flags; // avoid compiler hint
  1813 Flags:= Flags; // avoid compiler hint
  1814 ap.ExplR:= 0;
  1814 ap.ExplR:= 0;
  1815 ap.Time:= 0;
  1815 ap.Time:= 0;
  1816 if (cGravityf <= 0) then
  1816 if (cGravityf <= 0) then
  1829 for i:= 0 to BOUNCES-1 do
  1829 for i:= 0 to BOUNCES-1 do
  1830     dmg[i]:= 0;
  1830     dmg[i]:= 0;
  1831 
  1831 
  1832 i:= 1;
  1832 i:= 1;
  1833 firstHit:= false;
  1833 firstHit:= false;
       
  1834 solidBounce:= false;
  1834 repeat
  1835 repeat
  1835     // Piano goes down
  1836     // Piano goes down
  1836     Y:= Y + 11;
  1837     if (not solidBounce) then
  1837     if TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(X), trunc(Y), 32) then
  1838         Y:= Y + 11;
       
  1839     if solidBounce or TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(X), trunc(Y), 32) then
  1838         begin
  1840         begin
  1839         if (not firstHit) then
  1841         if (not firstHit) then
  1840             targetY:= trunc(Y);
  1842             targetY:= trunc(Y);
  1841         firstHit:= true;
  1843         firstHit:= true;
       
  1844         if (GameFlags and gfSolidLand) <> 0 then
       
  1845             // Don't change Y when indestructible land was hit
       
  1846             solidBounce:= true;
       
  1847 
  1842         for e:= -1 to 1 do
  1848         for e:= -1 to 1 do
  1843             begin
  1849             begin
  1844             rate:= RateExplosion(Me, trunc(X) + 30*e, trunc(Y)+40, 161, afIgnoreMe);
  1850             rate:= RateExplosion(Me, trunc(X) + 30*e, trunc(Y)+40, 161, afIgnoreMe);
  1845             if rate <> BadTurn then
  1851             if rate <> BadTurn then
  1846                 dmg[i]:= dmg[i] + rate;
  1852                 dmg[i]:= dmg[i] + rate;
  1847             end;
  1853             end;
  1848 
  1854 
  1849         if (i > 1) and (dmg[i] > 0) then
  1855         if (i > 1) and (dmg[i] > 0) then
  1850             dmg[i]:= dmg[i] div 2;
  1856             dmg[i]:= dmg[i] div 2;
  1851         inc(i);
  1857         inc(i);
  1852         // Skip past the blast hole
  1858         if (not solidBounce) then
  1853         Y:= Y + 41
  1859             // Skip past the blast hole
       
  1860             Y:= Y + 41
  1854         end;
  1861         end;
  1855 until (i > BOUNCES) or (Y > cWaterLine);
  1862 until (i > BOUNCES) or (Y > cWaterLine);
  1856 
  1863 
  1857 if (i = 0) and (Y > cWaterLine) then
  1864 if (i = 0) and (Y > cWaterLine) then
  1858     exit(BadTurn);
  1865     exit(BadTurn);