Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- countWeaponDamage =
- {
- params ["_weapon"];
- // Count max damage for this weapon
- private _maxHit = 0;
- private _mags = getarray (configFile >> "CfgWeapons" >> _weapon >> "magazines");
- {
- private _ammo = getText (configfile >> "CfgMagazines" >> _x >> "ammo");
- private _hit = getNumber(configfile >> "CfgAmmo" >> _ammo >> "hit");
- if(_maxHit < _hit) then
- {
- _maxHit = _hit;
- };
- } forEach _mags;
- _maxHit
- };
- getWeaponAmmo =
- {
- private ["_ammo","_mag","_mags","_ammoCfg"];
- params ["_weapon"];
- _mags = getarray (configFile >> "CfgWeapons" >> _weapon >> "magazines");
- _mag = _mags select 0;
- _ammo = getText(configfile >> "CfgMagazines" >> _mag >> "ammo");
- _ammoCfg = (configfile >> "CfgAmmo" >> _ammo);
- _ammoCfg
- };
- hasWeaponAmmoAttribute =
- {
- private ["_ammo","_mag","_mags","_ammoCfg"];
- params ["_weapon","_attr"];
- private _ret = false;
- _mags = getarray (configFile >> "CfgWeapons" >> _weapon >> "magazines");
- {
- _mag = _x;
- _ammo = getText(configfile >> "CfgMagazines" >> _mag >> "ammo");
- _ammoCfg = (configfile >> "CfgAmmo" >> _ammo);
- if(getNumber (_ammoCfg >> _attr) > 0) exitwith { _ret = true; };
- } forEach _mags;
- _ret
- };
- getItemCost =
- {
- params ["_item"];
- private ["_cost","_itemType","_mainType","_childType"];
- _itemType = _item call BIS_fnc_itemType;
- _mainType = _itemType select 0;
- _childType = _itemType select 1;
- _cost = 0;
- switch (_mainType) do
- {
- case "Weapon":
- {
- private _dam = _item call countWeaponDamage;
- private _ammo = _item call getWeaponAmmo;
- private _addCost = 0;
- // https://community.bistudio.com/wiki/A3_Targeting_config_reference
- private _isAA = false;
- if([_item,"airLock"] call hasWeaponAmmoAttribute) then
- {
- _isAA = true;
- _addCost = _addCost + 500;
- };
- private _autoSeek = false;
- if([_item,"autoSeekTarget"] call hasWeaponAmmoAttribute) then
- {
- _autoSeek = true;
- _addCost = _addCost + 500;
- };
- private _irlock = false;
- if([_item,"irLock"] call hasWeaponAmmoAttribute) then
- {
- _irlock = true;
- _addCost = _addCost + 500;
- };
- private _laserLock = false;
- if([_item,"laserLock"] call hasWeaponAmmoAttribute) then
- {
- _laserLock = true;
- _addCost = _addCost + 250;
- };
- if([_item,"manualControl"] call hasWeaponAmmoAttribute) then
- {
- _laserLock = true;
- _addCost = _addCost + 300;
- };
- //diag_log format["????? %1 %2 %3 %4 %5 %6",_item,_childType,_isAA,_autoSeek,_irlock,_laserLock];
- if(_childType in ["RocketLauncher","MissileLauncher"]) then
- {
- if(!_isAA) then
- {
- diag_log format[">>> %1 %2 %3",_item,_childType,_dam];
- _addCost = _addCost + (_dam * 0.25);
- };
- }
- else
- {
- diag_log format["))) %1 %2 %3 %4",_item,_childType,_dam,(_dam * 25)];
- _addCost = _addCost + (_dam * 25);
- };
- if(_childType == "AssaultRifle") then
- {
- _cost = 1000;
- };
- if(_childType == "MachineGun") then
- {
- _cost = 1500;
- };
- if(_childType == "SniperRifle") then
- {
- _cost = 2500;
- };
- if(_childType == "RocketLauncher") then
- {
- diag_log format[" %1 %2 %3 %4 %5 %6",_item,_childType,_isAA,_autoSeek,_irlock,_laserLock];
- _cost = 2000;
- };
- if(_childType == "MissileLauncher") then
- {
- diag_log format[" %1 %2 %3 %4 %5 %6",_item,_childType,_isAA,_autoSeek,_irlock,_laserLock];
- _cost = 2000;
- };
- _cost = _cost + _addCost;
- };
- case "Magazine":
- {
- if(_childType == "Bullet") then
- {
- _cost = 70;
- };
- if(_childType == "Missile") then
- {
- _cost = 500;
- };
- if(_childType in ["Grenade","SmokeShell","Shell","Flare"]) then
- {
- _cost = 50;
- };
- if(_item == "Laserbatteries") then // childtype is "UnknownMagazine"
- {
- _cost = 55;
- };
- };
- case "Equipment":
- {
- if(_childType == "Glasses") then
- {
- _cost = 10;
- };
- if(_childType == "Headgear") then
- {
- _cost = 250;
- };
- if(_childType == "Vest") then
- {
- _cost = 500;
- };
- if(_childType == "Backpack") then
- {
- _cost = 250;
- };
- if(_childType == "Uniform") then
- {
- _cost = 50;
- };
- };
- case "Item":
- {
- //_cost = 77;
- if(_childType in ["AccessorySights","AccessoryMuzzle","AccessoryPointer","AccessoryBipod"]) then
- {
- _cost = 150;
- };
- if(_childType == "LaserDesignator") then { _cost = 300; };
- if(_childType == "Binocular") then { _cost = 30; };
- if(_childType == "FirstAidKit") then { _cost = 100; };
- if(_childType == "Compass") then { _cost = 30; };
- if(_childType == "Toolkit") then { _cost = 100; };
- if(_childType == "GPS") then { _cost = 150; };
- if(_childType == "Map") then { _cost = 10; };
- if(_childType == "Medikit") then { _cost = 300; };
- if(_childType == "MineDetector") then { _cost = 250; };
- if(_childType == "NVGoggles") then { _cost = 500; };
- if(_childType == "Radio") then { _cost = 100; };
- if(_childType == "UAVTerminal") then { _cost = 750; };
- if(_childType == "Watch") then { _cost = 20; };
- };
- };
- if(_cost == 0) then { player sidechat format["Unknown item category %1 >> %2", _item, _itemType]; };
- _cost
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement