Example #1
0
void CActorDeathEffector::Stop()
{
	RemoveEffector			(Actor(),effActorDeath);
	m_death_sound.destroy	();
	enable_input			();
	show_indicators			();
}
Example #2
0
void CControllerAura::update_schedule()
{
	if (!m_object->g_Alive()) return;

	float dist_to_actor		= Actor()->Position().distance_to(m_object->Position());

	if ((dist_to_actor > aura_radius + FAKE_MIN_ADD_DIST) && (dist_to_actor < aura_radius + FAKE_MAX_ADD_DIST)) 
	{
		
		// first time? 
		if (m_time_fake_aura == 0) {
			m_time_fake_aura = time() + 5000 + Random.randI(FAKE_AURA_DELAY);
			
			if (active()) {
				m_effector->switch_off	();
				m_effector				= 0;
			}
		} else {
			if (active()) {
				// check to stop
				if (m_time_fake_aura < time())  {
					m_effector->switch_off	();
					m_effector				= 0;
					m_time_fake_aura		= time() + 5000 + Random.randI(FAKE_AURA_DELAY);
				}
			} else {
				// check to start
				if (m_time_fake_aura < time())  {
					m_effector = new CPPEffectorControllerAura(m_state, 5000, aura_sound.left, aura_sound.right);
					Actor()->Cameras().AddPPEffector				(m_effector);

					m_time_fake_aura		= time() + 5000 + Random.randI(FAKE_AURA_DURATION);
				}
			}
		}
	} else {
		m_time_fake_aura = 0;

		bool need_be_active		= (dist_to_actor < aura_radius);

		if (active()) {
			if (!need_be_active) {
				m_effector->switch_off	();
				m_effector				= 0;
				
				m_hit_state				= eNone;

			} else {
			}
		} else {
			if (need_be_active) {
				// create effector
				m_effector = new CPPEffectorControllerAura(m_state, 5000, aura_sound.left, aura_sound.right);
				Actor()->Cameras().AddPPEffector				(m_effector);
				
				m_hit_state			= eEffectoring;
				m_time_started		= time();
			} else {
			}
		}
		
	}

	if (active()) {
		CEffectorCam* ce = Actor()->Cameras().GetCamEffector((ECamEffectorType)effControllerAura2);
		if(!ce) AddEffector(Actor(), effControllerAura2, "effector_controller_aura2", 0.15f);
	}else{
		CEffectorCam* ce = Actor()->Cameras().GetCamEffector((ECamEffectorType)effControllerAura2);
		if(ce)
			RemoveEffector(Actor(), effControllerAura2);
	}
}
Example #3
0
void CActorCondition::UpdateCondition()
{
	if(psActorFlags.test(AF_GODMODE_RT))
	{
		UpdateSatiety();
		UpdateBoosters();

		m_fAlcohol		+= m_fV_Alcohol*m_fDeltaTime;
		clamp			(m_fAlcohol,			0.0f,		1.0f);
		if(IsGameTypeSingle())
		{
			CEffectorCam* ce = Actor()->Cameras().GetCamEffector((ECamEffectorType)effAlcohol);
			if(ce)
				RemoveEffector(m_object,effAlcohol);
		}
	}

	if (GodMode())				return;
	if (!object().g_Alive())	return;
	if (!object().Local() && m_object != Level().CurrentViewEntity())		return;	
	
	float base_weight			= object().MaxCarryWeight();
	float cur_weight			= object().inventory().TotalWeight();

	if ((object().mstate_real&mcAnyMove))
	{
		ConditionWalk( cur_weight / base_weight,
			isActorAccelerated( object().mstate_real,object().IsZoomAimingMode() ),
			(object().mstate_real&mcSprint) != 0 );
	}
	else
	{
		ConditionStand( cur_weight / base_weight );
	}
	
	if ( IsGameTypeSingle() )
	{
		float k_max_power = 1.0f;
		if( true )
		{
			k_max_power = 1.0f + _min(cur_weight, base_weight) / base_weight
				+ _max(0.0f, (cur_weight - base_weight) / 10.0f);
		}
		else
		{
			k_max_power = 1.0f;
		}
		SetMaxPower		(GetMaxPower() - m_fPowerLeakSpeed * m_fDeltaTime * k_max_power);
	}


	m_fAlcohol		+= m_fV_Alcohol*m_fDeltaTime;
	clamp			(m_fAlcohol,			0.0f,		1.0f);

	if ( IsGameTypeSingle() )
	{	
		CEffectorCam* ce = Actor()->Cameras().GetCamEffector((ECamEffectorType)effAlcohol);
		if	((m_fAlcohol>0.0001f) ){
			if(!ce){
				AddEffector(m_object,effAlcohol, "effector_alcohol", GET_KOEFF_FUNC(this, &CActorCondition::GetAlcohol));
			}
		}else{
			if(ce)
				RemoveEffector(m_object,effAlcohol);
		}

		
		string512			pp_sect_name;
		shared_str ln		= Level().name();
		if(ln.size())
		{
			CEffectorPP* ppe	= object().Cameras().GetPPEffector((EEffectorPPType)effPsyHealth);
			

			strconcat			(sizeof(pp_sect_name),pp_sect_name, "effector_psy_health", "_", *ln);
			if(!pSettings->section_exist(pp_sect_name))
				xr_strcpy			(pp_sect_name, "effector_psy_health");

			if	( !fsimilar(GetPsyHealth(), 1.0f, 0.05f) )
			{
				if(!ppe)
				{
					AddEffector(m_object,effPsyHealth, pp_sect_name, GET_KOEFF_FUNC(this, &CActorCondition::GetPsy));
				}
			}else
			{
				if(ppe)
					RemoveEffector(m_object,effPsyHealth);
			}
		}
//-		if(fis_zero(GetPsyHealth()))
//-			SetHealth( 0.0f );
	};

	UpdateSatiety();
	UpdateBoosters();

	inherited::UpdateCondition();

	if( IsGameTypeSingle() )
		UpdateTutorialThresholds();

	if(GetHealth()<0.05f && m_death_effector==NULL && IsGameTypeSingle())
	{
		if(pSettings->section_exist("actor_death_effector"))
			m_death_effector = xr_new<CActorDeathEffector>(this, "actor_death_effector");
	}
	if(m_death_effector && m_death_effector->IsActual())
	{
		m_death_effector->UpdateCL	();

		if(!m_death_effector->IsActual())
			m_death_effector->Stop();
	}

	AffectDamage_InjuriousMaterialAndMonstersInfluence();
}