mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
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>
This commit is contained in:
parent
6525ae17b7
commit
7d4a2b07bb
@ -10,6 +10,13 @@ class CfgVehicles {
|
|||||||
showDisabled = 0;
|
showDisabled = 0;
|
||||||
icon = QPATHTOF(ui\gunbag_icon_ca.paa);
|
icon = QPATHTOF(ui\gunbag_icon_ca.paa);
|
||||||
};
|
};
|
||||||
|
class GVAR(weaponSwap) {
|
||||||
|
displayName = CSTRING(SwapGunbag);
|
||||||
|
condition = QUOTE((GVAR(swapGunbagEnabled)) && ([_target] call FUNC(hasGunbag)) && {[ARR_2(_player,_target)] call FUNC(canInteract) == 2});
|
||||||
|
statement = QUOTE([ARR_2(_player,_target)] call FUNC(swapGunbag));
|
||||||
|
showDisabled = 0;
|
||||||
|
icon = QPATHTOF(ui\gunbag_icon_ca.paa);
|
||||||
|
};
|
||||||
class GVAR(weaponOff) {
|
class GVAR(weaponOff) {
|
||||||
displayName = CSTRING(OffGunbag);
|
displayName = CSTRING(OffGunbag);
|
||||||
condition = QUOTE(([_target] call FUNC(hasGunbag)) && {[ARR_2(_player,_target)] call FUNC(canInteract) == 1});
|
condition = QUOTE(([_target] call FUNC(hasGunbag)) && {[ARR_2(_player,_target)] call FUNC(canInteract) == 1});
|
||||||
@ -41,6 +48,13 @@ class CfgVehicles {
|
|||||||
showDisabled = 0;
|
showDisabled = 0;
|
||||||
icon = QPATHTOF(ui\gunbag_icon_ca.paa);
|
icon = QPATHTOF(ui\gunbag_icon_ca.paa);
|
||||||
};
|
};
|
||||||
|
class GVAR(weaponSwap) {
|
||||||
|
displayName = CSTRING(SwapGunbag);
|
||||||
|
condition = QUOTE((GVAR(swapGunbagEnabled)) && ([ARR_2(_player,_player)] call FUNC(canInteract) == 2));
|
||||||
|
statement = QUOTE([ARR_2(_player,_player)] call FUNC(swapGunbag));
|
||||||
|
showDisabled = 0;
|
||||||
|
icon = QPATHTOF(ui\gunbag_icon_ca.paa);
|
||||||
|
};
|
||||||
class GVAR(weaponOff) {
|
class GVAR(weaponOff) {
|
||||||
displayName = CSTRING(OffGunbag);
|
displayName = CSTRING(OffGunbag);
|
||||||
condition = QUOTE([ARR_2(_player,_player)] call FUNC(canInteract) == 1);
|
condition = QUOTE([ARR_2(_player,_player)] call FUNC(canInteract) == 1);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
PREP(toGunbag);
|
PREP(toGunbag);
|
||||||
PREP(toGunbagCallback);
|
PREP(toGunbagCallback);
|
||||||
|
PREP(swapGunbag);
|
||||||
|
PREP(swapGunbagCallback);
|
||||||
PREP(offGunbag);
|
PREP(offGunbag);
|
||||||
PREP(offGunbagCallback);
|
PREP(offGunbagCallback);
|
||||||
PREP(status);
|
PREP(status);
|
||||||
|
@ -6,6 +6,8 @@ PREP_RECOMPILE_START;
|
|||||||
#include "XEH_PREP.hpp"
|
#include "XEH_PREP.hpp"
|
||||||
PREP_RECOMPILE_END;
|
PREP_RECOMPILE_END;
|
||||||
|
|
||||||
|
#include "initSettings.sqf"
|
||||||
|
|
||||||
// restore gunbag info after respawn
|
// restore gunbag info after respawn
|
||||||
["CAManBase", "respawn", {
|
["CAManBase", "respawn", {
|
||||||
[{
|
[{
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* 1: Target <OBJECT>
|
* 1: Target <OBJECT>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* -1: can't interact 0: empty gunbag 1: full gunbag <NUMBER>
|
* -1: can't interact 0: empty gunbag 1: full gunbag 2: full gunbag & has primary <NUMBER>
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* _canInteract = [player, target] call ace_gunbag_fnc_canInteract
|
* _canInteract = [player, target] call ace_gunbag_fnc_canInteract
|
||||||
@ -29,5 +29,7 @@ if ((_gunbag getVariable [QGVAR(gunbagWeapon), []]) isEqualTo [] && {_weapon !=
|
|||||||
if (!((_gunbag getVariable [QGVAR(gunbagWeapon), []]) isEqualTo []) && {_weapon == ""}) then {
|
if (!((_gunbag getVariable [QGVAR(gunbagWeapon), []]) isEqualTo []) && {_weapon == ""}) then {
|
||||||
_result = 1;
|
_result = 1;
|
||||||
};
|
};
|
||||||
|
if (!((_gunbag getVariable [QGVAR(gunbagWeapon), []]) isEqualTo []) && {_weapon != ""}) then {
|
||||||
|
_result = 2;
|
||||||
|
};
|
||||||
_result
|
_result
|
||||||
|
34
addons/gunbag/functions/fnc_swapGunbag.sqf
Normal file
34
addons/gunbag/functions/fnc_swapGunbag.sqf
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: Ir0n1E and mjc4wilton
|
||||||
|
* Swap primary weapon and weapon in gunbag.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
* 1: Target <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [player, target] call ace_gunbag_fnc_swapGunbag
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params ["_unit", "_target"];
|
||||||
|
|
||||||
|
private _gunbag = backpackContainer _target;
|
||||||
|
|
||||||
|
_unit call EFUNC(common,goKneeling);
|
||||||
|
|
||||||
|
// play sound
|
||||||
|
if (["ace_backpacks"] call EFUNC(common,isModLoaded)) then {
|
||||||
|
[_target, _gunbag] call EFUNC(backpacks,backpackOpened);
|
||||||
|
};
|
||||||
|
|
||||||
|
[(PROGRESSBAR_TIME * 1.5), _this, {
|
||||||
|
(_this select 0) call FUNC(swapGunbagCallback)
|
||||||
|
}, {}, LLSTRING(swapGunbag),
|
||||||
|
{(_this select 0) call FUNC(canInteract) == 2}
|
||||||
|
] call EFUNC(common,progressBar);
|
76
addons/gunbag/functions/fnc_swapGunbagCallback.sqf
Normal file
76
addons/gunbag/functions/fnc_swapGunbagCallback.sqf
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: Ir0n1E and mjc4wilton
|
||||||
|
* Swap primary weapon and weapon in gunbag.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
* 1: Target <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [player, target] call ace_gunbag_fnc_swapGunbag
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params ["_unit", "_target"];
|
||||||
|
private _currentWeapon = primaryWeapon _unit; //Get Current Weapon
|
||||||
|
private _gunbag = backpackContainer _target;
|
||||||
|
|
||||||
|
|
||||||
|
//---Set up current weapon for storing
|
||||||
|
private _currentWeaponState = [_unit, _currentWeapon] call EFUNC(common,getWeaponState); //Gets weapon attachments
|
||||||
|
|
||||||
|
/*
|
||||||
|
* example return value _state
|
||||||
|
* [["","","optic_Aco",""],["arifle_MX_GL_ACO_F","GL_3GL_F"],["30Rnd_65x39_caseless_mag","1Rnd_HE_Grenade_shell"],[30,1]]
|
||||||
|
*/
|
||||||
|
|
||||||
|
_currentWeaponState params ["_currentWeaponItems", "", "_currentWeaponMagazines", "_currentWeaponAmmo"]; //Extract Weapon Attachments to separate arrays
|
||||||
|
|
||||||
|
private _currentWeaponMass = [_currentWeapon, _currentWeaponItems, _currentWeaponMagazines] call FUNC(calculateMass);
|
||||||
|
|
||||||
|
{
|
||||||
|
_currentWeaponMagazines set [_forEachIndex, [_x, _currentWeaponAmmo select _forEachIndex]];
|
||||||
|
} forEach _currentWeaponMagazines;
|
||||||
|
|
||||||
|
//---Set up weapon in gunbag
|
||||||
|
private _newWeaponState = _gunbag getVariable [QGVAR(gunbagWeapon), []];
|
||||||
|
|
||||||
|
if (_newWeaponState isEqualTo []) exitWith {
|
||||||
|
[LLSTRING(empty)] call EFUNC(common,displayTextStructured);
|
||||||
|
};
|
||||||
|
|
||||||
|
_newWeaponState params ["_newWeapon", "_newWeaponItems", "_newWeaponMagazines"];
|
||||||
|
|
||||||
|
//---Swap Weapons
|
||||||
|
_unit removeWeapon _currentWeapon;
|
||||||
|
_unit addWeapon _newWeapon;
|
||||||
|
|
||||||
|
// Game will auto add magazines from player's inventory, put these back in player inventory as they will be overwritten
|
||||||
|
([_unit, _newWeapon] call EFUNC(common,getWeaponState)) params ["", "", "_addedMags", "_addedAmmo"];
|
||||||
|
{
|
||||||
|
if (((_x select 0) != "") && {(_addedMags select _forEachIndex) != ""}) then {
|
||||||
|
TRACE_2("Re-adding mag",_x,_addedMags select _forEachIndex);
|
||||||
|
_unit addMagazine [_addedMags select _forEachIndex, _addedAmmo select _forEachIndex];
|
||||||
|
};
|
||||||
|
} forEach _newWeaponMagazines;
|
||||||
|
|
||||||
|
removeAllPrimaryWeaponItems _unit;
|
||||||
|
|
||||||
|
{
|
||||||
|
_unit addWeaponItem [_newWeapon, _x];
|
||||||
|
} forEach (_newWeaponItems + _newWeaponMagazines);
|
||||||
|
|
||||||
|
_unit selectWeapon _newWeapon;
|
||||||
|
|
||||||
|
_newWeaponMagazines = _newWeaponMagazines apply {_x select 0};
|
||||||
|
|
||||||
|
private _newWeaponMass = [_newWeapon, _newWeaponItems, _newWeaponMagazines] call FUNC(calculateMass);
|
||||||
|
|
||||||
|
// update virtual load
|
||||||
|
[_target, _gunbag, _currentWeaponMass - _newWeaponMass] call EFUNC(movement,addLoadToUnitContainer);
|
||||||
|
_gunbag setVariable [QGVAR(gunbagWeapon), [_currentWeapon, _currentWeaponItems, _currentWeaponMagazines], true]; //Replace weapon in gunbag
|
9
addons/gunbag/initSettings.sqf
Normal file
9
addons/gunbag/initSettings.sqf
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// CBA Settings [ADDON: ace_gunbag]:
|
||||||
|
|
||||||
|
[
|
||||||
|
QGVAR(swapGunbagEnabled), "CHECKBOX",
|
||||||
|
[LSTRING(SwapGunbagEnabled_DisplayName), LSTRING(SwapGunbagEnabled_Description)],
|
||||||
|
["ACE Uncategorized", LLSTRING(DisplayName_Settings)],
|
||||||
|
true, // default value
|
||||||
|
true // isGlobal
|
||||||
|
] call CBA_fnc_addSetting;
|
@ -33,6 +33,22 @@
|
|||||||
<Turkish>Silah Çantası (Tan)</Turkish>
|
<Turkish>Silah Çantası (Tan)</Turkish>
|
||||||
<Spanish>Funda de arma (Tan)</Spanish>
|
<Spanish>Funda de arma (Tan)</Spanish>
|
||||||
</Key>
|
</Key>
|
||||||
|
<Key ID="STR_ACE_Gunbag_DisplayName_Settings">
|
||||||
|
<English>ACE Gunbag</English>
|
||||||
|
<German>ACE Waffentasche</German>
|
||||||
|
<French>ACE Housse d'arme</French>
|
||||||
|
<Russian>ACE Чехол</Russian>
|
||||||
|
<Czech>ACE Pouzdro na zbraň</Czech>
|
||||||
|
<Japanese>ACE ガンバッグ</Japanese>
|
||||||
|
<Polish>ACE Torba na broń</Polish>
|
||||||
|
<Korean>ACE 총가방</Korean>
|
||||||
|
<Italian>ACE Borsa per Armi</Italian>
|
||||||
|
<Chinesesimp>ACE 枪袋</Chinesesimp>
|
||||||
|
<Chinese>ACE 槍袋</Chinese>
|
||||||
|
<Portuguese>ACE Bolsa de Arma</Portuguese>
|
||||||
|
<Turkish>ACE Silah Çantası</Turkish>
|
||||||
|
<Spanish>ACE Funda de arma</Spanish>
|
||||||
|
</Key>
|
||||||
<Key ID="STR_ACE_Gunbag_ToGunbag">
|
<Key ID="STR_ACE_Gunbag_ToGunbag">
|
||||||
<English>Put weapon into gunbag</English>
|
<English>Put weapon into gunbag</English>
|
||||||
<German>Lege Waffe in Waffentasche</German>
|
<German>Lege Waffe in Waffentasche</German>
|
||||||
@ -49,6 +65,15 @@
|
|||||||
<Turkish>Silahını silah çantasına koy</Turkish>
|
<Turkish>Silahını silah çantasına koy</Turkish>
|
||||||
<Spanish>Poner el arma en la funda</Spanish>
|
<Spanish>Poner el arma en la funda</Spanish>
|
||||||
</Key>
|
</Key>
|
||||||
|
<Key ID="STR_ACE_Gunbag_SwapGunbag">
|
||||||
|
<English>Exchange weapon in gunbag</English>
|
||||||
|
</Key>
|
||||||
|
<Key ID="STR_ACE_Gunbag_SwapGunbagEnabled_DisplayName">
|
||||||
|
<English>Enable Weapon Swap</English>
|
||||||
|
</Key>
|
||||||
|
<Key ID="STR_ACE_Gunbag_SwapGunbagEnabled_Description">
|
||||||
|
<English>Allows interaction to directly swap the primary weapon and stored weapon.</English>
|
||||||
|
</Key>
|
||||||
<Key ID="STR_ACE_Gunbag_OffGunbag">
|
<Key ID="STR_ACE_Gunbag_OffGunbag">
|
||||||
<English>Get weapon out of gunbag</English>
|
<English>Get weapon out of gunbag</English>
|
||||||
<German>Hole Waffe aus Waffentasche</German>
|
<German>Hole Waffe aus Waffentasche</German>
|
||||||
|
Loading…
Reference in New Issue
Block a user