hedgewars/uGearsUtils.pas
changeset 8007 b07ce9dfc6bb
parent 8003 7d8bce524daf
child 8026 4a4f21070479
child 8161 0b8beacff8a5
equal deleted inserted replaced
8005:6d47a4f47e10 8007:b07ce9dfc6bb
   553 end;
   553 end;
   554 
   554 
   555 procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean);
   555 procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean);
   556 var x: LongInt;
   556 var x: LongInt;
   557     y, sy: LongInt;
   557     y, sy: LongInt;
   558     ar: array[0..511] of TPoint;
   558     ar: array[0..1023] of TPoint;
   559     ar2: array[0..1023] of TPoint;
   559     ar2: array[0..2047] of TPoint;
   560     cnt, cnt2: Longword;
   560     cnt, cnt2: Longword;
   561     delta: LongInt;
   561     delta: LongInt;
   562     ignoreNearObjects, ignoreOverlap, tryAgain: boolean;
   562     ignoreNearObjects, ignoreOverlap, tryAgain: boolean;
   563 begin
   563 begin
   564 ignoreNearObjects:= false; // try not skipping proximity at first
   564 ignoreNearObjects:= false; // try not skipping proximity at first
   565 ignoreOverlap:= false; // this not only skips proximity, but allows overlapping objects (barrels, mines, hogs, crates).  Saving it for a 3rd pass.  With this active, winning AI Survival goes back to virtual impossibility
   565 ignoreOverlap:= false; // this not only skips proximity, but allows overlapping objects (barrels, mines, hogs, crates).  Saving it for a 3rd pass.  With this active, winning AI Survival goes back to virtual impossibility
   566 tryAgain:= true;
   566 tryAgain:= true;
   567 while tryAgain do
   567 while tryAgain do
   568     begin
   568     begin
   569     delta:= 250;
   569     delta:= LAND_WIDTH div 16;
   570     cnt2:= 0;
   570     cnt2:= 0;
   571     repeat
   571     repeat
   572         x:= Left + LongInt(GetRandom(Delta));
   572         x:= Left + max(LAND_WIDTH div 2048, LongInt(GetRandom(Delta)));
   573         repeat
   573         repeat
   574             inc(x, Delta);
   574             inc(x, Delta);
   575             cnt:= 0;
   575             cnt:= 0;
   576             y:= min(1024, topY) - 2 * Gear^.Radius;
   576             y:= min(1024, topY) - 2 * Gear^.Radius;
   577             while y < cWaterLine do
   577             while y < cWaterLine do