Enter Half-Life Re-imagined, our current competition!
Check out Skewing textures in Hammer, our newest tutorial!
Say hello to Bear, our newest member!

logo

Site Stuff

Reference

Maps

Community

ShoutBOX

Poll

Valve Predictions 2017

What's the most likely thing Valve will release this year?

Nothing

18

A new game

3

More overpriced hardware

8

Source 2 SDK

11

An army of evil killer cyborgs

5

The hounds

8

Onliners

22 secs

Penguinboy

2 mins

Admer456

5 mins

Victor-933

22 mins

abbadon

31 mins

Bruce

39 mins

SpannerSpammer

39 mins

platoon

Affiliates

A gaming and technology blog by TWHL admins Penguinboy and Ant. A music blog by TWHL users Ant and Hugh.

View Roll When Strafing (like DMC)

By Cale 'Mazor' Dunlap

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