hedgewars/HHHandlers.inc
changeset 3396 e5b3e5f2818e
parent 3391 77161719ec3c
child 3397 c47af0694a7d
equal deleted inserted replaced
3395:095273ad0e08 3396:e5b3e5f2818e
    24 
    24 
    25 with PHedgehog(Gear^.Hedgehog)^ do
    25 with PHedgehog(Gear^.Hedgehog)^ do
    26     begin
    26     begin
    27     Gear^.Message:= Gear^.Message and not gm_Slot;
    27     Gear^.Message:= Gear^.Message and not gm_Slot;
    28 
    28 
    29     if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0)
    29     if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or
    30         or (MultiShootAttacks > 0)
    30        ((MultiShootAttacks > 0) and ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_NoRoundEndHint) = 0)) or
    31         or ((Gear^.State and gstHHDriven) = 0) then exit;
    31        ((Gear^.State and gstHHDriven) = 0) then exit;
    32 
    32 
       
    33     MultiShootAttacks:= 0;
    33     Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump);
    34     Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump);
    34 
    35 
    35     if CurSlot = slot then
    36     if CurSlot = slot then
    36         begin
    37         begin
    37         i:= 0;
    38         i:= 0;
    99 
   100 
   100 
   101 
   101 procedure Attack(Gear: PGear);
   102 procedure Attack(Gear: PGear);
   102 var xx, yy: hwFloat;
   103 var xx, yy: hwFloat;
   103     tmpGear: PVisualGear;
   104     tmpGear: PVisualGear;
       
   105     newGear, iterator, portal: PGear;
   104 begin
   106 begin
   105 bShowFinger:= false;
   107 bShowFinger:= false;
   106 with Gear^,
   108 with Gear^,
   107      PHedgehog(Gear^.Hedgehog)^ do
   109      PHedgehog(Gear^.Hedgehog)^ do
   108      begin
   110      begin
   146                       amGasBomb: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtGasBomb,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
   148                       amGasBomb: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtGasBomb,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
   147                       amBazooka: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   149                       amBazooka: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   148                           amBee: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtBee,          0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   150                           amBee: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtBee,          0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   149                       amShotgun: begin
   151                       amShotgun: begin
   150                                  PlaySound(sndShotgunReload);
   152                                  PlaySound(sndShotgunReload);
   151                                  CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtShotgunShot,  0, xx * _0_5, yy * _0_5, 0);
   153                                  AddGear(hwRound(X), hwRound(Y), gtShotgunShot,  0, xx * _0_5, yy * _0_5, 0);
   152                                  end;
   154                                  end;
   153                    amPickHammer: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, gtPickHammer, 0, _0, _0, 0);
   155                    amPickHammer: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, gtPickHammer, 0, _0, _0, 0);
   154                          amSkip: ParseCommand('/skip', true);
   156                          amSkip: ParseCommand('/skip', true);
   155                          amRope: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtRope, 0, xx, yy, 0);
   157                          amRope: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtRope, 0, xx, yy, 0);
   156                          amMine: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000);
   158                          amMine: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000);
   157                        amDEagle: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
   159                        amDEagle: AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
   158                       amSineGun: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0);
   160                       amSineGun: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0);
   159 (*
       
   160 Ok. Here's where I plan to go with this.
       
   161 1) Restrict portal gun to X shots.
       
   162 2) If on first shot, delete all existing gtPortal
       
   163 3) On any other shot, delete any existing portals of type X%2, and spawn a new portal of type X%2 oriented at angle 180° from the portal gun.  It might possibly be worth linking portals with a Gear reference, to save time on scanning through the Gear list every time we need a portal.
       
   164 *)
       
   165                     amPortalGun: begin
   161                     amPortalGun: begin
   166         //if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= MultiShootAttacks) then
   162                                  iterator:= GearsList;
   167                                 
   163                                  portal:= nil;
   168 
   164                                  while iterator <> nil do
   169 //CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, 0);
   165                                      begin
   170 AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, 0);
   166                                      if (iterator^.Kind = gtPortal) then
   171 
   167                                          begin
   172 
   168                                          newGear:= iterator;
   173 
   169                                          iterator:= iterator^.NextGear;
       
   170                                          if (portal <> nil) then
       
   171                                              begin
       
   172                                              if (portal^.uid < newGear^.uid) then 
       
   173                                                  begin
       
   174                                                  DeleteGear(portal);
       
   175                                                  portal:= newGear
       
   176                                                  end
       
   177                                              else
       
   178                                                  begin
       
   179                                                  if newGear^.NextGear = nil then iterator:= nil;
       
   180                                                  DeleteGear(newGear);
       
   181                                                  end
       
   182                                              end
       
   183                                          else portal:= newGear
       
   184                                          end
       
   185                                      else iterator:= iterator^.NextGear
       
   186                                      end;
       
   187 
       
   188                                  newGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, 0);
       
   189                                  if portal <> nil then 
       
   190                                      begin
       
   191                                      newGear^.IntersectGear:= portal;
       
   192                                      if portal^.Tag < 2 then newGear^.Tag:= 2
       
   193                                      end;
       
   194                                  newGear^.Angle:= Angle;
       
   195                                  newGear^.DirAngle:= Angle * 180 / cMaxAngle - 90;
       
   196                                  if Gear^.DirAngle < 0 then Gear^.DirAngle:= Gear^.DirAngle + 360
       
   197                                  else if 360 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle - 360;
       
   198                                  Ammo^[CurSlot, CurAmmo].Timer:= 0
   174                                  end;
   199                                  end;
   175 
       
   176 
       
   177 
       
   178 
       
   179                   amSniperRifle: begin
   200                   amSniperRifle: begin
   180                                  PlaySound(sndSniperReload);
   201                                  PlaySound(sndSniperReload);
   181                                  CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtSniperRifleShot, 0, xx * _0_5, yy * _0_5, 0);
   202                                  CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtSniperRifleShot, 0, xx * _0_5, yy * _0_5, 0);
   182                                  end;
   203                                  end;
   183                      amDynamite: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000);
   204                      amDynamite: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000);
   287             begin
   308             begin
   288             isInMultiShoot:= true
   309             isInMultiShoot:= true
   289             end
   310             end
   290         else
   311         else
   291             begin
   312             begin
   292             TurnTimeLeft:= Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].TimeAfterTurn;
   313             if ((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_NoRoundEndHint) = 0 then
   293             State:= State or gstAttacked;
   314                 begin
       
   315                 TurnTimeLeft:= Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].TimeAfterTurn;
       
   316                 State:= State or gstAttacked
       
   317                 end;
   294             OnUsedAmmo(CurrentHedgehog^);
   318             OnUsedAmmo(CurrentHedgehog^);
   295             end;
   319             end;
   296         end
   320         end
   297     else
   321     else
   298         begin
   322         begin
   563 procedure doStepHedgehog(Gear: PGear); forward;
   587 procedure doStepHedgehog(Gear: PGear); forward;
   564 ////////////////////////////////////////////////////////////////////////////////
   588 ////////////////////////////////////////////////////////////////////////////////
   565 procedure doStepHedgehogMoving(Gear: PGear);
   589 procedure doStepHedgehogMoving(Gear: PGear);
   566 var isFalling: boolean;
   590 var isFalling: boolean;
   567 begin
   591 begin
       
   592 if Gear^.dX > _0_995 then Gear^.dX:= _0_995;
       
   593 if Gear^.dY > _0_995 then Gear^.dY:= _0_995;
   568 if PHedgehog(Gear^.Hedgehog)^.Unplaced then
   594 if PHedgehog(Gear^.Hedgehog)^.Unplaced then
   569    begin
   595    begin
   570    Gear^.dY:= _0;
   596    Gear^.dY:= _0;
   571    Gear^.dX:= _0;
   597    Gear^.dX:= _0;
   572    Gear^.State:= Gear^.State and not gstMoving;
   598    Gear^.State:= Gear^.State and not gstMoving;