-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
6525ae1
commit 7d4a2b0
Showing
8 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters