hedgewars/uAIMisc.pas
changeset 15394 7718bdf60d45
parent 15371 381c828865e7
equal deleted inserted replaced
15393:262003f2e19a 15394:7718bdf60d45
   959 function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean;
   959 function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean;
   960 var pX, pY, tY: LongInt;
   960 var pX, pY, tY: LongInt;
   961 begin
   961 begin
   962 HHGo:= false;
   962 HHGo:= false;
   963 Gear^.CollisionMask:= lfNotCurHogCrate;
   963 Gear^.CollisionMask:= lfNotCurHogCrate;
       
   964 
       
   965 Gear^.dX.isNegative:= (Gear^.Message and gmLeft) <> 0;
       
   966 
   964 AltGear^:= Gear^;
   967 AltGear^:= Gear^;
   965 
   968 
   966 GoInfo.Ticks:= 0;
   969 GoInfo.Ticks:= 0;
   967 GoInfo.FallPix:= 0;
   970 GoInfo.FallPix:= 0;
   968 GoInfo.JumpType:= jmpNone;
   971 GoInfo.JumpType:= jmpNone;
  1010             exit(true)
  1013             exit(true)
  1011             end;
  1014             end;
  1012         continue
  1015         continue
  1013         end;
  1016         end;
  1014 
  1017 
  1015         // usual walk
  1018     // usual walk
  1016         if (Gear^.Message and gmLeft) <> 0 then
  1019     Gear^.dX:= SignAs(cLittle, Gear^.dX);
  1017             Gear^.dX:= -cLittle
  1020 
  1018         else
  1021     if MakeHedgehogsStep(Gear) then
  1019             if (Gear^.Message and gmRight) <> 0 then
  1022         inc(GoInfo.Ticks, cHHStepTicks);
  1020                 Gear^.dX:=  cLittle
  1023 
  1021             else
  1024     // we have moved for 1 px
  1022                 exit(false);
  1025     if (pX <> hwRound(Gear^.X)) and ((Gear^.State and gstMoving) = 0) then
  1023 
  1026         exit(true)
  1024         if MakeHedgehogsStep(Gear) then
       
  1025             inc(GoInfo.Ticks, cHHStepTicks);
       
  1026 
       
  1027         // we have moved for 1 px
       
  1028         if (pX <> hwRound(Gear^.X)) and ((Gear^.State and gstMoving) = 0) then
       
  1029             exit(true)
       
  1030 until (pX = hwRound(Gear^.X)) and (pY = hwRound(Gear^.Y)) and ((Gear^.State and gstMoving) = 0);
  1027 until (pX = hwRound(Gear^.X)) and (pY = hwRound(Gear^.Y)) and ((Gear^.State and gstMoving) = 0);
  1031 
  1028 
  1032 HHJump(AltGear, jmpHJump, GoInfo);
  1029 HHJump(AltGear, jmpHJump, GoInfo);
  1033 end;
  1030 end;
  1034 
  1031