home · browse · search · game entities · user directory · message board · IRC | register

October 27, 2006, 4:37 pm PDT
username  
password  
forgot password?

Popular Resources
  • Half-Life 2 Mod FAQ
  • Valve Hammer Editor
  • Hammer 3.5 beta test
  • Half-Life Utilities
  • game data files
  • ZHLT 2.5.3 custom build
  • Half-Life SDK
  • Feedback
    If you've got any feedback, suggestions, or bugs to report regarding the Collective website, go here!

  • Feedback (301)
  • Newsletter
     
    Enter your email address in the above form to add yourself to the email newsletter list. Click here for more info.

    Hosted Sites
  • Valve ERC
  • Collective
  • TFMapped
  • Spirit of Half-Life
  • Selective Design
  • Pixel Reviews
  • recent articles

    NPC and Item Placement Theory
    17/03/05 11:35pm PST
    Non-Player Character (NPC) and item placement can influence both the gameflow and immersion of a level. This article aims to give some pointers on how to properly place them.
    - Hugh 'Hugh' Lloyd

    Got Props?
    13/03/05 08:32am PST
    A common problem in HL2 mapping is props not showing up in game. This article explains why and offers solutions.
    - Jeff 'Yesukai' Pritchard

    Simulating Randomness
    18/12/04 11:29pm PST
    This article focuses on how to properly simulate random events that should occur at a certain average frequency, or within a certain probability per period of time.
    - Skyler 'Zipster' York

    Adding Single-Player Weapons to Half-Life 2
    15/12/04 06:52pm PST
    Covers the process behind adding weapons to a single-player Half-Life 2 modification.
    - Skyler 'Zipster' York

    Your world in HL2
    06/12/04 12:17am PST
    This article gives tips and advice to anyone wanting to make custom photorealistic textures to be used in Half-Life 2.
    - Oksid

    Hiding in Shadow
    21/08/04 01:11pm PDT
    Describes how to create a function that has monsters disregard you if you are hiding in a certain level of "darkness," which can be set from within map properties.
    - Anders [Wolf] Jenbo (NoBody)

    XSI EXP for Half-Life 2 Tutorial - Camera Control
    23/09/04 12:43am PDT
    A SOFTIMAGE|XSI tutorial explaining all of the camera controls available to you in XSI!
    - Josh Enes

    Bump Mapping in Half-Life
    08/08/04 11:58am PDT
    Details a method of achieving real-time bump mapping in Half-Life, and provides an implementation of the algorithm.
    - Francis 'DeathWish' Woodhouse

    Real-Time "TRON 2.0" Glow For Low-Spec Hardware
    19/06/04 02:06pm PDT
    A sequel to the original "Real-Time 'TRON 2.0' Glow" article, this describes how to implement real-time glow that works on low-spec graphics cards.
    - Francis 'DeathWish' Woodhouse

    Hitboxes and Code
    05/06/04 06:25pm PDT
    How do I make only one part of a monster take damage? Learn about the relationship between model hitboxes and what you can do with them in a characters code.
    - Jonathan 'Teh_Freak' Smith

    View Roll When Strafing (like DMC)
    [Fri Sep 20, 2002 / 11:02pm PDT] Cale 'Mazor' Dunlap - comments (0) comments enabled

    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

    article created on Mon Sep 02, 2002 / 09:14pm PDT
    this item has been viewed 1425 times
    [Half-Life / coding]

    Only registered users can post comments. Have you registered yet?

    noone has commented on this document

    VERC © 2004. All content copyright its respective owner, all rights reserved.
    script execution time: 0.0796129703522 seconds