hedgewars/uGearsHandlersMess.pas
changeset 15713 73c4e7d47575
parent 15712 b496233ac26d
child 15714 7a4b719ac611
equal deleted inserted replaced
15712:b496233ac26d 15713:73c4e7d47575
  7200         MakeSentryStep := true
  7200         MakeSentryStep := true
  7201     end
  7201     end
  7202 end;
  7202 end;
  7203     
  7203     
  7204 function MakeSentryJump(Sentry: PGear; maxXStep, maxYStep: LongInt): Boolean;
  7204 function MakeSentryJump(Sentry: PGear; maxXStep, maxYStep: LongInt): Boolean;
  7205 var x, y, offsetX, offsetY: LongInt;
  7205 var x, y, offsetX, offsetY, direction: LongInt;
  7206     jumpTime: hwFloat;
  7206     jumpTime: hwFloat;
  7207 begin
  7207 begin
  7208     MakeSentryJump := false;
  7208     MakeSentryJump := false;
  7209     x := hwRound(Sentry^.X);
  7209     x := hwRound(Sentry^.X);
  7210     y := hwRound(Sentry^.Y);
  7210     y := hwRound(Sentry^.Y);
  7211     offsetX := (maxXStep - Sentry^.Radius) * hwSign(Sentry^.dX);
  7211     offsetX := maxXStep - Sentry^.Radius;
       
  7212     direction := hwSign(Sentry^.dX);
       
  7213 
  7212     repeat
  7214     repeat
  7213         for offsetY := -maxYStep - 1 to maxYStep + 1 do
  7215         for offsetY := -maxYStep - 1 to maxYStep + 1 do
  7214         begin
  7216             if TestCollisionYImpl(x + offsetX * direction, y + offsetY, Sentry^.Radius, 1, Sentry^.CollisionMask) <> 0 then
  7215             if TestCollisionYImpl(x + offsetX, y + offsetY, Sentry^.Radius, 1, Sentry^.CollisionMask) <> 0 then
       
  7216                 break;
  7217                 break;
  7217         end;
       
  7218         if (offsetY >= -maxYStep) and (offsetY <= maxYStep) then
  7218         if (offsetY >= -maxYStep) and (offsetY <= maxYStep) then
  7219             break;
  7219             break;
  7220         Dec(offsetX, Sentry^.Radius * hwSign(Sentry^.dX));
  7220         Dec(offsetX, Sentry^.Radius);
  7221     until offsetX <= 0;
  7221     until offsetX <= 0;
  7222 
  7222 
  7223     if (offsetX > 0) and (not cGravity.isNegative) then
  7223     if (offsetX >= Sentry^.Radius) and (not cGravity.isNegative) then
  7224     begin
  7224     begin
  7225         Sentry^.dY := -_0_25;
  7225         Sentry^.dY := -_0_25;
  7226         jumpTime := _2 * Sentry^.dY / cGravity;
  7226         jumpTime := _2 * Sentry^.dY / cGravity;
  7227         Sentry^.dX := SignAs(int2hwFloat(abs(offsetX) - Sentry^.Radius) / jumpTime, Sentry^.dX);
  7227         Sentry^.dX := SignAs(int2hwFloat(offsetX - Sentry^.Radius) / jumpTime, Sentry^.dX);
  7228         MakeSentryJump := true;
  7228         MakeSentryJump := true;
  7229     end;
  7229     end;
  7230 end;
  7230 end;
  7231 
  7231 
  7232 function TraceAttackPath(fromX, fromY, toX, toY, step: hwFloat; mask: Word): LongWord;
  7232 function TraceAttackPath(fromX, fromY, toX, toY, step: hwFloat; mask: Word): LongWord;