Skip to content

Commit

Permalink
Fixed cosmetics not functioning and improved applyLoadout (#1182)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBrostrom authored Apr 19, 2024
1 parent ed5b9f5 commit 318a002
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 32 deletions.
32 changes: 13 additions & 19 deletions cScripts/functions/gear/fn_gear_applyCosmetics.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,35 @@
* This function apply cosmetician attributes to a unit.
*
* Arguments:
* 0: Unit <OBJECT>
* None
*
* Return Value:
* Nothing
*
* Example:
* [player] call cScripts_fnc_gear_applyCosmetics
* call cScripts_fnc_gear_applyCosmetics
*
*/

params [["_unit", objNull, [objNull]]];


// Player Name without rank prefix
if (!isNil{GETVAR(_unit,EGVAR(Unit,Name),nil)}) then {
private _name = [_unit] call EFUNC(unit,getName);
SETVAR(_unit,EGVAR(Unit,Name),_name);
if (!isNil{GETVAR(player,EGVAR(Unit,Name),nil)}) then {
private _name = [player] call EFUNC(unit,getName);
SETVAR(player,EGVAR(Unit,Name),_name);
};


// Player Rank to ingame rank
if (EGVAR(Settings,setPlayerRank)) then {
if (!isNil{GETVAR(_unit,EGVAR(Unit,Rank),nil)}) then {
private _rank = [_unit] call EFUNC(player,getRank);
SETVAR(_unit,EGVAR(Unit,Rank),_rank);
if (!isNil{GETVAR(player,EGVAR(Unit,Rank),nil)}) then {
private _rank = [player] call EFUNC(player,getRank);
SETVAR(player,EGVAR(Unit,Rank),_rank);
};
};


// Team Color
if (!isNil{GETVAR(_unit,EGVAR(Unit,TeamColor),nil)}) then {
[_unit] call EFUNC(unit,setTeamColor);
if (!isNil{GETVAR(player,EGVAR(Unit,TeamColor),nil)}) then {
[player] call EFUNC(unit,setTeamColor);
};


// Apply squad insignia
if (EGVAR(Settings,allowInsigniaApplication)) then {
private _insignia = if (call EFUNC(profile,loadInsignia) != "") then {
Expand All @@ -47,7 +41,7 @@ if (EGVAR(Settings,allowInsigniaApplication)) then {
call EFUNC(unit,getSquadInsignia);
};
[{
params ["_unit", "_insignia"];
[_unit, _insignia, false] call EFUNC(unit,setInsignia);
}, [_unit, _insignia], 2] call CBA_fnc_waitAndExecute;
params ["_insignia"];
[player, _insignia, false] call EFUNC(unit,setInsignia);
}, [_insignia], 2] call CBA_fnc_waitAndExecute;
};
17 changes: 6 additions & 11 deletions cScripts/functions/gear/fn_gear_applyLoadout.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if (_loadConfig) then {
_unit setVariable [QEGVAR(Gear,LoadoutClass), _loadout];

// Organizaiton
if (GVAR(isPlayer)) then {
if (hasInterface) then {
private _configPlatoon = getNumber (_config >> "platoon");
private _configCompany = getText (_config >> "company");
[_configPlatoon,_configCompany] call EFUNC(Player,setOrganization);
Expand Down Expand Up @@ -77,20 +77,15 @@ if (!_loadArray) then {
};

// Functions
if (GVAR(isPlayer)) then {
if (hasInterface) then {
call EFUNC(gear,applyFunctions);
};

// Select weapon
_unit selectWeapon (primaryWeapon _unit);
call EFUNC(gear,applyCosmetics);

// Apply googles effect after loadout applications
[_unit, goggles _unit] call ace_goggles_fnc_applyGlassesEffect;
[_unit, goggles _unit] call ace_goggles_fnc_applyGlassesEffect;

// Lower the weapon
if !(weaponLowered _unit) then {_unit action ["WeaponOnBack", _unit]};
_unit selectWeapon (primaryWeapon _unit);
if !(weaponLowered _unit) then {_unit action ["WeaponOnBack", _unit]};

if (GVAR(isPlayer)) then {
[QEGVAR(StagingArsenal,SaveWhitelist)] call CBA_fnc_localEvent;
};

Expand Down
1 change: 0 additions & 1 deletion cScripts/functions/gear/fn_gear_getLoadoutName.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

params [["_unit", objNull, [objNull]]];


private _return = GETVAR(_unit,EGVAR(Gear,loadoutClass), typeOf _unit);

_return
1 change: 1 addition & 0 deletions cScripts/functions/gear/fn_gear_getSideConfig.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* [independent] call cScripts_fnc_gear_getSideConfig
*
*/

params ["_side"];

switch (_side) do {
Expand Down
2 changes: 1 addition & 1 deletion cScripts/functions/gear/fn_gear_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* nothing
*
* Example:
* call cScripts_fnc_gear_postInit
* call cScripts_fnc_gear_preInit
*
*/

Expand Down

0 comments on commit 318a002

Please sign in to comment.