Dragging - Additional weight override parameter for setCarryable/setDraggable (#6780)

* Added weight override parameter to ace_dragging_fnc_setCarryable/setDraggable

- Additional optional parameter that ignores the `startCarry`/`startDrag` weight checks.
- Minor `==` to `isEqualto` replacements

* `count crew _target isEqualto -1` to `count crew _target isEqualto 0`

* Tab Replacement

- remove \t

* Reverted UAV check, Params formatting, Lazy Eval

* Update addons/dragging/functions/fnc_startCarry.sqf

Co-Authored-By: PiZZAD0X <509thparachuteinfantry@gmail.com>

* Update fnc_startDrag.sqf

* Remove beta suggestion extra line additions

* Update addons/dragging/functions/fnc_startDrag.sqf

Co-Authored-By: PiZZAD0X <509thparachuteinfantry@gmail.com>
This commit is contained in:
PiZZAD0X 2019-01-20 08:23:24 -08:00 committed by PabstMirror
parent c4655148e0
commit 13193d3e6d
9 changed files with 33 additions and 23 deletions

View File

@ -116,6 +116,7 @@ OnkelDisMaster <onkeldismaster@gmail.com>
Orbis2358 <mgkid3310@naver.com> Orbis2358 <mgkid3310@naver.com>
oscarmolinadev oscarmolinadev
PaxJaromeMalues <seemax1991@gmail.com> PaxJaromeMalues <seemax1991@gmail.com>
PiZZADOX <509thParachuteInfantry@gmail.com>
Phyma <sethramstrom@gmail.com> Phyma <sethramstrom@gmail.com>
pokertour pokertour
Professor <lukas.trneny@wo.cz> Professor <lukas.trneny@wo.cz>

View File

@ -8,7 +8,7 @@ class CfgPatches {
requiredVersion = REQUIRED_VERSION; requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interaction"}; requiredAddons[] = {"ace_interaction"};
author = ECSTRING(common,ACETeam); author = ECSTRING(common,ACETeam);
authors[] = {"Garth 'L-H' de Wet", "commy2"}; authors[] = {"Garth 'L-H' de Wet", "commy2", "PiZZADOX"};
url = ECSTRING(main,URL); url = ECSTRING(main,URL);
VERSION_CONFIG; VERSION_CONFIG;
}; };

View File

@ -27,4 +27,4 @@ if ((_unit getHitPointDamage "HitLegs") >= 0.5) exitWith {false};
// a static weapon has to be empty for dragging (ignore UAV AI) // a static weapon has to be empty for dragging (ignore UAV AI)
if (((typeOf _target) isKindOf "StaticWeapon") && {{(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"} count crew _target > 0}) exitWith {false}; if (((typeOf _target) isKindOf "StaticWeapon") && {{(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"} count crew _target > 0}) exitWith {false};
alive _target && {vehicle _target == _target} && {_target getVariable [QGVAR(canCarry), false]} && {animationState _target in ["", "unconscious"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})} alive _target && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canCarry), false]} && {animationState _target in ["", "unconscious"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})}

View File

@ -23,4 +23,4 @@ if !([_unit, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)) exi
// a static weapon has to be empty for dragging (ignore UAV AI) // a static weapon has to be empty for dragging (ignore UAV AI)
if ((typeOf _target) isKindOf "StaticWeapon" && {{(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"} count crew _target > 0}) exitWith {false}; if ((typeOf _target) isKindOf "StaticWeapon" && {{(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"} count crew _target > 0}) exitWith {false};
alive _target && {vehicle _target == _target} && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})}; alive _target && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})}

View File

@ -1,6 +1,6 @@
#include "script_component.hpp" #include "script_component.hpp"
/* /*
* Author: commy2 * Author: commy2, PiZZADOX
* Enable the object to be carried. * Enable the object to be carried.
* *
* Arguments: * Arguments:
@ -8,17 +8,19 @@
* 1: true to enable carrying, false to disable <BOOL> * 1: true to enable carrying, false to disable <BOOL>
* 2: Position offset for attachTo command <ARRAY> (default: [0,1,1]) * 2: Position offset for attachTo command <ARRAY> (default: [0,1,1])
* 3: Direction in degree to rotate the object after attachTo <NUMBER> (default: 0) * 3: Direction in degree to rotate the object after attachTo <NUMBER> (default: 0)
* 4: Override weight limit (optional; default: false) <BOOL>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* [object, true, [0,1,1], 0] call ace_dragging_fnc_setCarryable; * [object, true, [0,1,1], 0, false] call ace_dragging_fnc_setCarryable;
* *
* Public: Yes * Public: Yes
*/ */
params ["_object", "_enableCarry", "_position", "_direction"]; //IGNORE_PRIVATE_WARNING ["_player", "_target"];
params ["_object", "_enableCarry", "_position", "_direction", ["_ignoreWeightCarry", false, [false]]];
if (isNil "_position") then { if (isNil "_position") then {
_position = _object getVariable [QGVAR(carryPosition), [0,1,1]]; _position = _object getVariable [QGVAR(carryPosition), [0,1,1]];
@ -32,6 +34,7 @@ if (isNil "_direction") then {
_object setVariable [QGVAR(canCarry), _enableCarry]; _object setVariable [QGVAR(canCarry), _enableCarry];
_object setVariable [QGVAR(carryPosition), _position]; _object setVariable [QGVAR(carryPosition), _position];
_object setVariable [QGVAR(carryDirection), _direction]; _object setVariable [QGVAR(carryDirection), _direction];
_object setVariable [QGVAR(ignoreWeightCarry), _ignoreWeightCarry];
// add action to class if it is not already present // add action to class if it is not already present
private _type = typeOf _object; private _type = typeOf _object;

View File

@ -1,25 +1,26 @@
#include "script_component.hpp" #include "script_component.hpp"
/* /*
* Author: commy2 * Author: commy2, PiZZADOX
* Enable the object to be dragged. * Enable the object to be dragged.
* *
* Arguments: * Arguments:
* 0: Any object <OBJECT> * 0: Any object <OBJECT>
* 1: true to enable dragging, false to disable <BOOL> * 1: true to enable dragging, false to disable <BOOL>
* 2: Position offset for attachTo command (optinal; default: [0,0,0])<ARRAY> * 2: Position offset for attachTo command (optional; default: [0,0,0])<ARRAY>
* 3: Direction in degree to rotate the object after attachTo (optional; default: 0) <NUMBER> * 3: Direction in degree to rotate the object after attachTo (optional; default: 0) <NUMBER>
* 4: Override weight limit (optional; default: false) <BOOL>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* [object, true, [0,0,0], 0] call ace_dragging_fnc_setDraggable; * [object, true, [0,0,0], 0, false] call ace_dragging_fnc_setDraggable;
* *
* Public: Yes * Public: Yes
*/ */
//IGNORE_PRIVATE_WARNING ["_player", "_target"]; //IGNORE_PRIVATE_WARNING ["_player", "_target"];
params ["_object", "_enableDrag", "_position", "_direction"]; params ["_object", "_enableDrag", "_position", "_direction", ["_ignoreWeightDrag", false, [false]]];
if (isNil "_position") then { if (isNil "_position") then {
_position = _object getVariable [QGVAR(dragPosition), [0,0,0]]; _position = _object getVariable [QGVAR(dragPosition), [0,0,0]];
@ -33,6 +34,7 @@ if (isNil "_direction") then {
_object setVariable [QGVAR(canDrag), _enableDrag]; _object setVariable [QGVAR(canDrag), _enableDrag];
_object setVariable [QGVAR(dragPosition), _position]; _object setVariable [QGVAR(dragPosition), _position];
_object setVariable [QGVAR(dragDirection), _direction]; _object setVariable [QGVAR(dragDirection), _direction];
_object setVariable [QGVAR(ignoreWeightDrag), _ignoreWeightDrag];
// add action to class if it is not already present // add action to class if it is not already present
private _type = typeOf _object; private _type = typeOf _object;

View File

@ -1,6 +1,6 @@
#include "script_component.hpp" #include "script_component.hpp"
/* /*
* Author: commy2 * Author: commy2, PiZZADOX
* Start the carrying process. * Start the carrying process.
* *
* Arguments: * Arguments:
@ -19,10 +19,12 @@
params ["_unit", "_target"]; params ["_unit", "_target"];
TRACE_2("params",_unit,_target); TRACE_2("params",_unit,_target);
// check weight // exempt from weight check if object has override variable set
private _weight = [_target] call FUNC(getWeight); if (!GETVAR(_target,GVAR(ignoreWeightCarry),false) && {
private _weight = [_target] call FUNC(getWeight);
if (_weight > missionNamespace getVariable ["ACE_maxWeightCarry", 1E11]) exitWith { _weight > GETMVAR(ACE_maxWeightCarry,1E11)
}) exitWith {
// exit if object weight is over global var value
[localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured); [localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
}; };
@ -32,7 +34,7 @@ private _timer = CBA_missionTime + 5;
if (_target isKindOf "CAManBase") then { if (_target isKindOf "CAManBase") then {
// add a primary weapon if the unit has none. // add a primary weapon if the unit has none.
if (primaryWeapon _unit == "") then { if (primaryWeapon _unit isEqualto "") then {
_unit addWeapon "ACE_FakePrimaryWeapon"; _unit addWeapon "ACE_FakePrimaryWeapon";
}; };

View File

@ -58,7 +58,7 @@ if (_target isKindOf "CAManBase") then {
}; };
// wait for the unit to stand up // wait for the unit to stand up
if (stance _unit == "STAND") exitWith { if (stance _unit isEqualto "STAND") exitWith {
TRACE_4("Start carry object",_unit,_target,_timeOut,CBA_missionTime); TRACE_4("Start carry object",_unit,_target,_timeOut,CBA_missionTime);
[_unit, _target] call FUNC(carryObject); [_unit, _target] call FUNC(carryObject);

View File

@ -1,6 +1,6 @@
#include "script_component.hpp" #include "script_component.hpp"
/* /*
* Author: commy2 * Author: commy2, PiZZADOX
* Start the dragging process. * Start the dragging process.
* *
* Arguments: * Arguments:
@ -19,16 +19,18 @@
params ["_unit", "_target"]; params ["_unit", "_target"];
TRACE_2("params",_unit,_target); TRACE_2("params",_unit,_target);
// check weight // exempt from weight check if object has override variable set
private _weight = [_target] call FUNC(getWeight); if (!GETVAR(_target,GVAR(ignoreWeightDrag),false) && {
private _weight = [_target] call FUNC(getWeight);
if (_weight > missionNamespace getVariable ["ACE_maxWeightDrag", 1E11]) exitWith { _weight > GETMVAR(ACE_maxWeightDrag,1E11)
}) exitWith {
// exit if object weight is over global var value
[localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured); [localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
}; };
// add a primary weapon if the unit has none. // add a primary weapon if the unit has none.
// @todo prevent opening inventory when equipped with a fake weapon // @todo prevent opening inventory when equipped with a fake weapon
if (primaryWeapon _unit == "") then { if (primaryWeapon _unit isEqualto "") then {
_unit addWeapon "ACE_FakePrimaryWeapon"; _unit addWeapon "ACE_FakePrimaryWeapon";
}; };