From f9a4a053885609fe2957c187bebe327f378ee4c6 Mon Sep 17 00:00:00 2001 From: headshot2017 Date: Fri, 9 Feb 2024 03:09:16 -0400 Subject: [PATCH] correct head angle pitch when looking at peds for example at the end of the mission High Noon, Mario will now correctly look at Pulaski instead of looking upwards --- mario.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mario.cpp b/mario.cpp index 0c2637f..365c6ad 100644 --- a/mario.cpp +++ b/mario.cpp @@ -923,8 +923,17 @@ void marioTick(float dt) // part 2: pitch if (!ped->m_nPedFlags.bInVehicle) { - float dist = DistanceBetweenPoints(CVector2D(marioCurrPos), CVector2D(targetPos)) * 2.f; - int Zsign = -sign(targetPos.z - marioCurrPos.z); + RwV3d headPosRw = targetPos.ToRwV3d(); + if (lookAt->m_bEntityExist && lookAt->m_pEntity->m_nType == ENTITY_TYPE_PED) + { + const auto hier = GetAnimHierarchyFromSkinClump(lookAt->m_pEntity->m_pRwClump); + if (hier) + headPosRw = *RwMatrixGetPos(&RpHAnimHierarchyGetMatrixArray(hier)[RpHAnimIDGetIndex(hier, BONE_HEAD)]); + else + ((CPed*)lookAt->m_pEntity)->GetBonePosition(headPosRw, BONE_NECK, false); + } + float dist = DistanceBetweenPoints(CVector2D(marioCurrPos), CVector2D(headPosRw)) * 2.f; + int Zsign = -sign(headPosRw.z - marioCurrPos.z); headAngleTarget[0] = (dist) ? (M_PI_2 * Zsign) / dist : 0; if (headAngleTarget[0] < -M_PI || headAngleTarget[0] > M_PI) headAngleTarget[0] = 0; }