Example #1
0
//---------------------------------------------------------------------
void CVehicleWeapon::UpdateFPView(float frameTime)
{
	CItem::UpdateFPView(frameTime);

	if(GetOwnerId() && m_pVehicle && (m_pVehicle->GetCurrentWeaponId(GetOwnerId(), true) != GetEntityId())) //only update primary weapon
		UpdateCrosshair(frameTime);
	if (m_fm)
		m_fm->UpdateFPView(frameTime);
	if (m_zm)
		m_zm->UpdateFPView(frameTime);
}
Example #2
0
//------------------------------------------------------
void CWeapon::ForcePendingActions()
{
	CItem::ForcePendingActions();

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

	//Force start firing, if needed and possible
	/*if(m_requestedFire)
	{
		if(!IsDualWield() && !IsWeaponRaised())
		{
			m_requestedFire = false;
			if(IsTargetOn() || (m_fm && !m_fm->AllowZoom()))
				return;
			
			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);
				}
			}
		}
	}*/

	// EXP 1: Rewritten dual wield handling
	if(m_requestedFire && !IsWeaponRaised())
	{
		m_requestedFire = false;
		if(IsTargetOn() || (m_fm && !m_fm->AllowZoom()))
			return;
		
		if (!IsDualWield() || IsDualWieldSlave())
			OnAction(GetOwnerId(),"attack1",eAAM_OnPress,0.0f);
		else
			OnAction(GetOwnerId(),"attack2",eAAM_OnPress,0.0f);
	}
}
Example #3
0
bool 
Process::BuildYourValueSet(){

	int		temp;
	

	m_name		= GetName();
	m_canAbort	= GetCanAbort();
	m_canStart	= GetCanStart();
	m_canPause	= GetCanPause();
	m_ownerId	= GetOwnerId();
	m_ownerManagerClassType = GetOwnerManegerClassType();

	ManagedObject::BuildYourValueSet();

	temp = m_canStart? 1 : 0;
	AddInt( temp, SSAPI_PROCESS_FID_CAN_START );

	temp = m_canAbort? 1 : 0;
	AddInt( temp, SSAPI_PROCESS_FID_CAN_ABORT );

	temp = m_canPause? 1 : 0;
	AddInt( temp, SSAPI_PROCESS_FID_CAN_PAUSE );
	AddU32( m_percentComplete, SSAPI_PROCESS_FID_PERCENT_COMPLETE );
	AddU32( m_priority, SSAPI_PROCESS_FID_PRIORITY );
	AddInt64( m_timeStarted, SSAPI_PROCESS_FID_TIME_STARTED );
	AddU32( m_state, SSAPI_PROCESS_FID_STATE );
	AddU32( m_name, SSAPI_PROCESS_FID_NAME );
	AddU32( m_ownerManagerClassType, SSAPI_PROCESS_FID_OWNER_MANAGER_CLASS_TYPE);
	AddGenericValue( (char *)&m_ownerId, sizeof(m_ownerId), SSAPI_PROCESS_FID_OWNER_ID );

	return true;
}
Example #4
0
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);
}
//method called by Passenger to update visitor's location, state.
int VisitorTerminalBehavior::update( ElapsedTime _time, Point _OwnerPreLocation, bool _bBackup )
{
	int nNextState = GetOwner()->getState();
	PaxTerminalBehavior* spTerminalBehavior = (PaxTerminalBehavior*)GetOwner()->getBehavior(MobElementBehavior::TerminalBehavior);
	if (spTerminalBehavior == NULL)
	{
		return 1;
	}

	if (IfHaveOwnFlow(_time))
	{
		//////create ConvergePair,and add to GreetPool.            6.21.2004
		//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

		TrayHostList* pTrayHostList = m_pTerm->GetTrayHostList();

		if (pTrayHostList->IfNonPaxExsit(m_pPerson->getType().GetTypeIndex()) && !m_bInTray)
		{
			spTerminalBehavior->CopyVisitListToTrayHost(_time);
		}

		if (pTrayHostList->FindHostItem(m_pPerson->getType().GetTypeIndex()) || !pTrayHostList->IfNonPaxExsit(m_pPerson->getType().GetTypeIndex())\
			|| (pTrayHostList->IfNonPaxExsit(m_pPerson->getType().GetTypeIndex()) && !m_bInTray))
		{
			if (!spTerminalBehavior->StickForDestProcsOverload(_time) && !StickNonPaxDestProcsOverload(_time))
			{
				GetVisitor()->NewConvergePair(GetOwnerId(),true);
				if(GetOwner()) GetOwner()->NewConvergePair(m_pPerson->getID(),m_pPerson->getType().GetTypeIndex());

				m_pPerson->setState(FreeMoving);
				m_nFreeMoving = 1;
				m_nFreeMovingIndex = m_pPerson->getLogEntry().getCurrentCount();
				//	m_bWithOwner = false;
				m_pPerson->m_pGroupInfo->SetFollowerWithOwner(false);
				setDestination(_OwnerPreLocation);
				ElapsedTime eTime = _time + moveTime();
				generateEvent(eTime,false);

				if( getNextProcessor( eTime ) )
					generateEvent( eTime+moveTime(),false );//

				return 0;
			}
			return 1;
		}
		return 0;
	}

	m_pPerson->setState(nNextState);
	m_nQueuePathSegmentIndex = spTerminalBehavior->getCurrentIndex();
	m_pProcessor = spTerminalBehavior->getProcessor();

	CString sstr1= m_pProcessor->getID()->GetIDString();
	// write log entry
	//writeLog( _time );
	//CString _strOwnerProcessor = m_pOwnerPax->getProcessor()->getID()->GetIDString();
	GetVisitor()->writeVisitorLog( _time,_OwnerPreLocation, _bBackup, false);
	return 1;
}
Example #6
0
CHeavyMountedWeapon::~CHeavyMountedWeapon()
{
	if(m_stats.used)
	{
		m_stats.dropped = true; //prevent StopUse calling Drop
		StopUse(GetOwnerId());
	}
}
//------------------------------------------------------------------------
void CDebugGun::Shoot(bool bPrimary)
{   
  CWeapon::StartFire();
  
  // console cmd      
  string cmd;  

  cmd = (bPrimary) ? g_pGameCVars->i_debuggun_1->GetString() : g_pGameCVars->i_debuggun_2->GetString();  
  cmd += " ";        
        
  unsigned int flags = rwi_stop_at_pierceable|rwi_colltype_any;
  
  if (m_fireModes[m_fireMode].first == "pierceability")
  { 
    flags = (unsigned int)m_fireModes[m_fireMode].second & rwi_pierceability_mask;
  }
  
  IPhysicalWorld* pWorld = gEnv->pPhysicalWorld;
  IPhysicalEntity *pSkip = GetOwnerActor()->GetEntity()->GetPhysics();
  ray_hit rayhit;

  CCamera& cam = GetISystem()->GetViewCamera();
  Vec3 pos = cam.GetPosition()+cam.GetViewdir();
  Vec3 dir = cam.GetViewdir() * HIT_RANGE;

  IEntity* pEntity = 0;

  if (pWorld->RayWorldIntersection(pos, dir, ent_all, flags, &rayhit, 1, &pSkip, 1))
  {
    pEntity = (IEntity*)rayhit.pCollider->GetForeignData(PHYS_FOREIGN_ID_ENTITY);        
  }
  
  cmd.append(pEntity ? pEntity->GetName() : "0");   
  
  // if we execute an AI command take care of ai_debugdraw
  if (cmd.substr(0, 3) == "ai_")
  {
    if (pEntity && m_pAIDebugDraw->GetIVal() == 0)
      m_pAIDebugDraw->Set(1);
    else if(!pEntity && m_aiDebugDrawPrev == 0 && m_pAIDebugDraw->GetIVal() == 1)
      m_pAIDebugDraw->Set(0);
  }

  gEnv->pConsole->ExecuteString(cmd.c_str());

  // if 2nd button hits a vehicle, enable movement profiling  
  if (!bPrimary)
  {
    static IVehicleSystem* pVehicleSystem = g_pGame->GetIGameFramework()->GetIVehicleSystem();
     
    string vehicleCmd = "v_debugVehicle ";
    vehicleCmd.append((pEntity && pVehicleSystem->GetVehicle(pEntity->GetId())) ? pEntity->GetName() : "0");
    
    gEnv->pConsole->ExecuteString(vehicleCmd.c_str());
  }

  OnShoot(GetOwnerId(), 0, 0, pos, dir, Vec3(ZERO));
}
Example #8
0
//---------------------------------------------------------------------
void CVehicleWeapon::OnVehicleEvent(EVehicleEvent event, const SVehicleEventParams& params)
{
	CRY_ASSERT(GetOwnerId() == g_pGame->GetIGameFramework()->GetClientActorId());
	if (event == eVE_ViewChanged)
	{
		const bool isThirdPerson = params.bParam;
		AudioCache(true, isThirdPerson);	//enable what is currently needed (automatically uncache previously unneeded
	}
}
Example #9
0
//-------------------------------------------------------------------------
void CLam::ActivateLight(bool activate, bool aiRequest /* = false */)
{
    //GameWarning("CLam::ActivateLight(%i)", activate);

    CItem  *pParent = NULL;
    EntityId ownerId = 0;

    if (IItem *pOwnerItem = m_pItemSystem->GetItem(GetParentId()))
    {
        pParent = (CItem *)pOwnerItem;
        IWeapon *pWeapon = pOwnerItem->GetIWeapon();
        if(pWeapon)
            ownerId = pOwnerItem->GetOwnerId();
    }
    else
    {
        pParent = this;
        ownerId = GetOwnerId();
    }

    IActor *pOwnerActor = gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(ownerId);
    if (activate && !pOwnerActor)
        return;

    //Special FP stuff
    if(pOwnerActor && pOwnerActor->IsPlayer() && !m_lamparams.isFlashLight)
        return;

    //For AI must be deactivated by default (if they don't request)
    if(activate && !m_lightWasOn && !aiRequest && !pOwnerActor->IsPlayer())
        return;

    m_lightActivated = activate;

    //Activate or deactivate effect
    if (!m_lightActivated)
    {
        AttachLAMLight(false, pParent, eIGS_FirstPerson);
        AttachLAMLight(false, pParent, eIGS_ThirdPerson);

        //GameWarning("Global light count = %d", s_lightCount);
    }
    else
    {
        uint8 id = pOwnerActor->IsThirdPerson() ? 1 : 0;
        if (m_lightID[id] == 0)
        {
            AttachLAMLight(true, pParent, id?eIGS_ThirdPerson:eIGS_FirstPerson);
        }
    }

    if (m_laserActivated || m_lightActivated)
        GetGameObject()->EnablePostUpdates(this);
    if (!m_laserActivated && !m_lightActivated)
        GetGameObject()->DisablePostUpdates(this);

}
Example #10
0
//------------------------------------------------------
void CWeapon::ForcePendingActions(uint8 blockedActions)
{
	CItem::ForcePendingActions(blockedActions);

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

	//--- Lock action requests to ensure that we don't recurse back into this function but also
	//--- block any recursive action requests to ensure we don't repeat the actions next frame
	s_lockActionRequests = true;

	//Force start firing, if needed and possible
	if(IsInputFlagSet(eWeaponAction_Fire) && !(blockedActions&eWeaponAction_Fire))
	{
		ClearInputFlag(eWeaponAction_Fire);
		if(IsTargetOn() || (m_fm && !m_fm->AllowZoom()))
		{
			s_lockActionRequests = false;
			return;
		}
			
		OnAction(GetOwnerId(),CCryName("attack1"),eAAM_OnHold,0.0f);
	}

	//Force zoom in if needed
	if(IsInputFlagSet(eWeaponAction_Zoom) && !(blockedActions&eWeaponAction_Zoom))
	{
		if(!IsZoomed() && !IsZoomingInOrOut())
			OnActionZoom(GetOwnerId(), CCryName("zoom"), eAAM_OnPress, 0.0f);

		ClearInputFlag(eWeaponAction_Zoom);
	}

	if(IsInputFlagSet(eWeaponAction_Reload) && !(blockedActions&eWeaponAction_Reload))
	{
		if (!IsBusy())
			ReloadWeapon();
		ClearInputFlag(eWeaponAction_Reload);
	}

	s_lockActionRequests = false;
}
Example #11
0
void CHeavyMountedWeapon::PostSerialize()
{
	BaseClass::PostSerialize();

	if(m_rippingOff)
	{
		m_rippingOff = false;
		m_rippedOff = true;
	}

	StartUse(GetOwnerId());
}
Example #12
0
void CC4Projectile::SerializeSpawnInfo( TSerialize ser )
{
	BaseClass::SerializeSpawnInfo(ser);

	int prevTeamId = m_teamId;
	ser.Value("teamId", m_teamId, 'team');
	if(ser.IsReading() && prevTeamId != m_teamId)
	{
		const EntityId clientId = g_pGame->GetIGameFramework()->GetClientActorId();
		int localPlayerTeam = g_pGame->GetGameRules()->GetTeam( clientId );
		m_OnSameTeam = m_teamId ? m_teamId == localPlayerTeam : GetOwnerId() == clientId;
	}
}
Example #13
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);
				}
			}
		}
	}
}
Example #14
0
void CC4Projectile::OnChangedTeam( EntityId entityId, int oldTeamId, int newTeamId )
{
	const EntityId clientId = g_pGame->GetClientActorId();
	if(entityId == clientId)
	{
		m_OnSameTeam = m_teamId ? m_teamId == newTeamId : GetOwnerId() == clientId;
		if(m_pLightSource)
		{
			UpdateLight(0.f, true); //Force colour update
		}
		if(gEnv->bMultiplayer)
		{
			SetupUIIcon();
		}
	}
}
void CVehicleWeaponControlled::StopUse(EntityId userId)
{
   EntityId id = GetOwnerId();

   Base::StopUse(userId);

   SetOwnerId(id);
   m_CurrentTime = 0.5f;

   IVehicle *pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(m_vehicleId);
   if (pVehicle)
   {
	   SHUDEvent hudEvent(eHUDEvent_RemoveEntity);
	   hudEvent.AddData((int)pVehicle->GetEntityId());
	   CHUDEventDispatcher::CallEvent(hudEvent);
   }
}
Example #16
0
void CHeavyMountedWeapon::StopUse(EntityId userId)
{
	UnRegisterAsUser();

	if (m_rippedOff || m_rippingOff)
	{
		CActor *pActor = GetOwnerActor();

		m_rippedOff = true;
		m_rippingOff = false;
		RemoveViewLimits();
		BaseClass::StopUse(userId);

		if(pActor)
		{
			pActor->LockInteractor(GetEntityId(), false);
		}
	}
	else
	{
		CActor *pActor = GetOwnerActor();
		if (!pActor)
		{
			return;
		}

		if (m_isFiring)
		{
			StopFire();
		}
		DoRipOffPrompt(GetOwnerId(), false);
		SetViewMode(eIVM_ThirdPerson);
		DrawSlot(eIGS_ThirdPerson, true);

		if(gEnv->bMultiplayer)
		{
			HighlightWeapon(true);
		}

		//The use of CWeapon::StopUse() here and not BaseClass::StopUse() is deliberate; it avoids the '::Drop()' call that CHeavyWeapon makes
		CWeapon::StopUse(userId);
	}
}
Example #17
0
//---------------------------------------------------------------------
void CVehicleWeapon::UpdateFPView(float frameTime)
{
	CItem::UpdateFPView(frameTime);

	const EntityId ownerId = GetOwnerId();
	
	//only update primary weapon
	IVehicle* pVehicle = GetVehicle();
	if(ownerId && pVehicle && (pVehicle->GetCurrentWeaponId(ownerId, true) != GetEntityId())) 
	{
		UpdateCrosshair(frameTime);
	}
	if (m_fm)
	{
		m_fm->UpdateFPView(frameTime);
	}
	if (m_zm)
	{
		m_zm->UpdateFPView(frameTime);
	}
}
Example #18
0
//------------------------------------------------------------------------
void CItem::OnReset()
{
    //Hidden entities must have physics disabled
    if(!GetEntity()->IsHidden())
        GetEntity()->EnablePhysics(true);

    DestroyedGeometry(false);
    m_stats.health = (float)m_properties.hitpoints;

    UpdateDamageLevel();

    if(m_sharedparams->params.scopeAttachment)
        DrawSlot(eIGS_Aux1,false); //Hide secondary FP scope

    if (m_properties.mounted && m_sharedparams->params.mountable)
    {
        MountAt(GetEntity()->GetWorldPos());

        SEntityPhysicalizeParams params;
        params.mass = 0;
        params.nSlot = -1; // todo: -1 doesn't work for characters
        params.type = PE_STATIC;
        GetEntity()->Physicalize(params);
    }
    else
    {
        SetViewMode(eIVM_ThirdPerson);

        if (m_properties.pickable)
        {
            const bool hasOwner = (GetOwnerId() != 0);
            Physicalize(hasOwner ? false : true, m_properties.physics);
            Pickalize(true, false);
        }
        else
            Physicalize(m_properties.physics, true);
    }

    GetEntity()->InvalidateTM();
}
Example #19
0
void CHeavyMountedWeapon::UpdateFPView(float frameTime)
{
	BaseClass::UpdateFPView(frameTime);

	/*if(!gEnv->bMultiplayer)*/
	{
		if(!m_rippedOff && !m_rippingOff)
		{
			CActor* pOwner = GetOwnerActor();
			if(!pOwner)
				return;

			if (CanRipOff())
			{
				if(gEnv->bMultiplayer || !pOwner->GetLinkedVehicle())
				{
					DoRipOffPrompt(GetOwnerId(), true);
				}
			}
		}
	}
}
Example #20
0
void CHeavyMountedWeapon::FinishRipOff()
{
	m_rippingOff = false;
	m_rippedOff = true;
	
	RemoveViewLimits();

	if(IsClient() && gEnv->pGame->GetIGameFramework()->GetClientActorId()==GetOwnerId())
	{
		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);
				}
			}
		}
	}

	CActor* pOwner = GetOwnerActor();
	IActionController* pController = pOwner ? pOwner->GetAnimatedCharacter()->GetActionController() : NULL;
	if(pController)
	{
		CMannequinUserParamsManager& mannequinUserParams = g_pGame->GetIGameFramework()->GetMannequinInterface().GetMannequinUserParamsManager();
		const SMannequinItemParams* pParams = mannequinUserParams.FindOrCreateParams<SMannequinItemParams>(pController);

		UpdateMountedTags(pParams, pController->GetContext().state, true);
	}
}
Example #21
0
void CHeavyMountedWeapon::PerformRipOff(CActor* pOwner)
{
	ExitZoom(true);

	UnlinkMountedGun();
	SetUnMountedConfiguration();	// This needs to come after the call to UnlinkMountedGun otherwise killcam doesn't work properly
	AttachToHand(true);
	StopFire();
	Physicalize(false, false);

	if (pOwner)
	{
		HandleHeavyWeaponPro(*pOwner);

		float speedOverride = 1.0f;
		if(pOwner->IsPlayer())
		{
			CPlayer* pOwnerPlayer = static_cast<CPlayer*>(pOwner);
			speedOverride = pOwnerPlayer->GetModifiableValues().GetValue(kPMV_HeavyWeaponRipOffSpeedOverride);
		}

		PlayAction(GetFragmentIds().rip_off, 0, false, eIPAF_Default, speedOverride);

		m_rippingOff = true;
		m_stats.dropped = false;

		DoRipOffPrompt(GetOwnerId(), false);

		int timeDelay = GetCurrentAnimationTime(eIGS_Owner);
		timeDelay = (timeDelay > 0) ? timeDelay : 2000;
		int removeViewLimitDelay = int(timeDelay * 0.65f);
		GetScheduler()->TimerAction(timeDelay, CSchedulerAction<EndRippingOff>::Create(EndRippingOff(this)), false);
		GetScheduler()->TimerAction(removeViewLimitDelay, CSchedulerAction<RemoveViewLimitsAction>::Create(RemoveViewLimitsAction(this)), false);

		if(!pOwner->IsThirdPerson() && !(m_stats.viewmode&eIVM_FirstPerson))
		{
			SetViewMode(eIVM_FirstPerson);
		}

		//Lock view in place during rip off
		SActorParams &params = pOwner->GetActorParams();

		Vec3 limitDir(ZERO);
		
		bool bUseMovementState = true;

		if (pOwner->IsClient() && (g_pGame->GetHostMigrationState() != CGame::eHMS_NotMigrating))
		{
			// If this happens during a host migration, our aim direction may not have made it into the movement
			// controller yet, get it from the saved migration params instead
			const CGameRules::SHostMigrationClientControlledParams *pHostMigrationParams = g_pGame->GetGameRules()->GetHostMigrationClientParams();
			if (pHostMigrationParams)
			{
				limitDir = pHostMigrationParams->m_aimDirection;
				bUseMovementState = false;
			}
		}

		if (bUseMovementState)
		{
			IMovementController *pMovementController = pOwner->GetMovementController();
			SMovementState state;
			pMovementController->GetMovementState(state);

			limitDir = state.aimDirection;
		}

		params.viewLimits.SetViewLimit(limitDir, 0.01f, 0.01f, 0.01f, 0.01f, SViewLimitParams::eVLS_Item);

		pOwner->SetSpeedMultipler(SActorParams::eSMR_Item, 0.0f);

		if(!gEnv->bMultiplayer)
			pOwner->LockInteractor(GetEntityId(), false);

	}

	TriggerRespawn();

	if (pOwner)
	{
		if (CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem()) 
		{
			pRecordingSystem->OnWeaponRippedOff(this);
		}

		BATTLECHATTER(BC_Ripoff, GetOwnerId());

		if(pOwner->IsClient())
		{
			g_pGame->GetPersistantStats()->IncrementClientStats(EIPS_RipOffMountedWeapon);
			ClearInputFlag(eWeaponAction_Zoom);
		}
	}
	else
	{
		//--- If ripped off without an actor we should finish instantly
		m_rippingOff = false;
		m_rippedOff = true;
	}
}
Example #22
0
void CHeavyMountedWeapon::RemoveViewLimits()
{
	ApplyViewLimit(GetOwnerId(), false);
}
Example #23
0
//-------------------------------------------------------------------------
void CLam::ActivateLaser(bool activate, bool aiRequest /* = false */)
{
    if (m_laserActivated == activate)
        return;

    CItem  *pParent = NULL;
    EntityId ownerId = 0;
    bool ok = false;

    if (IItem *pOwnerItem = m_pItemSystem->GetItem(GetParentId()))
    {
        pParent = (CItem *)pOwnerItem;
        IWeapon *pWeapon = pOwnerItem->GetIWeapon();
        if(pWeapon)
            ownerId = pOwnerItem->GetOwnerId();

        ok = true;
    }
    else
    {
        pParent = this;
        ownerId = GetOwnerId();
    }

    IActor *pOwnerActor = gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(ownerId);
    if(!pOwnerActor)
        return;

    if(activate && !aiRequest && !pOwnerActor->IsPlayer())
        return;

    //Special FP stuff
    if(pOwnerActor->IsPlayer() && !m_lamparams.isLaser)
        return;

    m_laserActivated = activate;

    //Activate or deactivate effect??
    if (!m_laserActivated)
    {
        AttachLAMLaser(false, eIGS_FirstPerson);
        AttachLAMLaser(false, eIGS_ThirdPerson);
    }
    else
    {
        bool tp = pOwnerActor->IsThirdPerson();
        if(!tp && ok)
        {
            SAccessoryParams *params = pParent->GetAccessoryParams(GetEntity()->GetClass()->GetName());
            if (!params)
                return;

            m_laserHelperFP.clear();
            m_laserHelperFP = params->attach_helper.c_str();
            m_laserHelperFP.replace("_LAM","");
        }
        AttachLAMLaser(true, tp?eIGS_ThirdPerson:eIGS_FirstPerson);
    }

    if (m_laserActivated || m_lightActivated)
        GetGameObject()->EnablePostUpdates(this);
    if (!m_laserActivated && !m_lightActivated)
        GetGameObject()->DisablePostUpdates(this);
}
Example #24
0
void CHeavyWeapon::PostSerialize()
{
    CWeapon::PostSerialize();
    StartUse(GetOwnerId());
}
Example #25
0
void CWeapon::EndBurst()
{
	BROADCAST_WEAPON_EVENT(OnEndBurst, (this, GetOwnerId()));
}
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);
}