Proper zoom function for weapons

Moderator: GZDoom Developers

User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Proper zoom function for weapons

Post by wildweasel »

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 all

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
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Proper zoom function for weapons

Post by Nash »

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
XutaWoo
Posts: 4005
Joined: Sat Dec 30, 2006 4:25 pm
Location: beautiful hills of those who are friends
Contact:

Re: Proper zoom function for weapons

Post by XutaWoo »

0 could probally just be read as "no change" to prevent problems.
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: Proper zoom function for weapons

Post by wildweasel »

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
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Proper zoom function for weapons

Post by Enjay »

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
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Re: Proper zoom function for weapons

Post by Zippy »

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
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: Proper zoom function for weapons

Post by wildweasel »

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
.+:icytux:+.
Posts: 2659
Joined: Thu May 17, 2007 1:53 am
Location: Finland

Re: Proper zoom function for weapons

Post by .+:icytux:+. »

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
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: Proper zoom function for weapons

Post by HotWax »

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
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Re: Proper zoom function for weapons

Post by Zippy »

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
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: Proper zoom function for weapons

Post by HotWax »

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
Kate
... in rememberance ...
Posts: 2975
Joined: Tue Jul 15, 2003 8:06 pm

Re: Proper zoom function for weapons

Post by Kate »

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
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Proper zoom function for weapons

Post by Nash »

Lots of code being contributed these days in ZDoom land. Thanks a lot to Gez, bagheadspidey and SoulPriestess for your efforts. =D
User avatar
.+:icytux:+.
Posts: 2659
Joined: Thu May 17, 2007 1:53 am
Location: Finland

Re: Proper zoom function for weapons

Post by .+:icytux:+. »

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 ;) )
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”