Home   Help Search Login Register  

Author Topic: Friend or foe  (Read 3701 times)

0 Members and 1 Guest are viewing this topic.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Friend or foe
« Reply #15 on: 21 Jun 2007, 19:52:03 »
who destroys em ? i had a prob w/ mision not endin cuz my gunner dont wanna destroy dese tanks  ::)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Friend or foe
« Reply #16 on: 21 Jun 2007, 20:57:41 »
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

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Friend or foe
« Reply #17 on: 22 Jun 2007, 01:30:45 »
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:
 
Code: [Select]
// *****************************************************
// ** 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
« Last Edit: 22 Jun 2007, 01:32:44 by johnnyboy »
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Friend or foe
« Reply #18 on: 22 Jun 2007, 01:39:30 »
hehe you are cheating having guerillaStatus as a parameter of the script. ;)

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Friend or foe
« Reply #19 on: 22 Jun 2007, 01:44:00 »
Quote
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.
« Last Edit: 22 Jun 2007, 01:46:56 by johnnyboy »
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Cheetah

  • Former Staff
  • ****
Re: Friend or foe
« Reply #20 on: 22 Jun 2007, 02:10:49 »
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.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Friend or foe
« Reply #21 on: 22 Jun 2007, 02:15:10 »
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 command

LCD OUT

« Last Edit: 22 Jun 2007, 15:32:15 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta