This should make bee and other targetted things behave more reliably in infinite attack mode. Blocks switching of weps if a target point is active.
authornemo
Fri, 05 Nov 2010 17:27:14 -0400
changeset 4135 5be798ecafdc
parent 4134 3dc32c1fb97b
child 4136 5fe9235e02d8
This should make bee and other targetted things behave more reliably in infinite attack mode. Blocks switching of weps if a target point is active.
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uMisc.pas
--- a/hedgewars/GSHandlers.inc	Fri Nov 05 15:37:36 2010 -0400
+++ b/hedgewars/GSHandlers.inc	Fri Nov 05 17:27:14 2010 -0400
@@ -618,6 +618,10 @@
     dec(Gear^.Timer);
     if Gear^.Timer = 0 then
     begin
+        PHedgehog(Gear^.Hedgehog)^.Gear^.Message:= PHedgehog(Gear^.Hedgehog)^.Gear^.Message and not gmAttack;
+        PHedgehog(Gear^.Hedgehog)^.Gear^.State:= PHedgehog(Gear^.Hedgehog)^.Gear^.State and not gstAttacking;
+        AttackBar:= 0;
+        
         Gear^.SoundChannel := LoopSound(sndBee);
         Gear^.Timer := 5000;
         // save initial speed in otherwise unused Friction variable
--- a/hedgewars/HHHandlers.inc	Fri Nov 05 15:37:36 2010 -0400
+++ b/hedgewars/HHHandlers.inc	Fri Nov 05 17:27:14 2010 -0400
@@ -41,21 +41,24 @@
 end;
 
 // Shouldn't more of this ammo switching stuff be moved to uAmmos ?
-procedure ChangeAmmo(Gear: PGear);
+function ChangeAmmo(Gear: PGear): boolean;
 var slot, i: Longword;
     ammoidx: LongInt;
 begin
+ChangeAmmo:= false;
 slot:= Gear^.MsgParam;
 
 with PHedgehog(Gear^.Hedgehog)^ do
     begin
     Gear^.Message:= Gear^.Message and not gmSlot;
     ammoidx:= 0;
-    while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> CurAmmoType) do inc(ammoidx);
-
     if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or
+       (TargetPoint.X <> NoPointX) or
        ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEndHint) = 0)) or
        ((Gear^.State and gstHHDriven) = 0) then exit;
+    ChangeAmmo:= true;
+
+    while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> CurAmmoType) do inc(ammoidx);
 
     if ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEndHint) <> 0) and (MultiShootAttacks > 0) then OnUsedAmmo(PHedgehog(Gear^.Hedgehog)^);
 
@@ -95,6 +98,7 @@
 var t: LongInt;
     weap: TAmmoType;
     Hedgehog: PHedgehog;
+    s: boolean;
 begin
 weap:= TAmmoType(Gear^.MsgParam);
 Hedgehog:= PHedgehog(Gear^.Hedgehog);
@@ -110,11 +114,11 @@
 with Hedgehog^ do
     while (CurAmmoType <> weap) and (t >= 0) do
         begin
-        ChangeAmmo(Gear);
+        s:= ChangeAmmo(Gear);
         dec(t)
         end;
 
-ApplyAmmoChanges(PHedgehog(Gear^.Hedgehog)^)
+if s then ApplyAmmoChanges(PHedgehog(Gear^.Hedgehog)^)
 end;
 
 procedure HHSetTimer(Gear: PGear);
@@ -794,10 +798,7 @@
     or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEndHint) <> 0) then
     begin
     if ((Gear^.Message and gmSlot) <> 0) then
-        begin
-        ChangeAmmo(Gear);
-        ApplyAmmoChanges(Hedgehog^)
-        end;
+        if ChangeAmmo(Gear) then ApplyAmmoChanges(Hedgehog^);
 
     if ((Gear^.Message and gmWeapon) <> 0) then HHSetWeapon(Gear);
 
--- a/hedgewars/uMisc.pas	Fri Nov 05 15:37:36 2010 -0400
+++ b/hedgewars/uMisc.pas	Fri Nov 05 17:27:14 2010 -0400
@@ -763,7 +763,7 @@
     KBnum           := 0;
     InitStepsFlags  := 0;
     RealTicks       := 0;
-    AttackBar       := 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP
+    AttackBar       := 0; // 0 - none, 1 - just bar at the right-down corner, 2 - from weapon
     cCaseFactor     := 5;  {0..9}
     cLandMines      := 4;
     cExplosives     := 2;