Пример #1
0
void RadioSwitchToSong(int n, int entCode)
{

	edict_t *pentUsed = INDEXENT(entCode);

	if (FNullEnt(pentUsed)) return;


	// make radio play something else
	// store current song in IUSER3
	int song = pentUsed->v.iuser3;
	char songname[80];

	if (pentUsed->v.iuser4 == 1) return;

	// cycle thru songs: 1 2 3 1 2 3 etc
	
	if (n == 100)
	{
		song++;
		if (song > 10) song = 1;
	}
	else if (n == 101)
	{
		song--;
		if (song < 1) song = 10;
	}
	else
	{
		song = n;
	}

	// Change songs
	// 1.87 seconds long... the tune sound
	// First stop the OLD sound from playing.
	RadioGetSong( pentUsed->v.iuser3, songname);
	UTIL_EmitAmbientSound(pentUsed, pentUsed->v.origin, songname, 0, 0, SND_STOP, 0);

	// Now play the TUNING SOUND

	UTIL_EmitAmbientSound(pentUsed, pentUsed->v.origin, "avatar-x/avadd21.avfil", 1.0, ATTN_STATIC, 0, 100);
	
	pentUsed->v.iuser3 = song;

	// Set to play the selected song in 1.87 seconds
	
	pentUsed->v.iuser4 = 1;
	pentUsed->v.nextthink = gpGlobals->time + 1.87;
	pentUsed->v.fuser4 = gpGlobals->time + 70;

}
Пример #2
0
void CAmbientGeneric :: RampThink( void )
{
	char* szSoundFile = (char*) STRING(pev->message);
	int pitch = m_dpv.pitch; 
	int vol = m_dpv.vol;
	int flags = 0;
	int fChanged = 0;		// FALSE if pitch and vol remain unchanged this round
	int	prev;

	if (!m_dpv.spinup && !m_dpv.spindown && !m_dpv.fadein && !m_dpv.fadeout && !m_dpv.lfotype)
		return;						// no ramps or lfo, stop thinking

	// ==============
	// pitch envelope
	// ==============
	if (m_dpv.spinup || m_dpv.spindown)
	{
		prev = m_dpv.pitchfrac >> 8;

		if (m_dpv.spinup > 0)
			m_dpv.pitchfrac += m_dpv.spinup;
		else if (m_dpv.spindown > 0)
			m_dpv.pitchfrac -= m_dpv.spindown;

		pitch = m_dpv.pitchfrac >> 8;
		
		if (pitch > m_dpv.pitchrun)
		{
			pitch = m_dpv.pitchrun;
			m_dpv.spinup = 0;				// done with ramp up
		}

		if (pitch < m_dpv.pitchstart)
		{
			pitch = m_dpv.pitchstart;
			m_dpv.spindown = 0;				// done with ramp down

			// shut sound off
			if (m_pPlayFrom)
			{
				STOP_SOUND( m_pPlayFrom, m_iChannel, szSoundFile); //LRC
			}
			else
			{
				UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, 
						0, 0, SND_STOP, 0);
			}

			// return without setting nextthink
			return;
		}

		if (pitch > 255) pitch = 255;
		if (pitch < 1) pitch = 1;

		m_dpv.pitch = pitch;

		fChanged |= (prev != pitch);
		flags |= SND_CHANGE_PITCH;
	}
void CNPC_ControllerZapBall::ExplodeTouch( CBaseEntity *pOther )
{
	if (m_takedamage = DAMAGE_YES )
	{
		trace_t tr;
		tr = GetTouchTrace( );

		ClearMultiDamage( );

		Vector vecAttackDir = GetAbsVelocity();
		VectorNormalize( vecAttackDir );

		if (m_hOwner != NULL)
		{
			CTakeDamageInfo info( this, m_hOwner, sk_controller_dmgball.GetFloat(), DMG_ENERGYBEAM );
			CalculateMeleeDamageForce( &info, vecAttackDir, tr.endpos );
			pOther->DispatchTraceAttack( info, vecAttackDir, &tr );
		}
		else
		{
			CTakeDamageInfo info( this, this, sk_controller_dmgball.GetFloat(), DMG_ENERGYBEAM );
			CalculateMeleeDamageForce( &info, vecAttackDir, tr.endpos );
			pOther->DispatchTraceAttack( info, vecAttackDir, &tr );
		}

		ApplyMultiDamage();

	//	void UTIL_EmitAmbientSound( CBaseEntity *entity, const Vector &vecOrigin, const char *samp, float vol, soundlevel_t soundlevel, int fFlags, int pitch, float soundtime /*= 0.0f*/ )

		UTIL_EmitAmbientSound( GetSoundSourceIndex(), tr.endpos, "Controller.ElectroSound", 0.3, SNDLVL_NORM, 0, random->RandomInt( 90, 99 ) );
	}

	Kill();
}
Пример #4
0
void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther )
{
	if( pOther->pev->takedamage )
	{
		TraceResult tr = UTIL_GetGlobalTrace();

		CBaseEntity* pOwner;
		if( m_hOwner != nullptr )
		{
			pOwner = m_hOwner;
		}
		else
		{
			pOwner = this;
		}

		g_MultiDamage.Clear();
		pOther->TraceAttack( CTakeDamageInfo( pOwner, gSkillData.GetControllerDmgBall(), DMG_ENERGYBEAM ), pev->velocity.Normalize(), &tr );
		g_MultiDamage.ApplyMultiDamage( pOwner, pOwner );

		UTIL_EmitAmbientSound( this, tr.vecEndPos, "weapons/electro4.wav", 0.3, ATTN_NORM, 0, RANDOM_LONG( 90, 99 ) );

	}

	UTIL_Remove( this );
}
Пример #5
0
void CAmbientGeneric :: Precache( void )
{
	char* szSoundFile = (char*) STRING(pev->message);

	if ( !FStringNull( pev->message ) && strlen( szSoundFile ) > 1 )
	{
		if (*szSoundFile != '!')
			PRECACHE_SOUND(szSoundFile);
	}
	// init all dynamic modulation parms
	InitModulationParms();

	if ( !FBitSet (pev->spawnflags, AMBIENT_SOUND_START_SILENT ) )
	{
		// start the sound ASAP
		if (m_fLooping)
			m_fActive = TRUE;
	}
	if ( m_fActive )
	{
		UTIL_EmitAmbientSound ( ENT(pev), pev->origin, szSoundFile, 
				(m_dpv.vol * 0.01), m_flAttenuation, SND_SPAWNING, m_dpv.pitch);

		pev->nextthink = gpGlobals->time + 0.1;
	}
}
void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther )
{
	if (pOther->pev->takedamage)
	{
		TraceResult tr = UTIL_GetGlobalTrace( );

		entvars_t	*pevOwner;
		if (m_hOwner != NULL)
		{
			pevOwner = m_hOwner->pev;
		}
		else
		{
			pevOwner = pev;
		}

		ClearMultiDamage( );
		pOther->TraceAttack(pevOwner, gSkillData.controllerDmgBall, pev->velocity.Normalize(), &tr, DMG_ENERGYBEAM ); 
		ApplyMultiDamage( pevOwner, pevOwner );

		UTIL_EmitAmbientSound( ENT(pev), tr.vecEndPos, "weapons/electro4.wav", 0.3, ATTN_NORM, 0, RANDOM_LONG( 90, 99 ) );

	}

	UTIL_Remove( this );
}
Пример #7
0
//=========================================================
// ZapBeam - heavy damage directly forward
//=========================================================
void CISlave::ZapBeam(int side)
{
	Vector       vecSrc, vecAim;
	TraceResult  tr;
	CBaseEntity *pEntity;

	if(m_iBeams >= ISLAVE_MAX_BEAMS)
		return;

	vecSrc           = pev->origin + gpGlobals->v_up * 36;
	vecAim           = ShootAtEnemy(vecSrc);
	float deflection = 0.01;
	vecAim           = vecAim + side * gpGlobals->v_right * RANDOM_FLOAT(0, deflection) + gpGlobals->v_up * RANDOM_FLOAT(-deflection, deflection);
	UTIL_TraceLine(vecSrc, vecSrc + vecAim * 1024, dont_ignore_monsters, ENT(pev), &tr);

	m_pBeam[m_iBeams] = CBeam::BeamCreate("sprites/lgtning.spr", 50);
	if(!m_pBeam[m_iBeams])
		return;

	m_pBeam[m_iBeams]->PointEntInit(tr.vecEndPos, 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(20);
	m_iBeams++;

	pEntity = CBaseEntity::Instance(tr.pHit);
	if(pEntity != NULL && pEntity->pev->takedamage)
	{
		pEntity->TraceAttack(pev, gSkillData.slaveDmgZap, vecAim, &tr, DMG_SHOCK);
	}
	UTIL_EmitAmbientSound(ENT(pev), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG(140, 160));
}
Пример #8
0
void AvHHive::SetActive()
{
    AvHBaseBuildable::SetActive();

    if(!this->mActive)
    {
        this->mActive = true;
        this->mSpawning = false;
        
        this->mTimeLastContributed = gpGlobals->time;
        
        // Start animating
        this->pev->sequence	= 1;
        this->pev->frame = 0;
        ResetSequenceInfo();
        //AvHSUSetCollisionBoxFromSequence(this->pev);
        
        // Play spawn sound here
        EMIT_SOUND(ENT(this->pev), CHAN_AUTO, kHiveSpawnSound, 1.0, ATTN_IDLE);	
        
        // Note: this isn't being created for the first hive because this sound plays before the map is totally up
        UTIL_EmitAmbientSound(ENT(this->pev), this->pev->origin, kHiveAmbientSound, 1.0f, 2.0, 0, 100);
        
        this->FireSpawnTarget();
        
        //SetUse(&AvHHive::DonateUse);
    }
}
//=========================================================
// Pensar: Bucle de ejecución de tareas.
//=========================================================
void CInSurvivalGameRules::Think()
{
	BaseClass::Think();

	// Hora de reproducir la música.
	if ( NextAmbientMusic <= gpGlobals->curtime )
	{
		UTIL_EmitAmbientSound(0, Vector(0, 0, 0), "Ambient.SurvivorTerror", 0.8f, SNDLVL_NONE, 0, 100);
		NextAmbientMusic = gpGlobals->curtime + (random->RandomInt(20, 80));
	}

	FliesThink();
}
Пример #10
0
void RadioSpawn( edict_t *tEntity )
{
	
	// Spawn routine

	entvars_t *pRunOnPev = VARS( tEntity );

	//pev->movetype = MOVETYPE_NONE;
	tEntity->v.solid = SOLID_NOT;

	//SET_MODEL(pent, "avatar-x/avadd16.avfil");
	

	//pev->frame = 0;
	//pev->framerate = 0;
	
	//UTIL_SetSize(pev, Vector( -12, -12, -12), Vector(12, 12, 12));
	//UTIL_SetOrigin( pev, pev->origin );

	// play deploy sound
	EMIT_SOUND_DYN2( tEntity, CHAN_VOICE, "weapons/mine_deploy.wav", 1.0, ATTN_NORM , 0, 100);
	
	pRunOnPev->iuser2 = pRunOnPev->euser4->v.team; // Set the team this radio belongs to
	pRunOnPev->nextthink = gpGlobals->time + 1;
	pRunOnPev->fuser4 = gpGlobals->time + 70;

	// set default song
	pRunOnPev->iuser3 = 1;

	// set default pitch
	pRunOnPev->iuser1 = 101;

	

	//UTIL_SetSize(pev, Vector( -12, -12, -12), Vector(12, 12, 12));
	//SET_ORIGIN( pent, pev->origin );
	//pev->solid = SOLID_BBOX;
	
	// start playing annoying music
	//UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, 0, 0, SND_STOP, 0);

	//ATTN_STATIC

	char songname[80];
	RadioGetSong( pRunOnPev->iuser3, songname);
	UTIL_EmitAmbientSound(tEntity, pRunOnPev->origin, songname, 1.0, ATTN_STATIC, 0, pRunOnPev->iuser1);
	
	pRunOnPev->fuser3 = gpGlobals->time + (float)RANDOM_LONG(30, 60);


}
Пример #11
0
void CBaseEntity::FireBulletsWater( Vector vecSrc, Vector vecEnd, float ScaleSplash1, float ScaleSplash2 )
{
	if( !( POINT_CONTENTS( vecEnd ) == CONTENTS_WATER && POINT_CONTENTS( vecSrc ) != CONTENTS_WATER ) )
		return;

	float len = Vector( vecEnd - vecSrc).Length();
	Vector vecTemp = ( vecEnd + vecSrc ) / 2;
	while( len >= 1 )
	{
		if( POINT_CONTENTS( vecTemp ) == CONTENTS_WATER )
			vecEnd = vecTemp;
		else
			vecSrc = vecTemp;
		vecTemp = ( vecEnd + vecSrc ) / 2;
		len = Vector( vecEnd - vecSrc).Length();
	}

	MESSAGE_BEGIN(MSG_ALL, gmsgWaterSplash);
	WRITE_COORD( vecTemp.x );
	WRITE_COORD( vecTemp.y );
	WRITE_COORD( vecTemp.z );
	WRITE_COORD( ScaleSplash1 );
	WRITE_COORD( ScaleSplash2 );
	MESSAGE_END();

	switch( RANDOM_LONG( 1, 3 ) )
	{
	case 1:
		UTIL_EmitAmbientSound( ENT(0), vecTemp, "items/water_splash/water_splash1.wav", 1, ATTN_NORM, 0, 100 );
		break;
	case 2:
		UTIL_EmitAmbientSound( ENT(0), vecTemp, "items/water_splash/water_splash2.wav", 1, ATTN_NORM, 0, 100 );
		break;
	case 3:
		UTIL_EmitAmbientSound( ENT(0), vecTemp, "items/water_splash/water_splash3.wav", 1, ATTN_NORM, 0, 100 );
		break;
	}
}
Пример #12
0
void RadioChangeSongPitch(int newPitch, edict_t *pEntity)
{

	pEntity->v.iuser1 = newPitch;


	char songname[80];
	RadioGetSong( pEntity->v.iuser3, songname);
	UTIL_EmitAmbientSound(pEntity, pEntity->v.origin, songname, 1.0, ATTN_STATIC, SND_CHANGE_PITCH, pEntity->v.iuser1);

	
	ALERT(at_console, "Setting pitch to %i on %s\n", pEntity->v.iuser1, songname);

}
Пример #13
0
// this function needs to be called when the game is loaded, not just when the entity spawns.
// Don't make this a PostSpawn function.
void CAmbientGeneric :: Precache( void )
{
	char* szSoundFile = (char*) STRING(pev->message);

	if ( !FStringNull( pev->message ) && strlen( szSoundFile ) > 1 )
	{
		if (*szSoundFile != '!')
			PRECACHE_SOUND(szSoundFile);
	}
	// init all dynamic modulation parms
	InitModulationParms();

	if ( !FBitSet (pev->spawnflags, AMBIENT_SOUND_START_SILENT ) )
	{
		// start the sound ASAP
		if (m_fLooping)
			m_fActive = TRUE;
	}

	if( pev->target )
	{
		CBaseEntity *pTarget = UTIL_FindEntityByTargetname( NULL, STRING(pev->target));

		if( !pTarget )
		{
			ALERT( at_warning, "ambient_generic \"%s\" can't find \"%s\", its entity to play from.\n",
					STRING(pev->targetname), STRING(pev->target));
		}
		else m_pPlayFrom = ENT( pTarget->pev );
	}

	if ( m_fActive )
	{
		if (m_pPlayFrom)
		{
			SetThink(&CAmbientGeneric ::StartPlayFrom); //LRC
//			EMIT_SOUND_DYN( m_pPlayFrom, m_iChannel, szSoundFile, //LRC
//					(m_dpv.vol * 0.01), m_flAttenuation, SND_SPAWNING, m_dpv.pitch);

//			ALERT(at_console, "AMBGEN: spawn start\n");
		}
		else
		{
		UTIL_EmitAmbientSound ( ENT(pev), pev->origin, szSoundFile, 
				(m_dpv.vol * 0.01), m_flAttenuation, SND_SPAWNING, m_dpv.pitch);
		}
		SetNextThink( 0.1 );
	}
}
Пример #14
0
void RadioKillBoom( edict_t *pEntity )
{
	// Delete the radio

	int i = 1;
	char *pClassname;
	edict_t *frontEnt;

	for (i; i < 1025; i++) {

		frontEnt = INDEXENT ( i );
		if (frontEnt) {
			pClassname =  (char *)STRING(frontEnt->v.classname); 
			if (FStrEq("building_radio", pClassname)) {

				if (frontEnt->v.euser4 == pEntity) 
				{

					// Delete this radio
					
					frontEnt->v.flags |= FL_KILLME;

					// Boom

					MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, frontEnt->v.origin );
						WRITE_BYTE( TE_EXPLOSION );		// This makes a dynamic light and the explosion sprites/sound
						WRITE_COORD( frontEnt->v.origin.x );	// Send to PAS because of the sound
						WRITE_COORD( frontEnt->v.origin.y );
						WRITE_COORD( frontEnt->v.origin.z );
						WRITE_SHORT( g_sModelIndexFireball2 );
						WRITE_BYTE( 30  ); // scale * 10
						WRITE_BYTE( 15  ); // framerate
						WRITE_BYTE( 0 );
					MESSAGE_END();
					
					char songname[80];
					RadioGetSong( frontEnt->v.iuser3, songname);

					UTIL_EmitAmbientSound(frontEnt, frontEnt->v.origin, songname, 0, 0, SND_STOP, 0);

					

				}
			}
		}
	}
}
Пример #15
0
void CNihilanthHVR::ZapTouch( CBaseEntity *pOther )
{
	UTIL_EmitAmbientSound( edict(), pev->origin, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, RANDOM_LONG( 90, 95 ) );

	RadiusDamage( pev, pev, 50, CLASS_NONE, DMG_SHOCK );
	pev->velocity = pev->velocity * 0;

	/*
	for (int i = 0; i < 10; i++)
	{
		Crawl( );
	}
	*/

	SetTouch( NULL );
	UTIL_Remove( this );
	pev->nextthink = gpGlobals->time + 0.2;
}
Пример #16
0
void AvHHive::SetInactive()
{
    AvHBaseBuildable::SetInactive();

    // Set this so hives can be drawn translucently at hive locations for aliens
    this->pev->effects &= ~EF_NODRAW;

    this->ResetReinforcingPlayer(false);

	this->mActive = false;
	this->mSpawning = false;
	this->mSolid = false;
	this->mTimeLastContributed = -1;
	this->mTimeEmergencyUseEnabled=-1.0f;
	this->mTechnology = MESSAGE_NULL;

	this->pev->health = 0;
	this->pev->takedamage = DAMAGE_NO;
	this->pev->dmgtime = gpGlobals->time;
	this->pev->solid = SOLID_NOT;
	this->pev->team = TEAM_IND; 
	SetUpgradeMask(&this->pev->iuser4, MASK_BUILDABLE, false);
	
	this->pev->rendermode = kRenderTransAlpha;
	this->pev->renderamt = 0;
	
	// Stop animation
	this->pev->sequence	= 0;
	this->pev->frame = 0;
	this->pev->framerate = 0;

	// No longer built at all
	this->pev->fuser1 = 0.0f;
	SetThink(NULL);
	SetUse(NULL);
	// Stop looping
	UTIL_EmitAmbientSound(ENT(this->pev), this->pev->origin, kHiveAmbientSound, 1.0f, .5, SND_STOP, 100);

	ClearBits (pev->flags, FL_MONSTER); // why are they set in the first place???

	SetTouch(NULL);
}
Пример #17
0
void CCaptureObject::Captured(CBaseEntity *pPlayer)
{
	g_pGameRules->AddScoreToTeam(pev->team, 10);
	UTIL_EmitAmbientSound ( ENT(0), g_vecZero, "game/ctf_captured.wav", VOL_NORM, ATTN_NONE, 0, PITCH_NORM);
	UTIL_ShowMessage("#FLAG_CAPTURED", pPlayer);
	Reset(pPlayer);
	pev->impulse = CO_STAY;
	pev->origin = pev->startpos;
	UTIL_SetOrigin(pev, pev->origin);
	pev->angles = pev->v_angle;

	if (pPlayer == NULL)
		return;

	if (!pPlayer->IsPlayer())
		return;

	CBasePlayer *plr = (CBasePlayer *)pPlayer;
	plr->AddMoney (GIVE_CTF_WIN);
}
Пример #18
0
void FlashFade( Vector vecSrc )
{
	UTIL_EmitAmbientSound( ENT(0), vecSrc, "weapons/flashbang_explode.wav", 1, ATTN_NORM, 0, 100 );

	MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc );
		WRITE_BYTE( TE_DLIGHT );
		
		WRITE_COORD( vecSrc.x );
		WRITE_COORD( vecSrc.y );
		WRITE_COORD( vecSrc.z );
		WRITE_BYTE( 200 );

		WRITE_BYTE( 255 );
		WRITE_BYTE( 255 );
		WRITE_BYTE( 255 );

		WRITE_BYTE( 1 );
		WRITE_BYTE( 1 );
	MESSAGE_END();
	
	TraceResult	tr;
	CBaseEntity *pEntity = NULL;
	for( int i = 1; i <= 32; i++ )
	{
		pEntity = UTIL_PlayerByIndex( i );
		if( pEntity )
		{
			UTIL_TraceLine( vecSrc, pEntity->pev->origin, ignore_monsters, ENT( pEntity->pev ), &tr );
			if( tr.flFraction >= 1 )
			{
				Vector Angles =  UTIL_VecToAngles( vecSrc - pEntity->pev->origin ) - pEntity->pev->angles;
				float a = 255;
				if( Angles.y >= 135 && Angles.y <= 225 )
					a = 200;
				UTIL_ScreenFade( pEntity, Vector( 255, 255, 255 ), 5, 2, a, 0 );
			}
		}
	}
}
Пример #19
0
void CTentacle :: HandleAnimEvent( MonsterEvent_t *pEvent )
{
	char *sound;

	switch( pEvent->event )
	{
	case 1:	// bang 
		{
			Vector vecSrc, vecAngles;
			GetAttachment( 0, vecSrc, vecAngles );

			// Vector vecSrc = pev->origin + m_flTapRadius * Vector( cos( pev->angles.y * (3.14192653 / 180.0) ), sin( pev->angles.y * (M_PI / 180.0) ), 0.0 );

			// vecSrc.z += MyHeight( );

			switch( m_iTapSound )
			{
			case TE_SILO:
				UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitSilo ), 1.0, ATTN_NORM, 0, 100);
				break;
			case TE_NONE:
				break;
			case TE_DIRT:
				UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitDirt ), 1.0, ATTN_NORM, 0, 100);
				break;
			case TE_WATER:
				UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitWater ), 1.0, ATTN_NORM, 0, 100);
				break;
			}
          gpGlobals->force_retouch++;
		}
		break;

	case 3: // start killing swing
		m_iHitDmg = 200;
		// UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), "tentacle/te_swing1.wav", 1.0, ATTN_NORM, 0, 100);
		break;

	case 4: // end killing swing
		m_iHitDmg = 25;
		break;

	case 5: // just "whoosh" sound
		// UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), "tentacle/te_swing2.wav", 1.0, ATTN_NORM, 0, 100);
		break;

	case 2:	// tap scrape
	case 6: // light tap
		{
			Vector vecSrc = pev->origin + m_flTapRadius * Vector( cos( pev->angles.y * (M_PI / 180.0) ), sin( pev->angles.y * (M_PI / 180.0) ), 0.0 );

			vecSrc.z += MyHeight( );

			float flVol = RANDOM_FLOAT( 0.3, 0.5 );

			switch( m_iTapSound )
			{
			case TE_SILO:
				UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitSilo ), flVol, ATTN_NORM, 0, 100);
				break;
			case TE_NONE:
				break;
			case TE_DIRT:
				UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitDirt ), flVol, ATTN_NORM, 0, 100);
				break;
			case TE_WATER:
				UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitWater ), flVol, ATTN_NORM, 0, 100);
				break;
			}
		}
		break;


	case 7: // roar
		switch( RANDOM_LONG(0,1) )
		{
		case 0: sound = "tentacle/te_roar1.wav"; break;
		case 1: sound = "tentacle/te_roar2.wav"; break;
		}

		UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), sound, 1.0, ATTN_NORM, 0, 100);
		break;

	case 8: // search
		switch( RANDOM_LONG(0,1) )
		{
		case 0: sound = "tentacle/te_search1.wav"; break;
		case 1: sound = "tentacle/te_search2.wav"; break;
		}

		UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), sound, 1.0, ATTN_NORM, 0, 100);
		break;

	case 9: // swing
		switch( RANDOM_LONG(0,1) )
		{
		case 0: sound = "tentacle/te_move1.wav"; break;
		case 1: sound = "tentacle/te_move2.wav"; break;
		}

		UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), sound, 1.0, ATTN_NORM, 0, 100);
		break;

	default:
		CBaseMonster::HandleAnimEvent( pEvent );
	}
}
Пример #20
0
//=========================================================
// ZapBeam - heavy damage directly forward
//=========================================================
void CISlave :: ZapBeam( int side )
{
	Vector vecSrc, vecAim;
	TraceResult tr;
	CBaseEntity *pEntity;

	if (m_iBeams >= ISLAVE_MAX_BEAMS)
		return;

	vecSrc = pev->origin + gpGlobals->v_up * 36;
	vecAim = ShootAtEnemy( vecSrc );
	float deflection = 0.01;
	vecAim = vecAim + side * gpGlobals->v_right * RANDOM_FLOAT( 0, deflection ) + gpGlobals->v_up * RANDOM_FLOAT( -deflection, deflection );
	UTIL_TraceLine ( vecSrc, vecSrc + vecAim * 1024, dont_ignore_monsters, ENT( pev ), &tr);

	m_pBeam[m_iBeams] = CBeam::BeamCreate( "sprites/lgtning.spr", 50 );
	if (!m_pBeam[m_iBeams])
		return;

	m_pBeam[m_iBeams]->PointEntInit( tr.vecEndPos, 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( 20 );
	m_iBeams++;

	pEntity = CBaseEntity::Instance(tr.pHit);
	if (pEntity != NULL && pEntity->pev->takedamage)
	{
		pEntity->TraceAttack( pev, gSkillData.slaveDmgZap, vecAim, &tr, DMG_SHOCK );

		//im fat!
//		pev->renderfx = kRenderFxFatness;
		pev->renderamt += 10;

/*
		if (pev->health <=100 )
        pev->renderamt = 20;

		if (pev->health <=110 )
		pev->renderamt = 30;

		if (pev->health <=120 )
		pev->renderamt = 40;

		if (pev->health <=130 )
		pev->renderamt = 50;

		if (pev->health <=140 )
		pev->renderamt = 60;
*/

		TakeHealth(500, DMG_GENERIC);//150
	}

	//sys
/*	CSprite *pSprite = CSprite::SpriteCreate( "sprites/exp_end.spr", tr.vecEndPos, TRUE );
					
	pSprite->SetTransparency( kRenderTransAlpha, 222, 222, 222, 88, kRenderFxNone );
	pSprite->SetScale( 5.0 );
	pSprite->Expand( 5 , RANDOM_FLOAT( 140.0, 160.0 )  );
	pSprite->pev->frame = 0;
*/
	UTIL_DecalTrace( &tr, DECAL_SMALLSCORCH1 );

	UTIL_EmitAmbientSound( ENT(pev), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) );
}
Пример #21
0
void CEnvExplosion::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{ 
	TraceResult tr;

	pev->model = iStringNull;//invisible
	pev->solid = SOLID_NOT;// intangible

	Vector		vecSpot;// trace starts here!

	//LRC
	if (FStringNull(pev->target))
	{
		vecSpot = pev->origin;
	}
	else
	{
		vecSpot = CalcLocus_Position(this, pActivator, STRING(pev->target));
	}
		
	UTIL_TraceLine ( vecSpot + Vector( 0, 0, 8 ), vecSpot + Vector ( 0, 0, -32 ),  ignore_monsters, ENT(pev), & tr);
	
	// Pull out of the wall a bit
	if ( tr.flFraction != 1.0 )
	{
		pev->origin = tr.vecEndPos + (tr.vecPlaneNormal * (m_iMagnitude - 24) * 0.6);
	}
	else
	{
		pev->origin = vecSpot; //LRC
	}

	// draw decal
	if (! ( pev->spawnflags & SF_ENVEXPLOSION_NODECAL))
	{
		if ( RANDOM_FLOAT( 0 , 1 ) < 0.5 )
		{
			UTIL_DecalTrace( &tr, DECAL_SCORCH1 );
		}
		else
		{
			UTIL_DecalTrace( &tr, DECAL_SCORCH2 );
		}
	}

	// draw fireball
	if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOFIREBALL ) )
	{
		Vector vecOrigin(pev->origin.x, pev->origin.y, pev->origin.z);
		MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
			WRITE_BYTE( TE_EXPLOSION);
			WRITE_COORD(vecOrigin.x);
			WRITE_COORD(vecOrigin.y);
			WRITE_COORD(vecOrigin.z);
			WRITE_SHORT( g_sModelIndexFireball );
			WRITE_BYTE( (BYTE)m_spriteScale ); // scale * 10
			WRITE_BYTE( 15  ); // framerate
			WRITE_BYTE(TE_EXPLFLAG_NOSOUND);
		MESSAGE_END();

		UTIL_EmitAmbientSound(ENT(pev), vecOrigin, "weapons/explode3.wav", VOL_NORM, 0.6, 0, 100);
	}
	else
	{
		Vector vecOrigin(pev->origin.x, pev->origin.y, pev->origin.z);
		MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
			WRITE_BYTE( TE_EXPLOSION);
			WRITE_COORD(vecOrigin.x);
			WRITE_COORD(vecOrigin.y);
			WRITE_COORD(vecOrigin.z);
			WRITE_SHORT( g_sModelIndexFireball );
			WRITE_BYTE( 0 ); // no sprite
			WRITE_BYTE( 15  ); // framerate
			WRITE_BYTE(TE_EXPLFLAG_NOSOUND);
		MESSAGE_END();

		UTIL_EmitAmbientSound(ENT(pev), vecOrigin, "weapons/explode3.wav", VOL_NORM, 0.6, 0, 100);
	}

	// do damage
	if ( !( pev->spawnflags & SF_ENVEXPLOSION_NODAMAGE ) )
	{
		RadiusDamage ( pev, pev, m_iMagnitude, CLASS_NONE, DMG_BLAST );
	}

	SetThink(&CEnvExplosion:: Smoke );
	SetNextThink( 0.3 );

	// draw sparks
	if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS ) )
	{
		int sparkCount = RANDOM_LONG(0,3);

		for ( int i = 0; i < sparkCount; i++ )
		{
			Create( "spark_shower", pev->origin, tr.vecPlaneNormal, NULL );
		}
	}
}
void CControllerHeadBall :: HuntThink( void  )
{
	SetNextThink( 0.1 );

	pev->renderamt -= 5;

	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( pev->renderamt / 16 );	// radius
		WRITE_BYTE( 255 );	// R
		WRITE_BYTE( 255 );	// G
		WRITE_BYTE( 255 );	// B
		WRITE_BYTE( 2 );	// life * 10
		WRITE_COORD( 0 ); // decay
	MESSAGE_END();

	// check world boundaries
	if (gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == NULL || m_hOwner == NULL || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096)
	{
		SetTouch( NULL );
		UTIL_Remove( this );
		return;
	}

	MovetoTarget( m_hEnemy->Center( ) );

	if ((m_hEnemy->Center() - pev->origin).Length() < 64)
	{
		TraceResult tr;

		UTIL_TraceLine( pev->origin, m_hEnemy->Center(), dont_ignore_monsters, ENT(pev), &tr );

		CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
		if (pEntity != NULL && pEntity->pev->takedamage)
		{
			ClearMultiDamage( );
			pEntity->TraceAttack( m_hOwner->pev, gSkillData.controllerDmgZap, pev->velocity, &tr, DMG_SHOCK );
			ApplyMultiDamage( pev, m_hOwner->pev );
		}

		MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
			WRITE_BYTE( TE_BEAMENTPOINT );
			WRITE_SHORT( entindex() );
			WRITE_COORD( tr.vecEndPos.x );
			WRITE_COORD( tr.vecEndPos.y );
			WRITE_COORD( tr.vecEndPos.z );
			WRITE_SHORT( g_sModelIndexLaser );
			WRITE_BYTE( 0 ); // frame start
			WRITE_BYTE( 10 ); // framerate
			WRITE_BYTE( 3 ); // life
			WRITE_BYTE( 20 );  // width
			WRITE_BYTE( 0 );   // noise
			WRITE_BYTE( 255 );   // r, g, b
			WRITE_BYTE( 255 );   // r, g, b
			WRITE_BYTE( 255 );   // r, g, b
			WRITE_BYTE( 255 );	// brightness
			WRITE_BYTE( 10 );		// speed
		MESSAGE_END();

		UTIL_EmitAmbientSound( ENT(pev), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) );

		m_flNextAttack = gpGlobals->time + 3.0;

		SetThink(&CControllerHeadBall :: DieThink );
		SetNextThink( 0.3 );
	}

	// Crawl( );
}
Пример #23
0
void CNihilanthHVR :: ZapThink( void  )
{
	pev->nextthink = gpGlobals->time + 0.05;

	// check world boundaries
	if (m_hEnemy == NULL ||  pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096)
	{
		SetTouch( NULL );
		UTIL_Remove( this );
		return;
	}

	if (pev->velocity.Length() < 2000)
	{
		pev->velocity = pev->velocity * 1.2;
	}


	// MovetoTarget( m_hEnemy->Center( ) );

	if ((m_hEnemy->Center() - pev->origin).Length() < 256)
	{
		TraceResult tr;

		UTIL_TraceLine( pev->origin, m_hEnemy->Center(), dont_ignore_monsters, edict(), &tr );

		CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
		if (pEntity != NULL && pEntity->pev->takedamage)
		{
			ClearMultiDamage( );
			pEntity->TraceAttack( pev, gSkillData.nihilanthZap, pev->velocity, &tr, DMG_SHOCK );
			ApplyMultiDamage( pev, pev );
		}

		MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
			WRITE_BYTE( TE_BEAMENTPOINT );
			WRITE_SHORT( entindex() );
			WRITE_COORD( tr.vecEndPos.x );
			WRITE_COORD( tr.vecEndPos.y );
			WRITE_COORD( tr.vecEndPos.z );
			WRITE_SHORT( g_sModelIndexLaser );
			WRITE_BYTE( 0 ); // frame start
			WRITE_BYTE( 10 ); // framerate
			WRITE_BYTE( 3 ); // life
			WRITE_BYTE( 20 );  // width
			WRITE_BYTE( 20 );   // noise
			WRITE_BYTE( 64 );   // r, g, b
			WRITE_BYTE( 196 );   // r, g, b
			WRITE_BYTE( 255);   // r, g, b
			WRITE_BYTE( 255 );	// brightness
			WRITE_BYTE( 10 );		// speed
		MESSAGE_END();

		UTIL_EmitAmbientSound( edict(), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) );

		SetTouch( NULL );
		UTIL_Remove( this );
		pev->nextthink = gpGlobals->time + 0.2;
		return;
	}

	pev->frame = (int)(pev->frame + 1) % 11;

	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( 128 );	// radius
		WRITE_BYTE( 128 );	// R
		WRITE_BYTE( 128 );	// G
		WRITE_BYTE( 255 );	// B
		WRITE_BYTE( 10 );	// life * 10
		WRITE_COORD( 128 ); // decay
	MESSAGE_END();

	// Crawl( );
}
Пример #24
0
void CGrenade::C4Think( void )
{
    if( !IsInWorld() )
    {
        UTIL_Remove( this );
        return;
    }

    pev->nextthink = gpGlobals->time + 0.12;

    if( m_flNextFreq <= gpGlobals->time )
    {
        m_flNextFreq = gpGlobals->time + m_flNextFreqInterval;
        m_flNextFreqInterval *= 0.9;

        switch( m_iC4Beep )
        {
        case 0 :
        {
            m_flAttenu = 1.5;
            m_sBeepName = "weapons/c4_beep1.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 140 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        case 1 :
        {
            m_flAttenu = 1.0;
            m_sBeepName = "weapons/c4_beep2.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 70 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        case 2 :
        {
            m_flAttenu = 0.8;
            m_sBeepName = "weapons/c4_beep3.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 40 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        case 3 :
        {
            m_flAttenu = 0.5;
            m_sBeepName = "weapons/c4_beep4.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 30 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        case 4 :
        {
            m_flAttenu = 0.2;
            m_sBeepName = "weapons/c4_beep5.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 20 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        }

        ++m_iC4Beep;
    }

    if( m_flNextBeep <= gpGlobals->time )
    {
        m_flNextBeep = gpGlobals->time + 1.4;
        EMIT_SOUND( ENT( pev ), CHAN_VOICE, m_sBeepName, VOL_NORM, m_flAttenu );

        // TODO: Adds support for bots.
        // TheBots->OnEvent( EVENT_BOMB_BEEP, this, NULL );
    }

    if( m_flNextBlink <= gpGlobals->time )
    {
        m_flNextBlink = gpGlobals->time	+ 2.0;

        MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
        WRITE_BYTE( TE_GLOWSPRITE );
        WRITE_COORD( pev->origin.x );
        WRITE_COORD( pev->origin.y );
        WRITE_COORD( pev->origin.z + 5.0 );
        WRITE_SHORT( g_sModelIndexC4Glow );
        WRITE_BYTE( 1 );
        WRITE_BYTE( 3 );
        WRITE_BYTE( 255 );
        MESSAGE_END();
    }

    if( m_flC4Blow <= gpGlobals->time )
    {
        // TODO: Adds support for bots.
        // TheBots->OnEvent( EVENT_BOMB_EXPLODED, NULL, NULL );

        MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
        WRITE_BYTE( 0 );
        MESSAGE_END();

        if( m_pentCurBombTarget )
        {
            CBaseEntity *pEntity = CBaseEntity::Instance( m_pentCurBombTarget->pev );

            if( pEntity )
            {
                CBaseEntity* pPlayer = CBaseEntity::Instance( pev->owner );

                if( pPlayer )
                {
                    pEntity->Use( pPlayer, this, USE_TOGGLE, 0 );
                }
            }
        }

        CBasePlayer* pPlayer = (CBasePlayer *)CBaseEntity::Instance( pev->owner );

        if( pPlayer )
        {
            pPlayer->pev->frags += 3;
        }

        MESSAGE_BEGIN( MSG_ALL, gmsgBombPickup );
        MESSAGE_END();

        g_pGameRules->m_fBombDropped = FALSE;

        if( pev->waterlevel )
            UTIL_Remove( this );
        else
            SetThink( &CGrenade::Detonate2 );
    }

    if( m_fStartDefuse )
    {
        CBasePlayer* pDefuser = (CBasePlayer *)((CBaseEntity *)m_hDefuser);

        if( pDefuser && m_flDefuseCountDown > gpGlobals->time )
        {
            BOOL isOnGround = !!( pDefuser->pev->flags & FL_ONGROUND );

            if( m_flNextDefuseTime < gpGlobals->time || !isOnGround )
            {
                if( !isOnGround )
                {
                    ClientPrint( m_hDefuser->pev, HUD_PRINTCENTER, "#C4_Defuse_Must_Be_On_Ground" );
                }

                pDefuser->ResetMaxSpeed();
                pDefuser->SetProgressBarTime( 0 );
                pDefuser->m_fBombDefusing = FALSE;

                m_fStartDefuse = FALSE;
                m_flDefuseCountDown = 0.0;

                // TODO: Adds support for bots.
                // TheBots->OnEvent( EVENT_DEFUSE_ABORTED, NULL, NULL );
            }
        }
        else
        {
            // TODO: Adds support for bots.
            // TheBots->OnEvent( EVENT_BOMB_DEFUSED, pDefuser, NULL );

            Broadcast( "BOMBDEF" );

            MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR );
            WRITE_BYTE( 9 );
            WRITE_BYTE( DRC_CMD_EVENT );
            WRITE_SHORT( ENTINDEX( this->edict() ) );
            WRITE_SHORT( NULL );
            WRITE_ENTITY( DRC_FLAG_FINAL | DRC_FLAG_FACEPLAYER | DRC_FLAG_DRAMATIC | 15 );
            MESSAGE_END();

            UTIL_LogPrintf(	"\"%s<%i><%s><CT>\" triggered \"Defused_The_Bomb\"\n",
                            STRING( pDefuser->pev->netname ),
                            GETPLAYERAUTHID( pDefuser->edict() ),
                            GETPLAYERUSERID( pDefuser->edict() ) );

            UTIL_EmitAmbientSound( ENT( pev ), pev->origin, "weapons/c4_beep5.wav", 0, ATTN_NONE, SND_STOP, 0 );
            EMIT_SOUND( ENT( pDefuser->pev ), CHAN_WEAPON, "weapons/c4_disarmed.wav", 0.8, ATTN_NORM );

            UTIL_Remove( this );
            m_fJustBlew = TRUE;

            pDefuser->ResetMaxSpeed();
            pDefuser->m_fBombDefusing = FALSE;

            MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
            WRITE_BYTE( 0 );
            MESSAGE_END();

            if( g_pGameRules->IsCareer() )
            {
                // TODO: Adds support for bots.
                //TheCareerTasks->HandleEvents( EVEN_BOMB_DEFUSED, pDefuser, NULL );
            }

            g_pGameRules->m_bBombDefused = TRUE;
            g_pGameRules->CheckWinConditions();

            pDefuser->pev->frags += 3;

            MESSAGE_BEGIN( MSG_ALL, gmsgBombPickup );
            MESSAGE_END();

            g_pGameRules->m_fBombDropped = FALSE;
            m_fStartDefuse = FALSE;
        }
    }
}
void CNPC_Tentacle::Cycle( void )
{
	//NDebugOverlay::Cross3D( EarPosition(), 32, 255, 0, 0, false, 0.1 );

	// ALERT( at_console, "%s %.2f %d %d\n", STRING( pev->targetname ), pev->origin.z, m_MonsterState, m_IdealMonsterState );
	SetNextThink( gpGlobals->curtime + 0.1 );

	// ALERT( at_console, "%s %d %d %d %f %f\n", STRING( pev->targetname ), pev->sequence, m_iGoalAnim, m_iDir, pev->framerate, pev->health );

	if ( m_NPCState == NPC_STATE_SCRIPT || GetIdealState() == NPC_STATE_SCRIPT)
	{
		SetAbsAngles( QAngle( GetAbsAngles().x, m_flInitialYaw, GetAbsAngles().z ) );
		GetMotor()->SetIdealYaw( m_flInitialYaw );	
		RemoveIgnoredConditions();
		NPCThink( );
		m_iGoalAnim = TENTACLE_ANIM_Pit_Idle;
		return;
	}
	
	StudioFrameAdvance();
	DispatchAnimEvents( this );

	GetMotor()->UpdateYaw( MaxYawSpeed() );
	
	CSound *pSound = NULL;

	GetSenses()->Listen();
	m_BoneFollowerManager.UpdateBoneFollowers(this);

	// Listen will set this if there's something in my sound list
	if ( HeardAnything() )
		 pSound = GetSenses()->GetClosestSound( false, (SOUND_DANGER|SOUND_COMBAT|SOUND_WORLD|SOUND_PLAYER) );
	else
		 pSound = NULL;

	if ( pSound )
	{
		//NDebugOverlay::Line( EarPosition(), pSound->GetSoundOrigin(), 0, 255, 0, false, 0.2 );

		Vector vecDir;
		if ( gpGlobals->curtime - m_flPrevSoundTime < 0.5 )
		{
			float dt = gpGlobals->curtime - m_flPrevSoundTime;
			vecDir = pSound->GetSoundOrigin() + (pSound->GetSoundOrigin() - m_vecPrevSound) / dt - GetAbsOrigin();
		}
		else
		{
			vecDir = pSound->GetSoundOrigin() - GetAbsOrigin();
		}

		m_flPrevSoundTime = gpGlobals->curtime;
		m_vecPrevSound = pSound->GetSoundOrigin();

		m_flSoundYaw = VecToYaw ( vecDir ) - m_flInitialYaw;

		m_iSoundLevel = Level( vecDir.z );

		if (m_flSoundYaw < -180)
			m_flSoundYaw += 360;
		if (m_flSoundYaw > 180)
			m_flSoundYaw -= 360;

		// ALERT( at_console, "sound %d %.0f\n", m_iSoundLevel, m_flSoundYaw );
		if (m_flSoundTime < gpGlobals->curtime)
		{
			// play "I hear new something" sound
			 UTIL_EmitAmbientSound( GetSoundSourceIndex(), GetAbsOrigin() + Vector( 0, 0, MyHeight()), "Tentacle.Alert", 1.0, SNDLVL_GUNFIRE, 0, 100);
		}
		m_flSoundTime = gpGlobals->curtime + random->RandomFloat( 5.0, 10.0 );
	}

	// clip ideal_yaw
	float dy = m_flSoundYaw;
	switch( GetSequence() )
	{
	case TENTACLE_ANIM_Floor_Rear:
	case TENTACLE_ANIM_Floor_Rear_Idle:
	case TENTACLE_ANIM_Lev1_Rear:
	case TENTACLE_ANIM_Lev1_Rear_Idle:
	case TENTACLE_ANIM_Lev2_Rear:
	case TENTACLE_ANIM_Lev2_Rear_Idle:
	case TENTACLE_ANIM_Lev3_Rear:
	case TENTACLE_ANIM_Lev3_Rear_Idle:
		if (dy < 0 && dy > -m_flMaxYaw)
			dy = -m_flMaxYaw;
		if (dy > 0 && dy < m_flMaxYaw)
			dy = m_flMaxYaw;
		break;
	default:
		if (dy < -m_flMaxYaw)
			dy = -m_flMaxYaw;
		if (dy > m_flMaxYaw)
			dy = m_flMaxYaw;
	}
	GetMotor()->SetIdealYaw( m_flInitialYaw + dy );

	if ( IsSequenceFinished() )
	{
		// ALERT( at_console, "%s done %d %d\n", STRING( pev->targetname ), pev->sequence, m_iGoalAnim );
		if ( m_iHealth <= 1)
		{
			m_iGoalAnim = TENTACLE_ANIM_Pit_Idle;

			if ( GetSequence() == TENTACLE_ANIM_Pit_Idle)
			{
				m_iHealth = 75;
			}
		}
		else if ( m_flSoundTime > gpGlobals->curtime )
		{
			if (m_flSoundYaw >= -(m_flMaxYaw + 30) && m_flSoundYaw <= (m_flMaxYaw + 30))
			{
				// strike
				switch ( m_iSoundLevel )
				{
					case 0:
						m_iGoalAnim = SelectWeightedSequence ( ACT_1030 );
						break;
					case 1:
						m_iGoalAnim = SelectWeightedSequence ( ACT_1031 );
						break;
					case 2:
						m_iGoalAnim = SelectWeightedSequence ( ACT_1032 );
						break;
					case 3:
						m_iGoalAnim = SelectWeightedSequence ( ACT_1033 );
						break;
				}
			}
			else if (m_flSoundYaw >= -m_flMaxYaw * 2 && m_flSoundYaw <= m_flMaxYaw * 2) 
			{
				// tap
				switch ( m_iSoundLevel )
				{
					case 0:
						m_iGoalAnim = SelectWeightedSequence ( ACT_1020 );
						break;
					case 1:
						m_iGoalAnim = SelectWeightedSequence ( ACT_1021 );
						break;
					case 2:
						m_iGoalAnim = SelectWeightedSequence ( ACT_1022 );
						break;
					case 3:
						m_iGoalAnim = SelectWeightedSequence ( ACT_1023 );
						break;
				}
			}
			else
			{
				// go into rear idle
				switch ( m_iSoundLevel )
				{
					case 0:
						m_iGoalAnim = SelectWeightedSequence ( ACT_1040 );
						break;
					case 1:
						m_iGoalAnim = SelectWeightedSequence ( ACT_1041 );
						break;
					case 2:
						m_iGoalAnim = SelectWeightedSequence ( ACT_1042 );
						break;
					case 3:
						m_iGoalAnim = SelectWeightedSequence ( ACT_1043 );
						break;
					case 4:
						m_iGoalAnim = SelectWeightedSequence ( ACT_1044 );
						break;
				}
			}
		}
		else if ( GetSequence() == TENTACLE_ANIM_Pit_Idle)
		{
			// stay in pit until hear noise
			m_iGoalAnim = TENTACLE_ANIM_Pit_Idle;
		}
		else if ( GetSequence() == m_iGoalAnim)
		{
			if ( MyLevel() >= 0 && gpGlobals->curtime < m_flSoundTime)
			{
				if ( random->RandomInt(0,9) < m_flSoundTime - gpGlobals->curtime )
				{
					// continue stike
					switch ( m_iSoundLevel )
					{
						case 0:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1030 );
							break;
						case 1:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1031 );
							break;
						case 2:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1032 );
							break;
						case 3:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1033 );
							break;
					}
				}
				else
				{
					// tap
					switch ( m_iSoundLevel )
					{
						case 0:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1020 );
							break;
						case 1:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1021 );
							break;
						case 2:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1022 );
							break;
						case 3:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1023 );
							break;
					}
				}
			}
			else if ( MyLevel( ) < 0 )
			{
				m_iGoalAnim = SelectWeightedSequence( ACT_1010 );
			}
			else
			{
				if (m_flNextSong < gpGlobals->curtime)
				{
					// play "I hear new something" sound
					CPASAttenuationFilter filter( this );
					EmitSound( filter, entindex(), "Tentacle.Sing" );

					m_flNextSong = gpGlobals->curtime + random->RandomFloat( 10, 20 );
				}

				if (random->RandomInt(0,15) == 0)
				{
					// idle on new level
					switch ( random->RandomInt( 0, 3 ) )
					{
						case 0:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1010 );
							break;
						case 1:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1011 );
							break;
						case 2:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1012 );
							break;
						case 3:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1013 );
							break;
					}
				}
				else if ( random->RandomInt( 0, 3 ) == 0 )
				{
					// tap
					switch ( MyLevel() )
					{
						case 0:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1020 );
							break;
						case 1:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1021 );
							break;
						case 2:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1022 );
							break;
						case 3:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1023 );
							break;
					}
				}
				else
				{
					// idle
					switch ( MyLevel() )
					{
						case 0:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1010 );
							break;
						case 1:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1011 );
							break;
						case 2:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1012 );
							break;
						case 3:
							m_iGoalAnim = SelectWeightedSequence ( ACT_1013 );
							break;
					}
				}
			}
			if (m_flSoundYaw < 0)
				m_flSoundYaw += random->RandomFloat( 2, 8 );
			else
				m_flSoundYaw -= random->RandomFloat( 2, 8 );
		}

		SetSequence( FindTransitionSequence( GetSequence(), m_iGoalAnim, &m_iDir ) );
		

		if (m_iDir > 0)
		{
			SetCycle( 0 );
		}
		else
		{
			m_iDir = -1; // just to safe
			SetCycle( 1.0f );
		}

		ResetSequenceInfo( );

		m_flFramerateAdj = random->RandomFloat( -0.2, 0.2 );
		m_flPlaybackRate = m_iDir * 1.0 + m_flFramerateAdj;

		switch( GetSequence() )
		{
		case TENTACLE_ANIM_Floor_Tap:
		case TENTACLE_ANIM_Lev1_Tap:
		case TENTACLE_ANIM_Lev2_Tap:
		case TENTACLE_ANIM_Lev3_Tap:
			{
				Vector vecSrc, v_forward;
				AngleVectors( GetAbsAngles(), &v_forward );

				trace_t tr1, tr2;

				vecSrc = GetAbsOrigin() + Vector( 0, 0, MyHeight() - 4);
				UTIL_TraceLine( vecSrc, vecSrc + v_forward * 512, MASK_NPCSOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr1 );

				vecSrc = GetAbsOrigin() + Vector( 0, 0, MyHeight() + 8);
				UTIL_TraceLine( vecSrc, vecSrc + v_forward * 512, MASK_NPCSOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr2 );

				// ALERT( at_console, "%f %f\n", tr1.flFraction * 512, tr2.flFraction * 512 );

				m_flTapRadius = SetPoseParameter( 0, random->RandomFloat( tr1.fraction * 512, tr2.fraction * 512 ) );
			}
			break;
		default:
			m_flTapRadius = 336; // 400 - 64
			break;
		}
		SetViewOffset( Vector( 0, 0, MyHeight() ) );
		// ALERT( at_console, "seq %d\n", pev->sequence );
	}

	if (m_flPrevSoundTime + 2.0 > gpGlobals->curtime)
	{
		// 1.5 normal speed if hears sounds
		m_flPlaybackRate = m_iDir * 1.5 + m_flFramerateAdj;
	}
	else if (m_flPrevSoundTime + 5.0 > gpGlobals->curtime)
	{
		// slowdown to normal
		m_flPlaybackRate = m_iDir + m_iDir * (5 - (gpGlobals->curtime - m_flPrevSoundTime)) / 2 + m_flFramerateAdj;
	}
}
void CNPC_Tentacle::HandleAnimEvent( animevent_t *pEvent )
{
	switch( pEvent->event )
	{
	case 1:	// bang 
		{
			Vector vecSrc;
			QAngle angAngles;
			GetAttachment( "0", vecSrc, angAngles );

			// Vector vecSrc = GetAbsOrigin() + m_flTapRadius * Vector( cos( GetAbsAngles().y * (3.14192653 / 180.0) ), sin( GetAbsAngles().y * (M_PI / 180.0) ), 0.0 );

			// vecSrc.z += MyHeight( );

			switch( m_iTapSound )
			{
			case TE_SILO:
				UTIL_EmitAmbientSound( GetSoundSourceIndex(), vecSrc, "Tentacle.HitSilo", 1.0, SNDLVL_GUNFIRE, 0, 100);
				break;
			case TE_NONE:
				break;
			case TE_DIRT:
				UTIL_EmitAmbientSound( GetSoundSourceIndex(), vecSrc, "Tentacle.HitDirt", 1.0, SNDLVL_GUNFIRE, 0, 100);
				break;
			case TE_WATER:
				UTIL_EmitAmbientSound( GetSoundSourceIndex(), vecSrc, "Tentacle.HitWater", 1.0, SNDLVL_GUNFIRE, 0, 100);
				break;
			}
		}
		break;

	case 3: // start killing swing
		m_iHitDmg = 200;
		break;

	case 4: // end killing swing
		m_iHitDmg = 25;
		break;

	case 5: // just "whoosh" sound
		break;

	case 2:	// tap scrape
	case 6: // light tap
		{
			Vector vecSrc = GetAbsOrigin() + m_flTapRadius * Vector( cos( GetAbsAngles().y * (M_PI / 180.0) ), sin( GetAbsAngles().y * (M_PI / 180.0) ), 0.0 );

			vecSrc.z += MyHeight( );

			float flVol = random->RandomFloat( 0.3, 0.5 );

			switch( m_iTapSound )
			{
			case TE_SILO:
				UTIL_EmitAmbientSound( GetSoundSourceIndex(), vecSrc, "Tentacle.HitSilo", flVol, SNDLVL_GUNFIRE, 0, 100);
				break;
			case TE_NONE:
				break;
			case TE_DIRT:
				UTIL_EmitAmbientSound( GetSoundSourceIndex(), vecSrc, "Tentacle.HitDirt", flVol, SNDLVL_GUNFIRE, 0, 100);
				break;
			case TE_WATER:
				UTIL_EmitAmbientSound( GetSoundSourceIndex(), vecSrc, "Tentacle.HitWater", flVol, SNDLVL_GUNFIRE, 0, 100);
				break;
			}
		}
		break;


	case 7: // roar
		UTIL_EmitAmbientSound( GetSoundSourceIndex(), GetAbsOrigin() + Vector( 0, 0, MyHeight()), "Tentacle.Roar", 1.0, SNDLVL_GUNFIRE, 0, 100);
		break;

	case 8: // search
		UTIL_EmitAmbientSound( GetSoundSourceIndex(), GetAbsOrigin() + Vector( 0, 0, MyHeight()), "Tentacle.Search", 1.0, SNDLVL_GUNFIRE, 0, 100);
		break;

	case 9: // swing
		UTIL_EmitAmbientSound( GetSoundSourceIndex(), GetAbsOrigin() + Vector( 0, 0, MyHeight()), "Tentacle.Swing", 1.0, SNDLVL_GUNFIRE, 0, 100);
		break;
	default:
		BaseClass::HandleAnimEvent( pEvent );
	}
}
Пример #27
0
void CGrenade::C4Think(void)
{
	if (!IsInWorld())
	{
		UTIL_Remove(this);
		return;
	}

	pev->nextthink = gpGlobals->time + 0.12;

	if (gpGlobals->time >= m_flNextFreq)
	{
		m_flNextFreq = m_flNextFreqInterval + gpGlobals->time;
		m_flNextFreqInterval *= 0.9;

		switch (m_iCurWave)
		{
			case 0:
			{
				m_sBeepName = "weapons/c4_beep1.wav";
				m_fAttenu = 1.5;
				break;
			}

			case 1:
			{
				m_sBeepName = "weapons/c4_beep2.wav";
				m_fAttenu = 1;
				break;
			}

			case 2:
			{
				m_sBeepName = "weapons/c4_beep3.wav";
				m_fAttenu = 0.8;
				break;
			}

			case 3:
			{
				m_sBeepName = "weapons/c4_beep4.wav";
				m_fAttenu = 0.5;
				break;
			}

			case 4:
			{
				m_sBeepName = "weapons/c4_beep5.wav";
				m_fAttenu = 0.2;
				break;
			}
		}

		m_iCurWave++;
	}

	if (gpGlobals->time >= m_flNextBeep)
	{
		m_flNextBeep = gpGlobals->time + 1.4;
		EMIT_SOUND(ENT(pev), CHAN_VOICE, m_sBeepName, VOL_NORM, m_fAttenu);
	}

	if (gpGlobals->time >= m_flNextBlink)
	{
		m_flNextBlink = gpGlobals->time + 2;

		MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, pev->origin);
		WRITE_BYTE(TE_GLOWSPRITE);
		WRITE_COORD(pev->origin.x);
		WRITE_COORD(pev->origin.y);
		WRITE_COORD(pev->origin.z + 5);
		WRITE_SHORT(g_sModelIndexC4Glow);
		WRITE_BYTE(1);
		WRITE_BYTE(3);
		WRITE_BYTE(255);
		MESSAGE_END();
	}

	if (m_flC4Blow <= gpGlobals->time)
	{
		MESSAGE_BEGIN(MSG_ALL, gmsgScenarioIcon);
		WRITE_BYTE(0);
		MESSAGE_END();

		if (m_pentCurBombTarget)
		{
			CBaseEntity *pEntity = CBaseEntity::Instance(m_pentCurBombTarget);

			if (pEntity)
			{
				CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner);
				pEntity->Use(pOwner, this, USE_TOGGLE, 0);
			}
		}

		CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner);
		pOwner->pev->frags += 3;

		MESSAGE_BEGIN(MSG_ALL, gmsgBombPickup);
		MESSAGE_END();

		g_pGameRules->m_bBombDropped = false;

		if (pev->waterlevel != 0)
			UTIL_Remove(this);
		else
			SetThink(&CGrenade::Detonate2);
	}

	if (m_bStartDefuse == true && m_pBombDefuser != NULL)
	{
		CBasePlayer *pDefuser = (CBasePlayer *)CBaseEntity::Instance(m_pBombDefuser);

		if (m_flDefuseCountDown > gpGlobals->time)
		{
			int fOnGround = m_pBombDefuser->pev->flags & FL_ONGROUND;

			if (m_fNextDefuse < gpGlobals->time || !fOnGround)
			{
				if (!fOnGround)
					ClientPrint(m_pBombDefuser->pev, HUD_PRINTCENTER, "#C4_Defuse_Must_Be_On_Ground");

				pDefuser->ResetMaxSpeed();
				pDefuser->m_bIsDefusing = false;
				pDefuser->SetProgressBarTime(0);
				m_bStartDefuse = false;
				m_pBombDefuser = NULL;
				m_flDefuseCountDown = 0;
			}
		}
		else
		{
			if (m_pBombDefuser->pev->deadflag == DEAD_NO)
			{
				Broadcast("BOMBDEF");

				MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR);
				WRITE_BYTE(9);
				WRITE_BYTE(DRC_CMD_EVENT);
				WRITE_SHORT(ENTINDEX(ENT(m_pBombDefuser->pev)));
				WRITE_SHORT(0);
				WRITE_LONG(15 | DRC_FLAG_FINAL | DRC_FLAG_FACEPLAYER | DRC_FLAG_DRAMATIC);
				MESSAGE_END();

				UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Defused_The_Bomb\"\n", STRING(m_pBombDefuser->pev->netname), GETPLAYERUSERID(m_pBombDefuser->edict()), GETPLAYERAUTHID(m_pBombDefuser->edict()));
				UTIL_EmitAmbientSound(ENT(pev), pev->origin, "weapons/c4_beep5.wav", 0, ATTN_NONE, SND_STOP, 0);
				EMIT_SOUND(ENT(m_pBombDefuser->pev), CHAN_WEAPON, "weapons/c4_disarmed.wav", VOL_NORM, ATTN_NORM);
				UTIL_Remove(this);

				m_bJustBlew = true;
				pDefuser->ResetMaxSpeed();
				pDefuser->m_bIsDefusing = false;

				MESSAGE_BEGIN(MSG_ALL, gmsgScenarioIcon);
				WRITE_BYTE(0);
				MESSAGE_END();

				if (g_pGameRules->IsCareer())
				{
					if (!pDefuser->IsBot())
					{
					}
				}

				g_pGameRules->m_bBombDefused = true;
				g_pGameRules->CheckWinConditions();
				pDefuser->pev->frags += 3;

				MESSAGE_BEGIN(MSG_ALL, gmsgBombPickup);
				MESSAGE_END();

				g_pGameRules->m_bBombDropped = false;
				m_bStartDefuse = false;
				m_pBombDefuser = NULL;
			}
			else
			{
				pDefuser->ResetMaxSpeed();
				pDefuser->m_bIsDefusing = false;
				m_bStartDefuse = false;
				m_pBombDefuser = NULL;
			}
		}
	}
}
void CNPC_ControllerHeadBall::HuntThink( void  )
{
	SetNextThink( gpGlobals->curtime + 0.1 );

	if( !m_pSprite )
	{
		Assert(0);
		return;
	}

	m_pSprite->SetBrightness( m_pSprite->GetBrightness() - 5, 0.1f );

	CBroadcastRecipientFilter filter;
	te->DynamicLight( filter, 0.0, &GetAbsOrigin(), 255, 255, 255, 0, m_pSprite->GetBrightness() / 16, 0.2, 0 );

	// check world boundaries
	if (gpGlobals->curtime - m_flSpawnTime > 5 || m_pSprite->GetBrightness() < 64 /*|| GetEnemy() == NULL || m_hOwner == NULL*/ || !IsInWorld() )
	{
		SetTouch( NULL );
		SetThink( &CNPC_ControllerHeadBall::KillThink );
		SetNextThink( gpGlobals->curtime );
		return;
	}

	if( !GetEnemy() )
		return;

	MovetoTarget( GetEnemy()->GetAbsOrigin() );

	if ((GetEnemy()->WorldSpaceCenter() - GetAbsOrigin()).Length() < 64)
	{
		trace_t tr;

		UTIL_TraceLine( GetAbsOrigin(), GetEnemy()->WorldSpaceCenter(), MASK_ALL, this, COLLISION_GROUP_NONE, &tr );

		CBaseEntity *pEntity = tr.m_pEnt;
		if (pEntity != NULL && pEntity->m_takedamage == DAMAGE_YES)
		{
			ClearMultiDamage( );
			Vector dir = GetAbsVelocity();
			VectorNormalize( dir );
			CTakeDamageInfo info( this, this, sk_controller_dmgball.GetFloat(), DMG_SHOCK );
			CalculateMeleeDamageForce( &info, dir, tr.endpos );
			pEntity->DispatchTraceAttack( info, dir, &tr );
			ApplyMultiDamage();

			int haloindex = 0;
			int fadelength = 0;
			int amplitude = 0;
			const Vector vecEnd = tr.endpos;
			te->BeamEntPoint( filter, 0.0, entindex(), NULL, 0, &(tr.m_pEnt->GetAbsOrigin()), 
				g_sModelIndexLaser, haloindex /* no halo */, 0, 10, 3, 20, 20, fadelength, 
				amplitude, 255, 255, 255, 255, 10 );

		}

		UTIL_EmitAmbientSound( GetSoundSourceIndex(), GetAbsOrigin(), "Controller.ElectroSound", 0.5, SNDLVL_NORM, 0, 100 );

		SetNextAttack( gpGlobals->curtime + 3.0 );

		SetThink( &CNPC_ControllerHeadBall::KillThink );
		SetNextThink( gpGlobals->curtime + 0.3 );
	}
}
Пример #29
0
int CFuncCollideWall :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
	ALERT ( at_notice, "TakeDamage()\n");

	TraceResult trace = UTIL_GetGlobalTrace( );

//== 1) //metal
//== 5) //wood
//== 5) //water
//== -1/0) //not defined (default concrete)

	float flVolume = RANDOM_FLOAT ( 0.7 , 1.0 );//random volume range
	BOOL	b_CanMakeParticles = TRUE;

	if ( CVAR_GET_FLOAT( "r_paintball" ) == 0 )
	if ( CVAR_GET_FLOAT( "cl_wallpuff" ) >= 1 )
	{			
		if (pev->frags == 1) //metal
		{								
			UTIL_Ricochet( trace.vecEndPos, 0.5 );

			switch ( RANDOM_LONG(0,2) )
			{
				case 0: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/metal1.wav", flVolume, ATTN_NORM, 0, 100); break;
				case 1: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/metal2.wav", flVolume, ATTN_NORM, 0, 100); break;
				case 2: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/metal3.wav", flVolume, ATTN_NORM, 0, 100); break;
			}

			if (RANDOM_LONG( 0, 99 ) < 40)
			UTIL_WhiteSparks( trace.vecEndPos, trace.vecPlaneNormal, 0, 5, 500, 500 );//chispas

			UTIL_WhiteSparks( trace.vecEndPos, trace.vecPlaneNormal, 9, 5, 5, 100 );//puntos
			UTIL_WhiteSparks( trace.vecEndPos, trace.vecPlaneNormal, 0, 5, 500, 20 );//chispas
												
			b_CanMakeParticles = FALSE;
		}
		if (pev->frags == 5) //wood
		{
			switch ( RANDOM_LONG(0,2) )
			{
				case 0: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/wood1.wav", flVolume, ATTN_NORM, 0, 100); break;
				case 1: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/wood2.wav", flVolume, ATTN_NORM, 0, 100); break;
				case 2: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/wood3.wav", flVolume, ATTN_NORM, 0, 100); break;
			}
		}
		else if (pev->frags == 6) //water
		{
			switch ( RANDOM_LONG(0,2) )
			{
				case 0: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/water1.wav", flVolume, ATTN_NORM, 0, 100); break;
				case 1: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/water2.wav", flVolume, ATTN_NORM, 0, 100); break;
				case 2: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/water3.wav", flVolume, ATTN_NORM, 0, 100); break;
			}
		}
		else if (pev->frags == 7) //gas canister
		{
			switch ( RANDOM_LONG(0,1) )
			{
				case 0: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/gascan1.wav", flVolume, ATTN_NORM, 0, 100); break;
				case 1: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/gascan2.wav", flVolume, ATTN_NORM, 0, 100); break;
			}
		}

		else
		{
			switch ( RANDOM_LONG(0,2) )
			{
				case 0: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/concrete1.wav", flVolume, ATTN_NORM, 0, 100); break;
				case 1: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/concrete2.wav", flVolume, ATTN_NORM, 0, 100); break;
				case 2: UTIL_EmitAmbientSound(ENT(0), trace.vecEndPos, "weapons/bulletimpact/concrete3.wav", flVolume, ATTN_NORM, 0, 100); break;
			}
		}	
		
		if (b_CanMakeParticles)
		{
			if ( CVAR_GET_FLOAT("r_particles" ) != 0 )			
			{
				MESSAGE_BEGIN(MSG_ALL, gmsgParticles);
					WRITE_SHORT(0);
					WRITE_BYTE(0);
					WRITE_COORD( trace.vecEndPos.x );
					WRITE_COORD( trace.vecEndPos.y );
					WRITE_COORD( trace.vecEndPos.z );
					WRITE_COORD( 0 );
					WRITE_COORD( 0 );
					WRITE_COORD( 0 );
					if (pev->frags == 5) //wood
					WRITE_SHORT(iDefaultHitWood1);
					else if (pev->frags == 6) //water
					WRITE_SHORT(iDefaultWaterSplash);
					else if (pev->frags == 7) //gas canister
					WRITE_SHORT(iDefaultGasCanister);
					else
					WRITE_SHORT(iDefaultWallSmoke);
				MESSAGE_END();
			}
		}
	}//eo cvar check
	return 1;
}
Пример #30
0
void RadioThink ( edict_t *pent )
{


	if (pent->v.fuser3 < gpGlobals->time)
	{
		// babble
		pent->v.fuser3 = gpGlobals->time + (float)RANDOM_LONG(50, 80);
	
		int babnum = RANDOM_LONG(1, 3);
		if (babnum == 1) EMIT_SOUND_DYN2(pent, CHAN_WEAPON, "avatar-x/djtalk1.wav", 0.98, ATTN_STATIC, 0, 100); 
		if (babnum == 2) EMIT_SOUND_DYN2(pent, CHAN_WEAPON, "avatar-x/djtalk2.wav", 0.98, ATTN_STATIC, 0, 100); 
		if (babnum == 3) EMIT_SOUND_DYN2(pent, CHAN_WEAPON, "avatar-x/djtalk3.wav", 0.98, ATTN_STATIC, 0, 100); 

	}

	if (pent->v.iuser4 == 1)
	{

		// Start playing new song
		char songname[80];
		RadioGetSong( pent->v.iuser3 , songname);
		UTIL_EmitAmbientSound(pent, pent->v.origin, songname, 1.0, ATTN_STATIC, 0, pent->v.iuser1);
		
		pent->v.iuser4 = 0;
		pent->v.fuser4 = gpGlobals->time + 70;

	}
	if (pent->v.fuser1 == 0) 
	{
		pent->v.solid = SOLID_BBOX;
		pent->v.fuser1 = 1;
	}
	if (pent->v.fuser4 < gpGlobals->time) 
	{

		// stop and restart the radio
		//char songname[80];
		//RadioGetSong( pent->v.iuser3, songname);

		pent->v.fuser4 = gpGlobals->time + 70;
	}

	// see if we have been destroyed
	if (!pent->v.euser4 || pent->v.health <= 10000 || pent->v.euser4->v.iuser1 != 0 || pent->v.iuser2 != pent->v.euser4->v.team)
	{
		// We've been destroyed! Make a boom and tell the euser4

		if (pent->v.euser4) {
			
			ClientPrint( VARS( pent->v.euser4 ), HUD_PRINTTALK, "* Your radio has been destroyed!\n");
		}
		pent->v.flags |= FL_KILLME;
		// Boom
		MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pent->v.origin );
			WRITE_BYTE( TE_EXPLOSION );		// This makes a dynamic light and the explosion sprites/sound
			WRITE_COORD( pent->v.origin.x );	// Send to PAS because of the sound
			WRITE_COORD( pent->v.origin.y );
			WRITE_COORD( pent->v.origin.z );
			WRITE_SHORT( g_sModelIndexFireball2 );
			WRITE_BYTE( 30  ); // scale * 10
			WRITE_BYTE( 15  ); // framerate
			WRITE_BYTE( 0 );
		MESSAGE_END();

		char songname[80];
		RadioGetSong( pent->v.iuser3, songname);
		UTIL_EmitAmbientSound(pent, pent->v.origin, songname, 0, 0, SND_STOP, 0);

		// hurt anyone who is near this radio
		//AvTakeDamage( VARS(pent->v.euser4), VARS(pent->v.euser4), VARS(pent), 60, DMG_BLAST);
		AvRadiusDamage( pent->v.origin, VARS(pent), VARS(pent->v.euser4), 60, 200, DMG_BLAST);
	}

	pent->v.nextthink = gpGlobals->time + 0.2;

}