diff --git a/cgame.cpp b/cgame.cpp index 562520f..e9e2278 100644 --- a/cgame.cpp +++ b/cgame.cpp @@ -154,6 +154,50 @@ void pm_aimflag() { call(); } +extern cvar_t* cg_zoomSensitivity_ratio; +float stockCgZoomSensitivity() +{ + 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 + { + //ADS + *cg_zoomSensitivity = (stockCgZoomSensitivity() * cg_zoomSensitivity_ratio->value); + } + else if (*ads_anim_progress != 0) //ADS animation in progress + { + bool* ads = (bool*)CGAME_OFF(0x30209458); + if (*ads) + { + //ADS + *cg_zoomSensitivity = (stockCgZoomSensitivity() * cg_zoomSensitivity_ratio->value); + } + else + { + //NOT ADS + *cg_zoomSensitivity = stockCgZoomSensitivity(); + } + } + else if (*ads_anim_progress == 0) + { + //NOT ADS + *cg_zoomSensitivity = stockCgZoomSensitivity(); + } + + __asm + { + fstp st(0) + retn + } +} + #define cg_crosshairClientNum (*(int*)CGAME_OFF(0x3020C8C8)) #define cg_renderingThirdPerson (*(int*)CGAME_OFF(0x30207158)) @@ -828,6 +872,8 @@ void CG_Init(DWORD base) { __call(CGAME_OFF(0x3001E6A1), (int)CG_Obituary); + __jmp(CGAME_OFF(0x30032fe8), (int)sensitivityRatioAds); + *(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");