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
Verum

Замена жира

Собственно..добавил в игру растительное масло, в файле кукинг  добавил следующее:
 

modded class Cooking
{
	static const float COOKING_FOOD_TIME_INC_VALUE 		= 2;		//time increase when cooking a food
	static const float COOKING_LARD_DECREASE_COEF 		= 25;		//lard quantity decrease when cooking a food (Baking)
	static const float COOKING_OIL_DECREASE_COEF 		= 100;		//oil quantity decrease when cooking a food (Baking)
	//
	static const float DEFAULT_COOKING_TEMPERATURE 		= 150;		//default temperature for cooking (e.g. cooking on stick)
	static const float FOOD_MAX_COOKING_TEMPERATURE		= 150;		//
	static const float PARAM_BURN_DAMAGE_COEF			= 0.05;		//value for calculating damage on items located in fireplace cargo
	//
	typename COOKING_EQUIPMENT_POT	 					= Pot;
	typename COOKING_EQUIPMENT_FRYINGPAN				= FryingPan;
	typename COOKING_EQUIPMENT_CAULDRON					= Cauldron;
	typename COOKING_INGREDIENT_LARD 					= Lard;
	typename COOKING_INGREDIENT_OIL 					= Iss_Oil_Bottle;
	//
	static const float LIQUID_BOILING_POINT 			= 150;	//boiling point for liquids
	static const float LIQUID_VAPOR_QUANTITY 			= 2;	//vapor quantity
	
	//COOKING PROCESS
	//--- Cooking with equipment (pot)
	//Returns 1 if the item changed its cooking stage, 0 if not
	int CookWithEquipment( ItemBase cooking_equipment, float cooking_time_coef = 1 )
	{
		int cooking_state_update = 0;
		bool is_done;
		bool is_empty;
		bool is_burned;
		
		//check cooking conditions
		if ( cooking_equipment == NULL )
		{
			return cooking_state_update;
		}
		
		//manage items in cooking equipment
		CookingMethodType cooking_method = GetCookingMethod( cooking_equipment );
		CargoBase cargo = cooking_equipment.GetInventory().GetCargo();
		if ( cargo.GetItemCount() == 0 )
		{
			is_empty = true;
		}
		//process items
		for ( int i = 0; i < cargo.GetItemCount(); i++ )
		{
			ItemBase item = ItemBase.Cast( cargo.GetItem( i ) );
			Edible_Base item_to_cook = Edible_Base.Cast( item );
			
			if ( item_to_cook && item_to_cook.CanBeCooked() )
			{
				//update food
				cooking_state_update = UpdateCookingState( item_to_cook, cooking_method, cooking_equipment, cooking_time_coef );
				
				//check for done state for boiling and drying
				if ( item_to_cook.IsFoodBoiled() || item_to_cook.IsFoodDried() )
				{
					is_done = true;
				}
				//check for done state fro baking (exclude Lard from baked items)
				else if ( item_to_cook.IsFoodBaked() && item_to_cook.Type() != Lard )		
				{
					is_done = true;
				}
				else if ( item_to_cook.IsFoodBaked() && item_to_cook.Type() != Iss_Oil_Bottle )		
				{
					is_done = true;
				}
				//check for burned state
				else if ( item_to_cook.IsFoodBurned() )
				{
					is_burned = true;
				}
			}
			else   
			{
				//damage item
				item.DecreaseHealth( "", "", PARAM_BURN_DAMAGE_COEF * 100 );
				
				//add temperature to item
				AddTemperatureToItem( item, NULL, 0 );
			}
		}
		
		//manage cooking equipment
		Bottle_Base bottle_base = Bottle_Base.Cast( cooking_equipment );
		if ( bottle_base )
		{
			float cooking_equipment_temp = cooking_equipment.GetTemperature();
			bool is_water_boiling;
			
			//handle water boiling
			if ( cooking_equipment_temp >= LIQUID_BOILING_POINT )
			{
				//remove agents
				cooking_equipment.RemoveAllAgents();
				
				if ( cooking_equipment.GetQuantity() > 0 )
				{
					is_water_boiling = true;
					
					//vaporize liquid
					cooking_equipment.AddQuantity( -LIQUID_VAPOR_QUANTITY );
				};
			}
			
			//handle audio visuals
			bottle_base.RefreshAudioVisualsOnClient( cooking_method, is_done, is_empty, is_burned );
		}

		FryingPan frying_pan = FryingPan.Cast( cooking_equipment );
		if ( frying_pan && !bottle_base )
		{
			//handle audio visuals
			frying_pan.RefreshAudioVisualsOnClient( cooking_method, is_done, is_empty, is_burned );
		}
		
		return cooking_state_update;
	}
	
	//Returns 1 if the item changed its cooking stage, 0 if not
	int CookOnStick( Edible_Base item_to_cook, float cook_time_inc )
	{
		if ( item_to_cook && item_to_cook.CanBeCookedOnStick() )
		{
			//update food
			return UpdateCookingStateOnStick( item_to_cook, cook_time_inc );
		}
		
		return 0;
	}
	
	//Returns 1 if the item changed its cooking stage, 0 if not
	protected int UpdateCookingState( Edible_Base item_to_cook, CookingMethodType cooking_method, ItemBase cooking_equipment, float cooking_time_coef )
	{
		//food properties
		float food_temperature = item_to_cook.GetTemperature();
		
		//{min_temperature, time_to_cook, max_temperature (optional)}
		//get next stage name - if next stage is not defined, next stage name will be empty "" and no cooking properties (food_min_temp, food_time_to_cook, food_max_temp) will be set
		FoodStageType new_stage_type = item_to_cook.GetNextFoodStageType( cooking_method );
		float food_min_temp = 0;
		float food_time_to_cook = 0;
		float food_max_temp = -1;
		
		//Set next stage cooking properties if next stage possible
		if ( item_to_cook.CanChangeToNewStage( cooking_method ) )
		{
			ref array<float> next_stage_cooking_properties = new array<float>;
			
			string config_path = "CfgVehicles" + " " + item_to_cook.GetType() + " " + "Food" + " " + "FoodStages";
			GetGame().ConfigGetFloatArray( config_path + " " + item_to_cook.GetFoodStageName( new_stage_type ) + " " + "cooking_properties", next_stage_cooking_properties );
			
			food_min_temp = next_stage_cooking_properties.Get( 0 );
			food_time_to_cook = next_stage_cooking_properties.Get( 1 );
			
			if ( next_stage_cooking_properties.Count() > 2)
			{
				food_max_temp = next_stage_cooking_properties.Get ( 2 );
			}
		}
		
		//add temperature
		AddTemperatureToItem( item_to_cook, cooking_equipment, food_min_temp );
		
		//add cooking time if the food can be cooked by this method
		if ( food_min_temp > 0 && food_temperature >= food_min_temp )
		{
			float new_cooking_time = item_to_cook.GetCookingTime() + COOKING_FOOD_TIME_INC_VALUE * cooking_time_coef;
			item_to_cook.SetCookingTime( new_cooking_time );
			
			//progress to next stage
			if ( item_to_cook.GetCookingTime() >= food_time_to_cook )
			{
				//if max temp is defined check next food stage
				if ( food_max_temp >= 0 )
				{
					if ( food_temperature > food_max_temp && item_to_cook.GetFoodStageType() != FoodStageType.BURNED )
					{
						new_stage_type = FoodStageType.BURNED;
					}
				}
				
				//change food stage
				item_to_cook.ChangeFoodStage( new_stage_type );
				//Temp
				//Remove all modifiers
				item_to_cook.RemoveAllAgentsExcept(eAgents.BRAIN);
				
				//remove lard when baking with cooking equipment
				if ( cooking_equipment && cooking_method == CookingMethodType.BAKING )
				{
					if ( item_to_cook.Type() != COOKING_INGREDIENT_LARD )
					{
						//get lard item
						ItemBase item_lard = GetItemTypeFromCargo( COOKING_INGREDIENT_LARD, cooking_equipment );
						
						//decrease lard quantity
						float lard_quantity = item_lard.GetQuantity() - COOKING_LARD_DECREASE_COEF;
						lard_quantity = Math.Clamp( lard_quantity, 0, item_lard.GetQuantityMax() );
						item_lard.SetQuantity( lard_quantity );
					}
				}
				if ( cooking_equipment && cooking_method == CookingMethodType.BAKING )
				{
					if ( item_to_cook.Type() != COOKING_INGREDIENT_OIL )
					{
						//get lard item
						ItemBase item_oil = GetItemTypeFromCargo( COOKING_INGREDIENT_OIL, cooking_equipment );
						
						//decrease lard quantity
						float oil_quantity = item_oil.GetQuantity() - COOKING_OIL_DECREASE_COEF;
						oil_quantity = Math.Clamp( oil_quantity, 0, item_oil.GetQuantityMax() );
						item_oil.SetQuantity( oil_quantity );
					}
				}
				//reset cooking time
				item_to_cook.SetCookingTime( 0 );
				return 1;
			}
		}
		
		return 0;
	}
	
	//Returns 1 if the item changed its cooking stage, 0 if not
	protected int UpdateCookingStateOnStick( Edible_Base item_to_cook, float cook_time_inc )
	{
		//food properties
		float food_temperature = item_to_cook.GetTemperature();
		
		//{min_temperature, time_to_cook, max_temperature (optional)}
		//get next stage name - if next stage is not defined, next stage name will be empty "" and no cooking properties (food_min_temp, food_time_to_cook, food_max_temp) will be set
		FoodStageType new_stage_type = item_to_cook.GetNextFoodStageType( CookingMethodType.BAKING );
		float food_min_temp = 0;
		float food_time_to_cook = 0;
		float food_max_temp = -1;
		bool is_done = false;	// baked
		bool is_burned = false;	// burned

		//Set next stage cooking properties if next stage possible
		if ( item_to_cook.CanChangeToNewStage ( CookingMethodType.BAKING ) )
		{
			ref array<float> next_stage_cooking_properties = new array<float>;

			string config_path = "CfgVehicles" + " " + item_to_cook.GetType() + " " + "Food" + " " + "FoodStages";
			GetGame().ConfigGetFloatArray ( config_path + " " + item_to_cook.GetFoodStageName( new_stage_type ) + " " + "cooking_properties", next_stage_cooking_properties );

			food_min_temp = next_stage_cooking_properties.Get( 0 );
			food_time_to_cook = next_stage_cooking_properties.Get( 1 );

			if ( next_stage_cooking_properties.Count() > 2)
			{
				food_max_temp = next_stage_cooking_properties.Get( 2 );
			}
		}
		
		
		// refresh audio
		if ( item_to_cook.GetInventory().IsAttachment() )
		{
			InventoryLocation invloc = new InventoryLocation;
			item_to_cook.GetInventory().GetCurrentInventoryLocation( invloc );
			if ( invloc )
			{
				if ( InventorySlots.GetSlotName( invloc.GetSlot() ) != "Ingredient" )
				{
					item_to_cook.MakeSoundsOnClient( true );
				}
				else
				{
					//add temperature
					AddTemperatureToItem( item_to_cook, NULL, food_min_temp );
				}
			}
		}
		
		//add cooking time if the food can be cooked by this method
		if ( food_min_temp > 0 && food_temperature >= food_min_temp )
		{
			float new_cooking_time = item_to_cook.GetCookingTime() + cook_time_inc;
			item_to_cook.SetCookingTime( new_cooking_time );
			
			//progress to next stage
			if ( item_to_cook.GetCookingTime() >= food_time_to_cook )
			{
				//if max temp is defined check next food stage
				if ( food_max_temp >= 0 )
				{
					if ( food_temperature > food_max_temp && item_to_cook.GetFoodStageType() != FoodStageType.BURNED )
					{
						new_stage_type = FoodStageType.BURNED;
					}
				}
				
				//change food stage
				item_to_cook.ChangeFoodStage( new_stage_type );
				//Temp
				//Remove all modifiers
				item_to_cook.RemoveAllAgentsExcept(eAgents.BRAIN);

				//reset cooking time
				item_to_cook.SetCookingTime( 0 );
				return 1;
			}
		}
		
		return 0;
	}
	
	void SmokeItem( Edible_Base item_to_cook, float cook_time_inc )
	{
		if ( item_to_cook )
		{
			if ( ( item_to_cook.GetFoodStageType() == FoodStageType.RAW ) || ( item_to_cook.GetFoodStageType() == FoodStageType.BAKED ) || ( item_to_cook.GetFoodStageType() == FoodStageType.BOILED ) )
			{
				ref array<float> next_stage_cooking_properties = new array<float>;
				string config_path = "CfgVehicles" + " " + item_to_cook.GetType() + " " + "Food" + " " + "FoodStages";
				GetGame().ConfigGetFloatArray ( config_path + " " + item_to_cook.GetFoodStageName( FoodStageType.DRIED ) + " " + "cooking_properties", next_stage_cooking_properties );
				if ( next_stage_cooking_properties.Count() == 0 )
					return;
				
				float new_cooking_time = item_to_cook.GetCookingTime() + ( cook_time_inc );
				item_to_cook.SetCookingTime( new_cooking_time );

				if ( item_to_cook.GetCookingTime() >= next_stage_cooking_properties.Get( 1 ) )
				{
					item_to_cook.ChangeFoodStage( FoodStageType.DRIED );
					item_to_cook.RemoveAllAgentsExcept(eAgents.BRAIN);
				}
			}
			else
			{
				item_to_cook.SetCookingTime( 0 );
			}
		}
	}
	
	//COOKING DATA
	//
	protected ItemBase GetItemTypeFromCargo( typename item_type, ItemBase cooking_equipment )
	{
		CargoBase cargo = cooking_equipment.GetInventory().GetCargo();
		
		for ( int i = 0; i < cargo.GetItemCount(); i++ )
		{
			EntityAI entity = cargo.GetItem( i );
			if ( entity.Type() == item_type )
			{
				ItemBase item = ItemBase.Cast( entity );

				return item;
			}
		}
		
		return NULL;
	}

	protected CookingMethodType GetCookingMethod( ItemBase cooking_equipment )
	{
		if ( ( cooking_equipment.Type() == COOKING_EQUIPMENT_POT ) || ( cooking_equipment.Type() == COOKING_EQUIPMENT_CAULDRON ) )
		{
			//has water
			if ( cooking_equipment.GetQuantity() > 0 )
			{
				return CookingMethodType.BOILING;
			}
			
			//has lard in cargo
			if ( GetItemTypeFromCargo( COOKING_INGREDIENT_LARD, cooking_equipment ) )
			{
				return CookingMethodType.BAKING;
			}

			if ( GetItemTypeFromCargo( COOKING_INGREDIENT_OIL, cooking_equipment ) )
			{
				return CookingMethodType.BAKING;
			}
			return CookingMethodType.DRYING;
		}
		
		if (cooking_equipment.Type() == COOKING_EQUIPMENT_FRYINGPAN )
		{
			if ( GetItemTypeFromCargo( COOKING_INGREDIENT_LARD, cooking_equipment ) )
			{
				return CookingMethodType.BAKING;
			}
			return CookingMethodType.DRYING;
		}
		if (cooking_equipment.Type() == COOKING_EQUIPMENT_FRYINGPAN )
		{
			if ( GetItemTypeFromCargo( COOKING_INGREDIENT_OIL, cooking_equipment ) )
			{
				return CookingMethodType.BAKING;
			}
			return CookingMethodType.DRYING;
		}
		return CookingMethodType.NONE;
	}
	
	Edible_Base GetFoodOnStick( ItemBase stick_item )
	{
		Edible_Base food_on_stick = Edible_Base.Cast( stick_item.GetAttachmentByType( Edible_Base ) );

		return food_on_stick;
	}
	
	float GetTimeToCook( Edible_Base item_to_cook, CookingMethodType cooking_method )
	{
		ref array<float> next_stage_cooking_properties = new array<float>;
		string config_path = "CfgVehicles" + " " + item_to_cook.GetType() + " " + "Food" + " " + "FoodStages";
		FoodStageType food_stage_type = item_to_cook.GetNextFoodStageType( cooking_method );
		GetGame().ConfigGetFloatArray( config_path + " " + item_to_cook.GetFoodStageName( food_stage_type ) + " " + "cooking_properties", next_stage_cooking_properties );
		
		return next_stage_cooking_properties.Get( 1 );
	}

	float GetMinTempToCook( Edible_Base item_to_cook, CookingMethodType cooking_method )
	{
		ref array<float> next_stage_cooking_properties = new array<float>;
		string config_path = "CfgVehicles" + " " + item_to_cook.GetType() + " " + "Food" + " " + "FoodStages";
		FoodStageType food_stage_type = item_to_cook.GetNextFoodStageType( cooking_method );
		GetGame().ConfigGetFloatArray( config_path + " " + item_to_cook.GetFoodStageName( food_stage_type ) + " " + "cooking_properties", next_stage_cooking_properties );
		
		return next_stage_cooking_properties.Get( 0 );
	}
	
	//add temperature to item
	protected void AddTemperatureToItem( ItemBase cooked_item, ItemBase cooking_equipment, float min_temperature )
	{
		if ( cooked_item.GetTemperatureMax() >= FireplaceBase.PARAM_ITEM_HEAT_MIN_TEMP )
		{
			float item_temperature = cooked_item.GetTemperature();
			
			//set actual cooking temperature
			float actual_cooking_temp = DEFAULT_COOKING_TEMPERATURE;	//default
			if ( cooking_equipment )
			{
				actual_cooking_temp = cooking_equipment.GetTemperature();
			}
			
			//add temperature
			if ( actual_cooking_temp > item_temperature )
			{
				
				item_temperature = actual_cooking_temp * 0.5;
				item_temperature = Math.Clamp( item_temperature, min_temperature, FOOD_MAX_COOKING_TEMPERATURE );
				
				//set new temperature
				if ( GetGame() && GetGame().IsServer() )
				{
					cooked_item.SetTemperature( item_temperature );
				}
			}
		}
	}
	
}

Т.е. ввёл аналог жиру своё масло. Вообщем еда жарится нормально, не подгорает.. Но вопрос в том, что почему то не срабатывает команда по снятию квантити у масла. Что не так прописал, подскажите плиз.

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Как понимаю, на работает именно

float oil_quantity = item_oil.GetQuantity() - COOKING_OIL_DECREASE_COEF;

Скорее всего у предмета не задан параметр, отвечающий за Quantity, где-то в конфиге предмета

Share this post


Link to post
Share on other sites







  • 0

@123new да, не работает именно это..

Но в кофиге четко прописано квантити .

Да, это жидкость, но все же.. квантити есть как и у воды..

Share this post


Link to post
Share on other sites
  • 0
7 часов назад, Verum сказал:

@123new да, не работает именно это..

Но в кофиге четко прописано квантити .

Да, это жидкость, но все же.. квантити есть как и у воды..

в таком случае надо смотреть все остальные файлы вашей модификации, возможно, где-то не верно задан или не задан какой-либо скриптовый параметр.

Share this post


Link to post
Share on other sites
  • 0

@123new Про какие именно речь? сам

Пожалуйста, Войдите или Зарегистрируйтесь, чтобы увидеть это: Вложение.


 

Edited by Verum (see edit history)

Share this post


Link to post
Share on other sites
  • 0
2 часа назад, Verum сказал:

@123new Про какие именно речь? сам

Пожалуйста, Войдите или Зарегистрируйтесь, чтобы увидеть это: Вложение.


 

разумеется про те, от которого ты Quantity пытаешься получить, с ним же проблема.

Share this post


Link to post
Share on other sites
  • 0

@123new Ну в конфиге всё ясно... кватнтити 1000 стоит... по сути конфиг бутылки с водой, только жидкость новая.. в срипт самой бутылки ради теста скопировал скрипт жира...

Share this post


Link to post
Share on other sites
  • 0
3 часа назад, Verum сказал:

@123new Ну в конфиге всё ясно... кватнтити 1000 стоит... по сути конфиг бутылки с водой, только жидкость новая.. в срипт самой бутылки ради теста скопировал скрипт жира...

ну если это  все что есть то я Обама как минимум, так как что такое Iss_Oil_Bottle гра 100% знать уже не будет.

А так я уже сказал, я не эксперт в этом разбираться, но как минимум начинать изучать надо исходя из того что у вас в сумме имеется

Share this post


Link to post
Share on other sites
  • 0

@123new  Iss_Oil_Bottle это всего лишь классовое имя... тот же Lard...

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

×
×
  • 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.