//----------------------------------------------------------------------------- // Purpose: // Input : iActivity - //----------------------------------------------------------------------------- void CWarsWeapon::SendViewModelAnim( int nSequence ) { #if defined( CLIENT_DLL ) if ( !IsPredicted() ) { return; } #endif if ( nSequence < 0 ) return; CBasePlayer *pOwner = ToBasePlayer( GetCommander() ); if ( pOwner == NULL ) { BaseClass::SendViewModelAnim( nSequence ); return; } CBaseViewModel *vm = pOwner->GetViewModel( m_nViewModelIndex ); if ( vm == NULL ) { return; } SetViewModel(); Assert( vm->ViewModelIndex() == m_nViewModelIndex ); vm->SendViewModelMatchingSequence( nSequence ); }
void CHL2MP_Player::PostThink( void ) { BaseClass::PostThink(); if ( GetFlags() & FL_DUCKING ) { SetCollisionBounds( VEC_CROUCH_TRACE_MIN, VEC_CROUCH_TRACE_MAX ); } m_PlayerAnimState.Update(); // Store the eye angles pitch so the client can compute its animation state correctly. m_angEyeAngles = EyeAngles(); QAngle angles = GetLocalAngles(); angles[PITCH] = 0; SetLocalAngles( angles ); if (!IsDead()) { if (m_afButtonReleased & IN_KICK && m_flNextKickAttack < gpGlobals->curtime /* && m_flNextKickAttack < gpGlobals->curtime && !m_bIsKicking*/) { KickAttack(); m_bIsKicking = true; } } CBaseCombatWeapon *pWeapon = this->GetActiveWeapon(); if (pWeapon != NULL) { if (m_afButtonPressed & IN_IRONSIGHT) { pWeapon->EnableIronsights(); } else if (m_afButtonReleased & IN_IRONSIGHT) { pWeapon->DisableIronsights(); } } if (!IsDead()) { if (m_flNextKickAttack < gpGlobals->curtime) { m_bIsKicking = false; CBaseViewModel *vm = GetViewModel(1); if (vm) { int idealSequence = vm->SelectWeightedSequence(ACT_VM_IDLE); if (idealSequence >= 0) { vm->SendViewModelMatchingSequence(idealSequence); } } } } }
void CHL2MP_Player::KickAttack(void) { if (!IsDead()) { CBaseViewModel *vm = GetViewModel(1); if (vm) { int idealSequence = vm->SelectWeightedSequence(ACT_VM_PRIMARYATTACK); if (idealSequence >= 0) { vm->SendViewModelMatchingSequence(idealSequence); m_flNextKickAttack = gpGlobals->curtime + vm->SequenceDuration(idealSequence) - 0.5f; } QAngle recoil = QAngle(random->RandomFloat(1.0f, 2.0f), random->RandomFloat(-1.0f, 1.0f), 0); this->ViewPunch(recoil); // Trace up or down based on where the enemy is... // But only if we're basically facing that direction Vector vecDirection; int kick_maxrange = 120; AngleVectors(QAngle(clamp(EyeAngles().x, 20, kick_maxrange), EyeAngles().y, EyeAngles().z), &vecDirection); CBaseEntity *pEnemy = MyNPCPointer() ? MyNPCPointer()->GetEnemy() : NULL; if (pEnemy) { Vector vecDelta; VectorSubtract(pEnemy->WorldSpaceCenter(), Weapon_ShootPosition(), vecDelta); VectorNormalize(vecDelta); Vector2D vecDelta2D = vecDelta.AsVector2D(); Vector2DNormalize(vecDelta2D); if (DotProduct2D(vecDelta2D, vecDirection.AsVector2D()) > 0.8f) { vecDirection = vecDelta; } } Vector vecEnd; VectorMA(Weapon_ShootPosition(), 50, vecDirection, vecEnd); trace_t tr; UTIL_TraceHull(Weapon_ShootPosition(), vecEnd, Vector(-16, -16, -16), Vector(16, 16, 16), MASK_SHOT_HULL, this, COLLISION_GROUP_NONE, &tr); // did I hit someone? float KickDamageMult = 50 + (1 * ((fabs(GetAbsVelocity().x) + fabs(GetAbsVelocity().y) + fabs(GetAbsVelocity().z)) / 48)); float KickThrowForceMult = 20 + (1 * ((fabs(GetAbsVelocity().x) + fabs(GetAbsVelocity().y) + fabs(GetAbsVelocity().z)) / 48)); DevMsg("Kicking at %.2f of damage!\n", KickDamageMult); DevMsg("Kicking at %.2f of force!\n", KickThrowForceMult); if (tr.m_pEnt) { if (!(tr.m_pEnt)) { // return; } else { CBasePropDoor *pDoor = dynamic_cast<CBasePropDoor*>((CBaseEntity*)tr.m_pEnt); if (pDoor) { if (pDoor->HasSpawnFlags(SF_BREAKABLE_BY_PLAYER)) { AngularImpulse angVelocity(random->RandomFloat(0, 45), 18, random->RandomFloat(-45, 45)); pDoor->PlayBreakOpenSound(); pDoor->BreakDoor(Weapon_ShootPosition(), angVelocity); return; } pDoor->PlayBreakFailSound(); pDoor->KickFail(); return; } CBaseEntity *Victim = this->CheckTraceHullAttack(Weapon_ShootPosition(), vecEnd, Vector(-16, -16, -16), Vector(16, 16, 16), KickDamageMult, DMG_CRUSH, KickThrowForceMult, true); if (Victim) { EmitSound("HL2Player.kick_body"); return; } } } UTIL_TraceLine(Weapon_ShootPosition(), vecEnd, MASK_SHOT_HULL, this, COLLISION_GROUP_NONE, &tr);//IF we hit anything else if (tr.DidHit()) { EmitSound("HL2Player.kick_wall"); } else { EmitSound("HL2Player.kick_fire"); } } } }