// // Apply object movement to contacting peds // void CDeathmatchObject::UpdateContacting(const CVector& vecCenterOfRotation, const CVector& vecFrameTranslation, const CVector& vecFrameRotation) { bool bHasRotation = (vecFrameRotation.fX != 0 || vecFrameRotation.fY != 0 || vecFrameRotation.fZ != 0); bool bHasTranslation = (vecFrameTranslation.fX != 0 || vecFrameTranslation.fY != 0 || vecFrameTranslation.fZ != 0); // Early out if no orientation change here if (!bHasRotation && !bHasTranslation) return; // Step through each contacting ped list<CClientPed*>::iterator iter = m_Contacts.begin(); for (; iter != m_Contacts.end(); ++iter) { CClientPed* pPed = *iter; // Do not move the ped if it is frozen if (pPed->IsFrozen()) continue; // Get ped start position CVector vecPlayerPosition; pPed->GetPosition(vecPlayerPosition); // Apply rotation effect on position if (bHasRotation) { vecPlayerPosition -= vecCenterOfRotation; RotateVector(vecPlayerPosition, CVector(-vecFrameRotation.fX, -vecFrameRotation.fY, -vecFrameRotation.fZ)); vecPlayerPosition += vecCenterOfRotation; } // Apply translation vecPlayerPosition += vecFrameTranslation; pPed->SetPosition(vecPlayerPosition); // Also change ped facing direction if (vecFrameRotation.fZ != 0) { float fRotationZ = pPed->GetCurrentRotation(); pPed->SetCurrentRotation(fRotationZ + vecFrameRotation.fZ); } } // Look in attached objects for more ped contacts for (uint i = 0; i < m_AttachedEntities.size(); ++i) { CClientEntity* pEntity = m_AttachedEntities[i]; if (IS_OBJECT(pEntity)) { CDeathmatchObject* pObject = static_cast<CDeathmatchObject*>(pEntity); pObject->UpdateContacting(vecCenterOfRotation, vecFrameTranslation, vecFrameRotation); } } }