gunbag improvements
@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
class Extended_PreStart_EventHandlers {
|
class Extended_PreStart_EventHandlers {
|
||||||
class ADDON {
|
class ADDON {
|
||||||
init = QUOTE(call COMPILE_FILE(XEH_preStart));
|
init = QUOTE(call COMPILE_FILE(XEH_preStart));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
class Extended_PreInit_EventHandlers {
|
class Extended_PreInit_EventHandlers {
|
||||||
class ADDON {
|
class ADDON {
|
||||||
init = QUOTE( call COMPILE_FILE(XEH_preInit) );
|
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,7 @@ class CfgVehicles {
|
|||||||
};
|
};
|
||||||
class GVAR(StatusGunbag) {
|
class GVAR(StatusGunbag) {
|
||||||
displayName = CSTRING(Status);
|
displayName = CSTRING(Status);
|
||||||
condition = QUOTE([_target] call FUNC(isGunbag));
|
condition = QUOTE([_target] call FUNC(hasGunbag));
|
||||||
statement = QUOTE([_target] call FUNC(status));
|
statement = QUOTE([_target] call FUNC(status));
|
||||||
showDisabled = 0;
|
showDisabled = 0;
|
||||||
priority = 2;
|
priority = 2;
|
||||||
@ -34,7 +34,7 @@ class CfgVehicles {
|
|||||||
class ACE_Equipment {
|
class ACE_Equipment {
|
||||||
class GVAR(actions) {
|
class GVAR(actions) {
|
||||||
displayName = CSTRING(displayname);
|
displayName = CSTRING(displayname);
|
||||||
condition = QUOTE([_player] call FUNC(isGunbag));
|
condition = QUOTE([_player] call FUNC(hasGunbag));
|
||||||
showDisabled = 0;
|
showDisabled = 0;
|
||||||
priority = 0.1;
|
priority = 0.1;
|
||||||
icon = PATHTOF(ui\gunbag_icon_ca.paa);
|
icon = PATHTOF(ui\gunbag_icon_ca.paa);
|
||||||
@ -57,7 +57,7 @@ class CfgVehicles {
|
|||||||
};
|
};
|
||||||
class GVAR(StatusGunbag) {
|
class GVAR(StatusGunbag) {
|
||||||
displayName = CSTRING(Status);
|
displayName = CSTRING(Status);
|
||||||
condition = QUOTE([_player] call FUNC(isGunbag));
|
condition = QUOTE([_player] call FUNC(hasGunbag));
|
||||||
statement = QUOTE([_player] call FUNC(status));
|
statement = QUOTE([_player] call FUNC(status));
|
||||||
showDisabled = 0;
|
showDisabled = 0;
|
||||||
priority = 2;
|
priority = 2;
|
||||||
@ -84,6 +84,8 @@ class CfgVehicles {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class DOUBLES(CLASSNAME,Tan): CLASSNAME {
|
class DOUBLES(CLASSNAME,Tan): CLASSNAME {
|
||||||
|
_generalMacro = QUOTE(DOUBLES(CLASSNAME,Tan));
|
||||||
|
author = "Ir0n1E";
|
||||||
displayName = CSTRING(Displayname_Tan);
|
displayName = CSTRING(Displayname_Tan);
|
||||||
picture = PATHTOF(ui\gunbag_tan_ca.paa);
|
picture = PATHTOF(ui\gunbag_tan_ca.paa);
|
||||||
hiddenSelectionsTextures[] = {PATHTOF(data\gunbag_tan_co.paa)};
|
hiddenSelectionsTextures[] = {PATHTOF(data\gunbag_tan_co.paa)};
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
|
||||||
PREP(toGunbag);
|
PREP(toGunbag);
|
||||||
|
PREP(toGunbagCallback);
|
||||||
PREP(offGunbag);
|
PREP(offGunbag);
|
||||||
|
PREP(offGunbagCallback);
|
||||||
PREP(status);
|
PREP(status);
|
||||||
PREP(canInteract);
|
PREP(canInteract);
|
||||||
PREP(calculateMass);
|
PREP(calculateMass);
|
||||||
PREP(isGunbag);
|
PREP(hasGunbag);
|
||||||
|
@ -4,4 +4,22 @@ ADDON = false;
|
|||||||
|
|
||||||
#include "XEH_PREP.hpp"
|
#include "XEH_PREP.hpp"
|
||||||
|
|
||||||
|
// restore gunbag info after respawn
|
||||||
|
["CAManBase", "respawn", {
|
||||||
|
[{
|
||||||
|
params ["_unit", "_corpse"];
|
||||||
|
|
||||||
|
private _newBackpack = backpackContainer _unit;
|
||||||
|
private _oldBackpack = backpackContainer _corpse;
|
||||||
|
|
||||||
|
if !(typeOf _newBackpack isEqualTo typeOf _oldBackpack) exitWith {};
|
||||||
|
|
||||||
|
private _state = _oldBackpack getVariable [QGVAR(gunbagWeapon), []];
|
||||||
|
|
||||||
|
if !(_state isEqualTo []) then {
|
||||||
|
_newBackpack setVariable [QGVAR(gunbagWeapon), _state, true];
|
||||||
|
};
|
||||||
|
}, _this] call CBA_fnc_execNextFrame;
|
||||||
|
}] call CBA_fnc_addClassEventHandler;
|
||||||
|
|
||||||
ADDON = true;
|
ADDON = true;
|
||||||
|
@ -5,16 +5,16 @@
|
|||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Weapon <STRING>
|
* 0: Weapon <STRING>
|
||||||
* 1: Items <ARRAY>
|
* 1: Items <ARRAY>
|
||||||
|
* 2: Magazines <ARRAY>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* Mass <NUMBER>
|
* Mass <NUMBER>
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_weapon","_items"];
|
params ["_weapon", "_items", "_magazines"];
|
||||||
|
|
||||||
private _mass = getNumber (configFile >> "CfgWeapons" >> _weapon >> "WeaponSlotsInfo" >> "mass");
|
private _mass = getNumber (configFile >> "CfgWeapons" >> _weapon >> "WeaponSlotsInfo" >> "mass");
|
||||||
|
|
||||||
@ -22,4 +22,8 @@ private _mass = getNumber (configFile >> "CfgWeapons" >> _weapon >> "WeaponSlots
|
|||||||
_mass = _mass + getNumber (configFile >> "CfgWeapons" >> _x >> "ItemInfo" >> "mass");
|
_mass = _mass + getNumber (configFile >> "CfgWeapons" >> _x >> "ItemInfo" >> "mass");
|
||||||
} foreach _items;
|
} foreach _items;
|
||||||
|
|
||||||
|
{
|
||||||
|
_mass = _mass + getNumber (configFile >> "CfgWeapons" >> _x >> "mass");
|
||||||
|
} forEach _magazines;
|
||||||
|
|
||||||
_mass
|
_mass
|
||||||
|
@ -11,21 +11,18 @@
|
|||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_unit","_target"];
|
params ["_unit", "_target"];
|
||||||
|
|
||||||
private ["_result","_gunbag"];
|
private _result = -1;
|
||||||
|
private _gunbag = backpackContainer _target;
|
||||||
|
|
||||||
_result = -1;
|
if ((_gunbag getVariable [QGVAR(gunbagWeapon), []]) isEqualTo [] && {primaryWeapon _unit != ""} && {getNumber (configFile >> "CfgWeapons" >> primaryWeapon _unit >> QGVAR(allowGunbag)) == 1}) then {
|
||||||
_gunbag = backpackContainer _target;
|
|
||||||
|
|
||||||
if(count (_gunbag getVariable [QGVAR(GunbagWeapon),[]]) <= 0 && {primaryWeapon _unit != ""} && {getNumber (configFile >> "CfgWeapons" >> primaryWeapon _unit >> QGVAR(allowGunbag)) == 1}) then {
|
|
||||||
_result = 0;
|
_result = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
if(count (_gunbag getVariable [QGVAR(GunbagWeapon),[]]) >= 1 && {primaryWeapon _unit == ""}) then {
|
if (!((_gunbag getVariable [QGVAR(gunbagWeapon), []]) isEqualTo []) && {primaryWeapon _unit == ""}) then {
|
||||||
_result = 1;
|
_result = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_unit"];
|
params ["_unit"];
|
@ -11,35 +11,21 @@
|
|||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_unit","_target"];
|
params ["_unit", "_target"];
|
||||||
|
|
||||||
private ["_weapon", "_items", "_gunbag", "_state"];
|
private _gunbag = backpackContainer _target;
|
||||||
|
|
||||||
_gunbag = backpackContainer _target;
|
_unit call EFUNC(common,goKneeling);
|
||||||
_state = _gunbag getVariable [QGVAR(GunbagWeapon),[]];
|
|
||||||
|
|
||||||
if (count _state <= 0) exitWith {
|
|
||||||
[localize LSTRING(empty)] call EFUNC(common,displayTextStructured);
|
|
||||||
};
|
|
||||||
|
|
||||||
_weapon = (_state select 0) select 0;
|
|
||||||
_items = (_state select 1);
|
|
||||||
|
|
||||||
_unit addWeapon _weapon;
|
|
||||||
removeAllPrimaryWeaponItems _unit;
|
|
||||||
|
|
||||||
{
|
|
||||||
_unit addWeaponItem [_weapon, _x];
|
|
||||||
} forEach _items;
|
|
||||||
|
|
||||||
// remove virtual load
|
|
||||||
[_target, backpackContainer _target, -([_weapon, _items] call FUNC(calculateMass))] call EFUNC(movement,addLoadToUnitContainer);
|
|
||||||
_gunbag setVariable [QGVAR(GunbagWeapon), [], true];
|
|
||||||
|
|
||||||
// play sound
|
// play sound
|
||||||
if(["ACE_Backpacks"] call EFUNC(common,isModLoaded)) then {
|
if (!isNil "ACE_Backpacks") then {
|
||||||
[_unit, _target, backpackContainer _target] call EFUNC(backpacks,backpackOpened);
|
[_target, _gunbag] call EFUNC(backpacks,backpackOpened);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[PROGRESSBAR_TIME, _this, {
|
||||||
|
(_this select 0) call FUNC(offGunbagCallback)
|
||||||
|
}, {}, localize LSTRING(offGunbag), {
|
||||||
|
(_this select 0) call FUNC(canInteract) == 1
|
||||||
|
}] call EFUNC(common,progressBar);
|
||||||
|
48
addons/gunbag/functions/fnc_offGunbagCallback.sqf
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Author: Ir0n1E
|
||||||
|
* get weapon out of gunbag
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
* 1: Target <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* Nothing
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
params ["_unit", "_target"];
|
||||||
|
|
||||||
|
private _gunbag = backpackContainer _target;
|
||||||
|
|
||||||
|
private _state = _gunbag getVariable [QGVAR(gunbagWeapon), []];
|
||||||
|
|
||||||
|
if (_state isEqualTo []) exitWith {
|
||||||
|
[localize LSTRING(empty)] call EFUNC(common,displayTextStructured);
|
||||||
|
};
|
||||||
|
|
||||||
|
_state params ["_weapon", "_items", "_magazines"];
|
||||||
|
|
||||||
|
_unit addWeapon _weapon;
|
||||||
|
removeAllPrimaryWeaponItems _unit;
|
||||||
|
|
||||||
|
{
|
||||||
|
_unit addWeaponItem [_weapon, _x];
|
||||||
|
} forEach (_items + _magazines);
|
||||||
|
|
||||||
|
_unit selectWeapon _weapon;
|
||||||
|
|
||||||
|
_magazines = _magazines apply {_x select 0};
|
||||||
|
|
||||||
|
private _mass = [_weapon, _items, _magazines] call FUNC(calculateMass);
|
||||||
|
|
||||||
|
// remove virtual load
|
||||||
|
[_target, _gunbag, -_mass] call EFUNC(movement,addLoadToUnitContainer);
|
||||||
|
_gunbag setVariable [QGVAR(gunbagWeapon), [], true];
|
||||||
|
|
||||||
|
// play sound
|
||||||
|
if (!isNil "ACE_Backpacks") then {
|
||||||
|
[_target, _gunbag] call EFUNC(backpacks,backpackOpened);
|
||||||
|
};
|
@ -10,17 +10,19 @@
|
|||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_unit"];
|
params ["_unit"];
|
||||||
|
|
||||||
private _state = (backpackContainer _unit) getVariable [QGVAR(GunbagWeapon),[]];
|
private _state = (backpackContainer _unit) getVariable [QGVAR(gunbagWeapon), []];
|
||||||
|
|
||||||
if (count _state <= 0) then {
|
if (_state isEqualTo []) then {
|
||||||
[localize LSTRING(empty)] call EFUNC(common,displayTextStructured);
|
[localize LSTRING(empty)] call EFUNC(common,displayTextStructured);
|
||||||
} else {
|
} else {
|
||||||
private _weapon = (_state select 0) select 0;
|
_state params ["_weapon"];
|
||||||
[getText (configFile >> "CfgWeapons" >> _weapon >> "displayname"),
|
|
||||||
getText (configFile >> "CfgWeapons" >> _weapon >> "picture")] call EFUNC(common,displayTextPicture);
|
[
|
||||||
|
getText (configFile >> "CfgWeapons" >> _weapon >> "displayname"),
|
||||||
|
getText (configFile >> "CfgWeapons" >> _weapon >> "picture")
|
||||||
|
] call EFUNC(common,displayTextPicture);
|
||||||
};
|
};
|
||||||
|
@ -11,41 +11,21 @@
|
|||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_unit", "_target"];
|
params ["_unit", "_target"];
|
||||||
|
|
||||||
private ["_weapon", "_magazine", "_magazine_gl", "_items", "_gunbag", "_state", "_mass"];
|
private _gunbag = backpackContainer _target;
|
||||||
|
|
||||||
_gunbag = backpackContainer _target;
|
_unit call EFUNC(common,goKneeling);
|
||||||
_state = [_unit, primaryWeapon _unit] call EFUNC(common,getWeaponState);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* example returnvalue _state
|
|
||||||
* [["","","optic_Aco",""],["arifle_MX_GL_ACO_F","GL_3GL_F"],["30Rnd_65x39_caseless_mag","1Rnd_HE_Grenade_shell"],[30,1]]
|
|
||||||
*/
|
|
||||||
|
|
||||||
_weapon = (_state select 1) select 0;
|
|
||||||
_magazine = [(_state select 2) select 0, (_state select 3) select 0];
|
|
||||||
_magazine_gl = [(_state select 2) select 1, (_state select 3) select 1];
|
|
||||||
_items = _state select 0;
|
|
||||||
|
|
||||||
if ((_magazine_gl select 0) != "") then {
|
|
||||||
_unit addMagazine _magazine_gl;
|
|
||||||
};
|
|
||||||
|
|
||||||
if ((_magazine select 0) != "") then {
|
|
||||||
_unit addMagazine _magazine;
|
|
||||||
};
|
|
||||||
|
|
||||||
_unit removeWeapon _weapon;
|
|
||||||
|
|
||||||
// add virtual load
|
|
||||||
[_target, backpackContainer _target, [_weapon, _items] call FUNC(calculateMass)] call EFUNC(movement,addLoadToUnitContainer);
|
|
||||||
_gunbag setVariable [QGVAR(GunbagWeapon), [[_weapon], _items], true];
|
|
||||||
|
|
||||||
// play sound
|
// play sound
|
||||||
if(["ACE_Backpacks"] call EFUNC(common,isModLoaded)) then {
|
if (!isNil "ACE_Backpacks") then {
|
||||||
[_unit, _target, backpackContainer _target] call EFUNC(backpacks,backpackOpened);
|
[_target, _gunbag] call EFUNC(backpacks,backpackOpened);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[PROGRESSBAR_TIME, _this, {
|
||||||
|
(_this select 0) call FUNC(toGunbagCallback)
|
||||||
|
}, {}, localize LSTRING(toGunbag), {
|
||||||
|
(_this select 0) call FUNC(canInteract) == 0
|
||||||
|
}] call EFUNC(common,progressBar);
|
||||||
|
45
addons/gunbag/functions/fnc_toGunbagCallback.sqf
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Author: Ir0n1E
|
||||||
|
* put weapon into gunbag
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
* 1: Target <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* Nothing
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
params ["_unit", "_target"];
|
||||||
|
|
||||||
|
private _weapon = primaryWeapon _unit;
|
||||||
|
private _gunbag = backpackContainer _target;
|
||||||
|
|
||||||
|
private _state = [_unit, _weapon] call EFUNC(common,getWeaponState);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* example return value _state
|
||||||
|
* [["","","optic_Aco",""],["arifle_MX_GL_ACO_F","GL_3GL_F"],["30Rnd_65x39_caseless_mag","1Rnd_HE_Grenade_shell"],[30,1]]
|
||||||
|
*/
|
||||||
|
|
||||||
|
_state params ["_items", "", "_magazines", "_ammo"];
|
||||||
|
|
||||||
|
private _mass = [_weapon, _items, _magazines] call FUNC(calculateMass);
|
||||||
|
|
||||||
|
{
|
||||||
|
_magazines set [_forEachIndex, [_x, _ammo select _forEachIndex]];
|
||||||
|
} forEach _magazines;
|
||||||
|
|
||||||
|
_unit removeWeapon _weapon;
|
||||||
|
|
||||||
|
// add virtual load
|
||||||
|
[_target, _gunbag, _mass] call EFUNC(movement,addLoadToUnitContainer);
|
||||||
|
_gunbag setVariable [QGVAR(gunbagWeapon), [_weapon, _items, _magazines], true];
|
||||||
|
|
||||||
|
// play sound
|
||||||
|
if (!isNil "ACE_Backpacks") then {
|
||||||
|
[_target, _gunbag] call EFUNC(backpacks,backpackOpened);
|
||||||
|
};
|
@ -1,11 +1,10 @@
|
|||||||
#define COMPONENT gunbag
|
#define COMPONENT gunbag
|
||||||
#include "\z\ace\addons\main\script_mod.hpp"
|
#include "\z\ace\addons\main\script_mod.hpp"
|
||||||
|
|
||||||
#define CLASSNAME ACE_Gunbag
|
//#define DEBUG_ENABLED_GUNBAG
|
||||||
#define DEBUG_MODE_FULL
|
//#define DISABLE_COMPILE_CACHE
|
||||||
#define DISABLE_COMPILE_CACHE
|
//#define CBA_DEBUG_SYNCHRONOUS
|
||||||
#define CBA_DEBUG_SYNCHRONOUS
|
//#define ENABLE_PERFORMANCE_COUNTERS
|
||||||
#define ENABLE_PERFORMANCE_COUNTERS
|
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED_GUNBAG
|
#ifdef DEBUG_ENABLED_GUNBAG
|
||||||
#define DEBUG_MODE_FULL
|
#define DEBUG_MODE_FULL
|
||||||
@ -16,3 +15,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "\z\ace\addons\main\script_macros.hpp"
|
#include "\z\ace\addons\main\script_macros.hpp"
|
||||||
|
|
||||||
|
#define CLASSNAME ACE_Gunbag
|
||||||
|
#define PROGRESSBAR_TIME 5
|
||||||
|
@ -26,4 +26,4 @@
|
|||||||
<German>Waffentasche leer</German>
|
<German>Waffentasche leer</German>
|
||||||
</Key>
|
</Key>
|
||||||
</Package>
|
</Package>
|
||||||
</Project>
|
</Project>
|
||||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 4.1 MiB After Width: | Height: | Size: 4.1 MiB |
Before Width: | Height: | Size: 2.7 MiB After Width: | Height: | Size: 2.7 MiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 4.8 MiB After Width: | Height: | Size: 4.8 MiB |