Welcome, Guest! Login | Register

Egon Beam Observer Fix [Print this Article]
Posted by: OPTIMUS PRIME
Date posted: Mar 06 2003
User Rating: 5 out of 5.0
Number of views: 3893
Number of comments: 0
Description: For eye-mode specators

FIX FOR FIRST PERSON OBSERVER EGON BEAM

Author: [LMS]007
Email: 007@hl-elite.com
Mod: http://www.hl-elite.com


/*
Valve never bothered to either check and/or fix the client side egon beam for when a player is in the eye observer mode. If you indent to keep the valve weapons or at least use the gluon aka: egon in your mod, then this short tutorial fix is necessary.
*/


Step 1.

Project: hl.dll
File: client.cpp


Look for this line about 1/2 down in the client.cpp file:

 QUOTE  
if ( ent->v.flags & FL_SKIPLOCALHOST )


Change the contents between the start and end bracket of that if statement to be this:

 CODE  

{
      if ( ( hostflags & 1 ) && ( ent->v.owner == host ) )
            return 0;
      // don't send the local host observers in eye mode either
      if(host->v.iuser1 == OBS_IN_EYE )
            return 0;
}


Recompile hl.dll


/*
What happens here is that the server side egon beam entity is being creating and not being send the client who fires the egon because he/she makes there beam completely \"clientside\". If you notice the beam you see when someone shoots the weapon at you and the beam you see when you shoot the weapon are different, this is that reason. Well when an observer is targeting a player firing the egon and is in first person mode, he/she still receives the entity and renders it so you there are 2 beams being creating which donít even match up well because of lag and prediction, not to mention it looks terrible.
*/



Step 2.

Project: client.dll
File: ev_hldm.cpp


look for for this function just past half way down

 QUOTE  
EV_EgonFire function


find this line within that function:

 QUOTE  
VectorCopy( gHUD.m_vecAngles, angles );


Completely replace that line with this:

 CODE  
VectorCopy( args->angles, angles );


Recompile client.dll


/*
What this accomplishes is this: When someone fires the egon this function is only called once when the egon first fires, and once about 3 seconds later when the sound changes. So the very first time this function gets called, it sets the beam, correctly for the client player, but incorrectly for the client observer. So you have this effect of a single beam shooting in a wrong direction for a split second right when the egon first fires.
*/


Step 3.

Project: client.dll
File: hl_objects.cpp


Within this short cpp file, find this function:

 QUOTE  
void UpdateBeams ( void )


Within that function look for this line:

 QUOTE  
vec3_t view_ofs;


add this after that line:

 CODE  
vec3_t vecDest;


Go down two lines to this line:

 QUOTE  
int idx = pthisplayer->index;


Add this below it:

 CODE  

bool bIsEyeObserver = false;
if(g_iUser1 == OBS_IN_EYE || (g_iUser1 && (gHUD.m_Spectator.m_pip->value == INSET_IN_EYE)) ) // This pertains to eye-observer mode clients
{
            cl_entity_t         * ent = gEngfuncs.GetEntityByIndex( g_iUser2 );
            VectorCopy ( ent->angles, angles );
            VectorCopy ( ent->origin, origin );
            angles[0]*=-3;  // hack
            bIsEyeObserver = true;
}
else  // This pertains to any clients not in eye-observer mode
{
            gEngfuncs.GetViewAngles( (float *)angles );
            HUD_GetLastOrg( (float *)&origin );
}


Then remove these next two lines:

 QUOTE  

// Get our exact viewangles from engine
gEngfuncs.GetViewAngles( (float *)angles );

// Determine our last predicted origin
HUD_GetLastOrg( (float *)&origin );


Then serch for this line near the bottom of the function:

 QUOTE  
gEngfuncs.pEventAPI->EV_PopPMStates();


Below it add this:

 CODE  

if(bIsEyeObserver)
            vecDest = vecEnd;
else
            vecDest = tr.endpos;


Then go down two more lines and fine this line of code:

 QUOTE  
pBeam->target = tr.endpos;


Completly change that line it to this:

 CODE  
pBeam ->target = vecDest;


Do the same for pBeam2 which is 2 more lines down

 QUOTE  
pBeam2->target = tr.endpos;


to...

 CODE  
pBeam2 ->target = vecDest;


Recompile client.dll

You are done!


/*
This fixes the updating beams for the egon, There was a little trick with multiplies the X value for the angle vector by (-3). I'm not sure why that worked, but the angles given by the observer target were off by that factor. Also if you will notice this is not perfect. The trace result does not work for observer clients. So I had to make a little hack and excluded the trace result for the eye-mode observer. This affects the beam slightly. The sin function will appear to be stretched at as far as possible at all times and the beam will go through walls. This is of course only noticed by the observer client. The clipping problem with the beam is not noticeable because you can't actually see it going through walls because you are looking right down the path anyway.
*/


Aside from that this should work. I have not tested this tutorial on a fresh SDK so if you have any problem please feel free to email me at 007@hl-elite.com.The reason I chose to do this tutorial against may others is that this was a problem valve should have solved and I feel it will benefit anyone who wishes to included the egon into there mod.

Rate This Article
This article is currently rated: 5 out of 5.0 (1 Votes)

You have to register to rate this article.
User Comments

No User Comments

You must register to post a comment. If you have already registered, you must login.

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 05 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005


Latest Comments
knock knock
General | News
By: omega | Dec 22 2016
 
knock knock
General | News
By: MIFUNE | Oct 10 2015
 
New HL HUD Message System
Half-Life | Coding | Shared Tutorials
By: chbrules | Dec 31 2011
 
knock knock
General | News
By: Whistler | Nov 05 2011
 
Particle Engine tutorial part 4
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 18 2010
 
Particle Engine tutorial part 2
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Particle Engine tutorial part 3
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Game Movement Series #2: Analog Jumping and Floating
Half-Life 2 | Coding | Shared Tutorials
By: mars3554 | Oct 26 2009
 
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Deadpool | Aug 02 2009
 
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Persuter | Aug 02 2009
 

Site Info
297 Approved Articless
8 Pending Articles
3940 Registered Members
0 People Online (16 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!