71 m_Name =
"RecipeBase default name";
94 if( item1 == NULL || item2 == NULL )
return false;
104 for(
int x = 0;
x < tempArray.Count();
x++)
111 if( tempArray.Get(
x) == item.GetType() ||
GetGame().IsKindOf(item.GetType(),tempArray.Get(
x)))
123 if(!found)
return false;
143 ptr.Insert(ingredient);
150 for(
int i = 0; i < ptr.Count(); i++)
152 if(ptr[i] == ingredient)
185 spawned_objects.Clear();
196 string color = item.ConfigGetString(
"color");
198 item_to_spawn = new_class_name;
211 object = player.GetInventory().CreateInInventory(item_to_spawn);
224 object = player.GetInventory().CreateEntityInCargo(item_to_spawn);
232 Error(
"failed to spawn entity "+item_to_spawn+
" , make sure the classname exists and item can be spawned");
235 spawned_objects.Insert(
ItemBase.Cast(
object));
245 float all_ingredients_health = 0;
246 float all_ingredients_health01 = 0;
251 all_ingredients_health += ingrd.GetHealth(
"",
"");
252 all_ingredients_health01 += ingrd.GetHealth01(
"",
"");
265 if( res.IsItemBase() )
271 if( use_soft_skills )
273 value_delta = player.GetSoftSkillsManager().AddSpecialtyBonus(value_delta,
m_Specialty);
276 if( !resIb.IsMagazine() )
280 resIb.SetQuantityMax();
282 else if( value_delta != -1 )
284 resIb.SetQuantity( value_delta );
289 Magazine mgzn = Magazine.Cast(resIb);
292 mgzn.ServerSetAmmoMax();
294 else if( value_delta != -1 )
296 mgzn.ServerSetAmmoCount( value_delta );
303 if( use_soft_skills )
305 value_delta = player.GetSoftSkillsManager().AddSpecialtyBonus(value_delta,
m_Specialty);
307 res.SetHealth(
"",
"",value_delta);
319 float ing_health01 = ing.GetHealth01(
"",
"");
320 res.SetHealth(
"",
"", ing_health01 * res.GetMaxHealth(
"",
""));
328 res.SetHealth(
"",
"", average_health01 * res.GetMaxHealth(
"",
""));
341 MiscGameplayFunctions.TransferItemProperties(ingr, res);
342 MiscGameplayFunctions.TransferInventory(ingr, res, player);
381 if( use_soft_skills )
383 if(health_delta <0) health_delta = player.GetSoftSkillsManager().SubtractSpecialtyBonus(health_delta,
m_Specialty);
384 else health_delta = player.GetSoftSkillsManager().AddSpecialtyBonus(health_delta,
m_Specialty);
386 ingredient.AddHealth(
"",
"",health_delta);
391 ingredient.SetHealth(
"",
"",new_health);
397 if( use_soft_skills )
399 if(quantity_delta <0) quantity_delta = player.GetSoftSkillsManager().SubtractSpecialtyBonus(quantity_delta,
m_Specialty);
400 else quantity_delta = player.GetSoftSkillsManager().AddSpecialtyBonus(quantity_delta,
m_Specialty);
403 if( !ingredient.IsMagazine() )
406 bool isDestroyed = obj.AddQuantity(quantity_delta,
true);
415 Magazine mag = Magazine.Cast(ingredient);
416 int newQuantity = mag.GetAmmoCount() + quantity_delta;
417 if( newQuantity <= 0 )
424 mag.ServerSetAmmoCount( newQuantity );
438 if( !ingredient.IsMagazine() )
453 Magazine mag1 = Magazine.Cast(ingredient);
465 int dmg3 = ingredient.GetHealthLevel();
468 int dmg = ingredient.GetHealthLevel();
474 int dmg2 = ingredient.GetHealthLevel();
485 if( item1 == NULL || item2 == NULL )
487 Error(
"recipe invalid, at least one of the ingredients is NULL");
491 ItemBase item_in_hand = player.GetItemInHands();
493 if( !
IsRecipeAnywhere() && (item1 != item_in_hand && item2 != item_in_hand) )
510 if( item1 == NULL || item2 == NULL )
512 Error(
"CheckRecipe: recipe invalid, at least one of the ingredients is NULL");
527 if( item1 == NULL || item2 == NULL )
529 Error(
"PerformRecipe: recipe invalid, at least one of the ingredients is NULL");
530 Debug.
Log(
"PerformRecipe: at least one of the ingredients is NULL",
"recipes");
558 Debug.
Log(
"CheckRecipe failed on server",
"recipes");
564 player.GetSoftSkillsManager().AddSpecialty(
m_Specialty);
572 if (ingredients[i].GetInventory() && ingredients[i].GetInventory().AttachmentCount() > 0)
601 for(
int x = 0;
x < ptr.Count();
x++)
603 items.Insert( ptr.Get(
x) );
610 string itemType = item.GetType();
613 for (
int x = 0;
x < ptr.Count();
x++)
615 if (
GetGame().IsKindOf(itemType, ptr.Get(
x)))
632 for(
int x = 0;
x < ptr.Count();
x++)
634 if( ptr.Get(
x) == item )
return true;
648 for(
int x = 0;
x < ptr.Count();
x++)
650 if( ptr.Get(
x) == item )
class RecipeCacheData int
const float DEFAULT_SPAWN_DISTANCE
const int MAXIMUM_RESULTS
const int MAX_NUMBER_OF_INGREDIENTS
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
bool CheckRecipe(ItemBase item1, ItemBase item2, PlayerBase player)
int m_ResultReplacesIngredient[MAXIMUM_RESULTS]
int m_ResultToInventory[MAXIMUM_RESULTS]
void RemoveIngredient(int index, string ingredient)
void DeleleIngredientsPass()
bool m_IngredientUseSoftSkills[MAX_NUMBER_OF_INGREDIENTS]
int GetIngredientMaskForItem(string item)
returns a mask which marks ingredient positions for a given item in this recipe(for example mask of v...
string GetSoundCategory(int ingredientIndex, ItemBase item)
float m_IngredientAddHealth[MAX_NUMBER_OF_INGREDIENTS]
bool CanDo(ItemBase ingredients[], PlayerBase player)
void OnSelected(ItemBase item1, ItemBase item2, PlayerBase player)
void InsertIngredient(int index, string ingredient)
float m_IngredientSetHealth[MAX_NUMBER_OF_INGREDIENTS]
bool CheckIngredientMatch(ItemBase item1, ItemBase item2)
void OnSelectedRecipe(ItemBase item1, ItemBase item2, PlayerBase player)
ref array< string > m_SoundCategories[MAX_NUMBER_OF_INGREDIENTS]
int m_ResultInheritsHealth[MAXIMUM_RESULTS]
string m_ItemsToCreate[MAXIMUM_RESULTS]
void Do(ItemBase ingredients[], PlayerBase player, array< ItemBase > results, float specialty_weight)
void AddResult(string item)
int m_ResultInheritsColor[MAXIMUM_RESULTS]
void ApplySoftSkillsSpecialty(PlayerBase player)
bool CheckConditions(ItemBase sorted[])
float m_MinDamageIngredient[MAX_NUMBER_OF_INGREDIENTS]
float m_MaxQuantityIngredient[MAX_NUMBER_OF_INGREDIENTS]
void ApplyModificationsResults(ItemBase sorted[], array< ItemBase > results, ItemBase result, PlayerBase player)
bool m_AnywhereInInventory
float m_ResultSetQuantity[MAXIMUM_RESULTS]
ItemBase m_Items[MAX_NUMBER_OF_INGREDIENTS]
void ApplyModificationsIngredients(ItemBase sorted[], PlayerBase player)
bool m_ResultSetFullQuantity[MAXIMUM_RESULTS]
bool IsItemInRecipe(string item)
float m_ResultSetHealth[MAXIMUM_RESULTS]
ref array< string > m_Ingredients[MAX_NUMBER_OF_INGREDIENTS]
void GetAllItems(array< string > items)
void SpawnItems(ItemBase ingredients[], PlayerBase player, array< ItemBase > spawned_objects)
void PerformRecipe(ItemBase item1, ItemBase item2, PlayerBase player)
float m_MaxDamageIngredient[MAX_NUMBER_OF_INGREDIENTS]
float m_ResultSpawnDistance[MAXIMUM_RESULTS]
ref array< ItemBase > m_IngredientsToBeDeleted
ItemBase m_IngredientsSorted[MAX_NUMBER_OF_INGREDIENTS]
float m_IngredientAddQuantity[MAX_NUMBER_OF_INGREDIENTS]
float m_MinQuantityIngredient[MAX_NUMBER_OF_INGREDIENTS]
bool m_IngredientDestroy[MAX_NUMBER_OF_INGREDIENTS]
bool m_ResultUseSoftSkills[MAXIMUM_RESULTS]
void InsertIngredientEx(int index, string ingredient, string soundCategory)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
const float CRAFTING_TIME_UNIT_SIZE
static proto float Pow(float v, float power)
Return power of v ^ power.