//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponGrapple::FireHook(void) { if (m_bMustReload) return; CBasePlayer *pOwner = ToBasePlayer(GetOwner()); if (pOwner == NULL) return; #ifndef CLIENT_DLL Vector vecAiming = pOwner->GetAutoaimVector(0); Vector vecSrc = pOwner->Weapon_ShootPosition(); QAngle angAiming; VectorAngles(vecAiming, angAiming); CGrappleHook *pHook = CGrappleHook::HookCreate(vecSrc, angAiming, this); if (pOwner->GetWaterLevel() == 3) { pHook->SetAbsVelocity(vecAiming * BOLT_WATER_VELOCITY); } else { pHook->SetAbsVelocity(vecAiming * BOLT_AIR_VELOCITY); } m_hHook = pHook; CreateRope(); #endif pOwner->ViewPunch(QAngle(-2, 0, 0)); WeaponSound(SINGLE); WeaponSound(SPECIAL2); SendWeaponAnim(ACT_VM_PRIMARYATTACK); m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + 0.75; DoLoadEffect(); SetChargerState(CHARGER_STATE_DISCHARGE); }
//----------------------------------------------------------------------------- // Purpose: // Input : state - //----------------------------------------------------------------------------- void CWeaponGrapple::SetChargerState(ChargerState_t state) { // Make sure we're setup CreateChargerEffects(); // Don't do this twice if (state == m_nChargeState) return; m_nChargeState = state; switch (m_nChargeState) { case CHARGER_STATE_START_LOAD: WeaponSound(SPECIAL1); // Shoot some sparks and draw a beam between the two outer points DoLoadEffect(); break; #ifndef CLIENT_DLL case CHARGER_STATE_START_CHARGE: { if (m_hChargerSprite == NULL) break; m_hChargerSprite->SetBrightness(32, 0.5f); m_hChargerSprite->SetScale(0.025f, 0.5f); m_hChargerSprite->TurnOn(); } break; case CHARGER_STATE_READY: { // Get fully charged if (m_hChargerSprite == NULL) break; m_hChargerSprite->SetBrightness(80, 1.0f); m_hChargerSprite->SetScale(0.1f, 0.5f); m_hChargerSprite->TurnOn(); } break; case CHARGER_STATE_DISCHARGE: { SetSkin(BOLT_SKIN_NORMAL); if (m_hChargerSprite == NULL) break; m_hChargerSprite->SetBrightness(0); m_hChargerSprite->TurnOff(); } break; #endif case CHARGER_STATE_OFF: { SetSkin(BOLT_SKIN_NORMAL); #ifndef CLIENT_DLL if (m_hChargerSprite == NULL) break; m_hChargerSprite->SetBrightness(0); m_hChargerSprite->TurnOff(); #endif } break; default: break; } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponCrossbow::FireBolt() { if ( m_iClip1 <= 0 ) { if ( !m_bFireOnEmpty ) Reload(); else { WeaponSound( EMPTY ); m_flNextPrimaryAttack = 0.15; } return; } CBasePlayer *pOwner = ToBasePlayer(GetOwner()); if ( !pOwner ) return; #ifndef CLIENT_DLL pOwner->RumbleEffect(RUMBLE_357, 0, RUMBLE_FLAG_RESTART); Vector vecAiming = pOwner->GetAutoaimVector(0); Vector vecSrc = pOwner->Weapon_ShootPosition(); QAngle angAiming; VectorAngles( vecAiming, angAiming ); #if defined(HL2_EPISODIC) // !!!HACK - the other piece of the Alyx crossbow bolt hack for Outland_10 (see ::BoltTouch() for more detail) if( FStrEq(STRING(gpGlobals->mapname), "ep2_outland_10") ) { trace_t tr; UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 24.0f, MASK_SOLID, pOwner, COLLISION_GROUP_NONE, &tr ); if( tr.m_pEnt != NULL && tr.m_pEnt->Classify() == CLASS_PLAYER_ALLY_VITAL ) { // If Alyx is right in front of the player, make sure the bolt starts outside of the player's BBOX, or the bolt // will instantly collide with the player after the owner of the bolt is switched to Alyx in ::BoltTouch(). We // avoid this altogether by making it impossible for the bolt to collide with the player. vecSrc += vecAiming * 24.0f; } } #endif CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate( vecSrc, angAiming, pOwner ); if ( pOwner->GetWaterLevel() == 3 ) pBolt->SetAbsVelocity(vecAiming * BOLT_WATER_VELOCITY); else pBolt->SetAbsVelocity(vecAiming * BOLT_AIR_VELOCITY); #endif m_iClip1--; pOwner->ViewPunch(QAngle( -2, 0, 0 )); WeaponSound(SINGLE); WeaponSound(SPECIAL2); #ifndef CLIENT_DLL CSoundEnt::InsertSound(SOUND_COMBAT, GetAbsOrigin(), 200, 0.2); #endif SendWeaponAnim(ACT_VM_PRIMARYATTACK); // HEV suit - indicate out of ammo condition if ( !m_iClip1 && pOwner->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) pOwner->SetSuitUpdate("!HEV_AMO0", FALSE, 0); m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + 0.75; DoLoadEffect(); SetChargerState(CHARGER_STATE_DISCHARGE); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponCrossbow::FireBolt( void ) { if ( m_iClip1 <= 0 ) { if ( !m_bFireOnEmpty ) { Reload(); } else { WeaponSound( EMPTY ); m_flNextPrimaryAttack = 0.15; } return; } CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( pOwner == NULL ) return; #ifndef CLIENT_DLL Vector vecAiming = pOwner->GetAutoaimVector( 0 ); Vector vecSrc = pOwner->Weapon_ShootPosition(); QAngle angAiming; VectorAngles( vecAiming, angAiming ); CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate( vecSrc, angAiming, GetHL2MPWpnData().m_iPlayerDamage, pOwner ); if ( pOwner->GetWaterLevel() == 3 ) { pBolt->SetAbsVelocity( vecAiming * BOLT_WATER_VELOCITY ); } else { pBolt->SetAbsVelocity( vecAiming * BOLT_AIR_VELOCITY ); } #endif m_iClip1--; pOwner->ViewPunch( QAngle( -2, 0, 0 ) ); WeaponSound( SINGLE ); WeaponSound( SPECIAL2 ); SendWeaponAnim( ACT_VM_PRIMARYATTACK ); if ( !m_iClip1 && pOwner->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) { // HEV suit - indicate out of ammo condition pOwner->SetSuitUpdate("!HEV_AMO0", FALSE, 0); } m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + 0.75; DoLoadEffect(); SetChargerState( CHARGER_STATE_DISCHARGE ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponShock::FireBolt( void ) { if ( m_iClip1 <= 0 ) { if ( !m_bFireOnEmpty ) { Reload(); } else { WeaponSound( EMPTY ); m_flNextPrimaryAttack = 0.15; } return; } CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( pOwner == NULL ) return; #ifndef CLIENT_DLL CCrossbowBolt *pBolt[3]; //Fires three bolts, one 45 degrees to the left, one 45 degrees to the right, and one straight forward for (int i = 0; i < 3; i++) { Vector vecAiming = pOwner->GetAutoaimVector( 0 ); Vector vecSrc = pOwner->Weapon_ShootPosition(); QAngle angAiming; VectorAngles( vecAiming, angAiming ); angAiming.y -= 10; angAiming.y += (10 * i); vecSrc.y += 3; vecSrc.y -= (3*i); AngleVectors(angAiming, &vecAiming); pBolt[i] = CCrossbowBolt::BoltCreate( vecSrc, angAiming, GetHL2MPWpnData().m_iPlayerDamage, pOwner ); if ( pOwner->GetWaterLevel() == 3 ) { pBolt[i]->SetAbsVelocity( vecAiming * BOLT_WATER_VELOCITY); } else { pBolt[i]->SetAbsVelocity( vecAiming * BOLT_AIR_VELOCITY ); } } #endif m_iClip1 -= 1; pOwner->ViewPunch( QAngle( -2, 0, 0 ) ); WeaponSound( SINGLE ); WeaponSound( SPECIAL2 ); SendWeaponAnim( ACT_VM_PRIMARYATTACK ); if ( !m_iClip1 && pOwner->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) { // HEV suit - indicate out of ammo condition pOwner->SetSuitUpdate("!HEV_AMO0", FALSE, 0); } m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + 0.75; DoLoadEffect(); SetChargerState( CHARGER_STATE_DISCHARGE ); }