Dragging - Prevent carrying crewed static weapons (#9491)

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
Grim 2023-10-23 13:21:50 -04:00 committed by GitHub
parent 5bf46245b2
commit f35f872963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 20 deletions

View File

@ -55,12 +55,6 @@ _unit setVariable [QGVAR(releaseActionID), [
// Add anim changed EH
[_unit, "AnimChanged", FUNC(handleAnimChanged), [_unit]] call CBA_fnc_addBISEventHandler;
// Check everything
[FUNC(carryObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
// Reset current dragging height
GVAR(currentHeightChange) = 0;
// Prevent UAVs from firing
private _UAVCrew = _target call EFUNC(common,getVehicleUAVCrew);
@ -71,3 +65,9 @@ if (_UAVCrew isNotEqualTo []) then {
_target setVariable [QGVAR(isUAV), true, true];
};
// Check everything
[FUNC(carryObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
// Reset current dragging height
GVAR(currentHeightChange) = 0;

View File

@ -53,6 +53,18 @@ if !(alive _target && {_unit distance _target <= 10} && {_unit getHitPointDamage
_idPFH call CBA_fnc_removePerFrameHandler;
};
// Drop static if crew is in it (UAV crew deletion may take a few frames)
if (_target isKindOf "StaticWeapon" && {(crew _target) isNotEqualTo []} && {!(_target getVariable [QGVAR(isUAV), false])}) then {
TRACE_2("static weapon crewed",_unit,_target);
[_unit, _target] call FUNC(dropObject_carry);
_unit setVariable [QGVAR(hint), nil];
call EFUNC(interaction,hideMouseHint);
_idPFH call CBA_fnc_removePerFrameHandler;
};
private _previousHint = _unit getVariable [QGVAR(hint), []];
// If paused, don't show mouse button hints

View File

@ -68,18 +68,8 @@ if !(GVAR(dragAndFire)) then {
// Add anim changed EH
[_unit, "AnimChanged", FUNC(handleAnimChanged), [_unit]] call CBA_fnc_addBISEventHandler;
// Check everything
[FUNC(dragObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
// Reset current dragging height.
GVAR(currentHeightChange) = 0;
// Prevent UAVs from firing
private _UAVCrew = _target call EFUNC(common,getVehicleUAVCrew);
// Fixes not being able to move when in combat pace
[_unit, "forceWalk", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
if (_UAVCrew isNotEqualTo []) then {
{
_target deleteVehicleCrew _x;
@ -87,3 +77,12 @@ if (_UAVCrew isNotEqualTo []) then {
_target setVariable [QGVAR(isUAV), true, true];
};
// Check everything
[FUNC(dragObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
// Reset current dragging height.
GVAR(currentHeightChange) = 0;
// Fixes not being able to move when in combat pace
[_unit, "forceWalk", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);

View File

@ -45,3 +45,15 @@ if (!alive _target || {_unit distance _target > 10}) then {
_idPFH call CBA_fnc_removePerFrameHandler;
};
// Drop static if crew is in it (UAV crew deletion may take a few frames)
if (_target isKindOf "StaticWeapon" && {(crew _target) isNotEqualTo []} && {!(_target getVariable [QGVAR(isUAV), false])}) then {
TRACE_2("static weapon crewed",_unit,_target);
[_unit, _target] call FUNC(dropObject);
_unit setVariable [QGVAR(hint), nil];
call EFUNC(interaction,hideMouseHint);
_idPFH call CBA_fnc_removePerFrameHandler;
};

View File

@ -80,9 +80,14 @@ if (_unit getVariable ["ACE_isUnconscious", false]) then {
[_unit, "unconscious", 2] call EFUNC(common,doAnimation);
};
// Recreate UAV crew
// Recreate UAV crew (add a frame delay or this may cause the vehicle to be moved to [0,0,0])
if (_target getVariable [QGVAR(isUAV), false]) then {
createVehicleCrew _target;
[{
params ["_target"];
if (!alive _target) exitWith {};
TRACE_2("restoring uav crew",_target,getPosASL _target);
createVehicleCrew _target;
}, [_target]] call CBA_fnc_execNextFrame;
};
// Fixes not being able to move when in combat pace

View File

@ -77,9 +77,14 @@ if !(_target isKindOf "CAManBase") then {
[QEGVAR(common,fixFloating), _target, _target] call CBA_fnc_targetEvent;
};
// Recreate UAV crew
// Recreate UAV crew (add a frame delay or this may cause the vehicle to be moved to [0,0,0])
if (_target getVariable [QGVAR(isUAV), false]) then {
createVehicleCrew _target;
[{
params ["_target"];
if (!alive _target) exitWith {};
TRACE_2("restoring uav crew",_target,getPosASL _target);
createVehicleCrew _target;
}, [_target]] call CBA_fnc_execNextFrame;
};
// Reset mass