ozdeadmeat 12 Posted April 27, 2014 Hi Everyone, I have been working on a way to add partial magazines into a turret with little to no success. I can get it working on the main guns (turret [0]) but commander turrets etc I am having no joy. I am utilizing a function to return all the turrets on a vehicle and am then returning the magazines for the specific turrets. I am unable to assign rounds into specific magazines. (similar to <unit> addmagazine [<ammotype>, <rounds>];) Does anyone know of a way to do this? I currently have a feedback HERE _tank = _this select 0; /* INPUT: vehicle : OBJECT OUTPUT: paths_array : ARRAY EXAMPLE: _allPaths = MyTank call fnc_GetAllTurretPaths; // _allPaths: [[0], [0,0], [0,1]] */ fnc_GetAllTurretPaths = { private [ "_result", "_vehicle", "_currentNode", "_depth", "_currentConfig", "_cfgTurrets" ]; _result = []; if ((!isNil "_this") && {(typeName _this) in ["ARRAY", "OBJECT"]}) then { _vehicle = objNull; _currentNode = []; _depth = -1; _currentConfig = objNull; switch (typeName _this) do { case "ARRAY": { if ((count _this) == 5) then { _vehicle = _this select 0; _currentConfig = _this select 1; _currentNode = _this select 2; _depth = _this select 3; _result = _this select 4; }; }; case "OBJECT": { _vehicle = _this; _currentConfig = configFile >> "CfgVehicles" >> (typeOf _vehicle); _depth = 0; }; }; if ((!isNil "_vehicle") && (!isNil "_currentNode") && (!isNil "_depth") && (!isNil "_result") && (!isNil "_currentConfig") && {((typeName _vehicle) == "OBJECT") && ((typeName _currentNode) == "ARRAY") && ((typeName _depth) == "SCALAR") && ((typeName _result) == "ARRAY") && ((typeName _currentConfig) == "CONFIG")} && {!isNull _vehicle}) then { _cfgTurrets = _currentConfig >> "Turrets"; if (isClass _cfgTurrets) then { for "_i" from 0 to ((count _cfgTurrets) - 1) step 1 do { _currentNode set [_depth, _i]; _result set [count _result, +_currentNode]; [_vehicle, _cfgTurrets select _i, _currentNode, _depth + 1, _result] call fnc_GetAllTurretPaths; }; }; }; }; _result; }; OzDM_fnc_ClearVehicleTurretMags = { private["_turrets","_i","_turret","_mags4turret","_mag"]; _turrets = _this call fnc_GetAllTurretPaths; for "_i" from 0 to ((count _turrets) - 1) do { _turret = _turrets select _i; _mags4turret = _this magazinesTurret _turret; for "_i" from 0 to ((count _mags4turret) - 1) do { _mag = (_mags4turret select _i); _this removeMagazinesTurret [_mag,_turret]; }; }; }; OzDM_fnc_GetVehicleTurretMags = { private["_turrets","_i","_turret","_mags4turret","_mag"]; _turrets = _this call fnc_GetAllTurretPaths; _output = []; for "_i" from 0 to ((count _turrets) - 1) do { _turret = _turrets select _i; _mags4turret = _this magazinesTurret _turret; _output = _output + [[_turret, _mags4turret]]; }; _output }; Any Help would be appreciated. Share this post Link to post Share on other sites
jshock 513 Posted February 15, 2015 Pretty new command (a few updates back): https://community.bistudio.com/wiki/setMagazineTurretAmmo Share this post Link to post Share on other sites
epicgoldenwarrior 11 Posted February 15, 2015 I'm pretty sure you could just click on the vehicle and change the ammo bar so its not all the way up, right? :P Share this post Link to post Share on other sites
jshock 513 Posted February 15, 2015 I'm pretty sure you could just click on the vehicle and change the ammo bar so its not all the way up, right? :P That would affect all of the turrets, so if he only wanted to say change just the .50 cal, it wouldn't be of use to him. Share this post Link to post Share on other sites
epicgoldenwarrior 11 Posted February 15, 2015 Yea, but it would make his life 1000x easier. I mean, I didn't necessarily read the entire script, but I'm sure you dont need to have 2000 mg rounds (of course it depends on his mission) So, if he doesnt want to go through all of it, he can fall back on that. Share this post Link to post Share on other sites
ozdeadmeat 12 Posted February 16, 2015 I am working on a persistence DB function for Campaign Mission Mechanics. (A mission framework I am working on). It is more centred around RPG with story based missions from week to week. My issue is atm I cant save a vehicles ammo condition due to some of these new scripting commands not working. Read Here for a work around thnx to AgentRev but its not a 100% solution. http://feedback.arma3.com/view.php?id=21718 Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted February 16, 2015 In DayZ, they introduced this very handy command setMagazineAmmo: _magazine setMagazineAmmo _quantity; Pity, we don't have it in ArmA 3. Share this post Link to post Share on other sites
Schatten 290 Posted February 17, 2015 My solution... Function to get vehicle turrets weapons and magazines from config and magazines quantities of created vehicle: private ["_cfgEntry", "_getTurretsWeapons", "_turretsWeapons"]; _getTurretsWeapons = { private ["_path", "_subturrets", "_turret", "_turretPath", "_turrets", "_turretsNumber"]; _turrets = _this select 0; _path = _this select 1; _turretsNumber = count _turrets; for "_i" from 0 to (_turretsNumber - 1) do { _turret = _turrets select _i; if ((getNumber (_turret >> "isPersonTurret")) != 1) then { _turretPath = _path + [_i]; _turretsWeapons pushBack [ _turretPath, getArray (_turret >> "weapons") ]; _subturrets = _turret >> "Turrets"; if (isClass _subturrets) then {[_subturrets, _turretPath] call _getTurretsWeapons}; }; }; true }; _cfgEntry = configFile >> "CfgVehicles" >> (if ((typeName _this) == "STRING") then {_this} else {typeOf _this}); _turretsWeapons = [ [ [-1], getArray (_cfgEntry >> "weapons") ] ]; [_cfgEntry >> "Turrets", []] call _getTurretsWeapons; if ((typeName _this) == "OBJECT") then { private ["_magazineType", "_magazines", "_magazinesNumber", "_path", "_turretIndex", "_turretMagazines", "_weaponIndex", "_weaponMagazines", "_weaponType", "_weapons"]; { _path = _x select 0; _weapons = _x select 1; _turretIndex = _forEachIndex; _turretMagazines = _this magazinesTurret _path; { _weaponMagazines = []; _weaponType = _x; _weaponIndex = _forEachIndex; _magazines = getArray (configFile >> "CfgWeapons" >> _weaponType >> "magazines"); { _magazineType = _x; _magazinesNumber = {_x == _magazineType} count _turretMagazines; if (_magazinesNumber != 0) then {_weaponMagazines pushBack [_magazineType, _magazinesNumber]}; } forEach _magazines; _weapons set [ _weaponIndex, [_weaponType, _weaponMagazines] ]; } forEach _weapons; (_turretsWeapons select _turretIndex) set [1, _weapons]; } forEach _turretsWeapons; }; _turretsWeapons Usage: getTurretsWeapons = compileFinal (preprocessFileLineNumbers "getTurretsWeapons.sqf"); _vehicleType = typeOf _vehicle; // O_MBT_02_cannon_F copyToClipboard (str (_vehicleType call getTurretsWeapons)); copyToClipboard (str (_vehicle call getTurretsWeapons)); [ [ [-1], [] ], [ [0], ["cannon_125mm", "LMG_coax"] ], [ [0,0], ["HMG_NSVT", "SmokeLauncher"] ] ] [ [ [-1], [] ], [ [0], [ [ "cannon_125mm", [ ["24Rnd_125mm_APFSDS_T_Green", 1], ["12Rnd_125mm_HE_T_Green", 1], ["12Rnd_125mm_HEAT_T_Green", 1] ] ], [ "LMG_coax", [ ["2000Rnd_762x51_Belt_Green", 2] ] ] ] ], [ [0,0], [ [ "HMG_NSVT", [ ["450Rnd_127x108_Ball", 2] ] ], [ "SmokeLauncher", [ ["SmokeLauncherMag", 1] ] ] ] ] ] Also I added this code in my function to create vehicle: if (_ammo != 1) then { private ["_magazineAmmoNumber", "_magazineType", "_magazines", "_magazinesNumber", "_magazinesNumberRem", "_path", "_weaponType", "_weapons", "_turretsWeapons"]; _turretsWeapons = _vehicle call getTurretsWeapons; { _path = _x select 0; _weapons = _x select 1; { _weaponType = _x select 0; if (_weaponType != "SmokeLauncher") then { _magazines = _x select 1; { _magazineType = _x select 0; _magazinesNumber = _ammo * (_x select 1); _magazinesNumberRem = _magazinesNumber - (floor _magazinesNumber); _magazinesNumber = ceil _magazinesNumber; _vehicle removeMagazinesTurret [_magazineType, _path]; for "_i" from 1 to _magazinesNumber do { _vehicle addMagazineTurret [_magazineType, _path]; if ((_i == 1) and {_magazinesNumberRem > 0}) then { _magazineAmmoNumber = getNumber (configFile >> "CfgMagazines" >> _magazineType >> "count"); _magazineAmmoNumber = floor (_magazinesNumberRem * _magazineAmmoNumber); _vehicle setMagazineTurretAmmo [_magazineType, _magazineAmmoNumber, _path]; }; }; } forEach _magazines; }; } forEach _weapons; } forEach _turretsWeapons; }; _ammo is same as value in https://community.bistudio.com/wiki/setVehicleAmmo. Share this post Link to post Share on other sites