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