Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool CTFWeaponBaseMelee::DoSwingTrace( trace_t &trace )
- {
- // Setup a volume for the melee weapon to be swung - approx size, so all melee behave the same.
- static Vector vecSwingMins( -18, -18, -18 );
- static Vector vecSwingMaxs( 18, 18, 18 );
- // Get the current player.
- CTFPlayer *pPlayer = GetTFPlayerOwner();
- if ( !pPlayer )
- return false;
- // Setup the swing range.
- Vector vecForward;
- AngleVectors( pPlayer->EyeAngles(), &vecForward );
- Vector vecSwingStart = pPlayer->Weapon_ShootPosition();
- Vector vecSwingEnd = vecSwingStart + vecForward * 48;
- // See if we hit anything.
- UTIL_TraceLine( vecSwingStart, vecSwingEnd, MASK_SOLID, pPlayer, COLLISION_GROUP_NONE, &trace );
- if ( trace.fraction >= 1.0 )
- {
- UTIL_TraceHull( vecSwingStart, vecSwingEnd, vecSwingMins, vecSwingMaxs, MASK_SOLID, pPlayer, COLLISION_GROUP_NONE, &trace );
- if ( trace.fraction < 1.0 )
- {
- // Calculate the point of intersection of the line (or hull) and the object we hit
- // This is and approximation of the "best" intersection
- CBaseEntity *pHit = trace.m_pEnt;
- if ( !pHit || pHit->IsBSPModel() )
- {
- // Why duck hull min/max?
- FindHullIntersection( vecSwingStart, trace, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, pPlayer );
- }
- // This is the point on the actual surface (the hull could have hit space)
- vecSwingEnd = trace.endpos;
- }
- }
- return ( trace.fraction < 1.0f );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement