From 60777dc01ae4cef978430bb9981bf7f3a8423b4a Mon Sep 17 00:00:00 2001 From: FileEX Date: Thu, 31 Jul 2025 03:53:10 +0200 Subject: [PATCH 1/9] setCameraFieldOfView improvements & resetCameraFieldOfView --- Client/game_sa/CSettingsSA.cpp | 168 ++++++++++++++++++ Client/game_sa/CSettingsSA.h | 11 ++ .../logic/lua/CLuaFunctionParseHelpers.cpp | 2 + .../logic/lua/CLuaFunctionParseHelpers.h | 4 +- .../logic/luadefs/CLuaCameraDefs.cpp | 89 +++++----- .../deathmatch/logic/luadefs/CLuaCameraDefs.h | 3 +- Client/sdk/game/CSettings.h | 12 ++ 7 files changed, 244 insertions(+), 45 deletions(-) diff --git a/Client/game_sa/CSettingsSA.cpp b/Client/game_sa/CSettingsSA.cpp index 24f29aa31fb..3640b3651eb 100644 --- a/Client/game_sa/CSettingsSA.cpp +++ b/Client/game_sa/CSettingsSA.cpp @@ -494,6 +494,15 @@ float ms_fFOVCarMax = 100; // at high vehicle velocity bool ms_bFOVPlayerFromScript = false; bool ms_bFOVVehicleFromScript = false; +float ms_fovAiming = 70.0f; +float ms_fovSniperAiming_Min = 0.0f; // default 15 +float ms_fovSniperAiming_Max = 179.0f; // default 70 +float ms_fov1stPersonAiming = 70.0f; +float ms_fovSniperAiming = 70.0f; +bool ms_fovAimingFromScript = false; +bool ms_fovSniperAimingFromScript = false; +bool ms_fov1stPersonAimingFromScript = false; + // consider moving this to the camera class - qaisjp float CSettingsSA::GetFieldOfViewPlayer() { @@ -510,6 +519,82 @@ float CSettingsSA::GetFieldOfViewVehicleMax() return ms_fFOVCarMax; } +float CSettingsSA::GetFieldOfViewAiming() +{ + CCamera* camera = pGame->GetCamera(); + CCam* cam = camera->GetCam(camera->GetActiveCam()); + eCamMode cameraViewMode = static_cast(camera->GetCam(camera->GetActiveCam())->GetMode()); + + return (cameraViewMode == MODE_AIMWEAPON || cameraViewMode == MODE_AIMWEAPON_FROMCAR || cameraViewMode == MODE_AIMWEAPON_ATTACHED) ? cam->GetFOV() : ms_fovAiming; +} + +float CSettingsSA::GetFieldOfViewSniperAiming() +{ + CCamera* camera = pGame->GetCamera(); + CCam* cam = camera->GetCam(camera->GetActiveCam()); + eCamMode cameraViewMode = static_cast(camera->GetCam(camera->GetActiveCam())->GetMode()); + + return (cameraViewMode == MODE_SNIPER) ? cam->GetFOV() : ms_fovSniperAiming; +} + +float CSettingsSA::GetFieldOfView1stPersonAiming() +{ + return ms_fov1stPersonAiming; +} + +void CSettingsSA::ResetFieldOfViewPlayer() +{ + float fieldOfView; + g_pCore->GetCVars()->Get("fov", fieldOfView); + fieldOfView = Clamp(70.f, fieldOfView, 100.f); + + ms_bFOVPlayerFromScript = false; + SetFieldOfViewPlayer(fieldOfView, false); +} + +void CSettingsSA::ResetFieldOfViewVehicle() +{ + float fieldOfView; + g_pCore->GetCVars()->Get("fov", fieldOfView); + fieldOfView = Clamp(70.f, fieldOfView, 100.f); + + ms_bFOVVehicleFromScript = false; + SetFieldOfViewVehicle(fieldOfView, false); +} + +void CSettingsSA::ResetFieldOfViewVehicleMax() +{ + ms_bFOVVehicleFromScript = false; + SetFieldOfViewVehicleMax(100, false); +} + +void CSettingsSA::ResetFieldOfViewSniperAiming() +{ + // Restore original bytes + // Zoom in + MemPut(0x51089F, (void*)0x858CE0); + MemPut(0x5108B8, (void*)0x858CE0); + MemPut(0x5108AE, "\x8C\x42"); + MemPut(0x5108CF, "\x8C\x42"); + + // Zoom out + MemPut(0x5109A3, (void*)0x858B48); + MemPut(0x5109BC, (void*)0x858B48); + MemPut(0x5109B2, "\x70\x41"); + MemPut(0x5109CF, "\x70\x41"); + + ms_fovSniperAimingFromScript = false; + ms_fovSniperAiming = 70.0f; +} + +void CSettingsSA::ResetFieldOfView1stPersonAiming() +{ + MemPut((void*)0x510711, "\xC7\x07\x00\x00\x8C\x42"); + + ms_fov1stPersonAimingFromScript = false; + ms_fov1stPersonAiming = 70.0f; +} + void CSettingsSA::UpdateFieldOfViewFromSettings() { float fFieldOfView; @@ -518,12 +603,19 @@ void CSettingsSA::UpdateFieldOfViewFromSettings() SetFieldOfViewPlayer(fFieldOfView, false); SetFieldOfViewVehicle(fFieldOfView, false); SetFieldOfViewVehicleMax(100, false); + + ResetFieldOfViewSniperAiming(); + ResetFieldOfView1stPersonAiming(); } void CSettingsSA::ResetFieldOfViewFromScript() { ms_bFOVPlayerFromScript = false; ms_bFOVVehicleFromScript = false; + ms_fovAimingFromScript = false; + ms_fovSniperAimingFromScript = false; + ms_fov1stPersonAimingFromScript = false; + UpdateFieldOfViewFromSettings(); } @@ -598,6 +690,82 @@ void CSettingsSA::SetFieldOfViewVehicleMax(float fAngle, bool bFromScript, bool MemPut(0x0524BC5, ms_fFOVCarMax); } +////////////////////////////////////////////// +// This needs to be called every frame, because CCam::Process_AimWeapon overrides the FOV every frame +////////////////////////////////////////////// +bool CSettingsSA::SetFieldOfViewAiming(float angle, bool fromScript) +{ + if (!fromScript && ms_fovAimingFromScript) + return false; + + CCamera* camera = pGame->GetCamera(); + CCam* cam = camera->GetCam(camera->GetActiveCam()); + eCamMode cameraViewMode = static_cast(camera->GetCam(camera->GetActiveCam())->GetMode()); + + if (cameraViewMode != MODE_AIMWEAPON && cameraViewMode != MODE_AIMWEAPON_FROMCAR && cameraViewMode != MODE_AIMWEAPON_ATTACHED) + return false; + + cam->SetFOV(angle); + ms_fovAimingFromScript = fromScript; + ms_fovAiming = angle; + + return true; +} + +bool CSettingsSA::SetFieldOfViewSniperAiming(float angle, bool fromScript) +{ + if (!fromScript && ms_fovSniperAimingFromScript) + return false; + + CCamera* camera = pGame->GetCamera(); + CCam* cam = camera->GetCam(camera->GetActiveCam()); + eCamMode cameraViewMode = static_cast(camera->GetCam(camera->GetActiveCam())->GetMode()); + + if (!ms_fovSniperAimingFromScript && fromScript) + { + // Patch sniper zoom-in/zoom-out limit + // zoom in + MemPut(0x51089F, &ms_fovSniperAiming_Max); + MemPut(0x5108B8, &ms_fovSniperAiming_Max); + + MemPut(0x5108AE, "\x33\x43"); + MemPut(0x5108CF, "\x33\x43"); + + // zoom out + MemPut(0x5109A3, &ms_fovSniperAiming_Min); + MemPut(0x5109BC, &ms_fovSniperAiming_Min); + MemPut(0x5109B2, "\x00\x00"); + MemPut(0x5109CF, "\x00\x00"); + } + + if (cameraViewMode == MODE_SNIPER) + cam->SetFOV(angle); + + ms_fovSniperAimingFromScript = fromScript; + ms_fovSniperAiming = angle; + return true; +} + +bool CSettingsSA::SetFieldOfView1stPersonAiming(float angle, bool fromScript) +{ + if (!fromScript && ms_fov1stPersonAimingFromScript) + return false; + + CCamera* camera = pGame->GetCamera(); + CCam* cam = camera->GetCam(camera->GetActiveCam()); + eCamMode cameraViewMode = static_cast(camera->GetCam(camera->GetActiveCam())->GetMode()); + + if (!ms_fov1stPersonAimingFromScript && fromScript) + MemSet((void*)0x510711, 0x90, 6); + + if (cameraViewMode == MODE_SNIPER || cameraViewMode == MODE_M16_1STPERSON || cameraViewMode == MODE_HELICANNON_1STPERSON || cameraViewMode == MODE_CAMERA) + cam->SetFOV(angle); + + ms_fov1stPersonAimingFromScript = fromScript; + ms_fov1stPersonAiming = angle; + return true; +} + //////////////////////////////////////////////// // // Vehicles LOD draw distance diff --git a/Client/game_sa/CSettingsSA.h b/Client/game_sa/CSettingsSA.h index 8e1443d1171..b96dbf35f67 100644 --- a/Client/game_sa/CSettingsSA.h +++ b/Client/game_sa/CSettingsSA.h @@ -165,9 +165,20 @@ class CSettingsSA : public CGameSettings void SetFieldOfViewPlayer(float fAngle, bool bFromScript, bool instant = false); void SetFieldOfViewVehicle(float fAngle, bool bFromScript, bool instant = false); void SetFieldOfViewVehicleMax(float fAngle, bool bFromScript, bool instant = false); + bool SetFieldOfViewAiming(float angle, bool fromScript); + bool SetFieldOfViewSniperAiming(float angle, bool fromScript); + bool SetFieldOfView1stPersonAiming(float angle, bool fromScript); float GetFieldOfViewPlayer(); float GetFieldOfViewVehicle(); float GetFieldOfViewVehicleMax(); + float GetFieldOfViewAiming(); + float GetFieldOfViewSniperAiming(); + float GetFieldOfView1stPersonAiming(); + void ResetFieldOfViewPlayer(); + void ResetFieldOfViewVehicle(); + void ResetFieldOfViewVehicleMax(); + void ResetFieldOfViewSniperAiming(); + void ResetFieldOfView1stPersonAiming(); void SetVehiclesLODDistance(float fVehiclesLODDistance, float fTrainsPlanesLODDistance, bool bFromScript); void ResetVehiclesLODDistance(bool bForceDefault = false); diff --git a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp index 1a538347626..4d20973ad17 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp +++ b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp @@ -554,6 +554,8 @@ ADD_ENUM(FOV_MODE_PLAYER, "player") ADD_ENUM(FOV_MODE_VEHICLE, "vehicle") ADD_ENUM(FOV_MODE_VEHICLE_MAX, "vehicle_max") ADD_ENUM(FOV_MODE_AIMING, "aiming") +ADD_ENUM(FOV_MODE_SNIPER_AIMING, "sniper_aiming") +ADD_ENUM(FOV_MODE_1ST_PERSON_AIMING, "1stperson_aiming") IMPLEMENT_ENUM_END("fieldofview-mode") IMPLEMENT_ENUM_BEGIN(eTrayIconType) diff --git a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h index da35c0d1cc2..35ea1f1ce2c 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h +++ b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h @@ -130,7 +130,9 @@ enum eFieldOfViewMode FOV_MODE_PLAYER, FOV_MODE_VEHICLE, FOV_MODE_VEHICLE_MAX, - FOV_MODE_AIMING + FOV_MODE_AIMING, + FOV_MODE_SNIPER_AIMING, + FOV_MODE_1ST_PERSON_AIMING }; DECLARE_ENUM(eFieldOfViewMode); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp index 9c8cb6cd830..ace56f24b09 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp @@ -33,7 +33,8 @@ void CLuaCameraDefs::LoadFunctions() // Cam set funcs {"setCameraMatrix", SetCameraMatrix}, - {"setCameraFieldOfView", SetCameraFieldOfView}, + {"setCameraFieldOfView", ArgumentParserWarn}, + {"resetCameraFieldOfView", ArgumentParser}, {"setCameraTarget", SetCameraTarget}, {"setCameraInterior", SetCameraInterior}, {"fadeCamera", FadeCamera}, @@ -77,6 +78,7 @@ void CLuaCameraDefs::AddClass(lua_State* luaVM) lua_classfunction(luaVM, "setRotation", OOP_SetCameraRotation); lua_classfunction(luaVM, "setMatrix", "setCameraMatrix"); lua_classfunction(luaVM, "setFieldOfView", "setCameraFieldOfView"); + lua_classfunction(luaVM, "resetFieldOfView", "resetCameraFieldOfView"); lua_classfunction(luaVM, "setInterior", "setCameraInterior"); lua_classfunction(luaVM, "setTarget", "setCameraTarget"); lua_classfunction(luaVM, "setViewMode", "setCameraViewMode"); @@ -211,54 +213,55 @@ int CLuaCameraDefs::SetCameraMatrix(lua_State* luaVM) return 1; } -// Only when onfoot/invehicle -int CLuaCameraDefs::SetCameraFieldOfView(lua_State* luaVM) +bool CLuaCameraDefs::SetCameraFieldOfView(eFieldOfViewMode mode, float fov, std::optional instant) { - float fFOV; - eFieldOfViewMode eMode; - bool instant; - CScriptArgReader argStream(luaVM); - argStream.ReadEnumString(eMode); - argStream.ReadNumber(fFOV); - argStream.ReadBool(instant, false); + if (fov < 0 || fov > 179) + throw std::invalid_argument("Invalid FOV range (0-179)"); - if (!argStream.HasErrors()) + switch (mode) { - while (true) - { - if (fFOV < 0 || fFOV > 179) - { - argStream.SetCustomError("Invalid FOV range (0-179)"); - break; - } + case FOV_MODE_PLAYER: + g_pGame->GetSettings()->SetFieldOfViewPlayer(fov, true, instant.value_or(false)); + break; + case FOV_MODE_VEHICLE: + g_pGame->GetSettings()->SetFieldOfViewVehicle(fov, true, instant.value_or(false)); + break; + case FOV_MODE_VEHICLE_MAX: + g_pGame->GetSettings()->SetFieldOfViewVehicleMax(fov, true, instant.value_or(false)); + break; + case FOV_MODE_AIMING: + return g_pGame->GetSettings()->SetFieldOfViewAiming(fov, true); + case FOV_MODE_SNIPER_AIMING: + return g_pGame->GetSettings()->SetFieldOfViewSniperAiming(fov, true); + case FOV_MODE_1ST_PERSON_AIMING: + return g_pGame->GetSettings()->SetFieldOfView1stPersonAiming(fov, true); + } - if (eMode == FOV_MODE_PLAYER) - { - g_pGame->GetSettings()->SetFieldOfViewPlayer(fFOV, true, instant); - } - else if (eMode == FOV_MODE_VEHICLE) - { - g_pGame->GetSettings()->SetFieldOfViewVehicle(fFOV, true, instant); - } - else if (eMode == FOV_MODE_VEHICLE_MAX) - { - g_pGame->GetSettings()->SetFieldOfViewVehicleMax(fFOV, true, instant); - } - else - { - argStream.m_iIndex = 1; - argStream.SetCustomError(SString("Enum not yet implemented: " + EnumToString(eMode))); - break; - } + return true; +} - lua_pushboolean(luaVM, true); - return 1; - } +void CLuaCameraDefs::ResetCameraFieldOfView(eFieldOfViewMode mode) +{ + switch (mode) + { + case FOV_MODE_PLAYER: + g_pGame->GetSettings()->ResetFieldOfViewPlayer(); + break; + case FOV_MODE_VEHICLE: + g_pGame->GetSettings()->ResetFieldOfViewVehicle(); + break; + case FOV_MODE_VEHICLE_MAX: + g_pGame->GetSettings()->ResetFieldOfViewVehicleMax(); + break; + case FOV_MODE_AIMING: + break; + case FOV_MODE_SNIPER_AIMING: + g_pGame->GetSettings()->ResetFieldOfViewSniperAiming(); + break; + case FOV_MODE_1ST_PERSON_AIMING: + g_pGame->GetSettings()->ResetFieldOfView1stPersonAiming(); + break; } - - m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); - lua_pushboolean(luaVM, false); - return 1; } // Only when onfoot/invehicle diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.h index b233d4e39c8..72419aa1246 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.h @@ -36,7 +36,8 @@ class CLuaCameraDefs : public CLuaDefs LUA_DECLARE(SetCameraMatrix); LUA_DECLARE(SetCameraTarget); LUA_DECLARE(SetCameraInterior); - LUA_DECLARE(SetCameraFieldOfView); + static bool SetCameraFieldOfView(eFieldOfViewMode mode, float fov, std::optional instant); + static void ResetCameraFieldOfView(eFieldOfViewMode mode); LUA_DECLARE(FadeCamera); LUA_DECLARE(SetCameraClip); LUA_DECLARE(GetCameraClip); diff --git a/Client/sdk/game/CSettings.h b/Client/sdk/game/CSettings.h index 624b166fb56..728ac402552 100644 --- a/Client/sdk/game/CSettings.h +++ b/Client/sdk/game/CSettings.h @@ -158,10 +158,22 @@ class CGameSettings virtual void SetFieldOfViewPlayer(float fAngle, bool bFromScript, bool instant = false) = 0; virtual void SetFieldOfViewVehicle(float fAngle, bool bFromScript, bool instant = false) = 0; virtual void SetFieldOfViewVehicleMax(float fAngle, bool bFromScript, bool instant = false) = 0; + virtual bool SetFieldOfViewAiming(float angle, bool fromScript) = 0; + virtual bool SetFieldOfViewSniperAiming(float angle, bool fromScript) = 0; + virtual bool SetFieldOfView1stPersonAiming(float angle, bool fromScript) = 0; virtual float GetFieldOfViewPlayer() = 0; virtual float GetFieldOfViewVehicle() = 0; virtual float GetFieldOfViewVehicleMax() = 0; + virtual float GetFieldOfViewAiming() = 0; + virtual float GetFieldOfViewSniperAiming() = 0; + virtual float GetFieldOfView1stPersonAiming() = 0; + + virtual void ResetFieldOfViewPlayer() = 0; + virtual void ResetFieldOfViewVehicle() = 0; + virtual void ResetFieldOfViewVehicleMax() = 0; + virtual void ResetFieldOfViewSniperAiming() = 0; + virtual void ResetFieldOfView1stPersonAiming() = 0; virtual void SetVehiclesLODDistance(float fVehiclesLODDistance, float fTrainsPlanesLODDistance, bool bFromScript) = 0; virtual void ResetVehiclesLODDistance(bool bForceDefault = false) = 0; From d528a63d2195fd14a207455b282573e84373743c Mon Sep 17 00:00:00 2001 From: FileEX Date: Thu, 31 Jul 2025 04:09:13 +0200 Subject: [PATCH 2/9] Allow FOV change for RPG camera mode --- Client/game_sa/CSettingsSA.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Client/game_sa/CSettingsSA.cpp b/Client/game_sa/CSettingsSA.cpp index 3640b3651eb..1b926cc2acf 100644 --- a/Client/game_sa/CSettingsSA.cpp +++ b/Client/game_sa/CSettingsSA.cpp @@ -590,6 +590,7 @@ void CSettingsSA::ResetFieldOfViewSniperAiming() void CSettingsSA::ResetFieldOfView1stPersonAiming() { MemPut((void*)0x510711, "\xC7\x07\x00\x00\x8C\x42"); + MemPut((void*)0x511B71, "\xC7\x86\xB4\x00\x00\x00\x00\x00\x8C\x42"); ms_fov1stPersonAimingFromScript = false; ms_fov1stPersonAiming = 70.0f; @@ -756,7 +757,10 @@ bool CSettingsSA::SetFieldOfView1stPersonAiming(float angle, bool fromScript) eCamMode cameraViewMode = static_cast(camera->GetCam(camera->GetActiveCam())->GetMode()); if (!ms_fov1stPersonAimingFromScript && fromScript) + { MemSet((void*)0x510711, 0x90, 6); + MemSet((void*)0x511B71, 0x90, 10); + } if (cameraViewMode == MODE_SNIPER || cameraViewMode == MODE_M16_1STPERSON || cameraViewMode == MODE_HELICANNON_1STPERSON || cameraViewMode == MODE_CAMERA) cam->SetFOV(angle); From 5af3b591f6ec6381cbc47d658e37cb53a440567c Mon Sep 17 00:00:00 2001 From: FileEX Date: Thu, 31 Jul 2025 04:23:37 +0200 Subject: [PATCH 3/9] Update GetCameraFieldOfView --- .../logic/luadefs/CLuaCameraDefs.cpp | 57 +++++++------------ .../deathmatch/logic/luadefs/CLuaCameraDefs.h | 2 +- 2 files changed, 23 insertions(+), 36 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp index ace56f24b09..b9884d3c324 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp @@ -28,7 +28,7 @@ void CLuaCameraDefs::LoadFunctions() {"getCameraTarget", ArgumentParserWarn}, {"getCameraInterior", ArgumentParserWarn}, {"getCameraGoggleEffect", ArgumentParserWarn}, - {"getCameraFieldOfView", GetCameraFieldOfView}, + {"getCameraFieldOfView", ArgumentParserWarn}, {"getCameraDrunkLevel", ArgumentParserWarn}, // Cam set funcs @@ -163,6 +163,27 @@ std::string CLuaCameraDefs::GetCameraGoggleEffect() return "normal"; } +std::variant CLuaCameraDefs::GetCameraFieldOfView(eFieldOfViewMode mode) +{ + switch (mode) + { + case FOV_MODE_PLAYER: + return g_pGame->GetSettings()->GetFieldOfViewPlayer(); + case FOV_MODE_VEHICLE: + return g_pGame->GetSettings()->GetFieldOfViewVehicle(); + case FOV_MODE_VEHICLE_MAX: + return g_pGame->GetSettings()->GetFieldOfViewVehicleMax(); + case FOV_MODE_AIMING: + return g_pGame->GetSettings()->GetFieldOfViewAiming(); + case FOV_MODE_SNIPER_AIMING: + return g_pGame->GetSettings()->GetFieldOfViewSniperAiming(); + case FOV_MODE_1ST_PERSON_AIMING: + return g_pGame->GetSettings()->GetFieldOfView1stPersonAiming(); + default: + return false; + } +} + unsigned char CLuaCameraDefs::GetCameraDrunkLevel() { return g_pGame->GetPlayerInfo()->GetCamDrunkLevel(); @@ -264,40 +285,6 @@ void CLuaCameraDefs::ResetCameraFieldOfView(eFieldOfViewMode mode) } } -// Only when onfoot/invehicle -int CLuaCameraDefs::GetCameraFieldOfView(lua_State* luaVM) -{ - eFieldOfViewMode eMode; - CScriptArgReader argStream(luaVM); - - argStream.ReadEnumString(eMode); - - if (!argStream.HasErrors()) - { - float fFOV; - if (eMode == FOV_MODE_PLAYER) - fFOV = g_pGame->GetSettings()->GetFieldOfViewPlayer(); - else if (eMode == FOV_MODE_VEHICLE) - fFOV = g_pGame->GetSettings()->GetFieldOfViewVehicle(); - else if (eMode == FOV_MODE_VEHICLE_MAX) - fFOV = g_pGame->GetSettings()->GetFieldOfViewVehicleMax(); - else - { - argStream.m_iIndex = 1; - m_pScriptDebugging->LogCustom(luaVM, SString("Enum not yet implemented: " + EnumToString(eMode))); - lua_pushboolean(luaVM, false); - return 1; - } - - lua_pushnumber(luaVM, fFOV); - return 1; - } - - m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); - lua_pushboolean(luaVM, false); - return 1; -} - int CLuaCameraDefs::SetCameraTarget(lua_State* luaVM) { // bool setCameraTarget ( element target = nil ) or setCameraTarget ( float x, float y, float z ) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.h index 72419aa1246..713a9f63794 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.h @@ -29,7 +29,7 @@ class CLuaCameraDefs : public CLuaDefs static std::variant GetCameraTarget(); static unsigned char GetCameraInterior(); static std::string GetCameraGoggleEffect(); - LUA_DECLARE(GetCameraFieldOfView); + static std::variant GetCameraFieldOfView(eFieldOfViewMode mode); static unsigned char GetCameraDrunkLevel(); // Cam set funcs From a954b9a59fbbce8c0d50148d4e4607034c826bc2 Mon Sep 17 00:00:00 2001 From: FileEX Date: Thu, 31 Jul 2025 04:51:46 +0200 Subject: [PATCH 4/9] Fix crash when aiming with sniper --- Client/game_sa/CSettingsSA.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/game_sa/CSettingsSA.cpp b/Client/game_sa/CSettingsSA.cpp index 1b926cc2acf..185514451e8 100644 --- a/Client/game_sa/CSettingsSA.cpp +++ b/Client/game_sa/CSettingsSA.cpp @@ -573,7 +573,7 @@ void CSettingsSA::ResetFieldOfViewSniperAiming() // Restore original bytes // Zoom in MemPut(0x51089F, (void*)0x858CE0); - MemPut(0x5108B8, (void*)0x858CE0); + MemPut(0x5108B9, (void*)0x858CE0); MemPut(0x5108AE, "\x8C\x42"); MemPut(0x5108CF, "\x8C\x42"); @@ -727,7 +727,7 @@ bool CSettingsSA::SetFieldOfViewSniperAiming(float angle, bool fromScript) // Patch sniper zoom-in/zoom-out limit // zoom in MemPut(0x51089F, &ms_fovSniperAiming_Max); - MemPut(0x5108B8, &ms_fovSniperAiming_Max); + MemPut(0x5108B9, &ms_fovSniperAiming_Max); MemPut(0x5108AE, "\x33\x43"); MemPut(0x5108CF, "\x33\x43"); From 7ea722be344afcf8bfd10f6769d3168c65ef69f2 Mon Sep 17 00:00:00 2001 From: FileEX Date: Thu, 31 Jul 2025 05:39:57 +0200 Subject: [PATCH 5/9] Fix crash --- Client/game_sa/CSettingsSA.cpp | 43 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/Client/game_sa/CSettingsSA.cpp b/Client/game_sa/CSettingsSA.cpp index 185514451e8..73d45e23c2a 100644 --- a/Client/game_sa/CSettingsSA.cpp +++ b/Client/game_sa/CSettingsSA.cpp @@ -572,16 +572,16 @@ void CSettingsSA::ResetFieldOfViewSniperAiming() { // Restore original bytes // Zoom in - MemPut(0x51089F, (void*)0x858CE0); - MemPut(0x5108B9, (void*)0x858CE0); - MemPut(0x5108AE, "\x8C\x42"); - MemPut(0x5108CF, "\x8C\x42"); + MemCpy((void*)0x51089D, "\xD8\x1D\xE0\x8C\x85\x00", 6); + MemCpy((void*)0x5108B6, "\xD8\x1D\xE0\x8C\x85\x00", 6); + MemCpy((void*)0x5108AA, "\xC7\x07\x00\x00\x8C\x42", 6); + MemCpy((void*)0x5108C7, "\xC7\x05\xE8\xFF\xB6\x00\x00\x00\x8C\x42", 10); // Zoom out - MemPut(0x5109A3, (void*)0x858B48); - MemPut(0x5109BC, (void*)0x858B48); - MemPut(0x5109B2, "\x70\x41"); - MemPut(0x5109CF, "\x70\x41"); + MemCpy((void*)0x5109A1, "\xD8\x1D\x48\x8B\x85\x00", 6); + MemCpy((void*)0x5109BA, "\xD8\x1D\x48\x8B\x85\x00", 6); + MemCpy((void*)0x5109AE, "\xC7\x07\x00\x00\x70\x41", 6); + MemCpy((void*)0x5109C7, "\xC7\x05\xE8\xFF\xB6\x00\x00\x00\x70\x41 ", 10); ms_fovSniperAimingFromScript = false; ms_fovSniperAiming = 70.0f; @@ -589,8 +589,8 @@ void CSettingsSA::ResetFieldOfViewSniperAiming() void CSettingsSA::ResetFieldOfView1stPersonAiming() { - MemPut((void*)0x510711, "\xC7\x07\x00\x00\x8C\x42"); - MemPut((void*)0x511B71, "\xC7\x86\xB4\x00\x00\x00\x00\x00\x8C\x42"); + MemCpy((void*)0x510711, "\xC7\x07\x00\x00\x8C\x42", 6); + MemCpy((void*)0x511B71, "\xC7\x86\xB4\x00\x00\x00\x00\x00\x8C\x42", 10); ms_fov1stPersonAimingFromScript = false; ms_fov1stPersonAiming = 70.0f; @@ -701,7 +701,7 @@ bool CSettingsSA::SetFieldOfViewAiming(float angle, bool fromScript) CCamera* camera = pGame->GetCamera(); CCam* cam = camera->GetCam(camera->GetActiveCam()); - eCamMode cameraViewMode = static_cast(camera->GetCam(camera->GetActiveCam())->GetMode()); + eCamMode cameraViewMode = static_cast(cam->GetMode()); if (cameraViewMode != MODE_AIMWEAPON && cameraViewMode != MODE_AIMWEAPON_FROMCAR && cameraViewMode != MODE_AIMWEAPON_ATTACHED) return false; @@ -720,23 +720,24 @@ bool CSettingsSA::SetFieldOfViewSniperAiming(float angle, bool fromScript) CCamera* camera = pGame->GetCamera(); CCam* cam = camera->GetCam(camera->GetActiveCam()); - eCamMode cameraViewMode = static_cast(camera->GetCam(camera->GetActiveCam())->GetMode()); + eCamMode cameraViewMode = static_cast(cam->GetMode()); if (!ms_fovSniperAimingFromScript && fromScript) { // Patch sniper zoom-in/zoom-out limit - // zoom in + // Zoom in + //MemCpy((void*)0x51089D, "\xD8\x1D\xE0\x8C\x85\x00", 6); + //MemCpy((void*)0x5108B6, "\xD8\x1D\xE0\x8C\x85\x00", 6); MemPut(0x51089F, &ms_fovSniperAiming_Max); - MemPut(0x5108B9, &ms_fovSniperAiming_Max); + MemPut(0x5108B8, &ms_fovSniperAiming_Max); + MemCpy((void*)0x5108AA, "\xC7\x07\x00\x00\x33\x43", 6); + MemCpy((void*)0x5108C7, "\xC7\x05\xE8\xFF\xB6\x00\x00\x00\x33\x43", 10); - MemPut(0x5108AE, "\x33\x43"); - MemPut(0x5108CF, "\x33\x43"); - - // zoom out + // Zoom out MemPut(0x5109A3, &ms_fovSniperAiming_Min); MemPut(0x5109BC, &ms_fovSniperAiming_Min); - MemPut(0x5109B2, "\x00\x00"); - MemPut(0x5109CF, "\x00\x00"); + MemCpy((void*)0x5109AE, "\xC7\x07\x00\x00\x00\x00", 6); + MemCpy((void*)0x5109C7, "\xC7\x05\xE8\xFF\xB6\x00\x00\x00\x00\x00", 10); } if (cameraViewMode == MODE_SNIPER) @@ -754,7 +755,7 @@ bool CSettingsSA::SetFieldOfView1stPersonAiming(float angle, bool fromScript) CCamera* camera = pGame->GetCamera(); CCam* cam = camera->GetCam(camera->GetActiveCam()); - eCamMode cameraViewMode = static_cast(camera->GetCam(camera->GetActiveCam())->GetMode()); + eCamMode cameraViewMode = static_cast(cam->GetMode()); if (!ms_fov1stPersonAimingFromScript && fromScript) { From 079515ddfb8e69655e77c011344ecf5ddf1e18a5 Mon Sep 17 00:00:00 2001 From: FileEX Date: Thu, 31 Jul 2025 06:25:26 +0200 Subject: [PATCH 6/9] Another fixes --- Client/game_sa/CSettingsSA.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Client/game_sa/CSettingsSA.cpp b/Client/game_sa/CSettingsSA.cpp index 73d45e23c2a..cff85c7c66c 100644 --- a/Client/game_sa/CSettingsSA.cpp +++ b/Client/game_sa/CSettingsSA.cpp @@ -726,8 +726,6 @@ bool CSettingsSA::SetFieldOfViewSniperAiming(float angle, bool fromScript) { // Patch sniper zoom-in/zoom-out limit // Zoom in - //MemCpy((void*)0x51089D, "\xD8\x1D\xE0\x8C\x85\x00", 6); - //MemCpy((void*)0x5108B6, "\xD8\x1D\xE0\x8C\x85\x00", 6); MemPut(0x51089F, &ms_fovSniperAiming_Max); MemPut(0x5108B8, &ms_fovSniperAiming_Max); MemCpy((void*)0x5108AA, "\xC7\x07\x00\x00\x33\x43", 6); @@ -745,6 +743,8 @@ bool CSettingsSA::SetFieldOfViewSniperAiming(float angle, bool fromScript) ms_fovSniperAimingFromScript = fromScript; ms_fovSniperAiming = angle; + + *(float*)0x00B6FFE8 = angle; return true; } @@ -763,7 +763,7 @@ bool CSettingsSA::SetFieldOfView1stPersonAiming(float angle, bool fromScript) MemSet((void*)0x511B71, 0x90, 10); } - if (cameraViewMode == MODE_SNIPER || cameraViewMode == MODE_M16_1STPERSON || cameraViewMode == MODE_HELICANNON_1STPERSON || cameraViewMode == MODE_CAMERA) + if (cameraViewMode == MODE_SNIPER || cameraViewMode == MODE_M16_1STPERSON || cameraViewMode == MODE_HELICANNON_1STPERSON || cameraViewMode == MODE_CAMERA || cameraViewMode == MODE_ROCKETLAUNCHER) cam->SetFOV(angle); ms_fov1stPersonAimingFromScript = fromScript; From 3738dc53467771ed64022436c9ea2323d70d5b9a Mon Sep 17 00:00:00 2001 From: FileEX Date: Thu, 31 Jul 2025 06:43:41 +0200 Subject: [PATCH 7/9] Fix camera weapon --- Client/game_sa/CSettingsSA.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Client/game_sa/CSettingsSA.cpp b/Client/game_sa/CSettingsSA.cpp index cff85c7c66c..28731f363a0 100644 --- a/Client/game_sa/CSettingsSA.cpp +++ b/Client/game_sa/CSettingsSA.cpp @@ -739,12 +739,14 @@ bool CSettingsSA::SetFieldOfViewSniperAiming(float angle, bool fromScript) } if (cameraViewMode == MODE_SNIPER) + { cam->SetFOV(angle); + *(float*)0x00B6FFE8 = angle; + } ms_fovSniperAimingFromScript = fromScript; ms_fovSniperAiming = angle; - *(float*)0x00B6FFE8 = angle; return true; } From 24f44fb1a520b771336f480143aac62ef671025e Mon Sep 17 00:00:00 2001 From: FileEX Date: Thu, 31 Jul 2025 07:45:38 +0200 Subject: [PATCH 8/9] Add vehicle_bump mode --- Client/game_sa/CSettingsSA.cpp | 36 ++++++++++++++++++- Client/game_sa/CSettingsSA.h | 3 ++ .../logic/lua/CLuaFunctionParseHelpers.cpp | 1 + .../logic/lua/CLuaFunctionParseHelpers.h | 3 +- .../logic/luadefs/CLuaCameraDefs.cpp | 7 ++++ Client/sdk/game/CSettings.h | 3 ++ 6 files changed, 51 insertions(+), 2 deletions(-) diff --git a/Client/game_sa/CSettingsSA.cpp b/Client/game_sa/CSettingsSA.cpp index 28731f363a0..f25292126c7 100644 --- a/Client/game_sa/CSettingsSA.cpp +++ b/Client/game_sa/CSettingsSA.cpp @@ -503,6 +503,9 @@ bool ms_fovAimingFromScript = false; bool ms_fovSniperAimingFromScript = false; bool ms_fov1stPersonAimingFromScript = false; +float ms_fov1stPerson = 60.0f; +bool ms_fov1stPersonFromScript = false; + // consider moving this to the camera class - qaisjp float CSettingsSA::GetFieldOfViewPlayer() { @@ -542,6 +545,11 @@ float CSettingsSA::GetFieldOfView1stPersonAiming() return ms_fov1stPersonAiming; } +float CSettingsSA::GetFieldOfViewVehicleBump() +{ + return ms_fov1stPerson; +} + void CSettingsSA::ResetFieldOfViewPlayer() { float fieldOfView; @@ -596,6 +604,14 @@ void CSettingsSA::ResetFieldOfView1stPersonAiming() ms_fov1stPersonAiming = 70.0f; } +void CSettingsSA::ResetFieldOfViewVehicleBump() +{ + ms_fov1stPerson = 60.0f; + + MemCpy((void*)0x517EBA, "\x00\x00\x8C\x42", 4); + MemCpy((void*)0x51814B, "\x00\x00\x70\x42", 4); +} + void CSettingsSA::UpdateFieldOfViewFromSettings() { float fFieldOfView; @@ -605,8 +621,10 @@ void CSettingsSA::UpdateFieldOfViewFromSettings() SetFieldOfViewVehicle(fFieldOfView, false); SetFieldOfViewVehicleMax(100, false); + ms_fovAiming = 70.0f; ResetFieldOfViewSniperAiming(); ResetFieldOfView1stPersonAiming(); + ResetFieldOfViewVehicleBump(); } void CSettingsSA::ResetFieldOfViewFromScript() @@ -616,6 +634,7 @@ void CSettingsSA::ResetFieldOfViewFromScript() ms_fovAimingFromScript = false; ms_fovSniperAimingFromScript = false; ms_fov1stPersonAimingFromScript = false; + ms_fov1stPersonFromScript = false; UpdateFieldOfViewFromSettings(); } @@ -741,7 +760,8 @@ bool CSettingsSA::SetFieldOfViewSniperAiming(float angle, bool fromScript) if (cameraViewMode == MODE_SNIPER) { cam->SetFOV(angle); - *(float*)0x00B6FFE8 = angle; + + *(float*)0xB6FFE8 = angle; // something related to FOV - need it to be set here } ms_fovSniperAimingFromScript = fromScript; @@ -773,6 +793,20 @@ bool CSettingsSA::SetFieldOfView1stPersonAiming(float angle, bool fromScript) return true; } +bool CSettingsSA::SetFieldOfViewVehicleBump(float angle, bool fromScript) +{ + if (!fromScript && ms_fov1stPersonFromScript) + return false; + + ms_fov1stPerson = angle; + + MemCpy((void*)0x517EBA, &ms_fov1stPerson, 4); + MemCpy((void*)0x51814B, &ms_fov1stPerson, 4); + + ms_fov1stPersonFromScript = fromScript; + return true; +} + //////////////////////////////////////////////// // // Vehicles LOD draw distance diff --git a/Client/game_sa/CSettingsSA.h b/Client/game_sa/CSettingsSA.h index b96dbf35f67..a867b0566d6 100644 --- a/Client/game_sa/CSettingsSA.h +++ b/Client/game_sa/CSettingsSA.h @@ -168,17 +168,20 @@ class CSettingsSA : public CGameSettings bool SetFieldOfViewAiming(float angle, bool fromScript); bool SetFieldOfViewSniperAiming(float angle, bool fromScript); bool SetFieldOfView1stPersonAiming(float angle, bool fromScript); + bool SetFieldOfViewVehicleBump(float angle, bool fromScript); float GetFieldOfViewPlayer(); float GetFieldOfViewVehicle(); float GetFieldOfViewVehicleMax(); float GetFieldOfViewAiming(); float GetFieldOfViewSniperAiming(); float GetFieldOfView1stPersonAiming(); + float GetFieldOfViewVehicleBump(); void ResetFieldOfViewPlayer(); void ResetFieldOfViewVehicle(); void ResetFieldOfViewVehicleMax(); void ResetFieldOfViewSniperAiming(); void ResetFieldOfView1stPersonAiming(); + void ResetFieldOfViewVehicleBump(); void SetVehiclesLODDistance(float fVehiclesLODDistance, float fTrainsPlanesLODDistance, bool bFromScript); void ResetVehiclesLODDistance(bool bForceDefault = false); diff --git a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp index 4d20973ad17..028df76323f 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp +++ b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp @@ -556,6 +556,7 @@ ADD_ENUM(FOV_MODE_VEHICLE_MAX, "vehicle_max") ADD_ENUM(FOV_MODE_AIMING, "aiming") ADD_ENUM(FOV_MODE_SNIPER_AIMING, "sniper_aiming") ADD_ENUM(FOV_MODE_1ST_PERSON_AIMING, "1stperson_aiming") +ADD_ENUM(FOV_MODE_VEHICLE_BUMP, "vehicle_bump") IMPLEMENT_ENUM_END("fieldofview-mode") IMPLEMENT_ENUM_BEGIN(eTrayIconType) diff --git a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h index 35ea1f1ce2c..b81a3803218 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h +++ b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h @@ -132,7 +132,8 @@ enum eFieldOfViewMode FOV_MODE_VEHICLE_MAX, FOV_MODE_AIMING, FOV_MODE_SNIPER_AIMING, - FOV_MODE_1ST_PERSON_AIMING + FOV_MODE_1ST_PERSON_AIMING, + FOV_MODE_VEHICLE_BUMP, }; DECLARE_ENUM(eFieldOfViewMode); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp index b9884d3c324..fdb6f781a72 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp @@ -179,6 +179,8 @@ std::variant CLuaCameraDefs::GetCameraFieldOfView(eFieldOfViewMode return g_pGame->GetSettings()->GetFieldOfViewSniperAiming(); case FOV_MODE_1ST_PERSON_AIMING: return g_pGame->GetSettings()->GetFieldOfView1stPersonAiming(); + case FOV_MODE_VEHICLE_BUMP: + return g_pGame->GetSettings()->GetFieldOfViewVehicleBump(); default: return false; } @@ -256,6 +258,8 @@ bool CLuaCameraDefs::SetCameraFieldOfView(eFieldOfViewMode mode, float fov, std: return g_pGame->GetSettings()->SetFieldOfViewSniperAiming(fov, true); case FOV_MODE_1ST_PERSON_AIMING: return g_pGame->GetSettings()->SetFieldOfView1stPersonAiming(fov, true); + case FOV_MODE_VEHICLE_BUMP: + return g_pGame->GetSettings()->SetFieldOfViewVehicleBump(fov, true); } return true; @@ -282,6 +286,9 @@ void CLuaCameraDefs::ResetCameraFieldOfView(eFieldOfViewMode mode) case FOV_MODE_1ST_PERSON_AIMING: g_pGame->GetSettings()->ResetFieldOfView1stPersonAiming(); break; + case FOV_MODE_VEHICLE_BUMP: + g_pGame->GetSettings()->ResetFieldOfViewVehicleBump(); + break; } } diff --git a/Client/sdk/game/CSettings.h b/Client/sdk/game/CSettings.h index 728ac402552..4861b8d3285 100644 --- a/Client/sdk/game/CSettings.h +++ b/Client/sdk/game/CSettings.h @@ -161,6 +161,7 @@ class CGameSettings virtual bool SetFieldOfViewAiming(float angle, bool fromScript) = 0; virtual bool SetFieldOfViewSniperAiming(float angle, bool fromScript) = 0; virtual bool SetFieldOfView1stPersonAiming(float angle, bool fromScript) = 0; + virtual bool SetFieldOfViewVehicleBump(float angle, bool fromScript) = 0; virtual float GetFieldOfViewPlayer() = 0; virtual float GetFieldOfViewVehicle() = 0; @@ -168,12 +169,14 @@ class CGameSettings virtual float GetFieldOfViewAiming() = 0; virtual float GetFieldOfViewSniperAiming() = 0; virtual float GetFieldOfView1stPersonAiming() = 0; + virtual float GetFieldOfViewVehicleBump() = 0; virtual void ResetFieldOfViewPlayer() = 0; virtual void ResetFieldOfViewVehicle() = 0; virtual void ResetFieldOfViewVehicleMax() = 0; virtual void ResetFieldOfViewSniperAiming() = 0; virtual void ResetFieldOfView1stPersonAiming() = 0; + virtual void ResetFieldOfViewVehicleBump() = 0; virtual void SetVehiclesLODDistance(float fVehiclesLODDistance, float fTrainsPlanesLODDistance, bool bFromScript) = 0; virtual void ResetVehiclesLODDistance(bool bForceDefault = false) = 0; From c5d2586567f4f6f61adefe6c3a5b51d76fff0a96 Mon Sep 17 00:00:00 2001 From: FileEX Date: Sun, 10 Aug 2025 18:40:33 +0200 Subject: [PATCH 9/9] assert checks --- Client/game_sa/CSettingsSA.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Client/game_sa/CSettingsSA.cpp b/Client/game_sa/CSettingsSA.cpp index f25292126c7..9fe6cdf56b4 100644 --- a/Client/game_sa/CSettingsSA.cpp +++ b/Client/game_sa/CSettingsSA.cpp @@ -525,18 +525,24 @@ float CSettingsSA::GetFieldOfViewVehicleMax() float CSettingsSA::GetFieldOfViewAiming() { CCamera* camera = pGame->GetCamera(); + assert(camera); + CCam* cam = camera->GetCam(camera->GetActiveCam()); - eCamMode cameraViewMode = static_cast(camera->GetCam(camera->GetActiveCam())->GetMode()); + assert(cam); + eCamMode cameraViewMode = static_cast(camera->GetCam(camera->GetActiveCam())->GetMode()); return (cameraViewMode == MODE_AIMWEAPON || cameraViewMode == MODE_AIMWEAPON_FROMCAR || cameraViewMode == MODE_AIMWEAPON_ATTACHED) ? cam->GetFOV() : ms_fovAiming; } float CSettingsSA::GetFieldOfViewSniperAiming() { CCamera* camera = pGame->GetCamera(); + assert(camera); + CCam* cam = camera->GetCam(camera->GetActiveCam()); - eCamMode cameraViewMode = static_cast(camera->GetCam(camera->GetActiveCam())->GetMode()); + assert(cam); + eCamMode cameraViewMode = static_cast(camera->GetCam(camera->GetActiveCam())->GetMode()); return (cameraViewMode == MODE_SNIPER) ? cam->GetFOV() : ms_fovSniperAiming; } @@ -719,7 +725,11 @@ bool CSettingsSA::SetFieldOfViewAiming(float angle, bool fromScript) return false; CCamera* camera = pGame->GetCamera(); + assert(camera); + CCam* cam = camera->GetCam(camera->GetActiveCam()); + assert(cam); + eCamMode cameraViewMode = static_cast(cam->GetMode()); if (cameraViewMode != MODE_AIMWEAPON && cameraViewMode != MODE_AIMWEAPON_FROMCAR && cameraViewMode != MODE_AIMWEAPON_ATTACHED) @@ -738,7 +748,11 @@ bool CSettingsSA::SetFieldOfViewSniperAiming(float angle, bool fromScript) return false; CCamera* camera = pGame->GetCamera(); + assert(camera); + CCam* cam = camera->GetCam(camera->GetActiveCam()); + assert(cam); + eCamMode cameraViewMode = static_cast(cam->GetMode()); if (!ms_fovSniperAimingFromScript && fromScript) @@ -776,7 +790,11 @@ bool CSettingsSA::SetFieldOfView1stPersonAiming(float angle, bool fromScript) return false; CCamera* camera = pGame->GetCamera(); + assert(camera); + CCam* cam = camera->GetCam(camera->GetActiveCam()); + assert(cam); + eCamMode cameraViewMode = static_cast(cam->GetMode()); if (!ms_fov1stPersonAimingFromScript && fromScript)