OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Mandoble on 21 Jun 2007, 00:11:23
-
That is the question.
Is unit A friend or foe of unit B?
How to know?
-
u cud use countEnemy
unitA countEnemy [unitB] > 0
even tho i think deres a better way ???
LCD OUT
-
LOL Yep, I'm waiting for that suposed "better way". But it seems to not be so obvious.
-
deres da enemy command as in
unitA enemy (SIDE unitB)
now dat returns a true or false... works 4 whole side not 4 a unit tho
i hope i got dat 1 right... enemy command is not explained good
LCD OUT
-
Seems "enemy" is just the side of renegade units, these that kill any friendly becomes renegade (enemy side).
-
The friendly (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=f#friendly) command has almost the same description but I don't know how one could use it to determine if a unit is friend or foe.
There are numerous alternatives for this but as far as I know there is no single command which can do the job right now. Might be good to create a function for this.
-
u cud also use da findNearestEnemy...
unitA findNearestEnemy (getpos unitB)
shud return unitB if it is
but dats probably not wat ur lookin 4 also
btw in da COMREF it says dat sideEnemy is used 4 renegades... but it doesnt say dat on da Enemy command
LCD OUT
-
"enemy" seems to be the same, that is a side for enemies to all sides (renegades).
-
Hmm.
KnowsAbout (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=h#knowsAbout) ?
I don't know if this is any use. ???
-
mmmm nope, knowsabout tells you how much do you "know" a unit, but it is worthless to determine if friend or foe.
-
If the units A and B are on the same side, how about checking unit A's rating?
According to Biki:
Each hit in a single player game will affect the player's rating. If it goes below -2000, he will be considered an enemy, and be attacked by all units.
So you'd need to check if unit A's rating is below -2000, which happens like this (I think):
rating unit_A = -2000 : goto "enemy"
goto "friendly"
#enemy
Hint "Unit A is an enemy"
Exit
#friendly
Hint "Unit A is friendly"
Exit
Just a thought, not sure if it works.
-
Won't work. All units have a positive rating unless they attack their own side.
-
u cud use countEnemy
unitA countEnemy [unitB] > 0
even tho i think deres a better way Huh?
LCD OUT
Note that empty enemy vehicles return as friendly, a least in OFP. I don't know how the command behave in Arma.
-
And that is good, dont destroy what you may steal later :D
-
Yes, but why do they destroy the vehicle when the crew disembarks? What is the real threat here? The empty vehicle or the crew that's firing upon you?
-
who destroys em ? i had a prob w/ mision not endin cuz my gunner dont wanna destroy dese tanks ::)
LCD OUT
-
Well, once they have a target, they will keep firing at it until the target cannot fire back, and that is also the reason LCD gunner dont want to kill some enemy tanks, because they cannot fire (gun damaged or destroyed).
BACK ON TOPIC: FRIEND OR FOE? :P
-
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
-
hehe you are cheating having guerillaStatus as a parameter of the script. ;)
-
hehe you are cheating having guerillaStatus as a parameter of the script
As Dirty Harry once said: "A man's got to know his limitations..." :)
But its a reasonable solution, since once chosen by Mission Designer, guerillaStatus cannot be changed during game run-time, therefore designer can use this function, and specify the correct guerillaStatus, and depend on it to work!
Edit: If anybody thinks this is useful enough, I'll submit it over at the Editing/Scripting Beta Testing forum. Let me know.
-
I suggest that you submit it, you never know if someone is going to need such a script in the future. Easier to find in the resource beta.
-
u can actually make a quick check inside da function 2 check who resistance is friendly 2... u can create a trigger and use da countenemy command :D
[edit] btw u actually can change resistances side (nd ny oder side) during gameplay... use da setFriend (http://community.bistudio.com/wiki/setFriend) command
LCD OUT