hedgewars/uGearsHandlersMess.pas
changeset 10251 a3b42e81803c
parent 10234 a3a200e35c6e
child 10253 ea57f2f2b98d
equal deleted inserted replaced
10250:887610b44848 10251:a3b42e81803c
  2500 var
  2500 var
  2501     HHGear: PGear;
  2501     HHGear: PGear;
  2502     x, y, tx, ty: hwFloat;
  2502     x, y, tx, ty: hwFloat;
  2503     rx: LongInt;
  2503     rx: LongInt;
  2504     LandFlags: Word;
  2504     LandFlags: Word;
       
  2505     warn: PVisualGear;
       
  2506     distFail: boolean;
  2505 begin
  2507 begin
  2506     AllInactive := false;
  2508     AllInactive := false;
  2507 
  2509 
  2508     HHGear := Gear^.Hedgehog^.Gear;
  2510     HHGear := Gear^.Hedgehog^.Gear;
  2509     tx := int2hwFloat(Gear^.Target.X);
  2511     tx := int2hwFloat(Gear^.Target.X);
  2514 
  2516 
  2515     LandFlags:= 0;
  2517     LandFlags:= 0;
  2516     if Gear^.AmmoType = amRubber then LandFlags:= lfBouncy
  2518     if Gear^.AmmoType = amRubber then LandFlags:= lfBouncy
  2517     else if cIce then LandFlags:= lfIce;
  2519     else if cIce then LandFlags:= lfIce;
  2518 
  2520 
  2519     if ((Distance(tx - x, ty - y) > _256) and ((WorldEdge <> weWrap) or
  2521     distFail:= ((Distance(tx - x, ty - y) > _256) and ((WorldEdge <> weWrap) or
  2520             (
  2522             (
  2521             (Distance(tx - int2hwFloat(rightX+(rx-leftX)), ty - y) > _256) and
  2523             (Distance(tx - int2hwFloat(rightX+(rx-leftX)), ty - y) > _256) and
  2522             (Distance(tx - int2hwFloat(leftX-(rightX-rx)), ty - y) > _256)
  2524             (Distance(tx - int2hwFloat(leftX-(rightX-rx)), ty - y) > _256)
  2523             )))
  2525             )));
       
  2526     if distFail
  2524     or (not TryPlaceOnLand(Gear^.Target.X - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Width div 2, Gear^.Target.Y - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Height div 2, Ammoz[Gear^.AmmoType].PosSprite, Gear^.State, true, false, LandFlags)) then
  2527     or (not TryPlaceOnLand(Gear^.Target.X - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Width div 2, Gear^.Target.Y - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Height div 2, Ammoz[Gear^.AmmoType].PosSprite, Gear^.State, true, false, LandFlags)) then
  2525         begin
  2528         begin
  2526         PlaySound(sndDenied);
  2529         PlaySound(sndDenied);
       
  2530         if not distFail then
       
  2531             begin
       
  2532             warn:= AddVisualGear(Gear^.Target.X, Gear^.Target.Y, vgtNoPlaceWarn, 0);
       
  2533             if warn <> nil then
       
  2534                 warn^.Tex := GetPlaceCollisionTex(Gear^.Target.X - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Width div 2, Gear^.Target.Y - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Height div 2, Ammoz[Gear^.AmmoType].PosSprite, Gear^.State);
       
  2535             end;
  2527         HHGear^.Message := HHGear^.Message and (not gmAttack);
  2536         HHGear^.Message := HHGear^.Message and (not gmAttack);
  2528         HHGear^.State := HHGear^.State and (not gstAttacking);
  2537         HHGear^.State := HHGear^.State and (not gstAttacking);
  2529         HHGear^.State := HHGear^.State or gstHHChooseTarget;
  2538         HHGear^.State := HHGear^.State or gstHHChooseTarget;
  2530         isCursorVisible := true;
  2539         isCursorVisible := true;
  2531         DeleteGear(Gear)
  2540         DeleteGear(Gear)