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


C++ CHL2MP_Player类代码示例

本文整理汇总了C++中CHL2MP_Player的典型用法代码示例。如果您正苦于以下问题:C++ CHL2MP_Player类的具体用法?C++ CHL2MP_Player怎么用?C++ CHL2MP_Player使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CHL2MP_Player类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ToBasePlayer

//-----------------------------------------------------------------------------
// Animation event handlers
//-----------------------------------------------------------------------------
void CWeaponZMFists::HandleAnimEventMeleeHit( CBaseCombatCharacter *pOperator )
{
	//do the trace stuff here so we can pass it to the Hit() function
	trace_t traceHit;

	// Try a ray
	CBasePlayer *pOwner = ToBasePlayer(pOperator);
	if ( !pOwner )
		return;

	Vector swingStart = pOwner->Weapon_ShootPosition( );
	Vector forward;

	pOwner->EyeVectors( &forward, NULL, NULL );

	Vector swingEnd = swingStart + forward * GetRange();

#ifndef CLIENT_DLL
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( GetPlayerOwner() );
	// Move other players back to history positions based on local player's lag
	lagcompensation->StartLagCompensation( pPlayer, pPlayer->GetCurrentCommand() );
#endif
	UTIL_TraceLine( swingStart, swingEnd, MASK_SHOT_HULL, pOwner, COLLISION_GROUP_NONE, &traceHit );
	Hit( traceHit, ACT_VM_HITCENTER);
#ifndef CLIENT_DLL
	// Move other players back to history positions based on local player's lag
	lagcompensation->FinishLagCompensation( pPlayer );
#endif
}
开发者ID:TotallyMehis,项目名称:ZM-Updated,代码行数:32,代码来源:weapon_zm_fists.cpp

示例2: respawn

// called by ClientKill and DeadThink
void respawn( CBaseEntity *pEdict, bool fCopyCorpse )
{
	/*CHL2MP_Player *pPlayer = ToHL2MPPlayer( pEdict );

	if ( pPlayer )
	{
		if ( gpGlobals->curtime > pPlayer->GetDeathTime() + DEATH_ANIMATION_TIME )
		{		
			// respawn player
			pPlayer->Spawn();			
		}
		else
		{
			pPlayer->SetNextThink( gpGlobals->curtime + 0.1f );
		}
	}*/
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( pEdict );

	if ( pPlayer )
	{
		//BG2 - Draco - Start(this is the part that supresses respawns when mp_respawnstyle != 0)
		//if ( gpGlobals->curtime > pPlayer->GetDeathTime() + DEATH_ANIMATION_TIME )
		//BG2 - Tjoppen - assume this function only gets called if we're allowed to respawn/spawn

		// respawn player
		pPlayer->Spawn();
	}
}
开发者ID:newroob,项目名称:bg2-2007,代码行数:29,代码来源:hl2mp_client.cpp

示例3: Q_snprintf

//-----------------------------------------------------------------------------
// Purpose: Create a new Bot and put it in the game.
// Output : Pointer to the new Bot, or NULL if there's no free clients.
//-----------------------------------------------------------------------------
CBasePlayer *BotPutInServer( bool bFrozen, int iTeam )
{
	g_iNextBotTeam = iTeam;

	char botname[ 64 ];
	Q_snprintf( botname, sizeof( botname ), "Bot%02i", BotNumber );

	// This is an evil hack, but we use it to prevent sv_autojointeam from kicking in.

	edict_t *pEdict = engine->CreateFakeClient( botname );

	if (!pEdict)
	{
		Msg( "Failed to create Bot.\n");
		return NULL;
	}

	// Allocate a CBasePlayer for the bot, and call spawn
	//ClientPutInServer( pEdict, botname );
	CHL2MP_Player *pPlayer = ((CHL2MP_Player *)CBaseEntity::Instance( pEdict ));
	pPlayer->ClearFlags();
	pPlayer->AddFlag( FL_CLIENT | FL_FAKECLIENT );

	if ( bFrozen )
		pPlayer->AddEFlags( EFL_BOT_FROZEN );

	BotNumber++;

	g_BotData[pPlayer->entindex()-1].m_WantedTeam = iTeam;
	g_BotData[pPlayer->entindex()-1].m_flJoinTeamTime = gpGlobals->curtime + 0.3;

	return pPlayer;
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:37,代码来源:hl2mp_bot_temp.cpp

示例4: GetAbsOrigin

CHL2MP_Player* CHL2MP_Player::FindNearestAlly()
{
	//Credits goes to JailBreak Source for this

	const Vector &  vAbsOrigin      = GetAbsOrigin();
	float           closestDistSq   = FLT_MAX;
	CHL2MP_Player * pNearest        = NULL;
	float           distSq;

	for (int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		CHL2MP_Player *pPlayer = ToHL2MPPlayer(UTIL_PlayerByIndex( i ));
		if ( pPlayer && pPlayer != this)
		{
			if(pPlayer->GetTeamNumber() != this->GetTeamNumber())
				continue;

			distSq = ( vAbsOrigin - pPlayer->GetAbsOrigin() ).LengthSqr();

			if(distSq > closestDistSq)
				continue;

			closestDistSq = distSq;
			pNearest = pPlayer;
		}
	}
	return pNearest;
}
开发者ID:Orygin,项目名称:BisounoursParty,代码行数:28,代码来源:hl2mp_player.cpp

示例5: GetOwner

//-----------------------------------------------------------------------------
// Purpose: 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CBaseHL2MPCombatWeapon::Deploy( void )
{
	// If we should be lowered, deploy in the lowered position
	// We have to ask the player if the last time it checked, the weapon was lowered
	if ( GetOwner() && GetOwner()->IsPlayer() )
	{
		CHL2MP_Player *pPlayer = assert_cast<CHL2MP_Player*>( GetOwner() );
		if ( pPlayer->IsWeaponLowered() )
		{
			if ( SelectWeightedSequence( ACT_VM_IDLE_LOWERED ) != ACTIVITY_NOT_AVAILABLE )
			{
				if ( DefaultDeploy( (char*)GetViewModel(), (char*)GetWorldModel(), ACT_VM_IDLE_LOWERED, (char*)GetAnimPrefix() ) )
				{
					m_bLowered = true;

					// Stomp the next attack time to fix the fact that the lower idles are long
					pPlayer->SetNextAttack( gpGlobals->curtime + 1.0 );
					m_flNextPrimaryAttack = gpGlobals->curtime + 1.0;
					m_flNextSecondaryAttack	= gpGlobals->curtime + 1.0;
					return true;
				}
			}
		}
	}

	m_bLowered = false;
	return BaseClass::Deploy();
}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:32,代码来源:weapon_hl2mpbasehlmpcombatweapon.cpp

示例6: ToHL2MPPlayer

void CWeaponCrowbar::PrimaryAttack()
{
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( GetOwner() );
	if (pPlayer)
	{
#ifndef CLIENT_DLL
		if (pPlayer->gorephased)
		{
			//BB: JAM Request... sneak attacks
			pPlayer->DoGorePhase();
			pPlayer->covenStatusEffects &= pPlayer->covenStatusEffects & ~COVEN_FLAG_PHASE;
			pPlayer->SetStatusTime(COVEN_BUFF_PHASE, 0.0f);
		}
		if (pPlayer->covenClassID == COVEN_CLASSID_FIEND && pPlayer->covenStatusEffects & COVEN_FLAG_DODGE)
		{
			pPlayer->VampireUnDodge();
		}
#else
		/*C_BasePlayer *local = C_BasePlayer::GetLocalPlayer();
		C_BaseHLPlayer *pPlayer2 = (C_BaseHLPlayer *)local;
		if (pPlayer2->covenClassID == COVEN_CLASSID_FIEND && pPlayer2->GetRenderColor().a < 255)
			return;*/
		//second half of sneak attacks
		/*C_BasePlayer *local = C_BasePlayer::GetLocalPlayer();
		C_BaseHLPlayer *pPlayer2 = (C_BaseHLPlayer *)local;
		if (pPlayer2->GetEffects() & EF_NODRAW)
		{
			return;
		}*/
#endif
	}
	BaseClass::PrimaryAttack();
}
开发者ID:rendenba,项目名称:source-sdk-2013,代码行数:33,代码来源:weapon_crowbar.cpp

示例7: 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

示例8: ToHL2MPPlayer

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponFrag::ItemPostFrame( void )
{
	if( m_fDrawbackFinished )
	{
		CHL2MP_Player *pOwner = ToHL2MPPlayer( GetOwner() );

		if (pOwner)
		{
			switch( m_AttackPaused )
			{
			case GRENADE_PAUSED_PRIMARY:
				if( !(pOwner->m_nButtons & IN_ATTACK) )
				{
					SendWeaponAnim( ACT_VM_THROW );
					pOwner->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );
					m_fDrawbackFinished = false;
				}
				break;

			case GRENADE_PAUSED_SECONDARY:
				if( !(pOwner->m_nButtons & IN_ATTACK2) )
				{
					//See if we're ducking
					if ( pOwner->m_nButtons & IN_DUCK )
					{
						//Send the weapon animation
						SendWeaponAnim( ACT_VM_SECONDARYATTACK );
					}
					else
					{
						//Send the weapon animation
						SendWeaponAnim( ACT_VM_HAULBACK );
					}
					//Tony; the grenade really should have a secondary anim. but it doesn't on the player.
					pOwner->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );

					m_fDrawbackFinished = false;
				}
				break;

			default:
				break;
			}
		}
	}

	BaseClass::ItemPostFrame();

	if ( m_bRedraw )
	{
		if ( IsViewModelSequenceFinished() )
		{
			Reload();
		}
	}
}
开发者ID:hlstriker,项目名称:source-sdk-2013,代码行数:59,代码来源:weapon_frag.cpp

示例9: respawn

// called by ClientKill and DeadThink
void respawn( CBaseEntity *pEdict, bool fCopyCorpse )
{
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( pEdict );
	if ( pPlayer )
	{
		if ( gpGlobals->curtime > pPlayer->GetDeathTime() + DEATH_ANIMATION_TIME )
			pPlayer->Spawn();
		else
			pPlayer->SetNextThink( gpGlobals->curtime + 0.1f );
	}
}
开发者ID:SCell555,项目名称:bisonours-party,代码行数:12,代码来源:hl2mp_client.cpp

示例10: ClientPutInServer

/*
===========
ClientPutInServer

called each time a player is spawned into the game
============
*/
void ClientPutInServer( edict_t *pEdict, const char *playername )
{
	// Allocate a CBaseTFPlayer for pev, and call spawn
	CHL2MP_Player *pPlayer = CHL2MP_Player::CreatePlayer( "player", pEdict );
#ifdef HL2SB
	if( pPlayer )
		pPlayer->SetPlayerName( playername );
#else
	pPlayer->SetPlayerName( playername );
#endif
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:18,代码来源:hl2mp_client.cpp

示例11: ToBasePlayer

//-----------------------------------------------------------------------------
// Purpose: Get the damage amount for the animation we're doing
// Input  : hitActivity - currently played activity
// Output : Damage amount
//-----------------------------------------------------------------------------
float CWeaponCrowbar::GetDamageForActivity( Activity hitActivity )
{	
	CBasePlayer *pPlayer  = ToBasePlayer( GetOwner() );
	
	if ( pPlayer == NULL )
		return 0;

	CHL2MP_Player *pHLPlayer = (CHL2MP_Player *)pPlayer;

	float baseDMG = 5.0f + pHLPlayer->myStrength();

	return baseDMG + random->RandomInt(0,20);
}
开发者ID:rendenba,项目名称:source-sdk-2013,代码行数:18,代码来源:weapon_crowbar.cpp

示例12: sndFilter

bool CItemMoney::MyTouch( CBasePlayer *pPlayer )
{
	if ( pPlayer != m_taker )
		return false;

	CPASAttenuationFilter sndFilter( pPlayer );
	pPlayer->EmitSound( sndFilter, pPlayer->entindex(), "Buttons.snd2" );

	CHL2MP_Player * p = ToHL2MPPlayer( pPlayer );
	p->AddMoney( m_iAmount );

	return true;
}
开发者ID:schroe2a,项目名称:DotaSource2,代码行数:13,代码来源:ItemMoney.cpp

示例13: UTIL_PlayerByIndex

void CHL2MPRules::CheckAllPlayersReady( void )
{
    for (int i = 1; i <= gpGlobals->maxClients; i++ )
    {
        CHL2MP_Player *pPlayer = (CHL2MP_Player*) UTIL_PlayerByIndex( i );

        if ( !pPlayer )
            continue;
        if ( !pPlayer->IsReady() )
            return;
    }
    m_bHeardAllPlayersReady = true;
}
开发者ID:whztt07,项目名称:halflife-vr,代码行数:13,代码来源:hl2mp_gamerules.cpp

示例14: SendWeaponAnim

void CWeaponBaseballBat::PrimaryAttack( void )
{
	BaseClass::PrimaryAttack();

	//HACK - our model crashes the decompiler and all the original files are lost so we can't fix the messed up activities
	SendWeaponAnim( ACT_VM_HITCENTER );

	CHL2MP_Player *pOwner = ToHL2MPPlayer( GetOwner() );
	if ( !pOwner )
		return;

	pOwner->SetAnimation( PLAYER_ATTACK1 );
	pOwner->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );
}
开发者ID:dreckard,项目名称:dhl2,代码行数:14,代码来源:weapon_baseballbat.cpp

示例15: ToHL2MPPlayer

//------------------------------------------------------------------------------
// Purpose :
// Input   :
// Output  :
//------------------------------------------------------------------------------
void CBaseHL2MPBludgeonWeapon::PrimaryAttack()
{

#ifndef CLIENT_DLL
    CHL2MP_Player *pPlayer = ToHL2MPPlayer( GetPlayerOwner() );
    // Move other players back to history positions based on local player's lag
    lagcompensation->StartLagCompensation( pPlayer, pPlayer->GetCurrentCommand() );
#endif
    Swing( false );
#ifndef CLIENT_DLL
    // Move other players back to history positions based on local player's lag
    lagcompensation->FinishLagCompensation( pPlayer );
#endif

}
开发者ID:dreckard,项目名称:dhl2,代码行数:20,代码来源:weapon_hl2mpbasebasebludgeon.cpp


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