From ec1b91e5270b1c91885a5e8000a5ff8286aee140 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 16 May 2020 05:06:51 +0300 Subject: Remove unused audio enum --- src/peds/Ped.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index fd8fd540..a1709fd7 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -441,8 +441,8 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) m_nPedType = pedType; m_lastSoundStart = 0; m_soundStart = 0; - m_lastQueuedSound = SOUND_TOTAL_PED_SOUNDS; - m_queuedSound = SOUND_TOTAL_PED_SOUNDS; + m_lastQueuedSound = SOUND_NO_SOUND; + m_queuedSound = SOUND_NO_SOUND; m_objective = OBJECTIVE_NONE; m_prevObjective = OBJECTIVE_NONE; CharCreatedBy = RANDOM_CHAR; @@ -5537,7 +5537,7 @@ CPed::PlayHitSound(CPed *hitTo) S42 = SOUND_FIGHT_PUNCH_FROM_BEHIND_42, S43 = SOUND_FIGHT_KNEE_OR_KICK_43, S44 = SOUND_FIGHT_KICK_44, - NO_SND = SOUND_TOTAL_PED_SOUNDS + NO_SND = SOUND_NO_SOUND }; uint16 hitSoundsByFightMoves[12][10] = { {S39,S42,S43,S43,S39,S39,S39,S39,S39,S42}, @@ -16283,7 +16283,7 @@ CPed::ServiceTalking(void) } else { m_queuedSound = SOUND_PED_BOMBER; } - if (m_queuedSound != SOUND_TOTAL_PED_SOUNDS) { + if (m_queuedSound != SOUND_NO_SOUND) { if (m_queuedSound == SOUND_PED_DEATH) m_soundStart = CTimer::GetTimeInMilliseconds() - 1; @@ -16295,7 +16295,7 @@ CPed::ServiceTalking(void) + CTimer::GetTimeInMilliseconds() + CGeneral::GetRandomNumberInRange(0, CommentWaitTime[m_queuedSound - SOUND_PED_DEATH].m_nOverrideFixedDelayTime); m_lastQueuedSound = m_queuedSound; - m_queuedSound = SOUND_TOTAL_PED_SOUNDS; + m_queuedSound = SOUND_NO_SOUND; } } } -- cgit v1.2.3 From 0c231663188ff4b639549c1be3c6f08df9a5afe1 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 16 May 2020 10:33:19 +0200 Subject: changed CPedIK names --- src/peds/Ped.cpp | 30 +++++----- src/peds/PedIK.cpp | 160 ++++++++++++++++++++++++++--------------------------- src/peds/PedIK.h | 12 ++-- 3 files changed, 101 insertions(+), 101 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index a1709fd7..d48a6a2f 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -2514,37 +2514,37 @@ CPed::CalculateNewVelocity(void) if ((!idleAssoc || idleAssoc->blendAmount < 0.5f) && !fightAssoc) { #endif LimbOrientation newUpperLegs; - newUpperLegs.phi = localWalkAngle; + newUpperLegs.yaw = localWalkAngle; - if (newUpperLegs.phi < -DEGTORAD(100.0f)) { - newUpperLegs.phi += PI; - } else if (newUpperLegs.phi > DEGTORAD(100.0f)) { - newUpperLegs.phi -= PI; + if (newUpperLegs.yaw < -DEGTORAD(100.0f)) { + newUpperLegs.yaw += PI; + } else if (newUpperLegs.yaw > DEGTORAD(100.0f)) { + newUpperLegs.yaw -= PI; } - if (newUpperLegs.phi > -DEGTORAD(50.0f) && newUpperLegs.phi < DEGTORAD(50.0f)) { + if (newUpperLegs.yaw > -DEGTORAD(50.0f) && newUpperLegs.yaw < DEGTORAD(50.0f)) { #ifdef PED_SKIN if(IsClumpSkinned(GetClump())){ /* // this looks shit - newUpperLegs.theta = 0.0f; + newUpperLegs.pitch = 0.0f; RwV3d axis = { -1.0f, 0.0f, 0.0f }; - RtQuatRotate(&m_pFrames[PED_UPPERLEGL]->hanimFrame->q, &axis, RADTODEG(newUpperLegs.phi), rwCOMBINEPRECONCAT); - RtQuatRotate(&m_pFrames[PED_UPPERLEGR]->hanimFrame->q, &axis, RADTODEG(newUpperLegs.phi), rwCOMBINEPRECONCAT); + RtQuatRotate(&m_pFrames[PED_UPPERLEGL]->hanimFrame->q, &axis, RADTODEG(newUpperLegs.yaw), rwCOMBINEPRECONCAT); + RtQuatRotate(&m_pFrames[PED_UPPERLEGR]->hanimFrame->q, &axis, RADTODEG(newUpperLegs.yaw), rwCOMBINEPRECONCAT); */ - newUpperLegs.theta = 0.1f; + newUpperLegs.pitch = 0.1f; RwV3d Xaxis = { 1.0f, 0.0f, 0.0f }; RwV3d Zaxis = { 0.0f, 0.0f, 1.0f }; - RtQuatRotate(&m_pFrames[PED_UPPERLEGL]->hanimFrame->q, &Zaxis, RADTODEG(newUpperLegs.theta), rwCOMBINEPOSTCONCAT); - RtQuatRotate(&m_pFrames[PED_UPPERLEGL]->hanimFrame->q, &Xaxis, RADTODEG(newUpperLegs.phi), rwCOMBINEPOSTCONCAT); - RtQuatRotate(&m_pFrames[PED_UPPERLEGR]->hanimFrame->q, &Zaxis, RADTODEG(newUpperLegs.theta), rwCOMBINEPOSTCONCAT); - RtQuatRotate(&m_pFrames[PED_UPPERLEGR]->hanimFrame->q, &Xaxis, RADTODEG(newUpperLegs.phi), rwCOMBINEPOSTCONCAT); + RtQuatRotate(&m_pFrames[PED_UPPERLEGL]->hanimFrame->q, &Zaxis, RADTODEG(newUpperLegs.pitch), rwCOMBINEPOSTCONCAT); + RtQuatRotate(&m_pFrames[PED_UPPERLEGL]->hanimFrame->q, &Xaxis, RADTODEG(newUpperLegs.yaw), rwCOMBINEPOSTCONCAT); + RtQuatRotate(&m_pFrames[PED_UPPERLEGR]->hanimFrame->q, &Zaxis, RADTODEG(newUpperLegs.pitch), rwCOMBINEPOSTCONCAT); + RtQuatRotate(&m_pFrames[PED_UPPERLEGR]->hanimFrame->q, &Xaxis, RADTODEG(newUpperLegs.yaw), rwCOMBINEPOSTCONCAT); bDontAcceptIKLookAts = true; }else #endif { - newUpperLegs.theta = 0.0f; + newUpperLegs.pitch = 0.0f; m_pedIK.RotateTorso(m_pFrames[PED_UPPERLEGL], &newUpperLegs, false); m_pedIK.RotateTorso(m_pFrames[PED_UPPERLEGR], &newUpperLegs, false); } diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp index ae9a85b4..ebd41296 100644 --- a/src/peds/PedIK.cpp +++ b/src/peds/PedIK.cpp @@ -21,14 +21,14 @@ CPedIK::CPedIK(CPed *ped) { m_ped = ped; m_flags = 0; - m_headOrient.phi = 0.0f; - m_headOrient.theta = 0.0f; - m_torsoOrient.phi = 0.0f; - m_torsoOrient.theta = 0.0f; - m_upperArmOrient.phi = 0.0f; - m_upperArmOrient.theta = 0.0f; - m_lowerArmOrient.phi = 0.0f; - m_lowerArmOrient.theta = 0.0f; + m_headOrient.yaw = 0.0f; + m_headOrient.pitch = 0.0f; + m_torsoOrient.yaw = 0.0f; + m_torsoOrient.pitch = 0.0f; + m_upperArmOrient.yaw = 0.0f; + m_upperArmOrient.pitch = 0.0f; + m_lowerArmOrient.yaw = 0.0f; + m_lowerArmOrient.pitch = 0.0f; } #ifdef PED_SKIN @@ -55,8 +55,8 @@ CPedIK::RotateTorso(AnimBlendFrameData *node, LimbOrientation *limb, bool change RtQuat *q = &node->hanimFrame->q; #ifndef FIX_BUGS // this is what the game does (also VC), but it does not look great - RtQuatRotate(q, &XaxisIK, RADTODEG(limb->phi), rwCOMBINEPRECONCAT); - RtQuatRotate(q, &ZaxisIK, RADTODEG(limb->theta), rwCOMBINEPRECONCAT); // pitch + RtQuatRotate(q, &XaxisIK, RADTODEG(limb->yaw), rwCOMBINEPRECONCAT); + RtQuatRotate(q, &ZaxisIK, RADTODEG(limb->pitch), rwCOMBINEPRECONCAT); // pitch #else // copied the code from the non-skinned case // this seems to work ok @@ -78,8 +78,8 @@ CPedIK::RotateTorso(AnimBlendFrameData *node, LimbOrientation *limb, bool change vec2.z = -(c*mat->at.x + s*mat->at.y); // Not sure what exactly to do here - RtQuatRotate(q, &vec1, RADTODEG(limb->phi), rwCOMBINEPRECONCAT); - RtQuatRotate(q, &vec2, RADTODEG(limb->theta), rwCOMBINEPRECONCAT); + RtQuatRotate(q, &vec1, RADTODEG(limb->yaw), rwCOMBINEPRECONCAT); + RtQuatRotate(q, &vec2, RADTODEG(limb->pitch), rwCOMBINEPRECONCAT); #endif m_ped->bDontAcceptIKLookAts = true; }else @@ -122,14 +122,14 @@ CPedIK::RotateTorso(AnimBlendFrameData *node, LimbOrientation *limb, bool change float curYaw, curPitch; ExtractYawAndPitchWorld(mat, &curYaw, &curPitch); - RwMatrixRotate(RwFrameGetMatrix(f), &rightVector, RADTODEG(limb->theta), rwCOMBINEPOSTCONCAT); - RwMatrixRotate(RwFrameGetMatrix(f), &upVector, RADTODEG(limb->phi - (curYaw - m_ped->m_fRotationCur)), rwCOMBINEPOSTCONCAT); + RwMatrixRotate(RwFrameGetMatrix(f), &rightVector, RADTODEG(limb->pitch), rwCOMBINEPOSTCONCAT); + RwMatrixRotate(RwFrameGetMatrix(f), &upVector, RADTODEG(limb->yaw - (curYaw - m_ped->m_fRotationCur)), rwCOMBINEPOSTCONCAT); RwMatrixRotate(RwFrameGetMatrix(f), &forwardVector, RADTODEG(alpha), rwCOMBINEPOSTCONCAT); }else{ // pitch - RwMatrixRotate(RwFrameGetMatrix(f), &rightVector, RADTODEG(limb->theta), rwCOMBINEPOSTCONCAT); + RwMatrixRotate(RwFrameGetMatrix(f), &rightVector, RADTODEG(limb->pitch), rwCOMBINEPOSTCONCAT); // yaw - RwMatrixRotate(RwFrameGetMatrix(f), &upVector, RADTODEG(limb->phi), rwCOMBINEPOSTCONCAT); + RwMatrixRotate(RwFrameGetMatrix(f), &upVector, RADTODEG(limb->yaw), rwCOMBINEPOSTCONCAT); } RwFrameGetMatrix(f)->pos = pos; RwMatrixDestroy(mat); @@ -176,43 +176,43 @@ CPedIK::GetWorldMatrix(RwFrame *source, RwMatrix *destination) } LimbMoveStatus -CPedIK::MoveLimb(LimbOrientation &limb, float approxPhi, float approxTheta, LimbMovementInfo &moveInfo) +CPedIK::MoveLimb(LimbOrientation &limb, float targetYaw, float targetPitch, LimbMovementInfo &moveInfo) { LimbMoveStatus result = ONE_ANGLE_COULDNT_BE_SET_EXACTLY; - // phi + // yaw - if (limb.phi > approxPhi) { - limb.phi -= moveInfo.yawD; - } else if (limb.phi < approxPhi) { - limb.phi += moveInfo.yawD; + if (limb.yaw > targetYaw) { + limb.yaw -= moveInfo.yawD; + } else if (limb.yaw < targetYaw) { + limb.yaw += moveInfo.yawD; } - if (Abs(limb.phi - approxPhi) < moveInfo.yawD) { - limb.phi = approxPhi; + if (Abs(limb.yaw - targetYaw) < moveInfo.yawD) { + limb.yaw = targetYaw; result = ANGLES_SET_EXACTLY; } - if (limb.phi > moveInfo.maxYaw || limb.phi < moveInfo.minYaw) { - limb.phi = clamp(limb.phi, moveInfo.minYaw, moveInfo.maxYaw); + if (limb.yaw > moveInfo.maxYaw || limb.yaw < moveInfo.minYaw) { + limb.yaw = clamp(limb.yaw, moveInfo.minYaw, moveInfo.maxYaw); result = ANGLES_SET_TO_MAX; } - // theta + // pitch - if (limb.theta > approxTheta) { - limb.theta -= moveInfo.pitchD; - } else if (limb.theta < approxTheta) { - limb.theta += moveInfo.pitchD; + if (limb.pitch > targetPitch) { + limb.pitch -= moveInfo.pitchD; + } else if (limb.pitch < targetPitch) { + limb.pitch += moveInfo.pitchD; } - if (Abs(limb.theta - approxTheta) < moveInfo.pitchD) - limb.theta = approxTheta; + if (Abs(limb.pitch - targetPitch) < moveInfo.pitchD) + limb.pitch = targetPitch; else result = ONE_ANGLE_COULDNT_BE_SET_EXACTLY; - if (limb.theta > moveInfo.maxPitch || limb.theta < moveInfo.minPitch) { - limb.theta = clamp(limb.theta, moveInfo.minPitch, moveInfo.maxPitch); + if (limb.pitch > moveInfo.maxPitch || limb.pitch < moveInfo.minPitch) { + limb.pitch = clamp(limb.pitch, moveInfo.minPitch, moveInfo.maxPitch); result = ANGLES_SET_TO_MAX; } return result; @@ -231,14 +231,14 @@ void CPedIK::RotateHead(void) { RtQuat *q = &m_ped->m_pFrames[PED_HEAD]->hanimFrame->q; - RtQuatRotate(q, &XaxisIK, RADTODEG(m_headOrient.phi), rwCOMBINEREPLACE); - RtQuatRotate(q, &ZaxisIK, RADTODEG(m_headOrient.theta), rwCOMBINEPOSTCONCAT); + RtQuatRotate(q, &XaxisIK, RADTODEG(m_headOrient.yaw), rwCOMBINEREPLACE); + RtQuatRotate(q, &ZaxisIK, RADTODEG(m_headOrient.pitch), rwCOMBINEPOSTCONCAT); m_ped->bDontAcceptIKLookAts = true; } #endif bool -CPedIK::LookInDirection(float phi, float theta) +CPedIK::LookInDirection(float targetYaw, float targetPitch) { bool success = true; float yaw, pitch; @@ -246,21 +246,21 @@ CPedIK::LookInDirection(float phi, float theta) if(IsClumpSkinned(m_ped->GetClump())){ if (!(m_ped->m_pFrames[PED_HEAD]->flag & AnimBlendFrameData::IGNORE_ROTATION)) { m_ped->m_pFrames[PED_HEAD]->flag |= AnimBlendFrameData::IGNORE_ROTATION; - ExtractYawAndPitchLocalSkinned(m_ped->m_pFrames[PED_HEAD], &m_headOrient.phi, &m_headOrient.theta); + ExtractYawAndPitchLocalSkinned(m_ped->m_pFrames[PED_HEAD], &m_headOrient.yaw, &m_headOrient.pitch); } // parent of head is torso RwMatrix worldMat = *GetBoneMatrix(m_ped, BONE_torso); ExtractYawAndPitchWorld(&worldMat, &yaw, &pitch); - LimbMoveStatus headStatus = MoveLimb(m_headOrient, CGeneral::LimitRadianAngle(phi - yaw), + LimbMoveStatus headStatus = MoveLimb(m_headOrient, CGeneral::LimitRadianAngle(targetYaw - yaw), CGeneral::LimitRadianAngle(DEGTORAD(10.0f)), ms_headInfo); if (headStatus == ANGLES_SET_TO_MAX) success = false; if (headStatus != ANGLES_SET_EXACTLY){ if (!(m_flags & LOOKAROUND_HEAD_ONLY)){ - if (MoveLimb(m_torsoOrient, CGeneral::LimitRadianAngle(phi), theta, ms_torsoInfo)) + if (MoveLimb(m_torsoOrient, CGeneral::LimitRadianAngle(targetYaw), targetPitch, ms_torsoInfo)) success = true; }else{ RotateHead(); @@ -279,7 +279,7 @@ CPedIK::LookInDirection(float phi, float theta) if (!(m_ped->m_pFrames[PED_HEAD]->flag & AnimBlendFrameData::IGNORE_ROTATION)) { m_ped->m_pFrames[PED_HEAD]->flag |= AnimBlendFrameData::IGNORE_ROTATION; - ExtractYawAndPitchLocal(frameMat, &m_headOrient.phi, &m_headOrient.theta); + ExtractYawAndPitchLocal(frameMat, &m_headOrient.yaw, &m_headOrient.pitch); } RwMatrix *worldMat = RwMatrixCreate(); @@ -288,25 +288,25 @@ CPedIK::LookInDirection(float phi, float theta) ExtractYawAndPitchWorld(worldMat, &yaw, &pitch); RwMatrixDestroy(worldMat); - yaw += m_torsoOrient.phi; - float neededPhiTurn = CGeneral::LimitRadianAngle(phi - yaw); - pitch *= Cos(neededPhiTurn); + yaw += m_torsoOrient.yaw; + float neededYawTurn = CGeneral::LimitRadianAngle(targetYaw - yaw); + pitch *= Cos(neededYawTurn); - float neededThetaTurn = CGeneral::LimitRadianAngle(theta - pitch); - LimbMoveStatus headStatus = MoveLimb(m_headOrient, neededPhiTurn, neededThetaTurn, ms_headInfo); + float neededPitchTurn = CGeneral::LimitRadianAngle(targetPitch - pitch); + LimbMoveStatus headStatus = MoveLimb(m_headOrient, neededYawTurn, neededPitchTurn, ms_headInfo); if (headStatus == ANGLES_SET_TO_MAX) success = false; if (headStatus != ANGLES_SET_EXACTLY && !(m_flags & LOOKAROUND_HEAD_ONLY)) { - float remainingTurn = CGeneral::LimitRadianAngle(phi - m_ped->m_fRotationCur); - if (MoveLimb(m_torsoOrient, remainingTurn, theta, ms_torsoInfo)) + float remainingTurn = CGeneral::LimitRadianAngle(targetYaw - m_ped->m_fRotationCur); + if (MoveLimb(m_torsoOrient, remainingTurn, targetPitch, ms_torsoInfo)) success = true; } CMatrix nextFrame = CMatrix(frameMat); CVector framePos = nextFrame.GetPosition(); - nextFrame.SetRotateZ(m_headOrient.theta); - nextFrame.RotateX(m_headOrient.phi); + nextFrame.SetRotateZ(m_headOrient.pitch); + nextFrame.RotateX(m_headOrient.yaw); nextFrame.GetPosition() += framePos; nextFrame.UpdateRW(); @@ -320,32 +320,32 @@ CPedIK::LookInDirection(float phi, float theta) bool CPedIK::LookAtPosition(CVector const &pos) { - float phiToFace = CGeneral::GetRadianAngleBetweenPoints( + float yawToFace = CGeneral::GetRadianAngleBetweenPoints( pos.x, pos.y, m_ped->GetPosition().x, m_ped->GetPosition().y); - float thetaToFace = CGeneral::GetRadianAngleBetweenPoints( + float pitchToFace = CGeneral::GetRadianAngleBetweenPoints( pos.z, (m_ped->GetPosition() - pos).Magnitude2D(), m_ped->GetPosition().z, 0.0f); - return LookInDirection(phiToFace, thetaToFace); + return LookInDirection(yawToFace, pitchToFace); } bool -CPedIK::PointGunInDirection(float phi, float theta) +CPedIK::PointGunInDirection(float targetYaw, float targetPitch) { bool result = true; bool armPointedToGun = false; - float angle = CGeneral::LimitRadianAngle(phi - m_ped->m_fRotationCur); + float angle = CGeneral::LimitRadianAngle(targetYaw - m_ped->m_fRotationCur); m_flags &= (~GUN_POINTED_SUCCESSFULLY); m_flags |= LOOKAROUND_HEAD_ONLY; if (m_flags & AIMS_WITH_ARM) { - armPointedToGun = PointGunInDirectionUsingArm(angle, theta); - angle = CGeneral::LimitRadianAngle(angle - m_upperArmOrient.phi); + armPointedToGun = PointGunInDirectionUsingArm(angle, targetPitch); + angle = CGeneral::LimitRadianAngle(angle - m_upperArmOrient.yaw); } if (armPointedToGun) { - if (m_flags & AIMS_WITH_ARM && m_torsoOrient.phi * m_upperArmOrient.phi < 0.0f) - MoveLimb(m_torsoOrient, 0.0f, m_torsoOrient.theta, ms_torsoInfo); + if (m_flags & AIMS_WITH_ARM && m_torsoOrient.yaw * m_upperArmOrient.yaw < 0.0f) + MoveLimb(m_torsoOrient, 0.0f, m_torsoOrient.pitch, ms_torsoInfo); } else { // Unused code RwMatrix *matrix; @@ -365,7 +365,7 @@ CPedIK::PointGunInDirection(float phi, float theta) } // - LimbMoveStatus status = MoveLimb(m_torsoOrient, angle, theta, ms_torsoInfo); + LimbMoveStatus status = MoveLimb(m_torsoOrient, angle, targetPitch, ms_torsoInfo); if (status == ANGLES_SET_TO_MAX) result = false; else if (status == ANGLES_SET_EXACTLY) @@ -379,7 +379,7 @@ CPedIK::PointGunInDirection(float phi, float theta) } bool -CPedIK::PointGunInDirectionUsingArm(float phi, float theta) +CPedIK::PointGunInDirectionUsingArm(float targetYaw, float targetPitch) { bool result = false; @@ -410,18 +410,18 @@ CPedIK::PointGunInDirectionUsingArm(float phi, float theta) RwV3d rightVector = { 0.0f, 0.0f, 1.0f }; RwV3d forwardVector = { 1.0f, 0.0f, 0.0f }; - float uaPhi, uaTheta; + float uaYaw, uaPitch; #ifdef PED_SKIN if(IsClumpSkinned(m_ped->GetClump())){ - uaPhi = phi; - uaTheta = theta + DEGTORAD(10.0f); + uaYaw = targetYaw; + uaPitch = targetPitch + DEGTORAD(10.0f); }else #endif { - uaPhi = phi - m_torsoOrient.phi - DEGTORAD(15.0f); - uaTheta = CGeneral::LimitRadianAngle(theta - pitch); + uaYaw = targetYaw - m_torsoOrient.yaw - DEGTORAD(15.0f); + uaPitch = CGeneral::LimitRadianAngle(targetPitch - pitch); } - LimbMoveStatus uaStatus = MoveLimb(m_upperArmOrient, uaPhi, uaTheta, ms_upperArmInfo); + LimbMoveStatus uaStatus = MoveLimb(m_upperArmOrient, uaYaw, uaPitch, ms_upperArmInfo); if (uaStatus == ANGLES_SET_EXACTLY) { m_flags |= GUN_POINTED_SUCCESSFULLY; result = true; @@ -433,13 +433,13 @@ CPedIK::PointGunInDirectionUsingArm(float phi, float theta) if(!IsClumpSkinned(m_ped->GetClump())) #endif if (uaStatus == ANGLES_SET_TO_MAX) { - float laPhi = uaPhi - m_upperArmOrient.phi; + float laYaw = uaYaw - m_upperArmOrient.yaw; LimbMoveStatus laStatus; - if (laPhi > 0.0f) - laStatus = MoveLimb(m_lowerArmOrient, laPhi, -DEGTORAD(45.0f), ms_lowerArmInfo); + if (laYaw > 0.0f) + laStatus = MoveLimb(m_lowerArmOrient, laYaw, -DEGTORAD(45.0f), ms_lowerArmInfo); else - laStatus = MoveLimb(m_lowerArmOrient, laPhi, 0.0f, ms_lowerArmInfo); + laStatus = MoveLimb(m_lowerArmOrient, laYaw, 0.0f, ms_lowerArmInfo); if (laStatus == ANGLES_SET_EXACTLY) { m_flags |= GUN_POINTED_SUCCESSFULLY; @@ -447,16 +447,16 @@ CPedIK::PointGunInDirectionUsingArm(float phi, float theta) } RwFrame *child = GetFirstChild(m_ped->m_pFrames[PED_UPPERARMR]->frame); RwV3d pos = RwFrameGetMatrix(child)->pos; - RwMatrixRotate(RwFrameGetMatrix(child), &forwardVector, RADTODEG(m_lowerArmOrient.theta), rwCOMBINEPOSTCONCAT); - RwMatrixRotate(RwFrameGetMatrix(child), &rightVector, RADTODEG(-m_lowerArmOrient.phi), rwCOMBINEPOSTCONCAT); + RwMatrixRotate(RwFrameGetMatrix(child), &forwardVector, RADTODEG(m_lowerArmOrient.pitch), rwCOMBINEPOSTCONCAT); + RwMatrixRotate(RwFrameGetMatrix(child), &rightVector, RADTODEG(-m_lowerArmOrient.yaw), rwCOMBINEPOSTCONCAT); RwFrameGetMatrix(child)->pos = pos; } #ifdef PED_SKIN if(IsClumpSkinned(m_ped->GetClump())){ RtQuat *q = &m_ped->m_pFrames[PED_UPPERARMR]->hanimFrame->q; - RtQuatRotate(q, &XaxisIK, RADTODEG(m_upperArmOrient.phi), rwCOMBINEPOSTCONCAT); - RtQuatRotate(q, &ZaxisIK, RADTODEG(m_upperArmOrient.theta), rwCOMBINEPOSTCONCAT); + RtQuatRotate(q, &XaxisIK, RADTODEG(m_upperArmOrient.yaw), rwCOMBINEPOSTCONCAT); + RtQuatRotate(q, &ZaxisIK, RADTODEG(m_upperArmOrient.pitch), rwCOMBINEPOSTCONCAT); m_ped->bDontAcceptIKLookAts = true; }else #endif @@ -464,8 +464,8 @@ CPedIK::PointGunInDirectionUsingArm(float phi, float theta) RwFrame *frame = m_ped->m_pFrames[PED_UPPERARMR]->frame; // with PED_SKIN we're also getting upVector here RwV3d pos = RwFrameGetMatrix(frame)->pos; - RwMatrixRotate(RwFrameGetMatrix(frame), &rightVector, RADTODEG(m_upperArmOrient.theta), rwCOMBINEPOSTCONCAT); - RwMatrixRotate(RwFrameGetMatrix(frame), &upVector, RADTODEG(m_upperArmOrient.phi), rwCOMBINEPOSTCONCAT); + RwMatrixRotate(RwFrameGetMatrix(frame), &rightVector, RADTODEG(m_upperArmOrient.pitch), rwCOMBINEPOSTCONCAT); + RwMatrixRotate(RwFrameGetMatrix(frame), &upVector, RADTODEG(m_upperArmOrient.yaw), rwCOMBINEPOSTCONCAT); RwFrameGetMatrix(frame)->pos = pos; } return result; @@ -511,8 +511,8 @@ CPedIK::RestoreLookAt(void) CMatrix matrix(mat); CVector pos = matrix.GetPosition(); - matrix.SetRotateZ(m_headOrient.theta); - matrix.RotateX(m_headOrient.phi); + matrix.SetRotateZ(m_headOrient.pitch); + matrix.RotateX(m_headOrient.yaw); matrix.Translate(pos); matrix.UpdateRW(); } diff --git a/src/peds/PedIK.h b/src/peds/PedIK.h index a1cb5d13..e91d7c06 100644 --- a/src/peds/PedIK.h +++ b/src/peds/PedIK.h @@ -4,8 +4,8 @@ struct LimbOrientation { - float phi; - float theta; + float yaw; + float pitch; }; struct LimbMovementInfo { @@ -48,8 +48,8 @@ public: static LimbMovementInfo ms_lowerArmInfo; CPedIK(CPed *ped); - bool PointGunInDirection(float phi, float theta); - bool PointGunInDirectionUsingArm(float phi, float theta); + bool PointGunInDirection(float targetYaw, float targetPitch); + bool PointGunInDirectionUsingArm(float targetYaw, float targetPitch); bool PointGunAtPosition(CVector const& position); void GetComponentPosition(RwV3d *pos, uint32 node); static RwMatrix *GetWorldMatrix(RwFrame *source, RwMatrix *destination); @@ -57,10 +57,10 @@ public: void ExtractYawAndPitchLocal(RwMatrix *mat, float *yaw, float *pitch); void ExtractYawAndPitchLocalSkinned(AnimBlendFrameData *node, float *yaw, float *pitch); void ExtractYawAndPitchWorld(RwMatrix *mat, float *yaw, float *pitch); - LimbMoveStatus MoveLimb(LimbOrientation &limb, float approxPhi, float approxTheta, LimbMovementInfo &moveInfo); + LimbMoveStatus MoveLimb(LimbOrientation &limb, float targetYaw, float targetPitch, LimbMovementInfo &moveInfo); bool RestoreGunPosn(void); void RotateHead(void); - bool LookInDirection(float phi, float theta); + bool LookInDirection(float targetYaw, float targetPitch); bool LookAtPosition(CVector const& pos); bool RestoreLookAt(void); }; -- cgit v1.2.3 From 0b0ba49abc34315f532f9adcdbc277d5275723c7 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 19 May 2020 21:42:55 +0200 Subject: small fixes --- src/peds/Population.cpp | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index 1566ba3d..e2257a28 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -966,18 +966,11 @@ CPopulation::ConvertToRealObject(CDummyObject *dummy) if (!obj) return; - bool makeInvisible; CWorld::Remove(dummy); delete dummy; CWorld::Add(obj); - int16 mi = obj->GetModelIndex(); - if (mi == MI_GLASS1 || mi == MI_GLASS2 || mi == MI_GLASS3 || mi == MI_GLASS4 || - mi == MI_GLASS5 || mi == MI_GLASS6 || mi == MI_GLASS7 || mi == MI_GLASS8) - makeInvisible = true; - else - makeInvisible = false; - if (makeInvisible) { + if (IsGlass(obj->GetModelIndex())) { obj->bIsVisible = false; } else if (obj->GetModelIndex() == MI_BUOY) { obj->bIsStatic = false; @@ -996,17 +989,8 @@ CPopulation::ConvertToDummyObject(CObject *obj) dummy->GetMatrix().UpdateRW(); dummy->UpdateRwFrame(); - bool makeInvisible; - int16 mi = obj->GetModelIndex(); - if (mi == MI_GLASS1 || mi == MI_GLASS2 || mi == MI_GLASS3 || mi == MI_GLASS4 || - mi == MI_GLASS5 || mi == MI_GLASS6 || mi == MI_GLASS7 || mi == MI_GLASS8) - makeInvisible = true; - else - makeInvisible = false; - - if (makeInvisible) { + if (IsGlass(obj->GetModelIndex())) dummy->bIsVisible = false; - } CWorld::Remove(obj); delete obj; -- cgit v1.2.3 From 14755a4ff4668e2cf2fa580797321141770e3b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sun, 24 May 2020 16:41:29 +0300 Subject: all my fixes live in exes --- src/peds/PlayerPed.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/peds') diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 3c6fad57..eb4ac09e 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -227,7 +227,7 @@ CPlayerPed::SetInitialState(void) { m_bAdrenalineActive = false; m_nAdrenalineTime = 0; - CTimer::SetTimeStep(1.0f); + CTimer::SetTimeScale(1.0f); m_pSeekTarget = nil; m_vecSeekPos = { 0.0f, 0.0f, 0.0f }; m_fleeFromPosX = 0.0f; -- cgit v1.2.3 From 3c3b1aadc0bfd3b8d58cc9dcc269d83f6a003235 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 25 May 2020 20:36:18 +0200 Subject: small fixes --- src/peds/Ped.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index d48a6a2f..e3fa2104 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -63,7 +63,7 @@ CPed *gapTempPedList[50]; uint16 gnNumTempPedList; -CColPoint aTempPedColPts[MAX_COLLISION_POINTS]; +static CColPoint aTempPedColPts[MAX_COLLISION_POINTS]; // Corresponds to ped sounds (from SOUND_PED_DEATH to SOUND_PED_TAXI_CALL) PedAudioData CommentWaitTime[39] = { -- cgit v1.2.3 From 7e5dde1f1a6ffbba98572b7fad3a51538104c04b Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 26 May 2020 11:37:46 +0200 Subject: eSurfaceType --- src/peds/Ped.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index e3fa2104..6b3b8686 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -2037,7 +2037,7 @@ particleProduceFootDust(CPed *ped, CVector const &pos, float size, int times) switch (ped->m_nSurfaceTouched) { case SURFACE_TARMAC: - case SURFACE_DIRT: + case SURFACE_GRAVEL: case SURFACE_PAVEMENT: case SURFACE_SAND: for (int i = 0; i < times; ++i) { @@ -2190,7 +2190,7 @@ CPed::PlayFootSteps(void) } } - if (m_nSurfaceTouched == SURFACE_PUDDLE) { + if (m_nSurfaceTouched == SURFACE_WATER) { float pedSpeed = CVector2D(m_vecMoveSpeed).Magnitude(); if (pedSpeed > 0.03f && CTimer::GetFrameCounter() % 2 == 0 && pedSpeed > 0.13f) { #ifdef PC_PARTICLE @@ -2588,7 +2588,7 @@ CPed::CanPedDriveOff(void) bool CPed::CanPedJumpThis(CEntity *unused, CVector *damageNormal = nil) { - if (m_nSurfaceTouched == SURFACE_PUDDLE) + if (m_nSurfaceTouched == SURFACE_WATER) return true; CVector pos = GetPosition(); @@ -11055,7 +11055,7 @@ CPed::SetJump(void) #ifdef VC_PED_PORTS m_nPedState != PED_JUMP && !RpAnimBlendClumpGetAssociation(GetClump(), ANIM_JUMP_LAUNCH) && #endif - (m_nSurfaceTouched != SURFACE_STONE || DotProduct(GetForward(), m_vecDamageNormal) >= 0.0f)) { + (m_nSurfaceTouched != SURFACE_STEEP_CLIFF || DotProduct(GetForward(), m_vecDamageNormal) >= 0.0f)) { SetStoredState(); m_nPedState = PED_JUMP; CAnimBlendAssociation *jumpAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_JUMP_LAUNCH, 8.0f); @@ -14781,7 +14781,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints) GetMatrix().GetPosition().z = FEET_OFFSET + intersectionPoint.point.z; #endif m_nSurfaceTouched = intersectionPoint.surfaceB; - if (m_nSurfaceTouched == SURFACE_STONE) { + if (m_nSurfaceTouched == SURFACE_STEEP_CLIFF) { bHitSteepSlope = true; m_vecDamageNormal = intersectionPoint.normal; } @@ -14889,7 +14889,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints) #endif sphereNormal.Normalise(); collidingPoints[sphere].normal = sphereNormal; - if (collidingPoints[sphere].surfaceB == SURFACE_STONE) + if (collidingPoints[sphere].surfaceB == SURFACE_STEEP_CLIFF) bHitSteepSlope = true; } } @@ -16749,7 +16749,7 @@ CPed::UpdatePosition(void) velocityChange = m_moved + velocityOfSurface - m_vecMoveSpeed; m_fRotationCur += curSurface->m_vecTurnSpeed.z * CTimer::GetTimeStep(); m_fRotationDest += curSurface->m_vecTurnSpeed.z * CTimer::GetTimeStep(); - } else if (m_nSurfaceTouched != SURFACE_STONE || m_vecDamageNormal.x == 0.0f && m_vecDamageNormal.y == 0.0f) { + } else if (m_nSurfaceTouched != SURFACE_STEEP_CLIFF || m_vecDamageNormal.x == 0.0f && m_vecDamageNormal.y == 0.0f) { velocityChange = m_moved - m_vecMoveSpeed; } else { // Ped got damaged by steep slope -- cgit v1.2.3 From 5d90e4b2f095079221de35e0e172cbc52f4a9a4c Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Mon, 1 Jun 2020 22:10:11 +0200 Subject: Fix collision with peds heads --- src/peds/Ped.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 6b3b8686..cfdbb6bc 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -6187,6 +6187,9 @@ CPed::Die(void) uint8 CPed::DoesLOSBulletHitPed(CColPoint &colPoint) { +#ifdef FIX_BUGS + return 1; +#else uint8 retVal = 2; float headZ = GetNodePosition(PED_HEAD).z; @@ -6202,6 +6205,7 @@ CPed::DoesLOSBulletHitPed(CColPoint &colPoint) retVal = 0; return retVal; +#endif } bool -- cgit v1.2.3 From 04a91761df7c90ed16b37407d65d8674033efd3f Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 2 Jun 2020 23:34:53 +0200 Subject: some vehicle cleanup --- src/peds/Ped.cpp | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 6b3b8686..055581ad 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -1682,11 +1682,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatP switch (component) { case CAR_DOOR_RF: - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - vehDoorPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - vehDoorPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; - + vehDoorPos = vehModel->GetFrontSeatPosn(); vehDoorPos.x += seatOffset; vehDoorOffset.x = -vehDoorOffset.x; break; @@ -1698,11 +1694,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatP break; case CAR_DOOR_LF: - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - vehDoorPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - vehDoorPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; - + vehDoorPos = vehModel->GetFrontSeatPosn(); vehDoorPos.x = -(vehDoorPos.x + seatOffset); break; @@ -1712,11 +1704,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatP break; default: - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - vehDoorPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - vehDoorPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; - + vehDoorPos = vehModel->GetFrontSeatPosn(); vehDoorOffset = CVector(0.0f, 0.0f, 0.0f); } return vehDoorPos - vehDoorOffset; @@ -15031,11 +15019,7 @@ CPed::SeekBoatPosition(void) CVehicleModelInfo *boatModel = m_carInObjective->GetModelInfo(); CVector enterOffset; - if (boatModel->m_vehicleType == VEHICLE_TYPE_BOAT) - enterOffset = boatModel->m_positions[BOAT_POS_FRONTSEAT]; - else - enterOffset = boatModel->m_positions[CAR_POS_FRONTSEAT]; - + enterOffset = boatModel->GetFrontSeatPosn(); enterOffset.x = 0.0f; CMatrix boatMat(m_carInObjective->GetMatrix()); SetMoveState(PEDMOVE_WALK); @@ -16817,29 +16801,20 @@ CPed::SetPedPositionInCar(void) CMatrix newMat(m_pMyVehicle->GetMatrix()); CVector seatPos; if (m_pMyVehicle->pDriver == this) { - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - seatPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - seatPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; - + seatPos = vehModel->GetFrontSeatPosn(); if (!m_pMyVehicle->IsBoat() && m_pMyVehicle->m_vehType != VEHICLE_TYPE_BIKE) seatPos.x = -seatPos.x; } else if (m_pMyVehicle->pPassengers[0] == this) { - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - seatPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - seatPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; + seatPos = vehModel->GetFrontSeatPosn(); } else if (m_pMyVehicle->pPassengers[1] == this) { seatPos = vehModel->m_positions[CAR_POS_BACKSEAT]; seatPos.x = -seatPos.x; } else { if (m_pMyVehicle->pPassengers[2] == this) { seatPos = vehModel->m_positions[CAR_POS_BACKSEAT]; - } else if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) { - seatPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; } else { - seatPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; + seatPos = vehModel->GetFrontSeatPosn(); } } newMat.GetPosition() += Multiply3x3(newMat, seatPos); -- cgit v1.2.3 From 12717917cc67c7fa854991b606b7ea71499ec602 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 4 Jun 2020 04:31:04 +0300 Subject: Restore original logic of CPed::WanderRange --- src/peds/Ped.cpp | 15 ++++----------- src/peds/Ped.h | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 055581ad..88b09e91 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -57,6 +57,7 @@ #include "Timecycle.h" #include "ParticleObject.h" #include "Floater.h" +#include "Range2D.h" #define CAN_SEE_ENTITY_ANGLE_THRESHOLD DEGTORAD(60.0f) @@ -14927,17 +14928,9 @@ CPed::WanderRange(void) bool arrived = Seek(); if (arrived) { Idle(); - if (((m_randomSeed % 256) + 3 * CTimer::GetFrameCounter()) % 1000 > 997) { - - int xDiff = Abs(m_wanderRangeBounds[1].x - m_wanderRangeBounds[0].x); - int yDiff = Abs(m_wanderRangeBounds[1].y - m_wanderRangeBounds[0].y); - - CVector newCoords( - (CGeneral::GetRandomNumber() % xDiff) + m_wanderRangeBounds[0].x, - (CGeneral::GetRandomNumber() % yDiff) + m_wanderRangeBounds[0].y, - GetPosition().z); - - SetSeek(newCoords, 2.5f); + if ((m_randomSeed + 3 * CTimer::GetFrameCounter()) % 1000 > 997) { + CVector2D newCoords2D = m_wanderRangeBounds->GetRandomPointInRange(); + SetSeek(CVector(newCoords2D.x, newCoords2D.y, GetPosition().z), 2.5f); } } } diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 56e527c5..31a75ace 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -468,7 +468,7 @@ public: CEntity *m_pCollidingEntity; uint8 m_stateUnused; uint32 m_timerUnused; - CVector2D *m_wanderRangeBounds; // array with 2 CVector2D (actually unused CRange2D class) - unused + class CRange2D *m_wanderRangeBounds; CWeapon m_weapons[WEAPONTYPE_TOTAL_INVENTORY_WEAPONS]; eWeaponType m_storedWeapon; uint8 m_currentWeapon; // eWeaponType -- cgit v1.2.3 From 2578880e1c7bb0b09e2799efdb364dedc57d46f0 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 4 Jun 2020 05:04:00 +0300 Subject: PedChat & PedDebug --- src/peds/Ped.cpp | 367 +------------------------------------------------- src/peds/Ped.h | 13 ++ src/peds/PedChat.cpp | 153 +++++++++++++++++++++ src/peds/PedDebug.cpp | 310 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 477 insertions(+), 366 deletions(-) create mode 100644 src/peds/PedChat.cpp create mode 100644 src/peds/PedDebug.cpp (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 88b09e91..89c0b6af 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -66,48 +66,6 @@ uint16 gnNumTempPedList; static CColPoint aTempPedColPts[MAX_COLLISION_POINTS]; -// Corresponds to ped sounds (from SOUND_PED_DEATH to SOUND_PED_TAXI_CALL) -PedAudioData CommentWaitTime[39] = { - {500, 800, 500, 2}, - {500, 800, 500, 2}, - {500, 800, 500, 2}, - {500, 800, 500, 2}, - {100, 2, 100, 2}, - {700, 500, 1000, 500}, - {700, 500, 1000, 500}, - {5000, 2000, 15000, 3000}, - {5000, 2000, 15000, 3000}, - {5000, 2000, 15000, 3000}, - {6000, 6000, 6000, 6000}, - {1000, 1000, 2000, 2000}, - {1000, 500, 2000, 1500}, - {1000, 500, 2000, 1500}, - {800, 200, 1000, 500}, - {800, 200, 1000, 500}, - {800, 400, 2000, 1000}, - {800, 400, 2000, 1000}, - {400, 300, 2000, 1000}, - {2000, 1000, 2500, 1500}, - {200, 200, 200, 200}, - {6000, 3000, 5000, 6000}, - {6000, 3000, 9000, 5000}, - {6000, 3000, 9000, 5000}, - {6000, 3000, 9000, 5000}, - {400, 300, 4000, 1000}, - {400, 300, 4000, 1000}, - {400, 300, 4000, 1000}, - {1000, 500, 3000, 1000}, - {1000, 500, 1000, 1000}, - {3000, 2000, 3000, 2000}, - {1000, 500, 3000, 6000}, - {1000, 500, 2000, 4000}, - {1000, 500, 2000, 5000}, - {1000, 500, 3000, 2000}, - {1600, 1000, 2000, 2000}, - {3000, 2000, 5000, 3000}, - {1000, 1000, 1000, 1000}, - {1000, 1000, 5000, 5000}, -}; uint16 nPlayerInComboMove; RpClump *flyingClumpTemp; @@ -160,228 +118,11 @@ void *CPed::operator new(size_t sz, int handle) { return CPools::GetPedPool()->N void CPed::operator delete(void *p, size_t sz) { CPools::GetPedPool()->Delete((CPed*)p); } void CPed::operator delete(void *p, int handle) { CPools::GetPedPool()->Delete((CPed*)p); } -static char ObjectiveText[][28] = { - "No Obj", - "Wait on Foot", - "Flee on Foot Till Safe", - "Guard Spot", - "Guard Area", - "Wait in Car", - "Wait in Car then Getout", - "Kill Char on Foot", - "Kill Char Any Means", - "Flee Char on Foot Till Safe", - "Flee Char on Foot Always", - "GoTo Char on Foot", - "Follow Char in Formation", - "Leave Car", - "Enter Car as Passenger", - "Enter Car as Driver", - "Follow Car in Car", - "Fire at Obj from Vehicle", - "Destroy Obj", - "Destroy Car", - "GoTo Area Any Means", - "GoTo Area on Foot", - "Run to Area", - "GoTo Area in Car", - "Follow Car on Foot Woffset", - "Guard Attack", - "Set Leader", - "Follow Route", - "Solicit", - "Take Taxi", - "Catch Train", - "Buy IceCream", - "Steal Any Car", - "Mug Char", -#ifdef VC_PED_PORTS - "Leave Car and Die" -#endif -}; - -static char StateText[][18] = { - "None", - "Idle", - "Look Entity", - "Look Heading", - "Wander Range", - "Wander Path", - "Seek Pos", - "Seek Entity", - "Flee Pos", - "Flee Entity", - "Pursue", - "Follow Path", - "Sniper Mode", - "Rocket Mode", - "Dummy", - "Pause", - "Attack", - "Fight", - "Face Phone", - "Make Call", - "Chat", - "Mug", - "AimGun", - "AI Control", - "Seek Car", - "Seek InBoat", - "Follow Route", - "C.P.R.", - "Solicit", - "Buy IceCream", - "Investigate", - "Step away", - "On Fire", - "Unknown", - "STATES_NO_AI", - "Jump", - "Fall", - "GetUp", - "Stagger", - "Dive away", - "STATES_NO_ST", - "Enter Train", - "Exit Train", - "Arrest Plyr", - "Driving", - "Passenger", - "Taxi Passngr", - "Open Door", - "Die", - "Dead", - "CarJack", - "Drag fm Car", - "Enter Car", - "Steal Car", - "Exit Car", - "Hands Up", - "Arrested", -}; - -static char PersonalityTypeText[][18] = { - "Player", - "Cop", - "Medic", - "Fireman", - "Gang 1", - "Gang 2", - "Gang 3", - "Gang 4", - "Gang 5", - "Gang 6", - "Gang 7", - "Street Guy", - "Suit Guy", - "Sensible Guy", - "Geek Guy", - "Old Guy", - "Tough Guy", - "Street Girl", - "Suit Girl", - "Sensible Girl", - "Geek Girl", - "Old Girl", - "Tough Girl", - "Tramp Male", - "Tramp Female", - "Tourist", - "Prostitute", - "Criminal", - "Busker", - "Taxi Driver", - "Psycho", - "Steward", - "Sports Fan", - "Shopper", - "Old Shopper" -}; - -static char WaitStateText[][16] = { - "No Wait", - "Traffic Lights", - "Pause CrossRoad", - "Look CrossRoad", - "Look Ped", - "Look Shop", - "Look Accident", - "FaceOff Gang", - "Double Back", - "Hit Wall", - "Turn 180deg", - "Surprised", - "Ped Stuck", - "Look About", - "Play Duck", - "Play Cower", - "Play Taxi", - "Play HandsUp", - "Play HandsCower", - "Play Chat", - "Finish Flee", -}; - #ifdef TOGGLEABLE_BETA_FEATURES bool CPed::bPopHeadsOnHeadshot = false; bool CPed::bMakePedsRunToPhonesToReportCrimes = false; #endif -#ifndef MASTER -int nDisplayDebugInfo = 0; - -void -CPed::SwitchDebugDisplay(void) -{ - nDisplayDebugInfo = !nDisplayDebugInfo; -} - -void -CPed::DebugRenderOnePedText(void) -{ - if ((GetPosition() - TheCamera.GetPosition()).MagnitudeSqr() < sq(30.0f)) { - float width, height; - RwV3d screenCoords; - CVector bitAbove = GetPosition(); - bitAbove.z += 2.0f; - if (CSprite::CalcScreenCoors(bitAbove, &screenCoords, &width, &height, true)) { - - float lineHeight = SCREEN_SCALE_Y(Min(height/100.0f, 0.7f) * 22.0f); - - DefinedState(); - CFont::SetPropOn(); - CFont::SetBackgroundOn(); - - // Originally both of them were being divided by 60.0f. - float xScale = Min(width / 240.0f, 0.7f); - float yScale = Min(height / 80.0f, 0.7f); - - CFont::SetScale(SCREEN_SCALE_X(xScale), SCREEN_SCALE_Y(yScale)); - CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_WIDTH); - CFont::SetJustifyOff(); - CFont::SetColor(CRGBA(255, 255, 0, 255)); - CFont::SetBackGroundOnlyTextOn(); - CFont::SetFontStyle(0); - AsciiToUnicode(StateText[m_nPedState], gUString); - CFont::PrintString(screenCoords.x, screenCoords.y, gUString); - AsciiToUnicode(ObjectiveText[m_objective], gUString); - CFont::PrintString(screenCoords.x, screenCoords.y + lineHeight, gUString); - AsciiToUnicode(PersonalityTypeText[m_pedStats->m_type], gUString); - CFont::PrintString(screenCoords.x, screenCoords.y + 2 * lineHeight, gUString); - AsciiToUnicode(WaitStateText[m_nWaitState], gUString); - CFont::PrintString(screenCoords.x, screenCoords.y + 3 * lineHeight, gUString); - if (m_nPedState == PED_SEEK_POS || m_nPedState == PED_SEEK_ENTITY) { - sprintf(gString, "Safe distance to target: %.2f", m_distanceToCountSeekDone); - AsciiToUnicode(gString, gUString); - CFont::PrintString(screenCoords.x, screenCoords.y + 4 * lineHeight, gUString); - } - DefinedState(); - } - } -} -#endif - CPed::~CPed(void) { CWorld::Remove(this); @@ -2369,7 +2110,7 @@ CPed::SetupLighting(void) #ifndef MASTER // Originally this was being called through iteration of Sectors, but putting it here is better. - if (nDisplayDebugInfo && !IsPlayer()) + if (GetDebugDisplay() != 0 && !IsPlayer()) DebugRenderOnePedText(); #endif @@ -5565,78 +5306,6 @@ CPed::PlayHitSound(CPed *hitTo) DMAudio.PlayOneShot(m_audioEntityId, soundId, 0.0f); } -void -CPed::Say(uint16 audio) -{ - uint16 audioToPlay = audio; - - if (IsPlayer()) { - - // Ofc this part isn't in VC. - switch (audio) { - case SOUND_PED_DEATH: - audioToPlay = SOUND_PED_DAMAGE; - break; - case SOUND_PED_DAMAGE: - case SOUND_PED_HIT: - case SOUND_PED_LAND: - break; - case SOUND_PED_BULLET_HIT: - case SOUND_PED_CAR_JACKED: - case SOUND_PED_DEFEND: - audioToPlay = SOUND_PED_HIT; - break; - default: - return; - } - } else { - if (3.0f + TheCamera.GetPosition().z < GetPosition().z) - return; - - if (TheCamera.m_CameraAverageSpeed > 1.65f) { -#ifdef VC_PED_PORTS - if (audio != SOUND_PED_DAMAGE && audio != SOUND_PED_HIT && audio != SOUND_PED_LAND) -#endif - return; - - } else if (TheCamera.m_CameraAverageSpeed > 1.25f) { - if (audio != SOUND_PED_DEATH && -#ifdef VC_PED_PORTS - audio != SOUND_PED_DAMAGE && audio != SOUND_PED_HIT && audio != SOUND_PED_LAND && -#endif - audio != SOUND_PED_TAXI_WAIT && audio != SOUND_PED_EVADE) - return; - - } else if (TheCamera.m_CameraAverageSpeed > 0.9f) { - switch (audio) { - case SOUND_PED_DEATH: -#ifdef VC_PED_PORTS - case SOUND_PED_DAMAGE: - case SOUND_PED_HIT: - case SOUND_PED_LAND: -#endif - case SOUND_PED_BURNING: - case SOUND_PED_FLEE_SPRINT: - case SOUND_PED_TAXI_WAIT: - case SOUND_PED_EVADE: - case SOUND_PED_CAR_COLLISION: - break; - default: - return; - } - } - } - - if (audioToPlay < m_queuedSound) { - if (audioToPlay != m_lastQueuedSound || audioToPlay == SOUND_PED_DEATH - || CommentWaitTime[audioToPlay - SOUND_PED_DEATH].m_nOverrideMaxRandomDelayTime - + m_lastSoundStart - + (uint32) CGeneral::GetRandomNumberInRange(0, CommentWaitTime[audioToPlay - SOUND_PED_DEATH].m_nMaxRandomDelayTime) <= CTimer::GetTimeInMilliseconds()) { - m_queuedSound = audioToPlay; - } - } -} - void CPed::CollideWithPed(CPed *collideWith) { @@ -11053,12 +10722,6 @@ CPed::SetJump(void) } } -bool -CPed::ServiceTalkingWhenDead(void) -{ - return m_queuedSound == SOUND_PED_DEATH; -} - void CPed::RemoveInCarAnims(void) { @@ -16250,34 +15913,6 @@ CPed::SeekCar(void) } } -void -CPed::ServiceTalking(void) -{ - if (!bBodyPartJustCameOff || m_bodyPartBleeding != PED_HEAD) { - if (CGeneral::faststricmp(CModelInfo::GetModelInfo(GetModelIndex())->GetName(), "bomber")) { - if (m_nPedState == PED_ON_FIRE) - m_queuedSound = SOUND_PED_BURNING; - } else { - m_queuedSound = SOUND_PED_BOMBER; - } - if (m_queuedSound != SOUND_NO_SOUND) { - if (m_queuedSound == SOUND_PED_DEATH) - m_soundStart = CTimer::GetTimeInMilliseconds() - 1; - - if (CTimer::GetTimeInMilliseconds() > m_soundStart) { - DMAudio.PlayOneShot(m_audioEntityId, m_queuedSound, 1.0f); - m_lastSoundStart = CTimer::GetTimeInMilliseconds(); - m_soundStart = - CommentWaitTime[m_queuedSound - SOUND_PED_DEATH].m_nFixedDelayTime - + CTimer::GetTimeInMilliseconds() - + CGeneral::GetRandomNumberInRange(0, CommentWaitTime[m_queuedSound - SOUND_PED_DEATH].m_nOverrideFixedDelayTime); - m_lastQueuedSound = m_queuedSound; - m_queuedSound = SOUND_NO_SOUND; - } - } - } -} - void CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk) { diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 31a75ace..59e0053b 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -879,8 +879,21 @@ public: #ifndef MASTER // Mobile things + void DebugDrawPedDestination(CPed *, int, int); + void DebugDrawPedDesiredHeading(CPed *, int, int); + void DebugDrawCollisionRadius(float, float, float, float, int); + void DebugDrawVisionRange(CVector, float); + void DebugDrawVisionSimple(CVector, float); + void DebugDrawLook(); + void DebugDrawPedPsyche(); + void DebugDrawDebugLines(); + static void SwitchDebugDisplay(void); + static int GetDebugDisplay(void); + + void DebugDrawLookAtPoints(); void DebugRenderOnePedText(void); + void DebugRenderClosePedText(); #endif #ifdef PED_SKIN diff --git a/src/peds/PedChat.cpp b/src/peds/PedChat.cpp new file mode 100644 index 00000000..9045a2e0 --- /dev/null +++ b/src/peds/PedChat.cpp @@ -0,0 +1,153 @@ +#include "common.h" +#include "Camera.h" +#include "DMAudio.h" +#include "General.h" +#include "Ped.h" + +// Corresponds to ped sounds (from SOUND_PED_DEATH to SOUND_PED_TAXI_CALL) +PedAudioData CommentWaitTime[39] = { + {500, 800, 500, 2}, + {500, 800, 500, 2}, + {500, 800, 500, 2}, + {500, 800, 500, 2}, + {100, 2, 100, 2}, + {700, 500, 1000, 500}, + {700, 500, 1000, 500}, + {5000, 2000, 15000, 3000}, + {5000, 2000, 15000, 3000}, + {5000, 2000, 15000, 3000}, + {6000, 6000, 6000, 6000}, + {1000, 1000, 2000, 2000}, + {1000, 500, 2000, 1500}, + {1000, 500, 2000, 1500}, + {800, 200, 1000, 500}, + {800, 200, 1000, 500}, + {800, 400, 2000, 1000}, + {800, 400, 2000, 1000}, + {400, 300, 2000, 1000}, + {2000, 1000, 2500, 1500}, + {200, 200, 200, 200}, + {6000, 3000, 5000, 6000}, + {6000, 3000, 9000, 5000}, + {6000, 3000, 9000, 5000}, + {6000, 3000, 9000, 5000}, + {400, 300, 4000, 1000}, + {400, 300, 4000, 1000}, + {400, 300, 4000, 1000}, + {1000, 500, 3000, 1000}, + {1000, 500, 1000, 1000}, + {3000, 2000, 3000, 2000}, + {1000, 500, 3000, 6000}, + {1000, 500, 2000, 4000}, + {1000, 500, 2000, 5000}, + {1000, 500, 3000, 2000}, + {1600, 1000, 2000, 2000}, + {3000, 2000, 5000, 3000}, + {1000, 1000, 1000, 1000}, + {1000, 1000, 5000, 5000}, +}; + +bool +CPed::ServiceTalkingWhenDead(void) +{ + return m_queuedSound == SOUND_PED_DEATH; +} + +void +CPed::ServiceTalking(void) +{ + if (!bBodyPartJustCameOff || m_bodyPartBleeding != PED_HEAD) { + if (!CGeneral::faststricmp(CModelInfo::GetModelInfo(GetModelIndex())->GetName(), "bomber")) + m_queuedSound = SOUND_PED_BOMBER; + else if (m_nPedState == PED_ON_FIRE) + m_queuedSound = SOUND_PED_BURNING; + + if (m_queuedSound != SOUND_NO_SOUND) { + if (m_queuedSound == SOUND_PED_DEATH) + m_soundStart = CTimer::GetTimeInMilliseconds() - 1; + + if (CTimer::GetTimeInMilliseconds() > m_soundStart) { + DMAudio.PlayOneShot(m_audioEntityId, m_queuedSound, 1.0f); + m_lastSoundStart = CTimer::GetTimeInMilliseconds(); + m_soundStart = + CommentWaitTime[m_queuedSound - SOUND_PED_DEATH].m_nFixedDelayTime + + CTimer::GetTimeInMilliseconds() + + CGeneral::GetRandomNumberInRange(0, CommentWaitTime[m_queuedSound - SOUND_PED_DEATH].m_nOverrideFixedDelayTime); + m_lastQueuedSound = m_queuedSound; + m_queuedSound = SOUND_NO_SOUND; + } + } + } +} + +void +CPed::Say(uint16 audio) +{ + uint16 audioToPlay = audio; + + if (IsPlayer()) { + + // Ofc this part isn't in VC. + switch (audio) { + case SOUND_PED_DEATH: + audioToPlay = SOUND_PED_DAMAGE; + break; + case SOUND_PED_DAMAGE: + case SOUND_PED_HIT: + case SOUND_PED_LAND: + break; + case SOUND_PED_BULLET_HIT: + case SOUND_PED_CAR_JACKED: + case SOUND_PED_DEFEND: + audioToPlay = SOUND_PED_HIT; + break; + default: + return; + } + } else { + if (TheCamera.GetPosition().z + 3.0f < GetPosition().z) + return; + + if (TheCamera.m_CameraAverageSpeed > 1.65f) { +#ifdef VC_PED_PORTS + if (audio != SOUND_PED_DAMAGE && audio != SOUND_PED_HIT && audio != SOUND_PED_LAND) +#endif + return; + + } else if (TheCamera.m_CameraAverageSpeed > 1.25f) { + if (audio != SOUND_PED_DEATH && +#ifdef VC_PED_PORTS + audio != SOUND_PED_DAMAGE && audio != SOUND_PED_HIT && audio != SOUND_PED_LAND && +#endif + audio != SOUND_PED_TAXI_WAIT && audio != SOUND_PED_EVADE) + return; + + } else if (TheCamera.m_CameraAverageSpeed > 0.9f) { + switch (audio) { + case SOUND_PED_DEATH: +#ifdef VC_PED_PORTS + case SOUND_PED_DAMAGE: + case SOUND_PED_HIT: + case SOUND_PED_LAND: +#endif + case SOUND_PED_BURNING: + case SOUND_PED_FLEE_SPRINT: + case SOUND_PED_TAXI_WAIT: + case SOUND_PED_EVADE: + case SOUND_PED_CAR_COLLISION: + break; + default: + return; + } + } + } + + if (audioToPlay < m_queuedSound) { + if (audioToPlay != m_lastQueuedSound || audioToPlay == SOUND_PED_DEATH + || CommentWaitTime[audioToPlay - SOUND_PED_DEATH].m_nOverrideMaxRandomDelayTime + + m_lastSoundStart + + (uint32) CGeneral::GetRandomNumberInRange(0, CommentWaitTime[audioToPlay - SOUND_PED_DEATH].m_nMaxRandomDelayTime) <= CTimer::GetTimeInMilliseconds()) { + m_queuedSound = audioToPlay; + } + } +} \ No newline at end of file diff --git a/src/peds/PedDebug.cpp b/src/peds/PedDebug.cpp new file mode 100644 index 00000000..1c22963e --- /dev/null +++ b/src/peds/PedDebug.cpp @@ -0,0 +1,310 @@ +#include "common.h" +#ifndef MASTER +#include "main.h" +#include "Camera.h" +#include "Font.h" +#include "Ped.h" +#include "Sprite.h" +#include "Text.h" + + +static char ObjectiveText[][28] = { + "No Obj", + "Wait on Foot", + "Flee on Foot Till Safe", + "Guard Spot", + "Guard Area", + "Wait in Car", + "Wait in Car then Getout", + "Kill Char on Foot", + "Kill Char Any Means", + "Flee Char on Foot Till Safe", + "Flee Char on Foot Always", + "GoTo Char on Foot", + "Follow Char in Formation", + "Leave Car", + "Enter Car as Passenger", + "Enter Car as Driver", + "Follow Car in Car", + "Fire at Obj from Vehicle", + "Destroy Obj", + "Destroy Car", + "GoTo Area Any Means", + "GoTo Area on Foot", + "Run to Area", + "GoTo Area in Car", + "Follow Car on Foot Woffset", + "Guard Attack", + "Set Leader", + "Follow Route", + "Solicit", + "Take Taxi", + "Catch Train", + "Buy IceCream", + "Steal Any Car", + "Mug Char", +#ifdef VC_PED_PORTS + "Leave Car and Die" +#endif +}; + +static char StateText[][18] = { + "None", + "Idle", + "Look Entity", + "Look Heading", + "Wander Range", + "Wander Path", + "Seek Pos", + "Seek Entity", + "Flee Pos", + "Flee Entity", + "Pursue", + "Follow Path", + "Sniper Mode", + "Rocket Mode", + "Dummy", + "Pause", + "Attack", + "Fight", + "Face Phone", + "Make Call", + "Chat", + "Mug", + "AimGun", + "AI Control", + "Seek Car", + "Seek InBoat", + "Follow Route", + "C.P.R.", + "Solicit", + "Buy IceCream", + "Investigate", + "Step away", + "On Fire", + "Unknown", + "STATES_NO_AI", + "Jump", + "Fall", + "GetUp", + "Stagger", + "Dive away", + "STATES_NO_ST", + "Enter Train", + "Exit Train", + "Arrest Plyr", + "Driving", + "Passenger", + "Taxi Passngr", + "Open Door", + "Die", + "Dead", + "CarJack", + "Drag fm Car", + "Enter Car", + "Steal Car", + "Exit Car", + "Hands Up", + "Arrested", +}; + +static char PersonalityTypeText[][18] = { + "Player", + "Cop", + "Medic", + "Fireman", + "Gang 1", + "Gang 2", + "Gang 3", + "Gang 4", + "Gang 5", + "Gang 6", + "Gang 7", + "Street Guy", + "Suit Guy", + "Sensible Guy", + "Geek Guy", + "Old Guy", + "Tough Guy", + "Street Girl", + "Suit Girl", + "Sensible Girl", + "Geek Girl", + "Old Girl", + "Tough Girl", + "Tramp Male", + "Tramp Female", + "Tourist", + "Prostitute", + "Criminal", + "Busker", + "Taxi Driver", + "Psycho", + "Steward", + "Sports Fan", + "Shopper", + "Old Shopper" +}; + +static char WaitStateText[][16] = { + "No Wait", + "Traffic Lights", + "Pause CrossRoad", + "Look CrossRoad", + "Look Ped", + "Look Shop", + "Look Accident", + "FaceOff Gang", + "Double Back", + "Hit Wall", + "Turn 180deg", + "Surprised", + "Ped Stuck", + "Look About", + "Play Duck", + "Play Cower", + "Play Taxi", + "Play HandsUp", + "Play HandsCower", + "Play Chat", + "Finish Flee", +}; + +void +CPed::DebugDrawPedDestination(CPed *, int, int) +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +void +CPed::DebugDrawPedDesiredHeading(CPed *, int, int) +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +void +CPed::DebugDrawCollisionRadius(float, float, float, float, int) +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +void +CPed::DebugDrawVisionRange(CVector a1, float) +{ + for (int i = a1.x - 90; i < a1.x + 89; i += 30) { +#ifndef FINAL + // TODO: something was here +#endif // !FINAL + } +} + +void +CPed::DebugDrawVisionSimple(CVector, float) +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +void +CPed::DebugDrawLook() +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +void +CPed::DebugDrawPedPsyche() +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +void +CPed::DebugDrawDebugLines() +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +int nDisplayDebugInfo = 0; + +void +CPed::SwitchDebugDisplay(void) +{ + if (++nDisplayDebugInfo > 2) + nDisplayDebugInfo = 0; +} + +int +CPed::GetDebugDisplay(void) +{ + return nDisplayDebugInfo; +} + +void +CPed::DebugDrawLookAtPoints() +{ + // TODO: mobile code +} + +void +CPed::DebugRenderOnePedText(void) +{ + if ((GetPosition() - TheCamera.GetPosition()).MagnitudeSqr() < sq(30.0f)) { + float width, height; + RwV3d screenCoords; + CVector bitAbove = GetPosition(); + bitAbove.z += 2.0f; + if (CSprite::CalcScreenCoors(bitAbove, &screenCoords, &width, &height, true)) { + + float lineHeight = SCREEN_SCALE_Y(Min(height / 100.0f, 0.7f) * 22.0f); + + DefinedState(); + CFont::SetPropOn(); + CFont::SetBackgroundOn(); + + // Originally both of them were being divided by 60.0f. + float xScale = Min(width / 240.0f, 0.7f); + float yScale = Min(height / 80.0f, 0.7f); + + CFont::SetScale(SCREEN_SCALE_X(xScale), SCREEN_SCALE_Y(yScale)); + CFont::SetCentreOn(); + CFont::SetCentreSize(SCREEN_WIDTH); + CFont::SetJustifyOff(); + CFont::SetColor(CRGBA(255, 255, 0, 255)); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetFontStyle(0); + AsciiToUnicode(StateText[m_nPedState], gUString); + CFont::PrintString(screenCoords.x, screenCoords.y, gUString); + AsciiToUnicode(ObjectiveText[m_objective], gUString); + CFont::PrintString(screenCoords.x, screenCoords.y + lineHeight, gUString); + AsciiToUnicode(PersonalityTypeText[m_pedStats->m_type], gUString); + CFont::PrintString(screenCoords.x, screenCoords.y + 2 * lineHeight, gUString); + AsciiToUnicode(WaitStateText[m_nWaitState], gUString); + CFont::PrintString(screenCoords.x, screenCoords.y + 3 * lineHeight, gUString); + if (m_nPedState == PED_SEEK_POS || m_nPedState == PED_SEEK_ENTITY) { + sprintf(gString, "Safe distance to target: %.2f", m_distanceToCountSeekDone); + AsciiToUnicode(gString, gUString); + CFont::PrintString(screenCoords.x, screenCoords.y + 4 * lineHeight, gUString); + } + DefinedState(); + } + } +} + +void +CPed::DebugRenderClosePedText() +{ + // TODO: mobile code +} +#endif \ No newline at end of file -- cgit v1.2.3 From 016ebc0b00905c35ca16dcbd22c41fb4602c3e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Thu, 4 Jun 2020 06:03:12 +0300 Subject: fixes, mostly from miami --- src/peds/Ped.cpp | 56 +++++++++++++++++++++++++++++--------------------- src/peds/Ped.h | 2 +- src/peds/PlayerPed.cpp | 12 ++++++++--- 3 files changed, 43 insertions(+), 27 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 89c0b6af..a2068645 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -829,6 +829,9 @@ CPed::ClearAimFlag(void) bIsAimingGun = false; bIsRestoringGun = true; m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM; +#ifdef VC_PED_PORTS + m_lookTimer = 0; +#endif } if (IsPlayer()) @@ -3378,9 +3381,14 @@ CPed::SetStoredState(void) if (m_nMoveState == PEDMOVE_NONE || m_nMoveState == PEDMOVE_STILL) m_nMoveState = PEDMOVE_WALK; } - m_nLastPedState = m_nPedState; - if (m_nMoveState >= m_nPrevMoveState) - m_nPrevMoveState = m_nMoveState; +#ifdef VC_PED_PORTS + if (m_nPedState != PED_IDLE) +#endif + { + m_nLastPedState = m_nPedState; + if (m_nMoveState >= m_nPrevMoveState) + m_nPrevMoveState = m_nMoveState; + } } void @@ -5149,7 +5157,10 @@ CPed::SetWaitState(eWaitState state, void *time) case WAITSTATE_DOUBLEBACK: m_headingRate = 0.0f; m_nWaitTimer = CTimer::GetTimeInMilliseconds() + 3500; - CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_HBHB, 4.0f); + animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_HBHB, 4.0f); +#ifdef FIX_BUGS + animAssoc->SetFinishCallback(RestoreHeadingRateCB, this); +#endif break; case WAITSTATE_HITWALL: m_headingRate = 2.0f; @@ -5183,7 +5194,10 @@ CPed::SetWaitState(eWaitState state, void *time) SetMoveAnim(); m_headingRate = 0.0f; m_nWaitTimer = CTimer::GetTimeInMilliseconds() + 5000; - CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f); + animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f); +#ifdef FIX_BUGS + animAssoc->SetFinishCallback(RestoreHeadingRateCB, this); +#endif if (m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER && CharCreatedBy == RANDOM_CHAR && m_nPedState == PED_SEEK_CAR) { ClearObjective(); @@ -5196,7 +5210,11 @@ CPed::SetWaitState(eWaitState state, void *time) SetMoveAnim(); m_headingRate = 0.0f; m_nWaitTimer = CTimer::GetTimeInMilliseconds() + 5000; - CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_HBHB, 4.0f); + animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_HBHB, 4.0f); +#ifdef FIX_BUGS + animAssoc->SetFinishCallback(RestoreHeadingRateCB, this); +#endif + break; case WAITSTATE_PLAYANIM_COWER: waitAnim = ANIM_HANDSCOWER; @@ -5238,7 +5256,10 @@ CPed::SetWaitState(eWaitState state, void *time) SetMoveAnim(); m_headingRate = 0.0f; m_nWaitTimer = CTimer::GetTimeInMilliseconds() + 2500; - CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f); + animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f); +#ifdef FIX_BUGS + animAssoc->SetFinishCallback(RestoreHeadingRateCB, this); +#endif break; default: m_nWaitState = WAITSTATE_FALSE; @@ -5730,6 +5751,9 @@ CPed::SetChat(CEntity *chatWith, uint32 time) m_nPedState = PED_CHAT; SetMoveState(PEDMOVE_STILL); +#ifdef VC_PED_PORTS + m_lookTimer = 0; +#endif SetLookFlag(chatWith, true); m_standardTimer = CTimer::GetTimeInMilliseconds() + time; m_lookTimer = CTimer::GetTimeInMilliseconds() + 3000; @@ -5738,10 +5762,7 @@ CPed::SetChat(CEntity *chatWith, uint32 time) void CPed::SetDead(void) { -#ifdef VC_PED_PORTS - if (!RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DROWN)) -#endif - bUsesCollision = false; + bUsesCollision = false; m_fHealth = 0.0f; if (m_nPedState == PED_DRIVING) @@ -9236,17 +9257,6 @@ CPed::ProcessControl(void) float oldDestRot = CGeneral::LimitRadianAngle(m_fRotationDest); -#ifdef VC_PED_PORTS - if (m_nPedState == PED_FOLLOW_PATH) { - if (DotProduct(m_vecDamageNormal, GetForward()) < -0.866f && CanPedJumpThis(collidingEnt, &m_vecDamageNormal)) { - SetJump(); - - // Moved break into here, for compatibility with III - break; - } - // break; - } -#endif if (m_pedInObjective && (m_objective == OBJECTIVE_GOTO_CHAR_ON_FOOT || m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT)) { @@ -10072,7 +10082,7 @@ CPed::ProcessControl(void) case PED_SEEK_ENTITY: case PED_PURSUE: case PED_SNIPER_MODE: - case PED_ROCKET_ODE: + case PED_ROCKET_MODE: case PED_DUMMY: case PED_FACE_PHONE: case PED_MAKE_CALL: diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 59e0053b..6e536ede 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -231,7 +231,7 @@ enum PedState PED_PURSUE, PED_FOLLOW_PATH, PED_SNIPER_MODE, - PED_ROCKET_ODE, + PED_ROCKET_MODE, PED_DUMMY, PED_PAUSE, PED_ATTACK, diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index eb4ac09e..305c329e 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -1058,6 +1058,9 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) } #ifdef FREE_CAM + static int8 changedHeadingRate = 0; + if (changedHeadingRate == 2) changedHeadingRate = 1; + // Rotate player/arm when shooting. We don't have auto-rotation anymore if (CCamera::m_bUseMouse3rdPerson && CCamera::bFreeCam && m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) { @@ -1081,6 +1084,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) #endif } else { m_fRotationDest = limitedCam; + changedHeadingRate = 2; m_headingRate = 50.0f; // Anim. fix for shotgun, ak47 and m16 (we must finish rot. it quickly) @@ -1099,10 +1103,12 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) } } else if (weaponInfo->m_bCanAimWithArm) ClearPointGunAt(); - else - RestoreHeadingRate(); } } + if (changedHeadingRate == 1) { + changedHeadingRate = 0; + RestoreHeadingRate(); + } #endif if (padUsed->GetTarget() && m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) { @@ -1347,7 +1353,7 @@ CPlayerPed::ProcessControl(void) case PED_WANDER_PATH: case PED_PURSUE: case PED_FOLLOW_PATH: - case PED_ROCKET_ODE: + case PED_ROCKET_MODE: case PED_DUMMY: case PED_PAUSE: case PED_FACE_PHONE: -- cgit v1.2.3 From 3f26250d73d5c196a66262821a7980ccdbd8deed Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 6 Jun 2020 13:31:09 +0300 Subject: fixing some uninitialized stuff --- src/peds/Ped.cpp | 3 +++ src/peds/PlayerPed.cpp | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index eebfa099..4e9280e6 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -187,6 +187,9 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) m_queuedSound = SOUND_NO_SOUND; m_objective = OBJECTIVE_NONE; m_prevObjective = OBJECTIVE_NONE; +#ifdef FIX_BUGS + m_objectiveTimer = 0; +#endif CharCreatedBy = RANDOM_CHAR; m_leader = nil; m_pedInObjective = nil; diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 305c329e..6613ea1b 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -35,6 +35,9 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1) { m_fMoveSpeed = 0.0f; SetModelIndex(MI_PLAYER); +#ifdef FIX_BUGS + m_fCurrentStamina = m_fMaxStamina = 150.0f; +#endif SetInitialState(); m_pWanted = new CWanted(); @@ -46,8 +49,9 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1) m_bSpeedTimerFlag = false; m_pPointGunAt = nil; m_nPedState = PED_IDLE; - m_fMaxStamina = 150.0f; - m_fCurrentStamina = m_fMaxStamina; +#ifndef FIX_BUGS + m_fCurrentStamina = m_fMaxStamina = 150.0f; +#endif m_fStaminaProgress = 0.0f; m_nEvadeAmount = 0; field_1367 = 0; -- cgit v1.2.3 From e099aaaa6b7aa90a632d785c6f83a1fbb110cdd9 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 6 Jun 2020 16:36:26 +0300 Subject: minor fixes --- src/peds/Ped.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 4e9280e6..254f89a6 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -243,6 +243,9 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) m_nPedState = PED_IDLE; m_nLastPedState = PED_NONE; m_nMoveState = PEDMOVE_STILL; +#ifdef FIX_BUGS + m_nPrevMoveState = PEDMOVE_NONE; +#endif m_nStoredMoveState = PEDMOVE_NONE; m_pFire = nil; m_pPointGunAt = nil; -- cgit v1.2.3 From cafe4d6f0cafaa431dcf4bce7a96af73fc833ef8 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 25 Jun 2020 15:12:57 +0200 Subject: rename attractor flag to type --- src/peds/Ped.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/peds') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 254f89a6..cf254cf4 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -8644,11 +8644,11 @@ CPed::LookForInterestingNodes(void) return false; } - switch (effect->attractor.flags) { - case ATTRACTORFLAG_ICECREAM: + switch (effect->attractor.type) { + case ATTRACTORTYPE_ICECREAM: SetInvestigateEvent(EVENT_ICECREAM, CVector2D(effectPos), 0.1f, 15000, angleToFace); break; - case ATTRACTORFLAG_STARE: + case ATTRACTORTYPE_STARE: SetInvestigateEvent(EVENT_SHOPSTALL, CVector2D(effectPos), 1.0f, CGeneral::GetRandomNumberInRange(8000, 10 * effect->attractor.probability + 8500), angleToFace); -- cgit v1.2.3