hedgewars/GSHandlers.inc
changeset 1669 b709e061577e
parent 1652 2f15a299ffc6
child 1689 3d0eee01f734
equal deleted inserted replaced
1668:ceee3f20c784 1669:b709e061577e
    23 if cWaterLine < hwRound(Gear^.Y) + Gear^.Radius then
    23 if cWaterLine < hwRound(Gear^.Y) + Gear^.Radius then
    24 	begin
    24 	begin
    25 	CheckGearDrowning:= true;
    25 	CheckGearDrowning:= true;
    26 	Gear^.State:= gstDrowning;
    26 	Gear^.State:= gstDrowning;
    27 	Gear^.doStep:= @doStepDrowningGear;
    27 	Gear^.doStep:= @doStepDrowningGear;
    28 	PlaySound(sndSplash, false)
    28 	PlaySound(sndSplash, false, nil)
    29 	end else
    29 	end else
    30 	CheckGearDrowning:= false
    30 	CheckGearDrowning:= false
    31 end;
    31 end;
    32 
    32 
    33 procedure CheckCollision(Gear: PGear);
    33 procedure CheckCollision(Gear: PGear);
    41 var dmg: Longword;
    41 var dmg: Longword;
    42 begin
    42 begin
    43 if _0_4 < Gear^.dY then
    43 if _0_4 < Gear^.dY then
    44 	begin
    44 	begin
    45 	if _0_6 < Gear^.dY then
    45 	if _0_6 < Gear^.dY then
    46 		PlaySound(sndOw4, false)
    46 		PlaySound(sndOw4, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack)
    47 	else
    47 	else
    48 		PlaySound(sndOw1, false);
    48 		PlaySound(sndOw1, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
    49 
    49 
    50 	dmg:= 1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70);
    50 	dmg:= 1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70);
    51 	inc(Gear^.Damage, dmg);
    51 	inc(Gear^.Damage, dmg);
    52 	AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color);
    52 	AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color);
    53 	end
    53 	end
   169 
   169 
   170 CalcRotationDirAngle(Gear);
   170 CalcRotationDirAngle(Gear);
   171 
   171 
   172 if Gear^.Kind = gtHellishBomb then
   172 if Gear^.Kind = gtHellishBomb then
   173 	begin
   173 	begin
   174 	if Gear^.Timer = 3000 then PlaySound(sndHellish, false);
   174 	if Gear^.Timer = 3000 then PlaySound(sndHellish, false, nil);
   175 
   175 
   176 	if (GameTicks and $3F) = 0 then
   176 	if (GameTicks and $3F) = 0 then
   177 		if (Gear^.State and gstCollision) = 0 then
   177 		if (Gear^.State and gstCollision) = 0 then
   178 			AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0);
   178 			AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0);
   179 	end;
   179 	end;
   180 
   180 
   181 if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then
   181 if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then
   182 	if (hwAbs(Gear^.dX) > _0_1) or
   182 	if (hwAbs(Gear^.dX) > _0_1) or
   183 	   (hwAbs(Gear^.dY) > _0_1) then
   183 	   (hwAbs(Gear^.dY) > _0_1) then
   184 		PlaySound(sndGrenadeImpact, false)
   184 		PlaySound(sndGrenadeImpact, false, nil)
   185 end;
   185 end;
   186 
   186 
   187 procedure doStepWatermelon(Gear: PGear);
   187 procedure doStepWatermelon(Gear: PGear);
   188 begin
   188 begin
   189 AllInactive:= false;
   189 AllInactive:= false;
   190 PlaySound(sndMelon, false);
   190 PlaySound(sndMelon, false, nil);
   191 Gear^.doStep:= @doStepBomb
   191 Gear^.doStep:= @doStepBomb
   192 end;
   192 end;
   193 
   193 
   194 procedure doStepCluster(Gear: PGear);
   194 procedure doStepCluster(Gear: PGear);
   195 begin
   195 begin
   282       Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
   282       Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
   283       if Gear^.dY > - _1div1024 then
   283       if Gear^.dY > - _1div1024 then
   284          begin
   284          begin
   285          Gear^.Active:= false;
   285          Gear^.Active:= false;
   286          exit
   286          exit
   287          end else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false)
   287          end else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false, nil)
   288       end;
   288       end;
   289 
   289 
   290 Gear^.Y:= Gear^.Y + Gear^.dY;
   290 Gear^.Y:= Gear^.Y + Gear^.dY;
   291 CheckGearDrowning(Gear);
   291 CheckGearDrowning(Gear);
   292 Gear^.dY:= Gear^.dY + cGravity
   292 Gear^.dY:= Gear^.dY + cGravity
   338    exit
   338    exit
   339    end;
   339    end;
   340 dec(Gear^.Timer);
   340 dec(Gear^.Timer);
   341 if Gear^.Timer = 0 then
   341 if Gear^.Timer = 0 then
   342    begin
   342    begin
   343    PlaySound(sndUFO, true);
   343    PlaySound(sndUFO, true, nil);
   344    Gear^.Timer:= 5000;
   344    Gear^.Timer:= 5000;
   345    Gear^.doStep:= @doStepUFOWork
   345    Gear^.doStep:= @doStepUFOWork
   346    end;
   346    end;
   347 end;
   347 end;
   348 
   348 
   366 if ((Gear^.State and gstAnimation) = 0) then
   366 if ((Gear^.State and gstAnimation) = 0) then
   367 	begin
   367 	begin
   368 	dec(Gear^.Timer);
   368 	dec(Gear^.Timer);
   369 	if Gear^.Timer = 0 then
   369 	if Gear^.Timer = 0 then
   370 		begin
   370 		begin
   371 		PlaySound(sndShotgunFire, false);
   371 		PlaySound(sndShotgunFire, false, nil);
   372 		Gear^.State:= Gear^.State or gstAnimation
   372 		Gear^.State:= Gear^.State or gstAnimation
   373 		end;
   373 		end;
   374 	exit
   374 	exit
   375 	end
   375 	end
   376 	else inc(Gear^.Timer);
   376 	else inc(Gear^.Timer);
   424 	Gear^.doStep:= @doStepShotIdle
   424 	Gear^.doStep:= @doStepShotIdle
   425 end;
   425 end;
   426 
   426 
   427 procedure doStepDEagleShot(Gear: PGear);
   427 procedure doStepDEagleShot(Gear: PGear);
   428 begin
   428 begin
   429 PlaySound(sndGun, false);
   429 PlaySound(sndGun, false, nil);
   430 Gear^.doStep:= @doStepDEagleShotWork
   430 Gear^.doStep:= @doStepDEagleShotWork
   431 end;
   431 end;
   432 
   432 
   433 ////////////////////////////////////////////////////////////////////////////////
   433 ////////////////////////////////////////////////////////////////////////////////
   434 procedure doStepActionTimer(Gear: PGear);
   434 procedure doStepActionTimer(Gear: PGear);
   540 
   540 
   541 DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius * 2, 2, Pred(i));
   541 DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius * 2, 2, Pred(i));
   542 Gear^.dY:= HHGear^.dY;
   542 Gear^.dY:= HHGear^.dY;
   543 DeleteCI(HHGear);
   543 DeleteCI(HHGear);
   544 
   544 
   545 PlaySound(sndPickhammer, true);
   545 PlaySound(sndPickhammer, true, nil);
   546 doStepPickHammerWork(Gear);
   546 doStepPickHammerWork(Gear);
   547 Gear^.doStep:= @doStepPickHammerWork
   547 Gear^.doStep:= @doStepPickHammerWork
   548 end;
   548 end;
   549 
   549 
   550 ////////////////////////////////////////////////////////////////////////////////
   550 ////////////////////////////////////////////////////////////////////////////////
   635 
   635 
   636 ////////////////////////////////////////////////////////////////////////////////
   636 ////////////////////////////////////////////////////////////////////////////////
   637 
   637 
   638 procedure doStepRopeWork(Gear: PGear);
   638 procedure doStepRopeWork(Gear: PGear);
   639 var HHGear: PGear;
   639 var HHGear: PGear;
   640 	len, cs, cc, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY: hwFloat;
   640 	len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY: hwFloat;
   641 	lx, ly: LongInt;
   641 	lx, ly: LongInt;
   642 	haveCollision,
   642 	haveCollision,
   643 	haveDivided: boolean;
   643 	haveDivided: boolean;
   644 
   644 
   645 	procedure DeleteMe;
   645 	procedure DeleteMe;
   925 		if ((GameTicks and $1F) = 0) then
   925 		if ((GameTicks and $1F) = 0) then
   926 			if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking
   926 			if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking
   927 		end else // gstAttacking <> 0
   927 		end else // gstAttacking <> 0
   928 		begin
   928 		begin
   929 		AllInactive:= false;
   929 		AllInactive:= false;
   930 		if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false);
   930 		if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false, nil);
   931 		if Gear^.Timer = 0 then
   931 		if Gear^.Timer = 0 then
   932 			begin
   932 			begin
   933 			doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
   933 			doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
   934 			DeleteGear(Gear);
   934 			DeleteGear(Gear);
   935 			exit
   935 			exit
   993 	if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else
   993 	if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else
   994 	if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then
   994 	if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then
   995 		begin
   995 		begin
   996 		Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
   996 		Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
   997 		if Gear^.dY > - _0_001 then Gear^.dY:= _0
   997 		if Gear^.dY > - _0_001 then Gear^.dY:= _0
   998 			else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false);
   998 			else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false, nil);
   999 		end;
   999 		end;
  1000 	CheckGearDrowning(Gear);
  1000 	CheckGearDrowning(Gear);
  1001 	end;
  1001 	end;
  1002 
  1002 
  1003 if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear)
  1003 if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear)
  1216 Gear^.dX:= SignAs(_0_45, Gear^.dX);
  1216 Gear^.dX:= SignAs(_0_45, Gear^.dX);
  1217 Gear^.dY:= - _0_9;
  1217 Gear^.dY:= - _0_9;
  1218 Gear^.doStep:= @doStepFirePunchWork;
  1218 Gear^.doStep:= @doStepFirePunchWork;
  1219 DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5);
  1219 DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5);
  1220 
  1220 
  1221 PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false)
  1221 PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false, PHedgehog(HHGear^.Hedgehog)^.Team^.voicepack)
  1222 end;
  1222 end;
  1223 
  1223 
  1224 ////////////////////////////////////////////////////////////////////////////////
  1224 ////////////////////////////////////////////////////////////////////////////////
  1225 
  1225 
  1226 procedure doStepParachuteWork(Gear: PGear);
  1226 procedure doStepParachuteWork(Gear: PGear);
  1319 if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then
  1319 if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then
  1320 	Gear^.dX:= Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(TargetPoint.Y) - Gear^.Y) * 2 / cGravity) * Gear^.Tag;
  1320 	Gear^.dX:= Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(TargetPoint.Y) - Gear^.Y) * 2 / cGravity) * Gear^.Tag;
  1321 
  1321 
  1322 Gear^.Health:= 6;
  1322 Gear^.Health:= 6;
  1323 Gear^.doStep:= @doStepAirAttackWork;
  1323 Gear^.doStep:= @doStepAirAttackWork;
  1324 PlaySound(sndIncoming, false)
  1324 PlaySound(sndIncoming, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack)
  1325 end;
  1325 end;
  1326 
  1326 
  1327 ////////////////////////////////////////////////////////////////////////////////
  1327 ////////////////////////////////////////////////////////////////////////////////
  1328 
  1328 
  1329 procedure doStepAirBomb(Gear: PGear);
  1329 procedure doStepAirBomb(Gear: PGear);
  1579 AllInactive:= false;
  1579 AllInactive:= false;
  1580 dec(Gear^.Timer);
  1580 dec(Gear^.Timer);
  1581 if Gear^.Timer = 0 then
  1581 if Gear^.Timer = 0 then
  1582 	begin
  1582 	begin
  1583 	Gear^.Pos:= 1;
  1583 	Gear^.Pos:= 1;
  1584 	PlaySound(sndKamikaze, false);
  1584 	PlaySound(sndKamikaze, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
  1585 	Gear^.doStep:= @doStepKamikazeWork
  1585 	Gear^.doStep:= @doStepKamikazeWork
  1586 	end
  1586 	end
  1587 end;
  1587 end;
  1588 
  1588 
  1589 procedure doStepKamikaze(Gear: PGear);
  1589 procedure doStepKamikaze(Gear: PGear);
  1639 		if (dmg > 1) and (gi^.Kind = gtHedgehog) then
  1639 		if (dmg > 1) and (gi^.Kind = gtHedgehog) then
  1640 			gi^.State:= gi^.State or gstWinner;
  1640 			gi^.State:= gi^.State or gstWinner;
  1641 		gi:= gi^.NextGear
  1641 		gi:= gi^.NextGear
  1642 		end;
  1642 		end;
  1643 	Gear^.doStep:= @doStepCakeExpl;
  1643 	Gear^.doStep:= @doStepCakeExpl;
  1644 	PlaySound(sndCake, false)
  1644 	PlaySound(sndCake, false, nil)
  1645 	end else dec(Gear^.Pos)
  1645 	end else dec(Gear^.Pos)
  1646 end;
  1646 end;
  1647 
  1647 
  1648 
  1648 
  1649 procedure doStepCakeWork(Gear: PGear);
  1649 procedure doStepCakeWork(Gear: PGear);
  1802 if Gear^.Timer > 250 then
  1802 if Gear^.Timer > 250 then
  1803 	begin
  1803 	begin
  1804 	Gear^.Timer:= 0;
  1804 	Gear^.Timer:= 0;
  1805 	inc(Gear^.Pos);
  1805 	inc(Gear^.Pos);
  1806 	if Gear^.Pos = 5 then
  1806 	if Gear^.Pos = 5 then
  1807 		PlaySound(sndYoohoo, false)
  1807 		PlaySound(sndYoohoo, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack)
  1808 	end;
  1808 	end;
  1809 
  1809 
  1810 if Gear^.Pos = 14 then
  1810 if Gear^.Pos = 14 then
  1811 	Gear^.doStep:= @doStepSeductionWork
  1811 	Gear^.doStep:= @doStepSeductionWork
  1812 end;
  1812 end;
  1927 		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0,
  1927 		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0,
  1928 				SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx,
  1928 				SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx,
  1929 				AngleCos(HHGear^.Angle) * ( - _0_8) + ry,
  1929 				AngleCos(HHGear^.Angle) * ( - _0_8) + ry,
  1930 				0);
  1930 				0);
  1931 		
  1931 		
  1932 		PlaySound(sndGun, false);
  1932 		PlaySound(sndGun, false, nil);
  1933 		end;
  1933 		end;
  1934 
  1934 
  1935 	if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then
  1935 	if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then
  1936 		begin
  1936 		begin
  1937 		DeleteGear(Gear);
  1937 		DeleteGear(Gear);