Exemple #1
0
bool CBinocular::OnActionToggleNightVision( EntityId actorId, const ActionId& actionId, int activationMode, float value )
{
	if(m_bZoomed == false)
		return true;

	if(m_pNightVisionCVar == NULL)
		return true;

	if(m_pDefaultNVMode == NULL)
		return true;

	if (m_bNightVisionEnabled == true)
	{
		PlayAction(g_pItemStrings->nightvision_off);
		m_pNightVisionCVar->ForceSet("0");
	}
	else
	{
		PlayAction(g_pItemStrings->nightvision_on);
		m_pNightVisionCVar->ForceSet(m_pDefaultNVMode->GetString());
	}

	m_bNightVisionEnabled = !m_bNightVisionEnabled;

	return true;
}
Exemple #2
0
//-------------------------------------------------------------------------
bool CWeapon::OnActionModify(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	COffHand * offHandWeapon = NULL;
	bool isOffHandSelected = false;
	GetOffHandInfo(this,isOffHandSelected,&offHandWeapon);

	if (!IsBusy() && !isOffHandSelected)
	{
		if (m_fm)
			m_fm->StopFire();

		if(m_zm && m_zm->IsZoomed())
			m_zm->StopZoom();

		if(m_weaponRaised)
			RaiseWeapon(false,true);

		if (m_modifying && !m_transitioning)
		{
			StopLayer(g_pItemStrings->modify_layer, eIPAF_Default, false);
			PlayAction(g_pItemStrings->leave_modify, 0);
			m_dofSpeed = -1.0f/((float)GetCurrentAnimationTime(eIGS_FirstPerson)/1000.0f);
			m_dofValue = 1.0f;
			m_focusValue = -1.0f;

			GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<ScheduleLayer_Leave>::Create(this), false);
			m_transitioning = true;

			SAFE_HUD_FUNC(WeaponAccessoriesInterface(false));
			m_modifying = false;

			GetGameObject()->InvokeRMI(CItem::SvRequestLeaveModify(), CItem::EmptyParams(), eRMI_ToServer);
		}
		else if (!m_modifying && !m_transitioning)
		{
			gEnv->p3DEngine->SetPostEffectParam("Dof_Active", 1.0f);
			gEnv->p3DEngine->SetPostEffectParam("Dof_FocusRange", -1.0f);
			gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMin", 0.0f);
			gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMax", 5.0f);
			gEnv->p3DEngine->SetPostEffectParam("Dof_FocusLimit", 20.0f);
			gEnv->p3DEngine->SetPostEffectParam("Dof_UseMask", 0.0f);

			PlayAction(g_pItemStrings->enter_modify, 0, false, eIPAF_Default | eIPAF_RepeatLastFrame);
			m_dofSpeed = 1.0f/((float)GetCurrentAnimationTime(eIGS_FirstPerson)/1000.0f);
			m_dofValue = 0.0f;
			m_transitioning = true;

			GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<ScheduleLayer_Enter>::Create(this), false);
			m_modifying = true;

			GetGameObject()->InvokeRMI(CItem::SvRequestEnterModify(), CItem::EmptyParams(), eRMI_ToServer);
		}
	}

	return true;
}
Exemple #3
0
//------------------------------------------------------------------------
void CBinocular::Select(bool select)
{
	if(select == false)
	{
		PlayAction(g_pItemStrings->lower);
		ResetState();
	}
	else
	{
		PlayAction(g_pItemStrings->select);
	}
		
	CWeapon::Select(select);
}
Exemple #4
0
//------------------------------------------------------------------------
void CGunTurret::OnTargetLocked(IEntity *pTarget)
{
	if(pTarget)
		PlayAction(g_pItemStrings->lock);

	if(IsServer())
	{
		// if this turret has others linked, notify them about acquired target
		for(IEntityLink *pLink = GetEntity()->GetEntityLinks(); pLink; pLink = pLink->next)
		{
			if(0 != strcmp(pLink->name, "TargetInfo"))
				continue;

			IItem *pItem = g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem(pLink->entityId);

			if(pItem)
			{
				SGameObjectEvent event(pTarget?eCGE_Turret_LockedTarget:eCGE_Turret_LostTarget, eGOEF_ToExtensions);
				event.ptr = pTarget;
				pItem->GetGameObject()->SendEvent(event);
			}
		}
	}

	if(IsClient())
	{
		m_pGameFramework->GetMusicLogic()->SetEvent(eMUSICLOGICEVENT_PLAYER_TURRET_ATTACK);
	}
}
Exemple #5
0
//------------------------------------------------------------------------
void CItem::UpdateFPCharacter(float frameTime)
{
	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(8);
				pCharacter->SkeletonPreProcess(renderLocation, renderLocation, GetISystem()->GetViewCamera(),0x55 );
				pCharacter->SetPostProcessParameter(renderLocation, renderLocation, 0, 1.0f, 0x55 ); 
			}
		}
	}

	IEntityRenderProxy *pProxy=GetRenderProxy();
	if (pProxy)
		pProxy->InvalidateLocalBounds();
}
Exemple #6
0
// turn walking on/off
void WalkToggle(bool onOff) {
    // if servos are off then turn on
    ServoStartup();

    if (onOff) {
        // turn on walk
        PlayAction(8);  // walking stance
        // enable walking minus head
        Walking::GetInstance()->m_Joint.SetEnableBodyWithoutHead(true, true);
        MotionManager::GetInstance()->SetEnable(true);
        // enable head motion module
        Head::GetInstance()->m_Joint.SetEnableHeadOnly(true);
        // initialze motion to 0 and start walking
        Walking::GetInstance()->X_MOVE_AMPLITUDE = 0;
        Walking::GetInstance()->Y_MOVE_AMPLITUDE = 0;
        Walking::GetInstance()->A_MOVE_AMPLITUDE = 0;
        Walking::GetInstance()->Start();
    } else {
        // turn off walk
        Walking::GetInstance()->Stop();
        while (Walking::GetInstance()->IsRunning() == 1) usleep(8000);
        MotionManager::GetInstance()->Reinitialize();
        // enable all servos for motion manager
        MotionManager::GetInstance()->SetEnable(true);
        Walking::GetInstance()->m_Joint.SetEnableBody(false);
        Action::GetInstance()->m_Joint.SetEnableBody(true);
    }
}
void CHeavyMountedWeapon::OnEndCutScene()
{
	if (m_rippedOff)
	{
		Hide(false);

		PlayAction(GetSelectAction());
	}
}
Exemple #8
0
//------------------------------------------------------------------------
void CGunTurret::OnReset()
{
	if(IScriptTable *pScriptTable = GetEntity()->GetScriptTable())
	{
		SmartScriptTable props;

		if(pScriptTable->GetValue("Properties", props))
			ReadProperties(props);
	}

	CItem::OnReset();

	Matrix34 tm = GetEntity()->GetSlotLocalTM(eIGS_Aux0,false);

	tm.SetTranslation(GetSlotHelperPos(eIGS_Aux0,m_radarHelper.c_str(),false));
	GetEntity()->SetSlotLocalTM(eIGS_ThirdPerson,tm);

	if(GetEntity()->IsSlotValid(eIGS_Aux1))
	{
		tm.SetTranslation(GetSlotHelperPos(eIGS_ThirdPerson,m_barrelHelper.c_str(),false));
		GetEntity()->SetSlotLocalTM(eIGS_Aux1,tm);
	}

	m_targetId = 0;
	m_destinationId = 0;
	m_updateTargetTimer = 0.0f;
	m_abandonTargetTimer = 0.0f;
	m_goalYaw = 0.0f;
	m_goalPitch = 0.0f;
	m_burstTimer = 0.0f;
	m_pauseTimer = 0.0f;
	m_searchHint = 0;
	m_fireHint = 1;
	m_deviationPos.zero();

	m_randoms[eRV_UpdateTarget].Range(m_turretparams.update_target_time * m_fireparams.randomness);
	m_randoms[eRV_AbandonTarget].Range(m_turretparams.abandon_target_time * m_fireparams.randomness);
	m_randoms[eRV_BurstTime].Range(m_turretparams.burst_time * m_fireparams.randomness);
	m_randoms[eRV_BurstPause].Range(m_turretparams.burst_pause * m_fireparams.randomness);

	m_lightId = AttachLight(eIGS_ThirdPerson, m_lightId, false);
	StopSound(m_lightSound);
	m_lightSound = INVALID_SOUNDID;

	if(m_turretparams.light_fov > 0.f)
	{
		m_lightId = AttachLight(eIGS_ThirdPerson, 0, true, m_turretparams.mg_range, m_searchparams.light_color*m_searchparams.light_diffuse_mul, 1.f/m_searchparams.light_diffuse_mul, m_searchparams.light_texture, m_turretparams.light_fov, m_searchparams.light_helper, Vec3(0,0,0), Vec3(-1,0,0), m_searchparams.light_material, m_searchparams.light_hdr_dyn);
		m_lightSound = PlayAction(g_pItemStrings->use_light);
	}

	SetFiringLocator(this);

	if(m_fm2)
		m_fm2->Activate(true);

	EnableUpdate(true, eIUS_General);
}
Exemple #9
0
void CBinocular::Zoom()
{
	if (m_zm && !m_bZoomed)
	{
		gEnv->p3DEngine->SetPostEffectParam("Dof_UseMask", 0);
		gEnv->p3DEngine->SetPostEffectParam("Dof_Active", 1);
		gEnv->p3DEngine->SetPostEffectParam("Dof_BlurAmount", 1.0f);
		gEnv->p3DEngine->SetPostEffectParamString("Dof_MaskTexName", "");

		PlayAction(g_pItemStrings->zoom_in);
		m_zm->StartZoom();
		m_bZoomed = true;
		SetDefaultIdleAnimation( eIGS_FirstPerson,g_pItemStrings->idle_raised);
	}
}
Exemple #10
0
//-----------------------------------------------------------------------
bool CBinocular::OnActionZoom(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	if (activationMode == eAAM_OnPress)
	{
		if(m_bZoomed == false)
		{
			PlayAction(g_pItemStrings->raise);
			SetWeaponRaised(true);
			GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndRaiseWeaponAction>::Create(EndRaiseWeaponAction(this)), true);
		}
		else
		{
			if(m_zm && m_zm->IsZoomed())
			{
				PlayAction(g_pItemStrings->lower);
				m_zm->ExitZoom();
			}

			ResetState();
		}
	}

	return true;
}
Exemple #11
0
//-------------------------------------------------------------------------
bool CBinocular::OnActionZoomIn(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	if(m_bZoomed == false)
		return true;
	
	if (m_zm)
	{
		if (m_zm->GetCurrentStep() < m_zm->GetMaxZoomSteps())
		{
			PlayAction(g_pItemStrings->zoom_in);
			m_zm->StartZoom(false, true);
		}
	}

	return true;
}
Exemple #12
0
void CFists::RaiseWeapon(bool raise, bool faster /*= false*/)
{
	//Only when colliding something while running
	if(raise && (GetCurrentAnimState()==eFAS_RUNNING || GetCurrentAnimState()==eFAS_JUMPING) && !IsWeaponRaised())
	{
		if((m_fm && m_fm->IsFiring())||(m_melee && m_melee->IsFiring()))
			return;

		PlayAction(g_pItemStrings->raise);

		SetDefaultIdleAnimation( eIGS_FirstPerson,g_pItemStrings->idle_relaxed);
		SetWeaponRaised(true);

		//Also give the player some impulse into the opposite direction
		CActor *pPlayer = GetOwnerActor();
		Vec3		pos;
		if(pPlayer)
		{
			IPhysicalEntity* playerPhysics = pPlayer->GetEntity()->GetPhysics();
			if(playerPhysics)
			{
				IMovementController *pMC = pPlayer->GetMovementController();
				if(pMC)
				{
					SMovementState state;
					pMC->GetMovementState(state);
					
					pe_action_impulse impulse;
					impulse.iApplyTime = 1;
					impulse.impulse = -state.eyeDirection*600.0f;
					playerPhysics->Action(&impulse);

					pos = state.eyePosition + state.eyeDirection*0.5f;
				}
				
			}
		}

		GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndRaiseWeaponAction>::Create(EndRaiseWeaponAction(this)), true);

		//Sound and FX feedback
		CollisionFeeback(pos,m_currentAnimState);
	}
	else if(!raise)
		SetWeaponRaised(false);

}
Exemple #13
0
//------------------------------------------------------------------------
void CItem::OnAttach(bool attach)
{
	if(attach && m_parentId)
	{
		if(CItem *pParent=static_cast<CItem *>(m_pItemSystem->GetItem(m_parentId)))
		{
			const SStats &stats=pParent->GetStats();

			if(stats.mounted)
			{
				pParent->ForceSkinning(true);
				PlayAction(m_idleAnimation[eIGS_FirstPerson], 0, true);
				ForceSkinning(true);
			}
		}
	}
}
Exemple #14
0
//------------------------------------------------------------------------
void CItem::OnDestroyed()
{
    /* MR, 2007-02-09: shouldn't be needed
    for (int i=0; i<eIGS_Last; i++)
    {
    	ICharacterInstance *pCharacter = GetEntity()->GetCharacter(i);
    	if (pCharacter)
    		pCharacter->SetAnimationSpeed(0);
    }*/

    DestroyedGeometry(true);

    if(!gEnv->pSystem->IsSerializingFile()) //don't replay destroy animations/effects
        PlayAction(g_pItemStrings->destroy);

    EnableUpdate(false);
}
Exemple #15
0
//========================================
void CRocketLauncher::Drop(float impulseScale, bool selectNext, bool byDeath)
{
	CActor* pOwner = GetOwnerActor();
	//Don't let the player drop it if it has not been opened
	if(m_stats.first_selection && pOwner && pOwner->IsPlayer() && pOwner->GetHealth()>0 && !byDeath)
		return;

	if(pOwner && !pOwner->IsPlayer())
	{
		//In this case goes to the clip, no the inventory
		for(TAmmoMap::const_iterator it = m_minDroppedAmmo.begin();it!=m_minDroppedAmmo.end();it++)
			m_ammo[it->first] = it->second;

		m_minDroppedAmmo.clear();
	}

	PlayAction(g_pItemStrings->deselect);
	GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndDropAction>::Create(EndDropAction(this)), true);
}
Exemple #16
0
//=================================================
void CRocketLauncher::AutoDrop()
{
	if(m_zm && m_zm->IsZoomed())
	{
		GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndZoomOutAction>::Create(EndZoomOutAction(this)), true);
	}
	else if(m_fm)
	{
		m_firedRockets--;

		CActor* pOwner = GetOwnerActor();
		// no need to auto-drop for AI
		if(pOwner && !pOwner->IsPlayer())
			return;

		if((GetAmmoCount(m_fm->GetAmmoType()) + GetInventoryAmmoCount(m_fm->GetAmmoType()) <= 0)&&(m_firedRockets<=0))
		{
			PlayAction(g_pItemStrings->deselect);
			GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndDropAction>::Create(EndDropAction(this)), true);
		}
	}
}
Exemple #17
0
//--------------------------------------------------------------------------
bool CBinocular::OnActionZoomOut(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	if(m_bZoomed == false)
		return true;

	if (m_zm)
	{
		if (m_zm->GetCurrentStep() > 1)
		{
			m_zm->ZoomOut();
		}
		else	
		{
			PlayAction(g_pItemStrings->lower);
			m_zm->ExitZoom();

			ResetState();
		}
	}

	return true;
}
Exemple #18
0
void CJaw::DoAutoDrop()
{
	if(!m_playedDropAction && m_fm)
	{
		m_firedRockets--;

		CActor* pOwner = GetOwnerActor();
		// no need to auto-drop for AI
		if(pOwner && !pOwner->IsPlayer())
			return;

		if((GetAmmoCount(m_fm->GetAmmoType())<=0)&&(m_firedRockets<=0))
		{
			if( pOwner )
			{
				uint8 uniqueId = m_pItemSystem->GetItemUniqueId(GetEntity()->GetClass()->GetName());
				bool selectNext = pOwner->GetInventory()->GetCountOfUniqueId(uniqueId) <= 1;

				PlayAction(GetFragmentIds().drop);
				m_playedDropAction = true;
			}
		}
	}
}
//------------------------------------------------------------------------
IMPLEMENT_RMI(CItem, ClLeaveModify)
{
	PlayAction(GetFragmentIds().leave_modify, 0);

	return true;
}
Exemple #20
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 #21
0
void CItem::AttachAccessory(const ItemString &name, bool attach, bool noanim, bool force, bool initialSetup)
{
	if(!force && IsBusy())
		return;

	bool anim = !noanim && m_stats.fp;
	SAccessoryParams *params = GetAccessoryParams(name);

	if(!params)
		return;

	if(attach)
	{
		if(!IsAccessoryHelperFree(params->attach_helper))
			return;

		if(CItem *pAccessory = AddAccessory(name))
		{
			pAccessory->Physicalize(false, false);
			pAccessory->SetViewMode(m_stats.viewmode);

			if(!initialSetup)
				pAccessory->m_bonusAccessoryAmmo.clear();

			SetCharacterAttachment(eIGS_FirstPerson, params->attach_helper, pAccessory->GetEntity(), eIGS_FirstPerson, 0);
			SetBusy(true);

			AttachAction action(pAccessory, params);

			if(anim)
			{
				PlayAction(params->attach_action, 0, false, eIPAF_Default|eIPAF_NoBlend);
				m_scheduler.TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<AttachAction>::Create(action), false);
			}
			else
				action.execute(this);

		}
	}
	else
	{
		if(CItem *pAccessory = GetAccessory(name))
		{
			DetachAction action(pAccessory, params);

			if(anim)
			{
				StopLayer(params->attach_layer, eIPAF_Default|eIPAF_NoBlend);
				PlayAction(params->detach_action, 0, false, eIPAF_Default|eIPAF_NoBlend);
				m_scheduler.TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<DetachAction>::Create(action), false);
				SetBusy(true);
			}
			else
			{
				SetBusy(true);
				action.execute(this);
			}
		}
	}

	//Skip all this for the offhand
	if(GetEntity()->GetClass()!=CItem::sOffHandClass)
		FixAccessories(params, attach);

	//Attach silencer to 2nd SOCOM
	/////////////////////////////////////////////////////////////
	bool isDualWield = IsDualWieldMaster();
	CItem *dualWield = 0;

	if(isDualWield)
	{
		IItem *slave = GetDualWieldSlave();

		if(slave && slave->GetIWeapon())
			dualWield = static_cast<CItem *>(slave);
		else
			isDualWield = false;
	}

	if(isDualWield)
		dualWield->AttachAccessory(name,attach,noanim);

	//////////////////////////////////////////////////////////////

	//Luciano - send game event
	g_pGame->GetIGameFramework()->GetIGameplayRecorder()->Event(GetOwner(), GameplayEvent(eGE_AttachedAccessory, name, (float)attach, (void *)GetEntityId()));

}
Exemple #22
0
void CAccessory::PickUp(EntityId pickerId, bool sound, bool select/* =true */, bool keepHistory/* =true */, const char *setup /*= NULL*/)
{
    CActor *pActor=GetActor(pickerId);
    if (!pActor)
        return;

    TriggerRespawn();

    GetEntity()->EnablePhysics(false);
    Physicalize(false, false);

    bool soundEnabled = IsSoundEnabled();
    EnableSound(sound);

    SetViewMode(0);
    SetOwnerId(pickerId);

    CopyRenderFlags(GetOwner());

    Hide(true);
    m_stats.dropped = false;
    m_stats.detached = false;
    m_stats.brandnew = false;


    IInventory *pInventory = pActor->GetInventory();
    if (!pInventory)
        {
            GameWarning("Actor '%s' has no inventory, when trying to pickup '%s'!",pActor->GetEntity()->GetName(),GetEntity()->GetName());
            return;
        }

    if (!pActor->IsPlayer() || pActor->IsClient() || gEnv->bMultiplayer)
        {
            bool hasAccessory = pInventory->HasAccessory(GetEntity()->GetClass());
            bool hasAccessoryForThisWeapon = pInventory->HasAccessory(GetEntity()->GetClass());

            if (!hasAccessoryForThisWeapon)
                pInventory->AddAccessory(GetEntity()->GetClass());
            if (!hasAccessory)
                ProcessAccessoryAmmoCapacities(pInventory, true);
            if (!hasAccessoryForThisWeapon)
                ProcessAccessoryAmmo(pInventory);
        }

    OnPickedUp(pickerId, m_sharedparams->params.unique);

    if (select)
        {
            PlayAction(GetFragmentIds().pickedup);
        }

    EnableSound(soundEnabled);

    bool isLocalEntity = GetEntity()->GetFlags()&(ENTITY_FLAG_CLIENT_ONLY|ENTITY_FLAG_SERVER_ONLY) ? true : false;

    if (IsServer() && !IsDemoPlayback())
        {
            if(!gEnv->bMultiplayer || isLocalEntity)
                RemoveEntity();
            else if(g_pGame->GetGameRules())
                g_pGame->GetGameRules()->ScheduleEntityRemoval(GetEntityId(),10.0f,false); //Give some time to the clients to pick the msg
        }

    if (IsServer())
        {
            GetGameObject()->SetNetworkParent(pickerId);
            if (!isLocalEntity)
                {
                    pActor->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClPickUp(), CActor::PickItemParams(GetEntityId(), m_stats.selected, sound), eRMI_ToAllClients|eRMI_NoLocalCalls, GetEntityId());
                }
        }
}
Exemple #23
0
 // Actions
 int PlayActionJS(int pageNumber) {return PlayAction(pageNumber);}
Exemple #24
0
void CAccessory::PickUp(EntityId pickerId, bool sound, bool select, bool keepHistory, const char *setup)
{
	CActor *pActor=GetActor(pickerId);
	if (!pActor)
		return;

	if(!CheckAmmoRestrictions(pickerId))
	{
		if (IsServer())
			g_pGame->GetGameRules()->SendTextMessage(eTextMessageCenter, "@ammo_maxed_out", eRMI_ToClientChannel, pActor->GetChannelId(), (string("@")+GetEntity()->GetClass()->GetName()).c_str());
		return;
	}

	TriggerRespawn();

	GetEntity()->EnablePhysics(false);
	Physicalize(false, false);

	bool soundEnabled = IsSoundEnabled();
	EnableSound(sound);

	SetViewMode(0);		
	SetOwnerId(pickerId);

	CopyRenderFlags(GetOwner());

	Hide(true);
	m_stats.dropped = false;
	m_stats.brandnew = false;


	IInventory *pInventory = pActor->GetInventory();
	if (!pInventory)
	{
		GameWarning("Actor '%s' has no inventory, when trying to pickup '%s'!",pActor->GetEntity()->GetName(),GetEntity()->GetName());
		return;
	}

	if(!pInventory->HasAccessory(GetEntity()->GetClass()))
	{
		pInventory->AddAccessory(GetEntity()->GetClass());
	}

	OnPickedUp(pickerId, m_sharedparams->params.unique);	

	PlayAction(g_pItemStrings->pickedup);

	EnableSound(soundEnabled);

	if (IsServer() && !IsDemoPlayback())
	{
		if(!gEnv->bMultiplayer)
			RemoveEntity();
		else if(g_pGame->GetGameRules())
			g_pGame->GetGameRules()->ScheduleEntityRemoval(GetEntityId(),10.0f,false); //Give some time to the clients to pick the msg
	}

	if (IsServer())
	{
		GetGameObject()->SetNetworkParent(pickerId);
		if ((GetEntity()->GetFlags()&(ENTITY_FLAG_CLIENT_ONLY|ENTITY_FLAG_SERVER_ONLY)) == 0)
		{
			pActor->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClPickUp(), CActor::PickItemParams(GetEntityId(), m_stats.selected, sound), eRMI_ToAllClients|eRMI_NoLocalCalls, GetEntityId());

			const char *displayName=GetDisplayName();
}
	}
}
//------------------------------------------------------------------------
IMPLEMENT_RMI(CItem, ClLeaveModify)
{
	PlayAction(g_pItemStrings->leave_modify, 0);

	return true;
}
//------------------------------------------------------------------------
IMPLEMENT_RMI(CItem, ClEnterModify)
{
	PlayAction(g_pItemStrings->enter_modify, 0, false, eIPAF_Default | eIPAF_RepeatLastFrame);

	return true;
}
Exemple #27
0
//------------------------------------------------------------------------
bool CItem::ReadGeometry(const IItemParamsNode *geometry)
{
	FUNCTION_PROFILER(GetISystem(), PROFILE_GAME);

	if(!m_sharedparams->Valid())
	{
		// read teh helpers
		m_sharedparams->helpers.resize(0);

		const IItemParamsNode *attachments = geometry->GetChild("boneattachments");

		if(attachments)
		{
			int n = attachments->GetChildCount();
			SAttachmentHelper helper;

			for(int i=0; i<n; i++)
			{
				const IItemParamsNode *attachment = attachments->GetChild(i);
				const char *slot = attachment->GetAttribute("target");
				const char *name = attachment->GetAttribute("name");
				const char *bone = attachment->GetAttribute("bone");

				int islot = TargetToSlot(slot);

				if(islot == eIGS_Last)
				{
					GameWarning("Invalid attachment helper target for item '%s'! Skipping...", GetEntity()->GetName());
					continue;
				}

				if(!name || !bone)
				{
					GameWarning("Invalid attachment helper specification for item '%s'! Skipping...", GetEntity()->GetName());
					continue;
				}

				helper.name = name;
				helper.bone = bone;
				helper.slot = islot;

				m_sharedparams->helpers.push_back(helper);
			}
		}
	}

	bool result = true;
	int n = geometry->GetChildCount();

	for(int i=0; i<n; i++)
	{
		const IItemParamsNode *child = geometry->GetChild(i);
		int islot=TargetToSlot(geometry->GetChildName(i));
		assert(islot >= 0);

		if(islot < eIGS_Last)
		{
			result = result && SetGeometryFromParams(islot, child);

			if(result)
				PlayAction(m_idleAnimation[islot], 0, true, (eIPAF_Default|eIPAF_NoBlend)&~eIPAF_Owner);
		}
	}

	ForceSkinning(true);

	return result;
}
Exemple #28
0
//-------------------------------------------------------------------------
void CLam::AttachLAMLight(bool attach, CItem* pLightAttach, eGeometrySlot slot)
{
    //GameWarning("CLam::AttachLight");

    int id = (slot==eIGS_FirstPerson) ? 0 : 1;

    if (attach)
    {
        if (m_lamparams.light_range[id] == 0.f)
            return;

        Vec3 color = m_lamparams.light_color[id] * m_lamparams.light_diffuse_mul[id];
        float specular = 1.0f/m_lamparams.light_diffuse_mul[id];

        string helper;
        Vec3 dir(-1,0,0);
        Vec3 localOffset(0.0f,0.0f,0.0f);

        if (this != pLightAttach)
        {
            SAccessoryParams *params = pLightAttach->GetAccessoryParams(GetEntity()->GetClass()->GetName());
            if (!params)
                return;

            helper = params->attach_helper.c_str();
            if(slot==eIGS_FirstPerson)
                helper.append("_light");

            //Assets don't have same orientation for pistol/rifle.. 8/
            dir = (m_lamparams.isLamRifle && id==0) ? Vec3(-0.1f,-1.0f,0.0f) : Vec3(-1.0f,-0.1f,0.0f);
            dir.Normalize();
        }

        bool fakeLight = false;
        bool castShadows = false;

        //Some MP/SP restrictions for lights
        IRenderNode *pCasterException = NULL;
        if(CActor *pOwner = pLightAttach->GetOwnerActor())
        {
            if(gEnv->bMultiplayer)
            {
                if(!pOwner->IsClient())
                    fakeLight = true;
                else
                    castShadows = true;
            }
            else
            {
                if(pOwner->IsPlayer())
                    castShadows = true;
                //castShadows = false; //Not for now
            }

            if(castShadows)
            {
                if(IEntityRenderProxy* pRenderProxy = static_cast<IEntityRenderProxy*>(pOwner->GetEntity()->GetProxy(ENTITY_PROXY_RENDER)))
                    pCasterException = pRenderProxy->GetRenderNode();
            }
        }

        m_lightID[id] = pLightAttach->AttachLightEx(slot, 0, true, fakeLight, castShadows, pCasterException, m_lamparams.light_range[id], color, specular, m_lamparams.light_texture[id], m_lamparams.light_fov[id], helper.c_str(), localOffset, dir, m_lamparams.light_material[id].c_str(), m_lamparams.light_hdr_dyn[id]);

        if (m_lightID[id])
            ++s_lightCount;

        // sounds
        pLightAttach->PlayAction(g_pItemStrings->enable_light);

        if (m_lightSoundId == INVALID_SOUNDID)
            m_lightSoundId = pLightAttach->PlayAction(g_pItemStrings->use_light);

        //Detach the non-needed light
        uint8 other = id^1;
        if (m_lightID[other])
        {
            pLightAttach->AttachLightEx(other, m_lightID[other], false, true),
                         m_lightID[other] = 0;
            --s_lightCount;
        }
    }
    else
    {
        if (m_lightID[id])
        {
            pLightAttach->AttachLightEx(slot, m_lightID[id], false, true);
            m_lightID[id] = 0;
            --s_lightCount;

            PlayAction(g_pItemStrings->disable_light);
            StopSound(m_lightSoundId);
            m_lightSoundId = INVALID_SOUNDID;
        }
    }

    //GameWarning("Global light count = %d", s_lightCount);
}
//------------------------------------------------------------------------
bool CItem::SetGeometry(int slot, const ItemString &name, const Vec3 &poffset, const Ang3 &aoffset, float scale, bool forceReload)
{
	bool changedfp=false;

	switch(slot)
	{
	case eIGS_Arms:
	{
		if(!name || forceReload)
		{
			GetEntity()->FreeSlot(slot);
#ifndef ITEM_USE_SHAREDSTRING
			m_geometry[slot].resize(0);
#else
			m_geometry[slot].reset();
#endif
		}

		ResetCharacterAttachment(eIGS_FirstPerson, ITEM_ARMS_ATTACHMENT_NAME);

		ICharacterInstance *pCharacter=0;

		if(name && name[0])
		{
			if(name != m_geometry[slot])
				GetEntity()->LoadCharacter(slot, name);

			DrawSlot(eIGS_Arms, false);

			pCharacter = GetEntity()->GetCharacter(eIGS_Arms);
		}
		else if(m_pForcedArms)
		{
			pCharacter = m_pForcedArms;
		}
		else
		{
			int armsId=m_stats.hand==eIH_Right?0:1;
			pCharacter = GetOwnerActor()?GetOwnerActor()->GetFPArms(armsId):0;
		}

		if(pCharacter)
		{
			pCharacter->SetFlags(pCharacter->GetFlags()&(~CS_FLAG_UPDATE));
			SetCharacterAttachment(eIGS_FirstPerson, ITEM_ARMS_ATTACHMENT_NAME, pCharacter, 0);
		}
	}
	break;

	case eIGS_FirstPerson:
	case eIGS_ThirdPerson:
	default:
	{
		if(!name || forceReload)
		{
			GetEntity()->FreeSlot(slot);
#ifndef ITEM_USE_SHAREDSTRING
			m_geometry[slot].resize(0);
#else
			m_geometry[slot].reset();
#endif
		}

		DestroyAttachmentHelpers(slot);

		if(name && name[0])
		{
			if(m_geometry[slot] != name)
			{
				const char *ext = PathUtil::GetExt(name.c_str());

				if((stricmp(ext, "chr") == 0) || (stricmp(ext, "cdf") == 0) || (stricmp(ext, "cga") == 0))
					GetEntity()->LoadCharacter(slot, name, 0);
				else
					GetEntity()->LoadGeometry(slot, name, 0, 0);

				changedfp=slot==eIGS_FirstPerson;
			}

			CreateAttachmentHelpers(slot);

			SetDefaultIdleAnimation(slot, g_pItemStrings->idle);
		}

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

			if(pCharacter)
			{
				pCharacter->SetFlags(pCharacter->GetFlags()&(~CS_FLAG_UPDATE));
			}
		}
		else if(slot == eIGS_Destroyed)
			DrawSlot(eIGS_Destroyed, false);
	}
	break;
	}

	Matrix34 slotTM;
	slotTM = Matrix34::CreateRotationXYZ(aoffset);
	slotTM.Scale(Vec3(scale, scale, scale));
	slotTM.SetTranslation(poffset);
	GetEntity()->SetSlotLocalTM(slot, slotTM);

	if(changedfp && m_stats.mounted)
	{
		PlayAction(m_idleAnimation[eIGS_FirstPerson], 0, true);
		ForceSkinning(true);

		if(!m_mountparams.pivot.empty())
		{
			Matrix34 tm=GetEntity()->GetSlotLocalTM(eIGS_FirstPerson, false);
			Vec3 pivot = GetSlotHelperPos(eIGS_FirstPerson, m_mountparams.pivot.c_str(), false);
			tm.AddTranslation(pivot);

			GetEntity()->SetSlotLocalTM(eIGS_FirstPerson, tm);
		}

		GetEntity()->InvalidateTM();
	}

	m_geometry[slot] = name ? name : "";

	ReAttachAccessories();

	return true;
}
Exemple #30
0
// turn all servos off (make sure robot is sitting)
void ServoShutdown() {
    WalkToggle(false);  // turn off walking if is walking
    PlayAction(15);  // sit robot
    // shutdown
    cm730.DXLPowerOn(false);
}