Esempio n. 1
0
void CRestrictedObject::remove_restrictions	(const shared_str &out_restrictions, const shared_str &in_restrictions)
{
	if (!out_restrictions.size() && !in_restrictions.size())
		return;

	START_PROFILE("Restricted Object/Remove Restrictions");
	
	Level().space_restriction_manager().remove_restrictions	(object().ID(),*out_restrictions,*in_restrictions);
	
	actual						(false);

	STOP_PROFILE;
}
BOOL is_combat_cover			(shared_str const &table_id)
{
	if (table_id.size() == 0)
		return					(FALSE);

	string256					temp;
	xr_strcpy					(temp, "smart_covers.descriptions.");
	xr_strcat					(temp, *table_id);

	luabind::object				table, value;
	bool						result = 
		ai().script_engine().function_object(
		temp,
		table,
		LUA_TTABLE
		);

	VERIFY2						(result, make_string("bad or missing description in smart_cover [%s]", table_id.c_str()));
	if (table.type() != LUA_TTABLE) {
		VERIFY					(table.type() != LUA_TNIL);
		return					(TRUE);
	}

	value						= table["is_combat_cover"];
	if (value.type() == LUA_TNIL) {
		Msg						("! is_combat_cover flag not found for smart_cover [%s], forcing to \"true\"", table_id.c_str());
		return					(TRUE);
	}

	return						(parse_bool(table, "is_combat_cover") ? TRUE : FALSE);
}
Esempio n. 3
0
void CEnvironment::SetWeather(shared_str name, bool forced)
{
//.	static BOOL bAlready = FALSE;
//.	if(bAlready)	return;
	if (name.size())	{
//.		bAlready = TRUE;
        EnvsMapIt it		= WeatherCycles.find(name);
		if (it == WeatherCycles.end())
		{
			Msg("! Invalid weather name: %s", name.c_str());
			return;
		}
        R_ASSERT3			(it!=WeatherCycles.end(),"Invalid weather name.",*name);
		CurrentCycleName	= it->first;
		if (forced)			{Invalidate();			}
		if (!bWFX){
			CurrentWeather		= &it->second;
			CurrentWeatherName	= it->first;
		}
		if (forced)			{SelectEnvs(fGameTime);	}
#ifdef WEATHER_LOGGING
		Msg					("Starting Cycle: %s [%s]",*name,forced?"forced":"deferred");
#endif
    }else{
#ifndef _EDITOR
		FATAL				("! Empty weather name");
#endif
    }
}
Esempio n. 4
0
void CUIHudStatesWnd::SetAmmoIcon(const shared_str& sect_name)
{
	if (!sect_name.size())
	{
		m_ui_weapon_icon->Show(false);
		return;
	}
	m_ui_weapon_icon->Show(true);

	Frect texture_rect;
	texture_rect.x1					= pSettings->r_float(sect_name,  "inv_grid_x")		*INV_GRID_WIDTH;
	texture_rect.y1					= pSettings->r_float(sect_name,  "inv_grid_y")		*INV_GRID_HEIGHT;
	texture_rect.x2					= pSettings->r_float( sect_name, "inv_grid_width")	*INV_GRID_WIDTH;
	texture_rect.y2					= pSettings->r_float( sect_name, "inv_grid_height")	*INV_GRID_HEIGHT;
	texture_rect.rb.add				(texture_rect.lt);
	m_ui_weapon_icon->GetUIStaticItem().SetTextureRect(texture_rect);
	m_ui_weapon_icon->SetStretchTexture(true);

	float h = texture_rect.height() * 0.8f;
	float w = texture_rect.width() * 0.8f;

// now perform only width scale for ammo, which (W)size >2
	if (texture_rect.width() > 2.01f*INV_GRID_WIDTH)
		w = INV_GRID_WIDTH * 1.5f;

	m_ui_weapon_icon->SetWidth( w*UI().get_current_kx() );
	m_ui_weapon_icon->SetHeight( h );
}
Esempio n. 5
0
CGameTaskManager::CGameTaskManager()
{
	m_gametasks					= xr_new<CGameTaskWrapper>();
	m_flags.zero				();
	m_flags.set					(eChanged, TRUE);
	if(g_active_task_id.size())	SetActiveTask(g_active_task_id, g_active_task_objective_id);
}
Esempio n. 6
0
void CUITalkWnd::AddQuestion(const shared_str& text, const shared_str& value)
{
	if(text.size() == 0)
	{
		return;
	}
	UITalkDialogWnd->AddQuestion(*CStringTable().translate(text),value.c_str());
}
Esempio n. 7
0
void CUITalkWnd::AddAnswer(const shared_str& text, LPCSTR SpeakerName)
{
	//для пустой фразы вообще ничего не выводим
	if(text.size() == 0) return;
	PlaySnd			(text.c_str());

	bool i_am = (0 == xr_strcmp(SpeakerName, m_pOurInvOwner->Name()));
	UITalkDialogWnd->AddAnswer(SpeakerName,*CStringTable().translate(text),i_am);
}
Esempio n. 8
0
bool CEnvironment::SetWeatherFX(shared_str name)
{
	if (bWFX)				return false;
	if (name.size()){
		EnvsMapIt it		= WeatherFXs.find(name);
		R_ASSERT3			(it!=WeatherFXs.end(),"Invalid weather effect name.",*name);
		EnvVec* PrevWeather = CurrentWeather; VERIFY(PrevWeather);
		CurrentWeather		= &it->second;
		CurrentWeatherName	= it->first;

		float rewind_tm		= WFX_TRANS_TIME*fTimeFactor;
		float start_tm		= fGameTime+rewind_tm;
		float current_length;
		float current_weight;
		if (Current[0]->exec_time>Current[1]->exec_time){
			float x			= fGameTime>Current[0]->exec_time?fGameTime-Current[0]->exec_time:(DAY_LENGTH-Current[0]->exec_time)+fGameTime;
			current_length	= (DAY_LENGTH-Current[0]->exec_time)+Current[1]->exec_time;
			current_weight	= x/current_length; 
		}else{
			current_length	= Current[1]->exec_time-Current[0]->exec_time;
			current_weight	= (fGameTime-Current[0]->exec_time)/current_length; 
		}
		clamp				(current_weight,0.f,1.f);

		std::sort			(CurrentWeather->begin(),CurrentWeather->end(),sort_env_etl_pred);
		CEnvDescriptor* C0	= CurrentWeather->at(0);
		CEnvDescriptor* C1	= CurrentWeather->at(1);
		CEnvDescriptor* CE	= CurrentWeather->at(CurrentWeather->size()-2);
		CEnvDescriptor* CT	= CurrentWeather->at(CurrentWeather->size()-1);
		C0->copy			(*Current[0]);	C0->exec_time = NormalizeTime(fGameTime-((rewind_tm/(Current[1]->exec_time-fGameTime))*current_length-rewind_tm));
		C1->copy			(*Current[1]);	C1->exec_time = NormalizeTime(start_tm);
		for (EnvIt t_it=CurrentWeather->begin()+2; t_it!=CurrentWeather->end()-1; t_it++)
			(*t_it)->exec_time= NormalizeTime(start_tm+(*t_it)->exec_time_loaded);
		SelectEnv			(PrevWeather,WFX_end_desc[0],CE->exec_time);
		SelectEnv			(PrevWeather,WFX_end_desc[1],WFX_end_desc[0]->exec_time+0.5f);
		CT->copy			(*WFX_end_desc[0]);CT->exec_time = NormalizeTime(CE->exec_time+rewind_tm);
		wfx_time			= TimeDiff(fGameTime,CT->exec_time);
		bWFX				= true;

		// sort wfx envs
		std::sort			(CurrentWeather->begin(),CurrentWeather->end(),sort_env_pred);

		Current[0]			= C0;
		Current[1]			= C1;
#ifdef WEATHER_LOGGING
		Msg					("Starting WFX: '%s' - %3.2f sec",*name,wfx_time);
		for (EnvIt l_it=CurrentWeather->begin(); l_it!=CurrentWeather->end(); l_it++)
			Msg				(". Env: '%s' Tm: %3.2f",*(*l_it)->sect_name,(*l_it)->exec_time);
#endif
	}else{
#ifndef _EDITOR
		FATAL				("! Empty weather effect name");
#endif
	}
	return true;
}
Esempio n. 9
0
void CEffect_Thunderbolt::OnFrame(shared_str id, float period, float duration)
{
	BOOL enabled			= !!(id.size());
	if (bEnabled!=enabled){
    	bEnabled			= enabled;
	    next_lightning_time = Device.fTimeGlobal+period+Random.randF(-period*0.5f,period*0.5f);
    }else if (bEnabled&&(Device.fTimeGlobal>next_lightning_time)){ 
    	if (state==stIdle && !!(id.size())) Bolt(id,period,duration);
    }
	if (state==stWorking){
    	if (current_time>life_time) state = stIdle;
    	current_time	+= Device.fTimeDelta;
		Fvector fClr;		
		int frame;
		u32 uClr		= current->color_anim->CalculateRGB(current_time/life_time,frame);
		fClr.set		(
			clampr(float(color_get_R(uClr)/255.f), 0.f, 1.f),
			clampr(float(color_get_G(uClr)/255.f), 0.f, 1.f),
			clampr(float(color_get_B(uClr)/255.f), 0.f, 1.f)
		);

        lightning_phase	= 1.5f*(current_time/life_time);
        clamp			(lightning_phase,0.f,1.f);

		CEnvironment&	environment = g_pGamePersistent->Environment();
		
		Fvector&		sky_color = environment.CurrentEnv->sky_color;
        sky_color.mad	( fClr, environment.p_sky_color );
		clamp			( sky_color.x, 0.f, 1.f );
		clamp			( sky_color.y, 0.f, 1.f );
		clamp			( sky_color.z, 0.f, 1.f );

        environment.CurrentEnv->sun_color.mad(fClr,environment.p_sun_color);
		environment.CurrentEnv->fog_color.mad(fClr,environment.p_fog_color);

		if (::Render->get_generation()==IRender_interface::GENERATION_R2)	{
			R_ASSERT	( _valid(current_direction) );
			g_pGamePersistent->Environment().CurrentEnv->sun_dir = current_direction;
			VERIFY2(g_pGamePersistent->Environment().CurrentEnv->sun_dir.y<0,"Invalid sun direction settings while CEffect_Thunderbolt");

		} 
    }
}
Esempio n. 10
0
bool CInventoryOwner::HasInfo(shared_str info_id) const
{
	VERIFY( info_id.size() );
	const KNOWN_INFO_VECTOR* known_info = m_known_info_registry->registry().objects_ptr ();
	if(!known_info) return false;

	if(std::find_if(known_info->begin(), known_info->end(), CFindByIDPred(info_id)) == known_info->end())
		return false;

	return true;
}
void CUIColorAnimatorWrapper::SetColorAnimation(const shared_str &animationName)
{
	if (animationName.size() != 0)
	{
		colorAnimation	= LALib.FindItem(*animationName);
		R_ASSERT2(colorAnimation, *animationName);
	}
	else
	{
		colorAnimation	= NULL;
	}
}
Esempio n. 12
0
bool CInventoryOwner::GetInfo	(shared_str info_id, INFO_DATA& info_data) const
{
	VERIFY( info_id.size() );
	const KNOWN_INFO_VECTOR* known_info = m_known_info_registry->registry().objects_ptr ();
	if(!known_info) return false;

	KNOWN_INFO_VECTOR::const_iterator it = std::find_if(known_info->begin(), known_info->end(), CFindByIDPred(info_id));
	if(known_info->end() == it)
		return false;

	info_data = *it;
	return true;
}
Esempio n. 13
0
void CCharacterInfo::InitSpecificCharacter (shared_str new_id)
{
    R_ASSERT(new_id.size());
    m_SpecificCharacterId = new_id;

    m_SpecificCharacter.Load(m_SpecificCharacterId);
    if(Rank().value() == NO_RANK)
        SetRank(m_SpecificCharacter.Rank());
    if(Reputation().value() == NO_REPUTATION)
        SetReputation(m_SpecificCharacter.Reputation());
    if(Community().index() == NO_COMMUNITY_INDEX)
        SetCommunity(m_SpecificCharacter.Community());
    if(!m_StartDialog || !m_StartDialog.size() )
        m_StartDialog = m_SpecificCharacter.data()->m_StartDialog;
}
Esempio n. 14
0
void CInventoryOwner::OnDisableInfo(shared_str info_id) const
{
	VERIFY( info_id.size() );
	//удалить запись из реестра
	
#ifdef DEBUG
	if(psAI_Flags.test(aiInfoPortion))
		Msg("[%s] Disabled Info [%s]", Name(), *info_id);
#endif

	KNOWN_INFO_VECTOR& known_info = m_known_info_registry->registry().objects();

	KNOWN_INFO_VECTOR_IT it = std::find_if(known_info.begin(), known_info.end(), CFindByIDPred(info_id));
	if( known_info.end() == it)	return;
	known_info.erase(it);
}
Esempio n. 15
0
void CUITalkWnd::AddQuestion(const shared_str& text, const shared_str& value
#ifdef NUM_PHRASES
, int number
#endif
)
{
	if(text.size() == 0)
	{
		return;
	}
	UITalkDialogWnd->AddQuestion(*CStringTable().translate(text),value.c_str()
#ifdef NUM_PHRASES
, number
#endif
);
}
Esempio n. 16
0
void CEffect_Thunderbolt::Bolt(shared_str id, float period, float lt)
{
	VERIFY					(id.size());
	state 		            = stWorking;
	life_time	            = lt+Random.randF(-lt*0.5f,lt*0.5f);
    current_time            = 0.f;

    current		            = g_pGamePersistent->Environment().thunderbolt_collection(collection, id)->GetRandomDesc(); VERIFY(current);

    Fmatrix XF,S;
    Fvector pos,dev;
    float sun_h, sun_p; 
	CEnvironment&			environment = g_pGamePersistent->Environment();
    environment.CurrentEnv->sun_dir.getHP			(sun_h,sun_p);
    float alt	            = environment.p_var_alt;//Random.randF(environment.p_var_alt.x,environment.p_var_alt.y);
    float lng	            = Random.randF(sun_h-environment.p_var_long+PI,sun_h+environment.p_var_long+PI); 
    float dist	            = Random.randF(FAR_DIST*environment.p_min_dist,FAR_DIST*.95f);
    current_direction.setHP	(lng,alt);
    pos.mad		            (Device.vCameraPosition,current_direction,dist);
    dev.x		            = Random.randF(-environment.p_tilt,environment.p_tilt);
    dev.y		            = Random.randF(0,PI_MUL_2);
    dev.z		            = Random.randF(-environment.p_tilt,environment.p_tilt);
    XF.setXYZi	            (dev);               

    Fvector light_dir 		= {0.f,-1.f,0.f};
    XF.transform_dir		(light_dir);
    lightning_size			= FAR_DIST*2.f;
    RayPick					(pos,light_dir,lightning_size);

    lightning_center.mad	(pos,light_dir,lightning_size*0.5f);

    S.scale					(lightning_size,lightning_size,lightning_size);
    XF.translate_over		(pos);
    current_xform.mul_43	(XF,S);

    float next_v			= Random.randF();

    if (next_v<environment.p_second_prop){
	    next_lightning_time = Device.fTimeGlobal+lt+EPS_L;
    }else{
	    next_lightning_time = Device.fTimeGlobal+period+Random.randF(-period*0.3f,period*0.3f);
		current->snd.play_no_feedback		(0,0,dist/300.f,&pos,0,0,&Fvector2().set(dist/2,dist*2.f));
    }


	current_direction.invert			();	// for env-sun
}
Esempio n. 17
0
void IConsole_Command::add_to_LRU(shared_str const& arg)
{
    if (arg.size() == 0 || bEmptyArgsHandled)
    {
        return;
    }

    bool dup = (std::find(m_LRU.begin(), m_LRU.end(), arg) != m_LRU.end());
    if (!dup)
    {
        m_LRU.push_back(arg);
        if (m_LRU.size() > LRU_MAX_COUNT)
        {
            m_LRU.erase(m_LRU.begin());
        }
    }
}
Esempio n. 18
0
void CInventoryOwner::TransferInfo(shared_str info_id, bool add_info) const
{
	VERIFY( info_id.size() );
	const CObject* pThisObject = smart_cast<const CObject*>(this); VERIFY(pThisObject);

	//отправляем от нашему PDA пакет информации с номером
	NET_Packet		P;
	CGameObject::u_EventGen(P, GE_INFO_TRANSFER, pThisObject->ID());
	P.w_u16			(pThisObject->ID());					//отправитель
	P.w_stringZ		(info_id);							//сообщение
	P.w_u8			(add_info?1:0);							//добавить/удалить информацию
	CGameObject::u_EventSend(P);

	CInfoPortion info_portion;
	info_portion.Load(info_id);
	{
		if(add_info)
			OnReceiveInfo	(info_id);
		else
			OnDisableInfo	(info_id);
	}
}
Esempio n. 19
0
bool CInventoryOwner::OnReceiveInfo(shared_str info_id) const
{
	VERIFY( info_id.size() );
	//добавить запись в реестр
	KNOWN_INFO_VECTOR& known_info = m_known_info_registry->registry().objects();
	KNOWN_INFO_VECTOR_IT it = std::find_if(known_info.begin(), known_info.end(), CFindByIDPred(info_id));
	if( known_info.end() == it)
		known_info.push_back(INFO_DATA(info_id, Level().GetGameTime()));
	else
		return false;

#ifdef DEBUG
	if(psAI_Flags.test(aiInfoPortion))
		Msg("[%s] Received Info [%s]", Name(), *info_id);
#endif

	//Запустить скриптовый callback
	const CGameObject* pThisGameObject = smart_cast<const CGameObject*>(this);
	VERIFY(pThisGameObject);

//	SCRIPT_CALLBACK_EXECUTE_2(*m_pInfoCallback, pThisGameObject->lua_game_object(), info_index);
//	pThisGameObject->callback(GameObject::eInventoryInfo)(pThisGameObject->lua_game_object(), *info_id);
	

	CInfoPortion info_portion;
	info_portion.Load(info_id);

	//запустить скриптовые функции
	info_portion.RunScriptActions(pThisGameObject);

	//выкинуть те info portions которые стали неактуальными
	for(u32 i=0; i<info_portion.DisableInfos().size(); i++)
		TransferInfo(info_portion.DisableInfos()[i], false);


	return true;
}
Esempio n. 20
0
void CUIMainIngameWnd::SetAmmoIcon (const shared_str& sect_name)
{
	if ( !sect_name.size() )
	{
		UIWeaponIcon.Show			(false);
		return;
	};

	UIWeaponIcon.Show			(true);
	//properties used by inventory menu
	float iGridWidth			= pSettings->r_float(sect_name, "inv_grid_width");
	float iGridHeight			= pSettings->r_float(sect_name, "inv_grid_height");

	float iXPos				= pSettings->r_float(sect_name, "inv_grid_x");
	float iYPos				= pSettings->r_float(sect_name, "inv_grid_y");

	UIWeaponIcon.GetUIStaticItem().SetOriginalRect(	(iXPos		 * INV_GRID_WIDTH),
													(iYPos		 * INV_GRID_HEIGHT),
													(iGridWidth	 * INV_GRID_WIDTH),
													(iGridHeight * INV_GRID_HEIGHT));
	UIWeaponIcon.SetStretchTexture(true);

	// now perform only width scale for ammo, which (W)size >2
	// all others ammo (1x1, 1x2) will be not scaled (original picture)
	float w = ((iGridWidth>2)?1.6f:iGridWidth)*INV_GRID_WIDTH*0.9f;
	float h = INV_GRID_HEIGHT*0.9f;//1 cell

	float x = UIWeaponIcon_rect.x1;
	if	(iGridWidth<2)
		x	+= ( UIWeaponIcon_rect.width() - w) / 2.0f;

	UIWeaponIcon.SetWndPos	(x, UIWeaponIcon_rect.y1);
	
	UIWeaponIcon.SetWidth	(w);
	UIWeaponIcon.SetHeight	(h);
};
Esempio n. 21
0
void IReader::r_stringZ(shared_str& dest)
{
    dest = (char*)(data + Pos);
    Pos += (dest.size() + 1);
}