hedgewars/uAIMisc.pas
changeset 100 f324a18698fe
parent 95 1ef5e2c41115
child 108 08f1fe6f21f8
equal deleted inserted replaced
99:fd9613278d1b 100:f324a18698fe
    53 
    53 
    54 procedure FillTargets;
    54 procedure FillTargets;
    55 procedure FillBonuses(isAfterAttack: boolean);
    55 procedure FillBonuses(isAfterAttack: boolean);
    56 procedure AwareOfExplosion(x, y, r: integer);
    56 procedure AwareOfExplosion(x, y, r: integer);
    57 function RatePlace(Gear: PGear): integer;
    57 function RatePlace(Gear: PGear): integer;
    58 function DxDy2AttackAngle(const _dY, _dX: Extended): integer;
       
    59 function TestColl(x, y, r: integer): boolean;
    58 function TestColl(x, y, r: integer): boolean;
    60 function RateExplosion(Me: PGear; x, y, r: integer): integer;
    59 function RateExplosion(Me: PGear; x, y, r: integer): integer;
    61 function RateShove(Me: PGear; x, y, r, power: integer): integer;
    60 function RateShove(Me: PGear; x, y, r, power: integer): integer;
    62 function HHGo(Gear, AltGear: PGear; out GoInfo: TGoInfo): boolean;
    61 function HHGo(Gear, AltGear: PGear; out GoInfo: TGoInfo): boolean;
    63 
    62 
   164          begin
   163          begin
   165          r:= round(sqrt(sqr(Gear.X - X) + sqr(Gear.Y - y)));
   164          r:= round(sqrt(sqr(Gear.X - X) + sqr(Gear.Y - y)));
   166          if r < Radius then
   165          if r < Radius then
   167             inc(Result, Score * (Radius - r))
   166             inc(Result, Score * (Radius - r))
   168          end;
   167          end;
   169 end;
       
   170 
       
   171 function DxDy2AttackAngle(const _dY, _dX: Extended): integer;
       
   172 const piDIVMaxAngle: Extended = pi/cMaxAngle;
       
   173 asm
       
   174         fld     _dY
       
   175         fld     _dX
       
   176         fpatan
       
   177         fld     piDIVMaxAngle
       
   178         fdiv
       
   179         sub     esp, 4
       
   180         fistp   dword ptr [esp]
       
   181         pop     eax
       
   182 end;
   168 end;
   183 
   169 
   184 function TestColl(x, y, r: integer): boolean;
   170 function TestColl(x, y, r: integer): boolean;
   185 begin
   171 begin
   186 Result:=(((x-r) and $FFFFF800) = 0)and(((y-r) and $FFFFFC00) = 0) and (Land[y-r, x-r] <> 0);
   172 Result:=(((x-r) and $FFFFF800) = 0)and(((y-r) and $FFFFFC00) = 0) and (Land[y-r, x-r] <> 0);