88// Jumpjets stuck at FireError::FACING because Jumpjet has its own facing just for JumpjetTurnRate
99// We should not touch the linked unit's PrimaryFacing when it's moving and just let the loco sync this shit in 54D692
1010// The body facing never actually turns, it just syncs
11+ // Whatever, now let's totally forget PrimaryFacing and only use that loco facing
1112DEFINE_HOOK (0x736F78 , UnitClass_UpdateFiring_FireErrorIsFACING, 0x6 )
1213{
1314 GET (UnitClass* const , pThis, ESI);
@@ -176,7 +177,7 @@ DEFINE_HOOK(0x70B649, TechnoClass_RigidBodyDynamics_NoTiltCrashBlyat, 0x6)
176177}
177178
178179// Just rewrite this completely to avoid headache
179- Matrix3D* __stdcall JumpjetLocomotionClass_Draw_Matrix (ILocomotion* iloco, Matrix3D* ret, VoxelIndexKey * pIndex)
180+ Matrix3D* __stdcall JumpjetLocomotionClass_Draw_Matrix (ILocomotion* iloco, Matrix3D* ret, int * pIndex)
180181{
181182 __assume (iloco != nullptr );
182183 auto const pThis = static_cast <JumpjetLocomotionClass*>(iloco);
@@ -185,19 +186,15 @@ Matrix3D* __stdcall JumpjetLocomotionClass_Draw_Matrix(ILocomotion* iloco, Matri
185186 bool const onGround = pThis->State == JumpjetLocomotionClass::State::Grounded;
186187 // Man, what can I say, you don't want to stick your rotor into the ground
187188 auto slope_idx = MapClass::Instance->GetCellAt (linked->Location )->SlopeIndex ;
188-
189- if (onGround && pIndex && pIndex->Is_Valid_Key ())
190- *(int *)(pIndex) = slope_idx + (*(int *)(pIndex) << 6 );
191-
192- *ret = Matrix3D::VoxelRampMatrix[onGround ? slope_idx : 0 ] * pThis->LocomotionClass ::Draw_Matrix (pIndex);
193-
189+ *ret = Matrix3D::VoxelRampMatrix[onGround ? slope_idx : 0 ];
190+ auto curf = pThis->LocomotionFacing .Current ();
191+ ret->RotateZ ((float )curf.GetRadian <32 >());
194192 float arf = linked->AngleRotatedForwards ;
195193 float ars = linked->AngleRotatedSideways ;
196194
197195 if (std::abs (ars) >= 0.005 || std::abs (arf) >= 0.005 )
198196 {
199- if (pIndex)
200- pIndex->Invalidate ();
197+ if (pIndex) *pIndex = -1 ;
201198
202199 if (onGround)
203200 {
@@ -218,6 +215,14 @@ Matrix3D* __stdcall JumpjetLocomotionClass_Draw_Matrix(ILocomotion* iloco, Matri
218215 ret->RotateY (arf);
219216 }
220217 }
218+
219+ if (pIndex && *pIndex != -1 )
220+ {
221+ if (onGround) *pIndex = slope_idx + (*pIndex << 6 );
222+ *pIndex *= 32 ;
223+ *pIndex |= curf.GetFacing <32 >();
224+ }
225+
221226 return ret;
222227}
223228
0 commit comments