Add EH for UAV control, Add Hellfire support (#5305)

* Add EH for UAV control, Add Hellfire support

* cycle guidance keybind

* Handle broken PlayerViewChanged

* humps

* UAV Self-interactions (#5379)

* Switch ACE_Player to uav AI on valid seat change

* Different approach to UAV interactions

* Forgot to remove a variable

* Changed param to select
This commit is contained in:
PabstMirror 2017-08-22 16:07:45 -05:00 committed by GitHub
parent 43ac39f06c
commit 74fd0f507f
7 changed files with 105 additions and 24 deletions

View File

@ -317,6 +317,49 @@ GVAR(OldIsCamera) = false;
END_COUNTER(stateChecker); END_COUNTER(stateChecker);
}, 0.5, []] call CBA_fnc_addPerFrameHandler; }, 0.5, []] call CBA_fnc_addPerFrameHandler;
// Add event handler for UAV control change
ACE_controlledUAV = [objNull, 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;
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 // Eventhandlers for player controlled machines
@ -355,7 +398,9 @@ GVAR(OldIsCamera) = false;
// Players can always interact with his vehicle // Players can always interact with his vehicle
{vehicle _unit == _target} || {vehicle _unit == _target} ||
// Players can always interact with passengers of the same vehicle // Players can always interact with passengers of the same vehicle
{_unit != _target && {vehicle _unit == vehicle _target}} {_unit != _target && {vehicle _unit == vehicle _target}} ||
// Players can always interact with connected UAV
{!(isNull (ACE_controlledUAV select 0))}
}] call FUNC(addCanInteractWithCondition); }] call FUNC(addCanInteractWithCondition);
["isNotInZeus", {isNull curatorCamera}] call FUNC(addCanInteractWithCondition); ["isNotInZeus", {isNull curatorCamera}] call FUNC(addCanInteractWithCondition);

View File

@ -7,4 +7,13 @@ GVAR(pfID) = -1;
["ace_settingsInitialized", { ["ace_settingsInitialized", {
["turret", LINKFUNC(showHud), false] call CBA_fnc_addPlayerEventHandler; ["turret", LINKFUNC(showHud), false] call CBA_fnc_addPlayerEventHandler;
["vehicle", LINKFUNC(showHud), true] call CBA_fnc_addPlayerEventHandler; // only one of these needs the retro flag ["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; }] call CBA_fnc_addEventHandler;

View File

@ -41,6 +41,7 @@ GVAR(lastTimeSearchedActions) = -1000;
GVAR(ParsedTextCached) = []; GVAR(ParsedTextCached) = [];
GVAR(useCursorMenu) = (vehicle ACE_player != ACE_player) || GVAR(useCursorMenu) = (vehicle ACE_player != ACE_player) ||
(!(isNull (ACE_controlledUAV select 0))) ||
visibleMap || visibleMap ||
(!isNull curatorCamera) || (!isNull curatorCamera) ||
{(_menuType == 1) && {(isWeaponDeployed ACE_player) || GVAR(AlwaysUseCursorSelfInteraction) || {cameraView == "GUNNER"}}} || {(_menuType == 1) && {(isWeaponDeployed ACE_player) || GVAR(AlwaysUseCursorSelfInteraction) || {cameraView == "GUNNER"}}} ||
@ -93,6 +94,13 @@ GVAR(selfMenuOffset) = (AGLtoASL (positionCameraToWorld [0, 0, 2])) vectorDiff (
//Auto expand the first level when self, mounted vehicle or zeus (skips the first animation as there is only one choice) //Auto expand the first level when self, mounted vehicle or zeus (skips the first animation as there is only one choice)
if (GVAR(openedMenuType) == 0) then { if (GVAR(openedMenuType) == 0) then {
if (isNull curatorCamera) then { if (isNull curatorCamera) then {
if (!(isNull (ACE_controlledUAV select 0))) then {
GVAR(menuDepthPath) = [["ACE_SelfActions", (ACE_controlledUAV select 0)]];
GVAR(expanded) = true;
GVAR(expandedTime) = diag_tickTime;
GVAR(lastPath) = +GVAR(menuDepthPath);
GVAR(startHoverTime) = -1000;
} else {
if (vehicle ACE_player != ACE_player) then { if (vehicle ACE_player != ACE_player) then {
GVAR(menuDepthPath) = [["ACE_SelfActions", (vehicle ACE_player)]]; GVAR(menuDepthPath) = [["ACE_SelfActions", (vehicle ACE_player)]];
GVAR(expanded) = true; GVAR(expanded) = true;
@ -100,6 +108,7 @@ if (GVAR(openedMenuType) == 0) then {
GVAR(lastPath) = +GVAR(menuDepthPath); GVAR(lastPath) = +GVAR(menuDepthPath);
GVAR(startHoverTime) = -1000; GVAR(startHoverTime) = -1000;
}; };
};
} else { } else {
GVAR(menuDepthPath) = [["ACE_ZeusActions", (getAssignedCuratorLogic player)]]; GVAR(menuDepthPath) = [["ACE_ZeusActions", (getAssignedCuratorLogic player)]];
GVAR(expanded) = true; GVAR(expanded) = true;

View File

@ -130,6 +130,10 @@ GVAR(collectedActionPoints) resize 0;
// Render nearby actions, unit self actions or vehicle self actions as appropiate // Render nearby actions, unit self actions or vehicle self actions as appropiate
if (GVAR(openedMenuType) == 0) then { if (GVAR(openedMenuType) == 0) then {
if (isNull curatorCamera) then { if (isNull curatorCamera) then {
if (!(isNull (ACE_controlledUAV select 0))) then {
// Render UAV self actions when in control of UAV AI
(ACE_controlledUAV select 0) call _fnc_renderSelfActions;
} else {
if (vehicle ACE_player == ACE_player) then { if (vehicle ACE_player == ACE_player) then {
if (diag_tickTime > GVAR(lastTimeSearchedActions) + 0.20) then { if (diag_tickTime > GVAR(lastTimeSearchedActions) + 0.20) then {
// Once every 0.2 secs, collect nearby objects active and visible action points and render them // Once every 0.2 secs, collect nearby objects active and visible action points and render them
@ -142,6 +146,7 @@ if (GVAR(openedMenuType) == 0) then {
// Render vehicle self actions when in vehicle // Render vehicle self actions when in vehicle
(vehicle ACE_player) call _fnc_renderSelfActions; (vehicle ACE_player) call _fnc_renderSelfActions;
}; };
};
} else { } else {
// Render zeus actions when zeus open // Render zeus actions when zeus open
(getAssignedCuratorLogic player) call _fnc_renderZeusActions; (getAssignedCuratorLogic player) call _fnc_renderZeusActions;

View File

@ -37,7 +37,7 @@ private _pos = if((count _this) > 2) then {
// For non-self actions, exit if the action is too far away or ocluded // For non-self actions, exit if the action is too far away or ocluded
private _distanceToBasePoint = 0; //This will be 0 for self/zeus/in-vehicle (used later to check sub action distance) private _distanceToBasePoint = 0; //This will be 0 for self/zeus/in-vehicle (used later to check sub action distance)
if ((GVAR(openedMenuType) == 0) && {vehicle ACE_player == ACE_player} && {isNull curatorCamera} && if ((GVAR(openedMenuType) == 0) && {isNull (ACE_controlledUAV select 0)} && {vehicle ACE_player == ACE_player} && {isNull curatorCamera} &&
{ {
private _headPos = ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot"); private _headPos = ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot");
_distanceToBasePoint = _headPos distance _pos; _distanceToBasePoint = _headPos distance _pos;

View File

@ -24,6 +24,7 @@ if ((!alive ACE_player) || {!([ACE_player, vehicle ACE_player, []] call EFUNC(co
private _currentShooter = objNull; private _currentShooter = objNull;
private _currentWeapon = ""; private _currentWeapon = "";
if (isNull (ACE_controlledUAV param [0, objNull])) then {
if (ACE_player call CBA_fnc_canUseWeapon) then { if (ACE_player call CBA_fnc_canUseWeapon) then {
_currentShooter = ACE_player; _currentShooter = ACE_player;
_currentWeapon = currentWeapon ACE_player; _currentWeapon = currentWeapon ACE_player;
@ -32,6 +33,11 @@ if (ACE_player call CBA_fnc_canUseWeapon) then {
private _turretPath = if (ACE_player == (driver _currentShooter)) then {[-1]} else {ACE_player call CBA_fnc_turretPath}; private _turretPath = if (ACE_player == (driver _currentShooter)) then {[-1]} else {ACE_player call CBA_fnc_turretPath};
_currentWeapon = _currentShooter currentWeaponTurret _turretPath; _currentWeapon = _currentShooter currentWeaponTurret _turretPath;
}; };
} else {
_currentShooter = ACE_controlledUAV select 0;
private _turretPath = ACE_controlledUAV select 2;
_currentWeapon = _currentShooter currentWeaponTurret _turretPath;
};
TRACE_2("",_currentShooter,_currentWeapon); TRACE_2("",_currentShooter,_currentWeapon);
if (((getNumber (configFile >> "CfgWeapons" >> _currentWeapon >> "laser")) == 0) && if (((getNumber (configFile >> "CfgWeapons" >> _currentWeapon >> "laser")) == 0) &&

View File

@ -24,6 +24,7 @@ if (!([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith))
private ["_currentShooter", "_currentMagazine"]; private ["_currentShooter", "_currentMagazine"];
if (isNull (ACE_controlledUAV param [0, objNull])) then {
if (((vehicle ACE_player) == ACE_player) || {ACE_player call CBA_fnc_canUseWeapon}) then { if (((vehicle ACE_player) == ACE_player) || {ACE_player call CBA_fnc_canUseWeapon}) then {
_currentShooter = ACE_player; _currentShooter = ACE_player;
_currentMagazine = currentMagazine ACE_player; _currentMagazine = currentMagazine ACE_player;
@ -32,6 +33,12 @@ if (((vehicle ACE_player) == ACE_player) || {ACE_player call CBA_fnc_canUseWeapo
private _turretPath = if (ACE_player == (driver _currentShooter)) then {[-1]} else {ACE_player call CBA_fnc_turretPath}; private _turretPath = if (ACE_player == (driver _currentShooter)) then {[-1]} else {ACE_player call CBA_fnc_turretPath};
_currentMagazine = _currentShooter currentMagazineTurret _turretPath; _currentMagazine = _currentShooter currentMagazineTurret _turretPath;
}; };
} else {
_currentShooter = ACE_controlledUAV select 0;
private _turretPath = ACE_controlledUAV select 2;
_currentMagazine = _currentShooter currentMagazineTurret _turretPath;
};
if (_currentMagazine == "") exitWith {TRACE_1("no magazine",_currentMagazine)}; if (_currentMagazine == "") exitWith {TRACE_1("no magazine",_currentMagazine)};
private _ammo = getText (configFile >> "CfgMagazines" >> _currentMagazine >> "ammo"); private _ammo = getText (configFile >> "CfgMagazines" >> _currentMagazine >> "ammo");