hedgewars/HHHandlers.inc
changeset 4233 b4ad20bfe310
parent 4224 99c6d87df131
child 4238 6f1631765ebd
equal deleted inserted replaced
4232:3a7862405c36 4233:b4ad20bfe310
   135         end;
   135         end;
   136 end;
   136 end;
   137 
   137 
   138 
   138 
   139 procedure Attack(Gear: PGear);
   139 procedure Attack(Gear: PGear);
   140 var xx, yy, lx, ly: hwFloat;
   140 var xx, yy, newDx, newDy, lx, ly: hwFloat;
   141     tmpGear: PVisualGear;
   141     tmpGear: PVisualGear;
   142     CurWeapon: PAmmo;
   142     CurWeapon: PAmmo;
       
   143     altUse: boolean;
   143 begin
   144 begin
   144 bShowFinger:= false;
   145 bShowFinger:= false;
   145 CurWeapon:= GetAmmoEntry(PHedgehog(Gear^.Hedgehog)^);
   146 CurWeapon:= GetAmmoEntry(PHedgehog(Gear^.Hedgehog)^);
   146 with Gear^,
   147 with Gear^,
   147      PHedgehog(Gear^.Hedgehog)^ do
   148      PHedgehog(Gear^.Hedgehog)^ do
   180         ly:= Y + int2hwfloat(round(GetLaunchY(CurAmmoType, Angle)));
   181         ly:= Y + int2hwfloat(round(GetLaunchY(CurAmmoType, Angle)));
   181 
   182 
   182         if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) then xx:= - xx;
   183         if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) then xx:= - xx;
   183         if Ammoz[CurAmmoType].Ammo.AttackVoice <> sndNone then
   184         if Ammoz[CurAmmoType].Ammo.AttackVoice <> sndNone then
   184            PlaySound(Ammoz[CurAmmoType].Ammo.AttackVoice, CurrentTeam^.voicepack);
   185            PlaySound(Ammoz[CurAmmoType].Ammo.AttackVoice, CurrentTeam^.voicepack);
       
   186 
       
   187 // Initiating alt attack
       
   188         if  (CurAmmoGear <> nil) and
       
   189             ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) and
       
   190             ((Gear^.Message and gmLJump) <> 0) and
       
   191             ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then
       
   192             begin
       
   193             newDx:= dX / _2; 
       
   194             newDy:= dY / _2;
       
   195             altUse:= true;
       
   196             end
       
   197         else
       
   198             begin
       
   199             newDx:= xx*Power/cPowerDivisor;
       
   200             newDy:= yy*Power/cPowerDivisor;
       
   201             altUse:= false
       
   202             end;
       
   203 
   185              case CurAmmoType of
   204              case CurAmmoType of
   186                       amGrenade: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtBomb,         0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, CurWeapon^.Timer);
   205                       amGrenade: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtBomb,         0, newDx, newDy, CurWeapon^.Timer);
   187                       amMolotov: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtMolotov,      0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   206                       amMolotov: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtMolotov,      0, newDx, newDy, 0);
   188                   amClusterBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtClusterBomb,  0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, CurWeapon^.Timer);
   207                   amClusterBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtClusterBomb,  0, newDx, newDy, CurWeapon^.Timer);
   189                       amGasBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtGasBomb,      0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, CurWeapon^.Timer);
   208                       amGasBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtGasBomb,      0, newDx, newDy, CurWeapon^.Timer);
   190                       amBazooka: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtShell,        0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   209                       amBazooka: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtShell,        0, newDx, newDy, 0);
   191                           amBee: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtBee,          0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   210                           amBee: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtBee,          0, newDx, newDy, 0);
   192                       amShotgun: begin
   211                       amShotgun: begin
   193                                  PlaySound(sndShotgunReload);
   212                                  PlaySound(sndShotgunReload);
   194                                  CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtShotgunShot,  0, xx * _0_5, yy * _0_5, 0);
   213                                  CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtShotgunShot,  0, xx * _0_5, yy * _0_5, 0);
   195                                  end;
   214                                  end;
   196                    amPickHammer: CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly) + cHHRadius, gtPickHammer, 0, _0, _0, 0);
   215                    amPickHammer: CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly) + cHHRadius, gtPickHammer, 0, _0, _0, 0);
   197                          amSkip: ParseCommand('/skip', true);
   216                          amSkip: ParseCommand('/skip', true);
   198                          amRope: CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtRope, 0, xx, yy, 0);
   217                          amRope: CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtRope, 0, xx, yy, 0);
   199                          amMine: AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000);
   218                          amMine: if altUse then
       
   219                                     AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, newDx, newDy, 3000)
       
   220                                  else
       
   221                                     AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000);
   200                         amSMine: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtSMine,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   222                         amSMine: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtSMine,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   201                        amDEagle: CurAmmoGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
   223                        amDEagle: CurAmmoGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
   202                       amSineGun: CurAmmoGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0);
   224                       amSineGun: CurAmmoGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0);
   203                     amPortalGun: AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, 0);
   225                     amPortalGun: AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, 0);
   204                   amSniperRifle: begin
   226                   amSniperRifle: begin
   239                                  CurAmmoGear^.SoundChannel:= LoopSound(sndRCPlane, nil)
   261                                  CurAmmoGear^.SoundChannel:= LoopSound(sndRCPlane, nil)
   240                                  end;
   262                                  end;
   241                        amKamikaze: CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0);
   263                        amKamikaze: CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0);
   242                          amCake: CurAmmoGear:= AddGear(hwRound(lx) + hwSign(dX) * 3, hwRound(ly), gtCake, 0, xx, _0, 0);
   264                          amCake: CurAmmoGear:= AddGear(hwRound(lx) + hwSign(dX) * 3, hwRound(ly), gtCake, 0, xx, _0, 0);
   243                     amSeduction: CurAmmoGear:= AddGear(hwRound(lx + xx * cHHRadius * 2), hwRound(ly + yy * cHHRadius * 2), gtSeduction, 0, xx * _0_4, yy * _0_4, 0);
   265                     amSeduction: CurAmmoGear:= AddGear(hwRound(lx + xx * cHHRadius * 2), hwRound(ly + yy * cHHRadius * 2), gtSeduction, 0, xx * _0_4, yy * _0_4, 0);
   244                    amWatermelon: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtWatermelon,  0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, CurWeapon^.Timer);
   266                    amWatermelon: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtWatermelon,  0, newDx, newDy, CurWeapon^.Timer);
   245                   amHellishBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtHellishBomb,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   267                   amHellishBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtHellishBomb,    0, newDx, newDy, 0);
   246                        amNapalm: AddGear(CurWeapon^.Pos, 0, gtAirAttack, 2, _0, _0, 0);
   268                        amNapalm: AddGear(CurWeapon^.Pos, 0, gtAirAttack, 2, _0, _0, 0);
   247                         amDrill: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtDrill, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   269                         amDrill: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtDrill, 0, newDx, newDy, 0);
   248                       amBallgun: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtBallgun,  0, xx * _0_5, yy * _0_5, 0);
   270                       amBallgun: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtBallgun,  0, xx * _0_5, yy * _0_5, 0);
   249                     amJetpack: CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtJetpack, 0, _0, _0, 0);
   271                     amJetpack: CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtJetpack, 0, _0, _0, 0);
   250                     amBirdy: begin
   272                     amBirdy: begin
   251                              PlaySound(sndWhistle);
   273                              PlaySound(sndWhistle);
   252                              CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly) - 32, gtBirdy, 0, _0, _0, 0);
   274                              CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly) - 32, gtBirdy, 0, _0, _0, 0);
   793     with Hedgehog^ do
   815     with Hedgehog^ do
   794         if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)
   816         if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)
   795             and ((Gear^.Message and gmLJump) <> 0)
   817             and ((Gear^.Message and gmLJump) <> 0)
   796             and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then
   818             and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then
   797             begin
   819             begin
   798             Gear^.Message:= Gear^.Message and not gmLJump;
   820             Attack(Gear);
   799             Attack(Gear)
   821             Gear^.Message:= Gear^.Message and not gmLJump
   800             end;
   822             end;
   801 
   823 
   802 if (CurAmmoGear = nil)
   824 if (CurAmmoGear = nil)
   803     or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) 
   825     or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) 
   804     or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEndHint) <> 0) then
   826     or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEndHint) <> 0) then