本文整理汇总了C++中CBaseCombatCharacter类的典型用法代码示例。如果您正苦于以下问题:C++ CBaseCombatCharacter类的具体用法?C++ CBaseCombatCharacter怎么用?C++ CBaseCombatCharacter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBaseCombatCharacter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetOwner
//-----------------------------------------------------------------------------
// Purpose:
// Input :
// Output :
//-----------------------------------------------------------------------------
void CWeapon_SLAM::PrimaryAttack( void )
{
CBaseCombatCharacter *pOwner = GetOwner();
if (!pOwner)
{
return;
}
if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0)
{
return;
}
switch (m_tSlamState)
{
case SLAM_TRIPMINE_READY:
if (CanAttachSLAM())
{
StartTripmineAttach();
}
break;
case SLAM_SATCHEL_THROW:
StartSatchelThrow();
break;
case SLAM_SATCHEL_ATTACH:
StartSatchelAttach();
break;
}
}
示例2: EntityIsVisibleToPlayer
//---------------------------------------------------------
//---------------------------------------------------------
bool CVisibilityMonitor::EntityIsVisibleToPlayer( const visibility_target_t &target, CBasePlayer *pPlayer, int *numTraces )
{
CBaseCombatCharacter *pEyeEntity = pPlayer->ActivePlayerCombatCharacter();
Vector vecTargetOrigin = target.entity->WorldSpaceCenter();
Vector vecPlayerOrigin = pEyeEntity->EyePosition();
float flDistSqr = vecPlayerOrigin.DistToSqr( vecTargetOrigin );
if( flDistSqr <= target.minDistSqr )
{
// Increment the counter of traces done during this polling cycle
*numTraces += 1;
trace_t tr;
int mask = MASK_BLOCKLOS_AND_NPCS & ~CONTENTS_BLOCKLOS;
UTIL_TraceLine( vecPlayerOrigin, vecTargetOrigin, mask, pEyeEntity, COLLISION_GROUP_NONE, &tr );
if( tr.fraction == 1.0f || tr.m_pEnt == target.entity )
return true;
if( debug_visibility_monitor.GetInt() > 1 )
{
NDebugOverlay::Line( vecPlayerOrigin, vecTargetOrigin, 255, 0, 0, false, vismon_poll_frequency.GetFloat() );
}
}
return false;
}
示例3: 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 ) );
}
}
}
示例4: GetOwner
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponTranquilizer::CreateLaserPointer( void )
{
#ifndef CLIENT_DLL
if ( m_hLaserDot != NULL )
return;
CBaseCombatCharacter *pOwner = GetOwner();
if ( pOwner == NULL )
return;
if ( pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
return;
m_hLaserDot = CLaserDot::Create( GetAbsOrigin(), GetOwner() );
m_hLaserDot->TurnOff();
m_hLaserDot->SetRenderMode(kRenderWorldGlow);
if(HL2MPRules()->IsTeamplay())
{
if(pOwner->GetTeamNumber() == TEAM_PINK)
m_hLaserDot->SetRenderColor(255,100,255,255);
else
m_hLaserDot->SetRenderColor(153,255,153,255);
}
else
m_hLaserDot->SetRenderColor(255,0,0,255);
UpdateLaserPosition();
#endif
}
示例5: GetOwner
//-----------------------------------------------------------------------------
// Purpose: Same as base reload but doesn't change the owner's next attack time. This
// lets us zoom out while reloading. This hack is necessary because our
// ItemPostFrame is only called when the owner's next attack time has
// expired.
// Output : Returns true if the weapon was reloaded, false if no more ammo.
//-----------------------------------------------------------------------------
bool CWeaponSniperRifle::Reload( void )
{
CBaseCombatCharacter *pOwner = GetOwner();
if (!pOwner)
{
return false;
}
if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) > 0)
{
int primary = MIN(GetMaxClip1() - m_iClip1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));
int secondary = MIN(GetMaxClip2() - m_iClip2, pOwner->GetAmmoCount(m_iSecondaryAmmoType));
if (primary > 0 || secondary > 0)
{
// Play reload on different channel as it happens after every fire
// and otherwise steals channel away from fire sound
WeaponSound(RELOAD);
SendWeaponAnim( ACT_VM_RELOAD );
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
m_bInReload = true;
}
return true;
}
return false;
}
示例6: ToBaseCombatCharacter
//-----------------------------------------------------------------------------
// Purpose: Override so give correct ammo
// Input : pOther - the entity that touched me
// Output :
//-----------------------------------------------------------------------------
void CWeapon_SLAM::SlamTouch( CBaseEntity *pOther )
{
CBaseCombatCharacter* pBCC = ToBaseCombatCharacter( pOther );
// Can I even pick stuff up?
if ( pBCC && !pBCC->IsAllowedToPickupWeapons() )
return;
// ---------------------------------------------------
// First give weapon to touching entity if allowed
// ---------------------------------------------------
BaseClass::DefaultTouch(pOther);
// ----------------------------------------------------
// Give slam ammo if touching client
// ----------------------------------------------------
if (pOther->GetFlags() & FL_CLIENT)
{
// ------------------------------------------------
// If already owned weapon of this type remove me
// ------------------------------------------------
CWeapon_SLAM* oldWeapon = (CWeapon_SLAM*)pBCC->Weapon_OwnsThisType( GetClassname() );
if (oldWeapon != this)
{
UTIL_Remove( this );
}
else
{
pBCC->GiveAmmo( 1, m_iSecondaryAmmoType );
SetThink(NULL);
}
}
}
示例7: PickupTouch
void CGETKnife::PickupTouch( CBaseEntity *pOther )
{
// Vehicles can touch items + pick them up
if ( pOther->GetServerVehicle() )
{
pOther = pOther->GetServerVehicle()->GetPassenger();
if ( !pOther )
return;
}
CBaseCombatCharacter *pPicker = pOther->MyCombatCharacterPointer();
if ( !pPicker )
return;
// Must be a valid pickup scenario (no blocking). Though this is a more expensive
// check than some that follow, this has to be first because it's the only one
// that inhibits firing the output OnCacheInteraction.
if ( UTIL_ItemCanBeTouchedByPlayer( this, ToGEPlayer(pPicker) ) == false )
return;
// Can I even pick stuff up?
if ( !pPicker->IsAllowedToPickupWeapons() )
return;
if ( MyTouch( pPicker ) )
{
SetTouch( NULL );
SetThink( NULL );
UTIL_Remove( this );
}
}
示例8: ToBaseCombatCharacter
//-----------------------------------------------------------------------------
// Purpose: Override so give correct ammo
// Input : pOther - the entity that touched me
// Output :
//-----------------------------------------------------------------------------
void CWeaponMolotov::MolotovTouch( CBaseEntity *pOther )
{
// ---------------------------------------------------
// First give weapon to touching entity if allowed
// ---------------------------------------------------
BaseClass::DefaultTouch(pOther);
// ----------------------------------------------------
// Give molotov ammo if touching client
// ----------------------------------------------------
if (pOther->GetFlags() & FL_CLIENT)
{
// ------------------------------------------------
// If already owned weapon of this type remove me
// ------------------------------------------------
CBaseCombatCharacter* pBCC = ToBaseCombatCharacter( pOther );
CWeaponMolotov* oldWeapon = (CWeaponMolotov*)pBCC->Weapon_OwnsThisType( GetClassname() );
if (oldWeapon != this)
{
UTIL_Remove( this );
}
else
{
pBCC->GiveAmmo( 1, m_iSecondaryAmmoType );
SetThink (NULL);
}
}
}
示例9: while
//-----------------------------------------------------------------------------
// Purpose:
// Input : inputdata -
//-----------------------------------------------------------------------------
void CEntityFlame::InputIgnite( inputdata_t &inputdata )
{
if (m_target != NULL_STRING)
{
CBaseEntity *pTarget = NULL;
while ((pTarget = gEntList.FindEntityGeneric(pTarget, STRING(m_target), this, inputdata.pActivator)) != NULL)
{
// Combat characters know how to catch themselves on fire.
CBaseCombatCharacter *pBCC = pTarget->MyCombatCharacterPointer();
if (pBCC)
{
// DVS TODO: consider promoting Ignite to CBaseEntity and doing everything here
pBCC->Ignite(m_flLifetime);
}
// Everything else, we handle here.
else
{
CEntityFlame *pFlame = CEntityFlame::Create(pTarget);
if (pFlame)
{
pFlame->SetLifetime(m_flLifetime);
}
}
}
}
}
示例10: WaitingUntilSeen
bool CASW_BaseAI_Senses::WaitingUntilSeen( CBaseEntity *pSightEnt )
{
if ( GetOuter()->GetSpawnFlags() & SF_NPC_WAIT_TILL_SEEN )
{
// asw, wake up if marines see us (not players)
if ( pSightEnt && pSightEnt->Classify() == CLASS_ASW_MARINE )
{
CBaseCombatCharacter *pBCC = dynamic_cast<CBaseCombatCharacter*>( pSightEnt );
Vector zero = Vector(0,0,0);
// don't link this client in the list if the npc is wait till seen and the player isn't facing the npc
if (// && pPlayer->FVisible( GetOuter() )
pBCC->FInViewCone( GetOuter() )
&& FBoxVisible( pSightEnt, static_cast<CBaseEntity*>(GetOuter()), zero ) )
{
// marine sees us, become normal now.
GetOuter()->RemoveSpawnFlags( SF_NPC_WAIT_TILL_SEEN );
return false;
}
}
return true;
}
return false;
}
示例11: Warning
//-----------------------------------------------------------------------------
// Purpose: Override so only reload one shell at a time
// Input :
// Output :
//-----------------------------------------------------------------------------
bool CWeaponShotgun::Reload( void )
{
// Check that StartReload was called first
if (!m_bInReload)
{
Warning("ERROR: Shotgun Reload called incorrectly!\n");
}
CBaseCombatCharacter *pOwner = GetOwner();
if ( pOwner == NULL )
return false;
if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
return false;
if (m_iClip1 >= GetMaxClip1())
return false;
int j = MIN(1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));
if (j <= 0)
return false;
FillClip();
// Play reload on different channel as otherwise steals channel away from fire sound
WeaponSound(RELOAD);
SendWeaponAnim( ACT_VM_RELOAD );
pOwner->m_flNextAttack = gpGlobals->curtime;
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
return true;
}
示例12: GetOwner
//-----------------------------------------------------------------------------
// Purpose: Override so only reload one shell at a time
// Input :
// Output :
//-----------------------------------------------------------------------------
bool CWeaponShotgun::StartReload( void )
{
if ( m_bNeedPump )
return false;
CBaseCombatCharacter *pOwner = GetOwner();
if ( pOwner == NULL )
return false;
if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
return false;
if (m_iClip1 >= GetMaxClip1())
return false;
int j = MIN(1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));
if (j <= 0)
return false;
SendWeaponAnim( ACT_SHOTGUN_RELOAD_START );
// Make shotgun shell visible
SetBodygroup(1,0);
pOwner->m_flNextAttack = gpGlobals->curtime;
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
m_bInReload = true;
return true;
}
示例13: KillNPCInRange
//-----------------------------------------------------------------------------
// Purpose: Attempts to kill an NPC if it's within range and other criteria
// Input : *pVictim - NPC to assess
// **pPhysObj - pointer to the ragdoll created if the NPC is killed
// Output : bool - whether or not the NPC was killed and the returned pointer is valid
//-----------------------------------------------------------------------------
bool CGravityVortexController::KillNPCInRange( CBaseEntity *pVictim, IPhysicsObject **pPhysObj )
{
CBaseCombatCharacter *pBCC = pVictim->MyCombatCharacterPointer();
// See if we can ragdoll
if ( pBCC != NULL && pBCC->CanBecomeRagdoll() )
{
// Don't bother with striders
if ( FClassnameIs( pBCC, "npc_strider" ) )
return false;
// TODO: Make this an interaction between the NPC and the vortex
// Become ragdoll
CTakeDamageInfo info( this, this, 1.0f, DMG_GENERIC );
CBaseEntity *pRagdoll = CreateServerRagdoll( pBCC, 0, info, COLLISION_GROUP_INTERACTIVE_DEBRIS, true );
pRagdoll->SetCollisionBounds( pVictim->CollisionProp()->OBBMins(), pVictim->CollisionProp()->OBBMaxs() );
// Necessary to cause it to do the appropriate death cleanup
CTakeDamageInfo ragdollInfo( this, this, 10000.0, DMG_GENERIC | DMG_REMOVENORAGDOLL );
pVictim->TakeDamage( ragdollInfo );
// Return the pointer to the ragdoll
*pPhysObj = pRagdoll->VPhysicsGetObject();
return true;
}
// Wasn't able to ragdoll this target
*pPhysObj = NULL;
return false;
}
示例14: GetOwner
void CWeaponMine::WeaponIdle( void )
{
if(gpGlobals->curtime > m_flNextPrimaryAttack){
CBaseCombatCharacter *pOwner = GetOwner();
if (!pOwner)
return;
//Si on a une mine à finir de poser
if(m_bAttachMine)
FinishAttach();
//Sinon si on doit recharger
if( m_bNeedReload )
{
if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) > 0){
SendWeaponAnim(ACT_SLAM_TRIPMINE_DRAW);
m_bNeedReload = false;
}
#ifndef CLIENT_DLL
//Sinon on a pas assez de munitions et on drop l'arme
else
{
pOwner->Weapon_Drop(this);
UTIL_Remove(this);
}
#endif
}
//Sinon on idle
else
{
SendWeaponAnim(ACT_SLAM_TRIPMINE_IDLE);
m_flWallSwitchTime = 0;
}
}
}
示例15: EnsnareVictim
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CNPC_Ichthyosaur::EnsnareVictim( CBaseEntity *pVictim )
{
CBaseCombatCharacter* pBCC = (CBaseCombatCharacter *) pVictim;
if ( pBCC && pBCC->DispatchInteraction( g_interactionBarnacleVictimGrab, NULL, this ) )
{
if ( pVictim->IsPlayer() )
{
CBasePlayer *pPlayer = dynamic_cast< CBasePlayer * >((CBaseEntity *) pVictim);
if ( pPlayer )
{
m_flHoldTime = MAX( gpGlobals->curtime+3.0f, pPlayer->PlayerDrownTime() - 2.0f );
}
}
else
{
m_flHoldTime = gpGlobals->curtime + 4.0f;
}
m_pVictim = pVictim;
m_pVictim->AddSolidFlags( FSOLID_NOT_SOLID );
SetSchedule( SCHED_ICH_DROWN_VICTIM );
}
}