本文整理汇总了C++中ToBaseCombatCharacter函数的典型用法代码示例。如果您正苦于以下问题:C++ ToBaseCombatCharacter函数的具体用法?C++ ToBaseCombatCharacter怎么用?C++ ToBaseCombatCharacter使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ToBaseCombatCharacter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
示例2: GetOwner
//-----------------------------------------------------------------------------
// Purpose:
// Input :
// Output :
//-----------------------------------------------------------------------------
bool CWeapon_SLAM::CanAttachSLAM( void )
{
CBaseCombatCharacter *pOwner = GetOwner();
if (!pOwner)
{
return false;
}
Vector vecSrc = pOwner->Weapon_ShootPosition( );
Vector vecAiming = pOwner->BodyDirection2D( );
trace_t tr;
Vector vecEnd = vecSrc + (vecAiming * 42);
UTIL_TraceLine( vecSrc, vecEnd, MASK_SOLID, pOwner, COLLISION_GROUP_NONE, &tr );
if (tr.fraction < 1.0)
{
// Don't attach to a living creature
if (tr.m_pEnt)
{
CBaseEntity *pEntity = tr.m_pEnt;
CBaseCombatCharacter *pBCC = ToBaseCombatCharacter( pEntity );
if (pBCC)
{
return false;
}
}
return true;
}
else
{
return false;
}
}
示例3: 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);
}
}
}
示例4: ToHL2MPPlayer
//Pose la mine sur son support une fois l'animation terminée
void CWeaponMine::FinishAttach( void ){
CHL2MP_Player *pOwner = ToHL2MPPlayer( GetOwner() );
if (!pOwner)
return;
Vector vecSrc, vecAiming;
vecSrc = pOwner->EyePosition();
QAngle angles = pOwner->GetLocalAngles();
AngleVectors( angles, &vecAiming );
trace_t tr;
UTIL_TraceLine( vecSrc, vecSrc + (vecAiming * 60), MASK_SOLID, pOwner, COLLISION_GROUP_NONE, &tr );
if (tr.fraction < 1.0)
{
if (tr.m_pEnt)
{
//On attache pas la mine sur une entité vivante
CBaseEntity *pEntity = tr.m_pEnt;
CBaseCombatCharacter *pBCC = ToBaseCombatCharacter( pEntity );
if (pBCC){
m_bAttachMine = false;
m_bNeedReload = true;
return;
}
#ifndef CLIENT_DLL
//On vérifie qu'il n 'y a pas déjà une mine sur le support visé
CBaseEntity* pResult = gEntList.FindEntityByClassname(NULL,"npc_mine");
while (pResult)
{
if((pResult->GetAbsOrigin() - tr.endpos).Length() < MINE_DISTANCE){
m_bAttachMine = false;
m_bNeedReload = true;
return;
}
pResult = gEntList.FindEntityByClassname(pResult,"npc_mine");
}
if (pEntity && !(pEntity->GetFlags() & FL_CONVEYOR))
{
QAngle angles;
VectorAngles(tr.plane.normal, angles);
angles.x += 90;
CBaseEntity *pEnt = CBaseEntity::Create( "npc_mine", tr.endpos + tr.plane.normal * 3, angles, NULL );
CNPCMine *pMine = (CNPCMine *)pEnt;
pMine->m_hOwner = GetOwner();
ChooseMineColor(pMine);
pMine->AttachToEntity( pEntity );
pOwner->RemoveAmmo( 1, m_iSecondaryAmmoType );
}
#endif
}
}
m_bAttachMine = false;
m_bNeedReload = true;
}
示例5: ToBaseCombatCharacter
//-----------------------------------------------------------------------------
// Purpose:
// Input : &inputdata -
//-----------------------------------------------------------------------------
void CPropVehiclePrisonerPod::InputEnterVehicleImmediate( inputdata_t &inputdata )
{
if ( m_bEnterAnimOn )
return;
// Try the activator first & use them if they are a player.
CBaseCombatCharacter *pPassenger = ToBaseCombatCharacter( inputdata.pActivator );
if ( pPassenger == NULL )
{
// Activator was not a player, just grab the nearest player. // AI Patch Addition.
pPassenger = UTIL_GetNearestPlayer(GetAbsOrigin()); // AI Patch Addition.
if ( pPassenger == NULL )
return;
}
CBasePlayer *pPlayer = ToBasePlayer( pPassenger );
if ( pPlayer != NULL )
{
if ( pPlayer->IsInAVehicle() )
{
// Force the player out of whatever vehicle they are in.
pPlayer->LeaveVehicle();
}
pPlayer->GetInVehicle( GetServerVehicle(), VEHICLE_ROLE_DRIVER );
}
else
{
// NPCs are not currently supported - jdw
Assert( 0 );
}
}
示例6: ToBaseCombatCharacter
//-----------------------------------------------------------------------------
// Purpose:
// Input : &inputdata -
//-----------------------------------------------------------------------------
void CPropVehicleChoreoGeneric::InputEnterVehicleImmediate( inputdata_t &inputdata )
{
if ( m_bEnterAnimOn )
return;
// Try the activator first & use them if they are a player.
CBaseCombatCharacter *pPassenger = ToBaseCombatCharacter( inputdata.pActivator );
if ( pPassenger == NULL )
{
// Activator was not a player, just grab the singleplayer player.
pPassenger = UTIL_PlayerByIndex( 1 );
if ( pPassenger == NULL )
return;
}
CBasePlayer *pPlayer = ToBasePlayer( pPassenger );
if ( pPlayer != NULL )
{
if ( pPlayer->IsInAVehicle() )
{
// Force the player out of whatever vehicle they are in.
pPlayer->LeaveVehicle();
}
pPlayer->GetInVehicle( GetServerVehicle(), VEHICLE_ROLE_DRIVER );
}
else
{
// NPCs not supported yet - jdw
Assert( 0 );
}
}
示例7: ToBaseCombatCharacter
void CWeaponMine::MineTouch( CBaseEntity *pOther )
{
#ifdef GAME_DLL
CBaseCombatCharacter* pBCC = ToBaseCombatCharacter( pOther );
if ( pBCC && !pBCC->IsAllowedToPickupWeapons() )
return;
#endif
BaseClass::DefaultTouch(pOther);
}
示例8: GetAbsOrigin
void CTripmineGrenade::BeamBreakThink( void )
{
// See if I can go solid yet (has dropper moved out of way?)
if (IsSolidFlagSet( FSOLID_NOT_SOLID ))
{
trace_t tr;
Vector vUpBit = GetAbsOrigin();
vUpBit.z += 5.0;
UTIL_TraceEntity( this, GetAbsOrigin(), vUpBit, MASK_SHOT, &tr );
if ( !tr.startsolid && (tr.fraction == 1.0) )
{
RemoveSolidFlags( FSOLID_NOT_SOLID );
}
}
trace_t tr;
// NOT MASK_SHOT because we want only simple hit boxes
UTIL_TraceLine( GetAbsOrigin(), m_vecEnd, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr );
// ALERT( at_console, "%f : %f\n", tr.flFraction, m_flBeamLength );
// respawn detect.
if ( !m_pBeam )
{
MakeBeam( );
if ( tr.m_pEnt )
m_hOwner = tr.m_pEnt; // reset owner too
}
CBaseEntity *pEntity = tr.m_pEnt;
CBaseCombatCharacter *pBCC = ToBaseCombatCharacter( pEntity );
bool bAttachMoved = false;
if ( m_bAttached && m_hAttachEntity.Get() != NULL )
{
if ( m_hAttachEntity.Get()->GetAbsOrigin() != m_vAttachedPosition )
bAttachMoved = true;
}
// Also blow up if the attached entity goes away, ie: a crate
if (pBCC || fabs( m_flBeamLength - tr.fraction ) > 0.001 || ( m_bAttached && m_hAttachEntity.Get() == NULL) || bAttachMoved )
{
m_iHealth = 0;
if (m_pConstraint)
m_pConstraint->Deactivate();
Event_Killed( CTakeDamageInfo( (CBaseEntity*)m_hOwner, this, 100, GIB_NORMAL ) );
return;
}
SetNextThink( gpGlobals->curtime + 0.05f );
}
示例9: ToBaseCombatCharacter
bool C_BaseCombatWeapon::GetShootPosition( Vector &vOrigin, QAngle &vAngles )
{
// Get the entity because the weapon doesn't have the right angles.
C_BaseCombatCharacter *pEnt = ToBaseCombatCharacter( GetOwner() );
if ( pEnt )
{
if ( pEnt == C_BasePlayer::GetLocalPlayer() )
{
vAngles = pEnt->EyeAngles();
}
else
{
vAngles = pEnt->GetRenderAngles();
}
}
else
{
vAngles.Init();
}
C_BasePlayer *player = ToBasePlayer( pEnt );
bool bUseViewModel = false;
if ( C_BasePlayer::IsLocalPlayer( pEnt ) )
{
ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( pEnt );
bUseViewModel = !player->ShouldDrawLocalPlayer();
}
QAngle vDummy;
if ( IsActiveByLocalPlayer() && bUseViewModel )
{
C_BaseViewModel *vm = player ? player->GetViewModel( 0 ) : NULL;
if ( vm )
{
int iAttachment = vm->LookupAttachment( "muzzle" );
if ( vm->GetAttachment( iAttachment, vOrigin, vDummy ) )
{
return true;
}
}
}
else
{
// Thirdperson
int iAttachment = LookupAttachment( "muzzle" );
if ( GetAttachment( iAttachment, vOrigin, vDummy ) )
{
return true;
}
}
vOrigin = GetRenderOrigin();
return false;
}
示例10: ToBaseCombatCharacter
//-----------------------------------------------------------------------------
// Purpose: Determine if we can jump to be on the enemy's vehicle
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
inline bool CAI_PassengerBehaviorZombie::CanBeOnEnemyVehicle( void )
{
CBaseCombatCharacter *pEnemy = ToBaseCombatCharacter( GetOuter()->GetEnemy() );
if ( pEnemy != NULL )
{
IServerVehicle *pVehicle = pEnemy->GetVehicle();
if ( pVehicle && pVehicle->NPC_HasAvailableSeat( GetRoleName() ) )
return true;
}
return false;
}
示例11: ToBaseCombatCharacter
//-----------------------------------------------------------------------------
// Purpose:
// Input : &position -
// &angles -
// &velocity -
// &angVelocity -
// *owner -
// Output : CBaseGrenade
//-----------------------------------------------------------------------------
CGrenadeBugBait *BugBaitGrenade_Create( const Vector &position, const QAngle &angles, const Vector &velocity, const QAngle &angVelocity, CBaseEntity *owner )
{
CGrenadeBugBait *pGrenade = (CGrenadeBugBait *) CBaseEntity::Create( "npc_grenade_bugbait", position, angles, owner );
if ( pGrenade != NULL )
{
pGrenade->SetLocalAngularVelocity( angVelocity );
pGrenade->SetAbsVelocity( velocity );
pGrenade->SetThrower( ToBaseCombatCharacter( owner ) );
}
return pGrenade;
}
示例12: ToBaseCombatCharacter
CBaseGrenade *Fraggrenade_Create( const Vector &position, const QAngle &angles, const Vector &velocity, const AngularImpulse &angVelocity, CBaseEntity *pOwner, float timer, bool combineSpawned )
{
// Don't set the owner here, or the player can't interact with grenades he's thrown
CGrenadeFrag *pGrenade = (CGrenadeFrag *)CBaseEntity::Create( "npc_grenade_frag", position, angles, pOwner );
pGrenade->SetTimer( timer, timer - 1.5f );
pGrenade->SetVelocity( velocity, angVelocity );
pGrenade->SetThrower( ToBaseCombatCharacter( pOwner ) );
pGrenade->m_takedamage = DAMAGE_EVENTS_ONLY;
pGrenade->SetCombineSpawned( combineSpawned );
return pGrenade;
}
示例13: ToBaseCombatCharacter
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CBaseGrenade *HopWire_Create( const Vector &position, const QAngle &angles, const Vector &velocity, const AngularImpulse &angVelocity, CBaseEntity *pOwner, float timer )
{
CGrenadeHopwire *pGrenade = (CGrenadeHopwire *) CBaseEntity::Create( "npc_grenade_hopwire", position, angles, pOwner );
// Only set ourselves to detonate on a timer if we're not a trap hopwire
if ( hopwire_trap.GetBool() == false )
{
pGrenade->SetTimer( timer );
}
pGrenade->SetVelocity( velocity, angVelocity );
pGrenade->SetThrower( ToBaseCombatCharacter( pOwner ) );
return pGrenade;
}
示例14: ToBaseCombatCharacter
//-----------------------------------------------------------------------------
// Purpose: Override so give correct ammo
// Input : pOther - the entity that touched me
// Output :
//-----------------------------------------------------------------------------
void CWeapon_SLAM::SlamTouch( CBaseEntity *pOther )
{
#ifdef GAME_DLL
CBaseCombatCharacter* pBCC = ToBaseCombatCharacter( pOther );
// Can I even pick stuff up?
if ( pBCC && !pBCC->IsAllowedToPickupWeapons() )
return;
#endif
// ---------------------------------------------------
// First give weapon to touching entity if allowed
// ---------------------------------------------------
BaseClass::DefaultTouch(pOther);
}
示例15: GetAbsOrigin
void CTripmineGrenade::BeamBreakThink( void )
{
// See if I can go solid yet (has dropper moved out of way?)
if (IsSolidFlagSet( FSOLID_NOT_SOLID ))
{
trace_t tr;
Vector vUpBit = GetAbsOrigin();
vUpBit.z += 5.0;
UTIL_TraceEntity( this, GetAbsOrigin(), vUpBit, MASK_SHOT, &tr );
if ( !tr.startsolid && (tr.fraction == 1.0) )
{
RemoveSolidFlags( FSOLID_NOT_SOLID );
}
}
trace_t tr;
// NOT MASK_SHOT because we want only simple hit boxes
UTIL_TraceLine( GetAbsOrigin(), m_vecEnd, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr );
// ALERT( at_console, "%f : %f\n", tr.flFraction, m_flBeamLength );
// respawn detect.
if ( !m_pBeam )
{
MakeBeam( );
if ( tr.m_pEnt )
m_hOwner = tr.m_pEnt; // reset owner too
}
CBaseEntity *pEntity = tr.m_pEnt;
CBaseCombatCharacter *pBCC = ToBaseCombatCharacter( pEntity );
if (pBCC && pBCC->GetTeamNumber() != m_nTeam && pBCC->m_floatCloakFactor < 1.0f)
//if (pBCC || fabs( m_flBeamLength - tr.fraction ) > 0.001)
{
m_iHealth = 0;
Event_Killed( CTakeDamageInfo( (CBaseEntity*)m_hOwner, this, 100, GIB_NORMAL ) );
return;
}
SetNextThink( gpGlobals->curtime + 0.05f );
}