Deny air attack in bounce world edge if target is in "impossible" position
authorWuzzy <Wuzzy2@mail.ru>
Sun, 13 Jan 2019 17:02:15 +0100
changeset 14565 833ab5b359e5
parent 14564 599f136d4f32
child 14566 85921db6f7c3
Deny air attack in bounce world edge if target is in "impossible" position
hedgewars/uGearsHandlersMess.pas
hedgewars/uVariables.pas
--- a/hedgewars/uGearsHandlersMess.pas	Sun Jan 13 15:54:10 2019 +0100
+++ b/hedgewars/uGearsHandlersMess.pas	Sun Jan 13 17:02:15 2019 +0100
@@ -3044,9 +3044,42 @@
 end;
 
 procedure doStepAirAttack(Gear: PGear);
+var valid: boolean;
+    HHGear: PGear;
+    planeY: LongInt;
 begin
     AllInactive := false;
 
+    planeY:= topY - 300;
+    valid:= true;
+    if (WorldEdge = weBounce) then
+        if (Gear^.X.QWordValue = 0) and (Gear^.Target.X > rightX) then
+            valid:= false
+        else if (Gear^.X.QWordValue <> 0) and (Gear^.Target.X < leftX) then
+            valid:= false
+        else if (Gear^.Target.Y < planeY) then
+            valid:= false;
+
+    if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) then
+        HHGear:= Gear^.Hedgehog^.Gear;
+
+    if (not valid) then
+        begin
+        if (HHGear <> nil) then
+            begin
+            HHGear^.Message := HHGear^.Message and (not gmAttack);
+            HHGear^.State := HHGear^.State and (not gstAttacking);
+            HHGear^.State := HHGear^.State or gstChooseTarget;
+            isCursorVisible := true;
+            end;
+        DeleteGear(Gear);
+        PlaySound(sndDenied);
+        exit;
+        end;
+
+    if (HHGear <> nil) then
+        PlaySoundV(sndIncoming, Gear^.Hedgehog^.Team^.voicepack);
+
     if Gear^.X.QWordValue = 0 then
         begin
         Gear^.Tag :=  1;
@@ -3058,7 +3091,7 @@
         Gear^.X := int2hwFloat(max(LAND_WIDTH,4096) + 2048);
         end;
 
-    Gear^.Y := int2hwFloat(topY-300);
+    Gear^.Y := int2hwFloat(planeY);
     Gear^.dX := int2hwFloat(Gear^.Target.X) - int2hwFloat(Gear^.Tag * (Gear^.Health-1) * Gear^.Damage) / 2;
 
     // calcs for Napalm Strike, so that it will hit the target (without wind at least :P)
--- a/hedgewars/uVariables.pas	Sun Jan 13 15:54:10 2019 +0100
+++ b/hedgewars/uVariables.pas	Sun Jan 13 17:02:15 2019 +0100
@@ -1290,7 +1290,7 @@
                 Timer: 0;
                 Pos: 0;
                 AmmoType: amAirAttack;
-                AttackVoice: sndIncoming;
+                AttackVoice: sndNone; // handled in doStepAirAttack
                 Bounciness: defaultBounciness);
             Slot: 5;
             TimeAfterTurn: 0;
@@ -1318,7 +1318,7 @@
                 Timer: 0;
                 Pos: 0;
                 AmmoType: amMineStrike;
-                AttackVoice: sndIncoming;
+                AttackVoice: sndNone; // handled in doStepAirAttack
                 Bounciness: defaultBounciness);
             Slot: 5;
             TimeAfterTurn: 0;
@@ -1615,7 +1615,7 @@
                 Timer: 0;
                 Pos: 0;
                 AmmoType: amNapalm;
-                AttackVoice: sndIncoming;
+                AttackVoice: sndNone; // handled in doStepAirAttack
                 Bounciness: defaultBounciness);
             Slot: 5;
             TimeAfterTurn: 0;
@@ -2222,7 +2222,7 @@
                 Timer: 5000;
                 Pos: 0;
                 AmmoType: amDrillStrike;
-                AttackVoice: sndIncoming;
+                AttackVoice: sndNone; // handled in doStepAirAttack
                 Bounciness: defaultBounciness);
             Slot: 5;
             TimeAfterTurn: 0;