void asw_ragdoll_marine_f() { CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient()); static CRagdollProp * s_pRagdoll = NULL; if (pPlayer && pPlayer->GetMarine()) { CASW_Marine* pMarine = pPlayer->GetMarine(); pMarine->SetKnockedOut(!pMarine->m_bKnockedOut); return; if (pMarine->IsEffectActive(EF_NODRAW) && s_pRagdoll) { //Calcs the diff between ragdoll worldspace center and victim worldspace center, moves the victim by this diff. //Sets the victim's angles to 0, ragdoll yaw, 0 QAngle newAngles( 0, s_pRagdoll->GetAbsAngles()[YAW], 0 ); Vector centerDelta = s_pRagdoll->WorldSpaceCenter() - pMarine->WorldSpaceCenter(); centerDelta.z = 0; // don't put us in the floor Vector newOrigin = pMarine->GetAbsOrigin() + centerDelta; pMarine->SetAbsOrigin( newOrigin ); pMarine->SetAbsAngles( newAngles ); //DetachAttachedRagdoll( s_pRagdoll ); // unnecessary since we remove it next? UTIL_Remove( s_pRagdoll ); pMarine->RemoveEffects( EF_NODRAW ); pMarine->RemoveSolidFlags( FSOLID_NOT_SOLID ); } else { pMarine->InvalidateBoneCache(); pMarine->AddSolidFlags( FSOLID_NOT_SOLID ); CTakeDamageInfo info; info.SetDamageType( DMG_GENERIC ); info.SetDamageForce( vec3_origin ); info.SetDamagePosition( pMarine->WorldSpaceCenter() ); s_pRagdoll = (CRagdollProp*) CreateServerRagdoll( pMarine, 0, info, COLLISION_GROUP_NONE ); if ( s_pRagdoll ) { s_pRagdoll->DisableAutoFade(); s_pRagdoll->SetThink( NULL ); s_pRagdoll->SetUnragdoll( pMarine ); } pMarine->AddEffects( EF_NODRAW ); //pMarine->SetupBones( m_pRagdollBones, BONE_USED_BY_ANYTHING ); } } }