Here's a FriendOrFoe function. See attached sample mission.
The function handles the fact that we have 4 unit sides (east, west, guerrila, civilian), and the fact that civilian/guerilla units are either friend or foe to others based on the Mission Designer picking one of the following:
- Guerillas friendly to west (i.e., RACS friendly to BLUFOR)
- Guerillas friendly to east (i.e., RACS friendly to OPFOR)
- Guerillas friendly to nobody (i.e., RACS friendly to Nobody)
- Guerillas friendly to all (i.e., RACS friendly to All sides)
Since I don't know of an ARMA function that will tell me which option the Mission Designer chose, we will have to pass in a variable indicating the chosen option. (Please tell me if there is a way to look this up!).
A sample mission is attached that allows you test all combinations of unit sides and "guerilla friendly to ..." combinations.
Note: This function has NOT been tested on vehicles yet.
And Here's the function code:
// *****************************************************
// ** friendOrFoe.sqf
// **
// ** Returns "Friend" or "Foe" for relationship of unit A to unit B.
// **
// ** Example call: _fof = [unitA, unitB, guerillaStatus] call friendOrFoe;
// **
// ** guerillaStatus must be one of four values depending on who guerillas (aka Independent, aka Resistance)
// ** are defined as friendly to in mission editor:
// **
// ** "GFE" - Guerillas friendly to East
// ** "GFW" - Guerillas friendly to West
// ** "GFN" - Guerillas friendly to Nobody
// ** "GFA" - Guerillas friendly to All Sides (everybody)
// **
// ** Note that Civs are always friendly with Guerillas, and are treated same as Guerillas
// ** when compared to East or West.
// *****************************************************
_unitA = _this select 0;
_unitB = _this select 1;
_guerillaStatus = _this select 2;
_sideA = side _unitA;
_sideB = side _unitB;
_friendOrFoe = "";
//player sidechat format ["_sideA is %1, _sideB is %2",_sideA, _sideB];
// For guerilla or civ units, set side variables to East or West depending on
// _guerillaStatus input.
if ((_sideA == resistance or _sideA == civilian) and _guerillaStatus == "GFE") then
{
_sideA = EAST;
};
if ((_sideA == resistance or _sideA == civilian) and _guerillaStatus == "GFW") then
{
_sideA = WEST;
};
if ((_sideB == resistance or _sideB == civilian) and _guerillaStatus == "GFE") then
{
_sideB = EAST;
};
if ((_sideB == resistance or _sideB == civilian) and _guerillaStatus == "GFW") then
{
_sideB = WEST;
};
// If units on same side, or units a combination of civilian and resistance, then return Friend.
if ((_sideA == _sideB) or (_sideA == civilian and _sideB == resistance) or (_sideA == resistance and _sideB == civilian)) then
{
_friendOrFoe = "Friend";
}
else
{
// If Guerilla Friendly to ALL, and either unit is a civilian or resistance, then return Friend.
if (_guerillaStatus == "GFA" and (_sideA == civilian or _sideA == resistance or _sideB == civilian or _sideB == resistance)) then
{
_friendOrFoe = "Friend";
}
else
{
// ELSE, return Foe.
_friendOrFoe = "Foe";
};
};
_friendOrFoe