Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • Need help?

    Create a topic in the appropriate section
    Don't write everything in the chat!
  • Take a look at the marketplace

    There you can buy
    everything related to game servers
  • Don't want a ban?

    Please read our rules
    Don't disturb the order!
  • Sell or buy?

    Use services of the guarantor
    We will make your deal safe
  • 0
Sign in to follow this  
Denis1979

attachments

Здравствуйте уважаемые форумчане. Подскажите пожалуйста ответ на один вопрос, у меня есть массив лута, спавнится, все отлично, но я не знаю как спавнить собранное оружие.

protected void CreateDefaultConfig()
	{

		array<FBSLootcrate_Container_Set> FBSLootcrate_box_red_ContainerSet;
		
		array<string> PossibleLootSets = {};

		array<FBSLootcrate_Loot_Set> LootSets = {};
		
		array<string> LootTir_1_FixedLoot = {};
		array<string> LootTir_1_RandomLoot = {};
		array<string> LootTir_2_FixedLoot = {};
		array<string> LootTir_2_RandomLoot = {};
		array<string> LootTir_3_FixedLoot = {};
		array<string> LootTir_3_RandomLoot = {};
		array<string> LootTir_4_FixedLoot = {};
		array<string> LootTir_4_RandomLoot = {};
		
		//Составляйте списки LootTir_1
		LootTir_1_FixedLoot.Insert("M4A1");
		LootTir_1_FixedLoot.Insert("ACOGOptic");
		LootTir_1_RandomLoot.Insert("Canteen");
		LootTir_1_RandomLoot.Insert("Ammo_762x54");
		LootTir_1_RandomLoot.Insert("TacticalBaconCan");

		//Составляйте списки LootTir_2
		LootTir_2_FixedLoot.Insert("Tomato");
		LootTir_2_FixedLoot.Insert("TireRepairKit");
		LootTir_2_RandomLoot.Insert("Rope");
		LootTir_2_RandomLoot.Insert("Roadflare");
		LootTir_2_RandomLoot.Insert("DressShoes_Beige");
		LootTir_2_RandomLoot.Insert("DogFoodCan_Opened");
		LootTir_2_RandomLoot.Insert("MiniDress_BlueChecker");
		LootTir_2_RandomLoot.Insert("FlatCap_Black");
		
		//Составляйте списки LootTir_3
		LootTir_3_FixedLoot.Insert("Tomato");
		LootTir_3_FixedLoot.Insert("TireRepairKit");
		LootTir_3_RandomLoot.Insert("Rope");
		LootTir_3_RandomLoot.Insert("Roadflare");
		LootTir_3_RandomLoot.Insert("DressShoes_Beige");
		LootTir_3_RandomLoot.Insert("DogFoodCan_Opened");
		LootTir_3_RandomLoot.Insert("MiniDress_BlueChecker");
		LootTir_3_RandomLoot.Insert("FlatCap_Black");
		
		//Составляйте списки LootTir_4
		LootTir_4_FixedLoot.Insert("Tomato");
		LootTir_4_FixedLoot.Insert("TireRepairKit");
		LootTir_4_RandomLoot.Insert("Rope");
		LootTir_4_RandomLoot.Insert("Roadflare");
		LootTir_4_RandomLoot.Insert("DressShoes_Beige");
		LootTir_4_RandomLoot.Insert("DogFoodCan_Opened");
		LootTir_4_RandomLoot.Insert("MiniDress_BlueChecker");
		LootTir_4_RandomLoot.Insert("FlatCap_Black");
		
		//Составьте список возможных наборов добычи
		PossibleLootSets.Insert("LootTir_1");
		PossibleLootSets.Insert("LootTir_2");
		PossibleLootSets.Insert("LootTir_3");
		PossibleLootSets.Insert("LootTir_4");

		//Создавайте наборы для добычи
		FBSLootcrate_Loot_Set LootTir_1 = new FBSLootcrate_Loot_Set("LootTir_1", 3, 5, false, LootTir_1_FixedLoot, LootTir_1_RandomLoot);
		FBSLootcrate_Loot_Set LootTir_2 = new FBSLootcrate_Loot_Set("LootTir_2", 3, 5, false, LootTir_2_FixedLoot, LootTir_2_RandomLoot);
		FBSLootcrate_Loot_Set LootTir_3 = new FBSLootcrate_Loot_Set("LootTir_3", 3, 5, false, LootTir_3_FixedLoot, LootTir_3_RandomLoot);
		FBSLootcrate_Loot_Set LootTir_4 = new FBSLootcrate_Loot_Set("LootTir_4", 3, 5, false, LootTir_4_FixedLoot, LootTir_4_RandomLoot);
		
		//Соберем все это вместе
		m_ConfigData = new FBSLootcrate_ConfigData();
		
		//Создайте набор контейнеров
		FBSLootcrate_Container_Set lootset1 = new FBSLootcrate_Container_Set("FBS_Lootcrate_box_1", false, false, false, 1200, false, 1200, PossibleLootSets);
		m_ConfigData.getContainerSets().Insert(lootset1);
		FBSLootcrate_Container_Set lootset2 = new FBSLootcrate_Container_Set("FBS_Lootcrate_box_2", false, false, false, 1200, false, 1200, PossibleLootSets);		
		m_ConfigData.getContainerSets().Insert(lootset2);
		FBSLootcrate_Container_Set lootset3 = new FBSLootcrate_Container_Set("FBS_Lootcrate_box_3", false, false, false, 1200, false, 1200, PossibleLootSets);	
		m_ConfigData.getContainerSets().Insert(lootset3);
		FBSLootcrate_Container_Set lootset4 = new FBSLootcrate_Container_Set("FBS_Lootcrate_box_4", false, false, false, 1200, false, 1200, PossibleLootSets);	
		m_ConfigData.getContainerSets().Insert(lootset4);

		//Подключите наборы для добычи
		m_ConfigData.getLootSets().Insert(LootTir_1);
		m_ConfigData.getLootSets().Insert(LootTir_2);		
		m_ConfigData.getLootSets().Insert(LootTir_3);
		m_ConfigData.getLootSets().Insert(LootTir_4);

		//Запишите конфигурационный файл JSON по умолчанию на диск
        JsonFileLoader<FBSLootcrate_ConfigData>.JsonSaveFile(m_ProfilePath + m_ConfigFolderName + "/" + m_ConfigName, m_ConfigData);
	}

Как мне сделать attachments?

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

я бы вообще понимал хоть что вы спавните то и куда, с учетом что сверху это вообще вырезка куска кода, спавнящего json конфиг в каком-то формате.

Share this post


Link to post
Share on other sites



  • 0
21.05.2024 в 23:33, 123new сказал:

я бы вообще понимал хоть что вы спавните то и куда, с учетом что сверху это вообще вырезка куска кода, спавнящего json конфиг в каком-то формате.

//The Loot Set Object
class FBSLootcrate_Loot_Set
{
	protected string SetName;
	protected int MinRandomLoot;
	protected int MaxRandomLoot;
	protected bool ForceUnique;
	protected array<string> FixedLoot;
	
	protected array<string> RandomLoot;

	void FBSLootcrate_Loot_Set(string in_setName = "", int in_minRandomLoot = 3, int in_maxRandomLoot = 5, bool in_forceUnique = false, array<string> in_fixedLoot = null, array<string> in_randomLoot = null)
	{
		SetName = in_setName;
		MinRandomLoot = in_minRandomLoot;
		MaxRandomLoot = in_maxRandomLoot;
		ForceUnique = in_forceUnique;
		FixedLoot = in_fixedLoot;
		RandomLoot = in_randomLoot;
	}
	
	string getSetName()
	{
		return SetName;
	}
	
	int getMinRandomLoot()
	{
		return MinRandomLoot;
	}
	
	int getMaxRandomLoot()
	{
		return MaxRandomLoot;
	}
	
	bool getForceUnique()
	{
		return ForceUnique;
	}
	
	array<string> getFixedLoot()
	{
		return FixedLoot;
	}
	
	array<string> getRandomLoot()
	{
		return RandomLoot;
	}
}

//The Container Set Object
class FBSLootcrate_Container_Set
{
	protected string ContainerName;
	protected bool CanBePickedUp = false;
	protected bool DeleteWhenEmpty = false;
	protected bool RefillWhenEmpty = false;
	protected int RefillWhenEmptyTimer = 1200;
	protected bool RefreshContainerLoot = false;
	protected int RefreshContainerLootTimer = 1200;
	
	protected array<string> PossibleLootSets;

	void FBSLootcrate_Container_Set(string in_containerName = "", bool in_canbepickedup = false, bool in_deletewhenempty = false, bool in_RefillWhenEmpty = false, int in_RefillWhenEmptyTimer = 1200, bool in_RefreshContainerLoot = false, int in_RefreshContainerLootTimer = 1200, array<string> in_possibleLootSets = null)
	{
		ContainerName = in_containerName;
		CanBePickedUp = in_canbepickedup;
		DeleteWhenEmpty = in_deletewhenempty;
		RefillWhenEmpty = in_RefillWhenEmpty;
		RefillWhenEmptyTimer = in_RefillWhenEmptyTimer;
		RefreshContainerLoot = in_RefreshContainerLoot;
		RefreshContainerLootTimer = in_RefreshContainerLootTimer;		
		PossibleLootSets = in_possibleLootSets;
	}
	
	string getContainerName()
	{
		return ContainerName;
	}
	
	bool getCanBePickedUp()
	{
		return CanBePickedUp;
	}	
	
	bool getDeleteWhenEmpty()
	{
		return DeleteWhenEmpty;
	}
	
	bool getRefillWhenEmpty()
	{
		return RefillWhenEmpty;
	}

	int getRefillWhenEmptyTimer()
	{
		return RefillWhenEmptyTimer;
	}	
	
	bool getRefreshContainerLoot()
	{
		return RefreshContainerLoot;
	}

	int getRefreshContainerLootTimer()
	{
		return RefreshContainerLootTimer;
	}	

	array<string> getPossibleLootSets()
	{
		return PossibleLootSets;
	}
}

//The Master Config Data object
class FBSLootcrate_ConfigData
{
	protected int ConfigSchemaVersion = 3;

	protected bool DebugLogging = false;
	protected ref array<FBSLootcrate_Container_Set> ContainerSets;
	protected ref array<FBSLootcrate_Loot_Set> LootSets;	

	void FBSLootcrate_ConfigData() 
	{
		ContainerSets = new ref array<FBSLootcrate_Container_Set>;
		LootSets = new ref array<FBSLootcrate_Loot_Set>>;
	}

	int getConfigSchemaVersion() 
	{ 
		return ConfigSchemaVersion; 
	}

	void setConfigSchemaVersion(int configVersion) 
	{ 
		ConfigSchemaVersion = configVersion; 
	}

	bool getDebugLogging() 
	{ 
		return DebugLogging; 
	}

	array<FBSLootcrate_Container_Set> getContainerSets() 
	{ 
		return ContainerSets; 
	}

	array<FBSLootcrate_Loot_Set> getLootSets() 
	{ 
		return LootSets; 
	}

}

//Контроллер для объекта данных Master Config
class FBSLootcrate_Config
{
	protected int CurrentConfigSchemaVersion = 3;

	const protected static string m_ProfilePath = "$profile:";
	const protected static string m_ConfigFolderName = "FBSLootcrates";
	const protected static string m_ConfigName = "FBSLootConfig.json";

	protected static ref FBSLootcrate_ConfigData m_ConfigData;
	
	void FBSLootcrate_Config()
	{
		LoadConfig();
	}	

	FBSLootcrate_ConfigData getConfigData()
	{
		if(!m_ConfigData)
		{
			LoadConfig();
		}
		return m_ConfigData;
	}
	
	array<string> getRandomLoot(string in_Container)
	{
		protected array<string> output_Loot = {};

		//получите возможные наборы добычи
		protected array<FBSLootcrate_Container_Set> calc_containers = m_ConfigData.getContainerSets();
		
		for( int i = 0; i < calc_containers.Count(); i++ )
		{
			if (calc_containers[i].getContainerName() == in_Container)
			{
				protected string calc_containerSet = calc_containers[i].getContainerName();
				protected array<string> calc_possibleLootSets = calc_containers[i].getPossibleLootSets();
				break;
			}
		}
		
		if (calc_possibleLootSets)
		{
			//выберите случайный набор лута и узнайте его название
			protected int lootsetindex = Math.RandomInt(0,(calc_possibleLootSets.Count()));
			protected string calc_possibleLootSetName = calc_possibleLootSets[lootsetindex];
			
			//возьмите наборы для добычи и найдите тот, который мы ищем
			protected array<FBSLootcrate_Loot_Set> calc_lootSets = m_ConfigData.getLootSets();
	
			//Найди того, кого мы ищем
			for( int j = 0; j < calc_lootSets.Count(); j++ )
			{
				if (calc_lootSets[j].getSetName() == calc_possibleLootSetName)
				{
					string calc_LootSetName = calc_lootSets[j].getSetName();
					protected FBSLootcrate_Loot_Set calc_LootSet = calc_lootSets[j];
					break;
				}
			}	

			if (calc_LootSet)
			{
				//Захватите параметры
				protected int calc_minRandomLoot = calc_LootSet.getMinRandomLoot();
				protected int calc_maxRandomLoot = calc_LootSet.getMaxRandomLoot();
				protected bool calc_forceUnique = calc_LootSet.getForceUnique();
				protected array<string> calc_FixedLoot = calc_LootSet.getFixedLoot();
				protected array<string> calc_RandomLoot = calc_LootSet.getRandomLoot();

				//Ловушка для пустых фиксированных наборов добычи
				if (calc_FixedLoot)
				{
					//Перебирайте фиксированный лут и добавляйте в список
					for( int k = 0; k < calc_FixedLoot.Count(); k++ )
						output_Loot.Insert(calc_FixedLoot[k]);
				}
				else
				{
					Print("[FBSLootCrates] - Class " + in_Container + " had a null set for FixedLoot in the " + calc_possibleLootSetName + " LootSet");
				}

				//Ловушка для пустых случайных наборов
				if (calc_RandomLoot)
				{
					//Подсчитайте, сколько случайных предметов для добычи мы добавим
					protected int calc_RandomLootItems = Math.RandomInt(calc_minRandomLoot, calc_maxRandomLoot);
					for( int l = 0; l < calc_RandomLootItems; l++ )		
					{
						//Нужно ли нам усиливать уникальность?
						if (calc_forceUnique)
						{
							int tries_counter = 0;
							bool calc_itemUnique = false;						
							while (!calc_itemUnique && tries_counter <= calc_RandomLoot.Count()) 
							{
								int calc_element = Math.RandomInt(0, calc_RandomLoot.Count());
								string calc_LootClass = calc_RandomLoot[calc_element];
								calc_itemUnique = true;	

								for( int m = 0; m < output_Loot.Count(); m++ )
								{
									if (output_Loot[m] == calc_LootClass)
									{
										calc_itemUnique = false;
										break;
									}
								}
								tries_counter += 1;
							}

						if (calc_itemUnique)
							output_Loot.Insert(calc_LootClass);
						}
						else
						{	
							calc_element = Math.RandomInt(0, calc_RandomLoot.Count());
							calc_LootClass = calc_RandomLoot[calc_element];
							output_Loot.Insert(calc_LootClass);
						}
					}
				}
				else
				{
					Print("[FBSLootCrates] - Class " + in_Container + " had a null set for RandomLoot in the " + calc_possibleLootSetName + " LootSet");
				}				
			}
		}
		return output_Loot;
	}

	
	protected void LoadConfig()
	{
		if (!FileExist(m_ProfilePath + m_ConfigFolderName + "/"))
        {
			MakeDirectory(m_ProfilePath + m_ConfigFolderName + "/");
		}
		
		m_ConfigData = new FBSLootcrate_ConfigData();
		
		if (FileExist(m_ProfilePath + m_ConfigFolderName + "/" + m_ConfigName))
        {
            JsonFileLoader<FBSLootcrate_ConfigData>.JsonLoadFile(m_ProfilePath + m_ConfigFolderName + "/" + m_ConfigName, m_ConfigData);
			
			if (m_ConfigData.getConfigSchemaVersion() < CurrentConfigSchemaVersion)
			{
				m_ConfigData.setConfigSchemaVersion(CurrentConfigSchemaVersion);
				JsonFileLoader<FBSLootcrate_ConfigData>.JsonSaveFile(m_ProfilePath + m_ConfigFolderName + "/" + m_ConfigName, m_ConfigData);
			}
        }
        else
        {
            CreateDefaultConfig();
        }
	}
	
	protected void CreateDefaultConfig()
	{

		array<FBSLootcrate_Container_Set> FBSLootcrate_box_red_ContainerSet;
		
		array<string> PossibleLootSets = {};

		array<FBSLootcrate_Loot_Set> LootSets = {};
		
		array<string> LootTir_1_FixedLoot = {};
		array<string> LootTir_1_RandomLoot = {};
		array<string> LootTir_2_FixedLoot = {};
		array<string> LootTir_2_RandomLoot = {};
		array<string> LootTir_3_FixedLoot = {};
		array<string> LootTir_3_RandomLoot = {};
		array<string> LootTir_4_FixedLoot = {};
		array<string> LootTir_4_RandomLoot = {};
		
		//Составляйте списки LootTir_1
		LootTir_1_FixedLoot.Insert("M4A1");
		LootTir_1_FixedLoot.Insert("ACOGOptic");
		LootTir_1_RandomLoot.Insert("Canteen");
		LootTir_1_RandomLoot.Insert("Ammo_762x54");
		LootTir_1_RandomLoot.Insert("TacticalBaconCan");

		//Составляйте списки LootTir_2
		LootTir_2_FixedLoot.Insert("Tomato");
		LootTir_2_FixedLoot.Insert("TireRepairKit");
		LootTir_2_RandomLoot.Insert("Rope");
		LootTir_2_RandomLoot.Insert("Roadflare");
		LootTir_2_RandomLoot.Insert("DressShoes_Beige");
		LootTir_2_RandomLoot.Insert("DogFoodCan_Opened");
		LootTir_2_RandomLoot.Insert("MiniDress_BlueChecker");
		LootTir_2_RandomLoot.Insert("FlatCap_Black");
		
		//Составляйте списки LootTir_3
		LootTir_3_FixedLoot.Insert("Tomato");
		LootTir_3_FixedLoot.Insert("TireRepairKit");
		LootTir_3_RandomLoot.Insert("Rope");
		LootTir_3_RandomLoot.Insert("Roadflare");
		LootTir_3_RandomLoot.Insert("DressShoes_Beige");
		LootTir_3_RandomLoot.Insert("DogFoodCan_Opened");
		LootTir_3_RandomLoot.Insert("MiniDress_BlueChecker");
		LootTir_3_RandomLoot.Insert("FlatCap_Black");
		
		//Составляйте списки LootTir_4
		LootTir_4_FixedLoot.Insert("Tomato");
		LootTir_4_FixedLoot.Insert("TireRepairKit");
		LootTir_4_RandomLoot.Insert("Rope");
		LootTir_4_RandomLoot.Insert("Roadflare");
		LootTir_4_RandomLoot.Insert("DressShoes_Beige");
		LootTir_4_RandomLoot.Insert("DogFoodCan_Opened");
		LootTir_4_RandomLoot.Insert("MiniDress_BlueChecker");
		LootTir_4_RandomLoot.Insert("FlatCap_Black");
		
		//Составьте список возможных наборов добычи
		PossibleLootSets.Insert("LootTir_1");
		PossibleLootSets.Insert("LootTir_2");
		PossibleLootSets.Insert("LootTir_3");
		PossibleLootSets.Insert("LootTir_4");

		//Создавайте наборы для добычи
		FBSLootcrate_Loot_Set LootTir_1 = new FBSLootcrate_Loot_Set("LootTir_1", 3, 5, false, LootTir_1_FixedLoot, LootTir_1_RandomLoot);
		FBSLootcrate_Loot_Set LootTir_2 = new FBSLootcrate_Loot_Set("LootTir_2", 3, 5, false, LootTir_2_FixedLoot, LootTir_2_RandomLoot);
		FBSLootcrate_Loot_Set LootTir_3 = new FBSLootcrate_Loot_Set("LootTir_3", 3, 5, false, LootTir_3_FixedLoot, LootTir_3_RandomLoot);
		FBSLootcrate_Loot_Set LootTir_4 = new FBSLootcrate_Loot_Set("LootTir_4", 3, 5, false, LootTir_4_FixedLoot, LootTir_4_RandomLoot);
		
		//Соберем все это вместе
		m_ConfigData = new FBSLootcrate_ConfigData();
		
		//Создайте набор контейнеров
		FBSLootcrate_Container_Set lootset1 = new FBSLootcrate_Container_Set("FBS_Lootcrate_box_1", false, false, false, 1200, false, 1200, PossibleLootSets);
		m_ConfigData.getContainerSets().Insert(lootset1);
		FBSLootcrate_Container_Set lootset2 = new FBSLootcrate_Container_Set("FBS_Lootcrate_box_2", false, false, false, 1200, false, 1200, PossibleLootSets);		
		m_ConfigData.getContainerSets().Insert(lootset2);
		FBSLootcrate_Container_Set lootset3 = new FBSLootcrate_Container_Set("FBS_Lootcrate_box_3", false, false, false, 1200, false, 1200, PossibleLootSets);	
		m_ConfigData.getContainerSets().Insert(lootset3);
		FBSLootcrate_Container_Set lootset4 = new FBSLootcrate_Container_Set("FBS_Lootcrate_box_4", false, false, false, 1200, false, 1200, PossibleLootSets);	
		m_ConfigData.getContainerSets().Insert(lootset4);

		//Подключите наборы для добычи
		m_ConfigData.getLootSets().Insert(LootTir_1);
		m_ConfigData.getLootSets().Insert(LootTir_2);		
		m_ConfigData.getLootSets().Insert(LootTir_3);
		m_ConfigData.getLootSets().Insert(LootTir_4);

		//Запишите конфигурационный файл JSON по умолчанию на диск
        JsonFileLoader<FBSLootcrate_ConfigData>.JsonSaveFile(m_ProfilePath + m_ConfigFolderName + "/" + m_ConfigName, m_ConfigData);
	}	
}

Наполнение ящика, не важно как он спавнится,  при спавне он наполняется рандомным и фиксированным лутом. У меня не получается спавнить оружие в сборе. Есть еще один проект, там такая же беда.

Edited by Denis1979 (see edit history)

Share this post


Link to post
Share on other sites
  • 0

В данном коде идет лишь код чтения-записи и создания json конфига для мода. Но никак не применения его в игре как таковой.

В игре функции CreateObject, CreateAttachment, CreateInHands создают сами объекты и предметы в чем либо или на чем либо.

Учитывая прописанную сложную стркутуру в моде, хотелось бы конечно понимать зачем такие сложности с рандомами, но да ладно. Сама суть вопроса я так понимаю - это заряжать оружие при спавне поумолчанию. Если так, то функций именно спавна объекта в игре в приложенном вами коде я не наблюдаю.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you automaticly agree to our Guidelines and Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.