hedgewars/uGearsHandlersMess.pas
changeset 15229 f16376e9374f
parent 15227 deaa316af414
child 15230 ebbc2f04b863
equal deleted inserted replaced
15228:32678e65b25e 15229:f16376e9374f
  3070     AllInactive := false;
  3070     AllInactive := false;
  3071     Gear^.X := Gear^.X + cAirPlaneSpeed * Gear^.Tag;
  3071     Gear^.X := Gear^.X + cAirPlaneSpeed * Gear^.Tag;
  3072     if (Gear^.Health > 0) and (not (Gear^.X < Gear^.dX)) and (Gear^.X < Gear^.dX + cAirPlaneSpeed) then
  3072     if (Gear^.Health > 0) and (not (Gear^.X < Gear^.dX)) and (Gear^.X < Gear^.dX + cAirPlaneSpeed) then
  3073         begin
  3073         begin
  3074         dec(Gear^.Health);
  3074         dec(Gear^.Health);
  3075         if (WorldEdge = weBounce) and (((Gear^.Tag = 1) and (hwRound(Gear^.X) > rightX)) or ((Gear^.Tag = -1) and (hwRound(Gear^.X) < leftX))) then
  3075         // Spawn missile
  3076             begin
  3076         case Gear^.State of
  3077             // Don't spawn missile if it would end up inside bounce world edge of the opposite side
  3077             0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
  3078             PlaySound(sndVaporize);
  3078             1: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine,    0, cBombsSpeed * Gear^.Tag, _0, 0);
  3079             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmoke);
  3079             2: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtNapalmBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
  3080             end
  3080             3: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtDrill, gsttmpFlag, cBombsSpeed * Gear^.Tag, _0, Gear^.Timer + 1);
  3081         else
  3081         end;
  3082             begin
  3082         Gear^.dX := Gear^.dX + int2hwFloat(Gear^.Damage * Gear^.Tag);
  3083             // Spawn missile
  3083         if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
  3084             case Gear^.State of
  3084             FollowGear^.State:= FollowGear^.State or gstSubmersible;
  3085                 0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
       
  3086                 1: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine,    0, cBombsSpeed * Gear^.Tag, _0, 0);
       
  3087                 2: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtNapalmBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
       
  3088                 3: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtDrill, gsttmpFlag, cBombsSpeed * Gear^.Tag, _0, Gear^.Timer + 1);
       
  3089             end;
       
  3090             Gear^.dX := Gear^.dX + int2hwFloat(Gear^.Damage * Gear^.Tag);
       
  3091             if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
       
  3092                 FollowGear^.State:= FollowGear^.State or gstSubmersible;
       
  3093             end;
       
  3094         StopSoundChan(Gear^.SoundChannel, 4000);
  3085         StopSoundChan(Gear^.SoundChannel, 4000);
  3095         end;
  3086         end;
  3096 
  3087 
  3097     if (GameTicks and $3F) = 0 then
  3088     if (GameTicks and $3F) = 0 then
  3098         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  3089         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  3104         DeleteGear(Gear)
  3095         DeleteGear(Gear)
  3105         end
  3096         end
  3106 end;
  3097 end;
  3107 
  3098 
  3108 procedure doStepAirAttack(Gear: PGear);
  3099 procedure doStepAirAttack(Gear: PGear);
  3109 var valid: boolean;
  3100 var HHGear: PGear;
  3110     HHGear: PGear;
       
  3111 begin
  3101 begin
  3112     AllInactive := false;
  3102     AllInactive := false;
  3113 
       
  3114     valid:= true;
       
  3115     // Bounce world edge restrictions ...
       
  3116     if (WorldEdge = weBounce) then
       
  3117         // If plane flies right, deny placement inside the right bounce side
       
  3118         if (Gear^.X.QWordValue = 0) and (Gear^.Target.X > rightX) then
       
  3119             valid:= false
       
  3120         // If plane flies left, deny placement inside the left bounce side
       
  3121         else if (Gear^.X.QWordValue <> 0) and (Gear^.Target.X < leftX) then
       
  3122             valid:= false
       
  3123         // Deny placement of high targets. This serves as a buffer to further
       
  3124         // reduce potentially weird bouncy gear behaviour
       
  3125         else if (Gear^.Target.Y < (topY - 50)) then
       
  3126             valid:= false;
       
  3127 
  3103 
  3128     if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) then
  3104     if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) then
  3129         HHGear:= Gear^.Hedgehog^.Gear;
  3105         HHGear:= Gear^.Hedgehog^.Gear;
  3130 
       
  3131     if (not valid) then
       
  3132         begin
       
  3133         if (HHGear <> nil) then
       
  3134             begin
       
  3135             HHGear^.Message := HHGear^.Message and (not gmAttack);
       
  3136             HHGear^.State := HHGear^.State and (not gstAttacking);
       
  3137             HHGear^.State := HHGear^.State or gstChooseTarget;
       
  3138             isCursorVisible := true;
       
  3139             end;
       
  3140         DeleteGear(Gear);
       
  3141         PlaySound(sndDenied);
       
  3142         exit;
       
  3143         end;
       
  3144 
  3106 
  3145     if (HHGear <> nil) then
  3107     if (HHGear <> nil) then
  3146         PlaySoundV(sndIncoming, Gear^.Hedgehog^.Team^.voicepack);
  3108         PlaySoundV(sndIncoming, Gear^.Hedgehog^.Team^.voicepack);
  3147     AfterAttack;
  3109     AfterAttack;
  3148     CurAmmoGear := nil;
  3110     CurAmmoGear := nil;