hedgewars/uAIMisc.pas
changeset 7210 2ff30b79d2b0
parent 7208 62e36dc45098
child 7214 befce0edf527
equal deleted inserted replaced
7208:62e36dc45098 7210:2ff30b79d2b0
    79         Count: Longword;
    79         Count: Longword;
    80         ar: array[0..Pred(MAXBONUS)] of TBonus;
    80         ar: array[0..Pred(MAXBONUS)] of TBonus;
    81         end;
    81         end;
    82 
    82 
    83 implementation
    83 implementation
    84 uses uCollisions, uVariables, uUtils, uDebug;
    84 uses uCollisions, uVariables, uUtils, uDebug, uLandTexture;
    85 
    85 
    86 const KillScore = 200;
    86 const KillScore = 200;
    87 
    87 
    88 var friendlyfactor: LongInt = 300;
    88 var friendlyfactor: LongInt = 300;
    89     KnownExplosion: record
    89     KnownExplosion: record
   333             exit(-1);
   333             exit(-1);
   334     end;
   334     end;
   335 end;
   335 end;
   336 
   336 
   337 function TraceShoveFall(x, y, dX, dY: Real): LongInt;
   337 function TraceShoveFall(x, y, dX, dY: Real): LongInt;
   338 var dmg: LongInt;
   338 var dmg, v: LongInt;
   339 begin
   339 begin
       
   340 v:= random($FFFFFFFF);
   340     while true do
   341     while true do
   341     begin
   342     begin
   342         x:= x + dX;
   343         x:= x + dX;
   343         y:= y + dY;
   344         y:= y + dY;
   344         dY:= dY + cGravityf;
   345         dY:= dY + cGravityf;
       
   346 
       
   347         if ((trunc(y) and LAND_HEIGHT_MASK) = 0) and ((trunc(x) and LAND_WIDTH_MASK) = 0) then 
       
   348             begin
       
   349             LandPixels[trunc(y), trunc(x)]:= v;
       
   350             UpdateLandTexture(trunc(X), 1, trunc(Y), 1, true);
       
   351             end;
       
   352 
       
   353         // consider adding dX/dY calc here for fall damage
   345         if TestCollExcludingObjects(trunc(x), trunc(y), cHHRadius) then
   354         if TestCollExcludingObjects(trunc(x), trunc(y), cHHRadius) then
   346         begin
   355         begin
   347             if 0.4 < dY then
   356             if 0.4 < dY then
   348             begin
   357             begin
   349                 dmg := 1 + trunc((abs(dY) - 0.4) * 70);
   358                 dmg := 1 + trunc((abs(dY) - 0.4) * 70);
   418 function RateShove(Me: PGear; x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt;
   427 function RateShove(Me: PGear; x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt;
   419 var i, fallDmg, dmg, rate: LongInt;
   428 var i, fallDmg, dmg, rate: LongInt;
   420     dX, dY, dmgMod: real;
   429     dX, dY, dmgMod: real;
   421 begin
   430 begin
   422 fallDmg:= 0;
   431 fallDmg:= 0;
   423 dX:= gdX * 0.005 * kick;
   432 dX:= gdX * 0.01 * kick;
   424 dY:= gdY * 0.005 * kick;
   433 dY:= gdY * 0.01 * kick;
   425 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent;
   434 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent;
   426 rate:= 0;
   435 rate:= 0;
   427 for i:= 0 to Pred(Targets.Count) do
   436 for i:= 0 to Pred(Targets.Count) do
   428     with Targets.ar[i] do
   437     with Targets.ar[i] do
   429       if skip then 
   438       if skip then 
   430         if (Flags and afSetSkip = 0) then skip:= false else {still skip}
   439         if (Flags and afSetSkip = 0) then skip:= false else {still skip}
   431       else  
   440       else  
   432         begin
   441         begin
   433         dmg:= 0;
   442         dmg:= 0;
   434         if abs(Point.x - x) + abs(Point.y - y) < r then
   443         if abs(Point.x - x) + abs(Point.y - y) < r then
   435             begin
       
   436             dmg:= r - trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y)));
   444             dmg:= r - trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y)));
   437             dmg:= trunc(dmg * dmgMod);
   445 
   438             end;
       
   439         if dmg > 0 then
   446         if dmg > 0 then
   440             begin
   447             begin
   441             if (Flags and afSetSkip <> 0) then skip:= true;
   448             if (Flags and afSetSkip <> 0) then skip:= true;
   442             if (Flags and afTrackFall <> 0) then 
   449             if (Flags and afTrackFall <> 0) then 
   443                 fallDmg:= trunc(TraceShoveFall(Point.x, Point.y - 2, dX, dY) * dmgMod);
   450                 fallDmg:= trunc(TraceShoveFall(Point.x, Point.y - 2, dX, dY) * dmgMod);