mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Dragging - Minor code cleanup (#9859)
* Dragging minor code cleanup * Update fnc_startCarryPFH.sqf * Revert UAV changes
This commit is contained in:
parent
5ca81b7ef3
commit
a8ed533004
@ -68,6 +68,3 @@ if (_UAVCrew isNotEqualTo []) then {
|
|||||||
|
|
||||||
// Check everything
|
// Check everything
|
||||||
[FUNC(carryObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
|
[FUNC(carryObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
// Reset current dragging height
|
|
||||||
GVAR(currentHeightChange) = 0;
|
|
||||||
|
@ -35,16 +35,36 @@ if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
|
|||||||
_idPFH call CBA_fnc_removePerFrameHandler;
|
_idPFH call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Drop if the crate is destroyed OR target moved away from carrier (weapon disassembled) OR carrier starts limping
|
// Drop if the target is destroyed
|
||||||
if !(alive _target && {_unit distance _target <= 10} && {_unit getHitPointDamage "HitLegs" < 0.5}) exitWith {
|
if (!alive _target) exitWith {
|
||||||
TRACE_2("dead/distance",_unit,_target);
|
TRACE_2("dead",_unit,_target);
|
||||||
|
|
||||||
if ((_unit distance _target > 10) && {(CBA_missionTime - _startTime) < 1}) exitWith {
|
[_unit, _target] call FUNC(dropObject_carry);
|
||||||
|
|
||||||
|
_unit setVariable [QGVAR(hint), nil];
|
||||||
|
call EFUNC(interaction,hideMouseHint);
|
||||||
|
|
||||||
|
_idPFH call CBA_fnc_removePerFrameHandler;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Drop if the target moved away from carrier (e.g. weapon disassembled)
|
||||||
// attachTo seems to have some kind of network delay and target can return an odd position during the first few frames,
|
// attachTo seems to have some kind of network delay and target can return an odd position during the first few frames,
|
||||||
// So wait a full second to exit if out of range (this is critical as we would otherwise detach and set it's pos to weird pos)
|
// So wait a full second to exit if out of range (this is critical as we would otherwise detach and set it's pos to weird pos)
|
||||||
TRACE_3("ignoring bad distance at start",_unit distance _target,_startTime,CBA_missionTime);
|
if (_unit distance _target > 10 && {(CBA_missionTime - _startTime) >= 1}) exitWith {
|
||||||
|
TRACE_2("distance",_unit,_target);
|
||||||
|
|
||||||
|
[_unit, _target] call FUNC(dropObject_carry);
|
||||||
|
|
||||||
|
_unit setVariable [QGVAR(hint), nil];
|
||||||
|
call EFUNC(interaction,hideMouseHint);
|
||||||
|
|
||||||
|
_idPFH call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Drop if the carrier starts limping
|
||||||
|
if (_unit getHitPointDamage "HitLegs" >= 0.5) exitWith {
|
||||||
|
TRACE_2("limping",_unit,_target);
|
||||||
|
|
||||||
[_unit, _target] call FUNC(dropObject_carry);
|
[_unit, _target] call FUNC(dropObject_carry);
|
||||||
|
|
||||||
_unit setVariable [QGVAR(hint), nil];
|
_unit setVariable [QGVAR(hint), nil];
|
||||||
@ -54,7 +74,7 @@ if !(alive _target && {_unit distance _target <= 10} && {_unit getHitPointDamage
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Drop static if crew is in it (UAV crew deletion may take a few frames)
|
// 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 {
|
if (_target isKindOf "StaticWeapon" && {!(_target getVariable [QGVAR(isUAV), false])} && {(crew _target) isNotEqualTo []}) exitWith {
|
||||||
TRACE_2("static weapon crewed",_unit,_target);
|
TRACE_2("static weapon crewed",_unit,_target);
|
||||||
|
|
||||||
[_unit, _target] call FUNC(dropObject_carry);
|
[_unit, _target] call FUNC(dropObject_carry);
|
||||||
|
@ -57,7 +57,7 @@ GVAR(releaseActionID) = [0xF1, [false, false, false], {
|
|||||||
["", LLSTRING(Drop)] call EFUNC(interaction,showMouseHint);
|
["", LLSTRING(Drop)] call EFUNC(interaction,showMouseHint);
|
||||||
|
|
||||||
// Block firing
|
// Block firing
|
||||||
if !(GVAR(dragAndFire)) then {
|
if (!GVAR(dragAndFire)) then {
|
||||||
_unit setVariable [QGVAR(blockFire), [
|
_unit setVariable [QGVAR(blockFire), [
|
||||||
_unit, "DefaultAction",
|
_unit, "DefaultAction",
|
||||||
{true},
|
{true},
|
||||||
@ -70,6 +70,7 @@ if !(GVAR(dragAndFire)) then {
|
|||||||
|
|
||||||
// Prevent UAVs from firing
|
// Prevent UAVs from firing
|
||||||
private _UAVCrew = _target call EFUNC(common,getVehicleUAVCrew);
|
private _UAVCrew = _target call EFUNC(common,getVehicleUAVCrew);
|
||||||
|
|
||||||
if (_UAVCrew isNotEqualTo []) then {
|
if (_UAVCrew isNotEqualTo []) then {
|
||||||
{
|
{
|
||||||
_target deleteVehicleCrew _x;
|
_target deleteVehicleCrew _x;
|
||||||
@ -81,8 +82,5 @@ if (_UAVCrew isNotEqualTo []) then {
|
|||||||
// Check everything
|
// Check everything
|
||||||
[FUNC(dragObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
|
[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
|
// Fixes not being able to move when in combat pace
|
||||||
[_unit, "forceWalk", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
|
[_unit, "forceWalk", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
|
||||||
|
@ -31,15 +31,20 @@ if !(_unit getVariable [QGVAR(isDragging), false]) exitWith {
|
|||||||
_idPFH call CBA_fnc_removePerFrameHandler;
|
_idPFH call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Drop if the crate is destroyed OR (target moved away from carrier (weapon disasembled))
|
// Drop if the target is destroyed
|
||||||
if (!alive _target || {_unit distance _target > 10}) then {
|
if (!alive _target) exitWith {
|
||||||
TRACE_2("dead/distance",_unit,_target);
|
TRACE_2("dead",_unit,_target);
|
||||||
|
|
||||||
if ((_unit distance _target > 10) && {(CBA_missionTime - _startTime) < 1}) exitWith {
|
[_unit, _target] call FUNC(dropObject);
|
||||||
|
|
||||||
|
_idPFH call CBA_fnc_removePerFrameHandler;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Drop if the target moved away from carrier (e.g. weapon disassembled)
|
||||||
// attachTo seems to have some kind of network delay and target can return an odd position during the first few frames,
|
// attachTo seems to have some kind of network delay and target can return an odd position during the first few frames,
|
||||||
// So wait a full second to exit if out of range (this is critical as we would otherwise detach and set it's pos to weird pos)
|
// So wait a full second to exit if out of range (this is critical as we would otherwise detach and set it's pos to weird pos)
|
||||||
TRACE_3("ignoring bad distance at start",_unit distance _target,_startTime,CBA_missionTime);
|
if (_unit distance _target > 10 && {(CBA_missionTime - _startTime) >= 1}) exitWith {
|
||||||
};
|
TRACE_2("distance",_unit,_target);
|
||||||
|
|
||||||
[_unit, _target] call FUNC(dropObject);
|
[_unit, _target] call FUNC(dropObject);
|
||||||
|
|
||||||
@ -47,7 +52,7 @@ if (!alive _target || {_unit distance _target > 10}) then {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Drop static if crew is in it (UAV crew deletion may take a few frames)
|
// 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 {
|
if (_target isKindOf "StaticWeapon" && {!(_target getVariable [QGVAR(isUAV), false])} && {(crew _target) isNotEqualTo []}) exitWith {
|
||||||
TRACE_2("static weapon crewed",_unit,_target);
|
TRACE_2("static weapon crewed",_unit,_target);
|
||||||
|
|
||||||
[_unit, _target] call FUNC(dropObject);
|
[_unit, _target] call FUNC(dropObject);
|
||||||
|
@ -26,7 +26,7 @@ if (!isNil QGVAR(releaseActionID)) then {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Stop blocking
|
// Stop blocking
|
||||||
if !(GVAR(dragAndFire)) then {
|
if (!GVAR(dragAndFire)) then {
|
||||||
[_unit, "DefaultAction", _unit getVariable [QGVAR(blockFire), -1]] call EFUNC(common,removeActionEventHandler);
|
[_unit, "DefaultAction", _unit getVariable [QGVAR(blockFire), -1]] call EFUNC(common,removeActionEventHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -82,6 +82,8 @@ if (_unit getVariable ["ACE_isUnconscious", false]) then {
|
|||||||
|
|
||||||
// Recreate UAV crew (add a frame delay or this may cause the vehicle to be moved to [0,0,0])
|
// 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 {
|
if (_target getVariable [QGVAR(isUAV), false]) then {
|
||||||
|
_target setVariable [QGVAR(isUAV), nil, true];
|
||||||
|
|
||||||
[{
|
[{
|
||||||
params ["_target"];
|
params ["_target"];
|
||||||
if (!alive _target) exitWith {};
|
if (!alive _target) exitWith {};
|
||||||
|
@ -88,6 +88,8 @@ if !(_target isKindOf "CAManBase") then {
|
|||||||
|
|
||||||
// Recreate UAV crew (add a frame delay or this may cause the vehicle to be moved to [0,0,0])
|
// 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 {
|
if (_target getVariable [QGVAR(isUAV), false]) then {
|
||||||
|
_target setVariable [QGVAR(isUAV), nil, true];
|
||||||
|
|
||||||
[{
|
[{
|
||||||
params ["_target"];
|
params ["_target"];
|
||||||
if (!alive _target) exitWith {};
|
if (!alive _target) exitWith {};
|
||||||
|
@ -27,7 +27,7 @@ private _carriedItem = _unit getVariable [QGVAR(carriedObject), objNull];
|
|||||||
// Disabled for persons
|
// Disabled for persons
|
||||||
if (_carriedItem isKindOf "CAManBase") exitWith {false};
|
if (_carriedItem isKindOf "CAManBase") exitWith {false};
|
||||||
|
|
||||||
if !(CBA_events_control) then {
|
if (!CBA_events_control) then {
|
||||||
// Raise/lower
|
// Raise/lower
|
||||||
// Move carried item 15 cm per scroll interval
|
// Move carried item 15 cm per scroll interval
|
||||||
_scrollAmount = _scrollAmount * 0.15;
|
_scrollAmount = _scrollAmount * 0.15;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
params ["_unit"];
|
params ["_unit"];
|
||||||
|
|
||||||
// If not dragging, don't do anything
|
// If not carrying, don't do anything
|
||||||
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {};
|
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {};
|
||||||
|
|
||||||
// If action is already present, don't add it again
|
// If action is already present, don't add it again
|
||||||
|
@ -49,7 +49,7 @@ if (_target isKindOf "CAManBase") then {
|
|||||||
_primaryWeapon = "ACE_FakePrimaryWeapon";
|
_primaryWeapon = "ACE_FakePrimaryWeapon";
|
||||||
};
|
};
|
||||||
|
|
||||||
// Select primary, otherwise the drag animation actions don't work
|
// Select primary, otherwise the carry animation actions don't work
|
||||||
_unit selectWeapon _primaryWeapon;
|
_unit selectWeapon _primaryWeapon;
|
||||||
|
|
||||||
// Move a bit closer and adjust direction when trying to pick up a person
|
// Move a bit closer and adjust direction when trying to pick up a person
|
||||||
|
@ -32,9 +32,9 @@ if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
|
|||||||
_idPFH call CBA_fnc_removePerFrameHandler;
|
_idPFH call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Same as dragObjectPFH, checks if object is deleted or dead OR (target moved away from carrier (weapon disasembled))
|
// Drop if the target is destroyed, if the target moved away from carrier (e.g. weapon disassembled) or if the carrier starts limping
|
||||||
if (!alive _target || {_unit distance _target > 10}) then {
|
if !(alive _target && {_unit distance _target <= 10} && {_unit getHitPointDamage "HitLegs" < 0.5}) exitWith {
|
||||||
TRACE_4("dead/distance",_unit,_target,_timeOut,CBA_missionTime);
|
TRACE_4("dead/distance/limping",_unit,_target,_timeOut,CBA_missionTime);
|
||||||
[_unit, _target] call FUNC(dropObject_carry);
|
[_unit, _target] call FUNC(dropObject_carry);
|
||||||
|
|
||||||
_idPFH call CBA_fnc_removePerFrameHandler;
|
_idPFH call CBA_fnc_removePerFrameHandler;
|
||||||
@ -42,7 +42,7 @@ if (!alive _target || {_unit distance _target > 10}) then {
|
|||||||
|
|
||||||
// Handle persons vs. objects
|
// Handle persons vs. objects
|
||||||
if (_target isKindOf "CAManBase") then {
|
if (_target isKindOf "CAManBase") then {
|
||||||
// Drop if in timeout
|
// Carry person after timeout (animation takes a long time to finish)
|
||||||
if (CBA_missionTime > _timeOut) exitWith {
|
if (CBA_missionTime > _timeOut) exitWith {
|
||||||
TRACE_4("Start carry person",_unit,_target,_timeOut,CBA_missionTime);
|
TRACE_4("Start carry person",_unit,_target,_timeOut,CBA_missionTime);
|
||||||
[_unit, _target] call FUNC(carryObject);
|
[_unit, _target] call FUNC(carryObject);
|
||||||
@ -50,7 +50,7 @@ if (_target isKindOf "CAManBase") then {
|
|||||||
_idPFH call CBA_fnc_removePerFrameHandler;
|
_idPFH call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// Drop if in timeout
|
// Timeout: Drop target. CBA_missionTime, because anim length is linked to ingame time
|
||||||
if (CBA_missionTime > _timeOut) exitWith {
|
if (CBA_missionTime > _timeOut) exitWith {
|
||||||
TRACE_4("timeout",_unit,_target,_timeOut,CBA_missionTime);
|
TRACE_4("timeout",_unit,_target,_timeOut,CBA_missionTime);
|
||||||
_idPFH call CBA_fnc_removePerFrameHandler;
|
_idPFH call CBA_fnc_removePerFrameHandler;
|
||||||
|
@ -40,7 +40,7 @@ if (_weight > GETMVAR(ACE_maxWeightDrag,1E11)) exitWith {
|
|||||||
private _primaryWeapon = primaryWeapon _unit;
|
private _primaryWeapon = primaryWeapon _unit;
|
||||||
|
|
||||||
// Add a primary weapon if the unit has none
|
// Add a primary weapon if the unit has none
|
||||||
if !(GVAR(dragAndFire)) then {
|
if (!GVAR(dragAndFire)) then {
|
||||||
if (_primaryWeapon == "") then {
|
if (_primaryWeapon == "") then {
|
||||||
_unit addWeapon "ACE_FakePrimaryWeapon";
|
_unit addWeapon "ACE_FakePrimaryWeapon";
|
||||||
_primaryWeapon = "ACE_FakePrimaryWeapon";
|
_primaryWeapon = "ACE_FakePrimaryWeapon";
|
||||||
|
@ -32,15 +32,15 @@ if !(_unit getVariable [QGVAR(isDragging), false]) exitWith {
|
|||||||
_idPFH call CBA_fnc_removePerFrameHandler;
|
_idPFH call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Same as dragObjectPFH, checks if object is deleted, dead or target moved away from carrier (e.g. weapon disassembled)
|
// Drop if the target is destroyed or if the target moved away from carrier (e.g. weapon disassembled)
|
||||||
if (!alive _target || {_unit distance _target > 10}) then {
|
if (!alive _target || {_unit distance _target > 10}) exitWith {
|
||||||
TRACE_4("dead/distance",_unit,_target,_timeOut,CBA_missionTime);
|
TRACE_4("dead/distance",_unit,_target,_timeOut,CBA_missionTime);
|
||||||
[_unit, _target] call FUNC(dropObject);
|
[_unit, _target] call FUNC(dropObject);
|
||||||
|
|
||||||
_idPFH call CBA_fnc_removePerFrameHandler;
|
_idPFH call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Timeout: Do nothing, quit. CBA_missionTime, because anim length is linked to ingame time
|
// Timeout: Drop target. CBA_missionTime, because anim length is linked to ingame time
|
||||||
if (CBA_missionTime > _timeOut) exitWith {
|
if (CBA_missionTime > _timeOut) exitWith {
|
||||||
TRACE_4("timeout",_unit,_target,_timeOut,CBA_missionTime);
|
TRACE_4("timeout",_unit,_target,_timeOut,CBA_missionTime);
|
||||||
_idPFH call CBA_fnc_removePerFrameHandler;
|
_idPFH call CBA_fnc_removePerFrameHandler;
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
[LSTRING(allowRunWithLightweight_DisplayName), LSTRING(allowRunWithLightweight_Description)],
|
[LSTRING(allowRunWithLightweight_DisplayName), LSTRING(allowRunWithLightweight_Description)],
|
||||||
LLSTRING(SettingsName),
|
LLSTRING(SettingsName),
|
||||||
true,
|
true,
|
||||||
true
|
1
|
||||||
] call CBA_fnc_addSetting;
|
] call CBA_fnc_addSetting;
|
||||||
|
|
||||||
[
|
[
|
||||||
@ -30,5 +30,5 @@
|
|||||||
[LSTRING(skipContainerWeight_DisplayName), LSTRING(skipContainerWeight_Description)],
|
[LSTRING(skipContainerWeight_DisplayName), LSTRING(skipContainerWeight_Description)],
|
||||||
LLSTRING(SettingsName),
|
LLSTRING(SettingsName),
|
||||||
false,
|
false,
|
||||||
true
|
1
|
||||||
] call CBA_fnc_addSetting;
|
] call CBA_fnc_addSetting;
|
||||||
|
Loading…
Reference in New Issue
Block a user