hedgewars/uAIMisc.pas
changeset 7719 eeae1cb6b6bf
parent 7716 95117607b81a
child 7788 27f7f0190e44
equal deleted inserted replaced
7718:97ba379164ec 7719:eeae1cb6b6bf
    88 
    88 
    89 const KillScore = 200;
    89 const KillScore = 200;
    90 var friendlyfactor: LongInt = 300;
    90 var friendlyfactor: LongInt = 300;
    91 
    91 
    92 implementation
    92 implementation
    93 uses uCollisions, uVariables, uUtils, uLandTexture;
    93 uses uCollisions, uVariables, uUtils, uLandTexture, uGearsUtils;
    94 
    94 
    95 var 
    95 var 
    96     KnownExplosion: record
    96     KnownExplosion: record
    97         X, Y, Radius: LongInt
    97         X, Y, Radius: LongInt
    98         end = (X: 0; Y: 0; Radius: 0);
    98         end = (X: 0; Y: 0; Radius: 0);
   729             HHJump(AltGear, jmpLJump, GoInfo);
   729             HHJump(AltGear, jmpLJump, GoInfo);
   730             exit(true)
   730             exit(true)
   731             end;
   731             end;
   732         continue
   732         continue
   733         end;
   733         end;
   734         
   734 
   735         // usual walk
   735         // usual walk
   736         if (Gear^.Message and gmLeft) <> 0 then
   736         if (Gear^.Message and gmLeft) <> 0 then
   737             Gear^.dX:= -cLittle
   737             Gear^.dX:= -cLittle
   738         else
   738         else
   739             if (Gear^.Message and gmRight) <> 0 then
   739             if (Gear^.Message and gmRight) <> 0 then
   740                 Gear^.dX:=  cLittle
   740                 Gear^.dX:=  cLittle
   741             else
   741             else
   742                 exit(false);
   742                 exit(false);
   743                 
   743 
   744         if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
   744         if MakeHedgehogsStep(Gear) then
   745             begin
   745             inc(GoInfo.Ticks, cHHStepTicks);
   746             Gear^.Y:= Gear^.Y - _1;
   746 
   747         if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
       
   748             begin
       
   749             Gear^.Y:= Gear^.Y - _1;
       
   750         if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
       
   751             begin
       
   752             Gear^.Y:= Gear^.Y - _1;
       
   753         if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
       
   754             begin
       
   755             Gear^.Y:= Gear^.Y - _1;
       
   756         if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
       
   757             begin
       
   758             Gear^.Y:= Gear^.Y - _1;
       
   759         if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
       
   760             begin
       
   761             Gear^.Y:= Gear^.Y - _1;
       
   762             if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
       
   763                 Gear^.Y:= Gear^.Y + _6
       
   764             end else Gear^.Y:= Gear^.Y + _5 else
       
   765             end else Gear^.Y:= Gear^.Y + _4 else
       
   766             end else Gear^.Y:= Gear^.Y + _3 else
       
   767             end else Gear^.Y:= Gear^.Y + _2 else
       
   768             end else Gear^.Y:= Gear^.Y + _1
       
   769             end;
       
   770 
       
   771         if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
       
   772         begin
       
   773             Gear^.X:= Gear^.X + int2hwFloat(hwSign(Gear^.dX));
       
   774             inc(GoInfo.Ticks, cHHStepTicks)
       
   775         end;
       
   776 
       
   777         // too scared to reformat this part
       
   778         if TestCollisionYwithGear(Gear, 1) = 0 then
       
   779             begin
       
   780             Gear^.Y:= Gear^.Y + _1;
       
   781             
       
   782         if TestCollisionYwithGear(Gear, 1) = 0 then
       
   783             begin
       
   784             Gear^.Y:= Gear^.Y + _1;
       
   785             
       
   786         if TestCollisionYwithGear(Gear, 1) = 0 then
       
   787             begin
       
   788             Gear^.Y:= Gear^.Y + _1;
       
   789 
       
   790         if TestCollisionYwithGear(Gear, 1) = 0 then
       
   791             begin
       
   792             Gear^.Y:= Gear^.Y + _1;
       
   793 
       
   794         if TestCollisionYwithGear(Gear, 1) = 0 then
       
   795             begin
       
   796             Gear^.Y:= Gear^.Y + _1;
       
   797 
       
   798         if TestCollisionYwithGear(Gear, 1) = 0 then
       
   799             begin
       
   800             Gear^.Y:= Gear^.Y + _1;
       
   801 
       
   802         if TestCollisionYwithGear(Gear, 1) = 0 then
       
   803             begin
       
   804             Gear^.Y:= Gear^.Y - _6;
       
   805             Gear^.dY:= _0;
       
   806             Gear^.State:= Gear^.State or gstMoving
       
   807             end
       
   808         end
       
   809         end
       
   810         end
       
   811         end
       
   812         end
       
   813         end;
       
   814         // we have moved for 1 px
   747         // we have moved for 1 px
   815         if (pX <> hwRound(Gear^.X)) and ((Gear^.State and gstMoving) = 0) then
   748         if (pX <> hwRound(Gear^.X)) and ((Gear^.State and gstMoving) = 0) then
   816             exit(true)
   749             exit(true)
   817 until (pX = hwRound(Gear^.X)) and (pY = hwRound(Gear^.Y)) and ((Gear^.State and gstMoving) = 0);
   750 until (pX = hwRound(Gear^.X)) and (pY = hwRound(Gear^.Y)) and ((Gear^.State and gstMoving) = 0);
   818 
   751