Пример #1
0
	////////////////////////////////////////////////////
	// Execute
	//
	// Purpose: Execute the behavior for this motion
	////////////////////////////////////////////////////
	virtual void Execute(void)
	{
		CBaseMotion::Execute();
		CPlayer *pPlayer = GetPlayer();
		const CGameActions &rGameActions = g_pGame->Actions();

		// Throw item in your hand if you have one
		COffHand* pOffHand = static_cast<COffHand*>(pPlayer->GetWeaponByClass(CItem::sOffHandClass));
		if (NULL != pOffHand)
		{
			int nOffHandState = pOffHand->GetOffHandState();
			if ((nOffHandState&(eOHS_HOLDING_OBJECT|eOHS_THROWING_OBJECT|eOHS_HOLDING_NPC|eOHS_THROWING_NPC)))
			{
				/*pOffHand->OnAction(pPlayer->GetEntityId(), rGameActions.attack1, eIS_Pressed, 1.0f);
				pOffHand->OnAction(pPlayer->GetEntityId(), rGameActions.attack1, eIS_Released, 1.0f);*/
				pOffHand->ThrowObject(eAAM_OnPress,nOffHandState&(eOHS_HOLDING_NPC|eOHS_THROWING_NPC)?true:false);
				pOffHand->ThrowObject(eAAM_OnRelease,nOffHandState&(eOHS_HOLDING_NPC|eOHS_THROWING_NPC)?true:false);
				g_pGame->GetWiiRemoteManager()->FreezeMovement();
				return;
			}

			// Throw a grenade instead
			pOffHand->OnAction(pPlayer->GetEntityId(), rGameActions.grenade, eIS_Pressed, 1.0f);
			pOffHand->OnAction(pPlayer->GetEntityId(), rGameActions.grenade, eIS_Released, 1.0f);
			g_pGame->GetWiiRemoteManager()->FreezeMovement();
		}
	}
Пример #2
0
//----------------------------------------------------------
bool CWeapon::OnActionZoom(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	COffHand * offHandWeapon = NULL;
	bool isOffHandSelected = false;
	GetOffHandInfo(this,isOffHandSelected,&offHandWeapon);

	if (!m_modifying && (!isOffHandSelected || (offHandWeapon->GetOffHandState()&eOHS_TRANSITIONING)))
	{
		if (activationMode == eAAM_OnPress && m_useViewMode)
		{
			IncrementViewmode();
		}
		else
		{
			bool isDualWield = false;
			CWeapon *dualWield = NULL;
			GetDualWieldInfo(this,isDualWield,&dualWield);

			if (!isDualWield)
			{
				if (m_fm && !m_fm->IsReloading())
				{
					if (activationMode == eAAM_OnPress)
					{
						if(!m_fm->AllowZoom())
						{
							if(!IsTargetOn()) //Allow zoom-in, when using aiming helper
								return false;
						}

						if(m_weaponRaised)
						{
							return false;
						}

						//Use mouse wheel for scopes with several steps/stages
						if (m_zm && m_zm->IsZoomed() && m_zm->GetMaxZoomSteps()>1)
							m_zm->StopZoom();
						else
							StartZoom(actorId,1);
					}
					else if (activationMode == eAAM_OnRelease)
					{
						if(m_zm && !m_zm->IsToggle())
							m_zm->StopZoom();
					}
				}
			}
		}
	}

	return true;
}
Пример #3
0
bool CPlayerInput::OnActionUse(EntityId entityId, const ActionId& actionId, int activationMode, float value)
{
	bool filterOut = true;
	IVehicle* pVehicle = m_pPlayer->GetLinkedVehicle();

	//FIXME:on vehicles use cannot be used
	if (pVehicle)
	{
		filterOut = false;
	}
	
	if (activationMode==eAAM_OnPress)
	{
		COffHand* pOffHand = static_cast<COffHand*>(m_pPlayer->GetWeaponByClass(CItem::sOffHandClass));
		IEntity *pEntity=gEnv->pEntitySystem->GetEntity(m_pPlayer->GetGameObject()->GetWorldQuery()->GetLookAtEntityId());

		//Drop objects/npc before enter a vehicle
		if(pOffHand)
		{
			if(pOffHand->GetOffHandState()&(eOHS_HOLDING_OBJECT|eOHS_HOLDING_NPC))
			{
				pOffHand->OnAction(m_pPlayer->GetEntityId(), actionId, activationMode, 0);
				return false;
			}
		}

		//--------------------------LADDERS-----------------------------------------------		
		if(m_pPlayer->m_stats.isOnLadder)
		{
			m_pPlayer->RequestLeaveLadder(CPlayer::eLAT_Use);
			return false;
		}
		else
		{
			if(m_pPlayer->IsLadderUsable())
			{
				m_pPlayer->RequestGrabOnLadder(CPlayer::eLAT_Use);
				return false;
			}
		}
	}

	return filterOut;
}
Пример #4
0
//---------------------------------------------------------------------
bool CWeapon::OnActionSpecial(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	if (activationMode == eAAM_OnPress)
	{
		if(m_weaponRaised)
		{
			RaiseWeapon(false,true);
		}

		COffHand * offHandWeapon = NULL;
		bool isOffHandSelected = false;
		GetOffHandInfo(this,isOffHandSelected,&offHandWeapon);

		if (CanMeleeAttack() && (!isOffHandSelected || (offHandWeapon->GetOffHandState()&(eOHS_HOLDING_NPC|eOHS_TRANSITIONING))))
			MeleeAttack();
	}

	return true;
}
Пример #5
0
//------------------------------------------------------------------------
void CItem::OnPickedUp(EntityId actorId, bool destroyed)
{
    if(GetISystem()->IsSerializingFile() == 1)
        return;

    CActor *pActor=GetActor(actorId);
    if (!pActor)
        return;

    RegisterAsUser();

    if(gEnv->bMultiplayer && pActor->IsClient() && IsSelected())
    {
        COffHand* pOffHand = static_cast<COffHand*>(pActor->GetWeaponByClass(CItem::sOffHandClass));
        if(pOffHand && pOffHand->GetOffHandState()==eOHS_HOLDING_GRENADE)
            pOffHand->FinishAction(eOHA_RESET);
    }

    if (!IsServer())
        return;

    //if (destroyed && m_params.unique)
    {
        if (!m_bonusAccessoryAmmo.empty())
        {
            for (TAccessoryAmmoMap::iterator it=m_bonusAccessoryAmmo.begin(); it!=m_bonusAccessoryAmmo.end(); ++it)
            {
                int count=it->second;

                AddAccessoryAmmoToInventory(it->first,count,pActor);
            }

            m_bonusAccessoryAmmo.clear();
        }
    }

    m_pItemSystem->UnregisterForCollection(GetEntityId());

}
Пример #6
0
//---------------------------------------------------------------------
bool CWeapon::OnActionSpecial(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	if (activationMode == eAAM_OnPress)
	{
		if(m_weaponRaised)
			RaiseWeapon(false,true);

		CActor* pOwnerActor = GetOwnerActor();
		if (pOwnerActor && g_pGameCVars->dt_enable)
		{
			CPlayer *pPlayer = static_cast<CPlayer*>(pOwnerActor);
			pPlayer->GetNanoSuit()->Tap(eNA_Melee);
		}

		COffHand * offHandWeapon = NULL;
		bool isOffHandSelected = false;
		GetOffHandInfo(this,isOffHandSelected,&offHandWeapon);

		if (CanMeleeAttack() && (!isOffHandSelected || (offHandWeapon->GetOffHandState()&(eOHS_HOLDING_NPC|eOHS_TRANSITIONING))))
			MeleeAttack();
	}

	return true;
}
Пример #7
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;
}
Пример #8
0
void CHUDCrosshair::UpdateCrosshair()
{
  IActor *pClientActor = g_pGame->GetIGameFramework()->GetClientActor();
	if(!pClientActor)
		return;

  int iNewFriendly = 0;

  if(pClientActor->GetLinkedVehicle())
  { 
    // JanM/MichaelR: 
    // Get status from the VehicleWeapon, which raycasts considering the necessary SkipEntities (in contrast to WorldQuery)
    // Julien: this is now done in MP as well
    iNewFriendly = g_pHUD->GetVehicleInterface()->GetFriendlyFire();
  }
  else
  {
    if(!gEnv->bMultiplayer)
    {
			CWeapon *pWeapon = g_pHUD->GetCurrentWeapon();
			if(pWeapon)
			{
				iNewFriendly = pWeapon->IsWeaponLowered() && pWeapon->IsPendingFireRequest();
				if(iNewFriendly && pWeapon->GetEntity()->GetClass() == CItem::sTACGunFleetClass)
					iNewFriendly = 0;
			}
			else{
				//Two handed pickups need the red X as well
				CPlayer *pPlayer= static_cast<CPlayer*>(pClientActor);
				if(CWeapon *pOffHand = static_cast<CWeapon*>(pPlayer->GetItemByClass(CItem::sOffHandClass)))
					iNewFriendly = pOffHand->IsWeaponLowered();
			}
    }
    else
    {
	    EntityId uiCenterId = pClientActor->GetGameObject()->GetWorldQuery()->GetLookAtEntityId();
			if(uiCenterId)
			{
				iNewFriendly = IsFriendlyEntity(gEnv->pEntitySystem->GetEntity(uiCenterId));
			}
    }
  }	

	// SNH: if player is carrying a claymore or mine, ask the weapon whether it is possible to place it currently
	//	(takes into account player speed / stance / aim direction).
	// So 'friendly' is a bit of a misnomer here, but we want the "don't/can't fire" crosshair...
	if(iNewFriendly != 1 && g_pHUD)
	{
		CWeapon *pWeapon = g_pHUD->GetCurrentWeapon();
		if(pWeapon)
		{
			static IEntityClass* pClaymoreClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("Claymore");
			static IEntityClass* pAVMineClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("AVMine");
			IEntityClass* pClass = pWeapon->GetEntity()->GetClass();
			if(pClass == pClaymoreClass || pClass == pAVMineClass)
			{
				if(IFireMode* pfm = pWeapon->GetFireMode(pWeapon->GetCurrentFireMode()))
				{
					if(!pfm->IsFiring())
						iNewFriendly = pWeapon->CanFire() ? 0 : 1;
				}
			}
		}
	}

	if(iNewFriendly != m_iFriendlyTarget)
	{
		m_iFriendlyTarget = iNewFriendly;
		//m_animCrossHair.Invoke("setFriendly", m_iFriendlyTarget);
		if(iNewFriendly)
			m_animFriendCross.SetVisible(true);
		else
			m_animFriendCross.SetVisible(false);
	}

	if(m_animInterActiveIcons.GetVisible())
	{
		m_bHideUseIconTemp = false;
		CItem *pItem = static_cast<CItem*>(pClientActor->GetCurrentItem());
		if(pItem)
		{
			IWeapon *pWeapon = pItem->GetIWeapon();
			if(pWeapon)
			{
				CItem::SStats stats = pItem->GetStats();
				if(stats.mounted && stats.used)
					m_bHideUseIconTemp = true;
			}
		}
		if(!m_bHideUseIconTemp)
		{
			EntityId offHandId = pClientActor->GetInventory()->GetItemByClass(CItem::sOffHandClass);
			IItem *pOffHandItem = g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem(offHandId);
			if(pOffHandItem)
			{
				COffHand *pOffHand = static_cast<COffHand*>(pOffHandItem);
				uint32 offHandState = pOffHand->GetOffHandState();
				if(offHandState == eOHS_HOLDING_OBJECT || offHandState == eOHS_THROWING_OBJECT ||
					offHandState == eOHS_HOLDING_NPC || offHandState == eOHS_THROWING_NPC)
					m_bHideUseIconTemp = true;
			}
		}
	}
}
Пример #9
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;
}