# HG changeset patch # User Wuzzy # Date 1533249590 -7200 # Node ID 212036414957fdac5c7739e1c86566a2bd45e0a1 # Parent ba6648614cd77ad7bd5cea09f64fa8b6019bc323 Make cake bounce off bounce edge, stop cake at wrap edge to prevent other bug The "other bug" is that the cake just walks through terrain when it hits the wrap world edge. This behaviour is even worse. diff -r ba6648614cd7 -r 212036414957 ChangeLog.txt --- a/ChangeLog.txt Fri Aug 03 15:34:23 2018 -0400 +++ b/ChangeLog.txt Fri Aug 03 00:39:50 2018 +0200 @@ -14,6 +14,8 @@ * Fix hammer and pickhammer not digging correctly at wrap world edge * Fix freezer ray not working through wrap world edge * Fix freezer ray going through bounce world edge + * Fix cake walking through bounce world edge + * Cake now stops at wrap world edge instead of walking through land (temporary fix) * Laser sight now works properly through wrap world edge * Fix extreme amounts of droplets when shooting with minigun into ocean world edge * Fix hog being unable to walk after using sniper rifle without firing both shots diff -r ba6648614cd7 -r 212036414957 hedgewars/uGearsHandlers.pas --- a/hedgewars/uGearsHandlers.pas Fri Aug 03 15:34:23 2018 -0400 +++ b/hedgewars/uGearsHandlers.pas Fri Aug 03 00:39:50 2018 +0200 @@ -27,7 +27,7 @@ implementation -uses SDLh, uFloat, uCollisions; +uses SDLh, uFloat, uCollisions, uVariables, uGearsUtils; @@ -95,6 +95,28 @@ end end; + // Handle world wrap and bounce edge manually + if (WorldEdge = weWrap) and + ((hwRound(Gear^.X) <= LongInt(leftX)) or (hwRound(Gear^.X) >= LongInt(rightX))) then + begin + LeftImpactTimer:= 150; + RightImpactTimer:= 150; + Gear^.WDTimer:= 4; + Gear^.Karma:= 2; + end + else if (WorldEdge = weBounce) and + (((hwRound(Gear^.X) - Gear^.Radius) < LongInt(leftX)) or ((hwRound(Gear^.X) + Gear^.Radius) > LongInt(rightX))) then + begin + if (hwRound(Gear^.X) - Gear^.Radius < LongInt(leftX)) then + LeftImpactTimer:= 333 + else + RightImpactTimer:= 333; + Gear^.Karma:= 1; + Gear^.WDTimer:= 0; + if (Gear^.Radius > 2) and (Gear^.dX.QWordValue > _0_001.QWordValue) then + AddBounceEffectForGear(Gear); + end; + cakeStep:= Gear^.WDTimer < 4 end; diff -r ba6648614cd7 -r 212036414957 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Fri Aug 03 15:34:23 2018 -0400 +++ b/hedgewars/uGearsHandlersMess.pas Fri Aug 03 00:39:50 2018 +0200 @@ -3559,6 +3559,23 @@ if not cakeStep(Gear) then Gear^.doStep:= @doStepCakeFall; + if (Gear^.Karma = 1) then + begin + // Cake hit bouncy edge, turn around + Gear^.dX.isNegative := (not Gear^.dX.isNegative); + Gear^.WDTimer := 0; + Gear^.Angle := (LongInt(Gear^.Angle) + 2) and 3; + Gear^.Karma := 0; + end + else if (Gear^.Karma = 2) then + begin + // Cake doesn't know how walk through world wrap + // so it gives up and stops. + // TODO: Teach cake how to deal with world wrap. + Gear^.Health := 0; + Gear^.Karma := 0; + end; + if Gear^.Tag = 0 then begin cakeData:= PCakeData(Gear^.Data);