//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CBaseHL2MPBludgeonWeapon::ImpactEffect( trace_t &traceHit ) { // See if we hit water (we don't do the other impact effects in this case) if ( ImpactWater( traceHit.startpos, traceHit.endpos ) ) return; //FIXME: need new decals UTIL_ImpactTrace( &traceHit, DMG_CLUB ); }
//BB: we need a new impact decal for claws on walls, etc. void CWeaponCrowbar::ImpactEffect( trace_t &traceHit ) { // See if we hit water (we don't do the other impact effects in this case) if ( ImpactWater( traceHit.startpos, traceHit.endpos ) ) return; //FIXME: need new decals if (traceHit.m_pEnt->IsPlayer()) { UTIL_ImpactTrace( &traceHit, DMG_BULLET ); } else { UTIL_ImpactTrace( &traceHit, DMG_SLASH );//DMG_SLASH } }
//------------------------------------------------------------------------------ // Purpose : Starts the swing of the weapon and determines the animation // Input : bIsSecondary - is this a secondary attack? //------------------------------------------------------------------------------ void CBaseHL2MPBludgeonWeapon::Swing( int bIsSecondary ) { trace_t traceHit; // Try a ray CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( !pOwner ) return; Vector swingStart = pOwner->Weapon_ShootPosition( ); Vector forward; pOwner->EyeVectors( &forward, NULL, NULL ); Vector swingEnd = swingStart + forward * GetRange(); UTIL_TraceLine( swingStart, swingEnd, MASK_SHOT_HULL, pOwner, COLLISION_GROUP_NONE, &traceHit ); Activity nHitActivity = ACT_VM_HITCENTER; #ifndef CLIENT_DLL // Like bullets, bludgeon traces have to trace against triggers. CTakeDamageInfo triggerInfo( GetOwner(), GetOwner(), GetDamageForActivity( nHitActivity ), DMG_CLUB ); TraceAttackToTriggers( triggerInfo, traceHit.startpos, traceHit.endpos, vec3_origin ); #endif if ( traceHit.fraction == 1.0 ) { float bludgeonHullRadius = 1.732f * BLUDGEON_HULL_DIM; // hull is +/- 16, so use cuberoot of 2 to determine how big the hull is from center to the corner point // Back off by hull "radius" swingEnd -= forward * bludgeonHullRadius; UTIL_TraceHull( swingStart, swingEnd, g_bludgeonMins, g_bludgeonMaxs, MASK_SHOT_HULL, pOwner, COLLISION_GROUP_NONE, &traceHit ); if ( traceHit.fraction < 1.0 && traceHit.m_pEnt ) { Vector vecToTarget = traceHit.m_pEnt->GetAbsOrigin() - swingStart; VectorNormalize( vecToTarget ); float dot = vecToTarget.Dot( forward ); // YWB: Make sure they are sort of facing the guy at least... if ( dot < 0.70721f ) { // Force amiss traceHit.fraction = 1.0f; } else { nHitActivity = ChooseIntersectionPointAndActivity( traceHit, g_bludgeonMins, g_bludgeonMaxs, pOwner ); } } } WeaponSound( SINGLE ); // ------------------------- // Miss // ------------------------- if ( traceHit.fraction == 1.0f ) { nHitActivity = bIsSecondary ? ACT_VM_MISSCENTER2 : ACT_VM_MISSCENTER; // We want to test the first swing again Vector testEnd = swingStart + forward * GetRange(); // See if we happened to hit water ImpactWater( swingStart, testEnd ); } else { Hit( traceHit, nHitActivity ); } // Send the anim SendWeaponAnim( nHitActivity ); pOwner->SetAnimation( PLAYER_ATTACK1 ); ToHL2MPPlayer(pOwner)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY ); //Setup our next attack times m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate(); m_flNextSecondaryAttack = gpGlobals->curtime + SequenceDuration(); }
void CBaseHLBludgeonWeapon::MotionSwing( const Vector &pos, const Vector &dir, float velocity ) { trace_t traceHit; // Try a ray CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( !pOwner ) return; Vector v; Vector swingStart = pos; Vector forward = dir/dir.Length(); //dir*velocity; Vector swingEnd = swingStart + forward * (GetRange()*.75); UTIL_TraceLine( swingStart, swingEnd, MASK_SHOT_HULL, pOwner, COLLISION_GROUP_NONE, &traceHit ); Activity nHitActivity = ACT_VM_HITCENTER; // Like bullets, bludgeon traces have to trace against triggers. CTakeDamageInfo triggerInfo( GetOwner(), GetOwner(), GetDamageForActivity( nHitActivity ), DMG_CLUB ); triggerInfo.SetDamagePosition( traceHit.startpos ); triggerInfo.SetDamageForce( forward ); TraceAttackToTriggers( triggerInfo, traceHit.startpos, traceHit.endpos, forward ); if ( traceHit.fraction == 1.0 ) { float bludgeonHullRadius = 1.732f * BLUDGEON_HULL_DIM; // hull is +/- 16, so use cuberoot of 2 to determine how big the hull is from center to the corner point // Back off by hull "radius" swingEnd -= forward * bludgeonHullRadius; UTIL_TraceHull( swingStart, swingEnd, g_bludgeonMins, g_bludgeonMaxs, MASK_SHOT_HULL, pOwner, COLLISION_GROUP_NONE, &traceHit ); if ( traceHit.fraction < 1.0 && traceHit.m_pEnt ) { Vector vecToTarget = traceHit.m_pEnt->GetAbsOrigin() - swingStart; VectorNormalize( vecToTarget ); float dot = vecToTarget.Dot( forward ); // YWB: Make sure they are sort of facing the guy at least... if ( dot < 0.70721f ) { // Force amiss traceHit.fraction = 1.0f; } else { nHitActivity = ChooseIntersectionPointAndActivity( traceHit, g_bludgeonMins, g_bludgeonMaxs, pOwner ); } } } gamestats->Event_WeaponFired( pOwner, true, GetClassname() ); // ------------------------- // Miss // ------------------------- float motionFireRate = GetFireRate()*.75; if ( traceHit.fraction == 1.0f ) { nHitActivity = ACT_VM_MISSCENTER; // We want to test the first swing again Vector testEnd = swingStart + forward * GetRange(); // See if we happened to hit water if ( ImpactWater( swingStart, testEnd ) ) m_flNextPrimaryAttack = gpGlobals->curtime + motionFireRate; } else { Hit( traceHit, nHitActivity, false ? true : false ); SendWeaponAnim( ACT_VM_HITDYNAMIC ); //Setup our next attack times m_flNextPrimaryAttack = gpGlobals->curtime + motionFireRate; m_flNextSecondaryAttack = gpGlobals->curtime + motionFireRate; } }
//------------------------------------------------------------------------------ // Purpose : Starts the swing of the weapon and determines the animation // Input : bIsSecondary - is this a secondary attack? //------------------------------------------------------------------------------ void CBaseSDKBludgeonWeapon::Swing( int bIsSecondary ) { trace_t traceHit; // Try a ray CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( !pOwner ) return; pOwner->RumbleEffect( RUMBLE_CROWBAR_SWING, 0, RUMBLE_FLAG_RESTART ); Vector swingStart = pOwner->Weapon_ShootPosition( ); Vector forward; forward = pOwner->GetAutoaimVector( AUTOAIM_SCALE_DEFAULT, GetRange() ); Vector swingEnd = swingStart + forward * GetRange(); UTIL_TraceLine( swingStart, swingEnd, MASK_SHOT_HULL, pOwner, COLLISION_GROUP_NONE, &traceHit ); Activity nHitActivity = ACT_VM_HITCENTER; // Like bullets, bludgeon traces have to trace against triggers. CTakeDamageInfo triggerInfo( GetOwner(), GetOwner(), GetDamageForActivity( nHitActivity ), DMG_CLUB ); triggerInfo.SetDamagePosition( traceHit.startpos ); triggerInfo.SetDamageForce( forward ); TraceAttackToTriggers( triggerInfo, traceHit.startpos, traceHit.endpos, forward ); if ( traceHit.fraction == 1.0 ) { float bludgeonHullRadius = 1.732f * BLUDGEON_HULL_DIM; // hull is +/- 16, so use cuberoot of 2 to determine how big the hull is from center to the corner point // Back off by hull "radius" swingEnd -= forward * bludgeonHullRadius; UTIL_TraceHull( swingStart, swingEnd, g_bludgeonMins, g_bludgeonMaxs, MASK_SHOT_HULL, pOwner, COLLISION_GROUP_NONE, &traceHit ); if ( traceHit.fraction < 1.0 && traceHit.m_pEnt ) { Vector vecToTarget = traceHit.m_pEnt->GetAbsOrigin() - swingStart; VectorNormalize( vecToTarget ); float dot = vecToTarget.Dot( forward ); // YWB: Make sure they are sort of facing the guy at least... if ( dot < 0.70721f ) { // Force amiss traceHit.fraction = 1.0f; } else { nHitActivity = ChooseIntersectionPointAndActivity( traceHit, g_bludgeonMins, g_bludgeonMaxs, pOwner ); } } } if ( !bIsSecondary ) { m_iPrimaryAttacks++; } else { m_iSecondaryAttacks++; } gamestats->Event_WeaponFired( pOwner, !bIsSecondary, GetClassname() ); // ------------------------- // Miss // ------------------------- if ( traceHit.fraction == 1.0f ) { nHitActivity = bIsSecondary ? ACT_VM_MISSCENTER2 : ACT_VM_MISSCENTER; // We want to test the first swing again Vector testEnd = swingStart + forward * GetRange(); // See if we happened to hit water ImpactWater( swingStart, testEnd ); } else { Hit( traceHit, nHitActivity, bIsSecondary ? true : false ); } // Send the anim SendWeaponAnim( nHitActivity ); //Setup our next attack times m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate(); m_flNextSecondaryAttack = gpGlobals->curtime + SequenceDuration(); //Play swing sound WeaponSound( SINGLE ); }