Add support for infinite fly time of jetpack and Birdy
authorWuzzy <Wuzzy2@mail.ru>
Thu, 02 Aug 2018 01:24:40 +0200
changeset 13598 083733ec7941
parent 13592 818134c33f54
child 13599 ddd90e92c4c3
Add support for infinite fly time of jetpack and Birdy
ChangeLog.txt
hedgewars/uConsts.pas
hedgewars/uGearsHandlersMess.pas
hedgewars/uScript.pas
--- a/ChangeLog.txt	Wed Aug 01 23:12:37 2018 +0200
+++ b/ChangeLog.txt	Thu Aug 02 01:24:40 2018 +0200
@@ -79,6 +79,7 @@
  + New parameter: SetAmmoTexts: 5th param. showExtra: Set to false to hide texts like “Not yet available”
  + New parameter: ShowMission: 6th param. forceDisplay: Set to true to prevent this particular mission panel to be hidden manually by player
  + New Lua library: Achievements
+ + Can enable infinite fly time for jetpack/Birdy by setting health to JETPACK_FUEL_INFINITE or BIRDY_ENERGY_INFINITE, respectively
  * Changed global: lfCurrentHog becomes lfCurHogCrate
  * Fixed variable: TotalRounds was -1 (instead of 0) in first real round after hog placement phase
  * AI sometimes intentionally shot hedgehogs with aihDoesntMatter set
--- a/hedgewars/uConsts.pas	Wed Aug 01 23:12:37 2018 +0200
+++ b/hedgewars/uConsts.pas	Thu Aug 02 01:24:40 2018 +0200
@@ -320,6 +320,9 @@
     AMMO_INFINITE = 100;
     AMMO_FINITE_MAX = 99;
 
+    JETPACK_FUEL_INFINITE : LongInt = Low(LongInt);
+    BIRDY_ENERGY_INFINITE : LongInt = Low(LongInt);
+
     // Special msgParam value used internally for invalid/non-existing value
     // Must not be sent over the network!
     MSGPARAM_INVALID = High(LongWord);
--- a/hedgewars/uGearsHandlersMess.pas	Wed Aug 01 23:12:37 2018 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Thu Aug 02 01:24:40 2018 +0200
@@ -1030,7 +1030,7 @@
 
     if Gear^.Timer = 0 then
         begin
-        // no "fuel"? just fall
+        // no energy? just fall
         doStepFallingGear(Gear);
         // if drowning, stop bee sound
         if (Gear^.State and gstDrowning) <> 0 then
@@ -4170,7 +4170,7 @@
     end;*)
     if HHGear^.Message and gmPrecise <> 0 then
         HedgehogChAngle(HHGear)
-    else if Gear^.Health > 0 then
+    else if (Gear^.Health > 0) or (Gear^.Health = JETPACK_FUEL_INFINITE) then
         begin
         if HHGear^.Message and gmUp <> 0 then
             begin
@@ -4192,7 +4192,8 @@
                     HHGear^.dY := HHGear^.dY - move;
                     end
                 end;
-            dec(Gear^.Health, fuel);
+            if Gear^.Health <> JETPACK_FUEL_INFINITE then
+                dec(Gear^.Health, fuel);
             Gear^.MsgParam := Gear^.MsgParam or gmUp;
             Gear^.Timer := GameTicks
             end;
@@ -4218,7 +4219,8 @@
                     end
                 end
             else PlaySound(sndJetpackBoost);
-            dec(Gear^.Health, fuel div 5);
+            if Gear^.Health <> JETPACK_FUEL_INFINITE then
+                dec(Gear^.Health, fuel div 5);
             Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight));
             Gear^.Timer := GameTicks
             end
@@ -4231,7 +4233,7 @@
         Gear^.MsgParam := 0
         end;
 
-    if Gear^.Health < 0 then
+    if (Gear^.Health < 0) and (Gear^.Health <> JETPACK_FUEL_INFINITE) then
         Gear^.Health := 0;
 
     i:= Gear^.Health div 20;
@@ -4239,9 +4241,9 @@
     if (i <> Gear^.Damage) and ((GameTicks and $3F) = 0) then
         begin
         Gear^.Damage:= i;
-        //AddCaption('Fuel: '+inttostr(round(Gear^.Health/20))+'%', cWhiteColor, capgrpAmmostate);
         FreeAndNilTexture(Gear^.Tex);
-        Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ansistring(': ' + inttostr(i) + '%'), cWhiteColor, fntSmall)
+        if Gear^.Health <> JETPACK_FUEL_INFINITE then
+            Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ansistring(': ' + inttostr(i) + '%'), cWhiteColor, fntSmall)
         end;
 
     if (HHGear^.Message and (gmAttack or gmUp or gmLeft or gmRight) <> 0) and
@@ -4334,7 +4336,7 @@
 procedure doStepBirdyFly(Gear: PGear);
 var
     HHGear: PGear;
-    fuel, i: LongInt;
+    energy, i: LongInt;
     move: hwFloat;
     s: ansistring;
 begin
@@ -4352,7 +4354,7 @@
         end;
 
     move := _0_2;
-    fuel := 50;
+    energy:= 50;
 
     if Gear^.Pos > 0 then
         dec(Gear^.Pos, 1)
@@ -4370,7 +4372,8 @@
         or (HHGear^.Y > -_256) then
             HHGear^.dY := HHGear^.dY - move;
 
-        dec(Gear^.Health, fuel);
+        if (Gear^.Health <> BIRDY_ENERGY_INFINITE) then
+            dec(Gear^.Health, energy);
         Gear^.MsgParam := Gear^.MsgParam or gmUp;
         end;
 
@@ -4378,14 +4381,15 @@
     if (HHGear^.Message and (gmLeft or gmRight)) <> 0 then
         begin
         HHGear^.dX := HHGear^.dX + (move * _0_1);
-        dec(Gear^.Health, fuel div 5);
+        if (Gear^.Health <> BIRDY_ENERGY_INFINITE) then
+            dec(Gear^.Health, energy div 5);
         Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight));
         end;
 
-    if Gear^.Health < 0 then
+    if (Gear^.Health < 0) and (Gear^.Health <> BIRDY_ENERGY_INFINITE) then
         Gear^.Health := 0;
 
-    if ((GameTicks and $FF) = 0) and (Gear^.Health < 500) then
+    if ((GameTicks and $FF) = 0) and (Gear^.Health < 500) and (Gear^.Health <> BIRDY_ENERGY_INFINITE) then
         for i:= ((500-Gear^.Health) div 250) downto 0 do
             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFeather);
 
--- a/hedgewars/uScript.pas	Wed Aug 01 23:12:37 2018 +0200
+++ b/hedgewars/uScript.pas	Thu Aug 02 01:24:40 2018 +0200
@@ -3916,6 +3916,10 @@
 ScriptSetInteger('SAY_THINK', 2);
 ScriptSetInteger('SAY_SHOUT', 3);
 
+// other
+ScriptSetInteger('JETPACK_FUEL_INFINITE', JETPACK_FUEL_INFINITE);
+ScriptSetInteger('BIRDY_ENERGY_INFINITE', BIRDY_ENERGY_INFINITE);
+
 // register gear types
 for at:= Low(TGearType) to High(TGearType) do
     ScriptSetInteger(EnumToStr(at), ord(at));