Lua: Add InitHealth, read-only variable containing the initial hog health setting
authorWuzzy <Wuzzy2@mail.ru>
Sat, 05 Jan 2019 22:05:20 +0100
changeset 14527 d0441c7e9000
parent 14526 8a11548cb1d2
child 14528 e176bf229649
Lua: Add InitHealth, read-only variable containing the initial hog health setting
ChangeLog.txt
QTfrontend/ui/widget/gamecfgwidget.cpp
hedgewars/uCommandHandlers.pas
hedgewars/uScript.pas
hedgewars/uVariables.pas
--- a/ChangeLog.txt	Sat Jan 05 21:52:15 2019 +0100
+++ b/ChangeLog.txt	Sat Jan 05 22:05:20 2019 +0100
@@ -36,6 +36,7 @@
  + SimpleMission: Add isMissionTeam attribute for teams
  + SpeedShoppa/TargetPractice libraries: Remove custom hog and team info settings
  + Params explode, poison in the SpawnFake*Crate functions now optional and default to false
+ + New global: InitHealth: Initial hog health value from game scheme (read-only)
 
 ====================== 0.9.25 ======================
 HIGHLIGHTS:
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp	Sat Jan 05 21:52:15 2019 +0100
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp	Sat Jan 05 22:05:20 2019 +0100
@@ -336,6 +336,7 @@
     bcfg << QString("e$gmflags %1").arg(getGameFlags()).toUtf8();
     bcfg << QString("e$damagepct %1").arg(schemeData(26).toInt()).toUtf8();
     bcfg << QString("e$turntime %1").arg(schemeData(27).toInt() * 1000).toUtf8();
+    bcfg << QString("e$inithealth %1").arg(schemeData(28).toInt()).toUtf8();
     bcfg << QString("e$sd_turns %1").arg(schemeData(29).toInt()).toUtf8();
     bcfg << QString("e$casefreq %1").arg(schemeData(30).toInt()).toUtf8();
     bcfg << QString("e$minestime %1").arg(schemeData(31).toInt() * 1000).toUtf8();
--- a/hedgewars/uCommandHandlers.pas	Sat Jan 05 21:52:15 2019 +0100
+++ b/hedgewars/uCommandHandlers.pas	Sat Jan 05 22:05:20 2019 +0100
@@ -785,6 +785,11 @@
 cHealthDecrease:= StrToInt(s)
 end;
 
+procedure chInitHealth(var s: shortstring);
+begin
+cInitHealth:= StrToInt(s)
+end;
+
 procedure chDamagePercent(var s: shortstring);
 begin
 cDamagePercent:= StrToInt(s)
@@ -926,6 +931,7 @@
     RegisterVariable('sd_turns', @chSuddenDTurns  , false);
     RegisterVariable('waterrise', @chWaterRise    , false);
     RegisterVariable('healthdec', @chHealthDecrease, false);
+    RegisterVariable('inithealth',@chInitHealth, false);
     RegisterVariable('damagepct',@chDamagePercent , false);
     RegisterVariable('ropepct' , @chRopePercent   , false);
     RegisterVariable('getawaytime' , @chGetAwayTime , false);
--- a/hedgewars/uScript.pas	Sat Jan 05 21:52:15 2019 +0100
+++ b/hedgewars/uScript.pas	Sat Jan 05 22:05:20 2019 +0100
@@ -3614,6 +3614,7 @@
 ScriptSetInteger('MaxCaseDrops', cMaxCaseDrops);
 ScriptSetInteger('HealthCaseProb', cHealthCaseProb);
 ScriptSetInteger('HealthCaseAmount', cHealthCaseAmount);
+ScriptSetInteger('InitHealth', cInitHealth);
 ScriptSetInteger('DamagePercent', cDamagePercent);
 ScriptSetInteger('RopePercent', cRopePercent);
 ScriptSetInteger('MinesNum', cLandMines);
@@ -3647,6 +3648,7 @@
 cMaxCaseDrops    := ScriptGetInteger('MaxCaseDrops');
 cHealthCaseProb  := ScriptGetInteger('HealthCaseProb');
 cHealthCaseAmount:= ScriptGetInteger('HealthCaseAmount');
+cInitHealth      := ScriptGetInteger('InitHealth');
 cDamagePercent   := ScriptGetInteger('DamagePercent');
 cRopePercent     := ScriptGetInteger('RopePercent');
 cLandMines       := ScriptGetInteger('MinesNum');
--- a/hedgewars/uVariables.pas	Sat Jan 05 21:52:15 2019 +0100
+++ b/hedgewars/uVariables.pas	Sat Jan 05 22:05:20 2019 +0100
@@ -106,6 +106,8 @@
     GameOver        : boolean;
     cSuddenDTurns   : LongInt;
     LastSuddenDWarn : LongInt; // last round in which the last SD warning appeared. -2 = no warning so far
+    cInitHealth     : LongInt; // initial hedgehog health (from game scheme. note the real hog health is sent directly
+                               // from frontend, this is only used to inform Lua scripts)
     cDamagePercent  : LongInt;
     cMineDudPercent : LongWord;
     cTemplateFilter : LongInt;
@@ -2806,6 +2808,7 @@
     TagTurnTimeLeft     := 0;
     cSuddenDTurns       := 15;
     LastSuddenDWarn     := -2;
+    cInitHealth         := 100;
     cDamagePercent      := 100;
     cRopePercent        := 100;
     cGetAwayTime        := 100;