From 44ad267683d0f35d4a159ba2cd0cf79ee4b3e328 Mon Sep 17 00:00:00 2001 From: raphael123333 <143759274+raphael12333@users.noreply.github.com> Date: Thu, 21 Sep 2023 04:01:20 +0200 Subject: [PATCH 1/3] New feature: Sensitivity Ratio ADS The sensitivityRatioAds cvar takes a float that your sensitivity gets multiplied by when aiming. --- cgame.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ cl_main.cpp | 2 ++ 2 files changed, 50 insertions(+) diff --git a/cgame.cpp b/cgame.cpp index 562520f..5a96e9a 100644 --- a/cgame.cpp +++ b/cgame.cpp @@ -154,6 +154,52 @@ void pm_aimflag() { call(); } +extern cvar_t* cg_zoomSensitivity_ratio; +void scaleSensitivityAds() +{ + //Com_Printf("^1 scaleSensitivityAds \n"); + + float* cg_zoomSensitivity = (float*)CGAME_OFF(0x3020b5f4); + + float* fov_visible_percentage = (float*)CGAME_OFF(0x3020958c); //VISIBLE PERCENTAGE OF CG_FOV VALUE + float* cg_fov_value = (float*)CGAME_OFF(0x30298c68); + float stock_cg_zoomSensitivity = (*fov_visible_percentage / *cg_fov_value); + + float* ads_anim_progress = (float*)CGAME_OFF(0x30207214); + int* ads = (int*)CGAME_OFF(0x30209458); //CAN'T BE USED ALONE + + if (*ads_anim_progress == 1) + { + //ADS ANIMATION DONE + *cg_zoomSensitivity = (stock_cg_zoomSensitivity * cg_zoomSensitivity_ratio->value); + } + else if (*ads_anim_progress != 0) + { + //ADS ANIMATION IN PROGRESS + if (*ads == 0) + { + //NOT ADS + *cg_zoomSensitivity = stock_cg_zoomSensitivity; + } + else + { + //ADS + *cg_zoomSensitivity = (stock_cg_zoomSensitivity * cg_zoomSensitivity_ratio->value); + } + } + else if (*ads_anim_progress == 0) + { + //NOT ADS + *cg_zoomSensitivity = stock_cg_zoomSensitivity; + } + + __asm + { + fstp st(0) + retn + } +} + #define cg_crosshairClientNum (*(int*)CGAME_OFF(0x3020C8C8)) #define cg_renderingThirdPerson (*(int*)CGAME_OFF(0x30207158)) @@ -828,6 +874,8 @@ void CG_Init(DWORD base) { __call(CGAME_OFF(0x3001E6A1), (int)CG_Obituary); + __jmp(CGAME_OFF(0x30032fe8), (int)scaleSensitivityAds); // FSTP dword ptr [DAT_3020b5f4] + *(UINT32*)CGAME_OFF(0x300749EC) = 1; // Enable cg_fov // *(UINT32*)CGAME_OFF(0x30074EBC) = 0; // Enable cg_thirdperson diff --git a/cl_main.cpp b/cl_main.cpp index fa56415..efaa68c 100644 --- a/cl_main.cpp +++ b/cl_main.cpp @@ -20,6 +20,7 @@ cvar_t *cl_font_type; cvar_t *cg_drawheadnames; cvar_t *cg_xui_scoreboard; cvar_t *cg_fov; +cvar_t *cg_zoomSensitivity_ratio; DWORD __glob_wd_threadid; HANDLE __glob_wd_threadhandle; @@ -268,6 +269,7 @@ void CL_Init(void) { cg_drawheadnames = Cvar_Get("cg_drawheadnames", "0", 0); cg_xui_scoreboard = Cvar_Get("cg_xui_scoreboard", "0", 0); cg_fov = Cvar_Get("cg_fov", "80", CVAR_ARCHIVE); + cg_zoomSensitivity_ratio = Cvar_Get("sensitivityRatioAds", "1.0", CVAR_ARCHIVE); Cvar_Set("version", va("COD MP 1.1x build %d %s %s win-x86", BUILDNUMBER, __DATE__, __TIME__)); Cvar_Set("shortversion", "1.1x"); From 9982085887d72a3d7162812503e2961ff41cb9eb Mon Sep 17 00:00:00 2001 From: raphael123333 <143759274+raphael12333@users.noreply.github.com> Date: Thu, 21 Sep 2023 09:42:22 +0200 Subject: [PATCH 2/3] Update cgame.cpp --- cgame.cpp | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/cgame.cpp b/cgame.cpp index 5a96e9a..59ff005 100644 --- a/cgame.cpp +++ b/cgame.cpp @@ -155,42 +155,38 @@ void pm_aimflag() { } extern cvar_t* cg_zoomSensitivity_ratio; -void scaleSensitivityAds() +void sensitivityRatioAds() { - //Com_Printf("^1 scaleSensitivityAds \n"); + //Stock cg_zoomSensitivity = fov_visible_percentage / cg_fov_value //See instruction 30032fe8 + //ADS check done using FUN_30032e20 - float* cg_zoomSensitivity = (float*)CGAME_OFF(0x3020b5f4); - - float* fov_visible_percentage = (float*)CGAME_OFF(0x3020958c); //VISIBLE PERCENTAGE OF CG_FOV VALUE + float* cg_zoomSensitivity = (float*)CGAME_OFF(0x3020b5f4); //zoomSensitivity var of cg_t struct + float* fov_visible_percentage = (float*)CGAME_OFF(0x3020958c); //Visible percentage of cg_fov value float* cg_fov_value = (float*)CGAME_OFF(0x30298c68); - float stock_cg_zoomSensitivity = (*fov_visible_percentage / *cg_fov_value); - - float* ads_anim_progress = (float*)CGAME_OFF(0x30207214); - int* ads = (int*)CGAME_OFF(0x30209458); //CAN'T BE USED ALONE - - if (*ads_anim_progress == 1) + + float* ads_anim_progress = (float*)CGAME_OFF(0x30207214); //From 0 to 1 + if (*ads_anim_progress == 1) //ADS animation completed { - //ADS ANIMATION DONE - *cg_zoomSensitivity = (stock_cg_zoomSensitivity * cg_zoomSensitivity_ratio->value); + *cg_zoomSensitivity = ((*fov_visible_percentage / *cg_fov_value) * cg_zoomSensitivity_ratio->value); } - else if (*ads_anim_progress != 0) + else if (*ads_anim_progress != 0) //ADS animation in progress { - //ADS ANIMATION IN PROGRESS - if (*ads == 0) + bool* ads = (bool*)CGAME_OFF(0x30209458); + if (*ads) { - //NOT ADS - *cg_zoomSensitivity = stock_cg_zoomSensitivity; + //ADS + *cg_zoomSensitivity = ((*fov_visible_percentage / *cg_fov_value) * cg_zoomSensitivity_ratio->value); } else { - //ADS - *cg_zoomSensitivity = (stock_cg_zoomSensitivity * cg_zoomSensitivity_ratio->value); + //NOT ADS + *cg_zoomSensitivity = (*fov_visible_percentage / *cg_fov_value); } } else if (*ads_anim_progress == 0) { //NOT ADS - *cg_zoomSensitivity = stock_cg_zoomSensitivity; + *cg_zoomSensitivity = (*fov_visible_percentage / *cg_fov_value); } __asm @@ -874,7 +870,7 @@ void CG_Init(DWORD base) { __call(CGAME_OFF(0x3001E6A1), (int)CG_Obituary); - __jmp(CGAME_OFF(0x30032fe8), (int)scaleSensitivityAds); // FSTP dword ptr [DAT_3020b5f4] + __jmp(CGAME_OFF(0x30032fe8), (int)sensitivityRatioAds); *(UINT32*)CGAME_OFF(0x300749EC) = 1; // Enable cg_fov // *(UINT32*)CGAME_OFF(0x30074EBC) = 0; // Enable cg_thirdperson From 76b46d41a8e735c7868af52627059dcc5cdf9d0c Mon Sep 17 00:00:00 2001 From: raphael123333 <143759274+raphael12333@users.noreply.github.com> Date: Sat, 23 Sep 2023 00:16:43 +0200 Subject: [PATCH 3/3] Update cgame.cpp --- cgame.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/cgame.cpp b/cgame.cpp index 59ff005..e9e2278 100644 --- a/cgame.cpp +++ b/cgame.cpp @@ -155,19 +155,21 @@ void pm_aimflag() { } extern cvar_t* cg_zoomSensitivity_ratio; -void sensitivityRatioAds() +float stockCgZoomSensitivity() { - //Stock cg_zoomSensitivity = fov_visible_percentage / cg_fov_value //See instruction 30032fe8 - //ADS check done using FUN_30032e20 - - float* cg_zoomSensitivity = (float*)CGAME_OFF(0x3020b5f4); //zoomSensitivity var of cg_t struct float* fov_visible_percentage = (float*)CGAME_OFF(0x3020958c); //Visible percentage of cg_fov value float* cg_fov_value = (float*)CGAME_OFF(0x30298c68); - + return (*fov_visible_percentage / *cg_fov_value); //See instruction 30032fe8 +} +void sensitivityRatioAds() +{ + float* cg_zoomSensitivity = (float*)CGAME_OFF(0x3020b5f4); //zoomSensitivity var of cg_t struct float* ads_anim_progress = (float*)CGAME_OFF(0x30207214); //From 0 to 1 + //See FUN_30032e20 if (*ads_anim_progress == 1) //ADS animation completed { - *cg_zoomSensitivity = ((*fov_visible_percentage / *cg_fov_value) * cg_zoomSensitivity_ratio->value); + //ADS + *cg_zoomSensitivity = (stockCgZoomSensitivity() * cg_zoomSensitivity_ratio->value); } else if (*ads_anim_progress != 0) //ADS animation in progress { @@ -175,18 +177,18 @@ void sensitivityRatioAds() if (*ads) { //ADS - *cg_zoomSensitivity = ((*fov_visible_percentage / *cg_fov_value) * cg_zoomSensitivity_ratio->value); + *cg_zoomSensitivity = (stockCgZoomSensitivity() * cg_zoomSensitivity_ratio->value); } else { //NOT ADS - *cg_zoomSensitivity = (*fov_visible_percentage / *cg_fov_value); + *cg_zoomSensitivity = stockCgZoomSensitivity(); } } else if (*ads_anim_progress == 0) { //NOT ADS - *cg_zoomSensitivity = (*fov_visible_percentage / *cg_fov_value); + *cg_zoomSensitivity = stockCgZoomSensitivity(); } __asm