Show selected weapon again when using it in inf attack mode
authorWuzzy <almikes@aol.com>
Thu, 05 Oct 2017 01:37:49 +0200
changeset 12654 2837dee472cc
parent 12653 c755afd8fb6b
child 12655 eaf719616c7b
Show selected weapon again when using it in inf attack mode This is useful if you have e.g. lots of (finite) bazookas; it's easy to lose track of the amount of remaining bazookas. Not displayed for weapons which always end your turn.
hedgewars/uAmmos.pas
hedgewars/uConsts.pas
hedgewars/uGearsHedgehog.pas
hedgewars/uVariables.pas
--- a/hedgewars/uAmmos.pas	Wed Oct 04 21:33:05 2017 +0200
+++ b/hedgewars/uAmmos.pas	Thu Oct 05 01:37:49 2017 +0200
@@ -378,15 +378,14 @@
 
 procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
 var s: ansistring;
-    CurWeapon: PAmmo;
+    OldWeapon, CurWeapon: PAmmo;
 begin
 TargetPoint.X:= NoPointX;
 
 with Hedgehog do
     begin
-    Timer:= 10;
-
     CurWeapon:= GetCurAmmoEntry(Hedgehog);
+    OldWeapon:= GetCurAmmoEntry(Hedgehog);
 
     if (CurWeapon^.Count = 0) then
         SwitchToFirstLegalAmmo(Hedgehog)
@@ -395,6 +394,10 @@
 
     CurWeapon:= GetCurAmmoEntry(Hedgehog);
 
+    // Weapon selection animation (if new ammo type)
+    if CurWeapon^.AmmoType <> OldWeapon^.AmmoType then
+        Timer:= 10;
+
     ApplyAngleBounds(Hedgehog, CurWeapon^.AmmoType);
 
     with CurWeapon^ do
--- a/hedgewars/uConsts.pas	Wed Oct 04 21:33:05 2017 +0200
+++ b/hedgewars/uConsts.pas	Thu Oct 05 01:37:49 2017 +0200
@@ -307,6 +307,7 @@
                           = $00080000;
     ammoprop_DoesntStopTimerWhileAttackingInInfAttackMode
                           = $00100000;
+    ammoprop_ForceTurnEnd = $00200000;
     ammoprop_NoRoundEnd   = $10000000;
 
     AMMO_INFINITE = 100;
--- a/hedgewars/uGearsHedgehog.pas	Wed Oct 04 21:33:05 2017 +0200
+++ b/hedgewars/uGearsHedgehog.pas	Thu Oct 05 01:37:49 2017 +0200
@@ -576,7 +576,8 @@
                 end;
             if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (HHGear <> nil) then
                 HHGear^.State:= HHGear^.State or gstAttacked;
-            if (Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then
+            if (a = amNothing) or ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) or
+               (((GameFlags and gfInfAttack) <> 0) and ((Ammoz[a].Ammo.Propz and ammoprop_ForceTurnEnd) = 0)) then
                 ApplyAmmoChanges(CurrentHedgehog^)
             end;
         end
--- a/hedgewars/uVariables.pas	Wed Oct 04 21:33:05 2017 +0200
+++ b/hedgewars/uVariables.pas	Thu Oct 05 01:37:49 2017 +0200
@@ -991,7 +991,8 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_NoCrosshair or
                           ammoprop_AttackInMove or
-                          ammoprop_DontHold;
+                          ammoprop_DontHold or
+                          ammoprop_ForceTurnEnd;
                 Count: AMMO_INFINITE;
                 NumPerTurn: 0;
                 Timer: 0;
@@ -1424,7 +1425,8 @@
             Ammo: (Propz: ammoprop_ForwMsgs or
                           ammoprop_DontHold or
                           ammoprop_NeedUpDown or
-                          ammoprop_AttackInMove;
+                          ammoprop_AttackInMove or
+                          ammoprop_ForceTurnEnd;
                 Count: 1;
                 NumPerTurn: 0;
                 Timer: 0;
@@ -1978,7 +1980,8 @@
                             ammoprop_NeedTarget or
                             ammoprop_AttackingPut or
                             ammoprop_DontHold or
-                            ammoprop_NotBorder;
+                            ammoprop_NotBorder or
+                            ammoprop_ForceTurnEnd;
                 Count: 1;
                 NumPerTurn: 0;
                 Timer: 0;
@@ -2216,7 +2219,8 @@
             Ammo: (Propz: ammoprop_ForwMsgs or
                           ammoprop_NoCrosshair or
                           ammoprop_Utility or
-                          ammoprop_DontHold;
+                          ammoprop_DontHold or
+                          ammoprop_ForceTurnEnd;
                 Count: 2;
                 NumPerTurn: 0;
                 Timer: 0;