RamireDu06

Arma 3 Get Ammo Function

Oct 2nd, 2020 (edited)
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. get_good_val_to_add = {
  2. _mag_array_and_max = _this select 0;
  3. _max_multiplier = _this select 1;
  4. _mag_type = _this select 2;
  5.  
  6. _result_to_add = 0;
  7.  
  8. {
  9. if ((_x select 0) == _mag_type) exitWith {
  10. _mag_max_count = _x select 1;
  11.  
  12. _result_to_add = _mag_max_count * _max_multiplier
  13. };
  14. }forEach _mag_array_and_max;
  15.  
  16. _result_to_add;
  17. };
  18.  
  19. get_munitions_level = {
  20. _vehicle = _this select 0;
  21.  
  22. _munition_level = 0;
  23. _false_munition_level = 0;
  24. _max_munition_level = 0;
  25.  
  26. _all_magazines_one_time = [];
  27. _magazines_one_time_count = [];
  28. _magazines_type_and_max_count = [];
  29. _all_infos_turrets = magazinesAllTurrets _vehicle;
  30.  
  31. {
  32. _magazine_type = _x select 0;
  33. _magazine_count = _x select 2;
  34.  
  35. if !(_magazine_type in _all_magazines_one_time) then {
  36. _all_magazines_one_time pushBack _magazine_type;
  37. };
  38.  
  39. if (count _magazines_one_time_count > 0) then {
  40. _can_add = true;
  41.  
  42. for "_arr_index" from 0 to ((count _magazines_one_time_count) - 1) do {
  43. _mag_array = _magazines_one_time_count select _arr_index;
  44. _mag_type = _mag_array select 0;
  45.  
  46. if (_mag_type == _magazine_type) then {
  47. _mag_array pushBack _magazine_type;
  48. _can_add = false;
  49. };
  50. };
  51.  
  52. if (_can_add) then {
  53. _magazines_one_time_count pushBack [_magazine_type];
  54. };
  55. }
  56. else {
  57. _magazines_one_time_count pushBack [_magazine_type];
  58. };
  59.  
  60. _false_munition_level = _false_munition_level + _magazine_count;
  61. }forEach _all_infos_turrets;
  62.  
  63. {
  64. _magazines_type_and_max_count pushBack [_x, getNumber (configfile >> "CfgMagazines" >> _x >> "count")];
  65. }forEach _all_magazines_one_time;
  66.  
  67. {
  68. _max_munition_level = _max_munition_level + ([_magazines_type_and_max_count, (count _x), (_x select 0)] call get_good_val_to_add);
  69. }forEach _magazines_one_time_count;
  70.  
  71. _munition_level = (_false_munition_level / _max_munition_level);
  72.  
  73. _munition_level;
  74. };
Add Comment
Please, Sign In to add comment