[Solved] Scale Player Turning Without A_ZoomFactor?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
22alpha22
Posts: 308
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

[Solved] Scale Player Turning Without A_ZoomFactor?

Post by 22alpha22 »

Is it possible to scale the player's horizontal and vertical turning similar to "A_ZoomFactor" without actually zooming the player's view-port? In the Delta Force mod I'm working on, the player can use scopes that zoom in a secondary window rendered on the player's view-port without actually zooming the whole view-port in. The screenshot below demonstrates this.
Image

The issue is, when using scopes with higher magnifications, especially at range, it can be hard to accurately aim at targets due to the player's turning rate not being scaled back to match the magnification. The temporary solution I'm using now is to call "A_ZoomFactor" when ever the player activates the scope, hide the fact the whole view-port get zoomed in by rendering a non zoomed camera texture over the whole view-port, and then finally rendering the zoomed in secondary window over everything else. This method seems really hacky and creates temporary distortions for a moment when ever the scope is activated as well as not playing nice with different aspect-ratios or resolutions. I'm hoping somebody has better idea how to scale the player's turn rate.
Last edited by 22alpha22 on Sat May 06, 2017 7:14 am, edited 1 time in total.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Scale Player Turning Without A_ZoomFactor?

Post by Matt »

What I've been doing is, every single tic, I'd take the player's angle (and pitch - let's say "angle" for brevity) compared to their previous angle (though now I'm trying to see if I can just set the player's angle to their previous angle and start from MODINPUT_YAW/PITCH), modify that based on whatever circumstances I need (including whether the player is crouching, the weight of the weapon, etc.), then set the player's angle based on that result.

I'd post an example from Hideous Destructor, but the current state of that code is a mess and frankly you'd do a better job recreating it from scratch.
User avatar
22alpha22
Posts: 308
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: Scale Player Turning Without A_ZoomFactor?

Post by 22alpha22 »

Vaecrius wrote:What I've been doing is, every single tic, I'd take the player's angle (and pitch - let's say "angle" for brevity) compared to their previous angle (though now I'm trying to see if I can just set the player's angle to their previous angle and start from MODINPUT_YAW/PITCH), modify that based on whatever circumstances I need (including whether the player is crouching, the weight of the weapon, etc.), then set the player's angle based on that result.
I thought about doing something similar but decided it might be just as messy if not more so considering how intricately my weapons are already woven into Decorate, ACS, TEXTURES, and SBARINFO. My whole weapon code has tendrils going everywhere; I'm constantly breaking things when ever I try to add something new or make a change. Hence why decided to go with the method I did, simply because it required the least amount of tinkering with anything directly related to the weapons themselves. I was hoping there was some magical Decorate or ACS function that I missed that might solve this problem in a very neat and tidy way, but it looks like that is not the case. With all that being said, I am planning a complete overhaul of my weapon code sometime in the future and I'm definitely not happy with my current zoomfactor workaround, so if I haven't found something better, I'll definitely take another look at the feasibility of your method. I appreciate the help.
User avatar
22alpha22
Posts: 308
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: [Solved] Scale Player Turning Without A_ZoomFactor?

Post by 22alpha22 »

I've finally come up with a solution to scale the player's turn-rate without changing their FOV. I still call A_ZoomFactor and use its ability to scale the player's turn-rate, but now I also call a second new function created through ZScript. Basically, whenever the player selects a weapon with a scope, an overlay state is created which only purpose is to call a new function every tick. The new function sets the player's FOV to their desired FOV and since the function is being called every tick, it overrides the FOV changes made by A_ZoomFactor while still preserving the turn-rate scaling.

The new function:
Spoiler:
Decorate example:
Spoiler:
User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: [Solved] Scale Player Turning Without A_ZoomFactor?

Post by Major Cooke »

I do recommend not mixing decorate with zscript. The latter is far superior. Seeing all those A_JumpIfInventory statements now just gives me nightmares.
User avatar
22alpha22
Posts: 308
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: [Solved] Scale Player Turning Without A_ZoomFactor?

Post by 22alpha22 »

Major Cooke wrote:I do recommend not mixing decorate with zscript. The latter is far superior. Seeing all those A_JumpIfInventory statements now just gives me nightmares.
If that gives you nightmares, you don't want to see the rest of the weapon's code, you'll never be able to sleep again! :twisted:
Spoiler:
On a more serious note, I still don't really understand ZScript, I only messed around enough to learn how to make the function I needed. Considering how complex this one weapon is and the fact I have over 40 more, there is no way I am going to try and convert them all to ZScript when they work more or less as is. I am going to try to only use ZScript where absolutely necessary and primarily stick to Decorate and ACS. One thing I am curious about, can ZScript create new functions for ACS?
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: [Solved] Scale Player Turning Without A_ZoomFactor?

Post by Arctangent »

That would be kinda redundant, since ACS can already create new functions for ACS, and anything you'd want to do that'd require stuff ZScript has access to and ACS doesn't should be done strictly in ZScript anyway.
Locked

Return to “Editing (Archive)”