Tutorial *124*

Introduction
"Now, why would you want to remove the +mlook command" I hear you ask. Well, the purpose of this tutorial is not to remove the command, but to replace it with a cvar so you only have to toggle the cvar, and mlook is on or off, and have it saved to the configuration files on exit. The reason I am doing this, is so every time you load Quake and start a new game you don't have to keep on pulling the console down and typing '+mlook' to be able to use the mouse to look up and down!

Files Modified
The only source files affected by this tutorial are as follows
* Cl_input.c
* Cl_main.c
* In_win.c
* Client.h

Client.h Changes
There are two changes to be made in client.h and should be pretty easy to do.
First of all, search for the following lines, towards the bottom of the file.



extern	cvar_t	lookstrafe;

extern	cvar_t	sensitivity;



extern	cvar_t	m_pitch;

extern	cvar_t	m_yaw;

and then modify it to look like the following...


extern	cvar_t	lookstrafe;

extern	cvar_t	sensitivity;



extern	cvar_t	in_mlook; //Heffo - mlook cvar



extern	cvar_t	m_pitch;

extern	cvar_t	m_yaw;

once you have that done, scroll down the page some until you see the following code.


typedef struct

{

	int		down[2];		// key nums holding it down

	int		state;			// low bit is down state

} kbutton_t;



extern	kbutton_t	in_mlook, in_klook;

extern 	kbutton_t 	in_strafe;

extern 	kbutton_t 	in_speed;

now, modify it too look like this.


typedef struct

{

	int		down[2];		// key nums holding it down

	int		state;			// low bit is down state

} kbutton_t;



extern	kbutton_t	in_klook;//Heffo - mlook cvar



extern 	kbutton_t 	in_strafe;

extern 	kbutton_t 	in_speed;

Cl_input.c Changes
In this file, we have four changes to make, and this also should be pretty easy to do
First, at the top of the file find the following lines.



state bit 1 is edge triggered on the up to down transition

state bit 2 is edge triggered on the down to up transition



==========================================================

*/



kbutton_t	in_mlook, in_klook;

kbutton_t	in_left, in_right, in_forward, in_back;

kbutton_t	in_lookup, in_lookdown, in_moveleft, in_moveright;

then modify the first 'kbutton_t' line so it looks like this...


state bit 1 is edge triggered on the up to down transition

state bit 2 is edge triggered on the down to up transition



==========================================================

*/



kbutton_t	in_klook;//Heffo - mlook cvar



kbutton_t	in_left, in_right, in_forward, in_back;

kbutton_t	in_lookup, in_lookdown, in_moveleft, in_moveright;

now for the second change, scroll down until you find this code.


void IN_KLookDown (void) {KeyDown(&in_klook);}

void IN_KLookUp (void) {KeyUp(&in_klook);}



void IN_MLookDown (void) {KeyDown(&in_mlook);}

void IN_MLookUp (void){

KeyUp(&in_mlook);

if ( !(in_mlook.state&1) &&  lookspring.value)

	V_StartPitchDrift();

}

void IN_UpDown(void) {KeyDown(&in_up);}

void IN_UpUp(void) {KeyUp(&in_up);}

now modify it to look like...


void IN_KLookDown (void) {KeyDown(&in_klook);}

void IN_KLookUp (void) {KeyUp(&in_klook);}



/*void IN_MLookDown (void) {KeyDown(&in_mlook);}

void IN_MLookUp (void){

KeyUp(&in_mlook);

if ( !(in_mlook.state&1) &&  lookspring.value)

	V_StartPitchDrift();

} Heffo - mlook cvar*/



void IN_UpDown(void) {KeyDown(&in_up);}

void IN_UpUp(void) {KeyUp(&in_up);}

now, find the following lines, in about the middle of the file, right above the CL_AdjustAngles function.


cvar_t	cl_yawspeed = {"cl_yawspeed","140"};

cvar_t	cl_pitchspeed = {"cl_pitchspeed","150"};



cvar_t	cl_anglespeedkey = {"cl_anglespeedkey","1.5"};

and make it look like this...


cvar_t	cl_yawspeed = {"cl_yawspeed","140"};

cvar_t	cl_pitchspeed = {"cl_pitchspeed","150"};



cvar_t	cl_anglespeedkey = {"cl_anglespeedkey","1.5"};



cvar_t	in_mlook = {"in_mlook", "1", true}; //Heffo - mlook cvar



for the final change in this file, scroll right to the bottom of the code, and look for the following code.


	Cmd_AddCommand ("+klook", IN_KLookDown);

	Cmd_AddCommand ("-klook", IN_KLookUp);

	Cmd_AddCommand ("+mlook", IN_MLookDown);

	Cmd_AddCommand ("-mlook", IN_MLookUp);

}

then you comment out the last to lines, like this...


	Cmd_AddCommand ("+klook", IN_KLookDown);

	Cmd_AddCommand ("-klook", IN_KLookUp);



	//Cmd_AddCommand ("+mlook", IN_MLookDown); Heffo - mlook cvar

	//Cmd_AddCommand ("-mlook", IN_MLookUp);



}


Cl_main.c Changes
This file needs two changes made..
Scroll to the bottom of the file, so you are in the 'CL_Init' function, then find these lines.


	Cvar_RegisterVariable (&lookstrafe);

	Cvar_RegisterVariable (&sensitivity);



	Cvar_RegisterVariable (&m_pitch);

	Cvar_RegisterVariable (&m_yaw);

Then add the in_mlook line so it looks like this...


	Cvar_RegisterVariable (&lookstrafe);

	Cvar_RegisterVariable (&sensitivity);



	Cvar_RegisterVariable (&in_mlook); //Heffo - mlook cvar



	Cvar_RegisterVariable (&m_pitch);

	Cvar_RegisterVariable (&m_yaw);

In_win.c Changes
There are six changes to be made here, but five of them can be done by a search and replace method.
At the top of the file, scroll down until you see this code.


cvar_t	joy_wwhack1 = {"joywwhack1", "0.0"};

cvar_t	joy_wwhack2 = {"joywwhack2", "0.0"};



qboolean	joy_avail, joy_advancedinit, joy_haspov;

DWORD	joy_oldbuttonstate, joy_oldpovstate;

And now add a new line, so it looks like this...


cvar_t	joy_wwhack1 = {"joywwhack1", "0.0"};

cvar_t	joy_wwhack2 = {"joywwhack2", "0.0"};



extern cvar_t	in_mlook; //Heffo - mlook cvar



qboolean	joy_avail, joy_advancedinit, joy_haspov;

DWORD	joy_oldbuttonstate, joy_oldpovstate;

Now through the rest of the in_win.c file find all references to 'in_mlook.state & 1' and replace it with 'in_mlook.value' and you should be set!

In Game Usage
To use the new 'in_mlook' cvar, just pull down the console and type 'in_mlook 1' to enable mouse look(default) and type 'in_mlook 0' to disable it.



 
Not logged in
Sign up
Login:
Passwd: