mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-10 14:42:05 +00:00
SERVER/CLIENT/FTE: More fluid weapon zoom, instant zoom for snipers
This commit is contained in:
parent
297ab1bfee
commit
0812781cb7
4 changed files with 43 additions and 21 deletions
|
@ -232,3 +232,5 @@ string build_datetime;
|
|||
#define VERSION_STRING "v1.0"
|
||||
|
||||
vector gun_kick;
|
||||
|
||||
float hide_viewmodel;
|
|
@ -1182,10 +1182,10 @@ void() Draw_Crosshair =
|
|||
else
|
||||
crosshair_color = [1, 1, 1];
|
||||
|
||||
hide_viewmodel = false;
|
||||
if (getstatf(STAT_WEAPONZOOM) == 2 && zoom_2_time < time)
|
||||
{
|
||||
setmodel(vmodel, "");
|
||||
setmodel(v2model, "");
|
||||
hide_viewmodel = true;
|
||||
drawfill('0 0 0', [g_width/2 - g_height/2, g_height, 0], '0 0 0', 1, 0);
|
||||
drawpic([(g_width/2 - g_height/2),0,0], "gfx/hud/scope_nb.tga", [g_height, g_height, 1], [1,1,1], 1);
|
||||
drawfill([(g_width/2 + g_height/2),0,0], [g_width, g_height, 0], '0 0 0', 1, 0);
|
||||
|
|
|
@ -248,7 +248,7 @@ void() Update_Vmodel =
|
|||
local vector dir;
|
||||
local float ads;
|
||||
|
||||
if (cvar("r_drawviewmodel") == FALSE) {
|
||||
if (cvar("r_drawviewmodel") == FALSE || hide_viewmodel == true) {
|
||||
vmodel.origin = '-10000 -10000 -10000';
|
||||
return;
|
||||
}
|
||||
|
@ -1095,7 +1095,7 @@ noref void() CSQC_Parse_Event =
|
|||
Hitmark_time = time + 0.2;
|
||||
break;
|
||||
case 4:
|
||||
zoom_2_time = time + 0.20;
|
||||
zoom_2_time = time + 0.05;
|
||||
break;
|
||||
case 5:
|
||||
crosshair_spread_time = time + 70/getWeaponRecoilReturn(getstatf(STAT_ACTIVEWEAPON));
|
||||
|
|
|
@ -2448,11 +2448,24 @@ void () Weapon_Logic =
|
|||
#ifdef FTE
|
||||
|
||||
else {
|
||||
if (self.weapon == W_KAR_SCOPE || self.weapon == W_PTRS ||
|
||||
self.weapon == W_HEADCRACKER || self.weapon == W_PENETRATOR) {
|
||||
if (self.scopetime >= time)
|
||||
self.viewzoom = 1 - (0.018*GetWeaponZoomAmount(self.weapon));
|
||||
} else {
|
||||
float zoom_factor = 1 - (0.018*GetWeaponZoomAmount(self.weapon));
|
||||
if (self.viewzoom > zoom_factor)
|
||||
self.viewzoom -= 0.03;
|
||||
else
|
||||
float sigmoid_input = (self.viewzoom - zoom_factor) * 10; // multiply by 10 to adjust the steepness of the sigmoid
|
||||
float sigmoid_output = 1 / (1 + exp(-sigmoid_input)); // apply the sigmoid function
|
||||
float zoom_speed = 0.06 * (sigmoid_output + 0.5) * (frametime*40); // adjust the zoom speed based on the sigmoid output
|
||||
|
||||
if (self.viewzoom > zoom_factor) {
|
||||
self.viewzoom -= zoom_speed;
|
||||
if (self.viewzoom < zoom_factor)
|
||||
self.viewzoom = zoom_factor;
|
||||
} else {
|
||||
self.viewzoom = zoom_factor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FTE
|
||||
|
@ -2470,19 +2483,26 @@ void () Weapon_Logic =
|
|||
|
||||
if (self.weapon == W_KAR_SCOPE || self.weapon == W_PTRS ||
|
||||
self.weapon == W_HEADCRACKER || self.weapon == W_PENETRATOR) {
|
||||
if (self.viewzoom == 0.2) {
|
||||
self.viewzoom += 0.03;
|
||||
ReturnWeaponModel();
|
||||
} else {
|
||||
UpdateVmodel(self.weaponmodel, GetWepSkin(self.weapon));
|
||||
UpdateV2model(self.weapon2model, 0);
|
||||
self.viewzoom += 0.03;
|
||||
}
|
||||
self.viewzoom = 1;
|
||||
} else {
|
||||
if (self.viewzoom == 0.9) {
|
||||
if (self.viewzoom == 0.75) {
|
||||
W_AimOut();
|
||||
} else {
|
||||
self.viewzoom += 0.03;
|
||||
float zoom_factor2 = 1 + (0.018 * GetWeaponZoomAmount(self.weapon)); // increase zoom factor
|
||||
float sigmoid_input2 = (zoom_factor2 - self.viewzoom) * 10; // adjust sigmoid input
|
||||
float sigmoid_output2 = 1 / (1 + exp(-sigmoid_input2)); // apply the sigmoid function
|
||||
float zoom_speed2 = 0.06 * (sigmoid_output2 + 0.5) * (frametime * 40); // adjust the zoom speed based on the sigmoid output
|
||||
|
||||
if (self.viewzoom < zoom_factor2) {
|
||||
self.viewzoom += zoom_speed2;
|
||||
if (self.viewzoom > zoom_factor2)
|
||||
self.viewzoom = zoom_factor2;
|
||||
} else {
|
||||
self.viewzoom = zoom_factor2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue