[Added] Proper zoom function for weapons

Moderator: GZDoom Developers

Proper zoom function for weapons

Postby wildweasel » Mon Jun 29, 2009 1:47 am

As many have probably seen, it's currently not possible (for ZDoom) to have a weapon-specific (i.e. Decorate-controlled) zoom function. Other such suggestions have been rejected in the past, but I think it might be doable this way:
Code: Select allExpand view
A_ZoomLevel(int)

where int can range from 0 to 2, as a multiplier of the user's current FOV setting. So for example, if a weapon were to call A_ZoomLevel(0.5), this would adjust the current FOV to half, so a user at FOV 90 would now be seeing at FOV 45, and a user who prefers FOV 110 would now see FOV 55. You could also fish-eye the view by setting a multiplier above 1 (1.75, for example, would result in a very distorted view).

A proper zoom function like this one would probably be much cleaner than an alias, much simpler than the camera texture hack (that no longer works, evidently due to some changes in the Textures code), and wouldn't overwrite the user's INI settings.

Of course I have no idea what the consequences would be of attempting to A_ZoomLevel to 0 - perhaps a solid minimum should be enforced, like 0.01?
User avatar
wildweasel
change o' pace.
Moderator Team Lead
 
Joined: 15 Jul 2003

Re: Proper zoom function for weapons

Postby Nash » Mon Jun 29, 2009 1:50 am

Good idea. I've never liked the console alias method as it forces a person to use absolute values which of course doesn't work well with users using FOV other than 90 degrees...

Also before someone says "nooo people will abuse this feature" - then don't play the WAD.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Proper zoom function for weapons

Postby XutaWoo » Mon Jun 29, 2009 2:11 am

0 could probally just be read as "no change" to prevent problems.
User avatar
XutaWoo
one day when going to see the rabbit, there was a previous visitor ...
 
Joined: 30 Dec 2006
Location: beautiful hills of those who are friends

Re: Proper zoom function for weapons

Postby wildweasel » Mon Jun 29, 2009 2:44 am

Nash wrote:Also before someone says "nooo people will abuse this feature" - then don't play the WAD.

There are a LOT of other features that can be similarly abused. Scripts that rob the player of their movement controls, scripts that randomly flail your view about...hell, the very fact that there are monsters can be abused. At what point does a developer step in and say that the author should not be able to use a feature because of the ways in which it can be abused? I'd think that the only reason a feature should be removed for abuse should be if said feature actually has the potential to damage something, i.e. INI settings, files, etc.

And then of course, the presence of this feature in no way limits the player's ability to use their zoom aliases. =P
User avatar
wildweasel
change o' pace.
Moderator Team Lead
 
Joined: 15 Jul 2003

Re: Proper zoom function for weapons

Postby Enjay » Mon Jun 29, 2009 4:21 am

The only concern for abuse, IMO, is something that messes with the contents of an end user's ini file. This doesn't.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Proper zoom function for weapons

Postby Zippy » Mon Jun 29, 2009 6:28 am

I think it has been suggested like this before, and I think it again boils down to finding somebody to who is willing to go through the code to explicitly define the behaviors that are needed in order to get the feature working in full with properly laid out behavior (e.g. what happens when you die while zoomed, what happens to the weapon on display while zoomed, what happens if you switch weapons while zoomed, etc.)
User avatar
Zippy
Your Golden Boy
 
Joined: 23 Mar 2005
Location: New Jersey
Discord: Zurock#4834

Re: Proper zoom function for weapons

Postby wildweasel » Mon Jun 29, 2009 1:07 pm

Zippy wrote:I think it has been suggested like this before, and I think it again boils down to finding somebody to who is willing to go through the code to explicitly define the behaviors that are needed in order to get the feature working in full with properly laid out behavior (e.g. what happens when you die while zoomed, what happens to the weapon on display while zoomed, what happens if you switch weapons while zoomed, etc.)

  1. What happens if you die while zoomed? Well, the weapon would naturally go to its deselect state. If the author has thought ahead, deselecting your weapon should automatically unzoom it, so this kind of takes care of itself.
  2. What happens to the weapon on display while zoomed? It continues to be rendered. As with the previous one, it's up to author discretion what to do with it. You could simply blank it out by using TNT1A0, or you could use the feature as a Call of Duty style iron-sight system and jump to an alternative state with the weapon centered on screen. The latter is one of the things I suggested this feature for.
  3. What happens if you switch weapons while zoomed? Well, much like the death example above, nothing would really happen unless the author specifically tells it to - in this case it'd be a wise idea to stick an A_ZoomLevel(1) into the deselect state just to make sure. There are legitimate uses for not resetting the zoom while switching weapons (perhaps a CustomInventory item that toggles Zoom mode on and off, as well as increasing damage slightly?).
User avatar
wildweasel
change o' pace.
Moderator Team Lead
 
Joined: 15 Jul 2003

Re: Proper zoom function for weapons

Postby .+:icytux:+. » Mon Jun 29, 2009 1:21 pm

indeed very usefull, having it as a acs command would also be good, i suggested something like that just awhile ago, but it was "meh"ed.
User avatar
.+:icytux:+.
Mr. Happy of the Day!
 
Joined: 17 May 2007
Location: Finland

Re: Proper zoom function for weapons

Postby HotWax » Mon Jun 29, 2009 6:48 pm

I agree with wildweasel. At some point you have to put the responsibility not to muck things up into the mod author's hands.
User avatar
HotWax
Do what you must, and pay the price later.
 
Joined: 18 Jul 2003
Location: Idaho Falls, ID

Re: Proper zoom function for weapons

Postby Zippy » Mon Jun 29, 2009 6:58 pm

wildweasel wrote:
  1. What happens if you die while zoomed? Well, the weapon would naturally go to its deselect state. If the author has thought ahead, deselecting your weapon should automatically unzoom it, so this kind of takes care of itself.
  2. What happens to the weapon on display while zoomed? It continues to be rendered. As with the previous one, it's up to author discretion what to do with it. You could simply blank it out by using TNT1A0, or you could use the feature as a Call of Duty style iron-sight system and jump to an alternative state with the weapon centered on screen. The latter is one of the things I suggested this feature for.
  3. What happens if you switch weapons while zoomed? Well, much like the death example above, nothing would really happen unless the author specifically tells it to - in this case it'd be a wise idea to stick an A_ZoomLevel(1) into the deselect state just to make sure. There are legitimate uses for not resetting the zoom while switching weapons (perhaps a CustomInventory item that toggles Zoom mode on and off, as well as increasing damage slightly?).
I personally don't care about the hows. The thing is you can't leave these and other behaviors undefined... there has to be a defined logic for what happens in these (and other) circumstances from the start in order to have a "complete" feature. It isn't just a case of slapping in a new code pointer into DECORATE, you have to create the whole system behind it and try not to leave any holes. It's something whoever makes the effort of implementation should keep in mind.
User avatar
Zippy
Your Golden Boy
 
Joined: 23 Mar 2005
Location: New Jersey
Discord: Zurock#4834

Re: Proper zoom function for weapons

Postby HotWax » Mon Jun 29, 2009 7:20 pm

OK, so defined behavior:

A_ChangeFOV(float amount)

amount is clamped to something reasonable (e.g. 0.1 < amount < 2.0). Then it is multiplied by the activating player's current FOV setting (NOTE: not the adjusted FOV from previous calls) and the result is used as the player's adjusted FOV. A call of A_ZoomLevel(1.0) will always reset to the player's FOV setting, and multiple calls of A_ZoomLevel(0.25) will result in no change after the first.

Adjusted FOV multiplier (amount from the most recent call) is stored and retreived from save files. This allows for saving/loading while zoomed without negative side-effects. It also means that when a player respawns, their FOV will most likely be reset to normal. FOV will be reset to 1.0 when the level is reinitialized (if the player changes maps or respawns without reloading a saved game). It is up to the author to change the FOV in the player class' spawn state if he wants the adjusted FOV to be "permanent."

Activating player:

Playerclass -- the player (duh)
Weapon -- The player holding the weapon
Item -- The player using the item
Other -- No valid player, nothing happens (Unless someone can think of uses I've missed)

The author will be responsible for reseting the FOV on weapon lower, death or leaving the "zoomed" state.

Optionally we could also use a ChangeFOV ACS function that only works if the activator is a player. Same rules as above.
User avatar
HotWax
Do what you must, and pay the price later.
 
Joined: 18 Jul 2003
Location: Idaho Falls, ID

Re: Proper zoom function for weapons

Postby Kate » Mon Jun 29, 2009 7:26 pm

HotWax wrote:Other -- No valid player, nothing happens (Unless someone can think of uses I've missed)

You missed one case: A miscellaneous actor calling it on itself, in which case it should set the fov for it's own view, which should be applied to players when they're viewing through the "eyes" of the actor that called it (and reset when they stop viewing through it). Would make for a nice map-placeable "zoomed camera" actor without scripting.
User avatar
Kate
... in loving memory ...
 
Joined: 15 Jul 2003


Re: Proper zoom function for weapons

Postby Nash » Tue Jun 30, 2009 9:08 am

Lots of code being contributed these days in ZDoom land. Thanks a lot to Gez, bagheadspidey and SoulPriestess for your efforts. =D
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Proper zoom function for weapons

Postby .+:icytux:+. » Tue Jun 30, 2009 12:26 pm

Nash wrote:Lots of code being contributed these days in ZDoom land. Thanks a lot to Gez, bagheadspidey and SoulPriestess for your efforts. =D


yea definitly, its nice that feature suggestions that have been noed plenty of times atleast gets put to a test nowadays thanks to theese awesome guys (and... girl)

and the best part of it is that alot of them has been Added :D (but we cant forget about randy and graf ;) )
User avatar
.+:icytux:+.
Mr. Happy of the Day!
 
Joined: 17 May 2007
Location: Finland

Next

Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests