hedgewars/uAIMisc.pas
changeset 8884 08fe08651130
parent 8845 8cf1ed3bae45
child 8895 95177c18e38c
equal deleted inserted replaced
8882:73d6d7f27945 8884:08fe08651130
    62 function  RatePlace(Gear: PGear): LongInt;
    62 function  RatePlace(Gear: PGear): LongInt;
    63 function  TestColl(x, y, r: LongInt): boolean; inline;
    63 function  TestColl(x, y, r: LongInt): boolean; inline;
    64 function  TestCollExcludingObjects(x, y, r: LongInt): boolean; inline;
    64 function  TestCollExcludingObjects(x, y, r: LongInt): boolean; inline;
    65 function  TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline;
    65 function  TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline;
    66 function  TraceShoveFall(x, y, dX, dY: Real): LongInt;
    66 function  TraceShoveFall(x, y, dX, dY: Real): LongInt;
    67 function TestCollWithLand(x, y, r: LongInt): boolean; inline;
    67 function  TestCollWithLand(x, y, r: LongInt): boolean; inline;
    68 
    68 
    69 function  RateExplosion(Me: PGear; x, y, r: LongInt): LongInt; inline;
    69 function  RateExplosion(Me: PGear; x, y, r: LongInt): LongInt; inline;
    70 function  RateExplosion(Me: PGear; x, y, r: LongInt; Flags: LongWord): LongInt;
    70 function  RateExplosion(Me: PGear; x, y, r: LongInt; Flags: LongWord): LongInt;
    71 function  RateShove(x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt;
    71 function  RateShove(x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt;
    72 function  RateShotgun(Me: PGear; gdX, gdY: real; x, y: LongInt): LongInt;
    72 function  RateShotgun(Me: PGear; gdX, gdY: real; x, y: LongInt): LongInt;
    88         ar: array[0..Pred(MAXBONUS div 8)] of TBonus;  // don't use too many
    88         ar: array[0..Pred(MAXBONUS div 8)] of TBonus;  // don't use too many
    89         end;
    89         end;
    90 
    90 
    91 const KillScore = 200;
    91 const KillScore = 200;
    92 var friendlyfactor: LongInt = 300;
    92 var friendlyfactor: LongInt = 300;
       
    93 var dmgMod: real = 1.0;
    93 
    94 
    94 implementation
    95 implementation
    95 uses uCollisions, uVariables, uUtils, uLandTexture, uGearsUtils;
    96 uses uCollisions, uVariables, uUtils, uLandTexture, uGearsUtils;
    96 
    97 
    97 var 
    98 var 
   410     RateExplosion:= RateExplosion(Me, x, y, r, 0);
   411     RateExplosion:= RateExplosion(Me, x, y, r, 0);
   411 end;
   412 end;
   412 
   413 
   413 function RateExplosion(Me: PGear; x, y, r: LongInt; Flags: LongWord): LongInt;
   414 function RateExplosion(Me: PGear; x, y, r: LongInt; Flags: LongWord): LongInt;
   414 var i, fallDmg, dmg, dmgBase, rate, erasure: LongInt;
   415 var i, fallDmg, dmg, dmgBase, rate, erasure: LongInt;
   415     dX, dY, dmgMod: real;
   416     dX, dY: real;
   416     hadSkips: boolean;
   417     hadSkips: boolean;
   417 begin
   418 begin
   418 fallDmg:= 0;
   419 fallDmg:= 0;
   419 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent;
       
   420 rate:= 0;
   420 rate:= 0;
   421 // add our virtual position
   421 // add our virtual position
   422 with Targets.ar[Targets.Count] do
   422 with Targets.ar[Targets.Count] do
   423     begin
   423     begin
   424     Point.x:= hwRound(Me^.X);
   424     Point.x:= hwRound(Me^.X);
   478     RateExplosion:= rate;
   478     RateExplosion:= rate;
   479 end;
   479 end;
   480 
   480 
   481 function RateShove(x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt;
   481 function RateShove(x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt;
   482 var i, fallDmg, dmg, rate: LongInt;
   482 var i, fallDmg, dmg, rate: LongInt;
   483     dX, dY, dmgMod: real;
   483     dX, dY: real;
   484 begin
   484 begin
   485 fallDmg:= 0;
   485 fallDmg:= 0;
   486 dX:= gdX * 0.01 * kick;
   486 dX:= gdX * 0.01 * kick;
   487 dY:= gdY * 0.01 * kick;
   487 dY:= gdY * 0.01 * kick;
   488 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent;
       
   489 rate:= 0;
   488 rate:= 0;
   490 for i:= 0 to Pred(Targets.Count) do
   489 for i:= 0 to Pred(Targets.Count) do
   491     with Targets.ar[i] do
   490     with Targets.ar[i] do
   492       if skip then 
   491       if skip then 
   493         if (Flags and afSetSkip = 0) then skip:= false else {still skip}
   492         if (Flags and afSetSkip = 0) then skip:= false else {still skip}
   522 RateShove:= rate * 1024
   521 RateShove:= rate * 1024
   523 end;
   522 end;
   524 
   523 
   525 function RateShotgun(Me: PGear; gdX, gdY: real; x, y: LongInt): LongInt;
   524 function RateShotgun(Me: PGear; gdX, gdY: real; x, y: LongInt): LongInt;
   526 var i, dmg, fallDmg, baseDmg, rate, erasure: LongInt;
   525 var i, dmg, fallDmg, baseDmg, rate, erasure: LongInt;
   527     dX, dY, dmgMod: real;
   526     dX, dY: real;
   528     hadSkips: boolean;
   527     hadSkips: boolean;
   529 begin
   528 begin
   530 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent;
       
   531 rate:= 0;
   529 rate:= 0;
   532 gdX:= gdX * 0.01;
   530 gdX:= gdX * 0.01;
   533 gdY:= gdX * 0.01;
   531 gdY:= gdX * 0.01;
   534 // add our virtual position
   532 // add our virtual position
   535 with Targets.ar[Targets.Count] do
   533 with Targets.ar[Targets.Count] do