@@ -923,12 +923,14 @@ DEFINE_HOOK(0x71ADE4, TemporalClass_Release_SlaveTargetFix, 0x5)
923
923
// which means it didn't consider the actual speed of the unit. Now we check it and the units won't get stuck
924
924
// even at high speeds - NetsuNegi
925
925
926
- DEFINE_HOOK (0x7295C5 , TunnelLocomotionClass_ProcessDigging_SlowdownDistance, 0x9 )
926
+ DEFINE_HOOK (0x72958E , TunnelLocomotionClass_ProcessDigging_SlowdownDistance, 0x8 )
927
927
{
928
928
enum { KeepMoving = 0x72980F , CloseEnough = 0x7295CE };
929
929
930
930
GET (TunnelLocomotionClass* const , pLoco, ESI);
931
- GET (int const , distance, EAX);
931
+
932
+ auto & currLoc = pLoco->LinkedTo ->Location ;
933
+ int distance = (int ) CoordStruct{currLoc.X - pLoco->Coords .X , currLoc.Y - pLoco->Coords .Y ,0 }.Magnitude () ;
932
934
933
935
// The movement speed was actually also hardcoded here to 19, so the distance check made sense
934
936
// It can now be customized globally or per TechnoType however - Starkku
@@ -943,9 +945,14 @@ DEFINE_HOOK(0x7295C5, TunnelLocomotionClass_ProcessDigging_SlowdownDistance, 0x9
943
945
speed = pLoco->LinkedTo ->GetCurrentSpeed ();
944
946
pType->Speed = maxSpeed;
945
947
946
- TunnelLocomotionClass::TunnelMovementSpeed = speed;
947
-
948
- return distance >= speed + 1 ? KeepMoving : CloseEnough;
948
+ if (distance > speed)
949
+ {
950
+ REF_STACK (CoordStruct, newLoc, STACK_OFFSET (0x40 , -0xC ));
951
+ double angle = -Math::atan2 (currLoc.Y - pLoco->Coords .Y , pLoco->Coords .X - currLoc.X );
952
+ newLoc = currLoc + CoordStruct { int ((double )speed * Math::cos (angle)), int ((double )speed * Math::sin (angle)), 0 };
953
+ return 0x7298D3 ;
954
+ }
955
+ return 0x7295CE ;
949
956
}
950
957
951
958
DEFINE_HOOK (0x75BD70 , WalkLocomotionClass_ProcessMoving_SlowdownDistance, 0x9 )
0 commit comments