当前位置: 首页>>代码示例>>C++>>正文


C++ ToBaseCombatCharacter函数代码示例

本文整理汇总了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);
		}
	}
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:33,代码来源:weapon_molotov.cpp

示例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;
	}
}
开发者ID:DreikVal,项目名称:nicksproject,代码行数:40,代码来源:weapon_slam.cpp

示例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);
		}
	}
}
开发者ID:DreikVal,项目名称:nicksproject,代码行数:38,代码来源:weapon_slam.cpp

示例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;
}
开发者ID:Orygin,项目名称:BisounoursParty,代码行数:61,代码来源:weapon_mine.cpp

示例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 );
	}
}
开发者ID:SCell555,项目名称:bisonours-party,代码行数:36,代码来源:vehicle_prisoner_pod.cpp

示例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 );
    }
}
开发者ID:paralin,项目名称:hl2sdk,代码行数:36,代码来源:vehicle_choreo_generic.cpp

示例7: ToBaseCombatCharacter

void CWeaponMine::MineTouch( CBaseEntity *pOther )
{
#ifdef GAME_DLL
	CBaseCombatCharacter* pBCC = ToBaseCombatCharacter( pOther );
	if ( pBCC && !pBCC->IsAllowedToPickupWeapons() )
		return;
#endif

	BaseClass::DefaultTouch(pOther);
}
开发者ID:Orygin,项目名称:BisounoursParty,代码行数:10,代码来源:weapon_mine.cpp

示例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 );
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:55,代码来源:grenade_tripmine.cpp

示例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;
}
开发者ID:AniCator,项目名称:Project-Potato,代码行数:54,代码来源:c_basecombatweapon.cpp

示例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;
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:16,代码来源:ai_behavior_passenger_zombie.cpp

示例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;
}
开发者ID:Muini,项目名称:Nag-asw,代码行数:22,代码来源:grenade_bugbait.cpp

示例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;
}
开发者ID:paralin,项目名称:hl2sdk,代码行数:13,代码来源:grenade_frag.cpp

示例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;
}
开发者ID:Muini,项目名称:Nag-asw,代码行数:18,代码来源:grenade_hopwire.cpp

示例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);
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:20,代码来源:weapon_slam.cpp

示例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 );
}
开发者ID:rendenba,项目名称:source-sdk-2013,代码行数:47,代码来源:grenade_tripmine.cpp


注:本文中的ToBaseCombatCharacter函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。