# HG changeset patch # User nemo # Date 1428266499 14400 # Node ID bce67defd8049132cbbb8dd623dee921a0460f31 # Parent b085cf83ab4c8b0509e85a7eddfa75bc94676718 Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter. diff -r b085cf83ab4c -r bce67defd804 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Sun Apr 05 12:44:54 2015 +0900 +++ b/hedgewars/uGearsHandlersMess.pas Sun Apr 05 16:41:39 2015 -0400 @@ -437,7 +437,26 @@ Gear^.dY := tdX*cElastic end; - Gear^.dY.isNegative := not tdY.isNegative; + Gear^.dX.isNegative:= tdX.isNegative; + Gear^.dY.isNegative:= tdY.isNegative; + if (collV > 0) and (collH > 0) and (not tdX.isNegative) and (not tdY.isNegative) then + begin + Gear^.dX.isNegative := true; + Gear^.dY.isNegative := true + end + else if (collV > 0) and (collH < 0) and (tdX.isNegative or tdY.isNegative) then + begin + Gear^.dY.isNegative := not tdY.isNegative; + if not tdY.isNegative then Gear^.dX.isNegative := false + end + else if (collV < 0) and (collH > 0) and (not tdX.isNegative) then + begin + Gear^.dX.isNegative := true; + Gear^.dY.isNegative := false + end + else if (collV < 0) and (collH < 0) and tdX.isNegative and tdY.isNegative then + Gear^.dX.isNegative := false; + isFalling := false; Gear^.AdvBounce := 10; end; @@ -463,7 +482,10 @@ Gear^.State := Gear^.State or gstMoving; if ((xland or land) and lfBouncy <> 0) and (Gear^.dX.QWordValue < _0_15.QWordValue) and (Gear^.dY.QWordValue < _0_15.QWordValue) then + begin Gear^.State := Gear^.State or gstCollision; + AddFileLog('no more bounce for you!'); + end; if ((xland or land) and lfBouncy <> 0) and (Gear^.Radius >= 3) and ((Gear^.dX.QWordValue > _0_15.QWordValue) or (Gear^.dY.QWordValue > _0_15.QWordValue)) then @@ -3484,6 +3506,7 @@ begin StopSoundChan(Gear^.SoundChannel); Gear^.Tag := 1; + Gear^.AdvBounce:= 50; Gear^.doStep := @doStepDrill end; diff -r b085cf83ab4c -r bce67defd804 hedgewars/uGearsHedgehog.pas --- a/hedgewars/uGearsHedgehog.pas Sun Apr 05 12:44:54 2015 +0900 +++ b/hedgewars/uGearsHedgehog.pas Sun Apr 05 16:41:39 2015 -0400 @@ -895,6 +895,7 @@ if land and lfBouncy <> 0 then begin doStepFallingGear(Gear); + Gear^.AdvBounce:= 1; Gear^.dX:= Gear^.dX * _0_8 end; if (land and lfBouncy = 0) or (Gear^.State and gstCollision <> 0) then @@ -935,6 +936,7 @@ if land and lfBouncy <> 0 then begin doStepFallingGear(Gear); + Gear^.AdvBounce:= 1; // hogs for some reason have very low friction. slippery little buggers Gear^.dX:= Gear^.dX * _0_8 end; @@ -1072,6 +1074,7 @@ land:= TestCollisionYwithXYShift(Gear, 0, 1, 1); if land and lfBouncy <> 0 then doStepFallingGear(Gear); + Gear^.AdvBounce:= 1; if (land <> 0) and ((land and lfBouncy = 0) or (Gear^.State and gstCollision <> 0)) then begin