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

Add EH for UAV control, Add Hellfire support #5305

Merged
merged 5 commits into from
Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
43 changes: 43 additions & 0 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,49 @@ GVAR(OldIsCamera) = false;
END_COUNTER(stateChecker);
}, 0.5, []] call CBA_fnc_addPerFrameHandler;

// Add event handler for UAV control change
ACE_controlledUAV = [objnull, objnull, [], ""];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Camel case in objNull.

addMissionEventHandler ["PlayerViewChanged", {
// On non-server client this command is semi-broken
// arg index 5 should be the controlled UAV, but it will often be objNull (delay from locality switching?)
// On PlayerViewChanged event, start polling for new uav state for a few seconds (should be done within a few frames)

params ["", "", "", "", "_newCameraOn", "_UAV"];
TRACE_2("PlayerViewChanged",_newCameraOn,_UAV);

[{
if (isNull player) exitWith {true};
private _UAV = getConnectedUAV player;
if (!alive player) then {_UAV = objNull;};
private _position = (UAVControl _UAV) param [1, ""];
private _seatAI = objnull;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

private _turret = [];
switch (toLower _position) do {
case (""): {
_UAV = objNull; // set to objNull if not actively controlling
};
case ("driver"): {
_turret = [-1];
_seatAI = driver _UAV;
};
case ("gunner"): {
_turret = [0];
_seatAI = gunner _UAV;
};
};

private _newArray = [_UAV, _seatAI, _turret, _position];
if (_newArray isEqualTo ACE_controlledUAV) exitWith {false}; // no change yet

TRACE_2("Seat Change",_newArray,ACE_controlledUAV);
ACE_controlledUAV = _newArray;
["ACE_controlledUAV", _newArray] call CBA_fnc_localEvent;

// stay in the loop as we might switch from gunner -> driver, and there may be a empty position event in-between
false
}, {}, [], 3, {TRACE_1("timeout",_this);}] call CBA_fnc_waitUntilAndExecute;
}];


//////////////////////////////////////////////////
// Eventhandlers for player controlled machines
Expand Down
9 changes: 9 additions & 0 deletions addons/hellfire/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@ GVAR(pfID) = -1;
["ace_settingsInitialized", {
["turret", LINKFUNC(showHud), false] call CBA_fnc_addPlayerEventHandler;
["vehicle", LINKFUNC(showHud), true] call CBA_fnc_addPlayerEventHandler; // only one of these needs the retro flag

// Add UAV Control Compatibility
["ACE_controlledUAV", {
params ["_UAV", "_seatAI", "_turret", "_position"];
TRACE_4("ACE_controlledUAV EH",_UAV,_seatAI,_turret,_position);
if (!isNull _seatAI) then {
[_seatAI] call FUNC(showHud);
};
}] call CBA_fnc_addEventHandler;
}] call CBA_fnc_addEventHandler;
16 changes: 11 additions & 5 deletions addons/laser/functions/fnc_keyLaserCodeChange.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ if ((!alive ACE_player) || {!([ACE_player, vehicle ACE_player, []] call EFUNC(co
private _currentShooter = objNull;
private _currentWeapon = "";

if (ACE_player call CBA_fnc_canUseWeapon) then {
_currentShooter = ACE_player;
_currentWeapon = currentWeapon ACE_player;
if (isNull (ACE_controlledUAV param [0, objNull])) then {
if (ACE_player call CBA_fnc_canUseWeapon) then {
_currentShooter = ACE_player;
_currentWeapon = currentWeapon ACE_player;
} else {
_currentShooter = vehicle ACE_player;
private _turretPath = if (ACE_player == (driver _currentShooter)) then {[-1]} else {ACE_player call CBA_fnc_turretPath};
_currentWeapon = _currentShooter currentWeaponTurret _turretPath;
};
} else {
_currentShooter = vehicle ACE_player;
private _turretPath = if (ACE_player == (driver _currentShooter)) then {[-1]} else {ACE_player call CBA_fnc_turretPath};
_currentShooter = ACE_controlledUAV select 0;
private _turretPath = ACE_controlledUAV select 2;
_currentWeapon = _currentShooter currentWeaponTurret _turretPath;
};

Expand Down
17 changes: 12 additions & 5 deletions addons/missileguidance/functions/fnc_cycleAttackProfileKeyDown.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ if (!([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith))


private ["_currentShooter", "_currentMagazine"];
if (((vehicle ACE_player) == ACE_player) || {ACE_player call CBA_fnc_canUseWeapon}) then {
_currentShooter = ACE_player;
_currentMagazine = currentMagazine ACE_player;
if (isNull (ACE_controlledUAV param [0, objNull])) then {
if (((vehicle ACE_player) == ACE_player) || {ACE_player call CBA_fnc_canUseWeapon}) then {
_currentShooter = ACE_player;
_currentMagazine = currentMagazine ACE_player;
} else {
_currentShooter = vehicle ACE_player;
private _turretPath = if (ACE_player == (driver _currentShooter)) then {[-1]} else {ACE_player call CBA_fnc_turretPath};
_currentMagazine = _currentShooter currentMagazineTurret _turretPath;
};
} else {
_currentShooter = vehicle ACE_player;
private _turretPath = if (ACE_player == (driver _currentShooter)) then {[-1]} else {ACE_player call CBA_fnc_turretPath};
_currentShooter = ACE_controlledUAV select 0;
private _turretPath = ACE_controlledUAV select 2;
_currentMagazine = _currentShooter currentMagazineTurret _turretPath;
};

if (_currentMagazine == "") exitWith {TRACE_1("no magazine",_currentMagazine)};

private _ammo = getText (configFile >> "CfgMagazines" >> _currentMagazine >> "ammo");
Expand Down