Jump to content
Sign in to follow this  
sion

edit of Bons Preset Script (make Ace Backpack compatible)

Recommended Posts

Hi guys

I'm editing Bons TFOR mission (got permission earlier) and now i have to edit one of his scripts.

His Loadout preset script.

I'm making TFOR ACE missions only and his Preset script only works with OA backpack system, so i wanna change it and make it compatible with the ACE Backpack System

How the Script works: You as player go to an Object (in this case Backpack Heap) and get the Action "get Equipment Preset". A dialog opens and you can choose between different presets and get it after you selected one. works fine so far :) even editing new presets is no problem! Works also with just recruited AI Units (also a script by bon). The only problem i have is that the items (Magazines, Grenades, Satchels, etc ...) i want to add to an Backpack (ACE Backpack System) aren't in the backpack ....

Hopefully someone can help me

example of Preset

_presetname = "Assault";

_primaryweapon = "G36A_camo";

_secondaryweapon = "ACE_Backpack_TT";

_items_sidearm = ["NVGoggles","ItemMap","ItemGPS","ItemCompass","ItemWatch","ItemRadio","Binocular_Vector"];

_magazines = [["30Rnd_556x45_G36",8],["SmokeShell",1],["HandGrenade_West",2],["ACE_Battery_Rangefinder",1]];

_ruckmags = [["30Rnd_556x45_G36",4],["Pipebomb",1],["SmokeShell",4],["HandGrenade_West",4],["ACE_ANM14",1]];

_ruckweaps = [];

_preset1 = [_presetname,_presetclass,_primaryweapon,_secondaryweapon,_items_sidearm,_magazines,_ruckmags,_ruckweaps];

bon_equip.sqf <-- must be edited (dont know how...)

// by Bon_Inf*

if(not local player || isNil "_this") exitWith{};

_unit = _this select 0;

_preset = _this select 1;

if(typename _preset == "STRING") then{

WaitUntil{not isNil "presets"};

_preset = call compile _preset;

};

_loadoutclass = _preset select 1;

_primaryweapon = _preset select 2;

_secondaryweapon = _preset select 3;

_items_sidearm = _preset select 4;

_magazines = _preset select 5;

_ruckmags = _preset select 6;

_ruckweaps = _preset select 7;

_classremaining = Server getVariable format["%1",_loadoutclass];

if(_loadoutclass != "" && _classremaining == 0) exitWith{hint "Team limits already reached for this equipment class"};

closeDialog 0;

_process = "";

for "_i" from 0 to 4 do {

hintSilent format["Equipping (%1) %2",_loadoutclass,_process];

sleep 0.5 + random 1;

_process = _process + ".";

};

hint "";

Server setVariable [_loadoutclass,_classremaining - 1,true];

/****************************************************************/

// determine unit's gear capacity:

_weaponslots = getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "weaponslots") % 131072;

_goggleslots = floor (_weaponslots/4096); // maybe needed for future work

_weaponslots = _weaponslots % 4096;

_magazineslots = floor (_weaponslots/256);

_weaponslots = _weaponslots % 256;

_pistolmagslots = floor (_weaponslots/16);

_weaponslots = _weaponslots % 16;

_launcherslots = floor (_weaponslots/4); // maybe needed for future work

_weaponslots = _weaponslots % 4;

/****************************************************************/

// equip unit

removeAllWeapons _unit;

removeAllItems _unit;

removeBackpack _unit;

_magcapacity = _magazineslots * 256;

_sidearmcapacity = _pistolmagslots * 16;

{

_currentmag = _x;

_magtype = getNumber (configFile >> "CfgMagazines" >> _currentmag select 0 >> "type");

for "_i" from 1 to (_currentmag select 1) do {

if(_magtype < 256 && _sidearmcapacity >= _magtype) then { // sidearm mag

_unit addMagazine (_currentmag select 0);

_sidearmcapacity = _sidearmcapacity - _magtype;

};

if(_magtype >= 256 && _magcapacity >= _magtype) then { // normal mag

_unit addMagazine (_currentmag select 0);

_magcapacity = _magcapacity - _magtype;

};

};

} foreach _magazines;

{

if(_x != "") then {

if(not isText (configFile >> "CfgWeapons" >> _x >> "displayName")) then { // is rucksack

_unit addBackpack _x;

} else {

_unit addWeapon _x;

};

};

} foreach [_primaryweapon] + [_secondaryweapon] + _items_sidearm;

if(not isNull (unitBackpack _unit)) then{

clearMagazineCargoGlobal (unitBackpack _unit);

{(unitBackpack _unit) addMagazineCargoGlobal _x} foreach _ruckmags;

{(unitBackpack _unit) addWeaponCargoGlobal _x} foreach _ruckweaps;

};

// patch 1.60 totally messes up AI the way it uses binoculars.

if(not isPlayer _unit) then {

_binoculars = ["Binocular","Binocular_Vector"];

{_unit removeWeapon _x} foreach _binoculars;

};

_unit selectWeapon (primaryWeapon _unit);

bon_presets_caller = nil;

Share this post


Link to post
Share on other sites

Do You think that could work?

{[_unit, _x]call ACE_fnc_PackMagazine} foreach _ruckmags;

{[_unit, _x]call ACE_fnc_PackWeapon} foreach _ruckweaps;

EDIT: doesent work :(

Edited by sion
doesnt work

Share this post


Link to post
Share on other sites

hmmm could some one tell me why those two attemps doesnt work?

_g36, _stanag, etc ... are working arrays ....

switch (typeof _primaryweapon) do{

case _g36 : {[_unit, "30Rnd_556x45_G36", 6] call ACE_fnc_PackMagazine};

case _stanag : {[_unit, "30Rnd_556x45_Stanag", 6] call ACE_fnc_PackMagazine};

case _HK417 : {[_unit, "ACE_20Rnd_762x51_B_HK417", 6] call ACE_fnc_PackMagazine};

case _DMR : {[_unit, "20Rnd_762x51_DMR", 6] call ACE_fnc_PackMagazine};

case _MP5 : {[_unit, "30Rnd_9x19_MP5", 6] call ACE_fnc_PackMagazine};

case _MP7 : {[_unit, "ACE_40Rnd_B_46x30_MP7", 6] call ACE_fnc_PackMagazine};

case _UMP : {[_unit, "ACE_25Rnd_1143x23_B_UMP45", 6] call ACE_fnc_PackMagazine};

case _MK17 : {[_unit, "20Rnd_762x51_B_SCAR", 6] call ACE_fnc_PackMagazine};

};

if(_primaryweapon typeof _g36) then {[_unit, "30Rnd_556x45_G36", 6] call ACE_fnc_PackMagazine};

if(_primaryweapon typeof _stanag) then {[_unit, "30Rnd_556x45_Stanag", 6] call ACE_fnc_PackMagazine};

if(_primaryweapon typeof _HK417) then {[_unit, "ACE_20Rnd_762x51_B_HK417", 6] call ACE_fnc_PackMagazine};

if(_primaryweapon typeof _DMR) then {[_unit, "20Rnd_762x51_DMR", 6] call ACE_fnc_PackMagazine};

if(_primaryweapon typeof _MP5) then {[_unit, "30Rnd_9x19_MP5", 6] call ACE_fnc_PackMagazine};

if(_primaryweapon typeof _MP7) then {[_unit, "ACE_40Rnd_B_46x30_MP7", 6] call ACE_fnc_PackMagazine};

if(_primaryweapon typeof _UMP) then {[_unit, "ACE_25Rnd_1143x23_B_UMP45", 6] call ACE_fnc_PackMagazine};

if(_primaryweapon typeof _MK17) then {[_unit, "20Rnd_762x51_B_SCAR", 6] call ACE_fnc_PackMagazine};

Share this post


Link to post
Share on other sites

You're only comparing a string to an array, that won't work.

switch (true) do {
case ((primaryWeapon player) in _g36): {// bla bla};

};

Share this post


Link to post
Share on other sites

to get ruck and contents

If (_ace) then {
_hasruck = player call ACE_Sys_Ruck_fnc_hasRuck;
If (_hasruck) then {
	_ruckMags = [_unit] call ACE_fnc_RuckMagazinesList;
	_ruckWeaps = [_unit] call ACE_fnc_RuckWeaponsList;
};
_weaponback = _unit getvariable "ACE_weapononback";
};

to give to a unit.

If (_ace) then {
If (_hasruck) then {
	{
		_success = [_uniform, _x select 0, _x select 1] call ACE_fnc_PackWeapon;
	} forEach _ruckWeaps;

	{
		_success = [_uniform, _x select 0, _x select 1] call ACE_fnc_PackMagazine;
	} forEach _ruckMags;	
};
If (_weaponback != "") then {
	_uniform addWeapon _weaponback;
	[_uniform, _weaponback] call ACE_fnc_PutWeaponOnBack;
};
};

the if condition is "_ace" just because im using it to check if ace is running by config.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×