Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
--- a/hedgewars/uCollisions.pas Sat Nov 30 20:53:54 2013 +0400
+++ b/hedgewars/uCollisions.pas Sat Nov 30 22:34:39 2013 -0500
@@ -157,7 +157,7 @@
repeat
if (y and LAND_HEIGHT_MASK) = 0 then
if Land[y, x] and Gear^.CollisionMask <> 0 then
- exit(Land[y, x]);
+ exit(Land[y, x] and Gear^.CollisionMask);
inc(y)
until (y > i);
end;
@@ -187,8 +187,7 @@
if (x and LAND_WIDTH_MASK) = 0 then
if Land[y, x] and Gear^.CollisionMask <> 0 then
begin
- TestCollisionYwithGear:= Land[y, x];
- exit(Land[y, x]);
+ exit(Land[y, x] and Gear^.CollisionMask)
end;
inc(x)
until (x > i);
@@ -213,10 +212,10 @@
i:= y + Gear^.Radius * 2 - 2;
repeat
if (y and LAND_HEIGHT_MASK) = 0 then
- if Land[y, x] > 255 then
- exit(Land[y, x])
- else if Land[y, x] <> 0 then
- pixel:= Land[y, x];
+ if Land[y, x] and Gear^.CollisionMask > 255 then
+ exit(Land[y, x] and Gear^.CollisionMask)
+ else if Land[y, x] and Gear^.CollisionMask <> 0 then
+ pixel:= Land[y, x] and Gear^.CollisionMask;
inc(y)
until (y > i);
end;
@@ -276,10 +275,10 @@
repeat
if (x and LAND_WIDTH_MASK) = 0 then
if Land[y, x] > 0 then
- if Land[y, x] > 255 then
- exit(Land[y, x])
+ if Land[y, x] and Gear^.CollisionMask > 255 then
+ exit(Land[y, x] and Gear^.CollisionMask)
else if Land[y, x] <> 0 then
- pixel:= Land[y, x];
+ pixel:= Land[y, x] and Gear^.CollisionMask;
inc(x)
until (x > i);
end;
@@ -350,8 +349,8 @@
i:= y + Gear^.Radius * 2 - 2;
repeat
if (y and LAND_HEIGHT_MASK) = 0 then
- if Land[y, x] > 255 then
- exit(Land[y, x]);
+ if Land[y, x] and Gear^.CollisionMask > 255 then
+ exit(Land[y, x] and Gear^.CollisionMask);
inc(y)
until (y > i);
end;
@@ -373,8 +372,8 @@
i:= x + Gear^.Radius * 2 - 2;
repeat
if (x and LAND_WIDTH_MASK) = 0 then
- if Land[y, x] > 255 then
- exit(Land[y, x]);
+ if Land[y, x] and Gear^.CollisionMask > 255 then
+ exit(Land[y, x] and Gear^.CollisionMask);
inc(x)
until (x > i);
end;
--- a/hedgewars/uGearsHandlersMess.pas Sat Nov 30 20:53:54 2013 +0400
+++ b/hedgewars/uGearsHandlersMess.pas Sat Nov 30 22:34:39 2013 -0500
@@ -325,7 +325,7 @@
if land and lfIce <> 0 then
Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1)
else Gear^.dX := Gear^.dX * Gear^.Friction;
- if land and lfBouncy = 0 then
+ if (Gear^.AdvBounce = 0) or (land and lfBouncy = 0) then
begin
Gear^.dY := - Gear^.dY * Gear^.Elasticity;
Gear^.State := Gear^.State or gstCollision
@@ -350,7 +350,7 @@
else
Gear^.dX := Gear^.dX * Gear^.Friction;
- if land and lfBouncy = 0 then
+ if (Gear^.AdvBounce = 0) or (land and lfBouncy = 0) then
begin
Gear^.dY := - Gear^.dY * Gear^.Elasticity;
Gear^.State := Gear^.State or gstCollision
@@ -373,7 +373,7 @@
if xland <> 0 then
begin
collH := hwSign(Gear^.dX);
- if xland and lfBouncy = 0 then
+ if (Gear^.AdvBounce = 0) or (xland and lfBouncy = 0) then
begin
Gear^.dX := - Gear^.dX * Gear^.Elasticity;
Gear^.dY := Gear^.dY * Gear^.Elasticity;
@@ -392,8 +392,8 @@
end;
//if Gear^.AdvBounce and (collV <>0) and (collH <> 0) and (hwSqr(tdX) + hwSqr(tdY) > _0_08) then
if (collV <> 0) and (collH <> 0) and
- (((Gear^.AdvBounce=1) and ((collV=-1) or ((tdX.QWordValue + tdY.QWordValue) > _0_2.QWordValue))) or
- ((xland or land) and lfBouncy <> 0)) then
+ (((Gear^.AdvBounce=1) and ((collV=-1) or ((tdX.QWordValue + tdY.QWordValue) > _0_2.QWordValue)))) then
+ //or ((xland or land) and lfBouncy <> 0)) then
begin
if (xland or land) and lfBouncy = 0 then
begin
@@ -430,7 +430,7 @@
else
Gear^.State := Gear^.State or gstMoving;
- if ((xland or land) and lfBouncy <> 0) and (Gear^.dX.QWordValue < _0_1.QWordValue) and (Gear^.dY.QWordValue < _0_1.QWordValue) then
+ if ((xland or land) and lfBouncy <> 0) and (Gear^.dX.QWordValue < _0_15.QWordValue) and (Gear^.dY.QWordValue < _0_15.QWordValue) then
Gear^.State := Gear^.State or gstCollision;
if ((xland or land) and lfBouncy <> 0) and
@@ -1697,12 +1697,14 @@
////////////////////////////////////////////////////////////////////////////////
procedure doStepSMine(Gear: PGear);
+ var land: Word;
begin
// TODO: do real calculation?
- if (TestCollisionXwithGear(Gear, 2) <> 0)
- or (TestCollisionYwithGear(Gear,-2) <> 0)
- or (TestCollisionXwithGear(Gear,-2) <> 0)
- or (TestCollisionYwithGear(Gear, 2) <> 0) then
+ land:= TestCollisionXwithGear(Gear, 2);
+ if land = 0 then land:= TestCollisionYwithGear(Gear,-2);
+ if land = 0 then land:= TestCollisionXwithGear(Gear,-2);
+ if land = 0 then land:= TestCollisionYwithGear(Gear, 2);
+ if (land <> 0) and (land and lfBouncy = 0) then
begin
if (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then
begin
--- a/hedgewars/uGearsHedgehog.pas Sat Nov 30 20:53:54 2013 +0400
+++ b/hedgewars/uGearsHedgehog.pas Sat Nov 30 22:34:39 2013 -0500
@@ -20,7 +20,7 @@
unit uGearsHedgehog;
interface
-uses uTypes;
+uses uTypes, uGearsHandlersMess;
procedure doStepHedgehog(Gear: PGear);
procedure AfterAttack;
@@ -857,8 +857,17 @@
isFalling:= (Gear^.dY.isNegative) or (TestCollisionYKick(Gear, 1) = 0);
if isFalling then
begin
- if (Gear^.dY.isNegative) and (TestCollisionYKick(Gear, -1) <> 0) then
- Gear^.dY:= _0;
+ land:= TestCollisionYKick(Gear, -1);
+ if (Gear^.dY.isNegative) and (land <> 0) then
+ begin
+ if land and lfBouncy <> 0 then
+ begin
+ doStepFallingGear(Gear);
+ Gear^.dX:= Gear^.dX * _0_8
+ end;
+ if (land and lfBouncy = 0) or (Gear^.State and gstCollision <> 0) then
+ Gear^.dY:= _0
+ end;
Gear^.State:= Gear^.State or gstMoving;
if (CurrentHedgehog^.Gear = Gear) and (CurrentHedgehog^.Gear^.State and gstHHDriven <> 0) and
(not CurrentTeam^.ExtDriven) and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
@@ -883,19 +892,35 @@
else
begin
land:= TestCollisionYwithGear(Gear, 1);
- if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0)
+ if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0)
+ and ((land and lfBouncy = 0) or (Gear^.State and gstCollision <> 0))
and ((Gear^.State and gstHHJumping) <> 0) then
SetLittle(Gear^.dX);
if not Gear^.dY.isNegative then
begin
+ if land and lfBouncy <> 0 then
+ begin
+ doStepFallingGear(Gear);
+ // hogs for some reason have very low friction. slippery little buggers
+ Gear^.dX:= Gear^.dX * _0_8
+ end;
+
CheckHHDamage(Gear);
- if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery)
- and (Gear^.dX.QWordValue < _0_02.QWordValue) then
- Gear^.dX.isNegative:= not Gear^.dX.isNegative; // landing after high jump
- Gear^.State:= Gear^.State and (not (gstHHJumping or gstHHHJump));
- Gear^.dY:= _0;
+ if (land and lfBouncy = 0) or (Gear^.State and gstCollision <> 0) then
+ begin
+ if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery)
+ and (Gear^.dX.QWordValue < _0_02.QWordValue) then
+ begin
+ if land and lfBouncy <> 0 then
+ Gear^.dY:= _0;
+ Gear^.dX.isNegative:= not Gear^.dX.isNegative // landing after high jump
+ end;
+ Gear^.State:= Gear^.State and (not (gstHHJumping or gstHHHJump));
+ if (land and lfBouncy = 0) or (Gear^.dX.QWordValue < _0_02.QWordValue) then
+ Gear^.dY:= _0
+ end
end
else
Gear^.dY:= Gear^.dY + cGravity;
@@ -1008,12 +1033,18 @@
// ARTILLERY but not being moved by explosions
Gear^.X:= Gear^.X + Gear^.dX;
Gear^.Y:= Gear^.Y + Gear^.dY;
- if (not Gear^.dY.isNegative) and (TestCollisionYKick(Gear, 1) = 0)
- and (TestCollisionYwithXYShift(Gear, 0, 1, 1) <> 0) then
+ if (not Gear^.dY.isNegative) and (TestCollisionYKick(Gear, 1) = 0) then
begin
- CheckHHDamage(Gear);
- Gear^.dY:= _0;
- Gear^.Y:= Gear^.Y + _1
+ land:= TestCollisionYwithXYShift(Gear, 0, 1, 1);
+ if land and lfBouncy <> 0 then
+ doStepFallingGear(Gear);
+
+ if (land <> 0) and ((land and lfBouncy = 0) or (Gear^.State and gstCollision <> 0)) then
+ begin
+ CheckHHDamage(Gear);
+ Gear^.dY:= _0;
+ Gear^.Y:= Gear^.Y + _1
+ end
end;
CheckGearDrowning(Gear);