recipebase.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. const int MAX_NUMBER_OF_INGREDIENTS = 2;
  2. const int MAXIMUM_RESULTS = 10;
  3. const float DEFAULT_SPAWN_DISTANCE = 0.6;
  4. class RecipeAnimationInfo
  5. {
  6. string m_IngredientName;
  7. int m_AnimationUID;
  8. bool m_ItemVisible;
  9. void RecipeAnimationInfo(string ingredient, int animationID, bool itemVisible)
  10. {
  11. m_IngredientName = ingredient;
  12. m_AnimationUID = animationID;
  13. m_ItemVisible = itemVisible;
  14. }
  15. }
  16. class RecipeBase
  17. {
  18. protected const int BASE_CRAFT_ANIMATION_ID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
  19. string m_ItemsToCreate[MAXIMUM_RESULTS];
  20. ref array<string> m_Ingredients[MAX_NUMBER_OF_INGREDIENTS];
  21. ref array<string> m_SoundCategories[MAX_NUMBER_OF_INGREDIENTS];
  22. protected ref array<ref RecipeAnimationInfo> m_AnimationInfos = new array<ref RecipeAnimationInfo>(); // used for overriding animation based on ingredient
  23. ItemBase m_Items[MAX_NUMBER_OF_INGREDIENTS];
  24. ItemBase m_IngredientsSorted[MAX_NUMBER_OF_INGREDIENTS]; //if the recipe is valid, this array will contain all ingredients sorted against the recipe ingredients
  25. ref array<ItemBase> m_IngredientsToBeDeleted = new array<ItemBase>;
  26. string m_Name;
  27. int m_ID;
  28. int m_NumberOfResults;
  29. int m_RecipeUID;//obsolete
  30. float m_AnimationLength = 1;//animation length in relative time units
  31. float m_Specialty = 0;// value > 0 for roughness, value < 0 for precision
  32. bool m_IsInstaRecipe;//should this recipe be performed instantly without animation
  33. bool m_AnywhereInInventory;//is this recipe valid even when neither of the items is in hands
  34. float m_MinQuantityIngredient[MAX_NUMBER_OF_INGREDIENTS];
  35. float m_MaxQuantityIngredient[MAX_NUMBER_OF_INGREDIENTS];
  36. float m_MinDamageIngredient[MAX_NUMBER_OF_INGREDIENTS];
  37. float m_MaxDamageIngredient[MAX_NUMBER_OF_INGREDIENTS];
  38. bool m_IngredientUseSoftSkills[MAX_NUMBER_OF_INGREDIENTS];
  39. float m_IngredientAddHealth[MAX_NUMBER_OF_INGREDIENTS];
  40. float m_IngredientAddQuantity[MAX_NUMBER_OF_INGREDIENTS];
  41. float m_IngredientSetHealth[MAX_NUMBER_OF_INGREDIENTS];
  42. bool m_IngredientDestroy[MAX_NUMBER_OF_INGREDIENTS];
  43. bool m_ResultSetFullQuantity[MAXIMUM_RESULTS];
  44. float m_ResultSetQuantity[MAXIMUM_RESULTS];
  45. float m_ResultSetHealth[MAXIMUM_RESULTS];
  46. float m_ResultSpawnDistance[MAXIMUM_RESULTS];
  47. int m_ResultToInventory[MAXIMUM_RESULTS];
  48. int m_ResultInheritsHealth[MAXIMUM_RESULTS];
  49. int m_ResultInheritsColor[MAXIMUM_RESULTS];
  50. int m_ResultReplacesIngredient[MAXIMUM_RESULTS];
  51. bool m_ResultUseSoftSkills[MAXIMUM_RESULTS];
  52. void RecipeBase()
  53. {
  54. for (int i = 0; i < MAX_NUMBER_OF_INGREDIENTS; i++)
  55. {
  56. m_Ingredients[i] = new array<string>;
  57. m_SoundCategories[i] = new array<string>;
  58. m_IngredientsSorted[i] = NULL;
  59. }
  60. for (i = 0; i < MAXIMUM_RESULTS; i++)
  61. {
  62. m_ResultSpawnDistance[i] = DEFAULT_SPAWN_DISTANCE;
  63. }
  64. m_NumberOfResults = 0;
  65. m_Name = "RecipeBase default name";
  66. m_RecipeUID = BASE_CRAFT_ANIMATION_ID;
  67. Init();
  68. }
  69. void Init();
  70. protected void SetAnimation (DayZPlayerConstants uid)
  71. {
  72. m_RecipeUID = uid;
  73. }
  74. float GetLengthInSecs()
  75. {
  76. return m_AnimationLength * CRAFTING_TIME_UNIT_SIZE;
  77. }
  78. float GetSpecialty()
  79. {
  80. return m_Specialty;
  81. }
  82. bool IsRecipeAnywhere()
  83. {
  84. return m_AnywhereInInventory;
  85. }
  86. bool IsRepeatable()
  87. {
  88. return false;
  89. }
  90. bool CheckIngredientMatch(ItemBase item1, ItemBase item2)
  91. {
  92. if (item1 == NULL || item2 == NULL) return false;
  93. m_Items[0] = item1;
  94. m_Items[1] = item2;
  95. bool found = false;
  96. for (int i = 0; i < MAX_NUMBER_OF_INGREDIENTS; i++)//all ingredients
  97. {
  98. found = false;
  99. array<string> tempArray = m_Ingredients[i];
  100. for (int x = 0; x < tempArray.Count(); x++)//particular ingredient array
  101. {
  102. for (int z = 0; z < MAX_NUMBER_OF_INGREDIENTS; z++)
  103. {
  104. if (m_Items[z] != NULL)
  105. {
  106. ItemBase item = m_Items[z];
  107. if (tempArray.Get(x) == item.GetType() || GetGame().IsKindOf(item.GetType(),tempArray.Get(x)))
  108. {
  109. found = true;//we found a match
  110. //m_IngredientsSorted.Insert(item);
  111. m_IngredientsSorted[i] = item;
  112. m_Items[z] = NULL;
  113. }
  114. }
  115. if (found) break;//we found a match, no need to check the remaining ingredients
  116. }
  117. if (found) break;//we found a match, no need to check this m_Ingredient array
  118. }
  119. if (!found) return false;// no match within an m_Ingredient array, no reason to continue the search, recipe is invalid
  120. }
  121. if (found)
  122. {
  123. return true;
  124. }
  125. else
  126. {
  127. return false;
  128. }
  129. }
  130. void InsertIngredient(int index, string ingredient, DayZPlayerConstants uid = BASE_CRAFT_ANIMATION_ID, bool showItem = false)
  131. {
  132. InsertIngredientEx(index, ingredient, "", uid, showItem);
  133. }
  134. void InsertIngredientEx(int index, string ingredient, string soundCategory, DayZPlayerConstants uid = BASE_CRAFT_ANIMATION_ID, bool showItem = false)
  135. {
  136. array<string> ptr = m_Ingredients[index];
  137. ptr.Insert(ingredient);
  138. m_SoundCategories[index].Insert(soundCategory);
  139. if(uid != BASE_CRAFT_ANIMATION_ID)
  140. {
  141. RecipeAnimationInfo rai = new RecipeAnimationInfo(ingredient, uid, showItem);
  142. int animationIndex;
  143. for(animationIndex = 0; animationIndex < m_AnimationInfos.Count(); animationIndex++)
  144. {
  145. if(GetGame().IsKindOf(ingredient, m_AnimationInfos[animationIndex].m_IngredientName))
  146. break;
  147. }
  148. m_AnimationInfos.InsertAt(rai, animationIndex);
  149. }
  150. }
  151. void RemoveIngredient(int index, string ingredient)
  152. {
  153. array<string> ptr = m_Ingredients[index];
  154. for (int i = 0; i < ptr.Count(); i++)
  155. {
  156. if (ptr[i] == ingredient)
  157. {
  158. ptr.Remove(i);
  159. m_SoundCategories[index].Remove(i);
  160. return;
  161. }
  162. }
  163. }
  164. void AddResult(string item)
  165. {
  166. m_ItemsToCreate[m_NumberOfResults] = item;
  167. m_NumberOfResults++;
  168. }
  169. string GetName()
  170. {
  171. return m_Name;
  172. }
  173. bool IsInstaRecipe()
  174. {
  175. return m_IsInstaRecipe;
  176. }
  177. //spawns results in the world
  178. void SpawnItems(ItemBase ingredients[], PlayerBase player, array<ItemBase> spawned_objects)
  179. {
  180. spawned_objects.Clear();//just to make sure
  181. EntityAI object = NULL;
  182. for (int i = 0; i < m_NumberOfResults; i++)
  183. {
  184. string item_to_spawn = m_ItemsToCreate[i];
  185. if (m_ResultInheritsColor[i] != -1)
  186. {
  187. ItemBase item = ingredients[m_ResultInheritsColor[i]];
  188. string color = item.ConfigGetString("color");
  189. string new_class_name = m_ItemsToCreate[i] + color;
  190. item_to_spawn = new_class_name;
  191. }
  192. if (m_ResultToInventory[i] == -1)
  193. {
  194. Debug.Log(" = "+m_ResultToInventory[i].ToString(),"recipes");
  195. /*
  196. InventoryLocation inv_loc = new InventoryLocation;
  197. if (player.GetInventory().FindFirstFreeLocationForNewEntity(item_to_spawn, FindInventoryLocationType.ANY, inv_loc))
  198. {
  199. object = SpawnItemOnLocation(item_to_spawn, inv_loc, false);
  200. }
  201. */
  202. object = player.GetInventory().CreateInInventory(item_to_spawn);
  203. }
  204. else if (m_ResultToInventory[i] >= 0)
  205. {
  206. /*
  207. object = player.SpawnEntityOnGroundOnCursorDir(item_to_spawn, 0.5);
  208. ItemBase item_swap_with = ingredients[m_ResultToInventory[i]];
  209. player.SwapEntities(true, item_swap_with, EntityAI.Cast(object));
  210. */
  211. }
  212. //spawning in inventory failed, spawning on the ground instead.....
  213. if (!object)
  214. {
  215. object = player.SpawnEntityOnGroundRaycastDispersed(item_to_spawn,m_ResultSpawnDistance[i]);
  216. if (!object)
  217. Error("failed to spawn entity "+item_to_spawn+" , make sure the classname exists and item can be spawned");
  218. }
  219. spawned_objects.Insert(ItemBase.Cast(object));
  220. object = null;
  221. }
  222. }
  223. //applies final modifications to results
  224. void ApplyModificationsResults(ItemBase sorted[], array<ItemBase> results, ItemBase result, PlayerBase player)
  225. {
  226. float all_ingredients_health = 0;//this is used later in results
  227. float all_ingredients_health01 = 0;//combined damage % of ingredients
  228. int value_delta;
  229. for (int i = 0; i < MAX_NUMBER_OF_INGREDIENTS; i++)
  230. {
  231. ItemBase ingrd = ItemBase.Cast(sorted[i]);
  232. all_ingredients_health += ingrd.GetHealth("", "");//accumulate health of all ingredients, used in results
  233. all_ingredients_health01 += ingrd.GetHealth01("", "");
  234. }
  235. //------------------- results ----------------------
  236. for (i = 0; i < m_NumberOfResults; i++)
  237. {
  238. ItemBase res = results.Get(i);
  239. if (!res)
  240. {
  241. continue;
  242. }
  243. if (res.IsItemBase())
  244. {
  245. value_delta = m_ResultSetQuantity[i];
  246. ItemBase resIb = ItemBase.Cast(res);
  247. if (!resIb.IsMagazine())//is not a magazine
  248. {
  249. if (m_ResultSetFullQuantity[i] == 1)//<------m_ResultSetFullQuantity
  250. {
  251. resIb.SetQuantityMax();
  252. }
  253. else if (value_delta != -1)//<------m_ResultSetQuantity
  254. {
  255. resIb.SetQuantity(value_delta);
  256. }
  257. }
  258. else//is magazine
  259. {
  260. Magazine mgzn = Magazine.Cast(resIb);
  261. if (m_ResultSetFullQuantity[i] == 1)//<------m_ResultSetFullQuantity
  262. {
  263. mgzn.ServerSetAmmoMax();
  264. }
  265. else if (value_delta != -1)//<------m_ResultSetQuantity
  266. {
  267. mgzn.ServerSetAmmoCount(value_delta);
  268. }
  269. }
  270. }
  271. if (m_ResultSetHealth[i] != -1)//<------m_ResultSetHealth
  272. {
  273. value_delta = m_ResultSetHealth[i];
  274. res.SetHealth("","",value_delta);
  275. }
  276. if (m_ResultInheritsHealth[i] != -1)//<------m_ResultInheritsHealth
  277. {
  278. if (m_ResultInheritsHealth[i] >= 0)
  279. {
  280. int ing_number = m_ResultInheritsHealth[i];
  281. ItemBase ing = sorted[ing_number];
  282. if (ing)
  283. {
  284. float ing_health01 = ing.GetHealth01("","");
  285. res.SetHealth("", "", ing_health01 * res.GetMaxHealth("",""));
  286. Debug.Log("Inheriting health from ingredient:"+m_ResultInheritsHealth[i].ToString(),"recipes");
  287. }
  288. }
  289. else if (m_ResultInheritsHealth[i] == -2)
  290. {
  291. float average_health01 = all_ingredients_health01 / MAX_NUMBER_OF_INGREDIENTS;
  292. res.SetHealth("", "", average_health01 * res.GetMaxHealth("",""));
  293. }
  294. }
  295. if (m_ResultReplacesIngredient[i] != -1)//<------ResultReplacesIngredient
  296. {
  297. if (m_ResultReplacesIngredient[i] > -1)
  298. {
  299. int ing_num = m_ResultReplacesIngredient[i];
  300. ItemBase ingr = sorted[ing_num];
  301. if (ingr)
  302. {
  303. MiscGameplayFunctions.TransferItemProperties(ingr, res);
  304. MiscGameplayFunctions.TransferInventory(ingr, res, player);
  305. }
  306. }
  307. }
  308. }
  309. }
  310. void DeleleIngredientsPass()
  311. {
  312. for (int i = 0; i < m_IngredientsToBeDeleted.Count(); i++)
  313. {
  314. ItemBase ingredient = m_IngredientsToBeDeleted.Get(i);
  315. ingredient.Delete();
  316. }
  317. m_IngredientsToBeDeleted.Clear();
  318. }
  319. //applies final modifications to ingredients
  320. void ApplyModificationsIngredients(ItemBase sorted[], PlayerBase player)
  321. {
  322. //---------------------- ingredients ----------------------
  323. for (int i = 0; i < MAX_NUMBER_OF_INGREDIENTS; i++)
  324. {
  325. ItemBase ingredient = sorted[i];
  326. if (m_IngredientDestroy[i] == 1)//<------m_IngredientDestroy
  327. {
  328. if (ingredient) m_IngredientsToBeDeleted.Insert(ingredient);
  329. }
  330. else
  331. {
  332. if (m_IngredientAddHealth[i] != 0)//<------m_IngredientAddHealth
  333. {
  334. float health_delta = m_IngredientAddHealth[i];
  335. ingredient.AddHealth("","",health_delta);
  336. }
  337. else if (m_IngredientSetHealth[i] != -1)//<------m_IngredientSetHealth
  338. {
  339. float new_health = m_IngredientSetHealth[i];
  340. ingredient.SetHealth("","",new_health);
  341. }
  342. if (m_IngredientAddQuantity[i] != 0)//<------m_IngredientAddQuantity
  343. {
  344. float quantity_delta = m_IngredientAddQuantity[i];
  345. if (!ingredient.IsMagazine())
  346. {
  347. ItemBase obj = ingredient;
  348. bool isDestroyed = obj.AddQuantity(quantity_delta, true);
  349. if (isDestroyed)
  350. {
  351. continue;
  352. }
  353. }
  354. else
  355. {
  356. Magazine mag = Magazine.Cast(ingredient);
  357. int newQuantity = mag.GetAmmoCount() + quantity_delta;
  358. if (newQuantity <= 0)
  359. {
  360. if (mag) m_IngredientsToBeDeleted.Insert(mag);
  361. continue;
  362. }
  363. else
  364. {
  365. mag.ServerSetAmmoCount(newQuantity);
  366. }
  367. }
  368. }
  369. }
  370. }
  371. }
  372. //checks the recipe conditions
  373. bool CheckConditions(ItemBase sorted[])
  374. {
  375. for (int i = 0; i < MAX_NUMBER_OF_INGREDIENTS; i++)
  376. {
  377. ItemBase ingredient = sorted[i];
  378. if (!ingredient.IsMagazine())
  379. {
  380. if (ingredient.GetQuantityMax() !=0 && m_MinQuantityIngredient[i] >= 0 && ingredient.GetQuantity() < m_MinQuantityIngredient[i])
  381. {
  382. //Debug.Log("Recipe condition check failing1: m_MinQuantityIngredient","recipes");
  383. return false;
  384. }
  385. if (m_MaxQuantityIngredient[i] >= 0 && ingredient.GetQuantity() > m_MaxQuantityIngredient[i])
  386. {
  387. //Debug.Log("Recipe condition check failing1: m_MaxQuantityIngredient","recipes");
  388. return false;
  389. }
  390. }
  391. else
  392. {
  393. Magazine mag1 = Magazine.Cast(ingredient);
  394. if (m_MinQuantityIngredient[i] >= 0 && mag1.GetAmmoCount() < m_MinQuantityIngredient[i])
  395. {
  396. //Debug.Log("Recipe condition check failing1: m_MinQuantityIngredient[0]","recipes");
  397. return false;
  398. }
  399. if (m_MaxQuantityIngredient[i] >= 0 && mag1.GetAmmoCount() > m_MaxQuantityIngredient[i])
  400. {
  401. //Debug.Log("Recipe condition check failing1: m_MaxQuantityIngredient[0]","recipes");
  402. return false;
  403. }
  404. }
  405. int dmg3 = ingredient.GetHealthLevel();
  406. if (m_MinDamageIngredient[i] >= 0 && ingredient.GetHealthLevel() < m_MinDamageIngredient[i])
  407. {
  408. int dmg = ingredient.GetHealthLevel();
  409. //Debug.Log("Recipe condition check failing1: m_MinDamageIngredient[0]","recipes");
  410. return false;
  411. }
  412. if (m_MaxDamageIngredient[i] >= 0 && ingredient.GetHealthLevel() > m_MaxDamageIngredient[i])
  413. {
  414. int dmg2 = ingredient.GetHealthLevel();
  415. //Debug.Log("Recipe condition check failing1: m_MaxDamageIngredient[0]","recipes");
  416. return false;
  417. }
  418. }
  419. return true;
  420. }
  421. //checks overall validity of this recipe
  422. bool CheckRecipe(ItemBase item1, ItemBase item2, PlayerBase player)
  423. {
  424. if (item1 == NULL || item2 == NULL)
  425. {
  426. Error("recipe invalid, at least one of the ingredients is NULL");
  427. return false;
  428. }
  429. ItemBase item_in_hand = player.GetItemInHands();
  430. if (!IsRecipeAnywhere() && (item1 != item_in_hand && item2 != item_in_hand))
  431. {
  432. return false;
  433. }
  434. m_IngredientsSorted[0] = item1;
  435. m_IngredientsSorted[1] = item2;
  436. if (CanDo(m_IngredientsSorted, player) && CheckConditions(m_IngredientsSorted))
  437. {
  438. return true;
  439. }
  440. return false;
  441. }
  442. void OnSelectedRecipe(ItemBase item1, ItemBase item2, PlayerBase player)
  443. {
  444. if (item1 == NULL || item2 == NULL)
  445. {
  446. Error("CheckRecipe: recipe invalid, at least one of the ingredients is NULL");
  447. //Debug.Log("recipe invalid, at least one of the ingredients is NULL","recipes");
  448. return;
  449. }
  450. OnSelected(item1,item2,player);
  451. }
  452. void OnSelected(ItemBase item1, ItemBase item2, PlayerBase player)
  453. {
  454. }
  455. //performs this recipe
  456. void PerformRecipe(ItemBase item1, ItemBase item2, PlayerBase player)
  457. {
  458. if (item1 == NULL || item2 == NULL)
  459. {
  460. Error("PerformRecipe: recipe invalid, at least one of the ingredients is NULL");
  461. Debug.Log("PerformRecipe: at least one of the ingredients is NULL","recipes");
  462. }
  463. if (CheckRecipe(item1,item2,player))
  464. {
  465. array<ItemBase> spawned_objects = new array<ItemBase>;
  466. SpawnItems(m_IngredientsSorted, player,spawned_objects);
  467. ApplyModificationsResults(m_IngredientsSorted, spawned_objects, NULL, player);
  468. ApplyModificationsIngredients(m_IngredientsSorted, player);
  469. Do(m_IngredientsSorted, player, spawned_objects, m_Specialty);
  470. DeleleIngredientsPass();
  471. }
  472. else
  473. {
  474. Debug.Log("CheckRecipe failed on server","recipes");
  475. }
  476. }
  477. void ApplySoftSkillsSpecialty(PlayerBase player)
  478. {
  479. }
  480. bool CanDo(ItemBase ingredients[], PlayerBase player)
  481. {
  482. //Debug.Log("Called Can Do on a recipe id:" + m_ID.ToString(),"recipes");
  483. for (int i = 0; i < MAX_NUMBER_OF_INGREDIENTS; i++)
  484. {
  485. if (ingredients[i].GetInventory() && ingredients[i].GetInventory().AttachmentCount() > 0)
  486. return false;
  487. }
  488. return true;
  489. }
  490. void Do(ItemBase ingredients[], PlayerBase player, array<ItemBase> results, float specialty_weight)
  491. {
  492. //Debug.Log("Called Do on a recipe id:" + m_ID.ToString(),"recipes");
  493. }
  494. int GetID()
  495. {
  496. return m_ID;
  497. }
  498. void SetID(int id)
  499. {
  500. m_ID = id;
  501. }
  502. void GetAllItems(array<string> items)
  503. {
  504. for (int i = 0; i < MAX_NUMBER_OF_INGREDIENTS; i++)
  505. {
  506. array<string> ptr = m_Ingredients[i];
  507. for (int x = 0; x < ptr.Count(); x++)
  508. {
  509. items.Insert(ptr.Get(x));
  510. }
  511. }
  512. }
  513. string GetSoundCategory(int ingredientIndex, ItemBase item)
  514. {
  515. string itemType = item.GetType();
  516. array<string> ptr = m_Ingredients[ingredientIndex];
  517. for (int x = 0; x < ptr.Count(); x++)
  518. {
  519. if (GetGame().IsKindOf(itemType, ptr.Get(x)))
  520. {
  521. return m_SoundCategories[ingredientIndex].Get(x);
  522. }
  523. }
  524. return "";
  525. }
  526. bool IsItemInRecipe(string item)
  527. {
  528. for (int i = 0; i < MAX_NUMBER_OF_INGREDIENTS; i++)
  529. {
  530. array<string> ptr = m_Ingredients[i];
  531. for (int x = 0; x < ptr.Count(); x++)
  532. {
  533. if (ptr.Get(x) == item) return true;
  534. }
  535. }
  536. return false;
  537. }
  538. //! returns a mask which marks ingredient positions for a given item in this recipe(for example mask of value 3 [....000011] means this item is both ingredient 1 and 2 in this recipe[from right to left])
  539. int GetIngredientMaskForItem(string item)
  540. {
  541. int mask = 0;
  542. for (int i = 0; i < MAX_NUMBER_OF_INGREDIENTS; i++)
  543. {
  544. array<string> ptr = m_Ingredients[i];
  545. for (int x = 0; x < ptr.Count(); x++)
  546. {
  547. if (ptr.Get(x) == item)
  548. {
  549. mask = ((int)Math.Pow(2, i)) | mask;
  550. }
  551. }
  552. }
  553. return mask;
  554. }
  555. int GetAnimationCommandUID()//obsolete
  556. {
  557. return BASE_CRAFT_ANIMATION_ID;
  558. }
  559. RecipeAnimationInfo GetRecipeAnimationInfo(PlayerBase player, ItemBase mainItem, ItemBase target)
  560. {
  561. RecipeAnimationInfo recipeAnimationInfo;
  562. int found = false;
  563. for(int i = 0; i < m_AnimationInfos.Count();i++)
  564. {
  565. recipeAnimationInfo = m_AnimationInfos[i];
  566. if(GetGame().IsKindOf(mainItem.GetType(), recipeAnimationInfo.m_IngredientName))
  567. {
  568. found = true;
  569. break;
  570. }
  571. }
  572. if(!found)
  573. {
  574. recipeAnimationInfo = new RecipeAnimationInfo("ItemBase", BASE_CRAFT_ANIMATION_ID, false);
  575. }
  576. return recipeAnimationInfo;
  577. }
  578. }