本文整理汇总了C++中UTIL_FindEntityByClassname函数的典型用法代码示例。如果您正苦于以下问题:C++ UTIL_FindEntityByClassname函数的具体用法?C++ UTIL_FindEntityByClassname怎么用?C++ UTIL_FindEntityByClassname使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UTIL_FindEntityByClassname函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SpawnNextBase
void CHeadQuartersRules :: SpawnNextBase( void )
{
if( CurrentBase )
CurrentBase->pev->effects |= EF_NODRAW;
CurrentBase = UTIL_FindEntityByClassname( CurrentBase, "func_headq" );
if( !CurrentBase )
CurrentBase = UTIL_FindEntityByClassname( CurrentBase, "func_headq" );
CurrentBase->pev->effects &= ~EF_NODRAW;
SpawnTime = gpGlobals->time;
}
示例2: RemoveAllNodeEntity
void RemoveAllNodeEntity()
{
CEntity *pFoundNode = UTIL_FindEntityByClassname(NULL, "info_node");
if (pFoundNode == NULL)
return; // No node entities
do {
CEntity *pNextNode = UTIL_FindEntityByClassname(pFoundNode, "info_node");
REMOVE_ENTITY(pFoundNode->edict());
pFoundNode = pNextNode;
} while (pFoundNode != NULL);
}
示例3: while
void CHostage::SendHostageEventMsg(void)
{
CBaseEntity *pEntity = NULL;
while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL)
{
if (FNullEnt(pEntity->edict()))
break;
if (!pEntity->IsPlayer())
continue;
if (pEntity->pev->flags == FL_DORMANT)
continue;
CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pEntity->pev);
if (pPlayer->pev->deadflag == DEAD_NO && pPlayer->m_iTeam == TEAM_CT)
{
MESSAGE_BEGIN(MSG_ONE, gmsgHostageK, NULL, pPlayer->pev);
WRITE_BYTE(m_iHostageIndex);
MESSAGE_END();
}
if (pPlayer->pev->deadflag == DEAD_NO)
pPlayer->SendHostageIcons();
}
}
示例4: PlayerSpawn
//=========================================================
//=========================================================
void CHalfLifeMultiplay :: PlayerSpawn( CBasePlayer *pPlayer )
{
BOOL addDefault;
CBaseEntity *pWeaponEntity = NULL;
pPlayer->pev->weapons |= (1<<IT_AXE);
addDefault = TRUE;
while ( pWeaponEntity = UTIL_FindEntityByClassname( pWeaponEntity, "game_player_equip" ))
{
pWeaponEntity->Touch( pPlayer );
addDefault = FALSE;
}
if ( addDefault )
{
// Start with init ammoload
pPlayer->m_iAmmoShells = 25;
// Start with shotgun and axe
pPlayer->GiveNamedItem( "weapon_quakegun" );
pPlayer->m_iQuakeItems |= (IT_SHOTGUN | IT_AXE);
pPlayer->m_iQuakeWeapon = pPlayer->W_BestWeapon();
pPlayer->W_SetCurrentAmmo();
}
}
示例5: Use
void CRadiomsg :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
CBaseEntity *pPlayer = UTIL_FindEntityByClassname ( NULL,"player" );
char txt [256];
sprintf ( txt, STRING(m_iszText));
int len = strlen ( txt );
MESSAGE_BEGIN( MSG_ONE, gmsgRadioMsg, NULL, pPlayer->pev );
WRITE_COORD ( gpGlobals->time );
WRITE_LONG ( m_iHead );
WRITE_LONG ( len );
for ( int i=0; i<180; i++ ) {
WRITE_BYTE ( txt[i] ); }
MESSAGE_END();
if ( FStringNull ( m_iszSentence ) )
return;
// EMIT_SOUND_SUIT(pPlayer->edict(), STRING(m_iszSentence) );
EMIT_SOUND_DYN(pPlayer->edict(), CHAN_STATIC, STRING(m_iszSentence), 1.0, ATTN_NORM, 0, 100);
}
示例6: SetTouch
//-----------------------------------------------------------------------------
// Purpose: Setup the item's respawn in the time set
//-----------------------------------------------------------------------------
void CItem::Respawn( float flTime )
{
pev->effects |= EF_NODRAW;
SetTouch( NULL );
if (!m_flMoneyRandomRespawn)
{
UTIL_SetOrigin( pev, pev->origin );
}
else
{
CBaseEntity *pSpot = NULL;
for ( int i = RANDOM_LONG(1,5); i > 0; i-- )
pSpot = UTIL_FindEntityByClassname( pSpot, "info_money_start" );
if (pSpot)
{
Vector tmp = pSpot->pev->origin;
UTIL_SetOrigin( pev, tmp );
DROP_TO_FLOOR ( ENT(pev) );
}
}
// Come back in time
SetThink ( Materialize );
pev->nextthink = gpGlobals->time + flTime;
}
示例7: SetupVisibility
/*
================
SetupVisibility
A client can have a separate "view entity" indicating that his/her view should depend on the origin of that
view entity. If that's the case, then pViewEntity will be non-NULL and will be used. Otherwise, the current
entity's origin is used. Either is offset by the view_ofs to get the eye position.
From the eye position, we set up the PAS and PVS to use for filtering network messages to the client. At this point, we could
override the actual PAS or PVS values, or use a different origin.
NOTE: Do not cache the values of pas and pvs, as they depend on reusable memory in the engine, they are only good for this one frame
================
*/
void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas )
{
Vector org;
edict_t *pView = pClient;
// Find the client's PVS
if ( pViewEntity )
{
pView = pViewEntity;
}
// modif de Julien
// camera du tank
CBaseEntity *pEnt = CBaseEntity::Instance(pClient);
if ( pEnt->IsPlayer() )
{
CBasePlayer *pPlayer = (CBasePlayer*)pEnt;
if( pPlayer->m_iDrivingTank == TRUE )
{
// origine de la camera et non pas du joueur
pView = UTIL_FindEntityByClassname(NULL, "info_tank_camera" )->edict();
}
}
org = pView->v.origin + pView->v.view_ofs;
if ( pView->v.flags & FL_DUCKING )
{
org = org + ( VEC_HULL_MIN - VEC_DUCK_HULL_MIN );
}
*pvs = ENGINE_SET_PVS ( (float *)&org );
*pas = ENGINE_SET_PAS ( (float *)&org );
}
示例8: while
// Periodic check of hostage count in case we lost some
void CCSBot::UpdateHostageEscortCount()
{
const float updateInterval = 1.0f;
if (m_hostageEscortCount == 0 || gpGlobals->time - m_hostageEscortCountTimestamp < updateInterval)
return;
m_hostageEscortCountTimestamp = gpGlobals->time;
// recount the hostages in case we lost some
m_hostageEscortCount = 0;
CHostage *pHostage = nullptr;
while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
{
if (FNullEnt(pHostage->edict()))
break;
// skip dead or rescued hostages
if (!pHostage->IsAlive())
continue;
// check if hostage has targeted us, and is following
if (pHostage->IsFollowing(this))
m_hostageEscortCount++;
}
}
示例9: while
void CCSBot::UpdateHostageEscortCount()
{
const float updateInterval = 1.0f;
if (m_hostageEscortCount == 0 || gpGlobals->time - m_hostageEscortCountTimestamp < updateInterval)
return;
m_hostageEscortCountTimestamp = gpGlobals->time;
// recount the hostages in case we lost some
m_hostageEscortCount = 0;
CHostage *hostage = NULL;
while ((hostage = static_cast<CHostage *>(UTIL_FindEntityByClassname(hostage, "hostage_entity"))) != NULL)
{
if (FNullEnt(hostage->edict()))
break;
// skip dead or rescued hostages
if (!hostage->IsValid())
continue;
// check if hostage has targeted us, and is following
if (hostage->IsFollowing(this))
++m_hostageEscortCount;
}
}
示例10: EMIT_SOUND
void CC4::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
{
if (m_pPlayer)
return;
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(1);
if (pPlayer)
{
edict_t *target = pPlayer->m_pentCurBombTarget;
pPlayer->m_pentCurBombTarget = NULL;
#ifndef CLIENT_WEAPONS
if (pev->speed != 0 && g_pGameRules)
g_pGameRules->m_iC4Timer = (int)pev->speed;
#endif
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/c4_plant.wav", VOL_NORM, ATTN_NORM);
CGrenade::ShootSatchelCharge(m_pPlayer->pev, m_pPlayer->pev->origin, Vector(0, 0, 0));
CGrenade *pGrenade = NULL;
while ((pGrenade = (CGrenade *)UTIL_FindEntityByClassname(pGrenade, "grenade")) != NULL)
{
if (pGrenade->m_bIsC4 && pGrenade->m_flNextFreq == gpGlobals->time)
{
pGrenade->pev->target = pev->target;
pGrenade->pev->noise1 = pev->noise1;
break;
}
}
pPlayer->m_pentCurBombTarget = target;
SUB_Remove();
}
}
示例11: FriendNumber
edict_t *CMTalkMonster::EnumFriends( edict_t *pPrevious, int listNumber, BOOL bTrace )
{
edict_t *pFriend = pPrevious;
char *pszFriend;
TraceResult tr;
Vector vecCheck;
pszFriend = m_szFriends[ FriendNumber(listNumber) ];
while (pFriend = UTIL_FindEntityByClassname( pFriend, pszFriend ))
{
if (pFriend == this->edict() || !UTIL_IsAlive(pFriend))
// don't talk to self or dead people
continue;
if ( bTrace )
{
vecCheck = pFriend->v.origin;
vecCheck.z = pFriend->v.absmax.z;
UTIL_TraceLine( pev->origin, vecCheck, ignore_monsters, ENT(pev), &tr);
}
else
tr.flFraction = 1.0;
if (tr.flFraction == 1.0)
{
return pFriend;
}
}
return NULL;
}
示例12: FindAllThink
void COsprey :: FindAllThink( void )
{
CBaseEntity *pEntity = NULL;
m_iUnits = 0;
while (m_iUnits < MAX_CARRY && (pEntity = UTIL_FindEntityByClassname( pEntity, "monster_human_grunt" )) != NULL)
{
if (pEntity->IsAlive())
{
m_hGrunt[m_iUnits] = pEntity;
m_vecOrigin[m_iUnits] = pEntity->pev->origin;
m_iUnits++;
}
}
if (m_iUnits == 0)
{
ALERT( at_console, "osprey error: no grunts to resupply\n");
UTIL_Remove( this );
return;
}
SetThink( FlyThink );
pev->nextthink = gpGlobals->time + 0.1;
m_startTime = gpGlobals->time;
}
示例13: FindAllThink
void COsprey :: FindAllThink( void )
{
CBaseEntity *pEntity = NULL;
m_iUnits = 0;
while (m_iUnits < MAX_CARRY && (pEntity = UTIL_FindEntityByClassname( pEntity, "monster_human_grunt" )) != NULL)
{
if (pEntity->IsAlive())
{
m_hGrunt[m_iUnits] = pEntity;
m_vecOrigin[m_iUnits] = pEntity->pev->origin;
m_iUnits++;
}
}
if (m_iUnits == 0)
{
m_iUnits = 4; //LRC - stop whining, just make the damn grunts...
// ALERT( at_console, "osprey error: no grunts to resupply\n");
// UTIL_Remove( this );
// return;
}
SetThink(&COsprey :: FlyThink );
SetNextThink( 0.1 );
m_startTime = gpGlobals->time;
}
示例14: FriendNumber
CBaseEntity *CTalkMonster::EnumFriends( CBaseEntity *pPrevious, int listNumber, const bool bTrace )
{
CBaseEntity *pFriend = pPrevious;
const char* pszFriend;
TraceResult tr;
Vector vecCheck;
pszFriend = m_szFriends[ FriendNumber(listNumber) ];
while( ( pFriend = UTIL_FindEntityByClassname( pFriend, pszFriend ) ) != nullptr )
{
if (pFriend == this || !pFriend->IsAlive())
// don't talk to self or dead people
continue;
if ( bTrace )
{
vecCheck = pFriend->GetAbsOrigin();
vecCheck.z = pFriend->GetAbsMax().z;
UTIL_TraceLine( GetAbsOrigin(), vecCheck, ignore_monsters, ENT(pev), &tr);
}
else
tr.flFraction = 1.0;
if (tr.flFraction == 1.0)
{
return pFriend;
}
}
return NULL;
}
示例15: memset
void CMultiSource::Register( void )
{
m_iTotal = 0;
memset( m_rgEntities, 0, MS_MAX_TARGETS * sizeof( EHANDLE ) );
SetThink( &CMultiSource::SUB_DoNothing );
// search for all entities which target this multisource (GetTargetname())
CBaseEntity* pTarget = nullptr;
while( ( pTarget = UTIL_FindEntityByTarget( pTarget, GetTargetname() ) ) != nullptr && ( m_iTotal < MS_MAX_TARGETS ) )
{
m_rgEntities[ m_iTotal++ ] = pTarget;
}
pTarget = nullptr;
while( ( pTarget = UTIL_FindEntityByClassname( pTarget, "multi_manager" ) ) != nullptr && ( m_iTotal < MS_MAX_TARGETS ) )
{
if( pTarget->HasTarget( GetTargetname() ) )
m_rgEntities[ m_iTotal++ ] = pTarget;
}
GetSpawnFlags().ClearFlags( SF_MULTI_INIT );
}