added new load handling

This commit is contained in:
ir0n1e 2016-05-04 09:56:33 +02:00
parent cbabae9253
commit 9af55d741b
7 changed files with 79 additions and 118 deletions

View File

@ -1,18 +1,45 @@
class CBA_Extended_EventHandlers;
class CfgVehicles {
class Man;
class CAManBase: Man {
class ACE_SelfActions {
class ACE_Equipment {
class GVAR(actions) {
displayName = CSTRING(displayname);
condition = QUOTE([_player] call FUNC(isGunbag));
showDisabled = 0;
priority = 0.1;
icon = PATHTOF(ui\gunbag_icon_ca.paa);
class GVAR(WeapontoGunbag) {
class Man;
class CAManBase: Man {
class ACE_Actions {
class ACE_MainActions {
class GVAR(WeapontoGunbag) {
displayName = CSTRING(toGunbag);
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canInteract) == 0);
statement = QUOTE([ARR_2(_player,_target)] call FUNC(toGunbag));
showDisabled = 0;
priority = 1;
icon = PATHTOF(ui\gunbag_icon_ca.paa);
};
class GVAR(WeaponoffGunbag) {
displayName = CSTRING(offGunbag);
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canInteract) == 1);
statement = QUOTE([ARR_2(_player,_target)] call FUNC(offGunbag));
showDisabled = 0;
priority = 1;
icon = PATHTOF(ui\gunbag_icon_ca.paa);
};
class GVAR(StatusGunbag) {
displayName = CSTRING(Status);
condition = QUOTE([_target] call FUNC(isGunbag));
statement = QUOTE([_target] call FUNC(status));
showDisabled = 0;
priority = 2;
icon = PATHTOF(ui\gunbag_icon_ca.paa);
};
};
};
class ACE_SelfActions {
class ACE_Equipment {
class GVAR(actions) {
displayName = CSTRING(displayname);
condition = QUOTE([_player] call FUNC(isGunbag));
showDisabled = 0;
priority = 0.1;
icon = PATHTOF(ui\gunbag_icon_ca.paa);
class GVAR(WeapontoGunbag) {
displayName = CSTRING(toGunbag);
condition = QUOTE([ARR_2(_player,_player)] call FUNC(canInteract) == 0);
statement = QUOTE([ARR_2(_player,_player)] call FUNC(toGunbag));
@ -41,36 +68,6 @@ class CfgVehicles {
};
};
class ACE_Actions {
class ACE_MainActions {
class GVAR(WeapontoGunbag) {
displayName = CSTRING(toGunbag);
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canInteract) == 0);
statement = QUOTE([ARR_2(_player,_target)] call FUNC(toGunbag));
showDisabled = 0;
priority = 1;
icon = PATHTOF(ui\gunbag_icon_ca.paa);
};
class GVAR(WeaponoffGunbag) {
displayName = CSTRING(offGunbag);
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canInteract) == 1);
statement = QUOTE([ARR_2(_player,_target)] call FUNC(offGunbag));
showDisabled = 0;
priority = 1;
icon = PATHTOF(ui\gunbag_icon_ca.paa);
};
class GVAR(StatusGunbag) {
displayName = CSTRING(Status);
condition = QUOTE([_target] call FUNC(isGunbag));
statement = QUOTE([_target] call FUNC(status));
showDisabled = 0;
priority = 2;
icon = PATHTOF(ui\gunbag_icon_ca.paa);
};
};
};
class Bag_Base;
class CLASSNAME: Bag_Base {
_generalMacro = QUOTE(CLASSNAME);
@ -83,29 +80,12 @@ class CfgVehicles {
hiddenSelections[] = {QUOTE(Camo),QUOTE(insignia)};
hiddenSelectionsTextures[] = {PATHTOF(data\gunbag_co.paa)};
maximumLoad = 80;
transportMaxMagazines = 2;
transportMaxWeapons = 1;
transportMaxBackpacks = 0;
GVAR(gunbagswitch) = QUOTE(DOUBLES(CLASSNAME,Full));
mass = 11;
};
class DOUBLES(CLASSNAME,Tan): CLASSNAME {
displayName = CSTRING(Displayname_Tan);
picture = PATHTOF(ui\gunbag_tan_ca.paa);
hiddenSelectionsTextures[] = {PATHTOF(data\gunbag_tan_co.paa)};
GVAR(gunbagswitch) = QUOTE(TRIPLES(CLASSNAME,Tan,Full));
};
class DOUBLES(CLASSNAME,Full): CLASSNAME {
scope = 1;
mass = 311;
GVAR(gunbagswitch) = QUOTE(CLASSNAME);
};
class TRIPLES(CLASSNAME,Tan,Full): DOUBLES(CLASSNAME,Tan) {
scope = 1;
mass = 311;
GVAR(gunbagswitch) = QUOTE(DOUBLES(CLASSNAME,Tan));
};
};

View File

@ -2,5 +2,5 @@ PREP(toGunbag);
PREP(offGunbag);
PREP(status);
PREP(canInteract);
PREP(switchBackpack);
PREP(calculateMass);
PREP(isGunbag);

View File

@ -2,10 +2,10 @@
class CfgPatches {
class ADDON {
units[] = {"ACE_Gunbag", "ACE_Gunbag_tan", "ACE_Gunbag_full", "ACE_Gunbag_tan_full"};
units[] = {"ACE_Gunbag", "ACE_Gunbag_tan"};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interaction"};
requiredAddons[] = {"ace_interaction", "ace_movement"};
author[] = {"Ir0n1E"};
VERSION_CONFIG;
};

View File

@ -0,0 +1,25 @@
/*
* Author: Ir0n1E
* calculate mass of weapon an items
*
* Arguments:
* 0: Weapon <STRING>
* 1: Items <ARRAY>
*
* Return Value:
* Mass <NUMBER>
*
* Public: No
*/
#include "script_component.hpp"
params ["_weapon","_items"];
private _mass = getNumber (configFile >> "CfgWeapons" >> _weapon >> "WeaponSlotsInfo" >> "mass");
{
_mass = _mass + getNumber (configFile >> "CfgWeapons" >> _x >> "ItemInfo" >> "mass");
} foreach _items;
_mass

View File

@ -40,4 +40,5 @@ removeAllPrimaryWeaponItems _unit;
_unit addWeaponItem [_weapon, _x];
} forEach _items;
([_target] call FUNC(switchBackpack)) setVariable [QGVAR(GunbagWeapon), [], true];
[_target, backpackContainer _target, [_weapon, _items] call FUNC(calculateMass)] call EFUNC(movement,addLoadToUnitContainer);
_gunbag setVariable [QGVAR(GunbagWeapon), [], true];

View File

@ -1,36 +0,0 @@
/*
* Author: Ir0n1E
* switches gunbag full/empty for mass calculation
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* backpack <OBJECT>
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
private ["_altgunbag", "_items", "_gunbag"];
_gunbag = backpackContainer _unit;
_items = backpackItems _unit;
_altgunbag = getText (configFile >> "CfgVehicles" >> typeof _gunbag >> QGVAR(gunbagswitch));
removeBackpack _unit;
_unit addBackpack _altgunbag;
{
_unit addItemToBackpack _x;
} forEach _items;
if ([QUOTE(ACE_Backpacks)] call EFUNC(common,isModLoaded)) then {
[_unit, backpackContainer _unit] call EFUNC(backpacks,backpackOpened);
};
(backpackContainer _unit)

View File

@ -16,22 +16,19 @@
params ["_unit", "_target"];
private ["_weapon", "_magazine", "_items", "_gunbag", "_state"];
private ["_weapon", "_magazine", "_items", "_gunbag", "_state", "_mass"];
_gunbag = backpackContainer _target;
_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]]
* ["","","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];
_items = _state select 0;
_weapon = ((_state select 4) select 0);
_magazine = [(_state select 5) select 0, (_state select 6) select 0];
_items = [_state select 0, _state select 1, _state select 2, _state select 3];
if ((_magazine select 0) != "") then {
@ -40,11 +37,5 @@ if ((_magazine select 0) != "") then {
_unit removeWeapon _weapon;
for "_loop" from 0 to (count _state) -1 do {
if (typeName (_state select _loop) == QUOTE(STRING)) then {
_items pushBack (_state select _loop);
};
};
([_target] call FUNC(switchBackpack)) setVariable [QGVAR(GunbagWeapon), [[_weapon], _items], true];
[_target, backpackContainer _target, [_weapon, _items] call FUNC(calculateMass)] call EFUNC(movement,addLoadToUnitContainer);
_gunbag setVariable [QGVAR(GunbagWeapon), [[_weapon], _items], true];