A_ZoomFactor New Flag To Only Scale Turning

Moderator: GZDoom Developers

Post Reply
User avatar
22alpha22
Posts: 303
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

A_ZoomFactor New Flag To Only Scale Turning

Post by 22alpha22 »

A new flag for A_ZoomFactor that will scale the player's turn-rate by the zoom value without actually changing the FOV (zooming in). There currently is no other way to just scale the player's turn rate through Decorate; trying to do it through ACS is messy, somewhat inaccurate, and not nearly as smooth as what could be achieved through A_ZoomFactor.
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: A_ZoomFactor New Flag To Only Scale Turning

Post by Major Cooke »

Doesn't belong to A_ZoomFactor in this case. What you propose is worth its own function.
User avatar
22alpha22
Posts: 303
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: A_ZoomFactor New Flag To Only Scale Turning

Post by 22alpha22 »

I just figured that since A_ZoomFactor already scales the player's turn-rate by default, it would be easier just to add a flag that disables the FOV change, rather than make an entire new function, but whatever works I suppose.
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: A_ZoomFactor New Flag To Only Scale Turning

Post by Caligari87 »

Are the internals for A_ZoomFactor not exposed? Is it not possible to write zscript function to adjust the player's turn rate?

8-)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_ZoomFactor New Flag To Only Scale Turning

Post by Graf Zahl »

Code: Select all

	action void A_ZoomFactor(double zoom = 1, int flags = 0)
	{
		let player = self.player;
		if (player != NULL && player.ReadyWeapon != NULL)
		{
			zoom = 1 / clamp(zoom, 0.1, 50.0);
			if (flags & 1)
			{ // 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;
		}
	}
Here's the function. The only relevant part is the assignment to FOVScale. Note that this is a weapon property, not a player property, just like A_ZoomFactor is a weapon function, not a player function.
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: A_ZoomFactor New Flag To Only Scale Turning

Post by Caligari87 »

After exploring the code a bit (still a newb at this), it seems that if FOVScale is set to negative it'll be used internally to also scale the player's pitch/yaw, correct? What are the chances of exporting or generalizing that scaling so we no longer have to deal with hacks with ChangeActorAngle (which generally runs the risk of causing jittering)?

8-)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_ZoomFactor New Flag To Only Scale Turning

Post by Graf Zahl »

That's the entire use for FOVScale. But it's a weapon property, making it a bit restrictive.
User avatar
22alpha22
Posts: 303
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: A_ZoomFactor New Flag To Only Scale Turning

Post by 22alpha22 »

My knowledge of C related languages is pretty much nill, but nonetheless I've been messing with this function trying to figure out how to scale the player's turn-rate without also invoking a FOV change, without success. I copied the A_ZoomFactor ZScript definition and named it A_ZoomFactorEx and got it working identically to the original in Decorate. After I verified that it worked, I began tweaking it, trying to get the turn-rate scale without the FOV change, and while I really don't understand how it all works, from what I can gather, FOVScale seems to be some internal function that can scale the player's FOV with or without scaling the player's turn-rate but the turn-rate cannot be scaled without changing the FOV.

Since the original request of this thread was given a [DIY], I assume there must be something I'm missing. I like to think my knowledge of Decorate and ACS is above average, but my skills with real programming languages is next to nill, so if there is a way to achieve the original request through ZScript, I'll need a little more explanation on how to do it.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_ZoomFactor New Flag To Only Scale Turning

Post by Graf Zahl »

The thing is, all what you asked for is to isolate that one line of code. If that doesn't work, the entire request is invalid because you really need a new feature.
User avatar
22alpha22
Posts: 303
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: A_ZoomFactor New Flag To Only Scale Turning

Post by 22alpha22 »

I'm sorry if my ignorance about ZScript and and programming in general is getting on people's nerves. My misunderstanding led me to believe that a new flag for A_ZoomFactor would be the simplest and best solution. Then when you posted the function in ZScript and tagged the request [DIY], I thought you meant I could simply edit the function and add the flag I needed. So now if I'm on same page, I need to do what Major Cooke originally suggested and create a new request for a brand new function that can scale the player's turn-rate?
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”