• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetActiveWeapon函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetActiveWeapon

//=========================================================
// Traduce una animación.
//=========================================================
Activity CIN_Player::TranslateActivity(Activity baseAct, bool *pRequired)
{
    // Esta será la nueva animación.
    Activity translated = baseAct;

    // El jugador tiene una arma, usar la animación con esa arma.
    if ( GetActiveWeapon() )
        translated = GetActiveWeapon()->ActivityOverride(baseAct, pRequired);

    // Estamos desarmados, verificar si existe una animación.
    else if ( unarmedActtable )
    {
        acttable_t *pTable	= unarmedActtable;
        int actCount		= ARRAYSIZE(unarmedActtable);

        for ( int i = 0; i < actCount; i++, pTable++ )
        {
            if ( baseAct == pTable->baseAct )
                translated = (Activity)pTable->weaponAct;
        }
    }
    else if ( pRequired )
        *pRequired = false;

    // @DEBUG: Guardamos la animación nueva para poder usarla en la información de depuración: anim_showstatelog
#ifndef CLIENT_DLL
    //DevMsg("[ANIM] %s \r\n", ActivityList_NameForIndex(translated));
#endif

    return translated;
}
开发者ID:InfoSmart,项目名称:InSource-Singleplayer,代码行数:34,代码来源:in_player_shared.cpp


示例2: OnKilledNPC

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CNPC_Monk::OnKilledNPC( CBaseCombatCharacter *pKilled )
{
	if ( !pKilled )
	{
		return;
	}

	if ( pKilled->Classify() == CLASS_ZOMBIE )
	{
		// Don't speak if the gun is empty, cause grigori will want to speak while he's reloading.
		if ( GetActiveWeapon() )
		{
			if ( GetActiveWeapon()->UsesPrimaryAmmo() && !GetActiveWeapon()->HasPrimaryAmmo() )
			{
				// Gun is empty. I'm about to reload.
				if( m_iNumZombies >= 2 )
				{
					// Don't talk about killing a single zombie if there are more coming.
					// the reload behavior will say "come to me, children", etc.
					return;
				}
			}
		}

		if( m_iNumZombies == 1 || random->RandomInt( 1, 3 ) == 1 )
		{
			SpeakIfAllowed( TLK_ENEMY_DEAD );
		}
	}
}
开发者ID:RaraFolf,项目名称:FIREFIGHT-RELOADED-src-sdk-2013,代码行数:32,代码来源:npc_monk.cpp


示例3: Weapon_OwnsThisType

void CHL2MP_Player::Weapon_Drop( CBaseCombatWeapon *pWeapon, const Vector *pvecTarget, const Vector *pVelocity )
{
	//Drop a grenade if it's primed.
	if ( GetActiveWeapon() )
	{
		CBaseCombatWeapon *pGrenade = Weapon_OwnsThisType("weapon_frag");

		if ( GetActiveWeapon() == pGrenade )
		{
			if ( ( m_nButtons & IN_ATTACK ) || (m_nButtons & IN_ATTACK2) )
			{
				DropPrimedFragGrenade( this, pGrenade );
				return;
			}
			//DHL - Skillet
			else
			{
				pGrenade->Drop( *pVelocity );
				return;
			}
		}
	}

	BaseClass::Weapon_Drop( pWeapon, pvecTarget, pVelocity );
}
开发者ID:dreckard,项目名称:dhl2,代码行数:25,代码来源:hl2mp_player.cpp


示例4: Weapon_CanSwitchTo

bool CSDKPlayer::Weapon_CanSwitchTo( CBaseCombatWeapon *pWeapon )
{
	if (IsPlayer())
	{
		CBasePlayer *pPlayer = (CBasePlayer *)this;
#if !defined( CLIENT_DLL )
		IServerVehicle *pVehicle = pPlayer->GetVehicle();
#else
		IClientVehicle *pVehicle = pPlayer->GetVehicle();
#endif
		if (pVehicle && !pPlayer->UsingStandardWeaponsInVehicle())
			return false;
	}

	if ( !pWeapon->CanDeploy() )
		return false;
	
	if ( GetActiveWeapon() )
	{
		if ( !GetActiveWeapon()->CanHolster() )
			return false;
	}

	return true;
}
开发者ID:jlwitthuhn,项目名称:DoubleAction,代码行数:25,代码来源:sdk_player_shared.cpp


示例5: switch

void CNPC_Monk::StartTask( const Task_t *pTask )
{
	switch( pTask->iTask )
	{
	case TASK_RELOAD:
		{
			if ( GetActiveWeapon() && GetActiveWeapon()->HasPrimaryAmmo() )
			{
				// Don't reload if you have done so while moving (See BACK_AWAY_AND_RELOAD schedule).
				TaskComplete();
				return;
			}

			if( m_iNumZombies >= 2 && random->RandomInt( 1, 3 ) == 1 )
			{
				SpeakIfAllowed( TLK_ATTACKING );
			}

			Activity reloadGesture = TranslateActivity( ACT_GESTURE_RELOAD );
			if ( reloadGesture != ACT_INVALID && IsPlayingGesture( reloadGesture ) )
			{
				ResetIdealActivity( ACT_IDLE );
				return;
			}

			BaseClass::StartTask( pTask );
		}
		break;

	default:
		BaseClass::StartTask( pTask );
		break;
	}
}
开发者ID:RaraFolf,项目名称:FIREFIGHT-RELOADED-src-sdk-2013,代码行数:34,代码来源:npc_monk.cpp


示例6: GetActiveWeapon

void C_HL2MP_Player::DoImpactEffect( trace_t &tr, int nDamageType )
{
	if ( GetActiveWeapon() )
	{
		GetActiveWeapon()->DoImpactEffect( tr, nDamageType );
		return;
	}

	BaseClass::DoImpactEffect( tr, nDamageType );
}
开发者ID:uunx,项目名称:quakelife2,代码行数:10,代码来源:c_hl2mp_player.cpp


示例7: GetAbsOrigin

bool CNPC_Monk::IsValidEnemy( CBaseEntity *pEnemy )
{
	if ( BaseClass::IsValidEnemy( pEnemy ) && GetActiveWeapon() )
	{
		float flDist;

		flDist = ( GetAbsOrigin() - pEnemy->GetAbsOrigin() ).Length();
		if( flDist <= GetActiveWeapon()->m_fMaxRange1 )
			return true;
	}
	return false;
}
开发者ID:RaraFolf,项目名称:FIREFIGHT-RELOADED-src-sdk-2013,代码行数:12,代码来源:npc_monk.cpp


示例8: SetCondition

//-----------------------------------------------------------------------------
// Purpose: check ammo
//-----------------------------------------------------------------------------
void CAI_BaseHumanoid::CheckAmmo( void )
{
	BaseClass::CheckAmmo();

	// FIXME: put into GatherConditions()?
	// FIXME: why isn't this a baseclass function?
	if (!GetActiveWeapon())
		return;

	// Don't do this while holstering / unholstering
	if ( IsWeaponStateChanging() )
		return;

	if (GetActiveWeapon()->UsesPrimaryAmmo())
	{
		if (!GetActiveWeapon()->HasPrimaryAmmo() )
		{
			SetCondition(COND_NO_PRIMARY_AMMO);
		}
		else if (GetActiveWeapon()->UsesClipsForAmmo1() && GetActiveWeapon()->Clip1() < (GetActiveWeapon()->GetMaxClip1() / 4 + 1))
		{
			// don't check for low ammo if you're near the max range of the weapon
			SetCondition(COND_LOW_PRIMARY_AMMO);
		}
	}

	if (!GetActiveWeapon()->HasSecondaryAmmo() )
	{
		if ( GetActiveWeapon()->UsesClipsForAmmo2() )
		{
			SetCondition(COND_NO_SECONDARY_AMMO);
		}
	}
}
开发者ID:Bubbasacs,项目名称:FinalProj,代码行数:37,代码来源:ai_basehumanoid.cpp


示例9: GetActiveWeapon

Activity CDODPlayer::TranslateActivity( Activity baseAct, bool *pRequired /* = NULL */ )
{
	Activity translated = baseAct;

	if ( GetActiveWeapon() )
	{
		translated = GetActiveWeapon()->ActivityOverride( baseAct, pRequired );
	}
	else if (pRequired)
	{
		*pRequired = false;
	}

	return translated;
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:15,代码来源:dod_player_shared.cpp


示例10: GetActiveWeapon

void CHL2MP_Player::FireBullets ( const FireBulletsInfo_t &info )
{
#ifndef GE_DLL
    // Move other players back to history positions based on local player's lag
    lagcompensation->StartLagCompensation( this, this->GetCurrentCommand() );

    FireBulletsInfo_t modinfo = info;

    CWeaponHL2MPBase *pWeapon = dynamic_cast<CWeaponHL2MPBase *>( GetActiveWeapon() );

    if ( pWeapon )
    {
        modinfo.m_iPlayerDamage = modinfo.m_iDamage = pWeapon->GetHL2MPWpnData().m_iPlayerDamage;
    }

    NoteWeaponFired();

    BaseClass::FireBullets( modinfo );

    // Move other players back to history positions based on local player's lag
    lagcompensation->FinishLagCompensation( this );
#else
    BaseClass::FireBullets( info );
#endif
}
开发者ID:Entropy-Soldier,项目名称:ges-legacy-code,代码行数:25,代码来源:hl2mp_player.cpp


示例11: GetNavigator

bool CAI_BaseHumanoid::OnMoveBlocked( AIMoveResult_t *pResult )
{
	if ( *pResult != AIMR_BLOCKED_NPC && GetNavigator()->GetBlockingEntity() && !GetNavigator()->GetBlockingEntity()->IsNPC() )
	{
		CBaseEntity *pBlocker = GetNavigator()->GetBlockingEntity();

		float massBonus = ( IsNavigationUrgent() ) ? 40.0 : 0;

		if ( pBlocker->GetMoveType() == MOVETYPE_VPHYSICS && 
			 pBlocker != GetGroundEntity() && 
			 !pBlocker->IsNavIgnored() &&
			 !dynamic_cast<CBasePropDoor *>(pBlocker) &&
			 pBlocker->VPhysicsGetObject() && 
			 pBlocker->VPhysicsGetObject()->IsMoveable() && 
			 ( pBlocker->VPhysicsGetObject()->GetMass() <= 35.0 + massBonus + 0.1 || 
			   ( pBlocker->VPhysicsGetObject()->GetMass() <= 50.0 + massBonus + 0.1 && IsSmall( pBlocker ) ) ) )
		{
			DbgNavMsg1( this, "Setting ignore on object %s", pBlocker->GetDebugName() );
			pBlocker->SetNavIgnore( 2.5 );
		}
#if 0
		else
		{
			CPhysicsProp *pProp = dynamic_cast<CPhysicsProp*>( pBlocker );
			if ( pProp && pProp->GetHealth() && pProp->GetExplosiveDamage() == 0.0 && GetActiveWeapon() && !GetActiveWeapon()->ClassMatches( "weapon_rpg" ) )
			{
				Msg( "!\n" );
				// Destroy!
			}
		}
#endif
	}

	return BaseClass::OnMoveBlocked( pResult );
}
开发者ID:Bubbasacs,项目名称:FinalProj,代码行数:35,代码来源:ai_basehumanoid.cpp


示例12: PlayerUse

//-----------------------------------------------------------------------------
// Purpose: Called every usercmd by the player PreThink
//-----------------------------------------------------------------------------
void CBasePlayer::ItemPreFrame()
{
	// Handle use events
	PlayerUse();

	CBaseCombatWeapon *pActive = GetActiveWeapon();

	// Allow all the holstered weapons to update
	for ( int i = 0; i < WeaponCount(); ++i )
	{
		CBaseCombatWeapon *pWeapon = GetWeapon( i );

		if ( pWeapon == NULL )
			continue;

		if ( pActive == pWeapon )
			continue;

		pWeapon->ItemHolsterFrame();
	}

    if ( gpGlobals->curtime < m_flNextAttack )
		return;

	if (!pActive)
		return;

#if defined( CLIENT_DLL )
	// Not predicting this weapon
	if ( !pActive->IsPredicted() )
		return;
#endif

	pActive->ItemPreFrame();
}
开发者ID:EspyEspurr,项目名称:game,代码行数:38,代码来源:baseplayer_shared.cpp


示例13: EmitSound

//-----------------------------------------------------------------------------
// Purpose
//-----------------------------------------------------------------------------
void C_BaseViewModel::FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options )
{
	// We override sound requests so that we can play them locally on the owning player
	if ( ( event == AE_CL_PLAYSOUND ) || ( event == CL_EVENT_SOUND ) )
	{
		// Only do this if we're owned by someone
		if ( GetOwner() != NULL )
		{
			CLocalPlayerFilter filter;
			EmitSound( filter, GetOwner()->GetSoundSourceIndex(), options, &GetAbsOrigin() );
			return;
		}
	}

	// Otherwise pass the event to our associated weapon
	C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
	if ( pWeapon )
	{
		// NVNT notify the haptics system of our viewmodel's event
		if ( haptics )
			haptics->ProcessHapticEvent(4,"Weapons",pWeapon->GetName(),"AnimationEvents",VarArgs("%i",event));

		bool bResult = pWeapon->OnFireEvent( this, origin, angles, event, options );
		if ( !bResult )
		{
			BaseClass::FireEvent( origin, angles, event, options );
		}
	}
}
开发者ID:malortie,项目名称:ulaval,代码行数:32,代码来源:c_baseviewmodel.cpp


示例14: GetLastWeapon

CBaseCombatWeapon* CSDKPlayer::GetLastWeapon()
{
	// This is pretty silly, but I'd rather mess around with stock Valve code as little as possible.
#ifdef CLIENT_DLL
	CBaseCombatWeapon* pLastWeapon = BaseClass::GetLastWeapon();
#else
	CBaseCombatWeapon* pLastWeapon = BaseClass::Weapon_GetLast();
#endif

	if (pLastWeapon && pLastWeapon != GetActiveWeapon())
		return pLastWeapon;

	CWeaponSDKBase* pHeaviest = NULL;
	CWeaponSDKBase* pBrawl = NULL;
	for (int i = 0; i < WeaponCount(); i++)
	{
		if (!GetWeapon(i))
			continue;

		if (GetWeapon(i) == GetActiveWeapon())
			continue;

		CWeaponSDKBase* pSDKWeapon = dynamic_cast<CWeaponSDKBase*>(GetWeapon(i));
		if (!pSDKWeapon)
			continue;

		if (pSDKWeapon->GetWeaponID() == SDK_WEAPON_BRAWL)
		{
			pBrawl = pSDKWeapon;
			continue;
		}

		if (!pHeaviest)
		{
			pHeaviest = pSDKWeapon;
			continue;
		}

		if (pHeaviest->GetWeight() < pSDKWeapon->GetWeight())
			pHeaviest = pSDKWeapon;
	}

	if (!pHeaviest)
		pHeaviest = pBrawl;

	return pHeaviest;
}
开发者ID:jlwitthuhn,项目名称:DoubleAction,代码行数:47,代码来源:sdk_player_shared.cpp


示例15: VPROF

//-----------------------------------------------------------------------------
// Purpose: Called every usercmd by the player PostThink
//-----------------------------------------------------------------------------
void CBasePlayer::ItemPostFrame()
{
	VPROF( "CBasePlayer::ItemPostFrame" );

	// Put viewmodels into basically correct place based on new player origin
	CalcViewModelView( EyePosition(), EyeAngles() );

	// check if the player is using something
	if ( m_hUseEntity != NULL )
	{
#if !defined( CLIENT_DLL )
		ImpulseCommands();// this will call playerUse
#endif
		return;
	}

    if ( gpGlobals->curtime < m_flNextAttack )
	{
		if ( GetActiveWeapon() )
		{
			GetActiveWeapon()->ItemBusyFrame();
		}
	}
	else
	{
		if ( GetActiveWeapon() )
		{
#if defined( CLIENT_DLL )
			// Not predicting this weapon
			if ( GetActiveWeapon()->IsPredicted() )
#endif

			{
				GetActiveWeapon()->ItemPostFrame( );
			}
		}
	}

#if !defined( CLIENT_DLL )
	ImpulseCommands();
#else
	// NOTE: If we ever support full impulse commands on the client,
	// remove this line and call ImpulseCommands instead.
	m_nImpulse = 0;
#endif
}
开发者ID:EspyEspurr,项目名称:game,代码行数:49,代码来源:baseplayer_shared.cpp


示例16: GetActiveWeapon

//-----------------------------------------------------------------------------
// Purpose: called every frame to get ammo info from the weapon
//-----------------------------------------------------------------------------
void CDoDHudAmmo::OnThink()
{
    C_BaseCombatWeapon *wpn = GetActiveWeapon();
    C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();

    hudlcd->SetGlobalStat( "(weapon_print_name)", wpn ? wpn->GetPrintName() : " " );
    hudlcd->SetGlobalStat( "(weapon_name)", wpn ? wpn->GetName() : " " );

    if ( !wpn || !player || !wpn->UsesPrimaryAmmo() )
    {
        hudlcd->SetGlobalStat( "(ammo_primary)", "n/a" );
        hudlcd->SetGlobalStat( "(ammo_secondary)", "n/a" );

        SetPaintEnabled( false );
        SetPaintBackgroundEnabled( false );
        return;
    }
    else
    {
        SetPaintEnabled( true );
        SetPaintBackgroundEnabled( true );
    }

    // get the ammo in our clip
    int ammo1 = wpn->Clip1();
    int ammo2;
    if ( ammo1 < 0 )
    {
        // we don't use clip ammo, just use the total ammo count
        ammo1 = player->GetAmmoCount( wpn->GetPrimaryAmmoType() );
        ammo2 = 0;
    }
    else
    {
        // we use clip ammo, so the second ammo is the total ammo
        ammo2 = player->GetAmmoCount( wpn->GetPrimaryAmmoType() );
    }

    hudlcd->SetGlobalStat( "(ammo_primary)", VarArgs( "%d", ammo1 ) );
    hudlcd->SetGlobalStat( "(ammo_secondary)", VarArgs( "%d", ammo2 ) );

    if ( wpn == m_hCurrentActiveWeapon )
    {
        // same weapon, just update counts
        SetAmmo( ammo1, true );
        SetAmmo2( ammo2, true );
    }
    else
    {
        // diferent weapon, change without triggering
        SetAmmo( ammo1, false );
        SetAmmo2( ammo2, false );

        // update whether or not we show the total ammo display
        m_bUsesClips = wpn->UsesClipsForAmmo1();
        m_hCurrentActiveWeapon = wpn;
    }
}
开发者ID:steadyfield,项目名称:SourceEngine2007,代码行数:61,代码来源:dod_hud_playerstatus_ammo.cpp


示例17: GetViewModelFOV

//-----------------------------------------------------------------------------
// Purpose: Use correct view model FOV
//-----------------------------------------------------------------------------
float ClientModeHL2MPNormal::GetViewModelFOV()
{
	CWeaponHL2MPBase *pWeapon = dynamic_cast<CWeaponHL2MPBase*>(GetActiveWeapon());
	if (pWeapon)
	{
		return pWeapon->GetViewModelFOV();
	}

	return BaseClass::GetViewModelFOV();
}
开发者ID:Ochii,项目名称:nt-revamp,代码行数:13,代码来源:clientmode_hl2mpnormal.cpp


示例18: GetActiveWeapon

//-----------------------------------------------------------------------------
// Only supports weapons that use clips.
//-----------------------------------------------------------------------------
bool CRebelZombie::ActiveWeaponIsFullyLoaded()
{
	CBaseCombatWeapon *pWeapon = GetActiveWeapon();

	if( !pWeapon )
		return false;

	//Always loaded.
	return true;
}
开发者ID:KyleGospo,项目名称:City-17-Episode-One-Source,代码行数:13,代码来源:npc_rebelzombie.cpp


示例19: GetActiveWeapon

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_BaseViewModel::GetBoneControllers(float controllers[MAXSTUDIOBONECTRLS])
{
	BaseClass::GetBoneControllers( controllers );

	// Tell the weapon itself that we've rendered, in case it wants to do something
	C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
	if ( pWeapon )
	{
		pWeapon->GetViewmodelBoneControllers( this, controllers );
	}
}
开发者ID:malortie,项目名称:ulaval,代码行数:14,代码来源:c_baseviewmodel.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetActiveWindow函数代码示例发布时间:2022-05-30
下一篇:
C++ GetActiveView函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap