voidCGameMovement::DoDuckJump(floatflFraction){if(flFraction>=1.0f){// Since we accelerate the ducking time artificially say that we are ducking so we don't fly up in the airplayer->AddFlag(FL_DUCKING);player->m_Local.m_bDucked=true;player->m_Local.m_bDucking=false;// Force the view offset to be "fully ducked"player->SetViewOffset(GetPlayerViewOffset(true));}else{// Move our view downSetDuckedEyeOffset(flFraction);// Move our body up a fraction of the difference between fully crouched and fully standingVectorhullSizeNormal=VEC_HULL_MAX-VEC_HULL_MIN;VectorhullSizeCrouch=VEC_DUCK_HULL_MAX-VEC_DUCK_HULL_MIN;VectorviewDelta=(hullSizeNormal-hullSizeCrouch)*DUCKJUMP_SCALING*flFraction;Vectorout;VectorAdd(mv->GetAbsOrigin(),viewDelta,out);mv->SetAbsOrigin(out);// See if we are stuck?FixPlayerCrouchStuck(true);// Recategorize position since ducking can change originCategorizePosition();}}voidCGameMovement::DoUnDuckJump(floatflFraction){if(flFraction<=0.0f){// Since we accelerate the ducking time artificially say that we are not ducking so we don't go through the floorplayer->m_Local.m_bDucked=false;player->RemoveFlag(FL_DUCKING);player->m_Local.m_bDucking=false;player->m_Local.m_bInDuckJump=false;// Set our view offset to fully standingplayer->SetViewOffset(GetPlayerViewOffset(false));player->m_Local.m_flDucktime=0;}else{// Move our view upSetDuckedEyeOffset(flFraction);// Move our body down a fraction of the difference between fully crouched and fully standingVectorhullSizeNormal=VEC_HULL_MAX-VEC_HULL_MIN;VectorhullSizeCrouch=VEC_DUCK_HULL_MAX-VEC_DUCK_HULL_MIN;VectorviewDelta=(hullSizeNormal-hullSizeCrouch)*DUCKJUMP_SCALING*flFraction;viewDelta.Negate();Vectorout;VectorAdd(mv->GetAbsOrigin(),viewDelta,out);mv->SetAbsOrigin(out);// See if we are stuck?FixPlayerCrouchStuck(true);// Recategorize position since ducking can change originCategorizePosition();}}

// The player is in duck transition and not duck-jumping.if(player->m_Local.m_bDucking&&!bDuckJump&&!bDuckJumpTime){floatflDuckMilliseconds=max(0.0f,GAMEMOVEMENT_DUCK_TIME-(float)player->m_Local.m_flDucktime);floatflDuckSeconds=flDuckMilliseconds*0.001f;// Finish in duck transition when transition time is over, in "duck", in air.if((flDuckSeconds>TIME_TO_DUCK)||bInDuck||bInAir){FinishDuck();}else{// Calc parametric timefloatflDuckFraction=SimpleSpline(flDuckSeconds/TIME_TO_DUCK);SetDuckedEyeOffset(flDuckFraction);}}

НОВЫЙ КОД (ПРИСЕДАНИЯ):

// The player is in duck transition and not duck-jumping.if(player->m_Local.m_bDucking&&!bDuckJump&&!bDuckJumpTime){floatflDuckMilliseconds=max(0.0f,GAMEMOVEMENT_DUCK_TIME-(float)player->m_Local.m_flDucktime);floatflDuckSeconds=flDuckMilliseconds*0.001f;// Finish in duck transition when transition time is over, in "duck", in air.if(((flDuckSeconds>TIME_TO_DUCK)||bInDuck)&&!bInAir){FinishDuck();}elseif(bInAir){// Speed up our duck transition by two times if we are duck jumpingfloatflDuckFraction=clamp(SimpleSpline(flDuckSeconds/TIME_TO_DUCK)*2.0f,0,1.0f);DoDuckJump(flDuckFraction);}else{// Calc parametric timefloatflDuckFraction=SimpleSpline(flDuckSeconds/TIME_TO_DUCK);SetDuckedEyeOffset(flDuckFraction);}}

СТАРЫЙ КОД (ВСТАВАНИЯ):

// Check to see if we are capable of unducking.if(CanUnduck()){// or unduckingif((player->m_Local.m_bDucking||player->m_Local.m_bDucked)){floatflDuckMilliseconds=max(0.0f,GAMEMOVEMENT_DUCK_TIME-(float)player->m_Local.m_flDucktime);floatflDuckSeconds=flDuckMilliseconds*0.001f;// Finish ducking immediately if duck time is over or not on groundif(flDuckSeconds>TIME_TO_UNDUCK||(bInAir&&!bDuckJump)){FinishUnDuck();}else{// Calc parametric timefloatflDuckFraction=SimpleSpline(1.0f-(flDuckSeconds/TIME_TO_UNDUCK));SetDuckedEyeOffset(flDuckFraction);player->m_Local.m_bDucking=true;}}}

НОВЫЙ КОД (ВСТАВАНИЯ):

// Check to see if we are capable of unducking.if(CanUnduck()){// or unduckingif((player->m_Local.m_bDucking||player->m_Local.m_bDucked)){floatflDuckMilliseconds=max(0.0f,GAMEMOVEMENT_DUCK_TIME-(float)player->m_Local.m_flDucktime);floatflDuckSeconds=flDuckMilliseconds*0.001f;// Finish ducking immediately if duck time is over or not on groundif(flDuckSeconds>TIME_TO_UNDUCK&&!bInAir){FinishUnDuck();}elseif(bInAir){// Reverse our processfloatflDuckFraction=clamp(SimpleSpline(1.0f-(flDuckSeconds/TIME_TO_UNDUCK))*2.0f,0,1.0f);DoUnDuckJump(flDuckFraction);}else{// Calc parametric timefloatflDuckFraction=SimpleSpline(1.0f-(flDuckSeconds/TIME_TO_UNDUCK));SetDuckedEyeOffset(flDuckFraction);player->m_Local.m_bDucking=true;}}}