better sentry free fall behavior
authoralfadur
Tue, 10 May 2022 02:59:11 +0300
changeset 15847 2839b68a3732
parent 15846 78745063cf33
child 15848 3d05bada4799
better sentry free fall behavior
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsList.pas
hedgewars/uGearsUtils.pas
--- a/hedgewars/uGearsHandlersMess.pas	Tue May 10 00:19:52 2022 +0300
+++ b/hedgewars/uGearsHandlersMess.pas	Tue May 10 02:59:11 2022 +0300
@@ -7245,6 +7245,7 @@
         Sentry^.dY := -_0_25;
         jumpTime := _2 * Sentry^.dY / cGravity;
         Sentry^.dX := SignAs(int2hwFloat(offsetX - Sentry^.Radius) / jumpTime, Sentry^.dX);
+        Sentry^.State := Sentry^.State or gstHHJumping;
         MakeSentryJump := true;
     end;
 end;
@@ -7397,6 +7398,7 @@
 
 procedure doStepSentryLand(Gear: PGear);
 var HHGear: PGear;
+    land: Word;
 const sentry_Idle = 0;
     sentry_Walking = 1;
     sentry_Aiming = 2;
@@ -7411,7 +7413,9 @@
     if CheckSentryDestroyed(Gear, sentry_Reloading) then
         exit;
 
-    if Gear^.dY.isNegative or (TestCollisionYwithGear(Gear, 1) = 0) then
+    land := TestCollisionYwithGear(Gear, 1);
+    if Gear^.dY.isNegative or (land = 0) or
+        ((Gear^.dY.QWordValue > _0_01.QWordValue) and ((Gear^.State and gstHHJumping) = 0)) then
     begin
         DeleteCI(Gear);
         doStepFallingGear(Gear);
@@ -7420,7 +7424,12 @@
         exit;
     end
     else
+    begin
         AddCI(Gear);
+        Gear^.State := Gear^.State and (not gstHHJumping);
+        Gear^.dX := SignAs(_0, Gear^.dX);
+        Gear^.dY := SignAs(_0, Gear^.dY);
+    end;
 
     if Gear^.Timer > 0 then dec(Gear^.Timer);
 
--- a/hedgewars/uGearsList.pas	Tue May 10 00:19:52 2022 +0300
+++ b/hedgewars/uGearsList.pas	Tue May 10 02:59:11 2022 +0300
@@ -839,8 +839,8 @@
         gtSentry: begin
                 gear^.Radius:= cHHRadius;
                 gear^.Health:= cSentryHealth;
-                gear^.Friction:= _0_93;
-                gear^.Elasticity:= _0_05;
+                gear^.Friction:= _0_999;
+                gear^.Elasticity:= _0_35;
                 gear^.Density:= _3;
                 gear^.Tag:= 0;
                 gear^.Timer:= 1000;
--- a/hedgewars/uGearsUtils.pas	Tue May 10 00:19:52 2022 +0300
+++ b/hedgewars/uGearsUtils.pas	Tue May 10 02:59:11 2022 +0300
@@ -183,6 +183,8 @@
                                     if (not GameOver) then
                                         Gear^.State:= (Gear^.State and (not gstWinner));
                                     end;
+                                if Gear^.Kind = gtSentry then
+                                    Gear^.State:= Gear^.State and (not gstHHJumping);
                                 Gear^.Active:= true;
                                 if Gear^.Kind <> gtFlame then FollowGear:= Gear;
                                 if Gear^.Kind = gtAirMine then