Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.07 KB | None | 0 0
  1. countWeaponDamage =
  2. {
  3. params ["_weapon"];
  4.  
  5. // Count max damage for this weapon
  6. private _maxHit = 0;
  7.  
  8. private _mags = getarray (configFile >> "CfgWeapons" >> _weapon >> "magazines");
  9. {
  10. private _ammo = getText (configfile >> "CfgMagazines" >> _x >> "ammo");
  11. private _hit = getNumber(configfile >> "CfgAmmo" >> _ammo >> "hit");
  12.  
  13. if(_maxHit < _hit) then
  14. {
  15. _maxHit = _hit;
  16. };
  17. } forEach _mags;
  18.  
  19. _maxHit
  20. };
  21.  
  22. getWeaponAmmo =
  23. {
  24. private ["_ammo","_mag","_mags","_ammoCfg"];
  25. params ["_weapon"];
  26.  
  27. _mags = getarray (configFile >> "CfgWeapons" >> _weapon >> "magazines");
  28. _mag = _mags select 0;
  29.  
  30. _ammo = getText(configfile >> "CfgMagazines" >> _mag >> "ammo");
  31. _ammoCfg = (configfile >> "CfgAmmo" >> _ammo);
  32.  
  33. _ammoCfg
  34. };
  35.  
  36. hasWeaponAmmoAttribute =
  37. {
  38. private ["_ammo","_mag","_mags","_ammoCfg"];
  39. params ["_weapon","_attr"];
  40. private _ret = false;
  41.  
  42. _mags = getarray (configFile >> "CfgWeapons" >> _weapon >> "magazines");
  43. {
  44. _mag = _x;
  45. _ammo = getText(configfile >> "CfgMagazines" >> _mag >> "ammo");
  46. _ammoCfg = (configfile >> "CfgAmmo" >> _ammo);
  47.  
  48. if(getNumber (_ammoCfg >> _attr) > 0) exitwith { _ret = true; };
  49.  
  50. } forEach _mags;
  51. _ret
  52. };
  53.  
  54. getItemCost =
  55. {
  56. params ["_item"];
  57. private ["_cost","_itemType","_mainType","_childType"];
  58.  
  59. _itemType = _item call BIS_fnc_itemType;
  60. _mainType = _itemType select 0;
  61. _childType = _itemType select 1;
  62.  
  63. _cost = 0;
  64.  
  65. switch (_mainType) do
  66. {
  67. case "Weapon":
  68. {
  69. private _dam = _item call countWeaponDamage;
  70. private _ammo = _item call getWeaponAmmo;
  71.  
  72. private _addCost = 0;
  73.  
  74. // https://community.bistudio.com/wiki/A3_Targeting_config_reference
  75.  
  76. private _isAA = false;
  77. if([_item,"airLock"] call hasWeaponAmmoAttribute) then
  78. {
  79. _isAA = true;
  80. _addCost = _addCost + 500;
  81. };
  82. private _autoSeek = false;
  83. if([_item,"autoSeekTarget"] call hasWeaponAmmoAttribute) then
  84. {
  85. _autoSeek = true;
  86. _addCost = _addCost + 500;
  87. };
  88. private _irlock = false;
  89. if([_item,"irLock"] call hasWeaponAmmoAttribute) then
  90. {
  91. _irlock = true;
  92. _addCost = _addCost + 500;
  93. };
  94. private _laserLock = false;
  95. if([_item,"laserLock"] call hasWeaponAmmoAttribute) then
  96. {
  97. _laserLock = true;
  98. _addCost = _addCost + 250;
  99. };
  100. if([_item,"manualControl"] call hasWeaponAmmoAttribute) then
  101. {
  102. _laserLock = true;
  103. _addCost = _addCost + 300;
  104. };
  105.  
  106. //diag_log format["????? %1 %2 %3 %4 %5 %6",_item,_childType,_isAA,_autoSeek,_irlock,_laserLock];
  107.  
  108.  
  109. if(_childType in ["RocketLauncher","MissileLauncher"]) then
  110. {
  111. if(!_isAA) then
  112. {
  113. diag_log format[">>> %1 %2 %3",_item,_childType,_dam];
  114.  
  115. _addCost = _addCost + (_dam * 0.25);
  116. };
  117. }
  118. else
  119. {
  120. diag_log format["))) %1 %2 %3 %4",_item,_childType,_dam,(_dam * 25)];
  121.  
  122. _addCost = _addCost + (_dam * 25);
  123. };
  124.  
  125.  
  126. if(_childType == "AssaultRifle") then
  127. {
  128. _cost = 1000;
  129. };
  130. if(_childType == "MachineGun") then
  131. {
  132. _cost = 1500;
  133. };
  134. if(_childType == "SniperRifle") then
  135. {
  136. _cost = 2500;
  137. };
  138. if(_childType == "RocketLauncher") then
  139. {
  140. diag_log format[" %1 %2 %3 %4 %5 %6",_item,_childType,_isAA,_autoSeek,_irlock,_laserLock];
  141.  
  142. _cost = 2000;
  143. };
  144. if(_childType == "MissileLauncher") then
  145. {
  146. diag_log format[" %1 %2 %3 %4 %5 %6",_item,_childType,_isAA,_autoSeek,_irlock,_laserLock];
  147.  
  148. _cost = 2000;
  149. };
  150.  
  151. _cost = _cost + _addCost;
  152. };
  153. case "Magazine":
  154. {
  155. if(_childType == "Bullet") then
  156. {
  157. _cost = 70;
  158. };
  159. if(_childType == "Missile") then
  160. {
  161. _cost = 500;
  162. };
  163. if(_childType in ["Grenade","SmokeShell","Shell","Flare"]) then
  164. {
  165. _cost = 50;
  166. };
  167.  
  168. if(_item == "Laserbatteries") then // childtype is "UnknownMagazine"
  169. {
  170. _cost = 55;
  171. };
  172. };
  173. case "Equipment":
  174. {
  175. if(_childType == "Glasses") then
  176. {
  177. _cost = 10;
  178. };
  179. if(_childType == "Headgear") then
  180. {
  181. _cost = 250;
  182. };
  183. if(_childType == "Vest") then
  184. {
  185. _cost = 500;
  186. };
  187. if(_childType == "Backpack") then
  188. {
  189. _cost = 250;
  190. };
  191. if(_childType == "Uniform") then
  192. {
  193. _cost = 50;
  194. };
  195. };
  196. case "Item":
  197. {
  198. //_cost = 77;
  199. if(_childType in ["AccessorySights","AccessoryMuzzle","AccessoryPointer","AccessoryBipod"]) then
  200. {
  201. _cost = 150;
  202. };
  203. if(_childType == "LaserDesignator") then { _cost = 300; };
  204. if(_childType == "Binocular") then { _cost = 30; };
  205. if(_childType == "FirstAidKit") then { _cost = 100; };
  206. if(_childType == "Compass") then { _cost = 30; };
  207. if(_childType == "Toolkit") then { _cost = 100; };
  208.  
  209. if(_childType == "GPS") then { _cost = 150; };
  210. if(_childType == "Map") then { _cost = 10; };
  211. if(_childType == "Medikit") then { _cost = 300; };
  212. if(_childType == "MineDetector") then { _cost = 250; };
  213. if(_childType == "NVGoggles") then { _cost = 500; };
  214. if(_childType == "Radio") then { _cost = 100; };
  215. if(_childType == "UAVTerminal") then { _cost = 750; };
  216. if(_childType == "Watch") then { _cost = 20; };
  217.  
  218. };
  219. };
  220.  
  221. if(_cost == 0) then { player sidechat format["Unknown item category %1 >> %2", _item, _itemType]; };
  222.  
  223.  
  224. _cost
  225. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement