diff options
author | Sergeanur <s.anureev@yandex.ua> | 2021-08-16 09:09:39 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2021-08-16 09:09:39 +0200 |
commit | d7e764d519a9b96969786a99494eba8c3af988b9 (patch) | |
tree | 811331933b6959a1071d452536c4eca7873621ac /src/weapons/Weapon.cpp | |
parent | Merge branch 'lcs' of github.com:GTAmodding/re3 into lcs (diff) | |
parent | PS2 audio reflections (diff) | |
download | re3-d7e764d519a9b96969786a99494eba8c3af988b9.tar re3-d7e764d519a9b96969786a99494eba8c3af988b9.tar.gz re3-d7e764d519a9b96969786a99494eba8c3af988b9.tar.bz2 re3-d7e764d519a9b96969786a99494eba8c3af988b9.tar.lz re3-d7e764d519a9b96969786a99494eba8c3af988b9.tar.xz re3-d7e764d519a9b96969786a99494eba8c3af988b9.tar.zst re3-d7e764d519a9b96969786a99494eba8c3af988b9.zip |
Diffstat (limited to 'src/weapons/Weapon.cpp')
-rw-r--r-- | src/weapons/Weapon.cpp | 71 |
1 files changed, 60 insertions, 11 deletions
diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 39f2265f..31738dbc 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -49,6 +49,29 @@ bool CWeapon::bPhotographHasBeenTaken; int32 sniperPirateCheck = 0x00797743; // 'Cwy\0' ??? #endif +#ifdef FREE_CAM +static bool +Find3rdPersonCamTargetVectorFromCachedVectors(float dist, CVector pos, CVector& source, CVector& target, CVector camSource, CVector camFront, CVector camUp) +{ + if (CPad::GetPad(0)->GetLookBehindForPed()) { + source = pos; + target = dist * FindPlayerPed()->GetForward() + source; + return false; + } else { + float angleX = DEGTORAD((CCamera::m_f3rdPersonCHairMultX - 0.5f) * 1.8f * 0.5f * TheCamera.Cams[TheCamera.ActiveCam].FOV * CDraw::GetAspectRatio()); + float angleY = DEGTORAD((0.5f - CCamera::m_f3rdPersonCHairMultY) * 1.8f * 0.5f * TheCamera.Cams[TheCamera.ActiveCam].FOV); + source = camSource; + target = camFront; + target += camUp * Tan(angleY); + target += CrossProduct(camFront, camUp) * Tan(angleX); + target.Normalise(); + source += DotProduct(pos - source, target) * target; + target = dist * target + source; + return true; + } +} +#endif + CWeaponInfo * CWeapon::GetInfo() { @@ -943,17 +966,23 @@ CWeapon::FireInstantHit(CEntity *shooter, CVector *fireSource) } else if ( shooter == FindPlayerPed() && TheCamera.Cams[0].Using3rdPersonMouseCam() ) { - TheCamera.Find3rdPersonCamTargetVector(info->m_fRange, *fireSource, source, target); #ifdef FREE_CAM - CPed *shooterPed = (CPed *)shooter; - if((shooterPed->m_pedIK.m_flags & CPedIK::GUN_POINTED_SUCCESSFULLY) == 0) { - target.x = info->m_fRange; - target.y = 0.0f; - target.z = 0.0f; + if (CCamera::bFreeCam) { + CPlayerPed* shooterPed = (CPlayerPed*)shooter; + Find3rdPersonCamTargetVectorFromCachedVectors(info->m_fRange, *fireSource, source, target, shooterPed->m_cachedCamSource, shooterPed->m_cachedCamFront, shooterPed->m_cachedCamUp); - shooterPed->TransformToNode(target, PED_HANDR); - } + if ((shooterPed->m_pedIK.m_flags & CPedIK::GUN_POINTED_SUCCESSFULLY) == 0) { + target.x = info->m_fRange; + target.y = 0.0f; + target.z = 0.0f; + + shooterPed->TransformToNode(target, PED_HANDR); + } + } else #endif + { + TheCamera.Find3rdPersonCamTargetVector(info->m_fRange, *fireSource, source, target); + } #ifdef FIX_BUGS // fix muzzleflash rotation @@ -1708,8 +1737,19 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource) if ( shooter == FindPlayerPed() && TheCamera.Cams[0].Using3rdPersonMouseCam() ) { - TheCamera.Find3rdPersonCamTargetVector(1.0f, *fireSource, source, target); - CVector Left = CrossProduct(TheCamera.Cams[TheCamera.ActiveCam].Front, TheCamera.Cams[TheCamera.ActiveCam].Up); + CVector Left; +#ifdef FREE_CAM + if (CCamera::bFreeCam) { + CPlayerPed* shooterPed = (CPlayerPed*)shooter; + Find3rdPersonCamTargetVectorFromCachedVectors(1.0f, *fireSource, source, target, shooterPed->m_cachedCamSource, shooterPed->m_cachedCamFront, shooterPed->m_cachedCamUp); + Left = CrossProduct(shooterPed->m_cachedCamFront, shooterPed->m_cachedCamUp); + } + else +#endif + { + TheCamera.Find3rdPersonCamTargetVector(1.0f, *fireSource, source, target); + Left = CrossProduct(TheCamera.Cams[TheCamera.ActiveCam].Front, TheCamera.Cams[TheCamera.ActiveCam].Up); + } float f = (i - (shootsAtOnce / 2)) * angleBetweenTwoShot; target = f * Left + target - source; @@ -2151,7 +2191,16 @@ CWeapon::FireAreaEffect(CEntity *shooter, CVector *fireSource) if ( shooter == FindPlayerPed() && TheCamera.Cams[0].Using3rdPersonMouseCam() ) { - TheCamera.Find3rdPersonCamTargetVector(info->m_fRange, *fireSource, source, target); +#ifdef FREE_CAM + if (CCamera::bFreeCam) { + CPlayerPed* shooterPed = (CPlayerPed*)shooter; + Find3rdPersonCamTargetVectorFromCachedVectors(info->m_fRange, *fireSource, source, target, shooterPed->m_cachedCamSource, shooterPed->m_cachedCamFront, shooterPed->m_cachedCamUp); + } + else +#endif + { + TheCamera.Find3rdPersonCamTargetVector(info->m_fRange, *fireSource, source, target); + } float norm = (1.0f / info->m_fRange); dir = (target - source) * norm; } |