hedgewars/GSHandlers.inc
changeset 4886 e3e5362a308e
parent 4881 35e6269227b6
child 4956 48e1f9a04c28
equal deleted inserted replaced
4884:b2006a9f0fbc 4886:e3e5362a308e
  2379     y := HHGear^.Y;
  2379     y := HHGear^.Y;
  2380 
  2380 
  2381     if (Distance(tx - x, ty - y) > _256) or
  2381     if (Distance(tx - x, ty - y) > _256) or
  2382        not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2,
  2382        not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2,
  2383        TargetPoint.Y - SpritesData[sprAmGirder].Height div 2,
  2383        TargetPoint.Y - SpritesData[sprAmGirder].Height div 2,
  2384        sprAmGirder, Gear^.State, true) then
  2384        sprAmGirder, Gear^.State, true, false) then
  2385     begin
  2385     begin
  2386         PlaySound(sndDenied);
  2386         PlaySound(sndDenied);
  2387         HHGear^.Message := HHGear^.Message and not gmAttack;
  2387         HHGear^.Message := HHGear^.Message and not gmAttack;
  2388         HHGear^.State := HHGear^.State and not gstAttacking;
  2388         HHGear^.State := HHGear^.State and not gstAttacking;
  2389         HHGear^.State := HHGear^.State or gstHHChooseTarget;
  2389         HHGear^.State := HHGear^.State or gstHHChooseTarget;
  2440     AllInactive := false;
  2440     AllInactive := false;
  2441 
  2441 
  2442     HHGear := Gear^.Hedgehog^.Gear;
  2442     HHGear := Gear^.Hedgehog^.Gear;
  2443     if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2,
  2443     if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2,
  2444        TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2,
  2444        TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2,
  2445        sprHHTelepMask, 0, false) then
  2445        sprHHTelepMask, 0, false, false) then
  2446     begin
  2446     begin
  2447         HHGear^.Message := HHGear^.Message and not gmAttack;
  2447         HHGear^.Message := HHGear^.Message and not gmAttack;
  2448         HHGear^.State := HHGear^.State and not gstAttacking;
  2448         HHGear^.State := HHGear^.State and not gstAttacking;
  2449         HHGear^.State := HHGear^.State or gstHHChooseTarget;
  2449         HHGear^.State := HHGear^.State or gstHHChooseTarget;
  2450         DeleteGear(Gear);
  2450         DeleteGear(Gear);
  3112 begin
  3112 begin
  3113     AllInactive := false;
  3113     AllInactive := false;
  3114 
  3114 
  3115     HHGear := Gear^.Hedgehog^.Gear;
  3115     HHGear := Gear^.Hedgehog^.Gear;
  3116     FollowGear := Gear;
  3116     FollowGear := Gear;
       
  3117 
       
  3118     if Gear^.Timer > 0 then dec(Gear^.Timer);
  3117 
  3119 
  3118     fChanged := false;
  3120     fChanged := false;
  3119     if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then
  3121     if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then
  3120     begin
  3122     begin
  3121         fChanged := true;
  3123         fChanged := true;
  4589         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  4591         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  4590     dec(Gear^.Timer)
  4592     dec(Gear^.Timer)
  4591 end;
  4593 end;
  4592 
  4594 
  4593 ////////////////////////////////////////////////////////////////////////////////
  4595 ////////////////////////////////////////////////////////////////////////////////
       
  4596 procedure doStepPlaceStructure(Gear: PGear);
       
  4597 var 
       
  4598     HHGear: PGear;
       
  4599     x, y, tx, ty: hwFloat;
       
  4600 begin
       
  4601     AllInactive := false;
       
  4602 
       
  4603     HHGear := Gear^.Hedgehog^.Gear;
       
  4604     tx := int2hwFloat(TargetPoint.X);
       
  4605     ty := int2hwFloat(TargetPoint.Y);
       
  4606     x := HHGear^.X;
       
  4607     y := HHGear^.Y;
       
  4608 
       
  4609     if (Distance(tx - x, ty - y) > _256) or
       
  4610        not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2,
       
  4611        TargetPoint.Y - SpritesData[sprAmGirder].Height div 2,
       
  4612        sprAmGirder, Gear^.State, true, false) then
       
  4613     begin
       
  4614         PlaySound(sndDenied);
       
  4615         HHGear^.Message := HHGear^.Message and not gmAttack;
       
  4616         HHGear^.State := HHGear^.State and not gstAttacking;
       
  4617         HHGear^.State := HHGear^.State or gstHHChooseTarget;
       
  4618         isCursorVisible := true;
       
  4619         DeleteGear(Gear)
       
  4620     end
       
  4621     else 
       
  4622     begin
       
  4623         PlaySound(sndPlaced);
       
  4624         DeleteGear(Gear);
       
  4625         AfterAttack;
       
  4626     end;
       
  4627 
       
  4628     HHGear^.State := HHGear^.State and not (gstAttacking or gstAttacked);
       
  4629     HHGear^.Message := HHGear^.Message and not gmAttack;
       
  4630     TargetPoint.X := NoPointX
       
  4631 end;
       
  4632 
  4594 procedure doStepStructure(Gear: PGear);
  4633 procedure doStepStructure(Gear: PGear);
  4595 var 
  4634 var 
  4596     i, x, y: LongInt;
  4635     i, x, y: LongInt;
  4597     dX, dY: HWFloat;
  4636     dX, dY: HWFloat;
  4598     hog: PHedgehog;
  4637     hog: PHedgehog;