hedgewars/uGears.pas
changeset 2376 ece7b87f1334
parent 2366 b38efe489615
child 2388 76ccf12faf22
equal deleted inserted replaced
2375:99f05a01a6a3 2376:ece7b87f1334
    77     SpeechType: Longword = 1;
    77     SpeechType: Longword = 1;
    78     SpeechText: shortstring;
    78     SpeechText: shortstring;
    79 
    79 
    80 implementation
    80 implementation
    81 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions,
    81 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions,
    82 	uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers, 
    82 	uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers,
    83 {$IFDEF GLES11}
    83 {$IFDEF GLES11}
    84 	gles11,
    84 	gles11,
    85 {$ELSE}
    85 {$ELSE}
    86 	GL,
    86 	GL,
    87 {$ENDIF}
    87 {$ENDIF}
   434 			t:= max(Gear^.Damage, Gear^.Health);
   434 			t:= max(Gear^.Damage, Gear^.Health);
   435 			Gear^.Damage:= t;
   435 			Gear^.Damage:= t;
   436 			AddGear(hwRound(Gear^.X), min(hwRound(Gear^.Y),cWaterLine+cVisibleWater+32), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
   436 			AddGear(hwRound(Gear^.X), min(hwRound(Gear^.Y),cWaterLine+cVisibleWater+32), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
   437 			uStats.HedgehogDamaged(Gear)
   437 			uStats.HedgehogDamaged(Gear)
   438 			end;
   438 			end;
   439 	
   439 
   440 		team:= PHedgehog(Gear^.Hedgehog)^.Team;
   440 		team:= PHedgehog(Gear^.Hedgehog)^.Team;
   441 		if CurrentHedgehog^.Gear = Gear then
   441 		if CurrentHedgehog^.Gear = Gear then
   442 			FreeActionsList; // to avoid ThinkThread on drawned gear
   442 			FreeActionsList; // to avoid ThinkThread on drawned gear
   443 		
   443 
   444 		PHedgehog(Gear^.Hedgehog)^.Gear:= nil;
   444 		PHedgehog(Gear^.Hedgehog)^.Gear:= nil;
   445 		inc(KilledHHs);
   445 		inc(KilledHHs);
   446 		RecountTeamHealth(team)
   446 		RecountTeamHealth(team)
   447 		end;
   447 		end;
   448 {$IFDEF DEBUGFILE}
   448 {$IFDEF DEBUGFILE}
   526 t:= GearsList;
   526 t:= GearsList;
   527 while t <> nil do
   527 while t <> nil do
   528 	begin
   528 	begin
   529 	Gear:= t;
   529 	Gear:= t;
   530 	t:= Gear^.NextGear;
   530 	t:= Gear^.NextGear;
   531 	if Gear^.Active then 
   531 	if Gear^.Active then
   532         begin
   532         begin
   533         if Gear^.RenderTimer and (Gear^.Timer > 500) and ((Gear^.Timer mod 1000) = 0) then
   533         if Gear^.RenderTimer and (Gear^.Timer > 500) and ((Gear^.Timer mod 1000) = 0) then
   534             begin
   534             begin
   535             if Gear^.Tex <> nil then FreeTexture(Gear^.Tex); 
   535             if Gear^.Tex <> nil then FreeTexture(Gear^.Tex);
   536             Gear^.Tex:= RenderStringTex(inttostr(Gear^.Timer div 1000), $FFFFFFFF, fntSmall);
   536             Gear^.Tex:= RenderStringTex(inttostr(Gear^.Timer div 1000), $FFFFFFFF, fntSmall);
   537             end;
   537             end;
   538         Gear^.doStep(Gear);
   538         Gear^.doStep(Gear);
   539         end
   539         end
   540 	end;
   540 	end;
   615 			end;
   615 			end;
   616 	stNTurn: begin
   616 	stNTurn: begin
   617 			if isInMultiShoot then isInMultiShoot:= false
   617 			if isInMultiShoot then isInMultiShoot:= false
   618 			else begin
   618 			else begin
   619 			ResetUtilities;
   619 			ResetUtilities;
   620 			
   620 
   621 			FreeActionsList; // could send -left, -right and similar commands, so should be called before /nextturn
   621 			FreeActionsList; // could send -left, -right and similar commands, so should be called before /nextturn
   622 			
   622 
   623 			ParseCommand('/nextturn', true);
   623 			ParseCommand('/nextturn', true);
   624 			SwitchHedgehog;
   624 			SwitchHedgehog;
   625 
   625 
   626 			inc(step); // FIXME wtf is that, it overflows step, and does nothing
   626 			inc(step); // FIXME wtf is that, it overflows step, and does nothing
   627 
   627 
   718                 AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
   718                 AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
   719                 RenderHealth(CurrentHedgehog^);
   719                 RenderHealth(CurrentHedgehog^);
   720                 RecountTeamHealth(CurrentHedgehog^.Team);
   720                 RecountTeamHealth(CurrentHedgehog^.Team);
   721                 end
   721                 end
   722             end;
   722             end;
   723         if ((GameFlags and gfKarma) <> 0) and 
   723         if ((GameFlags and gfKarma) <> 0) and
   724            ((GameFlags and gfInvulnerable) = 0) and
   724            ((GameFlags and gfInvulnerable) = 0) and
   725            not CurrentHedgehog^.Gear^.Invulnerable then
   725            not CurrentHedgehog^.Gear^.Invulnerable then
   726            begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
   726            begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
   727            inc(CurrentHedgehog^.Gear^.Karma, tmpDmg);
   727            inc(CurrentHedgehog^.Gear^.Karma, tmpDmg);
   728            AddGear(hwRound(CurrentHedgehog^.Gear^.X), 
   728            AddGear(hwRound(CurrentHedgehog^.Gear^.X),
   729                    hwRound(CurrentHedgehog^.Gear^.Y), 
   729                    hwRound(CurrentHedgehog^.Gear^.Y),
   730                    gtHealthTag, tmpDmg, _0, _0, 0)^.Hedgehog:= CurrentHedgehog;
   730                    gtHealthTag, tmpDmg, _0, _0, 0)^.Hedgehog:= CurrentHedgehog;
   731            end;
   731            end;
   732         end;
   732         end;
   733     end;
   733     end;
   734 	inc(Gear^.Damage, Damage);
   734 	inc(Gear^.Damage, Damage);
   786 			1,
   786 			1,
   787 			7,
   787 			7,
   788 			0);
   788 			0);
   789 	defaultPos:= false
   789 	defaultPos:= false
   790 	end else
   790 	end else
   791 if ((Gear^.State and gstWinner) <> 0) and 
   791 if ((Gear^.State and gstWinner) <> 0) and
   792    ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then
   792    ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then
   793 	begin
   793 	begin
   794 	DrawHedgehog(sx, sy,
   794 	DrawHedgehog(sx, sy,
   795 			hwSign(Gear^.dX),
   795 			hwSign(Gear^.dX),
   796 			2,
   796 			2,
   808 	defaultPos:= false
   808 	defaultPos:= false
   809 	end else
   809 	end else
   810 
   810 
   811 if (Gear^.State and gstHHDriven) <> 0 then
   811 if (Gear^.State and gstHHDriven) <> 0 then
   812 	begin
   812 	begin
   813 	if ((Gear^.State and gstHHThinking) = 0) and 
   813 	if ((Gear^.State and gstHHThinking) = 0) and
   814        ShowCrosshair and 
   814        ShowCrosshair and
   815        ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then
   815        ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then
   816 		begin
   816 		begin
   817 (* These calculations are a little complex for a few reasons:
   817 (* These calculations are a little complex for a few reasons:
   818    1: I need to draw the laser from weapon origin to nearest land
   818    1: I need to draw the laser from weapon origin to nearest land
   819    2: I need to start the beam outside the hedgie for attractiveness. 
   819    2: I need to start the beam outside the hedgie for attractiveness.
   820    3: I need to extend the beam beyond land. 
   820    3: I need to extend the beam beyond land.
   821    This routine perhaps should be pushed into uStore or somesuch instead of continuuing the increase in size of this function.
   821    This routine perhaps should be pushed into uStore or somesuch instead of continuuing the increase in size of this function.
   822 *)
   822 *)
   823 		dx:= hwSign(Gear^.dX) * m * Sin(Gear^.Angle * pi / cMaxAngle);
   823 		dx:= hwSign(Gear^.dX) * m * Sin(Gear^.Angle * pi / cMaxAngle);
   824 		dy:= - Cos(Gear^.Angle * pi / cMaxAngle);
   824 		dy:= - Cos(Gear^.Angle * pi / cMaxAngle);
   825 		if cLaserSighting then
   825 		if cLaserSighting then
   849 			if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then
   849 			if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then
   850 				begin
   850 				begin
   851 				tx:= round(lx + ax * (LAND_WIDTH div 4));
   851 				tx:= round(lx + ax * (LAND_WIDTH div 4));
   852 				ty:= round(ly + ay * (LAND_WIDTH div 4));
   852 				ty:= round(ly + ay * (LAND_WIDTH div 4));
   853 				end;
   853 				end;
   854 			
   854 
   855 			//if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
   855 			//if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
   856 				begin
   856 				begin
   857 				glDisable(GL_TEXTURE_2D);
   857 				glDisable(GL_TEXTURE_2D);
   858 				glEnable(GL_LINE_SMOOTH);
   858 				glEnable(GL_LINE_SMOOTH);
   859 
   859 
   860 				glLineWidth(1.0);
   860 				glLineWidth(1.0);
   861 				
   861 
   862 				glColor4ub($FF, $00, $00, $C0);
   862 				glColor4ub($FF, $00, $00, $C0);
   863 				VertexBuffer[0].X:= hx + WorldDx;
   863 				VertexBuffer[0].X:= hx + WorldDx;
   864 				VertexBuffer[0].Y:= hy + WorldDy;
   864 				VertexBuffer[0].Y:= hy + WorldDy;
   865 				VertexBuffer[1].X:= tx + WorldDx;
   865 				VertexBuffer[1].X:= tx + WorldDx;
   866 				VertexBuffer[1].Y:= ty + WorldDy;
   866 				VertexBuffer[1].Y:= ty + WorldDy;
   867 				
   867 
   868 				glEnableClientState(GL_VERTEX_ARRAY);
   868 				glEnableClientState(GL_VERTEX_ARRAY);
   869 				glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
   869 				glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
   870 				glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
   870 				glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
   871 				glColor4f(1, 1, 1, 1);
   871 				glColor4f(1, 1, 1, 1);
   872 				glEnable(GL_TEXTURE_2D);
   872 				glEnable(GL_TEXTURE_2D);
  1060 			amRCPlane: begin
  1060 			amRCPlane: begin
  1061 				DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0);
  1061 				DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0);
  1062 				defaultPos:= false
  1062 				defaultPos:= false
  1063 				end;
  1063 				end;
  1064 			amGirder: begin
  1064 			amGirder: begin
  1065                 DrawSpriteClipped(sprGirder, 
  1065                 DrawSpriteClipped(sprGirder,
  1066                                   sx-256, 
  1066                                   sx-256,
  1067                                   sy-256, 
  1067                                   sy-256,
  1068                                   LongInt(topY)+WorldDy, 
  1068                                   LongInt(topY)+WorldDy,
  1069                                   LongInt(rightX)+WorldDx, 
  1069                                   LongInt(rightX)+WorldDx,
  1070                                   cWaterLine+WorldDy,
  1070                                   cWaterLine+WorldDy,
  1071                                   LongInt(leftX)+WorldDx);
  1071                                   LongInt(leftX)+WorldDx);
  1072                 end;
  1072                 end;
  1073 		end;
  1073 		end;
  1074 
  1074 
  1101 			DrawHedgehog(sx, sy,
  1101 			DrawHedgehog(sx, sy,
  1102 				hwSign(Gear^.dX),
  1102 				hwSign(Gear^.dX),
  1103 				0,
  1103 				0,
  1104 				4,
  1104 				4,
  1105 				0);
  1105 				0);
  1106 			
  1106 
  1107 			HatVisible:= true;
  1107 			HatVisible:= true;
  1108 			with PHedgehog(Gear^.Hedgehog)^ do
  1108 			with PHedgehog(Gear^.Hedgehog)^ do
  1109 				if (HatTex <> nil)
  1109 				if (HatTex <> nil)
  1110 				and (HatVisibility > 0) then
  1110 				and (HatVisibility > 0) then
  1111 					DrawTextureF(HatTex,
  1111 					DrawTextureF(HatTex,
  1168 			HatVisibility:= HatVisibility + 0.2
  1168 			HatVisibility:= HatVisibility + 0.2
  1169 		else
  1169 		else
  1170 	else
  1170 	else
  1171 		if HatVisibility > 0.0 then
  1171 		if HatVisibility > 0.0 then
  1172 			HatVisibility:= HatVisibility - 0.2;
  1172 			HatVisibility:= HatVisibility - 0.2;
  1173 	
  1173 
  1174 	if (HatTex <> nil)
  1174 	if (HatTex <> nil)
  1175 	and (HatVisibility > 0) then
  1175 	and (HatVisibility > 0) then
  1176 		if DefaultPos then
  1176 		if DefaultPos then
  1177 			DrawTextureF(HatTex,
  1177 			DrawTextureF(HatTex,
  1178 				HatVisibility,
  1178 				HatVisibility,
  1250 if Gear^.Invulnerable then
  1250 if Gear^.Invulnerable then
  1251     begin
  1251     begin
  1252     DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0);
  1252     DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0);
  1253     end;
  1253     end;
  1254 if cVampiric and
  1254 if cVampiric and
  1255    (CurrentHedgehog^.Gear <> nil) and 
  1255    (CurrentHedgehog^.Gear <> nil) and
  1256    (CurrentHedgehog^.Gear = Gear) then
  1256    (CurrentHedgehog^.Gear = Gear) then
  1257     begin
  1257     begin
  1258     DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
  1258     DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
  1259     end;
  1259     end;
  1260 end;
  1260 end;
  1275 	//glEnable(GL_LINE_SMOOTH);
  1275 	//glEnable(GL_LINE_SMOOTH);
  1276 
  1276 
  1277 	glPushMatrix;
  1277 	glPushMatrix;
  1278 
  1278 
  1279 	glTranslatef(WorldDx, WorldDy, 0);
  1279 	glTranslatef(WorldDx, WorldDy, 0);
  1280 	
  1280 
  1281 	glLineWidth(4.0);
  1281 	glLineWidth(4.0);
  1282 
  1282 
  1283 	glColor3ub($B0, $B0, $B0);
  1283 	glColor3ub($B0, $B0, $B0);
  1284 
  1284 
  1285 	glEnableClientState(GL_VERTEX_ARRAY);
  1285 	glEnableClientState(GL_VERTEX_ARRAY);
  1286 	glVertexPointer(2, GL_INT, 0, @RopePoints.rounded[0]);
  1286 	glVertexPointer(2, GL_INT, 0, @RopePoints.rounded[0]);
  1287 	glDrawArrays(GL_LINE_STRIP, 0, RopePoints.Count + 2);
  1287 	glDrawArrays(GL_LINE_STRIP, 0, RopePoints.Count + 2);
  1288 	glColor4f(1, 1, 1, 1);
  1288 	glColor4f(1, 1, 1, 1);
  1289 
  1289 
  1290 	glPopMatrix;
  1290 	glPopMatrix;
  1291 	
  1291 
  1292 	glEnable(GL_TEXTURE_2D);
  1292 	glEnable(GL_TEXTURE_2D);
  1293 	//glDisable(GL_LINE_SMOOTH)
  1293 	//glDisable(GL_LINE_SMOOTH)
  1294 	end
  1294 	end
  1295 end;
  1295 end;
  1296 
  1296 
  1404 
  1404 
  1405        gtRCPlane: if (Gear^.Tag = -1) then
  1405        gtRCPlane: if (Gear^.Tag = -1) then
  1406                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, -1,  DxDy2Angle(Gear^.dX, Gear^.dY) + 90)
  1406                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, -1,  DxDy2Angle(Gear^.dX, Gear^.dY) + 90)
  1407                   else
  1407                   else
  1408                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,0,DxDy2Angle(Gear^.dY, Gear^.dX));
  1408                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,0,DxDy2Angle(Gear^.dY, Gear^.dX));
  1409        
  1409 
  1410        gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1410        gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1411        
  1411 
  1412        gtDrill: DrawRotated(sprDrill, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1412        gtDrill: DrawRotated(sprDrill, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1413         
  1413 
  1414         gtHedgehog: DrawHH(Gear);
  1414         gtHedgehog: DrawHH(Gear);
  1415     
  1415 
  1416     gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1416     gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1417        
  1417 
  1418        gtHealthTag: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
  1418        gtHealthTag: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
  1419 
  1419 
  1420            gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex);
  1420            gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex);
  1421              
  1421 
  1422              gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4);
  1422              gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4);
  1423       
  1423 
  1424       gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0);
  1424       gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0);
  1425             gtRope: DrawRope(Gear);
  1425             gtRope: DrawRope(Gear);
  1426       gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
  1426       gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
  1427        gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State);
  1427        gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State);
  1428             gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)
  1428             gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)
  1666 						if not (TestCollisionXwithXYShift(t^.ar[i], _0, -2, hwSign(t^.ar[i]^.dX))
  1666 						if not (TestCollisionXwithXYShift(t^.ar[i], _0, -2, hwSign(t^.ar[i]^.dX))
  1667 							or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1;
  1667 							or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1;
  1668 						if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX))
  1668 						if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX))
  1669 							or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1;
  1669 							or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1;
  1670 						end;
  1670 						end;
  1671 					
  1671 
  1672 					FollowGear:= t^.ar[i]
  1672 					FollowGear:= t^.ar[i]
  1673 					end;
  1673 					end;
  1674 		end
  1674 		end
  1675 	end;
  1675 	end;
  1676 SetAllToActive
  1676 SetAllToActive
  1876      end;
  1876      end;
  1877 // handles case of no ammo or utility crates - considered also placing booleans in uAmmos and altering probabilities
  1877 // handles case of no ammo or utility crates - considered also placing booleans in uAmmos and altering probabilities
  1878 if (FollowGear <> nil) then
  1878 if (FollowGear <> nil) then
  1879 	begin
  1879 	begin
  1880 	FindPlace(FollowGear, true, 0, LAND_WIDTH);
  1880 	FindPlace(FollowGear, true, 0, LAND_WIDTH);
  1881 	
  1881 
  1882 	if (FollowGear <> nil) then
  1882 	if (FollowGear <> nil) then
  1883 		PlaySound(sndReinforce, false, CurrentTeam^.voicepack)
  1883 		PlaySound(sndReinforce, false, CurrentTeam^.voicepack)
  1884 	end
  1884 	end
  1885 end;
  1885 end;
  1886 
  1886 
  1911 	repeat
  1911 	repeat
  1912 		inc(x, Delta);
  1912 		inc(x, Delta);
  1913 		cnt:= 0;
  1913 		cnt:= 0;
  1914         if topY > 1024 then
  1914         if topY > 1024 then
  1915 		    y:= 1024-Gear^.Radius * 2
  1915 		    y:= 1024-Gear^.Radius * 2
  1916         else 
  1916         else
  1917 		    y:= topY-Gear^.Radius * 2;
  1917 		    y:= topY-Gear^.Radius * 2;
  1918 		while y < LAND_HEIGHT do
  1918 		while y < LAND_HEIGHT do
  1919 			begin
  1919 			begin
  1920 			repeat
  1920 			repeat
  1921 				inc(y, 2);
  1921 				inc(y, 2);
  1922 			until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0);
  1922 			until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0);
  1923 			
  1923 
  1924 			sy:= y;
  1924 			sy:= y;
  1925 
  1925 
  1926 			repeat
  1926 			repeat
  1927 				inc(y);
  1927 				inc(y);
  1928 			until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0);
  1928 			until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0);
  1929 			
  1929 
  1930 			if (y - sy > Gear^.Radius * 2)
  1930 			if (y - sy > Gear^.Radius * 2)
  1931 				and (y < LAND_HEIGHT)
  1931 				and (y < LAND_HEIGHT)
  1932 				and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then
  1932 				and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then
  1933 				begin
  1933 				begin
  1934 				ar[cnt].X:= x;
  1934 				ar[cnt].X:= x;
  1935 				if withFall then ar[cnt].Y:= sy + Gear^.Radius
  1935 				if withFall then ar[cnt].Y:= sy + Gear^.Radius
  1936 							else ar[cnt].Y:= y - Gear^.Radius;
  1936 							else ar[cnt].Y:= y - Gear^.Radius;
  1937 				inc(cnt)
  1937 				inc(cnt)
  1938 				end;
  1938 				end;
  1939 			
  1939 
  1940 			inc(y, 45)
  1940 			inc(y, 45)
  1941 			end;
  1941 			end;
  1942 		
  1942 
  1943 		if cnt > 0 then
  1943 		if cnt > 0 then
  1944 			with ar[GetRandom(cnt)] do
  1944 			with ar[GetRandom(cnt)] do
  1945 				begin
  1945 				begin
  1946 				ar2[cnt2].x:= x;
  1946 				ar2[cnt2].x:= x;
  1947 				ar2[cnt2].y:= y;
  1947 				ar2[cnt2].y:= y;
  1948 				inc(cnt2)
  1948 				inc(cnt2)
  1949 				end
  1949 				end
  1950 	until (x + Delta > Right);
  1950 	until (x + Delta > Right);
  1951 	
  1951 
  1952 	dec(Delta, 60)
  1952 	dec(Delta, 60)
  1953 until (cnt2 > 0) or (Delta < 70);
  1953 until (cnt2 > 0) or (Delta < 70);
  1954 
  1954 
  1955 if cnt2 > 0 then
  1955 if cnt2 > 0 then
  1956 	with ar2[GetRandom(cnt2)] do
  1956 	with ar2[GetRandom(cnt2)] do