health reset mode ftw (replaces gfmines)
authorkoda
Wed, 03 Nov 2010 16:29:17 +0100
changeset 4099 af612377fcba
parent 4098 40df542b5f62
child 4100 a16295685c53
health reset mode ftw (replaces gfmines)
QTfrontend/ammoSchemeModel.cpp
QTfrontend/hedgewars.qrc
QTfrontend/pages.cpp
QTfrontend/pages.h
QTfrontend/res/btnMines.png
QTfrontend/res/btnResetHealth.png
hedgewars/CCHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uTeams.pas
--- a/QTfrontend/ammoSchemeModel.cpp	Wed Nov 03 00:48:42 2010 +0100
+++ b/QTfrontend/ammoSchemeModel.cpp	Wed Nov 03 16:29:17 2010 +0100
@@ -31,7 +31,7 @@
         << QVariant(false)         // low gravity    5
         << QVariant(false)         // laser sight    6
         << QVariant(false)         // invulnerable   7
-        << QVariant(true)          // add mines      8
+        << QVariant(false)         // reset health   8
         << QVariant(false)         // vampiric       9
         << QVariant(false)         // karma          10
         << QVariant(false)         // artillery      11
@@ -81,7 +81,7 @@
         << "lowgrav"          //  5
         << "laser"            //  6
         << "invulnerability"  //  7
-        << "mines"            //  8
+        << "resethealth"      //  8
         << "vampiric"         //  9
         << "karma"            // 10
         << "artillery"        // 11
@@ -116,7 +116,7 @@
         << QVariant(false)         // low gravity    5
         << QVariant(false)         // laser sight    6
         << QVariant(false)         // invulnerable   7
-        << QVariant(false)         // add mines      8
+        << QVariant(false)         // reset health   8
         << QVariant(false)         // vampiric       9
         << QVariant(false)         // karma          10
         << QVariant(false)         // artillery      11
@@ -151,7 +151,7 @@
         << QVariant(false)         // low gravity    5
         << QVariant(false)         // laser sight    6
         << QVariant(false)         // invulnerable   7
-        << QVariant(false)         // add mines      8
+        << QVariant(false)         // reset health   8
         << QVariant(false)         // vampiric       9
         << QVariant(false)         // karma          10
         << QVariant(false)         // artillery      11
@@ -186,7 +186,7 @@
         << QVariant(true)          // low gravity    5
         << QVariant(false)         // laser sight    6
         << QVariant(true)          // invulnerable   7
-        << QVariant(false)         // add mines      8
+        << QVariant(false)         // reset health   8
         << QVariant(false)         // vampiric       9
         << QVariant(false)         // karma          10
         << QVariant(false)         // artillery      11
@@ -221,7 +221,7 @@
         << QVariant(false)         // low gravity    5
         << QVariant(false)         // laser sight    6
         << QVariant(false)         // invulnerable   7
-        << QVariant(true)          // add mines      8
+        << QVariant(false)         // reset health   8
         << QVariant(false)         // vampiric       9
         << QVariant(false)         // karma          10
         << QVariant(false)         // artillery      11
@@ -256,7 +256,7 @@
         << QVariant(false)         // low gravity    5
         << QVariant(false)         // laser sight    6
         << QVariant(false)         // invulnerable   7
-        << QVariant(false)         // add mines      8
+        << QVariant(false)         // reset health   8
         << QVariant(false)         // vampiric       9
         << QVariant(false)         // karma          10
         << QVariant(false)         // artillery      11
@@ -291,7 +291,7 @@
         << QVariant(false)         // low gravity    5
         << QVariant(false)         // laser sight    6
         << QVariant(false)         // invulnerable   7
-        << QVariant(true)          // add mines      8
+        << QVariant(false)         // reset health   8
         << QVariant(false)         // vampiric       9
         << QVariant(false)         // karma          10
         << QVariant(false)         // artillery      11
--- a/QTfrontend/hedgewars.qrc	Wed Nov 03 00:48:42 2010 +0100
+++ b/QTfrontend/hedgewars.qrc	Wed Nov 03 16:29:17 2010 +0100
@@ -54,7 +54,7 @@
     <file>res/btnInvulnerable.png</file>
     <file>res/btnLaserSight.png</file>
     <file>res/btnLowGravity.png</file>
-    <file>res/btnMines.png</file>
+    <file>res/btnResetHealth.png</file>
     <file>res/btnTeamsDivide.png</file>
     <file>res/btnSolid.png</file>
     <file>res/btnVampiric.png</file>
--- a/QTfrontend/pages.cpp	Wed Nov 03 00:48:42 2010 +0100
+++ b/QTfrontend/pages.cpp	Wed Nov 03 16:29:17 2010 +0100
@@ -1503,9 +1503,9 @@
     TBW_invulnerable->setToolTip("<b>" + ToggleButtonWidget::tr("Invulnerable") + "</b>:<br />" + tr("All hogs have a personal forcefield"));
     glGMLayout->addWidget(TBW_invulnerable,1,1,1,1);
 
-    TBW_mines = new ToggleButtonWidget(gbGameModes, ":/res/btnMines.png");
-    TBW_mines->setToolTip("<b>" + ToggleButtonWidget::tr("Add Mines") + "</b>:<br />" + tr("Enable random mines"));
-    glGMLayout->addWidget(TBW_mines,1,2,1,1);
+    TBW_resethealth = new ToggleButtonWidget(gbGameModes, ":/res/btnResetHealth.png");
+    TBW_resethealth->setToolTip("<b>" + ToggleButtonWidget::tr("Reset Health") + "</b>:<br />" + tr("Every hog of the team is fully restored at the end of turn"));
+    glGMLayout->addWidget(TBW_resethealth,1,2,1,1);
 
     TBW_vampiric = new ToggleButtonWidget(gbGameModes, ":/res/btnVampiric.png");
     TBW_vampiric->setToolTip("<b>" + ToggleButtonWidget::tr("Vampirism") + "</b>:<br />" + tr("Gain 80% of the damage you do back in health"));
@@ -1732,7 +1732,7 @@
     mapper->addMapping(TBW_lowGravity, 5);
     mapper->addMapping(TBW_laserSight, 6);
     mapper->addMapping(TBW_invulnerable, 7);
-    mapper->addMapping(TBW_mines, 8);
+    mapper->addMapping(TBW_resethealth, 8);
     mapper->addMapping(TBW_vampiric, 9);
     mapper->addMapping(TBW_karma, 10);
     mapper->addMapping(TBW_artillery, 11);
--- a/QTfrontend/pages.h	Wed Nov 03 00:48:42 2010 +0100
+++ b/QTfrontend/pages.h	Wed Nov 03 16:29:17 2010 +0100
@@ -466,7 +466,7 @@
     ToggleButtonWidget * TBW_lowGravity;
     ToggleButtonWidget * TBW_laserSight;
     ToggleButtonWidget * TBW_invulnerable;
-    ToggleButtonWidget * TBW_mines;
+    ToggleButtonWidget * TBW_resethealth;
     ToggleButtonWidget * TBW_vampiric;
     ToggleButtonWidget * TBW_karma;
     ToggleButtonWidget * TBW_artillery;
Binary file QTfrontend/res/btnMines.png has changed
Binary file QTfrontend/res/btnResetHealth.png has changed
--- a/hedgewars/CCHandlers.inc	Wed Nov 03 00:48:42 2010 +0100
+++ b/hedgewars/CCHandlers.inc	Wed Nov 03 16:29:17 2010 +0100
@@ -170,6 +170,7 @@
     else CurrentHedgehog^.AmmoStore:= TeamsCount - 1;
     CurrentHedgehog^.Gear:= Gear;
     CurrentHedgehog^.Name:= id;
+    CurrentHedgehog^.InitialHealth:= Gear^.Health;
     CurrHedgehog:= HedgehogsNumber;
     inc(HedgehogsNumber)
     end
--- a/hedgewars/uConsts.pas	Wed Nov 03 00:48:42 2010 +0100
+++ b/hedgewars/uConsts.pas	Wed Nov 03 16:29:17 2010 +0100
@@ -339,7 +339,7 @@
     gfLowGravity         = $00000020;
     gfLaserSight         = $00000040;
     gfInvulnerable       = $00000080;
-    gfMines              = $00000100;           // redundant? same effect as 'landadds 0'
+    gfResetHealth        = $00000100;
     gfVampiric           = $00000200;
     gfKarma              = $00000400;
     gfArtillery          = $00000800;
--- a/hedgewars/uGears.pas	Wed Nov 03 00:48:42 2010 +0100
+++ b/hedgewars/uGears.pas	Wed Nov 03 16:29:17 2010 +0100
@@ -935,20 +935,30 @@
         cArtillery:= false;
     // have to sweep *all* current team hedgehogs since it is theoretically possible if you have enough invulnerabilities and switch turns to make your entire team invulnerable
     if (CurrentTeam <> nil) then
-       with CurrentTeam^ do
-          for i:= 0 to cMaxHHIndex do
-              with Hedgehogs[i] do
-                  begin
-                  if (SpeechGear <> nil) then
-                     begin
-                     DeleteVisualGear(SpeechGear);  // remove to restore persisting beyond end of turn. Tiy says was too much of a gameplay issue
-                     SpeechGear:= nil
-                     end;
+        with CurrentTeam^ do
+            for i:= 0 to cMaxHHIndex do
+                with Hedgehogs[i] do
+                    begin
+                    if (SpeechGear <> nil) then
+                        begin
+                        DeleteVisualGear(SpeechGear);  // remove to restore persisting beyond end of turn. Tiy says was too much of a gameplay issue
+                        SpeechGear:= nil
+                        end;
 
-                  if (Gear <> nil) then
-                     if (GameFlags and gfInvulnerable) = 0 then
-                        Gear^.Invulnerable:= false;
-                  end;
+                    if (Gear <> nil) then
+                        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
@@ -957,7 +967,9 @@
         end;
    
     if (GameFlags and gfResetWeps) <> 0 then
-        ResetWeapons
+        ResetWeapons;
+    if (GameFlags and gfResetHealth) <> 0 then
+        RecountTeamHealth(CurrentTeam);
 end;
 
 procedure ApplyDamage(Gear: PGear; Damage: Longword; Source: TDamageSource);
@@ -1203,12 +1215,11 @@
 
 if ((GameFlags and gfForts) = 0) then
     begin
-    if ((GameFlags and gfMines) <> 0) then
-        for i:= 0 to Pred(cLandMines) do
-            begin
-            Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0);
-            FindPlace(Gear, false, 0, LAND_WIDTH);
-            end;
+    for i:= 0 to Pred(cLandMines) do
+        begin
+        Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0);
+        FindPlace(Gear, false, 0, LAND_WIDTH);
+        end;
     for i:= 0 to Pred(cExplosives) do
         begin
         Gear:= AddGear(0, 0, gtExplosives, 0, _0, _0, 0);
--- a/hedgewars/uTeams.pas	Wed Nov 03 00:48:42 2010 +0100
+++ b/hedgewars/uTeams.pas	Wed Nov 03 16:29:17 2010 +0100
@@ -47,6 +47,7 @@
             HatVisibility: GLfloat;
             stats: TStatistics;
             Hat: shortstring;
+            InitialHealth: Byte; // used for gfResetHealth
             King: boolean;  // Flag for a bunch of hedgehog attributes
             Unplaced: boolean;  // Flag for hog placing mode
             Timer: Longword;