Apply wind while roping too (with the game flag set)
authornemo
Fri, 12 Nov 2010 23:29:11 -0500
changeset 4301 4866cc130b8d
parent 4299 d23f8a25fc3f
child 4303 9057d4d85830
Apply wind while roping too (with the game flag set)
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
--- a/hedgewars/GSHandlers.inc	Fri Nov 12 21:30:00 2010 -0500
+++ b/hedgewars/GSHandlers.inc	Fri Nov 12 23:29:11 2010 -0500
@@ -320,7 +320,7 @@
     if isFalling then 
         begin
         Gear^.dY := Gear^.dY + cGravity;
-        if (GameFlags and gfMoreWind) <> 0 then Gear^.dX := Gear^.dX + cWindSpeed * _16 / max(12,sqr(Gear^.Radius));
+        if (GameFlags and gfMoreWind) <> 0 then Gear^.dX := Gear^.dX + cWindSpeed * _16 / max(12,sqr(Gear^.Radius))
         end;
 
     Gear^.X := Gear^.X + Gear^.dX;
@@ -1110,6 +1110,7 @@
     HHGear^.X := HHGear^.X + HHGear^.dX;
     HHGear^.Y := HHGear^.Y + HHGear^.dY;
     HHGear^.dY := HHGear^.dY + cGravity;
+    if (GameFlags and gfMoreWind) <> 0 then HHGear^.dX := HHGear^.dX + cWindSpeed * _0_2;
 
     if (Gear^.Message and gmAttack) <> 0 then
     begin
@@ -1172,7 +1173,11 @@
     else
         if (Gear^.Message and gmRight <> 0) then HHGear^.dX := HHGear^.dX + _0_0002;
 
-    if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY := HHGear^.dY + cGravity;
+    if not TestCollisionYwithGear(HHGear, 1) then
+        begin
+        HHGear^.dY := HHGear^.dY + cGravity;
+        if (GameFlags and gfMoreWind) <> 0 then HHGear^.dX := HHGear^.dX + cWindSpeed * _0_2
+        end;
 
     ropeDx := HHGear^.X - Gear^.X;
     // vector between hedgehog and rope attaching point
@@ -1373,7 +1378,8 @@
             begin
             HHGear^.Y := HHGear^.Y + HHGear^.dY;
             Gear^.Y := Gear^.Y + HHGear^.dY;
-            HHGear^.dY := HHGear^.dY + cGravity
+            HHGear^.dY := HHGear^.dY + cGravity;
+            if (GameFlags and gfMoreWind) <> 0 then HHGear^.dX := HHGear^.dX + cWindSpeed * _0_2
             end;
 
         tt := Gear^.Elasticity;
@@ -3089,7 +3095,6 @@
             Gear^.Timer := GameTicks
             end
         end;
-    if not isUnderwater and ((GameFlags and gfMoreWind) <> 0) then HHGear^.dX := HHGear^.dX + cWindSpeed * _16 / sqr(cHHRadius);
 
     // erases them all at once :-/
     if (Gear^.Timer <> 0) and (GameTicks - Gear^.Timer > 250) then
@@ -3221,7 +3226,6 @@
         dec(Gear^.Health, fuel div 5);
         Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight));
         end;
-    if (GameFlags and gfMoreWind) <> 0 then HHGear^.dX := HHGear^.dX + cWindSpeed * _16 / sqr(cHHRadius);
 
     if Gear^.Health < 0 then Gear^.Health := 0;
     if ((GameTicks and $FF) = 0) and (Gear^.Health < 500) then
--- a/hedgewars/HHHandlers.inc	Fri Nov 12 21:30:00 2010 -0500
+++ b/hedgewars/HHHandlers.inc	Fri Nov 12 23:29:11 2010 -0500
@@ -662,11 +662,22 @@
    if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then Gear^.dY:= _0;
    Gear^.State:= Gear^.State or gstMoving;
    if isUnderwater then Gear^.dY:= Gear^.dY + cGravity / _2
-   else Gear^.dY:= Gear^.dY + cGravity
+   else
+       begin
+       Gear^.dY:= Gear^.dY + cGravity;
+// this set of circumstances could be less complex if jumping was more clearly identified
+       if ((GameFlags and gfMoreWind) <> 0) and 
+          (Gear^.Damage <> 0) or
+          ((CurAmmoGear <> nil) and
+            ((CurAmmoGear^.AmmoType = amJetpack) or
+            (CurAmmoGear^.AmmoType = amBirdy))) or
+          ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue)
+          then Gear^.dX := Gear^.dX + cWindSpeed * _0_2
+       end
    end 
 else
    begin
-   if ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_55)
+   if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue)
       and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX);
 
    if not Gear^.dY.isNegative then