diff --git a/addons/infantry/XEH_PREP.hpp b/addons/infantry/XEH_PREP.hpp index dd2628c6..58f1ba36 100644 --- a/addons/infantry/XEH_PREP.hpp +++ b/addons/infantry/XEH_PREP.hpp @@ -1,4 +1,6 @@ -PREP(getCallsign); -PREP(getShortDesignation); -PREP(getUnitDesignation); -PREP(setCallsign); \ No newline at end of file +PREP(getBillet); +PREP(getDesignation); +PREP(getUnitCallsign); +PREP(getUnitTeam); +PREP(setUniqCallsign); +PREP(setUnitTeam); \ No newline at end of file diff --git a/addons/infantry/XEH_postInit.sqf b/addons/infantry/XEH_postInit.sqf index 2c04628b..f6af1af5 100644 --- a/addons/infantry/XEH_postInit.sqf +++ b/addons/infantry/XEH_postInit.sqf @@ -2,4 +2,5 @@ if (!hasInterface) exitWith {}; -player call FUNC(setCallsign); \ No newline at end of file +[player] call FUNC(setUniqCallsign); +[player] call FUNC(setUnitTeam); \ No newline at end of file diff --git a/addons/infantry/functions/fnc_getShortDesignation.sqf b/addons/infantry/functions/fnc_getBillet.sqf similarity index 71% rename from addons/infantry/functions/fnc_getShortDesignation.sqf rename to addons/infantry/functions/fnc_getBillet.sqf index fd9ee542..3dfe67ec 100644 --- a/addons/infantry/functions/fnc_getShortDesignation.sqf +++ b/addons/infantry/functions/fnc_getBillet.sqf @@ -1,23 +1,23 @@ #include "..\script_component.hpp" /* - * Author: CPL.Brostrom.A - * This function return a unit designation - * The callsign can also be defined in mission via CfgLoadouts + * Author: SGT.Brostrom.A + * This function return your given unit billet designation. + * If you have a cfgLoadouts in your mission it will be used instead. * * Arguments: - * 0: Unit + * 0: Unit/Classname * * Return Value: - * Callsign + * Unit Billet (1/1/C/1-7) * * Example: - * _x = [player] call cav_infantry_fnc_getShortDesignation; + * _x = [player] call cav_infantry_fnc_getBillet; * _x // 1/1/C/1-7 * * Public: Yes */ -params [["_unit", objNull, [objNull]]]; +params [["_unit", objNull, [objNull,""]]]; private _hashMap = [_unit] call FUNC(getUnitCallsign); diff --git a/addons/infantry/functions/fnc_getUnitDesignation.sqf b/addons/infantry/functions/fnc_getDesignation.sqf similarity index 72% rename from addons/infantry/functions/fnc_getUnitDesignation.sqf rename to addons/infantry/functions/fnc_getDesignation.sqf index 90ed0daa..3688864b 100644 --- a/addons/infantry/functions/fnc_getUnitDesignation.sqf +++ b/addons/infantry/functions/fnc_getDesignation.sqf @@ -11,14 +11,16 @@ * HashMap * * Example: - * [player] call cav_infantry_fnc_getUnitDesignation; + * [player] call cav_infantry_fnc_getDesignation * * Public: No */ -params [["_unit", objNull, [objNull]]]; +params [["_unit", objNull, [objNull, ""]]]; -private _classname = typeOf _unit; +if (_unit isEqualType objNull) then { + _unit = typeOf _unit; +}; private _fn_companyLetter = { params ["_company"]; @@ -37,24 +39,26 @@ private _fn_companyLetter = { private _fn_getConfigValue = { params ["_configKey"]; - + LOG_1("getDesignation: Looking up key '%1'",_configKey); private _return = ""; _CfgLoadouts = isClass (missionConfigFile >> "CfgLoadouts"); - if (_configKey == "company") then { + if (_configKey in ["company", "regimentName"] ) then { _configKeyPrefixed = format["cav_%1",_configKey]; - _return = getText (configFile >> "CfgVehicles" >> _classname >> _configKeyPrefixed); + _return = getText (configFile >> "CfgVehicles" >> _unit >> _configKeyPrefixed); if (_CfgLoadouts) then { if (_CfgLoadouts) then { - _return = getText (missionConfigFile >> "CfgLoadouts" >> _classname >> _configKey); + _return = getText (missionConfigFile >> "CfgLoadouts" >> _unit >> _configKey); }; }; - _return = _return call _fn_companyLetter; + if (_configKey == "company") then { + _return = _return call _fn_companyLetter; + }; } else { _configKeyPrefixed = format["cav_%1",_configKey]; - _return = getNumber (configFile >> "CfgVehicles" >> _classname >> _configKeyPrefixed); + _return = getNumber (configFile >> "CfgVehicles" >> _unit >> _configKeyPrefixed); if (_CfgLoadouts) then { - _return = getNumber (missionConfigFile >> "CfgLoadouts" >> _classname >> _configKey); + _return = getNumber (missionConfigFile >> "CfgLoadouts" >> _unit >> _configKey); }; _return = [_return, 0] select (_return <= 0); _return = str _return; diff --git a/addons/infantry/functions/fnc_getCallsign.sqf b/addons/infantry/functions/fnc_getUnitCallsign.sqf similarity index 54% rename from addons/infantry/functions/fnc_getCallsign.sqf rename to addons/infantry/functions/fnc_getUnitCallsign.sqf index 0da3950d..de11fd13 100644 --- a/addons/infantry/functions/fnc_getCallsign.sqf +++ b/addons/infantry/functions/fnc_getUnitCallsign.sqf @@ -1,7 +1,8 @@ #include "..\script_component.hpp" /* - * Author: CPL.Brostrom.A - * This function gets your callsign based on your displayname + * Author: SGT.Brostrom.A + * This function gets your callsign based on your units displayName + * If you have a cfgLoadouts in your mission it will be used instead. * Exsample: Squad Leader (BADNIT-1) will return BADNIT-1 * * Arguments: @@ -11,17 +12,20 @@ * Unit Callsign * * Example: - * [player] call cav_infantry_fnc_getCallsign + * [player] call cav_infantry_fnc_getUnitCallsign * * Public: No */ -params [["_unit", objNull, [objNull]]]; +params [["_unit", objNull, [objNull, ""]]]; -private _classname = typeOf _unit; -_displayName = getText (configFile >> "CfgVehicles" >> _classname >> "displayName"); +if (_unit isEqualType objNull) then { + _unit = typeOf _unit; +}; + +_displayName = getText (configFile >> "CfgVehicles" >> _unit >> "displayName"); if (isClass (missionConfigFile >> "CfgLoadouts")) then { - _displayName = getText (missionConfigFile >> "CfgLoadouts" >> _classname >> "displayName"); + _displayName = getText (missionConfigFile >> "CfgLoadouts" >> _unit >> "displayName"); }; private _callsign = _displayName splitString " "; @@ -31,9 +35,4 @@ _callsign = _callsign select (count _callsign - 1); _callsign = _callsign splitString ")"; _callsign = _callsign select (count _callsign - 1); -private _group = group _unit; -private _currentID = groupId group _unit; -if (_currentID == _callsign) exitWith {_currentID}; - -[_group, _callsign] call CBA_fnc_setCallsign; _callsign; \ No newline at end of file diff --git a/addons/infantry/functions/fnc_getUnitTeam.sqf b/addons/infantry/functions/fnc_getUnitTeam.sqf new file mode 100644 index 00000000..c1bed682 --- /dev/null +++ b/addons/infantry/functions/fnc_getUnitTeam.sqf @@ -0,0 +1,33 @@ +#include "..\script_component.hpp" +/* + * Author: SGT.Brostrom.A + * This function get team color based on you unit prefix + * + * Arguments: + * 0: Unit + * + * Return Value: + * Color Name + * + * Example: + * [player] call cav_infantry_fnc_getUnitTeam; + * + * Public: No + */ + +params [["_unit", objNull, [objNull]]]; + +private _displayName = getText (configFile >> "CfgVehicles" >> typeOf _unit >> "displayName"); +_displayName = _displayName splitString " "; +_team = _displayName#0; +_teamUpper = toUpper _team; + +private _color = switch (_teamUpper) do { + case "ALPHA": {"RED"}; + case "BRAVO": {"BLUE"}; + case "CHARLIE": {"GREEN"}; + case "DELTA": {"YELLOW"}; + default {"MAIN"}; +}; + +_color; \ No newline at end of file diff --git a/addons/infantry/functions/fnc_setCallsign.sqf b/addons/infantry/functions/fnc_setUniqCallsign.sqf similarity index 76% rename from addons/infantry/functions/fnc_setCallsign.sqf rename to addons/infantry/functions/fnc_setUniqCallsign.sqf index 065049be..68952ca0 100644 --- a/addons/infantry/functions/fnc_setCallsign.sqf +++ b/addons/infantry/functions/fnc_setUniqCallsign.sqf @@ -7,41 +7,44 @@ * 0: Unit * * Return Value: - * Units new callsign + * True or False * * Example: - * [player] call cav_infantry_fnc_setCallsign + * [player] call cav_infantry_fnc_setUniqCallsign * * Public: No */ params [["_unit", objNull, [objNull]]]; +if (isNull _unit) exitWith {}; + private _classname = typeOf _unit; private _group = group _unit; private _currentID = groupId group _unit; -private _hashMap = [_unit] call FUNC(getUnitDesignation); +private _hashMap = [_unit] call FUNC(getDesignation); private _regiment = _hashMap getOrDefault ["regiment", "0"]; if (_regiment == "0") exitWith {INFO_1("Regiment for %1 is not set, callsign not changed",_unit); false}; INFO_1("Attempting to set callsign for %1",_unit); -private _callsign = [_unit] call FUNC(getCallsign); +private _callsign = [_unit] call FUNC(getUnitCallsign); // Check if the callsign is structured correctly CALLSIGN-1 private _callsignSplit = _callsign splitString "-"; if (count _callsignSplit != 2 ) exitWith {INFO_1("Uniq callsign not changed for %1",_unit); false}; // Check if your name is already set -if (_currentID == _callsign) exitWith {INFO_1("Uniq callsign for unit allready set %1",_unit); false}; +if (_currentID == _callsign) exitWith {INFO_1("Uniq callsign for unit already set %1",_unit); false}; // Check if name correspon to callsign given private _squad = _callsignSplit#1; private _expectedSquad = _hashMap getOrDefault ["squad", "0"]; -if (_squad != _expectedSquad) exitWith {INFO_1("Expected squad number value %1 don't match config %2",_expectedSquad,_squad); false}; +if (_squad != _expectedSquad) exitWith {INFO_2("Expected squad number value %1 don't match config %2",_expectedSquad,_squad); false}; INFO_1("Units group callsign set to '%1'",_callsign); [_group, _callsign] call CBA_fnc_setCallsign; + true \ No newline at end of file diff --git a/addons/infantry/functions/fnc_setUnitTeam.sqf b/addons/infantry/functions/fnc_setUnitTeam.sqf new file mode 100644 index 00000000..72c85327 --- /dev/null +++ b/addons/infantry/functions/fnc_setUnitTeam.sqf @@ -0,0 +1,28 @@ +#include "..\script_component.hpp" +/* + * Author: SGT.Brostrom.A + * This function sets your team name based on your units prefix + * + * Arguments: + * 0: Unit + * + * Return Value: + * Unit Callsign + * + * Example: + * [player] call cav_infantry_fnc_setUnitTeam; + * + * Public: No + */ + +params [["_unit", objNull, [objNull]]]; + +private _color = [_unit] call FUNC(getUnitTeam); + +if (assignedTeam _unit == _color) exitWith {INFO_1("Team color for unit already set %1",_unit);false}; + +[_unit, _color] call ace_interaction_fnc_joinTeam; + +INFO_2("%1 have joind team %2.", _unit, _color); + +true \ No newline at end of file diff --git a/addons/infantry_charlie_labeled/CfgVehicles.hpp b/addons/infantry_charlie_labeled/CfgVehicles.hpp index c8d92ad4..cd5ee8fa 100644 --- a/addons/infantry_charlie_labeled/CfgVehicles.hpp +++ b/addons/infantry_charlie_labeled/CfgVehicles.hpp @@ -19,7 +19,7 @@ class CfgVehicles { // First Platoon UNIT_CHARLIE(Cav_B_C_PlatoonSergeant_1_5_F,Cav_B_C_PlatoonSergeant_F,1,5); UNIT_CHARLIE(Cav_B_C_PlatoonLeader_1_6_F,Cav_B_C_PlatoonLeader_F,1,5); - UNIT_CHARLIE(Cav_B_C_PlatoonMedic_1_7_F,Cav_B_C_PlatoonMedic_F,1,5); + UNIT_CHARLIE(Cav_B_C_PlatoonMedic_1_7_F,Cav_B_C_PlatoonMedic_F,1,7); // Squad 1-1-C-1/7 UNIT_CHARLIE(Cav_B_C_SquadLeader_1_1_F,Cav_B_C_SquadLeader_F,1,1); @@ -77,8 +77,8 @@ class CfgVehicles { // Second Platoon UNIT_CHARLIE(Cav_B_C_PlatoonSergeant_2_5_F,Cav_B_C_PlatoonSergeant_F,2,5); - UNIT_CHARLIE(Cav_B_C_PlatoonLeader_2_6_F,Cav_B_C_PlatoonLeader_F,2,5); - UNIT_CHARLIE(Cav_B_C_PlatoonMedic_2_7_F,Cav_B_C_PlatoonMedic_F,2,5); + UNIT_CHARLIE(Cav_B_C_PlatoonLeader_2_6_F,Cav_B_C_PlatoonLeader_F,2,6); + UNIT_CHARLIE(Cav_B_C_PlatoonMedic_2_7_F,Cav_B_C_PlatoonMedic_F,2,7); // Squad 1-2-C-1/7 UNIT_CHARLIE(Cav_B_C_SquadLeader_2_1_F,Cav_B_C_SquadLeader_F,2,1);