hedgewars/GSHandlers.inc
changeset 2745 11fce231f24a
parent 2736 cc04e98dd535
child 2746 55593f8a490b
equal deleted inserted replaced
2744:803d0142594e 2745:11fce231f24a
    25 		begin
    25 		begin
    26 		d:= r - hwRound(Distance(gi^.X - x, gi^.Y - y));
    26 		d:= r - hwRound(Distance(gi^.X - x, gi^.Y - y));
    27 		if (d > 1) and (gi^.Kind = gtHedgehog) and not gi^.Invulnerable and (GetRandom(2) = 0) then
    27 		if (d > 1) and (gi^.Kind = gtHedgehog) and not gi^.Invulnerable and (GetRandom(2) = 0) then
    28 			begin
    28 			begin
    29 			if (CurrentHedgehog^.Gear = gi) then
    29 			if (CurrentHedgehog^.Gear = gi) then
    30 				PlaySound(sndOops, false, PHedgehog(gi^.Hedgehog)^.Team^.voicepack)
    30 				PlaySound(sndOops, PHedgehog(gi^.Hedgehog)^.Team^.voicepack)
    31 			else
    31 			else
    32 				begin
    32 				begin
    33 				if (gi^.State and gstMoving) = 0 then
    33 				if (gi^.State and gstMoving) = 0 then
    34 					gi^.State:= gi^.State or gstLoser;
    34 					gi^.State:= gi^.State or gstLoser;
    35 				if d > r div 2 then
    35 				if d > r div 2 then
    36 					PlaySound(sndNooo, false, PHedgehog(gi^.Hedgehog)^.Team^.voicepack)
    36 					PlaySound(sndNooo, PHedgehog(gi^.Hedgehog)^.Team^.voicepack)
    37 				else
    37 				else
    38 					PlaySound(sndUhOh, false, PHedgehog(gi^.Hedgehog)^.Team^.voicepack);
    38 					PlaySound(sndUhOh, PHedgehog(gi^.Hedgehog)^.Team^.voicepack);
    39 				end;
    39 				end;
    40 			end;
    40 			end;
    41 		gi:= gi^.NextGear
    41 		gi:= gi^.NextGear
    42 		end;
    42 		end;
    43 end;
    43 end;
    72 			begin
    72 			begin
    73 			Gear^.State:= Gear^.State and (not gstHHDriven);
    73 			Gear^.State:= Gear^.State and (not gstHHDriven);
    74 			AddCaption(Format(GetEventString(eidDrowned), PHedgehog(Gear^.Hedgehog)^.Name), cWhiteColor, capgrpMessage);
    74 			AddCaption(Format(GetEventString(eidDrowned), PHedgehog(Gear^.Hedgehog)^.Name), cWhiteColor, capgrpMessage);
    75 			end
    75 			end
    76         end;
    76         end;
    77     PlaySound(sndSplash, false, nil)
    77     PlaySound(sndSplash)
    78     end
    78     end
    79     else
    79     else
    80 	CheckGearDrowning:= false
    80 	CheckGearDrowning:= false
    81 end;
    81 end;
    82 
    82 
    95 	begin
    95 	begin
    96 	dmg:= ModifyDamage(1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70), Gear);
    96 	dmg:= ModifyDamage(1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70), Gear);
    97     if dmg < 1 then exit;
    97     if dmg < 1 then exit;
    98 
    98 
    99 	if _0_6 < Gear^.dY then
    99 	if _0_6 < Gear^.dY then
   100 		PlaySound(sndOw4, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack)
   100 		PlaySound(sndOw4, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack)
   101 	else
   101 	else
   102 		PlaySound(sndOw1, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   102 		PlaySound(sndOw1, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   103 
   103 
   104     ApplyDamage(Gear, dmg);
   104     ApplyDamage(Gear, dmg);
   105 	end
   105 	end
   106 end;
   106 end;
   107 
   107 
   238 
   238 
   239 CalcRotationDirAngle(Gear);
   239 CalcRotationDirAngle(Gear);
   240 
   240 
   241 if Gear^.Kind = gtHellishBomb then
   241 if Gear^.Kind = gtHellishBomb then
   242 	begin
   242 	begin
   243 	if Gear^.Timer = 3000 then PlaySound(sndHellish, false, nil);
   243 	if Gear^.Timer = 3000 then PlaySound(sndHellish);
   244 
   244 
   245 	if (GameTicks and $3F) = 0 then
   245 	if (GameTicks and $3F) = 0 then
   246 		if (Gear^.State and gstCollision) = 0 then
   246 		if (Gear^.State and gstCollision) = 0 then
   247 			AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0);
   247 			AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0);
   248 	end;
   248 	end;
   249 
   249 
   250 if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then
   250 if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then
   251 	if (hwAbs(Gear^.dX) > _0_1) or
   251 	if (hwAbs(Gear^.dX) > _0_1) or
   252 	   (hwAbs(Gear^.dY) > _0_1) then
   252 	   (hwAbs(Gear^.dY) > _0_1) then
   253 		PlaySound(sndGrenadeImpact, false, nil)
   253 		PlaySound(sndGrenadeImpact)
   254 end;
   254 end;
   255 ////////////////////////////////////////////////////////////////////////////////
   255 ////////////////////////////////////////////////////////////////////////////////
   256 procedure doStepMolotov(Gear: PGear);
   256 procedure doStepMolotov(Gear: PGear);
   257 var i: LongInt;
   257 var i: LongInt;
   258     dX, dY: hwFloat;
   258     dX, dY: hwFloat;
   262 	
   262 	
   263 	doStepFallingGear(Gear);
   263 	doStepFallingGear(Gear);
   264 	CalcRotationDirAngle(Gear);
   264 	CalcRotationDirAngle(Gear);
   265 
   265 
   266 	if (Gear^.State and gstCollision) <> 0 then begin
   266 	if (Gear^.State and gstCollision) <> 0 then begin
   267 		PlaySound(sndMolotov, false, nil);
   267 		PlaySound(sndMolotov);
   268 		//doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 5, EXPLAutoSound);
   268 		//doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 5, EXPLAutoSound);
   269 		for i:= 0 to 20 do begin
   269 		for i:= 0 to 20 do begin
   270 				dX:= AngleCos(i * 2) * ((_0_1*(i div 5))) * (GetRandom + _1);
   270 				dX:= AngleCos(i * 2) * ((_0_1*(i div 5))) * (GetRandom + _1);
   271 				dY:= AngleSin(i * 8) * _0_5 * (GetRandom + _1);
   271 				dY:= AngleSin(i * 8) * _0_5 * (GetRandom + _1);
   272 				Fire:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0);
   272 				Fire:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0);
   380       Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
   380       Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
   381       if Gear^.dY > - _1div1024 then
   381       if Gear^.dY > - _1div1024 then
   382          begin
   382          begin
   383          Gear^.Active:= false;
   383          Gear^.Active:= false;
   384          exit
   384          exit
   385          end else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false, nil)
   385          end else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact)
   386       end;
   386       end;
   387 
   387 
   388 Gear^.Y:= Gear^.Y + Gear^.dY;
   388 Gear^.Y:= Gear^.Y + Gear^.dY;
   389 CheckGearDrowning(Gear);
   389 CheckGearDrowning(Gear);
   390 Gear^.dY:= Gear^.dY + cGravity
   390 Gear^.dY:= Gear^.dY + cGravity
   414 
   414 
   415 CheckCollision(Gear);
   415 CheckCollision(Gear);
   416 dec(Gear^.Timer);
   416 dec(Gear^.Timer);
   417 if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then
   417 if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then
   418    begin
   418    begin
   419    StopSound(sndUFO);
   419    StopSound(Gear^.SoundChannel);
   420    doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
   420    doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
   421    DeleteGear(Gear);
   421    DeleteGear(Gear);
   422    end;
   422    end;
   423 end;
   423 end;
   424 
   424 
   436    exit
   436    exit
   437    end;
   437    end;
   438 dec(Gear^.Timer);
   438 dec(Gear^.Timer);
   439 if Gear^.Timer = 0 then
   439 if Gear^.Timer = 0 then
   440    begin
   440    begin
   441    PlaySound(sndUFO, true, nil);
   441    Gear^.SoundChannel:= LoopSound(sndUFO);
   442    Gear^.Timer:= 5000;
   442    Gear^.Timer:= 5000;
   443    Gear^.doStep:= @doStepUFOWork
   443    Gear^.doStep:= @doStepUFOWork
   444    end;
   444    end;
   445 end;
   445 end;
   446 
   446 
   464 if ((Gear^.State and gstAnimation) = 0) then
   464 if ((Gear^.State and gstAnimation) = 0) then
   465 	begin
   465 	begin
   466 	dec(Gear^.Timer);
   466 	dec(Gear^.Timer);
   467 	if Gear^.Timer = 0 then
   467 	if Gear^.Timer = 0 then
   468 		begin
   468 		begin
   469 		PlaySound(sndShotgunFire, false, nil);
   469 		PlaySound(sndShotgunFire);
   470 		Gear^.State:= Gear^.State or gstAnimation
   470 		Gear^.State:= Gear^.State or gstAnimation
   471 		end;
   471 		end;
   472 	exit
   472 	exit
   473 	end
   473 	end
   474 	else inc(Gear^.Timer);
   474 	else inc(Gear^.Timer);
   534     end;
   534     end;
   535 end;
   535 end;
   536 
   536 
   537 procedure doStepDEagleShot(Gear: PGear);
   537 procedure doStepDEagleShot(Gear: PGear);
   538 begin
   538 begin
   539 PlaySound(sndGun, false, nil);
   539 PlaySound(sndGun);
   540 Gear^.doStep:= @doStepBulletWork
   540 Gear^.doStep:= @doStepBulletWork
   541 end;
   541 end;
   542 
   542 
   543 procedure doStepSniperRifleShot(Gear: PGear);
   543 procedure doStepSniperRifleShot(Gear: PGear);
   544 var HHGear: PGear;
   544 var HHGear: PGear;
   557 if (HHGear^.Message and gm_Attack) <> 0 then
   557 if (HHGear^.Message and gm_Attack) <> 0 then
   558     begin
   558     begin
   559 	Gear^.State:= Gear^.State or gstAnimation;
   559 	Gear^.State:= Gear^.State or gstAnimation;
   560     Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _0_5;
   560     Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _0_5;
   561     Gear^.dY:= -AngleCos(HHGear^.Angle) * _0_5;
   561     Gear^.dY:= -AngleCos(HHGear^.Angle) * _0_5;
   562     PlaySound(sndGun, false, nil);
   562     PlaySound(sndGun);
   563     Gear^.doStep:= @doStepBulletWork;
   563     Gear^.doStep:= @doStepBulletWork;
   564     end
   564     end
   565 else
   565 else
   566     if (GameTicks mod 32) = 0 then
   566     if (GameTicks mod 32) = 0 then
   567         if (GameTicks mod 4096) < 2048 then
   567         if (GameTicks mod 4096) < 2048 then
   619 AllInactive:= false;
   619 AllInactive:= false;
   620 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
   620 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
   621 dec(Gear^.Timer);
   621 dec(Gear^.Timer);
   622 if (Gear^.Timer = 0)or((Gear^.Message and gm_Destroy) <> 0)or((HHGear^.State and gstHHDriven) = 0) then
   622 if (Gear^.Timer = 0)or((Gear^.Message and gm_Destroy) <> 0)or((HHGear^.State and gstHHDriven) = 0) then
   623 	begin
   623 	begin
   624 	StopSound(sndPickhammer);
   624 	StopSound(Gear^.SoundChannel);
   625 	DeleteGear(Gear);
   625 	DeleteGear(Gear);
   626 	AfterAttack;
   626 	AfterAttack;
   627 	exit
   627 	exit
   628 	end;
   628 	end;
   629 
   629 
   694 
   694 
   695 DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius * 2, 2, Pred(i));
   695 DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius * 2, 2, Pred(i));
   696 Gear^.dY:= HHGear^.dY;
   696 Gear^.dY:= HHGear^.dY;
   697 DeleteCI(HHGear);
   697 DeleteCI(HHGear);
   698 
   698 
   699 PlaySound(sndPickhammer, true, nil);
   699 Gear^.SoundChannel:= LoopSound(sndPickhammer);
   700 doStepPickHammerWork(Gear);
   700 doStepPickHammerWork(Gear);
   701 Gear^.doStep:= @doStepPickHammerWork
   701 Gear^.doStep:= @doStepPickHammerWork
   702 end;
   702 end;
   703 
   703 
   704 ////////////////////////////////////////////////////////////////////////////////
   704 ////////////////////////////////////////////////////////////////////////////////
  1171 		if ((GameTicks and $1F) = 0) then
  1171 		if ((GameTicks and $1F) = 0) then
  1172 			if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking
  1172 			if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking
  1173 		end else // gstAttacking <> 0
  1173 		end else // gstAttacking <> 0
  1174 		begin
  1174 		begin
  1175 		AllInactive:= false;
  1175 		AllInactive:= false;
  1176 		if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false, nil);
  1176 		if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick);
  1177 		if Gear^.Timer = 0 then
  1177 		if Gear^.Timer = 0 then
  1178 			begin
  1178 			begin
  1179 			doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
  1179 			doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
  1180 			DeleteGear(Gear);
  1180 			DeleteGear(Gear);
  1181 			exit
  1181 			exit
  1241 	if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else
  1241 	if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else
  1242 	if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then
  1242 	if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then
  1243 		begin
  1243 		begin
  1244 		Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
  1244 		Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
  1245 		if Gear^.dY > - _0_001 then Gear^.dY:= _0
  1245 		if Gear^.dY > - _0_001 then Gear^.dY:= _0
  1246 			else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false, nil);
  1246 			else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact);
  1247 		end;
  1247 		end;
  1248 	CheckGearDrowning(Gear);
  1248 	CheckGearDrowning(Gear);
  1249 	end;
  1249 	end;
  1250 
  1250 
  1251 if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear)
  1251 if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear)
  1255 ////////////////////////////////////////////////////////////////////////////////
  1255 ////////////////////////////////////////////////////////////////////////////////
  1256 
  1256 
  1257 procedure doStepTarget(Gear: PGear);
  1257 procedure doStepTarget(Gear: PGear);
  1258 begin
  1258 begin
  1259 if (Gear^.Timer = 0) and (Gear^.Tag = 0) then
  1259 if (Gear^.Timer = 0) and (Gear^.Tag = 0) then
  1260 	PlaySound(sndWarp, false, nil);
  1260 	PlaySound(sndWarp);
  1261 
  1261 
  1262 if (Gear^.Tag = 0) and (Gear^.Timer < 1000) then
  1262 if (Gear^.Tag = 0) and (Gear^.Timer < 1000) then
  1263 	inc(Gear^.Timer)
  1263 	inc(Gear^.Timer)
  1264 else if Gear^.Tag = 1 then
  1264 else if Gear^.Tag = 1 then
  1265 	begin
  1265 	begin
  1358 
  1358 
  1359 	if (hwRound(Gear^.Y) > cWaterLine) then
  1359 	if (hwRound(Gear^.Y) > cWaterLine) then
  1360 		begin
  1360 		begin
  1361 		for i:= 0 to 3 do
  1361 		for i:= 0 to 3 do
  1362 			AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 16 + Random(16), vgtSteam);
  1362 			AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 16 + Random(16), vgtSteam);
  1363 		PlaySound(sndVaporize, false, nil);
  1363 		PlaySound(sndVaporize);
  1364 		DeleteGear(Gear);
  1364 		DeleteGear(Gear);
  1365 		exit
  1365 		exit
  1366 		end
  1366 		end
  1367     end else begin
  1367     end else begin
  1368         if (Gear^.State and gsttmpFlag) <> 0 then 
  1368         if (Gear^.State and gsttmpFlag) <> 0 then 
  1472 Gear^.dX:= SignAs(_0_45, Gear^.dX);
  1472 Gear^.dX:= SignAs(_0_45, Gear^.dX);
  1473 Gear^.dY:= - _0_9;
  1473 Gear^.dY:= - _0_9;
  1474 Gear^.doStep:= @doStepFirePunchWork;
  1474 Gear^.doStep:= @doStepFirePunchWork;
  1475 DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5);
  1475 DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5);
  1476 
  1476 
  1477 PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false, PHedgehog(HHGear^.Hedgehog)^.Team^.voicepack)
  1477 PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), PHedgehog(HHGear^.Hedgehog)^.Team^.voicepack)
  1478 end;
  1478 end;
  1479 
  1479 
  1480 ////////////////////////////////////////////////////////////////////////////////
  1480 ////////////////////////////////////////////////////////////////////////////////
  1481 
  1481 
  1482 procedure doStepParachuteWork(Gear: PGear);
  1482 procedure doStepParachuteWork(Gear: PGear);
  1622 if (Distance(tx - x, ty - y) > _256) or
  1622 if (Distance(tx - x, ty - y) > _256) or
  1623    not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2,
  1623    not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2,
  1624                       TargetPoint.Y - SpritesData[sprAmGirder].Height div 2,
  1624                       TargetPoint.Y - SpritesData[sprAmGirder].Height div 2,
  1625                       sprAmGirder, Gear^.State, true) then
  1625                       sprAmGirder, Gear^.State, true) then
  1626 	begin
  1626 	begin
  1627     PlaySound(sndDenied, false, nil);
  1627     PlaySound(sndDenied);
  1628 	HHGear^.Message:= HHGear^.Message and not gm_Attack;
  1628 	HHGear^.Message:= HHGear^.Message and not gm_Attack;
  1629 	HHGear^.State:= HHGear^.State and not gstAttacking;
  1629 	HHGear^.State:= HHGear^.State and not gstAttacking;
  1630 	HHGear^.State:= HHGear^.State or gstHHChooseTarget;
  1630 	HHGear^.State:= HHGear^.State or gstHHChooseTarget;
  1631 	isCursorVisible:= true;
  1631 	isCursorVisible:= true;
  1632 	DeleteGear(Gear)
  1632 	DeleteGear(Gear)
  1633 	end
  1633 	end
  1634 else begin
  1634 else begin
  1635     PlaySound(sndPlaced, false, nil);
  1635     PlaySound(sndPlaced);
  1636 	DeleteGear(Gear);
  1636 	DeleteGear(Gear);
  1637     OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^);
  1637     OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^);
  1638     ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^)
  1638     ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^)
  1639 	end;
  1639 	end;
  1640 
  1640 
  1683 		HHGear^.Message:= HHGear^.Message and not gm_Attack;
  1683 		HHGear^.Message:= HHGear^.Message and not gm_Attack;
  1684 		HHGear^.State:= HHGear^.State and not gstAttacking;
  1684 		HHGear^.State:= HHGear^.State and not gstAttacking;
  1685 		HHGear^.State:= HHGear^.State or gstHHChooseTarget;
  1685 		HHGear^.State:= HHGear^.State or gstHHChooseTarget;
  1686 		DeleteGear(Gear);
  1686 		DeleteGear(Gear);
  1687 		isCursorVisible:= true;
  1687 		isCursorVisible:= true;
  1688 		PlaySound(sndDenied, false, nil);
  1688 		PlaySound(sndDenied)
  1689 		end
  1689 		end
  1690 	else begin
  1690 	else begin
  1691 		DeleteCI(HHGear);
  1691 		DeleteCI(HHGear);
  1692 		SetAllHHToActive;
  1692 		SetAllHHToActive;
  1693 		Gear^.doStep:= @doStepTeleportAnim;
  1693 		Gear^.doStep:= @doStepTeleportAnim;
  1694 		Gear^.X:= HHGear^.X;
  1694 		Gear^.X:= HHGear^.X;
  1695 		Gear^.Y:= HHGear^.Y;
  1695 		Gear^.Y:= HHGear^.Y;
  1696 		HHGear^.X:= int2hwFloat(TargetPoint.X);
  1696 		HHGear^.X:= int2hwFloat(TargetPoint.X);
  1697 		HHGear^.Y:= int2hwFloat(TargetPoint.Y);
  1697 		HHGear^.Y:= int2hwFloat(TargetPoint.Y);
  1698 		HHGear^.State:= HHGear^.State or gstMoving;
  1698 		HHGear^.State:= HHGear^.State or gstMoving;
  1699 		playSound(sndWarp, false, nil);
  1699 		playSound(sndWarp)
  1700 		end;
  1700 		end;
  1701 TargetPoint.X:= NoPointX;
  1701 TargetPoint.X:= NoPointX;
  1702 
  1702 
  1703 end;
  1703 end;
  1704 
  1704 
  1733 	HHGear^.Active:= false;
  1733 	HHGear^.Active:= false;
  1734 	HHGear^.Z:= cHHZ;
  1734 	HHGear^.Z:= cHHZ;
  1735 	RemoveGearFromList(HHGear);
  1735 	RemoveGearFromList(HHGear);
  1736 	InsertGearToList(HHGear);
  1736 	InsertGearToList(HHGear);
  1737 
  1737 
  1738 	PlaySound(sndSwitchHog, false, nil);
  1738 	PlaySound(sndSwitchHog);
  1739 	
  1739 	
  1740 	repeat
  1740 	repeat
  1741 		CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber);
  1741 		CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber);
  1742 	until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil);
  1742 	until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil);
  1743 
  1743 
  1862 AllInactive:= false;
  1862 AllInactive:= false;
  1863 dec(Gear^.Timer);
  1863 dec(Gear^.Timer);
  1864 if Gear^.Timer = 0 then
  1864 if Gear^.Timer = 0 then
  1865 	begin
  1865 	begin
  1866 	Gear^.Pos:= 1;
  1866 	Gear^.Pos:= 1;
  1867 	PlaySound(sndKamikaze, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
  1867 	PlaySound(sndKamikaze, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
  1868 	Gear^.doStep:= @doStepKamikazeWork
  1868 	Gear^.doStep:= @doStepKamikazeWork
  1869 	end
  1869 	end
  1870 end;
  1870 end;
  1871 
  1871 
  1872 procedure doStepKamikaze(Gear: PGear);
  1872 procedure doStepKamikaze(Gear: PGear);
  1927             else
  1927             else
  1928 			    gi^.State:= gi^.State or gstWinner;
  1928 			    gi^.State:= gi^.State or gstWinner;
  1929 		gi:= gi^.NextGear
  1929 		gi:= gi^.NextGear
  1930 		end;
  1930 		end;
  1931 	Gear^.doStep:= @doStepCakeExpl;
  1931 	Gear^.doStep:= @doStepCakeExpl;
  1932 	PlaySound(sndCake, false, nil)
  1932 	PlaySound(sndCake)
  1933 	end else dec(Gear^.Pos)
  1933 	end else dec(Gear^.Pos)
  1934 end;
  1934 end;
  1935 
  1935 
  1936 
  1936 
  1937 procedure doStepCakeWork(Gear: PGear);
  1937 procedure doStepCakeWork(Gear: PGear);
  2094 if Gear^.Timer > 250 then
  2094 if Gear^.Timer > 250 then
  2095 	begin
  2095 	begin
  2096 	Gear^.Timer:= 0;
  2096 	Gear^.Timer:= 0;
  2097 	inc(Gear^.Pos);
  2097 	inc(Gear^.Pos);
  2098 	if Gear^.Pos = 5 then
  2098 	if Gear^.Pos = 5 then
  2099 		PlaySound(sndYoohoo, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack)
  2099 		PlaySound(sndYoohoo, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack)
  2100 	end;
  2100 	end;
  2101 
  2101 
  2102 if Gear^.Pos = 14 then
  2102 if Gear^.Pos = 14 then
  2103 	Gear^.doStep:= @doStepSeductionWork
  2103 	Gear^.doStep:= @doStepSeductionWork
  2104 end;
  2104 end;
  2149 	Gear^.X:= Gear^.X + Gear^.dX;
  2149 	Gear^.X:= Gear^.X + Gear^.dX;
  2150 	Gear^.Y:= Gear^.Y + Gear^.dY;
  2150 	Gear^.Y:= Gear^.Y + Gear^.dY;
  2151 	DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6);
  2151 	DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6);
  2152     if(CheckGearDrowning(Gear)) then
  2152     if(CheckGearDrowning(Gear)) then
  2153         begin
  2153         begin
  2154         StopSound(sndPickhammer);
  2154         StopSound(Gear^.SoundChannel);
  2155 	    exit
  2155 	    exit
  2156         end
  2156         end
  2157 	end;
  2157 	end;
  2158 
  2158 
  2159 t:= CheckGearsCollision(Gear); //fixes drill not exploding when touching HH bug
  2159 t:= CheckGearsCollision(Gear); //fixes drill not exploding when touching HH bug
  2161 or (t^.Count <> 0)
  2161 or (t^.Count <> 0)
  2162 or (not TestCollisionYWithGear(Gear, hwSign(Gear^.dY))
  2162 or (not TestCollisionYWithGear(Gear, hwSign(Gear^.dY))
  2163 and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX)))
  2163 and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX)))
  2164 or (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] = COLOR_INDESTRUCTIBLE) then
  2164 or (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] = COLOR_INDESTRUCTIBLE) then
  2165 	begin //out of time or exited ground
  2165 	begin //out of time or exited ground
  2166     StopSound(sndPickhammer);
  2166     StopSound(Gear^.SoundChannel);
  2167 	doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
  2167 	doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
  2168 	DeleteGear(Gear);
  2168 	DeleteGear(Gear);
  2169 	exit
  2169 	exit
  2170 	end;
  2170 	end;
  2171 
  2171 
  2201 		doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
  2201 		doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
  2202 		DeleteGear(Gear);
  2202 		DeleteGear(Gear);
  2203 		exit;
  2203 		exit;
  2204 		end;
  2204 		end;
  2205 
  2205 
  2206     PlaySound(sndPickhammer, true, nil);
  2206     Gear^.SoundChannel:= LoopSound(sndPickhammer);
  2207 	Gear^.doStep:= @doStepDrillDrilling;
  2207 	Gear^.doStep:= @doStepDrillDrilling;
  2208 	dec(Gear^.Timer)
  2208 	dec(Gear^.Timer)
  2209 	end
  2209 	end
  2210 end;
  2210 end;
  2211 
  2211 
  2226 		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0,
  2226 		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0,
  2227 				SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx,
  2227 				SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx,
  2228 				AngleCos(HHGear^.Angle) * ( - _0_8) + ry,
  2228 				AngleCos(HHGear^.Angle) * ( - _0_8) + ry,
  2229 				0);
  2229 				0);
  2230 
  2230 
  2231 		PlaySound(sndGun, false, nil);
  2231 		PlaySound(sndGun);
  2232 		end;
  2232 		end;
  2233 
  2233 
  2234 	if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then
  2234 	if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then
  2235 		begin
  2235 		begin
  2236 		DeleteGear(Gear);
  2236 		DeleteGear(Gear);
  2321 	if ((HHGear^.Message and gm_LJump) <> 0)
  2321 	if ((HHGear^.Message and gm_LJump) <> 0)
  2322 		and ((Gear^.State and gsttmpFlag) = 0) then
  2322 		and ((Gear^.State and gsttmpFlag) = 0) then
  2323 		begin
  2323 		begin
  2324 		Gear^.State:= Gear^.State or gsttmpFlag;
  2324 		Gear^.State:= Gear^.State or gsttmpFlag;
  2325 		PauseMusic;
  2325 		PauseMusic;
  2326 		playSound(sndRideOfTheValkyries, false, nil);
  2326 		playSound(sndRideOfTheValkyries);
  2327 		end;
  2327 		end;
  2328 
  2328 
  2329 	// pickup bonuses
  2329 	// pickup bonuses
  2330 	t:= CheckGearNear(Gear, gtCase, 36, 36);
  2330 	t:= CheckGearNear(Gear, gtCase, 36, 36);
  2331 	if t <> nil then
  2331 	if t <> nil then
  2340 	t:= CheckGearNear(Gear, gtTarget, 36, 36);
  2340 	t:= CheckGearNear(Gear, gtTarget, 36, 36);
  2341 	if t <> nil then
  2341 	if t <> nil then
  2342 		begin
  2342 		begin
  2343 		if t^.Tag <> 0 then // collect it only once
  2343 		if t^.Tag <> 0 then // collect it only once
  2344 			exit;
  2344 			exit;
  2345 		PlaySound(sndShotgunReload, false, nil);
  2345 		PlaySound(sndShotgunReload);
  2346 		t^.Tag:= 1;
  2346 		t^.Tag:= 1;
  2347 		TrainingTargetGear:= nil; // remove target cursor
  2347 		TrainingTargetGear:= nil; // remove target cursor
  2348 		exit;
  2348 		exit;
  2349 		end;
  2349 		end;
  2350 
  2350 
  2356 
  2356 
  2357 if ((Gear^.State and gstCollision) <> 0) or (((TrainingFlags and tfRCPlane) <> 0) and (TurnTimeLeft = 0))
  2357 if ((Gear^.State and gstCollision) <> 0) or (((TrainingFlags and tfRCPlane) <> 0) and (TurnTimeLeft = 0))
  2358 	or CheckGearDrowning(Gear) then
  2358 	or CheckGearDrowning(Gear) then
  2359 	begin
  2359 	begin
  2360 	if ((TrainingFlags and tfRCPlane) <> 0) and ((TrainingFlags and tfTimeTrial) <> 0 ) and (TimeTrialStopTime = 0) then TimeTrialStopTime:= RealTicks;
  2360 	if ((TrainingFlags and tfRCPlane) <> 0) and ((TrainingFlags and tfTimeTrial) <> 0 ) and (TimeTrialStopTime = 0) then TimeTrialStopTime:= RealTicks;
  2361 	StopSound(sndRCPlane);
  2361 	StopSound(Gear^.SoundChannel);
  2362 	StopSound(sndRideOfTheValkyries);
  2362 	StopSound(sndRideOfTheValkyries);
  2363 	ResumeMusic;
  2363 	ResumeMusic;
  2364 
  2364 
  2365 	if ((Gear^.State and gstCollision) <> 0) or (((TrainingFlags and tfRCPlane) <> 0) and (TurnTimeLeft = 0)) then
  2365 	if ((Gear^.State and gstCollision) <> 0) or (((TrainingFlags and tfRCPlane) <> 0) and (TurnTimeLeft = 0)) then
  2366 		begin
  2366 		begin