hedgewars/uGears.pas
changeset 15159 fcd697bce2a8
parent 15107 b4a0dc4e85e8
child 15169 f532203c5ceb
equal deleted inserted replaced
15158:4744d7b78c75 15159:fcd697bce2a8
  1057     with TeamsArray[p]^ do
  1057     with TeamsArray[p]^ do
  1058         for i:= 0 to cMaxHHIndex do
  1058         for i:= 0 to cMaxHHIndex do
  1059             with Hedgehogs[i] do
  1059             with Hedgehogs[i] do
  1060                 if (Gear <> nil) and (Gear^.State and gsttmpFlag <> 0) then
  1060                 if (Gear <> nil) and (Gear^.State and gsttmpFlag <> 0) then
  1061                     begin
  1061                     begin
       
  1062                     // Get flower position
  1062                     x:= hwRound(Gear^.X) - SpritesData[sprTargetBee].Width div 2;
  1063                     x:= hwRound(Gear^.X) - SpritesData[sprTargetBee].Width div 2;
  1063                     y:= hwRound(Gear^.Y) - SpritesData[sprTargetBee].Height div 2;
  1064                     y:= hwRound(Gear^.Y) - SpritesData[sprTargetBee].Height div 2;
  1064                     x:= max(min(x, RightX - SpritesData[sprTargetBee].Width), LeftX);
  1065                     // Calculate offset from map boundaries and border
       
  1066                     if hasBorder then
       
  1067                         x:= max(min(x, RightX - SpritesData[sprTargetBee].Width) - cBorderWidth, LeftX + cBorderWidth)
       
  1068                     else
       
  1069                         x:= max(min(x, RightX - SpritesData[sprTargetBee].Width), LeftX);
  1065                     y:= max(y, TopY);
  1070                     y:= max(y, TopY);
       
  1071 
       
  1072                     // Place flower
  1066                     ForcePlaceOnLand(x, y, sprTargetBee, 0, lfBasic, $FFFFFFFF, false, false, false);
  1073                     ForcePlaceOnLand(x, y, sprTargetBee, 0, lfBasic, $FFFFFFFF, false, false, false);
       
  1074 
       
  1075                     // Place hog
  1067                     Gear^.Y:= int2hwFloat(hwRound(Gear^.Y) - (SpritesData[sprTargetBee].Height div 2) - Gear^.Radius);
  1076                     Gear^.Y:= int2hwFloat(hwRound(Gear^.Y) - (SpritesData[sprTargetBee].Height div 2) - Gear^.Radius);
  1068                     AddCI(Gear);
  1077                     AddCI(Gear);
  1069                     Gear^.State:= Gear^.State and (not gsttmpFlag);
  1078                     Gear^.State:= Gear^.State and (not gsttmpFlag);
       
  1079 
  1070                     AddFileLog('Placed flower for hog at coordinates (' + inttostr(x) + ',' + inttostr(y) + ')')
  1080                     AddFileLog('Placed flower for hog at coordinates (' + inttostr(x) + ',' + inttostr(y) + ')')
  1071                     end;
  1081                     end;
  1072 
  1082 
  1073 
  1083 
  1074 // divided teams: sort the hedgehogs from left to right by clan and shuffle clan members
  1084 // divided teams: sort the hedgehogs from left to right by clan and shuffle clan members