Posted by: OPTIMUS PRIME
Date posted: Mar 06 2003 User Rating: 5 out of 5.0 | Number of views: 4910 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:
| | if ( ent->v.flags & FL_SKIPLOCALHOST ) |
Change the contents between the start and end bracket of that if statement to be this:
| | { 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
find this line within that function:
| | VectorCopy( gHUD.m_vecAngles, angles ); |
Completely replace that line with this:
| | 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:
| | void UpdateBeams ( void ) |
Within that function look for this line:
add this after that line:
Go down two lines to this line:
| | int idx = pthisplayer->index; |
Add this below it:
| | 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:
| | // 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:
| | gEngfuncs.pEventAPI->EV_PopPMStates(); |
Below it add this:
| | if(bIsEyeObserver) vecDest = vecEnd; else vecDest = tr.endpos;
|
Then go down two more lines and fine this line of code:
| | pBeam->target = tr.endpos; |
Completly change that line it to this:
| | pBeam ->target = vecDest; |
Do the same for pBeam2 which is 2 more lines down
| | pBeam2->target = tr.endpos; |
to...
| | 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. |
|
User Comments
No User Comments
You must register to post a comment. If you have already registered, you must login.
|
297 Approved Articless
8 Pending Articles
3940 Registered Members
0 People Online (6 guests)
|
|