Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inline const Vector &CShotManipulator::ApplySpread( const Vector &vecSpread, float bias )
- {
- // get circular gaussian spread
- float x, y, z;
- if ( bias > 1.0 )
- bias = 1.0;
- else if ( bias < 0.0 )
- bias = 0.0;
- float shotBiasMin = ai_shot_bias_min.GetFloat();
- float shotBiasMax = ai_shot_bias_max.GetFloat();
- // 1.0 gaussian, 0.0 is flat, -1.0 is inverse gaussian
- float shotBias = ( ( shotBiasMax - shotBiasMin ) * bias ) + shotBiasMin;
- float flatness = ( fabsf(shotBias) * 0.5 );
- do
- {
- x = random->RandomFloat(-1,1) * flatness + random->RandomFloat(-1,1) * (1 - flatness);
- y = random->RandomFloat(-1,1) * flatness + random->RandomFloat(-1,1) * (1 - flatness);
- if ( shotBias < 0 )
- {
- x = ( x >= 0 ) ? 1.0 - x : -1.0 - x;
- y = ( y >= 0 ) ? 1.0 - y : -1.0 - y;
- }
- z = x*x+y*y;
- } while (z > 1);
- m_vecResult = m_vecShotDirection + x * vecSpread.x * m_vecRight + y * vecSpread.y * m_vecUp;
- return m_vecResult;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement