Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
authornemo
Wed, 03 Nov 2010 12:28:44 -0400
changeset 4101 c5967f360beb
parent 4100 a16295685c53
child 4102 96efb3bbf8e3
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
hedgewars/uGears.pas
hedgewars/uTeams.pas
--- a/hedgewars/uGears.pas	Wed Nov 03 16:35:24 2010 +0100
+++ b/hedgewars/uGears.pas	Wed Nov 03 12:28:44 2010 -0400
@@ -949,27 +949,26 @@
                         begin
                         if (GameFlags and gfInvulnerable) = 0 then
                             Gear^.Invulnerable:= false;
-                        if (GameFlags and gfResetHealth) <> 0 then
-                            begin
-                            if Gear^.Health < InitialHealth then
-                                begin
-                                Gear^.Health:= InitialHealth;
-                                RenderHealth(CurrentHedgehog^);
-                                end;
-                            end;
                         end;
                     end;
     t:= GearsList;
     while t <> nil do
         begin
         t^.PortalCounter:= 0;
+        if ((GameFlags and gfResetHealth) <> 0) and (t^.Kind = gtHedgehog) and (t^.Health < PHedgehog(t^.Hedgehog)^.InitialHealth) then
+            begin
+            t^.Health:= PHedgehog(t^.Hedgehog)^.InitialHealth;
+            RenderHealth(PHedgehog(t^.Hedgehog)^);
+            end;
         t:= t^.NextGear
         end;
    
     if (GameFlags and gfResetWeps) <> 0 then
         ResetWeapons;
+
     if (GameFlags and gfResetHealth) <> 0 then
-        RecountTeamHealth(CurrentTeam);
+        for i:= 0 to Pred(TeamsCount) do
+            RecountTeamHealth(TeamsArray[i])
 end;
 
 procedure ApplyDamage(Gear: PGear; Damage: Longword; Source: TDamageSource);
--- a/hedgewars/uTeams.pas	Wed Nov 03 16:35:24 2010 +0100
+++ b/hedgewars/uTeams.pas	Wed Nov 03 12:28:44 2010 -0400
@@ -47,7 +47,7 @@
             HatVisibility: GLfloat;
             stats: TStatistics;
             Hat: shortstring;
-            InitialHealth: Byte; // used for gfResetHealth
+            InitialHealth: LongInt; // used for gfResetHealth
             King: boolean;  // Flag for a bunch of hedgehog attributes
             Unplaced: boolean;  // Flag for hog placing mode
             Timer: Longword;
@@ -371,35 +371,36 @@
 begin
 
 for t:= 0 to Pred(TeamsCount) do
-   with TeamsArray[t]^ do
-      begin
-      if (not ExtDriven) and (Hedgehogs[0].BotLevel = 0) then
-          begin
-          LocalClan:= Clan^.ClanIndex;
-          LocalAmmo:= Hedgehogs[0].AmmoStore
-          end;
-      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';
-          Hedgehogs[0].Effects[hePoisoned] := false;
-          h:= Hedgehogs[0].Gear^.Health;
-          Hedgehogs[0].Gear^.Health:= hwRound(int2hwFloat(th)*_0_375);
-          if Hedgehogs[0].Gear^.Health > h then
-              begin
-              dec(th, h);
-              inc(th, Hedgehogs[0].Gear^.Health);
-              if th > MaxTeamHealth then MaxTeamHealth:= th
-              end
-          else Hedgehogs[0].Gear^.Health:= h
-          end;
-      end;
+    with TeamsArray[t]^ do
+        begin
+        if (not ExtDriven) and (Hedgehogs[0].BotLevel = 0) then
+            begin
+            LocalClan:= Clan^.ClanIndex;
+            LocalAmmo:= Hedgehogs[0].AmmoStore
+            end;
+        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';
+            Hedgehogs[0].Effects[hePoisoned] := false;
+            h:= Hedgehogs[0].Gear^.Health;
+            Hedgehogs[0].Gear^.Health:= hwRound(int2hwFloat(th)*_0_375);
+            if Hedgehogs[0].Gear^.Health > h then
+                begin
+                dec(th, h);
+                inc(th, Hedgehogs[0].Gear^.Health);
+                if th > MaxTeamHealth then MaxTeamHealth:= th
+                end
+            else Hedgehogs[0].Gear^.Health:= h
+            Hedgehogs[0].InitialHealth:= Hedgehogs[0].Gear^.Health;
+            end;
+        end;
 
 RecountAllTeamsHealth
 end;