hedgewars/HHHandlers.inc
changeset 2017 7845c77c8d31
parent 1964 dc9ea05c9d2f
child 2023 41d3afaa20c7
equal deleted inserted replaced
2016:73b0bcc4396d 2017:7845c77c8d31
    98 end;
    98 end;
    99 
    99 
   100 
   100 
   101 procedure Attack(Gear: PGear);
   101 procedure Attack(Gear: PGear);
   102 var xx, yy: hwFloat;
   102 var xx, yy: hwFloat;
       
   103     tmpGear: PGear;
   103 begin
   104 begin
   104 with Gear^,
   105 with Gear^,
   105      PHedgehog(Gear^.Hedgehog)^ do
   106      PHedgehog(Gear^.Hedgehog)^ do
   106      begin
   107      begin
   107      if ((State and gstHHDriven) <> 0)and
   108      if ((State and gstHHDriven) <> 0)and
   187                       //this flag unfortunately gets cleared too often for true invulnerability, although it seemed like the natural choice
   188                       //this flag unfortunately gets cleared too often for true invulnerability, although it seemed like the natural choice
   188                       //amInvulnerable: State:= State or gstNoDamage;
   189                       //amInvulnerable: State:= State or gstNoDamage;
   189                       amInvulnerable: Invulnerable:= true;
   190                       amInvulnerable: Invulnerable:= true;
   190                       amExtraTime: TurnTimeLeft:= TurnTimeLeft + 30000;
   191                       amExtraTime: TurnTimeLeft:= TurnTimeLeft + 30000;
   191                       amLaserSight: cLaserSighting:= true;
   192                       amLaserSight: cLaserSighting:= true;
       
   193                       amVampiric: cVampiric:= true;
   192                   end;
   194                   end;
   193 
   195 
   194         uStats.AmmoUsed(Ammo^[CurSlot, CurAmmo].AmmoType);
   196         uStats.AmmoUsed(Ammo^[CurSlot, CurAmmo].AmmoType);
       
   197 
       
   198         if not (SpeechText = '') then
       
   199             begin
       
   200             tmpGear:= AddGear(0, 0, gtSpeechBubble, 0, _0, _0, 0);
       
   201             tmpGear^.Text:= SpeechText;
       
   202             tmpGear^.Hedgehog:= CurrentHedgehog;
       
   203             tmpGear^.State:= SpeechType;
       
   204             SpeechText:= ''
       
   205             end;
   195 
   206 
   196         Power:= 0;
   207         Power:= 0;
   197         if (CurAmmoGear <> nil)
   208         if (CurAmmoGear <> nil)
   198            and (((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_AltUse) = 0){check for dropping ammo from rope} then
   209            and (((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_AltUse) = 0){check for dropping ammo from rope} then
   199            begin
   210            begin
   384          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   395          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   385       if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX))
   396       if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX))
   386          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   397          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   387       end;
   398       end;
   388 
   399 
       
   400    // ARTILLERY HERE
   389    if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX);
   401    if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX);
   390    SetAllHHToActive;
   402    SetAllHHToActive;
   391 
   403 
   392    if not TestCollisionYwithGear(Gear, 1) then
   404    if not TestCollisionYwithGear(Gear, 1) then
   393    begin
   405    begin
   502    end else Gear^.State:= Gear^.State or gstMoving;
   514    end else Gear^.State:= Gear^.State or gstMoving;
   503 
   515 
   504 if (Gear^.State and gstMoving) <> 0 then
   516 if (Gear^.State and gstMoving) <> 0 then
   505    begin
   517    begin
   506    Gear^.State:= Gear^.State and not gstAnimation;
   518    Gear^.State:= Gear^.State and not gstAnimation;
       
   519 // ARTILLERY but not being moved by explosions
   507    Gear^.X:= Gear^.X + Gear^.dX;
   520    Gear^.X:= Gear^.X + Gear^.dX;
   508    Gear^.Y:= Gear^.Y + Gear^.dY;
   521    Gear^.Y:= Gear^.Y + Gear^.dY;
   509    if (not Gear^.dY.isNegative) and
   522    if (not Gear^.dY.isNegative) and
   510       (not TestCollisionYKick(Gear, 1)) and
   523       (not TestCollisionYKick(Gear, 1)) and
   511        TestCollisionYwithXYShift(Gear, 0, 1, 1) then
   524        TestCollisionYwithXYShift(Gear, 0, 1, 1) then