Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: MulleDK19
- Description:
- 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.
- Parameter(s):
- 0: SIDE - the first side
- 1: SIDE - the other side
- 2: NUMBER - friendship value. 0.0 = enemy, 1.0 = friend.
- Returns:
- NOTHING
- */
- private ["_side1", "_side2", "_amount", "_unit", "_friends"];
- _side1 = [_this, 0, sideUnknown, [sideUnknown]] call BIS_fnc_param;
- _side2 = [_this, 1, sideUnknown, [sideUnknown]] call BIS_fnc_param;
- _amount = [_this, 2, -1, [0]] call BIS_fnc_param;
- if (_side1 == sideUnknown) exitWith { ["Argument 0 is not a valid side."] call BIS_fnc_error; };
- if (_side2 == sideUnknown) exitWith { ["Argument 1 is not a valid side."] call BIS_fnc_error; };
- if (_amount < 0.0 || _amount > 1.0) exitWith { ["Argument 2 must be a number between 0 and 1."] call BIS_fnc_error; };
- _friends = false;
- if (_amount >= 0.6) then
- {
- _friends = true;
- };
- // Set side friendship.
- _side1 setFriend [_side2, _amount];
- _side2 setFriend [_side1, _amount];
- // Work-around for units not wanting to shoot.
- // Both decreasing/increasing rating and re-revealing units is crucial.
- {
- _unit = _x;
- if (side _unit == _side1 || side _unit == _side2) then
- {
- _unit addRating (if (!_friends) then { -1000000 } else { 1000000 });
- {
- if (side _x == _side1 || side _x == _side2) then
- {
- // If this unit knows about the unit, re-reveal.
- if (_x knowsAbout _unit >= 1.5) then
- {
- _x reveal [_unit, _x knowsAbout _unit];
- };
- };
- } forEach allUnits;
- _unit addRating (if (!_friends) then { 1000000 } else { -1000000 });
- };
- } forEach allUnits;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement