Ejemplo n.º 1
0
//---------------------------------------------------------------------------------
bool CWeapon::OnActionFiremode(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	if (activationMode==eAAM_OnPress)
	{
		bool isDualWield = false;
		CWeapon *dualWield = NULL;
		GetDualWieldInfo(this,isDualWield,&dualWield);

		if (isDualWield)
		{
			if(IsWeaponRaised())
				RaiseWeapon(false,true);

			if(dualWield->IsWeaponRaised())
				dualWield->RaiseWeapon(false,true);

			StartChangeFireMode();
		}
		else
		{
			if(m_weaponRaised)
				RaiseWeapon(false,true);

			StartChangeFireMode();
		}
	}

	return true;
}
Ejemplo n.º 2
0
//---------------------------------------------------------
bool CWeapon::OnActionReload(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	if(activationMode==eAAM_OnPress)
	{
		COffHand * offHandWeapon = NULL;
		bool isOffHandSelected = false;
		GetOffHandInfo(this,isOffHandSelected,&offHandWeapon);

		if (!IsBusy() && !m_modifying && !isOffHandSelected)
		{
			bool isDualWield = false;
			CWeapon *dualWield = NULL;
			GetDualWieldInfo(this,isDualWield,&dualWield);

			if(IsWeaponRaised() && m_fm && m_fm->CanReload())
				RaiseWeapon(false);

			Reload();

			if (isDualWield)
			{
				if(dualWield->IsWeaponRaised() && dualWield->CanReload())
					dualWield->RaiseWeapon(false);
				dualWield->Reload();
			}
		}
	}

	return true;
}
Ejemplo n.º 3
0
//------------------------------------------------------
void CWeapon::ForcePendingActions(uint8 blockedActions)
{
	CItem::ForcePendingActions(blockedActions);

	CActor* pOwner = GetOwnerActor();
	if(!pOwner || !pOwner->IsClient())
		return;

	//Force start firing, if needed and possible
	if(m_requestedFire)
	{
		if(!IsDualWield() && !IsWeaponRaised())
		{
			m_requestedFire = false;
			OnAction(GetOwnerId(),"attack1",eAAM_OnPress,0.0f);
		}
		else if(IsDualWield() && IsDualWieldMaster())
		{
			IItem *slave = GetDualWieldSlave();
			if(!IsWeaponRaised())
			{
				m_requestedFire = false;
				OnAction(GetOwnerId(),"attack1",eAAM_OnPress,0.0f);
			}
			else if(slave && slave->GetIWeapon())
			{
				CWeapon* dualwield = static_cast<CWeapon*>(slave);
				if(!dualwield->IsWeaponRaised())
				{
					m_requestedFire = false;
					OnAction(GetOwnerId(),"attack1",eAAM_OnPress,0.0f);
				}
			}
		}
	}
}
Ejemplo n.º 4
0
//--------------------------------------------------------------------
bool CWeapon::OnActionAttack(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	if(!m_modifying)
	{
		COffHand * offHandWeapon = NULL;
		bool isOffHandSelected = false;
		GetOffHandInfo(this,isOffHandSelected,&offHandWeapon);

		if(IsTwoHand())
		{
			if(offHandWeapon && 
				(offHandWeapon->GetOffHandState()&(eOHS_HOLDING_GRENADE|eOHS_SWITCHING_GRENADE|eOHS_PICKING_ITEM)))
				return false;
		}

		if (activationMode == eAAM_OnPress)
		{

			if(PreActionAttack(true))
				return true;

			bool isDualWield = false;
			CWeapon *dualWield = NULL;
			GetDualWieldInfo(this,isDualWield,&dualWield);

			// EXPANSION: Dino has rewritten dual wield control!
			/*if (isDualWield)
			{
				m_fire_alternation = !m_fire_alternation;
				m_requestedFire = true;

				if (!m_fire_alternation && dualWield->OutOfAmmo(false) && dualWield->CanReload())
				{
					dualWield->Reload();
					return true;
				}
				else if(m_fire_alternation && OutOfAmmo(false) && CanReload())
				{
					Reload();
					return true;
				}

				if (m_fire_alternation || (!dualWield->CanFire() || !dualWield->IsSelected()))
				{
					if(!IsWeaponRaised() && CanFire())
						StartFire();
					else if(!dualWield->IsWeaponRaised() && dualWield->IsSelected())
						dualWield->StartFire();
				}
				else if (dualWield->CanFire())
				{
					if(!dualWield->IsWeaponRaised() && dualWield->CanFire())
						dualWield->StartFire();
					else if(!IsWeaponRaised())
						StartFire();
				}
			}*/
			// /EXPANSION
		
			if (isDualWield)
			{
				if (offHandWeapon && !(offHandWeapon->GetOffHandState() & (eOHS_INIT_STATE)))
					return false;

				m_fire_alternation = false;
								
				if (!dualWield->IsWeaponRaised())// && dualWield->CanFire())
				{
					dualWield->StartFire();
				}
			/*	else if(dualWield->OutOfAmmo(false) && !dualWield->IsReloading())
				{
					dualWield->Reload();
				}*/

				dualWield->m_requestedFire = true;
			}
			else
			{
				if(!m_weaponRaised)
				{
					StartFire();
				}

				m_requestedFire = true;
			}
		}
		else if (activationMode == eAAM_OnRelease)
		{
			PreActionAttack(false);

			// EXP 1: Don't stop both slave and master simultaneously!!!
				//Stop slave
			if(IsDualWieldMaster())
			{
				//FireSlave(actorId,false);
				CWeapon *dualWield = NULL;
				IItem *slave = GetDualWieldSlave();

				if (slave && slave->GetIWeapon())
					dualWield = static_cast<CWeapon *>(slave);

				if(dualWield)
				{
					dualWield->StopFire();
					dualWield->m_requestedFire=false;
				}

			}
			else if (m_fm)
			{
				m_fm->StopFire();
				m_requestedFire = false;
			}
			// StopFire();
			// /EXP 1
		}
	}

	return true;
}
Ejemplo n.º 5
0
//--------------------------------------------------------------------
bool CWeapon::OnActionAttack(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	if(!m_modifying)
	{
		if(IsTwoHand())
		{
			COffHand * offHandWeapon = NULL;
			bool isOffHandSelected = false;
			GetOffHandInfo(this,isOffHandSelected,&offHandWeapon);

			if(offHandWeapon && 
				(offHandWeapon->GetOffHandState()&(eOHS_HOLDING_GRENADE|eOHS_SWITCHING_GRENADE|eOHS_PICKING_ITEM)))
				return false;
		}

		if (activationMode == eAAM_OnPress)
		{

			if(PreActionAttack(true))
				return true;

			bool isDualWield = false;
			CWeapon *dualWield = NULL;
			GetDualWieldInfo(this,isDualWield,&dualWield);

			if (isDualWield)
			{
				m_fire_alternation = !m_fire_alternation;
				m_requestedFire = true;

				if (m_fire_alternation || !dualWield->CanFire())
				{
					if(!IsWeaponRaised() && CanFire())
						StartFire();
					else if(!dualWield->IsWeaponRaised())
						dualWield->StartFire();
				}
				else if (dualWield->CanFire())
				{
					if(!dualWield->IsWeaponRaised() && dualWield->CanFire())
						dualWield->StartFire();
					else if(!IsWeaponRaised())
						StartFire();
				}
				else if(OutOfAmmo(false))
				{
					Reload();
					dualWield->Reload();
				}
			}
			else
			{
				if(!m_weaponRaised)
					StartFire();

				m_requestedFire = true;
			}
		}
		else if (activationMode == eAAM_OnRelease)
		{
			PreActionAttack(false);

			StopFire();
			m_requestedFire = false;
		}
	}

	return true;
}