Skip to content

Commit 2adab62

Browse files
authored
Merge pull request #6 from raphael12333/main
New feature: Sensitivity Ratio ADS
2 parents dec00e0 + 76b46d4 commit 2adab62

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

cgame.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,50 @@ void pm_aimflag() {
154154
call();
155155
}
156156

157+
extern cvar_t* cg_zoomSensitivity_ratio;
158+
float stockCgZoomSensitivity()
159+
{
160+
float* fov_visible_percentage = (float*)CGAME_OFF(0x3020958c); //Visible percentage of cg_fov value
161+
float* cg_fov_value = (float*)CGAME_OFF(0x30298c68);
162+
return (*fov_visible_percentage / *cg_fov_value); //See instruction 30032fe8
163+
}
164+
void sensitivityRatioAds()
165+
{
166+
float* cg_zoomSensitivity = (float*)CGAME_OFF(0x3020b5f4); //zoomSensitivity var of cg_t struct
167+
float* ads_anim_progress = (float*)CGAME_OFF(0x30207214); //From 0 to 1
168+
//See FUN_30032e20
169+
if (*ads_anim_progress == 1) //ADS animation completed
170+
{
171+
//ADS
172+
*cg_zoomSensitivity = (stockCgZoomSensitivity() * cg_zoomSensitivity_ratio->value);
173+
}
174+
else if (*ads_anim_progress != 0) //ADS animation in progress
175+
{
176+
bool* ads = (bool*)CGAME_OFF(0x30209458);
177+
if (*ads)
178+
{
179+
//ADS
180+
*cg_zoomSensitivity = (stockCgZoomSensitivity() * cg_zoomSensitivity_ratio->value);
181+
}
182+
else
183+
{
184+
//NOT ADS
185+
*cg_zoomSensitivity = stockCgZoomSensitivity();
186+
}
187+
}
188+
else if (*ads_anim_progress == 0)
189+
{
190+
//NOT ADS
191+
*cg_zoomSensitivity = stockCgZoomSensitivity();
192+
}
193+
194+
__asm
195+
{
196+
fstp st(0)
197+
retn
198+
}
199+
}
200+
157201
#define cg_crosshairClientNum (*(int*)CGAME_OFF(0x3020C8C8))
158202
#define cg_renderingThirdPerson (*(int*)CGAME_OFF(0x30207158))
159203

@@ -828,6 +872,8 @@ void CG_Init(DWORD base) {
828872

829873
__call(CGAME_OFF(0x3001E6A1), (int)CG_Obituary);
830874

875+
__jmp(CGAME_OFF(0x30032fe8), (int)sensitivityRatioAds);
876+
831877
*(UINT32*)CGAME_OFF(0x300749EC) = 1; // Enable cg_fov
832878
// *(UINT32*)CGAME_OFF(0x30074EBC) = 0; // Enable cg_thirdperson
833879

cl_main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ cvar_t *cl_font_type;
2020
cvar_t *cg_drawheadnames;
2121
cvar_t *cg_xui_scoreboard;
2222
cvar_t *cg_fov;
23+
cvar_t *cg_zoomSensitivity_ratio;
2324

2425
DWORD __glob_wd_threadid;
2526
HANDLE __glob_wd_threadhandle;
@@ -268,6 +269,7 @@ void CL_Init(void) {
268269
cg_drawheadnames = Cvar_Get("cg_drawheadnames", "0", 0);
269270
cg_xui_scoreboard = Cvar_Get("cg_xui_scoreboard", "0", 0);
270271
cg_fov = Cvar_Get("cg_fov", "80", CVAR_ARCHIVE);
272+
cg_zoomSensitivity_ratio = Cvar_Get("sensitivityRatioAds", "1.0", CVAR_ARCHIVE);
271273

272274
Cvar_Set("version", va("COD MP 1.1x build %d %s %s win-x86", BUILDNUMBER, __DATE__, __TIME__));
273275
Cvar_Set("shortversion", "1.1x");

0 commit comments

Comments
 (0)