forked from IDI-Systems/acre2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfnc_updateInfantryPhoneStatus.sqf
77 lines (67 loc) · 3.23 KB
/
fnc_updateInfantryPhoneStatus.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "script_component.hpp"
/*
* Author: ACRE2Team
* Updates the status of the infantry phone of a vehicle.
*
* Arguments:
* 0: Vehicle with intercom <OBJECT>
* 1: Unit using the infantry phone <OBJECT>
* 2: Type of action <NUMBER>
* 3: Intercom network <NUMBER>
* 4: Unit giving the infantry phone <OBJECT> (default: objNull)
* 5: Relative position of the infantry phone interaction on the vehicle <POSITION> (default: [0, 0, 0])
*
* Return Value:
* None
*
* Example:
* [cursorTarget, player, 1, 0] call acre_sys_intercom_fnc_updateInfantryPhoneStatus
* [cursorTarget, infantryUnit, 1, 0, player] call acre_sys_intercom_fnc_updateInfantryPhoneStatus
*
* Public: No
*/
params ["_vehicle", "_unit", "_action", "_intercomNetwork", ["_givingUnit", objNull, [objNull]], ["_position", [0, 0, 0]]];
private _intercomName = ((_vehicle getVariable [QGVAR(intercomNames), []]) select _intercomNetwork) select 1;
private _intercomText = format ["( %1 )", _intercomName];
switch (_action) do {
case 0: {
// Stop using the intercom externally
_vehicle setVariable [QGVAR(unitInfantryPhone), nil, true];
_unit setVariable [QGVAR(vehicleInfantryPhone), nil, true];
// Destroy connector rope
[QEGVAR(sys_core,handleConnectorRopeEvent), [false]] call CBA_fnc_localEvent;
ACRE_PLAYER_INTERCOM = [];
[[ICON_RADIO_CALL], [format [localize LSTRING(infantryPhoneDisconnected), _intercomText]], true] call CBA_fnc_notify;
[GVAR(intercomPFH)] call CBA_fnc_removePerFrameHandler;
};
case 1: {
// Start using the intercom externally
_vehicle setVariable [QGVAR(unitInfantryPhone), [_unit, _intercomNetwork], true];
_unit setVariable [QGVAR(vehicleInfantryPhone), [_vehicle, _intercomNetwork], true];
// Create connector rope
[QEGVAR(sys_core,handleConnectorRopeEvent), [true, 0, _vehicle, _unit, _position]] call CBA_fnc_localEvent;
[[ICON_RADIO_CALL], [format [localize LSTRING(infantryPhoneConnected), _intercomText]], true] call CBA_fnc_notify;
GVAR(intercomPFH) = [DFUNC(intercomPFH), 1.1, [acre_player, _vehicle]] call CBA_fnc_addPerFrameHandler;
};
case 2: {
// Give the intercom to another unit
_givingUnit setVariable [QGVAR(vehicleInfantryPhone), nil, true];
[GVAR(intercomPFH)] call CBA_fnc_removePerFrameHandler;
// Destroy connector rope
[QEGVAR(sys_core,handleConnectorRopeEvent), [false]] call CBA_fnc_localEvent;
private _message = format [localize LSTRING(infantryPhoneReceived), _intercomText];
[QGVAR(giveInfantryPhone), [_vehicle, _unit, 1, _message, _intercomNetwork, _position], _unit] call CBA_fnc_targetEvent;
};
case 3: {
_vehicle setVariable [QGVAR(unitInfantryPhone), [_unit, _intercomNetwork], true];
_unit setVariable [QGVAR(vehicleInfantryPhone), [_vehicle, _intercomNetwork], true];
};
};
// Hook for third party mods with actions when picking returning infantry phone
private _event = _vehicle getVariable [QGVAR(eventInfantryPhone), ""];
if (_event != "") then {
_event = missionNamespace getVariable [_event, {}];
if (_event isEqualType {} && (_event isNotEqualTo {})) then {
[_vehicle, _unit, _action] call _event;
};
};