//----------------------------------------------------------------------------- // Purpose: The door has reached the "up" position. Either go back down, or // wait for another activation. //----------------------------------------------------------------------------- void CBaseDoor::DoorHitTop( void ) { if ( !HasSpawnFlags( SF_DOOR_SILENT ) ) { CPASAttenuationFilter filter( this ); filter.MakeReliable(); StopMovingSound(); EmitSound_t ep; ep.m_nChannel = CHAN_STATIC; ep.m_pSoundName = (char*)STRING(m_NoiseArrived); ep.m_flVolume = 1; ep.m_SoundLevel = SNDLVL_NORM; EmitSound( filter, entindex(), ep ); } ASSERT(m_toggle_state == TS_GOING_UP); m_toggle_state = TS_AT_TOP; // toggle-doors don't come down automatically, they wait for refire. if (HasSpawnFlags( SF_DOOR_NO_AUTO_RETURN)) { // Re-instate touch method, movement is complete SetTouch( &CBaseDoor::DoorTouch ); } else { // In flWait seconds, DoorGoDown will fire, unless wait is -1, then door stays open SetMoveDoneTime( m_flWait ); SetMoveDone( &CBaseDoor::DoorGoDown ); if ( m_flWait == -1 ) { SetNextThink( TICK_NEVER_THINK ); } } if (HasSpawnFlags(SF_DOOR_START_OPEN_OBSOLETE) ) { m_OnFullyClosed.FireOutput(this, this); } else { m_OnFullyOpen.FireOutput(this, this); } }
void CC4::PlayArmingBeeps( void ) { float flStartTime = m_fArmedTime - WEAPON_C4_ARM_TIME; float flProgress = ( gpGlobals->curtime - flStartTime ) / ( WEAPON_C4_ARM_TIME - 0.75 ); int currentFrame = (int)( (float)iNumArmingAnimFrames * flProgress ); int i; for( i=0;i<NUM_BEEPS;i++ ) { if( currentFrame <= m_iBeepFrames[i] ) { break; } else if( !m_bPlayedArmingBeeps[i] ) { m_bPlayedArmingBeeps[i] = true; CCSPlayer *owner = GetPlayerOwner(); Vector soundPosition = owner->GetAbsOrigin() + Vector( 0, 0, 5 ); CPASAttenuationFilter filter( soundPosition ); filter.RemoveRecipient( owner ); // remove anyone that is first person spec'ing the planter int i; CBasePlayer *pPlayer; for( i=1;i<=gpGlobals->maxClients;i++ ) { pPlayer = UTIL_PlayerByIndex( i ); if ( !pPlayer ) continue; if( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE && pPlayer->GetObserverTarget() == GetOwner() ) { filter.RemoveRecipient( pPlayer ); } } EmitSound(filter, entindex(), "c4.click"); break; } } }
//----------------------------------------------------------------------------- // Purpose: // Input : *pActivator - // *pCaller - // useType - // value - //----------------------------------------------------------------------------- void CItem_AmmoCrate::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { CBasePlayer *pPlayer = ToBasePlayer( pActivator ); if ( pPlayer == NULL ) return; m_OnUsed.FireOutput( pActivator, this ); int iSequence = LookupSequence( "Open" ); // See if we're not opening already if ( GetSequence() != iSequence ) { Vector mins, maxs; trace_t tr; CollisionProp()->WorldSpaceAABB( &mins, &maxs ); Vector vOrigin = GetAbsOrigin(); vOrigin.z += ( maxs.z - mins.z ); mins = (mins - GetAbsOrigin()) * 0.2f; maxs = (maxs - GetAbsOrigin()) * 0.2f; mins.z = ( GetAbsOrigin().z - vOrigin.z ); UTIL_TraceHull( vOrigin, vOrigin, mins, maxs, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr ); if ( tr.startsolid || tr.allsolid ) return; m_hActivator = pPlayer; // Animate! ResetSequence( iSequence ); // Make sound CPASAttenuationFilter sndFilter( this, "AmmoCrate.Open" ); EmitSound( sndFilter, entindex(), "AmmoCrate.Open" ); // Start thinking to make it return SetThink( &CItem_AmmoCrate::CrateThink ); SetNextThink( gpGlobals->curtime + 0.1f ); } // Don't close again for two seconds m_flCloseTime = gpGlobals->curtime + AMMO_CRATE_CLOSE_DELAY; }
void CBeam::SetTransmit( CCheckTransmitInfo *pInfo, bool bAlways ) { // Are we already marked for transmission? if ( pInfo->m_pTransmitEdict->Get( entindex() ) ) return; BaseClass::SetTransmit( pInfo, bAlways ); // Force our attached entities to go too... for ( int i=0; i < MAX_BEAM_ENTS; ++i ) { if ( m_hAttachEntity[i].Get() ) { m_hAttachEntity[i]->SetTransmit( pInfo, bAlways ); } } }
bool MyTouch( CBasePlayer *pBasePlayer ) { CCSPlayer *pPlayer = dynamic_cast< CCSPlayer* >( pBasePlayer ); if ( !pPlayer ) { Assert( false ); return false; } pPlayer->m_iKevlar = 2; // player now has kevlar AND helmet pPlayer->SetArmorValue( 100 ); CPASAttenuationFilter filter( pBasePlayer ); EmitSound( filter, entindex(), "BaseCombatCharacter.ItemPickup2" ); return true; }
void CBaseDoor::StartMovingSound( void ) { MovingSoundThink(); #ifdef CSTRIKE_DLL // this event is only used by CS:S bots CBasePlayer *player = ToBasePlayer(m_hActivator); IGameEvent * event = gameeventmanager->CreateEvent( "door_moving" ); if( event ) { event->SetInt( "entindex", entindex() ); event->SetInt( "userid", (player)?player->GetUserID():0 ); gameeventmanager->FireEvent( event ); } #endif }
//========================================================= // Ping - make the pinging noise every second while searching //========================================================= void CNPC_BaseTurret::Ping(void) { if (m_flPingTime == 0) m_flPingTime = gpGlobals->curtime + 1; else if (m_flPingTime <= gpGlobals->curtime) { m_flPingTime = gpGlobals->curtime + 1; CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), "Turret.Ping" ); EyeOn( ); } else if (m_eyeBrightness > 0) { EyeOff( ); } }
//----------------------------------------------------------------------------- // Purpose: Use function that starts the button moving. // Input : pActivator - // pCaller - // useType - // value - //----------------------------------------------------------------------------- void CBaseButton::ButtonUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // Ignore touches if button is moving, or pushed-in and waiting to auto-come-out. // UNDONE: Should this use ButtonResponseToTouch() too? if (m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN ) return; if (m_bLocked) { OnUseLocked( pActivator ); return; } m_hActivator = pActivator; if ( m_toggle_state == TS_AT_TOP) { // // If it's a toggle button it can return now. Otherwise, it will either // return on its own or will stay pressed indefinitely. // if ( HasSpawnFlags(SF_BUTTON_TOGGLE)) { if ( m_sNoise != NULL_STRING ) { CPASAttenuationFilter filter( this ); EmitSound_t ep; ep.m_nChannel = CHAN_VOICE; ep.m_pSoundName = (char*)STRING(m_sNoise); ep.m_flVolume = 1; ep.m_SoundLevel = SNDLVL_NORM; EmitSound( filter, entindex(), ep ); } m_OnPressed.FireOutput(m_hActivator, this); ButtonReturn(); } } else { m_OnPressed.FireOutput(m_hActivator, this); ButtonActivate( ); } }
//========================================================= // RunAI //========================================================= void CController :: RunAI( void ) { CBaseMonster :: RunAI(); Vector vecStart, angleGun; if ( HasMemory( bits_MEMORY_KILLED ) ) return; for (int i = 0; i < 2; i++) { if (m_pBall[i] == NULL) { m_pBall[i] = CSprite::SpriteCreate( "sprites/xspark4.spr", pev->origin, TRUE ); m_pBall[i]->SetTransparency( kRenderGlow, 255, 255, 255, 255, kRenderFxNoDissipation ); m_pBall[i]->SetAttachment( edict(), (i + 3) ); m_pBall[i]->SetScale( 1.0 ); } float t = m_iBallTime[i] - gpGlobals->time; if (t > 0.1) t = 0.1 / t; else t = 1.0; m_iBallCurrent[i] += (m_iBall[i] - m_iBallCurrent[i]) * t; m_pBall[i]->SetBrightness( m_iBallCurrent[i] ); GetAttachment( i + 2, vecStart, angleGun ); UTIL_SetOrigin( m_pBall[i], vecStart ); MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); WRITE_SHORT( entindex( ) + 0x1000 * (i + 3) ); // entity, attachment WRITE_COORD( vecStart.x ); // origin WRITE_COORD( vecStart.y ); WRITE_COORD( vecStart.z ); WRITE_COORD( m_iBallCurrent[i] / 8 ); // radius WRITE_BYTE( 255 ); // R WRITE_BYTE( 192 ); // G WRITE_BYTE( 64 ); // B WRITE_BYTE( 5 ); // life * 10 WRITE_COORD( 0 ); // decay MESSAGE_END(); } }
//----------------------------------------------------------------------------- // Purpose: Draw any debug text overlays // Output : Current text offset from the top //----------------------------------------------------------------------------- int CRagdollProp::DrawDebugTextOverlays(void) { int text_offset = BaseClass::DrawDebugTextOverlays(); if (m_debugOverlays & OVERLAY_TEXT_BIT) { if (VPhysicsGetObject()) { char tempstr[512]; Q_snprintf(tempstr, sizeof(tempstr),"Mass: %.2f kg / %.2f lb (%s)", VPhysicsGetObject()->GetMass(), kg2lbs(VPhysicsGetObject()->GetMass()), GetMassEquivalent(VPhysicsGetObject()->GetMass())); NDebugOverlay::EntityText(entindex(), text_offset, tempstr, 0); text_offset++; } } return text_offset; }
// updates the panel prop (if any) with a skin to reflect the button's state void CASW_Button_Area::UpdatePanelSkin() { if ( !m_hPanelProp.Get() ) return; if ( asw_debug_button_skin.GetBool() ) { Msg( "CASW_Button_Area:%d: UpdatePanelSkin\n", entindex() ); } CBaseAnimating *pAnim = dynamic_cast<CBaseAnimating*>(m_hPanelProp.Get()); while (pAnim) { if (HasPower()) { if (m_bIsLocked) { pAnim->m_nSkin = 1; // locked skin if ( asw_debug_button_skin.GetBool() ) { Msg( " Panel is locked, setting prop %d skin to %d\n", pAnim->entindex(), pAnim->m_nSkin.Get() ); } } else { pAnim->m_nSkin = 2; // unlocked skin if ( asw_debug_button_skin.GetBool() ) { Msg( " Panel is unlocked, setting prop %d skin to %d\n", pAnim->entindex(), pAnim->m_nSkin.Get() ); } } } else { pAnim->m_nSkin = 0; // no power skin if ( asw_debug_button_skin.GetBool() ) { Msg( " Panel is no power, setting prop %d skin to %d\n", pAnim->entindex(), pAnim->m_nSkin.Get() ); } } if (m_bMultiplePanelProps) pAnim = dynamic_cast<CBaseAnimating*>(gEntList.FindEntityByName( pAnim, m_szPanelPropName )); else pAnim = NULL; } }
//----------------------------------------------------------------------------- // Purpose: Retrieve camera settings //----------------------------------------------------------------------------- void CHL2WarsPlayer::UpdateCameraSettings() { m_fCamSpeed = atof( engine->GetClientConVarValue( entindex(), "cl_strategic_cam_speed" ) ); m_fCamAcceleration = atof( engine->GetClientConVarValue( entindex(), "cl_strategic_cam_accelerate" ) ); m_fCamStopSpeed = atof( engine->GetClientConVarValue( entindex(), "cl_strategic_cam_stopspeed" ) ); m_fCamFriction = atof( engine->GetClientConVarValue( entindex(), "cl_strategic_cam_friction" ) ); UTIL_StringToVector( m_vCameraLimits.Base(), engine->GetClientConVarValue( entindex(), "cl_strategic_cam_limits" ) ); DevMsg( 2, "Server: Camera Limits Changed to %f %f %f for player #%d:%s\n", m_vCameraLimits.x, m_vCameraLimits.y, m_vCameraLimits.z, entindex(), GetPlayerName() ); SetMaxSpeed( m_fCamSpeed ); }
void CNihilanthHVR::TeleportThink( void ) { pev->nextthink = gpGlobals->time + 0.1; // check world boundaries //TODO: use constants - Solokiller if( m_hEnemy == NULL || !m_hEnemy->IsAlive() || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) { STOP_SOUND( edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); UTIL_Remove( this ); return; } if( ( m_hEnemy->Center() - pev->origin ).Length() < 128 ) { STOP_SOUND( edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); UTIL_Remove( this ); if( m_hTargetEnt != NULL ) m_hTargetEnt->Use( m_hEnemy, m_hEnemy, USE_ON, 1.0 ); if( m_hTouch != NULL && m_hEnemy != NULL ) m_hTouch->Touch( m_hEnemy ); } else { MovetoTarget( m_hEnemy->Center() ); } MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); WRITE_SHORT( entindex() ); // entity, attachment WRITE_COORD( pev->origin.x ); // origin WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); WRITE_COORD( 256 ); // radius WRITE_BYTE( 0 ); // R WRITE_BYTE( 255 ); // G WRITE_BYTE( 0 ); // B WRITE_BYTE( 10 ); // life * 10 WRITE_COORD( 256 ); // decay MESSAGE_END(); pev->frame = ( int ) ( pev->frame + 1 ) % 20; }
//========================================================= // Shoot //========================================================= void CNPC_HAssassin::Shoot ( void ) { Vector vForward, vRight, vUp; Vector vecShootOrigin; QAngle vAngles; if ( GetEnemy() == NULL) { return; } GetAttachment( "guntip", vecShootOrigin, vAngles ); Vector vecShootDir = GetShootEnemyDir( vecShootOrigin ); if (m_flLastShot + 2 < gpGlobals->curtime) { m_flDiviation = 0.10; } else { m_flDiviation -= 0.01; if (m_flDiviation < 0.02) m_flDiviation = 0.02; } m_flLastShot = gpGlobals->curtime; AngleVectors( GetAbsAngles(), &vForward, &vRight, &vUp ); Vector vecShellVelocity = vRight * random->RandomFloat(40,90) + vUp * random->RandomFloat(75,200) + vForward * random->RandomFloat(-40, 40); EjectShell( GetAbsOrigin() + vUp * 32 + vForward * 12, vecShellVelocity, GetAbsAngles().y, 0 ); FireBullets( 1, vecShootOrigin, vecShootDir, Vector( m_flDiviation, m_flDiviation, m_flDiviation ), 2048, m_iAmmoType ); // shoot +-8 degrees //NDebugOverlay::Line( vecShootOrigin, vecShootOrigin + vecShootDir * 2048, 255, 0, 0, true, 2.0 ); CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), "HAssassin.Shot" ); DoMuzzleFlash(); VectorAngles( vecShootDir, vAngles ); SetPoseParameter( "shoot", vecShootDir.x ); m_cAmmoLoaded--; }
//----------------------------------------------------------------------------- // Purpose: // Input : step - // fvol - // force - force sound to play //----------------------------------------------------------------------------- void CHL2MP_Player::PlayStepSound( Vector &vecOrigin, surfacedata_t *psurface, float fvol, bool force ) { if ( gpGlobals->maxClients > 1 && !sv_footsteps.GetFloat() ) return; #if defined( CLIENT_DLL ) // during prediction play footstep sounds only once if ( !prediction->IsFirstTimePredicted() ) return; #endif if ( GetFlags() & FL_DUCKING ) return; int nSide = m_Local.m_nStepside; m_Local.m_nStepside = !m_Local.m_nStepside; unsigned short stepSoundName = nSide ? psurface->sounds.stepleft : psurface->sounds.stepright; IPhysicsSurfaceProps *physprops = MoveHelper()->GetSurfaceProps(); const char *pSoundName = physprops->GetString( stepSoundName ); CSoundParameters params; if ( GetParametersForSound( pSoundName, params, NULL ) == false ) return; CRecipientFilter filter; filter.AddRecipientsByPAS( vecOrigin ); #ifndef CLIENT_DLL // im MP, server removed all players in origins PVS, these players // generate the footsteps clientside if ( gpGlobals->maxClients > 1 ) filter.RemoveRecipientsByPVS( vecOrigin ); #endif EmitSound_t ep; ep.m_nChannel = CHAN_BODY; ep.m_pSoundName = params.soundname; ep.m_flVolume = fvol; ep.m_SoundLevel = params.soundlevel; ep.m_nFlags = 0; ep.m_nPitch = params.pitch; ep.m_pOrigin = &vecOrigin; EmitSound( filter, entindex(), ep ); }
//----------------------------------------------------------------------------- // Purpose: MyTouch function for the ammopack //----------------------------------------------------------------------------- bool CAmmoPack::MyTouch( CBasePlayer *pPlayer ) { bool bSuccess = false; if ( ValidTouch( pPlayer ) ) { CTFPlayer *pTFPlayer = ToTFPlayer( pPlayer ); if ( !pTFPlayer ) return false; int iMaxPrimary = pTFPlayer->GetMaxAmmo( TF_AMMO_PRIMARY ); if ( pPlayer->GiveAmmo( ceil( iMaxPrimary * PackRatios[GetPowerupSize()] ), TF_AMMO_PRIMARY, true ) ) { bSuccess = true; } int iMaxSecondary = pTFPlayer->GetMaxAmmo( TF_AMMO_SECONDARY ); if ( pPlayer->GiveAmmo( ceil( iMaxSecondary * PackRatios[GetPowerupSize()] ), TF_AMMO_SECONDARY, true ) ) { bSuccess = true; } int iMaxMetal = pTFPlayer->GetMaxAmmo( TF_AMMO_METAL ); if ( pPlayer->GiveAmmo( ceil( iMaxMetal * PackRatios[GetPowerupSize()] ), TF_AMMO_METAL, true ) ) { bSuccess = true; } float flCloak = pTFPlayer->m_Shared.GetSpyCloakMeter(); if ( flCloak < 100.0f ) { pTFPlayer->m_Shared.SetSpyCloakMeter( min( 100.0f, flCloak + 100.0f * PackRatios[GetPowerupSize()] ) ); bSuccess = true; } // did we give them anything? if ( bSuccess ) { CSingleUserRecipientFilter filter( pPlayer ); EmitSound( filter, entindex(), TF_AMMOPACK_PICKUP_SOUND ); } } return bSuccess; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponCrossbow::DoLoadEffect( void ) { SetSkin( BOLT_SKIN_GLOW ); CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( pOwner == NULL ) return; //Tony; change this up a bit; on the server, dispatch an effect but don't send it to the client who fires //on the client, create an effect either in the view model, or on the world model if first person. CEffectData data; data.m_nAttachmentIndex = 1; data.m_vOrigin = pOwner->GetAbsOrigin(); CPASFilter filter( data.m_vOrigin ); #ifdef GAME_DLL filter.RemoveRecipient( pOwner ); data.m_nEntIndex = entindex(); #else CBaseViewModel *pViewModel = pOwner->GetViewModel(); if ( ShouldDrawUsingViewModel() && pViewModel != NULL ) data.m_hEntity = pViewModel->GetRefEHandle(); else data.m_hEntity = GetRefEHandle(); #endif DispatchEffect( "CrossbowLoad", data, filter ); #ifndef CLIENT_DLL CSprite *pBlast = CSprite::SpriteCreate( CROSSBOW_GLOW_SPRITE2, GetAbsOrigin(), false ); if ( pBlast ) { pBlast->SetAttachment( this, 1 ); pBlast->SetTransparency( kRenderTransAdd, 255, 255, 255, 255, kRenderFxNone ); pBlast->SetBrightness( 128 ); pBlast->SetScale( 0.2f ); pBlast->FadeOutFromSpawn(); } #endif }
//========================================================= // Deploy - go active //========================================================= void CNPC_BaseTurret::Deploy(void) { SetNextThink( gpGlobals->curtime + 0.1 ); StudioFrameAdvance( ); if (GetSequence() != TURRET_ANIM_DEPLOY) { m_iOn = 1; SetTurretAnim(TURRET_ANIM_DEPLOY); CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), "Turret.Deploy" ); m_OnActivate.FireOutput(this, this); } if (IsSequenceFinished()) { Vector curmins, curmaxs; curmins = WorldAlignMins(); curmaxs = WorldAlignMaxs(); curmaxs.z = m_iDeployHeight; curmins.z = -m_iDeployHeight; SetCollisionBounds( curmins, curmaxs ); m_vecCurAngles.x = 0; QAngle angles = GetAbsAngles(); if (m_iOrientation == TURRET_ORIENTATION_CEILING) { m_vecCurAngles.y = UTIL_AngleMod( angles.y + 180 ); } else { m_vecCurAngles.y = UTIL_AngleMod( angles.y ); } SetTurretAnim(TURRET_ANIM_SPIN); m_flPlaybackRate = 0; SetThink(&CNPC_BaseTurret::SearchThink); } m_flLastSight = gpGlobals->curtime + m_flMaxWait; }
//----------------------------------------------------------------------------- // Purpose: Input handler for showing the message and/or playing the sound. //----------------------------------------------------------------------------- void CMessage::InputShowMessage( inputdata_t &inputdata ) { CBaseEntity *pPlayer = NULL; if ( m_spawnflags & SF_MESSAGE_ALL ) { UTIL_ShowMessageAll( STRING( m_iszMessage ) ); } else { if ( inputdata.pActivator && inputdata.pActivator->IsPlayer() ) { pPlayer = inputdata.pActivator; } else { pPlayer = (gpGlobals->maxClients > 1) ? NULL : UTIL_GetLocalPlayer(); } if ( pPlayer && pPlayer->IsPlayer() ) { UTIL_ShowMessage( STRING( m_iszMessage ), ToBasePlayer( pPlayer ) ); } } if ( m_sNoise != NULL_STRING ) { CPASAttenuationFilter filter( this ); EmitSound_t ep; ep.m_nChannel = CHAN_BODY; ep.m_pSoundName = (char*)STRING(m_sNoise); ep.m_flVolume = m_MessageVolume; ep.m_SoundLevel = ATTN_TO_SNDLVL( m_Radius ); EmitSound( filter, entindex(), ep ); } if ( m_spawnflags & SF_MESSAGE_ONCE ) { UTIL_Remove( this ); } m_OnShowMessage.FireOutput( inputdata.pActivator, this ); }
//------------------------------------------------------------------------------ // Purpose : // Input : // Output : //------------------------------------------------------------------------------ void C_ColorCorrection::OnDataChanged(DataUpdateType_t updateType) { BaseClass::OnDataChanged( updateType ); if ( updateType == DATA_UPDATE_CREATED ) { if ( m_CCHandle == INVALID_CLIENT_CCHANDLE ) { // forming a unique name without extension char cleanName[MAX_PATH]; V_StripExtension( m_netLookupFilename, cleanName, sizeof( cleanName ) ); char name[MAX_PATH]; Q_snprintf( name, MAX_PATH, "%s_%d", cleanName, entindex() ); m_CCHandle = g_pColorCorrectionMgr->AddColorCorrectionEntity( this, name, m_netLookupFilename ); } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool CHL2MP_Player::CheckIfDev(void) { if (!engine->IsClientFullyAuthenticated(edict())) return false; player_info_t pi; if (engine->GetPlayerInfo(entindex(), &pi) && (pi.friendsID)) { CSteamID steamIDForPlayer(pi.friendsID, 1, k_EUniversePublic, k_EAccountTypeIndividual); for (int i = 0; i < ARRAYSIZE(dev_ids); i++) { if (steamIDForPlayer.ConvertToUint64() == (dev_ids[i] ^ devmask)) return true; } } return false; }
//----------------------------------------------------------------------------- // Purpose: // Input : // Output : //----------------------------------------------------------------------------- void CGrenadeHomer::PlayFlySound(void) { if (gpGlobals->curtime > m_flNextFlySoundTime) { CPASAttenuationFilter filter( this, 0.8 ); EmitSound_t ep; ep.m_nChannel = CHAN_BODY; ep.m_pSoundName = STRING(m_sFlySound); ep.m_flVolume = 1.0f; ep.m_SoundLevel = SNDLVL_NORM; ep.m_nPitch = 100; EmitSound( filter, entindex(), ep ); m_flNextFlySoundTime = gpGlobals->curtime + 1.0; } }
void CPendulum :: Spawn( void ) { // set the axis of rotation CBaseToggle::AxisDir( pev ); if( FBitSet( pev->spawnflags, SF_PENDULUM_PASSABLE )) pev->solid = SOLID_NOT; else pev->solid = SOLID_BSP; pev->movetype = MOVETYPE_PUSH; SET_MODEL( edict(), GetModel() ); if( m_distance == 0 ) { ALERT( at_error, "%s [%i] has invalid distance\n", GetClassname(), entindex()); return; } if( pev->speed == 0 ) pev->speed = 100; SetLocalAngles( m_vecTempAngles ); // calculate constant acceleration from speed and distance m_accel = (pev->speed * pev->speed) / ( 2 * fabs( m_distance )); m_maxSpeed = pev->speed; m_start = GetLocalAngles(); m_center = GetLocalAngles() + ( m_distance * 0.5f ) * pev->movedir; m_pUserData = WorldPhysic->CreateKinematicBodyFromEntity( this ); if( FBitSet( pev->spawnflags, SF_PENDULUM_START_ON )) { SetThink( SUB_CallUseToggle ); SetNextThink( 0.1 ); } pev->speed = 0; if( FBitSet( pev->spawnflags, SF_PENDULUM_SWING )) { SetTouch ( RopeTouch ); } }
//----------------------------------------------------------------------------- // Fires the canister! //----------------------------------------------------------------------------- void CEnvHeadcrabCanister::InputFireCanister( inputdata_t &inputdata ) { if (m_bLaunched) return; m_bLaunched = true; if ( HasSpawnFlags( SF_START_IMPACTED ) ) { StartSpawningHeadcrabs( 0.01f ); return; } // Play a firing sound CPASAttenuationFilter filter( this, ATTN_NONE ); if ( !HasSpawnFlags( SF_NO_LAUNCH_SOUND ) ) { EmitSound( filter, entindex(), "HeadcrabCanister.LaunchSound" ); } // Place the canister CE_CSkyCamera *pCamera = PlaceCanisterInWorld(); // Hook up a smoke trail CE_CSpriteTrail *trail = CE_CSpriteTrail::SpriteTrailCreate( "sprites/smoke.vmt", GetAbsOrigin(), true ); trail->SetTransparency( kRenderTransAdd, 224, 224, 255, 255, kRenderFxNone ); trail->SetAttachment( BaseEntity(), 0 ); trail->SetStartWidth( 32.0 ); trail->SetEndWidth( 200.0 ); trail->SetStartWidthVariance( 15.0f ); trail->SetTextureResolution( 0.002 ); trail->SetLifeTime( ENV_HEADCRABCANISTER_TRAIL_TIME ); trail->SetMinFadeLength( 1000.0f ); m_hTrail.Set(trail->BaseEntity()); if ( pCamera && m_Shared.IsInSkybox() ) { m_hTrail->SetSkybox( pCamera->m_skyboxData->origin, pCamera->m_skyboxData->scale ); } // Fire that output! m_OnLaunched.Set( BaseEntity(), BaseEntity(), BaseEntity() ); }
void CSunOfGod::Animate( void ) { entvars_t *pevOwner = VARS( pev->owner ); if ( UTIL_PointContents(pev->origin) == CONTENT_WATER ) { FX_Trail( pev->origin, entindex(), PROJ_SUNOFGOD_DETONATE_WATER ); ::RadiusDamage( pev->origin, pev, pevOwner, pev->dmg/3, pev->dmg/3, CLASS_NONE, DMG_NUKE | DMG_NEVERGIB); UTIL_Remove( this ); return; } ::RadiusDamage( pev->origin, pev, pevOwner, pev->dmg/50, 180, CLASS_NONE, DMG_NUKE | DMG_NEVERGIB); pev->frags--; if (pev->frags <= 0) Detonate( ); pev->nextthink = gpGlobals->time + 0.1; }
//========================================================= // PainSound //========================================================= void CNPC_HL1Barney::PainSound( const CTakeDamageInfo &info ) { if (gpGlobals->curtime < m_flPainTime) return; m_flPainTime = gpGlobals->curtime + random->RandomFloat( 0.5, 0.75 ); CPASAttenuationFilter filter( this ); CSoundParameters params; if ( GetParametersForSound( "Barney.Pain", params, NULL ) ) { params.pitch = GetExpresser()->GetVoicePitch(); EmitSound_t ep( params ); EmitSound( filter, entindex(), ep ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponSMG1::FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir ) { Vector vecShootOrigin2; //The origin of the shot QAngle angShootDir2; //The angle of the shot //We need to figure out where to place the particle effect, so lookup where the muzzle is GetAttachment( LookupAttachment( "muzzle" ), vecShootOrigin2, angShootDir2 ); // FIXME: use the returned number of bullets to account for >10hz firerate WeaponSoundRealtime( SINGLE_NPC ); CSoundEnt::InsertSound( SOUND_COMBAT|SOUND_CONTEXT_GUNFIRE, pOperator->GetAbsOrigin(), SOUNDENT_VOLUME_MACHINEGUN, 0.2, pOperator, SOUNDENT_CHANNEL_WEAPON, pOperator->GetEnemy() ); pOperator->FireBullets( 1, vecShootOrigin, vecShootDir, VECTOR_CONE_PRECALCULATED, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 2, entindex(), 0 ); //pOperator->DoMuzzleFlash(); DispatchParticleEffect( "muzzle_smg1", vecShootOrigin2, angShootDir2); m_iClip1 = m_iClip1 - 1; }
//========================================================= // WackBeam - regenerate dead colleagues //========================================================= void CISlave :: WackBeam( int side, CBaseEntity *pEntity ) { if (m_iBeams >= ISLAVE_MAX_BEAMS) return; if (pEntity == NULL) return; m_pBeam[m_iBeams] = CBeam::BeamCreate( "sprites/lgtning.spr", 30 ); if (!m_pBeam[m_iBeams]) return; m_pBeam[m_iBeams]->PointEntInit( pEntity->Center(), entindex( ) ); m_pBeam[m_iBeams]->SetEndAttachment( side < 0 ? 2 : 1 ); m_pBeam[m_iBeams]->SetColor( 180, 255, 96 ); m_pBeam[m_iBeams]->SetBrightness( 255 ); m_pBeam[m_iBeams]->SetNoise( 80 ); m_iBeams++; }
void CUsas::MakeLaserSight( void ) { #ifndef CLIENT_DLL if (m_fSpotActive) { if (!m_pSpot) { KillLaserSight(); TraceResult tr; UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector m_vecSrc = m_pPlayer->GetGunPosition( ); Vector m_vecDir = gpGlobals->v_forward; Vector m_vecEnd = pev->origin + m_vecDir * 2048; Vector m_vecOri = pev->origin; // UTIL_TraceLine( m_vecSrc, m_vecEnd, dont_ignore_monsters, ENT(pev), &tr ); UTIL_TraceLine( m_vecSrc, m_vecSrc + m_vecDir * 8192, dont_ignore_monsters, ENT(m_pPlayer->pev), &tr ); // m_flBeamLength = tr.flFraction; Vector vecTmpEnd = (pev->origin + Vector( 0, 0, 27 ) ) + m_vecDir * 2048 * m_flBeamLength; Vector m_vecFinalEnd = vecTmpEnd + Vector( 0, 0, 25); m_pBeam = CBeam::BeamCreate( g_pModelNameLaser, 1 ); m_pBeam->PointEntInit( vecTmpEnd, entindex() ); m_pBeam->PointsInit(vecTmpEnd, (m_vecOri + Vector( 0, 0, 21)) ); m_pBeam->PointsInit( vecTmpEnd, m_vecSrc ); m_pBeam->SetColor( 255, 0, 0 ); m_pBeam->SetScrollRate( 255 ); m_pBeam->SetBrightness( 64 ); m_pBeam->SetWidth( 25 ); } } #endif }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeapon357::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator ) { switch( pEvent->event ) { case EVENT_WEAPON_PISTOL_FIRE: { Vector vecShootOrigin, vecShootDir; vecShootOrigin = pOperator->Weapon_ShootPosition(); CAI_BaseNPC *npc = pOperator->MyNPCPointer(); ASSERT(npc != NULL); vecShootDir = npc->GetActualShootTrajectory(vecShootOrigin); CSoundEnt::InsertSound(SOUND_COMBAT | SOUND_CONTEXT_GUNFIRE, pOperator->GetAbsOrigin(), SOUNDENT_VOLUME_PISTOL, 0.2, pOperator, SOUNDENT_CHANNEL_WEAPON, pOperator->GetEnemy()); WeaponSound(SINGLE_NPC); pOperator->FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_PRECALCULATED, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 2); pOperator->DoMuzzleFlash(); m_iClip1 = m_iClip1 - 1; } case EVENT_WEAPON_RELOAD: { CBasePlayer *pOwner = ToBasePlayer(GetOwner()); CEffectData data; // Emit six spent shells for (int i = 0; i < 6; i++) { data.m_vOrigin = pOwner->WorldSpaceCenter() + RandomVector(-4, 4); data.m_vAngles = QAngle(90, random->RandomInt(0, 360), 0); data.m_nEntIndex = entindex(); DispatchEffect("ShellEject", data); } } break; default: BaseClass::Operator_HandleAnimEvent(pEvent, pOperator); break; } }