Skip to content

Commit

Permalink
Update SetTeamColour.sqf
Browse files Browse the repository at this point in the history
Refining our methodology for this to raise its hit rate.
  • Loading branch information
AdamWaldie committed Sep 17, 2023
1 parent bfbcad5 commit b50e9c5
Showing 1 changed file with 18 additions and 43 deletions.
61 changes: 18 additions & 43 deletions MissionScripts/MissionInit/InitHelpers/SetTeamColour.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,64 +15,39 @@ call Waldo_fnc_SetTeamColour;
*/

private _getTeamName = "";
private _roleDesc = "";

if !(roleDescription player == "") then {
_getTeamName = roleDescription player;
_roleDesc = roleDescription player;
} else {
_getTeamName = getText (configFile >> "CfgVehicles" >> typeOf player >> "displayName");
_roleDesc = getText (configFile >> "CfgVehicles" >> typeOf player >> "displayName");
};
_getTeamName = _getTeamName splitString " ";
_getTeamName = _getTeamName select 0;
_getTeamName = toUpper _getTeamName;
_roleDesc = toUpper _roleDesc;

//Due to the large scope of potential name conventions for clans, heres a collossal catch all.
switch (_getTeamName) do {
case "ALPHA": {
[player, "RED"] call ace_interaction_fnc_joinTeam;
(player) setVariable ["Waldo_PlayerInit_Team", 'RED'];
};
case "RED": {
// Using a switch statement to match the condition and assign the team color - this is first match so order is imperative
switch (true) do {
case ((_roleDesc find "ASSISTANT SQUAD LEADER") > -1 || (_roleDesc find "ASL") > -1): {
[player, "RED"] call ace_interaction_fnc_joinTeam;
(player) setVariable ["Waldo_PlayerInit_Team", 'RED'];
};
case "BRAVO": {
[player, "BLUE"] call ace_interaction_fnc_joinTeam;
(player) setVariable ["Waldo_PlayerInit_Team", 'BLUE'];
};
case "BLUE": {
[player, "BLUE"] call ace_interaction_fnc_joinTeam;
(player) setVariable ["Waldo_PlayerInit_Team", 'BLUE'];
case ((_roleDesc find "SQUAD LEADER") > -1 || (_roleDesc find "SL") > -1): {
[player, "YELLOW"] call ace_interaction_fnc_joinTeam;
};
case "CHARLIE": {
case ((_roleDesc find "MEDIC") > -1): {
[player, "GREEN"] call ace_interaction_fnc_joinTeam;
(player) setVariable ["Waldo_PlayerInit_Team", 'GREEN'];
};
case "GREEN": {
[player, "GREEN"] call ace_interaction_fnc_joinTeam;
(player) setVariable ["Waldo_PlayerInit_Team", 'GREEN'];
case ((_roleDesc find "ALPHA") > -1 || (_roleDesc find "RED") > -1): {
[player, "RED"] call ace_interaction_fnc_joinTeam;
};
case "MEDIC": {
[player, "GREEN"] call ace_interaction_fnc_joinTeam;
(player) setVariable ["Waldo_PlayerInit_Team", 'GREEN'];
case ((_roleDesc find "BRAVO") > -1 || (_roleDesc find "BLUE") > -1): {
[player, "BLUE"] call ace_interaction_fnc_joinTeam;
};
case "COMBAT": {
case ((_roleDesc find "CHARLIE") > -1 || (_roleDesc find "GREEN") > -1): {
[player, "GREEN"] call ace_interaction_fnc_joinTeam;
(player) setVariable ["Waldo_PlayerInit_Team", 'GREEN'];
};
case "DELTA": {
[player, "YELLOW"] call ace_interaction_fnc_joinTeam;
(player) setVariable ["Waldo_PlayerInit_Team", 'YELLOW'];
};
case "YELLOW": {
[player, "YELLOW"] call ace_interaction_fnc_joinTeam;
(player) setVariable ["Waldo_PlayerInit_Team", 'YELLOW'];
};
case "SQUAD": {
case ((_roleDesc find "DELTA") > -1 || (_roleDesc find "YELLOW") > -1): {
[player, "YELLOW"] call ace_interaction_fnc_joinTeam;
(player) setVariable ["Waldo_PlayerInit_Team", 'YELLOW'];
};
default {
_getTeamName = 'WHITE';
(player) setVariable ["Waldo_PlayerInit_Team", 'WHITE'];
[player, "WHITE"] call ace_interaction_fnc_joinTeam;
};
};

0 comments on commit b50e9c5

Please sign in to comment.