Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core - Add PhysX Ropes as "connector wires" for Infantry-Phone/GSA/External #1290

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c12d85d
Rope handler
mrschick Sep 23, 2023
c88a534
Infantry phone uses rope
mrschick Sep 23, 2023
5be06e5
Overhauled handler
mrschick Sep 26, 2023
bfd7313
Fixed oversight from a variable renaming
mrschick Oct 2, 2023
efd0a70
Changed attach method for GSA rope
mrschick Oct 2, 2023
fb156ba
Break rope on GSA max distance disconnect
mrschick Oct 3, 2023
210f01b
Use ACE Refueling Hose as connector rope
mrschick Oct 4, 2023
d9860cb
Possible fix for rope blocking disconnect interaction
mrschick Oct 4, 2023
9c1a375
Add CBA Setting under sys_gestures
mrschick Oct 4, 2023
9f2c84a
Gave rope some slack at usual connection distances
mrschick Oct 7, 2023
cfe2085
Made hose->wire model thinner
mrschick Oct 7, 2023
47839cb
Find rope start position more efficiently
mrschick Nov 2, 2023
a3ad3a9
Prevent taking infantry phone that is being used
mrschick Nov 2, 2023
2db6cc0
Concentrate intercom wire handling in "updateInfantryPhoneStatus"
mrschick Nov 3, 2023
22c0c78
Use "PaperCar" as a helper object on both ends
mrschick Nov 3, 2023
12f106a
Hide all helper objects globally
mrschick Nov 3, 2023
73b0061
Cleaned up systemChat and Comment
mrschick Nov 12, 2023
cdfd44d
Custom Rope Helper Object
mrschick Nov 12, 2023
ef36edc
More local var use, reducing macro invocations
mrschick Nov 13, 2023
08290a4
Properly run hideObjectGlobal on Server
mrschick Jan 8, 2024
9be34ab
Use passed parameter instead of defaulting to player
mrschick Mar 14, 2024
c86bd4f
Delete rope via CBA Event if someone else picks up GSA
mrschick Mar 17, 2024
a1938f3
Hide Rope Helpers via CBA Server Events
mrschick Mar 17, 2024
0a23f66
Use CBA Events for all GSA Rope Handling
mrschick Mar 26, 2024
32bb482
Fix desync when adding/removing mast on GSA
mrschick Mar 28, 2024
87f6d84
Use CBA Events for Infantryphone Rope Handling
mrschick Apr 11, 2024
bd0877c
Shorten external radio rope to 1.2m
mrschick Apr 11, 2024
b2b266a
Fix implementation on external radios
mrschick Apr 11, 2024
9d8272d
Handle External Radio Rope on the user instead of the owner
mrschick Apr 23, 2024
4c2d984
Reword Translation
mrschick Jul 3, 2024
517de6e
Apply suggestions from code review
mrschick Aug 16, 2024
41daddd
Drop unused argument
mrschick Aug 28, 2024
9c89720
More appropriate init value
mrschick Aug 28, 2024
6926891
Remove External Radio Rope handling
mrschick Aug 28, 2024
5e10245
Use defined value instead of "constant" var
mrschick Aug 28, 2024
87b8ee8
Fix Intercom Passing
mrschick Aug 28, 2024
f2b3e0b
Prevent multiple rope creation, destroy previous
mrschick Aug 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions addons/sys_core/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class CfgNonAIVehicles {
class GVAR(connectorWireSegment) {
scope = 2;
displayName = "Connector Wire";
mrschick marked this conversation as resolved.
Show resolved Hide resolved
simulation = "ropesegment";
autocenter = 0;
animated = 0;
model = QPATHTOF(data\wire.p3d);
};
};

class CfgVehicles {
class Rope;
class GVAR(connectorWire): Rope {
segmentType = QGVAR(connectorWireSegment);
model = QPATHTOF(data\wire.p3d);
};

class Car;
class GVAR(connectorHelper): Car {
displayName = "Connector Rope Helper";
model = "core\default\default.p3d";
scope = 2;
};
};
1 change: 1 addition & 0 deletions addons/sys_core/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ PREP(getLanguageName);
PREP(getPlayersInVehicle);
PREP(getSpeakingLanguageId);
PREP(getSpokenLanguages);
PREP(handleConnectorRope);
PREP(handleGetClientID);
PREP(handleGetHeadVector);
PREP(handleGetPluginVersion);
Expand Down
14 changes: 14 additions & 0 deletions addons/sys_core/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ PREP_RECOMPILE_END;
// CBA Settings
#include "initSettings.inc.sqf"

if (isServer) then {
[QGVAR(hideConnectorRopeHelpers), {
params ["_ropeHelpers"];
{ hideObjectGlobal _x; } forEach _ropeHelpers;
}] call CBA_fnc_addEventHandler;
};

[QGVAR(handleConnectorRopeEvent), {
_this call FUNC(handleConnectorRope);
}] call CBA_fnc_addEventHandler;
mrschick marked this conversation as resolved.
Show resolved Hide resolved

if (!hasInterface) exitWith {
ADDON = true;
};
Expand Down Expand Up @@ -46,6 +57,9 @@ DGVAR(pttKeyDown) = false;

DGVAR(speaking_cache_valid) = false;

DGVAR(connectorRope) = objNull;
DGVAR(connectorRopeHelpers) = [];

DVAR(ACRE_SPIT_VERSION) = false;
DVAR(ACRE_IS_SYNCING) = false;
DVAR(ACRE_SPECTATORS_LIST) = [];
Expand Down
1 change: 1 addition & 0 deletions addons/sys_core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CfgPatches {
};
#include "CfgEventHandlers.hpp"
#include "CfgSounds.hpp"
#include "CfgVehicles.hpp"

class CfgAcreWorlds {

Expand Down
7 changes: 7 additions & 0 deletions addons/sys_core/data/wire.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CfgModels {
class wire {
sectionsInherit = "";
sections[] = {"rope"};
skeletonName = "";
};
};
mrschick marked this conversation as resolved.
Show resolved Hide resolved
Binary file added addons/sys_core/data/wire.p3d
Binary file not shown.
94 changes: 94 additions & 0 deletions addons/sys_core/fnc_handleConnectorRope.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include "script_component.hpp"
/*
* Author: mrschick
* Handles PhysX Ropes to represent "connector wires" for infantry phone, GSA, radio sharing, etc.
*
* Arguments:
* 0: State: true to create rope, false to remove <BOOLEAN>
* 1: Type of object to connect to: 0 = Infantry Phone, 1 = GSA, 2 = Shared radio <NUMBER> (default: 0)
* 2: Vehicle or object the rope starts from <OBJECT> (default: objNull)
* 3: Unit the rope should be attached to <OBJECT> (default: objNull)
* 4: Relative position offset for where the rope starts from <POSITION> (default: [0,0,0])
*
* Return Value:
* None
*
* Example:
* [true, _vehicle, _player, _infantryPhonePosition] call acre_sys_intercom_fnc_handleConnectorRope
* [false] call acre_sys_intercom_fnc_handleConnectorRope
*
* Public: No
*/

params ["_state", ["_type", 0], ["_fromObject", objNull], ["_toObject", objNull], ["_fromPoint", [0, 0, 0]]];

if (!EGVAR(sys_gestures,showConnectorRopes)) exitWith {};

private _helper = QGVAR(connectorHelper);

if (_state) then {
private _connectorRopeHelpers = [];
private _connectorRope = "";

switch (_type) do {
case 0: { // Connect rope to Infantry Phone
// Create Rope
_connectorRope = ropeCreate [_fromObject, _fromPoint, 3, nil, nil, QGVAR(connectorWire)];

// Create helper object on player pelvis
_connectorRopeHelpers set [0, _helper createVehicle position _toObject];
[_connectorRopeHelpers select 0, [0, 0, 0]] ropeAttachTo _connectorRope;
(_connectorRopeHelpers select 0) attachTo [_toObject, [-0.1, 0.1, 0.25], "Pelvis"];
(_connectorRopeHelpers select 0) allowDamage false;

// Hide Helper Object
[QGVAR(hideConnectorRopeHelpers), [_connectorRopeHelpers]] call CBA_fnc_serverEvent;
};
case 1: { // Connect rope to Ground Spike Antenna
// Create helper object on GSA
_connectorRopeHelpers set [0, _helper createVehicle position _fromObject];
(_connectorRopeHelpers select 0) disableCollisionWith _fromObject;
(_connectorRopeHelpers select 0) setPos (position _fromObject);
(_connectorRopeHelpers select 0) allowDamage false;

// Create helper object on player pelvis
_connectorRopeHelpers set [1, _helper createVehicle position _toObject];
(_connectorRopeHelpers select 1) attachTo [_toObject, [-0.1, 0.1, 0.15], "Pelvis"];
(_connectorRopeHelpers select 1) allowDamage false;

// Hide Helper Objects
[QGVAR(hideConnectorRopeHelpers), [_connectorRopeHelpers]] call CBA_fnc_serverEvent;

// Create Rope between helper objects
_connectorRope = ropeCreate [_connectorRopeHelpers select 0, _fromPoint, 5, nil, nil, QGVAR(connectorWire)];
[(_connectorRopeHelpers select 1), [0, 0, 0]] ropeAttachTo _connectorRope;
};
case 2: { // Connect rope to shared backpack radio owner
// Create helper object on radio owner
_connectorRopeHelpers set [0, _helper createVehicle position _fromObject];
(_connectorRopeHelpers select 0) attachTo [_fromObject, [-0.1, 0.1, 0.15], "Pelvis"];
(_connectorRopeHelpers select 0) allowDamage false;

// Create helper object on player pelvis
_connectorRopeHelpers set [1, _helper createVehicle position _toObject];
(_connectorRopeHelpers select 1) attachTo [_toObject, [-0.1, 0.1, 0.15], "Pelvis"];
(_connectorRopeHelpers select 1) allowDamage false;

// Hide Helper Objects
[QGVAR(hideConnectorRopeHelpers), [_connectorRopeHelpers]] call CBA_fnc_serverEvent;

// Create Rope between helper objects
_connectorRope = ropeCreate [_connectorRopeHelpers select 0, _fromPoint, 1.2, nil, nil, QGVAR(connectorWire)];
[_connectorRopeHelpers select 1, [0, 0, 0]] ropeAttachTo _connectorRope;
};
};

GVAR(connectorRope) = _connectorRope;
GVAR(connectorRopeHelpers) = _connectorRopeHelpers;
} else {
// Destroy rope
ropeDestroy GVAR(connectorRope);
GVAR(connectorRope) = objNull;
{ deleteVehicle _x } forEach GVAR(connectorRopeHelpers);
GVAR(connectorRopeHelpers) = [objNull, objNull];
};
3 changes: 3 additions & 0 deletions addons/sys_external/fnc_startUsingExternalRadio.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ ACRE_ACTIVE_EXTERNAL_RADIOS pushBackUnique _radioId;
// Set it as active radio.
[_radioId] call EFUNC(api,setCurrentRadio);

// Visualize the connection with a connector rope
[QEGVAR(sys_core,handleConnectorRopeEvent), [true, 2, _owner, _endUser]] call CBA_fnc_localEvent;

[[ICON_RADIO_CALL], [format [localize LSTRING(hintTake), _displayName, name _owner]], true] call CBA_fnc_notify;
3 changes: 3 additions & 0 deletions addons/sys_external/fnc_stopUsingExternalRadio.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ private _baseRadio = [_radioId] call EFUNC(api,getBaseRadio);
private _displayName = getText (ConfigFile >> "CfgWeapons" >> _baseRadio >> "displayName");
[[ICON_RADIO_CALL], [format [localize LSTRING(hintReturn), _displayName, name _owner]], true] call CBA_fnc_notify;

// Destroy Rope
[QEGVAR(sys_core,handleConnectorRopeEvent), [false]] call CBA_fnc_localEvent;

if (_target == _owner) then {
// Handle remote owner
private _message = format [localize LSTRING(hintReturnOwner), name ([_radioId] call FUNC(getExternalRadioUser)), _displayName];
Expand Down
11 changes: 11 additions & 0 deletions addons/sys_gestures/initSettings.inc.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@
{},
true
] call CBA_fnc_addSetting;

[
QGVAR(showConnectorRopes),
"CHECKBOX",
[LLSTRING(showConnectorRopes), LLSTRING(showConnectorRopes_description)],
LLSTRING(category),
true,
true,
{},
true
] call CBA_fnc_addSetting;
10 changes: 10 additions & 0 deletions addons/sys_gestures/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,15 @@
<Turkish>Telsiz kullanırken nişan almayı engeller</Turkish>
<Portuguese>Usar rádios irá impedir a mira</Portuguese>
</Key>
<Key ID="STR_ACRE_sys_gestures_showConnectorRopes">
<English>Show connector wires</English>
mrschick marked this conversation as resolved.
Show resolved Hide resolved
<German>Zeige verbindungskabel</German>
<Italian>Mostra cavi di collegamento</Italian>
</Key>
<Key ID="STR_ACRE_sys_gestures_showConnectorRopes_description">
<English>Connections to infantry phones, GSAs and shared radios will be visualized with connector wires.</English>
<German>Verbindungen zu Gegensprechanlage, BBA und Geteilten Funkgeräten werden mit Kabeln visualisiert.</German>
<Italian>Connessioni a telefoni di fanteria, antenne a pavimento e radio condivise verranno visualizzate con cavi.</Italian>
</Key>
</Package>
</Project>
1 change: 1 addition & 0 deletions addons/sys_gsa/fnc_connectServer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ _gsa setVariable [QGVAR(connectedRadio), _radioId, true];
[_radioId, "setState", ["externalAntennaConnected", [true, _gsa]]] call EFUNC(sys_data,dataEvent);

[QGVAR(notifyPlayer), [localize LSTRING(connected)], _player] call CBA_fnc_targetEvent;
[QEGVAR(sys_core,handleConnectorRopeEvent), [true, 1, _gsa, _player], _player] call CBA_fnc_targetEvent;

// Support for having several radios connected to GSA
private _pfh = [DFUNC(externalAntennaPFH), 1.0, [_gsa, _radioId]] call CBA_fnc_addPerFrameHandler;
Expand Down
3 changes: 3 additions & 0 deletions addons/sys_gsa/fnc_disconnectServer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ private _parentComponentClass = configFile >> "CfgAcreComponents" >> BASE_CLASS_
if (_connectedUnit isKindOf "CAManBase" || {crew _connectedUnit isNotEqualTo []}) then {
if (_connectedUnit isKindOf "CAManBase") then {
[QGVAR(notifyPlayer), [localize LSTRING(disconnected)], _connectedUnit] call CBA_fnc_targetEvent;
[QEGVAR(sys_core,handleConnectorRopeEvent), [false], _connectedUnit] call CBA_fnc_targetEvent;
} else {
{
[QGVAR(notifyPlayer), [localize LSTRING(disconnected)], _connectedUnit] call CBA_fnc_targetEvent;
[QEGVAR(sys_core,handleConnectorRopeEvent), [false], _connectedUnit] call CBA_fnc_targetEvent;
} forEach (crew _connectedUnit);
};
};
Expand All @@ -71,6 +73,7 @@ private _parentComponentClass = configFile >> "CfgAcreComponents" >> BASE_CLASS_
// The unit that disconnected the antenna is different from the unit that was connected to it
private _text = format [localize LSTRING(disconnectedUnit), name _connectedUnit];
[QGVAR(notifyPlayer), [_text], _unit] call CBA_fnc_targetEvent;
[QEGVAR(sys_core,handleConnectorRopeEvent), [false], _unit] call CBA_fnc_targetEvent;
};
};
};
Expand Down
1 change: 1 addition & 0 deletions addons/sys_gsa/fnc_externalAntennaPFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ if (
|| {(_unit distance _gsa) > ANTENNA_MAXDISTANCE}
) then {
[QGVAR(disconnectGsa), [_gsa, _unit, _radioId]] call CBA_fnc_localEvent;
[QEGVAR(sys_core,handleConnectorRopeEvent), [false]] call CBA_fnc_localEvent;
};
6 changes: 4 additions & 2 deletions addons/sys_gsa/fnc_handleMast.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ if (_connectedRadio isEqualTo "") then {
_connectedRadio = _gsa getVariable [QGVAR(connectedRadio), ""];
};

private _connectedPlayer = [_connectedRadio] call EFUNC(sys_radio,getRadioObject);

// Temporarily disconnect the GSA from the radio
if (_connectedRadio != "") then {
[_player, _gsa] call FUNC(disconnect);
[_connectedPlayer, _gsa] call FUNC(disconnect);
};

// Delete the antenna
Expand All @@ -43,5 +45,5 @@ if (_mountMast) then {

// Reconnect the GSA to the radio
if (_connectedRadio != "") then {
[_gsa, _connectedRadio] call FUNC(connect);
[QGVAR(connectGsa), [_gsa, _connectedRadio, _connectedPlayer]] call CBA_fnc_serverEvent;
};
4 changes: 2 additions & 2 deletions addons/sys_intercom/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ if (!hasInterface) exitWith {};
}, true] call CBA_fnc_addPlayerEventHandler;

[QGVAR(giveInfantryPhone), {
params ["_vehicle", "_unit", "_action", "_message", ["_intercomNetwork", INTERCOM_DISCONNECTED]];
params ["_vehicle", "_unit", "_action", "_message", ["_intercomNetwork", INTERCOM_DISCONNECTED], ["_position", objNull]];
[[ICON_RADIO_CALL], [_message]] call CBA_fnc_notify;
[_vehicle, _unit, _action, _intercomNetwork] call FUNC(updateInfantryPhoneStatus);
[_vehicle, _unit, _action, _intercomNetwork, objNull, _position] call FUNC(updateInfantryPhoneStatus);
}] call CBA_fnc_addEventHandler;

#ifdef DRAW_INFANTRYPHONE_INFO
Expand Down
27 changes: 20 additions & 7 deletions addons/sys_intercom/fnc_infantryPhoneChildrenActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
* Public: No
*/

params ["_target"];
params ["_target", "_unit", "_position"];

private _actions = [];

(acre_player getVariable [QGVAR(vehicleInfantryPhone), [objNull, INTERCOM_DISCONNECTED]]) params ["_vehicleInfantryPhone", "_infantryPhoneNetwork"];
(_target getVariable [QGVAR(unitInfantryPhone), [objNull, INTERCOM_DISCONNECTED]]) params ["_unitInfantryPhone", "_unitInfantryPhoneNetwork"];

private _intercomNames = _target getVariable [QGVAR(intercomNames), []];

Expand All @@ -36,7 +37,7 @@ if (_target isKindOf "CAManBase") then {
_params params ["_intercomNetwork"];

//USES_VARIABLES ["_target", "_player"];
[_player getVariable [QGVAR(vehicleInfantryPhone), [objNull, INTERCOM_DISCONNECTED]] select 0, _target, 2, _intercomNetwork, _player] call FUNC(updateInfantryPhoneStatus)
[_player getVariable [QGVAR(vehicleInfantryPhone), [objNull, INTERCOM_DISCONNECTED]] select 0, _target, 2, _intercomNetwork, _player, _position] call FUNC(updateInfantryPhoneStatus)
},
{true},
{},
Expand All @@ -47,16 +48,16 @@ if (_target isKindOf "CAManBase") then {
} else {
if (vehicle acre_player != _target) then {
// Pointing at a vehicle. Get or return the infantry telephone
if (isNull _vehicleInfantryPhone) then {
if (isNull _vehicleInfantryPhone && (isNull _unitInfantryPhone)) then {
{
private _action = [
format [QGVAR(takeInfantryPhone_%1), _x],
format [localize LSTRING(takeInfantryPhone), format ["(%1)", (_intercomNames select _forEachIndex) select 2]],
"",
{
params ["_target", "_player", "_params"];
_params params ["_intercomNetwork"];
[_target, _player, 1, _intercomNetwork] call FUNC(updateInfantryPhoneStatus)
_params params ["_intercomNetwork", "_position"];
[_target, _player, 1, _intercomNetwork, objNull, _position] call FUNC(updateInfantryPhoneStatus);
},
{
params ["_target", "_player", "_params"];
Expand All @@ -65,7 +66,7 @@ if (_target isKindOf "CAManBase") then {
!(_isCalling select 0) || ((_isCalling select 0) && ((_isCalling select 1) == _intercomNetwork))
},
{},
_forEachIndex
[_forEachIndex, _position]
] call ace_interact_menu_fnc_createAction;
_actions pushBack [_action, [], _target];
} forEach (_intercomNames select {_x in (_target getVariable [QGVAR(infantryPhoneIntercom), []])});
Expand All @@ -79,7 +80,7 @@ if (_target isKindOf "CAManBase") then {
{
params ["_target", "_player", ""];
//USES_VARIABLES ["_target", "_player"];
[_target, _player, 0, INTERCOM_DISCONNECTED] call FUNC(updateInfantryPhoneStatus)
[_target, _player, 0, INTERCOM_DISCONNECTED] call FUNC(updateInfantryPhoneStatus);
},
{true},
{},
Expand Down Expand Up @@ -111,6 +112,18 @@ if (_target isKindOf "CAManBase") then {
] call ace_interact_menu_fnc_createAction;
_actions pushBack [_action, [], _target];
} forEach (_intercomNames select {_x in (_target getVariable [QGVAR(infantryPhoneIntercom), []])});
} else {
// Generate empty action to show that the infantry phone is being used by someone else
private _action = [
QGVAR(infantryPhoneUnavailable),
format [localize LSTRING(infantryPhoneUnavailable)],
"",
{true},
{true},
{},
{}
] call ace_interact_menu_fnc_createAction;
_actions pushBack [_action, [], _target];
};
};
} else {
Expand Down
Loading