bool CWeapon_SLAM::Deploy( void ) { CBaseCombatCharacter *pOwner = GetOwner(); if (!pOwner) { return false; } m_bDetonatorArmed = AnyUndetonatedCharges(); SetModel( GetViewModel() ); m_tSlamState = (int)SLAM_SATCHEL_THROW; // ------------------------------ // Pick the right draw animation // ------------------------------ int iActivity; // If detonator is already armed m_bNeedReload = false; if (m_bDetonatorArmed) { if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0) { iActivity = ACT_SLAM_DETONATOR_DRAW; m_bNeedReload = true; } else if (CanAttachSLAM()) { iActivity = ACT_SLAM_DETONATOR_STICKWALL_DRAW; SetSlamState(SLAM_TRIPMINE_READY); } else { iActivity = ACT_SLAM_DETONATOR_THROW_DRAW; SetSlamState(SLAM_SATCHEL_THROW); } } else { if (CanAttachSLAM()) { iActivity = ACT_SLAM_TRIPMINE_DRAW; SetSlamState(SLAM_TRIPMINE_READY); } else { iActivity = ACT_SLAM_THROW_ND_DRAW; SetSlamState(SLAM_SATCHEL_THROW); } } return DefaultDeploy( (char*)GetViewModel(), (char*)GetWorldModel(), iActivity, (char*)GetAnimPrefix() ); }
//----------------------------------------------------------------------------- // Purpose: // Input : // Output : //----------------------------------------------------------------------------- void CWeapon_SLAM::SLAMThink( void ) { if (m_flWallSwitchTime <= gpGlobals->curtime) { // If not in tripmine mode we need to check to see if we are close to // a wall. If we are we go into satchel_attach mode CBaseCombatCharacter *pOwner = GetOwner(); if ((m_tSlamState != SLAM_TRIPMINE_READY) && (pOwner && pOwner->GetAmmoCount(m_iSecondaryAmmoType) > 0)) { if (CanAttachSLAM()) { if (m_tSlamState == SLAM_SATCHEL_THROW) { SetSlamState(SLAM_SATCHEL_ATTACH); int iAnim = m_bDetonatorArmed ? ACT_SLAM_THROW_TO_STICKWALL : ACT_SLAM_THROW_TO_STICKWALL_ND; SendWeaponAnim( iAnim ); m_flWallSwitchTime = gpGlobals->curtime + SequenceDuration(); } } else { if (m_tSlamState == SLAM_SATCHEL_ATTACH) { SetSlamState(SLAM_SATCHEL_THROW); int iAnim = m_bDetonatorArmed ? ACT_SLAM_STICKWALL_TO_THROW : ACT_SLAM_STICKWALL_TO_THROW_ND; SendWeaponAnim( iAnim ); m_flWallSwitchTime = gpGlobals->curtime + SequenceDuration(); } } } } SetNextThink( gpGlobals->curtime + 0.1f ); }
//----------------------------------------------------------------------------- // Purpose: // Input : // Output : //----------------------------------------------------------------------------- void CWeapon_SLAM::PrimaryAttack( void ) { CBaseCombatCharacter *pOwner = GetOwner(); if (!pOwner) { return; } if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0) { return; } switch (m_tSlamState) { case SLAM_TRIPMINE_READY: if (CanAttachSLAM()) { StartTripmineAttach(); } break; case SLAM_SATCHEL_THROW: StartSatchelThrow(); break; case SLAM_SATCHEL_ATTACH: StartSatchelAttach(); break; } }
//----------------------------------------------------------------------------- // Purpose: Secondary attack switches between satchel charge and tripmine mode // Input : // Output : //----------------------------------------------------------------------------- void CWeapon_SLAM::SecondaryAttack( void ) { return; // Nothin for now. SLAM's just a tripmine. CBaseCombatCharacter *pOwner = GetOwner(); if (!pOwner) { return; } if (m_bDetonatorArmed) { StartSatchelDetonate(); } else if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) > 0) { if (m_tSlamState == SLAM_TRIPMINE_READY) { // Play sound for going to throw mode EmitSound( "Weapon_SLAM.ThrowMode" ); if (CanAttachSLAM()) { SetSlamState(SLAM_SATCHEL_ATTACH); SendWeaponAnim( ACT_SLAM_TRIPMINE_TO_STICKWALL_ND ); } else { SetSlamState(SLAM_SATCHEL_THROW); SendWeaponAnim( ACT_SLAM_TRIPMINE_TO_THROW_ND ); } } else { // Play sound for going to tripmine mode EmitSound( "Weapon_SLAM.TripMineMode" ); if (m_tSlamState == SLAM_SATCHEL_ATTACH) { SetSlamState(SLAM_TRIPMINE_READY); SendWeaponAnim( ACT_SLAM_STICKWALL_TO_TRIPMINE_ND ); } else { SetSlamState(SLAM_TRIPMINE_READY); SendWeaponAnim( ACT_SLAM_THROW_TO_TRIPMINE_ND ); } } m_flNextSecondaryAttack = gpGlobals->curtime + SequenceDuration(); } }
//----------------------------------------------------------------------------- // Purpose: // Input : // Output : //----------------------------------------------------------------------------- void CWeapon_SLAM::SatchelThrow( void ) { // Only the player fires this way so we can cast CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); #ifndef CLIENT_DLL m_bThrowSatchel = false; Vector vecSrc = pPlayer->WorldSpaceCenter(); Vector vecFacing = pPlayer->BodyDirection3D( ); vecSrc = vecSrc + vecFacing * 18.0; // BUGBUG: is this because vecSrc is not from Weapon_ShootPosition()??? vecSrc.z += 24.0f; Vector vecThrow; GetOwner()->GetVelocity( &vecThrow, NULL ); vecThrow += vecFacing * 500; // Player may have turned to face a wall during the throw anim in which case // we don't want to throw the SLAM into the wall if (CanAttachSLAM()) { vecThrow = vecFacing; vecSrc = pPlayer->WorldSpaceCenter() + vecFacing * 5.0; } CSatchelCharge *pSatchel = (CSatchelCharge*)Create( "npc_satchel", vecSrc, vec3_angle, GetOwner() ); if ( pSatchel ) { pSatchel->SetThrower( GetOwner() ); pSatchel->ApplyAbsVelocityImpulse( vecThrow ); pSatchel->SetLocalAngularVelocity( QAngle( 0, 400, 0 ) ); pSatchel->m_bIsLive = true; pSatchel->m_pMyWeaponSLAM = this; } pPlayer->RemoveAmmo( 1, m_iSecondaryAmmoType ); pPlayer->SetAnimation( PLAYER_ATTACK1 ); #endif //Tony; is there a different anim in the player? must check.. ToHL2MPPlayer(pPlayer)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY ); // Play throw sound EmitSound( "Weapon_SLAM.SatchelThrow" ); }