- Implement hack to let ammo stores work without needed assistance of frontend
authorunc0rr
Mon, 05 Feb 2007 20:26:13 +0000
changeset 394 4c017ae1226a
parent 393 db01cc79f278
child 395 641ed71c7c93
- Implement hack to let ammo stores work without needed assistance of frontend - Ammo case can now contain other weapons besides Mine Strike
hedgewars/CCHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/hwengine.dpr
hedgewars/uAmmos.pas
hedgewars/uConsts.pas
hedgewars/uGears.pas
--- a/hedgewars/CCHandlers.inc	Mon Feb 05 19:33:24 2007 +0000
+++ b/hedgewars/CCHandlers.inc	Mon Feb 05 20:26:13 2007 +0000
@@ -46,12 +46,14 @@
    end
 end;
 
+const TeamsCount: Longword = 0;
+
 procedure chAddTeam(var s: shortstring);
-const TeamsCount: Longword = 0;
 begin
 if isDeveloperMode then
    begin
    inc(TeamsCount);
+   ParseCommand('ammstore 93919294221912103', true);
    TryDo(TeamsCount <= 5, 'Too many teams', true);
    AddTeam
    end;
@@ -110,7 +112,7 @@
     c: LongInt;
     Gear: PGear;
 begin
-if (not isDeveloperMode)or(CurrentTeam=nil) then exit;
+if (not isDeveloperMode) or (CurrentTeam = nil) then exit;
 with CurrentTeam^ do
      begin
      SplitBySpace(id, s);
@@ -120,7 +122,7 @@
      val(s, Gear^.Health, c);
      TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
      PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam;
-     Hedgehogs[HedgehogsNumber].AmmoStore:= 0;
+     Hedgehogs[HedgehogsNumber].AmmoStore:= TeamsCount - 1;
      Hedgehogs[HedgehogsNumber].Gear:= Gear;
      inc(HedgehogsNumber)
      end
--- a/hedgewars/HHHandlers.inc	Mon Feb 05 19:33:24 2007 +0000
+++ b/hedgewars/HHHandlers.inc	Mon Feb 05 20:26:13 2007 +0000
@@ -116,7 +116,7 @@
        posCaseAmmo: begin
                     a:= TAmmoType(Gear^.State);
                     AddAmmo(PHedgehog(HH^.Hedgehog), a);
-                    s:= trammo[Ammoz[a].NameId];
+                    s:= trammo[Ammoz[a].NameId] + '(+' + IntToStr(Ammoz[a].NumberInCase) + ')';
                     AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Color, capgrpAmmoinfo);
                     end;
      posCaseHealth: begin
--- a/hedgewars/hwengine.dpr	Mon Feb 05 19:33:24 2007 +0000
+++ b/hedgewars/hwengine.dpr	Mon Feb 05 20:26:13 2007 +0000
@@ -232,7 +232,6 @@
 SendIPCRaw(@s[0], Length(s) + 1); // send proto version
 
 InitTeams;
-ParseCommand('ammstore 91911111111111108', true);
 AssignStores;
 
 if isSoundEnabled then InitSound;
--- a/hedgewars/uAmmos.pas	Mon Feb 05 19:33:24 2007 +0000
+++ b/hedgewars/uAmmos.pas	Mon Feb 05 20:26:13 2007 +0000
@@ -107,7 +107,7 @@
         if hhammo^[slot, ami].Count > 0 then
            ammos[hhammo^[slot, ami].AmmoType]:= hhammo^[slot, ami].Count;
 
-if ammos[ammo] <> AMMO_INFINITE then inc(ammos[ammo]);
+if ammos[ammo] <> AMMO_INFINITE then inc(ammos[ammo], Ammoz[ammo].NumberInCase);
 FillAmmoStore(hhammo, ammos)
 end;
 
--- a/hedgewars/uConsts.pas	Mon Feb 05 19:33:24 2007 +0000
+++ b/hedgewars/uConsts.pas	Mon Feb 05 20:26:13 2007 +0000
@@ -328,12 +328,15 @@
 
       Ammoz: array [TAmmoType] of record
                                   NameId: TAmmoStrId;
+                                  Probability, NumberInCase: Longword;
                                   Ammo: TAmmo;
                                   Slot: 0..cMaxSlotIndex;
                                   TimeAfterTurn: Longword;
                                   minAngle, maxAngle: Longword;
                                   end = (
                                   (NameId: sidGrenade;
+                                   Probability: 0;
+                                   NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_Timerable or
                                                  ammoprop_Power;
                                           Count: AMMO_INFINITE;
@@ -345,6 +348,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                   (NameId: sidClusterBomb;
+                                   Probability: 100;
+                                   NumberInCase: 3;
                                    Ammo: (Propz: ammoprop_Timerable or
                                                  ammoprop_Power;
                                           Count: 5;
@@ -356,6 +361,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                   (NameId: sidBazooka;
+                                   Probability: 0;
+                                   NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_Power;
                                           Count: AMMO_INFINITE;
                                           NumPerTurn: 0;
@@ -366,6 +373,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                   (NameId: sidUFO;
+                                   Probability: 100;
+                                   NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_Power or
                                                  ammoprop_NeedTarget;
                                           Count: 2;
@@ -377,6 +386,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                   (NameId: sidShotgun;
+                                   Probability: 0;
+                                   NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_ForwMsgs;
                                           Count: AMMO_INFINITE;
                                           NumPerTurn: 1;
@@ -387,6 +398,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                   (NameId: sidPickHammer;
+                                   Probability: 0;
+                                   NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_ForwMsgs or
                                                  ammoprop_AttackInFall or
                                                  ammoprop_AttackInJump or
@@ -400,6 +413,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                   (NameId: sidSkip;
+                                   Probability: 0;
+                                   NumberInCase: 1;
                                    Ammo: (Propz: 0;
                                           Count: AMMO_INFINITE;
                                           NumPerTurn: 0;
@@ -410,6 +425,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                   (NameId: sidRope;
+                                   Probability: 100;
+                                   NumberInCase: 3;
                                    Ammo: (Propz: ammoprop_ForwMsgs or
                                                  ammoprop_AttackInFall or
                                                  ammoprop_AttackInJump;
@@ -422,6 +439,8 @@
                                    minAngle: 0;
                                    maxAngle: cMaxAngle div 2),
                                   (NameId: sidMine;
+                                   Probability: 100;
+                                   NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_NoCrosshair;
                                           Count: 2;
                                           NumPerTurn: 0;
@@ -432,6 +451,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                   (NameId: sidDEagle;
+                                   Probability: 100;
+                                   NumberInCase: 2;
                                    Ammo: (Propz: 0;
                                           Count: 3;
                                           NumPerTurn: 3;
@@ -442,6 +463,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                    (NameId: sidDynamite;
+                                   Probability: 100;
+                                   NumberInCase: 1;
                                     Ammo: (Propz: ammoprop_NoCrosshair or
                                                   ammoprop_AttackInJump or
                                                   ammoprop_AttackInFall;
@@ -454,6 +477,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                    (NameId: sidFirePunch;
+                                   Probability: 0;
+                                   NumberInCase: 1;
                                     Ammo: (Propz: ammoprop_NoCrosshair or
                                                   ammoprop_ForwMsgs or
                                                   ammoprop_AttackInJump or
@@ -467,6 +492,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                    (NameId: sidBaseballBat;
+                                   Probability: 100;
+                                   NumberInCase: 1;
                                     Ammo: (Propz: 0;
                                            Count: 1;
                                            NumPerTurn: 0;
@@ -477,6 +504,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                   (NameId: sidParachute;
+                                   Probability: 100;
+                                   NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_ForwMsgs or
                                                  ammoprop_AttackInJump or
                                                  ammoprop_AttackInFall;
@@ -489,6 +518,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                   (NameId: sidAirAttack;
+                                   Probability: 100;
+                                   NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_NoCrosshair or
                                                  ammoprop_NeedTarget or
                                                  ammoprop_AttackingPut;
@@ -501,6 +532,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                   (NameId: sidMineStrike;
+                                   Probability: 400;
+                                   NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_NoCrosshair or
                                                  ammoprop_NeedTarget or
                                                  ammoprop_AttackingPut;
@@ -513,6 +546,8 @@
                                    minAngle: 0;
                                    maxAngle: 0),
                                   (NameId: sidBlowTorch;
+                                   Probability: 100;
+                                   NumberInCase: 2;
                                    Ammo: (Propz: ammoprop_ForwMsgs;
                                           Count: 1;
                                           NumPerTurn: 0;
--- a/hedgewars/uGears.pas	Mon Feb 05 19:33:24 2007 +0000
+++ b/hedgewars/uGears.pas	Mon Feb 05 20:26:13 2007 +0000
@@ -221,7 +221,7 @@
                 end;
         gtRope: begin
                 Result^.Radius:= 3;
-                Result^.Friction:= 500;
+                Result^.Friction:= 450;
                 RopePoints.Count:= 0;
                 end;
    gtExplosion: begin
@@ -798,6 +798,8 @@
 end;
 
 procedure SpawnBoxOfSmth;
+var t: LongInt;
+    i: TAmmoType;
 begin
 if (CountGears(gtCase) >= 5) or (getrandom(cCaseFactor) <> 0) then exit;
 FollowGear:= AddGear(0, 0, gtCase, 0, 0, 0, 0);
@@ -807,8 +809,19 @@
         FollowGear^.Pos:= posCaseHealth
         end;
      1: begin
+        t:= 0;
+        for i:= Low(TAmmoType) to High(TAmmoType) do
+            inc(t, Ammoz[i].Probability);
+        t:= GetRandom(t);
+        i:= Low(TAmmoType);
+        dec(t, Ammoz[i].Probability);
+        while t >= 0 do
+          begin
+          inc(i);
+          dec(t, Ammoz[i].Probability)
+          end;
         FollowGear^.Pos:= posCaseAmmo;
-        FollowGear^.State:= Longword(amMineStrike)
+        FollowGear^.State:= Longword(i)
         end;
      end;
 FindPlace(FollowGear, true, 0, 2048)