From 37b6e547cd8c7024b5cf173bd568471924216442 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 30 Jun 2009 22:37:40 +0000 Subject: [PATCH] - A_ZoomFactor now scales turning with the FOV by default. ZOOM_NOSCALETURNING will leave it unaltered. SVN r1694 (trunk) --- docs/rh-log.txt | 2 ++ src/g_game.cpp | 15 ++++++++++++++- src/g_shared/a_weapons.cpp | 9 ++++++--- src/p_user.cpp | 6 ++++-- wadsrc/static/actors/shared/inventory.txt | 1 + 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index bcc61e95a..be3ebda45 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,6 @@ June 30, 2009 +- A_ZoomFactor now scales turning with the FOV by default. ZOOM_NOSCALETURNING + will leave it unaltered. - Added Gez's PowerInvisibility changes. - Fixed: clearflags did not clear flags6. - Added A_SetAngle, A_SetPitch, A_ScaleVelocity, and A_ChangeVelocity. diff --git a/src/g_game.cpp b/src/g_game.cpp index d160f9c45..038e2bded 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -695,6 +695,12 @@ void G_AddViewPitch (int look) return; } look <<= 16; + if (players[consoleplayer].playerstate != PST_DEAD && // No adjustment while dead. + players[consoleplayer].ReadyWeapon != NULL && // No adjustment if no weapon. + players[consoleplayer].ReadyWeapon->FOVScale > 0) // No adjustment if it is non-positive. + { + look = int(look * players[consoleplayer].ReadyWeapon->FOVScale); + } if (!level.IsFreelookAllowed()) { LocalViewPitch = 0; @@ -735,7 +741,14 @@ void G_AddViewAngle (int yaw) { return; } - LocalViewAngle -= yaw << 16; + yaw <<= 16; + if (players[consoleplayer].playerstate != PST_DEAD && // No adjustment while dead. + players[consoleplayer].ReadyWeapon != NULL && // No adjustment if no weapon. + players[consoleplayer].ReadyWeapon->FOVScale > 0) // No adjustment if it is non-positive. + { + yaw = int(yaw * players[consoleplayer].ReadyWeapon->FOVScale); + } + LocalViewAngle -= yaw; if (yaw != 0) { LocalKeyboardTurner = smooth_mouse; diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 5a0dc376e..b7543c4db 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -1710,11 +1710,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_ZoomFactor) if (self->player != NULL && self->player->ReadyWeapon != NULL) { zoom = 1 / clamp(zoom, 0.1f, 50.f); - self->player->ReadyWeapon->FOVScale = zoom; if (flags & 1) - { - // Make the zoom instant. + { // Make the zoom instant. self->player->FOV = self->player->DesiredFOV * zoom; } + if (flags & 2) + { // Disable pitch/yaw scaling. + zoom = -zoom; + } + self->player->ReadyWeapon->FOVScale = zoom; } } diff --git a/src/p_user.cpp b/src/p_user.cpp index 9b1ceddc1..2921cac7b 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2002,7 +2002,9 @@ void P_PlayerThink (player_t *player) player->ReadyWeapon != NULL && // No adjustment if no weapon. player->ReadyWeapon->FOVScale != 0) // No adjustment if the adjustment is zero. { - desired *= player->ReadyWeapon->FOVScale; + // A negative scale is used top prevent G_AddViewAngle/G_AddViewPitch + // from scaling with the FOV scale. + desired *= fabs(player->ReadyWeapon->FOVScale); } if (player->FOV != desired) { @@ -2087,7 +2089,7 @@ void P_PlayerThink (player_t *player) { int crouchdir = player->crouching; - if (crouchdir==0) + if (crouchdir == 0) { crouchdir = (player->cmd.ucmd.buttons & BT_CROUCH)? -1 : 1; } diff --git a/wadsrc/static/actors/shared/inventory.txt b/wadsrc/static/actors/shared/inventory.txt index 68b98ff32..95deef2a9 100644 --- a/wadsrc/static/actors/shared/inventory.txt +++ b/wadsrc/static/actors/shared/inventory.txt @@ -327,6 +327,7 @@ Actor Weapon : Inventory native action native A_ZoomFactor(float scale = 1, int flags = 0); const int ZOOM_INSTANT = 1; + const int ZOOM_NOSCALETURNING = 2; } ACTOR WeaponGiver : Weapon native