VERC: View Roll When Strafing (like DMC) Last edited 21 years ago2002-09-21 03:02:00 UTC

You are viewing an older revision of this wiki page. The current revision may be more detailed and up-to-date. Click here to see the current revision of this page.

This article was recovered from an archive and needs to be reviewed

  1. The formatting may be incorrect as it was automatically converted to WikiCode from HTML, it needs to be revised and reformatted
  2. Some information may be out of date as it was written before Half-Life was available on Steam
  3. After the article is re-formatted and updated for Steam HL, remove this notice
  4. Please do not remove the archive notice from the bottom of the article.
  5. Some archive articles are no longer useful, or they duplicate information from other tutorials and entity guides. In this case, delete the page after merging any relevant information into other pages. Contact an admin to delete a page.
View Roll Effect Tutorial

Function

names are in RED

Files
are in ORANGE
This tutorial will
show you how to achieve the view rolling effect while strafing, as in DMC and
AHL. In fact, this code is the same code used in the DMC modification, I'm just
showing you how to make it work for HLDM. Its quite easy actually, so lets get
started...
Open hud.cpp
first... go to around line 84, where you'll see this code:

extern
client_sprite_t *GetSpriteList(client_sprite_t *pList, const char *psz,
int iRes, int iCount);
extern
cvar_t *sensitivity;

cvar_t *cl_lw = NULL;

After that set
of code, add this:

//
Mazor - used for view rolling when strafing

cvar_t
*cl_rollangle;

cvar_t *cl_rollspeed;

Now, go in the
function CHud::Init() and find these lines:

m_SayText.Init();

m_Menu.Init();

ServersInit();
MsgFunc_ResetHUD(0,
0, NULL );

Those should be
right at the end of that function, before the final }. After that code, add
this to initialize the cvar variables we defined above:

//
Mazor - used for view rolling when strafing

cl_rollangle

gEngfuncs.pfnRegisterVariable ( "cl_rollangle", "0.65",

FCVAR_CLIENTDLL|FCVAR_ARCHIVE );

cl_rollspeed = gEngfuncs.pfnRegisterVariable ( "cl_rollspeed",
"300", FCVAR_CLIENTDLL|FCVAR_ARCHIVE );

Now thats it for
hud.cpp , now open
view.cpp
Find the V_CalcViewRoll()
function in that file around line 389, right above these lines:

void V_CalcViewRoll
( struct ref_params_s *pparams )

{

??????cl_entity_t *viewentity;

Add this code to
define the cvar's as external variables so the linker can make use of them at
compile time:

//
Mazor - used for view rolling when strafing

extern cvar_t *cl_rollangle;

extern cvar_t *cl_rollspeed;

Now that you defined
the variables and initialized them with some sort of value, you can begin to
use them, so go inside the function V_CalcViewRoll()
to find the line:

viewentity

gEngfuncs.GetEntityByIndex( pparams->viewentity );

if ( !viewentity )

?????return;

After that little
bit of code, add this line to make everything complete:

//Roll
the angles when strafing Quake style!

pparams->viewangles[ROLL]

V_CalcRoll (pparams->viewangles, pparams->simvel, cl_rollangle->value,

cl_rollspeed->value ) * 4;

That should complete
it. This will give you the view rolling when the player strafes from side to
side. If desired, the user can customize how much and how fast they want to
roll by changing the cvars: cl_rollangle, and cl_rollspeed. The defaults are
as follows: cl_rollangle = 0.65 and cl_rollspeed = 300. If you would like to
change these to fit your needs, go right ahead. If not, enjoy! Questions, comments,
snotty remarks, e-mail em here: mazor579@hotmail.com (Link: mazor579-at-hotmail.com)
This article was originally published on the Valve Editing Resource Collective (VERC).
TWHL only archives articles from defunct websites. For more information on TWHL's archiving efforts, please visit the TWHL Archiving Project page.

Comments

You must log in to post a comment. You can login or register a new account.