Ejemplo n.º 1
0
//------------------------------------------------------------------------
void CBurst::StartFire()
{
	if (!m_bursting && !m_fireTriggerDown)
	{
		m_fireTriggerDown = true;
		if (m_next_burst <= 0.0f)
		{
			CSingle::StartFire();

			if(m_fired)	//Only set if first shot was successful
			{
				IEntityClass* ammo = GetShared()->fireparams.ammo_type_class;
				
				// We need to add 1, because Single decreased one the ammo count already
				int ammoCount = (m_pWeapon->GetAmmoCount(ammo) + 1); 

				const CTagDefinition* pTagDefinition = NULL;
					
				int fragmentID = m_pWeapon->GetFragmentID("burst_fire", &pTagDefinition);
				if (fragmentID != FRAGMENT_ID_INVALID)
				{
					TagState actionTags = TAG_STATE_EMPTY;

					if(pTagDefinition)
					{
						CTagState fragTags(*pTagDefinition);
						m_pWeapon->SetAmmoCountFragmentTags(fragTags, ammoCount);
						actionTags = fragTags.GetMask();
					}
						
					CBurstFireAction* pAction = new CBurstFireAction(PP_PlayerAction, fragmentID, this, actionTags);

					if(m_fireParams->burstparams.useBurstSoundParam)
					{
						float param = 0.f;

						int burstLength = m_fireParams->burstparams.nshots;

						param = (float)min(burstLength, ammoCount);
						pAction->SetParam(CItem::sActionParamCRCs.burstFire, param);
					}

					m_pWeapon->PlayFragment(pAction, -1.f, -1.f, GetFireAnimationWeight(), GetFireFFeedbackWeight(), false);
				}

				m_next_burst = m_next_burst_dt;
				m_bursting = true;
				m_pWeapon->SetItemFlag(CItem::eIF_BlockActions, true);
			}
		}
	}
}
Ejemplo n.º 2
0
void CShotgun::EndReload(int zoomed)
{
	CActor *pActor = m_pWeapon->GetOwnerActor();

	float speedOverride = 1.0f;
	if (m_reload_was_broken)
	{
		speedOverride = m_fireParams->shotgunparams.endReloadSpeedOverride;
	}
	else
	{
		speedOverride = GetReloadSpeedMultiplier(pActor);
	}


	uint32 animTime = 100;
	uint32 reloadBreakTime = uint32(m_fireParams->shotgunparams.reloadBreakTime * 1000);

	const CTagDefinition* pTagDefinition = NULL;
	int fragmentID = m_pWeapon->GetFragmentID("exit_reload", &pTagDefinition);
	if(fragmentID != FRAGMENT_ID_INVALID)
	{
		TagState actionTags = TAG_STATE_EMPTY;
		if(pTagDefinition && m_reload_pump && !m_reload_was_broken)
		{
			CTagState fragTags(*pTagDefinition);
				
			fragTags.SetByCRC(CItem::sFragmentTagCRCs.ammo_empty, true);

			actionTags = fragTags.GetMask();
		}

		CItemAction* pAction = new CItemAction(PP_PlayerAction, fragmentID, actionTags);
		m_pWeapon->PlayFragment(pAction, speedOverride);
	}

	animTime = m_pWeapon->GetCurrentAnimationTime(eIGS_Owner);

	if(!m_reload_was_broken)
		m_pWeapon->GetScheduler()->TimerAction(animTime, CSchedulerAction<ReloadEndAction>::Create(ReloadEndAction(m_pWeapon, zoomed)), false);
	else
		m_pWeapon->GetScheduler()->TimerAction(reloadBreakTime, CSchedulerAction<ReloadEndAction>::Create(ReloadEndAction(m_pWeapon, zoomed)), false);

	m_pWeapon->SendEndReload();
}
Ejemplo n.º 3
0
void CActionItemIdle::UpdateFragmentTags()
{
	CItem* pItem = static_cast<CItem*>(m_ownerPlayer.GetCurrentItem());
	CWeapon* pWeapon = pItem ? static_cast<CWeapon*>(pItem->GetIWeapon()) : 0;
	const CTagDefinition* pTagDefinition = m_context->controllerDef.GetFragmentTagDef(m_fragmentID);

	if(pItem && pTagDefinition)
	{
		CTagState fragTags(*pTagDefinition);
		fragTags = m_fragTags;
		pItem->SetFragmentTags(fragTags);
		m_fragTags = fragTags.GetMask();
	}
	if (pWeapon)
	{
		SetParam(CItem::sActionParamCRCs.zoomTransition, pWeapon->GetZoomTransition());
	}
}
Ejemplo n.º 4
0
//------------------------------------------------------------------------
_smart_ptr<IAction> CItem::PlayAction(FragmentID action, int layer, bool loop, uint32 flags, float speedOverride, float animWeigth, float ffeedbackWeight)
{
    _smart_ptr<IAction> pAction;

    const CWeapon* pWeapon = static_cast<CWeapon*>(GetIWeapon());
    if (pWeapon && pWeapon->IsProxyWeapon())
        {
            return pAction;
        }

    IActionController* pActionController = GetActionController();

    if (pActionController && action != FRAGMENT_ID_INVALID)
        {
            SAnimationContext& animContext = pActionController->GetContext();
            const CTagDefinition* pTagDefinition = animContext.controllerDef.GetFragmentTagDef(action);
            float timeOverride = -1.0f;

            bool concentratedFire = (flags&eIPAF_ConcentratedFire) != 0;

            TagState actionTags = TAG_STATE_EMPTY;

            if (pTagDefinition)
                {
                    CTagState fragTags(*pTagDefinition);

                    SetFragmentTags(fragTags);
                    actionTags = fragTags.GetMask();
                }

            pAction = new CItemAction(PP_PlayerAction, action, actionTags);

            PlayFragment(pAction, speedOverride, timeOverride, animWeigth, ffeedbackWeight, concentratedFire);
        }

    return pAction;
}