hedgewars/uAIMisc.pas
changeset 6766 31ba56a8ec43
parent 6700 e04da46ee43c
child 6767 ccbf07b38a43
equal deleted inserted replaced
6765:8fcd2508c49f 6766:31ba56a8ec43
   233     
   233     
   234 TestColl:=(((x+r) and LAND_WIDTH_MASK) = 0)and(((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] <> 0)
   234 TestColl:=(((x+r) and LAND_WIDTH_MASK) = 0)and(((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] <> 0)
   235 end;
   235 end;
   236 
   236 
   237 function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt;
   237 function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt;
   238 var i, dmg, rate: LongInt;
   238 var i, dmg, dmgBase, rate: LongInt;
   239 begin
   239 begin
   240 rate:= 0;
   240 rate:= 0;
   241 // add our virtual position
   241 // add our virtual position
   242 with Targets.ar[Targets.Count] do
   242 with Targets.ar[Targets.Count] do
   243     begin
   243     begin
   244     Point.x:= hwRound(Me^.X);
   244     Point.x:= hwRound(Me^.X);
   245     Point.y:= hwRound(Me^.Y);
   245     Point.y:= hwRound(Me^.Y);
   246     Score:= - ThinkingHH^.Health
   246     Score:= - ThinkingHH^.Health
   247     end;
   247     end;
   248 // rate explosion
   248 // rate explosion
       
   249 dmgBase:= r + cHHRadius div 2;
   249 for i:= 0 to Targets.Count do
   250 for i:= 0 to Targets.Count do
   250     with Targets.ar[i] do
   251     with Targets.ar[i] do
   251         begin
   252         begin
   252         dmg:= hwRound(_0_01 * cDamageModifier * min((r + cHHRadius div 2 - LongInt(DistanceI(Point.x - x, Point.y - y).Round)) div 2, r) * cDamagePercent);
   253         dmg:= 0;
       
   254         if abs(Point.x - x) + abs(Point.y - y) < dmgBase then
       
   255             dmg:= hwRound(_0_01 * cDamageModifier * min((dmgBase - LongInt(DistanceI(Point.x - x, Point.y - y).Round)) div 2, r) * cDamagePercent);
   253 
   256 
   254         if dmg > 0 then
   257         if dmg > 0 then
   255             begin
   258             begin
   256             if dmg >= abs(Score) then
   259             if dmg >= abs(Score) then
   257                 if Score > 0 then
   260                 if Score > 0 then