King health proportional to team size
authornemo
Tue, 09 Feb 2010 20:47:22 +0000
changeset 2784 1a2e3c7c6a46
parent 2783 1532fde15179
child 2785 de6406cd6b25
King health proportional to team size
hedgewars/uFloat.pas
hedgewars/uTeams.pas
--- a/hedgewars/uFloat.pas	Tue Feb 09 18:58:44 2010 +0000
+++ b/hedgewars/uFloat.pas	Tue Feb 09 20:47:22 2010 +0000
@@ -90,6 +90,7 @@
            _0_25: hwFloat = (isNegative: false; QWordValue:  1073741824);
             _0_3: hwFloat = (isNegative: false; QWordValue:  1288490189);
            _0_35: hwFloat = (isNegative: false; QWordValue:  1503238553);
+          _0_375: hwFloat = (isNegative: false; QWordValue:  4294967296 * 3 div 8);
            _0_39: hwFloat = (isNegative: false; QWordValue:  1675037245);
             _0_4: hwFloat = (isNegative: false; QWordValue:  1717986918);
            _0_45: hwFloat = (isNegative: false; QWordValue:  1932735283);
--- a/hedgewars/uTeams.pas	Tue Feb 09 18:58:44 2010 +0000
+++ b/hedgewars/uTeams.pas	Tue Feb 09 20:47:22 2010 +0000
@@ -340,7 +340,7 @@
 
 procedure InitTeams;
 var i, t: LongInt;
-    th: LongInt;
+    th, h: LongInt;
 begin
 
 for t:= 0 to Pred(TeamsCount) do
@@ -349,17 +349,21 @@
       if (not ExtDriven) and (Hedgehogs[0].BotLevel = 0) then
           LocalClan:= Clan^.ClanIndex + 1;
       th:= 0;
+      for i:= 0 to cMaxHHIndex do
+          if Hedgehogs[i].Gear <> nil then
+             inc(th, Hedgehogs[i].Gear^.Health);
+      if th > MaxTeamHealth then MaxTeamHealth:= th;
       // Some initial King buffs
       if (GameFlags and gfKing) <> 0 then
           begin
           Hedgehogs[0].King:= true;
           Hedgehogs[0].Hat:= 'crown';
-          inc(Hedgehogs[0].Gear^.Health, hwRound(int2hwFloat(Hedgehogs[0].Gear^.Health)*_0_5))
+          h:= Hedgehogs[0].Gear^.Health;
+          Hedgehogs[0].Gear^.Health:= hwRound(int2hwFloat(th)*_0_375);
+          dec(th, h);
+          inc(th, Hedgehogs[0].Gear^.Health);
+          if th > MaxTeamHealth then MaxTeamHealth:= th
           end;
-      for i:= 0 to cMaxHHIndex do
-          if Hedgehogs[i].Gear <> nil then
-             inc(th, Hedgehogs[i].Gear^.Health);
-      if th > MaxTeamHealth then MaxTeamHealth:= th;
       end;
 
 RecountAllTeamsHealth