Forum

Dead space like tps zooming action

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Dead space like tps zooming action

Postby thommoboy » Wed Jan 11, 2012 5:13 am

I already have my own third person camsra working, how would serb I.add a zoomi (yes I know ung action to it if.i.pdess the right mouse
thommoboy
 
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Dead space like tps zooming action

Postby Baker » Wed Jan 11, 2012 6:00 am

In the console type:

fov 90 (enter ... look at what is onscreen)
fov 60 (enter ... look at what is onscreen)
fov 30 (enter ... look at what is onscreen)
fov 10 (enter ... look at what is onscreen)

Then type fov 90 in console to restore to what is probably normal.

You can mess with the zoom on a client doing stuffcmd("fov whatever value")

Maybe part of the clue you are looking for
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Dead space like tps zooming action

Postby thommoboy » Wed Jan 11, 2012 6:54 am

after i add the impulse how would i zoom out because you cannot assign multiple impulses to a single key
thommoboy
 
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Dead space like tps zooming action

Postby Baker » Wed Jan 11, 2012 12:28 pm

You need a new field to keep track of the player zoom state. Add to the very end of defs.qc something like this ...

Code: Select all
.float      iszoomed; // 0 = No they are not zoomed, set to 1 to indicate they are zoomed


Have your impulse do something like

Code: Select all
// This is a summary, not actual code ... you will have to adapt this
if (impulse == 40)
{
    if (iszoomed)
    {
      stuffcmd ("fov 90\n"); // Restore normal
      iszoomed = 0; // Not zoomed
   }
    else
   { stuffcmd("fov 30\n"); // Not zoomed so zoom them in
     iszoomed = 1; // We are zoomed in now
  }
}


There are tons of things wrong about the above, but the logic is sound. You should be able to adapt the above idea easily enough (and if not, you'll need to be able to in order to bring your ideas into reality).

[Having the server stuffcmd for is not ideal. However, unless you are targeting DP or FTE I think it is the only method available unfortunately.]
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Dead space like tps zooming action

Postby metlslime » Wed Jan 11, 2012 7:30 pm

thommoboy wrote:after i add the impulse how would i zoom out because you cannot assign multiple impulses to a single key


Actually you can...

Code: Select all
alias +zoom "impulse 25"
alias -zoom "impulse 26"
bind z +zoom


The above will bind key "z" so that it calls "impulse 25" when pressed and "impulse 26" when released.
metlslime
 
Posts: 316
Joined: Tue Feb 05, 2008 11:03 pm

Re: Dead space like tps zooming action

Postby Spike » Wed Jan 11, 2012 9:08 pm

note that impulses are unreliable and thus:
a) if you press and release your button fast enough, the mod will see only the release. This is also an issue if they use *any* other impulses at the same sort of time.
b) if a packet is dropped, its possible the mod will see only the press, and not the release.

so make sure its not too unusable if either happens.

if you are targetting DP or FTE, try using DP_VIEWZOOM:
.float viewzoom;
which won't kill the user's fov/sensitivity settings each and every single time they zoom in.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Dead space like tps zooming action

Postby leileilol » Thu Jan 12, 2012 1:14 am

the third person zooming in typical console shooters involve both moving the camera and adjusting the FOV at the same time. You can't seal the deal with a simple zoom alias
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Dead space like tps zooming action

Postby thommoboy » Fri Jan 13, 2012 2:50 am

for your code i get error: mismatch for == (fieldfloat and float)


:(
thommoboy
 
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Dead space like tps zooming action

Postby Baker » Fri Jan 13, 2012 3:06 am

thommoboy wrote:for your code i get error: mismatch for == (fieldfloat and float) :(


Do this easy flashlight tutorial. It is a 5 minute deal: http://inside3d.com/showtutorial.php?id=119

Once you do that tutorial, you should be able to correct my code. Sure I could correct the code, but if you correct the code yourself you'll gain +100 XP and be Level 2.

[Hint: self.origin, self.angles, self.impulse or above my crappy pseudo code ... self.iszoomed]
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Dead space like tps zooming action

Postby thommoboy » Fri Jan 13, 2012 7:16 am

okay ive got it so far i made my own code based off my modified tps code

Code: Select all
void (float amount) CCamzoom =
{
        self.camview_z = self.camview_z + amount;
        if (self.camview_z > -5)
                self.camview_z = -5;
        if (self.camview_z < -10)
                self.camview_z = -10;
       
                self.camview_x = self.camview_x + amount;
        if (self.camview_x < 16)
                self.camview_x = -16;
        if (self.camview_x > -16)
                self.camview_x = -16;
       
                self.camview_y = self.camview_y + amount;
        if (self.camview_y < 12)
                self.camview_y = 12;
        if (self.camview_y > -12)
                self.camview_y = -12;
               
                self.camview_z = self.camview_z + amount;
        if (self.camview_z > -48)
                self.camview_z = -48;
        if (self.camview_z < -72)
                self.camview_z = -72;
};

void (float amount) CCamdoom =
{
                self.camview_z = self.camview_z + amount;
        if (self.camview_z > -16)
                self.camview_z = -16;
        if (self.camview_z < -16)
                self.camview_z = -16;
};


CCamzoom is the default

i want it so when the (left trigger psp) or z button is held it will change to CCamdoom but when released it will change back to CCamzoom
thommoboy
 
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Dead space like tps zooming action

Postby thommoboy » Fri Jan 13, 2012 7:17 am

metlslime wrote:
thommoboy wrote:after i add the impulse how would i zoom out because you cannot assign multiple impulses to a single key


Actually you can...

Code: Select all
alias +zoom "impulse 25"
alias -zoom "impulse 26"
bind z +zoom


The above will bind key "z" so that it calls "impulse 25" when pressed and "impulse 26" when released.



for your code where do i put it?
thommoboy
 
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Dead space like tps zooming action

Postby thommoboy » Fri Jan 13, 2012 7:21 am

woo i figured it out yay!!!!!!!!!!!!!
thommoboy
 
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Dead space like tps zooming action

Postby Baker » Fri Jan 13, 2012 7:33 am

thommoboy wrote:woo i figured it out yay!!!!!!!!!!!!!


I was pretty sure you could :D
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Dead space like tps zooming action

Postby thommoboy » Fri Jan 13, 2012 7:35 am

how would i make it so that when the player is zoomed in he moves half the speed?
thommoboy
 
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Dead space like tps zooming action

Postby Baker » Fri Jan 13, 2012 8:41 am

thommoboy wrote:how would i make it so that when the player is zoomed in he moves half the speed?


Type in console cl_forwardspeed to find out what you forward speed is. Write it down. It may not be the default 350.

Type in console "fov 90; cl_forwardspeed 350". Move a little to feel the speed.
Type in console "fov 90; cl_forwardspeed 200". Move a little to feel the speed.
Type in console "fov 30; cl_forwardspeed 200". Move a little to feel the speed.
Type in console "fov 90; cl_forwardspeed 350". Back to normal.

Now messing with the player's cl_forwardspeed cvar but sending it via stuffcmd is not the proper way to do it any more than messing with the player fov via stuffcmd.

Still, it'll give you some ideas on how things work. There is a "haste" tutorial that ironically does it "wrong" too ... http://inside3d.com/showtutorial.php?id=122

The "correct" way is a bit involved and if you really want to do it "right" check out RuneQuake 1.3 source and search for "ath" for the rune of athletics that has code like:
http://www.runequake.com/html-source/runequake-1.3.0/
Code: Select all
Athlete_Run =
{
   if ((self.cl[CL_CMD_FORWARD] || self.cl[CL_CMD_SIDE]) && self.flags & FL_ONGROUND)
      self.velocity = self.velocity + self.velocity * 0.10;
};
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Next

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest