make random timers less easy to predict
authorsheepluva
Sun, 27 Nov 2016 12:58:41 +0100
changeset 12099 4dfc95eabee1
parent 12098 0d6e0ed36c9e
child 12100 e1bca1ebbad9
make random timers less easy to predict
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsList.pas
--- a/hedgewars/uGearsHandlersMess.pas	Sun Nov 27 06:32:00 2016 +0100
+++ b/hedgewars/uGearsHandlersMess.pas	Sun Nov 27 12:58:41 2016 +0100
@@ -1752,6 +1752,14 @@
         else // gstAttacking <> 0
             begin
             AllInactive := false;
+            // tag of 1 means this mine has a random timer
+            if (Gear^.Tag = 1) and (Gear^.Timer = 0) then
+                begin
+                if (GameTicks mod 2 = 0) then GetRandom(2);
+                if (GameTicks mod 3 = 0) then GetRandom(2);
+                Gear^.Timer:= GetRandom(51) * 100;
+                Gear^.Tag:= 0;
+                end;
             if (Gear^.Timer and $FF) = 0 then
                 PlaySound(sndMineTick);
             if Gear^.Timer = 0 then
--- a/hedgewars/uGearsList.pas	Sun Nov 27 06:32:00 2016 +0100
+++ b/hedgewars/uGearsList.pas	Sun Nov 27 12:58:41 2016 +0100
@@ -418,10 +418,11 @@
                 gear^.Elasticity:= _0_55;
                 gear^.Friction:= _0_995;
                 gear^.Density:= _1;
+                gear^.Tag:= 0;
                 if gear^.Timer = 0 then
                     begin
                     if cMinesTime < 0 then
-                        gear^.Timer:= getrandom(51)*100
+                        gear^.Tag:= 1 // gear tag of 1 means mine timer will be random
                     else
                         gear^.Timer:= cMinesTime
                     end