Fix Baseball, whip, firepunch attacking on slope
authorunc0rr
Mon, 09 Jun 2008 15:08:54 +0000
changeset 981 e883baf3a458
parent 980 20128e98988b
child 982 bbf382a5fe73
Fix Baseball, whip, firepunch attacking on slope
hedgewars/uGears.pas
--- a/hedgewars/uGears.pas	Mon Jun 09 15:02:49 2008 +0000
+++ b/hedgewars/uGears.pas	Mon Jun 09 15:08:54 2008 +0000
@@ -973,28 +973,39 @@
 t:= CheckGearsCollision(Ammo);
 i:= t^.Count;
 while i > 0 do
-    begin
-    dec(i);
-    if (t^.ar[i]^.State and gstNoDamage) = 0 then
-       case t^.ar[i]^.Kind of
-           gtHedgehog,
-               gtMine,
-             gtTarget,
-               gtCase: begin
-                       inc(t^.ar[i]^.Damage, Damage);
+	begin
+	dec(i);
+	if (t^.ar[i]^.State and gstNoDamage) = 0 then
+		case t^.ar[i]^.Kind of
+			gtHedgehog,
+			gtMine,
+			gtTarget,
+			gtCase: begin
+					inc(t^.ar[i]^.Damage, Damage);
+
+					if t^.ar[i]^.Kind = gtHedgehog then
+						AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, t^.ar[i]);
 
-                       if t^.ar[i]^.Kind = gtHedgehog then
-                          AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, t^.ar[i]);
+					DeleteCI(t^.ar[i]);
+					t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01;
+					t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01;
+					t^.ar[i]^.Active:= true;
+					t^.ar[i]^.State:= t^.ar[i]^.State or gstMoving;
 
-                       DeleteCI(t^.ar[i]);
-                       t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01;
-                       t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01;
-                       t^.ar[i]^.Active:= true;
-                       t^.ar[i]^.State:= t^.ar[i]^.State or gstMoving;
-                       FollowGear:= t^.ar[i]
-                       end;
-           end
-    end;
+(*					if TestCollisionXwithGear(t^.ar[i], hwSign(t^.ar[i]^.dX)) then
+						begin
+						if not (TestCollisionXwithXYShift(t^.ar[i], _0, -3, hwSign(t^.ar[i]^.dX))
+							or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1;
+						if not (TestCollisionXwithXYShift(t^.ar[i], _0, -2, hwSign(t^.ar[i]^.dX))
+							or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1;
+						if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX))
+							or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1;
+						end;
+*)					
+					FollowGear:= t^.ar[i]
+					end;
+		end
+	end;
 SetAllToActive
 end;