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


C++ GetWeapon函数代码示例

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


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

示例1: GetWeapon

//--------------------------------------------
void CLaser::TurnOnLaser(bool manual /*= false*/)
{
	CWeapon* pParentWeapon = GetWeapon();
	if(pParentWeapon == NULL)
		return;

	m_laserHelperFP.clear();
	const SAccessoryParams *params = GetWeapon()->GetAccessoryParams(GetEntity()->GetClass());
	if (params)
		m_laserHelperFP = params->attach_helper;

	int slot = pParentWeapon->IsOwnerFP() ? eIGS_FirstPerson: eIGS_ThirdPerson;

	CActor* pOwner = pParentWeapon->GetOwnerActor();
	GetGameObject()->EnableUpdateSlot(this, eIUS_General);
	if (pOwner && pOwner->IsPlayer())
		pParentWeapon->SetFiringLocator(this);
	m_laserBeam.TurnOnLaser();

	//Turn off crosshair
	if (pParentWeapon->IsOwnerClient())
	{
		pParentWeapon->SetCrosshairMode(CWeapon::eWeaponCrossHair_ForceOff);
		pParentWeapon->FadeCrosshair(0.0f, g_pGame->GetUI()->GetCVars()->hud_Crosshair_laser_fadeOutTime);
	}
}
开发者ID:Kufusonic,项目名称:Work-in-Progress-Sonic-Fangame,代码行数:27,代码来源:Laser.cpp

示例2: GetAmmoCount

void CSpammer::UpdateLoadIn(float frameTime)
{
	const int currentAmmoCount = GetAmmoCount();
	const bool infiniteAmmo = (GetClipSize() < 0);

	if ((!infiniteAmmo) && (m_numLoadedRockets >= currentAmmoCount))
	{
		GetWeapon()->PlayAction(GetFragmentIds().empty_clip);
		StopFire();
		return;
	}

	const SSpammerParams& params = GetShared()->spammerParams;

	const float loadInTime = 1.0f / (params.loadInRate / 60.0f);
	m_timer -= frameTime;

	while (m_timer < 0.0f && m_numLoadedRockets < params.maxNumRockets)
	{
		m_timer += loadInTime;
		AddTarget();
		GetWeapon()->PlayAction(GetFragmentIds().cock);
	}

	if (m_numLoadedRockets != m_targetsAssigned.GetNumLockOns())
	{
		EntityId nextTarget = GetNextLockOnTarget();
		if (nextTarget != 0)
			m_targetsAssigned.LockOn(nextTarget);
	}
}
开发者ID:PiratesAhoy,项目名称:HeartsOfOak-Core,代码行数:31,代码来源:Spammer.cpp

示例3: GetWeapon

void CCinematicInput::UpdateWeapons()
{
	CWeapon* pPrimaryWeapon = GetWeapon(eWeapon_Primary);
	CWeapon* pSecondaryWeapon = GetWeapon(eWeapon_Secondary);

	const bool doUpdate = (pPrimaryWeapon != NULL) || (pSecondaryWeapon != NULL);
	if (doUpdate)
	{
		const CCamera& camera = gEnv->pSystem->GetViewCamera();

		const Vec3 viewPosition  = camera.GetPosition();
		const Vec3 viewDirection = camera.GetViewdir();

		// Update raycast
		if (m_aimingRayID == 0)
		{
			IEntity *pIgnoredEntity = gEnv->pEntitySystem->GetEntity(m_weapons[eWeapon_Primary].m_parentId);
			IEntity *pIgnoredEntity2 = gEnv->pEntitySystem->GetEntity(m_weapons[eWeapon_Secondary].m_parentId);
			int ignoreCount = 0;
			IPhysicalEntity *pIgnoredEntityPhysics[2] = { NULL, NULL };
			if (pIgnoredEntity)
			{
				pIgnoredEntityPhysics[ignoreCount] = pIgnoredEntity->GetPhysics();
				ignoreCount += pIgnoredEntityPhysics[ignoreCount] ? 1 : 0;
			}
			if (pIgnoredEntity2 && (pIgnoredEntity2 != pIgnoredEntity))
			{
				pIgnoredEntityPhysics[ignoreCount] = pIgnoredEntity2->GetPhysics();
				ignoreCount += pIgnoredEntityPhysics[ignoreCount] ? 1 : 0;
			}

			m_aimingRayID = g_pGame->GetRayCaster().Queue(
				RayCastRequest::HighestPriority,
				RayCastRequest(viewPosition, viewDirection * CINEMATIC_INPUT_MAX_AIM_DISTANCE,
				ent_all|ent_water,
				rwi_stop_at_pierceable|rwi_ignore_back_faces,
				pIgnoredEntityPhysics,
				ignoreCount),
				functor(*this, &CCinematicInput::OnRayCastDataReceived));
		}

		// Update weapon orientation
		const Vec3 aimTargetPosition = viewPosition + (viewDirection * m_aimingDistance);
		if (pPrimaryWeapon != NULL)
		{
			UpdateWeaponOrientation( pPrimaryWeapon->GetEntity(), aimTargetPosition );
		}

		if (pSecondaryWeapon != NULL)
		{
			UpdateWeaponOrientation( pSecondaryWeapon->GetEntity(), aimTargetPosition );
		}
	}
}
开发者ID:danielasun,项目名称:dbho-GameSDK,代码行数:54,代码来源:CinematicInput.cpp

示例4: GetCurrentWeaponSlot

void CPedSA::SetCurrentWeaponSlot ( eWeaponSlot weaponSlot )
{
    if ( weaponSlot < WEAPONSLOT_MAX )
    {
        eWeaponSlot currentSlot = GetCurrentWeaponSlot ();
        if ( weaponSlot != GetCurrentWeaponSlot () )
        {
            CWeapon * pWeapon = GetWeapon ( currentSlot );
            if ( pWeapon ) RemoveWeaponModel ( pWeapon->GetInfo ( WEAPONSKILL_STD )->GetModel () );

            CPedSAInterface * thisPed = (CPedSAInterface *)this->GetInterface();
         
            // set the new weapon slot
            thisPed->bCurrentWeaponSlot = weaponSlot;

            // is the player the local player?
            CPed * pPed = pGame->GetPools()->GetPedFromRef ( (DWORD)1 );
            //if ( pPed == this && thisPed->pPlayerInfo )
            //{
            
            DWORD dwThis = (DWORD)this->GetInterface();
            if ( pPed == this )
            {
               ((CPlayerInfoSA *)pGame->GetPlayerInfo())->GetInterface()->PlayerPedData.m_nChosenWeapon = weaponSlot;

                DWORD dwFunc = FUNC_MakeChangesForNewWeapon_Slot;
                _asm
                {
                    mov     ecx, dwThis
                    push    weaponSlot
                    call    dwFunc
                }
            }
开发者ID:ntauthority,项目名称:openvice,代码行数:33,代码来源:CPedSA.cpp

示例5: GetWeapon

void WBCompEldHands::ShowWeaponHUD() const
{
	WBEntity* const pWeapon = GetWeapon();
	ASSERT( pWeapon );

	WBCompEldWeapon* const pWeaponComponent = GET_WBCOMP( pWeapon, EldWeapon );
	ASSERT( pWeaponComponent );

	STATIC_HASHED_STRING( HUD );
	STATIC_HASHED_STRING( WeaponIcon );

	{
		WB_MAKE_EVENT( SetWidgetImage, NULL );
		WB_SET_AUTO( SetWidgetImage, Hash, Screen, sHUD );
		WB_SET_AUTO( SetWidgetImage, Hash, Widget, sWeaponIcon );
		WB_SET_AUTO( SetWidgetImage, Hash, Image, pWeaponComponent->GetWeaponIcon() );
		WB_DISPATCH_EVENT( WBWorld::GetInstance()->GetEventManager(), SetWidgetImage, NULL );
	}

	{
		WB_MAKE_EVENT( SetWidgetHidden, NULL );
		WB_SET_AUTO( SetWidgetHidden, Hash, Screen, sHUD );
		WB_SET_AUTO( SetWidgetHidden, Hash, Widget, sWeaponIcon );
		WB_SET_AUTO( SetWidgetHidden, Bool, Hidden, false );
		WB_DISPATCH_EVENT( WBWorld::GetInstance()->GetEventManager(), SetWidgetHidden, NULL );
	}
}
开发者ID:MinorKeyGames,项目名称:Eldritch,代码行数:27,代码来源:wbcompeldhands.cpp

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

示例7: Activate

void CFireMode::Activate(bool activate)
{
	const int numPlugins = m_plugins.size();

	for (int i = 0; i < numPlugins; i++)
	{
		m_plugins[i]->Activate(activate);
	}

	for (TFireModeListeners::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next())
	{
		notifier->OnFireModeActivated(activate);
	}

	if (GetWeapon()->GetOwnerId())
	{
		if (m_pWeapon->IsSelected())
		{
			UpdateMannequinTags(activate);
		}
	}
	else
	{
		UpdateMannequinTags(activate);
	}
}
开发者ID:aronarts,项目名称:FireNET,代码行数:26,代码来源:FireMode.cpp

示例8: GetWeapon

//------------------------------------------------------------------------
int CScriptBind_Weapon::SetAmmoCount(IFunctionHandler *pH)
{
	CWeapon *pWeapon = GetWeapon(pH);
	if (!pWeapon)
		return pH->EndFunction();

	IFireMode* pFireMode = GetRequestedFireMode(pWeapon, pH);

	if (pFireMode)
	{
		if (pH->GetParamType(2) != svtNumber)
			return pH->EndFunction();

		const char *ammoName = 0;
		if (pH->GetParamType(1) == svtString)
			pH->GetParam(1, ammoName);

		IEntityClass* pAmmoType = pFireMode->GetAmmoType();

		if (ammoName)
			pAmmoType = gEnv->pEntitySystem->GetClassRegistry()->FindClass(ammoName);

		int ammo = 0;
		pH->GetParam(2, ammo);

		pWeapon->SetAmmoCount(pAmmoType, ammo);
	}

	return pH->EndFunction();
}
开发者ID:kitnet,项目名称:crynegine,代码行数:31,代码来源:ScriptBind_Weapon.cpp

示例9: ProcessEvent

	void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		if(eFE_Activate == event)
		{
			const bool bAttach = IsPortActive(pActInfo, EIP_ATTACH);
			const bool bDetach = IsPortActive(pActInfo, EIP_DETACH);
			if (!bAttach && !bDetach)
				return;

			IActor* pActor = GetActor(pActInfo);
			if (pActor == 0)
				return;

			const string& className = GetPortString(pActInfo, EIP_WEAPON);

			CWeapon* pWeapon = static_cast<CWeapon*> ( className.empty() ? GetWeapon(pActor) : GetWeapon(pActor, className.c_str()) );
			if (pWeapon != 0)
			{
				ItemString acc = ItemString(GetPortString(pActInfo, EIP_ACCESSORY));
				if (bAttach && pWeapon->GetAccessory(acc) == 0)
				{
					pWeapon->SwitchAccessory(acc);
					ActivateOutput(pActInfo, EOP_ATTACHED, true);
				}
				else if (bDetach && pWeapon->GetAccessory(acc) != 0)
				{
					pWeapon->SwitchAccessory(acc);
					ActivateOutput(pActInfo, EOP_DETACHED, true);
				}
			}
		}
	}
开发者ID:RenEvo,项目名称:dead6,代码行数:32,代码来源:WeaponNodes.cpp

示例10: CHANGED_NETWORK_STATE

void CC4Projectile::Arm(bool arm)
{
	if(arm != m_armed)
	{
		m_armed = arm;

		if(gEnv->bServer)
		{
			CHANGED_NETWORK_STATE(this, ASPECT_C4_STATUS);

			if(CWeapon* pWeapon = GetWeapon())
			{
				CHANGED_NETWORK_STATE(pWeapon, CC4::ASPECT_DETONATE);
			}
		}

		if(m_pStatObj)
		{
			m_pStatObj->SetMaterial(arm ? m_pArmedMaterial : m_pDisarmedMaterial);
		}

		if(m_pLightSource)
		{
			UpdateLight(0.f, true);
		}
	}
}
开发者ID:Xydrel,项目名称:Infected,代码行数:27,代码来源:C4Projectile.cpp

示例11: AutoShootHelper

//------------------------------------------------------------------------
int CScriptBind_Weapon::AutoShoot(IFunctionHandler *pH, int shots, bool autoReload)
{
	struct AutoShootHelper : public IWeaponEventListener
	{
		AutoShootHelper(int n, bool autoreload): m_nshots(n), m_reload(autoreload) {};
		virtual ~AutoShootHelper() {};

		int		m_nshots;
		bool	m_reload;

		virtual void OnShoot(IWeapon *pWeapon, EntityId shooterId, EntityId ammoId, IEntityClass* pAmmoType,
			const Vec3 &pos, const Vec3 &dir, const Vec3 &vel) {};
		virtual void OnStartFire(IWeapon *pWeapon, EntityId shooterId) {};
		virtual void OnStopFire(IWeapon *pWeapon, EntityId shooterId) {};
		virtual void OnStartReload(IWeapon *pWeapon, EntityId shooterId, IEntityClass* pAmmoType) {};
		virtual void OnEndReload(IWeapon *pWeapon, EntityId shooterId, IEntityClass* pAmmoType) {};
		virtual void OnSetAmmoCount(IWeapon *pWeapon, EntityId shooterId) {}
		virtual void OnOutOfAmmo(IWeapon *pWeapon, IEntityClass* pAmmoType)
		{
			if (m_reload)
				pWeapon->Reload(false);
			else
			{
				pWeapon->StopFire();
				pWeapon->RemoveEventListener(this);
			}
		};
		virtual void OnReadyToFire(IWeapon *pWeapon)
		{
			if (!(--m_nshots))
			{
				pWeapon->StopFire();
				pWeapon->RemoveEventListener(this);
			}
			else
			{
				pWeapon->StartFire();
				pWeapon->StopFire();
			}
		};
		virtual void OnPickedUp(IWeapon *pWeapon, EntityId actorId, bool destroyed){}
		virtual void OnDropped(IWeapon *pWeapon, EntityId actorId){}
		virtual void OnMelee(IWeapon* pWeapon, EntityId shooterId){}
		virtual void OnStartTargetting(IWeapon *pWeapon) {}
		virtual void OnStopTargetting(IWeapon *pWeapon) {}
		virtual void OnSelected(IWeapon *pWeapon, bool select) {}
		virtual void OnFireModeChanged(IWeapon *pWeapon, int currentFireMode) {}
		virtual void OnZoomChanged(IWeapon* pWeapon, bool zoomed, int idx) {}
	};

	CWeapon *pWeapon = GetWeapon(pH);
	if (!pWeapon)
		return pH->EndFunction();

	pWeapon->AddEventListener(new AutoShootHelper(shots, autoReload), __FUNCTION__); 	// FIXME: possible small memory leak here. 
	pWeapon->StartFire();
	pWeapon->StopFire();

	return pH->EndFunction();
}
开发者ID:kitnet,项目名称:crynegine,代码行数:61,代码来源:ScriptBind_Weapon.cpp

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

示例13: GetWeapon

void CAutoDefenseClass::Update (CInstalledDevice *pDevice, 
								CSpaceObject *pSource, 
								int iTick,
								bool *retbSourceDestroyed,
								bool *retbConsumedItems)

//	Update
//
//	Update device

	{
	if (pDevice->IsReady() && pDevice->IsEnabled())
		{
		int i;

		//	Look for a target

		CSpaceObject *pBestTarget = NULL;
		Metric rBestDist2 = MAX_INTERCEPT_DISTANCE * MAX_INTERCEPT_DISTANCE;

		for (i = 0; i < pSource->GetSystem()->GetObjectCount(); i++)
			{
			CSpaceObject *pObj = pSource->GetSystem()->GetObject(i);

			if (pObj
					&& pObj->GetCategory() == CSpaceObject::catMissile
					&& pObj->GetSource() != pSource
					&& (pObj->GetSource() == NULL || pSource->IsEnemy(pObj->GetSource())))
				{
				CVector vRange = pObj->GetPos() - pSource->GetPos();
				Metric rDistance2 = vRange.Dot(vRange);

				if (rDistance2 < rBestDist2)
					{
					pBestTarget = pObj;
					rBestDist2 = rDistance2;
					}
				}
			}

		//	If we found a target, try to shoot at it

		if (pBestTarget)
			{
			CDeviceClass *pWeapon = GetWeapon();

			if (pWeapon)
				{
				int iFireAngle;
				if (pWeapon->IsWeaponAligned(pSource, pDevice, pBestTarget, &iFireAngle))
					{
					pDevice->SetFireAngle(iFireAngle);
					pWeapon->Activate(pDevice, pSource, pBestTarget, iFireAngle, retbSourceDestroyed, retbConsumedItems);
					pDevice->SetActivationDelay(m_iRechargeTicks);
					}
				}
			}
		}
	}
开发者ID:alanhorizon,项目名称:Transport,代码行数:59,代码来源:CAutoDefenseClass.cpp

示例14: RemoveListener

	virtual void RemoveListener(EntityId weaponId, IWeaponEventListener* pListener)
	{
		if (!(weaponId && pListener))
			return;

		if (IWeapon* pWeapon = GetWeapon(weaponId))      
			pWeapon->RemoveEventListener(pListener);
	}
开发者ID:aronarts,项目名称:FireNET,代码行数:8,代码来源:FlowWeaponNodes.cpp

示例15: AddListener

	virtual void AddListener(EntityId weaponId, IWeaponEventListener* pListener)
	{
		if (!(weaponId && pListener))
			return;

		if (IWeapon* pWeapon = GetWeapon(weaponId))      
			pWeapon->AddEventListener(pListener, __FUNCTION__);
	}
开发者ID:aronarts,项目名称:FireNET,代码行数:8,代码来源:FlowWeaponNodes.cpp


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