本文整理汇总了C++中CBaseEntity::Classify方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseEntity::Classify方法的具体用法?C++ CBaseEntity::Classify怎么用?C++ CBaseEntity::Classify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseEntity
的用法示例。
在下文中一共展示了CBaseEntity::Classify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShouldHitEntity
bool CASWTraceFilterShot::ShouldHitEntity( IHandleEntity *pHandleEntity, int contentsMask )
{
Assert( pHandleEntity );
if ( !PassServerEntityFilter( pHandleEntity, m_pPassEnt2 ) )
return false;
CBaseEntity *pEntity = EntityFromEntityHandle( pHandleEntity );
// don't collide with other projectiles
if ( dynamic_cast<CASW_Flamer_Projectile*>( pEntity ) != NULL )
return false;
if ( dynamic_cast<CASW_Extinguisher_Projectile*>( pEntity ) != NULL )
return false;
if ( pEntity && pEntity->Classify() == CLASS_ASW_MARINE )
{
if ( m_bSkipMarines )
return false;
CASW_Marine *pMarine = assert_cast<CASW_Marine*>( pEntity );
if ( m_bSkipRollingMarines && pMarine->GetCurrentMeleeAttack() && pMarine->GetCurrentMeleeAttack()->m_nAttackID == CASW_Melee_System::s_nRollAttackID )
return false;
if ( m_bSkipMarinesReflectingProjectiles && pMarine->IsReflectingProjectiles() )
return false;
}
if ( m_bSkipAliens && pEntity && IsAlienClass( pEntity->Classify() ) )
return false;
return BaseClass::ShouldHitEntity( pHandleEntity, contentsMask );
}
示例2: Hit
//------------------------------------------------------------------------------
// Purpose: Implement impact function
//------------------------------------------------------------------------------
void CWeaponCrowbar::Hit( void )
{
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
//Make sound for the AI
CSoundEnt::InsertSound( SOUND_BULLET_IMPACT, m_traceHit.endpos, 400, 0.2f, pPlayer );
CBaseEntity *pHitEntity = m_traceHit.m_pEnt;
//Apply damage to a hit target
if ( pHitEntity != NULL )
{
Vector hitDirection;
pPlayer->EyeVectors( &hitDirection, NULL, NULL );
VectorNormalize( hitDirection );
ClearMultiDamage();
CTakeDamageInfo info( GetOwner(), GetOwner(), sk_plr_dmg_crowbar.GetFloat(), DMG_CLUB );
CalculateMeleeDamageForce( &info, hitDirection, m_traceHit.endpos );
pHitEntity->DispatchTraceAttack( info, hitDirection, &m_traceHit );
ApplyMultiDamage();
// Now hit all triggers along the ray that...
TraceAttackToTriggers( CTakeDamageInfo( GetOwner(), GetOwner(), sk_plr_dmg_crowbar.GetFloat(), DMG_CLUB ), m_traceHit.startpos, m_traceHit.endpos, hitDirection );
//Play an impact sound
ImpactSound( pHitEntity->Classify() == CLASS_NONE || pHitEntity->Classify() == CLASS_MACHINE );
}
//Apply an impact effect
ImpactEffect();
}
示例3: if
//=========================================================
// PlayerKilled - someone/something killed this player
//=========================================================
void CHalfLifeMultiplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor )
{
DeathNotice( pVictim, pKiller, pInflictor );
pVictim->m_iDeaths += 1;
FireTargets( "game_playerdie", pVictim, pVictim, USE_TOGGLE, 0 );
CBasePlayer *peKiller = NULL;
CBaseEntity *ktmp = CBaseEntity::Instance( pKiller );
if ( ktmp && (ktmp->Classify() == CLASS_PLAYER) )
peKiller = (CBasePlayer*)ktmp;
if ( pVictim->pev == pKiller )
{
// Already increment deaths, don't need to lose frags also
// killed self
//pKiller->frags -= 1;
}
else if ( ktmp && ktmp->IsPlayer() )
{
// if a player dies in a deathmatch game and the killer is a client, award the killer some points
pKiller->frags += IPointsForKill( peKiller, pVictim );
FireTargets( "game_playerkill", ktmp, ktmp, USE_TOGGLE, 0 );
}
else
{ // killed by the world
pKiller->frags -= 1;
}
// update the scores
// killed scores
pVictim->EffectivePlayerClassChanged();
// killers score, if it's a player
CBaseEntity *ep = CBaseEntity::Instance( pKiller );
if ( ep && ep->Classify() == CLASS_PLAYER )
{
CBasePlayer *PK = (CBasePlayer*)ep;
PK->EffectivePlayerClassChanged();
// let the killer paint another decal as soon as he'd like.
PK->m_flNextDecalTime = gpGlobals->time;
}
// Game rules shouldn't know about specific weapons! Removed this because AvH doesn't have satchel charges.
//#ifndef HLDEMO_BUILD
// if ( pVictim->HasNamedPlayerItem("weapon_satchel") )
// {
// DeactivateSatchels( pVictim );
// }
//#endif
}
示例4: if
//=========================================================
// PlayerKilled - someone/something killed this player
//=========================================================
void CHalfLifeMultiplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor )
{
DeathNotice( pVictim, pKiller, pInflictor );
pVictim->m_iDeaths += 1;
FireTargets( "game_playerdie", pVictim, pVictim, USE_TOGGLE, 0 );
CBasePlayer *peKiller = NULL;
CBaseEntity *ktmp = CBaseEntity::Instance( pKiller );
if ( ktmp && (ktmp->Classify() == CLASS_PLAYER) )
peKiller = (CBasePlayer*)ktmp;
if ( pVictim->pev == pKiller )
{ // killed self
pKiller->frags -= 1;
}
else if ( ktmp && ktmp->IsPlayer() )
{
// if a player dies in a deathmatch game and the killer is a client, award the killer some points
pKiller->frags += IPointsForKill( peKiller, pVictim );
FireTargets( "game_playerkill", ktmp, ktmp, USE_TOGGLE, 0 );
}
else
{ // killed by the world
pVictim->pev->frags -= 1;
}
// update the scores
// killed scores
MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo );
WRITE_BYTE( ENTINDEX(pVictim->edict()) );
WRITE_SHORT( pVictim->pev->frags );
WRITE_SHORT( pVictim->m_iDeaths );
WRITE_SHORT( pVictim->pev->team );
MESSAGE_END();
// killers score, if it's a player
CBaseEntity *ep = CBaseEntity::Instance( pKiller );
if ( ep && ep->Classify() == CLASS_PLAYER )
{
CBasePlayer *PK = (CBasePlayer*)ep;
MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo );
WRITE_BYTE( ENTINDEX(PK->edict()) );
WRITE_SHORT( PK->pev->frags );
WRITE_SHORT( PK->m_iDeaths );
WRITE_SHORT( PK->pev->team );
MESSAGE_END();
// let the killer paint another decal as soon as he'd like.
PK->m_flNextDecalTime = gpGlobals->time;
}
}
示例5: ShouldHitEntity
//-----------------------------------------------------------------------------
// Purpose:
// Input : *pHandleEntity -
// contentsMask -
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CASW_Trace_Filter_Doors::ShouldHitEntity( IHandleEntity *pHandleEntity, int contentsMask )
{
if ( !StandardFilterRules( pHandleEntity, contentsMask ) )
return false;
// Don't test if the game code tells us we should ignore this collision...
CBaseEntity *pEntity = EntityFromEntityHandle( pHandleEntity );
const CBaseEntity *pEntPass = EntityFromEntityHandle( m_pPassEnt );
// don't hurt ourself
if ( pEntPass == pEntity )
return false;
if ( !pEntity || pEntity->Classify() != CLASS_ASW_DOOR )
return false;
CASW_Door *pDoor = assert_cast<CASW_Door*>( pEntity );
if ( !pDoor )
return false;
if ( m_bRequireLockedOrSealed )
{
if ( pDoor->GetSealAmount() > 0 || !pDoor->IsAutoOpen() )
{
return true;
}
else
{
return false;
}
}
return true;
}
示例6: Fly
void CFlame::Fly( void )
{
if ( pev->frags <= 0 || UTIL_PointContents(pev->origin) == CONTENT_WATER )
{
FX_Trail( pev->origin, entindex(), PROJ_REMOVE );
UTIL_Remove( this );
return;
}
pev->frags--;
entvars_t *pevOwner = VARS(pev->owner);
CBaseEntity *pOther = NULL;
while ((pOther = UTIL_FindEntityInSphere( pOther, pev->origin, 50 )) != NULL)
{
if (pOther->edict() != pev->owner && pOther->pev->takedamage && pOther->Classify() != CLASS_MACHINE )
{
TraceResult tr;
UTIL_TraceLine( pev->origin, pOther->pev->origin, dont_ignore_monsters, ENT(pev), &tr );
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
ClearMultiDamage( );
pEntity->TraceAttack( pevOwner, pev->dmg/3, pev->velocity, &tr, DMG_IGNITE | DMG_NEVERGIB);
ApplyMultiDamage( pev, pevOwner );
}
}
pev->nextthink = gpGlobals->time + 0.1;
}
示例7: ImmolationDamage
void CWeaponImmolator::ImmolationDamage( const CTakeDamageInfo &info, const Vector &vecSrcIn, float flRadius, int iClassIgnore )
{
CBaseEntity *pEntity = NULL;
trace_t tr;
Vector vecSpot;
Vector vecSrc = vecSrcIn;
// iterate on all entities in the vicinity.
for ( CEntitySphereQuery sphere( vecSrc, flRadius ); pEntity = sphere.GetCurrentEntity(); sphere.NextEntity() )
{
CBaseCombatCharacter *pBCC;
pBCC = pEntity->MyCombatCharacterPointer();
if ( pBCC && !pBCC->IsOnFire() )
{
// UNDONE: this should check a damage mask, not an ignore
if ( iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore )
{
continue;
}
if( pEntity == GetOwner() )
{
continue;
}
pBCC->Ignite( random->RandomFloat( 15, 20 ) );
}
}
}
示例8: RadiusDamage
void CBlackHole::RadiusDamage( )
{
CBaseEntity *pEntity = NULL;
TraceResult tr;
float flAdjustedDamage;
Vector vecSpot;
entvars_t *pevOwner = VARS( pev->owner );
Vector vecSrc = pev->origin + Vector(0,0,1);
if ( !pevOwner )
pevOwner = pev;
CBaseEntity *pPlayer = CBaseEntity::Instance (pevOwner);
// iterate on all entities in the vicinity.
while ((pEntity = UTIL_FindEntityInSphere( pEntity, vecSrc, (dmg_chrono_radius.value * (mp_wpn_power.value/100)) )) != NULL)
{
if ( pEntity->pev->movetype != MOVETYPE_PUSH && pEntity->pev->movetype != MOVETYPE_NONE && pEntity->pev->movetype != MOVETYPE_FOLLOW && pEntity->pev->movetype != MOVETYPE_NOCLIP )
{
if (pEntity == this) continue;
if (CVAR_GET_FLOAT("mp_noselfdamage")==1 && pEntity->pev == pevOwner )
continue;
if (CVAR_GET_FLOAT("mp_noteamdamage")==1 && g_pGameRules->PlayerRelationship(pPlayer, pEntity) == GR_TEAMMATE && pEntity->pev != pevOwner)
continue;
vecSpot = pEntity->BodyTarget( vecSrc );
UTIL_TraceLine ( vecSrc, vecSpot, ignore_monsters, ENT(pev), &tr );
if ( tr.flFraction == 1.0 || tr.pHit == pEntity->edict() )
{
flAdjustedDamage = ( vecSrc - tr.vecEndPos ).Length();
if ( flAdjustedDamage < 1 )
flAdjustedDamage = 1;
Vector m_vel = ( vecSrc - tr.vecEndPos ).Normalize() * ((500 * (dmg_chrono_radius.value * (mp_wpn_power.value/100)) / flAdjustedDamage) + 150);
if (m_vel.Length() > 1000) m_vel = m_vel.Normalize() * 1000;
pEntity->pev->velocity = m_vel;
if (flAdjustedDamage < 200)
{
if (!(pEntity->Classify() == CLASS_MACHINE || pEntity->IsBot() || pEntity->IsPlayer() || FClassnameIs(pEntity->pev, "laser_dot") || FClassnameIs(pEntity->pev, "laser_spot")))
{
pEntity->Killed ( pevOwner, 0 );
return;
}
}
}
}
}
}
示例9: UpdateArena
void CASW_Arena::UpdateArena()
{
// has arena mode just been turned on?
if ( !m_bStartedArenaMode )
{
for ( int i=0; i< m_ArenaAliens.Count(); i++ )
{
UTIL_PrecacheOther( m_ArenaAliens[i]->m_szAlienClass );
}
m_bStartedArenaMode = true;
m_ArenaRestTimer.Start( 3.0f );
}
if ( m_ArenaShuffleWallsTimer.HasStarted() && m_ArenaShuffleWallsTimer.IsElapsed() )
{
TeleportPlayersToSpawn();
ShuffleArenaWalls();
m_ArenaShuffleWallsTimer.Invalidate();
m_ArenaRestTimer.Start( 2.5f );
}
if ( m_ArenaRestTimer.HasStarted() && m_ArenaRestTimer.IsElapsed() )
{
SpawnArenaWave();
m_ArenaRestTimer.Invalidate();
}
if ( m_ArenaCheckTimer.HasStarted() && m_ArenaCheckTimer.IsElapsed() )
{
// count live aliens
CBaseEntity* pEntity = NULL;
int iAliens = 0;
while ((pEntity = gEntList.NextEnt( pEntity )) != NULL)
{
if ( pEntity && pEntity->IsNPC() && pEntity->Classify() != CLASS_ASW_MARINE && pEntity->GetHealth() > 0 )
iAliens++;
}
if ( iAliens <= 0 && !m_ArenaRestTimer.HasStarted() && !m_ArenaShuffleWallsTimer.HasStarted() )
{
RefillMarineAmmo();
if ( asw_arena_shuffle_walls.GetInt() > 0 && ( m_iArenaWave % asw_arena_shuffle_walls.GetInt() ) == 0 && ( m_iArenaWave != 0 ) )
{
UTIL_CenterPrintAll( UTIL_VarArgs("Wave %d clear!\nThe arena is changing...", m_iArenaWave ) );
m_ArenaShuffleWallsTimer.Start( 5.0f );
}
else
{
UTIL_CenterPrintAll( UTIL_VarArgs("Wave %d clear!", m_iArenaWave ) );
m_ArenaRestTimer.Start( RandomFloat( 8, 12 ) );
}
m_ArenaCheckTimer.Invalidate();
}
}
}
示例10: FindSpawners
// searches for all our named spawners and adds them to the list
void CASW_Spawn_Group::FindSpawners()
{
for ( int i = 0; i < MAX_SPAWNER_NAMES_PER_GROUP; i++ )
{
if ( m_iszSpawnerNames[ i ] == NULL_STRING )
continue;
CBaseEntity *pEnt = NULL;
while ( ( pEnt = gEntList.FindEntityByName( pEnt, m_iszSpawnerNames[ i ], NULL ) ) != NULL )
{
if ( pEnt->Classify() != CLASS_ASW_SPAWNER && pEnt->Classify() != CLASS_ASW_HOLDOUT_SPAWNER )
continue;
CASW_Base_Spawner *pSpawner = assert_cast<CASW_Base_Spawner*>( pEnt );
m_hSpawners.AddToTail( pSpawner );
}
}
}
示例11: PlayerKilled
//=========================================================
// PlayerKilled - someone/something killed this player
//=========================================================
void CHalfLifeMultiplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor )
{
DeathNotice( pVictim, pKiller, pInflictor );
FireTargets( "game_playerdie", pVictim, pVictim, USE_TOGGLE, 0 );
CBasePlayer *peKiller = NULL;
CBaseEntity *ktmp = CBaseEntity::Instance( pKiller );
if ( ktmp && (ktmp->Classify() == CLASS_PLAYER) )
peKiller = (CBasePlayer*)ktmp;
CBaseEntity *ep = CBaseEntity::Instance( pKiller );
if ( ep && ep->Classify() == CLASS_PLAYER )
{
CBasePlayer *PK = (CBasePlayer*)ep;
// let the killer paint another decal as soon as he'd like.
PK->m_flNextDecalTime = gpGlobals->time;
}
}
示例12: UTIL_TextureHit
char UTIL_TextureHit(TraceResult *ptr, Vector vecSrc, Vector vecEnd)
{
char chTextureType;
float rgfl1[3], rgfl2[3];
const char *pTextureName;
char szbuffer[64];
CBaseEntity *pEntity;
if( ptr->pHit == NULL )
return CHAR_TEX_FLESH;
pEntity = CBaseEntity::Instance(ptr->pHit);
if (pEntity && pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE)
return CHAR_TEX_FLESH;
vecSrc.CopyToArray(rgfl1);
vecEnd.CopyToArray(rgfl2);
if (pEntity)
pTextureName = TRACE_TEXTURE(ENT(pEntity->pev), rgfl1, rgfl2);
else
pTextureName = TRACE_TEXTURE(ENT(0), rgfl1, rgfl2);
if (pTextureName)
{
if (*pTextureName == '-' || *pTextureName == '+')
pTextureName += 2;
if (*pTextureName == '{' || *pTextureName == '!' || *pTextureName == '~' || *pTextureName == ' ')
pTextureName++;
strncpy(szbuffer, pTextureName, sizeof(szbuffer));
szbuffer[CBTEXTURENAMEMAX - 1] = 0;
chTextureType = PM_FindTextureType(szbuffer);
}
else
chTextureType = 0;
return chTextureType;
}
示例13: UpdateStatusBar
void CBasePlayer::UpdateStatusBar()
{
int newSBarState[ SBAR_END ];
memset( newSBarState, 0, sizeof(newSBarState) );
// Find an ID Target
TraceResult tr;
UTIL_MakeVectors( pev->v_angle + pev->punchangle );
Vector vecSrc = EyePosition();
Vector vecEnd = vecSrc + (gpGlobals->v_forward * MAX_ID_RANGE);
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, edict(), &tr);
if (tr.flFraction != 1.0)
{
if ( !FNullEnt( tr.pHit ) )
{
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
if ( pEntity->Classify() == CLASS_PLAYER )
{
newSBarState[ SBAR_ID_TARGETNAME ] = ENTINDEX( pEntity->edict() );
newSBarState[ SBAR_ID_TARGETTEAM ] = FALSE;
m_flStatusBarDisappearDelay = gpGlobals->time + 1.0;
}
}
else if ( m_flStatusBarDisappearDelay > gpGlobals->time )
{
// hold the values for a short amount of time after viewing the object
newSBarState[ SBAR_ID_TARGETNAME ] = m_izSBarState[ SBAR_ID_TARGETNAME ];
newSBarState[ SBAR_ID_TARGETHEALTH ] = m_izSBarState[ SBAR_ID_TARGETHEALTH ];
newSBarState[ SBAR_ID_TARGETARMOR ] = m_izSBarState[ SBAR_ID_TARGETARMOR ];
newSBarState[ SBAR_ID_TARGETTEAM ] = m_izSBarState[ SBAR_ID_TARGETTEAM ];
}
}
// Check values and send if they don't match
for (int i = 1; i < SBAR_END; i++)
{
if ( newSBarState[i] != m_izSBarState[i] )
{
MESSAGE_BEGIN( MSG_ONE, gmsgStatusValue, NULL, pev );
WRITE_BYTE( i );
WRITE_SHORT( newSBarState[i] );
MESSAGE_END();
m_izSBarState[i] = newSBarState[i];
}
}
}
示例14: ShouldHitEntity
//-----------------------------------------------------------------------------
// Purpose: Trace filter that only hits anything but NPCs and the player
//-----------------------------------------------------------------------------
bool CTraceFilterNoNPCsOrPlayer::ShouldHitEntity( IHandleEntity *pHandleEntity, int contentsMask )
{
if ( CTraceFilterSimple::ShouldHitEntity( pHandleEntity, contentsMask ) )
{
CBaseEntity *pEntity = EntityFromEntityHandle( pHandleEntity );
if ( !pEntity )
return NULL;
#ifndef CLIENT_DLL
if ( pEntity->Classify() == CLASS_PLAYER_ALLY )
return false; // CS hostages are CLASS_PLAYER_ALLY but not IsNPC()
#endif
return (!pEntity->IsNPC() && !pEntity->IsPlayer());
}
return false;
}
示例15: ShouldHitEntity
//-----------------------------------------------------------------------------
// Purpose:
// Input : *pHandleEntity -
// contentsMask -
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CASW_Trace_Filter_Door_Crush::ShouldHitEntity( IHandleEntity *pHandleEntity, int contentsMask )
{
if ( !StandardFilterRules( pHandleEntity, contentsMask ) )
return false;
if ( !PassServerEntityFilter( pHandleEntity, m_pPassEnt ) )
return false;
// Don't test if the game code tells us we should ignore this collision...
CBaseEntity *pEntity = EntityFromEntityHandle( pHandleEntity );
if ( pEntity )
{
//Msg("%f CASW_Trace_Filter_Door_Crush::ShouldHitEntity %s\n", gpGlobals->curtime, pEntity->GetClassname());
if ( !pEntity->ShouldCollide( m_collisionGroup, contentsMask ) )
return false;
if ( !g_pGameRules->ShouldCollide( m_collisionGroup, pEntity->GetCollisionGroup() ) )
return false;
if ( pEntity->Classify() == CLASS_ASW_DOOR )
return false;
if ( pEntity->m_takedamage == DAMAGE_NO )
return false;
// Translate the vehicle into its driver for damage
if ( pEntity->GetServerVehicle() != NULL )
{
CBaseEntity *pDriver = pEntity->GetServerVehicle()->GetPassenger();
if ( pDriver != NULL )
{
pEntity = pDriver;
}
}
Vector attackDir = pEntity->WorldSpaceCenter() - m_dmgInfo->GetAttacker()->WorldSpaceCenter();
VectorNormalize( attackDir );
pEntity->TakeDamage( *m_dmgInfo );
//CalculateMeleeDamageForce( &info, attackDir, info.GetAttacker()->WorldSpaceCenter(), m_flForceScale );
return true;
}
return false;
}