View previous topic :: View next topic |
Author |
Message |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Mon Oct 20, 2008 2:28 pm Post subject: Sniper Scope |
|
|
I want to add a scope to my sniper rifle.
I used stuffcmds to alter the FOV.
The problem is that when the scope is disabled I "force" the player to a FOV of 110. What if they were using an FOV of 100? or 90?
How can I reset it back to their original FOV? _________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
jim

Joined: 05 Aug 2005 Posts: 400 Location: In The Sun
|
Posted: Mon Oct 20, 2008 2:52 pm Post subject: |
|
|
Add some oldfov to store the normal fov in it? _________________ zbang! |
|
Back to top |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Mon Oct 20, 2008 9:24 pm Post subject: |
|
|
I don't think that would work.
Nowhere in the .qc files is there any reference to .fov. _________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
Wazat
Joined: 15 Oct 2004 Posts: 732 Location: Middle 'o the desert, USA
|
Posted: Mon Oct 20, 2008 9:40 pm Post subject: |
|
|
Well, you may be able to use some of the QC callouts to obtain the value for storing. Or maybe you can set up an alias that rotates or something. LordHavoc or someone else who knows more about the callouts available might know. _________________ When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work. |
|
Back to top |
|
 |
frag.machine

Joined: 25 Nov 2006 Posts: 728
|
Posted: Mon Oct 20, 2008 11:45 pm Post subject: |
|
|
DISCLAIMER: Not tested
1) declare a variable to store the original FOV:
2) store it;
Code: | oldfov = cvar ("fov"); |
3) do your stuffcmd's to change the cvar;
4) restore the original FOV value.
Code: | stuffcmd ("fov ");
stuffcmd (ftos(oldfov));
stufcmd ("\n"); |
_________________ frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/ |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Tue Oct 21, 2008 2:41 am Post subject: |
|
|
frag.machine. That'll only work in singleplayer, and will fail miserably on dedicated servers.
Quite frankly there is no generic method that will work with all clients/servers.
DP has DP_QC_VIEWZOOM or whatever its actually called.
there's a .float viewzoom field which can be set to something like 0.25 to zoom in.
Or you can request the client to send you their current fov via:
stuffcmd(client, "cmd myfov $fov\n"); but that has a tendancy to break, and still isn't supported in most engines, plus you need extra code to parse the response.
dp's viewzoom feature does exactly what you want.
or you can use csqc. :P
Failing that you can ask the user to put their fov into an alias so that it can be restored after. Although this does require the user to create an 'alias restorefov "fov 90" ' alias. _________________ What's a signature? |
|
Back to top |
|
 |
Lardarse

Joined: 05 Nov 2005 Posts: 243 Location: Bristol, UK
|
Posted: Tue Oct 21, 2008 5:22 am Post subject: |
|
|
Spike wrote: | frag.machine. That'll only work in singleplayer, and will fail miserably on dedicated servers.
Quite frankly there is no generic method that will work with all clients/servers. |
RuneQuake removed all fov-changing recently because of this. |
|
Back to top |
|
 |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Tue Oct 21, 2008 6:43 am Post subject: |
|
|
Lardarse wrote: | Spike wrote: | frag.machine. That'll only work in singleplayer, and will fail miserably on dedicated servers.
Quite frankly there is no generic method that will work with all clients/servers. |
RuneQuake removed all fov-changing recently because of this. |
FOV changing is so evil that most Quakeworld clients have a cvar called default_fov to override the terrible behavior of mods that making the silly assumption that changing your FOV back to 90 is "restoring it back to normal".
Also evil: messing with a player's r_drawviewmodel value like the original rocket arena does.
Hopefully useful information
Since it is my understanding that RedRum is probably targetting only Quakeworld clients and aside from ezQuake, FTE, FuhQuake and the occasional DarkPlaces user I *think* you can the assumption that all those clients can save cvar values.
So you might be able to do something like sending them a couple of aliases to execute upon connecting that save their FOV and then one to execute the restore when your "special effect" is completed.
A quasi example that may require some adjustment:
Quote: |
alias savemyfov "set savedfov $fov" // Creates savedfov with a value of their fov
alias restoremyfov "set fov $savedfov" // Send restoremyfov to set their fov back to the saved setting
savemyfov // Have it execute upon connect
|
Then when you want to end the changed fov, send the "restoremyfov" to the client.
This is just a theory, but I don't offhand see any reason it wouldn't work. |
|
Back to top |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Tue Oct 21, 2008 4:36 pm Post subject: |
|
|
didn't quite follow all that, sounds interesting though. I'll look into it.
Yes, I'm targetting QW clients only. Thanks. _________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Tue Oct 21, 2008 5:14 pm Post subject: |
|
|
Try this and you'll see what I mean.
1. Load up whatever Quakeworld client you use.
2. Load a map
3. In the console, type "set myfov $fov"
4. (you just saved your fov)
5. Now type "fov 20"
6. (you just changed your fov to be really small)
7. Now type "fov"
8. (It will show it is 20, just so you can see what is going on)
9. Now type "set fov $myfov"
10. (You have just restored your FOV to the original fov you were using in step #3)
ezQuake, FTE, DarkPlaces and FuhQuake all support this.
So ...
Player X connects. You stuffcmd him "set myfov $fov" so his FOV is saved.
When you want to change his FOV, stuffcmd him "fov 20" or whatever.
When you want to store it, stuffcmd him "set fov $myfov" and it goes back to his preferred setting.
["set myfov $fov" creates temporary cvar called myfov on the client-side that saves his fov. The server can't read it but you don't care what the value is, just that you can restore that fov value when you need to which you can do by doing the reverse, "set fov $myfov".] |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Tue Oct 21, 2008 6:54 pm Post subject: |
|
|
If you make some gamecode that changes the fov and run it in FTE, FTE will latch the client's cvar. Whenever you set it to 90 (the default), it'll remove the latch, when you set it to something other than 90 it'll apply the latch. The user's preference is remembered the whole time, it just won't be used. Then again, viewzoom also works in FTE.
zquake, fuhquake(thus ezquake and any number of derivatives) and qw262 all have a default_fov cvar which works in a similar way to fte's. Its just a little less automatic.
Tbh, id's qw client shouldn't be used at all...
As far as I'm aware, all the above clients other than id's support "cmd myfov $fov\n" too. Although this is risky if your client lags out. Alternatively all can use setinfo as a way to tell the server what to use as the base, but this is not automatic.
set fov $myfov stuff is an extension and can still break if the user gets booted. Considering there's a default_fov or latching in all commonly used qw engines, its not a problem (anyone using id's client probably isn't playing seriously enough to care). _________________ What's a signature? |
|
Back to top |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Tue Oct 21, 2008 8:49 pm Post subject: |
|
|
Baker, ok I see what you mean. That sounds like it should work the way I want it to.
Can't wait to get home and try it.
Spike, thanks for the input!
You guys are very helpfull. _________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
MeTcHsteekle
Joined: 15 May 2008 Posts: 397 Location: its a secret
|
Posted: Sat Oct 25, 2008 12:23 am Post subject: |
|
|
DDDDDDDAAAAAAAANNNNNNYYYYYYYY!!!!!!!!>:0 _________________ bah |
|
Back to top |
|
 |
r00k
Joined: 13 Nov 2004 Posts: 483
|
Posted: Sat Oct 25, 2008 5:33 am Post subject: |
|
|
maybe is it possible that the server calls a generic aliases
like +fovdefault, or, +fovsnipe and just let the client determine the value?
if at all the client just doesnt change.
ok maybe its late and the beer is talking ... does this make sense?? |
|
Back to top |
|
 |
Wazat
Joined: 15 Oct 2004 Posts: 732 Location: Middle 'o the desert, USA
|
Posted: Sat Oct 25, 2008 2:16 pm Post subject: |
|
|
Well, the beer is right. I don't drink, but I do things like this in my mods often.
In Conquest and Ace of Nails for example I have an autoexec.cfg that sets +mlook and then executes game.cfg. That cfg sets up the player's special commands for the mod, both aliases and bindings (B key to buy from shops, secondary fire button, etc). The Readme practically begs the player to edit game.cfg to their liking.
So, you could have a game.cfg (or just autoexec.cfg) have this alias:
// The game calls this alias to zoom in/out with the sniper scope.
// Please change 90 to be the default FOV you play with so it resets
// correctly
alias +scopezoom "fov [some zoom]"
alias -scopezoom "fov 90"
I hope that's helpful. _________________ When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work. |
|
Back to top |
|
 |
|