本文整理汇总了C++中SUB_UseTargets函数的典型用法代码示例。如果您正苦于以下问题:C++ SUB_UseTargets函数的具体用法?C++ SUB_UseTargets怎么用?C++ SUB_UseTargets使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SUB_UseTargets函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
//
// Starts the door going to its "up" position (simply ToggleData->vecPosition2).
//
void CBaseDoor::DoorGoUp( void )
{
entvars_t *pevActivator;
// It could be going-down, if blocked.
ASSERT(m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN);
// emit door moving and stop sounds on CHAN_STATIC so that the multicast doesn't
// filter them out and leave a client stuck with looping door sounds!
if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving), 1, ATTN_NORM);
// ALERT(at_debug, "%s go up (was %d)\n", STRING(pev->targetname), m_toggle_state);
m_toggle_state = TS_GOING_UP;
SetMoveDone(&CBaseDoor:: DoorHitTop );
// LRC- if synched, we fire as soon as we start to go up
if (m_iImmediateMode)
{
if (m_iOnOffMode)
SUB_UseTargets( m_hActivator, USE_ON, 0 );
else
SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 );
}
if ( FClassnameIs(pev, "func_door_rotating")) // !!! BUGBUG Triggered doors don't work with this yet
{
float sign = 1.0;
if ( m_hActivator != NULL )
{
pevActivator = m_hActivator->pev;
if ( !FBitSet( pev->spawnflags, SF_DOOR_ONEWAY ) && pev->movedir.y ) // Y axis rotation, move away from the player
{
Vector vec = pevActivator->origin - pev->origin;
Vector angles = pevActivator->angles;
angles.x = 0;
angles.z = 0;
UTIL_MakeVectors (angles);
// Vector vnext = (pevToucher->origin + (pevToucher->velocity * 10)) - pev->origin;
UTIL_MakeVectors ( pevActivator->angles );
Vector vnext = (pevActivator->origin + (gpGlobals->v_forward * 10)) - pev->origin;
if ( (vec.x*vnext.y - vec.y*vnext.x) < 0 )
sign = -1.0;
}
}
AngularMove(m_vecAngle2*sign, pev->speed);
}
else
if(m_iSpeedMode==1){ //AJH modifed to allow two types of accelerating doors
LinearMove(m_vecPosition2, pev->speed);
}else{
LinearMove(m_vecPosition2, pev->speed, m_fAcceleration, m_fDeceleration); }
}
示例2: SUB_UseTargets
void CButtonTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( !ShouldToggle( useType, (int)pev->frame ) )
return;
pev->frame = 1-pev->frame;
if ( pev->frame )
SUB_UseTargets( pActivator, USE_ON, 0 );
else
SUB_UseTargets( pActivator, USE_OFF, 0 );
}
示例3: STOP_SOUND
//
// The door has reached the "down" position. Back to quiescence.
//
void CBaseDoor::DoorHitBottom( void )
{
if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
{
STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving) );
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseArrived), 1, ATTN_NORM);
}
// ALERT(at_debug, "%s hit bottom\n", STRING(pev->targetname));
ASSERT(m_toggle_state == TS_GOING_DOWN);
m_toggle_state = TS_AT_BOTTOM;
// Re-instate touch method, cycle is complete
if ( FBitSet ( pev->spawnflags, SF_DOOR_USE_ONLY ) &&
!FBitSet ( pev->spawnflags, SF_DOOR_FORCETOUCHABLE ) )
{// use only door
SetTouch ( NULL );
}
else // touchable door
SetTouch(&CBaseDoor:: DoorTouch );
// Fire the close target (if startopen is set, then "top" is closed) - netname is the close target
// LRC- 'message' is the open target
if (pev->spawnflags & SF_DOOR_START_OPEN)
{
if (pev->message)
FireTargets( STRING(pev->message), m_hActivator, this, USE_TOGGLE, 0 );
}
else
{
if (pev->netname)
FireTargets( STRING(pev->netname), m_hActivator, this, USE_TOGGLE, 0 );
}
// else
// {
// ALERT(at_console,"didn't fire closetarget because ");
// if (!(pev->netname))
// ALERT(at_console,"no netname\n");
// else if (pev->spawnflags & SF_DOOR_START_OPEN)
// ALERT(at_console,"startopen\n");
// else
// ALERT(at_console,"!!?!\n");
// }
// LRC- if synched, don't fire now
if (!m_iImmediateMode)
{
if (m_iOnOffMode)
SUB_UseTargets( m_hActivator, USE_ON, 0 );
else
SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 );
}
}
示例4: SUB_UseTargets
void CButtonTarget::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
{
if (!ShouldToggle(useType, int(pev->frame)))
return;
pev->frame = 1 - pev->frame;
if (pev->frame)
{
SUB_UseTargets(pActivator, USE_ON, 0);
}
else
SUB_UseTargets(pActivator, USE_OFF, 0);
}
示例5: trigger_onlyregistered_touch
void trigger_onlyregistered_touch( )
{
gedict_t *te;
if ( strneq( other->s.v.classname, "player" ) )
return;
if ( !Activated( self, other ) )
{
if ( self->else_goal )
{
te = Findgoal( self->else_goal );
if ( te )
AttemptToActivate( te, other, self );
}
return;
}
if ( self->attack_finished > g_globalvars.time )
return;
self->attack_finished = g_globalvars.time + 2;
if ( trap_cvar( "registered" ) )
{
self->s.v.message = "";
activator = other;
SUB_UseTargets( );
ent_remove( self );
} else
{
if ( self->s.v.message && strneq( self->s.v.message, "" ) )
{
G_centerprint( other, "%s", self->s.v.message );
sound( other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM );
}
}
}
示例6: SUB_UseTargets
//-----------------------------------------------------------------------------
// Purpose: Touch function that calls the virtual touch function
//-----------------------------------------------------------------------------
void CQuakeItem::ItemTouch( CBaseEntity *pOther )
{
// if it's not a player, ignore
if ( !pOther->IsPlayer() )
return;
//Dead?
if (pOther->pev->health <= 0)
return;
CBasePlayer *pPlayer = (CBasePlayer *)pOther;
// Call the virtual touch function
if ( MyTouch( pPlayer ) )
{
SUB_UseTargets( pOther, USE_TOGGLE, 0 );
// Respawn if it's not DM==2
if (gpGlobals->deathmatch != 2)
{
Respawn( m_flRespawnTime );
}
else
{
UTIL_Remove( this );
}
}
}
示例7: EMIT_SOUND
void CAirtank::TankTouch(CBaseEntity *pOther)
{
if (!pOther->IsPlayer())
{
return;
}
if (!m_state)
{
// "no oxygen" sound
EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim2.wav", VOL_NORM, ATTN_NORM);
return;
}
// give player 12 more seconds of air
pOther->pev->air_finished = gpGlobals->time + 12.0f;
// suit recharge sound
EMIT_SOUND(ENT(pev), CHAN_VOICE, "doors/aliendoor3.wav", VOL_NORM, ATTN_NORM);
// recharge airtank in 30 seconds
pev->nextthink = gpGlobals->time + 30.0f;
m_state = 0;
SUB_UseTargets(this, USE_TOGGLE, 1);
}
示例8: UTIL_ShowMessageAll
void CMessage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
CBaseEntity *pPlayer = NULL;
if ( pev->spawnflags & SF_MESSAGE_ALL )
UTIL_ShowMessageAll( STRING(pev->message) );
else
{
if ( pActivator && pActivator->IsPlayer() )
pPlayer = pActivator;
else
{
pPlayer = CBaseEntity::Instance( g_engfuncs.pfnPEntityOfEntIndex( 1 ) );
}
if ( pPlayer )
UTIL_ShowMessage( STRING(pev->message), pPlayer );
}
if ( pev->noise )
{
EMIT_SOUND( edict(), CHAN_BODY, STRING(pev->noise), pev->scale, pev->speed );
}
if ( pev->spawnflags & SF_MESSAGE_ONCE )
UTIL_Remove( this );
SUB_UseTargets( this, USE_TOGGLE, 0 );
}
示例9: UTIL_Remove
void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther )
{
// if it's not a player, ignore
if ( !pOther->IsPlayer() )
return;
CBasePlayer *pPlayer = (CBasePlayer *)pOther;
// can I have this?
if ( !g_pGameRules->CanHavePlayerItem( pPlayer, this ) )
{
if ( gEvilImpulse101 )
{
UTIL_Remove( this );
}
return;
}
if (pOther->AddPlayerItem( this ))
{
AttachToPlayer( pPlayer );
EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM);
}
SUB_UseTargets( pOther, USE_TOGGLE, 0 ); // UNDONE: when should this happen?
}
示例10: ASSERT
void CBaseButton::TriggerAndWait(void)
{
ASSERT(m_toggle_state == TS_GOING_UP);
if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator))
return;
m_toggle_state = TS_AT_TOP;
if (m_fStayPushed || FBitSet(pev->spawnflags, SF_BUTTON_TOGGLE))
{
if (!FBitSet(pev->spawnflags, SF_BUTTON_TOUCH_ONLY))
SetTouch(NULL);
else
SetTouch(&CBaseButton::ButtonTouch);
}
else
{
pev->nextthink = pev->ltime + m_flWait;
SetThink(&CBaseButton::ButtonReturn);
}
pev->frame = 1;
SUB_UseTargets(m_hActivator, USE_TOGGLE, 0);
}
示例11: ButtonResponseToTouch
void CBaseButton::ButtonTouch(CBaseEntity *pOther)
{
if (!FClassnameIs(pOther->pev, "player"))
return;
m_hActivator = pOther;
BUTTON_CODE code = ButtonResponseToTouch();
if (code == BUTTON_NOTHING)
return;
if (!UTIL_IsMasterTriggered(m_sMaster, pOther))
{
PlayLockSounds(pev, &m_ls, TRUE, TRUE);
return;
}
SetTouch(NULL);
if (code == BUTTON_RETURN)
{
EMIT_SOUND(ENT(pev), CHAN_VOICE, STRING(pev->noise), VOL_NORM, ATTN_NORM);
SUB_UseTargets(m_hActivator, USE_TOGGLE, 0);
ButtonReturn();
}
else
ButtonActivate();
}
示例12: switch
void CGameCounter::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
{
if (!CanFireForActivator(pActivator))
return;
switch (useType)
{
case USE_ON:
case USE_TOGGLE:
CountUp();
break;
case USE_OFF:
CountDown();
break;
case USE_SET:
SetCountValue((int)value);
break;
}
if (HitLimit())
{
SUB_UseTargets(pActivator, USE_TOGGLE, 0);
if (RemoveOnFire())
{
UTIL_Remove(this);
}
if (ResetOnFire())
{
ResetCount();
}
}
}
示例13: TakeDamage
int CBaseButton :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType )
{
if( FBitSet( pev->spawnflags, SF_BUTTON_DAMAGED_AT_LASER ) && !( bitsDamageType & DMG_ENERGYBEAM ))
return 0;
BUTTON_CODE code = ButtonResponseToTouch();
if( code == BUTTON_NOTHING )
return 0;
// temporarily disable the touch function, until movement is finished.
SetTouch( NULL );
m_hActivator = CBaseEntity::Instance( pevAttacker );
if( m_hActivator == NULL )
return 0;
if( code == BUTTON_RETURN )
{
EMIT_SOUND( edict(), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM );
// toggle buttons fire when they get back to their "home" position
if( !FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ))
SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 );
ButtonReturn();
}
else
{
// code == BUTTON_ACTIVATE
ButtonActivate( );
}
return 0;
}
示例14: SUB_UseTargets
void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if( !CanFireForActivator( pActivator ) )
return;
if( useType == USE_SET )
{
if( value < 0 )
{
m_teamIndex = -1;
}
else
{
m_teamIndex = g_pGameRules->GetTeamIndex( pActivator->TeamID() );
}
return;
}
if( TeamMatch( pActivator ) )
{
SUB_UseTargets( pActivator, triggerType, value );
if( RemoveOnFire() )
UTIL_Remove( this );
}
}
示例15: ButtonTouch
void CBaseButton:: ButtonTouch( CBaseEntity *pOther )
{
// ignore touches by anything but players
if( !pOther->IsPlayer( )) return;
m_hActivator = pOther;
BUTTON_CODE code = ButtonResponseToTouch();
if( code == BUTTON_NOTHING ) return;
if( IsLockedByMaster( ))
{
// play button locked sound
PlayLockSounds( pev, &m_ls, TRUE, TRUE );
return;
}
// temporarily disable the touch function, until movement is finished.
SetTouch( NULL );
if( code == BUTTON_RETURN )
{
EMIT_SOUND( edict(), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM );
SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 );
ButtonReturn();
}
else
{
ButtonActivate( );
}
}