Remove Distance from flake kick, reduce calls to Random() in flame replacing w/ checks on game tick and a little randomness.
authornemo
Sat, 27 Mar 2010 03:55:12 +0000
changeset 3096 9330eead14fa
parent 3095 63f1d0f13c5a
child 3097 6fa39c1c41b9
Remove Distance from flake kick, reduce calls to Random() in flame replacing w/ checks on game tick and a little randomness.
hedgewars/GSHandlers.inc
hedgewars/uVisualGears.pas
--- a/hedgewars/GSHandlers.inc	Sat Mar 27 03:39:35 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Sat Mar 27 03:55:12 2010 +0000
@@ -1612,8 +1612,8 @@
                 AmmoShove(Gear, 4, 100);
                 Gear^.Radius:= 1;
                 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 4, EXPLNoDamage);
-                if Random(100) > 90 then
-                  for i:= 0 to Random(3) do
+                if ((GameTicks and $7) = 0) and (Random(2) = 0) then
+                  for i:= 1 to Random(2)+1 do
                     AddVisualGear(hwRound(Gear^.X) - 3 + Random(6), hwRound(Gear^.Y) - 2, vgtSmoke);
                 if Gear^.Health > 0 then dec(Gear^.Health);
                 Gear^.Timer:= 450 - Gear^.Tag * 8
@@ -1634,8 +1634,8 @@
         end;
 if Gear^.Health = 0 then begin
   if (Gear^.State and gsttmpFlag) = 0 then begin
-    if Random(100) > 80 then begin
-      for i:= 0 to Random(3) do begin
+    if ((GameTicks and $3) = 0) and (Random(1) = 0) then begin
+      for i:= 1 to Random(2)+1 do begin
         AddVisualGear(hwRound(Gear^.X) - 3 + Random(6), hwRound(Gear^.Y) - 2, vgtSmoke);
       end;
     end;
--- a/hedgewars/uVisualGears.pas	Sat Mar 27 03:39:35 2010 +0000
+++ b/hedgewars/uVisualGears.pas	Sat Mar 27 03:55:12 2010 +0000
@@ -89,7 +89,9 @@
 
 // ==================================================================
 procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
+var sign: hwFloat;
 begin
+sign:= _1;
 with Gear^ do
     begin
     inc(FrameTicks, Steps);
@@ -108,10 +110,12 @@
        (hwRound(Y) <= (LAND_HEIGHT + 75)) and 
        (Timer > 0) and (Timer-Steps > 0) then
         begin
-        tdX:= tdX - _0_005*Steps;
-        tdY:= tdY - _0_005*Steps;
-        if tdX < _0 then tdX:= _0;
-        if tdY < _0 then tdY:= _0;
+        sign.isNegative:=tdX.isNegative;
+        tdX:= tdX - _0_005*Steps*sign;
+        if (sign.isNegative and (tdX > _0)) or (not sign.isNegative and (tdX < _0)) then tdX:= _0;
+        sign.isNegative:=tdY.isNegative;
+        tdY:= tdY - _0_005*Steps*sign;
+        if (sign.isNegative and (tdY > _0)) or (not sign.isNegative and (tdY < _0)) then tdY:= _0;
         dec(Timer, Steps)
         end
     else
@@ -669,11 +673,11 @@
       if Gear^.Kind = vgtFlake then
           begin
           // Damage calc from doMakeExplosion
-          dmg:= min(100,Radius*2  + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))));
+          dmg:= min(100,Radius  + cHHRadius div 2 - (hwRound(hwAbs(Gear^.X - int2hwFloat(X))+hwAbs(Gear^.Y - int2hwFloat(Y))) div 5));
           if dmg > 1 then
               begin
-              Gear^.tdX:= Gear^.dX + SignAs(_0_01 * dmg + cHHKick, Gear^.X - int2hwFloat(X));
-              Gear^.tdY:= Gear^.dY + SignAs(_0_01 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y));
+              Gear^.tdX:= SignAs(_0_02 * dmg + cHHKick, Gear^.X - int2hwFloat(X));
+              Gear^.tdY:= SignAs(_0_02 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y));
               Gear^.Timer:= 200
               end
           end;