Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Make unit-classnames usable in gearscript (for non-player units only). #229

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ if (_loadoutVariants isEqualTo []) exitWith
DEBUG_FORMAT3_LOG("[GEARSCRIPT-2]: Unable to add item from loadout '%1' into crate %2 for side %3: the loadout doesn't exist.",_loadout,_crateName,_side)
};

_baseVariant = _loadoutVariants # 0;
if !(_basevariant isEqualType []) exitWith
{
DEBUG_FORMAT3_LOG("[GEARSCRIPT-2]: Unable to add item from loadout '%1' into crate %2 for side %3: only arsenal gearscripts are supported.",_loadout,_crateName,_side)
};

_baseVariant = [_loadoutVariants # 0] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = [_baseVariant] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _baseVariant # 0;

if !(typeName _baseVariant == "ARRAY" and {count _baseVariant > 0 and {typeName (_baseVariant select 0) == "ARRAY"}}) exitWith
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ if (_loadoutVariants isEqualTo []) exitWith
};


_baseVariant = [_loadoutVariants # 0] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _loadoutVariants # 0;
if !(_basevariant isEqualType []) exitWith
{
DEBUG_FORMAT3_LOG("[GEARSCRIPT-2]: Unable to add item from loadout '%1' into crate %2 for side %3: only arsenal gearscripts are supported.",_loadout,_crateName,_side)
};

_baseVariant = [_baseVariant] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _baseVariant # 0;

if !(typeName _baseVariant == "ARRAY" and {count _baseVariant > 0 and {typeName (_baseVariant select 0) == "ARRAY"}}) exitWith
Expand Down
8 changes: 7 additions & 1 deletion components/gearScript/crateSupport/fn_addLauncherToCrate.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ if (_loadoutVariants isEqualTo []) exitWith
};


_baseVariant = [_loadoutVariants # 0] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _loadoutVariants # 0;
if !(_basevariant isEqualType []) exitWith
{
DEBUG_FORMAT3_LOG("[GEARSCRIPT-2]: Unable to add item from loadout '%1' into crate %2 for side %3: only arsenal gearscripts are supported.",_loadout,_crateName,_side)
};

_baseVariant = [_baseVariant] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _baseVariant # 0;

if !(typeName _baseVariant == "ARRAY" and {count _baseVariant > 0 and {typeName (_baseVariant select 0) == "ARRAY"}}) exitWith
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ if (_loadoutVariants isEqualTo []) exitWith
};


_baseVariant = [_loadoutVariants # 0] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _loadoutVariants # 0;
if !(_basevariant isEqualType []) exitWith
{
DEBUG_FORMAT3_LOG("[GEARSCRIPT-2]: Unable to add item from loadout '%1' into crate %2 for side %3: only arsenal gearscripts are supported.",_loadout,_crateName,_side)
};

_baseVariant = [_baseVariant] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _baseVariant # 0;

if !(typeName _baseVariant == "ARRAY" and {count _baseVariant > 0 and {typeName (_baseVariant select 0) == "ARRAY"}}) exitWith
Expand Down
8 changes: 7 additions & 1 deletion components/gearScript/crateSupport/fn_addPistolToCrate.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ if (_loadoutVariants isEqualTo []) exitWith
};


_baseVariant = [_loadoutVariants # 0] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _loadoutVariants # 0;
if !(_basevariant isEqualType []) exitWith
{
DEBUG_FORMAT3_LOG("[GEARSCRIPT-2]: Unable to add item from loadout '%1' into crate %2 for side %3: only arsenal gearscripts are supported.",_loadout,_crateName,_side)
};

_baseVariant = [_baseVariant] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _baseVariant # 0;

if !(typeName _baseVariant == "ARRAY" and {count _baseVariant > 0 and {typeName (_baseVariant select 0) == "ARRAY"}}) exitWith
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ if (_loadoutVariants isEqualTo []) exitWith
};


_baseVariant = [_loadoutVariants # 0] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _loadoutVariants # 0;
if !(_basevariant isEqualType []) exitWith
{
DEBUG_FORMAT3_LOG("[GEARSCRIPT-2]: Unable to add item from loadout '%1' into crate %2 for side %3: only arsenal gearscripts are supported.",_loadout,_crateName,_side)
};

_baseVariant = [_baseVariant] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _baseVariant # 0;

if !(typeName _baseVariant == "ARRAY" and {count _baseVariant > 0 and {typeName (_baseVariant select 0) == "ARRAY"}}) exitWith
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ if (_loadoutVariants isEqualTo []) exitWith
};


_baseVariant = [_loadoutVariants # 0] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _loadoutVariants # 0;
if !(_basevariant isEqualType []) exitWith
{
DEBUG_FORMAT3_LOG("[GEARSCRIPT-2]: Unable to add item from loadout '%1' into crate %2 for side %3: only arsenal gearscripts are supported.",_loadout,_crateName,_side)
};

_baseVariant = [_baseVariant] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _baseVariant # 0;

if !(typeName _baseVariant == "ARRAY" and {count _baseVariant > 0 and {typeName (_baseVariant select 0) == "ARRAY"}}) exitWith
Expand Down
8 changes: 7 additions & 1 deletion components/gearScript/crateSupport/fn_addRifleToCrate.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ if (_loadoutVariants isEqualTo []) exitWith
};


_baseVariant = [_loadoutVariants # 0] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _loadoutVariants # 0;
if !(_basevariant isEqualType []) exitWith
{
DEBUG_FORMAT3_LOG("[GEARSCRIPT-2]: Unable to add item from loadout '%1' into crate %2 for side %3: only arsenal gearscripts are supported.",_loadout,_crateName,_side)
};

_baseVariant = [_baseVariant] call f_fnc_normaliseCbaExtendedLoadout;
_baseVariant = _baseVariant # 0;

if !(typeName _baseVariant == "ARRAY" and {count _baseVariant > 0 and {typeName (_baseVariant select 0) == "ARRAY"}}) exitWith
Expand Down
2 changes: 2 additions & 0 deletions components/gearScript/fn_addGogglesEventHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ if (hasInterface) then

f_var_firstPlayerLoadout = true;

if !(_loadout isEqualType []) exitWith {};

if ((_unit isEqualTo player) and {!isNil 'f_var_playerGoggles'}) then
{
_loadout set [7, f_var_playerGoggles];
Expand Down
68 changes: 42 additions & 26 deletions components/gearScript/fn_applyLoadout.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -72,46 +72,62 @@ if (_loadoutVariants isEqualTo []) exitWith
};


private _originalLoadout = +(selectRandom _loadoutVariants);
_originalLoadout = [_originalLoadout] call f_fnc_normaliseCbaExtendedLoadout;
private _loadout = selectRandom _loadoutVariants;
private _extendedArray = [];

private _loadout = _originalLoadout#0;
private _extendedArray = _originalLoadout#1;
if !(_loadout isEqualTypeAny [[], ""]) exitWith
{
private _loadoutType = typeName _loadout;
DEBUG_FORMAT1_LOG("[GEARSCRIPT-2]: Unsupported type of gearscript (found %1, expected ARRAY or STRING).",_loadoutType)
};

if ((_loadout isEqualType "") and (isPlayer _unit)) exitWith
{
DEBUG_PRINT_LOG("[GEARSCRIPT-2]: Unit-classname gearscripts are not supported for players.")
};

if (count HATS_DYNAMIC(_gearVariant,_typeofUnit) > 0) then
if (_loadout isEqualType []) then
{
private _hat = selectRandom HATS_DYNAMIC(_gearVariant,_typeofUnit);
DEBUG_FORMAT1_LOG("Selected variant hat: %1",_hat)
private _originalLoadout = +_loadout;
_originalLoadout = [_originalLoadout] call f_fnc_normaliseCbaExtendedLoadout;

_loadout set [6, _hat];
};
_extendedArray = _originalLoadout#1;


if (count VESTS_DYNAMIC(_gearVariant,_typeofUnit) > 0) then
{
private _vest = selectRandom VESTS_DYNAMIC(_gearVariant,_typeofUnit);
DEBUG_FORMAT1_LOG("Selected variant vest: %1",_vest)
if (count HATS_DYNAMIC(_gearVariant,_typeofUnit) > 0) then
{
private _hat = selectRandom HATS_DYNAMIC(_gearVariant,_typeofUnit);
DEBUG_FORMAT1_LOG("Selected variant hat: %1",_hat)

_loadout select 4 set [0, _vest];
};
_loadout set [6, _hat];
};


if (count UNIFORMS_DYNAMIC(_gearVariant,_typeofUnit) > 0) then
{
private _uniform = selectRandom UNIFORMS_DYNAMIC(_gearVariant,_typeofUnit);
DEBUG_FORMAT1_LOG("Selected variant uniform: %1",_uniform)
if (count VESTS_DYNAMIC(_gearVariant,_typeofUnit) > 0) then
{
private _vest = selectRandom VESTS_DYNAMIC(_gearVariant,_typeofUnit);
DEBUG_FORMAT1_LOG("Selected variant vest: %1",_vest)

_loadout select 3 set [0, _uniform];
};
_loadout select 4 set [0, _vest];
};


if (count BACKPACKS_DYNAMIC(_gearVariant,_typeofUnit) > 0) then
{
private _backpack = selectRandom BACKPACKS_DYNAMIC(_gearVariant,_typeofUnit);
DEBUG_FORMAT1_LOG("Selected variant backpack: %1",_backpack)
if (count UNIFORMS_DYNAMIC(_gearVariant,_typeofUnit) > 0) then
{
private _uniform = selectRandom UNIFORMS_DYNAMIC(_gearVariant,_typeofUnit);
DEBUG_FORMAT1_LOG("Selected variant uniform: %1",_uniform)

_loadout select 3 set [0, _uniform];
};


_loadout select 5 set [0, _backpack];
if (count BACKPACKS_DYNAMIC(_gearVariant,_typeofUnit) > 0) then
{
private _backpack = selectRandom BACKPACKS_DYNAMIC(_gearVariant,_typeofUnit);
DEBUG_FORMAT1_LOG("Selected variant backpack: %1",_backpack)

_loadout select 5 set [0, _backpack];
};
};

["CA_PreGearscriptUnit_Local", [_typeOfUnit, _unit, _faction, _loadout, _extendedArray]] call CBA_fnc_localEvent;
Expand Down
2 changes: 2 additions & 0 deletions components/gearScript/fn_removeItemFromLoadout.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ private _removeItem =
};

{
if !(_x isEqualType []) then {continue};

private _cbaLoadout = [_x] call f_fnc_normaliseCbaExtendedLoadout;
private _loadout = _cbaLoadout#0;

Expand Down
4 changes: 3 additions & 1 deletion components/gearScript/fn_removeLinkedItemFromLoadout.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ if (_loadoutVariants isEqualTo []) exitWith

DEBUG_FORMAT3_LOG("[GEARSCRIPT-2]: Removing linked item #%1 from loadout '%2' for side '%3'.",_itemIndex,_unitType,_faction)

{
{
if !(_x isEqualType []) then {continue};

private _cbaLoadout = [_x] call f_fnc_normaliseCbaExtendedLoadout;
private _loadout = _cbaLoadout#0;

Expand Down
2 changes: 2 additions & 0 deletions components/radio/acre/fn_acre_removeRadiosFromLoadout.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

params ["_loadout"];

if !(_loadout isEqualType []) exitWith {};

private _filterOutRadios =
{
if (_this isEqualTo []) exitWith {};
Expand Down
2 changes: 2 additions & 0 deletions components/radio/acre/fn_acre_replaceUnitRadios.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

params ["_typeOfUnit", "_unit", "_faction", "_loadout", "_extendedArray"];

if !(_loadout isEqualType []) exitWith {};

[_loadout] call f_fnc_acre_removeRadiosFromLoadout;

private _groupName = groupId group _unit;
Expand Down
2 changes: 2 additions & 0 deletions components/radio/common/fn_configureUnitRadios.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

params [["_typeOfUnit", ""], "_unit", "_faction", "_loadout", "_extendedArray"];

if !(_loadout isEqualType []) exitWith {};

LOCAL_ONLY(_unit);

if (_typeOfUnit isEqualTo "") then
Expand Down
2 changes: 2 additions & 0 deletions components/radio/common/fn_replaceUnitRadios.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

params ["_typeOfUnit", "_unit", "_faction", "_loadout", "_extendedArray"];

if !(_loadout isEqualType []) exitWith {};

if (["acre_sys_radio"] call ace_common_fnc_isModLoaded) then
{
_this call f_fnc_acre_replaceUnitRadios;
Expand Down
4 changes: 2 additions & 2 deletions configuration/loadouts/gear_blufor.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BEGIN_LOADOUTS;

Available commands FOR UNIT LOADOUTS:

CREATE_LOADOUT(UNIT_NAME,<ACE Arsenal code>);
CREATE_LOADOUT(UNIT_NAME,<ACE Arsenal code> OR <unit class-name>);
COPY_LOADOUT(TO,FROM);

ADD_HAT(UNIT_NAME,"Hat Classname");
Expand All @@ -32,7 +32,7 @@ BEGIN_LOADOUTS;

CLEAR_ADDONS(UNIT_NAME);

ADD_VARIANT(UNIT_NAME,<ACE Arsenal code>);
ADD_VARIANT(UNIT_NAME,<ACE Arsenal code> OR <unit class-name>);

-------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions configuration/loadouts/gear_civilian.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BEGIN_LOADOUTS;

Available commands FOR UNIT LOADOUTS:

CREATE_LOADOUT(UNIT_NAME,<ACE Arsenal code>);
CREATE_LOADOUT(UNIT_NAME,<ACE Arsenal code> OR <unit class-name>);
COPY_LOADOUT(TO,FROM);

ADD_HAT(UNIT_NAME,"Hat Classname");
Expand All @@ -32,7 +32,7 @@ BEGIN_LOADOUTS;

CLEAR_ADDONS(UNIT_NAME);

ADD_VARIANT(UNIT_NAME,<ACE Arsenal code>);
ADD_VARIANT(UNIT_NAME,<ACE Arsenal code> OR <unit class-name>);

-------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions configuration/loadouts/gear_guerrilla.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BEGIN_LOADOUTS;

Available commands FOR UNIT LOADOUTS:

CREATE_LOADOUT(UNIT_NAME,<ACE Arsenal code>);
CREATE_LOADOUT(UNIT_NAME,<ACE Arsenal code> OR <unit class-name>);
COPY_LOADOUT(TO,FROM);

ADD_HAT(UNIT_NAME,"Hat Classname");
Expand All @@ -34,7 +34,7 @@ BEGIN_LOADOUTS;

CLEAR_ADDONS(UNIT_NAME);

ADD_VARIANT(UNIT_NAME,<ACE Arsenal code>);
ADD_VARIANT(UNIT_NAME,<ACE Arsenal code> OR <unit class-name>);

-------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions configuration/loadouts/gear_indfor.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BEGIN_LOADOUTS;

Available commands FOR UNIT LOADOUTS:

CREATE_LOADOUT(UNIT_NAME,<ACE Arsenal code>);
CREATE_LOADOUT(UNIT_NAME,<ACE Arsenal code> OR <unit class-name>);
COPY_LOADOUT(TO,FROM);

ADD_HAT(UNIT_NAME,"Hat Classname");
Expand All @@ -32,7 +32,7 @@ BEGIN_LOADOUTS;

CLEAR_ADDONS(UNIT_NAME);

ADD_VARIANT(UNIT_NAME,<ACE Arsenal code>);
ADD_VARIANT(UNIT_NAME,<ACE Arsenal code> OR <unit class-name>);

-------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions configuration/loadouts/gear_opfor.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BEGIN_LOADOUTS;

Available commands FOR UNIT LOADOUTS:

CREATE_LOADOUT(UNIT_NAME,<ACE Arsenal code>);
CREATE_LOADOUT(UNIT_NAME,<ACE Arsenal code> OR <unit class-name>);
COPY_LOADOUT(TO,FROM);

ADD_HAT(UNIT_NAME,"Hat Classname");
Expand All @@ -32,7 +32,7 @@ BEGIN_LOADOUTS;

CLEAR_ADDONS(UNIT_NAME);

ADD_VARIANT(UNIT_NAME,<ACE Arsenal code>);
ADD_VARIANT(UNIT_NAME,<ACE Arsenal code> OR <unit class-name>);

-------------------------------------------------

Expand Down
13 changes: 12 additions & 1 deletion configuration/loadouts/gearscript_readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Available commands FOR UNIT LOADOUTS:
CREATE_LOADOUT(UNIT_NAME,<ACE Arsenal code>);
- Assigns the ACE Arsenal loadout to the unit.
For example, you can create a Rifleman loadout and assign it to the unit-name "rif". The rif class will now be available at Loadout Lockers in-game.
- Also supports unit class-names. You can get these from the editor by using "copy class name" from the right-click menu.
This is only supported for NPCs and will not work upon players!
- For example:
CREATE_LOADOUT(med,"O_medic_F");
Any non-player medic will now look like a CSAT medic.

COPY_LOADOUT(TO,FROM);
- Copies a loadout from one unit-type to another unit-type. Useful if you want to give the same loadout to FTLs and SLs, etc.
Expand Down Expand Up @@ -63,7 +68,7 @@ CLEAR_BACKPACKS(UNIT_NAME);
CLEAR_ADDONS(UNIT_NAME);
- Empties all of the "random lists" for the unit type at the same time. Just like using all of the CLEAR_* commands at once.

ADD_VARIANT(UNIT_NAME,<ACE Arsenal code>);
ADD_VARIANT(UNIT_NAME,<ACE Arsenal code> OR <unit class-name>);
- Advanced feature. Adds alternative loadouts to the unit-type. The loadout will now be randomly chosen between the two.
You must create the first loadout using the CREATE_LOADOUT command before using this command.
Randomisation options apply across all variant loadouts.
Expand All @@ -73,6 +78,12 @@ ADD_VARIANT(UNIT_NAME,<ACE Arsenal code>);
Use ACE Arsenal to create a different Rifleman loadout with an M-16 rifle.
ADD_VARIANT(rif,<ACE Arsenal code>);
All riflemen will now randomly have an AK-47 or M-16 rifle.
- Also supports unit class-names. You can get these from the editor by using "copy class name" from the right-click menu.
This is only supported for NPCs and will not work upon players!
- For example:
ADD_VARIANT(med,"O_medic_F");
Any non-player medic will now look like a CSAT medic.


PUT_GUN_IN_GUNBAG(UNIT_NAME,<contents>)
- Allows the backpack of the given unit to be turned into an ACE gunbag, with the given contents placed inside.
Expand Down
Loading