hedgewars/uAIMisc.pas
changeset 15631 308930fe5f4a
parent 15410 7718bdf60d45
child 15632 4ae2ebe812be
equal deleted inserted replaced
15630:899fd1841399 15631:308930fe5f4a
    25 const MAXBONUS = 1024;
    25 const MAXBONUS = 1024;
    26 
    26 
    27       afTrackFall  = $00000001;
    27       afTrackFall  = $00000001;
    28       afErasesLand = $00000002;
    28       afErasesLand = $00000002;
    29       afSetSkip    = $00000004;
    29       afSetSkip    = $00000004;
       
    30       afIgnoreMe   = $00000008;
    30 
    31 
    31       BadTurn = Low(LongInt) div 4;
    32       BadTurn = Low(LongInt) div 4;
    32 
    33 
    33 type TTarget = record // starting to look more and more like a gear
    34 type TTarget = record // starting to look more and more like a gear
    34     Point: TPoint;
    35     Point: TPoint;
   537     hadSkips: boolean;
   538     hadSkips: boolean;
   538 begin
   539 begin
   539 x:= round(CheckWrap(real(x)));
   540 x:= round(CheckWrap(real(x)));
   540 fallDmg:= 0;
   541 fallDmg:= 0;
   541 rate:= 0;
   542 rate:= 0;
   542 // add our virtual position
   543 
   543 with Targets.ar[Targets.Count] do
   544 if (Flags and afIgnoreMe) = 0 then
   544     begin
   545     with Targets.ar[Targets.Count] do
   545     Point.x:= hwRound(Me^.X);
   546         // add our virtual position
   546     Point.y:= hwRound(Me^.Y);
   547         begin
   547     skip:= false;
   548         Point.x:= hwRound(Me^.X);
   548     matters:= true;
   549         Point.y:= hwRound(Me^.Y);
   549     Kind:= gtHedgehog;
   550         skip:= false;
   550     Density:= 1;
   551         matters:= true;
   551     Radius:= cHHRadius;
   552         Kind:= gtHedgehog;
   552     Score:= - ThinkingHH^.Health
   553         Density:= 1;
   553     end;
   554         Radius:= cHHRadius;
       
   555         Score:= - ThinkingHH^.Health
       
   556         end;
       
   557 
   554 // rate explosion
   558 // rate explosion
   555 
       
   556 if (Flags and afErasesLand <> 0) and (GameFlags and gfSolidLand = 0) then erasure:= r
   559 if (Flags and afErasesLand <> 0) and (GameFlags and gfSolidLand = 0) then erasure:= r
   557 else erasure:= 0;
   560 else erasure:= 0;
   558 
   561 
   559 hadSkips:= false;
   562 hadSkips:= false;
   560 
   563 
   561 for i:= 0 to Targets.Count do
   564 for i:= 0 to Targets.Count do
   562     if not Targets.ar[i].dead then
   565     if not Targets.ar[i].dead then
   563         with Targets.ar[i] do
   566         with Targets.ar[i] do
   564           if not matters then hadSkips:= true
   567           if not matters then
   565             else
   568             hadSkips:= true
       
   569           else
   566             begin
   570             begin
   567             dmg:= 0;
   571             dmg:= 0;
   568             dmgBase:= r + Radius div 2;
   572             dmgBase:= r + Radius div 2;
   569             if abs(Point.x - x) + abs(Point.y - y) < dmgBase then
   573             if abs(Point.x - x) + abs(Point.y - y) < dmgBase then
   570                 dmg:= trunc(dmgMod * min((dmgBase - trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y)))) div 2, r));
   574                 dmg:= trunc(dmgMod * min((dmgBase - trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y)))) div 2, r));