Commit 289e090b authored by Miller's avatar Miller
Browse files

Merge branch 'logistics' into 'master'

Include Logistics

See merge request Miller/w_fnc!9
parents fa8e83f4 60be3ceb
......@@ -106,11 +106,27 @@ class ADDON { // GrpW_mission_fnc_FNCNAME
#define COMPONENT db
class ADDON { // GrpW_db_fnc_FNCNAME
class mission {
class db {
file = "W_fnc\db";
class preInitDb {preInit = 1;};
class getGroups {};
class getPrefixCounter{};
class updatePrefixCounter {};
};
};
\ No newline at end of file
};
#define COMPONENT logistics
class ADDON { // GrpW_logistics_fnc_FNCNAME
class logistics {
file = "W_fnc\logistics";
class addBackpacksToCrate {};
class addItemsToCrate {};
class addMagazinesToCrate {};
class addWeaponsToCrate {};
class clearCargo {};
class createCrate {};
class defineLoad {};
class setupCrate {};
class setupVehicle {};
};
};
#include "script_component.hpp"
/*
This documentation is a stud. Don't use this function on your own.
*/
params [
["_container", objNull, [objNull] ],
["_backpackArray", [], [[]] ]
];
// [ [["typeA", 2], Items], [["typeB", 2], Items] ]
{
_container addBackpackCargoGlobal (_X select 0);
private _backpackLoad = _X select 1;
private _prevReturn = (everyBackpack _container) select [
( (count everyBackpack _container) - ((_X select 0) select 1) ),
(_X select 0) select 1
];
{
if (_backpackLoad != "") then {[_X, _backpackLoad] call FUNC(setupCrate)};
} forEach _prevReturn;
} forEach _backpackArray;
#include "script_component.hpp"
/*
This documentation is a stud. Don't use this function on your own.
*/
params [
["_container", objNull, [objNull] ],
["_itemsArray", [], [[]] ]
];
{
_container addItemCargoGlobal _X;
} forEach _itemsArray;
#include "script_component.hpp"
/*
This documentation is a stud. Don't use this function on your own.
*/
params [
["_container", objNull, [objNull] ],
["_magazinesArray", [], [[]] ]
];
{
_container addMagazineCargoGlobal _X;
} forEach _magazinesArray;
#include "script_component.hpp"
/*
This documentation is a stud. Don't use this function on your own.
*/
params [
["_container", objNull, [objNull] ],
["_weaponsArray", [], [[]] ]
];
{
_container addWeaponWithAttachmentsCargoGlobal _X;
} forEach _weaponsArray;
#include "script_component.hpp"
/*
This documentation is a stud. Don't use this function on your own.
*/
params [
["_container", objNull, [objNull] ]
];
clearWeaponCargoGlobal _container;
clearMagazineCargoGlobal _container;
clearItemCargoGlobal _container;
clearBackpackCargoGlobal _container;
#include "script_component.hpp"
/*
This documentation is a stud. Don't use this function on your own.
*/
params [
["_type", "", [""] ],
["_position", [0,0,0], [[]] ],
["_cargoSize", 1, [0] ],
["_dir", 0, [0] ]
];
private _container = _type createVehicle _position;
_container setDir _dir;
[_container, _cargoSize] call ace_cargo_fnc_setSize;
_container
#include "script_component.hpp"
/*
Name: GrpW_fnc_logistics_defineLoad
Author: [W] Miller
Use: define a load preset
Parameter(s):
0:
STRING - Preset Name
1:
ARRAY - An array containg arrays as in https://community.bistudio.com/wiki/addWeaponWithAttachmentsCargoGlobal
2:
ARRAY - An array containing arrays
E.g. [ ["MagtypeA", Count], ["MagtypeB", Count] ]
3:
ARRAY - An array containing items
E.g. [ ["ItemTypeA", Count], ["ItemTypeB", Count] ]
4:
ARRAY - An array containing backpacks
E.g. [ [["BackpackTypeA", Count], LoadPresetName], [["BackpackTypeB", Count], LoadPresetName] ]
Returns: BOOL
Example function(s):
[
"testBoxLoad",
[
[["arifle_MX_GL_F", "", "acc_flashlight", "", ["30Rnd_65x39_caseless_mag", 30], ["3Rnd_HE_Grenade_shell", 2], ""], 5],
[["arifle_MX_Holo_pointer_F", "", "", "", [], [], ""], 1]
],
[
["30Rnd_65x39_caseless_mag", 10],
["3Rnd_HE_Grenade_shell", 10]
],
[
["Binocular", 2],
["ItemGPS", 6]
],
[
[["B_AssaultPack_wdl_F", 2], "testBackpackLoad"],
[["B_AssaultPack_blk", 2], "testBackpackLoad2"]
]
] call GrpW_logistics_fnc_defineLoad;
*/
params [
["_presetName", "", [""] ],
["_weaponsArray", [], [[]] ],
["_magazinesArray", [], [[]] ],
["_itemsArray", [], [[]] ],
["_backpackArray", [], [[]] ]
];
//log errors
if (_presetName == "") exitWith {["No or non-string name given for group preset. Preset could not be saved."] call BIS_fnc_error; false};
_this deleteAt 0;
missionNamespace setVariable [(format [QGVAR(%1), _presetName]), _this, true];
true
#include "script_component.hpp"
/*
Name: GrpW_fnc_call
Author: [W] Miller
Use: call a GrpW function. This findes the right function and makes calling one easier
Parameter(s):
0:
OBJECT - Container to fill
OR
ARRAY - Spawn instructions
[ Crate_Type, Position_Array_3D, CargoSize, Rotation ]
Crate_Type = STRING
Position_Array_3D = ARRAY (OPTIONAL; Default = [0,0,0])
CargoSize = NUMBER (OPTIONAL; Default = 1)
Rotation = NUMBER (OPTIONAL; Default = 0)
1:
STRING - Load Preset Name
Returns: OBJECT
Example function(s): [box, "testBox"] call GrpW_logistics_fnc_setupCrate;
[
["Box_NATO_Ammo_F", getMarkerPos "box_spawn", 2, 0],
"testBox"
] call GrpW_logistics_fnc_setupCrate;
*/
params [
["_crate_defines", objNull, [objNull, []] ],
["_crate_type", "", [""] ]
];
//log errors
if (_crate_defines in [objNull, []]) exitWith {["No crate or crate data given."] call BIS_fnc_error; false};
//check if we need to spawn a crate. if yes, spawn it and return the new object.
private _container = if ( _crate_defines isEqualType [] ) then {
_crate_defines call FUNC(createCrate)
} else {
_crate_defines
};
systemChat str _container;
//clear cargo space
[_container] call FUNC(clearCargo);
//get load data from preset
missionNamespace getVariable [(format [QGVAR(%1), _crate_type]), []] params [
["_weaponsArray", [], [[]] ],
["_magazinesArray", [], [[]] ],
["_itemsArray", [], [[]] ],
["_backpackArray", [], [[]] ]
];
//start filling the crate.
[_container, _weaponsArray] call FUNC(addWeaponsToCrate);
[_container, _magazinesArray] call FUNC(addMagazinesToCrate);
[_container, _itemsArray] call FUNC(addItemsToCrate);
[_container, _backpackArray] call FUNC(addBackpacksToCrate);
//return the crate we just filled
_container
#include "script_component.hpp"
/*
Name: GrpW_fnc_call
Author: [W] Miller
Use: call a GrpW function. This findes the right function and makes calling one easier
Parameter(s):
0:
OBJECT - Vehicle to load
1:
STRING - Load Preset to load into Vehicle
2:
ARRAY - Crates to load into the vehicle. As in fn_setupCrate.sqf
Returns: BOOL
Example function(s): [
mycar,
"testBox",
[
[
[
"Box_NATO_Ammo_F",
getMarkerPos "box_spawn",
0.5,
0
],
"testBox"
],
[boxInBase,"testBox"],
[boxInBase_2, "testBox2"]
]
] call GrpW_logistics_fnc_setupVehicle;
*/
params [
["_vehicle", objNull, [objNull] ],
["_vehicle_load_inventory", "", [""] ],
["_vehicle_crates", [], [[]] ]
];
//log errors
if (_crate_defines == objNull) exitWith {["No vehicle given."] call BIS_fnc_error; false};
//fill vehicle inventory
[_vehicle, _vehicle_load_inventory] call FUNC(setupCrate);
//spawn crates, fill them and load them into the vehicle
{
private _newCrate = _X call FUNC(setupCrate);
private _loaded = [_newCrate, _vehicle, true] call ace_cargo_fnc_loadItem;
//check if we could fit the new crate
if (!_loaded) then {
//error
deleteVehicle _newCrate;
[format ["A crate with the load preset '%1' could not be loaded into the vehicle '%2'. The crate has not been created. Please check your size settings.", _X select 1, _vehicle]] call BIS_fnc_error;
};
} forEach _vehicle_crates;
true
#define COMPONENT logistics
#include "..\script_component.hpp"
......@@ -33,7 +33,7 @@ if ( _custom_class_bool ) then {
case "sql": { 'B_Soldier_SL_F' };
case "tl": { 'B_Soldier_TL_F' };
case "ar": { 'B_Soldier_AR_F' };
case "aar": { 'B_soldier_AAR_F' }
case "aar": { 'B_soldier_AAR_F' };
case "gren": { 'B_Soldier_GL_F' };
case "dm": { 'B_soldier_M_F' };
case "exp": { 'B_soldier_exp_F' };
......
......@@ -2,8 +2,8 @@
#define WCFG CfgWFNC
#define MAJOR 2
#define MINOR 0
#define PATCHLVL 0
#define MINOR 1
#define PATCHLVL 1
#define VERSION MAJOR.MINOR.PATCHLVL
#include "script_macros_common.hpp"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment