本文整理汇总了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
}
示例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();
}
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
}
}
示例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 );
}
}
示例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
}
示例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);
}
示例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;
}
示例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;
}
示例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 );
}
示例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
}