Exemple #1
0
//------------------------------------------------------------------------
void CVehicleWeapon::StartUse(EntityId userId)
{
	if (m_ownerId && userId != m_ownerId)
		return; 

  if (GetEntity()->GetParent())
  { 
    m_pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(GetEntity()->GetParent()->GetId());
    assert(m_pVehicle && "Using VehicleWeapons on non-vehicles may lead to unexpected behavior.");

    if (m_pVehicle)
    {   
      m_pPart = m_pVehicle->GetWeaponParentPart(GetEntityId()); 
      m_pOwnerSeat = m_pVehicle->GetWeaponParentSeat(GetEntityId());
      m_pSeatUser = m_pVehicle->GetSeatForPassenger(userId);
    }
  }
  
	SetOwnerId(userId);
  Select(true);	
	m_stats.used = true;

	EnableUpdate(true, eIUS_General);
	RequireUpdate(eIUS_General);

  if (OutOfAmmo(false))
    Reload(false);

  UseManualBlending(true);

	LowerWeapon(false);

	SendMusicLogicEvent(eMUSICLOGICEVENT_WEAPON_MOUNT);

}
void CHeavyMountedWeapon::ProcessEvent(SEntityEvent& event)
{
	if ((event.event == ENTITY_EVENT_XFORM) && IsMounted() && GetOwnerId())
	{
		const float Z_EPSILON = 0.01f;
		const Ang3& worldAngles = GetEntity()->GetWorldAngles();
		float xAngle = worldAngles.x;
		float zAngle = worldAngles.z;
		bool xAnglesAreEquivalent = (fabs(xAngle-m_lastXAngle)<Z_EPSILON);
		bool zAnglesAreEquivalent = (fabs(zAngle-m_lastZAngle)<Z_EPSILON);
		if (!xAnglesAreEquivalent || !zAnglesAreEquivalent)
		{
			if (m_rotatingSoundID==INVALID_SOUNDID)
				m_rotatingSoundID = PlayRotationSound();
			m_RotationSoundTimeOut = 0.15f;
			RequireUpdate( eIUS_General );
			m_lastXAngle = xAngle;
			m_lastZAngle = zAngle;
		}
			
		int flags = (int)event.nParam[0];
		if ((flags & ENTITY_XFORM_FROM_PARENT) && !(flags & ENTITY_XFORM_USER))
		{
			if (CActor* pOwnerActor = GetOwnerActor())
			{
				pOwnerActor->UpdateMountedGunController(true);
			}
		}
	}

	BaseClass::ProcessEvent(event);
}
Exemple #3
0
void CJaw::Update(SEntityUpdateContext& ctx, int slot)
{
	CWeapon::Update(ctx, slot);

	if (!IsSelected())
		return;

	if(slot == eIUS_Zooming)
	{
		UpdateLaser(ctx);
	}

	if (slot != eIUS_General)
		return;

	UpdatePendingShot();

	if (!IsInputFlagSet(CWeapon::eWeaponAction_Zoom) && IsInputFlagSet(CWeapon::eWeaponAction_Fire) && !IsZoomingIn())
		AutoZoomOut();

	if (m_controllingRocket && !IsZoomed() && !m_zoomTriggerDown)
		DoAutoDrop();

	if (m_autoDropping)
	{
		m_autoDropPendingTimer += ctx.fFrameTime;
		if (CanAutoDrop())
		{
			m_autoDropping = false;
			DoAutoDrop();
		}
	}

	if (m_dropped)
	{
		m_dropTime += ctx.fFrameTime;
		if (m_dropTime > g_hideTimeAfterDrop)
		{
			if(gEnv->bServer)
			{
				if(gEnv->IsEditor())
					Hide(true);
				else
					gEnv->pEntitySystem->RemoveEntity(GetEntity()->GetId());	
			}
			EnableUpdate(false);
		}
		else
		{
			RequireUpdate();
		}
	}
}
Exemple #4
0
//=======================================
void CRocketLauncher::Update(SEntityUpdateContext& ctx, int slot)
{
	FUNCTION_PROFILER(GetISystem(), PROFILE_GAME);

	CWeapon::Update(ctx,slot);

	if(slot==eIUS_General && m_laserTPOn)
	{
		UpdateTPLaser(ctx.fFrameTime);
		RequireUpdate(eIUS_General);
	}
}
void CHeavyMountedWeapon::Update( SEntityUpdateContext& ctx, int slot )
{
	BaseClass::Update(ctx, slot);
	
	if (m_rotatingSoundID!=INVALID_SOUNDID)
	{
		if (m_RotationSoundTimeOut>0)
		{
			m_RotationSoundTimeOut -= ctx.fFrameTime;
			RequireUpdate( eIUS_General );
		}
		else
		{
			StopSound(m_rotatingSoundID);
			m_rotatingSoundID = INVALID_SOUNDID;
		}
	}

	// Helper for editor placing
	if (gEnv->IsEditing())
	{
		// If host id is not 0, it means it is mounted to a vehicle, so don't render the helper in that case
		if (!GetHostId())
		{
			IRenderAuxGeom* pRenderAux = gEnv->pRenderer->GetIRenderAuxGeom();

			const Matrix34& weaponTM = GetEntity()->GetWorldTM();
			const Vec3 point1 = weaponTM.GetTranslation();
			const Vec3 point2 = point1 - (m_sharedparams->pMountParams->ground_distance * weaponTM.GetColumn2());
			const Vec3 point3 = point2 - (m_sharedparams->pMountParams->body_distance * weaponTM.GetColumn1());

			pRenderAux->DrawLine(point1, ColorB(0, 192, 0), point2, ColorB(0, 192, 0), 3.0f);
			pRenderAux->DrawLine(point2, ColorB(0, 192, 0), point3, ColorB(0, 192, 0), 3.0f);
			pRenderAux->DrawSphere(point3, 0.15f, ColorB(192, 0, 0));

			RequireUpdate(eIUS_General);
		}
	}
}
Exemple #6
0
//------------------------------------------------------------------------
void CVehicleWeapon::StartUse(EntityId userId)
{
	if (m_owner.GetId() && userId != m_owner.GetId())
		return; 

  if (GetEntity()->GetParent())
  { 
		const EntityId vehicleId = GetEntity()->GetParent()->GetId();
		m_vehicleId = vehicleId;
    IVehicle* pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(vehicleId);
    assert(pVehicle && "Using VehicleWeapons on non-vehicles may lead to unexpected behavior.");

    if (pVehicle)
    {
      IVehicleSeat* pOwnerSeat = pVehicle->GetWeaponParentSeat(GetEntityId());
      IVehicleSeat* pSeatUser = pVehicle->GetSeatForPassenger(userId);
			m_bOwnerInSeat = (pOwnerSeat == pSeatUser);

			if(userId == g_pGame->GetIGameFramework()->GetClientActorId())
			{
				pVehicle->RegisterVehicleEventListener(this, "CVehicleWeapon");
			}
    }
  }
  
	SetOwnerId(userId);
  Select(true);	
	m_stats.used = true;

	EnableUpdate(true, eIUS_General);
	RequireUpdate(eIUS_General);

  if (OutOfAmmo(false))
    Reload(false);

  m_shootCounter = 0;
	
	if(userId == g_pGame->GetIGameFramework()->GetClientActorId())
	{
		SHUDEvent	event;

		event.eventType			= eHUDEvent_OnItemSelected;
		event.eventIntData	= CItem::GetEntityId();

		CHUDEventDispatcher::CallEvent(event);

		SHUDEventWrapper::FireModeChanged(this, m_firemode);
	}
}
//-------------------------------------------
void CLaser::Update(SEntityUpdateContext& ctx, int slot)
{
	FUNCTION_PROFILER(GetISystem(), PROFILE_GAME);

	if((slot == eIUS_General) && m_laserBeam.IsLaserActivated())
	{
		RequireUpdate(eIUS_General);

		CWeapon* pParentWeapon = GetWeapon();
		if (pParentWeapon)
		{
			CActor* pOwnerActor = pParentWeapon->GetOwnerActor();
			Vec3 laserPos, laserDir;
			GetLaserPositionAndDirection(pParentWeapon, laserPos, laserDir);

			CLaserBeam::SLaserUpdateDesc laserUpdateDesc(laserPos, laserDir, ctx.fFrameTime, pParentWeapon->GetEntity()->IsHidden());
			laserUpdateDesc.m_weaponZoomed = pParentWeapon->IsZoomed() || pParentWeapon->IsZoomingInOrOut();

			m_laserBeam.UpdateLaser(laserUpdateDesc);
		}
	}
}
Exemple #8
0
void CJaw::Select(bool select)
{
	BaseClass::Select(select);

	if (select)
	{
		//Force an update, it will check for previous cancelled auto drop request (just in case we got an empty JAW)
		const bool forceDropOnSelect = m_playedDropAction || (IsOwnerClient() && m_fm && m_fm->OutOfAmmo());
		if (forceDropOnSelect)
		{
			m_playedDropAction = false; //Start auto drop again
			HideRocket();
			AutoDrop();
			RequireUpdate(eIUS_General);
		}
	}
	else
	{
		m_laserGuider.TurnOffLaser();
	}

}
Exemple #9
0
//----------------------------------------------------
void CRocketLauncher::ActivateTPLaser(bool activate)
{
	if(activate)
	{
		DrawSlot( eIGS_Aux1,true);
		ActivateLaserDot(true,false);
		m_laserTPOn = true;
		
		//Force first update
		m_lastUpdate = 0.0f;
		m_smoothLaserLength = -1.0f;
		UpdateTPLaser(0.0f);
		RequireUpdate(eIUS_General);
	}
	else
	{
		DrawSlot( eIGS_Aux1,false);
		GetEntity()->SetSlotLocalTM( eIGS_Aux1,Matrix34::CreateIdentity());
		ActivateLaserDot(false,false);
		m_laserTPOn = false;
	}
}
void CHeavyMountedWeapon::OnReset()
{
	BaseClass::OnReset();

	m_rippedOff = m_rippingOff = false;
	m_stats.mounted = true;
	m_rotatingSoundID = INVALID_SOUNDID;
	m_lastUsedFrame = -1;

	Physicalize(false, false);

	RequireUpdate(eIUS_General);

	if (m_linkedParentId != 0)
	{
		IEntity* pLinkedParent = gEnv->pEntitySystem->GetEntity(m_linkedParentId);
		if (pLinkedParent)
		{
			pLinkedParent->AttachChild(GetEntity());
		}
		m_linkedParentId = 0;
	}
}
void CVehicleWeaponControlled::Update(SEntityUpdateContext& ctx, int update)
{
	IVehicle *pVehicle = m_vehicleId ? gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(m_vehicleId) : NULL; 
  if (!m_vehicleId && GetEntity()->GetParent())
  {
    IEntity *entity = GetEntity();
    
    if (entity)
    {
      IEntity *parent = entity->GetParent();
      if (parent)
      {
				m_vehicleId = parent->GetId();
        pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(parent->GetId());
      }
    }
  }



  if (pVehicle)
  {
		IVehiclePart *pPart = pVehicle->GetWeaponParentPart(GetEntityId());
		if(pPart)
		{
			if(IVehiclePart *pParentPart = pPart->GetParent())
			{
				CRY_ASSERT(pVehicle->GetEntity());

				if(ICharacterInstance *characterInst = pVehicle->GetEntity()->GetCharacter(pParentPart->GetSlot()))
				{
					if(ISkeletonPose* pose = characterInst->GetISkeletonPose())
					{
						IDefaultSkeleton& rIDefaultSkeleton = characterInst->GetIDefaultSkeleton();
						int16 joint = rIDefaultSkeleton.GetJointIDByName(pPart->GetName());
						const QuatT &jQuat = pose->GetAbsJointByID(joint);

						Matrix34 localT(jQuat);
						localT.SetTranslation(jQuat.t/* - Vec3(0.0f, 0.75f, 0.0f)*/);

						Matrix34 vehicleWorldTm = pVehicle->GetEntity()->GetWorldTM();
						Matrix34 mat = vehicleWorldTm * localT;
						Vec3 vehicleSide2 = pPart->GetParent()->GetLocalTM(true, true).GetTranslation();

						CPlayer *pl = this->GetOwnerPlayer();

						Matrix33 mat2;
						if (!m_destination.IsEquivalent(ZERO))
						{
							Vec3 diff = GetDestination() - mat.GetTranslation(); //pPart->GetWorldTM().GetTranslation();
							diff.Normalize();

							Matrix33 loc(mat);
							loc.Invert();

							Vec3 diffLocal = loc.TransformVector(diff);

							Matrix33 desMat;
							desMat.SetRotationVDir(diffLocal, 0.0f);

							Vec3 test = GetEntity()->GetLocalTM().GetColumn0();

							Ang3 testTM(desMat);

							float za = testTM.x - m_Angles.x;
							za = (za < 0.0f) ? -gf_PI : gf_PI;
							za *= 0.05f * ctx.fFrameTime;

							m_Angles.x += za;
							Limit(m_Angles.x, -gf_PI * 0.33f, gf_PI * 0.33f);

							if (testTM.z > m_Angles.z + 0.05f)
							{
								m_Angles.z += gf_PI * factor1 * ctx.fFrameTime;        
							}
							else if (testTM.z < m_Angles.z - 0.05f)
							{
								m_Angles.z -= gf_PI * factor1 * ctx.fFrameTime;        
							}
							else
							{
								m_Angles.z = testTM.z;
							}

							Limit(m_Angles.z, -gf_PI * 0.33f, gf_PI * 0.33f);
							mat2.SetRotationXYZ(m_Angles);
						}
						else
						{
							if (!m_FireBlocked)
							{
								m_Angles.x = m_Angles.x - ctx.fFrameTime * factor2 * m_Angles.x;
								m_Angles.z = m_Angles.z - ctx.fFrameTime * factor2 * m_Angles.z;
							}
							mat2.SetRotationXYZ(m_Angles);
						}

						mat = mat * mat2; 


						GetEntity()->SetWorldTM(mat);


						if (pl)
						{
							Matrix34 worldGunMat = vehicleWorldTm * localT;

							if (!pl->IsDead())
							{

								Vec3 trans = worldGunMat.GetTranslation() - worldGunMat.GetColumn2() * 0.7f;
								worldGunMat.SetTranslation(trans);

								pl->GetEntity()->SetWorldTM(worldGunMat);


								float dot = mat.GetColumn1().dot(worldGunMat.GetColumn0());
								Update3PAnim(pl, 0.5f - dot * 0.5f, ctx.fFrameTime, mat);
							}
							else
							{

								ICharacterInstance* pCharacter = pl->GetEntity()->GetCharacter(0);
								int boneId = pCharacter ? pCharacter->GetIDefaultSkeleton().GetJointIDByName("Spine03") : 7;

								pl->LinkToMountedWeapon(0);
								if (IVehicleSeat* seat = pVehicle->GetSeatForPassenger(pl->GetEntityId()))
								{
									seat->Exit(false, true);
								}

								Matrix33 rot(worldGunMat);
								Vec3 offset(0.0f, 0.0f, 0.70f);
								Vec3 transformedOff = rot.TransformVector(offset);
								Vec3 trans = worldGunMat.GetTranslation();
								trans -= transformedOff;
								worldGunMat.SetTranslation(trans);
								pl->GetEntity()->SetWorldTM(worldGunMat);
								pl->GetEntity()->SetPos(worldGunMat.GetTranslation()); //worldGunMat.GetTranslation());
								pl->RagDollize(true);

								if (boneId > -1)
								{
									IPhysicalEntity *physEnt = pl->GetEntity()->GetPhysics();
									if (physEnt)
									{
										pe_simulation_params simulationParams;
										physEnt->GetParams(&simulationParams);

										pe_params_pos pos;
										pos.pos = GetEntity()->GetPos();
										physEnt->SetParams(&pos);

										pe_action_impulse impulse;
										impulse.ipart = boneId;
										impulse.angImpulse = Vec3(0.0f, 0.0f, 1.0f);
										impulse.impulse = worldGunMat.GetColumn1() * -1.5f * simulationParams.mass;
										physEnt->Action(&impulse);
									}
								}

								StopUse(GetOwnerId());

								SetOwnerId(0);
								StopFire();

								m_FireBlocked = true;
							} // IsDead
						} // pl
					} // pose
				} // characterInst
			} // pParentPart
		} // pPart
	} // pVehicle

  Base::Update(ctx, update);
  RequireUpdate(eIUS_General);
}
Exemple #12
0
//------------------------------------------------------------------------
void CItem::UpdateMounted(float frameTime)
{
	IRenderAuxGeom* pAuxGeom = gEnv->pRenderer->GetIRenderAuxGeom();

	if (!m_ownerId || !m_stats.mounted)
		return;

	CActor *pActor = GetOwnerActor();
	if (!pActor)
		return;

	CheckViewChange();

  if (true)
  {  
	  if (IsClient())
	  {
		  ICharacterInstance *pCharacter = GetEntity()->GetCharacter(eIGS_FirstPerson);

		  if (pCharacter && !m_idleAnimation[eIGS_FirstPerson].empty() && pCharacter->GetISkeletonAnim()->GetNumAnimsInFIFO(0)<1)
			  PlayAction(m_idleAnimation[eIGS_FirstPerson], 0, true);
	  }

		// need to explicitly update characters at this point
		// cause the entity system update occered earlier, with the last position
		for (int i=0; i<eIGS_Last; i++)
		{
			if (GetEntity()->GetSlotFlags(i)&ENTITY_SLOT_RENDER)
			{
				ICharacterInstance *pCharacter = GetEntity()->GetCharacter(i);
				if (pCharacter)
				{
					Matrix34 mloc = GetEntity()->GetSlotLocalTM(i,false);
					Matrix34 m34 = GetEntity()->GetWorldTM()*mloc;
					QuatT renderLocation = QuatT(m34);
					pCharacter->GetISkeletonPose()->SetForceSkeletonUpdate(9);
					pCharacter->SkeletonPreProcess(renderLocation, renderLocation, GetISystem()->GetViewCamera(),0x55 );
					pCharacter->SetPostProcessParameter(renderLocation, renderLocation, 0, 0.0f, 0x55 );		
				}
			}
		}

	//	f32 fColor[4] = {1,1,0,1};
	//	f32 g_YLine=60.0f;
	//	gEnv->pRenderer->Draw2dLabel( 1,g_YLine, 1.3f, fColor, false, "Mounted Gun Code" ); 

		//adjust the orientation of the gun based on the aim-direction


		SMovementState info;
		IMovementController* pMC = pActor->GetMovementController();		
		pMC->GetMovementState(info);
		Vec3 dir = info.aimDirection.GetNormalized();
		Matrix34 tm = Matrix33::CreateRotationVDir(dir);
		Vec3 vGunXAxis=tm.GetColumn0();

		if (pActor->GetLinkedVehicle()==0)
		{
			if (pMC)
			{						
				if(!pActor->IsPlayer())
				{
					// prevent snapping direction
					Vec3 currentDir = GetEntity()->GetWorldRotation().GetColumn1();
					float dot = currentDir.Dot(dir);
					dot = CLAMP(dot,-1,1);
					float reqAngle = cry_acosf(dot);
					const float maxRotSpeed = 2.0f;
					float maxAngle = frameTime * maxRotSpeed;
					if(fabs(reqAngle) > maxAngle)
					{
						Vec3 axis = currentDir.Cross(dir);
						if(axis.GetLengthSquared()>0.001f) // current dir and new dir are enough different
							dir = currentDir.GetRotated(axis.GetNormalized(),sgn(reqAngle)*maxAngle);
					}
				}				
				//adjust the orientation of the gun based on the aim-direction
				tm = Matrix33::CreateRotationVDir(dir);
				Vec3 vWPos=GetEntity()->GetWorldPos();
				tm.SetTranslation(vWPos);
				GetEntity()->SetWorldTM(tm);  //set the new orientation of the mounted gun

				vGunXAxis=tm.GetColumn0();
				Vec3 vInitialAimDirection = m_stats.mount_dir;
				Matrix33 vInitialPlayerOrientation = Matrix33::CreateRotationVDir(vInitialAimDirection);
				assert( vInitialAimDirection.IsUnit() );

	  		Vec3 newp;

				if (pActor->IsThirdPerson())
				{
					//third person
					f32 dist = m_mountparams.body_distance*1.3f;
					Vec3 oldp = pActor->GetEntity()->GetWorldPos();
					newp = GetEntity()->GetWorldPos()-vInitialAimDirection*dist; //mounted gun
					newp.z = oldp.z;
				}
				else
				{
					//first person
					f32 fMoveBack = (1.0f+(dir.z*dir.z*dir.z*dir.z*4.0f))*0.75f;
					f32	dist = m_mountparams.eye_distance*fMoveBack;
					Vec3 oldp = pActor->GetEntity()->GetWorldPos();
					newp = GetEntity()->GetWorldPos()-dir*dist; //mounted gun
					//newp.z -= 0.75f;
					newp.z = oldp.z;
				}


				Matrix34 actortm(pActor->GetEntity()->GetWorldTM());

				//if (pActor->IsThirdPerson())
				actortm=vInitialPlayerOrientation;

				actortm.SetTranslation(newp);
				pActor->GetEntity()->SetWorldTM(actortm, ENTITY_XFORM_USER);
				pActor->GetAnimationGraphState()->SetInput("Action","gunnerMounted");
				
				//f32 g_YLine=80.0f;
				//gEnv->pRenderer->Draw2dLabel( 1,g_YLine, 1.3f, fColor, false, "Mounted Gun Active for FP and AI" ); 

				if (ICharacterInstance *pCharacter = pActor->GetEntity()->GetCharacter(0))
				{
					ISkeletonAnim *pSkeletonAnim = pCharacter->GetISkeletonAnim();
					assert(pSkeletonAnim);

					uint32 numAnimsLayer = pSkeletonAnim->GetNumAnimsInFIFO(0);
					for(uint32 i=0; i<numAnimsLayer; i++)
					{
						CAnimation &animation = pSkeletonAnim->GetAnimFromFIFO(0, i);
						if (animation.m_AnimParams.m_nFlags & CA_MANUAL_UPDATE)
						{
							f32 aimrad = Ang3::CreateRadZ(Vec2(vInitialAimDirection),Vec2(dir));
							animation.m_fAnimTime = clamp_tpl(aimrad/gf_PI,-1.0f,+1.0f)*0.5f+0.5f;
							//if (pActor->IsThirdPerson()==0)
								//animation.m_fAnimTime=0.6f; //Ivo & Benito: high advanced future code. don't ask what it is 
							                                //Benito - Not needed any more ;)

							//f32 g_YLine=100.0f;
							//gEnv->pRenderer->Draw2dLabel( 1,g_YLine, 1.3f, fColor, false, "AnimTime: %f    MyAimAngle: %f deg:%   distance:%f", animation.m_fAnimTime, aimrad, RAD2DEG(aimrad),m_mountparams.body_distance ); 
						}
					}

				}

				m_stats.mount_last_aimdir = dir;
				
			}
		}
    
    if (ICharacterInstance* pCharInstance = pActor->GetEntity()->GetCharacter(0))
		{
      if (ISkeletonAnim* pSkeletonAnim = pCharInstance->GetISkeletonAnim())
      {   
        OldBlendSpace ap;				
        if (GetAimBlending(ap))
        {
					pSkeletonAnim->SetBlendSpaceOverride(eMotionParamID_TurnSpeed, 0.5f + 0.5f * ap.m_turn, true);
        }        
      }        
    } 

    UpdateIKMounted(pActor, vGunXAxis*0.1f);
   
		RequireUpdate(eIUS_General);
  }
}
Exemple #13
0
void CHeavyWeapon::StartUse(EntityId userId)
{
    // holster user item here
    SetOwnerId(userId);

    CActor* pOwner = GetOwnerActor();
    if (!pOwner)
        return;

    HighlightWeapon(false);
    Physicalize(false, false);

    if(gEnv->bMultiplayer)
        {
            m_properties.usable &= strlen(g_pGameCVars->g_forceHeavyWeapon->GetString()) == 0;

            CHANGED_NETWORK_STATE(pOwner, CPlayer::ASPECT_CURRENT_ITEM);
        }

    if(IItem* pCurrentItem = pOwner->GetCurrentItem())
        {
            //Don't keep history if we're switching from Pick & Throw otherwsie we'll switch back to it when we're done with the heavy weapon
            static IEntityClass* pPickAndThrowWeaponClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("PickAndThrowWeapon");
            m_pItemSystem->SetActorItem(pOwner, GetEntityId(), pCurrentItem->GetEntity()->GetClass() != pPickAndThrowWeaponClass);
        }
    else
        {
            m_pItemSystem->SetActorItem(pOwner, GetEntityId(), true);
        }

    TriggerRespawn();

    EnableUpdate(true, eIUS_General);
    RequireUpdate(eIUS_General);

    RegisterAsUser();

    HandleHeavyWeaponPro(*pOwner);

    m_stats.brandnew = false;
    m_stats.used = true;
    m_stats.detached = false;

    if(IsClient() && gEnv->pGame->GetIGameFramework()->GetClientActorId()==userId)
        {
            if(IEntity* pEntity = GetEntity())
                {
                    const char* collectibleId = pEntity->GetClass()->GetName();
                    CPersistantStats* pStats = g_pGame->GetPersistantStats();
                    if(pStats && pStats->GetStat(collectibleId, EMPS_SPWeaponByName) == 0)
                        {
                            pStats->SetMapStat(EMPS_SPWeaponByName, collectibleId, eDatabaseStatValueFlag_Available);

                            if(!gEnv->bMultiplayer)
                                {
                                    // Show hud unlock msg
                                    SHUDEventWrapper::DisplayWeaponUnlockMsg(collectibleId);
                                }
                        }
                }
        }

    if (IsServer())
        {
            pOwner->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClStartUse(), CActor::ItemIdParam(GetEntityId()), eRMI_ToAllClients|eRMI_NoLocalCalls, GetEntityId());
            g_pGame->GetGameRules()->AbortEntityRemoval(GetEntityId());
        }

    OnStartUsing();
}