hedgewars/HHHandlers.inc
changeset 2602 3deb9ff104da
parent 2585 0899ce8ad77f
child 2603 abed6070a669
equal deleted inserted replaced
2601:21ed7cec1fa2 2602:3deb9ff104da
   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
       
   140            PlaySound(Ammo^[CurSlot, CurAmmo].AttackVoice, false, CurrentTeam^.voicepack);
   139              case Ammo^[CurSlot, CurAmmo].AmmoType of
   141              case Ammo^[CurSlot, CurAmmo].AmmoType of
   140                       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);
   141                       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);
   142                   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);
   143                       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);
   147                                  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);
   148                                  end;
   150                                  end;
   149                    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);
   150                          amSkip: ParseCommand('/skip', true);
   152                          amSkip: ParseCommand('/skip', true);
   151                          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);
   152                          amMine: begin
   154                          amMine: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, 0, SignAs(_0_02, dX), _0, 3000);
   153                                  AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, 0, SignAs(_0_02, dX), _0, 3000);
       
   154                                  PlaySound(sndLaugh, false, CurrentTeam^.voicepack)
       
   155                                  end;
       
   156                        amDEagle: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
   155                        amDEagle: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
   157                   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);
   158                      amDynamite: begin
   157                      amDynamite: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000);
   159                                  AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000);
       
   160                                  PlaySound(sndLaugh, false, CurrentTeam^.voicepack)
       
   161                                  end;
       
   162                     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);
   163                          amWhip: begin
   159                          amWhip: begin
   164                                  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);
   165                                  PlaySound(sndWhipCrack, false, nil)
   161                                  PlaySound(sndWhipCrack, false, nil)
   166                                  end;
   162                                  end;
   182                       amRCPlane: begin
   178                       amRCPlane: begin
   183                                  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);
   184                                  PlaySound(sndRCPlane, true, nil)
   180                                  PlaySound(sndRCPlane, true, nil)
   185                                  end;
   181                                  end;
   186                        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);
   187                          amCake: begin
   183                          amCake: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 3, hwRound(Y), gtCake, 0, xx, _0, 0);
   188                                  CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 3, hwRound(Y), gtCake, 0, xx, _0, 0);
       
   189                                  PlaySound(sndLaugh, false, CurrentTeam^.voicepack)
       
   190                                  end;
       
   191                     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);
   192                    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);
   193                   amHellishBomb: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtHellishBomb,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   186                   amHellishBomb: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtHellishBomb,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   194                        amNapalm: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 2, _0, _0, 0);
   187                        amNapalm: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 2, _0, _0, 0);
   195                         amDrill: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtDrill, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   188                         amDrill: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtDrill, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   401       PlaySound(sndJump3, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   394       PlaySound(sndJump3, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   402       exit
   395       exit
   403       end;
   396       end;
   404 
   397 
   405    PrevdX:= hwSign(Gear^.dX);
   398    PrevdX:= hwSign(Gear^.dX);
   406    if (Gear^.Message and gm_Left  )<>0 then Gear^.dX:= -cLittle else
   399     
   407    if (Gear^.Message and gm_Right )<>0 then Gear^.dX:=  cLittle else exit;
   400    if (Gear^.Message and gm_Left) <> 0 then
       
   401       Gear^.dX:= -cLittle
       
   402    else if (Gear^.Message and gm_Right) <> 0 then
       
   403       Gear^.dX:=  cLittle
       
   404    else
       
   405       exit;
   408 
   406 
   409    StepTicks:= cHHStepTicks;
   407    StepTicks:= cHHStepTicks;
   410    if PrevdX <> hwSign(Gear^.dX) then
   408    if PrevdX <> hwSign(Gear^.dX) then
   411       begin
   409       begin
   412       FollowGear:= Gear;
   410       FollowGear:= Gear;
   591 else
   589 else
   592    Gear^.Message:= 0;
   590    Gear^.Message:= 0;
   593 
   591 
   594 if (TurnTimeLeft = 0) or (Gear^.Damage > 0) then
   592 if (TurnTimeLeft = 0) or (Gear^.Damage > 0) then
   595 	begin
   593 	begin
       
   594 	StopSound(sndWalking);
   596 	TurnTimeLeft:= 0;
   595 	TurnTimeLeft:= 0;
   597 	isCursorVisible:= false;
   596 	isCursorVisible:= false;
   598 	Gear^.State:= Gear^.State and not (gstHHDriven or gstAnimation or gstAttacking);
   597 	Gear^.State:= Gear^.State and not (gstHHDriven or gstAnimation or gstAttacking);
   599 	AttackBar:= 0;
   598 	AttackBar:= 0;
   600 	if Gear^.Damage > 0 then
   599 	if Gear^.Damage > 0 then
   602 	exit
   601 	exit
   603 	end;
   602 	end;
   604 
   603 
   605 if (Gear^.State and gstAnimation) <> 0 then
   604 if (Gear^.State and gstAnimation) <> 0 then
   606 	begin
   605 	begin
       
   606 	StopSound(sndWalking);
   607 	Gear^.Message:= 0;
   607 	Gear^.Message:= 0;
       
   608 	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);
   608 	inc(Gear^.Timer);
   609 	inc(Gear^.Timer);
   609 	if Gear^.Timer = Wavez[TWave(Gear^.Tag)].Interval then
   610 	if Gear^.Timer = Wavez[TWave(Gear^.Tag)].Interval then
   610 		begin
   611 		begin
   611 		Gear^.Timer:= 0;
   612 		Gear^.Timer:= 0;
   612 		inc(Gear^.Pos);
   613 		inc(Gear^.Pos);
   614 			Gear^.State:= Gear^.State and not gstAnimation
   615 			Gear^.State:= Gear^.State and not gstAnimation
   615 		end;
   616 		end;
   616 	exit
   617 	exit
   617 	end;
   618 	end;
   618 
   619 
       
   620 	// HACK? "StepTicks < 100" - any better way to detect the jump delay?
       
   621 if not cArtillery and (StepTicks < 100) and ((Gear^.State and (gstMoving or gstDrowning)) = 0) and ((Gear^.Message and (gm_Left or gm_Right)) <> 0) then
       
   622    LoopSound(sndWalking, nil)
       
   623 else
       
   624    StopSound(sndWalking);
       
   625 
       
   626 	
   619 if ((Gear^.State and gstMoving) <> 0)
   627 if ((Gear^.State and gstMoving) <> 0)
   620     or (StepTicks = cHHStepTicks)
   628     or (StepTicks = cHHStepTicks)
   621 	or (CurAmmoGear <> nil) then // we are moving
   629 	or (CurAmmoGear <> nil) then // we are moving
   622 	begin
   630 	begin
   623 	with PHedgehog(Gear^.Hedgehog)^ do
   631 	with PHedgehog(Gear^.Hedgehog)^ do