本文整理匯總了C++中EMIT_SOUND函數的典型用法代碼示例。如果您正苦於以下問題:C++ EMIT_SOUND函數的具體用法?C++ EMIT_SOUND怎麽用?C++ EMIT_SOUND使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EMIT_SOUND函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: MaxAmmoCarry
//=========================================================
// CWeaponBox - Touch: try to add my contents to the toucher
// if the toucher is a player.
//=========================================================
void CWeaponBox::Touch( CBaseEntity *pOther )
{
if ( !(pev->flags & FL_ONGROUND ) )
{
return;
}
if ( !pOther->IsPlayer() )
{
// only players may touch a weaponbox.
return;
}
if ( !pOther->IsAlive() )
{
// no dead guys.
return;
}
CBasePlayer *pPlayer = (CBasePlayer *)pOther;
int i;
// dole out ammo
for ( i = 0 ; i < MAX_AMMO_SLOTS ; i++ )
{
if ( !FStringNull( m_rgiszAmmo[ i ] ) )
{
// there's some ammo of this type.
pPlayer->GiveAmmo( m_rgAmmo[ i ], (char *)STRING( m_rgiszAmmo[ i ] ), MaxAmmoCarry( m_rgiszAmmo[ i ] ) );
//ALERT ( at_console, "Gave %d rounds of %s\n", m_rgAmmo[i], STRING(m_rgiszAmmo[i]) );
// now empty the ammo from the weaponbox since we just gave it to the player
m_rgiszAmmo[ i ] = iStringNull;
m_rgAmmo[ i ] = 0;
}
}
// go through my weapons and try to give the usable ones to the player.
// it's important the the player be given ammo first, so the weapons code doesn't refuse
// to deploy a better weapon that the player may pick up because he has no ammo for it.
for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ )
{
if ( m_rgpPlayerItems[ i ] )
{
CBasePlayerItem *pItem;
// have at least one weapon in this slot
while ( m_rgpPlayerItems[ i ] )
{
//ALERT ( at_console, "trying to give %s\n", STRING( m_rgpPlayerItems[ i ]->pev->classname ) );
pItem = m_rgpPlayerItems[ i ];
m_rgpPlayerItems[ i ] = m_rgpPlayerItems[ i ]->m_pNext;// unlink this weapon from the box
if ( pPlayer->AddPlayerItem( pItem ) )
{
pItem->AttachToPlayer( pPlayer );
}
}
}
}
EMIT_SOUND( pOther->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM );
SetTouch(NULL);
UTIL_Remove(this);
}
示例2: DyingThink
//.........這裏部分代碼省略.........
MESSAGE_BEGIN( MSG_BROADCAST, gmsgTempEntity );
WRITE_BYTE( TE_EXPLOSION); // This just makes a dynamic light now
WRITE_COORD( vecSpot.x );
WRITE_COORD( vecSpot.y );
WRITE_COORD( vecSpot.z + 512 );
WRITE_SHORT( m_iExplode );
WRITE_BYTE( 250 ); // scale * 10
WRITE_BYTE( 10 ); // framerate
MESSAGE_END();
*/
// gibs
MESSAGE_BEGIN( MSG_PVS, gmsgTempEntity, vecSpot );
WRITE_BYTE( TE_SPRITE );
WRITE_COORD( vecSpot.x );
WRITE_COORD( vecSpot.y );
WRITE_COORD( vecSpot.z + 512 );
WRITE_SHORT( m_iExplode );
WRITE_BYTE( 250 ); // scale * 10
WRITE_BYTE( 255 ); // brightness
MESSAGE_END();
/*
MESSAGE_BEGIN( MSG_BROADCAST, gmsgTempEntity );
WRITE_BYTE( TE_SMOKE );
WRITE_COORD( vecSpot.x );
WRITE_COORD( vecSpot.y );
WRITE_COORD( vecSpot.z + 300 );
WRITE_SHORT( g_sModelIndexSmoke );
WRITE_BYTE( 250 ); // scale * 10
WRITE_BYTE( 6 ); // framerate
MESSAGE_END();
*/
// blast circle
MESSAGE_BEGIN( MSG_PAS, gmsgTempEntity, pev->origin );
WRITE_BYTE( TE_BEAMCYLINDER );
WRITE_COORD( pev->origin.x);
WRITE_COORD( pev->origin.y);
WRITE_COORD( pev->origin.z);
WRITE_COORD( pev->origin.x);
WRITE_COORD( pev->origin.y);
WRITE_COORD( pev->origin.z + 2000 ); // reach damage radius over .2 seconds
WRITE_SHORT( m_iSpriteTexture );
WRITE_BYTE( 0 ); // startframe
WRITE_BYTE( 0 ); // framerate
WRITE_BYTE( 4 ); // life
WRITE_BYTE( 32 ); // width
WRITE_BYTE( 0 ); // noise
WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 192 ); // r, g, b
WRITE_BYTE( 128 ); // brightness
WRITE_BYTE( 0 ); // speed
MESSAGE_END();
EMIT_SOUND(ENT(pev), CHAN_STATIC, "weapons/mortarhit.wav", 1.0, 0.3);
RadiusDamage( pev->origin, pev, pev, 300, CLASS_NONE, DMG_BLAST );
// gibs
vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5;
MESSAGE_BEGIN( MSG_PAS, gmsgTempEntity, vecSpot );
WRITE_BYTE( TE_BREAKMODEL);
// position
WRITE_COORD( vecSpot.x );
WRITE_COORD( vecSpot.y );
WRITE_COORD( vecSpot.z + 64);
// size
WRITE_COORD( 800 );
WRITE_COORD( 800 );
WRITE_COORD( 128 );
// velocity
WRITE_COORD( m_velocity.x );
WRITE_COORD( m_velocity.y );
WRITE_COORD( fabs( m_velocity.z ) * 0.25 );
// randomization
WRITE_BYTE( 40 );
// Model
WRITE_SHORT( m_iBodyGibs ); //model id#
// # of shards
WRITE_BYTE( 128 );
// duration
WRITE_BYTE( 200 );// 10.0 seconds
// flags
WRITE_BYTE( BREAK_METAL );
MESSAGE_END();
UTIL_Remove( this );
}
}
示例3: EMIT_SOUND_DYN
void CGauss::SecondaryAttack()
{
// don't fire underwater
if ( m_pPlayer->pev->waterlevel == 3 )
{
if ( m_fInAttack != 0 )
{
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG(0,0x3f));
SendWeaponAnim( GAUSS_IDLE );
m_fInAttack = 0;
}
else
{
PlayEmptySound( );
}
m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay(0.5);
return;
}
if ( m_fInAttack == 0 )
{
if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
{
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM);
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
return;
}
m_fPrimaryFire = FALSE;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;// take one ammo just to start the spin
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase();
// spin up
m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME;
SendWeaponAnim( GAUSS_SPINUP );
m_fInAttack = 1;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5;
m_pPlayer->m_flStartCharge = gpGlobals->time;
m_pPlayer->m_flAmmoStartCharge = UTIL_WeaponTimeBase() + GetFullChargeTime();
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0 );
m_iSoundState = SND_CHANGE_PITCH;
}
else if (m_fInAttack == 1)
{
if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase())
{
SendWeaponAnim( GAUSS_SPIN );
m_fInAttack = 2;
}
}
else
{
// during the charging process, eat one bit of ammo every once in a while
if ( UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000 )
{
#ifdef CLIENT_DLL
if ( bIsMultiplayer() )
#else
if ( g_pGameRules->IsMultiplayer() )
#endif
{
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.1;
}
else
{
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3;
}
}
if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
{
// out of ammo! force the gun to fire
StartFire();
m_fInAttack = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1;
return;
}
if ( UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge )
{
// don't eat any more ammo after gun is fully charged.
m_pPlayer->m_flNextAmmoBurn = 1000;
}
int pitch = ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100;
if ( pitch > 250 )
pitch = 250;
// ALERT( at_console, "%d %d %d\n", m_fInAttack, m_iSoundState, pitch );
if ( m_iSoundState == 0 )
ALERT( at_console, "sound state %d\n", m_iSoundState );
//.........這裏部分代碼省略.........
示例4: switch
BOOL CItemWeapon::MyTouch( CBasePlayer *pPlayer )
{
BOOL bLeaveWeapon = FALSE;
if (gpGlobals->deathmatch == 2 || gpGlobals->deathmatch == 3 || gpGlobals->deathmatch == 5 || CVAR_GET_FLOAT("mp_weaponstay") > 0 )
bLeaveWeapon = TRUE;
// Leave the weapon if the player's already got it
if ( bLeaveWeapon && (pPlayer->m_iQuakeItems & m_iWeapon) )
return FALSE;
if ( pPlayer->pev->health <= 0)
return FALSE;
// Give the player some ammo
switch (m_iWeapon)
{
case IT_NAILGUN:
pPlayer->m_iAmmoNails += 30;
break;
case IT_SUPER_NAILGUN:
pPlayer->m_iAmmoNails += 30;
break;
case IT_SUPER_SHOTGUN:
pPlayer->m_iAmmoShells += 5;
break;
case IT_ROCKET_LAUNCHER:
pPlayer->m_iAmmoRockets += 5;
break;
case IT_GRENADE_LAUNCHER:
pPlayer->m_iAmmoRockets += 5;
break;
case IT_LIGHTNING:
pPlayer->m_iAmmoCells += 15;
break;
default:
break;
}
pPlayer->CheckAmmo();
EMIT_SOUND( ENT(pev), CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM );
// Change to new weapon?
int iOldItems = pPlayer->m_iQuakeWeapon;
pPlayer->m_iQuakeItems |= m_iWeapon;
pPlayer->Deathmatch_Weapon(iOldItems, m_iWeapon);
// Update HUD
pPlayer->W_SetCurrentAmmo();
pPlayer->m_iClientQuakeWeapon = -1;
pPlayer->m_fWeapon = FALSE;
pPlayer->m_fKnownItem = FALSE;
pPlayer->UpdateClientData();
if (bLeaveWeapon)
return FALSE;
// Respawn
m_flRespawnTime = 30;
return TRUE;
}
示例5: vector
void CMP5::MP5FireSilenced( float flSpread , float flCycleTime, BOOL fUseAutoAim, BOOL Silenced )
{
if ( m_fDefaultAnim == SILENCER_ON_SEMI )
{
if (!(m_pPlayer->m_afButtonPressed & IN_ATTACK))
return;
}
// Aiming Mechanics
float targetx=0.312; // these are the numbers we will use for the aiming vector (X Y Z)
float targety=0.312; // these are the numbers the will be loward accordingly to adjust the aim
float targetz=0.312;
// Aiming Mechanics
if (m_iClip <= 0)
{
if (m_fFireOnEmpty)
{
//PlayEmptySound();//for some reason, doesn't work
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM);
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2;
}
return;
}
m_iClip--;
//m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
int flags;
#if defined( CLIENT_WEAPONS )
flags = FEV_NOTHOST;
#else
flags = 0;
#endif
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH;
Vector vecSrc = m_pPlayer->GetGunPosition( );
Vector vecAiming;
if ( fUseAutoAim )
{
vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
}
else
{
vecAiming = gpGlobals->v_forward;
}
// Aiming Mechanics
if(!(m_pPlayer->pev->button & (IN_FORWARD|IN_BACK))) //test to see if you are moving forward or back
{
targetx-=0.090; //if you are not moving forward or back then we lower these numbers
targety-=0.132;
targetz-=0.090;
}
else
{
targetx-=0.058; //if you are moving forward or back then we lower these numbers
targety-=0.018; //notice the diffrence in the values from the code above
targetz-=0.058;
}
if(!(m_pPlayer->pev->button & (IN_MOVELEFT|IN_MOVERIGHT))) //test to see if you are moving left or right
{
targetx-=0.132; //do not mistake the above test for looking left or right this test is for straifing not turning
targety-=0.090; // these values are almost the same as the above only we alter the x more then y and z
targetz-=0.090;
}
else
{
targetx-=0.018;
targety-=0.058;
targetz-=0.058;
}
if((m_pPlayer->pev->button & (IN_DUCK))) //this test checks if you are crouched
{
targetx-=0.090; //the values here are only slightly diffrent from the above here we alter the z more then anything
targety-=0.090;
targetz-=0.132;
}
else
{
targetx-=0.020;
targety-=0.020;
targetz-=0.020;
}
// Aiming Mechanics
Vector vecDir;
//vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, Vector( targetx, targety, targetz ), 8192, BULLET_PLAYER_UZI, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
// ### COD RECOIL START ###
if ( m_pPlayer->pev->velocity.Length2D() <= 120 )
{
//.........這裏部分代碼省略.........
示例6: ClientPrint
/* <2464e8> ../cstrike/dlls/wpn_shared/wpn_c4.cpp:152 */
void CC4::__MAKE_VHOOK(PrimaryAttack)(void)
{
BOOL PlaceBomb;
int inBombZone, onGround;
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
{
return;
}
inBombZone = (m_pPlayer->m_signals.GetState() & SIGNAL_BOMB) == SIGNAL_BOMB;
onGround = (m_pPlayer->pev->flags & FL_ONGROUND) == FL_ONGROUND;
PlaceBomb = (onGround && inBombZone);
if (!m_bStartedArming)
{
if (!inBombZone)
{
ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_At_Bomb_Spot");
m_flNextPrimaryAttack = GetNextAttackDelay(1.0);
return;
}
if (!onGround)
{
ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground");
m_flNextPrimaryAttack = GetNextAttackDelay(1);
return;
}
m_bStartedArming = true;
m_bBombPlacedAnimation = false;
m_fArmedTime = gpGlobals->time + C4_ARMING_ON_TIME;
SendWeaponAnim(C4_ARM, UseDecrement() != FALSE);
SET_CLIENT_MAXSPEED(m_pPlayer->edict(), 1.0);
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
m_pPlayer->SetProgressBarTime(C4_ARMING_ON_TIME);
}
else
{
if (PlaceBomb)
{
CBaseEntity *pEntity = NULL;
CBasePlayer *pTempPlayer = NULL;
if (m_fArmedTime <= gpGlobals->time)
{
if (m_bStartedArming)
{
m_bStartedArming = false;
m_fArmedTime = 0;
Broadcast("BOMBPL");
m_pPlayer->m_bHasC4 = false;
if (pev->speed != 0 && g_pGameRules != NULL)
{
g_pGameRules->m_iC4Timer = (int)pev->speed;
}
CGrenade *pBomb = CGrenade::ShootSatchelCharge(m_pPlayer->pev, m_pPlayer->pev->origin, Vector(0, 0, 0));
MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR);
WRITE_BYTE(9);
WRITE_BYTE(DRC_CMD_EVENT);
WRITE_SHORT(m_pPlayer->entindex());
WRITE_SHORT(0);
WRITE_LONG(DRC_FLAG_FACEPLAYER | 11);
MESSAGE_END();
MESSAGE_BEGIN(MSG_ALL, gmsgBombDrop);
WRITE_COORD(pBomb->pev->origin.x);
WRITE_COORD(pBomb->pev->origin.y);
WRITE_COORD(pBomb->pev->origin.z);
WRITE_BYTE(1);
MESSAGE_END();
UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Bomb_Planted");
TheBots->OnEvent(EVENT_BOMB_PLANTED, m_pPlayer, pBomb);
if (g_pGameRules->IsCareer() && !m_pPlayer->IsBot())
{
TheCareerTasks->HandleEvent(EVENT_BOMB_PLANTED, m_pPlayer);
}
UTIL_LogPrintf
(
"\"%s<%i><%s><TERRORIST>\" triggered \"Planted_The_Bomb\"\n",
STRING(m_pPlayer->pev->netname),
GETPLAYERUSERID(m_pPlayer->edict()),
GETPLAYERAUTHID(m_pPlayer->edict())
);
g_pGameRules->m_bBombDropped = FALSE;
EMIT_SOUND(edict(), CHAN_WEAPON, "weapons/c4_plant.wav", VOL_NORM, ATTN_NORM);
//.........這裏部分代碼省略.........
示例7: EMIT_SOUND
// Powerup Touch
BOOL CItemPowerup::MyTouch( CBasePlayer *pPlayer )
{
if (pPlayer->pev->health <= 0)
return FALSE;
EMIT_SOUND( ENT(pev), CHAN_ITEM, STRING(pev->noise), 1, ATTN_NORM );
pPlayer->m_iQuakeItems |= m_iPowerupBit;
int iPowerUp = 0;
// Invincibility
if (invincible_finished)
{
// Make them glow red
if ( pPlayer->m_iQuakeItems & IT_QUAD )
{
pPlayer->pev->renderfx = kRenderFxGlowShell;
pPlayer->pev->rendercolor = Vector( 255, 125, 255 ); // RGB
pPlayer->pev->renderamt = 100; // Shell size
iPowerUp = 3;
}
else
{
pPlayer->pev->renderfx = kRenderFxGlowShell;
pPlayer->pev->rendercolor = Vector( 255, 128, 0 ); // RGB
pPlayer->pev->renderamt = 100; // Shell size
iPowerUp = 2;
}
if ( pPlayer->m_iQuakeItems & IT_INVISIBILITY )
{
pPlayer->pev->rendermode = kRenderTransColor;
pPlayer->pev->renderamt = 1;
}
pPlayer->m_flInvincibleFinished = gpGlobals->time + invincible_finished;
}
// Quad Damage
if (super_damage_finished)
{
// Make them glow blue
if ( pPlayer->m_iQuakeItems & IT_INVULNERABILITY )
{
pPlayer->pev->renderfx = kRenderFxGlowShell;
pPlayer->pev->rendercolor = Vector( 255, 125, 255 ); // RGB
pPlayer->pev->renderamt = 100; // Shell size
iPowerUp = 3;
}
else
{
pPlayer->pev->renderfx = kRenderFxGlowShell;
pPlayer->pev->rendercolor = Vector( 128, 128, 255 ); // RGB
pPlayer->pev->renderamt = 100; // Shell size
iPowerUp = 1;
}
if ( pPlayer->m_iQuakeItems & IT_INVISIBILITY )
{
pPlayer->pev->rendermode = kRenderTransColor;
pPlayer->pev->renderamt = 1;
}
pPlayer->m_flSuperDamageFinished = gpGlobals->time + super_damage_finished;
// Remove armor and cells if DM==4
if (gpGlobals->deathmatch == 4)
{
pPlayer->pev->armortype = 0;
pPlayer->pev->armorvalue = 0;
pPlayer->m_iAmmoCells = 0;
}
}
// Radiation suit
if (radsuit_finished)
pPlayer->m_flRadsuitFinished = gpGlobals->time + radsuit_finished;
// Invisibility
if (invisible_finished)
{
pPlayer->m_flInvisibleFinished = gpGlobals->time + invisible_finished;
pPlayer->pev->renderfx = kRenderFxGlowShell;
pPlayer->pev->rendercolor = Vector( 128, 128, 128 ); // RGB
pPlayer->pev->renderamt = 5; // Shell size
}
// tell director about it
MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR );
//.........這裏部分代碼省略.........
示例8: STOP_SOUND
void CMomentaryDoor::MomentaryMoveDone( void )
{
STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving));
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseArrived), 1, ATTN_NORM);
}
示例9: Think
//
// cycler think
//
void CCycler :: Think( void )
{
pev->nextthink = gpGlobals->time + 0.1;
CBaseEntity *pPlayer = UTIL_PlayerByIndex( 1 );
if ( FClassnameIs ( pev, "info_commentary" ) )
{
int iAllowCommentary = CVAR_GET_FLOAT( "commentary" );
if (iAllowCommentary >= 1)
{
// if ( pPlayer )//only if we have a player, jo jo
// pPlayer->g_bGodMode = TRUE;
}
else
{
// if ( pPlayer )//only if we have a player, jo jo
// pPlayer->g_bGodMode = FALSE;
//stop previous sound
if (pev->message)
EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/null.wav", 0.1, ATTN_NORM );
UTIL_Remove( this );
}
if ( pPlayer )//only if we have a player, jo jo
if ( pPlayer->g_bPlayerPointCommentary == TRUE)
{
if (pev->skin == 1)
pev->framerate = 2.0;
else
pev->framerate = 1.0;
// ALERT(at_console, "g_bPlayerPointCommentary == TRUE\n");
}
else
{
pev->animtime = gpGlobals->time;
pev->framerate = 0.0;
m_fSequenceFinished = FALSE;
// ALERT(at_console, "g_bPlayerPointCommentary == FALSE\n");
}
}
else
{
if (m_animate)
{
StudioFrameAdvance ( );
}
if (m_fSequenceFinished && !m_fSequenceLoops)
{
// ResetSequenceInfo();
// hack to avoid reloading model every frame
pev->animtime = gpGlobals->time;
pev->framerate = 1.0;
m_fSequenceFinished = FALSE;
m_flLastEventCheck = gpGlobals->time;
pev->frame = 0;
if (!m_animate)
pev->framerate = 0.0; // FIX: don't reset framerate
}
}
}
示例10: MonsterSight
void CSoldier :: MonsterSight( void )
{
EMIT_SOUND( edict(), CHAN_VOICE, "soldier/sight1.wav", 1.0, ATTN_NORM );
}
示例11: PlayLockSounds
void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton)
{
// LOCKED SOUND
// CONSIDER: consolidate the locksound_t struct (all entries are duplicates for lock/unlock)
// CONSIDER: and condense this code.
float flsoundwait;
if (fbutton)
flsoundwait = BUTTON_SOUNDWAIT;
else
flsoundwait = DOOR_SOUNDWAIT;
if (flocked)
{
int fplaysound = (pls->sLockedSound && gpGlobals->time > pls->flwaitSound);
int fplaysentence = (pls->sLockedSentence && !pls->bEOFLocked && gpGlobals->time > pls->flwaitSentence);
float fvol;
if (fplaysound && fplaysentence)
fvol = 0.25;
else
fvol = 1.0;
// if there is a locked sound, and we've debounced, play sound
if (fplaysound)
{
// play 'door locked' sound
EMIT_SOUND(ENT(pev), CHAN_ITEM, (char*)STRING(pls->sLockedSound), fvol, ATTN_NORM);
pls->flwaitSound = gpGlobals->time + flsoundwait;
}
// if there is a sentence, we've not played all in list, and we've debounced, play sound
if (fplaysentence)
{
// play next 'door locked' sentence in group
int iprev = pls->iLockedSentence;
pls->iLockedSentence = SENTENCEG_PlaySequentialSz(ENT(pev), STRING(pls->sLockedSentence),
0.85, ATTN_NORM, 0, 100, pls->iLockedSentence, FALSE);
pls->iUnlockedSentence = 0;
// make sure we don't keep calling last sentence in list
pls->bEOFLocked = (iprev == pls->iLockedSentence);
pls->flwaitSentence = gpGlobals->time + DOOR_SENTENCEWAIT;
}
}
else
{
// UNLOCKED SOUND
int fplaysound = (pls->sUnlockedSound && gpGlobals->time > pls->flwaitSound);
int fplaysentence = (pls->sUnlockedSentence && !pls->bEOFUnlocked && gpGlobals->time > pls->flwaitSentence);
float fvol;
// if playing both sentence and sound, lower sound volume so we hear sentence
if (fplaysound && fplaysentence)
fvol = 0.25;
else
fvol = 1.0;
// play 'door unlocked' sound if set
if (fplaysound)
{
EMIT_SOUND(ENT(pev), CHAN_ITEM, (char*)STRING(pls->sUnlockedSound), fvol, ATTN_NORM);
pls->flwaitSound = gpGlobals->time + flsoundwait;
}
// play next 'door unlocked' sentence in group
if (fplaysentence)
{
int iprev = pls->iUnlockedSentence;
pls->iUnlockedSentence = SENTENCEG_PlaySequentialSz(ENT(pev), STRING(pls->sUnlockedSentence),
0.85, ATTN_NORM, 0, 100, pls->iUnlockedSentence, FALSE);
pls->iLockedSentence = 0;
// make sure we don't keep calling last sentence in list
pls->bEOFUnlocked = (iprev == pls->iUnlockedSentence);
pls->flwaitSentence = gpGlobals->time + DOOR_SENTENCEWAIT;
}
}
}
示例12: FireGun
BOOL CApache :: FireGun( )
{
UTIL_MakeAimVectors( pev->angles );
Vector posGun, angGun;
GetAttachment( 1, posGun, angGun );
Vector vecTarget = (m_posTarget - posGun).Normalize( );
Vector vecOut;
vecOut.x = DotProduct( gpGlobals->v_forward, vecTarget );
vecOut.y = -DotProduct( gpGlobals->v_right, vecTarget );
vecOut.z = DotProduct( gpGlobals->v_up, vecTarget );
Vector angles = UTIL_VecToAngles (vecOut);
angles.x = -angles.x;
if (angles.y > 180)
angles.y = angles.y - 360;
if (angles.y < -180)
angles.y = angles.y + 360;
if (angles.x > 180)
angles.x = angles.x - 360;
if (angles.x < -180)
angles.x = angles.x + 360;
if (angles.x > m_angGun.x)
m_angGun.x = min( angles.x, m_angGun.x + 12 );
if (angles.x < m_angGun.x)
m_angGun.x = max( angles.x, m_angGun.x - 12 );
if (angles.y > m_angGun.y)
m_angGun.y = min( angles.y, m_angGun.y + 12 );
if (angles.y < m_angGun.y)
m_angGun.y = max( angles.y, m_angGun.y - 12 );
m_angGun.y = SetBoneController( 0, m_angGun.y );
m_angGun.x = SetBoneController( 1, m_angGun.x );
Vector posBarrel, angBarrel;
GetAttachment( 0, posBarrel, angBarrel );
Vector vecGun = (posBarrel - posGun).Normalize( );
if (DotProduct( vecGun, vecTarget ) > 0.98)
{
#if 1
FireBullets( 1, posGun, vecGun, VECTOR_CONE_4DEGREES, 8192, BULLET_MONSTER_12MM, 1 );
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "turret/tu_fire1.wav", 1, 0.3);
#else
static float flNext;
TraceResult tr;
UTIL_TraceLine( posGun, posGun + vecGun * 8192, dont_ignore_monsters, ENT( pev ), &tr );
if (!m_pBeam)
{
m_pBeam = CBeam::BeamCreate( "sprites/lgtning.spr", 80 );
m_pBeam->PointEntInit( pev->origin, entindex( ) );
m_pBeam->SetEndAttachment( 1 );
m_pBeam->SetColor( 255, 180, 96 );
m_pBeam->SetBrightness( 192 );
}
if (flNext < gpGlobals->time)
{
flNext = gpGlobals->time + 0.5;
m_pBeam->SetStartPos( tr.vecEndPos );
}
#endif
return TRUE;
}
else
{
if (m_pBeam)
{
UTIL_Remove( m_pBeam );
m_pBeam = NULL;
}
}
return FALSE;
}
示例13: DyingThink
//.........這裏部分代碼省略.........
// fireball
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot );
WRITE_BYTE( TE_SPRITE );
WRITE_COORD( vecSpot.x );
WRITE_COORD( vecSpot.y );
WRITE_COORD( vecSpot.z + 256 );
WRITE_SHORT( m_iExplode );
WRITE_BYTE( 120 ); // scale * 10
WRITE_BYTE( 255 ); // brightness
MESSAGE_END();
// big smoke
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot );
WRITE_BYTE( TE_SMOKE );
WRITE_COORD( vecSpot.x );
WRITE_COORD( vecSpot.y );
WRITE_COORD( vecSpot.z + 512 );
WRITE_SHORT( g_sModelIndexSmoke );
WRITE_BYTE( 250 ); // scale * 10
WRITE_BYTE( 5 ); // framerate
MESSAGE_END();
// blast circle
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_BEAMCYLINDER );
WRITE_COORD( pev->origin.x);
WRITE_COORD( pev->origin.y);
WRITE_COORD( pev->origin.z);
WRITE_COORD( pev->origin.x);
WRITE_COORD( pev->origin.y);
WRITE_COORD( pev->origin.z + 2000 ); // reach damage radius over .2 seconds
WRITE_SHORT( m_iSpriteTexture );
WRITE_BYTE( 0 ); // startframe
WRITE_BYTE( 0 ); // framerate
WRITE_BYTE( 4 ); // life
WRITE_BYTE( 32 ); // width
WRITE_BYTE( 0 ); // noise
WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 192 ); // r, g, b
WRITE_BYTE( 128 ); // brightness
WRITE_BYTE( 0 ); // speed
MESSAGE_END();
EMIT_SOUND(ENT(pev), CHAN_STATIC, "weapons/mortarhit.wav", 1.0, 0.3);
RadiusDamage( pev->origin, pev, pev, 300, CLASS_NONE, DMG_BLAST );
if (/*!(pev->spawnflags & SF_NOWRECKAGE) && */(pev->flags & FL_ONGROUND))
{
CBaseEntity *pWreckage = Create( "cycler_wreckage", pev->origin, pev->angles );
// SET_MODEL( ENT(pWreckage->pev), STRING(pev->model) );
UTIL_SetSize( pWreckage->pev, Vector( -200, -200, -128 ), Vector( 200, 200, -32 ) );
pWreckage->pev->frame = pev->frame;
pWreckage->pev->sequence = pev->sequence;
pWreckage->pev->framerate = 0;
pWreckage->pev->dmgtime = gpGlobals->time + 5;
}
// gibs
vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5;
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot );
WRITE_BYTE( TE_BREAKMODEL);
// position
WRITE_COORD( vecSpot.x );
WRITE_COORD( vecSpot.y );
WRITE_COORD( vecSpot.z + 64);
// size
WRITE_COORD( 400 );
WRITE_COORD( 400 );
WRITE_COORD( 128 );
// velocity
WRITE_COORD( 0 );
WRITE_COORD( 0 );
WRITE_COORD( 200 );
// randomization
WRITE_BYTE( 30 );
// Model
WRITE_SHORT( m_iBodyGibs ); //model id#
// # of shards
WRITE_BYTE( 200 );
// duration
WRITE_BYTE( 200 );// 10.0 seconds
// flags
WRITE_BYTE( BREAK_METAL );
MESSAGE_END();
SetThink(&CApache :: SUB_Remove );
SetNextThink( 0.1 );
}
}
示例14: while
//.........這裏部分代碼省略.........
}
if (!hostages_)
{
++m_eventsSeen;
SendPartialNotification();
}
}
else if (!Q_strcmp(m_name, "winfast"))
{
if (m_eventsNeeded >= TheCareerTasks->GetRoundElapsedTime())
{
m_eventsSeen = m_eventsNeeded;
SendPartialNotification();
}
}
else if (IsTaskCompletableThisRound())
{
++m_eventsSeen;
SendPartialNotification();
}
}
else
{
++m_eventsSeen;
SendPartialNotification();
}
}
}
if (event == m_event && !m_mustLive && m_eventsSeen >= m_eventsNeeded && IsTaskCompletableThisRound())
{
CBasePlayer *player = UTIL_GetLocalPlayer();
EMIT_SOUND(ENT(player->pev), CHAN_VOICE, "events/task_complete.wav", VOL_NORM, ATTN_NORM);
m_isComplete = true;
MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer);
WRITE_STRING("TASKDONE");
WRITE_BYTE(m_id);
MESSAGE_END();
if (TheTutor)
{
TheTutor->OnEvent(EVENT_CAREER_TASK_DONE);
}
UTIL_LogPrintf("Career Task Done %d\n", m_id);
if (m_event == EVENT_ROUND_WIN && !Q_strcmp(m_name, "winfast"))
{
TheCareerTasks->SetFinishedTaskTime((int)TheCareerTasks->GetRoundElapsedTime());
UTIL_GetLocalPlayer()->SyncRoundTimer();
}
}
else if (event >= EVENT_ROUND_DRAW)
{
if (event > EVENT_ROUND_LOSS)
{
if (event == EVENT_DIE && (m_mustLive || m_crossRounds))
{
m_eventsSeen = 0;
SendPartialNotification();
m_diedThisRound = true;
}
}
else if (m_mustLive)
示例15: UTIL_MakeVectors
int CAK74::Swing( int fFirst )
{
int fDidHit = FALSE;
TraceResult tr;
UTIL_MakeVectors (m_pPlayer->pev->v_angle);
Vector vecSrc = m_pPlayer->GetGunPosition( );
Vector vecEnd = vecSrc + gpGlobals->v_forward * 32;
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr );
#ifndef CLIENT_DLL
if ( tr.flFraction >= 1.0 )
{
UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr );
if ( tr.flFraction < 1.0 )
{
// Calculate the point of intersection of the line (or hull) and the object we hit
// This is and approximation of the "best" intersection
CBaseEntity *pHit = CBaseEntity::Instance( tr.pHit );
if ( !pHit || pHit->IsBSPModel() )
FindHullIntersection_AK( vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict() );
vecEnd = tr.vecEndPos; // This is the point on the actual surface (the hull could have hit space)
}
}
#endif
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usAk_stab,
0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0,
0.0, 0, 0.0 );
if ( tr.flFraction >= 1.0 )
{
if (fFirst)
{
// miss
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.5;//0.5
// player "shoot" animation
//m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
}
}
else
{
switch( ((m_iSwing++) % 2) + 1 )// + 1
{
case 0:
SendWeaponAnim( AK_NMC_STAB ); break;
case 1:
SendWeaponAnim( AK_NMC_STAB ); break;
case 2:
SendWeaponAnim( AK_NMC_STAB ); break;
}
// player "shoot" animation
// m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); // Naaaa
#ifndef CLIENT_DLL
// hit
fDidHit = TRUE;
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
ClearMultiDamage( );
if ( (m_flNextSecondaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() )
{
// first swing does full damage
pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgKnifeStab, gpGlobals->v_forward, &tr, DMG_CLUB | DMG_NEVERGIB ); //DMG_CLUB );
}
else
{
// subsequent swings do half
pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgKnifeStab /*/ 2*/, gpGlobals->v_forward, &tr, DMG_CLUB | DMG_NEVERGIB ); //DMG_CLUB );
}
ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev );
// play thwack, smack, or dong sound
float flVol = 1.0;
int fHitWorld = TRUE;
if (pEntity)
{
if ( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE )
{
// play thwack or smack sound
switch( RANDOM_LONG(0,2) )
{
case 0:
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/ak-47/AK47_stab_hit-1.wav", 1, ATTN_NORM); break;
case 1:
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/ak-47/AK47_stab_hit-2.wav", 1, ATTN_NORM); break;
case 2:
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/ak-47/AK47_stab_hit-1.wav", 1, ATTN_NORM); break;
}
m_pPlayer->m_iWeaponVolume = CROWBAR_BODYHIT_VOLUME;
if ( !pEntity->IsAlive() )
return TRUE;
//.........這裏部分代碼省略.........