- Switch to bazooka (or whatever) after use of some weapon (fixes problem with bots)
authorunc0rr
Sun, 08 Jul 2007 17:16:46 +0000
changeset 553 5478386d935f
parent 552 2167020d3bc0
child 554 4f83b3de17c7
- Switch to bazooka (or whatever) after use of some weapon (fixes problem with bots) - Decrease frequency of case spawning - Small fixes
hedgewars/HHHandlers.inc
hedgewars/uAI.pas
hedgewars/uAmmos.pas
hedgewars/uConsts.pas
hedgewars/uMisc.pas
hedgewars/uTeams.pas
--- a/hedgewars/HHHandlers.inc	Tue Jul 03 20:11:48 2007 +0000
+++ b/hedgewars/HHHandlers.inc	Sun Jul 08 17:16:46 2007 +0000
@@ -113,7 +113,7 @@
 case Gear^.Pos of
        posCaseAmmo: begin
                     a:= TAmmoType(Gear^.State);
-                    AddAmmo(PHedgehog(HH^.Hedgehog), a);
+                    AddAmmo(PHedgehog(HH^.Hedgehog)^, a);
                     s:= trammo[Ammoz[a].NameId] + '(+' + IntToStr(Ammoz[a].NumberInCase) + ')';
                     AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Clan^.Color, capgrpAmmoinfo);
                     end;
--- a/hedgewars/uAI.pas	Tue Jul 03 20:11:48 2007 +0000
+++ b/hedgewars/uAI.pas	Sun Jul 08 17:16:46 2007 +0000
@@ -308,7 +308,7 @@
    end;
 FillBonuses((Me^.State and gstAttacked) <> 0);
 for a:= Low(TAmmoType) to High(TAmmoType) do
-    CanUseAmmo[a]:= Assigned(AmmoTests[a].proc) and HHHasAmmo(PHedgehog(Me^.Hedgehog), a);
+    CanUseAmmo[a]:= Assigned(AmmoTests[a].proc) and HHHasAmmo(PHedgehog(Me^.Hedgehog)^, a);
 {$IFDEF DEBUGFILE}AddFileLog('Enter Think Thread');{$ENDIF}
 BeginThread(@Think, Me, ThinkThread)
 end;
--- a/hedgewars/uAmmos.pas	Tue Jul 03 20:11:48 2007 +0000
+++ b/hedgewars/uAmmos.pas	Sun Jul 08 17:16:46 2007 +0000
@@ -23,13 +23,15 @@
 
 procedure AddAmmoStore(s: shortstring);
 procedure AssignStores;
-procedure AddAmmo(Hedgehog: pointer; ammo: TAmmoType);
-function  HHHasAmmo(Hedgehog: pointer; Ammo: TAmmoType): boolean;
+procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
+function  HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): boolean;
 procedure PackAmmo(Ammo: PHHAmmo; Slot: LongInt);
 procedure OnUsedAmmo(var Hedgehog: THedgehog);
+procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
+procedure SwitchNotHoldedAmmo(var Hedgehog: THedgehog);
 
 implementation
-uses uMisc, uGears;
+uses uMisc, uGears, uWorld, uLocale;
 type TAmmoCounts = array[TAmmoType] of Longword;
 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
     StoreCnt: Longword = 0;
@@ -91,13 +93,13 @@
       end
 end;
 
-procedure AddAmmo(Hedgehog: pointer; ammo: TAmmoType);
+procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
 var ammos: TAmmoCounts;
     slot, ami: LongInt;
     hhammo: PHHAmmo;
 begin
 FillChar(ammos, sizeof(ammos), 0);
-hhammo:= PHedgehog(Hedgehog)^.Ammo;
+hhammo:= Hedgehog.Ammo;
 
 for slot:= 0 to cMaxSlotIndex do
     for ami:= 0 to cMaxSlotAmmoIndex do
@@ -118,7 +120,7 @@
       while (not b) and (ami < cMaxSlotAmmoIndex) do
           if (Ammo^[Slot, ami].Count = 0)
              and (Ammo^[Slot, ami + 1].Count > 0) then b:= true
-                                                 else inc(ami);
+                                                  else inc(ami);
       if b then // there's a free item in ammo stack
          begin
          Ammo^[Slot, ami]:= Ammo^[Slot, ami + 1];
@@ -143,18 +145,73 @@
      end
 end;
 
-function  HHHasAmmo(Hedgehog: pointer; Ammo: TAmmoType): boolean;
+function  HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): boolean;
 var slot, ami: LongInt;
 begin
 Slot:= Ammoz[Ammo].Slot;
 ami:= 0;
 while (ami <= cMaxSlotAmmoIndex) do
       begin
-      with PHedgehog(Hedgehog)^.Ammo^[Slot, ami] do
+      with Hedgehog.Ammo^[Slot, ami] do
             if (AmmoType = Ammo) and (Count > 0) then exit(true);
       inc(ami)
       end;
 HHHasAmmo:= false
 end;
 
+procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
+var s: shortstring;
+begin
+TargetPoint.X:= NoPointX;
+
+with Hedgehog do
+     begin
+     if (Ammo^[CurSlot, CurAmmo].Count = 0)then
+        begin
+        CurAmmo:= 0;
+        CurSlot:= 0;
+        while (CurSlot <= cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do inc(CurSlot)
+        end;
+
+with Ammo^[CurSlot, CurAmmo] do
+     begin
+     CurMinAngle:= Ammoz[AmmoType].minAngle;
+     if Ammoz[AmmoType].maxAngle <> 0 then CurMaxAngle:= Ammoz[AmmoType].maxAngle
+                                      else CurMaxAngle:= cMaxAngle;
+     with Hedgehog.Gear^ do
+        begin
+        if Angle < CurMinAngle then Angle:= CurMinAngle;
+        if Angle > CurMaxAngle then Angle:= CurMaxAngle;
+        end;
+
+     s:= trammo[Ammoz[AmmoType].NameId];
+     if Count <> AMMO_INFINITE then
+        s:= s + ' (' + IntToStr(Count) + ')';
+     if (Propz and ammoprop_Timerable) <> 0 then
+        s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds];
+     AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
+     if (Propz and ammoprop_NeedTarget) <> 0
+        then begin
+        Gear^.State:= Gear^.State or      gstHHChooseTarget;
+        isCursorVisible:= true
+        end else begin
+        Gear^.State:= Gear^.State and not gstHHChooseTarget;
+        isCursorVisible:= false
+        end;
+     ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0
+     end
+     end
+end;
+
+procedure SwitchNotHoldedAmmo(var Hedgehog: THedgehog);
+begin
+with Hedgehog do
+     if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_DontHold) <> 0 then
+        begin
+        CurAmmo:= 0;
+        CurSlot:= 0;
+        while (CurSlot <= cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do inc(CurSlot)
+        end
+end;
+
 end.
--- a/hedgewars/uConsts.pas	Tue Jul 03 20:11:48 2007 +0000
+++ b/hedgewars/uConsts.pas	Sun Jul 08 17:16:46 2007 +0000
@@ -173,6 +173,7 @@
       ammoprop_AttackInMove = $00000010;
       ammoprop_NoCrosshair  = $00000040;
       ammoprop_AttackingPut = $00000080;
+      ammoprop_DontHold     = $00000100;
       AMMO_INFINITE = High(LongWord);
 
       EXPLAllDamageInRadius = $00000001;
@@ -408,7 +409,8 @@
                                    Probability: 100;
                                    NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_Power or
-                                                 ammoprop_NeedTarget;
+                                                 ammoprop_NeedTarget or
+                                                 ammoprop_DontHold;
                                           Count: 2;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -440,7 +442,8 @@
                                    NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_ForwMsgs or
                                                  ammoprop_AttackInMove or
-                                                 ammoprop_NoCrosshair;
+                                                 ammoprop_NoCrosshair or
+                                                 ammoprop_DontHold;
                                           Count: 2;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -455,7 +458,7 @@
                                   (NameId: sidSkip;
                                    Probability: 0;
                                    NumberInCase: 1;
-                                   Ammo: (Propz: 0;
+                                   Ammo: (Propz: ammoprop_DontHold;
                                           Count: AMMO_INFINITE;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -471,7 +474,8 @@
                                    Probability: 100;
                                    NumberInCase: 3;
                                    Ammo: (Propz: ammoprop_ForwMsgs or
-                                                 ammoprop_AttackInMove;
+                                                 ammoprop_AttackInMove or
+                                                 ammoprop_DontHold;
                                           Count: 5;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -486,7 +490,8 @@
                                   (NameId: sidMine;
                                    Probability: 100;
                                    NumberInCase: 1;
-                                   Ammo: (Propz: ammoprop_NoCrosshair;
+                                   Ammo: (Propz: ammoprop_NoCrosshair or
+                                                 ammoprop_DontHold;
                                           Count: 2;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -517,7 +522,8 @@
                                    Probability: 100;
                                    NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_NoCrosshair or
-                                                 ammoprop_AttackInMove;
+                                                 ammoprop_AttackInMove or
+                                                 ammoprop_DontHold;
                                           Count: 1;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -549,7 +555,7 @@
                                   (NameId: sidBaseballBat;
                                    Probability: 100;
                                    NumberInCase: 1;
-                                   Ammo: (Propz: 0;
+                                   Ammo: (Propz: ammoprop_DontHold;
                                           Count: 1;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -566,7 +572,8 @@
                                    NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_ForwMsgs or
                                                  ammoprop_AttackInMove or
-                                                 ammoprop_NoCrosshair;
+                                                 ammoprop_NoCrosshair or
+                                                 ammoprop_DontHold;
                                           Count: 2;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -583,7 +590,8 @@
                                    NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_NoCrosshair or
                                                  ammoprop_NeedTarget or
-                                                 ammoprop_AttackingPut;
+                                                 ammoprop_AttackingPut or
+                                                 ammoprop_DontHold;
                                           Count: 1;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -600,7 +608,8 @@
                                    NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_NoCrosshair or
                                                  ammoprop_NeedTarget or
-                                                 ammoprop_AttackingPut;
+                                                 ammoprop_AttackingPut or
+                                                 ammoprop_DontHold;
                                           Count: 1;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -632,7 +641,8 @@
                                    NumberInCase: 3;
                                    Ammo: (Propz: ammoprop_NoCrosshair or
                                                  ammoprop_NeedTarget or
-                                                 ammoprop_AttackingPut;
+                                                 ammoprop_AttackingPut or
+                                                 ammoprop_DontHold;
                                           Count: 1;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -650,7 +660,8 @@
                                    Ammo: (Propz: ammoprop_ForwMsgs or
                                                  ammoprop_NoCrosshair or
                                                  ammoprop_NeedTarget or
-                                                 ammoprop_AttackingPut;
+                                                 ammoprop_AttackingPut or
+                                                 ammoprop_DontHold;
                                           Count: 2;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -666,7 +677,8 @@
                                    Probability: 100;
                                    NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_ForwMsgs or
-                                                 ammoprop_NoCrosshair;
+                                                 ammoprop_NoCrosshair or
+                                                 ammoprop_DontHold;
                                           Count: 3;
                                           NumPerTurn: 0;
                                           Timer: 0;
--- a/hedgewars/uMisc.pas	Tue Jul 03 20:11:48 2007 +0000
+++ b/hedgewars/uMisc.pas	Sun Jul 08 17:16:46 2007 +0000
@@ -61,7 +61,7 @@
     cExplosionBorderColor : LongWord = $808080;
 
     cShowFPS      : boolean = true;
-    cCaseFactor   : Longword = 3;  {1..10}
+    cCaseFactor   : Longword = 7;  {1..10}
     cFullScreen   : boolean = true;
     cLocaleFName  : shortstring = 'en.txt';
     cSeed         : shortstring = '';
@@ -211,7 +211,7 @@
 
 procedure SetLittle(var r: hwFloat);
 begin
-if not r.isNegative then r:= cLittle else r:= - cLittle
+r:= SignAs(cLittle, r)
 end;
 
 procedure SendStat(sit: TStatInfoType; s: shortstring);
--- a/hedgewars/uTeams.pas	Tue Jul 03 20:11:48 2007 +0000
+++ b/hedgewars/uTeams.pas	Sun Jul 08 17:16:46 2007 +0000
@@ -77,7 +77,6 @@
     CurMinAngle, CurMaxAngle: Longword;
 
 function AddTeam(TeamColor: Longword): PTeam;
-procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
 procedure SwitchHedgehog;
 procedure InitTeams;
 function  TeamSize(p: PTeam): Longword;
@@ -147,6 +146,7 @@
         AttacksNum:= 0;
         Gear^.Message:= 0;
         Gear^.Z:= cHHZ;
+        SwitchNotHoldedAmmo(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]);
         RemoveGearFromList(Gear);
         InsertGearToList(Gear)
         end;
@@ -268,50 +268,6 @@
 RecountAllTeamsHealth
 end;
 
-procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
-var s: shortstring;
-begin
-TargetPoint.X:= NoPointX;
-
-with Hedgehog do
-     begin
-     if Ammo^[CurSlot, CurAmmo].Count = 0 then
-        begin
-        CurAmmo:= 0;
-        CurSlot:= 0;
-        while (CurSlot <= cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do inc(CurSlot)
-        end;
-
-with Ammo^[CurSlot, CurAmmo] do
-     begin
-     CurMinAngle:= Ammoz[AmmoType].minAngle;
-     if Ammoz[AmmoType].maxAngle <> 0 then CurMaxAngle:= Ammoz[AmmoType].maxAngle
-                                      else CurMaxAngle:= cMaxAngle;
-     with Hedgehog.Gear^ do
-        begin
-        if Angle < CurMinAngle then Angle:= CurMinAngle;
-        if Angle > CurMaxAngle then Angle:= CurMaxAngle;
-        end;
-
-     s:= trammo[Ammoz[AmmoType].NameId];
-     if Count <> AMMO_INFINITE then
-        s:= s + ' (' + IntToStr(Count) + ')';
-     if (Propz and ammoprop_Timerable) <> 0 then
-        s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds];
-     AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
-     if (Propz and ammoprop_NeedTarget) <> 0
-        then begin
-        Gear^.State:= Gear^.State or      gstHHChooseTarget;
-        isCursorVisible:= true
-        end else begin
-        Gear^.State:= Gear^.State and not gstHHChooseTarget;
-        isCursorVisible:= false
-        end;
-     ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0
-     end
-     end
-end;
-
 function  TeamSize(p: PTeam): Longword;
 var i, Result: Longword;
 begin