hedgewars/uGearsHandlersMess.pas
changeset 14573 e26fa5ea2bf6
parent 14572 5de4d470dafe
child 14575 0da43a3d5500
equal deleted inserted replaced
14572:5de4d470dafe 14573:e26fa5ea2bf6
  3017     Gear^.X := Gear^.X + cAirPlaneSpeed * Gear^.Tag;
  3017     Gear^.X := Gear^.X + cAirPlaneSpeed * Gear^.Tag;
  3018 
  3018 
  3019     if (Gear^.Health > 0) and (not (Gear^.X < Gear^.dX)) and (Gear^.X < Gear^.dX + cAirPlaneSpeed) then
  3019     if (Gear^.Health > 0) and (not (Gear^.X < Gear^.dX)) and (Gear^.X < Gear^.dX + cAirPlaneSpeed) then
  3020         begin
  3020         begin
  3021         dec(Gear^.Health);
  3021         dec(Gear^.Health);
       
  3022         if (WorldEdge = weBounce) and (((Gear^.Tag = 1) and (hwRound(Gear^.X) > rightX)) or ((Gear^.Tag = -1) and (hwRound(Gear^.X) < leftX))) then
       
  3023             begin
       
  3024             // Don't spawn missile if it would end up inside bounce world edge of the opposite side
       
  3025             PlaySound(sndVaporize);
       
  3026             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmoke);
       
  3027             end
       
  3028         else
       
  3029             begin
       
  3030             // Spawn missile
  3022             case Gear^.State of
  3031             case Gear^.State of
  3023                 0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
  3032                 0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
  3024                 1: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine,    0, cBombsSpeed * Gear^.Tag, _0, 0);
  3033                 1: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine,    0, cBombsSpeed * Gear^.Tag, _0, 0);
  3025                 2: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtNapalmBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
  3034                 2: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtNapalmBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
  3026                 3: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtDrill, gsttmpFlag, cBombsSpeed * Gear^.Tag, _0, Gear^.Timer + 1);
  3035                 3: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtDrill, gsttmpFlag, cBombsSpeed * Gear^.Tag, _0, Gear^.Timer + 1);
  3027             //4: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtWaterMelon, 0, cBombsSpeed *
  3036             //4: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtWaterMelon, 0, cBombsSpeed *
  3028             //                 Gear^.Tag, _0, 5000);
  3037             //                 Gear^.Tag, _0, 5000);
  3029             end;
  3038             end;
  3030         Gear^.dX := Gear^.dX + int2hwFloat(Gear^.Damage * Gear^.Tag);
  3039             Gear^.dX := Gear^.dX + int2hwFloat(Gear^.Damage * Gear^.Tag);
  3031         if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
  3040             if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
  3032             FollowGear^.State:= FollowGear^.State or gstSubmersible;
  3041                 FollowGear^.State:= FollowGear^.State or gstSubmersible;
       
  3042             end;
  3033         StopSoundChan(Gear^.SoundChannel, 4000);
  3043         StopSoundChan(Gear^.SoundChannel, 4000);
  3034         end;
  3044         end;
  3035 
  3045 
  3036     if (GameTicks and $3F) = 0 then
  3046     if (GameTicks and $3F) = 0 then
  3037         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  3047         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  3049     HHGear: PGear;
  3059     HHGear: PGear;
  3050 begin
  3060 begin
  3051     AllInactive := false;
  3061     AllInactive := false;
  3052 
  3062 
  3053     valid:= true;
  3063     valid:= true;
       
  3064     // Bounce world edge restrictions ...
  3054     if (WorldEdge = weBounce) then
  3065     if (WorldEdge = weBounce) then
       
  3066         // If plane flies right, deny placement inside the right bounce side
  3055         if (Gear^.X.QWordValue = 0) and (Gear^.Target.X > rightX) then
  3067         if (Gear^.X.QWordValue = 0) and (Gear^.Target.X > rightX) then
  3056             valid:= false
  3068             valid:= false
       
  3069         // If plane flies left, deny placement inside the left bounce side
  3057         else if (Gear^.X.QWordValue <> 0) and (Gear^.Target.X < leftX) then
  3070         else if (Gear^.X.QWordValue <> 0) and (Gear^.Target.X < leftX) then
  3058             valid:= false
  3071             valid:= false
       
  3072         // Deny placement of high targets. This serves as a buffer to further
       
  3073         // reduce potentially weird bouncy gear behaviour
  3059         else if (Gear^.Target.Y < (topY - 50)) then
  3074         else if (Gear^.Target.Y < (topY - 50)) then
  3060             valid:= false;
  3075             valid:= false;
  3061 
  3076 
  3062     if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) then
  3077     if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) then
  3063         HHGear:= Gear^.Hedgehog^.Gear;
  3078         HHGear:= Gear^.Hedgehog^.Gear;