Tripwire Interactive Forums

Go Back   Tripwire Interactive Forums > Killing Floor Forums > Killing Floor Modifications > Coding

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-14-2011, 11:51 AM
YoYoBatty's Avatar
YoYoBatty YoYoBatty is offline
Senior Member
 
Join Date: Dec 2009
Location: Canada
Posts: 3,321
Default Can somebody please convert this code into UScript?

Here is the code taken from Half Life 2:

Code:
#define MAX_VIEWMODEL_LAG 1.5f
void CBaseViewModel::CalcViewModelLag( Vector& origin, QAngle& angles, QAngle& original_angles )
{
 // Calculate our drift
 Vector forward;
 AngleVectors( angles, &forward, NULL, NULL );
 if ( gpGlobals->frametime != 0.0f )
 {
  Vector vDifference;
  VectorSubtract( forward, m_vecLastFacing, vDifference );
  if ( fabs( vDifference.x ) > MAX_VIEWMODEL_LAG ||
    fabs( vDifference.y ) > MAX_VIEWMODEL_LAG ||
    fabs( vDifference.z ) > MAX_VIEWMODEL_LAG )
  {
   m_vecLastFacing = forward;
  }
  // FIXME:  Needs to be predictable?
  VectorMA( m_vecLastFacing, 5.0f * gpGlobals->frametime, vDifference, m_vecLastFacing );
  // Make sure it doesn't grow out of control!!!
  VectorNormalize( m_vecLastFacing );
  VectorMA( origin, 5, vDifference * -1, origin );
 }
 Vector right, up;
 AngleVectors( original_angles, &forward, &right, &up );
 float pitch = original_angles[ PITCH ];
 if ( pitch > 180.0f )
  pitch -= 360.0f;
 else if ( pitch < -180.0f )
  pitch += 360.0f;
 //FIXME: These are the old settings that caused too many exposed polys on some models
 VectorMA( origin, -pitch * 0.035f, forward, origin );
 VectorMA( origin, -pitch * 0.03f,  right, origin );
 VectorMA( origin, -pitch * 0.02f,  up,  origin);
}
This is the original unmodified code, I've made an attempt at converting it from C++ to UScript before and I was unsuccessful. Can somebody help me out?
__________________
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:14 PM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright ©2005 - 2013, Tripwire Interactive, LLC