hedgewars/HHHandlers.inc
changeset 2745 11fce231f24a
parent 2660 04c03640a7b0
child 2762 2fbc8d35eb52
equal deleted inserted replaced
2744:803d0142594e 2745:11fce231f24a
   118         else if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then Message:= Message and not gm_Attack
   118         else if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then Message:= Message and not gm_Attack
   119         else begin
   119         else begin
   120              if Power = 0 then
   120              if Power = 0 then
   121                 begin
   121                 begin
   122                 AttackBar:= CurrentTeam^.AttackBar;
   122                 AttackBar:= CurrentTeam^.AttackBar;
   123                 PlaySound(sndThrowPowerUp, false, nil)
   123                 PlaySound(sndThrowPowerUp)
   124                 end;
   124                 end;
   125              inc(Power)
   125              inc(Power)
   126              end;
   126              end;
   127         if ((Message and gm_Attack) <> 0) then exit;
   127         if ((Message and gm_Attack) <> 0) then exit;
   128 
   128 
   129         if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0 then
   129         if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0 then
   130            begin
   130            begin
   131            StopSound(sndThrowPowerUp);
   131            StopSound(sndThrowPowerUp);
   132            PlaySound(sndThrowRelease, false, nil);
   132            PlaySound(sndThrowRelease);
   133            end;
   133            end;
   134 
   134 
   135         xx:= SignAs(AngleSin(Angle), dX);
   135         xx:= SignAs(AngleSin(Angle), dX);
   136         yy:= -AngleCos(Angle);
   136         yy:= -AngleCos(Angle);
   137 
   137 
   138         if ((Gear^.State and gstHHHJump) <> 0) then xx:= - xx;
   138         if ((Gear^.State and gstHHHJump) <> 0) then xx:= - xx;
   139         if Ammo^[CurSlot, CurAmmo].AttackVoice <> sndNone then
   139         if Ammo^[CurSlot, CurAmmo].AttackVoice <> sndNone then
   140            PlaySound(Ammo^[CurSlot, CurAmmo].AttackVoice, false, CurrentTeam^.voicepack);
   140            PlaySound(Ammo^[CurSlot, CurAmmo].AttackVoice, CurrentTeam^.voicepack);
   141              case Ammo^[CurSlot, CurAmmo].AmmoType of
   141              case Ammo^[CurSlot, CurAmmo].AmmoType of
   142                       amGrenade: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Bomb,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
   142                       amGrenade: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Bomb,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
   143                       amMolotov: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtMolotov,      0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   143                       amMolotov: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtMolotov,      0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   144                   amClusterBomb: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtClusterBomb,  0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
   144                   amClusterBomb: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtClusterBomb,  0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
   145                       amBazooka: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   145                       amBazooka: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   146                           amUFO: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtUFO,          0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   146                           amUFO: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtUFO,          0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   147                       amShotgun: begin
   147                       amShotgun: begin
   148                                  PlaySound(sndShotgunReload, false, nil);
   148                                  PlaySound(sndShotgunReload);
   149                                  CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtShotgunShot,  0, xx * _0_5, yy * _0_5, 0);
   149                                  CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtShotgunShot,  0, xx * _0_5, yy * _0_5, 0);
   150                                  end;
   150                                  end;
   151                    amPickHammer: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, gtPickHammer, 0, _0, _0, 0);
   151                    amPickHammer: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, gtPickHammer, 0, _0, _0, 0);
   152                          amSkip: ParseCommand('/skip', true);
   152                          amSkip: ParseCommand('/skip', true);
   153                          amRope: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtRope, 0, xx, yy, 0);
   153                          amRope: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtRope, 0, xx, yy, 0);
   156                   amSniperRifle: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtSniperRifleShot, 0, xx * _0_5, yy * _0_5, 0);
   156                   amSniperRifle: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtSniperRifleShot, 0, xx * _0_5, yy * _0_5, 0);
   157                      amDynamite: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000);
   157                      amDynamite: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000);
   158                     amFirePunch: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtFirePunch, 0, xx, _0, 0);
   158                     amFirePunch: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtFirePunch, 0, xx, _0, 0);
   159                          amWhip: begin
   159                          amWhip: begin
   160                                  CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtWhip, 0, SignAs(_1, dX), - _0_8, 0);
   160                                  CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtWhip, 0, SignAs(_1, dX), - _0_8, 0);
   161                                  PlaySound(sndWhipCrack, false, nil)
   161                                  PlaySound(sndWhipCrack)
   162                                  end;
   162                                  end;
   163                   amBaseballBat: begin
   163                   amBaseballBat: begin
   164 								 CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, gsttmpFlag, xx * _0_5, yy * _0_5, 0);
   164 								 CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, gsttmpFlag, xx * _0_5, yy * _0_5, 0);
   165 								 PlaySound(sndBaseballBat, false, nil);
   165 								 PlaySound(sndBaseballBat)
   166 								 end;
   166 								 end;
   167                     amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, _0, _0, 0);
   167                     amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, _0, _0, 0);
   168                     amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, _0, _0, 0);
   168                     amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, _0, _0, 0);
   169                    amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, _0, _0, 0);
   169                    amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, _0, _0, 0);
   170                     amBlowTorch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0);
   170                     amBlowTorch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0);
   171                        amGirder: CurAmmoGear:= AddGear(0, 0, gtGirder, Ammo^[CurSlot, CurAmmo].Pos, _0, _0, 0);
   171                        amGirder: CurAmmoGear:= AddGear(0, 0, gtGirder, Ammo^[CurSlot, CurAmmo].Pos, _0, _0, 0);
   172                      amTeleport: CurAmmoGear:= AddGear(0, 0, gtTeleport, 0, _0, _0, 0);
   172                      amTeleport: CurAmmoGear:= AddGear(0, 0, gtTeleport, 0, _0, _0, 0);
   173                        amSwitch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtSwitcher, 0, _0, _0, 0);
   173                        amSwitch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtSwitcher, 0, _0, _0, 0);
   174                        amMortar: begin
   174                        amMortar: begin
   175 				playSound(sndMortar, false, nil);
   175 				playSound(sndMortar);
   176 				FollowGear:= AddGear(hwRound(X), hwRound(Y), gtMortar,  0, xx*cMaxPower/cPowerDivisor, yy*cMaxPower/cPowerDivisor, 0);
   176 				FollowGear:= AddGear(hwRound(X), hwRound(Y), gtMortar,  0, xx*cMaxPower/cPowerDivisor, yy*cMaxPower/cPowerDivisor, 0);
   177 				 end;
   177 				 end;
   178                       amRCPlane: begin
   178                       amRCPlane: begin
   179                                  CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtRCPlane,  0, xx * cMaxPower / cPowerDivisor / 4, yy * cMaxPower / cPowerDivisor / 4, 0);
   179                                  CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtRCPlane,  0, xx * cMaxPower / cPowerDivisor / 4, yy * cMaxPower / cPowerDivisor / 4, 0);
   180                                  PlaySound(sndRCPlane, true, nil)
   180                                  CurAmmoGear^.SoundChannel:= LoopSound(sndRCPlane, nil)
   181                                  end;
   181                                  end;
   182                        amKamikaze: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0);
   182                        amKamikaze: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0);
   183                          amCake: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 3, hwRound(Y), gtCake, 0, xx, _0, 0);
   183                          amCake: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 3, hwRound(Y), gtCake, 0, xx, _0, 0);
   184                     amSeduction: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius * 2), hwRound(Y + yy * cHHRadius * 2), gtSeduction, 0, xx * _0_4, yy * _0_4, 0);
   184                     amSeduction: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius * 2), hwRound(Y + yy * cHHRadius * 2), gtSeduction, 0, xx * _0_4, yy * _0_4, 0);
   185                    amWatermelon: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtWatermelon,  0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
   185                    amWatermelon: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtWatermelon,  0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
   286 	begin
   286 	begin
   287 	AllInactive:= false;
   287 	AllInactive:= false;
   288 	Gear^.Z:= cCurrHHZ;
   288 	Gear^.Z:= cCurrHHZ;
   289 	RemoveGearFromList(Gear);
   289 	RemoveGearFromList(Gear);
   290 	InsertGearToList(Gear);
   290 	InsertGearToList(Gear);
   291 	PlaySound(sndByeBye, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   291 	PlaySound(sndByeBye, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   292 	Gear^.Pos:= 0;
   292 	Gear^.Pos:= 0;
   293 	Gear^.Timer:= timertime
   293 	Gear^.Timer:= timertime
   294 	end
   294 	end
   295 end;
   295 end;
   296 
   296 
   299 var s: shortstring;
   299 var s: shortstring;
   300     a: TAmmoType;
   300     a: TAmmoType;
   301 	i: Integer;
   301 	i: Integer;
   302 begin
   302 begin
   303 Gear^.Message:= gm_Destroy;
   303 Gear^.Message:= gm_Destroy;
   304 PlaySound(sndShotgunReload, false, nil);
   304 PlaySound(sndShotgunReload);
   305 case Gear^.Pos of
   305 case Gear^.Pos of
   306        posCaseUtility,
   306        posCaseUtility,
   307        posCaseAmmo: begin
   307        posCaseAmmo: begin
   308                     a:= TAmmoType(Gear^.State);
   308                     a:= TAmmoType(Gear^.State);
   309                     AddAmmo(PHedgehog(HH^.Hedgehog)^, a);
   309                     AddAmmo(PHedgehog(HH^.Hedgehog)^, a);
   374          or   TestCollisionYwithGear(Gear, -1)) then
   374          or   TestCollisionYwithGear(Gear, -1)) then
   375          begin
   375          begin
   376          Gear^.dY:= -_0_15;
   376          Gear^.dY:= -_0_15;
   377          if not cArtillery then Gear^.dX:= SignAs(_0_15, Gear^.dX);
   377          if not cArtillery then Gear^.dX:= SignAs(_0_15, Gear^.dX);
   378          Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   378          Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   379          PlaySound(sndJump1, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   379          PlaySound(sndJump1, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   380          exit
   380          exit
   381          end;
   381          end;
   382       end;
   382       end;
   383 
   383 
   384    if ((Gear^.Message and gm_HJump ) <> 0) then
   384    if ((Gear^.Message and gm_HJump ) <> 0) then
   387       Gear^.Message:= Gear^.Message and not gm_HJump;
   387       Gear^.Message:= Gear^.Message and not gm_HJump;
   388 
   388 
   389       Gear^.dY:= -_0_2;
   389       Gear^.dY:= -_0_2;
   390       SetLittle(Gear^.dX);
   390       SetLittle(Gear^.dX);
   391       Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   391       Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   392       PlaySound(sndJump3, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   392       PlaySound(sndJump3, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   393       exit
   393       exit
   394       end;
   394       end;
   395 
   395 
   396    PrevdX:= hwSign(Gear^.dX);
   396    PrevdX:= hwSign(Gear^.dX);
   397    if (Gear^.Message and gm_Left  )<>0 then Gear^.dX:= -cLittle else
   397    if (Gear^.Message and gm_Left  )<>0 then Gear^.dX:= -cLittle else
   561     begin
   561     begin
   562     inc(Gear^.FlightTime, 1);
   562     inc(Gear^.FlightTime, 1);
   563 	if Gear^.FlightTime = 2000 then
   563 	if Gear^.FlightTime = 2000 then
   564 		begin
   564 		begin
   565 		AddCaption(GetEventString(eidHomerun), cWhiteColor, capgrpMessage);
   565 		AddCaption(GetEventString(eidHomerun), cWhiteColor, capgrpMessage);
   566 		PlaySound(sndHomerun, false, nil)
   566 		PlaySound(sndHomerun)
   567 		end;
   567 		end;
   568 	end
   568 	end
   569 else
   569 else
   570     begin
   570     begin
   571     Gear^.FlightTime:= 0;
   571     Gear^.FlightTime:= 0;
   594 	end;
   594 	end;
   595 
   595 
   596 if (Gear^.State and gstAnimation) <> 0 then
   596 if (Gear^.State and gstAnimation) <> 0 then
   597 	begin
   597 	begin
   598 	Gear^.Message:= 0;
   598 	Gear^.Message:= 0;
   599 	if (Gear^.Pos = Wavez[TWave(Gear^.Tag)].VoiceDelay) and (Gear^.Timer = 0) then PlaySound(Wavez[TWave(Gear^.Tag)].Voice, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   599 	if (Gear^.Pos = Wavez[TWave(Gear^.Tag)].VoiceDelay) and (Gear^.Timer = 0) then PlaySound(Wavez[TWave(Gear^.Tag)].Voice, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   600 	inc(Gear^.Timer);
   600 	inc(Gear^.Timer);
   601 	if Gear^.Timer = Wavez[TWave(Gear^.Tag)].Interval then
   601 	if Gear^.Timer = Wavez[TWave(Gear^.Tag)].Interval then
   602 		begin
   602 		begin
   603 		Gear^.Timer:= 0;
   603 		Gear^.Timer:= 0;
   604 		inc(Gear^.Pos);
   604 		inc(Gear^.Pos);
   669 		if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then
   669 		if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then
   670 			begin
   670 			begin
   671 			Gear^.State:= Gear^.State or gstHHHJump;
   671 			Gear^.State:= Gear^.State or gstHHHJump;
   672 			Gear^.dY:= -_0_25;
   672 			Gear^.dY:= -_0_25;
   673 			if not cArtillery then Gear^.dX:= -SignAs(_0_02, Gear^.dX);
   673 			if not cArtillery then Gear^.dX:= -SignAs(_0_02, Gear^.dX);
   674 			PlaySound(sndJump2, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack)
   674 			PlaySound(sndJump2, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack)
   675 			end;
   675 			end;
   676 
   676 
   677 	Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump);
   677 	Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump);
   678 
   678 
   679 	if (not cArtillery) and wasJumping and
   679 	if (not cArtillery) and wasJumping and