hedgewars/GSHandlers.inc
changeset 2031 b6f3e56fb100
parent 2029 51e164a40b41
child 2033 860b9aea5e86
equal deleted inserted replaced
2030:8eaf3d7c54b2 2031:b6f3e56fb100
   469      and (Land[y, x] <> 0) then inc(Gear^.Damage);
   469      and (Land[y, x] <> 0) then inc(Gear^.Damage);
   470   if Gear^.Damage > 5 then
   470   if Gear^.Damage > 5 then
   471       if Gear^.Ammo^.AmmoType = amDEagle then
   471       if Gear^.Ammo^.AmmoType = amDEagle then
   472           AmmoShove(Gear, 7, 20)
   472           AmmoShove(Gear, 7, 20)
   473       else
   473       else
   474           AmmoShove(Gear, Gear^.Timer*2, 20);
   474           AmmoShove(Gear, Gear^.Timer, 20);
   475   dec(i)
   475   dec(i)
   476 until (i = 0) or (Gear^.Damage > Gear^.Health);
   476 until (i = 0) or (Gear^.Damage > Gear^.Health);
   477 if Gear^.Damage > 0 then
   477 if Gear^.Damage > 0 then
   478    begin
   478    begin
   479    DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82 - i, 1);
   479    DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82 - i, 1);
   482    end;
   482    end;
   483 
   483 
   484 if (Gear^.Health <= 0)
   484 if (Gear^.Health <= 0)
   485 	or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0)
   485 	or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0)
   486 	or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then
   486 	or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then
       
   487     begin
       
   488     if (GameFlags and gfLaserSight) = 0 then cLaserSighting:= false;
       
   489     if (Gear^.Ammo^.NumPerTurn < CurrentHedgehog^.AttacksNum) and
       
   490        ((GameFlags and gfArtillery) = 0) then cArtillery:= false;
   487 	Gear^.doStep:= @doStepShotIdle
   491 	Gear^.doStep:= @doStepShotIdle
       
   492     end;
   488 end;
   493 end;
   489 
   494 
   490 procedure doStepDEagleShot(Gear: PGear);
   495 procedure doStepDEagleShot(Gear: PGear);
   491 begin
   496 begin
   492 PlaySound(sndGun, false, nil);
   497 PlaySound(sndGun, false, nil);
   493 Gear^.doStep:= @doStepBulletWork
   498 Gear^.doStep:= @doStepBulletWork
   494 end;
   499 end;
   495 
   500 
   496 procedure doStepSniperRifleShot(Gear: PGear);
   501 procedure doStepSniperRifleShot(Gear: PGear);
       
   502 var HHGear: PGear;
   497 begin
   503 begin
   498 cArtillery:= true;
   504 cArtillery:= true;
       
   505 HHGear:=PHedgehog(Gear^.Hedgehog)^.Gear;
       
   506 HHGear^.State:= HHGear^.State or gstNotKickable;
   499 if not cLaserSighting then // game doesn't have default laser sight. turn it on and give them a chance to aim
   507 if not cLaserSighting then // game doesn't have default laser sight. turn it on and give them a chance to aim
   500     begin
   508     begin
   501     cLaserSighting:= true;
   509     cLaserSighting:= true;
   502 	DeleteGear(Gear);
   510     HHGear^.Message:= 0;
   503 	AfterAttack;
   511     dec(HHGear^.Angle,32)
   504     exit 
   512     end;
       
   513 
       
   514 if (HHGear^.Message and gm_Attack) <> 0 then
       
   515     begin
       
   516 	Gear^.State:= Gear^.State or gstAnimation;
       
   517     Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _0_5;
       
   518     Gear^.dY:= -AngleCos(HHGear^.Angle) * _0_5;
       
   519     PlaySound(sndGun, false, nil);
       
   520     Gear^.doStep:= @doStepBulletWork;
   505     end
   521     end
   506 else
   522 else
   507     inc(CurrentHedgehog^.AttacksNum); // burn up a shot, Tiy wants only a single shot
   523     if (GameTicks mod 32) = 0 then
   508 
   524         if (GameTicks mod 4096) < 2048 then inc(HHGear^.Angle)
   509 if (PHedgehog(Gear^.Hedgehog)^.Gear^.Message and gm_Attack) <> 0 then
   525         else dec(HHGear^.Angle);
   510     begin
       
   511 	Gear^.State:= Gear^.State or gstAnimation;
       
   512     PlaySound(sndGun, false, nil);
       
   513     Gear^.doStep:= @doStepBulletWork
       
   514     end;
       
   515 
       
   516 if (Gear^.Ammo^.NumPerTurn < CurrentHedgehog^.AttacksNum) and
       
   517    ((GameFlags and gfArtillery) = 0) then cArtillery:= false;
       
   518 
   526 
   519 end;
   527 end;
   520 
   528 
   521 ////////////////////////////////////////////////////////////////////////////////
   529 ////////////////////////////////////////////////////////////////////////////////
   522 procedure doStepActionTimer(Gear: PGear);
   530 procedure doStepActionTimer(Gear: PGear);