Advertisement
MulleDK19

ARMA 3 - MTP_fnc_setFriendship

Mar 1st, 2014
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 KB | None | 0 0
  1. /*
  2.     Author: MulleDK19
  3.  
  4.     Description:
  5.     Sets the friendship between two sides. Works around the issue with units refusing to fire at units who they previously thought were friends, or stop firing at units that are now their friends.
  6.  
  7.     Parameter(s):
  8.         0: SIDE - the first side
  9.         1: SIDE - the other side
  10.         2: NUMBER - friendship value. 0.0 = enemy, 1.0 = friend.
  11.    
  12.     Returns:
  13.     NOTHING
  14. */
  15.  
  16. private ["_side1", "_side2", "_amount", "_unit", "_friends"];
  17. _side1 = [_this, 0, sideUnknown, [sideUnknown]] call BIS_fnc_param;
  18. _side2 = [_this, 1, sideUnknown, [sideUnknown]] call BIS_fnc_param;
  19. _amount = [_this, 2, -1, [0]] call BIS_fnc_param;
  20.  
  21. if (_side1 == sideUnknown) exitWith { ["Argument 0 is not a valid side."] call BIS_fnc_error; };
  22. if (_side2 == sideUnknown) exitWith { ["Argument 1 is not a valid side."] call BIS_fnc_error; };
  23. if (_amount < 0.0 || _amount > 1.0) exitWith { ["Argument 2 must be a number between 0 and 1."] call BIS_fnc_error; };
  24.  
  25. _friends = false;
  26. if (_amount >= 0.6) then
  27. {
  28.     _friends = true;
  29. };
  30.  
  31. // Set side friendship.
  32. _side1 setFriend [_side2, _amount];
  33. _side2 setFriend [_side1, _amount];
  34.  
  35. // Work-around for units not wanting to shoot.
  36. // Both decreasing/increasing rating and re-revealing units is crucial.
  37. {
  38.     _unit = _x;
  39.     if (side _unit == _side1 || side _unit == _side2) then
  40.     {
  41.         _unit addRating (if (!_friends) then { -1000000 } else { 1000000 });
  42.         {
  43.             if (side _x == _side1 || side _x == _side2) then
  44.             {
  45.                 // If this unit knows about the unit, re-reveal.
  46.                 if (_x knowsAbout _unit >= 1.5) then
  47.                 {
  48.                     _x reveal [_unit, _x knowsAbout _unit];
  49.                 };
  50.             };
  51.         } forEach allUnits;
  52.         _unit addRating (if (!_friends) then { 1000000 } else { -1000000 });
  53.     };
  54. } forEach allUnits;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement