ACE3/addons/gunbag/XEH_preInit.sqf

77 lines
2.6 KiB
Plaintext
Raw Normal View History

2016-05-03 08:21:21 +00:00
#include "script_component.hpp"
ADDON = false;
PREP_RECOMPILE_START;
2016-05-03 08:21:21 +00:00
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;
2016-05-03 08:21:21 +00:00
#include "initSettings.inc.sqf"
Gunbag - Add weapon swapping (#7713) * Gunbag Update adds capability to swap a currently held primary weapon and the weapon current stored in the gunbag. Has a 1.5x time to complete compared to just adding or removing a weapon from the gunbag. * Update stringtable.xml * Update addons/gunbag/functions/fnc_swapWeapon.sqf Update authors field to add credit to the original author of much of the changed code Co-authored-by: Joko <hoffman.jonas95@gmail.com> * Update addons/gunbag/functions/fnc_swapWeaponCallback.sqf Update the virtual load in a more efficient way. Co-authored-by: Joko <hoffman.jonas95@gmail.com> * Update addons/gunbag/functions/fnc_swapWeaponCallback.sqf Properly attribute author of majority of original code Co-authored-by: Joko <hoffman.jonas95@gmail.com> * Update stringtable.xml * Update French translation Co-authored-by: Elgin675 <elgin675@hotmail.com> * Remove non-English translations Leave translations open to translators * Add CBA setting to enable weapon switching (Default false) * Fixed variables and updated names for consistancy * Convert from ACE Settings to CBA Settings * Fix stringtable.xml indentation * Update addons/gunbag/initSettings.sqf Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com> * Update addons/gunbag/initSettings.sqf Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com> * Update addons/gunbag/functions/fnc_swapGunbagCallback.sqf Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com> * Update addons/gunbag/functions/fnc_swapGunbag.sqf Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com> * Update addons/gunbag/functions/fnc_swapGunbagCallback.sqf Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com> * Update addons/gunbag/initSettings.sqf Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com> * Update addons/gunbag/initSettings.sqf Co-authored-by: PabstMirror <pabstmirror@gmail.com> * Update initSettings.sqf Change default value to true * Update CfgVehicles.hpp Co-authored-by: Joko <hoffman.jonas95@gmail.com> Co-authored-by: Elgin675 <elgin675@hotmail.com> Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2020-06-19 15:35:19 +00:00
2016-06-12 11:51:23 +00:00
// restore gunbag info after respawn
["CAManBase", "respawn", {
[{
params ["_unit", "_corpse"];
private _newBackpack = backpackContainer _unit;
private _oldBackpack = backpackContainer _corpse;
if (typeOf _newBackpack isNotEqualTo typeOf _oldBackpack) exitWith {};
2016-06-12 11:51:23 +00:00
private _state = _oldBackpack getVariable [QGVAR(gunbagWeapon), []];
if (_state isNotEqualTo []) then {
2016-06-12 11:51:23 +00:00
_newBackpack setVariable [QGVAR(gunbagWeapon), _state, true];
};
}, _this] call CBA_fnc_execNextFrame;
}] call CBA_fnc_addClassEventHandler;
[QEGVAR(arsenal,loadoutVerified), {
params ["_loadout", "_extendedInfo", "", "", "_missingExtendedInfo"];
private _gunbagInfo = _extendedInfo getOrDefault [QGVAR(gunbagWeapon), []];
if (_gunbagInfo isEqualTo []) exitWith {};
private _weapon = (_gunbagInfo select 0) call EFUNC(arsenal,baseWeapon);
if !(_weapon in EGVAR(arsenal,virtualItemsFlat)) exitWith {
_missingExtendedInfo pushBack [QGVAR(gunbagWeapon), _weapon];
_extendedInfo deleteAt QGVAR(gunbagWeapon);
};
private _missingItems = [];
private _attachments = _gunbagInfo select 1;
{
if (_x != "" && {!(_x call EFUNC(arsenal,baseWeapon) in EGVAR(arsenal,virtualItemsFlat))}) then {
_missingItems pushBack _x;
_attachments set [_forEachIndex, ""];
};
} forEach _attachments;
private _magazines = _gunbagInfo select 2;
{
private _class = _x param [0, ""];
if (_class != "" && {!(_class in EGVAR(arsenal,virtualItemsFlat))}) then {
_missingItems pushBack _class;
_magazines set [_forEachIndex, ["", 0]];
};
} forEach _magazines;
if (_missingItems isNotEqualTo []) then {
_missingExtendedInfo pushBack [QGVAR(gunbagWeapon), _missingItems];
};
}] call CBA_fnc_addEventHandler;
["CBA_loadoutSet", {
params ["_unit", "_loadout", "_extendedInfo"];
private _gunbagWeapon = _extendedInfo getOrDefault [QGVAR(gunbagWeapon), []];
if (_gunbagWeapon isNotEqualTo []) then {
(backpackContainer _unit) setVariable [QGVAR(gunbagWeapon), _gunbagWeapon, true];
};
}] call CBA_fnc_addEventHandler;
["CBA_loadoutGet", {
params ["_unit", "_loadout", "_extendedInfo"];
private _gunbagWeapon = (backpackContainer _unit) getVariable [QGVAR(gunbagWeapon), []];
if (_gunbagWeapon isNotEqualTo []) then {
_extendedInfo set [QGVAR(gunbagWeapon), _gunbagWeapon];
};
}] call CBA_fnc_addEventHandler;
2016-05-03 08:21:21 +00:00
ADDON = true;