Skip to content

Commit

Permalink
Update cgame.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael12333 committed Sep 22, 2023
1 parent 9982085 commit 76b46d4
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions cgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,38 +155,40 @@ 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
{
bool* ads = (bool*)CGAME_OFF(0x30209458);
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
Expand Down

0 comments on commit 76b46d4

Please sign in to comment.